Skip to content

feat(risk-paths): validator, matcher, reusable workflow and core's own list (T801 t4) - #194

Merged
bketelsen merged 2 commits into
mainfrom
lucilla/t4-risk-paths
Nov 4, 2026
Merged

bketelsen merged 2 commits into
mainfrom
lucilla/t4-risk-paths

Conversation

@frostyard-machines

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

Copy link
Copy Markdown
Contributor

Summary

Plan T801 task t4 (ADR-0068, docs/specs/risk-paths.md). Adds:

  • scripts/lib/risk-paths.mjs: strict JSON parser (fails on a duplicate key), validator (spec field table, deny by default), glob matcher (**, *, ?, {a,b}), a minimal fetch GitHub client, and the labeling job runRiskPathsJob.
  • .github/workflows/risk-paths.yml (on: workflow_call): top-level permissions: {}, job contents: read + pull-requests: write only. It checks out nothing. It embeds the library verbatim in a heredoc and runs it with node --input-type=module. GitHub has no context value for a reusable workflow's own SHA, so a checkout of core at "the pinned commit" is not possible without a duplicate SHA input; embedding keeps all code at the caller's pinned core commit.
  • scripts/sync-risk-paths-workflow.mjs (npm run sync:risk-paths-workflow) and scripts/check-risk-paths.mjs (npm run check:risk-paths, now in verify): validates a list, rule C (the list and the caller are listed), and fails when the embedded copy drifts from the library.
  • Core's caller .github/workflows/risk-paths-caller.yml on pull_request_target (opened, synchronize, reopened, edited), no merge_group, not a required check. It uses the local path ./.github/workflows/risk-paths.yml: under pull_request_target that resolves to the base-branch commit, and a PR cannot pin to a SHA that does not exist yet. The spec now names this as the 1 exception to the SHA pin.
  • Core's .github/risk-paths.json (12 entries; each why starts with a protected_boundaries[].id).
  • The risk-paths surface in repository-surfaces v1 (contract, schema, invariant, fixtures, enrollment spec table). Snowcat is retired (ADR-0064), so no importer requires the 5th surface today.
  • Spec section E and "Derived artifacts" updated to the code; AGENTS.md live-convention bullet; PR template line (a risk:high match is the highest tier).

Job behaviour: pull_request_target only; reads .github/risk-paths.json at pull_request.base.sha through the contents API (404 → "no list on base", pass); strict-parses and validates (invalid → fail, no label); checks GET labels/risk:high on every run with a valid list (missing → fail with a message naming the label, the repository and the gh label create step; never creates it); lists PR files over all pages; ≥ 3000 files → label (fail safe) and a "truncated" note; on a match adds risk:high and writes path, glob and why to the job summary; never removes a label. Untrusted file names are printed only as JSON after a fixed prefix (no ::command:: injection) and escaped in the summary; the token goes only to the API host (a pagination link to another host fails).

Risk tier

Risk tier: high — a new pull_request_target workflow with a pull-requests: write token, new governance paths, and a change to the organization surface contract. This PR touches paths in its own new list (.github/workflows/**, .github/risk-paths.json, organization/contracts/**, organization/schemas/**, scripts/lib/risk-paths.mjs, scripts/check-risk-paths.mjs). Why it is safe: no PR head code runs (no checkout, list at the base SHA, files from the API), permissions are the 2 the spec allows, and the caller is not a required check. The caller does not run on this PR (no caller and no list on base).

Verification

  • make ci: 164 tests pass, 0 fail; ok risk_paths: 12 entries, workflow in sync; docs, organization, bash and corrections gates green.
  • actionlint 1.7.12 (with shellcheck) on all workflow files: no findings. ci.yml unchanged; no ADR changed.
  • Read-only live run against frostyard/core PR 190 with addLabels stubbed: contents, pagination and label reads worked; risk:high exists in core.
  • Revert test (scratch worktree at 34a28ce, removed afterwards):
    • matchGlob made to return false: node --test test/risk-paths.test.mjs → 66 tests, 16 fail (spec table rows, braces/**, dotfile, case, matchFiles, job match, sync check, check-risk-paths).
    • The job reads the list at pull_request.head.sha instead of the base: 9 fail, including "job reads the list at the base SHA, never at the head SHA".
  • Every action SHA-pinned (actions/setup-node@49933ea… # v4.4.0), permissions: {}, no checkout (ADR-0021).

Docs housekeeping

  • Cross-links: spec ↔ enrollment spec; ADR-0068 unchanged (immutable).
  • Conformance aliases untouched (AGENTS.md edited at the canonical path).

After merge

  • Core's caller runs on every core PR. risk:high already exists in core.
  • Unblocks t5 (updex) and t6 (snosi): their callers pin frostyard/core/.github/workflows/risk-paths.yml@<merge SHA>.

Cross-review

  • Coder: github-copilot/claude-opus-5.5. Reviewer: openai/gpt-6.1-sol (read-only), base 20fd8a3.
  • Round 1 at 34a28ce: Not ready, 2 blocking spec mismatches: (1) the summary showed 500 matches while section E said "each"; (2) the 256 brace-expansion limit was not in section A. Fixed in cc39d10: the spec states both; the summary names the count it omits and points to the job log, which lists every match; a new test with 503 matches pins it.
  • Re-review 1 at cc39d10: Ready, Blocking: none.
  • At cc39d10: make ci 165 pass, 0 fail; actionlint clean; CI green (docs-gate, fleet-conventions, scaffold-e2e). The revert tests above were at 34a28ce; cc39d10 changes only the summary text, the spec and 1 added test.

Rebase after #193 and #191

  • Rebased on 182a399 (main after t8 feat(scripts): weekly corrections report (T801 t8) #193 and t9 feat(scripts): instruction lint and the blind-review prompt (T801 t9) #191). Head: 4651509. The only conflict was the package.json scripts block: kept check:instructions and report:corrections from main, and added check:risk-paths and sync:risk-paths-workflow. git range-diff shows no other change. The fix has no logic change, so the re-review at cc39d10 (Ready) stays valid per the cross-review policy.
  • At 4651509: make ci 200 pass, 0 fail; ok risk_paths: 12 entries, workflow in sync; actionlint clean; CI green (docs-gate, fleet-conventions, scaffold-e2e).

@frostyard-machines frostyard-machines added risk:high Touches a path in .github/risk-paths.json ready-for-human Reviewed, CI green: ready for Brian to review and merge and removed ready-for-human Reviewed, CI green: ready for Brian to review and merge labels Nov 4, 2026
…n list (T801 t4)

Adds scripts/lib/risk-paths.mjs (strict JSON, validation, glob matcher,
API client, labeling job), its tests, the reusable workflow
.github/workflows/risk-paths.yml (on: workflow_call) that embeds the
library verbatim with no checkout, core's caller on pull_request_target,
core's .github/risk-paths.json, the gate npm run check:risk-paths, and the
risk-paths surface in repository-surfaces v1 (ADR-0068).
…e limit; test the cap

Cross-review round 1: the summary shows 500 matches and the count of the
rest, and the job log lists every match; the spec now says so, and a test
with 503 matches pins it. Section A names the 256-expansion brace limit.
@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Nov 4, 2026
@bketelsen
bketelsen merged commit 1b02a12 into main Nov 4, 2026
3 checks passed
@bketelsen
bketelsen deleted the lucilla/t4-risk-paths branch November 4, 2026 15:04
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