Repository navigation
Description
Problem or Motivation
The Service paces its GitHub requests with a self-cap of 4,000 an hour (measured peak 3,255). Pods outside the Service are not in that cap: the runner Jobs of the implement job, and soon the stage Job of #4559. They pace only by the GitHub rate headers. #5483 gives the stage Job its own budget (roadmap.stage.github_requests_per_hour). The shared window in Valkey comes later (#4563, Phase 4). The approved pipeline split design (tracker #5482) puts a fixed request budget for each pod before the stage Job.
Proposed Solution & Architectural Design
- Give each other roadmap Job the same budget, with a setting in the form of feat(roadmap): add the stage Job template and one-item entry point #5483 (for example
roadmap.implement.github_requests_per_hour). The owner sets the values. - The pod reads the setting of its job from the ConfigMap, so a Job that a person makes from a template (
k8s/devops/cronjob-runner.yaml) also gets the budget. The Job builder ofsrc/devops_cli/k8s/cluster_job.pypasses no value of its own. - The Service subtracts the budget of each running roadmap Job, the stage Jobs included, from its own self-cap.
- The paced GitHub session in a pod counts its requests. At its budget, the unit stops with exit 75 (retry), and the result line states
gh_requests. - feat(service): share the GitHub budget and holds in Valkey #4563 deletes the fixed budget when the shared window ships (no shim).
- A change of a setting needs a Service restart, as
service.github_requests_per_hourdoes. State this ink8s/README.md.
Target Subsystem
Roadmap Service and roadmap jobs (src/devops_cli/service/, src/devops_cli/k8s/cluster_job.py, k8s/devops/).
Acceptance Criteria
- Test first: a pod session at its budget exits 75. The test fails on the base.
- A test: with 2 running Jobs, the Service window is the self-cap minus 2 budgets.
- A test: a runner pod reads the budget of its job from the configuration.
- A test:
--dry-runsends 0 requests. - Live proof: after the merge and the release, a runner Job of the implement job and a manual Job made from the runner template run as the App with the budget. A comment on this issue gives their result lines with
gh_requests, and the value ofdevops_cli_service_budget_limit_requestswhile they ran.
Existing Tool Considered
The limits library (present) gives the windows, and GitHub sends its rate headers. No tool divides one installation budget across pods with no shared state. The Valkey window of #4563 is that tool later. Build: 150,000 to 300,000 agent tokens and 0.5 day.
Related
Tracker #5482, Phase 1. #5483 (the stage budget), #4559 (the stage submit). #4563 replaces it. Owner step: the values of the settings.
Dependencies
- chore(roadmap): hold incremental stage and implement work #6521 (hold: incremental stage and implement work)
Source: #5482
Alternatives check of 2026-11-29: in-use.
The repository already uses this tool.
Tool: limits (https://pypi.org/project/limits), MIT, last activity 2026-02-05, maintained.
Reason: Searches confirm limits is an open, maintained rate-limiting library with in-memory and shared-storage windows, which covers the per-pod hourly count, but it knows nothing of Kubernetes Job budgets, the exit-75 stop contract or the Service pool.
Covers:
- Fixed and moving hourly windows counted per process
- In-memory storage with no external state for one pod
- Shared storage backend for a later cross-pod budget
Lacks:
- No exit-75 stop contract or gh_requests result line
- No subtraction of running Job budgets from the Service pool
- No read of a per-job budget from the mounted ConfigMap
- No reservation kept an hour after a Job's last pod
Proposed design
Problem statement
The Service caps its own GitHub requests at service.github_requests_per_hour (500 by default, 4000 live). The implement and fix-checks Job pods pace only by the GitHub rate headers, and the implement submit run today installs the stage budget (src/devops_cli/roadmap/implement/implement_run.py:711), so a model pod can spend the installation budget that the Service counts on. This change gives the implement and fix-checks rows their own hourly budget from the mounted ConfigMap, stops the pod's unit at its budget with exit 75 and a gh_requests result line, and subtracts each running Job's budget from the Service pool. The owner sets 600 for implement, 100 for fix-checks, keeps 1000 for stage, and raises the pool to 4500 with the release. #4563 replaces the fixed budgets with a shared Valkey window later.
Acceptance criteria
Requirement: Pod session stops at its budget
A paced GitHub session in a roadmap pod SHALL stop its unit when the session reaches the hourly budget of its job.
Scenario: Implement session reaches its budget
- WHEN an implement pod session has sent
roadmap.implement.github_requests_per_hourrequests in its window - THEN the session raises
GitHubBudgetExhausted, the command writes one result line withgh_requestsequal to the budget, and the process exits 75.
Requirement: Service window subtracts running Job budgets
The Service SHALL subtract the hourly budget of each running roadmap Job from its own pool.
Scenario: Two running Jobs
- WHEN an implement Job with budget 600 and a stage Job with budget 1000 run
- THEN the Service window equals
service.github_requests_per_hourminus 1600, anddevops_cli_service_budget_limit_requestsshows that value.
Requirement: Service counts a manual runner Job
The Service MUST subtract the budget of a manual Job made from a model template from its pool.
Scenario: Manual runner Job is running
- WHEN a manual Job made from
k8s/devops/cronjob-runner.yamlruns with the implement budget - THEN the Service window equals the configured pool minus the implement budget and the budgets of the other running Jobs.
Requirement: Service floors the window when running budgets exceed the pool
When the sum of the running Job budgets exceeds service.github_requests_per_hour, the Service MUST floor its window at 0 and send no request.
Scenario: Sum exceeds the pool
- WHEN the sum of the budgets of the running Jobs is greater than
service.github_requests_per_hour - THEN the Service window is 0 and the Service sends no request until a Job ends.
Requirement: Service warns about an overcommitted configured budget
At startup, the Service MUST compare the sum of the configured row budgets with service.github_requests_per_hour and MUST log one warning that names both when the sum is greater.
Scenario: Configured budgets exceed the pool
- WHEN the Service starts with configured row budgets that sum above
service.github_requests_per_hour - THEN the Service logs one warning that names the sum and the pool, and its window stays at the pool until a Job runs.
Requirement: Pod reads its budget from the configuration
A roadmap Job pod SHALL read the hourly budget of its row from the mounted ConfigMap and fall back to the code default when the key is absent.
Scenario: Runner pod reads the implement budget
- WHEN a runner pod loads its settings with
roadmap.implement.github_requests_per_hourset to 640 in the ConfigMap - THEN the paced session limit equals 640.
Requirement: Code defaults hold the measured budgets
The settings module SHALL default roadmap.implement.github_requests_per_hour to 600 and roadmap.fix_checks.github_requests_per_hour to 100.
Scenario: Settings load with no budget keys
- WHEN a pod loads settings from a ConfigMap with no request-budget keys
- THEN the implement budget is 600 and the fix-checks budget is 100.
Requirement: Job builder passes no budget value
The Job builder in src/devops_cli/k8s/cluster_job.py MUST pass no request-budget value of its own.
Scenario: Built runner Job carries no budget value
- WHEN
build_jobmakes a runner Job fromk8s/devops/cronjob-runner.yaml - THEN the container environment of the Job holds no request-budget key.
Requirement: Dry run sends no request
A roadmap step with --dry-run MUST send no GitHub request and MUST not count against the budget.
Scenario: Dry run of a step
- WHEN a roadmap step runs with
--dry-runagainst a fake transport - THEN the transport records 0 requests and the command exits 0.
Requirement: Budget settings are positive integers
Each request-budget setting MUST be a positive integer.
Scenario: Zero budget is refused
- WHEN
roadmap.implement.github_requests_per_houris set to 0 - THEN the settings loader raises a validation error that names the key.
Requirement: Service keeps a Job reservation after its last pod ends
The Service MUST keep the reservation of a Job until 1 hour after its last pod ends.
Scenario: Job pod ends
- WHEN the last pod of a running Job ends
- THEN the Service keeps the Job budget in its window for 1 hour and releases it after that.
Requirement: README states when a budget change takes effect
k8s/README.md SHALL state that a change of service.github_requests_per_hour needs a restart of the Service and that a Job pod reads its row budget from the ConfigMap at its start.
Scenario: Docs check
- WHEN
uv run devops ci --check --only docsruns on the change - THEN the check passes and reports no docs error.
Requirement: High request alert compares with the pool
The RoadmapServiceGitHubRequestsHigh rule MUST divide the Service requests by the pool that the Service publishes as devops_cli_service_budget_pool_requests.
Scenario: Alert rule check
- WHEN
uv run devops ci --check --only k8sruns on the change - THEN the check passes and the recorded ratio divides
devops_cli_service_budget_spent_requestsbydevops_cli_service_budget_pool_requests.
Requirement: Pending a person after the merge
After the release, a runner Job of the implement job and a manual Job from the runner template MUST run as the App within their budget.
Scenario: Live runner Job with the budget
- WHEN after the release, a person runs
uv run devops k8s run-job --template runner -- roadmap implement --confirmand a manual Job fromk8s/devops/cronjob-runner.yaml - THEN each result line states
gh_requests, and thedevops_cli_service_budget_limit_requestsvalue during the run equals the configured pool minus the budgets of the running Jobs.
Existing Tool Considered
limits (https://pypi.org/project/limits), MIT and maintained, is the tool that the issue's alternatives check names; the block of that check records what the tool lacks. The repository does not import limits: src/devops_cli/http/client.py:160 is httpx2.Limits, the connection-pool bounds, and #2547 rejected limits for a request budget because it has no wait that a stop can end and no record that a restart reads back (openspec/changes/archive/2026-10-29-2547-request-budget-per-request/proposal.md:38). The change extends the project's own RequestBudget (src/devops_cli/server/service.py:226) through set_request_gate (src/devops_cli/github/rate_limiter.py:799), which the stage pod already installs (src/devops_cli/roadmap/stage/stage_job.py:230) and the implement submit run already installs (src/devops_cli/roadmap/implement/implement_run.py:711). Written cost to build, keep and fix the budget code until it matches the tool: 150,000 to 300,000 agent tokens and 0.5 day, as the issue records.
Key questions
- Where does a roadmap pod read its request budget?: Each roadmap Job pod mounts ConfigMap
devops-cli-configread-only at/configand setsDEVOPS_CLI_CONFIG=/config/devops-cli.yaml, so the settings loader reads the budget from that file. The Job builder passes no budget value. [sources: k8s/devops/cronjob-runner.yaml:69, docs/CLUSTER.md:89, src/devops_cli/k8s/cluster_job.py:275] - Which rows get a request-budget setting, and what values do they take?: The implement row gets 600 an hour and the fix-checks row gets 100 an hour. The stage row keeps 1000 an hour from feat(roadmap): add the stage Job template and one-item entry point #5483. The Service pool becomes 4500 an hour with the release, not before it. The three defaults sum to 1700, above the Service default of 500, so the startup comparison warns on a default install and the live ConfigMap sets the pool to 4500. (best practice) [sources: src/devops_cli/config/defaults.py:1074, src/devops_cli/k8s/cluster_job.py:84]
- Chosen: Implement 600, fix-checks 100, stage 1000, pool 4500. The owner measured each pod over 30 days and set the peak plus 25 %, rounded to 100; the pool stays below the 5000 installation limit.
- Rejected: 350 for each row. 350 is below the implement p99 of 385 and the stage p95 of 356, so pods stop in normal hours.
- Rejected: Implement 1000. Two Jobs at 1000 leave the Service 2500, below its measured peak of 3255.
- Which limiter counts the requests in a pod?: The pod uses the project's
RequestBudgetwith in-memory storage and no record, installed throughset_request_gate; a retry pod after exit 75 starts a new window.limitsis not a dependency of the project.RequestBudgetgains a stop mode for the pods, while the Service keeps the wait mode. (best practice) [sources: src/devops_cli/server/service.py:226, src/devops_cli/github/rate_limiter.py:799, src/devops_cli/roadmap/stage/stage_job.py:230, src/devops_cli/roadmap/implement/implement_run.py:711, src/devops_cli/http/client.py:160]- Chosen: RequestBudget through set_request_gate. The stage pod and the implement submit run already install it, it counts each request before it goes out, and it holds the window in memory.
- Rejected: limits with memory storage. The project does not import
limits;src/devops_cli/http/client.py:160ishttpx2.Limitsfor connection pools, and fix(service): the hourly GitHub budget counts only the rounds that end and lets a started round pass it, so the Service sent about 913 requests in an hour against a budget of 500 #2547 rejectedlimitsfor a request budget. - Rejected: Hand-rolled counter. It duplicates the window accounting that
RequestBudgetalready gives and adds code to keep and test. - Rejected: GitHub rate headers only. The headers state the installation limit, not the per-pod budget.
- How does a unit stop at its budget?: The budget raises a typed
GitHubBudgetExhausted; the roadmap command writes one result line withgh_requestsand exits 75, the contract of ADR 0021 for a retry. The stage pod's documented wait at its budget becomes the same stop, and its setting description anddocs/CLUSTER.mdchange with it. (best practice) [sources: docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:233, src/devops_cli/roadmap/job_result.py:218, docs/CLUSTER.md:104, src/devops_cli/server/service.py:226]- Chosen: Typed exception mapped to exit 75. ADR 0021 gives exit 75 for a retry and one JSON result line, and
RequestBudgetalready raises a typed error when it refuses a request. - Rejected: Wait at the budget, as the stage pod does today. A wait of up to an hour holds the Job pod past its time limits, and the issue asks for exit 75.
- Rejected: Sentinel return value. Every caller must check the sentinel, and a missed check sends a request over the budget.
- Rejected: GitHub 403 response. The 403 arrives after the budget and reports the installation limit, not the pod budget.
- Chosen: Typed exception mapped to exit 75. ADR 0021 gives exit 75 for a retry and one JSON result line, and
- Which running Jobs does the Service reserve from its pool?: The Service reserves each running Job with a component in
MODEL_COMPONENTSand each running pod with the name label of a model template (devops-cli-runnerorroadmap-stage). The first set covers the implement, stage and fix-checks Jobs that the Service creates. The second set covers a Job that a person makes with kubectl from a template, which carries neither a component nor a managed-by label, so the listing cannot filter onmanaged-by. The Service keeps a reservation until 1 hour after the last pod of the Job ends. (best practice) [sources: src/devops_cli/k8s/cluster_job.py:84, src/devops_cli/roadmap/job_launcher.py:188, k8s/devops/cronjob-runner.yaml:18, docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md:76]- Chosen: Model component Jobs and template pods. This covers the Jobs that the Service creates and a Job that a person makes with kubectl from a template, which carries neither a component nor a managed-by label.
- Rejected: Only the implement component. The issue asks for each other roadmap Job and names the stage Jobs.
- Rejected: Every Job of the Service. The short rows run in the Service pod and hold no separate budget.
- Where does the Service get the budget of a running Job?: The Service reads the budget of each row from its own settings. The Job spec carries no budget value, so the Service and the pod read one source and cannot disagree. (best practice) [sources: src/devops_cli/config/settings.py:1545, src/devops_cli/config/settings.py:1862, src/devops_cli/k8s/cluster_job.py:275]
- Chosen: Service configuration. One configuration holds the value for the Service and the pod, and the Job builder passes no value.
- Rejected: Annotation on the Job. It copies the value into the Job spec and gives two sources that can drift.
- Rejected: Environment value on the Job. The issue says the Job builder passes no value, so the pod reads the ConfigMap and the Service reads the same settings.
- What does the Service do when the sum of the running Job budgets exceeds its pool?: The Service floors its window at 0 and sends no request until a Job ends. A warning shows the misconfiguration. (best practice) [sources: k8s/devops/monitoring/prometheus-rules-values.yaml:44, src/devops_cli/server/service.py:226]
- Chosen: Floor at 0 and warn. The Service keeps its pool and the Jobs keep their budgets, and the warning shows the misconfiguration.
- Rejected: Create no Job when the sum exceeds the pool. The Service creates the Job before it can know the sum, and a refused Job stalls the item.
- Rejected: Let the window go negative and send requests. That breaks the pool and hides the misconfiguration.
- How does the Service report an overcommitted configured budget at startup?: The Service compares the sum of the configured row budgets with
service.github_requests_per_hourand logs one warning that names both. It does not change the window at startup, which stays at the pool until a Job runs; the window floors at 0 only when the running Job budgets exceed the pool. Setting the window to 0 at startup would silence a default install, because the code defaults 600 + 100 + 1000 sum above the Service default of 500. (best practice) [sources: src/devops_cli/config/settings.py:1545, src/devops_cli/config/settings.py:1862, src/devops_cli/config/defaults.py:1074]- Chosen: Warn only and keep the window at the pool. The warning names the misconfiguration, and a default install with the 500 pool still sends its own requests until a Job runs.
- Rejected: Set the window to 0 at startup when the configured sum is greater. The code defaults (600 + 100 + 1000) sum above the Service default of 500, so a default install would send no request.
- Rejected: Refuse the settings in the loader. The stage default of 1000 is above the Service default of 500, so the loader would refuse a valid configuration.
- Which alert comparison does the high request alert use?: The Service publishes its configured pool as
devops_cli_service_budget_pool_requests, and the recorded ratioservice:devops_cli_service_budget_requests_per_limit:ratiodivides the spent requests by that pool. The window stays indevops_cli_service_budget_limit_requests, so the alert measures the Service's share of the installation limit, not the smaller window. (best practice) [sources: k8s/devops/monitoring/prometheus-rules-values.yaml:44, k8s/devops/monitoring/prometheus-rules-values.yaml:175, k8s/README.md:193]- Chosen: Compare with the published pool. The owner asks for the pool, and the window shrinks when Jobs run, so the old comparison would fire in most hours.
- Rejected: Keep the budget-limit comparison. The limit gauge now shows the window, so the alert gives a false signal.
- Rejected: Keep the limit gauge as the pool and add a window gauge. The owner decides that
devops_cli_service_budget_limit_requestsshows the window that the Service admits.
- Does a change of a budget setting need a restart?: A change of
service.github_requests_per_hourneeds a restart of the Service, because the Service builds itsRequestBudgetfrom the settings at start. A row budget reaches the next Job pod from the mounted ConfigMap, and the Service reads the row settings again, so a row budget needs no restart. [sources: src/devops_cli/server/service.py:913, k8s/devops/cronjob-runner.yaml:69, docs/CLUSTER.md:68, k8s/README.md:418] - How does the settings loader validate a budget?: Each budget is a pydantic field with
ge=1(the stage and row budgets) orgt=0(the Service pool), so a zero or negative value is refused with the key named. The loader does not compare a row budget with the pool; the Service compares the configured budgets with its pool at startup. (best practice) [sources: src/devops_cli/config/settings.py:1545, src/devops_cli/config/settings.py:1862]- Chosen: Positive integer only, with a Service startup comparison. The loader accepts the stage default and the owner values, and the Service reports an overcommitted set.
- Rejected: Refuse a budget above the Service pool in the loader. The stage default of 1000 is above the Service default of 500, so the loader would refuse a valid configuration.
- Rejected: No validation. A zero or negative budget stops a pod at once.
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 13, 2026
Both distribute the GitHub request budget across pods; the candidate gives each pod a fixed budget setting, while 4563 creates a shared Valkey window that will replace those fixed budgets.devops-cli-service commentedon Nov 17, 2026
Alternatives check: in-use
Reason: Searches found no tool that divides one GitHub App installation budget across pods without shared state; the shared Valkey window is the later work of #4563. The
limitslibrary, which the issue records as already present and giving the windows, covers only the per-process hourly window accounting that a pod's paced session would count against.The repository already uses this tool.
Tool: limits (https://pypi.org/project/limits)
Covers:
limitsas present and giving the windows).Lacks:
roadmap.implement.github_requests_per_hour, read by the pod from the ConfigMap.gh_requestsline in the result.Tools considered:
Searches run:
Sources:
Checked on 2026-11-17. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 18, 2026
Owner question: What values do the request-budget settings take? (a person decides)
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
devops-cli-service commentedon Nov 21, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
dan-petty commentedon Nov 21, 2026
Answer to the owner question: the request-budget settings take these values.
roadmap.implement.github_requests_per_hourroadmap.fix_checks.github_requests_per_hourroadmap.stage.github_requests_per_hourservice.github_requests_per_hour(the pool)Rule: the peak of one pod plus 25 %, rounded to the nearest 100, and not less than 100.
About the measure:
OTEL_SERVICE_NAME=roadmap-implement. Their requests are in the implement figures.job=devops-cli-job) had a peak of 344 in 30 days and 123 in 7 days. No budget of this item covers them.Why the pool goes to 4500:
x-ratelimit-limit: 5000for the installation on 2026-11-21.ghcommand counts once, also when it reads many pages.Cost:
roadmap.model_jobs6), the window is 500.Changes to the design:
DEFAULT_ROADMAP_STAGE_GITHUB_REQUESTS_PER_HOURdoes. No live override is then necessary.service.github_requests_per_hour, because the stage default (1000) is above the Service default (500). The Service compares the budgets with its pool when it starts, and shows a misconfiguration with the metric of the design.RoadmapServiceGitHubRequestsHighcompares the Service with 0.9 xdevops_cli_service_budget_limit_requests. After this item, that gauge shows the smaller window, and the alert fires in most hours. Compare with the pool.Do not use 350. It is below the implement p99 and the stage p95, so pods would stop in normal hours.
Measure again 7 days after #6562. Query:
max_over_time(sum by (job) (increase(devops_cli_github_requests_total{status!="304"}[1h]))[30d:15m]), andquantile_over_timefor p95 and p99. For stage, divide by the number of running stage Jobs.Dependencies: #6521. This item adds a request cap, an exit-75 retry and a result line to the implement and fix-checks pods, and hold #6521 stops that work.
#4563, #6439 and #6562 are sources, not dependencies of this item.
devops-cli-service commentedon Nov 27, 2026
Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.
dan-petty commentedon Nov 30, 2026
Triage under #6519 (owner instruction of 2026-11-30), before the hold #6521 closes. This item adds or extends a gate, refusal, screen, cap, limit, retry, result line, shell allowlist, tool catalog or plan-shape rule of the stage, implement or fix-checks job. #6519 found that 263 of about 900 issues in four weeks added such rules and none replaced the engine. Stage now runs on stock Coder (grade 60 on 30 graded attempts), where the agent reads the repository, runs the checks in its loop and has a real shell; implement follows (#6527). The code paths that this item names have also moved. If the failure class still shows in graded attempts, file a new item from that evidence. Closed as not planned; a person may reopen it.