Skip to content

fix(search): default-group searches stay in the default group - #38

Merged
ctharvey merged 2 commits into
menhir/mainfrom
fix/default-group-search-scope
Nov 26, 2026
Merged

ctharvey merged 2 commits into
menhir/mainfrom
fix/default-group-search-scope

Conversation

@ctharvey

Copy link
Copy Markdown

search() turned group_ids=[''] into None, so a search scoped to the default group searched every group. resolve_extracted_edges scopes its duplicate and invalidation candidate searches to [edge.group_id], and nothing filters the candidates by group afterwards. A default-group edge (Menhir's default namespace) was therefore compared against, and could expire, edges in other groups. Upstream has the same line.

Change

  • search/search.py: [''] stays a scope. An empty list still means no group filter.
  • search_utils.fulltext_query, _build_neo4j_fulltext_query, _build_relate_fulltext_query: Lucene drops an empty group_id:"" clause (checked on Neo4j 5.26: group_id:"" AND (Redis) matches every group, and group_id:"" OR group_id:"other" AND (Redis) matches only other). A list holding '' gets no Lucene group clause; every caller's Cypher group_id IN $group_ids filter scopes it.
  • Not changed: FalkorDB, which keeps one graph per group.

Effect on Menhir

  • An omitted namespace still reaches Graphiti as None and searches every silo.
  • namespace="default", and clients pinned to it, now search the default silo only, as namespace_to_group_ids documents.
  • Edges with a null group_id match no group list. Production holds 8,976 such RELATES_TO edges, so default-scoped searches and default-group invalidation no longer reach them. They did only because of this bug.

Tests

  • tests/utils/search/test_default_group_scope.py: 8 tests, 4 of which fail before the fix. Added to the compatibility workflow.
  • tests/test_default_group_search_scope_int.py (disposable Neo4j, GRAPHITI_SAVE_TEST_NEO4J_URI): the same fact stored in '' and in another group. A [''] search returned both edges before the fix and returns only the default edge after it.
  • Local runs: focused search, maintenance, driver, ingestion and invalidation suites, 662 passed. Ruff and pyright are clean.

Fork-Label: upstream bug fix

🤖 Generated with Claude Code

https://claude.ai/code/session_01XS5vAATR9fFfT6MHbTpMap

ctharvey and others added 2 commits November 26, 2026 00:19
search() turned group_ids=[''] into None, so a search scoped to the
default group searched every group. resolve_extracted_edges scopes its
duplicate and invalidation candidate searches to [edge.group_id], so a
default-group edge (Menhir's default namespace) was compared against,
and could expire, edges in other groups. [''] now stays a scope; an
empty list still means no filter.

Lucene drops an empty group_id:"" clause, so the Neo4j and Relate
fulltext builders omit the group clause when '' is in the list and the
Cypher group_id IN $group_ids filter scopes it (before, ['', 'x']
narrowed to 'x').

Fork-Label: upstream bug fix

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XS5vAATR9fFfT6MHbTpMap
The fork-contracts job installs no optional drivers, so importing the
Relate search ops at module level failed collection.

Fork-Label: upstream bug fix

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XS5vAATR9fFfT6MHbTpMap
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