Skip to content

fix(mcpx): revive exited supervised child on spawn-intent re-dial (#17226) - #17310

Merged
developing-today-fleet[bot] merged 10 commits into
mainfrom
xaltha/17226-era-probe-race
Nov 30, 2026
Merged

developing-today-fleet[bot] merged 10 commits into
mainfrom
xaltha/17226-era-probe-race

Conversation

@developing-today-fleet

@developing-today-fleet developing-today-fleet Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #17226

Root cause

Slice 2 of the #17221 nightly stress failure (macOS e2e TestTheEraIsProbedOnceAndRememberedAcrossDaemonRestarts/…/legacy-exiting-on-discover-is-reached, era_test.go:118):

  1. The pool's era probe sends server/discover; a legacy server that exits on any first message but initialize (testsupport/eramcp legacy-exit) dies, so the probe returns ErrClosedDuringProbe.
  2. Pool recovery closes the probe transport and re-dials (spawn intent) for the ForceLegacy retry.
  3. The re-dial's ordinary supervisor attach is a reporting handshake: when it lands while the supervisor is still serving the dead child's exit report (the mcpx e2e remainder from #15689: TestRestartReportsAServerThatDoesNotComeBack + TestDaemonWarmReadsTheServersAtStartupFromTheEnvironment (run 46259867572) #16797 grace), the transport is born exited — SupervisedTransport.exited is set at attach and never updated.
  4. The recovery's initialize is refused by the dead transport itself: initialize: write to …/eramcp (supervised): child already exited: exit status 1. Start fails → pool failCount=1 → 2s restart cooldown → the call trips over the cooldown (1.999s in the nightly log).

The window is the gap between the supervisor recording the exit and finishing its exit-report shutdown; under macOS stress the supervisor's exit path is delayed enough for the re-dial to land inside it. The pool-level probe test passes because it uses direct stdio (no supervisor).

Fix

newSupervised (the spawn-intent dial; its only production caller is the pool's dialSpawn): when the initial attach succeeds but the transport is born exited, close it and revive the child through the supervisor's existing restart handshake action (#9963: an exited child is simply revived), retrying briefly while the reporting detach is processed. If the supervisor is gone or stays refused, fall through to the existing spawn path unchanged. Attach-only dials (AttachSupervised, restart dials) keep the reporting semantics — the exit report is a feature for observers, just not for a dial that needs a live child.

Regression test

TestSupervisedRedialAfterChildExitRevivesChild (internal/mcpclient): a hand-started supervisor runs exitchild (exits immediately); with no attach ever made, the supervisor parks in its never-attached wait holding the dead child, so a raw-handshake probe confirms childState="exited" and the dial lands in the reporting window deterministically. The test then requires Send to work and the revived child's frame to arrive.

Failing-first proof (test-only branch, no fix), remote run 46464462350:

supervised_test.go:378: send to revived child: write to … exitchild (supervised): child already exited: exit status 3

— the production error shape. With the fix: run 46464552018 passes.

Verification (remote dispatch, this branch on current main)

  • go test ./internal/mcpclient/ -race -shuffle=6839106235133155819 -count=3 (nightly seed) + gofmt + go vet — run 46465718752 ✅ (also: full TestSupervised* suite at -count=5, run 46456537008 ✅)
  • go test ./internal/pool/ -race -shuffle=6839106235133155819 -count=3 -run 'TestPoolProbe|TestEraCacheAcrossStarts|TestEraIdentity' — run 46465786079 ✅
  • go test ./internal/e2e/ -race -shuffle=6839106235133155819 -count=3 -run '^TestTheEraIsProbedOnceAndRememberedAcrossDaemonRestarts$' — run 46465851274 ✅

No quarantine, no seed pinning, no count reduction: the fix removes the born-dead transport at the seam where it is created.

{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-30T16:54:28Z",
    "session_id": null,
    "lane": null,
    "host": "htch-runtime",
    "worktree": "/home/hatch/workspace/github-work/code-17226",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/hatch/workspace/github-work/code-17226",
      "repo": "developing-today/code",
      "branch": "xaltha/17226-era-probe-race",
      "sha": "ff2c16d014d5c80827b5590deb69ce589f452a6c"
    },
    "auth_subject": "xaltha",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

#17226)

NewSupervised (the pool spawn dial) accepted a transport born exited
when its attach landed while the supervisor was still serving the
child exit report: every Send on it fails with "child already
exited". The era-probe recovery re-dials exactly then — the probe
discover has just killed a legacy server that exits on any first
message but initialize — so the ForceLegacy retry initialize was
refused by the dead transport itself, the start failed, and the pool
restart cooldown failed the call (nightly run 46433738642, macOS
leg). A born-exited attach is now closed and retried through the
supervisor restart action, which revives the child (#9963); if the
supervisor is gone the dial falls through to the ordinary spawn.

Regression test: kill the child while unattached (the supervisor
then serves the exit report for its #16797 grace), re-dial, and
require a live echo from a new child pid.
@coderabbitai

coderabbitai Bot commented Nov 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 72000b3c-bb88-458a-8f60-f6653ccdf7ba

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@developing-today-fleet
developing-today-fleet Bot merged commit 7263825 into main Nov 30, 2026
2 checks passed
@developing-today-fleet
developing-today-fleet Bot deleted the xaltha/17226-era-probe-race branch November 30, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcpx era probe: initialize races a respawned legacy-exit server into restart cooldown (flake slice of #17221)

1 participant