healer/reporter: the Claude auth-failure detector matches the model's own PROSE — a diagnosis quoting "not logged in" discarded a finished heal, flipped the account and paged a false auth failure #1682

Closed
opened 2026-09-21 04:32:01 +00:00 by ben · 3 comments
Owner

What happened (#1672 fire 1, 20260921T023204Z)

The healer ran TWICE for real — 18 min on account A, then 13 min on account B — and the second run returned a complete {"action":"healed","commit":"3b227968",…} verdict. Both runs were then classified as Claude auth refusals: the heal was reset away, the active-account marker flipped A→B for nothing, and Ben was paged "CLAUDE AUTH FAILED on account B — not logged in". Both tokens are fine (the reporter used them minutes later and filed #1678/#1679).

Cause

claude_auth_failed (.sandcastle/limit-lib.sh) greps the WHOLE of <who>-claude.out — the model's own prose — for CLAUDE_AUTH_RE (failed to authenticate|oauth session expired|not logged in|invalid api key|authentication_error). The healer's diagnosis quoted a Nextcloud 401 body it had read off the box:

`/settings/admin` → HTTP 401 {"message":"Current user is not logged in"}

not logged in matched. Any diagnosis of a SIGN-IN failure is likely to contain one of these phrases, and sign-in is most of what the drives prove right now — so this will recur.

Ask

Make the auth classifier read the CLI's refusal, not the model's prose. Options: anchor the phrases to the start of a line / the CLI's exact shapes ("Not logged in · Please run /login", "Failed to authenticate: …", API Error: 401 …authentication_error); or never classify an output that carries a parseable verdict as an auth refusal; or only consult stderr + a short stdout. Keep preflight-swarm's auth_detection self-test and scenario 31 of rehearsal-report-test.sh green, add a fixture with the exact prose above that must NOT classify, and carry the same change to dev-factory's copy of limit-lib.sh (the two copies share one host-global marker and must agree).

Same classifier guards run-swarm.sh's worker log, where a worker's prose can trip it the same way.

Related, already fixed (bdb42ff6): the alert this false positive fired printed the full token.

## What happened (#1672 fire 1, `20260921T023204Z`) The healer ran TWICE for real — 18 min on account A, then 13 min on account B — and the second run returned a complete `{"action":"healed","commit":"3b227968",…}` verdict. Both runs were then classified as **Claude auth refusals**: the heal was reset away, the active-account marker flipped A→B for nothing, and Ben was paged "CLAUDE AUTH FAILED on account B — not logged in". Both tokens are fine (the reporter used them minutes later and filed #1678/#1679). ## Cause `claude_auth_failed` (`.sandcastle/limit-lib.sh`) greps the WHOLE of `<who>-claude.out` — the model's own prose — for `CLAUDE_AUTH_RE` (`failed to authenticate|oauth session expired|not logged in|invalid api key|authentication_error`). The healer's diagnosis quoted a Nextcloud 401 body it had read off the box: ``` `/settings/admin` → HTTP 401 {"message":"Current user is not logged in"} ``` `not logged in` matched. Any diagnosis of a SIGN-IN failure is likely to contain one of these phrases, and sign-in is most of what the drives prove right now — so this will recur. ## Ask Make the auth classifier read the CLI's refusal, not the model's prose. Options: anchor the phrases to the start of a line / the CLI's exact shapes ("Not logged in · Please run /login", "Failed to authenticate: …", `API Error: 401 …authentication_error`); or never classify an output that carries a parseable verdict as an auth refusal; or only consult stderr + a short stdout. Keep `preflight-swarm`'s `auth_detection` self-test and scenario 31 of `rehearsal-report-test.sh` green, add a fixture with the exact prose above that must NOT classify, and carry the same change to dev-factory's copy of `limit-lib.sh` (the two copies share one host-global marker and must agree). Same classifier guards `run-swarm.sh`'s worker log, where a worker's prose can trip it the same way. Related, already fixed (`bdb42ff6`): the alert this false positive fired printed the full token.

Cross-ref from #1683: the token-leak fix landed in dev-factory (issue #159, PR #160 into main), and idss re-vendored FACTORY_REF to a commit off its own pin base (142a3c10) — no full-main upgrade taken. Your #1682 clause about the same change to dev-factory limit-lib.sh is NOT included in that commit; it should ride the watched full-main FACTORY_REF bump split off as #1684, which is the moment idss next re-vendors from dev-factory main.

Cross-ref from #1683: the token-leak fix landed in dev-factory (issue #159, PR #160 into main), and idss re-vendored `FACTORY_REF` to a commit off its own pin base (`142a3c10`) — **no full-main upgrade taken**. Your #1682 clause about the same change to dev-factory `limit-lib.sh` is NOT included in that commit; it should ride the watched full-main `FACTORY_REF` bump split off as #1684, which is the moment idss next re-vendors from dev-factory main.

This was generated by AI during triage.

Triage → ready-for-session (bug)

Verified against the tree (HEAD c4f65280): the bug reproduces exactly as described.

  • The classifier is claude_auth_failed() at .sandcastle/limit-lib.sh:172-173: it grep -qiE "$CLAUDE_AUTH_RE" over the whole of each file, and CLAUDE_AUTH_RE (:170) is failed to authenticate|oauth session expired|not logged in|invalid api key|authentication_error. A healer diagnosis that quotes a Nextcloud 401 {"message":"Current user is not logged in"} matches on not logged in — model prose, not a CLI refusal. Confirmed unfixed on the idss side.
  • Same classifier is exercised by the preflight-swarm self-test guard_auth_detection() (.sandcastle/preflight-swarm.sh:75) and by scenario 31 of .sandcastle/tests/rehearsal-report-test.sh:645 (the #632 dead-token case). Both must stay green.

Why ready-for-session, not ready-for-agent

Every file this fix touches (.sandcastle/limit-lib.sh, .sandcastle/tests/rehearsal-report-test.sh, .sandcastle/preflight-swarm.sh) is inside the fingerprinted protected tree (.sandcastle, per .sandcastle/protected-paths-lib.sh / #445). A swarm worker that edited it would be rolled back and fail loud; the machinery's own escape path routes such changes ready-for-session (ADR 0174). No swarm work is available here — an interactive session owns it. Not Ben: the change is a revertible classifier tightening, provable by existing tests plus the new fixture below, and touches no one-way door (it narrows a false-positive, widens no posture, no credentials, no trust surface, no spend, no data loss).

Agent brief (for the session)

Goal: the auth classifier must fire on the CLI's own refusal, never on the model's prose.

Change (.sandcastle/limit-lib.sh) — pick the tightest of the ticket's options that keeps both self-tests green:

  • anchor the phrases to line-start / the CLI's exact shapes (Not logged in · Please run /login, Failed to authenticate: …, API Error: 401 …authentication_error), and/or
  • never classify an output that carries a parseable verdict ({"action":…}) as an auth refusal, and/or
  • consult only stderr + a short stdout head, not the full transcript.

Acceptance criteria:

  1. guard_auth_detection() stays green — a real Not logged in · Please run /login refusal still classifies (the #632 positive), a usage-limit log still does not, a normal worker log still does not.
  2. Scenario 31 of rehearsal-report-test.sh stays green.
  3. New fixture carrying the exact healer prose — /settings/admin` → HTTP 401 {"message":"Current user is not logged in"} — that must NOT classify as an auth refusal. Add it to the guard_auth_detection negative set (and/or a rehearsal-report scenario), asserting a diagnosis quoting a 401 body survives as a real verdict.
  4. The same guard on run-swarm.sh's worker-log path is covered by the same fixture shape (a worker's prose quoting these phrases must not halt the swarm).

Explicitly out of scope for this ticket: the dev-factory copy of limit-lib.sh. Per #1683's cross-ref (comment above), idss re-vendored FACTORY_REF to 142a3c10 off its pin base with no full-main upgrade; the dev-factory-side change rides the watched full-main FACTORY_REF bump split off as #1684. Land the idss-side fix here; #1684 carries the twin so the two host-global-marker copies re-converge on the next full-main re-vendor.

> *This was generated by AI during triage.* ## Triage → `ready-for-session` (bug) **Verified against the tree (HEAD `c4f65280`):** the bug reproduces exactly as described. - The classifier is `claude_auth_failed()` at `.sandcastle/limit-lib.sh:172-173`: it `grep -qiE "$CLAUDE_AUTH_RE"` over the **whole** of each file, and `CLAUDE_AUTH_RE` (`:170`) is `failed to authenticate|oauth session expired|not logged in|invalid api key|authentication_error`. A healer diagnosis that quotes a Nextcloud `401 {"message":"Current user is not logged in"}` matches on `not logged in` — model prose, not a CLI refusal. Confirmed unfixed on the idss side. - Same classifier is exercised by the `preflight-swarm` self-test `guard_auth_detection()` (`.sandcastle/preflight-swarm.sh:75`) and by scenario 31 of `.sandcastle/tests/rehearsal-report-test.sh:645` (the #632 dead-token case). Both must stay green. ## Why `ready-for-session`, not `ready-for-agent` Every file this fix touches (`.sandcastle/limit-lib.sh`, `.sandcastle/tests/rehearsal-report-test.sh`, `.sandcastle/preflight-swarm.sh`) is inside the **fingerprinted protected tree** (`.sandcastle`, per `.sandcastle/protected-paths-lib.sh` / #445). A swarm worker that edited it would be rolled back and fail loud; the machinery's own escape path routes such changes `ready-for-session` (ADR 0174). No swarm work is available here — an interactive session owns it. Not Ben: the change is a revertible classifier tightening, provable by existing tests plus the new fixture below, and touches no one-way door (it *narrows* a false-positive, widens no posture, no credentials, no trust surface, no spend, no data loss). ## Agent brief (for the session) **Goal:** the auth classifier must fire on the CLI's own refusal, never on the model's prose. **Change** (`.sandcastle/limit-lib.sh`) — pick the tightest of the ticket's options that keeps both self-tests green: - anchor the phrases to line-start / the CLI's exact shapes (`Not logged in · Please run /login`, `Failed to authenticate: …`, `API Error: 401 …authentication_error`), **and/or** - never classify an output that carries a parseable verdict (`{"action":…}`) as an auth refusal, **and/or** - consult only stderr + a short stdout head, not the full transcript. **Acceptance criteria:** 1. `guard_auth_detection()` stays green — a real `Not logged in · Please run /login` refusal still classifies (the #632 positive), a usage-limit log still does not, a normal worker log still does not. 2. Scenario 31 of `rehearsal-report-test.sh` stays green. 3. **New fixture** carrying the exact healer prose — ``/settings/admin` → HTTP 401 {"message":"Current user is not logged in"}`` — that **must NOT** classify as an auth refusal. Add it to the `guard_auth_detection` negative set (and/or a rehearsal-report scenario), asserting a diagnosis quoting a 401 body survives as a real verdict. 4. The same guard on `run-swarm.sh`'s worker-log path is covered by the same fixture shape (a worker's prose quoting these phrases must not halt the swarm). **Explicitly out of scope for this ticket:** the dev-factory copy of `limit-lib.sh`. Per #1683's cross-ref (comment above), idss re-vendored `FACTORY_REF` to `142a3c10` off its pin base with **no full-main upgrade**; the dev-factory-side change rides the watched full-main `FACTORY_REF` bump split off as **#1684**. Land the idss-side fix here; #1684 carries the twin so the two host-global-marker copies re-converge on the next full-main re-vendor.

Closed — landed and proven. Ruled by agent under ADR 0174 — veto anytime.

Root cause

claude_auth_failed (.sandcastle/limit-lib.sh) grepped the WHOLE of <who>-claude.out — the model's own diagnosis prose — for CLAUDE_AUTH_RE. Fire 1 (20260921T023204Z) diagnosed a sign-in fault by quoting a Nextcloud 401 body — `/settings/admin` → HTTP 401 {"message":"Current user is not logged in"} — and not logged in matched inside that quote, so a finished heal ({"action":"healed","commit":"3b227968",…}) was reset away, the active-account marker flipped A→B for nothing, and the false "CLAUDE AUTH FAILED" alert paged Ben. Sign-in is most of what the drives prove, so any sign-in diagnosis was likely to recur this.

Fix (the classifier reads the CLI's refusal, not the model's prose)

A new CLAUDE_AUTH_LINE_RE anchors the auth phrases to the start of a line (^[[:space:]]*…) — the CLI prints its refusal as its own line / the whole output, so a phrase quoted mid-line (a JSON body, a markdown bullet, a sentence) is inert. authentication_error stays matchable only inside the CLI's own API Error: <code> …authentication_error framing. CLAUDE_AUTH_RE (the phrase list a caller lifts to NAME the refusal in its notice) is unchanged, so every extraction site (_execute_auth_line, claude_auth_announce, run-swarm's worker guard) is untouched.

This is the ONE shared classifier, so it fixes run-swarm.sh's worker log and execute-lib's classify at the same root as the healer/reporter — no per-caller patch needed. (Considered and not taken: also gating the healer/reporter auth branch on "carries a parseable verdict"; anchoring at the shared root is general and sufficient, and the reported prose is always mid-line inside JSON, so the extra mechanism would add control-flow to a vendored file for no additional coverage.)

Proof (red-before-green, all offline)

  • tests/limit-lib-test.sh +1 group: the exact fire-1 401 prose, a {"action":"healed",…} verdict quoting the phrase, a markdown-bullet mention and a mid-sentence authentication_error must NOT classify; the CLI's API Error: 401 …authentication_error line still MUST. Reintroducing the whole-file grep → the 401-prose case FAILs.
  • preflight-swarm.sh guard_auth_detection +1 runtime negative (the exact 401 prose) — the self-test now guards the live classifier against this false positive.
  • tests/preflight-swarm-test.sh's auth-injection scenario retargeted to CLAUDE_AUTH_LINE_RE (the pattern the classifier now reads) so it still turns auth_detection RED.
  • idss green after re-vendor: limit-lib 20, preflight 10 guards / 6 injection scenarios, execute-lib 14, run-swarm-auth-guard 5, rehearsal-report 50 (scenario 31); check-harness-drift.sh OK @ 834ec68.

The two copies now agree

limit-lib.sh is vendored (drift-gated), so the fix landed in dev-factory first and idss re-vendored byte-identically — branched off idss's own pin base 142a3c10 so the unadopted ~16-commit harness rework (#1684) is not dragged in.

Commits

  • idss 4dd2befc — re-vendor FACTORY_REF 142a3c10 → 834ec68 + STATUS.md.
  • dev-factory 1cfa5c0 (PR #161) — the classifier + limit-lib/preflight tests; 834ec68 (PR #163) — the preflight-injection retarget. Both merged to dev-factory main.

Related, already fixed (bdb42ff6/#1683): the alert this false positive fired printed the full token.

**Closed — landed and proven. Ruled by agent under ADR 0174 — veto anytime.** ## Root cause `claude_auth_failed` (`.sandcastle/limit-lib.sh`) grepped the WHOLE of `<who>-claude.out` — the model's own diagnosis prose — for `CLAUDE_AUTH_RE`. Fire 1 (`20260921T023204Z`) diagnosed a sign-in fault by quoting a Nextcloud 401 body — `` `/settings/admin` → HTTP 401 {"message":"Current user is not logged in"} `` — and `not logged in` matched inside that quote, so a **finished** heal (`{"action":"healed","commit":"3b227968",…}`) was reset away, the active-account marker flipped A→B for nothing, and the false "CLAUDE AUTH FAILED" alert paged Ben. Sign-in is most of what the drives prove, so any sign-in diagnosis was likely to recur this. ## Fix (the classifier reads the CLI's refusal, not the model's prose) A new **`CLAUDE_AUTH_LINE_RE`** anchors the auth phrases to the **start of a line** (`^[[:space:]]*…`) — the CLI prints its refusal as its own line / the whole output, so a phrase quoted **mid-line** (a JSON body, a markdown bullet, a sentence) is inert. `authentication_error` stays matchable only inside the CLI's own `API Error: <code> …authentication_error` framing. `CLAUDE_AUTH_RE` (the phrase list a caller lifts to NAME the refusal in its notice) is **unchanged**, so every extraction site (`_execute_auth_line`, `claude_auth_announce`, run-swarm's worker guard) is untouched. This is the ONE shared classifier, so it fixes **run-swarm.sh's worker log** and **execute-lib's classify** at the same root as the healer/reporter — no per-caller patch needed. (Considered and not taken: also gating the healer/reporter auth branch on "carries a parseable verdict"; anchoring at the shared root is general and sufficient, and the reported prose is always mid-line inside JSON, so the extra mechanism would add control-flow to a vendored file for no additional coverage.) ## Proof (red-before-green, all offline) - `tests/limit-lib-test.sh` **+1 group**: the exact fire-1 401 prose, a `{"action":"healed",…}` verdict quoting the phrase, a markdown-bullet mention and a mid-sentence `authentication_error` must **NOT** classify; the CLI's `API Error: 401 …authentication_error` line still **MUST**. Reintroducing the whole-file grep → the 401-prose case FAILs. - `preflight-swarm.sh` `guard_auth_detection` **+1 runtime negative** (the exact 401 prose) — the self-test now guards the live classifier against this false positive. - `tests/preflight-swarm-test.sh`'s auth-injection scenario retargeted to `CLAUDE_AUTH_LINE_RE` (the pattern the classifier now reads) so it still turns `auth_detection` RED. - idss green after re-vendor: **limit-lib 20**, **preflight 10 guards / 6 injection scenarios**, **execute-lib 14**, **run-swarm-auth-guard 5**, **rehearsal-report 50 (scenario 31)**; `check-harness-drift.sh` OK @ `834ec68`. ## The two copies now agree `limit-lib.sh` is vendored (drift-gated), so the fix landed in **dev-factory** first and idss re-vendored byte-identically — branched off idss's own pin base `142a3c10` so the unadopted ~16-commit harness rework (#1684) is **not** dragged in. ## Commits - **idss** `4dd2befc` — re-vendor `FACTORY_REF 142a3c10 → 834ec68` + `STATUS.md`. - **dev-factory** `1cfa5c0` (PR #161) — the classifier + limit-lib/preflight tests; `834ec68` (PR #163) — the preflight-injection retarget. Both merged to dev-factory `main`. Related, already fixed (`bdb42ff6`/#1683): the alert this false positive fired printed the full token.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#1682
No description provided.