Skip to content

Probe Claude before overnight and send one alert, not one per repo - #269

Merged
dmccoystephenson merged 1 commit into
mainfrom
fix/usage-limit-preflight
Nov 22, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
fix/usage-limit-preflight

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Why

On 2026-11-18 every one of the garden's 231 tends failed in about 1.7 s, at $0, with "Claude Code can't use your Claude subscription, usually because a payment is past due" (transcript error oauth_org_not_allowed). That wording wasn't a device-wide marker, so the batch never aborted. Each repo sent its own tend: FAILED alert: 162 reached Discord and 70 more were refused with HTTP 429.

What changes

  • New failure class: the unusable-subscription wording joins is_device_global_failure (SUBSCRIPTION_UNAVAILABLE_MARKERS). The usage-limit markers also catch weekly limit, hour limit and limit reached.
  • Pre-flight probe (gardener/quota.py): before parpt scoring or any tend, one tiny read-only report-mode call goes through run_agent. A device-wide failure skips the night with one SKIPPED alert, leaving the cursor untouched. A probe that fails for another reason lets the night go ahead. Turned off with --no-preflight; skipped when a routing file is in use and on a non-Claude harness.
  • Wait for the reset: when a usage-limit message names a reset time that still leaves room for a tend, gardener sends one PAUSED alert, sleeps until the reset plus 2 min, and probes again. Mid-run, this happens once per night and re-dispatches the repos that hit the limit.
  • One alert on abort: in overnight, repos that hit a device-wide failure no longer send their own FAILED alert (_quiet_device_global; gardener tend by hand still alerts). The batch summary now goes in the body of the single ABORTED alert, not as a second message.
  • Docs: OVERNIGHT.md (new "Usage limits" section, a 2026-11-18 row in the failure table), USAGE.md, ARCHITECTURE.md, TESTING.md.

Tests

  • tests/test_quota.py: reset-time parsing (bare hour, minutes, named zone, dated, across New Year, epoch form, unreadable), the budget rule, probe classification with an injected runner.
  • TestOvernightUsagePreflight in test_cli.py: the one-alert skip, a flaky probe going ahead, the reset wait and re-probe, a reset too late, routing skipping the probe, one ABORTED alert mid-run, and the mid-run wait re-dispatching the blocked repo.
  • test_cli.py and test_routing_wiring.py fences now patch quota.probe and quota.seconds_to_wait, so no test reaches claude or sleeps until a real reset. The existing two-alert assertion was updated to one.
  • Full suite: PYTHONPATH=. python3.12 -m unittest discover -s tests gives 1498 OK (2 skipped), run with a fake claude on PATH that logged zero calls. Offline integration tier: 79 OK (22 live-tier skips).

Not yet done: a manual overnight --hours 0.1 against a real exhausted window. The probe's report-mode call goes through the existing run_agent/MODE_SPECS path unchanged.

Companion: Stephenson-Software/quartermaster#762.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LYNeumw2Rk1yJYprnsLjvm


drafted by Claude on behalf of Daniel Stephenson

On 2026-11-18 every one of the garden's 231 tends failed in under two
seconds with "Claude Code can't use your Claude subscription" (billing).
That wording was not a device-wide marker, so the batch never aborted
and each repo sent its own FAILED alert: 162 reached Discord and 70 were
refused with HTTP 429.

- Treat the unusable-subscription wording as device-wide, and widen the
  usage-limit markers (weekly limit, N-hour limit, limit reached)
- Before parpt scoring or any tend, make one read-only report-mode probe
  through run_agent; a device-wide failure skips the night with one
  SKIPPED alert (--no-preflight turns it off; skipped with routing)
- Wait out a usage limit whose reset fits the budget, with one PAUSED
  alert, before the night and once mid-run, re-dispatching the repos
  that hit it
- Hold back per-repo FAILED alerts for device-wide failures in
  overnight, and fold the batch summary into the single ABORTED alert

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LYNeumw2Rk1yJYprnsLjvm
@dmccoystephenson
dmccoystephenson merged commit 2317106 into main Nov 22, 2026
5 checks passed
@dmccoystephenson
dmccoystephenson deleted the fix/usage-limit-preflight branch November 22, 2026 18:45
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.

1 participant