Skip to content

feat(retrieval): vector-mode retrieve with brute-force cosine knn (T09) - #7

Merged
prateekchaplot merged 2 commits into
mainfrom
arch/caliper/t09
Nov 16, 2026
Merged

prateekchaplot merged 2 commits into
mainfrom
arch/caliper/t09

Conversation

@prateekchaplot

@prateekchaplot prateekchaplot commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Task T09 from docs/ARCHITECTURE.md §14 (retrieval core).

Stacked on #8 (T05) — merge #8 first; this PR then shrinks to its own 2 commits (the extra commits are T05's, shown only because they're not yet on main).

What's inside

  • retrieve(question, conn, cfg, *, embeddings=None) -> list[Passage] — vector mode, brute-force vec0 MATCH ... AND k = ? cosine KNN (no ANN), metadata via get_chunks, deterministic (ties broken by ascending chunk_id)
  • Passage frozen dataclass: the 6 §7.5 fields + defaulted stage="vector" (§9.3 requirement)
  • RetrievalError for hard failures only; fewer-rows / empty / missing index return fewer / [] — the caller refuses (§9.3, §11.5)
  • 12 new tests (fakes only, seeded tmp DB, oracle cosine-distance ordering, no network)

Verification: combined stack — uv run pytest — 166 passed (122 + 32 T05 + 12 T09); ruff check + ruff format --check + mypy strict clean.

Notes: ambiguity resolutions recorded in docs/TASKS.md Notes (KNN query lives in-module since db.py is T03-owned; no sentinel scores; vector_top_k is T10's hybrid candidate depth). Dependents: T10, T11, T18.

@prateekchaplot
prateekchaplot merged commit b8c1155 into main Nov 16, 2026
1 check passed
@prateekchaplot
prateekchaplot deleted the arch/caliper/t09 branch November 16, 2026 17:45
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