@dirtydishes/skills 0.1.2 → 0.1.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 (36) hide show
  1. package/README.md +15 -11
  2. package/package.json +1 -1
  3. package/skills/dirtyloops/SKILL.md +8 -5
  4. package/skills/dirtyloops/examples/README.md +2 -2
  5. package/skills/dirtyloops/examples/orchestrator-callback/README.md +5 -3
  6. package/skills/dirtyloops/examples/orchestrator-callback/docs/implementation/example-stream/IMPLEMENT.md +29 -6
  7. package/skills/dirtyloops/examples/orchestrator-callback/docs/implementation/example-stream/prompts/closeout-selector-subagent.md +40 -0
  8. package/skills/dirtyloops/examples/orchestrator-callback/docs/implementation/example-stream/prompts/implementation-swarm-subagent.md +29 -0
  9. package/skills/dirtyloops/examples/orchestrator-callback/docs/implementation/example-stream/prompts/implementation-thread.md +11 -2
  10. package/skills/dirtyloops/examples/orchestrator-callback/docs/implementation/example-stream/prompts/review-thread.md +3 -2
  11. package/skills/dirtyloops/examples/orchestrator-callback/docs/implementation/example-stream/prompts/run-loop.md +10 -4
  12. package/skills/dirtyloops/examples/orchestrator-callback/docs/implementation/example-stream/prompts/selector-subagent.md +35 -0
  13. package/skills/dirtyloops/examples/orchestrator-callback/docs/implementation/example-stream/turn-docs/01-foundation.md +14 -2
  14. package/skills/dirtyloops/examples/single-thread-subagent/README.md +1 -0
  15. package/skills/dirtyloops/examples/single-thread-subagent/docs/implementation/example-stream/IMPLEMENT.md +2 -2
  16. package/skills/dirtyloops/examples/single-thread-subagent/docs/implementation/example-stream/prompts/run-loop.md +5 -4
  17. package/skills/dirtyloops/examples/single-thread-subagent/docs/implementation/example-stream/turn-docs/01-foundation.md +5 -5
  18. package/skills/dirtyloops/plan.html +13 -9
  19. package/skills/dirtyloops/references/beads.md +28 -4
  20. package/skills/dirtyloops/references/create-loop.md +17 -9
  21. package/skills/dirtyloops/references/help.md +9 -7
  22. package/skills/dirtyloops/references/run-loop.md +13 -6
  23. package/skills/dirtyloops/references/swarms.md +15 -6
  24. package/skills/dirtyloops/references/workflows/orchestrator-callback.md +83 -11
  25. package/skills/dirtyloops/references/workflows/single-thread-subagent.md +7 -6
  26. package/skills/dirtyloops/schemas/implementation-callback.schema.json +14 -1
  27. package/skills/dirtyloops/schemas/swarm-report.schema.json +1 -1
  28. package/skills/dirtyloops/templates/common/IMPLEMENT.md.template +3 -2
  29. package/skills/dirtyloops/templates/common/run-loop.md.template +3 -1
  30. package/skills/dirtyloops/templates/workflows/orchestrator-callback/closeout-selector-subagent-prompt.md.template +40 -0
  31. package/skills/dirtyloops/templates/workflows/orchestrator-callback/implementation-swarm-subagent-prompt.md.template +29 -0
  32. package/skills/dirtyloops/templates/workflows/orchestrator-callback/implementation-thread-prompt.md.template +11 -2
  33. package/skills/dirtyloops/templates/workflows/orchestrator-callback/review-thread-prompt.md.template +3 -2
  34. package/skills/dirtyloops/templates/workflows/orchestrator-callback/run-loop-addendum.md.template +10 -3
  35. package/skills/dirtyloops/templates/workflows/orchestrator-callback/selector-subagent-prompt.md.template +35 -0
  36. package/skills/dirtyloops/templates/workflows/single-thread-subagent/run-loop-addendum.md.template +5 -4
@@ -52,12 +52,16 @@ Epic metadata must include:
52
52
  "branch_pr_policy": "...",
53
53
  "quality_gates": ["..."],
54
54
  "thread_defaults": {
55
- "implementation": { "speed": "standard" },
56
- "review": { "speed": "standard" }
55
+ "selector": { "speed": "standard", "reasoning": "high", "inherit_orchestrator_thread_settings": false },
56
+ "implementation": { "speed": "standard", "reasoning": "high", "inherit_orchestrator_thread_settings": false },
57
+ "review": { "speed": "standard", "reasoning": "high", "inherit_orchestrator_thread_settings": false },
58
+ "closeout_selector": { "speed": "standard", "reasoning": "high", "inherit_orchestrator_thread_settings": false }
57
59
  }
58
60
  }
59
61
  ```
60
62
 
63
+ Thread defaults are actor-specific. Do not use `inherit`, current UI settings, the parent/orchestrator thread setting, or recent Codex thread defaults as the source of child-thread speed or reasoning. `fast` speed and `xhigh` reasoning are allowed only when the loop metadata explicitly names that value for that actor.
64
+
61
65
  For `orchestrator-callback`, add:
62
66
 
63
67
  ```json
@@ -65,8 +69,25 @@ For `orchestrator-callback`, add:
65
69
  "callback_policy": {
66
70
  "requires_concrete_orchestrator_thread_id": true,
67
71
  "requires_source_thread_id": true,
72
+ "wait_mode": "callback-wait",
73
+ "active_child_thread_monitoring": false,
68
74
  "heartbeat_after_minutes": 30,
69
75
  "polling": "fallback-only"
76
+ },
77
+ "selector_policy": {
78
+ "initial_selector_subagent": true,
79
+ "between_phase_closeout_selector_subagent": true,
80
+ "selector_report_schema": "schemas/swarm-report.schema.json",
81
+ "orchestrator_only_mutates_beads": true
82
+ },
83
+ "implementation_swarm_policy": {
84
+ "requires_swarm_first_for_non_trivial_phases": true,
85
+ "target_scout_agents": "8-20",
86
+ "target_slice_plan_agents": "8-16",
87
+ "target_implementation_helper_agents": "8-16",
88
+ "requires_slice_plan_before_broad_edits": true,
89
+ "lead_worker_role": "synthesize-integrate-own-pr",
90
+ "callback_requires_swarm_summary": true
70
91
  }
71
92
  }
72
93
  ```
@@ -77,19 +98,22 @@ For `single-thread-subagent`, add:
77
98
  {
78
99
  "swarm_policy": {
79
100
  "mode": "mass-subagent",
101
+ "requires_per_phase_swarms": true,
80
102
  "min_parallel_agents": 8,
103
+ "target_selector_agents": "4-8",
81
104
  "target_scout_agents": "8-20",
82
- "target_slice_agents": "8-16",
105
+ "target_slice_plan_agents": "8-16",
83
106
  "target_implementation_helper_agents": "8-16",
84
107
  "target_review_agents": "8-20",
85
108
  "target_ci_agents": "4-12",
86
109
  "requires_slice_plan_before_implementation": true,
110
+ "tiny_phase_exception_requires_turn_doc_reason": true,
87
111
  "coordinator_direct_implementation": "integration-only"
88
112
  }
89
113
  }
90
114
  ```
91
115
 
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.
116
+ Phase metadata must include phase number, phase doc, turn doc, completion criteria, quality gates, branch/PR instructions, and either callback/selector/implementation-swarm data or swarm slice policy for the selected workflow.
93
117
 
94
118
  ## Selection
95
119
 
@@ -13,11 +13,13 @@ Required:
13
13
  - epic title
14
14
  - workflow
15
15
  - run policy
16
- - thread defaults
16
+ - actor-specific thread defaults
17
17
  - callback policy for `orchestrator-callback`
18
18
  - swarm policy for `single-thread-subagent`
19
+ - implementation swarm policy for `orchestrator-callback`
19
20
  - quality gates
20
21
  - branch/PR policy
22
+ - selector policy for `orchestrator-callback`
21
23
 
22
24
  If required inputs are missing and cannot be inferred safely, ask one concise question before writing files.
23
25
 
@@ -25,9 +27,11 @@ Ask only for missing decisions. Prefer these defaults when the user has not spec
25
27
 
26
28
  - run policy: continue until epic complete, blocked, interrupted, or review/CI unresolved
27
29
  - one-shot mode: off unless the user says `run once` or `--once`
28
- - worker/reviewer speed: standard
29
- - orchestrator-callback heartbeat: 30 minutes, fallback-only polling
30
- - single-thread-subagent swarm mode: mass-subagent, minimum 8 parallel agents for broad scout/slice/review work
30
+ - orchestrator-callback child threads: `speed: standard`, `reasoning: high`, `inherit_orchestrator_thread_settings: false`
31
+ - orchestrator-callback wait policy: callback-wait, no active child-thread monitoring, 30 minute sparse fallback heartbeat only when overdue or liveness is uncertain
32
+ - orchestrator-callback selector policy: selector subagent before the first worker, closeout-selector subagent between phases
33
+ - orchestrator-callback implementation swarm policy: swarm-first for non-trivial phases with 8-20 scouts, 8-16 slice-plan agents, and 8-16 implementation-helper agents
34
+ - single-thread-subagent swarm mode: per-phase mass-subagent, selector 4-8, scout 8-20, slice-plan 8-16, implementation-helper 8-16, review 8-20, CI 4-12
31
35
 
32
36
  ## Steps
33
37
 
@@ -43,10 +47,14 @@ Ask only for missing decisions. Prefer these defaults when the user has not spec
43
47
  - Completion criterion: every plan requirement maps to one phase or an explicit follow-up.
44
48
 
45
49
  3. Normalize loop metadata.
46
- - 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.
48
- - 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
- - Completion criterion: the loop can be validated from Beads metadata before any worker, reviewer, or broad implementation work starts.
50
+ - Record workflow, run policy, branch/PR policy, quality gates, and actor-specific thread defaults.
51
+ - For `orchestrator-callback`, record thread defaults for selector, implementation, review, and closeout-selector actors. Default each actor to `speed: standard`, `reasoning: high`, and `inherit_orchestrator_thread_settings: false` unless the user explicitly chose an actor-specific override.
52
+ - For `orchestrator-callback`, do not let child threads inherit current UI settings, recent Codex thread defaults, or orchestrator-thread speed/reasoning. `fast` speed and `xhigh` reasoning require explicit Beads metadata for that actor.
53
+ - 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.
54
+ - 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.
55
+ - For `orchestrator-callback`, record implementation swarm policy: non-trivial phases require 8-20 scout agents, 8-16 slice-plan agents, 8-16 implementation-helper agents, pre-edit slice-plan synthesis, coherent lead-worker integration, and implementation callback `swarm_summary`.
56
+ - For `single-thread-subagent`, record swarm policy: per-phase mass-subagent mode, selector/scout/slice-plan/implementation-helper/review/CI swarm sizes, mandatory slice plan before implementation, tiny-phase exception rationale, and coordinator-direct-implementation limits.
57
+ - Completion criterion: the loop can be validated from Beads metadata before any worker, reviewer, or implementation work starts.
50
58
 
51
59
  4. Create Beads state.
52
60
  - Create or update the epic.
@@ -68,7 +76,7 @@ Ask only for missing decisions. Prefer these defaults when the user has not spec
68
76
  6. Generate the run prompt.
69
77
  - Save it as `docs/implementation/<stream>/prompts/run-loop.md`.
70
78
  - 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.
79
+ - Include Beads epic id, run policy, phase-doc location, turn-doc rules, review skill, CI ownership, actor-specific thread defaults, selector gates, implementation swarm policy, callback/slice preflight rules, and storyboard requirements.
72
80
  - Completion criterion: the user can paste the generated prompt into Codex to start the loop.
73
81
 
74
82
  ## Output Contract
@@ -11,7 +11,7 @@ Do not mutate files, Beads, branches, PRs, or threads while answering help.
11
11
  Every dirtyloop uses:
12
12
 
13
13
  - Beads as canonical tracker
14
- - typed loop metadata on Beads for workflow, run policy, callback policy, thread defaults, swarm policy, quality gates, and branch/PR policy
14
+ - typed loop metadata on Beads for workflow, run policy, callback policy, actor-specific thread defaults, swarm policy, quality gates, and branch/PR policy
15
15
  - phase docs linked from Beads child issues
16
16
  - repo-relative paths in generated docs and prompts
17
17
  - one Markdown turn doc per phase
@@ -40,7 +40,7 @@ Required inputs:
40
40
  - epic title
41
41
  - workflow
42
42
  - run policy
43
- - thread defaults
43
+ - actor-specific thread defaults
44
44
  - quality gates
45
45
  - branch/PR policy
46
46
 
@@ -109,7 +109,7 @@ main coordinator thread
109
109
  -> coordinator closeout
110
110
  ```
111
111
 
112
- Use it for CLI-friendly or context-controlled loops where separate callback threads are not desired. Single-thread means one visible coordinator, not solo implementation; broad phases should use 8+ subagents and a slice plan before implementation.
112
+ Use it for CLI-friendly or context-controlled loops where separate callback threads are not desired. Single-thread means one visible coordinator, not solo implementation; every phase uses selector, scout, slice-plan, implementation-helper, reviewer, and CI swarms unless a tiny-phase exception is recorded in the turn doc before implementation.
113
113
 
114
114
  ### `orchestrator-callback`
115
115
 
@@ -119,16 +119,18 @@ 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. Selector, implementation, review, and closeout-selector threads launch with explicit actor settings: `speed: standard`, `reasoning: high`, and `inherit_orchestrator_thread_settings: false`, unless Beads metadata overrides that actor. Current UI, recent thread, parent/orchestrator, `fast`, and `xhigh` settings do not count as defaults. After launching a worker or reviewer, the orchestrator waits for its single callback instead of repeatedly reading or monitoring the child thread.
132
+
133
+ Implementation threads are swarm-first for non-trivial phases. They run 8-20 scout agents, 8-16 slice-plan agents, and 8-16 implementation-helper agents before broad edits, synthesize the reports into one slice plan, integrate helper output coherently, and include `swarm_summary` in the implementation callback. Fewer agents require an explicit tiny-phase reason in the turn doc and callback.
132
134
 
133
135
  ## Which Workflow Should I Pick?
134
136
 
@@ -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,25 +18,31 @@ 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`.
20
- - For `orchestrator-callback`, require worker/reviewer thread defaults to be explicit, defaulting to standard speed/reasoning when metadata does not override it.
21
- - 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.
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.
22
+ - For `orchestrator-callback`, require explicit launch defaults for every child actor before launch: selector, implementation, review, and closeout-selector. Defaults are `speed: standard`, `reasoning: high`, and `inherit_orchestrator_thread_settings: false` unless Beads metadata overrides that actor.
23
+ - For `orchestrator-callback`, reject inherited launch settings. Do not use current UI settings, recent Codex thread defaults, parent/orchestrator settings, `fast`, or `xhigh` unless Beads metadata explicitly names that value for the actor being launched.
24
+ - For `single-thread-subagent`, require per-phase selector, scout, slice-plan, implementation-helper, review, and CI swarms before implementation and closeout. The coordinator may perform integration and final repairs, but it must not do most discovery or implementation itself.
22
25
  - Completion criterion: the workflow can start without relying on inherited thread settings, vague callback targets, or solo coordinator implementation.
23
26
 
24
27
  4. Run the selected workflow.
25
28
  - Follow the selected workflow reference.
26
29
  - Use required swarms for the workflow.
27
30
  - Keep implementation to exactly one phase.
31
+ - For `orchestrator-callback`, launch the child thread, then yield until its callback instead of polling the child thread for progress.
28
32
  - Completion criterion: the workflow reaches PR-ready, approved, repaired, blocked, or stream-complete state.
29
33
 
30
34
  5. Close out the phase.
35
+ - For `orchestrator-callback`, launch a closeout-selector subagent after the review callback and before closing the phase, stopping, or launching the next implementation thread.
36
+ - 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
37
  - Update the existing turn doc.
32
38
  - Update Beads first.
33
39
  - Record lifecycle events or notes for worker launch, callbacks, review launch, CI state, phase closeout, and next phase selection when supported by Beads.
34
40
  - Refresh Beads export when applicable.
35
41
  - Update `loop-state.md`.
36
- - Completion criterion: Beads and docs agree on the phase state.
42
+ - Completion criterion: Beads and docs agree on the phase state, and any required closeout-selector report has been validated and recorded.
37
43
 
38
44
  6. Continue or stop.
39
- - Default: select the next ready Beads child issue and continue the loop.
45
+ - Default: continue with the next ready Beads child issue selected by the workflow's selection gate.
46
+ - For `orchestrator-callback`, continue only from a selector or closeout-selector report; do not pick the next phase inline.
40
47
  - Stop when the epic is complete, blocked, interrupted, review/CI is unresolved, or the user requested `run once` / `--once`.
41
48
  - 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.
@@ -1,10 +1,11 @@
1
1
  # Swarms
2
2
 
3
- dirtyloops use bounded swarms. Fan out aggressively when the phase has broad surface area, shared architecture, CI risk, or user-facing behavior. In `single-thread-subagent`, mass subagent work is mandatory for broad phases: the visible coordinator orchestrates, synthesizes, integrates, and closes out; subagents do much of the discovery, slicing, implementation analysis, review, and CI verification.
3
+ dirtyloops use bounded swarms. Fan out aggressively when the phase has shared architecture, CI risk, user-facing behavior, or any meaningful implementation surface. In `single-thread-subagent`, mass subagent work is mandatory per phase: the visible coordinator orchestrates, synthesizes, integrates, and closes out; subagents do the discovery, slicing, implementation analysis, review, and CI verification. In `orchestrator-callback`, implementation threads are also swarm-first for non-trivial phases: the worker runs scout, slice-plan, and implementation-helper swarms before broad edits, then integrates the results coherently.
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
@@ -12,7 +13,15 @@ dirtyloops use bounded swarms. Fan out aggressively when the phase has broad sur
12
13
  - CI verification swarm: 4-12 agents
13
14
  - storyboard synthesis swarm: 3-8 agents
14
15
 
15
- For `single-thread-subagent`, use at least 8 parallel agents before broad implementation unless the phase is explicitly tiny. If fewer than 8 agents are used, record the reason in the turn doc.
16
+ For `single-thread-subagent`, every phase uses per-phase swarms unless the phase is explicitly tiny. Default per-phase sizes are selector 4-8 agents, scout 8-20 agents, slice-plan 8-16 agents, implementation-helper 8-16 agents, reviewer 8-20 agents, and CI verification 4-12 agents. If fewer than the default swarms are used, record the tiny-phase reason in the turn doc before implementation.
17
+
18
+ For `orchestrator-callback`, each non-trivial implementation thread must use massive bounded swarms before broad edits:
19
+
20
+ - 8-20 scout agents across files, modules, risks, tests, and integration edges
21
+ - 8-16 slice-plan agents to propose non-overlapping implementation slices
22
+ - 8-16 implementation-helper agents assigned to slices in parallel
23
+
24
+ The implementation thread synthesizes reports into the phase turn doc, chooses the final slice plan, integrates helper output, resolves conflicts, owns gates, and owns the PR. If a phase is tiny enough to use fewer than the default agents, record the reason in the turn doc and callback `swarm_summary`.
16
25
 
17
26
  ## Bounds
18
27
 
@@ -28,9 +37,9 @@ Each subagent gets:
28
37
 
29
38
  ## Slice Planning
30
39
 
31
- For non-trivial `single-thread-subagent` phases, run a slice planning swarm before implementation. Slices should be bounded by module, file group, workflow, test surface, or risk area.
40
+ For non-trivial phases, run a slice planning swarm before implementation. Slices should be bounded by module, file group, workflow, test surface, or risk area.
32
41
 
33
- The coordinator must synthesize the slice reports before broad edits. Direct coordinator implementation is limited to integration, glue, conflict resolution, final repairs, and Beads/PR state.
42
+ The coordinator or implementation thread must synthesize the slice reports before broad edits. Direct lead-thread implementation is limited to integration, glue, conflict resolution, final repairs, and Beads/PR state.
34
43
 
35
44
  ## Report Shape
36
45
 
@@ -38,7 +47,7 @@ Use compact reports:
38
47
 
39
48
  ```json
40
49
  {
41
- "mission": "scout|slice-plan|implementation-helper|review|ci|storyboard",
50
+ "mission": "selector|closeout-selector|scout|slice-plan|implementation-helper|review|ci|storyboard",
42
51
  "slice_id": "string-or-null",
43
52
  "status": "ready|blocked|risk-found|done",
44
53
  "scope_checked": ["..."],
@@ -1,21 +1,23 @@
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
- -> implementation thread may use subagents
11
+ -> implementation thread runs massive scout/slice/helper swarms
12
+ -> implementation thread synthesizes and integrates helper output
12
13
  -> implementation thread opens PR and calls back
13
14
  -> orchestrator creates review thread
14
15
  -> review thread may use subagents
15
16
  -> review thread owns CI and repairs
16
17
  -> review thread calls back after review + CI are resolved
17
- -> orchestrator updates Beads and loop state
18
- -> orchestrator launches next selector when continuing
18
+ -> closeout-selector subagent verifies closeout and selects stop or next phase
19
+ -> orchestrator applies Beads and loop-state updates
20
+ -> orchestrator launches the next selected phase or stops
19
21
  ```
20
22
 
21
23
  ## Authority
@@ -23,19 +25,38 @@ orchestrator thread
23
25
  The orchestrator owns:
24
26
 
25
27
  - Beads canonical state
26
- - phase selection
28
+ - selector and closeout-selector subagent dispatch
29
+ - validating selector outputs before advancing the loop
27
30
  - implementation thread creation
28
31
  - review thread creation
29
- - concrete callback target, callback preflight, and heartbeat
32
+ - concrete callback target, callback preflight, callback-wait, and sparse fallback heartbeat
30
33
  - phase closeout
31
- - launching the next selector
34
+ - launching the next selected phase
32
35
  - stream closeout and storyboard generation
33
36
 
37
+ The selector subagent owns:
38
+
39
+ - reading Beads ready state, dependencies, loop metadata, `IMPLEMENT.md`, `loop-state.md`, and linked phase docs
40
+ - selecting at most one ready phase
41
+ - returning a compact `swarm-report` with mission `selector`
42
+ - reporting blockers, ambiguity, or no-ready-phase state instead of guessing
43
+
44
+ The closeout-selector subagent owns:
45
+
46
+ - checking the review callback, PR/CI state, existing turn doc, Beads dependencies, and loop-state mirror
47
+ - recommending exact closeout actions for the just-reviewed phase
48
+ - selecting at most one next phase when continuation is allowed
49
+ - returning a compact `swarm-report` with mission `closeout-selector`
50
+ - reporting the allowed stop state when the epic is complete, blocked, interrupted, unresolved, or `--once`
51
+
34
52
  The implementation thread owns:
35
53
 
36
54
  - exactly one selected Beads issue
37
55
  - branch/worktree setup assigned by the orchestrator
56
+ - massive bounded scout, slice-plan, and implementation-helper swarms for non-trivial phases
57
+ - coherent synthesis of swarm reports into one slice plan
38
58
  - implementation
59
+ - integration, conflict resolution, and final repair
39
60
  - local gates before PR when feasible
40
61
  - PR creation
41
62
  - updating the existing Markdown turn doc
@@ -53,13 +74,56 @@ The review thread owns:
53
74
 
54
75
  - Only the orchestrator creates implementation and review threads.
55
76
  - Implementation threads do not create review threads.
77
+ - Implementation threads must not do broad solo implementation. For non-trivial phases, they run massive bounded scout, slice-plan, and implementation-helper swarms before broad edits.
78
+ - Implementation threads synthesize all swarm reports into the existing turn doc, integrate helper output coherently, and keep final ownership of the branch, gates, PR, and callback.
79
+ - If a phase is too small for the default swarm sizes, the implementation thread records the reason in the turn doc and callback `swarm_summary`.
56
80
  - Review threads do not create follow-up implementation threads.
57
81
  - Selector subagents never implement.
82
+ - Closeout-selector subagents never implement, review, repair, create threads, or mutate Beads.
58
83
  - Reviewer subagents never close Beads issues.
59
84
  - The orchestrator is the only actor that advances to the next phase.
60
- - Implementation and review threads default to standard speed/reasoning unless Beads metadata explicitly overrides it.
85
+ - The orchestrator must launch the initial selector subagent before the first implementation thread.
86
+ - After every review callback, the orchestrator must launch a closeout-selector subagent before closing the phase, stopping, or launching another implementation thread.
87
+ - 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.
88
+ - A fallback heartbeat is allowed only when the callback is overdue or liveness is uncertain; do not use heartbeat as routine polling.
89
+ - Selector, implementation, review, and closeout-selector threads default to `speed: standard`, `reasoning: high`, and `inherit_orchestrator_thread_settings: false` unless Beads metadata explicitly overrides that actor.
90
+ - Before launch, the orchestrator must verify the actual child-thread launch settings or prompt text spell out the actor's speed, reasoning, and non-inheritance. Current UI settings, recent Codex defaults, parent/orchestrator settings, `fast`, and `xhigh` do not count as valid defaults unless the Beads metadata explicitly names them for that actor.
61
91
  - 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
92
 
93
+ ## Selector Reports
94
+
95
+ Selector and closeout-selector subagents use `schemas/swarm-report.schema.json`.
96
+
97
+ Initial selector reports use:
98
+
99
+ ```json
100
+ {
101
+ "mission": "selector",
102
+ "slice_id": null,
103
+ "status": "ready|blocked",
104
+ "scope_checked": ["bd ready", "IMPLEMENT.md", "loop-state.md", "phase docs"],
105
+ "findings": [],
106
+ "recommendations": ["select <phase-id> because ..."],
107
+ "artifacts": ["docs/implementation/<stream>/<phase-doc>.md"],
108
+ "context_to_keep": []
109
+ }
110
+ ```
111
+
112
+ Between-phase closeout reports use:
113
+
114
+ ```json
115
+ {
116
+ "mission": "closeout-selector",
117
+ "slice_id": null,
118
+ "status": "ready|blocked|risk-found|done",
119
+ "scope_checked": ["review callback", "PR/CI state", "turn doc", "Beads dependencies", "loop-state.md"],
120
+ "findings": [],
121
+ "recommendations": ["close <phase-id>", "continue with <next-phase-id>"],
122
+ "artifacts": ["docs/implementation/<stream>/turn-docs/<phase-id>.md"],
123
+ "context_to_keep": []
124
+ }
125
+ ```
126
+
63
127
  ## Implementation Callback
64
128
 
65
129
  Implementation threads call back exactly once when:
@@ -83,6 +147,14 @@ Payload:
83
147
  "turn_doc": "...",
84
148
  "local_gates": ["..."],
85
149
  "changed_files": ["..."],
150
+ "swarm_summary": {
151
+ "scout_agents": 12,
152
+ "slice_plan_agents": 8,
153
+ "implementation_helper_agents": 10,
154
+ "slice_count": 5,
155
+ "synthesis": "Scout findings were collapsed into five file-group slices; helper outputs were integrated by the worker.",
156
+ "used_less_than_default_reason": null
157
+ },
86
158
  "blockers": [],
87
159
  "context_to_keep": []
88
160
  }
@@ -113,8 +185,8 @@ Payload:
113
185
 
114
186
  ## Heartbeat
115
187
 
116
- Prefer callback-driven coordination over polling. Use a lightweight fallback heartbeat around 30 minutes for long-running worker/reviewer threads.
188
+ 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
189
 
118
190
  ## Completion Criterion
119
191
 
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.
192
+ 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.
@@ -22,11 +22,12 @@ main coordinator thread
22
22
  - The main thread owns branch state, integration, PR state, Beads updates, and closeout.
23
23
  - Subagents inspect, compare, critique, slice the phase, prepare implementation guidance or patches, verify, and report.
24
24
  - Subagents do not advance loop state.
25
- - Use 8+ agents by default for broad scout, slice, implementation-helper, and review work; 8-20 agents is normal when the phase has meaningful surface area.
26
- - Before broad implementation, launch a slice planning swarm and record the synthesized slice plan in the turn doc.
27
- - For non-trivial phases, create or record intra-phase implementation slices. Use ephemeral Beads child issues when supported and useful; otherwise record the slices in the turn doc.
28
- - The coordinator may implement glue, integration, conflict resolution, and final repairs. If it performs most broad discovery or implementation itself, the loop has violated this workflow.
29
- - If fewer than 8 subagents are used for a broad phase, record the reason in the turn doc.
25
+ - Every phase uses per-phase swarms: selector, scout, slice-plan, implementation-helper, reviewer, and CI verification.
26
+ - Default per-phase sizes: selector 4-8 agents, scout 8-20 agents, slice-plan 8-16 agents, implementation-helper 8-16 agents, reviewer 8-20 agents, and CI verification 4-12 agents.
27
+ - Before implementation, launch a slice planning swarm and record the synthesized slice plan in the turn doc.
28
+ - Create or record intra-phase implementation slices. Use ephemeral Beads child issues when supported and useful; otherwise record the slices in the turn doc.
29
+ - The coordinator may implement glue, integration, conflict resolution, and final repairs. If it performs most discovery or implementation itself, the loop has violated this workflow.
30
+ - If a phase is tiny enough to use fewer than the default per-phase swarms, record the reason in the turn doc before implementation.
30
31
 
31
32
  ## Slice Contract
32
33
 
@@ -42,4 +43,4 @@ Each implementation slice has:
42
43
 
43
44
  ## Completion Criterion
44
45
 
45
- The main coordinator has selected one phase, received and synthesized scout/slice/implementation-helper reports, integrated one phase, received reviewer/CI subagent reports, updated the existing turn doc, updated Beads, and either continued to the next ready phase or stopped with an allowed stop reason.
46
+ The main coordinator has selected one phase, received and synthesized selector/scout/slice/implementation-helper reports, integrated one phase, received reviewer/CI subagent reports, recorded any tiny-phase swarm exception, updated the existing turn doc, updated Beads, and either continued to the next ready phase or stopped with an allowed stop reason.
@@ -3,7 +3,7 @@
3
3
  "title": "ImplementationCallback",
4
4
  "type": "object",
5
5
  "additionalProperties": false,
6
- "required": ["type", "orchestrator_thread_id", "source_thread_id", "phase_issue_id", "status", "branch", "pr", "commits", "turn_doc", "local_gates", "changed_files", "blockers", "context_to_keep"],
6
+ "required": ["type", "orchestrator_thread_id", "source_thread_id", "phase_issue_id", "status", "branch", "pr", "commits", "turn_doc", "local_gates", "changed_files", "swarm_summary", "blockers", "context_to_keep"],
7
7
  "properties": {
8
8
  "type": { "const": "implementation-callback" },
9
9
  "orchestrator_thread_id": { "type": "string", "minLength": 1 },
@@ -25,6 +25,19 @@
25
25
  "type": "array",
26
26
  "items": { "type": "string" }
27
27
  },
28
+ "swarm_summary": {
29
+ "type": "object",
30
+ "additionalProperties": false,
31
+ "required": ["scout_agents", "slice_plan_agents", "implementation_helper_agents", "slice_count", "synthesis", "used_less_than_default_reason"],
32
+ "properties": {
33
+ "scout_agents": { "type": "integer", "minimum": 0 },
34
+ "slice_plan_agents": { "type": "integer", "minimum": 0 },
35
+ "implementation_helper_agents": { "type": "integer", "minimum": 0 },
36
+ "slice_count": { "type": "integer", "minimum": 0 },
37
+ "synthesis": { "type": "string" },
38
+ "used_less_than_default_reason": { "type": ["string", "null"] }
39
+ }
40
+ },
28
41
  "blockers": {
29
42
  "type": "array",
30
43
  "items": { "type": "string" }
@@ -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": {
@@ -13,7 +13,7 @@ This stream is driven by Beads. These docs are execution context and resume aids
13
13
  ## Sources Of Truth
14
14
 
15
15
  - Beads epic: `{{EPIC_ID}}`
16
- - Beads loop metadata: workflow, run policy, branch/PR policy, quality gates, callback/thread defaults, and swarm policy
16
+ - Beads loop metadata: workflow, run policy, branch/PR policy, quality gates, callback policy, actor-specific thread defaults, and swarm policy
17
17
  - Roadmap: `docs/implementation/{{STREAM_SLUG}}/00-roadmap.md`
18
18
  - Loop state mirror: `docs/implementation/{{STREAM_SLUG}}/loop-state.md`
19
19
  - Phase docs linked from Beads child issues
@@ -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.
@@ -29,7 +30,7 @@ This stream is driven by Beads. These docs are execution context and resume aids
29
30
  - File Beads follow-ups instead of widening the selected phase.
30
31
  - Update Beads first, then update `loop-state.md`.
31
32
  - Use the workflow's required subagent swarms.
32
- - Worker and reviewer threads default to standard speed/reasoning unless Beads loop metadata explicitly overrides it.
33
+ - Orchestrator-callback child threads default to `speed: standard`, `reasoning: high`, and `inherit_orchestrator_thread_settings: false` unless Beads loop metadata explicitly overrides that actor.
33
34
 
34
35
  ## Review And CI
35
36
 
@@ -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.
@@ -22,7 +23,8 @@ Start from:
22
23
  - Use the workflow's required large bounded subagent swarms.
23
24
  - Reviewer agents must use `thermo-nuclear-code-quality-review`.
24
25
  - Reviewer and CI verification agents own CI.
25
- - Worker and reviewer threads default to standard speed/reasoning unless Beads loop metadata explicitly overrides it.
26
+ - Orchestrator-callback child threads must launch with explicit actor defaults: `speed: standard`, `reasoning: high`, and `inherit_orchestrator_thread_settings: false`, unless Beads metadata overrides that actor.
27
+ - Do not inherit child-thread speed or reasoning from the current UI, recent Codex thread defaults, or the orchestrator thread.
26
28
  - Update the existing Markdown turn doc.
27
29
  - Update Beads first, then update `loop-state.md`.
28
30
  - Do not widen the selected phase.
@@ -0,0 +1,40 @@
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
+ Launch defaults:
10
+
11
+ - speed: `standard`
12
+ - reasoning: `high`
13
+ - inherit_orchestrator_thread_settings: `false`
14
+
15
+ Do not run this closeout-selector with inherited UI, recent thread, parent/orchestrator, `fast`, or `xhigh` settings unless Beads metadata explicitly overrides the closeout-selector actor.
16
+
17
+ Read:
18
+
19
+ - Beads epic `{{EPIC_ID}}`
20
+ - the reviewed phase issue
21
+ - the implementation callback
22
+ - the review callback
23
+ - PR and CI evidence
24
+ - the existing phase turn doc
25
+ - `docs/implementation/{{STREAM_SLUG}}/IMPLEMENT.md`
26
+ - `docs/implementation/{{STREAM_SLUG}}/loop-state.md`
27
+ - linked phase docs for the next ready candidates
28
+
29
+ Rules:
30
+
31
+ - Do not implement.
32
+ - Do not review or repair.
33
+ - Do not mutate Beads.
34
+ - Do not edit files.
35
+ - Do not create implementation or review threads.
36
+ - Recommend exact closeout actions for the reviewed phase.
37
+ - Recommend stop when the epic is complete, blocked, interrupted, unresolved, or this is a `--once` run.
38
+ - Recommend exactly one next phase only when continuation is allowed and Beads dependencies make it ready.
39
+
40
+ Return a compact report matching `schemas/swarm-report.schema.json` with `mission: "closeout-selector"`.
@@ -0,0 +1,29 @@
1
+ # Implementation Swarm Subagent Prompt: {{STREAM_NAME}}
2
+
3
+ You are an implementation swarm subagent inside an `orchestrator-callback` implementation thread.
4
+
5
+ Mission: `{{SWARM_MISSION}}`
6
+
7
+ Allowed missions:
8
+
9
+ - `scout`: inspect a bounded surface and report facts, risks, likely files, and tests
10
+ - `slice-plan`: propose non-overlapping implementation slices and integration order
11
+ - `implementation-helper`: work one assigned slice in parallel and return patch guidance, changed files, gates, and integration notes
12
+
13
+ Inputs:
14
+
15
+ - Beads issue: `{{PHASE_ISSUE_ID}}`
16
+ - Phase doc: `{{PHASE_DOC}}`
17
+ - Turn doc: `{{TURN_DOC}}`
18
+ - Slice id: `{{SLICE_ID}}`
19
+ - Assigned scope: `{{ASSIGNED_SCOPE}}`
20
+
21
+ Rules:
22
+
23
+ - Stay inside the assigned scope.
24
+ - Do not mutate Beads.
25
+ - Do not create PRs or review threads.
26
+ - Do not own loop state or callback.
27
+ - Implementation-helper agents may prepare patches or concrete edit guidance only for their assigned slice.
28
+ - Return compact structured output matching `schemas/swarm-report.schema.json`.
29
+