From 90608f7d2975ab12aebfe6dbdcffaa948e949b09 Mon Sep 17 00:00:00 2001 From: Daniel Petty Date: Tue, 10 Nov 2026 04:42:55 +0000 Subject: [PATCH 1/2] docs(roadmap): the decision-step pattern for Jev decision points ADR 0019 decides seven rules for a Jev decision step, ranks the candidate decision points, lists what a decision model is not suited for, and names two pilots with their bars. The capability spec decision-steps holds the rules a test can assert. Plans #4326 --- ...tions-about-evidence-that-tools-extract.md | 77 +++++++++++++++++++ .../.openspec.yaml | 3 + .../design.md | 17 ++++ .../proposal.md | 30 ++++++++ .../specs/decision-steps/spec.md | 65 ++++++++++++++++ .../tasks.md | 15 ++++ 6 files changed, 207 insertions(+) create mode 100644 docs/adr/0019-a-decision-step-asks-jev-short-closed-questions-about-evidence-that-tools-extract.md create mode 100644 openspec/changes/4326-the-decision-step-pattern-for-jev/.openspec.yaml create mode 100644 openspec/changes/4326-the-decision-step-pattern-for-jev/design.md create mode 100644 openspec/changes/4326-the-decision-step-pattern-for-jev/proposal.md create mode 100644 openspec/changes/4326-the-decision-step-pattern-for-jev/specs/decision-steps/spec.md create mode 100644 openspec/changes/4326-the-decision-step-pattern-for-jev/tasks.md diff --git a/docs/adr/0019-a-decision-step-asks-jev-short-closed-questions-about-evidence-that-tools-extract.md b/docs/adr/0019-a-decision-step-asks-jev-short-closed-questions-about-evidence-that-tools-extract.md new file mode 100644 index 0000000000..7451cc02c9 --- /dev/null +++ b/docs/adr/0019-a-decision-step-asks-jev-short-closed-questions-about-evidence-that-tools-extract.md @@ -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. diff --git a/openspec/changes/4326-the-decision-step-pattern-for-jev/.openspec.yaml b/openspec/changes/4326-the-decision-step-pattern-for-jev/.openspec.yaml new file mode 100644 index 0000000000..d33c6d5ae8 --- /dev/null +++ b/openspec/changes/4326-the-decision-step-pattern-for-jev/.openspec.yaml @@ -0,0 +1,3 @@ +schema: spec-driven +created: 2026-11-10 +skip_specs: false diff --git a/openspec/changes/4326-the-decision-step-pattern-for-jev/design.md b/openspec/changes/4326-the-decision-step-pattern-for-jev/design.md new file mode 100644 index 0000000000..8751ce4dc9 --- /dev/null +++ b/openspec/changes/4326-the-decision-step-pattern-for-jev/design.md @@ -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. diff --git a/openspec/changes/4326-the-decision-step-pattern-for-jev/proposal.md b/openspec/changes/4326-the-decision-step-pattern-for-jev/proposal.md new file mode 100644 index 0000000000..44c1258914 --- /dev/null +++ b/openspec/changes/4326-the-decision-step-pattern-for-jev/proposal.md @@ -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. diff --git a/openspec/changes/4326-the-decision-step-pattern-for-jev/specs/decision-steps/spec.md b/openspec/changes/4326-the-decision-step-pattern-for-jev/specs/decision-steps/spec.md new file mode 100644 index 0000000000..766a390488 --- /dev/null +++ b/openspec/changes/4326-the-decision-step-pattern-for-jev/specs/decision-steps/spec.md @@ -0,0 +1,65 @@ +## Purpose + +A decision step is a place in a workflow where Jev (a System One decision model) gives evidence for a pick among a few known outcomes. This capability fixes the rules that every decision step follows: 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. The rules come from ADR 0019. + +## ADDED Requirements + +### Requirement: A decision step uses a closed question set +A decision step SHALL ask Jev only the questions of a set that its code fixes. Each question SHALL be a yes/no, a choice or a score question about one short piece of evidence. A decision step SHALL NOT write a text, a quote or a finding from a Jev answer. + +#### Scenario: The question set is fixed +- **WHEN** a test builds the request of a decision step for two different inputs +- **THEN** both requests hold the same question names for the same kinds of piece, and no question text comes from the input + +#### Scenario: The step writes no text +- **WHEN** Jev answers a request of a decision step +- **THEN** the outcome of the step is one band of the closed set, and no text of the answer reaches a comment, a finding or a file + +### Requirement: Tools extract the evidence +A decision step SHALL build the state of a request in code from the input, as a digest of short pieces and of facts that tools found: a hunk, a path, a quoted line, a test name, a criterion or a fact of a tool call. Each piece SHALL be limited in size. The state of a request SHALL NOT be the whole document. + +#### Scenario: A long input is cut to a digest +- **WHEN** the evidence builder gets an input with long texts +- **THEN** the state it returns holds each text cut to its size limit, and holds the facts that the tools found as facts + +### Requirement: Cuts are data that a fit set +A decision step SHALL read the cuts of its questions from a data file in the repository. The file SHALL record the model, the date, the cases of the fit and the numbers that gave each value. A decision step SHALL NOT take a cut from a constant that nobody fitted. + +#### Scenario: Thresholds are data +- **WHEN** a test loads the thresholds of a decision step +- **THEN** each question of the step has a cut in the data file, and the file names the model and the cases of its fit + +### Requirement: The fit uses fixed halves and is repeated +A fit SHALL use one fixed half of the labelled cases, and the report SHALL use the other half. The fit SHALL repeat with the halves swapped. It SHALL run with a cut for each question and with one cut for all questions, and the report SHALL give the loss of both and the number of cases in each half. + +#### Scenario: The halves are fixed +- **WHEN** the fit command runs twice on the same cases +- **THEN** it uses the same two halves both times, and it reports the numbers of the half that it did not fit + +### Requirement: The success bar is checked against its oracle +The report of a decision step SHALL state the oracle: the most cases that any step can skip with no loss on its labelled data. A success bar that asks for more than the oracle SHALL NOT be set. + +#### Scenario: The oracle is reported +- **WHEN** the fit command reports a step +- **THEN** the report gives the oracle beside the saving of the step, and says that the bar cannot be met when the bar is above the oracle + +### Requirement: A decision step has action bands +The outcome of a decision step SHALL be one band of at least three: continue (the cheap or existing path), send to the reviewer (the costly path) and flag (the case goes to the log for a person). The thresholds of the questions SHALL give the band. + +#### Scenario: Each band is reachable +- **WHEN** a test gives the step answers below, between and above the fitted thresholds +- **THEN** the step returns the continue band, the reviewer band and the flag band + +### Requirement: A decision step runs in shadow before a switch +A decision step SHALL have a setting that is off by default. A step with a shadow mode SHALL, in that mode, log and count its band beside the real result and SHALL change nothing else. The metric SHALL have labels with a bounded set of values, and the documents SHALL state its series count. + +#### Scenario: Shadow changes nothing +- **WHEN** a decision step runs in shadow mode with a fake Jev +- **THEN** the real path runs as with the setting off, one log record and one counter increment name the band, and the result of the workflow is equal + +### Requirement: A decision step fails open +A decision step SHALL send the case to the existing path when Jev raises an error, times out, leaves a question unanswered, or answers with a confidence below the fitted floor. It SHALL log the cause. A Jev answer SHALL NOT be the only security control of any path. + +#### Scenario: Jev fails +- **WHEN** a decision step gets an error from Jev +- **THEN** the existing path runs and one log record names the error diff --git a/openspec/changes/4326-the-decision-step-pattern-for-jev/tasks.md b/openspec/changes/4326-the-decision-step-pattern-for-jev/tasks.md new file mode 100644 index 0000000000..ea5863787d --- /dev/null +++ b/openspec/changes/4326-the-decision-step-pattern-for-jev/tasks.md @@ -0,0 +1,15 @@ +# Tasks + +## 1. Write the record + +Reads: `docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md`, `src/devops_cli/ai/jev.py`, `src/devops_cli/ai/jev_ask.py`, `src/devops_cli/roadmap/failure.py`. Changes: `docs/adr/0019-a-decision-step-asks-jev-short-closed-questions-about-evidence-that-tools-extract.md` (new), `openspec/specs/decision-steps/spec.md` (new, by archive). + +- [x] 1.1 Add the ADR with the status, the context of the three trials, the seven rules, the ranked candidates, the list of what is not suited, the two pilots with their bars, the considered options and the consequences + - Verification: `$ uv run devops ci docs` +- [x] 1.2 Add the capability spec `decision-steps` with the requirements for the closed question set, the evidence, the fitted thresholds, the bands, the shadow log and the fail-open rule + - Verification: `$ uv run devops openspec check` + +## Workflow follow-up + +- Pilot 1, the verify screen, is issue #4282. +- Pilot 2, the failure-class tail, waits for the shared parts of pilot 1. A person files it after pilot 1 is measured. From 74af15608356022e3fc4aa7be5f5a9c706cddc09 Mon Sep 17 00:00:00 2001 From: Daniel Petty Date: Tue, 10 Nov 2026 05:04:54 +0000 Subject: [PATCH 2/2] chore(openspec): archive 4326-the-decision-step-pattern-for-jev --- .../.openspec.yaml | 0 .../design.md | 0 .../proposal.md | 0 .../specs/decision-steps/spec.md | 0 .../tasks.md | 0 openspec/specs/decision-steps/spec.md | 66 +++++++++++++++++++ 6 files changed, 66 insertions(+) rename openspec/changes/{4326-the-decision-step-pattern-for-jev => archive/2026-11-10-4326-the-decision-step-pattern-for-jev}/.openspec.yaml (100%) rename openspec/changes/{4326-the-decision-step-pattern-for-jev => archive/2026-11-10-4326-the-decision-step-pattern-for-jev}/design.md (100%) rename openspec/changes/{4326-the-decision-step-pattern-for-jev => archive/2026-11-10-4326-the-decision-step-pattern-for-jev}/proposal.md (100%) rename openspec/changes/{4326-the-decision-step-pattern-for-jev => archive/2026-11-10-4326-the-decision-step-pattern-for-jev}/specs/decision-steps/spec.md (100%) rename openspec/changes/{4326-the-decision-step-pattern-for-jev => archive/2026-11-10-4326-the-decision-step-pattern-for-jev}/tasks.md (100%) create mode 100644 openspec/specs/decision-steps/spec.md diff --git a/openspec/changes/4326-the-decision-step-pattern-for-jev/.openspec.yaml b/openspec/changes/archive/2026-11-10-4326-the-decision-step-pattern-for-jev/.openspec.yaml similarity index 100% rename from openspec/changes/4326-the-decision-step-pattern-for-jev/.openspec.yaml rename to openspec/changes/archive/2026-11-10-4326-the-decision-step-pattern-for-jev/.openspec.yaml diff --git a/openspec/changes/4326-the-decision-step-pattern-for-jev/design.md b/openspec/changes/archive/2026-11-10-4326-the-decision-step-pattern-for-jev/design.md similarity index 100% rename from openspec/changes/4326-the-decision-step-pattern-for-jev/design.md rename to openspec/changes/archive/2026-11-10-4326-the-decision-step-pattern-for-jev/design.md diff --git a/openspec/changes/4326-the-decision-step-pattern-for-jev/proposal.md b/openspec/changes/archive/2026-11-10-4326-the-decision-step-pattern-for-jev/proposal.md similarity index 100% rename from openspec/changes/4326-the-decision-step-pattern-for-jev/proposal.md rename to openspec/changes/archive/2026-11-10-4326-the-decision-step-pattern-for-jev/proposal.md diff --git a/openspec/changes/4326-the-decision-step-pattern-for-jev/specs/decision-steps/spec.md b/openspec/changes/archive/2026-11-10-4326-the-decision-step-pattern-for-jev/specs/decision-steps/spec.md similarity index 100% rename from openspec/changes/4326-the-decision-step-pattern-for-jev/specs/decision-steps/spec.md rename to openspec/changes/archive/2026-11-10-4326-the-decision-step-pattern-for-jev/specs/decision-steps/spec.md diff --git a/openspec/changes/4326-the-decision-step-pattern-for-jev/tasks.md b/openspec/changes/archive/2026-11-10-4326-the-decision-step-pattern-for-jev/tasks.md similarity index 100% rename from openspec/changes/4326-the-decision-step-pattern-for-jev/tasks.md rename to openspec/changes/archive/2026-11-10-4326-the-decision-step-pattern-for-jev/tasks.md diff --git a/openspec/specs/decision-steps/spec.md b/openspec/specs/decision-steps/spec.md new file mode 100644 index 0000000000..1b8880d8eb --- /dev/null +++ b/openspec/specs/decision-steps/spec.md @@ -0,0 +1,66 @@ +# decision-steps Specification + +## Purpose +A decision step is a place in a workflow where Jev (a System One decision model) gives evidence for a pick among a few known outcomes. This capability fixes the rules that every decision step follows: 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. The rules come from ADR 0019. + +## Requirements + +### Requirement: A decision step uses a closed question set +A decision step SHALL ask Jev only the questions of a set that its code fixes. Each question SHALL be a yes/no, a choice or a score question about one short piece of evidence. A decision step SHALL NOT write a text, a quote or a finding from a Jev answer. + +#### Scenario: The question set is fixed +- **WHEN** a test builds the request of a decision step for two different inputs +- **THEN** both requests hold the same question names for the same kinds of piece, and no question text comes from the input + +#### Scenario: The step writes no text +- **WHEN** Jev answers a request of a decision step +- **THEN** the outcome of the step is one band of the closed set, and no text of the answer reaches a comment, a finding or a file + +### Requirement: Tools extract the evidence +A decision step SHALL build the state of a request in code from the input, as a digest of short pieces and of facts that tools found: a hunk, a path, a quoted line, a test name, a criterion or a fact of a tool call. Each piece SHALL be limited in size. The state of a request SHALL NOT be the whole document. + +#### Scenario: A long input is cut to a digest +- **WHEN** the evidence builder gets an input with long texts +- **THEN** the state it returns holds each text cut to its size limit, and holds the facts that the tools found as facts + +### Requirement: Cuts are data that a fit set +A decision step SHALL read the cuts of its questions from a data file in the repository. The file SHALL record the model, the date, the cases of the fit and the numbers that gave each value. A decision step SHALL NOT take a cut from a constant that nobody fitted. + +#### Scenario: Thresholds are data +- **WHEN** a test loads the thresholds of a decision step +- **THEN** each question of the step has a cut in the data file, and the file names the model and the cases of its fit + +### Requirement: The fit uses fixed halves and is repeated +A fit SHALL use one fixed half of the labelled cases, and the report SHALL use the other half. The fit SHALL repeat with the halves swapped. It SHALL run with a cut for each question and with one cut for all questions, and the report SHALL give the loss of both and the number of cases in each half. + +#### Scenario: The halves are fixed +- **WHEN** the fit command runs twice on the same cases +- **THEN** it uses the same two halves both times, and it reports the numbers of the half that it did not fit + +### Requirement: The success bar is checked against its oracle +The report of a decision step SHALL state the oracle: the most cases that any step can skip with no loss on its labelled data. A success bar that asks for more than the oracle SHALL NOT be set. + +#### Scenario: The oracle is reported +- **WHEN** the fit command reports a step +- **THEN** the report gives the oracle beside the saving of the step, and says that the bar cannot be met when the bar is above the oracle + +### Requirement: A decision step has action bands +The outcome of a decision step SHALL be one band of at least three: continue (the cheap or existing path), send to the reviewer (the costly path) and flag (the case goes to the log for a person). The thresholds of the questions SHALL give the band. + +#### Scenario: Each band is reachable +- **WHEN** a test gives the step answers below, between and above the fitted thresholds +- **THEN** the step returns the continue band, the reviewer band and the flag band + +### Requirement: A decision step runs in shadow before a switch +A decision step SHALL have a setting that is off by default. A step with a shadow mode SHALL, in that mode, log and count its band beside the real result and SHALL change nothing else. The metric SHALL have labels with a bounded set of values, and the documents SHALL state its series count. + +#### Scenario: Shadow changes nothing +- **WHEN** a decision step runs in shadow mode with a fake Jev +- **THEN** the real path runs as with the setting off, one log record and one counter increment name the band, and the result of the workflow is equal + +### Requirement: A decision step fails open +A decision step SHALL send the case to the existing path when Jev raises an error, times out, leaves a question unanswered, or answers with a confidence below the fitted floor. It SHALL log the cause. A Jev answer SHALL NOT be the only security control of any path. + +#### Scenario: Jev fails +- **WHEN** a decision step gets an error from Jev +- **THEN** the existing path runs and one log record names the error