Repository navigation
fix(state): let doctor repair legacy v17 agent databases - #134208
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 12:18 PM ET / 16:18 UTC. ClawSweeper reviewWhat this changesThe PR repairs legacy v17 agent databases by creating missing additive session objects inside the canonical-index repair savepoint before strict schema validation, with migration and Doctor CLI regression coverage. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessNo blocking correctness finding. The owner-level repair is coherent and the supplied packaged Doctor trace clears the prior proof gap; this fresh PR should remain open for exact-head CI and normal maintainer review. Priority: P1 Review scores
Verification
How this fits togetherDoctor repairs each persisted per-agent SQLite database before gateway startup uses it. Its migration path must turn a supported legacy schema into the current validated schema or preserve the database unchanged when unrelated drift makes repair unsafe. flowchart LR
A[Legacy v17 agent database] --> B[Doctor --fix]
B --> C[Migration owner]
C --> D[Index and additive repair savepoint]
D --> E[Current schema validation]
E --> F[Gateway startup]
D --> G[Rollback on unrelated drift]
Before merge
Agent review detailsSecurityNone. PR surfaceSource 0, Tests +187. Total +187 across 3 files. View PR surface stats
Review metrics
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: Keep one canonical v17 preflight that atomically converges additive session schema and canonical indexes before the normal schema migration, retaining both migration-owner and Doctor-process regressions. Do we have a high-confidence way to reproduce the issue? Yes. The v17 callback and its Doctor caller establish the path in source, and the PR supplies a packaged before/after Doctor trace using the same missing trigger, column, and canonical index scenario. Is this the best way to solve the issue? Yes. This is the best repair shape: it converges the missing additive objects at the canonical validation owner and shares the existing savepoint, rather than adding a Doctor-only workaround or a parallel migration path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9cc05cca83e2. LabelsLabel changes:
Label 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 (1 earlier review cycle)
|
|
Thanks @EthDing! Proof: The exact-head CI-built package ran
|
Move the schema-17 additive and canonical-index preflight into the existing migration transaction. A later participant identity rejection now rolls back every prerequisite write while damaged-index recovery still works. Replace the false-green early-rejection test with red/green owner and `openclaw doctor --fix` process regressions. Related to #134163 and follows #134208. Co-authored-by: Ayaan Zaidi <[email protected]>
…4208) Fixes openclaw#134163. Repair the v17 additive session schema inside the canonical-index savepoint before strict validation. Preserve rollback for unrelated schema drift and cover the distributed Doctor path. Co-authored-by: Ayaan Zaidi <[email protected]>
Move the schema-17 additive and canonical-index preflight into the existing migration transaction. A later participant identity rejection now rolls back every prerequisite write while damaged-index recovery still works. Replace the false-green early-rejection test with red/green owner and `openclaw doctor --fix` process regressions. Related to openclaw#134163 and follows openclaw#134208. Co-authored-by: Ayaan Zaidi <[email protected]>
Fixes #134163
What Problem This Solves
openclaw doctor --fixcould not migrate a supported agent database from schema v17 when both the additive session route context and the canonical transcript identity index were absent. Doctor validated the additive object before creating it, warned, and left the database at v17.Root Cause
The v17 canonical-index repair callback ran the strict legacy-schema assertion before
ensureSessionAdditiveColumns. The assertion therefore required the route-context trigger that the additive owner had not created yet.Fix
The existing canonical-index repair savepoint now runs
ensureSessionAdditiveColumnsbefore its strict v17 assertion. Additive convergence, index repair, and validation stay atomic. Unrelated schema drift rolls back both repairs.The takeover keeps
validateAfterRepair, does not change the schema version, does not add another migration path, and adds no configuration.Evidence
I installed CI-built OpenClaw packages for baseline
c884d51b870and contributor headbb70bcb73db2, then ran the distributed binary against byte-identical isolated v17 fixtures.The baseline package came from
dist-runtime-buildrun 33408370171. The repaired package came fromdist-runtime-buildrun 33406382600.Regression Coverage
cache_entriesand proves non-additive drift leaves v17 while rolling back both additive and index repair.doctor --fixtwice, verifies v17 reaches the current schema, and verifies the second run is clean.History
entry_validpredates v17. Commitcd8a96491e2added it while the agent schema was v16. Commit38fabc4e031later created v17. Tagv2026.8.1-beta.2contains v17 andentry_valid, so the savepoint does not expand to that older repair.