fix(review-swarm): validate candidate without self-judging
Summary
Follow-up to merged #259 (39dd21345abadfa21d55f57fdc8a6fe85e06b824). Its failed review check was not evidence about the retry-delay change: the immutable gate launched main:workflows/review-swarm.yaml, so the candidate definition was never exercised.
This PR keeps that trusted execution model and makes the boundary explicit:
- pin the trusted checkout to
github.event.pull_request.base.sha, so the judge cannot move while a run is live; - add a main-owned candidate-definition validator that parses the PR-head workflow and checks the load-bearing retry/timeout invariants;
- keep the cloud review run pointed at the trusted base definition, so a candidate cannot self-approve;
- add hermetic pass/reject tests for valid YAML, short backoff, timeout drift, and malformed YAML.
The candidate validator is a contract check, not a candidate verdict. Runtime execution of a changed review definition becomes authoritative only after that definition is merged and the main-owned gate runs it.
Evidence
bash .github/workflows/scripts/swarm-definition.test.sh— all pass../.github/workflows/scripts/swarm-definition.sh workflows/review-swarm.yaml workflows/review-swarm.yaml—CANDIDATE_DEFINITION_OK;retryDelayMs=60000;timeoutMs=3600000../.github/workflows/scripts/swarm-gate.test.sh— 21 passed, 0 failed.- Ruby/Psych YAML preflight and
git diff --cached --checkpass. - Veto diff review: PASS; code 93/100; security 97/100; no secrets findings.
Do not merge until this PR's checks and independent review are green at exact head.
[!NOTE]
Medium Risk
Changes merge-gate CI behavior and trusted checkout pinning; mistakes could block merges or weaken definition checks, but the design is fail-closed with main-owned tests.
Overview
Pins the immutable gate to the PR base SHA instead of a moving main ref, so the trusted scripts and workflows/review-swarm.yaml used to judge a run cannot change mid-flight.
When a PR actually patches workflows/review-swarm.yaml, a new Validate candidate review definition step runs a main-owned swarm-definition.sh contract check (Ruby/Psych) on the PR-head file against the base definition—enforcing retry strategy, minimum 60s retryDelayMs, and unchanged timeoutMs—while the cloud swarm still launches ../gate-files/workflows/review-swarm.yaml, so the candidate never self-approves.
The gate self-test step now verifies Psych is available, runs swarm-definition.test.sh from the pinned checkout, and sparse-checkout includes the new scripts; PR #265 can bootstrap with a notice until the validator exists on base.
Reviewed by Cursor Bugbot for commit 50c5ccdb527b9cea5385a2026971f958b4b379c6. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
Fixes review-swarm candidate validation so PRs that modify workflows/review-swarm.yaml are checked against the trusted base instead of letting the candidate judge itself. The gate now checks out the PR's base SHA (previously a moving main ref) and runs a new main-owned validator that enforces the retry strategy, a ≥60s retryDelayMs, and a timeoutMs matching the base, while the actual review run still launches the trusted base definition.
Migration
- The introducing PR can bootstrap with a notice until the validator lands on
main; afterwards a missing validator or invalid candidate YAML fails the gate closed.
Agent Relay sessions
codexsession01a08b61· opened viagh pr create· last active 2026-09-10