fix(store,mcp): a type claims only what it does alone, and a restore never says 'no such books'

ledger-store: a file coming in (Uploads::receive) now writes each chunk under
the lock a close takes and stops at the first chunk after a close, removing
its part; an export fetch (Exports::get) reads under that lock, so a close
waits for it. The INVARIANTS say exactly this: after close() returns no byte
is written or kept and none is read for a caller; the one thing a request
begun before the close does after it is remove the part file only it made;
a request still waiting for its next bytes is not woken by the type (the
books server's gate waits for it and cuts one that never finishes).

ledger-mcp: a restore over an open book took the book out of the list
before it shut the door, so every call while the restore waited for what was
inside got 404 'no such books' for a book that exists. The door is shut
first and the book listed closed: such a call gets the closed refusal (503,
the words), as in a close. The drain test now requires 503 throughout.
(A refusal at a shut door is not written to the access log, as in a close:
INVARIANT 11.)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-20 12:22:19 -07:00
1 parent ce636adbb5
commit ca6f5aa982
6 files changed
+211 -21

No files matched your search

+4 -1
View File
@@ -394,7 +394,10 @@ didn't open, with why). Protocol version 1: the requests are new, the
record, `books.audit`) before it repeats a write. A restore over an open
book (`restore --replace`) lets go of the book in the same way (waits for
what is inside the book's door, ends its sessions, stops its backups,
closes its logs) before it moves the book into `legacy/`.
closes its logs) before it moves the book into `legacy/`; the book is
listed closed from the moment the restore begins, so a call that comes
meanwhile is told the books aren't open (503, as in a close), never that
there are no such books (404).
- `sessions` lists, for each open book, its live MCP sessions: the token's
**name** (never the token, its text or its hash), the client's name and
version from `initialize`, the agent's self-report (`books.start`'s