Connecting a real GitHub App¶
Docs index · Getting started · Configuration
The quickstart runs with a throwaway key and signed fixtures. To see Graft on real pull requests you register your own GitHub App from the manifest in this repository, point its webhook at your laptop through a tunnel, and install it on a sandbox organisation. Use a sandbox: Phase 0 Graft reports only, but it still writes check runs and a comment on every pull request it sees.
Which manifest¶
Two manifests live in github/:
app-manifest.json: the full permission set. Register this one for a deployment that may enforce.app-manifest.report.json: the permission set for a deployment that only ever evaluates Graft (name and description say "report only"). Phase 1 step 2 addsmembers: readand themembershipandteamevents to both; later steps add more read permissions to both andcontents: writeto the full manifest only.test/unit/manifest.test.ts(U-MAN-2) pins that the report manifest never has a write permission other thanchecksandpull_requests, so an evaluating deployment cannot be enforced on by construction.
Registering the report manifest is the safest default. See Modes.
Register the App¶
- Pick the manifest (see above) and edit it (name,
url,hook_attributes.url). Create a channel at https://smee.io/new and use its URL as the hook URL. - Serve
github/register-app.html(for examplecd github && python3 -m http.server 8080, then open http://localhost:8080/register-app.html), enter the org name and submit. GitHub redirects toredirect_urlwith?code=.... - Convert the code:
gh api -X POST /app-manifests/<code>/conversions. The response has the Appid,pemandwebhook_secret. - Put the PEM in a file outside the repo and fill
.env:GITHUB_APP_ID,GITHUB_APP_PRIVATE_KEY_PATH,GITHUB_WEBHOOK_SECRET; also setSMEE_URL. - Run
pnpm tunnel(smee) next topnpm dev:serverandpnpm dev:worker, then install the App on a sandbox org.
gh webhook forward does not work for GitHub App webhooks (it only supports repository and organization webhooks). Use smee, or ngrok / cloudflared pointed at http://localhost:3000/webhooks/github.
After registering, record the App's slug too. Setting GITHUB_APP_SLUG enables the <slug>[bot] fallback that recognises Graft's own comment when performed_via_github_app is missing from the comments API (decision D13; see architecture.md). For a pilot, install the App on selected repositories; docs/pilots/onboarding.md explains why and lists what Graft reads and stores. Alternatively, install it on all repositories and turn on the database-backed repository filter before receiving repository events.
Console access and repository activation¶
No new GitHub App permission or webhook event is needed for repository activation. Both shipped manifests already include metadata: read for repository access and collaborator-permission checks, and organization members: read for the allowed-organization membership check. Repository administrators enable or disable Graft processing in its database; this does not edit GitHub repository settings and needs no administration permission.
For an older App, check GitHub App settings → Permissions & events → Organization permissions → Members: Read-only. If it was missing, save the change and have an organization owner accept the updated permissions on each installation. Organization-based console sign-in needs an active installation on that organization; explicitly allowed users do not need organization membership.
The console retains its separate, scope-free GitHub OAuth App and callback URL; no additional OAuth scopes are required. Configure the console allow-lists and signed Graft connection as described in the console setup. Installing on all repositories grants the App access to all of them: Graft's activation list is a processing filter, not a GitHub permission boundary.
More than one account¶
One Graft server holds one App's credentials (GITHUB_APP_ID, the key, GITHUB_WEBHOOK_SECRET), but an App can be installed on any number of accounts, and Graft keeps each installation apart. To serve a second user or organization, install the same App there instead of registering a second one.
The manifests are "public": false, and a private App installs only on the account that owns it. To install it elsewhere:
- Set
GRAFT_ALLOWED_ACCOUNTSto every account Graft should serve (for examplemmornati,horae-dev) and restart. Do this first: GitHub cannot limit who installs a public App, and it signs a stranger's deliveries with your webhook secret. With the list set, those deliveries are answered202 ignoredand never stored or enqueued. AddGRAFT_UNINSTALL_UNLISTED=onto also remove the App from such an account when it installs it (configuration). - In the App's settings, Advanced → Make public.
- Open
https://github.com/apps/<slug>/installations/new, pick the account and select its repositories. For an organization, an owner approves the install and its permissions.
Optionally, let only GitHub reach the webhook: at the proxy, allow /webhooks/github from the hooks ranges of https://api.github.com/meta only. That does not replace the list, since a stranger's installation also sends from those ranges.
To run Graft on a server instead of your laptop (a stable HTTPS webhook URL, no tunnel), see Deploying Graft.
The human steps (sandbox org, test repositories, smee channel, registration, install checks) are tracked in docs/phase-0/HUMAN-TODO.md.
Permissions and events¶
github/app-manifest.json is the source of truth; test/unit/manifest.test.ts pins it. Changing a permission means updating the test and this table together.
| Permission / event | Level | Use |
|---|---|---|
metadata |
read | Mandatory for every App; repository listing. |
contents |
write (full manifest), read (report manifest) | Read graft.yaml from the base branch (step 5, now used) and commit data for trailers (step 2); git.getCommit for the head commit when a PR has more than 250 commits. Phase 1 step 5: in guard_mode: enforce only, create the revert's tree, commit and graft-revert/<event id> branch (POST …/git/trees, …/git/commits, …/git/refs) and delete that branch on crash recovery; read trees and commits (GET …/git/trees/{sha}, …/git/commits/{sha}) for the plan in every mode. Without write, guard_mode is effectively report and the guard comment says why. |
issues |
read | Read the linked issue for the intent writer (now used, step 3). No write: comments go through pull_requests: write. |
pull_requests |
write | Read PRs, files, diffs, commits and reviews (steps 2, 3, 6); list PR commits (step 2); list PR files and patches (step 3); list comment reactions (step 3). Write is only for creating and updating the pinned card comment, since the issue-comments API accepts pull_requests: write. |
checks |
write | Create graft/provenance (step 2), graft/intent with Accurate/Wrong buttons (requested_action, step 3) and graft/policy check runs (step 5). |
pull_request event |
— | Trigger provenance, intent and policy on opened, synchronize, reopened, edited and closed; labeled and unlabeled re-run the policy (step 5). |
pull_request_review event |
— | submitted and dismissed refresh the approval count in the policy section (step 5). No new permission: reviews are covered by pull_requests. |
push event |
— | A push to a branch that changes graft.yaml (or a forced or 20-commit push) re-evaluates the open PRs of that branch, at most 100 (step 5). No new permission: covered by contents: read. |
check_run event |
— | rerequested re-runs our checks; requested_action delivers the card buttons (step 3). |
statuses |
read | Phase 1 step 4: read the commit statuses of default-branch commits (GET /repos/{o}/{r}/commits/{sha}/status) for the post-merge guard. Without it the guard reads check runs only. Not actions: read: GitHub Actions jobs are check runs, which checks already covers. The review summary also reads the statuses of PR heads; without it, it counts check runs only. |
check_suite, status events |
— | Phase 1 step 4: check_suite.completed and status on the default branch (and check_run.completed, already subscribed) schedule a guard.observe for the commit. The payload is a trigger: results are read from the API. A push to the default branch also starts guard.track. On an open PR's head, check_suite.completed (not Graft's own) and a non-pending status re-evaluate the policy once per 30 seconds, so the review summary shows CI and AI review results. |
installation, installation_repositories |
— | Delivered to every App without a subscription; drive the installations module. |
members (organization) |
read | Phase 1 step 2: verify that an approver is an active member of a team named in graft.yaml (GET /orgs/{org}/teams/{team_slug} and …/memberships/{username}). Read only; nothing about teams is stored. Without it every team constraint is unverified and never met. |
membership, team events |
— | Phase 1 step 2: membership (added, removed) and team (deleted, edited, added or removed from a repository) re-evaluate the installation's open PRs that have a team constraint, once per five-minute window, after the window closes. The payload is a trigger: only the installation id is read. |
Deferred (not requested):
actions: readand theworkflow_runevent: not needed (the guard reads CI through check runs and statuses).workflows: never. A revert of a change under.github/workflows/would need it; Graft leaves those to a human (needs_human/workflow_files).administration: never.
Phase 1 step 6: no new permission. The MCP tool open_change opens a pull request with pull_requests: write, which both manifests have since Phase 0; its reads (the repository, branch refs, open PRs by head, graft.yaml) are covered by metadata, contents: read and pull_requests. The report manifest can therefore open MCP PRs only if an operator raises the ceiling and sets --mcp-write on; an evaluation-only deployment keeps the ceiling at report, which forces mcp_write off. No event is added.
Phase 1 step 5: contents: write (full manifest only). The revert pull request needs contents: write (trees, commits, a branch) and the already granted pull_requests: write (the pull request, its graft:revert label, and enablePullRequestAutoMerge). The report manifest keeps contents: read, so an evaluation-only deployment can never open a revert (U-MAN-6). There is still no workflows permission, in either manifest. An organization owner accepts the new permission on each installation that will enforce the guard, then the operator runs pnpm graft mode refresh-permissions --installation <id>; until then guard_mode: enforce is effectively report (permission_missing contents:write).
Phase 1 step 4: statuses: read and two events. As for step 2, an organization owner accepts the new permission and the check_suite and status events on each installation, then the operator runs pnpm graft mode refresh-permissions --installation <id>. Until then pnpm graft mode show notes that the guard reads check runs only.
Phase 1 step 2: accepting the new permission on existing installations. GitHub does not grant a new permission by itself: after the App's permissions are updated, an organization owner must accept members: read and the two events on each installation (GitHub shows a banner on the installation's settings page, and the App receives installation.new_permissions_accepted). Graft re-reads the permissions on that event, once a day and on pnpm graft mode refresh-permissions --installation <id>; pnpm graft mode show prints the permissions line and, for a repository that enforces policy without members: read, a note that team constraints will fail. Until then the installation keeps working: it fails closed on team constraints only.
Comment reactions have no webhook; step 3 polls them every 15 minutes using pull_requests: read.
Step 6 changes no permission or event (github/app-manifest.json is unchanged, U-MAN-1). The reviewer sync's permission check (GET /repos/{owner}/{repo}/collaborators/{username}/permission) needs, per GitHub's documentation, only the repository permission Metadata: read, which the manifest already has; the OpenAPI types in node_modules do not record permissions, so this could not be confirmed offline (HUMAN-TODO verifies it on a real PR). If the App lacked access the check would answer 403 and requested users would silently be ineligible (fail closed); no permission was added. The review-time baseline reads the issue timeline (issues: read), reviews and requested reviewers (pull_requests: read) and commits (contents: read); the incident and reviewer jobs use the already subscribed pull_request (review_requested, labeled, closed) and pull_request_review events.