Repository navigation
Description
Refreshed plan (2026-10-17, unblocking review)
This section supersedes any text below that conflicts with it.
Decisions
- Decision D9 (owner, 2026-10-17): "feat(review): group analysis is profiled as its own stage, and analysis.json counts dispatched, replayed and failed jobs apart #482 and fix(review): a group-analysis reply that fails its checks is neither cached nor served #1013 leave feat(review): evidence-first code review — tools find, version-pinned facts ground, models explain and plan, fixes are re-checked #1137's frozen row and proceed in the explanation (group analysis) stage: fix(review): a group-analysis reply that fails its checks is neither cached nor served #1013 gets a validator with no resample so model calls <= groups + 1; feat(review): group analysis is profiled as its own stage, and analysis.json counts dispatched, replayed and failed jobs apart #482 counts dispatched, replayed and failed jobs; both land after fix(review): a group-analysis reply cut at its token cap is rejected, not shown as a checked explanation #876." This item no longer waits for feat(review): evidence-first code review — tools find, version-pinned facts ground, models explain and plan, fixes are re-checked #1137's unfiled P3-1. It closes when its own PR merges.
- The counts are per group job. Each job makes one chat call, because D9 allows no resample, so
dispatched + replayed + failedalways equals the number of jobs. When feat(review): related findings are linked by shared CWE, rule family, symbol-graph component or package, and one review-level plan orders the work across groups #1148's plan job exists, it counts as one more job. Reason: this gives one invariant that a test can check. replayedcounts replies whoseLLMResponse.cachedis true.failedcounts jobs that got no reply, meaning the call raised an error other thanReplyRejectedError(today'smodel-call-error).dispatchedcounts every other job, including a reply that the G10 checks, fix(review): a group-analysis reply cut at its token cap is rejected, not shown as a checked explanation #876'sreply-truncatedrule or fix(review): a group-analysis reply that fails its checks is neither cached nor served #1013's validator reject. A validator refusal reaches the job asReplyRejectedError, which carries the reply and is never cached, so it counts as dispatched. Reason: a refused reply still cost a model call.model_callsis removed from analysis.json and review.md, with no alias. Reason: it islen(jobs), so it counts replays and failed calls as model calls, and the project is pre-1.0 and keeps no shims.- When one
review_stageis nested in another, its wall time is subtracted from the outer stage, soreportno longer includes group analysis. Reason: group analysis runs midway throughgenerate_consolidated_report, which runs under the runner'sreportstage. Moving the call out would reorder code that refactor(review): the persona review stage, the legacy segment engine and review-time RAG are deleted, and devops review builds a model client only for the explanation stages #1151 PR 1 and feat(review): related findings are linked by shared CWE, rule family, symbol-graph component or package, and one review-level plan orders the work across groups #1148 also edit. No stage is nested today, so no other stage's figures change.
Scope
- Delivers three things. Group analysis gets its own profile stage,
group_analysis. analysis.json and review.md report dispatched, replayed and failed jobs. The terminal profile line shows replayed calls for each stage. - Dropped: the verifier replay rate and the "verdict from a cached verifier reply" checkbox. refactor(review): the model verifier, the hallucination catalog and the model-claim guards are deleted, and person-recorded verdicts become suppressions #1150 deleted the verifier in v0.2.33, and
src/devops_cli/ai/review/verification.pyno longer exists. - Dropped: the persona replay rate. refactor(review): the persona review stage, the legacy segment engine and review-time RAG are deleted, and devops review builds a model client only for the explanation stages #1151 (v0.2.38) deletes the persona stage.
- Dropped: the prefix-cache hit rate and the prompt-ordering fix. vLLM was removed in feat(k8s): modernize monitoring stack, llm profiles, traefik routing, and remove squid proxy #734.
inject_prompt_cache_pointshas no production caller. Group analysis already sends its static system prompt first and the job JSON as the only per-group text.
Delivery
- PR 1 (M), Closes feat(review): group analysis is profiled as its own stage, and analysis.json counts dispatched, replayed and failed jobs apart #482. Tests come first.
Acceptance criteria
- Group analysis runs inside
review_stage("group_analysis"). profile.json credits its model calls and replays to that stage, with none toreportorunstaged, andreport's wall time leaves out group analysis. - analysis.json holds
dispatched,replayedandfailedin place ofmodel_calls, and they sum to the number of jobs. - review.md's Model Analysis section prints the three counts in place of
Model Calls. - The terminal profile line shows each stage's replayed count next to its calls, and it lists a stage that only replayed.
- Two-run test: the review's report step runs twice with the real
LLMClientover an httpx2MockTransport, with the response cache intmp_path. On the second run the transport sees no request, thegroup_analysisstage showsllm_calls0 andcached_callsequal to the number of groups, and analysis.json showsreplayedequal to the number of groups, withdispatchedandfailedboth 0. - Failure test: a fake client that raises for one of N groups gives
failed1 anddispatchedN-1. - With
--no-cache,replayedis 0. - Tests run offline, with no network and no model, and each runs in under 1 s.
-
uv run devops cipasses.
Current references
model_callsfield:src/devops_cli/review/analysis.py:209. It starts at 0 at:792, is set tolen(jobs)at:810and is written into the report at:860. The exception path at:812-830recordsmodel-call-error, and review.md prints the count at:917.- Group job:
src/devops_cli/review/analysis.py:689-750, with the chat call at:700-706. The static system prompt is loaded at:795, and the job JSON is the user prompt at:699. - Cache-hit flag:
src/devops_cli/ai/client/models.py:121, set atsrc/devops_cli/ai/client/unified.py:569-575. - Validator refusal:
ReplyRejectedErroratsrc/devops_cli/ai/client/models.py:68-77carries the reply and is never cached. - Profiler:
cached_callsatsrc/devops_cli/ai/review/profile.py:94, credited to the active stage at:245-250.review_stageis at:411-423. - Stage wrap point:
src/devops_cli/ai/review/pipeline.py:4854, inside the runner'sreportstage atsrc/devops_cli/ai/review/runner.py:1070-1071. - Terminal profile line:
src/devops_cli/ai/review/runner.py:949-958. It prints onlyllm_callsand hides a stage that runs under 1 s with nollm_calls. - Tests to update:
tests/test_review_group_analysis.py:287,:509,:515and:648. - Test patterns:
tests/llm_stream_fakes.py:105-128(route_llm_clients) sends every request from anLLMClientbuilt inside the code under test to an httpx2MockTransport.tests/test_ai_client_structured.py:423-438shows a cached reply served with no second request, under thepublic_dnsfixture (tests/conftest.py:191-192). inject_prompt_cache_points:src/devops_cli/ai/pydantic_ai_bridge.py:378. Onlytests/test_pydantic_ai_workflows.py:108-130calls it.
Dependencies and order
- fix(ai): response-cache hits are counted as cached requests #816: closed (completed, v0.2.29). Cache hits reach the call observers, so this body's original dependency is met.
- fix(review): a group-analysis reply cut at its token cap is rejected, not shown as a checked explanation #876: open in v0.2.37, with
status/blockedremoved on 2026-10-17 and its body re-scoped to group-analysis cut replies (its title still names persona replies). It lands first because it changes the same_execute_single_group_job(D9). Its person-run check readsfinish_reasonsfrom thereportstage. Once this item lands, those figures are in thegroup_analysisstage. - fix(review): a group-analysis reply that fails its checks is neither cached nor served #1013: open, P1, no milestone. It keeps
status/blockeduntil its D9 re-scope is posted. Either it or this item can land first. Whichever lands second keeps the three counts summing to the number of jobs, with a validator refusal counted as dispatched. - refactor(review): the persona review stage, the legacy segment engine and review-time RAG are deleted, and devops review builds a model client only for the explanation stages #1151: open in v0.2.38. Its PR 1 changes the gate at
pipeline.py:4191-4198and the call at:4854, and its PR 2 also editsrunner.pyandprofile.py. This item lands after PR 1. That is an ordering choice to avoid a conflict, not a hard dependency. - feat(review): related findings are linked by shared CWE, rule family, symbol-graph component or package, and one review-level plan orders the work across groups #1148: open in v0.2.38. Its plan job runs in the
group_analysisstage and counts as one job. Whichever of the two lands second wires that up. - feat(review): evidence-first code review — tools find, version-pinned facts ground, models explain and plan, fixes are re-checked #1137: open, no milestone. Its frozen table drops feat(review): group analysis is profiled as its own stage, and analysis.json counts dispatched, replayed and failed jobs apart #482 in the same refresh.
- Milestone: none set. A person plans the milestone on the board. This item stays P2: no open item names it as a blocker. It does supply the figures for two of feat(review): evidence-first code review — tools find, version-pinned facts ground, models explain and plan, fixes are re-checked #1137's P1b exit criteria ("Model calls ≤ finding groups + 1" and "Model-phase wall time is reported separately from the tools"), so if feat(review): evidence-first code review — tools find, version-pinned facts ground, models explain and plan, fixes are re-checked #1137's refresh lists it as a P1b child, the blocker rule makes it P1.
Context & Rationale
Two caches can save review work: devops-cli's LLM response cache (devops ai cache status) and Anthropic/OpenAI prompt caching (the target of inject_prompt_cache_points), which can skip reprocessing a persona's static system prompt on every page. Neither is measured during reviews. Before vLLM was removed in #734, the tuner showed how much prefix reuse matters: identical prompts made vLLM's prompt processing nearly free.
Scope & Deliverables
- Context & Rationale*: Two caches can save review work: devops-cli's LLM response cache (
devops ai cache status) and Anthropic/OpenAI prompt caching (the target ofinject_prompt_cache_points), which can skip reprocessing a persona's static system prompt on every page. Neither is measured during reviews. Before vLLM was removed in feat(k8s): modernize monitoring stack, llm profiles, traefik routing, and remove squid proxy #734, the tuner showed how much prefix reuse matters: identical prompts made vLLM's prompt processing nearly free. - Deliverable*: Report response-cache hit rates per review run. vLLM was removed in feat(k8s): modernize monitoring stack, llm profiles, traefik routing, and remove squid proxy #734 and the Ollama nodes that replaced it export no metrics, so there is no per-backend prefix-cache hit rate (
vllm:prefix_cache_*) to report. Check that persona prompts keep static text ahead of page content so the prefix is shared, and fix any ordering that defeats it.
Strategic Alignment
Scope added 2026-10-02: the release review evaluation could count cache replays only by subtracting dispatched calls from persona pages, because profile.json cached_calls is 0 in every session (#816). Persona review replayed 192 of 268 replies in session 20261002-163203, 238 of 319 in 20261002-180320 and 301 of 341 in 20261002-200610. Verification replayed 3 of 76 and 6 of 99 in the first two. One hit rate per run would hide that split. Verification is now the larger cost (63%, 67% and 82% of those runs' prompt tokens), and it almost never replays. StageProfile already has a per-stage cached_calls field (ai/review/profile.py:92, counted at :216-218). Once #816 sends hits through the call observers, the figures exist, and this item reports them. Depends on #816.
- The terminal summary and
review.mdstate, for persona review and for verification, how many replies were generated and how many were replayed from the response cache. - A test runs the same review twice with the response cache on, using the real client over a fake HTTP transport, on findings with no executable criteria. The second run's profile shows verification
cached_callsequal to its verifier calls andllm_calls0 for that stage, and the summary prints both rates. The test runs offline.
Scope added 2026-10-02 from review session 20261002-214641 (.data/review-evaluation-20261002-s6.md, section 7): 9 of S6's 10 VERIFIED findings were verdicts replayed from the previous session's cache, stamped with S6's time.
- A finding whose verdict came from a cached verifier reply says so in findings.json and review.md.
Proposed design
Problem statement
The review process currently counts all LLM model calls under a single 'model_calls' field in analysis.json and review.md, without distinguishing between dispatched jobs (which actually called the model), replayed jobs (which used cached responses) and failed jobs (which raised errors). Additionally, group analysis is not profiled as its own stage, and the wall time of group analysis overlaps with the report stage, leading to inaccurate timing data.
Acceptance criteria
- Criterion 1: Group analysis runs inside
review_stage("group_analysis")
Verification: Verify that all group analysis code execution is wrapped within areview_stage("group_analysis")context manager. - Criterion 2: Profile.json credits model calls and replays to the 'group_analysis' stage, with none to 'report' or 'unstaged'
Verification: Check that profile.json shows non-zero 'llm_calls' and 'cached_calls' in the 'group_analysis' stage, and zero in 'report' and 'unstaged' stages. - Criterion 3: Analysis.json holds 'dispatched', 'replayed' and 'failed' in place of 'model_calls'
Verification: Validate that analysis.json contains 'dispatched', 'replayed', and 'failed' fields instead of 'model_calls', and that these sum to the number of jobs. - Criterion 4: Review.md's Model Analysis section prints the three counts in place of 'Model Calls'
Verification: Confirm that review.md shows 'dispatched', 'replayed', and 'failed' counts instead of a single 'Model Calls' count. - Criterion 5: Terminal profile line shows replayed count next to calls for each stage
Verification: Run a review and check the terminal output shows 'stage_name duration (calls, cached_calls)' format. - Criterion 6: Two-run test: second run uses cache with no new requests
Verification: Execute two identical reviews with caching enabled, verify second run has 0 LLM calls and cached_calls equal to number of groups in group_analysis stage. - Criterion 7: Failure test: one job raises error results in 'failed' count
Verification: Create a fake client that raises an error for one of N jobs and verify analysis.json shows 'failed': 1 and 'dispatched': N-1. - Criterion 8: With --no-cache, 'replayed' is 0
Verification: Run review with --no-cache flag and verify 'replayed' count in analysis.json is 0.
Key questions
- What are the specific changes needed to split dispatched, replayed, and failed job counts?: The model_calls field needs to be removed from AnalysisReport and replaced with dispatched, replayed, and failed counts. Each job execution must distinguish between these three states: dispatched (normal call), replayed (cached), and failed (error). [sources: src/devops_cli/review/analysis.py:209, src/devops_cli/review/analysis.py:810, src/devops_cli/review/analysis.py:860]
- How does the profiler track cached calls?: The profiler tracks cached calls in StageProfile.cached_calls and credits them to the active stage through the observe method in ReviewProfiler, which is called from the LLM client's observation system. [sources: src/devops_cli/ai/review/profile.py:94, src/devops_cli/ai/review/profile.py:245, src/devops_cli/ai/review/profile.py:250]
- Where is group analysis currently executed in the review pipeline?: Group analysis is currently executed as part of the 'report' stage in the review pipeline, which causes its timing to overlap with report generation and makes it difficult to isolate its performance. [sources: src/devops_cli/ai/review/pipeline.py:4854, src/devops_cli/ai/review/runner.py:1070, src/devops_cli/ai/review/runner.py:1071]
- Should the group analysis stage be moved out of the report stage?: Yes, to properly isolate its timing and resource usage, the group analysis should run as its own dedicated stage separate from the report stage. (proposed) [sources: src/devops_cli/ai/review/pipeline.py:4854, src/devops_cli/ai/review/runner.py:1070, src/devops_cli/ai/review/runner.py:1071]
- How should the terminal profile line be updated to show replayed counts?: The terminal profile line in runner.py needs to be modified to display cached_calls alongside llm_calls for each stage, and it should list stages that only replayed. [sources: src/devops_cli/ai/review/runner.py:949, src/devops_cli/ai/review/runner.py:958]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
docs(roadmap): plan LLM tuning and optimization work for v0.2.23 (#483)
feat(release): v0.2.23 (#681)
dan-petty commentedon Oct 1, 2026
Moved from the shipped v0.2.23 to the backlog. It is still valid (checked 2026-10-01), and P2 items don't displace P1 work in the planned releases.
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. The review's use of
ai/response_cache.pyand its page-retry loop are replaced in phase P3 by content-addressed review jobs (P3-1 in #1137, filed when that phase starts). This item stays open, labelledstatus/blocked, and closes when P3-1 lands. Chat and analysis cache effectiveness is #816's and #1014's.[-]feat(ai): llm cache effectiveness during reviews response cache and prefix cache[/-][+]feat(review): group analysis is profiled as its own stage, and analysis.json counts dispatched, replayed and failed jobs apart[/+]dan-petty commentedon Oct 20, 2026
Status set to Ready at 2954109 (see proposed design in issue body).