Repository navigation
fix: documents_fts migration repair + doc delete by slug (#549, #550) - #554
Merged
Merged
Conversation
#549: Add ensure_documents_fts() consistency check that creates the FTS5 virtual table and backfills existing documents if the v12 migration failed silently (best-effort execute). #550: Resolve slug to document ID before calling delete_document(), matching doc_get behavior. Previously delete_document(id) received the raw slug which never matched WHERE id = ?1.
| /// backfilled. This check runs after every `ensure_schema_version()` call so the | ||
| /// table is created and populated on next access. | ||
| fn ensure_documents_fts(&self) -> Result<(), Error> { | ||
| // Only relevant for schema v12+ databases. |
🔍 Cora AI Code Review❌ Blocked — critical issues found. 🔴 Error (2)
Review powered by cora-cli · BYOK · MIT |
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
Fixes #549 and #550 — two bugs in the document engine.
#549:
documents_ftstable missing — FTS5 search fails for document chunksRoot cause: Schema v12 migration creates the
documents_ftsFTS5 virtual table with best-effort execution (let _ = self.conn.execute(sql, []);). If the creation failed silently, the table is absent and existing documents are never backfilled. Everyuteke recall/uteke doc searchlogs a noisy warning.Fix: Add
ensure_documents_fts()consistency check (same pattern asensure_documents_has_children()from #500):ensure_schema_version()call (including on store open)documents_ftsexists viasqlite_masterensure_schema_consistency()foruteke repair#550:
uteke doc delete <SLUG>fails — only works with document IDRoot cause:
doc_delete()resolved the slug to an ID (main_id) for chunk cleanup, but passed the original slug todelete_document(id)which queriesWHERE id = ?1. Slug never matches a UUID.Fix: Resolve slug to
resolved_idFIRST, then use it consistently for descendants, chunk cleanup, and the actual delete.Test Results
cargo check: cleancargo fmt --check: cleancargo test: 284 passed, 4 pre-existing failures (dream tests — ONNX backend)schemaanddocumenttests: passedFiles Changed
crates/uteke-core/src/memory/schema.rs: +56 (ensure_documents_fts)crates/uteke-core/src/lib.rs: +17/-14 (doc_delete slug fix)Closes #549, Closes #550