Skip to content

feat: PR triage workflow that binds ready-for-human to the head commit (ADR-0077) - #220

Merged
bketelsen merged 2 commits into
mainfrom
lucilla/t1229-t2-pr-triage
Nov 9, 2026
Merged

bketelsen merged 2 commits into
mainfrom
lucilla/t1229-t2-pr-triage

Conversation

@frostyard-machines

@frostyard-machines frostyard-machines commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

ready-for-human says that the review passed and CI is green at the PR head, but the label names no commit. A later push, or a label added while CI is red or pending, leaves a false claim on the merge list. This PR makes core's reusable workflow remove the label in those 2 cases, for every PR of every repository with a caller, with no agent runtime (ADR-0077, new). Context: the merge-lane replay in #218.

  • .github/workflows/pr-triage.yml replaces risk-paths.yml (a git mv, then edits). 1 job pr-triage, 2 steps:
    • levels: the risk:high behavior of ADR-0068, unchanged. It does not run on labeled.
    • readiness (new, scripts/lib/pr-triage.mjs): on synchronize with the label in the payload, reason head-moved; on labeled with ready-for-human, it reads the check runs and commit statuses at the head (all pages; its own pr-triage* runs left out) and revokes when any is not green. Revocation writes 1 marker comment first, then DELETEs the label (200 and 404 count as done; other errors fail the step). A re-run after a failed delete finds the marker and writes no second comment.
    • The job layout has room for further steps (!cancelled() in their if:); a dependabot-shadow input is reserved and unused.
  • Both libraries are embedded verbatim in 2 heredocs and written to $RUNNER_TEMP/pr-triage/. npm run sync:risk-paths-workflow rewrites both; npm run check:risk-paths fails when either drifts and names it.
  • scripts/lib/risk-paths.mjs: 5 new API methods on 1 shared paginator; escapeCell, NAME_PATTERN, commandValue exported. Every old export and result is unchanged, so vendored copies keep working.
  • Core's caller (risk-paths-caller.yml, same file name) uses ./.github/workflows/pr-triage.yml with types opened, synchronize, reopened, edited, labeled; job id pr-triage (the readiness step leaves out checks by that prefix).
  • Docs: new spec docs/specs/pr-triage.md (contract, triggers, check evaluation, revoke order, limits), ADR-0077, risk-paths spec section E points to it, baseline row B6 accepts pr-triage.yml or, until a repository moves, the older risk-paths.yml. Callers in other repositories pin a core SHA (ADR-0021), so the old workflow keeps working for them until they move.
  • The invalid fixture repository-surfaces-risk-paths-wrong-path.json now uses .github/risk-paths.yaml as its wrong path (same diagnostic), so risk-paths.yml names only the old caller.

Limits (in the spec): best effort, not proof of the reviewed SHA; a delay of seconds to minutes; a failed run leaves a stale label and a red pr-triage check; a push and a label in the same second can remove a correct label (the error removes, never keeps); review at A, push B, CI on B green, then the label: kept. Exact binding needs the reviewed SHA in the label act (autonomy gate).

ADR number: 0077. A parallel change may take 0076; if this PR merges first, the gap stays or this ADR is renumbered before merge.

Risk tier

Risk tier: 3 — highest. The PR touches these risk paths of .github/risk-paths.json:

  • .github/workflows/pr-triage.yml, .github/workflows/risk-paths-caller.yml (.github/workflows/**): safe because the job keeps permissions: {} at the top, contents: read + pull-requests: write in the job (the same as today), no checkout, no secret but github.token, SHA-pinned setup-node, and only core code at the caller's pinned (in core: base) commit. Under pull_request_target core's local caller resolves to the base branch, so this PR's own workflow change runs only after merge.
  • .github/risk-paths.json: the why of .github/workflows/** renamed; 2 new entries (scripts/lib/pr-triage.mjs, scripts/sync-risk-paths-workflow.mjs). Nothing removed.
  • scripts/lib/risk-paths.mjs: additive API methods and exports; the labeling job is unchanged (test/risk-paths.test.mjs passes).
  • scripts/lib/pr-triage.mjs (new): it only comments and removes ready-for-human; it never adds a label, approves or merges.
  • scripts/check-risk-paths.mjs matches by glob but is unchanged; the sync script it calls now checks 2 blocks.

Docs housekeeping

  • New docs started from their category's TEMPLATE.md
  • Every new doc indexed in docs/README.md
  • Cross-links added in both directions (ADR ↔ design ↔ spec ↔ plan)
  • New significant decision recorded as an ADR first, in this PR
  • New/edited ADRs are fact-only (ADR-0051)
  • Conformance aliases (ADR-0029) untouched

Verification

  • npm run verify: docs, organization, scripts, corrections, risk-paths ("workflow in sync"), 469 tests, 0 failures
  • node scripts/check-docs.mjs green (105 docs, 1985 links)
  • Workflows: every action SHA-pinned, permissions: {}, no checkout; actionlint clean; YAML parses
  • End-to-end smoke: the heredoc step of the generated workflow, run with bash, wrote both files; pr-triage.mjs against a local fake API made GET comments → POST comment → DELETE label for a synchronize with the label, and the levels step read the list at the base SHA
  • git grep -n 'risk-paths\.yml' -- ':!docs/adr' ':!CHANGELOG*' shows only the B6 row and risk-paths spec line 95, both of which accept the old caller during the move

…t (ADR-0077)

Replace the reusable risk-paths workflow with pr-triage.yml. Its levels
step keeps the risk:high behavior of ADR-0068. A new readiness step
removes ready-for-human when the PR head moves after the label, or when
the label comes while CI at the head is not green. It writes 1 marker
comment first, then removes the label, so a re-run repairs a half-done
revocation.

Core's caller uses the local pr-triage.yml with the labeled type. The
gate checks both embedded libraries. Callers that pin the old
risk-paths.yml stay valid at their pinned SHA until they move.
@github-actions github-actions Bot added the risk:high Touches a path in .github/risk-paths.json label Nov 9, 2026
The check-runs API default is filter=latest; make it explicit and state
the policy in the spec: the step counts the latest run of each check
name, as GitHub's checks rollup does, so an older failed run that a
re-run replaced does not revoke ready-for-human. A test pins the query,
and .memory/corrections.jsonl records the guard.
@frostyard-machines

Copy link
Copy Markdown
Contributor Author

Cross-review record

  • Reviewer: openai/gpt-6.1-sol. Coder: github-copilot/claude-sonnet-5.5. Base bb30b9c767d2f8f8bbff6610457393dd2bb4c220.
  • Initial review at ced3dfb3607ba8d4f05fe72cd59e11f798a03125: all 18 files (generated heredoc bodies left out; their libraries, generator and sync tests were reviewed). Not ready, 1 blocking finding: listCheckRuns relied on the API's default filter, and the contract did not say which runs count.
  • Fix 1dcb5bea1ec18657def7a3971f2f93a7f61f7e16: explicit filter=latest (the latest run of each check name, as GitHub's checks rollup counts them; filter=all would let a failed run that a re-run replaced revoke the label), spec section D states the policy, the test pins the query, and .memory/corrections.jsonl records the guard.
  • Re-review 1 at 1dcb5bea1ec18657def7a3971f2f93a7f61f7e16: Ready, Blocking: none.

Revert test

In a scratch worktree at ced3dfb, each behavior removed alone, node --test test/pr-triage.test.mjs:

  • label DELETE removed: 13 targeted tests fail (for example "synchronize with the label writes 1 marker comment, then removes the label", "labeled with a failed check revokes");
  • marker check removed: "a re-run after the comment was written and the delete failed writes no second comment" fails;
  • own pr-triage run no longer left out: "the step's own pr-triage run is left out" fails;
  • 404 no longer accepted on DELETE: "removeIssueLabel gives true on 200, false on 404 and throws on 500" fails.
    At 1dcb5be, filter=latest removed: "listCheckRuns asks for the latest run of each check name …" fails.

@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Reviewed, CI green: ready for Brian to review and merge risk:high Touches a path in .github/risk-paths.json

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants