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,2 @@
schema: spec-driven
created: 2026-11-14
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Design

## Decisions

- **Scan the plan texts for an absence word next to the word check or guard, the code span of the named check, and the code span of the call site, instead of adding a reply field.**: The plan of #3368 stated the claim in its Feasibility text, so a required reply field would not catch a prose claim and would change the reply schema and its prompt for no gain.
- **Keep the scan and the search in `src/devops_cli/roadmap/stage/stage_probe.py`, not in `stage_change.py`.**: The scan makes no plan finding: the job returns the item instead of sending the reply back to the model, so it is no rule of the plan check and no new gate.
- **Read the body of the call site and of the functions that it calls in the same file first, then search the source files of the staging commit, with the commands that the probe of the item has left.**: The helper that the plan missed sits beside its call site, and a whole-tree search first can report a check that the call site never calls. Sharing the commands of the one run keeps the item within the bound of 10 that the base spec states.
- **Reuse `FalsePremise` with a `PremiseKind` field instead of adding a new outcome class.**: `plan_stage`, `plan_item`, `apply_stage` and `fix_plan` already return a `FalsePremise` to New, so a second class would repeat each of those paths for the same write.
- **Record `refine.next_step` as `retry` for a claim, and keep `edit` for a false absence.**: The body of a duplicate item is correct and only the plan was wrong, so a body edit would wait for a change that no person needs to make.
- **Write the plan-level tests in `tests/roadmap/stage/test_roadmap_stage_plan.py` and seed the sample file with `advance_origin`.**: The module already holds the plan-level tests of the probe quote and of the return, and `advance_origin` is the helper that the module already uses to add a file to the staging commit.

## Rejected alternatives

- **Search the whole base tree first and report the first line that holds the check.**: `src/devops_cli/roadmap/implement/implement_run.py:1463:def _delivery_title(self) -> str:` shows that the check sits one call below the cited site: a tree-first search reports the definition of the title check in another module, not the call in the helper that the plan missed, and it can name a check that the call site never reaches.
- **Ask the verifier model to find the claim in the plan.**: ADR 0005 keeps a finding deterministic and from a tool, and `docs/adr/0005-review-findings-come-from-tools-not-models.md` rejects a model verdict on a code claim, so the search is a read-only tool answer.
- **Add a required `missing_checks` field to `StageProposal`.**: The refused plan of #3368 made the claim in its Feasibility text, so a field that a model may leave empty catches no prose claim and changes the reply schema.
- **Stop the item as Blocked instead of returning it to New.**: `src/devops_cli/roadmap/stage/stage.py:925:class FalsePremise:` is the outcome that returns an item to New, and the issue asks for that return with the evidence, not for a stop.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Proposal

## Why

A stage plan of #3368 said that the implement job writes the delivery title with no check, while the helper that both call sites call already ran that check. The plan read the two call sites and not the body of the helper, so it duplicated a guard that the base holds and added a requirement that the base spec already states. For #3416, the premise probe must find a claimed missing check in the helpers of a cited call site and in the base tree, and the stage job must return the item with that evidence instead of planning a duplicate.

## What Changes

- Add `claimed_missing_checks` and `check_claims` to `src/devops_cli/roadmap/stage/stage_probe.py`: the scan of the plan texts for a claim that a call site runs no named check, and the read-only search of the call site's body, the helpers that it calls in its file, and the source files of the staging commit.
- Add the `left` field to `Probe` and the probe message that names the path and the line of a check that a plan says is missing, in `src/devops_cli/lang/en/messages.py`.
- Return the item to New from `src/devops_cli/roadmap/stage/stage.py` when the search finds the check, with a `PremiseKind.MISSING_CHECK` kind on `FalsePremise`, a comment that names the path and the line, and `refine.next_step` `retry`.
- Add the probe tests to `tests/roadmap/stage/test_roadmap_stage_probe.py` and the plan-level tests to `tests/roadmap/stage/test_roadmap_stage_plan.py`.
- Add two requirements to `openspec/specs/roadmap-stage/premise/spec.md` and change the return requirement of `openspec/specs/roadmap-stage/returns/spec.md` through the spec delta of the change.
- The change fits one pull request.

## Capabilities

### New Capabilities

None.

### Modified Capabilities

- `roadmap-stage/premise`: The job probes a claimed missing check in a helper of its call site, The job searches the base tree for a claimed missing check
- `roadmap-stage/returns`: A false absence or a claimed missing check returns the item

## Impact

- Code: `src/devops_cli/roadmap/stage/stage_probe.py`, `src/devops_cli/lang/en/messages.py`, `src/devops_cli/roadmap/stage/stage.py`
- Tests: `tests/roadmap/stage/test_roadmap_stage_probe.py`, `tests/roadmap/stage/test_roadmap_stage_plan.py`

## Feasibility

- The premise of the issue holds, and the path that it cites moved. `probes` says: "The path `src/devops_cli/roadmap/implement_run.py` is no file at the root of the staging commit. These files of the commit are candidates: `src/devops_cli/roadmap/implement/implement_run.py`. Commit bff2f14f 2026-11-06 refactor(roadmap): group the job modules in subpackages (#3897) deleted or renamed it."
- `read_file` of the staged file shows the check in the helper: `src/devops_cli/roadmap/implement/implement_run.py:1463:def _delivery_title(self) -> str:`, then `src/devops_cli/roadmap/implement/implement_run.py:1475:if not title_problems(title, declared):` and `src/devops_cli/roadmap/implement/implement_run.py:1480:raise _StopError(`. The issue cites line 957 of the old path, so its line number is stale.
- `search_code` for `_delivery_title(` shows the two call sites of the helper: `src/devops_cli/roadmap/implement/implement_run.py:1434:title = self._delivery_title()` and `src/devops_cli/roadmap/implement/implement_run.py:1551:delivery_title = self._delivery_title()`. A plan that reads only those two lines misses the body of the helper, which is the defect of #3368.
- The base spec that the issue cites moved too: `probes` says "Commit dfb09bd1 2026-11-12 refactor(openspec): split big capabilities into nested ones (#4981) deleted or renamed it." The plan adds no requirement about the delivery title, so it duplicates no base requirement. The text of the nested capability `roadmap-implement-job/pull-request` is not checked by this run.
- The plan uses the staged paths that `probes` names: "The path `src/devops_cli/roadmap/stage_probe.py` is no file at the root of the staging commit. These files of the commit are candidates: `src/devops_cli/roadmap/stage/stage_probe.py`", "The path `src/devops_cli/roadmap/stage.py` is no file at the root of the staging commit. These files of the commit are candidates: `src/devops_cli/ai/spend/stage.py`, `src/devops_cli/roadmap/stage/stage.py`", and "The path `tests/roadmap/test_roadmap_stage_plan.py` is no file at the root of the staging commit. These files of the commit are candidates: `tests/roadmap/stage/test_roadmap_stage_plan.py`. Commit bff2f14f 2026-11-06 refactor(roadmap): group the job modules in subpackages (#3897) deleted or renamed it."
- The probe and the settle step exist at the staged commit: `src/devops_cli/roadmap/stage/stage_probe.py:341:def probe_premise(source: Path, sha: str, body: str) -> Probe:` returns the lines that the model reads, and `src/devops_cli/roadmap/stage/stage.py:2121:-> StagedChange | OverBudget | _Refused:` is the return of the settle step that every reply reaches. `src/devops_cli/roadmap/stage/stage_probe.py:class Probe` and `src/devops_cli/roadmap/stage/stage_probe.py:class _Run` already hold the false premises and the commands left.
- The bound is staged as `src/devops_cli/config/constants.py:3454:CONST_ROADMAP_STAGE_PROBE_MAX_COMMANDS: Final[int] = 10`, and `src/devops_cli/roadmap/stage/stage_probe.py:125:left: int = CONST_ROADMAP_STAGE_PROBE_MAX_COMMANDS` applies it. The claim search spends the commands that the probe of the item has left, so the item runs at most 10 commands and the plan changes no base requirement about the bound.
- The claim search reads a file of the commit with `git cat-file -p <sha>:<path>`, which is one of the three commands that `The probes are bounded and read-only` names, so the plan leaves that base requirement as it is.
- Precondition of the call `definition_lines(source, sha, name, git, commands=...)`: a checkout of the repository, because `src/devops_cli/roadmap/premise.py:94:def definition_lines(` runs `git grep` at the staging commit; it needs no client and no network.
- Precondition of the call `check_claims(source, sha, claims, left)`: a checkout of the repository, because each of its commands is a read-only git command at the staging commit; it needs no client and no network.
- Precondition of the call `claimed_missing_checks(texts)`: none, because it reads the plan texts of the reply and nothing else.
- The return that the plan reuses exists: `src/devops_cli/roadmap/stage/stage.py:925:class FalsePremise:` is an outcome of `plan()`, and `src/devops_cli/roadmap/stage/stage.py:3568:def _return_premise(store: RoadmapStore, premise: FalsePremise) -> None:` writes the comment and the Status New. `src/devops_cli/lang/en/messages.py:4016:stage_returned_premise: str = (` and `src/devops_cli/lang/en/messages.py:4021:stage_returned_premise_line: str = (` are the messages that the new kind picks apart.
- The plan answers the findings of the check: the two new premise requirements hold 438 and 365 characters, both under 500, and the plan no longer modifies `The probes are bounded and read-only`, so the base scenario that names `shared_helper` stays out of the delta and needs no new test.
- The first checks of the implementation against the real system are `uv run devops ci test tests/roadmap/stage/test_roadmap_stage_probe.py`, `uv run devops ci test tests/roadmap/stage/test_roadmap_stage_plan.py`, `uv run devops openspec check` and `uv run devops ci docs`.
- The verify programs need no new runner capability: `uv`, `python`, `devops` and `pytest` are image tools, the pod runs with `readOnlyRootFilesystem: true`, `runAsNonRoot: true` and `capabilities.drop: ALL`, and a failing check is the failure class `test`.
- The plan-level test writes the sample file into the clone with `advance_origin`, which `tests/roadmap/stage/test_roadmap_stage_plan.py:247` already calls, so the tests reach no network, no cluster and no scanner.
- This run did not read #3368, #3374 or #3319 on GitHub, so the plan makes no claim about their state: not checked.

## Existing Tool Considered

No open, maintained tool checks a code premise across a call chain, and the issue's alternatives check found none. The premise probe is the repository's own tool, and this change extends it: about 8k tokens to build and test, about 1.5k tokens to keep and fix, and about 3 hours elapsed. The change deletes no internal code.

## Dependencies

None.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## ADDED Requirements

### Requirement: The job probes a claimed missing check in a helper of its call site
After the model reply and before it writes a branch or a pull request, the stage job SHALL read the body of a call site that a plan text says runs no named check, and the body of each helper that the call site calls in its file. The job SHALL write one line that names the path and the line of a check that it finds there, and SHALL send no model request for the read. A claim that names no call site and no named check SHALL add no line.

#### Scenario: A helper of the call site holds the check
- **WHEN** a plan text says that the call site `_publish` runs no `title_problems` check, and `_publish` calls `_delivery_title`, whose body calls `title_problems`
- **THEN** the probe line names `title_problems` at the path and the line of its call in `_delivery_title`

#### Scenario: A claim with no cited call site
- **WHEN** a plan says that a check is missing but names no call site and no check
- **THEN** the probe adds no line and the stage job plans the item as before

#### Scenario: A claim is probed with no model call
- **WHEN** a plan claims a missing check and the stage job probes it
- **THEN** the stage job sends no model request for the read

### Requirement: The job searches the base tree for a claimed missing check
The stage job SHALL search the source files of the staging commit for a named check that a plan text says is missing, when the cited call site and its helpers do not hold it. The search SHALL use the git commands that the probe of the item has left, SHALL run only read-only commands at the staging commit, and SHALL list a claim as skipped when no command is left.

#### Scenario: A check that only another file holds
- **WHEN** a plan says that a call site runs no named check, and only another source file of the staging commit holds that check
- **THEN** the probe line names the path and the line of the check in that file

#### Scenario: The bound leaves a claim unprobed
- **WHEN** a plan claims more missing checks than the commands that are left
- **THEN** the probe lists the claim as skipped and runs no further command
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## MODIFIED Requirements

### Requirement: A false absence or a claimed missing check returns the item
The stage job SHALL return an item to New with the probe evidence when the issue body states that a cited class field is absent and the staging commit defines it, and SHALL make no model call for that item. The stage job SHALL return an item to New with the probe evidence when a plan text says that a cited call site runs no named check and the staging commit holds it, and SHALL write no branch and open no pull request for that item.

#### Scenario: The body says a field is absent while the class defines it
- **WHEN** The body says that `PullStatus` defines no `labels` and `PullStatus` at the staging commit defines `labels`
- **THEN** The stage job returns the item to New, and its comment quotes the probe line that names the file and line of `labels`

#### Scenario: The item waits on a body edit
- **WHEN** The body states that a cited class field is absent and the staging commit defines it
- **THEN** The stage job records `refine.next_step` as `edit` for the item

#### Scenario: A plan that claims a check the base holds
- **WHEN** a plan says that `_publish` runs no `title_problems` check, and the staging commit holds `title_problems` in a helper of `_publish`
- **THEN** the stage job returns the item to New, writes no branch, opens no pull request, and its comment quotes the line that names the path and the line of `title_problems`

## RENAMED Requirements

- FROM: `### Requirement: A false absence returns the item`
- TO: `### Requirement: A false absence or a claimed missing check returns the item`
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Tasks

## 1. Add the missing-check claim search to the premise probe

Kind: behavior. Reads: `src/devops_cli/roadmap/stage/stage_probe.py`, `src/devops_cli/roadmap/premise.py`, `src/devops_cli/roadmap/refine/refine.py`, `src/devops_cli/lang/en/messages.py`, `tests/roadmap/stage/test_roadmap_stage_probe.py`. Changes: `src/devops_cli/roadmap/stage/stage_probe.py`, `src/devops_cli/lang/en/messages.py`, `tests/roadmap/stage/test_roadmap_stage_probe.py`.

- [ ] 1.1 Write `test_a_check_in_a_helper_body_of_the_call_site_is_found`, `test_a_check_that_only_another_file_holds_names_its_path_and_line`, `test_a_claim_with_no_call_site_adds_no_line` and `test_a_claim_with_no_command_left_is_skipped` in `tests/roadmap/stage/test_roadmap_stage_probe.py` first
- Verification: `$ uv run devops ci test tests/roadmap/stage/test_roadmap_stage_probe.py` fails on the base
- [ ] 1.2 Add to `src/devops_cli/roadmap/stage/stage_probe.py`: `claimed_missing_checks(texts)` reads each line that holds an absence word before the word check or guard and the code span of the named check on either side of that word, takes the other code-spanned identifier of the line as the call site, and returns each pair once. `check_claims(source, sha, claims, left)` starts a `_Run` with the commands left, and for each claim reads the definition of the call site with `definition_lines` and `commands=self.left`, reads that file once with `git cat-file -p <sha>:<path>`, searches the body of the call site and the body of each function that body calls in the same file, then searches `SYMBOL_PATHSPECS` with one `git grep -n -w`, and appends the message `stage_probe_claim_found` with the path and the line of the check to `false_premises`. A claim with no command left goes to `skipped`, and a search that does not finish adds no line. Add the `left` field to `Probe` and set it from `run.left` in `probe_premise`, the helpers `_functions` and `_callees`, the export of both new functions, and the message to `src/devops_cli/lang/en/messages.py`
- Verification: `$ uv run devops ci test tests/roadmap/stage/test_roadmap_stage_probe.py` passes

## 2. Return the item when a plan claims a check that the base holds

Kind: behavior. Reads: `src/devops_cli/roadmap/stage/stage.py`, `src/devops_cli/roadmap/stage/stage_probe.py`, `src/devops_cli/lang/en/messages.py`, `tests/roadmap/stage/test_roadmap_stage_plan.py`. Changes: `src/devops_cli/roadmap/stage/stage.py`, `src/devops_cli/lang/en/messages.py`, `tests/roadmap/stage/test_roadmap_stage_plan.py`.

- [ ] 2.1 Write `test_a_plan_that_claims_a_missing_check_in_a_helper_returns_the_item` and `test_a_plan_that_claims_a_missing_check_that_the_base_lacks_stays_ready` in `tests/roadmap/stage/test_roadmap_stage_plan.py` first. The first seeds `_publish`, `_delivery_title` and `title_problems` in the sample file with `advance_origin` and asserts the comment, the `FalsePremise` kind and `refine.next_step`; the second asserts that the plan stays ready and records no premise
- Verification: `$ uv run devops ci test tests/roadmap/stage/test_roadmap_stage_plan.py` fails on the base
- [ ] 2.2 Add `PremiseKind` with `ABSENT_FIELD` and `MISSING_CHECK`, and the `kind` field of `FalsePremise` with `ABSENT_FIELD` as its default, to `src/devops_cli/roadmap/stage/stage.py`. Keep the commands that the probe has left on `_Planner`, and add `_Planner._claim_premise`, which calls `claimed_missing_checks` on the texts that `_settle` builds and `check_claims` on the staging commit with those commands, and call it first in `_settle`, whose result becomes `StagedChange | OverBudget | FalsePremise | _Refused`. Widen the return type of `_gated`, `_returned` and `_note_gates`, and return `PlanRevision(premise)` for a `FalsePremise` in `revise`. In `_return_premise` pick `stage_returned_claim` with `NextStep.RETRY` for `MISSING_CHECK`, and in the run report pick `stage_returned_claim_line`. Add both messages to `src/devops_cli/lang/en/messages.py`
- Verification: `$ uv run devops ci test tests/roadmap/stage/test_roadmap_stage_plan.py` passes

## Workflow follow-up

- Pending a person: review the diff in tuicr (tuicr -r <base>..HEAD).