Repository navigation
fix(state): give one actionable answer for state written by a newer release and keep status reads read-only - #166963
Conversation
Keep compatible-build or matching-backup guidance through Doctor and Gateway admission, and report offline schema incompatibility before integrity checks. Route update status through artifact-preserving state reads so newer databases keep their bytes, mtimes, and SQLite sidecars unchanged. No schema or migration changes. Regression evidence covers all four reported paths. Independent P1 review was attempted but returned HTTP 401; campaign lead review remains required.
Prepare the channel-status RPC identity through the existing artifact-preserving reader. The default asynchronous existing-only lookup opens the shared actor and can create WAL/SHM files before refusing a newer schema. Exercise the real Gateway probe on the host-broker test lane, with byte and nanosecond-mtime assertions. The negative control reproduces sidecar creation without this fix. P1 autoreview again returned HTTP 401; campaign lead review is required.
|
🦞👀 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. Reviewed October 8, 2026, 12:46 AM ET / 04:46 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch prioritizes compatible-build or matching-backup guidance for newer databases and preserves SQLite files during update-status inspection. Example: Run
Review scores
ProductKind: Bug fix · Worth it: Yes Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Needs changes before merge - 2 items remain This PR has useful real CLI proof, but the previously reported P2 status-probe regression remains unresolved on the current head. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherOpenClaw stores shared runtime state in SQLite databases. Doctor, Gateway startup, update status, and offline preflight inspect these databases to report compatibility and recovery guidance. flowchart TD
A[Doctor, startup, or status command] --> B[Shared SQLite state]
B --> C[Artifact-preserving inspection]
C --> D{Schema supported?}
D -->|No| E[Compatible build or matching backup guidance]
D -->|Yes| F[Normal integrity and status checks]
Technical reviewBest possible solution: Keep identity selection with the Gateway authentication owner and use artifact-preserving reads only when that owner requires identity. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the remaining regression: a loopback token/password probe with an invalid persisted identity throws before RPC and returns no channel issues. No reviewer-side execution was performed. Is this the best way to solve the issue? No, the eager identity override bypasses an existing authentication decision. The narrower solution preserves deferred selection while changing the required identity read to preserve artifacts. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1eb5970ff972. Provenance checked
TestingProof path: shipped entry point. Added test files: 3. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +45, Tests +194, Docs +6, Other +1. Total +246 across 11 files. View PR surface stats
Stored data modelPersistent data-model change detected: LabelsLabel changes: No label 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 HistoryReview history (1 earlier review cycle)
|
Replace the copied preflight PRAGMA batch with the existing busy-timeout and read-only policy helpers. Preserve connection settings and version-first refusal without expanding the raw SQLite allowlist.
…ry at the CLI boundary (#167035) #166963 made the target-release schema preflight return before agent-store discovery; #161057 (cfee851) restored the production path concurrently. This adds a CLI-boundary regression so a downgrade target that cannot read the agent databases stays refused, and replaces a polling wait in the agent-database startup test with the inspection promise.
…elease and keep status reads read-only (openclaw#166963) Follow-up to openclaw#166906: Doctor --fix, Gateway startup, offline database preflight and update status now give one install-compatible-build / restore-backup answer for a database written by a newer release, and update status no longer creates SQLite sidecars.
…ry at the CLI boundary (openclaw#167035) openclaw#166963 made the target-release schema preflight return before agent-store discovery; openclaw#161057 (1991553) restored the production path concurrently. This adds a CLI-boundary regression so a downgrade target that cannot read the agent databases stays refused, and replaces a polling wait in the agent-database startup test with the inspection promise.
What Problem This Solves
Fixes contradictory repair advice and SQLite sidecar creation when an older OpenClaw build inspects state written by a newer release. Related: #166906 and #166857.
User Impact
Doctor, Gateway startup, update status, and offline database preflight consistently recommend a compatible newer build or restoration of the backup matching the older build. They preserve the newer database's bytes, mtimes, and SQLite sidecars. No schema, migration, configuration option, CLI option, or dependency changes.
Why This Change Was Made
Reuse the existing newer-schema classification and artifact-preserving reader. Doctor omits the generic repair tail; fleet preflight stops interpreting an unsupported registry; offline preflight checks the version before integrity. Update status also prepares its Gateway probe's device identity through the diagnostic reader, because the default asynchronous identity lookup opens a shared actor even for existing-only reads.
The explicit-file preflight implementation moves to a focused sibling to keep the owning module within its line cap. Its existing export remains available, and the native wrapper inventory includes the new module.
Evidence
node scripts/check-changed.mjs --base f0258248b3e0a1fc5a09bd4060a2f494c35b42c9passed, including full core/test typechecks, full core lint, script lint, ratchets, and import-cycle/closure checks.Fresh isolated copies of released
[email protected]state used shared-stateuser_version19 → 21 and the unreadable Workshop index mutation; this build supports schema 20. All five real CLI cases passed on the final build, preserving every SQLite-family file hash, nanosecond mtime, and file-set membership. No service or listener remained active.doctor --jsondoctor --fix --non-interactivegateway run --bind loopback --auth noneupdate status --jsondatabase preflight <copied-file> --jsonincompatible,foundVersion: 21, actionable reason; files unchangedLocal one-worker wall times: Doctor 212.22 / 112.31 / 94.83 seconds; preflight 9.31 / 6.10 / 6.05 seconds; status artifacts 46.11 / 36.52 / 22.91 seconds. The status artifact suite spent 10.39 / 17.96 / 13.86 seconds in tests; its real SQLite readers and RPC identity boundary are necessary to expose the sidecar mutation that a mocked probe misses. Doctor's existing maintenance/service-custody matrix accounts for its longer runtime. The broad importer/guard run took 1,221.82 seconds including shared runtime preparation; the final status importer/guard run took 183.60 seconds. Hosted CI seconds are pending at the authoring handoff.
Delta: production +169/-125 (net +44, including the preflight relocation); tests/support +198/-5; tooling +2/-0; docs +6/-0.
Pre-existing slow cases were recorded without increasing timeouts or changing assertions: native wrapper provisioning spent 343.76 seconds in tests (including 98.80 seconds for its cold/warm/sparse checkout sequence), and the original-capture Doctor flow took 46.55 seconds while exercising real custody, backup capture, and repeated repair admission. These inherited costs are unchanged; no timeouts, retries, or assertions were altered.