@wowok/skills 1.1.0 → 1.1.1
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/README.md +16 -20
- package/dist/cli.js +114 -19
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/skills.d.ts +46 -1
- package/dist/skills.d.ts.map +1 -1
- package/dist/skills.js +154 -16
- package/dist/skills.js.map +1 -1
- package/dist/types.d.ts +31 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -4
- package/scripts/install.js +5 -3
- package/wowok-arbitrator/SKILL.md +279 -0
- package/wowok-guard/SKILL.md +143 -167
- package/wowok-machine/SKILL.md +167 -279
- package/wowok-order/SKILL.md +281 -429
- package/wowok-provider/SKILL.md +453 -0
- package/wowok-safety/SKILL.md +42 -20
- package/wowok-tools/SKILL.md +328 -343
- package/schemas/onchain_operations/_common.md +0 -406
- package/schemas/onchain_operations/_index.md +0 -196
- package/schemas/onchain_operations/allocation.md +0 -28
- package/schemas/onchain_operations/arbitration.md +0 -106
- package/schemas/onchain_operations/contact.md +0 -40
- package/schemas/onchain_operations/demand.md +0 -53
- package/schemas/onchain_operations/gen_passport.md +0 -23
- package/schemas/onchain_operations/guard.md +0 -56
- package/schemas/onchain_operations/machine.md +0 -89
- package/schemas/onchain_operations/order.md +0 -56
- package/schemas/onchain_operations/payment.md +0 -24
- package/schemas/onchain_operations/permission.md +0 -68
- package/schemas/onchain_operations/personal.md +0 -58
- package/schemas/onchain_operations/progress.md +0 -38
- package/schemas/onchain_operations/repository.md +0 -70
- package/schemas/onchain_operations/reward.md +0 -38
- package/schemas/onchain_operations/service.md +0 -78
- package/schemas/onchain_operations/treasury.md +0 -68
- package/schemas/schema-account_operation.md +0 -402
- package/schemas/schema-guard2file.md +0 -153
- package/schemas/schema-local_info_operation.md +0 -160
- package/schemas/schema-local_mark_operation.md +0 -148
- package/schemas/schema-machineNode2file.md +0 -155
- package/schemas/schema-messenger_operation.md +0 -547
- package/schemas/schema-onchain_events.md +0 -201
- package/schemas/schema-onchain_table_data.md +0 -334
- package/schemas/schema-query_toolkit.md +0 -395
- package/schemas/schema-wip_file.md +0 -240
- package/schemas/schema-wowok_buildin_info.md +0 -296
- package/wowok-build/SKILL.md +0 -139
package/wowok-machine/SKILL.md
CHANGED
|
@@ -26,29 +26,27 @@ A Machine is a **workflow template** that defines how orders progress through st
|
|
|
26
26
|
|
|
27
27
|
## Machine Structure
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
```
|
|
29
|
+
**Operation**: `onchain_operations` with `operation_type: "machine"`.
|
|
30
|
+
|
|
31
|
+
**Schema Reference**: `schema_query({ action: "get", name: "onchain_operations_machine" })`
|
|
32
|
+
|
|
33
|
+
**Key Fields**:
|
|
34
|
+
- `object`: Machine object name (CREATE) or ID (MODIFY)
|
|
35
|
+
- `service`: Which Service this Machine belongs to
|
|
36
|
+
- `guard`: Guard for workflow validation
|
|
37
|
+
- `node`: Node configuration with:
|
|
38
|
+
- `op`: Operation type ("set", "add", "remove")
|
|
39
|
+
- `nodes`: Array of node definitions
|
|
40
|
+
- `bReplace`: Replace existing nodes flag
|
|
41
|
+
|
|
42
|
+
### Node Structure
|
|
43
|
+
|
|
44
|
+
Each node contains:
|
|
45
|
+
- `name`: Unique node identifier
|
|
46
|
+
- `pairs`: Data fields at this node (array of pair definitions)
|
|
47
|
+
- `forwards`: Allowed next nodes (array of forward definitions)
|
|
48
|
+
- `guard`: Guard for entering this node
|
|
49
|
+
- `threshold`: Required signers to advance
|
|
52
50
|
|
|
53
51
|
## Machine Node Design Rules
|
|
54
52
|
|
|
@@ -75,14 +73,11 @@ Start → Step1 → Step2 → Step3 → Done
|
|
|
75
73
|
```
|
|
76
74
|
Simple sequential workflow. Each node forwards to exactly one next node.
|
|
77
75
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
{ name: "completed", forwards: [] }
|
|
84
|
-
]
|
|
85
|
-
```
|
|
76
|
+
**Node Configuration**:
|
|
77
|
+
- Node "pending": forwards to "in_progress"
|
|
78
|
+
- Node "in_progress": forwards to "review"
|
|
79
|
+
- Node "review": forwards to "completed"
|
|
80
|
+
- Node "completed": no forwards (terminal)
|
|
86
81
|
|
|
87
82
|
### Pattern 2: Branching Workflow
|
|
88
83
|
```
|
|
@@ -92,18 +87,14 @@ Start → Review
|
|
|
92
87
|
```
|
|
93
88
|
Conditional branching based on Guard validation.
|
|
94
89
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
{ name: "revision", forwards: [{ name: "review" }] },
|
|
104
|
-
{ name: "completed", forwards: [] }
|
|
105
|
-
]
|
|
106
|
-
```
|
|
90
|
+
**Node Configuration**:
|
|
91
|
+
- Node "review": two forwards with different guards
|
|
92
|
+
- Forward to "approved" with approval guard
|
|
93
|
+
- Forward to "rejected" with rejection guard
|
|
94
|
+
- Node "approved": forward to "completed"
|
|
95
|
+
- Node "rejected": forward to "revision"
|
|
96
|
+
- Node "revision": forward back to "review"
|
|
97
|
+
- Node "completed": terminal
|
|
107
98
|
|
|
108
99
|
### Pattern 3: Multi-Party Approval
|
|
109
100
|
```
|
|
@@ -111,11 +102,8 @@ Start → Review (threshold: 3) → Completed
|
|
|
111
102
|
```
|
|
112
103
|
Requires multiple signers to advance.
|
|
113
104
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
{ name: "review", threshold: 3, forwards: [{ name: "completed" }] }
|
|
117
|
-
]
|
|
118
|
-
```
|
|
105
|
+
**Node Configuration**:
|
|
106
|
+
- Node "review": threshold = 3, forward to "completed"
|
|
119
107
|
|
|
120
108
|
### Pattern 4: Parallel Tracks
|
|
121
109
|
```
|
|
@@ -130,82 +118,68 @@ Multiple parallel work streams that converge.
|
|
|
130
118
|
Progress tracks an order's movement through a Machine's workflow.
|
|
131
119
|
|
|
132
120
|
### Advance Progress
|
|
133
|
-
|
|
134
|
-
onchain_operations
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
})
|
|
143
|
-
```
|
|
121
|
+
|
|
122
|
+
**Operation**: `onchain_operations` with `operation_type: "progress"`.
|
|
123
|
+
|
|
124
|
+
**Key Fields**:
|
|
125
|
+
- `op`: Operation type ("advance", "create", etc.)
|
|
126
|
+
- `order`: Order ID to advance
|
|
127
|
+
- `node`: Target node name
|
|
128
|
+
- `pairs`: Node data to submit
|
|
144
129
|
|
|
145
130
|
### Query Progress History
|
|
146
|
-
|
|
147
|
-
onchain_table_data
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
131
|
+
|
|
132
|
+
**Tool**: `onchain_table_data` with `query_type: "onchain_table_item_progress_history"`.
|
|
133
|
+
|
|
134
|
+
**Key Fields**:
|
|
135
|
+
- `parent`: Progress ID
|
|
136
|
+
- `u64`: Sequence number
|
|
137
|
+
|
|
138
|
+
**Schema Reference**: `schema_query({ action: "get", name: "onchain_table_data" })`
|
|
153
139
|
|
|
154
140
|
## Machine Creation Workflow
|
|
155
141
|
|
|
156
142
|
### Step 1: Design Nodes on Paper
|
|
157
|
-
Sketch the workflow graph before
|
|
143
|
+
Sketch the workflow graph before implementation. Identify all nodes, transitions, and conditions.
|
|
158
144
|
|
|
159
145
|
### Step 2: Create Guards for Transitions
|
|
160
|
-
Each conditional forward needs a Guard. Create these Guards first (see
|
|
146
|
+
Each conditional forward needs a Guard. Create these Guards first (see [wowok-guard](../wowok-guard/SKILL.md) skill).
|
|
161
147
|
|
|
162
148
|
### Step 3: Create the Machine (Dry Run)
|
|
163
|
-
|
|
164
|
-
onchain_operations
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
op: "set",
|
|
174
|
-
nodes: [ ... ],
|
|
175
|
-
bReplace: true
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
})
|
|
179
|
-
```
|
|
149
|
+
|
|
150
|
+
**Operation**: `onchain_operations` with `operation_type: "machine"`.
|
|
151
|
+
|
|
152
|
+
**Key Fields**:
|
|
153
|
+
- `op`: "create"
|
|
154
|
+
- `object`: Machine name
|
|
155
|
+
- `description`: Machine description
|
|
156
|
+
- `service`: Service ID this Machine belongs to
|
|
157
|
+
- `guard`: Guard ID for workflow validation
|
|
158
|
+
- `node`: Node configuration object
|
|
180
159
|
|
|
181
160
|
### Step 4: Export and Review
|
|
182
|
-
|
|
183
|
-
machineNode2file
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
161
|
+
|
|
162
|
+
**Tool**: `machineNode2file`.
|
|
163
|
+
|
|
164
|
+
**Key Fields**:
|
|
165
|
+
- `machine`: Machine ID
|
|
166
|
+
- `file_path`: Output file path
|
|
167
|
+
- `format`: Output format ("json" or "markdown")
|
|
189
168
|
|
|
190
169
|
### Step 5: Execute
|
|
191
|
-
After review, add `submission` to execute.
|
|
170
|
+
After review, add `submission` field to execute the operation.
|
|
192
171
|
|
|
193
172
|
## Machine from File
|
|
194
173
|
|
|
195
174
|
Load node definitions from a local file:
|
|
196
|
-
|
|
197
|
-
onchain_operations
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
json_or_markdown_file: "<path_to_file>"
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
})
|
|
208
|
-
```
|
|
175
|
+
|
|
176
|
+
**Operation**: `onchain_operations` with `operation_type: "machine"`.
|
|
177
|
+
|
|
178
|
+
**Key Fields**:
|
|
179
|
+
- `op`: "create"
|
|
180
|
+
- `object`: Machine name
|
|
181
|
+
- `service`: Service ID
|
|
182
|
+
- `node.json_or_markdown_file`: Path to node definition file
|
|
209
183
|
|
|
210
184
|
## Common Machine Errors
|
|
211
185
|
|
|
@@ -230,37 +204,15 @@ Order Confirmation → Shipping → In Transit → Completed
|
|
|
230
204
|
↘ Order End (Cancel Order)
|
|
231
205
|
```
|
|
232
206
|
|
|
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
|
|
207
|
+
**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.
|
|
234
208
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
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
|
-
```
|
|
209
|
+
**Node Structure**:
|
|
210
|
+
- Node "Order Confirmation": Two pairs
|
|
211
|
+
- From empty prev_node: threshold 0, forward to "Confirm Order"
|
|
212
|
+
- From "Order Confirmation": threshold 0, forward to "Cancel Order"
|
|
213
|
+
- Node "Shipping": From "Order Confirmation", threshold 1, forward to "Start Shipping"
|
|
214
|
+
- Node "In Transit": From "Shipping", threshold 1, forward to "Mark In Transit"
|
|
215
|
+
- Node "Completed": From "In Transit", threshold 1, forward to "Complete Order"
|
|
264
216
|
|
|
265
217
|
### MyShop Advanced: 11-Node Multi-Path Workflow
|
|
266
218
|
|
|
@@ -287,80 +239,6 @@ Order Confirmed ──→ Shipping ──→ Delivery Complete ──→ Order C
|
|
|
287
239
|
- **Wonderful rating**: Customer can rate delivery as "Wonderful" from the Shipping node, triggering reward
|
|
288
240
|
- **"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
241
|
|
|
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
242
|
### Insurance: 2-Node Time-Lock Workflow
|
|
365
243
|
|
|
366
244
|
**Source**: [Insurance Example](../examples/Insurance/Insurance.md)
|
|
@@ -373,22 +251,9 @@ Start → Complete (time-lock guard: clock > progress.current_time + 1000ms)
|
|
|
373
251
|
|
|
374
252
|
**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
253
|
|
|
376
|
-
|
|
377
|
-
|
|
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
|
-
```
|
|
254
|
+
**Node Structure**:
|
|
255
|
+
- Node "Start": From empty prev_node, threshold 0, forward to "start_claim"
|
|
256
|
+
- Node "Complete": From "Start", threshold 1, forward to "complete_claim" with time guard
|
|
392
257
|
|
|
393
258
|
### Travel: 5-Node Weather-Dependent Workflow
|
|
394
259
|
|
|
@@ -408,43 +273,6 @@ Start → Buy Insurance (creates sub-order) → SPA → Ice Scooting (weather ch
|
|
|
408
273
|
- **Time-lock completion**: The Complete forward uses `convert_witness: 100` for time-lock (same as Insurance)
|
|
409
274
|
- **Named forwards**: Each forward uses a descriptive `forward_name` for event tracking
|
|
410
275
|
|
|
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
276
|
### ThreeBody Signature: 2-Node Simple Workflow
|
|
449
277
|
|
|
450
278
|
**Source**: [ThreeBody Signature Example](../examples/ThreeBody_Signature/ThreeBody_Signature.md)
|
|
@@ -455,22 +283,9 @@ The simplest possible workflow — just delivery and completion:
|
|
|
455
283
|
Book Delivered → Signature Completed
|
|
456
284
|
```
|
|
457
285
|
|
|
458
|
-
|
|
459
|
-
|
|
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
|
-
```
|
|
286
|
+
**Node Structure**:
|
|
287
|
+
- Node "Book Delivered": From empty prev_node, threshold 0, forward to "Confirm Delivery"
|
|
288
|
+
- Node "Signature Completed": From "Book Delivered", threshold 1, forward to "Complete Signature"
|
|
474
289
|
|
|
475
290
|
## Machine Workflow Design Checklist
|
|
476
291
|
|
|
@@ -547,13 +362,86 @@ The optional `guard` field in a Forward validates critical operation results bef
|
|
|
547
362
|
- **Repository submission validation**: Verify that required data was successfully submitted to a specified Repository object
|
|
548
363
|
- **Supply chain commitment validation**: Confirm that sub-order commitments in the supply chain were fulfilled
|
|
549
364
|
- **External condition checks**: Validate any external state or conditions that must be met before proceeding
|
|
365
|
+
- **Service penalty validation**: Verify compensation payments for service failures (e.g., late delivery penalties)
|
|
550
366
|
|
|
551
367
|
When a forward has a Guard, the Guard's logic is evaluated when a user attempts to execute that forward. If the Guard returns `false`, the forward cannot be completed.
|
|
552
368
|
|
|
553
369
|
---
|
|
554
370
|
|
|
371
|
+
## Service Penalty & Compensation Pattern
|
|
372
|
+
|
|
373
|
+
Design Machines to handle **service failures gracefully** through automated compensation workflows. This pattern validates penalty payments before allowing workflow continuation.
|
|
374
|
+
|
|
375
|
+
### Use Case: Late Delivery Compensation
|
|
376
|
+
|
|
377
|
+
**Scenario**: Courier service fails to deliver within promised timeframe. Machine requires courier to pay penalty to customer before order can proceed.
|
|
378
|
+
|
|
379
|
+
```
|
|
380
|
+
Delivery Node ──→ Late Delivery Detected (Guard: time > deadline)
|
|
381
|
+
│
|
|
382
|
+
├──→ Penalty Payment Required ──→ Payment Verified (Guard)
|
|
383
|
+
│ │
|
|
384
|
+
└──→ Continue to Next Node ←─────────┘
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
**Machine Design**:
|
|
388
|
+
- Node "Delivery" with two forwards from "Shipping" node:
|
|
389
|
+
- "On Time Delivery" forward: normal path
|
|
390
|
+
- "Late Delivery" forward: with guard checking if past deadline
|
|
391
|
+
|
|
392
|
+
**Guard Logic** (`delivery_penalty_guard`):
|
|
393
|
+
- Query Progress: Get `progress.current_time` vs `expected_delivery_time`
|
|
394
|
+
- If late: Verify Payment object showing penalty amount transferred to Order
|
|
395
|
+
- Validate: Payment amount ≥ configured penalty rate
|
|
396
|
+
- Validate: Payment completed within grace period
|
|
397
|
+
|
|
398
|
+
**Benefits**:
|
|
399
|
+
- **Automatic enforcement**: Late delivery cannot proceed without compensation
|
|
400
|
+
- **Verified compensation**: Guard cryptographically verifies payment occurred
|
|
401
|
+
- **Customer protection**: Guaranteed penalty for service failures
|
|
402
|
+
- **Service accountability**: Forces service providers to meet commitments
|
|
403
|
+
|
|
404
|
+
### Cross-Service Collaboration Penalties
|
|
405
|
+
|
|
406
|
+
**Pattern**: When multiple services collaborate (e.g., Travel + Insurance + Courier), any party's failure can trigger penalties paid to the affected customer's Order.
|
|
407
|
+
|
|
408
|
+
```
|
|
409
|
+
Travel Order ──→ Courier Sub-order ──→ Late Delivery
|
|
410
|
+
│
|
|
411
|
+
├──→ Courier pays penalty to Travel Order
|
|
412
|
+
│
|
|
413
|
+
└──→ Travel Order receives compensation
|
|
414
|
+
(Order.receive to claim funds)
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
**Implementation**:
|
|
418
|
+
1. Courier Service Machine has `late_delivery` node with penalty Guard
|
|
419
|
+
2. Guard verifies Payment from Courier Service to Travel Order
|
|
420
|
+
3. Travel Order's `receive` operation extracts penalty to customer
|
|
421
|
+
4. Workflow continues only after penalty verified
|
|
422
|
+
|
|
423
|
+
**Schema Reference**: `schema_query({ action: "get", name: "onchain_operations_payment" })` — for penalty payment validation
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
555
427
|
## Progress Advancement Rules
|
|
556
428
|
|
|
557
429
|
- Sum of completed forward weights ≥ threshold → session moves to history, next node becomes current
|
|
558
430
|
- Order users advance via `Order` object
|
|
559
431
|
- Non-order users advance via `Progress` object directly
|
|
432
|
+
|
|
433
|
+
---
|
|
434
|
+
|
|
435
|
+
## Schema Reference
|
|
436
|
+
|
|
437
|
+
| Purpose | Schema Name |
|
|
438
|
+
|---------|-------------|
|
|
439
|
+
| Machine operations | `onchain_operations_machine` |
|
|
440
|
+
| Progress operations | `onchain_operations_progress` |
|
|
441
|
+
| Query on-chain objects | `query_toolkit` |
|
|
442
|
+
| Query table data | `onchain_table_data` |
|
|
443
|
+
| Payment operations | `onchain_operations_payment` |
|
|
444
|
+
|
|
445
|
+
**Query Schema**: `schema_query({ action: "get", name: "<schema_name>" })`
|
|
446
|
+
|
|
447
|
+
**Related Skills**: [wowok-guard](../wowok-guard/SKILL.md) | [wowok-order](../wowok-order/SKILL.md) | [wowok-provider](../wowok-provider/SKILL.md)
|