Skip to content

feat: sort pull requests by levels L1 to L4 (ADR-0078) - #223

Merged
bketelsen merged 2 commits into
mainfrom
lucilla/levels-l1-l4
Nov 9, 2026
Merged

bketelsen merged 2 commits into
mainfrom
lucilla/levels-l1-l4

Conversation

@frostyard-machines

Copy link
Copy Markdown
Contributor

Summary

risk:high is binary: a PR that matches a risk glob gets it, every other PR gets nothing. The owner merges about 70 PRs a day, and the label does not say how much of the rest to read. This PR gives every PR 1 label level:L1 (read every line) to level:L4 (title and CI), so the merge list can be sorted (ADR-0078, new, amends ADR-0068 in part). Idea from Airlock's levels and repository policy. Builds on #220 (the pr-triage.yml workflow).

  • Risk-paths list schema version 2 (docs/specs/risk-paths.md): default_level and a level per glob. A version 1 list stays valid and reads as each glob at L1, default L3, so an unmoved repository has at L1 every PR that has risk:high today.
  • Levels (scripts/lib/risk-paths.mjs): new exports LEVELS, ORG_FLOORS, levelOfFile, levelOfPullRequest, checkRequiredPaths, and listIssueLabels in the API client. A file takes the strictest matching glob, else the default, then the org floor when stricter. A PR takes the strictest file (both names of a rename); 0 files: default; 3000 files: L1.
  • Org floors (a constant; a list cannot change them): L1 for path words secret(s), credential(s), password(s), passwd, signing, keyring(s), keys, gpg, pgp and extensions pem, key, p12, pfx, gpg, asc; L2 for .github/workflows/**, .github/actions/**, .github/risk-paths.json, policies/**, .github/policies/**. Every change to the list is therefore at least L2.
  • Kept API for vendored copies: validateRiskPaths, matchGlob, parseStrictJson, matchFiles keep names and version 1 results. A test holds 22 version 1 fixtures with the exact { ok, errors } of the library before this PR. Only lists whose schema_version is not 1 get a new message (must be the integer 1 or 2).
  • The levels step (runLevelsStep in scripts/lib/pr-triage.mjs, replacing runRiskPathsJob): ratchet (adds the computed level when the PR has none or a looser one, then removes looser level labels; never lowers), risk:high alias at L1 and L2 (never removed), missing level labels: adds only risk:high and writes a warning with the settings command, does not fail and creates no label. A missing risk:high still fails. Summary table: 1 row per L1 or L2 path with its glob or floor.
  • Rule C level check (scripts/check-risk-paths.mjs through checkRequiredPaths): in version 2, each glob that matches the list or the caller is L1 or L2.
  • Core's list in version 2 by the grading rule (spec rule H): default L3; L1 for the settings, ruleset, skills-sync token and organization-contract entries; L2 for workflows, policies, schemas, and the risk-paths and pr-triage gate files.
  • Docs: ADR-0078, risk-paths spec v2 (field table, levels table, rule D examples, rule E step contract, new rules G floors and H grading), PR triage spec rule B, quality loop, docs/org-adrs.md, AGENTS.md, index, and the link-only "Amended in part by" line in ADR-0068.

Not in this PR: core's list entry for scripts/apply-triage-settings.sh (at L1) comes when #221 adds that script; the level labels are created by that script, so until then core's PRs get risk:high and a warning.

Risk tier

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

  • .github/risk-paths.json: schema version 2; levels added; 2 why texts updated; no glob removed. Each glob stays L1 or L2, so risk:high keeps every PR it had.
  • .github/workflows/pr-triage.yml: step renamed, header comments, and the 2 embedded copies re-synced (npm run check:risk-paths: in sync). No if:, permission, action or trigger change. .github/workflows/risk-paths-caller.yml: comment only.
  • scripts/lib/risk-paths.mjs: v2 validation, levels, floors, checkRequiredPaths, 1 read-only API method; the labeling job moves to pr-triage.mjs. Vendored callers use only the kept exports.
  • scripts/lib/pr-triage.mjs: the new levels step. It adds level:* and risk:high and removes only looser level:* labels; it never removes risk:high, never creates a label, approves or merges.
  • scripts/check-risk-paths.mjs: rule C through checkRequiredPaths, same "no glob matches" text for version 1.

Under pull_request_target, core's local caller resolves to the base branch, so this PR's run uses the old step; the new step runs on core PRs after merge.

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"), 540 tests, 0 failures (3 runs in a row)
  • node scripts/check-docs.mjs green (106 docs)
  • Docs-site scaffold tests: 5 pass
  • Workflows: actionlint clean; no action, permission or trigger change
  • Smoke: the "Write the triage scripts" step of the generated workflow, run with bash, wrote both files; the embedded risk-paths.mjs validates core's v2 list and gives README.md L3, scripts/sync-skills.sh L1, .github/workflows/ci.yml L2, docs/adr/x.md L3

Risk-paths list schema version 2 gives each glob a level and the list a
default level; org floors in scripts/lib/risk-paths.mjs put key, secret and
signing paths at L1 and workflows, policies and the list at L2. The levels
step of pr-triage.yml adds level:L1 to level:L4 by a ratchet and keeps
risk:high as the alias of L1 and L2. Version 1 lists stay valid and read as
each glob at L1 with default L3. Core's own list moves to version 2.

Amends ADR-0068 in part.
@github-actions github-actions Bot added the risk:high Touches a path in .github/risk-paths.json label Nov 9, 2026
@frostyard-machines

Copy link
Copy Markdown
Contributor Author

Cross-review: Ready, blocking: none.

  • Reviewer: openai/gpt-6.1-sol (read-only). Coder: github-copilot/claude-sonnet-5.5 (code, tests), claude-opus-5.5 (docs).
  • Reviewed: base 9a54cb8277f449b9c51baf09e477a09aadb38f7d, head f460814739d72b06ff636a13844a0d20fb76a7d0; all 16 changed paths in 2 batches. Excluded from line review: the 2 generated heredoc bodies in pr-triage.yml (their sources and the sync guard were reviewed).
  • Checked: v1 validateRiskPaths results kept; rules D, E, G in levelOfFile, levelOfPullRequest and runLevelsStep (label checks first, add before remove, never lowers, never removes risk:high, missing-label fallback); rule C only in the gate; import and embedding constraints; ADR-0078 facts-only and consistent with the spec and code.
  • Revert test (scratch worktree from the head, 1 behavior removed at a time, node --test test/risk-paths.test.mjs test/pr-triage.test.mjs): no floors gives 34 failures (for example "floor word secret is L1"); no v2 validation gives 32; no risk:high alias gives 10 ("levels adds risk:high for L1"); no ratchet gives 6 ("levels does not loosen: L1 present, computed L3 changes no level label"); no missing-label fallback gives 7 ("levels with a missing level label adds only risk:high, warns and does not fail"); no rule C level check gives 7 ("check-risk-paths fails on a v2 list with the caller at L3").
  • risk:high: the author owns this repository; the PR body names each matched path and why the change is safe.

@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Nov 9, 2026
bketelsen
bketelsen previously approved these changes Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

ready-for-human came off: the head moved from f460814739d7 to 0918026db242 after the label. Run the checks and the review again at the new head, then add the label again.

@github-actions github-actions Bot removed the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Nov 9, 2026
@bketelsen
bketelsen merged commit bc38abd into main Nov 9, 2026
4 checks passed
@bketelsen
bketelsen deleted the lucilla/levels-l1-l4 branch November 9, 2026 11:20
bketelsen pushed a commit that referenced this pull request Nov 9, 2026
…at L1 (#224)

* fix: put scripts/apply-triage-settings.sh back in the risk-path list at L1

The squash merge of #223 rewrote .github/risk-paths.json to schema
version 2 and dropped the entry that #221 added, so the script that
applies the required-checks ruleset and the level labels fell to the
default L3. The entry comes back at L1 (rulesets and settings, risk-paths
spec rule H). A test now names each settings script at L1, and a
corrections line records the lesson.

* test: name the settings-script guard for the administrative scripts it covers

---------

Co-authored-by: frostyard-machines <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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