Skip to content

feat(credentials): load no personal GitHub token off arich-mac - #151

Merged
smartwatermelon-agent[bot] merged 3 commits into
mainfrom
claude/feat-app-only-github-a895f791
Nov 10, 2026
Merged

smartwatermelon-agent[bot] merged 3 commits into
mainfrom
claude/feat-app-only-github-a895f791

Conversation

@smartwatermelon-agent

Copy link
Copy Markdown
Contributor

Layer 3 of the app-only GitHub rule: on any host other than arich-mac, the wrapper loads no personal GitHub token and removes inherited ones. arich-mac is unchanged.

One departure from the brief

The brief said to unset GH_TOKEN. This PR sets it to the existing fetch-failed sentinel instead. The other four vars are unset.

Why: with GH_TOKEN unset and no GH_TOKEN_* set, the dotfiles gh wrapper falls back to the keyring login, which is Andrew. _gh_wrapper_scoped_fallback returns early (gh-wrapper.sh:467), and the keyring read at 671-688 runs. So a plain unset would make the wrapper's own twistedmelonman, no-owner and third-party calls act as Andrew today, before layer 1 lands.

With the sentinel, those calls fail closed. The identity probe fails and the wrapper refuses, or gh fails auth. App-routed calls do not change: that branch returns before the env-token check, and the minted App token replaces GH_TOKEN for the call.

What changed

  • lib/credentials.sh: reads hostname -s once. Only an exact arich-mac match, in any case, allows personal tokens. Anywhere else it skips _load_gh_token and _load_owner_gh_tokens. creds_enforce_app_only_gh then unsets GH_TOKEN_NOS, GH_TOKEN_TWM, GH_TOKEN_SWM, GITHUB_TOKEN and CLAUDE_WRAPPER_VAULT_VARS, and exports the sentinel as GH_TOKEN.
  • If hostname is missing or fails, the host counts as personal.
  • There is no env-var override. Tests put a hostname stub on PATH, the same way they stub op and security.
  • bin/claude-wrapper calls creds_enforce_app_only_gh again just before exec. inject_secrets and the pre-launch hook run after credentials.sh, and a global ~/.config/claude-code/secrets.op on a personal Mac sets GH_TOKEN to the CCCLI PAT. Without the second call, that token would reach the session.
  • Docs: CLAUDE.md, docs/SECRETS.md and README.md now describe the arich-mac-only rule. A CLAUDE.md line that said the global secrets.op no longer exists is corrected.

Accepted consequences

  • twistedmelonman has no App. On personal Macs, agents lose all twistedmelonman GitHub access, reads included, until an App exists.
  • Owner-less calls (gh api user, gh search without an owner) and gh reads of third-party repos also stop for agents on personal Macs.
  • A Mac that cannot mint an App token loses that owner. It fails closed and never falls back.
  • On a personal Mac today, smartwatermelon and nightowlstudiollc go through their Apps (gh-app-routes.conf). Everything else is refused.

Not covered: SSH-key git fetch, git pull and git clone. These use no PAT and no OAuth login. A git push over SSH acts as Andrew, so layer 1 covers it.

Notes for the other layers

  • OP_SERVICE_ACCOUNT_TOKEN is still exported on personal Macs, because secrets-loader needs it. The Automation vault holds both PATs. An agent could op read them from inside the session, so layer 2 needs to deny that read.
  • The gh wrapper's refusal text tells the caller to "unset GH_TOKEN to use the keyring identity". For agents, that advice is now wrong. Also, every call that is not App-routed now pays for a failing gh api user round-trip first.

Also in this PR

  • tests/test-wrapper.sh now unsets CLAUDE_WRAPPER_VAULT_VARS, as test-credentials.sh does. Test 3.6 failed on main when run from inside a wrapper session.
  • Fixed ten existing SC2312 infos in tests/test-credentials.sh.

Tests

  • tests/test-credentials.sh: 49/49. The new host-gate section covers:
    • A personal host with all five vars inherited: none are kept, GH_TOKEN is the sentinel, children are clean, and no vault read happens.
    • A personal host with nothing inherited.
    • No warning on a personal host.
    • arich-mac2 and a missing hostname are both treated as personal.
    • ARICH-MAC and arich-mac are unchanged, and presets are kept.
    • The pre-exec strip on both kinds of host.
    • Five of these failed on the old code.
  • tests/test-wrapper.sh: 73/73. Test 4.3 launches the wrapper as a personal host with fake inherited tokens and checks that only the sentinel GH_TOKEN reaches the process. Test 4.6 checks that the strip comes after secrets load and before exec, and it fails on main.
  • shellcheck -S info is clean on all four changed scripts.
  • Only scoped suites ran locally. CI runs the rest.

Claude Code Bot added 3 commits November 9, 2026 19:38
Andrew's rule (2026-11-09): no GitHub operation by an agent may act as
a person. This is layer 3 of three: on any host other than arich-mac
(hostname -s, any case, exact match), the wrapper loads no GH_TOKEN,
GH_TOKEN_NOS or GH_TOKEN_TWM, and removes those, GH_TOKEN_SWM and
GITHUB_TOKEN if inherited. arich-mac is unchanged.

GH_TOKEN is set to the existing fetch-failed sentinel rather than
unset. With GH_TOKEN unset, gh and the dotfiles gh wrapper fall back to
the keyring login (Andrew, admin:org) for any repo that is not
App-routed. App-routed calls still work: the gh wrapper replaces
GH_TOKEN with the minted App token for that call.

The strip runs again in bin/claude-wrapper just before exec, because
inject_secrets and the pre-launch hook run after credentials.sh, and a
global secrets.op on a personal Mac can set GH_TOKEN.

hostname is resolved on PATH so tests stub it like op and security.
There is no env-var override. A missing hostname counts as personal.

Also: test-wrapper.sh now unsets CLAUDE_WRAPPER_VAULT_VARS, as
test-credentials.sh does. Test 3.6 failed on main when run from inside
a wrapper session. And the ten SC2312 infos in test-credentials.sh are
fixed.
Test 4.3's personal-host launch check is skipped when the wrapper cannot
run. Test 4.6 reads bin/claude-wrapper and fails unless
creds_enforce_app_only_gh comes after inject_secrets and the pre-launch
hook and before the first exec. It fails on main, where the call does
not exist.
The token-strip edit dropped it by accident on the secrets-loaded branch.
Found by the pre-push full-diff review.
@smartwatermelon-agent
smartwatermelon-agent Bot merged commit 3d60689 into main Nov 10, 2026
5 checks passed
@smartwatermelon-agent
smartwatermelon-agent Bot deleted the claude/feat-app-only-github-a895f791 branch November 10, 2026 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant