Skip to content

Commit d62cb8a

Browse files
authored
fix(sqlite): safely discard retired commitments state (#130629)
* fix(sqlite): finalize commitments retirement * fix(doctor): discard retired commitments json
1 parent 372850d commit d62cb8a

14 files changed

Lines changed: 983 additions & 87 deletions

‎docs/refactor/database-first.md‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ without exceptions outside doctor/import/export/debug boundaries.
151151
Doctor owns their validated import and verified removal.
152152
- Inferred commitments: retired. Extraction, delivery, runtime storage access,
153153
and the CLI are removed. The schema 7 migration discards canonical commitment
154-
rows. Legacy `commitments.json` stays untouched and inert pending an accepted
155-
retention decision.
154+
rows. Explicit Doctor repair also validates and irreversibly discards the
155+
exact version 1 `commitments/commitments.json` store without importing,
156+
archiving, or exporting it. Unknown or unsafe files remain unchanged.
156157
- Doctor migration: `migrating`, intentionally. Doctor imports legacy JSON,
157158
JSONL, and retired sidecar stores into SQLite, records migration runs/sources,
158159
and removes successful sources.
@@ -1122,7 +1123,9 @@ sessionId})`; create, branch, continue, list, and fork flows live in their
11221123
- Shared schema version 7 validates and removes the exact retired `commitments`
11231124
table and discards its inert rows. Unknown same-named tables or indexes are
11241125
preserved and the migration is refused. Runtime no longer reads or writes
1125-
commitment state. Doctor leaves the legacy `commitments.json` source untouched.
1126+
commitment state. Explicit Doctor repair validates and discards only the exact
1127+
version 1 `commitments/commitments.json` source, records a migration receipt,
1128+
and leaves malformed, changed, linked, or otherwise unsafe files untouched.
11261129
- Web Push subscriptions use typed shared `web_push_subscriptions` rows, and
11271130
generated VAPID identity uses the `webPush.vapidKeys` machine-state key.
11281131
Runtime registration,
@@ -1636,7 +1639,8 @@ Move these into the global database:
16361639
cache, installed plugin index, and app-server bindings. Android device auth
16371640
remains app-local in `SecurePrefs`.
16381641
- Shared schema version 7 discards retired commitment rows and removes their
1639-
table. The legacy `commitments.json` source stays inert and untouched.
1642+
table. Explicit Doctor repair discards the exact retired version 1
1643+
`commitments/commitments.json` source without import, archive, or export.
16401644
- Device/node pairing and bootstrap records now use typed SQLite tables
16411645
- Device-pair notification subscribers and delivered-request markers now use the
16421646
shared SQLite plugin-state table instead of `device-pair-notify.json`.

‎docs/reference/database-schemas.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ Do not lower the version while relative registry rows remain. A schema 8 build i
506506

507507
### Example: state schema 7 to 6
508508

509-
Schema 7 removed the retired shared commitments table. A schema 6 build still requires that canonical table, so a manual downgrade must recreate its exact empty schema before lowering the version.
509+
Schema 7 irreversibly discarded every row in the retired shared commitments table, then removed the table and its indexes. A schema 6 build still requires that canonical table, so a manual downgrade can recreate only its exact empty schema before lowering the version. Restore a verified pre-upgrade backup if the discarded rows are required.
510510

511511
Run equivalent SQL against the global state database after inspecting the exact schema that wrote it:
512512

@@ -570,7 +570,7 @@ WHERE meta_key = 'primary';
570570
COMMIT;
571571
```
572572

573-
The recreated table starts empty because schema 7 discarded the retired rows. A botched downgrade means restore from the verified backup.
573+
The recreated table starts empty. The downgrade cannot recover discarded commitment rows.
574574

575575
### Example: agent schema 17 to 16
576576

‎extensions/voice-call/doctor-contract-api.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ function describeVoiceCallSchemaMigration(migration: OpenClawStateDatabaseSchema
143143
case "audit-events-v2":
144144
return "audit event ledger -> versioned message lifecycle schema";
145145
case "commitments-retirement-v7":
146-
return "retired commitments storage -> removed table and indexes";
146+
return "retired commitments storage -> discarded rows, table, and indexes";
147147
case "state-table-retirement-v10":
148148
return "retired shared-state tables -> removed tables and indexes";
149149
case "state-table-retirement-v11":

0 commit comments

Comments
 (0)