Repository navigation
✨ [v5] claude auth: run Claude agents on an operator-supplied long-lived token (HIVE_CLAUDE_OAUTH_TOKEN) - #17890
Conversation
…oken (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 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>
…l 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>
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>
|
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: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
Mutation testing❌ 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.
Decision needed: @clubanderson should confirm that v5 hives may run every claude-backend agent on a single operator-supplied year-long claude setup-token credential (HIVE_CLAUDE_OAUTH_TOKEN), as v6 already does.
Read the port against the v5 tree (merge-base 835c1cd). The code is a faithful cherry-pick of the merged v6 commits and the v5 adaptations are consistent; I'm routing rather than confirming only because this introduces a new credential-delivery path, which is a trust decision for an approver, not a code question.
What I verified:
crux/claude/operator_token.go:27-40— env var wins over_FILEover/secrets/claude-oauth-token; read-only, never logged.crux/agent/manager.go:893reads it once at construction; the only other writer of a Claude token ismanager_tokens.go:30, which setsclaudeAuthToken, so a later dashboard sign-in cannot override the operator token. The body's "a dashboard sign-in never replaces it" holds.manager_env.go:431-435— the operator token is injected asCLAUDE_CODE_OAUTH_TOKENwithSecret: true(agentEnvPair,manager_env.go:157-162: set viatmux set-environment, never on a command line), gated onbackend == "claude", and takes the branch ahead of the short-lived dashboard token.manager_tmux.go:61addsHIVE_CLAUDE_OAUTH_TOKENtoinheritedCredentialEnvVars;applySessionEnv(manager_tmux.go:133-135) runsset-environment -rfor every entry before the per-agent pairs are set, so non-claude panes do not inherit the raw variable. (HIVE_CLAUDE_OAUTH_TOKEN_FILEis a path, not a secret, and is correctly not stripped.)claude_credential_bridge.go:528/:608andcredentials_watchdog.go:263short-circuit the re-bridge and the Claude durable-credential probe in operator-token mode; Copilot's watch is unaffected because the extra condition isw.backend == "claude"only.- The dropped hunks the body lists (
HeadlessCredentialEnv,logSecretSources,CredentialBridgeBroken) genuinely have no counterpart on v5 — none of those symbols exist in the v5 tree.
No defects found. The one operational fact an approver should weigh: with the token set, the Claude durable-credential watchdog is silent by design, so a rejected/expired operator token on v5 surfaces only as agent-side 401s until the v6 follow-up (#17861, "token rejected" reporting) is also ported.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Needs a decision, not a merge:
Head: verdict requires_human @4c3fa95, 70/70 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: yes — v5 hives may run claude-backend agents on an operator-supplied claude setup-token credential via HIVE_CLAUDE_OAUTH_TOKEN, matching v6 (#17762/#17841/#17858). This is the port I asked for.
Verified head 4c3fa95: diffed the ported files against origin/v6 — the only deltas are the #17861 additions (ClaudeLongLivedToken, snapshotAgent, AuthMode/TokenRejectedMessage), which landed on v6 after this PR opened and are correctly listed as not-yet-ported. The three re-bridge entry points on v5 after #17767 (interactive_home launch, watchdog, manager_tokens sign-in) all funnel through rebridgeClaudeCredential/RepairClaudeCredentialBridges, which are short-circuited in operator-token mode, so no overlap with the shared-credential work. Token is injected only as a Secret env pair, stripped from inherited pane env (test extended), and the once-per-process log names the variable, not the value. Fragments present and correctly named.
Follow-up: port #17861 to v5 once ready so a rejected token is surfaced rather than silent.
/lgtm
/approve
|
/lgtm |
|
LGTM label has been added. DetailsGit tree hash: 2d73d2bf966c0cefc22d4f69a5d559af6bb76b89 |
|
[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 |
|
LGTM label has been added. DetailsGit tree hash: 2d73d2bf966c0cefc22d4f69a5d559af6bb76b89 |
|
[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 |
…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>
Closes #17852
Why
v5 hives hit the same production problem as v6: on per-UID hives every Claude agent runs on the 8-hour dashboard sign-in, so the fleet logs out every ~8 hours. v6 fixed it by letting the operator supply a long-lived
claude setup-tokentoken (HIVE_CLAUDE_OAUTH_TOKEN). This PR forward-ports that family to v5. Before this PR, v5 had noHIVE_CLAUDE_OAUTH_TOKENreference.Ported v6 commits (cherry-picked with
-x, original authors kept)8c35975f— ✨ claude auth: run Claude agents on an operator-supplied long-lived token (HIVE_CLAUDE_OAUTH_TOKEN) #17762 (issue [scanner] [v6] claude auth: accept HIVE_CLAUDE_OAUTH_TOKEN and inject it as CLAUDE_CODE_OAUTH_TOKEN for every claude agent #17758): token intake (crux/claude/operator_token.go: env var,_FILEform,/secrets/claude-oauth-token), injection as secretCLAUDE_CODE_OAUTH_TOKENahead of the dashboard sign-in, and removal ofHIVE_CLAUDE_OAUTH_TOKENfrom every pane's inherited tmux env.7f27bbaa— 📖 docs: explain Claude setup-token operator flow #17841 (issue [scanner] [v6] claude auth: document the operator setup-token flow (env-vars, agent-configuration, backend auth recovery runbook) #17761): operator docs (agent-configuration, auth-recovery runbook, env-vars).9903fea7— 🐛 [v6] claude auth: suspend the credential re-bridge and durable-credential watchdog while HIVE_CLAUDE_OAUTH_TOKEN is set #17858 (issue [scanner] [v6] claude auth: skip the credential re-bridge and durable-credential watchdog while HIVE_CLAUDE_OAUTH_TOKEN is set #17760; it replaced the closed 🐛 [v6] claude auth: suspend the credential re-bridge and durable-credential watchdog while HIVE_CLAUDE_OAUTH_TOKEN is set #17851): suspends the credential re-bridge (launch, watchdog, sign-in) and the watchdog's Claude probe while the token is set. Logs this once. Copilot watching is unchanged.These are applied in the order they merged on v6. Changelog fragments
changelog.d/added-claude-long-lived-token.mdandchangelog.d/changed-claude-operator-token-suspends-rebridge.mdcame with the commits.What I changed for v5 (
🐛 fix(claude): adapt long-lived token port to v5plus conflict resolution)v5 and v6 have diverged, so some v6 code has nothing to attach to on v5:
HeadlessCredentialEnv(crux/agent/headless_credentials.go) is not on v5. I dropped that hunk and its test. v5 has no headless launch path that would need the token./api/logsread API /logSecretSources(pkg/dashboard/api_logs.go) is not on v5. I dropped the read-time scrub hunk, its test and the matchingapi-reference.mdcitation change. I kept v5's side of that conflict.CredentialBridgeBrokenstatus field (from v6 🐛 [v6] claude auth: opt-in switch to keep one shared ~/.claude so a token refresh reaches every agent #17752) is not on v5. I removed thesnapshotAgentstatus override and themanager_status.gocall-site changes. I also removed the matching claim from the changelog fragment.brokenBridgeFixture,fakeClaudeCredential). They now use v5'sbridgeTestFixture,simulateClaudeRefreshandbridgeTestCreds. The suspended and unset scenarios are still covered. The status assertions were dropped because v5 has no status field.The other tests from the v6 commits came across unchanged:
claude_operator_token_test.go,crux/claude/operator_token_test.goand the extended tmux inherited-env test.Not ported
The #17759 status/401 surfacing is still open on v6 as #17861. It will be ported when it lands.
— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 requested_by=@clubanderson