Skip to content

feat: fulltext ranking seam for replay (menhir#469) - #42

Merged
ctharvey merged 5 commits into
menhir/mainfrom
feat/fulltext-ranking-replay
Dec 2, 2026
Merged

ctharvey merged 5 commits into
menhir/mainfrom
feat/fulltext-ranking-replay

Conversation

@ctharvey

@ctharvey ctharvey commented Dec 1, 2026

Copy link
Copy Markdown

What

A FulltextRanking hook (ContextVar, graphiti_core/fulltext_ranking.py) for the BM25 lanes of search():

  • node_fulltext_search / edge_fulltext_search consult it. No hook bound: no change.
  • ranking() returns None: the search runs and observed() gets the ranked uuids.
  • ranking() returns uuids: the search does not run; items are read with get_by_uuids in the served order, and missing uuids go to unavailable().
  • The live search runs with the hook unbound, so a driver search_interface that delegates back to the same function (Menhir's does) records once.
  • Release 0.32.1.post5.

Why

BM25 scores use statistics over the whole fulltext index, not the searched group. Other groups' documents and deleted documents not yet merged away change near-tie rankings, so a Menhir replay into another database got different invalidation candidates and correlation pools (Archolith/menhir#469). The cosine lanes compare stored vectors only and are not hooked.

Evidence

  • tests/test_fulltext_ranking.py (added to the compatibility workflow).
  • End to end with Menhir against this branch: a 10-item capture build with every namespace in one Neo4j, replayed into a separate Neo4j: 123/123 episodes unchanged, 0 misses, 0 network calls, every namespace digest equal. The same setup without the seam replayed 1 namespace of 14.

Label: Menhir policy divergence

🤖 Generated with Claude Code

ctharvey and others added 5 commits December 1, 2026 16:58
node_fulltext_search and edge_fulltext_search consult a FulltextRanking hook
bound on a ContextVar. With no hook nothing changes. A hook can record the
ranked uuids the search returned, or serve uuids in place of the search: the
items are read by uuid and returned in the served order, and served uuids
missing from the graph are reported to the hook.

BM25 scores use statistics over the whole fulltext index, so other groups'
documents and unmerged deleted documents change near-tie rankings. Menhir's
replay into another database needs the source's ranking (getzep#469). The cosine
lanes compare stored vectors only and are not hooked.

Label: Menhir policy divergence

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Menhir's search interface runs the stock fulltext query by calling node_fulltext_search
again. The nested call consulted the hook too, so a capture recorded every
ranking twice while a replay served it once. The live search now runs with the
hook unbound; only the outermost call records or serves.

Label: Menhir policy divergence

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ctharvey
ctharvey merged commit a46a2ed into menhir/main Dec 2, 2026
3 checks passed
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