Files
wanderbooks/crates/ledger-cli
swaitsandClaude Sonnet 5.5 89403a7159 fix(mcp): a close waits for the answers on their way out, and test it under a hammer
The first run of the hammer (agents calling two books while one is closed and
reopened over and over) found a real race: an MCP request's handler returns
as soon as the session's task has the request, and the tool's answer streams
back afterwards. A close that waited only for handlers and running tools
could end the sessions while an answer was still on its way, so a call that
did not run (refused as closing) reached its client as neither answered nor
refused. The gate now also counts answers on their way out (Answering,
carried in the response body as the server's own close counts them), and a
close waits for them, for ANSWER_GRACE at most, before it ends the sessions.

The hammer (tests/book_open_close.rs) replays both journals afterwards:
every acknowledged draft is there exactly once under the id it was told, no
refused call left anything, the closed book's journal and access log never
moved between the close answer and its reopening, the other book never
refused a call and kept answering while the first was closed. Beside it: a
server started with --open, the sessions request over the real socket, the
doctor's lines, and the docs (mcp-interface, architecture, testing).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 09:23:39 -07:00
..