@dirtydishes/skills 0.1.2 → 0.1.3

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 (23) hide show
  1. package/README.md +5 -5
  2. package/package.json +1 -1
  3. package/skills/dirtyloops/SKILL.md +3 -1
  4. package/skills/dirtyloops/examples/README.md +1 -1
  5. package/skills/dirtyloops/examples/orchestrator-callback/README.md +3 -3
  6. package/skills/dirtyloops/examples/orchestrator-callback/docs/implementation/example-stream/IMPLEMENT.md +18 -1
  7. package/skills/dirtyloops/examples/orchestrator-callback/docs/implementation/example-stream/prompts/closeout-selector-subagent.md +33 -0
  8. package/skills/dirtyloops/examples/orchestrator-callback/docs/implementation/example-stream/prompts/run-loop.md +6 -3
  9. package/skills/dirtyloops/examples/orchestrator-callback/docs/implementation/example-stream/prompts/selector-subagent.md +28 -0
  10. package/skills/dirtyloops/examples/orchestrator-callback/docs/implementation/example-stream/turn-docs/01-foundation.md +4 -2
  11. package/skills/dirtyloops/plan.html +9 -5
  12. package/skills/dirtyloops/references/beads.md +9 -1
  13. package/skills/dirtyloops/references/create-loop.md +6 -3
  14. package/skills/dirtyloops/references/help.md +4 -4
  15. package/skills/dirtyloops/references/run-loop.md +10 -4
  16. package/skills/dirtyloops/references/swarms.md +3 -2
  17. package/skills/dirtyloops/references/workflows/orchestrator-callback.md +65 -9
  18. package/skills/dirtyloops/schemas/swarm-report.schema.json +1 -1
  19. package/skills/dirtyloops/templates/common/IMPLEMENT.md.template +1 -0
  20. package/skills/dirtyloops/templates/common/run-loop.md.template +1 -0
  21. package/skills/dirtyloops/templates/workflows/orchestrator-callback/closeout-selector-subagent-prompt.md.template +33 -0
  22. package/skills/dirtyloops/templates/workflows/orchestrator-callback/run-loop-addendum.md.template +6 -2
  23. package/skills/dirtyloops/templates/workflows/orchestrator-callback/selector-subagent-prompt.md.template +28 -0
package/README.md CHANGED
@@ -94,7 +94,7 @@ A created loop writes a project-local execution surface under `docs/implementati
94
94
  - `loop-state.md` - Lightweight mirror for current phase, branch/PR posture, blockers, and next action.
95
95
  - `turn-docs/` - One Markdown turn doc per phase. Reviewers update the existing phase turn doc instead of creating separate review docs.
96
96
  - `prompts/run-loop.md` - The prompt used to start or continue loop execution.
97
- - Workflow prompts - `orchestrator-callback` also emits implementation and review thread prompts.
97
+ - Workflow prompts - `orchestrator-callback` also emits selector, implementation, review, and closeout-selector prompts.
98
98
  - Schemas - Callback/report JSON contracts for implementation, review, and swarm reports.
99
99
  - `storyboard-post-run-mm-dd-yyyy.html` - Final closeout artifact generated after the stream completes.
100
100
 
@@ -110,11 +110,11 @@ The skill package itself mirrors that shape:
110
110
  #### Workflows
111
111
 
112
112
  - `single-thread-subagent` - One visible coordinator thread owns loop state while mass subagent swarms handle selection, scouting, slice planning, implementation assistance, review, and CI.
113
- - `orchestrator-callback` - One orchestrator thread creates separate implementation and review threads; those threads call back to a concrete orchestrator thread id only when they are done, blocked, or have opened the expected PR.
113
+ - `orchestrator-callback` - One orchestrator thread delegates phase gates to selector subagents, creates separate implementation and review threads, and receives callbacks to a concrete orchestrator thread id when workers/reviewers are done or blocked.
114
114
 
115
115
  Choose `single-thread-subagent` when you want one visible coordinator thread, less thread management, and a CLI-friendly loop. The main coordinator owns the branch, integration, PR state, Beads updates, and closeout. Subagents inspect, scout, split phases into slices, prepare implementation guidance or patches, review, verify CI, and report, but they do not advance loop state. Broad phases should use 8+ subagents before implementation.
116
116
 
117
- Choose `orchestrator-callback` when you want the original multi-thread flow. The orchestrator chooses the next ready Beads phase, creates implementation threads with a concrete callback target id, waits for implementation callbacks, creates review threads with the same callback target id, waits for review and CI callbacks, updates Beads, and then advances to the next phase.
117
+ Choose `orchestrator-callback` when you want the original multi-thread flow. The orchestrator launches a selector subagent before the first worker, creates implementation threads with a concrete callback target id, waits for implementation callbacks, creates review threads with the same callback target id, waits for review and CI callbacks, launches a closeout-selector subagent between phases, updates Beads, and then advances only to the selected next phase.
118
118
 
119
119
  #### Authority Rules
120
120
 
@@ -132,7 +132,7 @@ The `dirtyloops` skill is strict about ownership:
132
132
  - Broad scout, slice, implementation-helper, and review work should use bounded subagent swarms, usually 8 or more agents and up to 20 when the phase warrants it.
133
133
  - Phase scope stays narrow. File follow-up Beads issues instead of widening an active phase.
134
134
 
135
- For `orchestrator-callback`, only the orchestrator creates implementation and review threads. Implementation threads do not create review threads, review threads do not create follow-up implementation threads, selector subagents never implement, and reviewer subagents never close Beads issues.
135
+ For `orchestrator-callback`, only the orchestrator creates implementation and review threads. The orchestrator must launch a selector subagent before the first worker and a closeout-selector subagent after each review callback before stopping or continuing. Implementation threads do not create review threads, review threads do not create follow-up implementation threads, selector subagents never implement, closeout-selector subagents never mutate Beads, and reviewer subagents never close Beads issues.
136
136
 
137
137
  For `single-thread-subagent`, the coordinator must run a slice/scout swarm before broad implementation. Solo coordinator implementation of most phase work is a workflow violation; coordinator implementation should be limited to synthesis, integration, glue, conflicts, final repairs, and Beads/PR closeout.
138
138
 
@@ -142,7 +142,7 @@ Implementation threads call back exactly once when the PR is ready, the task is
142
142
 
143
143
  Review threads call back exactly once after review and CI are resolved. The callback includes the concrete orchestrator thread id, source thread id, Beads issue id, status, PR, CI state, review skill, repairs, remaining findings, turn doc, and context to keep.
144
144
 
145
- Prefer callback-driven coordination over polling. For long-running worker or reviewer threads, use a lightweight heartbeat around 30 minutes. Do not launch callback threads whose actual prompt text says only `current orchestrator thread`, `this thread`, or another generic callback target.
145
+ Prefer callback-driven coordination over polling. After launching a worker or reviewer, the orchestrator waits for the single callback; it does not repeatedly read, monitor, summarize, or status-check the child thread. For long-running worker or reviewer threads, use a lightweight heartbeat around 30 minutes only when the callback is overdue or liveness is uncertain. Do not launch callback threads whose actual prompt text says only `current orchestrator thread`, `this thread`, or another generic callback target.
146
146
 
147
147
  #### Closeout
148
148
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dirtydishes/skills",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Installer and catalog for dirtydishes agent skills.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -23,7 +23,7 @@ A dirtyloop is a Beads-canonical Codex implementation loop: phase docs, one Mark
23
23
  2. Select the workflow.
24
24
  - Skip this step for `help`.
25
25
  - `single-thread-subagent`: one coordinator thread uses mass subagent swarms for selection, scouting, slice planning, implementation assistance, review, and CI; no separate Codex worker/reviewer threads.
26
- - `orchestrator-callback`: an orchestrator thread creates implementation threads, then review threads; workers and reviewers call back to a concrete orchestrator thread id.
26
+ - `orchestrator-callback`: an orchestrator thread delegates phase gates to selector subagents, creates implementation threads, then review threads; workers and reviewers call back to a concrete orchestrator thread id.
27
27
  - Choose `orchestrator-callback` when the user mentions original loop flow, new threads, callbacks, worker threads, implementation threads, or review threads.
28
28
  - Choose `single-thread-subagent` when the user mentions single thread, CLI-friendly, or keeping all orchestration in one thread.
29
29
  - If the workflow is ambiguous for `create` or `run`, ask one concise question.
@@ -58,7 +58,9 @@ A dirtyloop is a Beads-canonical Codex implementation loop: phase docs, one Mark
58
58
  - Reviewer agents must use `thermo-nuclear-code-quality-review`.
59
59
  - Reviewer and CI verification agents own CI.
60
60
  - `dirtyloops run` continues phase-by-phase by default. Stop only when the epic is complete, blocked, interrupted, review/CI is unresolved, or the user explicitly asked for `run once` / `--once`.
61
+ - For `orchestrator-callback`, the orchestrator must spawn a selector subagent before the first worker and a closeout-selector subagent after each review callback before continuing or stopping. The orchestrator validates their reports and remains the only actor that mutates Beads, updates loop state, creates implementation/review threads, or advances the loop.
61
62
  - Orchestrator-callback prompts and callback payloads must carry the concrete orchestrator thread id. Do not launch a worker or reviewer if the actual instruction text says only `current orchestrator thread`, `this thread`, or another generic target.
63
+ - Orchestrator-callback is callback-wait, not active monitoring. After launching a worker or reviewer, the orchestrator must not repeatedly read, monitor, or summarize the child thread while waiting for its single callback. Use only a sparse fallback heartbeat when the callback is overdue or liveness is uncertain.
62
64
  - Worker and reviewer threads default to standard speed/reasoning unless the Beads loop metadata explicitly says otherwise.
63
65
  - For `single-thread-subagent`, the coordinator orchestrates, synthesizes, integrates, owns branch/PR/Beads state, and closes out. It must launch mass subagent swarms before broad implementation; direct coordinator implementation is for integration, glue, and final repair work.
64
66
  - Use large bounded subagent swarms: 8+ by default for broad scout, slice, implementation-helper, and review work, and up to 20 when the phase warrants it.
@@ -3,6 +3,6 @@
3
3
  These examples show the shape `$dirtyloops create` should produce.
4
4
 
5
5
  - `single-thread-subagent/` shows one visible coordinator thread with mass subagent swarms, slice planning, implementation helpers, review, and CI verification.
6
- - `orchestrator-callback/` shows the original thread-callback loop: orchestrator thread, implementation threads, review threads, concrete callback targets, and callback payloads.
6
+ - `orchestrator-callback/` shows the original thread-callback loop: orchestrator thread, selector and closeout-selector subagents, implementation threads, review threads, concrete callback targets, and callback payloads.
7
7
 
8
8
  Treat these as shape examples, not content to copy verbatim. New loops should fill in repo-specific Beads ids, phase docs, gates, branch policy, callback target ids, thread defaults, swarm policy, and prompt wording.
@@ -6,13 +6,13 @@ Topology:
6
6
 
7
7
  ```text
8
8
  orchestrator thread
9
- -> selector subagent
9
+ -> selector subagent chooses first ready phase
10
10
  -> implementation thread with exact callback target
11
11
  -> implementation callback when PR-ready
12
12
  -> review thread with exact callback target
13
13
  -> review callback when review + CI resolved
14
- -> orchestrator closeout
15
- -> next selector
14
+ -> closeout-selector subagent verifies closeout and next phase
15
+ -> orchestrator applies closeout and continues or stops
16
16
  ```
17
17
 
18
18
  Beads is canonical. The docs are execution context. Implementation and review callbacks echo the concrete orchestrator thread id and source thread id. Review and CI update the existing phase turn doc.
@@ -23,6 +23,13 @@ Replace an old reporting path with a simpler evidence-backed implementation whil
23
23
 
24
24
  Only the orchestrator creates implementation and review threads.
25
25
 
26
+ Selector subagents:
27
+
28
+ - run before the first implementation thread
29
+ - read Beads, `IMPLEMENT.md`, `loop-state.md`, and linked phase docs
30
+ - return a `swarm-report` with mission `selector`
31
+ - never implement, mutate Beads, edit files, or create threads
32
+
26
33
  Implementation threads:
27
34
 
28
35
  - receive the full phase doc, Beads issue id, branch policy, quality gates, and orchestrator thread id
@@ -44,7 +51,17 @@ Review threads:
44
51
  - update the existing phase turn doc
45
52
  - call back exactly once when review and CI are resolved, echoing `orchestrator_thread_id` and including `source_thread_id`
46
53
 
47
- The orchestrator owns Beads closeout and next selector launch. The loop continues phase-by-phase until the epic is complete, blocked, interrupted, or review/CI is unresolved.
54
+ Closeout-selector subagents:
55
+
56
+ - run after each review callback and before the orchestrator closes, stops, or launches another worker
57
+ - check the review callback, PR/CI evidence, existing turn doc, Beads dependencies, and `loop-state.md`
58
+ - recommend exact closeout actions and at most one next phase
59
+ - return a `swarm-report` with mission `closeout-selector`
60
+ - never implement, review, repair, mutate Beads, edit files, or create threads
61
+
62
+ The orchestrator validates selector reports, owns Beads closeout, and launches only the selected next phase. The loop continues phase-by-phase until the epic is complete, blocked, interrupted, or review/CI is unresolved.
63
+
64
+ After launching implementation or review threads, the orchestrator waits for the single callback. It does not repeatedly read, monitor, summarize, or status-check the child thread unless a sparse fallback heartbeat is needed for an overdue callback or liveness recovery.
48
65
 
49
66
  ## Phase Ledger
50
67
 
@@ -0,0 +1,33 @@
1
+ # Closeout-Selector Subagent Prompt: Example Stream
2
+
3
+ You are the closeout-selector subagent for an `orchestrator-callback` dirtyloop.
4
+
5
+ Canonical tracker: Beads epic `example-epic`
6
+
7
+ Mission: verify the just-reviewed phase can be closed out, then recommend stop or at most one next phase.
8
+
9
+ Read:
10
+
11
+ - Beads epic `example-epic`
12
+ - the reviewed phase issue
13
+ - the implementation callback
14
+ - the review callback
15
+ - PR and CI evidence
16
+ - the existing phase turn doc
17
+ - `docs/implementation/example-stream/IMPLEMENT.md`
18
+ - `docs/implementation/example-stream/loop-state.md`
19
+ - linked phase docs for the next ready candidates
20
+
21
+ Rules:
22
+
23
+ - Do not implement.
24
+ - Do not review or repair.
25
+ - Do not mutate Beads.
26
+ - Do not edit files.
27
+ - Do not create implementation or review threads.
28
+ - Recommend exact closeout actions for the reviewed phase.
29
+ - Recommend stop when the epic is complete, blocked, interrupted, unresolved, or this is a `--once` run.
30
+ - Recommend exactly one next phase only when continuation is allowed and Beads dependencies make it ready.
31
+
32
+ Return a compact report matching `schemas/swarm-report.schema.json` with `mission: "closeout-selector"`.
33
+
@@ -13,11 +13,12 @@ Start from:
13
13
  ## Rules
14
14
 
15
15
  - Beads is canonical.
16
- - Orchestrator selects exactly one next ready Beads child issue.
16
+ - Orchestrator launches a selector subagent to select exactly one next ready Beads child issue before the first worker.
17
17
  - Continue phase-by-phase until the epic is complete, blocked, interrupted, or review/CI is unresolved.
18
18
  - Only the orchestrator creates implementation and review threads.
19
19
  - Worker and reviewer threads default to standard speed/reasoning unless Beads metadata says otherwise.
20
20
  - Worker and reviewer prompt text must include the exact orchestrator thread id `THREAD_ORCHESTRATOR_ID` as callback target.
21
+ - After launching a worker or reviewer, wait for its single callback; do not repeatedly read, monitor, summarize, or status-check the child thread.
21
22
  - Implementation threads call back exactly once when PR-ready or blocked.
22
23
  - Implementation callbacks echo `orchestrator_thread_id` and include `source_thread_id`.
23
24
  - Implementation threads do not create review threads.
@@ -25,9 +26,11 @@ Start from:
25
26
  - Review threads own CI, repairs, reruns, and evidence.
26
27
  - Review threads call back exactly once when review and CI are resolved.
27
28
  - Review callbacks echo `orchestrator_thread_id` and include `source_thread_id`.
28
- - All actors update the existing Markdown phase turn doc.
29
+ - After every review callback, the orchestrator launches a closeout-selector subagent before closing, stopping, or continuing.
30
+ - Selector and closeout-selector subagents return `swarm-report` payloads and never mutate Beads or create threads.
31
+ - Workers and reviewers update the existing Markdown phase turn doc; the orchestrator records selector reports, callbacks, Beads updates, and closeout there.
29
32
  - Update Beads first, then update `loop-state.md`.
30
33
 
31
34
  ## Start Prompt
32
35
 
33
- Run the Example Stream dirtyloop with workflow `orchestrator-callback`. Use Beads epic `example-epic` as canonical. Read `docs/implementation/example-stream/IMPLEMENT.md` and `docs/implementation/example-stream/loop-state.md`, select one next ready Beads child issue with a selector subagent, create an implementation thread at standard speed with the full linked phase doc and exact callback target `THREAD_ORCHESTRATOR_ID` in the prompt text, wait for an implementation callback that echoes `orchestrator_thread_id` and includes `source_thread_id`, then create a review thread at standard speed that uses `thermo-nuclear-code-quality-review` and owns CI. Close out only after the review callback reports concrete CI state and echoes the same callback target. Do not let worker threads create review threads. Continue to the next ready phase unless the epic is complete, blocked, interrupted, or review/CI is unresolved.
36
+ Run the Example Stream dirtyloop with workflow `orchestrator-callback`. Use Beads epic `example-epic` as canonical. Read `docs/implementation/example-stream/IMPLEMENT.md` and `docs/implementation/example-stream/loop-state.md`, launch a selector subagent to select one next ready Beads child issue, create an implementation thread at standard speed with the full linked phase doc and exact callback target `THREAD_ORCHESTRATOR_ID` in the prompt text, then wait for an implementation callback that echoes `orchestrator_thread_id` and includes `source_thread_id` without repeatedly reading or monitoring the worker thread. Create a review thread at standard speed that uses `thermo-nuclear-code-quality-review` and owns CI, then wait for its single callback the same way. After the review callback reports concrete CI state and echoes the same callback target, launch a closeout-selector subagent to verify closeout and select stop or at most one next phase. Apply Beads and loop-state updates only from the orchestrator. Do not let worker threads create review threads. Continue to the next selected phase unless the epic is complete, blocked, interrupted, or review/CI is unresolved.
@@ -0,0 +1,28 @@
1
+ # Selector Subagent Prompt: Example Stream
2
+
3
+ You are the selector subagent for an `orchestrator-callback` dirtyloop.
4
+
5
+ Canonical tracker: Beads epic `example-epic`
6
+
7
+ Mission: select at most one next ready Beads phase for the orchestrator.
8
+
9
+ Read:
10
+
11
+ - Beads epic `example-epic`
12
+ - Beads loop metadata
13
+ - `docs/implementation/example-stream/IMPLEMENT.md`
14
+ - `docs/implementation/example-stream/loop-state.md`
15
+ - linked phase docs for ready or nearly-ready child issues
16
+
17
+ Rules:
18
+
19
+ - Do not implement.
20
+ - Do not review.
21
+ - Do not mutate Beads.
22
+ - Do not edit files.
23
+ - Do not create implementation or review threads.
24
+ - Select exactly one phase only when Beads says it is ready and the linked phase doc is coherent.
25
+ - If no phase is ready or the state is ambiguous, report `blocked` with evidence.
26
+
27
+ Return a compact report matching `schemas/swarm-report.schema.json` with `mission: "selector"`.
28
+
@@ -8,7 +8,7 @@ This is the single Markdown turn doc for the phase.
8
8
 
9
9
  ## Phase Selection
10
10
 
11
- Selected by the orchestrator after `bd ready` showed `example-epic.1` unblocked.
11
+ Selected by selector subagent `THREAD_SELECTOR_ID` after `bd ready` showed `example-epic.1` unblocked.
12
12
 
13
13
  ## Implementation Log
14
14
 
@@ -76,4 +76,6 @@ Evidence:
76
76
 
77
77
  ## Closeout
78
78
 
79
- Orchestrator merged PR `#123`, closed `example-epic.1`, refreshed Beads export, and launched the next selector.
79
+ Closeout-selector subagent `THREAD_CLOSEOUT_SELECTOR_ID` verified the review callback, PR `#123`, `ci-repaired-and-green` evidence, and Beads dependencies. It recommended closing `example-epic.1` and continuing with `example-epic.2`.
80
+
81
+ Orchestrator merged PR `#123`, closed `example-epic.1`, refreshed Beads export, updated `loop-state.md`, and launched the selected next phase.
@@ -457,11 +457,11 @@
457
457
 
458
458
  <article class="workflow-card callback">
459
459
  <h3>orchestrator-callback</h3>
460
- <p>The original loop shape. A main orchestrator creates standard-speed implementation and review threads with concrete callback targets, then advances after validated callbacks.</p>
460
+ <p>The original loop shape. A main orchestrator delegates phase gates to selector subagents, creates standard-speed implementation and review threads with concrete callback targets, waits without monitoring, then advances after validated callbacks and closeout reports.</p>
461
461
  <div class="flow">
462
462
  <div class="node callback">
463
463
  <b>1</b>
464
- <div><strong>Orchestrator selects phase</strong><span>Selector subagent reads Beads and linked phase docs.</span></div>
464
+ <div><strong>Selector picks phase</strong><span>Selector subagent reads Beads, loop state, and linked phase docs before the first worker.</span></div>
465
465
  </div>
466
466
  <div class="node callback">
467
467
  <b>2</b>
@@ -471,6 +471,10 @@
471
471
  <b>3</b>
472
472
  <div><strong>Review thread owns CI</strong><span>Reviewer uses thermo-nuclear review, handles CI/repairs, then echoes the callback id.</span></div>
473
473
  </div>
474
+ <div class="node callback">
475
+ <b>4</b>
476
+ <div><strong>Closeout selector gates next</strong><span>Closeout-selector subagent verifies review, PR, CI, Beads, and loop state before stop or next phase.</span></div>
477
+ </div>
474
478
  </div>
475
479
  </article>
476
480
  </div>
@@ -491,7 +495,7 @@
491
495
  <tr>
492
496
  <td>Phase selection</td>
493
497
  <td>Main coordinator with selector subagents.</td>
494
- <td>Orchestrator with selector subagent.</td>
498
+ <td>Initial selector subagent; closeout-selector subagent between phases.</td>
495
499
  </tr>
496
500
  <tr>
497
501
  <td>Implementation</td>
@@ -511,12 +515,12 @@
511
515
  <tr>
512
516
  <td>Beads closeout</td>
513
517
  <td>Main coordinator updates Beads first, then loop-state.</td>
514
- <td>Orchestrator updates Beads after implementation/review callbacks.</td>
518
+ <td>Orchestrator updates Beads after callback validation and closeout-selector report.</td>
515
519
  </tr>
516
520
  <tr>
517
521
  <td>Next phase</td>
518
522
  <td>Main coordinator continues after closeout unless complete, blocked, interrupted, unresolved, or <code>--once</code>.</td>
519
- <td>Orchestrator launches the next selector after closeout unless complete, blocked, interrupted, unresolved, or <code>--once</code>.</td>
523
+ <td>Orchestrator launches only the phase selected by the closeout-selector unless complete, blocked, interrupted, unresolved, or <code>--once</code>.</td>
520
524
  </tr>
521
525
  </tbody>
522
526
  </table>
@@ -65,8 +65,16 @@ For `orchestrator-callback`, add:
65
65
  "callback_policy": {
66
66
  "requires_concrete_orchestrator_thread_id": true,
67
67
  "requires_source_thread_id": true,
68
+ "wait_mode": "callback-wait",
69
+ "active_child_thread_monitoring": false,
68
70
  "heartbeat_after_minutes": 30,
69
71
  "polling": "fallback-only"
72
+ },
73
+ "selector_policy": {
74
+ "initial_selector_subagent": true,
75
+ "between_phase_closeout_selector_subagent": true,
76
+ "selector_report_schema": "schemas/swarm-report.schema.json",
77
+ "orchestrator_only_mutates_beads": true
70
78
  }
71
79
  }
72
80
  ```
@@ -89,7 +97,7 @@ For `single-thread-subagent`, add:
89
97
  }
90
98
  ```
91
99
 
92
- Phase metadata must include phase number, phase doc, turn doc, completion criteria, quality gates, branch/PR instructions, and either callback target data or swarm slice policy for the selected workflow.
100
+ Phase metadata must include phase number, phase doc, turn doc, completion criteria, quality gates, branch/PR instructions, and either callback/selector target data or swarm slice policy for the selected workflow.
93
101
 
94
102
  ## Selection
95
103
 
@@ -18,6 +18,7 @@ Required:
18
18
  - swarm policy for `single-thread-subagent`
19
19
  - quality gates
20
20
  - branch/PR policy
21
+ - selector policy for `orchestrator-callback`
21
22
 
22
23
  If required inputs are missing and cannot be inferred safely, ask one concise question before writing files.
23
24
 
@@ -26,7 +27,8 @@ Ask only for missing decisions. Prefer these defaults when the user has not spec
26
27
  - run policy: continue until epic complete, blocked, interrupted, or review/CI unresolved
27
28
  - one-shot mode: off unless the user says `run once` or `--once`
28
29
  - worker/reviewer speed: standard
29
- - orchestrator-callback heartbeat: 30 minutes, fallback-only polling
30
+ - orchestrator-callback wait policy: callback-wait, no active child-thread monitoring, 30 minute sparse fallback heartbeat only when overdue or liveness is uncertain
31
+ - orchestrator-callback selector policy: selector subagent before the first worker, closeout-selector subagent between phases
30
32
  - single-thread-subagent swarm mode: mass-subagent, minimum 8 parallel agents for broad scout/slice/review work
31
33
 
32
34
  ## Steps
@@ -44,7 +46,8 @@ Ask only for missing decisions. Prefer these defaults when the user has not spec
44
46
 
45
47
  3. Normalize loop metadata.
46
48
  - Record workflow, run policy, branch/PR policy, quality gates, and thread defaults.
47
- - For `orchestrator-callback`, record callback policy: concrete orchestrator thread id required in prompts and callback payloads, source thread id required in callback payloads, heartbeat interval, and fallback-only polling.
49
+ - For `orchestrator-callback`, record callback policy: concrete orchestrator thread id required in prompts and callback payloads, source thread id required in callback payloads, callback-wait behavior, no active child-thread monitoring, heartbeat interval, and fallback-only polling.
50
+ - For `orchestrator-callback`, record selector policy: initial selector subagent required, between-phase closeout-selector subagent required, selector reports use `swarm-report`, and only the orchestrator mutates Beads or advances the loop.
48
51
  - For `single-thread-subagent`, record swarm policy: mass-subagent mode, minimum parallel agents, scout/slice/implementation-helper/review/CI swarm sizes, mandatory slice plan before implementation, and coordinator-direct-implementation limits.
49
52
  - Completion criterion: the loop can be validated from Beads metadata before any worker, reviewer, or broad implementation work starts.
50
53
 
@@ -68,7 +71,7 @@ Ask only for missing decisions. Prefer these defaults when the user has not spec
68
71
  6. Generate the run prompt.
69
72
  - Save it as `docs/implementation/<stream>/prompts/run-loop.md`.
70
73
  - Include the selected workflow name.
71
- - Include Beads epic id, run policy, phase-doc location, turn-doc rules, review skill, CI ownership, thread defaults, callback/slice preflight rules, and storyboard requirements.
74
+ - Include Beads epic id, run policy, phase-doc location, turn-doc rules, review skill, CI ownership, thread defaults, selector gates, callback/slice preflight rules, and storyboard requirements.
72
75
  - Completion criterion: the user can paste the generated prompt into Codex to start the loop.
73
76
 
74
77
  ## Output Contract
@@ -119,16 +119,16 @@ Shape:
119
119
 
120
120
  ```text
121
121
  orchestrator thread
122
- -> selector subagent
122
+ -> selector subagent chooses first ready phase
123
123
  -> implementation thread
124
124
  -> implementation callback when PR-ready
125
125
  -> review thread
126
126
  -> review callback when review + CI are resolved
127
- -> orchestrator closeout
128
- -> next selector
127
+ -> closeout-selector subagent verifies closeout and next phase
128
+ -> orchestrator applies closeout and continues or stops
129
129
  ```
130
130
 
131
- Only the orchestrator creates implementation and review threads. Worker threads do not create review threads. Worker and reviewer prompts must contain the concrete orchestrator thread id as callback target.
131
+ Only the orchestrator creates implementation and review threads. Worker threads do not create review threads. Worker and reviewer prompts must contain the concrete orchestrator thread id as callback target. Phase selection is delegated: initial selection uses a selector subagent, and between-phase closeout/selection uses a closeout-selector subagent. After launching a worker or reviewer, the orchestrator waits for its single callback instead of repeatedly reading or monitoring the child thread.
132
132
 
133
133
  ## Which Workflow Should I Pick?
134
134
 
@@ -4,10 +4,11 @@ Use this branch to execute an existing dirtyloop. Continue phase-by-phase by def
4
4
 
5
5
  ## Steps
6
6
 
7
- 1. Read Beads.
7
+ 1. Read Beads and route phase selection.
8
8
  - Inspect the epic and ready child issues.
9
9
  - Read dirtyloop metadata from the epic and phase execution metadata from the selected child issue.
10
- - Completion criterion: the next ready Beads issue, run policy, workflow, thread defaults, and callback/slice policy are known; or a concrete blocker is known.
10
+ - For `orchestrator-callback`, launch a selector subagent before choosing the first worker phase. The selector reads Beads, `IMPLEMENT.md`, `loop-state.md`, and linked phase docs, then returns a `swarm-report` with mission `selector`.
11
+ - Completion criterion: the next ready Beads issue, run policy, workflow, thread defaults, and callback/slice policy are known from Beads plus any required selector report; or a concrete blocker is known.
11
12
 
12
13
  2. Read the execution context.
13
14
  - Read `IMPLEMENT.md`.
@@ -17,6 +18,7 @@ Use this branch to execute an existing dirtyloop. Continue phase-by-phase by def
17
18
 
18
19
  3. Validate launch preflight.
19
20
  - For `orchestrator-callback`, require a concrete orchestrator thread id before launching workers/reviewers. The actual worker/reviewer prompt text must name that exact id as the callback target and must not rely on phrases like `current orchestrator thread`, `this thread`, or `source thread wrapper`.
21
+ - For `orchestrator-callback`, require callback-wait behavior: after launch, do not repeatedly read or monitor the child thread while waiting for the single callback. Sparse fallback heartbeat is allowed only when the callback is overdue or liveness is uncertain.
20
22
  - For `orchestrator-callback`, require worker/reviewer thread defaults to be explicit, defaulting to standard speed/reasoning when metadata does not override it.
21
23
  - For `single-thread-subagent`, require a mass-subagent slice/scout plan before broad implementation. The coordinator may perform integration and final repairs, but it must not do most broad discovery or implementation itself.
22
24
  - Completion criterion: the workflow can start without relying on inherited thread settings, vague callback targets, or solo coordinator implementation.
@@ -25,17 +27,21 @@ Use this branch to execute an existing dirtyloop. Continue phase-by-phase by def
25
27
  - Follow the selected workflow reference.
26
28
  - Use required swarms for the workflow.
27
29
  - Keep implementation to exactly one phase.
30
+ - For `orchestrator-callback`, launch the child thread, then yield until its callback instead of polling the child thread for progress.
28
31
  - Completion criterion: the workflow reaches PR-ready, approved, repaired, blocked, or stream-complete state.
29
32
 
30
33
  5. Close out the phase.
34
+ - For `orchestrator-callback`, launch a closeout-selector subagent after the review callback and before closing the phase, stopping, or launching the next implementation thread.
35
+ - The closeout-selector checks review callback status, PR/CI evidence, the existing turn doc, Beads dependencies, and `loop-state.md`, then recommends phase closeout plus stop or one next phase.
31
36
  - Update the existing turn doc.
32
37
  - Update Beads first.
33
38
  - Record lifecycle events or notes for worker launch, callbacks, review launch, CI state, phase closeout, and next phase selection when supported by Beads.
34
39
  - Refresh Beads export when applicable.
35
40
  - Update `loop-state.md`.
36
- - Completion criterion: Beads and docs agree on the phase state.
41
+ - Completion criterion: Beads and docs agree on the phase state, and any required closeout-selector report has been validated and recorded.
37
42
 
38
43
  6. Continue or stop.
39
- - Default: select the next ready Beads child issue and continue the loop.
44
+ - Default: continue with the next ready Beads child issue selected by the workflow's selection gate.
45
+ - For `orchestrator-callback`, continue only from a selector or closeout-selector report; do not pick the next phase inline.
40
46
  - Stop when the epic is complete, blocked, interrupted, review/CI is unresolved, or the user requested `run once` / `--once`.
41
47
  - Completion criterion: final response includes the current phase, PR/CI state, Beads updates, whether the loop continued or stopped, and the exact stop reason when stopped.
@@ -4,7 +4,8 @@ dirtyloops use bounded swarms. Fan out aggressively when the phase has broad sur
4
4
 
5
5
  ## Default Sizes
6
6
 
7
- - selector swarm: 4-8 agents
7
+ - selector swarm: 4-8 agents for `single-thread-subagent`; one selector subagent per phase gate for `orchestrator-callback`
8
+ - closeout-selector gate: one subagent after each `orchestrator-callback` review callback
8
9
  - scout swarm: 8-20 agents
9
10
  - slice planning swarm: 8-16 agents
10
11
  - implementation helper swarm: 8-16 agents
@@ -38,7 +39,7 @@ Use compact reports:
38
39
 
39
40
  ```json
40
41
  {
41
- "mission": "scout|slice-plan|implementation-helper|review|ci|storyboard",
42
+ "mission": "selector|closeout-selector|scout|slice-plan|implementation-helper|review|ci|storyboard",
42
43
  "slice_id": "string-or-null",
43
44
  "status": "ready|blocked|risk-found|done",
44
45
  "scope_checked": ["..."],
@@ -1,12 +1,12 @@
1
1
  # Workflow: Orchestrator Callback
2
2
 
3
- Use this workflow for the original loop style: a main orchestrator thread creates implementation threads and review threads that call back to a concrete orchestrator thread id.
3
+ Use this workflow for the original loop style: a main orchestrator thread delegates phase gates to selector subagents, creates implementation threads and review threads, and receives callbacks to a concrete orchestrator thread id.
4
4
 
5
5
  ## Topology
6
6
 
7
7
  ```text
8
8
  orchestrator thread
9
- -> selector subagent chooses next ready Beads phase
9
+ -> selector subagent chooses the first next ready Beads phase
10
10
  -> orchestrator creates implementation thread
11
11
  -> implementation thread may use subagents
12
12
  -> implementation thread opens PR and calls back
@@ -14,8 +14,9 @@ orchestrator thread
14
14
  -> review thread may use subagents
15
15
  -> review thread owns CI and repairs
16
16
  -> review thread calls back after review + CI are resolved
17
- -> orchestrator updates Beads and loop state
18
- -> orchestrator launches next selector when continuing
17
+ -> closeout-selector subagent verifies closeout and selects stop or next phase
18
+ -> orchestrator applies Beads and loop-state updates
19
+ -> orchestrator launches the next selected phase or stops
19
20
  ```
20
21
 
21
22
  ## Authority
@@ -23,14 +24,30 @@ orchestrator thread
23
24
  The orchestrator owns:
24
25
 
25
26
  - Beads canonical state
26
- - phase selection
27
+ - selector and closeout-selector subagent dispatch
28
+ - validating selector outputs before advancing the loop
27
29
  - implementation thread creation
28
30
  - review thread creation
29
- - concrete callback target, callback preflight, and heartbeat
31
+ - concrete callback target, callback preflight, callback-wait, and sparse fallback heartbeat
30
32
  - phase closeout
31
- - launching the next selector
33
+ - launching the next selected phase
32
34
  - stream closeout and storyboard generation
33
35
 
36
+ The selector subagent owns:
37
+
38
+ - reading Beads ready state, dependencies, loop metadata, `IMPLEMENT.md`, `loop-state.md`, and linked phase docs
39
+ - selecting at most one ready phase
40
+ - returning a compact `swarm-report` with mission `selector`
41
+ - reporting blockers, ambiguity, or no-ready-phase state instead of guessing
42
+
43
+ The closeout-selector subagent owns:
44
+
45
+ - checking the review callback, PR/CI state, existing turn doc, Beads dependencies, and loop-state mirror
46
+ - recommending exact closeout actions for the just-reviewed phase
47
+ - selecting at most one next phase when continuation is allowed
48
+ - returning a compact `swarm-report` with mission `closeout-selector`
49
+ - reporting the allowed stop state when the epic is complete, blocked, interrupted, unresolved, or `--once`
50
+
34
51
  The implementation thread owns:
35
52
 
36
53
  - exactly one selected Beads issue
@@ -55,11 +72,50 @@ The review thread owns:
55
72
  - Implementation threads do not create review threads.
56
73
  - Review threads do not create follow-up implementation threads.
57
74
  - Selector subagents never implement.
75
+ - Closeout-selector subagents never implement, review, repair, create threads, or mutate Beads.
58
76
  - Reviewer subagents never close Beads issues.
59
77
  - The orchestrator is the only actor that advances to the next phase.
78
+ - The orchestrator must launch the initial selector subagent before the first implementation thread.
79
+ - After every review callback, the orchestrator must launch a closeout-selector subagent before closing the phase, stopping, or launching another implementation thread.
80
+ - After launching a worker or reviewer, the orchestrator waits for the single callback. It does not repeatedly read, monitor, summarize, or status-check the child thread.
81
+ - A fallback heartbeat is allowed only when the callback is overdue or liveness is uncertain; do not use heartbeat as routine polling.
60
82
  - Implementation and review threads default to standard speed/reasoning unless Beads metadata explicitly overrides it.
61
83
  - Before launch, the orchestrator must verify the actual worker/reviewer prompt text includes the exact orchestrator thread id as callback target. Do not launch if the prompt relies on generic wording such as `current orchestrator thread`, `this thread`, or a hidden wrapper.
62
84
 
85
+ ## Selector Reports
86
+
87
+ Selector and closeout-selector subagents use `schemas/swarm-report.schema.json`.
88
+
89
+ Initial selector reports use:
90
+
91
+ ```json
92
+ {
93
+ "mission": "selector",
94
+ "slice_id": null,
95
+ "status": "ready|blocked",
96
+ "scope_checked": ["bd ready", "IMPLEMENT.md", "loop-state.md", "phase docs"],
97
+ "findings": [],
98
+ "recommendations": ["select <phase-id> because ..."],
99
+ "artifacts": ["docs/implementation/<stream>/<phase-doc>.md"],
100
+ "context_to_keep": []
101
+ }
102
+ ```
103
+
104
+ Between-phase closeout reports use:
105
+
106
+ ```json
107
+ {
108
+ "mission": "closeout-selector",
109
+ "slice_id": null,
110
+ "status": "ready|blocked|risk-found|done",
111
+ "scope_checked": ["review callback", "PR/CI state", "turn doc", "Beads dependencies", "loop-state.md"],
112
+ "findings": [],
113
+ "recommendations": ["close <phase-id>", "continue with <next-phase-id>"],
114
+ "artifacts": ["docs/implementation/<stream>/turn-docs/<phase-id>.md"],
115
+ "context_to_keep": []
116
+ }
117
+ ```
118
+
63
119
  ## Implementation Callback
64
120
 
65
121
  Implementation threads call back exactly once when:
@@ -113,8 +169,8 @@ Payload:
113
169
 
114
170
  ## Heartbeat
115
171
 
116
- Prefer callback-driven coordination over polling. Use a lightweight fallback heartbeat around 30 minutes for long-running worker/reviewer threads.
172
+ Prefer callback-driven coordination over polling. After worker/reviewer launch, stop reading the child thread and wait for its callback. Use at most a lightweight fallback heartbeat around 30 minutes for long-running threads, and only to recover liveness or an overdue callback.
117
173
 
118
174
  ## Completion Criterion
119
175
 
120
- The orchestrator has received and validated the required callback, updated Beads and the existing turn doc, and either launched the next selector or reported an allowed stop state.
176
+ The orchestrator has received and validated the required callback, received the required selector or closeout-selector report for the current gate, updated Beads and the existing turn doc, and either launched the selected next phase or reported an allowed stop state.
@@ -5,7 +5,7 @@
5
5
  "additionalProperties": false,
6
6
  "required": ["mission", "slice_id", "status", "scope_checked", "findings", "recommendations", "artifacts", "context_to_keep"],
7
7
  "properties": {
8
- "mission": { "enum": ["selector", "scout", "slice-plan", "implementation-helper", "review", "ci", "storyboard"] },
8
+ "mission": { "enum": ["selector", "closeout-selector", "scout", "slice-plan", "implementation-helper", "review", "ci", "storyboard"] },
9
9
  "slice_id": { "type": ["string", "null"] },
10
10
  "status": { "enum": ["ready", "blocked", "risk-found", "done"] },
11
11
  "scope_checked": {
@@ -22,6 +22,7 @@ This stream is driven by Beads. These docs are execution context and resume aids
22
22
  ## Loop Rules
23
23
 
24
24
  - Select exactly one next ready Beads child issue.
25
+ - Follow the workflow's selector gate before launching implementation.
25
26
  - Read the linked phase doc before editing.
26
27
  - Continue phase-by-phase by default until the epic is complete, blocked, interrupted, or review/CI is unresolved.
27
28
  - Use `run once` / `--once` only when intentionally running one phase and stopping after closeout.
@@ -15,6 +15,7 @@ Start from:
15
15
 
16
16
  - Beads is canonical.
17
17
  - Select exactly one next ready Beads child issue.
18
+ - Use the selected workflow's phase-selection gate; do not pick phases inline when the workflow requires selector subagents.
18
19
  - Continue phase-by-phase by default until the epic is complete, blocked, interrupted, or review/CI is unresolved.
19
20
  - Stop after one phase only when this run explicitly says `run once` or `--once`.
20
21
  - Read the linked phase doc before editing.
@@ -0,0 +1,33 @@
1
+ # Closeout-Selector Subagent Prompt: {{STREAM_NAME}}
2
+
3
+ You are the closeout-selector subagent for an `orchestrator-callback` dirtyloop.
4
+
5
+ Canonical tracker: Beads epic `{{EPIC_ID}}`
6
+
7
+ Mission: verify the just-reviewed phase can be closed out, then recommend stop or at most one next phase.
8
+
9
+ Read:
10
+
11
+ - Beads epic `{{EPIC_ID}}`
12
+ - the reviewed phase issue
13
+ - the implementation callback
14
+ - the review callback
15
+ - PR and CI evidence
16
+ - the existing phase turn doc
17
+ - `docs/implementation/{{STREAM_SLUG}}/IMPLEMENT.md`
18
+ - `docs/implementation/{{STREAM_SLUG}}/loop-state.md`
19
+ - linked phase docs for the next ready candidates
20
+
21
+ Rules:
22
+
23
+ - Do not implement.
24
+ - Do not review or repair.
25
+ - Do not mutate Beads.
26
+ - Do not edit files.
27
+ - Do not create implementation or review threads.
28
+ - Recommend exact closeout actions for the reviewed phase.
29
+ - Recommend stop when the epic is complete, blocked, interrupted, unresolved, or this is a `--once` run.
30
+ - Recommend exactly one next phase only when continuation is allowed and Beads dependencies make it ready.
31
+
32
+ Return a compact report matching `schemas/swarm-report.schema.json` with `mission: "closeout-selector"`.
33
+
@@ -3,8 +3,13 @@
3
3
  This loop uses a main orchestrator thread plus separate implementation and review threads.
4
4
 
5
5
  - Only the orchestrator creates implementation and review threads.
6
+ - Before the first worker, the orchestrator launches a selector subagent to choose exactly one next ready Beads phase.
7
+ - After every review callback, the orchestrator launches a closeout-selector subagent before closing the phase, stopping, or launching another worker.
8
+ - Selector and closeout-selector subagents return `swarm-report` payloads with mission `selector` or `closeout-selector`; they do not mutate Beads, edit files, implement, review, repair, create threads, or advance the loop.
6
9
  - The orchestrator passes its concrete thread id as the callback target.
7
10
  - Before launching a worker or reviewer, verify the actual prompt text includes that exact thread id and does not rely on generic wording like `current orchestrator thread` or `this thread`.
11
+ - After launching a worker or reviewer, wait for its single callback. Do not repeatedly read, monitor, summarize, or status-check the child thread while waiting.
12
+ - Use a sparse fallback heartbeat around 30 minutes only when the callback is overdue or liveness is uncertain; do not use heartbeat as routine polling.
8
13
  - Worker and reviewer threads default to standard speed/reasoning unless Beads loop metadata explicitly overrides it.
9
14
  - Implementation threads update the existing phase turn doc, open the PR, and call back exactly once when PR-ready or blocked.
10
15
  - Implementation callback payloads must echo `orchestrator_thread_id` and include `source_thread_id`.
@@ -13,5 +18,4 @@ This loop uses a main orchestrator thread plus separate implementation and revie
13
18
  - Review threads own CI, repairs, reruns, and evidence.
14
19
  - Review threads update the existing phase turn doc and call back exactly once when review and CI are resolved.
15
20
  - Review callback payloads must echo `orchestrator_thread_id` and include `source_thread_id`.
16
- - The orchestrator owns Beads closeout and next selector launch.
17
- - Use a fallback heartbeat around 30 minutes for long-running threads.
21
+ - The orchestrator validates selector reports, owns Beads closeout, and launches only the selected next phase.
@@ -0,0 +1,28 @@
1
+ # Selector Subagent Prompt: {{STREAM_NAME}}
2
+
3
+ You are the selector subagent for an `orchestrator-callback` dirtyloop.
4
+
5
+ Canonical tracker: Beads epic `{{EPIC_ID}}`
6
+
7
+ Mission: select at most one next ready Beads phase for the orchestrator.
8
+
9
+ Read:
10
+
11
+ - Beads epic `{{EPIC_ID}}`
12
+ - Beads loop metadata
13
+ - `docs/implementation/{{STREAM_SLUG}}/IMPLEMENT.md`
14
+ - `docs/implementation/{{STREAM_SLUG}}/loop-state.md`
15
+ - linked phase docs for ready or nearly-ready child issues
16
+
17
+ Rules:
18
+
19
+ - Do not implement.
20
+ - Do not review.
21
+ - Do not mutate Beads.
22
+ - Do not edit files.
23
+ - Do not create implementation or review threads.
24
+ - Select exactly one phase only when Beads says it is ready and the linked phase doc is coherent.
25
+ - If no phase is ready or the state is ambiguous, report `blocked` with evidence.
26
+
27
+ Return a compact report matching `schemas/swarm-report.schema.json` with `mission: "selector"`.
28
+