Orchestrate
Full review-test-fix-push-review loop until convergence with compliance report
---
description: "Full review-test-fix-push-review loop until convergence with compliance report"
allowed-tools:
["Bash", "Glob", "Grep", "Read", "Write", "Edit", "Agent", "Skill"]
---
# Orchestrate — Automated Review-Fix-Push-Review Convergence Loop
Run the full quality loop until zero changes across all gates: local review, tests, formatting, push, and Gemini review. Produces a session report with every comment's status and industry compliance percentage.
## MANDATORY EXECUTION RULES — READ FIRST
These rules are non-negotiable and OVERRIDE any judgment about efficiency or shortcuts:
1. **ALWAYS run /review every iteration** — spawns 2 fresh agents on ALL changes. Never skip. Never do "quick delta check."
2. **ALWAYS run ALL 3 test suites** — `./gradlew test`, `./gradlew :integration-tests:test`, `./gradlew e2e`. Never skip even if "nothing changed."
3. **NEVER accept or defer ANY comment** — dev phase means fix everything. No "accepted," no "out of scope," no "good enough."
4. **ALWAYS review ALL changes** — every iteration reviews the full diff `main...HEAD`, not just the delta since last review.
5. **ALWAYS wait for and address Gemini review** — after push, wait 270s, poll, fix all findings.
6. **NEVER terminate early** — loop until zero changes in a full pass, or hit max 3 iterations.
7. **ALWAYS produce the final report** — comment ledger + compliance dashboard + accepted/out-of-scope table (must be empty).
8. **ALWAYS write the report to a file** — `docs/review-reports/{issue}-session-{date}.md` for persistence.
## Step 0: Initialize
1. Determine the Linear issue number from the branch name or argument (e.g., `APP-35`).
2. Initialize the comment ledger — an empty list that accumulates every finding across all iterations:
```
commentLedger = []
iteration = 0
converged = false
startTime = now
agentsSpawned = 0
geminiRounds = 0
```
3. Record the start time for the session report.
4. **Record the rollback checkpoint** — save the current commit SHA so we can revert if the loop makes things worse:
```bash
BASELINE_SHA=$(git rev-parse HEAD)
```
If the loop hits max iterations without converging, offer to revert to this SHA.
## Step 1: Local Review (every iteration)
Run these in parallel to gather context:
```bash
git log --oneline main..HEAD
git diff main...HEAD --stat
git diff main...HEAD --name-only
Then invoke /review via the Skill tool. This spawns:
- Agent A: Trading Engine Constraint Checker (10 blocking rules including
final var) - Agent B: General Code Quality Review
Both agents review ALL changes (main...HEAD), not just the delta.
Collect all findings. For each finding, append to the comment ledger:
{ iteration, source: "LocalReview-AgentA" or "LocalReview-AgentB",
severity: "blocking" or "critical" or "medium" or "low",
file, line, description, status: "OPEN", fixCommit: null }
If there are findings: fix ALL of them (edit the files), then run ./gradlew spotlessApply.
Step 2: Test Suites — ALL THREE, NO EXCEPTIONS
MANDATORY: Run ALL 3 test suites EVERY iteration. No exceptions. No "already passing." No "UP-TO-DATE means skip." No "only markdown changed." Execute each command and report the actual result.
./gradlew test
If failures: fix them, add to ledger (source: "UnitTest"), run ./gradlew spotlessApply, commit, and restart from Step 1.
./gradlew :integration-tests:test
If failures: fix them, add to ledger (source: "IntegrationTest"), run ./gradlew spotlessApply, commit, and restart from Step 1.
./gradlew e2e
If failures: first run ./gradlew e2eClean, then retry. If still failing, fix, add to ledger (source: "E2E"), commit, and restart from Step 1.
NEVER skip any suite. NEVER claim a suite was "already run." Execute all three and report pass/fail with actual output.
Step 2b: Compliance Score — MEASURED, NEVER GUESSED
After tests pass each iteration, run the FULL compliance measurement. NEVER estimate or guess a score. ALWAYS execute every scan command and report actual numbers.
Run these exact commands and report the actual output:
── Tools Run Every Iteration ─────────────────────────────────
TOOL │ PURPOSE │ CATEGORY
──────────────────────────────────┼────────────────────────────┼──────────
Skill(/review) │ 2 fresh agents, 10 rules │ All
./gradlew test │ Unit tests │ Cat 1
./gradlew :integration-tests:test │ Integration tests │ Cat 1
./gradlew e2e │ Full 3-node cluster E2E │ Cat 1
./gradlew spotlessApply │ Auto-format │ Cat 8
./gradlew spotlessCheck │ Verify format (must pass) │ Cat 8
grep -rEn (determinism) │ Cluster non-determinism │ Cat 4
grep -rEn (collections) │ java.util.* in hot-path │ Cat 5
grep -rl (logging SLF4J) │ SLF4J anywhere │ Cat 9
grep -rl (logging Log4j2) │ Log4j2 in hot-path │ Cat 9
grep -rEn (clock) │ Wall-clock outside cluster │ Cat 10
Agent A (docs + threading) │ Javadoc + thread-safety │ Cat 3, 13
Agent B (alloc + autobox + var) │ Zero-alloc + final var │ Cat 2, 6, 11
./gradlew dependencyCheckAnalyze │ OWASP CVE scan │ Cat 12
gh api (Gemini poll) │ External review │ Gemini
──────────────────────────────────┴────────────────────────────┴──────────
After executing ALL scans, print the MEASURED score:
── Iteration {N} Compliance (MEASURED) ───────────────────
# │ Category │ Score │ Status
────┼─────────────────────────────┼───────┼────────
1 │ Test Coverage │ {X}% │ {PASS/SUBPAR}
2 │ Zero-Allocation │ {X}% │ {PASS/SUBPAR}
3 │ Code Documentation │ {X}% │ {PASS/SUBPAR}
4 │ Determinism
Maintain Orchestrate?
Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.
[Orchestrate on getagentictools](https://getagentictools.com/loops/jsohi-orchestrate-automated-review-fix-push-review-convergence-loop?ref=badge)