Skip to content

fix(roadmap): refine writes each item when that item is done #3631

Closed

Description

@dan-petty

Problem

A refine round plans all its items first and writes after, so a Service stop loses the finished work of the round. A stop now comes often, because each release rolls the Service.

  • src/devops_cli/roadmap/run.py:544 runs the plan and then the writes. A round took at least about 13 minutes. service.drain_timeout_seconds is 120 in the live ConfigMap.
  • Refine wrote no comment from 2026-11-05T12:18:55Z to at least 14:37Z. Before that, the longest gap in 11 hours was 59 minutes.
  • Five rollouts fell in the first part of that gap, 22 to 35 minutes apart, at 12:35Z, 13:01Z, 13:25Z, 14:00Z and 14:22Z, and one more at 14:34Z. Each came 4 to 10 minutes after a release.
  • At 13:25Z the log shows the stop of a devops-cli model round. For the other rollouts, the log gives no proof, because no line records the start or the end of a refine round.

The stop is the likely cause, not a proved one. GitHub budget holds fall in the same gap, and the data cannot divide the time between the two. A lost round also spends its model tokens again in the next round, on the same items.

Expected

Refine writes each item when that item is done. A stop ends the round and loses at most the item in progress. The log has one line when a refine round starts and one when it ends, with the counts.

Acceptance criteria

  • A test: a round of 3 items that stops after item 2 has written items 1 and 2, and the next round takes item 3 first.
  • A test: plan_refine without --confirm still writes nothing.
  • A test: a round logs its start and its end with the counts of items taken, written and failed.
  • Run live: refine writes during a period of three rollouts in 2 hours.

Existing tool considered

Existing project code. #3560 keeps the work of a stopped implement step in the same way. No new tool.

Related

Related: #3560, #3497

Proposed design

Problem statement

A refine round plans all its items before it writes any of them. A Service stop in the round loses every finished item, and the next round spends its model tokens on the same items again. Refine must write each item when that item is done.

Acceptance criteria

Requirement: Per-item write in the round

The refine round SHALL write each item's result as soon as that item's refinement finishes, before it takes the next item.

Scenario: Round of three items stops after item two

  • WHEN A refine round of 3 items stops after it writes item 2.
  • THEN Items 1 and 2 carry their refine result, and the next round takes item 3 first.

Requirement: No write without confirm

The refine round MUST write no item when plan_refine runs without --confirm.

Scenario: Plan run without confirm

  • WHEN plan_refine runs on a round of 3 items without --confirm.
  • THEN The round writes no comment, label or body change to any of the 3 items.

Requirement: Failed item does not stop the round

The refine round SHALL count an item whose write fails as failed and SHALL continue with the next item.

Scenario: Write of item two fails

  • WHEN The write of item 2 fails in a round of 3 items.
  • THEN The round writes item 3, counts taken=3, written=2 and failed=1, and leaves item 2 New.

Requirement: Round start and end log

The refine round SHALL log one line at its start and one line at its end, and the end line MUST give the counts of items taken, written and failed.

Scenario: Round with one failed item

  • WHEN A refine round takes 3 items, writes 2 and fails 1.
  • THEN The log holds one start line with the number of items taken and one end line with taken=3, written=2 and failed=1.

Existing Tool Considered

No alternatives check has run on this issue. The change modifies existing project code, src/devops_cli/roadmap/run.py and src/devops_cli/roadmap/refine.py, and no open tool or library covers the per-item write of a roadmap job. The written cost is about 40k output tokens to build with its tests, about 5k tokens a month to keep, and about 3k tokens for each fix, over about 2 days of elapsed time.

Key questions

  • Where does the round write an item's result?: The round writes each item inside its loop, as soon as that item's refinement finishes, before it takes the next item. (best practice) [sources: src/devops_cli/roadmap/run.py, src/devops_cli/roadmap/refine.py]
    • Chosen: Write each item inside the round loop after its refinement finishes. A stop loses at most the item in progress, and no second pass writes the items again.
    • Rejected: Keep the batch write after all items. A stop loses every finished item of the round, which is the defect.
    • Rejected: Write from a background thread while planning continues. It adds concurrency with no gain, and a stop still loses the item in progress.
  • How does the next round take the items that a stopped round did not write?: The write sets the item to Ready, so select_candidates returns it no more. The next round starts with the items that remain. (best practice) [sources: src/devops_cli/roadmap/refine.py, src/devops_cli/roadmap/run.py]
    • Chosen: Use the item's new status so the next round skips it. The status already records the finished work, and no new state can go stale.
    • Rejected: Keep a round cursor in a file. It adds state that a crash or a second lane can make stale, against ADR 0001.
  • What happens when the write of one item fails?: The round logs the failure, counts the item as failed, leaves the item New and continues with the next item. (best practice) [sources: src/devops_cli/roadmap/run.py, src/devops_cli/roadmap/failure.py]
    • Chosen: Log the failure, count it and continue. One bad item does not stop the other items, and the next round takes the item again.
    • Rejected: Abort the round at the first failed write. One item that fails stops the rest of the round and loses their work.
  • What does a refine round log?: The round writes one start line with the number of items taken and one end line with the counts of items taken, written and failed, through the existing logger. (best practice) [sources: src/devops_cli/roadmap/run.py]
    • Chosen: One start line and one end line through the existing logger. The two lines show the start and the end of each round, and the counts show what a stop lost.
    • Rejected: One line for each item only. No line records the start or the end of a round, so a lost round stays unseen.
  • Does plan_refine without --confirm still write nothing?: Yes. plan_refine stays a planner that returns the plan, and the round writes only when --confirm is set. (best practice) [sources: src/devops_cli/roadmap/refine.py, src/devops_cli/commands/roadmap.py, tests/roadmap/test_roadmap_refine.py]
    • Chosen: Keep the write behind --confirm. A plan run stays read-only, and its tests keep the same contract.
    • Rejected: Write on every plan run and drop --confirm. A plan run would change issues with no person's request.
  • Which existing tool or library covers this need?: No alternatives check has run. The need is a change to existing project code, and no open tool or library covers it. [sources: src/devops_cli/roadmap/run.py, src/devops_cli/roadmap/refine.py]
  • How is the live run check done?: The live run waits on three rollouts of the Service in 2 hours, which is outside this item. It moves to a new issue and does not hold this item. (best practice) [sources: CONTEXT.md, src/devops_cli/roadmap/run.py]
    • Chosen: Defer the live run to a new issue. The code and its tests can be delivered now, and the live check needs a release period.
    • Rejected: Hold this item until the live run happens. It keeps a testable fix in New for a release period that no code change starts.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

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

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. Recurring data loss and wasted model tokens on every release rollout, but the system recovers by retrying.
    • Value: Medium. Prevents loss of completed work and avoids re-spending model tokens on already-finished items.
    • Effort: Medium. Requires changing the write pattern from batch to incremental, adding start/end log lines, and three new tests.
    • Related: fix(roadmap): refine looks again when the cause of a wait ends #3483, which asks for a different change. Both change refine round behaviour in run.py, but #3483 fixes wait re-evaluation while the candidate changes the write order to per-item.
  3. added
    priority/p2-medium
    on Nov 5, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 6, 2026
  5. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 27c7019 (see proposed design in issue body).

    Moved to new items: #3793.

  6. added
    owner/agent
    status/in-progress
    and removed
    status/ready
    on Nov 7, 2026
  7. removed
    status/in-progress
    owner/agent
    on Nov 7, 2026
  8. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor
  9. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-07 06:18 UTC

  10. added a commit that references this issue on Nov 16, 2026
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