@wowok/skills 1.2.3 → 1.2.5
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 +34 -16
- package/dist/cli.js +6 -2
- package/dist/cli.js.map +1 -1
- package/dist/skills.d.ts +32 -1
- package/dist/skills.d.ts.map +1 -1
- package/dist/skills.js +63 -0
- package/dist/skills.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/examples/Insurance/Insurance.md +543 -475
- package/examples/MyShop/MyShop.md +865 -746
- package/examples/MyShop_Advanced/MyShop_Advanced.md +1520 -1376
- package/examples/ThreeBody_Signature/ThreeBody_Signature.md +891 -651
- package/examples/Travel/Travel.md +952 -848
- package/package.json +2 -2
- package/scripts/install.js +3 -17
- package/wowok-arbitrator/SKILL.md +18 -57
- package/wowok-auditor/SKILL.md +16 -12
- package/wowok-distill/SKILL.md +237 -0
- package/wowok-guard/SKILL.md +40 -354
- package/wowok-machine/SKILL.md +21 -127
- package/wowok-messenger/SKILL.md +14 -59
- package/wowok-onboard/SKILL.md +42 -12
- package/wowok-order/SKILL.md +20 -169
- package/wowok-output/SKILL.md +0 -10
- package/wowok-planner/SKILL.md +28 -9
- package/wowok-provider/SKILL.md +91 -49
- package/wowok-safety/SKILL.md +8 -80
- package/wowok-scenario/SKILL.md +63 -98
- package/wowok-tools/SKILL.md +111 -122
- package/references/glossary.ts +0 -297
- package/references/guard-scenario-ledger.md +0 -353
- package/references/guard-template-library.md +0 -481
- package/references/machine-design-reference.md +0 -398
- package/references/machine-scenario-ledger.md +0 -227
- package/references/machine-template-library.md +0 -522
- package/references/merchant-scenario-coordination.md +0 -383
- package/references/object-collaboration.md +0 -362
- package/references/onchain-constants.md +0 -81
- package/wowok-arbitrator/APPENDIX.md +0 -545
- package/wowok-auditor/APPENDIX.md +0 -487
- package/wowok-guard/APPENDIX.md +0 -428
- package/wowok-machine/APPENDIX.md +0 -407
- package/wowok-messenger/APPENDIX.md +0 -550
- package/wowok-onboard/APPENDIX.md +0 -500
- package/wowok-order/APPENDIX.md +0 -777
- package/wowok-output/APPENDIX.md +0 -575
- package/wowok-planner/APPENDIX.md +0 -724
- package/wowok-provider/APPENDIX.md +0 -453
- package/wowok-safety/APPENDIX.md +0 -561
- package/wowok-scenario/APPENDIX.md +0 -97
- package/wowok-scenario/MODE-DETAILS.md +0 -275
- package/wowok-tools/APPENDIX.md +0 -388
|
@@ -1,522 +0,0 @@
|
|
|
1
|
-
# Machine Template Library
|
|
2
|
-
|
|
3
|
-
> Reference covering the WoWok Machine semantic layer template library design specification.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Core Thesis
|
|
8
|
-
|
|
9
|
-
The Machine Template Library is a parameterized template catalog for the Machine semantic layer (`machine-templates.ts`). Its goals:
|
|
10
|
-
|
|
11
|
-
1. **Lower design barrier**: Provide parameterized skeletons for common scenarios — AI only replaces variables instead of designing from scratch
|
|
12
|
-
2. **Guarantee correctness**: Templates embed Pattern matching, constraint rules, and risk pre-assessment
|
|
13
|
-
3. **Support Fork-Modify**: Templates serve as fork starting points; users adapt them into custom workflows (participation mode P-M5)
|
|
14
|
-
4. **Cross-reference, not duplicate**: Templates cross-reference the Ledger scene catalog, Translation patterns, and Risk rules rather than redefining them
|
|
15
|
-
|
|
16
|
-
### Design Principles (aligned with Guard Template Library)
|
|
17
|
-
|
|
18
|
-
- **Pure Data, No I/O**: Templates are pure data, no file I/O or MCP calls
|
|
19
|
-
- **Parameterized**: Use `${param}` placeholders with constrained types
|
|
20
|
-
- **Aligned with Ledger**: Each template binds a `scene_id` matching `machine-ledger.ts`
|
|
21
|
-
- **Aligned with Pattern**: Each template declares `recommended_patterns` matching `machine-translation.ts`
|
|
22
|
-
- **Cross-referenced with Risk**: Each template declares `relevant_risks` matching `machine-risk.ts`
|
|
23
|
-
- **Fork-Friendly**: Templates annotate `forkable_fields` — which fields users may safely modify
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
## Template Interface
|
|
28
|
-
|
|
29
|
-
### Parameter Types
|
|
30
|
-
|
|
31
|
-
```typescript
|
|
32
|
-
export type MachineTemplateParamType =
|
|
33
|
-
| "address"
|
|
34
|
-
| "string"
|
|
35
|
-
| "number"
|
|
36
|
-
| "boolean"
|
|
37
|
-
| "vec_address"
|
|
38
|
-
| "vec_string"
|
|
39
|
-
| "node_name_list" // Uniqueness + naming rule validation
|
|
40
|
-
| "permission_ref" // Permission object address or name
|
|
41
|
-
| "guard_ref" // Guard object address or name
|
|
42
|
-
| "machine_ref" // Machine object address or name (cross-machine)
|
|
43
|
-
| "service_ref" // Service object address or name
|
|
44
|
-
| "arbitration_ref" // Arbitration object address or name
|
|
45
|
-
| "reward_ref"; // Reward object address or name
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Parameter Definition
|
|
49
|
-
|
|
50
|
-
```typescript
|
|
51
|
-
export interface MachineTemplateParam {
|
|
52
|
-
name: string; // Variable placeholder, e.g. "merchant_permission"
|
|
53
|
-
type: MachineTemplateParamType;
|
|
54
|
-
description: string; // Semantic description (business meaning)
|
|
55
|
-
required: boolean;
|
|
56
|
-
default?: string; // Optional default value
|
|
57
|
-
constraint?: string; // Constraint rule description
|
|
58
|
-
validation?: string; // Validation regex or rule (optional)
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### Template Definition
|
|
63
|
-
|
|
64
|
-
```typescript
|
|
65
|
-
export interface MachineTemplate {
|
|
66
|
-
id: string;
|
|
67
|
-
scene_id: string; // Maps to machine-ledger.ts MACHINE_SCENES
|
|
68
|
-
name: string;
|
|
69
|
-
description: string;
|
|
70
|
-
recommended_patterns: string[]; // Maps to machine-translation.ts
|
|
71
|
-
recommended_topology: string[];
|
|
72
|
-
parameters: MachineTemplateParam[];
|
|
73
|
-
example_nodes: object; // Uses ${param} placeholders
|
|
74
|
-
example_pairs: object;
|
|
75
|
-
example_forwards: object;
|
|
76
|
-
required_guards: Array<{ // Cross-ref to guard-templates.ts
|
|
77
|
-
guard_template_id: string;
|
|
78
|
-
bound_to_forward: string;
|
|
79
|
-
purpose: string;
|
|
80
|
-
}>;
|
|
81
|
-
required_permissions: Array<{
|
|
82
|
-
index: number;
|
|
83
|
-
name: string;
|
|
84
|
-
description: string;
|
|
85
|
-
}>;
|
|
86
|
-
required_allocators: Array<{
|
|
87
|
-
name: string;
|
|
88
|
-
trigger_node: string;
|
|
89
|
-
description: string;
|
|
90
|
-
}>;
|
|
91
|
-
forkable_fields: string[]; // Fields safe to modify when forking
|
|
92
|
-
applicable_industries: string[];
|
|
93
|
-
relevant_risks: string[]; // Cross-ref to machine-risk.ts
|
|
94
|
-
creation_notes: string[];
|
|
95
|
-
example_use_case: string;
|
|
96
|
-
publish_checklist: string[]; // Must be verified before publish
|
|
97
|
-
}
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
---
|
|
101
|
-
|
|
102
|
-
## Template Catalog (10 Scenarios)
|
|
103
|
-
|
|
104
|
-
### 1. `tpl_machine_ecommerce_standard` — Standard E-commerce Flow
|
|
105
|
-
|
|
106
|
-
| Field | Value |
|
|
107
|
-
|---|---|
|
|
108
|
-
| **scene_id** | `ecommerce_standard` |
|
|
109
|
-
| **Patterns** | `P-M-SEQ` |
|
|
110
|
-
| **Topology** | `P-M-LINEAR` |
|
|
111
|
-
| **Description** | Linear e-commerce: Order → Pay → Ship → Receive → Complete. Funds auto-allocated to merchant at Complete. Recommended baseline for new merchants. |
|
|
112
|
-
| **Key params** | `merchant_permission`, `ship_forward_name`, `receive_forward_name`, `pay_guard_name`, `complete_node_name` |
|
|
113
|
-
| **Nodes** | OrderCreated → Paid → Shipped → Received → `${complete_node_name}` |
|
|
114
|
-
| **Key Guards** | `tpl_buy_guard_whitelist` on Pay forward (verify payment) |
|
|
115
|
-
| **Permissions** | index 2: merchant (Ship + Finish), index 3: admin (optional) |
|
|
116
|
-
| **Allocators** | MerchantAllocation triggered at `${complete_node_name}` (100% to merchant) |
|
|
117
|
-
| **Industries** | ecommerce, retail |
|
|
118
|
-
| **Risks** | R-M1-01, R-M1-02, R-M1-08, R-M2-01, R-M3-02, R-M4-01 |
|
|
119
|
-
|
|
120
|
-
### 2. `tpl_machine_ecommerce_exceptions` — E-commerce with Exception Branches
|
|
121
|
-
|
|
122
|
-
| Field | Value |
|
|
123
|
-
|---|---|
|
|
124
|
-
| **scene_id** | `ecommerce_with_exceptions` |
|
|
125
|
-
| **Patterns** | `P-M-SEQ`, `P-M-COMPETING` |
|
|
126
|
-
| **Topology** | `P-M-LINEAR`, `P-M-COMPETING` |
|
|
127
|
-
| **Description** | Multi-path: Pay → Ship → Receive/Lost/Return. Lost uses dual-sig (threshold=2). Return path opens Refund → Complete. Competing pairs first-wins. |
|
|
128
|
-
| **Key params** | `merchant_permission`, `lost_threshold` (default 2), `arbitration_ref`, `time_guard_days` (default 10), `return_node_name` |
|
|
129
|
-
| **Nodes** | OrderCreated → Paid → Shipped → {Received, Lost, Return} → {Complete, Refund → Complete} |
|
|
130
|
-
| **Key Guards** | `tpl_forward_node_check` (Pay), `tpl_forward_dual_signature` (MerchantConfirm), `tpl_forward_time_guard` (TimeGuard) |
|
|
131
|
-
| **Permissions** | index 2: merchant, index 3: admin / time-guard trigger |
|
|
132
|
-
| **Allocators** | CompleteAllocation (normal), RefundAllocation (refund to customer), LostAllocation (optional) |
|
|
133
|
-
| **Industries** | ecommerce, logistics |
|
|
134
|
-
|
|
135
|
-
### 3. `tpl_machine_rental` — Equipment Rental Flow
|
|
136
|
-
|
|
137
|
-
| Field | Value |
|
|
138
|
-
|---|---|
|
|
139
|
-
| **scene_id** | `rental_standard` |
|
|
140
|
-
| **Patterns** | `P-M-SEQ` |
|
|
141
|
-
| **Topology** | `P-M-LINEAR` |
|
|
142
|
-
| **Description** | Reserve → Pay Deposit → Pickup → In Use → Return → Refund Deposit. Separates deposit from rental fee (two Allocators). Damage report via `retained_submission`. |
|
|
143
|
-
| **Key params** | `merchant_permission`, `deposit_amount`, `damage_inspection_node` (default DamageCheck), `return_node_name` |
|
|
144
|
-
| **Nodes** | Reserved → DepositPaid → PickedUp → InUse → Return → {DamageCheck → DepositRefund, Complete} → Complete |
|
|
145
|
-
| **Key Guards** | `tpl_allocator_threshold` (PayDeposit), `tpl_forward_privacy_delivery_proof` (Inspect) |
|
|
146
|
-
| **Permissions** | index 2: merchant (rental provider) |
|
|
147
|
-
| **Allocators** | RentalFeeAllocation (Complete), DepositRefundAllocation (DepositRefund, to customer), DamageDeductionAllocation (DamageCheck, to merchant) |
|
|
148
|
-
| **Industries** | rental, equipment, vehicle |
|
|
149
|
-
|
|
150
|
-
### 4. `tpl_machine_dual_signature` — Dual-Signature Consensus Flow
|
|
151
|
-
|
|
152
|
-
| Field | Value |
|
|
153
|
-
|---|---|
|
|
154
|
-
| **scene_id** | `dual_signature` |
|
|
155
|
-
| **Patterns** | `P-M-AND` |
|
|
156
|
-
| **Topology** | `P-M-LINEAR` |
|
|
157
|
-
| **Description** | Critical node requires customer + merchant confirmation. threshold=2 with two Forwards (weight=1 each). Customer = OrderHolder, merchant = permissionIndex=2. |
|
|
158
|
-
| **Key params** | `merchant_permission`, `critical_node_name` (default Approve), `next_node_after_approval` (default Execute) |
|
|
159
|
-
| **Nodes** | Initiated → `${critical_node_name}` → `${next_node_after_approval}` → Complete |
|
|
160
|
-
| **Key Guards** | `tpl_forward_node_check` (CustomerApprove + MerchantApprove) |
|
|
161
|
-
| **Permissions** | index 2: merchant |
|
|
162
|
-
| **Industries** | ecommerce, service, logistics, escrow |
|
|
163
|
-
| **Note** | threshold=2 means BOTH Forwards must execute (AND semantics) |
|
|
164
|
-
|
|
165
|
-
### 5. `tpl_machine_weighted_voting` — Weighted Voting Flow
|
|
166
|
-
|
|
167
|
-
| Field | Value |
|
|
168
|
-
|---|---|
|
|
169
|
-
| **scene_id** | `weighted_voting` |
|
|
170
|
-
| **Patterns** | `P-M-VOTE` |
|
|
171
|
-
| **Topology** | `P-M-LINEAR` |
|
|
172
|
-
| **Description** | Multi-party voting with unequal weights. threshold=100, chief weight=60, members weight=40 total. Each member's weight extracted via Guard query from Arbitration object. |
|
|
173
|
-
| **Key params** | `arbitration_ref`, `threshold_total` (default 100), `chief_weight` (default 60), `member_count` (default 5) |
|
|
174
|
-
| **Nodes** | VoteOpened → Voting → {Approved, Rejected} |
|
|
175
|
-
| **Key Guards** | `tpl_arb_voting_guard` (ChiefVote + MemberVote — prevents double-vote) |
|
|
176
|
-
| **Permissions** | index 2: chief, index 3: admin |
|
|
177
|
-
| **Industries** | governance, arbitration, dao |
|
|
178
|
-
| **Critical Risk** | R-X1-14: double-vote prevention — Guard MUST check `arb.voted has [Signer]` |
|
|
179
|
-
|
|
180
|
-
### 6. `tpl_machine_cross_machine` — Cross-Machine Supply Chain
|
|
181
|
-
|
|
182
|
-
| Field | Value |
|
|
183
|
-
|---|---|
|
|
184
|
-
| **scene_id** | `cross_machine_supply_chain` |
|
|
185
|
-
| **Patterns** | `P-M-CROSS-MACHINE` |
|
|
186
|
-
| **Topology** | `P-M-LINEAR` |
|
|
187
|
-
| **Description** | Decomposed supply chain across multiple Machines. Machine B's Forward Guard queries Machine A's Progress via `convert_witness=100` to verify upstream completion. |
|
|
188
|
-
| **Key params** | `machine_a_id` (must be published first), `machine_a_complete_node`, `machine_b_permission` |
|
|
189
|
-
| **Nodes** | UpstreamVerified → Production → Complete |
|
|
190
|
-
| **Key Guards** | `tpl_forward_cross_machine_progress` (VerifyUpstream — queries Machine A's Progress) |
|
|
191
|
-
| **Permissions** | index 2: manufacturer |
|
|
192
|
-
| **Industries** | manufacturing, logistics, retail, supply_chain |
|
|
193
|
-
| **Constraint** | Machine A MUST be published before Machine B (dependency order, no cycles) |
|
|
194
|
-
|
|
195
|
-
### 7. `tpl_machine_privacy_delivery` — Privacy-Preserving Delivery Flow
|
|
196
|
-
|
|
197
|
-
| Field | Value |
|
|
198
|
-
|---|---|
|
|
199
|
-
| **scene_id** | `privacy_delivery` |
|
|
200
|
-
| **Patterns** | `P-M-SEQ` |
|
|
201
|
-
| **Topology** | `P-M-LINEAR` |
|
|
202
|
-
| **Description** | Customer submits privacy data via Messenger (encrypted, off-chain). Chain stores only Merkle Root Proof. Guard verifies Proof signature + timestamp + service binding. |
|
|
203
|
-
| **Key params** | `merchant_permission`, `proof_node_name` (default ProofSubmitted), `delivery_node_name` (default DeliveryConfirmed) |
|
|
204
|
-
| **Nodes** | OrderCreated → `${proof_node_name}` → `${delivery_node_name}` → Complete |
|
|
205
|
-
| **Key Guards** | `tpl_forward_privacy_delivery_proof` (strict mode — 3 conditions: Signer + time + service binding) |
|
|
206
|
-
| **Permissions** | index 2: merchant |
|
|
207
|
-
| **Industries** | ecommerce, logistics, privacy_service |
|
|
208
|
-
| **Note** | Guard table item name MUST be <64 BCS bytes (MAX_NAME_LENGTH=64) |
|
|
209
|
-
|
|
210
|
-
### 8. `tpl_machine_reward` — Reward Incentive Flow
|
|
211
|
-
|
|
212
|
-
| Field | Value |
|
|
213
|
-
|---|---|
|
|
214
|
-
| **scene_id** | `reward_incentive` |
|
|
215
|
-
| **Patterns** | `P-M-SEQ` |
|
|
216
|
-
| **Topology** | `P-M-LINEAR` |
|
|
217
|
-
| **Description** | Customer triggers Reward claim at specific node. Guard prevents double-claim via `query_reward_record_count==0`. Reward object independent of Allocator. |
|
|
218
|
-
| **Key params** | `reward_ref` (must be created before publishing), `claim_node_name` (default ClaimReward) |
|
|
219
|
-
| **Nodes** | Eligible → `${claim_node_name}` → Rewarded → Complete |
|
|
220
|
-
| **Key Guards** | `tpl_reward_anti_double` (TriggerClaim — prevents double-claim) |
|
|
221
|
-
| **Permissions** | index 2: merchant, index 3: reward_admin |
|
|
222
|
-
| **Industries** | ecommerce, subscription, education, loyalty |
|
|
223
|
-
| **Critical Risk** | R-X1-14: double-claim prevention — MUST check `query_reward_record_count == 0` |
|
|
224
|
-
|
|
225
|
-
### 9. `tpl_machine_arbitration` — Arbitration Flow
|
|
226
|
-
|
|
227
|
-
| Field | Value |
|
|
228
|
-
|---|---|
|
|
229
|
-
| **scene_id** | `arbitration_flow` |
|
|
230
|
-
| **Patterns** | `P-M-VOTE`, `P-M-SEQ` |
|
|
231
|
-
| **Topology** | `P-M-LINEAR` |
|
|
232
|
-
| **Description** | Dispute → Submit → Vote → Ruling → Execute. Uses `arbitration_usage_guard` + `arbitration_voting_guard`. MAX_DISPUTE_COUNT=10 per order. Dual-vote prevention mandatory. |
|
|
233
|
-
| **Key params** | `arbitration_ref`, `max_disputes` (default 10, hard limit), `voting_threshold` (default 100) |
|
|
234
|
-
| **Nodes** | DisputeOpened → EvidenceSubmitted → Voting → Ruling → Executed |
|
|
235
|
-
| **Key Guards** | `tpl_arb_usage_anti_double` (OpenDispute — dispute count < 10), `tpl_arb_voting_guard` (ChiefVote + MemberVote) |
|
|
236
|
-
| **Permissions** | index 2: chief_arbitrator, index 3: admin |
|
|
237
|
-
| **Industries** | arbitration, ecommerce, service, rental |
|
|
238
|
-
| **Critical Risk** | R-X1-14: double-dispute + double-vote prevention |
|
|
239
|
-
|
|
240
|
-
### 10. `tpl_machine_subscription` — Subscription / Membership Flow
|
|
241
|
-
|
|
242
|
-
| Field | Value |
|
|
243
|
-
|---|---|
|
|
244
|
-
| **scene_id** | `subscription` |
|
|
245
|
-
| **Patterns** | `P-M-SEQ`, `P-M-COMPETING` |
|
|
246
|
-
| **Topology** | `P-M-LINEAR`, `P-M-COMPETING` |
|
|
247
|
-
| **Description** | Subscribe → Pay → Activate → [Renew | Expire] → Cancel/End. Time-lock on Renew. Competing Pair: Renew vs Expire (first-wins). Repository stores status. |
|
|
248
|
-
| **Key params** | `merchant_permission`, `subscription_duration_days` (default 30), `repository_ref` |
|
|
249
|
-
| **Nodes** | Subscribed → Active → RenewEligible → {Renewed → Active, Expired → Ended, Cancelled → Ended} |
|
|
250
|
-
| **Key Guards** | `tpl_forward_time_guard` (TimeUnlock + AutoExpire), `tpl_repository_write_guard` (Activate) |
|
|
251
|
-
| **Permissions** | index 2: provider, index 3: admin |
|
|
252
|
-
| **Allocators** | RenewAllocation triggered at Renewed |
|
|
253
|
-
| **Industries** | subscription, saas, membership, service |
|
|
254
|
-
|
|
255
|
-
---
|
|
256
|
-
|
|
257
|
-
## Cross-Reference: Template ↔ Pattern / Risk
|
|
258
|
-
|
|
259
|
-
| Template ID | Patterns | Topology | Risk IDs |
|
|
260
|
-
|---|---|---|---|
|
|
261
|
-
| `tpl_machine_ecommerce_standard` | P-M-SEQ | P-M-LINEAR | R-M1-01, R-M1-02, R-M1-08, R-M2-01, R-M3-02, R-M4-01 |
|
|
262
|
-
| `tpl_machine_ecommerce_exceptions` | P-M-SEQ, P-M-COMPETING | P-M-LINEAR, P-M-COMPETING | R-M1-01, R-M1-03, R-M1-08, R-M2-01, R-M2-05, R-M3-02, R-M3-04, R-M3-05, R-M4-01, R-M5-03 |
|
|
263
|
-
| `tpl_machine_rental` | P-M-SEQ | P-M-LINEAR | R-M1-01, R-M1-08, R-M2-01, R-M2-04, R-M3-02, R-M4-01, R-M5-02 |
|
|
264
|
-
| `tpl_machine_dual_signature` | P-M-AND | P-M-LINEAR | R-M1-08, R-M2-01, R-M3-02, R-M3-04 |
|
|
265
|
-
| `tpl_machine_weighted_voting` | P-M-VOTE | P-M-LINEAR | R-M1-08, R-M2-05, R-M3-04, R-M5-04, R-X1-14 |
|
|
266
|
-
| `tpl_machine_cross_machine` | P-M-CROSS-MACHINE | P-M-LINEAR | R-M1-01, R-M1-08, R-M2-01, R-M2-04, R-M3-04, R-M5-04, R-M5-05, R-M5-06 |
|
|
267
|
-
| `tpl_machine_privacy_delivery` | P-M-SEQ | P-M-LINEAR | R-M1-01, R-M1-08, R-M2-01, R-M2-04, R-M3-02, R-M5-03 |
|
|
268
|
-
| `tpl_machine_reward` | P-M-SEQ | P-M-LINEAR | R-M1-08, R-M2-05, R-M3-04, R-X1-14 |
|
|
269
|
-
| `tpl_machine_arbitration` | P-M-VOTE, P-M-SEQ | P-M-LINEAR | R-M1-08, R-M2-05, R-M3-04, R-M5-04, R-X1-14 |
|
|
270
|
-
| `tpl_machine_subscription` | P-M-SEQ, P-M-COMPETING | P-M-LINEAR, P-M-COMPETING | R-M1-01, R-M1-08, R-M2-01, R-M2-05, R-M3-02, R-M3-04, R-M4-01, R-M5-04 |
|
|
271
|
-
|
|
272
|
-
---
|
|
273
|
-
|
|
274
|
-
## Cross-Reference: Template ↔ Industry
|
|
275
|
-
|
|
276
|
-
| Industry | Recommended Templates |
|
|
277
|
-
|---|---|
|
|
278
|
-
| ecommerce | `tpl_machine_ecommerce_standard`, `tpl_machine_ecommerce_exceptions`, `tpl_machine_dual_signature`, `tpl_machine_privacy_delivery`, `tpl_machine_reward`, `tpl_machine_arbitration` |
|
|
279
|
-
| rental | `tpl_machine_rental`, `tpl_machine_ecommerce_exceptions` |
|
|
280
|
-
| logistics | `tpl_machine_cross_machine`, `tpl_machine_privacy_delivery`, `tpl_machine_arbitration` |
|
|
281
|
-
| manufacturing | `tpl_machine_cross_machine` |
|
|
282
|
-
| governance | `tpl_machine_weighted_voting`, `tpl_machine_arbitration` |
|
|
283
|
-
| arbitration | `tpl_machine_arbitration`, `tpl_machine_weighted_voting` |
|
|
284
|
-
| subscription | `tpl_machine_subscription`, `tpl_machine_reward` |
|
|
285
|
-
| service | `tpl_machine_dual_signature`, `tpl_machine_arbitration`, `tpl_machine_subscription` |
|
|
286
|
-
| dao | `tpl_machine_weighted_voting` |
|
|
287
|
-
| escrow | `tpl_machine_dual_signature` |
|
|
288
|
-
|
|
289
|
-
---
|
|
290
|
-
|
|
291
|
-
## Template Selection Decision Tree
|
|
292
|
-
|
|
293
|
-
```
|
|
294
|
-
START
|
|
295
|
-
↓
|
|
296
|
-
Q1: Does the workflow involve multiple independent services/parties?
|
|
297
|
-
├─ YES → Q2
|
|
298
|
-
└─ NO → Q3
|
|
299
|
-
|
|
300
|
-
Q2: Are these services already published as separate Machines?
|
|
301
|
-
├─ YES → tpl_machine_cross_machine
|
|
302
|
-
└─ NO → Decompose into multiple Machines first
|
|
303
|
-
|
|
304
|
-
Q3: Does any node require multiple parties' confirmation to advance?
|
|
305
|
-
├─ YES → Q4
|
|
306
|
-
└─ NO → Q5
|
|
307
|
-
|
|
308
|
-
Q4: Do all parties have EQUAL weight?
|
|
309
|
-
├─ YES → tpl_machine_dual_signature (AND semantics, threshold=2)
|
|
310
|
-
└─ NO → tpl_machine_weighted_voting (VOTE semantics, threshold=100)
|
|
311
|
-
|
|
312
|
-
Q5: Does the workflow need exception branches (lost, return, dispute)?
|
|
313
|
-
├─ YES → tpl_machine_ecommerce_exceptions
|
|
314
|
-
└─ NO → Q6
|
|
315
|
-
|
|
316
|
-
Q6: Does it involve recurring payments or time-based state changes?
|
|
317
|
-
├─ YES → tpl_machine_subscription
|
|
318
|
-
└─ NO → Q7
|
|
319
|
-
|
|
320
|
-
Q7: Does it need privacy-preserving data delivery (Messenger)?
|
|
321
|
-
├─ YES → tpl_machine_privacy_delivery
|
|
322
|
-
└─ NO → Q8
|
|
323
|
-
|
|
324
|
-
Q8: Does it involve deposit/refund separation?
|
|
325
|
-
├─ YES → tpl_machine_rental
|
|
326
|
-
└─ NO → Q9
|
|
327
|
-
|
|
328
|
-
Q9: Does it need reward/incentive distribution at a specific node?
|
|
329
|
-
├─ YES → tpl_machine_reward
|
|
330
|
-
└─ NO → tpl_machine_ecommerce_standard (default baseline)
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
---
|
|
334
|
-
|
|
335
|
-
## Template Usage Flow (aligned with wowok-onboard R3-R7)
|
|
336
|
-
|
|
337
|
-
```
|
|
338
|
-
M1 (within R3): Initial intent collection
|
|
339
|
-
- User describes business flow
|
|
340
|
-
- inferSceneFromFlow() suggests scene
|
|
341
|
-
- suggestTemplateForIntent() suggests template
|
|
342
|
-
- AI presents template + parameters to user
|
|
343
|
-
↓
|
|
344
|
-
M2 (within R3): Parameter collection
|
|
345
|
-
- AI collects values for each template parameter
|
|
346
|
-
- Validates types + constraints
|
|
347
|
-
- fillTemplate() generates filled nodes/pairs JSON
|
|
348
|
-
↓
|
|
349
|
-
M3-M5 (within R4): Node + Guard design refinement
|
|
350
|
-
- Review filled JSON with user
|
|
351
|
-
- Adjust node names, forwards, thresholds per user input
|
|
352
|
-
- Identify required Guards (from required_guards list)
|
|
353
|
-
- Design each Guard using guard-templates.ts
|
|
354
|
-
↓
|
|
355
|
-
M6 (within R5): Topology + permission model verification
|
|
356
|
-
- Verify branching (competing vs parallel)
|
|
357
|
-
- Verify permission indices are consistent
|
|
358
|
-
- Assess risks using machine-risk.ts
|
|
359
|
-
↓
|
|
360
|
-
M7 (within R6): Guard integration verification
|
|
361
|
-
- All required_guards created on-chain
|
|
362
|
-
- Each Guard bound to correct Forward
|
|
363
|
-
- gen_passport verifies each Guard
|
|
364
|
-
↓
|
|
365
|
-
M8 (within R7): Pre-publish confirmation
|
|
366
|
-
- Run full publish_checklist
|
|
367
|
-
- Generate confirmation text (machine-confirm.ts)
|
|
368
|
-
- User MUST approve before publish
|
|
369
|
-
- Testnet test run MANDATORY before mainnet publish
|
|
370
|
-
```
|
|
371
|
-
|
|
372
|
-
---
|
|
373
|
-
|
|
374
|
-
## Template Operations
|
|
375
|
-
|
|
376
|
-
### Query Functions
|
|
377
|
-
|
|
378
|
-
| Function | Signature | Description |
|
|
379
|
-
|---|---|---|
|
|
380
|
-
| `getAllTemplates` | `(): MachineTemplate[]` | Get all templates |
|
|
381
|
-
| `getTemplateById` | `(id: string): MachineTemplate \| undefined` | Get template by ID |
|
|
382
|
-
| `getTemplatesByScene` | `(scene_id: string): MachineTemplate[]` | Get templates by scene ID |
|
|
383
|
-
| `getTemplatesByIndustry` | `(industry: string): MachineTemplate[]` | Get templates by industry tag |
|
|
384
|
-
| `suggestTemplateForIntent` | `(intent: string): MachineTemplate \| undefined` | Suggest template based on user intent |
|
|
385
|
-
|
|
386
|
-
### Template Filling
|
|
387
|
-
|
|
388
|
-
```typescript
|
|
389
|
-
export interface TemplateFillResult {
|
|
390
|
-
success: boolean;
|
|
391
|
-
filled_nodes?: object; // nodes with ${param} replaced
|
|
392
|
-
filled_pairs?: object; // pairs with ${param} replaced
|
|
393
|
-
missing_params?: string[]; // required params not provided
|
|
394
|
-
validation_errors?: string[];
|
|
395
|
-
}
|
|
396
|
-
```
|
|
397
|
-
|
|
398
|
-
The `fillTemplate(template, params)` function:
|
|
399
|
-
1. Validates all required params are provided
|
|
400
|
-
2. Validates param types
|
|
401
|
-
3. Substitutes `${param}` placeholders in `example_nodes` / `example_pairs` via `deepSubstitute`
|
|
402
|
-
|
|
403
|
-
### Fork-Modify
|
|
404
|
-
|
|
405
|
-
```typescript
|
|
406
|
-
export interface ForkResult {
|
|
407
|
-
template_id: string;
|
|
408
|
-
forkable_fields: string[];
|
|
409
|
-
current_values: Record<string, unknown>;
|
|
410
|
-
instructions: string[];
|
|
411
|
-
}
|
|
412
|
-
```
|
|
413
|
-
|
|
414
|
-
`forkTemplate(template)` returns editable fields for user customization. Instructions:
|
|
415
|
-
- Modify fields below to customize the workflow
|
|
416
|
-
- Keep template structure intact unless explicitly noted
|
|
417
|
-
- Run risk assessment after modification (machine-risk.ts)
|
|
418
|
-
- User MUST confirm final JSON before publish (ConfirmGate)
|
|
419
|
-
|
|
420
|
-
---
|
|
421
|
-
|
|
422
|
-
## Extension Mechanism
|
|
423
|
-
|
|
424
|
-
### Adding a New Template
|
|
425
|
-
|
|
426
|
-
1. Define scene in `machine-ledger.ts` first (if new scene)
|
|
427
|
-
2. Define template with full parameterization
|
|
428
|
-
3. Cross-reference to `guard-templates.ts` (`required_guards`)
|
|
429
|
-
4. Cross-reference to `machine-translation.ts` (`recommended_patterns`)
|
|
430
|
-
5. Cross-reference to `machine-risk.ts` (`relevant_risks`)
|
|
431
|
-
6. Add `publish_checklist` items
|
|
432
|
-
7. Test on testnet before promoting to production
|
|
433
|
-
|
|
434
|
-
### Version Control
|
|
435
|
-
|
|
436
|
-
```typescript
|
|
437
|
-
export interface MachineTemplateVersion {
|
|
438
|
-
template_id: string;
|
|
439
|
-
version: string; // semver
|
|
440
|
-
breaking_changes: string[];
|
|
441
|
-
migration_notes: string[];
|
|
442
|
-
deprecated: boolean;
|
|
443
|
-
successor_id?: string;
|
|
444
|
-
}
|
|
445
|
-
```
|
|
446
|
-
|
|
447
|
-
Templates are immutable once published (like Guards/Machines). New requirements → new template ID.
|
|
448
|
-
|
|
449
|
-
---
|
|
450
|
-
|
|
451
|
-
## Alignment with Guard Template Library
|
|
452
|
-
|
|
453
|
-
| Dimension | Guard Templates | Machine Templates |
|
|
454
|
-
|---|---|---|
|
|
455
|
-
| Count | 10 | 10 (one per Machine scene) |
|
|
456
|
-
| Param types | address/string/number/boolean/vec_address | + node_name_list, permission_ref, guard_ref, machine_ref, service_ref, arbitration_ref, reward_ref |
|
|
457
|
-
| Cross-refs | → Pattern (P02-P17), Risk (R-C*) | → Pattern (P-M-*), Risk (R-M*), → Guard templates (via required_guards) |
|
|
458
|
-
| Forkable | N/A (Guards are CREATE-only) | `forkable_fields` per template (P-M5 mode) |
|
|
459
|
-
| Post-publish modification | NO (immutable) | NO (immutable) |
|
|
460
|
-
| Testing | `gen_passport` | Testnet Progress run |
|
|
461
|
-
| Entry point | wowok-guard skill | wowok-machine + wowok-onboard skills |
|
|
462
|
-
|
|
463
|
-
---
|
|
464
|
-
|
|
465
|
-
## Module Dependencies
|
|
466
|
-
|
|
467
|
-
```
|
|
468
|
-
machine-ledger.ts (scene definitions)
|
|
469
|
-
↓
|
|
470
|
-
machine-templates.ts (this module)
|
|
471
|
-
↓
|
|
472
|
-
machine-translation.ts (Patterns + constraints)
|
|
473
|
-
↓
|
|
474
|
-
machine-risk.ts (risk assessment)
|
|
475
|
-
↓
|
|
476
|
-
machine-confirm.ts (publish confirmation gate)
|
|
477
|
-
↓
|
|
478
|
-
machine-puzzle.ts (information puzzle integration)
|
|
479
|
-
↓
|
|
480
|
-
machine-context.ts (context injection)
|
|
481
|
-
↓
|
|
482
|
-
machine-topology.ts (DAG topology analysis)
|
|
483
|
-
```
|
|
484
|
-
|
|
485
|
-
**Key dependencies**:
|
|
486
|
-
- `machine-ledger.ts`: Provides `scene_id` and scene definitions
|
|
487
|
-
- `guard-templates.ts`: Provides Guard templates referenced in `required_guards`
|
|
488
|
-
- `machine-translation.ts`: Provides Patterns referenced in `recommended_patterns`
|
|
489
|
-
- `machine-risk.ts`: Provides risk rules referenced in `relevant_risks`
|
|
490
|
-
- `machine-confirm.ts`: Executes `publish_checklist` mandatory checks
|
|
491
|
-
|
|
492
|
-
---
|
|
493
|
-
|
|
494
|
-
## Implementation Status
|
|
495
|
-
|
|
496
|
-
### Implemented in `guard-templates.ts`
|
|
497
|
-
- ✅ Complete Guard 10 template definitions
|
|
498
|
-
- ✅ Guard template parameterization + type constraints
|
|
499
|
-
- ✅ Guard template cross-references to Pattern/Risk
|
|
500
|
-
- ✅ Guard template `verifier_constraint_level` grading
|
|
501
|
-
|
|
502
|
-
### Implemented in `machine-templates.ts` (Phase M-7 complete)
|
|
503
|
-
- ✅ `MachineTemplate` / `MachineTemplateParam` / `RequiredGuardRef` / `RequiredPermission` / `RequiredAllocator` interfaces
|
|
504
|
-
- ✅ 10 Machine templates complete data (ecommerce, rental, reward, crowdfunding, etc.)
|
|
505
|
-
- ✅ `getAllTemplates` / `getTemplateById` / `getTemplatesByScene` / `getTemplatesByIndustry` / `getTemplatesByPattern`
|
|
506
|
-
- ✅ `suggestTemplateForIntent` (depends on `inferSceneFromFlow` from machine-ledger.ts)
|
|
507
|
-
- ✅ `getTemplateParameters` / `getRequiredParameters` / `getOptionalParameters`
|
|
508
|
-
- ✅ `fillTemplate` (returns `TemplateFillResult`, uses `deepSubstitute` for recursive placeholder replacement)
|
|
509
|
-
- ✅ `forkTemplate` (Fork-Modify support, returns `ForkResult`, corresponds to participation mode P-M5)
|
|
510
|
-
- ✅ Template version metadata (`MACHINE_TEMPLATES_VERSION` / `MACHINE_TEMPLATES_COUNT`)
|
|
511
|
-
- ✅ Decision tree (`DECISION_TREE` + `walkDecisionTree`)
|
|
512
|
-
- ✅ Template consistency self-check (`verifyTemplateSceneReferences` / `getReferencedGuardTemplateIds` / `getReferencedRiskIds`)
|
|
513
|
-
- ✅ Template listing (`listTemplates` for UI display)
|
|
514
|
-
|
|
515
|
-
### Implemented in `machine-confirm.ts`
|
|
516
|
-
- ✅ Decision tree (`DECISION_TREE` + `walkDecisionTree`)
|
|
517
|
-
- ✅ Template usage flow integrated with wowok-onboard R3-R7 (`progressiveCheck`)
|
|
518
|
-
- ✅ Template `publish_checklist` enforcement (`PUBLISH_CHECKLIST` + `runStaticChecklist` + `confirmPublish` 4-layer ConfirmGate)
|
|
519
|
-
|
|
520
|
-
---
|
|
521
|
-
|
|
522
|
-
*Reference document for the Machine Template Library — 10 parameterized templates for the Machine semantic layer. Each template includes complete parameters, node structure, Guard references, permission configuration, Allocator integration, and publish checklist.*
|