Sprint 3.39 retrieval eval: scores hybrid RRF search against a frozen, DB-anchored gold set. recall.rs is a pure precision@k/recall@k evaluator, baseline.rs a pure keyed-line ratchet (no DB, no embedder, both fully unit-tested); the gold set is checked-in fixture data. main.rs is the documented Gate-2 DB-shell: connects to the live index, runs the frozen gold queries, and enforces the ratchet.
| Tier | tools |
| Role | unclassified (baselined) |
| Path | crates/tools/retrieval-eval |
| Edition | 2021 |
| Targets | tools-retrieval-eval, tools_retrieval_eval |
| Public items | 11 across 3 modules |
| Tests | 34 |
What it is for
Sprint 3.39 retrieval eval: scores hybrid RRF search against a frozen, DB-anchored gold set. recall.rs is a pure precision@k/recall@k evaluator, baseline.rs a pure keyed-line ratchet (no DB, no embedder, both fully unit-tested); the gold set is checked-in fixture data. main.rs is the documented Gate-2 DB-shell: connects to the live index, runs the frozen gold queries, and enforces the ratchet.
Capabilities
baseline (other)
Pure baseline-ratchet logic (sprint 3.39 Phase 0 task 1, DB-shell binary
| Item |
|---|
fn flatten(report : & EvalReport, k : usize) -> BTreeMap <String, f64> |
fn render(map : & BTreeMap <String, f64>) -> String |
fn parse(text : & str) -> Result <BTreeMap <String, f64>, String> |
Regression
Pure baseline-ratchet logic (sprint 3.39 Phase 0 task 1, DB-shell binary
| Item |
|---|
pub enum Regression |
fn regressions(current : & BTreeMap <String, f64>, baseline : & BTreeMap <String, f64>,) -> Vec <Regression> |
gold_books_v1 (other)
Frozen, DB-anchored gold set — sprint 3.39 Class A (books, v1).
| Item |
|---|
fn cases() -> Vec <GoldCase> |
recall (other)
Pure retrieval-quality scorer (sprint 3.39 Phase 0 task 1). No DB, no
| Item |
|---|
fn score(gold : & GoldCase, retrieved : & HashMap <String, Vec <String>>, k : usize) -> EvalReport |
CaseResult
Pure retrieval-quality scorer (sprint 3.39 Phase 0 task 1). No DB, no
| Item |
|---|
pub struct CaseResult |
CorpusAggregate
Pure retrieval-quality scorer (sprint 3.39 Phase 0 task 1). No DB, no
| Item |
|---|
pub struct CorpusAggregate |
EvalReport
Pure retrieval-quality scorer (sprint 3.39 Phase 0 task 1). No DB, no
| Item |
|---|
pub struct EvalReport |
GoldCase
Pure retrieval-quality scorer (sprint 3.39 Phase 0 task 1). No DB, no
| Item |
|---|
pub struct GoldCase |
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
tools_retrieval_eval
baselinegold_books_v1recall
flowchart TD n_tools_retrieval_eval["tools_retrieval_eval"] n_tools_retrieval_eval --> n_baseline["baseline"] n_tools_retrieval_eval --> n_gold_books_v1["gold_books_v1"] n_tools_retrieval_eval --> n_recall["recall"]
Public surface
`baseline`
| Item | What it is |
|---|---|
fn flatten(report : & EvalReport, k : usize) -> BTreeMap <String, f64> | Flatten a report into the same key -> value shape the baseline file stores, at cutoff k |
fn render(map : & BTreeMap <String, f64>) -> String | Render a flattened map as the keyed-line baseline text, at RENDER_DECIMALS places. |
fn parse(text : & str) -> Result <BTreeMap <String, f64>, String> | Parse baseline text back into a key -> value map |
pub enum Regression | One baseline key that failed to hold. |
fn regressions(current : & BTreeMap <String, f64>, baseline : & BTreeMap <String, f64>,) -> Vec <Regression> | Every baseline key not held by current — new keys in current that aren't in baseline are growth, never a regression. |
`gold_books_v1`
| Item | What it is |
|---|---|
fn cases() -> Vec <GoldCase> | The 6 Class-A cases |
`recall`
| Item | What it is |
|---|---|
pub struct GoldCase | One labeled query -> gold-answer case |
pub struct CaseResult | Per-case score |
pub struct CorpusAggregate | — |
pub struct EvalReport | — |
fn score(gold : & GoldCase, retrieved : & HashMap <String, Vec <String>>, k : usize) -> EvalReport | Score every gold case against its retrieved (raw, rank-ordered, un-deduped, un-truncated) doc refs, keyed by case_id — not by query text, since two cases may share a query |
Re-exports. Exported here, defined elsewhere.
| Export | Defined in |
|---|---|
{score,CaseResult,CorpusAggregate,EvalReport,GoldCase} | recall::{score,CaseResult,CorpusAggregate,EvalReport,GoldCase} |
Boundary
Reaches into infrastructure.
Shares tier tools with 84 other crates: tools-advisory-reach, tools-archive-guard, tools-artifact-scaffold, tools-ask-ai-core, tools-ask-ais, tools-ask-gemini, tools-book, tools-book-report, … (84 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | tools |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/tools/retrieval-eval |
| Vocabulary in force (lexicon) | current |
Tier flow. Which tiers this crate's own edges cross.
flowchart LR n_tools["tools"] --> n_infrastructure["infrastructure"]
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `infrastructure-doc-ingest` | infrastructure | no | always |
| `infrastructure-knowledge-index` | infrastructure | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
clap | ^4 | derive | no | always |
sqlx | ^0.8 | runtime-tokio, postgres, chrono, uuid, json | no | always |
tokio | ^1 | full, macros, rt-multi-thread | no | always |
uuid | ^1 | v4, v7, serde, js | no | always |
Development, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `tools-cli-conformance` | tools | no | always |
Build. None.
Depended on by. Nothing in this workspace.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR SELF["tools-retrieval-eval"] SELF -->|development| n_tools_cli_conformance["tools-cli-conformance"] SELF -->|runtime| n_infrastructure_doc_ingest["infrastructure-doc-ingest"] SELF -->|runtime| n_infrastructure_knowledge_index["infrastructure-knowledge-index"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
| Feature | Enables | On by default |
|---|---|---|
ort | infrastructure-doc-ingest/ort | no |
flowchart LR n_ort["ort"] --> n_infrastructure_doc_ingest_ort["infrastructure-doc-ingest/ort"]
Targets
| Kind | Name | Source |
|---|---|---|
| bin | tools-retrieval-eval | `src/main.rs` |
| lib | tools_retrieval_eval | `src/lib.rs` |
Error model
No public error type was detected: no public item declares a type named *Error, and no public signature returns one.
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | yes |
| database access | yes |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | yes |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
| Variable | Read in |
|---|---|
DATABASE_URL | src/main.rs |
ORG_KNOWLEDGE_DB | src/main.rs |
Related capabilities
No workspace crate depends on this one.
Verification
| Kind | Count |
|---|---|
| Unit tests | 34 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
baseline | 5 | 0 | 0 |
gold_books_v1 | 1 | 0 | 0 |
recall | 5 | 0 | 0 |
What the tests establish, by name:
dropped_value_is_a_regression—src/baseline.rsexact_epsilon_boundary_is_not_a_regression—src/baseline.rsflatten_omits_recall_key_for_true_negative_case—src/baseline.rsimprovement_is_not_a_regression—src/baseline.rskey_vanishing_entirely_is_a_regression_not_silently_ignored—src/baseline.rsnew_key_not_in_baseline_is_growth_not_a_regression—src/baseline.rsno_regression_when_current_matches_baseline—src/baseline.rsparse_rejects_duplicate_key—src/baseline.rsparse_rejects_malformed_line—src/baseline.rsparse_rejects_non_numeric_value—src/baseline.rsparse_skips_comments_and_blank_lines—src/baseline.rsrender_precision_quantization_is_not_a_regression—src/baseline.rsrender_then_parse_round_trips—src/baseline.rstiny_float_noise_is_not_a_regression—src/baseline.rsall_source_refs_are_book_prefixed—src/gold_books_v1.rsapache_cases_share_the_same_three_row_gold_set—src/gold_books_v1.rscase_ids_are_unique—src/gold_books_v1.rsexactly_one_true_negative_case—src/gold_books_v1.rssix_cases_all_library_corpus—src/gold_books_v1.rscli_conforms—src/main.rscorpora_scored_independently—src/recall.rscorpus_means_are_the_real_average_not_the_sum_times_count—src/recall.rsdedupe_happens_before_k_truncation—src/recall.rsdedupe_preserves_first_occurrence_order—src/recall.rsduplicate_case_id_panics_in_debug—src/recall.rsempty_gold_slice_produces_empty_report_no_panic—src/recall.rsk_zero_scores_every_case_as_nothing_retrieved_no_panic—src/recall.rsmissing_case_in_retrieved_map_scores_as_nothing_retrieved—src/recall.rsper_case_results_survive_even_when_corpus_aggregate_looks_healthy—src/recall.rspositive_case_exact_match_scores_perfect—src/recall.rs- _… 4 more_
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 9 | 11 |
Public modules with a //! block | 3 | 3 |
pie showData
title Public items with rustdoc
"Documented" : 9
"No rustdoc detected" : 2
Metrics
| Metric | Value |
|---|---|
| Rust source files | 5 |
| Source lines | 1039 |
| Code lines | 815 |
| Public API items | 11 |
| Public modules | 3 |
| Tests | 34 |
| Examples | 0 |
| Cargo features | 1 |
| Direct runtime dependencies | 6 |
| Workspace reverse dependencies | 0 |
pie showData
title Public API by kind
"enum" : 1
"function" : 6
"struct" : 4
pie showData
title Rust source composition
"Code" : 815
"Blank or comment" : 224
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.