@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
@@ -208,6 +208,15 @@ export { BRIDGE_RISK_RULES, BRIDGE_RISK_VERSION, checkBridgeRisks, getBridgeRisk
208
208
  export { TOOLS_REFERENCE, getToolReference, searchToolReference, getToolSequence, };
209
209
  export { SCENARIO_MODES, SCENARIO_MODES_VERSION, MODE_COMPOSITIONS, matchScenarioMode, inferScenarioTraits, getScenarioMode, listScenarioModes, getShippedModes, getModeCompositions, };
210
210
  export { GUARD_DESIGN_PATTERNS, GUARD_DESIGN_PATTERNS_VERSION, VERIFIER_LEVEL_GUIDANCE, getGuardDesignPattern, searchGuardDesignPatterns, getPatternsByHost, getPatternsByIndustry, getPatternsByDataSourceClass, getVerifierLevelGuidance, suggestPatternForRequirement, };
211
+ import { loadOverrides as loadOverridesFromDisk } from "./overrides-loader.js";
212
+ let KNOWLEDGE_OVERRIDES = loadOverridesFromDisk();
213
+ export function getKnowledgeOverrides() {
214
+ return KNOWLEDGE_OVERRIDES;
215
+ }
216
+ export function refreshKnowledgeOverrides() {
217
+ KNOWLEDGE_OVERRIDES = loadOverridesFromDisk(true);
218
+ return KNOWLEDGE_OVERRIDES;
219
+ }
211
220
  export function getKnowledgeBase() {
212
221
  return {
213
222
  version: {
@@ -8,7 +8,7 @@ import { type ChecklistResult } from "./machine-confirm.js";
8
8
  import { type GuardScene } from "./guard-ledger.js";
9
9
  export declare const MACHINE_CONTEXT_VERSION = "1.0.0";
10
10
  export interface VerificationNote {
11
- topic: "bReplace" | "um" | "consensus_repositories" | "namedOperator_assignment" | "cross_machine_dependency";
11
+ topic: "bReplace" | "um" | "consensus_repositories" | "namedOperator_assignment" | "cross_machine_dependency" | "first_node_semantics_service_bound";
12
12
  judgment: "YES" | "PARTIAL" | "NO";
13
13
  verified_semantic: string;
14
14
  code_reference: string;
@@ -52,6 +52,23 @@ export const MACHINE_VERIFICATION_NOTES = [
52
52
  code_reference: "progress.move (progress::new, assert_published) + guard.move (convert_witness)",
53
53
  affected_modes: ["cross_machine", "pre_publish_check"],
54
54
  },
55
+ {
56
+ topic: "first_node_semantics_service_bound",
57
+ judgment: "YES",
58
+ verified_semantic: "For Service-bound Machines, the entry node (prev_node='' target) represents a " +
59
+ "POST-PAYMENT state, because Service.buy() performs quote + buy (payment) + " +
60
+ "order_allocation + order_progress ATOMICALLY in a single transaction. The Machine " +
61
+ "must NOT include separate 'Order', 'Pay', 'Reserve', or 'Subscribe' nodes — those " +
62
+ "actions are handled by the Service layer before the Progress (Machine instance) " +
63
+ "is created. All nodes after entry represent ORDER PROCESSING stages (fulfillment, " +
64
+ "delivery, confirmation, review, refund), NOT payment actions. Correct entry node " +
65
+ "examples: 'Paid', 'DepositPaid', 'Active'. Incorrect: 'OrderCreated', 'Reserved', " +
66
+ "'Subscribed'. See machine-ledger.ts first_node_semantics field per scene and " +
67
+ "machine-templates.ts example_nodes/example_pairs for the canonical structure.",
68
+ code_reference: "ts-sdk\\packages\\wowok\\src\\w\\call\\service.ts (buy: quote -> buy -> order_allocation -> order_progress) " +
69
+ "+ machine-ledger.ts (first_node_semantics field) + machine-templates.ts (example_nodes)",
70
+ affected_modes: ["initial_design", "mid_design_review", "pre_publish_check"],
71
+ },
55
72
  ];
56
73
  export function getMachineKnowledgeSnapshot() {
57
74
  const verifiedYes = MACHINE_VERIFICATION_NOTES.filter((n) => n.judgment === "YES").length;
@@ -632,7 +649,11 @@ function buildPromptHints(ctx) {
632
649
  hints.push("Start by confirming the matched scene and selecting a template.");
633
650
  if (ctx.matched_scene) {
634
651
  hints.push(`Scene "${ctx.matched_scene.name}" recommends patterns: ${ctx.matched_scene.recommended_patterns.join(", ")}.`);
652
+ if (ctx.matched_scene.first_node_semantics) {
653
+ hints.push(`First-node semantics: ${ctx.matched_scene.first_node_semantics}`);
654
+ }
635
655
  }
656
+ hints.push("⚠ First node convention: For Service-bound Machines, the entry node (prev_node='' target) MUST represent a POST-PAYMENT state (e.g. 'Paid', 'DepositPaid'). Do NOT add 'Order'/'Pay'/'Reserve'/'Subscribe' nodes — Service.buy() handles payment atomically before Progress is created.");
636
657
  if (ctx.suggested_templates.length > 0) {
637
658
  hints.push(`Top template suggestion: ${ctx.suggested_templates[0].id} (${ctx.suggested_templates[0].name}).`);
638
659
  }
@@ -19,6 +19,7 @@ export interface MachineScene {
19
19
  guard_requirements: GuardRequirement[];
20
20
  allocation_integration: string;
21
21
  special_constraints: string[];
22
+ first_node_semantics: string;
22
23
  mutable_after_publish: boolean;
23
24
  m_rounds_focus: string[];
24
25
  }
@@ -3,22 +3,25 @@ export const MACHINE_SCENES = [
3
3
  id: "ecommerce_standard",
4
4
  name: "Standard E-commerce Flow",
5
5
  industry: ["ecommerce"],
6
- scenario: "Order → Pay → Ship → Receive → Complete",
6
+ scenario: "Paid (entry) → Ship → Receive → Complete",
7
7
  participants: [
8
- { role: "customer", permission_type: "OrderHolder", involved_in: ["Order", "Receive"] },
8
+ { role: "customer", permission_type: "OrderHolder", involved_in: ["Receive"] },
9
9
  { role: "merchant", permission_type: "Permission", involved_in: ["Ship"] },
10
10
  ],
11
11
  recommended_patterns: ["P-M-SEQ"],
12
12
  recommended_topology: ["P-M-LINEAR"],
13
13
  guard_requirements: [
14
- { forward: "Ship", scene: "machine_forward_guard", purpose: "Verify payment completion" },
14
+ { forward: "Ship", scene: "machine_forward_guard", purpose: "Verify order is paid (post-buy state)" },
15
15
  { forward: "Receive", scene: "machine_forward_guard", purpose: "Verify identity" },
16
16
  ],
17
17
  allocation_integration: "Complete node -> Allocator distributes funds to merchant",
18
18
  special_constraints: [
19
- "Payment must complete before shipping (Guard verifies order.amount is paid)",
19
+ "First node 'Paid' represents post-payment state — buy() completes payment atomically before Progress is created",
20
+ "No separate 'Order' or 'Pay' nodes needed — payment is handled by Service.buy(), not Machine",
21
+ "All nodes after entry represent order processing (ship, receive, complete), NOT payment actions",
20
22
  "Receipt auto-triggers fund allocation",
21
23
  ],
24
+ first_node_semantics: "Paid — order has been created and paid via Service.buy(); Machine starts at post-payment state",
22
25
  mutable_after_publish: false,
23
26
  m_rounds_focus: ["M1", "M2", "M3", "M5", "M8"],
24
27
  },
@@ -26,24 +29,26 @@ export const MACHINE_SCENES = [
26
29
  id: "ecommerce_with_exceptions",
27
30
  name: "E-commerce Flow with Exception Branches",
28
31
  industry: ["ecommerce"],
29
- scenario: "Order → Pay → Ship → {Receive → Complete | Lost → Arbitration | Return → Refund}",
32
+ scenario: "Paid (entry) → Ship → {Receive → Complete | Lost (terminal) | Return → Refund}",
30
33
  participants: [
31
- { role: "customer", permission_type: "OrderHolder", involved_in: ["Order", "Receive", "Return"] },
32
- { role: "merchant", permission_type: "Permission", involved_in: ["Ship", "Refund"] },
33
- { role: "arbitrator", permission_type: "NamedOperator", involved_in: ["Arbitration"] },
34
+ { role: "customer", permission_type: "OrderHolder", involved_in: ["Receive", "Return", "Lost"] },
35
+ { role: "merchant", permission_type: "Permission", involved_in: ["Ship", "Refund", "Lost"] },
34
36
  ],
35
37
  recommended_patterns: ["P-M-SEQ", "P-M-COMPETING"],
36
38
  recommended_topology: ["P-M-LINEAR", "P-M-COMPETING"],
37
39
  guard_requirements: [
38
40
  { forward: "Lost", scene: "machine_forward_guard", purpose: "Dual-sig to confirm lost" },
39
- { forward: "Arbitration", scene: "arbitration_usage_guard", purpose: "Verify arbitration eligibility" },
40
41
  ],
41
- allocation_integration: "Complete->merchant | Refund->customer | Arb->arbitrator",
42
+ allocation_integration: "Complete->merchant | Refund->customer | Lost->escrow or partial refund (Allocator only). Disputes are NOT modeled here — they flow through Order + Arbitration object off-Machine.",
42
43
  special_constraints: [
43
- "Lost node threshold=2 (customer + merchant dual-sig)",
44
- "Competing Pair: Receive vs Lost (first-wins)",
45
- "Arbitration flow independent of main flow",
44
+ "First node 'Paid' represents post-payment state — buy() completes payment atomically before Progress is created",
45
+ "No separate 'Order' or 'Pay' nodes needed — payment is handled by Service.buy(), not Machine",
46
+ "Lost node threshold=2 (customer + merchant dual-sig) — Lost is a TERMINAL node, not a path to arbitration",
47
+ "Competing Pair: Receive vs Lost vs Return (first-wins)",
48
+ "DISPUTE INDEPENDENCE: arbitration is NOT a Machine node. If a Lost-terminal order later needs dispute resolution, the customer files arbitration::dispute(order, arbitration) against the Arbitration object bound to the Service — completely off-Machine. Arbitrators live in Arbitration.voting_guard, never in Permission or NamedOperator.",
49
+ "Refund Allocation must use sharing.who=OrderHolder (refund to customer, NOT merchant)",
46
50
  ],
51
+ first_node_semantics: "Paid — order has been created and paid via Service.buy(); Machine starts at post-payment state",
47
52
  mutable_after_publish: false,
48
53
  m_rounds_focus: ["M1", "M2", "M3", "M5", "M6", "M8"],
49
54
  },
@@ -51,22 +56,25 @@ export const MACHINE_SCENES = [
51
56
  id: "rental_standard",
52
57
  name: "Equipment Rental Flow",
53
58
  industry: ["rental"],
54
- scenario: "Reserve → Pay Deposit → Pickup → In Use → Return → Refund Deposit",
59
+ scenario: "DepositPaid (entry) → Pickup → In Use → Return → Refund Deposit",
55
60
  participants: [
56
- { role: "customer", permission_type: "OrderHolder", involved_in: ["Reserve", "Pickup", "Return"] },
61
+ { role: "customer", permission_type: "OrderHolder", involved_in: ["Pickup", "Return"] },
57
62
  { role: "merchant", permission_type: "Permission", involved_in: ["Deliver", "Refund Deposit"] },
58
63
  ],
59
64
  recommended_patterns: ["P-M-SEQ"],
60
65
  recommended_topology: ["P-M-LINEAR"],
61
66
  guard_requirements: [
62
- { forward: "Pickup", scene: "machine_forward_guard", purpose: "Verify deposit paid" },
67
+ { forward: "Pickup", scene: "machine_forward_guard", purpose: "Verify deposit paid (post-buy state)" },
63
68
  { forward: "Return", scene: "machine_forward_guard", purpose: "Verify equipment condition" },
64
69
  ],
65
70
  allocation_integration: "Return complete -> deposit refund + rental fee allocation",
66
71
  special_constraints: [
72
+ "First node 'DepositPaid' represents post-payment state — buy() completes deposit payment atomically before Progress is created",
73
+ "No separate 'Reserve' or 'PayDeposit' nodes needed — reservation and payment are handled by Service.buy(), not Machine",
67
74
  "Deposit and rental fee separated (two Allocators)",
68
75
  "Equipment damage verified by Guard (retained_submission stores inspection report)",
69
76
  ],
77
+ first_node_semantics: "DepositPaid — deposit has been paid via Service.buy(); Machine starts at post-deposit state",
70
78
  mutable_after_publish: false,
71
79
  m_rounds_focus: ["M1", "M2", "M3", "M5", "M8"],
72
80
  },
@@ -90,6 +98,7 @@ export const MACHINE_SCENES = [
90
98
  "Customer Forward: namedOperator='' (OrderHolder)",
91
99
  "Merchant Forward: permissionIndex=2",
92
100
  ],
101
+ first_node_semantics: "Initiated — order has been created and paid via Service.buy(); Machine starts at post-payment state, awaiting dual-sig confirmation",
93
102
  mutable_after_publish: false,
94
103
  m_rounds_focus: ["M3", "M4", "M5"],
95
104
  },
@@ -113,6 +122,7 @@ export const MACHINE_SCENES = [
113
122
  "GuardIdentifier must be numeric type (extracts weight)",
114
123
  "Prevent double-voting (Guard queries arb.voted has)",
115
124
  ],
125
+ first_node_semantics: "VoteOpened — dispute has been submitted (order already paid via Service.buy()); Machine starts at post-payment dispute state",
116
126
  mutable_after_publish: false,
117
127
  m_rounds_focus: ["M3", "M4", "M5"],
118
128
  },
@@ -138,7 +148,9 @@ export const MACHINE_SCENES = [
138
148
  "Cross-Machine dependency is one-way (no cycles)",
139
149
  "Each Machine must be published independently",
140
150
  "Dependency verification: indirect via progress::new -> assert_published (see 06 §14.6)",
151
+ "Each Machine in the chain starts at a post-payment state (each link's Service.buy() handles payment independently)",
141
152
  ],
153
+ first_node_semantics: "UpstreamVerified — order has been paid via upstream Service.buy(); Machine starts at post-payment state, verifying upstream completion",
142
154
  mutable_after_publish: false,
143
155
  m_rounds_focus: ["M1", "M3", "M8"],
144
156
  },
@@ -163,7 +175,9 @@ export const MACHINE_SCENES = [
163
175
  "Proof MUST be generated by messenger.submitChainProof",
164
176
  "submitChainProof about_address = peerAddress (NOT sessionId)",
165
177
  "Guard table item name <64 BCS bytes (MAX_NAME_LENGTH=64)",
178
+ "First node represents post-payment state — payment is handled by Service.buy(), not Machine",
166
179
  ],
180
+ first_node_semantics: "Paid — order has been created and paid via Service.buy(); Machine starts at post-payment state, awaiting proof submission",
167
181
  mutable_after_publish: false,
168
182
  m_rounds_focus: ["M1", "M3", "M7"],
169
183
  },
@@ -187,42 +201,45 @@ export const MACHINE_SCENES = [
187
201
  "Uses query_reward_record_count == 0 for anti-reentry",
188
202
  "Reward object must be already created",
189
203
  ],
204
+ first_node_semantics: "Eligible — order has been created and paid via Service.buy(); Machine starts at post-payment state, customer is eligible to claim reward",
190
205
  mutable_after_publish: false,
191
206
  m_rounds_focus: ["M1", "M3", "M8"],
192
207
  },
193
208
  {
194
- id: "arbitration_flow",
195
- name: "Arbitration Flow",
196
- industry: ["ecommerce", "service", "rental"],
197
- scenario: "Dispute → Submit → Vote → Ruling → Execute",
209
+ id: "wonder_feedback",
210
+ name: "Wonder Feedback Flow (Post-Completion Rating)",
211
+ industry: ["ecommerce", "service", "rental", "subscription", "education"],
212
+ scenario: "Paid (entry) → ... → Completed → {Wonder | NoWonder} (rating terminals)",
198
213
  participants: [
199
- { role: "disputant", permission_type: "OrderHolder", involved_in: ["Submit Dispute"] },
200
- { role: "arbitrator", permission_type: "NamedOperator", involved_in: ["Vote"] },
201
- { role: "system", permission_type: "Permission", involved_in: ["Execute Ruling"] },
214
+ { role: "customer", permission_type: "OrderHolder", involved_in: ["Wonder", "NoWonder"] },
215
+ { role: "merchant", permission_type: "Permission", involved_in: ["Completed"] },
202
216
  ],
203
- recommended_patterns: ["P-M-VOTE", "P-M-SEQ"],
204
- recommended_topology: ["P-M-LINEAR"],
217
+ recommended_patterns: ["P-M-SEQ", "P-M-COMPETING"],
218
+ recommended_topology: ["P-M-LINEAR", "P-M-COMPETING"],
205
219
  guard_requirements: [
206
- { forward: "Submit Dispute", scene: "arbitration_usage_guard", purpose: "Verify dispute eligibility + prevent double-dispute" },
207
- { forward: "Vote", scene: "arbitration_voting_guard", purpose: "Verify voting eligibility + extract weight" },
220
+ { forward: "Praise", scene: "machine_forward_guard", purpose: "Verify Progress.current == 'Completed' (rating only after completion)" },
221
+ { forward: "Complain", scene: "machine_forward_guard", purpose: "Verify Progress.current == 'Completed' (rating only after completion)" },
208
222
  ],
209
- allocation_integration: "After ruling -> distribute funds according to ruling",
223
+ allocation_integration: "Completed -> merchant allocation (terminal); Wonder/NoWonder are reputation terminals — no fund allocation. Reward object (independent) claims fire when Progress.current == 'wonder'",
210
224
  special_constraints: [
211
- "Arbitration object must be already created",
212
- "Prevent double-dispute (R-X1-14 HIGH)",
213
- "Prevent double-vote (R-X1-14 CRITICAL)",
214
- "MAX_DISPUTE_COUNT=10 per order",
225
+ "Dispute MUST NOT be modeled as machine nodes — disputes flow through Order + Arbitration object, independent of this Machine",
226
+ "Wonder/NoWonder are POST-completion terminals: order is already settled when customer rates",
227
+ "Both Wonder and NoWonder forwards have named_operator='' (OrderHolder) — rating is a customer-only action",
228
+ "Reward object (if bound) MUST use a Guard verifying Progress.current == 'wonder' AND order.holder == signer — no Permission needed for reward claim",
229
+ "Competing Pair: Praise vs Complain (first-wins; one rating per order)",
230
+ "No dispute/refund/arbitration nodes in this Machine — those flows live off-Machine",
215
231
  ],
232
+ first_node_semantics: "Paid — order has been created and paid via Service.buy(); Machine starts at post-payment state, same as e-commerce baseline",
216
233
  mutable_after_publish: false,
217
- m_rounds_focus: ["M1", "M3", "M4", "M5", "M8"],
234
+ m_rounds_focus: ["M1", "M2", "M3", "M5", "M8"],
218
235
  },
219
236
  {
220
237
  id: "subscription",
221
238
  name: "Subscription / Membership Flow",
222
239
  industry: ["subscription", "service"],
223
- scenario: "Subscribe → Pay → Activate → [Renew | Expire] → Cancel/End",
240
+ scenario: "Paid (entry) → Activate → [Renew | Expire] → Cancel/End",
224
241
  participants: [
225
- { role: "subscriber", permission_type: "OrderHolder", involved_in: ["Subscribe", "Renew", "Cancel"] },
242
+ { role: "subscriber", permission_type: "OrderHolder", involved_in: ["Renew", "Cancel"] },
226
243
  { role: "provider", permission_type: "Permission", involved_in: ["Activate", "Pause"] },
227
244
  ],
228
245
  recommended_patterns: ["P-M-SEQ", "P-M-COMPETING"],
@@ -233,11 +250,14 @@ export const MACHINE_SCENES = [
233
250
  ],
234
251
  allocation_integration: "Renew -> fund allocation | Expire -> stop service",
235
252
  special_constraints: [
253
+ "First node 'Paid' represents post-payment state — buy() completes subscription payment atomically before Progress is created",
254
+ "No separate 'Subscribe' or 'Pay' nodes needed — subscription and payment are handled by Service.buy(), not Machine",
236
255
  "Time-lock: context(Clock) >= progress.entry_time + duration",
237
256
  "Competing Pair: Renew vs Expire (first-wins)",
238
257
  "Repository records subscription status",
239
258
  "Note: Machine.consensus_repositories is declarative-only and NOT auto-passed to Progress (see 06 §14.4)",
240
259
  ],
260
+ first_node_semantics: "Paid — subscription has been created and paid via Service.buy(); Machine starts at post-payment state, awaiting activation",
241
261
  mutable_after_publish: false,
242
262
  m_rounds_focus: ["M1", "M3", "M6", "M8"],
243
263
  },
@@ -261,8 +281,11 @@ export function inferSceneFromFlow(description) {
261
281
  if (lower.includes("supply chain") || lower.includes("cross-machine")) {
262
282
  return findScene("cross_machine_supply_chain");
263
283
  }
264
- if (lower.includes("arbitration") || lower.includes("dispute")) {
265
- return findScene("arbitration_flow");
284
+ if (lower.includes("wonder") || lower.includes("praise") || lower.includes("complain")
285
+ || lower.includes("thumbs_up") || lower.includes("thumbs_down")
286
+ || lower.includes("rating") || lower.includes("feedback")
287
+ || lower.includes("好评") || lower.includes("差评")) {
288
+ return findScene("wonder_feedback");
266
289
  }
267
290
  if (lower.includes("reward") || lower.includes("incentive")) {
268
291
  return findScene("reward_incentive");
@@ -109,6 +109,29 @@ export const MACHINE_RISK_RULES = [
109
109
  auto_fixable: false,
110
110
  related_constraint: "MC-C-04",
111
111
  },
112
+ {
113
+ id: "R-M1-11",
114
+ name: "Dispute anti-pattern — machine illegally models dispute flow",
115
+ category: "structural",
116
+ severity: "critical",
117
+ description: "Machine contains nodes named 'disputed', 'refunded', 'arb', 'arbitration', " +
118
+ "'dispute', or 'refund'. This is a CRITICAL design anti-pattern because " +
119
+ "dispute is INDEPENDENT of the machine workflow. Dispute flows through: " +
120
+ "Order → Arbitration.dispute() → Arb object → arbitration() ruling → " +
121
+ "arb_withdraw by order holder. Arbitrators are configured in " +
122
+ "Arbitration.voting_guard, NOT in Permission. Merchants who model " +
123
+ "dispute in the machine (e.g., 'disputed → refunded' forward guarded " +
124
+ "by Permission index 1500) create dead-end paths because no one has " +
125
+ "Permission 1500 — arbitrators are NOT Permission holders.",
126
+ detection: "Match node names against regex /^(disputed|refunded|arb|arbitration|dispute|refund)$/i",
127
+ recommendation: "Remove all dispute/refund nodes from the machine. Instead: (1) bind an " +
128
+ "Arbitration object to the Service via Service.arbitrations, (2) configure " +
129
+ "arbitrators via Arbitration.voting_guard_add, (3) deposit compensation_fund " +
130
+ "to the Service. Disputes are then filed via arbitration::dispute(order, " +
131
+ "arbitration) — completely independent of the machine workflow.",
132
+ auto_fixable: false,
133
+ related_constraint: "dispute_independence_principle",
134
+ },
112
135
  {
113
136
  id: "R-M2-01",
114
137
  name: "Guard not created",