Build a small corpus, two search legs, rank fusion, evidence packing and a failing release gate with reproducible checks.
Project: ship a permission-aware hybrid retrieval release gate
Define the corpus and questions
Create 83 passages from policy revisions, case notes and help articles. Give every passage an immutable ID, tenant, document revision, state and source location. Add two tenants, one revoked passage, duplicated wording in two revisions and one table-like exception. Write 47 judged questions across exact IDs, paraphrases, mixed intent, no-answer and conflicting-revision cases. Keep judgments outside the search implementation.
Implement a transparent baseline
Start with a simple token-based lexical ranker and a precomputed semantic ranking supplied as data. Both legs must filter tenant and active state before fusion. Use rank fusion with stable passage identity; show each leg's rank and the final order for a query. Add a bounded context packet and store included IDs. This project tests retrieval logic without requiring paid model calls.
Break it deliberately
Remove an access filter from one leg and demonstrate that the test fails before a private passage reaches fusion. Swap in a stale revision and verify rejection. Make a candidate absent from both lists and show that reranking cannot recover it. Generate one unsupported numeric claim and prove citation validation catches it. Each failure should name its query and passage IDs.
Gate the release
Compare baseline and candidate on answer-bearing recall at 12, first relevant rank, forbidden exposures, packet fact coverage and p95 local query latency. Write a release decision that refuses any exposure or exact-ID regression. Package corpus manifest, judgment set, executable checks, measured output and rollback target. A screenshot of a plausible answer is not completion evidence.
Worked contract
def release_gate(rows: list[dict]) -> dict[str, object]:
if not rows:
raise ValueError("judged queries required")
exposed = [row["query_id"] for row in rows if row["forbidden_seen"]]
missed = [row["query_id"] for row in rows
if row["exact_id_query"] and not row["answer_passage_found"]]
return {"promote": not (exposed or missed), "exposed": exposed,
"missed_exact_ids": missed}
checks = [{"query_id": "q-47", "forbidden_seen": False,
"exact_id_query": True, "answer_passage_found": True},
{"query_id": "q-63", "forbidden_seen": True,
"exact_id_query": False, "answer_passage_found": True}]
assert release_gate(checks) == {"promote": False, "exposed": ["q-63"],
"missed_exact_ids": []}Performance and operating cost
For Q judged rows the gate scans O(Q) time and uses O(Q) failure space. Building lexical rankings naively across N passages costs O(QN) token comparisons; production indexes avoid that scan. Keep this project small enough to inspect each failure, then scale only after the contracts are proved.
Common Mistakes
- Treating a high fused rank as permission to show a passage.
- Judging only answers and omitting candidate recall.
- Testing the same queries used to hand-tune every threshold without a held-out slice.
- Calling the project complete before deletion and rollback checks pass.
Validation drill
Deliver a repository folder with the 83-passage manifest, 47 questions, runnable gate, failure log and a one-page promotion decision. Revoke one passage after building the index and rerun all checks.
