fix(mcp): a close is bounded, the server's close is the book's close, and the tests prove what they claim

Close bound. A drill ran to its end however large the book, and a format
upgrade counted by the store's close held it, because only git was
cancellable. Now a close hurries them at its start (Backups::hurry): a drill
stops at its next look (git killed, journal line, file, chunk) and its
scratch clone is removed, nothing said of its target (it is due again at
open); a format upgrade is stopped before its journal.format_set line is
appended (reported not done, the books unchanged) and finishes once it is.
The close's last backup, and shut's stop of what is left of it, are not
hurried. INVARIANT 10 now states the bound as the sum of its named parts.
Lock files a stopped git left are removed by the store (previous commit) and
recorded here (lock_removed / lock_left, also those found at open).

Server's own close. It cut a stalled body only after admin jobs, store
closes and the serial 60 s backups, and never shut a gate or closed a log.
It is now Books::release for every open book (gates shut and the cut set for
one grace at the start, books released together, logs, uploads, exports,
backups and store closed), so there is one closing path; INVARIANT 15 says
what is true. A request that finds a shut door during the server's close is
refused as closing, not recorded.

Tests that passed with the fix removed. The timers test now holds a timer
between taking a book's handles and acting on them (--timer-hold), closes the
book in between and requires the tree not to move; the slow-upload test is
driven by conditions (a minute's grace) and has a mirror proving the cut of
an active upload; the line of the cut (a body read to its end is never cut)
has a unit test; a slow drill (--slow-steps) and a format upgrade are held by
the close test; REAL git killed inside init, a commit and a push by a close
leaves no lock and the next backup succeeds (this found that a killed init
left HEAD.lock, fixed in the store); the server's close with a stalled
upload and a stalled call exits 0 with both cut.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-20 13:10:41 -07:00
1 parent 10790d8794
commit f6daba558b
5 files changed
+1071 -126

No files matched your search

+19 -2
View File
@@ -370,9 +370,19 @@ didn't open, with why). Protocol version 1: the requests are new, the
finishes; its MCP sessions end (an agent's next
request on one gets the "isn't open" words above, and after a reopening
a 404 "Session not found", which a client takes as "open a new one"); its
last backup is made, as at the server's close, for 60 seconds at most:
last backup is made, as at the server's close, for 60 seconds at most
(a drill, or a format upgrade not yet journaled, is stopped when the
close begins, at its next look, so it never takes the last backup's
turn; its scratch clone is removed and the books are unchanged):
a backup still running after that is stopped (git is killed with all it
started) and waited for to end; then nothing of the server's can write
started, and any lock file it left, in the book's archive and in a
folder target on this computer, is removed and recorded in
`ops/backup.jsonl` as `lock_removed`; a lock that was there before the
push began is never touched, `lock_left`) and waited for to end;
the close is bounded by the sum written in the server's INVARIANT 10
(`local.rs`: running calls, the grace, the answers' grace, the stop of a
hurried step, the last backup's 60 s, the stop of what is left of it);
then nothing of the server's can write
to the book: its access log, uploads, exports and backups are closed
under the locks their writes go in under, so a handle held from before
can never write after a reopening; its store is let go, releasing the
@@ -398,6 +408,13 @@ didn't open, with why). Protocol version 1: the requests are new, the
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).
- **The server's own close** (its standard input ends, or SIGTERM) is the
same path for every open book at once: at its start every book's door
is shut and the cut (above) is set for 10 seconds from that moment; each
book is then released as `close_book` releases it. The server exits 0
once they are all closed (and the HTTP side has ended); a request that
arrives meanwhile is refused as closing (503) and not recorded, the
door being shut.
- `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