Skip to content

fix(mcpx): scan classifies a terminate dropped by an exiting supervisor as stale (#16639 part 1) - #16654

Merged
developing-today-fleet[bot] merged 2 commits into
mainfrom
xaltha/16639-supervisor-terminate-eof
Nov 29, 2026
Merged

developing-today-fleet[bot] merged 2 commits into
mainfrom
xaltha/16639-supervisor-terminate-eof

Conversation

@dezren39

@dezren39 dezren39 commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Closes #16639 (part 1; part 2 landed in #16641)

Problem

On darwin, the mcpx nix build's checkPhase failed nine internal/e2e
tests whose assertions had all passed — they failed at cleanup
(e2e_test.go:133) with:

cleanup: stop supervised servers: terminate supervisor /nix/var/nix/builds/.../sup-<id>.sock: supervisor terminate: EOF

(fleet-command run 46226123783 on main 9d3c4ffc9b.)

Root cause

The e2e cleanup first runs mcpx stop --all, which reaps every
supervisor (sends terminate), and then testsupport.StopSupervisors
scans the state dir and sends a second terminate to any socket
still present. A supervisor that accepted the first terminate
replies, then kills its child and exits — but until the child is
dead the listener stays open and the socket file stays on disk.
On darwin the child teardown is slow enough that the scan's second
terminate reliably lands inside that exit window: the dial succeeds
against the still-open listener, the supervisor process goes away
mid-handshake, and the reply read returns EOF (or the connection
resets / the write hits a broken pipe). terminateScanSocket
classified that as terminate-failed, and StopSupervisors
surfaced it as a cleanup error.

A live supervisor always answers a terminate — success or refusal —
so a dropped handshake means the supervisor is already gone or
going: for a reap, the goal is already met.

Fix

isStaleSocketErr in internal/mcpclient/supervised_scan.go now
also classifies io.EOF, ECONNRESET, and EPIPE from the
terminate handshake as stale, alongside the existing dial-side
signals (ECONNREFUSED, ENOTSOCK, not-exist). The scan removes
the socket file and reports stale-removed instead of
terminate-failed. No skip-list changes; no test was skipped.

Test

Failing-first: TestScanClassifiesExitingSupervisorAsStale in
supervised_phase3_test.go stands up a fake listener that accepts
the scan's connection and closes it without replying — the
clean-exit (EOF) shape and the reset shape. Before the fix it
reports terminate-failed / supervisor terminate: EOF; after,
stale-removed.

Verification

  • Failing-first (test only, head 8eae21c43): fleet-command run
    46241151672 — FAILURE as expected (exact output in the run log).
  • Fixed head: fleet-command Linux run — go test ./internal/mcpclient/ -count=1 plus the new test under
    -race -shuffle=on -count=5.
  • Acceptance (the issue's recorded repro): fleet-command macOS run
    — nix build .#packages.aarch64-darwin.mcpx --print-build-logs
    at the exact PR head; checkPhase passes with no
    supervisor terminate: EOF cleanup failures.
{
  "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-29T08:13:54Z",
    "session_id": null,
    "lane": null,
    "host": "htch-runtime",
    "worktree": "/home/hatch/workspace/github-work/code-16639",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/hatch/workspace/github-work/code-16639",
      "repo": "developing-today/code",
      "branch": "xaltha/16639-supervisor-terminate-eof",
      "sha": "12dd3b32db45d348d38bdefa772cc6ffee96f780"
    },
    "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.

…#16639)

Failing-first for part 1 of #16639: a supervisor already exiting
after an earlier terminate drops the scan's second terminate
handshake without replying, and the scan reports terminate-failed
(supervisor terminate: EOF) instead of stale. The new test stands
up a fake listener that accepts and closes without replying, in
both the clean-exit (EOF) and reset shapes.
…or as stale (#16639)

A supervisor that accepted an earlier terminate replies, then
kills its child and exits — but its listener and socket file
outlive the reply until the child is dead. A second terminate in
that window (the adopt-or-reap scan after mcpx stop --all already
reaped) dials the still-open listener and the supervisor process
goes away mid-handshake: the reply read sees EOF, a reset, or a
broken pipe. isStaleSocketErr now classifies those alongside the
dial-side gone signals, so the scan reports stale-removed instead
of terminate-failed. A live supervisor always answers a terminate
(success or refusal), so a dropped handshake never classifies a
live supervisor as stale. Fixes the nine darwin e2e cleanup
failures in run 46226123783 (supervisor terminate: EOF).
@coderabbitai

coderabbitai Bot commented Nov 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 51 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

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: 30538f2c-5824-4989-a619-d3e1802d1d7f
Commits

Reviewing files that changed from the base of the PR and between 7e05284 and 12dd3b3.

Files selected for processing: 2

  • pkgs/mcpx/internal/mcpclient/supervised_phase3_test.go
  • pkgs/mcpx/internal/mcpclient/supervised_scan.go
  • 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

@dezren39

Copy link
Copy Markdown
Member Author

Lane 0156-W-E verification dispatched at head 12dd3b32db45d348d38bdefa772cc6ffee96f780:

  • Failing-first evidence (test-only head 8eae21c43): fleet-command run 46241151672 — FAILURE with the exact production signatures: terminate-failed / supervisor terminate: EOF (close-after-read) and connection reset by peer (close-unread).
  • Linux package verification: run 46241666132 — new test under -race -shuffle=on -count=5 + full internal/mcpclient package.
  • Acceptance (issue's recorded repro): macOS run 46241670368 — nix build .#packages.aarch64-darwin.mcpx --print-build-logs.

Merge only on concluded SUCCESS at this exact head.

@dezren39

Copy link
Copy Markdown
Member Author

Verification update at head 12dd3b32d:

  • Linux run 46241666132: SUCCESS — new test green under -race -shuffle=on -count=5, full internal/mcpclient package green.
  • macOS acceptance run 46241670368: FAILURE, but the mcpx darwin: nix checkPhase fails — supervisor terminate EOF cluster + unix socket path bind failure #16639 part-1 signature is eliminated — zero supervisor terminate: EOF occurrences in the build log (was 9), and 7 of the 9 named tests now pass outright. Three e2e tests fail on different, non-cleanup assertions: TestDaemonWarmReadsTheServersAtStartupFromTheEnvironment (effect_test.go:4083), TestEveryToolInToolsListIsReachableFromAScript (toolparity_test.go:72), TestRestartReportsAServerThatDoesNotComeBack (cliops_test.go:584).
  • Baseline control dispatched: run 46244362018 — identical command on this branch's base commit 4a8555aa9 (current main at branch time) to determine whether those three failures pre-date this change. Merge decision waits on that comparison.

@developing-today-fleet

Copy link
Copy Markdown
Contributor

Lane 0252-C (bravo SUSTAIN landings) — merging on full-diff verification. Diff read in full (2 files, +70/-1): isStaleSocketErr now also classifies io.EOF/ECONNRESET/EPIPE from the terminate handshake as stale, with the rationale recorded in-code; new failing-first test TestScanClassifiesExitingSupervisorAsStale covers the clean-exit (EOF) and reset shapes. Matches the PR's stated fix for #16639 part 1 exactly; no unrelated changes. CI is not a gate per Drew's 2026-11-29 rule; post-merge failures get fixed forward.

@developing-today-fleet
developing-today-fleet Bot merged commit afb11ae into main Nov 29, 2026
2 checks passed
@developing-today-fleet
developing-today-fleet Bot deleted the xaltha/16639-supervisor-terminate-eof branch November 29, 2026 08:58
@dezren39

Copy link
Copy Markdown
Member Author

Final verification record (lane 0156-W-E): the baseline control has now concluded and confirms the merge adjudication.

Merged at exact head 12dd3b32d (merge commit afb11aeb1); #16639 auto-closed. Part 1 of #16639 is complete: the supervisor-terminate EOF cleanup cluster no longer fails darwin checkPhase.

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 darwin: nix checkPhase fails — supervisor terminate EOF cluster + unix socket path bind failure

1 participant