@lifeaitools/rdc-skills 0.25.2 → 0.25.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/.claude-plugin/plugin.json +1560 -1560
  2. package/.github/workflows/self-test.yml +34 -34
  3. package/CHANGELOG.md +322 -322
  4. package/MANIFEST.md +224 -224
  5. package/README.md +379 -379
  6. package/RELEASE.md +49 -0
  7. package/commands/build.md +181 -181
  8. package/commands/collab.md +180 -180
  9. package/commands/deploy.md +148 -148
  10. package/commands/fixit.md +150 -150
  11. package/commands/handoff.md +173 -173
  12. package/commands/overnight.md +220 -220
  13. package/commands/plan.md +158 -158
  14. package/commands/preplan.md +131 -131
  15. package/commands/prototype.md +145 -145
  16. package/commands/report.md +99 -99
  17. package/commands/review.md +120 -120
  18. package/commands/status.md +86 -86
  19. package/commands/workitems.md +127 -127
  20. package/git-sha.json +1 -1
  21. package/guides/agent-bootstrap.md +195 -195
  22. package/guides/agents/backend.md +102 -102
  23. package/guides/agents/content.md +94 -94
  24. package/guides/agents/cs2.md +56 -56
  25. package/guides/agents/data.md +86 -86
  26. package/guides/agents/design.md +77 -77
  27. package/guides/agents/frontend.md +91 -91
  28. package/guides/agents/infrastructure.md +81 -81
  29. package/guides/agents/setup.md +272 -272
  30. package/guides/agents/verify.md +119 -119
  31. package/guides/agents/viz.md +106 -106
  32. package/package.json +57 -57
  33. package/scripts/install-rdc-skills.js +1401 -1401
  34. package/scripts/self-test.mjs +1460 -1460
  35. package/scripts/validate-publish-manifests.js +502 -502
  36. package/skills/build/SKILL.md +559 -559
  37. package/skills/channel-formatter/SKILL.md +538 -538
  38. package/skills/collab/SKILL.md +239 -239
  39. package/skills/convert/SKILL.md +167 -167
  40. package/skills/deploy/SKILL.md +541 -541
  41. package/skills/design/SKILL.md +205 -205
  42. package/skills/env/SKILL.md +139 -141
  43. package/skills/fixit/SKILL.md +203 -203
  44. package/skills/handoff/SKILL.md +236 -236
  45. package/skills/housekeeping/SKILL.md +1 -1
  46. package/skills/onramp/SKILL.md +1459 -1459
  47. package/skills/overnight/SKILL.md +251 -251
  48. package/skills/plan/SKILL.md +345 -345
  49. package/skills/preplan/SKILL.md +90 -90
  50. package/skills/prototype/SKILL.md +150 -150
  51. package/skills/regen-media/SKILL.md +94 -94
  52. package/skills/release/SKILL.md +140 -140
  53. package/skills/report/SKILL.md +100 -100
  54. package/skills/review/SKILL.md +151 -151
  55. package/skills/self-test/SKILL.md +108 -108
  56. package/skills/status/SKILL.md +99 -99
  57. package/skills/tests/MATRIX.md +55 -55
  58. package/skills/tests/onramp.test.json +87 -87
  59. package/skills/tests/rdc-regen-media.test.json +29 -29
  60. package/skills/watch/SKILL.md +84 -84
  61. package/skills/workitems/SKILL.md +151 -151
@@ -1,428 +1,428 @@
1
- ---
2
- name: rdc:build
3
- description: "Usage `rdc:build <epic-id>` — You have a planned epic with tasks ready to execute. Dispatches parallel typed agents, each commits atomically to develop, runs a mandatory per-wave code-review gate (pr-review-toolkit:code-reviewer), closes work items, and runs the validator gate. Call after rdc:plan or when told to build."
4
- ---
5
-
6
- > **⚠️ OUTPUT CONTRACT (READ FIRST):** `guides/output-contract.md`
7
- > Checklist-only output. No tool-call narration. No raw MCP/JSON/log dumps.
8
- > One checklist upfront, updated in place, shown again at end with a 1-line verdict.
9
-
10
- > **Sandbox contract:** This skill honors `RDC_TEST=1` per `guides/agent-bootstrap.md` § RDC_TEST Sandbox Contract. Destructive external calls short-circuit under the flag.
11
-
12
-
13
- # rdc:build — Typed Agent Dispatch Engine
14
-
15
- ## When to Use
16
- - Plan is approved and ready to execute
17
- - Project lead says "build it", "go", "execute", "do not stop"
18
- - An epic exists with child tasks ready for implementation
19
- - Called by `rdc:overnight` as part of the automated build loop
20
-
21
- ## Arguments
22
- - `rdc:build <epic-id>` — build from a specific Supabase epic
23
- - `rdc:build <topic>` — find the epic by label/title match
24
- - `rdc:build` (no args) — show open epics and ask which to build (interactive only)
25
- - `rdc:build <epic-id> --unattended` — silent mode for overnight builds
26
-
27
- ## Agent Types & Guide Files
28
-
29
- Every dispatched agent MUST read two files before starting — in this order:
30
- 1. `{PROJECT_ROOT}/.rdc/guides/agent-bootstrap.md` — credentials, git rules, completion report format
31
- (fallback: `.rdc/guides/agent-bootstrap.md` relative to cwd if `{PROJECT_ROOT}` is not substituted)
32
- 2. `{PROJECT_ROOT}/.rdc/guides/engineering-behavior.md` — assumptions, minimal changes, surgical scope, verification evidence
33
- (fallback: `.rdc/guides/engineering-behavior.md` relative to cwd if `{PROJECT_ROOT}` is not substituted)
34
- 3. `{PROJECT_ROOT}/.rdc/guides/<type>.md` — role-specific guide
35
- (fallback: `.rdc/guides/<type>.md` relative to cwd if `{PROJECT_ROOT}` is not substituted)
36
-
37
- Include both lines in every agent prompt:
38
- ```
39
- "Read {PROJECT_ROOT}/.rdc/guides/agent-bootstrap.md first (fallback: .rdc/guides/agent-bootstrap.md), then {PROJECT_ROOT}/.rdc/guides/engineering-behavior.md (fallback: .rdc/guides/engineering-behavior.md), then {PROJECT_ROOT}/.rdc/guides/<type>.md (fallback: .rdc/guides/<type>.md) before starting."
40
- ```
41
-
42
- | Agent Type | Guide File | When to dispatch |
43
- |-----------|-----------|-----------------|
44
- | `frontend` | `.rdc/guides/frontend.md` | React components, pages, UI, Tailwind, animation |
45
- | `backend` | `.rdc/guides/backend.md` | API routes, server components, database queries, auth |
46
- | `data` | `.rdc/guides/data.md` | Migrations, schema changes, RPC functions |
47
- | `design` | `.rdc/guides/design.md` | Visual design, brand palettes, OG images, token work |
48
- | `infra` | `.rdc/guides/infrastructure.md` | CI/CD, deployment, DNS, SSL |
49
- | `content` | `.rdc/guides/content.md` | Marketing copy, messaging, tone |
50
- | `cs2` | `.rdc/guides/cs2.md` | CS 2.0 paradigm work (generic) |
51
- | `hail` | `.rdc/guides/cs2.md` + `packages/hail/CLAUDE.md` | Grammar, DSL compiler, evolution |
52
- | `pal` | `.rdc/guides/cs2.md` + `packages/pal/CLAUDE.md` | Sessions, moment windows, graph memory |
53
- | `bpmn` | `.rdc/guides/cs2.md` + `docs/systems/<domain>/flowable-bpmn-architecture.md` | BPMN flows, governance |
54
- | `virtue` | `.rdc/guides/cs2.md` + `packages/virtue-engine/CLAUDE.md` | Virtue weights, coherence, certification |
55
- | `viz` | `.rdc/guides/frontend.md` + `.rdc/guides/design.md` | Custom viz components, charts, diagrams |
56
-
57
- ### How to classify a task → agent type
58
-
59
- Read the task title and description, then:
60
- - Mentions React, component, page, UI, Tailwind → `frontend`
61
- - Mentions API route, server, database query, auth → `backend`
62
- - Mentions migration, schema, table, RPC → `data`
63
- - Mentions brand, palette, typography, OG image → `design`
64
- - Mentions deploy, infrastructure, CI, DNS → `infra`
65
- - Mentions copy, messaging, email template → `content`
66
- - Mentions grammar, DSL, compiler → `hail`
67
- - Mentions session, moment, memory graph → `pal`
68
- - Mentions BPMN, flow, governance → `bpmn`
69
- - Mentions virtue, coherence, certification → `virtue`
70
- - Mentions visualization, chart, diagram, SVG → `viz`
71
- - Multiple types? Dispatch multiple agents, each with its guide.
72
-
73
- ## Procedure
74
-
75
- 1. **Load the epic and run pre-flight gate:**
76
- ```sql
77
- SELECT get_work_items_by_epic('<epic-id>', 'todo');
78
- ```
79
-
80
- **Session lock — claim the epic immediately (before any agent dispatch):**
81
-
82
- After loading the epic, check its status:
83
- - If `status = 'in_progress'` → **ABORT** with:
84
- ```
85
- SKIP: epic <id> is already in_progress — claimed by another session. Pick a different epic.
86
- ```
87
- Do NOT proceed. Do NOT dispatch any agents.
88
- - If `status = 'todo'` or `status = 'blocked'` → immediately claim it:
89
- ```sql
90
- SELECT update_work_item_status('<epic-id>'::uuid, 'in_progress',
91
- '["Claimed by build session — dispatching agents"]'::jsonb
92
- );
93
- ```
94
- This is an atomic Supabase write. A concurrent session that loads the same epic after this point will see `in_progress` and abort. **Do this before any classification, planning, or agent dispatch.**
95
-
96
- **Pre-flight gate — run after claiming:**
97
-
98
- | Condition | Action |
99
- |-----------|--------|
100
- | No child tasks returned | → Invoke `rdc:plan` on this epic. Do NOT proceed with build. |
101
- | Tasks exist but all have empty `description` fields | → Invoke `rdc:plan` on this epic. Tasks without descriptions cannot be safely dispatched. |
102
- | Plan doc missing `## Checklist Decomposition Matrix` | → Invoke `rdc:plan` on this epic. Do NOT dispatch agents. |
103
- | Plan doc missing `## Checklist Quality Gate` with `verdict: PASS` | → Invoke `rdc:plan` on this epic. Do NOT dispatch agents. |
104
- | Any implementation task lacks `decomp-*` items, has < 10 attested rows, or leaves a declared surface (screen/api/db/tool) uncovered | → Invoke `rdc:plan` on this epic. Coarse/under-decomposed checklists cannot be safely dispatched. |
105
- | Any `decomp-*` item lacks route/file, action, expected result, or evidence artifact | → Invoke `rdc:plan` on this epic. Do NOT dispatch agents. |
106
- | Tasks exist and have descriptions | → Continue with build. |
107
-
108
- **Re-planning is not a failure — it is correct behavior.** The build skill is the last gate before agent dispatch; catching an under-specified epic here is cheaper than a wasted agent run.
109
-
110
- **How to re-plan:**
111
- - Interactive: tell the user — "Epic has no tasks / tasks lack descriptions — invoking rdc:plan first." Then invoke `rdc:plan <epic-id>`.
112
- - Unattended: invoke `rdc:plan <epic-id> --unattended` inline, wait for it to complete, then reload tasks and re-run this gate once. If tasks still missing after re-plan, escalate via advisor.
113
-
114
- **Interactive (no args):** show open epics, ask which to build.
115
-
116
- 2. **CHECK FOR EXISTING WORK (mandatory — never skip):**
117
- ```sql
118
- -- Check if prototypes exist from earlier sessions
119
- SELECT name, component, source_path, status, notes
120
- FROM prototype_registry
121
- WHERE status IN ('prototype', 'converting')
122
- ORDER BY created_at DESC;
123
-
124
- -- Check for design decisions on this topic
125
- SELECT topic, context_type, summary, source
126
- FROM design_context
127
- WHERE topic ILIKE '%<epic-topic>%'
128
- ORDER BY created_at DESC;
129
- ```
130
- **If a prototype exists: ADAPT IT. Do not build from scratch.**
131
- Tell the agent: "Read <source_path> first and convert it to the production contract."
132
-
133
- **If design decisions exist: follow them.** Include the summary in the agent prompt.
134
-
135
- 3. **Load the plan** (mandatory): check `.rdc/plans/` for matching topic (fallback: `.rdc/plans/`).
136
-
137
- 3b. **Checklist decomposition quality gate (mandatory before code):**
138
-
139
- `rdc:build` is the final gate before implementation. It MUST reject any plan or work item that is too coarse for an agent to execute and verify independently.
140
-
141
- Required plan sections:
142
- - `## Checklist Decomposition Matrix`
143
- - `## Checklist Quality Gate`
144
- - `verdict: PASS`
145
-
146
- Required task checklist shape:
147
- - Every implementation work item has >= 10 attested `decomp-*`/`test-*` rows and meets the
148
- per-surface completeness floors from rdc:plan (each declared surface covered; a multi-surface
149
- WP carries the SUM of its surface floors, typically 12-20). A flat 5-6-row checklist for a
150
- feature WP is REJECTED — reopen the epic to rdc:plan for full surface-area decomposition.
151
- - Every implementation work item has at least one `decomp-*` checklist row and one `test-*` checklist row.
152
- - Every `decomp-*` row names a concrete route or file path.
153
- - Every `decomp-*` row names one user/agent action.
154
- - Every `decomp-*` row names one expected UI/API/DB result.
155
- - Every `decomp-*` row names one verification artifact: test name, route probe, Playwright screenshot, SQL query, API response, type-check, migration proof, or CLI transcript.
156
-
157
- Atomicity rubric:
158
- - One observable behavior per `decomp-*` row.
159
- - The row can pass or fail without reading hidden intent from the plan narrative.
160
- - The row is small enough for a worker to implement, tick, and cite evidence for directly.
161
- - Vague rows such as "theme management works", "UI implemented", "verified", "all screens", or "integration complete" are failures.
162
-
163
- Minimum decomposition heuristics:
164
- - UI route: at least empty/loading/loaded/error or the documented reason a state does not apply.
165
- - CRUD surface: at least list, create, edit, detail, duplicate/delete/archive where applicable, and validation failure.
166
- - API route: at least successful read/write, validation failure, and unauthorized/forbidden or documented auth bypass.
167
- - DB/migration task: at least schema object, relationship/guard, policy/permission, seed/fixture or backfill, and smoke query.
168
- - Editor/sidebar/CLI workflow: at least start, attach/open, enqueue action, observe result, timeout/error, and live refresh where applicable.
169
-
170
- HARD FLOOR (mirrors rdc:plan): every implementation task carries >= 10 attested rows; a
171
- multi-surface WP carries the SUM of its per-surface floors (typically 12-20). A flat 5-6-row
172
- feature checklist, or any declared surface (screen/api/db/tool) left uncovered, is a REJECT —
173
- reopen to rdc:plan. Every row must name its surface + one verification artifact (attested).
174
-
175
- ### ⛔ Deliverable / acceptance check-off table — show BEFORE any implementation
176
- Before dispatching the first wave, render a deliverable/acceptance table and
177
- keep it visible through the build (lesson 2026-06-16-build-poor-goal-execution-mdk-brain:
178
- a build satisfied generic checklist rows — tsc clean, route 200 — while never
179
- touching the surface the user actually named, because no row anchored the
180
- user's TARGET SURFACE). The table MUST contain:
181
- - **One mandatory row for the user-named TARGET SURFACE** — the exact screen,
182
- endpoint, file, or behavior the user asked for, by name. Its acceptance check
183
- is what proves THAT surface renders/works, not a proxy.
184
- - **At least one NEGATIVE verifier row** — a check that proves the WRONG thing
185
- does NOT happen (e.g. "mock data is NOT rendered", "old route returns 404",
186
- "stub component is absent from the bundle"). A positive-only suite passes
187
- even when the deliverable is wired to the wrong source.
188
-
189
- | Deliverable | Target surface? | Acceptance check | Negative verifier | Status |
190
- |---|---|---|---|---|
191
-
192
- **Gating rule:** any work item whose deliverable maps to the TARGET SURFACE row
193
- stays in `review` (never `done`) until that target-surface acceptance check
194
- passes. Generic gates (tsc, route 200) clearing is NOT sufficient to advance
195
- the target-surface item.
196
-
197
- If the gate fails:
198
- - Interactive: show the failing rows and invoke `rdc:plan <epic-id>` to repair the matrix before dispatch.
199
- - Unattended: invoke `rdc:plan <epic-id> --unattended`, reload tasks, and run this gate once more.
200
- - If the second gate fails, abort the build and return the failure list. Do not dispatch implementation agents.
201
-
202
- **Plan verifier escalation:** A separate verifier agent is optional, not default. Dispatch one only when the plan touches 5+ UI routes, 3+ data/API boundaries, auth/security, production deployment, or when this rubric fails twice. The verifier reads the plan and work-item checklists only; it does not write code.
203
-
204
- 4. **Read CLAUDE.md files** for all affected packages.
205
-
206
- 5. **Classify each task** → assign agent type from the table above.
207
-
208
- 5b. **Write or refresh the checklist into every work item before dispatching:**
209
- For each task, append the exact `decomp-*` and `test-*` checklist rows to its notes BEFORE setting to `in_progress`:
210
- ```sql
211
- SELECT update_work_item_status('<id>'::uuid, 'in_progress',
212
- '["CHECKLIST: [ ] decomp-ui-route-state: <route/file> | action=<action> | expect=<result> | evidence=<artifact>, [ ] test-smoke-route: <route probe>, [ ] committed"]'::jsonb
213
- );
214
- ```
215
- The agent must complete every item on this checklist and return it checked off in AGENT_COMPLETE.
216
- A checklist with unchecked items = incomplete work. Do not proceed to next wave with unchecked items.
217
-
218
- 6. **Group tasks into waves** — parallelize tasks with no file overlap:
219
- - Wave 1: independent tasks (different packages/files)
220
- - Wave 2: tasks that depend on Wave 1 outputs
221
- - Wave 3: integration tasks
222
-
223
- 7. **For each wave — dispatch typed agents in parallel:**
224
-
225
- ### ⛔ Agent Dispatch Non-Negotiable Defaults
226
- Every `Agent()` call MUST include these parameters:
227
- ```
228
- model: <chosen per the routing table below>
229
- max_turns: 70
230
- ```
231
- `isolation` is chosen per the dispatch-mode rule below — it is NOT a blanket
232
- default. Worktree isolation is reserved for true parallel MULTI-committer waves
233
- in the same repo; doc-only and single-committer waves default to NON-isolated.
234
-
235
- ### ⛔ Dispatch mode — non-isolated is the default for single-committer / doc-only waves
236
- Worktree isolation exists to protect a SHARED working tree from a git-index race
237
- between MULTIPLE agents committing in parallel. When there is only ONE committer,
238
- that race cannot occur, and the stale-base hazard of worktrees (see the HARD GATE
239
- below — recurring across 2026-06-10/11/15/16/17/23) is pure downside. Pick the
240
- dispatch mode by committer count, not by reflex:
241
-
242
- | Wave shape | Dispatch mode | isolation |
243
- |---|---|---|
244
- | **Doc-only wave** (markdown/docs/plans, no code build) | NON-isolated, one committer on `develop` | omit `isolation` |
245
- | **Single-committer wave** (only one agent commits, or work serializes to the supervisor) | NON-isolated, one committer on `develop` | omit `isolation` |
246
- | **True parallel MULTI-committer wave** (2+ agents committing concurrently in the same repo, disjoint files) | worktree-isolated, supervisor merges | `isolation: "worktree"` |
247
-
248
- - **Default = NON-isolated.** Only escalate to `isolation: "worktree"` when the
249
- wave genuinely has 2+ concurrent committers in the same repo.
250
- - A pure docs wave is single-committer by default: either dispatch ONE doc agent,
251
- or have parallel doc agents return diffs/patches that the supervisor commits
252
- serially. Do NOT fan out 2+ concurrent committers onto one shared `develop`
253
- tree (lesson 2026-06-13-build-concurrent-agents-same-branch-git-race: three
254
- parallel doc agents on one `develop` tree raced on the git index/stash — one
255
- commit swept in another agent's staged-but-uncommitted files under the wrong
256
- message, two agents reported the SAME SHA, a pre-commit `sync:docs` ref-lock
257
- race misattributed authorship). The fix for that race is single-committer
258
- serialization, NOT blanket worktree isolation.
259
- - When you DO need a true MULTI-committer parallel wave, worktree isolation is
260
- mandatory AND the HARD GATE below (base == develop HEAD) MUST pass before
261
- dispatch — a stale-base worktree wave is a build failure, not a warning.
262
-
263
- ### ⛔ Foreign concurrent session guard — `git status` BEFORE the build
264
- Worktree isolation protects against THIS build's own agents, not against a
265
- DIFFERENT session (another cell, a Codex run, a human) already committing on
266
- the same shared tree (lesson 2026-06-16-build-concurrent-session-shared-tree-commit-corruption:
267
- a foreign session's staged-but-uncommitted files were swept into this build's
268
- commit under the wrong message). Before dispatching any wave, run `git status`
269
- to detect foreign-dirty files you did not create. If foreign-dirty files are
270
- present: do NOT fan out concurrent committers — **serialize ALL committers to
271
- the supervisor** (agents return diffs/patches; the supervisor stages and
272
- commits each one alone). After every supervisor commit, assert the exact file
273
- set landed and nothing foreign leaked in:
274
- ```bash
275
- git show --stat <sha> # confirm ONLY the files this commit owns are listed
276
- ```
277
- A `git show --stat` that lists a file the agent did not touch = a foreign file
278
- leaked into the commit; reset and re-stage by explicit path.
279
-
280
- **Agent model routing — pick per task, not per wave.** The supervisor session model does NOT cascade to agents; you must set `model` explicitly on every dispatch.
281
-
282
- | Task character | Model | When to pick it |
283
- |---|---|---|
284
- | Updates, edits, mechanical refactors, small fixes, content tweaks, config patches, doc/copy edits, straightforward API wiring | `claude-sonnet-4-6` | Default for `frontend.md`/`content.md`/`infrastructure.md` work whose checklist is mostly "change X to Y" or "wire up endpoint Z". Budget-safe for parallel dispatch. |
285
- | Harder coding tasks — non-trivial algorithm, migration with backfill, schema reshape, multi-file refactor with subtle invariants, performance-sensitive code, anything where correctness is the bar | `claude-opus-4-6` | Default for `backend.md`/`data.md` work and any `frontend.md` task that involves state machines, race conditions, or cross-package contracts. |
286
- | Design or innovative thought — new component design, brand/UX work, CS 2.0 paradigm work (HAIL/Quad Pixel/AEMG/Virtue), grammar evolution, architecture-first design, anything where the *shape* of the solution is the deliverable rather than the implementation | `claude-opus-4-8` | Default for `design.md`/`cs2.md` work. Also use for `backend.md`/`data.md` tasks tagged with `architecture` or `design-decision` in work item labels. |
287
-
288
- **How to choose when the task straddles categories:**
289
- - If the task's checklist contains the word "design", "decide", "propose", "evaluate alternatives", "novel", or any CS 2.0 primitive → **Opus 4.8**.
290
- - If the task touches `packages/cs2*`, `packages/hail`, `packages/quad-pixel`, `packages/virtue-engine`, `packages/aemg`, `packages/planetary-ontology`, or `packages/being-state-processor` → **Opus 4.8** (CS 2.0 paradigm requires innovative thought, not transcription).
291
- - If the task is a Supabase migration that drops/renames/reshapes anything, or a refactor across ≥5 files → **Opus 4.6**.
292
- - Otherwise → **Sonnet 4.6**.
293
-
294
- **State the choice in the wave plan.** Before dispatching a wave, the supervisor must log one line per agent in the form `[wave-N agent-K] role=<role> task=<id> model=<chosen> reason=<one phrase>`. This keeps routing decisions reviewable in the transcript and lets `rdc:report` summarize the fleet mix.
295
-
296
- **Cost guardrail.** If a single wave would dispatch more than 3 Opus 4.8 agents in parallel, downshift the lowest-priority Opus-4.8 tasks to Opus 4.6 unless their work items are tagged `priority=urgent`. Opus 4.8 fast-mode is cheap individually but still ~5× a Sonnet agent at scale.
297
- Without `max_turns: 70`, agents hit the default turn cap mid-task and stop.
298
- `isolation: "worktree"` gives each agent its own git worktree and branch — eliminates push race conditions and index lock contention when multiple agents commit in parallel. The supervisor merges worktree branches after each wave (Step 9).
299
-
300
- ### ✅ PREVENTION FIRST — create worktrees fresh off origin/develop (kills stale-base by construction)
301
- The repeated stale-base failures below come from creating worktrees off a
302
- local/old ref. Eliminate the failure mode at the source: ALWAYS create agent
303
- worktrees with a fresh fetch + `origin/develop` base, e.g.
304
- `git fetch origin develop && git worktree add <dir> -b <branch> origin/develop`
305
- — or use the canonical launcher `node scripts/wt.mjs add <name>`, which does
306
- exactly that. A worktree cut from `origin/develop` HEAD **cannot** be stale.
307
- The HARD GATE below remains as the blocking backstop (detection), but
308
- construction-from-`origin/develop` is the primary defense.
309
-
310
- ### ⛔ HARD GATE — Worktree base MUST equal develop HEAD (blocking, not advisory)
311
- The worktree-isolation harness has shipped worktrees pinned to a STALE base
312
- commit (lessons 2026-06-10-build-worktree-stale-base, 2026-06-11-build-worktree-stale-base,
313
- 2026-06-15-build-worktree-stale-base, 2026-06-16-build-worktree-stale-base,
314
- 2026-06-17-build-worktree-stale-base, 2026-06-23-build-worktree-stale-base:
315
- agents branched hundreds of commits / multiple days behind develop HEAD, on a
316
- tree where the target app did not yet exist — their diffs would have silently
317
- reverted merged work or operated on a deleted structure). This is a recurring
318
- harness defect, so the check is a **HARD BLOCKING GATE, not a suggestion.**
319
-
320
- **Before dispatching ANY `isolation:"worktree"` wave**, the supervisor MUST run
321
- the base==HEAD assertion and MUST abort isolation on any mismatch — there is no
322
- "proceed anyway" path:
323
- ```bash
324
- DEV_HEAD=$(git rev-parse develop)
325
- # After worktrees are created, for each agent worktree:
326
- git worktree list # compare each agent worktree's SHA to $DEV_HEAD
327
- # If ANY worktree base != $DEV_HEAD (it is behind), the wave is UNSAFE — ABORT.
328
- ```
329
- - **MANDATORY ABORT:** if ANY worktree base != `$DEV_HEAD`, you MUST abort
330
- isolation for this wave. Do NOT merge stale worktree output. Do NOT "fast-forward
331
- and continue". Do NOT proceed with the isolated wave under any circumstance.
332
- Pivot to **sequential, non-isolated dispatch on a real `develop` checkout**
333
- (one disjoint WP at a time to avoid `.git/index` races; the supervisor pushes) —
334
- the same reason the validator runs non-isolated (it must see merged develop).
335
- - This gate is blocking by design: an isolated wave dispatched on a stale base
336
- is treated as a build failure, not a warning. Skipping or downgrading this
337
- assertion to advisory is a contract violation.
338
- - Also at every merge: `git show <branch>:<key-file> | grep -c <symbol-a-prior-wave-introduced>`
339
- — a 0 where there should be ≥1 means the branch is stale or deleted a shared
340
- export; resolve to `--ours` and re-apply that wave's real delta on current HEAD.
341
- esbuild/tsc PASS is necessary, not sufficient — pair it with a grep gate on
342
- the symbols a refactor must preserve.
343
-
344
- ### Forked agents vs. standalone agents
345
-
346
- **When the supervisor has already read the plan** (via a prior `Read` tool call in the same session),
347
- dispatch **forked agents** with short prompts. Forked agents inherit the full conversation context —
348
- including every file the supervisor has read — so you do NOT need to copy plan sections, file specs,
349
- or architecture details into the prompt. The agent already sees them.
350
-
351
- Short forked prompt template:
352
- ```
353
- You are a frontend agent building <WP name>. Work item: <uuid>.
354
- Scope: <one sentence>. Files: <list>. Verification: tsc --noEmit.
355
- Set item to review when done, return AGENT_COMPLETE with verification evidence.
356
- Read .rdc/guides/agent-bootstrap.md + .rdc/guides/engineering-behavior.md + .rdc/guides/frontend.md before starting.
357
- ```
358
-
359
- **When the supervisor has NOT read the plan** (e.g. dispatching from a fresh `rdc:build` call with
360
- only an epic ID), the agent has no plan context — write a full briefing prompt with all specs.
361
-
362
- ### ⛔ Reuse contract — when a WP builds on an existing subsystem
363
- When a work package extends an existing subsystem, "compose adapter + X"
364
- under-specifies reuse and lets an agent legitimately re-author markup/logic the
365
- subsystem already exposes (lesson 2026-06-11-build-reuse-existing-engine-prompt:
366
- an agent set up to reinvent a grid when the card engine already shipped four
367
- `CardLayout` display types + a full `parseCommand → CardSpec → adapter → CardModel[]`
368
- calling sequence). The dispatch prompt MUST:
369
- 1. **Enumerate the existing public API the agent must reuse, BY FILE** — types/enums
370
- (`packages/.../types.ts:NN`), calling-sequence functions, AND the existing
371
- display/render components — not just the data adapter.
372
- 2. **Mark which seams are extend/delegate-only.** State explicitly: "thread a
373
- pass-through prop (e.g. `layout`) to the existing components; do NOT
374
- reimplement layout/render." Verify at WP review that the agent reused the
375
- named parser/adapter/components and did not hand-roll a parallel implementation.
376
-
377
- ---
378
-
379
- ### Required agent prompt contents
380
- - Set work item to `in_progress` before dispatching
381
- - Each agent prompt MUST include:
382
- - `"Read {PROJECT_ROOT}/.rdc/guides/agent-bootstrap.md first (fallback: .rdc/guides/agent-bootstrap.md), then {PROJECT_ROOT}/.rdc/guides/<type>.md (fallback: .rdc/guides/<type>.md) before starting."`
383
- - `"Read {PROJECT_ROOT}/.rdc/guides/engineering-behavior.md (fallback: .rdc/guides/engineering-behavior.md) before editing; follow it for assumptions, minimal changes, surgical scope, evidence, and escalation."`
384
- - Specific files to create/modify (or omit if forked agent inherits plan context)
385
- - Exact deliverables and commit message
386
- - `"NEVER run pnpm build/test. NEVER modify files outside your scope."`
387
- - **`"You are running in an isolated git worktree. Commit your work normally. Do NOT push to origin — the supervisor merges your branch after the wave completes."`**
388
- - **`"When done, set your work item to 'review' (NOT 'done') and return AGENT_COMPLETE with a verification field. The validator closes work items — you do not."`**
389
- - **`"COMPLETION PROOF REQUIRED in AGENT_COMPLETE: list every file written, the exact commit hash, and paste the vitest/tsc output. A report without this evidence will be rejected."`**
390
- - **`"If you find that a file or feature already exists: you MUST still verify it satisfies the full task spec before marking review. Finding a file is not completion. Run verification, check every requirement, and report what you found vs. what was required."`**
391
- - **The decomposition items from the work item's checklist** (all `decomp-*` prefixed items). Include them verbatim in the prompt and instruct the agent:
392
- ```
393
- DECOMPOSITION CHECKLIST — you MUST implement/verify each row and tick it immediately via update_checklist_item(..., p_actor_session_id := '<your-session-id>', p_actor_role := 'agent'):
394
- - decomp-ui-xxx: <route/file> | action=<action> | expect=<result> | evidence=<artifact>
395
- - decomp-api-xxx: <route/file> | action=<action> | expect=<result> | evidence=<artifact>
396
- Tick each item as soon as that specific behavior is implemented and proven. Do NOT batch.
397
- ```
398
- - **The test plan items from the work item's checklist** (all `test-*` prefixed items). Include them verbatim in the prompt and instruct the agent:
399
- ```
400
- TEST PLAN — you MUST implement/verify each of these and tick them off via update_checklist_item(..., p_actor_session_id := '<your-session-id>', p_actor_role := 'agent'):
401
- - test-assert-xxx: <description> → write a vitest test that proves this
402
- - test-smoke-xxx: <description> → run the command and confirm the result
403
- - test-visual-xxx: <description> → note: delegate to UI audit (you cannot verify this yourself)
404
- - test-contract-xxx: <description> → verify the export/type/shape exists
405
- Tick each item as you complete it. Do NOT batch — tick immediately after each verification.
406
- ```
407
- - Use `run_in_background: true` for parallel execution
408
- - NEVER let agents overlap on the same files
409
-
410
- ### ⛔ Agent Definition-of-Done additions (include in every prompt)
411
- - **Declare every import in the package's OWN package.json.** Every import an
412
- agent adds MUST be present in that package's own `package.json`
413
- dependencies/devDependencies — never rely on monorepo-hoisted deps. A pnpm
414
- worktree can import a root-hoisted dep (e.g. `vitest`,
415
- `@supabase/supabase-js`) so `tsc`/`vitest` PASS in the worktree, then `tsc`
416
- FAILS on a clean develop checkout after merge (lesson
417
- 2026-06-10-build-card-engine-agent-deps). Agent prompt line: *"Verify that
418
- every import you add is declared in this package's own package.json — do not
419
- rely on hoisted monorepo deps."*
1
+ ---
2
+ name: rdc:build
3
+ description: "Usage `rdc:build <epic-id>` — You have a planned epic with tasks ready to execute. Dispatches parallel typed agents, each commits atomically to develop, runs a mandatory per-wave code-review gate (pr-review-toolkit:code-reviewer), closes work items, and runs the validator gate. Call after rdc:plan or when told to build."
4
+ ---
5
+
6
+ > **⚠️ OUTPUT CONTRACT (READ FIRST):** `guides/output-contract.md`
7
+ > Checklist-only output. No tool-call narration. No raw MCP/JSON/log dumps.
8
+ > One checklist upfront, updated in place, shown again at end with a 1-line verdict.
9
+
10
+ > **Sandbox contract:** This skill honors `RDC_TEST=1` per `guides/agent-bootstrap.md` § RDC_TEST Sandbox Contract. Destructive external calls short-circuit under the flag.
11
+
12
+
13
+ # rdc:build — Typed Agent Dispatch Engine
14
+
15
+ ## When to Use
16
+ - Plan is approved and ready to execute
17
+ - Project lead says "build it", "go", "execute", "do not stop"
18
+ - An epic exists with child tasks ready for implementation
19
+ - Called by `rdc:overnight` as part of the automated build loop
20
+
21
+ ## Arguments
22
+ - `rdc:build <epic-id>` — build from a specific Supabase epic
23
+ - `rdc:build <topic>` — find the epic by label/title match
24
+ - `rdc:build` (no args) — show open epics and ask which to build (interactive only)
25
+ - `rdc:build <epic-id> --unattended` — silent mode for overnight builds
26
+
27
+ ## Agent Types & Guide Files
28
+
29
+ Every dispatched agent MUST read two files before starting — in this order:
30
+ 1. `{PROJECT_ROOT}/.rdc/guides/agent-bootstrap.md` — credentials, git rules, completion report format
31
+ (fallback: `.rdc/guides/agent-bootstrap.md` relative to cwd if `{PROJECT_ROOT}` is not substituted)
32
+ 2. `{PROJECT_ROOT}/.rdc/guides/engineering-behavior.md` — assumptions, minimal changes, surgical scope, verification evidence
33
+ (fallback: `.rdc/guides/engineering-behavior.md` relative to cwd if `{PROJECT_ROOT}` is not substituted)
34
+ 3. `{PROJECT_ROOT}/.rdc/guides/<type>.md` — role-specific guide
35
+ (fallback: `.rdc/guides/<type>.md` relative to cwd if `{PROJECT_ROOT}` is not substituted)
36
+
37
+ Include both lines in every agent prompt:
38
+ ```
39
+ "Read {PROJECT_ROOT}/.rdc/guides/agent-bootstrap.md first (fallback: .rdc/guides/agent-bootstrap.md), then {PROJECT_ROOT}/.rdc/guides/engineering-behavior.md (fallback: .rdc/guides/engineering-behavior.md), then {PROJECT_ROOT}/.rdc/guides/<type>.md (fallback: .rdc/guides/<type>.md) before starting."
40
+ ```
41
+
42
+ | Agent Type | Guide File | When to dispatch |
43
+ |-----------|-----------|-----------------|
44
+ | `frontend` | `.rdc/guides/frontend.md` | React components, pages, UI, Tailwind, animation |
45
+ | `backend` | `.rdc/guides/backend.md` | API routes, server components, database queries, auth |
46
+ | `data` | `.rdc/guides/data.md` | Migrations, schema changes, RPC functions |
47
+ | `design` | `.rdc/guides/design.md` | Visual design, brand palettes, OG images, token work |
48
+ | `infra` | `.rdc/guides/infrastructure.md` | CI/CD, deployment, DNS, SSL |
49
+ | `content` | `.rdc/guides/content.md` | Marketing copy, messaging, tone |
50
+ | `cs2` | `.rdc/guides/cs2.md` | CS 2.0 paradigm work (generic) |
51
+ | `hail` | `.rdc/guides/cs2.md` + `packages/hail/CLAUDE.md` | Grammar, DSL compiler, evolution |
52
+ | `pal` | `.rdc/guides/cs2.md` + `packages/pal/CLAUDE.md` | Sessions, moment windows, graph memory |
53
+ | `bpmn` | `.rdc/guides/cs2.md` + `docs/systems/<domain>/flowable-bpmn-architecture.md` | BPMN flows, governance |
54
+ | `virtue` | `.rdc/guides/cs2.md` + `packages/virtue-engine/CLAUDE.md` | Virtue weights, coherence, certification |
55
+ | `viz` | `.rdc/guides/frontend.md` + `.rdc/guides/design.md` | Custom viz components, charts, diagrams |
56
+
57
+ ### How to classify a task → agent type
58
+
59
+ Read the task title and description, then:
60
+ - Mentions React, component, page, UI, Tailwind → `frontend`
61
+ - Mentions API route, server, database query, auth → `backend`
62
+ - Mentions migration, schema, table, RPC → `data`
63
+ - Mentions brand, palette, typography, OG image → `design`
64
+ - Mentions deploy, infrastructure, CI, DNS → `infra`
65
+ - Mentions copy, messaging, email template → `content`
66
+ - Mentions grammar, DSL, compiler → `hail`
67
+ - Mentions session, moment, memory graph → `pal`
68
+ - Mentions BPMN, flow, governance → `bpmn`
69
+ - Mentions virtue, coherence, certification → `virtue`
70
+ - Mentions visualization, chart, diagram, SVG → `viz`
71
+ - Multiple types? Dispatch multiple agents, each with its guide.
72
+
73
+ ## Procedure
74
+
75
+ 1. **Load the epic and run pre-flight gate:**
76
+ ```sql
77
+ SELECT get_work_items_by_epic('<epic-id>', 'todo');
78
+ ```
79
+
80
+ **Session lock — claim the epic immediately (before any agent dispatch):**
81
+
82
+ After loading the epic, check its status:
83
+ - If `status = 'in_progress'` → **ABORT** with:
84
+ ```
85
+ SKIP: epic <id> is already in_progress — claimed by another session. Pick a different epic.
86
+ ```
87
+ Do NOT proceed. Do NOT dispatch any agents.
88
+ - If `status = 'todo'` or `status = 'blocked'` → immediately claim it:
89
+ ```sql
90
+ SELECT update_work_item_status('<epic-id>'::uuid, 'in_progress',
91
+ '["Claimed by build session — dispatching agents"]'::jsonb
92
+ );
93
+ ```
94
+ This is an atomic Supabase write. A concurrent session that loads the same epic after this point will see `in_progress` and abort. **Do this before any classification, planning, or agent dispatch.**
95
+
96
+ **Pre-flight gate — run after claiming:**
97
+
98
+ | Condition | Action |
99
+ |-----------|--------|
100
+ | No child tasks returned | → Invoke `rdc:plan` on this epic. Do NOT proceed with build. |
101
+ | Tasks exist but all have empty `description` fields | → Invoke `rdc:plan` on this epic. Tasks without descriptions cannot be safely dispatched. |
102
+ | Plan doc missing `## Checklist Decomposition Matrix` | → Invoke `rdc:plan` on this epic. Do NOT dispatch agents. |
103
+ | Plan doc missing `## Checklist Quality Gate` with `verdict: PASS` | → Invoke `rdc:plan` on this epic. Do NOT dispatch agents. |
104
+ | Any implementation task lacks `decomp-*` items, has < 10 attested rows, or leaves a declared surface (screen/api/db/tool) uncovered | → Invoke `rdc:plan` on this epic. Coarse/under-decomposed checklists cannot be safely dispatched. |
105
+ | Any `decomp-*` item lacks route/file, action, expected result, or evidence artifact | → Invoke `rdc:plan` on this epic. Do NOT dispatch agents. |
106
+ | Tasks exist and have descriptions | → Continue with build. |
107
+
108
+ **Re-planning is not a failure — it is correct behavior.** The build skill is the last gate before agent dispatch; catching an under-specified epic here is cheaper than a wasted agent run.
109
+
110
+ **How to re-plan:**
111
+ - Interactive: tell the user — "Epic has no tasks / tasks lack descriptions — invoking rdc:plan first." Then invoke `rdc:plan <epic-id>`.
112
+ - Unattended: invoke `rdc:plan <epic-id> --unattended` inline, wait for it to complete, then reload tasks and re-run this gate once. If tasks still missing after re-plan, escalate via advisor.
113
+
114
+ **Interactive (no args):** show open epics, ask which to build.
115
+
116
+ 2. **CHECK FOR EXISTING WORK (mandatory — never skip):**
117
+ ```sql
118
+ -- Check if prototypes exist from earlier sessions
119
+ SELECT name, component, source_path, status, notes
120
+ FROM prototype_registry
121
+ WHERE status IN ('prototype', 'converting')
122
+ ORDER BY created_at DESC;
123
+
124
+ -- Check for design decisions on this topic
125
+ SELECT topic, context_type, summary, source
126
+ FROM design_context
127
+ WHERE topic ILIKE '%<epic-topic>%'
128
+ ORDER BY created_at DESC;
129
+ ```
130
+ **If a prototype exists: ADAPT IT. Do not build from scratch.**
131
+ Tell the agent: "Read <source_path> first and convert it to the production contract."
132
+
133
+ **If design decisions exist: follow them.** Include the summary in the agent prompt.
134
+
135
+ 3. **Load the plan** (mandatory): check `.rdc/plans/` for matching topic (fallback: `.rdc/plans/`).
136
+
137
+ 3b. **Checklist decomposition quality gate (mandatory before code):**
138
+
139
+ `rdc:build` is the final gate before implementation. It MUST reject any plan or work item that is too coarse for an agent to execute and verify independently.
140
+
141
+ Required plan sections:
142
+ - `## Checklist Decomposition Matrix`
143
+ - `## Checklist Quality Gate`
144
+ - `verdict: PASS`
145
+
146
+ Required task checklist shape:
147
+ - Every implementation work item has >= 10 attested `decomp-*`/`test-*` rows and meets the
148
+ per-surface completeness floors from rdc:plan (each declared surface covered; a multi-surface
149
+ WP carries the SUM of its surface floors, typically 12-20). A flat 5-6-row checklist for a
150
+ feature WP is REJECTED — reopen the epic to rdc:plan for full surface-area decomposition.
151
+ - Every implementation work item has at least one `decomp-*` checklist row and one `test-*` checklist row.
152
+ - Every `decomp-*` row names a concrete route or file path.
153
+ - Every `decomp-*` row names one user/agent action.
154
+ - Every `decomp-*` row names one expected UI/API/DB result.
155
+ - Every `decomp-*` row names one verification artifact: test name, route probe, Playwright screenshot, SQL query, API response, type-check, migration proof, or CLI transcript.
156
+
157
+ Atomicity rubric:
158
+ - One observable behavior per `decomp-*` row.
159
+ - The row can pass or fail without reading hidden intent from the plan narrative.
160
+ - The row is small enough for a worker to implement, tick, and cite evidence for directly.
161
+ - Vague rows such as "theme management works", "UI implemented", "verified", "all screens", or "integration complete" are failures.
162
+
163
+ Minimum decomposition heuristics:
164
+ - UI route: at least empty/loading/loaded/error or the documented reason a state does not apply.
165
+ - CRUD surface: at least list, create, edit, detail, duplicate/delete/archive where applicable, and validation failure.
166
+ - API route: at least successful read/write, validation failure, and unauthorized/forbidden or documented auth bypass.
167
+ - DB/migration task: at least schema object, relationship/guard, policy/permission, seed/fixture or backfill, and smoke query.
168
+ - Editor/sidebar/CLI workflow: at least start, attach/open, enqueue action, observe result, timeout/error, and live refresh where applicable.
169
+
170
+ HARD FLOOR (mirrors rdc:plan): every implementation task carries >= 10 attested rows; a
171
+ multi-surface WP carries the SUM of its per-surface floors (typically 12-20). A flat 5-6-row
172
+ feature checklist, or any declared surface (screen/api/db/tool) left uncovered, is a REJECT —
173
+ reopen to rdc:plan. Every row must name its surface + one verification artifact (attested).
174
+
175
+ ### ⛔ Deliverable / acceptance check-off table — show BEFORE any implementation
176
+ Before dispatching the first wave, render a deliverable/acceptance table and
177
+ keep it visible through the build (lesson 2026-06-16-build-poor-goal-execution-mdk-brain:
178
+ a build satisfied generic checklist rows — tsc clean, route 200 — while never
179
+ touching the surface the user actually named, because no row anchored the
180
+ user's TARGET SURFACE). The table MUST contain:
181
+ - **One mandatory row for the user-named TARGET SURFACE** — the exact screen,
182
+ endpoint, file, or behavior the user asked for, by name. Its acceptance check
183
+ is what proves THAT surface renders/works, not a proxy.
184
+ - **At least one NEGATIVE verifier row** — a check that proves the WRONG thing
185
+ does NOT happen (e.g. "mock data is NOT rendered", "old route returns 404",
186
+ "stub component is absent from the bundle"). A positive-only suite passes
187
+ even when the deliverable is wired to the wrong source.
188
+
189
+ | Deliverable | Target surface? | Acceptance check | Negative verifier | Status |
190
+ |---|---|---|---|---|
191
+
192
+ **Gating rule:** any work item whose deliverable maps to the TARGET SURFACE row
193
+ stays in `review` (never `done`) until that target-surface acceptance check
194
+ passes. Generic gates (tsc, route 200) clearing is NOT sufficient to advance
195
+ the target-surface item.
196
+
197
+ If the gate fails:
198
+ - Interactive: show the failing rows and invoke `rdc:plan <epic-id>` to repair the matrix before dispatch.
199
+ - Unattended: invoke `rdc:plan <epic-id> --unattended`, reload tasks, and run this gate once more.
200
+ - If the second gate fails, abort the build and return the failure list. Do not dispatch implementation agents.
201
+
202
+ **Plan verifier escalation:** A separate verifier agent is optional, not default. Dispatch one only when the plan touches 5+ UI routes, 3+ data/API boundaries, auth/security, production deployment, or when this rubric fails twice. The verifier reads the plan and work-item checklists only; it does not write code.
203
+
204
+ 4. **Read CLAUDE.md files** for all affected packages.
205
+
206
+ 5. **Classify each task** → assign agent type from the table above.
207
+
208
+ 5b. **Write or refresh the checklist into every work item before dispatching:**
209
+ For each task, append the exact `decomp-*` and `test-*` checklist rows to its notes BEFORE setting to `in_progress`:
210
+ ```sql
211
+ SELECT update_work_item_status('<id>'::uuid, 'in_progress',
212
+ '["CHECKLIST: [ ] decomp-ui-route-state: <route/file> | action=<action> | expect=<result> | evidence=<artifact>, [ ] test-smoke-route: <route probe>, [ ] committed"]'::jsonb
213
+ );
214
+ ```
215
+ The agent must complete every item on this checklist and return it checked off in AGENT_COMPLETE.
216
+ A checklist with unchecked items = incomplete work. Do not proceed to next wave with unchecked items.
217
+
218
+ 6. **Group tasks into waves** — parallelize tasks with no file overlap:
219
+ - Wave 1: independent tasks (different packages/files)
220
+ - Wave 2: tasks that depend on Wave 1 outputs
221
+ - Wave 3: integration tasks
222
+
223
+ 7. **For each wave — dispatch typed agents in parallel:**
224
+
225
+ ### ⛔ Agent Dispatch Non-Negotiable Defaults
226
+ Every `Agent()` call MUST include these parameters:
227
+ ```
228
+ model: <chosen per the routing table below>
229
+ max_turns: 70
230
+ ```
231
+ `isolation` is chosen per the dispatch-mode rule below — it is NOT a blanket
232
+ default. Worktree isolation is reserved for true parallel MULTI-committer waves
233
+ in the same repo; doc-only and single-committer waves default to NON-isolated.
234
+
235
+ ### ⛔ Dispatch mode — non-isolated is the default for single-committer / doc-only waves
236
+ Worktree isolation exists to protect a SHARED working tree from a git-index race
237
+ between MULTIPLE agents committing in parallel. When there is only ONE committer,
238
+ that race cannot occur, and the stale-base hazard of worktrees (see the HARD GATE
239
+ below — recurring across 2026-06-10/11/15/16/17/23) is pure downside. Pick the
240
+ dispatch mode by committer count, not by reflex:
241
+
242
+ | Wave shape | Dispatch mode | isolation |
243
+ |---|---|---|
244
+ | **Doc-only wave** (markdown/docs/plans, no code build) | NON-isolated, one committer on `develop` | omit `isolation` |
245
+ | **Single-committer wave** (only one agent commits, or work serializes to the supervisor) | NON-isolated, one committer on `develop` | omit `isolation` |
246
+ | **True parallel MULTI-committer wave** (2+ agents committing concurrently in the same repo, disjoint files) | worktree-isolated, supervisor merges | `isolation: "worktree"` |
247
+
248
+ - **Default = NON-isolated.** Only escalate to `isolation: "worktree"` when the
249
+ wave genuinely has 2+ concurrent committers in the same repo.
250
+ - A pure docs wave is single-committer by default: either dispatch ONE doc agent,
251
+ or have parallel doc agents return diffs/patches that the supervisor commits
252
+ serially. Do NOT fan out 2+ concurrent committers onto one shared `develop`
253
+ tree (lesson 2026-06-13-build-concurrent-agents-same-branch-git-race: three
254
+ parallel doc agents on one `develop` tree raced on the git index/stash — one
255
+ commit swept in another agent's staged-but-uncommitted files under the wrong
256
+ message, two agents reported the SAME SHA, a pre-commit `sync:docs` ref-lock
257
+ race misattributed authorship). The fix for that race is single-committer
258
+ serialization, NOT blanket worktree isolation.
259
+ - When you DO need a true MULTI-committer parallel wave, worktree isolation is
260
+ mandatory AND the HARD GATE below (base == develop HEAD) MUST pass before
261
+ dispatch — a stale-base worktree wave is a build failure, not a warning.
262
+
263
+ ### ⛔ Foreign concurrent session guard — `git status` BEFORE the build
264
+ Worktree isolation protects against THIS build's own agents, not against a
265
+ DIFFERENT session (another cell, a Codex run, a human) already committing on
266
+ the same shared tree (lesson 2026-06-16-build-concurrent-session-shared-tree-commit-corruption:
267
+ a foreign session's staged-but-uncommitted files were swept into this build's
268
+ commit under the wrong message). Before dispatching any wave, run `git status`
269
+ to detect foreign-dirty files you did not create. If foreign-dirty files are
270
+ present: do NOT fan out concurrent committers — **serialize ALL committers to
271
+ the supervisor** (agents return diffs/patches; the supervisor stages and
272
+ commits each one alone). After every supervisor commit, assert the exact file
273
+ set landed and nothing foreign leaked in:
274
+ ```bash
275
+ git show --stat <sha> # confirm ONLY the files this commit owns are listed
276
+ ```
277
+ A `git show --stat` that lists a file the agent did not touch = a foreign file
278
+ leaked into the commit; reset and re-stage by explicit path.
279
+
280
+ **Agent model routing — pick per task, not per wave.** The supervisor session model does NOT cascade to agents; you must set `model` explicitly on every dispatch.
281
+
282
+ | Task character | Model | When to pick it |
283
+ |---|---|---|
284
+ | Updates, edits, mechanical refactors, small fixes, content tweaks, config patches, doc/copy edits, straightforward API wiring | `claude-sonnet-5` | Default for `frontend.md`/`content.md`/`infrastructure.md` work whose checklist is mostly "change X to Y" or "wire up endpoint Z". Budget-safe for parallel dispatch. |
285
+ | Harder coding tasks — non-trivial algorithm, migration with backfill, schema reshape, multi-file refactor with subtle invariants, performance-sensitive code, anything where correctness is the bar | `claude-opus-5` | Default for `backend.md`/`data.md` work and any `frontend.md` task that involves state machines, race conditions, or cross-package contracts. |
286
+ | Design or innovative thought — new component design, brand/UX work, CS 2.0 paradigm work (HAIL/Quad Pixel/AEMG/Virtue), grammar evolution, architecture-first design, anything where the *shape* of the solution is the deliverable rather than the implementation | `claude-opus-5` | Default for `design.md`/`cs2.md` work. Also use for `backend.md`/`data.md` tasks tagged with `architecture` or `design-decision` in work item labels. |
287
+
288
+ **How to choose when the task straddles categories:**
289
+ - If the task's checklist contains the word "design", "decide", "propose", "evaluate alternatives", "novel", or any CS 2.0 primitive → **Opus 5**.
290
+ - If the task touches `packages/cs2*`, `packages/hail`, `packages/quad-pixel`, `packages/virtue-engine`, `packages/aemg`, `packages/planetary-ontology`, or `packages/being-state-processor` → **Opus 5** (CS 2.0 paradigm requires innovative thought, not transcription).
291
+ - If the task is a Supabase migration that drops/renames/reshapes anything, or a refactor across ≥5 files → **Opus 5**.
292
+ - Otherwise → **Sonnet 5**.
293
+
294
+ **State the choice in the wave plan.** Before dispatching a wave, the supervisor must log one line per agent in the form `[wave-N agent-K] role=<role> task=<id> model=<chosen> reason=<one phrase>`. This keeps routing decisions reviewable in the transcript and lets `rdc:report` summarize the fleet mix.
295
+
296
+ **Cost guardrail.** If a single wave would dispatch more than 3 Opus 5 agents in parallel, downshift the lowest-priority Opus 5 tasks to Sonnet 5 unless their work items are tagged `priority=urgent`. Opus 5 is cheap individually but still ~2× a Sonnet 5 agent at scale.
297
+ Without `max_turns: 70`, agents hit the default turn cap mid-task and stop.
298
+ `isolation: "worktree"` gives each agent its own git worktree and branch — eliminates push race conditions and index lock contention when multiple agents commit in parallel. The supervisor merges worktree branches after each wave (Step 9).
299
+
300
+ ### ✅ PREVENTION FIRST — create worktrees fresh off origin/develop (kills stale-base by construction)
301
+ The repeated stale-base failures below come from creating worktrees off a
302
+ local/old ref. Eliminate the failure mode at the source: ALWAYS create agent
303
+ worktrees with a fresh fetch + `origin/develop` base, e.g.
304
+ `git fetch origin develop && git worktree add <dir> -b <branch> origin/develop`
305
+ — or use the canonical launcher `node scripts/wt.mjs add <name>`, which does
306
+ exactly that. A worktree cut from `origin/develop` HEAD **cannot** be stale.
307
+ The HARD GATE below remains as the blocking backstop (detection), but
308
+ construction-from-`origin/develop` is the primary defense.
309
+
310
+ ### ⛔ HARD GATE — Worktree base MUST equal develop HEAD (blocking, not advisory)
311
+ The worktree-isolation harness has shipped worktrees pinned to a STALE base
312
+ commit (lessons 2026-06-10-build-worktree-stale-base, 2026-06-11-build-worktree-stale-base,
313
+ 2026-06-15-build-worktree-stale-base, 2026-06-16-build-worktree-stale-base,
314
+ 2026-06-17-build-worktree-stale-base, 2026-06-23-build-worktree-stale-base:
315
+ agents branched hundreds of commits / multiple days behind develop HEAD, on a
316
+ tree where the target app did not yet exist — their diffs would have silently
317
+ reverted merged work or operated on a deleted structure). This is a recurring
318
+ harness defect, so the check is a **HARD BLOCKING GATE, not a suggestion.**
319
+
320
+ **Before dispatching ANY `isolation:"worktree"` wave**, the supervisor MUST run
321
+ the base==HEAD assertion and MUST abort isolation on any mismatch — there is no
322
+ "proceed anyway" path:
323
+ ```bash
324
+ DEV_HEAD=$(git rev-parse develop)
325
+ # After worktrees are created, for each agent worktree:
326
+ git worktree list # compare each agent worktree's SHA to $DEV_HEAD
327
+ # If ANY worktree base != $DEV_HEAD (it is behind), the wave is UNSAFE — ABORT.
328
+ ```
329
+ - **MANDATORY ABORT:** if ANY worktree base != `$DEV_HEAD`, you MUST abort
330
+ isolation for this wave. Do NOT merge stale worktree output. Do NOT "fast-forward
331
+ and continue". Do NOT proceed with the isolated wave under any circumstance.
332
+ Pivot to **sequential, non-isolated dispatch on a real `develop` checkout**
333
+ (one disjoint WP at a time to avoid `.git/index` races; the supervisor pushes) —
334
+ the same reason the validator runs non-isolated (it must see merged develop).
335
+ - This gate is blocking by design: an isolated wave dispatched on a stale base
336
+ is treated as a build failure, not a warning. Skipping or downgrading this
337
+ assertion to advisory is a contract violation.
338
+ - Also at every merge: `git show <branch>:<key-file> | grep -c <symbol-a-prior-wave-introduced>`
339
+ — a 0 where there should be ≥1 means the branch is stale or deleted a shared
340
+ export; resolve to `--ours` and re-apply that wave's real delta on current HEAD.
341
+ esbuild/tsc PASS is necessary, not sufficient — pair it with a grep gate on
342
+ the symbols a refactor must preserve.
343
+
344
+ ### Forked agents vs. standalone agents
345
+
346
+ **When the supervisor has already read the plan** (via a prior `Read` tool call in the same session),
347
+ dispatch **forked agents** with short prompts. Forked agents inherit the full conversation context —
348
+ including every file the supervisor has read — so you do NOT need to copy plan sections, file specs,
349
+ or architecture details into the prompt. The agent already sees them.
350
+
351
+ Short forked prompt template:
352
+ ```
353
+ You are a frontend agent building <WP name>. Work item: <uuid>.
354
+ Scope: <one sentence>. Files: <list>. Verification: tsc --noEmit.
355
+ Set item to review when done, return AGENT_COMPLETE with verification evidence.
356
+ Read .rdc/guides/agent-bootstrap.md + .rdc/guides/engineering-behavior.md + .rdc/guides/frontend.md before starting.
357
+ ```
358
+
359
+ **When the supervisor has NOT read the plan** (e.g. dispatching from a fresh `rdc:build` call with
360
+ only an epic ID), the agent has no plan context — write a full briefing prompt with all specs.
361
+
362
+ ### ⛔ Reuse contract — when a WP builds on an existing subsystem
363
+ When a work package extends an existing subsystem, "compose adapter + X"
364
+ under-specifies reuse and lets an agent legitimately re-author markup/logic the
365
+ subsystem already exposes (lesson 2026-06-11-build-reuse-existing-engine-prompt:
366
+ an agent set up to reinvent a grid when the card engine already shipped four
367
+ `CardLayout` display types + a full `parseCommand → CardSpec → adapter → CardModel[]`
368
+ calling sequence). The dispatch prompt MUST:
369
+ 1. **Enumerate the existing public API the agent must reuse, BY FILE** — types/enums
370
+ (`packages/.../types.ts:NN`), calling-sequence functions, AND the existing
371
+ display/render components — not just the data adapter.
372
+ 2. **Mark which seams are extend/delegate-only.** State explicitly: "thread a
373
+ pass-through prop (e.g. `layout`) to the existing components; do NOT
374
+ reimplement layout/render." Verify at WP review that the agent reused the
375
+ named parser/adapter/components and did not hand-roll a parallel implementation.
376
+
377
+ ---
378
+
379
+ ### Required agent prompt contents
380
+ - Set work item to `in_progress` before dispatching
381
+ - Each agent prompt MUST include:
382
+ - `"Read {PROJECT_ROOT}/.rdc/guides/agent-bootstrap.md first (fallback: .rdc/guides/agent-bootstrap.md), then {PROJECT_ROOT}/.rdc/guides/<type>.md (fallback: .rdc/guides/<type>.md) before starting."`
383
+ - `"Read {PROJECT_ROOT}/.rdc/guides/engineering-behavior.md (fallback: .rdc/guides/engineering-behavior.md) before editing; follow it for assumptions, minimal changes, surgical scope, evidence, and escalation."`
384
+ - Specific files to create/modify (or omit if forked agent inherits plan context)
385
+ - Exact deliverables and commit message
386
+ - `"NEVER run pnpm build/test. NEVER modify files outside your scope."`
387
+ - **`"You are running in an isolated git worktree. Commit your work normally. Do NOT push to origin — the supervisor merges your branch after the wave completes."`**
388
+ - **`"When done, set your work item to 'review' (NOT 'done') and return AGENT_COMPLETE with a verification field. The validator closes work items — you do not."`**
389
+ - **`"COMPLETION PROOF REQUIRED in AGENT_COMPLETE: list every file written, the exact commit hash, and paste the vitest/tsc output. A report without this evidence will be rejected."`**
390
+ - **`"If you find that a file or feature already exists: you MUST still verify it satisfies the full task spec before marking review. Finding a file is not completion. Run verification, check every requirement, and report what you found vs. what was required."`**
391
+ - **The decomposition items from the work item's checklist** (all `decomp-*` prefixed items). Include them verbatim in the prompt and instruct the agent:
392
+ ```
393
+ DECOMPOSITION CHECKLIST — you MUST implement/verify each row and tick it immediately via update_checklist_item(..., p_actor_session_id := '<your-session-id>', p_actor_role := 'agent'):
394
+ - decomp-ui-xxx: <route/file> | action=<action> | expect=<result> | evidence=<artifact>
395
+ - decomp-api-xxx: <route/file> | action=<action> | expect=<result> | evidence=<artifact>
396
+ Tick each item as soon as that specific behavior is implemented and proven. Do NOT batch.
397
+ ```
398
+ - **The test plan items from the work item's checklist** (all `test-*` prefixed items). Include them verbatim in the prompt and instruct the agent:
399
+ ```
400
+ TEST PLAN — you MUST implement/verify each of these and tick them off via update_checklist_item(..., p_actor_session_id := '<your-session-id>', p_actor_role := 'agent'):
401
+ - test-assert-xxx: <description> → write a vitest test that proves this
402
+ - test-smoke-xxx: <description> → run the command and confirm the result
403
+ - test-visual-xxx: <description> → note: delegate to UI audit (you cannot verify this yourself)
404
+ - test-contract-xxx: <description> → verify the export/type/shape exists
405
+ Tick each item as you complete it. Do NOT batch — tick immediately after each verification.
406
+ ```
407
+ - Use `run_in_background: true` for parallel execution
408
+ - NEVER let agents overlap on the same files
409
+
410
+ ### ⛔ Agent Definition-of-Done additions (include in every prompt)
411
+ - **Declare every import in the package's OWN package.json.** Every import an
412
+ agent adds MUST be present in that package's own `package.json`
413
+ dependencies/devDependencies — never rely on monorepo-hoisted deps. A pnpm
414
+ worktree can import a root-hoisted dep (e.g. `vitest`,
415
+ `@supabase/supabase-js`) so `tsc`/`vitest` PASS in the worktree, then `tsc`
416
+ FAILS on a clean develop checkout after merge (lesson
417
+ 2026-06-10-build-card-engine-agent-deps). Agent prompt line: *"Verify that
418
+ every import you add is declared in this package's own package.json — do not
419
+ rely on hoisted monorepo deps."*
420
420
  - **A server/MCP/API task is NOT done without a committed automated test that
421
- ships in the SAME commit and exercises EVERY surface.** Manual curl / a single
422
- `/health` 200 is a proxy, not coverage (lesson 2026-06-10-build-weak-dod-no-tests).
423
- For a collection (MCP skills, API routes, CLI commands): loop over ALL items
424
- and assert `output == source` — never a single spot check. Wire an npm script
425
- and run it green before the item leaves `review`. Agent prompt line: *"This
421
+ ships in the SAME commit and exercises EVERY surface.** Manual curl / a single
422
+ `/health` 200 is a proxy, not coverage (lesson 2026-06-10-build-weak-dod-no-tests).
423
+ For a collection (MCP skills, API routes, CLI commands): loop over ALL items
424
+ and assert `output == source` — never a single spot check. Wire an npm script
425
+ and run it green before the item leaves `review`. Agent prompt line: *"This
426
426
  task is not done until a committed test in the same commit exercises every
427
427
  surface; for collections, loop all items and assert output == source."*
428
428
  - **Durable workflow E2E gate (hard):** A task that creates a queue/job,
@@ -436,143 +436,143 @@ Read the task title and description, then:
436
436
  construction, or a `/health` probe cannot substitute. If no safe disposable
437
437
  environment exists, create one within the work package; do not waive this
438
438
  gate or mark the item reviewable.
439
-
440
- 8. **Post-wave test gate (mandatory):**
441
- After all agents in a wave complete, before proceeding:
442
- ```bash
443
- # For each package modified in this wave:
444
- cd packages/<name> && npx vitest run 2>&1 | tail -20
445
- ```
446
- - All tests must pass before proceeding to next wave
447
- - If tests fail: fix before proceeding
448
- - NEVER use `pnpm build` or `pnpm turbo test` — vitest only per package
449
- - New code must have tests: if a modified package shows 0 new test files, flag it
450
-
451
- 9. **After all wave agents complete — merge worktrees and push:**
452
-
453
- Each completed agent returns a worktree branch (e.g. `claude/agent-frontend-abc123`). Merge them all to develop before running the test gate:
454
-
455
- ```bash
456
- # For each worktree branch returned by agents in this wave:
457
- git merge --no-ff <worktree-branch> -m "merge(<agent-type>): <task-title>"
458
- ```
459
-
460
- - Resolve any conflicts before proceeding — do not skip
461
- - Worker agents set items to `review` — **do NOT close to `done` yet**
462
- - After all branches merged, push once:
463
- ```bash
464
- if [ "$RDC_TEST" != "1" ]; then
465
- git push origin develop
466
- else
467
- echo "[RDC_TEST] skipping git push"
468
- fi
469
- ```
470
- - Then run the post-wave test gate (Step 8) on the merged state
471
- - Then run the code-review gate (Step 9b) before the next wave dispatches
472
- - Continue to next wave
473
-
474
- **If an agent fails (returns no worktree branch):**
475
- - Interactive: diagnose before retrying
476
- - Unattended: retry once; on second failure escalate via advisor
477
- ```
478
- BUILD_STATUS: { wave, tasks_done, tasks_failed, commits, escalated: true }
479
- ```
480
-
481
- 9b. **Mandatory per-wave code-review gate (runs after merge + test gate, BEFORE next wave dispatches):**
482
-
483
- ⛔ **NO wave may dispatch until the previous wave's code-review pass clears.** Memory `feedback_code_review_per_wave.md` — Davesend 2026-05-24 incident.
484
-
485
- Dispatch ONE `pr-review-toolkit:code-reviewer` agent with the wave's merged diff:
486
-
487
- ```
488
- Agent({
489
- subagent_type: "pr-review-toolkit:code-reviewer",
490
- description: "Wave <N> code review",
491
- prompt: "Review the diff `git diff <wave-base-sha>..HEAD` on develop.
492
- Focus on: bugs, logic errors, security vulnerabilities, project-convention adherence
493
- (.claude/rules/*, CLAUDE.md). Apply confidence-based filtering — high-confidence
494
- findings only. Report severity per finding: critical | high | medium | low.
495
- Return CODE_REVIEW_COMPLETE with: { critical_count, high_count, medium_count,
496
- low_count, findings: [{severity, file:line, issue, suggested_fix}] }."
497
- })
498
- ```
499
-
500
- **Severity gate (default — high+ blocks):**
501
- - `critical` or `high` findings → reopen affected work items to `todo` with finding text in notes; fix in a new wave before continuing
502
- - `medium` or `low` findings → append to each work item's `implementation_report.flags`; do NOT reopen; validator sees them
503
- - Zero findings → log `CODE_REVIEW: CLEAN` and proceed to next wave
504
-
505
- Under `RDC_TEST=1`: echo `[RDC_TEST] skipping code-review dispatch` and proceed.
506
-
507
- 10. **Mandatory validator gate (runs after ALL waves complete — before any work item closes):**
508
-
509
- ⛔ **NO work item may be set to `done` without the validator passing it.**
510
-
511
- Dispatch ONE validator agent with the complete list of `review` work items and the full git diff.
512
- ⚠️ The validator does NOT use `isolation: "worktree"` — it must read the fully merged develop branch. Omit the isolation parameter for this dispatch only.
513
-
514
- ```
515
- "Read {PROJECT_ROOT}/.rdc/guides/agent-bootstrap.md then {PROJECT_ROOT}/.rdc/guides/verify.md.
516
- Read {PROJECT_ROOT}/.rdc/guides/engineering-behavior.md before validating scope, deviations, and evidence.
517
- Validate these work items: [list of IDs and titles].
518
- Apps touched: [list].
519
- Git diff since build start: [attach or reference].
520
- You are the ONLY agent that closes work items to done.
521
- Follow verify.md procedure exactly: tsc → vitest → dev server route probes → record result per item."
522
- ```
523
-
524
- The validator:
525
- - Runs `npx tsc --noEmit` for every touched app/package
526
- - Starts the dev server and probes every modified route (expects HTTP 200, not 500)
439
+
440
+ 8. **Post-wave test gate (mandatory):**
441
+ After all agents in a wave complete, before proceeding:
442
+ ```bash
443
+ # For each package modified in this wave:
444
+ cd packages/<name> && npx vitest run 2>&1 | tail -20
445
+ ```
446
+ - All tests must pass before proceeding to next wave
447
+ - If tests fail: fix before proceeding
448
+ - NEVER use `pnpm build` or `pnpm turbo test` — vitest only per package
449
+ - New code must have tests: if a modified package shows 0 new test files, flag it
450
+
451
+ 9. **After all wave agents complete — merge worktrees and push:**
452
+
453
+ Each completed agent returns a worktree branch (e.g. `claude/agent-frontend-abc123`). Merge them all to develop before running the test gate:
454
+
455
+ ```bash
456
+ # For each worktree branch returned by agents in this wave:
457
+ git merge --no-ff <worktree-branch> -m "merge(<agent-type>): <task-title>"
458
+ ```
459
+
460
+ - Resolve any conflicts before proceeding — do not skip
461
+ - Worker agents set items to `review` — **do NOT close to `done` yet**
462
+ - After all branches merged, push once:
463
+ ```bash
464
+ if [ "$RDC_TEST" != "1" ]; then
465
+ git push origin develop
466
+ else
467
+ echo "[RDC_TEST] skipping git push"
468
+ fi
469
+ ```
470
+ - Then run the post-wave test gate (Step 8) on the merged state
471
+ - Then run the code-review gate (Step 9b) before the next wave dispatches
472
+ - Continue to next wave
473
+
474
+ **If an agent fails (returns no worktree branch):**
475
+ - Interactive: diagnose before retrying
476
+ - Unattended: retry once; on second failure escalate via advisor
477
+ ```
478
+ BUILD_STATUS: { wave, tasks_done, tasks_failed, commits, escalated: true }
479
+ ```
480
+
481
+ 9b. **Mandatory per-wave code-review gate (runs after merge + test gate, BEFORE next wave dispatches):**
482
+
483
+ ⛔ **NO wave may dispatch until the previous wave's code-review pass clears.** Memory `feedback_code_review_per_wave.md` — Davesend 2026-05-24 incident.
484
+
485
+ Dispatch ONE `pr-review-toolkit:code-reviewer` agent with the wave's merged diff:
486
+
487
+ ```
488
+ Agent({
489
+ subagent_type: "pr-review-toolkit:code-reviewer",
490
+ description: "Wave <N> code review",
491
+ prompt: "Review the diff `git diff <wave-base-sha>..HEAD` on develop.
492
+ Focus on: bugs, logic errors, security vulnerabilities, project-convention adherence
493
+ (.claude/rules/*, CLAUDE.md). Apply confidence-based filtering — high-confidence
494
+ findings only. Report severity per finding: critical | high | medium | low.
495
+ Return CODE_REVIEW_COMPLETE with: { critical_count, high_count, medium_count,
496
+ low_count, findings: [{severity, file:line, issue, suggested_fix}] }."
497
+ })
498
+ ```
499
+
500
+ **Severity gate (default — high+ blocks):**
501
+ - `critical` or `high` findings → reopen affected work items to `todo` with finding text in notes; fix in a new wave before continuing
502
+ - `medium` or `low` findings → append to each work item's `implementation_report.flags`; do NOT reopen; validator sees them
503
+ - Zero findings → log `CODE_REVIEW: CLEAN` and proceed to next wave
504
+
505
+ Under `RDC_TEST=1`: echo `[RDC_TEST] skipping code-review dispatch` and proceed.
506
+
507
+ 10. **Mandatory validator gate (runs after ALL waves complete — before any work item closes):**
508
+
509
+ ⛔ **NO work item may be set to `done` without the validator passing it.**
510
+
511
+ Dispatch ONE validator agent with the complete list of `review` work items and the full git diff.
512
+ ⚠️ The validator does NOT use `isolation: "worktree"` — it must read the fully merged develop branch. Omit the isolation parameter for this dispatch only.
513
+
514
+ ```
515
+ "Read {PROJECT_ROOT}/.rdc/guides/agent-bootstrap.md then {PROJECT_ROOT}/.rdc/guides/verify.md.
516
+ Read {PROJECT_ROOT}/.rdc/guides/engineering-behavior.md before validating scope, deviations, and evidence.
517
+ Validate these work items: [list of IDs and titles].
518
+ Apps touched: [list].
519
+ Git diff since build start: [attach or reference].
520
+ You are the ONLY agent that closes work items to done.
521
+ Follow verify.md procedure exactly: tsc → vitest → dev server route probes → record result per item."
522
+ ```
523
+
524
+ The validator:
525
+ - Runs `npx tsc --noEmit` for every touched app/package
526
+ - Starts the dev server and probes every modified route (expects HTTP 200, not 500)
527
527
  - Runs vitest for every touched package
528
528
  - For every durable workflow, runs the committed E2E harness and rejects the
529
529
  item unless its receipt proves public ingress -> queued/running -> terminal
530
530
  state, persisted outputs, and fixture cleanup on the deploy-equivalent
531
531
  runtime; an absent harness is a hard rejection.
532
- - **Verifies checklist decomposition quality per work item before functional validation:**
533
- - Every implementation work item has >= 10 attested `decomp-*`/`test-*` items, meets the per-surface completeness floors (each declared surface covered), and no feature WP ships a 5-6-row checklist
534
- - Every `decomp-*` item includes route/file, action, expected result, and evidence artifact
535
- - Any unchecked `decomp-*` item with `required: true` = work item CANNOT be set to `done`
536
- - Any coarse or non-falsifiable `decomp-*` item = reopen to `todo` with the specific failure
537
- - **Verifies test plan completion per work item:**
538
- - For each `test-assert-*` checklist item: confirm a corresponding vitest test exists and passes
539
- - For each `test-smoke-*` checklist item: run the command and confirm exit code / HTTP status
540
- - For each `test-visual-*` checklist item: note as "delegated to UI audit" (validator cannot verify visuals)
541
- - For each `test-contract-*` checklist item: verify the export/type/shape exists in the built code
542
- - Any unchecked `test-*` item with `required: true` = work item CANNOT be set to `done` (DB enforces this)
543
- - Sets passing items to `done`, failing items back to `todo` with failure detail
544
- - Returns `VALIDATOR_COMPLETE` report with test plan status per item
545
-
546
- **If the validator finds failures:** fix them in a new wave, then re-run the validator. Do not skip.
547
- **File existence alone is NOT verification.** A route returning 500 is a failure regardless of tsc passing.
548
- **Unchecked test plan items are a hard gate** — `update_work_item_status('done', ..., p_actor_role := 'validator')` will raise an exception if any `required: true` checklist item is unchecked, missing agent-session tick evidence, or re-ticked by a supervisor/validator.
549
-
550
- 11. **After verification passes:**
551
- - All wave commits are already on develop and pushed (Step 9 pushes after each wave merge).
552
- - Update epic version: `bump_epic_version()`
553
- - Report summary with verification evidence quoted
554
-
555
- ## Agent TDD Requirements
556
-
557
- When dispatching agents, include in every prompt:
558
- ```
559
- TDD REQUIREMENT: Write tests FIRST for new functions/modules.
560
- Run: npx vitest run packages/<name> to verify red → implement → verify green.
561
- NEVER run pnpm build or pnpm turbo. Use npx vitest run only.
562
- ```
563
-
564
- ## Rules
565
- - Branch: development branch only (auto-commit, no confirmation needed)
566
- - NEVER let two agents edit the same file
567
- - NEVER run `pnpm build` (crashes system) — code only
568
- - Every agent reads its guide file — no exceptions
569
- - Update Supabase work items IN REAL TIME — not batch at end
570
- - Push after each wave, not just at the end
571
- - Unattended: NEVER pause — continue automatically
572
- - Unattended: max 2 retries per task before escalating to advisor
573
- - Every Agent() dispatch: `model: <routed>` + `max_turns: 70` — non-negotiable. `isolation` is per the dispatch-mode rule in Step 7: NON-isolated (omit `isolation`) for doc-only and single-committer waves; `isolation: "worktree"` ONLY for true parallel MULTI-committer waves, and only after the HARD GATE (worktree base == develop HEAD) passes — a stale-base isolated wave is a build failure. Model is chosen per task per the routing table in Step 7: Sonnet 4.6 for updates/edits, Opus 4.6 for harder coding, Opus 4.8 for design/innovative thought (CS 2.0, brand/UX, architecture). Supervisor logs `model=<chosen> reason=<phrase>` per agent. Exception: validator agent in Step 10 always omits isolation; validator model stays `claude-sonnet-4-6` (verification, not generation).
574
- - Finding an existing file is NOT task completion — verify it satisfies the spec
575
-
576
- ## Capture lessons (exit step)
577
-
578
- Before the final verdict line, follow `.rdc/guides/lessons-learned-spec.md` § Capture procedure. If this run taught something non-obvious — a first root-cause theory that turned out wrong, the documented/standard path not working, a missing gate or check that cost a round, or a surprising tool/infra behavior — write one `.rdc/lessons/<YYYY-MM-DD>-build-<short-slug>.md` per lesson using the schema in that spec. Set `scope` (`simple` | `architectural`) and `status` (`open`, or `applied` if you shipped the fix in this same run, with the commit linked). Commit the lesson file(s) on `develop` alongside the run's other commits, and note "N lessons captured" in your verdict/summary. A run that taught nothing writes nothing — absence is the default.
532
+ - **Verifies checklist decomposition quality per work item before functional validation:**
533
+ - Every implementation work item has >= 10 attested `decomp-*`/`test-*` items, meets the per-surface completeness floors (each declared surface covered), and no feature WP ships a 5-6-row checklist
534
+ - Every `decomp-*` item includes route/file, action, expected result, and evidence artifact
535
+ - Any unchecked `decomp-*` item with `required: true` = work item CANNOT be set to `done`
536
+ - Any coarse or non-falsifiable `decomp-*` item = reopen to `todo` with the specific failure
537
+ - **Verifies test plan completion per work item:**
538
+ - For each `test-assert-*` checklist item: confirm a corresponding vitest test exists and passes
539
+ - For each `test-smoke-*` checklist item: run the command and confirm exit code / HTTP status
540
+ - For each `test-visual-*` checklist item: note as "delegated to UI audit" (validator cannot verify visuals)
541
+ - For each `test-contract-*` checklist item: verify the export/type/shape exists in the built code
542
+ - Any unchecked `test-*` item with `required: true` = work item CANNOT be set to `done` (DB enforces this)
543
+ - Sets passing items to `done`, failing items back to `todo` with failure detail
544
+ - Returns `VALIDATOR_COMPLETE` report with test plan status per item
545
+
546
+ **If the validator finds failures:** fix them in a new wave, then re-run the validator. Do not skip.
547
+ **File existence alone is NOT verification.** A route returning 500 is a failure regardless of tsc passing.
548
+ **Unchecked test plan items are a hard gate** — `update_work_item_status('done', ..., p_actor_role := 'validator')` will raise an exception if any `required: true` checklist item is unchecked, missing agent-session tick evidence, or re-ticked by a supervisor/validator.
549
+
550
+ 11. **After verification passes:**
551
+ - All wave commits are already on develop and pushed (Step 9 pushes after each wave merge).
552
+ - Update epic version: `bump_epic_version()`
553
+ - Report summary with verification evidence quoted
554
+
555
+ ## Agent TDD Requirements
556
+
557
+ When dispatching agents, include in every prompt:
558
+ ```
559
+ TDD REQUIREMENT: Write tests FIRST for new functions/modules.
560
+ Run: npx vitest run packages/<name> to verify red → implement → verify green.
561
+ NEVER run pnpm build or pnpm turbo. Use npx vitest run only.
562
+ ```
563
+
564
+ ## Rules
565
+ - Branch: development branch only (auto-commit, no confirmation needed)
566
+ - NEVER let two agents edit the same file
567
+ - NEVER run `pnpm build` (crashes system) — code only
568
+ - Every agent reads its guide file — no exceptions
569
+ - Update Supabase work items IN REAL TIME — not batch at end
570
+ - Push after each wave, not just at the end
571
+ - Unattended: NEVER pause — continue automatically
572
+ - Unattended: max 2 retries per task before escalating to advisor
573
+ - Every Agent() dispatch: `model: <routed>` + `max_turns: 70` — non-negotiable. `isolation` is per the dispatch-mode rule in Step 7: NON-isolated (omit `isolation`) for doc-only and single-committer waves; `isolation: "worktree"` ONLY for true parallel MULTI-committer waves, and only after the HARD GATE (worktree base == develop HEAD) passes — a stale-base isolated wave is a build failure. Model is chosen per task per the routing table in Step 7: Sonnet 5 for updates/edits, Opus 5 for harder coding and design/innovative thought (CS 2.0, brand/UX, architecture). Supervisor logs `model=<chosen> reason=<phrase>` per agent. Exception: validator agent in Step 10 always omits isolation; validator model stays `claude-sonnet-5` (verification, not generation).
574
+ - Finding an existing file is NOT task completion — verify it satisfies the spec
575
+
576
+ ## Capture lessons (exit step)
577
+
578
+ Before the final verdict line, follow `.rdc/guides/lessons-learned-spec.md` § Capture procedure. If this run taught something non-obvious — a first root-cause theory that turned out wrong, the documented/standard path not working, a missing gate or check that cost a round, or a surprising tool/infra behavior — write one `.rdc/lessons/<YYYY-MM-DD>-build-<short-slug>.md` per lesson using the schema in that spec. Set `scope` (`simple` | `architectural`) and `status` (`open`, or `applied` if you shipped the fix in this same run, with the commit linked). Commit the lesson file(s) on `develop` alongside the run's other commits, and note "N lessons captured" in your verdict/summary. A run that taught nothing writes nothing — absence is the default.