repositories / smith
smith
There are many coding harnesses - but this one is fast
owned by bugabinga
.github/workflows/adw-gate.yml
Raw# ADW merge-gate — the deterministic check that native auto-merge waits on.
# No Claude here: it just reads the PR's labels and decides mergeability, so the
# LLM reviewers' verdicts (expressed as labels) drive the gate without parsing any
# model output. Required by the `main` ruleset (.github/rulesets/main.json).
#
# Green iff BOTH review verdicts are in (`reviewed` + `security-cleared`) AND no
# blocking label is present. Re-runs on every label change so the gate re-decides
# the moment a reviewer posts its verdict.
#
# The label sets live in .github/adw/gate-labels.sh, shared with the jam
# detector, and are read from the BASE commit — a PR must not get to edit the
# gate that judges it.
name: adw-gate
on:
pull_request:
types: [opened, reopened, synchronize, labeled, unlabeled]
permissions:
contents: read
pull-requests: read
concurrency:
group: adw-gate-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
merge-gate:
name: merge-gate
runs-on: ubuntu-latest
steps:
# Base commit, never the PR head: the gate's own definition must not be
# editable by the branch it is judging. Sparse — only the label source.
- uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.base.sha }}
sparse-checkout: .github/adw
sparse-checkout-cone-mode: false
- name: Evaluate merge readiness from labels
env:
GH_TOKEN: ${{ github.token }}
PR: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
EVENT_ACTION: ${{ github.event.action }}
run: |
set -euo pipefail
# A new head has not been reviewed, whatever the labels currently say.
# adw-review's reset strips the previous head's verdicts, but it races
# this job: both fire on the same `synchronize`, and auto-merge stays
# armed across pushes, so a gate that read labels first could go green
# on a review that never saw this code and let it merge. Refusing on
# the push itself removes the race rather than narrowing it — the
# reviewers' own `labeled` events re-run this job once they re-earn.
if [ "$EVENT_ACTION" = "synchronize" ]; then
echo "::error::new head pushed — verdicts must be re-earned on this commit"
exit 1
fi
# BOOTSTRAP FALLBACK — keep in sync with .github/adw/gate-labels.sh;
# .github/adw/gate-labels.test.sh fails if these two ever disagree.
# A base that predates the shared file (this PR before it lands, a
# revert, an old branch cut) must degrade to the known-good label sets,
# not die on `source` under `set -e`. A gate that cannot read its own
# definition and therefore fails every PR is the jam this workflow
# exists to prevent.
if [ -f .github/adw/gate-labels.sh ]; then
. .github/adw/gate-labels.sh
else
echo "::warning::base lacks .github/adw/gate-labels.sh — using bootstrap defaults"
REQUIRED_GATE_LABELS="reviewed security-cleared"
BLOCKING_GATE_LABELS="risk:high blocked changes-requested needs:info needs:spec needs:prototype"
fi
labels=$(gh pr view "$PR" --repo "$REPO" --json labels -q '[.labels[].name] | join(",")')
echo "labels: [$labels]"
csv=",$labels,"
held=""
for b in $BLOCKING_GATE_LABELS; do
case "$csv" in *",$b,"*) held="$held $b";; esac
done
waiting=""
for p in $REQUIRED_GATE_LABELS; do
case "$csv" in *",$p,"*) ;; *) waiting="$waiting $p";; esac
done
if [ -n "$held" ]; then echo "::error::merge held by label(s):$held"; exit 1; fi
if [ -n "$waiting" ]; then echo "::error::waiting on verdict label(s):$waiting"; exit 1; fi
echo "merge-gate green — reviewed + security-cleared, no blocking labels"