@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,1105 +1 @@
1
- export const GUARD_TEMPLATES = [
2
- {
3
- id: "tpl_buy_guard_whitelist",
4
- scene_id: "service_buy_guard",
5
- name: "Whitelist purchase validation",
6
- description: "Only addresses in the whitelist can purchase the service. Suitable for limited-time sales, VIP exclusives, internal testing eligibility, etc.",
7
- recommended_patterns: ["P04", "P03"],
8
- parameters: [
9
- { name: "whitelist", type: "vec_address", description: "List of authorized addresses", required: true,
10
- constraint: "Each address must be valid and unique" },
11
- { name: "service_name", type: "string", description: "Service object name (used for circular references)", required: false,
12
- constraint: "If P16 circular reference is used, a name must be provided rather than an address" },
13
- ],
14
- example_table: [
15
- { identifier: 0, b_submission: false, value_type: "Vec<Address>", value: "${whitelist}", name: "Authorized purchase whitelist" },
16
- ],
17
- example_root: {
18
- type: "vec_contains_address",
19
- vec: { type: "identifier", identifier: 0 },
20
- target: { type: "context", context: "Signer" },
21
- },
22
- applicable_industries: ["rental", "ecommerce", "education", "travel", "subscription"],
23
- relevant_risks: ["R-C1-01", "R-C3-01", "R-C4-01"],
24
- creation_notes: [
25
- "Updating the whitelist requires rebuilding the Guard (buy_guard is iterable)",
26
- "If the Service is already published, the table can use the address directly; otherwise use the name (P16 circular reference)",
27
- ],
28
- example_use_case: "Internal testing phase for camera equipment rental, allowing only the first 50 seed users to place rental orders.",
29
- verifier_constraint_level: "level2_identity_set",
30
- },
31
- {
32
- id: "tpl_allocator_threshold",
33
- scene_id: "service_order_allocators_guard",
34
- name: "Allocation amount threshold validation",
35
- description: "Selects different allocation strategies based on the order amount. When the amount exceeds the threshold, advanced allocation is used; otherwise, default allocation applies.",
36
- recommended_patterns: ["P02", "P10"],
37
- parameters: [
38
- { name: "threshold", type: "number", description: "Allocation threshold (unit: smallest precision)", required: true,
39
- constraint: "Must be > 0; a reasonable range is recommended to avoid boundary gaming" },
40
- { name: "service_name", type: "string", description: "Service object name", required: true },
41
- ],
42
- example_table: [
43
- { identifier: 0, b_submission: false, value_type: "Address", value: "${service_name}", name: "Service object" },
44
- { identifier: 1, b_submission: false, value_type: "U64", value: "${threshold}", name: "Allocation threshold" },
45
- ],
46
- example_root: {
47
- type: "logic_as_u256_greater",
48
- left: { type: "query", query: "order.amount", object: { identifier: 0 }, parameters: [] },
49
- right: { type: "identifier", identifier: 1 },
50
- },
51
- applicable_industries: ["ecommerce", "rental", "education", "travel"],
52
- relevant_risks: ["R-X1-01", "R-X1-05", "R-X1-08"],
53
- creation_notes: [
54
- "order_allocators cannot be modified after binding (immutable after publish)",
55
- "First-match-wins mechanism: multiple allocators are matched in order; the first one that passes executes",
56
- "Threshold boundary must be tested: behavior when exactly equal to the threshold (> vs >=)",
57
- ],
58
- example_use_case: "E-commerce platform: order amount > 1000 WOW triggers 3-way allocation (platform + merchant + logistics); otherwise 2-way allocation (platform + merchant).",
59
- verifier_constraint_level: "level3_scene_combined",
60
- },
61
- {
62
- id: "tpl_allocator_treasury_personal",
63
- scene_id: "service_order_allocators_guard",
64
- name: "Treasury + personal address allocation (Entity sharing)",
65
- description: "2 allocators representing 2 merchant collection approaches: (1) named Treasury address for public fund aggregation, (2) fixed personal address. " +
66
- "Uses sharing.who=Entity so funds always flow to the legitimate recipient regardless of caller — no Signer binding needed in Guard. " +
67
- "Guards verify the order is at the Complete node + belongs to the service (project binding).",
68
- recommended_patterns: ["P02", "P10", "P16"],
69
- parameters: [
70
- { name: "service_name", type: "string", description: "Service object name (circular ref via P16 — resolved after Service publish)", required: true,
71
- constraint: "Must be a name, not an address (the Service is not yet published when the Guard is created)" },
72
- { name: "complete_node_name", type: "string", description: "Expected node name that triggers allocation (e.g. 'Complete')", required: true,
73
- default: "Complete", constraint: "Must exactly match the Machine node name (case-sensitive)" },
74
- { name: "treasury_name", type: "string", description: "Named Treasury object (created with the Service's permission)", required: true,
75
- constraint: "Treasury must be created before the Service; use the SAME permission as the Service for consistency" },
76
- { name: "personal_address", type: "address", description: "Fixed personal collection address (e.g. the permission creator's address)", required: true },
77
- ],
78
- example_table: [
79
- { identifier: 0, b_submission: true, value_type: "Address", object_type: "Order",
80
- name: "order_id (Order object submitted at runtime)" },
81
- { identifier: 1, b_submission: false, value_type: "String", value: "${complete_node_name}",
82
- name: "Expected Complete node name (case-sensitive)" },
83
- { identifier: 2, b_submission: false, value_type: "Address", value: "${service_name}",
84
- name: "Service object (project binding, circular ref via name)" },
85
- ],
86
- example_root: {
87
- type: "logic_and",
88
- nodes: [
89
- {
90
- type: "logic_equal",
91
- nodes: [
92
- { type: "query", query: "progress.current", object: { identifier: 0, convert_witness: "OrderProgress" }, parameters: [] },
93
- { type: "identifier", identifier: 1 },
94
- ],
95
- },
96
- {
97
- type: "logic_equal",
98
- nodes: [
99
- { type: "query", query: "order.service", object: { identifier: 0 }, parameters: [] },
100
- { type: "identifier", identifier: 2 },
101
- ],
102
- },
103
- ],
104
- },
105
- applicable_industries: ["insurance", "ecommerce", "travel", "rental", "subscription"],
106
- relevant_risks: ["R-C3-05", "R-C3-06", "R-X1-05", "R-X1-01"],
107
- creation_notes: [
108
- "2 Guard objects with IDENTICAL root/table but DIFFERENT descriptions (allocators require unique guard addresses — no two allocators may reference the same Guard).",
109
- "sharing.who=Entity (Treasury/personal) — no Signer binding needed in the Guard (R-C3-06 safe).",
110
- "First-match-wins: only the first allocator (Treasury) executes; the personal allocator is an alternative (swap the allocators order to activate personal collection).",
111
- "Treasury should be created with the SAME permission as the Service (permission consistency — different permissions = minor risk).",
112
- "order.service binding (query 1563) suppresses R-C3-05 (cross-project bypass prevents premature allocation on foreign orders).",
113
- "order_allocators is immutable after Service publish — verify the Guard logic and sharing config before publishing.",
114
- ],
115
- example_use_case: "Insurance service: after a claim reaches the Complete node, order funds are allocated to the insurance Treasury " +
116
- "(approach 1, for operational fund aggregation) or to the provider's personal address (approach 2, for direct income).",
117
- verifier_constraint_level: "level3_scene_combined",
118
- },
119
- {
120
- id: "tpl_allocator_identity_set_order_holder",
121
- scene_id: "service_order_allocators_guard",
122
- name: "Order-holder identity-set allocation (Level 2)",
123
- description: "Level 2 identity-set binding: Signer is order.owner (1562, Address) OR order.agent (1567, Bool with [Signer] param). " +
124
- "Demonstrates the mixed return-type construction pattern — Address-returning queries are wrapped in logic_equal, " +
125
- "while Bool-returning queries (suffix 'has') are used directly as logic_or children. " +
126
- "Combined with order.service binding (R-C3-05) for cross-service theft prevention. " +
127
- "Use when either the order owner or an authorized agent should be able to trigger allocation (e.g. refund to caller).",
128
- recommended_patterns: ["P02", "P10", "P16"],
129
- parameters: [
130
- { name: "service_name", type: "string", description: "Service object name (circular ref via P16)", required: true,
131
- constraint: "Must be a name, not an address (the Service is not yet published when the Guard is created)" },
132
- ],
133
- example_table: [
134
- { identifier: 0, b_submission: true, value_type: "Address", object_type: "Order",
135
- name: "order_id (Order object submitted at runtime)" },
136
- { identifier: 1, b_submission: false, value_type: "Address", value: "${service_name}",
137
- name: "Service object (project binding, circular ref via name)" },
138
- ],
139
- example_root: {
140
- type: "logic_and",
141
- nodes: [
142
- {
143
- type: "logic_or",
144
- nodes: [
145
- {
146
- type: "logic_equal",
147
- nodes: [
148
- { type: "query", query: "order.owner", object: { identifier: 0 }, parameters: [] },
149
- { type: "context", context: "Signer" },
150
- ],
151
- },
152
- {
153
- type: "query",
154
- query: "order.agent has",
155
- object: { identifier: 0 },
156
- parameters: [{ type: "context", context: "Signer" }],
157
- },
158
- ],
159
- },
160
- {
161
- type: "logic_equal",
162
- nodes: [
163
- { type: "query", query: "order.service", object: { identifier: 0 }, parameters: [] },
164
- { type: "identifier", identifier: 1 },
165
- ],
166
- },
167
- ],
168
- },
169
- applicable_industries: ["ecommerce", "rental", "travel", "subscription"],
170
- relevant_risks: ["R-C3-01", "R-C3-05", "R-C3-06", "R-C4-04"],
171
- creation_notes: [
172
- "MIXED RETURN-TYPE CONSTRUCTION (key Level 2 pattern): query 1562 (order.owner) returns Address → wrap in logic_equal with context(Signer); query 1567 (order.agent has) returns Bool → use directly as logic_or child with parameters: [context(Signer)].",
173
- "logic_or wrapping of the Signer check suppresses R-C4-04 (Level 1 strict binding convenience warning) — this is the recommended Level 2 alternative.",
174
- "Use this pattern when sharing.who=Signer (funds flow to caller) AND either the owner or an agent should be authorized to trigger allocation.",
175
- "order.service binding (query 1563) suppresses R-C3-05 (cross-project bypass).",
176
- "If agents are not needed, use the simpler Level 2 dynamic pattern: logic_equal[query(1562), context(Signer)] without logic_or.",
177
- ],
178
- example_use_case: "Refund allocation: when an order is cancelled, either the order owner or an authorized agent can trigger the refund. " +
179
- "The Guard verifies Signer is order.owner OR order.agent, and that the order belongs to this service.",
180
- verifier_constraint_level: "level2_identity_set",
181
- },
182
- {
183
- id: "tpl_allocator_identity_set_service_provider_dynamic",
184
- scene_id: "service_order_allocators_guard",
185
- name: "Service-provider identity-set allocation with dynamic permission (Level 2)",
186
- description: "Level 2 identity-set binding with DYNAMIC permission address: Signer is permission.owner (1002, Address) OR " +
187
- "has admin (1004, Bool with [Signer] param). The permission address is submitted by the caller and verified " +
188
- "against service.permission (1488) — this survives permission rotation without rebuilding the Guard. " +
189
- "Use when the Service may rotate its permission (like a company changing its board) and a static permission " +
190
- "address would break the Guard.",
191
- recommended_patterns: ["P02", "P10", "P16"],
192
- parameters: [
193
- { name: "service_name", type: "string", description: "Service object name (circular ref via P16)", required: true,
194
- constraint: "Must be a name, not an address (the Service is not yet published when the Guard is created)" },
195
- ],
196
- example_table: [
197
- { identifier: 0, b_submission: true, value_type: "Address", object_type: "Order",
198
- name: "order_id (Order object submitted at runtime)" },
199
- { identifier: 1, b_submission: false, value_type: "Address", value: "${service_name}",
200
- name: "Service object (project binding, circular ref via name)" },
201
- { identifier: 2, b_submission: true, value_type: "Address", object_type: "Permission",
202
- name: "permission_id (Permission object submitted by caller — must equal service.permission)" },
203
- ],
204
- example_root: {
205
- type: "logic_and",
206
- nodes: [
207
- {
208
- type: "logic_equal",
209
- nodes: [
210
- { type: "query", query: "order.service", object: { identifier: 0 }, parameters: [] },
211
- { type: "identifier", identifier: 1 },
212
- ],
213
- },
214
- {
215
- type: "logic_equal",
216
- nodes: [
217
- { type: "query", query: "service.permission", object: { identifier: 1 }, parameters: [] },
218
- { type: "identifier", identifier: 2 },
219
- ],
220
- },
221
- {
222
- type: "logic_or",
223
- nodes: [
224
- {
225
- type: "logic_equal",
226
- nodes: [
227
- { type: "query", query: "permission.owner", object: { identifier: 2 }, parameters: [] },
228
- { type: "context", context: "Signer" },
229
- ],
230
- },
231
- {
232
- type: "query",
233
- query: "permission.admin has",
234
- object: { identifier: 2 },
235
- parameters: [{ type: "context", context: "Signer" }],
236
- },
237
- ],
238
- },
239
- ],
240
- },
241
- applicable_industries: ["ecommerce", "rental", "insurance", "travel", "subscription"],
242
- relevant_risks: ["R-C3-01", "R-C3-05", "R-C3-06", "R-C4-04"],
243
- creation_notes: [
244
- "DYNAMIC PERMISSION VERIFICATION (key pattern): caller submits a Permission address (identifier 2); Guard verifies query(1488: service.permission) == submitted permission, then checks 1002/1004 against the submitted permission. This survives permission rotation — if the Service changes its permission, the Guard still works without rebuilding.",
245
- "MIXED RETURN-TYPE CONSTRUCTION: query 1002 (permission.owner) returns Address → wrap in logic_equal; query 1004 (permission.admin has) returns Bool → use directly as logic_or child with parameters: [context(Signer)].",
246
- "logic_or wrapping of the Signer check suppresses R-C4-04 (Level 1 strict binding convenience warning).",
247
- "THREE conditions in logic_and: (1) order.service binding (R-C3-05), (2) dynamic permission verification, (3) identity set (owner OR admin).",
248
- "Static permission alternative (simpler but breaks on rotation): use a table constant for the permission address instead of b_submission=true + 1488 verification.",
249
- "Repository-based address set (most flexible, most complex): store the permission address set in a Repository and query dynamically — only for extreme flexibility needs.",
250
- ],
251
- example_use_case: "Merchant allocation: the Service may rotate its permission (like a company changing its board). " +
252
- "The caller submits the current permission address; the Guard verifies it matches service.permission (1488), " +
253
- "then checks that Signer is the permission owner or has admin rights.",
254
- verifier_constraint_level: "level2_identity_set",
255
- },
256
- {
257
- id: "tpl_forward_node_check",
258
- scene_id: "machine_forward_guard",
259
- name: "Workflow node state validation",
260
- description: "Verifies that the order is currently at the correct Machine node before advancing to the next step. Prevents skipping nodes or reverse operations.",
261
- recommended_patterns: ["P06", "P09"],
262
- parameters: [
263
- { name: "expected_node", type: "string", description: "Expected current node name", required: true,
264
- constraint: "Must exactly match the name defined in Machine nodes (case-sensitive)" },
265
- ],
266
- example_table: [
267
- { identifier: 0, b_submission: true, value_type: "Address", name: "Order object address",
268
- object_type: "Order" },
269
- { identifier: 1, b_submission: false, value_type: "String", value: "${expected_node}",
270
- name: "Expected current node name" },
271
- ],
272
- example_root: {
273
- type: "logic_equal",
274
- left: {
275
- type: "query", query: "progress.current",
276
- object: { identifier: 0, convert_witness: "OrderProgress" },
277
- parameters: [],
278
- },
279
- right: { type: "identifier", identifier: 1 },
280
- },
281
- applicable_industries: ["rental", "ecommerce", "education", "travel", "subscription"],
282
- relevant_risks: ["R-C2-01", "R-C2-03", "R-X1-08"],
283
- creation_notes: [
284
- "Forward.guard cannot be modified after binding (immutable after Machine publish)",
285
- "witness 100 (Order→Progress) is a single hop; no risk of chained-derivation breakage",
286
- "Node names are case-sensitive; query returns a String type",
287
- ],
288
- example_use_case: "Camera equipment rental flow: the user must be at the 'pending return' node to perform the return operation.",
289
- verifier_constraint_level: "level3_scene_combined",
290
- },
291
- {
292
- id: "tpl_forward_privacy_delivery_proof",
293
- scene_id: "machine_forward_guard",
294
- name: "Privacy-delivery Proof verification (strict mode, Messenger → on-chain Proof)",
295
- description: "Strict-mode guard for 'privacy information delivered via Messenger but not suitable for on-chain publication' " +
296
- "(e.g. shipping details, return addresses, private credentials). The verifier submits BOTH a Proof object address " +
297
- "(generated by messenger.submitChainProof) AND the Order object address. Three conditions verify: " +
298
- "(1) Signer == proof.signer (submitter accountability — 'whoever benefits bears the burden of proof'), " +
299
- "(2) proof.time > order.time (proof created after the order — freshness, prevents stale-proof replay), " +
300
- "(3) order.service == service (project binding, suppresses R-C3-05 cross-project bypass). " +
301
- "No content verification — only submission responsibility. The counterparty can dispute by checking their own " +
302
- "Messenger conversation. Broad-mode alternative (verify Merkle Root string length == 66 via P15) is documented " +
303
- "in creation_notes — broad mode trusts the submitter's honesty and is suitable when the Guard is mainly an " +
304
- "arbitration basis rather than a fund-flow gate.",
305
- recommended_patterns: ["P10", "P15"],
306
- parameters: [
307
- { name: "service_name", type: "string", description: "Service object name (circular ref via P16 — resolved after Service publish)", required: true,
308
- constraint: "Must be a name, not an address (the Service is not yet published when the Guard is created)" },
309
- ],
310
- example_table: [
311
- { identifier: 0, b_submission: true, value_type: "Address", object_type: "Proof",
312
- name: "proof_object (Proof address generated by messenger.submitChainProof, submitted by verifier at runtime)",
313
- binding_constraint: "Must be a Proof object created AFTER the order; signer must equal the transaction Signer" },
314
- { identifier: 1, b_submission: true, value_type: "Address", object_type: "Order",
315
- name: "order_object (Order address submitted by verifier at runtime)",
316
- binding_constraint: "Must belong to the service declared in identifier 2 (order.service == service)" },
317
- { identifier: 2, b_submission: false, value_type: "Address", value: "${service_name}",
318
- name: "Service object (project binding, circular ref via name)" },
319
- ],
320
- example_root: {
321
- type: "logic_and",
322
- nodes: [
323
- {
324
- type: "logic_equal",
325
- nodes: [
326
- { type: "context", context: "Signer" },
327
- { type: "query", query: "proof.signer", object: { identifier: 0 }, parameters: [] },
328
- ],
329
- },
330
- {
331
- type: "logic_as_u256_greater",
332
- nodes: [
333
- { type: "query", query: "proof.time", object: { identifier: 0 }, parameters: [] },
334
- { type: "query", query: "order.time", object: { identifier: 1 }, parameters: [] },
335
- ],
336
- },
337
- {
338
- type: "logic_equal",
339
- nodes: [
340
- { type: "query", query: "order.service", object: { identifier: 1 }, parameters: [] },
341
- { type: "identifier", identifier: 2 },
342
- ],
343
- },
344
- ],
345
- },
346
- applicable_industries: ["ecommerce", "logistics", "service", "privacy delivery"],
347
- relevant_risks: ["R-C3-01", "R-C3-05", "R-X1-12"],
348
- creation_notes: [
349
- "STRICT MODE (this template): verifier submits Proof + Order addresses. Three conditions: Signer==proof.signer (submitter accountability), proof.time>order.time (freshness), order.service==service (project binding). No content verification — only submission responsibility ('beneficiary bears burden of proof' principle).",
350
- "BROAD MODE ALTERNATIVE: use P15 retained_submission with a String submission (the Merkle Root) and verify calc_string_length == 66 (0x prefix + 64 hex chars). Broad mode trusts the submitter's honesty; the counterparty can dispute by checking their own Messenger conversation. Broad mode is suitable when the Guard is mainly an arbitration basis, not a fund-flow gate.",
351
- "Guard table supports MULTIPLE b_submission=true Address identifiers (no submission count limit) — this template uses two: Proof (identifier 0) and Order (identifier 1).",
352
- "submitChainProof(env, peerAddress, description?) sets Proof.about = peerAddress (the counterparty's address). Pass the order_id as a string in the description parameter to associate the Proof with an order (e.g. description: 'order:0x123...').",
353
- "Query IDs (all zero-parameter): proof.signer=1958, proof.time=1960 (invariant clock_derived, always >0), order.time=1574, order.service=1563.",
354
- "Forward.guard is immutable after Machine publish — choose broad vs strict before publishing.",
355
- "The same strict Guard can be reused across ALL Machine forwards that need merkle-root verification (shipping, lost, returns, etc.) — the verifier just submits the relevant Proof + Order each time.",
356
- "Condition (1) Signer==proof.signer suppresses R-C3-01 (submission not bound to Signer). Condition (3) order.service==service suppresses R-C3-05 (cross-project submission bypass).",
357
- ],
358
- example_use_case: "MyShop e-commerce: after delivering shipping details / return addresses via Messenger (privacy info not suitable for on-chain publication), " +
359
- "the provider generates a Proof via submitChainProof and submits it with the Order address to advance the Machine forward. " +
360
- "The Guard verifies the submitter is the Proof's signer, the Proof was created after the order, and the order belongs to this service.",
361
- verifier_constraint_level: "level3_scene_combined",
362
- },
363
- {
364
- id: "tpl_submission_signer_binding",
365
- scene_id: "progress_submission_guard",
366
- name: "Submission data signer binding validation",
367
- description: "Verifies that the user submitting the data is a legitimate Progress participant and that the submitted value matches expectations.",
368
- recommended_patterns: ["P08", "P15"],
369
- parameters: [
370
- { name: "expected_value", type: "string", description: "Expected submitted value (e.g. node name, status code)", required: true },
371
- { name: "provider_address", type: "address", description: "Service provider address (used for identity verification)", required: true },
372
- ],
373
- example_table: [
374
- { identifier: 0, b_submission: true, value_type: "String",
375
- name: "User-submitted operation type (e.g. 'return' / 'damage')",
376
- binding_constraint: "Must be one of the predefined operation types" },
377
- { identifier: 1, b_submission: false, value_type: "Address",
378
- value: "${provider_address}", name: "Service provider address" },
379
- { identifier: 2, b_submission: false, value_type: "String",
380
- value: "${expected_value}", name: "Expected submitted value" },
381
- ],
382
- example_root: {
383
- type: "logic_and",
384
- nodes: [
385
- { type: "logic_equal",
386
- nodes: [{ type: "identifier", identifier: 0 }, { type: "identifier", identifier: 2 }] },
387
- { type: "logic_equal",
388
- nodes: [{ type: "context", context: "Signer" }, { type: "identifier", identifier: 1 }] },
389
- ],
390
- },
391
- applicable_industries: ["rental", "ecommerce", "education", "travel"],
392
- relevant_risks: ["R-C3-01", "R-C3-03", "R-X1-12"],
393
- creation_notes: [
394
- "submission guard cannot be modified after binding",
395
- "The name of b_submission=true entries must be a complete natural-language description (≥10 characters)",
396
- "Providing a binding_constraint field describing value rules is recommended (R-X1-12)",
397
- ],
398
- example_use_case: "On equipment return, the user submits the 'return' operation; the Guard verifies that the submitter is the service provider and that the operation type is correct.",
399
- verifier_constraint_level: "level1_strict",
400
- },
401
- {
402
- id: "tpl_reward_one_time_claim",
403
- scene_id: "reward_guard",
404
- name: "One-time reward claim validation",
405
- description: "Verifies that the user is claiming the reward for the first time, preventing duplicate claims. Implemented by querying the historical record count via Repository.",
406
- recommended_patterns: ["P07", "P13"],
407
- parameters: [
408
- { name: "repository_address", type: "address", description: "Repository object address (stores claim records)", required: true },
409
- ],
410
- example_table: [
411
- { identifier: 0, b_submission: false, value_type: "Address",
412
- value: "${repository_address}", name: "Reward claim record Repository",
413
- object_type: "Repository" },
414
- { identifier: 1, b_submission: false, value_type: "U64",
415
- value: "0", name: "First-claim threshold (record_count == 0)" },
416
- ],
417
- example_root: {
418
- type: "logic_equal",
419
- left: {
420
- type: "query", query: "repository.data",
421
- object: { identifier: 0 },
422
- parameters: [{ type: "context", context: "Signer" }],
423
- },
424
- right: { type: "identifier", identifier: 1 },
425
- },
426
- applicable_industries: ["ecommerce", "education", "travel", "subscription"],
427
- relevant_risks: ["R-C1-03", "R-X1-01", "R-X1-10"],
428
- creation_notes: [
429
- "Repository with quote_guard: rigid verification — any guard querying this Repository's data MUST satisfy the quote_guard (see R-X1-10, pattern.repository_quote_guard_subscription)",
430
- "repository.data query returns U64 (record count), compared with identifier[1] (value 0)",
431
- "Reward guard is iterable; duplicate-claim protection requires rebuilding the Guard to update the Repository address",
432
- ],
433
- example_use_case: "New-user first-order reward: query the user's historical order count via Repository; allow claim only when record_count==0.",
434
- verifier_constraint_level: "level3_scene_combined",
435
- },
436
- {
437
- id: "tpl_write_guard_type_check",
438
- scene_id: "repository_write_guard",
439
- name: "Storage write type validation",
440
- description: "Verifies that the data type written to the Repository matches the declaration and that the writer's identity is legitimate.",
441
- recommended_patterns: ["P08", "P11"],
442
- parameters: [
443
- { name: "repository_address", type: "address", description: "Repository object address", required: true,
444
- constraint: "Must be the address of an already-published Repository" },
445
- { name: "entity_registrar", type: "address", description: "EntityRegistrar address (fixed 0xaab)", required: false,
446
- default: "0xaab" },
447
- ],
448
- example_table: [
449
- { identifier: 0, b_submission: true, value_type: "Address",
450
- name: "Writer address (submitted by caller)",
451
- binding_constraint: "Must be a valid Entity address" },
452
- { identifier: 1, b_submission: true, value_type: "String",
453
- name: "Write data key name (submitted by caller)",
454
- binding_constraint: "Key name format must be 'category:key'" },
455
- { identifier: 2, b_submission: false, value_type: "Address",
456
- value: "${entity_registrar}", name: "EntityRegistrar system address",
457
- is_system_address: true },
458
- ],
459
- example_root: {
460
- type: "logic_and",
461
- nodes: [
462
- { type: "logic_equal",
463
- nodes: [{ type: "context", context: "Signer" }, { type: "identifier", identifier: 0 }] },
464
- { type: "logic_not_equal",
465
- nodes: [{ type: "identifier", identifier: 0 }, { type: "identifier", identifier: 2 }] },
466
- ],
467
- },
468
- applicable_industries: ["ecommerce", "education", "travel", "subscription", "rental"],
469
- relevant_risks: ["R-C1-02", "R-C3-03", "R-C3-04"],
470
- creation_notes: [
471
- "id_from_submission in write_guard must be of Address type",
472
- "data_from_submission must match the Repository value_type",
473
- "EntityRegistrar (0xaab) and EntityLinker (0xaaa) are fixed system addresses",
474
- ],
475
- example_use_case: "E-commerce platform merchant writes product review data; the Guard verifies that the writer is a registered Entity and not a system address.",
476
- verifier_constraint_level: "level1_strict",
477
- },
478
- {
479
- id: "tpl_usage_guard_threshold",
480
- scene_id: "arbitration_usage_guard",
481
- name: "Dispute initiation threshold validation",
482
- description: "Verifies that the dispute initiator meets minimum conditions (e.g. order amount, time window), filtering out meaningless disputes.",
483
- recommended_patterns: ["P02", "P10"],
484
- parameters: [
485
- { name: "min_amount", type: "number", description: "Minimum dispute amount threshold", required: true,
486
- constraint: "A reasonable threshold is recommended; too high hinders user rights protection, too low produces many invalid disputes" },
487
- ],
488
- example_table: [
489
- { identifier: 0, b_submission: true, value_type: "Address",
490
- name: "Dispute-related Order object address", object_type: "Order" },
491
- { identifier: 1, b_submission: false, value_type: "U64",
492
- value: "${min_amount}", name: "Minimum dispute amount threshold" },
493
- ],
494
- example_root: {
495
- type: "logic_as_u256_greater_or_equal",
496
- left: { type: "query", query: "order.amount", object: { identifier: 0 }, parameters: [] },
497
- right: { type: "identifier", identifier: 1 },
498
- },
499
- applicable_industries: ["ecommerce", "rental", "education", "travel"],
500
- relevant_risks: ["R-X1-01", "R-X1-07", "R-C3-03"],
501
- creation_notes: [
502
- "usage_guard is iterable (Arbitration can be updated)",
503
- "AND conditions should not be too many (R-X1-07); ≤3 conditions recommended",
504
- "When Arbitration bPaused=true, blocking takes priority (checked before Guard)",
505
- ],
506
- example_use_case: "Rental service dispute: only disputes with order amount ≥ 10 WOW are accepted, filtering out small-amount conflicts.",
507
- verifier_constraint_level: "level3_scene_combined",
508
- },
509
- {
510
- id: "tpl_voting_guard_numeric_weight",
511
- scene_id: "arbitration_voting_guard",
512
- name: "Numeric voting weight validation",
513
- description: "Assigns numeric voting weights based on arbitrator rank; higher-rank arbitrators have greater weight.",
514
- recommended_patterns: ["P12"],
515
- parameters: [
516
- { name: "arbiter_weights", type: "vec_address", description: "Arbitrator address to weight mapping (address:weight pairs)", required: true,
517
- constraint: "Weights must be numeric types U8-U256" },
518
- ],
519
- example_table: [
520
- { identifier: 0, b_submission: true, value_type: "Address",
521
- name: "Arbitrator address (submitted by caller)", object_type: "Arb" },
522
- { identifier: 1, b_submission: false, value_type: "Vec<Address>",
523
- value: "${arbiter_weights}", name: "Authorized arbitrator address list" },
524
- ],
525
- example_root: {
526
- type: "vec_contains_address",
527
- vec: { type: "identifier", identifier: 1 },
528
- target: { type: "identifier", identifier: 0 },
529
- },
530
- applicable_industries: ["ecommerce", "rental", "education", "travel"],
531
- relevant_risks: ["R-C3-02", "R-C2-01", "R-C2-02"],
532
- creation_notes: [
533
- "The GuardIdentifier for voting_guard must be numeric (U8-U256), otherwise E_GUARD_IDENTIFIER_NOT_NUMBER",
534
- "Weights from submitted data (b_submission=true) carry forgery risk (R-C3-02 critical)",
535
- "Deriving weights from the Arb object via witness is recommended, rather than submitting them directly",
536
- ],
537
- example_use_case: "3-person arbitration panel: chief arbitrator weight 3, regular arbitrators weight 1, majority vote decision.",
538
- verifier_constraint_level: "level2_identity_set",
539
- },
540
- {
541
- id: "tpl_gen_passport_identity",
542
- scene_id: "gen_passport_guard",
543
- name: "Passport identity credential generation validation",
544
- description: "Standalone Guard; after verifying the user's identity, generates a Passport with a credential, used as submission data for subsequent operations.",
545
- recommended_patterns: ["P03", "P14"],
546
- parameters: [
547
- { name: "authorized_address", type: "address", description: "Authorized address (or use Vec<Address> whitelist)", required: true },
548
- ],
549
- example_table: [
550
- { identifier: 0, b_submission: false, value_type: "Address",
551
- value: "${authorized_address}", name: "Authorized address" },
552
- ],
553
- example_root: {
554
- type: "logic_equal",
555
- nodes: [
556
- { type: "context", context: "Signer" },
557
- { type: "identifier", identifier: 0 },
558
- ],
559
- },
560
- applicable_industries: ["ecommerce", "education", "travel", "subscription", "rental"],
561
- relevant_risks: ["R-C1-01", "R-X1-10", "R-X1-13"],
562
- creation_notes: [
563
- "gen_passport is a standalone Guard; it does not bind a Host Object (host_object: Standalone)",
564
- "quote_guard is a rigid requirement: if the Guard queries Repository data with quote_guard set, the quote_guard must be verified (see R-X1-10)",
565
- "The Guard can be depended on by other Guards via rely (requires rep=true)",
566
- "The generated Passport can be used as submission data for subsequent operations",
567
- ],
568
- example_use_case: "After the user passes identity verification, a Passport is generated; this Passport is then submitted as an identity credential in subsequent service purchases.",
569
- verifier_constraint_level: "level1_strict",
570
- },
571
- {
572
- id: "tpl_repository_quote_guard_subscription",
573
- scene_id: "repository_write",
574
- name: "Repository data subscription with payment verification",
575
- description: "Repository quote_guard requires payment proof for data access. When any Guard queries this Repository's data (query 1167), the quote_guard is rigidly verified. Enables data subscription revenue model (e.g., weather data, market oracle data).",
576
- recommended_patterns: ["P03", "P07"],
577
- parameters: [
578
- { name: "repository_address", type: "address", description: "Repository object address", required: true },
579
- { name: "subscription_price", type: "number", description: "Subscription payment amount required for data access", required: true },
580
- { name: "payment_for_object", type: "address", description: "Payment for_object (Repository address)", required: true },
581
- ],
582
- example_table: [
583
- { identifier: 0, b_submission: false, value_type: "Address", value: "${repository_address}", name: "Repository address" },
584
- { identifier: 1, b_submission: false, value_type: "U256", value: "${subscription_price}", name: "Subscription price" },
585
- { identifier: 2, b_submission: true, value_type: "Address", name: "Submitted Payment (for_object verification)" },
586
- { identifier: 3, b_submission: true, value_type: "U256", name: "Submitted Payment amount" },
587
- ],
588
- example_root: {
589
- type: "logic_and",
590
- nodes: [
591
- {
592
- type: "logic_equal",
593
- nodes: [
594
- { type: "query", query: "payment.info.for", object: { identifier: 2 } },
595
- { type: "identifier", identifier: 0 },
596
- ],
597
- },
598
- {
599
- type: "logic_as_u256_ge",
600
- nodes: [
601
- { type: "query", query: "payment.amount", object: { identifier: 2 } },
602
- { type: "identifier", identifier: 1 },
603
- ],
604
- },
605
- ],
606
- },
607
- applicable_industries: ["subscription", "travel", "rental", "education"],
608
- relevant_risks: ["R-X1-10"],
609
- creation_notes: [
610
- "VERIFIER-EVIDENCE DESIGN: user submits valid Payment via Passport (b_submission=true), quote_guard verifies Payment fields",
611
- "quote_guard must be is_depended: immutable=true, relies empty, rep=true (guard.move#L133-135)",
612
- "Repository.owner_receive<T> accepts Payment as subscription revenue (repository.move#L714-717)",
613
- "Rigid verification: any guard querying this Repository's data MUST satisfy the quote_guard",
614
- "Two-phase: passport generation scans + prepares, passport verification re-checks + verifies",
615
- "VERIFIED QUERY NAMES: payment.info.for (id 1107, Address), payment.amount (id 1100, U256)",
616
- ],
617
- example_use_case: "Weather data provider publishes daily temperature data to Repository. Insurance Machine queries weather data; user must pay subscription (Payment) to access data in their insurance claim flow.",
618
- verifier_constraint_level: "level3_scene_combined",
619
- },
620
- {
621
- id: "tpl_buy_guard_order_holder",
622
- scene_id: "service_buy_guard",
623
- name: "Supply chain sub-order purchase verification",
624
- description: "Sub-service buy_guard verifies the user owns a main service order. Enables supply chain milestone unlock: each milestone = one sub-order, sub-service only purchasable by users who bought the main service.",
625
- recommended_patterns: ["P03", "P04"],
626
- parameters: [
627
- { name: "main_service_address", type: "address", description: "Main Service object address", required: true },
628
- { name: "main_order_address", type: "address", description: "Submitted main Order address (b_submission=true)", required: false,
629
- constraint: "If using P16 circular reference, use service name instead of address" },
630
- ],
631
- example_table: [
632
- { identifier: 0, b_submission: false, value_type: "Address", value: "${main_service_address}", name: "Main service address" },
633
- { identifier: 1, b_submission: true, value_type: "Address", name: "Submitted main Order (ownership verification)" },
634
- ],
635
- example_root: {
636
- type: "logic_and",
637
- nodes: [
638
- {
639
- type: "logic_equal",
640
- nodes: [
641
- { type: "query", query: "order.owner", object: { identifier: 1 } },
642
- { type: "context", context: "Signer" },
643
- ],
644
- },
645
- {
646
- type: "logic_equal",
647
- nodes: [
648
- { type: "query", query: "order.service", object: { identifier: 1 } },
649
- { type: "identifier", identifier: 0 },
650
- ],
651
- },
652
- ],
653
- },
654
- applicable_industries: ["travel", "rental", "education", "freelance"],
655
- relevant_risks: ["R-C3-05"],
656
- creation_notes: [
657
- "VERIFIER-EVIDENCE DESIGN: user submits main Order as evidence (b_submission=true), buy_guard verifies ownership + service match",
658
- "No parent_order field needed — relationship verified via buy_guard querying submitted Order fields",
659
- "Each milestone = one sub-order with its own Service + buy_guard",
660
- "Main flow can branch to different sub-services based on Machine node progression",
661
- "VERIFIED QUERY NAMES: order.owner (id 1202, Address), order.service (id 1203, Address)",
662
- ],
663
- example_use_case: "Travel package: main service = tour booking. Sub-services = hotel, guide, transfer — each with buy_guard verifying the user purchased the main tour order.",
664
- verifier_constraint_level: "level2_identity_set",
665
- },
666
- {
667
- id: "tpl_payment_exception_compensation",
668
- scene_id: "machine_forward_guard",
669
- name: "Exception branch compensation Payment",
670
- description: "Machine forward guard for exception handling: verifies a compensation Payment bound to specific order + guard + unique progress step (history count) + node name. Enables user-friendly exception branches (e.g., delivery delay > 30min triggers auto-compensation).",
671
- recommended_patterns: ["P03", "P07", "P09"],
672
- parameters: [
673
- { name: "order_address", type: "address", description: "Order object address (Payment for_object target)", required: true },
674
- { name: "this_guard_address", type: "address", description: "This guard's own address (Payment for_guard target)", required: true },
675
- { name: "compensation_amount", type: "number", description: "Minimum compensation amount", required: true },
676
- { name: "expected_node_name", type: "string", description: "Expected node name (stored in PaymentInfo.remark, compared with progress.current)", required: true },
677
- ],
678
- example_table: [
679
- { identifier: 0, b_submission: false, value_type: "Address", value: "${order_address}", name: "Order address" },
680
- { identifier: 1, b_submission: false, value_type: "Address", value: "${this_guard_address}", name: "This guard address" },
681
- { identifier: 2, b_submission: false, value_type: "U256", value: "${compensation_amount}", name: "Compensation amount" },
682
- { identifier: 3, b_submission: false, value_type: "String", value: "${expected_node_name}", name: "Expected node name (for remark comparison)" },
683
- { identifier: 4, b_submission: true, value_type: "Address", name: "Submitted Payment (compensation proof)" },
684
- ],
685
- example_root: {
686
- type: "logic_and",
687
- nodes: [
688
- {
689
- type: "logic_equal",
690
- nodes: [
691
- { type: "query", query: "payment.info.for", object: { identifier: 4 } },
692
- { type: "identifier", identifier: 0 },
693
- ],
694
- },
695
- {
696
- type: "logic_equal",
697
- nodes: [
698
- { type: "query", query: "payment.info.guard", object: { identifier: 4 } },
699
- { type: "identifier", identifier: 1 },
700
- ],
701
- },
702
- {
703
- type: "logic_as_u256_ge",
704
- nodes: [
705
- { type: "query", query: "payment.amount", object: { identifier: 4 } },
706
- { type: "identifier", identifier: 2 },
707
- ],
708
- },
709
- {
710
- type: "logic_as_u256_equal",
711
- nodes: [
712
- { type: "query", query: "payment.info.index", object: { identifier: 4 } },
713
- { type: "query", query: "progress.history count" },
714
- ],
715
- },
716
- {
717
- type: "logic_string_nocase_equal",
718
- nodes: [
719
- { type: "query", query: "payment.info.remark", object: { identifier: 4 } },
720
- { type: "query", query: "progress.current" },
721
- ],
722
- },
723
- ],
724
- },
725
- applicable_industries: ["rental", "travel", "ecommerce", "freelance"],
726
- relevant_risks: [],
727
- creation_notes: [
728
- "VERIFIED: payment.move#L66-71 (PaymentInfo: for_object, for_guard, remark, index), payment.move#L82-86 (payment_info_with_guard)",
729
- "VERIFIED: treasury.move#L249-264 (withdraw creates Payment via payment::new_singleton + from_object_set)",
730
- "VERIFIED QUERY NAMES: payment.info.for (id 1107, Address), payment.info.guard (id 1109, Address), payment.info.index (id 1111, U64), payment.info.remark (id 1110, String), payment.amount (id 1100, U64; logic_as_u256_ge casts U64→U256 for comparison)",
731
- "VERIFIED INDEX: progress.history count (id 1273, U64) = unique monotonically increasing step index (progress.move L440-441, L475, L482). Even in cycles, each entry has a different count.",
732
- "VERIFIED NODE NAME: progress.current (id 1253, String) = current node name. A node can be entered multiple times in cycles, but the history count is unique each time.",
733
- "DESIGN: payment.info.index stores the step index set by Treasury at creation time; progress.history count provides the current unique step. Comparing them ensures the Payment was created for THIS specific progress step.",
734
- "DESIGN: payment.info.remark stores the node name; progress.current provides the current node name. Comparing them provides semantic verification of which node triggered the compensation.",
735
- "ANTI-REUSE: 4-dimensional binding: for_object (Order) + for_guard (Guard) + index (unique step) + remark (node name). Same Payment cannot be reused in other contexts.",
736
- "Payment is freeze_object (immutable) — cannot be modified after creation",
737
- "VERIFIER-EVIDENCE DESIGN: customer submits Payment, guard verifies binding fields match current context",
738
- "Treasury withdraws compensation with PaymentInfo(for_object=order, for_guard=this, index=history_count_at_creation, remark=node_name)",
739
- ],
740
- example_use_case: "Food delivery: if delivery delayed > 30min at node 'delayed' (history count=5), restaurant Treasury auto-compensates $5 to customer with PaymentInfo(for_object=order, for_guard=this, index=5, remark='delayed'). Customer submits Payment via Passport, guard verifies index matches current history count AND remark matches current node name.",
741
- verifier_constraint_level: "level3_scene_combined",
742
- },
743
- {
744
- id: "tpl_forward_content_subscription_deliver",
745
- scene_id: "machine_forward_guard",
746
- name: "Content subscription delivery verification (Substack-style)",
747
- description: "Forward guard for content subscription delivery flow. Verifies that (1) the order is at the expected pre-delivery node " +
748
- "(e.g. 'Ordered'), AND (2) the Signer holds the author's permission index on the bound Permission object. " +
749
- "Prevents unauthorized parties from publishing content on behalf of the author. " +
750
- "Designed for Substack-style content subscription: Paid → ContentPublished → Completed (success path), " +
751
- "with Cancelled and Disputed branches using separate guards (tpl_forward_content_subscription_cancel, " +
752
- "tpl_forward_content_subscription_refund).",
753
- recommended_patterns: ["P06", "P09"],
754
- parameters: [
755
- {
756
- name: "expected_pre_delivery_node",
757
- type: "string",
758
- description: "Expected current node name BEFORE delivery (e.g. 'Ordered')",
759
- required: true,
760
- default: "Ordered",
761
- constraint: "Must exactly match the name defined in Machine nodes (case-sensitive). This is the node from which the 'Deliver' forward advances.",
762
- },
763
- {
764
- name: "permission_object",
765
- type: "address",
766
- description: "Permission object address bound to the Machine (author role lives here)",
767
- required: true,
768
- constraint: "Must be the same Permission object bound to the Machine. Use name (not address) if Permission is not yet created.",
769
- },
770
- {
771
- name: "author_permission_index",
772
- type: "number",
773
- description: "Permission index reserved for the author role (who can publish content)",
774
- required: true,
775
- default: "1000",
776
- constraint: "Must match the index configured in the Permission object. Substack convention: 1000=author, 1500=arbitrator, reader uses namedOperator='' (no specific operator).",
777
- },
778
- ],
779
- example_table: [
780
- {
781
- identifier: 0,
782
- b_submission: true,
783
- value_type: "Address",
784
- object_type: "Order",
785
- name: "Order object address (submitted by verifier at runtime)",
786
- binding_constraint: "Must be an Order belonging to the bound Service; progress.current must match expected_pre_delivery_node",
787
- },
788
- {
789
- identifier: 1,
790
- b_submission: false,
791
- value_type: "String",
792
- value: "${expected_pre_delivery_node}",
793
- name: "Expected pre-delivery node name (e.g. 'Ordered')",
794
- },
795
- {
796
- identifier: 2,
797
- b_submission: false,
798
- value_type: "Address",
799
- value: "${permission_object}",
800
- name: "Permission object address (bound to Machine, holds author role)",
801
- },
802
- {
803
- identifier: 3,
804
- b_submission: false,
805
- value_type: "U64",
806
- value: "${author_permission_index}",
807
- name: "Author permission index (e.g. 1000)",
808
- },
809
- ],
810
- example_root: {
811
- type: "logic_and",
812
- nodes: [
813
- {
814
- type: "logic_string_nocase_equal",
815
- nodes: [
816
- { type: "query", query: "progress.current", object: { identifier: 0, convert_witness: "OrderProgress" }, parameters: [] },
817
- { type: "identifier", identifier: 1 },
818
- ],
819
- },
820
- {
821
- type: "logic_equal",
822
- nodes: [
823
- { type: "context", context: "Signer" },
824
- {
825
- type: "query",
826
- query: "permission.permitted",
827
- object: { identifier: 2 },
828
- parameters: [{ type: "context", context: "Signer" }, { type: "identifier", identifier: 3 }],
829
- },
830
- ],
831
- },
832
- ],
833
- },
834
- applicable_industries: ["subscription", "content", "newsletter", "media"],
835
- relevant_risks: ["R-C2-01", "R-C2-03", "R-X1-08"],
836
- creation_notes: [
837
- "VERIFIED QUERY NAMES: progress.current (id 1253, String) — current node name; permission.permitted (Permission object query, returns Address of permitted operator for the given index)",
838
- "SUBSTACK DEPLOYMENT: this guard was used in Substack v2 Service. Original v1 Service was published without arbitrations — had to be recreated as v2 with arbitrations bound BEFORE publish (F-S-21).",
839
- "AUTHOR ROLE: permission index 1000 = author (publish + cancel). namedOperator='' for reader role (open — any subscriber). Arbitrator uses index 1500.",
840
- "FORWARD DESIGN: 'Deliver' forward advances from 'Ordered' → 'ContentPublished'. Threshold=1, weight=1, permissionIndex=1000 (author only).",
841
- "GUARD-FIRST-WINS: when 'Ordered' has competing forwards (Deliver|Cancel|Dispute), each with its own guard, the first guard to verify wins. Subscribers cannot double-claim by triggering multiple forwards.",
842
- "IMMUTABILITY: Forward.guard cannot be modified after Machine publish. Verify all 3 guards (deliver/cancel/refund) are correctly bound BEFORE publishing the Machine.",
843
- "CIRCULAR REF: if Permission is not yet created, use its name (not address) in value field — Guard resolves names at evaluation time, not at creation time.",
844
- ],
845
- example_use_case: "Substack newsletter: subscriber pays $5/month. Author publishes content → 'Deliver' forward advances Ordered→ContentPublished. " +
846
- "This guard verifies (1) order is at 'Ordered' node (not already delivered), AND (2) Signer holds permission index 1000 on author's Permission object. " +
847
- "Prevents a malicious party from publishing fake content. Subscriber cannot trigger 'Deliver' (lacks permission).",
848
- verifier_constraint_level: "level2_identity_set",
849
- },
850
- {
851
- id: "tpl_forward_content_subscription_cancel",
852
- scene_id: "machine_forward_guard",
853
- name: "Content subscription cancel verification (Substack-style)",
854
- description: "Forward guard for content subscription cancel flow. Verifies that (1) the order is at the expected pre-cancel node " +
855
- "(e.g. 'Ordered'), AND (2) the Signer is the order owner (subscriber). Allows subscriber to cancel within grace period " +
856
- "for full refund. Designed for Substack-style: Paid → Cancelled (terminal-cancel), with refund via Allocation template.",
857
- recommended_patterns: ["P06", "P09"],
858
- parameters: [
859
- {
860
- name: "expected_pre_cancel_node",
861
- type: "string",
862
- description: "Expected current node name BEFORE cancel (e.g. 'Ordered')",
863
- required: true,
864
- default: "Ordered",
865
- constraint: "Must exactly match the name defined in Machine nodes (case-sensitive).",
866
- },
867
- ],
868
- example_table: [
869
- {
870
- identifier: 0,
871
- b_submission: true,
872
- value_type: "Address",
873
- object_type: "Order",
874
- name: "Order object address (submitted by verifier at runtime)",
875
- },
876
- {
877
- identifier: 1,
878
- b_submission: false,
879
- value_type: "String",
880
- value: "${expected_pre_cancel_node}",
881
- name: "Expected pre-cancel node name (e.g. 'Ordered')",
882
- },
883
- ],
884
- example_root: {
885
- type: "logic_and",
886
- nodes: [
887
- {
888
- type: "logic_string_nocase_equal",
889
- nodes: [
890
- { type: "query", query: "progress.current", object: { identifier: 0, convert_witness: "OrderProgress" }, parameters: [] },
891
- { type: "identifier", identifier: 1 },
892
- ],
893
- },
894
- {
895
- type: "logic_equal",
896
- nodes: [
897
- { type: "context", context: "Signer" },
898
- { type: "query", query: "order.owner", object: { identifier: 0 }, parameters: [] },
899
- ],
900
- },
901
- ],
902
- },
903
- applicable_industries: ["subscription", "content", "newsletter", "media"],
904
- relevant_risks: ["R-C2-01", "R-C2-03"],
905
- creation_notes: [
906
- "VERIFIED QUERY NAMES: progress.current (id 1253, String); order.owner (id 1202, Address) — order holder (subscriber).",
907
- "SUBSCRIBER-ONLY: only the order owner can cancel — prevents third-party griefing. Author cannot cancel on behalf of subscriber.",
908
- "GRACE PERIOD: this guard does NOT enforce a time window. If a grace period is needed (e.g. cancel within 24h of payment), add a third condition: context(Clock) <= order.time + grace_period.",
909
- "REFUND ALLOCATION: pair this guard with an Allocation template that refunds 100% to the subscriber (order.owner). Trigger node = 'Cancelled'.",
910
- "GUARD-FIRST-WINS: when 'Ordered' has competing forwards (Deliver|Cancel|Dispute), each with its own guard, the first guard to verify wins.",
911
- ],
912
- example_use_case: "Substack newsletter: subscriber pays $5, then changes mind before content is published. 'Cancel' forward advances Ordered→Cancelled. " +
913
- "This guard verifies (1) order is at 'Ordered' (not yet delivered), AND (2) Signer is the order owner. " +
914
- "Author cannot cancel on behalf of subscriber. Refund triggers automatically via Allocation on 'Cancelled' node.",
915
- verifier_constraint_level: "level2_identity_set",
916
- },
917
- {
918
- id: "tpl_forward_content_subscription_refund",
919
- scene_id: "machine_forward_guard",
920
- name: "Content subscription refund verification (Substack-style, arbitration-triggered)",
921
- description: "Forward guard for content subscription dispute/refund flow. Verifies that (1) the order is at the expected pre-dispute node " +
922
- "(e.g. 'Disputed'), AND (2) the Signer holds the arbitrator's permission index on the bound Permission object. " +
923
- "Only the arbitrator can advance Disputed→Refunded, ensuring dispute resolution is impartial. " +
924
- "Designed for Substack-style: Paid → Disputed → Refunded (terminal-dispute).",
925
- recommended_patterns: ["P06", "P09"],
926
- parameters: [
927
- {
928
- name: "expected_pre_refund_node",
929
- type: "string",
930
- description: "Expected current node name BEFORE refund (e.g. 'Disputed')",
931
- required: true,
932
- default: "Disputed",
933
- constraint: "Must exactly match the name defined in Machine nodes (case-sensitive).",
934
- },
935
- {
936
- name: "permission_object",
937
- type: "address",
938
- description: "Permission object address bound to the Machine (arbitrator role lives here)",
939
- required: true,
940
- constraint: "Must be the same Permission object bound to the Machine. Use name (not address) if Permission is not yet created.",
941
- },
942
- {
943
- name: "arbitrator_permission_index",
944
- type: "number",
945
- description: "Permission index reserved for the arbitrator role (who can resolve disputes)",
946
- required: true,
947
- default: "1500",
948
- constraint: "Must match the index configured in the Permission object. Substack convention: 1000=author, 1500=arbitrator.",
949
- },
950
- ],
951
- example_table: [
952
- {
953
- identifier: 0,
954
- b_submission: true,
955
- value_type: "Address",
956
- object_type: "Order",
957
- name: "Order object address (submitted by verifier at runtime)",
958
- },
959
- {
960
- identifier: 1,
961
- b_submission: false,
962
- value_type: "String",
963
- value: "${expected_pre_refund_node}",
964
- name: "Expected pre-refund node name (e.g. 'Disputed')",
965
- },
966
- {
967
- identifier: 2,
968
- b_submission: false,
969
- value_type: "Address",
970
- value: "${permission_object}",
971
- name: "Permission object address (bound to Machine, holds arbitrator role)",
972
- },
973
- {
974
- identifier: 3,
975
- b_submission: false,
976
- value_type: "U64",
977
- value: "${arbitrator_permission_index}",
978
- name: "Arbitrator permission index (e.g. 1500)",
979
- },
980
- ],
981
- example_root: {
982
- type: "logic_and",
983
- nodes: [
984
- {
985
- type: "logic_string_nocase_equal",
986
- nodes: [
987
- { type: "query", query: "progress.current", object: { identifier: 0, convert_witness: "OrderProgress" }, parameters: [] },
988
- { type: "identifier", identifier: 1 },
989
- ],
990
- },
991
- {
992
- type: "logic_equal",
993
- nodes: [
994
- { type: "context", context: "Signer" },
995
- {
996
- type: "query",
997
- query: "permission.permitted",
998
- object: { identifier: 2 },
999
- parameters: [{ type: "context", context: "Signer" }, { type: "identifier", identifier: 3 }],
1000
- },
1001
- ],
1002
- },
1003
- ],
1004
- },
1005
- applicable_industries: ["subscription", "content", "newsletter", "media"],
1006
- relevant_risks: ["R-C2-01", "R-C2-03", "R-X1-08"],
1007
- creation_notes: [
1008
- "VERIFIED QUERY NAMES: progress.current (id 1253, String); permission.permitted (Permission object query, returns Address of permitted operator for the given index).",
1009
- "ARBITRATOR-ONLY: only the arbitrator (permission index 1500) can advance Disputed→Refunded. Neither author nor subscriber can self-resolve.",
1010
- "ARBITRATIONS BINDING: Service MUST have arbitrations bound BEFORE publish (F-S-21 — post-publish immutable). ConfirmGate C-S-19 + QS11 will warn if publish is attempted without arbitrations.",
1011
- "DISPUTE ENTRY: 'Dispute' forward (Ordered→Disputed) is triggered by subscriber (order.owner). After Disputed, only arbitrator can resolve.",
1012
- "REFUND ALLOCATION: pair this guard with an Allocation template that refunds 100% to the subscriber (order.owner). Trigger node = 'Refunded'.",
1013
- "GUARD-FIRST-WINS: when 'Disputed' has competing forwards (Resolve-Refund|Resolve-Reject), each with its own guard. First guard to verify wins.",
1014
- ],
1015
- example_use_case: "Substack newsletter: subscriber disputes content quality. Subscriber triggers 'Dispute' forward (Ordered→Disputed). " +
1016
- "Arbitrator reviews evidence and triggers 'Resolve-Refund' forward (Disputed→Refunded). " +
1017
- "This guard verifies (1) order is at 'Disputed' (dispute properly opened), AND (2) Signer holds arbitrator permission index 1500. " +
1018
- "Author cannot self-resolve. Subscriber cannot self-refund.",
1019
- verifier_constraint_level: "level2_identity_set",
1020
- },
1021
- ];
1022
- export function getTemplatesByScene(sceneId) {
1023
- return GUARD_TEMPLATES.filter((t) => t.scene_id === sceneId);
1024
- }
1025
- export function getTemplateById(templateId) {
1026
- return GUARD_TEMPLATES.find((t) => t.id === templateId);
1027
- }
1028
- export function getTemplatesByIndustry(industry) {
1029
- return GUARD_TEMPLATES.filter((t) => t.applicable_industries.includes(industry));
1030
- }
1031
- export function getTemplatesByPattern(patternId) {
1032
- return GUARD_TEMPLATES.filter((t) => t.recommended_patterns.includes(patternId));
1033
- }
1034
- export function listGuardTemplates() {
1035
- return GUARD_TEMPLATES;
1036
- }
1037
- export function suggestTemplateForScene(sceneId) {
1038
- return GUARD_TEMPLATES.find((t) => t.scene_id === sceneId);
1039
- }
1040
- export function getTemplateParameters(templateId) {
1041
- const template = getTemplateById(templateId);
1042
- return template?.parameters ?? [];
1043
- }
1044
- export function validateTemplateParams(templateId, params) {
1045
- const template = getTemplateById(templateId);
1046
- if (!template) {
1047
- return { valid: false, missing: ["template_not_found"] };
1048
- }
1049
- const missing = template.parameters
1050
- .filter((p) => p.required && !(p.name in params))
1051
- .map((p) => p.name);
1052
- return { valid: missing.length === 0, missing };
1053
- }
1054
- function deepSubstitute(obj, params) {
1055
- if (typeof obj === "string") {
1056
- const full = obj.match(/^\$\{(\w+)\}$/);
1057
- if (full && full[1] in params) {
1058
- return params[full[1]];
1059
- }
1060
- return obj.replace(/\$\{(\w+)\}/g, (_, key) => key in params ? String(params[key]) : `\${${key}}`);
1061
- }
1062
- if (Array.isArray(obj)) {
1063
- return obj.map((item) => deepSubstitute(item, params));
1064
- }
1065
- if (obj && typeof obj === "object") {
1066
- const result = {};
1067
- for (const [k, v] of Object.entries(obj)) {
1068
- result[k] = deepSubstitute(v, params);
1069
- }
1070
- return result;
1071
- }
1072
- return obj;
1073
- }
1074
- export function fillGuardTemplate(templateId, params) {
1075
- const template = getTemplateById(templateId);
1076
- if (!template) {
1077
- return { ok: false, error: `Template not found: ${templateId}` };
1078
- }
1079
- const { valid, missing } = validateTemplateParams(templateId, params);
1080
- if (!valid) {
1081
- return {
1082
- ok: false,
1083
- error: `Missing required parameters: ${missing.join(", ")}`,
1084
- missing,
1085
- };
1086
- }
1087
- const filled = { ...params };
1088
- for (const p of template.parameters) {
1089
- if (!(p.name in filled) && p.default !== undefined) {
1090
- filled[p.name] = p.default;
1091
- }
1092
- }
1093
- const table = deepSubstitute(template.example_table, filled);
1094
- const root = deepSubstitute(template.example_root, filled);
1095
- const leftover = JSON.stringify({ table, root }).match(/\$\{(\w+)\}/);
1096
- if (leftover) {
1097
- return {
1098
- ok: false,
1099
- error: `Unresolved placeholder \${${leftover[1]}} — not declared in template parameters`,
1100
- };
1101
- }
1102
- return { ok: true, table, root };
1103
- }
1104
- export const GUARD_TEMPLATES_VERSION = "1.0.0";
1105
- export const GUARD_TEMPLATES_COUNT = GUARD_TEMPLATES.length;
1
+ export const GUARD_TEMPLATES=[{'id':'tpl_buy_guard_whitelist','scene_id':'service_buy_guard','name':'Whitelist\x20purchase\x20validation','description':'Only\x20addresses\x20in\x20the\x20whitelist\x20can\x20purchase\x20the\x20service.\x20Suitable\x20for\x20limited-time\x20sales,\x20VIP\x20exclusives,\x20internal\x20testing\x20eligibility,\x20etc.','recommended_patterns':['P04','P03'],'parameters':[{'name':'whitelist','type':'vec_address','description':'List\x20of\x20authorized\x20addresses','required':!![],'constraint':'Each\x20address\x20must\x20be\x20valid\x20and\x20unique'},{'name':'service_name','type':'string','description':'Service\x20object\x20name\x20(used\x20for\x20circular\x20references)','required':![],'constraint':'If\x20P16\x20circular\x20reference\x20is\x20used,\x20a\x20name\x20must\x20be\x20provided\x20rather\x20than\x20an\x20address'}],'example_table':[{'identifier':0x0,'b_submission':![],'value_type':'Vec<Address>','value':'${whitelist}','name':'Authorized\x20purchase\x20whitelist'}],'example_root':{'type':'vec_contains_address','vec':{'type':'identifier','identifier':0x0},'target':{'type':'context','context':'Signer'}},'applicable_industries':['rental','ecommerce','education','travel','subscription'],'relevant_risks':['R-C1-01','R-C3-01','R-C4-01'],'creation_notes':['Updating\x20the\x20whitelist\x20requires\x20rebuilding\x20the\x20Guard\x20(buy_guard\x20is\x20iterable)','If\x20the\x20Service\x20is\x20already\x20published,\x20the\x20table\x20can\x20use\x20the\x20address\x20directly;\x20otherwise\x20use\x20the\x20name\x20(P16\x20circular\x20reference)'],'example_use_case':'Internal\x20testing\x20phase\x20for\x20camera\x20equipment\x20rental,\x20allowing\x20only\x20the\x20first\x2050\x20seed\x20users\x20to\x20place\x20rental\x20orders.','verifier_constraint_level':'level2_identity_set'},{'id':'tpl_allocator_threshold','scene_id':'service_order_allocators_guard','name':'Allocation\x20amount\x20threshold\x20validation','description':'Selects\x20different\x20allocation\x20strategies\x20based\x20on\x20the\x20order\x20amount.\x20When\x20the\x20amount\x20exceeds\x20the\x20threshold,\x20advanced\x20allocation\x20is\x20used;\x20otherwise,\x20default\x20allocation\x20applies.','recommended_patterns':['P02','P10'],'parameters':[{'name':'threshold','type':'number','description':'Allocation\x20threshold\x20(unit:\x20smallest\x20precision)','required':!![],'constraint':'Must\x20be\x20>\x200;\x20a\x20reasonable\x20range\x20is\x20recommended\x20to\x20avoid\x20boundary\x20gaming'},{'name':'service_name','type':'string','description':'Service\x20object\x20name','required':!![]}],'example_table':[{'identifier':0x0,'b_submission':![],'value_type':'Address','value':'${service_name}','name':'Service\x20object'},{'identifier':0x1,'b_submission':![],'value_type':'U64','value':'${threshold}','name':'Allocation\x20threshold'}],'example_root':{'type':'logic_as_u256_greater','left':{'type':'query','query':'order.amount','object':{'identifier':0x0},'parameters':[]},'right':{'type':'identifier','identifier':0x1}},'applicable_industries':['ecommerce','rental','education','travel'],'relevant_risks':['R-X1-01','R-X1-05','R-X1-08'],'creation_notes':['order_allocators\x20cannot\x20be\x20modified\x20after\x20binding\x20(immutable\x20after\x20publish)','First-match-wins\x20mechanism:\x20multiple\x20allocators\x20are\x20matched\x20in\x20order;\x20the\x20first\x20one\x20that\x20passes\x20executes','Threshold\x20boundary\x20must\x20be\x20tested:\x20behavior\x20when\x20exactly\x20equal\x20to\x20the\x20threshold\x20(>\x20vs\x20>=)'],'example_use_case':'E-commerce\x20platform:\x20order\x20amount\x20>\x201000\x20WOW\x20triggers\x203-way\x20allocation\x20(platform\x20+\x20merchant\x20+\x20logistics);\x20otherwise\x202-way\x20allocation\x20(platform\x20+\x20merchant).','verifier_constraint_level':'level3_scene_combined'},{'id':'tpl_allocator_treasury_personal','scene_id':'service_order_allocators_guard','name':'Treasury\x20+\x20personal\x20address\x20allocation\x20(Entity\x20sharing)','description':'2\x20allocators\x20representing\x202\x20merchant\x20collection\x20approaches:\x20(1)\x20named\x20Treasury\x20address\x20for\x20public\x20fund\x20aggregation,\x20(2)\x20fixed\x20personal\x20address.\x20'+'Uses\x20sharing.who=Entity\x20so\x20funds\x20always\x20flow\x20to\x20the\x20legitimate\x20recipient\x20regardless\x20of\x20caller\x20—\x20no\x20Signer\x20binding\x20needed\x20in\x20Guard.\x20'+'Guards\x20verify\x20the\x20order\x20is\x20at\x20the\x20Complete\x20node\x20+\x20belongs\x20to\x20the\x20service\x20(project\x20binding).','recommended_patterns':['P02','P10','P16'],'parameters':[{'name':'service_name','type':'string','description':'Service\x20object\x20name\x20(circular\x20ref\x20via\x20P16\x20—\x20resolved\x20after\x20Service\x20publish)','required':!![],'constraint':'Must\x20be\x20a\x20name,\x20not\x20an\x20address\x20(the\x20Service\x20is\x20not\x20yet\x20published\x20when\x20the\x20Guard\x20is\x20created)'},{'name':'complete_node_name','type':'string','description':'Expected\x20node\x20name\x20that\x20triggers\x20allocation\x20(e.g.\x20\x27Complete\x27)','required':!![],'default':'Complete','constraint':'Must\x20exactly\x20match\x20the\x20Machine\x20node\x20name\x20(case-sensitive)'},{'name':'treasury_name','type':'string','description':'Named\x20Treasury\x20object\x20(created\x20with\x20the\x20Service\x27s\x20permission)','required':!![],'constraint':'Treasury\x20must\x20be\x20created\x20before\x20the\x20Service;\x20use\x20the\x20SAME\x20permission\x20as\x20the\x20Service\x20for\x20consistency'},{'name':'personal_address','type':'address','description':'Fixed\x20personal\x20collection\x20address\x20(e.g.\x20the\x20permission\x20creator\x27s\x20address)','required':!![]}],'example_table':[{'identifier':0x0,'b_submission':!![],'value_type':'Address','object_type':'Order','name':'order_id\x20(Order\x20object\x20submitted\x20at\x20runtime)'},{'identifier':0x1,'b_submission':![],'value_type':'String','value':'${complete_node_name}','name':'Expected\x20Complete\x20node\x20name\x20(case-sensitive)'},{'identifier':0x2,'b_submission':![],'value_type':'Address','value':'${service_name}','name':'Service\x20object\x20(project\x20binding,\x20circular\x20ref\x20via\x20name)'}],'example_root':{'type':'logic_and','nodes':[{'type':'logic_equal','nodes':[{'type':'query','query':'progress.current','object':{'identifier':0x0,'convert_witness':'OrderProgress'},'parameters':[]},{'type':'identifier','identifier':0x1}]},{'type':'logic_equal','nodes':[{'type':'query','query':'order.service','object':{'identifier':0x0},'parameters':[]},{'type':'identifier','identifier':0x2}]}]},'applicable_industries':['insurance','ecommerce','travel','rental','subscription'],'relevant_risks':['R-C3-05','R-C3-06','R-X1-05','R-X1-01'],'creation_notes':['2\x20Guard\x20objects\x20with\x20IDENTICAL\x20root/table\x20but\x20DIFFERENT\x20descriptions\x20(allocators\x20require\x20unique\x20guard\x20addresses\x20—\x20no\x20two\x20allocators\x20may\x20reference\x20the\x20same\x20Guard).','sharing.who=Entity\x20(Treasury/personal)\x20—\x20no\x20Signer\x20binding\x20needed\x20in\x20the\x20Guard\x20(R-C3-06\x20safe).','First-match-wins:\x20only\x20the\x20first\x20allocator\x20(Treasury)\x20executes;\x20the\x20personal\x20allocator\x20is\x20an\x20alternative\x20(swap\x20the\x20allocators\x20order\x20to\x20activate\x20personal\x20collection).','Treasury\x20should\x20be\x20created\x20with\x20the\x20SAME\x20permission\x20as\x20the\x20Service\x20(permission\x20consistency\x20—\x20different\x20permissions\x20=\x20minor\x20risk).','order.service\x20binding\x20(query\x201563)\x20suppresses\x20R-C3-05\x20(cross-project\x20bypass\x20prevents\x20premature\x20allocation\x20on\x20foreign\x20orders).','order_allocators\x20is\x20immutable\x20after\x20Service\x20publish\x20—\x20verify\x20the\x20Guard\x20logic\x20and\x20sharing\x20config\x20before\x20publishing.'],'example_use_case':'Insurance\x20service:\x20after\x20a\x20claim\x20reaches\x20the\x20Complete\x20node,\x20order\x20funds\x20are\x20allocated\x20to\x20the\x20insurance\x20Treasury\x20'+'(approach\x201,\x20for\x20operational\x20fund\x20aggregation)\x20or\x20to\x20the\x20provider\x27s\x20personal\x20address\x20(approach\x202,\x20for\x20direct\x20income).','verifier_constraint_level':'level3_scene_combined'},{'id':'tpl_allocator_identity_set_order_holder','scene_id':'service_order_allocators_guard','name':'Order-holder\x20identity-set\x20allocation\x20(Level\x202)','description':'Level\x202\x20identity-set\x20binding:\x20Signer\x20is\x20order.owner\x20(1562,\x20Address)\x20OR\x20order.agent\x20(1567,\x20Bool\x20with\x20[Signer]\x20param).\x20'+'Demonstrates\x20the\x20mixed\x20return-type\x20construction\x20pattern\x20—\x20Address-returning\x20queries\x20are\x20wrapped\x20in\x20logic_equal,\x20'+'while\x20Bool-returning\x20queries\x20(suffix\x20\x27has\x27)\x20are\x20used\x20directly\x20as\x20logic_or\x20children.\x20'+'Combined\x20with\x20order.service\x20binding\x20(R-C3-05)\x20for\x20cross-service\x20theft\x20prevention.\x20'+'Use\x20when\x20either\x20the\x20order\x20owner\x20or\x20an\x20authorized\x20agent\x20should\x20be\x20able\x20to\x20trigger\x20allocation\x20(e.g.\x20refund\x20to\x20caller).','recommended_patterns':['P02','P10','P16'],'parameters':[{'name':'service_name','type':'string','description':'Service\x20object\x20name\x20(circular\x20ref\x20via\x20P16)','required':!![],'constraint':'Must\x20be\x20a\x20name,\x20not\x20an\x20address\x20(the\x20Service\x20is\x20not\x20yet\x20published\x20when\x20the\x20Guard\x20is\x20created)'}],'example_table':[{'identifier':0x0,'b_submission':!![],'value_type':'Address','object_type':'Order','name':'order_id\x20(Order\x20object\x20submitted\x20at\x20runtime)'},{'identifier':0x1,'b_submission':![],'value_type':'Address','value':'${service_name}','name':'Service\x20object\x20(project\x20binding,\x20circular\x20ref\x20via\x20name)'}],'example_root':{'type':'logic_and','nodes':[{'type':'logic_or','nodes':[{'type':'logic_equal','nodes':[{'type':'query','query':'order.owner','object':{'identifier':0x0},'parameters':[]},{'type':'context','context':'Signer'}]},{'type':'query','query':'order.agent\x20has','object':{'identifier':0x0},'parameters':[{'type':'context','context':'Signer'}]}]},{'type':'logic_equal','nodes':[{'type':'query','query':'order.service','object':{'identifier':0x0},'parameters':[]},{'type':'identifier','identifier':0x1}]}]},'applicable_industries':['ecommerce','rental','travel','subscription'],'relevant_risks':['R-C3-01','R-C3-05','R-C3-06','R-C4-04'],'creation_notes':['MIXED\x20RETURN-TYPE\x20CONSTRUCTION\x20(key\x20Level\x202\x20pattern):\x20query\x201562\x20(order.owner)\x20returns\x20Address\x20→\x20wrap\x20in\x20logic_equal\x20with\x20context(Signer);\x20query\x201567\x20(order.agent\x20has)\x20returns\x20Bool\x20→\x20use\x20directly\x20as\x20logic_or\x20child\x20with\x20parameters:\x20[context(Signer)].','logic_or\x20wrapping\x20of\x20the\x20Signer\x20check\x20suppresses\x20R-C4-04\x20(Level\x201\x20strict\x20binding\x20convenience\x20warning)\x20—\x20this\x20is\x20the\x20recommended\x20Level\x202\x20alternative.','Use\x20this\x20pattern\x20when\x20sharing.who=Signer\x20(funds\x20flow\x20to\x20caller)\x20AND\x20either\x20the\x20owner\x20or\x20an\x20agent\x20should\x20be\x20authorized\x20to\x20trigger\x20allocation.','order.service\x20binding\x20(query\x201563)\x20suppresses\x20R-C3-05\x20(cross-project\x20bypass).','If\x20agents\x20are\x20not\x20needed,\x20use\x20the\x20simpler\x20Level\x202\x20dynamic\x20pattern:\x20logic_equal[query(1562),\x20context(Signer)]\x20without\x20logic_or.'],'example_use_case':'Refund\x20allocation:\x20when\x20an\x20order\x20is\x20cancelled,\x20either\x20the\x20order\x20owner\x20or\x20an\x20authorized\x20agent\x20can\x20trigger\x20the\x20refund.\x20'+'The\x20Guard\x20verifies\x20Signer\x20is\x20order.owner\x20OR\x20order.agent,\x20and\x20that\x20the\x20order\x20belongs\x20to\x20this\x20service.','verifier_constraint_level':'level2_identity_set'},{'id':'tpl_allocator_identity_set_service_provider_dynamic','scene_id':'service_order_allocators_guard','name':'Service-provider\x20identity-set\x20allocation\x20with\x20dynamic\x20permission\x20(Level\x202)','description':'Level\x202\x20identity-set\x20binding\x20with\x20DYNAMIC\x20permission\x20address:\x20Signer\x20is\x20permission.owner\x20(1002,\x20Address)\x20OR\x20'+'has\x20admin\x20(1004,\x20Bool\x20with\x20[Signer]\x20param).\x20The\x20permission\x20address\x20is\x20submitted\x20by\x20the\x20caller\x20and\x20verified\x20'+'against\x20service.permission\x20(1488)\x20—\x20this\x20survives\x20permission\x20rotation\x20without\x20rebuilding\x20the\x20Guard.\x20'+'Use\x20when\x20the\x20Service\x20may\x20rotate\x20its\x20permission\x20(like\x20a\x20company\x20changing\x20its\x20board)\x20and\x20a\x20static\x20permission\x20'+'address\x20would\x20break\x20the\x20Guard.','recommended_patterns':['P02','P10','P16'],'parameters':[{'name':'service_name','type':'string','description':'Service\x20object\x20name\x20(circular\x20ref\x20via\x20P16)','required':!![],'constraint':'Must\x20be\x20a\x20name,\x20not\x20an\x20address\x20(the\x20Service\x20is\x20not\x20yet\x20published\x20when\x20the\x20Guard\x20is\x20created)'}],'example_table':[{'identifier':0x0,'b_submission':!![],'value_type':'Address','object_type':'Order','name':'order_id\x20(Order\x20object\x20submitted\x20at\x20runtime)'},{'identifier':0x1,'b_submission':![],'value_type':'Address','value':'${service_name}','name':'Service\x20object\x20(project\x20binding,\x20circular\x20ref\x20via\x20name)'},{'identifier':0x2,'b_submission':!![],'value_type':'Address','object_type':'Permission','name':'permission_id\x20(Permission\x20object\x20submitted\x20by\x20caller\x20—\x20must\x20equal\x20service.permission)'}],'example_root':{'type':'logic_and','nodes':[{'type':'logic_equal','nodes':[{'type':'query','query':'order.service','object':{'identifier':0x0},'parameters':[]},{'type':'identifier','identifier':0x1}]},{'type':'logic_equal','nodes':[{'type':'query','query':'service.permission','object':{'identifier':0x1},'parameters':[]},{'type':'identifier','identifier':0x2}]},{'type':'logic_or','nodes':[{'type':'logic_equal','nodes':[{'type':'query','query':'permission.owner','object':{'identifier':0x2},'parameters':[]},{'type':'context','context':'Signer'}]},{'type':'query','query':'permission.admin\x20has','object':{'identifier':0x2},'parameters':[{'type':'context','context':'Signer'}]}]}]},'applicable_industries':['ecommerce','rental','insurance','travel','subscription'],'relevant_risks':['R-C3-01','R-C3-05','R-C3-06','R-C4-04'],'creation_notes':['DYNAMIC\x20PERMISSION\x20VERIFICATION\x20(key\x20pattern):\x20caller\x20submits\x20a\x20Permission\x20address\x20(identifier\x202);\x20Guard\x20verifies\x20query(1488:\x20service.permission)\x20==\x20submitted\x20permission,\x20then\x20checks\x201002/1004\x20against\x20the\x20submitted\x20permission.\x20This\x20survives\x20permission\x20rotation\x20—\x20if\x20the\x20Service\x20changes\x20its\x20permission,\x20the\x20Guard\x20still\x20works\x20without\x20rebuilding.','MIXED\x20RETURN-TYPE\x20CONSTRUCTION:\x20query\x201002\x20(permission.owner)\x20returns\x20Address\x20→\x20wrap\x20in\x20logic_equal;\x20query\x201004\x20(permission.admin\x20has)\x20returns\x20Bool\x20→\x20use\x20directly\x20as\x20logic_or\x20child\x20with\x20parameters:\x20[context(Signer)].','logic_or\x20wrapping\x20of\x20the\x20Signer\x20check\x20suppresses\x20R-C4-04\x20(Level\x201\x20strict\x20binding\x20convenience\x20warning).','THREE\x20conditions\x20in\x20logic_and:\x20(1)\x20order.service\x20binding\x20(R-C3-05),\x20(2)\x20dynamic\x20permission\x20verification,\x20(3)\x20identity\x20set\x20(owner\x20OR\x20admin).','Static\x20permission\x20alternative\x20(simpler\x20but\x20breaks\x20on\x20rotation):\x20use\x20a\x20table\x20constant\x20for\x20the\x20permission\x20address\x20instead\x20of\x20b_submission=true\x20+\x201488\x20verification.','Repository-based\x20address\x20set\x20(most\x20flexible,\x20most\x20complex):\x20store\x20the\x20permission\x20address\x20set\x20in\x20a\x20Repository\x20and\x20query\x20dynamically\x20—\x20only\x20for\x20extreme\x20flexibility\x20needs.'],'example_use_case':'Merchant\x20allocation:\x20the\x20Service\x20may\x20rotate\x20its\x20permission\x20(like\x20a\x20company\x20changing\x20its\x20board).\x20'+'The\x20caller\x20submits\x20the\x20current\x20permission\x20address;\x20the\x20Guard\x20verifies\x20it\x20matches\x20service.permission\x20(1488),\x20'+'then\x20checks\x20that\x20Signer\x20is\x20the\x20permission\x20owner\x20or\x20has\x20admin\x20rights.','verifier_constraint_level':'level2_identity_set'},{'id':'tpl_forward_node_check','scene_id':'machine_forward_guard','name':'Workflow\x20node\x20state\x20validation','description':'Verifies\x20that\x20the\x20order\x20is\x20currently\x20at\x20the\x20correct\x20Machine\x20node\x20before\x20advancing\x20to\x20the\x20next\x20step.\x20Prevents\x20skipping\x20nodes\x20or\x20reverse\x20operations.','recommended_patterns':['P06','P09'],'parameters':[{'name':'expected_node','type':'string','description':'Expected\x20current\x20node\x20name','required':!![],'constraint':'Must\x20exactly\x20match\x20the\x20name\x20defined\x20in\x20Machine\x20nodes\x20(case-sensitive)'}],'example_table':[{'identifier':0x0,'b_submission':!![],'value_type':'Address','name':'Order\x20object\x20address','object_type':'Order'},{'identifier':0x1,'b_submission':![],'value_type':'String','value':'${expected_node}','name':'Expected\x20current\x20node\x20name'}],'example_root':{'type':'logic_equal','left':{'type':'query','query':'progress.current','object':{'identifier':0x0,'convert_witness':'OrderProgress'},'parameters':[]},'right':{'type':'identifier','identifier':0x1}},'applicable_industries':['rental','ecommerce','education','travel','subscription'],'relevant_risks':['R-C2-01','R-C2-03','R-X1-08'],'creation_notes':['Forward.guard\x20cannot\x20be\x20modified\x20after\x20binding\x20(immutable\x20after\x20Machine\x20publish)','witness\x20100\x20(Order→Progress)\x20is\x20a\x20single\x20hop;\x20no\x20risk\x20of\x20chained-derivation\x20breakage','Node\x20names\x20are\x20case-sensitive;\x20query\x20returns\x20a\x20String\x20type'],'example_use_case':'Camera\x20equipment\x20rental\x20flow:\x20the\x20user\x20must\x20be\x20at\x20the\x20\x27pending\x20return\x27\x20node\x20to\x20perform\x20the\x20return\x20operation.','verifier_constraint_level':'level3_scene_combined'},{'id':'tpl_forward_privacy_delivery_proof','scene_id':'machine_forward_guard','name':'Privacy-delivery\x20Proof\x20verification\x20(strict\x20mode,\x20Messenger\x20→\x20on-chain\x20Proof)','description':'Strict-mode\x20guard\x20for\x20\x27privacy\x20information\x20delivered\x20via\x20Messenger\x20but\x20not\x20suitable\x20for\x20on-chain\x20publication\x27\x20'+'(e.g.\x20shipping\x20details,\x20return\x20addresses,\x20private\x20credentials).\x20The\x20verifier\x20submits\x20BOTH\x20a\x20Proof\x20object\x20address\x20'+'(generated\x20by\x20messenger.submitChainProof)\x20AND\x20the\x20Order\x20object\x20address.\x20Three\x20conditions\x20verify:\x20'+'(1)\x20Signer\x20==\x20proof.signer\x20(submitter\x20accountability\x20—\x20\x27whoever\x20benefits\x20bears\x20the\x20burden\x20of\x20proof\x27),\x20'+'(2)\x20proof.time\x20>\x20order.time\x20(proof\x20created\x20after\x20the\x20order\x20—\x20freshness,\x20prevents\x20stale-proof\x20replay),\x20'+'(3)\x20order.service\x20==\x20service\x20(project\x20binding,\x20suppresses\x20R-C3-05\x20cross-project\x20bypass).\x20'+'No\x20content\x20verification\x20—\x20only\x20submission\x20responsibility.\x20The\x20counterparty\x20can\x20dispute\x20by\x20checking\x20their\x20own\x20'+'Messenger\x20conversation.\x20Broad-mode\x20alternative\x20(verify\x20Merkle\x20Root\x20string\x20length\x20==\x2066\x20via\x20P15)\x20is\x20documented\x20'+'in\x20creation_notes\x20—\x20broad\x20mode\x20trusts\x20the\x20submitter\x27s\x20honesty\x20and\x20is\x20suitable\x20when\x20the\x20Guard\x20is\x20mainly\x20an\x20'+'arbitration\x20basis\x20rather\x20than\x20a\x20fund-flow\x20gate.','recommended_patterns':['P10','P15'],'parameters':[{'name':'service_name','type':'string','description':'Service\x20object\x20name\x20(circular\x20ref\x20via\x20P16\x20—\x20resolved\x20after\x20Service\x20publish)','required':!![],'constraint':'Must\x20be\x20a\x20name,\x20not\x20an\x20address\x20(the\x20Service\x20is\x20not\x20yet\x20published\x20when\x20the\x20Guard\x20is\x20created)'}],'example_table':[{'identifier':0x0,'b_submission':!![],'value_type':'Address','object_type':'Proof','name':'proof_object\x20(Proof\x20address\x20generated\x20by\x20messenger.submitChainProof,\x20submitted\x20by\x20verifier\x20at\x20runtime)','binding_constraint':'Must\x20be\x20a\x20Proof\x20object\x20created\x20AFTER\x20the\x20order;\x20signer\x20must\x20equal\x20the\x20transaction\x20Signer'},{'identifier':0x1,'b_submission':!![],'value_type':'Address','object_type':'Order','name':'order_object\x20(Order\x20address\x20submitted\x20by\x20verifier\x20at\x20runtime)','binding_constraint':'Must\x20belong\x20to\x20the\x20service\x20declared\x20in\x20identifier\x202\x20(order.service\x20==\x20service)'},{'identifier':0x2,'b_submission':![],'value_type':'Address','value':'${service_name}','name':'Service\x20object\x20(project\x20binding,\x20circular\x20ref\x20via\x20name)'}],'example_root':{'type':'logic_and','nodes':[{'type':'logic_equal','nodes':[{'type':'context','context':'Signer'},{'type':'query','query':'proof.signer','object':{'identifier':0x0},'parameters':[]}]},{'type':'logic_as_u256_greater','nodes':[{'type':'query','query':'proof.time','object':{'identifier':0x0},'parameters':[]},{'type':'query','query':'order.time','object':{'identifier':0x1},'parameters':[]}]},{'type':'logic_equal','nodes':[{'type':'query','query':'order.service','object':{'identifier':0x1},'parameters':[]},{'type':'identifier','identifier':0x2}]}]},'applicable_industries':['ecommerce','logistics','service','privacy\x20delivery'],'relevant_risks':['R-C3-01','R-C3-05','R-X1-12'],'creation_notes':['STRICT\x20MODE\x20(this\x20template):\x20verifier\x20submits\x20Proof\x20+\x20Order\x20addresses.\x20Three\x20conditions:\x20Signer==proof.signer\x20(submitter\x20accountability),\x20proof.time>order.time\x20(freshness),\x20order.service==service\x20(project\x20binding).\x20No\x20content\x20verification\x20—\x20only\x20submission\x20responsibility\x20(\x27beneficiary\x20bears\x20burden\x20of\x20proof\x27\x20principle).','BROAD\x20MODE\x20ALTERNATIVE:\x20use\x20P15\x20retained_submission\x20with\x20a\x20String\x20submission\x20(the\x20Merkle\x20Root)\x20and\x20verify\x20calc_string_length\x20==\x2066\x20(0x\x20prefix\x20+\x2064\x20hex\x20chars).\x20Broad\x20mode\x20trusts\x20the\x20submitter\x27s\x20honesty;\x20the\x20counterparty\x20can\x20dispute\x20by\x20checking\x20their\x20own\x20Messenger\x20conversation.\x20Broad\x20mode\x20is\x20suitable\x20when\x20the\x20Guard\x20is\x20mainly\x20an\x20arbitration\x20basis,\x20not\x20a\x20fund-flow\x20gate.','Guard\x20table\x20supports\x20MULTIPLE\x20b_submission=true\x20Address\x20identifiers\x20(no\x20submission\x20count\x20limit)\x20—\x20this\x20template\x20uses\x20two:\x20Proof\x20(identifier\x200)\x20and\x20Order\x20(identifier\x201).','submitChainProof(env,\x20peerAddress,\x20description?)\x20sets\x20Proof.about\x20=\x20peerAddress\x20(the\x20counterparty\x27s\x20address).\x20Pass\x20the\x20order_id\x20as\x20a\x20string\x20in\x20the\x20description\x20parameter\x20to\x20associate\x20the\x20Proof\x20with\x20an\x20order\x20(e.g.\x20description:\x20\x27order:0x123...\x27).','Query\x20IDs\x20(all\x20zero-parameter):\x20proof.signer=1958,\x20proof.time=1960\x20(invariant\x20clock_derived,\x20always\x20>0),\x20order.time=1574,\x20order.service=1563.','Forward.guard\x20is\x20immutable\x20after\x20Machine\x20publish\x20—\x20choose\x20broad\x20vs\x20strict\x20before\x20publishing.','The\x20same\x20strict\x20Guard\x20can\x20be\x20reused\x20across\x20ALL\x20Machine\x20forwards\x20that\x20need\x20merkle-root\x20verification\x20(shipping,\x20lost,\x20returns,\x20etc.)\x20—\x20the\x20verifier\x20just\x20submits\x20the\x20relevant\x20Proof\x20+\x20Order\x20each\x20time.','Condition\x20(1)\x20Signer==proof.signer\x20suppresses\x20R-C3-01\x20(submission\x20not\x20bound\x20to\x20Signer).\x20Condition\x20(3)\x20order.service==service\x20suppresses\x20R-C3-05\x20(cross-project\x20submission\x20bypass).'],'example_use_case':'MyShop\x20e-commerce:\x20after\x20delivering\x20shipping\x20details\x20/\x20return\x20addresses\x20via\x20Messenger\x20(privacy\x20info\x20not\x20suitable\x20for\x20on-chain\x20publication),\x20'+'the\x20provider\x20generates\x20a\x20Proof\x20via\x20submitChainProof\x20and\x20submits\x20it\x20with\x20the\x20Order\x20address\x20to\x20advance\x20the\x20Machine\x20forward.\x20'+'The\x20Guard\x20verifies\x20the\x20submitter\x20is\x20the\x20Proof\x27s\x20signer,\x20the\x20Proof\x20was\x20created\x20after\x20the\x20order,\x20and\x20the\x20order\x20belongs\x20to\x20this\x20service.','verifier_constraint_level':'level3_scene_combined'},{'id':'tpl_submission_signer_binding','scene_id':'progress_submission_guard','name':'Submission\x20data\x20signer\x20binding\x20validation','description':'Verifies\x20that\x20the\x20user\x20submitting\x20the\x20data\x20is\x20a\x20legitimate\x20Progress\x20participant\x20and\x20that\x20the\x20submitted\x20value\x20matches\x20expectations.','recommended_patterns':['P08','P15'],'parameters':[{'name':'expected_value','type':'string','description':'Expected\x20submitted\x20value\x20(e.g.\x20node\x20name,\x20status\x20code)','required':!![]},{'name':'provider_address','type':'address','description':'Service\x20provider\x20address\x20(used\x20for\x20identity\x20verification)','required':!![]}],'example_table':[{'identifier':0x0,'b_submission':!![],'value_type':'String','name':'User-submitted\x20operation\x20type\x20(e.g.\x20\x27return\x27\x20/\x20\x27damage\x27)','binding_constraint':'Must\x20be\x20one\x20of\x20the\x20predefined\x20operation\x20types'},{'identifier':0x1,'b_submission':![],'value_type':'Address','value':'${provider_address}','name':'Service\x20provider\x20address'},{'identifier':0x2,'b_submission':![],'value_type':'String','value':'${expected_value}','name':'Expected\x20submitted\x20value'}],'example_root':{'type':'logic_and','nodes':[{'type':'logic_equal','nodes':[{'type':'identifier','identifier':0x0},{'type':'identifier','identifier':0x2}]},{'type':'logic_equal','nodes':[{'type':'context','context':'Signer'},{'type':'identifier','identifier':0x1}]}]},'applicable_industries':['rental','ecommerce','education','travel'],'relevant_risks':['R-C3-01','R-C3-03','R-X1-12'],'creation_notes':['submission\x20guard\x20cannot\x20be\x20modified\x20after\x20binding','The\x20name\x20of\x20b_submission=true\x20entries\x20must\x20be\x20a\x20complete\x20natural-language\x20description\x20(≥10\x20characters)','Providing\x20a\x20binding_constraint\x20field\x20describing\x20value\x20rules\x20is\x20recommended\x20(R-X1-12)'],'example_use_case':'On\x20equipment\x20return,\x20the\x20user\x20submits\x20the\x20\x27return\x27\x20operation;\x20the\x20Guard\x20verifies\x20that\x20the\x20submitter\x20is\x20the\x20service\x20provider\x20and\x20that\x20the\x20operation\x20type\x20is\x20correct.','verifier_constraint_level':'level1_strict'},{'id':'tpl_reward_one_time_claim','scene_id':'reward_guard','name':'One-time\x20reward\x20claim\x20validation','description':'Verifies\x20that\x20the\x20user\x20is\x20claiming\x20the\x20reward\x20for\x20the\x20first\x20time,\x20preventing\x20duplicate\x20claims.\x20Implemented\x20by\x20querying\x20the\x20historical\x20record\x20count\x20via\x20Repository.','recommended_patterns':['P07','P13'],'parameters':[{'name':'repository_address','type':'address','description':'Repository\x20object\x20address\x20(stores\x20claim\x20records)','required':!![]}],'example_table':[{'identifier':0x0,'b_submission':![],'value_type':'Address','value':'${repository_address}','name':'Reward\x20claim\x20record\x20Repository','object_type':'Repository'},{'identifier':0x1,'b_submission':![],'value_type':'U64','value':'0','name':'First-claim\x20threshold\x20(record_count\x20==\x200)'}],'example_root':{'type':'logic_equal','left':{'type':'query','query':'repository.data','object':{'identifier':0x0},'parameters':[{'type':'context','context':'Signer'}]},'right':{'type':'identifier','identifier':0x1}},'applicable_industries':['ecommerce','education','travel','subscription'],'relevant_risks':['R-C1-03','R-X1-01','R-X1-10'],'creation_notes':['Repository\x20with\x20quote_guard:\x20rigid\x20verification\x20—\x20any\x20guard\x20querying\x20this\x20Repository\x27s\x20data\x20MUST\x20satisfy\x20the\x20quote_guard\x20(see\x20R-X1-10,\x20pattern.repository_quote_guard_subscription)','repository.data\x20query\x20returns\x20U64\x20(record\x20count),\x20compared\x20with\x20identifier[1]\x20(value\x200)','Reward\x20guard\x20is\x20iterable;\x20duplicate-claim\x20protection\x20requires\x20rebuilding\x20the\x20Guard\x20to\x20update\x20the\x20Repository\x20address'],'example_use_case':'New-user\x20first-order\x20reward:\x20query\x20the\x20user\x27s\x20historical\x20order\x20count\x20via\x20Repository;\x20allow\x20claim\x20only\x20when\x20record_count==0.','verifier_constraint_level':'level3_scene_combined'},{'id':'tpl_write_guard_type_check','scene_id':'repository_write_guard','name':'Storage\x20write\x20type\x20validation','description':'Verifies\x20that\x20the\x20data\x20type\x20written\x20to\x20the\x20Repository\x20matches\x20the\x20declaration\x20and\x20that\x20the\x20writer\x27s\x20identity\x20is\x20legitimate.','recommended_patterns':['P08','P11'],'parameters':[{'name':'repository_address','type':'address','description':'Repository\x20object\x20address','required':!![],'constraint':'Must\x20be\x20the\x20address\x20of\x20an\x20already-published\x20Repository'},{'name':'entity_registrar','type':'address','description':'EntityRegistrar\x20address\x20(fixed\x200xaab)','required':![],'default':'0xaab'}],'example_table':[{'identifier':0x0,'b_submission':!![],'value_type':'Address','name':'Writer\x20address\x20(submitted\x20by\x20caller)','binding_constraint':'Must\x20be\x20a\x20valid\x20Entity\x20address'},{'identifier':0x1,'b_submission':!![],'value_type':'String','name':'Write\x20data\x20key\x20name\x20(submitted\x20by\x20caller)','binding_constraint':'Key\x20name\x20format\x20must\x20be\x20\x27category:key\x27'},{'identifier':0x2,'b_submission':![],'value_type':'Address','value':'${entity_registrar}','name':'EntityRegistrar\x20system\x20address','is_system_address':!![]}],'example_root':{'type':'logic_and','nodes':[{'type':'logic_equal','nodes':[{'type':'context','context':'Signer'},{'type':'identifier','identifier':0x0}]},{'type':'logic_not_equal','nodes':[{'type':'identifier','identifier':0x0},{'type':'identifier','identifier':0x2}]}]},'applicable_industries':['ecommerce','education','travel','subscription','rental'],'relevant_risks':['R-C1-02','R-C3-03','R-C3-04'],'creation_notes':['id_from_submission\x20in\x20write_guard\x20must\x20be\x20of\x20Address\x20type','data_from_submission\x20must\x20match\x20the\x20Repository\x20value_type','EntityRegistrar\x20(0xaab)\x20and\x20EntityLinker\x20(0xaaa)\x20are\x20fixed\x20system\x20addresses'],'example_use_case':'E-commerce\x20platform\x20merchant\x20writes\x20product\x20review\x20data;\x20the\x20Guard\x20verifies\x20that\x20the\x20writer\x20is\x20a\x20registered\x20Entity\x20and\x20not\x20a\x20system\x20address.','verifier_constraint_level':'level1_strict'},{'id':'tpl_usage_guard_threshold','scene_id':'arbitration_usage_guard','name':'Dispute\x20initiation\x20threshold\x20validation','description':'Verifies\x20that\x20the\x20dispute\x20initiator\x20meets\x20minimum\x20conditions\x20(e.g.\x20order\x20amount,\x20time\x20window),\x20filtering\x20out\x20meaningless\x20disputes.','recommended_patterns':['P02','P10'],'parameters':[{'name':'min_amount','type':'number','description':'Minimum\x20dispute\x20amount\x20threshold','required':!![],'constraint':'A\x20reasonable\x20threshold\x20is\x20recommended;\x20too\x20high\x20hinders\x20user\x20rights\x20protection,\x20too\x20low\x20produces\x20many\x20invalid\x20disputes'}],'example_table':[{'identifier':0x0,'b_submission':!![],'value_type':'Address','name':'Dispute-related\x20Order\x20object\x20address','object_type':'Order'},{'identifier':0x1,'b_submission':![],'value_type':'U64','value':'${min_amount}','name':'Minimum\x20dispute\x20amount\x20threshold'}],'example_root':{'type':'logic_as_u256_greater_or_equal','left':{'type':'query','query':'order.amount','object':{'identifier':0x0},'parameters':[]},'right':{'type':'identifier','identifier':0x1}},'applicable_industries':['ecommerce','rental','education','travel'],'relevant_risks':['R-X1-01','R-X1-07','R-C3-03'],'creation_notes':['usage_guard\x20is\x20iterable\x20(Arbitration\x20can\x20be\x20updated)','AND\x20conditions\x20should\x20not\x20be\x20too\x20many\x20(R-X1-07);\x20≤3\x20conditions\x20recommended','When\x20Arbitration\x20bPaused=true,\x20blocking\x20takes\x20priority\x20(checked\x20before\x20Guard)'],'example_use_case':'Rental\x20service\x20dispute:\x20only\x20disputes\x20with\x20order\x20amount\x20≥\x2010\x20WOW\x20are\x20accepted,\x20filtering\x20out\x20small-amount\x20conflicts.','verifier_constraint_level':'level3_scene_combined'},{'id':'tpl_voting_guard_numeric_weight','scene_id':'arbitration_voting_guard','name':'Numeric\x20voting\x20weight\x20validation','description':'Assigns\x20numeric\x20voting\x20weights\x20based\x20on\x20arbitrator\x20rank;\x20higher-rank\x20arbitrators\x20have\x20greater\x20weight.','recommended_patterns':['P12'],'parameters':[{'name':'arbiter_weights','type':'vec_address','description':'Arbitrator\x20address\x20to\x20weight\x20mapping\x20(address:weight\x20pairs)','required':!![],'constraint':'Weights\x20must\x20be\x20numeric\x20types\x20U8-U256'}],'example_table':[{'identifier':0x0,'b_submission':!![],'value_type':'Address','name':'Arbitrator\x20address\x20(submitted\x20by\x20caller)','object_type':'Arb'},{'identifier':0x1,'b_submission':![],'value_type':'Vec<Address>','value':'${arbiter_weights}','name':'Authorized\x20arbitrator\x20address\x20list'}],'example_root':{'type':'vec_contains_address','vec':{'type':'identifier','identifier':0x1},'target':{'type':'identifier','identifier':0x0}},'applicable_industries':['ecommerce','rental','education','travel'],'relevant_risks':['R-C3-02','R-C2-01','R-C2-02'],'creation_notes':['The\x20GuardIdentifier\x20for\x20voting_guard\x20must\x20be\x20numeric\x20(U8-U256),\x20otherwise\x20E_GUARD_IDENTIFIER_NOT_NUMBER','Weights\x20from\x20submitted\x20data\x20(b_submission=true)\x20carry\x20forgery\x20risk\x20(R-C3-02\x20critical)','Deriving\x20weights\x20from\x20the\x20Arb\x20object\x20via\x20witness\x20is\x20recommended,\x20rather\x20than\x20submitting\x20them\x20directly'],'example_use_case':'3-person\x20arbitration\x20panel:\x20chief\x20arbitrator\x20weight\x203,\x20regular\x20arbitrators\x20weight\x201,\x20majority\x20vote\x20decision.','verifier_constraint_level':'level2_identity_set'},{'id':'tpl_gen_passport_identity','scene_id':'gen_passport_guard','name':'Passport\x20identity\x20credential\x20generation\x20validation','description':'Standalone\x20Guard;\x20after\x20verifying\x20the\x20user\x27s\x20identity,\x20generates\x20a\x20Passport\x20with\x20a\x20credential,\x20used\x20as\x20submission\x20data\x20for\x20subsequent\x20operations.','recommended_patterns':['P03','P14'],'parameters':[{'name':'authorized_address','type':'address','description':'Authorized\x20address\x20(or\x20use\x20Vec<Address>\x20whitelist)','required':!![]}],'example_table':[{'identifier':0x0,'b_submission':![],'value_type':'Address','value':'${authorized_address}','name':'Authorized\x20address'}],'example_root':{'type':'logic_equal','nodes':[{'type':'context','context':'Signer'},{'type':'identifier','identifier':0x0}]},'applicable_industries':['ecommerce','education','travel','subscription','rental'],'relevant_risks':['R-C1-01','R-X1-10','R-X1-13'],'creation_notes':['gen_passport\x20is\x20a\x20standalone\x20Guard;\x20it\x20does\x20not\x20bind\x20a\x20Host\x20Object\x20(host_object:\x20Standalone)','quote_guard\x20is\x20a\x20rigid\x20requirement:\x20if\x20the\x20Guard\x20queries\x20Repository\x20data\x20with\x20quote_guard\x20set,\x20the\x20quote_guard\x20must\x20be\x20verified\x20(see\x20R-X1-10)','The\x20Guard\x20can\x20be\x20depended\x20on\x20by\x20other\x20Guards\x20via\x20rely\x20(requires\x20rep=true)','The\x20generated\x20Passport\x20can\x20be\x20used\x20as\x20submission\x20data\x20for\x20subsequent\x20operations'],'example_use_case':'After\x20the\x20user\x20passes\x20identity\x20verification,\x20a\x20Passport\x20is\x20generated;\x20this\x20Passport\x20is\x20then\x20submitted\x20as\x20an\x20identity\x20credential\x20in\x20subsequent\x20service\x20purchases.','verifier_constraint_level':'level1_strict'},{'id':'tpl_repository_quote_guard_subscription','scene_id':'repository_write','name':'Repository\x20data\x20subscription\x20with\x20payment\x20verification','description':'Repository\x20quote_guard\x20requires\x20payment\x20proof\x20for\x20data\x20access.\x20When\x20any\x20Guard\x20queries\x20this\x20Repository\x27s\x20data\x20(query\x201167),\x20the\x20quote_guard\x20is\x20rigidly\x20verified.\x20Enables\x20data\x20subscription\x20revenue\x20model\x20(e.g.,\x20weather\x20data,\x20market\x20oracle\x20data).','recommended_patterns':['P03','P07'],'parameters':[{'name':'repository_address','type':'address','description':'Repository\x20object\x20address','required':!![]},{'name':'subscription_price','type':'number','description':'Subscription\x20payment\x20amount\x20required\x20for\x20data\x20access','required':!![]},{'name':'payment_for_object','type':'address','description':'Payment\x20for_object\x20(Repository\x20address)','required':!![]}],'example_table':[{'identifier':0x0,'b_submission':![],'value_type':'Address','value':'${repository_address}','name':'Repository\x20address'},{'identifier':0x1,'b_submission':![],'value_type':'U256','value':'${subscription_price}','name':'Subscription\x20price'},{'identifier':0x2,'b_submission':!![],'value_type':'Address','name':'Submitted\x20Payment\x20(for_object\x20verification)'},{'identifier':0x3,'b_submission':!![],'value_type':'U256','name':'Submitted\x20Payment\x20amount'}],'example_root':{'type':'logic_and','nodes':[{'type':'logic_equal','nodes':[{'type':'query','query':'payment.info.for','object':{'identifier':0x2}},{'type':'identifier','identifier':0x0}]},{'type':'logic_as_u256_ge','nodes':[{'type':'query','query':'payment.amount','object':{'identifier':0x2}},{'type':'identifier','identifier':0x1}]}]},'applicable_industries':['subscription','travel','rental','education'],'relevant_risks':['R-X1-10'],'creation_notes':['VERIFIER-EVIDENCE\x20DESIGN:\x20user\x20submits\x20valid\x20Payment\x20via\x20Passport\x20(b_submission=true),\x20quote_guard\x20verifies\x20Payment\x20fields','quote_guard\x20must\x20be\x20is_depended:\x20immutable=true,\x20relies\x20empty,\x20rep=true\x20(guard.move#L133-135)','Repository.owner_receive<T>\x20accepts\x20Payment\x20as\x20subscription\x20revenue\x20(repository.move#L714-717)','Rigid\x20verification:\x20any\x20guard\x20querying\x20this\x20Repository\x27s\x20data\x20MUST\x20satisfy\x20the\x20quote_guard','Two-phase:\x20passport\x20generation\x20scans\x20+\x20prepares,\x20passport\x20verification\x20re-checks\x20+\x20verifies','VERIFIED\x20QUERY\x20NAMES:\x20payment.info.for\x20(id\x201107,\x20Address),\x20payment.amount\x20(id\x201100,\x20U256)'],'example_use_case':'Weather\x20data\x20provider\x20publishes\x20daily\x20temperature\x20data\x20to\x20Repository.\x20Insurance\x20Machine\x20queries\x20weather\x20data;\x20user\x20must\x20pay\x20subscription\x20(Payment)\x20to\x20access\x20data\x20in\x20their\x20insurance\x20claim\x20flow.','verifier_constraint_level':'level3_scene_combined'},{'id':'tpl_buy_guard_order_holder','scene_id':'service_buy_guard','name':'Supply\x20chain\x20sub-order\x20purchase\x20verification','description':'Sub-service\x20buy_guard\x20verifies\x20the\x20user\x20owns\x20a\x20main\x20service\x20order.\x20Enables\x20supply\x20chain\x20milestone\x20unlock:\x20each\x20milestone\x20=\x20one\x20sub-order,\x20sub-service\x20only\x20purchasable\x20by\x20users\x20who\x20bought\x20the\x20main\x20service.','recommended_patterns':['P03','P04'],'parameters':[{'name':'main_service_address','type':'address','description':'Main\x20Service\x20object\x20address','required':!![]},{'name':'main_order_address','type':'address','description':'Submitted\x20main\x20Order\x20address\x20(b_submission=true)','required':![],'constraint':'If\x20using\x20P16\x20circular\x20reference,\x20use\x20service\x20name\x20instead\x20of\x20address'}],'example_table':[{'identifier':0x0,'b_submission':![],'value_type':'Address','value':'${main_service_address}','name':'Main\x20service\x20address'},{'identifier':0x1,'b_submission':!![],'value_type':'Address','name':'Submitted\x20main\x20Order\x20(ownership\x20verification)'}],'example_root':{'type':'logic_and','nodes':[{'type':'logic_equal','nodes':[{'type':'query','query':'order.owner','object':{'identifier':0x1}},{'type':'context','context':'Signer'}]},{'type':'logic_equal','nodes':[{'type':'query','query':'order.service','object':{'identifier':0x1}},{'type':'identifier','identifier':0x0}]}]},'applicable_industries':['travel','rental','education','freelance'],'relevant_risks':['R-C3-05'],'creation_notes':['VERIFIER-EVIDENCE\x20DESIGN:\x20user\x20submits\x20main\x20Order\x20as\x20evidence\x20(b_submission=true),\x20buy_guard\x20verifies\x20ownership\x20+\x20service\x20match','No\x20parent_order\x20field\x20needed\x20—\x20relationship\x20verified\x20via\x20buy_guard\x20querying\x20submitted\x20Order\x20fields','Each\x20milestone\x20=\x20one\x20sub-order\x20with\x20its\x20own\x20Service\x20+\x20buy_guard','Main\x20flow\x20can\x20branch\x20to\x20different\x20sub-services\x20based\x20on\x20Machine\x20node\x20progression','VERIFIED\x20QUERY\x20NAMES:\x20order.owner\x20(id\x201202,\x20Address),\x20order.service\x20(id\x201203,\x20Address)'],'example_use_case':'Travel\x20package:\x20main\x20service\x20=\x20tour\x20booking.\x20Sub-services\x20=\x20hotel,\x20guide,\x20transfer\x20—\x20each\x20with\x20buy_guard\x20verifying\x20the\x20user\x20purchased\x20the\x20main\x20tour\x20order.','verifier_constraint_level':'level2_identity_set'},{'id':'tpl_payment_exception_compensation','scene_id':'machine_forward_guard','name':'Exception\x20branch\x20compensation\x20Payment','description':'Machine\x20forward\x20guard\x20for\x20exception\x20handling:\x20verifies\x20a\x20compensation\x20Payment\x20bound\x20to\x20specific\x20order\x20+\x20guard\x20+\x20unique\x20progress\x20step\x20(history\x20count)\x20+\x20node\x20name.\x20Enables\x20user-friendly\x20exception\x20branches\x20(e.g.,\x20delivery\x20delay\x20>\x2030min\x20triggers\x20auto-compensation).','recommended_patterns':['P03','P07','P09'],'parameters':[{'name':'order_address','type':'address','description':'Order\x20object\x20address\x20(Payment\x20for_object\x20target)','required':!![]},{'name':'this_guard_address','type':'address','description':'This\x20guard\x27s\x20own\x20address\x20(Payment\x20for_guard\x20target)','required':!![]},{'name':'compensation_amount','type':'number','description':'Minimum\x20compensation\x20amount','required':!![]},{'name':'expected_node_name','type':'string','description':'Expected\x20node\x20name\x20(stored\x20in\x20PaymentInfo.remark,\x20compared\x20with\x20progress.current)','required':!![]}],'example_table':[{'identifier':0x0,'b_submission':![],'value_type':'Address','value':'${order_address}','name':'Order\x20address'},{'identifier':0x1,'b_submission':![],'value_type':'Address','value':'${this_guard_address}','name':'This\x20guard\x20address'},{'identifier':0x2,'b_submission':![],'value_type':'U256','value':'${compensation_amount}','name':'Compensation\x20amount'},{'identifier':0x3,'b_submission':![],'value_type':'String','value':'${expected_node_name}','name':'Expected\x20node\x20name\x20(for\x20remark\x20comparison)'},{'identifier':0x4,'b_submission':!![],'value_type':'Address','name':'Submitted\x20Payment\x20(compensation\x20proof)'}],'example_root':{'type':'logic_and','nodes':[{'type':'logic_equal','nodes':[{'type':'query','query':'payment.info.for','object':{'identifier':0x4}},{'type':'identifier','identifier':0x0}]},{'type':'logic_equal','nodes':[{'type':'query','query':'payment.info.guard','object':{'identifier':0x4}},{'type':'identifier','identifier':0x1}]},{'type':'logic_as_u256_ge','nodes':[{'type':'query','query':'payment.amount','object':{'identifier':0x4}},{'type':'identifier','identifier':0x2}]},{'type':'logic_as_u256_equal','nodes':[{'type':'query','query':'payment.info.index','object':{'identifier':0x4}},{'type':'query','query':'progress.history\x20count'}]},{'type':'logic_string_nocase_equal','nodes':[{'type':'query','query':'payment.info.remark','object':{'identifier':0x4}},{'type':'query','query':'progress.current'}]}]},'applicable_industries':['rental','travel','ecommerce','freelance'],'relevant_risks':[],'creation_notes':['VERIFIED:\x20payment.move#L66-71\x20(PaymentInfo:\x20for_object,\x20for_guard,\x20remark,\x20index),\x20payment.move#L82-86\x20(payment_info_with_guard)','VERIFIED:\x20treasury.move#L249-264\x20(withdraw\x20creates\x20Payment\x20via\x20payment::new_singleton\x20+\x20from_object_set)','VERIFIED\x20QUERY\x20NAMES:\x20payment.info.for\x20(id\x201107,\x20Address),\x20payment.info.guard\x20(id\x201109,\x20Address),\x20payment.info.index\x20(id\x201111,\x20U64),\x20payment.info.remark\x20(id\x201110,\x20String),\x20payment.amount\x20(id\x201100,\x20U64;\x20logic_as_u256_ge\x20casts\x20U64→U256\x20for\x20comparison)','VERIFIED\x20INDEX:\x20progress.history\x20count\x20(id\x201273,\x20U64)\x20=\x20unique\x20monotonically\x20increasing\x20step\x20index\x20(progress.move\x20L440-441,\x20L475,\x20L482).\x20Even\x20in\x20cycles,\x20each\x20entry\x20has\x20a\x20different\x20count.','VERIFIED\x20NODE\x20NAME:\x20progress.current\x20(id\x201253,\x20String)\x20=\x20current\x20node\x20name.\x20A\x20node\x20can\x20be\x20entered\x20multiple\x20times\x20in\x20cycles,\x20but\x20the\x20history\x20count\x20is\x20unique\x20each\x20time.','DESIGN:\x20payment.info.index\x20stores\x20the\x20step\x20index\x20set\x20by\x20Treasury\x20at\x20creation\x20time;\x20progress.history\x20count\x20provides\x20the\x20current\x20unique\x20step.\x20Comparing\x20them\x20ensures\x20the\x20Payment\x20was\x20created\x20for\x20THIS\x20specific\x20progress\x20step.','DESIGN:\x20payment.info.remark\x20stores\x20the\x20node\x20name;\x20progress.current\x20provides\x20the\x20current\x20node\x20name.\x20Comparing\x20them\x20provides\x20semantic\x20verification\x20of\x20which\x20node\x20triggered\x20the\x20compensation.','ANTI-REUSE:\x204-dimensional\x20binding:\x20for_object\x20(Order)\x20+\x20for_guard\x20(Guard)\x20+\x20index\x20(unique\x20step)\x20+\x20remark\x20(node\x20name).\x20Same\x20Payment\x20cannot\x20be\x20reused\x20in\x20other\x20contexts.','Payment\x20is\x20freeze_object\x20(immutable)\x20—\x20cannot\x20be\x20modified\x20after\x20creation','VERIFIER-EVIDENCE\x20DESIGN:\x20customer\x20submits\x20Payment,\x20guard\x20verifies\x20binding\x20fields\x20match\x20current\x20context','Treasury\x20withdraws\x20compensation\x20with\x20PaymentInfo(for_object=order,\x20for_guard=this,\x20index=history_count_at_creation,\x20remark=node_name)'],'example_use_case':'Food\x20delivery:\x20if\x20delivery\x20delayed\x20>\x2030min\x20at\x20node\x20\x27delayed\x27\x20(history\x20count=5),\x20restaurant\x20Treasury\x20auto-compensates\x20$5\x20to\x20customer\x20with\x20PaymentInfo(for_object=order,\x20for_guard=this,\x20index=5,\x20remark=\x27delayed\x27).\x20Customer\x20submits\x20Payment\x20via\x20Passport,\x20guard\x20verifies\x20index\x20matches\x20current\x20history\x20count\x20AND\x20remark\x20matches\x20current\x20node\x20name.','verifier_constraint_level':'level3_scene_combined'},{'id':'tpl_forward_content_subscription_deliver','scene_id':'machine_forward_guard','name':'Content\x20subscription\x20delivery\x20verification\x20(Substack-style)','description':'Forward\x20guard\x20for\x20content\x20subscription\x20delivery\x20flow.\x20Verifies\x20that\x20(1)\x20the\x20order\x20is\x20at\x20the\x20expected\x20pre-delivery\x20node\x20'+'(e.g.\x20\x27Ordered\x27),\x20AND\x20(2)\x20the\x20Signer\x20holds\x20the\x20author\x27s\x20permission\x20index\x20on\x20the\x20bound\x20Permission\x20object.\x20'+'Prevents\x20unauthorized\x20parties\x20from\x20publishing\x20content\x20on\x20behalf\x20of\x20the\x20author.\x20'+'Designed\x20for\x20Substack-style\x20content\x20subscription:\x20Paid\x20→\x20ContentPublished\x20→\x20Completed\x20(success\x20path),\x20'+'with\x20Cancelled\x20and\x20Disputed\x20branches\x20using\x20separate\x20guards\x20(tpl_forward_content_subscription_cancel,\x20'+'tpl_forward_content_subscription_refund).','recommended_patterns':['P06','P09'],'parameters':[{'name':'expected_pre_delivery_node','type':'string','description':'Expected\x20current\x20node\x20name\x20BEFORE\x20delivery\x20(e.g.\x20\x27Ordered\x27)','required':!![],'default':'Ordered','constraint':'Must\x20exactly\x20match\x20the\x20name\x20defined\x20in\x20Machine\x20nodes\x20(case-sensitive).\x20This\x20is\x20the\x20node\x20from\x20which\x20the\x20\x27Deliver\x27\x20forward\x20advances.'},{'name':'permission_object','type':'address','description':'Permission\x20object\x20address\x20bound\x20to\x20the\x20Machine\x20(author\x20role\x20lives\x20here)','required':!![],'constraint':'Must\x20be\x20the\x20same\x20Permission\x20object\x20bound\x20to\x20the\x20Machine.\x20Use\x20name\x20(not\x20address)\x20if\x20Permission\x20is\x20not\x20yet\x20created.'},{'name':'author_permission_index','type':'number','description':'Permission\x20index\x20reserved\x20for\x20the\x20author\x20role\x20(who\x20can\x20publish\x20content)','required':!![],'default':'1000','constraint':'Must\x20match\x20the\x20index\x20configured\x20in\x20the\x20Permission\x20object.\x20Substack\x20convention:\x201000=author,\x201500=arbitrator,\x20reader\x20uses\x20namedOperator=\x27\x27\x20(no\x20specific\x20operator).'}],'example_table':[{'identifier':0x0,'b_submission':!![],'value_type':'Address','object_type':'Order','name':'Order\x20object\x20address\x20(submitted\x20by\x20verifier\x20at\x20runtime)','binding_constraint':'Must\x20be\x20an\x20Order\x20belonging\x20to\x20the\x20bound\x20Service;\x20progress.current\x20must\x20match\x20expected_pre_delivery_node'},{'identifier':0x1,'b_submission':![],'value_type':'String','value':'${expected_pre_delivery_node}','name':'Expected\x20pre-delivery\x20node\x20name\x20(e.g.\x20\x27Ordered\x27)'},{'identifier':0x2,'b_submission':![],'value_type':'Address','value':'${permission_object}','name':'Permission\x20object\x20address\x20(bound\x20to\x20Machine,\x20holds\x20author\x20role)'},{'identifier':0x3,'b_submission':![],'value_type':'U64','value':'${author_permission_index}','name':'Author\x20permission\x20index\x20(e.g.\x201000)'}],'example_root':{'type':'logic_and','nodes':[{'type':'logic_string_nocase_equal','nodes':[{'type':'query','query':'progress.current','object':{'identifier':0x0,'convert_witness':'OrderProgress'},'parameters':[]},{'type':'identifier','identifier':0x1}]},{'type':'logic_equal','nodes':[{'type':'context','context':'Signer'},{'type':'query','query':'permission.permitted','object':{'identifier':0x2},'parameters':[{'type':'context','context':'Signer'},{'type':'identifier','identifier':0x3}]}]}]},'applicable_industries':['subscription','content','newsletter','media'],'relevant_risks':['R-C2-01','R-C2-03','R-X1-08'],'creation_notes':['VERIFIED\x20QUERY\x20NAMES:\x20progress.current\x20(id\x201253,\x20String)\x20—\x20current\x20node\x20name;\x20permission.permitted\x20(Permission\x20object\x20query,\x20returns\x20Address\x20of\x20permitted\x20operator\x20for\x20the\x20given\x20index)','SUBSTACK\x20DEPLOYMENT:\x20this\x20guard\x20was\x20used\x20in\x20Substack\x20v2\x20Service.\x20Original\x20v1\x20Service\x20was\x20published\x20without\x20arbitrations\x20—\x20had\x20to\x20be\x20recreated\x20as\x20v2\x20with\x20arbitrations\x20bound\x20BEFORE\x20publish\x20(F-S-21).','AUTHOR\x20ROLE:\x20permission\x20index\x201000\x20=\x20author\x20(publish\x20+\x20cancel).\x20namedOperator=\x27\x27\x20for\x20reader\x20role\x20(open\x20—\x20any\x20subscriber).\x20Arbitrator\x20uses\x20index\x201500.','FORWARD\x20DESIGN:\x20\x27Deliver\x27\x20forward\x20advances\x20from\x20\x27Ordered\x27\x20→\x20\x27ContentPublished\x27.\x20Threshold=1,\x20weight=1,\x20permissionIndex=1000\x20(author\x20only).','GUARD-FIRST-WINS:\x20when\x20\x27Ordered\x27\x20has\x20competing\x20forwards\x20(Deliver|Cancel|Dispute),\x20each\x20with\x20its\x20own\x20guard,\x20the\x20first\x20guard\x20to\x20verify\x20wins.\x20Subscribers\x20cannot\x20double-claim\x20by\x20triggering\x20multiple\x20forwards.','IMMUTABILITY:\x20Forward.guard\x20cannot\x20be\x20modified\x20after\x20Machine\x20publish.\x20Verify\x20all\x203\x20guards\x20(deliver/cancel/refund)\x20are\x20correctly\x20bound\x20BEFORE\x20publishing\x20the\x20Machine.','CIRCULAR\x20REF:\x20if\x20Permission\x20is\x20not\x20yet\x20created,\x20use\x20its\x20name\x20(not\x20address)\x20in\x20value\x20field\x20—\x20Guard\x20resolves\x20names\x20at\x20evaluation\x20time,\x20not\x20at\x20creation\x20time.'],'example_use_case':'Substack\x20newsletter:\x20subscriber\x20pays\x20$5/month.\x20Author\x20publishes\x20content\x20→\x20\x27Deliver\x27\x20forward\x20advances\x20Ordered→ContentPublished.\x20'+'This\x20guard\x20verifies\x20(1)\x20order\x20is\x20at\x20\x27Ordered\x27\x20node\x20(not\x20already\x20delivered),\x20AND\x20(2)\x20Signer\x20holds\x20permission\x20index\x201000\x20on\x20author\x27s\x20Permission\x20object.\x20'+'Prevents\x20a\x20malicious\x20party\x20from\x20publishing\x20fake\x20content.\x20Subscriber\x20cannot\x20trigger\x20\x27Deliver\x27\x20(lacks\x20permission).','verifier_constraint_level':'level2_identity_set'},{'id':'tpl_forward_content_subscription_cancel','scene_id':'machine_forward_guard','name':'Content\x20subscription\x20cancel\x20verification\x20(Substack-style)','description':'Forward\x20guard\x20for\x20content\x20subscription\x20cancel\x20flow.\x20Verifies\x20that\x20(1)\x20the\x20order\x20is\x20at\x20the\x20expected\x20pre-cancel\x20node\x20'+'(e.g.\x20\x27Ordered\x27),\x20AND\x20(2)\x20the\x20Signer\x20is\x20the\x20order\x20owner\x20(subscriber).\x20Allows\x20subscriber\x20to\x20cancel\x20within\x20grace\x20period\x20'+'for\x20full\x20refund.\x20Designed\x20for\x20Substack-style:\x20Paid\x20→\x20Cancelled\x20(terminal-cancel),\x20with\x20refund\x20via\x20Allocation\x20template.','recommended_patterns':['P06','P09'],'parameters':[{'name':'expected_pre_cancel_node','type':'string','description':'Expected\x20current\x20node\x20name\x20BEFORE\x20cancel\x20(e.g.\x20\x27Ordered\x27)','required':!![],'default':'Ordered','constraint':'Must\x20exactly\x20match\x20the\x20name\x20defined\x20in\x20Machine\x20nodes\x20(case-sensitive).'}],'example_table':[{'identifier':0x0,'b_submission':!![],'value_type':'Address','object_type':'Order','name':'Order\x20object\x20address\x20(submitted\x20by\x20verifier\x20at\x20runtime)'},{'identifier':0x1,'b_submission':![],'value_type':'String','value':'${expected_pre_cancel_node}','name':'Expected\x20pre-cancel\x20node\x20name\x20(e.g.\x20\x27Ordered\x27)'}],'example_root':{'type':'logic_and','nodes':[{'type':'logic_string_nocase_equal','nodes':[{'type':'query','query':'progress.current','object':{'identifier':0x0,'convert_witness':'OrderProgress'},'parameters':[]},{'type':'identifier','identifier':0x1}]},{'type':'logic_equal','nodes':[{'type':'context','context':'Signer'},{'type':'query','query':'order.owner','object':{'identifier':0x0},'parameters':[]}]}]},'applicable_industries':['subscription','content','newsletter','media'],'relevant_risks':['R-C2-01','R-C2-03'],'creation_notes':['VERIFIED\x20QUERY\x20NAMES:\x20progress.current\x20(id\x201253,\x20String);\x20order.owner\x20(id\x201202,\x20Address)\x20—\x20order\x20holder\x20(subscriber).','SUBSCRIBER-ONLY:\x20only\x20the\x20order\x20owner\x20can\x20cancel\x20—\x20prevents\x20third-party\x20griefing.\x20Author\x20cannot\x20cancel\x20on\x20behalf\x20of\x20subscriber.','GRACE\x20PERIOD:\x20this\x20guard\x20does\x20NOT\x20enforce\x20a\x20time\x20window.\x20If\x20a\x20grace\x20period\x20is\x20needed\x20(e.g.\x20cancel\x20within\x2024h\x20of\x20payment),\x20add\x20a\x20third\x20condition:\x20context(Clock)\x20<=\x20order.time\x20+\x20grace_period.','REFUND\x20ALLOCATION:\x20pair\x20this\x20guard\x20with\x20an\x20Allocation\x20template\x20that\x20refunds\x20100%\x20to\x20the\x20subscriber\x20(order.owner).\x20Trigger\x20node\x20=\x20\x27Cancelled\x27.','GUARD-FIRST-WINS:\x20when\x20\x27Ordered\x27\x20has\x20competing\x20forwards\x20(Deliver|Cancel|Dispute),\x20each\x20with\x20its\x20own\x20guard,\x20the\x20first\x20guard\x20to\x20verify\x20wins.'],'example_use_case':'Substack\x20newsletter:\x20subscriber\x20pays\x20$5,\x20then\x20changes\x20mind\x20before\x20content\x20is\x20published.\x20\x27Cancel\x27\x20forward\x20advances\x20Ordered→Cancelled.\x20'+'This\x20guard\x20verifies\x20(1)\x20order\x20is\x20at\x20\x27Ordered\x27\x20(not\x20yet\x20delivered),\x20AND\x20(2)\x20Signer\x20is\x20the\x20order\x20owner.\x20'+'Author\x20cannot\x20cancel\x20on\x20behalf\x20of\x20subscriber.\x20Refund\x20triggers\x20automatically\x20via\x20Allocation\x20on\x20\x27Cancelled\x27\x20node.','verifier_constraint_level':'level2_identity_set'},{'id':'tpl_forward_content_subscription_refund','scene_id':'machine_forward_guard','name':'Content\x20subscription\x20refund\x20verification\x20(Substack-style,\x20arbitration-triggered)','description':'Forward\x20guard\x20for\x20content\x20subscription\x20dispute/refund\x20flow.\x20Verifies\x20that\x20(1)\x20the\x20order\x20is\x20at\x20the\x20expected\x20pre-dispute\x20node\x20'+'(e.g.\x20\x27Disputed\x27),\x20AND\x20(2)\x20the\x20Signer\x20holds\x20the\x20arbitrator\x27s\x20permission\x20index\x20on\x20the\x20bound\x20Permission\x20object.\x20'+'Only\x20the\x20arbitrator\x20can\x20advance\x20Disputed→Refunded,\x20ensuring\x20dispute\x20resolution\x20is\x20impartial.\x20'+'Designed\x20for\x20Substack-style:\x20Paid\x20→\x20Disputed\x20→\x20Refunded\x20(terminal-dispute).','recommended_patterns':['P06','P09'],'parameters':[{'name':'expected_pre_refund_node','type':'string','description':'Expected\x20current\x20node\x20name\x20BEFORE\x20refund\x20(e.g.\x20\x27Disputed\x27)','required':!![],'default':'Disputed','constraint':'Must\x20exactly\x20match\x20the\x20name\x20defined\x20in\x20Machine\x20nodes\x20(case-sensitive).'},{'name':'permission_object','type':'address','description':'Permission\x20object\x20address\x20bound\x20to\x20the\x20Machine\x20(arbitrator\x20role\x20lives\x20here)','required':!![],'constraint':'Must\x20be\x20the\x20same\x20Permission\x20object\x20bound\x20to\x20the\x20Machine.\x20Use\x20name\x20(not\x20address)\x20if\x20Permission\x20is\x20not\x20yet\x20created.'},{'name':'arbitrator_permission_index','type':'number','description':'Permission\x20index\x20reserved\x20for\x20the\x20arbitrator\x20role\x20(who\x20can\x20resolve\x20disputes)','required':!![],'default':'1500','constraint':'Must\x20match\x20the\x20index\x20configured\x20in\x20the\x20Permission\x20object.\x20Substack\x20convention:\x201000=author,\x201500=arbitrator.'}],'example_table':[{'identifier':0x0,'b_submission':!![],'value_type':'Address','object_type':'Order','name':'Order\x20object\x20address\x20(submitted\x20by\x20verifier\x20at\x20runtime)'},{'identifier':0x1,'b_submission':![],'value_type':'String','value':'${expected_pre_refund_node}','name':'Expected\x20pre-refund\x20node\x20name\x20(e.g.\x20\x27Disputed\x27)'},{'identifier':0x2,'b_submission':![],'value_type':'Address','value':'${permission_object}','name':'Permission\x20object\x20address\x20(bound\x20to\x20Machine,\x20holds\x20arbitrator\x20role)'},{'identifier':0x3,'b_submission':![],'value_type':'U64','value':'${arbitrator_permission_index}','name':'Arbitrator\x20permission\x20index\x20(e.g.\x201500)'}],'example_root':{'type':'logic_and','nodes':[{'type':'logic_string_nocase_equal','nodes':[{'type':'query','query':'progress.current','object':{'identifier':0x0,'convert_witness':'OrderProgress'},'parameters':[]},{'type':'identifier','identifier':0x1}]},{'type':'logic_equal','nodes':[{'type':'context','context':'Signer'},{'type':'query','query':'permission.permitted','object':{'identifier':0x2},'parameters':[{'type':'context','context':'Signer'},{'type':'identifier','identifier':0x3}]}]}]},'applicable_industries':['subscription','content','newsletter','media'],'relevant_risks':['R-C2-01','R-C2-03','R-X1-08'],'creation_notes':['VERIFIED\x20QUERY\x20NAMES:\x20progress.current\x20(id\x201253,\x20String);\x20permission.permitted\x20(Permission\x20object\x20query,\x20returns\x20Address\x20of\x20permitted\x20operator\x20for\x20the\x20given\x20index).','ARBITRATOR-ONLY:\x20only\x20the\x20arbitrator\x20(permission\x20index\x201500)\x20can\x20advance\x20Disputed→Refunded.\x20Neither\x20author\x20nor\x20subscriber\x20can\x20self-resolve.','ARBITRATIONS\x20BINDING:\x20Service\x20MUST\x20have\x20arbitrations\x20bound\x20BEFORE\x20publish\x20(F-S-21\x20—\x20post-publish\x20immutable).\x20ConfirmGate\x20C-S-19\x20+\x20QS11\x20will\x20warn\x20if\x20publish\x20is\x20attempted\x20without\x20arbitrations.','DISPUTE\x20ENTRY:\x20\x27Dispute\x27\x20forward\x20(Ordered→Disputed)\x20is\x20triggered\x20by\x20subscriber\x20(order.owner).\x20After\x20Disputed,\x20only\x20arbitrator\x20can\x20resolve.','REFUND\x20ALLOCATION:\x20pair\x20this\x20guard\x20with\x20an\x20Allocation\x20template\x20that\x20refunds\x20100%\x20to\x20the\x20subscriber\x20(order.owner).\x20Trigger\x20node\x20=\x20\x27Refunded\x27.','GUARD-FIRST-WINS:\x20when\x20\x27Disputed\x27\x20has\x20competing\x20forwards\x20(Resolve-Refund|Resolve-Reject),\x20each\x20with\x20its\x20own\x20guard.\x20First\x20guard\x20to\x20verify\x20wins.'],'example_use_case':'Substack\x20newsletter:\x20subscriber\x20disputes\x20content\x20quality.\x20Subscriber\x20triggers\x20\x27Dispute\x27\x20forward\x20(Ordered→Disputed).\x20'+'Arbitrator\x20reviews\x20evidence\x20and\x20triggers\x20\x27Resolve-Refund\x27\x20forward\x20(Disputed→Refunded).\x20'+'This\x20guard\x20verifies\x20(1)\x20order\x20is\x20at\x20\x27Disputed\x27\x20(dispute\x20properly\x20opened),\x20AND\x20(2)\x20Signer\x20holds\x20arbitrator\x20permission\x20index\x201500.\x20'+'Author\x20cannot\x20self-resolve.\x20Subscriber\x20cannot\x20self-refund.','verifier_constraint_level':'level2_identity_set'}];export function getTemplatesByScene(a){return GUARD_TEMPLATES['filter'](b=>b['scene_id']===a);}export function getTemplateById(a){return GUARD_TEMPLATES['find'](b=>b['id']===a);}export function getTemplatesByIndustry(a){return GUARD_TEMPLATES['filter'](b=>b['applicable_industries']['includes'](a));}export function getTemplatesByPattern(a){return GUARD_TEMPLATES['filter'](b=>b['recommended_patterns']['includes'](a));}export function listGuardTemplates(){return GUARD_TEMPLATES;}export function suggestTemplateForScene(a){return GUARD_TEMPLATES['find'](b=>b['scene_id']===a);}export function getTemplateParameters(a){const b=getTemplateById(a);return b?.['parameters']??[];}export function validateTemplateParams(a,b){const c=getTemplateById(a);if(!c)return{'valid':![],'missing':['template_not_found']};const d=c['parameters']['filter'](e=>e['required']&&!(e['name']in b))['map'](e=>e['name']);return{'valid':d['length']===0x0,'missing':d};}function deepSubstitute(a,b){if(typeof a==='string'){const c=a['match'](/^\$\{(\w+)\}$/);if(c&&c[0x1]in b)return b[c[0x1]];return a['replace'](/\$\{(\w+)\}/g,(d,e)=>e in b?String(b[e]):'${'+e+'}');}if(Array['isArray'](a))return a['map'](d=>deepSubstitute(d,b));if(a&&typeof a==='object'){const d={};for(const [e,f]of Object['entries'](a)){d[e]=deepSubstitute(f,b);}return d;}return a;}export function fillGuardTemplate(a,b){const c=getTemplateById(a);if(!c)return{'ok':![],'error':'Template\x20not\x20found:\x20'+a};const {valid:d,missing:e}=validateTemplateParams(a,b);if(!d)return{'ok':![],'error':'Missing\x20required\x20parameters:\x20'+e['join'](',\x20'),'missing':e};const f={...b};for(const j of c['parameters']){!(j['name']in f)&&j['default']!==undefined&&(f[j['name']]=j['default']);}const g=deepSubstitute(c['example_table'],f),h=deepSubstitute(c['example_root'],f),i=JSON['stringify']({'table':g,'root':h})['match'](/\$\{(\w+)\}/);if(i)return{'ok':![],'error':'Unresolved\x20placeholder\x20${'+i[0x1]+'}\x20—\x20not\x20declared\x20in\x20template\x20parameters'};return{'ok':!![],'table':g,'root':h};}export const GUARD_TEMPLATES_VERSION='1.0.0';export const GUARD_TEMPLATES_COUNT=GUARD_TEMPLATES['length'];