@wowok/skills 1.1.10 → 1.1.12

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