Repository navigation
fix: prevent externally supervised state schema drift - #121069
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 9, 2026, 4:44 PM ET / 20:44 UTC. ClawSweeper reviewWhat this changesAdds external-supervisor ownership for shared SQLite state, immutable copied-state schema preflight, and write checks across Gateway, CLI, Doctor, updater, and diagnostic paths. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep this PR open: both previously identified P1 ownership races remain at the exact head, so its documented once-claimed refusal guarantee is not yet true. Priority: P1 Review scores
Verification
How this fits togetherGateway, CLI, Doctor, updater, and diagnostics share OpenClaw’s SQLite state database. The new ownership row should make unmarked writers refuse while copied snapshots are assessed read-only before activation or rollback. flowchart LR
A[External supervisor] --> B[Durable ownership claim]
C[Gateway CLI Doctor updater] --> D{Shared-state write path}
B --> D
D -->|authorized| E[SQLite state and WAL]
D -->|unmarked| F[Explicit refusal]
G[Copied SQLite snapshot] --> H[Immutable schema preflight]
H --> I[Release activation decision]
Decision needed
Why: The branch deliberately leaves both concurrent windows open while public documentation promises the broader guarantee; choosing the permanent operator contract requires maintainer intent. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +947, Tests +1324, Docs +35, Generated 0, Other +2. Total +2308 across 41 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Use one lifecycle coordination boundary for ownership claims, state-open setup, and destructive Doctor maintenance, then add claim-during-open and claim-during-compaction regressions. Do we have a high-confidence way to reproduce the issue? Yes—injecting a claim after the pre-open ownership check or after Doctor validation gives a high-confidence source-level reproduction; the current tests inject only before schema repair. Is this the best way to solve the issue? No—the state lifecycle is the correct owner, but the patch does not fence all mutations that its new public contract says occur after a claim. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against bff0494f33b2. 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)
|
f4ab91d to
a864c75
Compare
31f5aa9 to
76a6f7e
Compare
9f1a47d to
afa84eb
Compare
f3427b3 to
5b69452
Compare
5b69452 to
eb80c65
Compare
eb80c65 to
2b02823
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
* fix: prevent externally supervised state schema drift * refactor: isolate schema ownership support code * test: follow canonical additive column order * test: keep older schema fixture valid * fix: preserve additive schema compatibility * chore: remove release-owned changelog entry * test: follow schema compatibility owner * style: format schema compatibility test * refactor: split sqlite schema sql helpers * fix: preserve desktop schema compatibility * fix: preserve ownership gates across platforms * fix: preserve detached updater long paths * fix: close external state ownership races * chore: refresh plugin sdk api baseline
…ream The 2026-08-12 resync left this file a hybrid merge that dropped upstream's handoff rework while its callers and tests already expected the new API: - root-mismatch binding (openclaw#121288): concurrent handoffs across distinct install roots silently coalesced instead of rejecting; single-flight test failed ("promise resolved 'joined' instead of rejecting"). - tag threading (openclaw#121328): callers pass `tag` via a conditional spread that bypasses TS excess-property checking, so the pinned/adopted target version was silently dropped and a moving channel could update to the wrong version. - externally-supervised state-drift guard (openclaw#121069): the detached update helper could write/migrate an externally-supervised gateway's shared SQLite. Take upstream's file wholesale — no fork-specific logic in it; callers and all four handoff test files are already byte-identical to upstream. Verified: repro test now passes, all 4 handoff test files green (28 passed), tsgo:core update surface clean, autoreview clean. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Closes #121068
What Problem This Solves
Fixes an issue where externally supervised OpenClaw installations could let different immutable releases enter writable shared-state lifecycle without a durable owner, and where equal numeric SQLite schema versions could hide incompatible physical column shapes.
This affected rollback, startup, update, Doctor, config-health, proxy-capture, checkpoint, and detached fallback workflows around the shared state database.
Why This Change Was Made
Shared-state lifecycle now records a versioned external-supervision claim in the existing machine-state table and fences non-owner writes both before opening state and again inside
BEGIN IMMEDIATE. An explicit copied-state preflight opens consolidated SQLite snapshots read-only and immutable, returning structured compatibility outcomes without modifying the target.The fix covers startup checkpoints, compaction, debug proxy capture, config health, update handoff, and direct writer paths. It does not bump the SQLite schema version, add an environment variable or config option, automatically unclaim ownership, add a dependency, or introduce a fallback writer. The generated Plugin SDK contract manifest records reviewed private declaration-closure changes; visible Plugin SDK exports are unchanged.
User Impact
Operators can give an external supervisor durable ownership of shared-state writes, detect incompatible same-version copied state before switching releases, and receive an explicit refusal when an unmarked process attempts to write externally owned state. Compatible ordinary installations continue using the existing state lifecycle.
Evidence
ClawSweeper disposition
BEGIN IMMEDIATE, after ownership and schema-version checks. A deterministic regression claims ownership during cold open and proves the unmarked opener cannot mutate the database.allowCompatibleAdditiveColumns. A copied-snapshot regression proves a future bare nullable column remains downgrade-safe and the source snapshot is untouched.main, and the exact integration head passed focused and full CI proof.The later ClawSweeper review on
eb80c650375affb5249e2a5f6c244a4ea851d03braised two additional coordination concerns. Their landing disposition is explicit:BEGIN IMMEDIATE; pathname permission hardening is idempotent OS metadata. Stronger coordination around all connection setup would broaden the accepted owner boundary beyond this repair.These are deliberate maintainer scope decisions, not silent omissions. An exact-head
@clawsweeper re-reviewwas requested, but GitHub installation throttling deferred its live-item check; the native review artifacts record the same disposition.Final exact-head proof
32d8b3bf81adf4baaf5172bec708bd24cd74d5d6.2b02823de87d752a1a6d37b3ebf0109e47a10253and currentmainbff0494f33b24aef664990dafda0d38750d798bcas parents.openclaw/ci-gate, build artifacts, Windows, Plugin SDK baseline, SQLite guards, all selected Node tests, lint/types, docs, and security-fast.provider=blacksmith-testbox,id=tbx_01kzm4b3rnxpws9g1s1218zmvt): run 31335044287.pnpm plugin-sdk:api:check: passed.pnpm plugin-sdk:surface:check: passed with zero forbidden package subpaths.+2885/-577PR surface; its non-generated stable patch ID exactly matches the reviewed head. The only recomputed file is the generated Plugin SDK checksum baseline.git diff --check: passed.0.98).Earlier proof
openclaw/ci-gate.id=tbx_01kzm1551cb38r4fkgrq1th7k1): run 31332652949, Plugin SDK API/surface green and 172/172 focused tests passed.id=tbx_01kzm0q7a5bd3yn0tt9594v92g): run 31332316601.id=tbx_01kzkc52y2p3akndvrcg7txt80,slug=harbor-lobster-22e9): run 31316502806, with the changed gate, 508 focused tests, build, and docs passing.AI-assisted: yes. The implementation and follow-up simplification were reviewed, and I understand the ownership, schema-preflight, and direct-writer boundaries changed here. No prompts or agent transcript are included.