Dispatch

Orchestrate the isucon-arch-isunarabe rollout. Fires every ready subagent in its own git worktree (up to 32 in parallel), merges…

mazrean updated 2mo ago
Claude CodeGeneric
View source ↗
---
description: Orchestrate the isucon-arch-isunarabe rollout. Fires every ready subagent in its own git worktree (up to 32 in parallel), merges each successful branch back to main, and halts on the first verify failure or merge conflict.
allowed-tools: Bash, Read, Agent
---

# isucon-arch-isunarabe — Dispatcher

<background_information>
- **Source of truth for "done"**: git log trailers `Task: isucon-arch-isunarabe/<task-id>` on `main` after merge.
- **Source of truth for "task list"**: the **Tasks** section of `.claude/commands/isucon-arch-isunarabe/overview.md`.
- **Dependency rules**: the table below (re-encoded from the DAG in `overview.md` for unambiguous parsing).
- **Isolation**: each subagent runs in a fresh git worktree via `isolation: "worktree"`. Its commit lands on a per-worktree branch; the dispatcher merges that branch into `main` between rounds.
- **Concurrency**: up to **32 subagents in parallel** per round (operator box has 32 CPU cores). Bounded by the ready set size and the DAG, not by an arbitrary cap below 32.
- **Mission**: fire every subagent whose dependencies are satisfied, in parallel; merge their branches; halt on the first failure or conflict; resume cleanly on re-invoke.
</background_information>

<instructions>

## Task table (parsed by this command)

| Task ID | Subagent name | Depends on |
|---------|---------------|-----------|
| topology-env-systemd | isucon-arch-isunarabe-topology-env-systemd | – |
| topology-hosts | isucon-arch-isunarabe-topology-hosts | – |
| topology-nginx | isucon-arch-isunarabe-topology-nginx | – |
| topology-db-remote | isucon-arch-isunarabe-topology-db-remote | – |
| topology-app-pool | isucon-arch-isunarabe-topology-app-pool | – |
| schema-indexes | isucon-arch-isunarabe-schema-indexes | topology-db-remote |
| cache-impl | isucon-arch-isunarabe-cache-impl | schema-indexes |
| endpoint-1-me-join | isucon-arch-isunarabe-endpoint-1-me-join | schema-indexes, cache-impl |
| endpoint-2-list | isucon-arch-isunarabe-endpoint-2-list | schema-indexes, cache-impl, endpoint-1-me-join |
| endpoint-3-image-detail | isucon-arch-isunarabe-endpoint-3-image-detail | schema-indexes, cache-impl, endpoint-2-list |
| endpoint-cache-consumers | isucon-arch-isunarabe-endpoint-cache-consumers | cache-impl, endpoint-3-image-detail |
| deploy-reboot-test | isucon-arch-isunarabe-deploy-reboot-test | topology-env-systemd, topology-hosts, topology-nginx, topology-db-remote, topology-app-pool, schema-indexes, cache-impl, endpoint-1-me-join, endpoint-2-list, endpoint-3-image-detail, endpoint-cache-consumers |

## Execution Steps

1. **Snapshot state.** Confirm `main` is the current branch, working tree clean (`git status --porcelain` empty). For every task ID in the table, run:
   `git log main --grep="Task: isucon-arch-isunarabe/<task-id>" --oneline | head -1`.
   A non-empty line means the task is `done`. Empty means `pending`.
2. **Cross-check overview.** Read `.claude/commands/isucon-arch-isunarabe/overview.md` and confirm every `done` task is `- [x]` and every `pending` task is `- [ ]`. If a row disagrees, halt and report the drift — do not fire any subagent.
3. **Compute ready set.** A task is `ready` if it is `pending` AND every dependency in its `Depends on` column is `done`.
4. **If ready set is empty AND there are pending tasks**: report which parent is blocking each pending task and stop. (Indicates a previous failure that has not been resolved.)
5. **If ready set is empty AND all tasks are done**: report "Rollout complete. Final score check pending — re-run benchmarker and/or `make -C ansible maji`." and stop.
6. **Cap to 32.** Take the first 32 of the ready set in the task-table order. The remainder waits for the next round. (No realistic round in this DAG approaches 32; the cap is a ceiling.)
7. **Fire ready tasks in parallel.** Send a single message containing one `Agent` tool call per chosen task, with:
   - `subagent_type`: the task's subagent name (e.g. `isucon-arch-isunarabe-endpoint-1-me-join`).
   - `description`: the task's short title (≤ 5 words).
   - `prompt`: "Run task <task-id> for isucon-arch-isunarabe. Follow the subagent's instructions verbatim. Do not invoke other tasks. The working tree you see is a fresh worktree off `main`; commit on the worktree's current branch."
   - **`isolation: "worktree"`** — required. Each subagent gets its own worktree off `main`.
8. **Wait for all firings to return.** Each subagent commits atomically on its worktree's branch. The `Task:` trailer is on that branch's tip commit, not yet on `main`.
9. **Merge successful branches into `main`.** For each subagent that returned a non-empty branch (changes were committed):

   ```bash
   git merge --no-ff --no-edit <branch>

Process branches in DAG-topological order. Among siblings of one round, any order works. On merge conflict, halt — do not attempt automatic resolution. Report the conflicting files and the two branches involved. 10. Detect failures. For every task that was fired but did NOT return a branch with a Task: isucon-arch-isunarabe/<task-id> trailer on its tip commit, report it as failed and halt. Do not fire dependents of a failed task. (A failed subagent's worktree may have been auto-cleaned because no commits landed; verify with git worktree list.) 11. Re-snapshot (step 1). 12. Loop. Re-evaluate ready set (step 3). Re-fire (step 7). Continue until ready set is empty.

Halt-and-resume semantics

  • Halting on failure is the default. The user reads the failed subagent's transcript, fixes the underlying issue (or edits the apply-skill and re-runs writing-isucon-arch-subagent-tasks), then re-invokes /isucon-arch-isunarabe/dispatch.
  • The dispatcher is idempotent: a task whose commit already exists on main is treated as done and not re-fired. The merge step is idempotent for the same reason — re-running fast-forwards or skips.
  • The dispatcher never edits the overview checklist — only subagents do. Drif

Maintain Dispatch?

Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.

[Dispatch on getagentictools](https://getagentictools.com/loops/mazrean-isucon-arch-isunarabe-dispatcher?ref=badge)
npx agentictools info loops/mazrean-isucon-arch-isunarabe-dispatcher

The second line is the CLI lookup for this page — handy in READMEs and docs.