Skip to content

fix: optimizer writes reindex into search; shared index helper; delete chokepoint - #97

Merged
WKJBryan merged 4 commits into
mainfrom
worktree-fix-optimizer-reindex
Jul 10, 2026
Merged

WKJBryan merged 4 commits into
mainfrom
worktree-fix-optimizer-reindex

Conversation

@WKJBryan

Copy link
Copy Markdown
Owner

Summary

Follow-up to Phase 2 (#95), closing its one flagged gap plus two sibling consolidations:

  • Optimizer-applied changes are searchable without restart — both worker write paths (sidecar overlay, full-rewrite) now trigger commit_note_index_refresh (search + chunk + topic hubs) after the worker releases its phase locks. Deliberately narrower than commit_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.
  • Shared services/index_commit.rs — the search-index commit core is now one function used by both the Tauri app (commit_note_write) and the grafyn-mcp binary (which previously hand-rolled the same sequence; compiles clean under --no-default-features --features mcp, no Tauri types leak).
  • commit_note_delete symmetry chokepoint — delete_note's removal sequence (search + chunks + link discovery + hubs + optimizer) consolidated next to commit_note_write, same rationale: five drifting copies is how the original reindex regression happened.

Test plan

  • 280/280 Rust tests (274 → +6), TDD RED/GREEN (staleness probes assert on the stored Tantivy doc, not the vault)
  • MCP feature-set build clean; zero new clippy lints (42 baseline)
  • Spec+quality review: Approved (loop analysis, feature-gating, lock ordering all independently verified)

🤖 Generated with Claude Code

WKJBryan and others added 4 commits July 10, 2026 12:46
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>
@WKJBryan
WKJBryan merged commit 1582675 into main Jul 10, 2026
10 checks passed
@WKJBryan
WKJBryan deleted the worktree-fix-optimizer-reindex branch July 10, 2026 05:39
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