Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 4 additions & 2 deletions .github/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ load-bearing**, not the file the change lives in:
it. `ai-loop`, `ai-loop-paused` and `deep-review` steer automation the same way. Deleting or
renaming one of those disables a control **with no workflow diff at all**, which is the exact
hazard this section exists to name. A new `documentation` label is inert; a label a workflow
reads is middle row.
reads is middle row. `review-converged` is written by `review-converged.yml` for the owner
to read. That workflow reads it back only to decide whether to add or remove it, and no
automation gates on it.
- **Schedules are not uniformly inert.** A `schedule:` on `ai-scan` or the stale sweep decides
when a security control runs. A docs-build cadence does not.
- **`dependabot.yml` ignores are not uniformly inert.** A `semver-major` ignore only declines a
Expand Down Expand Up @@ -532,7 +534,7 @@ jobs (`ci.yml`, `deploy.yml`, `test-deploy.yml`, `visual-regression.yml`, `story
`security-txt-expiry` (`check`), `auto-close-duplicates` (`auto-close`), `claude` (`claude`),
`claude-implement` (`implement`), `bestaxbot-reply` (`respond`), `claude-review` (`review`),
`claude-pr-loop` (`fix` and `verify`), `mcp-registry` (`publish`), `codemod-registry`
(`validate` and `publish`). The command below lists them.
(`validate` and `publish`), `review-converged` (`sync`). The command below lists them.
- **Audit, deliberately, pending a measured allowlist** — none, as of #578. That issue closed the
group by measuring every member instead of guessing for them. They all now **use** the same
allowlist, and the gap between that and what the measurement produced is the part worth
Expand Down
177 changes: 177 additions & 0 deletions .github/workflows/review-converged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
name: Review Converged Label

# Keeps the `review-converged` label in step with PRs that opted into the
# Claude deep review through the `deep-review` label, so the owner can see in
# the PR list which ones are ready for human review. What "converged" means,
# and every decision, lives in scripts/review-converged.mjs behind a node
# --test sibling (rule 9 in .github/CLAUDE.md). This file only triggers it.
#
# PRs labeled `ai-loop` are skipped: claude-pr-loop.yml hands those off with
# `needs-human-review`.
#
# No pull_request or pull_request_target trigger, and no checkout of PR code.
# workflow_run and schedule run the default branch's copy of this file, and
# the job checks out main to run the script. Review bodies are model-authored
# text that the script only matches against fixed patterns and never prints.
#
# Runs no model and holds no secret beyond the job's GITHUB_TOKEN, so it is
# deliberately not gated on vars.AI_LOOP_ENABLED (the house rule for
# zero-Claude workflows, same as auto-close-duplicates.yml). Label writes made
# with GITHUB_TOKEN emit no workflow events, so nothing re-triggers on them.

on:
workflow_run:
# A finished deep review or CI run is what changes the answer. Each entry
# must match that workflow's `name:`, which the test sibling checks: a
# renamed workflow would otherwise stop this trigger without a sound.
workflows:
- Claude Deep Review
- CI
types: [completed]
Comment thread
allxsmith marked this conversation as resolved.
Resolved
schedule:
# Watchdog: thread resolutions and commit statuses (CodeRabbit's among
# them) fire no event this workflow hears, so re-check every hour.
- cron: '47 * * * *'
workflow_dispatch:
# No actor allowlist needed: GitHub only lets users with write access
# dispatch a workflow.
inputs:
pr:
description: 'PR number to check (leave empty to check every open PR)'
required: false
default: ''

# No workflow-level grants. The single job takes exactly what it needs.
permissions: {}

jobs:
sync:
# The script leaves this job's own check run out of the checks it judges,
# matched by this name (OWN_CHECK_NAME). The test sibling holds them equal.
name: Sync review-converged label
# workflow_run: only a run for a PR whose head is in this repository can
# move a label this job writes. A push to main or a fork PR's run is
# skipped before the job starts.
if: |
github.event_name != 'workflow_run' || (
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.head_repository.full_name == github.repository)
# One group for every run, so two jobs can never write the same label at
# once. A per-PR group would need the PR number before the job starts,
# which the schedule trigger does not have.
#
# Declared on the job, not the workflow, and that placement is load-bearing.
# It relies on GitHub evaluating the job's `if:` before the job joins its
# concurrency group, so a run whose job is skipped (CI on a push to main, a
# fork PR's run) never enters the group. At workflow level such a run would
# still join, replace a pending run, and then do nothing.
#
# When GitHub replaces a pending job with a newer one, the newer job sweeps
# every open PR from live data and covers what the replaced one would have
# done. The exception is a dispatch naming a single PR: if it replaces a
# pending sweep, the next sweep catches up, at the latest the hourly one.
#
# No cancel-in-progress: a job is a handful of API calls, and cutting one
# short between its re-read and its label write buys nothing.
concurrency:
group: review-converged
cancel-in-progress: false
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read # check out main to run the script
pull-requests: write # read PRs, reviews and review threads, add and remove the label
checks: read # check runs on the head commit
statuses: read # commit statuses on the head commit
steps:
# Rule 10 (.github/CLAUDE.md): a new job starts at `block`. It runs only
# on workflow_run, schedule and workflow_dispatch, outside the
# untrusted-trigger class.
#
# api.github.com: every REST and GraphQL call the script makes, and the
# API calls actions/checkout makes.
# github.com: actions/checkout's git fetch of main.
#
# Nothing else, because nothing is installed. The script is
# dependency-free (node: builtins and the global fetch) and runs on the
# runner's preinstalled Node, so there is no setup-node step and none of
# the hosts its toolcache-miss path needs. auto-close-duplicates runs the
# same checkout-and-REST shape and reached only these two hosts under
# block (rule 10 cites the run).
#
# Derived from what the steps below reach rather than from a measured
# run of this job. Resolve anything you add here first: an unresolvable
# entry makes the agent revert the firewall while the pre-step still
# exits 0.
- name: Harden runner
uses: step-security/harden-runner@05e31511f85b41b11d1cf0ef85d0992719546e2c # v2.21.0
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
github.com:443

# Asserts the policy the pre-step decided (agent.json) AND that the agent
# actually came up (agent.status, written only once the firewall rules are
# installed). Either alone is a false pass: #487 was the first kind, and an
# unresolvable host in an allowlist is the second.
#
# Scope it honestly: this proves enforcement was armed AT THIS STEP. It does
# NOT prove the policy stays armed — the agent writes `Initialized` and then
# serves, and a later runtime error makes it revert the firewall with both
# files still reading exactly as they do here. Rule 10 in .github/CLAUDE.md
# carries the mechanism and what to check when a run looks wrong.
#
# Placement is rule 10's default (immediately after harden-runner): nothing
# `always()`-guarded keys off this job's outputs, and the job is not itself
# a fail-closed path, so neither placement exception applies.
#
# Linux-only paths (macOS uses /opt/step-security); all runners are ubuntu-latest.
- name: Assert egress policy is enforced
run: |
set -uo pipefail
# harden-runner has several deliberate "install nothing, exit 0" paths
# (StepSecurity unavailable, the skip-harden-runner repo property, a
# container or slim runner). None of them writes agent.json, so name
# that case rather than leaving a bare jq "could not open file".
if [ ! -e /home/agent/agent.json ]; then
echo "::error::harden-runner installed no agent, so nothing is enforcing egress. Usual causes: a StepSecurity outage (its pre-step returns green without installing), the skip-harden-runner repo property, or a container/slim runner. This job holds pull-requests: write and will not run unprotected (#487)."
exit 1
fi
if ! jq -e '.egress_policy == "block"' /home/agent/agent.json; then
echo "::error::effective egress policy is not block — harden-runner downgraded it (#487)."
exit 1
fi
# Poll rather than test once: the pre-step waits only for the file to
# EXIST and gives up after ~9s, while the agent resolves every
# allow-listed host before writing its status, so a cold resolver or a
# long list can leave the file absent or still empty here.
for _ in $(seq 1 30); do
if grep -q '^Initialized' /home/agent/agent.status 2>/dev/null; then
exit 0
fi
sleep 1
done
echo "::error::agent.json reads block but the agent never reported Initialized — the firewall is not up. Check the agent log for 'Reverted changes' (usually an unresolvable allow-listed host)."
exit 1

# main, never a PR branch, whatever ref a dispatch was started from.
- name: Checkout main for the script
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: main
persist-credentials: false

# The PR number reaches the script through the environment, never
# interpolated into the shell, and the script rejects anything that is
# not a positive integer. Empty (every trigger but a dispatch naming a
# PR) means sweep.
- name: Sync the label
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
PR: ${{ inputs.pr }}
run: |
set -euo pipefail
node --version
node scripts/review-converged.mjs --repo="$REPO" --pr="$PR"
11 changes: 10 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,16 @@ green and every AI review thread is resolved.
- **Labels:** `ai-loop` (in the loop), `needs-human-review` (converged or contested — owner
reviews and squash-merges manually; the loop never merges), `ai-loop-paused` (cap/guard
hit). AI-assisted PRs (bestaxbot author or the Claude Code attribution footer) also get
an auto-applied `claude-assisted` provenance label.
an auto-applied `claude-assisted` provenance label. Outside the loop, `review-converged`
marks a `deep-review` PR based on the default branch whose newest deep-review summary is
pinned to the head commit with nothing left open, with every review thread resolved and
every check green. A verify pass reviews no commits, so the PR also needs a fresh deep
review of the head commit with no blocking findings, or a fresh review whose blocking
findings later verify passes resolved, with the pass that resolved the last of them pinned
to the head commit. A stacked PR gets no CI run, so it is out of scope.
`review-converged.yml` adds it and removes it while the PR keeps `deep-review`, not
`ai-loop`, and the default branch as its base. `scripts/review-converged.mjs` holds the
full definition, and an `ai-loop` PR never gets it.
- **Deep review on demand:** a triage+ user can apply the opt-in `deep-review` label to any
same-repo PR to run the Claude deep review on it. Never a fork: the job gate requires the
head repository to be this one, so labelling a fork PR is a no-op: the job
Expand Down
1 change: 1 addition & 0 deletions docs/docs/guides/getting-started/ai-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ PRs authored by the loop move through a small label lifecycle:
| `needs-human-review` | PRs | The loop converged (or hit a disagreement) — awaiting maintainer review/merge |
| `ai-loop-paused` | PRs | The loop hit its iteration cap or a guardrail — a maintainer must intervene |
| `deep-review` | PRs | Opt-in: a triage+ user applies it to run the Claude deep review on any same-repo PR (never a fork — the job gate requires the head repository to be this one, so the label is a no-op there and the job reports skipped). The label is what starts a run: pushes and comments do not, and re-applying a label already present emits no event, so a re-run means removing it and adding it back. Re-applying settles that review's own open threads and raises nothing new; a steer comment starting `deep-review: fresh` asks for a full review of the current code instead, and that choice sticks — once a triage+ `fresh` steer exists, later toggles stay fresh for as long as it is still the newest triage+ steer the run can see. A steer the run cannot read leaves it unfocused and in verify rather than failing, so an unexpected verify pass can mean a lookup that did not resolve rather than a steer nobody posted. Steer it by pre-posting a PR comment starting with `deep-review:` (focus areas, suspected weak spots) — only comments from triage+ authors are used |
| `review-converged` | PRs | Auto-applied to a `deep-review` PR outside the loop whose base is the default branch, when its newest deep-review summary is pinned to the head commit with nothing left open, every review thread is resolved, every check has passed, and `needs-security-review` is absent. A verify pass reviews no commits, so the PR also needs a fresh deep review of the head commit with no blocking findings, or a fresh review whose blocking findings later verify passes resolved, with the pass that resolved the last of them pinned to the head commit. Once it is on, any later push needs another fresh review (a `deep-review: fresh` steer, then a label toggle) before it comes back. A stacked PR gets no CI run and is never labeled. On a PR that still has `deep-review`, not `ai-loop`, and the default branch as its base, the label comes off when any of this stops holding. Removing `deep-review`, adding `ai-loop` or changing the base leaves it, so take it off by hand then. The workflow that sets it runs no model, so `AI_LOOP_ENABLED` does not turn it off |
| `ai-triage` | PRs & issues | Runs one-shot AI triage (related issues + duplicates): automatic on new issues/PRs in auto mode (daily budget), or applied by a triage+ user (budget-exempt; label auto-removes) |
| `claude-repro` | issues | Triage+ user applies it: Claude drafts a candidate reproduction test and github-actions[bot] posts it for a human to run (author-only — CI does not run it). Auto-removes |
| `needs-security-review` | PRs & issues | Auto-applied by the security scanner when it flags an item; blocks every entry point this repo controls — `claude-repro`, `claude-fix`, `@claude`, `@bestaxbot` — until a maintainer removes it (third-party reviewers are not gated) |
Expand Down
Loading
Loading