Skip to content

fix: admit published memory FTS during v16 Doctor upgrades - #194359

Merged
roboclaw-bot merged 3 commits into
openclaw:mainfrom
ericcaiwx-star:fix/v16-memory-fts-admission
Nov 7, 2026
Merged

roboclaw-bot merged 3 commits into
openclaw:mainfrom
ericcaiwx-star:fix/v16-memory-fts-admission

Conversation

@ericcaiwx-star

@ericcaiwx-star ericcaiwx-star commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

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_rowid before 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 when matchesSqliteMemorySearchFragment() accepts it for unicode61 or trigram, 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 after chunk_rowid exists. 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 --fix without 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 is 1c013f15059; 8c247bf599b only 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-suggestions

OPENCLAW_UPDATE_IN_PROGRESS=1 skips 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 had memory_index_chunks_fts_after_insert, memory_index_chunks_fts_after_update, and memory_index_chunks_fts_after_delete installed. Those triggers were not dropped before launch. memory_index_chunks had no chunk_rowid column and user_version was 16. The rebased source at 8c247bf599b ran Doctor twice. Both exits were 0. The first saved a pre-repair backup and reported v16 -> v40. The second stayed at schema 40. The three triggers, the synthetic chunk text, and both MATCH queries remained. PRAGMA integrity_check was ok, and PRAGMA foreign_key_check returned no rows. Full output: doctor-exact-head.txt in the gist.

Published v2026.11.1 to this candidate. [email protected] (4ffdd20) indexed MEMORY.md and memory/synthetic-stable.md for agent main. The texts were synthetic stable root memory alpha-20261107 and synthetic stable memory token alpha-20261107. Config kept gateway.mode=local, gateway.port=18981, gateway.auth.mode=token, and agents.defaults.workspace pointing at the synthetic workspace. Published doctor --fix --non-interactive --no-workspace-suggestions exited 0 and left user_version at 27 (doctor-stable.txt). A copy of that state was then upgraded by the candidate command above. Exit 0. Doctor reported v27 -> v40 (doctor-candidate.txt). Afterward both memory texts were still present, memory_index_chunks_fts MATCH 'synthetic' returned MEMORY.md and memory/synthetic-stable.md, integrity was ok, 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, and drifted-memory-fts fail with unexpected 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.ts passed 34, including canonical-trigger conversion and drifted-trigger refusal. The production files were restored after the base-red run. The worktree is clean at 8c247bf599b.

Isolated Gateway on the same repair before the rebase, token <synthetic-token>, --allow-unconfigured --bind loopback --port 54827: the first process listened on 127.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.

@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 6, 2026
@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: Doctor refuses the database with unexpected table memory_index_chunks_fts.
  • After: Doctor upgrades it to schema 40 while preserving searchable memory and reinstalling canonical triggers.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused, source-verified repair with recorded Doctor upgrade proof, relevant regression coverage, and successful head checks.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The linked recorded source Doctor runs exercise the reviewed head against synthetic beta.6 v16 state with canonical triggers, complete twice, and retain searchable memory and integrity; published v2026.11.1-to-candidate upgrade evidence addresses existing-state compatibility and resolves the previous proof request.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Doctor refuses a published historical agent database containing OpenClaw-created memory search indexes, preventing the upgrade from finishing.
Reason: Restoring an existing published upgrade path has clear value and introduces no new configuration, schema version, or public API.

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
Reviewed head: 8c247bf599b4f75f0ee9bcc69ab8fbc29b643765

Before merge

None.

Findings

None.

Agent review details

How this fits together

Doctor 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]
Loading

Technical review

Best 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

  • v16 validity repair admission keeps the original intent (ffee6a1: Restore missing canonical validity triggers while preserving data and rejecting unrelated schema drift.)
  • Legacy memory storage dependent validation keeps the original intent (c659113: Convert memory embeddings losslessly and preserve logical text, identities, and search behavior without silently discarding unknown dependents.)
  • Memory and transcript conversion ordering changes intended behavior with a stated reason (c659113: Perform physical storage conversions within the existing agent migration transaction; this PR explains why canonical legacy memory triggers require memory conversion to run first.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +77, Tests +116, Other +3. Total +196 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 87 10 +77
Tests 2 117 1 +116
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 3 0 +3
Total 6 207 11 +196

Preflight source

Source 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

Metric Value Why it matters
Production versus regression coverage Production +87/-10 lines; tests +117/-1 lines Growth covers canonical historical-schema admission, required migration ordering, and distinct preservation and refusal regressions without adding another migration owner.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Affected published beta databases cannot finish Doctor migration and remain blocked from normal agent database use.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-06T23:27:33.978Z sha 51640f5749c1bdc0ef9a5832ae3a59c6547be87f :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-07T00:36:06.287Z sha 8c247bf :: needs real behavior proof before merge. :: none

Reviewed November 6, 2026, 8:15 PM ET / November 7, 2026, 01:15 UTC (Revision 3).

@ericcaiwx-star
ericcaiwx-star marked this pull request as ready for review November 6, 2026 23:48
ericcaiwx-star and others added 3 commits November 7, 2026 08:03
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]>
@ericcaiwx-star
ericcaiwx-star force-pushed the fix/v16-memory-fts-admission branch from 3a3c307 to 8c247bf Compare November 7, 2026 00:07
@ericcaiwx-star

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The head is 8c247bf599b4f75f0ee9bcc69ab8fbc29b643765. The PR body now records the shipped source Doctor entry run twice on a synthetic beta.6 v16 database that still had memory_index_chunks_fts_after_insert, memory_index_chunks_fts_after_update, and memory_index_chunks_fts_after_delete installed. Both runs exited 0, left schema 40, kept those triggers, and preserved the synthetic message and both MATCH queries. An isolated loopback Gateway listened, finished its sidecars, and shut down cleanly, then did so again on restart. Drifted trigger SQL is still refused.

@clawsweeper

clawsweeper Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 7, 2026
@ericcaiwx-star

Copy link
Copy Markdown
Contributor Author

Recorded transcripts for head 8c247bf599b4f75f0ee9bcc69ab8fbc29b643765 are in https://gist.github.com/ericcaiwx-star/08bf81a40946122f1f802d019793cb8d and the Evidence section now points at them.

  • doctor-exact-head.txt: source Doctor twice on the synthetic beta.6 v16 database with memory_index_chunks_fts_after_insert, memory_index_chunks_fts_after_update, and memory_index_chunks_fts_after_delete still installed. Both exits are 0. The first reports v16 -> v40.
  • doctor-stable.txt and doctor-candidate.txt: published v2026.11.1 (4ffdd20) settled the synthetic memory index at schema 27, then this candidate upgraded that copy v27 -> v40 with exit 0. The workspace setting, gateway mode, port, and auth mode stayed, and both indexed memory texts still match.
  • base-red.txt: the new published beta.6 cases against 266a7aa0fe69e2b5fe6445c4ceb1e15b5360c957 exit 1 with unexpected table memory_index_chunks_fts.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 7, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 7, 2026
@roboclaw-bot
roboclaw-bot merged commit 958bfb7 into openclaw:main Nov 7, 2026
161 checks passed
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Thanks @ericcaiwx-star — independently reviewed (no P0–P2 findings) and landed as 958bfb7. Not yet released; it ships in the next release.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 8, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Doctor refuses beta.6 agent databases that contain OpenClaw's own memory FTS tables

2 participants