Repository navigation
fix(doctor): doctor fails with an internal lease error instead of explaining an unwritable state database - #178178
Conversation
Report effective database, sidecar, and directory access failures with the blocked path and manual ownership, mount, and immutable-flag remedies. Preserve the original error when storage remains writable. Harden existing state through its permission owner before config convergence can retain a read-only SQLite handle. Keep foreign-owned writable stores usable when chmod returns EPERM without relaxing owned-file hardening. Release-note context: doctor --non-interactive explains unwritable state storage instead of exposing an internal plugin lifecycle lease error.
|
🦞👀 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 SummaryThis 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 changesThis PR repairs owned read-only state files before config preparation and replaces opaque storage failures with path-specific recovery guidance. Example: An owned state database has mode 0444 when openclaw doctor --non-interactive runs.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it addresses a concrete Doctor failure still present on current main, and inspection found no definite introduced code defect. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherDoctor prepares database and config state before running health checks; the shared permission owner hardens database files, while the command boundary translates confirmed storage-access failures into recovery instructions. flowchart TD
A[Doctor CLI] --> B[Database schema admission]
B --> C[State permission owner]
C --> D[Config and plugin preparation]
D --> E[Health checks]
D --> F[Storage failure diagnosis]
F --> G[Path and recovery guidance]
Technical reviewBest possible solution: Keep permission repair in the existing shared owner and diagnose confirmed access failures at Doctor's command boundary. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the reported path, and the PR records before/after immutable-file and owned-0444 reproductions; no target code was executed during this read-only review. Is this the best way to solve the issue? The patch reuses the permission owner, retains schema admission before config preparation, and preserves original errors when effective access succeeds; the simplification review found no clearly unnecessary production machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1f31394cc6d4. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +85, Tests +174, Docs +7. Total +266 across 6 files. Added test files: 1. View PR surface stats
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 October 20, 2026, 3:05 AM ET / 07:05 UTC. |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
Report effective database, sidecar, and directory access failures with the blocked path and manual ownership, mount, and immutable-flag remedies. Preserve the original error when storage remains writable. Harden existing state through its permission owner before config convergence can retain a read-only SQLite handle. Keep foreign-owned writable stores usable when chmod returns EPERM without relaxing owned-file hardening. Release-note context: doctor --non-interactive explains unwritable state storage instead of exposing an internal plugin lifecycle lease error.
Related: #178107
What Problem This Solves
Fixes:
openclaw doctorfails with the internal error "failed to acquire plugin lifecycle lease core:plugin-lifecycle/global: store unavailable (storage-error)" instead of explaining the problem when the shared state database is not writable, for example after asudo openclaw …run left root-owned files, on a read-only mounted volume, or with an immutable file.User Impact
User impact: Doctor names the unwritable database or directory and gives the concrete fix (ownership/permissions for the user running OpenClaw, remounting the volume writable, or clearing an immutable flag), and points to
openclaw doctor --lintfor read-only checks. A database the user owns with a too-restrictive mode is repaired by the existing permission owner and Doctor continues normally. Writable databases owned by another user (DockerfsGroup, NFS) and writable volumes that rejectchmodkeep working. Doctor never changes ownership or immutable flags itself.Why This Change Was Made
Doctor's first write is the shared-state lease taken during post-core plugin convergence; the lease wrapper reduced the SQLite failure to "store unavailable" without the path. Failed storage admission now runs an effective-access check (non-truncating opens of the database and existing sidecars, plus an exclusive disposable file in the parent directory) and, only when access is actually denied, reports the path and remedy; other errors keep their original cause. Doctor's existing write-admission step now runs the permission owner before config convergence, so an owned read-only file is hardened instead of leaving a read-only connection. Ownership alone is never treated as a problem. No schema, migration, public config, run-order or exit-policy change. This complements #178107, which fixes the Gateway startup message for the same situation.
Evidence
chflags uchg): before, Doctor printed only the internal lease error; after, Doctor exits 1 with "State storage is not writable at … Fix ownership and permissions for the user running OpenClaw (for example: sudo chown "$(id -u):$(id -g)" '') … Or remount the volume writable. If the file or directory is immutable, clear its immutable flag (on macOS: chflags nouchg ''). Then rerun openclaw doctor. For read-only diagnostics, use openclaw doctor --lint."0444: Doctor hardens it to0600and completes (exit 0).0444, writable foreign-owned via real file metadata with the current uid mocked, chmod-rejecting but writable): the immutable and owned-0444cases fail before the change (internal lease error) and pass after; 6 cases, 57 s wall. Focused Doctor/state suites: 57 tests across six files pass.pnpm tsgo:core, oxlint, oxfmt, madge (0 cycles),git diff --checkpass. Autoreview (Codex): scoped-clean, no actionable findings.Landing validation
The exact head
9beb3a65c634104c4a3345175c45d346759950acpasses the offline newer-schema Doctor regression, including unchanged database/sidecar bytes, inode, birth time, mtime, and ctime. Fresh isolated Codex review with the maintenance/admission source context found no actionable P0–P2 findings.CI run 39382672660 completed with three inherited failing test jobs and their downstream gate;
security-fastpassed. Compared job-level logs with the same cases in scheduled main run 39382483409:checks-node-changed-compact-large-16: threeopenclaw-state-db.transactions.test.tscases fail with the same Gateway ownership namespace error (main job118494854830).checks-node-changed-compact-large-21: both foreign-owner checkpoint cases inopenclaw-state-db-open.test.tsfail with that same namespace error (main job118494854815).checks-node-changed-compact-small-6:restart-intent.test.ts/ “records restart options while an older Gateway owns a pending-migration database” fails the same boolean assertion (main job118494854333).The failing tests and their relevant ownership/restart source inputs are unchanged between the CI baseline and its tested PR merge. Landing uses the native inherited-failure exception; this does not claim CI is green.