Repository navigation
feat(pr-triage): take the caller's token grant and accept a dispatch for bot PRs - #278
Merged
Merged
Conversation
…for bot PRs pr-triage.yml sets no permissions, so its job gets the calling job's grant. A private caller can grant checks: read and statuses: read, and the readiness step then reads the checks instead of getting HTTP 403 (ADR-0086, amends ADR-0021 in part). check:fleet fails a job that calls pr-triage.yml without its own narrow permissions mapping; it reads the workflows with the yaml parser. pr-triage.yml takes the input pr. On workflow_dispatch only the levels step runs: it refuses a pr value that is not digits only, reads the PR and its base SHA from the pulls API, and labels the PR as on pull_request_target. A repository whose workflows open PRs with GITHUB_TOKEN adds the dispatch caller of the spec (ADR-0087). Closes #227 Closes #233
scripts/lib/fleet-conventions.mjs now imports the yaml package, and the fleet-conventions job ran check:fleet without npm ci (ERR_MODULE_NOT_FOUND). A test pins npm ci before npm run check:fleet in that job.
The B5 test derives the files without top-level permissions: {} from
disk, the guard tests cover flow-mapping jobs, quoted keys and the YAML
1.2 merge key (fails closed), and the docs say to run npm ci before
check-fleet-conventions.mjs in a core checkout. Adds the correction
record for the fleet-conventions job that ran without npm ci.
…urces ADR-0086 quotes the GitHub sentence on a calling job without its own grant and says the guard ignores workflow-level permissions, so it holds whatever GitHub takes as the default. The caller and private counts name the inventory table and its date; ADR-0087 names the bot workflows and their tokens (incus opens its sync PRs with a PAT). The review rubric names the pr-triage.yml exception, and the spec lists the 4 grants by scope.
bketelsen
approved these changes
Nov 18, 2026
This was referenced Nov 22, 2026
Merged
Merged
Merged
ci: pin core pr-triage workflow to f99acfd (retry of 5xx and network errors)
frostyard/frostmail#369
Merged
ci: pin core pr-triage workflow to f99acfd (retry of 5xx and network errors)
frostyard/frostmarks#13
Merged
Merged
Merged
ci: pin core pr-triage workflow to f99acfd (retry of 5xx and network errors)
bketelsen/trimlights#86
Merged
Merged
Merged
Merged
ci: pin core pr-triage workflow to f99acfd (retry of 5xx and network errors)
frostyard/testsuite#100
Merged
This was referenced Nov 22, 2026
Merged
Merged
ci: pin core pr-triage workflow to f99acfd (retry of 5xx and network errors)
frostyard/chairlift#330
Merged
Merged
Merged
Merged
Merged
Merged
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #227. Closes #233.
#227: the caller grants the triage token (ADR-0086, amends ADR-0021 in part)
pr-triage.ymlhas nopermissionskey (top level and job). A called workflow can only reduce the token that the calling job passes (GitHub: reusing workflow configurations), so a fixed grant withchecks: readandstatuses: readwould ask for more than the existing callers grant (34 repositories with a caller: the inventory indocs/design/pull-request-target-policy.md, read on 2026-11-09). With no key, a private caller adds the 2 reads to its own job, and thereadinessstep reads the checks instead of getting HTTP 403. A public caller needs no change.risk-paths-caller.ymlgrantscontents: read,pull-requests: write,checks: read,statuses: read.npm run check:fleetfails a job that callspr-triage.ymlwithout its ownpermissionsmapping, with a string grant (write-all,read-all), or with a scope or value outsidecontents: read,pull-requests: write,checks: read|none,statuses: read|none(triageCallerGrantGapsinscripts/lib/fleet-conventions.mjs). A workflow-level grant does not count: GitHub gives a calling job without its own grant the default token. The check parses the workflows with theyamlpackage (2.9.1, exact pin, no dependencies) instead of 1 more hand-written YAML reader.pr-triage.ymlis the 1 exception to the top-levelpermissions: {}rule.test/repository-baseline.test.mjspins the exemption list to exactly that file, which must exist, have only theworkflow_calltrigger and nopermissionsline.#233: dispatch for bot PRs (ADR-0087)
pr-triage.ymltakes the inputpr(string, default""). Onworkflow_dispatch, thelevelsstep refuses a value that does not match^[1-9][0-9]*$or is not a safe integer, before any API call. It readsGET /pulls/{number}; a PR that is not open gets the outcomenot-openand no label change. The base SHA comes from that answer. Then the step labels as onpull_request_target. The step does not readhead.sha: it needs only the base SHA and the file list.pull_request_target, a non-emptyprfails the step. Another event name fails it.readiness, the Dependabot metadata step andshadownow also needgithub.event_name == 'pull_request_target'in theirif:, so a dispatch runs only the scripts step andlevels..github/workflows/pr-triage-dispatch.ymland the bot job step (gh workflow run ... -f pr="$PR_NUMBER",actions: write). It is a separate file because the Actions event policy for the caller paths is an allowlist of events.The callers' PRs (private callers add the 2 reads; bot repositories add the dispatch caller) come after a core commit with this change is pinned. None is opened here.
Risk tier
Risk tier: 3 —
risk:high. Matched paths in.github/risk-paths.json, and why the change is safe:.github/workflows/**(L2):pr-triage.ymlandrisk-paths-caller.yml.pr-triage.ymlloses its own permission blocks. Its token is now the calling job's grant. In core that grant is 4 scopes, 3 read andpull-requests: write, the same write scope as before. In other repositories,check:fleetfails a caller job without a narrow grant (enabled declarations; the spec states the rule for all callers). The job still checks out nothing and runs no PR code.prinput reaches the script only throughenv:(PR_TRIAGE_PR), never insiderun:, and the script accepts digits only.github.event_name == 'pull_request_target'conditions only narrow when a step runs.scripts/lib/pr-triage.mjs(L2): thelevelsstep acceptsworkflow_dispatch. Thereadinessandshadowcode is unchanged and still refuses any event butpull_request_target.pr-triage.ymlwas rewritten only bynpm run sync:risk-paths-workflow;check:risk-pathspasses.Docs housekeeping
TEMPLATE.md(ADR-0086, ADR-0087)docs/README.mdspecs/pr-triage.md,specs/risk-paths.md,specs/repository-baseline.md,design/pull-request-target-policy.md; ADR-0021 gets the "Amended in part by" line)Decision trail: the maintainer chose option A on #227 (caller grant plus a fleet guard) and option A on #233 (dispatch with a PR number, levels only).
Verification
make ciat3b644cd: 1039 tests, 1039 pass, 0 fail (0149919adds 1 blank line in ADR-0086:check:docsand CI green there);check:docs,check:risk-pathsgreen.GITHUB_TOKEN=… node scripts/check-fleet-conventions.mjs:okfor all 7 enabled repositories (clix, core, firn, frostmarks, hearth, std, updex), 32 workflow files read.yaml); the tests still cover flow and block mappings, quoting, comments, anchors and aliases, duplicate keys, BOM, CRLF, an empty file and no final newline.risk-paths-caller.ymlkeepspermissions: {};pr-triage.ymlis the ADR-0086 exception.ci.yml: thefleet-conventionsjob now runsnpm cibeforenpm run check:fleet(the guard importsyaml); a test pins that order.e3ee192,scripts/lib/pr-triage.mjsand both workflows restored to the base, andtriageCallerGrantGapsstubbed toreturn [], thennode --test test/pr-triage.test.mjs test/fleet-conventions.test.mjs test/repository-baseline.test.mjs: 28 triage/workflow tests fail (for examplelevels dispatch reads the live base SHA and shares the label ratchet,levels dispatch refuses invalid pr input "7\n" before any API call,workflow_dispatch runs only the scripts and levels; ...,B5: every workflow pins its actions by SHA, ...) and 28 guard tests fail (for exampletriageCallerGrantGaps requires own job permissions despite top-level "permissions: write-all\n",checkFleetConventions reports a triage caller without its own job permissions), all on assertions. Thenpm citest fails with theci.ymlline reverted.0149919(docs-gate, fleet-conventions, scaffold-e2e, pr-triage).Cross-review
Reviewer
github-copilot/claude-sonnet-5.5; coderopenai/gpt-6.1-sol(code, tests, spec and design edits), the 2 ADRs from an Anthropic model. Base602caf9bba57e0f354b9e5484f488ab8cd9afe34.e3ee192: 1 blocking point, thefleet-conventionsjob rancheck:fleetwithoutnpm ci, so the newyamlimport failed on a clean runner (also seen in run 44208991438). Fixed ina36ad0fwith a guard test and the correction record.memory/corrections/2026-11-18-pr-278-fleet-job-npm-ci.json. 5 low points: a constant assertion (replaced by a check derived from disk), a stale comment inworkflow-triggers.mjs, 3 missing YAML shapes (flow-mapping job, quoted keys,<<fails closed: tests added),npm ciin the doc commands (added), and a regex that can also match a foreign owner (accepted: extra gaps only).f680088: Ready, no blocking point. 5 non-blocking doc points: fixed in3b644cd(the GitHub default-token claim is quoted and hedged, and the guard ignores workflow-level permissions either way; counts name their source and date; ADR-0087 names the bot workflows and tokens, and incus is left out because it opens its sync PRs with a PAT; the review rubric names the exception; the spec lists the grants by scope).3b644cd: Ready; 1 low point (a missing paragraph break), fixed in0149919.01499193fa662e2b394928b78e14081da4f4c0fb: Ready,Blocking: none.Follow-ups (after a core commit with this change is pinned; not opened here)
checks: readandstatuses: readto thepr-triagejob and bump the pin..github/workflows/pr-triage-dispatch.yml(spec rule A2) and a dispatch step incheck-dependencies.yml.WORKFLOW_PATsecret is not set.sync-upstream.ymluses the PATUPSTREAM_SYNC_TOKEN).Not tested: no live run on GitHub. The dispatch path and a private caller's grant are covered by unit tests with a fake API only. After merge, the core caller's next PR run shows the grant at work in a public repository.