Repository navigation
Description
Summary
In the #1002 event-index architecture, files indexed by the local file watcher (direct on-disk writes from Obsidian, an editor, git pull, cloud sync landing files, etc.) are indexed for full-text search and relations but are not vector-embedded. As a result, externally-edited notes are silently missing from semantic/vector search until a manual bm reindex --embeddings. This happens in the normal flow with the watcher running (env: user/dev), so it is not a test-only or doc-only issue.
Reproduction (env=user, watcher active, semantic_search_enabled=true)
Create notes two ways in the same project, then inspect search_vector_chunks:
| entity | created via | vector chunks |
|---|---|---|
| Tide Charts | write_note (MCP) |
5 |
| MCP Source Forward Ref | write_note (MCP) |
3 |
| MCP Forward Target QQQ | write_note (MCP) |
1 |
| Watcher Auto Index Probe | file written directly to disk | 0 |
| Source With Forward Ref | file written directly to disk | 0 |
| Watcher Forward Target ZZZ | file written directly to disk | 0 |
The watcher correctly indexes the on-disk notes (they appear in FTS search and their relations resolve — logs show index_markdown_file + Local event-index relation repair completed), but no embeddings are produced. Semantic search then silently omits them:
search_notes(query="probe note created on disk by the file change monitor", search_type="semantic", min_similarity=0)
# returns other (embedded) notes; the on-disk "Watcher Auto Index Probe" is absent
A bm reindex --embeddings (ideally --full) embeds them and they become semantically searchable.
Root cause
The local watch/inline event runtime plumbs an index_embeddings: bool = True flag (src/basic_memory/index/local_runtime.py:221,283; src/basic_memory/index/inline_operations.py:65,82) into an IndexFileEmbeddingJobContext, but nothing executes that embedding locally. Vector embedding is only actually run by:
- the MCP/API write path (
src/basic_memory/api/v2/routers/knowledge_router.py— entity vector sync on write), and - the reindex/project-index path (
src/basic_memory/indexing/embedding_index_planning.py,project_index_runtime.py).
The watch inline path (LocalInlineStorageEventResultRecorder.index_file_completed) runs relation repair (resolve_project_relations) but never calls sync_entity_vectors[_batch]. Cloud consumes the embedding job context via PGQ; local has no inline embedding execution on the watch path.
A revealing symmetry (please cross-link #1015)
The two post-index follow-ups are each wired to only one ingress path:
| Ingress | Vector embedding | Relation back-resolution |
|---|---|---|
MCP write_note (API) |
yes | no (#1015) |
| Watcher / direct-disk write | no (this issue) | yes |
So write_note embeds but doesn't back-resolve inbound dangling [[wikilinks]]; the watcher back-resolves but doesn't embed. Neither path runs both. This strongly suggests a single fix: both ingress paths should run the same set of post-index follow-ups (relation resolution + vector embedding) when enabled.
Suggested fix
In the local watch inline path, when index_embeddings is true and semantic search is enabled, run the same embedding follow-up the API/reindex paths use (sync_entity_vectors_batch for the affected entity ids) after index_file_completed. Pair it with the #1015 fix so the MCP and watcher ingress paths converge on identical follow-up behavior.
Impact
- Obsidian / external-editor /
git pull/ cloud-sync users: their notes are FTS-searchable and relation-linked but silently absent from semantic search until a manual reindex. - The failure is silent — semantic search just returns fewer/no results, with no signal that content isn't embedded yet.
Environment
- branch
codex/repository-explicit-sessions(v0.22.1), SQLite, local runtime env: user(file watcher + background schedulers active),semantic_search_enabled: true, fastembedbge-small-en-v1.5- Found during refactor(core): add shared runtime orchestration #1002 local-runtime regression testing.
Activity
claude commentedon Jun 23, 2026
Claude finished @phernandez's task in 5m 38s —— View job • Create PR ➔
Issue Triage & Analysis
Classification: Bug | Priority: High | Component: sync | Complexity: Medium
Root cause verified in
src/basic_memory/sync/sync_service.py:sync_file():The watcher path (
WatchService.handle_changes()) callssync_service.sync_file()for every file change.sync_file()callssearch_service.index_entity()— which only updates FTS rows — but never callssearch_service.sync_entity_vectors(). Vector embeddings are only generated by:SyncService.sync()(bulk sync) → callssync_entity_vectors_batch()at line 400knowledge_router.py(MCPwrite_noteAPI) → callssync_entity_vectors_batch()inlineThe watcher calls neither, so externally-edited notes are permanently missing from semantic search until a manual
bm reindex --embeddings.Fix implemented
src/basic_memory/sync/sync_service.py— addedsync_entity_vectors()call insync_file()after FTS indexing, guarded bysemantic_search_enabled:tests/sync/test_sync_service.py— added 3 regression tests:test_sync_file_calls_sync_entity_vectors_when_semantic_search_enabled— verifiessync_entity_vectorsis called in the watcher pathtest_sync_file_skips_sync_entity_vectors_when_semantic_search_disabled— verifies it is NOT called when disabledtest_sync_file_handles_sync_entity_vectors_semantic_error— verifiesSemanticDependenciesMissingErrordoesn't fail syncbuglabelsync_service.py)Commit:
fa0bf28on branchclaude/issue-1016-20260623-2221fix(core): run relation resolution and embedding on both note ingress…
hegu-1 commentedon Jul 1, 2026
This is an important bug for local-first personal memory setups because it breaks the contract between the authored vault and generated recall views.
If a user edits notes through Obsidian, an editor,
git pull, or file sync, those markdown files are still the source of truth. Semantic search is a generated view over that source. When the watcher indexes FTS/relations but skips embeddings, the system ends up in a subtle split-brain state:For a personal memory vault, that is more dangerous than a loud failure. The user thinks the vault contains the memory, but an agent using semantic search may behave as if it does not exist.
The invariant I’d want is:
So
write_note, direct file watcher writes, git sync, and external editor saves should converge on the same pipeline:It may also be useful to expose an index freshness signal per note or project:
Then agents can avoid treating missing semantic results as absence of knowledge.
I’ve been exploring this from a Personal AI OS / Memory Vault angle: authored markdown should remain the durable source of truth, while FTS/vector/graph indexes are rebuildable generated views. The key is making drift between source and recall views visible, not silent.
Related public projects:
phernandez commentedon Jul 15, 2026
Fixed on main via the #1002 runtime rewrite. The watcher/inline ingress path now runs the same post-index follow-ups as the API write path —
LocalInlineStorageEventResultRecorder.index_file_completed()callssync_entity_vectors_batch()after FTS and relation indexing, gated onsemantic_search_enabled(index/local_runtime.py, wired inindex/watch_service.py). Externally edited notes (Obsidian, git pull, file sync) are embedded inline instead of waiting for a manual reindex.Covered by
tests/index/test_local_inline_result_recorder.pyand an end-to-end fastembed watcher test (tests/index/test_local_watch_semantic_embedding.py). The per-note index-freshness signal suggested in the thread is a good follow-up for a separate issue. Closing.