A Claude subscription turn refused for the 5-hour limit before any reply
(429) ended its run through relay's abort, and the conversation's native
session went with it. After the reset the turn was told whole to a new
Claude Code: 354,900 tokens written to the cache again (recih).
Now relay's abort is told the status and words (relayFailing); on a 429
keepForReset shelves a copy of the session cut before the refused turn
(no user line, no synthetic error line), under the turn's key. Cut at
backLine/backMsg for a resumed idle run, or at fromLen (the saved file's
length at start) for a run started from a saved session that has answered
nothing, so a turn refused again while still limited is kept again.
It waits until the reset the refusal names, else the account's used-up
window's reset from the rate_limit_event (KeptClaudeLimits), else 5h; plus
1h, at least idleLongest, at most longestQuota (8d). until goes into
claude-shelf.json, so the entry survives a restart. Shelf still capped at
shelfMost.
Run (on mica; mote was over its cores):
- go test -tags nogui ./internal/gateway/ -run 'Claude|Shelf|Relay|Bridge|Subscription': ok 93s
- new TestClaudeTurnRefusedForTheLimitKeepsItsSessionTillTheReset (print and
interactive: two refusals, restart, then --resume of the cut session told
the turn alone) and TestQuotaShelfFor: ok
- GOOS=linux and GOOS=windows go vet ./internal/gateway/: ok; gofmt clean
Broken by hand, each red:
- keepForReset call removed: "try 1: no session kept"
- fromLen forced to 0: "try 2: no session kept"
- fromLen cut at the file's end (refused turn kept): "try 2: the kept
session isn't the conversation before the refused turn"
Not tried: a real account hitting its real 5-hour limit; Claude's
"resets 9pm" text is still not parsed by resetsAt (the rate_limit_event's
resetsAt covers it). The full suite runs after the push.