Skip to content

feat: fail CI when the answers or the golden set change - #12

Merged
matheusPavaneli merged 2 commits into
mainfrom
feat/answer-gate
Sep 18, 2026
Merged

matheusPavaneli merged 2 commits into
mainfrom
feat/answer-gate

Conversation

@matheusPavaneli

Copy link
Copy Markdown
Owner

What

CI now fails when the answers change, as well as when retrieval does. The 30 recorded answers are committed as a fixture and replayed with no key, and the answer eval is compared with the published report question by question. Every report now records the golden set it was scored against, so an edited golden span is refused instead of passed. This is the last backend slice before the frontend (F7).

Why

After ADR 0010 the answer run replayed offline, but only on the machine holding the chat cache, and rageval.eval refused --answer with --baseline. A change to parsing, citation resolution or the answer metrics merged green. ADR 0008 also left a gap open: moving q01's golden span by 40 characters was caught by nothing.

Scope was chosen before building: the answer gate only. A correctness judge would need 30+ live calls on a rate-limited free tier and would publish a new number. Abstention would change the prompt and replace the published 0.533. Both are named in the README and ADR as not built.

How

  • Recorded answers are a committed fixture. evals/answers/26b03ce9a1c2c1d4-682ec1326b2f.jsonl holds 30 lines, 21 KB: the chain digest of each prompt and the result returned for it, sorted, LF-terminated. --record-answers PATH writes it, never by hand. --replay-answers PATH validates every line before writing any of them into the chat cache, where the keyless chat path from ADR 0010 serves them. Rejected: a release asset (the size doesn't justify one, and a reviewer can read this diff), and serving replies straight from the file, which would put a path production never uses under the gate.
  • What counts as drift for an answer. The model's text is fixed, so the gate compares what the pipeline derives from it. Per question: answer text, parse error, every citation's status and span, cited chunk sizes, citation hit, recall, provider. Plus the aggregates. Zero tolerance, both directions. A report from another corpus, k, retrieval config, prompt version, chat chain, golden set or question set is refused. A changed prompt misses the cache, so without a key it fails by refusal and never reaches a provider.
  • Golden-set digest. A sha256 of the parsed questions rather than the file bytes, because Git checks the file out with CRLF on Windows and LF on Ubuntu. Old reports still load but are no longer comparable.
  • chat_chain replaces chat_model in the answer report. chat_model named Gemini while Groq wrote 29 of the 30 answers.
  • Four baselines re-cut. Every number matches the old report field by field; only ran_at, the digest and chat_chain differ. The old reports stay committed.

Results

Planted one at a time, with no key:

Planted regression Gate Unit suite
resolver matches raw text, without collapsing whitespace fail: 24 questions; hit rate 0.533 → 0.200, resolved 0.981 → 0.288 fail
every resolved span one character longer fail: all 30 questions fail
passage header [1] → (1) in the prompt fail by refusal: no cached answer for this prompt… fail
citation_hit overlap < → <= pass: no question changes fail
q01's golden span shifted by 40 characters fail on all four gates: golden set differs pass

The last row is the ADR 0008 plant that nothing caught before; now only the gate catches it. The <= plant cannot fire on this data because no citation ends exactly where a golden span begins, the same situation as the overlap plant in ADR 0008.

Verification

From .workflow/RAG-11/evidence.md, with both keys blank and an empty cache filled only from the vector release asset and the answer fixture, as CI does:

  • uv run ruff check ., uv run ruff format --check ., uv run mypy: pass
  • uv run pytest: 283 passed
  • uv run pytest -m integration: pass (live provider tests skip without keys)
  • rageval.vectors import … --sha256 …: pass
  • BM25, dense, hybrid-bm25 and answer evals with --fail-on-change against the new baselines: no drift, each with 0 call(s) reached the network; the answer step printed loaded 30 recorded answers

Risk and rollback

No critical zones. Reverting removes the fixture, the four new baselines, the answer step and the golden-set check, and ci.yml points back at the old baselines, which were never modified. No schema change in Postgres, and no change to the golden set, the prompt or the cache layout.

Open questions

  • Changing the prompt, retrieval or a chat model now means recording again: a live run with keys and --record-answers, then a new fixture and answer baseline in the same PR. The README documents this.
  • Editing the golden set means re-cutting all four baselines. That is the intended cost of closing the gap.
  • The gate covers the pipeline around the model, not the model. Whether a live model still answers the same way, and whether an answer is correct, are not measured.

The answer eval could only replay on the machine holding the chat cache,
and it refused a baseline, so a change to parsing, citation resolution
or the answer metrics merged green. A golden span moved inside a chunk
changed no retrieval metric and was caught by nothing.

The 30 recorded answers are committed as a fixture, written by
--record-answers and loaded into the chat cache by --replay-answers, so
CI replays them with no key. --answer now accepts --baseline and
--fail-on-change and compares every question's answer, citations,
spans and hit, plus the aggregates. Every report records a digest of
the parsed golden set and comparison refuses a mismatch. The answer
report names the configured chat chain instead of failover's first
model. The four baselines are re-cut with identical numbers.
ADR 0011 covers the committed answer fixture, what counts as drift for
an answer, the golden-set digest, the re-cut baselines and five planted
regressions, and why the judge and abstention were left out. ADR 0008
points to it for the closed span gap; the README says what a green
check now covers and how to record answers again.
@matheusPavaneli
matheusPavaneli merged commit cd3cef2 into main Sep 18, 2026
3 checks passed
@matheusPavaneli
matheusPavaneli deleted the feat/answer-gate branch September 18, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant