Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# A decision step asks Jev short closed questions about evidence that tools extract

TypeSafe Jev (`typesafe/jev-1.14`) is a System One decision model. It answers typed questions about a text with a calibrated probability, and it writes no text. It is no drop-in replacement for a model that writes. On 2026-11-10 the owner decided that the workflows must change to fit a decision model. This record decides how a workflow uses Jev. It builds no code.

## Status

The merge of the pull request that adds this record is the approval of this record. `git log --follow -- docs/adr/0019-a-decision-step-asks-jev-short-closed-questions-about-evidence-that-tools-extract.md` names the merge commit. The pilot of the first decision step is issue #4282. The pilot of the second step is planned here and built later.

## Context

Three trials used Jev as a cheaper model. All three failed their gates.

- **The completeness check of a draft pull request** (#4320, switch off) gave 28% false holds and 43% recall. The probability moved 0.02 or less when one hunk left a long diff that was given as state. Jev did not read the long state.
- **The labels of an intake proposal** (#4323, switch off) are behind the triage model on priority, Value and Effort. They found 0 of 3 true duplicates. The thresholds (0.90 and 0.60) were guesses. The confidence of a score was 0.25 to 0.55.
- **The screen before the verify step** (#4282) had a guessed threshold (0.05) and no data.

What the trials share: each one gave Jev a long text and asked a broad question, and each one set a threshold by hand. Jev works on short, closed questions, as `devops ai ask-jev` shows.

## Decision

A **decision step** is a place in a workflow where the workflow must pick one of a few known outcomes, and Jev gives evidence for the pick. A decision step follows seven rules.

1. **A decision point, not a generation point.** A decision step picks an outcome from a closed set: skip or run, a class from a fixed list, a tier. It never writes a plan, a comment, a quote or code. A step that needs a quote or a text stays with a model that writes.
2. **Tools extract the evidence. Jev judges a short digest of it.** Code builds the evidence: the hunk, the path, the quoted line, the test name, the criterion, the fact of a tool call. The digest holds these facts and short pieces, each cut to a size limit. A fact that a tool found, such as "this path is not in the repository", goes into the digest as a fact. A long document is never the state of a question.
3. **Many small questions in one request.** The questions about one digest go in one `DecisionRequest`. A request that asks nine questions about one digest costs a ninth of nine requests, and in pilot 1 it ranked the cases as well as nine requests did. The question set of a step is fixed in code and has a test.
4. **Thresholds are fitted, not guessed.** A fit script sets the cuts from labelled data. The cases are in two fixed halves. The script fits on one half and reports on the other, and then repeats with the halves swapped. The fitted values are data in the repository, with the date, the model, the cases and the numbers that gave them. A cut in a constant is a guess, and a test refuses it. The fit is made two ways, a cut for each question and one cut for all questions, and the report gives the loss of both on the half that was not fitted. In pilot 1 each half held about 24 cases. With the recorded split, one shared cut lost no serious defect in either direction, and a cut for each question lost 6 in one direction. With an earlier split, the result was the reverse for one case. The loss moved with one case. A half of that size is weak evidence, and the report says so.
5. **Action bands, not pass or fail.** A step has at least three bands: *continue* (the existing path goes on, or the cheap path is taken), *send to the reviewer* (the costly path runs) and *flag* (a person or the log sees the case). The band follows the fitted thresholds.
6. **Shadow first. Fail open.** A step first runs in shadow: it logs and counts its decision beside the real result and changes nothing. A person turns a step on after reading the shadow log and the fit report. A switch is off by default. An error, a timeout, a missing answer or a confidence below the fitted floor sends the case to the existing path.
7. **A Jev answer is evidence, never the only control.** A step never approves, rejects or merges alone. It is never the only security control. Its input can hold text that misleads it, so a step that skips a check also keeps a deterministic check that does not depend on Jev.

### The measure of a step

A step has a success bar that is fixed before the fit. The bar names the loss that is allowed, the saving that must follow, and the cases on which both are counted. The labelled data bounds the saving: the share of cases that need no run, which the report calls the oracle, is the most that any screen can skip with no loss. A bar is checked against its oracle before the first fit, and a bar above the oracle is not set. The report of a step gives the same numbers for the halves that were fitted and for the halves that were not, and it says what it cannot show.

### The shape in code

One small module holds the shared parts: the typed question set, the request builder, the fitted thresholds with their bands, the log record and the fail-open rule. A step supplies its evidence builder and its question set. The module reuses `create_jev_model` of `src/devops_cli/ai/jev.py`. It builds no second client.

## The candidate decision points, ranked by fit

| Rank | Decision point | Outcomes | Why it fits | Status |
| :--- | :--- | :--- | :--- | :--- |
| 1 | The screen before the verify step (#4282): skip the tool-using reviewer, or run it | skip, run, flag | The outcome is binary. The golden set labels the defects. The reviewer is the fallback. A skip saves an agent run. | Pilot 1 |
| 2 | The class of a failure when no regex rule matches (`src/devops_cli/roadmap/failure.py`) | one of the 19 `FailureClass` values, or `ci_infra` | A closed choice. The default is known. The stored failures are labelled by their typed causes. | Pilot 2, later |
| 3 | The tier of a stage run (#4284) | tier, high risk | A closed choice with a score. The real result is the label. | Shadow only, after the pilots |
| 4 | The `type/*` label of an intake item when the title gives none | one of the type labels | A closed choice over a short title. | Later, with bands |
| 5 | A tool call of an agent (`gate_tool_call_with_jev`) | run, review, block | Short evidence: the tool name and the arguments. | Never alone: it adds to a deterministic control |

## What is not suited

- **Any step that writes**: a plan, a pull request body, a comment, a finding or a quote. A finding that can stop a plan needs a quote from the input (`open_findings`), and Jev gives none.
- **A judgment of a long text as state**: the completeness of a diff (#4320). The answer did not follow the text.
- **A duplicate search**: a true duplicate is rare, and the answer needs the nearest items as evidence. Intake found 0 of 3 true duplicates with Jev. A decision step may flag a pair that an embedding search proposed. It does not search.
- **Priority, Value and Effort of an item with a guessed threshold**: the triage model leads on them. They return only with fitted thresholds and a *flag* band.
- **A question that needs the repository**: an agent with read tools answers it. A decision step may screen before such an agent. It does not replace the agent.
- **A security control used alone**: see rule 7.

## The pilots and their bars

The data of pilot 1 is the golden set of the stage job: 56 cases, 51 plans with 317 labelled defects and 5 good plans. A fixed split makes two halves. The reviewer is the model of the task `verification` (run with `deepseek-v4.1-flash-1017` for the baseline).

- **Pilot 1, the verify screen (#4282).** The screen decides before the reviewer runs. The cascade passes when, on the half that was not fitted, it loses no serious defect (blocker or major) that the reviewer alone finds on the same cases, **and** it skips at least 30% of the reviewer calls. The report also gives the false-clear rate and the cost of a plan with and without the screen. If the bar is not met, the setting stays off and the report states why, with the numbers and the best design found. The pull request of #4282 measured this bar. The reviewer alone found no serious defect in 9 of the 48 cases that it could review (19%), so the oracle of the golden set is below 30%, and no screen could meet the bar. A later bar for the same step must come from the oracle of its data.
- **Pilot 2, the failure-class tail (later).** `classify_failure` in `src/devops_cli/roadmap/failure.py` is a pure function of the evidence (`FailureEvidence`: the exit status, the error text, the refusal of a tool, the name of the check and the log of the check). Its rules run in order, and a failure that matches no rule is `ci_infra`, whose default action is one retry. The step adds a `Choice` question over the 19 `FailureClass` values, asked only when no rule matches and only about the evidence that code cuts: the last lines of the error text and of the check log, the check name and the exit status, with secrets masked. Its bands: *continue* takes the class when its probability reaches the fitted cut, *review* keeps `ci_infra` and its retry, and *flag* logs a failure that Jev puts in `oom`, `timeout` or `refused_tool` with a high probability, for a person to compare with the cause. The data is the first work item of the pilot: a failure that a rule matches has its class as a label, so the fit hides the phrase that the rule used, and the fallbacks need a sample that a person labels from the job records. The oracle is the share of fallbacks whose true class is `ci_infra`. The pilot passes when, on the half that was not fitted, the class that Jev takes equals the labelled class on the share of the taken cases that the bar fixes before the fit, with at least 7 days in shadow. A separate issue plans it, and it waits for the shared parts of pilot 1.

## Considered Options

- **Use Jev as the model of each step that a cheaper model could serve**: rejected. Three trials show that Jev does not write and does not read a long text.
- **Guess a threshold and tune it after a switch is on**: rejected. It was the cause of the failure of #4323 and #4282.
- **One rule for the cuts, fixed in advance**: rejected. Questions differ in base rate and scale, but a half of 24 cases cannot fit nine cuts. The fit runs both ways and the report shows both.
- **Replace the reviewer**: rejected. The reviewer reads the repository with tools and gives a quote. Jev does neither.
- **Wait for a better Jev**: rejected. The pattern holds for the next version, and the fit script repeats on its data.

## Consequences

- Each decision step is a small module on the shared parts, with a fit script, a data file of fitted thresholds and a shadow metric of bounded labels.
- A step that fails its bar stays off, and its report says why. The record does not promise a saving.
- The cost of a step is a Jev request for each piece, at about 0.042 USD for one million input tokens. The fit needs labelled data, and a step with no labelled data does not start.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
schema: spec-driven
created: 2026-11-10
skip_specs: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Design

## Decisions

- **The record is an ADR and a spec.** The ADR holds the reasons, the candidates and the bars. The spec holds the rules that a test can assert. Both follow `docs/adr/0018-*` and `openspec/specs/ai-ask-jev`.
- **Seven rules.** A decision point and not a generation point; tools extract the evidence into a short digest that Jev judges; many small questions in one request; thresholds fitted on labelled data with a fixed split and a swapped repeat; action bands; shadow first and fail open; a Jev answer is evidence and never the only control. Each rule answers a failure of the three trials.
- **The pilots.** Pilot 1 is the verify screen, because its outcome is binary, the golden set labels it, and the reviewer is the fallback. Pilot 2 is the failure-class tail, because it is a closed choice with a known default. Pilot 2 waits, so that the shared parts of pilot 1 are proved first.
- **The bar and its oracle.** A bar above the share of cases that need no run cannot be met. The ADR requires the oracle to be reported and checked before the first fit.
- **Shared parts, not a framework.** The ADR names one small module for the typed question set, the request builder, the fitted thresholds and bands, the log record and the fail-open rule. The code is in the pull request of #4282.

## Rejected alternatives

- **Use Jev as the model of every step that a cheaper model could serve.** Rejected: the completeness check (28% false holds, 43% recall) and the intake labels (0 of 3 duplicates) show that Jev does not write and does not read a long text.
- **Guess a threshold and tune it after a switch is on.** Rejected: the guessed thresholds of #4323 and #4282 are the cause of their failures.
- **One rule for the cuts, fixed in advance.** Rejected: questions differ in base rate, but a half of 24 cases cannot fit nine cuts. The fit runs both ways and the report shows both.
- **Let Jev replace the reviewer.** Rejected: the reviewer reads the repository with tools and gives a quote, and a finding that can stop a plan needs a quote.
- **Wait for a better Jev.** Rejected: the pattern holds for the next version, and the fit repeats on its data.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Proposal: The decision-step pattern for Jev decision points

## Why

Closes #4326. Three trials used TypeSafe Jev (`typesafe/jev-1.14`) as a cheaper model, and all three failed their gates: the completeness check of a draft pull request (#4320), the labels of an intake proposal (#4323) and the screen before the verify step (#4282, a guessed threshold and no data). On 2026-11-10 the owner decided that Jev is no drop-in replacement for a model that writes text, and that the workflows must change to fit a decision model. The project has no record of how a Jev decision point is built, so each trial made its own choices.

## What Changes

- New ADR `docs/adr/0019-a-decision-step-asks-jev-short-closed-questions-about-evidence-that-tools-extract.md`. It decides seven rules of a decision step, ranks the candidate decision points by fit, lists what a decision model is not suited for, and names two pilots with their success bars.
- New capability spec `decision-steps` with the requirements: a closed question set, an evidence builder that tools run, thresholds fitted on labelled data, action bands, a shadow log and a fail-open rule.
- No code changes. Pilot 1 (the verify screen) is the work of #4282. Pilot 2 (the failure-class tail) is planned in the ADR and built later.

## Capabilities

- `decision-steps`: new capability.

## Impact

- No behavior change. The record binds the next decision steps: a step that does not follow it needs a new record.
- #4282, #4284 and any later Jev step cite the record.

## Feasibility

- The three trials and their numbers are in the issues and pull requests #4320, #4323 and #4282. The premise (a decision model works on short closed questions) is from `devops ai ask-jev` and from the TypeSafe cookbooks (`https://docs.typesafe.ai/cookbooks`): the SDE cascade, the line-by-line search and the parallel questions cookbook use many small questions about pieces that code extracts.
- The `DecisionRequest`, `NoulQuestion`, `ChoiceQuestion` and `ScoreQuestion` types are in `pydantic_ai/models/decision.py` of the locked version. A request has one state and many named questions, so a question about another piece needs another request.
- The success bar of pilot 1 is measured on the golden set of the stage job (`tests/fixtures/roadmap_eval/stage`, 56 cases, 317 labelled defects) with `devops roadmap eval verify`. The measure is in the pull request of #4282.

## Existing Tool Considered

TypeSafe Jev through the `DecisionModel` of pydantic_ai, as `src/devops_cli/ai/jev.py` wraps it. The record builds no second client and no new library. The cost of the record is one document and one spec in one pull request. The fits need labelled data, which the golden sets already hold. The change fits one pull request.
Loading