swarm: two-account Claude token failover — ride over an exhausted weekly window instead of parking #510
Labels
No labels
agent-blocked
agent-working
autopilot
bug
deferred
deploy-pending
enhancement
landing-pr
model-haiku
model-opus
model-sonnet
needs-design
needs-info
needs-triage
no-triage
out-of-scope
priority
ready-for-agent
ready-for-human
ready-for-session
rehearsal-183
snapshot-pending
standing-drive
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Matou/idss#510
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
2026-08-13/14: the primary Claude account hit its weekly limit (resets Aug 15, 8am UTC) and the whole loop parked — swarm runs on both repos paused on the limit guard, the rehearsal reporter's diagnosis leg failed to the generic ready-for-human path, and the healer went dark. The fix was a hand-swap to a second account's token (org secret +
rehearsal-env.sh), ~a day of degraded reds later than it needed to be.We now hold two accounts. The machinery should ride over an exhausted window by itself.
Design sketch
CLAUDE_CODE_OAUTH_TOKEN_B(the standby account). The org level is now the ONE source of truth — the diverged ourcloud repo-level override was deleted 2026-08-14; never reintroduce it..sandcastle/limit-lib.sh(shared by run-swarm and the healer so they can't drift — the 2026-07-29 "weekly" phrasing lesson). Failover keys off the same predicate.claude_limit_hitwith the active token, re-try the sandcastle run ONCE on the other token, and stamp a host-global active-token marker (sibling of the existing/tmp/matou-swarm-claude-limitnotice marker — repo-agnostic by design, one subscription window per account) so subsequent runs on this host start on the live token without paying a failed attempt first.rehearsal-env.shcarries both tokens; the reporter/healer wrapper tries active-then-standby with the same marker discipline. (Host-only file — the tokens must never enter.sandcastle/.env, which forwards into worker containers; 2026-07-11 lesson.)Acceptance criteria
Notes
_B)..sandcastle/machinery: prompt rule 9 / #445 route — human-gated landing, hence ready-for-human.Ruled by agent under ADR 0174 — veto anytime. Ruling: build as sketched — the design + acceptance criteria in the body are complete, offline-tested, marker-TTL-bounded, and degrade to exactly today's quiet park when both accounts are limited. Two-way door. It sits
ready-for-session(notready-for-agent) only because.sandcastle/is a protected path (#445) — an interactive session lands it.Machinery LANDED:
4ed8d44(ruled build-as-sketched under ADR 0174, landed by session — protected path #445).limit-lib.sh(ONE detection point — AC-3):claude_select_token/claude_failover/ host-global active-account marker, 1h TTL (stale never pins the standby — AC-4).run-swarm.sh(retry once + account-named notices: "account A limited — failed over to B" / "BOTH accounts limited" — AC-1/AC-2 shape),heal.sh, and bothrehearsal-report.shcall sites.limit-lib-test.sh11 groups (marker matrix, flip/flip-back, fresh-B steering, stale-fallback) +heal-test.shride-over and no-standby-defers scenarios. No live-token test in the gate.Why human (the remaining tail)
The machinery is INERT until the standby credential exists — personal-credential work (ADR 0174 one-way door):
CLAUDE_CODE_OAUTH_TOKEN_B(the standby account's token — org level only, the repo-level override stays dead).CLAUDE_CODE_OAUTH_TOKEN_Bexport to the workstation'srehearsal-env.sh(host-only file — never.sandcastle/.env).Relabelled
ready-for-humanfor that two-line tail; it rides the next digest.COMPLETE — tokens wired, primary probed live, failover armed (Ben's hands + session, 2026-08-14 evening).
rehearsal-env.shcarries both accounts: primary answers a liveokprobe; standby is a distinct 108-char token (fresh mint, back in window at its 8am UTC reset). Host-only file, as designed — nothing entered.sandcastle/.env.CLAUDE_CODE_OAUTH_TOKEN_Bexists (set via UI — the API PUT 403s on a repo-scoped PAT); the swarm + healer workflows pass it through sincedb928ad.4ed8d44(limit-lib primitives, run-swarm/healer/reporter wiring, both-streams detection, offline suites green).Closing: the loop now rides over an exhausted window on the workstation paths, and the CI paths are one secret-value swap from the same. AC-2 (both-limited quiet park) was proven live earlier today — twice, unintentionally.
Residue resolved: org
CLAUDE_CODE_OAUTH_TOKEN_Bswapped to the standby account's token (PUT 204 — the earlier 403 was the workstation's scoped-down token, not the local PAT). Both pairs (org + rehearsal-env.sh) now span the two accounts: primary = live account, standby = the 8am-reset account. Org secrets verified as two independent slots (list API), values write-only.