Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Generated from REVIEW.md › High-risk paths: `node scripts/risk-tier.mjs codeowners > .github/CODEOWNERS`.
# test/risk-tier.test.mjs fails when the two differ. GitHub requests Tom's review
# from it. It enforces nothing: GitHub's code-owner rule needs at least one
# required approval, which would put Tom on every PR, so Risk tier is the gate.
# Rows that count only when a file is deleted (the tests) can't be said here.
/.github/** @tomdebres
/scripts/risk-tier.mjs @tomdebres
/scripts/publish-check.mjs @tomdebres
17 changes: 17 additions & 0 deletions .github/high-risk-paths.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# High-risk paths

A pull request that touches one of these, or that comes from outside, needs
the maintainer's approval of its head commit before it can merge: the "Risk
tier" check (`scripts/risk-tier.mjs`) reads this table, and
`.github/CODEOWNERS` is generated from it (`node scripts/risk-tier.mjs
codeowners > .github/CODEOWNERS`). Globs are from the repo root; "deleted" rows
count only when a file is deleted or renamed away.

<!-- high-risk-paths -->
| Path | Counts | Why |
|---|---|---|
| `.github/**` | any | CI, review, Risk tier, Publish check, CODEOWNERS and this table: the gates themselves. |
| `scripts/risk-tier.mjs` | any | The matcher Risk tier runs. |
| `scripts/publish-check.mjs` | any | What keeps private details out of this public repo. |
| `test/**` | deleted | A deleted test is a weaker spec. |
<!-- /high-risk-paths -->
39 changes: 32 additions & 7 deletions .github/workflows/claude-code-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ name: Claude Code Review
# keeps the rounds (round 1 the whole diff, later rounds the new commits, three
# at most) and decides the check: red only for an open Important finding or the
# round cap. Every other failure (token, outage, timeout, turn limit) passes
# with a warning, so an outage never blocks every merge.
#
# devkit's own reviewer (devkit a7a7482, itself bodyops's), copied from heerr
# with only the repo name in the prompt changed; scripts/review-round.mjs and
# test/review-round.test.mjs are devkit's, verbatim.
# with a warning, so an outage never blocks every merge. A fork's
# scripts/review-scope.mjs, if it has one, tells upstream's part of an upstream
# merge from the fork's: a bug in upstream's own code is Upstream, never red.
on:
pull_request:
types:
Expand Down Expand Up @@ -44,6 +42,32 @@ jobs:
continue-on-error: true
with:
node-version: '22'
# A public repo keeps REVIEW.md in its private notes repo, <repo>-notes
# (devkit PLAN.md › Public repos), read with the NOTES_KEY secret, a
# read-only deploy key there. Only REVIEW.md is kept, and the rest goes
# before the review starts, so nothing else of the notes can reach a
# public comment. A fork's PR gets no secret, and no review either.
- name: Notes key
id: notes
continue-on-error: true
env:
KEY: ${{ secrets.NOTES_KEY }}
run: '[ -z "$KEY" ] || echo "repo=${GITHUB_REPOSITORY}-notes" >> "$GITHUB_OUTPUT"'
- name: Private notes
if: steps.notes.outputs.repo
continue-on-error: true
uses: actions/checkout@v4
with:
repository: ${{ steps.notes.outputs.repo }}
ssh-key: ${{ secrets.NOTES_KEY }}
path: .notes
persist-credentials: false
- name: REVIEW.md from the notes
if: steps.notes.outputs.repo
continue-on-error: true
run: |
if [ ! -e REVIEW.md ] && [ -f .notes/REVIEW.md ]; then cp .notes/REVIEW.md REVIEW.md; fi
rm -rf .notes
- name: Plan the round
id: plan
continue-on-error: true
Expand All @@ -58,7 +82,7 @@ jobs:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
github_token: ${{ github.token }}
prompt: |
You are the bug reviewer for nockmark pull request #${{ github.event.pull_request.number }}. Report bugs only.
You are the bug reviewer for ${{ github.event.repository.name }} pull request #${{ github.event.pull_request.number }}. Report bugs only.

1. Read REVIEW.md first. "What failure looks like here" is what to look for in this repo; "Findings" is how to tag.
2. The scope of this round is at the end. Review only that; anything else in the PR is context.
Expand All @@ -68,13 +92,14 @@ jobs:
- Important: in code this PR adds or changes, and it would reach a user, the data or a ship: wrong behaviour, a crash, lost or corrupted data, a security hole, or a REVIEW.md rule broken.
- Nit: a real bug, but minor or unlikely.
- Pre-existing: a bug in code this PR didn't change. Never Important.
- Upstream: only on a PR the scope below says merges the repo's upstream: a bug in upstream's own changes. Listed, never blocks. Git then checks every Important and Upstream finding against the scope, so put each where its cause is.
6. Don't post comments or reviews yourself. Answer only with the JSON the output schema asks for: file is repo-relative, line is in the PR head's version, title is one line, detail is the failing scenario in a sentence or two. List each earlier finding's id under resolved or still_open.

${{ steps.plan.outputs.context }}
claude_args: |
--max-turns 30
--allowedTools "Read,Grep,Glob,Bash(git diff:*),Bash(git log:*),Bash(git show:*)"
--json-schema '{"type":"object","properties":{"summary":{"type":"string"},"findings":{"type":"array","items":{"type":"object","properties":{"severity":{"type":"string","enum":["Important","Nit","Pre-existing"]},"file":{"type":"string"},"line":{"type":"integer"},"title":{"type":"string"},"detail":{"type":"string"}},"required":["severity","file","title","detail"]}},"resolved":{"type":"array","items":{"type":"string"}},"still_open":{"type":"array","items":{"type":"string"}}},"required":["summary","findings","resolved","still_open"]}'
--json-schema '{"type":"object","properties":{"summary":{"type":"string"},"findings":{"type":"array","items":{"type":"object","properties":{"severity":{"type":"string","enum":["Important","Nit","Pre-existing","Upstream"]},"file":{"type":"string"},"line":{"type":"integer"},"title":{"type":"string"},"detail":{"type":"string"}},"required":["severity","file","title","detail"]}},"resolved":{"type":"array","items":{"type":"string"}},"still_open":{"type":"array","items":{"type":"string"}}},"required":["summary","findings","resolved","still_open"]}'
- name: Verdict
if: ${{ !cancelled() }}
env:
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/publish-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Publish check

# A public repo carries no agent working docs, personal emails in commit
# metadata, secrets, or self-hosted runners: scripts/publish-check.mjs checks the
# tree and the new commits of each PR and of each push to main (a web merge or
# edit included). From devkit's templates/publish-check.yml (kit-install
# --public). Its personal patterns are private, so here it runs without them;
# the pre-push hook on Tom's Mac (devkit bin/notes-link) runs it with them.
# Read-only: it checks out and reads, and runs nothing from the PR but the
# script, which a PR from outside can't merge without Tom (Risk tier).
on:
pull_request:
push:
branches: [main]

concurrency:
group: publish-check-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
publish-check:
# Branch protection requires this check by its name: change both together.
name: Publish check
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Check
env:
BASE: ${{ github.event.pull_request.base.sha || github.event.before }}
HEAD: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
case "$BASE" in
''|0000000000000000000000000000000000000000) range="" ;;
*) range="--range $BASE..$HEAD" ;;
esac
node scripts/publish-check.mjs --no-personal $range .
46 changes: 46 additions & 0 deletions .github/workflows/risk-tier-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Risk tier on review

# A review can be Tom's approval (or its dismissal), but the "Risk tier" check
# is risk-tier.yml's pull_request_target run. A red Risk tier from one run
# blocks the merge whatever another run says, so a review reports none of its
# own: Tom's approval once passed in its own run while the earlier red stayed
# (devkit PLAN.md › Agent identity). This reruns the newest Risk tier run on the
# head commit, once it has finished, when its conclusion disagrees with the
# verdict now. The rerun decides with main's code as always; this job's own
# result is no verdict. pull_request_review has no _target variant, so this
# file is the PR's copy, but the script is main's. From devkit's
# templates/risk-tier-review.yml.
on:
pull_request_review:
types:
- submitted
- dismissed

concurrency:
group: risk-tier-review-${{ github.event.pull_request.number }}
cancel-in-progress: true

permissions:
actions: write
contents: read
pull-requests: read
issues: read

jobs:
rerun:
name: Rerun Risk tier
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Rerun if the review changed the verdict
env:
GH_TOKEN: ${{ github.token }}
PR: ${{ github.event.pull_request.number }}
run: node scripts/risk-tier.mjs rerun --repo "$GITHUB_REPOSITORY" --pr "$PR"
49 changes: 49 additions & 0 deletions .github/workflows/risk-tier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Risk tier

# Fails while a PR touches a high-risk path (REVIEW.md › High-risk paths)
# without Tom's approving review of its head commit, which GitHub requests from
# him (CODEOWNERS). From devkit's templates/risk-tier.yml.
# pull_request_target runs main's copy of this workflow, and the checkout is
# main whatever the PR's base, so REVIEW.md and scripts/risk-tier.mjs are main's
# too and a PR can't loosen its own gate. Nothing from the PR is checked out or
# run: the changed files come from the API. "edited" covers a PR retargeted
# onto main. A review doesn't run this: risk-tier-review.yml reruns this run
# instead, as a second "Risk tier" of its own couldn't clear this one's red.
# The PR that adds this file isn't gated by it: main has no copy to run yet.
on:
pull_request_target:
types:
- opened
- synchronize
- reopened
- edited
- ready_for_review

concurrency:
group: risk-tier-${{ github.event.pull_request.number }}
cancel-in-progress: true

permissions:
contents: read
pull-requests: write
issues: write

jobs:
risk-tier:
# Branch protection requires this check by its name: change both together.
name: Risk tier
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Check
env:
GH_TOKEN: ${{ github.token }}
PR: ${{ github.event.pull_request.number }}
run: node scripts/risk-tier.mjs check --repo "$GITHUB_REPOSITORY" --pr "$PR"
Loading
Loading