@wowok/skills 1.2.4 → 1.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.
Files changed (53) hide show
  1. package/README.md +34 -16
  2. package/dist/cli.js +6 -2
  3. package/dist/cli.js.map +1 -1
  4. package/dist/skills.d.ts +32 -1
  5. package/dist/skills.d.ts.map +1 -1
  6. package/dist/skills.js +63 -0
  7. package/dist/skills.js.map +1 -1
  8. package/dist/types.d.ts +8 -0
  9. package/dist/types.d.ts.map +1 -1
  10. package/examples/Insurance/Insurance.md +543 -475
  11. package/examples/MyShop/MyShop.md +865 -746
  12. package/examples/MyShop_Advanced/MyShop_Advanced.md +1520 -1376
  13. package/examples/ThreeBody_Signature/ThreeBody_Signature.md +891 -651
  14. package/examples/Travel/Travel.md +952 -848
  15. package/package.json +2 -2
  16. package/scripts/install.js +3 -17
  17. package/wowok-arbitrator/SKILL.md +18 -57
  18. package/wowok-auditor/SKILL.md +16 -12
  19. package/wowok-distill/SKILL.md +237 -0
  20. package/wowok-guard/SKILL.md +40 -354
  21. package/wowok-machine/SKILL.md +21 -127
  22. package/wowok-messenger/SKILL.md +14 -59
  23. package/wowok-onboard/SKILL.md +42 -12
  24. package/wowok-order/SKILL.md +20 -169
  25. package/wowok-output/SKILL.md +0 -10
  26. package/wowok-planner/SKILL.md +29 -9
  27. package/wowok-provider/SKILL.md +72 -32
  28. package/wowok-safety/SKILL.md +8 -80
  29. package/wowok-scenario/SKILL.md +70 -102
  30. package/wowok-tools/SKILL.md +68 -107
  31. package/references/glossary.ts +0 -297
  32. package/references/guard-scenario-ledger.md +0 -353
  33. package/references/guard-template-library.md +0 -481
  34. package/references/machine-design-reference.md +0 -398
  35. package/references/machine-scenario-ledger.md +0 -227
  36. package/references/machine-template-library.md +0 -522
  37. package/references/merchant-scenario-coordination.md +0 -383
  38. package/references/object-collaboration.md +0 -362
  39. package/references/onchain-constants.md +0 -81
  40. package/wowok-arbitrator/APPENDIX.md +0 -545
  41. package/wowok-auditor/APPENDIX.md +0 -487
  42. package/wowok-guard/APPENDIX.md +0 -430
  43. package/wowok-machine/APPENDIX.md +0 -407
  44. package/wowok-messenger/APPENDIX.md +0 -550
  45. package/wowok-onboard/APPENDIX.md +0 -502
  46. package/wowok-order/APPENDIX.md +0 -777
  47. package/wowok-output/APPENDIX.md +0 -575
  48. package/wowok-planner/APPENDIX.md +0 -726
  49. package/wowok-provider/APPENDIX.md +0 -455
  50. package/wowok-safety/APPENDIX.md +0 -565
  51. package/wowok-scenario/APPENDIX.md +0 -97
  52. package/wowok-scenario/MODE-DETAILS.md +0 -275
  53. package/wowok-tools/APPENDIX.md +0 -394
@@ -1,398 +0,0 @@
1
- # Machine Design Reference
2
-
3
- > Consolidated design reference covering Machine architecture, core elements, puzzle model, translation patterns, risk rules, and publish flow.
4
-
5
- ---
6
-
7
- ## 1. Architecture Overview
8
-
9
- ### Core Concept
10
-
11
- A **Machine** is a **directed graph** (allows cycles): Node set + NodePair migration rules + Forward permissions and guards = a uniquely executable workflow blueprint.
12
-
13
- **Cycles are allowed** (e.g., rework → re-ship → re-inspect). Each cycle MUST have a reachable exit condition via competing Pair (first-threshold-wins), time-lock Guard, or externally triggered Forward.
14
-
15
- ### Three-Layer Reversibility
16
-
17
- ```
18
- [Business Process] ←→ [Semantic Puzzle (8D)] ←→ [Executable Machine JSON] ←→ [On-chain Machine]
19
- natural language 8 dimensions nodes+pairs+forwards+guards immutable object
20
- ```
21
-
22
- 1. **Semantic ↔ JSON**: N Patterns forward-generate JSON; field rules reverse-interpret JSON
23
- 2. **JSON ↔ Machine**: CREATE on-chain; machineNode2file reverse-exports JSON
24
- 3. **Business ↔ Semantic**: 8D puzzle forward-completes; confirmation text reverse-traces intent
25
-
26
- ### Two Flow Separation
27
-
28
- | Dimension | Provider (Design-Time) | Customer/Order (Run-Time) |
29
- |-----------|----------------------|--------------------------|
30
- | Party | Service provider / workflow designer | Customer / buyer |
31
- | Core objects | Permission, Service(draft), Machine(draft), Guard, Allocation | Order, Progress, Payment |
32
- | Lifecycle | Create → configure → audit → publish (irreversible) | Order → fulfill → settle → complete/arbitrate |
33
- | Progress role | **NOT a design-time object** | **Core**: each Order gets one Progress instance |
34
- | Trigger | Provider actively builds | Customer order auto-spawns Progress via Service+Machine |
35
-
36
- ### Key Differences from Guard
37
-
38
- | Dimension | Guard | Machine |
39
- |-----------|-------|---------|
40
- | Nature | Data computation tree (bool root) | Directed graph (nodes + migration, cycles allowed) |
41
- | Mutability | CREATE-only (immutable) | Mutable before publish, frozen after |
42
- | Risk types | Reentrancy / forgery / logic gaps | Structural integrity / cycle exit / Guard integration / permission dynamics / immutability |
43
- | Confirmation | 1 confirmation before CREATE | 100% confirmation before publish (irreversible) |
44
- | Puzzle dimensions | 6 (A-F) | 8 (A-H) |
45
-
46
- ### M1-M5 Sub-Process (Machine Design Lifecycle)
47
-
48
- | Step | Phase | Description |
49
- |------|-------|-------------|
50
- | **M1** | Flow & Node Design | Extract business process, design nodes (entry/normal/terminal/branch), Pair + threshold, Forward + permissions |
51
- | **M2** | Machine Creation (unpublished) | `wowok({ tool: "onchain_operations", data: { operation_type: "machine", publish: false } })` CREATE, verify node/forward completeness |
52
- | **M3** | Guard Creation & Binding | Guard design (table + root tree), CREATE Guard, `gen_passport` static test, MODIFY Machine to bind Guards to Forwards |
53
- | **M4** | Pre-Publish Audit | 8D puzzle completeness, 5D risk assessment, topology analysis, on-chain limit checks, machineNode2file backup, independent Progress test |
54
- | **M5** | Publish & Bind Service | User explicit confirmation, `publish:true` (nodes frozen), bind Machine to Service, publish Service |
55
-
56
- **Anti-patterns**: Publishing Machine before creating Guards (Machine frozen, can't bind); binding Guards without testing; using Order test for pre-publish validation (Service not yet published).
57
-
58
- ### 5 Participation Modes
59
-
60
- | Mode | ID | Description |
61
- |------|----|-------------|
62
- | Reference | P-M1 | Import existing published Machine via ID, modify, publish new |
63
- | Composition | P-M2 | Merge multiple Machine fragments into one complete Machine |
64
- | Cross-Machine | P-M3 | Machine A's Forward Guard queries Machine B's Progress |
65
- | Description | P-M4 | Natural language business process → translated to Machine |
66
- | Fork-Modify | P-M5 | Export Machine by ID to JSON, user edits, publish as new |
67
-
68
- ### 8 Semantic Modules
69
-
70
- | Module | File | Responsibility |
71
- |--------|------|---------------|
72
- | Info Puzzle | `machine-puzzle.ts` | 8D structured modeling + completeness check + confirmation text |
73
- | Scenario Ledger | `machine-ledger.ts` | N scene recognition + scene-specific constraints |
74
- | Translation | `machine-translation.ts` | Semantic ↔ JSON bidirectional mapping + constraint rules |
75
- | Topology Analysis | `machine-topology.ts` | Graph analysis + cycle detection + main/sub-branch identification |
76
- | Risk Assessment | `machine-risk.ts` | 5D risk rules (structural/Guard/permission/immutability/environment) |
77
- | Template Library | `machine-templates.ts` | N parameterized scene templates |
78
- | Context Awareness | `machine-context.ts` | Project object dependency table + integration analysis |
79
- | Confirmation Gate | `machine-confirm.ts` | 100% user confirmation before publish |
80
-
81
- ---
82
-
83
- ## 2. Core Element Types and Rule System
84
-
85
- ### 4-Layer Nested Structure
86
-
87
- ```
88
- Machine
89
- └── Node × N
90
- └── NodePair × M
91
- ├── prev_node: String — previous node name ("" = entry)
92
- ├── threshold: U32 — migration threshold
93
- └── Forward × K
94
- ├── name: String
95
- ├── namedOperator: Option<String> — permission type 1
96
- ├── permissionIndex: Option<U16> — permission type 2
97
- ├── weight: U16 — contribution weight
98
- └── guard: Option<ForwardGuard>
99
- ├── guard: String — Guard object ID
100
- └── retained_submission: Vec<U8> — submission retention indices
101
- ```
102
-
103
- ### Key On-Chain Constants
104
-
105
- | Constant | Value | Description |
106
- |----------|-------|-------------|
107
- | `MAX_NODE_COUNT` | 200 (chain) / 100 (SDK) | Max nodes; SDK uses stricter 100 |
108
- | `MAX_NODE_PAIR_COUNT` | 40 | Max pairs per node |
109
- | `MAX_FORWARD_COUNT` | 20 | Max forwards per pair |
110
- | `MAX_FORWARD_ORDER_COUNT` | 20 | Max retained_submission indices |
111
- | `USER_DEFINED_PERM_INDEX_START` | 1000 | Custom permission indices start here |
112
-
113
- ### Immutability Constraints
114
-
115
- - `publish:true` is irreversible (false → true only)
116
- - After publish: all 9 node operations (add/set/remove/clear/exchange/rename/remove prior node/add forward/remove forward) fail with `E_ALREADY_PUBLISHED`
117
- - `description`, `consensus_repositories`, `bPaused`, `um`, `permission` remain modifiable after publish
118
-
119
- ### Node Semantic Roles
120
-
121
- | Role | Condition | Meaning |
122
- |------|-----------|---------|
123
- | Entry | At least one Pair with `prev_node == ""` | Flow start point |
124
- | Normal | Has incoming Pair AND outgoing Pair | Intermediate node |
125
- | Terminal | No outgoing Pairs (empty pairs) | Flow endpoint |
126
- | Branch | Multiple Pairs pointing to different next_node | Decision point |
127
- | Merge | Multiple Pairs' next_node points to same node | Merge point |
128
-
129
- ### Threshold Semantics
130
-
131
- | Pattern | threshold | Forward weight | Meaning |
132
- |---------|-----------|---------------|---------|
133
- | Sequential | 1 | 1 | Single executor, execute = migrate |
134
- | Parallel AND | N | 1 (×N) | All N parties must execute |
135
- | Parallel OR | 1 | 1 (multiple Pairs) | Any party executes (competing) |
136
- | Weighted Voting | 100 | 60+40 | Unequal weight voting |
137
- | Hybrid | 5 | 3+1+1 | Key party required, others optional |
138
-
139
- ### 3 Permission Types
140
-
141
- | Type | Field | Scope | When to Use |
142
- |------|-------|-------|-------------|
143
- | Permission | `permissionIndex` | Organization | Internal staff (warehouse/admin/platform) — shared across orders |
144
- | NamedOperator | `namedOperator` | Per-order | Role varies per order (deliverer/reviewer/agent) |
145
- | OrderHolder | `namedOperator: ""` | Order holder | Customer (order owner and agents) |
146
-
147
- **Iron Law**: Every Forward must have at least one permission type. `permissionIndex` must be ≥ 1000 (chain-enforced).
148
-
149
- ### 9 Node Operations
150
-
151
- | # | Operation | Description |
152
- |---|-----------|-------------|
153
- | 1 | `add` | Add node(s); `bReplace:true` = replace, `bReplace:false` = merge |
154
- | 2 | `set` | Set node (similar to add, clearer semantics) |
155
- | 3 | `remove` | Remove node; invalidates referencing Pairs |
156
- | 4 | `clear` | Clear all nodes (irreversible data loss; backup first) |
157
- | 5 | `exchange` | Swap two nodes' positions |
158
- | 6 | `rename` | Rename node; auto-updates all prev_node references |
159
- | 7 | `remove prior node` | Remove specific prev_node from a node's Pairs |
160
- | 8 | `add forward` | Add Forward to a specific Pair |
161
- | 9 | `remove forward` | Remove Forward from a specific Pair |
162
-
163
- ---
164
-
165
- ## 3. Information Puzzle Model (8 Dimensions)
166
-
167
- > Building a Machine requires completing 8 dimensions of information. AI acts as strategic advisor.
168
-
169
- | Dim | Name | Sub-process | Info |
170
- |-----|------|------------|------|
171
- | **A** | Business Flow | M1 | Main flow node sequence + business semantics (cycle annotations) |
172
- | **B** | Node Design | M1 | Each node's name + semantic role (entry/normal/terminal/branch) |
173
- | **C** | Guard Acceptance | M3 | Each Forward's Guard binding + retained_submission |
174
- | **D** | Permission Model | M1 | Each Forward's namedOperator/permissionIndex/OrderHolder |
175
- | **E** | Threshold & Weight | M1 | Each Pair's threshold + each Forward's weight |
176
- | **F** | Branch Topology | M1 | Main/sub-branch / competing Pairs / cycle exit / graph connectivity |
177
- | **G** | Overall Objective | M4 | Allocation/reward/arbitration integration + Service context |
178
- | **H** | Risk Assessment | M4 | 5D risk (structural/Guard/permission/immutability/environment) |
179
-
180
- ### Completeness Check
181
-
182
- Each dimension has an `isComplete()` function. The overall `checkMachinePuzzleCompleteness()` returns which dimensions are missing and recommends the next step.
183
-
184
- ### 5 Participation Mode Initialization
185
-
186
- - **P-M1 (Reference)**: `initPuzzleFromMachineId(machineId)` → machineNode2file → derivePuzzleFromMachineJson
187
- - **P-M2 (Composition)**: `initPuzzleFromFragments(fragments)` → merge fragments → resolve conflicts → validate connectivity
188
- - **P-M3 (Cross-Machine)**: `initPuzzleForCrossChain(machineBId)` → identify Progress query points → Guard design with convert_witness
189
- - **P-M4 (Description)**: `initPuzzleFromIntent(description)` → match scene → recommend Pattern → initialize dimension A
190
- - **P-M5 (Fork-Modify)**: `initPuzzleForForkModify(machineId)` → export JSON → derive puzzle → wait for user changes
191
-
192
- ### Reverse Derivation
193
-
194
- `derivePuzzleFromMachineJson(json)` → reconstructs all 8 dimensions from existing Machine JSON.
195
-
196
- ---
197
-
198
- ## 4. Translation Rules and Patterns
199
-
200
- ### Direction A: Business Semantics → Machine JSON (12 Patterns)
201
-
202
- **Execution Patterns (5)**:
203
-
204
- | Pattern | ID | Intent | Threshold | Weight |
205
- |---------|----|--------|-----------|--------|
206
- | Sequential | P-M-SEQ | Single executor, step by step | 1 | 1 |
207
- | Parallel AND | P-M-AND | All parties must execute (dual-sig) | N | 1×N |
208
- | Parallel OR | P-M-OR | Any party executes (competing) | 1 per Pair | 1 |
209
- | Weighted Voting | P-M-VOTE | Weighted vote to reach threshold | 100 | e.g., 60+40 |
210
- | Hybrid | P-M-HYBRID | Key party required + optional | 5 | 3+1+1 |
211
-
212
- **Topology Patterns (3)**: P-M-LINEAR (linear), P-M-FORKMERGE (fork & merge), P-M-COMPETING (competing exclusive branches)
213
-
214
- **Permission Patterns (2)**: P-M-PERM-SINGLE (single permission type), P-M-PERM-MIXED (either namedOperator or permissionIndex)
215
-
216
- **Integration Patterns (2)**: P-M-CROSS-MACHINE (cross-Machine dependency), P-M-ALLOCATION-INTEGRATED (fund allocation integration)
217
-
218
- ### Direction B: Machine JSON → Business Semantics
219
-
220
- Field explanation rules for all node/pair/forward/guard fields. Node role identification (entry/terminal/normal/branch/merge). Execution pattern reverse-identification from JSON features.
221
-
222
- ### Constraint Rules (29 total)
223
-
224
- | Category | Count | Scope |
225
- |----------|-------|-------|
226
- | Creation (MC-C) | 19 | Node count, pair count, forward count, name uniqueness, permission validity, Guard existence, etc. |
227
- | Structure (MC-S) | 5 | Entry point, terminal, no orphan nodes, no dead branches, no cycles |
228
- | Publish (MC-P) | 5 | Guards tested, backup exported, testnet validation, user confirmation, Service exists |
229
- | Runtime (MC-R) | 3 | Post-publish immutability, session accumulation, competing Pair first-wins |
230
-
231
- ---
232
-
233
- ## 5. Risk Assessment Rules (40 Rules, 5 Dimensions)
234
-
235
- ### R-M1: Structural Integrity (10 rules)
236
-
237
- | ID | Risk | Severity | Description |
238
- |----|------|----------|-------------|
239
- | R-M1-01 | No entry point | CRITICAL | No Pair with `prev_node == ""` |
240
- | R-M1-02 | No terminal node | CRITICAL | No node with empty outgoing Pairs |
241
- | R-M1-03 | Dead-end node | MEDIUM | Non-terminal node with no outgoing Pair |
242
- | R-M1-04 | Orphan node | HIGH | Non-entry node with no incoming Pair |
243
- | R-M1-05 | Dead branch | HIGH | Competing Pair threshold never achievable |
244
- | R-M1-06 | Cycle reference | CRITICAL | Internal cycle via DFS detection |
245
- | R-M1-07 | Node count exceeded | CRITICAL | `nodes.length > MAX_NODE_COUNT_SDK(100)` |
246
- | R-M1-08 | Pair count exceeded | HIGH | Single node `pairs.length > 40` |
247
- | R-M1-09 | Forward count exceeded | HIGH | Single Pair `forwards.length > 20` |
248
- | R-M1-10 | Duplicate node name | CRITICAL | Multiple nodes with same name |
249
-
250
- ### R-M2: Guard Integration (8 rules)
251
-
252
- | ID | Risk | Severity | Description |
253
- |----|------|----------|-------------|
254
- | R-M2-01 | Guard not created | CRITICAL | Referenced Guard object doesn't exist |
255
- | R-M2-02 | Guard not tested | HIGH | Guard not verified via gen_passport |
256
- | R-M2-03 | Guard+Machine deadlock | CRITICAL | Bug found after both are immutable |
257
- | R-M2-04 | retained_submission mismatch | HIGH | Index doesn't match Guard table b_submission=true |
258
- | R-M2-05 | Guard reentrancy | HIGH | Missing anti-reentry mechanism |
259
- | R-M2-06 | Guard scene mismatch | MEDIUM | Guard scene doesn't match Forward purpose |
260
- | R-M2-07 | Cross-Machine cycle | CRITICAL | A depends on B, B depends on A |
261
- | R-M2-08 | Guard references unpublished object | HIGH | Guard table references unpublished object |
262
-
263
- ### R-M3: Permission Dynamics (8 rules)
264
-
265
- | ID | Risk | Severity | Description |
266
- |----|------|----------|-------------|
267
- | R-M3-01 | Forward has no permission | CRITICAL | Both namedOperator and permissionIndex are null |
268
- | R-M3-02 | permissionIndex out of bounds | CRITICAL | `>= Permission.indices.length` |
269
- | R-M3-03 | Permission rotation | HIGH | indices reordered after Permission update |
270
- | R-M3-04 | OrderHolder misuse | MEDIUM | `namedOperator: ""` on non-customer operation |
271
- | R-M3-05 | NamedOperator not assigned | HIGH | Progress created without namedOperator values |
272
- | R-M3-06 | Imbalanced permission dynamics | MEDIUM | Single party can unilaterally advance |
273
- | R-M3-07 | Mixed permission OR misuse | MEDIUM | Both permissions set, OR semantics misunderstood |
274
- | R-M3-08 | permissionIndex < 1000 | CRITICAL | Uses system-reserved index range |
275
-
276
- ### R-M4: Immutability & Publish (6 rules)
277
-
278
- | ID | Risk | Severity | Description |
279
- |----|------|----------|-------------|
280
- | R-M4-01 | No backup before publish | HIGH | machineNode2file not executed |
281
- | R-M4-02 | No testnet validation | MEDIUM | Direct mainnet publish without testnet test |
282
- | R-M4-03 | Guard not all created | CRITICAL | Some required Guards still null |
283
- | R-M4-04 | Wrong publish order | CRITICAL | Published Machine before creating Guards |
284
- | R-M4-05 | Allocation not configured | MEDIUM | Terminal nodes not mapped to Allocator |
285
- | R-M4-06 | No backup before clear | HIGH | `clear` operation without machineNode2file |
286
-
287
- ### R-M5: Environment Awareness (8 rules)
288
-
289
- | ID | Risk | Severity | Description |
290
- |----|------|----------|-------------|
291
- | R-M5-01 | Service not created | HIGH | No Service object for Machine to bind |
292
- | R-M5-02 | Permission mismatch | HIGH | Machine and Service use different Permission |
293
- | R-M5-03 | Allocation incomplete | HIGH | order_allocators not configured |
294
- | R-M5-04 | Reward not created | MEDIUM | Reward object missing |
295
- | R-M5-05 | Arbitration not created | MEDIUM | Arbitration object missing |
296
- | R-M5-06 | Cross-Machine not published | CRITICAL | Machine B (dependency) not published |
297
- | R-M5-07 | Repository not created | MEDIUM | Guard-referenced Repository missing |
298
- | R-M5-08 | Incomplete dependency table | LOW | Missing objects in project scan |
299
-
300
- ### Risk Level & Publish Decision
301
-
302
- | Overall Risk | Decision | User Confirmation |
303
- |-------------|----------|-------------------|
304
- | CRITICAL | ❌ Block | Must fix all critical |
305
- | HIGH | ⚠️ Warn | User acknowledges risk |
306
- | MEDIUM | ✅ Allow | Informational |
307
- | LOW | ✅ Allow | No confirmation needed |
308
-
309
- ### Auto-Fixable Rules
310
-
311
- | Risk ID | Auto-Fix | Method |
312
- |---------|----------|--------|
313
- | R-M2-04 | ✅ | Auto-correct retained_submission indices |
314
- | R-M4-01 | ✅ | Auto-execute machineNode2file |
315
- | R-M4-06 | ✅ | Auto-export backup before clear |
316
-
317
- ---
318
-
319
- ## 6. User Confirmation & Publish Flow
320
-
321
- ### 4-Layer ConfirmGate Architecture
322
-
323
- ```
324
- Layer 1: Static Checklist (11 hard constraints)
325
- → topology, permission, Guard binding, on-chain limits, Allocator
326
- ↓ [Pass?]
327
- Layer 2: Risk Assessment (40 rules, 5 dimensions)
328
- → identify blocking risks
329
- ↓ [No CRITICAL/HIGH?]
330
- Layer 3: User Confirmation Dialog
331
- → 6 questions (Q1-Q6), all must be "Yes"
332
- ↓ [User approves?]
333
- Layer 4: Environment Verification
334
- → testnet test mandatory for mainnet, dependency check, gas estimation
335
- ↓ [All green?]
336
- EXECUTE: onchain_operations publish: true
337
- ```
338
-
339
- ### 11 Static Checklist Items (C-01 to C-11)
340
-
341
- | ID | Check | Description |
342
- |----|-------|-------------|
343
- | C-01 | Entry point exists | At least one Pair with `prev_node=""` |
344
- | C-02 | Outgoing Forwards | Every non-terminal node has outgoing Pairs |
345
- | C-03 | Incoming Pairs | Every non-entry node has incoming Pair |
346
- | C-04 | Thresholds achievable | No dead branches (competing Pair always loses) |
347
- | C-05 | Guards exist on-chain | All referenced Guard addresses are valid |
348
- | C-06 | Forward permissions correct | Each Forward has namedOperator or permissionIndex |
349
- | C-07 | On-chain limits respected | `MAX_NODE_COUNT_SDK=100`, `MAX_NODE_PAIR_COUNT=40`, `MAX_FORWARD_COUNT=20`, `MAX_FORWARD_ORDER_COUNT=20` |
350
- | C-08 | Terminal → Allocator mapping | Terminal nodes mapped for fund distribution |
351
- | C-09 | Testnet test passed | End-to-end test on testnet (mandatory for mainnet) |
352
- | C-10 | machineNode2file backup | Current state exported before publish |
353
- | C-11 | permissionIndex ≥ 1000 | Custom permission indices respect `USER_DEFINED_PERM_INDEX_START` |
354
-
355
- ### User Confirmation Questions (Q1-Q6)
356
-
357
- 1. Reviewed topology and confirmed all nodes/forwards are correct?
358
- 2. Tested on TESTNET with a successful Progress run?
359
- 3. All Guards created, bound, and verified via gen_passport?
360
- 4. All Allocators configured for terminal nodes?
361
- 5. Acknowledge publishing is IRREVERSIBLE and gas will be consumed?
362
- 6. Proceed with publishing NOW?
363
-
364
- ### Override Mechanism
365
-
366
- - **HIGH risks**: Override allowed with explicit reason (for audit trail)
367
- - **CRITICAL risks**: Override NOT allowed — must fix
368
- - **Other statuses**: No override
369
-
370
- ### Testnet-First Policy
371
-
372
- **All projects must test on testnet before mainnet deployment**:
373
- - Testnet: free gas, repeatable, discardable
374
- - Mainnet: real gas, irreversible, errors require new Machine
375
- - Same JSON config for both networks (only `env.network` differs)
376
- - `replaceExistName: true` ensures repeatable execution
377
-
378
- ### Key Design Decisions
379
-
380
- 1. **Fail-closed**: Default deny; all checks pass + user confirmation = proceed
381
- 2. **4 layers (not 3)**: Static checklist + Risk + User + Environment — no blind spots
382
- 3. **Testnet mandatory for mainnet**: Low test cost vs. extremely high mainnet fix cost
383
- 4. **CRITICAL risks never overridable**: Some risks (funds, reentrancy, Guard binding) are absolute blockers
384
- 5. **C-07 uses SDK limit (100) not chain limit (200)**: Ensures human-reviewable Machine size
385
- 6. **C-11 enforces 1000 boundary**: Prevents confusion between built-in (0-999) and custom (≥1000) permission indices
386
-
387
- ---
388
-
389
- ## 7. Additional Design Principles
390
-
391
- 1. **Deterministic-first**: All rules are deterministic rule tables and algorithms, not AI "understanding"
392
- 2. **Reversibility guarantee**: Semantic ↔ JSON ↔ On-chain, each layer has forward generation and reverse explanation
393
- 3. **Context awareness**: Machine design must perceive Service/Permission/Guard/Allocation/Reward objects
394
- 4. **Irreversibility protection**: 100% user confirmation before publish, ConfirmGate fail-closed
395
- 5. **Object dependency order**: Machine(unpublished) → Guard(references Machine) → bind Forward → publish
396
- 6. **Cycle-friendly**: Directed graph (not DAG), cycles allowed but each must have reachable exit condition
397
- 7. **Complete deployment file**: Each project delivers a unified execution manual (testnet + mainnet) with `replaceExistName: true`
398
- 8. **Post-publish testing cannot replace pre-publish audit**: Core fields are frozen after publish
@@ -1,227 +0,0 @@
1
- # Machine Scenario Ledger
2
-
3
- > **Purpose**: Complete, deterministic catalog of all canonical Machine workflows on WoWok protocol.
4
-
5
- ---
6
-
7
- ## Scene Definition Interface
8
-
9
- ```typescript
10
- export interface MachineScene {
11
- id: string;
12
- name: string;
13
- industry: string[];
14
- scenario: string;
15
- participants: ParticipantRoleDef[];
16
- recommended_patterns: string[];
17
- recommended_topology: string[];
18
- guard_requirements: GuardRequirement[];
19
- allocation_integration: string;
20
- special_constraints: string[];
21
- mutable_after_publish: boolean;
22
- m_rounds_focus: string[];
23
- }
24
- ```
25
-
26
- Each scene defines: (1) business scenario, (2) participants & permission model, (3) recommended execution pattern (Sequential/AND/OR/Vote/Hybrid), (4) recommended branch topology (Linear/ForkMerge/Competing), (5) Guard integration requirements, (6) fund allocation integration, (7) special constraints.
27
-
28
- ---
29
-
30
- ## Scene Catalog (10 Scenes)
31
-
32
- ### 1. Standard E-Commerce
33
- - **ID**: `ecommerce_standard`
34
- - **Industry**: ecommerce
35
- - **Flow**: Order → Payment → Ship → Receive → Complete
36
- - **Pattern**: P-M-SEQ | **Topology**: P-M-LINEAR
37
- - **Participants**: customer (OrderHolder), merchant (Permission)
38
- - **Guards**: `machine_forward_guard` on Ship (verify payment), Receive (verify identity)
39
- - **Allocation**: Complete node → Allocator disburses to merchant
40
- - **Constraints**: Payment must complete before shipping; auto-trigger allocation on receipt
41
- - **Mutable after publish**: false
42
- - **Rounds**: M1, M2, M3, M5, M8
43
-
44
- ### 2. E-Commerce with Exception Branches
45
- - **ID**: `ecommerce_with_exceptions`
46
- - **Industry**: ecommerce
47
- - **Flow**: Order→Payment→Ship→{Receive→Complete | Lost→Arbitration | Return→Refund}
48
- - **Pattern**: P-M-SEQ, P-M-COMPETING | **Topology**: P-M-LINEAR, P-M-COMPETING
49
- - **Participants**: customer (OrderHolder), merchant (Permission), arbitrator (NamedOperator)
50
- - **Guards**: `machine_forward_guard` (dual-sign lost), `arbitration_usage_guard` (verify arbitration eligibility)
51
- - **Allocation**: Complete→merchant | Refund→refund allocation | Arb→arbitration allocation
52
- - **Constraints**: Lost node threshold=2 (customer+merchant dual-sign); competing Pair: Receive vs Lost (first-wins); arbitration independent of main flow
53
- - **Mutable after publish**: false
54
- - **Rounds**: M1, M2, M3, M5, M6, M8
55
-
56
- ### 3. Rental Standard
57
- - **ID**: `rental_standard`
58
- - **Industry**: rental
59
- - **Flow**: Book → Pay Deposit → Pick Up → In Use → Return → Refund Deposit
60
- - **Pattern**: P-M-SEQ | **Topology**: P-M-LINEAR
61
- - **Participants**: customer (OrderHolder), merchant (Permission)
62
- - **Guards**: `machine_forward_guard` on Pick Up (verify deposit), Return (verify equipment status)
63
- - **Allocation**: Return complete → deposit refund + rental allocation
64
- - **Constraints**: Deposit and rental separated (two Allocators); equipment damage requires Guard verification via `retained_submission`
65
- - **Mutable after publish**: false
66
- - **Rounds**: M1, M2, M3, M5, M8
67
-
68
- ### 4. Dual-Signature Consensus
69
- - **ID**: `dual_signature`
70
- - **Industry**: ecommerce, service, logistics
71
- - **Flow**: Critical node requires both customer + merchant confirmation
72
- - **Pattern**: P-M-AND | **Topology**: P-M-LINEAR
73
- - **Participants**: customer (OrderHolder), merchant (Permission)
74
- - **Guards**: `machine_forward_guard` on dual confirmation (verify identity)
75
- - **Allocation**: After dual confirmation → fund allocation
76
- - **Constraints**: threshold=2, two Forwards weight=1 each; customer Forward: namedOperator='' (OrderHolder); merchant Forward: permissionIndex=2
77
- - **Mutable after publish**: false
78
- - **Rounds**: M3, M4, M5
79
-
80
- ### 5. Weighted Voting
81
- - **ID**: `weighted_voting`
82
- - **Industry**: governance, arbitration
83
- - **Flow**: Multi-party weighted voting, cumulative threshold to advance
84
- - **Pattern**: P-M-VOTE | **Topology**: P-M-LINEAR
85
- - **Participants**: chief (Permission), member (NamedOperator)
86
- - **Guards**: `arbitration_voting_guard` (verify voting eligibility + extract weight)
87
- - **Allocation**: After voting → result execution
88
- - **Constraints**: threshold=100, chief weight=60, member weight=40; GuardIdentifier must be numeric (weight extraction); prevent double-voting (Guard queries arb.voted has)
89
- - **Mutable after publish**: false
90
- - **Rounds**: M3, M4, M5
91
-
92
- ### 6. Cross-Machine Supply Chain
93
- - **ID**: `cross_machine_supply_chain`
94
- - **Industry**: manufacturing, logistics, retail
95
- - **Flow**: Supplier → Manufacturer → Retailer, each step an independent Machine
96
- - **Pattern**: P-M-CROSS-MACHINE | **Topology**: P-M-LINEAR
97
- - **Participants**: supplier (Permission, Machine A), manufacturer (Permission, Machine B), retailer (Permission, Machine C)
98
- - **Guards**: `machine_forward_guard` on Start Manufacturing (verify supplier Progress complete), Start Retail (verify manufacturer Progress complete)
99
- - **Allocation**: Each Machine allocates independently
100
- - **Constraints**: Machine B Guard uses `convert_witness=100` to query Machine A's Progress; cross-Machine dependency is one-way (no cycles); each Machine must be published independently
101
- - **Mutable after publish**: false
102
- - **Rounds**: M1, M3, M8
103
-
104
- ### 7. Privacy Delivery
105
- - **ID**: `privacy_delivery`
106
- - **Industry**: ecommerce, logistics
107
- - **Flow**: Deliver private info (address/credentials) via Messenger; only Proof stored on-chain
108
- - **Pattern**: P-M-SEQ | **Topology**: P-M-LINEAR
109
- - **Participants**: customer (OrderHolder, Submit Proof), merchant (Permission, Verify Proof)
110
- - **Guards**: `machine_forward_guard` on Submit Proof (verify Proof signature + timestamp)
111
- - **Allocation**: After Proof verification → continue flow
112
- - **Constraints**: Uses `tpl_forward_privacy_delivery_proof` template; `retained_submission` retains Proof address for arbitration queries; Proof must be generated by `messenger.submitChainProof`
113
- - **Mutable after publish**: false
114
- - **Rounds**: M1, M3, M7
115
-
116
- ### 8. Reward Incentive
117
- - **ID**: `reward_incentive`
118
- - **Industry**: ecommerce, subscription, education
119
- - **Flow**: Trigger Reward claim upon completing specific nodes
120
- - **Pattern**: P-M-SEQ | **Topology**: P-M-LINEAR
121
- - **Participants**: customer (OrderHolder, Claim reward), platform (Permission, Issue reward)
122
- - **Guards**: `reward_guard` (verify claim eligibility + prevent duplicates)
123
- - **Allocation**: Reward independent of Allocation
124
- - **Constraints**: Reward Guard must prevent duplicates (R-X1-14 CRITICAL); uses `query_reward_record_count == 0` for reentrancy prevention; Reward object must have been created
125
- - **Mutable after publish**: false
126
- - **Rounds**: M1, M3, M8
127
-
128
- ### 9. Arbitration Flow
129
- - **ID**: `arbitration_flow`
130
- - **Industry**: ecommerce, service, rental
131
- - **Flow**: Dispute → Submit Arbitration → Vote → Ruling → Execute
132
- - **Pattern**: P-M-VOTE, P-M-SEQ | **Topology**: P-M-LINEAR
133
- - **Participants**: disputant (OrderHolder), arbitrator (NamedOperator), system (Permission)
134
- - **Guards**: `arbitration_usage_guard` (verify dispute eligibility + prevent duplicates), `arbitration_voting_guard` (verify voting eligibility + extract weight)
135
- - **Allocation**: After ruling → disburse funds per ruling
136
- - **Constraints**: Arbitration object must exist; prevent duplicate disputes (R-X1-14 HIGH); prevent duplicate votes (R-X1-14 CRITICAL); MAX_DISPUTE_COUNT=10 per order
137
- - **Mutable after publish**: false
138
- - **Rounds**: M1, M3, M4, M5, M8
139
-
140
- ### 10. Subscription / Membership
141
- - **ID**: `subscription`
142
- - **Industry**: subscription, service
143
- - **Flow**: Subscribe → Pay → Activate → Periodic Renewal → Expire/Cancel
144
- - **Pattern**: P-M-SEQ, P-M-COMPETING | **Topology**: P-M-LINEAR, P-M-COMPETING
145
- - **Participants**: subscriber (OrderHolder), provider (Permission)
146
- - **Guards**: `machine_forward_guard` on Renewal (time-lock verification), Cancel (verify subscription status)
147
- - **Allocation**: Renewal → fund allocation | Expire → stop service
148
- - **Constraints**: Time-lock: `context(Clock) >= progress.entry_time + duration`; competing Pair: Renewal vs Expire (first-wins); requires Repository to record subscription status
149
- - **Mutable after publish**: false
150
- - **Rounds**: M1, M3, M6, M8
151
-
152
- ---
153
-
154
- ## Scene Identification Patterns
155
-
156
- ```typescript
157
- export function inferSceneFromFlow(description: string): MachineScene | undefined {
158
- const lower = description.toLowerCase();
159
-
160
- if (lower.includes("supply chain") || lower.includes("cross machine")) return findScene("cross_machine_supply_chain");
161
- if (lower.includes("arbitration") || lower.includes("dispute")) return findScene("arbitration_flow");
162
- if (lower.includes("reward") || lower.includes("incentive")) return findScene("reward_incentive");
163
- if (lower.includes("privacy") || lower.includes("messenger")) return findScene("privacy_delivery");
164
- if (lower.includes("voting") || lower.includes("weighted")) return findScene("weighted_voting");
165
- if (lower.includes("dual sign") || lower.includes("dual confirmation")) return findScene("dual_signature");
166
- if (lower.includes("subscription") || lower.includes("membership")) return findScene("subscription");
167
- if (lower.includes("rental")) return findScene("rental_standard");
168
- if (lower.includes("lost") || lower.includes("return") || lower.includes("refund")) return findScene("ecommerce_with_exceptions");
169
- if (lower.includes("ecommerce") || lower.includes("order")) return findScene("ecommerce_standard");
170
-
171
- return undefined;
172
- }
173
- ```
174
-
175
- ---
176
-
177
- ## Scene-to-Guard Mapping
178
-
179
- | Machine Scene | Guard Scene(s) | Relationship |
180
- |---|---|---|
181
- | ecommerce_standard | `machine_forward_guard` | Forward binds Guard |
182
- | ecommerce_with_exceptions | `machine_forward_guard` + `arbitration_usage_guard` | Exception branches bind arbitration Guard |
183
- | rental_standard | `machine_forward_guard` | Standard Forward Guard |
184
- | dual_signature | `machine_forward_guard` | Dual-sign Forwards each bind Guard |
185
- | weighted_voting | `arbitration_voting_guard` | Voting uses voting_guard |
186
- | cross_machine_supply_chain | `machine_forward_guard` | Cross-Machine query via Forward Guard |
187
- | privacy_delivery | `machine_forward_guard` | Uses `tpl_forward_privacy_delivery_proof` template |
188
- | reward_incentive | `reward_guard` | Reward claim uses reward_guard |
189
- | arbitration_flow | `arbitration_usage_guard` + `arbitration_voting_guard` | Full arbitration lifecycle |
190
- | subscription | `machine_forward_guard` + `repository_write_guard` | Subscription status written to Repository |
191
-
192
- ---
193
-
194
- ## Key Constraints Summary
195
-
196
- | Scene | Key Special Constraints |
197
- |---|---|
198
- | ecommerce_standard | Payment must complete before shipping |
199
- | ecommerce_with_exceptions | Lost node dual-sign; competing Pair first-wins |
200
- | rental_standard | Deposit and rental separated; equipment damage `retained_submission` |
201
- | dual_signature | threshold=2; customer+merchant different permissions |
202
- | weighted_voting | threshold=100; prevent double-vote (R-X1-14 CRITICAL) |
203
- | cross_machine_supply_chain | One-way cross-Machine dependency; `convert_witness=100` |
204
- | privacy_delivery | Uses `tpl_forward_privacy_delivery_proof`; `retained_submission` retains Proof |
205
- | reward_incentive | Prevent duplicate claim (R-X1-14 CRITICAL); `query_reward_record_count==0` |
206
- | arbitration_flow | Prevent duplicate dispute (R-X1-14 HIGH); MAX_DISPUTE_COUNT=10 |
207
- | subscription | Time-lock; competing Pair (Renewal vs Expire); Repository records status |
208
-
209
- ---
210
-
211
- ## Execution Patterns & Topologies Reference
212
-
213
- ### Patterns
214
- - **P-M-SEQ**: Sequential execution — nodes advance one by one in order
215
- - **P-M-AND**: AND-join — multiple Forwards must all fire before the node advances
216
- - **P-M-VOTE**: Weighted voting — Forwards carry weights; node advances when cumulative weight reaches threshold
217
- - **P-M-COMPETING**: Competing branches — first Forward to fire wins, others are invalidated
218
- - **P-M-CROSS-MACHINE**: Cross-Machine — one Machine's Progress gates another Machine's Forward
219
-
220
- ### Topologies
221
- - **P-M-LINEAR**: Linear chain — nodes arranged in a straight sequence
222
- - **P-M-FORKMERGE**: Fork-Merge — branches split and later rejoin
223
- - **P-M-COMPETING**: Competing — mutually exclusive branches, first-wins semantics
224
-
225
- ---
226
-
227
- *All 10 scenes are immutable after publish (`mutable_after_publish: false`).*