Repository navigation
Description
Split from #4830.
Issue #4830 builds select_lens, the ordered lens.toml table, the span record and the counter, and adds devops ai chat --persona auto. It cannot make the review and roadmap callers select a lens: no review stage calls a persona (ARCHITECTURE.md says so), and no roadmap job builds a persona agent, so the lens and lens_rule fields of profile.json stay none and the counter's caller set holds only chat. Why deferred: the callers must first build a persona agent and pass it the evidence (changed paths, tool findings, labels), which is a separate change with its own tests. Acceptance criteria: - The review caller calls select_lens with the evidence of its target and writes lens and lens_rule into profile.json beside prompt_digest. - The roadmap caller that builds a persona agent calls select_lens with its item's evidence. - Each caller adds one closed caller value to devops_cli_ai_lens_total, and the product of the counter's label sets stays at 84 or fewer. - A table test covers each caller, and a call with no match records none and uses the generic prompt.
Proposed design
Problem statement
The review caller uses one generic prompt for the group-analysis explanation. Issue #4830 adds select_lens and the lens counter, but no review caller selects a lens, so the lens and lens_rule fields stay none. This change makes the review caller select a lens from its evidence. It records the lens and rule in profile.json. It adds a closed caller value to devops_cli_ai_lens_total. The roadmap caller is deferred because no roadmap job builds a persona agent at this commit.
Acceptance criteria
Requirement: Review caller selects a lens
The review caller SHALL call select_lens with the reviewed file paths, the admitted tool findings and the target labels, and SHALL write the selected lens and lens_rule into profile.json beside prompt_digest.
Scenario: Review target matches a lens rule
- WHEN The review caller runs on a target whose reviewed paths, admitted tool findings and labels match a rule in lens.toml.
- THEN The test asserts that profile.json holds that lens and rule, and that the group-analysis prompt is the lens prompt.
Requirement: Review lens keeps findings unchanged
The review caller MUST use the selected lens only as the group-analysis prompt and MUST NOT create, move, re-rate or change the state of a finding.
Scenario: Lens changes no finding
- WHEN The test runs the review caller with a selected lens and with the generic prompt on the same admitted findings.
- THEN The test asserts that findings.json has the same findings and states in both runs.
Requirement: Review caller counter value stays closed
The review caller SHALL add one closed caller value, review, to devops_cli_ai_lens_total, and the product of the counter label sets MUST stay at 84 or fewer.
Scenario: Counter label product
- WHEN The test builds the lens counter with the chat and review caller values.
- THEN The test asserts that the caller label accepts only the closed set and that the product of its label sets is 84 or fewer.
Requirement: No match uses generic prompt
A review caller call with no matching lens SHALL record none in lens and lens_rule and SHALL use the generic group-analysis prompt.
Scenario: No lens rule matches
- WHEN The test runs the review caller with evidence that matches no rule in lens.toml.
- THEN The test asserts that profile.json records none for both fields and that the prompt equals the value that load_task_prompt returns for the analysis prompt.
Requirement: Table test covers the review caller
A table test SHALL cover the review caller for a match, no match and its counter value.
Scenario: Review caller table test runs
- WHEN The command uv run devops ci test tests/ai/review/test_review_lens.py runs.
- THEN Each row asserts the lens, the rule, the prompt and the caller value, and the command passes.
Existing Tool Considered
No alternatives check has run for this issue. No open, maintained library covers selecting a prompt from reviewed paths, tool findings and labels and recording a closed metric caller. The change integrates select_lens and devops_cli_ai_lens_total from #4830. The written cost to build, keep and fix this code is about 35,000 tokens and one engineer-day.
Key questions
- Does a persona lens in the review caller violate ADR 0005?: No. ADR 0005 deletes the persona review stage that produced findings and keeps the persona definitions for chat and analysis. The review caller uses the lens only as the system prompt of the existing group-analysis explanation call. It never creates, moves, re-rates or changes a finding. (best practice) [sources: docs/adr/0005-review-findings-come-from-tools-not-models.md, ARCHITECTURE.md]
- Chosen: Use the lens only for the group-analysis prompt. The tools still produce every finding, and the model only explains. ADR 0005 holds.
- Rejected: Use the lens to produce review findings. ADR 0005 deletes the persona review stage. No model output may create, move, re-rate or change the state of a finding.
- Which callers select a lens in this change?: Only the review caller selects a lens in this change. The roadmap caller is deferred because no roadmap job builds a persona agent at this commit. Only devops ai chat loads the persona definitions and builds a persona agent. (best practice) [sources: ARCHITECTURE.md, src/devops_cli/commands/ai.py, src/devops_cli/roadmap/refine/refine_investigation.py, src/devops_cli/roadmap/implement/implement_step.py]
- Chosen: Review caller only; defer the roadmap caller. The review part is buildable now and keeps ADR 0005. No roadmap job builds a persona agent, so the roadmap part can not be built as written.
- Rejected: Both the review and roadmap callers. The roadmap caller does not exist. This would add a new persona agent to a roadmap job without a design for its prompt or evidence.
- Rejected: Only the roadmap caller. This leaves the review explanation on the generic prompt and meets neither part of the issue.
- Does a roadmap job build a persona agent?: No. The only persona agent is devops ai chat, which loads PERSONAS and passes the persona chat prompt to build_agent. The roadmap agents build their own instructions. The refine investigation and the implement step take no persona. [sources: ARCHITECTURE.md, src/devops_cli/commands/ai.py, src/devops_cli/roadmap/refine/refine_investigation.py, src/devops_cli/roadmap/implement/implement_step.py]
- What evidence does the review caller pass to select_lens?: The review caller passes the reviewed file paths and the admitted scanner findings as tool_findings. It passes the target labels when the caller holds them. Otherwise it passes an empty labels list. A review of a path or a branch has no labels. (best practice) [sources: src/devops_cli/ai/review/pipeline.py, src/devops_cli/review/analysis.py, src/devops_cli/ai/review/profile.py]
- Chosen: Pass reviewed paths, admitted findings and the target labels. These are the three inputs that select_lens takes. The review caller holds the paths and the admitted findings, and it uses labels when the target gives them.
- Rejected: Pass reviewed paths, admitted findings and an empty labels list always. This drops the label rules of lens.toml for a pull request target that has labels.
- Rejected: Pass labels only. The review caller holds no labels for a path or branch target, and this loses the path and finding rules of lens.toml.
- Rejected: Add a new evidence schema. feat(ai): choose a persona lens from evidence with a rule table #4830 already defines the input of select_lens.
- How does the counter keep its label product at 84 or fewer?: Add one closed caller value, review, to devops_cli_ai_lens_total. Do not add a new lens or rule value. The table test computes the product of the counter closed label sets and fails above 84. (best practice) [sources: docs/TELEMETRY.md, src/devops_cli/ai/knowledge_base/it_domains/tools/prometheus.md, openspec/changes/archive/2026-11-12-4703-count-each-implement-outcome-once-with/design.md]
- Chosen: Add review only. One closed value meets the issue. It adds no lens or rule value, so the product stays within the stated limit.
- Rejected: Add a caller value for each new call site. This adds label values and can raise the product above 84.
- Rejected: Add no caller value. The counter can not show which caller selected a lens.
- What does the review caller do when no lens rule matches?: It records none in lens and lens_rule. It passes the generic group-analysis prompt, which is the prompt that load_task_prompt(CONST_ANALYSIS_PROMPT_FILENAME) returns, unchanged. (best practice) [sources: src/devops_cli/review/analysis.py, src/devops_cli/ai/review/profile.py, docs/TELEMETRY.md]
- Chosen: Record none and use the generic prompt. This keeps the current prompt and gives profile.json an explicit absence value.
- Rejected: Skip the profile fields. profile.json would have no lens record, and the counter would not say that the caller selected nothing.
- Rejected: Fail the call. A missing lens is not an error.
Fit
Fits in one pull request.
Suspected block
None.
Activity
devops-cli-service commentedon Nov 15, 2026
#4830 builds select_lens and the chat flag; the candidate makes the review and roadmap callers use the selector.devops-cli-service commentedon Nov 18, 2026
Refine cannot set this item to Ready at 86358b6 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.
devops-cli-service commentedon Nov 25, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.