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
2 changes: 1 addition & 1 deletion docs/ROADMAP_WORKFLOW.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ uv run devops roadmap eval verify --case 2260 --dry-run

- **The cost.** An agent run reads until it has its findings, so the cost of a run depends on the model. On 2026-11-05 one case with the local verification model used 27 model requests, 18 tool calls and 578,119 input tokens in about 6 minutes, so a run of the whole set costs that amount times the number of cases. `--dry-run` lists the runs and not the tokens.
- **The run** reads the files that each recorded plan cites from the commit it was staged on, so `--source` must be a repository that holds those commits. It runs the pass of each case as an agent with the read tools of the planner, on the checkout of the case (#3039). It leaves out a case that holds no commit and names it in the report (`left_out`). It matches each finding to one labeled defect of the same type, the most serious defect first, and prints the recall of all labeled defects, the recall of the blocker and major ones, the recall for each type, and the findings on the good plans. It stores the report, with the findings of each case, as JSON under the data directory, in `roadmap_eval/verify/`.
- **A stopped run.** The run names its report file when it starts, and writes the file again when each case ends, so a stop keeps the cases that ended. `--resume <report>` runs only the cases that the report lacks or that failed in it, keeps the other cases, and updates the same file (#4344). The model of the run must be the model of the report. To split the set between processes, give each process its own `--case` options, and resume each process from its own file.
- **A stopped run.** The run creates its own report file when it starts: a unique part follows the time stamp in the name, so two runs that start in the same second get two files (#4488). The run writes the file again when each case ends, so a stop keeps the cases that ended. `--resume <report>` runs only the cases that the report lacks or that failed in it, keeps the other cases, and updates the same file (#4344). The model of the run must be the model of the report. To split the set between processes, give each process its own `--case` options, and resume each process from its own file.
- **How to read the score.** The match is by type and not by text, so a finding of the right type on the wrong spot counts. Read the findings in the report before you trust a high recall. A finding on a good plan is a false alarm. The score also counts those that would send the plan back to the planner.
- **The rule.** A pull request that changes the verification prompt (`roadmap_stage_verify.md` or `roadmap_stage_verify_tools.md`) or the model of the task states the score of the model before and after the change.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-11-11
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Design

## Decisions

- **Put the unique store file helper in `src/devops_cli/core/repo.py`, next to `resolve_store_path`.**: That module already resolves a store name under the data directory, so the folder and the file name stay in one place and every eval command can call it.
- **Create the file with `tempfile.mkstemp`, then close its descriptor and keep the path for every later write.**: One standard-library call creates the file exclusively and gives a unique name, and the project uses the same call in `write_report`.
- **Take the time stamp of the name from the clock, and freeze the clock in the tests with time-machine.**: The project lists time-machine as a development dependency and docs/TESTING.md names it for a faked wall clock, so the helper needs no time parameter, and the name still shows when the run started.
- **Resolve the store folder inside the helper and create it with `mkdir(parents=True, exist_ok=True)` before `mkstemp`.**: `mkstemp` creates a file but not a missing directory, and the project's `write_report` makes the directory first for the same reason.
- **Replace the stamp line of the command with `resume or create_store_file(_STORE)`.**: `--resume` stays a plain path that creates no new file, and a run without it gets a new file; the existing command tests already prove the per-case write and the resume.
- **Test two runs that write at the same time through the command, with the second run on its own thread.**: The first run waits in its model call while the second run starts in the same frozen second and writes its report, which is the order of two parallel processes. A second run on the same thread meets the running event loop of the first run.
- **Leave the stage, screen and completeness eval commands unchanged.**: Their stamp comes after a long run, so the reported collision does not apply to them, and the shared helper is ready when one of them needs it.

## Rejected alternatives

- **Create the report file with `open(path, "x")` and a counter suffix after `FileExistsError`.**: It needs a retry loop and more code for the same result, while `tempfile.mkstemp` creates the file exclusively in one call at `src/devops_cli/roadmap/implement/implement_eval_run.py:457:tempfile.mkstemp(prefix=f"implement-{stamp}-"`.
- **Add `secrets.token_hex(3)` to the stamp, as `src/devops_cli/ai/run_store.py` does.**: A random suffix makes a collision unlikely but does not create the file exclusively, so two processes can still choose one name and replace each other's cases.
- **Change all four eval commands in this pull request.**: The issue reports the collision for `roadmap_eval_verify.py` only, and the other three take their stamp at the end of a long run, so changing them adds unproven work to this pull request.
- **Give the helper an optional moment for the test.**: It adds a parameter only for tests, while time-machine freezes the clock with no change to the code.
- **A new test module `tests/commands/test_roadmap_eval_verify_store.py`.**: The command tests already sit in `tests/roadmap/stage/test_roadmap_stage_verify_eval.py` with the fixtures they need, and docs/TESTING.md puts a new test in the file that already tests the behaviour.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Proposal

## Why

Two `devops roadmap eval verify` runs that start in the same second share one report file, and each atomic write replaces the cases of the other run, so the parallel workflow that the workflow document recommends loses cases with no warning. #4488 asks each run without `--resume` to create its own report file and to write every later report of the run to it.

## What Changes

- Add `create_store_file` to `src/devops_cli/core/repo.py`, next to `resolve_store_path`: it creates the store folder, creates the file exclusively with `tempfile.mkstemp`, and returns the path of a new file whose name starts with the UTC time stamp of the call.
- In `src/devops_cli/commands/roadmap_eval_verify.py`, a run without `--resume` gets its report file from the helper, and every later write of the run goes to that file.
- Keep `--resume <report>` writing only the named report and creating no new report file.
- Add the offline tests in `tests/core/test_core_repo.py` (two files in one second, in a store folder that is absent) and in `tests/roadmap/stage/test_roadmap_stage_verify_eval.py` (two runs that start in one frozen second and write at the same time keep their cases in two reports).
- Update `docs/ROADMAP_WORKFLOW.md` to state that each run without `--resume` creates its own report file.
- The change fits one pull request.

## Capabilities

### New Capabilities

None.

### Modified Capabilities

- `roadmap-stage-eval`: The verify command creates its own report file, A resumed run keeps the report it names, A store file gets a unique name

## Impact

- Code: `src/devops_cli/core/repo.py`, `src/devops_cli/commands/roadmap_eval_verify.py`
- Documents: `docs/ROADMAP_WORKFLOW.md`
- Tests: `tests/core/test_core_repo.py`, `tests/roadmap/stage/test_roadmap_stage_verify_eval.py`

## Feasibility

- `read_file` of `src/devops_cli/commands/roadmap_eval_verify.py` showed `src/devops_cli/commands/roadmap_eval_verify.py:118:target = resume or resolve_store_path(`, so the name comes from `datetime.now(UTC)` with `%Y%m%dT%H%M%SZ` and nothing creates the file exclusively.
- The probe confirms the cited command file word for word: "The path `src/devops_cli/commands/roadmap_eval_verify.py` is a file of the staging commit."
- The probe confirms the cited document word for word: "The path `docs/ROADMAP_WORKFLOW.md` is a file of the staging commit."
- `read_file` showed `docs/ROADMAP_WORKFLOW.md:375:To split the set between processes`; the issue cites line 374, and the staged commit holds that sentence at line 375.
- The probe shows the short path of another eval command is a candidate at another location, word for word: "The path `roadmap_eval_stage.py` is no file at the root of the staging commit. These files of the commit are candidates: `src/devops_cli/commands/roadmap_eval_stage.py`."
- The probe line "The path `os.replace` is no file of the staging commit. No commit in the history deleted or renamed it." shows that `os.replace` is no repository path; the atomic write is `src/devops_cli/output/file_writer.py:def write_text_file`.
- `read_file` showed the existing exclusive create: `src/devops_cli/roadmap/implement/implement_eval_run.py:455:directory.mkdir(parents=True, exist_ok=True)` and then `src/devops_cli/roadmap/implement/implement_eval_run.py:457:tempfile.mkstemp(prefix=f"implement-{stamp}-"`.
- `read_file` showed `src/devops_cli/core/repo.py:def resolve_store_path`, which resolves a store name under `data.dir`; the new helper goes next to it.
- `read_file` showed the existing test of the command module: `tests/roadmap/stage/test_roadmap_stage_verify_eval.py:14:from devops_cli.commands.roadmap_eval_verify import _review_model`; `tests/core/test_core_repo.py` is the existing test of the module that gets the helper.
- `pyproject.toml` lists `time-machine==3.5.1` as a development dependency, and docs/TESTING.md names time-machine for a faked wall clock, so the tests freeze the clock with it and the helper needs no time parameter.
- A second run that starts inside the model call of the first run on the same thread fails with `RuntimeError('This event loop is already running')`, so the command test starts the second run on its own thread, as a second process has its own event loop.
- On the base, the command test fails with `assert [['a-first']] == [['a-first'], ['b-second']]`: one file holds only the cases of the run that wrote last.
- `find_issues` with the words `roadmap eval verify report` listed #4488 and nine other open items; none names the report path that this plan changes, so the plan has no dependency.
- `resolve_store_path` reads the settings and the data directory, and needs no checkout, client or network.
- `load_settings` reads the configuration files, and needs no checkout, client or network.
- `tempfile.mkstemp` creates the file in the store folder, and needs no checkout, client or network.
- `Path.mkdir` creates the store folder, and needs no checkout, client or network.
- The verify commands are the existing `uv run devops ci test`; `uv`, `python`, `pytest` and `devops` are in the runner image, a failing test is the failure class `test`, and no new class or program is introduced.
- The pod setting that applies is `readOnlyRootFilesystem: true`, so the new tests set `DEVOPS_CLI_DATA_DIR` to a `tmp_path` folder and write nothing else; the command verify runs in the checkout of the repository.
- The first checks are `uv run devops ci test tests/core/test_core_repo.py` and `uv run devops ci test tests/roadmap/stage/test_roadmap_stage_verify_eval.py`, and the document group runs `uv run devops ci test tests/invariants/test_roadmap_workflow_doc.py`.

## Existing Tool Considered

The Python standard library `tempfile.mkstemp` covers exclusive file creation, and the project already uses it in `src/devops_cli/roadmap/implement/implement_eval_run.py` (`write_report`) and in `src/devops_cli/docker/cosign.py`. The change builds no unique-name generator of its own.

## Dependencies

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

### Requirement: The verify command creates its own report file
`devops roadmap eval verify` SHALL create a report file with a name unique to the run in the verify store folder when `--resume` is absent, and SHALL write every later report of that run to the file that it created.

#### Scenario: Two runs start in one second
- **WHEN** Two runs start with no `--resume` while the clock reads one second, and both write their reports.
- **THEN** The verify store folder holds two `.json` reports, and each report holds only the cases of its run.

#### Scenario: A case ends and the report is written
- **WHEN** A run without `--resume` ends a case and writes the report.
- **THEN** The write goes to the report file that the run got at its start.

### Requirement: A resumed run keeps the report it names
`devops roadmap eval verify --resume <report>` SHALL write only the report that `--resume` names, and SHALL create no new report file for that run.

#### Scenario: A run resumes a report
- **WHEN** A run starts with `--resume` of a report that exists.
- **THEN** The run writes that file, and the verify store folder holds no new report file.

### Requirement: A store file gets a unique name
The store file helper SHALL create the store folder when it is absent, SHALL create the file exclusively, and SHALL give each call in one second a different name.

#### Scenario: The helper runs two times in one second
- **WHEN** The helper is called two times while the clock reads one second, and the store folder is absent.
- **THEN** The helper creates the folder, returns two different paths, and both files exist.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Tasks

## 1. Add the unique store file helper

Reads: `src/devops_cli/roadmap/implement/implement_eval_run.py`, `tests/core/test_core_repo.py`. Changes: `src/devops_cli/core/repo.py`, `tests/core/test_core_repo.py`.

- [x] 1.1 `test_two_store_files_of_one_second_are_two_files` in `tests/core/test_core_repo.py` fails first
- Verification: `$ uv run devops ci test tests/core/test_core_repo.py` fails on the base
- [x] 1.2 Add `create_store_file(folder, suffix=".json")` to `src/devops_cli/core/repo.py`: resolve the store folder with `resolve_store_path`, create it with `mkdir(parents=True, exist_ok=True)`, take the stamp `%Y%m%dT%H%M%SZ` from `datetime.now(UTC)`, call `tempfile.mkstemp(prefix=f"{stamp}-", suffix=suffix, dir=store)`, close the descriptor and return the path. The test freezes the clock with time-machine, uses the `isolate_data_dir` fixture, calls the helper twice in a store folder that is absent, and asserts two different paths with both files present
- Verification: `$ uv run devops ci test tests/core/test_core_repo.py` passes

## 2. Give the verify command its own report file

Reads: `src/devops_cli/core/repo.py`, `src/devops_cli/commands/roadmap_eval_verify.py`, `tests/roadmap/stage/test_roadmap_stage_verify_eval.py`. Changes: `src/devops_cli/commands/roadmap_eval_verify.py`, `tests/roadmap/stage/test_roadmap_stage_verify_eval.py`.

- [x] 2.1 `test_two_runs_that_start_in_one_second_keep_their_cases_in_two_reports` in `tests/roadmap/stage/test_roadmap_stage_verify_eval.py` fails first: with the clock frozen, the first run starts a second run on its own thread inside its model call, and the test expects two reports, each with the cases of its run
- Verification: `$ uv run devops ci test tests/roadmap/stage/test_roadmap_stage_verify_eval.py` fails on the base
- [x] 2.2 In `src/devops_cli/commands/roadmap_eval_verify.py`, import `create_store_file` in place of `resolve_store_path`, and replace the stamp line with `target = resume or create_store_file(_STORE)`
- Verification: `$ uv run devops ci test tests/roadmap/stage/test_roadmap_stage_verify_eval.py` passes

## 3. State the unique report file in the workflow page

Reads: `docs/ROADMAP_WORKFLOW.md`. Changes: `docs/ROADMAP_WORKFLOW.md`.

- [x] 3.1 In the stopped-run bullet of `docs/ROADMAP_WORKFLOW.md`, state that each run creates its own report file, so two runs that start in the same second get two files
- Verification: `$ uv run devops ci test tests/invariants/test_roadmap_workflow_doc.py` passes
25 changes: 25 additions & 0 deletions openspec/specs/roadmap-stage-eval/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -447,3 +447,28 @@ A report of another model, a report that holds a case that the set lacks, or a f
#### Scenario: A file that is not a report
- **WHEN** `--resume` names a JSON file with no model
- **THEN** the command exits 1 and names the file

### Requirement: The verify command creates its own report file
`devops roadmap eval verify` SHALL create a report file with a name unique to the run in the verify store folder when `--resume` is absent, and SHALL write every later report of that run to the file that it created.

#### Scenario: Two runs start in one second
- **WHEN** Two runs start with no `--resume` while the clock reads one second, and both write their reports.
- **THEN** The verify store folder holds two `.json` reports, and each report holds only the cases of its run.

#### Scenario: A case ends and the report is written
- **WHEN** A run without `--resume` ends a case and writes the report.
- **THEN** The write goes to the report file that the run got at its start.

### Requirement: A resumed run keeps the report it names
`devops roadmap eval verify --resume <report>` SHALL write only the report that `--resume` names, and SHALL create no new report file for that run.

#### Scenario: A run resumes a report
- **WHEN** A run starts with `--resume` of a report that exists.
- **THEN** The run writes that file, and the verify store folder holds no new report file.

### Requirement: A store file gets a unique name
The store file helper SHALL create the store folder when it is absent, SHALL create the file exclusively, and SHALL give each call in one second a different name.

#### Scenario: The helper runs two times in one second
- **WHEN** The helper is called two times while the clock reads one second, and the store folder is absent.
- **THEN** The helper creates the folder, returns two different paths, and both files exist.
11 changes: 6 additions & 5 deletions src/devops_cli/commands/roadmap_eval_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

The command runs the pass on each case of `tests/fixtures/roadmap_eval/stage/` with the model of
the `verification` task, or with `--model`, and prints the recall of the labeled defects and the
findings on the good plans. It stores the score as JSON under the data directory, and writes the
file again when each case ends. `--resume` takes such a file, runs only the cases that the file
lacks or that failed in it, and updates the file in place (#4344).
findings on the good plans. It stores the score as JSON in a new file of its own under the data
directory, also when another run starts in the same second (#4488), and writes the file again when
each case ends. `--resume` takes such a file, runs only the cases that the file lacks or that
failed in it, and updates the file in place (#4344).
"""

from __future__ import annotations
Expand All @@ -15,7 +16,7 @@

import typer

from devops_cli.core.repo import find_repo_root, resolve_store_path
from devops_cli.core.repo import create_store_file, find_repo_root
from devops_cli.dry_run import dry_run_class, is_dry_run, render_request_plan
from devops_cli.exceptions import ConfigurationError
from devops_cli.lang import HELP, MESSAGES
Expand Down Expand Up @@ -115,7 +116,7 @@ def _run(
return
client = get_llm_client(task=_TASK, settings=settings, model=model)
review = ToolboxModel(_review_model(settings, model))
target = resume or resolve_store_path(f"{_STORE}/{datetime.now(UTC):%Y%m%dT%H%M%SZ}.json")
target = resume or create_store_file(_STORE)
print_info(MESSAGES.roadmap.verify_eval_storing.format(path=target))
score = evaluate_cases(
name,
Expand Down
Loading
Loading