Skip to content

feat(bin): ship the agent credential shims + lint ~/.local/bin - #14

Merged
natevick merged 3 commits into
mainfrom
norm/agent-credential-shims-v2
Aug 2, 2026
Merged

feat(bin): ship the agent credential shims + lint ~/.local/bin#14
natevick merged 3 commits into
mainfrom
norm/agent-credential-shims-v2

Conversation

@natevick

@natevick natevick commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Follow-up to #12, which shipped a gitconfig pointing at a credential helper this repo did not contain — so a rebuilt agent host got config with nothing behind it. This adds the three shims.

shim what it does
gh injects the per-org PAT. Owner from -R/--repo, GH_REPO, an gh api path, a positional owner/repo, or the cwd origin. No default-org fallback — a repo-less call runs unauthenticated rather than quietly carrying an org credential.
git refuses force-push and branch-delete, audits, notifies.
git-credential-github-org one PAT per org, keyed on the remote URL owner.

The git guard is an accident catcher, not a control. Anything running as the agent can call /usr/bin/git, use the API, or set NORM_ALLOW_FORCE=1 (itself audited and notified). It exists because the broker hard-deny on force-push does not reach the ambient PAT path. It fails open to real git by design — breaking every git call is worse than missing one force-push. Non-push subcommands are untouched, so clean -fd / checkout -f / tag -f / branch -d still work.

  • Gated in .chezmoiignore on .agent: gh and git shadow real binaries, so on a host with no ~/.config/github-pats they would break github.com auth outright. Both renderings verified with --override-data.
  • Audit log created 0600 before first write — the ambient umask would otherwise leave a world-readable record of every credentialed operation. The token value is never logged.
  • home/dot_local/bin/* now covered by the shellcheck job; those files shadow real binaries and were outside the linter entirely. All four pass clean (0.11.0).

Verified on the agent host: 51 behavioural tests incl. sabotage passes, a real blocked force-push (nothing reached the remote), and a real push+delete cycle on a throwaway branch.

Supersedes #13, which had a stale merge base (that PR re-added the already-squashed gitconfig block).

PR #12 added a gitconfig pointing at a credential helper the repo did not
contain, so a rebuilt agent host got config with nothing behind it. Ship the
three shims it depends on:

  gh                        injects the per-org PAT, resolving owner from
                            -R/--repo, GH_REPO, an `gh api` path, a POSITIONAL
                            owner/repo, or the cwd's origin. No default-org
                            fallback: a repo-less call runs unauthenticated
                            rather than quietly carrying an org credential.
  git                       refuses force-push and branch-delete, audits, and
                            notifies. An ACCIDENT CATCHER, not a control —
                            anything running as the agent can call /usr/bin/git
                            or set NORM_ALLOW_FORCE=1. It fails OPEN to real git
                            by design; breaking every git call would be worse
                            than missing one force-push.
  git-credential-github-org one PAT per org, keyed on the remote URL's owner.

All three append to ~/.local/state/norm-gh-audit.jsonl (0600, created before
first write — the ambient umask would otherwise leave it world-readable). The
token value is never logged.

Gated in .chezmoiignore on .agent: `gh` and `git` SHADOW the real binaries, so
on a host without ~/.config/github-pats they would break github.com auth
outright. Verified both renderings with --override-data.

Also wire home/dot_local/bin/* into the shellcheck job. Those files shadow real
binaries and were outside the linter's reach; all four pass clean (0.11.0).
Norm and others added 2 commits August 1, 2026 08:46
Widening the shellcheck job to home/dot_local/bin/* newly lints this file and
SC2015 fires on `cd "$WORK" && git pull ... || true`. The warning is right:
`|| true` swallowed a failed cd as well as a failed pull, while everything
below (including the later `cd "$WORK"`) assumes we are in $WORK.

Split so cd failure is fatal under set -eu and only the pull is best-effort.
Verified with shellcheck 0.9.0 (matches CI's Ubuntu build) and 0.11.0.
@natevick
natevick merged commit fa4a3f6 into main Aug 2, 2026
2 checks passed
@natevick
natevick deleted the norm/agent-credential-shims-v2 branch August 2, 2026 14:58
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