Repository navigation
Description
Problem
The row stage_ready reads a draft with a failed check in each round, and a failed check does not change until a push or a new run. Evidence from #3497, in the window 2026-11-03T15:05Z to 2026-11-04T15:05Z:
- The row spent 1841 requests in one repository. The 3 open drafts of the Service in that repository each have 1 failed and 2 cancelled check runs.
The code at origin/main f6d57ec:
_settlereads the pull request and its check runs for each draft (src/devops_cli/roadmap/stage_ready.py:89).k8s/README.md(thestage_readyitem) says that the row is due every 3 minutes and that a waiting draft costs 2 requests a round (12 an hour). 2 requests each 3 minutes give 40 an hour, so that document needs a correction with this change.
Expected
After the row sees a failed check on a draft, it waits before it reads that draft again. The wait starts short and grows to a limit, and it ends when the head of the pull request changes or when a webhook event for that pull request arrives. A draft with a running check keeps the current cadence.
The refine plan on #3497 proposes an exponential backoff from 15 minutes to 60 minutes, with the next read time in the job record. The plan of this item confirms these values.
Acceptance criteria
- A test: a draft with a failed check backs off, and the test holds the interval.
Existing tool considered
The job record already keeps the state of the row. A small backoff calculation in the row needs no library. tenacity is a dependency, but it wraps a call in one process, and this wait must stay across rounds and restarts.
Related
Split from #3497, which holds the evidence. It holds criterion 7 of that issue.
Source: #3497
Alternatives check of 2026-11-08: none.
Tool: none found.
Proposed design
Problem statement
The stage_ready row reads a draft with a failed check in each 3-minute round. A failed check does not change until a push or a new run, so the row spends GitHub requests with no result; one repository spent 1841 requests on the row in one day, and the three open drafts there each hold one failed and two cancelled check runs. The row also states 12 requests an hour for a waiting draft, but 2 requests each 3 minutes is 40 an hour. The change records a next read time in the item job record, backs off from 15 minutes to 60 minutes, and clears the wait on a new head; the row keeps its pull request read in each round, so a push clears the wait with no webhook. The stage_ready item of docs/CLUSTER.md states the new cost.
Acceptance criteria
Requirement: A failed check records a 15-minute wait
The stage_ready row SHALL record stage_ready.failed_sha, stage_ready.backoff_minutes and stage_ready.next_read_at in the item job record when a draft head has a failed check and the record holds no wait for that head.
Scenario: First failed read of a head
- WHEN the row reads a draft whose head SHA has a failed check and the record holds no
stage_ready.failed_sha - THEN the record holds
stage_ready.failed_shaequal to the head SHA,stage_ready.backoff_minutesof 15 andstage_ready.next_read_at15 minutes after the read.
Requirement: The wait skips only the check-runs read
The row SHALL read the pull request of a waiting draft in each round and SHALL make no check-runs request before stage_ready.next_read_at.
Scenario: A waiting draft costs one request a round
- WHEN a round runs while the record holds a
stage_ready.next_read_atin the future and the pull request head SHA equalsstage_ready.failed_sha - THEN the round sends
GET pulls/<n>for that draft and sends noGET commits/<sha>/check-runs.
Requirement: Repeated failures double the wait to 60 minutes
The row SHALL double stage_ready.backoff_minutes after each later failed read of the same head SHA, up to 60 minutes.
Scenario: The wait stops at 60 minutes
- WHEN the row reads the same failed head at the end of each recorded wait, from 15 minutes after the first failed read
- THEN the record holds
stage_ready.backoff_minutes15 after the first read and 30, 60, 60 and 60 after the four later reads.
Requirement: A changed head clears the wait
The row SHALL clear the wait and read the check runs at once when the head SHA of the pull request differs from stage_ready.failed_sha.
Scenario: A push resets the wait
- WHEN the row reads a draft whose head SHA differs from
stage_ready.failed_shawhile the record holds anext_read_atin the future - THEN the round sends
GET commits/<new-sha>/check-runsat once, and a failed check records a wait of 15 minutes.
Requirement: A running check keeps the normal cadence
The row SHALL read the check runs of a draft that has a running check in every round and SHALL record no wait for that head.
Scenario: A running check is read each round
- WHEN the row reads at
stage_ready.next_read_ata draft whose check runs include a running check - THEN the record holds no
stage_ready.next_read_at, and the next round sendsGET commits/<sha>/check-runsfor that draft.
Requirement: A cancelled check keeps the normal cadence
The row SHALL keep the 3-minute cadence for a draft whose checks are cancelled and include no failed check.
Scenario: A cancelled check is read each round
- WHEN the row reads a draft whose check runs include a cancelled check and no failed check
- THEN the record holds no
stage_ready.next_read_at, and the next round reads the check runs of that draft.
Requirement: A passing head marks the draft ready
The row SHALL clear the wait and ask draft_readiness to mark the draft ready when every check of the head has passed.
Scenario: A passing head clears the wait
- WHEN the row reads the check runs at
stage_ready.next_read_atand every check has passed - THEN the row marks the pull request ready and the record holds no
stage_ready.next_read_at.
Requirement: The wait survives a restart
The row SHALL take the wait from the item job record on the issue, so that a Service restart keeps it.
Scenario: A restart keeps the wait
- WHEN a Service restart occurs while the record holds a
stage_ready.next_read_atin the future - THEN the first round after the restart sends no check-runs request for that draft before the recorded time.
Requirement: The stage_ready item states the new cost
The stage_ready item of docs/CLUSTER.md SHALL state the cost of a draft whose checks run, the cost of a draft that waits after a failed check, the 15-to-60-minute wait, and that only a failed check starts the wait.
Scenario: The item cost matches the cadence
- WHEN a reader opens item 18 of the Roadmap service section of
docs/CLUSTER.md - THEN the item states 2 requests a round and 40 an hour at the 3-minute interval for a draft whose checks run, 1 request a round for a draft that waits after a failed check, plus 2 requests for each recorded wait, waits of 15, 30 and 60 minutes, and that a cancelled, running or absent check keeps the 3-minute cadence.
Existing Tool Considered
The alternatives check of 2026-11-08 gave the verdict none: no open, maintained tool covers the need. It considered tenacity (Apache-2.0, last activity 2026-10-07) and backoff (MIT, last activity 2022-10-05). Both retry one call inside one process. Neither keeps a next-read time in the GitHub issue job record, skips a later poll round after a restart, or ends the wait on a changed head SHA. A scheduler with its own persistent store would add a second copy of the row state, which the issue job record already holds (ADR 0016). The change builds a small calculation in src/devops_cli/roadmap/stage/stage_ready.py and three record fields in src/devops_cli/roadmap/stores/store.py. The cost is about 70 lines of code, about 90 lines of tests, about 7,000 tokens to build, keep and fix, and about 3 hours of elapsed time.
Key questions
- Which document holds the
stage_readyitem, and what does it state for a waiting draft?:docs/CLUSTER.md, item 18 of the Roadmap service section at line 49, holds thestage_readyitem. It states that the row is due every 3 minutes and that a waiting draft costs 2 requests a round (12 an hour). The two values do not agree: 2 requests each 3 minutes is 40 an hour.k8s/README.mdis the Service guide for the cluster and holds nostage_readyitem. [sources: docs/CLUSTER.md:49, k8s/README.md] - Where does the row keep the next read time and the wait?: In the item job record in the issue body, under
stage_ready.failed_sha,stage_ready.backoff_minutesandstage_ready.next_read_at. The record already holdsstage.prandstage.ready, and it survives a Service restart (ADR 0016). (best practice) [sources: src/devops_cli/roadmap/stores/store.py:227, docs/adr/0016-labels-hold-the-roadmap-items-fields.md:19, docs/CLUSTER.md:49]- Chosen: Item job record. The record already keeps the row state, and the Service reads it again after a restart.
- Rejected: A new file on the Service volume. It adds a second source of the row state and needs its own cleanup (ADR 0016).
- Rejected: An in-memory cache. A restart loses the wait.
- Which check result starts a wait?: A check that ended as
failed. A running check keeps the 3-minute cadence, a cancelled check keeps it too, and a head whose checks all passed goes todraft_readiness. (best practice) [sources: src/devops_cli/github/check_verdict.py:88, src/devops_cli/roadmap/stage/stage_ready.py:142, docs/CLUSTER.md:49]- Chosen: A failed check only. The issue names a failed check, and each draft in the evidence holds one.
- Rejected: A failed or a cancelled check. A cancelled check also does not change, but the issue asks for a failed check only; a cancelled-only draft keeps the cadence.
- Rejected: Any check that
exit_code1 covers (failed, cancelled or unread).exit_codeconflates the three, and an unread check is a read error, not a stable failure. - Rejected: Any check that has not passed, including running. A running check can finish with no push, so the row must keep the current cadence.
- What is the wait sequence and the cap?: 15 minutes on the first failed read of a head, then 30, then 60. The wait stays at 60 minutes. The body of this issue records that the refine plan on fix(service): the rows stop repeating reads that find no change #3497 proposes an exponential backoff from 15 to 60 minutes and that the plan of this item confirms these values; fix(service): the rows stop repeating reads that find no change #3497 (fetched 2026-11-14) shows criterion 7 moved to fix(roadmap): stage_ready backs off after a failed check #3671, and
docs/CLUSTER.md:49holds the 3-minute cadence. (best practice) [sources: docs/CLUSTER.md:49, https://github.com/fix(service): the rows stop repeating reads that find no change #3497]- Chosen: 15, 30 and 60 minutes. The issue body confirms the 15-to-60-minute plan of fix(service): the rows stop repeating reads that find no change #3497.
- Rejected: 15, 30, 45 and 60 minutes. The plan states a doubling wait, not a linear step.
- Rejected: 5, 10, 20 and 40 minutes. The issue body names 15 minutes as the first wait.
- Does the wait stop the pull request read?: No. The row reads the pull request (
GET pulls/<n>) in every round and compareshead.shawithstage_ready.failed_sha. It skips only the check-runs read. A waiting draft then costs 1 request a round, not 2. (best practice) [sources: src/devops_cli/roadmap/stage/stage_ready.py:135, docs/CLUSTER.md:49]- Chosen: Keep the pull request read each round. The row sees a push at the next round, and the wait costs one request a round.
- Rejected: Skip both reads until the next read time. The review of the plan found that a push then waits up to 60 minutes.
- Rejected: Skip both reads and wait for a webhook clear. No
pull_requestscoped update exists, so the clear has no path (ADR 0017). That part is deferred.
- How does a new head clear the wait?: The row reads the pull request in each round. When
head.shadiffers fromstage_ready.failed_sha, the row clears the wait and reads the check runs at once. (best practice) [sources: src/devops_cli/roadmap/stage/stage_ready.py:135, docs/CLUSTER.md:49]- Chosen: Compare the head SHA in each round. The row already reads the pull request, so the check costs no extra request.
- Rejected: Clear the wait only on a webhook event. The Service has no
pull_requestscoped update, so this path is deferred to a new issue.
- Which function decides that a check failed?: A new pure helper
_check_stateinstage_ready.pyclassifies the check runs aspassed,running,failed,cancelled,unreadornonefromCheckVerdictSummary.fail_count,cancel_count,pending_count,unread_countandreports_nothing. Onlyfailedstarts a wait;draft_readinessstays the one gate that decides readiness. (best practice) [sources: src/devops_cli/github/check_verdict.py:88, src/devops_cli/roadmap/stage/stage_ready.py:142, src/devops_cli/roadmap/implement/implement_pull.py:210, openspec/specs/roadmap-stage/ready/spec.md:74]- Chosen: A new helper
_check_state. The row needs the reason, and the readiness gate keeps its one job. - Rejected: A reason from
draft_readiness.draft_readinessreturns aReadinesswhoseexit_code1 covers failed, cancelled and unread, so it cannot say which; four call sites change. - Rejected: A second read of the check runs in the row. A second read costs a request and can see another state.
- Chosen: A new helper
- Does the wait survive a Service restart?: Yes. The record lives on the issue, and the row reads it again at each round. [sources: docs/adr/0016-labels-hold-the-roadmap-items-fields.md:19, src/devops_cli/roadmap/stores/store.py:227, docs/CLUSTER.md:49]
- Does the change fit in one pull request?: The backoff and the documentation fit in one pull request. The webhook clear does not:
SCOPED_UPDATESholdsissuesevents only (ADR 0017), so apull_requestorcheck_rundelivery has no scoped update. The review of the plan refused the two parts in one pull request, so the webhook clear goes to a new issue. (best practice) [sources: src/devops_cli/roadmap/run.py:1153, docs/adr/0017-each-subscribed-webhook-event-runs-the-update-scoped-to-it.md:18, openspec/specs/roadmap-scoped-updates/spec.md:19]- Chosen: Split the webhook clear from the backoff. The review of the plan asks for this split, and the backoff is safe with the pull request read kept.
- Rejected: One pull request for both parts. The review refused it: the webhook clear needs a scoped update that does not exist.
- Rejected: Raise the effort and keep one pull request. The missing scoped update is a change of the router, not more work in the row.
- What does the
stage_readyitem state for the cost?: 2 requests a round, or 40 an hour at the 3-minute interval, for a draft whose checks run. 1 request a round, or 20 an hour, for a draft that waits after a failed check, plus 2 requests for each recorded wait. Waits of 15, 30 and 60 minutes. A cancelled, running or absent check keeps the 3-minute cadence. (best practice) [sources: docs/CLUSTER.md:49, src/devops_cli/roadmap/stores/github_store.py:894]- Chosen: State 40 and 20 an hour with the wait. 2 requests each 3 minutes is 40 an hour, and the waiting draft makes one request a round.
- Rejected: Keep 12 an hour. 12 an hour does not follow from 2 requests each 3 minutes.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 5, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(roadmap)scope of the title gives the scope.It wastes API requests but does not break functionality.It reduces wasted API calls without changing user-facing behaviour.A small backoff calculation in the row needs no new library.Both address failed checks in the stage row, but 3493 stops one item from suspending the row while this item adds read backoff after a failed check.fix(service): count each GitHub request with its HTTP status (#3686)
devops-cli-service commentedon Nov 7, 2026
Status set to Ready at 0550497 (see proposed design in issue body).
devops-cli-service commentedon Nov 8, 2026
Alternatives check: none
Reason: The searches turned up only general in-process retry libraries (tenacity, backoff), which wrap one call inside one process and cannot hold a next-read time in the item job record or skip a later poll round after a restart. No tool covers a backoff that lives in the GitHub issue job record, resets on a changed head SHA and clears on a pull_request webhook event, so the small calculation in stage_ready.py is the right shape.
Tool: none found
Lacks:
Tools considered:
Searches run:
Sources:
Checked on 2026-11-08. A person decides what this means for the item. The check changes no label and closes no issue.
dan-petty commentedon Nov 14, 2026
Cannot build as low effort in one safe pull request: the design needs a pull_request scoped update that does not exist (SCOPED_UPDATES holds issue events only, ADR 0017), so the webhook clear requirement has no path. Without that clear the row cannot see a new head before the 60-minute wait ends, and the changed-head reset cannot work. The backoff alone would trap a draft after a push. Split the webhook clear (payload model, scoped update, store clear, tests) from the backoff, or raise the effort.
15 remaining items
devops-cli-service commentedon Nov 16, 2026
The runner Job devops-cli-implement-devops-cli-3671-656474 ended: succeeded.
Image digest: sha256:d1c0e4299edebb4b31ade10343b7ac00ee0a875023756932aa25ad9aebca241a
The last lines of its log:
Failure class:
ci_infra.Action taken: none.
Action left:
retry: run the item again.The Job left this item without a result. The item is Blocked. When a retry can fix the class of the stop, the Service starts a new Job in the next round. The limit is
roadmap.implement.continuations_per_item, and the comment of that round says so. If no continuation is left, fix the cause. Then commentimplement: retry. A new runner image also clears the stop. This holds only if a retry can fix the class of the stop. The limits ofroadmap.implement.digest_clears_per_classandroadmap.implement.digest_clears_per_itemmust also allow it.devops-cli-service commentedon Nov 16, 2026
Cleared the stop at job by the rule
continue: the runner Job devops-cli-implement-devops-cli-3671-656474 ended without a result. The classci_infraof the stop is one that a new attempt can fix. This is continuation 1 of 4 for this item. The item is Ready again. The Service takes it in the next round. The new Job takes the branch fromorigin, so it keeps the work that the run pushed there.dan-petty commentedon Nov 16, 2026
Done by #5906: the row
watchhas the 30-minute failed-head backoff of this issue (src/devops_cli/roadmap/watch_row.py:338,docs/CLUSTER.md:49), andtests/roadmap/test_roadmap_watch_row.py:158holds it. The plan #5993 closed as stale (verdict Issue changed). The REST-fallback order defect that a vet found is filed as its own item.devops-cli-service commentedon Nov 16, 2026
Plan pull request #5993 closed with no merge. The job waits for an edit of the text of this item, or for a commit that changes a file that the reason names.
The reason, from the last comment of dan-petty on the pull request: