merge: P15 A1, the server opens and closes one book while it runs
The books server could only open every book at start and close them all at exit. The app is becoming one window with a tab per open company (D-77, D-78), so a company must be reachable exactly while its tab is open. The server now opens and closes one book on request, refuses calls to a closed book in words an agent can relay, and lists who is connected. Four independent reviews shaped it. After a close is answered nothing in the server can write to that book; a call either ran and is journaled or was refused, cut or stopped and left nothing; a close ends within a stated bound; closing one book never stops another's work; and nothing is ever deleted in a backup folder the owner chose. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
commit
a19473b282
35 files changed
+11097
-434
No files matched your search
@@ -287,6 +287,15 @@ re-verifies the journal.
|
||||
|
||||
## The local transport and the Windows arms (`ledger-mcp::ipc`, `ledger-store::winsec`, P11c, D-62)
|
||||
|
||||
The books server opens the books of the data root at its start (all, or the
|
||||
ones `--open` names), and opens or closes **one** while it runs (admin
|
||||
requests `open_book` and `close_book`, `ledger-mcp/src/local.rs`
|
||||
INVARIANT 10; plan/p15-app-and-relay.md 3.1): each open book has a gate
|
||||
every request enters before it touches the book, which a close shuts and
|
||||
waits empty, so the app's tab for a company can be its book's open state.
|
||||
`sessions.rs` keeps the per-book board of who is connected (the admin
|
||||
`sessions` request).
|
||||
|
||||
The books server, the host and everything that talks to them meet on
|
||||
channels only this account can open (plan 3.9). `ledger_mcp::ipc` is the
|
||||
one seam: `Endpoint` (a socket in the root's `run/` on Unix; the pipe
|
||||
|
||||
+147
-1
@@ -267,7 +267,10 @@ reach through the bridge.
|
||||
- **Served books** (`wanderbooks server`, started by the host; an agent
|
||||
connects with `wanderbooks mcp --book ID`, the bridge: stdio to the
|
||||
agent, the server's socket upstream): every book
|
||||
in the data root, on a socket in the root's private `run/` folder that
|
||||
in the data root that is open (all of them at the start, unless
|
||||
`wanderbooks server --open none|ID[,ID…]` says otherwise; one is opened
|
||||
or closed while the server runs, "Opening and closing one book" below),
|
||||
on a socket in the root's private `run/` folder that
|
||||
only this account can connect to. Every request carries a bearer token
|
||||
live for that book (refused 401 without one, 403 with another book's).
|
||||
Refusals at the door, tool calls, uploads, downloads and exports are
|
||||
@@ -275,6 +278,12 @@ reach through the bridge.
|
||||
book stops taking requests (an upload, download or export is then
|
||||
refused, 503).
|
||||
- `/b/{book}/mcp`: the book's MCP service. A request is at most 1 MiB.
|
||||
- A book that exists but is **closed** is refused on every route below
|
||||
and on this one: 503 with `x-wanderbooks-refused: closed` and the words
|
||||
`The books "ID" aren't open: open them in Wanderbooks.` (the bridge
|
||||
hands them to the agent as they are). A book that doesn't exist is 404
|
||||
`no-such-books`; one that failed to open is 503 `not-open` with why.
|
||||
Nothing of a closed book is written, its access log included.
|
||||
- `PUT /b/{book}/u/{upload}`: an upload's bytes (`books.begin_upload`),
|
||||
from the token that began it; what `wanderbooks upload --book B
|
||||
[--token NAME] UPLOAD FILE` sends. Streamed to the disk, kept only if
|
||||
@@ -331,6 +340,143 @@ reach through the bridge.
|
||||
hidden file and hard-linked in: never a partial file under the real
|
||||
name, never over another file.
|
||||
|
||||
### Opening and closing one book (plan/p15-app-and-relay.md 3.1, D-77, D-78)
|
||||
|
||||
The desktop app has one tab per company, and a company is reachable by
|
||||
agents exactly while its tab is open, so the books server opens and closes
|
||||
**one** book while it runs. These are requests on the admin socket (the
|
||||
command line sends them: `wanderbooks books open ID`, `wanderbooks books
|
||||
close ID`; `books list` and `doctor` show each book as open, closed, or
|
||||
didn't open, with why). Protocol version 1: the requests are new, the
|
||||
`closed` flag of a listed book defaults to false.
|
||||
|
||||
- `open_book { id }` opens a closed (or failed) book of the data root with
|
||||
exactly the checks of the server's start (verified, a drifted database
|
||||
rebuilt, a format upgrade waited for as at the start). Answers `opened`,
|
||||
`already_open`, `no_such_book`, or `could_not_open` with why (the book
|
||||
stays listed, with that `problem`).
|
||||
- `close_book { id }` answers `closed`, `closed_backup_incomplete` (with
|
||||
why), `was_not_open` or `no_such_book`.
|
||||
In this order: new calls on the book are refused (the door is shut and
|
||||
the book listed closed); the calls running on it finish, on every route
|
||||
(an ordinary call: nothing is killed, nothing is half-done; the calls
|
||||
that can run long are stopped instead, see below); the answers on their way out
|
||||
are sent, for 10 seconds at most (a client that never reads its answer
|
||||
doesn't hold the book open); a request whose body has not been read
|
||||
to its end when that time runs out (counted from the start of the
|
||||
close: an upload or a call that began and stopped sending) is cut: its
|
||||
connection is closed, an upload's part file is removed, nothing of an
|
||||
MCP call reached the journal, and the access log says `cut_by_close`;
|
||||
a call whose body arrived whole and is running is never cut, it
|
||||
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
|
||||
(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 sent SIGTERM, which
|
||||
makes it remove its own lock files, and killed with all it started only
|
||||
if it hasn't ended after 5 seconds) and waited for to end. The program
|
||||
never writes to or deletes from a backup folder (it is the owner's, and
|
||||
may be shared with other computers or a sync program): a lock git left
|
||||
there when it had to be killed is left in place, recorded in
|
||||
`ops/backup.jsonl` as `lock_left` with its whole path, and the target's
|
||||
backup is marked failed with words naming the file and saying to remove
|
||||
it only when nothing else is using the backup folder (`books.backup`
|
||||
and the close's answer say the same; the next backup that finds the
|
||||
lock gone goes on). In the book's own archive (`archive.git`, private to
|
||||
the program; running git by hand inside it is unsupported) it removes
|
||||
only the locks its own stopped git made, and, at open and when a backup
|
||||
begins, locks older than ten minutes, each recorded `lock_removed`;
|
||||
**What a close stops, and what it waits for.** At its start a close
|
||||
stops the calls and jobs that can do long I/O or loop over a book's
|
||||
whole journal or files, each at its next look: `books.back_up_now` and
|
||||
a backup a timer asked for (git is stopped; the call answers that it was
|
||||
stopped because the books are closing, its access record says
|
||||
`refused: stopped_by_close`, and nothing it was doing is recorded as done;
|
||||
a commit it had made stands), `books.verify` (once per journal line and
|
||||
per stored file; a heal of a drifted database is begun only if no stop
|
||||
was asked before it, then finishes), `books.export_cpa_package` (once per
|
||||
stored file, unless it has journaled a decision, below), a drill, and a
|
||||
format upgrade not yet at its final look (a
|
||||
stop is honoured up to that look; one that arrives after it still
|
||||
upgrades and records success). A stop is scoped to what it concerns. On
|
||||
the admin socket, a close of the book X stops the work on X only: an open
|
||||
of X, and a restore that replaces X. A create, an adoption and a restore
|
||||
that replaces nothing make a new book, which no close of a book is the
|
||||
close of: a close of one book never stops, fails, refuses or delays them,
|
||||
nor an open or a close of another book (each book has its own turn; books
|
||||
are made, adopted and restored one at a time, and a job queued for its
|
||||
turn leaves at once when asked to stop). The server's own close stops
|
||||
every job. A stopped job, before its point of no return (the rename that
|
||||
puts the books in place; create's making of its folder), removes what it
|
||||
wrote (an adoption also removes the lock file it made in the source
|
||||
folder, so the original is left as it was) and leaves the root byte for
|
||||
byte as it was, and answers that it was stopped because the books are
|
||||
closing; after it the job finishes (a rename or two and two directory
|
||||
syncs), and the book is then opened unless that, too, is stopped (it is
|
||||
left closed, and the answer says so). `books.export_cpa_package` with a
|
||||
reason to export (without an audit, with open drafts) journals that
|
||||
decision before it builds, because the package counts it (its README and
|
||||
every footer carry the journal's event count at the build): a close is
|
||||
looked for once, immediately before the first decision is journaled, and
|
||||
a stop then journals nothing; after it the package is made whatever a
|
||||
close does, so no decision is on record for a package that was never
|
||||
made (every refusal is decided before any decision is journaled). Every
|
||||
other call does work bounded by the size of one request and is waited
|
||||
for. Three are the named exceptions to the close's bound, each waited for
|
||||
in full if a close meets it: `books.import_bank_csv` (a file of up to
|
||||
25 MiB is rehearsed whole and then written row by row, each row
|
||||
journaled; worst case, a full import of the largest file accepted),
|
||||
a report or export over the whole journal (CPU on the ledger in memory,
|
||||
not stopped; worst case, one report over the whole book), and a package
|
||||
after its decision is journaled (worst case, one build over the whole
|
||||
book). Otherwise
|
||||
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
|
||||
writer lock, so another process could open the book. Only then is the
|
||||
close answered: `closed`, or `closed_backup_incomplete` when the last
|
||||
backup wasn't whole (a target failed, or the backup was stopped after
|
||||
its time): the book is closed all the same, and what it holds since the
|
||||
last good backup isn't backed up. Every other book keeps serving, and
|
||||
none of its calls waits for this close. For every call, either it ran
|
||||
completely and is in the journal, or it was refused unrun and nothing of
|
||||
it is; after the answer, no call on that book runs until it is opened
|
||||
again. **A call whose answer was never read** (the client was slow, or
|
||||
gone, and the grace ran out) is the same case as a connection dropped at
|
||||
any other moment: the call ran, and its access record, written before the
|
||||
answer went, says so (outcome and head). Nothing in the journaled tools
|
||||
makes asking again safe: they carry no client key and none checks for a
|
||||
duplicate, so a draft asked for twice is two drafts. A client that
|
||||
reconnects after a close should read the book's state (or the access
|
||||
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/`; 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).
|
||||
- **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
|
||||
`agent`, if it made one), when it connected, how many of its calls are
|
||||
running now, and its last tool with its outcome and time. A session
|
||||
that ended is not listed; nothing is kept across a server restart.
|
||||
`wanderbooks doctor` prints these lines under "Assistants connected".
|
||||
|
||||
## Server instructions
|
||||
|
||||
The MCP `initialize` response carries an `instructions` string, the
|
||||
|
||||
@@ -33,7 +33,14 @@ easily backupable, journable":
|
||||
ahead, the commit under the store's lock) and pushes it to the
|
||||
owner's private repository and backup folder, versioned and
|
||||
deduplicated, with full history (docs/mcp-interface.md, "Tools —
|
||||
backups").
|
||||
backups"). The program stops its git gently (SIGTERM first, so git
|
||||
removes its own lock files, and a kill only after 5 seconds), and never
|
||||
writes to or deletes from a backup folder, which is the owner's (shared,
|
||||
perhaps, with another computer or a sync program): a lock git left
|
||||
there after a kill is reported with its path, never removed. The book's
|
||||
own archive (`archive.git`) is private to the program; there it removes
|
||||
only the locks its own stopped git made, and locks older than ten
|
||||
minutes found when the books open or a backup begins.
|
||||
- **Journable.** It literally is a journal: `{seq, ts, type, payload, prev}`.
|
||||
Greppable, diffable, replayable. The audit trail isn't a feature bolted
|
||||
on — it's the storage format.
|
||||
|
||||
+87
-1
@@ -4084,7 +4084,8 @@ it checks are already theorems.
|
||||
a medium effort, no claim, a lowered bar read retroactively),
|
||||
`a_period_is_attested_on_a_standing_audit`,
|
||||
`cpa_package_refuses_without_a_counted_audit_unless_a_reason_is_given`
|
||||
(refused, a reason journaled as a decision, an audit alone not enough, a
|
||||
(refused, a reason journaled as a decision, and none journaled when an open
|
||||
draft then refuses the same package, an audit alone not enough, a
|
||||
year attested below the whole bar not enough, the whole bar, an entry
|
||||
since, `warn`), `audits_wait_for_the_upgrade` (the fixture over the
|
||||
wire; the package is not held up by an audit it cannot ask for).
|
||||
@@ -4290,6 +4291,91 @@ that make a group, the reversal skip, the `total > threshold` end),
|
||||
`audit::check_split` (`> unit`, not `>=`), `AttestationBar::parse`'s range
|
||||
(1..=64), `reconcilable::reconciliation_due` (`<=` through, `<` reconciled).
|
||||
|
||||
## P15 A1: open and close one book, and who is connected (2026-11-20)
|
||||
|
||||
The server opens and closes one book while it runs (`ledger-mcp/src/local.rs`
|
||||
INVARIANTS 3, 10 to 12; `admin.rs` INVARIANTS 8 and 9; `sessions.rs`). The
|
||||
rule the tests prove: for every call, either it ran completely and is in
|
||||
the journal, or it was refused and nothing of it is; after a close is
|
||||
answered no call on that book runs until it is opened again; and a close of
|
||||
one book never refuses or holds up a call on another.
|
||||
|
||||
| Test | What it proves |
|
||||
|---|---|
|
||||
| `local::tests::a_closed_book_is_refused_as_closed_and_the_other_still_serves` | a closed book's door says `closed` with the words an agent can relay, a name that is no book says `no-such-books`, the other book still passes the door, the list shows closed (not a problem), closing twice is `was_not_open`, opening is `opened` then `already_open`, a name that is no book is `no_such_book` |
|
||||
| `local::tests::a_closed_book_can_be_opened_by_another_program_and_not_by_two` | a close releases the store's writer lock (another `Store::open` succeeds); while another holds it, opening says `another program has these books open` and the book is listed with that problem; once it lets go it opens |
|
||||
| `local::tests::a_close_waits_for_the_requests_inside_and_refuses_the_next` | a close answers only after a request already inside the book's gate has left; a request arriving meanwhile is refused as closed at once; another book's door is not held up |
|
||||
| `local::tests::the_books_open_at_the_start_are_chosen_by_option` | `--open` takes `all`, `none`, or ids, and refuses a bad id |
|
||||
| `local::tests::the_sessions_request_says_who_is_connected_and_never_their_token` | the sessions list: the token's name, the client from `initialize` (known before any call), the agent's self-report, the last call; no token text; an ended session is not listed; a book's sessions end with it and a reopened book has none |
|
||||
| `sessions::tests` (3) | the running count rides in the call's guard; the last call, the client and the agent are kept, masked of any full TIN; a note for an ended session is dropped |
|
||||
| `book_open_close::books_left_closed_at_the_start_say_so_and_open_when_asked` | a real server started with `--open BOOK`: the other book is listed closed and says so on the MCP, download, export and upload routes; a name that is no book is 404; opening serves |
|
||||
| `book_open_close::the_open_option_takes_none_and_refuses_a_book_that_doesnt_exist` | `--open none` leaves every book closed; `--open nobody` exits 2 before opening anything |
|
||||
| `book_open_close::the_sessions_request_names_each_connection_and_never_its_token` | over the real socket: two tokens, two clients, an agent's report, neither token's text nor SHA-256 in the answer, an ended session gone, a close ends the book's sessions |
|
||||
| `book_open_close::closing_and_opening_a_book_over_and_over_loses_and_duplicates_nothing` | the hammer: 6 agents on one book (which has a backup target, every timer at 10 ms, and two clients sending bad tokens so refusals are being recorded) and 4 on another make journaled drafts and reads while the first is closed and reopened 12 times, and a maker thread creates up to eight new books and closes and opens a third over and over (every one must be answered as asked: a close of the first never stops, refuses or fails an admin job on another book; a probabilistic check, the deterministic one is `closing_and_opening_one_book_never_…`); every file of the closed book (journal, access log, every ops log, stored files, the backup's repository) is hashed when the close is answered and compared just before the reopening, every cycle; "the other book progressed" waits on that condition, not a sleep; the logs end as whole chains; both journals are replayed afterwards: every acknowledged draft is in its journal 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 the reopening, the other book never refused a call and kept answering while the first was closed, and the books replay with gapless ids |
|
||||
| `book_open_close::a_close_doesnt_wait_for_a_clients_open_event_stream` | a client keeps its standalone event stream (a GET) open (known open: its response head has come; no sleep): closing its book still answers at once, not after the grace for answers on their way out (it took 12 s while the stream was counted as an answer, which stalled the bridge in a hand demonstration) |
|
||||
| `local::tests::a_refusal_being_recorded_keeps_its_place_when_its_client_hangs_up` | a request refused at the door has its access record written by a task that keeps its place inside the book's door: with the only blocking thread held and the request's future dropped, the door stays counted, a close waits, and the record is written before it empties (it was uncounted: the record could land after the close, and after a reopening) |
|
||||
| `local::tests::handles_from_before_a_close_do_nothing_after_the_book_is_open_again` | the access log, uploads, exports and backups taken before a close, used after the same book is opened again (a late record, a sweep, a grant, an export, a run, a drill, a format upgrade), write nothing: the reopened book's tree is byte for byte what its own upgrade left, and its backup record is a whole chain (fails when the backups' shut flag and record close are removed) |
|
||||
| `ledger-store` `access::tests::a_closed_log_writes_nothing_and_a_reopened_one_stays_whole`, `uploads::tests::closed_uploads_change_nothing`, `exports::tests::closed_exports_change_nothing_and_give_nothing`, `backup::tests::a_cancelled_git_stops_what_runs_and_starts_nothing` | the closed state of each handle (under the lock its writes go in under), and git's cancel flag (a running command is stopped with all it started, none starts) |
|
||||
| `book_open_close::a_client_that_never_reads_its_answer_cannot_hold_a_close_nor_break_the_log` | a client asks for the 500 KB tools list and never reads it (the answer is stuck in the socket): the close waits the answer grace (shortened to 700 ms) and then answers; the folder doesn't move afterwards; after the reopening the access log is one whole chain |
|
||||
| `book_open_close::a_stalled_upload_body_cannot_hold_a_close_and_leaves_no_part_file` | an upload stops sending half way: the close waits the grace (600 ms), cuts it (connection closed, no part file, no bytes kept, record `cut_by_close`) and answers; the folder stands still; one whole access chain across the reopening (hung before the change) |
|
||||
| `book_open_close::a_stalled_mcp_body_cannot_hold_a_close_and_nothing_of_it_is_journaled` | a `tools/call` whose body stops half way is cut by the close: connection closed, the call is not in the journal, record `cut_by_close` (hung before the change) |
|
||||
| `book_open_close::a_restore_over_an_open_book_is_not_held_by_a_stalled_upload` | a restore over an open book with an upload stalled half way: the upload is cut after the grace, no part file in `legacy/`, the replaced book's log records `cut_by_close`, the restore is answered |
|
||||
| `book_open_close::a_restore_over_an_open_book_waits_for_what_is_inside_it` | (extended) every call while the restore waits for a half-received upload gets 503 and the closed words, never 404 `no such books` (fails when the restore takes the book out of the list before it shuts the door) |
|
||||
| `ledger-store` `uploads::tests::a_close_in_the_middle_of_a_file_stops_it_at_the_next_chunk`, `uploads::tests::a_close_between_the_last_byte_and_the_rename_keeps_nothing`, `exports::tests::a_close_waits_for_a_fetch_that_is_reading` | the types' own claims (INVARIANT 6 of uploads, 5 of exports): a close in the middle of a file stops it at the next chunk (no read after, no part left), a close between the last byte and the rename keeps nothing, and a fetch reads under the lock a close takes (a named pipe holds it inside its read; `close` must not return); each fails with its guard removed |
|
||||
| `book_open_close::a_slow_upload_that_finishes_within_the_grace_is_not_cut` | (made deterministic) the grace is a minute and the rest of the bytes go only after the book is listed closed: the cut waits for the grace (fails with the cut set to fire at once) |
|
||||
| `book_open_close::an_upload_still_arriving_when_the_grace_runs_out_is_cut_however_active_it_is` | the mirror: a client sending 8 KB every 25 ms (not stalled) of a 3 MB body with a 600 ms grace is cut (`cut_by_close`, no part, no bytes kept) and the close answered; driven by the client's condition (it sends until the connection is closed), fails with the cut removed |
|
||||
| `book_open_close::the_servers_own_close_cuts_stalled_requests_and_exits_zero_in_time` | one upload stalled on one book and one MCP body stalled on another, the server's stdin closed: exit code 0 within the bound, both cut after the grace, no part file, nothing journaled, two `cut_by_close` records, every log whole |
|
||||
| `book_open_close::a_backup_and_a_sweep_that_took_their_handles_before_a_close_do_nothing_after_it`, `…a_drill_and_a_sweep…` | `--timer-hold` holds a timer between taking a book's handles and acting; the book is closed meanwhile, stray files planted, the timers go on: the closed book's tree doesn't move; opened again the sweep works (fail with the handles' closed state, the gate's check and the backups' shut flag removed) |
|
||||
| `book_open_close::a_close_stops_a_slow_drill_instead_of_waiting_for_it` | `--slow-steps` makes each phase of a drill wait a minute: the close answers plain `closed` (the last backup was made), within the stated sum, with the drill's scratch clone removed (fails without `hurry`: `closed_backup_incomplete`) |
|
||||
| `book_open_close::a_close_that_stops_git_in_a_commit_or_a_push_leaves_no_lock_and_the_next_backup_succeeds` | REAL git (a wrapper that points git's hooks at a `reference-transaction` hook that waits) stopped inside `init`, a commit and a push to a folder by a close: git is sent SIGTERM and removes its own locks, so none is left in the archive or the folder and the backup's record holds no `lock_removed` or `lock_left` (nothing for the server to clean up), the reopened book backs up with no step by hand, `git fsck --strict` passes on both |
|
||||
| `local::tests::a_close_stops_a_format_upgrade_before_it_is_journaled` | an upgrade held in its backup's proof: the close stops it, it says nothing was upgraded, the journal is byte for byte as before |
|
||||
| `local::tests::a_body_read_to_its_end_is_never_cut_and_one_not_yet_is` | the line of the cut: a body read to its end is never cut (the cut firing, the body asked again), one not read to its end is cut even with bytes on the way |
|
||||
| `ledger-store` `backup::tests::a_git_stopped_by_sigterm_mid_commit_…`, `…_stopped_mid_add_…`, `a_push_stopped_by_sigterm_…`, `a_git_that_ignores_sigterm_…`, `a_git_that_cannot_end_on_sigterm_…`, `a_lock_left_in_a_folder_target_…`, `a_push_stopped_during_the_pack_transfer_…`, `the_archives_age_rule_at_open`, `removal_after_a_stop_goes_through_the_handle_…`, `git_locks::tests` (3) | REAL git stopped inside a commit (HEAD and ref locks), an add (the index lock) and a push to a folder (the target's ref lock): on SIGTERM it removes its own locks and nothing is noted (the grace is long, so a git that needed the kill would show); a git whose group is frozen (SIGSTOP, so SIGTERM stays pending) is killed only after the grace, and the archive's locks it left (not there when the command began) are removed, noted; the folder target's lock is NEVER removed, reported with its whole path (`LockLeft`, `lock_left` with `path`), a lock that was there before the push is untouched and not named, a later push fails by git's words and removes nothing, the next one passes once the test removes the file; a fake git that traps SIGTERM is sent it first (marker) and killed after the grace with all it started; a 48 MiB pack held in the receiving end's `pre-receive` hook (the target's `incoming-` quarantine present) stopped by SIGTERM and by the kill, `git fsck --strict` on both repositories at once; the archive's locks at open: older than ten minutes removed and noted, younger left and said, non-lock names, folders and links untouched; a swapped `refs` folder or archive path after the handle was opened touches nothing outside; the handle module: exact lock names only, regular files only, no link followed |
|
||||
| `ledger-store` `backup::tests::a_drill_stops_inside_the_phase_it_is_told_to_stop_in` | for each phase (clone, replay, verify, blobs, prefix) a stop set as the phase begins ends the drill inside it (the observer sees no later phase), scratch removed; each case fails when the loop's looks inside that phase are removed |
|
||||
| `book_open_close::a_running_call_is_never_cut_when_the_grace_runs_out` | an ordinary call (`books.attach_receipt`, held inside its read of its file, a named pipe) past the grace (body whole) is not cut: it finishes when fed, is answered and recorded `ok`, and then the close is answered (a backup asked for is no longer this call: it is stoppable) |
|
||||
| `book_open_close::a_close_stops_a_running_backup_call_and_says_so` | `books.back_up_now` held in a stalled `git` (never lifted until the call answers): the close stops it, the call is answered that it was stopped because the books are closing, its access record is `refused: stopped_by_close` with no head, the backup record holds `stopped` and no result of its own for the run, git and all it started are gone, the close's last backup is made and the close answers `closed` |
|
||||
| `book_open_close::a_close_stops_a_running_verification_and_a_running_package_and_says_so` | `books.verify` and `books.export_cpa_package` held as they begin by `--timer-hold` (`call:...`), which the close releases: each is stopped at its first look, answers it was stopped, is recorded `refused: stopped_by_close`, the journal is unchanged |
|
||||
| `book_open_close::a_close_stops_the_restore_and_the_open_of_its_own_book_leaving_the_root_as_it_was` | a restore over a book and the open of a book, each held inside a phase (`restore:copy`, `open:start`): its scratch or staging folder is there while held; a close of THAT book stops it, it answers it was stopped, the root's `books/` and `legacy/` are byte for byte as before; asked again it goes through |
|
||||
| `book_open_close::the_servers_close_stops_every_running_admin_job_leaving_the_root_as_it_was` | restore (a new book, and over `acme`), adopt, create and open, each held inside a phase, the server closed with nothing lifting the hold: each answers it was stopped, the root as it was, exit 0; asked again on a new server the first goes through |
|
||||
| `book_open_close::closing_and_opening_one_book_never_stops_waits_for_or_refuses_another_books_jobs` | a restore over `beta`, a create of `epsilon` and an adoption of `delta` in flight (they make books one at a time, so the later two queue for their turn, and each is held in its phase in its time), `acme` closed (its backup's git stalled, so the close is slow) and opened again around each; during each close `cedar` is opened and closed and answers while the close of `acme` is still not answered; all three finish (`Restored`, `Created`, `Adopted`, no problem), none was stopped. Mutations: a close that raises a server-wide stop fails it (a queued job stopped); one global lock around open and close fails it (the open waits for the close) |
|
||||
| `book_open_close::a_close_never_leaves_a_decision_on_record_for_a_package_that_was_not_made` | `books.export_cpa_package` with `allow_open_drafts`: held as it begins and the book closed, it is stopped and the journal holds no decision; held right after its decision is journaled and the book closed, it is made, handed over (`ok`), one decision. Mutations: no look before the journaling fails the first; a build still stoppable after it fails the second |
|
||||
| `ledger-store` `tests/root.rs::a_job_stopped_at_any_phase_before_its_point_of_no_return_leaves_the_root_as_it_was` | create, adopt, restore (over existing books) and the restore preview stopped at each phase they ask: `Stopped`, the root (`books/`, `legacy/`) byte for byte as before; never stopped, `place` is the last phase asked (nothing after the point of no return) |
|
||||
| `ledger-store` `tests/root.rs::an_adoption_that_does_not_finish_leaves_no_lock_file_in_the_source` | a source with no lock file: the adoption stopped at each of its seven phases, refused after taking the lock (a stale preview head), and panicking in the middle leaves the source folder name for name, byte for byte and mode for mode as it was; a lock file swapped in by someone else during the adoption is not removed; a source that had its lock keeps it (stopped or adopted, `source_lock_created` false); a success of a source with none leaves the one it made and says so. Mutation: no removal fails it |
|
||||
| `ledger-store` `tests/root.rs::a_job_waiting_for_its_turn_stops_when_asked_and_otherwise_waits_for_it` | the turn at making books held (as another process would): a create that isn't asked to stop waits, and stops within seconds once asked (`Stopped`, nothing made); not asked, it goes through when the turn is let go. Mutation: a blocking wait for the turn fails it |
|
||||
| `book_open_close::a_lock_a_kill_leaves_in_the_backup_folder_is_reported_and_never_removed_by_the_server` | REAL git in a push to a folder with its group frozen, so only the kill after the grace ends it: the lock it leaves is still there after the close, recorded `lock_left` with its whole path, no `lock_removed` for the folder, the close's answer and `books.backup` name the file and say when it may be removed, a lock that was there before is neither touched nor named, a later backup fails by git's words and removes nothing, and once the file is removed the backup goes on, `git fsck --strict` on both |
|
||||
| `book_open_close::a_call_whose_answer_was_never_read_is_on_record_as_having_run` | a journaled draft whose client goes without reading: after the close the access log has its record, outcome `ok`, with the head it wrote (INVARIANT 14: a retry isn't made safe by anything; the record says it ran) |
|
||||
| `book_open_close::a_close_is_not_answered_while_its_backup_still_runs` | a book with a folder target and a stand-in `git` on the server's PATH that waits: the close isn't answered before its backup bound (1.2 s), then answers `closed_backup_incomplete`, git and all it started are gone, and lifting the stall makes nothing resume; the reopened book's backup record is a whole chain and it backs up (fails when `shut` is removed: git still runs after the answer) |
|
||||
| `book_open_close::a_close_whose_backup_fails_says_so_and_leaves_nothing_running` | a target whose disk isn't there: `closed_backup_incomplete` naming the failure, quickly, no git run afterwards; the same book with its disk back is answered plainly `closed` |
|
||||
| `book_open_close::an_upload_in_flight_finishes_before_the_close_is_answered` | an upload half received when the close begins: the close isn't answered until it is complete (200), its bytes are kept, its record is written, no `.part` is left, nothing moves afterwards |
|
||||
| `book_open_close::a_restore_over_an_open_book_waits_for_what_is_inside_it` | a replacing restore over a book with an upload half received isn't answered for five seconds (a restore that doesn't wait takes about one); the upload then completes, the replaced book's log in `legacy/` holds it, is whole, no `.part` is left in `legacy/`, and it stands still (fails when the restore lets the store go without the drain) |
|
||||
| `book_open_close::downloads_during_a_close_complete_or_are_refused` | four clients download a 300 KB file in a loop while the book closes: each answer is a whole 200 or a refusal, the number of 200s is the number of download records, and nothing moves after the answer |
|
||||
| `book_open_close::the_timers_never_touch_a_closed_book` | `--timers 5` (sweep, backup look, drill look every 5 ms) on a book with a backup target, closed and opened 8 times: while closed, with strays planted for a sweep to take, not one file moves; open, it is backed up and drilled; the logs end as whole chains |
|
||||
| `commands::tests::doctor_says_who_is_connected` | the doctor's lines for sessions |
|
||||
|
||||
**Waiting on conditions, not on guesses (review of 2026-11-20).** A test of
|
||||
this branch that slept for a fixed time to let "the other side get there"
|
||||
now waits on the condition: `exports::tests::a_close_waits_for_a_fetch_that_is_reading`
|
||||
(it slept 300 ms assuming its thread had reached the named pipe; it now
|
||||
opens a non-blocking writer on the pipe, which succeeds only once a reader
|
||||
has it open); the two MCP bodies that stop half way
|
||||
(`a_stalled_mcp_body_cannot_hold_a_close_…`, the server's-own-close test, the
|
||||
second of which slept 200 ms and the first nothing at all) send their head
|
||||
with `Expect: 100-continue` and their body only on the server's `100
|
||||
Continue`, which the server sends when its handler first reads the body,
|
||||
inside the book's door (`raw::Raw::start_inside`); the late-timer test no
|
||||
longer sleeps 300 ms before its 800 ms window in which nothing may move;
|
||||
`a_close_whose_backup_fails_…` waits out the backup the opening makes by
|
||||
asking for one itself (it could be stopped by the close and leave a lock). The
|
||||
sleeps that remain are negative windows (a close must NOT have been answered;
|
||||
nothing must move), which can only fail when the property is broken, never
|
||||
because the machine is slow, and pacing of a stimulus (the hammer's jitter,
|
||||
a client trickling an upload on purpose).
|
||||
|
||||
**For P12 (mutation targets).** `Gate::enter` (count before looking at `shut`),
|
||||
`Books::release`'s order (the store's close, the gate emptied, sessions ended, the last backup, `Backups::shut`, the logs and files closed, `let_go`) and `Backups::begin`'s count-before-flag, `Backups::shut` (the flag, the turn, the steps drained, the record closed), `ChainLog::close`, `refused_at_door` taking the request's place into its task, the sweep taking the gate, `door`'s entering
|
||||
before it touches the book, and the gate's riding in the upload and
|
||||
download tasks.
|
||||
|
||||
## P12: the checklists
|
||||
|
||||
The **For P12** paragraphs above (kept where they were written, with their
|
||||
|
||||
Reference in new issue
Block a user