Repository navigation
mcpx tests: de-flake the two races that reddened the switch build (#2609) - #2612
Conversation
) Both failures from the 2026-10-30 switch build are test-side races, not product regressions: the Go code in internal/hooks and internal/mcpclient is byte-identical to the last green verification (efeea69, PR #2587) - the only mcpx change since is the #1910 TypeScript plugin work - and a re-run of the identical mcpx derivation (a0nzf2m5) passes both packages. 1. TestDeclaredHookFiresOnMatchingKindsOnly waited for the marker file to EXIST, then read it. The hook command is "cat > marker": cat creates the file before it writes the stdin payload, so under build load the test could read the just-created empty file - the observed failure was exactly an empty payload. The wait now polls the payload content itself, the same pattern the sibling python-hook test in this file already uses. 2. TestSupervisedPumpDetachReattach reattached immediately after Close(). Close returns when the local connection closes; the supervisor clears its attach slot when it notices the disconnect, asynchronously - so under load the reattach hit the (by-design) "already attached" refusal. The test now polls the reattach until the slot frees (10s deadline, refusal-only retries); production semantics are unchanged, including the refusal a genuinely attached second client still gets. Verified: both packages 5/5 consecutive green; the two tests at -count=100 / -count=60 green; gofmt + go vet clean.
|
Warning Review limit reachedYou'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 41 minutes. View limit details
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. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Gate proof:
|
Fixes #2609. Unblocks the NixOS deploy switch.
Verdict: two test-side races, not a product regression
The switch build (primary at 819889b) failed mcpx checkPhase on two tests. Both were green at efeea69 (PR #2587's verification). Between that commit and 819889b the only mcpx changes are the #1910 TypeScript plugin commits (33eda5c, 81d4b41, merges 52bfa5f/f9268e24) — the Go code in
internal/hooksandinternal/mcpclientis byte-identical to the green state. f9268e2 did not cause these; they are load-dependent flakes that surfaced under the full-system build's parallelism.Proof of nondeterminism: a re-run of the identical mcpx derivation (
/nix/store/a0nzf2m5b1kpr4w4a3hlhrm1sbmgq6y1-mcpx-0.1.0.drv, same inputs, same output path as the failed switch build) passed checkPhase —ok internal/hooks,ok internal/mcpclientin its nix log.Root causes
TestDeclaredHookFiresOnMatchingKindsOnly(internal/hooks) — the test waited for the marker file to exist, then read it. The hook command iscat > <marker>: cat creates the file before it writes the stdin payload, so under CPU starvation the test reads the just-created empty file. The switch failure was literallyhook stdin payload wrong:(empty). The production runner is not involved in the race: it feeds the full JSON viacmd.Stdinandcmd.Run()waits for cat to finish.Fix: the wait now polls the payload content itself (
"kind":"server.stopped"present) — the same pattern the sibling python-hook test in this file already uses. Assertions unchanged.TestSupervisedPumpDetachReattach(internal/mcpclient) — the test reattached immediately afterClose().Close()returns once the local connection is closed; the supervisor clears its attach slot when it notices the disconnect, in its own loop — asynchronously. Under load the immediate reattach arrived first and got the by-designalready attachedrefusal.Fix: the test polls the reattach, retrying only on the
already attachedrefusal, with a 10s deadline. Production semantics are unchanged — including the refusal a genuinely-attached second client still receives (covered by the neighboring test).No production code changed; #1910's feature is untouched.
Verification
go test ./internal/hooks/ ./internal/mcpclient/ -count=1).-count=100green, pump-count=60green.gofmtclean,go vetclean on both packages.nix build .#mcpxfrom this worktree: run after this PR opened; result in a follow-up comment. (Baseline note: the unmodified tree's identical derivation already re-ran green once, per above.)Need help on this PR? Tag
@codesmith-botwith what you need.