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/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 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`. 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,12 @@
# Design

## Decisions

- The digest goes after the program and before the outcome, in square brackets: `tool shell (program git) [argument abc123abc123], ok`. The digest names the call, so it stands with the tool and the program. The outcome, the exit status and the reason stay at the end, as before.
- The word `argument` tells the reader what the hexadecimal value is. The value is the digest of the masked argument, not the argument.
- The part is empty when the event holds no digest, the same as the program part. An old trace or a hand-made trace with no digest still prints.

## Rejected alternatives

- Change the requirement "The trace option prints the trace of the last run". Its text is near the 500-character limit of `openspec validate --strict`, so a new requirement holds the digest.
- Show only the first characters of the digest. The digest is already 12 characters, and a shorter value makes two different calls look the same.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Proposal: #4444

## Why

`devops roadmap explain <issue> --trace` does not show the digest of the argument of a tool call. The `tool` event in `implement.trace` holds the digest in the field `digest`, but `_event_line` in `src/devops_cli/roadmap/explain.py` does not read it. So a reader cannot see that the model made the same call two or more times. Issue #4393 asked for this in its criterion "Render tool and check details", and pull request #4436 did not deliver it. Closes #4444.

## What Changes

- The line of a `tool` event shows the digest of its argument after the program, for example `group 1: tool shell (program git) [argument abc123abc123], ok (exit status 0)`.
- A `tool` event with no digest shows no argument part, so a trace from before the digest still prints.
- The text of the part is `explain_trace_tool_digest` in `RoadmapMessages`.

The change fits one pull request.

## Capabilities

### New Capabilities

None.

### Modified Capabilities

- `roadmap-explain`: The trace option prints the argument digest of a tool call (added)

## Impact

- Code: `src/devops_cli/roadmap/explain.py`, `src/devops_cli/lang/en/messages.py`
- Tests: `tests/roadmap/test_roadmap_explain.py`
- Specs: `openspec/specs/roadmap-explain/spec.md`
- Documents: `docs/roadmap/implement.md`
- The trace keeps the same fields and the same bound. The digest is 12 hexadecimal characters of the SHA-256 of the masked argument, so the line shows no argument and no secret.

## Feasibility

- Source on `main`: `ImplementTrace.tool_call` in `src/devops_cli/roadmap/implement/implement_trace.py` keeps the digest in the field `digest`. The `TraceEventKind.TOOL` case of `_event_line` reads `tool`, `program`, `outcome`, `status` and `reason`, and not `digest`. `explain_trace_tool` is `"{step}: tool {tool}{program}, {outcome}{status}{reason}"`.
- Test output on the base: the two changed tests of `tests/roadmap/test_roadmap_explain.py` fail with `'group 1: tool shell (program git), ok (exit status 128)' != 'group 1: tool shell (program git) [argument abc123abc123], ok (exit status 128)'`.

## Existing Tool Considered

No tool applies: the change is one field in a line of text that the project owns. Cost to build: about 10k tokens and 30 minutes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## ADDED Requirements

### Requirement: The trace option prints the argument digest of a tool call
`explain <issue> --trace` SHALL show in the line of a `tool` event the digest of its argument, when the event holds one, so that a reader sees a repeated call. A `tool` event with no digest SHALL show no argument part.

#### Scenario: The same call twice
- **WHEN** the trace holds two `tool` events with the digest `abc123abc123`
- **THEN** each line says `[argument abc123abc123]`

#### Scenario: A tool call with no digest
- **WHEN** a `tool` event holds no digest
- **THEN** its line has no argument part
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Tasks

## 1. Behavior

Reads: `src/devops_cli/roadmap/explain.py`, `src/devops_cli/roadmap/implement/implement_trace.py`, `tests/roadmap/test_roadmap_explain.py`. Changes: `src/devops_cli/roadmap/explain.py`, `src/devops_cli/lang/en/messages.py`, `tests/roadmap/test_roadmap_explain.py`.

- [x] 1.1 Add the tests: the line of a tool call shows `[argument <digest>]` after the program, two calls with the same digest show the same digest, and a tool event with no digest shows no argument part. They fail on the base.
- Verification: `$ uv run devops ci test tests/roadmap/test_roadmap_explain.py`
- [x] 1.2 Add `explain_trace_tool_digest` to `RoadmapMessages`, put `{digest}` after `{program}` in `explain_trace_tool`, and fill it from the `digest` field in `_event_line`
- Verification: `$ uv run devops ci test tests/roadmap/test_roadmap_explain.py`

## 2. Documents

Reads: `docs/roadmap/implement.md`. Changes: `docs/roadmap/implement.md`.

- [x] 2.1 Say in `docs/roadmap/implement.md` that a tool call in the trace holds the digest of its argument, so a reader sees a repeated call
- Verification: `$ uv run devops ci docs`

## Criteria

- Group 1: The line of a tool event in `explain --trace` shows the digest of its argument when the event holds one, and no argument part when it holds none.
11 changes: 11 additions & 0 deletions openspec/specs/roadmap-explain/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,14 @@ For a New item whose job record holds `refine.failed_at` younger than the wait o
#### Scenario: A held item
- **WHEN** a New item's refine round failed with a `provider` error at 12:00 UTC and the clock reads 12:10
- **THEN** the refine job is `no` and the reason names 13:00

### Requirement: The trace option prints the argument digest of a tool call
`explain <issue> --trace` SHALL show in the line of a `tool` event the digest of its argument, when the event holds one, so that a reader sees a repeated call. A `tool` event with no digest SHALL show no argument part.

#### Scenario: The same call twice
- **WHEN** the trace holds two `tool` events with the digest `abc123abc123`
- **THEN** each line says `[argument abc123abc123]`

#### Scenario: A tool call with no digest
- **WHEN** a `tool` event holds no digest
- **THEN** its line has no argument part
3 changes: 2 additions & 1 deletion src/devops_cli/lang/en/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2267,9 +2267,10 @@ class RoadmapMessages:
# The report of `devops roadmap explain --trace` (#3032).
explain_trace_none: str = "Issue #{number} has no trace of a run."
explain_trace_model: str = "{step}: model {model}, {tokens_in}/{tokens_out} tokens, {seconds} s"
explain_trace_tool: str = "{step}: tool {tool}{program}, {outcome}{status}{reason}"
explain_trace_tool: str = "{step}: tool {tool}{program}{digest}, {outcome}{status}{reason}"
explain_trace_tool_status: str = " (exit status {status})"
explain_trace_tool_program: str = " (program {program})"
explain_trace_tool_digest: str = " [argument {digest}]"
explain_trace_tool_reason: str = ": {reason}"
explain_trace_check: str = "{step}: check {command}, {result}"
explain_trace_check_status: str = "exit status {status}"
Expand Down
2 changes: 2 additions & 0 deletions src/devops_cli/roadmap/explain.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,14 @@ def _event_line(event: TraceEvent) -> str:
)
case TraceEventKind.TOOL:
program = fields.get("program")
digest = fields.get("digest")
reason = fields.get("reason")
status = fields.get("status")
return texts.explain_trace_tool.format(
step=step,
tool=fields.get("tool", ""),
program=texts.explain_trace_tool_program.format(program=program) if program else "",
digest=texts.explain_trace_tool_digest.format(digest=digest) if digest else "",
outcome=fields.get("outcome", ""),
status=(
texts.explain_trace_tool_status.format(status=status)
Expand Down
21 changes: 18 additions & 3 deletions tests/roadmap/test_roadmap_explain.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,12 +471,14 @@ def test_the_trace_of_an_item_gives_one_line_for_each_event_in_order(job_world:
lines = report.splitlines()
assert len(lines) == 3
assert lines[0] == "group 1: model model-a, 100/20 tokens, 1.5 s"
assert lines[1] == "group 1: tool shell (program ruff), refused"
assert lines[1] == "group 1: tool shell (program ruff) [argument abc123abc123], refused"
assert lines[2] == "group 1: check ruff check ., exit status 1"
assert (job_world.store.job_writes, job_world.store.comments_on(number)) == before


def test_a_shell_call_with_an_exit_status_shows_it_in_the_line(job_world: JobWorld) -> None:
"""#4393: the line of a tool call shows the digest of its argument, so a reader sees that the
model made the same call twice, and the exit status of a shell call."""
number = _seed(job_world)
trace = ImplementTrace(step="group 1")
trace.tool_call("shell", "git", "abc123abc123", "ok", status=128)
Expand All @@ -486,11 +488,24 @@ def test_a_shell_call_with_an_exit_status_shows_it_in_the_line(job_world: JobWor
report = render_trace(read_trace(job_world.store, number), number=number)

assert report.splitlines() == [
"group 1: tool shell (program git), ok (exit status 128)",
"group 1: tool shell (program git), ok (exit status 0)",
"group 1: tool shell (program git) [argument abc123abc123], ok (exit status 128)",
"group 1: tool shell (program git) [argument abc123abc123], ok (exit status 0)",
]


def test_a_tool_call_with_no_digest_shows_no_argument(job_world: JobWorld) -> None:
number = _seed(job_world)
_record_trace(
job_world,
number,
'{"events":[{"kind":"tool","step":"g","tool":"edit_file","outcome":"ok"}],"dropped":0}',
)

report = render_trace(read_trace(job_world.store, number), number=number)

assert report.splitlines() == ["g: tool edit_file, ok"]


def test_the_trace_says_how_many_earlier_events_the_bound_dropped(job_world: JobWorld) -> None:
number = _seed(job_world)
_record_trace(job_world, number, '{"events":[],"dropped":12}')
Expand Down
Loading