@wowok/skills 2.0.1 → 2.1.0

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.
@@ -75,20 +75,35 @@ The ODG (Object Dependency Graph) is the single output artifact, persisted via `
75
75
  "status": "confirmed",
76
76
  "account": "merchant_v1",
77
77
  "objects": [
78
- { "id": "obj_permission", "type": "permission", "status": "planned", "reversible": true, "dependencies": [], "user_decisions": { "reuse": false, "indexes": { "provider": 1000 } } },
79
- { "id": "obj_service", "type": "service", "status": "planned", "reversible": true, "dependencies": ["obj_permission"], "user_decisions": { "name": "...", "publish": "deferred" } },
80
- { "id": "obj_machine", "type": "machine", "status": "planned", "reversible": false, "dependencies": ["obj_permission"], "user_decisions": { "nodes": [...], "forwards": [...], "publish": "deferred" } },
81
- { "id": "obj_arbitration", "type": "arbitration", "status": "planned", "reversible": true, "dependencies": [], "user_decisions": { "voting_guard_count": 3, "fee_balance": "1000 WOW", "note": "arbiters live in voting_guard, NOT Permission index 1500" } }
78
+ { "id": "obj_account", "type": "account", "status": "created", "reversible": true, "dependencies": [], "user_decisions": { "reuse": false, "network": "testnet" } },
79
+ { "id": "obj_permission", "type": "permission", "status": "planned", "reversible": true, "dependencies": ["obj_account"], "user_decisions": { "reuse": false, "indexes": { "provider": 1000 } } },
80
+ { "id": "obj_service", "type": "service", "status": "planned", "reversible": true, "dependencies": ["obj_permission"], "user_decisions": { "name": "...", "publish": "deferred", "note": "DRAFT first — Guards reference it by LocalMark NAME to break the Guard↔Service cycle" } },
81
+ { "id": "obj_machine", "type": "machine", "status": "planned", "reversible": false, "dependencies": ["obj_service", "obj_permission"], "user_decisions": { "nodes": [...], "forwards": [...], "publish": "deferred" } },
82
+ { "id": "obj_guard_*", "type": "guard", "status": "planned", "reversible": false, "dependencies": ["obj_machine", "obj_service"], "user_decisions": { "logic": "...", "note": "references machine node names + service name via LocalMark NAME" } },
83
+ { "id": "obj_treasury", "type": "treasury", "status": "planned", "reversible": true, "dependencies": ["obj_permission"], "user_decisions": { "reuse": false, "note": "optional fund pool for organizations; referenced by order_allocators as Entity recipient" } },
84
+ { "id": "obj_contact", "type": "contact", "status": "planned", "reversible": true, "dependencies": ["obj_permission", "obj_account"], "user_decisions": { "reuse": false, "messenger": true, "anti_spam": "open", "note": "Service.um → Contact → ims[]; messenger enabled + anti-spam configured" } },
85
+ { "id": "obj_arbitration", "type": "arbitration", "status": "planned", "reversible": true, "dependencies": ["obj_permission"], "user_decisions": { "reuse": true, "note": "REUSE third-party; permission MUST differ from Service (E_ARBITRATION_PERMISSION_CONFLICT); compensation_fund > 0 requires non-empty arbitrations" } }
82
86
  ],
83
87
  "phases": [
84
- { "phase": 1, "objects": ["obj_permission"], "gate": "user_confirm" },
85
- { "phase": 2, "objects": ["obj_service", "obj_machine", "obj_arbitration"], "gate": "risk_check" },
86
- { "phase": 3, "objects": ["obj_guard_*"], "gate": "passport_test" },
87
- { "phase": 4, "objects": ["obj_allocator_*"], "gate": "allocation_audit" },
88
- { "phase": 5, "objects": ["publish"], "gate": "final_audit" }
88
+ { "phase": 1, "objects": ["obj_account", "obj_permission"], "gate": "user_confirm" },
89
+ { "phase": 2, "objects": ["obj_service"], "gate": "user_confirm", "note": "Service DRAFT created BEFORE Machine so Guards can reference it by name" },
90
+ { "phase": 3, "objects": ["obj_machine", "obj_guard_*"], "gate": "risk_check", "note": "Machine + Guards designed together; guards bound to forwards before publish" },
91
+ { "phase": 4, "objects": ["publish_machine", "obj_treasury", "obj_allocator_*"], "gate": "allocation_audit", "note": "Machine published; Treasury (optional) created before order_allocators references it" },
92
+ { "phase": 5, "objects": ["obj_contact", "obj_arbitration"], "gate": "user_confirm", "note": "Contact + third-party Arbitration configured BEFORE publish; arbitration.permission != service.permission" },
93
+ { "phase": 6, "objects": ["publish_service"], "gate": "final_audit" }
89
94
  ],
90
95
  "risk_assessment": { "critical": [], "warnings": [], "irreversible_count": 1 }
91
96
  }
92
97
  ```
93
98
 
94
99
  Each object has: `id`, `type`, `status` (planned/created/published), `reversible` (true/false), `dependencies` (other object IDs), `user_decisions` (typed fields). Phases gate progression — `risk_check` calls `evaluate_project` (evaluation_type='risk'), `final_audit` runs the pre-publish audit checklist (see wowok-auditor).
100
+
101
+ **Dependency-chain ordering rules (authoritative, verified from Move/SDK):**
102
+ 1. **Service DRAFT is created BEFORE Machine** — Guards reference the Service by LocalMark NAME, so the Service skeleton must exist first to break the Guard↔Service circular dependency.
103
+ 2. **Machine + Guards are designed together** (one phase) — a forward's Guard depends on the Machine's node names; the Allocator's Guard depends on both Machine and Service.
104
+ 3. **Machine publishes before Service binds it** — `service.machine` must reference a *published* Machine.
105
+ 4. **`order_allocators` is L1-locked** — set it before `service.publish`; personal merchants route to Permission owner, organizations route to a Treasury (`Entity` recipient).
106
+ 5. **Contact (customer service)** is configured before Service publish — `Service.um → Contact → ims[]`, with the local account enabled as messenger and anti-spam set.
107
+ 6. **Arbitration is third-party and before publish** — `arbitration.permission != service.permission` (`E_ARBITRATION_PERMISSION_CONFLICT`); `compensation_fund > 0` requires non-empty `arbitrations` (`E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND`).
108
+
109
+ These rules are the single source of truth for the dependency chain; the phase list above is their concrete serialization. Hand-off to `wowok-onboard` (Review opening + 12 rounds) follows this same chain.
@@ -30,42 +30,46 @@ when_to_use:
30
30
 
31
31
  The following rule tables have been pushed down to the MCP knowledge layer and are automatically applied during project operations. You do NOT need to manually check these — the MCP server enforces them.
32
32
 
33
- | Rule Category | MCP Knowledge Module | Applied By |
34
- |---------------|---------------------|------------|
35
- | Safety rules (confirmation, immutability, object reuse) | `knowledge/safety-rules.ts` | `evaluate_project` + `onchain_operations` pre-publish |
36
- | Guard design patterns | `knowledge/guard-design-patterns.ts` | `evaluate_project` (guard risk assessment) |
37
- | Machine topology rules | `knowledge/machine-risk.ts` | `evaluate_project` (machine risk assessment) |
38
- | Scenario mode defaults | `knowledge/scenario-modes.ts` | `create_project` (pass `project_industry` parameter) |
39
- | Tool reference (gas, faucet, wrappers) | `knowledge/tools-reference.ts` | All tool calls automatically |
33
+ | Rule Category | Access via (MCP action) | Applied By |
34
+ |---------------|--------------------------|------------|
35
+ | Safety rules (confirmation, immutability, object reuse) | `schema_query` action='get_safety_rules' | `evaluate_project` + `onchain_operations` pre-publish |
36
+ | Guard design patterns | `schema_query` action='get_guard_design_patterns' | `evaluate_project` (guard risk assessment) |
37
+ | Machine topology rules | auto-applied | `evaluate_project` (machine risk assessment) |
38
+ | Scenario mode defaults | `project_operation` action='list_modes' | `create_project` (pass `project_industry` parameter) |
39
+ | Tool reference (gas, faucet, wrappers) | `schema_query` action='get_tool_reference' | All tool calls automatically |
40
40
 
41
41
  **How to use**: Call `project_operation` with `action: "evaluate_project"` (evaluation_type='risk') after completing your puzzle — the MCP server will automatically apply all relevant safety rules and return risk findings.
42
42
 
43
43
  ---
44
44
 
45
+ ## Core Interaction Principles
46
+
47
+ These four principles govern every service build/modify step. They mirror the wowok-onboard model and are non-negotiable.
48
+
49
+ 1. **Review-first**: State (a) what the AI understood about the service, (b) the dependency order to build/modify, and (c) the interaction contract — before the first choice.
50
+ 2. **User-driven**: Every step is an explicit user decision; the AI provides a `recommend` but never auto-advances. The user may pause at any important step.
51
+ 3. **Reuse / Customize / Discover (三选一)**: For every component (Permission, Machine, Guard, Treasury, Contact, Arbitration, etc.), surface all three avenues — reuse an existing object (benefit), customize a new one (sub-task ability), or discover from other projects / the system.
52
+ 4. **Default-config disclosure**: Disclose a new object's default config + important info + caveats BEFORE the user decides. No silent defaults.
53
+
54
+ ---
55
+
45
56
  ## ⚠️ PRE-FLIGHT: Required Items Checklist
46
57
 
47
58
  **THIS SECTION IS MANDATORY.** Before ANY service creation or publication, the AI MUST collect explicit user confirmation for EVERY required item. **Do NOT skip, do NOT fabricate, do NOT proceed with missing items.**
48
59
 
49
60
  ### The Golden Rule
50
61
 
51
- ```
52
- NEVER guess what the user sells, how their workflow operates, or how funds are distributed.
53
- These are BUSINESS decisions that ONLY the user can make.
54
-
55
- User hasn't provided it → ASK.
56
- User provides incomplete info → ASK for clarification.
57
- User says "just make something up" → REFUSE and explain why each item matters.
58
- ```
62
+ > **Golden Rule**: NEVER guess what the user sells, how their workflow operates, or how funds are distributed — these are BUSINESS decisions only the user can make. Not provided → ASK; incomplete → ASK to clarify; "just make something up" → REFUSE and explain why each item matters.
59
63
 
60
64
  ### Required Items
61
65
 
62
- For each item, the user must provide one of: **"Reuse existing: `<name_or_id>`"** OR **"Create new: `<details>`"**
66
+ For each item, the user must provide one of: **"Reuse existing: `<name_or_id>`"** OR **"Create new: `<details>`"** OR **"Discover from system / other projects"** — reuse / customize / discover, all three avenues must be surfaced.
63
67
 
64
68
  | # | Item | User Must Provide | Why Not Fabricate |
65
69
  |---|------|-------------------|--------------------|
66
70
  | **R1** | **Account** | Account name/address. Default `""` is fine. | Safe default exists |
67
71
  | **R2** | **Permission** | Existing Permission to reuse, OR name + type_parameter for new. **Reuse strongly recommended.** | Controls access to ALL your services |
68
- | **R3** | **Service** | Service name, type_parameter. What kind of service? | Your brand identity on-chain |
72
+ | **R3** | **Service (DRAFT)** | Service name, type_parameter. Create the draft FIRST (unpublished) so Guards can reference it by LocalMark NAME. | Your brand identity on-chain; breaks Guard↔Service cycle |
69
73
  | **R4** | **Machine** | Nodes, state transitions (pairs), forward paths. | IS your business process |
70
74
  | **R5** | **Guards** | For each Guard: validation logic, conditions. Reuse or define new. | Enforces your business rules |
71
75
  | **R6** | **Guard Bindings** | Which Guard validates which Machine forward? | Wrong binding = unauthorized access |
@@ -75,7 +79,7 @@ For each item, the user must provide one of: **"Reuse existing: `<name_or_id>`"*
75
79
 
76
80
  | # | Item | Trigger | User Must Provide |
77
81
  |---|------|---------|-------------------|
78
- | **C1** | **Contact (um)** | If `customer_required` is set | Contact name/ID |
82
+ | **C1** | **Contact (um)** | If `customer_required` is set (or customer service is desired) | Contact name/ID; if NEW → local account as messenger (`enabled: true`) + anti-spam profile (Open/Guarded/Closed/Defensive) |
79
83
  | **C2** | **WIP Files** | Physical goods | Product description, images |
80
84
  | **C3** | **Sales Products** | Listing products | Name, price, stock, WIP per product |
81
85
 
@@ -104,114 +108,29 @@ STEP 0: Present checklist R1-R7 to user
104
108
 
105
109
  ## Service Build Lifecycle
106
110
 
107
- Once R1-R7 confirmed, execute in strict order. All operations use R1 (Account) as `env.account`.
108
-
109
- ```
110
- All Tool: references below are sub-tools invoked via wowok({ tool: "<name>", data: { operation_type: "<type>", ... } })
111
-
112
- STEP 1: Foundation
113
- ├── Permission — REUSE existing (strongly recommended)
114
- │ Tool: "onchain_operations" (permission) | Fields: name, type_parameter
115
- └── Machine (unpublished) — CREATE new or REUSE template
116
- Tool: "onchain_operations" (machine) | Fields: nodes, pairs, forwards
117
- ⚠️ Machine nodes define the workflow; forward guards can be set inline here
118
- Discovery: "query_toolkit" (account_list, local_mark_list, onchain_objects)
119
- Template: "machineNode2file" (export existing for editing)
120
-
121
- STEP 2: Trust Layer
122
- └── Guards — CREATE new or REUSE existing
123
- Tool: "onchain_operations" (guard) | Fields: logic, instructions
124
- Template: "guard2file" (export existing for editing)
125
- ⚠️ Design your Guard tables based on how the target object reads data:
126
- - buy_guard → pass/fail only, no data extraction
127
- - Allocator guard → pass/fail only
128
- - Machine forward guard → if retained_submission is used, ensure b_submission:true entries match expected types
129
- - Reward guard → pass/fail only
130
- Guard design patterns: MCP `knowledge/guard-design-patterns.ts` (auto-applied via `evaluate_project`)
131
-
132
- STEP 3: Business Logic (MODIFY Machine)
133
- ├── Machine — bind Guards to forwards (update existing forwards with guard fields)
134
- │ Tool: "onchain_operations" (machine) | Fields: node (op: "add forward" / "set" with updated forwards including guard)
135
- │ ⚠️ Machine is still unpublished here — guards can be freely bound/unbound
136
- ├── Machine — publish (locks nodes/pairs/forwards permanently)
137
- │ Tool: "onchain_operations" (machine) | publish: true
138
- │ ⚠️ After publish, nodes/forwards are IMMUTABLE — verify via machineNode2file first
139
- └── Service (unpublished) — CREATE with machine + order_allocators + buy_guard + sales
140
- Tool: "onchain_operations" (service) | Fields: object (with permission), machine, order_allocators, buy_guard, sales
141
- ⚠️ machine must reference a PUBLISHED Machine (else Service publish will fail)
142
- ⚠️ order_allocators is L1-locked — MUST be set before Service publish
143
-
144
- STEP 4: Publication
145
- ├── Pre-Publish Verification (export and review):
146
- │ 1. machineNode2file → verify Machine nodes/forwards (published, immutable)
147
- │ 2. guard2file → verify Guard logic
148
- │ 3. project_operation evaluate_project (risk) → fix CRITICAL findings
149
- │ 4. Permission indexes: every permissionIndex in Machine forwards has entities granted?
150
- │ 5. Arbitration Permission isolation (if compensation_fund > 0)
151
- ├── Service — publish (locks machine/order_allocators)
152
- │ Tool: "onchain_operations" (service) | object: "<service_name>", publish: true
153
- │ ⚠️ L1-LOCKED: machine and order_allocators are permanently frozen
154
- └── Post-publish (mutable fields):
155
- description, location, sales, discount, buy_guard, customer_required, um (Contact), rewards (add), arbitrations (add), repositories (add)
156
-
157
- STEP 5: Post-Publish (MODIFY Service — mutable after publish)
158
- ├── description, location
159
- ├── sales (products with WIP) — ⛔ user MUST provide: name, price, stock, WIP
160
- ├── customer_required
161
- ├── um — Contact (REUSE existing or CREATE new)
162
- │ ⚠️ If customer_required is set → um MUST be set
163
- └── Test Order — verify full flow works
164
- Tool: "onchain_operations" (service) | order_new: { buy: { items, total_pay } }
165
- ⚠️ Requires Service bPublished=true (else E_NOT_PUBLISHED)
166
- After order: progress advance → allocation.alloc_by_guard → verify fund distribution
167
- ```
111
+ Once R1-R7 confirmed, execute in strict order. Sub-tools are invoked via `wowok({ tool: "<name>", data: { operation_type: "<type>", ... } })`; all use R1 (Account) as `env.account`.
168
112
 
169
- ### Object Reuse & Immutability
113
+ **STEP 1 — Foundation**: Account (`account_operation` gen) → Permission (`onchain_operations` permission) → Service DRAFT (`onchain_operations` service, `publish: false` — Guards reference it by LocalMark NAME) → Machine unpublished (`onchain_operations` machine: nodes/pairs/forwards). Discovery `query_toolkit` (account_list/local_mark_list/onchain_objects); template `machineNode2file`.
170
114
 
171
- | Object | Reuse Strategy | When Locked |
172
- |--------|---------------|-------------|
173
- | **Permission** | **Strongly recommended** — centralized control | Never |
174
- | Machine | Reuse via `machineNode2file` template | After publish |
175
- | Contact (um) | Reuse existing customer service Contact | Never |
176
- | Arbitration | Always reuse existing Arb services | — |
177
- | Guard | Reuse if logic matches | After creation |
178
- | Service | — | After publish: machine, order_allocators frozen |
115
+ **STEP 2 — Trust Layer (Guards)**: `onchain_operations` guard (logic/instructions). Design per target: buy_guard / allocator / reward = pass/fail only; machine forward guard = retained_submission needs `b_submission: true` entries matching types. Patterns: `schema_query` action='get_guard_design_patterns'.
179
116
 
180
- ### Service Step-by-Step Update (Two-Phase Deployment)
117
+ **STEP 3 — Bind + Publish Machine, Bind Service**: `onchain_operations` machine (`add forward`/`set` with guard) → machine `publish: true` (nodes/forwards IMMUTABLE; verify via machineNode2file) → `onchain_operations` service bind machine + buy_guard (machine must be PUBLISHED).
181
118
 
182
- Deploy a Service in two phases to handle Guard↔Service circular dependencies via LocalMark names. Both phases call `onchain_operations` (operation_type: "service"); they differ by `publish` flag and binding completeness.
119
+ **STEP 4 — Products (Sales + WIP)**: `onchain_operations` service sales (name/price/stock/wip/wip_hash); ⛔ user provides name/price(u64 min unit)/stock. `wip` = public URL + hash (on-chain stores URL+hash, not file); AI sub-task: generate WIP from web/doc → deploy to public URL (GitHub Pages). `wip <= MAX_WIP_LENGTH`, `wip_hash <= MAX_WIP_HASH_LENGTH`.
183
120
 
184
- **Phase 1 — CREATE (no publish)**: Build the full object graph with LocalMark name references so addresses can resolve later. Machine must be PUBLISHED before this phase.
121
+ **STEP 5 — Revenue (order_allocators + Treasury)**: `onchain_operations` service order_allocators (L1-locked). Mode: amount / rate (bps sum=10000) / surplus. Recipient: `{Entity}` / `{GuardIdentifier}` / `{Signer}`. Personal → Permission owner (Entity); Org → Treasury (`Treasury.receive` index 253). Offer new/select Treasury (query onchain_objects type=treasury).
185
122
 
186
- ```
187
- onchain_operations.service {
188
- object: {name: "<service_name>", type_parameter, permission},
189
- machine: "<published_machine_name_or_address>", # must be published
190
- order_allocators: [{ guard: "<guard_local_mark>", sharing: [...] }, ...],
191
- arbitrations: { list: ["<arb_local_mark>", ...] },
192
- buy_guard: "<buy_guard_local_mark>", # LocalMark name — defers resolution
193
- sales: [{ name, price, stock, wip: "<URL>" }],
194
- publish: false # CRITICAL: do not publish yet
195
- }
196
- ```
123
+ **STEP 6 — Customer Service (Contact + Messenger)**: `onchain_operations` contact (ims) + `account_operation` messenger (`enabled: true`). Contact mutable; `im_add`/`im_remove` need permission index 453 (CONTACT_IM). Anti-spam profiles: Open / Guarded / Closed / Defensive. Bind `onchain_operations` service `um` (if customer_required).
197
124
 
198
- **Phase 2 — PUBLISH**: After all referenced objects (Machine, Guards, Allocators) are created/published, re-call to publish.
125
+ **STEP 7 — Trust (Arbitration + compensation_fund)**: REUSE third-party Arbitration (MUST NOT share Service's Permission — E_ARBITRATION_PERMISSION_CONFLICT 33; don't create your own). `compensation_fund_add` (internal Balance<T>, not Treasury); fund>0 requires non-empty arbitrations (E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND 25); withdraw needs bPaused + lock elapsed.
199
126
 
200
- ```
201
- onchain_operations.service {
202
- object: "<service_name>", # target the existing draft by name
203
- publish: true
204
- }
205
- ```
127
+ **STEP 8 — Publication**: pre-publish verify — (1) machineNode2file, (2) guard2file, (3) evaluate_project risk → fix CRITICAL, (4) permission indexes granted, (5) arb permission isolation, (6) contact ims+enabled → `onchain_operations` service `publish: true` (L1-LOCKED: machine/order_allocators/arbitrations).
206
128
 
207
- > The SDK resolves all LocalMark names → on-chain addresses at publish time. Phase 1 + Phase 2 together replace the "create draft → mutate → publish" sequence in STEP 1-4 of the Service Build Lifecycle when circular dependencies exist.
129
+ **STEP 9 — Post-publish + Test Order**: mutable fields (description/location/sales/customer_required/rewards add/repositories add). Test order: `order_new` (requires bPublished, else E_NOT_PUBLISHED) → disclose next nodes → advance (order.progress / progress.operate) → alloc_by_guard → verify distribution. User chooses test account (default: service-creation account).
208
130
 
209
- **Post-publish mutability** (SDK-LOCKED vs mutable):
131
+ ### Post-Publish Mutability (SDK-LOCKED vs mutable)
210
132
 
211
- | Field | After Publish |
212
- |-------|---------------|
213
- | `buy_guard`, `sales`, `description`, `repositories` (add), `rewards` (add) | **Mutable** |
214
- | `machine`, `order_allocators`, `arbitrations` | **SDK-LOCKED** (immutable — fork required to change) |
133
+ Served by MCP `schema_query` action='get_safety_rules' (immutability-after-publish). Summary: `buy_guard` / `sales` / `description` / `repositories` / `rewards` are mutable; `machine` / `order_allocators` / `arbitrations` are SDK-LOCKED (fork required to change).
215
134
 
216
135
  ---
217
136
 
@@ -222,76 +141,17 @@ onchain_operations.service {
222
141
  > **Boundary conditions**: Service/Machine are IMMUTABLE after publish; Payment is FROZEN at creation; Order/Progress/Arbitration operations are irreversible. Use `get_project_detail` to check whether a project has published objects.
223
142
 
224
143
  ```
225
- Service (merchant storefront)
226
- ├── permission → Permission (required, mutable after publish)
227
- ├── machine → Machine (required, IMMUTABLE after publish per service.move:633 assert!(!self.bPublished))
228
- ├── order_allocators → Allocators inline struct (optional, IMMUTABLE after publish per service.move:503; each Order creates an independent Allocation at runtime)
229
- ├── arbitrations → Arbitration[] (optional, mutable after publish, max 20)
230
- ├── compensation_fund → Balance<T> value (optional, mutable after publish; NOT a Treasury address — Treasury is an independent object)
231
- ├── repositories → Repository[] (optional, mutable after publish; consensus repository refs)
232
- ├── sales → ServiceSale[] (optional, mutable after publish; inline product listings with name/price/stock/wip — NOT a Repository ref)
233
- ├── rewards → Reward[] (optional, mutable after publish)
234
- ├── um → Contact (optional, mutable after publish; customer service)
235
- ├── customer_required → string[] (optional, mutable after publish; personal info mark names, not a direct Personal ref)
236
- └── buy_guard → Guard (optional, mutable after publish; gates order placement)
237
-
238
- Order (per purchase, runtime-created)
239
- ├── builder → Customer (immutable after creation)
240
- ├── service → Service snapshot (immutable after creation)
241
- ├── machine → Machine (immutable after creation)
242
- ├── progress → Progress (immutable after binding)
243
- ├── dispute → Arb[] (optional; Arb addresses pushed on dispute per order.move:93, immutable once set — NOT an Arbitration ref)
244
- └── allocation → Allocation (optional, created at runtime; triggered via Progress.forward)
245
-
246
- Cross-object references:
247
- - Guard is referenced by 9 object types via diverse nested paths (full schema via MCP `schema_query` action='get_guard_design_patterns'):
248
- - Service.buy_guard (top-level Option<address>)
249
- - Machine.forward.guard (per-node dynamic table; SDK does not expose — requires query_table)
250
- - Allocation.allocators[].guard (array element — graph-builder edge fieldName: allocator_guard)
251
- - Arbitration.voting_guard[].guard (array element) + Arbitration.usage_guard (top-level Option)
252
- - Reward.guards[].guard (array element — graph-builder edge fieldName: guard)
253
- - Repository.policies[].write_guard[].guard (deeply nested) + Repository.policies[].quote_guard
254
- - Treasury.external_deposit_guard[].guard + Treasury.external_withdraw_guard[].guard (dual arrays)
255
- - Demand.guards[].guard (array element — graph-builder edge fieldName: guard)
256
- - Passport.info[].guard (verification snapshot, read-only)
257
- - Machine is referenced by 4 object types (Service.machine, Order.machine, Progress.machine, Order snapshot)
258
- - Permission is the central hub — 11 objects hold BuiltinPermissionIndex
144
+ Service → permission, machine (immutable), order_allocators (immutable),
145
+ arbitrations, compensation_fund (Balance<T>, NOT a Treasury ref),
146
+ repositories, sales, rewards, um (Contact), customer_required, buy_guard
147
+ Order (runtime) → builder, service snapshot, machine, progress, dispute (Arb[]), allocation
259
148
  ```
260
149
 
261
- ### Allocators + Machine Integration
262
-
263
- Design together for coherent fund flow. **Allocation Modes** (execute in order):
264
- 1. **Amount** — Fixed U64 per recipient
265
- 2. **Rate** — Basis points (10000 = 100%)
266
- 3. **Surplus** — Receives remainder (max 1)
267
-
268
- ```
269
- Example: Delivery workflow
270
- "delivered" → "order_complete" (threshold: 1)
271
- └── Forward: "customer_signed" → Allocator: 95% merchant, 5% platform
272
-
273
- "delivered" → "package_lost" (threshold: 2)
274
- ├── Forward: "customer_reports_lost"
275
- ├── Forward: "merchant_confirms_lost"
276
- └── Allocator: 100% to order (buyer withdraws)
277
- ```
150
+ Cross-object references (which 9 object types hold a Guard and which 4 hold a Machine) are served by MCP `schema_query` action='get_guard_design_patterns'. Permission is the central hub — 11 objects hold BuiltinPermissionIndex.
278
151
 
279
- ### Recipient Types in Allocators
280
-
281
- Each `sharing[].who` field determines where funds go. Choose the correct type based on who the recipient is and whether their address is known at Service creation time.
282
-
283
- | Type | Syntax | Resolves To | When to Use |
284
- |------|--------|-------------|-------------|
285
- | `Entity` | `{"Entity": {"name_or_address": "travel_service"}}` | Fixed address (resolved from account/mark/address) | Known recipient at creation time (merchant, platform) |
286
- | `GuardIdentifier` | `{"GuardIdentifier": N}` | Address from Guard table index N (submitted at runtime) | Dynamic recipient known only at order time (customer/Order ID) |
287
- | `Signer` | `{"Signer": "signer"}` | The caller of `alloc_by_guard` | Rare — only when the caller should receive all funds |
288
-
289
- > **⚠️ Common Mistake**: Using `{"Signer": "signer"}` for all sharing entries causes ALL funds to go to whoever calls `alloc_by_guard`, making differentiated splits (e.g., 80% merchant + 20% customer) impossible. Use `Entity` for known recipients and `GuardIdentifier` for dynamic ones.
152
+ ### Allocators + Machine Integration
290
153
 
291
- **Design Pattern for Customer Refunds**:
292
- - Merchant receipt → `{"Entity": {"name_or_address": "<service_name>"}}` — funds go to the Service object
293
- - Customer refund → `{"GuardIdentifier": 0}` — funds go to the Order object (customer as builder can withdraw)
294
- - The allocation Guard must have `identifier: 0` with `b_submission: true` and `value_type: "Address"` to accept the Order ID at runtime
154
+ Design together for coherent fund flow. **Allocation modes** (amount / rate / surplus) and **recipient types** (`Entity` / `GuardIdentifier` / `Signer`) are served by MCP allocation knowledge — the authoritative table + customer-refund design pattern live there. Summary: `Entity` = fixed known recipient; `GuardIdentifier` = runtime-submitted address (customer/Order ID); `Signer` = the `alloc_by_guard` caller (rare — don't use for all entries or splits collapse to one recipient).
295
155
 
296
156
  ### Triggering Allocation Distribution
297
157
 
@@ -369,15 +229,7 @@ Before forking, verify necessity via `get_project_detail` → `has_published_obj
369
229
  | Order | Fund escrow | Read-only |
370
230
  | **Progress** | Workflow state | **Operate this** — `hold: true` (lock) → work → `hold: false` (submit) |
371
231
 
372
- **⚠ Progress Routing Rule** (critical):
373
-
374
- | Forward `namedOperator` | Required Operation | Why |
375
- |------------------------|--------------------|-----|
376
- | `""` (empty = OrderHolder) | `order.progress` | Uses `order.has_op_permission` — order owner/agents authorized |
377
- | `"<role_name>"` (non-empty) | `progress.operate` | Uses Progress named_operator namespace |
378
- | `None` + `permissionIndex` | `progress.operate` | Uses Permission object entity table |
379
-
380
- Wrong path → "Permission denied" (Move abort code 5). The empty-string `namedOperator` is set automatically by `service::buy` — the customer becomes the operator. Providers who need to act on a forward should either use a non-empty `namedOperator` (and `progress.operate`) or use `permissionIndex` (requiring a custom permission grant in the Service's Permission object).
232
+ **⚠ Progress Routing Rule** (critical): served by MCP `schema_query` action='get_safety_rules' (operation classification). Summary: empty `namedOperator` (`""`) → `order.progress`; non-empty role name or `permissionIndex` → `progress.operate`. Wrong path → "Permission denied" (abort code 5).
381
233
 
382
234
  **AI Reminder**: When fulfilling, check `customer_required` fields. Missing → prompt via Messenger.
383
235