Commit Graph
1 Commits
Author SHA1 Message Date
Story Crater Bot ff28eac91f feat(M3.3): Implement mem query CLI command with reranking
Adds semantic search with vector recall + reranking + provenance walking:

Changes to crates/mem-cli/src/main.rs:
  - Add Query command variant with flags: --project, --levels, --k, --format, --explain
  - Add cmd_query handler: embed → recall → rerank → format output
  - Support both text and JSON output formats

Changes to crates/mem-cli/src/query_worker.rs:
  - Implement reranking in QueryWorker::query()
  - Recall 10×k candidates (capped at 50), rerank to top-k
  - Fall back to vector similarity if reranker fails
  - Handle reranker index mapping correctly (bare array format)

Changes to crates/mem-store/src/pgvector.rs:
  - Add pool() method for test access to connection pool

New file: tests/it_query.rs
  - 8 integration tests (6 ignored, require live DB + gateway):
    a1_known_answer: query returns correct L1 node first
    a2_provenance_resolves: every hit's parents exist in DB
    a3_default_excludes_l0: default output has no L0
    a4_levels_flag: --levels L0 returns evidence
    a5_rerank_reorders: pre/post rerank order differs
    a6_project_isolation: no cross-project hits
    a7_no_project_errors: bad project returns empty
    a8_l2_two_hop_provenance: L2→L1→L0 chain resolves
  - Seeded test DB fixture with L0/L1/L2 nodes

Pipeline:
  embed question → HNSW recall (10×k, cap 50) → rerank → top-k → render

Blocked on: M3.2 ( done), M2.1 ( done), M2.4 ( done)
2026-08-25 12:13:21 -07:00