@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.
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 +28 -9
  27. package/wowok-provider/SKILL.md +91 -49
  28. package/wowok-safety/SKILL.md +8 -80
  29. package/wowok-scenario/SKILL.md +63 -98
  30. package/wowok-tools/SKILL.md +111 -122
  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 -428
  43. package/wowok-machine/APPENDIX.md +0 -407
  44. package/wowok-messenger/APPENDIX.md +0 -550
  45. package/wowok-onboard/APPENDIX.md +0 -500
  46. package/wowok-order/APPENDIX.md +0 -777
  47. package/wowok-output/APPENDIX.md +0 -575
  48. package/wowok-planner/APPENDIX.md +0 -724
  49. package/wowok-provider/APPENDIX.md +0 -453
  50. package/wowok-safety/APPENDIX.md +0 -561
  51. package/wowok-scenario/APPENDIX.md +0 -97
  52. package/wowok-scenario/MODE-DETAILS.md +0 -275
  53. package/wowok-tools/APPENDIX.md +0 -388
@@ -1,724 +0,0 @@
1
- # Appendix — wowok-planner
2
-
3
- > This file is loaded on-demand (Progressive Disclosure).
4
- > Main skill: [SKILL.md](./SKILL.md)
5
-
6
- ---
7
-
8
- ## Dialogue Scripts (R1-R10)
9
-
10
- Each round follows: state the goal, ask the minimum questions needed, gather inputs (LLM translation only when free text is ambiguous), update the ODG in memory, persist checkpoint, advance.
11
-
12
- ## Project-Based Deployment Integration
13
-
14
- The planner flow integrates with the MCP project-based deployment pipeline (5 stages). Each stage maps to specific R rounds:
15
-
16
- - **Stage 1 (Project Naming)** → R1 — establish the `project` and `version` identifiers used by all subsequent `project_operation` calls.
17
- - **Stage 2 (Business Puzzle)** → R1 — call `project_operation` → `action: "analyze_intent"` to replace internal Scenario Registry matching; the MCP side performs Scenario Registry matching + ODG skeleton generation + puzzle initialization in one call.
18
- - **Stage 3 (Risk Calibration)** → R9 — call `project_operation` → `action: "aggregate_risks"` to perform L1/L2/L3 risk assessment on the assembled puzzles.
19
- - **Stage 4 (Deployment Doc)** → after R9 — call `project_operation` → `action: "generate_deployment_doc"` to produce the markdown deployment doc with D-01..D-18 scanner checks.
20
- - **Stage 5 (Substep Trace)** → R10 — call `project_operation` → `action: "trace_substeps"` to verify substep continuity before handoff to the Harness.
21
-
22
- All `project_operation` calls use the unified `project` + `version` keys established in R1. The `next_action` field returned by each call drives the stage transition.
23
-
24
- ### R1: Intent Capture
25
-
26
- **AI Goal**: Capture the user's natural-language intent and classify it against the Scenario Registry.
27
-
28
- **Key Questions**:
29
- - What do you want to build? (one or two sentences)
30
- - Who is your customer, and what do they pay for?
31
- - Is there a deposit, milestone, or instant exchange of value?
32
-
33
- **Tool Calls**:
34
- 1. `query_toolkit` → `local_names` — check for any prior planning checkpoint to offer a resume path.
35
- 2. `project_operation` → `action: "analyze_intent"` with `project`, `version`, `user_intent`, `industry` (if known) — MCP 内部完成 Scenario Registry 匹配 + ODG 生成 + puzzle 初始化. Returns `puzzles`, `next_step`, `next_action`. If `next_action: "aggregate_risks"` indicates puzzles are complete, you can proceed directly to Stage 3.
36
- 3. If no candidate matches → select `general` scenario (no failure — the fallback is intentional).
37
-
38
- **Success Criteria**: A `scenario` field is set on the ODG (one of `freelance`, `rental`, `digital_goods`, `travel_package`, `general`). The scenario's ODG template is loaded as the working skeleton.
39
-
40
- **Fallback**: If intent is too vague to match even `general` confidently → ask one clarifying question and retry once. After two retries, proceed with `general` and flag the uncertainty in the ODG `notes`.
41
-
42
- **Checkpoint**: Persist `{ round: R1, task_id, scenario, intent_text, traits }`.
43
-
44
- ---
45
-
46
- ### R2: Account Status
47
-
48
- **AI Goal**: Determine the working account and inventory existing objects so later rounds can decide reuse vs create.
49
-
50
- **Key Questions**:
51
- - Which account is the working account? (name or address)
52
- - (If multiple) Which one holds your existing WoWok objects?
53
-
54
- **Tool Calls**:
55
- 1. `query_toolkit` → `local_names` — list accounts and local marks.
56
- 2. `query_toolkit` → `account_balance` — verify balance > 0; if zero, surface a funding reminder (do not auto-faucet — the Harness owns execution).
57
- 3. `query_toolkit` → `onchain_objects` (filter types: Permission, Service, Machine, Guard, Allocation) — build an inventory map keyed by object type and friendly name.
58
-
59
- **Success Criteria**: Working account recorded. Object inventory persisted so R3-R7 can resolve reuse candidates by name without re-querying.
60
-
61
- **Fallback**: Account has zero balance → record `funding_required: true` in the ODG as a phase-0 prerequisite; do not block planning. Inventory query returns empty → all objects will be CREATE in subsequent rounds.
62
-
63
- **Checkpoint**: Persist `{ round: R2, account, balance, inventory: { permission: [...], service: [...], machine: [...], guard: [...], allocation: [...] } }`.
64
-
65
- ---
66
-
67
- ### R3: Service Definition
68
-
69
- **AI Goal**: Define the Service object's identity fields. Reuse is NOT an option for Service when the intent is a new service — a new Service draft is always planned; existing Services are only candidates if the user explicitly wants to extend one.
70
-
71
- **Key Questions**:
72
- - Service name? (scenario default applied, user confirms or overrides)
73
- - type_parameter (payment token type)? Default `0x2::wow::WOW`.
74
- - Deliverable description and base price?
75
-
76
- **Tool Calls**:
77
- 1. (Internal) Load scenario template's Service defaults.
78
- 2. If user references an existing Service by name → `query_toolkit` → `onchain_objects` to confirm it exists and is unpublished (published Services cannot be extended); record as `reuse_candidate`.
79
- 3. No on-chain writes — the planner only records the intended Service shape in the ODG. Execution is deferred to the Harness.
80
-
81
- **Success Criteria**: ODG `objects[]` contains a Service entry with `status: planned`, `dependencies: []` (Service is the root), and `user_decisions: { name, type_parameter, description, price }`.
82
-
83
- **Fallback**: type_parameter unknown → default to `0x2::wow::WOW`, flag for confirmation. Description too short → prompt for one more sentence (LLM translates to a typed string).
84
-
85
- **Checkpoint**: Persist `{ round: R3, service: { name, type_parameter, description, price, reuse: false } }`.
86
-
87
- ---
88
-
89
- ### R4: Permission Model
90
-
91
- **AI Goal**: Decide reuse vs create for the Permission object and record the role-to-index map. This is the highest-leverage reuse decision — wowok-safety §1.1 strongly recommends a single shared Permission.
92
-
93
- **Key Questions**:
94
- - Reuse an existing Permission, or create a new one? (default: reuse if any candidate exists)
95
- - If creating: confirm the scenario's default indexes (e.g., freelance: provider=1000, arbiter=1500, customer uses `namedOperator: ""`).
96
-
97
- **Tool Calls**:
98
- 1. `query_toolkit` → `onchain_objects` (filter type=Permission) — already in R2 inventory; present candidates by friendly name.
99
- 2. (Internal) Apply Decision Tree §D1 Reuse-vs-Create.
100
- 3. (Internal) Validate chosen indexes: user-defined must be ≥ 1000; < 1000 is reserved (wowok-tools §Permission Index Model). Reject and re-prompt if invalid.
101
-
102
- **Success Criteria**: ODG contains a Permission entry with `status: planned` (create) or `status: reuse` (with the existing object ID), and a `role_index_map` consumed by R5 Machine Forwards.
103
-
104
- **Fallback**: User wants a role split beyond scenario defaults → flag as Tier 3, hand the Permission design detail to wowok-safety for index rules, but keep the planner's record of the chosen map.
105
-
106
- **Checkpoint**: Persist `{ round: R4, permission: { reuse: bool, id?, indexes: { provider, arbiter, ... } } }`.
107
-
108
- ---
109
-
110
- ### R5: Machine Design
111
-
112
- **AI Goal**: Define the state graph: entry node, intermediate states, terminal nodes, forward transitions, and operator bindings per forward.
113
-
114
- **Key Questions**:
115
- - Confirm the scenario's default node graph, or list your custom states?
116
- - Per forward: who advances it? (permissionIndex from R4, or `namedOperator: ""` for the order owner)
117
- - Any timeout / auto-advance forwards? (recommended for acceptance and return nodes)
118
-
119
- **Tool Calls**:
120
- 1. (Internal) Load scenario template's Machine graph.
121
- 2. `machineNode2file` — if the user is editing an existing Machine draft, export it for visual review. (Read-only; the planner does not publish.)
122
- 3. (Internal) Validate: every forward's `permissionIndex` exists in R4's map OR uses `namedOperator`; every non-entry node has at least one inbound forward; at least one terminal node exists.
123
-
124
- **Success Criteria**: ODG contains a Machine entry with `status: planned`, `dependencies: [Permission]`, and a `node_graph` payload (nodes, forwards, guard bindings referenced by name, not yet created).
125
-
126
- **Fallback**: User wants a workflow beyond the scenario template → switch to `general` scenario for the Machine only, delegate detail design to wowok-machine, but retain the planner's record of the final graph. Cycle detected in the graph → trigger §F1 Dependency Cycle playbook.
127
-
128
- **Checkpoint**: Persist `{ round: R5, machine: { nodes: [...], forwards: [...], terminal_nodes: [...] } }`.
129
-
130
- ---
131
-
132
- ### R6: Guard Strategy
133
-
134
- **AI Goal**: Decide which operations need Guards, define each Guard's host (Service.buy_guard, a Machine Forward, or an Allocator trigger), and record the validation logic and submission requirements.
135
-
136
- **Key Questions**:
137
- - Which operations move funds or mark irreversible state? (Those need Guards.)
138
- - For each: what must the submitter prove? (KYC, WIP hash, signature, balance threshold)
139
- - Apply scenario's default Guard set, or customize?
140
-
141
- **Tool Calls**:
142
- 1. (Internal) Apply Decision Tree §D2 Guard Necessity.
143
- 2. (Internal) Load scenario template's Guard table.
144
- 3. `guard2file` — if the user is editing existing Guard drafts, export for review. (Read-only.)
145
- 4. (Internal) Validate: every Guard referenced by a Machine Forward (R5) or an Allocator trigger (R7) has a corresponding entry; `convert_witness` target types are consistent with the host object type.
146
-
147
- **Success Criteria**: ODG contains one Guard entry per planned Guard, each with `host`, `validation_logic`, `submission_fields`, and `bound_to` (Forward name or Allocator). Guards are listed before Allocators because R7 references them.
148
-
149
- **Fallback**: A Guard's logic is too complex for the scenario template → delegate to wowok-guard for the detailed table, retain the planner's record of host and trigger. `gen_passport` testing is deferred to the Harness execution phase (the planner does not write).
150
-
151
- **Checkpoint**: Persist `{ round: R6, guards: [{ name, host, bound_to, submission_fields }] }`.
152
-
153
- ---
154
-
155
- ### R7: Allocation Plan
156
-
157
- **AI Goal**: Define the fund distribution rules — one Allocator per terminal path, each Guard-gated, with a sharing array whose basis-point sum equals 10000.
158
-
159
- **Key Questions**:
160
- - Per terminal path (completed, refunded, damage_confirmed, etc.): who receives funds and in what ratio?
161
- - Confirm sharing sum = 10000 (basis points) per Allocator.
162
- - Recipient type per share: `Entity` (known address), `GuardIdentifier` (dynamic Order/customer), or `Signer`.
163
-
164
- **Tool Calls**:
165
- 1. (Internal) Apply Decision Tree §D3 Allocation Strategy.
166
- 2. (Internal) Load scenario template's Allocator strategy.
167
- 3. (Internal) Validate: every Allocator's trigger Guard exists in R6; refund path is covered (wowok-safety requires a refund Allocator for any dispute-capable service); sharing sum = 10000 per Allocator.
168
-
169
- **Success Criteria**: ODG contains one Allocation entry per terminal path, each with `trigger_guard`, `sharing[]`, and `dependencies: [Guard, Service]`. The `order_allocators` field on the Service entry is marked for binding at execution time.
170
-
171
- **Fallback**: Sharing sum ≠ 10000 → auto-normalize to 10000 with user confirmation (§F6). Missing refund path → block, prompt user to add one (hard requirement, not a warning). User wants multi-tier allocation (travel scenario) → flag as Tier 2/3, ensure each tier's Guard chain is recorded.
172
-
173
- **Checkpoint**: Persist `{ round: R7, allocations: [{ trigger_guard, sharing, refund_path_covered }] }`.
174
-
175
- ---
176
-
177
- ### R8: ODG Review
178
-
179
- **AI Goal**: Present the complete Object Dependency Graph and phased execution plan for explicit user confirmation before any execution begins.
180
-
181
- **Key Questions**:
182
- - Review the ODG summary (object count, phases, irreversible actions). Approve?
183
- - Any object you want to reconfigure before we hand off?
184
-
185
- **Tool Calls**:
186
- 1. (Internal) Assemble the full ODG from R1-R7 records.
187
- 2. (Internal) Run §D4 Publishing Timing check — Service publish must come AFTER all Guards tested and Machine published.
188
- 3. (Internal) Detect dependency cycles via §F1; abort review if any found.
189
- 4. Present the ODG in human-readable form: object table, phase list, reversibility flags.
190
-
191
- **Success Criteria**: User explicitly approves the ODG. `status: confirmed` is set on the ODG root. No on-chain writes have occurred.
192
-
193
- **Fallback**: User requests changes → return to the relevant round (R3-R7), apply the change, re-run R8 review. Do not partially confirm — the ODG is confirmed as a whole.
194
-
195
- **Checkpoint**: Persist `{ round: R8, odg_confirmed: true, odg_snapshot: <full ODG> }`.
196
-
197
- ---
198
-
199
- ### R9: Risk Assessment
200
-
201
- **AI Goal**: Flag irreversibility, fund risk, and estimated time per phase so the user gives informed consent before execution.
202
-
203
- **Key Questions**:
204
- - Confirm you accept the irreversible actions listed (Machine publish, Service publish, Guard creation)?
205
- - Confirm the fund-risk paths (deposit escrow, refund Allocator)?
206
-
207
- **Tool Calls**:
208
- 0. `project_operation` → `action: "aggregate_risks"` with `project`, `version`, `puzzles` (from R1's analyze_intent) — MCP 内部完成 L1/L2/L3 风险评估. Returns `findings`, `can_proceed`, `next_action`.
209
- - If `can_proceed: false` (CRITICAL risks) → record in ODG risk_assessment, block execution
210
- - If `can_proceed: true` → proceed to Stage 4
211
- 1. (Internal) Compute `reversible` per object (see §Reversibility Matrix).
212
- 2. (Internal) Estimate `estimated_time` per phase from scenario template defaults (Tier 1 ≈ 10 min, Tier 2 ≈ 30 min, Tier 3 ≈ 60 min, excluding human response time).
213
- 3. (Internal) List every object whose creation or publish is irreversible; require explicit per-item acknowledgment.
214
-
215
- **Success Criteria**: Every irreversible object has `user_acknowledged: true`. ODG `risk_assessment` block is populated with `irreversible_count`, `fund_risk_paths`, and `estimated_total_time`.
216
-
217
- **Fallback**: User declines to acknowledge an irreversible action → loop back to R8, offer the alternative (e.g., defer publish, create as draft only). If no safe alternative exists → block handoff and surface the conflict.
218
-
219
- **Checkpoint**: Persist `{ round: R9, risk_assessment, acknowledgments: [...] }`.
220
-
221
- **Stage 4 Gate: Deployment Document**
222
- After risks pass, call `project_operation` → `action: "generate_deployment_doc"` with `project`, `version`, `business_intent`, `objects`, `edges`, `steps`, `risk_status`, `risk_critical_count`, `risk_high_count`.
223
- - Returns markdown deployment doc + D-01..D-18 scanner checks
224
- - If `can_proceed: false` (D-errors) → fix doc errors
225
- - If `can_proceed: true` → proceed to R10
226
-
227
- ---
228
-
229
- ### R10: Execution Handoff
230
-
231
- **AI Goal**: Pass the confirmed, risk-assessed ODG to the L4 Harness with a checkpoint plan and per-phase verification hooks.
232
-
233
- **Key Questions**:
234
- - Ready to hand off to the Harness for execution?
235
- - Which execution delegate should run the phases? (default: wowok-onboard for a fresh build; wowok-provider for extensions)
236
-
237
- **Tool Calls**:
238
- 0. `project_operation` → `action: "trace_substeps"` with `project`, `version`, `network`, `substeps` (from Stage 4 deployment doc) — 验证子步骤衔接完整性.
239
- - If `can_proceed: false` → fix substep issues before handoff
240
- - If `can_proceed: true` → handoff to Harness/wowok-onboard for execution
241
- 1. (Internal) Emit the Harness handoff packet (see §Handoff Protocol).
242
- 2. `local_info_operation` → persist the final ODG under a stable `task_id` key so the Harness can read it.
243
- 3. (Internal) Register per-phase verification hooks: after each phase, the Harness must re-query on-chain state and reconcile with the ODG before advancing.
244
-
245
- **Success Criteria**: Harness acknowledges receipt of the ODG and begins phase 1. Planner's role ends; control passes to the execution loop.
246
-
247
- **Fallback**: Harness unavailable or rejects the ODG → keep the checkpoint, surface the rejection reason, loop back to the offending round. Do not re-plan from scratch — the ODG is the source of truth and only the flagged phase needs revision.
248
-
249
- **Checkpoint**: Persist `{ round: R10, handed_off: true, harness_phase: 1, delegate: <skill_name> }`. Mark planning COMPLETE.
250
-
251
- ---
252
-
253
- ## Scenario Registry
254
-
255
- Each scenario is a deterministic ODG template. The planner loads the matched scenario at R1 and fills it across R2-R7. Scenarios are presets, not constraints — every field is overridable.
256
-
257
- | Scenario | Intent Keywords | Trust Pattern | Default Tier |
258
- |----------|-----------------|---------------|--------------|
259
- | `freelance` | "freelance", "commission", "design", "develop", "consult", "deliverable" | Milestone allocation, acceptance gate | Tier 1 |
260
- | `rental` | "rent", "rental", "deposit", "lease", "borrow", "return" | Deposit escrow, return inspection | Tier 2 |
261
- | `digital_goods` | "sell digital", "download", "instant", "e-book", "template", "license key" | Instant delivery, no escrow | Tier 1 |
262
- | `travel_package` | "tour", "travel", "itinerary", "trip", "package", "multi-segment" | Multi-tier allocation per segment | Tier 3 |
263
- | `general` | (fallback) | User-defined | Tier 1+ |
264
-
265
- ### Scenario: freelance
266
-
267
- - **Intent keywords**: freelance, commission, design, develop, consult, deliverable
268
- - **ODG template**: Permission → Service → Machine (ordered→in_progress→delivered→accepted→completed, disputed→refunded) → Progress → Guards (buy, deliver, accept, withdraw, refund) → Allocation (100% provider on completed, 100% refund on refunded)
269
- - **Default permission indexes**: provider=1000, arbiter=1500, customer uses `namedOperator: ""`
270
- - **Typical Machine states**: ordered, in_progress, delivered, accepted, completed, disputed, refunded
271
- - **Guard recommendations**: buy_guard (KYC + cap), deliver_guard (WIP hash), accept_guard (signature or timeout), withdraw_guard (completed gate), refund_guard (refunded gate)
272
- - **Allocation template**: 2 Allocators — completed path 100% to provider Entity; refunded path 100% to Order via GuardIdentifier:0
273
- - **Reference**: [wowok-scenario §Freelance Mode](../wowok-scenario/SKILL.md)
274
-
275
- ### Scenario: rental
276
-
277
- - **Intent keywords**: rent, rental, deposit, lease, borrow, return, inspect
278
- - **ODG template**: Permission → Service → Machine (reserved→paid_deposit→in_use→returned→inspected→deposit_refunded→completed / damage_confirmed→deposit_deducted) → Progress → Guards (deposit, return, inspect, refund, damage) → Allocation (rent to owner, deposit refund to renter, deposit deduct to owner)
279
- - **Default permission indexes**: owner=1000, arbiter=1500, renter uses `namedOperator: ""`
280
- - **Typical Machine states**: reserved, paid_deposit, in_use, returned, inspected, deposit_refunded, completed, damage_confirmed, deposit_deducted, arbiter_rule
281
- - **Guard recommendations**: deposit_guard (balance ≥ deposit), return_guard (signature or timeout), inspect_guard (WIP hash of return condition), refund_guard (inspection passed), damage_guard (WIP hash diff pre vs post)
282
- - **Allocation template**: 3 Allocators — deposit_guard 100% rent to owner; refund_guard 100% deposit to renter; damage_guard 100% deposit to owner
283
- - **Reference**: [wowok-scenario §Rental Mode](../wowok-scenario/SKILL.md)
284
-
285
- ### Scenario: digital_goods
286
-
287
- - **Intent keywords**: sell digital, download, instant, e-book, template, license, asset
288
- - **ODG template**: Permission → Service → Machine (paid → delivered → completed, refunded) → Progress → Guards (buy_guard with cap + KYC, instant_deliver_guard with WIP hash, refund_guard) → Allocation (100% provider on completed, 100% refund on refunded)
289
- - **Default permission indexes**: provider=1000, arbiter=1500 (optional for low-value goods), customer uses `namedOperator: ""`
290
- - **Typical Machine states**: paid, delivered, completed, refunded
291
- - **Guard recommendations**: buy_guard (KYC + cap), instant_deliver_guard (auto-fires on payment, verifies WIP hash), refund_guard (failure-to-deliver within timeout)
292
- - **Allocation template**: 2 Allocators — completed 100% to provider; refunded 100% to Order. No deposit, no inspection.
293
- - **Notes**: Simplest trust pattern. Machine is short (3-4 nodes). Suitable for Tier 1 default.
294
-
295
- ### Scenario: travel_package
296
-
297
- - **Intent keywords**: tour, travel, itinerary, trip, package, multi-segment, agency
298
- - **ODG template**: Permission → Service → Machine (booked→paid_deposit→paid_final→segment_D1→segment_D2→...→return→completed / interrupted→refunded) → Progress → Guards (segment_guard per segment with WIP, refund_guard for interruption) → Allocation (multi-tier: deposit to agency, final to agency, then agency-side Allocation waterfall to hotel/guide/driver)
299
- - **Default permission indexes**: agency=1000, arbiter=1500, customer uses `namedOperator: ""`
300
- - **Typical Machine states**: booked, paid_deposit, paid_final, segment_D1..Dn, return, completed, interrupted, refunded
301
- - **Guard recommendations**: segment_guard (per-segment arrival WIP), refund_guard (agency approval or arbiter for interruption), no auto-advance (each segment requires explicit proof)
302
- - **Allocation template**: multi-tier — primary Allocators pay agency; secondary Allocators (chained) split agency receipts to hotel/guide/driver per segment. Tier 3.
303
- - **Reference**: [wowok-scenario §Travel Mode](../wowok-scenario/SKILL.md)
304
-
305
- ### Scenario: general (Fallback)
306
-
307
- - **Intent keywords**: (none — selected when no other scenario matches)
308
- - **ODG template**: empty skeleton — Permission → Service → Machine (entry→terminal minimum) → Progress → Guards (buy_guard + refund_guard minimum) → Allocation (at least one completed path + one refund path)
309
- - **Default permission indexes**: provider=1000, arbiter=1500, customer uses `namedOperator: ""` (same as freelance; user can override)
310
- - **Typical Machine states**: user-defined; planner enforces minimum 2 nodes (entry + terminal)
311
- - **Guard recommendations**: buy_guard and refund_guard are mandatory minimums; user adds others as needed
312
- - **Allocation template**: one completed-path Allocator + one refund-path Allocator; user defines sharing
313
- - **Notes**: This is the escape hatch, not an error. The planner loads `general` confidently and continues R2-R7 with empty defaults filled by user input.
314
-
315
- ---
316
-
317
- ## ODG Data Structure
318
-
319
- The ODG is the single output artifact of the planner. It is persisted via `local_info_operation` and consumed by the Harness.
320
-
321
- ```json
322
- {
323
- "task_id": "task_20260714_001",
324
- "scenario": "freelance",
325
- "version": 1,
326
- "status": "confirmed",
327
- "account": "merchant_v1",
328
- "objects": [
329
- {
330
- "id": "obj_permission",
331
- "type": "permission",
332
- "status": "planned",
333
- "reversible": true,
334
- "dependencies": [],
335
- "user_decisions": {
336
- "reuse": false,
337
- "indexes": { "provider": 1000, "arbiter": 1500 }
338
- },
339
- "estimated_time": "1 min"
340
- },
341
- {
342
- "id": "obj_service",
343
- "type": "service",
344
- "status": "planned",
345
- "reversible": true,
346
- "dependencies": ["obj_permission"],
347
- "user_decisions": {
348
- "name": "Logo Design Service",
349
- "type_parameter": "0x2::wow::WOW",
350
- "description": "Custom logo, 3 revisions, 5-day delivery",
351
- "price": 500,
352
- "publish": "deferred"
353
- },
354
- "estimated_time": "2 min"
355
- },
356
- {
357
- "id": "obj_machine",
358
- "type": "machine",
359
- "status": "planned",
360
- "reversible": false,
361
- "dependencies": ["obj_permission"],
362
- "user_decisions": {
363
- "nodes": ["ordered", "in_progress", "delivered", "accepted", "completed", "disputed", "refunded"],
364
- "forwards": [
365
- { "name": "place_order", "namedOperator": "" },
366
- { "name": "accept_order", "permissionIndex": 1000 },
367
- { "name": "submit_deliverable", "permissionIndex": 1000, "guard": "deliver_guard" },
368
- { "name": "confirm_acceptance", "namedOperator": "", "guard": "accept_guard" },
369
- { "name": "finalize", "permissionIndex": 1000 },
370
- { "name": "open_dispute", "namedOperator": "" },
371
- { "name": "arbiter_rule_refund", "permissionIndex": 1500 }
372
- ],
373
- "publish": "deferred"
374
- },
375
- "estimated_time": "3 min"
376
- },
377
- {
378
- "id": "obj_progress",
379
- "type": "progress",
380
- "status": "planned",
381
- "reversible": true,
382
- "dependencies": ["obj_machine", "obj_service"],
383
- "user_decisions": { "mirror_machine": true },
384
- "estimated_time": "1 min"
385
- },
386
- {
387
- "id": "obj_guard_withdraw",
388
- "type": "guard",
389
- "status": "planned",
390
- "reversible": false,
391
- "dependencies": [],
392
- "user_decisions": {
393
- "host": "allocator_trigger",
394
- "bound_to": "obj_allocation_withdraw",
395
- "validation_logic": "Progress.current == completed",
396
- "submission_fields": ["progress_id"]
397
- },
398
- "estimated_time": "2 min"
399
- },
400
- {
401
- "id": "obj_allocation_withdraw",
402
- "type": "allocation",
403
- "status": "planned",
404
- "reversible": false,
405
- "dependencies": ["obj_guard_withdraw", "obj_service"],
406
- "user_decisions": {
407
- "trigger_guard": "obj_guard_withdraw",
408
- "sharing": [
409
- { "who": { "Entity": { "name_or_address": "obj_service" } }, "sharing": 10000, "mode": "Rate" }
410
- ]
411
- },
412
- "estimated_time": "2 min"
413
- }
414
- ],
415
- "phases": [
416
- {
417
- "name": "phase_1_draft_objects",
418
- "objects": ["obj_permission", "obj_service", "obj_machine", "obj_progress", "obj_guard_withdraw", "obj_allocation_withdraw"],
419
- "verification": "query_toolkit.onchain_objects confirms all objects exist with bPublished=false"
420
- },
421
- {
422
- "name": "phase_2_guard_test",
423
- "objects": ["obj_guard_withdraw"],
424
- "verification": "gen_passport returns PASS for each Guard with mock submission"
425
- },
426
- {
427
- "name": "phase_3_test_order",
428
- "objects": ["obj_service"],
429
- "verification": "Test order traverses full Machine, Allocation distributes correctly"
430
- },
431
- {
432
- "name": "phase_4_publish",
433
- "objects": ["obj_machine", "obj_service"],
434
- "verification": "bPublished=true on Machine then Service; immutability locks confirmed"
435
- }
436
- ],
437
- "risk_assessment": {
438
- "irreversible_count": 4,
439
- "fund_risk_paths": ["refund path covered: obj_allocation_refund"],
440
- "estimated_total_time": "12 min (excluding human response)"
441
- },
442
- "handoff": {
443
- "delegate": "wowok-onboard",
444
- "checkpoint_key": "odg_task_20260714_001",
445
- "verification_hooks": ["post_phase_1", "post_phase_2", "post_phase_3", "pre_phase_4_publish"]
446
- },
447
- "notes": []
448
- }
449
- ```
450
-
451
- ### Reversibility Matrix
452
-
453
- | Object | `reversible` before publish | `reversible` after publish | Recovery |
454
- |--------|------------------------------|----------------------------|----------|
455
- | Permission | true | true (modifiable) | MODIFY in place |
456
- | Service (draft) | true | false | Create new Service |
457
- | Machine (draft) | true | false (nodes locked) | Create new Machine, rebind Service |
458
- | Progress | true | true (template modifiable) | MODIFY |
459
- | Guard | false (immutable on creation) | false | Create new Guard, update all refs |
460
- | Allocation | false (immutable on creation) | false | Create new Allocation, rebind Service |
461
-
462
- ---
463
-
464
- ## Decision Trees
465
-
466
- ### D1: Reuse vs Create (per object)
467
-
468
- ```
469
- For each of Permission / Machine / Guard / Allocation / Progress:
470
- ├── R2 inventory contains a candidate AND user confirms reuse?
471
- │ ── YES ──→ REUSE: record existing object ID, status: reuse, skip creation in execution
472
- ├── User explicitly says "create new"?
473
- │ ── YES ──→ CREATE: status: planned, dependencies resolved at execution
474
- └── User unsure?
475
- ──→ query on-chain, present candidates by friendly name, let user pick
476
- ──→ Default: Permission = REUSE (wowok-safety §1.1 strong recommendation);
477
- Machine/Guard/Allocation = CREATE (scenario-specific)
478
- ```
479
-
480
- ### D2: Guard Necessity (which operations need Guards)
481
-
482
- ```
483
- For each operation that changes state or moves funds:
484
- ├── Does the operation release funds from escrow?
485
- │ ── YES ──→ Guard REQUIRED (allocator trigger guard)
486
- ├── Does the operation mark an irreversible state transition?
487
- │ ── YES ──→ Guard REQUIRED (machine forward guard)
488
- ├── Does the operation accept an order / take custody?
489
- │ ── YES ──→ Guard REQUIRED (service buy_guard: KYC + amount cap)
490
- ├── Does the operation only read or advance a non-fund, non-terminal node?
491
- │ ── YES ──→ Guard OPTIONAL (logistics-only forward)
492
- └── No fund flow AND no irreversible state change?
493
- ──→ Guard NOT NEEDED
494
- ```
495
-
496
- ### D3: Allocation Strategy (single vs multi-allocator)
497
-
498
- ```
499
- How many terminal nodes does the Machine have?
500
- ├── 1 terminal (e.g., digital_goods: completed only)
501
- │ ──→ SINGLE Allocator: 100% to provider on completed
502
- ├── 2 terminals (e.g., freelance: completed + refunded)
503
- │ ──→ DUAL Allocators: one per terminal, refund path mandatory
504
- ├── 3+ terminals (e.g., rental: completed + refunded + damage_deducted)
505
- │ ──→ MULTI Allocators: one per terminal, each with its trigger Guard
506
- └── Multi-tier distribution (travel: agency then hotel/guide/driver)?
507
- ──→ TIER 3: chained Allocators, primary pays agency, secondary splits agency receipts
508
- ──→ Validate each tier's trigger Guard chain is acyclic
509
- ```
510
-
511
- ### D4: Publishing Timing (when to publish Service)
512
-
513
- ```
514
- Service publish readiness:
515
- ├── Machine published? ── NO ──→ BLOCK: publish Machine first
516
- ├── All Guards created and gen_passport PASS? ── NO ──→ BLOCK: re-test Guards
517
- ├── order_allocators bound and each Allocator's Guard exists? ── NO ──→ BLOCK: bind Allocators
518
- ├── Test order completed phase_3 successfully? ── NO ──→ BLOCK: run dry-run
519
- └── All checks PASS ──→ publish Machine (phase_4), then publish Service
520
- ──→ Post-publish: verify bPublished=true, machine + order_allocators immutable
521
- ```
522
-
523
- ### D5: Scenario Match (R1 intent classification)
524
-
525
- ```
526
- User intent text
527
- ├── keywords match freelance? ──→ scenario = freelance (Tier 1)
528
- ├── keywords match rental? ──→ scenario = rental (Tier 2)
529
- ├── keywords match digital_goods? ──→ scenario = digital_goods (Tier 1)
530
- ├── keywords match travel_package? ──→ scenario = travel_package (Tier 3)
531
- ├── multiple scenarios match equally?
532
- │ ──→ ask one disambiguating question (LLM-translated to typed choice)
533
- │ ──→ retry once; if still ambiguous → general
534
- └── no scenario matches ──→ scenario = general (fallback, not an error)
535
- ```
536
-
537
- ---
538
-
539
- ## Failure Playbooks
540
-
541
- ### F1: Dependency Cycle Detection
542
-
543
- **Symptom**: The ODG assembler detects a cycle — object A depends on B, B depends on A (directly or transitively).
544
-
545
- **Recovery**:
546
- 1. Run a topological sort on `objects[].dependencies`. If it fails, a cycle exists.
547
- 2. Identify the cycle's edges. Most cycles come from the Object-Guard Circular Reference Pattern (wowok-tools §Object-Guard Circular Reference Pattern) being modeled as a hard dependency instead of a name-resolved soft reference.
548
- 3. Replace the hard dependency with a `name_reference` field: Guards reference their host object by name (string), not by ODG id. The SDK resolves the name at runtime.
549
- 4. Re-run the sort. If still cyclic → the Machine graph itself has a cycle; hand off to wowok-machine §Cycle Detection.
550
- 5. Do NOT hand off to the Harness until the ODG is acyclic.
551
-
552
- ### F2: Missing User Decisions (R1-R7 incomplete)
553
-
554
- **Symptom**: The planner reaches R8 review but one or more objects have empty `user_decisions`.
555
-
556
- **Recovery**:
557
- 1. Identify which round owns each empty decision (R3=Service fields, R4=Permission, R5=Machine, R6=Guards, R7=Allocation).
558
- 2. Return to the earliest incomplete round; apply scenario defaults for any field the user skipped, flag each auto-filled field in `notes`.
559
- 3. Re-run R8 review. If the user rejects an auto-fill → loop back to that specific field.
560
- 4. Never hand off an ODG with empty `user_decisions` — the Harness will fail at execution.
561
-
562
- ### F3: Scenario Miss (intent doesn't match any template)
563
-
564
- **Symptom**: No scenario keywords match the user's intent, or the user explicitly says "none of these fit".
565
-
566
- **Recovery**:
567
- 1. Select `general` scenario. This is the intended fallback, not an error.
568
- 2. Load the empty ODG skeleton (Permission + Service + 2-node Machine + buy_guard + refund_guard + 2 Allocators).
569
- 3. Walk R3-R7 with empty defaults; the user provides every field.
570
- 4. If the user's intent is actually a hybrid (e.g., freelance + deposit) → load the dominant scenario and add the conflicting trait as an override, recording the hybrid in `notes`.
571
- 5. Flag the ODG as Tier 1+ (user-defined complexity).
572
-
573
- ### F4: LLM Fallback (LLM unavailable or rate-limited)
574
-
575
- **Symptom**: The LLM cannot be invoked for intent clarification or free-text translation.
576
-
577
- **Recovery**:
578
- 1. Fall back to pure rule-based planning: skip clarification questions, apply the first scenario whose keywords match (or `general` if none).
579
- 2. For free-text fields (description, deliverable), use the scenario template's placeholder text verbatim and flag `needs_user_edit: true` in `notes`.
580
- 3. For typed choices, apply the scenario default without asking.
581
- 4. Mark the ODG `planning_mode: "rule_only"` so the Harness knows human review of free-text fields is required before phase 4 publish.
582
- 5. Do NOT block planning on LLM unavailability — the deterministic path must always produce a valid ODG.
583
-
584
- ### F5: Resume Conflict (checkpoint vs on-chain state)
585
-
586
- **Symptom**: On resume, an object in the ODG checkpoint no longer exists on-chain, or its state has changed (e.g., a draft Service was published by another path).
587
-
588
- **Recovery**:
589
- 1. `query_toolkit` → `onchain_objects` for every object ID in the checkpoint.
590
- 2. For each mismatch:
591
- - Object missing → mark `status: missing`, re-plan that object as CREATE in the next phase.
592
- - Object published unexpectedly → mark `status: published`, skip its creation phase, verify its fields match the ODG (if not, surface conflict).
593
- - Object modified → re-read its current fields, update the ODG, flag `user_review: true`.
594
- 3. On-chain state is the source of truth; the checkpoint is only a hint.
595
- 4. If more than 30% of objects are mismatched → recommend restarting planning from R1.
596
-
597
- ### F6: Sharing Sum Invalid
598
-
599
- **Symptom**: An Allocator's `sharing` array sums to a value other than 10000 (basis points).
600
-
601
- **Recovery**:
602
- 1. Auto-normalize: scale each share proportionally so the sum equals 10000. Round to whole basis points; assign any remainder to the largest share.
603
- 2. Present the normalized array to the user for confirmation at R8.
604
- 3. If the user rejects → return to R7, let the user re-enter shares manually.
605
- 4. Never hand off an ODG with an invalid sharing sum — the Move contract will reject the Allocation at creation.
606
-
607
- ---
608
-
609
- ## Tier Layering
610
-
611
- ### Tier 1 (Basic)
612
-
613
- - Single Service + simple Machine (≤ 5 nodes) + 1 Guard set (buy + refund minimum) + 1-2 Allocators
614
- - Single allocator recipient (provider only)
615
- - Scenario templates drive all defaults; user only confirms
616
- - Typical scenarios: freelance (simple), digital_goods
617
- - Estimated planning time: 5 minutes
618
- - Estimated execution time: 10 minutes
619
-
620
- ### Tier 2 (Standard)
621
-
622
- - Multi-Guard (3-5 Guards including deposit/inspect/damage) + multi-state Machine (6-10 nodes) + multi-Allocator (3+ terminal paths)
623
- - Multiple recipient types (Entity + GuardIdentifier)
624
- - Timeout/auto-advance forwards on acceptance and return nodes
625
- - Typical scenarios: rental, freelance with arbitration
626
- - Estimated planning time: 10 minutes
627
- - Estimated execution time: 30 minutes
628
-
629
- ### Tier 3 (Advanced)
630
-
631
- - Complex dependency chains (chained Allocators, multi-tier distribution) + conditional flows (arbiter routing) + arbitration integration
632
- - Multi-tier Allocation (primary → secondary waterfall)
633
- - Hybrid scenarios (e.g., travel + rental)
634
- - Guard chains where one Guard's output feeds another's submission
635
- - Typical scenarios: travel_package, general with custom complexity
636
- - Estimated planning time: 20 minutes
637
- - Estimated execution time: 60 minutes
638
-
639
- ### Tier Escalation Rules
640
-
641
- - If the user overrides more than 3 scenario defaults → escalate one tier.
642
- - If the Machine has > 10 nodes → escalate one tier.
643
- - If multi-tier Allocation is selected → minimum Tier 3.
644
- - If arbitration is bound → minimum Tier 2.
645
- - Tier can be escalated mid-planning; it never downgrades within a single task.
646
-
647
- ---
648
-
649
- ## Handoff Protocol
650
-
651
- ### When to Hand Off
652
-
653
- | Trigger | Target | Reason |
654
- |---------|--------|--------|
655
- | R10 confirmed, fresh build | [wowok-onboard](../wowok-onboard/SKILL.md) | Guided R1-R10 execution of the ODG |
656
- | R10 confirmed, extending existing Service | [wowok-provider](../wowok-provider/SKILL.md) | Operations-phase execution |
657
- | R5 Machine design exceeds scenario template | [wowok-machine](../wowok-machine/SKILL.md) | Custom workflow detail design |
658
- | R6 Guard logic exceeds scenario template | [wowok-guard](../wowok-guard/SKILL.md) | Custom Guard table design |
659
- | R9 reveals dispute scenario | [wowok-arbitrator](../wowok-arbitrator/SKILL.md) | Arbitration setup before publish |
660
- | User asks about buyer-side flow | [wowok-order](../wowok-order/SKILL.md) | Customer perspective |
661
-
662
- ### Handoff Packet Format
663
-
664
- When handing off to the Harness or a delegate Skill, emit this context bundle:
665
-
666
- ```yaml
667
- handoff:
668
- from: wowok-planner
669
- to: <harness_or_delegate>
670
- state:
671
- journey: planning
672
- completed_rounds: R1-R10
673
- scenario: freelance
674
- tier: 1
675
- account: merchant_v1
676
- odg:
677
- task_id: task_20260714_001
678
- checkpoint_key: odg_task_20260714_001
679
- object_count: 6
680
- phase_count: 4
681
- irreversible_count: 4
682
- status: confirmed
683
- carry_context:
684
- - scenario_template # so delegate knows what was pre-filled
685
- - user_decisions # any deviations from scenario defaults
686
- - risk_acknowledgments # R9 acknowledgments
687
- next_actions:
688
- - phase: phase_1_draft_objects
689
- delegate: wowok-onboard
690
- verification: query_toolkit.onchain_objects confirms all objects exist with bPublished=false
691
- - phase: phase_2_guard_test
692
- verification: gen_passport returns PASS for each Guard
693
- - phase: phase_3_test_order
694
- verification: test order traverses full Machine
695
- - phase: phase_4_publish
696
- verification: bPublished=true, immutability locks confirmed
697
- ```
698
-
699
- ### Resumption Protocol
700
-
701
- When `wowok-planner` is invoked and a checkpoint exists:
702
- 1. Read the ODG checkpoint via `local_info_operation` using the `task_id`.
703
- 2. For each object in the ODG, `query_toolkit` → `onchain_objects` to verify current state (apply §F5 Resume Conflict if mismatched).
704
- 3. If all valid → resume at the next unconfirmed round.
705
- 4. If the ODG was already `status: confirmed` but Harness execution was interrupted → hand back to the Harness with the phase pointer, do not re-plan.
706
- 5. **Invariant**: on-chain state is the source of truth. The ODG is the plan; the chain is the reality.
707
-
708
- ---
709
-
710
- ## Quick Reference
711
-
712
- | Want to... | Use this |
713
- |------------|----------|
714
- | Classify a new intent | §Scenario Registry + §D5 Scenario Match |
715
- | Decide reuse vs create | §D1 Reuse vs Create |
716
- | Decide if a Guard is needed | §D2 Guard Necessity |
717
- | Pick an Allocation strategy | §D3 Allocation Strategy |
718
- | Know when to publish | §D4 Publishing Timing |
719
- | Recover from a dependency cycle | §F1 Dependency Cycle Detection |
720
- | Recover from missing decisions | §F2 Missing User Decisions |
721
- | Handle unmatched intent | §F3 Scenario Miss |
722
- | Plan without an LLM | §F4 LLM Fallback |
723
- | Resume an interrupted plan | §F5 Resume Conflict + §Resumption Protocol |
724
- | Estimate planning/execution time | §Tier Layering |