Repository navigation
mcpx: serve the exited-child supervisor report for the whole grace (#16797) - #17060
Merged
Merged
Conversation
added 2 commits
November 30, 2026 02:44
… detach (#16797) TestSupervisorServesExitedReportForTheWholeGrace: a supervisor whose child already exited serves the exit report to a first attacher, and a second, racing attacher must collect the same report afterwards. On current code the supervisor exits on the first detach and removes its socket, so the second attach fails — the unit form of the restart failure on #16797, where a warm start and a restart fallback spawn race two NewSupervised calls for one socket and the loser burns its whole spawn timeout reporting 'did not attach' instead of the child's real failure.
…16797) finishWhenDone ended the supervisor as soon as the first reporting attach detached: the listener closed and the socket was removed. A second spawner racing for the same socket — the shape the restart path takes when a warm start and the restart's fallback spawn overlap — then had nothing to dial, and its spawn poll burned the full 20s timeout reporting 'supervisor did not attach' while the child's real failure (e.g. fakemcp's 'refusing to start') sat in a report nobody could still collect. The supervisor now keeps the listener up and keeps serving the same exited report until the first-attach grace (10s from the child's exit — the bound that already governed the never-attached case) runs out, then finishes as before. The attached-then-exited path (exit reaches a live daemon as EOF after the drain) is unchanged, and no new process can linger past the grace.
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
This was referenced Nov 30, 2026
Contributor
Author
|
Verification addendum (0640-GS) — the flake-doctrine dimensions not in the original gate:
|
This was referenced Nov 30, 2026
This was referenced Nov 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #16797
Root cause
Proven by instrumenting the spawn path (lane 0640-GS, after 0640-GV's diagnostic verdict isolated the defect to the restart path's supervisor spawn): when a supervised server's child has already exited, the supervisor served the exit report to the first attacher and
finishWhenDonethen ended the supervisor on that attacher's detach — listener closed, socket removed, all within ~15ms.A restart in a daemon whose warm start is still settling runs two
NewSupervisedcalls for the same socket (the warm start's, and pool.Restart's fallback spawn after its restart dial finds no live supervisor). The trace (daemon pid 14949): warm's call spawned supervisor 14959, whose instantly-refusing child was reported and consumed; the restart fallback spawned supervisor 14986 at 02:39:14.068, it listened and spawned its child — and warm's still-polling first call collected that supervisor's report at .092, so the supervisor exited at .093. The restart's own spawn poll then dialed a removed socket for the full 20s and reportedsupervisor did not attach within 20s, hiding the child's real failure (fakemcp: refusing to start). The same one-shot report loss hits any two spawners racing one socket, and any spawner whose first poll lands after its own supervisor's report was consumed.Change (2 commits)
TestSupervisorServesExitedReportForTheWholeGrace(internal/mcpclient): a supervisor with an already-exited child must serve the same exit report to a second attacher after the first reporter detaches, and must still finish when the grace runs out. Fails pre-fix:second attach after the first report: dial unix .../sup.sock: connect: no such file or directory(run 46342803920).finishWhenDone(internal/mcpclient/supervised.go): once the child's exit has been reported, the supervisor keeps the listener up and keeps serving the same report until the first-attach grace (10s from the child's exit — the bound that already governed the never-attached case) expires, then finishes as before. The attached-then-exited path (exit reaches a live daemon as EOF after the drain) is unchanged; nothing can linger past the grace.No new dependencies.
Gate (read from the job logs)
internal/mcpclientpackage ok (36.1s, incl. the new test and all supervisor lifecycle tests), fullinternal/poolpackage ok (122.8s), gofmt clean.TestRestartReportsAServerThatDoesNotComeBack's functional assertions pass (nodid not attach, no missing-stderr failure; runtime 113.21s → 30.47s, the remainder being the cleanup wait). The only failure lines left are the mcpx: e2e suite hangs intermittently on aarch64-darwin (different test each run; daemon-side, reload path) #16312 cleanup leaks (daemon(s) still alive 30s after stop), which are PR mcpx: zombie-aware liveness for daemon stop checks (#16312) #17040's mechanism, not this issue's.felix/16797-gate-stack@ 159ea86, deleted after gating) — run 46343690212: all green —TestRestartReportsAServerThatDoesNotComeBackPASS (0.39s),TestDaemonWarmReadsTheServersAtStartupFromTheEnvironmentPASS, all four otherTestRestart*PASS, package ok.Composition note for the merge: this PR and #17040 are independent and each merge-ready; the fully-green e2e state is the two together, in either order. The warm test's only failure without #17040 is the #16312 cleanup leak.
Lane 0640-GS (Felix). Merge is Felix's call.
{ "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-30T03:07:13Z", "session_id": null, "lane": null, "host": "htch-runtime", "worktree": "/home/hatch", "model": null, "lane_start_issues": [], "workspace_ref": { "kind": "worktree", "id": "/home/hatch", "repo": "developing-today/code", "branch": "main", "sha": "010b47d1c4cecdcd1b7d6ea260b7c9b0a61fb89e" }, "auth_subject": "felix", "stamped_by": "fleet 0.1.0 (native)" } }Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.