Repository navigation
fix(memory): recover missing full-text index rows - #144641
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: blocked before merge. Reviewed September 11, 2026, 12:22 AM ET / 04:22 UTC (Revision 2). ClawSweeper reviewWhat this changesMemory initialization now rebuilds an incomplete full-text search index when its row count differs from canonical memory chunks, with regression coverage for restored results. Warning SQLite table change This PR modifies persisted SQLite tables in Merge readiness⛔ Blocked before merge - 1 item remains This PR remains useful: current main and the latest release retain the reported gap. The new persisted-database CLI evidence resolves the previous proof blocker, and no actionable patch defects were found. Priority: P2 Review scores
Verification
How this fits togetherThe Memory Host SDK maintains SQLite indexes used by OpenClaw’s memory search. During memory initialization, it reconciles derived full-text tables against canonical chunks before keyword queries use them. flowchart TD
A[Memory search command] --> B[Memory initialization]
B --> C[Compare canonical and index counts]
D[Canonical memory chunks] --> C
C -->|Different| E[Rebuild within savepoint]
C -->|Equal| F[Preserve existing index]
E --> G[Keyword search results]
F --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +3, Tests +39. Total +42 across 3 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep automatic partial-index recovery in the existing reconciliation owner, rebuilding solely from canonical chunks without changing stored formats or user settings. Do we have a high-confidence way to reproduce the issue? Yes: deleting one derived row while retaining another exposes the current-main empty-table guard. This is source-proven here; the contributor also supplies before/after CLI evidence, but this review did not execute it. Is this the best way to solve the issue? Yes: reusing the canonical rebuild inside the existing savepoint is a focused repair, and the persisted-database proof covers reopening affected state without a schema migration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8ddc4a1422c0. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Thanks for the review. The requested compatibility evidence is already included in the PR body under Data-model and upgrade compatibility and Isolated real CLI proof. This patch does not change the persisted data model: it adds no table, column, index option, schema version, migration, configuration, or public API. It only changes reconciliation of the existing fully derived The persisted-state proof starts with an existing current-format agent database containing 2 canonical rows and 1 derived FTS row, reopens it through the supported I also rechecked against current Could the generic data-model compatibility checkbox be cleared based on that evidence? @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Maintainer disposition of the SQLite-table warning at head 1f7a83f: this is not a persisted-format or schema change. The patch keeps the existing reconciliation owner in @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Merged via squash.
|
|
@jinliyl Narrow post-merge regression notice for the memory/FTS owner.
Baseline reproducer: node scripts/run-vitest.mjs extensions/memory-core/src/memory/manager-temporal-ranking.test.ts -t "through FTS unavailable"Is an existing canonical follow-up already owned? Relaying here to avoid competing memory fixes in the lease or Wear PRs. This is not a request to waive their exact-head CI, restart automation, or weaken the fallback assertion. |
Related: #136257 (F25), #142165. ## What Problem This Solves Fixes an issue where the Watch model picker used the phone's current catalog instead of the session selected on the Watch. A valid Watch-session choice could be rejected before reaching the session owner. The Gateway also implemented session-scoped catalogs without advertising that capability in hello. ## Why This Change Was Made The Wear bridge reads `models.list` for the requested session and uses the phone's existing result parser. The old phone-current catalog callback and selection veto are removed. Availability, unknown availability, search bounds, and partial-refresh warnings now flow from the same catalog result. Hello advertises the implemented capability, and the phone advertises model controls only when the Gateway supports it. New Watches always send their selected session. Shipped protocol-v1 Watches that omit the field retain phone-active-session behavior through the same direct catalog owner. The protocol version is unchanged. ## User Impact - The Watch lists models for its selected session and lets the session owner accept or reject a change. - Partial refresh warnings preserve usable choices. Context changes clear old catalog and search state. - Unsupported peers keep ordinary session navigation usable. Older Watches retain their existing request contract. ## Evidence - Baseline hello regression: one expected failure, 30 passing cases; the implemented session-catalog capability was absent. - Baseline selection regression: the phone-current catalog veto rejected a valid Watch-session choice before calling its owner. - Candidate: 43 Gateway tests and 150 focused Android tests passed, including shared parser, real phone runtime/WebSocket dispatch, Watch repository, state transitions, proxy identity, and protocol coverage. - Wear APK assembly, Kotlin formatting, and native localization verification passed. - All 15 sanitized config-corpus fixtures passed actual Gateway startup with external networking disabled, fake credentials, and external Tailscale exposure disabled for isolation. - A real Gateway client connection, also exercised by an independent validator, observed protocol 4, the published capability, and the requested fixture catalog. - Wear API 34 and phone API 36 emulators booted with KVM. The normal Wear APK installed and launched. No paired Data Layer or live Watch picker result is claimed. - Pairing proof gap, explicitly accepted for this change: **requires companion app + Play services; unit-covered**. The images have Play services but lack the required companion app; its official installation requires Google sign-in. Shared-parser, bridge, availability, and negotiation behavior are covered by the focused tests. No provider inference, real credentials, protocol bump, or storage migration was used. ### Unrelated CI failure Run [34567709488](https://github.com/openclaw/openclaw/actions/runs/34567709488) completed with every Android job passing. `checks-node-changed-extensions-config-49` failed the existing memory temporal-ranking `FTS unavailable` case at line 156; `openclaw/ci-gate` reports that child failure. CI merged this head into main `2575d0d6356535a58d3a9798f08000caac856d0e` (#144641). That main change replaced the schema write probe with a row-count check, so the test's injected view now reports available. The exact CI base reproduces the same failure with five neighboring cases passing: ```sh OPENCLAW_VITEST_MAX_WORKERS=2 node scripts/run-vitest.mjs --config test/vitest/vitest.extension-memory.config.ts extensions/memory-core/src/memory/manager-temporal-ranking.test.ts # exit 1 on 2575d0d ``` The earlier base `ada8b5f65083` passes all six cases. This PR changes no memory implementation, schema, dependency, or test-runner code. The verified unrelated failure is retained as a separate follow-up; no CI retry or test weakening was used. Co-authored-by: Ayaan Zaidi <[email protected]>
) * fix(memory): restore FTS fallback for same-name view collisions Detect SQLite views before FTS schema reconciliation so matching row counts cannot falsely report an available body index. Preserve colliding views, canonical rows, and existing ordinary-table repairs. Regression context: #144641. Validated with 53 focused tests and the full changed gate. P2 review raised only an unchanged path-trigger recovery limitation, confirmed with paired original/candidate SQLite proof and retained as a separate follow-up. * fix(memory): preserve SQLite view-collision diagnostics Keep the existing cannot-modify message when rejecting a colliding view before FTS reconciliation. This preserves the status diagnostic checked by the merged #144761 temporal-ranking fixture without changing schema or recovery behavior. Validated with 53 focused tests using the exact merged fixture. Incremental P2 review found no actionable issues; the previously recorded path-trigger recovery limitation remains unchanged.
* fix(memory): rebuild partial full-text indexes * test(memory): expect reconciled full-text rows
Related: openclaw#136257 (F25), openclaw#142165. ## What Problem This Solves Fixes an issue where the Watch model picker used the phone's current catalog instead of the session selected on the Watch. A valid Watch-session choice could be rejected before reaching the session owner. The Gateway also implemented session-scoped catalogs without advertising that capability in hello. ## Why This Change Was Made The Wear bridge reads `models.list` for the requested session and uses the phone's existing result parser. The old phone-current catalog callback and selection veto are removed. Availability, unknown availability, search bounds, and partial-refresh warnings now flow from the same catalog result. Hello advertises the implemented capability, and the phone advertises model controls only when the Gateway supports it. New Watches always send their selected session. Shipped protocol-v1 Watches that omit the field retain phone-active-session behavior through the same direct catalog owner. The protocol version is unchanged. ## User Impact - The Watch lists models for its selected session and lets the session owner accept or reject a change. - Partial refresh warnings preserve usable choices. Context changes clear old catalog and search state. - Unsupported peers keep ordinary session navigation usable. Older Watches retain their existing request contract. ## Evidence - Baseline hello regression: one expected failure, 30 passing cases; the implemented session-catalog capability was absent. - Baseline selection regression: the phone-current catalog veto rejected a valid Watch-session choice before calling its owner. - Candidate: 43 Gateway tests and 150 focused Android tests passed, including shared parser, real phone runtime/WebSocket dispatch, Watch repository, state transitions, proxy identity, and protocol coverage. - Wear APK assembly, Kotlin formatting, and native localization verification passed. - All 15 sanitized config-corpus fixtures passed actual Gateway startup with external networking disabled, fake credentials, and external Tailscale exposure disabled for isolation. - A real Gateway client connection, also exercised by an independent validator, observed protocol 4, the published capability, and the requested fixture catalog. - Wear API 34 and phone API 36 emulators booted with KVM. The normal Wear APK installed and launched. No paired Data Layer or live Watch picker result is claimed. - Pairing proof gap, explicitly accepted for this change: **requires companion app + Play services; unit-covered**. The images have Play services but lack the required companion app; its official installation requires Google sign-in. Shared-parser, bridge, availability, and negotiation behavior are covered by the focused tests. No provider inference, real credentials, protocol bump, or storage migration was used. ### Unrelated CI failure Run [34567709488](https://github.com/openclaw/openclaw/actions/runs/34567709488) completed with every Android job passing. `checks-node-changed-extensions-config-49` failed the existing memory temporal-ranking `FTS unavailable` case at line 156; `openclaw/ci-gate` reports that child failure. CI merged this head into main `0c892cac993095c0a95d7487f9f2e9123a835733` (openclaw#144641). That main change replaced the schema write probe with a row-count check, so the test's injected view now reports available. The exact CI base reproduces the same failure with five neighboring cases passing: ```sh OPENCLAW_VITEST_MAX_WORKERS=2 node scripts/run-vitest.mjs --config test/vitest/vitest.extension-memory.config.ts extensions/memory-core/src/memory/manager-temporal-ranking.test.ts # exit 1 on 0c892ca ``` The earlier base `0eb133df5ce0` passes all six cases. This PR changes no memory implementation, schema, dependency, or test-runner code. The verified unrelated failure is retained as a separate follow-up; no CI retry or test weakening was used. Co-authored-by: Ayaan Zaidi <[email protected]>
…claw#144783) * fix(memory): restore FTS fallback for same-name view collisions Detect SQLite views before FTS schema reconciliation so matching row counts cannot falsely report an available body index. Preserve colliding views, canonical rows, and existing ordinary-table repairs. Regression context: openclaw#144641. Validated with 53 focused tests and the full changed gate. P2 review raised only an unchanged path-trigger recovery limitation, confirmed with paired original/candidate SQLite proof and retained as a separate follow-up. * fix(memory): preserve SQLite view-collision diagnostics Keep the existing cannot-modify message when rejecting a colliding view before FTS reconciliation. This preserves the status diagnostic checked by the merged openclaw#144761 temporal-ranking fixture without changing schema or recovery behavior. Validated with 53 focused tests using the exact merged fixture. Incremental P2 review found no actionable issues; the previously recorded path-trigger recovery limitation remains unchanged.
…exes (#175555) Related: #144641, #174438 ## What Problem This Solves Memory index admission counted rows of the FTS5 table with `SELECT COUNT(*)`. FTS5 serves that count as a full scan of its `%_content` shadow table. On large stores this added up to about 1.7 s of cold I/O, inside the agent database write transaction. ## User Impact User impact: memory stores with a large full-text index open faster and hold the agent database write lock for less time. Search results, config, schema and stored data do not change. ## Why This Change Was Made The admitted body FTS DDL keeps the default `columnsize=1`, so FTS5 stores one `%_docsize` row per document. The reconcile check now counts `<fts>_docsize`, which gives the same number from a much smaller table (211 pages instead of 20,567 on a 43,490-chunk store). Admission drops and recreates any FTS table with different DDL before the count runs, so the docsize table is always present. The rebuild decision and its repair are unchanged. ## Evidence - Focused test `memory-schema-fts-reconcile.test.ts`: 16/16 pass. The new test checks that the query plan reads `memory_index_chunks_fts_docsize`, not the virtual table, and that the count equals `COUNT(*)` of the FTS table after deletes, re-inserts, edits and empty rows. - Built CLI on this head, isolated state: `openclaw memory index` on 31 memory files gave 31 chunks, 31 docsize rows, 31 content rows. Deleting 12 FTS rows left 19/19. The next `openclaw memory search zebracorn` admission saw the mismatch, rebuilt the index back to 31/31, and returned all 30 matching notes. - Contributor benchmark on two real stores: cold first admission 2,003-2,060 ms to 317-325 ms (43,490 chunks) and 220-230 ms to 72 ms (6,012 chunks). - Hosted CI green and ClawSweeper `ready` on the merged head. Co-authored-by: Ayaan Zaidi <[email protected]>
…exes (openclaw#175555) Related: openclaw#144641, openclaw#174438 ## What Problem This Solves Memory index admission counted rows of the FTS5 table with `SELECT COUNT(*)`. FTS5 serves that count as a full scan of its `%_content` shadow table. On large stores this added up to about 1.7 s of cold I/O, inside the agent database write transaction. ## User Impact User impact: memory stores with a large full-text index open faster and hold the agent database write lock for less time. Search results, config, schema and stored data do not change. ## Why This Change Was Made The admitted body FTS DDL keeps the default `columnsize=1`, so FTS5 stores one `%_docsize` row per document. The reconcile check now counts `<fts>_docsize`, which gives the same number from a much smaller table (211 pages instead of 20,567 on a 43,490-chunk store). Admission drops and recreates any FTS table with different DDL before the count runs, so the docsize table is always present. The rebuild decision and its repair are unchanged. ## Evidence - Focused test `memory-schema-fts-reconcile.test.ts`: 16/16 pass. The new test checks that the query plan reads `memory_index_chunks_fts_docsize`, not the virtual table, and that the count equals `COUNT(*)` of the FTS table after deletes, re-inserts, edits and empty rows. - Built CLI on this head, isolated state: `openclaw memory index` on 31 memory files gave 31 chunks, 31 docsize rows, 31 content rows. Deleting 12 FTS rows left 19/19. The next `openclaw memory search zebracorn` admission saw the mismatch, rebuilt the index back to 31/31, and returned all 30 matching notes. - Contributor benchmark on two real stores: cold first admission 2,003-2,060 ms to 317-325 ms (43,490 chunks) and 220-230 ms to 72 ms (6,012 chunks). - Hosted CI green and ClawSweeper `ready` on the merged head. Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #115775
What Problem This Solves
Fixes an issue where users with a populated but incomplete memory full-text index could receive silently missing search results. Ordinary schema reconciliation only rebuilt a completely empty index, so one or more missing derived rows survived startup.
Why This Change Was Made
The existing Memory Host SDK FTS owner now compares canonical and derived row counts inside its existing savepoint and invokes the existing canonical rebuild operation only when they diverge. This is routine maintenance of the derived-index contract accepted in #115775; it adds no schema, version, configuration, migration, or public API.
User Impact
Memory search recovers missing FTS rows during normal schema reconciliation while leaving complete indexes and canonical memory rows unchanged.
Evidence
keptand failed to restore/searchmissing.node scripts/run-vitest.mjs packages/memory-host-sdk/src/host/memory-schema-fts-reconcile.test.ts packages/memory-host-sdk/src/host/memory-schema.test.ts --maxWorkers=1(33 passed across both selected projects)memory-schema.test.ts: it expected a newly canonicalchunk-2to remain absent from FTS. The assertion now requires both canonical chunks after reconciliation, and the full sibling test file passes.Isolated real CLI proof
Used a fresh temporary state/config/workspace with two synthetic memory files and the normal supported CLI.
pnpm openclaw memory index --agent main --forceindexed both files. I then removed only the derived FTS row formemory/beta.md, producing this persisted precondition:{ "canonical": { "n": 2 }, "derived": { "n": 1 }, "missingMatch": [] }Running normal initialization through
pnpm openclaw memory search --agent main --query cobalt --jsonreturnedmemory/beta.mdwith its syntheticcobalt-lantern-482snippet. Read-only inspection after the command showed:{ "canonical": { "n": 2 }, "derived": { "n": 2 }, "match": [{ "path": "memory/beta.md" }] }Data-model and upgrade compatibility
The proof starts from an already persisted current-format agent database, removes a reconstructible derived row to model the affected existing state, and reopens it through the patched normal CLI path. The repair changes no table definition, columns, schema version, canonical rows, configuration, migration, downgrade behavior, or public API. It only rebuilds the existing derived FTS table from the existing canonical chunks when their cardinalities prove divergence. Equal-count databases retain their existing index.