@wowok/skills 1.1.9 → 1.1.11

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