Repository navigation
fix: admit published memory FTS during v16 Doctor upgrades - #194359
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR admits canonical memory FTS tables during v16 Doctor upgrades and converts memory storage before transcript rebuilds. Example: A 2026.7.2-beta.6 v16 database contains memory_index_chunks_fts and its canonical maintenance triggers.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open for landing: this PR fixes a current Doctor upgrade failure, supplies relevant recorded proof, and has no actionable correctness findings. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherDoctor passes backed-up historical agent databases through schema admission and transactional storage migrations, producing current databases for session and memory readers. flowchart LR
A[Historical agent database] --> B[Doctor backup and custody]
B --> C[Canonical schema admission]
C --> D[Memory storage conversion]
D --> E[Transcript storage migration]
E --> F[Current searchable agent database]
Technical reviewBest possible solution: Land the focused repair through the existing Doctor admission and memory conversion owners, preserving strict refusal of unrelated schema drift. Do we have a high-confidence way to reproduce the issue? Current-main admission rejects lazy memory FTS tables outside its base-schema allowlist; the supplied base-red transcript independently demonstrates that failure on the historical fixture. Is this the best way to solve the issue? The patch addresses both admission and rebuild ordering at their existing owners, reuses canonical schema contracts, and retains transactional rollback and unknown-schema refusal. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 11a9e5668b4a. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +77, Tests +116, Other +3. Total +196 across 6 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (2 earlier review cycles)
Reviewed November 6, 2026, 8:15 PM ET / November 7, 2026, 01:15 UTC (Revision 3). |
A beta.6 v16 agent database can already contain OpenClaw's lazy memory index. Doctor treated that virtual table and its SQLite shadow tables as unknown schema, so a legitimate index blocked the upgrade. Co-authored-by: Cursor <[email protected]>
Canonical body triggers can address chunk_rowid before that column exists. Admit that exact SQL, convert memory storage before later rebuilds reparse triggers, and still refuse drifted definitions. Co-authored-by: Cursor <[email protected]>
The published beta.6 regressions and the canonical trigger cases exceed the previous allocation once main's remaining slack is included. Co-authored-by: Cursor <[email protected]>
3a3c307 to
8c247bf
Compare
|
@clawsweeper re-review The head is |
|
🦞👀 Re-review progress:
|
|
Recorded transcripts for head
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Thanks @ericcaiwx-star — independently reviewed (no P0–P2 findings) and landed as 958bfb7. Not yet released; it ships in the next release. |
…194359) Doctor media-persistence now admits OpenClaw's own memory FTS virtual table and its SQLite shadow tables in published 2026.7.2-beta.6 v16 agent databases, instead of refusing the upgrade as an unknown extension (fixes openclaw#194358). Co-authored-by: Eric Cai <[email protected]> Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: steipete <[email protected]>
Fixes #194358
What Problem This Solves
Doctor cannot finish a beta.6 v16 agent-database upgrade when that database contains OpenClaw's own lazy memory FTS index. The v16 prerequisite treats the FTS virtual table or its SQLite shadow tables as unknown schema. The same published index can also already carry the canonical chunk triggers, which address
chunk_rowidbefore the v16 chunks table has that column. Later table rebuilds reparse those triggers and stop the upgrade.Why This Change Was Made
repairAndAssertOpenClawAgentV16Validity()allows only base-schema tables and indexes. Memory FTS is installed lazily by the memory schema owner and is absent from that DDL. The repair now accepts a chunks or path FTS table only whenmatchesSqliteMemorySearchFragment()accepts it forunicode61ortrigram, then allows the exact FTS5 shadow tables SQLite reports for that verified table. The memory storage owner also admits the exact canonical body-trigger SQL on the legacy chunks table, drops those triggers before later rebuilds reparse the schema, and reinstalls them afterchunk_rowidexists. Memory storage conversion runs before the transcript payload rebuild for that reason. Drifted definitions, forged ordinary tables, unknown virtual tables, and drifted trigger SQL still fail. The existing transaction, pre-repair backup, and unknown-structure refusal stay in place. No config, environment variable, or schema version is added.User Impact
An operator with a beta.6 database that already has OpenClaw memory search indexes, including the canonical chunk triggers, can complete
openclaw doctor --fixwithout deleting those indexes. Messages and indexed memory remain searchable. Databases with unrelated schema drift are still refused. A database already settled by published v2026.11.1 keeps its settings and indexed memory when this candidate Doctor upgrades it.Evidence
Recorded transcripts, with local home and checkout paths redacted: https://gist.github.com/ericcaiwx-star/08bf81a40946122f1f802d019793cb8d
Head
8c247bf599b4f75f0ee9bcc69ab8fbc29b643765. The repair is1c013f15059;8c247bf599bonly raises the test-line allocation.Candidate Doctor command for both runs below:
HOME=<isolated-home> OPENCLAW_STATE_DIR=<isolated-state> OPENCLAW_CONFIG_PATH=<isolated-state>/openclaw.json OPENCLAW_GATEWAY_TOKEN=<synthetic-token> OPENCLAW_NO_RESPAWN=1 OPENCLAW_UPDATE_IN_PROGRESS=1 node --import ./scripts/tsx.mjs src/entry.ts doctor --fix --non-interactive --no-workspace-suggestionsOPENCLAW_UPDATE_IN_PROGRESS=1skips the source-tree install capture. The pre-repair backup and schema migration still run.Affected beta.6 state. On
cfd165b3fe987cb332f17f4567619b3a83dc0f42, that entry refused a synthetic v16 database built from the published fixture plus owner-created memory FTS:unexpected table memory_index_chunks_fts, exit 1, version left at 16. After the change, a fresh copy still hadmemory_index_chunks_fts_after_insert,memory_index_chunks_fts_after_update, andmemory_index_chunks_fts_after_deleteinstalled. Those triggers were not dropped before launch.memory_index_chunkshad nochunk_rowidcolumn anduser_versionwas 16. The rebased source at8c247bf599bran Doctor twice. Both exits were 0. The first saved a pre-repair backup and reportedv16 -> v40. The second stayed at schema 40. The three triggers, the synthetic chunk text, and bothMATCHqueries remained.PRAGMA integrity_checkwasok, andPRAGMA foreign_key_checkreturned no rows. Full output:doctor-exact-head.txtin the gist.Published v2026.11.1 to this candidate.
[email protected](4ffdd20) indexedMEMORY.mdandmemory/synthetic-stable.mdfor agent main. The texts weresynthetic stable root memory alpha-20261107andsynthetic stable memory token alpha-20261107. Config keptgateway.mode=local,gateway.port=18981,gateway.auth.mode=token, andagents.defaults.workspacepointing at the synthetic workspace. Publisheddoctor --fix --non-interactive --no-workspace-suggestionsexited 0 and leftuser_versionat 27 (doctor-stable.txt). A copy of that state was then upgraded by the candidate command above. Exit 0. Doctor reportedv27 -> v40(doctor-candidate.txt). Afterward both memory texts were still present,memory_index_chunks_fts MATCH 'synthetic'returnedMEMORY.mdandmemory/synthetic-stable.md, integrity wasok, the foreign-key check was empty, and the four settings above were unchanged.Base-red regression. The candidate's published beta.6 historical test was run against production files from
266a7aa0fe69e2b5fe6445c4ceb1e15b5360c957, the parent of the repair:node scripts/run-vitest.mjs src/infra/state-migrations.media-persistence.historical.test.ts -t "published beta.6"Exit 1.
valid-fts-shadow,valid-fts-trigram, anddrifted-memory-ftsfail withunexpected table memory_index_chunks_fts(base-red.txt). The same filter on the candidate head passes: 13 passed.node scripts/run-vitest.mjs packages/memory-host-sdk/src/host/memory-schema-storage-migration.test.tspassed 34, including canonical-trigger conversion and drifted-trigger refusal. The production files were restored after the base-red run. The worktree is clean at8c247bf599b.Isolated Gateway on the same repair before the rebase, token
<synthetic-token>,--allow-unconfigured --bind loopback --port 54827: the first process listened on127.0.0.1:54827, finished sidecar startup, and shut down cleanly after SIGTERM. The second process on that same state logged[gateway] ready, finished post-ready maintenance, and also shut down cleanly. That pair was not re-run after the rebase. The rebase did not change the gateway startup path. Control UI assets were not built. The Gateway proof used the source entry.