Repository navigation
Description
Problem
The verifier is meant to see the lines each finding cites. _build_validation_prompt (src/devops_cli/ai/review/verification.py:277-340) asks _extract_finding_excerpt (:233-240) for each finding's lines. _extract_location_context (:111-135) finds them under a ### File: <path> header and its code fence (_file_header_indexes, :86-98). When no finding gets an excerpt, the prompt falls back to every segment it was given (:290-294).
The pipeline never gives it a header. _verify_single_file_payload builds its one segment as number_source_lines(file_code) plus the linked-file snippets (src/devops_cli/ai/review/pipeline.py:2669), with no header and no fence. So every excerpt is empty, and every verifier call gets the whole numbered file and up to 10 linked-file skeletons. At 38517a8, with the numbered src/devops_cli/ai/harness/workflow.py from session 20261002-180320 (535 lines) and one finding at line 300, _extract_location_context returns '' and the prompt holds all 535 lines (24,028 characters). With the same source under a ### File: header and fence, it holds lines 288 to 312 (2,621 characters). The helper only works where it gets headed pages: the legacy segment engine (src/devops_cli/ai/review/runner.py:1014-1020, reached only when the analysis client is not an LLMClient, :2240) and tests/test_review_page_line_numbers.py:171-194. No test covers the pipeline's call.
Turning the excerpt path on as it is would leak secrets. The fallback masks the code (mask_secrets, verification.py:294). _extract_finding_excerpt only strips boundary tags, and the pipeline reads the source raw (pipeline.py:2656-2660). With a fake ghp_ token on the cited line, the whole-file prompt holds no token, and the headed excerpt prompt holds it in clear.
What the whole file costs, measured on session 20261002-180320 (S3, commit 8271385; 120 files with findings; cl100k tokens):
- The whole numbered file averages 6,032 tokens. The union of ±40-line windows around each finding's lines averages 1,077, and ±12-line windows 450. One window per finding, not merged, averages 1,386, because 42 of the 120 files hold more than one finding. The review evaluation measured 6,322 and 1,106 on the files that reached the verifier.
- The linked-file skeletons (
_collect_linked_snippets,pipeline.py:716-734) add 2,408 tokens per file on average, from 7.6 files. - Per the evaluation, verification used 63% (S2) and 67% (S3) of the review's prompt tokens, and 984 s of S3's wall time. The evaluation estimates that windows alone save about 480k of S3's 1.72M verifier prompt tokens (28%) [estimate]. Dropping the skeletons would save about 220k more (93 calls at 2,408 tokens) [estimate].
The linked files add noise, not evidence. _find_linked_files (pipeline.py:1908-1937) keeps the first 10 files, in metadata order, that share any key symbol or dependency, or whose path loosely matches one of its dependencies. In S3, src/devops_cli/ai/harness/workflow.py was linked to .pre-commit-config.yaml, docs/github-pages.config.yaml and eight k8s/ YAML files, none of which it reads. src/devops_cli/ai/client/streaming.py was linked to ten ai/agents/* modules in alphabetical order. The lists also change between runs when nothing they depend on changed: per the evaluation, 17 of 27 and 10 of 28 changed lists on unchanged files differed only in files that had not changed [single]. The import-based related-file section (_find_related_file_metas, verification.py:148-186; up to 3 files per finding and 10 per prompt, each with its metadata and its first 1,500 characters, :188-230 and :296-305) already shows the verifier the modules a file imports, then files whose dependencies name it. For streaming.py in S3 it picked ai/client/models.py, ai/client/network.py and config/constants.py. Linked files feed nothing else: FileReviewPayload.linked_files (src/devops_cli/ai/review_schema.py:1134) is set at pipeline.py:2017-2031 and read only at :2664.
Changes since the evaluation: #949 (e4ea2e0) and #951 (38517a8) did not touch this path. pipeline.py:2669 and verification.py:111 are where the evaluation cited them. Lines here are cited at 38517a8. #987 (b1fddd0) and #1009 (79e1e93) merged after it and moved pipeline.py lines down by about 170, without changing the functions cited.
Acceptance criteria
-
_verify_single_file_payloadhands the verifier the file's numbered source under a### File: <path>header and a fence, so_extract_location_contextfinds each finding's lines. - For a finding at
<path>:N-M, the code section holds lines N-40 to M+40 of the file and no other line of it. The window is one constant:DEFAULT_DIFF_CONTEXT_LINES(config/defaults.py:413, read only by_extract_location_context) becomesDEFAULT_REVIEW_VERIFICATION_CONTEXT_LINES = 40.DEFAULT_LOCATION_CONTEXT_LINES(:412), which nothing reads, is deleted. - Findings in one file share one excerpt. Their windows are merged, each source line appears once, in file order, and a gap between windows is marked.
- The excerpt is masked as the whole file is today.
mask_secretsruns on the whole numbered file, as the fallback does today, before windows are cut, thensanitize_prompt_boundary_tags. A test puts a fakeghp_token on the cited line and asserts the token is not in the prompt. The test fails if the excerpt path is turned on without masking. - A finding whose location names no line, or a file with no header in the segment, gets the whole masked numbered file, as today.
- The linked-file skeletons are gone from the verifier prompt and from the code.
_find_linked_files,_collect_linked_snippetsandFileReviewPayload.linked_filesare deleted, with the linked-files block oftest_review_pipeline_dependency_and_network_auditing(tests/test_review_pipeline.py:859-870), their only test. The import-based related-file section stays. A saved session whosefiles/*.jsonholdslinked_filesstill loads. - A test runs
_verify_single_file_payloadon a 600-line file with findings at lines 100 and 500 and a recording verification client. The prompt holds lines 60 to 140 and 460 to 540 once each, no line 1, 300 or 600, and noLinked File (block. It fails on the current code. - The new tests run offline, with RAG stubbed, in under 1 s together.
-
changelog.d/1017.mdrecords the fix under### Fixed.CHANGELOG.mdis not edited. -
uv run devops cipasses. - (person-run) Re-run one branch review with a warm cache, before and after the change. The PR records verifier prompt tokens (ledger rows with stage
review.verification) and the count of findings per verdict for both runs. It names any finding that lost a verdict because the deciding code fell outside its window.
Key questions
- How wide should a window be? (proposed) ±40 lines, as one constant. S3's
src/devops_cli/commands/argo.py:91-93"unsafe YAML loading" finding is settled byyaml.safe_loadat:103, ten lines past the range, so ±12 barely reaches a guard like that. The evaluation measured ±40 at about 1,100 tokens a file against about 6,000 for the whole file. - Should the window grow to the enclosing function or class? (proposed) Not in this item. It needs a parser per language, while a line window works for every file kind. If the person-run comparison shows findings left without a verdict because the deciding code was cut off, widen the constant first.
- Should the linked-file skeletons stay, as a separate block? (proposed) No, delete them. They are the first 10 loose matches in metadata order, they shift between runs, and they cost about 2,400 tokens per call. The import-based related-file section already carries the cross-file context. Deleting them also retires the evaluation's proposed N3 (linked files chosen by relevance in a fixed order), since its only reader is this prompt.
- Will the verifier lose evidence it needs? (proposed) Some, by design. feat(review): review prompts state a threat model and an evidence bar, and send nothing the pipeline does not use #951's standard already tells it to leave a finding unverified when the code that settles it is not shown. The related-file section still shows the modules the file imports. The person-run comparison measures the effect.
- Why mask the whole file before cutting windows? (proposed) A multi-line secret, such as a PEM block, can straddle a window edge, and a cut piece may not match its pattern. Masking first keeps today's masking exactly.
- Does the legacy segment engine change too? (proposed) Yes, it calls the same
_extract_finding_excerptwith headed pages, so it gets masked, merged excerpts until refactor(review): delete the legacy segment engine so the orchestrator is the only review engine #995 deletes it.
Depends on: none.
Order: after #846 (v0.2.25). #846 changes _build_validation_prompt's findings block and the verdict copy-back at pipeline.py:2687-2708, next to the lines this item edits. If #1018 is scheduled, land this item first: both change how _build_validation_prompt builds its code section.
Related: #846 (the findings block of the same prompt). #951 (the verifier's evidence standard). #995 (deletes the legacy segment engine). #996 (one finding verifier; this item's code moves into it). #1018 (adds the removed lines of a hunk to the same code section).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 3, 2026
Frozen by the evidence-first review redesign (#1137, owner direction of 2026-10-03): patches to the model generator and verifier stop, and tool-layer fixes continue. This item patches code that #1150 deletes (the verifier path in
verification.py, the guards and verifier prompts,construct_validator.py,criteria_evidence.py, and the known-false-positive catalog). Its secret masking of model excerpts carries into #1147 as an acceptance criterion.It stays open, labelled
status/blocked, and closes as not planned with "Superseded by #1150" when that item lands. Until then, the interim is the tools-only review (--no-persona-review --no-verification). Do not start work on it.dan-petty-bot commentedon Oct 10, 2026
Moved to v0.2.34: v0.2.34 started with fewer than its 16 items and was topped up to 16 from Ready items, critical fixes and P0 features first. (devops roadmap reprioritize)
dan-petty commentedon Oct 11, 2026
Superseded by #1150