Skip to content

fix(roadmap): the implement row writes one result line for each Job #5476

Done

Description

@dan-petty

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:

So implement shows 4 successes in 9 attempts, but it has 3 successes in 8 Jobs.

Reproduction Steps

  1. Run the base query of docs/roadmap/job-success.md with |= "job=implement" over the window above.
  2. 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 _report twice 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 _report for an ended Job with a fake GitHub record and a fake result logger.
  • THEN The test observes the implement.job_state write before the log_job_result call.

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.spend holds both Jobs and implement.spend_counted holds the first Job.
  • THEN The result line holds tokens equal 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 no implement.spend.
  • THEN The result line holds result=stopped, the failure class and tokens=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 main prevent a second result line for one runner Job?: _report writes implement.job_state to the GitHub record before log_job_result, and _unreported skips 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 tokens hold on the implement result line?: The total input and output tokens of implement.spend minus implement.spend_counted. implement.spend accumulates 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_tokens returns 0 when implement.spend is absent. The reply reports no implement.spend for fix(roadmap): a claim release leaves the item In Progress #5118, so tokens=0 was correct. [sources: src/devops_cli/roadmap/implement/implement_submit.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    on Nov 13, 2026
  2. added
    type/bug
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Nov 13, 2026
  3. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor
  4. added
    priority/p2-medium
    on Nov 13, 2026
  5. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    A possible check for this item (agentic workflow spec, Table 3-1, "Result lines"): the count of implement lines 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 with succeeded or failed above 0, and 8 distinct items have an implement line. 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.

  6. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    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 the tokens=0 line, so no external tool covers it.

    Tool: none found

    Lacks:

    • A path in the project's own implement runner that reports the same ended Job twice
    • _report computing tokens as spend minus the spend already recorded, so a second report writes tokens=0
    • A confirmed cause for the result=stopped ... tokens=0 line of item fix(roadmap): a claim release leaves the item In Progress #5118
    • A first-written test that makes one result line per runner Job, using the GitHub record as the marker
    • A check that the count of implement result lines equals the count of runner Jobs that ended in the window

    Searches run:

    • Kubernetes Job completion tracking library report each Job once, results: 5
    • library deduplicate duplicate job result log lines idempotent reporting, results: 5
    • Python package report job result exactly once per job completion dedupe GitHub comment marker, results: 5

    Sources:

    Checked on 2026-11-17. A person decides what this means for the item. The check changes no label and closes no issue.

  7. added
    status/ready
    and removed
    status/new
    on Nov 18, 2026
  8. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 1130cd4 (see proposed design in issue body).

  9. dan-petty commented on Nov 25, 2026

    @dan-petty
    OwnerAuthor

    Returned to New (#5476 cannot be built as specified against origin/main):

    1. Contradiction with openspec/specs/roadmap-implement-job/record/spec.md: #5476 requires Tokens from the Job spend with "no subtraction of an earlier report." Committed record/spec.md (Counted spend, lines 133-154 from fix(roadmap): count the tokens of each implement Job once #4213/a243c25f2, and A 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) and tests/roadmap/implement/test_roadmap_implement_submit.py:2052-2070 (test_two_jobs_of_one_item_count_each_token_once) require subtracting implement.spend_counted because implement.spend accumulates across Jobs of an item.
    2. Already implemented / mismatch on evidence: src/devops_cli/roadmap/implement/implement_submit.py (_report, lines 384-422) already writes ImplementRecordKey.JOB_STATE via service_release before calling log_job_result, and _unreported (lines 207-218) skips items with implement.job_state. Item #5118 recorded "implement.stopped": "job", "implement.failure": "types", and no implement.spend key, so tokens=0 reflected no recorded spend.
  10. added
    status/new
    and removed
    status/ready
    on Nov 25, 2026
  11. added
    status/ready
    and removed
    status/new
    on Nov 25, 2026
  12. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  13. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 29, 2026
  14. removed
    status/in-review
    owner/agent
    on Nov 29, 2026
  15. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-29 16:17 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions