Repository navigation
✨ claude auth: run Claude agents on an operator-supplied long-lived token (HIVE_CLAUDE_OAUTH_TOKEN) - #17762
Conversation
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. hive/awaiting-ci: build-contributor failed on ebbfd94 with the buildx GHA-cache BlobNotFound infra error already triaged above; pushed an empty signed commit to retrigger the build. CI pending — sweep will merge when green. 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 Review findings from Correctness review (head f480eb2, read against the tree, no local checkout available) 1. The tmux server is spawned with the hive process's full environment ( The issue (#17758) requires "never written to a pane", and Fix: add Everything else I checked holds: precedence over Review findings from Intent alignment (vs #17758), read at head f480eb2. The diff does what the issue asks: One in-scope fix needed:
Out of scope, for backlog: the hive-side ioscan classifier ( Not verified here (as #17758/#17753 already note): that Claude Code prefers Review findings from Read the diff against What I verified:
What a human should weigh (not defects):
Per #17758 this is the scoped child; docs are deliberately deferred to #17761. Review findings from Read against the v6 tree, not just the diff. The env plumbing holds up and I found no defect. Verified
One docs note (not blocking) Open question, not a finding Looks correct to me. CI is green apart from stage 080-awaiting-merge-admission → 070-fixing: check-failure |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of No conflicting open PRs or same-file overlaps were found. |
There was a problem hiding this comment.
Security review (head f480eb2) — one in-scope gap, concrete fix.
HIVE_CLAUDE_OAUTH_TOKEN (env form) is inherited by every agent's pane, including non-claude backends
The sanctioned delivery (agentEnvPairs → secret pair → set-environment, src/crux/agent/manager_env.go:470-474) is fine. The problem is the raw variable. src/crux/agent/manager_tmux.go:25-59 documents the mechanism: a tmux server started by the hive process inherits the hive's environment into its global env, which tmux copies into every pane it forks, so every hive-process secret must be set-environment -r'd in applySessionEnv (manager_tmux.go:95-98). The list that strip walks, inheritedCredentialEnvVars (manager_tmux.go:52-59), contains HIVE_GITHUB_TOKEN and the Linear secrets but is not updated by this PR.
Consequence when the operator uses the env form (the first option named in changelog.d/added-claude-long-lived-token.md and in claude.OperatorToken(), src/crux/claude/operator_token.go:28): HIVE_CLAUDE_OAUTH_TOKEN=<year-long token> is present in the pane shell — and in every tool shell the CLI spawns — of every agent, copilot/codex/bob included. That is the same class of leak as the 2026-09-05 LINEAR_API_KEY incident quoted at manager_tmux.go:35-42, and it contradicts #17758's intake requirement ("never written to a pane") and the PR body's "It never appears … in a pane". TestClaudeOperatorToken_FileFormAndOtherBackends (src/crux/agent/claude_operator_token_test.go:124-131) only inspects agentEnvPairs, so it cannot catch this.
Requested change: add claude.OperatorTokenEnvVar to inheritedCredentialEnvVars (manager_tmux.go:52) so applySessionEnv hides it for all agents (claude agents still get the token under CLAUDE_CODE_OAUTH_TOKEN via the secret pair set afterwards), and extend the tmux-args test coverage to assert the -r for it. The file form (/secrets/claude-oauth-token) is unaffected.
Not blocking / open question: the default secret file path follows the dashboard-token convention; whether /secrets/claude-oauth-token is mode-restricted against per-agent UIDs is a deployment concern I could not verify from the tree.
— hive: agent=adjudicator-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
Review follow-ups (below
|
Mutation testingHead ❌ gremlins did not produce a report for 1 package(s), so no verdict can be derived from this run (see the job log):
Verdict: |
There was a problem hiding this comment.
Read against the tree at d6481e5 (merge-base with v6), not just the diff. Looks correct to me.
What I verified
src/crux/agent/manager_env.go:474-477— the operator token branch is taken before the existingclaudeAuthToken && !claudeCredentialReachable(...)branch, so a reachable credentials file no longer suppresses injection whenHIVE_CLAUDE_OAUTH_TOKENis set, and the pair is stillSecret: true(tmuxset-environmentonly,manager_env.go:183-188). With the operator token empty theelse ifis byte-for-byte the old condition, so the opt-out path is unchanged.src/crux/agent/manager.go:612,919—claudeOperatorTokenis written once inNewManagerWithOptionsand never byReloadClaudeToken(manager_tokens.go:28-35), which only rewritesclaudeAuthToken. That is what makes "a later dashboard sign-in cannot switch agents back" true;TestClaudeOperatorToken_WinsOverALaterDashboardSignInpins it.src/crux/agent/headless_credentials.go:38-43— headless launches get the same precedence, so the two launch paths cannot disagree about which credential aclaudeagent runs on.src/crux/claude/operator_token.go:27-39— env var →HIVE_CLAUDE_OAUTH_TOKEN_FILE→/secrets/claude-oauth-token, trimmed, unreadable file is"". Mirrors the dashboard-token convention.src/pkg/dashboard/api_logs.go:102— the value is inlogSecretSources, so a token mounted outside the secret roots is still redacted on/api/logs/readand the admin MCPlog_read;TestLogReadScrubsClaudeOperatorTokencovers both the file and env forms.api-reference.mdcitation shift is just the new import line inapi_logs.go.
One open question, not a defect (deferred to #17759 per the body, noting it so it does not get lost): once the operator token is set it is pinned for every claude agent, and because ReloadClaudeToken cannot displace it, a dashboard re-login will not recover a fleet whose setup-token has expired or been revoked — the only fix is to change the env/secret and restart. Worth saying in the operator docs under #17761.
Not a duplicate of #17752: that one changes how ~/.claude is shared; this one adds a credential source. They overlap on docs only, as the body notes.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
…UDE_OAUTH_TOKEN Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: Danathar <6772335+Danathar@users.noreply.github.com>
…sync api-reference citations HeadlessCredentialEnv now applies the same precedence as agentEnvPairs: the operator-supplied long-lived token wins over the short-lived credentials snapshot, so hub-launched claude CLIs no longer pin to a token that cannot refresh. Adds a unit test for the new path. api-reference.md citations for GET /api/logs/sources and /api/logs/read resynced via check-api-reference-citations.sh --fix after the import added in api_logs.go shifted the registrations by one line. 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>
…inherited env The hive process holds HIVE_CLAUDE_OAUTH_TOKEN in its own environment, and each tmux server it starts inherits that into its GLOBAL environment, which tmux copies into every pane it forks. applySessionEnv never removed it, so copilot/codex/bob agent shells (and every tool shell they spawn) could read the year-long token under its original name — contradicting the claim that the token never appears in a pane. The claude backend was unaffected in practice only because it also receives the value as CLAUDE_CODE_OAUTH_TOKEN. Add claude.OperatorTokenEnvVar to inheritedCredentialEnvVars so the creation-time strip records a `set-environment -r` removal for it, hiding the global value from every process forked afterwards. The file form (HIVE_CLAUDE_OAUTH_TOKEN_FILE) carries only a path and is unaffected. The real-tmux leak test now plants the variable in the server env and asserts a fresh pane no longer sees it; a tmux-free unit test pins the entry in inheritedCredentialEnvVars. Hive-Fix-Attempt: 2/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
11c43e0 to
eda7354
Compare
There was a problem hiding this comment.
Decision needed: @clubanderson should decide whether this lands on v5 as opened, or must be retargeted to v6 as #17753/#17758 ("Target: v6") specify.
The code looks correct to me; the open question is the base branch, not the diff.
What I verified in the tree (v5 @ ba6238c)
src/crux/agent/manager_tmux.go:125—applySessionEnvrunsset-environment -rfor everyinheritedCredentialEnvVarsentry before settingagentEnvPairs, so addingHIVE_CLAUDE_OAUTH_TOKENto that list hides the hive-process value from every pane and only claude-backend sessions get it back, renamed toCLAUDE_CODE_OAUTH_TOKEN. The ordering comment onmanager_tmux.go:113-118is exactly the guarantee this change relies on.src/crux/agent/manager_tokens.go:25-30—ReloadClaudeToken(the dashboard sign-in path) only rewritesm.claudeAuthTokenin memory; there is no tmux push for Claude the waypropagateCopilotTokendoes for Copilot. So the newif m.claudeOperatorToken != "" … else if m.claudeAuthToken != "" …ordering inmanager_env.gois sufficient for "a later sign-in never switches agents back" — nothing else emitsCLAUDE_CODE_OAUTH_TOKEN(the only other producers areheadless_credentials.go, updated here with the same precedence, andpkg/ioscan/cli_client.go:141, which just lists the name).src/crux/claude/operator_token.gois a leaf (os,strings), so the new import frompkg/dashboard/api_logs.gointroduces no cycle.credentials_watchdog.go:177,243will still warn "durable credential unusable … agents on this backend hang at login" when the credentials file goes stale under a pinned operator token. That warning becomes inaccurate in this mode; #17758 explicitly scopes the watchdog stand-down to #17760, so I'm noting it, not counting it against this PR.
The question for a maintainer
#17753 (opened by @Danathar) and #17758 both say Target: v6, and #17753 analyses the tree "as of v6 at d6481e59e". This PR targets v5. CONTRIBUTING.md:45-47 says v6 is for dashboard-optional-operation work under #7563 and that such PRs are "out of scope on v4 and v5" — and running agents without a dashboard sign-in is squarely that kind of change. The PR body does not say why v5 was chosen. If v5 is intended (it is opt-in and v5 accepts operability improvements), a one-line note in the body would settle it; otherwise this needs retargeting to v6 before merge.
I have not approved, closed, or relabelled anything.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the tree at 597ded2, not just the diff. This looks correct to me.
src/crux/agent/manager_env.go:471-477— the operator token branch is taken before theclaudeCredentialReachablefallback, so it is injected whether or not a credentials file is bridged;Secret: truekeeps it off the command line (agentEnvPair,manager_env.go:183-188).src/crux/agent/manager_tmux.go:60-63+applySessionEnv(manager_tmux.go:133-135) —HIVE_CLAUDE_OAUTH_TOKENisset-environment -r'd before the per-agent pairs are set, so non-claude panes never see it under either name.TestClaudeOperatorToken_StrippedFromInheritedPaneEnvcovers this.src/crux/agent/manager_tokens.go:28-33—ReloadClaudeTokenonly rewritesclaudeAuthToken;claudeOperatorTokenis set once inNewManagerWithOptions(manager.go:922), so a later dashboard sign-in cannot displace it, as the body claims andTestClaudeOperatorToken_WinsOverALaterDashboardSignInchecks.src/pkg/dashboard/api_logs.go:102— the value is added to the read-time scrub set;TestLogReadScrubsClaudeOperatorTokencovers both env and file sources.src/crux/claude/operator_token.go—InstallationCoverage-style "cannot read" returns"", so an absent file is a no-op, matching the opt-in claim.
Open question (not a defect, already tracked on #17753): whether Claude Code prefers CLAUDE_CODE_OAUTH_TOKEN over a still-bridged ~/.claude/.credentials.json is not verifiable from this tree; rebridgeClaudeCredentialsAfterSignIn still runs with the operator token set.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Needs a decision, not a merge:
Head: verdict requires_human @597ded2, 71/71 checks green, DCO yes, soak 0s of 10m0s. What to do: approve this head ( How to release it:
Clear the cause and the hive re-evaluates on its next pass; the stage moves to |
clubanderson
left a comment
There was a problem hiding this comment.
Decision (on Andy's behalf): yes, the hive may accept an operator-supplied long-lived Claude token. Reviewed the diff: the token is read once at construction and injected only to claude-backend panes as CLAUDE_CODE_OAUTH_TOKEN through the secret env path (never the command line), stripped from inherited tmux env under its own name, added to the log scrubber sources, wins over a later dashboard sign-in, and unset leaves today's behaviour (existing tests unchanged). Not exercising it against a real setup-token in CI is expected; the operator validates that on a staging hive. The re-bridge/watchdog bypass is the follow-up #17851 (stacked on this branch), which GitHub will retarget to v6 when this merges.
/lgtm
/approve
|
LGTM label has been added. DetailsGit tree hash: f35a1784732da0ef0ffb1c29d3877fffc740f71a |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: clubanderson The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
…ved token (HIVE_CLAUDE_OAUTH_TOKEN) (#17890) * ✨ claude auth: run Claude agents on an operator-supplied long-lived token (HIVE_CLAUDE_OAUTH_TOKEN) (#17762) * ✨ claude auth: inject operator-supplied long-lived token via HIVE_CLAUDE_OAUTH_TOKEN Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: Danathar <6772335+Danathar@users.noreply.github.com> * 🐛 claude auth: honor HIVE_CLAUDE_OAUTH_TOKEN in headless launches; resync api-reference citations HeadlessCredentialEnv now applies the same precedence as agentEnvPairs: the operator-supplied long-lived token wins over the short-lived credentials snapshot, so hub-launched claude CLIs no longer pin to a token that cannot refresh. Adds a unit test for the new path. api-reference.md citations for GET /api/logs/sources and /api/logs/read resynced via check-api-reference-citations.sh --fix after the import added in api_logs.go shifted the registrations by one line. 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> * 🔒 claude auth: strip HIVE_CLAUDE_OAUTH_TOKEN from every agent pane's inherited env The hive process holds HIVE_CLAUDE_OAUTH_TOKEN in its own environment, and each tmux server it starts inherits that into its GLOBAL environment, which tmux copies into every pane it forks. applySessionEnv never removed it, so copilot/codex/bob agent shells (and every tool shell they spawn) could read the year-long token under its original name — contradicting the claim that the token never appears in a pane. The claude backend was unaffected in practice only because it also receives the value as CLAUDE_CODE_OAUTH_TOKEN. Add claude.OperatorTokenEnvVar to inheritedCredentialEnvVars so the creation-time strip records a `set-environment -r` removal for it, hiding the global value from every process forked afterwards. The file form (HIVE_CLAUDE_OAUTH_TOKEN_FILE) carries only a path and is unaffected. The real-tmux leak test now plants the variable in the server env and asserts a fresh pane no longer sees it; a tmux-free unit test pins the entry in inheritedCredentialEnvVars. Hive-Fix-Attempt: 2/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> * 🌱 chore: retrigger build after buildx GHA cache BlobNotFound Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --------- Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: Danathar <6772335+Danathar@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> (cherry picked from commit 8c35975) Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> * 📖 docs: explain Claude setup-token operator flow (#17841) * 📖 docs: explain Claude setup-token operator flow Hive-Run: #17761 Hive-Plan: 17753 item 8 documentation Hive-Spec: 17753#docs Signed-off-by: Karibhou <Karibhou@users.noreply.github.com> * chore: correct PR closing reference Remove the unrelated closing reference from the PR description; this signed follow-up requests a fresh review. Signed-off-by: Karibhou <Karibhou@users.noreply.github.com> --------- Signed-off-by: Karibhou <Karibhou@users.noreply.github.com> Co-authored-by: Karibhou <Karibhou@users.noreply.github.com> Co-authored-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com> (cherry picked from commit 7f27bba) Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> * 🐛 claude auth: suspend the credential re-bridge and durable-credential watchdog while HIVE_CLAUDE_OAUTH_TOKEN is set (#17858) With the operator's long-lived token set, Claude agents authenticate through CLAUDE_CODE_OAUTH_TOKEN and the shared ~/.claude/.credentials.json is not in use. The per-agent credential re-bridge (launch, watchdog poll, post-sign-in) and the watchdog's Claude probe now do nothing in that mode: no files moved, no claude_token_missing audit or warning, no broken-bridge flag in status. The suspension is logged once at startup; Copilot watching is unchanged, and with the token unset nothing changes. Fixes #17760 Signed-off-by: Andrew Anderson <andy@clubanderson.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: Andrew Anderson <andy@clubanderson.com> (cherry picked from commit 9903fea) Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> * 🐛 fix(claude): adapt long-lived token port to v5 v5 has no HeadlessCredentialEnv, no /api/logs read API and no CredentialBridgeBroken status field, so those parts of the v6 commits have nothing to attach to here: the headless and log-scrub hunks were dropped during the #17762 cherry-pick, and the manager-level status override (snapshotAgent) from #17858 is removed. The operator-token-mode tests now build on v5's bridgeTestFixture/simulateClaudeRefresh helpers. Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: clubanderson <407614+clubanderson@users.noreply.github.com> --------- Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Signed-off-by: Karibhou <Karibhou@users.noreply.github.com> Signed-off-by: Andrew Anderson <andy@clubanderson.com> Co-authored-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: Danathar <6772335+Danathar@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Karibhou <157208370+Karibhou@users.noreply.github.com> Co-authored-by: Karibhou <Karibhou@users.noreply.github.com> Co-authored-by: Andrew Anderson <andy@clubanderson.com> Co-authored-by: clubanderson <407614+clubanderson@users.noreply.github.com>
…ved token (HIVE_CLAUDE_OAUTH_TOKEN) (#17890) * ✨ claude auth: run Claude agents on an operator-supplied long-lived token (HIVE_CLAUDE_OAUTH_TOKEN) (#17762) * ✨ claude auth: inject operator-supplied long-lived token via HIVE_CLAUDE_OAUTH_TOKEN Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: Danathar <6772335+Danathar@users.noreply.github.com> * 🐛 claude auth: honor HIVE_CLAUDE_OAUTH_TOKEN in headless launches; resync api-reference citations HeadlessCredentialEnv now applies the same precedence as agentEnvPairs: the operator-supplied long-lived token wins over the short-lived credentials snapshot, so hub-launched claude CLIs no longer pin to a token that cannot refresh. Adds a unit test for the new path. api-reference.md citations for GET /api/logs/sources and /api/logs/read resynced via check-api-reference-citations.sh --fix after the import added in api_logs.go shifted the registrations by one line. 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> * 🔒 claude auth: strip HIVE_CLAUDE_OAUTH_TOKEN from every agent pane's inherited env The hive process holds HIVE_CLAUDE_OAUTH_TOKEN in its own environment, and each tmux server it starts inherits that into its GLOBAL environment, which tmux copies into every pane it forks. applySessionEnv never removed it, so copilot/codex/bob agent shells (and every tool shell they spawn) could read the year-long token under its original name — contradicting the claim that the token never appears in a pane. The claude backend was unaffected in practice only because it also receives the value as CLAUDE_CODE_OAUTH_TOKEN. Add claude.OperatorTokenEnvVar to inheritedCredentialEnvVars so the creation-time strip records a `set-environment -r` removal for it, hiding the global value from every process forked afterwards. The file form (HIVE_CLAUDE_OAUTH_TOKEN_FILE) carries only a path and is unaffected. The real-tmux leak test now plants the variable in the server env and asserts a fresh pane no longer sees it; a tmux-free unit test pins the entry in inheritedCredentialEnvVars. Hive-Fix-Attempt: 2/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> * 🌱 chore: retrigger build after buildx GHA cache BlobNotFound Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --------- Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: Danathar <6772335+Danathar@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> (cherry picked from commit 8c35975) Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> * 📖 docs: explain Claude setup-token operator flow (#17841) * 📖 docs: explain Claude setup-token operator flow Hive-Run: #17761 Hive-Plan: 17753 item 8 documentation Hive-Spec: 17753#docs Signed-off-by: Karibhou <Karibhou@users.noreply.github.com> * chore: correct PR closing reference Remove the unrelated closing reference from the PR description; this signed follow-up requests a fresh review. Signed-off-by: Karibhou <Karibhou@users.noreply.github.com> --------- Signed-off-by: Karibhou <Karibhou@users.noreply.github.com> Co-authored-by: Karibhou <Karibhou@users.noreply.github.com> Co-authored-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com> (cherry picked from commit 7f27bba) Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> * 🐛 claude auth: suspend the credential re-bridge and durable-credential watchdog while HIVE_CLAUDE_OAUTH_TOKEN is set (#17858) With the operator's long-lived token set, Claude agents authenticate through CLAUDE_CODE_OAUTH_TOKEN and the shared ~/.claude/.credentials.json is not in use. The per-agent credential re-bridge (launch, watchdog poll, post-sign-in) and the watchdog's Claude probe now do nothing in that mode: no files moved, no claude_token_missing audit or warning, no broken-bridge flag in status. The suspension is logged once at startup; Copilot watching is unchanged, and with the token unset nothing changes. Fixes #17760 Signed-off-by: Andrew Anderson <andy@clubanderson.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: Andrew Anderson <andy@clubanderson.com> (cherry picked from commit 9903fea) Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> * 🐛 fix(claude): adapt long-lived token port to v5 v5 has no HeadlessCredentialEnv, no /api/logs read API and no CredentialBridgeBroken status field, so those parts of the v6 commits have nothing to attach to here: the headless and log-scrub hunks were dropped during the #17762 cherry-pick, and the manager-level status override (snapshotAgent) from #17858 is removed. The operator-token-mode tests now build on v5's bridgeTestFixture/simulateClaudeRefresh helpers. Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: clubanderson <407614+clubanderson@users.noreply.github.com> --------- Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Signed-off-by: Karibhou <Karibhou@users.noreply.github.com> Signed-off-by: Andrew Anderson <andy@clubanderson.com> Co-authored-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: Danathar <6772335+Danathar@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Karibhou <157208370+Karibhou@users.noreply.github.com> Co-authored-by: Karibhou <Karibhou@users.noreply.github.com> Co-authored-by: Andrew Anderson <andy@clubanderson.com> Co-authored-by: clubanderson <407614+clubanderson@users.noreply.github.com>
Why
On a hive where each agent runs as its own user, the dashboard sign-in hands every Claude agent an 8-hour access token plus a refresh grant that rotates. A refresh in one agent's
~/.claudereplaces the shared link and kills the grant for everyone else, so the fleet logs itself out roughly every 8 hours. Claude Code has a token built for this case:claude setup-tokenmakes a one-year, inference-only token used throughCLAUDE_CODE_OAUTH_TOKEN, and it never refreshes. The hive had no way to accept one. It only injectedCLAUDE_CODE_OAUTH_TOKENas a last resort, using the short-lived snapshot, when no credentials file was readable.This PR lets the operator hand the hive that token. When it is set, it is the one credential every
claudeagent runs on, whether or not a credentials file exists, so nothing is left to refresh. A later dashboard sign-in only updates the short-lived snapshot and cannot switch agents back to the 8-hour login.Notes
HIVE_CLAUDE_OAUTH_TOKENunset (and no secret file), behaviour is exactly as before. The existingclaude_oauth_env_test.gocases are unchanged.set-environment) as today's fallback. It never appears on a command line or in a pane.DASHBOARD_AUTH_TOKEN_FILE, default/secrets/dashboard-token). The env var wins, then the file named byHIVE_CLAUDE_OAUTH_TOKEN_FILE, then the mounted/secrets/claude-oauth-token.TOKEN, so the existing secret-env scan already covers it. The value is also added tologSecretSources, so log reads through the API and the admin MCPlog_readredact it even when it comes from a file outside the secret roots.sk-ant-…shapes are already masked bylogscrubin the hive log and by the pane redactor. Nothing new is logged, audited or returned.claude setup-tokentoken. The hive does not have one, so they remain tracked on ✨ [v6] claude auth: run Claude agents on an operator-supplied long-lived token (claude setup-token) so nothing refreshes #17753. That is safe because the change is opt-in.env-vars.md,agent-configuration.md) are not touched here. They belong to [scanner] [v6] claude auth: document the operator setup-token flow (env-vars, agent-configuration, backend auth recovery runbook) #17761 and are also being edited by open 🐛 [v6] claude auth: opt-in switch to keep one shared ~/.claude so a token refresh reaches every agent #17752.Closes #17758
Part of #17753 (children #17759, #17760, #17761 remain for status/401, bridge+watchdog stand-down, docs)
— hive: agent=scanner backend=copilot