Repository navigation
Read MCP stdin on its own thread (M01-04d slice 4, PR 1b) - #54
Merged
Merged
Conversation
…e main actor (M01-04d slice 4, PR 1b) No bridge removed; MCP JSON, CLI output, exit codes and approval order are unchanged. - MCPServer.run: a dedicated reader thread (same readLine framing) feeds an unbounded AsyncStream; a main-actor loop handles one request at a time and writes each reply before taking the next line. Exit 0 only after every buffered line was handled. The approval never yields, so the dialog's modal loop cannot run another request; the preview is still used up before asking. - runOnMain takes an async body; --mcp and --cli mcp share the one reader. CLI.run takes its subcommand from CLI.subcommand. - Self-test: run-loop fingerprint flipped (ticks>0: the main run loop is free while waiting for input; the old blocking loop fails it); re-entrancy (one ask while a second confirm waits, replies in order, a used preview refused); EOF during an open dialog (today's behavior) and during an approved move (exit after the move and its log record); 30 requests behind a dialog; idle --mcp still dies on SIGTERM.
…cy guarantee Docs and a comment only. D-018 records the stdin thread / one-request-at-a- time design and the user's decisions (unbounded buffer, an open dialog outlives EOF, no SIGTERM handling); RISK-018..020 track them. The MCPServer.run comment now names the single consumer and synchronous handle as the guarantee, with the main-queue rule only as a second layer.
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.
What
PR 1b of M01-04d slice 4 (0 ✅ → 1a ✅ → 1b → 2 → 3 → 4). No bridge removed; MCP JSON, CLI output, exit codes and approval order unchanged. User approval: SAFETY-CRITICAL APPROVED for this scope; decision: EOF while a dialog is open keeps today's behavior.
MCPServer.run(@MainActor async): a dedicated reader thread (samereadLineframing) feeds an unboundedAsyncStream(user decision: no request is ever dropped; the pipe no longer applies back-pressure). A main-actor loop handles one request at a time and writes each reply before taking the next line. Exit 0 only after every buffered line was handled.handle("one request at a time; an approval never yields"); the preview is still used up before asking.runOnMaintakes an async body;--mcpand--cli mcpshare the one reader.CLI.runtakes its subcommand fromCLI.subcommand(its oldmcpcase is unreachable and now returns 64).Tests
ticks>0(main run loop free while waiting for input). Negative control with the old blocking loop: only this check fails (544/1).--mcpstill terminates on SIGTERM (no handler).Checks (local)
check-approval-sites.shpass;check-no-test-hooks.shpass (Release,--expect-hooks)--cli mcpBefore merge
mc-reviewerandmc-safety-architect(Opus) clean🤖 Generated with Claude Code