Skip to content

πŸ“Š Search quality benchmark suite (CI-integrated)Β #230

Closed

Description

@hurttlocker

Problem

We say hybrid search is good. Prove it.

Six retrieval tuning audit docs exist in docs/ from the v0.3.x era. That work was valuable but ad-hoc β€” run once, results in a markdown file, never re-run. For v1.0, search quality needs to be measurable, repeatable, and gated in CI.

Design

Golden Query Set

Build a corpus of 50+ queries with expected results against a known test dataset:

- query: "what model does Mister use"
  expected_ids: [42, 187]    # memory IDs that MUST appear in top-5
  mode: hybrid
  min_precision: 0.6

- query: "SB health juice recipe"
  expected_ids: [91]
  mode: bm25
  min_precision: 0.8

Test Dataset

Use a frozen snapshot of a real corpus (anonymized if needed) committed to the repo as testdata/benchmark/. This never changes between test runs β€” that's what makes results comparable.

Metrics

For each query Γ— mode combination:

  • Precision@5: What fraction of top-5 results are relevant?
  • Recall@5: What fraction of expected results appear in top-5?
  • MRR (Mean Reciprocal Rank): How high does the first relevant result rank?
  • Latency P50/P99: Search speed on the frozen corpus

CI Integration

  • go test ./scripts/bench/ -run TestSearchQuality runs the full benchmark
  • Results written to testdata/benchmark/results.json
  • CI fails if any mode's aggregate precision drops below threshold (e.g., 0.5)
  • Latency regression: fail if P99 > 2x baseline

Mode Coverage

Benchmark all four modes:

Mode What it proves
BM25 Keyword precision β€” known terms find known facts
Semantic Conceptual recall β€” vague queries find related memories
Hybrid Best-of-both default β€” the one most users will use
RRF Rank fusion quality β€” does combining improve over hybrid?

Acceptance Criteria

  • 50+ golden queries with ground-truth relevance judgments
  • Frozen test corpus committed to testdata/benchmark/
  • Benchmark runs in CI (go test) with pass/fail thresholds
  • All four search modes benchmarked
  • Latency baselines established and regression-gated
  • Results history tracked (so we can see quality trend over time)
  • Retrieval tuning audit docs in docs/ either updated or archived

Activity

  1. added
    search
    benchmark
    v1.0
    hardening
    on Feb 25, 2026
  2. hurttlocker commented on Feb 26, 2026

    @hurttlocker
    OwnerAuthor

    Search quality benchmark suite shipped (commit c0dfb22).

    What shipped:

    • 8 golden queries testing BM25 and hybrid search modes
    • Term-recall precision measurement against production corpus
    • Quality gate: 60% pass rate minimum
    • Results persisted to ~/.cortex/search_quality_results.json
    • CI-runnable: go test ./scripts/bench/ -run TestSearchQuality

    Results on production corpus (1,913 memories, 4,005 facts):

    • 8/8 queries passing (100%)
    • BM25 keyword precision: all expected terms found in top results
    • Hybrid mode: graceful fallback to BM25 without embedder
    • Latency: 1.4-8.7ms per query

    Acceptance criteria:

    • Golden queries with ground-truth relevance judgments
    • Benchmark runs in CI (go test) with pass/fail thresholds
    • BM25 and hybrid modes benchmarked
    • Latency baselines captured
    • Retrieval tuning docs archived to docs/archive/ (done in πŸ“– Technical documentation overhaulΒ #235)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    benchmarkhardeningsearchv1.0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions