mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
6ac28aeee9
Deferred relation resolution in `sync_service.resolve_forward_references` and `BatchIndexer._resolve_batch_relations` called `LinkResolver.resolve_link(to_name)` with the default `strict=False`. When the link text didn't match any entity's permalink, title, or file_path, the resolver fell through to BM25/ts_rank fuzzy search and silently picked `results[0]` — even for ambiguous links that share only incidental tokens with the wrong entity. Producers commonly emit disambiguator-style wikilinks like `[[overview (state-management/session-execution)]]`. basic-memory does not parse `(qualifier)` as a disambiguator, so no entity matches exactly. The previous behavior resolved such links to whichever unrelated note shared the most tokens, polluting the graph with confidently-wrong edges that `basic-memory status` / `doctor` do not catch. Entity-creation already passes `strict=True` (see `entity_service.update_entity_relations` at line 1030). The deferred sync and batch-indexer paths must use the same contract so unresolved relations stay unresolved (`to_id=NULL`) and surface to the producer instead of getting silently filled with a wrong target. Adds two regression tests that spy on `resolve_link` and assert `strict=True` is passed by both deferred paths. Verified failing on the previous code and passing after. Reported in basic-memory-bug-report Issue 2. Signed-off-by: Dennis Hempel <uhg.dennnis@gmail.com>