@wowok/agent-mcp 2.5.2 → 2.5.4

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 (110) hide show
  1. package/dist/customer/index.d.ts +2 -2
  2. package/dist/customer/index.js +1 -1
  3. package/dist/customer/info-puzzle.d.ts +39 -2
  4. package/dist/customer/info-puzzle.js +370 -29
  5. package/dist/customer/risk-assessment.js +51 -14
  6. package/dist/customer/types.d.ts +85 -0
  7. package/dist/index.js +46 -6
  8. package/dist/knowledge/guard-design-patterns.js +104 -1
  9. package/dist/knowledge/guard-ledger.js +3 -3
  10. package/dist/knowledge/guard-lint.js +3 -3
  11. package/dist/knowledge/guard-risk.js +23 -15
  12. package/dist/knowledge/guard-templates.js +174 -2
  13. package/dist/knowledge/guard-translation.js +3 -3
  14. package/dist/knowledge/index.d.ts +3 -0
  15. package/dist/knowledge/index.js +9 -0
  16. package/dist/knowledge/machine-context.d.ts +1 -1
  17. package/dist/knowledge/machine-context.js +21 -0
  18. package/dist/knowledge/machine-ledger.d.ts +1 -0
  19. package/dist/knowledge/machine-ledger.js +60 -37
  20. package/dist/knowledge/machine-risk.js +23 -0
  21. package/dist/knowledge/machine-templates.js +150 -164
  22. package/dist/knowledge/overrides-loader.d.ts +13 -0
  23. package/dist/knowledge/overrides-loader.js +67 -0
  24. package/dist/knowledge/payment-risk.d.ts +4 -0
  25. package/dist/knowledge/payment-risk.js +67 -0
  26. package/dist/knowledge/repository-confirm.d.ts +4 -0
  27. package/dist/knowledge/repository-confirm.js +44 -0
  28. package/dist/knowledge/repository-risk.d.ts +8 -2
  29. package/dist/knowledge/repository-risk.js +61 -0
  30. package/dist/knowledge/repository-translation.js +23 -0
  31. package/dist/knowledge/reward-templates.d.ts +1 -1
  32. package/dist/knowledge/reward-templates.js +77 -5
  33. package/dist/knowledge/scenario-modes.js +22 -5
  34. package/dist/knowledge/service-templates.js +38 -0
  35. package/dist/knowledge/treasury-templates.js +42 -0
  36. package/dist/knowledge/trust-metrics.d.ts +4 -0
  37. package/dist/knowledge/trust-metrics.js +67 -7
  38. package/dist/loop-engineering/context-collect.d.ts +7 -0
  39. package/dist/loop-engineering/context-collect.js +83 -0
  40. package/dist/loop-engineering/improve.d.ts +29 -0
  41. package/dist/loop-engineering/improve.js +178 -0
  42. package/dist/project/context-assembly.d.ts +16 -0
  43. package/dist/project/context-assembly.js +130 -0
  44. package/dist/project/deployment-doc.d.ts +115 -0
  45. package/dist/project/deployment-doc.js +595 -0
  46. package/dist/project/index.js +37 -1
  47. package/dist/project/migration.d.ts +22 -0
  48. package/dist/project/migration.js +125 -0
  49. package/dist/project/project-store.d.ts +110 -0
  50. package/dist/project/project-store.js +425 -0
  51. package/dist/project/rollback-policy.d.ts +45 -0
  52. package/dist/project/rollback-policy.js +290 -0
  53. package/dist/project/stage-gate.d.ts +49 -0
  54. package/dist/project/stage-gate.js +310 -0
  55. package/dist/schema/call/allocation.d.ts +5 -0
  56. package/dist/schema/call/arbitration.d.ts +59 -54
  57. package/dist/schema/call/base.d.ts +3 -0
  58. package/dist/schema/call/base.js +1 -0
  59. package/dist/schema/call/bridge.d.ts +24 -0
  60. package/dist/schema/call/contact.d.ts +5 -0
  61. package/dist/schema/call/demand.d.ts +53 -48
  62. package/dist/schema/call/guard.d.ts +15 -0
  63. package/dist/schema/call/machine.d.ts +10 -0
  64. package/dist/schema/call/order.d.ts +5 -0
  65. package/dist/schema/call/payment.d.ts +5 -0
  66. package/dist/schema/call/permission.d.ts +5 -0
  67. package/dist/schema/call/personal.d.ts +5 -0
  68. package/dist/schema/call/progress.d.ts +5 -0
  69. package/dist/schema/call/proof.d.ts +10 -0
  70. package/dist/schema/call/repository.d.ts +5 -0
  71. package/dist/schema/call/reward.d.ts +5 -0
  72. package/dist/schema/call/service.d.ts +5 -0
  73. package/dist/schema/call/treasury.d.ts +5 -0
  74. package/dist/schema/operations.d.ts +286 -76
  75. package/dist/schema/operations.js +24 -0
  76. package/dist/schema/project/index.d.ts +2633 -120
  77. package/dist/schema/project/index.js +622 -2
  78. package/dist/schema/query/index.d.ts +601 -0
  79. package/dist/schema/query/index.js +61 -0
  80. package/dist/schema/trust/index.d.ts +10 -10
  81. package/dist/schemas/bridge_operation.schema.json +4 -0
  82. package/dist/schemas/guard2file.schema.json +4 -0
  83. package/dist/schemas/index.json +1 -1
  84. package/dist/schemas/machineNode2file.schema.json +4 -0
  85. package/dist/schemas/onchain_operations.schema.json +20 -0
  86. package/dist/schemas/onchain_operations_allocation.schema.json +4 -0
  87. package/dist/schemas/onchain_operations_arbitration.schema.json +4 -0
  88. package/dist/schemas/onchain_operations_contact.schema.json +4 -0
  89. package/dist/schemas/onchain_operations_demand.schema.json +4 -0
  90. package/dist/schemas/onchain_operations_gen_passport.schema.json +8 -0
  91. package/dist/schemas/onchain_operations_gen_proof.schema.json +8 -0
  92. package/dist/schemas/onchain_operations_guard.schema.json +4 -0
  93. package/dist/schemas/onchain_operations_machine.schema.json +4 -0
  94. package/dist/schemas/onchain_operations_order.schema.json +4 -0
  95. package/dist/schemas/onchain_operations_payment.schema.json +4 -0
  96. package/dist/schemas/onchain_operations_permission.schema.json +4 -0
  97. package/dist/schemas/onchain_operations_personal.schema.json +4 -0
  98. package/dist/schemas/onchain_operations_progress.schema.json +4 -0
  99. package/dist/schemas/onchain_operations_proof.schema.json +4 -0
  100. package/dist/schemas/onchain_operations_repository.schema.json +4 -0
  101. package/dist/schemas/onchain_operations_reward.schema.json +4 -0
  102. package/dist/schemas/onchain_operations_service.schema.json +4 -0
  103. package/dist/schemas/onchain_operations_treasury.schema.json +4 -0
  104. package/dist/schemas/project_operation.output.json +1798 -0
  105. package/dist/schemas/project_operation.schema.json +132 -2
  106. package/dist/schemas/query_toolkit.output.json +407 -1
  107. package/dist/schemas/query_toolkit.schema.json +132 -0
  108. package/dist/tools/handlers/project.js +742 -1
  109. package/dist/tools/handlers/query.js +38 -2
  110. package/package.json +2 -2
@@ -155,6 +155,71 @@ const R_P_07 = {
155
155
  return { ...R_P_07.rule, evidence: "uses_signer_for_provenance=true (informational only)" };
156
156
  },
157
157
  };
158
+ const R_P_08 = {
159
+ rule: {
160
+ id: "R-PAYMENT-08",
161
+ level: "MEDIUM",
162
+ category: "semantic",
163
+ title: "Payment scene binding (for_object + for_guard + index) — anti-reuse for exception branches",
164
+ description: "PaymentInfo supports for_object (binds to specific Order), for_guard (binds to specific Guard), " +
165
+ "and index (binds to specific Progress step) — payment.move#L66-71. When all three are set via " +
166
+ "payment_info_with_guard (payment.move#L82-86), the Payment is scene-bound: it can ONLY be used " +
167
+ "in the specific order + guard + progress context. This is the anti-reuse design for exception " +
168
+ "branch compensation (e.g., delivery delay >30min triggers auto-compensation). " +
169
+ "Payment is immutable (freeze_object, payment.move#L160) — binding cannot be altered. " +
170
+ "VERIFIER-EVIDENCE DESIGN: customer submits Payment, Guard verifies binding fields match current context.",
171
+ affected_stakeholders: ["signer", "recipient", "consumer"],
172
+ scenario: "Treasury creates compensation Payment with PaymentInfo(for_object=order, for_guard=exception_guard, index=current_progress) for delivery delay",
173
+ mitigation: "Use payment_info_with_guard for all exception branch Payments. Ensure for_object, for_guard, and index " +
174
+ "all match the intended context. Use tpl_payment_exception_compensation (guard-templates.ts) as design template.",
175
+ auto_fixable: false,
176
+ },
177
+ check: (ctx) => {
178
+ if (!ctx.uses_scene_binding)
179
+ return null;
180
+ const missing = [];
181
+ if (!ctx.has_for_object)
182
+ missing.push("for_object not set (Order binding missing)");
183
+ if (!ctx.has_for_guard)
184
+ missing.push("for_guard not set (Guard binding missing)");
185
+ if (!ctx.has_index)
186
+ missing.push("index not set (Progress step binding missing)");
187
+ if (missing.length === 0)
188
+ return null;
189
+ return { ...R_P_08.rule, evidence: `incomplete scene binding: ${missing.join(", ")}` };
190
+ },
191
+ };
192
+ const R_P_09 = {
193
+ rule: {
194
+ id: "R-PAYMENT-09",
195
+ level: "LOW",
196
+ category: "semantic",
197
+ title: "PaymentInfo variant selection — use payment_info_with_guard for exception branches",
198
+ description: "PaymentInfo has 4 constructor variants (payment.move#L66-86): " +
199
+ "payment_info (for_object+remark+index, no for_guard), " +
200
+ "payment_info2 (remark+index, no for_object/for_guard), " +
201
+ "payment_info_with_guard (for_object+for_guard+remark+index — FULL binding), " +
202
+ "payment_info2_with_guard (for_guard+remark+index, no for_object). " +
203
+ "For exception branch compensation, ALWAYS use payment_info_with_guard to get full scene binding. " +
204
+ "Using payment_info (without for_guard) or payment_info2 (without for_object) weakens anti-reuse protection.",
205
+ affected_stakeholders: ["signer", "consumer"],
206
+ scenario: "Caller uses payment_info instead of payment_info_with_guard for exception compensation; for_guard is lost",
207
+ mitigation: "For exception branch Payments: always use payment_info_with_guard(for_object, for_guard, remark, index). " +
208
+ "For simple Payments without scene binding: payment_info or payment_info2 is fine. " +
209
+ "SDK should auto-select the variant based on which fields are provided.",
210
+ auto_fixable: true,
211
+ },
212
+ check: (ctx) => {
213
+ if (!ctx.uses_scene_binding)
214
+ return null;
215
+ if (ctx.payment_info_variant === "payment_info_with_guard")
216
+ return null;
217
+ return {
218
+ ...R_P_09.rule,
219
+ evidence: `uses_scene_binding=true but variant=${ctx.payment_info_variant ?? "unknown"} (should be payment_info_with_guard)`,
220
+ };
221
+ },
222
+ };
158
223
  export const PAYMENT_RISK_RULES = [
159
224
  R_P_01,
160
225
  R_P_02,
@@ -163,6 +228,8 @@ export const PAYMENT_RISK_RULES = [
163
228
  R_P_05,
164
229
  R_P_06,
165
230
  R_P_07,
231
+ R_P_08,
232
+ R_P_09,
166
233
  ];
167
234
  export const PAYMENT_RISK_VERSION = "1.0.0";
168
235
  export function checkPaymentRisks(ctx) {
@@ -25,6 +25,10 @@ export interface RepositoryOpCheckInput {
25
25
  reward_count?: number;
26
26
  is_data_remove_with_passport?: boolean;
27
27
  description?: string;
28
+ has_quote_guard?: boolean;
29
+ quote_guard_is_depended?: boolean;
30
+ quote_guard_verifies_payment?: boolean;
31
+ has_owner_receive?: boolean;
28
32
  }
29
33
  export declare function preCheckRepositoryOp(input: RepositoryOpCheckInput): RepositoryConfirmItem[];
30
34
  export declare function canProceedRepositoryOp(input: RepositoryOpCheckInput): {
@@ -196,6 +196,48 @@ function checkIdFromString(input) {
196
196
  fix_hint: "Use 0/1/2, or 'None'/'Clock'/'Signer' (case-insensitive).",
197
197
  };
198
198
  }
199
+ function checkQuoteGuardIsDepended(input) {
200
+ if (!input.has_quote_guard) {
201
+ return { id: "C-REP-11", severity: "info", title: "quote_guard is_depended check", description: "Skipped: no quote_guard set.", passed: true };
202
+ }
203
+ const passed = input.quote_guard_is_depended === true;
204
+ return {
205
+ id: "C-REP-11",
206
+ severity: passed ? "info" : "block",
207
+ title: "quote_guard satisfies is_depended (immutable + rep=true + no relies)",
208
+ description: "When quote_guard is set, it MUST satisfy guard::is_depended (guard.move#L133-135): " +
209
+ "immutable=true, relies empty, rep=true. Move aborts with E_NEED_DEPENDENT_GUARD (repository.move#L422). " +
210
+ "VERIFIED: passport.rs#L545-612 — check_repository_quote_guard enforces this at query time. " +
211
+ "quote_guard is a RIGID verification requirement: any guard querying this Repository's data must satisfy it.",
212
+ passed,
213
+ evidence: passed ? "quote_guard is is_depended" : "quote_guard NOT is_depended (will abort)",
214
+ fix_hint: "Ensure the quote_guard Guard object has: immutable=true, relies=empty, rep=true.",
215
+ };
216
+ }
217
+ function checkQuoteGuardSubscriptionDesign(input) {
218
+ if (!input.has_quote_guard) {
219
+ return { id: "C-REP-12", severity: "info", title: "quote_guard subscription design check", description: "Skipped: no quote_guard set.", passed: true };
220
+ }
221
+ const issues = [];
222
+ if (!input.quote_guard_verifies_payment)
223
+ issues.push("quote_guard does not verify Payment for subscription");
224
+ if (!input.has_owner_receive)
225
+ issues.push("Repository missing owner_receive for Payment revenue");
226
+ const passed = issues.length === 0;
227
+ return {
228
+ id: "C-REP-12",
229
+ severity: passed ? "info" : "warn",
230
+ title: "quote_guard data subscription design — Payment verification + owner_receive revenue",
231
+ description: "For data subscription pattern (Repository+quote_guard+Payment): " +
232
+ "(1) quote_guard should verify Payment (for_object matches Repository, amount meets subscription price); " +
233
+ "(2) Repository should have owner_receive<T> configured to accept Payment as subscription revenue " +
234
+ "(repository.move#L714-717). VERIFIED: passport.rs#L545-612. " +
235
+ "DESIGN: user submits Payment via Passport → quote_guard verifies → repository data query passes.",
236
+ passed,
237
+ evidence: passed ? "quote_guard subscription design complete" : issues.join("; "),
238
+ fix_hint: "Use tpl_repository_quote_guard_subscription (guard-templates.ts) as the design template.",
239
+ };
240
+ }
199
241
  export function preCheckRepositoryOp(input) {
200
242
  return [
201
243
  checkPolicyCount(input),
@@ -208,6 +250,8 @@ export function preCheckRepositoryOp(input) {
208
250
  checkRewardCount(input),
209
251
  checkDataRemoveWithPassportSubmission(input),
210
252
  checkIdFromString(input),
253
+ checkQuoteGuardIsDepended(input),
254
+ checkQuoteGuardSubscriptionDesign(input),
211
255
  ];
212
256
  }
213
257
  export function canProceedRepositoryOp(input) {
@@ -31,10 +31,16 @@ export interface RepositoryRiskCheckContext {
31
31
  constants_synced?: boolean;
32
32
  }
33
33
  declare function normalizeIdFrom(v: number | string): number;
34
+ export interface RepositoryQuoteGuardContext {
35
+ has_quote_guard?: boolean;
36
+ quote_guard_is_depended?: boolean;
37
+ quote_guard_verifies_payment?: boolean;
38
+ has_owner_receive?: boolean;
39
+ }
34
40
  export declare const REPOSITORY_RISK_RULES: {
35
41
  rule: RepositoryRisk;
36
- check: (ctx: RepositoryRiskCheckContext) => RepositoryRisk | null;
42
+ check: (ctx: RepositoryRiskCheckContext & RepositoryQuoteGuardContext) => RepositoryRisk | null;
37
43
  }[];
38
- export declare function checkRepositoryRisks(ctx: RepositoryRiskCheckContext): RepositoryRisk[];
44
+ export declare function checkRepositoryRisks(ctx: RepositoryRiskCheckContext & RepositoryQuoteGuardContext): RepositoryRisk[];
39
45
  export declare function getRepositoryRiskById(id: string): RepositoryRisk | undefined;
40
46
  export { normalizeIdFrom as parseIdFromForRiskCheck };
@@ -285,6 +285,65 @@ const R_REP_5_01 = {
285
285
  return { ...R_REP_5_01.rule, evidence: "constants_synced=false" };
286
286
  },
287
287
  };
288
+ const R_REP_6_01 = {
289
+ rule: {
290
+ id: "R-REP-11",
291
+ level: "HIGH",
292
+ category: "policy",
293
+ title: "quote_guard must be is_depended (immutable + rep=true + no relies) — Move assert",
294
+ description: "Repository policy's quote_guard must satisfy guard::is_depended (guard.move#L133-135): " +
295
+ "immutable=true, relies empty, rep=true. This ensures the quote_guard is a stable, " +
296
+ "repository-querying guard that can be depended upon. Move aborts with " +
297
+ "E_NEED_DEPENDENT_GUARD (repository.move#L422) if the guard is not is_depended. " +
298
+ "VERIFIED: passport.rs#L545-612 (check_repository_quote_guard enforces this at query time).",
299
+ affected_stakeholders: ["creator", "reader"],
300
+ scenario: "Creator sets quote_guard to a Guard that is not is_depended (e.g., has relies or is mutable)",
301
+ mitigation: "Ensure the quote_guard Guard object has: immutable=true, relies=empty, rep=true. " +
302
+ "Use pattern.repository_quote_guard_subscription as the design template.",
303
+ related_move_error: "E_NEED_DEPENDENT_GUARD",
304
+ auto_fixable: false,
305
+ },
306
+ check: (ctx) => {
307
+ if (!ctx.has_quote_guard)
308
+ return null;
309
+ if (ctx.quote_guard_is_depended)
310
+ return null;
311
+ return { ...R_REP_6_01.rule, evidence: "quote_guard set but not is_depended (immutable + rep=true + no relies)" };
312
+ },
313
+ };
314
+ const R_REP_6_02 = {
315
+ rule: {
316
+ id: "R-REP-12",
317
+ level: "MEDIUM",
318
+ category: "knowledge",
319
+ title: "quote_guard data subscription design — verify Payment verification + owner_receive revenue",
320
+ description: "When using quote_guard for data subscription (Repository+quote_guard+Payment pattern), " +
321
+ "ensure: (1) quote_guard verifies Payment fields (for_object matches Repository, amount meets price), " +
322
+ "(2) Repository has owner_receive<T> configured to accept Payment as subscription revenue " +
323
+ "(repository.move#L714-717). VERIFIED: passport.rs#L545-612, repository.move#L714-717. " +
324
+ "DESIGN: quote_guard is a RIGID verification requirement — any guard querying this Repository's " +
325
+ "data MUST satisfy the quote_guard (see R-X1-10 in guard-risk.ts).",
326
+ affected_stakeholders: ["creator", "reader", "verifier"],
327
+ scenario: "Creator sets quote_guard but does not configure Payment verification or owner_receive",
328
+ mitigation: "1) Ensure quote_guard verifies Payment (for_object, amount); " +
329
+ "2) Configure Repository owner_receive<T> to accept subscription Payment revenue; " +
330
+ "3) Use pattern.repository_quote_guard_subscription (guard-design-patterns.ts) and " +
331
+ "tpl_repository_quote_guard_subscription (guard-templates.ts) as design templates.",
332
+ auto_fixable: false,
333
+ },
334
+ check: (ctx) => {
335
+ if (!ctx.has_quote_guard)
336
+ return null;
337
+ if (ctx.quote_guard_verifies_payment && ctx.has_owner_receive)
338
+ return null;
339
+ const missing = [];
340
+ if (!ctx.quote_guard_verifies_payment)
341
+ missing.push("quote_guard does not verify Payment");
342
+ if (!ctx.has_owner_receive)
343
+ missing.push("Repository missing owner_receive for revenue");
344
+ return { ...R_REP_6_02.rule, evidence: missing.join("; ") };
345
+ },
346
+ };
288
347
  export const REPOSITORY_RISK_RULES = [
289
348
  R_REP_1_01,
290
349
  R_REP_2_01,
@@ -296,6 +355,8 @@ export const REPOSITORY_RISK_RULES = [
296
355
  R_REP_1_04,
297
356
  R_REP_1_05,
298
357
  R_REP_5_01,
358
+ R_REP_6_01,
359
+ R_REP_6_02,
299
360
  ];
300
361
  export function checkRepositoryRisks(ctx) {
301
362
  const risks = [];
@@ -329,6 +329,29 @@ export const REPOSITORY_CONSTRAINT_RULES = [
329
329
  failure_message: "Mode 5 routing missed if only id_from_submission is checked (P1-1 fix)",
330
330
  related_field: "policies[].write_guard",
331
331
  },
332
+ {
333
+ id: "REP_C_09",
334
+ name: "quote_guard must be is_depended (immutable + rep=true + no relies)",
335
+ description: "When quote_guard is set on a policy, it MUST satisfy guard::is_depended (guard.move#L133-135): " +
336
+ "immutable=true, relies empty, rep=true. Move aborts with E_NEED_DEPENDENT_GUARD (repository.move#L422). " +
337
+ "VERIFIED: passport.rs#L545-612 — check_repository_quote_guard enforces this when any guard queries " +
338
+ "this Repository's data (query 1167). quote_guard is a RIGID verification requirement.",
339
+ validation_logic: "quote_guard != null => guard.is_depended (immutable && relies.empty && rep)",
340
+ failure_message: "quote_guard must be is_depended — E_NEED_DEPENDENT_GUARD (repository.move#L422)",
341
+ related_field: "policies[].quote_guard",
342
+ },
343
+ {
344
+ id: "REP_C_10",
345
+ name: "quote_guard data subscription design (Payment verification + owner_receive)",
346
+ description: "For data subscription pattern: (1) quote_guard should verify Payment (for_object matches Repository, " +
347
+ "amount meets subscription price); (2) Repository should have owner_receive<T> configured to accept " +
348
+ "Payment as subscription revenue (repository.move#L714-717). " +
349
+ "DESIGN: user submits Payment via Passport → quote_guard verifies → impack_list updated → repository " +
350
+ "data query passes. 'On-chain data is consumed by guard verifiers.'",
351
+ validation_logic: "quote_guard != null => quote_guard_verifies_payment && repository_has_owner_receive",
352
+ failure_message: "quote_guard subscription incomplete: missing Payment verification or owner_receive revenue",
353
+ related_field: "policies[].quote_guard",
354
+ },
332
355
  ];
333
356
  function normalizeIdFrom(v) {
334
357
  if (typeof v === "number")
@@ -1,4 +1,4 @@
1
- export type RewardTemplateType = "first_order" | "referral" | "loyalty" | "flash_sale" | "bulk_discount" | "milestone" | "cashback";
1
+ export type RewardTemplateType = "first_order" | "referral" | "loyalty" | "flash_sale" | "bulk_discount" | "milestone" | "cashback" | "wonder_praise" | "wonder_feedback";
2
2
  export interface RewardTemplate {
3
3
  type: RewardTemplateType;
4
4
  name: string;
@@ -92,6 +92,68 @@ export const REWARD_TEMPLATES = [
92
92
  example: "Service reaches the 100-order milestone; the first 50 customers each receive 5 WOW extra reward.",
93
93
  relevantGuardOps: ["query", "repository_read"],
94
94
  },
95
+ {
96
+ type: "wonder_praise",
97
+ name: "Wonder-node praise reward (post-completion positive feedback)",
98
+ description: "Rewards customers who advance their order Progress to the 'wonder' node after normal completion — " +
99
+ "a user-driven positive-feedback mechanism. The machine design pattern is: " +
100
+ "place_order → booked → in_progress → completed → (wonder | no_wonder). " +
101
+ "After the order reaches 'completed' (terminal business state), the OrderHolder " +
102
+ "(namedOperator='') can advance Progress to 'wonder' (positive review) or 'no_wonder' " +
103
+ "(negative review). The Reward's claim_guard verifies Progress.current == 'wonder' " +
104
+ "AND order.service == this Service, so only satisfied customers can claim. " +
105
+ "This creates an on-chain reputation signal that benefits both the merchant " +
106
+ "(public proof of quality) and the customer (monetary reward for honest feedback).",
107
+ guardCondition: "Guard verifies: (1) Progress.current == 'wonder' (customer advanced to praise node), " +
108
+ "(2) Progress.task == order_address AND order.service == this Service, " +
109
+ "(3) Progress.machine == service.machine (snapshot match), " +
110
+ "(4) claimer is the order holder (order.holder == signer). " +
111
+ "Recommended Guard ops: query Progress object, query Order object, " +
112
+ "verify Progress.current field equals 'wonder'.",
113
+ amountRange: { min: "0.1WOW", max: "20WOW" },
114
+ allocationStrategy: "fixed",
115
+ parameters: [
116
+ { name: "amount", type: "string", description: "Reward amount per praise (e.g., '1WOW')", required: true },
117
+ { name: "budget", type: "string", description: "Total budget (e.g., '500WOW')", required: true },
118
+ { name: "expiration_time", type: "number", description: "Claim expiration timestamp (ms); 0 = no expiration", required: false },
119
+ { name: "max_claims_per_user", type: "number", description: "Max claims per user (default 1, prevents duplicate praise rewards)", required: false },
120
+ ],
121
+ example: "A photography service machine: place_order → booked → in_progress → completed → wonder. " +
122
+ "After delivery, the customer advances Progress to 'wonder' if satisfied. " +
123
+ "The Reward's Guard verifies Progress.current == 'wonder', and the customer claims 1 WOW. " +
124
+ "Merchant benefits from on-chain proof of customer satisfaction.",
125
+ relevantGuardOps: ["query", "progress_node_check"],
126
+ },
127
+ {
128
+ type: "wonder_feedback",
129
+ name: "Wonder-node feedback collection (covers wonder & no_wonder)",
130
+ description: "A feedback-collection Reward that pays a small amount for EITHER positive (wonder) OR " +
131
+ "negative (no_wonder) feedback, encouraging customers to leave honest reviews. " +
132
+ "The machine design pattern is the same as wonder_praise: " +
133
+ "place_order → booked → in_progress → completed → (wonder | no_wonder). " +
134
+ "The Reward's claim_guard verifies Progress.current ∈ {'wonder', 'no_wonder'} — both nodes " +
135
+ "trigger the reward. This is useful for merchants who want to gather feedback signal " +
136
+ "regardless of sentiment, e.g., for product improvement or public reputation metrics. " +
137
+ "Pair with a Repository that records the feedback node for historical analysis.",
138
+ guardCondition: "Guard verifies: (1) Progress.current ∈ {'wonder', 'no_wonder'}, " +
139
+ "(2) Progress.task == order_address AND order.service == this Service, " +
140
+ "(3) claimer is the order holder. " +
141
+ "The Guard should query the Progress object and check that current node is one of the " +
142
+ "two feedback nodes. Optional: write the feedback node to a Repository for analytics.",
143
+ amountRange: { min: "0.05WOW", max: "5WOW" },
144
+ allocationStrategy: "fixed",
145
+ parameters: [
146
+ { name: "amount", type: "string", description: "Reward amount per feedback (e.g., '0.5WOW')", required: true },
147
+ { name: "budget", type: "string", description: "Total budget (e.g., '200WOW')", required: true },
148
+ { name: "feedback_nodes", type: "string", description: "Comma-separated list of feedback node names (default: 'wonder,no_wonder')", required: false },
149
+ { name: "expiration_time", type: "number", description: "Claim expiration timestamp (ms); 0 = no expiration", required: false },
150
+ ],
151
+ example: "A freelance design service: place_order → ... → completed → (wonder | no_wonder). " +
152
+ "Customer advances to 'wonder' (liked the work) or 'no_wonder' (didn't like it). " +
153
+ "Both trigger a 0.5 WOW feedback reward. Merchant tracks the wonder/no_wonder ratio " +
154
+ "in a Repository to identify quality issues and improve service.",
155
+ relevantGuardOps: ["query", "progress_node_check", "repository_write"],
156
+ },
95
157
  ];
96
158
  const TEMPLATE_INDEX = new Map(REWARD_TEMPLATES.map((t) => [t.type, t]));
97
159
  export function getRewardTemplate(type) {
@@ -102,22 +164,32 @@ export function listRewardTemplates() {
102
164
  }
103
165
  export function suggestRewardTemplate(intent) {
104
166
  const lower = intent.toLowerCase();
167
+ if (lower.includes("wonder") || lower.includes("praise") || lower.includes("thumbs_up")
168
+ || lower.includes("好评") || lower.includes("positive review")
169
+ || lower.includes("satisfaction reward")) {
170
+ return getRewardTemplate("wonder_praise");
171
+ }
172
+ if (lower.includes("feedback") || lower.includes("review collection")
173
+ || lower.includes("no_wonder") || lower.includes("thumbs_down")
174
+ || lower.includes("差评") || lower.includes("both sentiment")) {
175
+ return getRewardTemplate("wonder_feedback");
176
+ }
105
177
  if (lower.includes("first order") || lower.includes("new") || lower.includes("first")) {
106
178
  return getRewardTemplate("first_order");
107
179
  }
108
- if (lower.includes("referral") || lower.includes("viral") || lower.includes("referral")) {
180
+ if (lower.includes("referral") || lower.includes("viral")) {
109
181
  return getRewardTemplate("referral");
110
182
  }
111
- if (lower.includes("repeat") || lower.includes("loyalty") || lower.includes("loyalty")) {
183
+ if (lower.includes("repeat") || lower.includes("loyalty")) {
112
184
  return getRewardTemplate("loyalty");
113
185
  }
114
- if (lower.includes("limited-time") || lower.includes("flash") || lower.includes("flash")) {
186
+ if (lower.includes("limited-time") || lower.includes("flash")) {
115
187
  return getRewardTemplate("flash_sale");
116
188
  }
117
- if (lower.includes("cashback") || lower.includes("cashback")) {
189
+ if (lower.includes("cashback")) {
118
190
  return getRewardTemplate("cashback");
119
191
  }
120
- if (lower.includes("milestone") || lower.includes("milestone")) {
192
+ if (lower.includes("milestone")) {
121
193
  return getRewardTemplate("milestone");
122
194
  }
123
195
  return undefined;
@@ -13,7 +13,7 @@ export const SCENARIO_MODES = [
13
13
  multi_tier_allocation: false,
14
14
  },
15
15
  machine_shape: [
16
- { name: "ordered", role: "Customer places order, payment escrowed" },
16
+ { name: "paid", role: "Entry: order created and paid via Service.buy(); Machine starts here" },
17
17
  { name: "delivering", role: "Provider submits deliverable (WIP hash)" },
18
18
  { name: "delivered", role: "Deliverable available for review" },
19
19
  { name: "accepted", role: "Customer signs acceptance" },
@@ -27,6 +27,7 @@ export const SCENARIO_MODES = [
27
27
  { template_id: "accept_guard_signer", host: "machine", purpose: "Only customer can sign acceptance" },
28
28
  { template_id: "withdraw_guard_permission", host: "machine", purpose: "Only provider can withdraw after acceptance" },
29
29
  { template_id: "refund_guard_signer", host: "machine", purpose: "Only customer can initiate refund" },
30
+ { template_id: "tpl_payment_exception_compensation", host: "machine", purpose: "Delivery delay exception compensation via scene-bound Payment (§2.13)" },
30
31
  ],
31
32
  allocator: {
32
33
  recipient: "signer",
@@ -39,6 +40,7 @@ export const SCENARIO_MODES = [
39
40
  "Use Service `setting_locked_time` to lock rules for the engagement duration",
40
41
  "WIP hash on deliverable is mandatory — protects provider in disputes",
41
42
  "Acceptance gate is the trust pivot — both parties must agree on criteria",
43
+ "NEW: Payment exception compensation for delivery delays — provider Treasury auto-compensates customer (§2.13)",
42
44
  ],
43
45
  },
44
46
  {
@@ -55,7 +57,7 @@ export const SCENARIO_MODES = [
55
57
  multi_tier_allocation: false,
56
58
  },
57
59
  machine_shape: [
58
- { name: "reserved", role: "Customer reserves item, pays deposit + rent" },
60
+ { name: "deposit_paid", role: "Entry: deposit + rent paid via Service.buy(); Machine starts here" },
59
61
  { name: "handover_out", role: "Owner hands over item, records pre-rental WIP" },
60
62
  { name: "in_use", role: "Rental period active" },
61
63
  { name: "returned", role: "Customer returns item" },
@@ -69,6 +71,8 @@ export const SCENARIO_MODES = [
69
71
  { template_id: "inspect_guard_signer", host: "machine", purpose: "Only owner can submit inspection result" },
70
72
  { template_id: "refund_guard_permission", host: "machine", purpose: "Refund requires owner permission" },
71
73
  { template_id: "damage_guard_wip", host: "machine", purpose: "Damage claim requires pre+post WIP comparison" },
74
+ { template_id: "tpl_payment_exception_compensation", host: "machine", purpose: "Return delay/damage exception compensation via scene-bound Payment (§2.13)" },
75
+ { template_id: "tpl_repository_quote_guard_subscription", host: "repository", purpose: "Weather/usage data oracle subscription (§2.11)" },
72
76
  ],
73
77
  allocator: {
74
78
  recipient: "entity",
@@ -81,6 +85,8 @@ export const SCENARIO_MODES = [
81
85
  "Pre-rental WIP is non-negotiable — without it, damage claims fail",
82
86
  "Deposit must be escrowed, not direct-transferred — enables fair deduction",
83
87
  "Inspection gate prevents customer from denying damage",
88
+ "NEW: Payment exception compensation for return delays — Treasury withdraws scene-bound Payment (§2.13)",
89
+ "NEW: Repository quote_guard for weather/usage data subscription revenue (§2.11)",
84
90
  ],
85
91
  },
86
92
  {
@@ -97,7 +103,7 @@ export const SCENARIO_MODES = [
97
103
  multi_tier_allocation: false,
98
104
  },
99
105
  machine_shape: [
100
- { name: "enrolled", role: "Student enrolls, pays tuition" },
106
+ { name: "paid", role: "Entry: enrollment and tuition paid via Service.buy(); Machine starts here" },
101
107
  { name: "session_N", role: "Per-session attendance (1..N)" },
102
108
  { name: "completed", role: "All sessions delivered" },
103
109
  { name: "refunded", role: "Institution-approved refund" },
@@ -105,6 +111,7 @@ export const SCENARIO_MODES = [
105
111
  guards: [
106
112
  { template_id: "attendance_guard_signer", host: "machine", purpose: "Per-session student attendance signature" },
107
113
  { template_id: "refund_guard_permission", host: "machine", purpose: "Institution approval OR arbiter for refund" },
114
+ { template_id: "tpl_buy_guard_order_holder", host: "service", purpose: "Course module progressive unlock via supply chain sub-orders (§2.12)" },
108
115
  ],
109
116
  allocator: {
110
117
  recipient: "entity",
@@ -117,6 +124,8 @@ export const SCENARIO_MODES = [
117
124
  "Use Service `setting_locked_time` to lock rules mid-semester (regulatory compliance)",
118
125
  "Attendance Guard needs WIP hash for session content commitment",
119
126
  "Per-session release requires threshold-based trigger",
127
+ "NEW: Supply chain sub-orders for course module progressive unlock — each module = sub-service with buy_guard verifying previous module completion (§2.12)",
128
+ "NEW: Repository for learning progress collaboration data — progress as key, session data as value (§2.10)",
120
129
  ],
121
130
  },
122
131
  {
@@ -133,7 +142,7 @@ export const SCENARIO_MODES = [
133
142
  multi_tier_allocation: true,
134
143
  },
135
144
  machine_shape: [
136
- { name: "ordered", role: "Customer books tour, pays deposit + final" },
145
+ { name: "paid", role: "Entry: tour booked and paid (deposit + final) via Service.buy(); Machine starts here" },
137
146
  { name: "segment_D1", role: "Segment 1 (e.g., hotel check-in)" },
138
147
  { name: "segment_D2", role: "Segment 2 (e.g., guided tour)" },
139
148
  { name: "returned", role: "Trip completed, customer returns" },
@@ -143,6 +152,9 @@ export const SCENARIO_MODES = [
143
152
  guards: [
144
153
  { template_id: "segment_guard_wip", host: "machine", purpose: "Per-segment arrival WIP (hotel check-in, etc.)" },
145
154
  { template_id: "refund_guard_permission", host: "machine", purpose: "Agency approval OR arbiter for trip interruption" },
155
+ { template_id: "tpl_buy_guard_order_holder", host: "service", purpose: "Supply chain sub-orders for tour package segments (§2.12)" },
156
+ { template_id: "tpl_payment_exception_compensation", host: "machine", purpose: "Trip delay/segment change exception compensation (§2.13)" },
157
+ { template_id: "tpl_repository_quote_guard_subscription", host: "repository", purpose: "Weather/travel data oracle subscription (§2.11)" },
146
158
  ],
147
159
  allocator: {
148
160
  recipient: "entity",
@@ -155,6 +167,9 @@ export const SCENARIO_MODES = [
155
167
  "Multi-tier Allocation is WoWok's unique advantage over traditional travel platforms",
156
168
  "segment_guard needs standardized WIP templates per segment type (hotel, transport, activity)",
157
169
  "Multi-tier waterfall needs guard chaining validation",
170
+ "NEW: Supply chain sub-orders — each tour segment = sub-service with buy_guard verifying main tour order (§2.12)",
171
+ "NEW: Payment exception compensation for flight/segment delays (§2.13)",
172
+ "NEW: Repository quote_guard for weather/travel data subscription revenue (§2.11)",
158
173
  ],
159
174
  },
160
175
  {
@@ -171,7 +186,7 @@ export const SCENARIO_MODES = [
171
186
  multi_tier_allocation: false,
172
187
  },
173
188
  machine_shape: [
174
- { name: "subscribed", role: "Subscriber signs up" },
189
+ { name: "paid", role: "Entry: subscription paid and active via Service.buy(); Machine starts here" },
175
190
  { name: "charge_period_N", role: "Periodic charge (1..N)" },
176
191
  { name: "deliver_period_N", role: "Per-period delivery" },
177
192
  { name: "cancelled", role: "Subscriber cancels — takes effect next period" },
@@ -181,6 +196,7 @@ export const SCENARIO_MODES = [
181
196
  { template_id: "charge_guard_signer", host: "machine", purpose: "User confirms each charge — no auto-renew trap" },
182
197
  { template_id: "cancel_guard_signer", host: "machine", purpose: "User cancels anytime, next-period effective" },
183
198
  { template_id: "deliver_guard_wip", host: "machine", purpose: "Creator WIP hash per period — prevents content abandonment" },
199
+ { template_id: "tpl_repository_quote_guard_subscription", host: "repository", purpose: "Creator publishes paid data (analytics, market data) with quote_guard subscription (§2.11)" },
184
200
  ],
185
201
  allocator: {
186
202
  recipient: "entity",
@@ -193,6 +209,7 @@ export const SCENARIO_MODES = [
193
209
  "Pure digital — native WoWok soil",
194
210
  "charge_guard needs periodic trigger (off-chain scheduler + on-chain Guard)",
195
211
  "Targets indie creators, niche SaaS, paid newsletters",
212
+ "NEW: Repository quote_guard for creator data subscription revenue — creators publish paid data, users pay to access (§2.11)",
196
213
  ],
197
214
  },
198
215
  {
@@ -369,6 +369,44 @@ export const SERVICE_TEMPLATES = [
369
369
  "Sales can still be updated post-publish (only allocator is locked)",
370
370
  ],
371
371
  },
372
+ {
373
+ id: "T-S-09",
374
+ name: "Supply Chain Sub-order Service (milestone unlock via buy_guard)",
375
+ description: "Sub-service whose buy_guard verifies the user purchased the main service order. Each milestone = one sub-order. Enables supply chain composition: main service → multiple sub-services with conditional access.",
376
+ applicable_scenes: ["service_buy_guard"],
377
+ industry_tags: ["travel", "rental", "education", "freelance", "ecommerce", "supply_chain"],
378
+ params: [
379
+ { name: "owner_address", type: "address", description: "Sub-service owner address", required: true },
380
+ { name: "permission_address", type: "address", description: "Permission object address", required: true },
381
+ { name: "description", type: "string", description: "Sub-service description (e.g., 'Hotel booking for tour package X')", required: true },
382
+ { name: "main_service_address", type: "address", description: "Main Service object address (the parent service)", required: true },
383
+ { name: "buy_guard_address", type: "address", description: "Guard address verifying main order ownership (order.owner==Signer AND order.service==main_service)", required: true },
384
+ { name: "price", type: "number", description: "Sub-service price", required: true },
385
+ { name: "machine_address", type: "address", description: "Machine object for sub-order workflow", required: true },
386
+ ],
387
+ body: (p) => ({
388
+ object: null,
389
+ description: p.description,
390
+ service_type: "supply_chain_sub",
391
+ buy_guard: p.buy_guard_address,
392
+ price: p.price,
393
+ machine: p.machine_address,
394
+ permission: p.permission_address,
395
+ }),
396
+ notes: [
397
+ "VERIFIED: service.move#L173 (buy_guard: Option<address>), L263-268 (buy_with_passport evaluates buy_guard)",
398
+ "VERIFIER-EVIDENCE DESIGN: user submits main Order as evidence (b_submission=true), buy_guard verifies order.owner==Signer AND order.service==main_service_address",
399
+ "No parent_order field needed — relationship verified via buy_guard querying submitted Order fields",
400
+ "Each milestone = one sub-order with its own Service + buy_guard + Machine",
401
+ "Main flow Machine can branch to different sub-services based on node progression",
402
+ "Use tpl_buy_guard_order_holder (guard-templates.ts) for the buy_guard design",
403
+ ],
404
+ post_publish_considerations: [
405
+ "buy_guard is mutable post-publish (can update the guard address)",
406
+ "If main service is unpublished, sub-service buy_guard will fail (order.service won't match)",
407
+ "Consider publishing main service before sub-services",
408
+ ],
409
+ },
372
410
  ];
373
411
  export const SERVICE_TEMPLATES_VERSION = "1.0.0";
374
412
  export function getAllServiceTemplates() {
@@ -272,6 +272,48 @@ export const TREASURY_TEMPLATES = [
272
272
  "Suitable for fee sinks, donation pools, or auto-forwarding revenue",
273
273
  ],
274
274
  },
275
+ {
276
+ id: "T-T-07",
277
+ name: "Exception Compensation Treasury (scene-bound Payment withdraw)",
278
+ description: "Treasury for exception branch compensation: withdraws create scene-bound Payments with for_object + for_guard + index binding. Enables auto-compensation for delays, defects, or service exceptions.",
279
+ applicable_scenes: ["treasury_fund_collection", "treasury_um_delegation"],
280
+ industry_tags: ["retail", "travel", "rental", "freelance", "ecommerce"],
281
+ params: [
282
+ { name: "treasury_name", type: "string", description: "Name for the new Treasury object", required: true },
283
+ { name: "owner_address", type: "address", description: "Owner address (service provider, becomes admin)", required: true },
284
+ { name: "coin_type", type: "coin_type", description: "Coin type T (e.g. 0x2::wow::WOW)", required: true },
285
+ { name: "description", type: "string", description: "Treasury description (e.g., 'Compensation fund for delivery delays')", required: true },
286
+ { name: "permission_name", type: "string", description: "Name for the new Permission object", required: true },
287
+ { name: "withdrawer_address", type: "address", description: "Address authorized to withdraw compensations (can be same as owner)", required: true },
288
+ { name: "external_withdraw_guard", type: "address", description: "Guard address for external_withdraw (verifies exception conditions + Payment binding)", required: true },
289
+ ],
290
+ body: (p) => ({
291
+ object: {
292
+ name: p.treasury_name,
293
+ type_parameter: p.coin_type,
294
+ permission: {
295
+ name: p.permission_name,
296
+ description: `Permission for ${p.treasury_name}`,
297
+ indexes: [
298
+ { index: 253, name: "TREASURY_DEPOSIT", mark: p.owner_address, description: "Owner deposits funds" },
299
+ { index: 254, name: "TREASURY_WITHDRAW", mark: p.withdrawer_address, description: "Withdraw for exception compensation (creates scene-bound Payment)" },
300
+ { index: 256, name: "TREASURY_EXTERNAL_WITHDRAW", mark: p.withdrawer_address, description: "External withdraw with guard (verifies exception + Payment binding)" },
301
+ { index: 257, name: "TREASURY_OWNER_RECEIVE", mark: p.owner_address, description: "Owner receives remaining funds" },
302
+ ],
303
+ },
304
+ },
305
+ description: p.description,
306
+ }),
307
+ notes: [
308
+ "VERIFIED: treasury.move#L249-264 (withdraw creates Payment via payment::new_singleton + from_object_set)",
309
+ "VERIFIED: treasury.move#L415-418 (withdraw<T> sends to recipient with PaymentInfo)",
310
+ "Payment created has PaymentInfo(for_object=order, for_guard=exception_guard, index=current_progress)",
311
+ "ANTI-REUSE: for_object + for_guard + index binds Payment to specific context (payment.move#L66-71)",
312
+ "VERIFIER-EVIDENCE: customer submits Payment via Passport, Guard verifies binding fields match",
313
+ "Use with tpl_payment_exception_compensation (guard-templates.ts) for the exception branch guard",
314
+ "Suitable for: delivery delay compensation, defect refund, service-level agreement penalties",
315
+ ],
316
+ },
275
317
  ];
276
318
  export const TREASURY_TEMPLATES_VERSION = "1.0.0";
277
319
  export function getAllTreasuryTemplates() {
@@ -1,6 +1,9 @@
1
1
  export interface ServiceTrustMetrics {
2
2
  arbitrationScore?: number;
3
3
  arbitrationCases?: number;
4
+ arbitrationVotingGuardCount?: number;
5
+ arbitrationFeeBalance?: bigint;
6
+ arbitrationPaused?: boolean;
4
7
  reviewStats?: {
5
8
  likes: number;
6
9
  dislikes: number;
@@ -11,6 +14,7 @@ export interface ServiceTrustMetrics {
11
14
  completedRate?: number;
12
15
  avgCompletionTime?: number;
13
16
  compensationFundBalance?: bigint;
17
+ typicalOrderAmount?: bigint;
14
18
  hasPublishedEvents?: boolean;
15
19
  hasMachineBound?: boolean;
16
20
  hasBuyGuard?: boolean;