@wowok/skills 1.0.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.
Files changed (70) hide show
  1. package/README.md +156 -0
  2. package/dist/cli.d.ts +3 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +177 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/index.d.ts +3 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +19 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/skills.d.ts +5 -0
  11. package/dist/skills.d.ts.map +1 -0
  12. package/dist/skills.js +46 -0
  13. package/dist/skills.js.map +1 -0
  14. package/dist/types.d.ts +9 -0
  15. package/dist/types.d.ts.map +1 -0
  16. package/dist/types.js +3 -0
  17. package/dist/types.js.map +1 -0
  18. package/examples/Insurance/Insurance.md +594 -0
  19. package/examples/Insurance/Insurance_TestResults.md +481 -0
  20. package/examples/Insurance/insurance_complete_guard_v1.json +50 -0
  21. package/examples/MyShop/MyShop.md +1353 -0
  22. package/examples/MyShop/MyShop_TestResults.md +1003 -0
  23. package/examples/MyShop_Advanced/MyShop_Advanced.md +1898 -0
  24. package/examples/MyShop_Advanced/MyShop_Advanced_MerchantSystem_TestResults.md +1297 -0
  25. package/examples/MyShop_Advanced/MyShop_Advanced_OrderFlow_TestResults.md +743 -0
  26. package/examples/MyShop_Advanced/machine_nodes.json +222 -0
  27. package/examples/ThreeBody_Signature/ThreeBody_Signature.md +776 -0
  28. package/examples/ThreeBody_Signature/ThreeBody_Signature_TestResults.md +599 -0
  29. package/examples/Travel/Travel.md +1157 -0
  30. package/examples/Travel/Travel_TestResults.md +743 -0
  31. package/examples/Travel/calc-weather-timestamps.js +8 -0
  32. package/examples/Travel/travel_machine_v2_export.json +104 -0
  33. package/examples/Travel/weather_check_guard_v1.json +51 -0
  34. package/package.json +56 -0
  35. package/schemas/onchain_operations/_common.md +236 -0
  36. package/schemas/onchain_operations/_index.md +22 -0
  37. package/schemas/onchain_operations/allocation.md +50 -0
  38. package/schemas/onchain_operations/arbitration.md +95 -0
  39. package/schemas/onchain_operations/contact.md +36 -0
  40. package/schemas/onchain_operations/demand.md +52 -0
  41. package/schemas/onchain_operations/gen_passport.md +43 -0
  42. package/schemas/onchain_operations/guard.md +136 -0
  43. package/schemas/onchain_operations/machine.md +70 -0
  44. package/schemas/onchain_operations/order.md +57 -0
  45. package/schemas/onchain_operations/payment.md +32 -0
  46. package/schemas/onchain_operations/permission.md +57 -0
  47. package/schemas/onchain_operations/personal.md +59 -0
  48. package/schemas/onchain_operations/progress.md +35 -0
  49. package/schemas/onchain_operations/repository.md +81 -0
  50. package/schemas/onchain_operations/reward.md +40 -0
  51. package/schemas/onchain_operations/service.md +104 -0
  52. package/schemas/onchain_operations/treasury.md +74 -0
  53. package/schemas/schema-account_operation.md +402 -0
  54. package/schemas/schema-guard2file.md +153 -0
  55. package/schemas/schema-local_info_operation.md +160 -0
  56. package/schemas/schema-local_mark_operation.md +148 -0
  57. package/schemas/schema-machineNode2file.md +155 -0
  58. package/schemas/schema-messenger_operation.md +547 -0
  59. package/schemas/schema-onchain_events.md +201 -0
  60. package/schemas/schema-onchain_table_data.md +334 -0
  61. package/schemas/schema-query_toolkit.md +375 -0
  62. package/schemas/schema-wip_file.md +240 -0
  63. package/schemas/schema-wowok_buildin_info.md +296 -0
  64. package/scripts/install.js +113 -0
  65. package/wowok-build/SKILL.md +606 -0
  66. package/wowok-guard/SKILL.md +374 -0
  67. package/wowok-machine/SKILL.md +512 -0
  68. package/wowok-order/SKILL.md +499 -0
  69. package/wowok-safety/SKILL.md +381 -0
  70. package/wowok-tools/SKILL.md +635 -0
@@ -0,0 +1,512 @@
1
+ ---
2
+ name: wowok-machine
3
+ description: |
4
+ WoWok Machine workflow design — defines multi-step workflows (state machines)
5
+ for order processing. Machines control how orders progress through stages,
6
+ who can advance them, and what conditions must be met at each step.
7
+
8
+ Use this skill when designing or modifying Machine workflows, creating
9
+ Progress tracking, or troubleshooting workflow advancement issues.
10
+ when_to_use:
11
+ - User wants to create or modify a Machine workflow
12
+ - User asks about workflow steps, state transitions, or progress
13
+ - User needs to design order processing pipelines
14
+ - User mentions "machine", "workflow", "progress", "state machine", "pipeline"
15
+ ---
16
+
17
+ # WoWok Machine Workflow Design
18
+
19
+ ## What is a Machine?
20
+
21
+ A Machine is a **workflow template** that defines how orders progress through stages. It's a directed graph where:
22
+ - **Nodes** = stages/states in the workflow
23
+ - **Forwards** = allowed transitions between nodes
24
+ - **Guards** = conditions that must be met to advance
25
+ - **Pairs** = data fields tracked at each node
26
+
27
+ ## Machine Structure
28
+
29
+ ```
30
+ Machine {
31
+ service: "<service_id>", // Which Service this Machine belongs to
32
+ guard: "<guard_id>", // Guard for workflow validation
33
+ node: {
34
+ op: "set",
35
+ nodes: [
36
+ {
37
+ name: "<node_name>", // Unique node identifier
38
+ pairs: [ // Data fields at this node
39
+ { name: "<field>", value_type: "<type>", description: "..." }
40
+ ],
41
+ forwards: [ // Allowed next nodes
42
+ { name: "<next_node>", guard: "<guard_id>" }
43
+ ],
44
+ guard: "<guard_id>", // Guard for entering this node
45
+ threshold: <number> // Required signers to advance
46
+ }
47
+ ],
48
+ bReplace: true
49
+ }
50
+ }
51
+ ```
52
+
53
+ ## Machine Node Design Rules
54
+
55
+ ### Rule 1: Every Node Needs a Unique Name
56
+ Node names are identifiers. Use descriptive names like "pending", "in_progress", "review", "completed".
57
+
58
+ ### Rule 2: Forwards Define the Graph
59
+ Each node's `forwards` array defines which nodes can be reached next. A node without forwards is a terminal/end state.
60
+
61
+ ### Rule 3: Guards Control Transitions
62
+ Each forward can have a `guard` that must pass before the transition is allowed. This enables conditional workflows.
63
+
64
+ ### Rule 4: Pairs Define Node Data
65
+ Each node's `pairs` define what data is tracked at that stage. Different nodes can track different data.
66
+
67
+ ### Rule 5: Threshold Controls Multi-Sig
68
+ The `threshold` field defines how many signers must approve to advance from this node. Use for multi-party approval workflows.
69
+
70
+ ## Common Workflow Patterns
71
+
72
+ ### Pattern 1: Linear Pipeline
73
+ ```
74
+ Start → Step1 → Step2 → Step3 → Done
75
+ ```
76
+ Simple sequential workflow. Each node forwards to exactly one next node.
77
+
78
+ ```
79
+ nodes: [
80
+ { name: "pending", forwards: [{ name: "in_progress" }] },
81
+ { name: "in_progress", forwards: [{ name: "review" }] },
82
+ { name: "review", forwards: [{ name: "completed" }] },
83
+ { name: "completed", forwards: [] }
84
+ ]
85
+ ```
86
+
87
+ ### Pattern 2: Branching Workflow
88
+ ```
89
+ → Approved → Completed
90
+ Start → Review
91
+ → Rejected → Revision → Review
92
+ ```
93
+ Conditional branching based on Guard validation.
94
+
95
+ ```
96
+ nodes: [
97
+ { name: "review", forwards: [
98
+ { name: "approved", guard: "<approval_guard>" },
99
+ { name: "rejected", guard: "<rejection_guard>" }
100
+ ]},
101
+ { name: "approved", forwards: [{ name: "completed" }] },
102
+ { name: "rejected", forwards: [{ name: "revision" }] },
103
+ { name: "revision", forwards: [{ name: "review" }] },
104
+ { name: "completed", forwards: [] }
105
+ ]
106
+ ```
107
+
108
+ ### Pattern 3: Multi-Party Approval
109
+ ```
110
+ Start → Review (threshold: 3) → Completed
111
+ ```
112
+ Requires multiple signers to advance.
113
+
114
+ ```
115
+ nodes: [
116
+ { name: "review", threshold: 3, forwards: [{ name: "completed" }] }
117
+ ]
118
+ ```
119
+
120
+ ### Pattern 4: Parallel Tracks
121
+ ```
122
+ → Track A → Merge
123
+ Start →
124
+ → Track B → Merge → Done
125
+ ```
126
+ Multiple parallel work streams that converge.
127
+
128
+ ## Progress Operations
129
+
130
+ Progress tracks an order's movement through a Machine's workflow.
131
+
132
+ ### Advance Progress
133
+ ```
134
+ onchain_operations({
135
+ operation_type: "progress",
136
+ data: {
137
+ op: "advance",
138
+ order: "<order_id>",
139
+ node: "<target_node_name>",
140
+ pairs: { <node_data> }
141
+ }
142
+ })
143
+ ```
144
+
145
+ ### Query Progress History
146
+ ```
147
+ onchain_table_data({
148
+ query_type: "onchain_table_item_progress_history",
149
+ parent: "<progress_id>",
150
+ u64: <sequence_number>
151
+ })
152
+ ```
153
+
154
+ ## Machine Creation Workflow
155
+
156
+ ### Step 1: Design Nodes on Paper
157
+ Sketch the workflow graph before coding. Identify all nodes, transitions, and conditions.
158
+
159
+ ### Step 2: Create Guards for Transitions
160
+ Each conditional forward needs a Guard. Create these Guards first (see `wowok-guard` skill).
161
+
162
+ ### Step 3: Create the Machine (Dry Run)
163
+ ```
164
+ onchain_operations({
165
+ operation_type: "machine",
166
+ data: {
167
+ op: "create",
168
+ name: "<machine_name>",
169
+ description: "<description>",
170
+ service: "<service_id>",
171
+ guard: "<guard_id>",
172
+ node: {
173
+ op: "set",
174
+ nodes: [ ... ],
175
+ bReplace: true
176
+ }
177
+ }
178
+ })
179
+ ```
180
+
181
+ ### Step 4: Export and Review
182
+ ```
183
+ machineNode2file({
184
+ machine: "<machine_id>",
185
+ file_path: "<output_path>",
186
+ format: "json"
187
+ })
188
+ ```
189
+
190
+ ### Step 5: Execute
191
+ After review, add `submission` to execute.
192
+
193
+ ## Machine from File
194
+
195
+ Load node definitions from a local file:
196
+ ```
197
+ onchain_operations({
198
+ operation_type: "machine",
199
+ data: {
200
+ op: "create",
201
+ name: "<machine_name>",
202
+ service: "<service_id>",
203
+ node: {
204
+ json_or_markdown_file: "<path_to_file>"
205
+ }
206
+ }
207
+ })
208
+ ```
209
+
210
+ ## Common Machine Errors
211
+
212
+ | Error | Cause | Fix |
213
+ |-------|-------|-----|
214
+ | "node not found" | Forward references non-existent node | Check all forward names match node names |
215
+ | "guard not found" | Forward references non-existent Guard | Create the Guard first |
216
+ | "circular dependency" | Infinite loop in forwards | Ensure at least one terminal node |
217
+ | "threshold not met" | Not enough signers | Check threshold value and signer count |
218
+ | "invalid pairs" | Node data doesn't match pairs schema | Check pairs definition matches submitted data |
219
+
220
+ ## Real-World Machine Workflows (from tested examples)
221
+
222
+ ### MyShop: 4-Node Order Processing
223
+
224
+ **Source**: [MyShop Example](../examples/MyShop/MyShop.md)
225
+
226
+ A linear order fulfillment workflow for an e-commerce store:
227
+
228
+ ```
229
+ Order Confirmation → Shipping → In Transit → Completed
230
+ ↘ Order End (Cancel Order)
231
+ ```
232
+
233
+ **Key Design**: The first node (`Order Confirmation`) has two `pairs` entries — one for the initial transition (threshold=0, from empty `prev_node`) and one for cancel. Normal flow goes through Shipping → In Transit → Completed. The customer (order owner) can cancel from Order Confirmation using `namedOperator: ""`.
234
+
235
+ ```
236
+ nodes: [
237
+ {
238
+ name: "Order Confirmation",
239
+ pairs: [
240
+ { prev_node: "", threshold: 0, forwards: [{ name: "Confirm Order", permissionIndex: 1000, weight: 1 }] },
241
+ { prev_node: "Order Confirmation", threshold: 0, forwards: [{ name: "Cancel Order", permissionIndex: 1001, weight: 1 }] }
242
+ ]
243
+ },
244
+ {
245
+ name: "Shipping",
246
+ pairs: [
247
+ { prev_node: "Order Confirmation", threshold: 1, forwards: [{ name: "Start Shipping", permissionIndex: 1000, weight: 1 }] }
248
+ ]
249
+ },
250
+ {
251
+ name: "In Transit",
252
+ pairs: [
253
+ { prev_node: "Shipping", threshold: 1, forwards: [{ name: "Mark In Transit", permissionIndex: 1000, weight: 1 }] }
254
+ ]
255
+ },
256
+ {
257
+ name: "Completed",
258
+ pairs: [
259
+ { prev_node: "In Transit", threshold: 1, forwards: [{ name: "Complete Order", permissionIndex: 1002, weight: 1 }] }
260
+ ]
261
+ }
262
+ ]
263
+ ```
264
+
265
+ ### MyShop Advanced: 11-Node Multi-Path Workflow
266
+
267
+ **Source**: [MyShop Advanced Example](../examples/MyShop_Advanced/MyShop_Advanced.md)
268
+
269
+ An enterprise-grade workflow with dual-signature returns, reward incentives, and time-based auto-completion:
270
+
271
+ ```
272
+ Order Confirmed ──→ Shipping ──→ Delivery Complete ──→ Order Complete
273
+ │ │ │ │ │
274
+ │ │ │ │ └──→ Non-receipt Return ──→ Return Complete
275
+ │ │ │ │
276
+ │ │ ├──→ Wonderful
277
+ │ │ ├──→ Order Complete (time >= 10d)
278
+ │ │ └──→ Lost (dual-sig, threshold=2)
279
+ │ │
280
+ └── Order Cancel ──┘ Receipt Return ──→ Return Fail (time >= 10d)
281
+ └──→ Return Complete (dual-sig)
282
+ ```
283
+
284
+ **Key Design Decisions**:
285
+ - **Dual-signature returns**: Lost, Non-receipt Return, Receipt Return, and Return Complete all use `threshold: 2` — requiring both customer and merchant to confirm
286
+ - **Time-based auto-completion**: Order Complete and Return Fail use time guards (10 days) for automatic transitions
287
+ - **Wonderful rating**: Customer can rate delivery as "Wonderful" from the Shipping node, triggering reward
288
+ - **"Who completes, who submits"**: The party responsible for an action submits the on-chain proof (e.g., merchant submits Merkle Root for shipping, customer for returns)
289
+
290
+ ```
291
+ nodes: [
292
+ {
293
+ name: "Order Confirmed",
294
+ pairs: [
295
+ { prev_node: "", threshold: 0, forwards: [{ name: "Confirm Order", permissionIndex: 1010, weight: 1 }] },
296
+ { prev_node: "Order Confirmed", threshold: 0, forwards: [{ name: "Cancel Order", permissionIndex: 1010, weight: 1 }] }
297
+ ]
298
+ },
299
+ {
300
+ name: "Order Cancel",
301
+ pairs: [
302
+ { prev_node: "Order Confirmed", threshold: 1, forwards: [{ name: "Cancel Order", permissionIndex: 1010, weight: 1 }] }
303
+ ]
304
+ },
305
+ {
306
+ name: "Shipping",
307
+ pairs: [
308
+ { prev_node: "Order Confirmed", threshold: 1, forwards: [{ name: "Ship Order", permissionIndex: 1011, weight: 1, guard: { guard: "machine_merkle_root_v2" } }] }
309
+ ]
310
+ },
311
+ {
312
+ name: "Delivery Complete",
313
+ pairs: [
314
+ { prev_node: "Shipping", threshold: 1, forwards: [{ name: "Confirm Delivery", permissionIndex: 1012, weight: 1 }] }
315
+ ]
316
+ },
317
+ {
318
+ name: "Wonderful",
319
+ pairs: [
320
+ { prev_node: "Shipping", threshold: 1, forwards: [{ name: "Rate Wonderful", permissionIndex: 1013, weight: 1 }] }
321
+ ]
322
+ },
323
+ {
324
+ name: "Order Complete",
325
+ pairs: [
326
+ { prev_node: "Shipping", threshold: 1, forwards: [{ name: "Auto Complete (10d)", permissionIndex: 1011, weight: 1, guard: { guard: "machine_time_10d_v2" } }] },
327
+ { prev_node: "Delivery Complete", threshold: 1, forwards: [{ name: "Complete Order", permissionIndex: 1011, weight: 1 }] }
328
+ ]
329
+ },
330
+ {
331
+ name: "Lost",
332
+ pairs: [
333
+ { prev_node: "Shipping", threshold: 2, forwards: [{ name: "Report Lost", permissionIndex: 1014, weight: 1 }] }
334
+ ]
335
+ },
336
+ {
337
+ name: "Non-receipt Return",
338
+ pairs: [
339
+ { prev_node: "Delivery Complete", threshold: 2, forwards: [{ name: "Return (No Receipt)", permissionIndex: 1015, weight: 1 }] }
340
+ ]
341
+ },
342
+ {
343
+ name: "Receipt Return",
344
+ pairs: [
345
+ { prev_node: "Delivery Complete", threshold: 2, forwards: [{ name: "Return (With Receipt)", permissionIndex: 1016, weight: 1 }] }
346
+ ]
347
+ },
348
+ {
349
+ name: "Return Fail",
350
+ pairs: [
351
+ { prev_node: "Receipt Return", threshold: 1, forwards: [{ name: "Return Failed (10d)", permissionIndex: 1011, weight: 1, guard: { guard: "machine_time_10d_v2" } }] }
352
+ ]
353
+ },
354
+ {
355
+ name: "Return Complete",
356
+ pairs: [
357
+ { prev_node: "Non-receipt Return", threshold: 2, forwards: [{ name: "Complete Return", permissionIndex: 1017, weight: 1 }] },
358
+ { prev_node: "Receipt Return", threshold: 2, forwards: [{ name: "Complete Return", permissionIndex: 1017, weight: 1 }] }
359
+ ]
360
+ }
361
+ ]
362
+ ```
363
+
364
+ ### Insurance: 2-Node Time-Lock Workflow
365
+
366
+ **Source**: [Insurance Example](../examples/Insurance/Insurance.md)
367
+
368
+ A minimal claim processing workflow with time-lock protection:
369
+
370
+ ```
371
+ Start → Complete (time-lock guard: clock > progress.current_time + 1000ms)
372
+ ```
373
+
374
+ **Key Design**: The Complete forward uses a Guard with `convert_witness: 100` (TypeOrderProgress) to access the Order's Progress object and query `progress.current_time`. This creates a time-lock — the claim cannot be completed until the lock duration passes.
375
+
376
+ ```
377
+ nodes: [
378
+ {
379
+ name: "Start",
380
+ pairs: [
381
+ { prev_node: "", threshold: 0, forwards: [{ name: "start_claim", permissionIndex: 1000, weight: 1 }] }
382
+ ]
383
+ },
384
+ {
385
+ name: "Complete",
386
+ pairs: [
387
+ { prev_node: "Start", threshold: 1, forwards: [{ name: "complete_claim", permissionIndex: 1001, weight: 1, guard: { guard: "insurance_complete_guard_v1" } }] }
388
+ ]
389
+ }
390
+ ]
391
+ ```
392
+
393
+ ### Travel: 5-Node Weather-Dependent Workflow
394
+
395
+ **Source**: [Travel Example](../examples/Travel/Travel.md)
396
+
397
+ A complex travel service workflow with insurance sub-order and weather-dependent activity:
398
+
399
+ ```
400
+ Start → Buy Insurance (creates sub-order) → SPA → Ice Scooting (weather check guard)
401
+ ├──→ Complete (time-lock)
402
+ └──→ Cancel
403
+ ```
404
+
405
+ **Key Design**:
406
+ - **Insurance sub-order**: The "Buy Insurance" forward creates a sub-order on the Insurance Service via `forward_to_order_create`
407
+ - **Weather-dependent activity**: The Ice Scooting forward uses a weather check Guard that queries the weather Repository
408
+ - **Time-lock completion**: The Complete forward uses `convert_witness: 100` for time-lock (same as Insurance)
409
+ - **Named forwards**: Each forward uses a descriptive `forward_name` for event tracking
410
+
411
+ ```
412
+ nodes: [
413
+ {
414
+ name: "Start",
415
+ pairs: [
416
+ { prev_node: "", threshold: 0, forwards: [{ forward_name: "start_travel", permissionIndex: 1000, weight: 1 }] }
417
+ ]
418
+ },
419
+ {
420
+ name: "Buy Insurance",
421
+ pairs: [
422
+ { prev_node: "Start", threshold: 1, forwards: [{ forward_name: "buy_insurance", permissionIndex: 1001, weight: 1, guard: { guard: "travel_buy_insurance_guard_v1" } }] }
423
+ ]
424
+ },
425
+ {
426
+ name: "SPA",
427
+ pairs: [
428
+ { prev_node: "Buy Insurance", threshold: 1, forwards: [{ forward_name: "enjoy_spa", permissionIndex: 1002, weight: 1 }] }
429
+ ]
430
+ },
431
+ {
432
+ name: "Ice Scooting",
433
+ pairs: [
434
+ { prev_node: "SPA", threshold: 1, forwards: [
435
+ { forward_name: "ice_scooting", permissionIndex: 1003, weight: 1, guard: { guard: "weather_check_guard_v1" } }
436
+ ]}
437
+ ]
438
+ },
439
+ {
440
+ name: "Complete",
441
+ pairs: [
442
+ { prev_node: "Ice Scooting", threshold: 1, forwards: [{ forward_name: "complete_travel", permissionIndex: 1004, weight: 1, guard: { guard: "travel_complete_guard_v1" } }] }
443
+ ]
444
+ }
445
+ ]
446
+ ```
447
+
448
+ ### ThreeBody Signature: 2-Node Simple Workflow
449
+
450
+ **Source**: [ThreeBody Signature Example](../examples/ThreeBody_Signature/ThreeBody_Signature.md)
451
+
452
+ The simplest possible workflow — just delivery and completion:
453
+
454
+ ```
455
+ Book Delivered → Signature Completed
456
+ ```
457
+
458
+ ```
459
+ nodes: [
460
+ {
461
+ name: "Book Delivered",
462
+ pairs: [
463
+ { prev_node: "", threshold: 0, forwards: [{ name: "Confirm Delivery", permissionIndex: 1000, weight: 1 }] }
464
+ ]
465
+ },
466
+ {
467
+ name: "Signature Completed",
468
+ pairs: [
469
+ { prev_node: "Book Delivered", threshold: 1, forwards: [{ name: "Complete Signature", permissionIndex: 1001, weight: 1 }] }
470
+ ]
471
+ }
472
+ ]
473
+ ```
474
+
475
+ ## Machine Workflow Design Checklist
476
+
477
+ Based on patterns from all tested examples:
478
+
479
+ ```
480
+ Designing a Machine workflow?
481
+ ├─ How many nodes?
482
+ │ ├─ 2 nodes → Pattern: Start → Complete (Insurance, ThreeBody)
483
+ │ ├─ 4 nodes → Pattern: Linear pipeline (MyShop)
484
+ │ ├─ 5+ nodes → Pattern: Multi-path with branches (Travel, MyShop Advanced)
485
+ │ └─ 11+ nodes → Pattern: Enterprise with dual-sig + time + rewards
486
+
487
+ ├─ Need dual-signature (multi-party approval)?
488
+ │ └─ Set threshold: 2 on the node → Both parties must confirm
489
+
490
+ ├─ Need time-based auto-advancement?
491
+ │ └─ Add a time guard on the forward (e.g., machine_time_10d_v2)
492
+
493
+ ├─ Need sub-order creation (supply chain)?
494
+ │ └─ Use forward_to_order_create on the forward (Travel → Insurance)
495
+
496
+ ├─ Need initial entry (prev_node: "")?
497
+ │ └─ threshold: 0 on the first pair means "anyone can enter from start"
498
+
499
+ └─ Need guard on forward?
500
+ └─ guard: { guard: "<guard_name>" } validates the transition
501
+ ```
502
+
503
+ ## Machine Node Patterns Quick Reference
504
+
505
+ | Pattern | Nodes | Threshold | Guard | Use Case |
506
+ |---------|-------|-----------|-------|----------|
507
+ | Auto-start | `prev_node: ""` | 0 | none | Entry point — anyone can start |
508
+ | Single-party | `prev_node: "X"` | 1 | optional | One party advances (merchant or customer) |
509
+ | Dual-signature | `prev_node: "X"` | 2 | optional | Both parties must confirm (returns, lost) |
510
+ | Time-lock | `prev_node: "X"` | 1 | time guard | Auto-complete after duration |
511
+ | Guarded | `prev_node: "X"` | 1 | condition guard | Weather check, Merkle root, etc. |
512
+ | Sub-order | `prev_node: "X"` | 1 | guard + forward_to | Create order on another Service |