Use scripts/adversarial_resolve.py as the durable state and budget controller. Act as the builder and evidence referee; the external reviewer is an adversary, not an authority.
origin/main worktree and preserve unrelated changes.max_rounds unset unless the user explicitly requests a round cap.Create a version-1 JSON spec using the schema in docs/adversarial-resolve.md. Keep temporary specs outside the repo; the controller copies the normalized contract into its ignored run directory.
Initialize:
python3 scripts/adversarial_resolve.py init --spec /private/tmp/hg-resolve-objective.json
If authorization was granted after initialization, record it only after the user grants it:
python3 scripts/adversarial_resolve.py authorize --run <run-dir> --external-review
acceptance_commands. Do not hide separately paid hg-verify or UX-review calls there; give those tools their own explicit caps and report their spend separately.Run one round:
python3 scripts/adversarial_resolve.py round --run <run-dir>
The controller runs acceptance commands, creates a fresh code_verify.py packet, invokes hg-code-review with the remaining exploratory allowance, assigns stable finding IDs, records provider costs, and evaluates stop conditions. It will not spend the protected final-review reserve during an exploratory round.
For NEEDS_FIX:
round-NN/findings.json and the supporting review packet.python3 scripts/adversarial_resolve.py triage \
--run <run-dir> \
--finding <finding-id> \
--status confirmed \
--evidence "Reproduced by the new regression test ..."
resolved with evidence once the deterministic test passes.invalid only with concrete evidence. Do not implement a reviewer suggestion merely to make the model agree.Do not weaken tests, remove a valid benchmark, broaden tolerances, or rewrite success criteria to manufacture a pass. Cluster lexical variants under their root cause, and do not chase invented synonyms outside the documented parser contract. If the requirement genuinely changes, create a new run contract or obtain explicit user direction.
When exploratory work is ready, or the controller returns AWAITING_FINAL_REVIEW, run:
python3 scripts/adversarial_resolve.py round --run <run-dir> --final
Treat only controller status resolved as adversarial resolution. It requires green deterministic checks, an accepted complete final reviewer verdict, and no unresolved configured blocking findings.
stopped_budget: report spend and remaining findings; never imply resolution.stopped_round_limit: applies only when the spec explicitly configured max_rounds; report the best current state and unresolved evidence.stopped_no_progress: applies only when the spec explicitly enabled stop_on_repeated_findings; stop changing code blindly and request the missing evidence or decision.stopped_tool_error: preserve artifacts and diagnose the provider/tool failure without widening scope.After resolved, run any additional repository gates that the controller did not own, then follow the repository’s PR and merge policy. Report objective, rounds, total and provider spend, tests added, findings fixed or disproved, final verdict, PR/deployment state, and any separately metered review costs.
The run budget covers hg-code-review API calls launched by this controller. Codex application usage is not expressed as API dollars. Exploratory rounds cannot consume the protected final-review reserve. The reviewer launches its required providers sequentially with stage reservations, and the controller records provider-reported spend before permitting another round. The monthly verifier ledger remains an independent runaway-spend guard.