Join active file saves after shutdown settlement fails (#664) #675

Closed
kayg wants to merge 0 commits from issue/664-shutdown-settle into dev
Owner

Shutdown could poll a completed history receipt while a file save was paused, panic the room, and drop the active Flush. Receipts are now consumed once, and both actor loops share one shutdown failure state while frozen file work and writer joins still finish.

A placed save also retains its completion until history promotion succeeds. The room keeps the exact written base immediately, then finishes promotion before another save or outside merge replaces the pending row. This prevents recovery from merging its own file twice. Failed promotion retains only small completion metadata; healthy saves reuse their frozen text.

Permanent tests cover the DuringPrepare reproduction, promotion failure with and without an outside edit, late disk recovery after writer closure, and 500 generated interleavings per property run. The property checks actor panics directly, durable Saved receipts, the five-second shutdown allowance, file ordering, and exact replay twice after restart. Quota configuration runs separately from the writes it makes fail. Delayed quota restoration after shutdown intentionally expects "history writer stopped" and client replay on restart.

Validation ran as an unprivileged user in an isolated staging checkout, with all 1,060 source files matched to this commit and disk use below 60%. The existing notes_live startup health probe reset once in an earlier run; its unchanged target then passed 20 focused repetitions, and the final workspace run passed.

cargo fmt --check: exit 0
cargo clippy --workspace --all-targets -j4 -- -D warnings: exit 0
cargo test --workspace -j4: exit 0
workspace totals: 923 passed, 0 failed, 7 ignored
notes crash tests: 30/30 repetitions passed
new regression and state-machine property: 20/20 repetitions passed; 10,000 generated cases
N-room tests: 10/10 repetitions passed (12 and 100 rooms)
all requested gates: PASS

Refs #664. Verbatim gate output and findings are recorded on the issue.

Shutdown could poll a completed history receipt while a file save was paused, panic the room, and drop the active Flush. Receipts are now consumed once, and both actor loops share one shutdown failure state while frozen file work and writer joins still finish. A placed save also retains its completion until history promotion succeeds. The room keeps the exact written base immediately, then finishes promotion before another save or outside merge replaces the pending row. This prevents recovery from merging its own file twice. Failed promotion retains only small completion metadata; healthy saves reuse their frozen text. Permanent tests cover the DuringPrepare reproduction, promotion failure with and without an outside edit, late disk recovery after writer closure, and 500 generated interleavings per property run. The property checks actor panics directly, durable Saved receipts, the five-second shutdown allowance, file ordering, and exact replay twice after restart. Quota configuration runs separately from the writes it makes fail. Delayed quota restoration after shutdown intentionally expects "history writer stopped" and client replay on restart. Validation ran as an unprivileged user in an isolated staging checkout, with all 1,060 source files matched to this commit and disk use below 60%. The existing notes_live startup health probe reset once in an earlier run; its unchanged target then passed 20 focused repetitions, and the final workspace run passed. ```text cargo fmt --check: exit 0 cargo clippy --workspace --all-targets -j4 -- -D warnings: exit 0 cargo test --workspace -j4: exit 0 workspace totals: 923 passed, 0 failed, 7 ignored notes crash tests: 30/30 repetitions passed new regression and state-machine property: 20/20 repetitions passed; 10,000 generated cases N-room tests: 10/10 repetitions passed (12 and 100 rooms) all requested gates: PASS ``` Refs #664. Verbatim gate output and findings are recorded on the issue.
Let Shutdown reach the actor's closing path without the read-command
settle check. A history error must not refuse the stop request and leave
RoomHandle::shutdown waiting forever. Closing still attempts to settle
and save, and Saved still waits for durable history so clients can replay
unacknowledged changes after restart, as required by ADR 0020.

Cover persistent SQLite page-quota failures, shutdown within the settle
budget, lock reacquisition, writer closure, no false Saved and recovery
of pending client state after restart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U5oTUycqAh7DT72mdSUztk
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U5oTUycqAh7DT72mdSUztk
Close at most sixteen rooms together and let each closing actor settle
history once before saving. Skip file placement after settlement fails,
and stop history retry backoff and requeueing when shutdown begins.
Keep actor and writer joins ahead of releasing storage.

Cover 12 and 100 full-history rooms within the five-second allowance,
unchanged durable state, no false Saved, and repeated replay after restart.
Also cover healthy shutdown saving pending typing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U5oTUycqAh7DT72mdSUztk
Join active file saves after shutdown settlement fails (#664)
Some checks failed
CI / web (pull_request) Failing after 55s
CI / server (pull_request) Successful in 1m22s
CI / rust (pull_request) Failing after 3m48s
0ca023cd1e
Consume history receipts once and share one shutdown failure state between
both actor loops. Stop history submission and receipt consumption after
closing settlement fails while still awaiting frozen file work and writers.

Keep a placed file's exact base and unfinished completion when history
promotion fails. Finish that promotion before another save or outside merge
can replace its pending row, so recovery never merges our own file twice.
Healthy saves reuse frozen text; retries retain only completion metadata.

Add the live-save shutdown reproduction, promotion failure with and without
outside edits, and a real-room state-machine property with 500 generated
cases, observing actor panics independently of discarded join errors.
Isolate test quota configuration from the writes it makes fail. The delayed
disk-recovery probe now expects "history writer stopped" after failed
shutdown; unacknowledged typing is recovered by client replay on restart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U5oTUycqAh7DT72mdSUztk
Author
Owner

Landed through train BF (PR #677, 3671dc4), live on calternal.cloud. Closing this duplicate.

Landed through train BF (PR #677, 3671dc4), live on calternal.cloud. Closing this duplicate.
kayg closed this pull request 2026-10-23 03:42:28 +00:00
Some checks failed
CI / web (pull_request) Failing after 55s
CI / server (pull_request) Successful in 1m22s
CI / rust (pull_request) Failing after 3m48s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal!675
No description provided.