Skip to content

feat(github): a repository-scoped, read-only installation token - #302

Merged
sweepies merged 2 commits into
mainfrom
feat/scoped-installation-token
Nov 13, 2026
Merged

sweepies merged 2 commits into
mainfrom
feat/scoped-installation-token

Conversation

@sweepies

@sweepies sweepies commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

PR 2 of 4 for GitHub Actions workflow lockfiles (#300 was PR 1). Nothing calls the new token yet, so there's no behaviour change; PR 3 uses it.

  • Scoped mint (crates/github/src/app.rs): POST /app/installations/{id}/access_tokens with {"repository_ids": [<id>], "permissions": {"metadata": "read"}}. The token reads public repositories, as any authenticated caller can, and nothing private. The cache key becomes (installation, scope) with the same reuse window (until two minutes before expiry) and single-flight. The full-installation mint is unchanged: no body, byte for byte.
  • Repository id: GET /repos/{owner}/{name} with the installation token.
  • The accessor PR 3 calls: Runner::actions_lock_token(repository) returns { token, kind: Scoped | RunToken }. With App credentials it's the scoped token. On a bare-token run (the CLI with PATCHULA_TOKEN, the GitHub Action) it's the run's own token, as Renovate does; that was the user's decision. ToolToken has no Debug, and the token goes on the run's secrets for masking.
  • Real-installation proof: real_installation_scopes_a_token_to_one_repository is #[ignore]d and gated on PATCHULA_TEST_APP_ID, PATCHULA_TEST_APP_KEY_FILE, PATCHULA_TEST_INSTALLATION, PATCHULA_TEST_REPO and PATCHULA_TEST_OTHER_PRIVATE_REPO. It asserts the minted permissions and repositories, public reads, a 404 on another private repository, and a refused write. It hasn't been run yet: no App key is available in CI or to the agent. The run line is in internals/github-client.md.
  • State versions: rows covering crates/github/src/ are bumped (all unreleased since perf(cache): extraction, catalog and notes state survive a release when their code did not change #293).

Offline tests against the testkit's FakeGitHub cover the exact body, the honoured scope, cache reuse and renewal, per-repository separation, and the accessor's two kinds. test:unit and clippy pass on the project VM.

View guided diff Turn on auto-fix

sweepies and others added 2 commits November 13, 2026 20:43
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… for the named repository

ToolToken's token is private: grant() is the only way to hand it to a
tool, and it sets GH_TOKEN and puts the token on the run's secrets in
one step. The repository-id lookup checks the answer's full_name, so a
rename that leaves the old name pointing elsewhere fails the mint
instead of scoping it to another repository. The real-installation test
fails when its variables are missing rather than passing without proof.
@sweepies
sweepies merged commit 51034d3 into main Nov 13, 2026
12 checks passed
@sweepies
sweepies deleted the feat/scoped-installation-token branch November 13, 2026 21:37
@sweepies-ops sweepies-ops Bot mentioned this pull request Nov 13, 2026
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