Run a set of issues, or a whole spec, through other sessions as their Chief of Staff — analyse them, propose one Dispatch Plan, hand each Delegation to an Executor, relay every Decision Request, verify each report, QA each finished head where the repository requires it, and close out with the Ready to Merge list and a merge order. Invoked by the user.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Orchestrate?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/mnaimfaizy-orchestrate)
---
name: orchestrate
description: Run a set of issues, or a whole spec, through other sessions as their Chief of Staff — analyse them, propose one Dispatch Plan, hand each Delegation to an Executor, relay every Decision Request, verify each report, QA each finished head where the repository requires it, and close out with the Ready to Merge list and a merge order. Invoked by the user.
disable-model-invocation: true
argument-hint: "#<n> [#<n>…] [go] [autonomous] | --spec <n> [go] [autonomous] | --spec <n> --team [go] [autonomous] | --status [<run>] | --status --spec <n> | --upload <run> | --dashboard [--repo <host/owner/repo>] [--local-logs] | --resume <run> | --factory <snapshot dir>"
metadata:
agent-kit-scope: user
---
# Orchestrate
A user-invoked skill. Running it makes this session the **Chief of Staff** for a set of issues, or for a spec and the work under it. The Chief of Staff analyses each issue, shows one **Dispatch Plan**, and after the human's "go" hands each piece of work, a **Delegation**, to an **Executor**: a separate Live Session, a headless run, or a sub-agent in this session. It relays every **Decision Request** to the human, keeps the board, checks every report against git, the tracker and CI, has each finished head QA'd where the repository requires it, and ends with the **Ready to Merge** list and a merge order.
The Chief of Staff plans, delegates, relays and verifies. It never does a Delegation's work itself, and it never merges (the Factory's merge gate does, never a Chief of Staff).
Load [CONFIG.md](CONFIG.md) when reading or asking for the config. Load [BRIEF.md](BRIEF.md) before writing a brief or reading a report. Load [RUN.md](RUN.md) before opening, updating or resuming a run folder. Load [HARNESSES.md](HARNESSES.md) at step 1, to find this run's **Harness**; then load that harness's own file under [harnesses/](harnesses/), and only that one, before the first `spawn`, `message`, `await` or `report`. Load [SPEC.md](SPEC.md) for `--spec` (not for `--status --spec <n>`, which reads the tracker alone), or on `--resume` of a spec run ([RUN.md](RUN.md#resume)), and only then. Load [TEAM.md](TEAM.md) for `--spec <n> --team`, after SPEC.md, on `--resume` or `--status` of a run whose board says it is a Team Run, or for `--status --spec <n>`, and only then: it says how a Team Run's plan changes, adds the Shared Board's writes after "go", and says how the Shared Board is read. Load [FACTORY.md](FACTORY.md) and [harnesses/factory.md](harnesses/factory.md) for `--factory <snapshot dir>`, in place of every file above but this one, and follow FACTORY.md for the steps it keeps. Load [DESIGN.md](DESIGN.md) when a rule needs its reason, or before changing this skill.
`<skill>` in a command below is the absolute path of the folder this file is in, written with forward slashes (`C:/Users/me/...` on Windows), inside double quotes because it may contain spaces. Every command runs from the root of the repository the issues belong to.
## Which copy runs
A harness can load this skill from a user-level folder (under the home folder) while the repository keeps its own copy, pinned to the version the repository was set up with. The user-level copy can be older, and would then follow rules the repository no longer uses. So before anything else, check which copy this is:
```bash
node "<skill>/config.mjs" where orchestrate
```
It finds the repository from the folder it runs in, and lists the copies of `orchestrate` the repository keeps in the folders harnesses read skills from: `.claude/skills`, `.agents/skills`, `.github/skills` and `.cursor/skills`.
- `use` is `this`: go on. This copy is inside the repository, or the repository keeps none of its own.
- `use` is `repository`: stop, and run nothing more from this copy. Read the `SKILL.md` that `load` names and follow it from its start instead, with `<skill>` its folder. Tell the human that the copy at `this_copy` was not used, and that the repository's copy at `load` was.
- Exit 2, or no such script: compare by hand. When this file is outside the repository's root (`git rev-parse --show-toplevel`) and one of those folders in the repository holds `orchestrate/SKILL.md`, do as for `repository`.
## Invocations
- `/orchestrate #12 #34`: a run for these issues. The Dispatch Plan waits for "go".
- `/orchestrate #12 #34 go`: the same, and the run starts straight after the Dispatch Plan is shown, unless analysis raised a Decision Request.
- `/orchestrate #12 #34 go autonomous`, or `/orchestrate #12 #34 autonomous`: the same, with the Dispatch Plan's **Decision authority** line filled in as `autonomous` ([Autonomous runs](#autonomous-runs)). The word only fills the line in: the run is autonomous only once the plan is approved with that line, as step 4 says.
- `/orchestrate --spec 50 [go] [autonomous]`: a run for the spec `#50` and the work it holds, in dependency order. Load [SPEC.md](SPEC.md) before step 3: it says how the spec becomes Delegations and how the work lands. `autonomous` fills in the Decision authority line, as for issues.
- `/orchestrate --spec 50 --team [go] [autonomous]`: a **Team Run** of the spec `#50`. Each teammate runs their own Chief of Staff, and this one builds only the spec's tickets assigned to this teammate alone, listing the rest. Load [TEAM.md](TEAM.md) with SPEC.md before step 3 for `--team`: it says how the plan changes, and adds the Shared Board's writes after "go". `go` and `autonomous` are this teammate's own.
- `/orchestrate --status [<run>]`: print the board of the run named, or of the latest run, with the [default-branch check](#the-default-branch-check)'s result, and act on and write nothing ([RUN.md](RUN.md#status)). In a Team Run, it also prints the whole spec from the tracker ([RUN.md](RUN.md#in-a-team-run)).
- `/orchestrate --status --spec 50`: print the Shared Board of the Team Run on the spec `#50` from the tracker alone, with no run of your own, and write nothing ([RUN.md](RUN.md#--status---spec-n)). For a reviewer, the spec's owner, or a teammate with no tickets.
- `/orchestrate --upload <run>`: upload a closed run's Run Record to the sink the config's `records.sink` names, after showing the disclosure, and write nothing else ([RUN.md](RUN.md#uploading-the-run-record)). Repeating it is safe: the upload is create-only.
- `/orchestrate --dashboard [--repo <host/owner/repo>] [--local-logs]`: build the past-runs dashboard from the Run Records in `<run_dir>/records/` and from the config's `records.sink`, when it sets one, into `<run_dir>/dashboard.html`, and print its `file://` link ([RUN.md](RUN.md#the-past-runs-dashboard)). It only reads the sink, never writes it; it reads no tracker and never opens a browser; and it writes nothing but the page and the cache of the records it fetched. It covers every repository the sink holds, and opens on the current repository, or on the one `--repo` names. It shows each teammate side by side in a People table, with a Person page and, for a Team Run's spec, a Spec page ([RUN.md](RUN.md#teammates-on-the-dashboard)). With `--local-logs` it also writes `dashboard.local.html`, which holds the prose Activity Log of runs whose folder is still here.
- `/orchestrate --resume <run>`: continue a run from its board ([RUN.md](RUN.md#resume)).
- `/orchestrate --factory <snapshot dir>`: the Chief of Staff of one build Stage run of the Agentic Software Factory, started by the Orchestrate engine in a sandbox, reading a Snapshot and writing a checked Outbox, and never asking a person anything ([FACTORY.md](FACTORY.md)). It refuses to run without the engine's marker in the Snapshot folder.
`--spec` takes exactly one issue number and nothing else but `--team`, `go` and `autonomous`, except in `--status --spec <n>`. `--team` is taken only with `--spec <n>`, once, straight after its number: anywhere else, or twice, it is a mix this version does not take. `--status --spec <n>` takes exactly one issue number and nothing else: no run name, `--team`, `go` or `autonomous`, and `--status` comes first. `--upload <run>` takes exactly one run name and nothing else, and `--upload` comes first. `--dashboard` takes nothing but `--repo <host/owner/repo>` and `--local-logs`, each once, and `--dashboard` comes first. `autonomous` is taken once, last, and only in a run for issues or a spec, after `go` when both are given. With `--status` or `--resume`, on its own, before `go`, or twice, it is a mix this version does not take. `--factory` takes exactly one path, the Snapshot folder, and nothing else: with `--status`, `--resume`, `--upload`, `--dashboard`, `--spec`, `--team`, an issue number, `go` or `autonomous`, it is a mix this version does not take, and the run stops before anything is read. Any other argument this version does not know, or a mix of the forms above, `autonomous` included, stops the run before anything is read: say which invocations this version knows.
## Rules
- **The Chief of Staff never does a Delegation's work.** It plans, delegates, relays and verifies, on every tier and in every run: running a Delegation in its own session would mix the work it must verify with the session that verifies it. For QA, the Chief of Staff never starts the QA Stack, drives a scenario on any surface, runs `web.mjs`, `http.mjs`, `storyboard.mjs` or `mp4.mjs`, or writes or edits a QA Report or its QA Artifacts. It may read them, check the posted header, and run read-only `report.mjs` checks. There is no override, even if the human asks directly or insists.
- **Authority.** The Chief of Staff never merges, force-pushes, changes repository settings, or destroys a branch, worktree or checkpoint without the human's yes. A yes covers the one action it was given for. The detached worktrees the Chief of Staff makes for its own checks are its own scratch space: it removes each one when that check ends, and never one a Delegation works in.
- **Writes as the human.** A Delegation may push its own branch, open its own pull request and reply on its own review. Every other write made in the human's name (an issue comment, a new issue, a label, closing an issue) goes through the Chief of Staff: it drafts the write and raises it as a Decision Request, unless the human approved that kind of routine write in the Dispatch Plan.
- **Nothing is reported that was not checked.** A Delegation's report is a claim. The Chief of Staff tells the human only what it has checked against the branch, the pull request and CI, and says which parts it could not check.
- **Every question goes to the human whole.** A Decision Request is self-contained: the human can answer it without opening the Delegation, from the question, the options, the evidence and the recommendation alone ([BRIEF.md](BRIEF.md#decision-request)). In an autonomous run, the kinds of question the human handed over at "go" are answered by Rulings instead ([Autonomous runs](#autonomous-runs)). Each Ruling is self-contained in the same way, so the human can review it from the Ruling Ledger alone. Every other question still goes to the human whole.
- **No unsettled design gets built.** An issue that is not ready for an agent becomes an analysis Delegation: it produces evidence and options, then stops.
- **Two Delegations that touch the same files never share a wave**, and a named shared resource has one holder at a time. The **QA Stack** is one, held by every QA Delegation that runs against it, whether or not `limits.shared` names it.
- **QA holds for one head.** A QA result is about the commit it ran on. Any push to the branch after it, a review fix or a conflict merge alike, voids it, and the new head goes through QA again.
- **Every step is a Run Event.** The Chief of Staff and each Delegation write a timestamped Run Event for each step as it happens, with the records script ([RUN.md](RUN.md#run-events-and-the-run-record)), and the Chief of Staff derives the Run Record from them at close-out. A Run Record holds no free text. The Activity Log stays as the readable prose.
- **No repository fact is guessed.** Every command route, re-gate command, model, skill, label and limit comes from the config, or from the human's answer when the config does not say.
## Autonomous runs
A run whose Dispatch Plan was approved with **Decision authority: autonomous** (step 4) is an autonomous run. In it, the Chief of Staff answers some Decision Requests itself, as **Rulings**, and keeps them in the run's **Ruling Ledger** ([RUN.md](RUN.md#ruling-ledger)). The human reviews each one in the **Ruling Review** before anything is Ready to Merge. Why: [DESIGN.md](DESIGN.md#rulings-under-review). A run approved with plain `go` is not autonomous: every Decision Request goes to the human, and nothing in this section applies.
**The split is fixed, all or nothing.** The human hands over every kind in the first list, or none.
- **The Chief of Staff rules on:** a building Delegation's question about how to do the work within its issue's goal; a stalled or crashed Delegation (nudge it, or restart it from its branch as a new Delegation, `d<issue>-<k>` with the next suffix not yet used in the run ([RUN.md](RUN.md#layout)), on the same Executor and model), once per issue in the run; the merge order between conflicting branches (step 8); merging the default branch into a row's branch (step 10), when its re-gate on the merge result failed; a QA FAIL (send it back, or run QA again, step 9); the delivery of a QA Plan (step 9); while a QA Plan is composed, its subject issue, an `unknown` row, and a test `qa-plan` finds could prove a promise (send it back to the building Delegation to add the test, or keep the scenario), each under the evidence bar (step 9). With QA approved, also the surface when `manual-qa` raises a `run.surface` need, and each Review box that asks for literal words, on the source quoted at the pinned head (step 9).
- **The human keeps:** the QA readiness answers and the QA run needs, which the Dispatch Plan asks for and which are never a Ruling (step 4); with QA approved, the QA questions held for close-out, below (starting a scoped QA Delegation `d<issue>-qa<k>` for scenarios left for a person is the human's answer at close-out, never a Ruling); each hosted (`url`) QA host, typed in the Dispatch Plan, which no config key confirms (step 4); widening a scope fence; accepting a QA FAIL or waiving a manual scenario; merging a row as it is with the admin bypass (step 10); an analysis Delegation's options; any write as the human not approved as routine; everything under Authority. So do the questions the Chief of Staff raises before "go", such as a missing triage role or a closed issue at step 3.
**QA runs from the brief.** The handover includes the QA skills' own waits, but only when the human approved QA in the Dispatch Plan (step 4): the QA yes is its own answer, so the QA Rulings below, and the QA hold list, join this split only when QA is approved. Within approved QA, it is all or nothing with the rest of the split. A QA Delegation on a `target: stack` plan composes, delivers and runs QA from its brief: its session reads each QA skill's `SKILL.md` and follows it, and the skill's "Run from an autonomous brief" section says what replaces each place it would wait on the person. Nobody types `/qa-plan` or `/manual-qa` ([BRIEF.md](BRIEF.md#the-qa-brief)). The skills stay invoked by a person everywhere else ([DESIGN.md](DESIGN.md#qa-on-the-head-that-merges)). A QA Delegation on a `target: url` plan runs from the brief too, with each host typed in the Dispatch Plan and checked there (step 4), relayed to its session only through its brief ([BRIEF.md](BRIEF.md#the-qa-brief)); a host the human did not type, or that `host` refused, holds only its scenarios (step 9), and nothing falls back to the typed route mid-run.
**Nothing is asked mid-run once QA is approved.** A QA Delegation on a `target: stack` or `target: url` plan never sets itself `waiting` on the human after "go". Each question it would ask goes one of three ways. Asked once in the Dispatch Plan: the readiness answers, the run's needs, the `working_dir` check, the optional local address, each hosted host typed, and the seeder answer per environment (step 4). Ruled by the Chief of Staff under the evidence bar: plan delivery, the subject issue, `unknown` rows, the add-the-test send-back, `run.surface`, a Review box that asks for literal words, and sending back or re-running a FAIL (step 9). Held for close-out: a Review box that needs judgment; scenarios left for a person; a scenario that can only run after merge (a new QA Delegation, pass, waive, or run after merge); needs that only appear after compose; a `working_dir` not ignored at a head; a missing address; a hosted host that was refused, not typed or missing; a seeder answered "no" for an environment; accepting a FAIL; waiving a scenario; and anything the evidence does not settle. Held items go in the "QA held for you" list right after the Ruling Review (step 10), outside the Ruling Ledger because they are not Rulings. The run goes on, and a row is Ready to Merge once its held items are answered. Why: [DESIGN.md](DESIGN.md#qa-asks-nothing-mid-run).
**The evidence bar.** The Chief of Staff rules only when its evidence picks one option: the issue or spec text, the glossary, an ADR, code, CI output, or an earlier Ruling. Each piece is cited so that it can still be checked after the branch has moved: `path:line` at a commit SHA, command output saved to a file in the run folder's `evidence/` ([RUN.md](RUN.md#layout)), a tracker permalink, or an earlier Ruling by its id. "It seemed reasonable" does not meet the bar. When the evidence is split or missing, or when an option cannot be undone by a later commit, it does not rule: it treats the question as one the human keeps.
**A question it does not rule on** sets only its own Delegation to `waiting`, except a QA question once QA is approved: that is held for close-out, and its Delegation goes on. The run goes on: the other Delegations keep working, and the next one whose wait is over starts. The question is queued for the human, whole, on the board and in the Chief of Staff's session, and the Chief of Staff notifies the human where the harness can ([HARNESSES.md](HARNESSES.md#notifying-the-human)).
**Making a Ruling:**
1. Give it the next run-wide id, `R<n>`: `R1`, `R2`, and so on, never reused. A new Team Run after a lost machine starts one past the highest `R<n>` on the old run's pull requests instead ([RUN.md](RUN.md#after-a-lost-machine)).
2. Append it to the Ruling Ledger, `unreviewed`, with its question, options, choice and reason, evidence, and the earlier Rulings it cites. Mark the Decision Request in the Delegation's `decisions.md` as answered by the Chief of Staff, as `R<n>`.
3. `message` it to the Delegation that asked, in the Ruling form ([BRIEF.md](BRIEF.md#ruling)), or for a stall, a crash or a merge order, to the Delegation it acts on. Record it where `decisions.to` says, labelled "Chief of Staff ruling, not yet reviewed". With `pull-request`, the line goes in the building Delegation's own pull request body: for a building Delegation's Ruling, its Ruling form tells it to add the line; for a QA Delegation's, whose brief allows no such write, the QA Delegation's form says `Record: none`, and the Chief of Staff sends the line to the building Delegation whose pull request it tests. With `issue-comment`, the Chief of Staff drafts the comment, a write as the human handled as step 6 says. The Delegation goes on with the Ruling while that write waits.
4. Write `ruling-made` (the Ruling's `R<n>` and the Delegation it was sent to), log it in the Activity Log, then act on it as on the human's answer: the nudge or restart, the merge order, the send back, the new QA run, or the delivery.
A Ruling may cite an earlier one by its id, and the ledger shows the link.
A Ruling **concerns** a branch and its pull request, not one Delegation: the branch of the Delegation it was sent to, or, for a QA Delegation, the branch whose pull request it tests. So it concerns every Delegation that works on that branch, before or after it: a restart, an overturn's new Delegation, and the building Delegation a QA Ruling's pull request belongs to. That Delegation's Ready to Merge waits for it. A Delegation started from another's branch (a restart, or an overturn's new Delegation) gets, in its brief's **Read first**, every Ruling already concerning that branch, from the ledger: its id, its choice, its verdict, and its **Commits** line. Where the earlier Delegation left no verified report, the Chief of Staff fills that line from the branch (`git log <merge-base>..<head>`) and the earlier Delegation's Activity Log, and marks each commit `(read from the branch, not reported)`, as the ledger form shows ([RUN.md](RUN.md#ruling-ledger)). A Delegation that has ended can no longer change its pull request: a line it would add or update is sent to the Chief of Staff instead, who drafts the edit to that pull request's body as a write as the human, handled as step 6 says. The Dispatch Plan of an autonomous run offers that edit as a routine kind the human may approve.
**The Ruling Review.** Each verdict is a `ruling-verdict`, written with actor `human` for each Ruling the answer names. The human may uphold or overturn a Ruling at any time in the Chief of Staff's session, and must before a Delegation it concerns is Ready to Merge (step 10). The answer names Rulings by id, `upheld: R1 R2; overturned: R3 → option 2`, or is "uphold all". `--status` prints the ledger, and `--resume` opens with the Rulings still awaiting review ([RUN.md](RUN.md#resume)). There is no other invocation for it.
- **Upheld:** the ledger says `upheld`. The building Delegation whose pull request carries the Ruling line updates it to upheld, or, when it has ended, the Chief of Staff drafts that edit, as above; with `issue-comment`, that update is a write as the human, drafted as usual.
- **Overturned:** the ledger says `overturned`, with the option the human chose. It becomes an ordinary human answer to the Decision Request, recorded where `decisions.to` says, and the Ruling line is updated to overturned in the same way. It is sent to the Delegation, or, when that one has ended, to a new Delegation started from its branch, `d<issue>-<k>` with the next unused suffix, on the same Executor and model. The rework is a push: the head goes back to step 7, and QA on the old head is `void` (step 6). An overturned merge order changes only the order step 10 prints.
- **Every Ruling that cited an overturned one** is marked `needs re-review` in the ledger, and is reviewed again. It is not overturned with it.
A Delegation is Ready to Merge only when every Ruling it concerns is `upheld`, or `overturned` with its rework verified. Until then, a Delegation that otherwise meets Ready to Merge is `awaiting Ruling Review` ([RUN.md](RUN.md#states)).
## Workflow
### 1. Read the config
```bash
node "<skill>/config.mjs" check
```
- Exit 1: the config has **problems**. Show each one with its line, and stop until it is fixed. A misread config would send every Delegation down the wrong route.
- Exit 2: the command or the answers file is wrong; its message says how. Fix that and run it again.
- `readiness.needs` not empty: ask for everything it lists in one message. Check that `run_dir` is ignored (below), make the run folder ([RUN.md](RUN.md#layout)), and write the answers there as `answers.json`, the JSON object [CONFIG.md](CONFIG.md#answers-given-in-chat) describes. Run `check` again with `--answers <run_dir>/<run>/answers.json` until it exits 0 with no needs. Offer to write them into a config file; write one only on a yes.
- `readiness.notes`: say each one, and go on.
Before anything is written to `run_dir`, check that it is ignored: `git check-ignore -q <run_dir>/x`. Nothing in a run folder is committed. If it is not ignored, say so, and offer to add `<run_dir>/` as a line of its own to the `.gitignore` at the repository root. On a yes, add it and leave the change uncommitted for the human to commit with their next change; then check again. Without a yes, write nothing to `run_dir` and stop.
When `triage_labels.from` is `document`, read that document now: it maps each triage role to the repository's label.
Then find the harness, from `check`'s `harness` output and this session's own tools, as [HARNESSES.md](HARNESSES.md#finding-the-harness) says: never guessed, and a pinned `harness` that disagrees is a Decision Request. Load its file. For each other harness `executors` names, as an id or in an entry, check its CLI answers `--version`, and that it is signed in where the CLI reports it; note it `ok`, `missing` or `signed-out` for step 4, and load its file too.
**Done when:** `check` exits 0 with `readiness.ready` true, `run_dir` is ignored, each triage role's label is known, and the harness is named, with its Support Level, in the Activity Log.
### 2. Open the run
Make the run folder, unless step 1 made it for the answers, then the board and the Chief of Staff's Activity Log, as [RUN.md](RUN.md) lays them out. Every later step updates the board as its state changes, and appends what it did and why to the Activity Log.
Then write the run's first Run Event, `run-opened`, to the Chief of Staff's `events.jsonl` ([RUN.md](RUN.md#run-events-and-the-run-record)): the repository, the tracker, the run kind, the spec, `team`, `took_over`, the tickets, the harness and its Support Level, and the Decision authority and landing as known so far. From here every step below writes its own Run Event as it happens, never afterwards from memory: the time comes from the clock.
**Done when:** the run folder exists inside `run_dir`, with a board listing each issue named, and its `events.jsonl` opens with `run-opened`.
### 3. Analyse each issue
For each issue, read its body, its comments, its labels, the issues and pull requests it links, and any open blockers. Then place it in the readiness table by its triage role, read through the label mapping from step 1:
| Triage role | Becomes |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `ready-for-agent` | A building Delegation. |
| `needs-triage` | An analysis Delegation: evidence and options, then a Decision Request. Nothing is built. |
| `needs-info` | An analysis Delegation, scoped to what the issue is waiting on. Nothing is built. |
| `ready-for-human` | No Delegation. Listed on the board for the human. |
| `wontfix` | No Delegation. Listed as skipped. |
| no role, or two | A Decision Request: say which labels the issue carries, and recommend a role. Nothing is delegated until it is answered. |
An issue that is closed, or that an open pull request already closes, is a Decision Request too: say what is there, and recommend skipping it or continuing that work.
For each building Delegation, write down the paths it is likely to touch and the shared resources (named in `limits.shared`) it will hold, read from the issue and the code it names. These are its scope fence, and they decide its wave.
Then decide which building Delegations need QA: all of them with `ready_to_merge.qa: report` and no `qa_labels`, or those whose issue carries one of the `qa_labels`; none with `qa: none`. Each one that does gets a **QA Delegation** of its own, `d<issue>-qa`, run after it (step 9). A spec run decides its QA rows with its landing ([SPEC.md](SPEC.md#qa-in-the-dispatch-plan)). When `check` named a `qa_config`, read its `run.target` there: a QA Delegation for a `stack` target holds the **QA Stack**; one for a `url` target holds nothing, and needs its hosts typed in the Dispatch Plan (step 4). A target the file does not give counts as `stack`. In an approved-QA autonomous run both targets start their QA skills from the brief (step 4).
**Done when:** every issue has a row in the readiness table, every building Delegation has a scope fence, and each one that needs QA has its QA Delegation.
### Separate review after the builder stops
When a builder reports `head ready for review: <head>`, the Chief of Staff checks that `<head>` is the committed head of its branch, makes a detached worktree at that exact head, and starts the planned `d<issue>-review<k>` headless reviewer there on the review brief ([BRIEF.md](BRIEF.md#the-review-brief)). Only the Chief of Staff starts the reviewer. Record its own board state and lifecycle events; it writes only its report. Once it ends, remove the detached worktree. Check that its report names the pinned head, relay every finding word for word to the builder, and send it back to fix each finding inside its fence or explain why it does not apply. Verify the resulting report and fixes at step 7. One round runs by default; a second round requires the human's request or, in an autonomous run, a Ruling. Number each new round `d<issue>-review<k>` and keep its report and state. A later push does not void the prior review.
### 4. Show the Dispatch Plan
The Dispatch Plan opens with the harness, its tier and its **Support Level**. Below `verified`, it says what that level means for this run ([HARNESSES.md](HARNESSES.md#support-level)), and the plan waits for the human's "go" even when the invocation carried `go`. On an unlisted harness, it says no harness file exists, and that the run goes one Delegation at a time, on tier 3.
For each Executor, name the actual permission route in the plan: individual approval requests, confirmed narrow rules, or the explicitly chosen broader access. State which Git, network, worktree and run-folder operations it needs. A plan's approval does not establish that an automatic reviewer will approve them. If a launch is refused, retain the reason and use a permitted alternative; never treat an untested rule or automatic approval as confirmed. A Desktop chat's creation and messaging also require the app tool's explicit human authorization ([codex-desktop](harnesses/codex-desktop.md)).
When `executors` is set, choose the building harnesses first, then add review candidates with their chosen builder harness and choose the full plan in table order: write the rows (`id`, `kind` as `build`, `analysis`, `review` or `qa`, the issue's `labels`, their earliest `wave` allowed by blockers, scope fences and shared resources, and each review candidate's chosen builder harness as `build_harness`) and step 1's results to the run folder, and run `config.mjs choose` ([CONFIG.md](CONFIG.md#choosing-an-entry)). A problem it prints, or an exit of 2, is a config problem: say it, and stop. Use its assigned waves, checking scope fences, shared resources, blockers and sequential harnesses again; if a row must move, supply its later earliest wave and rerun the whole choice until all constraints hold. Say its `notes` under the table. For each building Delegation when `executors.review` is set, choose a review entry against that building issue's labels using the same plan-time fallback and round-robin rules. If its harness differs from the builder's, include `d<issue>-review1` as a separate review row, with its chosen harness, model, effort and reason, wave after the builder reports its review head, scope fence "none: report only", and no shared resources. Use the lower Support Level of the build and review harnesses for the warning. No review row counts against `limits.building`. When `executors.review` is unset or the selected harness equals the build harness, keep the existing in-brief review phase. Then one table, one row per Delegation: its issue, its kind (building, analysis, review or QA), its Executor, its harness, its model, its effort and why that entry was chosen (`choose`'s `why`; for a single id or no `executors`, the model and effort come from `models` and `efforts`, and the reason is blank; leave the effort blank where the row's Executor cannot be given one), its wave, its scope fence and its shared resources. A QA Delegation's wave is "after `d<issue>` is verified", its scope fence is "none: commits nothing", and its shared resources are the QA Stack or nothing. Then **Harness limits**: each limit from the harness files loaded at step 1 that bears on this run's Delegations, with what the human will see because of it ([HARNESSES.md](HARNESSES.md#the-harness-limits-section)), and each persistent change the harness needs, such as a copy of the QA skills where it reads skills. Then each check or reminder a harness file's verbs say the Dispatch Plan gives, such as whether messages between sessions would be held. Then the lists: the issues with no Delegation and why, the open Decision Requests from step 3, and the kinds of routine write the human may approve for the whole run (for example, moving an issue's label from one triage role to another when its Delegation starts, or, when the config sets a `records.sink`, **uploading the Run Record** at close-out). Uploading the raw run folder is never one of them.
When the run has a QA Delegation, the plan also says:
- **The QA yes.** In a `go autonomous` run, the plan asks a separate yes for QA, "approve QA?", and only when the config proposes QA rows (step 3): with none it asks nothing. The human may strike rows from it ("QA all but #258"). It is a yes of its own, not implied by `autonomous`, so a run can be autonomous with no QA. A "no", or a struck row, means no QA for those rows: each is Ready to Merge without it once its other conditions are met, the board and the close-out say "QA declined in the Dispatch Plan" on it, and no readiness question, run need or other QA answer below is asked for it (for no row left, none of them is asked). The yes covers re-QA on new heads, `-qa2` and `-qa3`, under the same answers. A run approved with plain `go` is never asked it: its QA stays on the typed route, as below. Everything below that is marked as an approved-QA run applies only to the rows the human approved.
- **QA readiness, asked once.** Run `node "<qa-plan>/adapter.mjs" check --for plan` in this checkout, with `<qa-plan>` the folder of the `qa-plan` copy the QA Delegations will run: the one beside this skill (`<skill>/../qa-plan`), or the folder that its `where qa-plan` names in `load`. With no QA config, or with `readiness.needs` not empty, the plan asks the readiness question here, once, beside the "go": each need, and whether the answers are for this run only or to save a config. It waits for the answers as it waits for a Decision Request from step 3. Write them to the run folder as `qa-readiness.json`, the JSON object `qa-plan`'s `--answers` takes ([RUN.md](RUN.md#layout)), and log them. Then check that they answer every need: copy the file into this checkout's `working_dir` and run `check --for plan --answers` on that copy, and ask again, in the same message, for anything its `readiness.needs` still lists, so no QA session has a need left to ask. Delete the copy afterwards. With "save a config", also write them into the QA config with `qa-plan`'s `render --write`, in this checkout, uncommitted for the human to commit with their next change; the QA Delegations still get the file, since the heads they test do not carry that config. No QA brief asks it again, and the question is never a mid-run Decision Request or a Ruling: readiness answers are facts about the repository, and only the human knows them. The answers hold for the base branch they were given for: the branch the merged config's `effective.plan.base_ref` names, in the output of that `check --for plan --answers` (`origin/main` names `main`), whether the answers or the config set it; or the default branch, when it is null. The board's `QA readiness` line records it. A QA Delegation whose pull request has another base gets no answers file: its `qa-plan` asks, as it does with none, and the Chief of Staff writes the human's answers for that base to `qa-readiness-<base>.json`, for any later QA Delegation on the same base.
- **QA run needs, asked up front.** In an approved-QA run, ask what `manual-qa` would ask a QA session, here, so that none does. Run `node "<manual-qa>/adapter.mjs" check --for run` in this checkout, with no plan, and `<manual-qa>` the folder of the `manual-qa` copy the QA Delegations will run (the one beside this skill, `<skill>/../manual-qa`, or the folder its `where manual-qa` names in `load`). Its `readiness.needs` are the run's needs: the target, the surface, the roles, the stack commands and `accounts.print`. Ask for them in the same message as the readiness answers above, with the same choice: whether the answers are for this run only or to save a config. That one choice covers both answers files. Write them to the run folder as `qa-run.json`, the JSON object `manual-qa`'s `--answers` takes ([RUN.md](RUN.md#layout)), a whole `stack` or `accounts` mapping each, and log them. Then check that they answer every need: copy the file into this checkout's `working_dir`, run `check --for run --answers <copy> --answers-base <base> --base <base>` on it, with `<base>` the branch the readiness answers hold for, and ask again, in the same message, for anything its `readiness.needs` still lists. Delete the copy afterwards. With "save a config", also write them with `manual-qa`'s `render --write`, uncommitted for the human to commit with their next change; the QA Delegations still get the file. Two more answers belong to the same message. **The `working_dir` check:** `git check-ignore -q <working_dir>/x`, with the `working_dir` the merged answers give, and when it is not ignored, ask once whether to add it to `.gitignore`, as for `run_dir` in step 1 (left uncommitted); a QA session never asks it, and one whose pinned head leaves it not ignored (a head that differs from the one checked here) writes nothing and stops, its row held (step 9). **The optional local address,** `run.stack.address`: the address the app serves on, for a stack whose `up` prints none, as part of the `stack` mapping of `qa-run.json`. It is checked here with `node "<manual-qa>/adapter.mjs" host "<address>"`, and kept only when the verdict is `local`; a QA session checks it again before any sign-in. With none given, the QA Delegations whose `up` prints no address hold their scenarios (step 9), since a missing address is never a mid-run question. No QA brief asks it again, and the question is never a mid-run Decision Request or a Ruling: these are facts about the repository and the stack, and only the human knows them. Run answers hold only for the base branch they were given for, as the readiness answers do: a QA Delegation whose pull request has another base gets no `qa-run.json`, and its QA is held for close-out (step 9) instead of asked about.
- **QA hosts, typed in the Dispatch Plan.** In an approved-QA run whose QA config's `run.target` is `url`, or whose plan's QA Delegations would run against a hosted address, the plan asks for each host here, in the same message as the QA yes and the run's needs, so no QA session asks for one. The human types each host, or confirms each `run.hosts` entry (a candidate: `confirmed: false`, `held`, in `check --for run`'s output) by typing its address, in their reply to the Dispatch Plan. No config key confirms a hosted address: a host the human did not type counts as not confirmed, however the config lists it. For each host, run `node "<manual-qa>/adapter.mjs" host "<address>" --target url --confirmed "<the host as typed>"` here, and show its verdict beside the host; **only `hosted` goes ahead**. A `stop` (it looks like production, or is not `http` or `https`) or an unconfirmed entry (`confirm`: not typed, or typed differently) is held before "go": the plan says so, and the human may type another address, or let it be held, which holds only its scenarios (the ones its **Service:** or surface names) while the rest of the plan runs. Then ask, once for each environment (each host in `readiness.environments`), **"did the environment's owner run this repo's seeder there?"**. With "yes", the QA session runs `accounts.print` itself and keeps the values in its own conversation; with "no", the scenarios that sign in there are held for close-out (step 9). The Chief of Staff never collects role values: no value is typed here, written to a file or put in a brief, so none passes through an agent. Write the hosts, with their verdicts and each seeder answer, to the run folder as `qa-hosts.json` ([RUN.md](RUN.md#layout)), and log only that they were typed and each verdict, not the addresses; a host is never written to a config, with "save a config" or without it, and `qa-hosts.json` is deleted at close-out (step 10). A QA session gets a host only through its brief, with a provenance line ([BRIEF.md](BRIEF.md#the-qa-brief)), and checks it again before any sign-in. The question is never a mid-run Decision Request or a Ruling: a host is a fact only the human can type, and a QA session that finds none held for it holds its scenarios and never asks.
- **How each QA skill starts.** The QA Delegation's session always starts on its brief, and its first phase pins the head. What follows depends on the Decision authority line and the plan's target:
- **`relay`: the typed route.** `qa-plan` and `manual-qa` are invoked only by a person. After that phase stops, `/qa-plan <n> [--answers <working_dir>/qa-readiness.json]` is sent to it as a message, with the `--answers` part only when the run has an answers file for its pull request's base, and `/manual-qa <plan file>` later, where [HARNESSES.md](HARNESSES.md#choosing-an-executor) says this harness may run a message as the user's invocation. If the session does not run it (it says it cannot invoke the skill, or asks for it), the human types each command there, and the Chief of Staff gives them the exact command, with its `--answers` path or without it, by the same rule. The plan says this up front, so the human knows they may be asked.
- **`autonomous`, on `target: stack`, once QA is approved: from the brief.** The session reads `qa-plan`'s `SKILL.md`, then `manual-qa`'s, from the paths its brief gives, and follows each as a phase of the brief, by the skill's "Run from an autonomous brief" section ([Autonomous runs](#autonomous-runs)). No command is sent, and the human types none.
- **`autonomous`, on `target: url`, once QA is approved: from the brief too,** with each host typed in the Dispatch Plan (above) and relayed through the brief. No command is sent, no host is typed in the session, and the QA Delegation is never `waiting` on the human.
Where HARNESSES.md names a fallback Executor for QA, the QA row names it with the first (for example, "headless run; else a session you start"), so the "go" covers the switch.
- **QA Places, shown and changeable.** Show the Places this run's QA Report tags its items left for a person with, and which of them hold a merge: the `places` in the `effective` output of the readiness `check --for plan` above, which come from `report.places` and `report.holds` in the merged QA config (`qa-plan`'s ADAPTER.md, _Places_). With no `report` key they are `local` (holds a merge), `staging` and `production` (deferred); `none` (`places: none`) turns Places off, and every item then holds. The human may change them for this run only, or save them to the config, in the same message as the readiness answers and with the same choice. A change is a `report` mapping (`places`, `holds`) in the readiness answers: it goes into `qa-readiness.json` ([RUN.md](RUN.md#layout)), and with "save a config" `render --write` writes it too, as for the other answers. Check it with `check --for plan --answers`, as for the rest. Say plainly in the plan what a run-only change does: it applies to composing the QA Plan only, since only `check --for plan --answers` reads that file. `adapter.mjs plan` and `report.mjs` (`comment`, `summary`, `evidence`) read the QA config at the pinned head alone, so the committed `qa.config.yml` stays the source of truth for them; a change meant for posting is saved to the config and committed before QA, and the human should commit it to the config for the run to rely on it. The QA brief carries the Places the run uses ([BRIEF.md](BRIEF.md#the-qa-brief)), and the Chief of Staff reads each posted header against them (step 9).
- **QA uploads, off unless approved.** Uploads stay off. Ask, once, in the same message as the QA yes but as its own question, **"upload eligible QA Artifacts to `<tag>`?"**, and only when the QA config's `run.evidence.upload` is `gh-release:<tag>`; with `none` nothing is asked. Run `gh repo view --json visibility,nameWithOwner` here first, and when `visibility` is not `PRIVATE`, show with the question: _anyone who can see this repository can download a release asset; upload only files that show QA Account data on a test system_. The yes covers the run and its re-QA. With it, a QA session uploads exactly what `node "<manual-qa>/report.mjs" evidence` accepts, with no per-file question, and never a failed run's screenshots or recordings; the eligibility refusals `evidence` makes still apply, and so do `manual-qa` step 10's rules for which files are offered, and it creates the prerelease only when `evidence` says `create`. Without it, or on the "no", every QA Artifact stays local. It is a yes of its own, not implied by the QA yes.
- **The QA writes.** Delivering each QA Plan is always a Decision Request carrying the draft, so the human sees what will be tested before it is run. Posting the QA Report where the plan was delivered is a routine kind the human may approve for the run. Uploading is never routine and never a Decision Request per file: it is the one opt-in above, or nothing. In an autonomous run, a post the human did not approve waits as a queued write. The stale edit `qa-plan` step 8 would offer is never made or asked about: a posted header names its commit, and a re-QA's post replaces the comment.
- **The headless opt-in.** Where the harness starts QA sessions parked at `go` ([harnesses/claude-code-desktop.md](harnesses/claude-code-desktop.md)), the plan also offers `executors.qa: claude-code-cli` as an alternative, a headless QA run, and names its costs: the human cannot watch it, it has no built-in browser, and it runs with `--permission-mode auto`. Without that setting, QA runs in the Live Sessions, parked.
- **That "go" covers re-QA.** When a head moves and is QA'd again, the new QA Delegation (`d<issue>-qa2`, then `-qa3`) runs on the same Executor and model without a new plan. On a harness with parked QA sessions it also runs in the same session as the QA Delegation before it (step 9). A different Executor, or QA for an issue the plan gave none, is a new plan.
Choose waves so that:
- no two Delegations in one wave overlap in scope fence or shared resource;
- a Delegation whose issue is blocked by another issue in the run is in a later wave than its blocker;
- no wave holds more building Delegations than `limits.building`, or than one on a harness that runs sequentially ([HARNESSES.md](HARNESSES.md#tiers)). Review, QA and analysis Delegations do not count toward `limits.building`; each entry limit caps its own Delegations in a wave, and a full entry falls back or moves the work to a later wave; a QA Delegation on the QA Stack still never runs beside another holder of it.
A Delegation in a later wave because of an overlap or a blocker starts only once the Delegation it waits for is merged, so it is built on the merged work, not beside it. Until then it is parked ([RUN.md](RUN.md#states)).
Choose each Executor from what this harness's file offers (its **Executors** line), or from the harness the plan's row names, which nothing changes after "go": a Live Session for a building Delegation where the harness has one, so the human can open it; a headless run or a sub-agent for an analysis Delegation, or where the harness has no Live Sessions; a session the human starts where the harness can start neither. A QA Delegation is never a sub-agent: it needs a working copy and a browser of its own, and outside an autonomous run it runs user-invoked skills.
Last, the **Decision authority** line: `relay`, the default (outside factory mode, which never waits on a human: `--factory`), where every Decision Request goes to the human, or `autonomous`, where the Chief of Staff rules on the kinds [Autonomous runs](#autonomous-runs) lists, and the human reviews each Ruling before anything is Ready to Merge. The line lists both halves of the split, so the human sees what they would hand over. When the run has a QA Delegation, its `autonomous` half lists the QA Rulings ([Autonomous runs](#autonomous-runs)) only when QA is approved (the QA yes above), and says that QA, on a `stack` or a `url` target, then runs from the brief, with no command typed, and that each hosted host is typed in the Dispatch Plan. An `autonomous` word in the invocation fills it in as `autonomous`; without one, it reads `relay`.
Under it, the **QA** line, when the run is autonomous and has QA rows: `QA: approved for <rows>` or `QA: declined in the Dispatch Plan for <rows>`, and for an approved row three lists, so the human sees what they hand over: **asked now** (the readiness answers, the run's needs, the `working_dir` check, the optional local address, the typed hosts and the seeder answers, below), **the Chief of Staff rules on** (the QA Rulings, step 9), and **held for close-out** (what waits for them after the run, step 10).
The human's "go" approves the whole plan: every row, the routine writes they tick, and the Decision authority line as shown. `go autonomous` approves it with the line set to `autonomous`. A change to any row, or setting the line back to `relay` on a harness at `verified`, is a new plan, shown again. With `go` in the invocation, start as soon as the plan is shown, unless step 3 raised a Decision Request, or a harness the plan uses is below `verified`: then wait for the answer and the human's "go". Below `verified`, the line an `autonomous` word fills in reads `autonomous, on a typed go autonomous`, and the plan says that Rulings would be made on a harness whose limits are not fully known. That line, as shown, offers two answers: `go autonomous`, typed after seeing the plan, starts the run autonomous; a plain `go` approves the plan as shown with the line at `relay`. Neither is a change to the plan, so neither shows it again.
The plan's approval is a wait of the run, not of a Delegation: when the plan is shown and waits for "go", write `wait-opened` (step kind `plan-approval`, cause `by-design`, how `chat`), and a Decision Request raised before "go" as `decision-request`. The human's "go" is one touch: write `wait-closed` with actor `human`, covering those Decision Requests, then `plan-approved` with the Decision authority line as approved. With `go` in the invocation and no wait, the "go" is a `human-step` of the same kind.
**The live board.** The Chief of Staff writes `board.html` each time it rewrites `board.md`, with `node <skill>/records.mjs board <run-folder> --heartbeat <minutes|none>` (the interval on the board's `Heartbeat` line, or `none` while the heartbeat is deleted or on tier 3), and at `go` and `go autonomous` it gives the human the `file://` link that command prints, so they can watch the run in a browser ([RUN.md](RUN.md#the-live-board)). It is a file that reloads itself, never hosted, and the human answers in the chat, never on the board.
**An optional server.** Where a process can run, the human may start `node "<skill>/records.mjs" serve <run-folder> --heartbeat <minutes|none>` from the repository's root: it binds to 127.0.0.1 only, pushes each new Run Event to the page it serves, and runs until it is stopped. Nothing needs it: the run never waits on it, and `board.html` works without it ([RUN.md](RUN.md#the-optional-server)).
**Done when:** the human has said "go" to this plan, and the board records it, with its Decision authority.
### 5. Dispatch a wave
Before spawning, validate each brief's start-event command with the read-only check in [BRIEF.md](BRIEF.md#the-brief-contract). A rejected command is corrected before the Executor starts.
For each Delegation in the wave, write its brief to its folder in the run, carrying every item of the Brief Contract ([BRIEF.md](BRIEF.md)), and `spawn` its Executor with that brief. Record the Executor's handle, its branch and its start time on the board.
Where the harness file says its `spawn` can only propose a session for the human to start (on Claude Code desktop, a turn the app started), the Delegation is `waiting` on the human to start it, with what the human must do queued as a Decision Request. Step 6 checks `waiting` rows on every wake-up, so the turn that finds the session records its handle and start time, sets the row to `running`, and arms its waits, as the harness file says.
Where the harness file starts QA sessions parked (Claude Code desktop, with QA approved in step 4), the `go` turn also starts one parked QA session per approved QA row, each on a QA brief written without `<head>` ([BRIEF.md](BRIEF.md#the-qa-brief)), and the row is `parked` with its handle. Those starts are never cards: the human's words at `go` authorize them, and a parked session that later proves unusable holds its row for close-out instead of being replaced by a card mid-run.
Each brief gives the Delegation its own `events.jsonl` as an absolute path, and the commands to write its `delegation-started`, `delegation-landed` and `delegation-ended` events with its Executor kind, harness, model, effort (when set) and start route already filled in ([BRIEF.md](BRIEF.md#the-brief-contract)). The Delegation writes them, so its start and end are the times it really started and ended, not the times the Chief of Staff noticed. A start the harness refused, so that the human must start it from a card, opens a `wait-opened` with cause `harness-limit`, how `card` and the card's id, and the human's click closes it.
**Done when:** every Delegation in the wave is running, with its handle on the board, or is `waiting` on the human to start it, as above.
### 6. Run the loop
`await` the Delegations the run waits on, on the harness's event and the heartbeat ([HARNESSES.md](HARNESSES.md#waiting-an-event-and-a-heartbeat)). A wake-up means something may have changed, never that a report is final. So on each one, check every Delegation the run waits on, not only the one the wake-up named: any that is `running`, `waiting`, `reported` or `sent back`, and a QA Delegation still in progress ([HARNESSES.md](HARNESSES.md#waiting-an-event-and-a-heartbeat)). For each event:
- **A Decision Request:** in an autonomous run, first decide whether it is a kind the Chief of Staff rules on, with evidence that meets the bar ([Autonomous runs](#autonomous-runs)). If it is, make a Ruling. If not, set only that Delegation to `waiting`, queue the question, notify the human where the harness can, and go on with the run. In any other run, relay it to the human, whole. When the human answers, `message` the answer to the Delegation, and log it. Then record it where `decisions.to` says ([CONFIG.md](CONFIG.md#decisions)), starting with `decisions.marker` when one is set: for `pull-request`, the message tells the Delegation to add it to its own pull request's body; for `issue-comment`, the Chief of Staff drafts the comment, and posts it as a write as the human.
- **A drafted write as the human:** an approved routine kind goes ahead and is logged; any other kind is relayed as a Decision Request, and made only on a yes.
- **A report:** when its **Final:** line says `yes`, verify it (step 7), or for a QA Delegation, step 9. When it says `no, waiting on <what>`, it is not verified yet and not sent back: re-arm the wait on that Delegation, and let the heartbeat check it again. Where the Executor is a process that has exited (a headless run ends its process when its turn ends), nothing will rewrite that report on its own. An exited process whose report says `no` is not a crash: it waits on what it named. Once that has finished (CI on its head, a review run), `message` it to finish the work and rewrite its report. It is a crash only when it exited with no report at all.
- **A push to a branch that has passed step 7:** its head moved. Its verification and any QA for the old head no longer hold: set its building row back to `reported`, whether it was `verified`, `awaiting Ruling Review` or `ready to merge`, mark a running or `passed` QA Delegation for it `void` (a `failed` one stays `failed`, as the record of that run), and verify the new head from step 7.
- **No sign of progress** for longer than the work explains: read the Delegation's Activity Log and its branch. If it is stuck, `message` it once with what you see. If it is still stuck at the next check, raise it to the human as a Decision Request.
- **A crash:** keep its branch and worktree as they are: they are its handoff. Record what was done and what is left on the board, and raise it to the human with a recommendation (start a new Delegation from the branch, or stop).
- **In an autonomous run**, a Delegation still stuck after the nudge, or a crashed one, is a Ruling instead of a question to the human: nudge it again, or restart it from its branch. The Chief of Staff makes one such Ruling per issue in the run. When the nudged or restarted Delegation stalls or crashes again, that is a question the human keeps: it is queued and notified as a question not ruled on ([Autonomous runs](#autonomous-runs)). Stopping it, or dropping it from the run, stays the human's.
- **A Ruling overturned in the Ruling Review:** act on it as on any human answer ([Autonomous runs](#autonomous-runs)).
**Run Events in the loop.** Each event above is also written as a Run Event, with the actor who did it: a Decision Request queued, the run's own or a Delegation's, is `decision-request`, which only the Chief of Staff writes, with the next run-wide id `dr<n>` (a Delegation writes none), and a question not ruled on opens a `wait-opened` (cause from the list in [RUN.md](RUN.md#run-events-and-the-run-record), how the human answers) that the human's answer closes, covering every Decision Request that one answer settled; a Ruling is `ruling-made` (its `R<n>` and the Delegation it was sent to), written when it is sent, and its verdict `ruling-verdict` (actor `human`), written for each Ruling the Ruling Review names, once the answer has been given; a wait that belongs to the run and not a Delegation (the review label, posting replies, the merge) is a `wait-opened` with no `delegation`, and the human's touch that ends it is the `wait-closed`; a wait never closed is reported as open when the record is derived; a report sent back is `send-back`; each write made in the human's name is a `write` with `as-human` true and actor `chief-of-staff`; a review round and a CI result are `review` and `ci`; a QA Delegation's result is `qa-result`; a ticket parked on a teammate's ticket opens a `teammate-blocker` wait, and unparking closes it. A wake-up that finds the human has acted writes the human's touch with the time the wake-up found it, and says in the Activity Log that the time is the wake-up's.
**The heartbeat.** Arm it at the first `spawn` of the run, in the form the harness file gives, and record its id on the board, with the time it was made ([RUN.md](RUN.md#board)). Where the heartbeat is the foreground watch, the board says `foreground watch` in place of an id. For a shell-loop watch, before launching each watch (and on `--resume`), increment the monotonic generation id in `<run_dir>/<run>/watch.gen` (and clean up any prior `<run_dir>/<run>/watch.pid`), keep the watch shell loop strictly read-only (inspection and stdout only, never writing `activity.md`, `board.md`, or `events.jsonl`) and exiting immediately if superseded, and drop any watch output whose generation id does not match current `watch.gen` without acting or appending to `activity.md` or `events.jsonl` ([HARNESSES.md](HARNESSES.md#waiting-an-event-and-a-heartbeat)). On tier 3 there is none: the human is the event. Delete it at close-out (step 10), or when the run parks with nothing running and only the human's merges to wait for, in the form the harness file gives, a marker file included, along with any foreground-watch `watch.gen` / `watch.pid` files, and record that on the board. `--resume` arms it again ([RUN.md](RUN.md#resume)). Where the harness's heartbeat expires, recreate it before then and record the new id. On each firing, the Chief of Staff, before anything else, writes a `heartbeat` Run Event (actor `chief-of-staff`, no other fields) and rewrites `board.html`, so a quiet run never reads as stale ([RUN.md](RUN.md#the-live-board)); then it:
1. reads the board;
2. compares each Delegation the run waits on, by its `report.md` and `decisions.md`, with what it last handled. On every wake-up, the Chief of Staff logs the time and size of each `report.md` and `decisions.md` it handles in its Activity Log, so this comparison has a baseline, after `--resume` too. `activity.md` is prose context/baseline only and never authorizes a new action or `events.jsonl` entry without verifying `decisions.md` (answered markers), `report.md`, and the git, pull request, and CI source;
3. checks each Delegation's session or process where nothing new was written, the pull request's checks (`gh pr checks <pr>`), and the review run ([step 7](#the-review-workflow));
4. acts on what changed, as the events above say, and re-arms any wait that ended or timed out, such as a subscription on one Delegation or a capped wait on CI or the review. When nothing changed, it logs one line in the Activity Log and ends the turn at once, or, on a foreground watch, runs the watch again; the `heartbeat` event it wrote first is what keeps the board fresh.
A question already queued and notified is not notified again at each firing: it waits on the board, as before.
When a Delegation leaves the wave, start the next Delegation whose wait is over, within `limits.building`, or one on a harness that runs sequentially.
**Done when:** every building Delegation is Ready to Merge or `awaiting Ruling Review`, stopped with its analysis delivered, parked until a merge, landed on a spec run's integration branch ([SPEC.md](SPEC.md#on-an-integration-branch)), or raised to the human.
### 7. Verify each report
Keep the board's Verification cell current for each check ([RUN.md](RUN.md#board)). Before each re-gate, run the environment preflight in [CONFIG.md](CONFIG.md#re-gate-preflight) in the environment that will run it, using `regate --tools` to check its detached checkout; fix missing prerequisites or report them, and never interpret a failed or stopped gate as passed. While any required verification remains, tell the human the PR is not yet Ready to Merge.
Only a final report is verified: one that says `**Final:** yes`. A report that says `no, waiting on <what>` is not sent back, since the Delegation said what it waits for. It waits for the heartbeat (step 6). A report with no **Final:** line is sent back, as a blank line would be.
Check each claim the report makes ([BRIEF.md](BRIEF.md#report)) against the source:
- **git:** the branch exists, its head is the commit the report names, and it is pushed;
- **the tracker:** the pull request exists, targets the default branch, and its body closes the issue;
- **CI:** every check on that head has passed;
- **re-gate:** each `regate` command passes on that head. Run `node "<skill>/config.mjs" regate <head> --out <run folder>/evidence/<id>-regate.json`: it makes the detached worktree, never the Delegation's, runs each command there, removes it, and writes the results to that file. It exits non-zero on any failure the config's `regate.allowed_failures` does not list, and names it ([CONFIG.md](CONFIG.md#regate)); a listed failure is known, and does not hold the report back;
- **review:** where the repository runs Agent-kit's review workflow, that review has run on that head ([below](#the-review-workflow)); every review comment is fixed or answered; and with `ready_to_merge.review: approved`, an approving review exists;
- **Rulings:** in an autonomous run, the report's commit-to-Ruling map ([BRIEF.md](BRIEF.md#report)): each commit it maps is on the branch, each Ruling it names is in the ledger, and every Ruling that concerns its branch is in this map, or in the verified report of an earlier Delegation on the same branch (one it was restarted from); a Ruling its brief listed from an earlier Delegation is carried into the map with the commits the brief gave, and checked against the ledger entry the brief was written from, and, with `pull-request`, its pull request's body carries the line of each Ruling it concerns, with its current verdict. A ticket on a spec run's integration branch has no pull request: its lines are checked on the `<integration>` row instead ([SPEC.md](SPEC.md#on-an-integration-branch));
- **scope fence:** every path the branch changes from the default branch (`git diff --name-only <merge-base> <head>`) is inside its scope fence, or was answered as a Decision Request. A change outside it that no Decision Request answered, a fix a reviewer or CI prompted included, is raised to the human as a Decision Request: the fence was approved in the Dispatch Plan, and only the human widens it. On a spec run's integration branch, `node "<skill>/config.mjs" land` makes this check again at landing, against the brief's fence globs ([SPEC.md](SPEC.md#on-an-integration-branch)).
#### The review workflow
The review workflow's Caller is the repository's workflow with a job that `uses:` Agent-kit's `agent-review-reusable.yml`. With `ready_to_merge.review_workflow: detect` (the default), look for it under `.github/workflows/`; when more than one workflow there has such a job, ask the human which one is the review Caller, and suggest setting its path in the config, rather than picking one. With a path, that file is the Caller. With `none`, or when `detect` finds no Caller, there is no review workflow to wait for, and the review claim is the comments alone.
With a Caller, green CI and no review comments is not a settled review: the review workflow posts its comments after CI is green, minutes later. Base the claim on the Caller's run for the verified head, never on whether comments exist yet. Find it with `gh run list --workflow <Caller> --commit <head>`, or the review job's check in `gh pr checks <pr>`. A run started by a manual dispatch is recorded against the commit it was dispatched on, usually the default branch's, not the pull request's head, so neither of those finds it: list the Caller's dispatched runs since the head was pushed (`gh run list --workflow <Caller> --event workflow_dispatch`), and read which head each reviewed from its log once it has finished: the review job's "Build review brief" step shows the head it was given as `HEAD_SHA` (`gh run view <run-id> --log`; `gh` gives no log for a run still going). A dispatched run still queued or running, started since the head was pushed, counts as a review running for this head until its finished log says otherwise. A finished dispatched run, started since the head was pushed, whose log shows no `HEAD_SHA` (its gate refused the dispatching actor, or it was cancelled while it waited) is a failed or cancelled review: raise it as below, with its link. A run whose review job was skipped is not a review, and neither is a run for an earlier head. The review claim holds once a run's review job has finished on this head and every comment it posted is fixed or answered, or once the human has said no review is coming for this head, recorded where `decisions.to` says.
- **The review is running or queued:** the row stays `reported`. Check it again at the pace the review takes, minutes apart: at each wake-up, the heartbeat's included, or with a capped wait the harness file names, such as `gh run watch <run-id> --interval 60`. Never tighter than that. A capped wait that ends with nothing found is re-armed at the next heartbeat, never left ended. Where the harness delivers the pull request's events to this session, wait for them instead. Where it does not, as on harnesses with no CI or pull request subscription, these checks are the only way the comments reach the run.
- **No run on this head:** the review starts on a trigger the human owns, such as a label (Agent-kit's example Caller runs on `agent:review`) or a manual dispatch. Raise a Decision Request: start the review on this head, or say no review is coming. Adding the label is a write as the human, drafted unless the human approved that kind in the Dispatch Plan.
- **The review job failed or was cancelled:** it is not a review. Raise it to the human, with the run's link, with the same two options.
A review can also land later on a head that has already passed this step: someone runs the review again, or a reviewer comments. The head did not move, so the push rule in step 6 does not apply. Set the building row back to `reported`, send each new comment to its Delegation, and check the review claim again. QA for that head holds, a `passed` QA Delegation included: if the comment is answered without a push, the row goes back to where it was without new QA. A fix is a push, and voids it as any push does. Before the close-out prints a row as Ready to Merge, check its head once more for a review run or a comment newer than its verification (step 10).
QA is not checked here: it runs on the head this step verified (step 9).
A claim that does not hold goes back to the Delegation with what was found. Tell the human only what held. A building Delegation whose report holds goes on to step 8.
An analysis Delegation's report is checked the same way: every piece of evidence it cites must be where it says. Then relay its options as a Decision Request, in an autonomous run too: an analysis Delegation's options stay the human's.
**Done when:** each report is verified, or sent back with what did not hold.
### 8. Find conflicts between finished branches
For each pair of verified branches, and for each against the default branch, check whether they merge cleanly in the order proposed, without touching any checkout (`git merge-tree --write-tree`). A pair that conflicts goes back into the plan: propose an order that merges one first and has the other's Delegation merge the default branch into its own branch afterwards, resolving the conflict in a new commit, as a Decision Request, or, in an autonomous run, as a Ruling. A rebase would need a force-push. That new commit is a new head: the branch goes back to step 7, and any QA for its old head is `void`.
Fetch first, and test against the default branch's tip on the remote (`<remote>/<default>`). When the board's `Default branch` line reads `none yet`, write it, once every verified branch has been checked against that tip, with the tip's SHA and the time, naming as passed, each with its head, only a verified branch whose head already contains that tip (`git merge-base --is-ancestor <tip> <head>`): its merge result is its head, which step 7 re-gated. Step 8 runs no re-gate on a merge result, so every other branch is left unnamed, and the first default-branch check re-gates it ([RUN.md](RUN.md#board)). The line is the baseline the [default-branch check](#the-default-branch-check) compares with. After that, only the default-branch check rewrites it, since it checks every Ready to Merge row against the new tip; a later step 8 that rewrote it would hide a move from a row verified before it.
This runs before QA so that the head QA tests is the head that merges. A branch whose report held and that merges cleanly is Ready to Merge when it needs no QA, but listed as Ready to Merge only once it has passed the [default-branch check](#the-default-branch-check). One that needs QA is `verified`, and goes to step 9.
**Done when:** an order exists in which every verified branch merges cleanly.
### 9. QA each finished head
For each building Delegation that is `verified` and merges cleanly in the order from step 8 (on a spec run with an integration branch, the `<integration>` row, [SPEC.md](SPEC.md#on-an-integration-branch)), with `<head>` the commit step 7 verified:
1. **Dispatch its QA Delegation.** Write the QA brief ([BRIEF.md](BRIEF.md#the-qa-brief)), pinned to `<head>`. Where a QA session for the row is already parked (step 5), message it the head instead of spawning one, and set the row `running`. Otherwise `spawn` it on the plan's Executor with the model and effort of its row, once no other holder of the QA Stack is running, when it holds the QA Stack. Record it on the board as `running`, with `<head>` in its Branch cell. When it reports a mismatch at its phase 1, the head moved: handle it as a push (step 6). When it reports that the head is pinned, on the typed route ([step 4](#4-show-the-dispatch-plan)), send `/qa-plan <n> [--answers <working_dir>/qa-readiness.json]` to it as the plan says (the `--answers` part only when the run has an answers file for its pull request's base), and log whether the session ran it as an invocation; if it did not, tell the human which session to type it in, and the exact command. On the brief route there is nothing to send: the session goes on to compose from its brief. The first run that relies on a message for this records the result in its Activity Log, for [HARNESSES.md](HARNESSES.md) to be corrected.
2. **Relay the QA Plan.** The QA Delegation raises its draft QA Plan as a Decision Request: relay it whole. In an autonomous run, its delivery is a Ruling instead, when the evidence meets the bar: each scenario follows from a promise in the issue, and none needs a write the human keeps. When `qa-plan` found no Residue, it wrote no plan, and the QA Delegation reports that instead: go to 3. The human's answer is `qa-plan`'s yes, or the correction it asks for. When the human is in the QA session and answered `qa-plan` there, its Activity Log says so, and there is nothing to relay. While it composes, `qa-plan` may raise other questions, each a Decision Request: in an autonomous run, its subject issue and an `unknown` row are Rulings under the evidence bar, or, when the evidence does not settle one, questions the human keeps (with QA approved, held for close-out and the QA Delegation goes on; on the typed route, the QA Delegation is `waiting`); and when it asks whether a test could prove a promise, **Add the test** is a send-back Ruling: `message` the building Delegation what the test must assert. It writes and pushes the test, so its head moves and goes back to step 7 (step 6), and this QA Delegation is `void`; the new head is QA'd again. When `qa-plan` stops on a regression, the QA Delegation reports its rows: handle them as a FAIL (4). Once the plan is delivered, start `manual-qa` in that session the way the plan says: on the typed route, `message` it `/manual-qa <plan file>`, or tell the human to type it there; on the brief route, there is nothing to send.
3. **Verify its report** against the source: the QA Plan and QA Report it copied into its Delegation folder, the plan's **Head** is `<head>`, the report has one row per scenario in the plan, the pull request's head is still `<head>`, and wherever the report says the plan was delivered or the report posted, it is there. **A QA claim is checked by the posted comment's strict header,** never by the QA session's word: the Chief of Staff reads the posted comment itself (`gh`), saves it to a file, and runs `node "<manual-qa>/report.mjs" summary <comment file>` on it, in this checkout, with the Places the config at `<head>` gives ([Places](#4-show-the-dispatch-plan)). The header is `QA Report: result=passed|failed; commit=<sha>; left-for-person=<n>; deferred=<n>`, or `QA Report: no manual QA needed; commit=<sha>`. The claim holds only when the comment parses (exit 0), its `commit` is `<head>` in full, its `result` is the one the QA report claims, and its `left-for-person` and `deferred` counts equal the items the QA Report leaves for a person and defers. A header that does not parse, whose commit is not `<head>` (a comment for an older head is stale), or whose result or counts differ, counts as no report: the claim is not accepted, and it goes back to the QA Delegation. With no Residue there is no plan or QA Report to compare: check instead that each claim the report names as proving a promise is a test or CI check that passed on `<head>`, and, if a comment was posted, that its header parses and names `<head>`. A claim that does not hold goes back to the QA Delegation.
4. **Act on the result.** Each outcome below that makes the building Delegation Ready to Merge lists it as such only once it has passed the [default-branch check](#the-default-branch-check), since the default branch may have moved while QA ran.
- **Every scenario passed:** the QA Delegation is `passed`, and the building Delegation is Ready to Merge.
- **No Residue:** `qa-plan` found every promise covered by automation and wrote no plan. Once its claims are checked, the QA Delegation is `passed`, the building Delegation is Ready to Merge, and the close-out says it needed no manual QA, with the claims.
- **Scenarios left for a person, and no FAIL:** the Chief of Staff never runs scenarios left for a person ([Rules](#rules)). With QA approved, they are held for close-out (below). Otherwise one Decision Request lists them, each with its steps from the plan, and offers three options in order: (1) **a new QA Delegation** (`d<issue>-qa<k>`, next unused suffix), scoped to the listed scenarios on the same `<head>` and the same delivered QA Plan, on an Executor the human names in the answer that has the missing driver (for example a Live Session with a browser); (2) **the human runs it** (runs each and gives its result); or (3) **waive** it. Never the Chief of Staff. On a new QA Delegation, `spawn` (or start, per the named Executor) `d<issue>-qa<k>` on a scoped QA brief ([BRIEF.md](BRIEF.md#the-qa-brief)): it is not a re-QA of a new head, merges its rows into the head's one QA Report with provenance naming `d<issue>-qa<k>` (editing any existing `<!-- qa-report -->` comment in place where posting is approved, never posting a second comment), and is verified as any QA result (item 3). When the human runs or waives each, record the answer where `decisions.to` says. The building Delegation is Ready to Merge once each has passed or been waived. A FAIL reported by the human or the scoped QA Delegation is handled as below. **When asked directly:** if the human asks the Chief of Staff for those results, it answers in one line naming the rule ([Rules](#rules): "The Chief of Staff never does a Delegation's work") and why (the verifying session must not be the doing session), then raises the Decision Request with the options above, or points to the `"QA held for you"` entry already there, naming an Executor here that has the missing driver. No override: the same answer if the human insists.
- **A FAIL, or an outcome under the plan's _Stop and do not merge if_:** the QA Delegation is `failed`. One Decision Request carries each failing row with its evidence, and three options: send it back to the building Delegation (recommended), run QA again on the same head (when the failure looks like the QA Stack, not the change), or accept it as it is. On send back, `message` the building Delegation the failing rows: it is `sent back`, and its fix's new head starts again at step 7. On accept, record the decision where `decisions.to` says, and the building Delegation is Ready to Merge. In an autonomous run, send back or run again is a Ruling; accepting the FAIL stays the human's, and so does waiving a scenario left for a person, held for close-out with QA approved (below).
Each QA run after the first, on a new head or on the same one, is a new QA Delegation, `d<issue>-qa2`, then `-qa3`, under the same "go" (except a scoped QA Delegation for scenarios left for a person, which runs on the Executor the human named in their answer). Where QA sessions are parked, a re-QA runs in the same session: copy the earlier QA Plan and QA Report to the run folder, then message it the new head and that it is a re-QA, so it throws away its old state and re-pins. It is never a card, and never a new session, unless the parked session is unusable ([harnesses/claude-code-desktop.md](harnesses/claude-code-desktop.md)), when its row is held for close-out. Its QA Plan replaces the one delivered before.
**Done when:** every building Delegation that needs QA has a `passed` QA Delegation for its current head, a result the human accepted or waived, or has been sent back.
#### Approved QA: Rulings, holds and Review boxes
With QA approved (step 4), on a `stack` or `url` target, this step runs as above, except that a QA Delegation is never `waiting` on the human. A Decision Request it raises is one of the Ruling kinds (the Autonomous runs list), and the Chief of Staff answers it in the same wake-up under the evidence bar; when the evidence does not settle it, the Chief of Staff does not queue it: it records the item as held, tells the session to go on, and the session reports it. A question that is not one of those kinds is never raised: the session holds it itself, in its report's **Held for close-out:** line. Each held item goes to `qa-held.md` in the run folder, with its row, what it is, its evidence and its options ([RUN.md](RUN.md#layout)), and the building Delegation stays `verified` until step 10, where it is `waiting` on the held items, listed in its Decision Requests cell ([RUN.md](RUN.md#states)), until its list is answered.
- **Review boxes.** The QA session quotes each open box's file at the pinned head (`git show <head>:<path>`), saves the quotes to `review-quotes.md` in its Delegation folder, and marks each box "literal, quoted" or "needs judgment". For a literal box, the Chief of Staff re-reads the source at that SHA itself, so the session's quote is never the only evidence, and rules under the evidence bar: "holds", or "does not hold". A "holds" Ruling is shown in the QA Report as `(checked under R<n>)` under the box's line, and its Ruling line goes in the pull request body, through the building Delegation, as Rulings go. A "does not hold" Ruling is a FAIL: the box's words are not in the file, so it is sent back to the building Delegation, as step 9 sends a FAIL back, and a missing promise is fixed, not waved through. A box that needs judgment, such as a wording review, is held for close-out. No agent ever ticks a box, even under a "holds" Ruling: the tick stays a person's sign-off.
- **Scenarios left for a person.** The Chief of Staff never runs or passes one ([Rules](#rules)). A surface with no driver, a role restore on a hosted target, a run that could not carry a scenario out, and a need that appears only after compose are held for close-out with their steps and the options: **a new QA Delegation** (`d<issue>-qa<k>`, next unused suffix, on an Executor the human names that has the missing driver), **the human runs it** (pass), **waive**, and **run after merge** (never the Chief of Staff), and the rest of the plan runs. "Run after merge" is an answer, so its row may be Ready to Merge with the follow-up recorded; starting `d<issue>-qa<k>` is the human's answer at close-out, never a Ruling. If the human asks the Chief of Staff directly for those results, it answers in one line naming the rule ([Rules](#rules)) and why, and points to the `"QA held for you"` entry (naming an Executor here that has the driver), with no override even if the human insists.
- **A hosted host the session cannot use.** The QA session's own `host` check refuses a relayed host, the brief carries no entry for a service or surface a scenario needs, or an entry is unconfirmed: only the scenarios that use it are held, with the reason, and logged in the report's **Held for close-out:** line; the rest run. The session never falls back to the typed route, and nothing is typed in it. A seeder answered "no" holds the scenarios that sign in there. A harness whose QA session does not accept a relayed host (its **Check before use**) holds all of them.
- **A `working_dir` not ignored at the pinned head.** The QA session writes nothing and stops, and its row is held. A stack whose `up` prints no address, with no `run.stack.address` in `qa-run.json`, holds its scenarios.
- **A FAIL.** Sending it back, or running QA again when it looks like the QA Stack, is a Ruling. Accepting it, and waiving a scenario, are held.
### 10. Close out
In an autonomous run, the Ruling Review comes first. List each Delegation that is `awaiting Ruling Review`. Show the Ruling Ledger grouped by Delegation: each Ruling with its question, its options, the choice and its reason, its evidence, the commits that followed from it, and the Rulings it cited, `needs re-review` ones first. The human answers per Ruling, `upheld: R1 R2; overturned: R3 → option 2`, or with "uphold all". An overturn sends its Delegation back to work, as [Autonomous runs](#autonomous-runs) says, and its row leaves this close-out until its new head is verified. Once no Ruling for a row is `unreviewed` or `needs re-review` (and, with approved QA, once its held items are answered, below), and, with `pull-request`, its pull request's body shows each Ruling it concerns with its verdict (sent to the Delegation, or drafted by the Chief of Staff, as [Autonomous runs](#autonomous-runs) says), it is Ready to Merge.
**QA held for you.** With QA approved, right after the Ruling Review, list every held QA item (`qa-held.md`), grouped by row, each with its row, what it is, its evidence and its options: a judgment box with the file's quote, a scenario left for a person with its steps (**a new QA Delegation** `d<issue>-qa<k>` on an Executor the human names in the answer that has the missing driver, **the human runs it**, **waive**, or **run after merge** — never the Chief of Staff), a FAIL to accept (or one the evidence does not settle), a missing address, a refused or missing host, a seeder answered "no", an unignored `working_dir`. For a held Surface question, list its choices and exact affected scenario IDs. Record the human's Surface choice before asking which completion route applies (a scoped QA Delegation, the human runs them, waive, or run after merge). Pass that choice and those IDs to a scoped brief as a run-only answer, without changing the committed config or delivered plan. The human answers all of them in one sitting, per item. They are outside the Ruling Ledger, since held items are not Rulings: nothing in it records an answer, the answers are logged and recorded where `decisions.to` says. Starting `d<issue>-qa<k>` is the human's answer at close-out, never a Ruling: when chosen, `d<issue>-qa<k>` runs on a scoped QA brief ([BRIEF.md](BRIEF.md#the-qa-brief)), merges its rows into the head's one QA Report (editing any existing `<!-- qa-report -->` comment in place, never posting a second), and is verified as any QA result (step 9) before the row becomes Ready to Merge. If the human asks the Chief of Staff directly for those results, it answers in one line naming the rule ([Rules](#rules)) and why, and points to this entry (naming an Executor here that has the driver), with no override even if the human insists. A row is Ready to Merge once its held items are answered, as well as its Rulings upheld. A row whose QA the human declined in the Dispatch Plan is printed with "QA declined in the Dispatch Plan", and is Ready to Merge without it.
Delete `qa-hosts.json` from the run folder, and each QA brief's copy of a host with it, so the run folder no longer holds a host the human typed; the board and the Activity Log keep only that hosts were typed and their verdicts, not the addresses. Then check each Ready to Merge row's head for a review run or comment newer than its verification ([step 7](#the-review-workflow)); a row with one goes back to step 7. Then run the [default-branch check](#the-default-branch-check) on each row still Ready to Merge; a row it takes off the list is printed with what is not on it, below. Then print the Ready to Merge list, one row per Delegation with its pull request and head, and for one that needed QA, its QA result for that head, and for one the human chose to merge as it is, that choice; then the merge order from step 8. With `routes.merge` set, print the command for each, in order. Never run it.
When the list has more than one row, each merge moves the tip under the rows after it: where the repository requires branches to be up to date, they become `BEHIND`, and where it does not, they would merge into code they were not re-gated with. So the merge order opens with: merge one at a time, and say "merged <pr>" after each, so the Chief of Staff checks the next row against the new tip before you merge it.
**Stale QA comments.** List each QA Report comment that stayed for an older head because posting was not approved: the pull request, the comment's link, the head it names and the current head. `qa-plan`'s stale edit is never made in an approved-QA run, and a post the human did not approve is a queued write, so an older comment the run left is still there. It says nothing false, since its header names its commit, but a reader may take it for the current one: the human deletes or marks it stale themselves, or posts the new report. A re-QA's approved post replaces the comment, so it is not listed.
Also print what is not on the list and why: parked Delegations, Delegations awaiting Ruling Review, Delegations `waiting` on held QA items, analysis results waiting on a decision, issues for the human, and anything raised and unanswered.
Once the list is printed, delete the heartbeat (step 6), with anything the harness file says goes with it, such as a hook's marker file and any foreground-watch `watch.gen` / `watch.pid` files, and record that on the board. Anything that sends a Delegation back to work after that, such as an overturned Ruling, arms it again.
Then one line for the harness: each **check before use** item this run settled, and what it found, so the harness file can be corrected; and, on an unlisted harness, an offer to draft a harness file from what the run learned. Writing either is a change to this skill, made only on the human's yes.
**Derive the Run Record.** Once the human has said they have merged, or the run ends without a merge, write `pull-request` for each pull request, the human's merge and close-out answers as `wait-closed` or `human-step` events (cause `by-design`), and last `run-closed` with the run's outcome. Then derive the record from the events:
```bash
node "<skill>/records.mjs" derive "<run_dir>/<run>"
```
It writes `<run_dir>/records/<run-id>.json`, outside the run folder, so pruning or deleting the folder leaves it. The safe-field check refuses a record that holds free text or a field outside the schema, and names the field: fix the events with a new event and derive again, and say in the Activity Log what was wrong. The record is local only, and every run writes it, with or without any `records` config; it leaves the machine only by the upload below. Say its path in the close-out. With a `records.sink` and `records.upload` not `never`, then **upload it** as [RUN.md](RUN.md#uploading-the-run-record) says: show the disclosure, and upload on the human's "Upload", or without asking when the Dispatch Plan's routine write "upload the Run Record" was approved. Without a `records.sink`, the record stays local and nothing is offered. **Then, only with a `records.raw.sink`, offer the raw run folder** as [RUN.md](RUN.md#uploading-the-raw-run-folder) says: after the record's line has been answered, show the raw line from `upload-raw <run>`, and upload only on the human's "Upload", at every close-out. It is never a routine write: the Dispatch Plan cannot list it, and approving the plan answers nothing about it. Without a `records.raw.sink`, nothing raw is offered. When the sink's Support Level ([SINKS.md](SINKS.md)) is below `verified`, as `gitlab` and `s3` are until a run has uploaded to them and the dashboard has read the record back (`github` is `verified`), say so after the disclosure.
**Prune old run folders, on opt-in.** With `prune.after_days` set in the config, run `node "<skill>/records.mjs" prune` once the record is derived: it deletes the closed-out run folders older than that many days, never `records/` and never an open run, and prints each one it deleted ([RUN.md](RUN.md#pruning-old-run-folders)). With no `prune` key, ask once whether to prune at 90 days, and write `prune.after_days: 90` into the config only on a yes. On a no, run `node "<skill>/records.mjs" prune --declined` and write nothing to the config: a "no" is not asked again. Do not ask when the `prune` key is there, or when `<run_dir>/prune-declined` is.
After the human says they have merged, offer a **Run Summary** on the umbrella issue the run's issues share, if they share one ([RUN.md](RUN.md#run-summary)). It is a write as the human: draft it, show it, and post it only on a yes. If parked Delegations are waiting on the merges, offer to resume the run.
**Done when:** the human has the Ready to Merge list and the merge order, and the board says where every Delegation ended.
#### The default-branch check
The default branch moves while rows wait for the human, on merges from inside the run and outside it. This check makes sure a row is still Ready to Merge against the default branch as it is now. It runs at step 10 before the list is printed, and again whenever the human comes back to the run: on `--status`, on `--resume` ([RUN.md](RUN.md#resume)), and when the human says "merged <pr>". No heartbeat is armed for it ([DESIGN.md](DESIGN.md#the-default-branch-checked-on-the-humans-return)).
It checks each row that has a pull request of its own: in a spec run on an integration branch, the `<integration>` row, since a landed ticket has none ([SPEC.md](SPEC.md#on-an-integration-branch)). First fetch, and read the default branch's current tip, `<tip>` (`git rev-parse <remote>/<default>`). Then, for each row:
1. **Its pull request:** `gh pr view <pr> --json headRefOid,mergeStateStatus`. A `headRefOid` other than the row's head is a push: handle it as step 6 says, and check nothing more on that row. `mergeStateStatus` is GitHub's own reading of the repository's rules, from a ruleset or branch protection, so nothing is guessed: `BEHIND` means the repository requires branches to be up to date and this one is not; `UNKNOWN` means GitHub has not worked it out yet, so read it again a minute later, and while it stays `UNKNOWN` the row is off the list, set back to `reported`, shown as "merge state unknown". No other value changes what this check does.
2. **The merge:** `git merge-tree --write-tree <tip> <head>`. A conflict is handled as step 8 handles one: the Delegation merges the default branch into its branch, as a Decision Request, or in an autonomous run a Ruling. That is the row's one question from this check: nothing more is checked on it.
3. **Its checks:** `gh pr checks <pr>`. A failing check, required or not, sends the row back to step 7, which holds every check on the head to green: it is `reported` again. A check still pending keeps the row off the list, set back to `reported` and shown as "checks running": step 7 verifies it again once its checks finish.
4. **The re-gate on the merge result,** when `<tip>` has moved since the board's `Default branch` line, or when the line does not name the row, at its current head, as passed at that tip (a row that failed or was taken off the list at the last check, was verified since, or has a new head since it passed), strict rule or not: two changes that each pass can fail together. Make the merge result a commit without touching any checkout (`git commit-tree <tree> -p <tip> -p <head>`, with `<tree>` from item 2), run each `regate` command on it in a detached worktree, as step 7's re-gate is run, and remove the worktree afterwards.
A row that is `BEHIND`, or whose re-gate fails, is a Decision Request, and the row is `waiting` with the request in its Decision Requests cell ([RUN.md](RUN.md#states)). It says what the check found: the row's head, `<tip>`, the `mergeStateStatus`, whether the merge is clean, and the re-gate's result with its output. Its options:
1. **Merge it as it is**, with the human's admin bypass where the repository requires branches to be up to date. The Chief of Staff never merges, so the human does. The row is Ready to Merge again, and the list says it is to be merged as it is. The choice holds for that head while later re-gates on the merge result pass; one that fails raises the request again.
2. **The Delegation merges the default branch in**: it merges `<tip>` into its own branch, in a new commit, and pushes. That is a new head: the row goes back to step 7, and any QA for the old head is `void` (step 6).
Recommend 1 when the re-gate passed (or did not need to run); otherwise 2. In an autonomous run, option 2 may be a Ruling, when the re-gate failed and the evidence meets the bar ([Autonomous runs](#autonomous-runs)); option 1 is always the human's. So a row that is `BEHIND` with a passing re-gate is a question the human keeps: it goes to them whole, queued as a question not ruled on, with option 1 listed as theirs to take and what option 2 would cost (a new head, step 7 again, QA again).
When the human says "merged <pr>", check that the pull request is merged (`gh pr view <pr> --json state`), mark its row `merged`, and run the default-branch check on each row still Ready to Merge before naming the next one in the order.
On `--status`, the check acts on nothing and writes nothing, the `Default branch` line included: it prints what it found, and `--resume` step 4, which runs the check on each `ready to merge` row against the same line, finds it again and acts on it ([RUN.md](RUN.md#status)).
A row with nothing found stays Ready to Merge. Once every row is checked, except on `--status`, rewrite the board's `Default branch` line with `<tip>` and the time, naming as passed only the rows that passed this check, each with the head it passed at, and log each row's result in the Activity Log. A row the line does not name at its current head is re-gated at its next check, whether or not the tip has moved by then.
Files in this skill
BRIEF.md24.4 KB
CONFIG.md43.4 KB
DESIGN.md53.6 KB
HARNESSES.md21.5 KB
RUN.md79.4 KB
SINKS.md5.6 KB
SKILL.md92.2 KB
SPEC.md20.7 KB
TEAM.md45.7 KB
TRACKERS.md4 KB
config.gate.test.mjs22.1 KB
config.mjs96.1 KB
fixtures/records/2026-11-17-spec-253/delegations/d255-qa/events.jsonl326 B
fixtures/records/2026-11-17-spec-253/delegations/d255-qa2/events.jsonl326 B
fixtures/records/2026-11-17-spec-253/delegations/d255/events.jsonl438 B
fixtures/records/2026-11-17-spec-253/delegations/d256-qa/events.jsonl322 B
fixtures/records/2026-11-17-spec-253/delegations/d256/events.jsonl438 B
fixtures/records/2026-11-17-spec-253/delegations/d257-qa/events.jsonl322 B
fixtures/records/2026-11-17-spec-253/delegations/d257/events.jsonl438 B