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-03
18 changes: 18 additions & 0 deletions openspec/changes/3309-a-staged-plan-lists-the-files/design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Design

## Decisions

- **Compare the plan's base commit (`StagePlan.sha`) with the fetched default branch.**: The planner reads the checkout and the context at that commit, so a later commit on the default branch is what the reviewer has not seen. The branch starts from the default branch that `add_worktree` fetches at write time, so the comparison also covers a commit that landed while the model planned.
- **Take the union of `reads` and `changes` of every group of the plan, and leave out `creates`.**: `creates` is a subset of `changes` by the schema of `StageGroup`, so it adds no path.
- **Fetch the default branch once in `apply_stage`, before it writes a staged item.**: The clone can lag the remote, and a stale comparison would hide a commit that moved a named path. One fetch per run keeps `plan_stage` free of a write to git.
- **Run one `git log` over all named paths, with `--name-only`, and keep the entries for those paths.**: One local command gives the commits, their subjects and their files, and the log itself makes no network call and no model call.
- **Write the moved paths in the comment of the staged item, under their own heading.**: The comment is the record the reviewer reads, and the pull request body has an 800-character limit.
- **Add the precondition rule to `feasibility` in the stage prompt, and add no reply field.**: `feasibility` is already a list of strings, and a structured field would change the reply schema and the validator for one prompt rule.

## Rejected alternatives

- **Put the moved-file list in the draft pull request body.**: `src/devops_cli/roadmap/stage_change.py` holds `BODY_MAX_CHARS: Final[int] = 800`, and the body is the squash commit message.
- **Get the commits from the GitHub API instead of the clone.**: `src/devops_cli/roadmap/clone_git.py` already gives `git()` on the clone that the job holds, so the API would add a network call and a rate limit for data that the clone holds.
- **Compare the default branch in `plan_stage`.**: `plan_stage` promises no write to git or to GitHub, and the comment is written later in `apply_stage`, so a commit that lands between the plan and the write would be missing.
- **Compare only the `reads` paths.**: `src/devops_cli/roadmap/stage_change.py` gives a group both `reads` and `changes`, and a path that the plan writes is as stale as one it reads.
- **Add a structured `preconditions` field to the stage reply.**: `StageProposal` in `src/devops_cli/roadmap/stage_change.py` already holds `feasibility` as `list[Line]`, so a new field would change the schema and the checks for one prompt rule.
45 changes: 45 additions & 0 deletions openspec/changes/3309-a-staged-plan-lists-the-files/proposal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Proposal

## Why

A staged plan can rest on a base that `main` has moved past. The plan in #3261 held two stale facts: a title rule that `staging_title` had changed, and two callees that need a checkout, which the plan did not say. Both reached a reviewer, who had to find them (#3309). The stage job now names the plan's files that `main` changed after the base, and the prompt asks for the preconditions of each callee.

## What Changes

- A new module `src/devops_cli/roadmap/stage_moved.py` finds the commits that changed a path after the base commit.
- The stage job fetches the default branch once when it writes a plan and writes the moved paths of each item in the comment of the staged item.
- New messages in `src/devops_cli/lang/en/messages.py` give the heading and the lines of the moved-file section.
- The stage prompt `src/devops_cli/ai/tasks/roadmap_stage_change.md` asks for one `feasibility` line for each called function whose arguments need a checkout, a client or a network.
- The change alters the comment that the stage job writes, so it carries a spec delta on `roadmap-stage`.
- The change fits one pull request.

## Capabilities

### New Capabilities

None.

### Modified Capabilities

- `roadmap-stage`: The comment lists the named paths that moved, A moved path gives its commits in log order, The comparison reads the latest default branch, The prompt asks for the preconditions of a called function

## Impact

- Code: `src/devops_cli/roadmap/stage_moved.py`, `src/devops_cli/roadmap/stage.py`, `src/devops_cli/lang/en/messages.py`
- Documents: `src/devops_cli/ai/tasks/roadmap_stage_change.md`
- Tests: `tests/roadmap/test_roadmap_stage_moved.py`, `tests/roadmap/test_roadmap_stage_apply.py`, `tests/roadmap/test_roadmap_stage_prompt_rules.py`

## Feasibility

- `list_files` and `read_file` showed that `src/devops_cli/roadmap/stage.py` holds `StagePlan.sha`, the commit that the planner read: `sha: str = ""`, set from `read_stage_selection` with `sha = inspect_checkout(source, repo)`.
- `read_file` of `src/devops_cli/roadmap/stage.py` showed that `apply_stage` holds `plan.sha` and calls `_stage_one` for each ready change, and `_stage_one` posts the comment with `texts.stage_comment_staged.format(marker=..., branch=..., pull=..., budget=..., groups=..., notes=_notes(change))`, so the write is the place for the moved-file section.
- `read_file` of `src/devops_cli/git/worktree_add.py` showed that `_create` fetches `origin/main` and makes the worktree at that commit, so the branch can start past the commit that the planner read.
- `read_file` of `src/devops_cli/roadmap/stage_change.py` showed that a group holds `reads` and `changes` as `list[RepositoryPath]`, so the union of both is the set of paths the plan names.
- `read_file` of `src/devops_cli/roadmap/clone_git.py` showed the `git(cwd, *args, operation=...)` helper that runs a git command in the clone, so the log needs no new process edge.
- The premise holds: the code cited by the issue exists at the staging commit and holds the state the issue describes.
- First check against the real system: `uv run devops ci test tests/roadmap/test_roadmap_stage_moved.py` runs the new tests offline.
- Second check against the real system: `uv run devops ci lint` runs Ruff over the new module and the changed files.

## Existing Tool Considered

Git covers the need. `git log --format=%h%x00%s --name-only <base>..<default> -- <path>` lists the commits that changed a path and the files of each commit, from the clone that the stage job already holds. The repository already wraps it in `git()` of `src/devops_cli/roadmap/clone_git.py`, so the change adds no dependency. The log makes no network call; the comparison reuses the fetch of the default branch that the job makes before it writes. Git does not parse the plan's `reads` and `changes` lists, so the change adds about 80 lines of code and its tests: a build of roughly 6k tokens, a keep cost of a few hundred tokens per change, and under an hour of work. It deletes no internal code.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## ADDED Requirements

### Requirement: The comment lists the named paths that moved
The stage job SHALL list each path that a group of the plan names under `reads` or `changes` and that a commit on the default branch changed after the plan's base.

#### Scenario: A named plan path changes on main
- **WHEN** The plan names `src/devops_cli/roadmap/stage_change.py` under `reads` and a later commit on the default branch changes that file.
- **THEN** The comment of the staged item names `src/devops_cli/roadmap/stage_change.py` and the commit that changed it.

#### Scenario: An unnamed path changes on main
- **WHEN** A commit after the base changes a file that no group of the plan names under `reads` or `changes`.
- **THEN** The comment of the staged item does not name that file.

### Requirement: A moved path gives its commits in log order
The stage job SHALL give the short hash and the subject of each commit that changed a listed path, in log order.

#### Scenario: Two commits change one named path
- **WHEN** Two commits after the base change a path that the plan names under `changes`.
- **THEN** The comment lists the two short hashes and subjects under that path in log order.

#### Scenario: No commit changes a named path
- **WHEN** No commit after the base changes a path that the plan names under `reads` or `changes`.
- **THEN** The comment of the staged item has no moved-file section.

### Requirement: The comparison reads the latest default branch
The stage job MUST fetch the default branch before it compares the plan's base with the default branch.

#### Scenario: The remote default branch advances
- **WHEN** A remote commit changes a named path after the stage job fetched the base.
- **THEN** The comment of the staged item lists that path and commit.

### Requirement: The prompt asks for the preconditions of a called function
The stage prompt SHALL ask for one `feasibility` line for each called function whose arguments need a checkout, a client or a network.

#### Scenario: The stage prompt loads
- **WHEN** The stage job loads `src/devops_cli/ai/tasks/roadmap_stage_change.md`.
- **THEN** The prompt text names a checkout, a client and a network as preconditions to state in `feasibility`.
38 changes: 38 additions & 0 deletions openspec/changes/3309-a-staged-plan-lists-the-files/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Tasks

## 1. Find the commits that changed a named path after the base

Reads: `src/devops_cli/roadmap/clone_git.py`, `src/devops_cli/roadmap/stage_paths.py`. Changes: `src/devops_cli/roadmap/stage_moved.py` (new), `tests/roadmap/test_roadmap_stage_moved.py` (new).

- [ ] 1.1 Write `tests/roadmap/test_roadmap_stage_moved.py` first: a clone with two commits that change one named path gives both short hashes and subjects in log order, a commit that changes an unnamed path gives nothing, and a base with no later commit gives an empty list
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_stage_moved.py` fails on the base
- [ ] 1.2 Add `src/devops_cli/roadmap/stage_moved.py` with a frozen `MovedPath` of the path and its commits, and one function that takes the checkout, the base commit, the default branch and the named paths, runs `git log --format=%h%x00%s --name-only <base>..<branch> -- <paths>` through `git()` of `src/devops_cli/roadmap/clone_git.py`, and keeps the entries for the named paths. Give the log its own operation name for the git helper
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_stage_moved.py` passes

## 2. Write the moved paths in the comment of a staged item

Reads: `src/devops_cli/roadmap/stage.py`, `src/devops_cli/roadmap/stage_moved.py`, `src/devops_cli/roadmap/clone_git.py`, `src/devops_cli/lang/en/messages.py`. Changes: `src/devops_cli/roadmap/stage.py`, `src/devops_cli/lang/en/messages.py`, `tests/roadmap/test_roadmap_stage_apply.py`.

- [ ] 2.1 Add a case to `tests/roadmap/test_roadmap_stage_apply.py`: a staged item whose plan names a path that a later commit changed gives a comment with the moved-file heading, the path and the commit, and an item whose plan names no moved path gives a comment with no heading
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_stage_apply.py` fails on the base
- [ ] 2.2 Fetch the default branch once in `apply_stage` before the ready phase, read the moved paths of each `StagedChange` with the new function of `src/devops_cli/roadmap/stage_moved.py`, and pass them to `_stage_one`. Render them in `_notes` of `src/devops_cli/roadmap/stage.py` under a heading that `src/devops_cli/lang/en/messages.py` holds, one line for each path with its short hash and subject. Render nothing when no path moved
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_stage_apply.py` passes

## 3. Ask the stage prompt for the preconditions of a callee

Reads: `src/devops_cli/ai/tasks/roadmap_stage_change.md`. Changes: `src/devops_cli/ai/tasks/roadmap_stage_change.md`.

- [ ] 3.1 Add one rule to the `feasibility` section of the stage prompt: give one line for each function that the plan calls whose arguments need a checkout, a client or a network, and name that need in the line. Run `uv run devops roadmap eval stage --replay` and state the score of the model before and after the prompt change
- Verification: `uv run devops openspec check` passes

## 4. Check the prompt rule and the changed code together

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

- [ ] 4.1 Add a test to `tests/roadmap/test_roadmap_stage_prompt_rules.py` that loads `src/devops_cli/ai/tasks/roadmap_stage_change.md` and asserts that its text names a checkout, a client and a network as preconditions of `feasibility`
- Verification: `uv run devops ci test tests/roadmap/test_roadmap_stage_prompt_rules.py` passes

## Workflow follow-up

- Pending a person: run `uv run devops roadmap eval stage --model <model>` before and after the prompt change, and state both scores and the model.
- Pending a person: review the diff in tuicr (tuicr -r <base>..HEAD).
Loading