Repository navigation
Description
Problem Description
The implement row can start a Job for an item while a stage Job for the same item still runs. The stage Job then pushes a new head to the plan pull request, the Plan Check starts again, and the implement Job leaves its item out. The Service records that Job as a stop of class ci_infra for "a Job that ended without a result". It counts a failed attempt and spends one of the 4 continuations of the item.
Reproduction Steps
Observed on 2026-12-01 for item #7970 and plan pull request #7997 (times in UTC).
- 01:50:19 the stage row creates Job
devops-cli-stage-devops-cli-7970-d4aef7f857. It ends at 02:02:03. - 01:59:47 the implement row creates Job
devops-cli-implement-devops-cli-7970-6aea75. - 02:01:34
devops-cli-service[bot]force-pushes the plan branch, from89fe83557toc52047a80. - The prepare phase of the implement Job reports: "The run left item fix(ci): DevContainer Image averages over the 360 s limit #7970 out: The check Plan Check of its plan pull request still runs." Each container exits 0.
- 02:09:44 the Service records
result=stopped class=ci_infra tokens=0 seconds=213. At 02:10 it clears the stop by the rulecontinue("continuation 1 of 4") and creates a second Job.
Expected vs Actual Behavior
Expected: the implement row starts no Job for an item with an active stage Job, and a Job that leaves its item out records no stop and spends no continuation.
Actual: one Job of about 3 minutes is lost, the success metrics count a failure, and the item has one continuation less. After 4 such cases the item stays Blocked.
Environment Diagnostics
Service v0.266.0, runner v0.265.4, repository dan-petty/devops-cli.
Pre-Submission Checklist
- I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
- I have checked existing issues and pull requests to ensure this is not a duplicate.
Source
Source: #7997
Alternatives check of 2026-12-01: rejected.
Rejected by ADR 0021. A newer fact can change an ADR.
Tool: Kubernetes Lease (https://github.com/kubernetes/kubernetes), Apache-2.0, last activity 2026-11-27, maintained.
Reason: Searches found no library for per-item exclusion between two Job templates. A Kubernetes Lease covers only the lock part, and ADR 0021 rejects it; the skip result and continuation rules stay project code.
Covers:
- Per-item named lock with holder identity and expiry
- Lock records read through the existing Kubernetes client
- Exclusion between the stage row and the implement row
Lacks:
- No rule maps the Job labels to a per-item lock
- No skipped result and no continuation accounting
- Each renewal is an API write and needs a pod token
Proposed design
Problem statement
The implement row can start a Job for an item while a stage Job for the same item runs. The stage Job pushes a new head, the Plan Check starts again, and the implement Job leaves its item out. The Service records a ci_infra stop, counts a failed attempt, and spends one continuation. The same wrong stop occurs when the plan pull request waits for a merge. The change makes the implement round skip an item with a running stage Job. It also writes a skipped result for a Job that leaves its item out, so the Service records no stop and spends no continuation.
Acceptance criteria
Requirement: Running stage Job blocks the implement round
The implement round SHALL create no implement Job for an item that a running stage Job works on.
Scenario: Item with a running stage Job
- WHEN The stage Job list names a running stage Job for item fix(ci): DevContainer Image averages over the 360 s limit #7970, and the implement round selects the items of the repository.
- THEN The round calls the stage Job list with the stage selector, and it creates no implement Job for item fix(ci): DevContainer Image averages over the 360 s limit #7970.
Requirement: Free item still starts
The implement round SHALL create an implement Job for a free Staged or Planned item when another item has a running stage Job.
Scenario: Free item beside a busy item
- WHEN The stage Job list names a running stage Job for one item, and another Staged item is free.
- THEN The round creates one implement Job, and the item of that Job is the free item.
Requirement: Publish writes the skip result
The publish phase SHALL record implement.result as skipped when the run state names a left-out reason.
Scenario: Left-out state at publish
- WHEN The state file of the run says that the run ended, and it names a left-out reason, such as a pending Plan Check or a plan that waits for a merge.
- THEN The item records
implement.resultasskipped, and it records noimplement.stopped.
Requirement: Skip result records no stop
The implement report SHALL record no stop for a Job whose item records implement.result as skipped.
Scenario: Job with the skip result
- WHEN An implement Job ended, and its item records
implement.resultasskipped. - THEN The report records
implement.job_stateassucceeded, and it writes noimplement.stoppedand noimplement.failure.
Requirement: Skip spends no continuation
The Service SHALL count a Job that records implement.result as skipped as no failed attempt and no continuation.
Scenario: Skip result in the counters
- WHEN The report runs for an implement Job whose item records
implement.resultasskipped. - THEN The counter
devops_cli_service_implement_failures_totaltakes no increment, andimplement.continuationskeeps its value.
Requirement: Skip leaves the item selectable
The implement round SHALL select the item again when its stage Job ended and its Plan Check passed.
Scenario: Item after the skip
- WHEN The item records
implement.resultasskippedand no stop, and the stage Job list names no running Job for it, and its Plan Check passed. - THEN The next selection returns the item as an implement target.
Existing Tool Considered
Kubernetes Lease (https://github.com/kubernetes/kubernetes), Apache-2.0, maintained. The alternatives check in the issue body records the verdict rejected. ADR 0021 rejects a Lease for each lock, and the check found no library for per-item exclusion between two Job templates. The block lists what the tool covers and lacks. The proposal maps the stage Job labels to the item in the implement round, and it adds the skipped result and the continuation rule in project code. Estimated cost: about 20,000 tokens to build, 10,000 to keep, 10,000 to fix, and about 2 days.
Key questions
- How does the implement round know that an item has a running stage Job?: The round lists the stage Jobs with
stage_jobs_selector(). It takes the running Jobs of its repository by the owner and repository labels. It passes the item-to-Job map toplan_implement, and the plan leaves each busy item out with a reason that names the stage Job. (best practice) [sources: docs/CLUSTER.md:106, src/devops_cli/roadmap/stage/stage_submit.py:296, src/devops_cli/roadmap/implement/implement_submit.py:28, src/devops_cli/k8s/cluster_job.py:162, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:63]- Chosen: Read the stage Job list. The stage row uses the same list as the lock, and the Job labels name the item, the owner and the repository.
- Rejected: Read the check runs of the plan pull request in the round. The round reads a head that the stage Job has not pushed yet, so it cannot see the new head.
- Rejected: Use a Kubernetes Lease for each item. ADR 0021 rejects a Lease for each lock, because each renewal is an API write and agent pods hold no API token.
- Rejected: Use the item status label. No status label names a running stage Job.
- How does a left-out implement Job report that it did no work?: The publish phase reads a state that ended with a left-out reason. It writes
implement.resultasskippedand exits 0. The report treatsskippedas no stop, so it writes noimplement.stoppedand spends no continuation. (best practice) [sources: src/devops_cli/roadmap/implement/implement_phases.py:1036, src/devops_cli/roadmap/implement/implement_submit.py:157, src/devops_cli/roadmap/stores/store.py:421, src/devops_cli/roadmap/stores/store.py:451, src/devops_cli/roadmap/implement/implement_submit.py:221]- Chosen: Add the result
skippedand write it in publish. The enum holds the ends of a run, publish is the last phase, and the Service decides a stop by the result value. - Rejected: Write the result in prepare. The record says that
implement.resultis the last mark of the end, and publish is the last phase. - Rejected: Reuse the result
yielded.yieldedmeans that an agent or a person claimed the item, so the record would name the wrong cause. - Rejected: Exit 75. The Service reads no exit status of an implement Job as a skip; it reads
implement.result. - Rejected: Record a stop of class
head_moved. A stop still counts a failed attempt and can spend a continuation.
- Chosen: Add the result
- Which left-out reasons write the skip result?: Every left-out reason writes
skipped. The prepare phase judges the item again at the next round, so a persistent reason leaves the item out before it starts a Job. A plan pull request that waits for a merge is one such reason. (best practice) [sources: src/devops_cli/commands/roadmap_jobs.py:1033, src/devops_cli/roadmap/implement/implement.py:341, src/devops_cli/roadmap/implement/implement.py:495]- Chosen: Every left-out reason. The next round judges the item again, so a persistent reason starts no Job.
- Rejected: Only a check that still runs. The reason is a message, not a value, and the other transient reasons keep the wrong stop.
- Rejected: Only a reason that names a check. A check that cannot be read or that was cancelled also leaves the item out, and the Job did no work in each case.
- Which check decides that the Plan Check still runs?: The prepare phase calls
_pull_reason. It reads the check runs of the head of the plan pull request withread_check_runs. A check in bucketCheckBucket.PENDINGgivesimplement_left_check_running, and the message names the check. In the reproduction the pending check isPlan Check. [sources: src/devops_cli/roadmap/implement/implement.py:547, src/devops_cli/roadmap/implement/implement.py:565, src/devops_cli/lang/en/messages.py:4008, .github/workflows/pr-checks.yml:132, tests/roadmap/implement/test_roadmap_implement_selection.py:883] - Which labels identify the stage Job of one item?: The stage Job carries the component, part-of, managed-by, owner, repository and item labels.
stage_job_labelswrites them, andstage_jobs_selectorselects the Jobs by the component label. The round takes the Jobs of its repository by the owner and repository labels. [sources: src/devops_cli/k8s/cluster_job.py:149, src/devops_cli/k8s/cluster_job.py:162, src/devops_cli/roadmap/stage/stage_submit.py:296, docs/CLUSTER.md:106] - Which rule records a stop when an implement Job ends with no result?:
_settles_as_stopreturns true for an open item that is In Progress, or Ready or Planned with no stop._reportthen sets Blocked and recordsimplement.stoppedasjob. The clear rulecontinuespends one continuation when the class has the actionretry. [sources: src/devops_cli/roadmap/implement/implement_submit.py:221, src/devops_cli/roadmap/implement/implement_submit.py:341, docs/CLUSTER.md:57] - Which tests cover the implement round, the phases and the stage Job list?:
tests/roadmap/implement/test_roadmap_implement_submit.pycovers the round and the report.tests/roadmap/implement/test_roadmap_implement_selection.pycovers the selection.tests/roadmap/implement/test_roadmap_implement_phases.pycovers the phases.tests/roadmap/stage/test_roadmap_stage_submit.pycovers the stage Job list. [sources: tests/roadmap/implement/test_roadmap_implement_submit.py, tests/roadmap/implement/test_roadmap_implement_selection.py, tests/roadmap/implement/test_roadmap_implement_phases.py, tests/roadmap/stage/test_roadmap_stage_submit.py]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Dec 1, 2026
The race wastes continuations and can block an item after four occurrences, increasing error rates without a hard CI failure.Both stop the implement job from starting when the plan is not ready, but #3976 checks for already-failed checks while the candidate checks for an active stage Job running concurrently.devops-cli-service commentedon Dec 1, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.
dan-petty commentedon Dec 1, 2026
Second case, 2026-12-01 (UTC), with another reason for the same result, item dan-petty/danielpetty.com#149 and plan pull request #154:
devops-cli-implement-danielpetty-com-149-ee87c1.class=ci_infra tokens=0 seconds=42(runner v0.268.2).So a Job that leaves its item out is recorded as an infrastructure stop for more than one reason of the left-out list. While a plan waits for a merge, each such Job can spend one continuation.
devops-cli-service commentedon Dec 1, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (9)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Dec 1, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
devops-cli-service commentedon Dec 1, 2026
Released in v0.268.5: https://github.com/dan-petty/devops-cli/releases/tag/v0.268.5
devops-cli-service commentedon Dec 1, 2026
Live since 2026-12-01 12:40 UTC