fix(mcp,store): a close stops every call and job that can run long, and says so; an unrecorded refusal never ran
A close waited, unbounded, for a running books.back_up_now (git only Backups::shut could cancel), for a restore, create or adopt (they hold the one lifecycle lock, and at the server's close admin_jobs.wait() waited for them before anything was released), and, through the store lock, for a verification or a package reading every stored file. The bound's T_calls term was not finite. Now a close calls hurry at its start, and the stoppable work looks at it: books.back_up_now and timer-asked backups (git stopped, a stopped run records 'stopped' and no result of its own), books.verify (per journal line and file; a heal of a drifted database is begun only if no stop came before it: stopped half way it would leave the live ledger part replayed), books.export_cpa_package (per stored file). Such a call answers that it was stopped because the books are closing, and its access record says refused: stopped_by_close. On the admin socket restore, adopt, create and open take a JobStop: asked at each phase and file copied, they remove what they wrote and leave the root byte for byte as it was; the renames that put the books in place are the point of no return, after which they finish (two renames and two syncs). A close of any book, and the server's own, raises the flag before it waits for the lifecycle lock. A close whose last backup had to be killed in the owner's folder now says which file was left, and the target's backup is marked failed by shut when the run's future was dropped at its bound. INVARIANT 10 is rewritten so each term of the bound is enforced by code, and lists the calls that can run long (and the one known exception, books.import_bank_csv); INVARIANTS 8 and 9 say exactly which refusals are recorded and why an unrecorded one never ran; the format upgrade's wording says a stop is honoured up to its final look. Tests: the close is held to the bound while a backup call, a verification, a package and each admin job is running and would never end; the stopped job leaves the root byte for byte as it was; a lock left in a backup folder is reported and never removed. Sleeps that stood for 'the other side got there' now wait on the condition (Expect: 100-continue for a half-sent body, a writable named pipe for a fetch that is reading). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6f174f3f87
commit
aa64df9a25
18 files changed
+1889
-248
No files matched your search
+27
-3
@@ -4326,12 +4326,17 @@ one book never refuses or holds up a call on another.
|
||||
| `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) killed inside `init`, a commit and a push to a folder by a close: no lock left in the archive or the folder before the close is answered, each recorded, the reopened book backs up with no step by hand, `git fsck --strict` passes on both |
|
||||
| `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_killed_mid_commit_…`, `…_mid_add_…`, `…_mid_push_…`, `locks_found_in_the_archive_when_the_books_open_…` | real git killed inside a commit (HEAD and ref locks), an add (the index lock) and a push to a folder (the target's ref lock): locks removed once the group is gone, noted; a lock that was in the target before the push is never removed, and the target's lock is removed only after LOCK_SETTLE; next backup succeeds, `git fsck` passes; the archive's locks are cleared at open |
|
||||
| `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` | `books.back_up_now` held in a stalled `git` past the grace (body whole) is not cut: it finishes, is answered and recorded `ok`, and then the close is answered |
|
||||
| `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_a_running_restore_adopt_create_and_open_leaving_the_root_as_it_was` | each admin job held inside a phase (`restore:copy`, `adopt:open`, `create:start`, `open:start`): its scratch or staging folder is there while held; a close of another 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 |
|
||||
| `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) |
|
||||
| `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` |
|
||||
@@ -4341,6 +4346,25 @@ one book never refuses or holds up a call on another.
|
||||
| `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
|
||||
|
||||
Reference in new issue
Block a user