Repository navigation
Description
Finding
PR #1495 (commit 18ba1ee35b, "mcpx: supervised stdio transport behind a flag (#1385, Phase 1 of #1384)") added pkgs/mcpx/internal/mcpclient/supervised.go. In pumpStdout the supervisor performs a blocking socket write to the attached daemon while holding the supervisor's global state mutex — verified unchanged on current main (origin/main at 5a34fa7070, 2026-10-29):
supervised.go:290pumpStdout()— at:297it takess.mu.Lock(), and at:299it callss.attached.Write(data)inside that lock before unlocking.- The child-exit goroutine at
:210-211doess.child.Wait()and then needs the sames.mu.Lock()to recordexited/exitErrand closewaitDone. detach()(:344-area lock),handleAttach()(attach/drain path), andfinishWhenDone()also need the same mutex.
Failure chain: if the attached daemon stops reading (paused, wedged, or slow enough that the unix-socket send buffer fills — the pump writes 32 KiB chunks), the Write blocks indefinitely with the mutex held. From that moment:
- a child exit can never be recorded (the
Waitgoroutine blocks on the mutex), sowaitDonenever closes andfinishWhenDonenever runs — the supervisor wedges instead of surfacing the exit; - no detach or replacement attach can proceed (both need the mutex), so the stalled attach cannot be cleared;
- child output stops being consumed, so the child can in turn block on a full stdout pipe — a full supervisor/child stall, behind the (default-off, Phase 1) supervised flag.
The existing tests from #1495 (TestSupervisedPumpDetachReattach, TestSupervisedSingleAttachRefused, TestSupervisedBufferOverflow, TestSupervisedChildExitSurfaced) cover a reading daemon and unattached buffering, but nothing covers an attached daemon that stops reading.
Why it matters
The supervised transport exists precisely so a daemon going away never harms the child, and so a child exit always surfaces. A stalled-but-connected daemon is the one case the current locking defeats both guarantees for, and it fails silently (no error, no exit report, supervisor process lingers).
Acceptance criteria
-
pumpStdoutnever performs a blocking write to the attached connection while holding the supervisor state mutex (e.g. a dedicated per-connection write mutex/queue owns attach writes and preserves the reply → buffered → live byte ordering thathandleAttach's under-lock flush was protecting). - With an attached daemon that never reads: the child can still exit and the exit is recorded/reported (or the attach is dropped after a bounded write timeout), and a later attach/detach proceeds.
- A regression test pins the stalled-reader case (daemon attaches, stops reading, child emits more than a socket buffer of output and/or exits; the supervisor does not wedge).
- Existing supervised tests keep passing; unattached tail-buffer behaviour and
droppedBytesaccounting are unchanged.
Found by the pr-diff-review job reviewing PR #1495's diff against current main; deduped against open/closed issues (searched "supervised", "pumpStdout", "supervisor blocked/deadlock" — only the closed implementation issue #1385 covers this code, and it does not name this flaw).
Activity
developing-today commentedon Oct 29, 2026
CODE-1217
dezren39 commentedon Oct 29, 2026
🤖 Agent note · filed
33 remaining items
fix(mcpx): supervisor — atomic unattached buffer append + flush barri…
fix(mcpx): supervisor — route failed-write recovery chunks to a repla…
dezren39 commentedon Oct 31, 2026
🤖 Agent note · parked
3a272fbb7(atomic unattached buffer append under s.mu; closeAfterFlush barrier in finishWhenDone) andf83a26a29(the fresh Codex round's follow-on P2: failed-write recovery chunks routed to a replacement attachment instead of stranding in the tail buffer). All three Codex findings are fixed and replied on their threads.f83a26a29is FULLY GREEN (lint, plugin tests, mcpx-docs build, stress race/shuffle/repeat, CI budget — verified 2026-10-31T00:56:11Z) and laptopgo test ./internal/mcpclient/incl.-racesupervised subset passes. Parked 20m for ONE remaining gate: no Codex review round has posted on headf83a26a29yet despite the push and an explicit@codex reviewtrigger. Resume: Codex round onf83a26a29posts with no new findings (or any new finding is dispositioned) → merge PR fix(mcpx): supervisor per-connection writer + bounded write deadline (#2390) #2861 (MERGEABLE) → close fix(mcpx): supervised transport (PR #1495) — pumpStdout writes to the attached daemon while holding the supervisor mutex, so a stalled daemon wedges exit and detach #2390 → complete task 3978.chatgpt-codex-connector commentedon Oct 31, 2026
To use Codex here, create an environment for this repo.
dezren39 commentedon Oct 31, 2026
🤖 Agent note · picked up (resume)
Merge pull request #2861 from developing-today/queue/3978-2390-superv…
dezren39 commentedon Oct 31, 2026
🤖 Agent note · done