feat: two-pass retrieval with sort order and graph expansion #5

Merged
m3taversal merged 1 commit from epimetheus/two-pass-retrieval into main 2026-03-30 11:32:33 +00:00
Owner

Summary

  • lib/search.py: Two-pass Qdrant retrieval (5 default, 10 max with expansion)
  • Sort order: similarity desc → challenged_by (1.5x weight) → graph-expanded
  • Schema normalization (direct + expanded results share superset schema)
  • Pass field (1|2) for consumer disambiguation
  • Graph expansion via YAML frontmatter edges + wiki links
  • Collision logging, disjoint overlap warning

Review

7 findings fixed per Ganymede code review. Full sign-off granted.

## Summary - lib/search.py: Two-pass Qdrant retrieval (5 default, 10 max with expansion) - Sort order: similarity desc → challenged_by (1.5x weight) → graph-expanded - Schema normalization (direct + expanded results share superset schema) - Pass field (1|2) for consumer disambiguation - Graph expansion via YAML frontmatter edges + wiki links - Collision logging, disjoint overlap warning ## Review 7 findings fixed per Ganymede code review. Full sign-off granted.
m3taversal added 1 commit 2026-03-30 11:04:18 +00:00
feat: two-pass retrieval with sort order and graph expansion
Some checks failed
CI / lint-and-test (pull_request) Has been cancelled
e17e6c25db
lib/search.py — shared search library:
- Pass 1 (default): top 5 from Qdrant, score >= 0.70, no expansion
- Pass 2 (expand=True): next 5 via offset=5, score >= 0.60, plus
  graph expansion from YAML frontmatter edges. Hard cap 10 total.
- Sort order: cosine desc → challenged_by → other graph-expanded
- result_type internal tag for stable sort (direct/challenge/graph)
- Module-level constants for easy threshold tuning post-calibration
- Structural file exclusion (_map.md, _overview.md)
- Within-vector dedup via _dedup_hits()

Caller updates:
- kb_retrieval.py: retrieve_vector_context() calls search(expand=True)
- diagnostics/app.py: search endpoint passes expand query param
- Argus imports from lib/search.py via sys.path (no longer owns search)

Tests: 5 new tests covering pass1-only, pass2 expansion, hard cap,
sort order, challenges-before-other-expansion.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
m3taversal merged commit ad48d7384e into main 2026-03-30 11:32:33 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: teleo/teleo-infrastructure#5
No description provided.