Repository navigation
fix(plugin-state): avoid shared SQLite corruption when CLI starts during gateway runtime - #113204
Conversation
e7d2552 to
d2271db
Compare
|
Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 4:12 PM ET / 20:12 UTC. ClawSweeper reviewWhat this changesThe PR routes plugin-state lookup, enumeration, key-range, and live-entry-count reads through a read-only shared-state accessor so CLI/runtime readers do not run the Gateway-owned writable SQLite lifecycle. Merge readinessKeep this PR open for maintainer review. The current-main source confirms the reported owner-boundary hazard, and the PR provides strong concurrent runtime proof, but this partial checkout cannot materialize the exact PR blobs because its promisor remote cannot resolve GitHub; a direct diff/correctness verdict would be unsafe. Likely related people: Vincent Koc (recent shared-state contributor; medium confidence). Priority: P0 Review scores
Verification
How this fits togetherPlugin-state persists plugin-owned records in OpenClaw’s shared SQLite state database. CLI and runtime readers query that database while the Gateway owns schema setup, WAL configuration, permission changes, transactions, and writes; this boundary decides whether a read can mutate shared-state lifecycle. flowchart LR
CLI[CLI and runtime reads] --> PluginState[Plugin-state read APIs]
PluginState --> ReadAccessor[Read-only state accessor]
Gateway[Gateway process] --> WriteLifecycle[Writable state lifecycle]
ReadAccessor --> StateDB[(Shared SQLite state)]
WriteLifecycle --> StateDB
StateDB --> Result[Plugin-state results]
Decision needed
Why: The supplied concurrent Gateway proof is strong, but the local checkout cannot read the exact proposed blobs, so automation cannot safely verify the final code path or its upgrade-sensitive behavior. Before merge
Agent review detailsSecurityNone. PR surfaceSource +121, Tests +165. Total +286 across 4 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Materialize and review the exact head, then merge only if all plugin-state read APIs use the existing-state read-only path while writes remain on the canonical writable transaction owner and the stated missing/quarantine/schema behavior is covered. Do we have a high-confidence way to reproduce the issue? No deterministic corruption reproduction was established in this checkout. Source inspection does show that current plugin-state read APIs enter the writable state lifecycle, while the PR body supplies a real concurrent Gateway/CLI after-fix run with passing integrity checks. Is this the best way to solve the issue? Unclear: moving read APIs to the established read-only state-owner boundary is the right architectural direction, but the exact final implementation could not be inspected because the PR blobs are unavailable locally. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6d339763186a. LabelsLabel 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
HistoryReview history (4 earlier review cycles)
|
74ac73f to
3bdc6a4
Compare
3bdc6a4 to
1325647
Compare
1325647 to
caf9cac
Compare
|
Maintainer disposition for the current exact head
This satisfies the two ClawSweeper Rank-up moves. The PR remains a bounded repair related to #101290; the broader issue must stay open. |
|
Maintainer disposition for
Both Rank-up moves are addressed. This bounded PR is ready to merge. It remains only related to #101290; the broader issue must stay open. |
* origin/main: (22 commits) fix(cron): preserve lazy ownership and bounded notification lifetimes (#117018) fix: live updater no-op restarts healthy gateways (#117038) fix(bedrock): release streaming clients (#117039) fix(google): restore canonical Gemini and Vertex provider invariants (#117042) fix(channels): preserve accepted LINE and Mattermost delivery (#117024) fix(feishu): unify truthful delivery and media ownership (#117023) fix(ui): isolate gateway observer lifecycles (#117017) fix(tui): keep reset transitions isolated from stale input (#116873) fix(gateway): centralize streamed media descriptor ownership (#117000) feat(plugins): externalize OpenCode provider (#117035) fix(onboarding): restore skill dependency consent (#116644) fix(streaming): preserve incomplete bracket tails in final replies (#116983) fix: allow slower gateway readiness after updates (#117032) fix(plugin-state): avoid shared SQLite corruption when CLI starts during gateway runtime (#113204) fix(cli): keep config file output raw under JSON logging (#116968) fix(ai): malformed Anthropic stream frames expose raw event payloads (#116938) fix(qa): authenticate actual scenario execution evidence (#117004) feat(plugins): externalize NovitaAI provider (#117007) fix(text): preserve fenced tool markers in visible-text sanitizer (#116939) (#116971) fix(channels): reset metadata memos with plugin lifecycle (#117005) ...
…ing gateway runtime (openclaw#113204) * fix(plugin-state): keep reads outside writable state lifecycle * fix(state): keep open guard private * fix(state): preserve cached read-only handles * test(plugin-state): cover newer read-only schemas --------- Co-authored-by: Vincent Koc <[email protected]>
Related to #101290
What Problem This Solves
CLI startup and preflight plugin-state reads could open the shared SQLite database through the writable lifecycle while the Gateway was running. That let read-only callers re-enter permission, WAL, schema, and repair work owned by the writer.
Why This Change Was Made
Plugin-state reads now use the canonical state-owner read accessor. It reuses a safe process-held handle or opens an existing database physically read-only without schema, WAL, or permission mutation.
Fresh opens preserve process-local and persisted quarantine checks. Missing files remain empty, non-missing filesystem failures remain actionable, and writes stay on the canonical writable transaction path. The follow-up commits keep the internal open guard module-private and preserve process-held handle reuse before any fresh filesystem probe.
User Impact
CLI startup and runtime plugin-state lookups no longer enter writable shared-state maintenance. Missing state remains empty. Damaged, quarantined, incompatible, or inaccessible state fails closed, while a safe process-held handle remains reusable.
This is a bounded repair for the plugin-state read owner boundary. The broader production-validation issue #101290 remains open.
Evidence
Frozen base:
6d339763186adbd9312114904ffb6af5c93baf1fExact PR head:
caf9cac456aa05a8aa3eb86b67d37352f97a3eb9The contributor's three commits remain patch-identical after the rebase; author credit is preserved.
The four touched files are byte-identical on current
mainto the original merge base, and the old contributor head has a clean three-way merge.Focused regression proof: 75 passed, 1 Windows-only test skipped. Coverage includes the four read APIs, missing databases, process-local and persisted quarantine, newer schemas, inaccessible directories, process-held handle reuse, and the current schema-migration-required sibling.
A byte-identical pre-rebase head passed the changed gate: format, plugin boundaries, both Knip scans, core and core-test tsgo, oxlint, schema guards, database-first storage checks, and import-cycle checks: https://github.com/openclaw/openclaw/actions/runs/30660036355
Fresh exact-head autoreview returned no actionable findings at 0.98 confidence.
Concurrent runtime proof on the byte-identical four-file patch passed with a real ephemeral Gateway:
Run: https://github.com/openclaw/openclaw/actions/runs/30658395411
Final delegated verification matched the frozen base, exact changed-file set, and all four expected blob hashes. The concurrent proof validates the corrected ownership boundary and database health; it does not claim a deterministic reproduction of the timing-sensitive corruption.