Skip to content

πŸ› [v6] claude auth: suspend the credential re-bridge and durable-credential watchdog while HIVE_CLAUDE_OAUTH_TOKEN is set - #17858

Merged
hivecommons-hive[bot] merged 1 commit into
v6from
scanner/fix-17760
Nov 12, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
v6from
scanner/fix-17760

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Closes #17760
Part of #17753 (child 2 of 4)
Supersedes #17851

#17851 was auto-closed (not rejected) when its stacked base branch scanner/fix-17758 was deleted on #17762's merge; this PR carries the same commit, original author preserved, rebased onto v6 over #17807.

Why

With HIVE_CLAUDE_OAUTH_TOKEN set, Claude agents authenticate with the operator's long-lived claude setup-token token, which is never refreshed. The shared ~/.claude/.credentials.json is not what the fleet uses in that mode, so the refresh machinery built around it has nothing to do: re-bridging per-agent credential files would move files for no reason, and the durable-credential watchdog's Claude alerts (claude_token_missing, "durable credential unusable", the broken-bridge flag on the dashboard) would send operators to redo a sign-in the fleet does not depend on. Both are suspended for Claude while the token is set (logged once at startup); Copilot watching is unaffected, and with the token unset behaviour is exactly as before.

Tests in claude_operator_token_mode_test.go cover both paths: token set β†’ re-bridge/watchdog Claude probe are no-ops, and token unset β†’ behaviour unchanged.

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

…l watchdog while HIVE_CLAUDE_OAUTH_TOKEN is set

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>
@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 danathar 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
@github-actions

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 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 head 109a9fe)

The code and changelog match #17760 (re-bridge and Claude watchdog probe suspended while the token is set; claude.OperatorToken() honours env and file, so the fragment's "(or its secret file)" is accurate). No src/docs citation drift; CI docs guards pass.

Advisory, non-blocking (operator docs now describe behaviour this PR deliberately turns off in token mode):

  • src/docs/agent-watchdog.md:132 β€” "Hive repairs this on its own: at the agent's next launch, on the next credential-watchdog tick, and right after the next dashboard sign-in." With HIVE_CLAUDE_OAUTH_TOKEN set, rebridgeClaudeCredential and RepairClaudeCredentialBridges return early (src/crux/agent/claude_credential_bridge.go:547-550, 627-630) and the card no longer shows the broken bridge (claude_operator_token_mode.go:47-53), so an operator following this page would wait for a repair that never comes. Same statement at src/docs/agent-configuration.md:718-722, 734 and src/docs/troubleshooting.md:307, src/docs/dashboard-sections/workflow-and-agents.md:370.
  • src/docs/agent-configuration.md:160-185 (Claude setup-token) says nothing about the re-bridge/watchdog suspension or the one-time startup log line; one sentence there would cover it.
  • src/docs/env-vars.md:317-318 β€” HIVE_CREDENTIAL_WATCHDOG_INTERVAL / HIVE_CLAUDE_CREDENTIAL_BRIDGE_INTERVAL descriptions don't note that Claude is excluded in operator-token mode.

#17760 asked for tests + a changelog fragment only (parent #17753 item 8 routes docs to the intake child), so this is backlog, not a blocker here.

Evidence bundle `#17858109a9fe` sha256:d6f3be5f0fedfb7730ff844e7a23922531c18f4ac40d1057393dca2c2c2d5ebe β€” download from the dashboard or `hivectl review evidence #17858`.

@github-actions

Copy link
Copy Markdown
Contributor

Mutation testing

Head 109a9fe98.

❌ 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 the v6 tree at 109a9fe, not just the diff. This looks correct to me.

What I verified:

  • All three re-bridge entry points are covered by one gate. rebridgeClaudeCredential (src/crux/agent/claude_credential_bridge.go:543-549) is the shared entry for launch (interactive_home.go:436,451), the watchdog loop (claude_credential_bridge.go:653 via RepairClaudeCredentialBridges, itself gated at :627) and the sign-in hook; returning nil is already the legacy-layout path, so callers need no change.
  • The watchdog probe gate resets the tracker. evalCredentialWatch (credentials_watchdog.go:270) treats operator mode like "backend not in use" and still delete(lastUnusable, w.backend), so unsetting the token later alerts on the first bad tick rather than being masked. Copilot's watch is untouched.
  • No status path leaks the masked flag. The only remaining a.snapshot() call in non-test code is inside snapshotAgent (claude_operator_token_mode.go:48); GetStatusFast, GetStatus and AllStatuses all go through it, and dashboard/status_builder.go:1424 reads proc.CredentialBridgeBroken from those, so the dashboard repair prompt is suppressed consistently.
  • Mode is fixed per process. claudeOperatorToken is written only at construction (manager.go:925 ← claude.OperatorToken()) and read at manager_env.go:473; nothing assigns it later, so the sync.Once log and the gate cannot disagree mid-run.

Minor, not a finding: StartCredentialWatchdog emits the one-time "suspended" log even on a hive with the token set but no claude agents configured (credentials_watchdog.go:235 runs before any backendInUse check). It is info-level and accurate about what is suspended, so I would leave it.

β€” hive: agent=reviewer-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 docs-currency β€” Operator docs still promise automatic Claude credential re-bridge, which operator-token mode now suspends (src/docs/agent-watchdog.md:132): src/docs/agent-watchdog.md:132 (and agent-configuration.md:718-722,734; troubleshooting.md:307; dashboard-sections/workflow-and-agents.md:370) state that Hive repairs a replaced .credentials.json lin…

@hivecommons-hive
hivecommons-hive Bot merged commit 9903fea into v6 Nov 12, 2026
84 of 91 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-17760 branch November 12, 2026 06:34
@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

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. 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: skip the credential re-bridge and durable-credential watchdog while HIVE_CLAUDE_OAUTH_TOKEN is set

1 participant