@wowok/agent-mcp 3.1.3 → 3.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (379) hide show
  1. package/dist/config/config-audit.spec.d.ts +1 -0
  2. package/dist/config/config-audit.spec.js +1 -0
  3. package/dist/config/exposure.d.ts +108 -0
  4. package/dist/config/exposure.js +1 -0
  5. package/dist/config/index.d.ts +2 -0
  6. package/dist/config/index.js +1 -1
  7. package/dist/config/judgment.d.ts +1228 -0
  8. package/dist/config/judgment.js +1 -0
  9. package/dist/config/judgment.spec.d.ts +1 -0
  10. package/dist/config/judgment.spec.js +1 -0
  11. package/dist/config/rule-engine.d.ts +299 -0
  12. package/dist/config/rule-engine.js +1 -0
  13. package/dist/config/rule-engine.spec.d.ts +1 -0
  14. package/dist/config/rule-engine.spec.js +1 -0
  15. package/dist/config/severity.d.ts +7 -0
  16. package/dist/config/severity.js +1 -0
  17. package/dist/customer/order-monitor.d.ts +3 -1
  18. package/dist/customer/order-monitor.js +1 -1
  19. package/dist/evaluation/acceptance.d.ts +1 -0
  20. package/dist/evaluation/acceptance.js +1 -1
  21. package/dist/evaluation/arbitration-game.js +1 -1
  22. package/dist/evaluation/builtins/demand-match.js +1 -1
  23. package/dist/evaluation/builtins/graph-service.js +1 -1
  24. package/dist/evaluation/builtins/graph-service.spec.js +1 -1
  25. package/dist/evaluation/engine.js +1 -1
  26. package/dist/evaluation/game-strategy.d.ts +2 -2
  27. package/dist/evaluation/game-strategy.js +1 -1
  28. package/dist/evaluation/match-operation.d.ts +2 -2
  29. package/dist/evaluation/match-operation.js +1 -1
  30. package/dist/evaluation/standards.d.ts +3 -25
  31. package/dist/evaluation/standards.js +1 -1
  32. package/dist/evaluation/types.d.ts +2 -1
  33. package/dist/experience/realtime-feedback.js +1 -1
  34. package/dist/extensions/business-modules.js +1 -1
  35. package/dist/extensions/custom-registry-file.js +1 -1
  36. package/dist/extensions/industry-audit.spec.d.ts +1 -0
  37. package/dist/extensions/industry-audit.spec.js +1 -0
  38. package/dist/extensions/industry-layers.d.ts +8 -0
  39. package/dist/extensions/industry-layers.js +1 -1
  40. package/dist/extensions/industry-pack.d.ts +2 -0
  41. package/dist/extensions/industry-pack.js +1 -1
  42. package/dist/extensions/mode-evaluator.js +1 -1
  43. package/dist/extensions/modes.js +1 -1
  44. package/dist/graph/onchain/analyze.d.ts +3 -1
  45. package/dist/graph/onchain/analyze.js +1 -1
  46. package/dist/graph/onchain/analyze.spec.js +1 -1
  47. package/dist/graph/onchain/edge-schema.d.ts +1 -0
  48. package/dist/graph/onchain/edge-schema.js +1 -1
  49. package/dist/graph/onchain/expand.js +1 -1
  50. package/dist/graph/onchain/exploration.d.ts +28 -0
  51. package/dist/graph/onchain/exploration.js +1 -0
  52. package/dist/graph/onchain/exploration.spec.d.ts +1 -0
  53. package/dist/graph/onchain/exploration.spec.js +1 -0
  54. package/dist/graph/onchain/exposure.d.ts +18 -0
  55. package/dist/graph/onchain/exposure.js +1 -0
  56. package/dist/graph/onchain/exposure.spec.d.ts +1 -0
  57. package/dist/graph/onchain/exposure.spec.js +1 -0
  58. package/dist/graph/onchain/graph-policy.spec.d.ts +1 -0
  59. package/dist/graph/onchain/graph-policy.spec.js +1 -0
  60. package/dist/graph/onchain/index.d.ts +6 -0
  61. package/dist/graph/onchain/index.js +1 -1
  62. package/dist/graph/onchain/interest.js +1 -1
  63. package/dist/graph/onchain/interest.spec.js +1 -1
  64. package/dist/graph/onchain/names.js +1 -1
  65. package/dist/graph/onchain/names.spec.js +1 -1
  66. package/dist/graph/onchain/policy.d.ts +8 -0
  67. package/dist/graph/onchain/policy.js +1 -0
  68. package/dist/graph/onchain/proposal-graph.js +1 -1
  69. package/dist/graph/onchain/proposal-graph.spec.js +1 -1
  70. package/dist/graph/onchain/synthesis.d.ts +20 -0
  71. package/dist/graph/onchain/synthesis.js +1 -0
  72. package/dist/graph/onchain/synthesis.spec.d.ts +1 -0
  73. package/dist/graph/onchain/synthesis.spec.js +1 -0
  74. package/dist/graph/onchain/types.d.ts +11 -1
  75. package/dist/keeper/keeper.spec.js +1 -1
  76. package/dist/knowledge/alloc-audit-policy.spec.d.ts +1 -0
  77. package/dist/knowledge/alloc-audit-policy.spec.js +1 -0
  78. package/dist/knowledge/allocation-ledger.js +1 -1
  79. package/dist/knowledge/allocation-puzzle.d.ts +1 -1
  80. package/dist/knowledge/allocation-puzzle.js +1 -1
  81. package/dist/knowledge/allocation-risk.d.ts +4 -1
  82. package/dist/knowledge/allocation-risk.js +1 -1
  83. package/dist/knowledge/allocation-templates.js +1 -1
  84. package/dist/knowledge/arb-risk.d.ts +6 -5
  85. package/dist/knowledge/arb-risk.js +1 -1
  86. package/dist/knowledge/arbitration-ledger.d.ts +4 -4
  87. package/dist/knowledge/arbitration-ledger.js +1 -1
  88. package/dist/knowledge/arbitration-puzzle.d.ts +1 -1
  89. package/dist/knowledge/arbitration-puzzle.js +1 -1
  90. package/dist/knowledge/arbitration-risk.d.ts +4 -1
  91. package/dist/knowledge/arbitration-risk.js +1 -1
  92. package/dist/knowledge/arbitration-templates.js +1 -1
  93. package/dist/knowledge/baselines/judgment-baselines.json +289 -0
  94. package/dist/knowledge/baselines/risk-baselines.spec.js +1 -1
  95. package/dist/knowledge/baselines/rules/alloc_audit.json +290 -0
  96. package/dist/knowledge/baselines/rules/allocation.json +492 -0
  97. package/dist/knowledge/baselines/rules/arb.json +155 -0
  98. package/dist/knowledge/baselines/rules/arbitration.json +366 -0
  99. package/dist/knowledge/baselines/rules/bridge.json +197 -0
  100. package/dist/knowledge/baselines/rules/contact.json +152 -0
  101. package/dist/knowledge/baselines/rules/demand.json +158 -0
  102. package/dist/knowledge/baselines/rules/graph.json +453 -0
  103. package/dist/knowledge/baselines/rules/guard.json +981 -0
  104. package/dist/knowledge/baselines/rules/machine.json +706 -0
  105. package/dist/knowledge/baselines/rules/order.json +549 -0
  106. package/dist/knowledge/baselines/rules/payment.json +205 -0
  107. package/dist/knowledge/baselines/rules/permission.json +330 -0
  108. package/dist/knowledge/baselines/rules/personal.json +139 -0
  109. package/dist/knowledge/baselines/rules/progress.json +346 -0
  110. package/dist/knowledge/baselines/rules/proof.json +158 -0
  111. package/dist/knowledge/baselines/rules/registrar.json +159 -0
  112. package/dist/knowledge/baselines/rules/repository.json +244 -0
  113. package/dist/knowledge/baselines/rules/resource.json +117 -0
  114. package/dist/knowledge/baselines/rules/reward.json +471 -0
  115. package/dist/knowledge/baselines/rules/service.json +595 -0
  116. package/dist/knowledge/baselines/rules/treasury.json +440 -0
  117. package/dist/knowledge/baselines/rules/util.json +101 -0
  118. package/dist/knowledge/bridge-risk.d.ts +6 -5
  119. package/dist/knowledge/bridge-risk.js +1 -1
  120. package/dist/knowledge/builtin-templates.d.ts +26 -0
  121. package/dist/knowledge/builtin-templates.js +1 -0
  122. package/dist/knowledge/contact-risk.d.ts +6 -5
  123. package/dist/knowledge/contact-risk.js +1 -1
  124. package/dist/knowledge/demand-risk.d.ts +6 -5
  125. package/dist/knowledge/demand-risk.js +1 -1
  126. package/dist/knowledge/event-semantics.js +1 -1
  127. package/dist/knowledge/facts-sync.spec.d.ts +1 -0
  128. package/dist/knowledge/facts-sync.spec.js +1 -0
  129. package/dist/knowledge/getting-started.js +1 -1
  130. package/dist/knowledge/guard-design-patterns.js +1 -1
  131. package/dist/knowledge/guard-field-cognition.d.ts +1 -1
  132. package/dist/knowledge/guard-field-cognition.js +1 -1
  133. package/dist/knowledge/guard-ledger.js +1 -1
  134. package/dist/knowledge/guard-risk.d.ts +4 -1
  135. package/dist/knowledge/guard-risk.js +1 -1
  136. package/dist/knowledge/guard-templates.js +1 -1
  137. package/dist/knowledge/guard-translation.js +1 -1
  138. package/dist/knowledge/index.d.ts +10 -2
  139. package/dist/knowledge/index.js +1 -1
  140. package/dist/knowledge/industry-registry.js +1 -1
  141. package/dist/knowledge/industry-strategy.js +1 -1
  142. package/dist/knowledge/jsonrpc-enum.js +1 -1
  143. package/dist/knowledge/machine-ledger.js +1 -1
  144. package/dist/knowledge/machine-risk.d.ts +4 -1
  145. package/dist/knowledge/machine-risk.js +1 -1
  146. package/dist/knowledge/machine-templates.js +1 -1
  147. package/dist/knowledge/machine-translation.js +1 -1
  148. package/dist/knowledge/migration-preflight.js +1 -1
  149. package/dist/knowledge/operation-dictionary.js +1 -1
  150. package/dist/knowledge/order-ledger.js +1 -1
  151. package/dist/knowledge/order-puzzle.d.ts +3 -3
  152. package/dist/knowledge/order-puzzle.js +1 -1
  153. package/dist/knowledge/order-risk.d.ts +6 -3
  154. package/dist/knowledge/order-risk.js +1 -1
  155. package/dist/knowledge/order-templates.js +1 -1
  156. package/dist/knowledge/passport-ledger.js +1 -1
  157. package/dist/knowledge/passport-templates.js +1 -1
  158. package/dist/knowledge/payment-risk.d.ts +8 -6
  159. package/dist/knowledge/payment-risk.js +1 -1
  160. package/dist/knowledge/payment-tracker.js +1 -1
  161. package/dist/knowledge/permission-ledger.js +1 -1
  162. package/dist/knowledge/permission-puzzle.d.ts +12 -12
  163. package/dist/knowledge/permission-puzzle.js +1 -1
  164. package/dist/knowledge/permission-risk.d.ts +4 -7
  165. package/dist/knowledge/permission-risk.js +1 -1
  166. package/dist/knowledge/permission-templates.js +1 -1
  167. package/dist/knowledge/personal-risk.d.ts +6 -5
  168. package/dist/knowledge/personal-risk.js +1 -1
  169. package/dist/knowledge/progress-ledger.js +1 -1
  170. package/dist/knowledge/progress-puzzle.d.ts +2 -2
  171. package/dist/knowledge/progress-puzzle.js +1 -1
  172. package/dist/knowledge/progress-risk.d.ts +4 -1
  173. package/dist/knowledge/progress-risk.js +1 -1
  174. package/dist/knowledge/progress-templates.js +1 -1
  175. package/dist/knowledge/proof-risk.d.ts +6 -5
  176. package/dist/knowledge/proof-risk.js +1 -1
  177. package/dist/knowledge/puzzle-projections.js +1 -1
  178. package/dist/knowledge/recipient-constraint.d.ts +20 -1
  179. package/dist/knowledge/recipient-constraint.js +1 -1
  180. package/dist/knowledge/registrar-risk.d.ts +6 -5
  181. package/dist/knowledge/registrar-risk.js +1 -1
  182. package/dist/knowledge/repository-risk.d.ts +7 -6
  183. package/dist/knowledge/repository-risk.js +1 -1
  184. package/dist/knowledge/resource-risk.d.ts +6 -5
  185. package/dist/knowledge/resource-risk.js +1 -1
  186. package/dist/knowledge/reward-ledger.d.ts +1 -1
  187. package/dist/knowledge/reward-ledger.js +1 -1
  188. package/dist/knowledge/reward-puzzle.d.ts +2 -2
  189. package/dist/knowledge/reward-puzzle.js +1 -1
  190. package/dist/knowledge/reward-risk.d.ts +4 -1
  191. package/dist/knowledge/reward-risk.js +1 -1
  192. package/dist/knowledge/rule-node-analyzers.spec.js +1 -1
  193. package/dist/knowledge/rule-outcome.js +1 -1
  194. package/dist/knowledge/scenario-modes.d.ts +2 -2
  195. package/dist/knowledge/scenario-modes.js +1 -1
  196. package/dist/knowledge/scenario-topology.js +1 -1
  197. package/dist/knowledge/service-allocator-audit-node.js +1 -1
  198. package/dist/knowledge/service-ledger.js +1 -1
  199. package/dist/knowledge/service-puzzle.d.ts +2 -2
  200. package/dist/knowledge/service-puzzle.js +1 -1
  201. package/dist/knowledge/service-risk-node.js +1 -1
  202. package/dist/knowledge/service-risk.d.ts +4 -1
  203. package/dist/knowledge/service-risk.js +1 -1
  204. package/dist/knowledge/service-templates.js +1 -1
  205. package/dist/knowledge/strategy-manuals.d.ts +1 -1
  206. package/dist/knowledge/strategy-manuals.js +1 -1
  207. package/dist/knowledge/template-loader.d.ts +84 -0
  208. package/dist/knowledge/template-loader.js +1 -0
  209. package/dist/knowledge/template-loader.spec.d.ts +1 -0
  210. package/dist/knowledge/template-loader.spec.js +1 -0
  211. package/dist/knowledge/template-registry.js +1 -1
  212. package/dist/knowledge/template-scanner.d.ts +17 -0
  213. package/dist/knowledge/template-scanner.js +1 -0
  214. package/dist/knowledge/template-scanner.spec.d.ts +1 -0
  215. package/dist/knowledge/template-scanner.spec.js +1 -0
  216. package/dist/knowledge/tools-reference.js +1 -1
  217. package/dist/knowledge/treasury-ledger.d.ts +1 -1
  218. package/dist/knowledge/treasury-ledger.js +1 -1
  219. package/dist/knowledge/treasury-puzzle.d.ts +3 -3
  220. package/dist/knowledge/treasury-puzzle.js +1 -1
  221. package/dist/knowledge/treasury-risk.d.ts +4 -1
  222. package/dist/knowledge/treasury-risk.js +1 -1
  223. package/dist/knowledge/treasury-templates.js +1 -1
  224. package/dist/knowledge/util-risk.d.ts +6 -5
  225. package/dist/knowledge/util-risk.js +1 -1
  226. package/dist/knowledge/workflow-guidance.d.ts +4 -0
  227. package/dist/knowledge/workflow-guidance.js +1 -1
  228. package/dist/knowledge/workspace-lists.js +1 -1
  229. package/dist/monitor/MonitorLoop.js +1 -1
  230. package/dist/participation/arbitrator-interest.js +1 -1
  231. package/dist/participation/radar-core.js +1 -1
  232. package/dist/persona/analyzer.js +1 -1
  233. package/dist/persona/index.js +1 -1
  234. package/dist/persona/model.js +1 -1
  235. package/dist/persona/persona-audit.spec.d.ts +1 -0
  236. package/dist/persona/persona-audit.spec.js +1 -0
  237. package/dist/persona/types.d.ts +2 -0
  238. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  239. package/dist/playbooks/service-build/facet-money.d.ts +11 -0
  240. package/dist/playbooks/service-build/facet-money.js +1 -1
  241. package/dist/playbooks/service-build/machine-panorama.d.ts +17 -0
  242. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  243. package/dist/playbooks/service-build/merchant-guide.d.ts +2 -2
  244. package/dist/playbooks/service-build/migration-planner.d.ts +43 -0
  245. package/dist/playbooks/service-build/migration-planner.js +1 -0
  246. package/dist/playbooks/service-build/object-panorama.d.ts +42 -1
  247. package/dist/playbooks/service-build/object-panorama.js +1 -1
  248. package/dist/playbooks/service-build/participation-radar.js +1 -1
  249. package/dist/playbooks/service-build/pipeline-actions.d.ts +1 -1
  250. package/dist/playbooks/service-build/reverse-mapping.d.ts +1 -0
  251. package/dist/playbooks/service-build/reverse-mapping.js +1 -1
  252. package/dist/playbooks/service-build/risk-aggregator.d.ts +2 -1
  253. package/dist/playbooks/service-build/risk-aggregator.js +1 -1
  254. package/dist/playbooks/service-build/semantic-graph.js +1 -1
  255. package/dist/playbooks/service-build/service-panorama.d.ts +53 -1
  256. package/dist/playbooks/service-build/service-panorama.js +1 -1
  257. package/dist/playbooks/service-build/topology-evaluation.spec.js +1 -1
  258. package/dist/playbooks/service-build/topology-query.js +1 -1
  259. package/dist/playbooks/service-build/workflow-design-assessment.d.ts +2 -2
  260. package/dist/playbooks/service-build/workflow-design-assessment.js +1 -1
  261. package/dist/relationship/registry.js +1 -1
  262. package/dist/review/machine.js +1 -1
  263. package/dist/review/order.js +1 -1
  264. package/dist/review/service.js +1 -1
  265. package/dist/review/types.d.ts +7 -0
  266. package/dist/safety/confirm-gate.js +1 -1
  267. package/dist/schema/benchmark-migration/index.d.ts +207 -0
  268. package/dist/schema/benchmark-migration/index.js +1 -0
  269. package/dist/schema/call/allocation.d.ts +1 -1
  270. package/dist/schema/call/allocation.js +1 -1
  271. package/dist/schema/call/arbitration.d.ts +1 -1
  272. package/dist/schema/call/arbitration.js +1 -1
  273. package/dist/schema/call/base.d.ts +5 -5
  274. package/dist/schema/call/base.js +1 -1
  275. package/dist/schema/call/contact.d.ts +1 -1
  276. package/dist/schema/call/demand.d.ts +1 -1
  277. package/dist/schema/call/guard.d.ts +3 -3
  278. package/dist/schema/call/machine.d.ts +5 -5
  279. package/dist/schema/call/order.d.ts +3 -3
  280. package/dist/schema/call/payment.js +1 -1
  281. package/dist/schema/call/permission-handler.d.ts +1 -1
  282. package/dist/schema/call/permission-handler.js +1 -1
  283. package/dist/schema/call/permission.d.ts +16 -16
  284. package/dist/schema/call/permission.js +1 -1
  285. package/dist/schema/call/personal.d.ts +8 -8
  286. package/dist/schema/call/personal.js +1 -1
  287. package/dist/schema/call/progress.d.ts +3 -3
  288. package/dist/schema/call/repository.d.ts +11 -11
  289. package/dist/schema/call/repository.js +1 -1
  290. package/dist/schema/call/reward.d.ts +1 -1
  291. package/dist/schema/call/semantic.js +1 -1
  292. package/dist/schema/call/service.d.ts +7 -7
  293. package/dist/schema/call/service.js +1 -1
  294. package/dist/schema/call/treasury.d.ts +1 -1
  295. package/dist/schema/common/index.d.ts +6 -6
  296. package/dist/schema/common/index.js +1 -1
  297. package/dist/schema/config/index.d.ts +50 -1
  298. package/dist/schema/config/index.js +1 -1
  299. package/dist/schema/evaluation/index.d.ts +27 -11
  300. package/dist/schema/evaluation/index.js +1 -1
  301. package/dist/schema/goal/index.d.ts +5 -5
  302. package/dist/schema/goal/planning.d.ts +15 -15
  303. package/dist/schema/goal/planning.js +1 -1
  304. package/dist/schema/index.d.ts +1 -0
  305. package/dist/schema/index.js +1 -1
  306. package/dist/schema/interaction/index.d.ts +1 -1
  307. package/dist/schema/local/index.js +1 -1
  308. package/dist/schema/messenger/index.d.ts +26 -26
  309. package/dist/schema/operations.d.ts +33 -33
  310. package/dist/schema/operations.js +1 -1
  311. package/dist/schema/persona/index.d.ts +4708 -0
  312. package/dist/schema/persona/index.js +1 -1
  313. package/dist/schema/query/bi.d.ts +232 -25
  314. package/dist/schema/query/bi.js +1 -1
  315. package/dist/schema/query/index.d.ts +35 -35
  316. package/dist/schema/query/index.js +1 -1
  317. package/dist/schema/schema-version.js +1 -1
  318. package/dist/schema/workflow/index.d.ts +1 -1
  319. package/dist/schema-query-impl/index.d.ts +9 -0
  320. package/dist/schema-query-impl/index.js +1 -1
  321. package/dist/schemas/benchmark_migration_operation.output.json +793 -0
  322. package/dist/schemas/benchmark_migration_operation.schema.json +83 -0
  323. package/dist/schemas/bridge_operation.schema.json +5 -5
  324. package/dist/schemas/config_operation.output.json +252 -0
  325. package/dist/schemas/config_operation.schema.json +21 -1
  326. package/dist/schemas/evaluation_operation.output.json +22 -10
  327. package/dist/schemas/goal_operation.schema.json +8 -8
  328. package/dist/schemas/guard2file.schema.json +1 -1
  329. package/dist/schemas/index.json +7 -1
  330. package/dist/schemas/machineNode2file.schema.json +1 -1
  331. package/dist/schemas/messenger_operation.schema.json +24 -12
  332. package/dist/schemas/onchain_events.output.json +1 -1
  333. package/dist/schemas/onchain_operations.output.json +4 -2
  334. package/dist/schemas/onchain_operations.schema.json +189 -139
  335. package/dist/schemas/onchain_operations_allocation.schema.json +13 -11
  336. package/dist/schemas/onchain_operations_arbitration.schema.json +10 -8
  337. package/dist/schemas/onchain_operations_contact.schema.json +7 -5
  338. package/dist/schemas/onchain_operations_demand.schema.json +7 -5
  339. package/dist/schemas/onchain_operations_gen_passport.schema.json +5 -3
  340. package/dist/schemas/onchain_operations_gen_proof.schema.json +1 -1
  341. package/dist/schemas/onchain_operations_guard.schema.json +5 -3
  342. package/dist/schemas/onchain_operations_machine.schema.json +22 -18
  343. package/dist/schemas/onchain_operations_order.schema.json +11 -7
  344. package/dist/schemas/onchain_operations_payment.schema.json +3 -3
  345. package/dist/schemas/onchain_operations_permission.schema.json +19 -11
  346. package/dist/schemas/onchain_operations_personal.schema.json +16 -10
  347. package/dist/schemas/onchain_operations_progress.schema.json +11 -7
  348. package/dist/schemas/onchain_operations_proof.schema.json +5 -3
  349. package/dist/schemas/onchain_operations_repository.schema.json +12 -8
  350. package/dist/schemas/onchain_operations_reward.schema.json +11 -9
  351. package/dist/schemas/onchain_operations_service.schema.json +28 -22
  352. package/dist/schemas/onchain_operations_treasury.schema.json +11 -9
  353. package/dist/schemas/onchain_table_data.output.json +27 -17
  354. package/dist/schemas/persona_operation.output.json +15875 -1
  355. package/dist/schemas/persona_operation.schema.json +3056 -478
  356. package/dist/schemas/query_toolkit.output.json +343 -63
  357. package/dist/schemas/query_toolkit.schema.json +1 -1
  358. package/dist/schemas/workflow_operation.schema.json +4 -2
  359. package/dist/strategy/scorecard.js +1 -1
  360. package/dist/tools/handlers/benchmark-migration.d.ts +2 -0
  361. package/dist/tools/handlers/benchmark-migration.js +1 -0
  362. package/dist/tools/handlers/config.js +1 -1
  363. package/dist/tools/handlers/industry-pack.js +1 -1
  364. package/dist/tools/handlers/onchain.js +1 -1
  365. package/dist/tools/handlers/query.js +1 -1
  366. package/dist/tools/handlers/schema-query.js +1 -1
  367. package/dist/tools/index.js +1 -1
  368. package/dist/tools/move-fn-index.gen.d.ts +3 -0
  369. package/dist/tools/move-fn-index.gen.js +1 -0
  370. package/dist/tools/registry/business.js +1 -1
  371. package/dist/tools/registry/config.js +1 -1
  372. package/dist/tools/registry/evaluation.js +1 -1
  373. package/dist/tools/registry/onchain.js +1 -1
  374. package/dist/tools/sanitize-output.d.ts +3 -0
  375. package/dist/tools/sanitize-output.js +1 -0
  376. package/dist/tools/sanitize-output.spec.d.ts +1 -0
  377. package/dist/tools/sanitize-output.spec.js +1 -0
  378. package/package.json +9 -4
  379. package/dist/knowledge/baselines/evaluation-baselines.json +0 -79
@@ -1 +1 @@
1
- import{MAX_SHARING_COUNT,MAX_ALLOCATOR_COUNT}from'@wowok/wowok';export{MAX_ALLOCATOR_COUNT};export const ALLOCATION_MAX_SHARING_COUNT=MAX_SHARING_COUNT;export const ALLOCATION_MODE_AMOUNT=0x0;export const ALLOCATION_MODE_RATE=0x1;export const ALLOCATION_MODE_SURPLUS=0x2;export const RATE_TOTAL_FULL=0x2710;export const ALLOCATION_ERROR_CODES={'ERECIPIENT_IDENTIFIER_NOT_ADDRESS':0x1,'EALLOCATOR_COUNT_EXCEEDED':0x2,'ENO_ALLOCATOR':0x3,'ERATE_NOT_10000':0x4,'EMULTIPLE_SURPLUS':0x5,'ERATE_EXCEEDS_10000':0x6,'EINSUFFICIENT_BALANCE':0x7,'EALLOCATORS_EMPTY':0x8,'ENO_PAYMENT_INFO':0x9,'ESHARING_COUNT_EXCEEDED':0xa,'ESHARING_MODE_INVALID':0xb,'EAMOUNT_BELOW_THRESHOLD':0xc,'EAMOUNT_EXCEEDS_MAX':0xd,'EZERO_DISTRIBUTION':0xe,'ERECIPIENT_NOT_FOR_OBJECT':0xf};export const ORDER_ALLOCATION_ALREADY_SPECIFIED='E_ALLOCATION_ALREADY_SPECIFIED';export const ALLOCATION_SCENES=[{'id':'allocation_standard_three_way_split','name':'Standard\x20three-way\x20split\x20(merchant\x20/\x20platform\x20/\x20logistics)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'All\x20three\x20Treasury\x20objects\x20must\x20use\x20the\x20same\x20Coin<T>\x20type\x20as\x20the\x20Allocation','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20Treasury\x20address','Guard\x20verifies\x20order.service\x20binding\x20(query\x201563)\x20to\x20prevent\x20cross-project\x20bypass','Guard\x20verifies\x20progress.current_node\x20===\x20\x27Complete\x27'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','order_allocators\x20immutable\x20after\x20Service\x20publish\x20(R-A-10)'],'recommended_templates':['T-A-02']},{'id':'allocation_merchant_full_payment','name':'Merchant\x20full\x20payment\x20(single\x20recipient,\x20100%)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'Simplest\x20configuration\x20—\x20single\x20Treasury\x20or\x20personal\x20address','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'single_relaxed','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate\x20sharing\x20=\x2010000','Guard\x20only\x20verifies\x20order\x20status\x20(no\x20complex\x20conditions)','who=Entity\x20can\x20be\x20either\x20Treasury\x20or\x20personal\x20wallet'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['Simplest\x20allocation\x20configuration','No\x20multi-party\x20coordination\x20required'],'recommended_templates':['T-A-01']},{'id':'allocation_refund_first_surplus_to_merchant','name':'Refund\x20first\x20+\x20surplus\x20to\x20merchant\x20(Amount\x20+\x20Surplus\x20hybrid)','trigger_source':'service_order_allocators','distribution_strategy':'amount_plus_surplus','coin_type_note':'Refund\x20amount\x20must\x20match\x20Coin<T>\x20precision','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Surplus'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x202\x20sharing\x20items','sharing[0]:\x20Amount=refund_value,\x20who=Entity(customer_address)','sharing[1]:\x20Surplus,\x20who=Entity(merchant_treasury)','fix\x20=\x20refund_value\x20(cached\x20Amount\x20sum)','threshold\x20=\x20refund_value\x20(ensure\x20sufficient\x20balance\x20for\x20Amount)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator','F-A-07:\x20fix\x20>=\x20threshold\x20(Amount\x20sum\x20must\x20cover\x20threshold)','fix\x20must\x20precisely\x20match\x20the\x20refund\x20amount'],'recommended_templates':['T-A-03']},{'id':'allocation_treasury_personal_alternatives','name':'Treasury\x20+\x20Personal\x20alternative\x20strategies\x20(caller-specified\x20guard)','trigger_source':'service_order_allocators','distribution_strategy':'first_match_alternatives','coin_type_note':'Both\x20target\x20addresses\x20must\x20accept\x20the\x20same\x20Coin<T>','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators,\x20each\x20with\x201\x20Rate=10000\x20sharing','Allocator[0]:\x20guard=guard_treasury,\x20who=Entity(treasury_address)','Allocator[1]:\x20guard=guard_personal,\x20who=Entity(personal_address)','Two\x20Guard\x20objects\x20must\x20be\x20different\x20addresses\x20(R-A-11)','caller-specified\x20guard:\x20caller\x20selects\x20Treasury\x20or\x20Personal\x20path\x20via\x20alloc_by_guard;\x20passport::result_for_guard\x20hard-validates\x20(failure\x20aborts\x20with\x20E_VERIFY_FAILED;\x20caller\x20must\x20switch\x20guard\x20and\x20retry)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-14:\x20allocators[].guard\x20must\x20be\x20unique','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','Guard\x20A\x20and\x20Guard\x20B\x20may\x20share\x20root/table\x20but\x20must\x20differ\x20in\x20description'],'recommended_templates':['T-A-04']},{'id':'allocation_tiered_by_order_amount','name':'Tiered\x20split\x20by\x20order\x20amount\x20(multi-Allocator\x20amount-threshold\x20switch)','trigger_source':'service_order_allocators','distribution_strategy':'tiered_by_amount','coin_type_note':'Amount\x20threshold\x20uses\x20Coin<T>\x20smallest\x20unit\x20(e.g.\x20MIST\x20for\x20WOW)','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators\x20triggered\x20by\x20mutually\x20exclusive\x20Guard\x20conditions','Allocator[0]:\x20guard\x20verifies\x20order.amount\x20<\x20threshold,\x20Rate=10000\x20to\x20merchant','Allocator[1]:\x20guard\x20verifies\x20order.amount\x20>=\x20threshold,\x20Rate=8000/2000\x20split','caller-specified\x20guard:\x20caller\x20selects\x20the\x20matching\x20Allocator\x20based\x20on\x20order\x20amount;\x20allocator\x20order\x20is\x20irrelevant','Guard\x20queries\x20order.amount\x20(query\x201561)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20(R-A-4-02\x20design\x20clarity)','Caller\x20must\x20select\x20correct\x20guard\x20based\x20on\x20order.amount\x20(no\x20auto-fallback)'],'recommended_templates':['T-A-05']},{'id':'allocation_dynamic_recipient','name':'Multi-role\x20split\x20with\x20dynamic\x20recipient\x20(GuardIdentifier)','trigger_source':'service_order_allocators','distribution_strategy':'dynamic_recipient','coin_type_note':'Passport\x20table\x20must\x20contain\x20address-typed\x20entry\x20at\x20the\x20referenced\x20identifier','typical_allocator_count':0x1,'sharing_who_types':['Entity','GuardIdentifier'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items','sharing[0]:\x20Rate=8000,\x20who=Entity(merchant_treasury)','sharing[1]:\x20Rate=1000,\x20who=Entity(platform_treasury)','sharing[2]:\x20Rate=1000,\x20who=GuardIdentifier(0)\x20—\x20resolves\x20from\x20Passport\x20table','Customer\x20submits\x20Passport\x20with\x20referrer\x20address\x20at\x20identifier=0'],'dependencies':['Service','Treasury','Guard','Passport','Order','Payment'],'key_constraints':['F-A-13:\x20Passport\x20table[identifier]\x20must\x20be\x20address\x20type\x20(else\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS)','Guard\x20must\x20verify\x20Passport\x20completeness','Customer\x20order\x20must\x20include\x20Passport\x20with\x20referrer\x20address'],'recommended_templates':['T-A-06']},{'id':'allocation_arbitration_fees','name':'Arbitration\x20fees\x20split\x20(arbitrator\x20/\x20platform)','trigger_source':'arbitration_fees','distribution_strategy':'pure_rate','coin_type_note':'Coin<T>\x20must\x20match\x20Arbitration\x27s\x20fee\x20Coin\x20type','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Triggered\x20by\x20Arbitration.fees_alloc\x20(permission\x20365)\x20or\x20fees_alloc_with_passport','Single\x20Allocator,\x202\x20Rate\x20sharing\x20items:\x208000\x20arbitrator\x20/\x202000\x20platform','payment_info\x20reuses\x20Arbitration\x27s\x20payment_info','Caller\x20must\x20hold\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'dependencies':['Arbitration','Treasury','Guard','Payment'],'key_constraints':['Independent\x20from\x20Service-order\x20Allocation','Requires\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'recommended_templates':['T-A-08']},{'id':'allocation_refund_to_order','name':'Refund\x20Allocator\x20(100%\x20to\x20Order\x20object)','trigger_source':'service_order_allocators','distribution_strategy':'refund_to_order','coin_type_note':'who=Entity\x20must\x20be\x20the\x20Order\x20object\x20address\x20(NOT\x20a\x20personal\x20wallet)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate=10000\x20sharing','who=Entity(order_address)\x20—\x20funds\x20flow\x20back\x20to\x20Order,\x20not\x20personal\x20wallet','Guard\x20verifies\x20customer\x20refund\x20request\x20and\x20eligibility','Customer-side\x20risk\x20assessment\x20adds\x208-point\x20weight\x20(onchain_topology\x20graph\x20evaluation)'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['who=Entity\x20MUST\x20be\x20Order\x20object\x20address\x20(not\x20personal\x20address)','Customer\x20due-diligence\x20rewards\x20this\x20configuration\x20(8-point\x20weight)','Refund\x20funds\x20return\x20to\x20Order\x20for\x20downstream\x20handling'],'recommended_templates':['T-A-07']},{'id':'allocation_max_capped_retain','name':'Max-capped\x20allocation\x20(retain\x20residual\x20balance)','trigger_source':'service_order_allocators','distribution_strategy':'max_capped','coin_type_note':'max\x20field\x20uses\x20Coin<T>\x20smallest\x20unit','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['Single\x20Allocator\x20with\x20max\x20field\x20set','max\x20triple\x20role:\x20Amount\x20cap\x20+\x20Rate\x20base\x20+\x20Surplus\x20cap','Amount\x20sharing\x20consumes\x20fix;\x20Rate\x20sharing\x20uses\x20(max\x20-\x20fix)\x20as\x20base','Residual\x20balance\x20remains\x20in\x20Allocation\x20for\x20subsequent\x20alloc()\x20calls'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','max\x20-\x20fix\x20becomes\x20Rate\x20base\x20(NOT\x20balance\x20-\x20fix)','Residual\x20balance\x20may\x20be\x20claimed\x20by\x20re-triggering\x20alloc()'],'recommended_templates':[]},{'id':'allocation_multi_node_trigger','name':'Multi-Machine-node\x20triggered\x20allocation\x20(Complete\x20/\x20Refund\x20/\x20Lost)','trigger_source':'service_order_allocators','distribution_strategy':'multi_node_trigger','coin_type_note':'All\x20Allocators\x20share\x20the\x20same\x20Allocation\x27s\x20Coin<T>','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['3\x20Allocators\x20mapped\x20to\x20Machine\x20terminal\x20nodes\x20(Complete/Refund/Lost)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20progress.current_node\x20==\x20<node_name>','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20terminal\x20node\x20active\x20at\x20a\x20time)','Machine.required_allocators[]\x20describes\x20each\x20trigger_node\x20mapping'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive','Sequence-sensitive:\x20business-flow\x20order','Machine.required_allocators[trigger_node]\x20must\x20map\x20to\x20Allocator\x20indices'],'recommended_templates':[]},{'id':'allocation_standalone_periodic_split','name':'Standalone\x20periodic\x20split\x20(investment\x20dividends\x20/\x20shared\x20income)','trigger_source':'standalone','distribution_strategy':'periodic_split','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20asset\x20being\x20distributed\x20(e.g.\x20profit\x20token)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x20N\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20beneficiary\x20wallet\x20(not\x20Treasury)','Guard\x20verifies\x20time-based\x20trigger\x20(e.g.\x20context(Clock).timestamp\x20>=\x20next_release)\x20or\x20signer\x20authorization','User\x20calls\x20receive()\x20to\x20deposit\x20funds,\x20then\x20alloc()\x20to\x20trigger\x20distribution','No\x20Service/Order/Progress/Machine\x20context\x20required'],'dependencies':['Treasury','Guard','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20+\x20Passport\x20MUST\x20be\x20sufficient','Caller\x20is\x20fully\x20responsible\x20for\x20receive\x20→\x20alloc\x20lifecycle\x20(no\x20auto-trigger)','Guard\x20should\x20bind\x20Signer\x20to\x20prevent\x20unauthorized\x20alloc()\x20calls'],'recommended_templates':['T-A-09']},{'id':'allocation_standalone_vesting','name':'Standalone\x20vesting\x20release\x20(time-locked\x20multi-stage\x20unlock)','trigger_source':'standalone','distribution_strategy':'time_locked_vesting','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20vested\x20asset\x20(e.g.\x20locked\x20team\x20tokens)','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate','Surplus'],'guard_requirement':'multiple_unique','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['N\x20Allocators,\x20each\x20mapped\x20to\x20a\x20vesting\x20stage\x20(e.g.\x2025%\x20at\x20month\x2012,\x2025%\x20at\x20month\x2024,\x2050%\x20surplus\x20at\x20month\x2036)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20context(Clock).timestamp\x20>=\x20stage_unlock_time','Amount\x20sharing\x20per\x20stage\x20with\x20max\x20field\x20capping\x20the\x20cumulative\x20release','Final\x20Allocator\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance\x20after\x20last\x20vesting\x20stage','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20stage\x20active\x20at\x20a\x20time,\x20based\x20on\x20timestamp)','User\x20calls\x20receive()\x20to\x20deposit\x20locked\x20tokens,\x20then\x20alloc()\x20at\x20each\x20vesting\x20milestone'],'dependencies':['Treasury','Guard','Passport','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(final\x20stage\x20uses\x20Surplus\x20to\x20drain\x20remainder)','F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20time-lock\x20MUST\x20be\x20enforced','Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20by\x20timestamp\x20(R-A-4-02)','Caller\x20must\x20wait\x20for\x20time-lock\x20expiry\x20before\x20alloc()\x20succeeds;\x20otherwise\x20alloc()\x20silently\x20returns\x20(R-A-4-01)'],'recommended_templates':['T-A-10']}];export const ALLOCATION_LEDGER_VERSION='1.0.0';export function getScenesByTriggerSource(a){return ALLOCATION_SCENES['filter'](b=>b['trigger_source']===a);}export function getScenesByMode(a){return ALLOCATION_SCENES['filter'](b=>b['modes_used']['includes'](a));}export function getScenesByStrategy(a){return ALLOCATION_SCENES['filter'](b=>b['distribution_strategy']===a);}export function findSceneById(a){return ALLOCATION_SCENES['find'](b=>b['id']===a);}export function inferSceneFromIntent(a){const b=a['toLowerCase']();if(b['includes']('arbitration')||b['includes']('fees_alloc'))return findSceneById('allocation_arbitration_fees');if(b['includes']('standalone')||b['includes']('periodic\x20split')||b['includes']('investment\x20dividend')||b['includes']('shared\x20income')||b['includes']('dividend'))return findSceneById('allocation_standalone_periodic_split');if(b['includes']('vesting')||b['includes']('time-lock')||b['includes']('unlock\x20period')||b['includes']('locked\x20release')||b['includes']('token\x20unlock'))return findSceneById('allocation_standalone_vesting');if(b['includes']('refund')){if(b['includes']('order')||b['includes']('100%'))return findSceneById('allocation_refund_to_order');if(b['includes']('surplus')||b['includes']('merchant'))return findSceneById('allocation_refund_first_surplus_to_merchant');}if(b['includes']('alternative')||b['includes']('priority')||b['includes']('treasury')&&b['includes']('personal'))return findSceneById('allocation_treasury_personal_alternatives');if(b['includes']('tiered')||b['includes']('threshold\x20switch'))return findSceneById('allocation_tiered_by_order_amount');if(b['includes']('dynamic\x20recipient')||b['includes']('referrer')||b['includes']('guardidentifier'))return findSceneById('allocation_dynamic_recipient');if(b['includes']('retain')||b['includes']('max'))return findSceneById('allocation_max_capped_retain');if(b['includes']('multi-node')||b['includes']('multi\x20machine')||b['includes']('multi_node'))return findSceneById('allocation_multi_node_trigger');const c=(a['match'](/%/g)||[])['length'];if(c<=0x1)return findSceneById('allocation_merchant_full_payment');if(c>=0x2)return findSceneById('allocation_standard_three_way_split');return undefined;}export function getAllScenes(){return[...ALLOCATION_SCENES];}export function getScenesCount(){return ALLOCATION_SCENES['length'];}export function allocationModeToNumber(a){switch(a){case'Amount':return ALLOCATION_MODE_AMOUNT;case'Rate':return ALLOCATION_MODE_RATE;case'Surplus':return ALLOCATION_MODE_SURPLUS;}}export function allocationModeFromNumber(a){switch(a){case ALLOCATION_MODE_AMOUNT:return'Amount';case ALLOCATION_MODE_RATE:return'Rate';case ALLOCATION_MODE_SURPLUS:return'Surplus';default:throw new Error('Invalid\x20AllocationMode\x20number:\x20'+a);}}export function getRecipientType(a){if('GuardIdentifier'in a)return'GuardIdentifier';if('Entity'in a)return'Entity';return'Signer';}export function isSignerRecipient(a){return'Signer'in a;}export function isEntityRecipient(a){return'Entity'in a;}export function isGuardIdentifierRecipient(a){return'GuardIdentifier'in a;}export function getErrorName(a){for(const [b,d]of Object['entries'](ALLOCATION_ERROR_CODES)){if(d===a)return b;}return undefined;}export function getErrorDescription(a){const b={0x1:'GuardIdentifier\x20resolved\x20value\x20is\x20not\x20an\x20address\x20type',0x2:'Allocator\x20count\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20(100)',0x3:'No\x20Allocator\x20in\x20the\x20allocators\x20vector',0x4:'Pure\x20Rate\x20mode\x20sum\x20!=\x2010000\x20(no\x20Surplus\x20to\x20absorb\x20remainder)',0x5:'Multiple\x20Surplus\x20sharing\x20in\x20a\x20single\x20Allocator',0x6:'Rate\x20+\x20Surplus\x20sum\x20>\x2010000',0x7:'balance\x20<\x20threshold\x20(insufficient\x20balance\x20to\x20trigger\x20alloc)',0x8:'allocators.allocators\x20is\x20empty',0x9:'payment_info\x20is\x20None\x20when\x20alloc()\x20is\x20called',0xa:'sharing\x20count\x20exceeds\x20MAX_SHARING_COUNT\x20(100)',0xb:'sharing\x20mode\x20is\x20not\x200\x20(Amount)\x20/\x201\x20(Rate)\x20/\x202\x20(Surplus)',0xc:'Amount\x20sum\x20(fix)\x20<\x20threshold',0xd:'Amount\x20sum\x20(fix)\x20>\x20max',0xe:'distribution\x20computes\x20to\x20zero\x20while\x20the\x20pool\x20still\x20holds\x20funds\x20(or\x20balance\x20is\x200)',0xf:'GuardIdentifier\x20recipient\x20address\x20!=\x20payment_info.for_object\x20anchor\x20(abort\x20fires\x20only\x20when\x20a\x20for_object\x20binding\x20is\x20declared)'};return b[a];}
1
+ import{MAX_SHARING_COUNT,MAX_ALLOCATOR_COUNT}from'@wowok/wowok';export{MAX_ALLOCATOR_COUNT};export const ALLOCATION_MAX_SHARING_COUNT=MAX_SHARING_COUNT;export const ALLOCATION_MODE_AMOUNT=0x0;export const ALLOCATION_MODE_RATE=0x1;export const ALLOCATION_MODE_SURPLUS=0x2;export const RATE_TOTAL_FULL=0x2710;export const ALLOCATION_ERROR_CODES={'ERECIPIENT_IDENTIFIER_NOT_ADDRESS':0x1,'EALLOCATOR_COUNT_EXCEEDED':0x2,'ENO_ALLOCATOR':0x3,'ERATE_NOT_10000':0x4,'EMULTIPLE_SURPLUS':0x5,'ERATE_EXCEEDS_10000':0x6,'EINSUFFICIENT_BALANCE':0x7,'EALLOCATORS_EMPTY':0x8,'ENO_PAYMENT_INFO':0x9,'ESHARING_COUNT_EXCEEDED':0xa,'ESHARING_MODE_INVALID':0xb,'EAMOUNT_BELOW_THRESHOLD':0xc,'EAMOUNT_EXCEEDS_MAX':0xd,'EZERO_DISTRIBUTION':0xe,'ERECIPIENT_NOT_FOR_OBJECT':0xf};export const ORDER_ALLOCATION_ALREADY_SPECIFIED='E_ALLOCATION_ALREADY_SPECIFIED';export const ALLOCATION_SCENES=[{'id':'allocation_standard_three_way_split','name':'Standard\x20three-way\x20split\x20(merchant\x20/\x20platform\x20/\x20logistics)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'All\x20three\x20Treasury\x20objects\x20must\x20use\x20the\x20same\x20Coin<T>\x20type\x20as\x20the\x20Allocation','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20Treasury\x20address','Guard\x20verifies\x20order.service\x20binding\x20(query\x201563)\x20to\x20prevent\x20cross-project\x20bypass','Guard\x20verifies\x20progress.current_node\x20===\x20\x27Complete\x27'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','order_allocators\x20immutable\x20after\x20Service\x20publish\x20(R-A-10)'],'recommended_templates':['T-A-02']},{'id':'allocation_merchant_full_payment','name':'Merchant\x20full\x20payment\x20(single\x20recipient,\x20100%)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'Simplest\x20configuration\x20—\x20single\x20Treasury\x20or\x20personal\x20address','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'single_relaxed','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate\x20sharing\x20=\x2010000','Guard\x20only\x20verifies\x20order\x20status\x20(no\x20complex\x20conditions)','who=Entity\x20can\x20be\x20either\x20Treasury\x20or\x20personal\x20wallet'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['Simplest\x20allocation\x20configuration','No\x20multi-party\x20coordination\x20required'],'recommended_templates':['T-A-01']},{'id':'allocation_refund_first_surplus_to_merchant','name':'Refund\x20first\x20+\x20surplus\x20to\x20merchant\x20(Amount\x20+\x20Surplus\x20hybrid)','trigger_source':'service_order_allocators','distribution_strategy':'amount_plus_surplus','coin_type_note':'Refund\x20amount\x20must\x20match\x20Coin<T>\x20precision','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Surplus'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x202\x20sharing\x20items','sharing[0]:\x20Amount=refund_value,\x20who=Entity(customer_address)','sharing[1]:\x20Surplus,\x20who=Entity(merchant_treasury)','fix\x20=\x20refund_value\x20(cached\x20Amount\x20sum)','threshold\x20=\x20refund_value\x20(ensure\x20sufficient\x20balance\x20for\x20Amount)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator','F-A-07:\x20fix\x20>=\x20threshold\x20(Amount\x20sum\x20must\x20cover\x20threshold)','fix\x20must\x20precisely\x20match\x20the\x20refund\x20amount'],'recommended_templates':['T-A-03']},{'id':'allocation_treasury_personal_alternatives','name':'Treasury\x20+\x20Personal\x20alternative\x20strategies\x20(caller-specified\x20guard)','trigger_source':'service_order_allocators','distribution_strategy':'first_match_alternatives','coin_type_note':'Both\x20target\x20addresses\x20must\x20accept\x20the\x20same\x20Coin<T>','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators,\x20each\x20with\x201\x20Rate=10000\x20sharing','Allocator[0]:\x20guard=guard_treasury,\x20who=Entity(treasury_address)','Allocator[1]:\x20guard=guard_personal,\x20who=Entity(personal_address)','Two\x20Guard\x20objects\x20must\x20be\x20different\x20addresses\x20(R-A-11)','caller-specified\x20guard:\x20caller\x20selects\x20Treasury\x20or\x20Personal\x20path\x20via\x20alloc_by_guard;\x20the\x20Passport\x20hard-verifies\x20the\x20selected\x20Guard\x20(failure\x20aborts\x20with\x20E_VERIFY_FAILED;\x20caller\x20must\x20switch\x20guard\x20and\x20retry)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-14:\x20allocators[].guard\x20must\x20be\x20unique','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','Guard\x20A\x20and\x20Guard\x20B\x20may\x20share\x20root/table\x20but\x20must\x20differ\x20in\x20description'],'recommended_templates':['T-A-04']},{'id':'allocation_tiered_by_order_amount','name':'Tiered\x20split\x20by\x20order\x20amount\x20(multi-Allocator\x20amount-threshold\x20switch)','trigger_source':'service_order_allocators','distribution_strategy':'tiered_by_amount','coin_type_note':'Amount\x20threshold\x20uses\x20Coin<T>\x20smallest\x20unit\x20(e.g.\x20MIST\x20for\x20WOW)','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators\x20triggered\x20by\x20mutually\x20exclusive\x20Guard\x20conditions','Allocator[0]:\x20guard\x20verifies\x20order.amount\x20<\x20threshold,\x20Rate=10000\x20to\x20merchant','Allocator[1]:\x20guard\x20verifies\x20order.amount\x20>=\x20threshold,\x20Rate=8000/2000\x20split','caller-specified\x20guard:\x20caller\x20selects\x20the\x20matching\x20Allocator\x20based\x20on\x20order\x20amount;\x20allocator\x20order\x20is\x20irrelevant','Guard\x20queries\x20order.amount\x20(query\x201561)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20(R-A-4-02\x20design\x20clarity)','Caller\x20must\x20select\x20correct\x20guard\x20based\x20on\x20order.amount\x20(no\x20auto-fallback)'],'recommended_templates':['T-A-05']},{'id':'allocation_dynamic_recipient','name':'Multi-role\x20split\x20with\x20dynamic\x20recipient\x20(GuardIdentifier)','trigger_source':'service_order_allocators','distribution_strategy':'dynamic_recipient','coin_type_note':'Passport\x20table\x20must\x20contain\x20address-typed\x20entry\x20at\x20the\x20referenced\x20identifier','typical_allocator_count':0x1,'sharing_who_types':['Entity','GuardIdentifier'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items','sharing[0]:\x20Rate=8000,\x20who=Entity(merchant_treasury)','sharing[1]:\x20Rate=1000,\x20who=Entity(platform_treasury)','sharing[2]:\x20Rate=1000,\x20who=GuardIdentifier(0)\x20—\x20resolves\x20from\x20Passport\x20table','Customer\x20submits\x20Passport\x20with\x20referrer\x20address\x20at\x20identifier=0'],'dependencies':['Service','Treasury','Guard','Passport','Order','Payment'],'key_constraints':['F-A-13:\x20Passport\x20table[identifier]\x20must\x20be\x20address\x20type\x20(else\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS)','Guard\x20must\x20verify\x20Passport\x20completeness','Customer\x20order\x20must\x20include\x20Passport\x20with\x20referrer\x20address'],'recommended_templates':['T-A-06']},{'id':'allocation_arbitration_fees','name':'Arbitration\x20fees\x20split\x20(arbitrator\x20/\x20platform)','trigger_source':'arbitration_fees','distribution_strategy':'pure_rate','coin_type_note':'Coin<T>\x20must\x20match\x20Arbitration\x27s\x20fee\x20Coin\x20type','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Triggered\x20by\x20the\x20Arbitration\x20fee-allocation\x20operation\x20(permission\x20365),\x20direct\x20or\x20Passport\x20path','Single\x20Allocator,\x202\x20Rate\x20sharing\x20items:\x208000\x20arbitrator\x20/\x202000\x20platform','payment_info\x20reuses\x20Arbitration\x27s\x20payment_info','Caller\x20must\x20hold\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'dependencies':['Arbitration','Treasury','Guard','Payment'],'key_constraints':['Independent\x20from\x20Service-order\x20Allocation','Requires\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'recommended_templates':['T-A-08']},{'id':'allocation_refund_to_order','name':'Refund\x20Allocator\x20(100%\x20to\x20Order\x20object)','trigger_source':'service_order_allocators','distribution_strategy':'refund_to_order','coin_type_note':'who=Entity\x20must\x20be\x20the\x20Order\x20object\x20address\x20(NOT\x20a\x20personal\x20wallet)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate=10000\x20sharing','who=Entity(order_address)\x20—\x20funds\x20flow\x20back\x20to\x20Order,\x20not\x20personal\x20wallet','Guard\x20verifies\x20customer\x20refund\x20request\x20and\x20eligibility','Customer-side\x20risk\x20assessment\x20adds\x208-point\x20weight\x20(onchain_topology\x20graph\x20evaluation)'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['who=Entity\x20MUST\x20be\x20Order\x20object\x20address\x20(not\x20personal\x20address)','Customer\x20due-diligence\x20rewards\x20this\x20configuration\x20(8-point\x20weight)','Refund\x20funds\x20return\x20to\x20Order\x20for\x20downstream\x20handling'],'recommended_templates':['T-A-07']},{'id':'allocation_max_capped_retain','name':'Max-capped\x20allocation\x20(retain\x20residual\x20balance)','trigger_source':'service_order_allocators','distribution_strategy':'max_capped','coin_type_note':'max\x20field\x20uses\x20Coin<T>\x20smallest\x20unit','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['Single\x20Allocator\x20with\x20max\x20field\x20set','max\x20triple\x20role:\x20Amount\x20cap\x20+\x20Rate\x20base\x20+\x20Surplus\x20cap','Amount\x20sharing\x20consumes\x20fix;\x20Rate\x20sharing\x20uses\x20(max\x20-\x20fix)\x20as\x20base','Residual\x20balance\x20remains\x20in\x20Allocation\x20for\x20subsequent\x20alloc()\x20calls'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','max\x20-\x20fix\x20becomes\x20Rate\x20base\x20(NOT\x20balance\x20-\x20fix)','Residual\x20balance\x20may\x20be\x20claimed\x20by\x20re-triggering\x20alloc()'],'recommended_templates':[]},{'id':'allocation_multi_node_trigger','name':'Multi-Machine-node\x20triggered\x20allocation\x20(Complete\x20/\x20Refund\x20/\x20Lost)','trigger_source':'service_order_allocators','distribution_strategy':'multi_node_trigger','coin_type_note':'All\x20Allocators\x20share\x20the\x20same\x20Allocation\x27s\x20Coin<T>','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['3\x20Allocators\x20mapped\x20to\x20Machine\x20terminal\x20nodes\x20(Complete/Refund/Lost)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20progress.current_node\x20==\x20<node_name>','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20terminal\x20node\x20active\x20at\x20a\x20time)','Machine.required_allocators[]\x20describes\x20each\x20trigger_node\x20mapping'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive','Sequence-sensitive:\x20business-flow\x20order','Machine.required_allocators[trigger_node]\x20must\x20map\x20to\x20Allocator\x20indices'],'recommended_templates':[]},{'id':'allocation_standalone_periodic_split','name':'Standalone\x20periodic\x20split\x20(investment\x20dividends\x20/\x20shared\x20income)','trigger_source':'standalone','distribution_strategy':'periodic_split','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20asset\x20being\x20distributed\x20(e.g.\x20profit\x20token)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x20N\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20beneficiary\x20wallet\x20(not\x20Treasury)','Guard\x20verifies\x20time-based\x20trigger\x20(e.g.\x20context(Clock).timestamp\x20>=\x20next_release)\x20or\x20signer\x20authorization','User\x20calls\x20receive()\x20to\x20deposit\x20funds,\x20then\x20alloc()\x20to\x20trigger\x20distribution','No\x20Service/Order/Progress/Machine\x20context\x20required'],'dependencies':['Treasury','Guard','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20+\x20Passport\x20MUST\x20be\x20sufficient','Caller\x20is\x20fully\x20responsible\x20for\x20receive\x20→\x20alloc\x20lifecycle\x20(no\x20auto-trigger)','Guard\x20should\x20bind\x20Signer\x20to\x20prevent\x20unauthorized\x20alloc()\x20calls'],'recommended_templates':['T-A-09']},{'id':'allocation_standalone_vesting','name':'Standalone\x20vesting\x20release\x20(time-locked\x20multi-stage\x20unlock)','trigger_source':'standalone','distribution_strategy':'time_locked_vesting','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20vested\x20asset\x20(e.g.\x20locked\x20team\x20tokens)','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate','Surplus'],'guard_requirement':'multiple_unique','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['N\x20Allocators,\x20each\x20mapped\x20to\x20a\x20vesting\x20stage\x20(e.g.\x2025%\x20at\x20month\x2012,\x2025%\x20at\x20month\x2024,\x2050%\x20surplus\x20at\x20month\x2036)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20context(Clock).timestamp\x20>=\x20stage_unlock_time','Amount\x20sharing\x20per\x20stage\x20with\x20max\x20field\x20capping\x20the\x20cumulative\x20release','Final\x20Allocator\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance\x20after\x20last\x20vesting\x20stage','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20stage\x20active\x20at\x20a\x20time,\x20based\x20on\x20timestamp)','User\x20calls\x20receive()\x20to\x20deposit\x20locked\x20tokens,\x20then\x20alloc()\x20at\x20each\x20vesting\x20milestone'],'dependencies':['Treasury','Guard','Passport','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(final\x20stage\x20uses\x20Surplus\x20to\x20drain\x20remainder)','F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20time-lock\x20MUST\x20be\x20enforced','Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20by\x20timestamp\x20(R-A-4-02)','Caller\x20must\x20wait\x20for\x20time-lock\x20expiry\x20before\x20alloc()\x20succeeds;\x20otherwise\x20alloc()\x20silently\x20returns\x20(R-A-4-01)'],'recommended_templates':['T-A-10']}];export const ALLOCATION_LEDGER_VERSION='1.0.0';export function getScenesByTriggerSource(a){return ALLOCATION_SCENES['filter'](b=>b['trigger_source']===a);}export function getScenesByMode(a){return ALLOCATION_SCENES['filter'](b=>b['modes_used']['includes'](a));}export function getScenesByStrategy(a){return ALLOCATION_SCENES['filter'](b=>b['distribution_strategy']===a);}export function findSceneById(a){return ALLOCATION_SCENES['find'](b=>b['id']===a);}export function inferSceneFromIntent(a){const b=a['toLowerCase']();if(b['includes']('arbitration')||b['includes']('fees\x20alloc'))return findSceneById('allocation_arbitration_fees');if(b['includes']('standalone')||b['includes']('periodic\x20split')||b['includes']('investment\x20dividend')||b['includes']('shared\x20income')||b['includes']('dividend'))return findSceneById('allocation_standalone_periodic_split');if(b['includes']('vesting')||b['includes']('time-lock')||b['includes']('unlock\x20period')||b['includes']('locked\x20release')||b['includes']('token\x20unlock'))return findSceneById('allocation_standalone_vesting');if(b['includes']('refund')){if(b['includes']('order')||b['includes']('100%'))return findSceneById('allocation_refund_to_order');if(b['includes']('surplus')||b['includes']('merchant'))return findSceneById('allocation_refund_first_surplus_to_merchant');}if(b['includes']('alternative')||b['includes']('priority')||b['includes']('treasury')&&b['includes']('personal'))return findSceneById('allocation_treasury_personal_alternatives');if(b['includes']('tiered')||b['includes']('threshold\x20switch'))return findSceneById('allocation_tiered_by_order_amount');if(b['includes']('dynamic\x20recipient')||b['includes']('referrer')||b['includes']('guardidentifier'))return findSceneById('allocation_dynamic_recipient');if(b['includes']('retain')||b['includes']('max'))return findSceneById('allocation_max_capped_retain');if(b['includes']('multi-node')||b['includes']('multi\x20machine')||b['includes']('multi_node'))return findSceneById('allocation_multi_node_trigger');const c=(a['match'](/%/g)||[])['length'];if(c<=0x1)return findSceneById('allocation_merchant_full_payment');if(c>=0x2)return findSceneById('allocation_standard_three_way_split');return undefined;}export function getAllScenes(){return[...ALLOCATION_SCENES];}export function getScenesCount(){return ALLOCATION_SCENES['length'];}export function allocationModeToNumber(a){switch(a){case'Amount':return ALLOCATION_MODE_AMOUNT;case'Rate':return ALLOCATION_MODE_RATE;case'Surplus':return ALLOCATION_MODE_SURPLUS;}}export function allocationModeFromNumber(a){switch(a){case ALLOCATION_MODE_AMOUNT:return'Amount';case ALLOCATION_MODE_RATE:return'Rate';case ALLOCATION_MODE_SURPLUS:return'Surplus';default:throw new Error('Invalid\x20AllocationMode\x20number:\x20'+a);}}export function getRecipientType(a){if('GuardIdentifier'in a)return'GuardIdentifier';if('Entity'in a)return'Entity';return'Signer';}export function isSignerRecipient(a){return'Signer'in a;}export function isEntityRecipient(a){return'Entity'in a;}export function isGuardIdentifierRecipient(a){return'GuardIdentifier'in a;}export function getErrorName(a){for(const [b,d]of Object['entries'](ALLOCATION_ERROR_CODES)){if(d===a)return b;}return undefined;}export function getErrorDescription(a){const b={0x1:'GuardIdentifier\x20resolved\x20value\x20is\x20not\x20an\x20address\x20type',0x2:'Allocator\x20count\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20(100)',0x3:'No\x20Allocator\x20in\x20the\x20allocators\x20vector',0x4:'Pure\x20Rate\x20mode\x20sum\x20!=\x2010000\x20(no\x20Surplus\x20to\x20absorb\x20remainder)',0x5:'Multiple\x20Surplus\x20sharing\x20in\x20a\x20single\x20Allocator',0x6:'Rate\x20+\x20Surplus\x20sum\x20>\x2010000',0x7:'balance\x20<\x20threshold\x20(insufficient\x20balance\x20to\x20trigger\x20alloc)',0x8:'allocators.allocators\x20is\x20empty',0x9:'payment_info\x20is\x20None\x20when\x20alloc()\x20is\x20called',0xa:'sharing\x20count\x20exceeds\x20MAX_SHARING_COUNT\x20(100)',0xb:'sharing\x20mode\x20is\x20not\x200\x20(Amount)\x20/\x201\x20(Rate)\x20/\x202\x20(Surplus)',0xc:'Amount\x20sum\x20(fix)\x20<\x20threshold',0xd:'Amount\x20sum\x20(fix)\x20>\x20max',0xe:'distribution\x20computes\x20to\x20zero\x20while\x20the\x20pool\x20still\x20holds\x20funds\x20(or\x20balance\x20is\x200)',0xf:'GuardIdentifier\x20recipient\x20address\x20!=\x20payment_info.for_object\x20anchor\x20(abort\x20fires\x20only\x20when\x20a\x20for_object\x20binding\x20is\x20declared)'};return b[a];}
@@ -121,7 +121,7 @@ export declare function initPuzzleFromIntent(intent: Partial<AllocationIntentPuz
121
121
  export declare function checkPuzzleCompleteness(puzzle: AllocationPuzzle): AllocationPuzzleCompleteness;
122
122
  export interface AllocationConstraintViolation {
123
123
  constraint_id: string;
124
- severity: "CRITICAL" | "HIGH" | "MEDIUM" | "LOW";
124
+ severity: "critical" | "high" | "medium" | "low";
125
125
  message: string;
126
126
  current_value?: string | number;
127
127
  limit?: string | number;
@@ -1 +1 @@
1
- import{MAX_ALLOCATOR_COUNT,ALLOCATION_MAX_SHARING_COUNT,RATE_TOTAL_FULL}from'./allocation-ledger.js';export function initPuzzleFromIntent(a){const b={};return(a['action']||a['distribution_goal']||a['trigger_condition'])&&(b['intent']={'action':a['action']??'create','host_context':a['host_context']??'service_order_allocators','trigger_condition':a['trigger_condition']??'','distribution_goal':a['distribution_goal']??'','failure_conditions':a['failure_conditions']??[]}),b['constraints']={'F_A_01_allocator_count_le_100':!![],'F_A_02_sharing_count_le_100':!![],'F_A_03_sharing_mode_valid':!![],'F_A_04_at_most_1_surplus_per_allocator':!![],'F_A_05_pure_rate_sum_eq_10000':!![],'F_A_06_rate_plus_surplus_sum_le_10000':!![],'F_A_07_amount_sum_ge_threshold':!![],'F_A_08_amount_sum_le_max':!![],'F_A_09_balance_ge_threshold_at_alloc':!![],'F_A_10_payment_info_present':!![],'F_A_11_allocators_not_empty':!![],'F_A_12_order_at_most_1_allocation':!![],'F_A_13_guard_identifier_is_address':!![],'F_A_14_guard_addresses_unique':!![],'F_A_15_order_allocators_immutable_after_publish':!![]},b;}export function checkPuzzleCompleteness(a){const b=[],c=[];if(!a['intent'])b['push']('A'),c['push']({'dimension':'A','reason':'Intent\x20not\x20specified\x20(action\x20+\x20distribution_goal)'});else{if(!a['intent']['distribution_goal'])b['push']('A'),c['push']({'dimension':'A','reason':'distribution_goal\x20is\x20empty'});else!a['intent']['host_context']&&(b['push']('A'),c['push']({'dimension':'A','reason':'host_context\x20(trigger\x20source)\x20must\x20be\x20specified'}));}if(!a['binding'])b['push']('B'),c['push']({'dimension':'B','reason':'Binding\x20not\x20specified\x20(coin_type\x20+\x20guard_objects)'});else{if(!a['binding']['coin_type'])b['push']('B'),c['push']({'dimension':'B','reason':'coin_type\x20is\x20missing'});else a['binding']['guard_objects']['length']===0x0&&(b['push']('B'),c['push']({'dimension':'B','reason':'guard_objects\x20list\x20is\x20empty\x20—\x20at\x20least\x201\x20Guard\x20required'}));}if(!a['data_source']&&a['intent']?.['action']==='create')b['push']('C'),c['push']({'dimension':'C','reason':'Data\x20source\x20not\x20specified\x20(allocators_config\x20+\x20payment_info)'});else a['data_source']&&a['data_source']['allocators_config']['allocators']['length']===0x0&&(b['push']('C'),c['push']({'dimension':'C','reason':'allocators_config.allocators\x20is\x20empty'}));return!a['operations']&&(b['push']('D'),c['push']({'dimension':'D','reason':'Operations\x20not\x20enumerated'})),!a['logic']&&(b['push']('E'),c['push']({'dimension':'E','reason':'Logic\x20flow\x20(7-step\x20alloc)\x20not\x20defined'})),!a['constraints']&&(b['push']('F'),c['push']({'dimension':'F','reason':'Constraints\x20not\x20checked'})),{'dimensions':['A','B','C','D','E','F'],'missing':b,'missing_details':c,'complete':b['length']===0x0,'next_step':b['length']===0x0?'Puzzle\x20complete\x20—\x20ready\x20for\x20confirmation\x20text\x20generation':'Next:\x20complete\x20dimension\x20'+b[0x0]+'\x20—\x20'+c[0x0]['reason']};}export function validateConstraints(a){const b=[];if(!a['data_source'])return b;const c=a['data_source']['allocators_config'];c['allocators']['length']>MAX_ALLOCATOR_COUNT&&b['push']({'constraint_id':'F-A-01','severity':'CRITICAL','message':'Allocator\x20count\x20'+c['allocators']['length']+'\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20'+MAX_ALLOCATOR_COUNT,'current_value':c['allocators']['length'],'limit':MAX_ALLOCATOR_COUNT,'related_move_error':'EALLOCATOR_COUNT_EXCEEDED\x20(2)'});c['allocators']['length']===0x0&&b['push']({'constraint_id':'F-A-11','severity':'CRITICAL','message':'allocators.allocators\x20is\x20empty\x20—\x20at\x20least\x201\x20Allocator\x20required','related_move_error':'EALLOCATORS_EMPTY\x20(8)\x20/\x20ENO_ALLOCATOR\x20(3)'});const d=c['allocators']['map'](f=>f['guard']),e=new Set(d);e['size']!==d['length']&&b['push']({'constraint_id':'F-A-14','severity':'MEDIUM','message':'Duplicate\x20Guard\x20addresses\x20in\x20allocators\x20('+d['length']+'\x20entries,\x20'+e['size']+'\x20unique)\x20—\x20alloc_by_guard\x20address\x20match\x20only\x20hits\x20the\x20first,\x20subsequent\x20duplicate\x20Allocators\x20are\x20never\x20reachable'});for(const f of c['allocators']){f['sharing']['length']>ALLOCATION_MAX_SHARING_COUNT&&b['push']({'constraint_id':'F-A-02','severity':'CRITICAL','message':'Allocator\x20'+f['guard']+'\x20has\x20'+f['sharing']['length']+'\x20sharing\x20entries,\x20exceeds\x20MAX_SHARING_COUNT\x20'+ALLOCATION_MAX_SHARING_COUNT,'current_value':f['sharing']['length'],'limit':ALLOCATION_MAX_SHARING_COUNT,'related_move_error':'ESHARING_COUNT_EXCEEDED\x20(10)'});for(const m of f['sharing']){!['Amount','Rate','Surplus']['includes'](m['mode'])&&b['push']({'constraint_id':'F-A-03','severity':'CRITICAL','message':'Invalid\x20sharing\x20mode:\x20'+m['mode'],'related_move_error':'ESHARING_MODE_INVALID\x20(11)'});}const g=f['sharing']['filter'](n=>n['mode']==='Surplus')['length'];g>0x1&&b['push']({'constraint_id':'F-A-04','severity':'HIGH','message':'Allocator\x20'+f['guard']+'\x20has\x20'+g+'\x20Surplus\x20sharing\x20—\x20at\x20most\x201\x20allowed','current_value':g,'limit':0x1,'related_move_error':'EMULTIPLE_SURPLUS\x20(5)'});const h=f['sharing']['filter'](n=>n['mode']==='Rate')['reduce']((n,o)=>n+Number(o['sharing']),0x0),i=g>0x0;!i&&h>0x0&&h!==RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-05','severity':'HIGH','message':'Pure\x20Rate\x20mode\x20(no\x20Surplus)\x20sum\x20'+h+'\x20!=\x20'+RATE_TOTAL_FULL,'current_value':h,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_NOT_10000\x20(4)'});i&&h>RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-06','severity':'HIGH','message':'Rate\x20+\x20Surplus\x20mode\x20sum\x20'+h+'\x20>\x20'+RATE_TOTAL_FULL,'current_value':h,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});const j=f['sharing']['filter'](n=>n['mode']==='Amount')['reduce']((n,o)=>n+Number(o['sharing']),0x0),k=Number(c['threshold']);j>0x0&&j<k&&b['push']({'constraint_id':'F-A-07','severity':'HIGH','message':'Amount\x20sum\x20'+j+'\x20<\x20threshold\x20'+k,'current_value':j,'limit':k,'related_move_error':'EAMOUNT_BELOW_THRESHOLD\x20(12)'});f['max']!=null&&j>Number(f['max'])&&b['push']({'constraint_id':'F-A-08','severity':'MEDIUM','message':'Amount\x20sum\x20'+j+'\x20>\x20max\x20'+Number(f['max']),'current_value':j,'limit':Number(f['max']),'related_move_error':'EAMOUNT_EXCEEDS_MAX\x20(13)'});const l=f['sharing']['find'](n=>typeof n['who']==='object'&&'GuardIdentifier'in n['who']);if(l){}}return b;}export function generateConfirmationText(a){const b=[];b['push']('═══\x20Allocation\x20Confirmation\x20═══'),b['push']('');if(a['intent']){b['push']('Action:\x20'+a['intent']['action']),b['push']('Host\x20context:\x20'+a['intent']['host_context']),b['push']('Trigger:\x20'+a['intent']['trigger_condition']),b['push']('Distribution\x20goal:\x20'+a['intent']['distribution_goal']);if(a['intent']['failure_conditions']['length']>0x0){b['push']('Failure\x20conditions:');for(const d of a['intent']['failure_conditions'])b['push']('\x20\x20-\x20'+d);}b['push']('');}if(a['binding']){b['push']('─\x20Binding\x20──────────────'),b['push']('Coin\x20type:\x20'+a['binding']['coin_type']);if(a['binding']['host_service'])b['push']('Host\x20Service:\x20'+a['binding']['host_service']);if(a['binding']['host_arbitration'])b['push']('Host\x20Arbitration:\x20'+a['binding']['host_arbitration']);if(a['binding']['bound_order'])b['push']('Bound\x20Order:\x20'+a['binding']['bound_order']);if(a['binding']['trigger_node'])b['push']('Trigger\x20node:\x20'+a['binding']['trigger_node']);b['push']('Guard\x20objects\x20('+a['binding']['guard_objects']['length']+'):\x20'+a['binding']['guard_objects']['join'](',\x20')),b['push']('Payment\x20info\x20source:\x20'+a['binding']['payment_info_source']),b['push']('');}if(a['data_source']){const e=a['data_source']['allocators_config'];b['push']('─\x20Data\x20Source\x20──────────────'),b['push']('Description:\x20'+e['description']),b['push']('Threshold:\x20'+e['threshold']),b['push']('Allocators:\x20'+e['allocators']['length']),e['allocators']['forEach']((f,g)=>{b['push']('\x20\x20['+g+']\x20guard='+f['guard']+',\x20sharing='+f['sharing']['length']+'\x20items,\x20fix='+(f['fix']??'0')+',\x20max='+(f['max']??'null')),f['sharing']['forEach']((h,k)=>{b['push']('\x20\x20\x20\x20\x20\x20('+k+')\x20who='+JSON['stringify'](h['who'])+',\x20sharing='+h['sharing']+',\x20mode='+h['mode']);});}),b['push']('Payment\x20info\x20for_object:\x20'+a['data_source']['payment_info']['for_object']+(a['data_source']['payment_info']['for_object']?'\x20(ENFORCED\x20at\x20alloc:\x20GuardIdentifier\x20submissions\x20must\x20equal\x20this\x20address,\x20abort\x2015\x20on\x20mismatch)':'\x20(no\x20anchor:\x20nothing\x20enforced\x20on-chain,\x20recipient\x20routing\x20is\x20the\x20creator\x27s\x20business)')),b['push']('Coin\x20source:\x20'+a['data_source']['coin_source']),b['push']('');}if(a['logic']){b['push']('─\x20Logic\x20──────────────'),b['push']('Guard\x20matching:\x20'+a['logic']['guard_matching_strategy']),b['push']('alloc()\x20flow\x20('+a['logic']['alloc_flow']['length']+'\x20steps):');for(const f of a['logic']['alloc_flow']){b['push']('\x20\x20'+f['step']+'.\x20'+f['action']+':\x20'+f['description']);}b['push']('');}const c=validateConstraints(a);if(c['length']>0x0){b['push']('─\x20Constraint\x20Violations\x20──────────────');for(const g of c){b['push']('\x20\x20['+g['severity']+']\x20'+g['constraint_id']+':\x20'+g['message']);}b['push']('');}return b['join']('\x0a');}export function buildDefaultAllocFlow(){return[{'step':0x1,'action':'pre_check','description':'assert\x20balance\x20>=\x20threshold,\x20payment_info.is_some(),\x20allocators\x20not\x20empty'},{'step':0x2,'action':'guard_lookup','description':'iterate\x20allocators[],\x20locate\x20alloc.guard\x20==\x20alloc_by_guard\x20address;\x20on\x20hit\x20call\x20passport::result_for_guard\x20hard\x20verification\x20(failure\x20aborts\x20E_VERIFY_FAILED)'},{'step':0x3,'action':'rate_base_calc','description':'total_rates\x20=\x20max\x20-\x20fix\x20(if\x20max)\x20else\x20balance\x20-\x20fix'},{'step':0x4,'action':'sharing_distribution','description':'iterate\x20sharing[],\x20split\x20by\x20mode\x20(Amount/Rate/Surplus\x20placeholder)'},{'step':0x5,'action':'surplus_distribution','description':'withdraw_all\x20to\x20surplus_recipient\x20(if\x20any)'},{'step':0x6,'action':'recipient_resolution','description':'resolve\x20address\x20from\x20GuardIdentifier(passport)\x20/\x20Entity(static)\x20/\x20Signer(tx\x20sender);\x20GuardIdentifier\x20submissions\x20are\x20additionally\x20checked\x20against\x20payment_info.for_object\x20when\x20it\x20is\x20Some\x20(mismatch\x20aborts\x20ERECIPIENT_NOT_FOR_OBJECT\x2015;\x20None\x20=\x20no\x20anchor,\x20nothing\x20enforced)'},{'step':0x7,'action':'payment_creation','description':'create\x20Payment\x20object,\x20push\x20to\x20self.payment\x20vector'}];}export function buildDefaultRecipientRules(){return[{'recipient_type':'GuardIdentifier','resolution_source':'passport_table','safety_level':'safe'},{'recipient_type':'Entity','resolution_source':'static_address','safety_level':'safe'},{'recipient_type':'Signer','resolution_source':'tx_sender','safety_level':'dangerous'}];}export function buildDefaultLogicPuzzle(){return{'alloc_flow':buildDefaultAllocFlow(),'guard_matching_strategy':'caller_specified_guard','recipient_resolution_rules':buildDefaultRecipientRules()};}export const ALLOCATION_PUZZLE_VERSION='1.0.0';
1
+ import{MAX_ALLOCATOR_COUNT,ALLOCATION_MAX_SHARING_COUNT,RATE_TOTAL_FULL}from'./allocation-ledger.js';export function initPuzzleFromIntent(a){const b={};return(a['action']||a['distribution_goal']||a['trigger_condition'])&&(b['intent']={'action':a['action']??'create','host_context':a['host_context']??'service_order_allocators','trigger_condition':a['trigger_condition']??'','distribution_goal':a['distribution_goal']??'','failure_conditions':a['failure_conditions']??[]}),b['constraints']={'F_A_01_allocator_count_le_100':!![],'F_A_02_sharing_count_le_100':!![],'F_A_03_sharing_mode_valid':!![],'F_A_04_at_most_1_surplus_per_allocator':!![],'F_A_05_pure_rate_sum_eq_10000':!![],'F_A_06_rate_plus_surplus_sum_le_10000':!![],'F_A_07_amount_sum_ge_threshold':!![],'F_A_08_amount_sum_le_max':!![],'F_A_09_balance_ge_threshold_at_alloc':!![],'F_A_10_payment_info_present':!![],'F_A_11_allocators_not_empty':!![],'F_A_12_order_at_most_1_allocation':!![],'F_A_13_guard_identifier_is_address':!![],'F_A_14_guard_addresses_unique':!![],'F_A_15_order_allocators_immutable_after_publish':!![]},b;}export function checkPuzzleCompleteness(a){const b=[],c=[];if(!a['intent'])b['push']('A'),c['push']({'dimension':'A','reason':'Intent\x20not\x20specified\x20(action\x20+\x20distribution_goal)'});else{if(!a['intent']['distribution_goal'])b['push']('A'),c['push']({'dimension':'A','reason':'distribution_goal\x20is\x20empty'});else!a['intent']['host_context']&&(b['push']('A'),c['push']({'dimension':'A','reason':'host_context\x20(trigger\x20source)\x20must\x20be\x20specified'}));}if(!a['binding'])b['push']('B'),c['push']({'dimension':'B','reason':'Binding\x20not\x20specified\x20(coin_type\x20+\x20guard_objects)'});else{if(!a['binding']['coin_type'])b['push']('B'),c['push']({'dimension':'B','reason':'coin_type\x20is\x20missing'});else a['binding']['guard_objects']['length']===0x0&&(b['push']('B'),c['push']({'dimension':'B','reason':'guard_objects\x20list\x20is\x20empty\x20—\x20at\x20least\x201\x20Guard\x20required'}));}if(!a['data_source']&&a['intent']?.['action']==='create')b['push']('C'),c['push']({'dimension':'C','reason':'Data\x20source\x20not\x20specified\x20(allocators_config\x20+\x20payment_info)'});else a['data_source']&&a['data_source']['allocators_config']['allocators']['length']===0x0&&(b['push']('C'),c['push']({'dimension':'C','reason':'allocators_config.allocators\x20is\x20empty'}));return!a['operations']&&(b['push']('D'),c['push']({'dimension':'D','reason':'Operations\x20not\x20enumerated'})),!a['logic']&&(b['push']('E'),c['push']({'dimension':'E','reason':'Logic\x20flow\x20(7-step\x20alloc)\x20not\x20defined'})),!a['constraints']&&(b['push']('F'),c['push']({'dimension':'F','reason':'Constraints\x20not\x20checked'})),{'dimensions':['A','B','C','D','E','F'],'missing':b,'missing_details':c,'complete':b['length']===0x0,'next_step':b['length']===0x0?'Puzzle\x20complete\x20—\x20ready\x20for\x20confirmation\x20text\x20generation':'Next:\x20complete\x20dimension\x20'+b[0x0]+'\x20—\x20'+c[0x0]['reason']};}export function validateConstraints(a){const b=[];if(!a['data_source'])return b;const c=a['data_source']['allocators_config'];c['allocators']['length']>MAX_ALLOCATOR_COUNT&&b['push']({'constraint_id':'F-A-01','severity':'critical','message':'Allocator\x20count\x20'+c['allocators']['length']+'\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20'+MAX_ALLOCATOR_COUNT,'current_value':c['allocators']['length'],'limit':MAX_ALLOCATOR_COUNT,'related_move_error':'EALLOCATOR_COUNT_EXCEEDED\x20(2)'});c['allocators']['length']===0x0&&b['push']({'constraint_id':'F-A-11','severity':'critical','message':'allocators.allocators\x20is\x20empty\x20—\x20at\x20least\x201\x20Allocator\x20required','related_move_error':'EALLOCATORS_EMPTY\x20(8)\x20/\x20ENO_ALLOCATOR\x20(3)'});const d=c['allocators']['map'](f=>f['guard']),e=new Set(d);e['size']!==d['length']&&b['push']({'constraint_id':'F-A-14','severity':'medium','message':'Duplicate\x20Guard\x20addresses\x20in\x20allocators\x20('+d['length']+'\x20entries,\x20'+e['size']+'\x20unique)\x20—\x20alloc_by_guard\x20address\x20match\x20only\x20hits\x20the\x20first,\x20subsequent\x20duplicate\x20Allocators\x20are\x20never\x20reachable'});for(const f of c['allocators']){f['sharing']['length']>ALLOCATION_MAX_SHARING_COUNT&&b['push']({'constraint_id':'F-A-02','severity':'critical','message':'Allocator\x20'+f['guard']+'\x20has\x20'+f['sharing']['length']+'\x20sharing\x20entries,\x20exceeds\x20MAX_SHARING_COUNT\x20'+ALLOCATION_MAX_SHARING_COUNT,'current_value':f['sharing']['length'],'limit':ALLOCATION_MAX_SHARING_COUNT,'related_move_error':'ESHARING_COUNT_EXCEEDED\x20(10)'});for(const m of f['sharing']){!['Amount','Rate','Surplus']['includes'](m['mode'])&&b['push']({'constraint_id':'F-A-03','severity':'critical','message':'Invalid\x20sharing\x20mode:\x20'+m['mode'],'related_move_error':'ESHARING_MODE_INVALID\x20(11)'});}const g=f['sharing']['filter'](n=>n['mode']==='Surplus')['length'];g>0x1&&b['push']({'constraint_id':'F-A-04','severity':'high','message':'Allocator\x20'+f['guard']+'\x20has\x20'+g+'\x20Surplus\x20sharing\x20—\x20at\x20most\x201\x20allowed','current_value':g,'limit':0x1,'related_move_error':'EMULTIPLE_SURPLUS\x20(5)'});const h=f['sharing']['filter'](n=>n['mode']==='Rate')['reduce']((n,o)=>n+Number(o['sharing']),0x0),i=g>0x0;!i&&h>0x0&&h!==RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-05','severity':'high','message':'Pure\x20Rate\x20mode\x20(no\x20Surplus)\x20sum\x20'+h+'\x20!=\x20'+RATE_TOTAL_FULL,'current_value':h,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_NOT_10000\x20(4)'});i&&h>RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-06','severity':'high','message':'Rate\x20+\x20Surplus\x20mode\x20sum\x20'+h+'\x20>\x20'+RATE_TOTAL_FULL,'current_value':h,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});const j=f['sharing']['filter'](n=>n['mode']==='Amount')['reduce']((n,o)=>n+Number(o['sharing']),0x0),k=Number(c['threshold']);j>0x0&&j<k&&b['push']({'constraint_id':'F-A-07','severity':'high','message':'Amount\x20sum\x20'+j+'\x20<\x20threshold\x20'+k,'current_value':j,'limit':k,'related_move_error':'EAMOUNT_BELOW_THRESHOLD\x20(12)'});f['max']!=null&&j>Number(f['max'])&&b['push']({'constraint_id':'F-A-08','severity':'medium','message':'Amount\x20sum\x20'+j+'\x20>\x20max\x20'+Number(f['max']),'current_value':j,'limit':Number(f['max']),'related_move_error':'EAMOUNT_EXCEEDS_MAX\x20(13)'});const l=f['sharing']['find'](n=>typeof n['who']==='object'&&'GuardIdentifier'in n['who']);if(l){}}return b;}export function generateConfirmationText(a){const b=[];b['push']('═══\x20Allocation\x20Confirmation\x20═══'),b['push']('');if(a['intent']){b['push']('Action:\x20'+a['intent']['action']),b['push']('Host\x20context:\x20'+a['intent']['host_context']),b['push']('Trigger:\x20'+a['intent']['trigger_condition']),b['push']('Distribution\x20goal:\x20'+a['intent']['distribution_goal']);if(a['intent']['failure_conditions']['length']>0x0){b['push']('Failure\x20conditions:');for(const d of a['intent']['failure_conditions'])b['push']('\x20\x20-\x20'+d);}b['push']('');}if(a['binding']){b['push']('─\x20Binding\x20──────────────'),b['push']('Coin\x20type:\x20'+a['binding']['coin_type']);if(a['binding']['host_service'])b['push']('Host\x20Service:\x20'+a['binding']['host_service']);if(a['binding']['host_arbitration'])b['push']('Host\x20Arbitration:\x20'+a['binding']['host_arbitration']);if(a['binding']['bound_order'])b['push']('Bound\x20Order:\x20'+a['binding']['bound_order']);if(a['binding']['trigger_node'])b['push']('Trigger\x20node:\x20'+a['binding']['trigger_node']);b['push']('Guard\x20objects\x20('+a['binding']['guard_objects']['length']+'):\x20'+a['binding']['guard_objects']['join'](',\x20')),b['push']('Payment\x20info\x20source:\x20'+a['binding']['payment_info_source']),b['push']('');}if(a['data_source']){const e=a['data_source']['allocators_config'];b['push']('─\x20Data\x20Source\x20──────────────'),b['push']('Description:\x20'+e['description']),b['push']('Threshold:\x20'+e['threshold']),b['push']('Allocators:\x20'+e['allocators']['length']),e['allocators']['forEach']((f,g)=>{b['push']('\x20\x20['+g+']\x20guard='+f['guard']+',\x20sharing='+f['sharing']['length']+'\x20items,\x20fix='+(f['fix']??'0')+',\x20max='+(f['max']??'null')),f['sharing']['forEach']((h,k)=>{b['push']('\x20\x20\x20\x20\x20\x20('+k+')\x20who='+JSON['stringify'](h['who'])+',\x20sharing='+h['sharing']+',\x20mode='+h['mode']);});}),b['push']('Payment\x20info\x20for_object:\x20'+a['data_source']['payment_info']['for_object']+(a['data_source']['payment_info']['for_object']?'\x20(ENFORCED\x20at\x20alloc:\x20GuardIdentifier\x20submissions\x20must\x20equal\x20this\x20address,\x20abort\x2015\x20on\x20mismatch)':'\x20(no\x20anchor:\x20nothing\x20enforced\x20on-chain,\x20recipient\x20routing\x20is\x20the\x20creator\x27s\x20business)')),b['push']('Coin\x20source:\x20'+a['data_source']['coin_source']),b['push']('');}if(a['logic']){b['push']('─\x20Logic\x20──────────────'),b['push']('Guard\x20matching:\x20'+a['logic']['guard_matching_strategy']),b['push']('alloc()\x20flow\x20('+a['logic']['alloc_flow']['length']+'\x20steps):');for(const f of a['logic']['alloc_flow']){b['push']('\x20\x20'+f['step']+'.\x20'+f['action']+':\x20'+f['description']);}b['push']('');}const c=validateConstraints(a);if(c['length']>0x0){b['push']('─\x20Constraint\x20Violations\x20──────────────');for(const g of c){b['push']('\x20\x20['+g['severity']+']\x20'+g['constraint_id']+':\x20'+g['message']);}b['push']('');}return b['join']('\x0a');}export function buildDefaultAllocFlow(){return[{'step':0x1,'action':'pre_check','description':'assert\x20balance\x20>=\x20threshold,\x20payment_info.is_some(),\x20allocators\x20not\x20empty'},{'step':0x2,'action':'guard_lookup','description':'iterate\x20allocators[],\x20locate\x20alloc.guard\x20==\x20alloc_by_guard\x20address;\x20on\x20hit\x20run\x20the\x20Passport\x20guard-result\x20hard\x20verification\x20(failure\x20aborts\x20E_VERIFY_FAILED)'},{'step':0x3,'action':'rate_base_calc','description':'total_rates\x20=\x20max\x20-\x20fix\x20(if\x20max)\x20else\x20balance\x20-\x20fix'},{'step':0x4,'action':'sharing_distribution','description':'iterate\x20sharing[],\x20split\x20by\x20mode\x20(Amount/Rate/Surplus\x20placeholder)'},{'step':0x5,'action':'surplus_distribution','description':'withdraw_all\x20to\x20surplus_recipient\x20(if\x20any)'},{'step':0x6,'action':'recipient_resolution','description':'resolve\x20address\x20from\x20GuardIdentifier(passport)\x20/\x20Entity(static)\x20/\x20Signer(tx\x20sender);\x20GuardIdentifier\x20submissions\x20are\x20additionally\x20checked\x20against\x20payment_info.for_object\x20when\x20it\x20is\x20Some\x20(mismatch\x20aborts\x20ERECIPIENT_NOT_FOR_OBJECT\x2015;\x20None\x20=\x20no\x20anchor,\x20nothing\x20enforced)'},{'step':0x7,'action':'payment_creation','description':'create\x20Payment\x20object,\x20push\x20to\x20self.payment\x20vector'}];}export function buildDefaultRecipientRules(){return[{'recipient_type':'GuardIdentifier','resolution_source':'passport_table','safety_level':'safe'},{'recipient_type':'Entity','resolution_source':'static_address','safety_level':'safe'},{'recipient_type':'Signer','resolution_source':'tx_sender','safety_level':'dangerous'}];}export function buildDefaultLogicPuzzle(){return{'alloc_flow':buildDefaultAllocFlow(),'guard_matching_strategy':'caller_specified_guard','recipient_resolution_rules':buildDefaultRecipientRules()};}export const ALLOCATION_PUZZLE_VERSION='1.0.0';
@@ -1,5 +1,6 @@
1
1
  import { ALLOCATION_ERROR_CODES, type AllocationScene } from "./allocation-ledger.js";
2
- export type AllocationRiskLevel = "CRITICAL" | "HIGH" | "MEDIUM" | "LOW";
2
+ import { type Facts, type FindingExposure } from "../config/rule-engine.js";
3
+ export type AllocationRiskLevel = "critical" | "high" | "medium" | "low";
3
4
  export type AllocationRiskCategory = "structural" | "semantic" | "authority" | "lifecycle" | "cross_object";
4
5
  export interface AllocationRisk {
5
6
  id: string;
@@ -14,6 +15,7 @@ export interface AllocationRisk {
14
15
  related_move_error?: string;
15
16
  related_guard_risk?: string;
16
17
  auto_fixable: boolean;
18
+ exposure?: FindingExposure;
17
19
  }
18
20
  export type AllocationStakeholder = "owner" | "allocator" | "recipient" | "service_provider" | "system";
19
21
  export interface AllocationRiskRule {
@@ -60,6 +62,7 @@ export interface AllocationRiskCheckContext {
60
62
  bound_order?: string;
61
63
  order_already_has_allocation?: boolean;
62
64
  }
65
+ export declare function allocationRiskFacts(ctx: AllocationRiskCheckContext): Facts;
63
66
  export declare const ALLOCATION_RISK_VERSION = "1.1.0";
64
67
  export declare function getAllRiskRules(): AllocationRiskRule[];
65
68
  export interface AllocationRiskAssessment {
@@ -1 +1 @@
1
- import{MAX_ALLOCATOR_COUNT,RATE_TOTAL_FULL,ALLOCATION_ERROR_CODES}from'./allocation-ledger.js';import{isUnboundSignerTheft,canonicalDoctrine}from'./recipient-constraint.js';const R_A_1_01={'id':'R-A-1-01','category':'structural','trigger':'allocators\x20is\x20empty\x20or\x20sharing\x20arrays\x20are\x20empty','check':a=>{if(!a['allocators_config'])return null;const b=a['allocators_config']['allocators'];if(b['length']===0x0)return{'id':'R-A-1-01','level':'CRITICAL','category':'structural','title':'Empty\x20allocators\x20—\x20funds\x20will\x20be\x20permanently\x20locked','description':'Allocation\x20has\x20empty\x20allocators.allocators.\x20Service\x20publish\x20with\x20empty\x20order_allocators\x20causes\x20order\x20funds\x20to\x20be\x20permanently\x20locked\x20in\x20the\x20Allocation\x20object.','affected_stakeholders':['owner','service_provider','system'],'scenario':'Service\x20published\x20without\x20configuring\x20any\x20Allocator','mitigation':'Configure\x20at\x20least\x201\x20Allocator.\x20If\x20no\x20distribution\x20is\x20needed\x20yet,\x20use\x20a\x20single\x20Allocator\x20with\x20Rate=10000\x20to\x20the\x20merchant\x20address.','evidence':'allocators.length=0','related_move_error':'EALLOCATORS_EMPTY\x20(8)\x20/\x20ENO_ALLOCATOR\x20(3)','auto_fixable':![]};for(let c=0x0;c<b['length'];c++){if(b[c]['sharing']['length']===0x0)return{'id':'R-A-1-01','level':'CRITICAL','category':'structural','title':'Allocator\x20'+c+'\x20has\x20empty\x20sharing\x20—\x20will\x20never\x20distribute','description':'Allocator\x20at\x20index\x20'+c+'\x20(guard='+b[c]['guard']+')\x20has\x20empty\x20sharing\x20array.\x20Even\x20if\x20its\x20Guard\x20passes\x20verification,\x20no\x20funds\x20will\x20be\x20distributed.','affected_stakeholders':['owner','recipient'],'scenario':'Allocator\x20with\x20empty\x20sharing\x20vector','mitigation':'Add\x20at\x20least\x201\x20sharing\x20entry\x20to\x20Allocator\x20'+c,'evidence':'allocator['+c+'].sharing.length=0','related_move_error':'ENO_ALLOCATOR\x20(3)','auto_fixable':![]};}return null;}},R_A_1_02={'id':'R-A-1-02','category':'structural','trigger':'Pure\x20Rate\x20mode\x20sum\x20!=\x2010000\x20or\x20Rate+Surplus\x20sum\x20>\x2010000','check':b=>{if(!b['allocators_config'])return null;for(let c=0x0;c<b['allocators_config']['allocators']['length'];c++){const d=b['allocators_config']['allocators'][c],e=d['sharing']['filter'](g=>g['mode']==='Rate')['reduce']((g,h)=>g+Number(h['sharing']),0x0),f=d['sharing']['some'](g=>g['mode']==='Surplus');if(!f&&e>0x0&&e!==RATE_TOTAL_FULL)return{'id':'R-A-1-02','level':'HIGH','category':'structural','title':'Pure\x20Rate\x20mode\x20sum\x20'+e+'\x20!=\x20'+RATE_TOTAL_FULL,'description':'Allocator\x20'+c+'\x20(guard='+d['guard']+')\x20uses\x20pure\x20Rate\x20mode\x20(no\x20Surplus),\x20but\x20sum(rates)='+e+'\x20≠\x20'+RATE_TOTAL_FULL+'.\x20Funds\x20will\x20be\x20permanently\x20locked\x20(if\x20sum<10000)\x20or\x20Move\x20will\x20abort\x20with\x20ERATE_NOT_10000\x20(if\x20sum\x20!=\x2010000\x20exactly).','affected_stakeholders':['owner','recipient'],'scenario':'Misconfigured\x20rate\x20proportions','mitigation':'Adjust\x20sharing.sharing\x20values\x20so\x20sum(rates)='+RATE_TOTAL_FULL+',\x20OR\x20add\x201\x20Surplus\x20sharing\x20to\x20absorb\x20the\x20remainder.','evidence':'rateSum='+e+',\x20expected='+RATE_TOTAL_FULL,'related_move_error':'ERATE_NOT_10000\x20(4)','auto_fixable':!![]};if(f&&e>RATE_TOTAL_FULL)return{'id':'R-A-1-02','level':'HIGH','category':'structural','title':'Rate\x20+\x20Surplus\x20sum\x20'+e+'\x20>\x20'+RATE_TOTAL_FULL,'description':'Allocator\x20'+c+'\x20(guard='+d['guard']+')\x20uses\x20Rate+Surplus\x20mode,\x20but\x20sum(rates)='+e+'\x20>\x20'+RATE_TOTAL_FULL+'.\x20Move\x20will\x20abort\x20with\x20ERATE_EXCEEDS_10000.','affected_stakeholders':['owner'],'scenario':'Rate\x20percentages\x20exceed\x20100%\x20before\x20Surplus','mitigation':'Reduce\x20sum(rates)\x20to\x20≤\x20'+RATE_TOTAL_FULL+'.','evidence':'rateSum='+e+',\x20max='+RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)','auto_fixable':!![]};}return null;}},R_A_1_03={'id':'R-A-1-03','category':'structural','trigger':'Multiple\x20Surplus\x20sharing\x20in\x20one\x20Allocator,\x20or\x20Amount\x20sum\x20violates\x20threshold/max','check':b=>{if(!b['allocators_config'])return null;for(let c=0x0;c<b['allocators_config']['allocators']['length'];c++){const d=b['allocators_config']['allocators'][c],e=d['sharing']['filter'](h=>h['mode']==='Surplus')['length'];if(e>0x1)return{'id':'R-A-1-03','level':'MEDIUM','category':'structural','title':'Allocator\x20'+c+'\x20has\x20'+e+'\x20Surplus\x20sharing\x20—\x20at\x20most\x201\x20allowed','description':'Allocator\x20'+c+'\x20(guard='+d['guard']+')\x20has\x20'+e+'\x20Surplus\x20sharing\x20entries.\x20Move\x20will\x20abort\x20with\x20EMULTIPLE_SURPLUS\x20at\x20alloc()\x20time.','affected_stakeholders':['owner'],'scenario':'Multiple\x20Surplus\x20entries\x20in\x20one\x20Allocator','mitigation':'Keep\x20at\x20most\x201\x20Surplus\x20per\x20Allocator.\x20Use\x20Rate\x20mode\x20for\x20multi-party\x20remainder\x20distribution.','evidence':'surplusCount='+e,'related_move_error':'EMULTIPLE_SURPLUS\x20(5)','auto_fixable':!![]};const f=d['sharing']['filter'](h=>h['mode']==='Amount')['reduce']((h,j)=>h+Number(j['sharing']),0x0),g=Number(b['allocators_config']['threshold']);if(f>0x0&&f<g)return{'id':'R-A-1-03','level':'HIGH','category':'structural','title':'Amount\x20sum\x20'+f+'\x20<\x20threshold\x20'+g,'description':'Allocator\x20'+c+'\x20pure\x20Amount\x20mode\x20fix='+f+'\x20<\x20threshold='+g+'.\x20Move\x20will\x20abort\x20with\x20EAMOUNT_BELOW_THRESHOLD\x20at\x20allocator_add\x20time.','affected_stakeholders':['owner'],'scenario':'Amount\x20sum\x20insufficient\x20to\x20trigger\x20alloc','mitigation':'Either\x20lower\x20threshold\x20to\x20<=\x20fix,\x20or\x20increase\x20Amount\x20sharing\x20values.','evidence':'fix='+f+',\x20threshold='+g,'related_move_error':'EAMOUNT_BELOW_THRESHOLD\x20(12)','auto_fixable':![]};if(d['max']!=null&&f>Number(d['max']))return{'id':'R-A-1-03','level':'MEDIUM','category':'structural','title':'Amount\x20sum\x20'+f+'\x20>\x20max\x20'+Number(d['max']),'description':'Allocator\x20'+c+'\x20Amount\x20sum\x20exceeds\x20max.\x20Move\x20will\x20abort\x20with\x20EAMOUNT_EXCEEDS_MAX.','affected_stakeholders':['owner'],'scenario':'Amount\x20sum\x20exceeds\x20max\x20cap','mitigation':'Increase\x20max\x20or\x20reduce\x20Amount\x20sharing\x20values.','evidence':'fix='+f+',\x20max='+Number(d['max']),'related_move_error':'EAMOUNT_EXCEEDS_MAX\x20(13)','auto_fixable':!![]};}return null;}},R_A_2_01={'id':'R-A-2-01','category':'semantic','trigger':'sharing.who=Signer\x20without\x20Guard\x20Signer\x20binding\x20—\x20fund\x20theft\x20risk','check':b=>{if(!b['allocators_config'])return null;for(let c=0x0;c<b['allocators_config']['allocators']['length'];c++){const d=b['allocators_config']['allocators'][c],e=d['sharing']['some'](g=>'Signer'in g['who']),f=b['guard_signer_bindings']?.[d['guard']]===!![];if(isUnboundSignerTheft({'recipient_is_signer':e,'caller_identity_constrained':f})){const g=canonicalDoctrine('RC-FIND-01');return{'id':'R-A-2-01','level':g['severity'],'category':'semantic','title':g['title'],'description':'Allocator\x20'+c+'\x20(guard='+d['guard']+')\x20has\x20sharing.who=Signer,\x20but\x20the\x20Guard\x20does\x20not\x20bind\x20context(Signer)==authorized.\x20Anyone\x20who\x20passes\x20the\x20Guard\x20can\x20steal\x20100%\x20of\x20funds.\x20(Canonical\x20finding\x20RC-FIND-01,\x20linked\x20to\x20guard-risk.ts\x20R-C3-06.)','affected_stakeholders':['owner','recipient','service_provider'],'scenario':'Signer\x20recipient\x20without\x20Guard\x20Signer\x20authentication','mitigation':g['mitigation'],'evidence':'guard='+d['guard']+',\x20guardSignerBound='+f,'related_guard_risk':'R-C3-06','auto_fixable':![]};}}return null;}},R_A_2_02={'id':'R-A-2-02','category':'semantic','trigger':'sharing.who=GuardIdentifier\x20but\x20Passport\x20table\x20entry\x20is\x20not\x20address\x20type','check':b=>{if(!b['allocators_config'])return null;if(!b['passport_identifier_types'])return null;for(let c=0x0;c<b['allocators_config']['allocators']['length'];c++){const d=b['allocators_config']['allocators'][c],e=d['sharing']['find'](h=>'GuardIdentifier'in h['who']);if(!e)continue;const f=e['who']['GuardIdentifier'],g=b['passport_identifier_types'][f];if(g!==undefined&&g!=='address')return{'id':'R-A-2-02','level':'MEDIUM','category':'semantic','title':'GuardIdentifier\x20'+f+'\x20resolves\x20to\x20non-address\x20type\x20('+g+')','description':'Allocator\x20'+c+'\x20uses\x20sharing.who=GuardIdentifier('+f+'),\x20but\x20Passport\x20table['+f+']\x20is\x20of\x20type\x20'+g+',\x20not\x20address.\x20Move\x20will\x20abort\x20with\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS\x20at\x20alloc()\x20time.','affected_stakeholders':['recipient'],'scenario':'Passport\x20table\x20entry\x20type\x20mismatch','mitigation':'Ensure\x20Passport\x20table['+f+']\x20is\x20address-typed,\x20OR\x20use\x20sharing.who=Entity\x20with\x20a\x20static\x20address.','evidence':'identifier='+f+',\x20type='+g,'related_move_error':'ERECIPIENT_IDENTIFIER_NOT_ADDRESS\x20(1)','auto_fixable':![]};}return null;}},R_A_2_03={'id':'R-A-2-03','category':'semantic','trigger':'Duplicate\x20Guard\x20addresses\x20in\x20allocators\x20(alloc_by_guard\x20address\x20match\x20only\x20hits\x20the\x20first\x20one)','check':a=>{if(!a['allocators_config'])return null;const b=a['allocators_config']['allocators']['map'](d=>d['guard']),c=new Set(b);if(c['size']!==b['length']){const d=b['filter']((e,f)=>b['indexOf'](e)!==f);return{'id':'R-A-2-03','level':'MEDIUM','category':'semantic','title':'Duplicate\x20Guard\x20addresses\x20in\x20allocators','description':'Multiple\x20Allocators\x20reference\x20the\x20same\x20Guard\x20object:\x20'+d['join'](',\x20')+'.\x20alloc_by_guard\x20locates\x20the\x20Allocator\x20by\x20iterating\x20guard\x20addresses;\x20duplicate\x20addresses\x20only\x20match\x20the\x20first\x20one,\x20so\x20subsequent\x20duplicate\x20Allocators\x20are\x20unreachable\x20(dead\x20code).','affected_stakeholders':['owner','allocator'],'scenario':'Reusing\x20same\x20Guard\x20object\x20across\x20multiple\x20Allocators','mitigation':'Create\x20independent\x20Guard\x20objects\x20for\x20each\x20Allocator\x20(they\x20may\x20share\x20root/table\x20but\x20must\x20differ\x20in\x20description).','evidence':'total='+b['length']+',\x20unique='+c['size']+',\x20dupes='+d['join'](','),'auto_fixable':!![]};}return null;}},R_A_2_04={'id':'R-A-2-04','category':'semantic','trigger':'GuardIdentifier\x20recipients\x20combined\x20with\x20payment_info.for_object\x20anchor\x20state\x20(Some\x20=\x20enforced,\x20None\x20=\x20absent)','check':a=>{if(!a['allocators_config'])return null;if(a['payment_info_for_object']===undefined)return null;const b=a['allocators_config']['allocators']['some'](d=>d['sharing']['some'](e=>'GuardIdentifier'in e['who']));if(!b)return null;const c=a['payment_info_for_object'];if(c)return{'id':'R-A-2-04','level':'MEDIUM','category':'semantic','title':'payment_info.for_object\x20anchor\x20is\x20ENFORCED\x20at\x20alloc()','description':'payment_info.for_object\x20is\x20set\x20to\x20'+c+'.\x20At\x20alloc(),\x20every\x20Recipient::GuardIdentifier\x20submission\x20must\x20equal\x20this\x20address\x20or\x20the\x20whole\x20tx\x20aborts\x20with\x20ERECIPIENT_NOT_FOR_OBJECT\x20(15)\x20—\x20a\x20wrong\x20anchor\x20or\x20a\x20guard\x20whose\x20passport\x20submits\x20a\x20different\x20address\x20makes\x20alloc()\x20permanently\x20fail\x20(payment_info\x20is\x20immutable\x20after\x20create).\x20Verify\x20the\x20anchor\x20matches\x20the\x20intended\x20recipient\x20flow.','affected_stakeholders':['owner','recipient'],'scenario':'Allocation\x20created\x20with\x20a\x20declared\x20for_object\x20binding\x20and\x20GuardIdentifier\x20recipients','mitigation':'Before\x20create:\x20confirm\x20for_object\x20is\x20the\x20object\x20the\x20GuardIdentifier\x20submissions\x20will\x20resolve\x20to\x20(the\x20guard\x27s\x20passport\x20must\x20submit\x20exactly\x20this\x20address\x20for\x20the\x20recipient\x20identifier).\x20Entity/Signer\x20sharing\x20lines\x20are\x20unaffected\x20by\x20the\x20anchor.','evidence':'for_object='+c,'related_move_error':'ERECIPIENT_NOT_FOR_OBJECT\x20(15)','auto_fixable':![]};return{'id':'R-A-2-04','level':'MEDIUM','category':'semantic','title':'payment_info.for_object\x20=\x20None\x20—\x20GuardIdentifier\x20destination\x20has\x20no\x20on-chain\x20anchor','description':'payment_info.for_object\x20is\x20not\x20set:\x20alloc()\x20enforces\x20NO\x20recipient\x20binding\x20for\x20Recipient::GuardIdentifier\x20lines.\x20Whoever\x20builds\x20the\x20passport\x20chooses\x20the\x20payout\x20address;\x20nothing\x20on-chain\x20constrains\x20it.\x20This\x20is\x20legal\x20by\x20design\x20(Allocation\x20is\x20a\x20generic\x20component,\x20the\x20anchor\x20is\x20opt-in),\x20but\x20it\x20means\x20recipient\x20routing\x20is\x20trust-on-creator.','affected_stakeholders':['owner','recipient'],'scenario':'Allocation\x20created\x20without\x20a\x20for_object\x20anchor\x20while\x20using\x20GuardIdentifier\x20recipients','mitigation':'If\x20enforced\x20routing\x20is\x20desired,\x20set\x20payment_info.for_object\x20to\x20the\x20intended\x20recipient\x20anchor\x20at\x20create\x20(it\x20becomes\x20mechanism-enforced:\x20mismatch\x20aborts\x20with\x20code\x2015).\x20If\x20no\x20anchor\x20is\x20intended,\x20document\x20that\x20the\x20recipient\x20is\x20the\x20passport\x20builder\x27s\x20choice\x20and\x20constrain\x20it\x20in\x20the\x20guard\x20expression\x20instead.','evidence':'for_object=None','related_move_error':'ERECIPIENT_NOT_FOR_OBJECT\x20(15,\x20only\x20fires\x20when\x20a\x20binding\x20is\x20declared)','auto_fixable':![]};}},R_A_3_01={'id':'R-A-3-01','category':'authority','trigger':'Service\x20already\x20published\x20—\x20order_allocators\x20is\x20immutable','check':a=>{if(!a['host_service_published'])return null;return{'id':'R-A-3-01','level':'HIGH','category':'authority','title':'order_allocators\x20immutable\x20after\x20Service\x20publish','description':'Service\x20is\x20already\x20published.\x20order_allocators\x20field\x20is\x20now\x20immutable\x20(safety-rules.ts:170-174).\x20Any\x20configuration\x20error\x20(wrong\x20Guard,\x20wrong\x20sharing\x20proportion,\x20wrong\x20Entity\x20address)\x20will\x20affect\x20ALL\x20subsequent\x20orders\x20and\x20cannot\x20be\x20fixed\x20without\x20creating\x20a\x20new\x20Service.','affected_stakeholders':['owner','service_provider'],'scenario':'Attempting\x20to\x20modify\x20order_allocators\x20after\x20Service\x20publish','mitigation':'1)\x20Verify\x20the\x20configuration\x20is\x20correct\x20before\x20publish.\x202)\x20Use\x20deploy-scanner\x20pre-publish\x20validation.\x203)\x20If\x20already\x20published\x20with\x20errors,\x20create\x20a\x20new\x20Service\x20to\x20replace.','evidence':'host_service_published='+a['host_service_published'],'auto_fixable':![]};}},R_A_3_02={'id':'R-A-3-02','category':'authority','trigger':'Treasury\x20Permission\x20inconsistent\x20with\x20Service\x20Permission','check':a=>{if(!a['allocators_config'])return null;if(!a['referenced_treasuries_permissions'])return null;if(!a['host_service_permission'])return null;for(const b of a['allocators_config']['allocators']){for(const c of b['sharing']){if(!('Entity'in c['who']))continue;const d=c['who']['Entity'],e=a['referenced_treasuries_permissions'][d];if(e&&e!==a['host_service_permission'])return{'id':'R-A-3-02','level':'MEDIUM','category':'authority','title':'Treasury\x20Permission\x20inconsistent\x20with\x20Service\x20Permission','description':'sharing.who=Entity\x20points\x20to\x20Treasury\x20'+d+'\x20whose\x20Permission\x20('+e+')\x20differs\x20from\x20Service\x20Permission\x20('+a['host_service_permission']+').\x20Two\x20different\x20permission\x20organizations\x20control\x20fund\x20flow,\x20creating\x20potential\x20authority\x20conflicts.','affected_stakeholders':['owner','service_provider'],'scenario':'Treasury\x20owned\x20by\x20different\x20party\x20than\x20Service','mitigation':'Create\x20Treasury\x20with\x20the\x20same\x20Permission\x20object\x20as\x20the\x20Service,\x20OR\x20ensure\x20both\x20are\x20owned\x20by\x20the\x20same\x20address.','evidence':'treasury='+d+',\x20treasuryPerm='+e+',\x20servicePerm='+a['host_service_permission'],'auto_fixable':![]};}}return null;}},R_A_3_03={'id':'R-A-3-03','category':'authority','trigger':'No\x20ALLOCATION_*\x20builtin\x20permission\x20index\x20—\x20Allocation\x20has\x20no\x20independent\x20access\x20control','check':a=>{if(a['operation_type']!=='create')return null;const b=a['trigger_source']==='standalone';return{'id':'R-A-3-03','level':'LOW','category':'authority','title':'Allocation\x20has\x20no\x20builtin\x20permission\x20index\x20(passive-object\x20design)','description':b?'BuiltinPermissionIndex\x20has\x20no\x20ALLOCATION_*\x20entries.\x20Allocation\x27s\x20access\x20control\x20is\x20fully\x20delegated\x20to\x20Guard\x20+\x20Passport.\x20In\x20standalone\x20mode\x20(trigger_source=standalone),\x20there\x20is\x20no\x20Service/Arbitration\x20layer\x20to\x20enforce\x20caller\x20authorization\x20—\x20Guard\x20MUST\x20provide\x20sufficient\x20access\x20control\x20(see\x20R-A-3-04).\x20This\x20is\x20the\x20\x27passive\x20object\x27\x20design\x20philosophy,\x20not\x20a\x20defect,\x20but\x20standalone\x20mode\x20shifts\x20full\x20responsibility\x20to\x20the\x20Guard\x20configuration.':'BuiltinPermissionIndex\x20has\x20no\x20ALLOCATION_*\x20entries.\x20Allocation\x27s\x20access\x20control\x20is\x20fully\x20delegated\x20to\x20Service\x20(SERVICE_ORDER_ALLOCATOR=313)\x20or\x20Arbitration\x20(ARBITRATION_FEES_ALLOC=365).\x20This\x20is\x20the\x20\x27passive\x20object\x27\x20design\x20philosophy,\x20not\x20a\x20defect.\x20In\x20embedded\x20mode,\x20the\x20host\x20Service/Arbitration\x20provides\x20an\x20additional\x20access-control\x20layer\x20on\x20top\x20of\x20Guard\x20+\x20Passport.','affected_stakeholders':['system'],'scenario':b?'Standalone\x20Allocation\x20creation\x20(user-initiated,\x20no\x20Service\x20context)':'Embedded\x20Allocation\x20creation\x20(via\x20Service\x20order_allocators\x20or\x20Arbitration\x20fees_alloc)','mitigation':b?'For\x20standalone\x20Allocation,\x20ensure\x20Guard\x20binds\x20Signer\x20or\x20enforces\x20time-lock\x20(see\x20R-A-3-04).\x20Document\x20this\x20design\x20choice\x20explicitly.':'For\x20embedded\x20Allocation,\x20ensure\x20Service/Arbitration\x20permission\x20configuration\x20is\x20correct.\x20Document\x20this\x20design\x20choice\x20explicitly.','evidence':'BuiltinPermissionIndex\x20has\x20no\x20ALLOCATION_*\x20entries;\x20trigger_source='+(a['trigger_source']??'unknown'),'auto_fixable':![]};}},R_A_3_04={'id':'R-A-3-04','category':'authority','trigger':'Standalone\x20Allocation\x20(trigger_source=standalone)\x20with\x20Guard\x20lacking\x20both\x20Signer\x20binding\x20and\x20time-lock','check':b=>{if(b['trigger_source']!=='standalone')return null;if(!b['allocators_config'])return null;const c=[];for(const d of b['allocators_config']['allocators']){const e=b['guard_signer_bindings']?.[d['guard']]===!![],f=b['guard_has_time_lock']?.[d['guard']]===!![];!e&&!f&&c['push'](d['guard']);}if(c['length']===0x0)return null;return{'id':'R-A-3-04','level':'HIGH','category':'authority','title':'Standalone\x20Allocation:\x20'+c['length']+'\x20Guard(s)\x20lack\x20Signer\x20binding\x20AND\x20time-lock','description':'Standalone\x20Allocation\x20(trigger_source=standalone)\x20has\x20no\x20Service-layer\x20access\x20control.\x20The\x20following\x20Guard(s)\x20lack\x20both\x20Signer\x20binding\x20(context(Signer)==authorized)\x20and\x20time-lock\x20(context(Clock).timestamp>=unlock):\x20'+c['join'](',\x20')+'.\x20Anyone\x20who\x20passes\x20these\x20Guards\x20can\x20trigger\x20alloc()\x20and\x20receive\x20funds,\x20with\x20no\x20additional\x20authorization\x20layer.\x20This\x20is\x20the\x20most\x20severe\x20standalone-mode\x20risk.','affected_stakeholders':['owner','recipient','system'],'scenario':'Standalone\x20Allocation\x20created\x20with\x20weak\x20Guard\x20(no\x20Signer\x20binding,\x20no\x20time-lock)','mitigation':'Option\x20A\x20(preferred):\x20configure\x20Guard\x20to\x20bind\x20context(Signer)==authorized_address,\x20so\x20only\x20the\x20owner\x20can\x20trigger\x20alloc().\x20Option\x20B:\x20configure\x20Guard\x20with\x20time-lock\x20(context(Clock).timestamp>=unlock_time)\x20for\x20vesting-style\x20releases.\x20Option\x20C:\x20switch\x20to\x20embedded\x20mode\x20(via\x20Service)\x20to\x20leverage\x20Service-layer\x20access\x20control.\x20Until\x20fixed,\x20this\x20Allocation\x20should\x20not\x20receive\x20funds.','evidence':'trigger_source=standalone,\x20weakGuards='+c['join'](','),'related_guard_risk':'R-C3-06\x20(Signer\x20binding)\x20/\x20time-lock\x20patterns','auto_fixable':![]};}},R_A_4_01={'id':'R-A-4-01','category':'lifecycle','trigger':'caller-specified\x20guard\x20with\x20no\x20matching\x20Allocator\x20—\x20silent\x20return\x20causes\x20funds\x20to\x20be\x20stuck','check':a=>{if(!a['allocators_config'])return null;if(a['allocators_config']['allocators']['length']<=0x1)return null;if(a['has_fallback_allocator'])return null;return{'id':'R-A-4-01','level':'CRITICAL','category':'lifecycle','title':'caller-specified\x20guard\x20with\x20no\x20matching\x20Allocator\x20—\x20silent\x20return\x20causes\x20funds\x20to\x20be\x20stuck','description':'Multi-Allocation\x20configuration\x20('+a['allocators_config']['allocators']['length']+'\x20Allocators)\x20without\x20alternative\x20Allocator.\x20alloc()\x20is\x20driven\x20by\x20the\x20caller\x20explicitly\x20specifying\x20an\x20Allocator\x20via\x20alloc_by_guard:\x20if\x20the\x20guard\x20address\x20does\x20not\x20match\x20any\x20allocators[].guard,\x20alloc()\x20silently\x20returns\x20(no\x20error,\x20no\x20distribution),\x20funds\x20remain\x20stuck\x20in\x20Allocation.balance,\x20and\x20the\x20caller\x20gets\x20no\x20immediate\x20signal.\x20Linked\x20to\x20guard-risk.ts\x20R-X1-05.','affected_stakeholders':['owner','service_provider','system'],'scenario':'Caller\x20passes\x20a\x20guard\x20address\x20not\x20present\x20in\x20allocators[]\x20(e.g.\x20wrong\x20Guard\x20object,\x20or\x20order\x20state\x20not\x20matching\x20any\x20terminal\x20node)','mitigation':'1)\x20The\x20caller\x20should\x20verify\x20alloc_by_guard\x20∈\x20allocators[].guard\x20address\x20set\x20before\x20calling\x20alloc().\x202)\x20Provide\x20an\x20alternative\x20Allocator\x20and\x20document\x20the\x20caller\x27s\x20retry\x20strategy.\x203)\x20Caller\x20should\x20check\x20balance==0\x20after\x20alloc()\x20to\x20detect\x20no-match.','evidence':'allocators='+a['allocators_config']['allocators']['length']+',\x20hasFallback='+(a['has_fallback_allocator']??![]),'related_guard_risk':'R-X1-05','auto_fixable':![]};}},R_A_4_02={'id':'R-A-4-02','category':'lifecycle','trigger':'Multi-Allocation\x20without\x20mutually\x20exclusive\x20Guard\x20conditions\x20(design\x20clarity\x20issue,\x20not\x20a\x20correctness\x20requirement)','check':a=>{if(!a['allocators_config'])return null;if(a['allocators_config']['allocators']['length']<=0x1)return null;if(a['guard_conditions_mutually_exclusive'])return null;return{'id':'R-A-4-02','level':'MEDIUM','category':'lifecycle','title':'Multi-Allocation\x20without\x20mutually\x20exclusive\x20Guard\x20conditions','description':'Multi-Allocation\x20('+a['allocators_config']['allocators']['length']+'\x20Allocators)\x20without\x20verified\x20mutual\x20exclusion.\x20Under\x20caller-specified\x20guard\x20semantics,\x20the\x20caller\x20explicitly\x20selects\x20an\x20Allocator\x20via\x20alloc_by_guard,\x20so\x20there\x20is\x20no\x20correctness\x20problem\x20of\x20\x22the\x20latter\x20is\x20unreachable\x22;\x20however,\x20if\x20two\x20Guard\x20conditions\x20can\x20both\x20pass\x20simultaneously\x20and\x20the\x20caller\x20has\x20no\x20explicit\x20selection\x20strategy,\x20the\x20caller\x20may\x20be\x20confused\x20or\x20bind\x20to\x20an\x20unexpected\x20path.','affected_stakeholders':['owner'],'scenario':'Two\x20Guard\x20conditions\x20overlap\x20(e.g.\x20amount<1000\x20and\x20amount<500),\x20caller\x20Passport\x20satisfies\x20both','mitigation':'It\x20is\x20recommended\x20that\x20Guard\x20conditions\x20be\x20strictly\x20mutually\x20exclusive\x20(e.g.\x20amount<1000\x20vs\x20amount>=1000)\x20to\x20avoid\x20caller\x20confusion;\x20alternatively,\x20document\x20explicitly\x20which\x20path\x20the\x20caller\x20should\x20prefer.','evidence':'allocators='+a['allocators_config']['allocators']['length']+',\x20mutuallyExclusive='+(a['guard_conditions_mutually_exclusive']??![]),'auto_fixable':![]};}},R_A_4_03={'id':'R-A-4-03','category':'lifecycle','trigger':'Pure\x20Amount\x20mode\x20without\x20Surplus\x20—\x20residual\x20balance\x20reentrancy','check':b=>{if(!b['allocators_config'])return null;for(let c=0x0;c<b['allocators_config']['allocators']['length'];c++){const d=b['allocators_config']['allocators'][c],e=d['sharing']['length']>0x0&&d['sharing']['every'](f=>f['mode']==='Amount');if(!e)continue;return{'id':'R-A-4-03','level':'LOW','category':'lifecycle','title':'Pure\x20Amount\x20mode\x20without\x20Surplus\x20—\x20residual\x20balance\x20reentrancy','description':'Allocator\x20'+c+'\x20uses\x20pure\x20Amount\x20mode\x20(no\x20Rate,\x20no\x20Surplus).\x20After\x20alloc(),\x20if\x20fix\x20<\x20balance,\x20residual\x20funds\x20remain\x20in\x20Allocation.balance\x20and\x20can\x20be\x20claimed\x20by\x20re-triggering\x20alloc().\x20Linked\x20to\x20guard-risk.ts\x20reentrancy\x20LOW.','affected_stakeholders':['owner','system'],'scenario':'Pure\x20Amount\x20mode\x20leaves\x20residual\x20balance','mitigation':'1)\x20Preferred:\x20add\x20a\x20Surplus\x20sharing\x20to\x20absorb\x20remainder.\x202)\x20Or\x20use\x20Rate\x20mode.\x203)\x20Or\x20add\x20anti-reentrancy\x20Guard\x20check:\x20logic_not(query(\x27order.allocation\x20some\x27,\x20object=order)).','evidence':'allocator['+c+'].mode=pure-amount','related_guard_risk':'reentrancy\x20LOW','auto_fixable':![]};}return null;}},R_A_5_01={'id':'R-A-5-01','category':'cross_object','trigger':'Order\x20already\x20has\x20an\x20Allocation\x20bound\x20(1:1\x20constraint)','check':a=>{if(!a['order_already_has_allocation'])return null;return{'id':'R-A-5-01','level':'HIGH','category':'cross_object','title':'Order\x20already\x20has\x20an\x20Allocation\x20—\x201:1\x20constraint\x20violation','description':'Order\x20'+(a['bound_order']??'(unknown)')+'\x20already\x20has\x20an\x20Allocation\x20bound.\x20Move\x20layer\x20will\x20abort\x20with\x20E_ALLOCATION_ALREADY_SPECIFIED\x20(order.move)\x20when\x20attempting\x20to\x20bind\x20a\x20second\x20Allocation.','affected_stakeholders':['owner','service_provider'],'scenario':'Attempting\x20to\x20bind\x20a\x20second\x20Allocation\x20to\x20the\x20same\x20Order','mitigation':'Use\x20the\x20existing\x20Allocation,\x20or\x20unbind\x20it\x20first\x20(if\x20supported),\x20or\x20create\x20a\x20new\x20Order.','evidence':'bound_order='+(a['bound_order']??'unknown')+',\x20alreadyHasAllocation='+a['order_already_has_allocation'],'related_move_error':'E_ALLOCATION_ALREADY_SPECIFIED\x20(order.move)','auto_fixable':![]};}},R_A_5_02={'id':'R-A-5-02','category':'cross_object','trigger':'payment_info\x20missing\x20for\x20alloc()\x20—\x20ENO_PAYMENT_INFO','check':a=>{if(a['has_payment_info'])return null;if(a['operation_type']!=='alloc_by_guard')return null;return{'id':'R-A-5-02','level':'HIGH','category':'cross_object','title':'payment_info\x20missing\x20—\x20alloc()\x20will\x20abort\x20with\x20ENO_PAYMENT_INFO','description':'Allocation\x20has\x20no\x20payment_info\x20set.\x20Move\x20alloc()\x20requires\x20payment_info.is_some()\x20at\x20step\x201\x20(pre_check).\x20The\x20entire\x20alloc()\x20transaction\x20will\x20revert,\x20funds\x20remain\x20in\x20Allocation.','affected_stakeholders':['owner'],'scenario':'Triggering\x20alloc()\x20before\x20setting\x20payment_info','mitigation':'Ensure\x20payment_info\x20is\x20set\x20during\x20Allocation\x20creation\x20(CallAllocation_Create\x20requires\x20payment_info\x20field).','evidence':'has_payment_info='+(a['has_payment_info']??![]),'related_move_error':'ENO_PAYMENT_INFO\x20(9)','auto_fixable':![]};}},R_A_5_03={'id':'R-A-5-03','category':'cross_object','trigger':'MAX_ALLOCATOR_COUNT\x20not\x20synced\x20to\x20onchain-constants.ts','check':a=>{return{'id':'R-A-5-03','level':'LOW','category':'cross_object','title':'MAX_ALLOCATOR_COUNT\x20not\x20synced\x20to\x20onchain-constants.ts','description':'Move\x20layer\x20allocation.move:16\x20defines\x20MAX_ALLOCATOR_COUNT='+MAX_ALLOCATOR_COUNT+',\x20but\x20onchain-constants.ts\x20does\x20NOT\x20export\x20this\x20constant.\x20SDK\x20allocation.ts:318\x20defines\x20it\x20locally,\x20creating\x20a\x20double-definition\x20risk.\x20MCP\x20knowledge\x20imports\x20the\x20local\x20definition.','affected_stakeholders':['system'],'scenario':'Constant\x20sync\x20drift\x20between\x20Move\x20/\x20SDK\x20/\x20MCP','mitigation':'1)\x20Add\x20MAX_ALLOCATOR_COUNT=100\x20to\x20onchain-constants.ts.\x202)\x20Update\x20SDK\x20allocation.ts\x20to\x20import\x20from\x20onchain-constants.js.\x203)\x20Delete\x20local\x20definition.','evidence':'MAX_ALLOCATOR_COUNT='+MAX_ALLOCATOR_COUNT+'\x20(local),\x20not\x20in\x20onchain-constants.ts','auto_fixable':!![]};}},ALL_RULES=[R_A_1_01,R_A_1_02,R_A_1_03,R_A_2_01,R_A_2_02,R_A_2_03,R_A_2_04,R_A_3_01,R_A_3_02,R_A_3_03,R_A_3_04,R_A_4_01,R_A_4_02,R_A_4_03,R_A_5_01,R_A_5_02,R_A_5_03];export const ALLOCATION_RISK_VERSION='1.1.0';export function getAllRiskRules(){return[...ALL_RULES];}export function assessAllocationRisks(a){const b=[];for(const g of ALL_RULES){const h=g['check'](a);if(h)b['push'](h);}const c=b['length']===0x0?'LOW':b['some'](i=>i['level']==='CRITICAL')?'CRITICAL':b['some'](i=>i['level']==='HIGH')?'HIGH':b['some'](i=>i['level']==='MEDIUM')?'MEDIUM':'LOW',d={},e={};for(const i of b){d[i['category']]=(d[i['category']]??0x0)+0x1,e[i['level']]=(e[i['level']]??0x0)+0x1;}const f={};for(const j of b){for(const k of j['affected_stakeholders']){if(!f[k])f[k]=[];f[k]['push'](j['id']+':\x20'+j['mitigation']);}}return{'summary':'Assessed\x20'+b['length']+'\x20risk(s)\x20across\x20'+Object['keys'](d)['length']+'\x20categories','risks':b,'overall_risk':c,'risks_by_category':d,'risks_by_level':e,'stakeholder_advice':f,'needs_human_review':b['some'](l=>l['level']==='CRITICAL'||l['level']==='HIGH'),'blocks_publish':b['some'](l=>l['level']==='CRITICAL')};}export{ALLOCATION_ERROR_CODES};
1
+ import{MAX_ALLOCATOR_COUNT,RATE_TOTAL_FULL,ALLOCATION_ERROR_CODES}from'./allocation-ledger.js';import{isUnboundSignerTheft}from'./recipient-constraint.js';import{getJudgmentDoc,factoryRulePack}from'../config/judgment.js';import{evaluateRuleBook,evaluateCondition}from'../config/rule-engine.js';const AUTO_FIXABLE=new Set(['R-A-1-02#0','R-A-1-02#1','R-A-1-03#0','R-A-1-03#2','R-A-2-03#0','R-A-5-03#0']),RELATED_MOVE_ERROR={'R-A-1-01#0':'EALLOCATORS_EMPTY\x20(8)\x20/\x20ENO_ALLOCATOR\x20(3)','R-A-1-01#1':'ENO_ALLOCATOR\x20(3)','R-A-1-02#0':'ERATE_NOT_10000\x20(4)','R-A-1-02#1':'ERATE_EXCEEDS_10000\x20(6)','R-A-1-03#0':'EMULTIPLE_SURPLUS\x20(5)','R-A-1-03#1':'EAMOUNT_BELOW_THRESHOLD\x20(12)','R-A-1-03#2':'EAMOUNT_EXCEEDS_MAX\x20(13)','R-A-2-02#0':'ERECIPIENT_IDENTIFIER_NOT_ADDRESS\x20(1)','R-A-2-04#0':'ERECIPIENT_NOT_FOR_OBJECT\x20(15)','R-A-2-04#1':'ERECIPIENT_NOT_FOR_OBJECT\x20(15,\x20only\x20fires\x20when\x20a\x20binding\x20is\x20declared)','R-A-5-01#0':'E_ALLOCATION_ALREADY_SPECIFIED','R-A-5-02#0':'ENO_PAYMENT_INFO\x20(9)'},RELATED_GUARD_RISK={'R-A-2-01#0':'R-C3-06','R-A-3-04#0':'R-C3-06\x20(Signer\x20binding)\x20/\x20time-lock\x20patterns','R-A-4-01#0':'R-X1-05','R-A-4-03#0':'reentrancy\x20low'};export function allocationRiskFacts(b){const c=b['allocators_config'],d=!!c,e=d?c['allocators']:[];let f,g;if(d&&e['length']>0x0)for(let P=0x0;P<e['length'];P++){if(e[P]['sharing']['length']===0x0){f=P,g=e[P]['guard'];break;}}let h,j,k,l=![],m=![];if(d)for(let Q=0x0;Q<e['length'];Q++){const R=e[Q],S=R['sharing']['filter'](U=>U['mode']==='Rate')['reduce']((U,V)=>U+Number(V['sharing']),0x0),T=R['sharing']['some'](U=>U['mode']==='Surplus');if(!T&&S>0x0&&S!==RATE_TOTAL_FULL){h=Q,j=R['guard'],k=S,l=!![];break;}if(T&&S>RATE_TOTAL_FULL){h=Q,j=R['guard'],k=S,m=!![];break;}}let n,o,p,q,r,t,u;if(d){const U=Number(c['threshold']);for(let V=0x0;V<e['length'];V++){const W=e[V],X=W['sharing']['filter'](Z=>Z['mode']==='Surplus')['length'];if(X>0x1){n='multiple_surplus',o=V,p=W['guard'],q=X;break;}const Y=W['sharing']['filter'](Z=>Z['mode']==='Amount')['reduce']((Z,a0)=>Z+Number(a0['sharing']),0x0);if(Y>0x0&&Y<U){n='below_threshold',o=V,p=W['guard'],r=Y,t=U;break;}if(W['max']!=null&&Y>Number(W['max'])){n='exceeds_max',o=V,p=W['guard'],r=Y,u=Number(W['max']);break;}}}let v=![],w,x,y;if(d)for(let Z=0x0;Z<e['length'];Z++){const a0=e[Z],a1=a0['sharing']['some'](a3=>'Signer'in a3['who']),a2=b['guard_signer_bindings']?.[a0['guard']]===!![];if(isUnboundSignerTheft({'recipient_is_signer':a1,'caller_identity_constrained':a2})){v=!![],w=Z,x=a0['guard'],y=a2;break;}}let z,A,B;if(d&&b['passport_identifier_types'])for(let a3=0x0;a3<e['length'];a3++){const a4=e[a3],a5=a4['sharing']['find'](a8=>'GuardIdentifier'in a8['who']);if(!a5)continue;const a6=a5['who']['GuardIdentifier'],a7=b['passport_identifier_types'][a6];if(a7!==undefined&&a7!=='address'){z=a6,A=a7,B=a3;break;}}let C=![],D,E,F,G;if(d){const a8=e['map'](aa=>aa['guard']),a9=new Set(a8);if(a9['size']!==a8['length']){const aa=a8['filter']((ab,ad)=>a8['indexOf'](ab)!==ad);C=!![],D=a8['length'],E=a9['size'],F=aa['join'](',\x20'),G=aa['join'](',');}}const H=b['payment_info_for_object']!==undefined,I=d&&e['some'](ab=>ab['sharing']['some'](ad=>'GuardIdentifier'in ad['who'])),J=!!b['payment_info_for_object'];let K=![],L,M;if(d&&b['referenced_treasuries_permissions']&&b['host_service_permission'])for(const ab of e){for(const ad of ab['sharing']){if(!(ad['who']!==null&&typeof ad['who']==='object'&&'Entity'in ad['who']))continue;const ae=ad['who']['Entity'],af=b['referenced_treasuries_permissions'][ae];if(af&&af!==b['host_service_permission']){K=!![],L=ae,M=af;break;}}if(K)break;}let N;if(b['trigger_source']==='standalone'&&d){const ag=[];for(const ah of e){const ai=b['guard_signer_bindings']?.[ah['guard']]===!![],aj=b['guard_has_time_lock']?.[ah['guard']]===!![];if(!ai&&!aj)ag['push'](ah['guard']);}N=ag;}let O;if(d)for(let ak=0x0;ak<e['length'];ak++){const al=e[ak],am=al['sharing']['length']>0x0&&al['sharing']['every'](an=>an['mode']==='Amount');if(am){O=ak;break;}}return{'allocators_config_present':d,'allocators_count':d?e['length']:undefined,'allocators_empty':d&&e['length']===0x0,'empty_sharing_allocator_index':f,'empty_sharing_allocator_guard':g,'rate_rule_index':h,'rate_rule_guard':j,'rate_rule_sum':k,'rate_rule_pure':l,'rate_rule_exceed':m,'rate_total_full':RATE_TOTAL_FULL,'amount_rule_branch':n,'amount_rule_index':o,'amount_rule_guard':p,'amount_rule_surplus_count':q,'amount_rule_amount_sum':r,'amount_rule_threshold':t,'amount_rule_max':u,'signer_theft_detected':v,'signer_theft_index':w,'signer_theft_guard':x,'signer_theft_guard_bound':y,'guard_id_bad_identifier':z,'guard_id_bad_type':A,'guard_id_bad_index':B,'duplicate_guards_present':C,'allocators_total':D,'allocators_unique':E,'duplicate_guards_csv_sp':F,'duplicate_guards_csv':G,'for_object_anchor_known':H,'guard_identifier_recipient_present':I,'for_object_anchor_set':J,'for_object_anchor':H&&J?b['payment_info_for_object']??undefined:undefined,'host_service_published':b['host_service_published'],'treasury_perm_mismatch':K,'treasury_perm_entity':L,'treasury_perm_treasury':M,'host_service_permission':b['host_service_permission'],'allocation_create_op':b['operation_type']==='create','allocation_standalone':b['trigger_source']==='standalone','trigger_source_display':b['trigger_source']??'unknown','standalone_weak_guards_count':N?.['length'],'standalone_weak_guards_csv_sp':N?.['join'](',\x20'),'standalone_weak_guards_csv':N?.['join'](','),'has_fallback_allocator':b['has_fallback_allocator'],'guard_conditions_mutually_exclusive':b['guard_conditions_mutually_exclusive'],'has_fallback_allocator_display':String(b['has_fallback_allocator']??![]),'mutually_exclusive_display':String(b['guard_conditions_mutually_exclusive']??![]),'pure_amount_index':O,'order_already_has_allocation':b['order_already_has_allocation'],'bound_order_display':b['bound_order']??'unknown','bound_order_paren_display':b['bound_order']??'(unknown)','has_payment_info':b['has_payment_info'],'operation_type':b['operation_type'],'max_allocator_count':MAX_ALLOCATOR_COUNT,'always_true':!![]};}function allocationRuleBook(){const a=getJudgmentDoc()['rules']['domains']['allocation'];if(!a)throw new Error('factory\x20rule\x20pack\x20\x27allocation\x27\x20missing\x20—\x20broken\x20installation');return a['rules'];}function firedCaseKey(a,b,c){const d=a['find'](e=>e['rule_id']===c);if(d)for(let e=0x0;e<d['cases']['length'];e++){if(evaluateCondition(d['cases'][e]['when'],b))return c+'#'+e;}return c+'#0';}function findingToAllocationRisk(a,b){const c=RELATED_MOVE_ERROR[b],d=RELATED_GUARD_RISK[b];return{'id':a['rule_id'],'level':a['level'],'category':a['dimension']??'structural','title':a['title'],'description':a['description'],'affected_stakeholders':a['stakeholders']??[],'scenario':a['scenario']??'','mitigation':a['mitigation']??'','evidence':a['evidence'],...c!==undefined?{'related_move_error':c}:{},...d!==undefined?{'related_guard_risk':d}:{},'auto_fixable':AUTO_FIXABLE['has'](b),...a['exposure']!=null?{'exposure':a['exposure']}:{}};}export const ALLOCATION_RISK_VERSION='1.1.0';export function getAllRiskRules(){const a=factoryRulePack('allocation');if(!a)return[];return a['rules']['map'](b=>({'id':b['rule_id'],'category':b['dimension']??'structural','trigger':b['trigger']??'','check':c=>{const d=allocationRiskFacts(c),{findings:e}=evaluateRuleBook([b],d);return e['length']>0x0?findingToAllocationRisk(e[0x0],firedCaseKey([b],d,b['rule_id'])):null;}}));}export function assessAllocationRisks(a){const b=allocationRuleBook(),c=allocationRiskFacts(a),{findings:d}=evaluateRuleBook(b,c),e=d['map'](j=>findingToAllocationRisk(j,firedCaseKey(b,c,j['rule_id']))),f=e['length']===0x0?'low':e['some'](j=>j['level']==='critical')?'critical':e['some'](j=>j['level']==='high')?'high':e['some'](j=>j['level']==='medium')?'medium':'low',g={},h={};for(const j of e){g[j['category']]=(g[j['category']]??0x0)+0x1,h[j['level']]=(h[j['level']]??0x0)+0x1;}const i={};for(const k of e){for(const l of k['affected_stakeholders']){if(!i[l])i[l]=[];i[l]['push'](k['id']+':\x20'+k['mitigation']);}}return{'summary':'Assessed\x20'+e['length']+'\x20risk(s)\x20across\x20'+Object['keys'](g)['length']+'\x20categories','risks':e,'overall_risk':f,'risks_by_category':g,'risks_by_level':h,'stakeholder_advice':i,'needs_human_review':e['some'](m=>m['level']==='critical'||m['level']==='high'),'blocks_publish':e['some'](m=>m['level']==='critical')};}export{ALLOCATION_ERROR_CODES};
@@ -1 +1 @@
1
- export const ALLOCATION_TEMPLATES=[{'id':'T-A-01','name':'Single\x20Rate\x20100%\x20to\x20Treasury','description':'Simplest\x20allocation\x20—\x20single\x20Allocator,\x20single\x20Rate=10000\x20sharing\x20to\x20one\x20Treasury/personal\x20address','applicable_scenes':['allocation_merchant_full_payment'],'industry_tags':['universal','retail','service'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(e.g.\x20\x270x2::wow::WOW\x27)','required':!![]},{'name':'recipient_address','type':'address','description':'Treasury\x20or\x20personal\x20wallet\x20address\x20to\x20receive\x20100%','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20order\x20completion)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Single\x20Rate\x20100%\x20allocation'}],'body':a=>({'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Single\x20Rate\x20100%\x20allocation','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['recipient_address']},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}}),'notes':['Simplest\x20configuration\x20—\x20no\x20multi-party\x20coordination','Guard\x20only\x20needs\x20to\x20verify\x20order\x20status,\x20no\x20complex\x20conditions','Suitable\x20for\x20solo\x20merchants\x20or\x20single-treasury\x20services']},{'id':'T-A-02','name':'Standard\x203-way\x20Rate\x20split','description':'Three-way\x20split:\x20merchant\x20/\x20platform\x20/\x20logistics.\x20Pure\x20Rate\x20mode,\x20sum(rates)\x20MUST\x20equal\x2010000','applicable_scenes':['allocation_standard_three_way_split'],'industry_tags':['retail','ecommerce','logistics'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address','required':!![]},{'name':'platform_treasury','type':'address','description':'Platform\x20Treasury\x20address','required':!![]},{'name':'logistics_treasury','type':'address','description':'Logistics\x20Treasury\x20address\x20(set\x20to\x20platform_treasury\x20if\x20N/A)','required':!![]},{'name':'merchant_rate','type':'number','description':'Merchant\x20rate\x20in\x20basis\x20points\x20(e.g.\x208000\x20=\x2080%)','required':!![],'default':0x1f40},{'name':'platform_rate','type':'number','description':'Platform\x20rate\x20in\x20basis\x20points\x20(e.g.\x201000\x20=\x2010%)','required':!![],'default':0x3e8},{'name':'logistics_rate','type':'number','description':'Logistics\x20rate\x20in\x20basis\x20points\x20(e.g.\x201000\x20=\x2010%)','required':!![],'default':0x3e8},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20order\x20completion\x20+\x20service\x20binding)','required':!![]}],'body':a=>{const b=Number(a['merchant_rate']),c=Number(a['platform_rate']),d=Number(a['logistics_rate']),e=b+c+d;if(e!==0x2710)throw new Error('T-A-02:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(RATE_TOTAL_FULL),\x20got\x20'+e+'\x20'+('(merchant='+b+'\x20+\x20platform='+c+'\x20+\x20logistics='+d+')'));return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'3-way\x20split:\x20merchant\x20'+b+'/10000,\x20platform\x20'+c+'/10000,\x20logistics\x20'+d+'/10000','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['merchant_treasury']},'sharing':String(b),'mode':'Rate'},{'who':{'Entity':a['platform_treasury']},'sharing':String(c),'mode':'Rate'},{'who':{'Entity':a['logistics_treasury']},'sharing':String(d),'mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-05:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(pure\x20Rate\x20mode,\x20no\x20Surplus)','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-3-02)','Guard\x20should\x20verify\x20order.service\x20binding\x20(query\x201563)\x20to\x20prevent\x20cross-project\x20bypass']},{'id':'T-A-03','name':'Refund-first\x20+\x20Surplus-to-merchant\x20(Amount\x20+\x20Surplus\x20hybrid)','description':'Single\x20Allocator\x20with\x202\x20sharing\x20items:\x20Amount=refund_value\x20to\x20customer,\x20Surplus\x20to\x20merchant','applicable_scenes':['allocation_refund_first_surplus_to_merchant'],'industry_tags':['retail','refund','customer_protection'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'customer_address','type':'address','description':'Customer\x20address\x20to\x20receive\x20refund\x20Amount','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address\x20to\x20receive\x20Surplus','required':!![]},{'name':'refund_amount','type':'number','description':'Refund\x20amount\x20in\x20smallest\x20coin\x20unit\x20(e.g.\x20MIST\x20for\x20WOW)','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20refund\x20approval)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Refund-first\x20+\x20Surplus-to-merchant'}],'body':a=>{const b=Number(a['refund_amount']);if(b<=0x0)throw new Error('T-A-03:\x20refund_amount\x20MUST\x20be\x20>\x200,\x20got\x20'+b);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Refund-first\x20+\x20Surplus-to-merchant','threshold':String(b),'allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['customer_address']},'sharing':String(b),'mode':'Amount'},{'who':{'Entity':a['merchant_treasury']},'sharing':'0','mode':'Surplus'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(✓\x20single\x20Surplus\x20here)','F-A-07:\x20threshold\x20=\x20refundAmount\x20(ensure\x20balance\x20covers\x20Amount)','fix\x20is\x20cached\x20as\x20refundAmount\x20at\x20allocator_add\x20time','Guard\x20must\x20verify\x20customer\x20refund\x20eligibility\x20(e.g.\x20order\x20status\x20=\x20Refunded)']},{'id':'T-A-04','name':'Treasury\x20+\x20Personal\x20alternative\x20(caller-specified\x20guard,\x202\x20Allocators)','description':'2\x20Allocators\x20as\x20alternative\x20strategies:\x20caller\x20selects\x20Treasury\x20or\x20Personal\x20wallet\x20via\x20alloc_by_guard\x20(hard\x20verification\x20per\x20call)','applicable_scenes':['allocation_treasury_personal_alternatives'],'industry_tags':['universal','alternative','treasury'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'treasury_address','type':'address','description':'Treasury\x20address\x20(primary\x20recipient)','required':!![]},{'name':'personal_address','type':'address','description':'Personal\x20wallet\x20address\x20(alternative\x20recipient)','required':!![]},{'name':'treasury_guard','type':'address','description':'Guard\x20for\x20Treasury\x20path\x20(verifies\x20treasury\x20operational)','required':!![]},{'name':'personal_guard','type':'address','description':'Guard\x20for\x20Personal\x20path\x20(verifies\x20personal\x20wallet\x20active)\x20—\x20MUST\x20differ\x20from\x20treasury_guard','required':!![]}],'body':a=>{if(a['treasury_guard']===a['personal_guard'])throw new Error('T-A-04:\x20treasury_guard\x20and\x20personal_guard\x20MUST\x20be\x20different\x20addresses\x20(F-A-14:\x20allocators[].guard\x20must\x20be\x20unique)');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Treasury\x20/\x20Personal\x20alternative\x20(caller-specified\x20guard)','threshold':'0','allocators':[{'guard':a['treasury_guard'],'sharing':[{'who':{'Entity':a['treasury_address']},'sharing':'10000','mode':'Rate'}],'max':null},{'guard':a['personal_guard'],'sharing':[{'who':{'Entity':a['personal_address']},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-14:\x20treasury_guard\x20!=\x20personal_guard\x20(Allocator\x20Guards\x20must\x20be\x20unique)','caller-specified\x20guard:\x20alloc_by_guard\x20explicitly\x20selects\x20an\x20Allocator;\x20passport::result_for_guard\x20hard-verifies\x20(failure\x20aborts\x20E_VERIFY_FAILED)','No\x20auto-fallback:\x20on\x20verification\x20failure\x20the\x20caller\x20must\x20switch\x20guard\x20and\x20retry','R-A-4-02:\x20if\x20the\x20caller\x27s\x20submitted\x20Passport\x20satisfies\x20both\x20Guards\x20simultaneously,\x20the\x20caller\x20may\x20freely\x20choose\x20between\x20the\x20two\x20paths\x20(mutual\x20exclusion\x20is\x20a\x20design\x20clarity\x20recommendation,\x20not\x20a\x20correctness\x20requirement)']},{'id':'T-A-05','name':'Tiered\x20by\x20order\x20amount\x20(mutually\x20exclusive\x20Guard\x20conditions)','description':'2\x20Allocators\x20triggered\x20by\x20mutually\x20exclusive\x20Guard\x20conditions\x20(small\x20order\x20vs\x20large\x20order)','applicable_scenes':['allocation_tiered_by_order_amount'],'industry_tags':['retail','tiered_pricing','volume_discount'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address','required':!![]},{'name':'platform_treasury','type':'address','description':'Platform\x20Treasury\x20address','required':!![]},{'name':'small_order_guard','type':'address','description':'Guard\x20verifying\x20order.amount\x20<\x20threshold\x20(small\x20order\x20path)','required':!![]},{'name':'large_order_guard','type':'address','description':'Guard\x20verifying\x20order.amount\x20>=\x20threshold\x20(large\x20order\x20path)\x20—\x20MUST\x20differ\x20from\x20small_order_guard','required':!![]},{'name':'small_order_merchant_rate','type':'number','description':'Merchant\x20rate\x20for\x20small\x20orders\x20(e.g.\x2010000\x20=\x20100%)','required':!![],'default':0x2710},{'name':'large_order_merchant_rate','type':'number','description':'Merchant\x20rate\x20for\x20large\x20orders\x20(e.g.\x208000\x20=\x2080%)','required':!![],'default':0x1f40},{'name':'large_order_platform_rate','type':'number','description':'Platform\x20rate\x20for\x20large\x20orders\x20(e.g.\x202000\x20=\x2020%)','required':!![],'default':0x7d0}],'body':a=>{if(a['small_order_guard']===a['large_order_guard'])throw new Error('T-A-05:\x20small_order_guard\x20and\x20large_order_guard\x20MUST\x20be\x20different\x20addresses\x20(F-A-14)');const b=Number(a['small_order_merchant_rate']);if(b!==0x2710)throw new Error('T-A-05:\x20small_order_merchant_rate\x20MUST\x20equal\x2010000\x20(pure\x20Rate,\x20no\x20Surplus\x20in\x20this\x20Allocator),\x20got\x20'+b);const c=Number(a['large_order_merchant_rate']),d=Number(a['large_order_platform_rate']),e=c+d;if(e!==0x2710)throw new Error('T-A-05:\x20large_order\x20rates\x20MUST\x20sum\x20to\x2010000,\x20got\x20'+e+'\x20(merchant='+c+'\x20+\x20platform='+d+')');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Tiered\x20by\x20order\x20amount:\x20small=100%\x20merchant,\x20large=80/20\x20merchant/platform','threshold':'0','allocators':[{'guard':a['small_order_guard'],'sharing':[{'who':{'Entity':a['merchant_treasury']},'sharing':'10000','mode':'Rate'}],'max':null},{'guard':a['large_order_guard'],'sharing':[{'who':{'Entity':a['merchant_treasury']},'sharing':String(c),'mode':'Rate'},{'who':{'Entity':a['platform_treasury']},'sharing':String(d),'mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Guard\x20conditions\x20MUST\x20be\x20mutually\x20exclusive\x20(R-A-4-02)','Sequence-sensitive:\x20strict\x20condition\x20(small\x20order)\x20first,\x20relaxed\x20condition\x20(large\x20order)\x20last','Guard\x20queries\x20order.amount\x20(query\x201561)\x20to\x20determine\x20which\x20Allocator\x20fires','If\x20neither\x20Guard\x20passes,\x20funds\x20are\x20silently\x20locked\x20(R-A-4-02)']},{'id':'T-A-06','name':'Dynamic\x20recipient\x20via\x20GuardIdentifier\x20(referrer\x20from\x20Passport)','description':'Single\x20Allocator\x20with\x203\x20Rate\x20sharing\x20items,\x20one\x20recipient\x20resolved\x20from\x20customer\x27s\x20Passport\x20table[0]','applicable_scenes':['allocation_dynamic_recipient'],'industry_tags':['referral','affiliate','marketing'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address','required':!![]},{'name':'platform_treasury','type':'address','description':'Platform\x20Treasury\x20address','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(must\x20be\x20configured\x20with\x20identifier=0\x20as\x20address\x20type)','required':!![]},{'name':'passport_identifier','type':'number','description':'Passport\x20table\x20identifier\x20(u8,\x200-255)\x20—\x20customer\x20submits\x20referrer\x20address\x20at\x20this\x20slot','required':!![],'default':0x0},{'name':'merchant_rate','type':'number','description':'Merchant\x20rate\x20in\x20basis\x20points\x20(e.g.\x208000\x20=\x2080%)','required':!![],'default':0x1f40},{'name':'platform_rate','type':'number','description':'Platform\x20rate\x20in\x20basis\x20points\x20(e.g.\x201000\x20=\x2010%)','required':!![],'default':0x3e8},{'name':'referrer_rate','type':'number','description':'Referrer\x20rate\x20in\x20basis\x20points\x20(e.g.\x201000\x20=\x2010%)','required':!![],'default':0x3e8}],'body':a=>{const b=Number(a['merchant_rate']),c=Number(a['platform_rate']),d=Number(a['referrer_rate']),e=b+c+d;if(e!==0x2710)throw new Error('T-A-06:\x20sum(rates)\x20MUST\x20equal\x2010000,\x20got\x20'+e+'\x20(merchant='+b+'\x20+\x20platform='+c+'\x20+\x20referrer='+d+')');const f=Number(a['passport_identifier']);if(f<0x0||f>0xff)throw new Error('T-A-06:\x20passport_identifier\x20MUST\x20be\x20u8\x20(0-255),\x20got\x20'+f);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Dynamic\x20recipient:\x20merchant\x20'+b+'/10000,\x20platform\x20'+c+'/10000,\x20referrer\x20'+d+'/10000\x20(from\x20Passport\x20identifier='+f+')','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['merchant_treasury']},'sharing':String(b),'mode':'Rate'},{'who':{'Entity':a['platform_treasury']},'sharing':String(c),'mode':'Rate'},{'who':{'GuardIdentifier':f},'sharing':String(d),'mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-13:\x20Passport\x20table[identifier]\x20MUST\x20be\x20address\x20type\x20(else\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS=1)','Guard.is_identifier_address(guard,\x20identifier)\x20MUST\x20be\x20true\x20at\x20allocator_add\x20time\x20(else\x20allocator_add\x20fails)','Customer\x20must\x20submit\x20Passport\x20with\x20referrer\x20address\x20at\x20the\x20specified\x20identifier\x20slot','Guard\x20should\x20verify\x20Passport\x20completeness\x20before\x20alloc()\x20executes']},{'id':'T-A-07','name':'Refund\x20to\x20the\x20submitted\x20Order\x20(100%\x20delivered\x20to\x20the\x20order\x20as\x20escrow)','description':'Single\x20Allocator,\x201\x20Rate=10000\x20sharing\x20whose\x20recipient\x20is\x20the\x20order\x20submitted\x20at\x20alloc\x20time\x20(Guard\x20table\x20identifier\x200).\x20The\x20funds\x20are\x20delivered\x20to\x20that\x20order\x20and\x20received\x20by\x20its\x20owner.','applicable_scenes':['allocation_refund_to_order'],'industry_tags':['refund','customer_protection','order_lifecycle'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20verifying\x20the\x20submitted\x20order\x20qualifies\x20(e.g.\x20order\x20at\x20the\x20refund\x20node,\x20order.service\x20==\x20host\x20service).\x20Its\x20table\x20needs\x20an\x20address-typed\x20b_submission\x20slot\x20at\x20identifier\x200.','required':!![]}],'body':a=>({'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Refund\x20to\x20the\x20submitted\x20Order\x20(100%\x20delivered\x20to\x20the\x20order\x20as\x20escrow)','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'GuardIdentifier':0x0},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}}),'notes':['The\x20Guard\x20table\x20MUST\x20have\x20an\x20address-typed\x20b_submission\x20slot\x20at\x20identifier\x200\x20carrying\x20the\x20submitted\x20order\x20(else\x20allocator_add\x20fails\x20with\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS).','At\x20alloc\x20time\x20the\x20full\x20Rate\x20is\x20delivered\x20to\x20the\x20submitted\x20order\x20as\x20a\x20CoinWrapper\x20—\x20the\x20order\x20object\x20owns\x20it.\x20Its\x20owner\x20subsequently\x20receives\x20the\x20bare\x20coins\x20through\x20the\x20order\x27s\x20owner-receive\x20entry;\x20unrelated\x20addresses\x20cannot\x20intercept.','The\x20Guard\x20decides\x20which\x20submitted\x20orders\x20qualify:\x20node\x20state\x20plus\x20a\x20service-scope\x20binding\x20(order.service\x20==\x20host\x20service)\x20are\x20the\x20typical\x20conditions;\x20tightening\x20those\x20conditions\x20is\x20how\x20the\x20destination\x20is\x20controlled.','When\x20the\x20per-order\x20Allocation\x20is\x20created\x20through\x20the\x20Service\x20flow,\x20payment_info.for_object\x20is\x20set\x20to\x20the\x20order\x20the\x20allocation\x20belongs\x20to,\x20recording\x20the\x20business\x20context\x20auditors\x20can\x20query.']},{'id':'T-A-08','name':'Arbitration\x20fees\x20split\x20(arbitrator\x2080%\x20/\x20platform\x2020%)','description':'Single\x20Allocator,\x202\x20Rate\x20sharing\x20items.\x20Triggered\x20by\x20Arbitration.fees_alloc\x20(permission\x20365)\x20or\x20fees_alloc_with_passport.','applicable_scenes':['allocation_arbitration_fees'],'industry_tags':['arbitration','dispute','fees'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(must\x20match\x20Arbitration\x20fee\x20Coin\x20type)','required':!![]},{'name':'arbitrator_treasury','type':'address','description':'Arbitrator\x20Treasury\x20address','required':!![]},{'name':'platform_treasury','type':'address','description':'Platform\x20Treasury\x20address','required':!![]},{'name':'arbitrator_rate','type':'number','description':'Arbitrator\x20rate\x20in\x20basis\x20points\x20(e.g.\x208000\x20=\x2080%)','required':!![],'default':0x1f40},{'name':'platform_rate','type':'number','description':'Platform\x20rate\x20in\x20basis\x20points\x20(e.g.\x202000\x20=\x2020%)','required':!![],'default':0x7d0},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20Arbitration\x20ruling\x20finalized)','required':!![]}],'body':a=>{const b=Number(a['arbitrator_rate']),c=Number(a['platform_rate']),d=b+c;if(d!==0x2710)throw new Error('T-A-08:\x20sum(rates)\x20MUST\x20equal\x2010000,\x20got\x20'+d+'\x20(arbitrator='+b+'\x20+\x20platform='+c+')');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Arbitration\x20fees\x20split:\x20arbitrator\x20'+b+'/10000,\x20platform\x20'+c+'/10000','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['arbitrator_treasury']},'sharing':String(b),'mode':'Rate'},{'who':{'Entity':a['platform_treasury']},'sharing':String(c),'mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Triggered\x20by\x20Arbitration.fees_alloc\x20(permission\x20ARBITRATION_FEES_ALLOC=365)\x20or\x20fees_alloc_with_passport','Independent\x20from\x20Service-order\x20Allocation\x20(this\x20Allocation\x20is\x20not\x20bound\x20to\x20Order)','payment_info\x20typically\x20reuses\x20Arbitration\x27s\x20payment_info','Caller\x20MUST\x20hold\x20ARBITRATION_FEES_ALLOC=365\x20permission']},{'id':'T-A-09','name':'Standalone\x20periodic\x20split\x20(investment\x20dividends\x20/\x20shared\x20income)','description':'Standalone\x20Allocation\x20with\x20single\x20Allocator,\x20N\x20Rate\x20sharing\x20items\x20to\x20beneficiary\x20wallets.\x20No\x20Service\x20context.\x20Guard\x20provides\x20time-based\x20or\x20signer-based\x20access\x20control.','applicable_scenes':['allocation_standalone_periodic_split'],'industry_tags':['standalone','investment','dividends','shared_income'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(e.g.\x20\x270x2::wow::WOW\x27\x20or\x20profit\x20token\x20type)','required':!![]},{'name':'beneficiaries','type':'address[]','description':'Array\x20of\x20beneficiary\x20wallet\x20addresses\x20(NOT\x20Treasury\x20objects\x20—\x20standalone\x20mode\x20has\x20no\x20Service\x20context)','required':!![]},{'name':'rates','type':'string[]','description':'Array\x20of\x20rates\x20in\x20basis\x20points\x20(e.g.\x20[\x275000\x27,\x273000\x27,\x272000\x27]\x20=\x2050%/30%/20%).\x20MUST\x20sum\x20to\x2010000.','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20—\x20MUST\x20bind\x20Signer\x20or\x20verify\x20time-based\x20trigger\x20(R-A-3-04:\x20standalone\x20has\x20no\x20Service-layer\x20access\x20control)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Standalone\x20periodic\x20split'}],'body':a=>{const b=a['beneficiaries'],c=a['rates']['map'](e=>Number(e));if(b['length']!==c['length'])throw new Error('T-A-09:\x20beneficiaries\x20('+b['length']+')\x20and\x20rates\x20('+c['length']+')\x20MUST\x20have\x20equal\x20length');if(b['length']===0x0)throw new Error('T-A-09:\x20at\x20least\x201\x20beneficiary\x20required');if(b['length']>0x64)throw new Error('T-A-09:\x20beneficiaries\x20count\x20'+b['length']+'\x20exceeds\x20MAX_SHARING_COUNT\x20(100)');const d=c['reduce']((e,f)=>e+f,0x0);if(d!==0x2710)throw new Error('T-A-09:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(RATE_TOTAL_FULL),\x20got\x20'+d);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Standalone\x20periodic\x20split','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':b['map']((e,f)=>({'who':{'Entity':e},'sharing':String(c[f]),'mode':'Rate'})),'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Standalone\x20mode\x20(§0):\x20no\x20Service/Order/Arbitration\x20context\x20required','R-A-3-04:\x20Guard\x20MUST\x20bind\x20Signer\x20or\x20verify\x20time-based\x20trigger\x20—\x20no\x20Service-layer\x20access\x20control\x20exists','F-A-05:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(pure\x20Rate\x20mode,\x20no\x20Surplus)','Caller\x20lifecycle:\x20receive()\x20to\x20deposit\x20funds\x20→\x20alloc()\x20to\x20trigger\x20distribution','Guard\x20should\x20bind\x20context(Signer)==authorized\x20to\x20prevent\x20unauthorized\x20alloc()\x20calls','beneficiaries\x20are\x20personal\x20wallets,\x20NOT\x20Treasury\x20objects\x20(no\x20Service\x20context)']},{'id':'T-A-10','name':'Standalone\x20vesting\x20release\x20(time-locked\x20multi-stage\x20unlock)','description':'Standalone\x20Allocation\x20with\x20N\x20Allocators\x20(default\x203\x20stages),\x20each\x20triggered\x20by\x20a\x20time-locked\x20Guard.\x20Stages\x201..N-1\x20use\x20Amount\x20mode;\x20final\x20stage\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance.\x20No\x20Service\x20context.','applicable_scenes':['allocation_standalone_vesting'],'industry_tags':['standalone','vesting','time_lock','team_tokens'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(vested\x20asset,\x20e.g.\x20locked\x20team\x20tokens)','required':!![]},{'name':'beneficiary_address','type':'address','description':'Single\x20beneficiary\x20wallet\x20address\x20(vesting\x20recipient)','required':!![]},{'name':'stage_1_guard','type':'address','description':'Guard\x20for\x20stage\x201\x20(verifies\x20context(Clock).timestamp\x20>=\x20stage_1_unlock)','required':!![]},{'name':'stage_1_amount','type':'number','description':'Amount\x20to\x20release\x20at\x20stage\x201\x20(smallest\x20coin\x20unit,\x20e.g.\x20MIST)','required':!![]},{'name':'stage_2_guard','type':'address','description':'Guard\x20for\x20stage\x202\x20(verifies\x20context(Clock).timestamp\x20>=\x20stage_2_unlock)\x20—\x20MUST\x20differ\x20from\x20stage_1_guard','required':!![]},{'name':'stage_2_amount','type':'number','description':'Amount\x20to\x20release\x20at\x20stage\x202\x20(smallest\x20coin\x20unit)','required':!![]},{'name':'stage_3_guard','type':'address','description':'Guard\x20for\x20stage\x203\x20(final\x20stage,\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance)\x20—\x20MUST\x20differ\x20from\x20stage_1_guard\x20and\x20stage_2_guard','required':!![]},{'name':'max_cap','type':'number','description':'Maximum\x20cumulative\x20release\x20cap\x20(applied\x20to\x20stages\x201\x20and\x202\x20via\x20max\x20field).\x20Stage\x203\x20uses\x20Surplus\x20so\x20no\x20max\x20needed.','required':![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Standalone\x20vesting\x20release\x20(3-stage\x20time-locked)'}],'body':a=>{const b=[a['stage_1_guard'],a['stage_2_guard'],a['stage_3_guard']],c=new Set(b);if(c['size']!==b['length']){const h=b['filter']((j,k)=>b['indexOf'](j)!==k);throw new Error('T-A-10:\x20stage\x20guards\x20MUST\x20be\x20unique\x20(F-A-14),\x20duplicates:\x20'+h['join'](',\x20'));}const d=Number(a['stage_1_amount']),e=Number(a['stage_2_amount']);if(d<=0x0||e<=0x0)throw new Error('T-A-10:\x20stage_1_amount\x20and\x20stage_2_amount\x20MUST\x20be\x20>\x200,\x20got\x20stage1='+d+',\x20stage2='+e);const f=d+e,g=a['max_cap']!=null?Number(a['max_cap']):null;if(g!==null&&f>g)throw new Error('T-A-10:\x20stage_1_amount\x20+\x20stage_2_amount\x20('+f+')\x20MUST\x20be\x20<=\x20max_cap\x20('+g+')\x20—\x20F-A-08\x20(EAMOUNT_EXCEEDS_MAX)');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Standalone\x20vesting\x20release\x20(3-stage\x20time-locked)','threshold':'0','allocators':[{'guard':a['stage_1_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':String(d),'mode':'Amount'}],'max':g!=null?String(g):null},{'guard':a['stage_2_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':String(e),'mode':'Amount'}],'max':g!=null?String(g):null},{'guard':a['stage_3_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':'0','mode':'Surplus'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Standalone\x20mode\x20(§0):\x20no\x20Service/Order/Arbitration\x20context\x20required','R-A-3-04:\x20Guard\x20time-lock\x20MUST\x20be\x20enforced\x20—\x20no\x20Service-layer\x20access\x20control\x20exists','F-A-14:\x20stage_1_guard,\x20stage_2_guard,\x20stage_3_guard\x20MUST\x20be\x20unique\x20(duplicate\x20guards\x20are\x20dead\x20code)','F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(stage\x203\x20uses\x20Surplus\x20to\x20drain\x20remainder)','F-A-08:\x20stage_1_amount\x20+\x20stage_2_amount\x20MUST\x20be\x20<=\x20max_cap\x20(if\x20max_cap\x20provided)','R-A-4-01:\x20if\x20caller\x20calls\x20alloc()\x20before\x20stage\x20time-lock\x20expires,\x20alloc()\x20silently\x20returns\x20—\x20caller\x20should\x20check\x20balance==0\x20after\x20alloc()','R-A-4-02:\x20Guard\x20conditions\x20SHOULD\x20be\x20mutually\x20exclusive\x20by\x20timestamp\x20(e.g.\x20stage_1:\x20ts<stage_2_unlock,\x20stage_2:\x20stage_2_unlock<=ts<stage_3_unlock,\x20stage_3:\x20ts>=stage_3_unlock)','Caller\x20lifecycle:\x20receive()\x20to\x20deposit\x20locked\x20tokens\x20→\x20alloc()\x20at\x20each\x20vesting\x20milestone']},{'id':'T-A-11','name':'Standalone\x20payroll\x20/\x20salary\x20distribution\x20(issuer\x20+\x20Repository\x20verified)','description':'Standalone\x20Allocation\x20for\x20periodic\x20payroll:\x20employees\x20receive\x20Rate\x20shares.\x20The\x20Guard\x20binds\x20the\x20issuer\x20Signer\x20identity\x20and\x20cross-checks\x20a\x20Repository\x20payroll\x20record\x20(period\x20and\x20amounts).\x20No\x20Service\x20context.','applicable_scenes':['allocation_standalone_payroll'],'industry_tags':['standalone','payroll','salary','compensation','hr'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20used\x20for\x20payroll\x20(e.g.\x20\x270x2::wow::WOW\x27)','required':!![]},{'name':'employees','type':'address[]','description':'Employee\x20wallet\x20addresses\x20(Recipient::Entity\x20recipients)','required':!![]},{'name':'rates','type':'string[]','description':'Per-employee\x20rates\x20in\x20basis\x20points\x20(e.g.\x20[\x276000\x27,\x274000\x27]).\x20MUST\x20sum\x20to\x2010000.','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20that\x20binds\x20Signer\x20==\x20issuer\x20AND\x20cross-checks\x20the\x20Repository\x20payroll\x20record\x20(both\x20required)','required':!![]},{'name':'payroll_period','type':'string','description':'Human-readable\x20period\x20label\x20(e.g.\x20\x272025-W26\x27)\x20—\x20recorded\x20in\x20the\x20Allocation\x20description\x20for\x20audit','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Standalone\x20payroll\x20distribution'}],'body':a=>{const b=a['employees'],c=a['rates']['map'](e=>Number(e));if(b['length']!==c['length'])throw new Error('T-A-11:\x20employees\x20('+b['length']+')\x20and\x20rates\x20('+c['length']+')\x20MUST\x20have\x20equal\x20length');if(b['length']===0x0)throw new Error('T-A-11:\x20at\x20least\x201\x20employee\x20required');if(b['length']>0x64)throw new Error('T-A-11:\x20employees\x20count\x20'+b['length']+'\x20exceeds\x20MAX_SHARING_COUNT\x20(100)');const d=c['reduce']((e,f)=>e+f,0x0);if(d!==0x2710)throw new Error('T-A-11:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(RATE_TOTAL_FULL),\x20got\x20'+d);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':(a['description']??'Standalone\x20payroll\x20distribution')+'\x20—\x20period:\x20'+a['payroll_period'],'threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':b['map']((e,f)=>({'who':{'Entity':e},'sharing':String(c[f]),'mode':'Rate'})),'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Standalone\x20mode:\x20no\x20Service/Order/Arbitration\x20context\x20required','RC-FIND-04:\x20the\x20Guard\x20MUST\x20bind\x20the\x20issuer\x20identity\x20(Signer\x20==\x20employer/admin,\x20or\x20a\x20Permission\x20member)\x20—\x20standalone\x20has\x20no\x20Service\x20access-control\x20layer','Repository\x20distinction:\x20the\x20Guard\x20MUST\x20cross-check\x20the\x20Repository\x20payroll\x20record\x20(period\x20hash,\x20amounts\x20and\x20recipients)\x20so\x20the\x20distribution\x20is\x20tied\x20to\x20auditable\x20work/payroll\x20data','Auditability:\x20the\x20Guard\x20rules\x20are\x20public\x20—\x20third\x20parties\x20verify\x20who\x20may\x20distribute\x20and\x20what\x20inputs\x20distinguish\x20a\x20valid\x20payroll','F-A-05:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(pure\x20Rate\x20mode)','Caller\x20lifecycle:\x20issuer\x20receive()\x20to\x20fund\x20payroll\x20→\x20alloc()\x20after\x20the\x20Repository\x20record\x20for\x20the\x20period\x20is\x20committed','Employees\x20are\x20personal\x20wallets\x20(Recipient::Entity),\x20never\x20Recipient::Signer']}];export const ALLOCATION_TEMPLATES_VERSION='1.0.0';export function getAllTemplates(){return[...ALLOCATION_TEMPLATES];}export function getTemplateById(a){return ALLOCATION_TEMPLATES['find'](b=>b['id']===a);}export function getTemplatesByScene(a){return ALLOCATION_TEMPLATES['filter'](b=>b['applicable_scenes']['includes'](a));}export function getTemplatesByIndustry(a){return ALLOCATION_TEMPLATES['filter'](b=>b['industry_tags']['includes'](a)||b['industry_tags']['includes']('universal'));}export function suggestTemplateForScene(a){const b=getTemplatesByScene(a);return b['length']>0x0?b[0x0]:undefined;}export function listTemplates(){return ALLOCATION_TEMPLATES['map'](a=>({'id':a['id'],'name':a['name'],'description':a['description'],'scenes':a['applicable_scenes']}));}export function fillTemplate(a,b){const c=getTemplateById(a);if(!c)return{'ok':![],'error':'Template\x20'+a+'\x20not\x20found'};for(const d of c['params']){if(d['required']&&!(d['name']in b))return{'ok':![],'error':'Missing\x20required\x20param:\x20'+d['name']};}try{return{'ok':!![],'body':c['body'](b)};}catch(f){return{'ok':![],'error':f instanceof Error?f['message']:String(f)};}}
1
+ export const ALLOCATION_TEMPLATES=[{'id':'T-A-01','name':'Single\x20Rate\x20100%\x20to\x20Treasury','description':'Simplest\x20allocation\x20—\x20single\x20Allocator,\x20single\x20Rate=10000\x20sharing\x20to\x20one\x20Treasury/personal\x20address','applicable_scenes':['allocation_merchant_full_payment'],'industry_tags':['universal','retail','service'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(e.g.\x20\x270x2::wow::WOW\x27)','required':!![]},{'name':'recipient_address','type':'address','description':'Treasury\x20or\x20personal\x20wallet\x20address\x20to\x20receive\x20100%','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20order\x20completion)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Single\x20Rate\x20100%\x20allocation'}],'body':a=>({'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Single\x20Rate\x20100%\x20allocation','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['recipient_address']},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}}),'notes':['Simplest\x20configuration\x20—\x20no\x20multi-party\x20coordination','Guard\x20only\x20needs\x20to\x20verify\x20order\x20status,\x20no\x20complex\x20conditions','Suitable\x20for\x20solo\x20merchants\x20or\x20single-treasury\x20services']},{'id':'T-A-02','name':'Standard\x203-way\x20Rate\x20split','description':'Three-way\x20split:\x20merchant\x20/\x20platform\x20/\x20logistics.\x20Pure\x20Rate\x20mode,\x20sum(rates)\x20MUST\x20equal\x2010000','applicable_scenes':['allocation_standard_three_way_split'],'industry_tags':['retail','ecommerce','logistics'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address','required':!![]},{'name':'platform_treasury','type':'address','description':'Platform\x20Treasury\x20address','required':!![]},{'name':'logistics_treasury','type':'address','description':'Logistics\x20Treasury\x20address\x20(set\x20to\x20platform_treasury\x20if\x20N/A)','required':!![]},{'name':'merchant_rate','type':'number','description':'Merchant\x20rate\x20in\x20basis\x20points\x20(e.g.\x208000\x20=\x2080%)','required':!![],'default':0x1f40},{'name':'platform_rate','type':'number','description':'Platform\x20rate\x20in\x20basis\x20points\x20(e.g.\x201000\x20=\x2010%)','required':!![],'default':0x3e8},{'name':'logistics_rate','type':'number','description':'Logistics\x20rate\x20in\x20basis\x20points\x20(e.g.\x201000\x20=\x2010%)','required':!![],'default':0x3e8},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20order\x20completion\x20+\x20service\x20binding)','required':!![]}],'body':a=>{const b=Number(a['merchant_rate']),c=Number(a['platform_rate']),d=Number(a['logistics_rate']),e=b+c+d;if(e!==0x2710)throw new Error('T-A-02:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(RATE_TOTAL_FULL),\x20got\x20'+e+'\x20'+('(merchant='+b+'\x20+\x20platform='+c+'\x20+\x20logistics='+d+')'));return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'3-way\x20split:\x20merchant\x20'+b+'/10000,\x20platform\x20'+c+'/10000,\x20logistics\x20'+d+'/10000','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['merchant_treasury']},'sharing':String(b),'mode':'Rate'},{'who':{'Entity':a['platform_treasury']},'sharing':String(c),'mode':'Rate'},{'who':{'Entity':a['logistics_treasury']},'sharing':String(d),'mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-05:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(pure\x20Rate\x20mode,\x20no\x20Surplus)','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-3-02)','Guard\x20should\x20verify\x20order.service\x20binding\x20(query\x201563)\x20to\x20prevent\x20cross-project\x20bypass']},{'id':'T-A-03','name':'Refund-first\x20+\x20Surplus-to-merchant\x20(Amount\x20+\x20Surplus\x20hybrid)','description':'Single\x20Allocator\x20with\x202\x20sharing\x20items:\x20Amount=refund_value\x20to\x20customer,\x20Surplus\x20to\x20merchant','applicable_scenes':['allocation_refund_first_surplus_to_merchant'],'industry_tags':['retail','refund','customer_protection'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'customer_address','type':'address','description':'Customer\x20address\x20to\x20receive\x20refund\x20Amount','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address\x20to\x20receive\x20Surplus','required':!![]},{'name':'refund_amount','type':'number','description':'Refund\x20amount\x20in\x20smallest\x20coin\x20unit\x20(e.g.\x20MIST\x20for\x20WOW)','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20refund\x20approval)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Refund-first\x20+\x20Surplus-to-merchant'}],'body':a=>{const b=Number(a['refund_amount']);if(b<=0x0)throw new Error('T-A-03:\x20refund_amount\x20MUST\x20be\x20>\x200,\x20got\x20'+b);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Refund-first\x20+\x20Surplus-to-merchant','threshold':String(b),'allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['customer_address']},'sharing':String(b),'mode':'Amount'},{'who':{'Entity':a['merchant_treasury']},'sharing':'0','mode':'Surplus'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(✓\x20single\x20Surplus\x20here)','F-A-07:\x20threshold\x20=\x20refundAmount\x20(ensure\x20balance\x20covers\x20Amount)','the\x20fix\x20is\x20cached\x20as\x20refundAmount\x20when\x20the\x20Allocator\x20is\x20added','Guard\x20must\x20verify\x20customer\x20refund\x20eligibility\x20(e.g.\x20order\x20status\x20=\x20Refunded)']},{'id':'T-A-04','name':'Treasury\x20+\x20Personal\x20alternative\x20(caller-specified\x20guard,\x202\x20Allocators)','description':'2\x20Allocators\x20as\x20alternative\x20strategies:\x20caller\x20selects\x20Treasury\x20or\x20Personal\x20wallet\x20via\x20alloc_by_guard\x20(hard\x20verification\x20per\x20call)','applicable_scenes':['allocation_treasury_personal_alternatives'],'industry_tags':['universal','alternative','treasury'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'treasury_address','type':'address','description':'Treasury\x20address\x20(primary\x20recipient)','required':!![]},{'name':'personal_address','type':'address','description':'Personal\x20wallet\x20address\x20(alternative\x20recipient)','required':!![]},{'name':'treasury_guard','type':'address','description':'Guard\x20for\x20Treasury\x20path\x20(verifies\x20treasury\x20operational)','required':!![]},{'name':'personal_guard','type':'address','description':'Guard\x20for\x20Personal\x20path\x20(verifies\x20personal\x20wallet\x20active)\x20—\x20MUST\x20differ\x20from\x20treasury_guard','required':!![]}],'body':a=>{if(a['treasury_guard']===a['personal_guard'])throw new Error('T-A-04:\x20treasury_guard\x20and\x20personal_guard\x20MUST\x20be\x20different\x20addresses\x20(F-A-14:\x20allocators[].guard\x20must\x20be\x20unique)');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Treasury\x20/\x20Personal\x20alternative\x20(caller-specified\x20guard)','threshold':'0','allocators':[{'guard':a['treasury_guard'],'sharing':[{'who':{'Entity':a['treasury_address']},'sharing':'10000','mode':'Rate'}],'max':null},{'guard':a['personal_guard'],'sharing':[{'who':{'Entity':a['personal_address']},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-14:\x20treasury_guard\x20!=\x20personal_guard\x20(Allocator\x20Guards\x20must\x20be\x20unique)','caller-specified\x20guard:\x20alloc_by_guard\x20explicitly\x20selects\x20an\x20Allocator;\x20the\x20Passport\x27s\x20guard\x20result\x20is\x20hard-verified\x20(failure\x20aborts\x20E_VERIFY_FAILED)','No\x20auto-fallback:\x20on\x20verification\x20failure\x20the\x20caller\x20must\x20switch\x20guard\x20and\x20retry','R-A-4-02:\x20if\x20the\x20caller\x27s\x20submitted\x20Passport\x20satisfies\x20both\x20Guards\x20simultaneously,\x20the\x20caller\x20may\x20freely\x20choose\x20between\x20the\x20two\x20paths\x20(mutual\x20exclusion\x20is\x20a\x20design\x20clarity\x20recommendation,\x20not\x20a\x20correctness\x20requirement)']},{'id':'T-A-05','name':'Tiered\x20by\x20order\x20amount\x20(mutually\x20exclusive\x20Guard\x20conditions)','description':'2\x20Allocators\x20triggered\x20by\x20mutually\x20exclusive\x20Guard\x20conditions\x20(small\x20order\x20vs\x20large\x20order)','applicable_scenes':['allocation_tiered_by_order_amount'],'industry_tags':['retail','tiered_pricing','volume_discount'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address','required':!![]},{'name':'platform_treasury','type':'address','description':'Platform\x20Treasury\x20address','required':!![]},{'name':'small_order_guard','type':'address','description':'Guard\x20verifying\x20order.amount\x20<\x20threshold\x20(small\x20order\x20path)','required':!![]},{'name':'large_order_guard','type':'address','description':'Guard\x20verifying\x20order.amount\x20>=\x20threshold\x20(large\x20order\x20path)\x20—\x20MUST\x20differ\x20from\x20small_order_guard','required':!![]},{'name':'small_order_merchant_rate','type':'number','description':'Merchant\x20rate\x20for\x20small\x20orders\x20(e.g.\x2010000\x20=\x20100%)','required':!![],'default':0x2710},{'name':'large_order_merchant_rate','type':'number','description':'Merchant\x20rate\x20for\x20large\x20orders\x20(e.g.\x208000\x20=\x2080%)','required':!![],'default':0x1f40},{'name':'large_order_platform_rate','type':'number','description':'Platform\x20rate\x20for\x20large\x20orders\x20(e.g.\x202000\x20=\x2020%)','required':!![],'default':0x7d0}],'body':a=>{if(a['small_order_guard']===a['large_order_guard'])throw new Error('T-A-05:\x20small_order_guard\x20and\x20large_order_guard\x20MUST\x20be\x20different\x20addresses\x20(F-A-14)');const b=Number(a['small_order_merchant_rate']);if(b!==0x2710)throw new Error('T-A-05:\x20small_order_merchant_rate\x20MUST\x20equal\x2010000\x20(pure\x20Rate,\x20no\x20Surplus\x20in\x20this\x20Allocator),\x20got\x20'+b);const c=Number(a['large_order_merchant_rate']),d=Number(a['large_order_platform_rate']),e=c+d;if(e!==0x2710)throw new Error('T-A-05:\x20large_order\x20rates\x20MUST\x20sum\x20to\x2010000,\x20got\x20'+e+'\x20(merchant='+c+'\x20+\x20platform='+d+')');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Tiered\x20by\x20order\x20amount:\x20small=100%\x20merchant,\x20large=80/20\x20merchant/platform','threshold':'0','allocators':[{'guard':a['small_order_guard'],'sharing':[{'who':{'Entity':a['merchant_treasury']},'sharing':'10000','mode':'Rate'}],'max':null},{'guard':a['large_order_guard'],'sharing':[{'who':{'Entity':a['merchant_treasury']},'sharing':String(c),'mode':'Rate'},{'who':{'Entity':a['platform_treasury']},'sharing':String(d),'mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Guard\x20conditions\x20MUST\x20be\x20mutually\x20exclusive\x20(R-A-4-02)','Sequence-sensitive:\x20strict\x20condition\x20(small\x20order)\x20first,\x20relaxed\x20condition\x20(large\x20order)\x20last','Guard\x20queries\x20order.amount\x20(query\x201561)\x20to\x20determine\x20which\x20Allocator\x20fires','If\x20neither\x20Guard\x20passes,\x20funds\x20are\x20silently\x20locked\x20(R-A-4-02)']},{'id':'T-A-06','name':'Dynamic\x20recipient\x20via\x20GuardIdentifier\x20(referrer\x20from\x20Passport)','description':'Single\x20Allocator\x20with\x203\x20Rate\x20sharing\x20items,\x20one\x20recipient\x20resolved\x20from\x20customer\x27s\x20Passport\x20table[0]','applicable_scenes':['allocation_dynamic_recipient'],'industry_tags':['referral','affiliate','marketing'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'merchant_treasury','type':'address','description':'Merchant\x20Treasury\x20address','required':!![]},{'name':'platform_treasury','type':'address','description':'Platform\x20Treasury\x20address','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(must\x20be\x20configured\x20with\x20identifier=0\x20as\x20address\x20type)','required':!![]},{'name':'passport_identifier','type':'number','description':'Passport\x20table\x20identifier\x20(u8,\x200-255)\x20—\x20customer\x20submits\x20referrer\x20address\x20at\x20this\x20slot','required':!![],'default':0x0},{'name':'merchant_rate','type':'number','description':'Merchant\x20rate\x20in\x20basis\x20points\x20(e.g.\x208000\x20=\x2080%)','required':!![],'default':0x1f40},{'name':'platform_rate','type':'number','description':'Platform\x20rate\x20in\x20basis\x20points\x20(e.g.\x201000\x20=\x2010%)','required':!![],'default':0x3e8},{'name':'referrer_rate','type':'number','description':'Referrer\x20rate\x20in\x20basis\x20points\x20(e.g.\x201000\x20=\x2010%)','required':!![],'default':0x3e8}],'body':a=>{const b=Number(a['merchant_rate']),c=Number(a['platform_rate']),d=Number(a['referrer_rate']),e=b+c+d;if(e!==0x2710)throw new Error('T-A-06:\x20sum(rates)\x20MUST\x20equal\x2010000,\x20got\x20'+e+'\x20(merchant='+b+'\x20+\x20platform='+c+'\x20+\x20referrer='+d+')');const f=Number(a['passport_identifier']);if(f<0x0||f>0xff)throw new Error('T-A-06:\x20passport_identifier\x20MUST\x20be\x20u8\x20(0-255),\x20got\x20'+f);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Dynamic\x20recipient:\x20merchant\x20'+b+'/10000,\x20platform\x20'+c+'/10000,\x20referrer\x20'+d+'/10000\x20(from\x20Passport\x20identifier='+f+')','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['merchant_treasury']},'sharing':String(b),'mode':'Rate'},{'who':{'Entity':a['platform_treasury']},'sharing':String(c),'mode':'Rate'},{'who':{'GuardIdentifier':f},'sharing':String(d),'mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['F-A-13:\x20Passport\x20table[identifier]\x20MUST\x20be\x20address\x20type\x20(else\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS=1)','The\x20Guard\x20identifier\x20slot\x27s\x20address-type\x20check\x20MUST\x20pass\x20when\x20the\x20Allocator\x20is\x20added\x20(else\x20the\x20Allocator\x20add\x20fails)','Customer\x20must\x20submit\x20Passport\x20with\x20referrer\x20address\x20at\x20the\x20specified\x20identifier\x20slot','Guard\x20should\x20verify\x20Passport\x20completeness\x20before\x20alloc()\x20executes']},{'id':'T-A-07','name':'Refund\x20to\x20the\x20submitted\x20Order\x20(100%\x20delivered\x20to\x20the\x20order\x20as\x20escrow)','description':'Single\x20Allocator,\x201\x20Rate=10000\x20sharing\x20whose\x20recipient\x20is\x20the\x20order\x20submitted\x20at\x20alloc\x20time\x20(Guard\x20table\x20identifier\x200).\x20The\x20funds\x20are\x20delivered\x20to\x20that\x20order\x20and\x20received\x20by\x20its\x20owner.','applicable_scenes':['allocation_refund_to_order'],'industry_tags':['refund','customer_protection','order_lifecycle'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20verifying\x20the\x20submitted\x20order\x20qualifies\x20(e.g.\x20order\x20at\x20the\x20refund\x20node,\x20order.service\x20==\x20host\x20service).\x20Its\x20table\x20needs\x20an\x20address-typed\x20b_submission\x20slot\x20at\x20identifier\x200.','required':!![]}],'body':a=>({'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Refund\x20to\x20the\x20submitted\x20Order\x20(100%\x20delivered\x20to\x20the\x20order\x20as\x20escrow)','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'GuardIdentifier':0x0},'sharing':'10000','mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}}),'notes':['The\x20Guard\x20table\x20MUST\x20have\x20an\x20address-typed\x20b_submission\x20slot\x20at\x20identifier\x200\x20carrying\x20the\x20submitted\x20order\x20(else\x20the\x20Allocator\x20add\x20fails\x20with\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS).','At\x20alloc\x20time\x20the\x20full\x20Rate\x20is\x20delivered\x20to\x20the\x20submitted\x20order\x20as\x20a\x20CoinWrapper\x20—\x20the\x20order\x20object\x20owns\x20it.\x20Its\x20owner\x20subsequently\x20receives\x20the\x20bare\x20coins\x20through\x20the\x20order\x27s\x20owner-receive\x20entry;\x20unrelated\x20addresses\x20cannot\x20intercept.','The\x20Guard\x20decides\x20which\x20submitted\x20orders\x20qualify:\x20node\x20state\x20plus\x20a\x20service-scope\x20binding\x20(order.service\x20==\x20host\x20service)\x20are\x20the\x20typical\x20conditions;\x20tightening\x20those\x20conditions\x20is\x20how\x20the\x20destination\x20is\x20controlled.','When\x20the\x20per-order\x20Allocation\x20is\x20created\x20through\x20the\x20Service\x20flow,\x20payment_info.for_object\x20is\x20set\x20to\x20the\x20order\x20the\x20allocation\x20belongs\x20to,\x20recording\x20the\x20business\x20context\x20auditors\x20can\x20query.']},{'id':'T-A-08','name':'Arbitration\x20fees\x20split\x20(arbitrator\x2080%\x20/\x20platform\x2020%)','description':'Single\x20Allocator,\x202\x20Rate\x20sharing\x20items.\x20Triggered\x20by\x20the\x20Arbitration\x20fees-distribution\x20operation\x20(permission\x20365),\x20with\x20or\x20without\x20a\x20Passport.','applicable_scenes':['allocation_arbitration_fees'],'industry_tags':['arbitration','dispute','fees'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(must\x20match\x20Arbitration\x20fee\x20Coin\x20type)','required':!![]},{'name':'arbitrator_treasury','type':'address','description':'Arbitrator\x20Treasury\x20address','required':!![]},{'name':'platform_treasury','type':'address','description':'Platform\x20Treasury\x20address','required':!![]},{'name':'arbitrator_rate','type':'number','description':'Arbitrator\x20rate\x20in\x20basis\x20points\x20(e.g.\x208000\x20=\x2080%)','required':!![],'default':0x1f40},{'name':'platform_rate','type':'number','description':'Platform\x20rate\x20in\x20basis\x20points\x20(e.g.\x202000\x20=\x2020%)','required':!![],'default':0x7d0},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20(verifies\x20Arbitration\x20ruling\x20finalized)','required':!![]}],'body':a=>{const b=Number(a['arbitrator_rate']),c=Number(a['platform_rate']),d=b+c;if(d!==0x2710)throw new Error('T-A-08:\x20sum(rates)\x20MUST\x20equal\x2010000,\x20got\x20'+d+'\x20(arbitrator='+b+'\x20+\x20platform='+c+')');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':'Arbitration\x20fees\x20split:\x20arbitrator\x20'+b+'/10000,\x20platform\x20'+c+'/10000','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':[{'who':{'Entity':a['arbitrator_treasury']},'sharing':String(b),'mode':'Rate'},{'who':{'Entity':a['platform_treasury']},'sharing':String(c),'mode':'Rate'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Triggered\x20by\x20the\x20Arbitration\x20fees-distribution\x20operation\x20(permission\x20ARBITRATION_FEES_ALLOC=365),\x20with\x20or\x20without\x20a\x20Passport','Independent\x20from\x20Service-order\x20Allocation\x20(this\x20Allocation\x20is\x20not\x20bound\x20to\x20Order)','payment_info\x20typically\x20reuses\x20Arbitration\x27s\x20payment_info','Caller\x20MUST\x20hold\x20ARBITRATION_FEES_ALLOC=365\x20permission']},{'id':'T-A-09','name':'Standalone\x20periodic\x20split\x20(investment\x20dividends\x20/\x20shared\x20income)','description':'Standalone\x20Allocation\x20with\x20single\x20Allocator,\x20N\x20Rate\x20sharing\x20items\x20to\x20beneficiary\x20wallets.\x20No\x20Service\x20context.\x20Guard\x20provides\x20time-based\x20or\x20signer-based\x20access\x20control.','applicable_scenes':['allocation_standalone_periodic_split'],'industry_tags':['standalone','investment','dividends','shared_income'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(e.g.\x20\x270x2::wow::WOW\x27\x20or\x20profit\x20token\x20type)','required':!![]},{'name':'beneficiaries','type':'address[]','description':'Array\x20of\x20beneficiary\x20wallet\x20addresses\x20(NOT\x20Treasury\x20objects\x20—\x20standalone\x20mode\x20has\x20no\x20Service\x20context)','required':!![]},{'name':'rates','type':'string[]','description':'Array\x20of\x20rates\x20in\x20basis\x20points\x20(e.g.\x20[\x275000\x27,\x273000\x27,\x272000\x27]\x20=\x2050%/30%/20%).\x20MUST\x20sum\x20to\x2010000.','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20object\x20address\x20—\x20MUST\x20bind\x20Signer\x20or\x20verify\x20time-based\x20trigger\x20(R-A-3-04:\x20standalone\x20has\x20no\x20Service-layer\x20access\x20control)','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Standalone\x20periodic\x20split'}],'body':a=>{const b=a['beneficiaries'],c=a['rates']['map'](e=>Number(e));if(b['length']!==c['length'])throw new Error('T-A-09:\x20beneficiaries\x20('+b['length']+')\x20and\x20rates\x20('+c['length']+')\x20MUST\x20have\x20equal\x20length');if(b['length']===0x0)throw new Error('T-A-09:\x20at\x20least\x201\x20beneficiary\x20required');if(b['length']>0x64)throw new Error('T-A-09:\x20beneficiaries\x20count\x20'+b['length']+'\x20exceeds\x20MAX_SHARING_COUNT\x20(100)');const d=c['reduce']((e,f)=>e+f,0x0);if(d!==0x2710)throw new Error('T-A-09:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(RATE_TOTAL_FULL),\x20got\x20'+d);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Standalone\x20periodic\x20split','threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':b['map']((e,f)=>({'who':{'Entity':e},'sharing':String(c[f]),'mode':'Rate'})),'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Standalone\x20mode\x20(§0):\x20no\x20Service/Order/Arbitration\x20context\x20required','R-A-3-04:\x20Guard\x20MUST\x20bind\x20Signer\x20or\x20verify\x20time-based\x20trigger\x20—\x20no\x20Service-layer\x20access\x20control\x20exists','F-A-05:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(pure\x20Rate\x20mode,\x20no\x20Surplus)','Caller\x20lifecycle:\x20receive()\x20to\x20deposit\x20funds\x20→\x20alloc()\x20to\x20trigger\x20distribution','Guard\x20should\x20bind\x20context(Signer)==authorized\x20to\x20prevent\x20unauthorized\x20alloc()\x20calls','beneficiaries\x20are\x20personal\x20wallets,\x20NOT\x20Treasury\x20objects\x20(no\x20Service\x20context)']},{'id':'T-A-10','name':'Standalone\x20vesting\x20release\x20(time-locked\x20multi-stage\x20unlock)','description':'Standalone\x20Allocation\x20with\x20N\x20Allocators\x20(default\x203\x20stages),\x20each\x20triggered\x20by\x20a\x20time-locked\x20Guard.\x20Stages\x201..N-1\x20use\x20Amount\x20mode;\x20final\x20stage\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance.\x20No\x20Service\x20context.','applicable_scenes':['allocation_standalone_vesting'],'industry_tags':['standalone','vesting','time_lock','team_tokens'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20(vested\x20asset,\x20e.g.\x20locked\x20team\x20tokens)','required':!![]},{'name':'beneficiary_address','type':'address','description':'Single\x20beneficiary\x20wallet\x20address\x20(vesting\x20recipient)','required':!![]},{'name':'stage_1_guard','type':'address','description':'Guard\x20for\x20stage\x201\x20(verifies\x20context(Clock).timestamp\x20>=\x20stage_1_unlock)','required':!![]},{'name':'stage_1_amount','type':'number','description':'Amount\x20to\x20release\x20at\x20stage\x201\x20(smallest\x20coin\x20unit,\x20e.g.\x20MIST)','required':!![]},{'name':'stage_2_guard','type':'address','description':'Guard\x20for\x20stage\x202\x20(verifies\x20context(Clock).timestamp\x20>=\x20stage_2_unlock)\x20—\x20MUST\x20differ\x20from\x20stage_1_guard','required':!![]},{'name':'stage_2_amount','type':'number','description':'Amount\x20to\x20release\x20at\x20stage\x202\x20(smallest\x20coin\x20unit)','required':!![]},{'name':'stage_3_guard','type':'address','description':'Guard\x20for\x20stage\x203\x20(final\x20stage,\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance)\x20—\x20MUST\x20differ\x20from\x20stage_1_guard\x20and\x20stage_2_guard','required':!![]},{'name':'max_cap','type':'number','description':'Maximum\x20cumulative\x20release\x20cap\x20(applied\x20to\x20stages\x201\x20and\x202\x20via\x20max\x20field).\x20Stage\x203\x20uses\x20Surplus\x20so\x20no\x20max\x20needed.','required':![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Standalone\x20vesting\x20release\x20(3-stage\x20time-locked)'}],'body':a=>{const b=[a['stage_1_guard'],a['stage_2_guard'],a['stage_3_guard']],c=new Set(b);if(c['size']!==b['length']){const h=b['filter']((j,k)=>b['indexOf'](j)!==k);throw new Error('T-A-10:\x20stage\x20guards\x20MUST\x20be\x20unique\x20(F-A-14),\x20duplicates:\x20'+h['join'](',\x20'));}const d=Number(a['stage_1_amount']),e=Number(a['stage_2_amount']);if(d<=0x0||e<=0x0)throw new Error('T-A-10:\x20stage_1_amount\x20and\x20stage_2_amount\x20MUST\x20be\x20>\x200,\x20got\x20stage1='+d+',\x20stage2='+e);const f=d+e,g=a['max_cap']!=null?Number(a['max_cap']):null;if(g!==null&&f>g)throw new Error('T-A-10:\x20stage_1_amount\x20+\x20stage_2_amount\x20('+f+')\x20MUST\x20be\x20<=\x20max_cap\x20('+g+')\x20—\x20F-A-08\x20(EAMOUNT_EXCEEDS_MAX)');return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':a['description']??'Standalone\x20vesting\x20release\x20(3-stage\x20time-locked)','threshold':'0','allocators':[{'guard':a['stage_1_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':String(d),'mode':'Amount'}],'max':g!=null?String(g):null},{'guard':a['stage_2_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':String(e),'mode':'Amount'}],'max':g!=null?String(g):null},{'guard':a['stage_3_guard'],'sharing':[{'who':{'Entity':a['beneficiary_address']},'sharing':'0','mode':'Surplus'}],'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Standalone\x20mode\x20(§0):\x20no\x20Service/Order/Arbitration\x20context\x20required','R-A-3-04:\x20Guard\x20time-lock\x20MUST\x20be\x20enforced\x20—\x20no\x20Service-layer\x20access\x20control\x20exists','F-A-14:\x20stage_1_guard,\x20stage_2_guard,\x20stage_3_guard\x20MUST\x20be\x20unique\x20(duplicate\x20guards\x20are\x20dead\x20code)','F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(stage\x203\x20uses\x20Surplus\x20to\x20drain\x20remainder)','F-A-08:\x20stage_1_amount\x20+\x20stage_2_amount\x20MUST\x20be\x20<=\x20max_cap\x20(if\x20max_cap\x20provided)','R-A-4-01:\x20if\x20caller\x20calls\x20alloc()\x20before\x20stage\x20time-lock\x20expires,\x20alloc()\x20silently\x20returns\x20—\x20caller\x20should\x20check\x20balance==0\x20after\x20alloc()','R-A-4-02:\x20Guard\x20conditions\x20SHOULD\x20be\x20mutually\x20exclusive\x20by\x20timestamp\x20(e.g.\x20stage_1:\x20ts<stage_2_unlock,\x20stage_2:\x20stage_2_unlock<=ts<stage_3_unlock,\x20stage_3:\x20ts>=stage_3_unlock)','Caller\x20lifecycle:\x20receive()\x20to\x20deposit\x20locked\x20tokens\x20→\x20alloc()\x20at\x20each\x20vesting\x20milestone']},{'id':'T-A-11','name':'Standalone\x20payroll\x20/\x20salary\x20distribution\x20(issuer\x20+\x20Repository\x20verified)','description':'Standalone\x20Allocation\x20for\x20periodic\x20payroll:\x20employees\x20receive\x20Rate\x20shares.\x20The\x20Guard\x20binds\x20the\x20issuer\x20Signer\x20identity\x20and\x20cross-checks\x20a\x20Repository\x20payroll\x20record\x20(period\x20and\x20amounts).\x20No\x20Service\x20context.','applicable_scenes':['allocation_standalone_payroll'],'industry_tags':['standalone','payroll','salary','compensation','hr'],'params':[{'name':'allocation_name','type':'string','description':'Local\x20name\x20for\x20the\x20new\x20Allocation\x20object','required':!![]},{'name':'coin_type','type':'string','description':'Coin<T>\x20type\x20string\x20used\x20for\x20payroll\x20(e.g.\x20\x270x2::wow::WOW\x27)','required':!![]},{'name':'employees','type':'address[]','description':'Employee\x20wallet\x20addresses\x20(Recipient::Entity\x20recipients)','required':!![]},{'name':'rates','type':'string[]','description':'Per-employee\x20rates\x20in\x20basis\x20points\x20(e.g.\x20[\x276000\x27,\x274000\x27]).\x20MUST\x20sum\x20to\x2010000.','required':!![]},{'name':'guard_address','type':'address','description':'Guard\x20that\x20binds\x20Signer\x20==\x20issuer\x20AND\x20cross-checks\x20the\x20Repository\x20payroll\x20record\x20(both\x20required)','required':!![]},{'name':'payroll_period','type':'string','description':'Human-readable\x20period\x20label\x20(e.g.\x20\x272025-W26\x27)\x20—\x20recorded\x20in\x20the\x20Allocation\x20description\x20for\x20audit','required':!![]},{'name':'description','type':'string','description':'Allocation\x20description','required':![],'default':'Standalone\x20payroll\x20distribution'}],'body':a=>{const b=a['employees'],c=a['rates']['map'](e=>Number(e));if(b['length']!==c['length'])throw new Error('T-A-11:\x20employees\x20('+b['length']+')\x20and\x20rates\x20('+c['length']+')\x20MUST\x20have\x20equal\x20length');if(b['length']===0x0)throw new Error('T-A-11:\x20at\x20least\x201\x20employee\x20required');if(b['length']>0x64)throw new Error('T-A-11:\x20employees\x20count\x20'+b['length']+'\x20exceeds\x20MAX_SHARING_COUNT\x20(100)');const d=c['reduce']((e,f)=>e+f,0x0);if(d!==0x2710)throw new Error('T-A-11:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(RATE_TOTAL_FULL),\x20got\x20'+d);return{'object':{'name':a['allocation_name'],'type_parameter':a['coin_type']},'allocators':{'description':(a['description']??'Standalone\x20payroll\x20distribution')+'\x20—\x20period:\x20'+a['payroll_period'],'threshold':'0','allocators':[{'guard':a['guard_address'],'sharing':b['map']((e,f)=>({'who':{'Entity':e},'sharing':String(c[f]),'mode':'Rate'})),'max':null}]},'coin':{'name':a['allocation_name']+'_coin'},'payment_info':{}};},'notes':['Standalone\x20mode:\x20no\x20Service/Order/Arbitration\x20context\x20required','RC-FIND-04:\x20the\x20Guard\x20MUST\x20bind\x20the\x20issuer\x20identity\x20(Signer\x20==\x20employer/admin,\x20or\x20a\x20Permission\x20member)\x20—\x20standalone\x20has\x20no\x20Service\x20access-control\x20layer','Repository\x20distinction:\x20the\x20Guard\x20MUST\x20cross-check\x20the\x20Repository\x20payroll\x20record\x20(period\x20hash,\x20amounts\x20and\x20recipients)\x20so\x20the\x20distribution\x20is\x20tied\x20to\x20auditable\x20work/payroll\x20data','Auditability:\x20the\x20Guard\x20rules\x20are\x20public\x20—\x20third\x20parties\x20verify\x20who\x20may\x20distribute\x20and\x20what\x20inputs\x20distinguish\x20a\x20valid\x20payroll','F-A-05:\x20sum(rates)\x20MUST\x20equal\x2010000\x20(pure\x20Rate\x20mode)','Caller\x20lifecycle:\x20issuer\x20receive()\x20to\x20fund\x20payroll\x20→\x20alloc()\x20after\x20the\x20Repository\x20record\x20for\x20the\x20period\x20is\x20committed','Employees\x20are\x20personal\x20wallets\x20(Recipient::Entity),\x20never\x20Recipient::Signer']}];export const ALLOCATION_TEMPLATES_VERSION='1.0.0';export function getAllTemplates(){return[...ALLOCATION_TEMPLATES];}export function getTemplateById(a){return ALLOCATION_TEMPLATES['find'](b=>b['id']===a);}export function getTemplatesByScene(a){return ALLOCATION_TEMPLATES['filter'](b=>b['applicable_scenes']['includes'](a));}export function getTemplatesByIndustry(a){return ALLOCATION_TEMPLATES['filter'](b=>b['industry_tags']['includes'](a)||b['industry_tags']['includes']('universal'));}export function suggestTemplateForScene(a){const b=getTemplatesByScene(a);return b['length']>0x0?b[0x0]:undefined;}export function listTemplates(){return ALLOCATION_TEMPLATES['map'](a=>({'id':a['id'],'name':a['name'],'description':a['description'],'scenes':a['applicable_scenes']}));}export function fillTemplate(a,b){const c=getTemplateById(a);if(!c)return{'ok':![],'error':'Template\x20'+a+'\x20not\x20found'};for(const d of c['params']){if(d['required']&&!(d['name']in b))return{'ok':![],'error':'Missing\x20required\x20param:\x20'+d['name']};}try{return{'ok':!![],'body':c['body'](b)};}catch(f){return{'ok':![],'error':f instanceof Error?f['message']:String(f)};}}