Skip to content

✨ [v6] claude auth: report long-lived-token vs dashboard-sign-in mode on auth status and surface 401 as token rejected - #17861

Merged
hivecommons-hive[bot] merged 7 commits into
v6from
scanner/fix-17759
Nov 12, 2026
Merged

hivecommons-hive[bot] merged 7 commits into
v6from
scanner/fix-17759

Conversation

@hivecommons-hive

@hivecommons-hive hivecommons-hive Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Refs #17759 (closed by #17841; this PR adds changelog.d/added-claude-auth-mode-status.md, src/crux/agent/authprobe.go, src/crux/agent/claude_operator_token_test.go, src/crux/agent/start_failure.go, src/crux/agent/start_failure_test.go and 13 more)
Part of #17753 (child 3 of 4)

Why

Operators running Claude agents on the long-lived claude setup-token token (#17762) need to see which auth mode is live without the token leaking anywhere. They also need a rejected inference-only token to be reported as a rejected token. Today it looks like a logout and tells them to run /login, which cannot fix it.

What

  • Mode on both surfaces. GET /api/claude-auth/status now returns mode (long-lived token or dashboard sign-in) alongside logged_in. The new read-only admin MCP tool claude_auth_status wraps the same route, so the dashboard and MCP report the same mode. Neither returns token material. Detection reuses claude.OperatorToken() from ✨ claude auth: run Claude agents on an operator-supplied long-lived token (HIVE_CLAUDE_OAUTH_TOKEN) #17762 through a new claude.AuthMode(). ✨ claude auth: run Claude agents on an operator-supplied long-lived token (HIVE_CLAUDE_OAUTH_TOKEN) #17762 added no set-token control, so this PR adds none to MCP either.
  • 401 shown as "token rejected". In long-lived-token mode:
    • the login-detector pause notification and its hint read Claude token rejected: generate a new one with claude setup-token;
    • a claude login-required start failure records the same reason.
    • AgentHasValidCredential no longer treats a fresh dashboard credentials file as proof for a claude agent, because the agent doesn't use that file. Without this change, the token-restart heal would swallow the rejection.
  • Unknown instead of logout. The inference-only token never reaches the profile read; only the dashboard sign-in exchange calls FetchProfile. ClaudeProber.Probe (usage/headroom) now fails open with a neutral "unknown" error in this mode. That error contains none of the watchdog auth markers, so it can't loop or page as a logout.
  • Docs and changelog. Updated agent-configuration.md, the auth recovery runbook, api-reference.md, admin-mcp.md and design/admin-mcp.md. The design doc notes that the status route is the one in-scope claude-auth route. Added a changelog fragment.

Tests

  • Status read through the dashboard handler and through the admin MCP provider, in both modes.
  • Redaction test: a sentinel token value, and a prefix of it, never appears in the status API, the MCP output or the hive log.
  • 401 wording in the pause notice and in the start-failure reason.
  • The usage probe reads as unknown and never calls the usage endpoint.
  • The credential-file proof is ignored in token mode.
  • Tool registration and its read path.

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 requested_by=@Danathar

… and surface 401 as token rejected

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 12, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign hanthor for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 12, 2026
@hivecommons-hive

hivecommons-hive Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

hive/awaiting-ci: CI pending — sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

Review findings from adjudicator-2 (folded here because this head already carries its hive review):

docs-currency (read at head f01b915)

The behavior changes land cleanly in agent-configuration.md, the runbook, admin-mcp.md and the design doc, but two operator-facing docs that describe the login-detector notification were not updated and now disagree with the code:

  1. src/docs/notifications.md:222 — the notification table still says the login detector "sends the backend-specific login instruction (Login required: <agent>)". src/pkg/loginscan/loginscan.go:46-51 (PauseNotice) now sends a different title and body in long-lived-token mode: 🔑 Claude token rejected: <agent> with the claude setup-token remediation. An operator filtering notifications by the documented title misses the new one. Add a row (or amend this one) for the token-mode variant.
  2. src/docs/troubleshooting.md:290 — "sends a high-priority notification telling you to attach to hive-<agent> and run that backend's login command." In token mode the notification deliberately does not say that (/login cannot fix a rejected token, per claude.TokenRejectedMessage). One clause pointing to the runbook's "Replace a Claude operator token" section would keep this current.
  3. src/docs/api-reference/auth.md:15 — the area page row for GET /api/claude-auth/status still reads "Claude Auth Status" while the index row in src/docs/api-reference.md:105 was expanded to describe logged_in/mode. The index header (api-reference.md:3) asks that the index and the area page be updated together.

Minor: the token-mode pause body (loginscan.go:49-50) tells the operator to "replace HIVE_CLAUDE_OAUTH_TOKEN with it", but the token may be supplied via HIVE_CLAUDE_OAUTH_TOKEN_FILE (src/crux/claude/operator_token.go:16); the runbook already covers both, so consider "update the configured secret source" wording there too.

Review findings from adjudicator (folded here because this head already carries its hive review):

Style/maintainability review at head f01b915. No blocker; two advisory notes.

1. Two sources of truth for "long-lived-token mode" inside one code path. Manager snapshots the token once at construction (src/crux/agent/manager.go:612, "read once at construction") and the new agent-side checks use that snapshot (src/crux/agent/authprobe.go:453, src/crux/agent/start_failure.go:275). The other new sites re-read env/file live: src/pkg/loginscan/loginscan.go:328 (claude.OperatorToken() != ""), src/pkg/rotation/rotation.go:393, and src/pkg/dashboard/claude_auth.go:64 via claude.AuthMode(). In Scan specifically, credentialValid := agentMgr.AgentHasValidCredential(name) (loginscan.go:303) follows the snapshot while PauseNotice(..., claude.OperatorToken() != "") four lines later follows the file, so a token file removed or rotated at runtime makes the verdict and the notice wording disagree. Suggest one predicate: either expose ClaudeLongLivedToken() bool on Manager/the AgentManager interface (loginscan.go:228) and use it in Scan, or have everything go through the new claude.AuthMode() — currently that helper exists but three of four new mode checks bypass it for OperatorToken() != "".

2. Pause-notice remediation names only the env-var source. src/pkg/loginscan/loginscan.go:49-50 tells the operator to "replace HIVE_CLAUDE_OAUTH_TOKEN with it", but claude.OperatorToken() also reads HIVE_CLAUDE_OAUTH_TOKEN_FILE / /secrets/claude-oauth-token (src/crux/claude/operator_token.go:13-22), and this PR's own runbook text covers both sources. A file-mounted deployment gets a hint that does not apply; pointing at the runbook or naming both sources would keep the notice accurate.

Minor: the hermetic operator-token test setup (Setenv ×2 + swap claude.OperatorTokenFile) is now written out four times (claude_operator_token_test.go:20, claude_auth_mode_test.go:24-28, rotation_claude_token_mode_test.go:19-23, operator_token_test.go:44-47); a shared helper would keep them from drifting.

Review findings from reviewer (folded here because this head already carries its hive review):

Read the diff against the v6 tree (callers included). Looks correct to me.

What I verified:

  • AgentHasValidCredential (src/crux/agent/authprobe.go:453) now returns false for claude in token mode, so loginscan.Verdict (src/pkg/loginscan/loginscan.go:188-199) falls through to ActionPause after the sighting streak instead of ActionDeferAuthenticated. The pause then renders via the new PauseNotice, which takes the mode from the same Manager snapshot (ClaudeLongLivedToken → claudeOperatorTokenMode, read once at construction in manager.go:925 from claude.OperatorToken()), so verdict and notice text can't disagree.
  • ClaudeProber.Probe (src/pkg/rotation/rotation.go:390) returns failOpen before any credential read; probeErrorCause classifies it as ProbeCauseProbeFailed, and the test asserts the error carries no login/401/sk-ant markers.
  • handleClaudeAuthStatus only ever emits logged_in and mode; adminmcp.ReadPath maps claude_auth_status to that route and the tool takes no input, so no token material can reach the MCP surface.
  • Body ↔ diff: every claim in "What" has a corresponding hunk; docs, runbook and changelog fragment match the strings in claude/operator_token.go.

One observation, not a defect: in token mode logged_in is now true even with no dashboard credentials file (previously false). That is the right reading for "can agents authenticate", and the mode field disambiguates it, but any dashboard UI that gated the sign-in button purely on logged_in will now hide it in token mode — which is consistent with the mode doc ("signing in again on the dashboard does not replace it").

Review findings from adjudicator-3 (folded here because this head already carries its hive review):

Style review (head 8e8f9b4) — approve with advisory

Clean structure: claudetest.SetOperatorToken centralises the token staging the old stageOperatorToken duplicated, PauseNotice pulls the notification rendering out of Scan, and the ClaudeAuthModeReporter fallback is justified since runEvalCycle takes agentMgr crux.Runtime (src/cmd/hive/main_eval_cycle.go:531, call at :1236).

  1. Pause reason still says "login required" in token mode — src/pkg/loginscan/loginscan.go:349 now renders the notice as Claude token rejected: …, but the pause the operator sees on the dashboard is still recorded at :377 with agentMgr.Pause(name, "login-detector", "login required detected"). So the notification says the token was rejected while the agent card says login required — the exact "looks like a logout" story the PR body sets out to fix. Suggest a mode-aware reason for Pause (e.g. claude.TokenRejectedMessage); leave the logger.Warn("login required detected", …) at :354 as is, since the fleet selfreport class derives from it ([selfreport] agent_login_required: login required detected #16953). Low severity, advisory.

  2. Nit: changelog.d/added-claude-auth-mode-status.md:1 omits the trailing issue reference that sibling fragments carry (e.g. changed-claude-operator-token-suspends-rebridge.md ends (#17760)).

Review findings from reviewer-2 (folded here because this head already carries its hive review):

Read the tree at 8e8f9b4, not just the diff. This looks correct to me.

What I verified

  • crux/agent/authprobe.go:453 returns false in long-lived-token mode before credentialFileProves. I read all three in-process callers and the effect is consistent: pkg/loginscan/loginscan.go:324 → Verdict(...) now pauses after the streak instead of ActionDeferAuthenticated; crux/agent/manager_poll.go:175 skips the token-restart heal; crux/agent/watchdog_fleet.go:147 sets credentialProven=false so the fleet reconciler pages rather than stays quiet. The remote Runtime (crux/api/client/client.go:800) reads HasValidCredential from supervision, which crux/serve/families.go:720 fills from the same method, so remote and in-process agree.
  • pkg/rotation/rotation.go:393-398: the new failOpen error text (claude usage unknown: agents run on the long-lived token, which has no usage scope) contains none of the authErrorMarkers at crux/watchdog/rotation_probe.go:39-48 (login, 401, unauthorized, authentication, …), so the body's claim that it cannot be read as a logout holds.
  • pkg/loginscan/loginscan.go:349-358: loginCmd is still fed to the WARN line's login_hint, so the agent_login_required selfreport class keeps its field.
  • crux/agent/start_failure.go:274-281 only rewrites the reason for StartFailureLoginRequired + claude + token mode; other backends and the dashboard-sign-in path keep startFailureReason unchanged (test at start_failure_test.go:388-404 covers both).
  • pkg/adminmcp/adminmcp.go: claude_auth_status is added to toolDefs, AllowedTool, inputSchema (empty props) and ReadPath → /api/claude-auth/status, matching the pattern of ToolVersionRead.
  • Docs (api-reference.md, api-reference/auth.md, troubleshooting.md, runbook) and the changelog fragment describe exactly what the code does.

One note, not a defect — pkg/dashboard/claude_auth.go:65: in long-lived-token mode logged_in is true whenever a token is configured, independent of whether Claude accepts it. So a hive whose agents are all paused with Claude token rejected will still show logged_in: true, mode: long-lived token. That is consistent with the route never probing, and mode tells the operator where to look, but a maintainer may want the field documented as "configured" rather than "valid" in token mode.

Evidence bundle `#1786126a63b8` sha256:6ca3138538553ffa0b0aeb954969b0a6dbd140117c471ba3f7a8de5421cf4a76 — download from the dashboard or `hivectl review evidence #17861`.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v6

Conflicts are checked with every PR merged onto the current tip of v6, so a PR that only needs a rebase is not reported as conflicting with its siblings.

No conflicting open PRs or same-file overlaps were found.

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 12, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the v6 tree at 4e6b6cc including every caller of AgentHasValidCredential. This looks correct to me, and the behaviour in operator-token mode is coherent end to end:

  • A login prompt on the long-lived token is no longer "healed" by a pointless restart. AgentHasValidCredential returns false for claude in operator mode (src/crux/agent/authprobe.go:453), so the token-restart theory in manager_poll.go:175 is not entered, loginscan.Scan (loginscan.go:304,329) pauses the agent with the PauseNotice token-rejected title/body/hint instead of the /login text, and the fleet watchdog's credentialProven (watchdog_fleet.go:147) stays false so the reconciler pages an operator. The three consumers agree; none is left pointing at /login.
  • Start-failure reason is rewritten only on the exact class. recordStartFailureLocked (start_failure.go:275) swaps the message for StartFailureLoginRequired && backend=="claude" only, keeping the detail suffix; other classes and backends are unchanged.
  • Rotation prober fails open rather than reading as a logout. ClaudeProber.Probe (rotation.go:391-397) returns failOpen (Available: true, rotation.go:327), so no strand/rotation is triggered off the unused credentials file.
  • Status surfaces leak no token material. /api/claude-auth/status adds only mode (dashboard/claude_auth.go), computed from claude.AuthMode() which returns a fixed label; the admin MCP claude_auth_status tool is registered in the read-only set and the no-argument schema group (adminmcp.go:478) and proxies that endpoint.

Minor, not a finding: claude.OperatorToken() is re-evaluated per call here (env, then the token file) whereas the Manager reads it once at construction (manager.go:925). They can only disagree if the operator edits the token file mid-run, in which case the status endpoint would report "long-lived token" while running agents still hold the old value until restart — the notice body already tells the operator to restart the hive, so this is fine as is.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Mutation testing

Head 26a63b8de.

❌ gremlins did not produce a report for 1 package(s), so no verdict can be derived from this run (see the job log):

  • crux/agent: gremlins exited 1

Verdict: error (#17349).

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read against the v6 tree, including the consumers of AgentHasValidCredential. The change does what the body says and the three surfaces agree; looks correct to me. Two small notes, neither a defect.

Verified

  • Manager.claudeOperatorToken is read once at construction (src/crux/agent/manager.go:612), so the new authprobe.go check is stable for the process lifetime, matching how claudeOperatorTokenMode() is already used in credentials_watchdog.go:270 and claude_credential_bridge.go:547.
  • Returning false from AgentHasValidCredential in token mode produces the intended routing at every caller: pkg/loginscan/loginscan.go:281 → Verdict(...) lands on ActionPause rather than ActionDeferAuthenticated, so the new PauseNotice wording reaches the operator; crux/agent/manager_poll.go:175 skips the token-restart heal; crux/agent/watchdog_fleet.go:147 sets credentialProven=false, so the fleet reconciler pages instead of staying silent. That is exactly the "heal would swallow the rejection" case the body describes.
  • failOpen (pkg/rotation/rotation.go:327) already sets Available: true with ProbeErrCause, so the early return keeps the prober's existing degraded shape; the test asserts none of the watchdog's logout markers are in the message.
  • pkg/dashboard/claude_auth.go already imports crux/claude, and the JS consumers of logged_in (core.js:43, tooltips-dialogs.js:930) only read the boolean, so the added mode key is additive.

Notes (info)

  1. src/pkg/dashboard/claude_auth.go (new handleClaudeAuthStatus): in long-lived-token mode logged_in is true whenever a token is configured, not when it is accepted. tooltips-dialogs.js:931 will therefore render state: 'ok' while Claude is answering 401 to that token; the rejection is only visible via the pause notice / start-failure reason this PR adds. That is a reasonable reading of "logged in" for an inference-only token the hive cannot probe, but the api-reference.md text might say so explicitly ("configured", not "validated") so an operator does not read logged_in: true as a liveness check.
  2. src/crux/agent/authprobe.go and start_failure.go compare m.claudeOperatorToken != "" directly; the package already has m.claudeOperatorTokenMode() (crux/agent/claude_operator_token_mode.go:24) for the same predicate. Using the helper would keep one definition of the mode.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Supersession sweep found that this PR's claimed issue is already closed by another merged PR.

  • Claimed issue: hive#17759
  • Closing PR: #17841

Keeping this hive-authored PR open: with head b36d9d7 current with v6, it still adds 18 file(s) #17841 did not touch: changelog.d/added-claude-auth-mode-status.md, src/crux/agent/authprobe.go, src/crux/agent/claude_operator_token_test.go, src/crux/agent/start_failure.go, src/crux/agent/start_failure_test.go and 13 more. Its body now reads Refs #17759 (closed by #17841; …) instead of Closes #17759, and it continues in the lane.

This comment is edited in place by the supersession sweep; it is not duplicated.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the Go changes against the v6 tree (a222a3e), including the surrounding code each hunk lands in. Looks correct to me, and I checked specifically that no token material can leave the process through the new surfaces.

What I verified:

  • claude.AuthMode() (crux/claude/operator_token.go) only tests OperatorToken() != ""; the string it returns is one of two fixed constants. handleClaudeAuthStatus (pkg/dashboard/claude_auth.go) emits {logged_in, mode} and nothing else, so exposing it through the read-only admin MCP tool claude_auth_status does not widen what the MCP can see. The tool is added to the read-only case list and the no-args inputSchema case in pkg/adminmcp/adminmcp.go, matching ToolLogSources.
  • start_failure.go uses m.claudeOperatorToken != "", which is exactly the predicate Manager.claudeOperatorTokenMode() already defines (crux/agent/claude_operator_token_mode.go:24), and that field is read once at construction, so the "token rejected" reason is consistent with the mode the credential bridge and watchdog already suspend on.
  • loginscan.PauseNotice factors the existing title/body out unchanged for the non-token case (compared against the removed notifier.Send block) and only diverges for backend == "claude" && longLivedToken.
  • rotation.go: the early failOpen sits before the credentials-file read in ClaudeProber.Probe, and failOpen/Provider() exist at rotation.go:327 and :388; a long-lived token genuinely has no usage scope, so "unknown headroom, not a logout" is the right classification.

One observation, not a defect: in long-lived-token mode logged_in is true whenever the token is configured, independent of whether Claude currently accepts it. Rejection is surfaced through the start-failure reason and the pause notice instead. That split seems intentional per the body ("mode", not health), but a dashboard reader may expect logged_in to flip on a 401; worth a sentence in backend-auth-recovery-runbook.md if it is not already there.

Style nit only: start_failure.go could call m.claudeOperatorTokenMode() instead of re-spelling the comparison.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read against the v6 tree (merge-base a222a3e); looks correct to me, and I found no path by which token material reaches a surface.

What I verified:

  • crux/claude/operator_token.go:56-61 — AuthMode() returns one of two fixed strings and never the token. pkg/dashboard/claude_auth.go:64-68 returns only {logged_in, mode}; the admin MCP tool is a pure read of that route (adminmcp.go:801-802, argument-free schema at :478, listed in AllowedTool at :409).
  • crux/agent/authprobe.go:453-455 — returning false for a claude agent in token mode is the right sign for both callers: loginscan.go:304-312 then takes the pause branch instead of ActionDeferAuthenticated (which would hand a rejected token to the token-restart heal, as the body says), and watchdog_fleet.go:147 sets credentialProven=false so the reconciler pages rather than stays silent. Non-claude backends are untouched by the backend == "claude" guard.
  • loginscan.go:46-61 PauseNotice and start_failure.go:274-281 both emit claude.TokenRejectedMessage only when backend == "claude" and the token is set; the default wording is byte-identical to what Scan produced before (loginscan.go:341-349 pre-change).
  • rotation.go:391-397 — the fail-open error text contains none of the watchdog auth markers, so the usage probe can't masquerade as a logout.

One observation, not a defect: rotation.go:395 and loginscan.go:329 call claude.OperatorToken() per tick, which falls through to an os.ReadFile of /secrets/claude-oauth-token whenever the env var is unset (operator_token.go:33-39). The Manager read the token once at construction (#17762); these two re-read it each cycle. Harmless at these tick rates, but if you want consistency, Manager could expose claudeOperatorTokenMode() to both.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 12, 2026
…ken sources, mirror docs

Review fixes for #17861:

- Scan took the Claude auth mode from a live claude.OperatorToken() read
  while AgentHasValidCredential used the Manager's construction-time
  snapshot, so a token file removed or rotated at runtime could yield a
  verdict from one mode and a notice from the other. Manager now exports
  ClaudeLongLivedToken() and Scan prefers it through the optional
  loginscan.ClaudeAuthModeReporter interface, falling back to
  claude.AuthMode() for runtimes that cannot say. The two new in-package
  checks route through claudeOperatorTokenMode() and rotation.go through
  claude.AuthMode(), so no caller compares the raw token any more.
- The token-mode pause body named only HIVE_CLAUDE_OAUTH_TOKEN; it now
  names the _FILE source too and points at the runbook's "Replace a Claude
  operator token" section.
- notifications.md and troubleshooting.md document the "Claude token
  rejected: <agent>" variant; api-reference/auth.md mirrors the index row
  for GET /api/claude-auth/status.
- The hermetic operator-token test setup, duplicated across four test
  files, lives once in crux/claude/claudetest.SetOperatorToken.

Hive-Fix-Attempt: 1/6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 12, 2026
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Nov 12, 2026
@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 12, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correctness re-review of the delta f01b915…9bcec8c — all seven findings from the previous head are fixed (notifications.md row, troubleshooting.md paragraph, api-reference/auth.md row, _FILE source named in PauseNotice body at src/pkg/loginscan/loginscan.go:49-52, mode now sourced from the manager via ClaudeAuthModeReporter at loginscan.go:238-254, helper deduplicated into claudetest.SetOperatorToken). The manager-sourced mode is sound for the in-process runtime: cruxruntime.New returns the *agent.Manager unwrapped (src/cmd/hive/agent_runtime.go:29-38), so the type assertion at loginscan.go:250 succeeds; only the sidecar host falls back to the live claude.AuthMode() read.

One new in-scope issue introduced by the delta:

crux/claude/claudetest has no test files, so the coverage gate fails — src/crux/claude/claudetest/ contains only claudetest.go at this head. The per-package gate in .github/workflows/v2-tests.yml:2460-2466 marks any non-exempt package with no _test.go as BROKEN: NO TEST FILES, and the coverage check on this head fails with exactly crux/claude/claudetest: NO TEST FILES (run 43179121397). Fix: add src/crux/claude/claudetest/claudetest_test.go that calls SetOperatorToken(t, "")/SetOperatorToken(t, "sk-…") and asserts claude.OperatorToken() returns exactly the given value with the env/_FILE/default-file sources each pinned — that both satisfies the gate and pins the "one place that knows the full list of sources" promise in the package doc.

— hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88

…iles

The per-package coverage gate rejects a package with no test files
(crux/claude/claudetest: NO TEST FILES). The test also proves the helper
pins every token source and restores them.

Hive-Fix-Attempt: 1/6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code reads correct to me; the one thing blocking it is the red coverage check, and that is caused by this diff.

src/crux/claude/claudetest/claudetest.go is a new package with no _test.go. The per-package gate in .github/workflows/v2-tests.yml:2466 hard-fails any package go test -cover reports as [no test files] (the only exemption list, UNTESTED_CMD_MAINS, is for thin cmd/ mains and is empty). The coverage job log ends with exactly that:

COVERAGE GATE FAILED:
crux/claude/claudetest: NO TEST FILES

src/crux/claude/auth_mode_test.go and src/crux/agent/claude_operator_token_test.go do exercise SetOperatorToken, but from other packages, which doesn't count toward claudetest's own score. The fix is small: add src/crux/claude/claudetest/claudetest_test.go asserting that SetOperatorToken(t, "x") makes claude.OperatorToken() return "x" and SetOperatorToken(t, "") makes it return "" with claude.OperatorTokenFile pointing at a missing path. Same shape src/crux/cruxtest/recorder_test.go uses for that helper package.

What I verified in the tree, for the record:

  • AgentHasValidCredential returning false in token mode (src/crux/agent/authprobe.go:453) is safe for all three callers: manager_poll.go:175 skips the token-restart heal (intended), loginscan.go:324 lets the streak reach ActionPause (intended), and watchdog_fleet.go:147 feeds CredentialProven, which crux/watchdog/classify.go:84-88 documents as positive-evidence-only — false can only soften a verdict, never page.
  • The new ClaudeProber.Probe error text (src/pkg/rotation/rotation.go:394) contains none of the eight authErrorMarkers in src/crux/watchdog/rotation_probe.go:39-48, so it classifies as AuthUnknown, not AuthFailed, as the body says.
  • claude_auth.go:65-66 short-circuits the credentials-file read in token mode, so mode and logged_in carry no token material; the MCP tool is a pure ReadPath wrapper (adminmcp.go:801).

One note, not a defect: loginscan.go:375 still passes "login required detected" as the Pause reason in token mode, so the dashboard pause reason will say "login required" while the notification says "token rejected". The body doesn't claim to change the pause reason, so I'm only flagging it as a possible follow-up.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Nov 12, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the diff against the v6 tree and the callers; this looks correct to me.

What I verified:

  • crux/watchdog/rotation_probe.go:39-48 — the new fail-open error in pkg/rotation/rotation.go:393-399 (claude usage unknown: agents run on the long-lived token…) contains none of the authErrorMarkers, so ProbeAuth returns AuthUnknown, not AuthFailed. The "can't loop or page as a logout" claim holds.
  • crux/agent/authprobe.go:450-455 — the three callers of AgentHasValidCredential (manager_poll.go:175 restart heal, watchdog_fleet.go:147 credentialProven, loginscan.go:324) all read the new false the intended way: the heal no longer swallows the 401, and loginscan reaches ActionPause with the token-rejected notice.
  • pkg/loginscan/loginscan.go:249-254 — in-process *agent.Manager satisfies ClaudeAuthModeReporter and answers from the construction-time snapshot (manager.go:925), the same one AgentHasValidCredential and recordStartFailureLocked use; the live claude.AuthMode() read is only the remote-runtime fallback. Verdict and notice come from one source, as the comment says.
  • pkg/dashboard/claude_auth.go:63-68 and pkg/adminmcp/adminmcp.go:801-802 — status payload is {logged_in, mode} only; nothing in the diff writes the token value anywhere, and the sentinel test covers API, MCP and log output.

One observation, not a defect: in long-lived-token mode logged_in is true whenever a token is configured (claude_auth.go:66), independent of whether Claude currently accepts it. A rejected token therefore still reads logged_in: true, mode: long-lived token, with the rejection surfacing only via the pause notice / start-failure reason. That matches the PR body's stated scope ("see which auth mode is live"), so I'm flagging it only so the docs wording isn't read as a liveness check.

#17890 is the v5 twin of this change (different base); not a duplicate.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 12, 2026
@hivecommons-hive
hivecommons-hive Bot merged commit 7e2cb43 into v6 Nov 12, 2026
88 of 91 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-17759 branch November 12, 2026 08:47
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) labels Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR copilot dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scanner] [v6] claude auth: report long-lived-token vs dashboard-sign-in mode on the auth status (dashboard + MCP) and surface 401 as token rejected

0 participants