agentleFS
kendrickkendrick/skills/work-issue/SKILL.md

work-issue

Skill1 starsChanged 2 months agoMITView on GitHub

Advance one GitHub issue from its approved plan to a pull request whose review threads are answered, resuming from wherever a previous invocation left it. Use when one issue should be built, published, and its review threads answered, including an issue with no plan yet that the user invokes it on directly; or when an orchestrating skill runs one planned issue as a lane; or when an open pull request it did not open has review findings to triage and answer. It never merges. To run a plan that has no issue, use divvy-up.

  • Deletes or force-pushes
  • Installs packages
  • Commits and pushes

5 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Every later command in a taken worktree names it by absolute path (git -C WORKTREE …).

    line 189
  2. Very specific:

    Every plan_concerns entry goes into a "Plan concerns" section in the pull-request body.

    line 236
  3. Very specific:

    Write date -u +%FT%TZ to RUN_DIR/pushed_at, then push: git push -u origin <BRANCH>:refs/heads/<BRANCH>, or git push …

    line 260

“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

work-issue

divvy-up ends at its Step 7 with a green verify and an assembled diff. Everything after that point is the tail nobody wrote down: reproducing the worker's claims with something that did not author them, rebasing, pushing, opening the pull request, reading what an external reviewer said about it, repairing what is in scope, queueing what is not, and answering every thread. Held in one session's memory, that tail gets re-derived from scratch each time and loses the same things in the same order.

One invocation advances one issue to its next gate and stops there. A gate here means one of the stops listed under Where a Run Stops, and nothing else: divvy-up's per-wave gate and Step 3's code-review are checks the run passes through on the way to one. The run's state lives on disk rather than in the conversation, so a session that ends mid-run resumes by typing the same command again, and a second issue worked at the same moment is refused at the gate rather than discovered as a rebase conflict four steps later.

Four siblings do the work this skill does not: divvy-up derives and dispatches the waves, code-review reads the assembled diff against the issue, adversarial-review fires on the diffs that earn it, and technical-writing writes every pull-request body and thread reply, and every commit message except an in-branch one on a squash-only repo. Each is invoked by name. Where one is not installed, the step that needs it stops and says which. ponytail-review is optional: Step 3 runs it where it is installed, and its absence skips that reviewer and stops nothing.

Two rules hold across every step below.

  • Prove the mutation, then read the result. Every edit is proved before anything reads a result that depends on it: after writing, show the changed bytes (git diff -- <path> non-empty, or a grep for the inserted text with its line number), and only then run the command whose outcome depends on the edit. The session this skill came out of lost five separate edits this way — BSD sed refusing a 0,/re/ address, a regex that missed the real symbol, a perl guard that matched nothing — and every one of them produced a passing suite, because the suite ran against a file nothing had changed.
  • Never the default branch. Every push names its refspec in full — git push origin <BRANCH>:refs/heads/<BRANCH> — after checking that BRANCH is not DEFAULT, so what leaves this machine is the run's own branch and never the default branch. --force-with-lease=<BRANCH> only, and only after the Step 5 rebase. An adopted run never rebases and never force-pushes. gh pr create always carries --base <DEFAULT> --head <BRANCH>. The Step 0 grant covers this issue's branch and nothing else, and Adopt's grant covers the adopted pull request's head branch and nothing else. A human merges the pull request at the end; this skill stops one step short of that.

This skill is model-invocable because a skill that runs a wave of issues reaches one lane through it, and a skill no sibling can call is one no sibling can compose with. Typing its name still works—a description adds agent discovery without taking the human's away. Step 0's confirmation is what stands between a misfire and a branch nobody asked for: it stops the run before anything is dispatched, and the half of its grant covering push and pull request is answerable separately from the half covering the build.

Where a step names a shell command, treat it as the intent and use your native shell or file tools.

Resolve once per invocation:

  • N — the issue number from the arguments: a bare integer, #N, or an issue or pull-request URL. A URL whose path holds /pull/ is a pull request. For a bare number or #N, ask gh api repos/REPO/issues/<n> --jq '.pull_request != null': true is a pull request, false an issue, and a non-zero exit stops the run quoting its stderr, because a failed lookup read as "not a pull request" sends a pull request down the issue path in silence. A pull request's number is M, and it goes to Adopt, which settles whether M resolves back to an issue. Absent stops the run. There is no "issue from the conversation" mode, because a number inferred from context runs this entire loop against the wrong ticket and every gate it passes agrees with it.
  • M — the pull-request number, on an adopted run only.
  • REPO — gh repo view --json nameWithOwner --jq .nameWithOwner
  • DEFAULT — gh repo view --json defaultBranchRef --jq .defaultBranchRef.name. Never assumed to be main.
  • ROOT — git rev-parse --show-toplevel of the invoking directory
  • COMMON — git rev-parse --git-common-dir, made absolute
  • PROJECT — ROOT's final path segment, lowercased to a-z0-9-
  • BRANCH — issue-<N>, or on an adopted run the pull request's headRefName
  • WORKTREE — <ROOT>/../<PROJECT>-issue-<N>/, or <ROOT>/../<PROJECT>-pr-<M>/ on an adopted run
  • WORKER — issue-<N>: the herdr agent name, and the label for a plain subagent
  • RUN_DIR — <COMMON>/work-issue/issue-<N>/. Subpaths: issue.md, draft-plan.md, plan.md, base_sha, baseline.txt, baseline-<wave>.txt, baseline-repair-<n>.txt, max_review_rounds, pushed_at, review_loop, merge_methods.json, full_commit_pass, timing.log, policy.log, conflict.txt, reports/, prompts/, gated/, review/, redteam/, triage/, queue.md, pr-body.md, and on an adopted run adopted.json. An adopted run's RUN_DIR is <COMMON>/work-issue/pr-<M>/. A finished run moves to <COMMON>/work-issue/closed/issue-<N>/. Under the common dir it is one location visible from every worktree, invisible to git status without an exclude entry, and it survives git worktree remove. It holds phase outputs — reports, verdicts, triage rows — and the resume probe reads those outputs. Nothing in it records which phase the run believes it reached: a note saying "phase 4" outlives the crash that stranded the run at 3.
  • PLAN — first hit wins, and an adopted run has none:

    1. the path in the arguments
    2. <ROOT>/docs/plans/*issue-<N>*.md or <ROOT>/docs/plans/*-<N>-*.md, newest by name
    3. a path linked from the issue under a Plan heading
    4. the one plan work-issue/scripts/find-plan.py --issue N --repo REPO prints from the directories in WORK_ISSUE_PLAN_DIRS
    5. the approved plan held in the conversation

    Route 4 searches each directory in WORK_ISSUE_PLAN_DIRS, a colon-separated list. Unset, it searches ~/.claude/plans if that exists, which is where Claude Code's plan mode saves. Set to the empty string, the route is off. Only *.md files directly inside a listed directory are candidates. A file matches when its name contains N as a whole number, not inside a longer digit run, and it is dropped when its name ends in .v<digits>.md or its text names another repository by a github.com/owner/name URL or an owner/name#<number> reference. A plan that names only REPO, or no repository, survives. Two or more survivors refuse the run: quote the script's stderr and end "pass one as the plan path: work-issue N <path>". Zero survivors fall through to route 5. Exit 3 stops the run with the script's stderr quoted: a directory named in a set WORK_ISSUE_PLAN_DIRS that is missing or not a directory, a candidate it cannot read, or a usage error. A typo in the variable would otherwise fall through to route 5 in silence.

    Route 5 is where missing all four of those lands, and it lands silently: routes 2, 3, and 4 miss, the conversation supplies the plan, the run proceeds, and nothing says so. RUN_DIR/plan.md is then the only copy. An ordinary resume survives that—row 6 of the Resume table sends the run back to the plan gate, which re-reads the copy. Row 5's first leg does not: a run that stopped before divvy-up wrote its ## Waves table, with no branch made yet, has its RUN_DIR moved to closed/ and starts over at Step 0, where PLAN resolves in a session that no longer holds the plan and every route misses. A direct invocation then plans the issue again from nothing, and a wrapped one refuses. The plan survives at closed/issue-<N>/plan.md, out of the resolution path and recoverable only by hand. A path on the argument line, a link in the issue, or a plan in a WORK_ISSUE_PLAN_DIRS directory is one that resolves again next time—which is the whole of the fix.

    Where all five routes miss, the invocation decides what happens. It is direct when the user asked for this run in their own words in this session and no calling skill's grant came with it, and the Plan block between Step 0's items 2 and 3 plans the issue. Every other invocation is wrapped: one carrying a calling skill's grant, as a work-wave lane brief does, and one the model reached without the user asking. A wrapped invocation plans nothing and refuses with the plan gate's refusal, "Plan it first: writing-plans, then work-issue N <plan path>." A drive.py launch is wrapped, because the driver launches a headless agent the user isn't talking to, so it never plans: on an unplanned issue its dry-run launch meets that refusal, prints no Go?, and the driver halts, which is the right end for an issue nobody has planned.

    The hit is copied to RUN_DIR/plan.md, and every later step reads the copy. divvy-up writes its ## Waves table into whatever it is handed, and a tracked plan file must not gain a table in the pull-request diff.

  • CRITERIA — every - [ ] / - [x] line under a heading containing Acceptance in the issue body, saved into RUN_DIR/issue.md
  • BASE_SHA — git merge-base origin/<DEFAULT> <BRANCH> once BRANCH exists; before that, git rev-parse origin/<DEFAULT> after git fetch origin <DEFAULT>. Written to RUN_DIR/base_sha by Step 1, and rewritten by Step 5 item 2 after each proven rebase, which Step 8 item 2 repeats; nothing else writes the file. It is the one fixed point code-review, the reproducer, and adversarial-review all measure against, so it is read from that file rather than re-resolved: a ref moves, and a run that re-resolves it reviews different code on Tuesday than it did on Monday. A rebase is the one move the file follows, because it moves the base under the branch, and a file left at the old base diffs every commit merged in between as part of this change. The resume probe's base_sha_state stops a run whose file has drifted from the live merge-base.
  • PR — gh pr list --head <BRANCH> --state all --json number,state,url --jq '.[0]', or M on an adopted run
  • VERIFY_CMD, INSTALL_CMD — VERIFY_CMD on an issue run is the command work-issue/scripts/run-state.py verify-cmd --plan RUN_DIR/plan.md prints, the first backticked span on the plan's - Verify with: line (bold or a missing colon still match), so a lane gates on its own plan's suites; where that exits 3, the plan is unreadable, so stop the run quoting the script's stderr; where it exits 1, the plan names none, and VERIFY_CMD is harvested; an adopted run has no plan, so it never calls verify-cmd and harvests off disk the way file-issue harvests, as INSTALL_CMD always is, and quoted: manifest scripts first (package.json, Makefile, pyproject.toml, Cargo.toml); with no manifest, runnable scripts under tests/ or scripts/, then what .github/workflows/ runs, then absent. INSTALL_CMD is the manifest's install (pnpm install --frozen-lockfile, npm ci, uv sync, …), else absent. Once Step 2's first wave settles, VERIFY_CMD green means a run showing no failure the latest baseline does not show, the latest baseline being the highest-numbered RUN_DIR/baseline-repair-<n>.txt, else the newest RUN_DIR/baseline-<wave>.txt, else baseline.txt, with each failure attributed by the rule divvy-up's Step 6 applies, and red means it shows one. Every repair gate that passes a full VERIFY_CMD run green writes the next baseline-repair-<n>.txt, as Step 3 says, and a scoped gate at Step 4 or Step 7 writes none and runs only on a latest baseline reading exit: 0, so a failure one repair fixed and a later repair brought back reads red rather than passing against a wave file that still shows it. A failure the plan never fixed stays in that baseline from the run's start to its publish, and a raw exit status would leave every gate after the waves red on it with no route out. Where that baseline is red and the run's output or the baseline names no individual failures, the gate stops the run with the same message Step 2's gate prints. With VERIFY_CMD absent nothing runs, and there is no green or red to read.
  • HERDR — test "${HERDR_ENV:-}" = 1 && command -v herdr
  • SINCE — the contents of RUN_DIR/pushed_at (UTC ISO 8601, written immediately before every push, and before Resume's row-18 review request, so an event stamped the same second still counts). Only where that file is absent, the head commit's committer date: a pushed_at that exists but is empty or unparseable is a damaged cutoff, and probe stops on it rather than falling back. On an adopted run, adoption writes the first pushed_at: SINCE is the committer date of the commit the newest review names in a Reviewed commit: line, and the head commit's only where no review names one. A named commit this clone can't resolve refuses the adoption rather than falling back, since the head's date would score that review's findings as older than SINCE and drop them.
  • FLAGS — --isolate / --no-isolate pin the Step 1 row; --deep forces adversarial-review at Step 4; --max-review-rounds N caps the post-PR review loop at N triage rounds, default 2, and Step 0 writes it to RUN_DIR/max_review_rounds (see Step 6), where a resume keeps it: to change the cap mid-run, write another positive integer to that file before the round it would cap is triaged, because phase_of reads an already-triaged round against the file as it now stands and would repair rows that round queued and answered as deferred; --review-loop[=<comment>] turns on the review loop: Step 0 writes <comment>, @codex review where none is given, to RUN_DIR/review_loop, and while that file exists Steps 5 and 8 post it as the review request (see Step 6) and no review round is capped, so the loop ends on cleared, the budget stop, the poll cap, or an error; a round that pushes nothing, its findings all refused or queued, posts no request and ends at Step 8 item 5's final report, and re-invoking with the flag at row 18 asks again; an empty comment, --review-loop=, refuses the run before anything is written under RUN_DIR; on a run whose RUN_DIR already exists, Step 0 item 1 writes the file before the gather block so the probe reads the mode, and the flag's comment replaces the file's; an invocation without the flag leaves the file as it is, so the mode holds for the rest of the run; --no-publish ends the run at the withheld-grant stop once Step 4 is done, so no step past Step 4 runs: no git push, no gh pr create, and no pushed_at write, however the confirmation was answered, and a resume whose phase: is 5, 6, 7, or 8 meets the same stop (see Resume); the flag binds only the invocation that carries it and is never written to RUN_DIR, because a persisted copy would hold back the later invocation meant to publish, so work-issue N without it resumes into Step 5 through row 13, as the stop's closing line says: "work-issue N without --no-publish publishes."; --until-boundary is the driver's flag, which work-issue/scripts/drive.py N --until-boundary carries to every launch: it ends the invocation at the boundary stop Step 2 names once a wave settles with a later wave in ## Waves still pending, so each launch builds one wave; it binds only the invocation that carries it and is never written to RUN_DIR, because a persisted copy would make a later hand-typed work-issue N stop at every wave too; --wave-baseline <path> is work-wave's flag: it names the wave's no-branch baseline, which Step 1 copies in place of its own VERIFY_CMD run when run-state.py reuse-baseline finds the base SHA and both commands match; it binds only the invocation that carries it and is never written to RUN_DIR, because Step 1 is its only reader and every build dispatch carries it again, and an invocation without it runs VERIFY_CMD at Step 1 as it always has; --auto-budget <ratio> raises the budget ratio to <ratio> once at a budget stop and defers the round's open rows past it at Step 7; --repair-class <class> repairs a finding in that class, unowned-write the only one, at the red-team stop and at triage from round --defer-after on, and defers the rest, though in a capped round the review round cap rules first (see Step 6); --defer-after <k> defers every in-scope row outside the repair class from triage round k on; Step 0 runs work-issue/scripts/policy.py flags on the three before anything is written under RUN_DIR, and a non-zero exit refuses the run quoting its stderr; references/policy.md gives each stop's ruling; the three bind only the invocation that carries them and are never written to RUN_DIR, like --wave-baseline, so work-issue N without them asks at every stop, as it did before they existed; --dry-run runs every gate and every derivation, drafts no plan, renders the confirmation, and dispatches nothing and pushes nothing.

gh auth status is a Step 0 preflight, the way file-issue runs one. Unauthenticated at Step 0 stops the run, because the issue cannot be read and CRITERIA would be invented. Unauthenticated at Step 5 or later renders the pull-request body to RUN_DIR/pr-body.md, pushes nothing, and stops with "resume after gh auth login". A rendered body says on its face that it is rendered: a draft that reads like an opened pull request is a draft somebody goes looking for on GitHub.

The user owns two acts in this loop, and the run performs neither. Approving the plan comes inside Step 0: a direct invocation on an issue with no plan drafts one in the Plan block and waits at Stop 1 for the user's approval, and a wrapped one refuses with the message that names writing-plans. Merging comes after Step 8, where the final report ends "a human merges" once the review is cleared — or, once every finding is answered and the queue published but nothing has cleared the round yet, "waiting on the reviewer" instead, since resolving stays their act either way. Waiting on an external reviewer is not a third act — it is the poll inside Step 6, bounded per invocation and continued by re-invoking.

Timing. Steps 1 through 8 each stamp RUN_DIR/timing.log with work-issue/scripts/run-state.py stamp --timing RUN_DIR/timing.log <n> start as step <n> begins, and the same command with end once its Done-when holds. Where budget's own pairing leaves label <n> open, as a crash leaves it, stamp closes it first, writing <n> end at the newest stamp already in the log ahead of the new start, so you write no close-first line yourself. The crashed interval then ends at the last thing the run recorded, and the hours it sat dead count toward nothing. A different label left open needs no line from you: the resume table often sends a run on to another step, and budget ends any open label, poll included, at the newest stamp before the next step's start, the same place. Before printing a stop under Where a Run Stops, run stamp <n> end for the step it ends in. stamp appends nothing where the step's Done-when already wrote its end, as the final report and the stops Steps 4, 5, and 6 count in their Done-when do, or where another step's start closed it. A label a crash left open belongs to no invocation, so a stop leaves it to stamp and budget, which end it at the newest stamp. A stop at Step 0 or at Resume, before any step opens, writes nothing. Every resume into step <n> reopens it with that step's own start line, written through stamp before the step does anything. The time a run spends stopped, waiting on the user, then counts as neither build nor review. Step 6 brackets each wait for a reviewer with poll start and poll end, inside its own 6 bracket. A crash mid-poll often resumes straight into triage with no new poll start, so the step's own start is what closes that poll. The budget subtracts poll time from review, because the reviewer's latency is not this run's review. Read the log with:

work-issue/scripts/run-state.py budget --timing RUN_DIR/timing.log --now "$(date -u +%FT%TZ)"

It prints build: <m>m review: <m>m ratio: <r> over: yes|no, build being Steps 2 and 3 and review being Steps 4, 6, 7, and 8 less their poll time. --now closes the step in progress at this moment; without it, a running Step 4's own start is the newest stamp, and Step 4 reads as 0 min of review for as long as it runs. Run it before each red-team round, each adversarial-review invocation, each Step 7 dispatch, and Step 8 item 1's re-fire. over: yes is the budget stop, the same one the Resume table's rows 10, 11, 16, and 17 give: print the budget line, and ask the user to stop here or raise the ratio. At row 16's budget stop, whose newest triage round has in-scope rows not yet queued and no repair yet, the user can also defer any of them. A deferral is written as Step 6's review round cap paragraph says. A raise appends budget-raised <ratio> to the log, which replaces the 2.0 ratio from that line on. --ratio <r> on one command outranks every budget-raised line for that check alone. Where the invocation carries --auto-budget, run policy.py budget at each over: yes before asking, and act on the ruling it prints as references/policy.md says. On cambium #23 and #26, about 50 min of build drew about 5 h of review and 7 repair cycles per lane for 1 blocker, and nothing in the loop said so until a human counted.

Step 0 — Gate and confirm

  1. Where --review-loop= gives an empty comment, refuse the run naming the flag. Where RUN_DIR already exists and the invocation carries --review-loop, write its comment to RUN_DIR/review_loop now, so the probe reads the mode; on a fresh issue item 2 writes it instead. Then run the resume probe before anything else is written under RUN_DIR: the gather block in references/resume.md, which ends with run-state.py probe and then run-state.py phase (see Resume). A run dir with no branch is row 5's mark of a dead run, so an issue.md written first would make every fresh issue look dead and send it to closed/. Any phase past 0 jumps there; the rest of this step is for a fresh issue.
  2. Where --max-review-rounds is given a value that is not a positive integer, 0 included, refuse the run naming that value, before anything is written under RUN_DIR. Read the issue into RUN_DIR/issue.md and extract CRITERIA. Write the --max-review-rounds value, 2 where the flag is absent, to RUN_DIR/max_review_rounds. Where --review-loop is given, write its comment to RUN_DIR/review_loop too. Then fetch the repo's merge settings once, for every commit the run makes:

    gh api repos/{owner}/{repo} --jq '{squash: .allow_squash_merge, merge: .allow_merge_commit, rebase: .allow_rebase_merge}' > RUN_DIR/merge_methods.json

    A non-zero gh exit deletes RUN_DIR/merge_methods.json, and the run goes on: Step 2's commit rule reads a missing file as the full pass. No later step fetches the settings again, so a resumed run reads this same file. A token that cannot administer the repo gets null for each key, which also reads as the full pass.

Plan block. Runs only on a direct invocation where every PLAN route missed (see PLAN for direct and wrapped). An adopted run never reaches it.

  • Plan directory. The first entry of WORK_ISSUE_PLAN_DIRS when that is set and non-empty, else ~/.claude/plans when the variable is unset and that directory exists. Any other case refuses before planning: unset with ~/.claude/plans missing, set to the empty string, or a first entry that sits inside ROOT. A set first entry that is missing or not a directory never reaches this block, because route 4 already stops on it with find-plan.py's stderr naming the directory. The refusal names the directory, or the empty variable, and ends "set WORK_ISSUE_PLAN_DIRS to a plan directory outside this repository, then work-issue N." The plan reaches the plan directory only by the copy after Stop 1's approval and never goes into the repo tree, so it never lands in the pull-request diff.
  • Dry run. Under --dry-run the plan-directory check above still runs and its refusals stand. The run then stops before any planner with "--dry-run drafts no plan; work-issue N without it plans the issue."
  • Name. <plan dir>/<N>-<slug>.md, the slug being the issue title lowercased with each run of characters outside a-z0-9 turned into one - and none at either end. Route 4's whole-number match finds it again by N once the copy after Stop 1 puts it there. Check whether that file exists before invoking either planner, and again immediately before that copy. A file already there is one route 4 did not resolve for this issue, since a resolved one would have kept PLAN from reaching this block. Usually it is another repository's plan for an issue with the same number and title, which route 4 drops for naming that repository; it can also be an earlier run's own copy kept for a needed reference to another repository. Where it exists, refuse naming the file and ending "move it or pass a plan path, then work-issue N." The copy never overwrites it. A refusal at the copy leaves the approved draft where the planner put it, RUN_DIR/draft-plan.md under writing-plans or plan mode's own file under plan mode. The next work-issue N moves that RUN_DIR to closed/ by resume row 5's first leg, so a writing-plans draft is then recoverable only by hand from under closed/.
  • Planner, the first one present:
    1. the writing-plans skill, invoked by name with the issue's title, body, and CRITERIA from RUN_DIR/issue.md, told to save to RUN_DIR/draft-plan.md and to stop once the plan is saved, because Stop 1 is its approval and this run is its execution. No PLAN route searches RUN_DIR, so a draft is never resolved as a plan before the user approves it. A session interrupted before Stop 1's answer leaves the draft only there: resume row 5's first leg moves that RUN_DIR to closed/, Step 0 starts over, every route misses, and a direct invocation plans again, with the old draft kept as draft-plan.md in the run dir moved under closed/;
    2. the harness's plan mode: in Claude Code, EnterPlanMode, then ExitPlanMode, whose approval is Stop 1's approval. Plan mode keeps its draft under a name of its own in ~/.claude/plans until approval, a name route 4 cannot match to N;
    3. neither: refuse with the plan gate's refusal below, as a wrapped invocation does.
  • Gate the draft before the user sees it. Run item 3 on the draft, RUN_DIR/draft-plan.md or plan mode's own file, both halves: check-plan.py on that path, then the derivation. A non-zero check-plan.py exit or a derivation question goes back to the planner as a revision note carrying the stderr or the questions, never to the user as a refusal, and the gate runs again until it passes.
  • Stop 1. Put the draft's path and the plan to the user and ask for approval or changes. Changes go back to the planner as a revision note, through the gate, and to Stop 1 again. On approval, repeat the existence check under Name, then copy the draft to <plan dir>/<N>-<slug>.md. For both planners the file reaches the plan directory only by this copy, so find-plan.py runs after the copy: run work-issue/scripts/find-plan.py --issue N --repo REPO and confirm it prints the copied path. A miss deletes the copy, which is this run's own file and would otherwise trip the existence check on the next copy, and goes back to the planner with the revision note and through Stop 1 again. A miss caused by a reference to another repository that the plan needs keeps the reference and the copy, and Stop 2 says the plan resolves only by path, work-issue N <path>. PLAN is then the copied path, copied to RUN_DIR/plan.md as any route's hit is, and the run continues at item 3, which passes on the same bytes. On a decline, delete RUN_DIR/draft-plan.md, because the draft would otherwise sit in RUN_DIR and reach closed/ on the next work-issue N looking like an interrupted session's draft rather than one the user turned down; under plan mode nothing was copied, so there is nothing to delete. Then stop with "Plan declined and deleted; work-issue N drafts a new one." Stop 1 approves an artifact, the plan, and grants nothing, so the one-confirmation rule holds: the confirmation that grants execution and the push is still item 8, which is Stop 2.
  1. The plan gate, mechanical half:

    work-issue/scripts/check-plan.py RUN_DIR/plan.md --issue N --criteria RUN_DIR/issue.md

    A non-zero exit refuses the run, quoting the script's stderr and ending "Plan it first: writing-plans, then work-issue N <plan path>."

    Then the judgment half, which is why the script is only half the gate. Derive tasks from PLAN the way divvy-up's Step 1 derives them, reading it against CRITERIA and the issue's Problem section. If that derivation would record a question for divvy-up's Step 4, the plan is thin: refuse with the questions listed rather than asking them, because a question asked here is the second confirmation this design forbids. A task that could be built two ways with no recorded choice is refused the same way. Inside the Plan block, both halves send the draft back to the planner instead of refusing.

  2. Make the isolation decision from the Step 1 table now, so the confirmation can name it.
  3. Derive the shape: invoke divvy-up by name on RUN_DIR/plan.md and run its Steps 1 through 3 in the tree that will host the work. Quote its shape line as-is rather than restating the counts. Name VERIFY_CMD to divvy-up as the verify command, so its Step 3 skips its own repo-disk resolution and its Step 6 gate runs it. Its Step 6 gate runs it in the deferred form Step 3's Deferred liveness paragraph gives. Tell divvy-up its baseline will be named before its Step 5, so its Step 3 skips its own verify run: neither the tree nor RUN_DIR/baseline.txt exists until Step 1, and Step 2 names the file, or, where VERIFY_CMD is absent, tells it its BASELINE is absent instead.
  4. Cross-run ownership. Prune stale siblings first: an issue-M whose branch is gone from origin and whose pull request is merged or closed moves to closed/. A sibling whose queue.md still holds a row whose Status cell, read with its whitespace dropped, is exactly queued, the rule queue_unfiled_rows counts by, or whose queue.md has no Status column, stays in place: moving it to closed/ skips that run's own resume row 1 stop. work-issue M files or dismisses its rows first, and check-inflight.py below still counts it. Then:

    work-issue/scripts/check-inflight.py RUN_DIR/plan.md --runs <COMMON>/work-issue --self issue-N

    A non-zero exit is a hard stop whatever the isolation decision was. Two worktrees rewriting one file produce a rebase conflict at Step 5, and a run the user has walked away from cannot resolve it.

  5. Red-team mode for the confirmation text: reproduce claims, or reproduce claims, then adversarial-review (<row names>; depth <n> forecast) when the forecast match below prints a row, or reproduce claims, then adversarial-review (--deep; depth 2 forecast) when --deep is set, since that flag fires the trigger on its own. The forecast match feeds the current contents of the plan's owned paths to Step 4's script as an all-added diff against the empty tree, run in the tree that will host the work.

    Check first that adversarial-review is installed: adversarial-review/scripts/match-triggers.py and adversarial-review/references/trigger-table.md both exist, at the paths the forecast command names. Where either is missing, refuse the run here and name adversarial-review as the sibling to install, before anything is dispatched, because every Step 4 path needs it: the match, --deep, and the review itself. A run that went on would build the whole change and stop at Step 4 for the same missing skill.

    The forecast command:

    git diff $(git hash-object -t tree /dev/null) HEAD -- <the plan's owned paths> | adversarial-review/scripts/match-triggers.py rows --only 1,2,4

    The script reads only + and - lines, so file contents piped in bare match nothing; the empty-tree diff marks every line added. An owned path that does not exist yet contributes nothing, so a file the plan creates is forecast from nothing. <row names> are the names the command printed. A non-zero exit decides nothing: stop and quote its stderr, since an empty output from a failed run reads as reproduce claims. Take <n> from the Depth table in adversarial-review's Step 2, applied to the plan's owned paths. The rows it counts are the ones the forecast match printed. Step 4 re-runs that match against the real diff, so this is the forecast rather than the verdict. Where the mode names adversarial-review, a yes to this confirmation also answers adversarial-review's Step 2 question for this run, at any depth up to the forecast one.

  6. The one confirmation, in one message:

    `4 waves, 6 tasks; wave 0 is 1 contract task on opus.` Plan: `~/.claude/plans/42-cambium.md` (route 4). Isolation: worktree at `../cambium-issue-42/` (another run is in flight: issue-38). Red-team: reproduce claims. On yes: execute, commit each passing wave, push `issue-42` to origin, open a PR against `main`, and push repair commits, without asking again. Never `main`. Go?

    The Plan clause names the path PLAN resolved to and its route number, for every route, because it is the user's only check that a plan found in a shared directory is the right one. Route 5 shows as Plan: the conversation (route 5). This message is Stop 2 wherever the Plan block ran, and a plan it drafted shows as Plan: <saved path> (planned this run). Where the Plan block kept a needed reference to another repository, the clause adds that the plan resolves only by path, work-issue N <path>, because route 4 drops it, so a fresh Step 0 finds it only by a path argument.

    Where isolation resolved to ask, that choice is the one variable in this question. divvy-up's own Step 4 question is folded in here: this confirmation answers it on the user's behalf, the shape line says so, and divvy-up does not ask it again. With --no-publish, the "On yes" clause names only the build half: execute and commit each passing wave. --dry-run renders this message and stops.

    Run work-issue/scripts/run-state.py commit-style --run-dir RUN_DIR before rendering the message. Where it prints bare, the message carries one more clause, squash-only repo: in-branch commits get bare subjects, ahead of "Go?". Where it prints full, the message carries nothing about commits. Where the user overrules the bare clause, write an empty RUN_DIR/full_commit_pass, which makes commit-style print full for the rest of the run, resumes included. The overrule only runs toward the full pass: a repo that can merge or rebase keeps its in-branch commits on the default branch, so nothing justifies bare subjects there.

    Once the user answers yes, write the red-team mode line this message carried to RUN_DIR/redteam/mode.txt, replacing any earlier copy. Step 4 hands that file's line to adversarial-review as the confirmation its Step 2 checks, because a resumed run reaches Step 4 without this conversation.

Done when: RUN_DIR/max_review_rounds holds the cap; RUN_DIR/merge_methods.json holds the fetched settings bundle, or is absent after a failed gh fetch; RUN_DIR/full_commit_pass exists where the user overruled the bare clause; where the Plan block ran, the user approved the draft at Stop 1, it was copied to <plan dir>/<N>-<slug>.md with no existing file overwritten, and find-plan.py printed that path, or the plan keeps a needed reference to another repository and Stop 2 says it resolves only by path; check-plan.py exited 0 and no derivation question was recorded; check-inflight.py exited 0; adversarial-review's script and trigger table were both found; the forecast match exited 0, or --deep is set; the shape line, the plan path and its route, the isolation choice, the red-team mode, and the push grant, or only the build half under --no-publish, were put to the user in one message and answered yes, and RUN_DIR/redteam/mode.txt holds the red-team mode line that message carried — or the run stopped at a refusal, a stop, a dry-run, or a no, with nothing dispatched and nothing pushed.

Adopt — enter at Step 6

A pull request this skill did not open has no plan and no build to resume, only review threads to answer. Adoption writes the RUN_DIR files Steps 0 through 5 would have left and enters at Step 6, so Steps 0 through 5 never run and no plan is needed. A pull request that closes no issue is adopted all the same, with its body as the spec. Run these in order:

  1. Flags. Only --max-review-rounds and --dry-run apply. A plan path, --isolate, --no-isolate, --deep, --no-publish, or --until-boundary refuses the run, naming the flag: each shapes a build an adopted run never makes, --until-boundary has no waves to stop between, and --no-publish would meet the withheld-grant stop at every phase an adopted run can reach. --review-loop refuses the run the same way, because it would ask for reviews on a pull request this skill didn't open, with no Step 5 to post from. --wave-baseline refuses the run the same way, because an adopted run has no Step 1 and no wave hands it one.
  2. Save gh pr view <M> --json number,url,state,isCrossRepository,headRefName,baseRefName,closingIssuesReferences,body and run-state.py review <M> --save, each to its own mktemp file outside RUN_DIR, for the reason references/resume.md's Gather item 2 gives. A non-zero exit from either stops the run, quoting its stderr. LOGIN, the login this run replies as, is gh api user --jq .login.
  3. A pull request this skill opened resumes its own run: where its head branch is issue-<K> and <COMMON>/work-issue/issue-<K>/ exists, N becomes K and the run continues at Step 0 item 1's resume probe, unchanged. Any other pull request is adopted.
  4. RUN_DIR is <COMMON>/work-issue/pr-<M>/. Where RUN_DIR/adopted.json exists, adoption finished earlier: resume through the probe with --pr M (see Resume). Where RUN_DIR exists without adopted.json, adoption never finished, and it reruns from item 5, overwriting what it finds.
  5. git fetch origin <DEFAULT> <head>, then a dry run:

    work-issue/scripts/run-state.py adopt <M> --pr-json PR_JSON --bundle BUNDLE --run-dir RUN_DIR --root ROOT --default DEFAULT --invoker LOGIN [--max-review-rounds R] --dry-run

    Exit 1 refuses the run, quoting its stderr: one run-state: adopt: line for each refusal, whether the pull request is not open, its head is on a fork or is DEFAULT, it targets a branch other than DEFAULT, or a review names a commit this clone lacks. Exit 3 stops the run the same way: a usage error, an unreadable input, or an origin/<DEFAULT> or origin/<head> that doesn't resolve, which the line says to fetch. Exit 0 prints six lines, adopt:, head:, issues:, since:, base_sha:, and threads to triage:, which the confirmation quotes.

  6. The one confirmation, in one message, modeled on this example:

    Adopt PR #96 (`fix/84-guard-asserts-the-tree` into `main`), closing #95. Triage: 2 unanswered threads, SINCE 2026-09-30T14:02:11Z from reviewed commit f79627ee5f. Worktree at `../cambium-pr-96/`. On yes: triage, repair what is in scope, push to `fix/84-guard-asserts-the-tree` only, and reply to every thread, without asking again. Never a force push, never `main`. Go?

    --dry-run renders it and stops.

  7. On yes, WORKTREE is checked out on the head branch, so the user's checkout is never switched. A worktree that already has the head branch checked out is reused only where it is clean and its HEAD equals origin/<head>. Dirty, it is refused with "commit or stash first"; at any other SHA, the run refuses and names both SHAs, since a clean branch can still hold commits origin lacks and Step 8 would push them with the repair. A local branch of that name that no worktree holds is added with git worktree add WORKTREE <head>, but only where it equals origin/<head>; otherwise the run refuses and names both SHAs. With no local branch, the command is git worktree add --track -b <head> WORKTREE origin/<head>.
  8. Write RUN_DIR/issue.md. With one or more closing issues, it holds each issue's title and decoded Markdown body, one block per issue appended in the order the pull request lists them, each written by gh issue view <K> --json number,title,body --jq '"# #\(.number) \(.title)\n\n\(.body)\n"', so CRITERIA reads every issue's Acceptance lines. Raw --json output keeps each body inside an escaped JSON string, where CRITERIA finds no heading and no checkbox line. With no closing issue, it holds the pull request body under # PR #<M>. CRITERIA is read from that file as Resolve once reads it. Then run INSTALL_CMD and VERIFY_CMD in WORKTREE, and write RUN_DIR/baseline.txt in Step 1's format, before any repair commit.
  9. The item 5 command without --dry-run. It exits 3 while issue.md or baseline.txt is missing, which keeps item 8 ahead of the files that make RUN_DIR resumable. It writes base_sha, pushed_at, max_review_rounds, queue.md where a ## Deferred findings comment from the pull request's author or LOGIN seeds it and the file is absent, and then adopted.json, last, because its presence is what tells item 4 that adoption finished. Then go to Step 6's first adopted pass.

A stop anywhere in this section comes before any step opens, so, like a stop at Step 0, it writes nothing to timing.log.

Done when: RUN_DIR/adopted.json exists beside issue.md, baseline.txt, base_sha, pushed_at, and max_review_rounds; WORKTREE is on the head branch at origin/<head>'s SHA; and the confirmation was put to the user in one message and answered yes — or the run stopped at a refusal, a dry-run, or a no, with nothing pushed.

Step 1 — Isolate

ProbeDecision
git status --porcelain in ROOT non-empty, untracked includedtake
Another run in flight: any <COMMON>/work-issue/issue-M/ (M≠N) not under closed/, or a git worktree list --porcelain entry at a <PROJECT>-issue-M pathtake
ROOT clean, on DEFAULT, nothing in flightskip: git switch -c issue-N origin/DEFAULT in place
ROOT clean, nothing in flight, HEAD not on DEFAULTask (folded into Step 0's question)
A worktree this skill did not create existsask
--isolate / --no-isolatepins the row; --no-isolate on a dirty tree still stops with "commit or stash first"

Take with HERDR: herdr worktree create with --cwd ROOT --branch issue-N --base origin/DEFAULT --path WORKTREE --no-focus, reading the IDs back out of the JSON response. --cwd ROOT is what names the source repo: with no source flag herdr branches off the focused workspace's repo, and --workspace branches off whatever repo herdr bound that workspace to when it opened, which a later cd never updates, so either one can put the worktree in another repo with no error. The response's .result.workspace.worktree.repo_root must equal ROOT; on a mismatch, stop with "herdr made <WORKTREE> in <repo_root>, not <ROOT>; remove that worktree, then work-issue N.", because herdr just made a worktree in someone else's repo and removing it is the user's call. Check those flag names against herdr worktree help at run time — the installed binary is the authority, and this line is a cache of what it printed once. Take without herdr: git fetch origin DEFAULT && git worktree add -b issue-N WORKTREE origin/DEFAULT.

Once the tree exists, run work-issue/scripts/review-rules.py check <tree>, with <tree> as WORKTREE where the row took one and ROOT otherwise, because that tree sits at origin/DEFAULT, the commit Codex reads its review rules from. On exit 1, print one warning naming review-rules.py install <repo> as the command that refreshes the repo's AGENTS.md and carries the block's pull-request conventions to Codex, say the repo's owner runs it on the default branch and merges it in a pull request of its own, never in this run's tree, and continue the run. On exit 3, print the script's stderr once and continue. The step never runs install and never edits the repo's AGENTS.md, since that file belongs to the repo's owner and a stale block costs a review, not a build.

Then INSTALL_CMD, then VERIFY_CMD, saved to RUN_DIR/baseline.txt as a first line exit: <status> holding its exit status, then its output tail. divvy-up reads the status from that line, because output alone can't show a non-zero exit that printed no failure. With VERIFY_CMD absent, run nothing and write RUN_DIR/baseline.txt holding the single line absent, because the resume probe reads the file's existence as Step 1 finished. A baseline captured before any worker runs is what tells the first wave's workers and gate, and Step 4, whether a red suite belongs to this run or was already red.

Where the invocation carries --wave-baseline <path> and VERIFY_CMD is not absent, the handed file can stand in for the VERIFY_CMD run. Step 1 reuses the handed baseline exactly when BASE_SHA equals its base: SHA and both recorded commands equal the resolved INSTALL_CMD and VERIFY_CMD. INSTALL_CMD runs in this tree first whether or not the baseline is reused, because the workers need its dependencies; the reuse replaces only the VERIFY_CMD run. Once INSTALL_CMD has run, run work-issue/scripts/run-state.py reuse-baseline --wave-baseline <path> --base-sha BASE_SHA --install INSTALL_CMD --verify VERIFY_CMD --out RUN_DIR/baseline.txt, passing the BASE_SHA this step writes to RUN_DIR/base_sha and each command as resolved, absent included. Exit 0 means the script wrote RUN_DIR/baseline.txt from the handed file, and VERIFY_CMD does not run. Any other exit status means print the script's stderr once, so the wave's reader sees why this lane ran its own suite, then run VERIFY_CMD as the paragraph above says. A wave whose VERIFY_CMD chains more suites than this plan names declines here, and that decline is the expected result: the lane runs its own VERIFY_CMD once, and never widens it to match the handed file. The guard sees only the SHA and the command text, so a difference outside git between the wave's tree and this one, such as an untracked local config file, passes it.

Every later command in a taken worktree names it by absolute path (git -C WORKTREE …). Subagent shells reset their working directory between calls, so a relative path silently addresses ROOT instead.

Done when: BRANCH exists at origin/DEFAULT's SHA in the tree the run will use, RUN_DIR/base_sha holds that SHA, INSTALL_CMD ran or was absent, and RUN_DIR/baseline.txt opens with exit: <status>, VERIFY_CMD's real exit status, followed by its real output, or, where VERIFY_CMD is absent, holds the single line absent, or, where reuse-baseline exited 0, holds the wave baseline's exit: line and output tail as that command copied them.

Step 2 — Dispatch

Continue divvy-up at its Step 5, in the work tree, naming RUN_DIR/baseline.txt as its BASELINE: the wrapping skill's baseline that Step 0 item 5 said would come, and name VERIFY_CMD to it again as the verify command at every wave it continues. divvy-up's Step 6 gate runs it in the deferred form Step 3's Deferred liveness paragraph gives. Each time Step 2 continues divvy-up at a wave, the first dispatch after a resume included, name instead the RUN_DIR/baseline-<wave>.txt of the highest-numbered wave already settled, and baseline.txt only while no wave has settled. Where VERIFY_CMD is not absent and that wave's file is missing, which only a run gated before these files existed can leave since Step 3 saves it ahead of any commit or marker, run VERIFY_CMD at HEAD on the clean, committed tree before dispatching, save it as that wave's baseline-<wave>.txt in baseline.txt's format, and name it. That run's output is the baseline the settled wave left, since the tree it reads is the one that wave's gate passed on. With VERIFY_CMD absent, name no baseline file at any wave and tell divvy-up its BASELINE is absent, so its Step 3 absent rule holds rather than its named-file rule, which reads a file with no exit: line as red. A resumed session has lost divvy-up's in-memory refresh, and the run-start file would pass a failure an earlier wave fixed and a later wave brought back. divvy-up's Step 4 never runs here, so a red baseline adds no question. It reaches each worker as {{BASELINE}} and the gate as data, and the gate charges a task only with a failure that baseline does not show. Where the baseline is red and verification fails with either the wave's output or the baseline naming no individual failures, the gate stops the run with "Verification failed without naming individual failures, so this wave's failures can't be told from the baseline's.", followed by both outputs quoted.

Steps 2 and 3 run once per wave, in the order ## Waves gives: dispatch the wave here, gate and settle it as Step 3 says, then dispatch the next wave in the same turn. A settled wave with a later wave pending is not a stopping point. The one exception is an invocation carrying --until-boundary: once a wave settles and a later wave in ## Waves is still pending, it ends at the boundary stop with "wave <k> settled; work-issue N dispatches wave <k+1>." instead of dispatching, and the next launch resumes at wave <k+1> through row 7, or, where herdr reads the issue-N agent idle or done, through row 21, whose cell sends a task with neither a report nor uncommitted changes to Step 2 at its wave. After the last wave settles the flag changes nothing, and Step 3's self-review runs in the same turn. Without the flag, Step 2 continues until every wave in ## Waves is settled, and the Step 0 yes covers every one of them, not wave 0 alone. Between waves the run stops only at the boundary stop or a divvy-up stop listed under Where a Run Stops. On kendrick/cambium three lanes each committed wave 0 and then went idle with wave 1 ready, printing nothing, and each read as a run still working until the user noticed.

Substrate, by shape: one task in one wave with HERDR goes to herdr agent start issue-N --kind <kind> --pane <pane> -- --model <model> (<model> is the task's routed model, the Model cell of its ## Waves row; the -- hands --model to the agent's own CLI) and then herdr agent prompt issue-N "<prompt>" --wait --timeout <ms>. --wait returns once herdr reads the agent idle or done, and that can come before the report: a worker that ends its turn with a suite still under a background monitor writes RUN_DIR/reports/<task>.json only when the suite finishes. So after --wait returns, wait for that file with a background until-loop bounded by the same <ms>, never a foreground sleep, and enter Step 3 only once it exists. A file still missing at the timeout stops the run with "<task>'s report never landed while herdr lists issue-N; close the agent's pane if the worker is gone, then work-issue N.", with nothing reverted, and resume row 21 holds the same wait for a run that stopped in between. Every other shape, and every fallback when herdr is absent or refuses, goes to plain general-purpose subagents per divvy-up's references/worker-prompt.md. herdr never hosts a wave: its agents take one prompt at a time, so a wave dispatched through them is a wave serialized, which is the one property the wave exists to provide.

Every dispatch carries this skill's references/worker-prompt.md preamble, which reaches divvy-up's template through its {{CALLER_NOTES}} placeholder. Fill the preamble's {{ISSUE}}, {{CRITERIA}}, and {{TREE}} per task, write it to RUN_DIR/prompts/<wave>-<task>.caller.md, and pass that file to divvy-up's render-prompt.py as --caller-notes, with --verify-cmd set to VERIFY_CMD. divvy-up's PROMPT_DIR is RUN_DIR/prompts/, so each rendered prompt lands at RUN_DIR/prompts/<wave>-<task>.md and the worker gets the one-line pointer divvy-up Step 5 dispatches. prompts/ is outside the work tree, so Step 6's ownership derivation never sees it, and run-state.py reads only the directories it names, so the directory adds no resume row. A render that exits non-zero stops the dispatch with its stderr quoted. Herdr keeps sending the full prompt inline: one task is one prompt, herdr agent prompt takes the text directly, and the preamble heads the whole prompt there rather than reaching a template, so nothing is rendered or written to prompts/ for a herdr dispatch. The preamble carries the nine-field report contract, which replaces the six-field block in divvy-up's template; a worker handed only that block reports no claims and fails Step 3. Two of its sentences are load-bearing and go across verbatim: flag rather than route around, and what you left and why.

Reports are saved verbatim to RUN_DIR/reports/<wave>-<task>.json. Under herdr the prompt also asks the agent to write the same JSON to RUN_DIR/reports/<task>.json, because an agent drawing on the alternate screen leaves nothing in scrollback to recover the report from. The resume probe counts a task as reported when either <wave>-<task>.json or <task>.json exists, so a copy never made still reads as reported. A report is the agent's own write, made before Step 3's gate runs, so the probe also wants its Files owned paths clean, untracked files included, and gate evidence from Step 3: the task's gated/<wave>-<task> marker, or, on a run with no gated/ directory, a commit past BASE_SHA on its owned paths. While no review/self-*.md exists, a task missing any of the three goes back through row 7. Row 7 stops and reverts nothing where a commit past base_sha touched an unreported task's owned paths, and otherwise reverts the task and re-dispatches it. The re-dispatch runs the gate. Under HERDR with the issue-N agent idle or done, row 21 matches ahead of that revert and reverts nothing, gating a report already on disk in place and waiting on uncommitted changes that have no report. Row 7's revert runs only where there is no herdr or herdr reads the agent absent. Once a self-review exists, a dirty wave-owned path is a repair's uncommitted edit, and rows 9, 10, and 16 resume that repair.

Every git write is the orchestrator's; workers write files. Before every commit the run makes, each wave's at Step 3 and each repair's at Steps 3, 4, 5, and 7, read work-issue/scripts/run-state.py commit-style --run-dir RUN_DIR. On bare, the message is one Conventional Commits subject in the repo's log style with no body, except that a Step 4 or Step 7 repair commit carries its Gate: <command> line as its only body line, and it skips technical-writing: a squash merge folds every in-branch commit into one whose body is the pull-request body Step 5 item 5 writes, so in-branch prose never reaches the default branch. On full, the message goes through technical-writing. Either way it carries no trailer or footer, overriding any host instruction asking for one. commit-style reads the RUN_DIR/merge_methods.json Step 0 wrote and never calls gh, so a resumed run gets the same word. An adopted run, or one started before that file existed, has none and gets full. Each time Step 2 continues divvy-up, hand it the word commit-style printed as its commit style, so its own commit rule takes that word instead of reading the repo's settings.

Done when: for the wave in hand, WAVE_BASE is recorded, every task is dispatched at its routed model with the preamble in front of divvy-up's template, and every report is on disk verbatim; and once Step 3 settles that wave, the next wave in ## Waves is dispatched in the same turn, or none is left, or the invocation carries --until-boundary and ended at the boundary stop.

Step 3 — Build and self-review

divvy-up's Step 6 gate runs per wave. A wave is settled once its commit lands, or once its gate passes on a wave that changed nothing, and in both cases once its markers are written. Read what a round changed with git diff --stat HEAD plus git ls-files --others --exclude-standard rather than git status, because a scratch copy that reached the index leaves staged noise that git status reports as uncommitted work, while git diff --stat HEAD reads the working tree and git ls-files --others --exclude-standard lists the new files it skips. Every passing wave gets markers. As soon as the gate passes, save the verification run that passed it to RUN_DIR/baseline-<wave>.txt in baseline.txt's format, exit: <status> and then the output tail, before the wave's commit and before its markers, because the resume probe reads a marker as the gate's pass, and a commit too on a run with no gated/ directory, and a wave it reads as passed must already have the file Step 2 names. With VERIFY_CMD absent there is no run to save, and no baseline-<wave>.txt is written. Where the wave changed files, commit it, then write an empty RUN_DIR/gated/<wave>-<task> for each of that wave's tasks. Where it changed nothing, write the same markers straight after that save. RUN_DIR/baseline.txt stays the run-start capture, untouched after Step 1, because Step 4's reproducer reads it. Either way the markers land before the next wave is dispatched, and the run returns to Step 2 for the next one. Once the last wave in ## Waves is settled, divvy-up's Step 7 read of git diff BASE_SHA against PLAN runs unchanged, and only then does code-review run. The resume probe reads the marker as the gate's pass. It reads a commit that way only on a run with no gated/ directory, one from before markers existed, because a commit names paths, and a later wave's task can share a path with an earlier wave's commit.

Deferred liveness. Every gate that decides no push runs its command in the deferred form (export WORK_ISSUE_DEFER_LIVENESS=1; <command>), <command> being VERIFY_CMD or the scoped command exactly as that gate would otherwise run it. Four gates defer: the build wave gate, which is divvy-up's Step 6 verification; Step 3's re-gate of a repair; Step 4 item 4's scoped gate and its VERIFY_CMD fallback; and Step 7's gate. At the build wave gate, the session running divvy-up's Step 6 runs the VERIFY_CMD it was handed in the deferred form, so the verify command named to divvy-up at Step 0 item 5 and Step 2, and to each build worker through --verify-cmd, stays plain VERIFY_CMD, and a repair worker runs the repair's verify command plain too. Step 5 item 2 and Step 8 item 2 decide a push, so every gate run under them runs its command bare, Step 5 item 2's rebase repair re-gate and the gate of that repair's red-team repair included, because nothing runs VERIFY_CMD again between those gates and the push. Step 1's baseline run and Step 2's re-capture of a missing baseline-<wave>.txt are captures, and run bare too. The parentheses end the export with the gate, so on a host whose shell keeps state between calls it never reaches a push gate, and a repair commit's Gate: <command> line names the command inside them. A smoke that reads the variable skips its liveness search, about 20 of tests/work-issue-smoke.sh's 27 minutes on a branch that edits run-state.py, and each push gate still runs it in full.

Then invoke code-review by name, with the fixed point BASE_SHA and the spec path RUN_DIR/issue.md, in session on the session model. Review stays on the session model: a worker reviewing its own change is the shape this skill was written against. Hold both axes verbatim for RUN_DIR/review/self-<round>.md, under ## Standards and ## Spec, and write nothing to review/ yet.

Where ponytail-review is installed, invoke it by name in session once code-review has dispatched its Standards and Spec subagents, while they run, against the same diff, and route no finding until both have run. Aggregate code-review's two axes when both subagents report back; on a host where they block until they return, ponytail-review runs after code-review finishes. It is installed when the host's available-skills list names ponytail-review, bare or plugin-qualified as <plugin>:ponytail-review; that list is the only check. Its one argument names the change: the branch diff git diff <BASE_SHA>..HEAD in the work tree, by the tree's absolute path. It gets nothing else, not the issue, the plan, or the worker's report, because it reviews the code rather than the claims. Save its output verbatim under ## Ponytail in the same self-<round>.md. Where it is not installed, write ponytail-review not installed; skipped as the only line under ## Ponytail, print that line once, and carry on with the step unchanged. Write self-<round>.md once, with ## Standards, ## Spec, and ## Ponytail together, only after both reviewers have run or the skip line is decided, writing it as self-<round>.md.tmp and renaming it to self-<round>.md once complete. The resume probe counts a self-review by the file alone, so a file written before ## Ponytail resumes at row 9's fix dispatch and routes without ponytail's findings, while a run that stops before the rename leaves no self-*.md and resumes at row 8, which runs code-review again.

Route each finding. A Spec finding naming a CRITERIA line, or a Standards hard violation, becomes a repair dispatch to the worker with the finding quoted and {{PRIOR}} carrying that worker's earlier report. Render it as Step 2 renders a task, for the row of the task being repaired (--wave and --task of that task), with --verify-cmd set to the repair's verify command in place of VERIFY_CMD, --prior RUN_DIR/prompts/fix-<n>.prior.md holding the worker's earlier report followed by the quoted findings and then the repair override line, and --out RUN_DIR/prompts/fix-<n>.md, n one past the highest fix-*.prior.md already there, so each repair keeps its own file and the build prompt stays as the worker received it; under herdr it goes inline. A repair whose findings name a path outside the repaired row's Files owned, a peer task's path or one no task owns, goes inline too and is not rendered, as Step 7's repair does, since render-prompt.py renders one row and that row's Files you own would forbid the fix; pipe the named paths to divvy-up/scripts/check-waves.py owners RUN_DIR/plan.md --wave <wave> --task <task> on stdin, one per line, and it exits 1 on a path outside the row, and list as owned the row's paths plus each path the findings name. The repair's verify command is what a rendered repair gets as --verify-cmd and what an inline repair fills into {{VERIFY_CMD}} by hand, at this step, Step 4 item 4, and Step 7 alike. Compute it from the work tree, just before the dispatch, as the output of work-issue/scripts/run-state.py scoped-cmd --plan RUN_DIR/plan.md --report <scope>. For a Step 3 repair that stays inside its row, <scope> is the repaired task's build report, RUN_DIR/reports/<wave>-<task>.json, or <task>.json under herdr. For every other repair, <scope> is RUN_DIR/prompts/<repair>.scope.json, written just before the dispatch as {"files_changed": [...]} listing the paths the prompt hands the repair, <repair> being fix-<n>, redteam-repair-<k>, or repair-<k> to match the report the repair will write. The repair's verify command is VERIFY_CMD, with no scoped-cmd call, where a failed claim or finding names no path or the run is adopted and has no plan, and it is VERIFY_CMD on scoped-cmd exit 1. Exit 3 stops the run quoting its stderr, and with VERIFY_CMD absent the repair's verify command is absent. Step 4 item 4's red-baseline skip is a gate's rule and leaves this command as computed, since a worker's run saves no baseline either way. The template has a worker run the command its definition of done names ahead of {{VERIFY_CMD}}, and a repair's verify command can run more suites than that one, so every repair prompt, rendered or inline, ends its {{PRIOR}} with this repair override line, which the template places directly above its verification paragraph: This is a repair: run the command in the verification block below, not the one your definition of done names. A smell-baseline judgment call is the worker's to fix or to leave, and leaving it goes in left with the reason. A ## Ponytail finding routes by the group heading ponytail-review put it under, and its wording never moves it. A finding under Must fix is a required repair dispatch with the finding quoted, as a Spec finding naming a CRITERIA line is. A finding under Should fix or Nice to have is the worker's call: fix it, or put it in left with a reason, which Step 4's reproducer checks like every left reason. A ponytail finding and a code-review finding overlap when they name the same file and their line ranges intersect, and an overlapping pair routes once, at the stronger routing, a required repair over the worker's call, with both findings quoted in the dispatch. Two ponytail findings never merge. Re-gate—the format pass divvy-up's Step 6 runs, scoped to the repair's reported files_changed where Step 6 scopes to the paths it derived, then VERIFY_CMD green—then commit. Between that green run and the commit, save the run to RUN_DIR/baseline-repair-<n>.txt in baseline.txt's format, exit: <status> and then the output tail, n one past the highest number already present, 1 where none is. Every repair gate that runs the full VERIFY_CMD does this, Step 4's, Step 5 item 2's, and Step 7's included; the scoped gate Step 4 item 4 defines saves nothing, and with VERIFY_CMD absent no gate writes anything. Immediately before its format pass, a repair gate records an untracked manifest as divvy-up's Step 5 does, each path from git ls-files --others --exclude-standard with its git hash-object -w, and uses HEAD plus that manifest as its WAVE_BASE. HEAD holds the tracked bytes because every wave that changed files is committed before a repair is dispatched, and the manifest keeps the error-path revert below from deleting an untracked file the user already had. The paths the pass changed outside files_changed are found as divvy-up's Step 6 finds them: every path the derivation lists after the pass that it did not list before. Where the pass's command itself errors, divvy-up's Step 6 reverts the pass's writes outside the derived set and then classifies the error, and a repair does the same with its reported files_changed as the derived set. After that first revert, revert the repair's own writes on every branch: each files_changed path HEAD tracks goes back to HEAD, and each one the pre-pass manifest lists as untracked is deleted, since the run started on a clean tree and committed every wave before the repair, so an untracked path the repair reported is one it created. Delete any report already saved for the repair, so the resume probe still reads it as owed. An error naming only paths in files_changed is the repair's failure: re-dispatch the repair once, at the same model, with the formatter's output attached. Where that re-dispatched repair fails the format pass the same way again, revert its writes as above and stop the run. An error naming no files_changed path, output naming both a files_changed path and an outside one, as divvy-up's mixed rule has it, or an error that cannot be tied to a path either way stops the run with the tree clean, so a resume lands on that repair's own row rather than on its leftovers. A repair never passes through that Step 6, and a subagent worker was told by divvy-up's template to leave any tree-wide format or --fix pass to the orchestrator.

The worker's final report is RUN_DIR/reports/build-final.json, and its claims is non-empty. Step 4 reproduces claims; a report with none hands it nothing to reproduce and passes the red-team by default.

Done when: every wave in ## Waves settled, with a gated/<wave>-<task> marker for each of its tasks, and, where VERIFY_CMD is not absent, a baseline-<wave>.txt for each wave settled since these files existed, while a wave gated before then may lack one, since Step 2 writes the one it names before it dispatches; code-review ran against BASE_SHA with the issue as spec; ## Ponytail in self-<round>.md holds ponytail-review's output, or the skip line where it is not installed; every Spec finding, Standards hard violation, and Must fix finding fixed and committed, or in left with a reason, each committed repair preceded, where VERIFY_CMD is not absent, by the baseline-repair-<n>.txt its green gate saved; build-final.json exists with non-empty claims.

Step 4 — Red-team

Input is claims, left, and plan_concerns from the final report. The rule, quoted from adversarial-review: a finding is a hypothesis until something that did not author it reproduces it. A claim is the same object pointed the other way, and it gets the same treatment.

  1. Preflight: the work tree is clean. Commit first — a verifier running against uncommitted changes tests something the review never looked at. Item 2's reproducer and item 7's trigger both read this commit, so it lands before either starts.
  2. Overlap. On the build's round 1, dispatch the reproducer in the background (a background subagent, or codex exec as a background command), and run item 7 while it runs: the trigger match, the reading, trigger.txt, and, where it fired, the adversarial-review invocation and its persist. Neither reads the other's output, but the review writes its tests and fix commits into the work tree while the reproducer runs, so the reproducer gets a tree of its own. Right after item 1's commit, clear a leftover RUN_DIR/redteam/repro-tree as rows 10 and 11 do, then run git worktree add --detach RUN_DIR/redteam/repro-tree HEAD. Run INSTALL_CMD in RUN_DIR/redteam/repro-tree before dispatching the reproducer, and nothing where INSTALL_CMD is absent, because dependencies are tree-local and Step 1 installed them in the work tree only. That path is the tree path the reproducer receives, and HEAD is item 1's commit SHA. Once the reproducer returns, run git worktree remove --force RUN_DIR/redteam/repro-tree, before items 3 through 6 route. Where git worktree add, remove, or prune on that path, or INSTALL_CMD run there, exits non-zero, stop and quote its stderr. Route nothing, and run none of items 3 through 6, until both the reproducer's verdicts and the review, or a trigger.txt reading fired: no, have returned; items 3 through 6 then run in order. On a host that cannot run the reproducer in the background, nothing overlaps, and item 7 runs after item 6. A repair round, and Step 8's rounds, run the reproducer alone.

    Read references/redteam.md and run one reproducer, resolving its executor from printenv WORK_ISSUE_REPRODUCER at the start of every round. With WORK_ISSUE_REPRODUCER unset or empty, the reproducer is a fresh general-purpose subagent, sonnet by default and opus when any claim's path matches a trigger row. With WORK_ISSUE_REPRODUCER set to a codex: value such as codex:gpt-6-luna:xhigh, it runs as codex exec under the cap and split in references/redteam.md, then falls back to that subagent for exactly the claims work-issue/scripts/merge-verdicts.py reports uncovered, and appends the reason to RUN_DIR/redteam/executor.log. The fallback conditions: the value is malformed or names an executor other than codex, codex is not on PATH, the host cannot run a background command, the round resumes over verdict lines an interrupted run left, codex exec exits non-zero, the cap fires, or its verdict lines leave a claim uncovered, a line that does not parse included. A fallback reports its reason and never stops the run. Either way, the reproducer receives the claims, BASE_SHA, HEAD, the tree path, baseline.txt, and RUN_DIR/plan.md as cat -n prints it, or none where the run has no plan, plus REPAIR_BASE in a repair round, and nothing else — not the worker's reasoning, not its summary, not its proposed fixes. A baseline.txt reading absent means the repo has no verification command, so nothing ran before this run and nothing was already failing. Its stance is refutation. Per claim it returns the command, the real output, and a verdict of REPRODUCED, NOT_REPRODUCED, or UNVERIFIABLE; per left entry, whether the stated reason holds against the code. Before running a claim's command it proves the change that claim rests on shows in the range's per-commit history (git log -p BASE_SHA..HEAD -- <path> | grep -n <symbol>, with <path> the claim's own path field), so a line a later commit removed still counts and the claim's command decides whether it survived, and a claim whose change it cannot find, or that names no path, is NOT_REPRODUCED with that grep as the evidence. In a repair round, a claim about the repair itself runs that grep over REPAIR_BASE..HEAD instead, and redteam.md says which range judges a left reason. Any fixture it edits to provoke a failure is proved the same way. Where a claim concerns a seam some production caller reaches at HEAD, its last reproduction drives that caller rather than the seam. A fixture built by hand shares the assumptions of whoever built it; the caller does not. The seam run stays and the caller run follows it. Every verdict carries reproduced_at beside its verdict: caller or seam where a command ran, and null wherever none did—an UNVERIFIABLE claim, which arrived with no command, and a claim the change-exists grep refuted before its command ran. A verdict that ran also carries a caller object holding the search that looked for callers and what driving the nearest one produced. A search that turns up no production caller is an answer: reproduced_at is seam, caller.path is null, and the evidence is the search with whatever it returned—nothing, or the hits that named the symbol and ran it nowhere.

  3. Save the verdicts verbatim to RUN_DIR/redteam/round-<k>.json; on the codex path, merge-verdicts.py writes that file instead.
  4. NOT_REPRODUCED sends a repair dispatch carrying the run that failed—caller.command and caller.output where reproduced_at is caller, and the top-level command and output otherwise. A caller-level failure leaves the seam's own run green, and a claim the change-exists grep refuted never reached a seam run at all, so on a null verdict that top-level pair is the grep and its empty result. The dispatch fills {{VERIFY_CMD}} with the repair's verify command Step 3 defines, its scope file RUN_DIR/prompts/redteam-repair-<k>.scope.json listing each failed claim's path. Before that dispatch, write git rev-parse HEAD to RUN_DIR/redteam/redteam-repair-base-<k>, k the round the repair answers, unless that file already exists. Write it once and never overwrite it, as Step 7 does for repair-base-<k>; the redteam- prefix keeps the resume probe, which reads repair-base-<k> as a triage repair's base, from taking this one for it. Re-gate the repair as Step 3's repair is, with the scoped gate in place of its VERIFY_CMD run: work-issue/scripts/run-state.py scoped-cmd --plan RUN_DIR/plan.md --report RUN_DIR/reports/redteam-repair-<k>.json. Run it, and the command it prints, from the work tree, where a relative path in a Done when span resolves. Before calling scoped-cmd, read the latest baseline's exit: line. Where it reads anything but exit: 0, skip scoped-cmd and take its exit 1 fallback below, because a scoped pass that clears a failure that baseline holds saves no file recording the fix, and a later repair that brings the failure back would read green against it. Exit 0 prints the done-when command of every ## Waves task that owns a path in the report's files_changed, in table order with repeats dropped. One command prints as written, and two or more print as sh -c '<cmd>' joined by &&, so the line fails whenever any task's command fails, whatever ;, &, #, or set -e a span holds, in any shell that runs the line. A task's command is the first backticked span in its Done when cell whose first word resolves on PATH. Run that command and read it by VERIFY_CMD green against the latest baseline, the stop for output that names no individual failures included. A scoped run saves no baseline-repair-<n>.txt, because its output covers a fraction of the suite and a later full run read against it would show the rest as new failures. Exit 1 is the fallback, and its one run-state: scoped-cmd: stderr line names the cause: a files_changed path no task owns, a matched task whose done-when names no command, a matched task whose Done when cell holds an unclosed backtick span because a | inside the span split the cell, a plan with no ## Waves task rows, or an empty or missing files_changed. On exit 1, gate on VERIFY_CMD green and save baseline-repair-<n>.txt as Step 3 says. An adopted run has no plan, so it never calls scoped-cmd and gates on VERIFY_CMD. Exit 3 means the plan or report is unreadable or the report is not JSON: stop the run quoting its stderr. With VERIFY_CMD absent nothing runs, scoped or full. The repair commit's body carries one Gate: <command> line naming the command the gate ran, the scoped command or VERIFY_CMD, so a reader can tell a scoped pass from a full one; the push gate re-runs the full VERIFY_CMD either way. Then run round k+1 over the failed claims only, with redteam-repair-base-<k> as its REPAIR_BASE. A build round, round 1, has none. That repair's report lands at RUN_DIR/reports/redteam-repair-<k>.json, k the round it answers, a name apart from Step 7's repair-<k>.json: the resume probe matches a triage round to its repair by number, and a build repair called repair-1.json read as the repair for triage round 1. Repair re-fire. Item 7's review covered the HEAD before this repair, so once round k+1 over the repair comes back clean, run git diff "$(cat RUN_DIR/redteam/redteam-repair-base-<k>)"..HEAD as its own command and check its exit, then pass its output to adversarial-review/scripts/match-triggers.py rows --only 1,2,4 and, where that prints a row, to lines --only 1,2,4, reading each printed line as item 7 reads it, in its hunk of the repair diff. The review re-fires exactly when a line reads implements, whether or not item 7's review fired. Step 8's severity condition has no counterpart here. Wherever the rows run prints a row, write the result to RUN_DIR/redteam/trigger-redteam-repair-<k>.txt in trigger.txt's format. Where it fired, run adversarial-review as item 7 does, write its report verbatim to RUN_DIR/redteam/ar-report-redteam-repair-<k>.md, copy its run directory's escalation.md to RUN_DIR/redteam/escalation-redteam-repair-<k>.md where that review wrote one and delete that file where it wrote none, then copy its state line into RUN_DIR/redteam/ar-state-redteam-repair-<k>.txt. The report and the escalation copy land first, as item 7 orders its own, because the resume probe reads the state file as the re-fire settled. Step 5 carries both into the body. These names stay apart from Step 8's trigger-repair-<k>.txt family, which is numbered by triage round. A non-zero exit from git diff or either matcher run decides nothing: stop and quote its stderr. Two rounds, then stop with the evidence, the way divvy-up stops on a task that failed twice. That stop runs policy.py sort --kind redteam on the second failed round first, where the invocation carries --repair-class, and repairs or defers by its ruling as references/policy.md says; any ask in its output stops the run. Where the two-failed-rounds stop ends the run, a human answers it by appending redteam-continue <k> to RUN_DIR/redteam/continue.log, k the newest failed round, and the answer buys one round: the resume probe routes to the repair and round k+1, and a failed k+1 stops again until a new line names it.
  5. UNVERIFIABLE becomes a "Not independently verified" section in the pull-request body.
  6. Every plan_concerns entry goes into a "Plan concerns" section in the pull-request body. Only an entry with open: true, or with no open field, also becomes a queue.md row whose source is worker; open: false means did settled it in the branch.
  7. Trigger. On the build's round 1 this item runs while item 2's reproducer runs, as item 2 says, and its outcome routes nothing until that reproducer returns. Match the changed lines of the diff against the diff signals of rows 1 (money), 2 (authz), and 4 (schema) of adversarial-review/references/trigger-table.md:

    git diff BASE_SHA..HEAD | adversarial-review/scripts/match-triggers.py rows --only 1,2,4

    The script reads the table at run time and applies its matching rules, so no signal is copied here: the table is upstream and it gains signals. It prints one <n> <name> line per matched row. Any output line makes the diff a candidate, and a candidate fires the trigger only where a reading confirms it. The match is lexical, so the English "where" hits authz and "default" hits schema. For a candidate, print each matched changed line:

    git diff BASE_SHA..HEAD | adversarial-review/scripts/match-triggers.py lines --only 1,2,4

    Each output line is <n> <name>, the path, the signal, and the changed line with its + or -, tab-separated. Read each printed line in its hunk (git diff BASE_SHA..HEAD -- <path>) and give it one verdict. implements: the line computes or converts a money or quantity value; adds, removes, or changes a predicate or check deciding which rows or actions a caller can reach; or changes a schema, migration, or constraint. That holds in code, in SQL a program runs (a query string passed to an execute call counts), and in an instruction an agent executes, such as a SKILL.md step. mentions: the signal is a word in prose, a heading, a comment or docstring, a ledger row, a test expectation, fixture data, or an example prompt or sample session that names the hazard without changing what anything does. A removed line counts as the change its removal makes. A line the reading cannot settle reads implements. The trigger fires on the first implements line, and the lines after it need no verdict. --deep fires the trigger on its own, with no reading. A non-zero exit decides nothing, from rows or lines alike: stop and quote its stderr, since an empty output from a failed run reads as fired: no. Record the result in RUN_DIR/redteam/trigger.txt: first line exactly fired: yes or fired: no, then the rows command and its output lines, verbatim. Where the reading ran, the lines command follows, then one line per line read: implements or mentions, a tab, the lines output line verbatim, a tab, and the reason in a few words. Where --deep fired it, the line after the rows output is reading: skipped, --deep.

    Where it fired, invoke adversarial-review by name with FIXED_POINT = BASE_SHA in the work tree. Pass --deep on to it where this run carries --deep, so the review pins the Depth 2 that Step 0 forecast for a --deep run. Where mode.txt names adversarial-review, hand the review that file's line, verbatim, in the same invocation, as the wrapping skill's confirmation its Step 2 checks the derived depth against: a resumed run has no conversation holding the yes. Put the line last, after the fixed point and any flags, wrapped in double quotes, so the review can tell where it starts and read it as the quoted text its Wrapper confirmation rule names. Read its report and its escalation.md, nothing else. Where RUN_DIR/redteam/mode.txt names adversarial-review, the Step 0 yes carries into its Step 2 as that question's answer, and the review fans out without asking again, but only while the depth adversarial-review derives at its Step 2 is at or below the depth forecast in mode.txt. A deeper derived depth answers nothing: the user said yes to the forecast, not to a costlier run. A missing file answers nothing, and the review asks its own question. Once the report is read, delete RUN_DIR/redteam/ar-state.txt where an earlier review left one, as the build review's sits on disk when Step 5 item 2 red-teams a fix, so a stop before this review's persist resumes through row 11 rather than past it. Then write the report it printed, verbatim, to RUN_DIR/redteam/ar-report.md, replacing any copy an earlier attempt left, and copy its run directory's escalation.md to RUN_DIR/redteam/escalation.md where this review wrote one, and delete RUN_DIR/redteam/escalation.md where this review wrote none. Step 5 builds the body from these two files, so they always describe the latest review. Both writes land before RUN_DIR/redteam/ar-state.txt, because the resume probe reads that file as the review finished, and a run that resumes past it never persists them. Then copy the blocking (REPRODUCED): … UNVERIFIED: … line its ledger.py state prints into RUN_DIR/redteam/ar-state.txt, with its run directory's path on the line above. That file is what the resume probe reads: adversarial-review writes no terminal report of its own, and its run directory exists from its preflight onward, so the directory alone cannot say whether the review finished. Its --fast flag narrows its own roster and never suppresses this trigger.

Done when: every claim carries a reproducer verdict that pastes the real output of every command the reproducer ran for it, and names no command where none ran; every verdict whose command ran says whether it was reproduced at the caller or at the seam, and a seam-only one carries the caller search that decided it, while a verdict where no command ran carries reproduced_at null; no claim is NOT_REPRODUCED, or the run stopped after two rounds; every left reason was checked against the code; trigger.txt is written, with a verdict for every line it read wherever the match printed a row and --deep was unset; and where the trigger fired, adversarial-review completed with every blocker fixed or named in its escalation.md, redteam/ar-report.md holds that review's report, and redteam/escalation.md exists exactly where that review wrote one, both written before ar-state.txt and after any earlier review's ar-state.txt was deleted; where the host could run the reproducer in the background, item 7 ran while round 1's reproducer ran, and none of items 3 through 6 ran before both had returned; a red-team repair whose own diff from redteam-repair-base-<k> prints a trigger row has trigger-redteam-repair-<k>.txt written and, where it fired, ar-report-redteam-repair-<k>.md, escalation-redteam-repair-<k>.md exactly where that review wrote an escalation.md, and then ar-state-redteam-repair-<k>.txt showing UNVERIFIED: 0, with the PR body carrying the first two as Step 5 item 5 says; on the overlapped round 1, the reproducer ran in item 2's repro-tree worktree after INSTALL_CMD ran there or was absent, and that worktree was removed before items 3 through 6 routed; and where WORK_ISSUE_REPRODUCER was set, redteam/executor.log has a line for the round.

Step 5 — Publish

  1. git fetch origin DEFAULT, then git rebase origin/DEFAULT. A conflict writes RUN_DIR/conflict.txt with the conflicted paths, leaves the rebase in progress, and stops: "resolve, then work-issue N". Resolving somebody else's concurrent change is a judgment call, and an unattended run guessing at it writes a merge nobody reviewed.
  2. Prove the rebase: git diff origin/DEFAULT..HEAD --stat is non-empty, and git status shows no rebase in progress. Then move the fixed point with the branch: m="$(git merge-base origin/DEFAULT issue-N)" && printf '%s\n' "$m" > RUN_DIR/base_sha, and show the file. The file is written only once the merge-base resolves, so a failed command leaves the old base for the resume probe to name rather than an empty file it would read as absent. Every later step that reads BASE_SHA—this item's own repair red-team, Step 6's in-scope test, Step 7's code-review, Step 8's reproducer and adversarial-review—otherwise diffs against the pre-rebase base and reviews every commit merged in between. The rewrite comes before the marker's removal so a stop between the two still carries conflict.txt and resumes here through row 12. Then remove RUN_DIR/conflict.txt where it exists: the marker is item 1's stop signal, and left behind it sends every later invocation back to item 1 through row 12. Then run VERIFY_CMD and read it by VERIFY_CMD green. Red here means the rebase brought a failure the latest baseline lacks: repair dispatch, re-gated as Step 3's repair is, red-team the fix with Step 4 scoped to the fix diff, then continue.
  3. gh auth status. Unauthenticated renders the body and stops.
  4. Write date -u +%FT%TZ to RUN_DIR/pushed_at, then push: git push -u origin <BRANCH>:refs/heads/<BRANCH>, or git push --force-with-lease=<BRANCH> origin <BRANCH>:refs/heads/<BRANCH> where the remote branch already exists and was just rebased. The marker goes first because GitHub stamps events to the second, and a review that lands in the push's own second has to count.
  5. The body goes through technical-writing on its pull-request-description profile, using .github/PULL_REQUEST_TEMPLATE.md where the repo has one. Without a template: summary, Closes #N, verification (the reproducer's commands and output tails, not the worker's, each claim whose command ran marked caller or seam; a caller claim carries caller.command and the tail of caller.output, and a seam claim carries the seam's own command with the case from references/redteam.md that sent it there; an UNVERIFIABLE claim ran nothing, carries reproduced_at null, and belongs to the next section), "Not independently verified", "Plan concerns", and "Left out". "Left out" names every finding adversarial-review's report lists as LISTED, with its repro command, beside what the worker put in left. With a template or without one, the body carries a "Left out" section naming every finding listed that way; where the template has no such section, append one. With a template or without one, "Left out" also names every finding RUN_DIR/redteam/escalation.md holds, each with its repro command, and "Not independently verified" names every finding RUN_DIR/redteam/ar-report.md records as UNVERIFIABLE and every territory it gives the verdict UNREVIEWED; where the template lacks either section, append it. Read both from disk, never from the conversation: a resumed session has only the files. Where neither file exists, the build's trigger never fired, and only a re-fire's files are carried. Every RUN_DIR/redteam/ar-report-redteam-repair-<k>.md and RUN_DIR/redteam/escalation-redteam-repair-<k>.md that Step 4 item 4's re-fire wrote is carried exactly as ar-report.md and escalation.md are, beside them: its LISTED findings into "Left out" with their queue.md rows, its escalated findings into "Left out", and its UNVERIFIABLE findings and UNREVIEWED territories into "Not independently verified". An escalated finding gets no queue.md row, since the human merging rules on it. Every LISTED finding written into "Left out" also gets a queue.md row with Source adversarial-review, Finding the advisory quoted with its repro command, Outside because listed advisory, a file-issue Recommendation, and Status queued; a finding an earlier pass already queued, matched by its repro command, isn't appended again. A listed advisory lives in that section and in queue.md, so a body without the section loses it from the pull request. Then, where PR resolved to nothing, gh pr create --base DEFAULT --head issue-N --title … --body-file RUN_DIR/pr-body.md; an existing pull request keeps its number, receives the push, and has any LISTED finding its "Left out" section lacks added to it, by editing that section in place so the rest of the body stays as it is. Its entries carried from escalation.md, ar-report.md, and the re-fire's copies of both are brought to match those files the same way: one the files hold and the body lacks is added, and one the files no longer hold is removed. To tell them from the worker's entries, each carried entry opens with adversarial-review:. Where RUN_DIR/review_loop exists, post the review request once the pull request exists, before Step 6's first poll start.

Done when: origin/issue-N equals local HEAD, rebased on origin/DEFAULT; RUN_DIR/base_sha holds git merge-base origin/DEFAULT issue-N; VERIFY_CMD green against the latest baseline at that SHA, or VERIFY_CMD absent; pushed_at written; exactly one open pull request for the branch, whose body carries Closes #N, marks every claim its verification section names caller or seam with that claim's own command and output tail beneath it, leaves each UNVERIFIABLE claim to "Not independently verified", carries a "Left out" section naming every LISTED finding whatever template the repo uses, carries every finding in redteam/escalation.md under "Left out" and every UNVERIFIABLE finding and UNREVIEWED territory in redteam/ar-report.md under "Not independently verified", whatever template the repo uses, and none an earlier review left, and carries no attribution trailer or footer; and, where the review loop is on, the review request posted — or the run stopped on a conflict or on unauthenticated gh, with nothing pushed.

Step 6 — Triage

The review request. Where RUN_DIR/review_loop exists, Step 5 item 5, Step 8 item 2, and Resume's review-loop paragraph each post that file's contents on the pull request as a comment, and nothing else posts it:

gh api graphql -F b=@RUN_DIR/review_loop -f id="$(gh pr view <PR> --json id --jq .id)" -f query='mutation($id: ID!, $b: String!) { addComment(input: {subjectId: $id, body: $b}) { commentEdge { node { url } } } }'

A non-zero exit from either gh call stops the invocation, quoting its stderr. The run posts as the pull request's author, and run-state.py review skips the author's comments, so the request never scores as a finding.

Where the host can run a shell command in the background and notify you when it exits (Claude Code's run_in_background, for example), wait for the review with this loop as one background command, <PR>, <SINCE>, <login>, and RUN_DIR filled in. It checks every 60 seconds, capped at 60 checks (one hour), and writes its own poll start and poll end, so the budget keeps the whole wait out of review time while you sit idle. A turn is spent only when the state leaves pending, a check errors, or the cap is hit (#165): the foreground poll spends a turn on every check, and on cambium#137 the Codex review took about 4 minutes, so a slower one outlasts the 10-minute poll and strands the lane until someone re-invokes.

MAX=60; k=0; st=pending
echo "poll start $(date -u +%FT%TZ)" >> RUN_DIR/timing.log
while [ "$k" -lt "$MAX" ]; do
  k=$((k + 1))
  out=$(work-issue/scripts/run-state.py review <PR> --since <SINCE> --author <login> --save RUN_DIR/review/poll-$k.json); rc=$?
  st=${out%%$'\n'*}
  if [ "$rc" -ne 0 ]; then st="error $rc"; break; fi
  [ "$st" = pending ] || break
  [ "$k" -lt "$MAX" ] && sleep 60
done
echo "poll end $(date -u +%FT%TZ)" >> RUN_DIR/timing.log
echo "poll $k: $st"

The loop's last output line is poll <k>: <state>, and that line routes the wake-up: findings and cleared route as below, read from RUN_DIR/review/poll-<k>.json; pending means the cap was hit; error <rc> stops the invocation naming exit code <rc> and quoting the run-state.py stderr the background command left as its output. <k> restarts at 1 each invocation.

On an adopted run, every poll check, the loop's included, adds --invoker <LOGIN>, and --author names the pull request's author, so the run's own replies never score as a reviewer's.

Where the host has no background execution, fall back to the foreground poll. Poll every 60 seconds, for at most 10 minutes in one invocation, with poll start written to RUN_DIR/timing.log before the first poll and poll end after the last, each check running the loop's run-state.py review line with its --save path at RUN_DIR/review/poll-<k>.json.

The first adopted pass. An adopted run's first Step 6 takes every unresolved thread whose newest comment comes from neither self login, the pull request's author and LOGIN, whatever its age, because a thread a reviewer opened before adoption is still owed an answer. It runs one check, with no wait:

work-issue/scripts/run-state.py review <M> --since <SINCE> --author <PR author> --invoker <LOGIN> --unanswered --save RUN_DIR/review/poll-1.json

--unanswered replaces the SINCE test for threads alone; reviews, comments, and reactions are still scored against SINCE. Route its first line as the poll routes it: findings to triage below, cleared to Step 8's final report, and pending into the poll loop, which runs without --unanswered. Only this first check passes it.

Three states, each scored relative to SINCE:

StateRule (relative to SINCE)
findingsany unresolved review thread whose root comment, or whose latest comment from a login other than the author, is newer than SINCE; or a CHANGES_REQUESTED review newer than SINCE; or a pull-request-level or issue comment newer than SINCE from a login other than the author that is not a bare approval, does not open with Codex's review-summary marker comment, and, read after any leading HTML comments, does not open with Codex's no-issues verdict or its create-an-environment setup notice
clearedno findings, and either an APPROVED review newer than SINCE, or a +1 reaction on the pull request (gh api repos/{owner}/{repo}/issues/<pr>/reactions) newer than SINCE from a login other than the author, or a comment newer than SINCE from a login other than the author that opens with Codex's no-issues verdict, read after any leading HTML comments
pendingneither

[bot] is stripped before logins are compared: REST reports chatgpt-codex-connector[bot] where GraphQL reports chatgpt-codex-connector, and an unstripped comparison reads one reviewer as two different logins depending on which API answered.

pending at the cap (60 checks in the background, ten minutes in the foreground) writes RUN_DIR/triage/waiting and stops: "no review yet on <PR URL>; work-issue N resumes here." The URL is there because this stop is the report a run gets when nothing has happened, and a run that entered Step 8 only to post a worker's queue and stopped before its final report reads pending here next. cleared goes to Step 8's final report. findings reads references/triage.md and writes RUN_DIR/triage/round-<k>.md: the heading # Triage round <k>, since <SINCE>, then one row per finding in a table with a Severity column holding the reviewer's marker (P0, P1, P2, blocking, or - where none, per references/triage.md), each row scored by the in-scope test: in scope when the finding points at a line inside git diff BASE_SHA..HEAD, names a CRITERIA line, or names a plan task; out of scope otherwise. On an adopted run the plan-task clause is inert, because an adopted run has no plan, and the CRITERIA clause is inert where issue.md holds no Acceptance lines; the diff clause still scores every finding. Ambiguous is in scope where the reviewer marked it P0 and out otherwise, with the ambiguity recorded on the row. The heading's SINCE is the --since value this poll ran with, written once when the round is created. The resume probe reads that heading, never the file's time, to decide whether the round answers the current push, because Step 8 writes reply URLs into the round after the push that answers it.

The review round cap. Round k is capped once k reaches N, the value in RUN_DIR/max_review_rounds (2 where the file is absent). While RUN_DIR/review_loop exists, no round is capped: every round routes as one under the cap does, and the loop ends on cleared, the budget stop, the poll cap, an error, or a round that pushes nothing (see FLAGS). A round already triaged as capped keeps its queued rows and their answers. A capped round is triaged and answered and never repaired. Each in-scope row's Scope cell reads in scope; queued: review round cap reached (N), and the row is appended to queue.md with Outside-because review round cap reached (N). The exception is an in-scope row whose Severity is P0 or blocking: its Scope cell stays in scope, and the run stops once the round is written, naming the cap and that row, for a human to decide. Queueing it ships a known blocker, and repairing it breaks the cap. A fresh review of new code nearly always finds something, so without the cap P2 threads hold a lane in Steps 6 through 8 for good. When the user defers an in-scope row at the review round cap's stop or at row 16's budget stop, write in scope; queued: <reason> in its Scope cell and append the row to queue.md with that reason as Outside-because. Step 8 answers it like any other queued row. A queued row is owed no repair, and the resume probe reads it as no blocker the cap would ship. Only the Scope cell records the deferral, because Step 8 writes the reply after row 16 has already read the round, and queue.md also holds out-of-scope and worker rows. Where the invocation carries --defer-after K, a round k at or above K runs policy.py sort --kind triage once its rows are written and before this cap reads them, and each row it rules defer is queued with policy: --defer-after K, as references/policy.md says. A row it rules repair goes to Step 7 only in a round below the cap or while RUN_DIR/review_loop exists; in a capped round this cap rules it as any in-scope row.

Out-of-scope rows append to RUN_DIR/queue.md:

| # | Source | Finding | Outside because | Recommendation | Status |

Source is the thread or comment URL, or worker for a plan_concerns entry with open: true or no open field. Recommendation is usually a file-issue line for the human to run; the skill leaves the filing to them.

Done when: review returned cleared; or it returned findings, the round's heading records the SINCE it was triaged against, and every finding has a row marked in scope or queued with its reason, and in a capped round every in-scope row but a P0 or blocking one is queued with review round cap reached (N), and an in-scope P0 or blocking row stopped the run, and from round --defer-after on every row policy.py sort ruled defer is queued with policy: --defer-after K, and a row it ruled repair in a capped round met the cap as any in-scope row does; or pending reached its cap, 60 checks in the background or ten minutes in the foreground, and triage/waiting says so; or a check exited non-zero and the invocation stopped naming its exit code and quoting its stderr.

Step 7 — Repair

A capped round (Step 6) skips this step: it gets no dispatch, no repair-base-<k>, and no repair-<k>.json, and Step 8 answers its queued rows.

Before the dispatch, write git rev-parse HEAD to RUN_DIR/redteam/repair-base-<k>, k the triage round this repair answers, unless that file already exists. Write it once and never overwrite it: a resumed Step 7 keeps the first base, so the diff from it to HEAD still covers every commit the repair made. Step 8 saves the repair's own diff from this SHA to RUN_DIR/redteam/repair-diff-<k>.patch before item 2's push, and item 1 and the probe read that patch, so item 2's rebase orphaning the SHA changes neither answer.

One dispatch carrying every in-scope row not yet queued, each finding quoted with its URL. A row whose Scope cell reads in scope; queued: was deferred and stays out of the dispatch, so a user who defers some of a round's rows at row 16's budget stop gets the rest repaired and those left alone. Under herdr that is herdr agent prompt issue-N … on the same agent, the full prompt inline as in Step 2; otherwise a fresh subagent with the build report followed by the repair override line as {{PRIOR}}, its prompt inline too: the repair spans tasks, which render-prompt.py's one row cannot express, and an adopted run has no plan to render from. On an adopted run {{PRIOR}} reads none: an adopted pull request has no build report, then the repair override line Step 3 gives. Same preamble, same report contract. The dispatch fills {{VERIFY_CMD}} with the repair's verify command Step 3 defines, its scope file RUN_DIR/prompts/repair-<k>.scope.json listing each path the in-scope findings name.

Gate it the way Step 3 gates: the format pass from divvy-up's Step 6 over the repair's reported files_changed, then Step 4 item 4's scoped gate with --report RUN_DIR/reports/repair-<k>.json, then code-review against BASE_SHA, with findings routed the same way. The scoped gate runs the done-when commands of the plan tasks that own the repair's files_changed and reads them by VERIFY_CMD green. It falls back to VERIFY_CMD green when the latest baseline's exit: line reads anything but exit: 0, when a changed path is owned by no task, when a matched task's done-when names no command, when the run is adopted and has no plan, and on every other scoped-cmd exit 1. A scoped run saves no baseline-repair-<n>.txt. The gate runs the VERIFY_CMD Step 1 resolved and never a wider one. Save a green full VERIFY_CMD run as the next baseline-repair-<n>.txt, as Step 3's repair gate does, then commit. Its message follows Step 2's commit rule, read again before this commit, and carries the Gate: <command> line Step 4 item 4 describes. The report lands at RUN_DIR/reports/repair-<k>.json.

Done when: repair-base-<k> holds the HEAD SHA from before the first dispatch for round k; every in-scope row not yet queued is fixed and committed, or sits in left with a reason the orchestrator accepted and recorded on the row; where VERIFY_CMD is not absent, each repair commit carries its Gate: <command> line, and each one gated on the full VERIFY_CMD has the baseline-repair-<n>.txt that gate saved; code-review ran on the repaired diff; repair-<k>.json exists.

Step 8 — Close

Run Step 8 in this order: the capture, then item 2's push, then item 1's checks, then items 3 through 5. The reviewer starts on the pushed repair while item 1 red-teams it, so neither waits on the other. The capture runs where RUN_DIR/redteam/repair-base-<k> exists for the newest round k and local HEAD is ahead of origin, item 2's own guard, so a resume after the push never captures a rebased range. A no-change round, one whose repair committed nothing past repair-base-<k>, is never ahead of origin, so it captures nothing: its diff is empty, and item 1 reads the missing patch as the repair-diff condition unmet. Write git rev-parse HEAD to RUN_DIR/redteam/repair-head-<k>, unless that file already exists. Then run git diff "$(cat RUN_DIR/redteam/repair-base-<k>)"..HEAD as its own command, check its exit, and write its output to RUN_DIR/redteam/repair-diff-<k>.patch through a temp file and mv, unless the patch already exists. Write each file once and never overwrite it, as Step 7 writes repair-base-<k>: a resume after item 2's rebase would otherwise capture every upstream line the rebase brought in as the repair's own. A non-zero exit from git diff decides nothing: stop and quote its stderr. A pipe would hide that exit, and a base SHA that no longer resolves would read as no row. Where item 1 sends a red-team repair, its rounds and its Step 4 item 4 re-fire finish before anything pushes again, and then item 2 runs once more under its ahead-of-origin guard. The round closes only when both item 1 and the reviewer have answered: item 1's last round is clean, and Step 6's next poll has a review of the pushed HEAD.

  1. Where the newest triage round has a repair report, red-team it: the reproducer over repair-<k>.json's claims, as Step 4 items 1 through 6 run it, on the executor WORK_ISSUE_REPRODUCER resolves to, with the same fallback, and with REPAIR_BASE set, for the first round over repair-<k>.json, to the SHA RUN_DIR/redteam/repair-base-<k> holds where it is still an ancestor of HEAD (git merge-base --is-ancestor exits 0), else to HEAD~<n>, n from git rev-list --count "$(cat RUN_DIR/redteam/repair-base-<k>)".."$(cat RUN_DIR/redteam/repair-head-<k>)", since item 2's rebase replays the repair's commits last and in order (none where repair-base-<k> is missing, as on a run from before Step 7 wrote it, or where it is orphaned and repair-head-<k> is missing), or to the SHA the highest-numbered redteam-repair-base-<k> holds for a later round after a red-team repair of that repair. Once the reproducer comes back clean, the trigger re-fires on either of two conditions. Repair diff: run adversarial-review/scripts/match-triggers.py rows --only 1,2,4 < RUN_DIR/redteam/repair-diff-<k>.patch, the patch the capture saved. A printed row makes the repair diff a candidate. Run adversarial-review/scripts/match-triggers.py lines --only 1,2,4 < RUN_DIR/redteam/repair-diff-<k>.patch and read each printed line as Step 4 item 7 reads it, in its hunk of that patch. The condition holds when the matcher prints a row and the reading finds an implements line, because a reviewer can label a real money, authz, or schema blocker P2. A missing repair-diff-<k>.patch leaves this condition unmet, so the repair rests on severity alone. The capture runs before the push and writes once, so only a repair with no repair-base-<k>, or a run that pushed before Step 8 saved the patch, lacks it. Severity: that triage round held a row whose Severity is P0, P1, or blocking, and the full diff fires the trigger as Step 4 item 7 evaluates it. Whenever the repair diff prints a row or the round held such a row, write the result to RUN_DIR/redteam/trigger-repair-<k>.txt rather than trigger.txt: first line exactly fired: yes or fired: no, second line condition: repair-diff, condition: severity, condition: both, or condition: none, naming which fired, then each command that ran and its output lines, verbatim, with the reading's verdict lines in trigger.txt's format wherever the reading ran. The condition: line names the conditions that held after the reading, so a repair whose candidate lines all read mentions, in a round with no such row, writes fired: no and condition: none. A non-zero exit from either matcher run decides nothing: stop and quote its stderr, as Step 4 item 7 does. Where it fired, run adversarial-review as item 7 does and copy its state line into RUN_DIR/redteam/ar-state-repair-<k>.txt. Then add every finding its report lists as LISTED to the open pull request's "Left out" section, each with its repro command, by editing the existing body, which needs no push. Each also gets a queue.md row with Source adversarial-review, Finding the advisory quoted with its repro command, Outside because listed advisory, a file-issue Recommendation, and Status queued, unless an earlier pass already queued it, matched by its repro command. Step 5 wrote that section before this review ran, so nothing else carries these findings to the reader. A repair whose round held no such row and whose own diff prints no row gets the reproducer and nothing more, and writes neither file. A resume that finds trigger-repair-<k>.txt already written starts at the invocation; without it, the reproducer runs again. Each fix is new code that draws an advisory a notch smaller than the last, so re-firing after every repair almost never ends: on cambium #23 and #26 it ran 7 repair cycles per lane for 1 blocker. An entry that reached this step with no repair, an all-queued round, a capped round, or a worker row owed its comment, skips this item; item 2 has its own guard.
  2. Where local HEAD is ahead of origin: rebase, rewrite RUN_DIR/base_sha, verify to VERIFY_CMD green, write pushed_at, push — Step 5 items 1 through 4, the base_sha rewrite in item 2 included. Never a no-op push: it moves SINCE past the review just triaged and makes it read as stale. On an adopted run there is no rebase and no base_sha rewrite: VERIFY_CMD green, write pushed_at, then git push origin <BRANCH>:refs/heads/<BRANCH>, a fast-forward. A rejected push stops with "<BRANCH> moved on origin; merge origin/<BRANCH> into it locally, then work-issue <M>". Where RUN_DIR/review_loop exists, post the review request after the push and before the next poll start: post the request, run item 1, run items 3 and 4, close Step 8 with stamp 8 end, open Step 6 with stamp 6 start, and poll in place of item 5, whose final report the loop reaches on cleared.
  3. Reply to every finding thread with what changed. A reply that names a change of its own cites that change's commit SHA. A reply that names none, a refused finding, a row left in left, or a round where every finding was refused, cites no SHA and never reaches for HEAD. A reply that names no change leads with its verdict as technical-writing's review-correspondence profile gives it, then what was checked and what it showed. Post each reply with gh api repos/{owner}/{repo}/pulls/<pr>/comments/<id>/replies -f body=…, where <id> is the reply-to id on the thread's deciding line, and a pull-request comment for review-level and issue-level findings. The push in item 2 moves SINCE past the rows being answered, and that is why triage_rows_unanswered counts every round: a stop between the push and these replies resumes here, at row 17, rather than at row 14's poll. A queued row that names no change gets "deferred: <Outside because>; tracked in the deferred-findings comment" in place of an opening verdict, and a sentence saying whether the finding holds where the run checked it. A queued row somebody fixed anyway names that change and cites its SHA, as an in-scope fix does. Replies go through technical-writing. Answer, never resolve: marking a thread resolved is the reviewer's act, and taking it from them destroys the only signal they have that anyone read the finding.
  4. One pull-request comment headed Deferred findings carries the queue table copied byte-for-byte, never reformatted as a link or wrapped in backticks (see references/triage.md), edited in place on later rounds rather than posted again. Find the comment in the saved bundle by its ## Deferred findings heading, posted by the pull request's author or the invoking login, and edit that one; post a new one only where neither has posted it. The resume probe compares every queue row, whole, against that comment as literal text, so a round that added rows, or changed a row's Status without touching its Source, and stopped before this edit resumes here rather than at the poll.
  5. The final report: pull-request URL, review state, rounds run, per-model task counts, escalations, the rows the review round cap queued with review round cap reached (N), the queue, the budget line, the lines of RUN_DIR/redteam/executor.log where it exists, the lines of RUN_DIR/policy.log where it exists, and the closing line the review state earns — "a human merges" where review_state is cleared; "waiting on the reviewer" where every finding is answered and the queue published but the round has not cleared (row 18's second reading). Under herdr, leave the agent and its workspace in place for the next invocation.

Done when: every triage row has a reply URL; every repair's claims carry reproducer verdicts; repair-head-<k> and repair-diff-<k>.patch exist wherever repair-base-<k> does, except on a no-change round or a run that pushed the repair before Step 8 captured it; a repair whose triage round held a P0, P1, or blocking row, or whose saved repair-diff-<k>.patch prints a trigger row, has trigger-repair-<k>.txt written and, where it fired, ar-state-repair-<k>.txt showing UNVERIFIED: 0, and every LISTED finding from a re-fired review is in the pull request's "Left out" section; origin/<BRANCH> equals HEAD; the deferred-findings comment exists wherever the queue is non-empty; and the final report was printed, or, where the review loop is on and item 2 pushed, the review request posted and the run back at Step 6's poll.

Where a Run Stops

An invocation ends at one of these stops and no other. Each prints its message as the invocation's last output, writes its marker, or both, so a stopped run never reads the same as a working one. Before its message, each stop also runs work-issue/scripts/run-state.py stamp --timing RUN_DIR/timing.log <n> end for its step, as the Timing paragraph says, so the wait for the user's answer never reaches the budget. An invocation that ends any other way, silent after a settled wave, a dispatch, a check, or a report saved to disk, has stopped outside this list, and that is a defect in the run, not a gate.

StopStepWhat the run prints or writes
No issue number, a --max-review-rounds value that is not a positive integer, or an empty --review-loop= comment0a refusal naming what is missing, the value given, or the flag
gh is unauthenticated0a stop saying the issue cannot be read until gh auth login
A sibling skill is not installedanythe stop naming the sibling to install
The resume gather fails: gh pr list or run-state.py review --save exits non-zero, or probe or phase exits 3; or a Step 6 poll check or the review request exits non-zero0, 5, 6, 8, Resumethat command's stderr, quoted
The plan gate refuses0the refusal: check-plan.py's stderr quoted, ending "Plan it first: writing-plans, then work-issue N <plan path>.", or the derivation's questions listed
A wrapped invocation with no plan, or a direct one with neither planner present0the plan gate's refusal, ending "Plan it first: writing-plans, then work-issue N <plan path>."
A direct invocation with no plan and no plan directory0the refusal naming the directory or the empty variable, ending "set WORK_ISSUE_PLAN_DIRS to a plan directory outside this repository, then work-issue N."
A direct invocation whose <plan dir>/<N>-<slug>.md already exists, before planning or at the copy after Stop 10the refusal naming that file, ending "move it or pass a plan path, then work-issue N."
Stop 1, the drafted plan put to the user and declined0RUN_DIR/draft-plan.md deleted, and "Plan declined and deleted; work-issue N drafts a new one."
--dry-run on a direct invocation where every PLAN route missed0"--dry-run drafts no plan; work-issue N without it plans the issue."
divvy-up stops while deriving the shape0the stop divvy-up prints, quoted as-is
Another run in flight owns a path0check-inflight.py's stderr, quoted
Adoption refuses: the pull request is not open, its head is on a fork or is DEFAULT, it targets a branch other than DEFAULT, a review names a commit this clone lacks, a flag an adopted run does not take, or a local head branch or worktree that differs from origin's or is dirtyAdoptrun-state.py adopt's stderr, quoted, or the refusal naming the flag, both SHAs, or "commit or stash first"
The forecast or trigger match, Step 4's red-team repair diff, or Step 8's repair diff, exits non-zero0, 4, 8the failing command's stderr, quoted
git worktree add, remove, or prune on RUN_DIR/redteam/repro-tree, or INSTALL_CMD run there, exits non-zero4, Resumethat command's stderr, quoted
The confirmation, answered no or rendered by --dry-run0, Adoptthe one confirmation message
--no-isolate on a dirty tree1"commit or stash first"
herdr made the worktree in another repo: the response's repo_root is not ROOT1"herdr made <WORKTREE> in <repo_root>, not <ROOT>; remove that worktree, then work-issue N."
A wave settles under --until-boundary with a later wave in ## Waves pending2"wave <k> settled; work-issue N dispatches wave <k+1>."
A task stops for an answer2, 3the held question, put to the user once the rest of the wave lands
A task fails twice, or fails on fable3divvy-up's stop report naming the task and its failure
Verification fails on a red baseline, and the wave's output or the baseline names no individual failures2, 3, 4, 5, 7, 8"Verification failed without naming individual failures, so this wave's failures can't be told from the baseline's.", followed by BASELINE and the failing output, both quoted
The format pass's command errors naming no path in the derived set or the repair's files_changed, or none it can be tied to, or a repair already re-dispatched for a format-pass error fails it again3, 4, 5, 7the pass's output, quoted, after its writes outside the derived set are reverted, and at a repair gate the repair's own writes too
Two red-team rounds fail in a row4the failed claims with the reproducer's commands and output, ending with how to answer it: append redteam-continue <k>, k the newest round, to RUN_DIR/redteam/continue.log, which buys round k+1
adversarial-review derives a depth past the forecast4, 8that review's own question
The budget stop4, 7, 8the budget line, "build: <m>m review: <m>m ratio: <r> over: yes", and the question: stop here or raise the ratio, and at row 16 also defer the newest triage round's in-scope rows not yet queued, written as Step 6's review round cap paragraph says
The push half of the grant is withheld, or --no-publish is setafter 4, Resumethe report the withholding caller asked for, carrying Step 4's result; with the flag and no caller, Step 4's result and "work-issue N without --no-publish publishes."
A rebase conflict5, 8RUN_DIR/conflict.txt and "resolve, then work-issue N"
An adopted pull request's head branch moved on origin8"<BRANCH> moved on origin; merge origin/<BRANCH> into it locally, then work-issue <M>"
gh is unauthenticated at publish5, 8RUN_DIR/pr-body.md and "resume after gh auth login"
No review within the poll's cap: 60 checks in the background, ten minutes in the foreground6RUN_DIR/triage/waiting and "no review yet on <PR URL>; work-issue N resumes here."
The review round cap meets an in-scope P0 or blocking row6, 7a stop naming the cap and that row, and on resume the row 16: stop reason until the row is deferred as Step 6's review round cap paragraph says
A herdr task's reports/<task>.json is still missing when the dispatch's --timeout runs out, at Step 2 or at resume row 212, Resume"<task>'s report never landed while herdr lists issue-N; close the agent's pane if the worker is gone, then work-issue N."
An unreported task owns paths a commit past base_sha touched, and no review/self-*.md existsResumethe row 7: stop reason naming the disagreement, with nothing reverted
RUN_DIR/base_sha has drifted from the live merge-baseResumethe base_sha mismatch stop reason naming not-merge-base or not-ancestor
The resume probe answers stop on any other reason: row 3's blocked agent, row 7's ## Waves table with no task rows, a null field, or no row matchingResumethe phase: stop reason: … line, and the blocked herdr UI where row 3 matched
The pull request is merged or closedResumethe cleanup offer, asked before anything is removed
A merged or closed pull request's queue still holds queued rowsResume"<k> deferred findings on <PR URL> still read queued; answer which to file and which to dismiss, with a reason for each dismissal"
The final report8the final report, ending "a human merges" or "waiting on the reviewer"

Keep every quoted message byte-identical to the step that prints it; the suite's drift check depends on it, and so does work-issue/scripts/drive.py, which reads this table at run time to tell how a launch ended. A stop with no double-quoted text in its row is one the driver can't recognize: it relaunches, and halts once two launches in a row change nothing.

Resume

The world outranks RUN_DIR, and RUN_DIR outranks memory. git, gh, and herdr are asked first, because a run's own notes are exactly what the crash that stranded it leaves stale.

Run the gather block in references/resume.md. It asks gh for the pull request and saves its bundle outside RUN_DIR, reads herdr's state for the issue agent under HERDR, and ends with:

work-issue/scripts/run-state.py probe --run-dir RUN_DIR --root ROOT (--issue N | --pr M) [--pr-bundle "$bundle"] [--herdr-state STATE] > "$probe"
work-issue/scripts/run-state.py phase --probe "$probe"

probe prints every field, null where it could not answer with a stderr line saying why, and exits 3 on input it cannot read, which stops the run. A null in any field but pr_state and review_state answers stop naming the field: fix what the stderr line names and run the block again, rather than guessing the value. A base_sha_state of not-merge-base or not-ancestor answers stop naming the mismatch, unless a conflict or a rebase is in progress, which row 12 owns. phase prints phase: <0-8|done|wait|stop> reason: <one line> and exits 0, or exits 3 on a malformed probe. First match wins:

#ProbeResume at
1PR state MERGED or CLOSEDstop where queue_unfiled_rows is above 0, for the filing pass below; else done; offer cleanup (worktree remove, RUN_DIR → closed/), ask before removing
2HERDR and agent workingwait, re-probe
3HERDR and agent blockedshow the blocked UI, stop
21HERDR and agent idle or done; branch exists; ## Waves present; base_sha and baseline.txt present; some task not counted as reported, by row 7's count, while no review/self-*.md exists; no unreported task owns a path a commit in git log <base_sha>..HEAD touchedrevert nothing. Take the lowest wave holding an unreported task, and for each of its unreported tasks: a report on disk under either name, Step 3 at that wave's gate, on the tree as it stands; no report and uncommitted changes in its owned paths, wait up to the dispatch's --timeout for reports/<task>.json, then re-probe, and at the timeout stop with Step 2's missing-report message; neither, Step 2 at that wave, since the agent never got the task
19adopted.json in RUN_DIR: an adopted pull requeststop where a rebase is in progress or conflict.txt exists, since an adopted run never rebases; Step 6's first adopted pass where no triage round exists yet; else on to row 14, skipping rows 4 through 13, which read a build and a publish this run never makes
4no issue-N branch locally or on origin, no RUN_DIRStep 0
5RUN_DIR exists, no branch anywhereplan.md without ## Waves: RUN_DIR → closed/, Step 0. With it: Step 0 redoes items 4, 6, and 7 (isolation, cross-run check, red-team mode) before the confirmation, then Step 1
6branch exists; plan.md has no ## WavesStep 0 at the plan gate
7## Waves present; no base_sha or no baseline.txt, or some task is not counted as reported while no review/self-*.md exists (no <wave>-<task>.json or <task>.json, a report beside uncommitted changes in its owned paths, or no gated/<wave>-<task> marker and, on a run with no gated/ directory, no commit on its owned paths), or the table has no numbered task row while no review/self-*.md existsStep 1 at the missing artifact; a table with no task rows: stop, naming the empty table; an unreported task whose owned paths a commit in git log <base_sha>..HEAD touched: stop, naming the disagreement, and revert nothing; else Step 2 at that wave (delete each unreported task's reports under both names and its gated/<wave>-<task> marker, then revert only the uncommitted changes the half-written wave left in its owned paths, back to HEAD, then re-record WAVE_BASE)
8every wave task counted as reported; no review/self-*.mdStep 3 at the code-review invocation
9review/self-* present; no reports/build-final.jsonStep 3 at the fix dispatch
10build-final.json; no redteam/round-*.json, or newest round failed (redteam_last_failed), except a failed round under an open PR whose newest triage round has its reports/repair-<k>.json, with neither conflict.txt nor a rebase in progress: that round is Step 8 item 1's, and row 17 takes itStep 4, first clear a leftover RUN_DIR/redteam/repro-tree: git worktree remove --force it by that path where git worktree list --porcelain lists it, delete the directory where it exists unlisted, then run git worktree prune, so a crashed overlap never leaks it. With no round: round 1, with item 7 overlapped from where row 11 would place it, and skipped where trigger.txt reads fired: no or redteam/ar-state.txt shows UNVERIFIED: 0, since a review that landed before round-<k>.json already finished. A failed round 1 whose item 7 has not finished finishes it first, as row 11 places it, then routes: the repair dispatch, or round k+1 where a repair report followed the failed round; two failed rounds in a row stop with the evidence, unless redteam/continue.log names the newest round (redteam_stop_answered), which buys round k+1 only; review over budget: the budget stop
11red-team clean; trigger.txt absent, or its first line fired: yes with no redteam/ar-state.txt showing UNVERIFIED: 0. Build diff only: a red-team repair's re-fire reads its own files at row 20, and a triage repair's at row 17Step 4, first clear a leftover RUN_DIR/redteam/repro-tree: git worktree remove --force it by that path where git worktree list --porcelain lists it, delete the directory where it exists unlisted, then run git worktree prune, so a crashed overlap never leaks it as row 10 does, then at the trigger, or at the adversarial-review invocation. An ar-state.txt or ar-report.md that landed before round-<k>.json sent the run through row 10, which re-ran the round, and a finished review never matches here; review over budget: the budget stop
20red-team clean; trigger recorded; no triage round; the newest redteam/redteam-repair-base-<k>'s diff to HEAD hits trigger row 1, 2, or 4 (redteam_repair_diff_triggers), with neither redteam/trigger-redteam-repair-<k>.txt reading fired: no nor redteam/ar-state-redteam-repair-<k>.txt showing UNVERIFIED: 0Step 4 item 4's repair re-fire: at the matcher where trigger-redteam-repair-<k>.txt is absent, else at the adversarial-review invocation; review over budget: the budget stop
12conflict.txt exists, or a rebase in progressStep 5 item 1
13red-team clean; trigger recorded; no triage round yet; no PR, or local HEAD ahead of origin/issue-NStep 5
14PR open; review pending; no triage row without a reply URL; no queue row missing from its comment; no repair awaiting item 1's reproducer, its red-team re-fire, or its own unsettled re-fire, and no repair report with local HEAD ahead of origin (row 17: its item-1 leg, else its push leg for an unpushed repair)Step 6 poll
15PR open; findings; no triage round recorded against the current SINCE; no repair awaiting item 1's reproducer, its red-team re-fire, or its own unsettled re-fire, and no repair report with local HEAD ahead of origin (row 17: its item-1 leg, else its push leg for an unpushed repair)Step 6 triage
16newest triage round has in-scope rows not yet queued; no reports/repair-<k>.json for that roundStep 7; review over budget: the budget stop; round at the review round cap (triage_rounds ≥ max_review_rounds, no review_loop): the cap stop where it holds an in-scope P0 or blocking row, else no repair, on to row 17
17PR open; the item-1 leg: a reports/repair-<k>.json for the newest round k awaits item 1, because the newest redteam/round-*.json failed and its routing has not finished (redteam_last_failed), or, with local HEAD not ahead of origin, no round is newer than the report (repair_after_last_round), or the newest round is clean over item 1's own red-team repair whose diff from redteam-repair-base-<k> hits trigger row 1, 2, or 4 with its re-fire not settled (redteam_repair_diff_triggers), ahead of origin or not, since item 2's rebase can orphan that base and erase the signal. A failed newest round means item 2 already pushed the triage repair, since Step 4 never finishes on a failed round and item 1 runs only after the push, so this leg takes it ahead of row 10 where neither conflict.txt nor a rebase is in progress, and whether or not a red-team repair commit has put local HEAD ahead of origin again (resume at item 1's reproducer where no round is newer than the report; at item 1's red-team repair dispatch where the newest round failed and no repair followed it; at round k+1 where a red-team repair followed it, which item 2 pushes only after a clean round; at Step 4 item 4's repair re-fire where a clean round left it owed, from the matcher where trigger-redteam-repair-<k>.txt is absent, else at the adversarial-review invocation, and item 2 pushes the red-team repair once it settles; origin already has the triage repair, so nothing pushes first); an unpushed triage repair, local HEAD ahead of origin with no failed round behind it, takes the last leg below instead, over budget or not, where the capture and item 2's push run first; or the re-fire leg: a pushed repair report, local HEAD not ahead of origin, whose triage round held a P0, P1, or blocking row, or whose saved redteam/repair-diff-<k>.patch hits trigger row 1, 2, or 4 (repair_diff_triggers), with the repair's adversarial-review not settled (resume at item 1: the reproducer until trigger-repair-<k>.txt exists, then the adversarial-review invocation); or a queue row missing from the Deferred findings comment, or a repair report or an all-queued triage round with local ahead of origin or a triage row without a reply URLStep 8; two failed red-team rounds in a row on the item-1 leg: stop with the evidence; review over budget on the item-1 leg or the re-fire leg: the budget stop
18PR open; cleared, or findings with the round triaged, answered, and its queue publisheddone: final report, then wait on the reviewer

The filing pass. Row 1's stop lists every queued row of queue.md in one message. Each entry carries the row's Finding and Source and a drafted issue title and body, built from the row's Recommendation. The message ends with "<k> deferred findings on <PR URL> still read queued; answer which to file and which to dismiss, with a reason for each dismissal". That answer is file-issue's confirmation. Each row the human says to file goes through file-issue --yolo with the drafted title and body, and its Status becomes filed #M. Each dismissed row's Status becomes dismissed: <reason>, in the human's words. A row the answer doesn't name stays queued, and the next resume stops on it again. Then run Step 8 item 4's edit again, so the Deferred findings comment on the merged or closed pull request names the issues. Then re-probe: with the count at 0, row 1 answers done and the cleanup offer follows.

With --no-publish set, a phase: of 5, 6, 7, or 8 meets the withheld-grant stop in place of that step: only a branch or pull request already past Step 4 answers one of those, and stopping is the answer that pushes nothing.

An invocation carrying a policy flag whose probe answers stop rules that stop before asking. A reason reading review time is over budget runs policy.py budget with --at from the row the reason names, and a reason reading two red-team rounds in a row failed runs policy.py sort --kind redteam on the newest round. Act on a budget ruling as references/policy.md says. A red-team ruling resumes only where it prints repair and no reports/redteam-repair-<k>.json exists for that round, at Step 4 item 4's repair dispatch. Any other ruling, and every ask, is the stop as the probe gave it.

An invocation carrying --review-loop whose phase: answers row 14, or row 18 on a findings review, posts the review request inside Step 6, after its 6 start, and then runs Step 6's poll. At row 18 it first writes date -u +%FT%TZ to RUN_DIR/pushed_at: that round is triaged and answered already, and its findings sit past the old SINCE, so the poll would score them again at once. At row 14 SINCE stays put, since pending means nothing has landed past it. Row 18 on cleared posts nothing and ends at the final report. An invocation without the flag posts nothing at either row, so re-invoking a waiting run never stacks requests.

Further Reading

  • references/resume.md — read at Step 0 for the gather block, what each probe field means, and the phase table
  • references/worker-prompt.md — read at Steps 2 and 7 to build the preamble and the report contract every dispatch carries
  • references/redteam.md — read at Step 4 to instantiate the reproducer and run the adversarial-review trigger
  • references/triage.md — read at Steps 6 and 8 to score review signal, queue what is out of scope, and answer every thread
  • scripts/check-plan.py — run at Step 0 as the mechanical half of the plan gate: work-issue/scripts/check-plan.py PLAN.md --issue N [--criteria ISSUE.md]
  • scripts/find-plan.py — run at Step 0 as PLAN's route 4: work-issue/scripts/find-plan.py --issue N --repo REPO, reading WORK_ISSUE_PLAN_DIRS. Exit 0 prints one path or nothing, exit 1 lists survivors as ambiguous: <path> on stderr, exit 3 is a usage error, a missing set directory, or an unreadable candidate
  • scripts/check-inflight.py — run at Step 0 to prove no in-flight run owns a path this plan owns: work-issue/scripts/check-inflight.py PLAN.md --runs DIR [--self issue-N]
  • scripts/review-rules.py — run at Step 1 to check that the target repo's AGENTS.md carries the current review-rules block: work-issue/scripts/review-rules.py check <tree>. Exit 0 is current, exit 1 means the block is stale, missing, or has malformed markers (stale or missing also print the install <repo> command that refreshes it), exit 3 is a usage error or an unreadable file; install <repo> is the maintainer's command and no step runs it
  • references/codex-review-rules.md — the block review-rules.py installs between its markers in a repo's AGENTS.md; read it to change a rule, and edit nothing else to change what Codex is told
  • references/policy.md — read where the invocation carries --auto-budget, --repair-class, or --defer-after, for the ruling at each budget, red-team, and late triage stop
  • scripts/policy.py — run at Step 0 to check the policy flags and at each stop policy.md names to rule it: work-issue/scripts/policy.py flags [--auto-budget R] [--repair-class C] [--defer-after K], work-issue/scripts/policy.py budget --timing RUN_DIR/timing.log --at 4|7|8 --run-dir RUN_DIR [--now T] [--auto-budget R], and work-issue/scripts/policy.py sort --kind triage|redteam --round-file FILE --round K --plan RUN_DIR/plan.md --run-dir RUN_DIR [--root WORKTREE] [--repair-class C] [--defer-after K]. Exit 0 prints the ruling, exit 3 is a usage error, a bad flag value, or unreadable input
  • scripts/run-state.py — run at Step 0 to gather the probe and place the run, at Adopt to check and write an adopted run's RUN_DIR, at Step 1 to resolve VERIFY_CMD from the plan and to reuse a matching --wave-baseline file, at Steps 4 and 7 to scope a repair gate to the plan's done-when commands, at Steps 6 and 8 to score the review, ahead of each review cycle to read the budget, and at each step boundary and each stop to stamp timing.log: work-issue/scripts/run-state.py probe --run-dir DIR --root ROOT (--issue N | --pr M) [--pr-bundle FILE] [--herdr-state STATE] [--author LOGIN], work-issue/scripts/run-state.py phase --probe PROBE.json, work-issue/scripts/run-state.py review <PR> [--since ISO8601] [--author LOGIN] [--invoker LOGIN] [--unanswered] [--input BUNDLE.json] [--save PATH], work-issue/scripts/run-state.py adopt <M> --pr-json FILE --bundle FILE --run-dir DIR --root ROOT --default DEFAULT --invoker LOGIN [--max-review-rounds R] [--dry-run], work-issue/scripts/run-state.py reuse-baseline --wave-baseline PATH --base-sha SHA --install CMD --verify CMD --out PATH, work-issue/scripts/run-state.py verify-cmd --plan PATH, work-issue/scripts/run-state.py scoped-cmd --plan PATH --report PATH, work-issue/scripts/run-state.py budget --timing RUN_DIR/timing.log [--ratio R], and work-issue/scripts/run-state.py stamp --timing RUN_DIR/timing.log <label> start|end [--now ISO8601]

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.