@wowok/agent-mcp 2.7.1 → 2.7.2

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 (375) hide show
  1. package/dist/config/index.js +1 -1
  2. package/dist/config/runtime.js +1 -238
  3. package/dist/customer/customer-advice.js +1 -130
  4. package/dist/customer/index.js +1 -11
  5. package/dist/customer/industry-risks.js +1 -438
  6. package/dist/customer/info-puzzle.js +1 -681
  7. package/dist/customer/order-monitor.js +1 -328
  8. package/dist/customer/order-strategy.js +1 -373
  9. package/dist/customer/post-purchase.js +1 -351
  10. package/dist/customer/preorder-compare.js +1 -34
  11. package/dist/customer/reminder-system.js +1 -316
  12. package/dist/customer/risk-assessment.js +1 -397
  13. package/dist/customer/types.js +1 -13
  14. package/dist/customer/user-preferences.js +1 -460
  15. package/dist/evaluation/arbitration-game.d.ts +9 -2
  16. package/dist/evaluation/arbitration-game.js +1 -48
  17. package/dist/evaluation/builtins/demand-match.js +1 -153
  18. package/dist/evaluation/builtins/index.js +1 -10
  19. package/dist/evaluation/builtins/service-risk.js +1 -55
  20. package/dist/evaluation/capability.js +1 -13
  21. package/dist/evaluation/composer.js +1 -40
  22. package/dist/evaluation/engine.js +1 -175
  23. package/dist/evaluation/extract.js +1 -115
  24. package/dist/evaluation/game-strategy.d.ts +27 -0
  25. package/dist/evaluation/game-strategy.js +1 -0
  26. package/dist/evaluation/gap.js +1 -100
  27. package/dist/evaluation/index.d.ts +1 -0
  28. package/dist/evaluation/index.js +1 -11
  29. package/dist/evaluation/node-game.d.ts +31 -3
  30. package/dist/evaluation/node-game.js +1 -57
  31. package/dist/evaluation/region.js +1 -36
  32. package/dist/evaluation/types.d.ts +1 -0
  33. package/dist/evaluation/types.js +1 -1
  34. package/dist/evaluation/user-injection.js +1 -27
  35. package/dist/experience/experience-reuse.js +1 -103
  36. package/dist/experience/index.js +1 -5
  37. package/dist/experience/intent-distill.js +1 -83
  38. package/dist/experience/realtime-feedback.js +1 -94
  39. package/dist/experience/types.js +1 -1
  40. package/dist/experience/user-profile.js +1 -171
  41. package/dist/extensions/business-modules.js +1 -287
  42. package/dist/extensions/capability-manifest.js +1 -781
  43. package/dist/extensions/constraint-registry.js +1 -198
  44. package/dist/extensions/index.js +1 -6
  45. package/dist/extensions/metric-registry.js +1 -257
  46. package/dist/extensions/mode-evaluator.js +1 -170
  47. package/dist/extensions/modes.js +1 -499
  48. package/dist/extensions/registry.js +1 -717
  49. package/dist/extensions/types.js +1 -1
  50. package/dist/harness/auto-escalation.js +1 -68
  51. package/dist/harness/checkpoint.js +1 -129
  52. package/dist/harness/index.js +1 -78
  53. package/dist/harness/plan.js +1 -315
  54. package/dist/harness/recover.js +1 -139
  55. package/dist/harness/types.js +1 -1
  56. package/dist/harness/verify.js +1 -237
  57. package/dist/index.js +1 -273
  58. package/dist/intent/enrich.js +1 -67
  59. package/dist/intent/index.js +1 -60
  60. package/dist/intent/matcher.js +1 -81
  61. package/dist/intent/store.js +1 -55
  62. package/dist/intent/types.js +1 -10
  63. package/dist/knowledge/acquisition-flywheel.js +1 -192
  64. package/dist/knowledge/allocation-confirm.js +1 -534
  65. package/dist/knowledge/allocation-context.js +1 -249
  66. package/dist/knowledge/allocation-ledger.js +1 -463
  67. package/dist/knowledge/allocation-puzzle.js +1 -298
  68. package/dist/knowledge/allocation-risk.js +1 -568
  69. package/dist/knowledge/allocation-templates.js +1 -970
  70. package/dist/knowledge/allocation-translation.js +1 -585
  71. package/dist/knowledge/arb-risk.js +1 -210
  72. package/dist/knowledge/arbitration-confirm.js +1 -559
  73. package/dist/knowledge/arbitration-context.js +1 -505
  74. package/dist/knowledge/arbitration-ledger.js +1 -521
  75. package/dist/knowledge/arbitration-puzzle.js +1 -304
  76. package/dist/knowledge/arbitration-risk.js +1 -423
  77. package/dist/knowledge/arbitration-templates.js +1 -276
  78. package/dist/knowledge/arbitration-translation.js +1 -487
  79. package/dist/knowledge/arbitration-trust.js +1 -117
  80. package/dist/knowledge/audit-rules.js +1 -141
  81. package/dist/knowledge/bridge-risk.js +1 -263
  82. package/dist/knowledge/contact-risk.js +1 -200
  83. package/dist/knowledge/contact-templates.js +1 -60
  84. package/dist/knowledge/demand-confirm.js +1 -206
  85. package/dist/knowledge/demand-matching.js +1 -132
  86. package/dist/knowledge/demand-risk.js +1 -240
  87. package/dist/knowledge/demand-translation.js +1 -354
  88. package/dist/knowledge/deployment-scanner.js +1 -823
  89. package/dist/knowledge/dynamic-pricing.js +1 -87
  90. package/dist/knowledge/examples-scanner-cli.js +1 -26
  91. package/dist/knowledge/examples-scanner.js +1 -843
  92. package/dist/knowledge/flywheel-loop.js +1 -404
  93. package/dist/knowledge/fund-layer.js +1 -973
  94. package/dist/knowledge/glossary.js +1 -211
  95. package/dist/knowledge/guard-confirm.js +1 -406
  96. package/dist/knowledge/guard-context.js +1 -287
  97. package/dist/knowledge/guard-design-patterns.js +1 -360
  98. package/dist/knowledge/guard-ledger.js +1 -260
  99. package/dist/knowledge/guard-lint.js +1 -670
  100. package/dist/knowledge/guard-migration.js +1 -228
  101. package/dist/knowledge/guard-puzzle.js +1 -805
  102. package/dist/knowledge/guard-render.js +1 -700
  103. package/dist/knowledge/guard-risk.js +1 -1879
  104. package/dist/knowledge/guard-submission-prompt.js +1 -171
  105. package/dist/knowledge/guard-templates.js +1 -1105
  106. package/dist/knowledge/guard-translation.js +1 -1119
  107. package/dist/knowledge/index.js +1 -436
  108. package/dist/knowledge/industry-evolution.js +1 -323
  109. package/dist/knowledge/industry-generalizer.js +1 -381
  110. package/dist/knowledge/industry-registry.js +1 -174
  111. package/dist/knowledge/intent-metrics.d.ts +4 -3
  112. package/dist/knowledge/intent-metrics.js +1 -566
  113. package/dist/knowledge/machine-confirm.js +1 -559
  114. package/dist/knowledge/machine-context.js +1 -833
  115. package/dist/knowledge/machine-ledger.js +1 -338
  116. package/dist/knowledge/machine-puzzle.js +1 -494
  117. package/dist/knowledge/machine-render.js +1 -565
  118. package/dist/knowledge/machine-risk.js +1 -669
  119. package/dist/knowledge/machine-templates.js +1 -1597
  120. package/dist/knowledge/machine-topology.js +1 -234
  121. package/dist/knowledge/machine-translation.js +1 -513
  122. package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
  123. package/dist/knowledge/mcp-schema-audit.js +1 -777
  124. package/dist/knowledge/onchain-constants.js +1 -35
  125. package/dist/knowledge/order-confirm.js +1 -573
  126. package/dist/knowledge/order-context.js +1 -390
  127. package/dist/knowledge/order-ledger.js +1 -341
  128. package/dist/knowledge/order-puzzle.js +1 -255
  129. package/dist/knowledge/order-risk.js +1 -653
  130. package/dist/knowledge/order-templates.js +1 -368
  131. package/dist/knowledge/order-translation.js +1 -550
  132. package/dist/knowledge/overrides-loader.js +1 -65
  133. package/dist/knowledge/passport-confirm.js +1 -531
  134. package/dist/knowledge/passport-context.js +1 -306
  135. package/dist/knowledge/passport-ledger.js +1 -282
  136. package/dist/knowledge/passport-puzzle.js +1 -333
  137. package/dist/knowledge/passport-risk.js +1 -450
  138. package/dist/knowledge/passport-templates.js +1 -568
  139. package/dist/knowledge/passport-translation.js +1 -516
  140. package/dist/knowledge/payment-risk.js +1 -249
  141. package/dist/knowledge/permission-confirm.js +1 -426
  142. package/dist/knowledge/permission-context.js +1 -224
  143. package/dist/knowledge/permission-ledger.js +1 -403
  144. package/dist/knowledge/permission-puzzle.js +1 -173
  145. package/dist/knowledge/permission-risk.js +1 -411
  146. package/dist/knowledge/permission-templates.js +1 -234
  147. package/dist/knowledge/permission-translation.js +1 -350
  148. package/dist/knowledge/personal-risk.js +1 -212
  149. package/dist/knowledge/process-model.js +1 -160
  150. package/dist/knowledge/progress-confirm.js +1 -456
  151. package/dist/knowledge/progress-context.js +1 -452
  152. package/dist/knowledge/progress-ledger.js +1 -330
  153. package/dist/knowledge/progress-puzzle.js +1 -219
  154. package/dist/knowledge/progress-risk.js +1 -461
  155. package/dist/knowledge/progress-templates.js +1 -228
  156. package/dist/knowledge/progress-translation.js +1 -405
  157. package/dist/knowledge/proof-confirm.js +1 -187
  158. package/dist/knowledge/proof-risk.js +1 -207
  159. package/dist/knowledge/proof-translation.js +1 -283
  160. package/dist/knowledge/registrar-risk.js +1 -217
  161. package/dist/knowledge/repository-confirm.js +1 -286
  162. package/dist/knowledge/repository-risk.js +1 -373
  163. package/dist/knowledge/repository-translation.js +1 -445
  164. package/dist/knowledge/reputation-rules.js +1 -99
  165. package/dist/knowledge/resource-risk.js +1 -157
  166. package/dist/knowledge/reward-confirm.js +1 -526
  167. package/dist/knowledge/reward-context.js +1 -504
  168. package/dist/knowledge/reward-ledger.js +1 -502
  169. package/dist/knowledge/reward-puzzle.js +1 -300
  170. package/dist/knowledge/reward-risk.js +1 -627
  171. package/dist/knowledge/reward-templates.js +1 -197
  172. package/dist/knowledge/reward-translation.js +1 -501
  173. package/dist/knowledge/safety-rules.js +1 -404
  174. package/dist/knowledge/scenario-modes.js +1 -321
  175. package/dist/knowledge/service-confirm.js +1 -807
  176. package/dist/knowledge/service-context.js +1 -403
  177. package/dist/knowledge/service-ledger.js +1 -609
  178. package/dist/knowledge/service-puzzle.js +1 -236
  179. package/dist/knowledge/service-risk.js +1 -651
  180. package/dist/knowledge/service-templates.js +1 -456
  181. package/dist/knowledge/service-translation.js +1 -622
  182. package/dist/knowledge/template-registry.js +1 -353
  183. package/dist/knowledge/tool-constraints.js +1 -195
  184. package/dist/knowledge/tools-reference.js +1 -178
  185. package/dist/knowledge/treasury-confirm.js +1 -512
  186. package/dist/knowledge/treasury-context.js +1 -363
  187. package/dist/knowledge/treasury-ledger.js +1 -300
  188. package/dist/knowledge/treasury-puzzle.js +1 -216
  189. package/dist/knowledge/treasury-risk.js +1 -440
  190. package/dist/knowledge/treasury-templates.js +1 -358
  191. package/dist/knowledge/treasury-translation.js +1 -498
  192. package/dist/knowledge/trust-metrics.js +1 -198
  193. package/dist/knowledge/util-risk.js +1 -135
  194. package/dist/loop-engineering/aggregate.js +1 -132
  195. package/dist/loop-engineering/context-collect.js +1 -83
  196. package/dist/loop-engineering/diagnose.js +1 -273
  197. package/dist/loop-engineering/improve.js +1 -405
  198. package/dist/loop-engineering/index.js +1 -4
  199. package/dist/loop-engineering/pipeline.js +1 -56
  200. package/dist/mode-market/index.js +1 -3
  201. package/dist/mode-market/registry.js +1 -124
  202. package/dist/mode-market/review.js +1 -214
  203. package/dist/mode-market/submission.js +1 -85
  204. package/dist/participation/collaborator-interest.d.ts +23 -0
  205. package/dist/participation/collaborator-interest.js +1 -0
  206. package/dist/participation/customer-interest.d.ts +25 -0
  207. package/dist/participation/customer-interest.js +1 -0
  208. package/dist/participation/merchant-interest.js +1 -100
  209. package/dist/participation/radar-core.d.ts +13 -3
  210. package/dist/participation/radar-core.js +1 -269
  211. package/dist/participation/supplier-interest.d.ts +25 -0
  212. package/dist/participation/supplier-interest.js +1 -0
  213. package/dist/persona/analyzer.js +1 -66
  214. package/dist/persona/bridge.js +1 -86
  215. package/dist/persona/defaults.js +1 -195
  216. package/dist/persona/experience-bridge.js +1 -23
  217. package/dist/persona/index.js +1 -71
  218. package/dist/persona/model.js +1 -111
  219. package/dist/persona/store.js +1 -62
  220. package/dist/persona/types.d.ts +3 -1
  221. package/dist/persona/types.js +1 -5
  222. package/dist/project/business-puzzle.js +1 -383
  223. package/dist/project/context-assembly.js +1 -254
  224. package/dist/project/deployment-bridge.js +1 -120
  225. package/dist/project/deployment-doc.js +1 -1126
  226. package/dist/project/edit-planner.js +1 -1342
  227. package/dist/project/evaluation.js +1 -2011
  228. package/dist/project/game-theory.js +1 -177
  229. package/dist/project/graph-builder.js +1 -656
  230. package/dist/project/graph.js +1 -340
  231. package/dist/project/handlers.js +1 -1784
  232. package/dist/project/index.d.ts +1 -0
  233. package/dist/project/index.js +1 -301
  234. package/dist/project/intent-analyzer.js +1 -149
  235. package/dist/project/machine-nodes.js +1 -36
  236. package/dist/project/merchant-guide.js +1 -264
  237. package/dist/project/migration.js +1 -125
  238. package/dist/project/mode-actions.js +1 -309
  239. package/dist/project/namespace.js +1 -206
  240. package/dist/project/participation-radar.js +1 -428
  241. package/dist/project/pipeline-actions.js +1 -109
  242. package/dist/project/project-store.js +1 -422
  243. package/dist/project/query.js +1 -153
  244. package/dist/project/reverse-mapping.d.ts +34 -0
  245. package/dist/project/reverse-mapping.js +1 -0
  246. package/dist/project/risk-aggregator.js +1 -295
  247. package/dist/project/rollback-policy.js +1 -290
  248. package/dist/project/semantic-assembler.js +1 -345
  249. package/dist/project/semantic-graph.js +1 -292
  250. package/dist/project/stage-gate.js +1 -369
  251. package/dist/project/substep-trace.js +1 -332
  252. package/dist/project/task-tracker.js +1 -78
  253. package/dist/role/derivation.d.ts +18 -0
  254. package/dist/role/derivation.js +1 -0
  255. package/dist/role/index.d.ts +5 -0
  256. package/dist/role/index.js +1 -0
  257. package/dist/role/model.d.ts +8 -0
  258. package/dist/role/model.js +1 -0
  259. package/dist/role/resolution.d.ts +11 -0
  260. package/dist/role/resolution.js +1 -0
  261. package/dist/role/types.d.ts +11 -0
  262. package/dist/role/types.js +1 -0
  263. package/dist/rules.js +1 -52
  264. package/dist/safety/confirm-gate.js +1 -88
  265. package/dist/safety/index.js +1 -3
  266. package/dist/safety/preview.js +1 -52
  267. package/dist/schema/call/allocation.js +1 -34
  268. package/dist/schema/call/arbitration.js +1 -113
  269. package/dist/schema/call/base.d.ts +15 -15
  270. package/dist/schema/call/base.js +1 -370
  271. package/dist/schema/call/bridge-handler.js +1 -265
  272. package/dist/schema/call/bridge.d.ts +7 -7
  273. package/dist/schema/call/bridge.js +1 -458
  274. package/dist/schema/call/contact.js +1 -37
  275. package/dist/schema/call/demand.js +1 -47
  276. package/dist/schema/call/guard.js +1 -161
  277. package/dist/schema/call/handler.js +1 -322
  278. package/dist/schema/call/index.js +1 -20
  279. package/dist/schema/call/machine.js +1 -193
  280. package/dist/schema/call/order.js +1 -35
  281. package/dist/schema/call/payment.js +1 -37
  282. package/dist/schema/call/permission-handler.js +1 -54
  283. package/dist/schema/call/permission.js +1 -105
  284. package/dist/schema/call/personal.js +1 -78
  285. package/dist/schema/call/progress.js +1 -47
  286. package/dist/schema/call/proof.js +1 -33
  287. package/dist/schema/call/repository.js +1 -77
  288. package/dist/schema/call/reward.js +1 -30
  289. package/dist/schema/call/semantic.js +1 -1679
  290. package/dist/schema/call/service.js +1 -184
  291. package/dist/schema/call/treasury.js +1 -71
  292. package/dist/schema/common/index.js +1 -407
  293. package/dist/schema/config/index.js +1 -68
  294. package/dist/schema/evaluation/index.d.ts +213 -16
  295. package/dist/schema/evaluation/index.js +1 -356
  296. package/dist/schema/index.js +1 -17
  297. package/dist/schema/intent-radar/index.d.ts +13 -13
  298. package/dist/schema/intent-radar/index.js +1 -89
  299. package/dist/schema/local/index.d.ts +21 -21
  300. package/dist/schema/local/index.js +1 -927
  301. package/dist/schema/local/wip.js +1 -187
  302. package/dist/schema/messenger/index.d.ts +7 -7
  303. package/dist/schema/messenger/index.js +1 -475
  304. package/dist/schema/operations.d.ts +7 -7
  305. package/dist/schema/operations.js +1 -520
  306. package/dist/schema/persona/index.d.ts +54 -54
  307. package/dist/schema/persona/index.js +1 -148
  308. package/dist/schema/project/index.d.ts +94 -48
  309. package/dist/schema/project/index.js +1 -2057
  310. package/dist/schema/query/index.d.ts +423 -7
  311. package/dist/schema/query/index.js +1 -1646
  312. package/dist/schema/schema-query/index.js +1 -104
  313. package/dist/schema/schema-version.js +1 -76
  314. package/dist/schema/sync-layer4.js +1 -286
  315. package/dist/schema/task-status.js +1 -36
  316. package/dist/schema/trust/index.js +1 -314
  317. package/dist/schema/utils/guard-parser.js +1 -419
  318. package/dist/schema/utils/guard-query-utils.js +1 -46
  319. package/dist/schema/utils/node-parser.js +1 -369
  320. package/dist/schema/utils/object-type-utils.js +1 -35
  321. package/dist/schema/utils/permission-index-utils.js +1 -7
  322. package/dist/schema/utils/permission-machine-check.js +1 -121
  323. package/dist/schema/utils/skills-recommendation.js +1 -77
  324. package/dist/schema-query/index.js +1 -810
  325. package/dist/schemas/account_operation.output.json +5 -2
  326. package/dist/schemas/bridge_operation.output.json +5 -2
  327. package/dist/schemas/evaluation_operation.output.json +112 -7
  328. package/dist/schemas/evaluation_operation.schema.json +93 -6
  329. package/dist/schemas/index.json +1 -1
  330. package/dist/schemas/intent_radar.output.json +4 -1
  331. package/dist/schemas/intent_radar.schema.json +4 -1
  332. package/dist/schemas/local_info_operation.output.json +5 -2
  333. package/dist/schemas/local_mark_operation.output.json +5 -2
  334. package/dist/schemas/messenger_operation.output.json +5 -2
  335. package/dist/schemas/onchain_events.output.json +5 -2
  336. package/dist/schemas/onchain_operations.output.json +5 -2
  337. package/dist/schemas/onchain_operations.schema.json +4 -4
  338. package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
  339. package/dist/schemas/onchain_operations_machine.schema.json +2 -2
  340. package/dist/schemas/onchain_operations_service.schema.json +1 -1
  341. package/dist/schemas/onchain_table_data.output.json +6 -3
  342. package/dist/schemas/persona_operation.output.json +4 -1
  343. package/dist/schemas/persona_operation.schema.json +4 -1
  344. package/dist/schemas/project_operation.output.json +28 -8
  345. package/dist/schemas/query_toolkit.output.json +8 -5
  346. package/dist/schemas/wowok_buildin_info.output.json +132 -0
  347. package/dist/schemas/wowok_buildin_info.schema.json +14 -0
  348. package/dist/telemetry/index.js +1 -112
  349. package/dist/telemetry/redact.js +1 -23
  350. package/dist/telemetry/storage.js +1 -80
  351. package/dist/tools/handlers/bridge.js +1 -1
  352. package/dist/tools/handlers/config.js +1 -74
  353. package/dist/tools/handlers/evaluation.js +1 -123
  354. package/dist/tools/handlers/file-export.js +1 -90
  355. package/dist/tools/handlers/intent-radar.js +1 -76
  356. package/dist/tools/handlers/local.js +1 -53
  357. package/dist/tools/handlers/messenger.js +1 -188
  358. package/dist/tools/handlers/onchain.js +1 -1180
  359. package/dist/tools/handlers/persona.js +1 -89
  360. package/dist/tools/handlers/project.js +1 -211
  361. package/dist/tools/handlers/query.js +1 -434
  362. package/dist/tools/handlers/schema-query.js +1 -176
  363. package/dist/tools/handlers/task-status.js +1 -26
  364. package/dist/tools/handlers/trust.js +1 -380
  365. package/dist/tools/handlers/wip.js +1 -90
  366. package/dist/tools/index.js +1 -1382
  367. package/dist/tools/retry.js +1 -85
  368. package/dist/tools/rules-hook.js +1 -23
  369. package/dist/tools/shared.js +1 -130
  370. package/dist/tools/types.js +1 -1
  371. package/dist/tools/upgrade-check.d.ts +19 -0
  372. package/dist/tools/upgrade-check.js +1 -0
  373. package/dist/tools/wip-deploy-assist.js +1 -306
  374. package/dist/tools/wrap.js +1 -500
  375. package/package.json +4 -2
@@ -1,1597 +1 @@
1
- import { findScene, inferSceneFromFlow, } from "./machine-ledger.js";
2
- export const MACHINE_TEMPLATES = [
3
- {
4
- id: "tpl_machine_ecommerce_standard",
5
- scene_id: "ecommerce_standard",
6
- name: "Standard E-commerce Flow",
7
- description: "Linear e-commerce workflow: Paid (entry) -> Ship -> Receive -> Complete. " +
8
- "Payment is handled by Service.buy() atomically; Machine starts at post-payment state. " +
9
- "Funds auto-allocated to merchant at Complete node. Recommended baseline for new merchants.",
10
- recommended_patterns: ["P-M-SEQ"],
11
- recommended_topology: ["P-M-LINEAR"],
12
- parameters: [
13
- {
14
- name: "merchant_permission",
15
- type: "permission_ref",
16
- required: true,
17
- description: "Merchant Permission object address or name (must have custom indices defined)",
18
- constraint: "Permission must already be created; index 2 (merchant) and index 3 (admin) recommended",
19
- },
20
- {
21
- name: "ship_forward_name",
22
- type: "string",
23
- required: true,
24
- default: "Ship",
25
- description: "Forward name for shipping step",
26
- constraint: "Must be <64 BCS bytes; only letters/digits/underscore",
27
- },
28
- {
29
- name: "receive_forward_name",
30
- type: "string",
31
- required: true,
32
- default: "Receive",
33
- description: "Forward name for customer receipt confirmation",
34
- },
35
- {
36
- name: "complete_node_name",
37
- type: "string",
38
- required: true,
39
- default: "Complete",
40
- description: "Terminal node name triggering fund allocation",
41
- },
42
- ],
43
- example_nodes: [
44
- { name: "Paid", description: "Entry: order created and paid via Service.buy(); Machine starts here" },
45
- { name: "Shipped", description: "Goods dispatched" },
46
- { name: "Received", description: "Customer confirmed receipt" },
47
- { name: "${complete_node_name}", description: "Terminal: triggers allocation" },
48
- ],
49
- example_pairs: [
50
- {
51
- prev_node: "",
52
- next_node: "Paid",
53
- threshold: 1,
54
- forwards: [
55
- { name: "Enter", weight: 1, named_operator: "", permission_index: 0 },
56
- ],
57
- },
58
- {
59
- prev_node: "Paid",
60
- next_node: "Shipped",
61
- threshold: 1,
62
- forwards: [
63
- {
64
- name: "${ship_forward_name}",
65
- weight: 1,
66
- permission_index: 2,
67
- named_operator: "",
68
- },
69
- ],
70
- },
71
- {
72
- prev_node: "Shipped",
73
- next_node: "Received",
74
- threshold: 1,
75
- forwards: [
76
- { name: "${receive_forward_name}", weight: 1, named_operator: "", permission_index: 0 },
77
- ],
78
- },
79
- {
80
- prev_node: "Received",
81
- next_node: "${complete_node_name}",
82
- threshold: 1,
83
- forwards: [
84
- { name: "Finish", weight: 1, permission_index: 2, named_operator: "" },
85
- ],
86
- },
87
- ],
88
- required_guards: [],
89
- required_permissions: [
90
- { index: 2, name: "merchant", description: "Merchant role for Ship + Finish" },
91
- { index: 3, name: "admin", description: "Admin override (optional)" },
92
- ],
93
- required_allocators: [
94
- {
95
- name: "MerchantAllocation",
96
- trigger_node: "${complete_node_name}",
97
- description: "100% to merchant Treasury or personal address",
98
- },
99
- ],
100
- forkable_fields: ["node_names", "forward_names", "thresholds", "additional_branches"],
101
- applicable_industries: ["ecommerce", "retail"],
102
- relevant_risks: ["R-M1-01", "R-M1-02", "R-M1-08", "R-M2-01", "R-M3-02", "R-M4-01"],
103
- creation_notes: [
104
- "Build order: Permission -> Machine (unpublished) -> Guards -> Bind guards -> Publish -> Bind to Service",
105
- "First node 'Paid' represents post-payment state — Service.buy() completes payment atomically before Progress is created",
106
- "No separate 'Order' or 'Pay' nodes needed — payment is handled by Service.buy(), not Machine",
107
- "Entry point: prev_node='' (empty string) targets 'Paid' — at least one Pair must exist with empty prev_node",
108
- "If using P16 circular reference for Service, use name not address (Service not yet published)",
109
- ],
110
- example_use_case: "Small e-commerce shop selling camera accessories. Linear flow with no exceptions. " +
111
- "Funds allocated to merchant personal address on Complete.",
112
- publish_checklist: [
113
- "All 4 nodes have at least one outgoing Forward (except terminal)",
114
- "Entry Pair exists (prev_node='' targets 'Paid')",
115
- "permissionIndex values match Permission object indices",
116
- "Test Progress run on testnet",
117
- "machineNode2file export as backup",
118
- ],
119
- },
120
- {
121
- id: "tpl_machine_ecommerce_exceptions",
122
- scene_id: "ecommerce_with_exceptions",
123
- name: "E-commerce Flow with Exception Branches",
124
- description: "Multi-path workflow: Paid (entry) -> Ship -> Receive/Lost/Return. Lost uses dual-sig (threshold=2). " +
125
- "Payment is handled by Service.buy() atomically; Machine starts at post-payment state. " +
126
- "Return path opens Refund -> Complete. Competing pairs first-wins.",
127
- recommended_patterns: ["P-M-SEQ", "P-M-COMPETING"],
128
- recommended_topology: ["P-M-LINEAR", "P-M-COMPETING"],
129
- parameters: [
130
- {
131
- name: "merchant_permission",
132
- type: "permission_ref",
133
- required: true,
134
- description: "Merchant Permission object",
135
- },
136
- {
137
- name: "lost_threshold",
138
- type: "number",
139
- required: true,
140
- default: "2",
141
- description: "Threshold for dual-sig on Lost node",
142
- constraint: "Must be 2 (customer + merchant)",
143
- },
144
- {
145
- name: "arbitration_ref",
146
- type: "arbitration_ref",
147
- required: false,
148
- description: "Arbitration object if Lost escalates to arbitration",
149
- },
150
- {
151
- name: "time_guard_days",
152
- type: "number",
153
- required: true,
154
- default: "10",
155
- description: "Days before auto-complete trigger (time guard)",
156
- constraint: "Must be > 0; reasonable range 7-30",
157
- },
158
- {
159
- name: "return_node_name",
160
- type: "string",
161
- required: true,
162
- default: "Return",
163
- description: "Name of the return/refund node in the exception branch",
164
- },
165
- ],
166
- example_nodes: [
167
- { name: "Paid", description: "Entry: order created and paid via Service.buy(); Machine starts here" },
168
- { name: "Shipped" },
169
- { name: "Received" },
170
- { name: "Lost" },
171
- { name: "Return" },
172
- { name: "Refund" },
173
- { name: "Complete" },
174
- ],
175
- example_pairs: [
176
- {
177
- prev_node: "",
178
- next_node: "Paid",
179
- threshold: 1,
180
- forwards: [{ name: "Enter", weight: 1, named_operator: "" }],
181
- },
182
- {
183
- prev_node: "Paid",
184
- next_node: "Shipped",
185
- threshold: 1,
186
- forwards: [{ name: "Ship", weight: 1, permission_index: 2 }],
187
- },
188
- {
189
- prev_node: "Shipped",
190
- next_node: "Received",
191
- threshold: 1,
192
- forwards: [{ name: "ConfirmReceive", weight: 1, named_operator: "" }],
193
- },
194
- {
195
- prev_node: "Shipped",
196
- next_node: "Lost",
197
- threshold: "${lost_threshold}",
198
- forwards: [
199
- { name: "CustomerReport", weight: 1, named_operator: "" },
200
- { name: "MerchantConfirm", weight: 1, permission_index: 2 },
201
- ],
202
- },
203
- {
204
- prev_node: "Shipped",
205
- next_node: "Return",
206
- threshold: 1,
207
- forwards: [{ name: "RequestReturn", weight: 1, named_operator: "" }],
208
- },
209
- {
210
- prev_node: "Received",
211
- next_node: "Complete",
212
- threshold: 1,
213
- forwards: [
214
- {
215
- name: "TimeGuard",
216
- weight: 1,
217
- permission_index: 3,
218
- guard: "time_guard_${time_guard_days}_days",
219
- },
220
- { name: "MerchantFinish", weight: 1, permission_index: 2 },
221
- ],
222
- },
223
- {
224
- prev_node: "Return",
225
- next_node: "Refund",
226
- threshold: 1,
227
- forwards: [{ name: "IssueRefund", weight: 1, permission_index: 2 }],
228
- },
229
- {
230
- prev_node: "Refund",
231
- next_node: "Complete",
232
- threshold: 1,
233
- forwards: [{ name: "CloseReturn", weight: 1, permission_index: 2 }],
234
- },
235
- ],
236
- required_guards: [
237
- {
238
- guard_template_id: "tpl_forward_node_check",
239
- bound_to_forward: "MerchantConfirm",
240
- purpose: "Dual-sig on Lost node",
241
- },
242
- {
243
- guard_template_id: "tpl_forward_node_check",
244
- bound_to_forward: "TimeGuard",
245
- purpose: "Time lock ${time_guard_days} days",
246
- },
247
- ],
248
- required_permissions: [
249
- { index: 2, name: "merchant", description: "Merchant role" },
250
- { index: 3, name: "admin", description: "Admin / time-guard trigger" },
251
- ],
252
- required_allocators: [
253
- {
254
- name: "CompleteAllocation",
255
- trigger_node: "Complete",
256
- description: "Full allocation to merchant on normal completion",
257
- },
258
- {
259
- name: "RefundAllocation",
260
- trigger_node: "Refund",
261
- description: "Full refund to customer on return",
262
- },
263
- {
264
- name: "LostAllocation",
265
- trigger_node: "Lost",
266
- description: "Optional: partial refund or escrow (depends on policy)",
267
- },
268
- ],
269
- forkable_fields: ["node_names", "branch_conditions", "time_guard_days", "lost_threshold"],
270
- applicable_industries: ["ecommerce", "logistics"],
271
- relevant_risks: [
272
- "R-M1-01", "R-M1-03", "R-M1-08", "R-M2-01", "R-M2-05",
273
- "R-M3-02", "R-M3-04", "R-M3-05", "R-M4-01", "R-M5-03",
274
- ],
275
- creation_notes: [
276
- "First node 'Paid' represents post-payment state — Service.buy() completes payment atomically before Progress is created",
277
- "No separate 'Order' or 'Pay' nodes needed — payment is handled by Service.buy(), not Machine",
278
- "Competing Pairs (Shipped -> Received/Lost/Return) are mutually exclusive — first threshold met wins",
279
- "Lost node threshold=2 means BOTH customer and merchant Forwards must execute",
280
- "TimeGuard must use context(Clock) >= progress.entry_time + duration",
281
- "If Lost escalates to arbitration, bind arbitration_usage_guard on Lost forward",
282
- "Refund Allocation must use sharing.who=OrderHolder (refund to customer, NOT merchant)",
283
- ],
284
- example_use_case: "Mid-size e-commerce with 7-day return policy and dispute handling. " +
285
- "Lost claims require customer+merchant dual confirmation.",
286
- publish_checklist: [
287
- "All competing Pairs tested: verify first-wins semantics on testnet",
288
- "Lost dual-sig tested: incomplete signatures do not advance",
289
- "TimeGuard Clock query verified (testnet)",
290
- "All three Allocators tested with correct sharing.who",
291
- "Arbitration binding (if any) verified via gen_passport",
292
- ],
293
- },
294
- {
295
- id: "tpl_machine_rental",
296
- scene_id: "rental_standard",
297
- name: "Equipment Rental Flow",
298
- description: "Rental flow: DepositPaid (entry) -> Pickup -> In Use -> Return -> Refund Deposit. " +
299
- "Payment is handled by Service.buy() atomically; Machine starts at post-deposit state. " +
300
- "Separates deposit from rental fee (two Allocators). Damage report via retained_submission.",
301
- recommended_patterns: ["P-M-SEQ"],
302
- recommended_topology: ["P-M-LINEAR"],
303
- parameters: [
304
- { name: "merchant_permission", type: "permission_ref", required: true, description: "Merchant Permission object" },
305
- {
306
- name: "deposit_amount",
307
- type: "number",
308
- required: true,
309
- description: "Deposit amount in smallest WOW unit",
310
- constraint: "Must equal order.amount field; verify via Guard query",
311
- },
312
- {
313
- name: "damage_inspection_node",
314
- type: "string",
315
- required: true,
316
- default: "DamageCheck",
317
- description: "Name of the node where damage inspection occurs",
318
- },
319
- {
320
- name: "return_node_name",
321
- type: "string",
322
- required: true,
323
- default: "Return",
324
- description: "Name of the return node after damage check fails",
325
- },
326
- ],
327
- example_nodes: [
328
- { name: "DepositPaid", description: "Entry: deposit paid via Service.buy(); Machine starts here" },
329
- { name: "PickedUp" },
330
- { name: "InUse" },
331
- { name: "Return" },
332
- { name: "DamageCheck" },
333
- { name: "DepositRefund" },
334
- { name: "Complete" },
335
- ],
336
- example_pairs: [
337
- {
338
- prev_node: "",
339
- next_node: "DepositPaid",
340
- threshold: 1,
341
- forwards: [{ name: "Enter", weight: 1, named_operator: "" }],
342
- },
343
- {
344
- prev_node: "DepositPaid",
345
- next_node: "PickedUp",
346
- threshold: 1,
347
- forwards: [{ name: "Pickup", weight: 1, named_operator: "", permission_index: 2 }],
348
- },
349
- {
350
- prev_node: "PickedUp",
351
- next_node: "InUse",
352
- threshold: 1,
353
- forwards: [{ name: "StartUse", weight: 1, named_operator: "" }],
354
- },
355
- {
356
- prev_node: "InUse",
357
- next_node: "Return",
358
- threshold: 1,
359
- forwards: [{ name: "ReturnItem", weight: 1, named_operator: "" }],
360
- },
361
- {
362
- prev_node: "Return",
363
- next_node: "DamageCheck",
364
- threshold: 1,
365
- forwards: [
366
- {
367
- name: "Inspect",
368
- weight: 1,
369
- permission_index: 2,
370
- retained_submission: "damage_report",
371
- },
372
- ],
373
- },
374
- {
375
- prev_node: "Return",
376
- next_node: "Complete",
377
- threshold: 1,
378
- forwards: [{ name: "CleanReturn", weight: 1, permission_index: 2 }],
379
- },
380
- {
381
- prev_node: "DamageCheck",
382
- next_node: "DepositRefund",
383
- threshold: 1,
384
- forwards: [{ name: "DeductDamage", weight: 1, permission_index: 2 }],
385
- },
386
- {
387
- prev_node: "DepositRefund",
388
- next_node: "Complete",
389
- threshold: 1,
390
- forwards: [{ name: "Close", weight: 1, permission_index: 2 }],
391
- },
392
- ],
393
- required_guards: [
394
- {
395
- guard_template_id: "tpl_forward_privacy_delivery_proof",
396
- bound_to_forward: "Inspect",
397
- purpose: "Optional: damage evidence proof (photo, video)",
398
- },
399
- ],
400
- required_permissions: [
401
- { index: 2, name: "merchant", description: "Rental provider" },
402
- ],
403
- required_allocators: [
404
- {
405
- name: "RentalFeeAllocation",
406
- trigger_node: "Complete",
407
- description: "Rental fee to merchant",
408
- },
409
- {
410
- name: "DepositRefundAllocation",
411
- trigger_node: "DepositRefund",
412
- description: "Remaining deposit to customer (OrderHolder sharing.who)",
413
- },
414
- {
415
- name: "DamageDeductionAllocation",
416
- trigger_node: "DamageCheck",
417
- description: "Damage deduction to merchant",
418
- },
419
- ],
420
- forkable_fields: ["deposit_amount", "damage_node_logic", "additional_inspection_steps"],
421
- applicable_industries: ["rental", "equipment", "vehicle"],
422
- relevant_risks: [
423
- "R-M1-01", "R-M1-08", "R-M2-01", "R-M2-04", "R-M3-02",
424
- "R-M4-01", "R-M5-02",
425
- ],
426
- creation_notes: [
427
- "First node 'DepositPaid' represents post-payment state — Service.buy() completes deposit payment atomically before Progress is created",
428
- "No separate 'Reserve' or 'PayDeposit' nodes needed — reservation and payment are handled by Service.buy(), not Machine",
429
- "Damage report uses retained_submission — values stored uniquely by (current_node, next_node, forward_name)",
430
- "Two competing Pairs at Return node: DamageCheck vs Complete (clean return)",
431
- "DamageDeduction Allocation uses sharing.who=Entity (merchant), not OrderHolder",
432
- ],
433
- example_use_case: "Camera equipment rental: customer pays 1000 WOW deposit, returns equipment, " +
434
- "merchant inspects. If damaged, 200 WOW deducted; otherwise full refund.",
435
- publish_checklist: [
436
- "Deposit Guard tested (testnet) with valid/invalid amounts",
437
- "Damage report retained_submission stored correctly (query progress_history)",
438
- "Both Return branches tested (DamageCheck + CleanReturn)",
439
- "All three Allocators verified with correct sharing.who",
440
- ],
441
- },
442
- {
443
- id: "tpl_machine_dual_signature",
444
- scene_id: "dual_signature",
445
- name: "Dual-Signature Consensus Flow",
446
- description: "Critical node requires both customer + merchant confirmation. threshold=2 with two Forwards (weight=1 each). " +
447
- "Customer uses namedOperator='' (OrderHolder); merchant uses permissionIndex=2.",
448
- recommended_patterns: ["P-M-AND"],
449
- recommended_topology: ["P-M-LINEAR"],
450
- parameters: [
451
- { name: "merchant_permission", type: "permission_ref", required: true, description: "Merchant Permission object" },
452
- {
453
- name: "critical_node_name",
454
- type: "string",
455
- required: true,
456
- default: "Approve",
457
- description: "Node requiring dual-sig",
458
- },
459
- {
460
- name: "next_node_after_approval",
461
- type: "string",
462
- required: true,
463
- default: "Execute",
464
- description: "Name of the node that follows after dual-signature approval",
465
- },
466
- ],
467
- example_nodes: [
468
- { name: "Initiated" },
469
- { name: "${critical_node_name}", description: "Dual-sig required here" },
470
- { name: "${next_node_after_approval}" },
471
- { name: "Complete" },
472
- ],
473
- example_pairs: [
474
- {
475
- prev_node: "",
476
- next_node: "Initiated",
477
- threshold: 1,
478
- forwards: [{ name: "Initiate", weight: 1, named_operator: "" }],
479
- },
480
- {
481
- prev_node: "Initiated",
482
- next_node: "${critical_node_name}",
483
- threshold: 1,
484
- forwards: [{ name: "Submit", weight: 1, named_operator: "" }],
485
- },
486
- {
487
- prev_node: "${critical_node_name}",
488
- next_node: "${next_node_after_approval}",
489
- threshold: 2,
490
- forwards: [
491
- {
492
- name: "CustomerApprove",
493
- weight: 1,
494
- named_operator: "",
495
- guard: "customer_identity_guard",
496
- },
497
- {
498
- name: "MerchantApprove",
499
- weight: 1,
500
- permission_index: 2,
501
- guard: "merchant_identity_guard",
502
- },
503
- ],
504
- },
505
- {
506
- prev_node: "${next_node_after_approval}",
507
- next_node: "Complete",
508
- threshold: 1,
509
- forwards: [{ name: "Finish", weight: 1, permission_index: 2 }],
510
- },
511
- ],
512
- required_guards: [
513
- {
514
- guard_template_id: "tpl_forward_node_check",
515
- bound_to_forward: "CustomerApprove",
516
- purpose: "Verify customer identity (order.owner)",
517
- },
518
- {
519
- guard_template_id: "tpl_forward_node_check",
520
- bound_to_forward: "MerchantApprove",
521
- purpose: "Verify merchant identity (permission holder)",
522
- },
523
- ],
524
- required_permissions: [
525
- { index: 2, name: "merchant", description: "Merchant approval" },
526
- ],
527
- required_allocators: [
528
- {
529
- name: "CompleteAllocation",
530
- trigger_node: "Complete",
531
- description: "Allocation on dual-sig completion",
532
- },
533
- ],
534
- forkable_fields: ["critical_node_name", "additional_approvers", "guard_logic"],
535
- applicable_industries: ["ecommerce", "service", "logistics", "escrow"],
536
- relevant_risks: ["R-M1-08", "R-M2-01", "R-M3-02", "R-M3-04"],
537
- creation_notes: [
538
- "threshold=2 means BOTH Forwards must execute to advance (AND semantics)",
539
- "Customer Forward uses namedOperator='' (OrderHolder)",
540
- "Merchant Forward uses permissionIndex=2",
541
- "If either party fails to sign, workflow stalls — consider adding timeout Guard",
542
- ],
543
- example_use_case: "High-value order (e.g. real estate transaction) requiring both buyer and seller confirmation.",
544
- publish_checklist: [
545
- "Both Forward identities tested on testnet",
546
- "Verify partial signature does NOT advance (threshold=2)",
547
- "Guards correctly distinguish customer vs merchant identity",
548
- ],
549
- },
550
- {
551
- id: "tpl_machine_weighted_voting",
552
- scene_id: "weighted_voting",
553
- name: "Weighted Voting Flow",
554
- description: "Multi-party voting with unequal weights. threshold=100, chief weight=60, members weight=40 total. " +
555
- "Each member's weight extracted via Guard query from Arbitration object.",
556
- recommended_patterns: ["P-M-VOTE"],
557
- recommended_topology: ["P-M-LINEAR"],
558
- parameters: [
559
- {
560
- name: "arbitration_ref",
561
- type: "arbitration_ref",
562
- required: true,
563
- description: "Arbitration object storing voter weights",
564
- },
565
- {
566
- name: "threshold_total",
567
- type: "number",
568
- required: true,
569
- default: "100",
570
- description: "Total weight threshold for decision",
571
- },
572
- {
573
- name: "chief_weight",
574
- type: "number",
575
- required: true,
576
- default: "60",
577
- description: "Weight assigned to the chief voter (out of 100)",
578
- },
579
- {
580
- name: "member_count",
581
- type: "number",
582
- required: true,
583
- default: "5",
584
- description: "Number of voting members (excluding chief)",
585
- },
586
- ],
587
- example_nodes: [
588
- { name: "VoteOpened" },
589
- { name: "Voting" },
590
- { name: "Approved" },
591
- { name: "Rejected" },
592
- ],
593
- example_pairs: [
594
- {
595
- prev_node: "",
596
- next_node: "VoteOpened",
597
- threshold: 1,
598
- forwards: [{ name: "OpenVote", weight: 1, permission_index: 3 }],
599
- },
600
- {
601
- prev_node: "VoteOpened",
602
- next_node: "Voting",
603
- threshold: 1,
604
- forwards: [{ name: "StartVoting", weight: 1, permission_index: 3 }],
605
- },
606
- {
607
- prev_node: "Voting",
608
- next_node: "Approved",
609
- threshold: "${threshold_total}",
610
- forwards: [
611
- {
612
- name: "ChiefVote",
613
- weight: "${chief_weight}",
614
- permission_index: 2,
615
- guard: "arb_voting_guard",
616
- retained_submission: "chief_vote_record",
617
- },
618
- {
619
- name: "MemberVote",
620
- weight: 8,
621
- named_operator: "member",
622
- guard: "arb_voting_guard",
623
- retained_submission: "member_vote_record",
624
- },
625
- ],
626
- },
627
- {
628
- prev_node: "Voting",
629
- next_node: "Rejected",
630
- threshold: 1,
631
- forwards: [
632
- {
633
- name: "TimeoutReject",
634
- weight: 1,
635
- permission_index: 3,
636
- guard: "voting_timeout_guard",
637
- },
638
- ],
639
- },
640
- ],
641
- required_guards: [
642
- {
643
- guard_template_id: "tpl_voting_guard_numeric_weight",
644
- bound_to_forward: "ChiefVote",
645
- purpose: "Verify voting eligibility + extract weight from Arbitration",
646
- },
647
- {
648
- guard_template_id: "tpl_voting_guard_numeric_weight",
649
- bound_to_forward: "MemberVote",
650
- purpose: "Verify voting eligibility + prevent double-vote",
651
- },
652
- ],
653
- required_permissions: [
654
- { index: 2, name: "chief", description: "Chief voter (high weight)" },
655
- { index: 3, name: "admin", description: "Vote opener / timeout trigger" },
656
- ],
657
- required_allocators: [
658
- {
659
- name: "ApprovedAllocation",
660
- trigger_node: "Approved",
661
- description: "Allocation on approval",
662
- },
663
- ],
664
- forkable_fields: ["weights", "voter_count", "timeout_days"],
665
- applicable_industries: ["governance", "arbitration", "dao"],
666
- relevant_risks: [
667
- "R-M1-08", "R-M2-05", "R-M3-04", "R-M5-04",
668
- "R-X1-14",
669
- ],
670
- creation_notes: [
671
- "Member weight must be extracted dynamically via Guard query (not hardcoded in Forward)",
672
- "Guard MUST check arb.voted has [Signer] to prevent double-voting (R-X1-14 CRITICAL)",
673
- "Competing Pair: Approved vs Rejected (timeout) — first-wins",
674
- "Voting weight is query-derived; Forward weight field is just session counter",
675
- ],
676
- example_use_case: "Arbitration panel: 1 chief (weight 60) + 5 members (weight 8 each = 40). " +
677
- "Need total >= 100 to approve. Reject after 72h timeout.",
678
- publish_checklist: [
679
- "Arbitration object created and tested",
680
- "Double-vote prevention verified (try voting twice — should fail)",
681
- "Weight extraction tested with different voter configurations",
682
- "Timeout Guard (Clock) verified on testnet",
683
- ],
684
- },
685
- {
686
- id: "tpl_machine_cross_machine",
687
- scene_id: "cross_machine_supply_chain",
688
- name: "Cross-Machine Supply Chain",
689
- description: "Decomposed supply chain across multiple Machines. Machine B's Forward Guard queries Machine A's Progress " +
690
- "via convert_witness=100 to verify upstream completion before advancing.",
691
- recommended_patterns: ["P-M-CROSS-MACHINE"],
692
- recommended_topology: ["P-M-LINEAR"],
693
- parameters: [
694
- {
695
- name: "machine_a_id",
696
- type: "machine_ref",
697
- required: true,
698
- description: "Upstream Machine (must already be published)",
699
- constraint: "Machine A must be published BEFORE Machine B's Guard can reference its Progress " +
700
- "(indirect via progress::new -> assert_published, see 06 §14.6)",
701
- },
702
- {
703
- name: "machine_a_complete_node",
704
- type: "string",
705
- required: true,
706
- default: "Complete",
707
- description: "Target node name in Machine A to verify",
708
- },
709
- {
710
- name: "machine_b_permission",
711
- type: "permission_ref",
712
- required: true,
713
- description: "Machine B's Permission object",
714
- },
715
- ],
716
- example_nodes: [
717
- { name: "UpstreamVerified" },
718
- { name: "Production" },
719
- { name: "Complete" },
720
- ],
721
- example_pairs: [
722
- {
723
- prev_node: "",
724
- next_node: "UpstreamVerified",
725
- threshold: 1,
726
- forwards: [
727
- {
728
- name: "VerifyUpstream",
729
- weight: 1,
730
- permission_index: 2,
731
- guard: "upstream_progress_guard",
732
- retained_submission: "upstream_progress_id",
733
- },
734
- ],
735
- },
736
- {
737
- prev_node: "UpstreamVerified",
738
- next_node: "Production",
739
- threshold: 1,
740
- forwards: [{ name: "StartProduction", weight: 1, permission_index: 2 }],
741
- },
742
- {
743
- prev_node: "Production",
744
- next_node: "Complete",
745
- threshold: 1,
746
- forwards: [{ name: "Finish", weight: 1, permission_index: 2 }],
747
- },
748
- ],
749
- required_guards: [
750
- {
751
- guard_template_id: "tpl_forward_node_check",
752
- bound_to_forward: "VerifyUpstream",
753
- purpose: "Query Machine A's Progress: verify it reached ${machine_a_complete_node}",
754
- },
755
- ],
756
- required_permissions: [
757
- { index: 2, name: "manufacturer", description: "Machine B operator" },
758
- ],
759
- required_allocators: [
760
- {
761
- name: "CompleteAllocation",
762
- trigger_node: "Complete",
763
- description: "Allocation to Machine B's merchant",
764
- },
765
- ],
766
- forkable_fields: ["upstream_machine_ref", "verification_node_name"],
767
- applicable_industries: ["manufacturing", "logistics", "retail", "supply_chain"],
768
- relevant_risks: [
769
- "R-M1-01", "R-M1-08", "R-M2-01", "R-M2-04", "R-M3-04",
770
- "R-M5-04", "R-M5-05", "R-M5-06",
771
- ],
772
- creation_notes: [
773
- "Machine A MUST be published before Machine B (dependency order)",
774
- "Guard uses convert_witness=100 to convert submitted Order/Progress ID into queryable Progress object",
775
- "Cross-Machine dependency is one-way (no cycles)",
776
- "retained_submission stores upstream Progress ID for later audit",
777
- "Multi-party chain: extend pattern with Machine C, D, ... (each independently published)",
778
- "Dependency verification: indirect via progress::new -> assert_published (see 06 §14.6)",
779
- ],
780
- example_use_case: "Supplier (Machine A) -> Manufacturer (Machine B) -> Retailer (Machine C). " +
781
- "Manufacturer cannot start production until supplier's Progress reaches 'Complete'.",
782
- publish_checklist: [
783
- "Machine A already published on-chain (verify via onchain_objects)",
784
- "Cross-Machine Guard tested with valid/invalid upstream Progress IDs",
785
- "retained_submission verified (query progress_history for upstream_progress_id)",
786
- "Independent testing: run Machine A to Complete, then attempt Machine B's VerifyUpstream",
787
- ],
788
- },
789
- {
790
- id: "tpl_machine_privacy_delivery",
791
- scene_id: "privacy_delivery",
792
- name: "Privacy-Preserving Delivery Flow",
793
- description: "Customer submits privacy data via Messenger (encrypted, off-chain). Chain stores only Merkle Root Proof. " +
794
- "Guard verifies Proof signature + timestamp + service binding. Uses tpl_forward_privacy_delivery_proof (strict mode).",
795
- recommended_patterns: ["P-M-SEQ"],
796
- recommended_topology: ["P-M-LINEAR"],
797
- parameters: [
798
- { name: "merchant_permission", type: "permission_ref", required: true, description: "Merchant Permission object" },
799
- {
800
- name: "proof_node_name",
801
- type: "string",
802
- required: true,
803
- default: "ProofSubmitted",
804
- description: "Name of the node where delivery proof is submitted",
805
- },
806
- {
807
- name: "delivery_node_name",
808
- type: "string",
809
- required: true,
810
- default: "DeliveryConfirmed",
811
- description: "Name of the node where delivery confirmation occurs",
812
- },
813
- ],
814
- example_nodes: [
815
- { name: "Paid", description: "Entry: order created and paid via Service.buy(); Machine starts here" },
816
- { name: "${proof_node_name}", description: "Customer submits Proof via Messenger" },
817
- { name: "${delivery_node_name}" },
818
- { name: "Complete" },
819
- ],
820
- example_pairs: [
821
- {
822
- prev_node: "",
823
- next_node: "Paid",
824
- threshold: 1,
825
- forwards: [{ name: "Enter", weight: 1, named_operator: "" }],
826
- },
827
- {
828
- prev_node: "Paid",
829
- next_node: "${proof_node_name}",
830
- threshold: 1,
831
- forwards: [
832
- {
833
- name: "SubmitProof",
834
- weight: 1,
835
- named_operator: "",
836
- guard: "tpl_forward_privacy_delivery_proof",
837
- retained_submission: "proof_address",
838
- },
839
- ],
840
- },
841
- {
842
- prev_node: "${proof_node_name}",
843
- next_node: "${delivery_node_name}",
844
- threshold: 1,
845
- forwards: [{ name: "ConfirmDelivery", weight: 1, permission_index: 2 }],
846
- },
847
- {
848
- prev_node: "${delivery_node_name}",
849
- next_node: "Complete",
850
- threshold: 1,
851
- forwards: [{ name: "Finish", weight: 1, permission_index: 2 }],
852
- },
853
- ],
854
- required_guards: [
855
- {
856
- guard_template_id: "tpl_forward_privacy_delivery_proof",
857
- bound_to_forward: "SubmitProof",
858
- purpose: "Verify Proof: signer=proof.signer ∧ proof.time>order.time ∧ order.service=service",
859
- },
860
- ],
861
- required_permissions: [
862
- { index: 2, name: "merchant", description: "Merchant confirms delivery" },
863
- ],
864
- required_allocators: [
865
- {
866
- name: "CompleteAllocation",
867
- trigger_node: "Complete",
868
- description: "Allocation to merchant after delivery confirmation",
869
- },
870
- ],
871
- forkable_fields: ["proof_node_name", "delivery_node_name", "additional_evidence_steps"],
872
- applicable_industries: ["ecommerce", "logistics", "privacy_service"],
873
- relevant_risks: [
874
- "R-M1-01", "R-M1-08", "R-M2-01", "R-M2-04", "R-M3-02",
875
- "R-M5-03",
876
- ],
877
- creation_notes: [
878
- "Use strict mode tpl_forward_privacy_delivery_proof (3 conditions: Signer + time + service binding)",
879
- "submitChainProof about_address = peerAddress (NOT sessionId)",
880
- "order_id passed via description string field (not about_address)",
881
- "Guard table item name MUST be <64 BCS bytes (MAX_NAME_LENGTH=64)",
882
- "retained_submission stores Proof address for arbitration query",
883
- "Proof MUST be generated by messenger.submitChainProof (not manual)",
884
- ],
885
- example_use_case: "Customer sends delivery address via Messenger (encrypted). Chain stores only Proof. " +
886
- "Merchant verifies Proof, then confirms delivery.",
887
- publish_checklist: [
888
- "Strict mode Guard tested: 3 conditions verified individually",
889
- "Messenger integration tested end-to-end (submit + verify)",
890
- "retained_submission stored Proof address queryable from progress_history",
891
- "Guard table item name length validated (<64 BCS bytes)",
892
- ],
893
- },
894
- {
895
- id: "tpl_machine_reward",
896
- scene_id: "reward_incentive",
897
- name: "Reward Incentive Flow",
898
- description: "Customer triggers Reward claim at specific node. Guard prevents double-claim via query_reward_record_count==0. " +
899
- "Reward object independent of Allocator.",
900
- recommended_patterns: ["P-M-SEQ"],
901
- recommended_topology: ["P-M-LINEAR"],
902
- parameters: [
903
- {
904
- name: "reward_ref",
905
- type: "reward_ref",
906
- required: true,
907
- description: "Reward object address (must be already created)",
908
- },
909
- {
910
- name: "claim_node_name",
911
- type: "string",
912
- required: true,
913
- default: "ClaimReward",
914
- description: "Name of the node where reward claims are triggered",
915
- },
916
- ],
917
- example_nodes: [
918
- { name: "Eligible" },
919
- { name: "${claim_node_name}" },
920
- { name: "Rewarded" },
921
- { name: "Complete" },
922
- ],
923
- example_pairs: [
924
- {
925
- prev_node: "",
926
- next_node: "Eligible",
927
- threshold: 1,
928
- forwards: [{ name: "Enter", weight: 1, named_operator: "" }],
929
- },
930
- {
931
- prev_node: "Eligible",
932
- next_node: "${claim_node_name}",
933
- threshold: 1,
934
- forwards: [
935
- {
936
- name: "TriggerClaim",
937
- weight: 1,
938
- named_operator: "",
939
- guard: "reward_anti_double_guard",
940
- retained_submission: "claim_record",
941
- },
942
- ],
943
- },
944
- {
945
- prev_node: "${claim_node_name}",
946
- next_node: "Rewarded",
947
- threshold: 1,
948
- forwards: [{ name: "IssueReward", weight: 1, permission_index: 3 }],
949
- },
950
- {
951
- prev_node: "Rewarded",
952
- next_node: "Complete",
953
- threshold: 1,
954
- forwards: [{ name: "Finish", weight: 1, permission_index: 2 }],
955
- },
956
- ],
957
- required_guards: [
958
- {
959
- guard_template_id: "tpl_reward_one_time_claim",
960
- bound_to_forward: "TriggerClaim",
961
- purpose: "Verify query_reward_record_count==0 to prevent double-claim",
962
- },
963
- ],
964
- required_permissions: [
965
- { index: 2, name: "merchant", description: "Completes flow" },
966
- { index: 3, name: "reward_admin", description: "Issues reward tokens" },
967
- ],
968
- required_allocators: [
969
- {
970
- name: "CompleteAllocation",
971
- trigger_node: "Complete",
972
- description: "Standard allocation (separate from Reward)",
973
- },
974
- ],
975
- forkable_fields: ["claim_node_name", "additional_reward_conditions"],
976
- applicable_industries: ["ecommerce", "subscription", "education", "loyalty"],
977
- relevant_risks: [
978
- "R-M1-08", "R-M2-05", "R-M3-04",
979
- "R-X1-14",
980
- ],
981
- creation_notes: [
982
- "Reward Guard MUST check query_reward_record_count == 0 (R-X1-14 CRITICAL)",
983
- "Reward is INDEPENDENT of Allocator — both can fire on different nodes",
984
- "Reward object must be created BEFORE publishing this Machine",
985
- "retained_submission stores claim record for audit",
986
- ],
987
- example_use_case: "Loyalty program: after customer completes 5 orders, eligible to claim reward token. " +
988
- "Anti-double-claim Guard ensures one claim per customer.",
989
- publish_checklist: [
990
- "Reward object already created and tested",
991
- "Anti-double-claim Guard tested: claim twice should fail on second attempt",
992
- "retained_submission verified (claim_record queryable)",
993
- ],
994
- },
995
- {
996
- id: "tpl_machine_wonder_feedback",
997
- scene_id: "wonder_feedback",
998
- name: "Wonder Feedback Flow (Post-Completion Rating)",
999
- description: "Post-completion rating flow: Paid (entry) → Shipped → Received → Completed → {Wonder | NoWonder}. " +
1000
- "After the order reaches 'Completed' (terminal business state, funds already allocated to merchant), " +
1001
- "the OrderHolder (namedOperator='') can advance Progress to 'wonder' (positive review) or 'no_wonder' " +
1002
- "(negative review). A bound Reward object's claim_guard verifies Progress.current == 'wonder' before " +
1003
- "paying out — reward claim needs NO Permission. Dispute is NEVER modeled here: it flows through " +
1004
- "Order → Arbitration.dispute() → Arb → arbitration() ruling → arb_withdraw, fully off-Machine.",
1005
- recommended_patterns: ["P-M-SEQ", "P-M-COMPETING"],
1006
- recommended_topology: ["P-M-LINEAR", "P-M-COMPETING"],
1007
- parameters: [
1008
- {
1009
- name: "merchant_permission",
1010
- type: "permission_ref",
1011
- required: true,
1012
- description: "Merchant Permission object (index 2 = merchant, index 3 = admin)",
1013
- },
1014
- {
1015
- name: "wonder_node_name",
1016
- type: "string",
1017
- required: true,
1018
- default: "wonder",
1019
- description: "Node name for positive feedback (praise) terminal",
1020
- constraint: "Must match /^(wonder|praise|thumbs_up)$/i OR be a custom name; must NOT match dispute anti-pattern regex",
1021
- },
1022
- {
1023
- name: "no_wonder_node_name",
1024
- type: "string",
1025
- required: true,
1026
- default: "no_wonder",
1027
- description: "Node name for negative feedback (complaint) terminal",
1028
- constraint: "Must match /^(no_wonder|complain|thumbs_down)$/i OR be a custom name; must NOT match dispute anti-pattern regex",
1029
- },
1030
- {
1031
- name: "reward_ref",
1032
- type: "reward_ref",
1033
- required: false,
1034
- description: "Reward object address (optional). If bound, its claim_guard should verify Progress.current == wonder_node_name AND order.holder == signer. Use wonder_praise or wonder_feedback reward template.",
1035
- },
1036
- {
1037
- name: "rating_time_limit_days",
1038
- type: "number",
1039
- required: false,
1040
- default: "30",
1041
- description: "Days after completion during which the customer can rate (enforced by Guard on Praise/Complain forwards via context(Clock))",
1042
- constraint: "Must be > 0; reasonable range 7-90",
1043
- },
1044
- ],
1045
- example_nodes: [
1046
- { name: "Paid", description: "Entry: order created and paid via Service.buy(); Machine starts here" },
1047
- { name: "Shipped", description: "Merchant dispatched goods/service" },
1048
- { name: "Received", description: "Customer confirmed receipt" },
1049
- { name: "Completed", description: "Terminal business state — triggers merchant Allocation. Funds settled." },
1050
- { name: "${wonder_node_name}", description: "Positive feedback terminal (praise). OrderHolder-only. Reward-eligible." },
1051
- { name: "${no_wonder_node_name}", description: "Negative feedback terminal (complaint). OrderHolder-only. Optional Repository write for analytics." },
1052
- ],
1053
- example_pairs: [
1054
- {
1055
- prev_node: "",
1056
- next_node: "Paid",
1057
- threshold: 1,
1058
- forwards: [{ name: "Enter", weight: 1, named_operator: "" }],
1059
- },
1060
- {
1061
- prev_node: "Paid",
1062
- next_node: "Shipped",
1063
- threshold: 1,
1064
- forwards: [{ name: "Ship", weight: 1, permission_index: 2, named_operator: "" }],
1065
- },
1066
- {
1067
- prev_node: "Shipped",
1068
- next_node: "Received",
1069
- threshold: 1,
1070
- forwards: [{ name: "ConfirmReceive", weight: 1, named_operator: "" }],
1071
- },
1072
- {
1073
- prev_node: "Received",
1074
- next_node: "Completed",
1075
- threshold: 1,
1076
- forwards: [{ name: "Finish", weight: 1, permission_index: 2, named_operator: "" }],
1077
- },
1078
- {
1079
- prev_node: "Completed",
1080
- next_node: "${wonder_node_name}",
1081
- threshold: 1,
1082
- forwards: [
1083
- {
1084
- name: "Praise",
1085
- weight: 1,
1086
- named_operator: "",
1087
- guard: "rating_window_guard",
1088
- retained_submission: "rating_record",
1089
- },
1090
- ],
1091
- },
1092
- {
1093
- prev_node: "Completed",
1094
- next_node: "${no_wonder_node_name}",
1095
- threshold: 1,
1096
- forwards: [
1097
- {
1098
- name: "Complain",
1099
- weight: 1,
1100
- named_operator: "",
1101
- guard: "rating_window_guard",
1102
- retained_submission: "rating_record",
1103
- },
1104
- ],
1105
- },
1106
- ],
1107
- required_guards: [
1108
- {
1109
- guard_template_id: "tpl_forward_node_check",
1110
- bound_to_forward: "Praise",
1111
- purpose: "Verify Progress.current == 'Completed' (rating only allowed after completion) AND context(Clock) <= progress.entry_time + rating_time_limit_days",
1112
- },
1113
- {
1114
- guard_template_id: "tpl_forward_node_check",
1115
- bound_to_forward: "Complain",
1116
- purpose: "Verify Progress.current == 'Completed' (rating only allowed after completion) AND context(Clock) <= progress.entry_time + rating_time_limit_days",
1117
- },
1118
- ],
1119
- required_permissions: [
1120
- { index: 2, name: "merchant", description: "Merchant role for Ship + Finish (NOT for rating — rating is OrderHolder-only via named_operator='')" },
1121
- { index: 3, name: "admin", description: "Admin override (optional)" },
1122
- ],
1123
- required_allocators: [
1124
- {
1125
- name: "MerchantAllocation",
1126
- trigger_node: "Completed",
1127
- description: "100% to merchant Treasury or personal address. Fires at Completion — NOT at Wonder/NoWonder (those are reputation-only terminals with no fund flow).",
1128
- },
1129
- ],
1130
- forkable_fields: ["wonder_node_name", "no_wonder_node_name", "rating_time_limit_days", "additional_rating_nodes"],
1131
- applicable_industries: ["ecommerce", "service", "rental", "subscription", "education"],
1132
- relevant_risks: [
1133
- "R-M1-01", "R-M1-02", "R-M1-08", "R-M1-11",
1134
- "R-M2-01", "R-M2-05",
1135
- "R-M3-02", "R-M3-04",
1136
- "R-M4-01", "R-M5-03",
1137
- ],
1138
- creation_notes: [
1139
- "DISPUTE INDEPENDENCE: This Machine MUST NOT contain 'disputed', 'refunded', 'arb', 'arbitration' nodes (R-M1-11 critical). Disputes are filed off-Machine via arbitration::dispute(order, arbitration).",
1140
- "Build order: Permission → Machine (unpublished) → Guards → Bind guards → Publish → Bind to Service → Bind Reward (optional)",
1141
- "First node 'Paid' represents post-payment state — Service.buy() completes payment atomically before Progress is created",
1142
- "No separate 'Order' or 'Pay' nodes needed — payment is handled by Service.buy(), not Machine",
1143
- "Wonder/NoWonder forwards have named_operator='' (empty) — this delegates to the OrderHolder (customer). No Permission index needed for rating.",
1144
- "Completed node triggers MerchantAllocation — funds are settled BEFORE the rating window opens. Rating does NOT affect fund flow.",
1145
- "Competing Pair: Praise vs Complain (first-wins) — one rating per order, enforced by Guard + retained_submission audit trail.",
1146
- "Reward object (if bound) is INDEPENDENT of Allocator: Reward.claim() requires Guard+passport, not Permission. Guard checks Progress.current == 'wonder' AND order.holder == signer.",
1147
- "rating_window_guard enforces time limit: context(Clock) <= progress.entry_time + rating_time_limit_days. After window closes, no rating possible (Completed becomes true terminal).",
1148
- "Optional: bind a Repository to record feedback node for analytics. Repository write happens via Guard's data extraction (NOT auto-passed — see 06 §14.4).",
1149
- ],
1150
- example_use_case: "Photography service: Paid → Shipped (booking confirmed) → Received (session delivered) → Completed " +
1151
- "(photos delivered, funds released to photographer) → customer advances to 'wonder' (loved the work) " +
1152
- "or 'no_wonder' (didn't love it). Bound Reward pays 1 WOW to customers who advance to 'wonder'. " +
1153
- "Merchant's wonder/no_wonder ratio becomes an on-chain reputation signal. Disputes (if any) are " +
1154
- "filed separately via Arbitration object — never enter this Machine.",
1155
- publish_checklist: [
1156
- "All 6 nodes verified: no 'disputed'/'refunded'/'arb'/'arbitration' names (R-M1-11 PASS)",
1157
- "Entry Pair exists (prev_node='' targets 'Paid')",
1158
- "Competing Pair tested: Praise vs Complain — first-wins semantics verified on testnet",
1159
- "rating_window_guard tested: rating blocked after time limit expires",
1160
- "MerchantAllocation fires ONLY at Completed (NOT at Wonder/NoWonder)",
1161
- "Reward object (if bound): claim_guard tested — Progress.current == 'wonder' required, claim fails at 'no_wonder' or 'Completed'",
1162
- "named_operator='' on Praise/Complain forwards verified (OrderHolder-only operation)",
1163
- "machineNode2file export as backup",
1164
- ],
1165
- },
1166
- {
1167
- id: "tpl_machine_subscription",
1168
- scene_id: "subscription",
1169
- name: "Subscription / Membership Flow",
1170
- description: "Subscribe -> Pay -> Activate -> [Renew | Expire] -> Cancel/End. Time-lock on Renew. " +
1171
- "Competing Pair: Renew vs Expire (first-wins). Repository stores subscription status.",
1172
- recommended_patterns: ["P-M-SEQ", "P-M-COMPETING"],
1173
- recommended_topology: ["P-M-LINEAR", "P-M-COMPETING"],
1174
- parameters: [
1175
- { name: "merchant_permission", type: "permission_ref", required: true, description: "Provider Permission object" },
1176
- {
1177
- name: "subscription_duration_days",
1178
- type: "number",
1179
- required: true,
1180
- default: "30",
1181
- description: "Days between Renew and Expire eligibility",
1182
- },
1183
- {
1184
- name: "repository_ref",
1185
- type: "address",
1186
- required: true,
1187
- description: "Repository object storing subscription status (note: not consensus_repositories, which is declarative-only — see 06 §14.4)",
1188
- },
1189
- ],
1190
- example_nodes: [
1191
- { name: "Paid", description: "Entry: subscription created and paid via Service.buy(); Machine starts here" },
1192
- { name: "Active" },
1193
- { name: "RenewEligible" },
1194
- { name: "Renewed" },
1195
- { name: "Expired" },
1196
- { name: "Cancelled" },
1197
- { name: "Ended" },
1198
- ],
1199
- example_pairs: [
1200
- {
1201
- prev_node: "",
1202
- next_node: "Paid",
1203
- threshold: 1,
1204
- forwards: [{ name: "Enter", weight: 1, named_operator: "" }],
1205
- },
1206
- {
1207
- prev_node: "Paid",
1208
- next_node: "Active",
1209
- threshold: 1,
1210
- forwards: [
1211
- {
1212
- name: "Activate",
1213
- weight: 1,
1214
- permission_index: 2,
1215
- guard: "repository_write_guard",
1216
- },
1217
- ],
1218
- },
1219
- {
1220
- prev_node: "Active",
1221
- next_node: "RenewEligible",
1222
- threshold: 1,
1223
- forwards: [
1224
- {
1225
- name: "TimeUnlock",
1226
- weight: 1,
1227
- permission_index: 3,
1228
- guard: "time_lock_guard_${subscription_duration_days}_days",
1229
- },
1230
- ],
1231
- },
1232
- {
1233
- prev_node: "RenewEligible",
1234
- next_node: "Renewed",
1235
- threshold: 1,
1236
- forwards: [{ name: "Renew", weight: 1, named_operator: "" }],
1237
- },
1238
- {
1239
- prev_node: "RenewEligible",
1240
- next_node: "Expired",
1241
- threshold: 1,
1242
- forwards: [
1243
- {
1244
- name: "AutoExpire",
1245
- weight: 1,
1246
- permission_index: 3,
1247
- guard: "expire_time_guard",
1248
- },
1249
- ],
1250
- },
1251
- {
1252
- prev_node: "RenewEligible",
1253
- next_node: "Cancelled",
1254
- threshold: 1,
1255
- forwards: [{ name: "Cancel", weight: 1, named_operator: "" }],
1256
- },
1257
- {
1258
- prev_node: "Renewed",
1259
- next_node: "Active",
1260
- threshold: 1,
1261
- forwards: [{ name: "Reactivate", weight: 1, permission_index: 2 }],
1262
- },
1263
- {
1264
- prev_node: "Expired",
1265
- next_node: "Ended",
1266
- threshold: 1,
1267
- forwards: [{ name: "CloseExpired", weight: 1, permission_index: 3 }],
1268
- },
1269
- {
1270
- prev_node: "Cancelled",
1271
- next_node: "Ended",
1272
- threshold: 1,
1273
- forwards: [{ name: "CloseCancelled", weight: 1, permission_index: 2 }],
1274
- },
1275
- ],
1276
- required_guards: [
1277
- {
1278
- guard_template_id: "tpl_forward_node_check",
1279
- bound_to_forward: "TimeUnlock",
1280
- purpose: "Time lock: context(Clock) >= progress.entry_time + ${subscription_duration_days} days",
1281
- },
1282
- {
1283
- guard_template_id: "tpl_write_guard_type_check",
1284
- bound_to_forward: "Activate",
1285
- purpose: "Write subscription status to Repository",
1286
- },
1287
- {
1288
- guard_template_id: "tpl_forward_node_check",
1289
- bound_to_forward: "AutoExpire",
1290
- purpose: "Hard expire: context(Clock) >= progress.entry_time + 2x duration",
1291
- },
1292
- ],
1293
- required_permissions: [
1294
- { index: 2, name: "provider", description: "Provider activates/reactivates" },
1295
- { index: 3, name: "admin", description: "Time-lock triggers" },
1296
- ],
1297
- required_allocators: [
1298
- {
1299
- name: "RenewAllocation",
1300
- trigger_node: "Renewed",
1301
- description: "Charge renewal fee on Renew",
1302
- },
1303
- ],
1304
- forkable_fields: ["duration_days", "grace_period", "additional_tiers"],
1305
- applicable_industries: ["subscription", "saas", "membership", "service"],
1306
- relevant_risks: [
1307
- "R-M1-01", "R-M1-08", "R-M2-01", "R-M2-05",
1308
- "R-M3-02", "R-M3-04", "R-M4-01", "R-M5-04",
1309
- ],
1310
- creation_notes: [
1311
- "First node 'Paid' represents post-payment state — Service.buy() completes subscription payment atomically before Progress is created",
1312
- "No separate 'Subscribe' or 'Pay' nodes needed — subscription and payment are handled by Service.buy(), not Machine",
1313
- "Time-lock uses context(Clock) — verify Clock address in Guard table",
1314
- "Competing Pair: Renew vs Expire vs Cancel — first-wins",
1315
- "Renewed node loops back to Active (recurring subscription)",
1316
- "Repository records subscription status for cross-Machine verification",
1317
- "Renewal Allocation triggers on Renewed node (not Active — avoids double-charge)",
1318
- "Note: consensus_repositories is declarative-only (NOT auto-passed to Progress); use repository_ref parameter for actual Repository object — see 06 §14.4",
1319
- "VARIANT — Content subscription (Substack-style): replace time-lock Renew/Expire with content-delivery flow:",
1320
- " 6-node variant: Paid (entry) → ContentPublished → Completed (terminal-success)",
1321
- " Paid → Cancelled (terminal-cancel) | Paid → Disputed → Refunded (terminal-dispute)",
1322
- " Permission: author=index 1000 (publish + cancel), arbitrator=index 1500 (resolve dispute), reader=namedOperator='' (open role, no specific operator)",
1323
- " Guards: deliver_guard (verify author permission + content hash), cancel_guard (verify subscriber request), refund_guard (verify arbitration outcome)",
1324
- " Allocators: deliver=100% to author, cancel=100% refund to subscriber, dispute=100% refund to subscriber (Guard-first-wins pattern)",
1325
- " First-Forward-wins: when Paid has competing forwards (Deliver|Cancel|Dispute), the first triggered forward wins; subscribers cannot double-claim",
1326
- "CRITICAL — v1→v2 lesson: arbitrations MUST be added BEFORE Service.publish (post-publish, arbitrations become immutable and cannot be added — service.move F-S-21)",
1327
- " If you accidentally published without arbitrations, you MUST create a new Service v2 with arbitrations bound before publishing (the v1 Service must be paused/abandoned)",
1328
- " ConfirmGate (C-S-19, QS11) will warn before publish without arbitrations — do not bypass this warning unless explicitly intending no-arbitration operation",
1329
- "Build order (content variant): Permission → Machine (unpublished, with initial forward) → 3 Guards → 3 Allocators (template on Service) → Service (unpublished, bind machine+buy_guard+order_allocators+arbitrations) → Publish Service → Test order (3 paths: normal/cancel/dispute)",
1330
- ],
1331
- example_use_case: "Monthly SaaS subscription: $10/month. Customer can renew anytime after day 25. " +
1332
- "Auto-expire on day 35 if not renewed. Cancel anytime.\n\n" +
1333
- "VARIANT — Content subscription (Substack-style): $5/month newsletter. Author publishes content → " +
1334
- "subscriber reads. Subscriber can cancel anytime for full refund. Disputes resolved by arbitrator " +
1335
- "(100% refund to subscriber if dispute upheld). 6-node Machine, 3 Guards, 3 Allocators. " +
1336
- "Tested on testnet with 3 order paths: normal delivery, cancel, dispute.",
1337
- publish_checklist: [
1338
- "Time-lock Guards tested on testnet (both TimeUnlock + AutoExpire)",
1339
- "Competing Pair semantics verified (Renew vs Expire vs Cancel)",
1340
- "Repository write tested (subscription status queryable)",
1341
- "Renewal loop tested: Paid -> Active -> RenewEligible -> Renewed -> Active",
1342
- "Content variant: initial node (prev_node='') MUST have at least one forward (FIX-002) — empty forwards=[] causes Progress to be permanently stuck",
1343
- "Content variant: arbitrations added BEFORE publish (cannot add post-publish per F-S-21)",
1344
- "Content variant: 3 order paths tested on testnet — normal delivery, cancel-within-grace, dispute-resolution",
1345
- "Content variant: machineNode2file export as backup (covers all 6 nodes)",
1346
- ],
1347
- },
1348
- ];
1349
- export const MACHINE_TEMPLATES_VERSION = "1.0.0";
1350
- export const MACHINE_TEMPLATES_COUNT = MACHINE_TEMPLATES.length;
1351
- export function getAllTemplates() {
1352
- return MACHINE_TEMPLATES;
1353
- }
1354
- export function getTemplateById(id) {
1355
- return MACHINE_TEMPLATES.find((t) => t.id === id);
1356
- }
1357
- export function getTemplatesByScene(scene_id) {
1358
- return MACHINE_TEMPLATES.filter((t) => t.scene_id === scene_id);
1359
- }
1360
- export function getTemplatesByIndustry(industry) {
1361
- return MACHINE_TEMPLATES.filter((t) => t.applicable_industries.includes(industry));
1362
- }
1363
- export function getTemplatesByPattern(patternId) {
1364
- return MACHINE_TEMPLATES.filter((t) => t.recommended_patterns.includes(patternId));
1365
- }
1366
- export function suggestTemplateForIntent(intent) {
1367
- const scene = inferSceneFromFlow(intent);
1368
- if (!scene)
1369
- return undefined;
1370
- const templates = getTemplatesByScene(scene.id);
1371
- return templates[0];
1372
- }
1373
- export function getTemplateParameters(templateId) {
1374
- const template = getTemplateById(templateId);
1375
- return template ? template.parameters : [];
1376
- }
1377
- export function getRequiredParameters(templateId) {
1378
- return getTemplateParameters(templateId).filter((p) => p.required);
1379
- }
1380
- export function getOptionalParameters(templateId) {
1381
- return getTemplateParameters(templateId).filter((p) => !p.required);
1382
- }
1383
- function validateParamType(value, type) {
1384
- switch (type) {
1385
- case "address":
1386
- case "string":
1387
- case "permission_ref":
1388
- case "guard_ref":
1389
- case "machine_ref":
1390
- case "service_ref":
1391
- case "arbitration_ref":
1392
- case "reward_ref":
1393
- return typeof value === "string";
1394
- case "number":
1395
- return typeof value === "number" || (typeof value === "string" && /^\d+$/.test(value));
1396
- case "boolean":
1397
- return typeof value === "boolean";
1398
- case "vec_address":
1399
- case "vec_string":
1400
- case "node_name_list":
1401
- return Array.isArray(value) && value.every((v) => typeof v === "string");
1402
- default:
1403
- return false;
1404
- }
1405
- }
1406
- function deepSubstitute(obj, params) {
1407
- if (typeof obj === "string") {
1408
- return obj.replace(/\$\{(\w+)\}/g, (_, key) => key in params ? String(params[key]) : `\${${key}}`);
1409
- }
1410
- if (Array.isArray(obj)) {
1411
- return obj.map((item) => deepSubstitute(item, params));
1412
- }
1413
- if (obj && typeof obj === "object") {
1414
- const result = {};
1415
- for (const [k, v] of Object.entries(obj)) {
1416
- result[k] = deepSubstitute(v, params);
1417
- }
1418
- return result;
1419
- }
1420
- return obj;
1421
- }
1422
- export function fillTemplate(templateId, params) {
1423
- const template = getTemplateById(templateId);
1424
- if (!template) {
1425
- return {
1426
- success: false,
1427
- validation_errors: [`Template not found: ${templateId}`],
1428
- };
1429
- }
1430
- const missing = template.parameters
1431
- .filter((p) => p.required && !(p.name in params))
1432
- .map((p) => p.name);
1433
- if (missing.length > 0) {
1434
- return {
1435
- success: false,
1436
- missing_params: missing,
1437
- validation_errors: [`Missing required parameters: ${missing.join(", ")}`],
1438
- };
1439
- }
1440
- const errors = [];
1441
- for (const param of template.parameters) {
1442
- if (param.name in params) {
1443
- const value = params[param.name];
1444
- if (!validateParamType(value, param.type)) {
1445
- errors.push(`Parameter "${param.name}" type mismatch: expected ${param.type}, got ${typeof value}`);
1446
- }
1447
- }
1448
- }
1449
- if (errors.length > 0) {
1450
- return { success: false, validation_errors: errors };
1451
- }
1452
- const filled_nodes = deepSubstitute(template.example_nodes, params);
1453
- const filled_pairs = deepSubstitute(template.example_pairs, params);
1454
- return { success: true, filled_nodes, filled_pairs };
1455
- }
1456
- export function forkTemplate(templateId) {
1457
- const template = getTemplateById(templateId);
1458
- if (!template)
1459
- return undefined;
1460
- const current_values = {};
1461
- for (const field of template.forkable_fields) {
1462
- current_values[field] = "see example_nodes/example_pairs";
1463
- }
1464
- return {
1465
- template_id: templateId,
1466
- forkable_fields: template.forkable_fields,
1467
- current_values,
1468
- instructions: [
1469
- "Modify fields below to customize the workflow",
1470
- "Keep template structure intact unless explicitly noted",
1471
- "Run risk assessment after modification (machine-risk.ts)",
1472
- "User MUST confirm final JSON before publish (ConfirmGate)",
1473
- ],
1474
- };
1475
- }
1476
- export const DECISION_TREE = {
1477
- Q1: {
1478
- question: "Does the workflow involve multiple independent services/parties?",
1479
- no_next: "Q3",
1480
- },
1481
- Q2: {
1482
- question: "Are these services already published as separate Machines?",
1483
- yes_template: "tpl_machine_cross_machine",
1484
- no_next: "DECOMPOSE",
1485
- },
1486
- Q3: {
1487
- question: "Does any node require multiple parties' confirmation to advance?",
1488
- no_next: "Q5",
1489
- },
1490
- Q4: {
1491
- question: "Do all parties have EQUAL weight?",
1492
- yes_template: "tpl_machine_dual_signature",
1493
- no_next: "tpl_machine_weighted_voting",
1494
- },
1495
- Q5: {
1496
- question: "Does the workflow need exception branches (lost, return, dispute)?",
1497
- yes_template: "tpl_machine_ecommerce_exceptions",
1498
- no_next: "Q6",
1499
- },
1500
- Q6: {
1501
- question: "Does it involve recurring payments or time-based state changes?",
1502
- yes_template: "tpl_machine_subscription",
1503
- no_next: "Q7",
1504
- },
1505
- Q7: {
1506
- question: "Does it need privacy-preserving data delivery (Messenger)?",
1507
- yes_template: "tpl_machine_privacy_delivery",
1508
- no_next: "Q8",
1509
- },
1510
- Q8: {
1511
- question: "Does it involve deposit/refund separation?",
1512
- yes_template: "tpl_machine_rental",
1513
- no_next: "Q9",
1514
- },
1515
- Q9: {
1516
- question: "Does it need reward/incentive distribution at a specific node?",
1517
- yes_template: "tpl_machine_reward",
1518
- no_next: "tpl_machine_ecommerce_standard",
1519
- },
1520
- };
1521
- export function walkDecisionTree(answers) {
1522
- let current = "Q1";
1523
- while (current) {
1524
- const node = DECISION_TREE[current];
1525
- if (!node)
1526
- return "UNKNOWN";
1527
- const answer = answers[current];
1528
- if (answer === undefined)
1529
- return current;
1530
- if (answer) {
1531
- if (node.yes_template)
1532
- return node.yes_template;
1533
- if (current === "Q1") {
1534
- current = "Q2";
1535
- continue;
1536
- }
1537
- if (current === "Q3") {
1538
- current = "Q4";
1539
- continue;
1540
- }
1541
- return "UNKNOWN";
1542
- }
1543
- else {
1544
- if (node.no_next) {
1545
- if (node.no_next === "DECOMPOSE") {
1546
- return "DECOMPOSE_INTO_MULTIPLE_MACHINES";
1547
- }
1548
- if (node.no_next.startsWith("tpl_")) {
1549
- return node.no_next;
1550
- }
1551
- current = node.no_next;
1552
- continue;
1553
- }
1554
- return "UNKNOWN";
1555
- }
1556
- }
1557
- return "UNKNOWN";
1558
- }
1559
- export function verifyTemplateSceneReferences() {
1560
- const invalid = [];
1561
- for (const template of MACHINE_TEMPLATES) {
1562
- if (!findScene(template.scene_id)) {
1563
- invalid.push({
1564
- template_id: template.id,
1565
- invalid_scene_id: template.scene_id,
1566
- });
1567
- }
1568
- }
1569
- return invalid;
1570
- }
1571
- export function getReferencedGuardTemplateIds() {
1572
- const ids = new Set();
1573
- for (const template of MACHINE_TEMPLATES) {
1574
- for (const ref of template.required_guards) {
1575
- ids.add(ref.guard_template_id);
1576
- }
1577
- }
1578
- return ids;
1579
- }
1580
- export function getReferencedRiskIds() {
1581
- const ids = new Set();
1582
- for (const template of MACHINE_TEMPLATES) {
1583
- for (const risk of template.relevant_risks) {
1584
- ids.add(risk);
1585
- }
1586
- }
1587
- return ids;
1588
- }
1589
- export function listTemplates() {
1590
- return MACHINE_TEMPLATES.map((t) => ({
1591
- id: t.id,
1592
- name: t.name,
1593
- scene_id: t.scene_id,
1594
- patterns: t.recommended_patterns,
1595
- industries: t.applicable_industries,
1596
- }));
1597
- }
1
+ import{findScene,inferSceneFromFlow}from'./machine-ledger.js';export const MACHINE_TEMPLATES=[{'id':'tpl_machine_ecommerce_standard','scene_id':'ecommerce_standard','name':'Standard\x20E-commerce\x20Flow','description':'Linear\x20e-commerce\x20workflow:\x20Paid\x20(entry)\x20->\x20Ship\x20->\x20Receive\x20->\x20Complete.\x20'+'Payment\x20is\x20handled\x20by\x20Service.buy()\x20atomically;\x20Machine\x20starts\x20at\x20post-payment\x20state.\x20'+'Funds\x20auto-allocated\x20to\x20merchant\x20at\x20Complete\x20node.\x20Recommended\x20baseline\x20for\x20new\x20merchants.','recommended_patterns':['P-M-SEQ'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Merchant\x20Permission\x20object\x20address\x20or\x20name\x20(must\x20have\x20custom\x20indices\x20defined)','constraint':'Permission\x20must\x20already\x20be\x20created;\x20index\x202\x20(merchant)\x20and\x20index\x203\x20(admin)\x20recommended'},{'name':'ship_forward_name','type':'string','required':!![],'default':'Ship','description':'Forward\x20name\x20for\x20shipping\x20step','constraint':'Must\x20be\x20<64\x20BCS\x20bytes;\x20only\x20letters/digits/underscore'},{'name':'receive_forward_name','type':'string','required':!![],'default':'Receive','description':'Forward\x20name\x20for\x20customer\x20receipt\x20confirmation'},{'name':'complete_node_name','type':'string','required':!![],'default':'Complete','description':'Terminal\x20node\x20name\x20triggering\x20fund\x20allocation'}],'example_nodes':[{'name':'Paid','description':'Entry:\x20order\x20created\x20and\x20paid\x20via\x20Service.buy();\x20Machine\x20starts\x20here'},{'name':'Shipped','description':'Goods\x20dispatched'},{'name':'Received','description':'Customer\x20confirmed\x20receipt'},{'name':'${complete_node_name}','description':'Terminal:\x20triggers\x20allocation'}],'example_pairs':[{'prev_node':'','next_node':'Paid','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':'','permission_index':0x0}]},{'prev_node':'Paid','next_node':'Shipped','threshold':0x1,'forwards':[{'name':'${ship_forward_name}','weight':0x1,'permission_index':0x2,'named_operator':''}]},{'prev_node':'Shipped','next_node':'Received','threshold':0x1,'forwards':[{'name':'${receive_forward_name}','weight':0x1,'named_operator':'','permission_index':0x0}]},{'prev_node':'Received','next_node':'${complete_node_name}','threshold':0x1,'forwards':[{'name':'Finish','weight':0x1,'permission_index':0x2,'named_operator':''}]}],'required_guards':[],'required_permissions':[{'index':0x2,'name':'merchant','description':'Merchant\x20role\x20for\x20Ship\x20+\x20Finish'},{'index':0x3,'name':'admin','description':'Admin\x20override\x20(optional)'}],'required_allocators':[{'name':'MerchantAllocation','trigger_node':'${complete_node_name}','description':'100%\x20to\x20merchant\x20Treasury\x20or\x20personal\x20address'}],'forkable_fields':['node_names','forward_names','thresholds','additional_branches'],'applicable_industries':['ecommerce','retail'],'relevant_risks':['R-M1-01','R-M1-02','R-M1-08','R-M2-01','R-M3-02','R-M4-01'],'creation_notes':['Build\x20order:\x20Permission\x20->\x20Machine\x20(unpublished)\x20->\x20Guards\x20->\x20Bind\x20guards\x20->\x20Publish\x20->\x20Bind\x20to\x20Service','First\x20node\x20\x27Paid\x27\x20represents\x20post-payment\x20state\x20—\x20Service.buy()\x20completes\x20payment\x20atomically\x20before\x20Progress\x20is\x20created','No\x20separate\x20\x27Order\x27\x20or\x20\x27Pay\x27\x20nodes\x20needed\x20—\x20payment\x20is\x20handled\x20by\x20Service.buy(),\x20not\x20Machine','Entry\x20point:\x20prev_node=\x27\x27\x20(empty\x20string)\x20targets\x20\x27Paid\x27\x20—\x20at\x20least\x20one\x20Pair\x20must\x20exist\x20with\x20empty\x20prev_node','If\x20using\x20P16\x20circular\x20reference\x20for\x20Service,\x20use\x20name\x20not\x20address\x20(Service\x20not\x20yet\x20published)'],'example_use_case':'Small\x20e-commerce\x20shop\x20selling\x20camera\x20accessories.\x20Linear\x20flow\x20with\x20no\x20exceptions.\x20'+'Funds\x20allocated\x20to\x20merchant\x20personal\x20address\x20on\x20Complete.','publish_checklist':['All\x204\x20nodes\x20have\x20at\x20least\x20one\x20outgoing\x20Forward\x20(except\x20terminal)','Entry\x20Pair\x20exists\x20(prev_node=\x27\x27\x20targets\x20\x27Paid\x27)','permissionIndex\x20values\x20match\x20Permission\x20object\x20indices','Test\x20Progress\x20run\x20on\x20testnet','machineNode2file\x20export\x20as\x20backup']},{'id':'tpl_machine_ecommerce_exceptions','scene_id':'ecommerce_with_exceptions','name':'E-commerce\x20Flow\x20with\x20Exception\x20Branches','description':'Multi-path\x20workflow:\x20Paid\x20(entry)\x20->\x20Ship\x20->\x20Receive/Lost/Return.\x20Lost\x20uses\x20dual-sig\x20(threshold=2).\x20'+'Payment\x20is\x20handled\x20by\x20Service.buy()\x20atomically;\x20Machine\x20starts\x20at\x20post-payment\x20state.\x20'+'Return\x20path\x20opens\x20Refund\x20->\x20Complete.\x20Competing\x20pairs\x20first-wins.','recommended_patterns':['P-M-SEQ','P-M-COMPETING'],'recommended_topology':['P-M-LINEAR','P-M-COMPETING'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Merchant\x20Permission\x20object'},{'name':'lost_threshold','type':'number','required':!![],'default':'2','description':'Threshold\x20for\x20dual-sig\x20on\x20Lost\x20node','constraint':'Must\x20be\x202\x20(customer\x20+\x20merchant)'},{'name':'arbitration_ref','type':'arbitration_ref','required':![],'description':'Arbitration\x20object\x20if\x20Lost\x20escalates\x20to\x20arbitration'},{'name':'time_guard_days','type':'number','required':!![],'default':'10','description':'Days\x20before\x20auto-complete\x20trigger\x20(time\x20guard)','constraint':'Must\x20be\x20>\x200;\x20reasonable\x20range\x207-30'},{'name':'return_node_name','type':'string','required':!![],'default':'Return','description':'Name\x20of\x20the\x20return/refund\x20node\x20in\x20the\x20exception\x20branch'}],'example_nodes':[{'name':'Paid','description':'Entry:\x20order\x20created\x20and\x20paid\x20via\x20Service.buy();\x20Machine\x20starts\x20here'},{'name':'Shipped'},{'name':'Received'},{'name':'Lost'},{'name':'Return'},{'name':'Refund'},{'name':'Complete'}],'example_pairs':[{'prev_node':'','next_node':'Paid','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':''}]},{'prev_node':'Paid','next_node':'Shipped','threshold':0x1,'forwards':[{'name':'Ship','weight':0x1,'permission_index':0x2}]},{'prev_node':'Shipped','next_node':'Received','threshold':0x1,'forwards':[{'name':'ConfirmReceive','weight':0x1,'named_operator':''}]},{'prev_node':'Shipped','next_node':'Lost','threshold':'${lost_threshold}','forwards':[{'name':'CustomerReport','weight':0x1,'named_operator':''},{'name':'MerchantConfirm','weight':0x1,'permission_index':0x2}]},{'prev_node':'Shipped','next_node':'Return','threshold':0x1,'forwards':[{'name':'RequestReturn','weight':0x1,'named_operator':''}]},{'prev_node':'Received','next_node':'Complete','threshold':0x1,'forwards':[{'name':'TimeGuard','weight':0x1,'permission_index':0x3,'guard':'time_guard_${time_guard_days}_days'},{'name':'MerchantFinish','weight':0x1,'permission_index':0x2}]},{'prev_node':'Return','next_node':'Refund','threshold':0x1,'forwards':[{'name':'IssueRefund','weight':0x1,'permission_index':0x2}]},{'prev_node':'Refund','next_node':'Complete','threshold':0x1,'forwards':[{'name':'CloseReturn','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'MerchantConfirm','purpose':'Dual-sig\x20on\x20Lost\x20node'},{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'TimeGuard','purpose':'Time\x20lock\x20${time_guard_days}\x20days'}],'required_permissions':[{'index':0x2,'name':'merchant','description':'Merchant\x20role'},{'index':0x3,'name':'admin','description':'Admin\x20/\x20time-guard\x20trigger'}],'required_allocators':[{'name':'CompleteAllocation','trigger_node':'Complete','description':'Full\x20allocation\x20to\x20merchant\x20on\x20normal\x20completion'},{'name':'RefundAllocation','trigger_node':'Refund','description':'Full\x20refund\x20to\x20customer\x20on\x20return'},{'name':'LostAllocation','trigger_node':'Lost','description':'Optional:\x20partial\x20refund\x20or\x20escrow\x20(depends\x20on\x20policy)'}],'forkable_fields':['node_names','branch_conditions','time_guard_days','lost_threshold'],'applicable_industries':['ecommerce','logistics'],'relevant_risks':['R-M1-01','R-M1-03','R-M1-08','R-M2-01','R-M2-05','R-M3-02','R-M3-04','R-M3-05','R-M4-01','R-M5-03'],'creation_notes':['First\x20node\x20\x27Paid\x27\x20represents\x20post-payment\x20state\x20—\x20Service.buy()\x20completes\x20payment\x20atomically\x20before\x20Progress\x20is\x20created','No\x20separate\x20\x27Order\x27\x20or\x20\x27Pay\x27\x20nodes\x20needed\x20—\x20payment\x20is\x20handled\x20by\x20Service.buy(),\x20not\x20Machine','Competing\x20Pairs\x20(Shipped\x20->\x20Received/Lost/Return)\x20are\x20mutually\x20exclusive\x20—\x20first\x20threshold\x20met\x20wins','Lost\x20node\x20threshold=2\x20means\x20BOTH\x20customer\x20and\x20merchant\x20Forwards\x20must\x20execute','TimeGuard\x20must\x20use\x20context(Clock)\x20>=\x20progress.entry_time\x20+\x20duration','If\x20Lost\x20escalates\x20to\x20arbitration,\x20bind\x20arbitration_usage_guard\x20on\x20Lost\x20forward','Refund\x20Allocation\x20must\x20use\x20sharing.who=OrderHolder\x20(refund\x20to\x20customer,\x20NOT\x20merchant)'],'example_use_case':'Mid-size\x20e-commerce\x20with\x207-day\x20return\x20policy\x20and\x20dispute\x20handling.\x20'+'Lost\x20claims\x20require\x20customer+merchant\x20dual\x20confirmation.','publish_checklist':['All\x20competing\x20Pairs\x20tested:\x20verify\x20first-wins\x20semantics\x20on\x20testnet','Lost\x20dual-sig\x20tested:\x20incomplete\x20signatures\x20do\x20not\x20advance','TimeGuard\x20Clock\x20query\x20verified\x20(testnet)','All\x20three\x20Allocators\x20tested\x20with\x20correct\x20sharing.who','Arbitration\x20binding\x20(if\x20any)\x20verified\x20via\x20gen_passport']},{'id':'tpl_machine_rental','scene_id':'rental_standard','name':'Equipment\x20Rental\x20Flow','description':'Rental\x20flow:\x20DepositPaid\x20(entry)\x20->\x20Pickup\x20->\x20In\x20Use\x20->\x20Return\x20->\x20Refund\x20Deposit.\x20'+'Payment\x20is\x20handled\x20by\x20Service.buy()\x20atomically;\x20Machine\x20starts\x20at\x20post-deposit\x20state.\x20'+'Separates\x20deposit\x20from\x20rental\x20fee\x20(two\x20Allocators).\x20Damage\x20report\x20via\x20retained_submission.','recommended_patterns':['P-M-SEQ'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Merchant\x20Permission\x20object'},{'name':'deposit_amount','type':'number','required':!![],'description':'Deposit\x20amount\x20in\x20smallest\x20WOW\x20unit','constraint':'Must\x20equal\x20order.amount\x20field;\x20verify\x20via\x20Guard\x20query'},{'name':'damage_inspection_node','type':'string','required':!![],'default':'DamageCheck','description':'Name\x20of\x20the\x20node\x20where\x20damage\x20inspection\x20occurs'},{'name':'return_node_name','type':'string','required':!![],'default':'Return','description':'Name\x20of\x20the\x20return\x20node\x20after\x20damage\x20check\x20fails'}],'example_nodes':[{'name':'DepositPaid','description':'Entry:\x20deposit\x20paid\x20via\x20Service.buy();\x20Machine\x20starts\x20here'},{'name':'PickedUp'},{'name':'InUse'},{'name':'Return'},{'name':'DamageCheck'},{'name':'DepositRefund'},{'name':'Complete'}],'example_pairs':[{'prev_node':'','next_node':'DepositPaid','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':''}]},{'prev_node':'DepositPaid','next_node':'PickedUp','threshold':0x1,'forwards':[{'name':'Pickup','weight':0x1,'named_operator':'','permission_index':0x2}]},{'prev_node':'PickedUp','next_node':'InUse','threshold':0x1,'forwards':[{'name':'StartUse','weight':0x1,'named_operator':''}]},{'prev_node':'InUse','next_node':'Return','threshold':0x1,'forwards':[{'name':'ReturnItem','weight':0x1,'named_operator':''}]},{'prev_node':'Return','next_node':'DamageCheck','threshold':0x1,'forwards':[{'name':'Inspect','weight':0x1,'permission_index':0x2,'retained_submission':'damage_report'}]},{'prev_node':'Return','next_node':'Complete','threshold':0x1,'forwards':[{'name':'CleanReturn','weight':0x1,'permission_index':0x2}]},{'prev_node':'DamageCheck','next_node':'DepositRefund','threshold':0x1,'forwards':[{'name':'DeductDamage','weight':0x1,'permission_index':0x2}]},{'prev_node':'DepositRefund','next_node':'Complete','threshold':0x1,'forwards':[{'name':'Close','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_forward_privacy_delivery_proof','bound_to_forward':'Inspect','purpose':'Optional:\x20damage\x20evidence\x20proof\x20(photo,\x20video)'}],'required_permissions':[{'index':0x2,'name':'merchant','description':'Rental\x20provider'}],'required_allocators':[{'name':'RentalFeeAllocation','trigger_node':'Complete','description':'Rental\x20fee\x20to\x20merchant'},{'name':'DepositRefundAllocation','trigger_node':'DepositRefund','description':'Remaining\x20deposit\x20to\x20customer\x20(OrderHolder\x20sharing.who)'},{'name':'DamageDeductionAllocation','trigger_node':'DamageCheck','description':'Damage\x20deduction\x20to\x20merchant'}],'forkable_fields':['deposit_amount','damage_node_logic','additional_inspection_steps'],'applicable_industries':['rental','equipment','vehicle'],'relevant_risks':['R-M1-01','R-M1-08','R-M2-01','R-M2-04','R-M3-02','R-M4-01','R-M5-02'],'creation_notes':['First\x20node\x20\x27DepositPaid\x27\x20represents\x20post-payment\x20state\x20—\x20Service.buy()\x20completes\x20deposit\x20payment\x20atomically\x20before\x20Progress\x20is\x20created','No\x20separate\x20\x27Reserve\x27\x20or\x20\x27PayDeposit\x27\x20nodes\x20needed\x20—\x20reservation\x20and\x20payment\x20are\x20handled\x20by\x20Service.buy(),\x20not\x20Machine','Damage\x20report\x20uses\x20retained_submission\x20—\x20values\x20stored\x20uniquely\x20by\x20(current_node,\x20next_node,\x20forward_name)','Two\x20competing\x20Pairs\x20at\x20Return\x20node:\x20DamageCheck\x20vs\x20Complete\x20(clean\x20return)','DamageDeduction\x20Allocation\x20uses\x20sharing.who=Entity\x20(merchant),\x20not\x20OrderHolder'],'example_use_case':'Camera\x20equipment\x20rental:\x20customer\x20pays\x201000\x20WOW\x20deposit,\x20returns\x20equipment,\x20'+'merchant\x20inspects.\x20If\x20damaged,\x20200\x20WOW\x20deducted;\x20otherwise\x20full\x20refund.','publish_checklist':['Deposit\x20Guard\x20tested\x20(testnet)\x20with\x20valid/invalid\x20amounts','Damage\x20report\x20retained_submission\x20stored\x20correctly\x20(query\x20progress_history)','Both\x20Return\x20branches\x20tested\x20(DamageCheck\x20+\x20CleanReturn)','All\x20three\x20Allocators\x20verified\x20with\x20correct\x20sharing.who']},{'id':'tpl_machine_dual_signature','scene_id':'dual_signature','name':'Dual-Signature\x20Consensus\x20Flow','description':'Critical\x20node\x20requires\x20both\x20customer\x20+\x20merchant\x20confirmation.\x20threshold=2\x20with\x20two\x20Forwards\x20(weight=1\x20each).\x20'+'Customer\x20uses\x20namedOperator=\x27\x27\x20(OrderHolder);\x20merchant\x20uses\x20permissionIndex=2.','recommended_patterns':['P-M-AND'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Merchant\x20Permission\x20object'},{'name':'critical_node_name','type':'string','required':!![],'default':'Approve','description':'Node\x20requiring\x20dual-sig'},{'name':'next_node_after_approval','type':'string','required':!![],'default':'Execute','description':'Name\x20of\x20the\x20node\x20that\x20follows\x20after\x20dual-signature\x20approval'}],'example_nodes':[{'name':'Initiated'},{'name':'${critical_node_name}','description':'Dual-sig\x20required\x20here'},{'name':'${next_node_after_approval}'},{'name':'Complete'}],'example_pairs':[{'prev_node':'','next_node':'Initiated','threshold':0x1,'forwards':[{'name':'Initiate','weight':0x1,'named_operator':''}]},{'prev_node':'Initiated','next_node':'${critical_node_name}','threshold':0x1,'forwards':[{'name':'Submit','weight':0x1,'named_operator':''}]},{'prev_node':'${critical_node_name}','next_node':'${next_node_after_approval}','threshold':0x2,'forwards':[{'name':'CustomerApprove','weight':0x1,'named_operator':'','guard':'customer_identity_guard'},{'name':'MerchantApprove','weight':0x1,'permission_index':0x2,'guard':'merchant_identity_guard'}]},{'prev_node':'${next_node_after_approval}','next_node':'Complete','threshold':0x1,'forwards':[{'name':'Finish','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'CustomerApprove','purpose':'Verify\x20customer\x20identity\x20(order.owner)'},{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'MerchantApprove','purpose':'Verify\x20merchant\x20identity\x20(permission\x20holder)'}],'required_permissions':[{'index':0x2,'name':'merchant','description':'Merchant\x20approval'}],'required_allocators':[{'name':'CompleteAllocation','trigger_node':'Complete','description':'Allocation\x20on\x20dual-sig\x20completion'}],'forkable_fields':['critical_node_name','additional_approvers','guard_logic'],'applicable_industries':['ecommerce','service','logistics','escrow'],'relevant_risks':['R-M1-08','R-M2-01','R-M3-02','R-M3-04'],'creation_notes':['threshold=2\x20means\x20BOTH\x20Forwards\x20must\x20execute\x20to\x20advance\x20(AND\x20semantics)','Customer\x20Forward\x20uses\x20namedOperator=\x27\x27\x20(OrderHolder)','Merchant\x20Forward\x20uses\x20permissionIndex=2','If\x20either\x20party\x20fails\x20to\x20sign,\x20workflow\x20stalls\x20—\x20consider\x20adding\x20timeout\x20Guard'],'example_use_case':'High-value\x20order\x20(e.g.\x20real\x20estate\x20transaction)\x20requiring\x20both\x20buyer\x20and\x20seller\x20confirmation.','publish_checklist':['Both\x20Forward\x20identities\x20tested\x20on\x20testnet','Verify\x20partial\x20signature\x20does\x20NOT\x20advance\x20(threshold=2)','Guards\x20correctly\x20distinguish\x20customer\x20vs\x20merchant\x20identity']},{'id':'tpl_machine_weighted_voting','scene_id':'weighted_voting','name':'Weighted\x20Voting\x20Flow','description':'Multi-party\x20voting\x20with\x20unequal\x20weights.\x20threshold=100,\x20chief\x20weight=60,\x20members\x20weight=40\x20total.\x20'+'Each\x20member\x27s\x20weight\x20extracted\x20via\x20Guard\x20query\x20from\x20Arbitration\x20object.','recommended_patterns':['P-M-VOTE'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'arbitration_ref','type':'arbitration_ref','required':!![],'description':'Arbitration\x20object\x20storing\x20voter\x20weights'},{'name':'threshold_total','type':'number','required':!![],'default':'100','description':'Total\x20weight\x20threshold\x20for\x20decision'},{'name':'chief_weight','type':'number','required':!![],'default':'60','description':'Weight\x20assigned\x20to\x20the\x20chief\x20voter\x20(out\x20of\x20100)'},{'name':'member_count','type':'number','required':!![],'default':'5','description':'Number\x20of\x20voting\x20members\x20(excluding\x20chief)'}],'example_nodes':[{'name':'VoteOpened'},{'name':'Voting'},{'name':'Approved'},{'name':'Rejected'}],'example_pairs':[{'prev_node':'','next_node':'VoteOpened','threshold':0x1,'forwards':[{'name':'OpenVote','weight':0x1,'permission_index':0x3}]},{'prev_node':'VoteOpened','next_node':'Voting','threshold':0x1,'forwards':[{'name':'StartVoting','weight':0x1,'permission_index':0x3}]},{'prev_node':'Voting','next_node':'Approved','threshold':'${threshold_total}','forwards':[{'name':'ChiefVote','weight':'${chief_weight}','permission_index':0x2,'guard':'arb_voting_guard','retained_submission':'chief_vote_record'},{'name':'MemberVote','weight':0x8,'named_operator':'member','guard':'arb_voting_guard','retained_submission':'member_vote_record'}]},{'prev_node':'Voting','next_node':'Rejected','threshold':0x1,'forwards':[{'name':'TimeoutReject','weight':0x1,'permission_index':0x3,'guard':'voting_timeout_guard'}]}],'required_guards':[{'guard_template_id':'tpl_voting_guard_numeric_weight','bound_to_forward':'ChiefVote','purpose':'Verify\x20voting\x20eligibility\x20+\x20extract\x20weight\x20from\x20Arbitration'},{'guard_template_id':'tpl_voting_guard_numeric_weight','bound_to_forward':'MemberVote','purpose':'Verify\x20voting\x20eligibility\x20+\x20prevent\x20double-vote'}],'required_permissions':[{'index':0x2,'name':'chief','description':'Chief\x20voter\x20(high\x20weight)'},{'index':0x3,'name':'admin','description':'Vote\x20opener\x20/\x20timeout\x20trigger'}],'required_allocators':[{'name':'ApprovedAllocation','trigger_node':'Approved','description':'Allocation\x20on\x20approval'}],'forkable_fields':['weights','voter_count','timeout_days'],'applicable_industries':['governance','arbitration','dao'],'relevant_risks':['R-M1-08','R-M2-05','R-M3-04','R-M5-04','R-X1-14'],'creation_notes':['Member\x20weight\x20must\x20be\x20extracted\x20dynamically\x20via\x20Guard\x20query\x20(not\x20hardcoded\x20in\x20Forward)','Guard\x20MUST\x20check\x20arb.voted\x20has\x20[Signer]\x20to\x20prevent\x20double-voting\x20(R-X1-14\x20CRITICAL)','Competing\x20Pair:\x20Approved\x20vs\x20Rejected\x20(timeout)\x20—\x20first-wins','Voting\x20weight\x20is\x20query-derived;\x20Forward\x20weight\x20field\x20is\x20just\x20session\x20counter'],'example_use_case':'Arbitration\x20panel:\x201\x20chief\x20(weight\x2060)\x20+\x205\x20members\x20(weight\x208\x20each\x20=\x2040).\x20'+'Need\x20total\x20>=\x20100\x20to\x20approve.\x20Reject\x20after\x2072h\x20timeout.','publish_checklist':['Arbitration\x20object\x20created\x20and\x20tested','Double-vote\x20prevention\x20verified\x20(try\x20voting\x20twice\x20—\x20should\x20fail)','Weight\x20extraction\x20tested\x20with\x20different\x20voter\x20configurations','Timeout\x20Guard\x20(Clock)\x20verified\x20on\x20testnet']},{'id':'tpl_machine_cross_machine','scene_id':'cross_machine_supply_chain','name':'Cross-Machine\x20Supply\x20Chain','description':'Decomposed\x20supply\x20chain\x20across\x20multiple\x20Machines.\x20Machine\x20B\x27s\x20Forward\x20Guard\x20queries\x20Machine\x20A\x27s\x20Progress\x20'+'via\x20convert_witness=100\x20to\x20verify\x20upstream\x20completion\x20before\x20advancing.','recommended_patterns':['P-M-CROSS-MACHINE'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'machine_a_id','type':'machine_ref','required':!![],'description':'Upstream\x20Machine\x20(must\x20already\x20be\x20published)','constraint':'Machine\x20A\x20must\x20be\x20published\x20BEFORE\x20Machine\x20B\x27s\x20Guard\x20can\x20reference\x20its\x20Progress\x20'+'(indirect\x20via\x20progress::new\x20->\x20assert_published,\x20see\x2006\x20§14.6)'},{'name':'machine_a_complete_node','type':'string','required':!![],'default':'Complete','description':'Target\x20node\x20name\x20in\x20Machine\x20A\x20to\x20verify'},{'name':'machine_b_permission','type':'permission_ref','required':!![],'description':'Machine\x20B\x27s\x20Permission\x20object'}],'example_nodes':[{'name':'UpstreamVerified'},{'name':'Production'},{'name':'Complete'}],'example_pairs':[{'prev_node':'','next_node':'UpstreamVerified','threshold':0x1,'forwards':[{'name':'VerifyUpstream','weight':0x1,'permission_index':0x2,'guard':'upstream_progress_guard','retained_submission':'upstream_progress_id'}]},{'prev_node':'UpstreamVerified','next_node':'Production','threshold':0x1,'forwards':[{'name':'StartProduction','weight':0x1,'permission_index':0x2}]},{'prev_node':'Production','next_node':'Complete','threshold':0x1,'forwards':[{'name':'Finish','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'VerifyUpstream','purpose':'Query\x20Machine\x20A\x27s\x20Progress:\x20verify\x20it\x20reached\x20${machine_a_complete_node}'}],'required_permissions':[{'index':0x2,'name':'manufacturer','description':'Machine\x20B\x20operator'}],'required_allocators':[{'name':'CompleteAllocation','trigger_node':'Complete','description':'Allocation\x20to\x20Machine\x20B\x27s\x20merchant'}],'forkable_fields':['upstream_machine_ref','verification_node_name'],'applicable_industries':['manufacturing','logistics','retail','supply_chain'],'relevant_risks':['R-M1-01','R-M1-08','R-M2-01','R-M2-04','R-M3-04','R-M5-04','R-M5-05','R-M5-06'],'creation_notes':['Machine\x20A\x20MUST\x20be\x20published\x20before\x20Machine\x20B\x20(dependency\x20order)','Guard\x20uses\x20convert_witness=100\x20to\x20convert\x20submitted\x20Order/Progress\x20ID\x20into\x20queryable\x20Progress\x20object','Cross-Machine\x20dependency\x20is\x20one-way\x20(no\x20cycles)','retained_submission\x20stores\x20upstream\x20Progress\x20ID\x20for\x20later\x20audit','Multi-party\x20chain:\x20extend\x20pattern\x20with\x20Machine\x20C,\x20D,\x20...\x20(each\x20independently\x20published)','Dependency\x20verification:\x20indirect\x20via\x20progress::new\x20->\x20assert_published\x20(see\x2006\x20§14.6)'],'example_use_case':'Supplier\x20(Machine\x20A)\x20->\x20Manufacturer\x20(Machine\x20B)\x20->\x20Retailer\x20(Machine\x20C).\x20'+'Manufacturer\x20cannot\x20start\x20production\x20until\x20supplier\x27s\x20Progress\x20reaches\x20\x27Complete\x27.','publish_checklist':['Machine\x20A\x20already\x20published\x20on-chain\x20(verify\x20via\x20onchain_objects)','Cross-Machine\x20Guard\x20tested\x20with\x20valid/invalid\x20upstream\x20Progress\x20IDs','retained_submission\x20verified\x20(query\x20progress_history\x20for\x20upstream_progress_id)','Independent\x20testing:\x20run\x20Machine\x20A\x20to\x20Complete,\x20then\x20attempt\x20Machine\x20B\x27s\x20VerifyUpstream']},{'id':'tpl_machine_privacy_delivery','scene_id':'privacy_delivery','name':'Privacy-Preserving\x20Delivery\x20Flow','description':'Customer\x20submits\x20privacy\x20data\x20via\x20Messenger\x20(encrypted,\x20off-chain).\x20Chain\x20stores\x20only\x20Merkle\x20Root\x20Proof.\x20'+'Guard\x20verifies\x20Proof\x20signature\x20+\x20timestamp\x20+\x20service\x20binding.\x20Uses\x20tpl_forward_privacy_delivery_proof\x20(strict\x20mode).','recommended_patterns':['P-M-SEQ'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Merchant\x20Permission\x20object'},{'name':'proof_node_name','type':'string','required':!![],'default':'ProofSubmitted','description':'Name\x20of\x20the\x20node\x20where\x20delivery\x20proof\x20is\x20submitted'},{'name':'delivery_node_name','type':'string','required':!![],'default':'DeliveryConfirmed','description':'Name\x20of\x20the\x20node\x20where\x20delivery\x20confirmation\x20occurs'}],'example_nodes':[{'name':'Paid','description':'Entry:\x20order\x20created\x20and\x20paid\x20via\x20Service.buy();\x20Machine\x20starts\x20here'},{'name':'${proof_node_name}','description':'Customer\x20submits\x20Proof\x20via\x20Messenger'},{'name':'${delivery_node_name}'},{'name':'Complete'}],'example_pairs':[{'prev_node':'','next_node':'Paid','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':''}]},{'prev_node':'Paid','next_node':'${proof_node_name}','threshold':0x1,'forwards':[{'name':'SubmitProof','weight':0x1,'named_operator':'','guard':'tpl_forward_privacy_delivery_proof','retained_submission':'proof_address'}]},{'prev_node':'${proof_node_name}','next_node':'${delivery_node_name}','threshold':0x1,'forwards':[{'name':'ConfirmDelivery','weight':0x1,'permission_index':0x2}]},{'prev_node':'${delivery_node_name}','next_node':'Complete','threshold':0x1,'forwards':[{'name':'Finish','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_forward_privacy_delivery_proof','bound_to_forward':'SubmitProof','purpose':'Verify\x20Proof:\x20signer=proof.signer\x20∧\x20proof.time>order.time\x20∧\x20order.service=service'}],'required_permissions':[{'index':0x2,'name':'merchant','description':'Merchant\x20confirms\x20delivery'}],'required_allocators':[{'name':'CompleteAllocation','trigger_node':'Complete','description':'Allocation\x20to\x20merchant\x20after\x20delivery\x20confirmation'}],'forkable_fields':['proof_node_name','delivery_node_name','additional_evidence_steps'],'applicable_industries':['ecommerce','logistics','privacy_service'],'relevant_risks':['R-M1-01','R-M1-08','R-M2-01','R-M2-04','R-M3-02','R-M5-03'],'creation_notes':['Use\x20strict\x20mode\x20tpl_forward_privacy_delivery_proof\x20(3\x20conditions:\x20Signer\x20+\x20time\x20+\x20service\x20binding)','submitChainProof\x20about_address\x20=\x20peerAddress\x20(NOT\x20sessionId)','order_id\x20passed\x20via\x20description\x20string\x20field\x20(not\x20about_address)','Guard\x20table\x20item\x20name\x20MUST\x20be\x20<64\x20BCS\x20bytes\x20(MAX_NAME_LENGTH=64)','retained_submission\x20stores\x20Proof\x20address\x20for\x20arbitration\x20query','Proof\x20MUST\x20be\x20generated\x20by\x20messenger.submitChainProof\x20(not\x20manual)'],'example_use_case':'Customer\x20sends\x20delivery\x20address\x20via\x20Messenger\x20(encrypted).\x20Chain\x20stores\x20only\x20Proof.\x20'+'Merchant\x20verifies\x20Proof,\x20then\x20confirms\x20delivery.','publish_checklist':['Strict\x20mode\x20Guard\x20tested:\x203\x20conditions\x20verified\x20individually','Messenger\x20integration\x20tested\x20end-to-end\x20(submit\x20+\x20verify)','retained_submission\x20stored\x20Proof\x20address\x20queryable\x20from\x20progress_history','Guard\x20table\x20item\x20name\x20length\x20validated\x20(<64\x20BCS\x20bytes)']},{'id':'tpl_machine_reward','scene_id':'reward_incentive','name':'Reward\x20Incentive\x20Flow','description':'Customer\x20triggers\x20Reward\x20claim\x20at\x20specific\x20node.\x20Guard\x20prevents\x20double-claim\x20via\x20query_reward_record_count==0.\x20'+'Reward\x20object\x20independent\x20of\x20Allocator.','recommended_patterns':['P-M-SEQ'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'reward_ref','type':'reward_ref','required':!![],'description':'Reward\x20object\x20address\x20(must\x20be\x20already\x20created)'},{'name':'claim_node_name','type':'string','required':!![],'default':'ClaimReward','description':'Name\x20of\x20the\x20node\x20where\x20reward\x20claims\x20are\x20triggered'}],'example_nodes':[{'name':'Eligible'},{'name':'${claim_node_name}'},{'name':'Rewarded'},{'name':'Complete'}],'example_pairs':[{'prev_node':'','next_node':'Eligible','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':''}]},{'prev_node':'Eligible','next_node':'${claim_node_name}','threshold':0x1,'forwards':[{'name':'TriggerClaim','weight':0x1,'named_operator':'','guard':'reward_anti_double_guard','retained_submission':'claim_record'}]},{'prev_node':'${claim_node_name}','next_node':'Rewarded','threshold':0x1,'forwards':[{'name':'IssueReward','weight':0x1,'permission_index':0x3}]},{'prev_node':'Rewarded','next_node':'Complete','threshold':0x1,'forwards':[{'name':'Finish','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_reward_one_time_claim','bound_to_forward':'TriggerClaim','purpose':'Verify\x20query_reward_record_count==0\x20to\x20prevent\x20double-claim'}],'required_permissions':[{'index':0x2,'name':'merchant','description':'Completes\x20flow'},{'index':0x3,'name':'reward_admin','description':'Issues\x20reward\x20tokens'}],'required_allocators':[{'name':'CompleteAllocation','trigger_node':'Complete','description':'Standard\x20allocation\x20(separate\x20from\x20Reward)'}],'forkable_fields':['claim_node_name','additional_reward_conditions'],'applicable_industries':['ecommerce','subscription','education','loyalty'],'relevant_risks':['R-M1-08','R-M2-05','R-M3-04','R-X1-14'],'creation_notes':['Reward\x20Guard\x20MUST\x20check\x20query_reward_record_count\x20==\x200\x20(R-X1-14\x20CRITICAL)','Reward\x20is\x20INDEPENDENT\x20of\x20Allocator\x20—\x20both\x20can\x20fire\x20on\x20different\x20nodes','Reward\x20object\x20must\x20be\x20created\x20BEFORE\x20publishing\x20this\x20Machine','retained_submission\x20stores\x20claim\x20record\x20for\x20audit'],'example_use_case':'Loyalty\x20program:\x20after\x20customer\x20completes\x205\x20orders,\x20eligible\x20to\x20claim\x20reward\x20token.\x20'+'Anti-double-claim\x20Guard\x20ensures\x20one\x20claim\x20per\x20customer.','publish_checklist':['Reward\x20object\x20already\x20created\x20and\x20tested','Anti-double-claim\x20Guard\x20tested:\x20claim\x20twice\x20should\x20fail\x20on\x20second\x20attempt','retained_submission\x20verified\x20(claim_record\x20queryable)']},{'id':'tpl_machine_wonder_feedback','scene_id':'wonder_feedback','name':'Wonder\x20Feedback\x20Flow\x20(Post-Completion\x20Rating)','description':'Post-completion\x20rating\x20flow:\x20Paid\x20(entry)\x20→\x20Shipped\x20→\x20Received\x20→\x20Completed\x20→\x20{Wonder\x20|\x20NoWonder}.\x20'+'After\x20the\x20order\x20reaches\x20\x27Completed\x27\x20(terminal\x20business\x20state,\x20funds\x20already\x20allocated\x20to\x20merchant),\x20'+'the\x20OrderHolder\x20(namedOperator=\x27\x27)\x20can\x20advance\x20Progress\x20to\x20\x27wonder\x27\x20(positive\x20review)\x20or\x20\x27no_wonder\x27\x20'+'(negative\x20review).\x20A\x20bound\x20Reward\x20object\x27s\x20claim_guard\x20verifies\x20Progress.current\x20==\x20\x27wonder\x27\x20before\x20'+'paying\x20out\x20—\x20reward\x20claim\x20needs\x20NO\x20Permission.\x20Dispute\x20is\x20NEVER\x20modeled\x20here:\x20it\x20flows\x20through\x20'+'Order\x20→\x20Arbitration.dispute()\x20→\x20Arb\x20→\x20arbitration()\x20ruling\x20→\x20arb_withdraw,\x20fully\x20off-Machine.','recommended_patterns':['P-M-SEQ','P-M-COMPETING'],'recommended_topology':['P-M-LINEAR','P-M-COMPETING'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Merchant\x20Permission\x20object\x20(index\x202\x20=\x20merchant,\x20index\x203\x20=\x20admin)'},{'name':'wonder_node_name','type':'string','required':!![],'default':'wonder','description':'Node\x20name\x20for\x20positive\x20feedback\x20(praise)\x20terminal','constraint':'Must\x20match\x20/^(wonder|praise|thumbs_up)$/i\x20OR\x20be\x20a\x20custom\x20name;\x20must\x20NOT\x20match\x20dispute\x20anti-pattern\x20regex'},{'name':'no_wonder_node_name','type':'string','required':!![],'default':'no_wonder','description':'Node\x20name\x20for\x20negative\x20feedback\x20(complaint)\x20terminal','constraint':'Must\x20match\x20/^(no_wonder|complain|thumbs_down)$/i\x20OR\x20be\x20a\x20custom\x20name;\x20must\x20NOT\x20match\x20dispute\x20anti-pattern\x20regex'},{'name':'reward_ref','type':'reward_ref','required':![],'description':'Reward\x20object\x20address\x20(optional).\x20If\x20bound,\x20its\x20claim_guard\x20should\x20verify\x20Progress.current\x20==\x20wonder_node_name\x20AND\x20order.holder\x20==\x20signer.\x20Use\x20wonder_praise\x20or\x20wonder_feedback\x20reward\x20template.'},{'name':'rating_time_limit_days','type':'number','required':![],'default':'30','description':'Days\x20after\x20completion\x20during\x20which\x20the\x20customer\x20can\x20rate\x20(enforced\x20by\x20Guard\x20on\x20Praise/Complain\x20forwards\x20via\x20context(Clock))','constraint':'Must\x20be\x20>\x200;\x20reasonable\x20range\x207-90'}],'example_nodes':[{'name':'Paid','description':'Entry:\x20order\x20created\x20and\x20paid\x20via\x20Service.buy();\x20Machine\x20starts\x20here'},{'name':'Shipped','description':'Merchant\x20dispatched\x20goods/service'},{'name':'Received','description':'Customer\x20confirmed\x20receipt'},{'name':'Completed','description':'Terminal\x20business\x20state\x20—\x20triggers\x20merchant\x20Allocation.\x20Funds\x20settled.'},{'name':'${wonder_node_name}','description':'Positive\x20feedback\x20terminal\x20(praise).\x20OrderHolder-only.\x20Reward-eligible.'},{'name':'${no_wonder_node_name}','description':'Negative\x20feedback\x20terminal\x20(complaint).\x20OrderHolder-only.\x20Optional\x20Repository\x20write\x20for\x20analytics.'}],'example_pairs':[{'prev_node':'','next_node':'Paid','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':''}]},{'prev_node':'Paid','next_node':'Shipped','threshold':0x1,'forwards':[{'name':'Ship','weight':0x1,'permission_index':0x2,'named_operator':''}]},{'prev_node':'Shipped','next_node':'Received','threshold':0x1,'forwards':[{'name':'ConfirmReceive','weight':0x1,'named_operator':''}]},{'prev_node':'Received','next_node':'Completed','threshold':0x1,'forwards':[{'name':'Finish','weight':0x1,'permission_index':0x2,'named_operator':''}]},{'prev_node':'Completed','next_node':'${wonder_node_name}','threshold':0x1,'forwards':[{'name':'Praise','weight':0x1,'named_operator':'','guard':'rating_window_guard','retained_submission':'rating_record'}]},{'prev_node':'Completed','next_node':'${no_wonder_node_name}','threshold':0x1,'forwards':[{'name':'Complain','weight':0x1,'named_operator':'','guard':'rating_window_guard','retained_submission':'rating_record'}]}],'required_guards':[{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'Praise','purpose':'Verify\x20Progress.current\x20==\x20\x27Completed\x27\x20(rating\x20only\x20allowed\x20after\x20completion)\x20AND\x20context(Clock)\x20<=\x20progress.entry_time\x20+\x20rating_time_limit_days'},{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'Complain','purpose':'Verify\x20Progress.current\x20==\x20\x27Completed\x27\x20(rating\x20only\x20allowed\x20after\x20completion)\x20AND\x20context(Clock)\x20<=\x20progress.entry_time\x20+\x20rating_time_limit_days'}],'required_permissions':[{'index':0x2,'name':'merchant','description':'Merchant\x20role\x20for\x20Ship\x20+\x20Finish\x20(NOT\x20for\x20rating\x20—\x20rating\x20is\x20OrderHolder-only\x20via\x20named_operator=\x27\x27)'},{'index':0x3,'name':'admin','description':'Admin\x20override\x20(optional)'}],'required_allocators':[{'name':'MerchantAllocation','trigger_node':'Completed','description':'100%\x20to\x20merchant\x20Treasury\x20or\x20personal\x20address.\x20Fires\x20at\x20Completion\x20—\x20NOT\x20at\x20Wonder/NoWonder\x20(those\x20are\x20reputation-only\x20terminals\x20with\x20no\x20fund\x20flow).'}],'forkable_fields':['wonder_node_name','no_wonder_node_name','rating_time_limit_days','additional_rating_nodes'],'applicable_industries':['ecommerce','service','rental','subscription','education'],'relevant_risks':['R-M1-01','R-M1-02','R-M1-08','R-M1-11','R-M2-01','R-M2-05','R-M3-02','R-M3-04','R-M4-01','R-M5-03'],'creation_notes':['DISPUTE\x20INDEPENDENCE:\x20This\x20Machine\x20MUST\x20NOT\x20contain\x20\x27disputed\x27,\x20\x27refunded\x27,\x20\x27arb\x27,\x20\x27arbitration\x27\x20nodes\x20(R-M1-11\x20critical).\x20Disputes\x20are\x20filed\x20off-Machine\x20via\x20arbitration::dispute(order,\x20arbitration).','Build\x20order:\x20Permission\x20→\x20Machine\x20(unpublished)\x20→\x20Guards\x20→\x20Bind\x20guards\x20→\x20Publish\x20→\x20Bind\x20to\x20Service\x20→\x20Bind\x20Reward\x20(optional)','First\x20node\x20\x27Paid\x27\x20represents\x20post-payment\x20state\x20—\x20Service.buy()\x20completes\x20payment\x20atomically\x20before\x20Progress\x20is\x20created','No\x20separate\x20\x27Order\x27\x20or\x20\x27Pay\x27\x20nodes\x20needed\x20—\x20payment\x20is\x20handled\x20by\x20Service.buy(),\x20not\x20Machine','Wonder/NoWonder\x20forwards\x20have\x20named_operator=\x27\x27\x20(empty)\x20—\x20this\x20delegates\x20to\x20the\x20OrderHolder\x20(customer).\x20No\x20Permission\x20index\x20needed\x20for\x20rating.','Completed\x20node\x20triggers\x20MerchantAllocation\x20—\x20funds\x20are\x20settled\x20BEFORE\x20the\x20rating\x20window\x20opens.\x20Rating\x20does\x20NOT\x20affect\x20fund\x20flow.','Competing\x20Pair:\x20Praise\x20vs\x20Complain\x20(first-wins)\x20—\x20one\x20rating\x20per\x20order,\x20enforced\x20by\x20Guard\x20+\x20retained_submission\x20audit\x20trail.','Reward\x20object\x20(if\x20bound)\x20is\x20INDEPENDENT\x20of\x20Allocator:\x20Reward.claim()\x20requires\x20Guard+passport,\x20not\x20Permission.\x20Guard\x20checks\x20Progress.current\x20==\x20\x27wonder\x27\x20AND\x20order.holder\x20==\x20signer.','rating_window_guard\x20enforces\x20time\x20limit:\x20context(Clock)\x20<=\x20progress.entry_time\x20+\x20rating_time_limit_days.\x20After\x20window\x20closes,\x20no\x20rating\x20possible\x20(Completed\x20becomes\x20true\x20terminal).','Optional:\x20bind\x20a\x20Repository\x20to\x20record\x20feedback\x20node\x20for\x20analytics.\x20Repository\x20write\x20happens\x20via\x20Guard\x27s\x20data\x20extraction\x20(NOT\x20auto-passed\x20—\x20see\x2006\x20§14.4).'],'example_use_case':'Photography\x20service:\x20Paid\x20→\x20Shipped\x20(booking\x20confirmed)\x20→\x20Received\x20(session\x20delivered)\x20→\x20Completed\x20'+'(photos\x20delivered,\x20funds\x20released\x20to\x20photographer)\x20→\x20customer\x20advances\x20to\x20\x27wonder\x27\x20(loved\x20the\x20work)\x20'+'or\x20\x27no_wonder\x27\x20(didn\x27t\x20love\x20it).\x20Bound\x20Reward\x20pays\x201\x20WOW\x20to\x20customers\x20who\x20advance\x20to\x20\x27wonder\x27.\x20'+'Merchant\x27s\x20wonder/no_wonder\x20ratio\x20becomes\x20an\x20on-chain\x20reputation\x20signal.\x20Disputes\x20(if\x20any)\x20are\x20'+'filed\x20separately\x20via\x20Arbitration\x20object\x20—\x20never\x20enter\x20this\x20Machine.','publish_checklist':['All\x206\x20nodes\x20verified:\x20no\x20\x27disputed\x27/\x27refunded\x27/\x27arb\x27/\x27arbitration\x27\x20names\x20(R-M1-11\x20PASS)','Entry\x20Pair\x20exists\x20(prev_node=\x27\x27\x20targets\x20\x27Paid\x27)','Competing\x20Pair\x20tested:\x20Praise\x20vs\x20Complain\x20—\x20first-wins\x20semantics\x20verified\x20on\x20testnet','rating_window_guard\x20tested:\x20rating\x20blocked\x20after\x20time\x20limit\x20expires','MerchantAllocation\x20fires\x20ONLY\x20at\x20Completed\x20(NOT\x20at\x20Wonder/NoWonder)','Reward\x20object\x20(if\x20bound):\x20claim_guard\x20tested\x20—\x20Progress.current\x20==\x20\x27wonder\x27\x20required,\x20claim\x20fails\x20at\x20\x27no_wonder\x27\x20or\x20\x27Completed\x27','named_operator=\x27\x27\x20on\x20Praise/Complain\x20forwards\x20verified\x20(OrderHolder-only\x20operation)','machineNode2file\x20export\x20as\x20backup']},{'id':'tpl_machine_subscription','scene_id':'subscription','name':'Subscription\x20/\x20Membership\x20Flow','description':'Subscribe\x20->\x20Pay\x20->\x20Activate\x20->\x20[Renew\x20|\x20Expire]\x20->\x20Cancel/End.\x20Time-lock\x20on\x20Renew.\x20'+'Competing\x20Pair:\x20Renew\x20vs\x20Expire\x20(first-wins).\x20Repository\x20stores\x20subscription\x20status.','recommended_patterns':['P-M-SEQ','P-M-COMPETING'],'recommended_topology':['P-M-LINEAR','P-M-COMPETING'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Provider\x20Permission\x20object'},{'name':'subscription_duration_days','type':'number','required':!![],'default':'30','description':'Days\x20between\x20Renew\x20and\x20Expire\x20eligibility'},{'name':'repository_ref','type':'address','required':!![],'description':'Repository\x20object\x20storing\x20subscription\x20status\x20(note:\x20not\x20consensus_repositories,\x20which\x20is\x20declarative-only\x20—\x20see\x2006\x20§14.4)'}],'example_nodes':[{'name':'Paid','description':'Entry:\x20subscription\x20created\x20and\x20paid\x20via\x20Service.buy();\x20Machine\x20starts\x20here'},{'name':'Active'},{'name':'RenewEligible'},{'name':'Renewed'},{'name':'Expired'},{'name':'Cancelled'},{'name':'Ended'}],'example_pairs':[{'prev_node':'','next_node':'Paid','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':''}]},{'prev_node':'Paid','next_node':'Active','threshold':0x1,'forwards':[{'name':'Activate','weight':0x1,'permission_index':0x2,'guard':'repository_write_guard'}]},{'prev_node':'Active','next_node':'RenewEligible','threshold':0x1,'forwards':[{'name':'TimeUnlock','weight':0x1,'permission_index':0x3,'guard':'time_lock_guard_${subscription_duration_days}_days'}]},{'prev_node':'RenewEligible','next_node':'Renewed','threshold':0x1,'forwards':[{'name':'Renew','weight':0x1,'named_operator':''}]},{'prev_node':'RenewEligible','next_node':'Expired','threshold':0x1,'forwards':[{'name':'AutoExpire','weight':0x1,'permission_index':0x3,'guard':'expire_time_guard'}]},{'prev_node':'RenewEligible','next_node':'Cancelled','threshold':0x1,'forwards':[{'name':'Cancel','weight':0x1,'named_operator':''}]},{'prev_node':'Renewed','next_node':'Active','threshold':0x1,'forwards':[{'name':'Reactivate','weight':0x1,'permission_index':0x2}]},{'prev_node':'Expired','next_node':'Ended','threshold':0x1,'forwards':[{'name':'CloseExpired','weight':0x1,'permission_index':0x3}]},{'prev_node':'Cancelled','next_node':'Ended','threshold':0x1,'forwards':[{'name':'CloseCancelled','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'TimeUnlock','purpose':'Time\x20lock:\x20context(Clock)\x20>=\x20progress.entry_time\x20+\x20${subscription_duration_days}\x20days'},{'guard_template_id':'tpl_write_guard_type_check','bound_to_forward':'Activate','purpose':'Write\x20subscription\x20status\x20to\x20Repository'},{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'AutoExpire','purpose':'Hard\x20expire:\x20context(Clock)\x20>=\x20progress.entry_time\x20+\x202x\x20duration'}],'required_permissions':[{'index':0x2,'name':'provider','description':'Provider\x20activates/reactivates'},{'index':0x3,'name':'admin','description':'Time-lock\x20triggers'}],'required_allocators':[{'name':'RenewAllocation','trigger_node':'Renewed','description':'Charge\x20renewal\x20fee\x20on\x20Renew'}],'forkable_fields':['duration_days','grace_period','additional_tiers'],'applicable_industries':['subscription','saas','membership','service'],'relevant_risks':['R-M1-01','R-M1-08','R-M2-01','R-M2-05','R-M3-02','R-M3-04','R-M4-01','R-M5-04'],'creation_notes':['First\x20node\x20\x27Paid\x27\x20represents\x20post-payment\x20state\x20—\x20Service.buy()\x20completes\x20subscription\x20payment\x20atomically\x20before\x20Progress\x20is\x20created','No\x20separate\x20\x27Subscribe\x27\x20or\x20\x27Pay\x27\x20nodes\x20needed\x20—\x20subscription\x20and\x20payment\x20are\x20handled\x20by\x20Service.buy(),\x20not\x20Machine','Time-lock\x20uses\x20context(Clock)\x20—\x20verify\x20Clock\x20address\x20in\x20Guard\x20table','Competing\x20Pair:\x20Renew\x20vs\x20Expire\x20vs\x20Cancel\x20—\x20first-wins','Renewed\x20node\x20loops\x20back\x20to\x20Active\x20(recurring\x20subscription)','Repository\x20records\x20subscription\x20status\x20for\x20cross-Machine\x20verification','Renewal\x20Allocation\x20triggers\x20on\x20Renewed\x20node\x20(not\x20Active\x20—\x20avoids\x20double-charge)','Note:\x20consensus_repositories\x20is\x20declarative-only\x20(NOT\x20auto-passed\x20to\x20Progress);\x20use\x20repository_ref\x20parameter\x20for\x20actual\x20Repository\x20object\x20—\x20see\x2006\x20§14.4','VARIANT\x20—\x20Content\x20subscription\x20(Substack-style):\x20replace\x20time-lock\x20Renew/Expire\x20with\x20content-delivery\x20flow:','\x20\x206-node\x20variant:\x20Paid\x20(entry)\x20→\x20ContentPublished\x20→\x20Completed\x20(terminal-success)','\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Paid\x20→\x20Cancelled\x20(terminal-cancel)\x20|\x20Paid\x20→\x20Disputed\x20→\x20Refunded\x20(terminal-dispute)','\x20\x20Permission:\x20author=index\x201000\x20(publish\x20+\x20cancel),\x20arbitrator=index\x201500\x20(resolve\x20dispute),\x20reader=namedOperator=\x27\x27\x20(open\x20role,\x20no\x20specific\x20operator)','\x20\x20Guards:\x20deliver_guard\x20(verify\x20author\x20permission\x20+\x20content\x20hash),\x20cancel_guard\x20(verify\x20subscriber\x20request),\x20refund_guard\x20(verify\x20arbitration\x20outcome)','\x20\x20Allocators:\x20deliver=100%\x20to\x20author,\x20cancel=100%\x20refund\x20to\x20subscriber,\x20dispute=100%\x20refund\x20to\x20subscriber\x20(Guard-first-wins\x20pattern)','\x20\x20First-Forward-wins:\x20when\x20Paid\x20has\x20competing\x20forwards\x20(Deliver|Cancel|Dispute),\x20the\x20first\x20triggered\x20forward\x20wins;\x20subscribers\x20cannot\x20double-claim','CRITICAL\x20—\x20v1→v2\x20lesson:\x20arbitrations\x20MUST\x20be\x20added\x20BEFORE\x20Service.publish\x20(post-publish,\x20arbitrations\x20become\x20immutable\x20and\x20cannot\x20be\x20added\x20—\x20service.move\x20F-S-21)','\x20\x20If\x20you\x20accidentally\x20published\x20without\x20arbitrations,\x20you\x20MUST\x20create\x20a\x20new\x20Service\x20v2\x20with\x20arbitrations\x20bound\x20before\x20publishing\x20(the\x20v1\x20Service\x20must\x20be\x20paused/abandoned)','\x20\x20ConfirmGate\x20(C-S-19,\x20QS11)\x20will\x20warn\x20before\x20publish\x20without\x20arbitrations\x20—\x20do\x20not\x20bypass\x20this\x20warning\x20unless\x20explicitly\x20intending\x20no-arbitration\x20operation','Build\x20order\x20(content\x20variant):\x20Permission\x20→\x20Machine\x20(unpublished,\x20with\x20initial\x20forward)\x20→\x203\x20Guards\x20→\x203\x20Allocators\x20(template\x20on\x20Service)\x20→\x20Service\x20(unpublished,\x20bind\x20machine+buy_guard+order_allocators+arbitrations)\x20→\x20Publish\x20Service\x20→\x20Test\x20order\x20(3\x20paths:\x20normal/cancel/dispute)'],'example_use_case':'Monthly\x20SaaS\x20subscription:\x20$10/month.\x20Customer\x20can\x20renew\x20anytime\x20after\x20day\x2025.\x20'+'Auto-expire\x20on\x20day\x2035\x20if\x20not\x20renewed.\x20Cancel\x20anytime.\x0a\x0a'+'VARIANT\x20—\x20Content\x20subscription\x20(Substack-style):\x20$5/month\x20newsletter.\x20Author\x20publishes\x20content\x20→\x20'+'subscriber\x20reads.\x20Subscriber\x20can\x20cancel\x20anytime\x20for\x20full\x20refund.\x20Disputes\x20resolved\x20by\x20arbitrator\x20'+'(100%\x20refund\x20to\x20subscriber\x20if\x20dispute\x20upheld).\x206-node\x20Machine,\x203\x20Guards,\x203\x20Allocators.\x20'+'Tested\x20on\x20testnet\x20with\x203\x20order\x20paths:\x20normal\x20delivery,\x20cancel,\x20dispute.','publish_checklist':['Time-lock\x20Guards\x20tested\x20on\x20testnet\x20(both\x20TimeUnlock\x20+\x20AutoExpire)','Competing\x20Pair\x20semantics\x20verified\x20(Renew\x20vs\x20Expire\x20vs\x20Cancel)','Repository\x20write\x20tested\x20(subscription\x20status\x20queryable)','Renewal\x20loop\x20tested:\x20Paid\x20->\x20Active\x20->\x20RenewEligible\x20->\x20Renewed\x20->\x20Active','Content\x20variant:\x20initial\x20node\x20(prev_node=\x27\x27)\x20MUST\x20have\x20at\x20least\x20one\x20forward\x20(FIX-002)\x20—\x20empty\x20forwards=[]\x20causes\x20Progress\x20to\x20be\x20permanently\x20stuck','Content\x20variant:\x20arbitrations\x20added\x20BEFORE\x20publish\x20(cannot\x20add\x20post-publish\x20per\x20F-S-21)','Content\x20variant:\x203\x20order\x20paths\x20tested\x20on\x20testnet\x20—\x20normal\x20delivery,\x20cancel-within-grace,\x20dispute-resolution','Content\x20variant:\x20machineNode2file\x20export\x20as\x20backup\x20(covers\x20all\x206\x20nodes)']}];export const MACHINE_TEMPLATES_VERSION='1.0.0';export const MACHINE_TEMPLATES_COUNT=MACHINE_TEMPLATES['length'];export function getAllTemplates(){return MACHINE_TEMPLATES;}export function getTemplateById(a){return MACHINE_TEMPLATES['find'](b=>b['id']===a);}export function getTemplatesByScene(a){return MACHINE_TEMPLATES['filter'](b=>b['scene_id']===a);}export function getTemplatesByIndustry(a){return MACHINE_TEMPLATES['filter'](b=>b['applicable_industries']['includes'](a));}export function getTemplatesByPattern(a){return MACHINE_TEMPLATES['filter'](b=>b['recommended_patterns']['includes'](a));}export function suggestTemplateForIntent(a){const b=inferSceneFromFlow(a);if(!b)return undefined;const c=getTemplatesByScene(b['id']);return c[0x0];}export function getTemplateParameters(a){const b=getTemplateById(a);return b?b['parameters']:[];}export function getRequiredParameters(a){return getTemplateParameters(a)['filter'](b=>b['required']);}export function getOptionalParameters(a){return getTemplateParameters(a)['filter'](b=>!b['required']);}function validateParamType(a,b){switch(b){case'address':case'string':case'permission_ref':case'guard_ref':case'machine_ref':case'service_ref':case'arbitration_ref':case'reward_ref':return typeof a==='string';case'number':return typeof a==='number'||typeof a==='string'&&/^\d+$/['test'](a);case'boolean':return typeof a==='boolean';case'vec_address':case'vec_string':case'node_name_list':return Array['isArray'](a)&&a['every'](c=>typeof c==='string');default:return![];}}function deepSubstitute(a,b){if(typeof a==='string')return a['replace'](/\$\{(\w+)\}/g,(c,d)=>d in b?String(b[d]):'${'+d+'}');if(Array['isArray'](a))return a['map'](c=>deepSubstitute(c,b));if(a&&typeof a==='object'){const c={};for(const [d,e]of Object['entries'](a)){c[d]=deepSubstitute(e,b);}return c;}return a;}export function fillTemplate(a,b){const c=getTemplateById(a);if(!c)return{'success':![],'validation_errors':['Template\x20not\x20found:\x20'+a]};const d=c['parameters']['filter'](h=>h['required']&&!(h['name']in b))['map'](h=>h['name']);if(d['length']>0x0)return{'success':![],'missing_params':d,'validation_errors':['Missing\x20required\x20parameters:\x20'+d['join'](',\x20')]};const e=[];for(const h of c['parameters']){if(h['name']in b){const i=b[h['name']];!validateParamType(i,h['type'])&&e['push']('Parameter\x20\x22'+h['name']+'\x22\x20type\x20mismatch:\x20expected\x20'+h['type']+',\x20got\x20'+typeof i);}}if(e['length']>0x0)return{'success':![],'validation_errors':e};const f=deepSubstitute(c['example_nodes'],b),g=deepSubstitute(c['example_pairs'],b);return{'success':!![],'filled_nodes':f,'filled_pairs':g};}export function forkTemplate(a){const b=getTemplateById(a);if(!b)return undefined;const c={};for(const d of b['forkable_fields']){c[d]='see\x20example_nodes/example_pairs';}return{'template_id':a,'forkable_fields':b['forkable_fields'],'current_values':c,'instructions':['Modify\x20fields\x20below\x20to\x20customize\x20the\x20workflow','Keep\x20template\x20structure\x20intact\x20unless\x20explicitly\x20noted','Run\x20risk\x20assessment\x20after\x20modification\x20(machine-risk.ts)','User\x20MUST\x20confirm\x20final\x20JSON\x20before\x20publish\x20(ConfirmGate)']};}export const DECISION_TREE={'Q1':{'question':'Does\x20the\x20workflow\x20involve\x20multiple\x20independent\x20services/parties?','no_next':'Q3'},'Q2':{'question':'Are\x20these\x20services\x20already\x20published\x20as\x20separate\x20Machines?','yes_template':'tpl_machine_cross_machine','no_next':'DECOMPOSE'},'Q3':{'question':'Does\x20any\x20node\x20require\x20multiple\x20parties\x27\x20confirmation\x20to\x20advance?','no_next':'Q5'},'Q4':{'question':'Do\x20all\x20parties\x20have\x20EQUAL\x20weight?','yes_template':'tpl_machine_dual_signature','no_next':'tpl_machine_weighted_voting'},'Q5':{'question':'Does\x20the\x20workflow\x20need\x20exception\x20branches\x20(lost,\x20return,\x20dispute)?','yes_template':'tpl_machine_ecommerce_exceptions','no_next':'Q6'},'Q6':{'question':'Does\x20it\x20involve\x20recurring\x20payments\x20or\x20time-based\x20state\x20changes?','yes_template':'tpl_machine_subscription','no_next':'Q7'},'Q7':{'question':'Does\x20it\x20need\x20privacy-preserving\x20data\x20delivery\x20(Messenger)?','yes_template':'tpl_machine_privacy_delivery','no_next':'Q8'},'Q8':{'question':'Does\x20it\x20involve\x20deposit/refund\x20separation?','yes_template':'tpl_machine_rental','no_next':'Q9'},'Q9':{'question':'Does\x20it\x20need\x20reward/incentive\x20distribution\x20at\x20a\x20specific\x20node?','yes_template':'tpl_machine_reward','no_next':'tpl_machine_ecommerce_standard'}};export function walkDecisionTree(a){let b='Q1';while(b){const c=DECISION_TREE[b];if(!c)return'UNKNOWN';const d=a[b];if(d===undefined)return b;if(d){if(c['yes_template'])return c['yes_template'];if(b==='Q1'){b='Q2';continue;}if(b==='Q3'){b='Q4';continue;}return'UNKNOWN';}else{if(c['no_next']){if(c['no_next']==='DECOMPOSE')return'DECOMPOSE_INTO_MULTIPLE_MACHINES';if(c['no_next']['startsWith']('tpl_'))return c['no_next'];b=c['no_next'];continue;}return'UNKNOWN';}}return'UNKNOWN';}export function verifyTemplateSceneReferences(){const a=[];for(const b of MACHINE_TEMPLATES){!findScene(b['scene_id'])&&a['push']({'template_id':b['id'],'invalid_scene_id':b['scene_id']});}return a;}export function getReferencedGuardTemplateIds(){const a=new Set();for(const b of MACHINE_TEMPLATES){for(const c of b['required_guards']){a['add'](c['guard_template_id']);}}return a;}export function getReferencedRiskIds(){const a=new Set();for(const b of MACHINE_TEMPLATES){for(const c of b['relevant_risks']){a['add'](c);}}return a;}export function listTemplates(){return MACHINE_TEMPLATES['map'](a=>({'id':a['id'],'name':a['name'],'scene_id':a['scene_id'],'patterns':a['recommended_patterns'],'industries':a['applicable_industries']}));}