Repository navigation
fix(sqlite): keep read-only state journal-aware - #113404
Conversation
aca5322 to
046065e
Compare
|
Codex review: needs maintainer review before merge. Reviewed July 24, 2026, 4:51 PM ET / 20:51 UTC. ClawSweeper reviewWhat this changesThe PR makes existing OpenClaw state-database read-only access respect SQLite locking and journals, then verifies quarantine, integrity, and canonical schema state before diagnostics read the database. Merge readinessKeep this active maintainer-authored PR open for normal merge review. The branch addresses a concrete state-integrity failure mode and includes targeted crash-recovery evidence; it is neither superseded by current main nor eligible for automated cleanup. Before landing, reviewers should confirm all read-only diagnostic callers surface the new verification failures appropriately and let the in-progress CI finish. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw state diagnostics open the shared SQLite state database to inspect and repair runtime state. This path feeds doctor and maintenance reporting, so it must not treat pages from an interrupted writer as committed state or silently accept quarantined, corrupt, or noncanonical databases. flowchart LR
A[State database files] --> B[Read-only diagnostics]
B --> C[Quarantine check]
C --> D[SQLite journal-aware open]
D --> E[Integrity and schema validation]
E --> F[Trusted diagnostic result]
D --> G[Hot journal or invalid state]
G --> H[Fail closed]
H --> I[Writable recovery path]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -1, Tests +102. Total +101 across 5 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain journal-aware SQLite opens, preserve the explicit fail-closed diagnostic behavior, and land only after caller-level error handling and the targeted cross-platform checks confirm that writable recovery remains the supported remediation. Do we have a high-confidence way to reproduce the issue? Yes in source, with medium confidence: the added crash fixture creates a hot rollback journal after a killed writer and contrasts immutable reads with the proposed journal-aware read-only open. The supplied PR evidence reports that scenario ran successfully, but this review could not independently execute it. Is this the best way to solve the issue? Yes, provisionally: removing immutable mode at the shared read-only state boundary is narrower and safer than attempting to detect every journal sidecar manually. The remaining merge check is that all diagnostic callers correctly expose the resulting verification failures and recovery path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2ee8730450dc. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
8c407cd to
722c791
Compare
722c791 to
4050253
Compare
2eae9f1 to
7d82a81
Compare
|
Land-ready proof completed on exact head Validation:
Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/30135620488 Covered behavior includes hot rollback recovery, active WAL reads, same-size WAL reset, rollback-to-WAL transition, source replacement, missing WAL/SHM pairs, unsafe indexes, retryable cleanup, source-byte preservation, and the end-to-end SQLite sessions/transcripts flip. No touched-surface proof gaps remain. Direct WSL2, macOS arm64, Docker multi-arch, Linux-variant, sandbox, vacuum/restore crash-point, and high-I/O fault-injection proof continues under #113306 after this bounded fix lands. |
|
Merged via squash.
|
* fix(sqlite): keep read-only state journal-aware * fix(sqlite): snapshot read-only state safely * fix(sqlite): retry read snapshot replacement races * fix(sqlite): isolate private staging directory setup
Related: #113306
What Problem This Solves
Fixes read-only state diagnostics that could bypass SQLite journal handling with
immutable=1, require writes beside a sidecar-free WAL database, or inspect a mixed database/sidecar generation while a writer reset WAL or replaced the source file.Why This Change Was Made
Read-only state access now resolves SQLite's canonical filename and prepares a private, single-file snapshot before validation. Rollback journals and complete active WAL families use SQLite locking plus online backup under a pinned read transaction. Incomplete WAL families are copied with stable source and sidecar fingerprints so crash residue can be inspected without creating source coordination files.
The private snapshot is normalized to rollback journaling, checked for integrity and canonical current-schema indexes, and cleaned on close with retry support for transient cleanup failures.
Private staging-directory setup is isolated in a dependency-light module so state diagnostics do not pull snapshot transforms, process logging, or plugin/runtime initialization into their import graph.
User Impact
Doctor and update-planning diagnostics get a consistent point-in-time view that includes committed WAL state, preserves source bytes and directory entries, rejects unsafe indexes, and does not race source replacement or journal-mode transitions. Writable startup remains the sole owner of recovery and maintenance.
Evidence
7d82a818d12d271d2469172ae178f507cb360fbe.tbx_01kyb9q5fe6kaswcmwc56masd7).pnpm deadcode:exports: production, full-tree, and script scans passed with zero findings.pnpm check:changed: formatting, API/schema/database guards, core/core-test typecheck, import cycles, database-first guards, and the full core lint sweep passed in 17m08s.checks-windows-node-test.