Skip to content

fix(service): a restart keeps the halt, the budget window and the failure ledger, and a rate limit or a suspended installation stops every worker - #2515

Merged
dan-petty merged 2 commits into
mainfrom
fix/2474-service-state-survives-restart
Oct 28, 2026
Merged

dan-petty merged 2 commits into
mainfrom
fix/2474-service-state-survives-restart

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The roadmap Service kept its halt, its hourly budget window and its failure ledger in memory, so a restart after a refusal started again at full speed. A rate limit stopped only the thread that got it, and the other workers sent requests during the wait. A suspended App installation whose token was still valid did not halt the Service. Requests sent after a refusal are the behavior most likely to make GitHub block the App.

  • The Service keeps service-halt.json, service-budget.json and service-failures.json in the roadmap directory of the data directory, beside the schedule.json of each repository, on volume roadmap-service-home. A restart reads them back. A record that cannot be read stops the start and names the file.
  • A halt stays after a restart until a person removes service-halt.json and restarts the Service. A start that finds the halt counts the refusal once, so the alert RoadmapServiceIdentityRefused holds through a restart. The alert's description, its promtool test and k8s/README.md say how to clear a halt.
  • The budget keeps the end of each round and the requests sent since the round before, so a new process can count from any value. The ledger keys a failure by a SHA-256 digest of the round's input.
  • devops serve --service builds the lane jobs with service_jobs(state_dir). SERVICE_JOBS and SERVICE_FAILURES are deleted.
  • A rate-limit wait in the GitHub session or in run_gh holds every request of the identity, from all threads, until the wait ends (GitHubRateLimiter.hold_requests).
  • The gh-output table reads "installation has been suspended" and "suspended your access" as a refused identity. The HTTP classifier reads a 403 to a write whose answer has no x-ratelimit-* header as a refused identity.

The roadmap store writes through gh api, which shows no response header, and the Service sends no write through the session. So the header rule covers writes through the session, and the Service's own writes depend on the gh-output phrases. The OpenSpec design records why the change does not add -i to the store's writes.

Change: openspec/changes/archive/2026-10-28-2474-service-state-survives-restart/

Closes #2474

…lure ledger, and a rate limit or a suspended installation stops every worker

The roadmap Service kept its halt, its hourly budget window and its
failure ledger in memory, so a restart after a refusal started again at
full speed. A rate limit stopped only the thread that got it, and a
suspended App installation whose token was still valid did not halt the
Service.

- The Service keeps service-halt.json, service-budget.json and
  service-failures.json in the roadmap directory of the data directory,
  beside each repository's schedule.json, on volume
  roadmap-service-home. A restart reads them back. A record that cannot
  be read stops the start and names the file. A halt stays until a
  person removes service-halt.json and restarts the Service.
- A start that finds the halt counts the refusal once in
  devops_cli_service_identity_refused_total, so the alert
  RoadmapServiceIdentityRefused holds through a restart. Its
  description, its promtool test and its README row say so.
- The budget keeps the end of each round and the requests sent since
  the round before, so a new process can count from any value. The
  ledger keys a failure by a digest of the round's input.
- serve --service builds the lane jobs with service_jobs(state_dir).
  SERVICE_JOBS and SERVICE_FAILURES are deleted.
- A rate-limit wait in the session or in run_gh holds every request of
  the identity, from all threads, until the wait ends.
- The gh-output table reads "installation has been suspended" and
  "suspended your access" as a refused identity, and the HTTP
  classifier reads a 403 to a write with no x-ratelimit-* header as
  one.
- k8s/README.md says where the files are and how to clear a halt.

Closes #2474
@dan-petty

Copy link
Copy Markdown
Owner Author

Fail-to-pass run: https://github.com/dan-petty/devops-cli/actions/runs/40754351907/job/123049156298

On the base tree, test_a_gh_failure_is_classified_by_its_exit_status_and_the_gh_output_table and test_a_403_to_a_write_that_reports_no_quota_is_a_refused_identity[no-quota-headers] fail. tests/test_service_limits.py and tests/test_roadmap_run.py cannot import on the base tree, because service_state_dir, service_jobs and the record constants do not exist there.

Local checks on the branch:

  • With only the hold of the rate limiter reverted, test_a_secondary_limit_one_worker_meets_holds_the_requests_of_every_worker_until_it_ends failed: the second worker's request was paced 0.42 s, not 60 s.
  • Before the count at start, test_a_restart_keeps_the_halt_the_budget_window_and_the_failure_ledger failed: the restarted Service's refusal counter was 0.
  • uv run mypy src, the swallowed-failures ratchet and the architectural invariants passed.
  • The promtool tests of tests/test_k8s_monitoring_alerting.py skip locally (no promtool). CI installs the pinned promtool, and Tests & Coverage passed.

@dan-petty
dan-petty marked this pull request as ready for review October 28, 2026 19:41
@dan-petty
dan-petty merged commit 3630de1 into main Oct 28, 2026
18 checks passed
@dan-petty
dan-petty deleted the fix/2474-service-state-survives-restart branch October 28, 2026 19:41
dan-petty pushed a commit that referenced this pull request Oct 28, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.11.0](v0.10.1...v0.11.0)
(2026-10-28)


### Features

* **monitoring:** the roadmap Service's identity refusals, failing and
stalled jobs, restarts, and GitHub and model request volume raise alerts
([#2496](#2496))
([0137f23](0137f23)),
closes [#2472](#2472)
* **service:** roadmap-service runs at one replica, and each model call
in the cluster is sent at most two times
([#2500](#2500))
([2d32dae](2d32dae)),
closes [#2494](#2494)


### Bug Fixes

* **cli:** every command reports a DevOpsCLIError through one exit seam
([#2502](#2502))
([eadd55f](eadd55f)),
closes [#2487](#2487)
* **github:** pr monitor waits until the checks settle and names every
blocker, and pr ready reads the merge-readiness verdict
([#2498](#2498))
([43326ea](43326ea))
* **k8s:** a pod that does not call the Kubernetes API mounts no service
account token
([#2522](#2522))
([305d3ba](305d3ba))
* **k8s:** the cloudflared tunnel replicas prefer different nodes and
keep one up through a drain
([#2499](#2499))
([d4edaf6](d4edaf6)),
closes [#1023](#1023)
* **k8s:** the grafana, prometheus, argo cd and loki clients dial
through the egress-checked factory, and their pre-flight address checks
go ([#2497](#2497))
([e7ca1d5](e7ca1d5))
* **monitoring:** the roadmap Service alerts count a series that starts
in the hour, and a lane of a new pod can stall
([#2514](#2514))
([c7692b2](c7692b2)),
closes [#2505](#2505)
* **review:** a review's scanners leave out the rules that never gave a
valid finding here
([#2508](#2508))
([fe953ac](fe953ac))
* **roadmap:** a refine round leaves an outside account issue to a
person, and refine neutralizes comment openers, www links and
cross-repository references
([#2507](#2507))
([e6230dc](e6230dc)),
closes [#2478](#2478)
* **sandbox:** the metrics scrape and the whitelist NetworkPolicy
resolve each host one time, through the egress check
([#2521](#2521))
([7c01426](7c01426))
* **security:** the subprocess environment guard refuses the zsh and
interpreter keys that make a child run code
([#2510](#2510))
([459621a](459621a))
* **service:** a restart keeps the halt, the budget window and the
failure ledger, and a rate limit or a suspended installation stops every
worker ([#2515](#2515))
([3630de1](3630de1)),
closes [#2474](#2474)


### Code Refactoring

* **config:** settings resolve in one declared order through
pydantic-settings sources
([#2518](#2518))
([6a5447a](6a5447a)),
closes [#2445](#2445)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
dan-petty added a commit that referenced this pull request Oct 28, 2026
…il its wait ends (#2529)

A review of #2515 found that the last rate limit of a request held no
other worker. The session set the hold only for a refusal that it sent
again, and `run_gh` returned from its backoff before the hold on its
last attempt. So the refusal that failed the round held nothing, and the
other workers sent requests at once, although GitHub asked for a wait
with no request.

- The session's `retry_wait` and `run_gh`'s `_handle_attempt_backoff`
hold every request of the identity for the wait of each rate limit, the
last one too, before they decide whether a retry is left. The last
attempt records no throttle and sleeps no wait.
`SessionGitHubAPI.handle_rate_limit_error` loses its early return for a
spent retry count.
- A test sends a secondary limit to each attempt of one worker's
request, through the session and through gh, with each wait moving the
clock, and finds that the next worker's request waits for the last
refusal's wait. It also fails when the hold in `run_gh`'s backoff is
removed, which no test caught before.
- A test starts the Service through `devops serve --service` over a halt
record and a budget record, and finds the Service halted with the
requests of the window counted. It fails when `serve.py` gives no
`state_dir`.
- The rule comment above `RoadmapServiceIdentityRefused` says that a
halt stays after a restart. `ServeMessages.state_unreadable` and the
comments that #2474 added say "cannot" in place of "can't".

Change:
`openspec/changes/archive/2026-10-28-2523-last-rate-limit-holds-every-worker/`

Closes #2523
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(service): a restart keeps the halt, the budget window and the failure ledger, and a secondary limit or a suspended installation stops every worker

1 participant