← Back to Pull requests

fix(plugins): default stdio server cwd to the data root, not the package dir #136283

Open
unknown opened this pull request with 525 lines diff across 6 files
View on GitHub
unknown unknown commented on Oct 10, 2026 19:30 UTC
Author

What does this PR do?

A stdio MCP server declared by a plugin without a cwd field was translated with its cwd pinned to the plugin's own install directory (hermes_cli/agent_plugins.py::_translate_stdio). On Windows a live process's current directory cannot be renamed, so while that server ran, the rename-aside at the heart of every plugin update (pm/publication.py::StagedPlugin.publish, os.replace(target, backup)) failed with [WinError 32], the update rolled back, and the plugin stayed on its old revision (#136223).

This changes the default cwd to the per-plugin data root (plugin-data/<namespace>), which is the writable, package-external location loading already creates. The fix works for every operation that swaps the plugin tree (update, reinstall, disable/re-enable housekeeping), not just the reported plugins update path, and it needs no new coordination between the CLI publisher and the gateway process that owns the running server.

Explicit cwd values (./..., ${PLUGIN_ROOT}, ${PLUGIN_DATA}) are resolved exactly as before; packages that genuinely need to run inside their own tree can still configure that, at the cost of the same Windows rename pin. PLUGIN_ROOT / PLUGIN_DATA env vars keep pointing plugins at both trees.

Related Issue

Fixes #136223

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • Changes Made

  • hermes_cli/agent_plugins.py — _translate_stdio: when no cwd is configured, default to data_root instead of plugin_root, with a comment naming the Windows rename pin (#136223). The existing create_data branch already creates the data root on load, so the spawned server's cwd always exists.

  • tests/hermes_cli/test_agent_plugins.py — updated the default-cwd assertion in test_loads_manifest_skill_and_stdio_server and added test_stdio_default_cwd_stays_off_the_package_directory pinning the new default (cwd = data root, directory created, never the package dir).
  • How to Test

    1. pytest tests/hermes_cli/test_agent_plugins.py -q — Observed result: 48 passed. With the old default restored, test_loads_manifest_skill_and_stdio_server and test_stdio_default_cwd_stays_off_the_package_directory fail (red/green verified).
    2. pytest tests/hermes_cli/test_plugins.py tests/tui_gateway/test_plugins_manage_late_activation.py -q — Observed result: 88 passed.
    3. python scripts/check --base <merge-base with upstream/main> — Observed result: 11 checks, ok.
    4. Windows reproduction of the report (conceptually, per the issue): a plugin whose stdio server is running no longer holds the plugin directory as the server's cwd, so hermes plugins update <name> can rename the old tree aside and publish the new one.

    Checklist

    Code

  • I've read the Contributing Guide

  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)

  • I searched for existing PRs to make sure this isn't a duplicate

  • My PR contains only changes related to this fix/feature (no unrelated commits)

  • I've run pytest tests/ -q and all tests pass

  • python scripts/check passes (the blocking lint and code-health checks CI runs)

  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)

  • I've tested on my platform: macOS 15 (arm64); the Windows-specific failure mode is covered by the translated-cwd regression test
  • Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A

  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A

  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A

  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A

  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A
  • For New Skills

    N/A

    Diff: 525 lines (+393 / -132) across 6 files Reviewer: PRATHAMESH75 Review duration: 78066m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.55) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.55 · 525 lines diff across 6 files
    0.55
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.375
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #136283"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 54.8% (MEDIUM) · Higher = larger blast radius
    54.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 30.3% · Safe to merge
    30.3%