fix(review-swarm): expose safe failure diagnostics - #283
khaliqgant wants to merge 5 commits into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe review workflow now uses the PR base SHA as its trusted gate, validates changed swarm definitions with new Bash and Ruby checks, tests validator behavior, and reports swarm failures through structured JSON fields. ChangesTrusted workflow validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant PR as Pull request
participant Workflow as review-swarm.yml
participant Base as Immutable base checkout
participant Validator as swarm-definition.sh
participant Swarm as Review swarm
PR->>Workflow: Modify review-swarm.yaml
Workflow->>Base: Checkout base SHA
Workflow->>Validator: Validate candidate against trusted definition
Validator-->>Workflow: Return validation result
Workflow->>Swarm: Run review with base definition
Swarm-->>Workflow: Return status payload
Workflow-->>PR: Write structured failure diagnostic
Merge Risk: 🟠 High · up to The new gate filters failure diagnostics and validates selected swarm policy fields, but a candidate can preserve those fields while changing other executable graph behavior. That could weaken later review gates, so the validation gap should be resolved before merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. I’m a rabbit guarding the gate, Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff5f5c5240
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # The introducing PR cannot run a helper that is not on its base | ||
| # yet. Once this PR lands, absence is a deletion or checkout bug | ||
| # and must fail closed like the verdict self-test above. | ||
| if [ "$REVIEW_PR_NUMBER" = 265 ]; then |
There was a problem hiding this comment.
Use the actual PR number for validator bootstrap
At this exact head the introducing change is PR #283, while base commit 4dd9277 does not contain swarm-definition.test.sh; consequently this condition is false and the self-test exits with “main-owned candidate validator is missing” before the swarm launches. The duplicate bootstrap check near line 126 has the same stale 265 value, so both checks must recognize the actual introducing PR.
Useful? React with 👍 / 👎.
| # The base SHA is the immutable definition this PR is judged by. A | ||
| # moving `main` ref could change the judge while this run is live. | ||
| ref: ${{ github.event.pull_request.base.sha }} |
There was a problem hiding this comment.
Keep the wrapper gate from judging its own changes
Checking out the inner relayflow definition from the base SHA does not make this GitHub Actions wrapper immutable: this PR also changes .github/workflows/review-swarm.yml, whose candidate version supplies the bootstrap checks, launch/wait logic, and final enforcement for its own pull_request run. A candidate can therefore weaken or bypass the wrapper that judges it; this wrapper change needs validation by a gate definition outside the candidate-controlled workflow.
AGENTS.md reference: AGENTS.md:L34-L34
Useful? React with 👍 / 👎.
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
e837b32 to
f27529b
Compare
Review swarm: maintainabilityMaintainability Review: PR #283PR: fix(review-swarm): expose safe failure diagnostics SummaryThis PR refactors FindingsF1: Implicit token validation contract has no explanationLocation: The jq filter defines a
A maintainer reading this in six months will see sanitization but not understand what they must preserve when modifying the script. The prompt says "expose safe failure diagnostics" but the code does not document what "safe" means here or what would be unsafe. Impact: A future change could weaken the validation (e.g., by removing it as "unnecessary") without understanding that it's a security boundary. The validation appears to prevent shell injection or GitHub Actions injection, but this is implicit, not stated. F2: Unclear what input structure is expectedLocation: The jq filter expects a JSON response with a specific structure: Or possibly: The old code extracted from
Looking at Impact: A maintainer cannot safely modify this script without understanding the input contract. If the API response changes, they won't know if the script should adapt or if the API change is breaking. F3: Silent failure handling obscures problemsLocation: The jq command uses
The script silently outputs an empty string or Impact: When the diagnostic script breaks, it will fail silently. Debugging will require manually reproducing the failure case. A comment explaining that this is intentionally fail-open (for observability, not correctness) would clarify the design choice. F4: The relationship between old error extraction and new failure extraction is unclearLocation: The old code extracted
The commit message says "expose safe failure diagnostics" but doesn't explain what changed in the data model or why. Impact: A maintainer debugging a missing diagnostic won't know if they should expect the old format, the new format, or both. The migration path is invisible. F5: Token validation logic is not reusable or testableLocation: The token validation regex is embedded in a jq filter. If this validation needs to be applied elsewhere (e.g., in other diagnostic scripts, in the swarm-post script, in the swarm-prepare script), it will be duplicated with potential drift. Additionally, there is no test demonstrating that:
Impact: Correctness depends on a regex that has no test coverage and no usage examples. A future maintainer cannot validate changes without manually constructing test cases. F6: Missing failure handling for GITHUB_STEP_SUMMARYLocation: The script writes to
If This would break Impact: Running this script in a test environment or outside GitHub Actions will fail with an unclear error. The diagnostic is not essential to correctness (the caller uses F7: The output format change may break downstream consumersLocation: The old output was: The new output is: If any automation, log parser, or human process depends on the old format, this is a breaking change. The PR description and commit message do not indicate whether this was audited. Impact: Unknown downstream breakage. A maintainer cannot assess the blast radius of this change without searching for all consumers of stderr or Additional observations (not blocking)
VerdictThe change improves structure (moving from free-text to structured diagnostics) but introduces multiple maintainability hazards:
A stranger reading this in six months would not be able to:
Recommendations to pass
Overall assessmentThe code will work as written, but it is not safely maintainable. The implicit contracts, silent failures, and undocumented validation make it fragile for future changes. REVIEW_FAILED |
Review swarm: historyPR #283 — history reviewReviewed head: Input provenance and environmentThe requested
The supplied diff matches HEAD's parent-to-head patch byte for byte (capture below). The empty preceding commit, Historical assessment
Captured evidenceCommands below were executed for this review. These are static history/source checks and a small diagnostic fixture probe, not a live swarm, full test suite, or mutation verification. The fixture's Command: git log --oneline -40Captured stdout/stderr: Exit status: 0 Command: git show -s --format=full 6077688eCaptured stdout/stderr: Exit status: 0 Command: git show --format=short 8a8ece9b -- .github/workflows/review-swarm.ymlCaptured stdout/stderr: Exit status: 0 Command: git show --stat --oneline 794501eaCaptured stdout/stderr: Exit status: 0 Command: git diff HEAD^ HEAD -- .github/workflows/scripts/swarm-status-diagnostic.sh | cmp - .review-target/pr.diffCaptured stdout/stderr: Exit status: 0 Command: sed -n '4544,4556p;9266,9283p;9303,9324p;10053,10080p' ops/DRIVE-LOG.mdCaptured stdout/stderr: Exit status: 0 Command: sed -n '255,290p' .github/workflows/review-swarm.ymlCaptured stdout/stderr: Exit status: 0 Command: python3 - <<'PROBE'
import subprocess, tempfile, os
p='.github/workflows/scripts/swarm-status-diagnostic.sh'
for label,payload in [('structural','{"failure":{"phase":"queue","code":"queue_timeout"}}'),('legacy','{"result":{"error":"Total CPU limit exceeded. Maximum allowed: 250."}}'),('non-object','[]'),('invalid-token','{"failure":{"phase":"queue","code":"::error:: injected"}}'),('malformed-json','{')]:
with tempfile.NamedTemporaryFile() as summary:
r=subprocess.run(['bash',p,payload],text=True,capture_output=True,env={**os.environ,'GITHUB_STEP_SUMMARY':summary.name})
print(label, 'exit='+str(r.returncode), 'stdout='+repr(r.stdout), 'stderr='+repr(r.stderr), 'summary='+repr(open(summary.name).read()))
PROBECaptured stdout/stderr: Exit status: 0 No blocking history finding. The loss of legacy free-form diagnostics and the unverified producer contract are disclosed above; the PR-body wording should be narrowed. REVIEW_PASSED |
Review swarm: structureNo fresh transcript was produced for run |
Review swarm: FAILED
Cloud run: |
8a8ece9 to
058e672
Compare
Summary
Dependency
This PR extends #265’s candidate-validation workflow and is intentionally based on its branch until #265 merges. The main-owned validator required by the immutable gate is introduced there; targeting
maincaused the gate to correctly fail closed before launch.Validation
Note
Medium Risk
Changes privileged CI behavior (failure reporting and a new pull_request_target gate) for the merge-blocking review swarm, though diagnostics are intentionally constrained and the guard only blocks edits to the wrapper workflow.
Overview
Replaces raw swarm failure logging in
review-swarm.ymlwith a base-ownedswarm-status-diagnostic.shthat prints only an allowlisted structural identity (phase/codetokens from.failure) to stderr and the job summary, avoiding untrusted agent/provider text in Actions logs.Adds a
pull_request_targetwrapper guard (review-swarm-wrapper-guard.yml+swarm-wrapper-guard.sh) that checks out the PR base and fails closed if the candidate PR touches.github/workflows/review-swarm.yml, so the review wrapper cannot be relaxed from the PR under review.Reviewed by Cursor Bugbot for commit f27529b. Bugbot is set up for automated code reviews on this repo. Configure here.