🐛 fix: P-18 the owner's SSH route covered

Merged
AT
1mo ago
+408-45

Slice: #46

Covers the owner's SSH route to GitHub (finding (c)). After machine signed gh out of the owner, git still reached GitHub as the owner over SSH, using the owner's ~/.ssh/id_ed25519 from the SSH agent. It builds on P-17 (#61), whose env lock it relies on. It replaces #62, which auto-merge merged into the stacked P-17 branch by mistake; that merge was undone there.

  • The pre-push identity guard, for every adopter (spec G-6). onboard now writes the pre-push hook with identity alone, not only with work-rules, and replaces the hook older releases wrote. process-rules pre-push now takes git's remote URL and first checks who the push reaches GitHub as. In an agent session, it refuses:

    • a push to GitHub over SSH, because it would use this Mac's keys, which are the owner's;
    • over HTTPS, a push with credentials that are not the agent's. It asks git credential fill (never prompting) for the credentials git would push with, then asks GitHub's /user whose they are. A refusal names the account.

    An agent session is one where PROCESS_RULES_AGENT is set, or any shell where Claude Code sets CLAUDECODE=1, so the guard holds in a session whose Claude Code hooks never ran. The owner's own pushes are left alone, and so are cloud sessions' pushes: they reach GitHub as the account connected to them. The hook runs the launcher from #61 and refuses an agent session's push when no CLI can run. The work rules follow as before when work-rules is on.

  • machine and doctor name the route. They run ssh -T -o BatchMode=yes git@github.com and name the account GitHub greets, other than the agent, with what covers it. Removing the route is out of scope, as docs/decisions.md records: the key is the owner's own way to GitHub, and an agent session runs as the same macOS user. The coverage is #61's env lock (SSH remotes on HTTPS, SSH refused) plus this guard. Only a separate macOS user would close a session that works around both on purpose.

Proof against the sandbox (athya-hq/process-rules-sandbox, cloned locally, this build's pre-push hook, the launcher pointing at this build; --dry-run, so nothing could be pushed):

  1. A Claude Code shell with the identity removed, pushing to git@github.com:athya-hq/process-rules-sandbox.git: SSH authenticated as the owner, then the guard refused with ✗ this push goes to GitHub over SSH, with this Mac's SSH keys, which reach GitHub as their owner, not AthyaBot….
  2. The agent session over HTTPS: the identity check passed, and the work rules then refused the slice-less probe commit.
  3. The owner's terminal (no CLAUDECODE) over SSH: the push went ahead.

git ls-remote shows no probe branch on the sandbox. On this Mac, this build's doctor printed ! ssh reaches GitHub as AlokBansal8 with this Mac's keys; ….

pnpm check passes (508 tests).

Release v0.6.0, with P-17 and P-18. #64 had already merged before the decision to make this one release, so package.json and the README install line on main already say 0.6.0, and nothing is tagged yet. Once this merges, tag v0.6.0 on this pull request's merge commit; the release then ships both slices:

  • P-17 (#61): the env lock in the client's settings, the PreToolUse guard, the launcher machine writes (doctor checks it), session-start's failures reaching the session, onboard's Verified check retrying, and hook entries upgraded in place.
  • P-18 (this pull request): the pre-push identity guard for every adopter, and machine/doctor naming the owner's SSH route.

After the release:

  • On each Mac: install 0.6.0, then run process-rules machine <agent> once to write the launcher. doctor fails until it exists.
  • In each client: run onboard again to upgrade .claude/settings.json and the pre-push hook.
  • In this repository: a follow-up moves the workflow pin to v0.6.0, and .claude/settings.json and the pre-push hook to this release's. That has to wait for the release, because the 0.5.0 CLI has no guard.

🤖 Generated with Claude Code