Repository navigation
fix: skip dead-pid proxy-origin records in MCP shell origin resolution (#405) - #522
Conversation
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-522Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr522.tgz
npm install -g packageThis comment is automatically updated on each push. |
|
Review vs master 3cd85b6: ✅ merge-ready.
Behavior question (non-blocking): when the dead record is skipped we dial 8787 by default; if the user runs the proxy on a custom port this still fails — but that was equally true pre-PR (dialing a dead origin), and the stderr note now tells them to set (tracking: #599) |
Confirmed your review independently against current master ( Your check covered
So it's merge-ready against current master, not just the pre-#527 base. (I ran typecheck + the directly-affected governance file, not the whole ~948-test suite — CI re-runs that on merge.) Behavior question — agreed, no action needed: the custom-port case was equally broken pre-PR (dialing a dead origin), and now at least emits an actionable Next step is yours to take — I can't merge (human-only per AGENTS.md). It's a content PR (no version bump, no lockfile), so on merge it lands on master and ships with the next release. |
Closes #599 — tracking issue for this PR.
Split from #514 (fix 1 of 5, the only part still a gap on master — see review there). Fixes #405 (MCP half).
What
resolveProxyOrigin()(src/mcp.ts) resolved env → instance file → default origin with no liveness check. When a proxy crashes or is killed, its JSON instance record stays behind naming a port nothing listens on — spawned MCP shells then dial the dead origin forever, and every tool call fails until the host client is restarted (or a new proxy happens to bind that exact port).Rebuilt on the
src/instance.tsprimitives (#394/#403/#417) rather than the HTTP-probe chain from #514:isPidAlive, kill(0) — synchronous, no network on the hot path) is trusted as today.http://127.0.0.1:8787, where a replacement proxy binds) with a one-time stderr note suggestingBILI_MCP_PROXYif the proxy runs elsewhere. Self-healing: the next tool call re-resolves, so a restarted proxy is picked up with no shell restart.pid: 0(record makes no liveness claim, foreign writer) and legacy plain-URL pointers keep the old trust semantics — deliberate asymmetry vs plugin-install, which refuses them.BILI_MCP_PROXYenv still wins over everything (operator intent).Why pid-check instead of #514's
/__bili/healthprobe: the JSON record already carries the writer's pid, the check is synchronous (probe would have to become async + cached), and it exactly matches how the launcher attach and plugin-install already gate on the same file.Tests
tests/instance-governance.test.ts: dead-pid JSON record → default origin (re-resolved on every call); live pid → record origin; pid 0 → trusted; stderr note fires once and mentions BILI_MCP_PROXY.
Pre-flight
resolveClientCommand: codex/claude resolve to themselvestest (machine has /usr/bin/codex), identical on clean master (baseline 946/947)Notes
BILI_MCP_PROXYenv pointing at a dead port still dial it — env is operator intent by design; recovery = repoint/reinstall.