notes

Agent sessions act as the App, not as the architect

Name of this note, of helpers/smelter-token and of helpers/smelter-bin/: provisional, minted 2026-10-07 (UTC) by the lane for milestone 128 (the automation gets its own identity). It extends automation-identity.md, which covers the App itself and the workflows, and is already over the prose budget.

Turning it off, from a plain terminal

Nothing here is persistent outside a session that opted in. No file in .git/config, ~/.gitconfig or gh's configuration is written; the opt-in lives only in that session's environment. So any of these, none of which needs a tool this change added, returns everything to the state before it:

A shell that never set NIFE_SMELTER=1, calef's own terminal among them, is never affected.

What calef ruled

All four on 2026-10-07 (UTC), on #1828:

The gap this closes

Without it, an agent session on patagonia runs gh and git push as calef. His classic gh token carries the scopes repo, workflow, admin:public_key, gist and read:org, so such a lane holds a credential that reaches his personal repositories and his SSH keys. Every pull request, comment and label it makes carries his name. The scheduled workflows run as the nife-smelter App.

How a session becomes the App

helpers/smelter-token signs a JSON Web Token (JWT) with the App's private key, finds the App's installation on nifeos, and exchanges the JWT for an installation token that lives an hour. It caches the token per scope (mode 0600, under ~/Library/Caches/nife-smelter/) and remints it with ten minutes left. The key goes to openssl on a pipe and is never written to disk.

A session opts in by setting NIFE_SMELTER=1. Then helpers/smelter-token env prints environment variables for that session, as shell lines (env --json gives JSON). Without the opt-in it prints a comment and changes nothing, whether or not the key is installed. The variables do three things:

The selftest checks the "nothing persistent" claim mechanically. It runs every subcommand with an empty home and working directory and fails if either holds a file afterward, or if a stand-in global git config changed; a mutation that writes git config --global fails it.

Opting a session in, in any harness

An agent's shell tool starts a fresh shell per command, so the variables must reach each command. The one form that works in every harness is a prefix:

eval "$(NIFE_SMELTER=1 helpers/smelter-token env)"; gh pr list

Wiring a harness to apply it to every command (Claude Code's SessionStart hook and CLAUDE_ENV_FILE, opencode's shell.env plugin hook) is deliberately left to a later change, after a trial on single sessions. helpers/smelter-token check exits 1 with a warning when a session set NIFE_SMELTER=1 but the variables are not applied. script/claim runs it at every lane's first act; a session that did not opt in sees nothing.

Two scopes, one App

A token is minted with one of two permission sets, and GitHub enforces the one asked for.

Scope Permissions How a session gets it
lane Contents, Pull requests, Issues, Actions, Workflows write; Checks, Commit statuses read the default
maintainer the above, plus Administration write NIFE_SMELTER_SCOPE=maintainer in the command

Administration is what repository settings, rulesets and the merge queue's configuration need. Keeping it out of the default means a settings change names itself on its own command line. Every workflow's token names Contents and Pull requests write explicitly, which was the App's whole set before this, so widening the App for sessions widens no workflow.

Switching it on (calef, in order)

  1. Widen the App at https://github.com/organizations/nifeos/settings/apps/nife-smelter/permissions. Repository permissions: Actions, Administration, Contents, Issues, Pull requests and Workflows Read and write; Checks and Commit statuses Read-only; Metadata stays Read-only. Save, then approve the pending request on the installation at https://github.com/organizations/nifeos/settings/installations.

  2. On the same installation page, set Repository access to All repositories. An installation belongs to one organization, so this reaches every nifeos repository as the monorepo splits, and nothing outside it.

  3. On the App's General page, Generate a private key. It is a second key, kept apart from the one in the automation environment so either can be revoked alone. Store it in the login keychain, base64 on one line (security -w prints a value containing newlines as hex), then delete the download:

    security add-generic-password -s nife-smelter -a private-key -T /usr/bin/security
    -w "$(base64 < ~/Downloads/nife-smelter..private-key.pem | tr -d '\n')" rm ~/Downloads/nife-smelter..private-key.pem

    -T /usr/bin/security lets the helper read it without a prompt on every mint.

  4. Check it from the repository: helpers/smelter-token identity prints nife-smelter[bot]. Then NIFE_SMELTER_SCOPE=maintainer helpers/smelter-token token >/dev/null && echo ok prints ok; an HTTP 422 there means step 1's Administration was not approved.

  5. Try one session: eval "$(NIFE_SMELTER=1 helpers/smelter-token env)"; gh api /installation/repositories --jq .total_count answers only for the App. Wiring a harness comes after the trial.

To switch it off, see the first section; revoke the key on the App's General page as well.

What changes once pull requests are the App's

Checked against the tree and the main ruleset on 2026-10-07 (UTC):

EXAMPLES

helpers/smelter-token identity                       # nife-smelter[bot]
helpers/smelter-token check                          # warns if opted in but not applied
eval "$(NIFE_SMELTER=1 helpers/smelter-token env)"; gh pr list   # one opted-in command
GH_TOKEN="$(helpers/smelter-token token)" gh api /repos/nifeos/nife --jq .full_name
NIFE_SMELTER_SCOPE=maintainer gh api -X PATCH /repos/nifeos/nife -F allow_auto_merge=true
helpers/smelter-token --selftest                      # no network, no keychain

BUGS