Repository navigation
fix: keep doctor --fix pending checks from creating SQLite sidecars - #206485
fuller-stack-dev merged 5 commits into
Conversation
A read-only node:sqlite open of a WAL store whose sidecars are absent creates -shm and -wal and cannot remove them. Pending checks that read the state or an agent database now decide only while a connection holds the store, and otherwise answer undecidable, through the shared live-store guard. Repair-side reads for agent database paths, generated exec approvals and retired usage-cost rows take the old write path for an unheld store. The store snapshot helper now records sidecars, and two tests run every registered contribution and step check on stores with no sidecars.
|
🦞👀 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 changes before merge. What this changesThis PR prevents Doctor pending checks from creating SQLite sidecars and preserves the existing repair paths when a safe read is unavailable. Example: Doctor checks state/openclaw.sqlite in WAL mode with no -wal or -shm files present.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Needs changes before merge - 2 items remain Keep this PR open: it repairs a source-confirmed read-only contract violation using the existing SQLite guard, but the new note mock introduces a required-check failure. Reviewed head: Before merge
Findings
Tests
Agent review detailsHow this fits togetherDoctor evaluates pending checks before maintenance repairs; these checks consume configuration and database state and emit work, none, or undecidable decisions for tracing. flowchart TD
A[Doctor fix flow] --> B[Pending check]
B --> C[Existing sidecar guard]
C --> D[Safe live store read]
C --> E[Undecidable]
D --> F[Recorded decision]
E --> F
F --> G[Existing repair execution]
Technical reviewBest possible solution: Keep the shared sidecar guard and existing repair owners, preserve the note module’s exports in the new test, and resolve the test allowance. Do we have a high-confidence way to reproduce the issue? Current-main pending checks reach native read-only WAL opens without the established sidecar guard; the PR records red-on-base failures on real SQLite stores, though this read-only review ran no reproduction. Is this the best way to solve the issue? The production approach is appropriately scoped: it shares the existing safety probe, returns undecidable when necessary, and retains repair execution rather than deleting sidecars after inspection. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 42e4aec4ca9a. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +216, Tests +493. Total +709 across 20 files. Added test files: 3. 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 27, 2026, 3:01 AM ET / 08:01 UTC. |
|
Merged via squash.
|
* commit 'fd681ab8786e062045fa5ec6261b1b06f60832eb': (2115 commits) fix: keep doctor --fix pending checks from creating SQLite sidecars (#206485) fix(ci): update iOS screenshot reducer gate (#206497) fix: keep chat photo previews sharp within their byte limits (#206461) fix: let agents use short Workboard card IDs fix(tui): run provider sign-in in the local TUI (#200605) improve(config): reduce repeated directory checks for larger agent rosters (#206494) perf(test): reuse the Periphery producer workflow snapshot (#189681) fix(ci): keep locale assets within the installed package budget (#206492) fix: preserve failed Apple chat messages across partial history pages (#205404) improve: avoid merging unrelated settings for agent directory lookups (#206489) fix: show typing while a queued follow-up turn runs (#201920) fix: stop 2026-11-17 main Git checkouts from half-switching on a schema update (#206341) refactor(codex): centralize native completion delivery (#206447) fix(subagents): finish claimed stops after session rotation (#206405) fix: let owners fork a chat with exec after a subagent or exec completion (#206483) test(cli): gate agent --local cold-start processes and workers (#206466) perf(ci): skip baseline inventory when line-cap debt is empty (#189909) refactor(test): share core process-result fixtures (#174149) refactor(ci): reuse canonical budget flag parsing (#189480) fix: recover Codex chats after oversized requests (#206475) ...
* commit 'fd681ab8786e062045fa5ec6261b1b06f60832eb': (923 commits) fix: keep doctor --fix pending checks from creating SQLite sidecars (#206485) fix(ci): update iOS screenshot reducer gate (#206497) fix: keep chat photo previews sharp within their byte limits (#206461) fix: let agents use short Workboard card IDs fix(tui): run provider sign-in in the local TUI (#200605) improve(config): reduce repeated directory checks for larger agent rosters (#206494) perf(test): reuse the Periphery producer workflow snapshot (#189681) fix(ci): keep locale assets within the installed package budget (#206492) fix: preserve failed Apple chat messages across partial history pages (#205404) improve: avoid merging unrelated settings for agent directory lookups (#206489) fix: show typing while a queued follow-up turn runs (#201920) fix: stop 2026-11-17 main Git checkouts from half-switching on a schema update (#206341) refactor(codex): centralize native completion delivery (#206447) fix(subagents): finish claimed stops after session rotation (#206405) fix: let owners fork a chat with exec after a subagent or exec completion (#206483) test(cli): gate agent --local cold-start processes and workers (#206466) perf(ci): skip baseline inventory when line-cap debt is empty (#189909) refactor(test): share core process-result fixtures (#174149) refactor(ci): reuse canonical budget flag parsing (#189480) fix: recover Codex chats after oversized requests (#206475) ...
…ds nothing (#206694) * fix(doctor): skip the state schema repair when its read-only plan finds nothing Doctor's shared-state schema repair ran on every doctor --fix (doctor mode repairs unconditionally since #155446): a write-mode open of the state, credential and quarantine stores, the schema lease, write transactions and a clean-close seal invalidation, even on a healthy install where it changes nothing. planOpenClawStateDatabaseDoctorRepair enumerates every condition the doctor-scope repair acts on at the current schema version, each decided at its owner from the rows or catalog entries that step writes (delivery queue compaction and pruning, cron job projection, subagent payloads, approval references, ACP accounting, credential receipt, canonical catalog, indexes, integrity and the rest). It reads the live stores through the #206485 guard, so a store nobody holds is undecidable. The repair runs exactly as before unless every condition answers none. The config-flow pending check now records this plan as its first input and stays at work while the agent database and plugin obligation inputs have no predicate. * fix(doctor): include quarantine clearing in the state schema plan and fall back on plan errors * test(doctor): add guard fixtures for the remaining state schema plan conditions * fix(doctor): read the schema version predicate through Kysely and record the guard test lines * fix(doctor): load the state schema plan only for Doctor and list it in the PR wrapper inventory * refactor(doctor): trace config-flow inputs through the startup helper * fix(doctor): give the config-flow pending tracer one exported spelling
…penclaw#206485) * fix: keep doctor --fix pending checks from creating SQLite sidecars A read-only node:sqlite open of a WAL store whose sidecars are absent creates -shm and -wal and cannot remove them. Pending checks that read the state or an agent database now decide only while a connection holds the store, and otherwise answer undecidable, through the shared live-store guard. Repair-side reads for agent database paths, generated exec approvals and retired usage-cost rows take the old write path for an unheld store. The store snapshot helper now records sidecars, and two tests run every registered contribution and step check on stores with no sidecars. * test: fold the step pending guard into the stopped-Gateway Doctor test * test: close held store connections explicitly
…ds nothing (openclaw#206694) * fix(doctor): skip the state schema repair when its read-only plan finds nothing Doctor's shared-state schema repair ran on every doctor --fix (doctor mode repairs unconditionally since openclaw#155446): a write-mode open of the state, credential and quarantine stores, the schema lease, write transactions and a clean-close seal invalidation, even on a healthy install where it changes nothing. planOpenClawStateDatabaseDoctorRepair enumerates every condition the doctor-scope repair acts on at the current schema version, each decided at its owner from the rows or catalog entries that step writes (delivery queue compaction and pruning, cron job projection, subagent payloads, approval references, ACP accounting, credential receipt, canonical catalog, indexes, integrity and the rest). It reads the live stores through the openclaw#206485 guard, so a store nobody holds is undecidable. The repair runs exactly as before unless every condition answers none. The config-flow pending check now records this plan as its first input and stays at work while the agent database and plugin obligation inputs have no predicate. * fix(doctor): include quarantine clearing in the state schema plan and fall back on plan errors * test(doctor): add guard fixtures for the remaining state schema plan conditions * fix(doctor): read the schema version predicate through Kysely and record the guard test lines * fix(doctor): load the state schema plan only for Doctor and list it in the PR wrapper inventory * refactor(doctor): trace config-flow inputs through the startup helper * fix(doctor): give the config-flow pending tracer one exported spelling
Related: #204775 (follow-up to #206348, #206247, #206420, #206195, #206246)
What Problem This Solves
openclaw doctor --fixrecords a read-onlypendingdecision before each repair. The contract insrc/commands/doctor-maintenance-pending.tssays a check must not open a store in a mode that can create files. Several checks broke it: they open the state or an agent database read-only, and a read-only SQLite open of a WAL database whose-wal/-shmare absent creates both files and cannot remove them. After the Gateway stops, no connection holds the stores, so a check that is the first reader leaves a 32 KB-shmand an empty-walbehind. The snapshot helper the tests used skipped every-shmand every empty-wal, so the "decides without writing" assertions could not see this.User Impact
No visible change in today's
doctor --fix. Every step still runs and the stop is unchanged. Pending answers are only traced; a check that meets an unheld store now tracespending=undecidable(counted as work) instead of opening it. Beside a serving Gateway, which holds its stores, the checks decide as before. This keeps the contract true for the planned step that runs these checks before the stop.Why This Change Was Made
Each violating check now goes through the guard #206246 already uses:
readOnlyOpenWouldCreateSqliteSidecarspluswithLiveStateReads. This PR adds it asdecideDoctorPendingFromLiveStoresinsrc/commands/doctor-live-store-pending.ts, with the same contents as the in-flightdoctor-pending-step5clane's version, and moves the migration-backup check onto it. When the guard can't decide, the check answersundecidable. No check creates sidecars and then deletes them.Checks audited (contributions and steps on
main), and their status:doctor:legacy-state(exec approvals)doctor:config-audit-scrub(checkLegacyRuntimeFilesPending)doctor:release-configured-plugin-installsdoctor:agent-memory-schemadoctor:legacy-plugin-manifestsdoctor:project-clone-shapedoctor:telegram-general-topic-conversations(derived from its detect)boot-lifecycledoctor:write-config(post-write cron read, which also copied the state DB)doctor:plugin-registrystate-database-repair,database-migrations, runtime-checks deletion journalRepair-side reads that #206348 added, for an unheld store (the repair runs inside the stop and may open stores for writing):
The two questions the review left open:
database-missingfor an existing file. The usage-cost read now treats that asundecidable, so the retire path still runs for it, as before feat: let four more doctor --fix repairs tell when they have nothing to do #206348. The writer refuses incognito paths (assertAgentDatabaseWriteAllowed), so nothing was retired there before either.?? snapshotFromExecApprovalsRow). Registry readers treat a missing state database as empty. Every writer creates the database on its first open. This PR keeps "missing → 0".The snapshot helper now records
-shmand an empty-walby presence only. A sidecar that appears or disappears is a change. An already-present-shmwhose bytes change is not, because a live connection rewrites it. A-walthat gains frames is a change. Diagnostics may read unheld stores, sodoctor-health-contributions.diagnostic-only.test.tsopts out explicitly withignoreReadSidecars. Under the strict helper,doctor:channel-ingress-dead-lettersshows the diagnostic read leaving sidecars; see Not proven.For the later step that runs checks before the stop (not changed here): time-based predicates can change between a check and its repair. These are the 10-second usage-cost temp-file grace (
src/commands/doctor-usage-cost-cache.ts,LEGACY_USAGE_COST_TEMP_GRACE_MS) and the 1-hour capture-root cutoff insrc/plugins/plugin-source-capture-directory.ts.Evidence
Tested commit:
70b10610497(fix commit28291f64e9b, two test-only follow-ups, merges ofmain). The red runs used unmodifiedmainat46435812b1ewith only the new and updated test files copied in.New guards:
src/flows/doctor-health-contributions.pending-read-only.test.tsruns every registered contribution check (28 today, including any a later PR registers) on its own healthy install. It runs each one twice: once with no connection holding the stores, asserting no file is created or changed, and once beside held connections, asserting the check answersnone/workand still creates nothing. The second pass is the negative control.src/commands/doctor-maintenance.stopped-systemd.test.tsrunsdoctor --fixagainst a stopped systemd Gateway and wrapstraceDoctorMaintenancePending. Before each step's check it closes every connection, so each check meets stores with no sidecars. Any step check added later, including the config-flow plan check in flight, is covered once it records its decision.Red on
main(failing cases):The "beside connections that hold the stores" cases pass on
mainand on the head.Green on the head: all affected suites pass (
node scripts/run-vitest.mjsover 45 files in 6 shards: unit, cli, commands, plugins, infra, state).pnpm tsgo:core,pnpm tsgo:core:testandnode scripts/check-changed.mjs --base origin/main(lint, typecheck, mock-export and line-cap guards) pass. The session identity and test-lines ratchets pass (+387 net test lines, under the 400 allowance).Review: autoreview on the branch diff, Codex route,
--max-priority P2 --thinking high, with 11 unchanged owner and caller files supplied as source context (the pending contract, the sidecar guard, live-state reads, the #206246 checks, contribution plumbing, plugin registry, exec-approval store, agent read-only reader). Result: scoped-clean, no P0 to P2 findings, on the first head and again on the final diff (12 context files, including the flow test support). The report lists every changed file and the supplied context files as inspected.No Linux cell was run. The defect is file creation by a function, and the tests show it on real SQLite stores.
Files audited in full: the eight test files touched or added. Removed: the old "reports pending schema work read-only" memory-schema case, whose snapshot ignored
-shmand empty-wal; the new case covers the same work/none/repair transitions with the strict helper. The usage-cost pending cases now hold a connection when they expectnone/work.Not proven
doctor:channel-ingress-dead-lettersread.