Repository navigation
Description
Problem Description
The status row redeliver (src/devops_cli/github/hook_redelivery.py) has no limit on its requests, and after a long stop it does not read all the failed deliveries.
- One round sends one
POST /app/hook/deliveries/<id>/attemptsfor each pending guid. No cap applies. - One round reads one page of 100 deliveries and moves the cursor to the newest ID. It never reads the other deliveries that came after the earlier cursor.
- The ledger keeps no record of an accepted attempt. The row asks again each round until it reads a 2xx for the guid on that one page, or until the delivery is 3 days old.
- A rate limit ends the round. The next round starts again at the oldest pending guid.
- Each POST takes a place in the hourly budget of the Service (500 by default). At 7 minutes for each round, about 60 pending guids use the full budget.
A rate limit wait is obeyed in the process: the session waits 60 s or more before each of 2 resends and holds the requests of the identity until the last wait ends (#7911). The hold is in memory only. A failed round writes no success stamp, so the row is due again before 7 minutes pass, until service.max_failed_rounds stops it for that input.
Reproduction Steps
Run redeliver_failed_deliveries against the fake GitHub API of the tests, on the fix of #7911:
- List 100 failed deliveries and run one round.
- List 1,000 newer failed deliveries and run a round.
- Run one more round.
- Answer the 50th POST and each later one with 403
API rate limit exceeded for integration ID ...and no rate-limit header. Run two rounds.
Expected vs Actual Behavior
Expected: a round sends a set number of attempts at most, reads each page back to the cursor (with a page cap), and does not ask again for an accepted attempt before GitHub records its result.
Actual:
- Step 2: 200 POSTs. The cursor moves to the newest ID. 900 new failed deliveries are never read.
- Step 3: the same 200 POSTs again.
- Step 4: each round sends 52 POSTs (49 accepted, then 3 refused on the 50th) and starts at the same guid.
Environment Diagnostics
devops-cli 0.264.1, Python 3.14.10, devcontainer. Offline probe with the test fake.
Alternatives check of 2026-11-30: in-use.
The repository already uses this tool.
Tool: gidgethub (https://github.com/gidgethub/gidgethub), Apache-2.0, last activity 2026-11-20, maintained.
Reason: No tool caps POST attempts per round or records accepted attempts. gidgethub waits on rate limits and iterates pages, but the row must hold the cap, cursor and ledger.
Covers:
- Waits for the GitHub rate-limit reset
- Iterates result pages through Link headers
- Handles the authenticated GitHub session
Lacks:
- No cap on POST attempts in one round
- No page cap with a stored cursor
- No ledger of accepted attempts
- No suppression of a repeated POST
Proposed design
Problem statement
The redeliver row of the roadmap Service sends one POST for each pending guid and has no cap. It reads one list page and moves the cursor to the newest ID, so it skips the deliveries between the old cursor and that page. It keeps no record of an accepted attempt, so it sends the same POST again each round. This change caps the POSTs and the pages, resumes from a stored page cursor, and suppresses a POST after GitHub accepts it.
Acceptance criteria
Requirement: Round POST cap
A redeliver round SHALL send no more than 40 POST requests to /app/hook/deliveries/{id}/attempts.
Scenario: A round with more pending guids than the cap
- WHEN The ledger holds 100 pending guids with no accepted record, and the fake session accepts each POST.
- THEN The fake session records 40 POST requests to the attempts path, and 60 pending guids still have no
last_attempt_atvalue.
Requirement: Page cap with stored cursor
A redeliver round SHALL read at most 12 list pages and SHALL store the next page cursor in the ledger when it reaches that cap.
Scenario: A backlog larger than the page cap
- WHEN The ledger delivery cursor is 1000 and 1,300 newer deliveries span 13 pages of 100 entries, each page with a
Linkheader. - THEN The round sends 12 GET requests, stores the page cursor for page 13, and keeps the delivery cursor at 1000.
Requirement: Backlog read to cursor
A redeliver round SHALL read each page from the stored page cursor until it reads an entry at or below the delivery cursor.
Scenario: A long stop leaves 1,000 newer deliveries
- WHEN The ledger delivery cursor is 1000, 1,000 newer deliveries fill 10 pages, and page 11 holds delivery 1000.
- THEN The round sends 11 GET requests, records all 1,000 deliveries in the pending set, sets the delivery cursor to the newest delivery ID, and clears the page cursor.
Requirement: Accepted attempt suppression
The redeliver row SHALL record each 2xx POST acceptance and SHALL NOT send another POST for that guid before GitHub lists a newer delivery entry for the guid or the guid passes the 3-day age limit.
Scenario: An accepted attempt waits for the GitHub result
- WHEN A round accepts the POST for a guid and the next list holds no newer entry for that guid.
- THEN The next round sends no POST for that guid and the ledger keeps the accepted record.
Requirement: Accepted record cleared by a newer result
The redeliver row SHALL clear the accepted record of a guid when GitHub lists a delivery for that guid with a later delivered_at value.
Scenario: GitHub records a newer failed attempt
- WHEN The accepted record has
delivered_at10:00 and the next list holds a failed delivery for the same guid at 10:05. - THEN The ledger clears the accepted record and the round sends one POST for the guid.
Requirement: Accepted attempt saved before a rate limit
The redeliver row SHALL save the ledger after each accepted POST and before it sends the next POST.
Scenario: A rate limit ends a round after an accepted attempt
- WHEN The fake session accepts 39 POSTs and then raises
GitHubRateLimitErroron the 40th. - THEN The ledger holds 39 accepted records and the next round sends no POST for those 39 guids.
Requirement: Least recently attempted first
The redeliver row SHALL choose pending guids by the oldest last_attempt_at value, then by the oldest delivery ID.
Scenario: The cap rotates over the pending set
- WHEN The ledger holds 60 pending guids with
last_attempt_at10:00 and 40 pending guids withlast_attempt_at09:00. - THEN The round sends POSTs for the 40 guids with
last_attempt_at09:00, oldest delivery ID first.
Existing Tool Considered
Alternatives check in the issue body: gidgethub, verdict in-use. The check lists what gidgethub covers and what it lacks. This change keeps gidgethub for the authenticated session, the rate-limit wait and the page iteration that the check names as covered. It adds the parts that the check names as lacking, in src/devops_cli/github/hook_redelivery.py: a POST cap of 40 for each round, a 12-page cap with a stored page cursor, an accepted-attempt ledger, and the suppression of a repeated POST.
Key questions
- Which parts of the issue remain after fix(service): redeliver once for the App with a valid JWT #7938?: The code already continues a round after a refused attempt and raises the first refusal after the last attempt. It asks the App, so only one repository reads the deliveries. The remaining parts are the POST cap, the page cap with a stored page cursor, the accepted-attempt ledger and the least-recently-attempted order. [sources: src/devops_cli/github/hook_redelivery.py, docs/SERVICE_PATTERNS.md]
- What limit applies to POST attempts in one round?: A round sends at most 40 POST attempts. The cap is a constant in
src/devops_cli/config/defaults.py. The row sends the oldest attempts first. The issue body states a budget of 500 requests in an hour. At 7-minute rounds, 40 POSTs and 12 list pages use at most 446 requests in an hour, so 40 leaves a margin. (best practice) [sources: src/devops_cli/github/hook_redelivery.py, src/devops_cli/config/defaults.py]- Rejected: No cap. The row spends the hourly budget and repeats attempts.
- Rejected: 60 attempts per round. 60 POSTs and 12 pages use 617 requests in an hour, above the 500 budget.
- Chosen: 40 attempts and 12 pages per round. 52 requests per round use at most 446 requests in an hour, below the 500 budget.
- How does a round read each page back to the cursor?: The round reads the next page URL from the
Linkheader of the list response. It stops when it reads an entry at or below the delivery cursor, or after 12 pages. At the page cap it stores the next page cursor in the ledger. The next round continues from that cursor. (best practice) [sources: src/devops_cli/github/hook_redelivery.py, src/devops_cli/github/session.py, src/devops_cli/roadmap/stores/github_store.py]- Rejected: One page only. The current row skips the deliveries after the first page.
- Rejected: Page number query. The App hook deliveries endpoint pages by the
Linkheader, not by a page number. - Chosen: Link-header cursor with a 12-page cap. It reads the backlog across rounds and bounds the list requests.
- How does the row stop a repeated POST after an accepted attempt?: The row stores an accepted attempt for the guid with its delivery ID and
delivered_at. It sends no new POST for that guid until GitHub lists a newer delivery for the guid, or the 3-day age limit passes. A newer entry clears the accepted record. (best practice) [sources: src/devops_cli/github/hook_redelivery.py, docs/SERVICE_PATTERNS.md]- Rejected: Keep no record. The row repeats the accepted POST each round.
- Rejected: Suppress until the age limit. A lost or failed redelivery never gets a new attempt.
- Chosen: Suppress until a newer delivery entry appears. GitHub records the result as a new entry, and the row decides from that result.
- How does the row choose pending guids when more than the cap wait?: The row sends the pending guids with the oldest
last_attempt_atvalue first, then the oldest delivery ID. The round setslast_attempt_atafter each POST. This order rotates the cap over the pending set and stops starvation. (best practice) [sources: src/devops_cli/github/hook_redelivery.py]- Rejected: Oldest delivery ID only. The same first 40 guids use every round and later guids starve.
- Rejected: Newest delivery ID first. Old failed deliveries wait until the age limit.
- Chosen: Least recently attempted first. Each pending guid gets a turn within the cap.
- When does the row save an accepted attempt?: The row saves the ledger after each accepted POST and before it sends the next POST. A rate limit then cannot cause a repeat of an accepted attempt. (best practice) [sources: src/devops_cli/github/hook_redelivery.py]
- Rejected: Save only at round start. A rate limit loses the accepted records of the round.
- Chosen: Save after each accepted POST. The next round sees the record and does not repeat the POST.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 30, 2026
The row consumes the full hourly API budget with about 60 pending guids, degrading service capacity.Both concern the redeliver row, but #4560 creates the feature while the candidate fixes its missing request and page limits.devops-cli-service commentedon Nov 30, 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 (10)
Tools considered:
Searches run:
Sources:
dan-petty commentedon Nov 30, 2026
Note from #7925 (pull request #7938): after that change, only the row of the first repository of
service.reposasks for redeliveries, so a round sends one attempt for each pending guid in total. A refused attempt (such as HTTP 422) no longer ends the round, and a rate limit or a refused identity still does. The request cap, the page limit and the record of an accepted attempt of this issue stay open.fix(service): read a 403 that names a rate limit as one (#7940)
dan-petty commentedon Nov 30, 2026
Live evidence from the Service log on 2026-11-30, image
v0.264.1, the last 40 minutes before about 21:55 UTC:check_suitehad the outcomerejected. They hold only 17 delivery IDs, and one ID came 30 times.403of the route for a signed, valid payload isunmanaged repository(server/routes/webhooks.py,_authenticated_payload). This is an inference from the source: the log line names no status, no reason and no repository.A refusal of this kind cannot succeed on a new attempt while the repository is not in
service.repos, so each redelivery spends a request for nothing.v0.264.1holds neither #7938 nor a request cap, so check which part #7938 already removes.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.
14 remaining items
fix(service): the redeliver row has no limit on its requests (#7920)
docs(spec): archive the change (#7920)
devops-cli-service commentedon Dec 1, 2026
Stopped at fix.
Failed check:
pre-push. The end of its log:Failure class:
no_change_in_fix.Action taken: none.
Action left:
wait: wait for a person.pytest on base: tests/github/test_hook_redelivery.pypytest on base: tests/github/test_hook_redelivery.pypre-pushReason:
Last message of the agent (a claim that no check verified): The
pre-pushfailure was a timeout (exit 124), not a code defect, and I changed no file. The six gates were each stopped after about 39 seconds. When I re-ran them withuv run devops ci --check --only lint,format,swallowed-failures,uv-check,constructs,deps, all six passed and the longest took 1m 27s. The checkout is clean. I did not run the fulldevops-ci-pre-pushhook itself, so the job must re-run it to confirm. If it times out again, the cause is the time limit on that hook.The item is Blocked, and the job will not run it. Fix the cause. Then comment
implement: retry. The Service clears the stop on its own when a new runner image rolls out, but only if a retry can fix the class of the stop and the limits ofroadmap.implement.digest_clears_per_classandroadmap.implement.digest_clears_per_itemallow it.The job kept the commits that passed on the branch
fix/7920-the-redeliver-row-has-no-limiton origin. The last isb174a44678cca4877a56698083d7bf6fd917f738. The pull request stays a draft. The next run continues from it, runs no group that is ticked, and runs the scoped checks again.fix(service): the redeliver row has no limit on its requests (#7920)
docs(spec): archive the change (#7920)
devops-cli-service commentedon Dec 1, 2026
Released in v0.269.1: https://github.com/dan-petty/devops-cli/releases/tag/v0.269.1
devops-cli-service commentedon Dec 1, 2026
Live since 2026-12-01 16:30 UTC