✨ feat: P-03 session-start: agent identity or GitHub locked out

Merged
AL
1mo ago
+429-43

Roadmap P-03, session start. Builds on P-02 (#1, merged). Also marks P-02 shipped in the roadmap.

process-rules session-start, run by a client's SessionStart hook (P-04's onboard will write that hook entry):

  • Appends a lock to CLAUDE_ENV_FILE first:
    • a GH_TOKEN GitHub refuses;
    • the credential helper reset to none;
    • GITHUB_TOKEN, GIT_CONFIG, GIT_CONFIG_PARAMETERS and askpass unset;
    • GitHub's SSH remotes rewritten to HTTPS, and every other SSH remote refused.
  • Then appends the agent's session file, which replaces the lock. It does this only when the file is exactly what machine writes for the agent that .github/process-rules.json names. An edited file, another agent's file, or a missing file stays locked.
  • Prints one line for the session:
    • the agent it works as; or
    • why GitHub is locked out, who to ask, and which machine and doctor commands fix it; or
    • STOP, when CLAUDE_ENV_FILE is unset.
  • Works offline, always exits 0, and leaves cloud sessions (CLAUDE_CODE_REMOTE) alone.

The lock and the agent identity now share one list of git config, which also clears core.askpass. That changes the session file machine writes: a file from before this PR is refused as out of date, both by session-start (which stays locked) and by doctor. The fix is to run process-rules machine <agent> again, which only rewrites the session file. This Mac's AthyaBot file has been rewritten, and doctor passes.

Checked on a Mac set up by machine. In a repo whose settings name the agent, a shell sourcing the env file gets the agent's login from gh api user, commits as the agent's no-reply address, and reads the sandbox repo. In a repo whose settings name an agent with no session file, gh is refused and git ls-remote over HTTPS and SSH both fail with no login.

pnpm check: 137 tests pass, including real-shell tests of the lock against an owner's leaking credential helpers; coverage 97% lines, 99% branches.

🤖 Generated with Claude Code


Summary by cubic

Adds process-rules session-start, run by a client's SessionStart hook, so each session either works as the agent the repo's settings name or has GitHub locked out. A session is told to STOP when CLAUDE_ENV_FILE is unset or unwritable, so it never falls back to the owner's login. Marks P-02 shipped in the roadmap.

New Features

  • Appends a lock to CLAUDE_ENV_FILE first: a GitHub-refused token, no credential helper or askpass program, nothing inherited that could restore one, GitHub SSH remotes rewritten to HTTPS and other SSH refused.
  • Appends the session file only when it is byte-for-byte what machine writes for the named agent; missing, edited, out-of-date, or other-agent files stay locked.
  • Prints one line naming the agent or why GitHub is locked out; always exits 0, works offline, leaves cloud sessions alone.
  • Reads settings from the project folder Claude Code names instead of the working directory.

Refactors

  • The lock and the agent identity now share one list of git config, and the session file machine writes stays unchanged.