run-swarm.sh: classify Claude auth refusals (mirror rehearsal-report CLAUDE_AUTH_RE) — a dead token must fail over/name, not red the swarm #632
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#632
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?
Class: harness-infra (swarm executor gap). Filed by the swarm healer for run https://git.matou.nz/Matou/idss/actions/runs/8307 (signature
096ffba7729c).Symptom
The
swarmjob went red and paged the healer with a degraded signature (seam-degradedmarker set, trigger error lineunknown, no fresh verdict artifact). The worker log (.sandcastle/logs/main-sandcastle-worker-20260821-043605-d7cda4-worker.log) shows the real fault:Root cause
.sandcastle/run-swarm.sh'swhile ! pnpm run sandcastleloop classifies only two refusal shapes:swarm_cancel_hit(operator cancel) andclaude_limit_hit(subscription-limit →#510two-account failover). A Claude auth refusal ("Not logged in · Please run /login" / "failed to authenticate" / "oauth session expired") matches neither, so it falls straight through toSWARM_EXIT_REASON="sandcastle-run-failed"; exit 1— a hard red that pages the healer with a signature that degrades to the workflow name (the near-unparseableanti-pattern commit2f0d3a65warned against)..sandcastle/rehearsal-report.shalready solves this for the cron reporter/healer path:claude_auth_failed/CLAUDE_AUTH_RE="failed to authenticate|oauth session expired|not logged in|invalid api key|authentication_error"with a fail-over-once-then-name pattern. The swarm executor never got the mirror.What good looks like
In
run-swarm.sh, add an auth-refusal branch alongside the limit branch (reuse a sharedCLAUDE_AUTH_RE/claude_auth_failedfromlimit-lib.sh, don't re-declare): on a Claude auth refusal, fail over once to the standby account (like the limit path), and if the retry also auth-fails (both accounts dead), exit cleanly with a LOUD, named Mattermost alarm ("BOTH Claude accounts auth-dead — re-login required") + a swarm.db event — never a degraded red that keys the healer onunknown. Keep it loud, keep it named (commit2f0d3a65's ruling).Acceptance
#510limit path).claim-lib/limit-libseam tests stay green.Note (not part of this ticket)
The concrete outage that surfaced this — both org OAuth tokens (
CLAUDE_CODE_OAUTH_TOKEN[A] andCLAUDE_CODE_OAUTH_TOKEN_B[B]) auth-dead at ~04:31–04:36 UTC 2026-08-21 — is a credential re-login the operator must do by hand (org secrets); it is escalated separately on Mattermost and is out of scope for this code change.Blocked — protected-path machinery change, needs a session (not a swarm agent)
This ticket is out of a swarm worker's reach: its entire deliverable is editing
.sandcastle/run-swarm.shand (per the ticket).sandcastle/limit-lib.sh— both under.sandcastle/, a fingerprinted protected directory (PP_PROTECTED_DIRS_DEFAULT=".sandcastle .forgejo"in.sandcastle/protected-paths-lib.sh, #445). The protected-paths boundary snapshots that tree before/after every worker run, rolls back any protected path a worker creates/changes/deletes, and fails the run loud. So a swarm agent physically cannot land this change — there is no non-protected surface here (the classifier, the failover branch, and the classifier test all live under.sandcastle/).Per CLAUDE.md rule 9 and the escape path spelled out in
protected-paths-lib.sh(PP_ESCAPE_PATH): a protected.sandcastle/change needs an interactive session's standing, not a swarm agent (ADR 0174 / #445). This is not a side-improvement I discovered while doing other work — the ticket is the machinery change — so the right move is to re-route this same issue rather than file a new one.Why session
The work modifies the machinery that judges swarm work (
run-swarm.shclassifier +limit-lib.sh). ADR 0174 / #445 reserve that to a session; a session rules on the machinery change itself and escalates toready-for-humanonly if it finds a genuine one-way door. Nothing here looks one-way (mirrors the already-shippedrehearsal-report.shCLAUDE_AUTH_REpattern), soready-for-session— notready-for-human.What a session must do (scope unchanged from the ticket)
CLAUDE_AUTH_RE/claude_auth_failedintolimit-lib.sh(don't re-declare it inrun-swarm.sh), mirroringrehearsal-report.sh.run-swarm.sh'swhile ! pnpm run sandcastleloop, alongsideclaude_limit_hit: fail over once to the standby account (like the #510 limit path); if the retry also auth-fails, exit 0 with a LOUD, named Mattermost alarm ("BOTH Claude accounts auth-dead — re-login required") + a swarm.db event — never a degraded red keyed onunknown.claim-lib/limit-libseam tests green.Re-arm by resolving in a session and (if needed) re-labelling. Releasing the swarm claim now.
Ruled by agent under ADR 0174 — veto anytime.
Two-way door: a code/config change to
.sandcastle/, revertible withgit revert 7d836350, provable by tests. Not on the one-way-door list (no credentials, no security-posture widening, no member-facing trust surface, no data destruction, no physical hardware).Landed:
7d836350(7d836350e8)CLAUDE_AUTH_RE/claude_auth_failedmoved fromrehearsal-report.shintolimit-lib.sh— one shared definition, consumed by both scripts (rehearsal-report.sh's own copy deleted, now sources the lib's).run-swarm.sh's retry loop gets a new branch, checked before the limit guard: a Claude auth refusal (claude_auth_failed) fails over to the standby account and retries once (mirrors the #510 limit path); if the retry also auth-fails, exits 0 with a loud, namedBOTH Claude accounts auth-dead — re-login requiredMattermost alarm (single-account hosts name that one account instead) + aswarm.dbevent — never a red job. An hourly marker dedupes repeat alarms from a queued-trigger burst, mirroring the existing limit-pause notice.preflight-swarm.shgets a newguard_auth_detection(mirrorsguard_limit_detection): a wording drift inCLAUDE_AUTH_REreds preflight, named, before any worker spawns — plus a cross-classification check (an auth refusal must never also read as a limit hit, and vice versa).tests/fixtures/claude-auth-refusal.txt, captured from the run 8307 worker log (main-sandcastle-worker-20260821-043605-d7cda4-worker.log) that surfaced this gap.Proof:
tests/run-swarm-auth-guard-test.sh(new, 5 scenarios): the exact #632 worker-log shape classifies as auth and not limit; a two-account host's first refusal fails over and retries; the second refusal halts naming BOTH accounts; a repeat halt inside the TTL re-logs to swarm.db but does not re-post to Mattermost; a single-account host's refusal halts naming that one account only.tests/preflight-swarm-test.shupdated (7→8 guards) and passing..sandcastle/tests/*.shsuite green, includingclaim-lib-test.shandlimit-lib-test.sh(seam tests unaffected).The concrete outage that filed this ticket (both org OAuth tokens auth-dead ~04:31–04:36 UTC) is a human re-login, out of scope here per the ticket's own note — tracked separately.