fix(mcp): fail closed on stdio child loss - #66
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs changes before merge. Reviewed August 14, 2026, 6:22 AM ET / 10:22 UTC. ClawSweeper reviewWhat this changesThis PR makes stdio MCP connections fail closed when their child process exits or stdout ends, clearing client state and failing pending requests. Merge readinessKeep open: the EOF close task can overtake tasks that deliver complete responses already read from stdout, causing a successful MCP response to be discarded as Priority: P1 Review scores
Verification
How this fits togetherTachikoma’s MCP client discovers tools through a transport; the stdio transport launches a child process, exchanges JSON-line requests and responses, and reports closure back to the client. This change controls teardown and reconnect behavior when that child transport ends. flowchart LR
A[MCP client] --> B[Stdio transport]
B --> C[Child process]
C --> D[Response or EOF]
D --> E[Deliver response]
D --> F[Close connection]
F --> G[Fail pending requests]
F --> H[Clear client tools]
Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Serialize delivery of all complete stdout responses ahead of EOF teardown, add a response-then-EOF regression, and remove the release-owned changelog edit. Do we have a high-confidence way to reproduce the issue? Yes: a fixture child can write one valid JSON-RPC response and exit immediately; source ordering shows EOF teardown may win before the response continuation is resumed. Is this the best way to solve the issue? No: fail-closing is appropriate, but teardown must first settle complete responses already read from stdout rather than race them. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0d2eb8d070a3. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Summary
MCPClientconnectivity and cached tools on unexpected closure, fail every pending request immediately with typedtransportClosed, and refuse later requests or notifications before writingProof
TACHIKOMA_TEST_MODE=mock TACHIKOMA_DISABLE_API_TESTS=true swift test --parallel— 837 core + 62 MCP tests passedswift build -c releaseswift package resolvewith noPackage.resolveddriftswiftformat --lint .swiftlint lint --config .swiftlint.yml --strict— 0 violations