docs(phase-8): plan — full-text search (BM25) + hybrid retrieval#77
Merged
Conversation
Mirrors phase-7-plan.md's shape: TL;DR + sub-phases + open Q1–Q10 + implementation order + scope estimate + risks + integration map. Awaiting user sign-off on Q1–Q10 before any code lands. ## Sub-phases Six chunks, modeled after Phase 7d's HNSW trio: - **8a** — standalone algorithms (tokenizer + BM25 scorer + posting list), no SQL integration. ~250 LOC. Pure-Rust, easy to test. - **8b** — SQL surface: `CREATE INDEX … USING fts(col)`, `fts_match`, `bm25_score`, `try_fts_probe` optimizer hook. ~250 LOC. - **8c** — persistence: new `KIND_FTS_POSTING` cell tag + dedicated page tree + on-demand v4→v5 file-format bump. ~250 LOC. - **8d** — hybrid retrieval (mostly docs + worked example showing BM25 + vector-distance score composition via raw arithmetic). - **8e** — MCP `bm25_search` tool (mirrors Phase 7h's `vector_search`). - **8f** — final docs sweep. Total: ~850 engine LOC + ~800 test + ~750 doc. ## Open questions (need user sign-off) | # | Question | Recommendation | |---|---|---| | Q1 | MATCH-operator syntax | Function-call shape: `fts_match(col, 'q')` (no parser changes) | | Q2 | Multi-column FTS | Single-column per index for MVP | | Q3 | Tokenizer | ASCII for MVP; Unicode follow-up behind a feature flag | | Q4 | Stemming | No | | Q5 | Stop words | No (BM25's IDF handles it) | | Q6 | Filtered FTS | Pre-filter then scalar-eval the rest (mirrors HNSW) | | Q7 | DELETE/UPDATE on FTS-indexed tables | needs_rebuild + rebuild at save (mirrors HNSW) | | Q8 | Hybrid retrieval API | Raw arithmetic; no typed `hybrid_score()` function | | Q9 | MCP `bm25_search` tool | YES, mirrors `vector_search` | | Q10 | File-format version bump | On-demand (only when first FTS index is created) | ## Cross-refs - `docs/_index.md` — points at the plan from the Future-work section - `docs/roadmap.md` — Phase 8 entry now references the plan + summarises the six-sub-phase structure + the v0.2.0 release framing - The plan itself cross-links to phase-7-plan.md (template), and to the engine integration files quoted by file:line for anyone reading the eventual implementation PRs ## Suggested release framing The 0.1.x cycle covered Phase 0 through Phase 7 (modernization through AI-era extensions). Phase 8 changes the file format (v4 → v5 on demand) and adds a substantial new SQL surface — the natural place to bump to v0.2.0. Alternatively fold all six sub-phases into one v0.1.26 release if the work runs small; we'll know after 8a-8c sizing is real. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 8 planning doc, mirroring
phase-7-plan.md's shape: TL;DR + sub-phases + open Q1–Q10 + implementation order + scope estimate + risks + integration map.Awaiting your sign-off on Q1–Q10 before any code lands. Once approved, implementation kicks off at sub-phase 8a (the standalone algorithms).
What Phase 8 ships
FTS5-style inverted-index full-text search with BM25 ranking, plus hybrid retrieval (BM25 + vector-distance score fusion via raw arithmetic). The deferred 7f scope from Phase 7's Q1.
Six sub-phases
CREATE INDEX … USING fts,fts_match,bm25_score, optimizer hook)KIND_FTS_POSTINGcell, page tree, on-demand v4→v5)bm25_searchtoolvector_searchtoolTotal: ~850 engine LOC + ~800 test + ~750 doc — comparable to Phase 7d.
Open questions for sign-off
fts_match(col, 'q')— no parser changes needed. SQLite-stylecol MATCH 'q'would require either patchingsqlparseror a hand-rolled pre-parse rewrite.[^A-Za-z0-9]+, lowercase). Unicode follow-up behind aunicodecargo feature.fts_match(col, 'q') AND status = 'published')needs_rebuild+ rebuild at save (mirrors HNSW).hybrid_score(...)function — composition via+/*is more flexible.bm25_searchtool tosqlrite-mcp?vector_search; surfaces FTS prominently to LLM agents.Suggested release framing
The 0.1.x cycle covered Phase 0 → Phase 7 (modernization → AI-era extensions). Phase 8 changes the file format (v4 → v5 on demand) and adds a substantial new SQL surface — the natural place to bump to v0.2.0.
Alternatively fold all six sub-phases into one v0.1.26 release if the work runs small. We'll know after 8a-8c sizing is real.
Test plan
feat/fts-algorithmsOut of scope (intentionally deferred to Phase 8.1+)
k1/bparametersMATCH '"exact phrase"')🤖 Generated with Claude Code