fix(review-swarm): harden wrapper and terminal diagnostics

Closed
KH
2mo ago
+516-26

Replacement stack

This is the coherent replacement for the closed stacked PRs:

  • #265 is already in main as merge 4d08f9a.
  • Replaces #285 (wrapper guard / trusted helper path); its valid findings are addressed, including rename detection via previous_filename, explicit base-owned documentation, deterministic guard tests, and the gate-files sparse-checkout/preflight correction.
  • Replaces #283 (terminal diagnostics); malformed/empty/unsupported payloads and missing summaries are handled with fixed safe diagnostics, legacy .result.error / .error reporting remains available, and deterministic tests cover the safety boundary.

Important rollout prerequisite

The immutable review-swarm-wrapper-guard.yml intentionally rejects any candidate touching .github/workflows/review-swarm.yml. This PR necessarily changes that base-owned wrapper to make the trusted diagnostic helper available in the sparse checkout and to run its tests before cloud launch. A guard-red result on this PR is therefore expected and is the required human/base-owned bootstrap step; do not weaken or bypass the guard. After this change is human-landed, the next ordinary candidate PR is the live green review-swarm proof prerequisite.

Checks

  • bash .github/workflows/scripts/swarm-status-diagnostic.test.sh
  • bash .github/workflows/scripts/swarm-wrapper-guard.test.sh
  • bash .github/workflows/scripts/review-swarm-workflow.test.sh
  • bash .github/workflows/scripts/swarm-definition.test.sh
  • bash .github/workflows/scripts/swarm-gate.test.sh
  • shellcheck -S warning .github/workflows/scripts/*.sh
  • actionlint .github/workflows/review-swarm.yml .github/workflows/review-swarm-wrapper-guard.yml
  • exact extracted wait-step probe from pr-head with gate-files helper: passed and emitted the quota reason
  • Veto security review: 0 findings, score 94; no secrets scan findings

No merge performed.


[!NOTE]
High Risk
Changes CI merge-gate enforcement, protected-path policy, and bootstrap behavior; incorrect rollout could block merges or weaken the candidate-vs-base trust boundary until base-owned landing completes.

Overview
Hardens the review-swarm merge gate so candidates cannot edit or rename base-owned control-plane files, and makes terminal swarm status diagnostics observability-only with fixed safe messages.

The wrapper guard now blocks touches to a full protected path list (workflows, gate scripts, and their tests), not only review-swarm.yml, still using both filename and previous_filename. It writes guard_result (clean / rejected / error) so the guard workflow can surface intentional rejection vs GitHub API/infrastructure failure in separate ::error:: steps.

review-swarm.yml expands the immutable gate-files sparse checkout and preflight to include the diagnostic and guard helpers plus new deterministic tests (swarm-status-diagnostic, swarm-wrapper-guard, review-swarm-workflow), with PR #297 bootstrap notices where the base does not yet contain those files. The wait step calls the base-owned diagnostic from pr-head with explicit checks if the helper is missing or regresses.

swarm-status-diagnostic.sh always exits 0 on empty, malformed, or unsupported payloads (caller still fails on non-completed swarm), avoids echoing unsafe input, and keeps structured failure.phase/code plus legacy error text with injection mitigations.

Adds docs/review-swarm.md documenting the trust boundary and how to run the local contract tests.

Reviewed by Cursor Bugbot for commit 6a3da0ae6eb77d704d0b5876193d71f696ea604c. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Hardens the review-swarm merge gate so candidates can't alter base-owned guard files, and turns malformed status responses into safe fixed diagnostics instead of opaque failures.

  • The wrapper guard now blocks add/edit/delete/rename of a protected control-plane set (wrapper, guard workflow, helper scripts, and their tests) via both filename and previous_filename.
  • Guard outcomes are explicit (rejected/error/clean), so API or checkout failures surface as infrastructure errors, not candidate rejections.
  • swarm-status-diagnostic.sh is observability-only: empty, malformed, or unsupported payloads always exit 0 with fixed messages; legacy .result.error/.error text is still emitted summary-safely.
  • Preflight runs new deterministic tests for the guard, diagnostic, and workflow contracts, verifies the executable helper, and docs/review-swarm.md documents the trust boundary.
  • This PR changes base-owned guard files and will be rejected by the guard; a human must land it as the #297 bootstrap before the next candidate can pass.

Agent Relay sessions

  • codex session 01a08d50 · opened via gh pr create · last active 2026-09-10