Repository navigation
fix(sqlite): safely discard retired commitments state - #130629
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper re-review Please evaluate the accepted destructive-retirement contract from Two independent local reviews found and resolved:
No schema version or index/query-plan changes are included. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
ClawSweeper rank-up moves addressed on exact head
No index DDL or indexed query plan changes are in this PR; the stable fixture only verifies removal of the retired shipped indexes, so a before/after index performance benchmark is not applicable. |
* fix(sqlite): finalize commitments retirement * fix(doctor): discard retired commitments json
Fixes #129547
Audit: https://gist.github.com/vincentkoc/10826f918dde7e23020cf2f390af95d3
What Problem This Solves
Fixes an upgrade gap where retired durable commitments state was deleted without
clear operator reporting, while the old
commitments/commitments.jsonstore hadno bounded cleanup owner. The schema detector also advertised the schema-7
retirement for versions where its executor would not run.
Why This Change Was Made
This implements the accepted destructive-retirement contract:
existing schema-7 migration;
openclaw doctor --fixvalidates and discards only the exactversion-1 commitments JSON envelope;
untouched and fails closed;
commits.
There is no schema-version bump, replacement table, query-plan change, or new
index.
User Impact
Operators get an explicit, deterministic retirement outcome. Recovery remains a
verified pre-upgrade backup only; downgrade recreates an empty legacy schema.
Runtime continues to ignore the retired JSON file unless Doctor is explicitly
run.
Evidence
v2026.7.1-2fixture now contains one representative durable commitmentrow and the three shipped indexes before migration.
foreign-key checks, reopen, and idempotency.
implementation and passes on this head.
transaction and passes when labels are emitted after commit.
node scripts/run-vitest.mjs src/infra/state-migrations.commitments.test.ts src/infra/state-migrations.test.tsnode scripts/run-vitest.mjs src/state/openclaw-state-db.test.tsdocs formatting, and
git diff --checkpassed.Its extension typecheck is blocked by missing existing IMAP workspace
dependencies (
imapflow,mailauth,mailparser) in this checkout. Thedead-export lane is independently blocked because current
mainomits thetracked sparse UI config inputs it requires.
fixture only proves deletion of the retired shipped indexes.
Review Notes
Root cause: the retirement contract was split across a moving schema detector,
a schema-7 executor, silent runtime result handling, a zero-row release fixture,
and an ownerless legacy JSON source.
Architectural owner: shared-state schema retirement plus Doctor-only legacy
state migration.
Best-fix verdict: this is the canonical owner-boundary fix. Preserving rows,
adding an archive/export path, or adding runtime JSON fallback reads would
contradict the accepted contract and database-first policy.
Production LOC: +356/-17 (net +339). Tests/support: +617/-64 plus the updated
SQLite fixture. Docs: +10/-6. Production growth is the bounded Doctor migration
owner, receipt recovery, and fail-closed source validation; the schema
retirement itself remains small and shared.
Codex contract check:
../codex/codex-rs/state/src/migrations.rs:13-27and../codex/codex-rs/state/src/sqlite.rs:254were inspected. This change does nottouch Codex state or protocol behavior.