Skip to content

✨ claude auth: run Claude agents on an operator-supplied long-lived token (HIVE_CLAUDE_OAUTH_TOKEN) - #17762

Merged
kubestellar-prow[bot] merged 6 commits into
v6from
scanner/fix-17758
Nov 12, 2026
Merged

kubestellar-prow[bot] merged 6 commits into
v6from
scanner/fix-17758

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

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 ~/.claude replaces 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-token makes a one-year, inference-only token used through CLAUDE_CODE_OAUTH_TOKEN, and it never refreshes. The hive had no way to accept one. It only injected CLAUDE_CODE_OAUTH_TOKEN as 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 claude agent 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

Closes #17758
Part of #17753 (children #17759, #17760, #17761 remain for status/401, bridge+watchdog stand-down, docs)

— hive: agent=scanner backend=copilot

@kubestellar-prow kubestellar-prow Bot added dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 11, 2026
@hivecommons-hive

hivecommons-hive Bot commented Nov 11, 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: 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: 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 (folded here because this head already carries its hive review):

Correctness review (head f480eb2, read against the tree, no local checkout available)

1. HIVE_CLAUDE_OAUTH_TOKEN set as an env var leaks into every agent's pane, on every backend — src/crux/agent/manager_tmux.go:52-59, :94-114

The tmux server is spawned with the hive process's full environment (tmuxCmd → exec.Command with nil Env, manager_tmux.go:236-238; the su-exec path at :270-272 preserves it too), so every variable the hive holds lands in the tmux global environment and is copied into each pane and every tool shell the CLI forks. The codebase already strips the hive's own credentials for exactly this reason via inheritedCredentialEnvVars (manager_tmux.go:52-59, applied with set-environment -r at :95-97). This PR introduces a new hive-held credential, HIVE_CLAUDE_OAUTH_TOKEN (src/crux/claude/operator_token.go:12), but does not add it to that list — so with the env-var intake form the changelog advertises, a copilot/codex/bob agent (and every claude agent, under the raw name) can read the one-year inference token with echo $HIVE_CLAUDE_OAUTH_TOKEN.

The issue (#17758) requires "never written to a pane", and TestClaudeOperatorToken_FileFormAndOtherBackends (src/crux/agent/claude_operator_token_test.go:116-128) asserts a copilot agent must not receive it — but that test only inspects agentEnvPairs, not the inherited global env, so it passes while the leak exists.

Fix: add claude.OperatorTokenEnvVar to inheritedCredentialEnvVars (manager_tmux.go:52). Claude agents still receive the token under CLAUDE_CODE_OAUTH_TOKEN from agentEnvPairs (manager_env.go:473-474), which is set after the removal, so nothing else changes. The file form (/secrets/claude-oauth-token, HIVE_CLAUDE_OAUTH_TOKEN_FILE) is unaffected.

Everything else I checked holds: precedence over claudeAuthToken/ReloadClaudeToken (manager_env.go:473-477), empty OperatorToken() is dropped by NewSecretScrubber's MinSecretValueLen filter (src/crux/logread/secrets.go:35), unset path unchanged.

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

Intent alignment (vs #17758), read at head f480eb2.

The diff does what the issue asks: claude.OperatorToken() (src/crux/claude/operator_token.go:27-40, env → HIVE_CLAUDE_OAUTH_TOKEN_FILE → /secrets/claude-oauth-token) is read once into Manager.claudeOperatorToken (src/crux/agent/manager.go:612,919) and, when set, wins unconditionally for claude agents as a secret pair (src/crux/agent/manager_env.go:473-477); the unset branch is the pre-existing fallback unchanged, and logSecretSources now includes the value (src/pkg/dashboard/api_logs.go:102). Tests cover the three env-pair cases and redaction across API + admin MCP. No scope creep.

One in-scope fix needed:

  1. CI relative links and anchors resolve fails because of this PR. The added crux/claude import in src/pkg/dashboard/api_logs.go:9 shifts registerLogReadRoutes so the handlers are now at api_logs.go:20-21, but src/docs/api-reference.md:639-640 still cites pkg/dashboard/api_logs.go:19 / :20. check-api-reference-citations.sh reports 2 drifted citations. Fix: run bash src/scripts/check-api-reference-citations.sh --fix and commit the two rewritten citations (this is a mechanical line-reference update, not the [scanner] [v6] claude auth: document the operator setup-token flow (env-vars, agent-configuration, backend auth recovery runbook) #17761 docs work).

Out of scope, for backlog: the hive-side ioscan classifier (src/pkg/ioscan/cli_client.go:141,243-246) still only passes the hive process's own CLAUDE_CODE_OAUTH_TOKEN through to its claude CLI; HIVE_CLAUDE_OAUTH_TOKEN is not mapped there. The issue scopes this PR to agents, so not blocking.

Not verified here (as #17758/#17753 already note): that Claude Code prefers CLAUDE_CODE_OAUTH_TOKEN over a readable ~/.claude/.credentials.json; that needs an operator-held setup-token.

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

Read the diff against v6 and the surrounding code. I found no defect; this is a credential-path change, so I am routing it rather than calling it fine.

What I verified:

  • src/crux/agent/manager_env.go:473-477 — the operator token is injected as a secret pair (true) and takes precedence over the dashboard snapshot; with it unset the else if is byte-for-byte the old condition, so the opt-in claim holds.
  • src/crux/agent/manager_tmux.go:60-62 — HIVE_CLAUDE_OAUTH_TOKEN is added to inheritedCredentialEnvVars, so the hive process's copy is stripped from the tmux server global env and only reaches claude panes under the CLAUDE_CODE_OAUTH_TOKEN name. The sandbox/kubejob launchers already refuse it via isCredentialName (src/crux/sandbox/sandbox.go:191-194, matches any name containing TOKEN).
  • src/crux/agent/headless_credentials.go:41-43 — same precedence for the headless path; claude was already imported there.
  • src/pkg/dashboard/api_logs.go:102 — the value is added to logSecretSources, so a file-sourced token is redacted at read time even outside the secret roots.
  • src/crux/claude/operator_token.go:27-40 — env wins, then HIVE_CLAUDE_OAUTH_TOKEN_FILE, then /secrets/claude-oauth-token; read failures return "" (no raise). Mirrors the dashboard-token convention as the body says.
  • src/crux/agent/manager_tokens.go:32 (ReloadClaudeToken) only touches claudeAuthToken, so a later dashboard sign-in cannot displace the operator token — matches the body.

What a human should weigh (not defects):

  1. The body states the parent's measurements "need an operator-held claude setup-token token. The hive does not have one" — so the end-to-end behaviour (Claude Code honouring CLAUDE_CODE_OAUTH_TOKEN over a reachable ~/.claude credentials file, concurrent fleet use) is untested here and tracked on ✨ [v6] claude auth: run Claude agents on an operator-supplied long-lived token (claude setup-token) so nothing refreshes #17753.
  2. Blast radius: today's fallback hands panes an 8-hour token; this hands every claude pane a one-year inference token readable by anything the agent runs (echo $CLAUDE_CODE_OAUTH_TOKEN). The body's "never appears ... in a pane" is about the command line; the value is still in the pane's environment by design. Whether that trade is acceptable for the fleet-logout problem is the decision.

Per #17758 this is the scoped child; docs are deliberately deferred to #17761.

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

Read against the v6 tree, not just the diff. The env plumbing holds up and I found no defect.

Verified

  • src/crux/agent/manager_env.go:471-475: the operator token is appended as a secret agentEnvPair only when backend == "claude", ahead of the existing last-resort branch, so a later ReloadClaudeToken (which only touches claudeAuthToken, manager_tokens.go:26-29) cannot displace it. Matches the precedence [scanner] [v6] claude auth: accept HIVE_CLAUDE_OAUTH_TOKEN and inject it as CLAUDE_CODE_OAUTH_TOKEN for every claude agent #17758 asks for.
  • src/crux/agent/manager_tmux.go:61 adds HIVE_CLAUDE_OAUTH_TOKEN to inheritedCredentialEnvVars; applySessionEnv (manager_tmux.go:125-127) runs set-environment -r for every entry before the per-agent pairs are set, so copilot/codex/bob panes never see the raw variable and claude panes see it only under CLAUDE_CODE_OAUTH_TOKEN.
  • The other launch paths don't leak it either: spek_hub_executor.go:1754-1757 builds env from allowedSpekHubExecutorEnv (allowlist) plus HeadlessCredentialEnv, and the su-exec caveman install uses agentSubprocessEnv (manager_launch_caveman.go:63-64). pkg/dashboard/api_logs.go:102 adds the value to logSecretSources, so a file-sourced token is redacted on /api/logs/read too.
  • claude/operator_token.go — env wins, then HIVE_CLAUDE_OAUTH_TOKEN_FILE, then /secrets/claude-oauth-token; same shape as DASHBOARD_AUTH_TOKEN_FILE. Opt-in: with none set, OperatorToken() returns "" and agentEnvPairs takes the pre-existing branch unchanged.

One docs note (not blocking)
src/docs/env-vars.md:392 still describes CLAUDE_CODE_OAUTH_TOKEN as "never injected when the agent can read ~/.claude/.credentials.json", which stops being true on v6 once this merges. The body defers docs to #17761 — fine, but that row is now inaccurate on the base branch until #17761 lands, so it is worth landing soon after.

Open question, not a finding
The body says the hive has not been able to confirm Claude Code prefers CLAUDE_CODE_OAUTH_TOKEN over an existing readable .credentials.json in the same session (tracked on #17753). Since the token is injected alongside a still-bridged credentials file, that is the one behaviour the whole change depends on; an operator with a setup-token should confirm it before relying on this.

Looks correct to me. CI is green apart from tide.

stage 080-awaiting-merge-admission → 070-fixing: check-failure

@github-actions

github-actions Bot commented Nov 11, 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 11, 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.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Review follow-ups (below review.backlog.min_severity: P2)

Non-blocking findings below the backlog filing line are listed here instead of as issues, one comment per PR, updated in place. Tick them off as they are fixed; set review.backlog.min_severity: P3 to file every finding.

  • P3 low intent-alignment — ioscan CLI classifier does not pick up HIVE_CLAUDE_OAUTH_TOKEN (src/pkg/ioscan/cli_client.go:141): CLIChatClient.env() (src/pkg/ioscan/cli_client.go:241-249) builds the hive-side claude classifier's environment from an allowlist that passes through only the hive process's own CLAUDE_CODE_OAUTH_T…

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Mutation testing

Head 597ded2ad.

❌ 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 added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Nov 11, 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 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 existing claudeAuthToken && !claudeCredentialReachable(...) branch, so a reachable credentials file no longer suppresses injection when HIVE_CLAUDE_OAUTH_TOKEN is set, and the pair is still Secret: true (tmux set-environment only, manager_env.go:183-188). With the operator token empty the else if is byte-for-byte the old condition, so the opt-out path is unchanged.
  • src/crux/agent/manager.go:612,919 — claudeOperatorToken is written once in NewManagerWithOptions and never by ReloadClaudeToken (manager_tokens.go:28-35), which only rewrites claudeAuthToken. That is what makes "a later dashboard sign-in cannot switch agents back" true; TestClaudeOperatorToken_WinsOverALaterDashboardSignIn pins 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 a claude agent 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 in logSecretSources, so a token mounted outside the secret roots is still redacted on /api/logs/read and the admin MCP log_read; TestLogReadScrubsClaudeOperatorToken covers both the file and env forms.
  • api-reference.md citation shift is just the new import line in api_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

@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 11, 2026
@kubestellar-prow kubestellar-prow Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 11, 2026
hivecommons-hive Bot and others added 3 commits November 11, 2026 16:52
…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>
@kubestellar-prow kubestellar-prow Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 11, 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 11, 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.

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 — applySessionEnv runs set-environment -r for every inheritedCredentialEnvVars entry before setting agentEnvPairs, so adding HIVE_CLAUDE_OAUTH_TOKEN to that list hides the hive-process value from every pane and only claude-backend sessions get it back, renamed to CLAUDE_CODE_OAUTH_TOKEN. The ordering comment on manager_tmux.go:113-118 is exactly the guarantee this change relies on.
  • src/crux/agent/manager_tokens.go:25-30 — ReloadClaudeToken (the dashboard sign-in path) only rewrites m.claudeAuthToken in memory; there is no tmux push for Claude the way propagateCopilotToken does for Copilot. So the new if m.claudeOperatorToken != "" … else if m.claudeAuthToken != "" … ordering in manager_env.go is sufficient for "a later sign-in never switches agents back" — nothing else emits CLAUDE_CODE_OAUTH_TOKEN (the only other producers are headless_credentials.go, updated here with the same precedence, and pkg/ioscan/cli_client.go:141, which just lists the name).
  • src/crux/claude/operator_token.go is a leaf (os, strings), so the new import from pkg/dashboard/api_logs.go introduces no cycle.
  • credentials_watchdog.go:177,243 will 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

@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) 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 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 the claudeCredentialReachable fallback, so it is injected whether or not a credentials file is bridged; Secret: true keeps 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_TOKEN is set-environment -r'd before the per-agent pairs are set, so non-claude panes never see it under either name. TestClaudeOperatorToken_StrippedFromInheritedPaneEnv covers this.
  • src/crux/agent/manager_tokens.go:28-33 — ReloadClaudeToken only rewrites claudeAuthToken; claudeOperatorToken is set once in NewManagerWithOptions (manager.go:922), so a later dashboard sign-in cannot displace it, as the body claims and TestClaudeOperatorToken_WinsOverALaterDashboardSignIn checks.
  • src/pkg/dashboard/api_logs.go:102 — the value is added to the read-time scrub set; TestLogReadScrubsClaudeOperatorToken covers 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

@hivecommons-hive hivecommons-hive Bot added stage/085-needs-decision A human decision is owed: sentinel alert, hold/needs-decision label, human-only rule or parked issue and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 12, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Needs a decision, not a merge:

  • the reviewer swarm returned requires_human @597ded2
  • the review found: the reviewer marked this change high-risk
  • reviewer question: @clubanderson should decide whether hive may accept an operator-supplied one-year Claude token (HIVE_CLAUDE_OAUTH_TOKEN / /secrets/claude-oauth-token) and hand it as CLAUDE_CODE_OAUTH_TOKEN to every claude-backend pane, given the body says it has not yet been exercised against a real claude setup-token.
  • the automerge lane will not merge this unattended

Head: verdict requires_human @597ded2, 71/71 checks green, DCO yes, soak 0s of 10m0s.

What to do: approve this head (597ded2) to merge as-is, or leave a changes requested review (or reply /hive decision <what to change>) and the hive will push the fix.

How to release it:

  • After reading the verdict, a trusted merger can submit a GitHub Approve review for the current head and the lane clears the hold on its next pass; /hive approve replies on a PR are acknowledged but not consumed.

Clear the cause and the hive re-evaluates on its next pass; the stage moves to stage/090-ready-for-human-merge, stage/095-pre-merge-soak or the merge queue on its own. Approval does not bypass CI, hold labels or other merge gates.

@clubanderson clubanderson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

@kubestellar-prow kubestellar-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Nov 12, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: f35a1784732da0ef0ffb1c29d3877fffc740f71a

@kubestellar-prow

Copy link
Copy Markdown
Contributor

[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

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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 12, 2026
@hivecommons-hive hivecommons-hive Bot removed the stage/085-needs-decision A human decision is owed: sentinel alert, hold/needs-decision label, human-only rule or parked issue label Nov 12, 2026
@kubestellar-prow
kubestellar-prow Bot merged commit 8c35975 into v6 Nov 12, 2026
98 of 105 checks passed
@hivecommons-hive hivecommons-hive Bot added the stage/050-review-pending Review swarm requested; awaiting a verdict for the current head label Nov 12, 2026
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-17758 branch November 12, 2026 05:35
@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

clubanderson added a commit that referenced this pull request Nov 12, 2026
…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>
hivecommons-hive Bot added a commit that referenced this pull request Nov 13, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. 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. lgtm Indicates that a PR is ready to be merged. role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) size/L Denotes a PR that changes 100-499 lines, ignoring generated files. stage/050-review-pending Review swarm requested; awaiting a verdict for the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scanner] [v6] claude auth: accept HIVE_CLAUDE_OAUTH_TOKEN and inject it as CLAUDE_CODE_OAUTH_TOKEN for every claude agent

1 participant