Repository navigation
fix: optimizer writes reindex into search; shared index helper; delete chokepoint - #97
Merged
Merged
Conversation
The vault optimizer's two write paths (sidecar_first overlay write in prepare_next; full_rewrite update_note in apply_pending) change tags, aliases, and properties that are visible via KnowledgeStore::get_note (overlay merge) but were never pushed into the search index, chunk index, or topic hubs. The change was invisible to search_notes until the next full rebuild_all_indexes (i.e. an app restart). prepare_next/apply_pending now return an OptimizerTick/Option<String> reporting which note (if any) was actually written, and the worker calls the new commands::commit_note_index_refresh after releasing its locks. That helper deliberately does not route through the full commit_note_write chokepoint (which would re-enqueue the note the optimizer just dequeued) — see its doc comment for the full analysis of why that loop is self-correcting and free but still worth avoiding. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Extracts the search index_note+commit / remove_note+commit sequence (with the readonly no-op check the MCP binary needs when it can't grab the Tantivy writer lock) into services/index_commit.rs, callable from both the Tauri app (commands/mod.rs) and the standalone MCP binary (mcp_tools.rs) since they share the services/ module tree verbatim. Chunk indexing is deliberately NOT part of this shared helper: the MCP binary's note write tools never wrote to the chunk index before this change, and folding it in would change MCP behavior beyond routing through the helper, which was out of scope. Verified compiling and passing tests under both feature sets (default tauri-app and --no-default-features --features mcp). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Extracts commands/notes.rs::delete_note's hand-rolled removal sequence (search remove+commit, chunk removal, link-discovery removal, topic-hub sync, optimizer enqueue) into commit_note_delete in commands/mod.rs, next to commit_note_write, as the symmetric "note removed" counterpart to the existing "note created/edited" chokepoint. delete_note now just deletes from the vault and calls the chokepoint. Adds regression coverage: deleting a note removes it from search results immediately, without a manual reindex. Co-Authored-By: Claude Fable 5 <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
Follow-up to Phase 2 (#95), closing its one flagged gap plus two sibling consolidations:
commit_note_index_refresh(search + chunk + topic hubs) after the worker releases its phase locks. Deliberately narrower thancommit_note_write: review verified the full-chokepoint alternative's re-enqueue loop is bounded and budget-free, but the narrow helper avoids the wasted cycle entirely. Lock canon (knowledge_store → vault_optimizer) verified held throughout.services/index_commit.rs— the search-index commit core is now one function used by both the Tauri app (commit_note_write) and thegrafyn-mcpbinary (which previously hand-rolled the same sequence; compiles clean under--no-default-features --features mcp, no Tauri types leak).commit_note_deletesymmetry chokepoint —delete_note's removal sequence (search + chunks + link discovery + hubs + optimizer) consolidated next tocommit_note_write, same rationale: five drifting copies is how the original reindex regression happened.Test plan
🤖 Generated with Claude Code