@axiomantic/garden 0.2.4 → 0.2.6

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.
package/SKILL.md CHANGED
@@ -103,6 +103,19 @@ Upon receiving the operator's responses:
103
103
  The primary conversation session acts as the Lead Orchestrator. The orchestrator directs, reviews, and weaves; it never performs large multi-file implementation edits directly when a worker fleet is active.
104
104
  </CRITICAL>
105
105
 
106
+ <CRITICAL>
107
+ Orchestrator Intake Gate & Non-Implementation Invariant (GVR-016):
108
+ The Lead Orchestrator is a CONDUCTOR, NOT A CODER.
109
+ Whenever the operator presents a task, feature request, bugfix, or asks to work on something:
110
+ THE ORCHESTRATOR MUST NEVER DIRECTLY JUMP INTO CODE EDITING OR IMPLEMENTATION TOOLS (e.g. `write_to_file`, `replace_file_content`).
111
+ Instead, it MUST STOP and ask the operator how they want the work routed using `ask_question`:
112
+ - Option 1 (Recommended): Enqueue to Cluster Work Queue (`rhizo enqueue queue:<project>:tasks --subject "..." --body "..."`) for background cluster workers.
113
+ - Option 2: Dispatch directly to an active cluster worker (`rhizo send <worker> --subject "..." --body "..."`).
114
+ - Option 3: Execute inline in main chat (only if the operator explicitly selects/confirms this option).
115
+
116
+ 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.
117
+ </CRITICAL>
118
+
106
119
  <INVARIANT>
107
120
  Delegation Precedence: When 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`). Harness-internal subagents (e.g. `invoke_subagent`, `Task`, `Agent`) must ONLY be used if the operator explicitly requests a "subagent" by name, or if no cluster workers exist in the cluster roster (`rhizo who`).
108
121
  </INVARIANT>
@@ -111,6 +124,13 @@ Delegation Precedence: When instructed to "delegate", "assign", or "dispatch" wo
111
124
  Zero Theatrical Dialogue: Every dialectical assertion must be substantiated with empirical evidence obtained through tool calls (file reading, test executions, benchmarks, or AST inspections). Theoretical roleplay without evidence is rejected.
112
125
  </INVARIANT>
113
126
 
127
+ <CRITICAL>
128
+ Worker Autonomous Execution Invariant (GVR-017):
129
+ Swarm workers are sovereign, autonomous implementers, not passive chatbots.
130
+ When 'rhizo listen' delivers an incoming task and exits, workers MUST NOT wait for an operator prompt or ask "Shall I begin?".
131
+ 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.
132
+ </CRITICAL>
133
+
114
134
  <INVARIANT>
115
135
  Never merge code into the canonical trunk without a verified Two-Key Gate pass ('vine gate' exit code 0) inside an isolated Rift strand.
116
136
  </INVARIANT>
@@ -145,6 +165,8 @@ Context compaction purges detailed operational invariants, ceremony rules, and p
145
165
  2. **Maintain Runtime State**: Keep this exact block in the working context:
146
166
  <!-- SWARM_RUNTIME_STATE: DO NOT DISCARD OR ABBREVIATE IN COMPACTION -->
147
167
  - AGENT_NAME: <codename> (Role: <role>)
168
+ - AGENT_ROLE: Lead Orchestrator (NON-IMPLEMENTING CONDUCTOR)
169
+ - INTAKE_GATE: MANDATORY_ASK (Never implement directly; ask to enqueue vs dispatch vs inline)
148
170
  - WORKSPACE_MODE: Root Trunk | Strand (<path>)
149
171
  - ACTIVE_STRAND: <branch> (Parent: <parent_branch>)
150
172
  - ACTIVE_PEERS:
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiomantic/garden",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "Multi-Agent Swarm Orchestration, Empirical Dialectics & Ceremonies on top of Rhizo & Vine",
5
5
  "main": "bin/run.js",
6
6
  "bin": {
@@ -95,6 +95,113 @@ Upon receiving the operator's responses:
95
95
  5. Register the orchestrator's presence (`rhizo open orchestrator`) and arm the listener.
96
96
  6. Poll or await cluster readiness gate (`rhizo who --json`) before proceeding to Phase 3.
97
97
 
98
+
99
+ ---
100
+
101
+ ## Unified Work Item State Machine (WISM)
102
+
103
+ 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.
104
+
105
+ ```mermaid
106
+ stateDiagram-v2
107
+ [*] --> DRAFTED : rhizo task create <id>
108
+ DRAFTED --> BLOCKED : Unmet DAG dependencies (depends_on)
109
+ DRAFTED --> QUEUED : Zero unmet dependencies
110
+ BLOCKED --> QUEUED : Parent task COMPLETED (Auto-promoted by Lua engine)
111
+
112
+ QUEUED --> DELIVERED : Listener pops message (Transport Receipt emitted)
113
+ DELIVERED --> CLAIMED : Worker acknowledges (Acquires monotonic lease)
114
+ DELIVERED --> ORPHANED : Receipt timeout (180s without claim)
115
+
116
+ CLAIMED --> IN_PROGRESS : Worker provisions strand (vine new <id>)
117
+ IN_PROGRESS --> IN_PROGRESS : Progress reported (rhizo task progress, lease extended)
118
+ IN_PROGRESS --> GATE_EVALUATING : Verification initiated (vine gate)
119
+ IN_PROGRESS --> YIELDED : rhizo task yield (Returned to pool)
120
+ IN_PROGRESS --> ORPHANED : Lease expires without progress
121
+
122
+ GATE_EVALUATING --> IN_PROGRESS : Gate failed (Tests red or merge conflict)
123
+ GATE_EVALUATING --> READY_TO_WEAVE : Two-Key Gate PASSED (Cryptographic gate token stamped)
124
+
125
+ READY_TO_WEAVE --> COMPLETED : vine weave && rhizo task complete (Unblocks downstream DAG children)
126
+
127
+ ORPHANED --> QUEUED : Re-queued for retry (attempts < 3)
128
+ ORPHANED --> DEAD_LETTER : Max delivery retries exceeded (attempts >= 3)
129
+ YIELDED --> QUEUED : Returned to pool
130
+
131
+ COMPLETED --> [*]
132
+ DEAD_LETTER --> [*]
133
+ ```
134
+
135
+ ### ASCII State Transition Reference (LLM Fast-Path)
136
+
137
+ ```text
138
+ [rhizo task create]
139
+ │
140
+ ▼
141
+ +---------+ Unmet deps
142
+ | DRAFTED | ──────────────────► [ BLOCKED ]
143
+ +---------+ │
144
+ │ Zero deps │ Parent task COMPLETED
145
+ ▼ ▼
146
+ +---------+ ◄───────────────────────+
147
+ | QUEUED |
148
+ +---------+
149
+ │
150
+ │ rhizo listen pops task (Transport Receipt emitted)
151
+ ▼
152
+ +-----------+ 180s Receipt Timeout
153
+ | DELIVERED | ─────────────────────────────────► [ ORPHANED ]
154
+ +-----------+ │
155
+ │ │ Attempts >= 3
156
+ │ rhizo task claim / rhizo reply ▼
157
+ ▼ [ DEAD_LETTER ]
158
+ +---------+
159
+ | CLAIMED |
160
+ +---------+
161
+ │
162
+ │ vine new <task_id> (Provision strand)
163
+ ▼
164
+ +-------------+ Lease expires
165
+ | IN_PROGRESS | ────────────────────────────────► [ ORPHANED ]
166
+ +-------------+
167
+ │ ▲
168
+ │ vine │ Gate fails
169
+ │ gate │ (Tests red or conflict)
170
+ ▼ │
171
+ +-----------------+
172
+ | GATE_EVALUATING |
173
+ +-----------------+
174
+ │
175
+ │ Two-Key Gate PASSED (Key 1 merge-tree + Key 2 live test suite green)
176
+ ▼
177
+ +----------------+
178
+ | READY_TO_WEAVE |
179
+ +----------------+
180
+ │
181
+ │ vine weave && rhizo task complete
182
+ ▼
183
+ +-----------+
184
+ | COMPLETED | ──► Auto-promotes BLOCKED child tasks to QUEUED!
185
+ +-----------+
186
+ ```
187
+
188
+ ### State Definitions & Invariants
189
+
190
+ | State | CLI Trigger | Atomic Action & Side Effects | Timeout / Failure Escalation |
191
+ | :--- | :--- | :--- | :--- |
192
+ | **`DRAFTED`** | `rhizo task create <id> --title <t>` | Creates immutable task contract hash `task:<id>` in Redis. | N/A |
193
+ | **`BLOCKED`** | Evaluated on create | Stamped if `depends_on` contains incomplete tasks. Workers cannot claim. | N/A |
194
+ | **`QUEUED`** | Auto on create or parent complete | Pushed to queue/inbox. Available for worker consumption. | N/A |
195
+ | **`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 $
196
+ | **`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 $
197
+ | **`IN_PROGRESS`** | Worker coding in strand | Enforces single-active-lease invariant. Periodic `rhizo task progress` extends lease. | Lease expires $
198
+ | **`GATE_EVALUATING`**| `vine gate` | Key 1 (mechanical merge-tree) & Key 2 (live compiler/test suite) evaluated. | Exit 1 $
199
+ | **`READY_TO_WEAVE`** | Both keys pass 100% | Cryptographic gate token stamped (`gate_token`). Report sent to orchestrator. | N/A |
200
+ | **`COMPLETED`** | `vine weave && rhizo task complete` | Fast-forward merged into canonical trunk. Strand pruned. Locks released. **Downstream DAG dependencies automatically unblocked (`BLOCKED` $
201
+ | **`ORPHANED`** | Receipt timeout or lease expired | Stalled worker detected. Increments `delivery_attempts`. If $\ge 3
202
+ | **`YIELDED`** | `rhizo task yield <id>` | Worker gracefully steps aside. Task returned to `QUEUED`. | N/A |
203
+ | **`DEAD_LETTER`** | Retries exhausted ($\ge 3$) | Moved to dead-letter queue. Alerts orchestrator and operator. | Requires manual operator triage |
204
+
98
205
  ---
99
206
 
100
207
  ## 3. Core Operational Invariants
@@ -103,6 +210,19 @@ Upon receiving the operator's responses:
103
210
  The primary conversation session acts as the Lead Orchestrator. The orchestrator directs, reviews, and weaves; it never performs large multi-file implementation edits directly when a worker fleet is active.
104
211
  </CRITICAL>
105
212
 
213
+ <CRITICAL>
214
+ Orchestrator Intake Gate & Non-Implementation Invariant (GVR-016):
215
+ The Lead Orchestrator is a CONDUCTOR, NOT A CODER.
216
+ Whenever the operator presents a task, feature request, bugfix, or asks to work on something:
217
+ THE ORCHESTRATOR MUST NEVER DIRECTLY JUMP INTO CODE EDITING OR IMPLEMENTATION TOOLS (e.g. `write_to_file`, `replace_file_content`).
218
+ Instead, it MUST STOP and ask the operator how they want the work routed using `ask_question`:
219
+ - Option 1 (Recommended): Enqueue to Cluster Work Queue (`rhizo enqueue queue:<project>:tasks --subject "..." --body "..."`) for background cluster workers.
220
+ - Option 2: Dispatch directly to an active cluster worker (`rhizo send <worker> --subject "..." --body "..."`).
221
+ - Option 3: Execute inline in main chat (only if the operator explicitly selects/confirms this option).
222
+
223
+ 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.
224
+ </CRITICAL>
225
+
106
226
  <INVARIANT>
107
227
  Delegation Precedence: When 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`). Harness-internal subagents (e.g. `invoke_subagent`, `Task`, `Agent`) must ONLY be used if the operator explicitly requests a "subagent" by name, or if no cluster workers exist in the cluster roster (`rhizo who`).
108
228
  </INVARIANT>
@@ -111,6 +231,13 @@ Delegation Precedence: When instructed to "delegate", "assign", or "dispatch" wo
111
231
  Zero Theatrical Dialogue: Every dialectical assertion must be substantiated with empirical evidence obtained through tool calls (file reading, test executions, benchmarks, or AST inspections). Theoretical roleplay without evidence is rejected.
112
232
  </INVARIANT>
113
233
 
234
+ <CRITICAL>
235
+ Worker Autonomous Execution Invariant (GVR-017):
236
+ Swarm workers are sovereign, autonomous implementers, not passive chatbots.
237
+ When 'rhizo listen' delivers an incoming task and exits, workers MUST NOT wait for an operator prompt or ask "Shall I begin?".
238
+ 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.
239
+ </CRITICAL>
240
+
114
241
  <INVARIANT>
115
242
  Never merge code into the canonical trunk without a verified Two-Key Gate pass ('vine gate' exit code 0) inside an isolated Rift strand.
116
243
  </INVARIANT>
@@ -145,6 +272,8 @@ Context compaction purges detailed operational invariants, ceremony rules, and p
145
272
  2. **Maintain Runtime State**: Keep this exact block in the working context:
146
273
  <!-- SWARM_RUNTIME_STATE: DO NOT DISCARD OR ABBREVIATE IN COMPACTION -->
147
274
  - AGENT_NAME: <codename> (Role: <role>)
275
+ - AGENT_ROLE: Lead Orchestrator (NON-IMPLEMENTING CONDUCTOR)
276
+ - INTAKE_GATE: MANDATORY_ASK (Never implement directly; ask to enqueue vs dispatch vs inline)
148
277
  - WORKSPACE_MODE: Root Trunk | Strand (<path>)
149
278
  - ACTIVE_STRAND: <branch> (Parent: <parent_branch>)
150
279
  - ACTIVE_PEERS:
@@ -28,7 +28,14 @@ description: "Generates and formats X distinct copy-pasteable bootstrap prompts
28
28
  Inside worker prompts, `rhizo listen <name>` must always be presented as a single-shot, blocking foreground command with zero timeout (infinite wait).
29
29
  NEVER wrap `rhizo listen` in a shell loop (`while true; do rhizo listen; done` or `until rhizo listen; do ...`). Loops trap message payloads inside unmonitored subshell logs and hang coordination.
30
30
  </CRITICAL>
31
- 4. **Zero Dirty Commits**:
31
+ 4. **Worker Autonomous Execution Invariant (GVR-017)**:
32
+ <CRITICAL>
33
+ Swarm workers operate as sovereign, autonomous implementers, not passive chatbots.
34
+ When 'rhizo listen' unblocks and exits, a directive has been delivered!
35
+ Workers MUST NOT wait for operator intervention or ask "Shall I start?".
36
+ 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.
37
+ </CRITICAL>
38
+ 5. **Zero Dirty Commits**:
32
39
  - Never stage coordination state (`.rhizo.*`, `*.lock`, `.vine.json`, `workspaces/`) into Git.
33
40
 
34
41
  ---
@@ -95,8 +102,15 @@ The Orchestrator presents the generated prompt blocks to the operator with clear
95
102
  - `cd "<project_dir>"`
96
103
  - `export RHIZO_AGENT_NAME="<name>"`
97
104
  - `rhizo open "<name>" "<tags>"`
105
+ - `rhizo hook install --codex --agent "<name>"` (if running in Codex CLI/Desktop)
98
106
  - `rhizo listen "<name>"` (blocking foreground command with infinite wait)
99
- 5. **Readiness Prompt**:
107
+ 5. **Scheduled Health Check Template (For Codex / Antigravity / Schedulers)**:
108
+ If workers configure a recurring 15-minute listener health check, prompts include the bulletproof 4-step template:
109
+ - STEP 1: Inspect completed subagents/tasks for unhandled delivered tasks and execute them immediately (never stay quiet with pending work).
110
+ - STEP 2: Inspect active tasks to verify a listener is currently running, and re-arm if missing.
111
+ - STEP 3: Run `rhizo probe <name> --json` and drain any inbox backlog.
112
+ - STEP 4: Stay quiet ONLY when a listener is actively running AND no delivered tasks are pending.
113
+ 6. **Readiness Prompt**:
100
114
  Instruct the operator: *"Once you have pasted these prompts and the sessions are listening, tell me here (or I will automatically detect them online via `rhizo who`), and we will proceed to Phase 3 (Dialectical Deliberation)."*
101
115
 
102
116
  ### Step 3: Verify Cluster Readiness Gate
@@ -128,3 +142,110 @@ for worker in $(python3 -c "import json; [print(w['name']) for w in json.load(op
128
142
  rhizo close "$worker" 2>/dev/null || true
129
143
  done
130
144
  ```
145
+
146
+ ---
147
+
148
+ ## Unified Work Item State Machine (WISM)
149
+
150
+ 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.
151
+
152
+ ```mermaid
153
+ stateDiagram-v2
154
+ [*] --> DRAFTED : rhizo task create <id>
155
+ DRAFTED --> BLOCKED : Unmet DAG dependencies (depends_on)
156
+ DRAFTED --> QUEUED : Zero unmet dependencies
157
+ BLOCKED --> QUEUED : Parent task COMPLETED (Auto-promoted by Lua engine)
158
+
159
+ QUEUED --> DELIVERED : Listener pops message (Transport Receipt emitted)
160
+ DELIVERED --> CLAIMED : Worker acknowledges (Acquires monotonic lease)
161
+ DELIVERED --> ORPHANED : Receipt timeout (180s without claim)
162
+
163
+ CLAIMED --> IN_PROGRESS : Worker provisions strand (vine new <id>)
164
+ IN_PROGRESS --> IN_PROGRESS : Progress reported (rhizo task progress, lease extended)
165
+ IN_PROGRESS --> GATE_EVALUATING : Verification initiated (vine gate)
166
+ IN_PROGRESS --> YIELDED : rhizo task yield (Returned to pool)
167
+ IN_PROGRESS --> ORPHANED : Lease expires without progress
168
+
169
+ GATE_EVALUATING --> IN_PROGRESS : Gate failed (Tests red or merge conflict)
170
+ GATE_EVALUATING --> READY_TO_WEAVE : Two-Key Gate PASSED (Cryptographic gate token stamped)
171
+
172
+ READY_TO_WEAVE --> COMPLETED : vine weave && rhizo task complete (Unblocks downstream DAG children)
173
+
174
+ ORPHANED --> QUEUED : Re-queued for retry (attempts < 3)
175
+ ORPHANED --> DEAD_LETTER : Max delivery retries exceeded (attempts >= 3)
176
+ YIELDED --> QUEUED : Returned to pool
177
+
178
+ COMPLETED --> [*]
179
+ DEAD_LETTER --> [*]
180
+ ```
181
+
182
+ ### ASCII State Transition Reference (LLM Fast-Path)
183
+
184
+ ```text
185
+ [rhizo task create]
186
+ │
187
+ ▼
188
+ +---------+ Unmet deps
189
+ | DRAFTED | ──────────────────► [ BLOCKED ]
190
+ +---------+ │
191
+ │ Zero deps │ Parent task COMPLETED
192
+ ▼ ▼
193
+ +---------+ ◄───────────────────────+
194
+ | QUEUED |
195
+ +---------+
196
+ │
197
+ │ rhizo listen pops task (Transport Receipt emitted)
198
+ ▼
199
+ +-----------+ 180s Receipt Timeout
200
+ | DELIVERED | ─────────────────────────────────► [ ORPHANED ]
201
+ +-----------+ │
202
+ │ │ Attempts >= 3
203
+ │ rhizo task claim / rhizo reply ▼
204
+ ▼ [ DEAD_LETTER ]
205
+ +---------+
206
+ | CLAIMED |
207
+ +---------+
208
+ │
209
+ │ vine new <task_id> (Provision strand)
210
+ ▼
211
+ +-------------+ Lease expires
212
+ | IN_PROGRESS | ────────────────────────────────► [ ORPHANED ]
213
+ +-------------+
214
+ │ ▲
215
+ │ vine │ Gate fails
216
+ │ gate │ (Tests red or conflict)
217
+ ▼ │
218
+ +-----------------+
219
+ | GATE_EVALUATING |
220
+ +-----------------+
221
+ │
222
+ │ Two-Key Gate PASSED (Key 1 merge-tree + Key 2 live test suite green)
223
+ ▼
224
+ +----------------+
225
+ | READY_TO_WEAVE |
226
+ +----------------+
227
+ │
228
+ │ vine weave && rhizo task complete
229
+ ▼
230
+ +-----------+
231
+ | COMPLETED | ──► Auto-promotes BLOCKED child tasks to QUEUED!
232
+ +-----------+
233
+ ```
234
+
235
+ ### State Definitions & Invariants
236
+
237
+ | State | CLI Trigger | Atomic Action & Side Effects | Timeout / Failure Escalation |
238
+ | :--- | :--- | :--- | :--- |
239
+ | **`DRAFTED`** | `rhizo task create <id> --title <t>` | Creates immutable task contract hash `task:<id>` in Redis. | N/A |
240
+ | **`BLOCKED`** | Evaluated on create | Stamped if `depends_on` contains incomplete tasks. Workers cannot claim. | N/A |
241
+ | **`QUEUED`** | Auto on create or parent complete | Pushed to queue/inbox. Available for worker consumption. | N/A |
242
+ | **`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 $
243
+ | **`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 $
244
+ | **`IN_PROGRESS`** | Worker coding in strand | Enforces single-active-lease invariant. Periodic `rhizo task progress` extends lease. | Lease expires $
245
+ | **`GATE_EVALUATING`**| `vine gate` | Key 1 (mechanical merge-tree) & Key 2 (live compiler/test suite) evaluated. | Exit 1 $
246
+ | **`READY_TO_WEAVE`** | Both keys pass 100% | Cryptographic gate token stamped (`gate_token`). Report sent to orchestrator. | N/A |
247
+ | **`COMPLETED`** | `vine weave && rhizo task complete` | Fast-forward merged into canonical trunk. Strand pruned. Locks released. **Downstream DAG dependencies automatically unblocked (`BLOCKED` $
248
+ | **`ORPHANED`** | Receipt timeout or lease expired | Stalled worker detected. Increments `delivery_attempts`. If $\ge 3
249
+ | **`YIELDED`** | `rhizo task yield <id>` | Worker gracefully steps aside. Task returned to `QUEUED`. | N/A |
250
+ | **`DEAD_LETTER`** | Retries exhausted ($\ge 3$) | Moved to dead-letter queue. Alerts orchestrator and operator. | Requires manual operator triage |
251
+
@@ -23,6 +23,19 @@ Whenever instructed to "delegate", "assign", or "dispatch" work, the Lead Orches
23
23
  NEVER spawn harness-internal subagents (e.g. `invoke_subagent`, `Task`) when asked to delegate, UNLESS the operator explicitly specifies the word "subagent". Cluster workers running in dedicated sessions are the primary execution vehicle.
24
24
  </CRITICAL>
25
25
 
26
+ <CRITICAL>
27
+ Orchestrator Intake Gate & Non-Implementation Invariant (GVR-016):
28
+ The Lead Orchestrator is a CONDUCTOR, NOT A CODER.
29
+ Whenever the operator presents a task, feature request, bugfix, or asks to work on something:
30
+ THE ORCHESTRATOR MUST NEVER DIRECTLY JUMP INTO CODE EDITING OR IMPLEMENTATION TOOLS (e.g. `write_to_file`, `replace_file_content`).
31
+ Instead, it MUST STOP and ask the operator how they want the work routed using `ask_question`:
32
+ - Option 1 (Recommended): Enqueue to Cluster Work Queue (`rhizo enqueue queue:<project>:tasks --subject "..." --body "..."`) for background cluster workers.
33
+ - Option 2: Dispatch directly to an active cluster worker (`rhizo send <worker> --subject "..." --body "..."`).
34
+ - Option 3: Execute inline in main chat (only if the operator explicitly selects/confirms this option).
35
+
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.
37
+ </CRITICAL>
38
+
26
39
  <CRITICAL>
27
40
  Compaction Preservation Rider & Post-Compact Invariant (GVR-010):
28
41
  Context compaction purges detailed operational invariants, ceremony rules, and protocol mechanics from working memory.
@@ -49,6 +62,8 @@ Context compaction purges detailed operational invariants, ceremony rules, and p
49
62
  2. **Maintain Runtime State**: Keep this exact block in the working context:
50
63
  <!-- SWARM_RUNTIME_STATE: DO NOT DISCARD OR ABBREVIATE IN COMPACTION -->
51
64
  - AGENT_NAME: <codename> (Role: Lead Orchestrator)
65
+ - AGENT_ROLE: Lead Orchestrator (NON-IMPLEMENTING CONDUCTOR)
66
+ - INTAKE_GATE: MANDATORY_ASK (Never implement directly; ask to enqueue vs dispatch vs inline)
52
67
  - WORKSPACE_MODE: Root Trunk (/Users/eek/Development/<project>)
53
68
  - ACTIVE_STRAND: canonical trunk
54
69
  - ACTIVE_PEERS:
@@ -102,25 +117,111 @@ In harnesses supporting `schedule` (e.g. Google Antigravity), arm a debounced wa
102
117
 
103
118
  ---
104
119
 
105
- ## 2. The Runtime Governance Loop
120
+ ## Unified Work Item State Machine (WISM)
121
+
122
+ 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.
106
123
 
107
124
  ```mermaid
108
- flowchart TD
109
- Start([Start Task from Plan]) --> Dispatch["Dispatch Task via rhizo send / enqueue"]
110
- Dispatch --> Wait["Wait for Worker rhizo reply (Two-Key Gate Report)"]
111
- Wait --> Decision{Did Worker Pass Two-Key Gate?}
112
- Decision -->|NO / Blocked| Remediate["Dispatch Fix Task to Auditor / Implementer"]
113
- Remediate --> Wait
114
- Decision -->|YES| Weave["Execute vine weave into Canonical Trunk"]
115
- Weave --> Update["Update implementation_plan.md Checkbox & Harness To-Do"]
116
- Update --> CheckAddenda{Emergent Design Addendum Filed?}
117
- CheckAddenda -->|YES| Ratify["Review, Ratify, Update design.md & plan"]
118
- CheckAddenda -->|NO| NextTask{More Tasks in Plan?}
119
- Ratify --> NextTask
120
- NextTask -->|YES| Start
121
- NextTask -->|NO| Finish([Mission Accomplished / Teardown Swarm])
125
+ stateDiagram-v2
126
+ [*] --> DRAFTED : rhizo task create <id>
127
+ DRAFTED --> BLOCKED : Unmet DAG dependencies (depends_on)
128
+ DRAFTED --> QUEUED : Zero unmet dependencies
129
+ BLOCKED --> QUEUED : Parent task COMPLETED (Auto-promoted by Lua engine)
130
+
131
+ QUEUED --> DELIVERED : Listener pops message (Transport Receipt emitted)
132
+ DELIVERED --> CLAIMED : Worker acknowledges (Acquires monotonic lease)
133
+ DELIVERED --> ORPHANED : Receipt timeout (180s without claim)
134
+
135
+ CLAIMED --> IN_PROGRESS : Worker provisions strand (vine new <id>)
136
+ IN_PROGRESS --> IN_PROGRESS : Progress reported (rhizo task progress, lease extended)
137
+ IN_PROGRESS --> GATE_EVALUATING : Verification initiated (vine gate)
138
+ IN_PROGRESS --> YIELDED : rhizo task yield (Returned to pool)
139
+ IN_PROGRESS --> ORPHANED : Lease expires without progress
140
+
141
+ GATE_EVALUATING --> IN_PROGRESS : Gate failed (Tests red or merge conflict)
142
+ GATE_EVALUATING --> READY_TO_WEAVE : Two-Key Gate PASSED (Cryptographic gate token stamped)
143
+
144
+ READY_TO_WEAVE --> COMPLETED : vine weave && rhizo task complete (Unblocks downstream DAG children)
145
+
146
+ ORPHANED --> QUEUED : Re-queued for retry (attempts < 3)
147
+ ORPHANED --> DEAD_LETTER : Max delivery retries exceeded (attempts >= 3)
148
+ YIELDED --> QUEUED : Returned to pool
149
+
150
+ COMPLETED --> [*]
151
+ DEAD_LETTER --> [*]
122
152
  ```
123
153
 
154
+ ### ASCII State Transition Reference (LLM Fast-Path)
155
+
156
+ ```text
157
+ [rhizo task create]
158
+ │
159
+ ▼
160
+ +---------+ Unmet deps
161
+ | DRAFTED | ──────────────────► [ BLOCKED ]
162
+ +---------+ │
163
+ │ Zero deps │ Parent task COMPLETED
164
+ ▼ ▼
165
+ +---------+ ◄───────────────────────+
166
+ | QUEUED |
167
+ +---------+
168
+ │
169
+ │ rhizo listen pops task (Transport Receipt emitted)
170
+ ▼
171
+ +-----------+ 180s Receipt Timeout
172
+ | DELIVERED | ─────────────────────────────────► [ ORPHANED ]
173
+ +-----------+ │
174
+ │ │ Attempts >= 3
175
+ │ rhizo task claim / rhizo reply ▼
176
+ ▼ [ DEAD_LETTER ]
177
+ +---------+
178
+ | CLAIMED |
179
+ +---------+
180
+ │
181
+ │ vine new <task_id> (Provision strand)
182
+ ▼
183
+ +-------------+ Lease expires
184
+ | IN_PROGRESS | ────────────────────────────────► [ ORPHANED ]
185
+ +-------------+
186
+ │ ▲
187
+ │ vine │ Gate fails
188
+ │ gate │ (Tests red or conflict)
189
+ ▼ │
190
+ +-----------------+
191
+ | GATE_EVALUATING |
192
+ +-----------------+
193
+ │
194
+ │ Two-Key Gate PASSED (Key 1 merge-tree + Key 2 live test suite green)
195
+ ▼
196
+ +----------------+
197
+ | READY_TO_WEAVE |
198
+ +----------------+
199
+ │
200
+ │ vine weave && rhizo task complete
201
+ ▼
202
+ +-----------+
203
+ | COMPLETED | ──► Auto-promotes BLOCKED child tasks to QUEUED!
204
+ +-----------+
205
+ ```
206
+
207
+ ### State Definitions & Invariants
208
+
209
+ | State | CLI Trigger | Atomic Action & Side Effects | Timeout / Failure Escalation |
210
+ | :--- | :--- | :--- | :--- |
211
+ | **`DRAFTED`** | `rhizo task create <id> --title <t>` | Creates immutable task contract hash `task:<id>` in Redis. | N/A |
212
+ | **`BLOCKED`** | Evaluated on create | Stamped if `depends_on` contains incomplete tasks. Workers cannot claim. | N/A |
213
+ | **`QUEUED`** | Auto on create or parent complete | Pushed to queue/inbox. Available for worker consumption. | N/A |
214
+ | **`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 $
215
+ | **`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 $
216
+ | **`IN_PROGRESS`** | Worker coding in strand | Enforces single-active-lease invariant. Periodic `rhizo task progress` extends lease. | Lease expires $
217
+ | **`GATE_EVALUATING`**| `vine gate` | Key 1 (mechanical merge-tree) & Key 2 (live compiler/test suite) evaluated. | Exit 1 $
218
+ | **`READY_TO_WEAVE`** | Both keys pass 100% | Cryptographic gate token stamped (`gate_token`). Report sent to orchestrator. | N/A |
219
+ | **`COMPLETED`** | `vine weave && rhizo task complete` | Fast-forward merged into canonical trunk. Strand pruned. Locks released. **Downstream DAG dependencies automatically unblocked (`BLOCKED` $
220
+ | **`ORPHANED`** | Receipt timeout or lease expired | Stalled worker detected. Increments `delivery_attempts`. If $\ge 3
221
+ | **`YIELDED`** | `rhizo task yield <id>` | Worker gracefully steps aside. Task returned to `QUEUED`. | N/A |
222
+ | **`DEAD_LETTER`** | Retries exhausted ($\ge 3$) | Moved to dead-letter queue. Alerts orchestrator and operator. | Requires manual operator triage |
223
+
224
+
124
225
  ---
125
226
 
126
227
  ## 3. Standard Operating Procedures