Repository navigation
Description
Context & Rationale
ai/review/runner.py holds two review engines. _execute_review_workflow (:2193-2289) forks at :2240 on type(clients.analysis).__name__ == "LLMClient": production goes to ReviewPipelineOrchestrator through 5 runner functions (150 lines); any other client, or a page with no file header, goes to _run_persona_loop (:1267-1349) and its helpers (_run_review :1165-1217, _execute_review_segments :920-988, _execute_findings_validation :1031-1115, _execute_final_recompose :1118-1162, _save_findings_json :427-472): 35 functions and 1,016 lines reachable only from that branch. Checked at 9c879ae (release/v0.2.25 tip).
- Six test files build
ReviewClients(analysis=DummyClient())or aMagicMockand so test the legacy engine, not the one production runs:tests/test_review_path.py,test_review_history.py,test_review_project_conventions.py,test_review_symbol_delta.py,test_review_verification_task.py,test_review_runner.py. - Two modules write
findings.json(pipeline.py:3701,runner.py:427), sohistory.pyhas to rank duplicate sessions. - The orchestrator is typed
Anyin the runner, and the runner reaches intoorchestrator._get_server_info(). pipeline.pyandrunner.pyco-change in 22 of runner's 23 commits.
Deletion test: the legacy engine is a second implementation of one concept. Deleting it makes the complexity vanish rather than move.
Scope & Deliverables
- Deliverable: one review engine.
_execute_review_workflowresolves the session subject and hands it to the orchestrator. The orchestrator takes the model client through a small chat protocol, so a fake adapter runs the real path in tests. The legacy functions, the class-name check and the secondfindings.jsonwriter are deleted, not wrapped. - Tests: the six files above re-point at the orchestrator with a fake chat adapter. The 8 patches of
_run_persona_loop,_run_review,_print_reviewand_load_shared_metadata_for_pagesgo with the code they patched. - Key questions (open):
- What is the smallest chat protocol the orchestrator needs, and does
tests/llm_stream_fakes.route_clientalready satisfy it? - Which legacy-only behaviours (pages with no file header) must the orchestrator absorb, and which are dead?
- What is the smallest chat protocol the orchestrator needs, and does
- Constraint: no shims (pre-1.0 policy). refactor(review): review session store that owns layout, fingerprints and verdicts #771 and feat(review): review tools run through one injectable executor in a network-less sandbox with CPU, memory and time limits #772 edit the same files; sequence the three to avoid rebases.
Strategic Alignment
- Milestone: Backlog (no release)
- Design: CONTEXT.md (Review session, Finding, Verdict)
- Depends on: none
- Related: refactor(review): review session store that owns layout, fingerprints and verdicts #771 (one writer makes the session store smaller), feat(review): review tools run through one injectable executor in a network-less sandbox with CPU, memory and time limits #772, feat(cli): one verdict writer, cited refutations and no unverified fix claims #601
- Source: architecture review of 2026-10-02, review pipeline cluster
Scope added 2026-10-02: checked at 38517a8. Production reaches the legacy engine in one case: no review page has a diff --git or ### File: header, so all_files is empty (ai/review/runner.py:2230), _run_profiled_session returns None after pre-analysis (:2102-2103) and the workflow falls through to _run_persona_loop (:2287). A branch or PR diff that changes only files in CONST_REVIEW_GENERATED_FILES (uv.lock and the other lockfiles, config/constants.py:582) gives one empty page (ai/review/chunker.py:431-432), and so does an empty PR diff, which _prepare_pr_content does not refuse (runner.py:1895-1937; a branch review exits at :1883-1885). The engine then sends that empty page to the model as "segment 1/1" for each persona, writes its own session, and review pr --post posts the result. An offline probe of _execute_review_workflow with a lockfile-only diff reached _run_persona_loop. The class-name check never fails in production: _make_review_clients (runner.py:1543-1584) is the only ReviewClients constructor in src and always builds LLMClient, which has no subclass; the gateway, Copilot and OpenAI-compatible backends are provider branches inside it (ai/client/unified.py:925). review path (with --watch and review benchmark), review branch, review pr, the devops ai review alias and the MCP review_path, review_branch and review_pr tools (ai/mcp/server.py:136-181, dispatched in-process to the same commands) all use it. The same fork hides a second defect: --summary ("Show segment metadata without running a full review", lang/en/help.py:951) is read only after the LLMClient branch returns (runner.py:2240-2276), so with any file header it runs a full review. Corrections: history.py ranks repeat reviews of one subject (#607, ai/review/history.py:1-15), not copies from two writers, so that ranking stays. The issue's 35 functions and 1,016 lines were counted at 9c879ae. At 38517a8, 35 functions (1,043 lines) are reachable only from _run_persona_loop: 32 in runner.py (975 lines) and _merge_segment_results, _reconcile_single_finding and _reconcile_verified in ai/review/verification.py (:2143-2151, :2170-2230). The 32 include runner's own _resolve_ollama_urls (runner.py:137-152), which only legacy functions call; the orchestrator uses its own copy (ai/review/pipeline.py:197). _collect_files (called only by tests) and _resolve_static_analyzer_states are already dead. tests/test_review_symbol_delta.py builds a real LLMClient and already runs the orchestrator. The legacy engine is the only reader of the compose task (ai.tasks.compose, ReviewClients.compose, PersonaDefinition.compose_prompt, ai/tasks/compose.md), of three task prompts (paginated_review_protocol.md, review_output_instruction.md, path_review_prompt.md), and of the prompt_builder and agents_md arguments, whose _load_agents_md still runs on every review (runner.py:1708, :1891, :1935). #987 (b1fddd0, after the baseline) added full_output to the same function and left the fork as it was. #1009 (79e1e93) did not touch runner.py. #789 (P3, backlog) reports a defect in the legacy recompose (runner.py:1149, verification.py:2207-2230). Production never reaches the recompose, because a header-less diff gives one page, and this item deletes it, so #789 closes with this item.
Acceptance criteria
-
_execute_review_workflowhas no class-name check and one engine._run_persona_loopand every function only it reaches are deleted (35 functions, 1,043 lines at 38517a8: 32 inrunner.py, runner's_resolve_ollama_urlsamong them, and 3 inverification.py; the PR lists them), with the dead_collect_filesand_resolve_static_analyzer_states.rg '_run_persona_loop|__name__ == "LLMClient"' src testsfinds nothing. - When no review page names a file, the review sends no model request, runs no pre-analysis, writes no session and posts no PR comment. It prints one line saying the diff has no reviewable file and exits 0. One test covers a branch diff that changes only
uv.lock, and one covers an empty PR diff with--post. Both use a fake client that fails the test on any call, and both fail at 38517a8, where the legacy engine calls the client and the orchestrator's constructor has already made a session directory (ai/review/pipeline.py:1482). -
--summaryprints the analysis metadata of the files the pages name and returns before the orchestrator is built. A test runsreview path <tmp dir> --summarywith a fake client and asserts no model call and no new session directory. It fails at 38517a8. -
ReviewPipelineOrchestratortypesllm_clientandverification_clientwith onetyping.Protocolthat names what the review calls:chat(ai/review/verification.py:2128),chat_messages(ai/agents/agent.py:887,ai/analyze/outlines.py:119),get_context_window(ai/review/pipeline.py:2285) andbackend_info.LLMClientsatisfies it under mypy, and so do the parameters the orchestrator hands the client to:PydanticAgent(client=...),_execute_pre_analysis_batch(pipeline.py:892-895, typedLLMClient | Nonetoday) and the verifier. The orchestrator'sgetattr(..., "_config", None)reads (pipeline.py:1520,:1600,:2497,:2798) work with a fake that has no config. The runner calls no underscored orchestrator member (_get_server_infotoday,runner.py:2241), and no runner parameter for the orchestrator is typedAny. - The tests that drove the legacy engine drive
_execute_review_workflowthrough the orchestrator with a fake that implements the protocol, or are deleted with the code they covered:test_review_path.py,test_review_runner.py,test_review_history.py,test_review_project_conventions.py,test_review_verification_task.py,test_review_prompt_guardrails.py,test_review_prompt_consistency.pyandtest_review_page_line_numbers.py, and the_merge_segment_resultsand_reconcile_verifiedtests intest_review_verification.py.test_category_metrics.pywrites its sessions through the pipeline's writer, not_save_findings_json. No test patches a deleted name. -
generate_consolidated_reportis the only code that createsfindings.json.devops review verifystill rewrites it to record a person's verdict (ai/review/adjudication.py:190-204). - The compose task is deleted: the
ai.tasks.composefield, the fourAI_TASK_COMPOSE_*keys (config/options.py:48-51), the fourDEVOPS_CLI_AI_TASK_COMPOSE_*variables (config/env.py:52-55),"compose"incommands/ai.py:170,ReviewClients.compose,PersonaDefinition.compose_promptandai/tasks/compose.md. So are the three legacy task prompts,sanitization._build_prompt,runner._build_path_prompt,_load_agents_md, and every_execute_review_workflowparameter that only the legacy engine read, with the callers' arguments.test_custom_personas.py,test_telemetry_instruments.pyandtest_ai_gateway_base_url.pystop naming the compose prompt or task. - Generated docs (
docs/CONFIGURATION.md,docs/ENV_VARS.md, the CLI reference) are regenerated and name no compose task. - The new and changed tests run offline, with no model, network or scanner.
-
changelog.d/995.mdrecords the lockfile-only and--summaryfixes under### Fixed, and the compose task and its variables under### Removed.CHANGELOG.mdis not edited. -
uv run devops cipasses. - (person-run) On a branch whose only change is
uv.lock,devops review branchprints the no-reviewable-file line and exits 0.devops review path src/devops_cli/ai/review --summaryprints the metadata table, and the gateway shows no request from it.
Key questions
- What is the smallest chat protocol the orchestrator needs, and does
tests/llm_stream_fakes.route_clientalready satisfy it? (proposed) The four members above, as a Protocol beside the orchestrator.route_clientworks only on a realLLMClient, by patching its private_shared_clientand_create_http_client(tests/llm_stream_fakes.py:85-102), and needs provider wire payloads. So orchestrator tests use a protocol fake, androute_clientstays for client tests.ai/agents/testing.FunctionModel(:81) already offerschatandchat_messagesand is the natural base for that fake. refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001 can narrow the protocol later. - Which legacy-only behaviours (pages with no file header) must the orchestrator absorb, and which are dead? (proposed) The orchestrator absorbs none. A page with no header becomes an early exit in the workflow, because a lockfile-only diff gives a persona nothing to read; scanning lockfile-only changes for vulnerable dependencies is a separate feature if wanted.
--summaryis handled before the orchestrator. The legacy--allran every persona, including challenger (runner.py:124-127); the orchestrator keeps its five (:2244), which is what production runs today. - feat(review): review tools run through one injectable executor in a network-less sandbox with CPU, memory and time limits #772 also lists "the class-name switch and the persona-loop engine are removed". Which item does the deletion? (proposed) This one. feat(review): review tools run through one injectable executor in a network-less sandbox with CPU, memory and time limits #772 keeps the workspace, scanner and enricher injection and drops that bullet when it is refined, so the two PRs do not race over
runner.py. - Does
ai.tasks.composeget a deprecation path? (proposed) No. The pre-1.0 policy forbids shims. A config file that still sets it loads, becauseAITasksConfigignores unknown keys, and the changelog names the removed key and variables. - When does it land? (proposed) After the open v0.2.25 items that edit
runner.py,pipeline.pyorverification.py(fix(review): grep-only criteria neither verify nor invalidate a finding, and prompt examples stop teaching them #846, fix(review): criteria commands run in the reviewed project's environment with a measured python timeout #847, fix(review): the report ranks verified findings first, keeps only scanned advisories, and uses one category taxonomy and calibrated severity #948, fix(review): the review learns only from a person's verdicts, and every reader of the feedback dataset is honest #950, fix(security): reviews take config, data, contracts, scanner config and probe suppressions from the tree under review #972), and before refactor(review): review session store that owns layout, fingerprints and verdicts #771, feat(review): review tools run through one injectable executor in a network-less sandbox with CPU, memory and time limits #772, refactor(review): one finding verifier owns the verdict and its side effects #996 and refactor(review): report rendering leaves the orchestrator #1008, which each get smaller once one engine remains.
Consolidated from #789
Problem (added). #789 reports that the legacy multi-page recompose sets reportable=False on every UNVERIFIED finding (ai/review/verification.py _reconcile_verified, reached from runner.py). So a multi-page review can drop an unverified HIGH finding and flip REQUEST CHANGES to APPROVE. This item deletes that recompose, and its body already says #789 closes with it. #789's placement note (2026-10-01) says it is "best closed with #772", and #772 moved the deletion here on 2026-10-02.
Acceptance criteria (added).
- fix(review): multi-page reviews drop unverified findings and can recommend approval #789's constraint holds on the one remaining engine: only INVALIDATED findings leave the report. An orchestrator test with an unverified HIGH finding keeps it in the report, with the REQUEST CHANGES recommendation. The PR names the existing test that pins this, or adds one.
Placement. P2 stays (#789 was P3). In the review redesign (#1137), this item is #1151's legacy-engine piece and lands first, as a child of #1151, so that runner.py is not deleted by two items.
Update 2026-10-08: refinement
Production no longer reaches the legacy engine: #948 returns no-file reviews first (ai/review/runner.py:2245-2266, :2355-2356). The criterion 'writes no session and posts no PR comment' contradicts #948.
- The no-file path stays
_review_routed_files_onlywith no model call (tests/test_review_path_routing.py:253).
The--summarydefect holds (runner.py:2392); the PR recounts the counts.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
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)
refactor(review): delete the legacy segment engine and the whole-file…
dan-petty commentedon Oct 11, 2026
Merged
feat(release): v0.2.34 (#1566)