Skip to content

fix(fts): populate the memories_fts index on init so search works without a manual rebuild#167

Open
J0nd1sk wants to merge 1 commit into
TSchonleber:mainfrom
J0nd1sk:fix/151-fts-cold-start
Open

fix(fts): populate the memories_fts index on init so search works without a manual rebuild#167
J0nd1sk wants to merge 1 commit into
TSchonleber:mainfrom
J0nd1sk:fix/151-fts-cold-start

Conversation

@J0nd1sk

@J0nd1sk J0nd1sk commented Jul 3, 2026

Copy link
Copy Markdown

External-content FTS5 (memories_fts, content=memories) starts with an empty
inverted index. cmd_init applied migrations but never seeded it, and
_ensure_fts_index_consistent only rebuilt when 'integrity-check' raised — an
empty index is consistent, not corrupt, so a populated-but-unindexed DB
returned nothing from search with no error.

  • cmd_init: rebuild memories_fts after migrations so fresh DBs are primed
  • _ensure_fts_index_consistent: detect under-population (memories_fts_docsize
    count < active indexed rows) and rebuild, not only on integrity-check failure
  • migration 084: repair DBs already created without a seeded index

Resolves the scenario-8 MCP add->search integration xfail (the search path now
heals a missing index deterministically instead of relying on version-dependent
incremental-index timing).

Refs bug #151 — brainctl init does not populate the FTS5 inverted index
(memory_search returns empty until a manual rebuild):
#151

Full CLI add->search resolution also requires the scoped memories_fts update
triggers from PR #166 (fix for bug #152) — on the unscoped triggers, post-insert
metadata UPDATEs erode the freshly inserted entry. Until #166 lands, the CLI
add->search path stays xfail; this PR fixes the init-seed, the MCP-search path,
and the auto-heal for genuinely empty indexes.

…hout a manual rebuild

External-content FTS5 (memories_fts, content=memories) starts with an empty
inverted index. cmd_init applied migrations but never seeded it, and
_ensure_fts_index_consistent only rebuilt when 'integrity-check' raised — an
empty index is consistent, not corrupt, so a populated-but-unindexed DB
returned nothing from search with no error.

- cmd_init: rebuild memories_fts after migrations so fresh DBs are primed
- _ensure_fts_index_consistent: detect under-population (memories_fts_docsize
  count < active indexed rows) and rebuild, not only on integrity-check failure
- migration 084: repair DBs already created without a seeded index

Resolves the scenario-8 MCP add->search integration xfail (the search path now
heals a missing index deterministically instead of relying on version-dependent
incremental-index timing).

Refs bug TSchonleber#151 — brainctl init does not populate the FTS5 inverted index
(memory_search returns empty until a manual rebuild):
TSchonleber#151

Full CLI add->search resolution also requires the scoped memories_fts update
triggers from PR TSchonleber#166 (fix for bug TSchonleber#152) — on the unscoped triggers, post-insert
metadata UPDATEs erode the freshly inserted entry. Until TSchonleber#166 lands, the CLI
add->search path stays xfail; this PR fixes the init-seed, the MCP-search path,
and the auto-heal for genuinely empty indexes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant