Skip to content

feat(tools): mint-token and agent session setup for the agent app (AGT-4, AGT-5) - #11

Merged
Moep90 merged 2 commits into
mainfrom
feat/agent-tools
Nov 5, 2026
Merged

Moep90 merged 2 commits into
mainfrom
feat/agent-tools

Conversation

@Moep90

@Moep90 Moep90 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

These are the workstation tools for agent sessions under the agent app. The spec is in kadet-hub/registry#558 (AGT-4, AGT-5), and the setup checklist is at the end of that pull request.

tools/agent/mint-token prints an installation token for the repositories I name. That token becomes GH_TOKEN of an agent session. The script takes AGENT_APP_ID (client ID or app ID) and AGENT_KEY_REF (the op:// reference).

  • op read pipes the key straight into openssl dgst -sign, so the key is never a file, a shell variable or an argument.
  • curl gets the JWT on stdin, because other local users can read a process's command line.
  • The installation ID is looked up through GET /orgs/kadet-hub/installation. The token request names the repositories, so the token covers nothing else.
  • Only the token goes to stdout. On an error, GitHub's status and message go to stderr and the exit code is non-zero.

tools/agent/test_mint_token.py generates a throwaway RSA key, puts a fake op and a curl wrapper that logs its arguments on PATH, and runs the script against a local fake API through GITHUB_API_URL. It checks:

  • stdout is exactly the token;
  • the JWT verifies against the throwaway key, with iat 60 s back, exp within 10 minutes and a numeric iss;
  • the request body is {"repositories": [...]};
  • no line of the key and not the JWT appears on stdout, stderr or curl's command line;
  • the working and temporary directories stay empty;
  • a 422 is reported on stderr with nothing on stdout;
  • a call without repositories exits 2 before any request.

Six mutations of the script each made the suite fail: the JWT on curl's argv, the key through a temp file (two variants), no repositories in the body, no argument check, and an error that prints the body and the JWT. The new tools workflow runs the suite on pull requests that change tools/.

tools/agent/sessions.md sets up a session on Fedora in one of two ways:

  • a separate OS user, started with run0 --setenv=GH_TOKEN with PrivateTmp and ProtectProc=invisible;
  • a rootless podman container with a named volume and --env GH_TOKEN.

Either way the session can't reach my home, the keyring with the gh logins, 1Password, the Vault token or the SSH and GPG keys. The bot identity, gh auth setup-git and the AGT-5 checks are the same for both. I tested gh auth setup-git and gh auth git-credential with only a dummy GH_TOKEN in a throwaway home: the helper answers x-access-token. I checked that a transient unit's environment shows in systemctl show for an unprivileged user, which is why the guide warns about run0. I did not create a user or build the image on this machine, so the guide's checks are what verifies it.

.github/CODEOWNERS names /.github/ and /tools/. The script handles the app key, and the app will be able to open pull requests here. The file changes nothing until code owner review is on in this repository's main ruleset, which is step 7 of the checklist.

tools/agent/mint-token reads the app key with op read straight into
openssl, signs the JWT, and prints an installation token limited to the
named repositories, for GH_TOKEN of an agent session. Key and JWT never
reach a file, a command line or the output. The test runs it against a
throwaway key, a fake op and a local fake API; the tools workflow runs
it. CODEOWNERS names tools/ and .github/ for the maintainer (AGT-10).

Signed-off-by: Moep90 <3042152+Moep90@users.noreply.github.com>
…(AGT-5)

Fedora setup for a session whose only GitHub credential is the app
token: a separate OS user started with run0, or a rootless podman
container with a named volume. Both keep the maintainer's home, keyring,
1Password, Vault token and SSH and GPG keys out of reach. Ends with the
checks of AGT-5.

Signed-off-by: Moep90 <3042152+Moep90@users.noreply.github.com>
@neat-bot

neat-bot commented Nov 5, 2026 •

Copy link
Copy Markdown

5 finding(s), none judged useful, approved

@neat-bot neat-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through this change and have nothing to flag.

@Moep90
Moep90 merged commit face044 into main Nov 5, 2026
2 checks passed
@Moep90
Moep90 deleted the feat/agent-tools branch November 5, 2026 12:29
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.

2 participants