feat(sessions): a rate-limited pool queues a run instead of crashing it (v0.448.0) - #835
Merged
Merged
Conversation
…it (v0.448.0) When every runtime account is limited, rotation falls through to the box's own login — which on most boxes has never been used and holds no tokens — so the launch pre-flight refused the run and reported a crashed session. On live instawp 21 of the last 22 `crashed` sessions were this: each card told an admin to re-login a credential that was not the problem, while the accounts that were reset themselves within the hour, and two humans re-clicked take-over into the same card. A temporary exhaustion (every account limited, with a reset time) now parks the launch as `queued` and the 60s sweep launches it when an account frees up. A pool with no moment to retry at — empty, or all disabled — still refuses as before; a wait past 6h gives up with the original credential reason so a weekly cap cannot hide a run forever; a `queued` row left by a restart is reported, not left waiting. Stop calls off a wait; attach says the run has not started. Also: `expiresAt: 0` is a record with no tokens, not a date — it no longer renders as "expired on 1970-01-01" on cards and admin alerts. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A launch that only lacks a free runtime account is parked as queued and started by the 60s sweep once an account resets, instead of being refused and reported as a crash.
Why
instawp, 2026-09-17: 21 of the tenant's last 22
crashedsessions were not crashes. Both pool accounts hit their 5-hour session limit within an hour of each other, a third was at its weekly cap and a fourth was disabled, so rotation had nothing to hand out and every launch fell through to the box default~/.claude— a login that had never been used and holds no tokens at all (expiresAt: 0). The pre-flight refused each run (correctly — it could not authenticate) and reported it as crashed, with a card telling an admin to re-login a credential that was not the problem. The accounts that were the problem reset themselves within the hour. Two humans re-clicked take-over and got the same card twice.What changed
TerminalManager): every account limited with a reset time + an unusable fallback → statusqueued, auditedsession.launch.queued, owner card naming the reset (“…at 14:14 UTC (in about 40 min)”).retryCapacityQueue()runs from the process-wide 60s sweep and launches it when rotation can serve it (session.launch.dequeued, card resolved).session.launch.queue.expired) — a weekly cap can't hide a run forever. Aqueuedrow with no spec in memory (a restart mid-wait) is reported to its owner, not left waiting.queuedis a session status — own dot, tooltip, filter. Stop calls off a wait; attach 409s with "has not started yet".expiresAt: 0no longer renders as "expired on 1970-01-01" on cards and admin alerts.Testing
scripts/capacity-queue-test.cjs(35 assertions), wired intonpm run test:governance.npm run typecheck,cd web && npm run build, fullnpm run test:governance— all green.🤖 Generated with Claude Code