Repository navigation
fix(doctor): diagnose immutable state without pending writes - #199509
Conversation
|
🦞👀 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 Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesDoctor checks whether an existing state database can be opened read-write even when no migration needs to write to it. Example: On macOS, ~/.openclaw/openclaw-state.sqlite is immutable after chflags uchg, with no pending migrations.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR restores a documented Doctor diagnosis with a focused change, and no introduced correctness or security defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherDoctor's config preflight admits state access before migration and plugin convergence; filesystem failures reach the existing command-boundary storage diagnosis and recovery guidance. flowchart LR
A[Doctor command] --> B[State ownership admission]
B --> C[Permission hardening]
C --> D[Read-write open check]
D --> E[Continue Doctor]
D --> F[Storage diagnosis]
F --> G[Recovery guidance and exit 1]
Technical reviewBest possible solution: Keep the non-truncating check in the existing state-admission owner and reuse the established recovery diagnosis. Do we have a high-confidence way to reproduce the issue? The source shows that existing admission need not attempt a write, and the unchanged macOS test supplies a concrete immutable-file reproduction with reported before/fix/revert results; this read-only review executed no tests. Is this the best way to solve the issue? The patch is the smallest complete fix for the reported trigger: check effective write access after permission repair without changing database contents or introducing another diagnosis owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against bd74a9f7e7b5. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +2, Docs 0. Total +2 across 2 files. Added test files: 0. 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. LabelsLabel changes: No label changes. Label justifications:
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 15, 2026, 2:17 AM ET / 07:17 UTC. |
|
I verified the real macOS CLI against With the fix, the immutable database is diagnosed without changing its bytes: After clearing the flag, Doctor completes. This and the control transcript below show the end of the captured output; unrelated checks and fresh-state configuration warnings are omitted. For the control, I removed only the new read-write-open line, rebuilt, and repeated the check on a separate fresh database. It reproduced the bug: I restored the source file and rebuilt afterward. The checkout is clean, the buildstamp names
The published updater completed the tarball update. The installed candidate passed Doctor, post-Doctor config validation, seeded state-survival assertions, and Gateway startup/readiness. Fresh installs passed with npm, pnpm, Bun, and npm on musl. Both lanes passed on their first attempt. This was the manual-restart upgrade variant; automatic restart and update idempotence were not tested. Candidate package SHA-256: |
Verify effective database write access during Doctor state admission after permission hardening. A current database with no plugin migrations can otherwise complete diagnostics without ever attempting a write, hiding immutable storage. The non-truncating open preserves database contents and uses the existing command-boundary diagnosis and recovery guidance. The existing macOS regression started failing in 6ce3260 (#184245), which removed a plugin fixture whose writes had incidentally exposed this condition. Keep its assertions unchanged and document the independent admission check. Release-note context: Doctor reports an immutable state database's path and the macOS chflags nouchg remedy, and exits unsuccessfully even when no migration is pending. Writable shared stores and owned read-only mode repair remain supported.
f4fbc7c to
045047b
Compare
|
Merged via squash.
|
…w#199509) Verify effective database write access during Doctor state admission after permission hardening. A current database with no plugin migrations can otherwise complete diagnostics without ever attempting a write, hiding immutable storage. The non-truncating open preserves database contents and uses the existing command-boundary diagnosis and recovery guidance. The existing macOS regression started failing in 1b7b2d7 (openclaw#184245), which removed a plugin fixture whose writes had incidentally exposed this condition. Keep its assertions unchanged and document the independent admission check. Release-note context: Doctor reports an immutable state database's path and the macOS chflags nouchg remedy, and exits unsuccessfully even when no migration is pending. Writable shared stores and owned read-only mode repair remain supported. Co-authored-by: Peter Steinberger <[email protected]>
Verify effective database write access during Doctor state admission after permission hardening. A current database with no plugin migrations can otherwise complete diagnostics without ever attempting a write, hiding immutable storage. The non-truncating open preserves database contents and uses the existing command-boundary diagnosis and recovery guidance. The existing macOS regression started failing in 6ce3260 (#184245), which removed a plugin fixture whose writes had incidentally exposed this condition. Keep its assertions unchanged and document the independent admission check. Release-note context: Doctor reports an immutable state database's path and the macOS chflags nouchg remedy, and exits unsuccessfully even when no migration is pending. Writable shared stores and owned read-only mode repair remain supported. Co-authored-by: Peter Steinberger <[email protected]> (cherry picked from commit 39c3099) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 0de3eb1eac1666561c6e4051b6f233420eb40766)
Related: #178178
What Problem This Solves
Fixes: on macOS,
openclaw doctorreports "Doctor complete." and exits 0 when the state database is immutable (chflags uchg) and no migration is pending. Nothing can write to that database, and Doctor doesn't say so.User Impact
User impact: Doctor again reports an immutable or otherwise unwritable state database, with its path and the macOS
chflags nouchgremedy, and exits unsuccessfully, even when no migration is pending.Doctor runs during
openclaw update, so an installation whose state database is immutable or on a read-only mount now gets this diagnosis and a non-zero Doctor exit there too. That's the behavior #178178 intended, and the Gateway can't write state on those installations anyway. Installations with writable state behave exactly as before.Why This Change Was Made
The storage diagnosis only fired when some write during the Doctor run happened to fail. Doctor's state admission now checks write access itself: after the existing permission hardening, it opens the existing database read-write without truncating it, then closes it. An immutable file, a read-only mount or an unwritable file now reaches the existing command-boundary diagnosis and recovery guidance. Database contents are untouched. Owned 0444 files are still hardened first, and foreign-owned writable files and unsupported
chmodstill pass.docs/gateway/doctor/running.mddescribes the check.Root cause
The macOS-only regression
src/commands/doctor-state-storage.test.ts› "diagnoses an immutable database at the command boundary" (it.skipIf(process.platform !== "darwin"), so Linux CI skips it) has failed since 6ce3260 (#184245). Until then, the test's plugin fixture caused an incidental state write that hit the immutable file. When the fixture was removed, a current database with no pending migrations finished without ever attempting a write. The test's assertions are unchanged here.Evidence
End-to-end on macOS, real CLI, isolated state, migration-current database: with the fix, Doctor names the path, gives the
chflags nouchgremedy and exits 1 with the database bytes unchanged. Afterchflags nouchgit completes with exit 0. With only the new line reverted, it prints "Doctor complete." and exits 0. Transcripts: fix(doctor): diagnose immutable state without pending writes #199509 (comment)Published driver × candidate:
published-upgrade-survivorwith published[email protected]updating tof4fbc7ca4925passed (849 s): updater success, candidate Doctor, post-Doctor config validation, seeded state survival, Gateway start and readiness. Fresh installdocker-package-installpassed (84 s) with npm, pnpm, Bun and npm on musl. This was the manual-restart variant; automatic restart and idempotence were not covered.Bisect, single case under Node, from 11ad47f (fix(doctor): doctor fails with an internal lease error instead of explaining an unwritable state database #178178, passes) to main: first bad is 6ce3260 (test(runtime,ui,plugins): remove low-value tests (batch d593) #184245). 15 historical runs, none skipped.
The macOS case,
--maxWorkers=1:Full
doctor-state-storage.test.ts: 6/6 pass on both runtimes (60.5 s Node, 33.5 s Bun).24 direct-consumer test files: 296/296 pass on both runtimes.
Targeted lint, both core type-check lanes, formatting, ratchets, MDX validation and commit hooks pass. Independent review is clean.
Test cost: no new tests. The existing macOS case is unchanged (about 18 s Bun, 53 s Node in single-worker local runs).
Rebased-head validation
786cd278fb1d51e5256b374a654483969242e871; candidate045047bac19d912d62b660e3c203b9f238287e58.git range-diffconfirms the product patch is unchanged.doctor-state-storage.test.tsanddoctor-config-preflight*.test.tsselection: 122 tests across 16 collected files passed under Node and the default pinned Bun runtime. All six storage-diagnosis cases passed on macOS under both runtimes, including the immutable-database regression. Runtime preparation andgit diff --checkpassed.786cd278fb1d51e5256b374a654483969242e871..045047bac19d912d62b660e3c203b9f238287e58: scoped-clean through P2, no actionable findings.doctor-config-preflight.legacy-driver.live.test.ts. An explicit optional invocation stopped in shared live setup before executing tests because the local auth source uses schema 19; no local installation was modified. That optional proof remains a gap. The published-driver evidence above remains prior-head evidence, including its manual-restart limitation.