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-02
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Design

## Decisions

- **The stage context carries the overlap list, and the gate reads it from the context.**: The gate sees only the context and the reply, so it can refuse a plan that ignores an overlap. The planner spends no tool call on the search.
- **The open pull requests and their changed files come from one GraphQL request for each 100 open pull requests.**: One request returns every field that the context needs and the rate limiter counts it once, so the count grows with the open pull requests and not with the reads of one plan.
- **The reply gets a `dependencies` field (`list[str]`), which the proposal renders as `## Dependencies`.**: The gate reads a field, not prose, and the prompt gives the planner one place for each overlap.
- **The context builder compares paths cited in the issue body, and the proposal gate checks the paths that the reply names.**: The context builder finds overlaps for paths cited in the issue body. The gate ensures that when overlaps exist, the proposal acknowledges them in `dependencies`.
- **A cited metric is a name that `INSTRUMENTS` holds, and its senders are the files that `git grep -w` finds at the staged commit.**: `INSTRUMENTS` is the single list of instruments, and `tests/telemetry/test_telemetry_instruments.py` already ties every metric to it.
- **A pull request whose title has the type `docs(openspec)` is marked as a plan pull request.**: The stage job gives every plan that title, so the mark tells a plan from the pull request that implements it with no extra read.
- **The prompt lists `dependencies` under reply keys, and PR records replay evaluation scores.**: `test_the_top_level_keys_of_the_reply_are_the_fields_of_the_proposal` checks that `StageProposal` fields match the prompt reply keys. Per `docs/ROADMAP_WORKFLOW.md:233`, changes to the prompt or gates state model replay scores before and after.

## Rejected alternatives

- **Let the planner search the open pull requests with its own `extended` tools.**: `CONTEXT.md` states that the planner works within a budget of tool calls, and the gate cannot check a search that the planner did not run.
- **Read each open pull request with one `gh pr view --json files`.**: `docs/TELEMETRY.md` states that `devops_cli_github_requests_total` counts each paced request, so one read for each open pull request spends the hourly budget of the Service.
- **Reuse the open pull requests that the poll reads.**: `src/devops_cli/roadmap/stage.py` reads no pull request in `read_stage_selection`, and the items of the poll carry no changed files.
- **Parse the `## Dependencies` prose of the proposal to find the overlaps.**: `src/devops_cli/roadmap/stage_change.py` renders the proposal from fields, so a change of wording would hide an overlap from the gate.
- **Take every `devops_cli_` token of the reply as a cited metric.**: `docs/TELEMETRY.md` lists metric names beside other `devops_cli_` identifiers, so a token can name something that is no metric.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Proposal

## Why

A plan is written without knowledge of the open plans and pull requests that edit the same files (#3252). Two plans that edit `INSTRUMENTS` or the generated `docs/TELEMETRY.md` can merge one after the other and force a regenerate, and nothing checks the other senders of a shared counter.

## What Changes

- Add `src/devops_cli/roadmap/stage_overlap.py`: it reads the open pull requests with their changed files, compares them with the paths cited in the issue body, and lists each overlap with its number, title, state, plan mark and shared paths.
- Read the open pull requests in one GraphQL request for each 100 through the GitHub session, so each request counts once in `devops_cli_github_requests_total`.
- List the other files that hold a cited metric name, from `git grep -w` at the staged commit, in the stage context.
- Add the `overlaps` and `metric_senders` keys to the stage request in `src/devops_cli/roadmap/stage.py`.
- Add the `dependencies` field to `StageProposal` in `src/devops_cli/roadmap/stage_change.py`, render it as `## Dependencies`, and refuse an empty one when the context lists an overlap.
- Add the `dependencies` key and rule to `src/devops_cli/ai/tasks/roadmap_stage_change.md`, and report model replay scores before and after per `docs/ROADMAP_WORKFLOW.md`.
- Tests give the builder a fake client and a fake tree, so no test reaches GitHub.
- The change fits one pull request.

## Capabilities

### New Capabilities

None.

### Modified Capabilities

- `roadmap-stage`: The stage context lists an overlapping pull request, A plan pull request carries a plan mark, A cited metric lists its other senders, The gate refuses an empty Dependencies part on an overlap, The stage prompt states the Dependencies rule, The overlap read costs a stated number of GitHub requests

## Impact

- Code: `src/devops_cli/roadmap/stage_overlap.py`, `src/devops_cli/roadmap/stage.py`, `src/devops_cli/roadmap/stage_change.py`
- Documents: `src/devops_cli/ai/tasks/roadmap_stage_change.md`, `docs/ROADMAP_WORKFLOW.md`
- Tests: `tests/roadmap/test_roadmap_stage_overlap.py`, `tests/roadmap/test_roadmap_stage_plan.py`, `tests/roadmap/test_roadmap_stage_form.py`, `tests/roadmap/test_roadmap_stage_prompt_rules.py`

## Feasibility

- `read_file` on `src/devops_cli/roadmap/stage.py` showed `check_proposal(proposal, self._known, self._tree_of(target, proposal), requirements=self._requirements, issue_body=target.item.body)` inside `_Planner._settle`, so the gate reads the reply and the staged tree and is the place for the overlap rule.
- `read_file` on `src/devops_cli/roadmap/stage.py` showed `_Planner._request` builds the request with the keys `number`, `title`, `body`, `context`, `capabilities`, `budget` and `probes`, so the overlap list joins it there.
- The probe answered "The path `docs/TELEMETRY.md` is a file of the staging commit", and `read_file` on it showed the row `devops_cli_github_requests_total` and the text "Each metric is an entry of `INSTRUMENTS` in `src/devops_cli/telemetry/instruments.py`", so a cited metric name appears in more than one file.
- The probe answered "The path `src/devops_cli/telemetry/instruments.py` is a file of the staging commit", and `read_file` showed `INSTRUMENTS` holding the declared instruments, so the list of metric names is in place.
- The probe answered "The path `src/devops_cli/roadmap/stage_eval_gates.py` is a file of the staging commit" and "The path `openspec/changes/archive/2026-11-01-3010-stage-refuses-missing-paths/design.md` is a file of the staging commit", so the path extraction of the earlier path rule is in place.
- `read_file` on `docs/adr/0001-github-is-the-roadmap-source.md` showed it links `0016-labels-hold-the-roadmap-items-fields.md`, which holds item fields and no request budget. The request budget is `devops_cli_github_requests_total` in `docs/TELEMETRY.md`.
- `list_files` on `src/devops_cli/ai/tasks/` showed `roadmap_stage_change.md`, so the stage prompt that the change edits is that file.
- First checks against the real system: `uv run devops ci test tests/roadmap/test_roadmap_stage_overlap.py`, then `uv run devops ci test tests/roadmap/test_roadmap_stage_form.py`, then `uv run devops openspec check`.
- A test cannot reach GitHub, so the overlap tests give the builder a fake client and a fake tree. The first real read is checked by `uv run devops roadmap stage --dry-run`, which lists the requests and sends none.

## Existing Tool Considered

`gh` is open and maintained and the repository already runs it, but it compares no path sets, renders no context entry and refuses no plan. `gh pr list --json number,title,state,files` gives the pull requests and their files, and `git grep -w` gives the files that hold a name. The change writes that glue: about 200 lines with tests, about 100k tokens to build, keep and fix, and about one day of elapsed time. It deletes no internal code.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
## ADDED Requirements

### Requirement: The stage context lists an overlapping pull request
The stage context builder SHALL list each open pull request that changes a path that the item body cites, with its number, title, state and the shared paths.

#### Scenario: A fake pull request changes a cited path
- **WHEN** A test gives the builder a fake client that holds pull request 3173, which changes `docs/TELEMETRY.md`, and an item body that cites `docs/TELEMETRY.md`.
- **THEN** The context holds one entry with number 3173, its title, its state and `docs/TELEMETRY.md`.

#### Scenario: A fake pull request changes a path that no item body cites
- **WHEN** A test gives the builder a fake client that holds pull request 3173, which changes `docs/TELEMETRY.md`, and an item body that cites only `src/devops_cli/roadmap/stage.py`.
- **THEN** The context holds no overlap entry.

### Requirement: A plan pull request carries a plan mark
The stage context builder SHALL mark an open pull request whose title has the type `docs(openspec)` as a plan pull request.

#### Scenario: A plan pull request overlaps a cited path
- **WHEN** A test gives the builder a fake client that holds pull request 3252, titled `docs(openspec): plan #3252 stage context`, which changes `src/devops_cli/roadmap/stage_overlap.py`, and an item body that cites that path.
- **THEN** The context entry holds the number, the title, the state, the plan mark and `src/devops_cli/roadmap/stage_overlap.py`.

#### Scenario: A pull request that is no plan carries no mark
- **WHEN** A test gives the builder a fake client that holds pull request 3253, titled `feat(roadmap): stage context`, which changes `src/devops_cli/roadmap/stage.py`, and an item body that cites that path.
- **THEN** The context entry holds the number and no plan mark.

### Requirement: A cited metric lists its other senders
For each cited metric name, the stage context builder SHALL list the other files that hold the name, from `git grep -w` at the staged commit.

#### Scenario: A cited counter lists the files that hold its name
- **WHEN** A test gives the builder an item body that cites `devops_cli_github_requests_total` and a staged tree that holds the name in two files.
- **THEN** The context lists `src/devops_cli/telemetry/instruments.py` and `docs/TELEMETRY.md` under the cited name.

#### Scenario: A name that `INSTRUMENTS` does not hold lists no sender
- **WHEN** A test gives the builder an item body that cites `devops_cli_dashboard_panel` and a staged tree that holds the name in one file.
- **THEN** The context lists no sender under that name.

### Requirement: The gate refuses an empty Dependencies part on an overlap
`check_proposal` SHALL refuse a reply whose `dependencies` field is empty when the context lists an overlap, and SHALL name the pull request and the shared path.

#### Scenario: An overlap with an empty Dependencies field
- **WHEN** `check_proposal` gets a reply whose `dependencies` field is empty and a context that lists pull request 3173 on `docs/TELEMETRY.md`.
- **THEN** The problems hold one sentence that names pull request 3173 and `docs/TELEMETRY.md`.

#### Scenario: A reply that names the overlap passes
- **WHEN** `check_proposal` gets a reply whose `dependencies` field names pull request 3173 and `docs/TELEMETRY.md`, and a context that lists that overlap.
- **THEN** The problems hold no sentence about the overlap.

### Requirement: The stage prompt states the Dependencies rule
The stage prompt SHALL tell the planner to write each overlap and each shared metric sender into the `dependencies` field.

#### Scenario: The prompt holds the Dependencies rule
- **WHEN** A test reads the stage prompt file.
- **THEN** The prompt holds a rule that names the `dependencies` field, the empty list and the overlap entry.

### Requirement: The overlap read costs a stated number of GitHub requests
The stage context builder SHALL read the open pull requests and their files in one GraphQL request for each 100 open pull requests, and SHALL state that count in the comment of the staged item.

#### Scenario: 150 open pull requests cost two requests
- **WHEN** A test gives the builder a fake client and 150 open pull requests.
- **THEN** The fake client records two GraphQL requests and no other request.
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Tasks

## 1. List the other files that hold a cited metric name

Reads: `src/devops_cli/telemetry/instruments.py`, `docs/TELEMETRY.md`. Changes: `src/devops_cli/roadmap/stage_overlap.py` (new), `tests/roadmap/test_roadmap_stage_overlap.py` (new).

- [ ] 1.1 In `tests/roadmap/test_roadmap_stage_overlap.py`, a test gives `metric_senders` a fake grep answer that holds `devops_cli_github_requests_total` in two files and asserts that both files are listed under the name, and a second test asserts that a name that `INSTRUMENTS` does not hold lists nothing
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_stage_overlap.py` fails on the base
- [ ] 1.2 Write `src/devops_cli/roadmap/stage_overlap.py` with `metric_senders(names, grep)` that keeps the names that `INSTRUMENTS` holds, runs `git grep -w` at the staged commit through a `grep` callable that the tests replace, and returns the files of each name in sorted order. It returns an empty mapping when no name survives
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_stage_overlap.py` passes

## 2. List the open pull requests that overlap the paths of a reply

Reads: `src/devops_cli/roadmap/stage_paths.py`, `src/devops_cli/roadmap/stage_github.py`, `src/devops_cli/github/session.py`. Changes: `src/devops_cli/roadmap/stage_overlap.py`, `tests/roadmap/test_roadmap_stage_overlap.py`.

- [ ] 2.1 A test gives `overlaps` a fake list that holds pull request 3173 on `docs/TELEMETRY.md` and an issue body that cites that path, and asserts one entry with the number, title, state and shared path. A second test asserts that a plan pull request carries the plan mark. A third test gives 150 fake pull requests and asserts that the fake client records two GraphQL requests and no other request
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_stage_overlap.py` fails on the base
- [ ] 2.2 Add `OpenPull` and `Overlap` dataclasses and `open_pulls(client)` to `src/devops_cli/roadmap/stage_overlap.py`. It reads `number`, `title`, `state` and `files` of the open pull requests in one GraphQL request for each 100 through the session client, marks a title whose type is `docs(openspec)` as a plan, and returns the entries. Add `overlaps(pulls, paths)` that compares paths with the files of each pull and returns one entry for each pull with its sorted shared paths. The client is a parameter, so the tests give a fake
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_stage_overlap.py` passes

## 3. Put the overlaps and the senders into the stage context

Reads: `src/devops_cli/roadmap/stage.py`, `src/devops_cli/roadmap/stage_overlap.py`. Changes: `src/devops_cli/roadmap/stage.py`, `tests/roadmap/test_roadmap_stage_plan.py`.

- [ ] 3.1 A test builds the request of one item with a fake client and a fake tree and asserts that the request holds an `overlaps` list with the number of the overlapping pull request and a `metric_senders` mapping for the cited name
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_stage_plan.py` fails on the base
- [ ] 3.2 In `_Planner._request` of `src/devops_cli/roadmap/stage.py`, read the open pull requests once for the item with `open_pulls`, add the `overlaps` entry for each pull whose files meet the paths that the item body cites, and add `metric_senders` for the names that `INSTRUMENTS` holds. A read that fails adds no key and never stops the item. Pass the overlap list to `_settle` so that `check_proposal` sees it
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_stage_plan.py` passes

## 4. Refuse an empty Dependencies field on an overlap

Reads: `src/devops_cli/roadmap/stage_change.py`, `tests/roadmap/test_roadmap_stage_form.py`. Changes: `src/devops_cli/roadmap/stage_change.py`, `tests/roadmap/test_roadmap_stage_form.py`.

- [ ] 4.1 In `tests/roadmap/test_roadmap_stage_form.py`, a test gives `check_proposal` a reply whose `dependencies` field is empty and an overlap list that names pull request 3173 on `docs/TELEMETRY.md`, and asserts that one problem names both. A second test gives a reply that names the overlap and asserts that no problem mentions it
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_stage_form.py` fails on the base
- [ ] 4.2 Add a `dependencies` field to `StageProposal` in `src/devops_cli/roadmap/stage_change.py`, render it as the `## Dependencies` section of the proposal, update `test_roadmap_stage_plan.py` snapshot assertions, and give `check_proposal` an `overlaps` argument. When the overlaps are non-empty and `dependencies` is empty, add one problem that names the pull request number and the shared path. When `dependencies` names an overlap, add no problem
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_stage_form.py` passes

## 5. State the Dependencies rule in the stage prompt

Reads: `src/devops_cli/ai/tasks/roadmap_stage_change.md`, `tests/roadmap/test_roadmap_stage_prompt_rules.py`. Changes: `src/devops_cli/ai/tasks/roadmap_stage_change.md`, `tests/roadmap/test_roadmap_stage_prompt_rules.py`.

- [ ] 5.1 In `tests/roadmap/test_roadmap_stage_prompt_rules.py`, a test reads the stage prompt and asserts that it names the `dependencies` field, the empty list and the overlap entry
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_stage_prompt_rules.py` fails on the base
- [ ] 5.2 Add the `dependencies` key under reply keys and the Dependencies rule to `src/devops_cli/ai/tasks/roadmap_stage_change.md`: write each overlap and each shared metric sender into the `dependencies` field, and leave it empty only when the context lists no overlap
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_stage_prompt_rules.py` passes
- [ ] 5.3 Update `src/devops_cli/ai/tasks/roadmap_stage_change.md`, and run `uv run devops docs generate --sync-readme`
- Verification: `uv run devops ci docs` passes

## 6. Report the request count of the overlap read in the workflow page

Reads: `docs/ROADMAP_WORKFLOW.md`, `src/devops_cli/roadmap/stage.py`. Changes: `docs/ROADMAP_WORKFLOW.md`.

- [ ] 6.1 State in `docs/ROADMAP_WORKFLOW.md` that the stage job reads the open pull requests in one GraphQL request for each 100, that the comment of the staged item reports the count, and that the gate refuses an empty Dependencies part when the context lists an overlap
- Verification: `uv run devops ci docs` passes
- [ ] 6.2 Update `docs/ROADMAP_WORKFLOW.md`, and run `uv run devops docs generate --sync-readme`
- Verification: `uv run devops ci docs` passes

## Criteria

- Group 2: A test with a fake list of pull requests shows that an overlapping path appears in the context with the number.
- Group 1: A test shows that a cited metric name lists its other senders.
- Group 4: `check_proposal` refuses "Dependencies: None" when the context lists an overlap, and names it.
- Group 6: The extra GitHub reads fit the request budget (ADR 0016), and the number of requests is stated.

## Workflow follow-up

- State the replay evaluation score of the same model before and after the prompt and gate changes per `docs/ROADMAP_WORKFLOW.md:233`.
- Pending a person: review the diff in tuicr (tuicr -r <base>..HEAD).
Loading