Repository navigation
Closed
Labels
priority/p1-highPriority P1: high-impact work for the next planned milestonescope/aiAI review pipeline, personas, prompts, LLM client, or RAGscope/reviewMulti-persona code review engine, verification, and findingstype/featureType feature: a new function
Milestone
Description
Problem
- The model output has been worthless: 412 model calls and 3.41M prompt tokens per run produced 0/94 strictly valid VERIFIED rows [measured: loop].
- What the owner asked for instead: the model correlates, investigates and plans; it does not originate findings.
- Rule documentation exists offline at the installed version.
ruff rule --all --output-format jsongives 970 rules, 952 with an Example [measured: u-reference]. Pack and Semgrep metadata, andkube-linter checks list, are also available. - Gaps an unchecked explanation would leave open [c-fidelity]:
- free prose can repeat the outdated training-data advice the owner reported;
- an applied diff is not a correct diff;
- "related locations" can be a model-originated finding in disguise;
- doc quotes and version strings can be invented;
- model prose in findings.sarif would break "identical on every run".
Acceptance criteria
- Deterministic groups:
- (path, enclosing symbol) for regions;
- (manifest, object) for Kubernetes;
- (lockfile, purl) for advisories.
- One model job per group.
- Inputs: anchor regions ± N lines, symbol-graph neighbours, rule docs at the installed version, matching KB manuals (feat(ai): knowledge-base manuals state the tool, language and dependency versions they apply to, and reviews ground explanations in the manuals that match the reviewed project #1149), and environment facts (language floor and pin, tool versions).
- Each job records the keys it needed, the keys it received and the keys it dropped, with a reason (for example
budget). - Coverage = received ÷ needed.
- A test forces a budget overflow and checks that review.md names the dropped rule doc.
- Each job records the keys it needed, the keys it received and the keys it dropped, with a reason (for example
- The output schema:
- explanation and root cause;
- related items, each an admitted finding id or a provided neighbour, with a fixed relation (
caller,callee,same-symbol,same-rule); - plan steps citing finding ids;
- doc quotes (key + text);
- an optional suppression note (text only).
- It has no diff field and no field for state, severity, a finding's location or a new finding (schema test).
- G10 checks, with failures dropped and counted by reason:
- finding ids exist;
- related targets are admitted ids or provided neighbours;
- code quotes are byte-equal to the commit's lines;
- doc quotes are byte-equal to the provided reference text, and cited keys were provided;
- every package or version string exists in the locked inventory, the tools lock or the advisory's fixed versions;
- every fenced Python block gets no syntax error and no F or UP finding from
ruff check --target-version <floor>.
- From fix(review): the verifier sees masked windows around the cited lines, not the whole file and the linked-file skeletons #1017: every excerpt sent to a model (anchor regions ± N lines) passes through
mask_secretsfirst. A test with a fixture secret in an anchor region shows it masked in the job input. - Output location:
- Output goes to
analysis.jsonand a review.md "Model analysis" section labelled model-written. - findings.json and findings.sarif never contain it. A property test shows they are byte-identical with this stage on and off.
- Output goes to
- A suppression note is text only. A person writes any suppression, with its reason and expiry, into
.devops/review.tomlthrough a PR. - Dispatch goes through the existing pool, capped at the slots table (fix(ai): review calls through the gateway no longer stall for about 190 s on ollama, with the cause measured first #1069). Sampling is recorded (fix(ai): sampling settings reach the model or are refused, review sessions record them, and the reply cache key includes them #1070). The prompt lives in Markdown under
src/devops_cli/ai/. - (person-run) On the loop input:
- model calls ≤ groups;
- a person rates 10 explanations, with 0 statements contradicting the floor or the locks;
- the rejection rate is recorded.
- Tests run offline with fakes and recorded tool output: no network, no real scanner, no model; each test under 1 s.
-
changelog.d/<n>.mdrecords the change;CHANGELOG.mdanddocs/ROADMAP.mdare not edited. -
uv run devops cipasses.
Key questions
- Why no diffs here? (proposed) An applied diff is not a validated one. P4-1 brings diffs only once tools and tests confirm them, which avoids building a second, partial validator.
- Can the model ask for more context? (proposed) Not in P1b. Fixed inputs keep prompts reproducible. A recorded, read-only lookup loop is considered once the rejection rate is known.
- Sampling? (proposed) The model card's values with a fixed seed, recorded.
- Prompt injection (feat(ai): synthetic prompt adversaries for injection resistance #417)? (proposed) The worst outcome is labelled prose that the checks above bound.
Strategic alignment
- Milestone: none; the roadmap tooling places it. Depends on: feat(review): every reported finding is admitted with its producer's anchor and a location that exists in the reviewed commit, the review writes findings.sarif, and review.md shows findings and suppressions #871, fix(ai): review calls through the gateway no longer stall for about 190 s on ollama, with the cause measured first #1069, fix(ai): the spend ledger records every attempt the gateway failed, including the retry transport's, and its gap to the gateway's count is measured first #1019. Related: feat(ai): synthetic prompt adversaries for injection resistance #417, fix(ai): sampling settings reach the model or are refused, review sessions record them, and the reply cache key includes them #1070 (sampling; kept whole), feat(ai): gpt-oss reasoning effort for group analysis is measured and set on its gateway deployments #479 (frozen; its per-deployment
reasoning_effortandmax_tokensmove to fix(ai): reasoning request parameters follow the model's declared capability, not its name #888/fix(ai): sampling settings reach the model or are refused, review sessions record them, and the reply cache key includes them #1070 before it closes), fix(review): the verifier sees masked windows around the cited lines, not the whole file and the linked-file skeletons #1017 (frozen; its masking moved here). - Parent: feat(review): evidence-first code review — tools find, version-pinned facts ground, models explain and plan, fixes are re-checked #1137 (phase P1b).
- Evidence tags ([measured: …], [code: path:line], [sourced: …], [estimate], [inference]; "S11" is the single review run of 2026-10-03 and "the loop" the ten runs S12–S21; c-feasibility and c-fidelity are the two design critiques) are explained in feat(review): evidence-first code review — tools find, version-pinned facts ground, models explain and plan, fixes are re-checked #1137.
Proposed design
Problem statement
The current model-generated review process produces worthless outputs with no validation, leading to a high rate of false positives and unverifiable findings. The system needs to shift from model-generated findings to tool-generated findings with model-written explanations and plans grounded in rule documentation.
Acceptance criteria
- Criterion 1: Each finding group gets a deterministic model job that correlates, investigates, and plans without originating findings
Verification: Model jobs are run per group with (path, enclosing symbol), (manifest, object), or (lockfile, purl) deterministically, with one model call per group - Criterion 2: Model output schema includes explanation, root cause, related items, plan steps, doc quotes, and suppression notes without diff field
Verification: Output schema test validates that the generated JSON matches the defined schema with required fields and no diff or finding-related fields - Criterion 3: All model outputs are checked for accuracy including code quotes, doc quotes, version strings, and package names
Verification: G10 checks validate that all code quotes are byte-equal to commit lines, doc quotes match provided references, versions exist in locked inventory, and fenced Python blocks pass syntax check - Criterion 4: Model inputs include anchor regions with N lines, symbol graph neighbors, rule docs at installed version, and environment facts
Verification: Test forces budget overflow and verifies that review.md names dropped rule docs, checking coverage = received ÷ needed - Criterion 5: Excerpts sent to model are masked for secrets using mask_secrets function
Verification: Test with fixture secret in anchor region shows it masked in job input - Criterion 6: Output goes to analysis.json and review.md "Model analysis" section, findings.json and findings.sarif never contain model-written explanations
Verification: Property test shows findings.json and findings.sarif are byte-identical with this stage on and off
Key questions
- Why no diffs here?: An applied diff is not a validated one. P4-1 brings diffs only once tools and tests confirm them, which avoids building a second, partial validator. [sources: src/devops_cli/ai/review/runner.py]
- Can the model ask for more context?: Not in P1b. Fixed inputs keep prompts reproducible. A recorded, read-only lookup loop is considered once the rejection rate is known. [sources: src/devops_cli/ai/review/runner.py]
- Sampling?: The model card's values with a fixed seed, recorded. [sources: src/devops_cli/ai/review/runner.py]
- Prompt injection (feat(ai): synthetic prompt adversaries for injection resistance #417)?: The worst outcome is labelled prose that the checks above bound. [sources: src/devops_cli/ai/review/runner.py]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
Metadata
Metadata
Assignees
Labels
priority/p1-highPriority P1: high-impact work for the next planned milestonescope/aiAI review pipeline, personas, prompts, LLM client, or RAGscope/reviewMulti-persona code review engine, verification, and findingstype/featureType feature: a new function
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 9, 2026
Folded in from the #1138 re-scope (2026-10-09)
The reference-coverage tolerance in
ai runs checkmoves here from #1138 (also listed in #1137's P2 scope): nothing records reference coverage (received ÷ needed per job) until this item does, so #1138 has no metric to check.dan-petty commentedon Oct 11, 2026
Status set to Ready at 6e862cd (see proposed design in issue body).
feat(review): grounded per-group model analysis and plan verified wit…
feat(release): v0.2.36 (#1615)