@wowok/agent-mcp 3.1.0 → 3.1.3

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 (337) hide show
  1. package/dist/config/runtime.js +1 -1
  2. package/dist/customer/index.d.ts +3 -9
  3. package/dist/customer/index.js +1 -1
  4. package/dist/customer/industry-risks.d.ts +3 -17
  5. package/dist/customer/industry-risks.js +1 -1
  6. package/dist/customer/types.d.ts +1 -165
  7. package/dist/customer/types.js +1 -1
  8. package/dist/customer/user-preferences.d.ts +0 -49
  9. package/dist/customer/user-preferences.js +1 -1
  10. package/dist/evaluation/arbitration-game.js +1 -1
  11. package/dist/evaluation/architecture.spec.d.ts +1 -0
  12. package/dist/evaluation/architecture.spec.js +1 -0
  13. package/dist/evaluation/builtins/graph-service.d.ts +16 -0
  14. package/dist/evaluation/builtins/graph-service.js +1 -0
  15. package/dist/evaluation/builtins/graph-service.spec.d.ts +1 -0
  16. package/dist/evaluation/builtins/graph-service.spec.js +1 -0
  17. package/dist/evaluation/builtins/index.d.ts +1 -1
  18. package/dist/evaluation/builtins/index.js +1 -1
  19. package/dist/evaluation/builtins/purity.spec.d.ts +1 -0
  20. package/dist/evaluation/builtins/purity.spec.js +1 -0
  21. package/dist/evaluation/engine.js +1 -1
  22. package/dist/evaluation/facets/catalog.d.ts +19 -0
  23. package/dist/evaluation/facets/catalog.js +1 -0
  24. package/dist/evaluation/guard-scan.d.ts +10 -0
  25. package/dist/evaluation/guard-scan.js +1 -0
  26. package/dist/evaluation/location-match.js +1 -1
  27. package/dist/evaluation/standards.d.ts +31 -0
  28. package/dist/evaluation/standards.js +1 -0
  29. package/dist/evaluation/standards.spec.d.ts +1 -0
  30. package/dist/evaluation/standards.spec.js +1 -0
  31. package/dist/evaluation/types.d.ts +9 -0
  32. package/dist/experience/realtime-feedback.js +1 -1
  33. package/dist/extensions/index.d.ts +1 -1
  34. package/dist/extensions/index.js +1 -1
  35. package/dist/extensions/industry-layers.d.ts +6 -5
  36. package/dist/extensions/industry-layers.js +1 -1
  37. package/dist/extensions/industry-pack.js +1 -1
  38. package/dist/goal/GoalClassifier.js +1 -1
  39. package/dist/graph/onchain/analyze.d.ts +16 -3
  40. package/dist/graph/onchain/analyze.js +1 -1
  41. package/dist/graph/onchain/analyze.spec.js +1 -1
  42. package/dist/graph/onchain/dataplane.d.ts +1 -1
  43. package/dist/graph/onchain/dataplane.js +1 -1
  44. package/dist/graph/onchain/edge-batch.spec.d.ts +1 -0
  45. package/dist/graph/onchain/edge-batch.spec.js +1 -0
  46. package/dist/graph/onchain/edge-schema.d.ts +11 -3
  47. package/dist/graph/onchain/edge-schema.js +1 -1
  48. package/dist/graph/onchain/entity-profile.spec.d.ts +1 -0
  49. package/dist/graph/onchain/entity-profile.spec.js +1 -0
  50. package/dist/graph/onchain/event-history.spec.d.ts +1 -0
  51. package/dist/graph/onchain/event-history.spec.js +1 -0
  52. package/dist/graph/onchain/expand.js +1 -1
  53. package/dist/graph/onchain/extract-deep.spec.d.ts +1 -0
  54. package/dist/graph/onchain/extract-deep.spec.js +1 -0
  55. package/dist/graph/onchain/extract.d.ts +11 -3
  56. package/dist/graph/onchain/extract.js +1 -1
  57. package/dist/graph/onchain/facet-projection.d.ts +99 -0
  58. package/dist/graph/onchain/facet-projection.js +1 -0
  59. package/dist/graph/onchain/facet-projection.spec.d.ts +1 -0
  60. package/dist/graph/onchain/facet-projection.spec.js +1 -0
  61. package/dist/graph/onchain/facts.d.ts +103 -0
  62. package/dist/graph/onchain/facts.js +1 -0
  63. package/dist/graph/onchain/facts.spec.d.ts +1 -0
  64. package/dist/graph/onchain/facts.spec.js +1 -0
  65. package/dist/graph/onchain/field-manifest.d.ts +29 -0
  66. package/dist/graph/onchain/field-manifest.js +1 -0
  67. package/dist/graph/onchain/field-manifest.spec.d.ts +1 -0
  68. package/dist/graph/onchain/field-manifest.spec.js +1 -0
  69. package/dist/graph/onchain/fixtures.d.ts +80 -0
  70. package/dist/graph/onchain/fixtures.js +1 -0
  71. package/dist/graph/onchain/fixtures.spec.d.ts +1 -0
  72. package/dist/graph/onchain/fixtures.spec.js +1 -0
  73. package/dist/graph/onchain/index.d.ts +8 -2
  74. package/dist/graph/onchain/index.js +1 -1
  75. package/dist/graph/onchain/interest.js +1 -1
  76. package/dist/graph/onchain/label-lint.spec.d.ts +1 -0
  77. package/dist/graph/onchain/label-lint.spec.js +1 -0
  78. package/dist/graph/onchain/names.d.ts +23 -0
  79. package/dist/graph/onchain/names.js +1 -0
  80. package/dist/graph/onchain/names.spec.d.ts +1 -0
  81. package/dist/graph/onchain/names.spec.js +1 -0
  82. package/dist/graph/onchain/onchain.spec.js +1 -1
  83. package/dist/graph/onchain/proposal-graph.d.ts +11 -0
  84. package/dist/graph/onchain/proposal-graph.js +1 -0
  85. package/dist/graph/onchain/proposal-graph.spec.d.ts +1 -0
  86. package/dist/graph/onchain/proposal-graph.spec.js +1 -0
  87. package/dist/graph/onchain/sdk-batch.d.ts +5 -1
  88. package/dist/graph/onchain/sdk-batch.js +1 -1
  89. package/dist/graph/onchain/sdk-dataplane.js +1 -1
  90. package/dist/graph/onchain/strategy.d.ts +16 -0
  91. package/dist/graph/onchain/strategy.js +1 -1
  92. package/dist/graph/onchain/strategy.spec.js +1 -1
  93. package/dist/graph/onchain/table-ledger.spec.d.ts +1 -0
  94. package/dist/graph/onchain/table-ledger.spec.js +1 -0
  95. package/dist/graph/onchain/types.d.ts +51 -11
  96. package/dist/graph/onchain/viewport.d.ts +1 -0
  97. package/dist/graph/onchain/viewport.js +1 -1
  98. package/dist/harness/index.d.ts +1 -5
  99. package/dist/harness/index.js +1 -1
  100. package/dist/harness/verify.d.ts +6 -1
  101. package/dist/harness/verify.js +1 -1
  102. package/dist/index.js +1 -1
  103. package/dist/knowledge/allocation-ledger.d.ts +2 -0
  104. package/dist/knowledge/allocation-ledger.js +1 -1
  105. package/dist/knowledge/allocation-puzzle.js +1 -1
  106. package/dist/knowledge/allocation-risk.d.ts +2 -3
  107. package/dist/knowledge/allocation-risk.js +1 -1
  108. package/dist/knowledge/arb-risk.d.ts +0 -1
  109. package/dist/knowledge/arb-risk.js +1 -1
  110. package/dist/knowledge/arbitration-risk.d.ts +0 -2
  111. package/dist/knowledge/arbitration-risk.js +1 -1
  112. package/dist/knowledge/baselines/evaluation-baselines.json +79 -0
  113. package/dist/knowledge/baselines/guard-lint-baseline.spec.d.ts +1 -0
  114. package/dist/knowledge/baselines/guard-lint-baseline.spec.js +1 -0
  115. package/dist/knowledge/baselines/risk-baselines.spec.d.ts +1 -0
  116. package/dist/knowledge/baselines/risk-baselines.spec.js +1 -0
  117. package/dist/knowledge/baselines/risk-cases.d.ts +8 -0
  118. package/dist/knowledge/baselines/risk-cases.js +1 -0
  119. package/dist/knowledge/bridge-risk.d.ts +0 -1
  120. package/dist/knowledge/bridge-risk.js +1 -1
  121. package/dist/knowledge/contact-risk.d.ts +0 -1
  122. package/dist/knowledge/contact-risk.js +1 -1
  123. package/dist/knowledge/contract-invariants.d.ts +1 -0
  124. package/dist/knowledge/contract-invariants.js +1 -1
  125. package/dist/knowledge/demand-risk.d.ts +0 -1
  126. package/dist/knowledge/demand-risk.js +1 -1
  127. package/dist/knowledge/getting-started.js +1 -1
  128. package/dist/knowledge/guard-design-patterns.js +1 -1
  129. package/dist/knowledge/guard-eval.d.ts +15 -0
  130. package/dist/knowledge/guard-eval.js +1 -0
  131. package/dist/knowledge/guard-eval.spec.d.ts +1 -0
  132. package/dist/knowledge/guard-eval.spec.js +1 -0
  133. package/dist/knowledge/guard-field-cognition.d.ts +48 -0
  134. package/dist/knowledge/guard-field-cognition.js +1 -0
  135. package/dist/knowledge/guard-lint.d.ts +1 -1
  136. package/dist/knowledge/guard-lint.js +1 -1
  137. package/dist/knowledge/guard-risk.d.ts +4 -19
  138. package/dist/knowledge/guard-risk.js +1 -1
  139. package/dist/knowledge/index.d.ts +42 -43
  140. package/dist/knowledge/index.js +1 -1
  141. package/dist/knowledge/industry-registry.js +1 -1
  142. package/dist/knowledge/industry-rule-node.d.ts +7 -0
  143. package/dist/knowledge/industry-rule-node.js +1 -0
  144. package/dist/knowledge/industry-strategy.js +1 -1
  145. package/dist/knowledge/jsonrpc-enum.js +1 -1
  146. package/dist/knowledge/machine-risk.d.ts +0 -6
  147. package/dist/knowledge/machine-risk.js +1 -1
  148. package/dist/knowledge/order-risk.d.ts +1 -9
  149. package/dist/knowledge/order-risk.js +1 -1
  150. package/dist/knowledge/payment-risk.d.ts +0 -1
  151. package/dist/knowledge/payment-risk.js +1 -1
  152. package/dist/knowledge/permission-risk.d.ts +0 -3
  153. package/dist/knowledge/permission-risk.js +1 -1
  154. package/dist/knowledge/personal-risk.d.ts +0 -1
  155. package/dist/knowledge/personal-risk.js +1 -1
  156. package/dist/knowledge/progress-risk.d.ts +0 -2
  157. package/dist/knowledge/progress-risk.js +1 -1
  158. package/dist/knowledge/proof-risk.d.ts +0 -1
  159. package/dist/knowledge/proof-risk.js +1 -1
  160. package/dist/knowledge/puzzle-projections.d.ts +11 -0
  161. package/dist/knowledge/puzzle-projections.js +1 -0
  162. package/dist/knowledge/recipient-constraint.d.ts +6 -1
  163. package/dist/knowledge/recipient-constraint.js +1 -1
  164. package/dist/knowledge/registrar-risk.d.ts +0 -1
  165. package/dist/knowledge/registrar-risk.js +1 -1
  166. package/dist/knowledge/repository-risk.d.ts +0 -1
  167. package/dist/knowledge/repository-risk.js +1 -1
  168. package/dist/knowledge/resource-risk.d.ts +0 -1
  169. package/dist/knowledge/resource-risk.js +1 -1
  170. package/dist/knowledge/reward-risk.d.ts +1 -5
  171. package/dist/knowledge/reward-risk.js +1 -1
  172. package/dist/knowledge/rule-node-analyzers.d.ts +43 -0
  173. package/dist/knowledge/rule-node-analyzers.js +1 -0
  174. package/dist/knowledge/rule-node-analyzers.spec.d.ts +1 -0
  175. package/dist/knowledge/rule-node-analyzers.spec.js +1 -0
  176. package/dist/knowledge/rule-outcome.d.ts +5 -0
  177. package/dist/knowledge/rule-outcome.js +1 -0
  178. package/dist/knowledge/safety-rules.js +1 -1
  179. package/dist/knowledge/scenario-topology.js +1 -1
  180. package/dist/knowledge/service-allocator-audit-node.d.ts +3 -0
  181. package/dist/knowledge/service-allocator-audit-node.js +1 -0
  182. package/dist/knowledge/service-risk-node.js +1 -1
  183. package/dist/knowledge/service-risk.d.ts +0 -3
  184. package/dist/knowledge/service-risk.js +1 -1
  185. package/dist/knowledge/template-registry.js +1 -1
  186. package/dist/knowledge/tools-reference.js +1 -1
  187. package/dist/knowledge/treasury-risk.d.ts +2 -3
  188. package/dist/knowledge/treasury-risk.js +1 -1
  189. package/dist/knowledge/util-risk.d.ts +0 -1
  190. package/dist/knowledge/util-risk.js +1 -1
  191. package/dist/knowledge/workflow-guidance.d.ts +2 -0
  192. package/dist/knowledge/workflow-guidance.js +1 -1
  193. package/dist/monitor/MonitorLoop.js +1 -1
  194. package/dist/persona/bridge.js +1 -1
  195. package/dist/persona/facet-profile.d.ts +33 -0
  196. package/dist/persona/facet-profile.js +1 -0
  197. package/dist/persona/model.d.ts +2 -1
  198. package/dist/persona/model.js +1 -1
  199. package/dist/persona/strategy-intent.js +1 -1
  200. package/dist/persona/topology-focus.d.ts +2 -2
  201. package/dist/persona/topology-focus.js +1 -1
  202. package/dist/persona/types.d.ts +12 -0
  203. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  204. package/dist/playbooks/service-build/facet-money.d.ts +22 -0
  205. package/dist/playbooks/service-build/facet-money.js +1 -0
  206. package/dist/playbooks/service-build/facet-money.spec.d.ts +1 -0
  207. package/dist/playbooks/service-build/facet-money.spec.js +1 -0
  208. package/dist/playbooks/service-build/intent-analyzer.js +1 -1
  209. package/dist/playbooks/service-build/machine-panorama.d.ts +3 -0
  210. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  211. package/dist/playbooks/service-build/object-panorama.d.ts +27 -27
  212. package/dist/playbooks/service-build/object-panorama.js +1 -1
  213. package/dist/playbooks/service-build/pipeline-actions.d.ts +2 -2
  214. package/dist/playbooks/service-build/pipeline-actions.js +1 -1
  215. package/dist/playbooks/service-build/risk-aggregator.d.ts +2 -1
  216. package/dist/playbooks/service-build/risk-aggregator.js +1 -1
  217. package/dist/playbooks/service-build/service-panorama.d.ts +4 -9
  218. package/dist/playbooks/service-build/service-panorama.js +1 -1
  219. package/dist/playbooks/service-build/topology-evaluation.spec.d.ts +1 -0
  220. package/dist/playbooks/service-build/topology-evaluation.spec.js +1 -0
  221. package/dist/playbooks/service-build/topology-query.d.ts +13 -2
  222. package/dist/playbooks/service-build/topology-query.js +1 -1
  223. package/dist/review/arb.d.ts +0 -2
  224. package/dist/review/arb.js +1 -1
  225. package/dist/review/order.d.ts +0 -1
  226. package/dist/review/order.js +1 -1
  227. package/dist/role/profiles.js +1 -1
  228. package/dist/rules.d.ts +1 -2
  229. package/dist/rules.js +1 -1
  230. package/dist/safety/confirm-gate.js +1 -1
  231. package/dist/safety/preview.js +1 -1
  232. package/dist/schema/call/base.d.ts +3372 -668
  233. package/dist/schema/call/base.js +1 -1
  234. package/dist/schema/call/handler.js +1 -1
  235. package/dist/schema/call/receipt.d.ts +28 -0
  236. package/dist/schema/call/receipt.js +1 -0
  237. package/dist/schema/call/semantic-customer-advice.spec.d.ts +1 -0
  238. package/dist/schema/call/semantic-customer-advice.spec.js +1 -0
  239. package/dist/schema/call/semantic.d.ts +5 -2
  240. package/dist/schema/call/semantic.js +1 -1
  241. package/dist/schema/call/treasury.js +1 -1
  242. package/dist/schema/common/index.js +1 -1
  243. package/dist/schema/evaluation/index.d.ts +289 -211
  244. package/dist/schema/evaluation/index.js +1 -1
  245. package/dist/schema/goal/index.d.ts +1 -1
  246. package/dist/schema/goal/planning.d.ts +2 -2
  247. package/dist/schema/index.d.ts +0 -1
  248. package/dist/schema/index.js +1 -1
  249. package/dist/schema/industry-pack/index.d.ts +1 -1
  250. package/dist/schema/keeper/index.d.ts +1 -1
  251. package/dist/schema/local/index.js +1 -1
  252. package/dist/schema/operations.d.ts +28 -10
  253. package/dist/schema/operations.js +1 -1
  254. package/dist/schema/persona/index.d.ts +24 -24
  255. package/dist/schema/query/bi.d.ts +629 -14
  256. package/dist/schema/query/bi.js +1 -1
  257. package/dist/schema/query/index.d.ts +9 -9
  258. package/dist/schema/query/index.js +1 -1
  259. package/dist/schema/schema-version.js +1 -1
  260. package/dist/schema/workspace/index.d.ts +2 -2
  261. package/dist/schema-query-impl/index.js +1 -1
  262. package/dist/schemas/account_operation.output.json +10 -10
  263. package/dist/schemas/account_operation.schema.json +3 -3
  264. package/dist/schemas/bridge_operation.output.json +10 -10
  265. package/dist/schemas/evaluation_operation.output.json +697 -169
  266. package/dist/schemas/evaluation_operation.schema.json +5 -434
  267. package/dist/schemas/index.json +1 -7
  268. package/dist/schemas/keeper_operation.output.json +10 -10
  269. package/dist/schemas/local_history_operation.output.json +10 -10
  270. package/dist/schemas/local_info_operation.output.json +10 -10
  271. package/dist/schemas/local_mark_operation.output.json +10 -10
  272. package/dist/schemas/messenger_operation.output.json +10 -10
  273. package/dist/schemas/monitor_events.output.json +10 -10
  274. package/dist/schemas/monitor_subscription.output.json +10 -10
  275. package/dist/schemas/onchain_events.output.json +11 -11
  276. package/dist/schemas/onchain_operations.output.json +6369 -3736
  277. package/dist/schemas/onchain_operations.schema.json +48 -48
  278. package/dist/schemas/onchain_operations_allocation.schema.json +5 -5
  279. package/dist/schemas/onchain_operations_arbitration.schema.json +3 -3
  280. package/dist/schemas/onchain_operations_contact.schema.json +2 -2
  281. package/dist/schemas/onchain_operations_demand.schema.json +2 -2
  282. package/dist/schemas/onchain_operations_machine.schema.json +2 -2
  283. package/dist/schemas/onchain_operations_order.schema.json +2 -2
  284. package/dist/schemas/onchain_operations_payment.schema.json +2 -2
  285. package/dist/schemas/onchain_operations_permission.schema.json +2 -2
  286. package/dist/schemas/onchain_operations_progress.schema.json +2 -2
  287. package/dist/schemas/onchain_operations_repository.schema.json +2 -2
  288. package/dist/schemas/onchain_operations_reward.schema.json +6 -6
  289. package/dist/schemas/onchain_operations_service.schema.json +8 -8
  290. package/dist/schemas/onchain_operations_treasury.schema.json +10 -10
  291. package/dist/schemas/onchain_table_data.output.json +78 -84
  292. package/dist/schemas/query_toolkit.output.json +1087 -254
  293. package/dist/schemas/query_toolkit.schema.json +65 -3
  294. package/dist/strategy/collectors.js +1 -1
  295. package/dist/strategy/metrics.js +1 -1
  296. package/dist/task/playbook.js +1 -1
  297. package/dist/tools/handlers/bridge.js +1 -1
  298. package/dist/tools/handlers/config.js +1 -1
  299. package/dist/tools/handlers/dispatch-expectations.d.ts +3 -0
  300. package/dist/tools/handlers/dispatch-expectations.js +1 -0
  301. package/dist/tools/handlers/evaluation.js +1 -1
  302. package/dist/tools/handlers/evaluation.spec.js +1 -1
  303. package/dist/tools/handlers/onchain.js +1 -1
  304. package/dist/tools/handlers/query.js +1 -1
  305. package/dist/tools/index.js +1 -1
  306. package/dist/tools/registry/evaluation.d.ts +2 -0
  307. package/dist/tools/registry/evaluation.js +1 -0
  308. package/dist/tools/registry/monitor.js +1 -1
  309. package/dist/tools/registry/query.js +1 -1
  310. package/dist/tools/shared.d.ts +0 -1
  311. package/dist/tools/shared.js +1 -1
  312. package/dist/tools/wrap.js +1 -1
  313. package/package.json +4 -3
  314. package/dist/customer/customer-advice.d.ts +0 -32
  315. package/dist/customer/customer-advice.js +0 -1
  316. package/dist/customer/info-puzzle.d.ts +0 -146
  317. package/dist/customer/info-puzzle.js +0 -1
  318. package/dist/customer/order-strategy.d.ts +0 -17
  319. package/dist/customer/order-strategy.js +0 -1
  320. package/dist/customer/preorder-compare.d.ts +0 -24
  321. package/dist/customer/preorder-compare.js +0 -1
  322. package/dist/customer/reminder-system.d.ts +0 -42
  323. package/dist/customer/reminder-system.js +0 -1
  324. package/dist/customer/risk-assessment.d.ts +0 -13
  325. package/dist/customer/risk-assessment.js +0 -1
  326. package/dist/evaluation/builtins/service-risk.d.ts +0 -7
  327. package/dist/evaluation/builtins/service-risk.js +0 -1
  328. package/dist/knowledge/trust-metrics.d.ts +0 -66
  329. package/dist/knowledge/trust-metrics.js +0 -1
  330. package/dist/schema/trust/index.d.ts +0 -334
  331. package/dist/schema/trust/index.js +0 -1
  332. package/dist/schemas/trust_score.output.json +0 -847
  333. package/dist/schemas/trust_score.schema.json +0 -364
  334. package/dist/tools/handlers/trust.d.ts +0 -16
  335. package/dist/tools/handlers/trust.js +0 -1
  336. package/dist/tools/registry/trust.d.ts +0 -2
  337. package/dist/tools/registry/trust.js +0 -1
@@ -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_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_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.0.0';export function getAllRiskRules(){return[...ALL_RULES];}export function getRiskRulesCount(){return ALL_RULES['length'];}export function getRiskRulesByCategory(a){return ALL_RULES['filter'](b=>b['category']===a);}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,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};
@@ -34,4 +34,3 @@ export declare const ARB_RISK_RULES: {
34
34
  }[];
35
35
  export declare const ARB_RISK_VERSION = "1.0.0";
36
36
  export declare function checkArbRisks(ctx: ArbRiskCheckContext): ArbRisk[];
37
- export declare function getArbRiskById(id: string): ArbRisk | undefined;
@@ -1 +1 @@
1
- import{MAX_VOTOR_COUNT,WITHDRAW_DURATION_TIME}from'@wowok/wowok';const R_A_01={'rule':{'id':'R-ARB-01','level':'HIGH','category':'lifecycle','title':'7-state\x20machine\x20—\x20invalid\x20transitions\x20can\x20deadlock\x20the\x20arbitration','description':'Arb\x20has\x20a\x207-state\x20machine:\x20Principal_confirming(0)\x20→\x20Arbitrator_confirming(1)\x20→\x20'+'Voting(2)\x20→\x20Arbitrated(3)\x20→\x20Objectionable(4)\x20→\x20Finished(5)\x20→\x20Withdrawn(6).\x20reset()\x20'+'can\x20revert\x20from\x20{1,\x204}\x20back\x20to\x200.\x20Each\x20op\x20asserts\x20the\x20current\x20status;\x20calling\x20an\x20op\x20'+'out\x20of\x20order\x20aborts\x20with\x20E_STATUS_NOT_MATCH\x20(3).\x20Repeated\x20mis-calls\x20leave\x20the\x20Arb\x20'+'stuck\x20in\x20a\x20non-terminal\x20state\x20with\x20no\x20automatic\x20recovery.','affected_stakeholders':['principal','arbitrator','voter'],'scenario':'Caller\x20calls\x20vote()\x20when\x20status\x20is\x20still\x20Arbitrator_confirming;\x20abort\x20blocks\x20progress','mitigation':'Strictly\x20validate\x20the\x20current\x20status\x20before\x20submitting\x20any\x20Arb\x20op.\x20The\x20SDK\x20should\x20'+'expose\x20a\x20status-aware\x20state\x20machine\x20helper.\x20Provide\x20a\x20recovery\x20path\x20(reset)\x20for\x20'+'Arbitrator_confirming\x20and\x20Objectionable\x20states.','related_move_error':'E_STATUS_NOT_MATCH\x20(3)','auto_fixable':![]},'check':a=>{if(!a['invalid_transition'])return null;return{...R_A_01['rule'],'evidence':'invalid_transition=true\x20(status='+(a['status']??'?')+')'};}},R_A_02={'rule':{'id':'R-ARB-02','level':'MEDIUM','category':'lifecycle','title':'WITHDRAW_DURATION_TIME='+WITHDRAW_DURATION_TIME+'ms\x20(30\x20days)\x20—\x20funds\x20locked','description':'After\x20arbitration,\x20the\x20fee\x20Balance\x20can\x20only\x20be\x20withdrawn\x20after\x20'+('WITHDRAW_DURATION_TIME='+WITHDRAW_DURATION_TIME+'ms\x20(30\x20days)\x20when\x20status\x20is\x20')+'Arbitrated(3)\x20or\x20Objectionable(4).\x20From\x20Finished(5),\x20withdraw\x20is\x20immediate.\x20'+'The\x2030-day\x20lock\x20is\x20a\x20dispute-window\x20safeguard,\x20but\x20it\x20locks\x20funds\x20for\x20a\x20long\x20time\x20'+'and\x20users\x20may\x20not\x20understand\x20why.','affected_stakeholders':['principal','arbitrator'],'scenario':'Arbitrator\x20finishes\x20a\x20case\x20but\x20must\x20wait\x2030\x20days\x20to\x20claim\x20the\x20fee','mitigation':'Surface\x20the\x20unlock\x20timestamp\x20in\x20the\x20UI.\x20To\x20shorten\x20the\x20lock,\x20drive\x20the\x20case\x20to\x20'+'Finished(5)\x20via\x20finish()\x20rather\x20than\x20leaving\x20it\x20in\x20Arbitrated/Objectionable.','related_move_error':'E_WITHDRAW_DURATION_TIME_NOT_PASSED\x20(8)','auto_fixable':![]},'check':a=>{if(!a['withdraw_too_early'])return null;return{...R_A_02['rule'],'evidence':'withdraw_too_early=true\x20(limit='+WITHDRAW_DURATION_TIME+'ms)'};}},R_A_03={'rule':{'id':'R-ARB-03','level':'MEDIUM','category':'structural','title':'MAX_VOTOR_COUNT='+MAX_VOTOR_COUNT+'\x20permissive\x20—\x20voting\x20efficiency\x20cost','description':'A\x20single\x20Arb\x20may\x20record\x20up\x20to\x20MAX_VOTOR_COUNT='+MAX_VOTOR_COUNT+'\x20voters\x20(arb.move:236).\x20'+'The\x20limit\x20aborts\x20with\x20E_MAX_VOTOR_COUNT\x20(6)\x20only\x20at\x20the\x20boundary.\x20520\x20voters\x20in\x20one\x20'+'Arb\x20inflates\x20the\x20voted\x20vector,\x20slowing\x20tally\x20and\x20gas,\x20and\x20complicates\x20weighted-quorum\x20'+'reasoning.','affected_stakeholders':['voter','arbitrator'],'scenario':'Arbitration\x20allows\x20520\x20voters;\x20tallying\x20the\x20vote\x20vector\x20is\x20slow\x20and\x20gas-heavy','mitigation':'Business\x20layer\x20should\x20self-limit\x20voter\x20count\x20based\x20on\x20the\x20Arbitration\x20rule\x27s\x20quorum.\x20'+'For\x20large\x20juries,\x20shard\x20across\x20multiple\x20Arb\x20instances\x20or\x20aggregate\x20off-chain.','related_move_error':'E_MAX_VOTOR_COUNT\x20(6)','auto_fixable':![]},'check':a=>{if(a['votor_count']===undefined)return null;if(a['votor_count']<MAX_VOTOR_COUNT)return null;return{...R_A_03['rule'],'evidence':'votor_count='+a['votor_count']+',\x20limit='+MAX_VOTOR_COUNT};}},R_A_04={'rule':{'id':'R-ARB-04','level':'LOW','category':'semantic','title':'proposition_change\x20may\x20not\x20emit\x20a\x20discrete\x20event\x20—\x20indexers\x20must\x20infer','description':'proposition_change\x20(arb.move)\x20updates\x20the\x20proposition\x20vector\x20in\x20place.\x20Unlike\x20'+'state\x20transitions\x20(which\x20emit\x20ArbEvent),\x20proposition\x20edits\x20may\x20not\x20produce\x20a\x20'+'discrete\x20event\x20—\x20indexers\x20must\x20infer\x20changes\x20by\x20diffing\x20the\x20proposition\x20vector\x20'+'across\x20polls.','affected_stakeholders':['arbitrator','voter'],'scenario':'Indexer\x20expects\x20a\x20PropositionChangedEvent;\x20none\x20is\x20emitted,\x20UI\x20fails\x20to\x20refresh','mitigation':'External\x20indexers\x20should\x20poll\x20the\x20proposition\x20vector.\x20UI\x20should\x20display\x20\x27propositions\x20'+'may\x20have\x20changed\x27\x20on\x20each\x20poll\x20rather\x20than\x20relying\x20on\x20event-driven\x20refresh.','auto_fixable':![]},'check':a=>{if(!a['expects_proposition_event'])return null;return{...R_A_04['rule'],'evidence':'expects_proposition_event=true\x20(poll\x20instead)'};}},R_A_05={'rule':{'id':'R-ARB-05','level':'MEDIUM','category':'semantic','title':'voting_deadline\x20is\x20Option<u64>\x20—\x20None\x20means\x20open-ended\x20vote','description':'voting_deadline\x20is\x20Option<u64>.\x20When\x20None,\x20voting\x20has\x20no\x20deadline\x20(open-ended)\x20and\x20'+'E_VOTING_DEADLINE_PASSED\x20(7)\x20never\x20triggers.\x20When\x20Some(t),\x20vote()\x20aborts\x20if\x20'+'clock.timestamp_ms()\x20>\x20t.\x20Callers\x20who\x20assume\x20a\x20default\x20deadline\x20may\x20be\x20surprised\x20by\x20'+'an\x20open-ended\x20vote\x20that\x20never\x20finalizes.','affected_stakeholders':['voter','arbitrator'],'scenario':'Voter\x20assumes\x20a\x20deadline;\x20voting_deadline\x20is\x20None\x20and\x20the\x20case\x20stalls\x20indefinitely','mitigation':'Document\x20that\x20None\x20means\x20open-ended.\x20Arbitrators\x20should\x20set\x20an\x20explicit\x20deadline\x20via\x20'+'arbitrator_confirm\x20unless\x20they\x20intend\x20an\x20open\x20vote.\x20SDK\x20should\x20surface\x20voting_deadline\x20'+'prominently.','related_move_error':'E_VOTING_DEADLINE_PASSED\x20(7)\x20/\x20E_VOTING_DEADLINE_NOT_PASSED\x20(4)','auto_fixable':![]},'check':a=>{if(!a['voting_deadline_none'])return null;return{...R_A_05['rule'],'evidence':'voting_deadline_none=true\x20(open-ended\x20vote)'};}},R_A_06={'rule':{'id':'R-ARB-06','level':'LOW','category':'semantic','title':'indemnity\x20is\x20Option<Indemnity>\x20—\x20None\x20means\x20no\x20compensation','description':'indemnity\x20is\x20Option<Indemnity>.\x20When\x20None,\x20the\x20arbitration\x20produces\x20no\x20compensation\x20'+'(e.g.\x20a\x20pure\x20declaratory\x20ruling).\x20Consumers\x20who\x20assume\x20a\x20non-null\x20indemnity\x20will\x20'+'mis-handle\x20None\x20cases.\x20finish()\x20returns\x20the\x20indemnity\x20amount\x20(0\x20when\x20None).','affected_stakeholders':['principal'],'scenario':'Principal\x20expects\x20compensation;\x20indemnity\x20is\x20None\x20and\x20finish()\x20returns\x200','mitigation':'Document\x20that\x20None\x20means\x20no\x20compensation.\x20UI\x20should\x20show\x20\x27no\x20compensation\x20awarded\x27\x20'+'rather\x20than\x20\x27compensation\x20pending\x27.','auto_fixable':![]},'check':a=>{if(!a['indemnity_none'])return null;return{...R_A_06['rule'],'evidence':'indemnity_none=true\x20(no\x20compensation)'};}},R_A_07={'rule':{'id':'R-ARB-07','level':'MEDIUM','category':'permission','title':'Voted.weight\x20is\x20set\x20by\x20the\x20Arbitration\x20rule\x20—\x20concentrated\x20weight\x20risk','description':'Voted.weight\x20(u32)\x20is\x20assigned\x20by\x20the\x20Arbitration\x20object\x27s\x20voting_guard\x20logic,\x20not\x20'+'by\x20the\x20voter.\x20If\x20the\x20Arbitration\x20rule\x20concentrates\x20weight\x20in\x20one\x20voter\x20(e.g.\x20an\x20'+'admin\x20with\x20weight\x201000\x20vs.\x20others\x20with\x20weight\x201),\x20a\x20single\x20voter\x20can\x20dictate\x20the\x20'+'outcome.\x20The\x20Arb\x20contract\x20itself\x20does\x20not\x20detect\x20concentration\x20—\x20that\x20is\x20the\x20'+'Arbitration\x20designer\x27s\x20responsibility.','affected_stakeholders':['voter','arbitrator'],'scenario':'Arbitration\x20rule\x20gives\x20one\x20voter\x20weight\x201000;\x20that\x20voter\x20single-handedly\x20decides\x20the\x20case','mitigation':'When\x20designing\x20the\x20Arbitration\x20rule,\x20cap\x20individual\x20voter\x20weight\x20and\x20require\x20a\x20'+'quorum.\x20Audit\x20the\x20voting_guard\x20to\x20ensure\x20no\x20single\x20voter\x20can\x20exceed\x20the\x20quorum\x20alone.','auto_fixable':![]},'check':a=>{if(!a['weight_concentrated'])return null;return{...R_A_07['rule'],'evidence':'weight_concentrated=true\x20(rule-level\x20risk)'};}},R_A_08={'rule':{'id':'R-ARB-08','level':'LOW','category':'semantic','title':'Status\x20uses\x20u8\x20constants\x20—\x20Move\x20enum\x20is\x20commented\x20out','description':'The\x207\x20statuses\x20are\x20defined\x20as\x20u8\x20constants\x20(Status_Principal_confirming=0,\x20etc.).\x20'+'The\x20Move\x20enum\x20definition\x20is\x20commented\x20out\x20(arb.move).\x20Consumers\x20cannot\x20rely\x20on\x20a\x20'+'type-safe\x20enum\x20and\x20must\x20compare\x20against\x20magic\x20numbers.\x20A\x20future\x20Wow\x20release\x20enabling\x20'+'the\x20enum\x20would\x20be\x20a\x20breaking\x20change\x20to\x20downstream\x20code.','affected_stakeholders':['system'],'scenario':'Developer\x20expects\x20a\x20Status\x20enum;\x20only\x20u8\x20constants\x20are\x20available,\x20causing\x20type\x20errors','mitigation':'SDK\x20should\x20expose\x20a\x20TypeScript\x20enum\x20mirroring\x20the\x20u8\x20constants.\x20Document\x20that\x20the\x20'+'Move\x20enum\x20is\x20intentionally\x20disabled\x20and\x20may\x20be\x20enabled\x20in\x20a\x20future\x20version.','auto_fixable':![]},'check':a=>{if(!a['expects_status_enum'])return null;return{...R_A_08['rule'],'evidence':'expects_status_enum=true\x20(only\x20u8\x20constants\x20exist)'};}};export const ARB_RISK_RULES=[R_A_01,R_A_02,R_A_03,R_A_04,R_A_05,R_A_06,R_A_07,R_A_08];export const ARB_RISK_VERSION='1.0.0';export function checkArbRisks(a){const b=[];for(const c of ARB_RISK_RULES){const d=c['check'](a);if(d)b['push'](d);}return b;}export function getArbRiskById(a){return ARB_RISK_RULES['find'](b=>b['rule']['id']===a)?.['rule'];}
1
+ import{MAX_VOTOR_COUNT,WITHDRAW_DURATION_TIME}from'@wowok/wowok';const R_A_01={'rule':{'id':'R-ARB-01','level':'HIGH','category':'lifecycle','title':'7-state\x20machine\x20—\x20invalid\x20transitions\x20can\x20deadlock\x20the\x20arbitration','description':'Arb\x20has\x20a\x207-state\x20machine:\x20Principal_confirming(0)\x20→\x20Arbitrator_confirming(1)\x20→\x20'+'Voting(2)\x20→\x20Arbitrated(3)\x20→\x20Objectionable(4)\x20→\x20Finished(5)\x20→\x20Withdrawn(6).\x20reset()\x20'+'can\x20revert\x20from\x20{1,\x204}\x20back\x20to\x200.\x20Each\x20op\x20asserts\x20the\x20current\x20status;\x20calling\x20an\x20op\x20'+'out\x20of\x20order\x20aborts\x20with\x20E_STATUS_NOT_MATCH\x20(3).\x20Repeated\x20mis-calls\x20leave\x20the\x20Arb\x20'+'stuck\x20in\x20a\x20non-terminal\x20state\x20with\x20no\x20automatic\x20recovery.','affected_stakeholders':['principal','arbitrator','voter'],'scenario':'Caller\x20calls\x20vote()\x20when\x20status\x20is\x20still\x20Arbitrator_confirming;\x20abort\x20blocks\x20progress','mitigation':'Strictly\x20validate\x20the\x20current\x20status\x20before\x20submitting\x20any\x20Arb\x20op.\x20The\x20SDK\x20should\x20'+'expose\x20a\x20status-aware\x20state\x20machine\x20helper.\x20Provide\x20a\x20recovery\x20path\x20(reset)\x20for\x20'+'Arbitrator_confirming\x20and\x20Objectionable\x20states.','related_move_error':'E_STATUS_NOT_MATCH\x20(3)','auto_fixable':![]},'check':a=>{if(!a['invalid_transition'])return null;return{...R_A_01['rule'],'evidence':'invalid_transition=true\x20(status='+(a['status']??'?')+')'};}},R_A_02={'rule':{'id':'R-ARB-02','level':'MEDIUM','category':'lifecycle','title':'WITHDRAW_DURATION_TIME='+WITHDRAW_DURATION_TIME+'ms\x20(30\x20days)\x20—\x20funds\x20locked','description':'After\x20arbitration,\x20the\x20fee\x20Balance\x20can\x20only\x20be\x20withdrawn\x20after\x20'+('WITHDRAW_DURATION_TIME='+WITHDRAW_DURATION_TIME+'ms\x20(30\x20days)\x20when\x20status\x20is\x20')+'Arbitrated(3)\x20or\x20Objectionable(4).\x20From\x20Finished(5),\x20withdraw\x20is\x20immediate.\x20'+'The\x2030-day\x20lock\x20is\x20a\x20dispute-window\x20safeguard,\x20but\x20it\x20locks\x20funds\x20for\x20a\x20long\x20time\x20'+'and\x20users\x20may\x20not\x20understand\x20why.','affected_stakeholders':['principal','arbitrator'],'scenario':'Arbitrator\x20finishes\x20a\x20case\x20but\x20must\x20wait\x2030\x20days\x20to\x20claim\x20the\x20fee','mitigation':'Surface\x20the\x20unlock\x20timestamp\x20in\x20the\x20UI.\x20To\x20shorten\x20the\x20lock,\x20drive\x20the\x20case\x20to\x20'+'Finished(5)\x20via\x20finish()\x20rather\x20than\x20leaving\x20it\x20in\x20Arbitrated/Objectionable.','related_move_error':'E_WITHDRAW_DURATION_TIME_NOT_PASSED\x20(8)','auto_fixable':![]},'check':a=>{if(!a['withdraw_too_early'])return null;return{...R_A_02['rule'],'evidence':'withdraw_too_early=true\x20(limit='+WITHDRAW_DURATION_TIME+'ms)'};}},R_A_03={'rule':{'id':'R-ARB-03','level':'MEDIUM','category':'structural','title':'MAX_VOTOR_COUNT='+MAX_VOTOR_COUNT+'\x20permissive\x20—\x20voting\x20efficiency\x20cost','description':'A\x20single\x20Arb\x20may\x20record\x20up\x20to\x20MAX_VOTOR_COUNT='+MAX_VOTOR_COUNT+'\x20voters\x20(arb.move:236).\x20'+'The\x20limit\x20aborts\x20with\x20E_MAX_VOTOR_COUNT\x20(6)\x20only\x20at\x20the\x20boundary.\x20520\x20voters\x20in\x20one\x20'+'Arb\x20inflates\x20the\x20voted\x20vector,\x20slowing\x20tally\x20and\x20gas,\x20and\x20complicates\x20weighted-quorum\x20'+'reasoning.','affected_stakeholders':['voter','arbitrator'],'scenario':'Arbitration\x20allows\x20520\x20voters;\x20tallying\x20the\x20vote\x20vector\x20is\x20slow\x20and\x20gas-heavy','mitigation':'Business\x20layer\x20should\x20self-limit\x20voter\x20count\x20based\x20on\x20the\x20Arbitration\x20rule\x27s\x20quorum.\x20'+'For\x20large\x20juries,\x20shard\x20across\x20multiple\x20Arb\x20instances\x20or\x20aggregate\x20off-chain.','related_move_error':'E_MAX_VOTOR_COUNT\x20(6)','auto_fixable':![]},'check':a=>{if(a['votor_count']===undefined)return null;if(a['votor_count']<MAX_VOTOR_COUNT)return null;return{...R_A_03['rule'],'evidence':'votor_count='+a['votor_count']+',\x20limit='+MAX_VOTOR_COUNT};}},R_A_04={'rule':{'id':'R-ARB-04','level':'LOW','category':'semantic','title':'proposition_change\x20may\x20not\x20emit\x20a\x20discrete\x20event\x20—\x20indexers\x20must\x20infer','description':'proposition_change\x20(arb.move)\x20updates\x20the\x20proposition\x20vector\x20in\x20place.\x20Unlike\x20'+'state\x20transitions\x20(which\x20emit\x20ArbEvent),\x20proposition\x20edits\x20may\x20not\x20produce\x20a\x20'+'discrete\x20event\x20—\x20indexers\x20must\x20infer\x20changes\x20by\x20diffing\x20the\x20proposition\x20vector\x20'+'across\x20polls.','affected_stakeholders':['arbitrator','voter'],'scenario':'Indexer\x20expects\x20a\x20PropositionChangedEvent;\x20none\x20is\x20emitted,\x20UI\x20fails\x20to\x20refresh','mitigation':'External\x20indexers\x20should\x20poll\x20the\x20proposition\x20vector.\x20UI\x20should\x20display\x20\x27propositions\x20'+'may\x20have\x20changed\x27\x20on\x20each\x20poll\x20rather\x20than\x20relying\x20on\x20event-driven\x20refresh.','auto_fixable':![]},'check':a=>{if(!a['expects_proposition_event'])return null;return{...R_A_04['rule'],'evidence':'expects_proposition_event=true\x20(poll\x20instead)'};}},R_A_05={'rule':{'id':'R-ARB-05','level':'MEDIUM','category':'semantic','title':'voting_deadline\x20is\x20Option<u64>\x20—\x20None\x20means\x20open-ended\x20vote','description':'voting_deadline\x20is\x20Option<u64>.\x20When\x20None,\x20voting\x20has\x20no\x20deadline\x20(open-ended)\x20and\x20'+'E_VOTING_DEADLINE_PASSED\x20(7)\x20never\x20triggers.\x20When\x20Some(t),\x20vote()\x20aborts\x20if\x20'+'clock.timestamp_ms()\x20>\x20t.\x20Callers\x20who\x20assume\x20a\x20default\x20deadline\x20may\x20be\x20surprised\x20by\x20'+'an\x20open-ended\x20vote\x20that\x20never\x20finalizes.','affected_stakeholders':['voter','arbitrator'],'scenario':'Voter\x20assumes\x20a\x20deadline;\x20voting_deadline\x20is\x20None\x20and\x20the\x20case\x20stalls\x20indefinitely','mitigation':'Document\x20that\x20None\x20means\x20open-ended.\x20Arbitrators\x20should\x20set\x20an\x20explicit\x20deadline\x20via\x20'+'arbitrator_confirm\x20unless\x20they\x20intend\x20an\x20open\x20vote.\x20SDK\x20should\x20surface\x20voting_deadline\x20'+'prominently.','related_move_error':'E_VOTING_DEADLINE_PASSED\x20(7)\x20/\x20E_VOTING_DEADLINE_NOT_PASSED\x20(4)','auto_fixable':![]},'check':a=>{if(!a['voting_deadline_none'])return null;return{...R_A_05['rule'],'evidence':'voting_deadline_none=true\x20(open-ended\x20vote)'};}},R_A_06={'rule':{'id':'R-ARB-06','level':'LOW','category':'semantic','title':'indemnity\x20is\x20Option<Indemnity>\x20—\x20None\x20means\x20no\x20compensation','description':'indemnity\x20is\x20Option<Indemnity>.\x20When\x20None,\x20the\x20arbitration\x20produces\x20no\x20compensation\x20'+'(e.g.\x20a\x20pure\x20declaratory\x20ruling).\x20Consumers\x20who\x20assume\x20a\x20non-null\x20indemnity\x20will\x20'+'mis-handle\x20None\x20cases.\x20finish()\x20returns\x20the\x20indemnity\x20amount\x20(0\x20when\x20None).','affected_stakeholders':['principal'],'scenario':'Principal\x20expects\x20compensation;\x20indemnity\x20is\x20None\x20and\x20finish()\x20returns\x200','mitigation':'Document\x20that\x20None\x20means\x20no\x20compensation.\x20UI\x20should\x20show\x20\x27no\x20compensation\x20awarded\x27\x20'+'rather\x20than\x20\x27compensation\x20pending\x27.','auto_fixable':![]},'check':a=>{if(!a['indemnity_none'])return null;return{...R_A_06['rule'],'evidence':'indemnity_none=true\x20(no\x20compensation)'};}},R_A_07={'rule':{'id':'R-ARB-07','level':'MEDIUM','category':'permission','title':'Voted.weight\x20is\x20set\x20by\x20the\x20Arbitration\x20rule\x20—\x20concentrated\x20weight\x20risk','description':'Voted.weight\x20(u32)\x20is\x20assigned\x20by\x20the\x20Arbitration\x20object\x27s\x20voting_guard\x20logic,\x20not\x20'+'by\x20the\x20voter.\x20If\x20the\x20Arbitration\x20rule\x20concentrates\x20weight\x20in\x20one\x20voter\x20(e.g.\x20an\x20'+'admin\x20with\x20weight\x201000\x20vs.\x20others\x20with\x20weight\x201),\x20a\x20single\x20voter\x20can\x20dictate\x20the\x20'+'outcome.\x20The\x20Arb\x20contract\x20itself\x20does\x20not\x20detect\x20concentration\x20—\x20that\x20is\x20the\x20'+'Arbitration\x20designer\x27s\x20responsibility.','affected_stakeholders':['voter','arbitrator'],'scenario':'Arbitration\x20rule\x20gives\x20one\x20voter\x20weight\x201000;\x20that\x20voter\x20single-handedly\x20decides\x20the\x20case','mitigation':'When\x20designing\x20the\x20Arbitration\x20rule,\x20cap\x20individual\x20voter\x20weight\x20and\x20require\x20a\x20'+'quorum.\x20Audit\x20the\x20voting_guard\x20to\x20ensure\x20no\x20single\x20voter\x20can\x20exceed\x20the\x20quorum\x20alone.','auto_fixable':![]},'check':a=>{if(!a['weight_concentrated'])return null;return{...R_A_07['rule'],'evidence':'weight_concentrated=true\x20(rule-level\x20risk)'};}},R_A_08={'rule':{'id':'R-ARB-08','level':'LOW','category':'semantic','title':'Status\x20uses\x20u8\x20constants\x20—\x20Move\x20enum\x20is\x20commented\x20out','description':'The\x207\x20statuses\x20are\x20defined\x20as\x20u8\x20constants\x20(Status_Principal_confirming=0,\x20etc.).\x20'+'The\x20Move\x20enum\x20definition\x20is\x20commented\x20out\x20(arb.move).\x20Consumers\x20cannot\x20rely\x20on\x20a\x20'+'type-safe\x20enum\x20and\x20must\x20compare\x20against\x20magic\x20numbers.\x20A\x20future\x20Wow\x20release\x20enabling\x20'+'the\x20enum\x20would\x20be\x20a\x20breaking\x20change\x20to\x20downstream\x20code.','affected_stakeholders':['system'],'scenario':'Developer\x20expects\x20a\x20Status\x20enum;\x20only\x20u8\x20constants\x20are\x20available,\x20causing\x20type\x20errors','mitigation':'SDK\x20should\x20expose\x20a\x20TypeScript\x20enum\x20mirroring\x20the\x20u8\x20constants.\x20Document\x20that\x20the\x20'+'Move\x20enum\x20is\x20intentionally\x20disabled\x20and\x20may\x20be\x20enabled\x20in\x20a\x20future\x20version.','auto_fixable':![]},'check':a=>{if(!a['expects_status_enum'])return null;return{...R_A_08['rule'],'evidence':'expects_status_enum=true\x20(only\x20u8\x20constants\x20exist)'};}};export const ARB_RISK_RULES=[R_A_01,R_A_02,R_A_03,R_A_04,R_A_05,R_A_06,R_A_07,R_A_08];export const ARB_RISK_VERSION='1.0.0';export function checkArbRisks(a){const b=[];for(const c of ARB_RISK_RULES){const d=c['check'](a);if(d)b['push'](d);}return b;}
@@ -99,8 +99,6 @@ export interface RiskCheckContext {
99
99
  }
100
100
  export declare const ARBITRATION_RISK_VERSION = "1.0.0";
101
101
  export declare function getAllRiskRules(): RiskRule[];
102
- export declare function getRiskRulesCount(): number;
103
- export declare function getRiskRulesByCategory(category: RiskCategory): RiskRule[];
104
102
  export interface ArbitrationRiskAssessment {
105
103
  summary: string;
106
104
  risks: ArbitrationRisk[];
@@ -1 +1 @@
1
- import{MAX_VOTING_GUARD_COUNT}from'@wowok/wowok';import{isTerminalArbStatus,isValidArbStatusTransition}from'./arbitration-ledger.js';const R_AB_1_01={'id':'R-AB-1-01','category':'structural','trigger':'voting_guard\x20count\x20exceeds\x20MAX_VOTING_GUARD_COUNT\x20(50)','check':a=>{if(!a['voting_guard'])return null;if(a['voting_guard']['op']==='add'||a['voting_guard']['op']==='set'){const b=a['voting_guard']['op']==='set'?a['voting_guard']['guards']['length']:(a['current_voting_guard_count']??0x0)+a['voting_guard']['guards']['length'];if(b>MAX_VOTING_GUARD_COUNT)return{'id':'R-AB-1-01','level':'HIGH','category':'structural','title':'voting_guard\x20count\x20exceeds\x20limit','description':'voting_guard\x20would\x20have\x20'+b+'\x20entries,\x20exceeds\x20MAX_VOTING_GUARD_COUNT\x20'+MAX_VOTING_GUARD_COUNT,'affected_stakeholders':['owner','arbiter'],'scenario':'Adding\x20too\x20many\x20voting\x20guards','mitigation':'Remove\x20unused\x20guards\x20before\x20adding\x20new\x20ones;\x20max\x20'+MAX_VOTING_GUARD_COUNT,'evidence':'count='+b};}return null;}},R_AB_1_02={'id':'R-AB-1-02','category':'structural','trigger':'Dispute\x20fee\x20below\x20arbitration.fee\x20threshold','check':a=>{if(!a['dispute']||a['current_arbitration_fee']===undefined)return null;const b=typeof a['current_arbitration_fee']==='string'?BigInt(a['current_arbitration_fee']):BigInt(a['current_arbitration_fee']),c=typeof a['dispute']['fee']==='object'&&a['dispute']['fee']!==null&&'balance'in a['dispute']['fee']?BigInt(a['dispute']['fee']['balance']??0x0):BigInt(0x0);if(c<b)return{'id':'R-AB-1-02','level':'CRITICAL','category':'structural','title':'Dispute\x20fee\x20insufficient\x20(E_FEE_NOT_ENOUGH)','description':'Provided\x20fee\x20'+c['toString']()+'\x20<\x20required\x20'+b['toString'](),'affected_stakeholders':['disputant'],'scenario':'Filing\x20dispute\x20with\x20insufficient\x20fee','mitigation':'Increase\x20dispute.fee.balance\x20to\x20>=\x20'+b['toString'](),'evidence':'provided='+c['toString']()+',\x20required='+b['toString']()};return null;}},R_AB_1_03={'id':'R-AB-1-03','category':'structural','trigger':'Arbitration\x20paused\x20(bPaused=true)\x20—\x20dispute\x20will\x20fail\x20with\x20E_PAUSED','check':a=>{if(a['dispute']&&a['current_bPaused']===!![])return{'id':'R-AB-1-03','level':'HIGH','category':'structural','title':'Arbitration\x20paused\x20—\x20cannot\x20file\x20dispute','description':'Arbitration.bPaused=true;\x20dispute()\x20will\x20abort\x20with\x20E_PAUSED','affected_stakeholders':['disputant'],'scenario':'Filing\x20dispute\x20against\x20a\x20paused\x20Arbitration','mitigation':'Call\x20pause(false)\x20(requires\x20ARBITRATION_PAUSE=356)\x20to\x20resume','evidence':'bPaused=true'};return null;}},R_AB_1_04={'id':'R-AB-1-04','category':'structural','trigger':'voting_deadline\x20in\x20the\x20past\x20—\x20vote\x20will\x20be\x20rejected','check':a=>{const b=a['confirm']?.['voting_deadline']??a['voting_deadline_change']?.['voting_deadline'];if(b!==undefined&&b!==null&&a['current_timestamp_ms']!==undefined){if(b<a['current_timestamp_ms'])return{'id':'R-AB-1-04','level':'HIGH','category':'structural','title':'voting_deadline\x20in\x20the\x20past','description':'Deadline\x20'+b+'\x20is\x20before\x20current\x20time\x20'+a['current_timestamp_ms'],'affected_stakeholders':['voter','arbiter'],'scenario':'Setting\x20voting\x20deadline\x20to\x20an\x20already-elapsed\x20timestamp','mitigation':'Use\x20a\x20future\x20timestamp\x20(e.g.\x20now\x20+\x207\x20days\x20in\x20ms)','evidence':'deadline='+b+',\x20now='+a['current_timestamp_ms']};}return null;}},R_AB_2_01={'id':'R-AB-2-01','category':'semantic','trigger':'voting_guard\x20misconfiguration\x20—\x20dispute\x20cannot\x20be\x20resolved','check':a=>{if(a['vote']&&a['vote']['voting_guard']){if(!a['current_voting_guard_addresses']||a['current_voting_guard_addresses']['length']===0x0)return{'id':'R-AB-2-01','level':'HIGH','category':'semantic','title':'voting_guard\x20misconfiguration\x20—\x20dispute\x20cannot\x20be\x20resolved','description':'vote.voting_guard\x20provided\x20but\x20Arbitration.voting_guard\x20is\x20empty;\x20E_VOTING_GUARD_NOT_FOUND\x20will\x20abort','affected_stakeholders':['voter','arbiter','disputant'],'scenario':'voting_guard\x20misconfiguration\x20prevents\x20vote\x20—\x20dispute\x20stuck','mitigation':'Either\x20add\x20the\x20Guard\x20to\x20voting_guard\x20list\x20(354)\x20or\x20use\x20open\x20vote()\x20without\x20voting_guard','evidence':'vote.voting_guard='+a['vote']['voting_guard']};if(!a['current_voting_guard_addresses']['includes'](a['vote']['voting_guard']))return{'id':'R-AB-2-01','level':'HIGH','category':'semantic','title':'voting_guard\x20misconfiguration\x20—\x20dispute\x20cannot\x20be\x20resolved','description':'vote.voting_guard\x20'+a['vote']['voting_guard']+'\x20not\x20in\x20Arbitration.voting_guard\x20list','affected_stakeholders':['voter','arbiter','disputant'],'scenario':'Voter\x27s\x20Guard\x20not\x20registered\x20—\x20vote\x20will\x20fail\x20with\x20E_VOTING_GUARD_NOT_FOUND','mitigation':'Add\x20guard\x20'+a['vote']['voting_guard']+'\x20via\x20voting_guard_add\x20(354),\x20or\x20use\x20a\x20registered\x20guard','evidence':'provided='+a['vote']['voting_guard']+',\x20registered='+a['current_voting_guard_addresses']['join'](',')};}return null;}},R_AB_2_03={'id':'R-AB-2-03','category':'semantic','trigger':'VoteValue.GuardIdentifier\x20with\x20non-numeric\x20Guard\x20submission\x20type','check':a=>{if(a['voting_guard']&&(a['voting_guard']['op']==='add'||a['voting_guard']['op']==='set'))for(const b of a['voting_guard']['guards']){const c=b['vote_weight'];if('GuardIdentifier'in c&&c['GuardIdentifier']!==undefined){if(c['GuardIdentifier']>0xff)return{'id':'R-AB-2-03','level':'HIGH','category':'semantic','title':'GuardIdentifier\x20index\x20>\x20u8::max\x20(255)','description':'GuardIdentifier\x20'+c['GuardIdentifier']+'\x20exceeds\x20u8\x20max\x20(255)','affected_stakeholders':['owner'],'scenario':'Setting\x20GuardIdentifier\x20index\x20beyond\x20u8\x20range','mitigation':'Use\x20GuardIdentifier\x20index\x200-255','evidence':'identifier='+c['GuardIdentifier']};}if('FixedValue'in c&&c['FixedValue']!==undefined){if(c['FixedValue']>0xffffffff)return{'id':'R-AB-2-03','level':'HIGH','category':'semantic','title':'FixedValue\x20>\x20u32::max\x20(4294967295)','description':'FixedValue\x20'+c['FixedValue']+'\x20exceeds\x20u32\x20max','affected_stakeholders':['owner'],'scenario':'Setting\x20FixedValue\x20beyond\x20u32\x20range','mitigation':'Use\x20FixedValue\x200-4294967295','evidence':'fixed='+c['FixedValue']};}}return null;}},R_AB_3_01={'id':'R-AB-3-01','category':'authority','trigger':'Arbiter\x20collusion\x20—\x20single\x20voter\x20controls\x20>50%\x20of\x20total\x20weight','check':a=>{if(!a['voting_guard']||a['voting_guard']['op']!=='add'&&a['voting_guard']['op']!=='set')return null;const b=a['voting_guard']['guards'];if(b['length']<0x2)return null;const c=b['filter'](f=>'FixedValue'in f['vote_weight']&&f['vote_weight']['FixedValue']!==undefined)['map'](f=>f['vote_weight']['FixedValue']);if(c['length']===0x0)return null;const d=c['reduce']((f,g)=>f+g,0x0),e=Math['max'](...c);if(d>0x0&&e/d>0.5)return{'id':'R-AB-3-01','level':'MEDIUM','category':'authority','title':'Arbiter\x20collusion\x20risk\x20—\x20single\x20guard\x20controls\x20>50%\x20weight','description':'One\x20voting_guard\x20has\x20'+e+'\x20of\x20'+d+'\x20total\x20weight\x20('+(e/d*0x64)['toFixed'](0x1)+'%)','affected_stakeholders':['owner','disputant'],'scenario':'Weighted\x20voting\x20with\x20dominant\x20arbiter\x20—\x20can\x20single-handedly\x20decide\x20rulings','mitigation':'Distribute\x20weight\x20more\x20evenly,\x20or\x20require\x20multi-arbiter\x20consensus','evidence':'max='+e+',\x20total='+d+',\x20ratio='+(e/d*0x64)['toFixed'](0x1)+'%'};return null;}},R_AB_3_02={'id':'R-AB-3-02','category':'authority','trigger':'Permission\x20over-concentration\x20—\x20single\x20admin\x20(owner)','check':a=>{if(a['builder'])return{'id':'R-AB-3-02','level':'HIGH','category':'authority','title':'Arbitration\x20ownership\x20transfer\x20—\x20IRREVERSIBLE','description':'Transferring\x20Arbitration\x20to\x20'+a['builder']+';\x20original\x20owner\x20loses\x20all\x20control\x20permanently','affected_stakeholders':['owner'],'scenario':'Transferring\x20Arbitration\x20ownership','mitigation':'1)\x20Verify\x20new\x20owner\x20twice.\x202)\x20Confirm\x20new\x20owner\x20has\x20350-368\x20permissions\x20configured.\x203)\x20Coordinate\x20before\x20transfer.','evidence':'new_owner='+a['builder']};return null;}},R_AB_3_03={'id':'R-AB-3-03','category':'authority','trigger':'ARBITRATION_ARBITRATION\x20(359)\x20granted\x20to\x20wide\x20audience','check':a=>{if(a['arbitration']&&!a['current_voting_guard_addresses']?.['length'])return{'id':'R-AB-3-03','level':'MEDIUM','category':'authority','title':'Ruling\x20without\x20voting_guard\x20—\x20single-arbiter\x20can\x20rule\x20unchallenged','description':'make_ruling\x20(359)\x20without\x20voting_guard\x20means\x20any\x20permission\x20holder\x20can\x20unilaterally\x20decide','affected_stakeholders':['disputant','voter'],'scenario':'Single-arbiter\x20Arbitration\x20without\x20consensus\x20check','mitigation':'Configure\x20voting_guard\x20(354)\x20to\x20require\x20multi-arbiter\x20consensus\x20before\x20ruling','evidence':'voting_guard=empty'};return null;}},R_AB_4_01={'id':'R-AB-4-01','category':'lifecycle','trigger':'Invalid\x20Arb\x20status\x20transition\x20(7-state\x20flow\x20violation)','check':a=>{if(!a['current_arb_status']||!a['expected_arb_status'])return null;if(a['current_arb_status']===a['expected_arb_status'])return null;if(!isValidArbStatusTransition(a['current_arb_status'],a['expected_arb_status']))return{'id':'R-AB-4-01','level':'CRITICAL','category':'lifecycle','title':'Invalid\x20Arb\x20status\x20transition','description':a['current_arb_status']+'\x20→\x20'+a['expected_arb_status']+'\x20is\x20not\x20a\x20valid\x207-state\x20flow\x20transition','affected_stakeholders':['arbiter','disputant'],'scenario':'Attempting\x20operation\x20out\x20of\x20order\x20(e.g.\x20vote\x20before\x20confirm)','mitigation':'Follow\x20the\x207-state\x20flow:\x20Principal_confirming\x20→\x20Arbitrator_confirming\x20→\x20Voting\x20→\x20Arbitrated\x20→\x20Objectionable\x20→\x20Finished/Withdrawn','evidence':a['current_arb_status']+'\x20→\x20'+a['expected_arb_status']};return null;}},R_AB_4_02={'id':'R-AB-4-02','category':'lifecycle','trigger':'Operation\x20on\x20terminal\x20Arb\x20status\x20(Finished/Withdrawn)','check':a=>{if(!a['current_arb_status'])return null;if(isTerminalArbStatus(a['current_arb_status'])){const b=a['arb_withdraw'];if(!b&&(a['vote']||a['confirm']||a['arbitration']||a['reset']||a['feedback']))return{'id':'R-AB-4-02','level':'HIGH','category':'lifecycle','title':'Operation\x20on\x20terminal\x20Arb\x20status\x20—\x20irreversible','description':'Arb\x20is\x20in\x20terminal\x20status\x20'+a['current_arb_status']+';\x20only\x20arb_withdraw\x20is\x20allowed','affected_stakeholders':['arbiter','disputant'],'scenario':'Voting/ruling/reset\x20on\x20a\x20Finished\x20or\x20Withdrawn\x20Arb','mitigation':'Open\x20a\x20new\x20Arb\x20case\x20via\x20dispute()\x20if\x20further\x20arbitration\x20is\x20needed','evidence':'status='+a['current_arb_status']};}return null;}},R_AB_4_03={'id':'R-AB-4-03','category':'lifecycle','trigger':'reset\x20operation\x20—\x20may\x20indefinitely\x20extend\x20arbitration','check':a=>{if(!a['reset'])return null;return{'id':'R-AB-4-03','level':'MEDIUM','category':'lifecycle','title':'reset\x20operation\x20—\x20arbitration\x20lifecycle\x20extended','description':'reset\x20on\x20Arb\x20'+a['reset']['arb']+'\x20restarts\x20lifecycle\x20to\x20Principal_confirming;\x20feedback\x20required','affected_stakeholders':['arbiter','disputant'],'scenario':'Disputant\x20objects\x20to\x20ruling\x20and\x20resubmits\x20materials','mitigation':'Track\x20reset\x20count\x20—\x20consider\x20capping\x20resets\x20to\x20prevent\x20abuse','evidence':'arb='+a['reset']['arb']};}},R_AB_5_01={'id':'R-AB-5-01','category':'cross_object','trigger':'fees_alloc/fees_transfer\x20unfair\x20distribution\x20—\x20destination\x20not\x20verified','check':a=>{if(!a['fees_transfer'])return null;const b='allocation'in a['fees_transfer']['to']?'Allocation\x20'+a['fees_transfer']['to']['allocation']:'Treasury\x20'+a['fees_transfer']['to']['treasury'];return{'id':'R-AB-5-01','level':'MEDIUM','category':'cross_object','title':'fees_alloc/fees_transfer\x20—\x20verify\x20destination\x20fairness','description':'All\x20Arbitration.balance\x20will\x20be\x20transferred\x20to\x20'+b+';\x20ensure\x20destination\x20policy\x20is\x20fair\x20to\x20arbiters','affected_stakeholders':['arbiter','owner'],'scenario':'Distributing\x20arbitration\x20fees\x20without\x20verifying\x20allocation\x20rules','mitigation':'Verify\x20'+b+'\x20has\x20fair\x20distribution\x20policy;\x20consider\x20allocating\x20to\x20arbiters\x27\x20Allocation','evidence':'dest='+b+',\x20remark='+a['fees_transfer']['payment_remark']};}},R_AB_5_02={'id':'R-AB-5-02','category':'cross_object','trigger':'Dispute\x20filed\x20but\x20Order\x20op\x20permission\x20not\x20verified\x20—\x20E_NOT_OP_PERMISSION','check':a=>{if(!a['dispute'])return null;return{'id':'R-AB-5-02','level':'HIGH','category':'cross_object','title':'Order\x20op\x20permission\x20required\x20for\x20dispute','description':'dispute\x20on\x20Order\x20'+a['dispute']['order']+'\x20requires\x20order::assert_op_permission;\x20signer\x20must\x20have\x20Order\x27s\x20dispute\x20permission','affected_stakeholders':['disputant'],'scenario':'Filing\x20dispute\x20without\x20Order\x20op\x20permission','mitigation':'Ensure\x20signer\x20has\x20Order\x27s\x20dispute\x20operation\x20permission\x20(custom\x20index\x20or\x20builtin)','evidence':'order='+a['dispute']['order']};}},ALL_RULES=[R_AB_1_01,R_AB_1_02,R_AB_1_03,R_AB_1_04,R_AB_2_01,R_AB_2_03,R_AB_3_01,R_AB_3_02,R_AB_3_03,R_AB_4_01,R_AB_4_02,R_AB_4_03,R_AB_5_01,R_AB_5_02];export const ARBITRATION_RISK_VERSION='1.0.0';export function getAllRiskRules(){return[...ALL_RULES];}export function getRiskRulesCount(){return ALL_RULES['length'];}export function getRiskRulesByCategory(a){return ALL_RULES['filter'](b=>b['category']===a);}export function assessArbitrationRisks(a){const b=[];for(const f of ALL_RULES){const g=f['check'](a);if(g)b['push'](g);}const c=b['length']===0x0?'LOW':b['some'](h=>h['level']==='CRITICAL')?'CRITICAL':b['some'](h=>h['level']==='HIGH')?'HIGH':b['some'](h=>h['level']==='MEDIUM')?'MEDIUM':'LOW',d={};for(const h of b){d[h['category']]=(d[h['category']]??0x0)+0x1;}const e={};for(const i of b){for(const j of i['affected_stakeholders']){if(!e[j])e[j]=[];e[j]['push'](i['id']+':\x20'+i['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,'stakeholder_advice':e,'needs_human_review':b['some'](k=>k['level']==='CRITICAL'||k['level']==='HIGH')};}
1
+ import{MAX_VOTING_GUARD_COUNT}from'@wowok/wowok';import{isTerminalArbStatus,isValidArbStatusTransition}from'./arbitration-ledger.js';const R_AB_1_01={'id':'R-AB-1-01','category':'structural','trigger':'voting_guard\x20count\x20exceeds\x20MAX_VOTING_GUARD_COUNT\x20(50)','check':a=>{if(!a['voting_guard'])return null;if(a['voting_guard']['op']==='add'||a['voting_guard']['op']==='set'){const b=a['voting_guard']['op']==='set'?a['voting_guard']['guards']['length']:(a['current_voting_guard_count']??0x0)+a['voting_guard']['guards']['length'];if(b>MAX_VOTING_GUARD_COUNT)return{'id':'R-AB-1-01','level':'HIGH','category':'structural','title':'voting_guard\x20count\x20exceeds\x20limit','description':'voting_guard\x20would\x20have\x20'+b+'\x20entries,\x20exceeds\x20MAX_VOTING_GUARD_COUNT\x20'+MAX_VOTING_GUARD_COUNT,'affected_stakeholders':['owner','arbiter'],'scenario':'Adding\x20too\x20many\x20voting\x20guards','mitigation':'Remove\x20unused\x20guards\x20before\x20adding\x20new\x20ones;\x20max\x20'+MAX_VOTING_GUARD_COUNT,'evidence':'count='+b};}return null;}},R_AB_1_02={'id':'R-AB-1-02','category':'structural','trigger':'Dispute\x20fee\x20below\x20arbitration.fee\x20threshold','check':a=>{if(!a['dispute']||a['current_arbitration_fee']===undefined)return null;const b=typeof a['current_arbitration_fee']==='string'?BigInt(a['current_arbitration_fee']):BigInt(a['current_arbitration_fee']),c=typeof a['dispute']['fee']==='object'&&a['dispute']['fee']!==null&&'balance'in a['dispute']['fee']?BigInt(a['dispute']['fee']['balance']??0x0):BigInt(0x0);if(c<b)return{'id':'R-AB-1-02','level':'CRITICAL','category':'structural','title':'Dispute\x20fee\x20insufficient\x20(E_FEE_NOT_ENOUGH)','description':'Provided\x20fee\x20'+c['toString']()+'\x20<\x20required\x20'+b['toString'](),'affected_stakeholders':['disputant'],'scenario':'Filing\x20dispute\x20with\x20insufficient\x20fee','mitigation':'Increase\x20dispute.fee.balance\x20to\x20>=\x20'+b['toString'](),'evidence':'provided='+c['toString']()+',\x20required='+b['toString']()};return null;}},R_AB_1_03={'id':'R-AB-1-03','category':'structural','trigger':'Arbitration\x20paused\x20(bPaused=true)\x20—\x20dispute\x20will\x20fail\x20with\x20E_PAUSED','check':a=>{if(a['dispute']&&a['current_bPaused']===!![])return{'id':'R-AB-1-03','level':'HIGH','category':'structural','title':'Arbitration\x20paused\x20—\x20cannot\x20file\x20dispute','description':'Arbitration.bPaused=true;\x20dispute()\x20will\x20abort\x20with\x20E_PAUSED','affected_stakeholders':['disputant'],'scenario':'Filing\x20dispute\x20against\x20a\x20paused\x20Arbitration','mitigation':'Call\x20pause(false)\x20(requires\x20ARBITRATION_PAUSE=356)\x20to\x20resume','evidence':'bPaused=true'};return null;}},R_AB_1_04={'id':'R-AB-1-04','category':'structural','trigger':'voting_deadline\x20in\x20the\x20past\x20—\x20vote\x20will\x20be\x20rejected','check':a=>{const b=a['confirm']?.['voting_deadline']??a['voting_deadline_change']?.['voting_deadline'];if(b!==undefined&&b!==null&&a['current_timestamp_ms']!==undefined){if(b<a['current_timestamp_ms'])return{'id':'R-AB-1-04','level':'HIGH','category':'structural','title':'voting_deadline\x20in\x20the\x20past','description':'Deadline\x20'+b+'\x20is\x20before\x20current\x20time\x20'+a['current_timestamp_ms'],'affected_stakeholders':['voter','arbiter'],'scenario':'Setting\x20voting\x20deadline\x20to\x20an\x20already-elapsed\x20timestamp','mitigation':'Use\x20a\x20future\x20timestamp\x20(e.g.\x20now\x20+\x207\x20days\x20in\x20ms)','evidence':'deadline='+b+',\x20now='+a['current_timestamp_ms']};}return null;}},R_AB_2_01={'id':'R-AB-2-01','category':'semantic','trigger':'voting_guard\x20misconfiguration\x20—\x20dispute\x20cannot\x20be\x20resolved','check':a=>{if(a['vote']&&a['vote']['voting_guard']){if(!a['current_voting_guard_addresses']||a['current_voting_guard_addresses']['length']===0x0)return{'id':'R-AB-2-01','level':'HIGH','category':'semantic','title':'voting_guard\x20misconfiguration\x20—\x20dispute\x20cannot\x20be\x20resolved','description':'vote.voting_guard\x20provided\x20but\x20Arbitration.voting_guard\x20is\x20empty;\x20E_VOTING_GUARD_NOT_FOUND\x20will\x20abort','affected_stakeholders':['voter','arbiter','disputant'],'scenario':'voting_guard\x20misconfiguration\x20prevents\x20vote\x20—\x20dispute\x20stuck','mitigation':'Either\x20add\x20the\x20Guard\x20to\x20voting_guard\x20list\x20(354)\x20or\x20use\x20open\x20vote()\x20without\x20voting_guard','evidence':'vote.voting_guard='+a['vote']['voting_guard']};if(!a['current_voting_guard_addresses']['includes'](a['vote']['voting_guard']))return{'id':'R-AB-2-01','level':'HIGH','category':'semantic','title':'voting_guard\x20misconfiguration\x20—\x20dispute\x20cannot\x20be\x20resolved','description':'vote.voting_guard\x20'+a['vote']['voting_guard']+'\x20not\x20in\x20Arbitration.voting_guard\x20list','affected_stakeholders':['voter','arbiter','disputant'],'scenario':'Voter\x27s\x20Guard\x20not\x20registered\x20—\x20vote\x20will\x20fail\x20with\x20E_VOTING_GUARD_NOT_FOUND','mitigation':'Add\x20guard\x20'+a['vote']['voting_guard']+'\x20via\x20voting_guard_add\x20(354),\x20or\x20use\x20a\x20registered\x20guard','evidence':'provided='+a['vote']['voting_guard']+',\x20registered='+a['current_voting_guard_addresses']['join'](',')};}return null;}},R_AB_2_03={'id':'R-AB-2-03','category':'semantic','trigger':'VoteValue.GuardIdentifier\x20with\x20non-numeric\x20Guard\x20submission\x20type','check':a=>{if(a['voting_guard']&&(a['voting_guard']['op']==='add'||a['voting_guard']['op']==='set'))for(const b of a['voting_guard']['guards']){const c=b['vote_weight'];if('GuardIdentifier'in c&&c['GuardIdentifier']!==undefined){if(c['GuardIdentifier']>0xff)return{'id':'R-AB-2-03','level':'HIGH','category':'semantic','title':'GuardIdentifier\x20index\x20>\x20u8::max\x20(255)','description':'GuardIdentifier\x20'+c['GuardIdentifier']+'\x20exceeds\x20u8\x20max\x20(255)','affected_stakeholders':['owner'],'scenario':'Setting\x20GuardIdentifier\x20index\x20beyond\x20u8\x20range','mitigation':'Use\x20GuardIdentifier\x20index\x200-255','evidence':'identifier='+c['GuardIdentifier']};}if('FixedValue'in c&&c['FixedValue']!==undefined){if(c['FixedValue']>0xffffffff)return{'id':'R-AB-2-03','level':'HIGH','category':'semantic','title':'FixedValue\x20>\x20u32::max\x20(4294967295)','description':'FixedValue\x20'+c['FixedValue']+'\x20exceeds\x20u32\x20max','affected_stakeholders':['owner'],'scenario':'Setting\x20FixedValue\x20beyond\x20u32\x20range','mitigation':'Use\x20FixedValue\x200-4294967295','evidence':'fixed='+c['FixedValue']};}}return null;}},R_AB_3_01={'id':'R-AB-3-01','category':'authority','trigger':'Arbiter\x20collusion\x20—\x20single\x20voter\x20controls\x20>50%\x20of\x20total\x20weight','check':a=>{if(!a['voting_guard']||a['voting_guard']['op']!=='add'&&a['voting_guard']['op']!=='set')return null;const b=a['voting_guard']['guards'];if(b['length']<0x2)return null;const c=b['filter'](f=>'FixedValue'in f['vote_weight']&&f['vote_weight']['FixedValue']!==undefined)['map'](f=>f['vote_weight']['FixedValue']);if(c['length']===0x0)return null;const d=c['reduce']((f,g)=>f+g,0x0),e=Math['max'](...c);if(d>0x0&&e/d>0.5)return{'id':'R-AB-3-01','level':'MEDIUM','category':'authority','title':'Arbiter\x20collusion\x20risk\x20—\x20single\x20guard\x20controls\x20>50%\x20weight','description':'One\x20voting_guard\x20has\x20'+e+'\x20of\x20'+d+'\x20total\x20weight\x20('+(e/d*0x64)['toFixed'](0x1)+'%)','affected_stakeholders':['owner','disputant'],'scenario':'Weighted\x20voting\x20with\x20dominant\x20arbiter\x20—\x20can\x20single-handedly\x20decide\x20rulings','mitigation':'Distribute\x20weight\x20more\x20evenly,\x20or\x20require\x20multi-arbiter\x20consensus','evidence':'max='+e+',\x20total='+d+',\x20ratio='+(e/d*0x64)['toFixed'](0x1)+'%'};return null;}},R_AB_3_02={'id':'R-AB-3-02','category':'authority','trigger':'Permission\x20over-concentration\x20—\x20single\x20admin\x20(owner)','check':a=>{if(a['builder'])return{'id':'R-AB-3-02','level':'HIGH','category':'authority','title':'Arbitration\x20ownership\x20transfer\x20—\x20IRREVERSIBLE','description':'Transferring\x20Arbitration\x20to\x20'+a['builder']+';\x20original\x20owner\x20loses\x20all\x20control\x20permanently','affected_stakeholders':['owner'],'scenario':'Transferring\x20Arbitration\x20ownership','mitigation':'1)\x20Verify\x20new\x20owner\x20twice.\x202)\x20Confirm\x20new\x20owner\x20has\x20350-368\x20permissions\x20configured.\x203)\x20Coordinate\x20before\x20transfer.','evidence':'new_owner='+a['builder']};return null;}},R_AB_3_03={'id':'R-AB-3-03','category':'authority','trigger':'ARBITRATION_ARBITRATION\x20(359)\x20granted\x20to\x20wide\x20audience','check':a=>{if(a['arbitration']&&!a['current_voting_guard_addresses']?.['length'])return{'id':'R-AB-3-03','level':'MEDIUM','category':'authority','title':'Ruling\x20without\x20voting_guard\x20—\x20single-arbiter\x20can\x20rule\x20unchallenged','description':'make_ruling\x20(359)\x20without\x20voting_guard\x20means\x20any\x20permission\x20holder\x20can\x20unilaterally\x20decide','affected_stakeholders':['disputant','voter'],'scenario':'Single-arbiter\x20Arbitration\x20without\x20consensus\x20check','mitigation':'Configure\x20voting_guard\x20(354)\x20to\x20require\x20multi-arbiter\x20consensus\x20before\x20ruling','evidence':'voting_guard=empty'};return null;}},R_AB_4_01={'id':'R-AB-4-01','category':'lifecycle','trigger':'Invalid\x20Arb\x20status\x20transition\x20(7-state\x20flow\x20violation)','check':a=>{if(!a['current_arb_status']||!a['expected_arb_status'])return null;if(a['current_arb_status']===a['expected_arb_status'])return null;if(!isValidArbStatusTransition(a['current_arb_status'],a['expected_arb_status']))return{'id':'R-AB-4-01','level':'CRITICAL','category':'lifecycle','title':'Invalid\x20Arb\x20status\x20transition','description':a['current_arb_status']+'\x20→\x20'+a['expected_arb_status']+'\x20is\x20not\x20a\x20valid\x207-state\x20flow\x20transition','affected_stakeholders':['arbiter','disputant'],'scenario':'Attempting\x20operation\x20out\x20of\x20order\x20(e.g.\x20vote\x20before\x20confirm)','mitigation':'Follow\x20the\x207-state\x20flow:\x20Principal_confirming\x20→\x20Arbitrator_confirming\x20→\x20Voting\x20→\x20Arbitrated\x20→\x20Objectionable\x20→\x20Finished/Withdrawn','evidence':a['current_arb_status']+'\x20→\x20'+a['expected_arb_status']};return null;}},R_AB_4_02={'id':'R-AB-4-02','category':'lifecycle','trigger':'Operation\x20on\x20terminal\x20Arb\x20status\x20(Finished/Withdrawn)','check':a=>{if(!a['current_arb_status'])return null;if(isTerminalArbStatus(a['current_arb_status'])){const b=a['arb_withdraw'];if(!b&&(a['vote']||a['confirm']||a['arbitration']||a['reset']||a['feedback']))return{'id':'R-AB-4-02','level':'HIGH','category':'lifecycle','title':'Operation\x20on\x20terminal\x20Arb\x20status\x20—\x20irreversible','description':'Arb\x20is\x20in\x20terminal\x20status\x20'+a['current_arb_status']+';\x20only\x20arb_withdraw\x20is\x20allowed','affected_stakeholders':['arbiter','disputant'],'scenario':'Voting/ruling/reset\x20on\x20a\x20Finished\x20or\x20Withdrawn\x20Arb','mitigation':'Open\x20a\x20new\x20Arb\x20case\x20via\x20dispute()\x20if\x20further\x20arbitration\x20is\x20needed','evidence':'status='+a['current_arb_status']};}return null;}},R_AB_4_03={'id':'R-AB-4-03','category':'lifecycle','trigger':'reset\x20operation\x20—\x20may\x20indefinitely\x20extend\x20arbitration','check':a=>{if(!a['reset'])return null;return{'id':'R-AB-4-03','level':'MEDIUM','category':'lifecycle','title':'reset\x20operation\x20—\x20arbitration\x20lifecycle\x20extended','description':'reset\x20on\x20Arb\x20'+a['reset']['arb']+'\x20restarts\x20lifecycle\x20to\x20Principal_confirming;\x20feedback\x20required','affected_stakeholders':['arbiter','disputant'],'scenario':'Disputant\x20objects\x20to\x20ruling\x20and\x20resubmits\x20materials','mitigation':'Track\x20reset\x20count\x20—\x20consider\x20capping\x20resets\x20to\x20prevent\x20abuse','evidence':'arb='+a['reset']['arb']};}},R_AB_5_01={'id':'R-AB-5-01','category':'cross_object','trigger':'fees_alloc/fees_transfer\x20unfair\x20distribution\x20—\x20destination\x20not\x20verified','check':a=>{if(!a['fees_transfer'])return null;const b='allocation'in a['fees_transfer']['to']?'Allocation\x20'+a['fees_transfer']['to']['allocation']:'Treasury\x20'+a['fees_transfer']['to']['treasury'];return{'id':'R-AB-5-01','level':'MEDIUM','category':'cross_object','title':'fees_alloc/fees_transfer\x20—\x20verify\x20destination\x20fairness','description':'All\x20Arbitration.balance\x20will\x20be\x20transferred\x20to\x20'+b+';\x20ensure\x20destination\x20policy\x20is\x20fair\x20to\x20arbiters','affected_stakeholders':['arbiter','owner'],'scenario':'Distributing\x20arbitration\x20fees\x20without\x20verifying\x20allocation\x20rules','mitigation':'Verify\x20'+b+'\x20has\x20fair\x20distribution\x20policy;\x20consider\x20allocating\x20to\x20arbiters\x27\x20Allocation','evidence':'dest='+b+',\x20remark='+a['fees_transfer']['payment_remark']};}},R_AB_5_02={'id':'R-AB-5-02','category':'cross_object','trigger':'Dispute\x20filed\x20but\x20Order\x20op\x20permission\x20not\x20verified\x20—\x20E_NOT_OP_PERMISSION','check':a=>{if(!a['dispute'])return null;return{'id':'R-AB-5-02','level':'HIGH','category':'cross_object','title':'Order\x20op\x20permission\x20required\x20for\x20dispute','description':'dispute\x20on\x20Order\x20'+a['dispute']['order']+'\x20requires\x20order::assert_op_permission;\x20signer\x20must\x20have\x20Order\x27s\x20dispute\x20permission','affected_stakeholders':['disputant'],'scenario':'Filing\x20dispute\x20without\x20Order\x20op\x20permission','mitigation':'Ensure\x20signer\x20has\x20Order\x27s\x20dispute\x20operation\x20permission\x20(custom\x20index\x20or\x20builtin)','evidence':'order='+a['dispute']['order']};}},ALL_RULES=[R_AB_1_01,R_AB_1_02,R_AB_1_03,R_AB_1_04,R_AB_2_01,R_AB_2_03,R_AB_3_01,R_AB_3_02,R_AB_3_03,R_AB_4_01,R_AB_4_02,R_AB_4_03,R_AB_5_01,R_AB_5_02];export const ARBITRATION_RISK_VERSION='1.0.0';export function getAllRiskRules(){return[...ALL_RULES];}export function assessArbitrationRisks(a){const b=[];for(const f of ALL_RULES){const g=f['check'](a);if(g)b['push'](g);}const c=b['length']===0x0?'LOW':b['some'](h=>h['level']==='CRITICAL')?'CRITICAL':b['some'](h=>h['level']==='HIGH')?'HIGH':b['some'](h=>h['level']==='MEDIUM')?'MEDIUM':'LOW',d={};for(const h of b){d[h['category']]=(d[h['category']]??0x0)+0x1;}const e={};for(const i of b){for(const j of i['affected_stakeholders']){if(!e[j])e[j]=[];e[j]['push'](i['id']+':\x20'+i['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,'stakeholder_advice':e,'needs_human_review':b['some'](k=>k['level']==='CRITICAL'||k['level']==='HIGH')};}
@@ -0,0 +1,79 @@
1
+ {
2
+ "version": 1,
3
+ "description": "Graph service evaluation standards — the canonical defaults document. The engine loads weights, dimension labels, severity deductions and level bands from HERE; an account persona may override per-dimension weights at runtime (persona layer 'evaluation.weights' → UserInjection.overrides.rules[id].weight), and an explicit request injection wins over persona. Weights are relative; the aggregate renormalizes over the enabled rules.",
4
+ "weights": {
5
+ "trust_arbitration": 20,
6
+ "trust_reviews": 35,
7
+ "trust_fulfillment": 20,
8
+ "trust_fund_safety": 15,
9
+ "trust_transparency": 10,
10
+ "risk_workflow": 35,
11
+ "risk_fund": 25,
12
+ "risk_trust": 20,
13
+ "risk_behavior": 20
14
+ },
15
+ "dimensions": {
16
+ "trust_arbitration": {
17
+ "label": "Arbitration",
18
+ "description": "Binding arbitration coverage of the service's payment paths."
19
+ },
20
+ "trust_reviews": {
21
+ "label": "Reputation",
22
+ "description": "Verified review votes on the service's review window."
23
+ },
24
+ "trust_fulfillment": {
25
+ "label": "Fulfillment",
26
+ "description": "Observed orders and a verifiable machine workflow (terminal set)."
27
+ },
28
+ "trust_fund_safety": {
29
+ "label": "Fund safety",
30
+ "description": "Compensation fund vs 3x windowed order volume (statutory ceiling)."
31
+ },
32
+ "trust_transparency": {
33
+ "label": "Transparency",
34
+ "description": "Snapshot self-description, lock duration and published flag."
35
+ },
36
+ "risk_workflow": {
37
+ "label": "Workflow risk",
38
+ "description": "Structural analyzer findings on the machine workflow."
39
+ },
40
+ "risk_fund": {
41
+ "label": "Fund risk",
42
+ "description": "Structural analyzer findings on fund paths and payouts."
43
+ },
44
+ "risk_trust": {
45
+ "label": "Trust-surface risk",
46
+ "description": "Structural analyzer findings on the trust surface (arb/review/fund hooks)."
47
+ },
48
+ "risk_behavior": {
49
+ "label": "Behavior risk",
50
+ "description": "Structural analyzer findings on operator behavior controls."
51
+ }
52
+ },
53
+ "severity_deduction": {
54
+ "critical": 50,
55
+ "high": 25,
56
+ "medium": 10,
57
+ "low": 5,
58
+ "info": 0
59
+ },
60
+ "level_bands": [
61
+ { "min": 85, "level": "low" },
62
+ { "min": 70, "level": "medium_low" },
63
+ { "min": 50, "level": "medium_high" },
64
+ { "min": 0, "level": "high" }
65
+ ],
66
+ "grade_words": {
67
+ "comment": "Readable per-side grade rendered from the score. trust: higher score = better service; risk: higher score = fewer findings (safer).",
68
+ "trust": [
69
+ { "min": 70, "word": "strong" },
70
+ { "min": 50, "word": "fair" },
71
+ { "min": 0, "word": "weak" }
72
+ ],
73
+ "risk": [
74
+ { "min": 80, "word": "low risk" },
75
+ { "min": 50, "word": "moderate risk" },
76
+ { "min": 0, "word": "high risk" }
77
+ ]
78
+ }
79
+ }
@@ -0,0 +1 @@
1
+ import{describe,expect,it}from'vitest';import{readFileSync,writeFileSync}from'node:fs';import{fileURLToPath}from'node:url';import{dirname,join}from'node:path';import{lintGuard}from'../guard-lint.js';const CASES={'whitelist':{'description':'Whitelist\x20purchase\x20validation','table':[{'identifier':0x0,'b_submission':![],'value_type':'VecAddress','value':['0xabc','0xdef'],'name':'Authorized\x20purchase\x20whitelist'}],'root':{'type':'vec_contains_address','nodes':[{'type':'identifier','identifier':0x0},{'type':'context','context':'Signer'}]}},'allocator_identifier':{'description':'Allocator\x20selector','table':[{'identifier':0x0,'b_submission':![],'value_type':'Address','value':'0xabc','name':'selector'}],'root':{'type':'identifier','identifier':0x0},'binding_hint':{'host_object':'Service','binding_field':'order_allocators'}}};async function runCase(a){const b=await lintGuard(a,{'auto_fix':![]});return{'risk_diagnostics':b['diagnostics']['filter'](c=>c['source']==='risk')['map'](c=>({'code':c['code'],'severity':c['severity'],'path':c['location']['path']})),'risk_assessment':(b['risk_assessment']?.['risks']??[])['map'](c=>({'id':c['id'],'level':c['level']})),'summary':{'errors':b['summary']['errors'],'warnings':b['summary']['warnings'],'infos':b['summary']['infos'],'ready':b['summary']['ready']}};}const here=dirname(fileURLToPath(import.meta.url)),SNAPSHOT=join(here,'guard-lint-baseline.json');describe('guard-lint\x20risk\x20section\x20—\x20pre-migration\x20baseline',()=>{it('matches\x20the\x20committed\x20snapshot\x20(regenerate\x20only\x20with\x20UPDATE_RISK_BASELINE=1)',async()=>{const a={};for(const [c,d]of Object['entries'](CASES)){a[c]=await runCase(d);}if(process['env']['UPDATE_RISK_BASELINE']==='1'){writeFileSync(SNAPSHOT,JSON['stringify'](a,null,0x2)+'\x0a','utf8');return;}const b=JSON['parse'](readFileSync(SNAPSHOT,'utf8'));expect(a)['toEqual'](b);}),it('every\x20case\x20reaches\x20the\x20risk\x20section\x20(at\x20least\x20one\x20risk\x20diagnostic)',async()=>{for(const [a,b]of Object['entries'](CASES)){const c=await runCase(b);expect(c['risk_diagnostics']['length'],a+':\x20risk\x20section\x20silent')['toBeGreaterThan'](0x0);}});});
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ import{describe,expect,it}from'vitest';import{readFileSync,writeFileSync}from'node:fs';import{fileURLToPath}from'node:url';import{dirname,join}from'node:path';import{RISK_CASES}from'./risk-cases.js';import{aggregateProjectRisks}from'../../playbooks/service-build/risk-aggregator.js';import{assessTreasuryRisks}from'../treasury-risk.js';import{assessRewardRisks}from'../reward-risk.js';function toArray(a){if(Array['isArray'](a))return a;if(a&&typeof a==='object')for(const b of['risks','detected_risks']){const c=a[b];if(Array['isArray'](c))return c;}return[];}function normalize(a){return toArray(a)['map'](b=>{const c=b??{};return{'id':String(c['id']??c['risk_rule_id']??c['rule_id']??'?'),'level':String(c['level']??c['severity']??'?')['toUpperCase'](),...c['evidence']!=null?{'evidence':String(c['evidence'])}:{}};})['sort']((c,d)=>c['id']===d['id']?(c['evidence']??'')['localeCompare'](d['evidence']??''):c['id']['localeCompare'](d['id']));}function runCase(a,b){try{return{'risks':normalize(a(b)),'threw':![]};}catch(c){return{'risks':[],'threw':!![]};}}function collect(){const a={};for(const b of RISK_CASES){const d=runCase(b['run'],b['empty']),e=runCase(b['run'],b['trigger']);a[b['pack']]={'objectType':b['objectType'],'empty':d['risks'],'emptyThrew':d['threw'],'trigger':e['risks']};}return a;}const here=dirname(fileURLToPath(import.meta.url)),SNAPSHOT=join(here,'risk-baselines.json'),AGG_SNAPSHOT=join(here,'aggregator-baselines.json');function puzzlesFrom(a){const b={};for(const d of RISK_CASES){if(d['pack']==='arb')continue;b[d['objectType']]={'puzzle':a(d)};}return b;}async function runAggregator(a){const b=await aggregateProjectRisks({'project_prefix':'baseline','version':'v1','industry':'general','puzzles':puzzlesFrom(a)});return{'severity_summary':b['severity_summary'],'status':b['status'],'findings':b['findings']['map'](c=>({'risk_rule_id':c['risk_rule_id'],'object_type':c['object_type'],'severity':c['severity']})),'warnings':b['warnings']};}describe('write-side\x20risk\x20packs\x20—\x20pre-migration\x20baseline',()=>{it('every\x20pack\x20trigger\x20context\x20fires\x20at\x20least\x20one\x20pack-specific\x20rule',()=>{for(const a of RISK_CASES){const {risks:b}=runCase(a['run'],a['trigger']);expect(b['length'],'pack\x20'+a['pack']+'\x20trigger\x20fired\x20nothing')['toBeGreaterThan'](0x0);}}),it('matches\x20the\x20committed\x20snapshot\x20(regenerate\x20only\x20with\x20--update)',()=>{const a=collect();if(process['env']['UPDATE_RISK_BASELINE']==='1'){writeFileSync(SNAPSHOT,JSON['stringify'](a,null,0x2)+'\x0a','utf8');return;}const b=JSON['parse'](readFileSync(SNAPSHOT,'utf8'));expect(new Set(Object['keys'](a)))['toEqual'](new Set(Object['keys'](b)));for(const c of Object['keys'](a)['sort']()){expect(a[c],'pack\x20'+c+'\x20drifted')['toEqual'](b[c]);}});}),describe('risk\x20aggregator\x20—\x20Task\x2026\x20parity\x20(id/severity/status)',()=>{const a=[['empty',b=>b['empty']],['trigger',b=>b['trigger']]];it('matches\x20the\x20committed\x20snapshot\x20(regenerate\x20only\x20with\x20--update)',async()=>{const b={};for(const [d,e]of a)b[d]=await runAggregator(e);if(process['env']['UPDATE_RISK_BASELINE']==='1'){writeFileSync(AGG_SNAPSHOT,JSON['stringify'](b,null,0x2)+'\x0a','utf8');return;}const c=JSON['parse'](readFileSync(AGG_SNAPSHOT,'utf8'));expect(b)['toEqual'](c);}),it('trigger\x20row\x20produces\x20CRITICAL\x20blockers\x20(sanity:\x20status\x20machine\x20alive)',async()=>{const b=await runAggregator(d=>d['trigger']);expect(b['findings']['some'](c=>c['severity']==='CRITICAL'))['toBe'](!![]),expect(b['status'])['not']['toBe']('RISK_PASSED');}),it('TR-26.2\x20every\x20finding\x20carries\x20its\x20proposal-graph\x20path\x20(explainability)',async()=>{const b=await aggregateProjectRisks({'project_prefix':'baseline','version':'v1','industry':'general','puzzles':puzzlesFrom(d=>d['trigger'])});expect(b['findings']['length'])['toBeGreaterThan'](0x0);for(const c of b['findings']){expect(c['details']?.['proposal_node'],'finding\x20'+c['risk_rule_id']+'\x20has\x20no\x20proposal\x20node')['toMatch'](/^proposal::/),expect(c['details']?.['rule_source'],'finding\x20'+c['risk_rule_id']+'\x20has\x20no\x20analyzer\x20source')['not']['toBe']('');}});}),describe('R-T-2-04\x20—\x20external_withdraw\x20pays\x20only\x20the\x20transaction\x20sender',()=>{const a={'withdraw':{'amount_by_external_withdraw_guard':'release-guard','recipient':'0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'}};it('flags\x20HIGH\x20(code\x2010\x20abort\x20ahead)\x20when\x20recipient\x20!=\x20known\x20sender',()=>{const {risks:b}=assessTreasuryRisks({...a,'sender_address':'0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'}),c=b['find'](d=>d['id']==='R-T-2-04');expect(c?.['level'])['toBe']('HIGH'),expect(c?.['description']??'')['toContain']('code\x2010');}),it('stays\x20silent\x20when\x20recipient\x20equals\x20the\x20sender',()=>{const {risks:b}=assessTreasuryRisks({...a,'sender_address':'0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'});expect(b['some'](c=>c['id']==='R-T-2-04'))['toBe'](![]);}),it('advises\x20MEDIUM\x20when\x20the\x20sender\x20is\x20not\x20known\x20at\x20analysis\x20time',()=>{const {risks:b}=assessTreasuryRisks(a),c=b['find'](d=>d['id']==='R-T-2-04');expect(c?.['level'])['toBe']('MEDIUM');}),it('does\x20not\x20fire\x20on\x20the\x20fixed\x20(permissioned)\x20withdraw\x20path',()=>{const {risks:b}=assessTreasuryRisks({'withdraw':{'amount_fixed':'1000','recipient':'0xcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'},'sender_address':'0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'});expect(b['some'](c=>c['id']==='R-T-2-04'))['toBe'](![]);});}),describe('R-T-4-04\x20—\x20mounting\x20external\x20Guards\x20(owner\x20diligence\x20reminder)',()=>{it('flags\x20MEDIUM\x20when\x20mounting\x20external\x20withdraw\x20Guards',()=>{const {risks:a}=assessTreasuryRisks({'external_withdraw_guard':{'op':'add','guards':[{'guard':'0xg1','identifier':0x0}]}}),b=a['find'](c=>c['id']==='R-T-4-04');expect(b?.['level'])['toBe']('MEDIUM'),expect(b?.['description']??'')['toContain']('code\x2010');}),it('flags\x20LOW\x20when\x20mounting\x20external\x20deposit\x20Guards',()=>{const {risks:a}=assessTreasuryRisks({'external_deposit_guard':{'op':'add','guards':[{'guard':'0xg2'}]}}),b=a['find'](c=>c['id']==='R-T-4-04');expect(b?.['level'])['toBe']('LOW');}),it('stays\x20silent\x20on\x20remove/clear',()=>{const {risks:a}=assessTreasuryRisks({'external_withdraw_guard':{'op':'remove','guards':['0xg1']}});expect(a['some'](b=>b['id']==='R-T-4-04'))['toBe'](![]);});}),describe('R-R-2-05\x20—\x20mounting\x20a\x20claim\x20Guard\x20with\x20a\x20GuardIdentifier\x20payout\x20slot',()=>{const a={'guard':'0xg1','amount':{'type':'fixed','value':'100'}};it('flags\x20MEDIUM\x20when\x20the\x20recipient\x20is\x20a\x20GuardIdentifier\x20slot',()=>{const {risks:b}=assessRewardRisks({'guard_add':[{...a,'recipient':{'GuardIdentifier':0x0}}]}),c=b['find'](d=>d['id']==='R-R-2-05');expect(c?.['level'])['toBe']('MEDIUM'),expect(c?.['description']??'')['toContain']('GuardIdentifier');}),it('stays\x20silent\x20for\x20Entity/Signer\x20recipients',()=>{const {risks:b}=assessRewardRisks({'guard_add':[{...a,'recipient':{'Entity':'0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'}}]});expect(b['some'](c=>c['id']==='R-R-2-05'))['toBe'](![]);});});
@@ -0,0 +1,8 @@
1
+ export interface RiskCase {
2
+ objectType: string;
3
+ pack: string;
4
+ run: (ctx: any) => unknown;
5
+ empty: any;
6
+ trigger: any;
7
+ }
8
+ export declare const RISK_CASES: RiskCase[];
@@ -0,0 +1 @@
1
+ import{assessServiceRisks,assessMachineRisks,assessAllocationRisks,assessTreasuryRisks,assessArbitrationRisks,assessRewardRisks,assessProgressRisks,assessOrderRisks,runGuardRulePack,checkContactRisks,checkResourceRisks,checkPaymentRisks,checkArbRisks,checkPersonalRisks,checkUtilRisks,checkRegistrarRisks,checkBridgeRisks,checkProofRisks,checkRepositoryRisks,checkDemandRisks}from'../index.js';import{assessPermissionRisks}from'../permission-risk.js';const HUGE=0xa**0x9,str=a=>'x'['repeat'](a);export const RISK_CASES=[{'objectType':'service','pack':'service','run':a=>assessServiceRisks(a),'empty':{},'trigger':{'pause':!![]}},{'objectType':'machine','pack':'machine','run':a=>assessMachineRisks(a,{}),'empty':{},'trigger':{'pairs':[],'nodes':[]}},{'objectType':'allocation','pack':'allocation','run':a=>assessAllocationRisks(a),'empty':{},'trigger':{'allocators_config':{'allocators':[{'guard':'0xg1','sharing':[]},{'guard':'0xg2','sharing':[]}]},'has_fallback_allocator':![],'guard_conditions_mutually_exclusive':![]}},{'objectType':'treasury','pack':'treasury','run':a=>assessTreasuryRisks(a),'empty':{},'trigger':{'description':str(0xfa1)}},{'objectType':'arb','pack':'arbitration','run':a=>assessArbitrationRisks(a),'empty':{},'trigger':{'arbitration':'0xarb-svc'}},{'objectType':'reward','pack':'reward','run':a=>assessRewardRisks(a),'empty':{},'trigger':{'guard_add':Array['from']({'length':0xc9},(a,b)=>({'guard':'0xg'+b,'recipient':{'Entity':'0x'+(b+0x1)['toString']()['padStart'](0x40,'0')},'amount':{'type':'fixed','value':'1'}}))}},{'objectType':'progress','pack':'progress','run':a=>assessProgressRisks(a),'empty':{},'trigger':{'machine_published':![],'current_machine':'0xmac'}},{'objectType':'order','pack':'order','run':a=>assessOrderRisks(a),'empty':{},'trigger':{'is_buy_operation':!![],'items':Array['from']({'length':0x33},()=>({}))}},{'objectType':'permission','pack':'permission','run':a=>assessPermissionRisks(a),'empty':{},'trigger':{'table':{'entity':'0xe1','index':Array['from']({'length':0x3e9},(a,b)=>b)}}},{'objectType':'guard','pack':'guard','run':a=>runGuardRulePack(a),'empty':{'table':[],'root':undefined},'trigger':{'table':[],'root':{'type':'identifier','value':0x0},'scene':{'id':'service_order_allocators_guard','host_object':'Service','binding_field':'order_allocators'}}},{'objectType':'contact','pack':'contact','run':a=>checkContactRisks(a),'empty':{},'trigger':{'im_count':0xc8}},{'objectType':'resource','pack':'resource','run':a=>checkResourceRisks(a),'empty':{},'trigger':{'tags_count':HUGE}},{'objectType':'payment','pack':'payment','run':a=>checkPaymentRisks(a),'empty':{},'trigger':{'recipient_count':HUGE}},{'objectType':'arb','pack':'arb','run':a=>checkArbRisks(a),'empty':{},'trigger':{'votor_count':HUGE}},{'objectType':'personal','pack':'personal','run':a=>checkPersonalRisks(a),'empty':{},'trigger':{'information_entries':[{'name':'phone','value':'+8613800000000'}],'information_count':HUGE}},{'objectType':'util','pack':'util','run':a=>checkUtilRisks(a),'empty':{},'trigger':{'uses_typo_function_name':!![],'assumes_stable_address_bytes':!![],'large_util_import':!![],'expects_util_events':!![],'bcs_manually_synced':!![]}},{'objectType':'registrar','pack':'registrar','run':a=>checkRegistrarRisks(a),'empty':{},'trigger':{'address_count':HUGE,'expects_singleton_migration':!![],'uses_reserved_vote_bits':!![],'expects_fresh_resource_on_register':!![],'expects_affiliation_event':!![],'relies_on_typed_value_convention':!![],'is_resource_transfer':!![],'expects_vote_time_only_on_like':!![]}},{'objectType':'bridge','pack':'bridge','run':a=>checkBridgeRisks(a),'empty':{},'trigger':{'idempotency_key_length':HUGE}},{'objectType':'proof','pack':'proof','run':a=>checkProofRisks(a),'empty':{},'trigger':{'proof':str(0x2801)}},{'objectType':'repository','pack':'repository','run':a=>checkRepositoryRisks(a),'empty':{},'trigger':{'data_size':HUGE}},{'objectType':'demand','pack':'demand','run':a=>checkDemandRisks(a),'empty':{},'trigger':{'reward_count':HUGE,'guard_count':HUGE,'feedback_count':HUGE}}];
@@ -33,4 +33,3 @@ export declare const BRIDGE_RISK_RULES: {
33
33
  }[];
34
34
  export declare const BRIDGE_RISK_VERSION = "1.0.0";
35
35
  export declare function checkBridgeRisks(ctx: BridgeRiskCheckContext): BridgeRisk[];
36
- export declare function getBridgeRiskById(id: string): BridgeRisk | undefined;
@@ -1 +1 @@
1
- import{BRIDGE_MESSAGE_VERSION,BRIDGE_EVM_ADDRESS_LENGTH,BRIDGE_CURRENT_VERSION}from'@wowok/wowok';const SUPPORTED_TOKENS=['ETH','WETH','WBTC','USDC','USDT'],MAX_IDEMPOTENCY_KEY_LENGTH=0x80,BRIDGE_ERROR_CODE_COUNT=0x14,R_B_01={'rule':{'id':'R-BRIDGE-01','level':'CRITICAL','category':'permission','title':'Cross-chain\x20asset\x20security\x20—\x20committee\x20signature\x20verification\x20is\x20the\x20single\x20trust\x20root','description':'Bridge\x20committee\x20signatures\x20are\x20the\x20only\x20thing\x20preventing\x20forged\x20cross-chain\x20messages\x20'+'from\x20minting\x20tokens\x20out\x20of\x20thin\x20air\x20(bridge.move:60).\x20If\x20a\x20committee\x20key\x20is\x20'+'compromised,\x20or\x20if\x20the\x20verification\x20logic\x20has\x20a\x20bug,\x20an\x20attacker\x20can\x20claim\x20arbitrary\x20'+'amounts\x20of\x20ETH/WETH/WBTC/USDC/USDT.\x20The\x20TransferLimiter\x20caps\x20single-transfer\x20amounts\x20'+'but\x20does\x20not\x20prevent\x20repeated\x20small\x20attacks.','affected_stakeholders':['user','committee','system'],'scenario':'Committee\x20private\x20key\x20leaks;\x20attacker\x20forges\x20an\x20approved\x20transfer\x20and\x20claims\x20funds','mitigation':'Committee\x20members\x20MUST\x20use\x20HSM-backed\x20multi-sig.\x20Rotate\x20keys\x20on\x20a\x20schedule.\x20Audit\x20'+'committee\x20membership\x20and\x20signature\x20verification\x20logic\x20on\x20every\x20release.\x20Monitor\x20'+'limiter\x20utilization\x20for\x20suspicious\x20patterns.\x20Have\x20an\x20EmergencyOp\x20pause\x20plan\x20ready.','auto_fixable':![]},'check':a=>{if(!a['assumes_committee_infallible'])return null;return{...R_B_01['rule'],'evidence':'assumes_committee_infallible=true\x20(trust\x20root\x20is\x20single-point)'};}},R_B_02={'rule':{'id':'R-BRIDGE-02','level':'HIGH','category':'cross_object','title':'Bridge\x20is\x20mainnet-only\x20—\x20testnet\x20operations\x20will\x20fail','description':'The\x20Bridge\x20is\x20only\x20configured\x20on\x20mainnet.\x20testnet\x20nodes\x20do\x20not\x20have\x20the\x20bridge\x20'+'role\x20configured,\x20so\x20any\x20cross-chain\x20operation\x20(cross_chain_wow_to_evm,\x20'+'cross_chain_evm_to_wow,\x20claim_wow_to_evm,\x20etc.)\x20will\x20abort.\x20Developers\x20who\x20test\x20on\x20'+'testnet\x20will\x20see\x20EBridgeUnavailable\x20(8)\x20and\x20may\x20misdiagnose\x20it\x20as\x20a\x20code\x20bug.','affected_stakeholders':['user','operator'],'scenario':'Developer\x20runs\x20cross_chain_wow_to_evm\x20on\x20testnet;\x20aborts\x20with\x20EBridgeUnavailable','mitigation':'MCP\x20layer\x20MUST\x20validate\x20mainnet\x20environment\x20before\x20submitting\x20Bridge\x20ops.\x20Document\x20'+'the\x20mainnet-only\x20restriction\x20prominently.\x20For\x20testing,\x20use\x20mainnet\x20small-amount\x20'+'transactions\x20or\x20fork\x20tests.','related_move_error':'EBridgeUnavailable\x20(8)','auto_fixable':![]},'check':a=>{if(!a['is_non_mainnet'])return null;return{...R_B_02['rule'],'evidence':'is_non_mainnet=true\x20(Bridge\x20unavailable)'};}},R_B_03={'rule':{'id':'R-BRIDGE-03','level':'HIGH','category':'structural','title':'TransferLimiter\x20caps\x20single\x20and\x20cumulative\x20transfer\x20amounts\x20—\x20large\x20transfers\x20reject','description':'The\x20TransferLimiter\x20(bridge.move:64)\x20enforces\x20both\x20per-transfer\x20and\x20cumulative\x20'+'transfer\x20caps\x20per\x20token\x20type.\x20A\x20transfer\x20that\x20exceeds\x20the\x20cap\x20aborts\x20with\x20'+'ETokenAlreadyClaimedOrHitLimit\x20(15)\x20or\x20similar.\x20Users\x20attempting\x20large\x20cross-chain\x20'+'moves\x20will\x20see\x20their\x20transactions\x20rejected\x20and\x20may\x20misdiagnose\x20it\x20as\x20a\x20bug.','affected_stakeholders':['user'],'scenario':'User\x20attempts\x20to\x20bridge\x201000\x20ETH;\x20limiter\x20rejects\x20the\x20transfer','mitigation':'Document\x20the\x20limiter\x20semantics.\x20Before\x20submitting,\x20query\x20the\x20current\x20limiter\x20'+'utilization.\x20For\x20large\x20amounts,\x20split\x20into\x20batches\x20across\x20multiple\x20transactions\x20'+'and/or\x20time\x20windows.\x20Surface\x20the\x20remaining\x20cap\x20in\x20the\x20UI.','related_move_error':'ETokenAlreadyClaimedOrHitLimit\x20(15)','auto_fixable':![]},'check':a=>null},R_B_04={'rule':{'id':'R-BRIDGE-04','level':'MEDIUM','category':'permission','title':'activeEvmAccount\x20is\x20a\x20single\x20global\x20EVM\x20account\x20—\x20key\x20leak\x20affects\x20all\x20assets','description':'Bridge\x20uses\x20a\x20single\x20global\x20activeEvmAccount\x20that\x20is\x20auto-generated\x20and\x20transparent\x20'+'to\x20users.\x20All\x20cross-chain\x20EVM-side\x20operations\x20flow\x20through\x20this\x20one\x20account.\x20If\x20its\x20'+'private\x20key\x20leaks,\x20every\x20supported\x20token\x20(ETH/WETH/WBTC/USDC/USDT)\x20on\x20every\x20'+'supported\x20chain\x20is\x20at\x20risk.\x20There\x20is\x20no\x20per-user\x20EVM\x20account\x20isolation.','affected_stakeholders':['user','system'],'scenario':'activeEvmAccount\x20private\x20key\x20leaks;\x20attacker\x20drains\x20all\x20bridged\x20EVM\x20assets','mitigation':'Store\x20the\x20activeEvmAccount\x20key\x20in\x20an\x20HSM.\x20Rotate\x20the\x20key\x20on\x20a\x20schedule\x20and\x20via\x20'+'Versioned\x20upgrade.\x20Monitor\x20EVM-side\x20balances\x20for\x20anomalous\x20outflows.\x20Have\x20an\x20'+'EmergencyOp\x20pause\x20plan\x20ready.','auto_fixable':![]},'check':a=>{if(!a['assumes_per_user_evm_account'])return null;return{...R_B_04['rule'],'evidence':'assumes_per_user_evm_account=true\x20(it\x20is\x20global)'};}},R_B_05={'rule':{'id':'R-BRIDGE-05','level':'MEDIUM','category':'cross_object','title':'Public\x20EVM\x20RPCs\x20may\x20rate-limit\x20(HTTP\x20429)\x20—\x20cross-chain\x20ops\x20stall','description':'Bridge\x20ops\x20that\x20query\x20EVM\x20state\x20(query_active_evm_account,\x20query_supported_evm_chains,\x20'+'query_transfer_status,\x20etc.)\x20depend\x20on\x20an\x20EVM\x20RPC.\x20Public\x20RPCs\x20(e.g.\x20Infura\x20free\x20tier,\x20'+'Alchemy\x20free\x20tier)\x20frequently\x20return\x20HTTP\x20429\x20under\x20load.\x20A\x20429\x20mid-flow\x20stalls\x20the\x20'+'cross-chain\x20operation\x20and\x20may\x20confuse\x20the\x20user.\x20manage_evm_rpc\x20supports\x20multi-RPC\x20'+'rotation,\x20but\x20it\x20must\x20be\x20configured\x20in\x20advance.','affected_stakeholders':['user','operator'],'scenario':'User\x20queries\x20transfer\x20status;\x20public\x20RPC\x20returns\x20429;\x20UI\x20shows\x20generic\x20error','mitigation':'Configure\x20multiple\x20EVM\x20RPCs\x20via\x20manage_evm_rpc\x20and\x20enable\x20failover.\x20Use\x20a\x20paid\x20RPC\x20'+'tier\x20for\x20production.\x20Surface\x20429\x20as\x20\x27RPC\x20busy,\x20retry\x27\x20rather\x20than\x20\x27operation\x20failed\x27.','auto_fixable':![]},'check':a=>{if(!a['uses_public_evm_rpc'])return null;return{...R_B_05['rule'],'evidence':'uses_public_evm_rpc=true\x20(429\x20risk)'};}},R_B_06={'rule':{'id':'R-BRIDGE-06','level':'MEDIUM','category':'lifecycle','title':'EmergencyOp\x20can\x20pause\x20the\x20Bridge\x20—\x20assets\x20lock\x20during\x20pause','description':'EmergencyOp\x20(bridge.move:89-91)\x20can\x20pause\x20the\x20entire\x20Bridge.\x20While\x20paused,\x20no\x20'+'cross-chain\x20operations\x20proceed\x20—\x20assets\x20in\x20flight\x20cannot\x20be\x20claimed,\x20new\x20transfers\x20'+'cannot\x20be\x20initiated.\x20The\x20pause\x20is\x20intended\x20for\x20incident\x20response,\x20but\x20a\x20prolonged\x20'+'pause\x20locks\x20user\x20funds\x20for\x20the\x20duration.','affected_stakeholders':['user','operator'],'scenario':'Bridge\x20is\x20paused\x20for\x20incident\x20response;\x20users\x20cannot\x20claim\x20in-flight\x20transfers','mitigation':'Document\x20the\x20pause\x20scenario\x20and\x20the\x20emergency\x20plan.\x20Provide\x20a\x20status\x20page\x20showing\x20'+'pause\x20state.\x20Set\x20expectations\x20on\x20pause\x20duration\x20and\x20recovery.\x20Operators\x20should\x20'+'practice\x20un-pause\x20drills.','auto_fixable':![]},'check':a=>{if(!a['is_paused'])return null;return{...R_B_06['rule'],'evidence':'is_paused=true\x20(assets\x20locked)'};}},R_B_07={'rule':{'id':'R-BRIDGE-07','level':'LOW','category':'structural','title':'Only\x20'+SUPPORTED_TOKENS['length']+'\x20tokens\x20supported\x20—\x20unsupported\x20tokens\x20cannot\x20bridge','description':'Bridge\x20supports\x20exactly\x20'+SUPPORTED_TOKENS['length']+'\x20tokens:\x20'+SUPPORTED_TOKENS['join'](',\x20')+'.\x20'+'Any\x20other\x20token\x20(e.g.\x20DAI,\x20LINK,\x20custom\x20tokens)\x20cannot\x20be\x20bridged.\x20Users\x20holding\x20'+'unsupported\x20tokens\x20will\x20see\x20their\x20transfer\x20rejected\x20with\x20EUnexpectedTokenType\x20(3).','affected_stakeholders':['user'],'scenario':'User\x20attempts\x20to\x20bridge\x20DAI;\x20aborts\x20with\x20EUnexpectedTokenType','mitigation':'Document\x20the\x20supported\x20token\x20list\x20prominently.\x20UI\x20should\x20filter\x20the\x20token\x20picker\x20to\x20'+'supported\x20tokens\x20only.\x20For\x20unsupported\x20tokens,\x20recommend\x20an\x20alternative\x20bridge.','related_move_error':'EUnexpectedTokenType\x20(3)','auto_fixable':![]},'check':a=>{if(!a['unsupported_token'])return null;return{...R_B_07['rule'],'evidence':'unsupported_token='+a['unsupported_token']+'\x20(supported:\x20'+SUPPORTED_TOKENS['join'](',')+')'};}},R_B_08={'rule':{'id':'R-BRIDGE-08','level':'MEDIUM','category':'structural','title':'Idempotency\x20key\x20max\x20'+MAX_IDEMPOTENCY_KEY_LENGTH+'\x20chars\x20—\x20long\x20keys\x20truncate\x20or\x20reject','description':'BridgeIdempotencyKeySchema\x20accepts\x20strings\x20of\x20length\x201-'+MAX_IDEMPOTENCY_KEY_LENGTH+'.\x20'+'Callers\x20who\x20generate\x20idempotency\x20keys\x20from\x20long\x20sources\x20(e.g.\x20full\x20JSON\x20payloads,\x20'+'UUIDs\x20with\x20prefixes)\x20may\x20exceed\x20the\x20limit\x20and\x20see\x20the\x20operation\x20rejected.\x20The\x20limit\x20'+'exists\x20to\x20keep\x20on-chain\x20storage\x20bounded.','affected_stakeholders':['user'],'scenario':'Caller\x20uses\x20a\x20200-char\x20idempotency\x20key;\x20operation\x20rejected','mitigation':'Generate\x20idempotency\x20keys\x20from\x20a\x20hash\x20(e.g.\x20keccak256\x20of\x20the\x20payload,\x20hex-encoded\x20=\x20'+'66\x20chars)\x20or\x20a\x20UUID\x20(36\x20chars).\x20Validate\x20length\x20client-side\x20before\x20submission.','auto_fixable':!![]},'check':a=>{if(a['idempotency_key_length']===undefined)return null;if(a['idempotency_key_length']<=MAX_IDEMPOTENCY_KEY_LENGTH)return null;return{...R_B_08['rule'],'evidence':'idempotency_key_length='+a['idempotency_key_length']+',\x20limit='+MAX_IDEMPOTENCY_KEY_LENGTH};}},R_B_09={'rule':{'id':'R-BRIDGE-09','level':'LOW','category':'structural','title':BRIDGE_ERROR_CODE_COUNT+'\x20error\x20codes\x20—\x20debugging\x20requires\x20a\x20lookup\x20table','description':'Bridge\x20defines\x20'+BRIDGE_ERROR_CODE_COUNT+'\x20error\x20codes\x20(EUnexpectedMessageType=0\x20'+'through\x20ETokenValueIsZero=19).\x20Debugging\x20an\x20abort\x20requires\x20mapping\x20the\x20numeric\x20code\x20'+'back\x20to\x20its\x20name\x20and\x20meaning.\x20New\x20contributors\x20often\x20misread\x20codes\x20because\x20they\x20'+'are\x20not\x20enumerated\x20in\x20the\x20abort\x20message.','affected_stakeholders':['user','operator'],'scenario':'Bridge\x20aborts\x20with\x20code\x2015;\x20developer\x20does\x20not\x20know\x20what\x20ETokenAlreadyClaimedOrHitLimit\x20means','mitigation':'Publish\x20an\x20error-code\x20lookup\x20table\x20in\x20the\x20docs.\x20SDK\x20should\x20decode\x20abort\x20codes\x20into\x20'+'human-readable\x20strings.\x20MCP\x20layer\x20should\x20surface\x20the\x20decoded\x20name\x20in\x20error\x20messages.','auto_fixable':![]},'check':a=>{if(!a['expects_simple_error_codes'])return null;return{...R_B_09['rule'],'evidence':'expects_simple_error_codes=true\x20(there\x20are\x20'+BRIDGE_ERROR_CODE_COUNT+')'};}},R_B_10={'rule':{'id':'R-BRIDGE-10','level':'MEDIUM','category':'lifecycle','title':'Versioned\x20upgrade\x20(current='+BRIDGE_CURRENT_VERSION+')\x20can\x20brick\x20the\x20Bridge\x20if\x20botched','description':'Bridge\x20uses\x20Versioned\x20to\x20wrap\x20BridgeInner\x20(bridge.move:49),\x20supporting\x20schema\x20upgrades.\x20'+('The\x20current\x20version\x20is\x20BRIDGE_CURRENT_VERSION='+BRIDGE_CURRENT_VERSION+'.\x20An\x20upgrade\x20')+'that\x20mishandles\x20the\x20inner\x20version\x20migration\x20can\x20permanently\x20brick\x20the\x20Bridge\x20—\x20'+'funds\x20in\x20flight\x20would\x20be\x20locked,\x20and\x20recovery\x20requires\x20a\x20new\x20package\x20version.\x20The\x20'+('message_version\x20(current='+BRIDGE_MESSAGE_VERSION+')\x20and\x20EVM\x20address\x20length\x20')+('('+BRIDGE_EVM_ADDRESS_LENGTH+'\x20bytes)\x20are\x20also\x20versioned.'),'affected_stakeholders':['user','operator','system'],'scenario':'Upgrade\x20mishandles\x20BridgeInner\x20migration;\x20Bridge\x20becomes\x20unusable','mitigation':'Test\x20upgrades\x20on\x20a\x20fork\x20with\x20full\x20state\x20replay.\x20Keep\x20a\x20rollback\x20package\x20version\x20'+'ready.\x20Stage\x20upgrades\x20with\x20a\x20pause\x20window\x20so\x20users\x20can\x20complete\x20in-flight\x20ops.\x20'+'Audit\x20message_version\x20and\x20EVM\x20address\x20length\x20compatibility\x20on\x20every\x20upgrade.','related_move_error':'EWrongInnerVersion\x20(7)','auto_fixable':![]},'check':a=>{if(!a['versioned_upgrade_in_progress'])return null;return{...R_B_10['rule'],'evidence':'versioned_upgrade_in_progress=true\x20(current='+BRIDGE_CURRENT_VERSION+')'};}};export const BRIDGE_RISK_RULES=[R_B_01,R_B_02,R_B_03,R_B_04,R_B_05,R_B_06,R_B_07,R_B_08,R_B_09,R_B_10];export const BRIDGE_RISK_VERSION='1.0.0';export function checkBridgeRisks(a){const b=[];for(const c of BRIDGE_RISK_RULES){const d=c['check'](a);if(d)b['push'](d);}return!b['find'](e=>e['id']==='R-BRIDGE-03')&&b['push'](R_B_03['rule']),b;}export function getBridgeRiskById(a){return BRIDGE_RISK_RULES['find'](b=>b['rule']['id']===a)?.['rule'];}
1
+ import{BRIDGE_MESSAGE_VERSION,BRIDGE_EVM_ADDRESS_LENGTH,BRIDGE_CURRENT_VERSION}from'@wowok/wowok';const SUPPORTED_TOKENS=['ETH','WETH','WBTC','USDC','USDT'],MAX_IDEMPOTENCY_KEY_LENGTH=0x80,BRIDGE_ERROR_CODE_COUNT=0x14,R_B_01={'rule':{'id':'R-BRIDGE-01','level':'CRITICAL','category':'permission','title':'Cross-chain\x20asset\x20security\x20—\x20committee\x20signature\x20verification\x20is\x20the\x20single\x20trust\x20root','description':'Bridge\x20committee\x20signatures\x20are\x20the\x20only\x20thing\x20preventing\x20forged\x20cross-chain\x20messages\x20'+'from\x20minting\x20tokens\x20out\x20of\x20thin\x20air\x20(bridge.move:60).\x20If\x20a\x20committee\x20key\x20is\x20'+'compromised,\x20or\x20if\x20the\x20verification\x20logic\x20has\x20a\x20bug,\x20an\x20attacker\x20can\x20claim\x20arbitrary\x20'+'amounts\x20of\x20ETH/WETH/WBTC/USDC/USDT.\x20The\x20TransferLimiter\x20caps\x20single-transfer\x20amounts\x20'+'but\x20does\x20not\x20prevent\x20repeated\x20small\x20attacks.','affected_stakeholders':['user','committee','system'],'scenario':'Committee\x20private\x20key\x20leaks;\x20attacker\x20forges\x20an\x20approved\x20transfer\x20and\x20claims\x20funds','mitigation':'Committee\x20members\x20MUST\x20use\x20HSM-backed\x20multi-sig.\x20Rotate\x20keys\x20on\x20a\x20schedule.\x20Audit\x20'+'committee\x20membership\x20and\x20signature\x20verification\x20logic\x20on\x20every\x20release.\x20Monitor\x20'+'limiter\x20utilization\x20for\x20suspicious\x20patterns.\x20Have\x20an\x20EmergencyOp\x20pause\x20plan\x20ready.','auto_fixable':![]},'check':a=>{if(!a['assumes_committee_infallible'])return null;return{...R_B_01['rule'],'evidence':'assumes_committee_infallible=true\x20(trust\x20root\x20is\x20single-point)'};}},R_B_02={'rule':{'id':'R-BRIDGE-02','level':'HIGH','category':'cross_object','title':'Bridge\x20is\x20mainnet-only\x20—\x20testnet\x20operations\x20will\x20fail','description':'The\x20Bridge\x20is\x20only\x20configured\x20on\x20mainnet.\x20testnet\x20nodes\x20do\x20not\x20have\x20the\x20bridge\x20'+'role\x20configured,\x20so\x20any\x20cross-chain\x20operation\x20(cross_chain_wow_to_evm,\x20'+'cross_chain_evm_to_wow,\x20claim_wow_to_evm,\x20etc.)\x20will\x20abort.\x20Developers\x20who\x20test\x20on\x20'+'testnet\x20will\x20see\x20EBridgeUnavailable\x20(8)\x20and\x20may\x20misdiagnose\x20it\x20as\x20a\x20code\x20bug.','affected_stakeholders':['user','operator'],'scenario':'Developer\x20runs\x20cross_chain_wow_to_evm\x20on\x20testnet;\x20aborts\x20with\x20EBridgeUnavailable','mitigation':'MCP\x20layer\x20MUST\x20validate\x20mainnet\x20environment\x20before\x20submitting\x20Bridge\x20ops.\x20Document\x20'+'the\x20mainnet-only\x20restriction\x20prominently.\x20For\x20testing,\x20use\x20mainnet\x20small-amount\x20'+'transactions\x20or\x20fork\x20tests.','related_move_error':'EBridgeUnavailable\x20(8)','auto_fixable':![]},'check':a=>{if(!a['is_non_mainnet'])return null;return{...R_B_02['rule'],'evidence':'is_non_mainnet=true\x20(Bridge\x20unavailable)'};}},R_B_03={'rule':{'id':'R-BRIDGE-03','level':'HIGH','category':'structural','title':'TransferLimiter\x20caps\x20single\x20and\x20cumulative\x20transfer\x20amounts\x20—\x20large\x20transfers\x20reject','description':'The\x20TransferLimiter\x20(bridge.move:64)\x20enforces\x20both\x20per-transfer\x20and\x20cumulative\x20'+'transfer\x20caps\x20per\x20token\x20type.\x20A\x20transfer\x20that\x20exceeds\x20the\x20cap\x20aborts\x20with\x20'+'ETokenAlreadyClaimedOrHitLimit\x20(15)\x20or\x20similar.\x20Users\x20attempting\x20large\x20cross-chain\x20'+'moves\x20will\x20see\x20their\x20transactions\x20rejected\x20and\x20may\x20misdiagnose\x20it\x20as\x20a\x20bug.','affected_stakeholders':['user'],'scenario':'User\x20attempts\x20to\x20bridge\x201000\x20ETH;\x20limiter\x20rejects\x20the\x20transfer','mitigation':'Document\x20the\x20limiter\x20semantics.\x20Before\x20submitting,\x20query\x20the\x20current\x20limiter\x20'+'utilization.\x20For\x20large\x20amounts,\x20split\x20into\x20batches\x20across\x20multiple\x20transactions\x20'+'and/or\x20time\x20windows.\x20Surface\x20the\x20remaining\x20cap\x20in\x20the\x20UI.','related_move_error':'ETokenAlreadyClaimedOrHitLimit\x20(15)','auto_fixable':![]},'check':a=>null},R_B_04={'rule':{'id':'R-BRIDGE-04','level':'MEDIUM','category':'permission','title':'activeEvmAccount\x20is\x20a\x20single\x20global\x20EVM\x20account\x20—\x20key\x20leak\x20affects\x20all\x20assets','description':'Bridge\x20uses\x20a\x20single\x20global\x20activeEvmAccount\x20that\x20is\x20auto-generated\x20and\x20transparent\x20'+'to\x20users.\x20All\x20cross-chain\x20EVM-side\x20operations\x20flow\x20through\x20this\x20one\x20account.\x20If\x20its\x20'+'private\x20key\x20leaks,\x20every\x20supported\x20token\x20(ETH/WETH/WBTC/USDC/USDT)\x20on\x20every\x20'+'supported\x20chain\x20is\x20at\x20risk.\x20There\x20is\x20no\x20per-user\x20EVM\x20account\x20isolation.','affected_stakeholders':['user','system'],'scenario':'activeEvmAccount\x20private\x20key\x20leaks;\x20attacker\x20drains\x20all\x20bridged\x20EVM\x20assets','mitigation':'Store\x20the\x20activeEvmAccount\x20key\x20in\x20an\x20HSM.\x20Rotate\x20the\x20key\x20on\x20a\x20schedule\x20and\x20via\x20'+'Versioned\x20upgrade.\x20Monitor\x20EVM-side\x20balances\x20for\x20anomalous\x20outflows.\x20Have\x20an\x20'+'EmergencyOp\x20pause\x20plan\x20ready.','auto_fixable':![]},'check':a=>{if(!a['assumes_per_user_evm_account'])return null;return{...R_B_04['rule'],'evidence':'assumes_per_user_evm_account=true\x20(it\x20is\x20global)'};}},R_B_05={'rule':{'id':'R-BRIDGE-05','level':'MEDIUM','category':'cross_object','title':'Public\x20EVM\x20RPCs\x20may\x20rate-limit\x20(HTTP\x20429)\x20—\x20cross-chain\x20ops\x20stall','description':'Bridge\x20ops\x20that\x20query\x20EVM\x20state\x20(query_active_evm_account,\x20query_supported_evm_chains,\x20'+'query_transfer_status,\x20etc.)\x20depend\x20on\x20an\x20EVM\x20RPC.\x20Public\x20RPCs\x20(e.g.\x20Infura\x20free\x20tier,\x20'+'Alchemy\x20free\x20tier)\x20frequently\x20return\x20HTTP\x20429\x20under\x20load.\x20A\x20429\x20mid-flow\x20stalls\x20the\x20'+'cross-chain\x20operation\x20and\x20may\x20confuse\x20the\x20user.\x20manage_evm_rpc\x20supports\x20multi-RPC\x20'+'rotation,\x20but\x20it\x20must\x20be\x20configured\x20in\x20advance.','affected_stakeholders':['user','operator'],'scenario':'User\x20queries\x20transfer\x20status;\x20public\x20RPC\x20returns\x20429;\x20UI\x20shows\x20generic\x20error','mitigation':'Configure\x20multiple\x20EVM\x20RPCs\x20via\x20manage_evm_rpc\x20and\x20enable\x20failover.\x20Use\x20a\x20paid\x20RPC\x20'+'tier\x20for\x20production.\x20Surface\x20429\x20as\x20\x27RPC\x20busy,\x20retry\x27\x20rather\x20than\x20\x27operation\x20failed\x27.','auto_fixable':![]},'check':a=>{if(!a['uses_public_evm_rpc'])return null;return{...R_B_05['rule'],'evidence':'uses_public_evm_rpc=true\x20(429\x20risk)'};}},R_B_06={'rule':{'id':'R-BRIDGE-06','level':'MEDIUM','category':'lifecycle','title':'EmergencyOp\x20can\x20pause\x20the\x20Bridge\x20—\x20assets\x20lock\x20during\x20pause','description':'EmergencyOp\x20(bridge.move:89-91)\x20can\x20pause\x20the\x20entire\x20Bridge.\x20While\x20paused,\x20no\x20'+'cross-chain\x20operations\x20proceed\x20—\x20assets\x20in\x20flight\x20cannot\x20be\x20claimed,\x20new\x20transfers\x20'+'cannot\x20be\x20initiated.\x20The\x20pause\x20is\x20intended\x20for\x20incident\x20response,\x20but\x20a\x20prolonged\x20'+'pause\x20locks\x20user\x20funds\x20for\x20the\x20duration.','affected_stakeholders':['user','operator'],'scenario':'Bridge\x20is\x20paused\x20for\x20incident\x20response;\x20users\x20cannot\x20claim\x20in-flight\x20transfers','mitigation':'Document\x20the\x20pause\x20scenario\x20and\x20the\x20emergency\x20plan.\x20Provide\x20a\x20status\x20page\x20showing\x20'+'pause\x20state.\x20Set\x20expectations\x20on\x20pause\x20duration\x20and\x20recovery.\x20Operators\x20should\x20'+'practice\x20un-pause\x20drills.','auto_fixable':![]},'check':a=>{if(!a['is_paused'])return null;return{...R_B_06['rule'],'evidence':'is_paused=true\x20(assets\x20locked)'};}},R_B_07={'rule':{'id':'R-BRIDGE-07','level':'LOW','category':'structural','title':'Only\x20'+SUPPORTED_TOKENS['length']+'\x20tokens\x20supported\x20—\x20unsupported\x20tokens\x20cannot\x20bridge','description':'Bridge\x20supports\x20exactly\x20'+SUPPORTED_TOKENS['length']+'\x20tokens:\x20'+SUPPORTED_TOKENS['join'](',\x20')+'.\x20'+'Any\x20other\x20token\x20(e.g.\x20DAI,\x20LINK,\x20custom\x20tokens)\x20cannot\x20be\x20bridged.\x20Users\x20holding\x20'+'unsupported\x20tokens\x20will\x20see\x20their\x20transfer\x20rejected\x20with\x20EUnexpectedTokenType\x20(3).','affected_stakeholders':['user'],'scenario':'User\x20attempts\x20to\x20bridge\x20DAI;\x20aborts\x20with\x20EUnexpectedTokenType','mitigation':'Document\x20the\x20supported\x20token\x20list\x20prominently.\x20UI\x20should\x20filter\x20the\x20token\x20picker\x20to\x20'+'supported\x20tokens\x20only.\x20For\x20unsupported\x20tokens,\x20recommend\x20an\x20alternative\x20bridge.','related_move_error':'EUnexpectedTokenType\x20(3)','auto_fixable':![]},'check':a=>{if(!a['unsupported_token'])return null;return{...R_B_07['rule'],'evidence':'unsupported_token='+a['unsupported_token']+'\x20(supported:\x20'+SUPPORTED_TOKENS['join'](',')+')'};}},R_B_08={'rule':{'id':'R-BRIDGE-08','level':'MEDIUM','category':'structural','title':'Idempotency\x20key\x20max\x20'+MAX_IDEMPOTENCY_KEY_LENGTH+'\x20chars\x20—\x20long\x20keys\x20truncate\x20or\x20reject','description':'BridgeIdempotencyKeySchema\x20accepts\x20strings\x20of\x20length\x201-'+MAX_IDEMPOTENCY_KEY_LENGTH+'.\x20'+'Callers\x20who\x20generate\x20idempotency\x20keys\x20from\x20long\x20sources\x20(e.g.\x20full\x20JSON\x20payloads,\x20'+'UUIDs\x20with\x20prefixes)\x20may\x20exceed\x20the\x20limit\x20and\x20see\x20the\x20operation\x20rejected.\x20The\x20limit\x20'+'exists\x20to\x20keep\x20on-chain\x20storage\x20bounded.','affected_stakeholders':['user'],'scenario':'Caller\x20uses\x20a\x20200-char\x20idempotency\x20key;\x20operation\x20rejected','mitigation':'Generate\x20idempotency\x20keys\x20from\x20a\x20hash\x20(e.g.\x20keccak256\x20of\x20the\x20payload,\x20hex-encoded\x20=\x20'+'66\x20chars)\x20or\x20a\x20UUID\x20(36\x20chars).\x20Validate\x20length\x20client-side\x20before\x20submission.','auto_fixable':!![]},'check':a=>{if(a['idempotency_key_length']===undefined)return null;if(a['idempotency_key_length']<=MAX_IDEMPOTENCY_KEY_LENGTH)return null;return{...R_B_08['rule'],'evidence':'idempotency_key_length='+a['idempotency_key_length']+',\x20limit='+MAX_IDEMPOTENCY_KEY_LENGTH};}},R_B_09={'rule':{'id':'R-BRIDGE-09','level':'LOW','category':'structural','title':BRIDGE_ERROR_CODE_COUNT+'\x20error\x20codes\x20—\x20debugging\x20requires\x20a\x20lookup\x20table','description':'Bridge\x20defines\x20'+BRIDGE_ERROR_CODE_COUNT+'\x20error\x20codes\x20(EUnexpectedMessageType=0\x20'+'through\x20ETokenValueIsZero=19).\x20Debugging\x20an\x20abort\x20requires\x20mapping\x20the\x20numeric\x20code\x20'+'back\x20to\x20its\x20name\x20and\x20meaning.\x20New\x20contributors\x20often\x20misread\x20codes\x20because\x20they\x20'+'are\x20not\x20enumerated\x20in\x20the\x20abort\x20message.','affected_stakeholders':['user','operator'],'scenario':'Bridge\x20aborts\x20with\x20code\x2015;\x20developer\x20does\x20not\x20know\x20what\x20ETokenAlreadyClaimedOrHitLimit\x20means','mitigation':'Publish\x20an\x20error-code\x20lookup\x20table\x20in\x20the\x20docs.\x20SDK\x20should\x20decode\x20abort\x20codes\x20into\x20'+'human-readable\x20strings.\x20MCP\x20layer\x20should\x20surface\x20the\x20decoded\x20name\x20in\x20error\x20messages.','auto_fixable':![]},'check':a=>{if(!a['expects_simple_error_codes'])return null;return{...R_B_09['rule'],'evidence':'expects_simple_error_codes=true\x20(there\x20are\x20'+BRIDGE_ERROR_CODE_COUNT+')'};}},R_B_10={'rule':{'id':'R-BRIDGE-10','level':'MEDIUM','category':'lifecycle','title':'Versioned\x20upgrade\x20(current='+BRIDGE_CURRENT_VERSION+')\x20can\x20brick\x20the\x20Bridge\x20if\x20botched','description':'Bridge\x20uses\x20Versioned\x20to\x20wrap\x20BridgeInner\x20(bridge.move:49),\x20supporting\x20schema\x20upgrades.\x20'+('The\x20current\x20version\x20is\x20BRIDGE_CURRENT_VERSION='+BRIDGE_CURRENT_VERSION+'.\x20An\x20upgrade\x20')+'that\x20mishandles\x20the\x20inner\x20version\x20migration\x20can\x20permanently\x20brick\x20the\x20Bridge\x20—\x20'+'funds\x20in\x20flight\x20would\x20be\x20locked,\x20and\x20recovery\x20requires\x20a\x20new\x20package\x20version.\x20The\x20'+('message_version\x20(current='+BRIDGE_MESSAGE_VERSION+')\x20and\x20EVM\x20address\x20length\x20')+('('+BRIDGE_EVM_ADDRESS_LENGTH+'\x20bytes)\x20are\x20also\x20versioned.'),'affected_stakeholders':['user','operator','system'],'scenario':'Upgrade\x20mishandles\x20BridgeInner\x20migration;\x20Bridge\x20becomes\x20unusable','mitigation':'Test\x20upgrades\x20on\x20a\x20fork\x20with\x20full\x20state\x20replay.\x20Keep\x20a\x20rollback\x20package\x20version\x20'+'ready.\x20Stage\x20upgrades\x20with\x20a\x20pause\x20window\x20so\x20users\x20can\x20complete\x20in-flight\x20ops.\x20'+'Audit\x20message_version\x20and\x20EVM\x20address\x20length\x20compatibility\x20on\x20every\x20upgrade.','related_move_error':'EWrongInnerVersion\x20(7)','auto_fixable':![]},'check':a=>{if(!a['versioned_upgrade_in_progress'])return null;return{...R_B_10['rule'],'evidence':'versioned_upgrade_in_progress=true\x20(current='+BRIDGE_CURRENT_VERSION+')'};}};export const BRIDGE_RISK_RULES=[R_B_01,R_B_02,R_B_03,R_B_04,R_B_05,R_B_06,R_B_07,R_B_08,R_B_09,R_B_10];export const BRIDGE_RISK_VERSION='1.0.0';export function checkBridgeRisks(a){const b=[];for(const c of BRIDGE_RISK_RULES){const d=c['check'](a);if(d)b['push'](d);}return!b['find'](e=>e['id']==='R-BRIDGE-03')&&b['push'](R_B_03['rule']),b;}