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 @@ -29,7 +29,7 @@ Notes on the table:

- A plan that an agent or a person writes is part of the one pull request that closes the issue. It has no separate gate G1. G1 exists for a plan that the Service stages.
- A person can do every step of an agent or of the Service. A person's claim beats the Service's claim.
- The command `devops roadmap explain <number>` says why the refine job, the stage job and the implement job take an Item or leave it out. It names the first rule that fails for each job, among them the limit `roadmap.stage.planned_limit` on Planned items (the stage job plans only items with the priority `P0-Critical` or `P1-High` while the count is at the limit). For refine it names the wait of the Item. It calls no model and writes nothing. It also reports the tokens, the seconds, the repair rounds and the outcome counts of the last implement run, and the count of dropped events. With `--json`, it prints those totals as a JSON object, and it refuses the option together with `--trace`. With `--trace`, it prints the trace of the last run of the implement job from the record of the issue, and no verdict. The option `--why` on `devops roadmap stage` and `devops roadmap implement` lists the open Items that the filter does not name.
- The command `devops roadmap explain <number>` says why the refine job, the stage job and the implement job take an Item or leave it out. It names the first rule that fails for each job, among them the limit `roadmap.stage.planned_limit` on Planned items (the stage job plans only items with the priority `P0-Critical` or `P1-High` while the count is at the limit). For refine it names the wait of the Item. It calls no model and writes nothing. It also reports the tokens, the seconds, the repair rounds and the outcome counts of the last implement run, and the count of dropped events. The totals include the events that the bound of the trace dropped, as the trace keeps their sums. For a trace with no such sums, as one from before #4457, the line beside the totals says that the totals leave the dropped events out. With `--json`, it prints those totals as a JSON object, and it refuses the option together with `--trace`. With `--trace`, it prints the trace of the last run of the implement job from the record of the issue, and no verdict. The option `--why` on `devops roadmap stage` and `devops roadmap implement` lists the open Items that the filter does not name.
- The command `devops roadmap plan-check <pull-request>` runs the stage gates and the checks of the pull request on a plan pull request that already exists. It calls no model and writes nothing. The job `Plan Check` of `pr-title.yml` runs it on each plan pull request of the Service, as an advisory check. [The plan-check page](roadmap/plan-check.md) tells what it checks.
- The command `devops roadmap plan-recheck` judges each change folder on the default branch again and gives it one result: `ok`, `rewrite`, `new-plan`, `delivered` or `cleanup`. Each refusal names its gate. With `--branch <ref>`, it compares the folders of a branch with the default branch and marks each refusal that the branch adds as a case to review. It judges less than the stage job, and the page lists what it leaves out. Before it judges a plan, it applies a mechanical rewrite in memory (a `Verification:` line, a bare name for a sample path, a `design.md` stub), and a plan gets `rewrite` only when the rewritten plan passes every check. It calls no model. It writes nothing, unless you give `--confirm` with `--source`: then it writes the rewritten files of the `rewrite` folders to that checkout and makes no commit. A plan with no way forward leaves the implement queue with the reason of the plan check, and `devops roadmap explain` names it. A new gate on merged plans only reports until this pass has run. [The plan-recheck page](roadmap/plan-recheck.md) tells the results and the policy.
- The command `devops roadmap consolidate` proposes groups of open items that share a root cause. A model proposes and then tries to refute each shortlist of the consolidation job; code checks the answers. The command writes a plan to `.data/roadmap/consolidate/<date>.json` and changes nothing on GitHub. Only `--decline <group-id> --confirm` writes, one mark in the job record of the anchor. [The consolidate page](roadmap/consolidate.md) tells the rules and the plan.
Expand Down
2 changes: 1 addition & 1 deletion docs/roadmap/implement.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ The job never merges. [Checks of the implement job](../ROADMAP_WORKFLOW.md#check

**A moved HEAD.** The shell of the agent allows `git`, so the agent can commit. A step makes the only commit, so before its exit checks the step resets a head that the agent moved with `git reset --soft`, to the start commit or to the last `wip:` commit. The reset keeps the work in the checkout, prints one line that names the moved head and the expected head, and the checks judge the work (#3575). The step stops with the class `head_moved` only when the reset fails.

**A stop.** A step that fails stops the item. The job comments why, shows a table of the steps (the step, its attempts, its tokens in and out, and its last failing command), shows the masked diff of the discarded work, and sets the Status to Blocked. The job keeps the trace of its run in `implement.trace`: each model call, tool call, check and retry, in the order of the run, with no argument, no output, no secret and no private host name. A tool call holds the digest of its argument, so a reader sees a repeated call, and a shell call holds the exit status of its command. When a long run does not fit the bound of the trace, the trace drops the oldest model events first, then the oldest of the other events, and counts them in `dropped`. The tool calls, checks, retries and attempts show what the run did, and `implement.spend` keeps the tokens of the run. Read it with `devops roadmap explain <issue> --trace`. The job keeps no Job artifact. Before the push of a stop, the job drops the files that no commit holds, such as the files of an archive that failed after it moved the change folder, so the rebase of the push finds a clean checkout. The Service runs the item again after the comment `implement: retry`. For a stop whose class a new attempt can fix, it runs the item again with no comment. This happens after a Job that ended with no result, up to `roadmap.implement.continuations_per_item` times (default 2). It also happens after a new runner image, within the limits of `roadmap.implement.digest_clears_per_class` and `roadmap.implement.digest_clears_per_item`.
**A stop.** A step that fails stops the item. The job comments why, shows a table of the steps (the step, its attempts, its tokens in and out, and its last failing command), shows the masked diff of the discarded work, and sets the Status to Blocked. The job keeps the trace of its run in `implement.trace`: each model call, tool call, check and retry, in the order of the run, with no argument, no output, no secret and no private host name. A tool call holds the digest of its argument, so a reader sees a repeated call, and a shell call holds the exit status of its command. When a long run does not fit the bound of the trace, the trace drops the oldest model events first, then the oldest of the other events, and counts them in `dropped`. It keeps the sums of the dropped events (their tokens, seconds, repair rounds and outcomes), so the totals of `devops roadmap explain` cover the whole run. The tool calls, checks, retries and attempts show what the run did, and `implement.spend` keeps the tokens of the run. Read it with `devops roadmap explain <issue> --trace`. The job keeps no Job artifact. Before the push of a stop, the job drops the files that no commit holds, such as the files of an archive that failed after it moved the change folder, so the rebase of the push finds a clean checkout. The Service runs the item again after the comment `implement: retry`. For a stop whose class a new attempt can fix, it runs the item again with no comment. This happens after a Job that ended with no result, up to `roadmap.implement.continuations_per_item` times (default 2). It also happens after a new runner image, within the limits of `roadmap.implement.digest_clears_per_class` and `roadmap.implement.digest_clears_per_item`.

**The premise of a behavior group.** Before a behavior group starts, the job checks its premise at the branch tip. It reads each task of the group that has an add verb, the word guard or check, and one name in a code span. When the branch tip defines that name, the job returns the item to New. The comment holds the task and the definition line. The job runs no step and makes no model request. It first takes back the checkpoints that it pushed (see Checkpoints). The check uses the same definition lookup as the premise check of the stage job (`src/devops_cli/roadmap/premise.py`). It reads the last commit that is not a `wip:` commit, so a guard that an earlier attempt of the same group kept is no defect. A group of another kind gets no check.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
schema: spec-driven
created: 2026-11-11
skip_specs: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Design

## Decisions

- The encoded trace keeps four sums of the dropped events: `dropped_tokens`, `dropped_seconds`, `dropped_repair_rounds` and `dropped_outcomes`. They are the inputs of `trace_totals`, so the totals of a long run equal the totals of the full run. The bound drops attempt events only when no model event is left, but it can drop them, so their repair rounds and outcomes are kept too.
- One class, `TraceSums`, makes the sums of a set of events. `trace_totals` uses it for the kept events, and `encode` uses it for each dropped event, so the two sums cannot disagree.
- The sums count toward the bound. `encode` measures the frame of the JSON with the sums of the events that it has dropped so far, so the text stays within `CONST_ROADMAP_IMPLEMENT_TRACE_CHARS`.
- A sum of zero is not written. A trace that fits the bound has the same form as before, and a reader of an old record sees no new key.
- The decoded sums are the start of the sums of the next encode, the same as the decoded `dropped`. `encode` does not change the trace, so the job can encode the same trace many times with no double count.
- `decode` checks the type of each sum and raises `TraceDecodeError`, the same as for `dropped`, so `explain` names `implement.trace` for a value that is not a trace.

## Rejected alternatives

- Read the token total from `implement.spend`. The record holds no seconds, and it does not give the repair rounds or the outcomes.
- Raise the bound or keep more model events. A longer run still drops them, and the bound protects the size of the issue body.
- Count only the model events and leave out the attempt events. The bound drops attempt events when no model event is left, and the totals would then be wrong again.
- Write the four keys always. Every trace that fits the bound would change its form for no gain.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Proposal: #4457

## Why

`devops roadmap explain <issue>` and `explain --json` report 0 tokens and 0 seconds for the last implement run when its trace is long. `trace_totals` adds the tokens and the seconds of the model events that the trace keeps. Since #4436 (issue #4393), `ImplementTrace.encode` drops the oldest model events first, so the bound drops every model event of a long run. The long runs are the runs that a reader most wants to explain. Closes #4457.

## What Changes

- `ImplementTrace.encode` keeps the sums of the events that it drops: `dropped_tokens` and `dropped_seconds` for the model events, and `dropped_repair_rounds` and `dropped_outcomes` for the attempt events. A sum of zero is not written, so a trace that fits the bound keeps its form.
- `decode` reads the sums. A trace with no sum, such as one from before this change, decodes with sums of zero. A sum that is not a number stops the decode with `TraceDecodeError`.
- A trace that is decoded and encoded again adds no sum twice: the decoded sums are the start of the sums of the next encode, the same as `dropped`.
- `trace_totals` adds the dropped sums to the sums of the kept events. The sums of a set of events come from one class, `TraceSums`, for the kept events and for the dropped events.
- The line beside the totals says that the totals include the dropped events. For a trace that holds no dropped sum, such as one from before this change, the line says that the totals leave them out.

The change fits one pull request.

## Capabilities

### New Capabilities

None.

### Modified Capabilities

- `roadmap-explain`: Totals of the last implement run; Dropped events beside the totals
- `roadmap-implement-job`: The job keeps the trace of its run

## Impact

- Code: `src/devops_cli/roadmap/implement/implement_trace.py`, `src/devops_cli/roadmap/explain.py`, `src/devops_cli/lang/en/messages.py`
- Tests: `tests/roadmap/implement/test_roadmap_implement_trace.py`, `tests/roadmap/test_roadmap_explain.py`, `tests/roadmap/test_roadmap_explain_command.py`, `tests/support/roadmap_implement.py`
- Specs: `openspec/specs/roadmap-explain/spec.md`, `openspec/specs/roadmap-implement-job/spec.md`
- Documents: `docs/ROADMAP_WORKFLOW.md`, `docs/roadmap/implement.md`
- The bound of the trace does not change. The sums take their characters from the bound, so a long trace keeps a few fewer events.

## Feasibility

- Source on `main` (`7234d718`): `trace_totals` in `src/devops_cli/roadmap/explain.py` sums only `trace.events`. `ImplementTrace.encode` in `src/devops_cli/roadmap/implement/implement_trace.py` sorts the model events first and drops them until the text fits.
- Command output on `main`: the run of the issue (100 model events of 20,300 tokens and 4 seconds, 150 shell calls, a failed attempt) gives `TraceTotals(tokens_total=2030000, seconds_total=400.0, ...)` for the full trace and `TraceTotals(tokens_total=0, seconds_total=0, ..., dropped=180)` after `encode` and `decode`. The decoded trace keeps 70 tool events, the attempt event and no model event.
- `implement.spend` holds the tokens of the run but no seconds, so it cannot give the seconds total.

## Existing Tool Considered

No tool applies: the change adds sums to a JSON value that the project owns. Cost to build: about 40k tokens and 1 hour.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## MODIFIED Requirements

### Requirement: Totals of the last implement run
The command SHALL report the token total, the seconds total, the repair-round count and the outcome counts of the last implement run of the item. The totals SHALL include the model events and the attempt events that the trace bound dropped.

#### Scenario: Totals of a fixture run
- **WHEN** the job record of the fixture item holds a trace with one model event of 1200 input tokens, 300 output tokens and 90 seconds, and two attempt events, the first with outcome `failed` and next `repair`, the second with outcome `passed` and next `stop`
- **THEN** the output reports 1500 tokens, 90 seconds, 1 repair round, 1 failed outcome and 1 passed outcome

#### Scenario: A long run
- **WHEN** the trace of the item holds 100 model events of 20,000 input tokens, 300 output tokens and 4 seconds each, 150 shell calls and a failed attempt, and the bound drops every model event
- **THEN** the output reports 2030000 tokens and 400.0 seconds, the totals of the full run, and `--json` gives the same values

#### Scenario: A trace with no dropped sums
- **WHEN** the trace holds `events` and `dropped` and no dropped sum, as a trace from before the sums
- **THEN** the trace decodes with no error, and the totals are the sums of the kept events

### Requirement: Dropped events beside the totals
The command SHALL state the number of events that the trace bound dropped, beside the totals. When the trace holds a sum of its dropped events, the line SHALL say that the totals include them. Otherwise the line SHALL say that the totals leave them out.

#### Scenario: Trace with dropped events
- **WHEN** the trace of the fixture item reports 12 dropped events and a dropped sum
- **THEN** the output names 12 dropped events and says that the totals include them

#### Scenario: Trace with dropped events and no dropped sum
- **WHEN** the trace of the fixture item reports 12 dropped events and no dropped sum, as a trace from before the sums
- **THEN** the output names 12 dropped events and says that the totals leave them out
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## MODIFIED Requirements

### Requirement: The job keeps the trace of its run
The job SHALL clear `implement.trace` when a run starts, and SHALL write it with each record of a passed group, with a stop and with the ready mark. The value SHALL be JSON with the events and the count `dropped`. When the value is longer than `CONST_ROADMAP_IMPLEMENT_TRACE_CHARS` characters, the job SHALL drop the oldest `model` events first, then the oldest other events, count them in `dropped`, and keep the sums of their tokens, seconds, repair rounds and outcomes.

#### Scenario: A trace that is too long
- **WHEN** a run makes more events than fit in `CONST_ROADMAP_IMPLEMENT_TRACE_CHARS` characters
- **THEN** the value is not longer than the bound, it holds the kept events whole in the order of the run, and `dropped` counts the others

#### Scenario: Many model events and few progress events
- **WHEN** a run records 5 `tool` or `check` events first, then 200 `model` events and an `attempt` event, and the encoded value is longer than the bound
- **THEN** the value holds the 5 `tool` or `check` events, the newest `model` events and the `attempt` event, and `dropped` counts only the dropped `model` events

#### Scenario: Progress events that alone do not fit
- **WHEN** the trace holds 100 `model` events and 10 `tool` events, and only 8 `tool` events fit the bound
- **THEN** the value holds the newest 8 `tool` events and no `model` event, and `dropped` is 102

#### Scenario: A stored trace from before the order of the run
- **WHEN** a stored trace holds its `model` events after the `tool` events of a turn
- **THEN** the trace decodes with no error, and its events keep the stored order

#### Scenario: A new run
- **WHEN** a person retries a stopped item
- **THEN** the job clears `implement.trace` before its first step, and the record holds only the events of the new run

#### Scenario: A Job that ends after a group
- **WHEN** the Service ends a Job after the record of group 1 and before the stop
- **THEN** the record holds the events of group 1

#### Scenario: The sums of dropped events
- **WHEN** the bound drops model events of 2,030,000 tokens and 400 seconds in all, and no attempt event
- **THEN** the value holds `dropped_tokens` 2030000 and `dropped_seconds` 400.0 and no dropped attempt sum, and a value that is decoded and written again holds the same sums
Loading
Loading