Repository navigation
Description
Problem Description
The implement row can write two result lines for one runner Job, and some implement lines show tokens=0. This changes the job grade and the tokens for each success of implement (docs/roadmap/job-success.md).
Evidence from the Service stream in Loki, 2026-11-12T12:58Z to 2026-11-13T16:00Z:
- Item fix(telemetry): keep one metric stream per workload #4697 has two lines 8 s apart, with two trace IDs:
result=ready tokens=13545198 seconds=3016at 02:13:42Z andresult=ready tokens=0 seconds=3016at 02:13:50Z (release 0.125.2). Both have the sameseconds, so both report the same Job. - Item fix(roadmap): a claim release leaves the item In Progress #5118 has
result=stopped class=types tokens=0 seconds=1008(release 0.129.0).
So implement shows 4 successes in 9 attempts, but it has 3 successes in 8 Jobs.
Reproduction Steps
- Run the base query of
docs/roadmap/job-success.mdwith|= "job=implement"over the window above. - Find the two lines of item fix(telemetry): keep one metric stream per workload #4697.
Expected vs Actual Behavior
Expected: one result line for each runner Job that ended, with the tokens of that Job.
Actual: a second report of the same Job writes a second line. src/devops_cli/roadmap/implement/implement_submit.py (_report) takes tokens as the spend minus the spend that the record already counted, so the second report gets 0. The cause of the second report (two rounds that report the same ended Job before the record marks it) is not confirmed.
Fix: find the path that reports one Job two times, make the report write one line for each Job (the GitHub record is the marker), and test it first. Then find why the line of #5118 has tokens=0.
Environment Diagnostics
devops-cli 0.125.2 to 0.129.0, the roadmap Service.
Logs, Traces, or Terminal Output
Found while writing the agentic workflow spec (#5443, gap G3).
Source: #5443
Alternatives check of 2026-11-23: none.
Tool: none found.
Reason: Searches for duplicate job-result lines, exactly-once reporting and token accounting found only generic reference pages, no maintained tool that writes one result line per runner Job or totals Job tokens; the fix is project code.
Lacks:
- No tool marks an ended runner Job in the GitHub record
- No tool suppresses a second result line for the same Job
- No tool writes total Job input and output tokens on the line
- No tool keeps recorded tokens on a stopped Job
Proposed design
Problem statement
The implement row wrote two result lines for one runner Job in release 0.125.2, and item #5118 wrote tokens=0. Current main writes implement.job_state before the result line, and _unreported skips a Job that has this state. The committed spec requires subtracting implement.spend_counted because implement.spend accumulates across Jobs of one item. Item #5118 had no implement.spend, so tokens=0 was correct. The change adds regression tests for these behaviors and corrects the issue's token premise.
Acceptance criteria
Requirement: A reported Job writes no second line
The implement report MUST write no result line for an item whose record holds implement.job_state.
Scenario: Two reports of one ended Job
- WHEN A test calls
_reporttwice for the same ended runner Job and the same GitHub record. - THEN The test observes one
roadmap job result:line for the Job, and the second call writes no line.
Requirement: The record write precedes the result line
The implement report SHALL write implement.job_state to the GitHub record before it calls log_job_result.
Scenario: Order of the record write and the result line
- WHEN A test runs
_reportfor an ended Job with a fake GitHub record and a fake result logger. - THEN The test observes the
implement.job_statewrite before thelog_job_resultcall.
Requirement: Counted spend is subtracted
The implement result line SHALL hold the tokens of implement.spend minus implement.spend_counted, so each Job counts its tokens once.
Scenario: Two Jobs of one item
- WHEN A test reports the second Job of an item whose
implement.spendholds both Jobs andimplement.spend_countedholds the first Job. - THEN The result line holds
tokensequal to the tokens of the second Job.
Requirement: A stopped Job with no spend writes zero
The implement result line of a stopped Job with no implement.spend MUST hold tokens=0 and the recorded failure class.
Scenario: A stopped Job with no spend
- WHEN A test reports an ended Job with
result=stopped, a failure class and noimplement.spend. - THEN The result line holds
result=stopped, the failure class andtokens=0.
Existing Tool Considered
The alternatives check of 2026-11-23 in the issue body gives verdict none and names no tool. Its block lists the lacks. No open, maintained tool covers the need. The change builds no production code; it adds regression tests in tests/roadmap/implement/test_roadmap_implement_submit.py and corrects the issue text. Written cost: about 0.5 developer-day and 15k tokens to build, keep and fix; no external dependency remains.
Key questions
- How does current
mainprevent a second result line for one runner Job?:_reportwritesimplement.job_stateto the GitHub record beforelog_job_result, and_unreportedskips an item that holds this state. The record is shared across rounds and restarts. [sources: src/devops_cli/roadmap/implement/implement_submit.py:207-218, src/devops_cli/roadmap/implement/implement_submit.py:384-422] - What value should
tokenshold on the implement result line?: The total input and output tokens ofimplement.spendminusimplement.spend_counted.implement.spendaccumulates across Jobs of one item, so the subtraction makes each Job count once. (best practice) [sources: openspec/specs/roadmap-implement-job/record/spec.md:133-154, tests/roadmap/implement/test_roadmap_implement_submit.py:2052-2070]- Chosen: Subtract counted spend. The committed spec and test require it, and the state marker prevents a duplicate report from subtracting the same Job twice.
- Rejected: Use total spend. A second Job would count the first Job's tokens again and inflate the total.
- Why did item fix(roadmap): a claim release leaves the item In Progress #5118 write
tokens=0?:_spend_tokensreturns 0 whenimplement.spendis absent. The reply reports noimplement.spendfor fix(roadmap): a claim release leaves the item In Progress #5118, sotokens=0was correct. [sources: src/devops_cli/roadmap/implement/implement_submit.py]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 13, 2026
Both touch implement_submit.py and deal with tokens being reported twice for implement Jobs, but #4200 fixes the Prometheus counter while this candidate fixes the Loki result line duplication.dan-petty commentedon Nov 13, 2026
A possible check for this item (agentic workflow spec, Table 3-1, "Result lines"): the count of
implementlines in a window equals the count of runner Jobs that ended in it. On 2026-11-13T16:00Z over 27 hours, kube-state-metrics shows 10 runner Jobs withsucceededorfailedabove 0, and 8 distinct items have animplementline. The Job series stay while the Job object exists, so a Job that ended before the window can also count. The check must read the end time of each Job, not only its series.devops-cli-service commentedon Nov 17, 2026
Alternatives check: none
Reason: Searches for an open tool or library that deduplicates job result reporting (idempotent, one report per Job, keyed by a GitHub record) returned only unrelated general pages and no such tool. The need is an internal fix in
src/devops_cli/roadmap/implement/implement_submit.py(_report) plus a diagnosis of thetokens=0line, so no external tool covers it.Tool: none found
Lacks:
implementrunner that reports the same ended Job twice_reportcomputingtokensas spend minus the spend already recorded, so a second report writestokens=0result=stopped ... tokens=0line of item fix(roadmap): a claim release leaves the item In Progress #5118implementresult lines equals the count of runner Jobs that ended in the windowSearches run:
Sources:
Checked on 2026-11-17. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 18, 2026
Status set to Ready at 1130cd4 (see proposed design in issue body).
dan-petty commentedon Nov 25, 2026
Returned to New (#5476 cannot be built as specified against
origin/main):openspec/specs/roadmap-implement-job/record/spec.md:#5476requiresTokens from the Job spendwith "no subtraction of an earlier report." Committedrecord/spec.md(Counted spend, lines 133-154 from fix(roadmap): count the tokens of each implement Job once #4213/a243c25f2, andA retry and a return to New clear the counted spend, lines 234-248 from fix(roadmap): check the premise before the first step #5886/1b12e5c82) andtests/roadmap/implement/test_roadmap_implement_submit.py:2052-2070(test_two_jobs_of_one_item_count_each_token_once) require subtractingimplement.spend_countedbecauseimplement.spendaccumulates across Jobs of an item.src/devops_cli/roadmap/implement/implement_submit.py(_report, lines 384-422) already writesImplementRecordKey.JOB_STATEviaservice_releasebefore callinglog_job_result, and_unreported(lines 207-218) skips items withimplement.job_state. Item#5118recorded"implement.stopped": "job","implement.failure": "types", and noimplement.spendkey, sotokens=0reflected no recorded spend.devops-cli-service commentedon Nov 25, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
devops-cli-service commentedon Nov 29, 2026
Released in v0.247.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.247.0
devops-cli-service commentedon Nov 29, 2026
Live since 2026-11-29 16:17 UTC