Skip to content

fix: forward source_ids/tags scope in AutoHypergraph.search - #90

Merged
yifanfeng97 merged 2 commits into
yifanfeng97:mainfrom
dex0shubham:fix/hypergraph-search-scope
Sep 6, 2026
Merged

fix: forward source_ids/tags scope in AutoHypergraph.search#90
yifanfeng97 merged 2 commits into
yifanfeng97:mainfrom
dex0shubham:fix/hypergraph-search-scope

Conversation

@dex0shubham

Copy link
Copy Markdown
Contributor

Problem

AutoHypergraph.search() declares source_ids / tags scope parameters (for he search --source/--tag), but when it fans out to the per-type helpers it passes only top_k:

nodes = self.search_nodes(query, top_k=top_k_nodes)   # source_ids/tags dropped
edges = self.search_edges(query, top_k=top_k_edges)   # source_ids/tags dropped

search_nodes/search_edges both accept and forward source_ids/tags, so the scope machinery works — the top-level search() just never hands it down. As a result a scoped hypergraph search silently returns unscoped results (no error). The sibling AutoGraph.search() forwards the scope correctly; hypergraph is the copy that lost it.

Fix

Forward source_ids=source_ids, tags=tags to both search_nodes and search_edges, matching AutoGraph.search().

Tests

tests/types/test_hypergraph_search_scope.py: spies on the helpers and asserts search(query, source_ids=[...], tags=[...]) forwards the scope to both. Fails on the pre-fix code.

ruff check/ruff format --check on hyperextract clean.

@yifanfeng97

Copy link
Copy Markdown
Owner

Merged — thanks for the catch! 🎯

Confirmed: AutoHypergraph.search accepted source_ids/tags in its signature but dropped them when calling search_nodes/search_edges, so scoped search (he search --source/--tag) silently returned out-of-scope results on hypergraph KAs. Verified locally that the fix forwards the scope and that the new regression test covers it.

This will ship in the next release.

@yifanfeng97
yifanfeng97 merged commit 5c02a19 into yifanfeng97:main Sep 6, 2026
4 checks passed
yifanfeng97 added a commit that referenced this pull request Sep 6, 2026
Sweeping for the #90 pattern (scope accepted but silently dropped) found
three more gaps:

- AutoSet: track_sources was enabled on its memory but feed never
  recorded sources, so the ledger stayed empty forever — scoped search
  returned nothing, he tag / he feed change detection crashed with
  AttributeError, and the ledger was never persisted. AutoSet now
  records + persists its ledger (sources_items.json), supports
  document-level upsert, remove_source, tags, and scoped search.
- Graph_RAG.search / Cog_RAG.search: overrides did not accept
  source_ids/tags, so he search --source/--tag on those KAs raised a
  raw TypeError. Both now accept and forward scope.
- he search: scope flags on KA types without a ledger (AutoList/
  AutoModel) now fail with a clear message instead of a TypeError.

Tests: set provenance suite (recording, scoping, tags, upsert,
persistence) + scope-forwarding coverage for both method overrides.
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.

2 participants