@wowok/agent-mcp 3.1.3 → 3.1.5

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 (384) hide show
  1. package/dist/config/config-audit.spec.d.ts +1 -0
  2. package/dist/config/config-audit.spec.js +1 -0
  3. package/dist/config/exposure.d.ts +108 -0
  4. package/dist/config/exposure.js +1 -0
  5. package/dist/config/index.d.ts +2 -0
  6. package/dist/config/index.js +1 -1
  7. package/dist/config/judgment.d.ts +1228 -0
  8. package/dist/config/judgment.js +1 -0
  9. package/dist/config/judgment.spec.d.ts +1 -0
  10. package/dist/config/judgment.spec.js +1 -0
  11. package/dist/config/rule-engine.d.ts +299 -0
  12. package/dist/config/rule-engine.js +1 -0
  13. package/dist/config/rule-engine.spec.d.ts +1 -0
  14. package/dist/config/rule-engine.spec.js +1 -0
  15. package/dist/config/severity.d.ts +7 -0
  16. package/dist/config/severity.js +1 -0
  17. package/dist/customer/order-monitor.d.ts +3 -1
  18. package/dist/customer/order-monitor.js +1 -1
  19. package/dist/evaluation/acceptance.d.ts +1 -0
  20. package/dist/evaluation/acceptance.js +1 -1
  21. package/dist/evaluation/arbitration-game.js +1 -1
  22. package/dist/evaluation/builtins/demand-match.js +1 -1
  23. package/dist/evaluation/builtins/graph-service.js +1 -1
  24. package/dist/evaluation/builtins/graph-service.spec.js +1 -1
  25. package/dist/evaluation/engine.js +1 -1
  26. package/dist/evaluation/game-strategy.d.ts +2 -2
  27. package/dist/evaluation/game-strategy.js +1 -1
  28. package/dist/evaluation/match-operation.d.ts +2 -2
  29. package/dist/evaluation/match-operation.js +1 -1
  30. package/dist/evaluation/standards.d.ts +3 -25
  31. package/dist/evaluation/standards.js +1 -1
  32. package/dist/evaluation/types.d.ts +2 -1
  33. package/dist/experience/realtime-feedback.js +1 -1
  34. package/dist/extensions/business-modules.js +1 -1
  35. package/dist/extensions/custom-registry-file.js +1 -1
  36. package/dist/extensions/industry-audit.spec.d.ts +1 -0
  37. package/dist/extensions/industry-audit.spec.js +1 -0
  38. package/dist/extensions/industry-layers.d.ts +8 -0
  39. package/dist/extensions/industry-layers.js +1 -1
  40. package/dist/extensions/industry-pack.d.ts +2 -0
  41. package/dist/extensions/industry-pack.js +1 -1
  42. package/dist/extensions/mode-evaluator.js +1 -1
  43. package/dist/extensions/modes.js +1 -1
  44. package/dist/graph/onchain/analyze.d.ts +3 -1
  45. package/dist/graph/onchain/analyze.js +1 -1
  46. package/dist/graph/onchain/analyze.spec.js +1 -1
  47. package/dist/graph/onchain/edge-schema.d.ts +1 -0
  48. package/dist/graph/onchain/edge-schema.js +1 -1
  49. package/dist/graph/onchain/expand.js +1 -1
  50. package/dist/graph/onchain/exploration.d.ts +28 -0
  51. package/dist/graph/onchain/exploration.js +1 -0
  52. package/dist/graph/onchain/exploration.spec.d.ts +1 -0
  53. package/dist/graph/onchain/exploration.spec.js +1 -0
  54. package/dist/graph/onchain/exposure.d.ts +18 -0
  55. package/dist/graph/onchain/exposure.js +1 -0
  56. package/dist/graph/onchain/exposure.spec.d.ts +1 -0
  57. package/dist/graph/onchain/exposure.spec.js +1 -0
  58. package/dist/graph/onchain/graph-policy.spec.d.ts +1 -0
  59. package/dist/graph/onchain/graph-policy.spec.js +1 -0
  60. package/dist/graph/onchain/index.d.ts +6 -0
  61. package/dist/graph/onchain/index.js +1 -1
  62. package/dist/graph/onchain/interest.js +1 -1
  63. package/dist/graph/onchain/interest.spec.js +1 -1
  64. package/dist/graph/onchain/names.js +1 -1
  65. package/dist/graph/onchain/names.spec.js +1 -1
  66. package/dist/graph/onchain/policy.d.ts +8 -0
  67. package/dist/graph/onchain/policy.js +1 -0
  68. package/dist/graph/onchain/proposal-graph.js +1 -1
  69. package/dist/graph/onchain/proposal-graph.spec.js +1 -1
  70. package/dist/graph/onchain/synthesis.d.ts +20 -0
  71. package/dist/graph/onchain/synthesis.js +1 -0
  72. package/dist/graph/onchain/synthesis.spec.d.ts +1 -0
  73. package/dist/graph/onchain/synthesis.spec.js +1 -0
  74. package/dist/graph/onchain/types.d.ts +11 -1
  75. package/dist/keeper/keeper.spec.js +1 -1
  76. package/dist/knowledge/alloc-audit-policy.spec.d.ts +1 -0
  77. package/dist/knowledge/alloc-audit-policy.spec.js +1 -0
  78. package/dist/knowledge/allocation-ledger.js +1 -1
  79. package/dist/knowledge/allocation-puzzle.d.ts +1 -1
  80. package/dist/knowledge/allocation-puzzle.js +1 -1
  81. package/dist/knowledge/allocation-risk.d.ts +4 -1
  82. package/dist/knowledge/allocation-risk.js +1 -1
  83. package/dist/knowledge/allocation-templates.js +1 -1
  84. package/dist/knowledge/arb-risk.d.ts +6 -5
  85. package/dist/knowledge/arb-risk.js +1 -1
  86. package/dist/knowledge/arbitration-ledger.d.ts +4 -4
  87. package/dist/knowledge/arbitration-ledger.js +1 -1
  88. package/dist/knowledge/arbitration-puzzle.d.ts +1 -1
  89. package/dist/knowledge/arbitration-puzzle.js +1 -1
  90. package/dist/knowledge/arbitration-risk.d.ts +4 -1
  91. package/dist/knowledge/arbitration-risk.js +1 -1
  92. package/dist/knowledge/arbitration-templates.js +1 -1
  93. package/dist/knowledge/baselines/judgment-baselines.json +289 -0
  94. package/dist/knowledge/baselines/risk-baselines.spec.js +1 -1
  95. package/dist/knowledge/baselines/rules/alloc_audit.json +290 -0
  96. package/dist/knowledge/baselines/rules/allocation.json +492 -0
  97. package/dist/knowledge/baselines/rules/arb.json +155 -0
  98. package/dist/knowledge/baselines/rules/arbitration.json +366 -0
  99. package/dist/knowledge/baselines/rules/bridge.json +197 -0
  100. package/dist/knowledge/baselines/rules/contact.json +152 -0
  101. package/dist/knowledge/baselines/rules/demand.json +158 -0
  102. package/dist/knowledge/baselines/rules/graph.json +453 -0
  103. package/dist/knowledge/baselines/rules/guard.json +981 -0
  104. package/dist/knowledge/baselines/rules/machine.json +706 -0
  105. package/dist/knowledge/baselines/rules/order.json +549 -0
  106. package/dist/knowledge/baselines/rules/payment.json +205 -0
  107. package/dist/knowledge/baselines/rules/permission.json +330 -0
  108. package/dist/knowledge/baselines/rules/personal.json +139 -0
  109. package/dist/knowledge/baselines/rules/progress.json +346 -0
  110. package/dist/knowledge/baselines/rules/proof.json +158 -0
  111. package/dist/knowledge/baselines/rules/registrar.json +159 -0
  112. package/dist/knowledge/baselines/rules/repository.json +244 -0
  113. package/dist/knowledge/baselines/rules/resource.json +117 -0
  114. package/dist/knowledge/baselines/rules/reward.json +471 -0
  115. package/dist/knowledge/baselines/rules/service.json +595 -0
  116. package/dist/knowledge/baselines/rules/treasury.json +440 -0
  117. package/dist/knowledge/baselines/rules/util.json +101 -0
  118. package/dist/knowledge/bridge-risk.d.ts +6 -5
  119. package/dist/knowledge/bridge-risk.js +1 -1
  120. package/dist/knowledge/builtin-templates.d.ts +26 -0
  121. package/dist/knowledge/builtin-templates.js +1 -0
  122. package/dist/knowledge/contact-risk.d.ts +6 -5
  123. package/dist/knowledge/contact-risk.js +1 -1
  124. package/dist/knowledge/demand-risk.d.ts +6 -5
  125. package/dist/knowledge/demand-risk.js +1 -1
  126. package/dist/knowledge/event-semantics.js +1 -1
  127. package/dist/knowledge/facts-sync.spec.d.ts +1 -0
  128. package/dist/knowledge/facts-sync.spec.js +1 -0
  129. package/dist/knowledge/getting-started.js +1 -1
  130. package/dist/knowledge/guard-design-patterns.js +1 -1
  131. package/dist/knowledge/guard-field-cognition.d.ts +1 -1
  132. package/dist/knowledge/guard-field-cognition.js +1 -1
  133. package/dist/knowledge/guard-ledger.js +1 -1
  134. package/dist/knowledge/guard-risk.d.ts +4 -1
  135. package/dist/knowledge/guard-risk.js +1 -1
  136. package/dist/knowledge/guard-templates.js +1 -1
  137. package/dist/knowledge/guard-translation.js +1 -1
  138. package/dist/knowledge/index.d.ts +10 -2
  139. package/dist/knowledge/index.js +1 -1
  140. package/dist/knowledge/industry-registry.js +1 -1
  141. package/dist/knowledge/industry-strategy.js +1 -1
  142. package/dist/knowledge/jsonrpc-enum.js +1 -1
  143. package/dist/knowledge/machine-ledger.js +1 -1
  144. package/dist/knowledge/machine-risk.d.ts +4 -1
  145. package/dist/knowledge/machine-risk.js +1 -1
  146. package/dist/knowledge/machine-templates.js +1 -1
  147. package/dist/knowledge/machine-translation.js +1 -1
  148. package/dist/knowledge/migration-preflight.js +1 -1
  149. package/dist/knowledge/operation-dictionary.js +1 -1
  150. package/dist/knowledge/order-ledger.js +1 -1
  151. package/dist/knowledge/order-puzzle.d.ts +3 -3
  152. package/dist/knowledge/order-puzzle.js +1 -1
  153. package/dist/knowledge/order-risk.d.ts +6 -3
  154. package/dist/knowledge/order-risk.js +1 -1
  155. package/dist/knowledge/order-templates.js +1 -1
  156. package/dist/knowledge/passport-ledger.js +1 -1
  157. package/dist/knowledge/passport-templates.js +1 -1
  158. package/dist/knowledge/payment-risk.d.ts +8 -6
  159. package/dist/knowledge/payment-risk.js +1 -1
  160. package/dist/knowledge/payment-tracker.js +1 -1
  161. package/dist/knowledge/permission-ledger.js +1 -1
  162. package/dist/knowledge/permission-puzzle.d.ts +12 -12
  163. package/dist/knowledge/permission-puzzle.js +1 -1
  164. package/dist/knowledge/permission-risk.d.ts +4 -7
  165. package/dist/knowledge/permission-risk.js +1 -1
  166. package/dist/knowledge/permission-templates.js +1 -1
  167. package/dist/knowledge/personal-risk.d.ts +6 -5
  168. package/dist/knowledge/personal-risk.js +1 -1
  169. package/dist/knowledge/progress-ledger.js +1 -1
  170. package/dist/knowledge/progress-puzzle.d.ts +2 -2
  171. package/dist/knowledge/progress-puzzle.js +1 -1
  172. package/dist/knowledge/progress-risk.d.ts +4 -1
  173. package/dist/knowledge/progress-risk.js +1 -1
  174. package/dist/knowledge/progress-templates.js +1 -1
  175. package/dist/knowledge/proof-risk.d.ts +6 -5
  176. package/dist/knowledge/proof-risk.js +1 -1
  177. package/dist/knowledge/puzzle-projections.js +1 -1
  178. package/dist/knowledge/recipient-constraint.d.ts +20 -1
  179. package/dist/knowledge/recipient-constraint.js +1 -1
  180. package/dist/knowledge/registrar-risk.d.ts +6 -5
  181. package/dist/knowledge/registrar-risk.js +1 -1
  182. package/dist/knowledge/repository-risk.d.ts +7 -6
  183. package/dist/knowledge/repository-risk.js +1 -1
  184. package/dist/knowledge/resource-risk.d.ts +6 -5
  185. package/dist/knowledge/resource-risk.js +1 -1
  186. package/dist/knowledge/reward-ledger.d.ts +1 -1
  187. package/dist/knowledge/reward-ledger.js +1 -1
  188. package/dist/knowledge/reward-puzzle.d.ts +2 -2
  189. package/dist/knowledge/reward-puzzle.js +1 -1
  190. package/dist/knowledge/reward-risk.d.ts +4 -1
  191. package/dist/knowledge/reward-risk.js +1 -1
  192. package/dist/knowledge/rule-node-analyzers.spec.js +1 -1
  193. package/dist/knowledge/rule-outcome.js +1 -1
  194. package/dist/knowledge/scenario-modes.d.ts +2 -2
  195. package/dist/knowledge/scenario-modes.js +1 -1
  196. package/dist/knowledge/scenario-topology.js +1 -1
  197. package/dist/knowledge/service-allocator-audit-node.js +1 -1
  198. package/dist/knowledge/service-ledger.js +1 -1
  199. package/dist/knowledge/service-puzzle.d.ts +2 -2
  200. package/dist/knowledge/service-puzzle.js +1 -1
  201. package/dist/knowledge/service-risk-node.js +1 -1
  202. package/dist/knowledge/service-risk.d.ts +4 -1
  203. package/dist/knowledge/service-risk.js +1 -1
  204. package/dist/knowledge/service-templates.js +1 -1
  205. package/dist/knowledge/strategy-manuals.d.ts +1 -1
  206. package/dist/knowledge/strategy-manuals.js +1 -1
  207. package/dist/knowledge/template-loader.d.ts +84 -0
  208. package/dist/knowledge/template-loader.js +1 -0
  209. package/dist/knowledge/template-loader.spec.d.ts +1 -0
  210. package/dist/knowledge/template-loader.spec.js +1 -0
  211. package/dist/knowledge/template-registry.js +1 -1
  212. package/dist/knowledge/template-scanner.d.ts +17 -0
  213. package/dist/knowledge/template-scanner.js +1 -0
  214. package/dist/knowledge/template-scanner.spec.d.ts +1 -0
  215. package/dist/knowledge/template-scanner.spec.js +1 -0
  216. package/dist/knowledge/tools-reference.js +1 -1
  217. package/dist/knowledge/treasury-ledger.d.ts +1 -1
  218. package/dist/knowledge/treasury-ledger.js +1 -1
  219. package/dist/knowledge/treasury-puzzle.d.ts +3 -3
  220. package/dist/knowledge/treasury-puzzle.js +1 -1
  221. package/dist/knowledge/treasury-risk.d.ts +4 -1
  222. package/dist/knowledge/treasury-risk.js +1 -1
  223. package/dist/knowledge/treasury-templates.js +1 -1
  224. package/dist/knowledge/util-risk.d.ts +6 -5
  225. package/dist/knowledge/util-risk.js +1 -1
  226. package/dist/knowledge/workflow-guidance.d.ts +4 -0
  227. package/dist/knowledge/workflow-guidance.js +1 -1
  228. package/dist/knowledge/workspace-lists.js +1 -1
  229. package/dist/monitor/MonitorLoop.js +1 -1
  230. package/dist/participation/arbitrator-interest.js +1 -1
  231. package/dist/participation/radar-core.js +1 -1
  232. package/dist/persona/analyzer.js +1 -1
  233. package/dist/persona/index.js +1 -1
  234. package/dist/persona/model.js +1 -1
  235. package/dist/persona/persona-audit.spec.d.ts +1 -0
  236. package/dist/persona/persona-audit.spec.js +1 -0
  237. package/dist/persona/types.d.ts +2 -0
  238. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  239. package/dist/playbooks/service-build/facet-money.d.ts +11 -0
  240. package/dist/playbooks/service-build/facet-money.js +1 -1
  241. package/dist/playbooks/service-build/machine-panorama.d.ts +17 -0
  242. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  243. package/dist/playbooks/service-build/merchant-guide.d.ts +2 -2
  244. package/dist/playbooks/service-build/migration-planner.d.ts +43 -0
  245. package/dist/playbooks/service-build/migration-planner.js +1 -0
  246. package/dist/playbooks/service-build/object-panorama.d.ts +42 -1
  247. package/dist/playbooks/service-build/object-panorama.js +1 -1
  248. package/dist/playbooks/service-build/participation-radar.js +1 -1
  249. package/dist/playbooks/service-build/pipeline-actions.d.ts +1 -1
  250. package/dist/playbooks/service-build/reverse-mapping.d.ts +1 -0
  251. package/dist/playbooks/service-build/reverse-mapping.js +1 -1
  252. package/dist/playbooks/service-build/risk-aggregator.d.ts +2 -1
  253. package/dist/playbooks/service-build/risk-aggregator.js +1 -1
  254. package/dist/playbooks/service-build/semantic-graph.js +1 -1
  255. package/dist/playbooks/service-build/service-panorama.d.ts +53 -1
  256. package/dist/playbooks/service-build/service-panorama.js +1 -1
  257. package/dist/playbooks/service-build/topology-evaluation.spec.js +1 -1
  258. package/dist/playbooks/service-build/topology-query.js +1 -1
  259. package/dist/playbooks/service-build/workflow-design-assessment.d.ts +2 -2
  260. package/dist/playbooks/service-build/workflow-design-assessment.js +1 -1
  261. package/dist/relationship/registry.js +1 -1
  262. package/dist/review/machine.js +1 -1
  263. package/dist/review/order.js +1 -1
  264. package/dist/review/service.js +1 -1
  265. package/dist/review/types.d.ts +7 -0
  266. package/dist/safety/confirm-gate.js +1 -1
  267. package/dist/schema/benchmark-migration/index.d.ts +207 -0
  268. package/dist/schema/benchmark-migration/index.js +1 -0
  269. package/dist/schema/call/allocation.d.ts +1 -1
  270. package/dist/schema/call/allocation.js +1 -1
  271. package/dist/schema/call/arbitration.d.ts +1 -1
  272. package/dist/schema/call/arbitration.js +1 -1
  273. package/dist/schema/call/base.d.ts +5 -5
  274. package/dist/schema/call/base.js +1 -1
  275. package/dist/schema/call/contact.d.ts +1 -1
  276. package/dist/schema/call/demand.d.ts +1 -1
  277. package/dist/schema/call/guard.d.ts +3 -3
  278. package/dist/schema/call/machine.d.ts +5 -5
  279. package/dist/schema/call/order.d.ts +3 -3
  280. package/dist/schema/call/payment.js +1 -1
  281. package/dist/schema/call/permission-handler.d.ts +1 -1
  282. package/dist/schema/call/permission-handler.js +1 -1
  283. package/dist/schema/call/permission.d.ts +16 -16
  284. package/dist/schema/call/permission.js +1 -1
  285. package/dist/schema/call/personal.d.ts +8 -8
  286. package/dist/schema/call/personal.js +1 -1
  287. package/dist/schema/call/progress.d.ts +3 -3
  288. package/dist/schema/call/repository.d.ts +11 -11
  289. package/dist/schema/call/repository.js +1 -1
  290. package/dist/schema/call/reward.d.ts +1 -1
  291. package/dist/schema/call/semantic.js +1 -1
  292. package/dist/schema/call/service.d.ts +7 -7
  293. package/dist/schema/call/service.js +1 -1
  294. package/dist/schema/call/treasury.d.ts +1 -1
  295. package/dist/schema/common/index.d.ts +6 -6
  296. package/dist/schema/common/index.js +1 -1
  297. package/dist/schema/config/index.d.ts +50 -1
  298. package/dist/schema/config/index.js +1 -1
  299. package/dist/schema/evaluation/index.d.ts +27 -11
  300. package/dist/schema/evaluation/index.js +1 -1
  301. package/dist/schema/goal/index.d.ts +5 -5
  302. package/dist/schema/goal/planning.d.ts +15 -15
  303. package/dist/schema/goal/planning.js +1 -1
  304. package/dist/schema/index.d.ts +1 -0
  305. package/dist/schema/index.js +1 -1
  306. package/dist/schema/interaction/index.d.ts +1 -1
  307. package/dist/schema/local/index.js +1 -1
  308. package/dist/schema/messenger/index.d.ts +26 -26
  309. package/dist/schema/operations.d.ts +33 -33
  310. package/dist/schema/operations.js +1 -1
  311. package/dist/schema/persona/index.d.ts +4708 -0
  312. package/dist/schema/persona/index.js +1 -1
  313. package/dist/schema/query/bi.d.ts +232 -25
  314. package/dist/schema/query/bi.js +1 -1
  315. package/dist/schema/query/index.d.ts +35 -35
  316. package/dist/schema/query/index.js +1 -1
  317. package/dist/schema/schema-version.js +1 -1
  318. package/dist/schema/workflow/index.d.ts +1 -1
  319. package/dist/schema/workspace/index.d.ts +53 -0
  320. package/dist/schema/workspace/index.js +1 -1
  321. package/dist/schema-query-impl/index.d.ts +9 -0
  322. package/dist/schema-query-impl/index.js +1 -1
  323. package/dist/schemas/benchmark_migration_operation.output.json +793 -0
  324. package/dist/schemas/benchmark_migration_operation.schema.json +83 -0
  325. package/dist/schemas/bridge_operation.schema.json +5 -5
  326. package/dist/schemas/config_operation.output.json +252 -0
  327. package/dist/schemas/config_operation.schema.json +21 -1
  328. package/dist/schemas/evaluation_operation.output.json +22 -10
  329. package/dist/schemas/goal_operation.schema.json +8 -8
  330. package/dist/schemas/guard2file.schema.json +1 -1
  331. package/dist/schemas/index.json +7 -1
  332. package/dist/schemas/machineNode2file.schema.json +1 -1
  333. package/dist/schemas/messenger_operation.schema.json +24 -12
  334. package/dist/schemas/onchain_events.output.json +1 -1
  335. package/dist/schemas/onchain_operations.output.json +4 -2
  336. package/dist/schemas/onchain_operations.schema.json +189 -139
  337. package/dist/schemas/onchain_operations_allocation.schema.json +13 -11
  338. package/dist/schemas/onchain_operations_arbitration.schema.json +10 -8
  339. package/dist/schemas/onchain_operations_contact.schema.json +7 -5
  340. package/dist/schemas/onchain_operations_demand.schema.json +7 -5
  341. package/dist/schemas/onchain_operations_gen_passport.schema.json +5 -3
  342. package/dist/schemas/onchain_operations_gen_proof.schema.json +1 -1
  343. package/dist/schemas/onchain_operations_guard.schema.json +5 -3
  344. package/dist/schemas/onchain_operations_machine.schema.json +22 -18
  345. package/dist/schemas/onchain_operations_order.schema.json +11 -7
  346. package/dist/schemas/onchain_operations_payment.schema.json +3 -3
  347. package/dist/schemas/onchain_operations_permission.schema.json +19 -11
  348. package/dist/schemas/onchain_operations_personal.schema.json +16 -10
  349. package/dist/schemas/onchain_operations_progress.schema.json +11 -7
  350. package/dist/schemas/onchain_operations_proof.schema.json +5 -3
  351. package/dist/schemas/onchain_operations_repository.schema.json +12 -8
  352. package/dist/schemas/onchain_operations_reward.schema.json +11 -9
  353. package/dist/schemas/onchain_operations_service.schema.json +28 -22
  354. package/dist/schemas/onchain_operations_treasury.schema.json +11 -9
  355. package/dist/schemas/onchain_table_data.output.json +27 -17
  356. package/dist/schemas/persona_operation.output.json +15875 -1
  357. package/dist/schemas/persona_operation.schema.json +3056 -478
  358. package/dist/schemas/query_toolkit.output.json +343 -63
  359. package/dist/schemas/query_toolkit.schema.json +1 -1
  360. package/dist/schemas/workflow_operation.schema.json +4 -2
  361. package/dist/schemas/workspace_operation.output.json +181 -1
  362. package/dist/schemas/workspace_operation.schema.json +61 -2
  363. package/dist/strategy/scorecard.js +1 -1
  364. package/dist/tools/handlers/benchmark-migration.d.ts +2 -0
  365. package/dist/tools/handlers/benchmark-migration.js +1 -0
  366. package/dist/tools/handlers/config.js +1 -1
  367. package/dist/tools/handlers/industry-pack.js +1 -1
  368. package/dist/tools/handlers/onchain.js +1 -1
  369. package/dist/tools/handlers/query.js +1 -1
  370. package/dist/tools/handlers/schema-query.js +1 -1
  371. package/dist/tools/handlers/workspace.js +1 -1
  372. package/dist/tools/index.js +1 -1
  373. package/dist/tools/move-fn-index.gen.d.ts +3 -0
  374. package/dist/tools/move-fn-index.gen.js +1 -0
  375. package/dist/tools/registry/business.js +1 -1
  376. package/dist/tools/registry/config.js +1 -1
  377. package/dist/tools/registry/evaluation.js +1 -1
  378. package/dist/tools/registry/onchain.js +1 -1
  379. package/dist/tools/sanitize-output.d.ts +3 -0
  380. package/dist/tools/sanitize-output.js +1 -0
  381. package/dist/tools/sanitize-output.spec.d.ts +1 -0
  382. package/dist/tools/sanitize-output.spec.js +1 -0
  383. package/package.json +9 -4
  384. package/dist/knowledge/baselines/evaluation-baselines.json +0 -79
@@ -0,0 +1,289 @@
1
+ {
2
+ "version": 1,
3
+ "description": "Judgment baselines — the factory defaults for every judgment this process makes. Sections: evaluation (scoring standards), game (strategy-game parameters), match (demand↔service matching), monitor (order-monitor thresholds), mode (mode-evaluator posture), scorecard (strategy scorecard tuning), rules (declarative rule book — factory rule packs load from knowledge/baselines/rules/<domain>.json into this namespace and merge with your overrides at rule granularity). Layering: this factory document < your user document (<config dir>/judgment-baselines.json, key-granularity merge — it can replace values or disable rules, never delete these entries) < session runtime overrides < persona < explicit request. The user document hot-reloads on every save; an invalid edit is rejected with the last good version kept in force (see config_operation judgment_list). Example patch (any subset, deep-merged at key granularity, unknown keys rejected): {\"evaluation\": {\"severity_deduction\": {\"critical\": 40}}, \"monitor\": {\"thresholds\": {\"messenger_timeout_hours\": 12}}, \"match\": {\"top_n\": 3}}.",
4
+ "evaluation": {
5
+ "comment": "Graph service evaluation standards. Weights are relative; the aggregate renormalizes over the enabled rules. An account persona may override per-dimension weights at runtime (persona layer 'evaluation.weights'), and an explicit request injection wins over persona.",
6
+ "weights": {
7
+ "trust_arbitration": 20,
8
+ "trust_reviews": 35,
9
+ "trust_fulfillment": 20,
10
+ "trust_fund_safety": 15,
11
+ "trust_transparency": 10,
12
+ "risk_workflow": 35,
13
+ "risk_fund": 25,
14
+ "risk_trust": 20,
15
+ "risk_behavior": 20
16
+ },
17
+ "dimensions": {
18
+ "trust_arbitration": {
19
+ "label": "Arbitration",
20
+ "description": "Binding arbitration coverage of the service's payment paths."
21
+ },
22
+ "trust_reviews": {
23
+ "label": "Reputation",
24
+ "description": "Verified review votes on the service's review window."
25
+ },
26
+ "trust_fulfillment": {
27
+ "label": "Fulfillment",
28
+ "description": "Observed orders and a verifiable machine workflow (terminal set)."
29
+ },
30
+ "trust_fund_safety": {
31
+ "label": "Fund safety",
32
+ "description": "Compensation fund vs 3x windowed order volume (statutory ceiling)."
33
+ },
34
+ "trust_transparency": {
35
+ "label": "Transparency",
36
+ "description": "Snapshot self-description, lock duration and published flag."
37
+ },
38
+ "risk_workflow": {
39
+ "label": "Workflow risk",
40
+ "description": "Structural analyzer findings on the machine workflow."
41
+ },
42
+ "risk_fund": {
43
+ "label": "Fund risk",
44
+ "description": "Structural analyzer findings on fund paths and payouts."
45
+ },
46
+ "risk_trust": {
47
+ "label": "Trust-surface risk",
48
+ "description": "Structural analyzer findings on the trust surface (arb/review/fund hooks)."
49
+ },
50
+ "risk_behavior": {
51
+ "label": "Behavior risk",
52
+ "description": "Structural analyzer findings on operator behavior controls."
53
+ }
54
+ },
55
+ "severity_deduction": {
56
+ "critical": 50,
57
+ "high": 25,
58
+ "medium": 10,
59
+ "low": 5,
60
+ "info": 0
61
+ },
62
+ "level_bands": [
63
+ { "min": 85, "level": "low" },
64
+ { "min": 70, "level": "medium_low" },
65
+ { "min": 50, "level": "medium_high" },
66
+ { "min": 0, "level": "high" }
67
+ ],
68
+ "grade_words": {
69
+ "comment": "Readable per-side grade rendered from the score. trust: higher score = better service; risk: higher score = fewer findings (safer).",
70
+ "trust": [
71
+ { "min": 70, "word": "strong" },
72
+ { "min": 50, "word": "fair" },
73
+ { "min": 0, "word": "weak" }
74
+ ],
75
+ "risk": [
76
+ { "min": 80, "word": "low risk" },
77
+ { "min": 50, "word": "moderate risk" },
78
+ { "min": 0, "word": "high risk" }
79
+ ]
80
+ }
81
+ },
82
+ "game": {
83
+ "comment": "Strategy-game parameters: role value anchors, appetite multipliers and scoring constants for the gain/risk consistency evaluation (net = base + per_gain*gains − per_risk*risks*sensitivity, clamped 0-100). Keyword rules re-anchor a role's interests from a persona's natural-language red lines (Q5 dictionary — users retune keywords/effects, never invent outcome vocabulary).",
84
+ "outcome_semantics": {
85
+ "completion": ["fund_released_to_merchant", "refund_leverage_given_up"],
86
+ "refund": ["fund_returned_to_buyer", "arbitration_review_triggered"],
87
+ "advance": ["node_advanced"]
88
+ },
89
+ "role_interests": {
90
+ "customer": {
91
+ "prefer": ["fund_returned_to_buyer"],
92
+ "avoid": ["fund_released_to_merchant", "refund_leverage_given_up"],
93
+ "sensitivity": 1.0
94
+ },
95
+ "merchant": {
96
+ "prefer": ["fund_released_to_merchant"],
97
+ "avoid": ["fund_returned_to_buyer", "arbitration_review_triggered"],
98
+ "sensitivity": 1.0
99
+ },
100
+ "demander": { "prefer": ["node_advanced"], "avoid": [], "sensitivity": 1.0 },
101
+ "collaborator": { "prefer": ["node_advanced"], "avoid": [], "sensitivity": 1.0 },
102
+ "supplier": {
103
+ "prefer": ["fund_released_to_merchant", "node_advanced"],
104
+ "avoid": ["fund_returned_to_buyer"],
105
+ "sensitivity": 1.0
106
+ },
107
+ "prospect": {
108
+ "prefer": ["fund_returned_to_buyer"],
109
+ "avoid": ["fund_released_to_merchant", "arbitration_review_triggered", "refund_leverage_given_up"],
110
+ "sensitivity": 1.0
111
+ },
112
+ "arbitrator": { "prefer": [], "avoid": ["arbitration_review_triggered"], "sensitivity": 1.0 },
113
+ "neutral": { "prefer": [], "avoid": [], "sensitivity": 1.0 },
114
+ "system": { "prefer": [], "avoid": [], "sensitivity": 1.0 }
115
+ },
116
+ "appetite_multipliers": { "conservative": 1.5, "balanced": 1.0, "aggressive": 0.6 },
117
+ "scoring": { "base": 60, "per_gain": 20, "per_risk": 25 },
118
+ "keyword_rules": [
119
+ {
120
+ "id": "kw_arbitration",
121
+ "keywords": ["arbitration"],
122
+ "effect": "arbitration_review_triggered",
123
+ "anchor": "avoid",
124
+ "when_forbidden": true
125
+ },
126
+ {
127
+ "id": "kw_refund",
128
+ "keywords": ["refund"],
129
+ "effect": "fund_returned_to_buyer",
130
+ "anchor": "prefer",
131
+ "when_forbidden": false
132
+ },
133
+ {
134
+ "id": "kw_upfront",
135
+ "keywords": ["upfront", "before delivery"],
136
+ "effect": "fund_released_to_merchant",
137
+ "anchor": "avoid",
138
+ "when_forbidden": true
139
+ },
140
+ {
141
+ "id": "kw_milestone",
142
+ "keywords": ["milestone"],
143
+ "effect": "node_advanced",
144
+ "anchor": "prefer",
145
+ "when_forbidden": false
146
+ }
147
+ ],
148
+ "forbid_pattern": "forbid|never|\\bno\\b",
149
+ "arb": {
150
+ "comment": "Arbitration 7-state game tunables — a PARALLEL case-lifecycle interest model (effects are about the dispute case, not the fund lifecycle; it shares only the appetite multiplier with the fund game). effect_semantics publishes the kernel effect vocabulary; keyword_rules re-anchor a perspective's prefer/avoid from persona red lines (an unconditional keyword entry is expressed as a pair with when_forbidden true AND false); scoring: favorability = clamp(base + per_gain × gains − per_risk × risks × sensitivity).",
151
+ "effect_semantics": {
152
+ "case_advanced": ["the case moves forward"],
153
+ "case_extended": ["the case is prolonged — more cost and delay"],
154
+ "reversal_chance": ["a chance to overturn a ruling"],
155
+ "adverse_ruling": ["an unfavorable ruling lands"],
156
+ "case_closed": ["the case reaches a terminal state"],
157
+ "fees_received": ["fees or indemnity are collected"]
158
+ },
159
+ "role_interests": {
160
+ "arbitrator": {
161
+ "prefer": ["case_advanced", "fees_received", "case_closed"],
162
+ "avoid": ["case_extended"],
163
+ "sensitivity": 1.0
164
+ },
165
+ "customer": {
166
+ "prefer": ["reversal_chance", "case_closed"],
167
+ "avoid": ["adverse_ruling", "case_extended"],
168
+ "sensitivity": 1.0
169
+ },
170
+ "merchant": {
171
+ "prefer": ["case_closed", "fees_received"],
172
+ "avoid": ["adverse_ruling", "reversal_chance", "case_extended"],
173
+ "sensitivity": 1.0
174
+ }
175
+ },
176
+ "keyword_rules": [
177
+ {
178
+ "id": "arb_kw_arbitration_forbid",
179
+ "keywords": ["arbitration"],
180
+ "effect": "case_extended",
181
+ "anchor": "avoid",
182
+ "when_forbidden": true
183
+ },
184
+ {
185
+ "id": "arb_kw_refund",
186
+ "keywords": ["refund"],
187
+ "effect": "reversal_chance",
188
+ "anchor": "prefer",
189
+ "when_forbidden": false
190
+ },
191
+ {
192
+ "id": "arb_kw_prolong",
193
+ "keywords": ["prolong", "delay"],
194
+ "effect": "case_extended",
195
+ "anchor": "avoid",
196
+ "when_forbidden": false
197
+ },
198
+ {
199
+ "id": "arb_kw_prolong_forbid",
200
+ "keywords": ["prolong", "delay"],
201
+ "effect": "case_extended",
202
+ "anchor": "avoid",
203
+ "when_forbidden": true
204
+ }
205
+ ],
206
+ "forbid_pattern": "forbid|never|\\bno\\b",
207
+ "scoring": { "base": 60, "per_gain": 20, "per_risk": 25 }
208
+ }
209
+ },
210
+ "match": {
211
+ "comment": "Demand↔service matching standing defaults (builtin evaluation 'demand_match'): region relation scores, per-dimension weights, trust bands and neutrality. A per-request UserInjection can still reweight or disable dimensions; trust_bands match FIRST entry whose min ≤ trust (keep descending order).",
212
+ "region_scores": { "exact": 100, "contains": 85, "compatible": 60, "overlap": 40, "mismatch": 0 },
213
+ "weights": {
214
+ "region": 15,
215
+ "industry": 20,
216
+ "price": 15,
217
+ "trust": 15,
218
+ "capabilities": 30,
219
+ "tags": 5,
220
+ "acceptance": 10
221
+ },
222
+ "trust_bands": [
223
+ { "min": 75, "score": 100 },
224
+ { "min": 50, "score": 60 },
225
+ { "min": 25, "score": 30 },
226
+ { "min": 0, "score": 0 }
227
+ ],
228
+ "neutral_score": 50,
229
+ "price_over_budget_tolerance_pct": 10,
230
+ "top_n": 5
231
+ },
232
+ "monitor": {
233
+ "comment": "In-progress order monitoring standing defaults. A caller-supplied per-order threshold (MonitorThresholds on the monitor input) always wins over thresholds here. progress_stall_hours = 0 derives the stall threshold from the expected advancement duration (expected × stall_expected_multiplier); escalation holds the critical-grade posture.",
234
+ "thresholds": {
235
+ "progress_stall_hours": 0,
236
+ "compensation_drop_ratio": 0.3,
237
+ "compensation_coverage_min": 1.0,
238
+ "messenger_timeout_hours": 24,
239
+ "review_window_closing_days": 3,
240
+ "arb_window_closing_days": 3
241
+ },
242
+ "escalation": {
243
+ "default_expected_progress_hours": 24,
244
+ "stall_expected_multiplier": 2,
245
+ "stall_escalation_multiplier": 2,
246
+ "messenger_escalation_multiplier": 2,
247
+ "ratio_critical_threshold": 0.5
248
+ }
249
+ },
250
+ "mode": {
251
+ "comment": "Mode-evaluator posture: risk/benefit recommendation thresholds per risk appetite (merchant_guide evaluation preview). risk_benefit_ratio is computed by the kernel; only the posture thresholds are tunable here.",
252
+ "appetite_thresholds": {
253
+ "conservative": { "max_risk": 30, "min_benefit": 50 },
254
+ "balanced": { "max_risk": 60, "min_benefit": 60 },
255
+ "aggressive": { "max_risk": 100, "min_benefit": 80 }
256
+ }
257
+ },
258
+ "scorecard": {
259
+ "comment": "Strategy scorecard numeric tuning (Q7 — one scoring document): per-metric posture weights and advisory good/bad scoring anchors, plus the shop-evidence gate. Catalog identity (source/unit/direction/labels) stays kernel-owned; only these numbers are data. Anchors: full score at/beyond good, zero at/beyond bad, linear between (direction lives in the good/bad ordering). A factory anchor can be retuned, never removed; metric ids can never be invented here. Shop-evidence gate BY DESIGN: document layers (user doc / persona / industry) can retune shop_evidence_metrics but can never EMPTY it — array merges never delete entries, so a numeric overall grade always demands at least one available own-commercial metric. To browse without the gate for one session, use a runtime override (config_operation judgment_set path scorecard.shop_evidence_metrics value []).",
260
+ "metrics": {
261
+ "order_count": { "weight": { "volume": 0.2, "balanced": 0.15, "margin": 0.05 }, "good_threshold": 20, "bad_threshold": 5 },
262
+ "completed_count": { "weight": { "volume": 0.1, "balanced": 0.1, "margin": 0.1 } },
263
+ "completion_rate": { "weight": { "volume": 0.15, "balanced": 0.2, "margin": 0.15 }, "good_threshold": 0.9, "bad_threshold": 0.6 },
264
+ "repeat_customer_rate": { "weight": { "volume": 0.2, "balanced": 0.25, "margin": 0.2 }, "good_threshold": 0.25, "bad_threshold": 0.1 },
265
+ "dispute_rate": { "weight": { "volume": 0.1, "balanced": 0.15, "margin": 0.2 }, "good_threshold": 0.02, "bad_threshold": 0.05 },
266
+ "dd_to_order_rate": { "weight": { "volume": 0.15, "balanced": 0.1, "margin": 0.05 }, "good_threshold": 0.2, "bad_threshold": 0.05 },
267
+ "market_recent_orders": { "weight": { "volume": 0.05, "balanced": 0.02, "margin": 0.02 } },
268
+ "market_recent_gmv": { "weight": { "volume": 0.02, "balanced": 0.02, "margin": 0.02 } },
269
+ "supply_demand_ratio": { "weight": { "volume": 0.02, "balanced": 0.03, "margin": 0.05 }, "good_threshold": 1, "bad_threshold": 4 },
270
+ "market_active_services": { "weight": { "volume": 0.01, "balanced": 0.01, "margin": 0.01 } },
271
+ "competitor_count": { "weight": { "volume": 0.02, "balanced": 0.05, "margin": 0.1 }, "good_threshold": 5, "bad_threshold": 30 },
272
+ "category_enumerated_count": { "weight": { "volume": 0.02, "balanced": 0.05, "margin": 0.1 } },
273
+ "arbitration_trust_score": { "weight": { "volume": 0.05, "balanced": 0.1, "margin": 0.15 }, "good_threshold": 80, "bad_threshold": 50 },
274
+ "open_attention_count": { "weight": { "volume": 0.03, "balanced": 0.03, "margin": 0.05 }, "good_threshold": 0, "bad_threshold": 5 }
275
+ },
276
+ "shop_evidence_metrics": [
277
+ "order_count",
278
+ "completion_rate",
279
+ "repeat_customer_rate",
280
+ "dispute_rate",
281
+ "dd_to_order_rate",
282
+ "arbitration_trust_score"
283
+ ]
284
+ },
285
+ "rules": {
286
+ "comment": "Declarative rule book. Factory rule packs live in knowledge/baselines/rules/<domain>.json and merge into this namespace at load time (Q11 split files, single document view). Override at rule granularity: retune levels/wording or disable with enabled=false (a trace is left) — factory rules can never be deleted or invented here.",
287
+ "domains": {}
288
+ }
289
+ }
@@ -1 +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'](![]);});});
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']??'?')['toLowerCase'](),...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,290 @@
1
+ {
2
+ "comment": "alloc_audit — the Service order-allocator fund-destination audit (analyzer ALC1, knowledge/service-allocator-audit-node.ts). The kernel (recipient-constraint.ts) stays the SINGLE judgment authority for recipient semantics; this pack owns the read-side NARRATIVE and ATTRIBUTION as data: per-finding copy, severity pass-through (fact:base_level), the evidence-gap finding, and the buyer-facing fund-destination verdict. The binding emits one rule-book evaluation per canonical finding plus gap/summary; unknown canonical codes keep a generic kernel fallback. Rule ids cite the canonical codes (RC-FIND-01..08).",
3
+ "facts": {
4
+ "host_service": "Service object address under audit.",
5
+ "code": "Canonical recipient-constraint finding code (RC-FIND-01..08).",
6
+ "base_level": "Read-side severity of the canonical finding (high/medium/low; a resolution_required medium escalates to high so the read side matches the write-side severity gate).",
7
+ "evidence_paths": "Comma-joined guard expression paths that triggered the finding, or '(root)'. For RC-FIND-08 these are the relied sub-guard addresses.",
8
+ "evidence_count": "Number of evidence paths (sub-guard count for RC-FIND-08).",
9
+ "unfetched_count": "Guards referenced by the allocation template whose table/root were not fetched with the topology.",
10
+ "unfetched_list": "Comma-joined unfetched guard identifiers (with provenance notes).",
11
+ "allocator_count": "Order allocators in the service's allocation template.",
12
+ "guard_count": "Guards resolved for the audit, including one-level relies composition.",
13
+ "destinations_text": "Comma-joined beneficial owners across all recipients, or '(no recipients)'.",
14
+ "dest_unsafe": "true when an unbound Signer direct-pay path exists (safe_destination false).",
15
+ "resolution_required": "true when a residual remains that needs an explicit merchant resolution before ordering.",
16
+ "audit_summary": "The canonical audit's own summary sentence, cited verbatim."
17
+ },
18
+ "rules": [
19
+ {
20
+ "rule_id": "RC-FIND-01",
21
+ "dimension": "fund_destination",
22
+ "trigger": "Signer recipient whose guard binds no caller identity — direct fund theft path.",
23
+ "cases": [
24
+ {
25
+ "when": { "field": "code", "op": "eq", "value": "RC-FIND-01" },
26
+ "level": "fact:base_level",
27
+ "title": "Fund theft risk: Signer recipient without caller identity constraint",
28
+ "description": "The order allocator Guard of service ${host_service} delivers funds directly to the transaction caller (Recipient::Signer) but binds the Signer to no authorized identity — anyone satisfying the remaining conditions can take the funds (rule ${code}, evidence paths ${evidence_paths}).",
29
+ "mitigation": "Fix immediately: bind the Signer to a fixed address or a derived identity such as order.owner, or switch to an Entity / submitted object slot; do NOT pay this service before the fix.",
30
+ "exposure": {
31
+ "loss_parties": [
32
+ { "role": "merchant", "basis": "The allocation pool pays whoever triggers it; the funder (merchant pool or buyer escrow routed through it) loses the delivered share permanently." },
33
+ { "role": "buyer", "basis": "When the pool carries the buyer's escrowed order funds, the theft drains the escrow leg." }
34
+ ],
35
+ "gain_paths": [
36
+ { "role": "neutral", "path": "Any caller satisfying the remaining guard conditions takes the pool share directly into their own wallet (Recipient::Signer, destination = caller).", "viability": "viable", "gate": "Direct-pay + no identity binding is the theft path itself; nothing else gates it." }
37
+ ]
38
+ }
39
+ }
40
+ ]
41
+ },
42
+ {
43
+ "rule_id": "RC-FIND-02",
44
+ "dimension": "fund_destination",
45
+ "trigger": "Submission slot without scope binding — arbitrary qualifying claims.",
46
+ "cases": [
47
+ {
48
+ "when": { "field": "code", "op": "eq", "value": "RC-FIND-02" },
49
+ "level": "fact:base_level",
50
+ "title": "Insufficient allocation condition: submission slot has no scope binding",
51
+ "description": "The order allocator Guard of service ${host_service} leaves its submission slot without any scope constraint (no order.service binding, no repository cross-check, no permission membership): a caller can submit arbitrary qualifying objects/addresses to claim the funds (rule ${code}, evidence paths ${evidence_paths}).",
52
+ "mitigation": "Require the merchant to add order.service == this service (query 1563) before ordering; an unbound recipient slot can be claimed by others.",
53
+ "exposure": {
54
+ "loss_parties": [
55
+ { "role": "merchant", "basis": "The allocation pool funds an attacker-chosen destination instead of the intended recipient split." },
56
+ { "role": "buyer", "basis": "Escrowed order funds routed through the pool can be steered to a third party the buyer never contracted with." }
57
+ ],
58
+ "gain_paths": [
59
+ { "role": "neutral", "path": "Submit an attacker-controlled address (or an order the attacker owns) in the unscoped slot and collect the pool share.", "viability": "viable", "gate": "Nothing constrains the submitted value; the CoinWrapper lands at the submitted target — wallet targets are directly collectible." }
60
+ ]
61
+ }
62
+ }
63
+ ]
64
+ },
65
+ {
66
+ "rule_id": "RC-FIND-03",
67
+ "dimension": "fund_destination",
68
+ "trigger": "Cross-order settlement residual — pool choice contestable, destination safe.",
69
+ "cases": [
70
+ {
71
+ "when": { "field": "code", "op": "eq", "value": "RC-FIND-03" },
72
+ "level": "fact:base_level",
73
+ "title": "Cross-order settlement residual (explicit resolution required)",
74
+ "description": "When the order allocator Guard of service ${host_service} pays the submitted order object, that order is not bound to the Allocation being settled (alloc is permissionless and allocation context is not a Guard input): a caller owning ANY qualifying order can settle OTHER allocations. Funds still land at the submitted order and only its owner can withdraw — destination is safe, the pool CHOICE is the residual (rule ${code}, evidence paths ${evidence_paths}).",
75
+ "mitigation": "Require the merchant to pick ONE resolution and record it in the service description: (1) declare competition semantics and cap exposure via threshold/max; (2) switch to a fixed Entity (treasury) recipient — the only exclusive choice on the automatic order_allocators route; (3) drop automatic allocation and pin a per-order Guard (order.owner == constant) for trustless exclusivity.",
76
+ "exposure": {
77
+ "loss_parties": [
78
+ { "role": "buyer", "basis": "Whoever funded the victim allocation (typically the order-tied buyer escrow) loses their pool to another order's settlement." },
79
+ { "role": "merchant", "basis": "Intended per-order distribution semantics cannot be enforced; disputes over 'whose pool was consumed' land on the merchant." }
80
+ ],
81
+ "gain_paths": [
82
+ { "role": "supplier", "path": "A caller owning any qualifying order settles a different allocation and drains its pool into their own order (they are that order's owner and collect on withdrawal).", "viability": "conditional", "gate": "Requires the caller to hold a guard-qualifying order and the allocation's payment_info to be unbound; destination stays an order owner — only the pool CHOICE is contested." }
83
+ ]
84
+ }
85
+ }
86
+ ]
87
+ },
88
+ {
89
+ "rule_id": "RC-FIND-04",
90
+ "dimension": "fund_destination",
91
+ "trigger": "Standalone allocation with no issuer binding — anyone can trigger distribution.",
92
+ "cases": [
93
+ {
94
+ "when": { "field": "code", "op": "eq", "value": "RC-FIND-04" },
95
+ "level": "fact:base_level",
96
+ "title": "Standalone allocation without issuer identity constraint",
97
+ "description": "The allocator Guard associated with service ${host_service} is in standalone form (no Service/arbitration access-control layer) and binds no Signer identity: anyone can trigger distribution (rule ${code}).",
98
+ "mitigation": "Bind the issuer (Signer == owner/admin) or move the allocation into a Service access-control layer.",
99
+ "exposure": {
100
+ "loss_parties": [
101
+ { "role": "merchant", "basis": "Distribution timing escapes the issuer's control — the pool can be released before the intended moment or conditions." },
102
+ { "role": "buyer", "basis": "Escrow release no longer tracks the agreed schedule." }
103
+ ],
104
+ "gain_paths": [
105
+ { "role": "neutral", "path": "Trigger distribution early; the configured recipients receive funds ahead of schedule (destination itself is unchanged).", "viability": "viable", "gate": "No issuer binding means any account can fire the settlement entry; the gain is timing control, not redirection." }
106
+ ]
107
+ }
108
+ }
109
+ ]
110
+ },
111
+ {
112
+ "rule_id": "RC-FIND-05",
113
+ "dimension": "fund_destination",
114
+ "trigger": "Session-only guard queries — permanent deadlock after session migration (shortfall, nobody gains).",
115
+ "cases": [
116
+ {
117
+ "when": { "field": "code", "op": "eq", "value": "RC-FIND-05" },
118
+ "level": "medium",
119
+ "title": "Guard uses session-only queries — fails permanently after session migration",
120
+ "description": "The order allocator Guard of service ${host_service} uses session queries (1270/1271) at ${evidence_paths}: after the session migrates to history the query aborts (W_FIELD_NOT_FOUND) and the Guard fails permanently — allocation can never trigger (rule ${code}).",
121
+ "mitigation": "Require the merchant to switch to progress.current_time (1272) or history queries (1274-1279); session queries deadlock the allocation.",
122
+ "exposure": {
123
+ "loss_parties": [
124
+ { "role": "supplier", "basis": "Expected allocator payouts never release — the pool is stranded behind a permanently failing guard." },
125
+ { "role": "buyer", "basis": "The escrowed order leg the allocation should release is frozen with it." }
126
+ ],
127
+ "gain_paths": []
128
+ }
129
+ }
130
+ ]
131
+ },
132
+ {
133
+ "rule_id": "RC-FIND-06",
134
+ "dimension": "fund_destination",
135
+ "trigger": "Permissionless alloc — settlement timing front-run; destination provably unaffected.",
136
+ "cases": [
137
+ {
138
+ "when": { "field": "code", "op": "eq", "value": "RC-FIND-06" },
139
+ "level": "low",
140
+ "title": "Permissionless alloc — settlement timing can be front-run",
141
+ "description": "Once the Guard conditions of service ${host_service}'s allocation hold, anyone can trigger settlement (alloc is permissionless). For Entity/object recipients this affects timing only, not destination (rule ${code}).",
142
+ "mitigation": "Watch settlement events; constrain time-sensitive allocations via Guard time conditions.",
143
+ "exposure": {
144
+ "loss_parties": [
145
+ { "role": "buyer", "basis": "Settlement timing becomes unpredictable — the buyer cannot rely on the scheduled release moment." },
146
+ { "role": "merchant", "basis": "Distribution timing escapes merchant control." }
147
+ ],
148
+ "gain_paths": [
149
+ { "role": "neutral", "path": "Trigger settlement the instant conditions hold; destination is provably unaffected (object receipt = owner receipt).", "viability": "viable", "gate": "Timing control only — the theft path (destination redirect) is blocked by Wow ownership; severity stays informational." }
150
+ ]
151
+ }
152
+ }
153
+ ]
154
+ },
155
+ {
156
+ "rule_id": "RC-FIND-07",
157
+ "dimension": "fund_destination",
158
+ "trigger": "Submission slot not Address-typed — allocation config invalid at registration.",
159
+ "cases": [
160
+ {
161
+ "when": { "field": "code", "op": "eq", "value": "RC-FIND-07" },
162
+ "level": "medium",
163
+ "title": "Submission slot is not address-typed",
164
+ "description": "The GuardIdentifier recipient slot of the order allocator Guard of service ${host_service} is not Address-typed: the Allocator-add step rejects it (ERECIPIENT_IDENTIFIER_NOT_ADDRESS) and the allocation config is invalid (rule ${code}, evidence paths ${evidence_paths}).",
165
+ "mitigation": "Change the slot value_type to Address, or switch to an Entity recipient.",
166
+ "exposure": {
167
+ "loss_parties": [
168
+ { "role": "merchant", "basis": "The allocation configuration is rejected at registration — the intended distribution never goes live." }
169
+ ],
170
+ "gain_paths": []
171
+ }
172
+ }
173
+ ]
174
+ },
175
+ {
176
+ "rule_id": "RC-FIND-08",
177
+ "dimension": "fund_destination",
178
+ "trigger": "Sub-guard composition — constraints not credited; both error directions disclosed.",
179
+ "cases": [
180
+ {
181
+ "when": { "field": "code", "op": "eq", "value": "RC-FIND-08" },
182
+ "level": "fact:base_level",
183
+ "title": "Guard relies on sub-guards — their constraints are NOT credited by this audit",
184
+ "description": "The allocator Guard of service ${host_service} composes ${evidence_count} sub-guard(s) via relies (one level, <=4): scope/signer constraints may live in the sub-guards. This audit evaluates only the guard's own expression tree — sub-guard constraints are NOT credited, so scope-binding gaps (RC-FIND-02) may be over-reported and sub-guard-only conditions stay unverified (rule ${code}).",
185
+ "mitigation": "Read the relied sub-guards' table and root directly on-chain and verify their constraints manually, or re-run with an audit tool that resolves them automatically.",
186
+ "exposure": {
187
+ "loss_parties": [
188
+ { "role": "buyer", "basis": "The audit's conclusions for this guard are uncertain in both directions — a real gap may be hidden in, or falsely imputed to, the composed sub-guards." }
189
+ ],
190
+ "gain_paths": [
191
+ { "role": "neutral", "path": "If a sub-guard carries a constraint this audit missed, the paired gap findings overstate the exposure; if the root alone is weak, the paired findings understate nothing — the deciding predicate sits outside this audit's evidence.", "viability": "unverifiable", "gate": "Disclosure duty: resolve every relied sub-guard (table + root) and re-run the canonical audit before ordering." }
192
+ ]
193
+ }
194
+ }
195
+ ]
196
+ },
197
+ {
198
+ "rule_id": "RC-GAP",
199
+ "dimension": "evidence",
200
+ "trigger": "Referenced guard table/root not fetched — the audit would silently pass; emits a visible evidence gap (shortfall, nobody gains).",
201
+ "cases": [
202
+ {
203
+ "when": { "field": "unfetched_count", "op": "gt", "value": 0 },
204
+ "level": "info",
205
+ "title": "Allocator Guard evidence gap: expression tree not fetched — fund-destination audit incomplete",
206
+ "description": "The allocation template of service ${host_service} references ${unfetched_count} guard(s) whose table/root were not fetched with the topology (${unfetched_list}): fund ownership and condition sufficiency cannot be assessed.",
207
+ "mitigation": "Read these guards' table and root directly by address on-chain and re-audit; an evidence gap is not a pass.",
208
+ "exposure": {
209
+ "loss_parties": [
210
+ { "role": "buyer", "basis": "The buyer cannot assess fund ownership or condition sufficiency for the unresolved guards — the decision rests on undisclosed information." },
211
+ { "role": "merchant", "basis": "Undisclosed guard internals keep the allocation unverifiable for every counterparty." }
212
+ ],
213
+ "gain_paths": []
214
+ }
215
+ }
216
+ ]
217
+ },
218
+ {
219
+ "rule_id": "RC-SUMMARY",
220
+ "dimension": "verdict",
221
+ "trigger": "Buyer-facing fund-destination verdict over the whole allocation template (unsafe wins, then residual, then safe).",
222
+ "cases": [
223
+ {
224
+ "when": { "all": [ { "field": "dest_unsafe", "op": "truthy" }, { "field": "resolution_required", "op": "truthy" } ] },
225
+ "level": "high",
226
+ "title": "Fund destination and condition integrity: stealable destination exists (residual requires explicit decision)",
227
+ "description": "Service ${host_service} allocation template: ${allocator_count} allocator(s) / ${guard_count} resolved guard(s). Fund destinations = ${destinations_text}. WARNING: an unbound Signer direct-pay path exists — do not pay before the fix. ${audit_summary}",
228
+ "mitigation": "A fund theft path exists: do not pay this service and require the merchant to fix the Guard.",
229
+ "exposure": {
230
+ "loss_parties": [
231
+ { "role": "merchant", "basis": "Intended fund destinations: ${destinations_text} — any deviation from this split is a loss for the intended parties." },
232
+ { "role": "buyer", "basis": "An unbound direct-pay path exists on the order allocator — escrowed funds routed through it can be taken before fulfillment." }
233
+ ],
234
+ "gain_paths": [
235
+ { "role": "neutral", "path": "An unbound Recipient::Signer direct-pay path hands the pool share to whoever triggers settlement.", "viability": "viable", "gate": "Signer recipient with no caller binding — the destination IS the attacker's wallet." }
236
+ ]
237
+ }
238
+ },
239
+ {
240
+ "when": { "field": "dest_unsafe", "op": "truthy" },
241
+ "level": "high",
242
+ "title": "Fund destination and condition integrity: stealable destination exists",
243
+ "description": "Service ${host_service} allocation template: ${allocator_count} allocator(s) / ${guard_count} resolved guard(s). Fund destinations = ${destinations_text}. WARNING: an unbound Signer direct-pay path exists — do not pay before the fix. ${audit_summary}",
244
+ "mitigation": "A fund theft path exists: do not pay this service and require the merchant to fix the Guard.",
245
+ "exposure": {
246
+ "loss_parties": [
247
+ { "role": "merchant", "basis": "Intended fund destinations: ${destinations_text} — any deviation from this split is a loss for the intended parties." },
248
+ { "role": "buyer", "basis": "An unbound direct-pay path exists on the order allocator — escrowed funds routed through it can be taken before fulfillment." }
249
+ ],
250
+ "gain_paths": [
251
+ { "role": "neutral", "path": "An unbound Recipient::Signer direct-pay path hands the pool share to whoever triggers settlement.", "viability": "viable", "gate": "Signer recipient with no caller binding — the destination IS the attacker's wallet." }
252
+ ]
253
+ }
254
+ },
255
+ {
256
+ "when": { "all": [ { "field": "dest_unsafe", "op": "falsy" }, { "field": "resolution_required", "op": "truthy" } ] },
257
+ "level": "medium",
258
+ "title": "Fund destination and condition integrity: destination safe (residual requires explicit decision)",
259
+ "description": "Service ${host_service} allocation template: ${allocator_count} allocator(s) / ${guard_count} resolved guard(s). Fund destinations = ${destinations_text}. No recipient can be redirected to an arbitrary attacker-controlled address (order escrow is enforced by Wow ownership: only the order owner can extract via owner_receive). ${audit_summary}",
260
+ "mitigation": "Before ordering, require the merchant to pick one resolution for the residual (competition declaration + capped exposure / Entity treasury routing / per-order pinned Guards) and confirm it is written in the service description.",
261
+ "exposure": {
262
+ "loss_parties": [
263
+ { "role": "merchant", "basis": "Intended fund destinations: ${destinations_text} — any deviation from this split is a loss for the intended parties." },
264
+ { "role": "buyer", "basis": "Escrowed order funds route through these destinations; sufficiency gaps stall the buyer's release." }
265
+ ],
266
+ "gain_paths": [
267
+ { "role": "neutral", "path": "Redirect a settlement to an attacker-controlled address.", "viability": "conditional", "gate": "Destination stays an order/entity owner; only the pool CHOICE is contestable (cross-order settlement residual)." }
268
+ ]
269
+ }
270
+ },
271
+ {
272
+ "when": { "all": [ { "field": "dest_unsafe", "op": "falsy" }, { "field": "resolution_required", "op": "falsy" } ] },
273
+ "level": "info",
274
+ "title": "Fund destination and condition integrity: destination safe",
275
+ "description": "Service ${host_service} allocation template: ${allocator_count} allocator(s) / ${guard_count} resolved guard(s). Fund destinations = ${destinations_text}. No recipient can be redirected to an arbitrary attacker-controlled address (order escrow is enforced by Wow ownership: only the order owner can extract via owner_receive). ${audit_summary}",
276
+ "mitigation": "Destination is safe; verify condition sufficiency per the RC audit suggestions before ordering.",
277
+ "exposure": {
278
+ "loss_parties": [
279
+ { "role": "merchant", "basis": "Intended fund destinations: ${destinations_text} — any deviation from this split is a loss for the intended parties." },
280
+ { "role": "buyer", "basis": "Escrowed order funds route through these destinations; sufficiency gaps stall the buyer's release." }
281
+ ],
282
+ "gain_paths": [
283
+ { "role": "neutral", "path": "Redirect a settlement to an attacker-controlled address.", "viability": "blocked", "gate": "Every recipient is a fixed entity or an order-tied submission — object receipt = owner receipt, no attacker-controlled destination exists." }
284
+ ]
285
+ }
286
+ }
287
+ ]
288
+ }
289
+ ]
290
+ }