Repository navigation
CONTRACT: fix(ui-server): contain individual host recovery failures - #3824
Conversation
|
Implementation handoff: #3824, head Local acceptance proof is complete: 72 focused tests; 39 provider-history/index tests; four failing/restored guard mutations; clean typecheck, lint and changeset validation; 1,280 passing preflight invariants; and passing actual offline Btrfs reference-pool and native-manager/host proofs with complete owned-resource cleanup. Current draft gates, contract and changeset checks passed; full candidate jobs are intentionally not yet requested. No reviews are present.
Resume after that reservation ends: reclaim #3816, fetch/rebase onto current |
24d218b to
3755d1c
Compare
# Conflicts: # docs/decisions/governed-writable-workers.md # docs/decisions/journal-database.md # docs/decisions/managed-worktrees.md # docs/integration-contract/package-api.md # docs/integration-contract/wire.md # packages/ui-server/tests/turn-journal.test.ts
…stderr lines Journal accounting runs inside the write worker and the writer gate's callers carry no logger, so their single structured cause line now goes to stderr directly instead of through console, which the package's console-discipline test refuses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The journal-migration guard parsed `ON DELETE CASCADE` in migration 085's quarantine table as a reference to an object named DELETE. Foreign-key actions are stripped before names are collected; a mutation pointing the same reference at the UI database's settings table still fails the guard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s alive The new indefinite release/dequeue retry slept on a referenced timer. A process that released its hold and closed its database at shutdown then retried the delete against the closed connection forever and never exited, which the maintenance boundary diagnostics test caught as a missing exit status. The retry's timer is unreferenced: an exited process's row is stale and the next gate read prunes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes #3816
What changed
Failed writer-gate deletes retry until the real delete commits. Disposable native indexes rebuild in place. Corrupt interrupted journal objects and malformed native intents stay quarantined while healthy work continues. Authenticated
/api/statusexposes native recovery restrictions. SDK and server changesets remain minor for the additive API fields.Why this shape
Follows #3813 and proportionate containment. Durable intents retain identity authority. A new independent allowance record preserves each stage's exact tmpfs cap before namespace creation, so a smaller configuration cannot under-count surviving storage. Missing directories prove no stage storage; missing historical bounds never become zero. Journal quarantine never restores corrupt bytes or erases old gap facts.
Review follow-up
worker_state_busy, and authenticated status reportshealthy: false. This fallback is necessary because today's allowance cannot prove an older cap.bun scripts/check-citations.ts.nativeRecoveryto the HTTP integration contract, including numeric/unknown charge semantics, authentication and health behavior.Containment checklist
Proof
Current head
133c941bb0ab3c1aa27fa816830251e8dd135198, baseorigin/maine4c4c1c99484196302428b6f6bd3186f125af00d. Checked out the reviewed3755d1c464245a6b8c0a794e9a8f50b5d925f402and rangit merge --no-edit origin/main; the freshly fetched base was already included, so no rebase or merge conflict was needed.NODE_OPTIONS=--max-old-space-size=8192 bun run typecheckpassed after correcting the test mock-list type.bun scripts/prove-native-host.ts --backend=claude --app-uid=1000passed: 2 hosted tests / 114 assertions, plus the selected media-worker case (1 test / 29 assertions). The real recovery case preserves an 8 KiB cap after configuration shrinks to 4 KiB, admits one healthy stage in the remaining budget, and refuses an excess stage. All owned mounts, loop resources and backing were cleaned up. This runtime provides no enforced AppArmor qualification.bun run api-reportproduced no additional API-report diff. Lint/leakage, changeset package validation and the full pending changeset plan passed: all twenty packages remain minor; no major.bun run check:pr --base origin/mainpassed all selected checks on this committed head; receipt below.NATIVE_QUARANTINE_RETAINS_HISTORICAL_ALLOWANCE: expected 8192, received 4096.NATIVE_QUARANTINE_CHARGE_REMAINS_RESERVED: an extra stage incorrectly fits.NATIVE_UNBOUNDED_QUARANTINE_IS_RECOVERY_NOT_BUSY: capacity error instead of recovery.NATIVE_BOUND_SURVIVES_UNCONFIRMED_CLOSE: the bound disappears.RECOVERY_INDEX_RETRIES_CONCRETE_DIAGNOSTIC_WRITE: no durable cause after recovery.NATIVE_UNBOUNDED_QUARANTINE_IS_UNHEALTHY: expected false, received true.{ "version": 1, "kind": "brain-check-pr-receipt", "head": "88abc91988ec75ff60a640ad3fdd32a7c7a2cca9", "base": "origin/main", "mode": "focused", "startedAt": "2026-11-10T08:45:01.683Z", "finishedAt": "2026-11-10T08:46:37.001Z", "checks": [ { "name": "all lint and leakage gates", "categories": [ "changeset" ], "outcome": "passed", "elapsedMs": 10788.982962 }, { "name": "environment documentation", "categories": [ "changeset" ], "outcome": "passed", "elapsedMs": 95.02625600000101 }, { "name": "pending changeset package names", "categories": [ "changeset" ], "outcome": "passed", "elapsedMs": 59.5196360000009 }, { "name": "contribution changeset", "categories": [ "changeset" ], "outcome": "passed", "elapsedMs": 17.29240799999934 }, { "name": "affected fast invariants", "categories": [ "verify", "unit" ], "outcome": "passed", "elapsedMs": 84318.419368 } ] }Historical first-round proof at 3755d1c (retained as evidence, superseded above)
Tested head
3755d1c464245a6b8c0a794e9a8f50b5d925f402againstorigin/maine4c4c1c99484196302428b6f6bd3186f125af00d. Rebased onto the backend-containment change (#3822); status-route conflicts retain both diagnostics. The working tree is clean.24d218bd41530d522832d7e85ae85246263fd45d: actual BtrfsprepareStagefailed with the unconditional “Unreadable native intents keep staging capacity charged” refusal. The healthy-stage test exercises the production manager and real namespace setup.JOURNAL_RECAPTURE_DOES_NOT_STOP_OTHER_ACTIVE_TURNSfailed with two stop callbacks carrying the quarantined-object error, through the concrete journal/capture/write-worker path.NODE_OPTIONS=--max-old-space-size=8192 bun run typecheckpassed. Regenerating API reports produced no further changes.bun scripts/prove-native-host.ts --backend=claude --app-uid=1000passed after both native mutations were restored: 2 hosted tests / 112 assertions, the selected media-worker case, and complete owned mount/loop/backing cleanup. This fixture has no enforced AppArmor qualification.bun scripts/prove-reference-pool.tspassed, including recovery-index fault injection and the next real checkpoint; both owned mounts and loop devices were cleaned up.bun run check:pr --base origin/mainpassed all selected checks, including 1,280 fast invariants / 8,565 assertions. Changeset package validation and the complete pending changeset plan passed (all twenty packages remain minor; no major).NATIVE_QUARANTINE_CHARGE_REMAINS_RESERVEDfails: an extra stage incorrectly fits.JOURNAL_RECAPTURE_DOES_NOT_STOP_OTHER_ACTIVE_TURNSfails with both active turns stopped.NATIVE_DIAGNOSTIC_FAILURE_DOES_NOT_BLOCK_BOOTfails on the diagnostic directory error.RECOVERY_INDEX_DIAGNOSTIC_DOES_NOT_BLOCK_REBUILDfails.NATIVE_QUARANTINE_VISIBLE_TO_OWNERfails after authenticated login.JOURNAL_IO_ERROR_IS_NOT_CORRUPTIONcases fail.GATE_CLEANUP_CAUSE_IS_DURABLEcases fail.PURGE_REMOVES_QUARANTINE_WITH_FOREIGN_KEYS_DISABLEDfails.JOURNAL_FINISH_PRESERVES_RECOVERY_GAPfails.Checklist
Anything left open
Optional N4: Authenticated status does not yet count journal object reservations left unresolved by persistent I/O errors. The recovery worker still logs the cause and retains the durable reservation without changing object truth or releasing its charge. An accurate count needs reporting from the journal worker to status, so it is left outside this focused follow-up as permitted by the review request.
Legacy malformed stage receipts with surviving directories and no independent allowance cannot safely inherit today's cap; they remain explicitly recovery-restricted until the owner proves their original bound or cleanup. This is a conservative compatibility case, not a zero charge or a transient-busy claim.
The PR remains ready for the coordinator. No
integrate.ts confirmor merge was run. Exact-candidate confirmation, selected hosted proof, any later base reconciliation and merge remain the coordinator's responsibility.Refresh after #3815 and #3817
A third independent review found nothing blocking; its remaining narrow findings (a quarantined-only staging charge still reported as busy, unresolved journal records not on status, three nits) are filed as #3826, and the N4 item from the second review is part of it.
Main was merged in after #3823. Conflicts were citation line numbers in
turn-journal.ts, #3815's revised failed-release text (kept), and adjacent additions inpackage-api.mdandturn-journal.test.ts(both kept); the driftedturn-journal.tscitations were repointed. The merged tree failedno-console.test.tson three recovery-cause lines injournal-accounting.tsandwriter-gate.ts; journal accounting runs inside the write worker and the gate's callers carry no logger, so the same single structured line is now written to stderr directly. Typecheck, the journal, gate, observer and console suites, and preflight pass on the merged head.The first hosted confirmation failed
journal-database.test.ts: its migration guard readON DELETE CASCADEin migration 085 as a reference to an object named DELETE. Foreign-key actions are now stripped before names are collected; pointing the reference at the UI database'ssettingstable still fails the guard (mutation receipt). The same run'sruntime_hostfailure was an Ubuntu mirror fetch error while building the runner image.A later confirmation failed
maintenance-temp-boundary-diagnostics.test.tson this branch only (it passes on main): the writer gate's new indefinite cleanup retry slept on a referenced timer, so a process that released its hold and then closed its database retried against the closed connection and never exited. The retry timer is now unreferenced; an exited process's row is stale and the next gate read prunes it. The test fails before the fix and passes after; writer-gate suite passes.