Repository navigation
Description
Problem or Motivation
The model review of a plan (stage_verify.verify(), refine_judge.judge()) is the costliest model step before a draft opens. In the stage job it is an agent with read tools. It runs for every plan, also for a plan with no defect. Evidence from a read-only study of TypeSafe Jev 1.14 (2026-11-09):
- Jev (
typesafe/jev-1.14, a System One decision model;src/devops_cli/ai/jev.py, PR feat(ai): integrate Jev 1.14 and agent configurations #4275) answers many typed questions about one text in one request, with a calibrated probability for each Noul question. It costs 0.042 USD per million input tokens. The gateway route is healthy. - The review input (issue plus plan,
VerificationInput) averages 4.1K tokens and is 51K tokens at most (30 cited files). One Jev request with 9 Noul questions (one for each type inVERIFY_TYPES) and 1 Score question (plan quality) costs about 0.0002 USD on average. The whole golden set costs about 0.02 USD. refine_judge.judge()sends the same input as Jev reads, with no tool, so Jev can stand in its place as the first screen.- The golden set
tests/fixtures/roadmap_eval/stagehas 56 directories: 51 cases with 317 labelled defects and 5 good plans. A stored run of the reviewer alone exists (.data/roadmap_eval/verify/20261105T203919Z.json, modelclaude-sonnet-5-5, 44 cases, recall 27%, serious recall 38%).
The idea: a cascade. If every open-type probability is below a low threshold, skip the tool-using reviewer. Otherwise run it as today. Jev never approves alone and never rejects. Any Jev error, timeout or low confidence means: run the reviewer (fail open).
Weak point: the set has only 5 good plans, so it cannot show the false-positive rate of the screen. The measure must say this.
Proposed Solution
Add roadmap.stage.jev_screen (bool, default false) and a function in stage_verify.py that builds the 10-question DecisionRequest for a VerificationInput, reusing create_jev_model and _run_decide of jev.py. _Planner._review and refine_judge.judge call it first. With the switch off, nothing changes. Score the cascade offline on the golden set with the existing scorer (stage_verify_eval: TypeRecall, serious_recall, good_returning), by type (Jev gives no quote). Turn the switch on only after a person reads the comparison.
Acceptance Criteria
uv run devops ci test tests/roadmap/stage/test_stage_verify_jev.pypasses. It fails today because the module does not exist. It uses a fake Jev and makes no network call.- With
roadmap.stage.jev_screenoff, the reviewer runs for every plan (test). - With the switch on and all open-type probabilities below the threshold, the reviewer is not called. With one at or above it, the reviewer is called. With a Jev error, the reviewer is called, and the error is logged (tests).
- The pull request comment holds the offline comparison on the golden set: recall and serious recall with and without the cascade, the share of skipped reviews and the spend.
uv run devops docs generate --sync-readmeshows the new setting.
Existing tool considered
src/devops_cli/ai/jev.py exists (create_jev_model, _run_decide, judge_with_jev). This work reuses it and builds no second client. judge_with_jev has a fixed rubric question set, so a new request builder for the 9 defect types is needed.
Cost
Build: one function, one setting, two call sites and tests. Run: about 0.0002 USD for each screened plan; it saves one agent run (several requests, thousands of tokens) for each skipped plan. Spend of the offline comparison: about 0.02 USD.
Related
#4274, #4275, #4204, #3153, #3039, #3502.
Proposed design
Problem statement
The model review of a plan, stage_verify.verify() and refine_judge.judge(), is the costliest model step before a draft opens. It runs for every plan, also for a plan with no defect. A cheap Jev screen can skip the review when no open defect type looks likely. Jev never approves or rejects alone, and any Jev error runs the reviewer as today. A premise check found that the gateway has no live Jev route today (issue #4289). This item therefore builds the screen against a fake Jev and keeps the switch off. The comparison on the golden set moves to a new issue.
Acceptance criteria
Requirement: Switch off keeps today's behaviour
With roadmap.stage.jev_screen set to false, the system SHALL run the reviewer for every plan and SHALL make no Jev call.
Scenario: switch off
- WHEN jev_screen is false and a fake Jev counts its calls
- THEN The reviewer runs once and the fake Jev gets zero calls.
Requirement: Screen skips a clean plan
With the switch on and every open-type probability below the threshold, the system SHALL NOT call the reviewer.
Scenario: all probabilities low
- WHEN jev_screen is true and the fake Jev returns a probability below the threshold for every open type
- THEN The reviewer is not called and the plan passes with no findings.
Requirement: Screen runs the reviewer on a risky plan
With the switch on and one open-type probability at or above the threshold, the system SHALL call the reviewer.
Scenario: one probability at threshold
- WHEN jev_screen is true and the fake Jev returns a probability equal to the threshold for one open type
- THEN The reviewer is called once.
Requirement: Screen fails open
When Jev raises an error, times out, leaves an open-type question unanswered or returns a probability that is not a number, the system SHALL call the reviewer and SHALL log the error.
Scenario: Jev error
- WHEN jev_screen is true and the fake Jev raises an exception
- THEN The reviewer is called and one log record names the error.
Requirement: Score never gates
The Score answer for plan quality SHALL NOT change whether the reviewer runs.
Scenario: score ignored
- WHEN jev_screen is true, every open-type probability is below the threshold, and the fake Jev returns a very low plan quality score
- THEN The reviewer is not called. With a very high score and one open-type probability at the threshold, the reviewer is called.
Requirement: Ten-question request
The request builder SHALL build one DecisionRequest with one Noul question for each type in VERIFY_TYPES and one Score question for plan quality.
Scenario: request shape
- WHEN The builder gets a VerificationInput
- THEN The request holds 10 questions: 9 Noul questions, one for each defect type, and 1 Score question.
Requirement: Both call sites use the screen
Both _Planner._review and refine_judge.judge SHALL call the screen before the reviewer.
Scenario: two call sites
- WHEN jev_screen is true and the fake Jev returns low probabilities
- THEN Neither _Planner._review nor refine_judge.judge calls its reviewer.
Requirement: Threshold is a named constant
The screen SHALL read its threshold from one constant in src/devops_cli/config/constants.py and SHALL NOT reuse CONST_AI_JEV_DEFAULT_BOOLEAN_THRESHOLD.
Scenario: constant used
- WHEN A test sets the fake Jev probability just below and just at the constant
- THEN The reviewer is skipped below the constant and called at the constant.
Requirement: Setting is documented
The setting roadmap.stage.jev_screen SHALL appear in the generated documentation with default false.
Scenario: docs sync
- WHEN uv run devops docs generate --sync-readme runs
- THEN The output shows roadmap.stage.jev_screen and no check reports drift.
Requirement: Test module runs offline
The module tests/roadmap/stage/test_stage_verify_jev.py SHALL pass with a fake Jev and no network call.
Scenario: offline test run
- WHEN uv run devops ci test tests/roadmap/stage/test_stage_verify_jev.py runs with the network blocked
- THEN All tests pass.
Existing Tool Considered
The tool is TypeSafe Jev 1.14 through the pydantic_ai DecisionModel, already wrapped in src/devops_cli/ai/jev.py (create_jev_model, _run_decide). This work reuses it and builds no second client. It lacks a request for the 9 defect types, because judge_with_jev has a fixed rubric question set. It also gives no quote, so the offline score works by type. No alternatives check has run. The new code is one request builder, one setting, one constant, two call sites and tests. The cost is a small number of tokens to build and fix it, in one pull request.
Key questions
- Which existing code does the screen reuse?: It reuses create_jev_model and _run_decide of jev.py, and adds only the request builder in stage_verify.py. The builder takes the decision model as an argument, as the other functions of jev.py do, so a test passes a fake. [sources: src/devops_cli/ai/jev.py, src/devops_cli/roadmap/stage/stage_verify.py]
- Which probabilities gate the skip?: Only the Noul questions of the open types (OPEN_TYPES) gate the skip. The other types in VERIFY_TYPES are asked but do not gate, because a finding of those types is advice and not a blocking finding. (best practice) [sources: src/devops_cli/roadmap/stage/stage_verify.py]
- Chosen: Gate on open types only. Matches open_findings, which keeps only findings of open types, and it saves more reviews.
- Rejected: Gate on all 9 types. It runs the reviewer for defects that do not block the plan, so it saves less.
- How does the Score question for plan quality affect the result?: The score is logged for the comparison only. It never gates, so Jev never approves a plan alone. (best practice) [sources: src/devops_cli/ai/jev.py]
- Chosen: Log only. Keeps the rule of the issue body that Jev never approves and never rejects.
- Rejected: Gate on the score. It adds a second gate whose score has no calibrated probability and no data to set it.
- What value does the low threshold take, and where does it live?: Add one new constant in src/devops_cli/config/constants.py next to the CONST_AI_JEV_* constants, with a low provisional value of 0.05. The deferred comparison issue tunes it on the golden set. The switch stays off until a person reads that comparison. Do not reuse CONST_AI_JEV_DEFAULT_BOOLEAN_THRESHOLD (0.50): it is a yes/no cut, not a low screen threshold. (best practice) [sources: src/devops_cli/config/constants.py]
- Chosen: New constant with a low provisional value. Follows the pattern of the CONST_AI_JEV_* constants. No live Jev route exists now, so the tuning waits for the comparison.
- Rejected: Reuse CONST_AI_JEV_DEFAULT_BOOLEAN_THRESHOLD. At 0.50 it is a boolean cut, not low enough for a screen that must not miss defects.
- Which Jev outcomes count as a failure that runs the reviewer?: An exception from _run_decide, a timeout, a missing answer for an open-type question, or a probability that is not a number all run the reviewer. _run_decide uses asyncio.run and does not catch errors, so the screen catches them, logs the error and returns 'run the reviewer'. (best practice) [sources: src/devops_cli/ai/jev.py]
- Chosen: Fail open on every anomaly. The issue body requires that any Jev error, timeout or low confidence runs the reviewer.
- Rejected: Fail closed. It would skip reviews when Jev is down and lose recall.
- Can Jev be reached today?: No. A premise check on 2026-11-09 found that POST /v1/systemone answered HTTP 404, and that chat/completions refuses the decisions model. The route problem is issue fix(ai): the gateway has no route for the Jev Decisions API #4289. This item builds the screen with a fake Jev and keeps the switch off. The comparison on live Jev moves to a new issue. [sources: src/devops_cli/ai/jev.py]
- Can the golden set show the false-positive rate of the screen?: No. It holds only 5 good plans in 56 directories. The later comparison reports recall and serious recall, and it states this limit. [sources: src/devops_cli/roadmap/stage/stage_verify_eval.py]
- Who turns the switch on?: A person turns roadmap.stage.jev_screen on, after reading the offline comparison. This change keeps the default false. Recommendation: turn it on only if the cascade loses no serious recall on the golden set. (a person decides)
Open questions
- Who turns the switch on? (a person decides)
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 9, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(roadmap)scope of the title gives the scope.It is a cost-saving optimization behind a flag, not a defect fix or a blocking gap.It saves one agent run per skipped plan but the per-plan saving is small and the set cannot show the false-positive rate.The body scopes it to one function, one setting, two call sites and tests.Both work on the stage verify step, but #3153 adds the model reviewer and the candidate adds a cheaper Jev screen that runs before it.devops-cli-service commentedon Nov 9, 2026
Refine cannot set this item to Ready at 84117ac until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.
dan-petty commentedon Nov 9, 2026
Premise check on 2026-11-09 (AGENTS.md rule 2). The item needs TypeSafe Jev to answer a Decisions request through the LLM gateway. It cannot.
POST /v1/systemoneon the gateway (the path thatSystemOneModelposts to) answered HTTP 404. The OpenAPI document of the gateway lists nosystemoneordecisionspath.POST /v1/chat/completionswith the modeltypesafe/jev-1.14answered HTTP 400: "typesafe/jev-1.14 is a decisions model and cannot be used with the chat/completions endpoint. Use the /api/alpha/decisions endpoint instead."k8s/llm/gateway/config.yamlserves the model asopenrouter/typesafe/jev-1.14, a chat route in LiteLLM.So no live Jev request can pass, and the offline comparison on the golden set could not run. The route problem is issue #4289. The code and its tests are on a local branch, built against a fake Jev, and are not in a pull request. A person must decide how Jev is reached (a gateway pass-through, the TypeSafe API with its own key, or no Jev). The item can go on after that.
devops-cli-service commentedon Nov 10, 2026
Refine cannot set this item to Ready at c70d673 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.
dan-petty commentedon Nov 10, 2026
Pilot 1 of the decision steps (ADR 0019, #4326) is in the draft pull request #4343. It replaces the design of this issue:
roadmap.stage.jev_screenhas three values (off,shadow,on) and isoffby default. The premise of the issue about the gateway route (fix(ai): the gateway has no route for the Jev Decisions API #4289) is solved:POST /v1/systemoneanswers.shadowlog of the live Service shows the false-clear rate of real reviews (counterdevops_cli_roadmap_decision_step_review_total). The offline numbers do not justifyon.docs(roadmap): the decision-step pattern for Jev (#4340)
devops-cli-service commentedon Nov 10, 2026
Released in v0.107.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.107.0
devops-cli-service commentedon Nov 10, 2026
Live since 2026-11-10 07:20 UTC