Skip to content

feat(appauth): narrow installation token permissions - #86

Merged
tbhb-agent merged 1 commit into
mainfrom
agent/gm-rec-c4-codex
Nov 23, 2026
Merged

tbhb-agent merged 1 commit into
mainfrom
agent/gm-rec-c4-codex

Conversation

@tbhb-agent

Copy link
Copy Markdown
Collaborator

Why

The reconciler design (#82, PR C of its split) limits the installation token to metadata and pull_requests read, as appendix B of the architecture docs requires. The request had no body, and GitHub issued the app's full permission set. This PR narrows the request. It must merge before PR G puts the reconciler into main.

Behavior change

The token request now sends {"permissions":{"metadata":"read","pull_requests":"read"}} with a JSON media type. The running service behaves as before, because no code calls the token source yet. Once PR G adds a caller, the token reads pull request data and nothing else.

Decisions

The permissions body is a constant in fetch. A response that grants fewer permissions than asked still counts as a valid token. The design is silent on that case, and GitHub documents that the response lists what it granted. The error rules, the https-only base URL, the 30 second timeout, the 2 hour expiry bound and the body cap don't change.

Deviations from the task

The brief also had the run fix one paragraph of the design, section 4. It described Token and Renew as they were before the hardening in #80. The first run stopped on that mismatch. The paragraph now says that Token keeps a still-valid cached token after a failed refresh and that Renew reuses a token another caller fetched while it waited. The code didn't change.

Needs human judgment

Nobody has verified here whether the installed app grants pull_requests read. GitHub answers a request for a permission the installation lacks with an error, and the source then returns ErrAuth. Someone with access to the app settings should confirm before PR G deploys.

Risk

Medium, because this is credential code. The change touches only the request body and one header, and the tests check the exact body. The token source gets two review runs.

Verification

bazelisk test //internal/appauth/... //:vale_test //:rumdl_test //:cspell_test
bazelisk run @tbhb_rules//lint:pr_size -- origin/main HEAD

These pass, with pr_size: code=31/400. The test server reads the request body and fails unless the body lists exactly the two read permissions. A Claude session read the full diff before opening the PR. A Codex run wrote the code.

Human steering

None.

Opened-by: LLM effort=medium;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:6507fa80a17e0653;surface=cli
Generated-by: LLM effort=high;harness=codex:0.171.0;model=openai:gpt-6.2-sol;session=sha-256-64:d07b7831e61bd1b2;surface=exec
Assisted-by: LLM effort=medium;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:6507fa80a17e0653;surface=cli

Generated-by: LLM effort=high;harness=codex:0.171.0;model=openai:gpt-6.2-sol;session=sha-256-64:d07b7831e61bd1b2;surface=exec
@tbhb-agent
tbhb-agent merged commit 91d75d5 into main Nov 23, 2026
8 checks passed
@tbhb-agent
tbhb-agent deleted the agent/gm-rec-c4-codex branch November 23, 2026 06:41
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