Repository navigation
fix(doctor): updates fail on a full disk because Doctor copies a stopped database just to read it - #196346
Conversation
…ped database just to read it During update activation Doctor holds schema-maintenance custody and the Gateway is stopped, yet its captured inspections still read every agent database through a private whole-file copy. On a host with a 21 GiB agent database that copy did not fit, session-entry-state refused, and the update left the Gateway stopped. When Doctor has custody and the family is drained (no journal, empty WAL), the artifact-preserving reader now opens the source in place through an immutable read-only URI, adding no lock, WAL or index beside it, and rejects the read if the source changed. Undrained or uncustodied reads keep the private copy. Captured inspection tests move to a sibling file to keep the session-entry test under its line cap.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesDoctor reads drained SQLite databases in place under maintenance custody instead of making a full-size inspection copy. Example: The reported APFS reproduction has a 31 MiB drained agent database and 18 MiB free.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it addresses an evidenced update failure still present on main, and inspection found no concrete introduced defect. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherUpdate activation invokes Doctor under migration capture and maintenance custody; the session scanner reads agent SQLite rows and returns repair candidates while preserving the captured source. flowchart TD
A[Update activation] --> B[Captured Doctor scan]
B --> C[Artifact-preserving reader]
C --> D[Custodied and drained source]
C --> E[Private snapshot fallback]
D --> F[Immutable read and close-time validation]
E --> G[Session inspection results]
F --> G
Technical reviewBest possible solution: Keep copy avoidance in the existing artifact-preserving reader, with maintenance custody, drained-family eligibility, source validation, and the existing snapshot fallback. Do we have a high-confidence way to reproduce the issue? Current-main source requires a whole-file snapshot in the reported captured scan, matching the supplied full-disk reproduction; no target code was executed during this review. Is this the best way to solve the issue? The focused change removes unnecessary copying through existing ownership and immutable-open contracts while retaining private recovery for undrained or uncustodied sources. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d1518e4d07a5. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +54, Tests +138. Total +192 across 5 files. Added test files: 2. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 9, 2026, 7:44 PM ET / November 10, 2026, 00:44 UTC. |
|
Merged via squash.
|
…e runs out (#196370) * fix(doctor): defer update session-entry inspection when snapshot space runs out During an update, a SqliteSnapshotCapacityError while staging the read-only session-entry snapshot refused the required session-entry-state step and stopped activation, even though nothing had been read or changed. Skip that target with a recoverable deferred warning instead, and let doctor --fix finish it after the update. Other failures, and runs outside an update, still refuse. * test: allocate update session-entry capacity regression lines * test(doctor): keep update capacity fixtures on the private-snapshot path A drained, custodied family is now read in place, so the capacity deferral applies to families that still hold WAL frames. * test: allocate drained capture test lines from #196346
…ped database just to read it (openclaw#196346) During update activation Doctor holds schema-maintenance custody and the Gateway is stopped, yet its captured inspections still read every agent database through a private whole-file copy. On a host with a 21 GiB agent database that copy did not fit, session-entry-state refused, and the update left the Gateway stopped. When Doctor has custody and the family is drained (no journal, empty WAL), the artifact-preserving reader now opens the source in place through an immutable read-only URI, adding no lock, WAL or index beside it, and rejects the read if the source changed. Undrained or uncustodied reads keep the private copy. Captured inspection tests move to a sibling file to keep the session-entry test under its line cap.
…e runs out (openclaw#196370) * fix(doctor): defer update session-entry inspection when snapshot space runs out During an update, a SqliteSnapshotCapacityError while staging the read-only session-entry snapshot refused the required session-entry-state step and stopped activation, even though nothing had been read or changed. Skip that target with a recoverable deferred warning instead, and let doctor --fix finish it after the update. Other failures, and runs outside an update, still refuse. * test: allocate update session-entry capacity regression lines * test(doctor): keep update capacity fixtures on the private-snapshot path A drained, custodied family is now read in place, so the capacity deferral applies to families that still hold WAL frames. * test: allocate drained capture test lines from openclaw#196346
…#196346) Backport the custodied immutable-read repair while preserving the release branch synchronous inspection and existing snapshot cleanup owners. (cherry picked from commit b91520c) Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
Preserve verified main 0c5c475 and all six planner contribution files. Account separately for the 128 inherited test lines above the ceiling: #196346 added 138 LF against 10 prior slack. Keep the planner grant at 157 and the shared scalar intact. The actual staged checker against 0c5c475 passed: 6,635,333 lines, 6,635,333 ceiling, zero slack.
…ped database just to read it (openclaw#196346) Release-specific adaptation for 2026.11.4: Read an exclusively custodied, drained agent DB in place; keep snapshot fallback and release cache/cleanup ownership. Source commit: b91520c Source PR: openclaw#196346 CI qualification pending; source-only verification completed. Co-authored-by: RomneyDa <[email protected]>
…e runs out (#196370) * fix(doctor): defer update session-entry inspection when snapshot space runs out During an update, a SqliteSnapshotCapacityError while staging the read-only session-entry snapshot refused the required session-entry-state step and stopped activation, even though nothing had been read or changed. Skip that target with a recoverable deferred warning instead, and let doctor --fix finish it after the update. Other failures, and runs outside an update, still refuse. * test: allocate update session-entry capacity regression lines * test(doctor): keep update capacity fixtures on the private-snapshot path A drained, custodied family is now read in place, so the capacity deferral applies to families that still hold WAL frames. * test: allocate drained capture test lines from #196346 (cherry picked from commit ef47e2e) Co-authored-by: RomneyDa <[email protected]>
Related: #174599, #188025, #194325
What Problem This Solves
Fixes: an update fails on a nearly full disk, leaving the Gateway stopped, when Doctor copies a stopped agent database just to read it during activation.
User Impact
User impact: updates on hosts with large agent databases no longer need free space equal to the largest database for Doctor's read-only session inspection. On the affected Gateway that copy needed 21 GiB with 16 GiB free, so
session-entry-staterefused and the update stopped. No configuration or migration is needed.Why This Change Was Made
Update activation runs Doctor inside the updater's migration capture. Captured inspections read each agent database through a private whole-file byte copy (#174599) so that nothing is written beside the source: no locks, WAL, index or sidecars, and the idle WAL header the updater verifies stays intact. During activation, though, the Gateway is stopped and Doctor holds schema-maintenance custody. When the family is also drained (no journal, empty WAL), the copy protects nothing. The source has no frames to interpret and no other owner can open it. On the affected Gateway the agent database Doctor inspected had a 0-byte WAL.
The artifact-preserving reader (
openSqliteReadOnlyDatabase) now opens a drained, custodied source in place through an immutable read-only URI. That is the same open #194325 uses for the updater's generation reads. It adds nothing beside the source, and at close it rejects the read if the inode, size or mtime changed or the family stopped being drained. The capturedsession-entry-statescan uses that owner when the source qualifies. Undrained families, uncustodied readers and every non-captured path keep the private copy unchanged.Update behavior: the change runs in the candidate's Doctor and keys only on custody and on-disk drained state, so updates driven by already-published updaters benefit as soon as the candidate includes it. The installed updater's preflight is unchanged. A separate change will make that budget accurate.
Evidence
OPENCLAW_UPDATE_IN_PROGRESS=1,TMPDIRon the volume, as shipped updaters set). It contained a 31 MiB drained agent database with 18 MiB free, and the capturedsession-entry-statescan ran under maintenance custody.Failing check session-entry-state (step-refused): SQLite read-only worker failed while creating its private snapshot, the exact production error.src/commands/doctor-session-entry-state.capture.test.ts:The capture tests moved out of
doctor-session-entry-state.test.tsinto this sibling file, with shared fixtures in a.test-support.tsfile, to keep that file under its line cap. No coverage was dropped.node scripts/check-changed.mjspasses typecheck, lint, format and the ratchets. Its dead-export scan fails only on files this PR does not touch (src/daemon/launchd.ts,src/plugins/provider-runtime.ts), a failure already on main.