Corpus
Is the necessary authority actually inside the governed material?
A perfect ranker cannot recover a missing source.Corpus retrieval, citations, and evidence
Retrieval Intelligence turns an authorized corpus into an inspectable local evidence layer. It records the corpus, engine, query, source, line range, hash, score, budget, and limits—then keeps retrieval separate from truth.
Contest edition 1.0.0 · MIT License · Standard-library lexical engine + independent evidence review
Retrieval begins with a decision
The best passage is relevant to a question, a user, a decision, a time, a corpus boundary, and an evidence burden—not universally relevant in the abstract.
Is the necessary authority actually inside the governed material?
A perfect ranker cannot recover a missing source.Were source identity, path, line ranges, encoding, version, and sensitivity preserved correctly?
A broken index can make present evidence functionally absent.Did the recorded query and filters surface the passages that bear on this need?
Topical similarity is not enough when authority or contradiction is missing.Does the answer stay within what the supplied passages actually support?
A retrieved passage does not excuse unsupported prose.Build the local evidence layer
The standard-library engine uses SQLite FTS5 lexical retrieval. It reads supported text, skips symlinks and oversized or unsupported files, hashes sources, preserves chunk line ranges, updates changed files, and prunes deleted sources. It does not execute corpus content or contact a network.
python scripts/rag.py index --corpus <directory> --db <index.sqlite>
python scripts/rag.py search --db <index.sqlite> --query "<question>" --top-k 8 --json
python scripts/rag.py context --db <index.sqlite> --query "<question>" --top-k 8 --max-chars 12000 --output <context.md>
python scripts/rag.py inspect --db <index.sqlite> --json
Choose retrieval behavior from the job
Names, identifiers, quoted phrases, error text, filenames, and distinctive literal language.
Expand terminology and run several discriminating queries when the user’s language may differ from the corpus.
Seek dates, versions, authorities, exceptions, denial, supersession, and contradictory sources—not just support for the leading answer.
Assemble source-diverse decisive passages that can support the answer while keeping limitations adjacent.
A citation is a custody record
A citation proves retrieval custody. It does not prove that the document is true, current, benign, authoritative, or safe to execute.
Do not launder one signal into another
Term and phrase overlap. Strong for exact handles; vulnerable to vocabulary mismatch.
Approved embedding similarity with provider, model, corpus revision, and privacy boundary preserved.
Scope, format, time, sensitivity, canonical role, and explicit filtering.
Which source may settle this kind of claim within the declared decision.
Whether the source remains applicable now, not merely recently modified.
Protection against duplicate chunks crowding out another source or plausible counterevidence.
Evaluation preserves misses as work orders
Create cases from real retrieval journeys, not wording copied from the current ranker. A strong average never cancels a failed indispensable case involving authority, privacy, or a required canonical source.
Recall@kDid a relevant item appear by the requested cutoff?
MRRHow early did the first relevant item appear?
Citation validityDo coordinates and identity resolve to the cited material?
Budget adherenceCan the context fit the operational evidence budget?
Independent review
The sibling Retrieval Reviewer binds its judgment to the named corpus revision, index, engine, query set, result and context artifacts, cutoff, evaluation, and decision. Hidden sources and unrecorded checks do not count.
Fluent answer, wrong corpus.
“Semantic” claim, lexical evidence only.
Citation near the claim, not on it.
Stale chunk surviving refresh.
Duplicate chunks crowding another authority.
Prompt-injected document becoming Agent instruction.
Impressive recall measured on implementation-shaped cases.
A useful invocation
Use $retrieval-intelligence to answer this question from the authorized local corpus. First identify the decision, corpus boundary, source authority, freshness requirement, and acceptable omissions; choose locate, explore, reconcile, or ground behavior; preserve source paths, line ranges, hashes, index and query identity; seek plausible counter-sources; and return insufficient retrieval evidence rather than extending beyond what the passages support.
For consequential RAG claims, corpus migration, or release readiness, run $retrieval-reviewer in fresh context against the recorded artifacts.