@axiomantic/garden 0.2.22 → 0.2.24

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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: garden
3
- description: "Master entrypoint and umbrella conductor for the Axiomantic Multi-Agent Swarm Triad (Garden + Rhizo + Vine). Activating Garden automatically coordinates Rhizo for transport/concurrency and Vine for Rift workspace virtualization. Guides the user through feature sowing (garden plant), deterministic germination (garden germinate dispatch|prompt|inline|status), conversational intake, persona selection, prompt-based worker fleet bootstrapping with 10-backtick copy-paste cards, 3-stage empirical dialectical pump (research, design, audit), master implementation planning, and Two-Key gate trunk weaving. Triggers: 'garden', 'swarm', 'multi-agent', 'agent team', 'coordinate agents', 'parallel agents', 'run swarm', 'start swarm', 'run garden', 'swarm this project', 'orchestrate with garden', 'start garden swarm', 'run the full garden ceremony', 'start a project with garden', 'start a project with rhizo', 'set up a multi-agent team', 'use rhizo for this project', 'set up a swarm', 'coordinate multiple agents on this project', 'set up agents for this project', 'garden plant', 'garden germinate', 'sow seed', 'germinate', 'roadmap'."
3
+ description: "Master entrypoint and umbrella conductor for the Axiomantic Multi-Agent Swarm Triad (Garden + Rhizo + Vine). Activating Garden automatically coordinates Rhizo for transport/concurrency and Vine for Rift workspace virtualization. Guides the user through feature sowing (garden plant), deterministic germination (garden germinate dispatch|prompt|inline|status), conversational intake, persona selection, prompt-based worker fleet bootstrapping with 10-backtick copy-paste cards, 3-stage empirical dialectical pump (research, design, audit), master implementation planning, and Three-Key gate trunk weaving. Triggers: 'garden', 'swarm', 'multi-agent', 'agent team', 'coordinate agents', 'parallel agents', 'run swarm', 'start swarm', 'run garden', 'swarm this project', 'orchestrate with garden', 'start garden swarm', 'run the full garden ceremony', 'start a project with garden', 'start a project with rhizo', 'set up a multi-agent team', 'use rhizo for this project', 'set up a swarm', 'coordinate multiple agents on this project', 'set up agents for this project', 'garden plant', 'garden germinate', 'sow seed', 'germinate', 'roadmap'."
4
4
  ---
5
5
 
6
6
  # Garden: Multi-Agent Swarm Ceremony & Orchestration Engine
@@ -40,7 +40,7 @@ flowchart TD
40
40
 
41
41
  subgraph Infrastructure["Coordination Infrastructure"]
42
42
  Rhizo["Rhizo (Redis Bus, Fencing Mutexes, Work Queues)"]
43
- Vine["Vine (Rift Strands, Two-Key Gate, Weaving)"]
43
+ Vine["Vine (Rift Strands, Three-Key Gate, Weaving)"]
44
44
  end
45
45
 
46
46
  Phase0 --> Phase1 --> Phase2 --> Phase3 --> Phase4 --> Phase5
@@ -102,7 +102,12 @@ When the operator prefixes a request with `garden: <prompt>` (or directs a featu
102
102
  The orchestrator MUST NOT immediately write code, edit files, or unilaterally launch massive multi-file changes.
103
103
  Instead, it acts as an **Intelligent Intake Concierge**:
104
104
 
105
- 1. **Evaluate Request Scope & Blast Radius**:
105
+ 0. **Fast-Path Check for Pre-Authorized Directives & Active Swarm**:
106
+ - **Pre-Authorized Directives & Autonomous Dispatch**: If the operator instructs "work on this with your workers" (or similar delegation phrases), or whenever active cluster workers already exist on the Rhizo cluster (`rhizo who`), the Orchestrator MUST NOT stop to ask routing questions. It is fully pre-authorized to act! It must immediately break down work, provision isolated Vine strands (`vine new <task>`), and dispatch directly over Rhizo (`rhizo send`) or enqueue to work queues (`rhizo enqueue`).
107
+ - **Fleet-First Mandate**: When online workers exist anywhere in the cluster, NEVER output copy-paste prompt cards to the human operator. Dispatch or repurpose existing workers over Rhizo (`rhizo send` / `garden repurpose`).
108
+ - **Mandatory `ask_question` Tool Discipline**: Only during a true cold start with 0 cluster workers online and no explicit delegation directive may the orchestrator solicit routing input. In that case, the orchestrator MUST invoke the interactive `ask_question` tool. Dumping numbered multiple-choice lists (1, 2, 3) or raw option text directly into the chat stream is STRICTLY PROHIBITED.
109
+
110
+ 1. **Evaluate Request Scope & Blast Radius (Cold Start Only)**:
106
111
  - **High Complexity / Architectural Shifts / New Subsystems / Multi-File Migrations**: The request impacts foundational contracts, multiple modules, or shared abstractions. Requires empirical research, RFC design, adversarial review, and parallel strand isolation. Recommend **Option 1**.
107
112
  - **Medium Complexity / Well-Defined Features / Self-Contained Deliverables**: The scope is clear, boundaries are known, and it can be implemented without a 3-stage dialectical design cycle. Recommend **Option 2**.
108
113
  - **Low Complexity / Single-File Fixes / Documentation / Scratch Tweaks**: Trivial 1-file patch or config change. Recommend **Option 3**.
@@ -121,16 +126,53 @@ Instead, it acts as an **Intelligent Intake Concierge**:
121
126
 
122
127
  3. **Execution Branching**:
123
128
  - **If Option 1 selected**: Run `garden plant "<prompt>"`, then proceed to Cold-Start Swarm Calibration / Phase 1 `choose-personas` (or attach to active swarm via Fast-Path) and Phase 3 `dialectical-pump`.
124
- - **If Option 2 selected**: Check `rhizo who --json`. If workers are online, dispatch via `rhizo send` or `rhizo enqueue`. If cold, run Cold-Start Swarm Calibration to spin up workers.
129
+ - **If Option 2 selected**: Check `rhizo who --all --json`. If workers are online, dispatch via `rhizo send` or `rhizo enqueue`. If cold, run Cold-Start Swarm Calibration to spin up workers.
125
130
  - **If Option 3 selected**: Execute inline in the current session.
126
131
 
127
- #### Fast-Path: Re-using an Active / Existing Swarm (First-Look Invariant)
128
- Before asking ANY intake questions or presenting configuration modals, the designated orchestrator MUST run `rhizo who --json` to inspect the cluster.
129
- If active, healthy workers are ALREADY registered and listening on the Rhizo cluster:
130
- - **DO NOT** ask intake interview questions or prompt the operator for new sessions or models.
131
- - **DO NOT** display swarm composition or harness questions.
132
+ #### Adaptive Swarm On-Ramp & Dynamic Worker Repurposing (First-Look Invariant)
133
+
134
+ Before asking ANY intake questions or presenting configuration modals, the designated orchestrator MUST run `rhizo who --all --json` to inspect the cluster across all projects.
135
+ Garden automatically categorizes cluster listeners into three operational pools:
136
+ 1. **`projectActive`**: Active listeners already registered on the target project.
137
+ 2. **`availableIdlePeers`**: Active idle listeners currently registered under other projects, immediately available for dynamic repurposing.
138
+ 3. **`busyClusterPeers`**: Active listeners executing in-flight tasks (`BUSY`), guarded from unintentional reassignment.
139
+
140
+ ##### Fast-Path: Re-using an Active / Existing Swarm
141
+ If active, healthy workers on the target project meet or exceed the target worker count (`projectActive >= targetWorkers`):
142
+ - **Fast-Path Activated**: Skip intake interview questions and avoid generating redundant prompt card files.
132
143
  - Automatically attach to the existing online workers (`@worker-1`, `@worker-2`, ...).
133
144
  - Confirm cluster readiness and proceed immediately to Phase 3 (Dialectical Pump / Task Breakdown) or Phase 5 (Task Dispatch).
145
+ - **Bypass**: To force prompt card regeneration despite active workers, pass `--force-prompts` to `garden prompts` or `garden launch`.
146
+
147
+ ##### Dual-Pathway Swarm On-Ramp (When Additional Workers Needed)
148
+ When target project workers are needed and idle cluster peers exist, Garden surfaces two distinct pathways:
149
+
150
+ - **Pathway A (Dynamic Repurposing via `garden repurpose`)**:
151
+ Repurpose existing idle cluster listeners directly into the target project without opening new terminal windows or copying prompt cards:
152
+ ```bash
153
+ garden repurpose <worker1> <worker2> \
154
+ --project <target-project> \
155
+ --role "<assigned-role>" \
156
+ [--tags "<t1,t2>"] \
157
+ [--force]
158
+ ```
159
+ - **Self-Tagging Capability Handshake (`--self-tag`)**: When cluster workers have heterogeneous environments (e.g. one tab has Nim/C, another Node/Playwright, another Python/uv), dispatch an authenticated `SWARM_REPURPOSE_OFFER` directive:
160
+ ```bash
161
+ garden repurpose <worker> \
162
+ --project <target-project> \
163
+ --self-tag \
164
+ --expected-tags "backend,frontend,qa,audit"
165
+ ```
166
+ The recipient worker inspects its local toolchain, self-selects a compatible role, adds corresponding tags (`rhizo tag add <tags>`), and replies with `WORKER_READY`.
167
+ - **Negative Control & Safety Guardrail**: Repurposing rejects workers that are actively `BUSY` on tasks to prevent disrupting active workflows. Repurposing a busy worker requires the explicit `--force` flag.
168
+
169
+ - **Pathway B (Fresh Session Bootstrapping)**:
170
+ When zero cluster listeners exist or the operator prefers isolated fresh sessions, Garden generates self-contained 10-backtick prompt cards in `/tmp/garden-<project>/` via `garden prompts` (or `garden launch`).
171
+
172
+ <CRITICAL>
173
+ Operator-Named Worker Delegation Mandate:
174
+ When the operator explicitly requests or names a worker or peer session (e.g. 'u + autopxd-architect' or 'assign to worker-1'), the Lead Orchestrator MUST dispatch directly to that named recipient over Rhizo (`rhizo send --to <worker> ...`). The orchestrator MUST NEVER gate delegation on whether that worker appears in local single-project `rhizo who`, and MUST NEVER fall back to internal subagents. When inspecting the cluster roster for active workers, an orchestrator MUST query `rhizo who --all --json` (or check specific peers via `rhizo who <worker>` / `rhizo probe <worker>`). Never assume the cluster is empty based solely on local single-project `rhizo who` output.
175
+ </CRITICAL>
134
176
 
135
177
  > [!CAUTION]
136
178
  > **Orchestrator Scope Restriction**: This fast-path applies **ONLY** to a session that was explicitly initialized or designated by the operator as the Lead Orchestrator. A fresh unbootstrapped session must NEVER assume it is the orchestrator simply because `<project>-orchestrator` appears in `rhizo who`!
@@ -185,7 +227,7 @@ Upon receiving the operator's response:
185
227
 
186
228
  ## Unified Work Item State Machine (WISM)
187
229
 
188
- Rhizo, Garden, and Vine coordinate all multi-agent work through the formal **Work Item State Machine (WISM)**. Every task progresses through 10 deterministic states with atomic Redis transitions, automated DAG unblocking, and Two-Key integration gates.
230
+ Rhizo, Garden, and Vine coordinate all multi-agent work through the formal **Work Item State Machine (WISM)**. Every task progresses through deterministic states with atomic Redis transitions, automated DAG unblocking, and Three-Key integration gates.
189
231
 
190
232
  ```mermaid
191
233
  stateDiagram-v2
@@ -200,14 +242,18 @@ stateDiagram-v2
200
242
 
201
243
  CLAIMED --> IN_PROGRESS : Worker provisions strand (vine new <id>)
202
244
  IN_PROGRESS --> IN_PROGRESS : Progress reported (rhizo task progress, lease extended)
203
- IN_PROGRESS --> GATE_EVALUATING : Verification initiated (vine gate)
245
+ IN_PROGRESS --> GATE_EVALUATING : Verification initiated (vine submit / vine gate)
204
246
  IN_PROGRESS --> YIELDED : rhizo task yield (Returned to pool)
205
247
  IN_PROGRESS --> ORPHANED : Lease expires without progress
206
248
 
207
- GATE_EVALUATING --> IN_PROGRESS : Gate failed (Tests red or merge conflict)
208
- GATE_EVALUATING --> READY_TO_WEAVE : Two-Key Gate PASSED (Cryptographic gate token stamped)
249
+ GATE_EVALUATING --> IN_PROGRESS : Gate failed (Tests red, changelog missing, or merge conflict)
250
+ GATE_EVALUATING --> READY_FOR_AUDIT : Keys 1 & 2 PASSED (vine submit, gate token stamped)
251
+
252
+ READY_FOR_AUDIT --> AUDIT_RATIFIED : Key 3 PASSED (vine audit approve, audit token stamped)
253
+ READY_FOR_AUDIT --> AUDIT_REJECTED : Key 3 FAILED (vine audit reject)
254
+ AUDIT_REJECTED --> IN_PROGRESS : Remediate defects in strand
209
255
 
210
- READY_TO_WEAVE --> COMPLETED : vine weave && rhizo task complete (Unblocks downstream DAG children)
256
+ AUDIT_RATIFIED --> COMPLETED : vine weave && rhizo task complete (Unblocks downstream DAG children)
211
257
 
212
258
  ORPHANED --> QUEUED : Re-queued for retry (attempts < 3)
213
259
  ORPHANED --> DEAD_LETTER : Max delivery retries exceeded (attempts >= 3)
@@ -251,17 +297,24 @@ stateDiagram-v2
251
297
  +-------------+
252
298
  │ ▲
253
299
  │ vine │ Gate fails
254
- │ gate │ (Tests red or conflict)
300
+ │ submit │ (Tests red or conflict)
255
301
  ▼ │
256
302
  +-----------------+
257
303
  | GATE_EVALUATING |
258
304
  +-----------------+
259
305
  │
260
- │ Two-Key Gate PASSED (Key 1 merge-tree + Key 2 live test suite green)
306
+ │ Keys 1 & 2 PASSED (vine submit: merge-tree + live test suite green)
261
307
  ▼
262
- +----------------+
263
- | READY_TO_WEAVE |
264
- +----------------+
308
+ +------------------+
309
+ | READY_FOR_AUDIT | ◄──────────────────────┐
310
+ +------------------+ │
311
+ │ │ │
312
+ │ approve │ reject │ Remediate
313
+ ▼ ▼ │
314
+ +------------+ +----------------+ │
315
+ | AUDIT_ | | AUDIT_REJECTED | ──────────┘
316
+ | RATIFIED | +----------------+
317
+ +------------+
265
318
  │
266
319
  │ vine weave && rhizo task complete
267
320
  ▼
@@ -277,13 +330,19 @@ stateDiagram-v2
277
330
  | **`DRAFTED`** | `rhizo task create <id> --title <t>` | Creates immutable task contract hash `task:<id>` in Redis. | N/A |
278
331
  | **`BLOCKED`** | Evaluated on create | Stamped if `depends_on` contains incomplete tasks. Workers cannot claim. | N/A |
279
332
  | **`QUEUED`** | Auto on create or parent complete | Pushed to queue/inbox. Available for worker consumption. | N/A |
280
- | **`DELIVERED`** | `rhizo listen` consumes payload | **Atomically moves into `task:<id>` DELIVERED state**. Instant transport receipt emitted to orchestrator. Mirrored to local `~/.config/rhizo/current_task.json` for turn-end hook interlocks. | 180s Receipt Timeout $
281
- | **`CLAIMED`** | `rhizo task claim <id>` / `rhizo reply` | Worker acquires monotonic fencing lease. Isolated Vine strand provisioned (`vine new <id>`). Turn-end hook blocks until work starts. | Lease expires $
282
- | **`IN_PROGRESS`** | Worker coding in strand | Enforces single-active-lease invariant. Periodic `rhizo task progress` extends lease. | Lease expires $
283
- | **`GATE_EVALUATING`**| `vine gate` | Key 1 (mechanical merge-tree) & Key 2 (live compiler/test suite) evaluated. | Exit 1 $
284
- | **`READY_TO_WEAVE`** | Both keys pass 100% | Cryptographic gate token stamped (`gate_token`). Report sent to orchestrator. | N/A |
285
- | **`COMPLETED`** | `vine weave && rhizo task complete` | Fast-forward merged into canonical trunk. Strand pruned. Locks released. **Downstream DAG dependencies automatically unblocked (`BLOCKED` $
286
- | **`ORPHANED`** | Receipt timeout or lease expired | Stalled worker detected. Increments `delivery_attempts`. If $\ge 3
333
+ | **`DELIVERED`** | `rhizo listen` consumes payload | **Atomically moves into `task:<id>` DELIVERED state**. Instant transport receipt emitted to orchestrator. Mirrored to local `~/.config/rhizo/current_task.json` for turn-end hook interlocks. | 180s Receipt Timeout $
334
+ ightarrow$ `ORPHANED` |
335
+ | **`CLAIMED`** | `rhizo task claim <id>` / `rhizo reply` | Worker acquires monotonic fencing lease. Isolated Vine strand provisioned (`vine new <id>`). Turn-end hook blocks until work starts. | Lease expires $
336
+ ightarrow$ `ORPHANED` |
337
+ | **`IN_PROGRESS`** | Worker coding in strand | Enforces single-active-lease invariant. Periodic `rhizo task progress` extends lease. | Lease expires $
338
+ ightarrow$ `ORPHANED` |
339
+ | **`GATE_EVALUATING`**| `vine submit` / `vine gate` | Key 1 (mechanical merge-tree) & Key 2 (live compiler/test suite + changelog) evaluated. | Exit 1 $\rightarrow$ `CONFLICTED`<br>Exit 2 $\rightarrow$ `GATE_FAILED` |
340
+ | **`READY_FOR_AUDIT`**| `vine submit` | Keys 1 & 2 passed. Strand submitted for independent adversarial review. | N/A |
341
+ | **`AUDIT_REJECTED`** | `vine audit reject` | Auditor rejected deliverable with recorded defect reasons. Worker returns to `IN_PROGRESS` for delta remediation. | N/A |
342
+ | **`AUDIT_RATIFIED`** | `vine audit approve` | Key 3 passed! Cryptographic `audit_token` stamped. Auditor and author identities strictly decoupled (`auditor != author`). | N/A |
343
+ | **`COMPLETED`** | `vine weave && rhizo task complete` | Fast-forward merged into canonical trunk. Strand pruned. Locks released. **Downstream DAG dependencies automatically unblocked (`BLOCKED` $\rightarrow$ `QUEUED`)!** | N/A |
344
+ | **`ORPHANED`** | Receipt timeout or lease expired | Stalled worker detected. Increments `delivery_attempts`. If $\ge 3
345
+ ightarrow$ `DEAD_LETTER`. Otherwise returns to `QUEUED`. | Escalates to operator if Dead-Lettered |
287
346
  | **`YIELDED`** | `rhizo task yield <id>` | Worker gracefully steps aside. Task returned to `QUEUED`. | N/A |
288
347
  | **`DEAD_LETTER`** | Retries exhausted ($\ge 3$) | Moved to dead-letter queue. Alerts orchestrator and operator. | Requires manual operator triage |
289
348
 
@@ -324,7 +383,7 @@ Zero Theatrical Dialogue: Every dialectical assertion must be substantiated with
324
383
  Worker Autonomous Execution Invariant (GVR-017):
325
384
  Swarm workers are sovereign, autonomous implementers, not passive chatbots.
326
385
  When 'rhizo listen' delivers an incoming task and exits, workers MUST NOT wait for an operator prompt or ask "Shall I begin?".
327
- They MUST immediately transition to active execution: claim the task, enter the isolated Vine strand, perform the work, verify the Two-Key Gate, report results, and re-arm the single-shot listener before concluding their turn.
386
+ They MUST immediately transition to active execution: claim the task, enter the isolated Vine strand, perform the work, submit the strand for independent audit ('vine submit'), report results, and re-arm the single-shot listener before concluding their turn. Remember: THE WORKER IS NOT THE AUDITOR; an independent adversarial auditor must review and ratify Key 3 ('vine audit approve').
328
387
  </CRITICAL>
329
388
 
330
389
  <CRITICAL>
@@ -32,7 +32,7 @@ description: "Generates and formats X distinct copy-pasteable bootstrap prompts
32
32
  Swarm workers operate as sovereign, autonomous implementers, not passive chatbots.
33
33
  When 'rhizo listen' unblocks and exits, a directive has been delivered!
34
34
  Workers MUST NOT wait for operator intervention or ask "Shall I start?".
35
- They MUST immediately inspect the delivered directive, claim the task, switch to their isolated Vine strand, execute the requested work, verify the Two-Key Gate, report results, and re-arm their single-shot listener.
35
+ They MUST immediately inspect the delivered directive, claim the task, switch to their isolated Vine strand, execute the requested work, submit the strand for independent audit ('vine submit'), report results, and re-arm their single-shot listener. Remember: THE WORKER IS NOT THE AUDITOR; an independent adversarial auditor must review and ratify Key 3 ('vine audit approve').
36
36
  </CRITICAL>
37
37
  5. **Zero Dirty Commits**:
38
38
  - Never stage coordination state (`.rhizo.*`, `*.lock`, `.vine.json`, `workspaces/`) into Git.
@@ -45,6 +45,15 @@ description: "Generates and formats X distinct copy-pasteable bootstrap prompts
45
45
  Swarm workers must never produce isolated shelfware or mock toys. Every task must implement both the Provider and an active Consumer call-site in live entrypoints, must holistically integrate with real application state and events, and must aggressively delete any legacy code it replaces in the same strand.
46
46
  </CRITICAL>
47
47
 
48
+ 8. **Mutual Arrival Handshake Invariant**:
49
+ <CRITICAL>
50
+ Swarm workers MUST NEVER boot into silent, passive blocking listeners.
51
+ Turn 1 of every worker prompt card mandates executing the Mutual Arrival Handshake:
52
+ `rhizo send --to "@<orchestrator>" --subject "WORKER_READY" --body "..."`
53
+ This broadcast guarantees that the Orchestrator's background listener is immediately woken upon session initialization.
54
+ Conversely, the Lead Orchestrator MUST arm its background listener (`rhizo listen <orchestrator>`) in the exact turn that prompt cards are emitted to prevent bootstrap deadlocks.
55
+ </CRITICAL>
56
+
48
57
  ---
49
58
 
50
59
  ## 2. The Bootstrapping Flow
@@ -61,15 +70,19 @@ sequenceDiagram
61
70
  Orch->>Garden: Runs garden prompts (or garden launch)
62
71
  Garden-->>Orch: Emits X prompt cards wrapped in 10 backticks
63
72
  Orch->>Op: Displays formatted prompt blocks to operator
73
+ Note over Orch: MANDATORY: Orchestrator arms background listener ('rhizo listen <orchestrator>')
64
74
  Op->>Workers: Pastes Prompt #1 into Session 1, Prompt #2 into Session 2...
65
75
  loop Each Pasted Worker Session
66
76
  Workers->>Workers: Sets RHIZO_AGENT_NAME & enters target directory
67
77
  Workers->>Redis: Runs rhizo open <name> "<tags>"
78
+ Workers->>Redis: Broadcasts Arrival Handshake ('rhizo send @orchestrator --subject WORKER_READY')
68
79
  Workers->>Redis: Runs rhizo listen <name> (blocks waiting for tasks)
80
+ Redis-->>Orch: WORKER_READY message wakes Orchestrator listener!
81
+ Orch->>Redis: Orchestrator immediately dispatches initial sprint task
69
82
  end
70
- Orch->>Redis: Runs rhizo who --json to verify readiness gate
71
- Redis-->>Orch: All workers active and listening
72
- Orch->>Op: Confirms swarm is ready for task dispatch
83
+ Orch->>Redis: Runs rhizo who --json to verify full cluster roster
84
+ Redis-->>Orch: All workers active, listening, and assigned
85
+ Orch->>Op: Confirms swarm is fully active and executing
73
86
  ```
74
87
 
75
88
  ---
@@ -159,7 +172,7 @@ done
159
172
 
160
173
  ## Unified Work Item State Machine (WISM)
161
174
 
162
- Rhizo, Garden, and Vine coordinate all multi-agent work through the formal **Work Item State Machine (WISM)**. Every task progresses through 10 deterministic states with atomic Redis transitions, automated DAG unblocking, and Two-Key integration gates.
175
+ Rhizo, Garden, and Vine coordinate all multi-agent work through the formal **Work Item State Machine (WISM)**. Every task progresses through deterministic states with atomic Redis transitions, automated DAG unblocking, and Three-Key integration gates.
163
176
 
164
177
  ```mermaid
165
178
  stateDiagram-v2
@@ -174,14 +187,18 @@ stateDiagram-v2
174
187
 
175
188
  CLAIMED --> IN_PROGRESS : Worker provisions strand (vine new <id>)
176
189
  IN_PROGRESS --> IN_PROGRESS : Progress reported (rhizo task progress, lease extended)
177
- IN_PROGRESS --> GATE_EVALUATING : Verification initiated (vine gate)
190
+ IN_PROGRESS --> GATE_EVALUATING : Verification initiated (vine submit / vine gate)
178
191
  IN_PROGRESS --> YIELDED : rhizo task yield (Returned to pool)
179
192
  IN_PROGRESS --> ORPHANED : Lease expires without progress
180
193
 
181
- GATE_EVALUATING --> IN_PROGRESS : Gate failed (Tests red or merge conflict)
182
- GATE_EVALUATING --> READY_TO_WEAVE : Two-Key Gate PASSED (Cryptographic gate token stamped)
194
+ GATE_EVALUATING --> IN_PROGRESS : Gate failed (Tests red, changelog missing, or merge conflict)
195
+ GATE_EVALUATING --> READY_FOR_AUDIT : Keys 1 & 2 PASSED (vine submit, gate token stamped)
196
+
197
+ READY_FOR_AUDIT --> AUDIT_RATIFIED : Key 3 PASSED (vine audit approve, audit token stamped)
198
+ READY_FOR_AUDIT --> AUDIT_REJECTED : Key 3 FAILED (vine audit reject)
199
+ AUDIT_REJECTED --> IN_PROGRESS : Remediate defects in strand
183
200
 
184
- READY_TO_WEAVE --> COMPLETED : vine weave && rhizo task complete (Unblocks downstream DAG children)
201
+ AUDIT_RATIFIED --> COMPLETED : vine weave && rhizo task complete (Unblocks downstream DAG children)
185
202
 
186
203
  ORPHANED --> QUEUED : Re-queued for retry (attempts < 3)
187
204
  ORPHANED --> DEAD_LETTER : Max delivery retries exceeded (attempts >= 3)
@@ -225,17 +242,24 @@ stateDiagram-v2
225
242
  +-------------+
226
243
  │ ▲
227
244
  │ vine │ Gate fails
228
- │ gate │ (Tests red or conflict)
245
+ │ submit │ (Tests red or conflict)
229
246
  ▼ │
230
247
  +-----------------+
231
248
  | GATE_EVALUATING |
232
249
  +-----------------+
233
250
  │
234
- │ Two-Key Gate PASSED (Key 1 merge-tree + Key 2 live test suite green)
251
+ │ Keys 1 & 2 PASSED (vine submit: merge-tree + live test suite green)
235
252
  ▼
236
- +----------------+
237
- | READY_TO_WEAVE |
238
- +----------------+
253
+ +------------------+
254
+ | READY_FOR_AUDIT | ◄──────────────────────┐
255
+ +------------------+ │
256
+ │ │ │
257
+ │ approve │ reject │ Remediate
258
+ ▼ ▼ │
259
+ +------------+ +----------------+ │
260
+ | AUDIT_ | | AUDIT_REJECTED | ──────────┘
261
+ | RATIFIED | +----------------+
262
+ +------------+
239
263
  │
240
264
  │ vine weave && rhizo task complete
241
265
  ▼
@@ -251,13 +275,19 @@ stateDiagram-v2
251
275
  | **`DRAFTED`** | `rhizo task create <id> --title <t>` | Creates immutable task contract hash `task:<id>` in Redis. | N/A |
252
276
  | **`BLOCKED`** | Evaluated on create | Stamped if `depends_on` contains incomplete tasks. Workers cannot claim. | N/A |
253
277
  | **`QUEUED`** | Auto on create or parent complete | Pushed to queue/inbox. Available for worker consumption. | N/A |
254
- | **`DELIVERED`** | `rhizo listen` consumes payload | **Atomically moves into `task:<id>` DELIVERED state**. Instant transport receipt emitted to orchestrator. Mirrored to local `~/.config/rhizo/current_task.json` for turn-end hook interlocks. | 180s Receipt Timeout $
255
- | **`CLAIMED`** | `rhizo task claim <id>` / `rhizo reply` | Worker acquires monotonic fencing lease. Isolated Vine strand provisioned (`vine new <id>`). Turn-end hook blocks until work starts. | Lease expires $
256
- | **`IN_PROGRESS`** | Worker coding in strand | Enforces single-active-lease invariant. Periodic `rhizo task progress` extends lease. | Lease expires $
257
- | **`GATE_EVALUATING`**| `vine gate` | Key 1 (mechanical merge-tree) & Key 2 (live compiler/test suite) evaluated. | Exit 1 $
258
- | **`READY_TO_WEAVE`** | Both keys pass 100% | Cryptographic gate token stamped (`gate_token`). Report sent to orchestrator. | N/A |
259
- | **`COMPLETED`** | `vine weave && rhizo task complete` | Fast-forward merged into canonical trunk. Strand pruned. Locks released. **Downstream DAG dependencies automatically unblocked (`BLOCKED` $
260
- | **`ORPHANED`** | Receipt timeout or lease expired | Stalled worker detected. Increments `delivery_attempts`. If $\ge 3
278
+ | **`DELIVERED`** | `rhizo listen` consumes payload | **Atomically moves into `task:<id>` DELIVERED state**. Instant transport receipt emitted to orchestrator. Mirrored to local `~/.config/rhizo/current_task.json` for turn-end hook interlocks. | 180s Receipt Timeout $
279
+ ightarrow$ `ORPHANED` |
280
+ | **`CLAIMED`** | `rhizo task claim <id>` / `rhizo reply` | Worker acquires monotonic fencing lease. Isolated Vine strand provisioned (`vine new <id>`). Turn-end hook blocks until work starts. | Lease expires $
281
+ ightarrow$ `ORPHANED` |
282
+ | **`IN_PROGRESS`** | Worker coding in strand | Enforces single-active-lease invariant. Periodic `rhizo task progress` extends lease. | Lease expires $
283
+ ightarrow$ `ORPHANED` |
284
+ | **`GATE_EVALUATING`**| `vine submit` / `vine gate` | Key 1 (mechanical merge-tree) & Key 2 (live compiler/test suite + changelog) evaluated. | Exit 1 $\rightarrow$ `CONFLICTED`<br>Exit 2 $\rightarrow$ `GATE_FAILED` |
285
+ | **`READY_FOR_AUDIT`**| `vine submit` | Keys 1 & 2 passed. Strand submitted for independent adversarial review. | N/A |
286
+ | **`AUDIT_REJECTED`** | `vine audit reject` | Auditor rejected deliverable with recorded defect reasons. Worker returns to `IN_PROGRESS` for delta remediation. | N/A |
287
+ | **`AUDIT_RATIFIED`** | `vine audit approve` | Key 3 passed! Cryptographic `audit_token` stamped. Auditor and author identities strictly decoupled (`auditor != author`). | N/A |
288
+ | **`COMPLETED`** | `vine weave && rhizo task complete` | Fast-forward merged into canonical trunk. Strand pruned. Locks released. **Downstream DAG dependencies automatically unblocked (`BLOCKED` $\rightarrow$ `QUEUED`)!** | N/A |
289
+ | **`ORPHANED`** | Receipt timeout or lease expired | Stalled worker detected. Increments `delivery_attempts`. If $\ge 3
290
+ ightarrow$ `DEAD_LETTER`. Otherwise returns to `QUEUED`. | Escalates to operator if Dead-Lettered |
261
291
  | **`YIELDED`** | `rhizo task yield <id>` | Worker gracefully steps aside. Task returned to `QUEUED`. | N/A |
262
292
  | **`DEAD_LETTER`** | Retries exhausted ($\ge 3$) | Moved to dead-letter queue. Alerts orchestrator and operator. | Requires manual operator triage |
263
293
 
@@ -1,12 +1,12 @@
1
1
  ---
2
2
  name: orchestrate-swarm
3
- description: "Directs live multi-agent swarm execution from the primary chat session acting as Lead Orchestrator. Dispatches tasks over the Rhizo Redis bus, monitors worker heartbeats with rhizo who, governs task leasing and dead-letter queues, ratifies emergent design addenda, verifies Two-Key Gate reports from workers, executes fast-forward trunk merges via vine weave, and dynamically maintains implementation plan checkboxes and harness To-Do tools. Triggers: 'orchestrate swarm', 'run implementation plan', 'execute swarm tasks', 'manage workers', 'drive plan'."
3
+ description: "Directs live multi-agent swarm execution from the primary chat session acting as Lead Orchestrator. Dispatches tasks over the Rhizo Redis bus, monitors worker heartbeats with rhizo who, governs task leasing and dead-letter queues, ratifies emergent design addenda, enforces the Three-Key Gate and independent adversarial audit ratification, executes fast-forward trunk merges via vine weave, and dynamically maintains implementation plan checkboxes and harness To-Do tools. Triggers: 'orchestrate swarm', 'run implementation plan', 'execute swarm tasks', 'manage workers', 'drive plan'."
4
4
  ---
5
5
 
6
6
  # `orchestrate-swarm`: Main-Chat Swarm Governance & Trunk Integration
7
7
 
8
8
  > **The Sovereign Conductor of Autonomous Execution**
9
- > *The Lead Orchestrator does not write the low-level code lines; it directs the symphony. It dispatches work over Redis, unblocks dependencies, enforces the Two-Key Gate, and weaves clean strands into the trunk.*
9
+ > *The Lead Orchestrator does not write the low-level code lines; it directs the symphony. It dispatches work over Redis, unblocks dependencies, enforces the Three-Key Gate, and weaves clean strands into the trunk.*
10
10
 
11
11
  ---
12
12
 
@@ -15,33 +15,47 @@ description: "Directs live multi-agent swarm execution from the primary chat ses
15
15
  The main chat session assumes the role of **Lead Orchestrator**:
16
16
  - **Non-Interference**: Never perform massive multi-file edits directly when workers are active in isolated strands.
17
17
  - **Strict Transport Discipline**: All task assignments, handoffs, and cancellation interrupts flow exclusively over the Rhizo Redis bus (`rhizo send`, `rhizo reply`, `rhizo enqueue`).
18
- - **Gated Integration**: Never run `git merge` directly. Only weave branches that have passed both Key 1 (mechanical merge-tree) and Key 2 (live compiler/tests) inside their Vine strands.
18
+ - **Gated Integration**: Never run `git merge` directly. Only weave branches that have passed Key 1 (mechanical merge-tree), Key 2 (live compiler/tests + changelog) inside their Vine strands, and Key 3 (independent adversarial audit ratification via `vine audit approve`).
19
19
 
20
20
  <CRITICAL>
21
- Delegation Precedence & Sovereign Session Invariant:
21
+ The Worker is NOT the Auditor Invariant:
22
+ Workers are autonomous implementers, NEVER their own auditors. When a worker completes their tasks and passes Keys 1 & 2, they MUST run 'vine submit' to mark the strand READY_FOR_AUDIT. The worker is strictly forbidden from executing 'vine audit approve' on their own work.
23
+ The Lead Orchestrator provisions an independent Adversarial Auditor persona to inspect the strand, verify the Five Pillars, and run 'vine audit approve --auditor <name>'. Self-auditing is mechanically rejected by Vine (ExitGateAuditViolation = 6).
24
+ </CRITICAL>
25
+
26
+ <CRITICAL>
27
+ Delegation Precedence & Operator-Named Worker Mandate:
22
28
  Whenever instructed to "delegate", "assign", or "dispatch" work, the Lead Orchestrator MUST route tasks to active cluster workers via Rhizo (`rhizo send <worker>`, `rhizo enqueue queue:<project>:tasks`, or `rhizo task assign/claim`).
23
29
  Cluster workers operate exclusively in dedicated, sovereign sessions bootstrapped via 10-backtick prompt cards. NEVER spawn harness-internal subagents (e.g. `invoke_subagent`, `Task`, OpenCode subtasks) to act as cluster workers. Internal subagents are ephemeral, cannot maintain persistent blocking listeners, and cause severe context poisoning. Harness-internal subagents are restricted solely to transient, single-turn ad-hoc inspections in non-swarm solo chats when the operator explicitly specifies the word "subagent".
30
+ Furthermore, when the operator explicitly requests or names a worker or peer session (e.g. 'u + autopxd-architect' or 'assign to worker-1'), the Lead Orchestrator MUST dispatch directly to that named recipient over Rhizo (`rhizo send --to <worker> ...`). The orchestrator MUST NEVER gate delegation on whether that worker appears in local single-project `rhizo who`, and MUST NEVER fall back to internal subagents. When inspecting the cluster roster for active workers, an orchestrator MUST query `rhizo who --all --json` (or check specific peers via `rhizo who <worker>` / `rhizo probe <worker>`). Never assume the cluster is empty based solely on local single-project `rhizo who` output.
24
31
  </CRITICAL>
25
32
 
26
33
  <CRITICAL>
27
- Orchestrator Intake Gate & Non-Implementation Invariant (GVR-016):
34
+ Orchestrator Intake Gate & Autonomous Dispatch Invariant (GVR-016):
28
35
  The Lead Orchestrator is a CONDUCTOR, NOT A CODER.
29
36
  Whenever the operator presents a task, feature request, bugfix, or asks to work on something (including "garden: <prompt>"):
30
37
  THE ORCHESTRATOR MUST NEVER DIRECTLY JUMP INTO CODE EDITING OR IMPLEMENTATION TOOLS (e.g. `write_to_file`, `replace_file_content`).
31
- Instead, it acts as an Intelligent Concierge, evaluates request scope, and MUST STOP to ask the operator how they want the work routed using `ask_question`:
32
- - **Option 1 (Full Ceremony - RFE ➔ RFD ➔ RFC ➔ Swarm)**: For architectural shifts, new subsystems, major refactors, or cross-cutting migrations. Sows the idea as a persistent roadmap seed (`garden plant`), authors the Research/RFD, System Architecture/RFC, and Adversarial Audit documents, schedules monotonic locks and isolated Vine strands, and writes worker prompts to `/tmp/garden-<project>/`.
33
- - **Option 2 (Direct Swarm Dispatch)**: For well-defined, self-contained features. Bypasses long design ceremonies; enqueues tasks straight to cluster work queues (`rhizo enqueue queue:<project>:tasks`) or dispatches directly to active cluster workers (`rhizo send <worker>`).
34
- - **Option 3 (Inline Execution)**: For trivial 1-file fixes, documentation, or quick scratch tweaks executed directly in the main session (only if the operator explicitly selects/confirms this option).
35
38
 
36
- This intake gate applies to ANY request to "work on X", "build Y", "fix Z", or "implement feature W". Direct inline implementation is prohibited unless the operator explicitly directs the orchestrator to code it inline in the main session.
39
+ The orchestrator inspects the cluster state via `rhizo who --all --json`:
40
+ 1. **Pre-Authorized Directives & Active Fleet Fast-Path**:
41
+ If the operator has already directed "work on this with your workers", "delegate", or "dispatch", OR if active cluster workers/queues already exist:
42
+ DO NOT STOP TO ASK ROUTING QUESTIONS. The routing is already decided.
43
+ The orchestrator MUST immediately provision strands (`vine new`), break down the work, and dispatch directly to available cluster workers (`rhizo send <worker>`) or enqueue to `queue:<project>:tasks`.
44
+ 2. **Mandatory `ask_question` Tool Discipline (Zero Conversational Multiple-Choice)**:
45
+ If and ONLY if the cluster is completely cold (0 active workers online across the machine) AND the operator has not specified an execution mode:
46
+ The orchestrator MUST invoke the interactive `ask_question` tool to solicit the operator's preference (Swarm vs Inline).
47
+ Dumping multiple-choice numbered lists (`1, 2, 3`) or routing questionnaires in raw chat text is STRICTLY PROHIBITED.
48
+ 3. **Fleet-First Mandate (Zero Prompt-Card Overhead When Workers Are Online)**:
49
+ When active or idle workers exist on the cluster (`rhizo who --all`), the orchestrator is strictly forbidden from printing copy-paste prompt cards into chat or asking the operator to open new terminal tabs. It must automatically dispatch or repurpose the existing fleet over Rhizo.
37
50
  </CRITICAL>
38
51
 
39
52
  <CRITICAL>
40
- Pre-Weave Adversarial Audit & Literal Fidelity Invariant:
41
- The Lead Orchestrator is the final gatekeeper against hermetic shelfware, hollow mocks, superficial heuristics, and green mirages.
53
+ Pre-Weave Adversarial Audit, Anti-Defeat-Device & Literal Fidelity Invariant:
54
+ The Lead Orchestrator is the final gatekeeper against hermetic shelfware, hollow mocks, superficial heuristics, benchmark defeat devices, and green mirages.
55
+ Intensive Five-Pillar adversarial audits are Standard Operating Procedure (SOP). They are pre-authorized, mandatory, and autonomous across the Triad; the Orchestrator executes them automatically without prompting for human operator input.
42
56
  Before executing `vine weave` on any worker strand, the Orchestrator MUST enforce the Five-Pillar Pre-Weave Adversarial Audit (Key 3 of the Three-Key Gate):
43
57
  1. Two-Point Diff: The branch modifies both a Provider and an active Consumer call-site (live router, CLI command dispatcher, UI, or event loop). Unwired modules tested solely by their own test suites are strictly rejected back to the worker as incomplete shelfware.
44
- 2. Holistic Integration (Anti-Stub / Anti-Toy): Real system behavior, state, and errors must be handled; no placeholder toys, stubs, mocks, naive string splits, or shallow heuristics pretending to be integrated.
58
+ 2. Holistic Integration & Anti-Defeat-Device: Real system behavior, state, and errors must be handled; no placeholder toys, stubs, mocks, naive string splits, or prompt keyword interceptors (e.g. 'if flight game in q'). Any prompt-matching defeat device that bypasses genuine pipelines to fake benchmark compliance is mechanically rejected at Key 2 (`ExitGateDefeatDeviceViolation` = 7) and Key 3.
45
59
  3. Literal Fidelity & Reference Parity Mandate (Anti-Approximation): If the task ports, reverse-engineers, duplicates functionality from a reference, or executes a specific operator directive, it must exhibit literal, true fidelity. Approximations ("looks right", "good enough for happy paths") are strictly rejected. All edge cases, flags, type boundaries, and error flows must match the specification precisely.
46
60
  4. Replacement Purge: All legacy or obsolete code targeted for replacement is completely deleted in the strand diff. Preserving dead code as "fallbacks" or leaving commented-out blocks is prohibited.
47
61
  5. Structural Assertion Rigor (Anti-Green-Mirage): Reject tests relying on partial/loose assertions (`assert "foo" in bar` or `assert len(x) > 0`). Require full structural equality (`assert actual == expected`) and mandatory negative controls.
@@ -92,10 +106,10 @@ Context compaction purges detailed operational invariants, ceremony rules, and p
92
106
  Orchestrator Turn-End Listener Invariant (GVR-014):
93
107
  Coding harnesses (Antigravity, Claude Code, OpenCode) are event-driven: when the model yields a turn with text output, execution is completely suspended. Redis inbox state changes CANNOT wake an idle harness without an active child process registered in the task manager.
94
108
 
95
- Whenever the Lead Orchestrator dispatches a task, broadcasts instructions, or awaits worker responses, THE FINAL ACTION OF THAT TURN MUST BE ARMING A BACKGROUND LISTENER:
109
+ Whenever the Lead Orchestrator dispatches a task, broadcasts instructions, awaits worker responses, or emits worker prompt cards ('garden prompts' / 'garden launch'), THE FINAL ACTION OF THAT TURN MUST BE ARMING A BACKGROUND LISTENER:
96
110
  `run_command(CommandLine="rhizo listen <orchestrator>", IsDaemon=false, WaitMsBeforeAsync=500)`
97
111
 
98
- FORBIDDEN: Never yield the conversation turn to the operator after dispatching work without an active background listener running. Yielding a turn without a listener severs the swarm's physical lifeline, trapping worker replies in Redis and causing silent swarm stalls.
112
+ FORBIDDEN: Never yield the conversation turn to the operator after dispatching work or emitting prompt cards without an active background listener running. Yielding a turn without a listener severs the swarm's physical lifeline, trapping worker replies and mutual arrival handshakes ('WORKER_READY') in Redis and causing silent swarm deadlocks.
99
113
 
100
114
  Safety Net (In-Flight Task Liveness Probe & Watchdog Protocol):
101
115
  - **Antigravity & OpenCode Idle Exemption**: When idle or waiting for routine replies in Google Antigravity (using background `run_command(CommandLine="rhizo listen <orchestrator>", IsDaemon=false, WaitMsBeforeAsync=500)`) and OpenCode (using background ear), DO NOT schedule recurring cron timers. Antigravity's task manager natively and reactively resumes execution on process exit when `rhizo listen` delivers a message.
@@ -128,7 +142,7 @@ Safety Net (In-Flight Task Liveness Probe & Watchdog Protocol):
128
142
 
129
143
  ## Unified Work Item State Machine (WISM)
130
144
 
131
- Rhizo, Garden, and Vine coordinate all multi-agent work through the formal **Work Item State Machine (WISM)**. Every task progresses through 10 deterministic states with atomic Redis transitions, automated DAG unblocking, and Two-Key integration gates.
145
+ Rhizo, Garden, and Vine coordinate all multi-agent work through the formal **Work Item State Machine (WISM)**. Every task progresses through deterministic states with atomic Redis transitions, automated DAG unblocking, and Three-Key integration gates.
132
146
 
133
147
  ```mermaid
134
148
  stateDiagram-v2
@@ -143,14 +157,18 @@ stateDiagram-v2
143
157
 
144
158
  CLAIMED --> IN_PROGRESS : Worker provisions strand (vine new <id>)
145
159
  IN_PROGRESS --> IN_PROGRESS : Progress reported (rhizo task progress, lease extended)
146
- IN_PROGRESS --> GATE_EVALUATING : Verification initiated (vine gate)
160
+ IN_PROGRESS --> GATE_EVALUATING : Verification initiated (vine submit / vine gate)
147
161
  IN_PROGRESS --> YIELDED : rhizo task yield (Returned to pool)
148
162
  IN_PROGRESS --> ORPHANED : Lease expires without progress
149
163
 
150
- GATE_EVALUATING --> IN_PROGRESS : Gate failed (Tests red or merge conflict)
151
- GATE_EVALUATING --> READY_TO_WEAVE : Two-Key Gate PASSED (Cryptographic gate token stamped)
164
+ GATE_EVALUATING --> IN_PROGRESS : Gate failed (Tests red, changelog missing, or merge conflict)
165
+ GATE_EVALUATING --> READY_FOR_AUDIT : Keys 1 & 2 PASSED (vine submit, gate token stamped)
152
166
 
153
- READY_TO_WEAVE --> COMPLETED : vine weave && rhizo task complete (Unblocks downstream DAG children)
167
+ READY_FOR_AUDIT --> AUDIT_RATIFIED : Key 3 PASSED (vine audit approve, audit token stamped)
168
+ READY_FOR_AUDIT --> AUDIT_REJECTED : Key 3 FAILED (vine audit reject)
169
+ AUDIT_REJECTED --> IN_PROGRESS : Remediate defects in strand
170
+
171
+ AUDIT_RATIFIED --> COMPLETED : vine weave && rhizo task complete (Unblocks downstream DAG children)
154
172
 
155
173
  ORPHANED --> QUEUED : Re-queued for retry (attempts < 3)
156
174
  ORPHANED --> DEAD_LETTER : Max delivery retries exceeded (attempts >= 3)
@@ -194,17 +212,24 @@ stateDiagram-v2
194
212
  +-------------+
195
213
  │ ▲
196
214
  │ vine │ Gate fails
197
- │ gate │ (Tests red or conflict)
215
+ │ submit │ (Tests red or conflict)
198
216
  ▼ │
199
217
  +-----------------+
200
218
  | GATE_EVALUATING |
201
219
  +-----------------+
202
220
  │
203
- │ Two-Key Gate PASSED (Key 1 merge-tree + Key 2 live test suite green)
221
+ │ Keys 1 & 2 PASSED (vine submit: merge-tree + live test suite green)
204
222
  ▼
205
- +----------------+
206
- | READY_TO_WEAVE |
207
- +----------------+
223
+ +------------------+
224
+ | READY_FOR_AUDIT | ◄──────────────────────┐
225
+ +------------------+ │
226
+ │ │ │
227
+ │ approve │ reject │ Remediate
228
+ ▼ ▼ │
229
+ +------------+ +----------------+ │
230
+ | AUDIT_ | | AUDIT_REJECTED | ──────────┘
231
+ | RATIFIED | +----------------+
232
+ +------------+
208
233
  │
209
234
  │ vine weave && rhizo task complete
210
235
  ▼
@@ -220,13 +245,19 @@ stateDiagram-v2
220
245
  | **`DRAFTED`** | `rhizo task create <id> --title <t>` | Creates immutable task contract hash `task:<id>` in Redis. | N/A |
221
246
  | **`BLOCKED`** | Evaluated on create | Stamped if `depends_on` contains incomplete tasks. Workers cannot claim. | N/A |
222
247
  | **`QUEUED`** | Auto on create or parent complete | Pushed to queue/inbox. Available for worker consumption. | N/A |
223
- | **`DELIVERED`** | `rhizo listen` consumes payload | **Atomically moves into `task:<id>` DELIVERED state**. Instant transport receipt emitted to orchestrator. Mirrored to local `~/.config/rhizo/current_task.json` for turn-end hook interlocks. | 180s Receipt Timeout $
224
- | **`CLAIMED`** | `rhizo task claim <id>` / `rhizo reply` | Worker acquires monotonic fencing lease. Isolated Vine strand provisioned (`vine new <id>`). Turn-end hook blocks until work starts. | Lease expires $
225
- | **`IN_PROGRESS`** | Worker coding in strand | Enforces single-active-lease invariant. Periodic `rhizo task progress` extends lease. | Lease expires $
226
- | **`GATE_EVALUATING`**| `vine gate` | Key 1 (mechanical merge-tree) & Key 2 (live compiler/test suite) evaluated. | Exit 1 $
227
- | **`READY_TO_WEAVE`** | Both keys pass 100% | Cryptographic gate token stamped (`gate_token`). Report sent to orchestrator. | N/A |
228
- | **`COMPLETED`** | `vine weave && rhizo task complete` | Fast-forward merged into canonical trunk. Strand pruned. Locks released. **Downstream DAG dependencies automatically unblocked (`BLOCKED` $
229
- | **`ORPHANED`** | Receipt timeout or lease expired | Stalled worker detected. Increments `delivery_attempts`. If $\ge 3
248
+ | **`DELIVERED`** | `rhizo listen` consumes payload | **Atomically moves into `task:<id>` DELIVERED state**. Instant transport receipt emitted to orchestrator. Mirrored to local `~/.config/rhizo/current_task.json` for turn-end hook interlocks. | 180s Receipt Timeout $
249
+ ightarrow$ `ORPHANED` |
250
+ | **`CLAIMED`** | `rhizo task claim <id>` / `rhizo reply` | Worker acquires monotonic fencing lease. Isolated Vine strand provisioned (`vine new <id>`). Turn-end hook blocks until work starts. | Lease expires $
251
+ ightarrow$ `ORPHANED` |
252
+ | **`IN_PROGRESS`** | Worker coding in strand | Enforces single-active-lease invariant. Periodic `rhizo task progress` extends lease. | Lease expires $
253
+ ightarrow$ `ORPHANED` |
254
+ | **`GATE_EVALUATING`**| `vine submit` / `vine gate` | Key 1 (mechanical merge-tree) & Key 2 (live compiler/test suite + changelog) evaluated. | Exit 1 $\rightarrow$ `CONFLICTED`<br>Exit 2 $\rightarrow$ `GATE_FAILED` |
255
+ | **`READY_FOR_AUDIT`**| `vine submit` | Keys 1 & 2 passed. Strand submitted for independent adversarial review. | N/A |
256
+ | **`AUDIT_REJECTED`** | `vine audit reject` | Auditor rejected deliverable with recorded defect reasons. Worker returns to `IN_PROGRESS` for delta remediation. | N/A |
257
+ | **`AUDIT_RATIFIED`** | `vine audit approve` | Key 3 passed! Cryptographic `audit_token` stamped. Auditor and author identities strictly decoupled (`auditor != author`). | N/A |
258
+ | **`COMPLETED`** | `vine weave && rhizo task complete` | Fast-forward merged into canonical trunk. Strand pruned. Locks released. **Downstream DAG dependencies automatically unblocked (`BLOCKED` $\rightarrow$ `QUEUED`)!** | N/A |
259
+ | **`ORPHANED`** | Receipt timeout or lease expired | Stalled worker detected. Increments `delivery_attempts`. If $\ge 3
260
+ ightarrow$ `DEAD_LETTER`. Otherwise returns to `QUEUED`. | Escalates to operator if Dead-Lettered |
230
261
  | **`YIELDED`** | `rhizo task yield <id>` | Worker gracefully steps aside. Task returned to `QUEUED`. | N/A |
231
262
  | **`DEAD_LETTER`** | Retries exhausted ($\ge 3$) | Moved to dead-letter queue. Alerts orchestrator and operator. | Requires manual operator triage |
232
263
 
@@ -305,20 +336,24 @@ If a worker is waiting for a lease or has held a lock too long, probe its listen
305
336
  rhizo probe <worker>
306
337
  ```
307
338
 
308
- ### SOP 3: Verifying the Three-Key Gate & Pre-Weave Adversarial Audit
309
- When a worker replies indicating Key 1 & Key 2 completion:
339
+ ### SOP 3: Enforcing the Three-Key Gate & Independent Adversarial Audit
340
+ When a worker finishes implementation in their strand, they run `vine submit --author <worker>` and report readiness:
310
341
  ```json
311
342
  {
312
- "status": "gate_passed",
343
+ "status": "READY_FOR_AUDIT",
313
344
  "task_id": "task-core-ds",
314
345
  "branch": "strand/task-core-ds",
315
346
  "strand_path": "/Users/eek/Development/workspaces/myproject/task-core-ds/myproject",
316
- "key1_mechanical": "PASS",
317
- "key2_semantic": "PASS"
347
+ "author": "implementer"
318
348
  }
319
349
  ```
320
350
 
321
- The Orchestrator or designated Auditor initiates **Key 3: The Pre-Weave Adversarial Code Audit Pump** under the **Presumption of Guilt**:
351
+ > [!CRITICAL]
352
+ > **THE WORKER IS NOT THE AUDITOR**: Workers cannot audit or approve their own strands (`vine audit approve` strictly enforces `auditor != author`).
353
+ > The Lead Orchestrator dispatches an audit request to the dedicated **Adversarial Auditor** session:
354
+ > `rhizo send @auditor --subject "Audit Request: task-core-ds" --body '{"strand_path": "...", "author": "implementer"}'`
355
+
356
+ The independent Auditor initiates **Key 3: The Pre-Weave Adversarial Code Audit Pump** under the **Presumption of Guilt**:
322
357
 
323
358
  1. **Thesis Intake**: Demand the worker's **Deliverable Claim Bundle** (task contract, Two-Point Diff mapping, test evidence, negative controls).
324
359
  2. **Five-Pillar Presumption-of-Guilt Audit**:
@@ -328,13 +363,17 @@ The Orchestrator or designated Auditor initiates **Key 3: The Pre-Weave Adversar
328
363
  - **Pillar 3 (Literal Fidelity & Reference Parity)**: When duplicating functionality, porting, or executing specific operator directives, demand literal true fidelity. Reject approximations ("looks right", "good enough for happy paths") and verify edge case parity against reference specifications.
329
364
  - **Pillar 4 (Aggressive Replacement Purge)**: Ensure all superseded legacy code, fallbacks, and commented-out blocks are deleted in the strand.
330
365
  - **Pillar 5 (Structural Assertion Rigor)**: Reject partial/loose assertions (`assert "foo" in bar`). Mandate complete structural equality (`assert actual == expected`) and negative controls.
331
- 3. **The Delta Re-Pump Loop**:
332
- - If findings exist: emit `code_audit_report.md` with empirical citations. Worker fixes them in the strand.
333
- - The auditor reviews the **git diff delta** against the previous audit commit (`git diff <audit_sha>...HEAD`) and re-runs `vine gate`.
334
- - The pump repeats until **ZERO open defects of severity CRIT, HIGH, or MED remain**.
366
+ 3. **Audit Ratification or Delta Re-Pump Loop**:
367
+ - **If findings exist**: Auditor executes `vine audit reject --reason "<defects>" --auditor <auditor_name>` and reports findings to the worker. Worker remediates inside the strand and re-submits with `vine submit`.
368
+ - **The Delta Re-Pump Loop**: Auditor reviews the git delta against the previous audit commit (`git diff <audit_sha>...HEAD`) and verifies clean tests. The pump repeats until **ZERO open defects of severity CRIT, HIGH, or MED remain**.
369
+ - **When 0 defects remain**: Auditor runs:
370
+ ```bash
371
+ vine audit approve --auditor <auditor_name>
372
+ ```
373
+ This stamps a cryptographic `audit_token` and marks the strand `AUDIT_RATIFIED`. Auditor notifies orchestrator.
335
374
  4. **Weave & Unlock (Only after Key 3 Clearance)**:
336
375
  ```bash
337
- # 1. Weave the verified strand into main
376
+ # 1. Weave the verified, ratified strand into main (mechanically verifies audit_token)
338
377
  vine weave
339
378
 
340
379
  # 2. Release any held fencing locks if applicable
@@ -363,6 +402,24 @@ If an incoming message contains `[DESIGN ADDENDUM]`:
363
402
  4. If rejected:
364
403
  - Reply with counter-guidance and instruct the worker to remain aligned with original specs.
365
404
 
405
+ ### SOP 6: Dynamic Worker Repurposing & Self-Tagging Capability Handshake
406
+ When cluster capacity needs adjustment, or idle listeners from other projects are available:
407
+ 1. **Triage Cluster Listeners**:
408
+ Query active listeners across all projects with `rhizo who --all --json` to classify `projectActive`, `availableIdlePeers`, and `busyClusterPeers`.
409
+ 2. **Execute Repurposing**:
410
+ Reassign workers into the target project using `garden repurpose`:
411
+ ```bash
412
+ garden repurpose <worker> --project <target-project> --role "<role>" --tags "<tag1,tag2>"
413
+ ```
414
+ 3. **Self-Tagging Capability Handshake**:
415
+ When workers operate in heterogeneous environments (different compilers, runtimes, or test harnesses), dispatch a self-tagging offer:
416
+ ```bash
417
+ garden repurpose <worker> --project <target-project> --self-tag --expected-tags "backend,frontend,qa,audit"
418
+ ```
419
+ This sends an authenticated `SWARM_REPURPOSE_OFFER` directive payload. The recipient worker inspects its local environment, claims matching tags via `rhizo tag add`, and responds with `WORKER_READY`.
420
+ 4. **Negative Controls & Safety**:
421
+ `garden repurpose` automatically halts if a worker is currently executing an in-flight task (`BUSY`), returning exit code 1. Repurposing a busy worker requires explicit `--force` override.
422
+
366
423
  ---
367
424
 
368
425
  ## 4. Swarm Conclusion & Teardown