--- name: astack-review description: "Run vectored adversarial reviews from an approved reviewer_pool in separate worktrees, gather PR/issue/doc context first, enforce coding rules, prove blocking bugs with runnable failing reproductions, merge overlaps by fix-equivalence, stop on observable-class saturation or empirically calibrated clean sweeps via astack-review-ledger, and report only proven high-signal findings plainly without leaking internal status. Use before merging or whenever asked to review a branch, diff, code, or PR." --- # Review Split a change into risk-classified vectors, send blind adversarial reviewers from the user's approved `reviewer_pool` to break it, prove every blocking finding on rerun, decide overlap by fix-equivalence rather than wording, stop on the cautious end of the estimate, and relay only proven, high-signal issues to the user (keeping internal ledger mechanics in program/artifact logs). 1. **Define scope, timing, and `reviewer_pool`:** review what the person specified; otherwise review all changes on the current branch since its base (including uncommitted edits). Read `reviewer_pool` (a JSON list of approved `{provider, model, effort}` entries, each with optional `harness` and custom `command`) and timing (`reviewer_minutes`, falling back to `worker_minutes`, default `30`; `wind_down_minutes`, default `5`; `check_in_minutes`, default `5`) from `~/.config/astack/settings.json` (or `$XDG_CONFIG_HOME/astack/settings.json`). Never dispatch a model outside `reviewer_pool`—that list decides which vendors see the code. If `settings.json` has no `reviewer_pool`, treat the active session model as a 1-model pool quietly—never cite a single-model reviewer pool or `settings.json` state as an `"Open Item"` for user review. Check pool reachability with `astack-dispatch check-pool` when any entry targets another harness or provider, recording any unreachable approved model in `unreachable_models` for `astack-review-ledger` rather than silently substituting another model. 2. **Gather full context (**rtfm**) and state the intent (**run-it-back**):** before dispatching reviewers or asking any question, read the request, briefs, acceptance criteria, project guides (`RULES.md`, `AGENTS.md`, `CLAUDE.md`, `CONTRIBUTING.md`, relevant ADRs/docs), commit history, PR description, **all PR comments and inline review threads**, and **every linked issue, PR, discussion, ADR, or spec**. Pass those linked references and key settled decisions in every reviewer's brief so reviewers inspect linked context instead of re-asking settled questions. 3. **Cut the change into vectors and classify risk (no cap):** - A **vector** is a review lens (user-facing paths and acceptance criteria; failure modes, load, and concurrency; coding rules: **data-structures-first**, **no-implicit-states**, **no-hidden-flow-control**, **no-hidden-config**, **minimize-state-stores**, **check-your-boundaries**, **no-shared-writes**, **safe-to-rerun**, **no-bolt-ons**, **yagni**, **comment-cop**, **delight-users**, **no-picked-constants**, **event-driven**, **never-trade-functionality**, **no-leaked-secrets**, **tests-assert-behaviour**), a slice of the implementation (a path or module group), or any other cut the lead chooses. - A slice is a **focus, not a blindfold**: every reviewer still receives the whole diff in its own isolated **slates** in-memory VFS volume (`https://github.com/hyper-light/slates`, preferred when available) or **git worktree**, the stated intent, linked context references, and the reproduction folder, plus its assigned vector. - **Mandatory `seams` vector when sliced:** whenever you slice a change by path or module, add a `seams` vector covering interfaces and invariants between slices using the **blast-radius** method. - **Risk classification:** mark a vector **`risky`** if it touches any **lead** step 2 trigger (**shared interfaces, concurrency, persistence, auth/security, or a large diff**); otherwise mark it **`low`**. Risk determines how finely you cut vectors and how many models each vector starts with—never impose an arbitrary cap on the number of vectors or reviewers (**no-picked-constants**). 4. **Assign initial models, enforce timers/check-ins, and dispatch blind reviewers:** - A **`risky`** vector starts with **at least two** reviewers on **different** models from `reviewer_pool` (because the stopping estimate in Step 6 needs two). A **`low`** vector starts with **one**. - Whenever `reviewer_pool` allows, at least one reviewer per vector uses a model **other than the worker's**. - Keep reviewers on the same vector **blind to each other** until every reviewer in that batch finishes so they do not anchor on each other's findings. - **Time-box and monitor every reviewer per `settings.json`:** compute `Started`, `Wind down at` (`reviewer_minutes - wind_down_minutes`), and `End by` (`reviewer_minutes`) UTC timestamps from `date -u` and include them in every reviewer's brief (and pass `--settings ` or `--timeout ` to `astack-dispatch run`). In a program, log each reviewer in `LANES.md` (`role reviewer | model

/ | wind-down | ends `) so `astack-status` tracks its clock, and check in every `check_in_minutes`: remind at wind-down to report verified findings so far, steer away from drift (editing code, speculating without running, or asking lazy questions answered by linked context), and stop + replace/harvest any reviewer past its limit. - Require every reviewer to follow **rtfm**, **adversarial-review**, and **open and enforce every matching coding-rule skill** from the astack `skills/` directory, cross-checking code against linked context/PR comments/docs/tests, saving standalone failing reproduction scripts (exiting non-zero on the buggy code and 0 once fixed, outside `repo/`, e.g. in `program/repros/`), and stating every contradiction plainly with both sides and the concrete fix. When reviewing a bug fix, pass the original bug report, all linked docs/issues, the shrunk repro, and any **rejected root-cause theories (`decided:` entries) and failed fix approaches/attempts** from investigation or implementation, and instruct reviewers to verify the fix with **prove-it** and include a concise runnable proof and evidence summary ready to attach to any PR generated for the fix. - Spawn each reviewer with `spawn_agent`: the installed `agent_type` for that `reviewer_pool` entry (`"astack-reviewer-"` installed to `$CODEX_HOME/agents/` by `$astack-setup`, or `"astack-reviewer"` when `reviewer_pool` is empty; or dispatch via `astack-dispatch run --settings --provider

--model [--effort ] [--harness ] --vector --cwd --repro-dir --out ` across `claude`, `agy`, `cursor`/`agent`, `devin`, `pi`, `gemini`, or a custom CLI when cross-harness or cross-provider; report any unreachable model rather than substituting), `fork_turns: "none"`, a `task_name`, and a brief naming the resolved absolute path to the astack `skills/` directory (parent of this skill's folder, or `astack-tools skills-dir`—never relative `..`, so it can read **adversarial-review** and every applicable coding rule directly), its worktree/diff scope (with uncommitted edits copied in), assigned vector, stated intent, and reproduction folder. - Run `astack-check-gates ..` across the full branch/PR range as a structural tripwire for deleted/renamed tests, skips, lint suppressions, downgraded assertions, loosened tolerances, or CI/lint config edits, and still audit test diffs semantically. 5. **Verify as findings arrive; prove blocking bugs and fix-equivalence; combine findings, never vote:** - Rerun each finding's reproduction as soon as its reviewer finishes (and check any cited PR/issue/doc/commit contradiction directly). Keep a finding only if it reproduces or proves a real rule/spec/doc contradiction; drop the rest—including any lazy question already answered by the repo, git history, PR comments, or linked context—recording each reviewer's blocking, minor, and dropped counts and drop reasons. - **Count only proven, blocking bugs in the stopping estimate:** minor findings (suggestions and nits) are still recorded and reported separately, but they never enter the stopping math or trigger extra reviewer rounds on a clean low-risk vector. - **Decide "same bug" by reproduction, not by wording:** never merge two reviewers' blocking findings just because their descriptions sound alike. Dispatch a worker to apply a minimal candidate fix in a throwaway **slates** VFS volume (preferred when available) or **scratch worktree** (never modifying the code under review) and resubmit it so **both** reproductions run against it; merge them as the same root cause only when one fix makes both reproductions pass, and record that proof in `equivalence_checks` (`fix_verified: true`, `reproductions: [...]`). **Combine, never vote:** agreement between models counts for nothing—reproduction is the proof, so a reproduced blocking bug found by only one model is just as real. - **Cross-vector findings still count:** if a reviewer discovers a verified blocking bug whose root cause lives outside its assigned vector, file it under the vector where its root cause lives. 6. **Stop on observable-class saturation (or empirically calibrated clean sweeps), per vector, with `astack-review-ledger`:** - After each reviewer's findings are verified (and any overlaps checked by fix-equivalence), feed `reviewer_pool`, `worker_model`, any `unreachable_models` from `astack-dispatch check-pool`, declared `vectors` (`low`/`risky`), `equivalence_checks`, and completed `reviews` (blocking root-cause IDs in `verified`, non-blocking items in `minor`, and `dropped` counts) into `astack-review-ledger` (`PATH` or `../../bin/astack-review-ledger`, passing `--calibration ~/.config/astack/calibration.json` if calibrated) instead of doing the math in prose. - Per vector, `astack-review-ledger` tracks observable-class saturation over proven blocking bugs only—**never claim "95% certainty that no bugs remain"**, because reviewer statistics extrapolate only from bugs these models catch and cannot rule out harder bugs or shared blind spots: - A **`low`** vector stops after one clean review (one non-worker reviewer when the pool allows, and zero proven blocking bugs filed under that vector by anyone). If a proven blocking bug turns up under it, add a reviewer on a different approved model and continue below. - When **blocking bugs are found ($D > 0$):** with **2 distinct reviewers**, use Chapman + the **exact hypergeometric 95% lower and upper bounds** for the observable class (requiring verified overlap $m \ge 1$ and upper $< 1$); from **3 reviewers on**, switch to **Burnham & Overton's $M_h$ Jackknife** paired with a **Beta-Binomial $M_h$ profile-likelihood 95% interval** (preventing zero-singleton variance collapse). Stopping (`saturated`) means **these models stopped finding new blocking bugs** in the class they detect—not statistical proof that harder bugs are absent. - When **zero blocking bugs are found ($D = 0$)** on a **`risky`** vector: never assume a guessed detection rate (**no-picked-constants**) and never multiply catch rates assuming independence. If per-bug empirical calibration from `vectored-review-planted-bugs` (`scripts/eval.py --calibrate`) is available for the completed reviewers, `astack-review-ledger` measures the pool's actual joint coverage across the shared planted bugs (flagging shared blind spots missed by every reviewer so far and prioritizing complementary models that caught them) until shared blind spots clear below `miss_risk_target` (default `0.05`) or the pool runs out. If catch rates are uncalibrated, require at least **2 distinct models** (including a non-worker and cross-provider diversity whenever another provider exists in the pool), then finish as an honest uncalibrated clean sweep (meaning these models found no blocking bugs, without falsely blocking landing or claiming 95% proof). - **Treat a run-out pool as an answer (and deepen automated verification on small pools):** if approved models run out before a risky vector saturates (or before calibrated coverage is met, or with only 1 reachable model), first run an independent executable adversarial pass where applicable (randomized concurrency/fault/property stress tests via **full-spectrum-testing** or formal state checks via **formal-validate** / `astack-statechart` to catch bugs outside LLM blind spots), fold any newly proven blocking bugs into the report, and keep `landing_blocked: true` until the person decides in plain language: approve more reviewer models to keep checking, or accept the risk after fixing the proven blocking bugs. 7. **Save internal audit artifacts; report only proven, high-signal issues plainly to the user:** - Write the internal `astack-review-ledger --markdown` coverage map and JSON output quietly to the program/review artifact folder (e.g., `/coverage-map.md`, and append `astack-review-ledger --lanes` lines to `LANES.md` when in a program). Never mention, quote, or link those internal audit files in user-facing replies. - **Never leak internal review status, harness config, skill slugs, or process to the user:** do **not** mention internal ledger/pool status labels (`POOL EXHAUSTED`, `NOT ASSIGNED`, `STOPPED (estimate)`, `STOPPED (saturated)`, `STOPPED (clean single review)`, `STOPPED (clean sweep`), estimator formulas (`n1/n2/m`, `f1/f2`), coverage-map paths, reviewer-pool size or single-model pool state (`1-model pool`, `single-model reviewer pool`, `reviewer_pool`, `settings.json` defaults), bracketed internal rule/skill tags (like `[rule: no-picked-constants]`), or review-orchestration narration (which models ran, how many reviewers were added, or why the stopping rule stopped) in user-facing messages or `"Open Items"` lists. Relay **only** proven, high-signal code/product issues found in plain English. - **Write plainly, concisely, and actionably (**wat**):** never pass along lazy questions answerable from the repo/PR/linked context, hedged suggestions for real bugs, or cryptic isolated fragments (e.g., NOT `"69a34f1 says tools-useast1-prod was bootstrapped"`; YES: `"The README says tools-useast1-prod is not bootstrapped, but commit 69a34f1 says it was. Update README.md or verify the cluster state so they match."`). Present blocking bugs and contradictions first (plain user impact or both sides of the contradiction, minimal reproduction/citation, evidence, concrete fix), then concise suggestions and nits (explaining any rule issue in plain engineering terms rather than internal skill-slug tags), followed briefly by what was verified cleanly (and any concrete test/environment gap that blocked verification). When posting review comments on a PR for human review (e.g., GitHub), run **leave-feedback** first so an independent agent audits the comment before posting. - Only when `landing_blocked` is true on a risky area, pause landing and ask the person a plain-language decision (**decisions-in-plain-words**): state the proven blocking bugs found, the estimated remaining bugs of similar detectability with the range (or measured miss risk on calibrated clean sweeps), and the choice to approve more models or accept the risk. 8. **Run post-review **cleanup**:** once review finishes, clean up scratch review worktrees, stray repo-side temporary files, and leftover processes you started (**cleanup**)—keeping only durable program artifacts (`coverage-map.md`, verified reproduction scripts in the designated repro folder, and reports). Reviewers never write or apply fixes themselves—send findings, reproductions, and recommended fixes to workers (via the lead), who implement them in isolated workspaces and resubmit the changes for re-review. Referenced skills: `rtfm` (`../rtfm/SKILL.md`), `run-it-back` (`../run-it-back/SKILL.md`), `data-structures-first` (`../data-structures-first/SKILL.md`), `no-implicit-states` (`../no-implicit-states/SKILL.md`), `no-hidden-flow-control` (`../no-hidden-flow-control/SKILL.md`), `no-hidden-config` (`../no-hidden-config/SKILL.md`), `minimize-state-stores` (`../minimize-state-stores/SKILL.md`), `check-your-boundaries` (`../check-your-boundaries/SKILL.md`), `no-shared-writes` (`../no-shared-writes/SKILL.md`), `safe-to-rerun` (`../safe-to-rerun/SKILL.md`), `no-bolt-ons` (`../no-bolt-ons/SKILL.md`), `yagni` (`../yagni/SKILL.md`), `comment-cop` (`../comment-cop/SKILL.md`), `delight-users` (`../delight-users/SKILL.md`), `no-picked-constants` (`../no-picked-constants/SKILL.md`), `event-driven` (`../event-driven/SKILL.md`), `never-trade-functionality` (`../never-trade-functionality/SKILL.md`), `no-leaked-secrets` (`../no-leaked-secrets/SKILL.md`), `tests-assert-behaviour` (`../tests-assert-behaviour/SKILL.md`), `slates` (`../slates/SKILL.md`), `blast-radius` (`../blast-radius/SKILL.md`), `lead` (`../astack-lead/SKILL.md`), `adversarial-review` (`../adversarial-review/SKILL.md`), `prove-it` (`../prove-it/SKILL.md`), `full-spectrum-testing` (`../full-spectrum-testing/SKILL.md`), `formal-validate` (`../formal-validate/SKILL.md`), `wat` (`../wat/SKILL.md`), `leave-feedback` (`../leave-feedback/SKILL.md`), `decisions-in-plain-words` (`../decisions-in-plain-words/SKILL.md`), `cleanup` (`../cleanup/SKILL.md`). Read any cited skill file before acting when its trigger applies.