Repository navigation
Description
Context & Rationale
No tool runs the review prompts through a model and measures the result. Every prompt edit ships on argument alone.
What exists, checked at ef21785:
devops ai prompt-evalreplays only the deterministic suppression layer against recorded verdicts. It never calls a model (src/devops_cli/ai/prompt_eval.py:1-16, 145-195).devops benchmark --suitecalls models, but not with the review prompts (src/devops_cli/ai/benchmark/suite.py:38-39, 581-600). It also treatsVERIFIEDas ground truth (suite.py:80-84).devops review corpus scoremeasures recall against injected defects. That ground truth does not come from the review loop. But it scores one session at a time:CorpusScoreholds onesession_id(src/devops_cli/ai/review/defects.py:1384-1410).score_corpustakes one session's findings (defects.py:1456-1494).--sessiontakes one value (src/devops_cli/commands/review.py:1568-1605).
devops review benchmarkreviews the same files k times with the response cache off (DEFAULT_REVIEW_BENCHMARK_RUNS = 3, src/devops_cli/config/defaults.py:391; commands/review.py:1365-1377). It keeps only medians of time, calls and tokens, not which defects each run found (src/devops_cli/ai/review/profile.py:335-421).- The run store compares one number per metric from each run:
compare_runs(src/devops_cli/ai/run_store.py:634-655) andcheck_regression(run_store.py:731-769). Nothing shows a difference against run-to-run variation. - A run's setup records models, page size and gateway pools (run_store.py:140-154). It records neither the prompts nor the temperature, so two runs with different prompts look like one setup.
- The setup can also name the wrong verification model.
- Reviews layer verification on the analysis task (src/devops_cli/ai/review/runner.py:1539-1556).
review_setuplayers it on the baseaisettings instead (run_store.py:146).- So when
ai.tasks.verificationis unset, which is the shipped default (docs/ROADMAP.md:354), the setup recordsai.modeland that group's pool for verification, not the analysis model that actually verified.
Prompt edits that shipped without measurement:
- v0.2.22 compressed the two hot-path review prompts from 4785 to 3244 tokens, a 32% cut (CHANGELOG.md:193, perf(ai): compress the two hot-path review prompts and scope their host rules #386). The only evidence that no decision was lost is a substring test (tests/test_personas.py:64-122).
- v0.2.24 changed
review.md,verify_finding_system.mdand the devsecops prompt the same way (CHANGELOG.md:83, fix(review): remediate session 20260928-160843 findings, harden feedback loops & calibration #682). - A live run traced the registry-mirror false positive to the verification prompt, not the model (docs/ROADMAP.md:354).
Ground truth:
-
VERIFIEDlabels come from the verifier under test. Two calibration sessions measured false-positive rates near 40% and 85% among high-severity findings (prompt_eval.py:7-12). So aVERIFIEDcount is a prior, not a label. -
The "122 human-verified records" this item first named are not a usable seed. Before v0.2.23, the exporter filed every finding that had no adjudicator as
human(fixed in ea49d6e; src/devops_cli/ai/review/exporter.py:60-63). -
On 2026-10-01 the local data hold no human verdicts:
- 0 of 2,237 findings in the 26 sessions under
.data/reviews; - 0 of 1,744 records in
.data/reviews/feedback_dataset.jsonl.
The "1066
VERIFIEDrecords" figure is also out of date: 633 records areVERIFIEDtoday. - 0 of 2,237 findings in the 26 sessions under
-
This item therefore uses the injected defects of a synthetic corpus as its ground truth. They measure regression on defect shapes the generator knows, not general review capability. The report keeps saying so (
SYNTHETIC_CAVEAT, defects.py:41-44). -
Agreement with human verdicts is split off (see Strategic Alignment), because the labels it needs do not exist yet.
Why repeated runs:
- Identical reviews produce different findings (commands/review.py:1365-1367).
- A judge can be consistent and still wrong. arXiv 2606.19544 reports test-retest reliability above 0.95 alongside position bias above 0.10 in two production judges.
- So one run per prompt says little. Each arm runs k times, and the difference between arms is shown next to the spread within each arm. One run has no spread, so it is never shown as one.
Scope & Deliverables
- Deliverable: Score k sessions of one corpus together (src/devops_cli/ai/review/defects.py).
CorpusScoregains three counts, all set inscore_corpus. Existing fields keep their values.candidate_findings: every finding the review raised before verification (thecandidatesargument).invalidated_findings: those findings with statusINVALIDATED.reported_findings: the findings verification kept (thereportedargument).
- A new
score_corpus_runscombines k per-sessionCorpusScores and each session'sReviewProfile(orNone) into aCorpusRunsScorewith these fields:- Per injection, keyed by its existing
id(file, line, template):found_inandreported_in, the number of sessions that found or reported it. - Found and reported totals, each with:
pass_at_k: the share of injections found in at least one session;pass_hat_k: the share found in every session;in_none: the number found in no session.
- One row per session:
- its
session_id; - recall found and recall reported;
- candidate, invalidated and reported findings;
- prompt tokens, completion tokens and unparsed persona replies (the profile's
persona_outcomescount forCONST_PERSONA_REPLY_UNPARSED), read fromprofile.json(0 when it is missing).
- its
- Top-level means of the per-session figures. They use the names the run store already extracts (
recall_found,recall_reported,prompt_tokens,completion_tokens), pluscandidate_findings,invalidated_findingsandreported_findings. Ratios round to 3 decimals and counts to 1. spread:[min, max]of each of those figures across the sessions. It isNonewhen k is 1, because one run measures no spread.scores: the full per-sessionCorpusScores.- Run details: the caveat,
runs(k) and the sessions' sharedprompt_digest.
- Per injection, keyed by its existing
- It uses only the standard library.
- Deliverable: Each review session records which prompts it ran.
review_prompt_digest()goes insrc/devops_cli/ai/personas/__init__.py.- It applies
run_store.digestto the relative path and text of every.mdfile underai/tasks/andai/personas/. - It takes the two directories as parameters, defaulting to the package's own.
- It applies
ReviewProfilegainsprompt_digest: str = "", set byReviewProfiler.build(profile.py:231-264).
- Deliverable:
devops review corpus scorescores one arm of k runs (commands/review.py:1494-1605).- Session selection.
--session/-sbecomes repeatable.- A new
--runs/-n N(minimum 1) takes the latest N sessions whose profile target is the corpus. This generalizes_corpus_session_dir(commands/review.py:1494-1509). With neither option, the command still scores the latest session, as it does today. The option defaults to unset rather than 1, so an explicit--runscan be refused next to--session.
- Refusals. Each of these exits 1:
--sessiongiven together with--runs;- fewer matching sessions than N. The message says how many exist.
- sessions whose
prompt_digestvalues differ. The message lists each session's digest, and no run is recorded. One score is one arm.
- Run record.
- The subject stays as it is today: the corpus digest.
- The setup is
review_setup(prompt_digest=..., runs=k, personas=...).personasis the sorted set of personas that replied in the scored sessions, read from each profile'spersona_replies. - The results are the
CorpusRunsScore.--jsonprints the same object.
- Text report.
- The totals.
- One row per session.
- One row per injection, with
found in x/k,reported in y/kand the finding titles that matched it in any session. - Per template: injections, found in any session, found in every session.
- The caveat line stays.
- Model pinning. When a gateway group in the setup's pools serves more than one distinct model, the report prints
not model-pinned: <group> serves <n> models. The run is still recorded. - Unchanged.
_scored_sessionand sample validation (commands/review.py:1703-1736) still score one session withscore_corpus.
- Session selection.
- Deliverable: The setup describes the review that ran, and arms are compared next to their spread (src/devops_cli/ai/run_store.py, src/devops_cli/commands/ai_runs.py).
review_setup(run_store.py:140-154) resolves verification the way reviews do:ai.for_task("analysis").for_task("verification")(runner.py:1539-1556). Withai.tasks.verificationunset, the setup then records the analysis model and pool for verification. This also changes the setups thatreview benchmarkand sample validation record (commands/review.py:1386, 1830).review_setupalso records each task'stemperatureandtop_p._extract_core_metrics(run_store.py:581-593) also extractscandidate_findings,invalidated_findingsandreported_findings.MetricDiff(run_store.py:601-608) gainsbase_rangeandcurrent_range, bothtuple[float, float] | None.compare_runsfills each from that record'sresults["spread"]when it is present.- When any metric has a range, the
devops ai runs comparetable (ai_runs.py:262-279) adds three columns: Base range, Current range and Spread.- Spread reads
overlapswhen the two ranges overlap andapartwhen they do not. - It reads
—when either run has no range, such as a one-run score.
- Spread reads
devops ai runs checkis unchanged and still compares means.
- Deliverable: Docs and records.
- Help text for
--runsand the repeatable--session(src/devops_cli/lang/en/help.py:884-885). - A regenerated docs/CLI_REFERENCE.md.
- A CHANGELOG entry. It says that run setups now record the analysis model for verification when verification is unset.
- The task file docs/agent/tasks/task-413-model-in-the-loop-prompt-benchmarking.md, rewritten to this scope in the delivering commit. It still says Backlog and v0.2.24.
- The roadmap entry (docs/ROADMAP.md:186-189), updated with the corrected figures. This applies only if
docs/ROADMAP.mdis still hand-edited when this item lands (feat(github): github-sourced roadmap, migration and generated roadmap view (devops roadmap migrate,render) #739).
- Help text for
- Acceptance criteria:
-
Scoring (unit test, tests/test_review_defects.py). The fixture has 4 injections and 3 sessions:
- session 1 finds injections 1-3 and reports 1;
- session 2 finds 1-2 and reports 1;
- session 3 finds 1 and reports none.
score_corpus_runsmust give:[(t.found_in, t.reported_in) for t in tallies] == [(3, 2), (2, 0), (1, 0), (0, 0)];- found
(pass_at_k, pass_hat_k, in_none) == (0.75, 0.25, 1); - reported
(pass_at_k, pass_hat_k, in_none) == (0.25, 0.0, 3); recall_found == 0.5with spread(0.25, 0.75);recall_reported == 0.167with spread(0.0, 0.25).
-
One session reproduces today's totals. Use the fixture of
test_score_matches_by_line_or_evidence_and_separates_what_verification_kept(tests/test_review_defects.py:282-318).score_corpus_runs([score], [None])must give:scores[0] == score;- found
pass_at_k == pass_hat_k == 1.0, which equalsscore.recall_found; - reported
pass_at_k == pass_hat_k == 0.75; (candidate_findings, invalidated_findings, reported_findings) == (6, 1, 5);spread is None.
-
CLI (tests/test_review_defects.py). Sessions are written with the
_sessionhelper (tests/test_review_defects.py:321-327), using profiles that carry token counts, one unparsed persona reply and one shared digest. Three sessions review the corpus and one reviews another target.corpus score <dir> --runs 3 --jsonexits 0, withruns == 3, one row per corpus session in oldest-firstsession_idorder, per-session tokens and unparsed replies taken from the profiles, andsetup["personas"]recorded.--runs 4exits 1.-s A -s Bscores exactly sessions A and B.-s A --runs 2exits 1.
-
Mixed arms. For two sessions with different
prompt_digestvalues,corpus score --runs 2exits 1, prints both digests and records no run. -
Existing tests. The two existing CLI tests (tests/test_review_defects.py:330-383) change only their JSON and results paths, to
scores[0].... No other existing test changes. -
Prompt digest (tests/test_review_profile.py):
review_prompt_digest()returns 16 hex characters and the same value on every call.- Over a temporary copy of the two directories, it returns a different value when one character of
tasks/review.mdchanges, and a different value again when one character ofpersonas/devsecops/prompt.mdchanges. - Adding a
.pyfile to either directory leaves the value unchanged. ReviewProfiler().build(...)carries the package's digest.
-
Setup (tests/test_run_store.py). With
gateway_poolpatched to return a fixed pool, and settings in which onlyai.tasks.analysisnames a gateway group and the baseai.modelnames another:review_setup()["models"]["verification"] == review_setup()["models"]["analysis"];poolsholds only the analysis group;- both tasks record the analysis task's
temperatureandtop_p.
-
Comparison (tests/test_run_comparison.py):
- Two
CORPUS_SCORErecords withspread.recall_foundof[0.25, 0.75]and[0.5, 1.0]give(base_range, current_range) == ((0.25, 0.75), (0.5, 1.0)), and thedevops ai runs comparetable marks that rowoverlaps. - With
[0.8, 1.0]as the current range, the row readsapart. - Records without
spread, including one-run scores, giveNoneranges. Compared with a record that has a range, the row reads—. - The existing tests in that file pass unmodified.
- Two
-
Pinning. With
review_setuppatched to return adevops-reviewpool servingqwen3-coder:30bandgpt-oss:20b, the text report containsnot model-pinned: devops-review serves 2 models. -
Gate.
- The new tests touch no network, cluster or model.
- Each new test runs in under 1 s. Check with
uv run pytest tests/test_review_defects.py tests/test_review_profile.py tests/test_run_store.py tests/test_run_comparison.py --durations=0. uv run devops cipasses.
-
Person-run check (needs a live model; never part of
devops ci).- Both arms must read one configuration file.
config.yamlis git-ignored (.gitignore:64), and the config lookup stops at a worktree's.git(src/devops_cli/config/settings.py:868-890). So a second worktree would otherwise run on the defaults, not the gateway. - Copy the main checkout's
config.yamlto a file outside both checkouts. In the copy, setai.tasks.analysis.modelandai.tasks.verification.modeltodevops-coder(one model: qwen3-coder:30b on ollama-48gib), both on the gateway provider. - Run from a checkout of the base commit:
export DEVOPS_CLI_CONFIG=<the copied file> # export it in arm B's worktree too uv run devops config get ai.tasks.analysis.model # devops-coder uv run devops config get ai.tasks.verification.model # devops-coder uv run devops review corpus generate src/devops_cli/core src/devops_cli/security src/devops_cli/crypto --seed 1 CORPUS=<the directory generate printed> uv run devops review benchmark "$CORPUS/files" --all --runs 3 uv run devops review corpus score "$CORPUS" --runs 3 # arm A; note its run ID uv run devops ai runs baseline set <A> uv run devops review benchmark "$CORPUS/files" --all --runs 3 uv run devops review corpus score "$CORPUS" --runs 3 # arm A again (A/A) uv run devops ai runs compare <A2> # setups identical- Then, in a separate worktree with the same
DEVOPS_CLI_CONFIG, edit one prompt and run the samebenchmarkandscorecommands to get arm B.uv run devops ai runs compare <B>listsprompt_digestas the only setup difference. - No
not model-pinnedline appears. - The PR description records the A/A ranges. They are the noise floor that later prompt changes are read against.
- Both arms must read one configuration file.
-
- Key questions:
- What is the ground truth? The synthetic corpus's injected defects (proposed).
- The review loop did not produce them.
- The verifier's
INVALIDATEDcount is reported as the verifier's opinion, not as truth. - No human verdicts exist locally, so agreement with people is split off.
- How is the prompt under test supplied? As a checkout (proposed).
- Prompts are package files:
personas/__init__.py:39-77, verification.py:51-52, runner.py:98-100 and classification.py:32-35. - So each arm runs from its own worktree, and the arm is identified by the prompt digest in each session's profile.
- An override flag would add a second way to load prompts, used only by benchmarks.
- Prompts are package files:
- What does the prompt digest cover? Every
.mdfile underai/tasks/andai/personas/(proposed).- It is a closed set with no file list to maintain.
- Including too much only makes an unrelated prompt edit look like a new arm.
- Prompt text built in code is covered by
RunRecord.commit.
- Where is k set? No new constant (proposed).
review benchmark --runsalready defaults toDEFAULT_REVIEW_BENCHMARK_RUNS = 3(defaults.py:391).corpus scorewithout--runsscores one session, so a plaincorpus scorebehaves as it does today.
- Pinned model and temperature? Hold both fixed across the arms and record them, without forcing temperature to 0 (proposed).
- Reviews run at the configured temperature. The default is 0.1 (defaults.py:70), but a local
config.yamlcan set another, so the setup records the value in use. - The k runs measure the spread that a nonzero temperature causes.
- Pin the model with a single-model gateway group such as
devops-coder(k8s/llm/gateway/configmap.yaml:44-47). devops-reviewserves qwen3-coder:30b and gpt-oss:20b (configmap.yaml:89-104), anddevops-chatserves two Qwen3.8 27B builds (configmap.yaml:15-42). So the report warns when a run is not pinned.- The person-run check holds model and temperature fixed for both arms through one shared config file.
- Reviews run at the configured temperature. The default is 0.1 (defaults.py:70), but a local
- How is the prompt difference read against the spread? Means and min-max ranges, marked
overlapsorapart(proposed).- With k = 3, a significance test would claim more than the data support.
- A one-run score has no range, so its comparison reads
—, neverapart.
- New command to run both arms? No (proposed).
- Arms are runs in the store.
devops ai runs baseline setnames the base arm, anddevops ai runs comparecompares the two.- A wrapper that creates worktrees and runs both arms can follow if the manual sequence proves error-prone.
- Use pydantic-evals? No; use the standard library (proposed).
- It is locked only as a transitive dependency of pydantic-ai (uv.lock:2417, 2480).
- Its
repeat=drives Python callables, while each arm here is a whole CLI review.
- JSON shape of
corpus score --json? One shape for every k (proposed).- The two existing CLI tests update their paths.
- Pre-1.0, there is no compatibility shim.
- Does state carry from one run to the next? Yes, in one place. Not changed in this item (proposed).
- Verification learns false-positive catalog entries from deterministic invalidations (src/devops_cli/ai/review/common_hallucinations.py:935-990) and applies learned entries to later findings (verification.py:1191-1210).
- So an earlier run can change a later run's verdicts.
- The A/A pair in the person-run check shows whether that moves the figures. If A2's ranges read
apartfrom A's, file a follow-up to run benchmarks undercatalog_learning_disabled()(common_hallucinations.py:183-189), the guard prompt-eval already uses (prompt_eval.py:141).
- Agreement with human verdicts (Cohen's kappa)? Split off; see Strategic Alignment.
- It compares recorded verdicts and needs labels that do not exist yet.
- It measures the verifier, not prompt arms.
- Order-swap probe? Split off; see Strategic Alignment.
- It reuses this item's arm comparison, with reversed verification order as arm B.
- Seeded dilution variants (the follow-on line at docs/ROADMAP.md:188)? Not in this item (proposed).
- A diluted prompt is just another arm.
- Counting
fix_llm_responserepairs needs a profile counter. File it when someone runs dilution arms.
- Do benchmark sessions inflate
devops review stats? Yes, but feat(review): subject-keyed review history with a leave-one-out baseline #607 owns session identity. - Priority and release? P1, in v0.2.25, as the owner retargeted it on 2026-10-01.
- What is the ground truth? The synthetic corpus's injected defects (proposed).
- Constraint: Ground truth must not come from the loop being measured.
- Recall comes from injections.
VERIFIEDandINVALIDATEDcounts are reported as the verifier's opinion, never as labels.- Every report carries the synthetic caveat.
- Constraint: Live-model runs stay on demand and never run inside
devops ci.- The new tests use temporary sessions and patched setups only. They touch no network, cluster or model, and each costs under 1 s.
- Tests use structural tuple assertions.
- Constraint: No new dependency, and no prompt-override path. Prompts load only from the package.
- Constraint: Cyclomatic complexity of 10 or less and nesting depth of 5 or less (AGENTS.md:13-17).
- Constraint: Out of scope:
- agreement with human verdicts (split off);
- the order-swap probe (split off);
- per-backend comparison (feat(review): per-model review quality baseline for the devops-review pool #475);
- rule pruning (feat(cli): generator-side rule pruning measured against verifier overlap #414);
- dilution variants;
- catalog learning during benchmarks (see the key question above);
benchmark --suite's use ofVERIFIEDas ground truth;- session identity in stats and export (feat(review): subject-keyed review history with a leave-one-out baseline #607).
Strategic Alignment
- Milestone: v0.2.25. The owner retargeted it from the shipped v0.2.23 on 2026-10-01: a P1 left open in a shipped release keeps precedence.
- Depends on: Nothing.
- Builds on this item:
- feat(review): per-model review quality baseline for the devops-review pool #475 (v0.2.25) scores each serving model as an arm with this report.
- feat(cli): generator-side rule pruning measured against verifier overlap #414 (backlog) measures each rule removal as an arm.
- Split-off feat(review): order-swap probe for verification verdicts #870 (order-swap probe for verification verdicts) adds reversed verification order as an arm.
- Split off: feat(review): verifier agreement with human verdicts as cohen's kappa #869 (verifier agreement with human verdicts as cohen's kappa).
- Related:
- feat(review): subject-keyed review history with a leave-one-out baseline #607 (v0.2.25): benchmark sessions are repeats of one target.
- feat(ai): finish reasons and stream completeness for model replies #599 (v0.2.25): truncated replies distort the counts.
- feat(ai): synthetic prompt adversaries for injection resistance #417 (backlog): adversarial prompts can reuse the arm comparison.
- fix(review): grep-only criteria neither verify nor invalidate a finding, and prompt examples stop teaching them #846 (backlog): it changes verification prompt examples, so it is a natural first arm to measure.
- test(security): pin the finding fingerprint and run-store digest to literal values #855 (backlog): it pins
run_store.digest, which the prompt digest reuses. - refactor(review): review session store that owns layout, fingerprints and verdicts #771 (backlog): it renames
candidates.json, whichcorpus scorereads throughCONST_REVIEW_CANDIDATES_FILENAME. - fix(test): the test network guard refuses loopback connects to services the test did not start #837: the new tests must pass under the loopback guard.
- fix(mcp): mcp tools and resources call commands and options that exist #836: no overlap, because
corpus scorehas no MCP tool.
- Split off (backlog): feat(review): verifier agreement with human verdicts as cohen's kappa #869 (verifier agreement with human verdicts as cohen's kappa); feat(review): order-swap probe for verification verdicts #870 (order-swap probe for verification verdicts).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
feat(review): let review verification use its own model task (#495)
feat(release): v0.2.23 (#681)
dan-petty commentedon Oct 1, 2026
Retargeted from the shipped v0.2.23 to v0.2.25. It is still valid (checked 2026-10-01), and a P1 left open in a shipped release keeps precedence over P1 work committed later.
feat(ai): model-in-the-loop prompt benchmarking (#413) (#939)
dan-petty commentedon Oct 2, 2026
Closed by #939, merged into
release/v0.2.25.GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by
devops gh issues close-merged.feat(release): v0.2.25 (#1089)