@wowok/agent-mcp 2.7.0 → 2.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (427) hide show
  1. package/dist/config/index.js +1 -1
  2. package/dist/config/runtime.js +1 -238
  3. package/dist/customer/customer-advice.js +1 -130
  4. package/dist/customer/index.js +1 -11
  5. package/dist/customer/industry-risks.js +1 -438
  6. package/dist/customer/info-puzzle.js +1 -681
  7. package/dist/customer/order-monitor.js +1 -328
  8. package/dist/customer/order-strategy.js +1 -373
  9. package/dist/customer/post-purchase.js +1 -351
  10. package/dist/customer/preorder-compare.js +1 -34
  11. package/dist/customer/reminder-system.js +1 -316
  12. package/dist/customer/risk-assessment.d.ts +5 -1
  13. package/dist/customer/risk-assessment.js +1 -397
  14. package/dist/customer/types.js +1 -13
  15. package/dist/customer/user-preferences.js +1 -460
  16. package/dist/evaluation/arbitration-game.d.ts +23 -0
  17. package/dist/evaluation/arbitration-game.js +1 -0
  18. package/dist/evaluation/builtins/demand-match.d.ts +15 -0
  19. package/dist/evaluation/builtins/demand-match.js +1 -0
  20. package/dist/evaluation/builtins/index.d.ts +3 -0
  21. package/dist/evaluation/builtins/index.js +1 -0
  22. package/dist/evaluation/builtins/service-risk.d.ts +6 -0
  23. package/dist/evaluation/builtins/service-risk.js +1 -0
  24. package/dist/evaluation/capability.d.ts +50 -0
  25. package/dist/evaluation/capability.js +1 -0
  26. package/dist/evaluation/composer.d.ts +13 -0
  27. package/dist/evaluation/composer.js +1 -0
  28. package/dist/evaluation/engine.d.ts +18 -0
  29. package/dist/evaluation/engine.js +1 -0
  30. package/dist/evaluation/extract.d.ts +30 -0
  31. package/dist/evaluation/extract.js +1 -0
  32. package/dist/evaluation/game-strategy.d.ts +27 -0
  33. package/dist/evaluation/game-strategy.js +1 -0
  34. package/dist/evaluation/gap.d.ts +2 -0
  35. package/dist/evaluation/gap.js +1 -0
  36. package/dist/evaluation/index.d.ts +12 -0
  37. package/dist/evaluation/index.js +1 -0
  38. package/dist/evaluation/node-game.d.ts +62 -0
  39. package/dist/evaluation/node-game.js +1 -0
  40. package/dist/evaluation/region.d.ts +10 -0
  41. package/dist/evaluation/region.js +1 -0
  42. package/dist/evaluation/types.d.ts +77 -0
  43. package/dist/evaluation/types.js +1 -0
  44. package/dist/evaluation/user-injection.d.ts +6 -0
  45. package/dist/evaluation/user-injection.js +1 -0
  46. package/dist/examples/education-contact-create.json +40 -0
  47. package/dist/examples/freelance-contact-create.json +40 -0
  48. package/dist/examples/insurance-machine-create.json +1 -1
  49. package/dist/examples/insurance-service-allocators.json +1 -1
  50. package/dist/examples/machine-publish.json +1 -1
  51. package/dist/examples/rental-ziroom-service-create.json +1 -1
  52. package/dist/examples/retail-adv-guard-messenger-proof-create.json +1 -1
  53. package/dist/examples/retail-myshop-service-create.json +1 -1
  54. package/dist/examples/retail-myshop-service-customer-required.json +1 -1
  55. package/dist/examples/subscription-contact-create.json +40 -0
  56. package/dist/examples/threebody-machine-create.json +1 -1
  57. package/dist/examples/travel-machine-create.json +1 -1
  58. package/dist/examples/travel-service-create.json +1 -1
  59. package/dist/experience/experience-reuse.js +1 -103
  60. package/dist/experience/index.js +1 -5
  61. package/dist/experience/intent-distill.js +1 -83
  62. package/dist/experience/realtime-feedback.js +1 -94
  63. package/dist/experience/types.js +1 -1
  64. package/dist/experience/user-profile.js +1 -171
  65. package/dist/extensions/business-modules.js +1 -287
  66. package/dist/extensions/capability-manifest.js +1 -781
  67. package/dist/extensions/constraint-registry.js +1 -198
  68. package/dist/extensions/index.js +1 -6
  69. package/dist/extensions/metric-registry.js +1 -257
  70. package/dist/extensions/mode-evaluator.js +1 -170
  71. package/dist/extensions/modes.js +1 -499
  72. package/dist/extensions/registry.js +1 -717
  73. package/dist/extensions/types.js +1 -1
  74. package/dist/harness/auto-escalation.js +1 -68
  75. package/dist/harness/checkpoint.js +1 -129
  76. package/dist/harness/index.js +1 -78
  77. package/dist/harness/plan.js +1 -276
  78. package/dist/harness/recover.js +1 -139
  79. package/dist/harness/types.js +1 -1
  80. package/dist/harness/verify.js +1 -237
  81. package/dist/index.js +1 -273
  82. package/dist/intent/enrich.d.ts +1 -0
  83. package/dist/intent/enrich.js +1 -0
  84. package/dist/intent/index.d.ts +23 -0
  85. package/dist/intent/index.js +1 -0
  86. package/dist/intent/matcher.d.ts +2 -0
  87. package/dist/intent/matcher.js +1 -0
  88. package/dist/intent/store.d.ts +19 -0
  89. package/dist/intent/store.js +1 -0
  90. package/dist/intent/types.d.ts +33 -0
  91. package/dist/intent/types.js +1 -0
  92. package/dist/knowledge/acquisition-flywheel.js +1 -192
  93. package/dist/knowledge/allocation-confirm.js +1 -534
  94. package/dist/knowledge/allocation-context.js +1 -249
  95. package/dist/knowledge/allocation-ledger.js +1 -463
  96. package/dist/knowledge/allocation-puzzle.js +1 -298
  97. package/dist/knowledge/allocation-risk.js +1 -568
  98. package/dist/knowledge/allocation-templates.js +1 -970
  99. package/dist/knowledge/allocation-translation.js +1 -585
  100. package/dist/knowledge/arb-risk.js +1 -210
  101. package/dist/knowledge/arbitration-confirm.js +1 -559
  102. package/dist/knowledge/arbitration-context.js +1 -505
  103. package/dist/knowledge/arbitration-ledger.js +1 -521
  104. package/dist/knowledge/arbitration-puzzle.js +1 -304
  105. package/dist/knowledge/arbitration-risk.js +1 -433
  106. package/dist/knowledge/arbitration-templates.js +1 -276
  107. package/dist/knowledge/arbitration-translation.js +1 -487
  108. package/dist/knowledge/arbitration-trust.js +1 -117
  109. package/dist/knowledge/audit-rules.js +1 -141
  110. package/dist/knowledge/bridge-risk.js +1 -263
  111. package/dist/knowledge/contact-risk.js +1 -200
  112. package/dist/knowledge/contact-templates.d.ts +27 -0
  113. package/dist/knowledge/contact-templates.js +1 -0
  114. package/dist/knowledge/demand-confirm.js +1 -206
  115. package/dist/knowledge/demand-matching.js +1 -132
  116. package/dist/knowledge/demand-risk.js +1 -240
  117. package/dist/knowledge/demand-translation.js +1 -354
  118. package/dist/knowledge/deployment-scanner.js +1 -823
  119. package/dist/knowledge/dynamic-pricing.js +1 -87
  120. package/dist/knowledge/examples-scanner-cli.js +1 -26
  121. package/dist/knowledge/examples-scanner.js +1 -825
  122. package/dist/knowledge/flywheel-loop.js +1 -404
  123. package/dist/knowledge/fund-layer.js +1 -973
  124. package/dist/knowledge/glossary.js +1 -211
  125. package/dist/knowledge/guard-confirm.js +1 -406
  126. package/dist/knowledge/guard-context.js +1 -287
  127. package/dist/knowledge/guard-design-patterns.js +1 -360
  128. package/dist/knowledge/guard-ledger.js +1 -260
  129. package/dist/knowledge/guard-lint.js +1 -670
  130. package/dist/knowledge/guard-migration.js +1 -228
  131. package/dist/knowledge/guard-puzzle.js +1 -805
  132. package/dist/knowledge/guard-render.js +1 -700
  133. package/dist/knowledge/guard-risk.js +1 -1879
  134. package/dist/knowledge/guard-submission-prompt.js +1 -171
  135. package/dist/knowledge/guard-templates.js +1 -1105
  136. package/dist/knowledge/guard-translation.js +1 -1119
  137. package/dist/knowledge/index.js +1 -436
  138. package/dist/knowledge/industry-evolution.js +1 -323
  139. package/dist/knowledge/industry-generalizer.js +1 -381
  140. package/dist/knowledge/industry-registry.js +1 -174
  141. package/dist/knowledge/intent-metrics.d.ts +4 -3
  142. package/dist/knowledge/intent-metrics.js +1 -566
  143. package/dist/knowledge/machine-confirm.js +1 -559
  144. package/dist/knowledge/machine-context.js +1 -833
  145. package/dist/knowledge/machine-ledger.js +1 -338
  146. package/dist/knowledge/machine-puzzle.js +1 -494
  147. package/dist/knowledge/machine-render.js +1 -565
  148. package/dist/knowledge/machine-risk.js +1 -670
  149. package/dist/knowledge/machine-templates.js +1 -1597
  150. package/dist/knowledge/machine-topology.js +1 -234
  151. package/dist/knowledge/machine-translation.js +1 -513
  152. package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
  153. package/dist/knowledge/mcp-schema-audit.d.ts +1 -1
  154. package/dist/knowledge/mcp-schema-audit.js +1 -773
  155. package/dist/knowledge/onchain-constants.js +1 -35
  156. package/dist/knowledge/order-confirm.js +1 -573
  157. package/dist/knowledge/order-context.js +1 -390
  158. package/dist/knowledge/order-ledger.js +1 -341
  159. package/dist/knowledge/order-puzzle.js +1 -255
  160. package/dist/knowledge/order-risk.js +1 -653
  161. package/dist/knowledge/order-templates.js +1 -368
  162. package/dist/knowledge/order-translation.js +1 -550
  163. package/dist/knowledge/overrides-loader.js +1 -65
  164. package/dist/knowledge/passport-confirm.js +1 -531
  165. package/dist/knowledge/passport-context.js +1 -306
  166. package/dist/knowledge/passport-ledger.js +1 -282
  167. package/dist/knowledge/passport-puzzle.js +1 -333
  168. package/dist/knowledge/passport-risk.js +1 -450
  169. package/dist/knowledge/passport-templates.js +1 -568
  170. package/dist/knowledge/passport-translation.js +1 -516
  171. package/dist/knowledge/payment-risk.js +1 -249
  172. package/dist/knowledge/permission-confirm.js +1 -426
  173. package/dist/knowledge/permission-context.js +1 -224
  174. package/dist/knowledge/permission-ledger.js +1 -403
  175. package/dist/knowledge/permission-puzzle.js +1 -173
  176. package/dist/knowledge/permission-risk.js +1 -411
  177. package/dist/knowledge/permission-templates.js +1 -234
  178. package/dist/knowledge/permission-translation.js +1 -350
  179. package/dist/knowledge/personal-risk.js +1 -212
  180. package/dist/knowledge/process-model.js +1 -160
  181. package/dist/knowledge/progress-confirm.js +1 -456
  182. package/dist/knowledge/progress-context.js +1 -452
  183. package/dist/knowledge/progress-ledger.js +1 -330
  184. package/dist/knowledge/progress-puzzle.js +1 -219
  185. package/dist/knowledge/progress-risk.js +1 -461
  186. package/dist/knowledge/progress-templates.js +1 -228
  187. package/dist/knowledge/progress-translation.js +1 -405
  188. package/dist/knowledge/proof-confirm.js +1 -187
  189. package/dist/knowledge/proof-risk.js +1 -207
  190. package/dist/knowledge/proof-translation.js +1 -283
  191. package/dist/knowledge/registrar-risk.js +1 -217
  192. package/dist/knowledge/repository-confirm.js +1 -286
  193. package/dist/knowledge/repository-risk.js +1 -373
  194. package/dist/knowledge/repository-translation.js +1 -445
  195. package/dist/knowledge/reputation-rules.js +1 -99
  196. package/dist/knowledge/resource-risk.js +1 -157
  197. package/dist/knowledge/reward-confirm.js +1 -526
  198. package/dist/knowledge/reward-context.js +1 -504
  199. package/dist/knowledge/reward-ledger.js +1 -502
  200. package/dist/knowledge/reward-puzzle.js +1 -300
  201. package/dist/knowledge/reward-risk.js +1 -627
  202. package/dist/knowledge/reward-templates.js +1 -197
  203. package/dist/knowledge/reward-translation.js +1 -501
  204. package/dist/knowledge/safety-rules.js +1 -404
  205. package/dist/knowledge/scenario-modes.js +1 -321
  206. package/dist/knowledge/service-confirm.js +1 -807
  207. package/dist/knowledge/service-context.js +1 -403
  208. package/dist/knowledge/service-ledger.js +1 -609
  209. package/dist/knowledge/service-puzzle.js +1 -236
  210. package/dist/knowledge/service-risk.js +1 -615
  211. package/dist/knowledge/service-templates.js +1 -456
  212. package/dist/knowledge/service-translation.js +1 -622
  213. package/dist/knowledge/template-registry.d.ts +1 -1
  214. package/dist/knowledge/template-registry.js +1 -341
  215. package/dist/knowledge/tool-constraints.js +1 -195
  216. package/dist/knowledge/tools-reference.js +1 -155
  217. package/dist/knowledge/treasury-confirm.js +1 -512
  218. package/dist/knowledge/treasury-context.js +1 -363
  219. package/dist/knowledge/treasury-ledger.js +1 -300
  220. package/dist/knowledge/treasury-puzzle.js +1 -216
  221. package/dist/knowledge/treasury-risk.js +1 -440
  222. package/dist/knowledge/treasury-templates.js +1 -358
  223. package/dist/knowledge/treasury-translation.js +1 -498
  224. package/dist/knowledge/trust-metrics.js +1 -198
  225. package/dist/knowledge/util-risk.js +1 -135
  226. package/dist/loop-engineering/aggregate.js +1 -132
  227. package/dist/loop-engineering/context-collect.js +1 -83
  228. package/dist/loop-engineering/diagnose.js +1 -273
  229. package/dist/loop-engineering/improve.js +1 -405
  230. package/dist/loop-engineering/index.js +1 -4
  231. package/dist/loop-engineering/pipeline.js +1 -56
  232. package/dist/mode-market/index.js +1 -3
  233. package/dist/mode-market/registry.js +1 -124
  234. package/dist/mode-market/review.js +1 -214
  235. package/dist/mode-market/submission.js +1 -85
  236. package/dist/participation/collaborator-interest.d.ts +23 -0
  237. package/dist/participation/collaborator-interest.js +1 -0
  238. package/dist/participation/customer-interest.d.ts +25 -0
  239. package/dist/participation/customer-interest.js +1 -0
  240. package/dist/participation/merchant-interest.js +1 -100
  241. package/dist/participation/radar-core.d.ts +13 -3
  242. package/dist/participation/radar-core.js +1 -269
  243. package/dist/participation/supplier-interest.d.ts +25 -0
  244. package/dist/participation/supplier-interest.js +1 -0
  245. package/dist/persona/analyzer.d.ts +16 -0
  246. package/dist/persona/analyzer.js +1 -0
  247. package/dist/persona/bridge.d.ts +5 -0
  248. package/dist/persona/bridge.js +1 -0
  249. package/dist/persona/defaults.d.ts +4 -0
  250. package/dist/persona/defaults.js +1 -0
  251. package/dist/persona/experience-bridge.d.ts +3 -0
  252. package/dist/persona/experience-bridge.js +1 -0
  253. package/dist/persona/index.d.ts +18 -0
  254. package/dist/persona/index.js +1 -0
  255. package/dist/persona/model.d.ts +7 -0
  256. package/dist/persona/model.js +1 -0
  257. package/dist/persona/store.d.ts +19 -0
  258. package/dist/persona/store.js +1 -0
  259. package/dist/persona/types.d.ts +45 -0
  260. package/dist/persona/types.js +1 -0
  261. package/dist/project/business-puzzle.js +1 -383
  262. package/dist/project/context-assembly.js +1 -254
  263. package/dist/project/deployment-bridge.js +1 -120
  264. package/dist/project/deployment-doc.js +1 -1126
  265. package/dist/project/edit-planner.js +1 -1342
  266. package/dist/project/evaluation.js +1 -2011
  267. package/dist/project/game-theory.js +1 -177
  268. package/dist/project/graph-builder.js +1 -656
  269. package/dist/project/graph.js +1 -340
  270. package/dist/project/handlers.d.ts +5 -0
  271. package/dist/project/handlers.js +1 -1762
  272. package/dist/project/index.d.ts +1 -0
  273. package/dist/project/index.js +1 -301
  274. package/dist/project/intent-analyzer.js +1 -149
  275. package/dist/project/machine-nodes.js +1 -36
  276. package/dist/project/merchant-guide.js +1 -264
  277. package/dist/project/migration.js +1 -125
  278. package/dist/project/mode-actions.js +1 -309
  279. package/dist/project/namespace.js +1 -206
  280. package/dist/project/participation-radar.js +1 -428
  281. package/dist/project/pipeline-actions.js +1 -109
  282. package/dist/project/project-store.js +1 -422
  283. package/dist/project/query.js +1 -153
  284. package/dist/project/reverse-mapping.d.ts +34 -0
  285. package/dist/project/reverse-mapping.js +1 -0
  286. package/dist/project/risk-aggregator.js +1 -295
  287. package/dist/project/rollback-policy.js +1 -290
  288. package/dist/project/semantic-assembler.js +1 -345
  289. package/dist/project/semantic-graph.js +1 -245
  290. package/dist/project/stage-gate.js +1 -369
  291. package/dist/project/substep-trace.js +1 -332
  292. package/dist/project/task-tracker.js +1 -78
  293. package/dist/role/derivation.d.ts +18 -0
  294. package/dist/role/derivation.js +1 -0
  295. package/dist/role/index.d.ts +5 -0
  296. package/dist/role/index.js +1 -0
  297. package/dist/role/model.d.ts +8 -0
  298. package/dist/role/model.js +1 -0
  299. package/dist/role/resolution.d.ts +11 -0
  300. package/dist/role/resolution.js +1 -0
  301. package/dist/role/types.d.ts +11 -0
  302. package/dist/role/types.js +1 -0
  303. package/dist/rules.d.ts +2 -0
  304. package/dist/rules.js +1 -9
  305. package/dist/safety/confirm-gate.js +1 -88
  306. package/dist/safety/index.js +1 -3
  307. package/dist/safety/preview.js +1 -52
  308. package/dist/schema/call/allocation.js +1 -34
  309. package/dist/schema/call/arbitration.js +1 -113
  310. package/dist/schema/call/base.d.ts +15 -15
  311. package/dist/schema/call/base.js +1 -370
  312. package/dist/schema/call/bridge-handler.js +1 -265
  313. package/dist/schema/call/bridge.d.ts +7 -7
  314. package/dist/schema/call/bridge.js +1 -458
  315. package/dist/schema/call/contact.js +1 -37
  316. package/dist/schema/call/demand.js +1 -47
  317. package/dist/schema/call/guard.js +1 -161
  318. package/dist/schema/call/handler.js +1 -322
  319. package/dist/schema/call/index.js +1 -20
  320. package/dist/schema/call/machine.js +1 -193
  321. package/dist/schema/call/order.js +1 -35
  322. package/dist/schema/call/payment.js +1 -37
  323. package/dist/schema/call/permission-handler.js +1 -54
  324. package/dist/schema/call/permission.js +1 -105
  325. package/dist/schema/call/personal.js +1 -78
  326. package/dist/schema/call/progress.js +1 -47
  327. package/dist/schema/call/proof.js +1 -33
  328. package/dist/schema/call/repository.js +1 -77
  329. package/dist/schema/call/reward.js +1 -30
  330. package/dist/schema/call/semantic.js +1 -1657
  331. package/dist/schema/call/service.js +1 -178
  332. package/dist/schema/call/treasury.js +1 -71
  333. package/dist/schema/common/index.js +1 -407
  334. package/dist/schema/config/index.js +1 -68
  335. package/dist/schema/evaluation/index.d.ts +4436 -0
  336. package/dist/schema/evaluation/index.js +1 -0
  337. package/dist/schema/index.d.ts +4 -0
  338. package/dist/schema/index.js +1 -13
  339. package/dist/schema/intent-radar/index.d.ts +284 -0
  340. package/dist/schema/intent-radar/index.js +1 -0
  341. package/dist/schema/local/index.d.ts +21 -21
  342. package/dist/schema/local/index.js +1 -927
  343. package/dist/schema/local/wip.js +1 -187
  344. package/dist/schema/messenger/index.d.ts +7 -7
  345. package/dist/schema/messenger/index.js +1 -475
  346. package/dist/schema/operations.d.ts +7 -7
  347. package/dist/schema/operations.js +1 -520
  348. package/dist/schema/persona/index.d.ts +1985 -0
  349. package/dist/schema/persona/index.js +1 -0
  350. package/dist/schema/project/index.d.ts +96 -50
  351. package/dist/schema/project/index.js +1 -2057
  352. package/dist/schema/query/index.d.ts +423 -7
  353. package/dist/schema/query/index.js +1 -1640
  354. package/dist/schema/schema-query/index.js +1 -104
  355. package/dist/schema/schema-version.js +1 -76
  356. package/dist/schema/sync-layer4.d.ts +1 -1
  357. package/dist/schema/sync-layer4.js +1 -282
  358. package/dist/schema/task-status.d.ts +168 -0
  359. package/dist/schema/task-status.js +1 -0
  360. package/dist/schema/trust/index.js +1 -314
  361. package/dist/schema/utils/guard-parser.js +1 -419
  362. package/dist/schema/utils/guard-query-utils.js +1 -46
  363. package/dist/schema/utils/node-parser.js +1 -369
  364. package/dist/schema/utils/object-type-utils.js +1 -35
  365. package/dist/schema/utils/permission-index-utils.js +1 -7
  366. package/dist/schema/utils/permission-machine-check.js +1 -121
  367. package/dist/schema/utils/skills-recommendation.js +1 -77
  368. package/dist/schema-query/index.js +1 -810
  369. package/dist/schemas/account_operation.output.json +5 -2
  370. package/dist/schemas/bridge_operation.output.json +5 -2
  371. package/dist/schemas/evaluation_operation.output.json +782 -0
  372. package/dist/schemas/evaluation_operation.schema.json +990 -0
  373. package/dist/schemas/index.json +25 -1
  374. package/dist/schemas/intent_radar.output.json +232 -0
  375. package/dist/schemas/intent_radar.schema.json +138 -0
  376. package/dist/schemas/local_info_operation.output.json +5 -2
  377. package/dist/schemas/local_mark_operation.output.json +5 -2
  378. package/dist/schemas/messenger_operation.output.json +5 -2
  379. package/dist/schemas/onchain_events.output.json +5 -2
  380. package/dist/schemas/onchain_operations.output.json +5 -2
  381. package/dist/schemas/onchain_operations.schema.json +6 -6
  382. package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
  383. package/dist/schemas/onchain_operations_machine.schema.json +2 -2
  384. package/dist/schemas/onchain_operations_service.schema.json +3 -3
  385. package/dist/schemas/onchain_table_data.output.json +6 -3
  386. package/dist/schemas/persona_operation.output.json +392 -0
  387. package/dist/schemas/persona_operation.schema.json +250 -0
  388. package/dist/schemas/project_operation.output.json +28 -8
  389. package/dist/schemas/query_task_status.output.json +115 -0
  390. package/dist/schemas/query_task_status.schema.json +24 -0
  391. package/dist/schemas/query_toolkit.output.json +9 -6
  392. package/dist/schemas/trust_score.schema.json +1 -1
  393. package/dist/schemas/wowok_buildin_info.output.json +132 -0
  394. package/dist/schemas/wowok_buildin_info.schema.json +14 -0
  395. package/dist/telemetry/index.js +1 -112
  396. package/dist/telemetry/redact.js +1 -23
  397. package/dist/telemetry/storage.js +1 -80
  398. package/dist/tools/handlers/bridge.js +1 -1
  399. package/dist/tools/handlers/config.js +1 -74
  400. package/dist/tools/handlers/evaluation.d.ts +2 -0
  401. package/dist/tools/handlers/evaluation.js +1 -0
  402. package/dist/tools/handlers/file-export.js +1 -90
  403. package/dist/tools/handlers/intent-radar.d.ts +2 -0
  404. package/dist/tools/handlers/intent-radar.js +1 -0
  405. package/dist/tools/handlers/local.js +1 -53
  406. package/dist/tools/handlers/messenger.js +1 -188
  407. package/dist/tools/handlers/onchain.js +1 -1082
  408. package/dist/tools/handlers/persona.d.ts +4 -0
  409. package/dist/tools/handlers/persona.js +1 -0
  410. package/dist/tools/handlers/project.js +1 -211
  411. package/dist/tools/handlers/query.js +1 -434
  412. package/dist/tools/handlers/schema-query.js +1 -176
  413. package/dist/tools/handlers/task-status.d.ts +0 -168
  414. package/dist/tools/handlers/task-status.js +1 -55
  415. package/dist/tools/handlers/trust.js +1 -380
  416. package/dist/tools/handlers/wip.js +1 -90
  417. package/dist/tools/index.js +1 -1306
  418. package/dist/tools/retry.js +1 -85
  419. package/dist/tools/rules-hook.js +1 -23
  420. package/dist/tools/shared.js +1 -130
  421. package/dist/tools/types.js +1 -1
  422. package/dist/tools/upgrade-check.d.ts +19 -0
  423. package/dist/tools/upgrade-check.js +1 -0
  424. package/dist/tools/wip-deploy-assist.d.ts +1 -1
  425. package/dist/tools/wip-deploy-assist.js +1 -278
  426. package/dist/tools/wrap.js +1 -500
  427. package/package.json +5 -3
@@ -1,653 +1 @@
1
- import { MAX_AGENT_COUNT, MAX_DISPUTE_COUNT, } from "@wowok/wowok";
2
- import { findSceneById, } from "./order-ledger.js";
3
- const R_O_1_01 = {
4
- id: "R-O-1-01",
5
- category: "structural",
6
- trigger: "Order has 14 fields but no Permission field (unique among 22 objects)",
7
- check: (ctx) => {
8
- if (ctx.is_buy_operation) {
9
- return {
10
- id: "R-O-1-01",
11
- level: "LOW",
12
- category: "structural",
13
- title: "Order uses owner/agent dual-layer (no Permission)",
14
- description: "Order is the only business object among 22 WoWok objects that does NOT use the Permission system. All access control flows through assert_owner and has_op_permission inline functions.",
15
- affected_stakeholders: ["system", "owner", "agent"],
16
- scenario: "Developer assumes Order uses Permission and writes permission::check logic",
17
- mitigation: "Use owner/agent checks directly. Do NOT attempt to apply a Permission object to Order.",
18
- evidence: "no_permission_field",
19
- };
20
- }
21
- return null;
22
- },
23
- };
24
- const R_O_1_02 = {
25
- id: "R-O-1-02",
26
- category: "structural",
27
- trigger: "Item count check (informational; no Move-level limit on items)",
28
- check: (ctx) => {
29
- if (!ctx.items || ctx.items.length === 0)
30
- return null;
31
- if (ctx.items.length > 50) {
32
- return {
33
- id: "R-O-1-02",
34
- level: "LOW",
35
- category: "structural",
36
- title: "Large items list may exceed tx size limits",
37
- description: `${ctx.items.length} items in a single Order — no protocol limit, but large lists increase transaction size and may hit gas/size limits`,
38
- affected_stakeholders: ["owner"],
39
- scenario: "Bulk purchase with many line items",
40
- mitigation: "Split into multiple Orders if items > 50",
41
- evidence: `items_count=${ctx.items.length}`,
42
- };
43
- }
44
- return null;
45
- },
46
- };
47
- const R_O_1_03 = {
48
- id: "R-O-1-03",
49
- category: "structural",
50
- trigger: "dispute count >= MAX_DISPUTE_COUNT (10)",
51
- check: (ctx) => {
52
- const count = ctx.current_dispute_count ?? 0;
53
- if (count >= MAX_DISPUTE_COUNT) {
54
- return {
55
- id: "R-O-1-03",
56
- level: "HIGH",
57
- category: "structural",
58
- title: "Dispute count at MAX_DISPUTE_COUNT limit",
59
- description: `Order already has ${count} disputes (MAX_DISPUTE_COUNT=${MAX_DISPUTE_COUNT}). Next dispute() call will abort E_DISPUTE_COUNT_EXCEEDED.`,
60
- affected_stakeholders: ["owner", "agent", "arbitrator"],
61
- scenario: "Filing 11th dispute on an Order with 10 existing disputes",
62
- mitigation: "Resolve existing disputes (via arb_claim_compensation) before filing new ones. Note: claimed_by blocks ALL future disputes.",
63
- evidence: `dispute_count=${count}`,
64
- };
65
- }
66
- return null;
67
- },
68
- };
69
- const R_O_1_04 = {
70
- id: "R-O-1-04",
71
- category: "structural",
72
- trigger: "agent count > MAX_AGENT_COUNT (doc=10, actual allows 11 due to <= bug)",
73
- check: (ctx) => {
74
- if (!ctx.agent_set)
75
- return null;
76
- const count = ctx.agent_set.agents.length;
77
- if (count > MAX_AGENT_COUNT) {
78
- return {
79
- id: "R-O-1-04",
80
- level: "HIGH",
81
- category: "structural",
82
- title: "Agent count exceeds documented MAX_AGENT_COUNT (boundary bug)",
83
- description: `Attempting to set ${count} agents. Doc says MAX_AGENT_COUNT=${MAX_AGENT_COUNT}, but Move agent_set_imp uses <= instead of <, actually allowing 11. SDK constant = ${MAX_AGENT_COUNT} does not match chain behavior.`,
84
- affected_stakeholders: ["owner", "system"],
85
- scenario: "Setting 11 agents — succeeds on chain but contradicts SDK/docs",
86
- mitigation: "Treat 10 as the soft cap (matching docs). If 11 is intentional, document the boundary bug explicitly. Long-term: fix Move to use < and sync SDK.",
87
- evidence: `agent_count=${count}, max_doc=${MAX_AGENT_COUNT}, max_actual=11`,
88
- };
89
- }
90
- return null;
91
- },
92
- };
93
- const R_O_1_05 = {
94
- id: "R-O-1-05",
95
- category: "structural",
96
- trigger: "wip_hash is empty string in any item",
97
- check: (ctx) => {
98
- if (!ctx.items)
99
- return null;
100
- const emptyHashItem = ctx.items.find(i => !i.wip_hash || i.wip_hash === "");
101
- if (emptyHashItem) {
102
- return {
103
- id: "R-O-1-05",
104
- level: "HIGH",
105
- category: "structural",
106
- title: "Empty wip_hash in item",
107
- description: `Item "${emptyHashItem.name}" has empty wip_hash. Move rejects empty strings (F-O-18).`,
108
- affected_stakeholders: ["owner"],
109
- scenario: "User submits item without computing WIP hash",
110
- mitigation: "Compute wip_hash from the work-in-progress file content before service::buy().",
111
- evidence: `item_name=${emptyHashItem.name}`,
112
- };
113
- }
114
- return null;
115
- },
116
- };
117
- const R_O_2_01 = {
118
- id: "R-O-2-01",
119
- category: "semantic",
120
- trigger: "Order.machine snapshot differs from current Service.machine",
121
- check: (ctx) => {
122
- if (!ctx.current_service_machine || !ctx.order_machine_snapshot)
123
- return null;
124
- if (ctx.current_service_machine !== ctx.order_machine_snapshot) {
125
- return {
126
- id: "R-O-2-01",
127
- level: "HIGH",
128
- category: "semantic",
129
- title: "Machine snapshot diverges from Service.machine",
130
- description: `Order.machine=${ctx.order_machine_snapshot} was snapshotted at buy time. Service.machine is now ${ctx.current_service_machine}. Same Service has Orders running different Machine versions.`,
131
- affected_stakeholders: ["owner", "service_provider", "arbitrator"],
132
- scenario: "Service provider upgrades Machine after some Orders are created",
133
- mitigation: "Audit each Order's machine snapshot separately. Document Machine version per Order. Plan migration paths for legacy Orders.",
134
- evidence: `order_machine=${ctx.order_machine_snapshot}, service_machine=${ctx.current_service_machine}`,
135
- };
136
- }
137
- return null;
138
- },
139
- };
140
- const R_O_2_02 = {
141
- id: "R-O-2-02",
142
- category: "semantic",
143
- trigger: "SDK uses 'builder' field for Move's 'owner' field (naming deviation)",
144
- check: (ctx) => {
145
- if (ctx.object) {
146
- return {
147
- id: "R-O-2-02",
148
- level: "MEDIUM",
149
- category: "semantic",
150
- title: "SDK builder ≠ Move owner (only naming deviation in 22 objects)",
151
- description: "SDK ObjectOrder.builder corresponds to Move Order.owner. This is the only field name deviation across all 22 WoWok objects. All Order knowledge uses Move's 'owner' as canonical.",
152
- affected_stakeholders: ["system"],
153
- scenario: "Developer reads SDK 'builder' and assumes it's a different concept from owner",
154
- mitigation: "Use moveToSdkField()/sdkToMoveField() helpers from order-ledger.ts. Document 'builder = owner' in all SDK consumers.",
155
- evidence: "sdk_field=builder, move_field=owner",
156
- };
157
- }
158
- return null;
159
- },
160
- };
161
- const R_O_2_03 = {
162
- id: "R-O-2-03",
163
- category: "semantic",
164
- trigger: "owner_change or agent_set aborted with E_PROGRESS_NOT_SPECIFIED (dual semantics)",
165
- check: (ctx) => {
166
- if (!ctx.operation)
167
- return null;
168
- if ((ctx.operation === "agent_set") && ctx.progress_bound) {
169
- return {
170
- id: "R-O-2-03",
171
- level: "MEDIUM",
172
- category: "semantic",
173
- title: "E_PROGRESS_NOT_SPECIFIED dual semantics (literal vs actual)",
174
- description: "agent_set aborted because progress.is_some() — but error code says 'PROGRESS_NOT_SPECIFIED'. The code is used in two OPPOSITE scenarios: (A) progress.is_none() during on_progress (literal), (B) progress.is_some() during owner_change/agent_set (opposite).",
175
- affected_stakeholders: ["owner", "agent"],
176
- scenario: "User sees 'Progress not specified' error when Progress IS specified — confusion",
177
- mitigation: "Translate error to: 'Cannot modify owner/agent: Progress already bound (frozen).' Long-term: split into two error codes (E_PROGRESS_ALREADY_BOUND and E_PROGRESS_NOT_SPECIFIED).",
178
- evidence: `operation=${ctx.operation}, progress_bound=${ctx.progress_bound}`,
179
- };
180
- }
181
- return null;
182
- },
183
- };
184
- const R_O_2_04 = {
185
- id: "R-O-2-04",
186
- category: "semantic",
187
- trigger: "SaleItem.item → PurchasedItem.name field name mapping",
188
- check: (ctx) => {
189
- if (ctx.is_buy_operation) {
190
- return {
191
- id: "R-O-2-04",
192
- level: "LOW",
193
- category: "semantic",
194
- title: "SaleItem.item (Move) maps to PurchasedItem.name (SDK)",
195
- description: "Move struct SaleItem uses field 'item', but SDK ObjectOrder.items uses field 'name'. This is the second naming deviation in Order system (after builder/owner).",
196
- affected_stakeholders: ["system"],
197
- scenario: "Cross-layer data mapping between Move and SDK",
198
- mitigation: "Use consistent SDK field names in user-facing code; document Move ↔ SDK mapping in audit logs.",
199
- evidence: "move_field=SaleItem.item, sdk_field=PurchasedItem.name",
200
- };
201
- }
202
- return null;
203
- },
204
- };
205
- const R_O_3_01 = {
206
- id: "R-O-3-01",
207
- category: "authority",
208
- trigger: "Agent attempts receive or transfer_to (L1 owner-only operations)",
209
- check: (ctx) => {
210
- if (!ctx.operation)
211
- return null;
212
- if ((ctx.operation === "receive" || ctx.operation === "transfer_to") &&
213
- ctx.caller_is_agent && !ctx.caller_is_owner) {
214
- return {
215
- id: "R-O-3-01",
216
- level: "HIGH",
217
- category: "authority",
218
- title: "Agent attempting owner-only operation",
219
- description: `Agent cannot call ${ctx.operation} — these are L1 owner-only operations (assert_owner). Agent can operate progress/arb_*/required_info but CANNOT receive funds or transfer ownership.`,
220
- affected_stakeholders: ["agent", "owner"],
221
- scenario: "Logistics agent tries to collect payment on behalf of buyer",
222
- mitigation: "Owner must call receive/transfer_to directly. If delegation is needed, owner can transfer_to a multi-sig wallet that includes the agent.",
223
- evidence: `operation=${ctx.operation}, caller=agent`,
224
- };
225
- }
226
- return null;
227
- },
228
- };
229
- const R_O_3_02 = {
230
- id: "R-O-3-02",
231
- category: "authority",
232
- trigger: "Non-owner non-agent attempts operation (no permission)",
233
- check: (ctx) => {
234
- if (!ctx.operation)
235
- return null;
236
- if (ctx.caller_is_owner === false && ctx.caller_is_agent === false) {
237
- return {
238
- id: "R-O-3-02",
239
- level: "HIGH",
240
- category: "authority",
241
- title: "Non-owner non-agent attempting operation",
242
- description: `Caller is neither owner nor agent. All Order operations require at least has_op_permission (L2 layer). Aborts E_PERMISSION.`,
243
- affected_stakeholders: ["system"],
244
- scenario: "Random address attempts to advance someone else's Order",
245
- mitigation: "Verify caller is owner or in agent[] before submitting transaction.",
246
- evidence: `operation=${ctx.operation}, caller=unauthorized`,
247
- };
248
- }
249
- return null;
250
- },
251
- };
252
- const R_O_3_03 = {
253
- id: "R-O-3-03",
254
- category: "authority",
255
- trigger: "arb_claim_compensation called (sets claimed_by, irreversible)",
256
- check: (ctx) => {
257
- if (ctx.operation !== "arb_claim_compensation")
258
- return null;
259
- return {
260
- id: "R-O-3-03",
261
- level: "HIGH",
262
- category: "authority",
263
- title: "arb_claim_compensation is IRREVERSIBLE (claimed_by one-time set)",
264
- description: "Setting claimed_by is permanent. After this call: (1) claimed_by cannot be reset, (2) NO new disputes can be filed (E_ORDER_ALREADY_CLAIMED), (3) all unresolved disputes become unactionable. If first compensation is insufficient, buyer has no recourse.",
265
- affected_stakeholders: ["owner", "agent", "arbitrator"],
266
- scenario: "Buyer claims partial compensation, then discovers additional damages",
267
- mitigation: "BEFORE claiming: (1) enumerate ALL disputes, (2) ensure proposition covers all damages, (3) confirm Arb ruling is final. Add explicit user confirmation (C-O-08).",
268
- evidence: `operation=arb_claim_compensation, current_claimed_by=${ctx.claimed_by_set ?? false}`,
269
- };
270
- },
271
- };
272
- const R_O_3_04 = {
273
- id: "R-O-3-04",
274
- category: "authority",
275
- trigger: "dispute attempted after claimed_by is set",
276
- check: (ctx) => {
277
- if (ctx.claimed_by_set && (ctx.operation === "arb_confirm" || ctx.operation === "arb_objection")) {
278
- return {
279
- id: "R-O-3-04",
280
- level: "HIGH",
281
- category: "authority",
282
- title: "Cannot file new dispute after claimed_by is set",
283
- description: "Order.claimed_by is set — any new dispute() call aborts E_ORDER_ALREADY_CLAIMED. arb_confirm/arb_objection trigger dispute() internally.",
284
- affected_stakeholders: ["owner", "agent"],
285
- scenario: "Buyer claims compensation then tries to file additional dispute",
286
- mitigation: "Resolve ALL disputes BEFORE calling arb_claim_compensation. claimed_by is terminal for dispute flow.",
287
- evidence: `operation=${ctx.operation}, claimed_by_set=true`,
288
- };
289
- }
290
- return null;
291
- },
292
- };
293
- const R_O_4_01 = {
294
- id: "R-O-4-01",
295
- category: "lifecycle",
296
- trigger: "Attempt to create Order independently (not via service::buy)",
297
- check: (ctx) => {
298
- if (ctx.is_buy_operation === false && ctx.operation === "service_buy" && !ctx.object) {
299
- return {
300
- id: "R-O-4-01",
301
- level: "CRITICAL",
302
- category: "lifecycle",
303
- title: "Order cannot be created independently (compound creation only)",
304
- description: "order::new() is package-only — only service::buy() can create Orders. Any attempt to call order::new directly will fail at the Move module boundary. Order + Allocation + Progress are created atomically in one transaction.",
305
- affected_stakeholders: ["system", "owner"],
306
- scenario: "Developer tries to construct Order independently for testing",
307
- mitigation: "Always use service::buy() to create Orders. For testing, deploy a minimal Service with machine/allocators configured.",
308
- evidence: "independent_creation_attempted",
309
- };
310
- }
311
- return null;
312
- },
313
- };
314
- const R_O_4_02 = {
315
- id: "R-O-4-02",
316
- category: "lifecycle",
317
- trigger: "agent_set or owner_change attempted after Progress binding",
318
- check: (ctx) => {
319
- if (!ctx.operation)
320
- return null;
321
- if ((ctx.operation === "agent_set") && ctx.progress_bound) {
322
- return {
323
- id: "R-O-4-02",
324
- level: "HIGH",
325
- category: "lifecycle",
326
- title: "agent_set blocked — Progress binding frozen owner/agent",
327
- description: "Once order.progress is set (during service::buy if Service has machine), agent_set and owner_change abort E_PROGRESS_NOT_SPECIFIED. Owner/agent must be finalized BEFORE buy.",
328
- affected_stakeholders: ["owner", "agent"],
329
- scenario: "Buyer wants to add agent mid-fulfillment after Progress is bound",
330
- mitigation: "Set agent list BEFORE service::buy (via pre-buy configuration). If post-buy agent change is needed, use transfer_to a new owner who has the desired agents.",
331
- evidence: `operation=agent_set, progress_bound=${ctx.progress_bound}`,
332
- };
333
- }
334
- return null;
335
- },
336
- };
337
- const R_O_4_03 = {
338
- id: "R-O-4-03",
339
- category: "lifecycle",
340
- trigger: "Progress advance attempted without progress bound",
341
- check: (ctx) => {
342
- if (ctx.operation === "progress_advance" && ctx.progress_bound === false) {
343
- return {
344
- id: "R-O-4-03",
345
- level: "HIGH",
346
- category: "lifecycle",
347
- title: "Cannot advance Progress — no Progress bound to Order",
348
- description: "Order has no progress field set (Service had no machine configured). Cannot advance a non-existent Progress. SDK CallOrder validates this pre-flight (CallOrder_Data.progress requires order.machine and order.progress).",
349
- affected_stakeholders: ["owner", "agent"],
350
- scenario: "Buyer tries to advance Progress on an Order created from a Service without machine",
351
- mitigation: "Use a Service with machine configured. If manual lifecycle is needed, track state off-chain.",
352
- evidence: `operation=progress_advance, progress_bound=false`,
353
- };
354
- }
355
- return null;
356
- },
357
- };
358
- const R_O_4_04 = {
359
- id: "R-O-4-04",
360
- category: "lifecycle",
361
- trigger: "arb_confirm/arb_objection/arb_claim_compensation (irreversible Arb operations)",
362
- check: (ctx) => {
363
- if (!ctx.operation)
364
- return null;
365
- if (ctx.operation === "arb_confirm" || ctx.operation === "arb_objection" || ctx.operation === "arb_claim_compensation") {
366
- return {
367
- id: "R-O-4-04",
368
- level: "HIGH",
369
- category: "lifecycle",
370
- title: `${ctx.operation} is irreversible (triggers Arb flow)`,
371
- description: `${ctx.operation} triggers the Arbitration workflow which cannot be undone. arb_confirm files a new dispute, arb_objection requests re-arbitration, arb_claim_compensation sets claimed_by permanently.`,
372
- affected_stakeholders: ["owner", "agent", "arbitrator"],
373
- scenario: "User accidentally files arb_confirm without understanding consequences",
374
- mitigation: "Add explicit user confirmation (C-O-08, C-O-11, C-O-12) before these operations. Show warning text describing irreversibility.",
375
- evidence: `operation=${ctx.operation}`,
376
- };
377
- }
378
- return null;
379
- },
380
- };
381
- const R_O_4_05 = {
382
- id: "R-O-4-05",
383
- category: "lifecycle",
384
- trigger: "receive attempted while Progress not at terminal node",
385
- check: (ctx) => {
386
- if (ctx.operation === "receive" && ctx.progress_bound && !ctx.progress_at_terminal) {
387
- return {
388
- id: "R-O-4-05",
389
- level: "HIGH",
390
- category: "lifecycle",
391
- title: "receive blocked — Order still delivering (E_ORDER_DELIVERING)",
392
- description: "owner_receive aborts E_ORDER_DELIVERING when Progress has not reached a terminal node. Funds cannot be collected until fulfillment completes.",
393
- affected_stakeholders: ["owner"],
394
- scenario: "Buyer tries to collect refund before Progress reaches 'completed' or 'cancelled'",
395
- mitigation: "Wait for Progress to reach terminal/cancel node. If urgent, file arb_confirm to dispute.",
396
- evidence: `operation=receive, progress_at_terminal=${ctx.progress_at_terminal}`,
397
- };
398
- }
399
- return null;
400
- },
401
- };
402
- const R_O_4_06 = {
403
- id: "R-O-4-06",
404
- category: "lifecycle",
405
- trigger: "transfer_to attempted (irreversible ownership transfer)",
406
- check: (ctx) => {
407
- if (ctx.operation !== "transfer_to")
408
- return null;
409
- return {
410
- id: "R-O-4-06",
411
- level: "CRITICAL",
412
- category: "lifecycle",
413
- title: "transfer_to is IRREVERSIBLE — new owner takes over ALL permissions",
414
- description: `Ownership transfer to ${ctx.transfer_to_new_owner ?? "(unknown)"} is permanent. New owner becomes the sole receiver of payments and gains full L1 control. Original owner loses ALL access.`,
415
- affected_stakeholders: ["owner"],
416
- scenario: "Buyer transfers Order to wrong address by mistake",
417
- mitigation: "1) Verify new owner address twice. 2) Coordinate with new owner before transfer. 3) Add explicit user confirmation (C-O-09). Note: transfer_to is NOT blocked by progress binding (unlike agent_set).",
418
- evidence: `new_owner=${ctx.transfer_to_new_owner}`,
419
- };
420
- },
421
- };
422
- const R_O_5_01 = {
423
- id: "R-O-5-01",
424
- category: "cross_object",
425
- trigger: "Service.machine upgraded after Order creation (snapshot divergence)",
426
- check: (ctx) => {
427
- if (ctx.is_buy_operation) {
428
- return {
429
- id: "R-O-5-01",
430
- level: "LOW",
431
- category: "cross_object",
432
- title: "Service snapshot mechanism — order.machine is a copy, not a reference",
433
- description: "When service::buy() creates an Order, order.machine is COPIED from service.machine. Future Service.machine upgrades do NOT affect this Order. Same Service may have Orders running different Machine versions.",
434
- affected_stakeholders: ["owner", "service_provider", "arbitrator"],
435
- scenario: "Service provider upgrades Machine workflow — old Orders keep old workflow",
436
- mitigation: "Track Machine version per Order (via order.machine address). Plan migration paths for legacy Orders. Document that old Orders are decoupled.",
437
- evidence: "snapshot_mechanism",
438
- };
439
- }
440
- return null;
441
- },
442
- };
443
- const R_O_5_02 = {
444
- id: "R-O-5-02",
445
- category: "cross_object",
446
- trigger: "Order references Progress that no longer exists or is corrupted",
447
- check: (ctx) => {
448
- if (ctx.progress_bound && ctx.object) {
449
- return {
450
- id: "R-O-5-02",
451
- level: "MEDIUM",
452
- category: "cross_object",
453
- title: "Order-Progress 1:1 binding (E_PROGRESS_ALREADY_SPECIFIED)",
454
- description: "Order.progress is one-time-set via on_progress (package-only). Cannot be rebound. If Progress object is corrupted, Order becomes stuck — cannot advance, cannot rebind.",
455
- affected_stakeholders: ["owner", "agent"],
456
- scenario: "Progress object becomes unresponsive or corrupted",
457
- mitigation: "Ensure Progress integrity via Machine audit before publishing Service. Use arb_claim_compensation as escape hatch if Progress is stuck.",
458
- evidence: `progress_bound=${ctx.progress_bound}`,
459
- };
460
- }
461
- return null;
462
- },
463
- };
464
- const R_O_5_03 = {
465
- id: "R-O-5-03",
466
- category: "cross_object",
467
- trigger: "Order references Allocation that no longer exists or is corrupted",
468
- check: (ctx) => {
469
- if (ctx.object && ctx.progress_bound) {
470
- return {
471
- id: "R-O-5-03",
472
- level: "MEDIUM",
473
- category: "cross_object",
474
- title: "Order-Allocation 1:1 binding (E_ALLOCATION_ALREADY_SPECIFIED)",
475
- description: "Order.allocation is one-time-set via on_allocation (package-only). Cannot be rebound. If Allocation object is corrupted, fund distribution is blocked.",
476
- affected_stakeholders: ["owner", "service_provider"],
477
- scenario: "Allocation object has wrong allocator configuration",
478
- mitigation: "Audit order_allocators configuration on Service BEFORE publishing. Use compensation_fund as fallback fund source.",
479
- evidence: "allocation_binding",
480
- };
481
- }
482
- return null;
483
- },
484
- };
485
- const R_O_5_04 = {
486
- id: "R-O-5-04",
487
- category: "cross_object",
488
- trigger: "Arbitration dispute appended to Order.dispute list",
489
- check: (ctx) => {
490
- if (ctx.operation === "arb_confirm") {
491
- return {
492
- id: "R-O-5-04",
493
- level: "LOW",
494
- category: "cross_object",
495
- title: "Arb object will be appended to order.dispute (package-only dispute())",
496
- description: "arb_confirm triggers Arb module to call order::dispute(arb_address), appending the Arb object to order.dispute list. Max 10 disputes (MAX_DISPUTE_COUNT). Frozen when claimed_by is set.",
497
- affected_stakeholders: ["arbitrator", "owner", "agent"],
498
- scenario: "Multiple arb_confirm calls create multiple Arb objects on same Order",
499
- mitigation: "Track dispute count. Once at 10, no more disputes can be filed. Resolve existing disputes before filing new ones.",
500
- evidence: `operation=arb_confirm, current_disputes=${ctx.current_dispute_count ?? 0}`,
501
- };
502
- }
503
- return null;
504
- },
505
- };
506
- const R_O_5_05 = {
507
- id: "R-O-5-05",
508
- category: "cross_object",
509
- trigger: "External system expects OrderCompletedEvent (does not exist)",
510
- check: (ctx) => {
511
- if (ctx.is_buy_operation || ctx.object) {
512
- return {
513
- id: "R-O-5-05",
514
- level: "MEDIUM",
515
- category: "cross_object",
516
- title: "Only NewOrderEvent emitted — no OrderCompletedEvent",
517
- description: "Move contract ONLY emits NewOrderEvent at creation. Order completion/cancellation/refund are IMPLICIT — must be inferred by querying Progress.current_node (terminal? cancel?) or Order.claimed_by. External monitoring requires polling, not event-driven.",
518
- affected_stakeholders: ["system"],
519
- scenario: "Analytics dashboard expects OrderCompletedEvent to track completion rate",
520
- mitigation: "Build composite query: NewOrderEvent + Order.progress query → infer completion. Document this limitation in monitoring tools. Long-term: advocate for Move upgrade to add OrderCompletedEvent.",
521
- evidence: "no_order_completed_event",
522
- };
523
- }
524
- return null;
525
- },
526
- };
527
- const R_O_5_06 = {
528
- id: "R-O-5-06",
529
- category: "cross_object",
530
- trigger: "service::buy pre-flight: Service not published or paused",
531
- check: (ctx) => {
532
- if (!ctx.is_buy_operation)
533
- return null;
534
- if (ctx.service_published === false) {
535
- return {
536
- id: "R-O-5-06",
537
- level: "CRITICAL",
538
- category: "cross_object",
539
- title: "Service not published — service::buy will abort E_NOT_PUBLISHED",
540
- description: "Cannot create Order from an unpublished Service. Service must be published (bPublished=true) before service::buy() can be called.",
541
- affected_stakeholders: ["owner"],
542
- scenario: "Buyer attempts to purchase from a draft Service",
543
- mitigation: "Verify Service.bPublished=true before service::buy(). Service owner must call service::publish() first.",
544
- evidence: `service_published=${ctx.service_published}`,
545
- };
546
- }
547
- if (ctx.service_paused === true) {
548
- return {
549
- id: "R-O-5-06",
550
- level: "CRITICAL",
551
- category: "cross_object",
552
- title: "Service paused — service::buy will abort E_PAUSED",
553
- description: "Cannot create Order from a paused Service. Service must be unpaused before service::buy() can be called.",
554
- affected_stakeholders: ["owner"],
555
- scenario: "Buyer attempts to purchase from a paused Service (e.g. during maintenance)",
556
- mitigation: "Wait for Service owner to call service::pause(false). Check Service.paused before service::buy().",
557
- evidence: `service_paused=${ctx.service_paused}`,
558
- };
559
- }
560
- return null;
561
- },
562
- };
563
- const ALL_RULES = [
564
- R_O_1_01, R_O_1_02, R_O_1_03, R_O_1_04, R_O_1_05,
565
- R_O_2_01, R_O_2_02, R_O_2_03, R_O_2_04,
566
- R_O_3_01, R_O_3_02, R_O_3_03, R_O_3_04,
567
- R_O_4_01, R_O_4_02, R_O_4_03, R_O_4_04, R_O_4_05, R_O_4_06,
568
- R_O_5_01, R_O_5_02, R_O_5_03, R_O_5_04, R_O_5_05, R_O_5_06,
569
- ];
570
- export const ORDER_RISK_VERSION = "1.0.0";
571
- export function getAllOrderRiskRules() {
572
- return [...ALL_RULES];
573
- }
574
- export function getOrderRiskRulesCount() {
575
- return ALL_RULES.length;
576
- }
577
- export function getOrderRiskRulesByCategory(category) {
578
- return ALL_RULES.filter(r => r.category === category);
579
- }
580
- export function getOrderRiskRuleById(id) {
581
- return ALL_RULES.find(r => r.id === id);
582
- }
583
- export function assessOrderRisks(ctx) {
584
- const risks = [];
585
- for (const rule of ALL_RULES) {
586
- const r = rule.check(ctx);
587
- if (r)
588
- risks.push(r);
589
- }
590
- const overall = risks.length === 0
591
- ? "LOW"
592
- : risks.some(r => r.level === "CRITICAL") ? "CRITICAL"
593
- : risks.some(r => r.level === "HIGH") ? "HIGH"
594
- : risks.some(r => r.level === "MEDIUM") ? "MEDIUM"
595
- : "LOW";
596
- const byCategory = {};
597
- for (const r of risks) {
598
- byCategory[r.category] = (byCategory[r.category] ?? 0) + 1;
599
- }
600
- const advice = {};
601
- for (const r of risks) {
602
- for (const s of r.affected_stakeholders) {
603
- if (!advice[s])
604
- advice[s] = [];
605
- advice[s].push(`${r.id}: ${r.mitigation}`);
606
- }
607
- }
608
- let scene;
609
- if (ctx.operation) {
610
- const sceneMap = {
611
- agent_set: "order_set_agent",
612
- required_info_update: "order_required_info",
613
- progress_advance: "order_advance",
614
- arb_confirm: "order_arb_confirm",
615
- arb_objection: "order_arb_objection",
616
- arb_claim_compensation: "order_arb_claim_compensation",
617
- receive: "order_receive",
618
- transfer_to: "order_transfer",
619
- service_buy: "order_create",
620
- };
621
- scene = findSceneById(sceneMap[ctx.operation] ?? "");
622
- }
623
- return {
624
- summary: `Assessed ${risks.length} risk(s) across ${Object.keys(byCategory).length} categories`,
625
- scene,
626
- risks,
627
- overall_risk: overall,
628
- risks_by_category: byCategory,
629
- stakeholder_advice: advice,
630
- needs_human_review: risks.some(r => r.level === "CRITICAL" || r.level === "HIGH"),
631
- };
632
- }
633
- export function checkPermissionLayer(operation, caller_is_owner, caller_is_agent) {
634
- const l1_ops = ["receive", "transfer_to", "owner_change", "agent_set"];
635
- const l2_ops = ["required_info_update", "progress_advance", "arb_confirm", "arb_objection", "arb_claim_compensation"];
636
- const l3_ops = ["on_progress", "on_allocation", "dispute", "compensate"];
637
- if (l3_ops.includes(operation)) {
638
- return { allowed: false, layer: "L3_package_only", reason: "Package-only — not callable externally" };
639
- }
640
- if (l1_ops.includes(operation)) {
641
- if (!caller_is_owner) {
642
- return { allowed: false, layer: "L1_owner_only", reason: `Owner-only operation (${operation}) — agent or unauthorized caller` };
643
- }
644
- return { allowed: true, layer: "L1_owner_only" };
645
- }
646
- if (l2_ops.includes(operation)) {
647
- if (!caller_is_owner && !caller_is_agent) {
648
- return { allowed: false, layer: "L2_owner_or_agent", reason: `Requires owner or agent permission (${operation})` };
649
- }
650
- return { allowed: true, layer: "L2_owner_or_agent" };
651
- }
652
- return { allowed: false, layer: "L3_package_only", reason: `Unknown operation: ${operation}` };
653
- }
1
+ import{MAX_AGENT_COUNT,MAX_DISPUTE_COUNT}from'@wowok/wowok';import{findSceneById}from'./order-ledger.js';const R_O_1_01={'id':'R-O-1-01','category':'structural','trigger':'Order\x20has\x2014\x20fields\x20but\x20no\x20Permission\x20field\x20(unique\x20among\x2022\x20objects)','check':a=>{if(a['is_buy_operation'])return{'id':'R-O-1-01','level':'LOW','category':'structural','title':'Order\x20uses\x20owner/agent\x20dual-layer\x20(no\x20Permission)','description':'Order\x20is\x20the\x20only\x20business\x20object\x20among\x2022\x20WoWok\x20objects\x20that\x20does\x20NOT\x20use\x20the\x20Permission\x20system.\x20All\x20access\x20control\x20flows\x20through\x20assert_owner\x20and\x20has_op_permission\x20inline\x20functions.','affected_stakeholders':['system','owner','agent'],'scenario':'Developer\x20assumes\x20Order\x20uses\x20Permission\x20and\x20writes\x20permission::check\x20logic','mitigation':'Use\x20owner/agent\x20checks\x20directly.\x20Do\x20NOT\x20attempt\x20to\x20apply\x20a\x20Permission\x20object\x20to\x20Order.','evidence':'no_permission_field'};return null;}},R_O_1_02={'id':'R-O-1-02','category':'structural','trigger':'Item\x20count\x20check\x20(informational;\x20no\x20Move-level\x20limit\x20on\x20items)','check':a=>{if(!a['items']||a['items']['length']===0x0)return null;if(a['items']['length']>0x32)return{'id':'R-O-1-02','level':'LOW','category':'structural','title':'Large\x20items\x20list\x20may\x20exceed\x20tx\x20size\x20limits','description':a['items']['length']+'\x20items\x20in\x20a\x20single\x20Order\x20—\x20no\x20protocol\x20limit,\x20but\x20large\x20lists\x20increase\x20transaction\x20size\x20and\x20may\x20hit\x20gas/size\x20limits','affected_stakeholders':['owner'],'scenario':'Bulk\x20purchase\x20with\x20many\x20line\x20items','mitigation':'Split\x20into\x20multiple\x20Orders\x20if\x20items\x20>\x2050','evidence':'items_count='+a['items']['length']};return null;}},R_O_1_03={'id':'R-O-1-03','category':'structural','trigger':'dispute\x20count\x20>=\x20MAX_DISPUTE_COUNT\x20(10)','check':a=>{const b=a['current_dispute_count']??0x0;if(b>=MAX_DISPUTE_COUNT)return{'id':'R-O-1-03','level':'HIGH','category':'structural','title':'Dispute\x20count\x20at\x20MAX_DISPUTE_COUNT\x20limit','description':'Order\x20already\x20has\x20'+b+'\x20disputes\x20(MAX_DISPUTE_COUNT='+MAX_DISPUTE_COUNT+').\x20Next\x20dispute()\x20call\x20will\x20abort\x20E_DISPUTE_COUNT_EXCEEDED.','affected_stakeholders':['owner','agent','arbitrator'],'scenario':'Filing\x2011th\x20dispute\x20on\x20an\x20Order\x20with\x2010\x20existing\x20disputes','mitigation':'Resolve\x20existing\x20disputes\x20(via\x20arb_claim_compensation)\x20before\x20filing\x20new\x20ones.\x20Note:\x20claimed_by\x20blocks\x20ALL\x20future\x20disputes.','evidence':'dispute_count='+b};return null;}},R_O_1_04={'id':'R-O-1-04','category':'structural','trigger':'agent\x20count\x20>\x20MAX_AGENT_COUNT\x20(doc=10,\x20actual\x20allows\x2011\x20due\x20to\x20<=\x20bug)','check':a=>{if(!a['agent_set'])return null;const b=a['agent_set']['agents']['length'];if(b>MAX_AGENT_COUNT)return{'id':'R-O-1-04','level':'HIGH','category':'structural','title':'Agent\x20count\x20exceeds\x20documented\x20MAX_AGENT_COUNT\x20(boundary\x20bug)','description':'Attempting\x20to\x20set\x20'+b+'\x20agents.\x20Doc\x20says\x20MAX_AGENT_COUNT='+MAX_AGENT_COUNT+',\x20but\x20Move\x20agent_set_imp\x20uses\x20<=\x20instead\x20of\x20<,\x20actually\x20allowing\x2011.\x20SDK\x20constant\x20=\x20'+MAX_AGENT_COUNT+'\x20does\x20not\x20match\x20chain\x20behavior.','affected_stakeholders':['owner','system'],'scenario':'Setting\x2011\x20agents\x20—\x20succeeds\x20on\x20chain\x20but\x20contradicts\x20SDK/docs','mitigation':'Treat\x2010\x20as\x20the\x20soft\x20cap\x20(matching\x20docs).\x20If\x2011\x20is\x20intentional,\x20document\x20the\x20boundary\x20bug\x20explicitly.\x20Long-term:\x20fix\x20Move\x20to\x20use\x20<\x20and\x20sync\x20SDK.','evidence':'agent_count='+b+',\x20max_doc='+MAX_AGENT_COUNT+',\x20max_actual=11'};return null;}},R_O_1_05={'id':'R-O-1-05','category':'structural','trigger':'wip_hash\x20is\x20empty\x20string\x20in\x20any\x20item','check':a=>{if(!a['items'])return null;const b=a['items']['find'](c=>!c['wip_hash']||c['wip_hash']==='');if(b)return{'id':'R-O-1-05','level':'HIGH','category':'structural','title':'Empty\x20wip_hash\x20in\x20item','description':'Item\x20\x22'+b['name']+'\x22\x20has\x20empty\x20wip_hash.\x20Move\x20rejects\x20empty\x20strings\x20(F-O-18).','affected_stakeholders':['owner'],'scenario':'User\x20submits\x20item\x20without\x20computing\x20WIP\x20hash','mitigation':'Compute\x20wip_hash\x20from\x20the\x20work-in-progress\x20file\x20content\x20before\x20service::buy().','evidence':'item_name='+b['name']};return null;}},R_O_2_01={'id':'R-O-2-01','category':'semantic','trigger':'Order.machine\x20snapshot\x20differs\x20from\x20current\x20Service.machine','check':a=>{if(!a['current_service_machine']||!a['order_machine_snapshot'])return null;if(a['current_service_machine']!==a['order_machine_snapshot'])return{'id':'R-O-2-01','level':'HIGH','category':'semantic','title':'Machine\x20snapshot\x20diverges\x20from\x20Service.machine','description':'Order.machine='+a['order_machine_snapshot']+'\x20was\x20snapshotted\x20at\x20buy\x20time.\x20Service.machine\x20is\x20now\x20'+a['current_service_machine']+'.\x20Same\x20Service\x20has\x20Orders\x20running\x20different\x20Machine\x20versions.','affected_stakeholders':['owner','service_provider','arbitrator'],'scenario':'Service\x20provider\x20upgrades\x20Machine\x20after\x20some\x20Orders\x20are\x20created','mitigation':'Audit\x20each\x20Order\x27s\x20machine\x20snapshot\x20separately.\x20Document\x20Machine\x20version\x20per\x20Order.\x20Plan\x20migration\x20paths\x20for\x20legacy\x20Orders.','evidence':'order_machine='+a['order_machine_snapshot']+',\x20service_machine='+a['current_service_machine']};return null;}},R_O_2_02={'id':'R-O-2-02','category':'semantic','trigger':'SDK\x20uses\x20\x27builder\x27\x20field\x20for\x20Move\x27s\x20\x27owner\x27\x20field\x20(naming\x20deviation)','check':a=>{if(a['object'])return{'id':'R-O-2-02','level':'MEDIUM','category':'semantic','title':'SDK\x20builder\x20≠\x20Move\x20owner\x20(only\x20naming\x20deviation\x20in\x2022\x20objects)','description':'SDK\x20ObjectOrder.builder\x20corresponds\x20to\x20Move\x20Order.owner.\x20This\x20is\x20the\x20only\x20field\x20name\x20deviation\x20across\x20all\x2022\x20WoWok\x20objects.\x20All\x20Order\x20knowledge\x20uses\x20Move\x27s\x20\x27owner\x27\x20as\x20canonical.','affected_stakeholders':['system'],'scenario':'Developer\x20reads\x20SDK\x20\x27builder\x27\x20and\x20assumes\x20it\x27s\x20a\x20different\x20concept\x20from\x20owner','mitigation':'Use\x20moveToSdkField()/sdkToMoveField()\x20helpers\x20from\x20order-ledger.ts.\x20Document\x20\x27builder\x20=\x20owner\x27\x20in\x20all\x20SDK\x20consumers.','evidence':'sdk_field=builder,\x20move_field=owner'};return null;}},R_O_2_03={'id':'R-O-2-03','category':'semantic','trigger':'owner_change\x20or\x20agent_set\x20aborted\x20with\x20E_PROGRESS_NOT_SPECIFIED\x20(dual\x20semantics)','check':a=>{if(!a['operation'])return null;if(a['operation']==='agent_set'&&a['progress_bound'])return{'id':'R-O-2-03','level':'MEDIUM','category':'semantic','title':'E_PROGRESS_NOT_SPECIFIED\x20dual\x20semantics\x20(literal\x20vs\x20actual)','description':'agent_set\x20aborted\x20because\x20progress.is_some()\x20—\x20but\x20error\x20code\x20says\x20\x27PROGRESS_NOT_SPECIFIED\x27.\x20The\x20code\x20is\x20used\x20in\x20two\x20OPPOSITE\x20scenarios:\x20(A)\x20progress.is_none()\x20during\x20on_progress\x20(literal),\x20(B)\x20progress.is_some()\x20during\x20owner_change/agent_set\x20(opposite).','affected_stakeholders':['owner','agent'],'scenario':'User\x20sees\x20\x27Progress\x20not\x20specified\x27\x20error\x20when\x20Progress\x20IS\x20specified\x20—\x20confusion','mitigation':'Translate\x20error\x20to:\x20\x27Cannot\x20modify\x20owner/agent:\x20Progress\x20already\x20bound\x20(frozen).\x27\x20Long-term:\x20split\x20into\x20two\x20error\x20codes\x20(E_PROGRESS_ALREADY_BOUND\x20and\x20E_PROGRESS_NOT_SPECIFIED).','evidence':'operation='+a['operation']+',\x20progress_bound='+a['progress_bound']};return null;}},R_O_2_04={'id':'R-O-2-04','category':'semantic','trigger':'SaleItem.item\x20→\x20PurchasedItem.name\x20field\x20name\x20mapping','check':a=>{if(a['is_buy_operation'])return{'id':'R-O-2-04','level':'LOW','category':'semantic','title':'SaleItem.item\x20(Move)\x20maps\x20to\x20PurchasedItem.name\x20(SDK)','description':'Move\x20struct\x20SaleItem\x20uses\x20field\x20\x27item\x27,\x20but\x20SDK\x20ObjectOrder.items\x20uses\x20field\x20\x27name\x27.\x20This\x20is\x20the\x20second\x20naming\x20deviation\x20in\x20Order\x20system\x20(after\x20builder/owner).','affected_stakeholders':['system'],'scenario':'Cross-layer\x20data\x20mapping\x20between\x20Move\x20and\x20SDK','mitigation':'Use\x20consistent\x20SDK\x20field\x20names\x20in\x20user-facing\x20code;\x20document\x20Move\x20↔\x20SDK\x20mapping\x20in\x20audit\x20logs.','evidence':'move_field=SaleItem.item,\x20sdk_field=PurchasedItem.name'};return null;}},R_O_3_01={'id':'R-O-3-01','category':'authority','trigger':'Agent\x20attempts\x20receive\x20or\x20transfer_to\x20(L1\x20owner-only\x20operations)','check':a=>{if(!a['operation'])return null;if((a['operation']==='receive'||a['operation']==='transfer_to')&&a['caller_is_agent']&&!a['caller_is_owner'])return{'id':'R-O-3-01','level':'HIGH','category':'authority','title':'Agent\x20attempting\x20owner-only\x20operation','description':'Agent\x20cannot\x20call\x20'+a['operation']+'\x20—\x20these\x20are\x20L1\x20owner-only\x20operations\x20(assert_owner).\x20Agent\x20can\x20operate\x20progress/arb_*/required_info\x20but\x20CANNOT\x20receive\x20funds\x20or\x20transfer\x20ownership.','affected_stakeholders':['agent','owner'],'scenario':'Logistics\x20agent\x20tries\x20to\x20collect\x20payment\x20on\x20behalf\x20of\x20buyer','mitigation':'Owner\x20must\x20call\x20receive/transfer_to\x20directly.\x20If\x20delegation\x20is\x20needed,\x20owner\x20can\x20transfer_to\x20a\x20multi-sig\x20wallet\x20that\x20includes\x20the\x20agent.','evidence':'operation='+a['operation']+',\x20caller=agent'};return null;}},R_O_3_02={'id':'R-O-3-02','category':'authority','trigger':'Non-owner\x20non-agent\x20attempts\x20operation\x20(no\x20permission)','check':a=>{if(!a['operation'])return null;if(a['caller_is_owner']===![]&&a['caller_is_agent']===![])return{'id':'R-O-3-02','level':'HIGH','category':'authority','title':'Non-owner\x20non-agent\x20attempting\x20operation','description':'Caller\x20is\x20neither\x20owner\x20nor\x20agent.\x20All\x20Order\x20operations\x20require\x20at\x20least\x20has_op_permission\x20(L2\x20layer).\x20Aborts\x20E_PERMISSION.','affected_stakeholders':['system'],'scenario':'Random\x20address\x20attempts\x20to\x20advance\x20someone\x20else\x27s\x20Order','mitigation':'Verify\x20caller\x20is\x20owner\x20or\x20in\x20agent[]\x20before\x20submitting\x20transaction.','evidence':'operation='+a['operation']+',\x20caller=unauthorized'};return null;}},R_O_3_03={'id':'R-O-3-03','category':'authority','trigger':'arb_claim_compensation\x20called\x20(sets\x20claimed_by,\x20irreversible)','check':a=>{if(a['operation']!=='arb_claim_compensation')return null;return{'id':'R-O-3-03','level':'HIGH','category':'authority','title':'arb_claim_compensation\x20is\x20IRREVERSIBLE\x20(claimed_by\x20one-time\x20set)','description':'Setting\x20claimed_by\x20is\x20permanent.\x20After\x20this\x20call:\x20(1)\x20claimed_by\x20cannot\x20be\x20reset,\x20(2)\x20NO\x20new\x20disputes\x20can\x20be\x20filed\x20(E_ORDER_ALREADY_CLAIMED),\x20(3)\x20all\x20unresolved\x20disputes\x20become\x20unactionable.\x20If\x20first\x20compensation\x20is\x20insufficient,\x20buyer\x20has\x20no\x20recourse.','affected_stakeholders':['owner','agent','arbitrator'],'scenario':'Buyer\x20claims\x20partial\x20compensation,\x20then\x20discovers\x20additional\x20damages','mitigation':'BEFORE\x20claiming:\x20(1)\x20enumerate\x20ALL\x20disputes,\x20(2)\x20ensure\x20proposition\x20covers\x20all\x20damages,\x20(3)\x20confirm\x20Arb\x20ruling\x20is\x20final.\x20Add\x20explicit\x20user\x20confirmation\x20(C-O-08).','evidence':'operation=arb_claim_compensation,\x20current_claimed_by='+(a['claimed_by_set']??![])};}},R_O_3_04={'id':'R-O-3-04','category':'authority','trigger':'dispute\x20attempted\x20after\x20claimed_by\x20is\x20set','check':a=>{if(a['claimed_by_set']&&(a['operation']==='arb_confirm'||a['operation']==='arb_objection'))return{'id':'R-O-3-04','level':'HIGH','category':'authority','title':'Cannot\x20file\x20new\x20dispute\x20after\x20claimed_by\x20is\x20set','description':'Order.claimed_by\x20is\x20set\x20—\x20any\x20new\x20dispute()\x20call\x20aborts\x20E_ORDER_ALREADY_CLAIMED.\x20arb_confirm/arb_objection\x20trigger\x20dispute()\x20internally.','affected_stakeholders':['owner','agent'],'scenario':'Buyer\x20claims\x20compensation\x20then\x20tries\x20to\x20file\x20additional\x20dispute','mitigation':'Resolve\x20ALL\x20disputes\x20BEFORE\x20calling\x20arb_claim_compensation.\x20claimed_by\x20is\x20terminal\x20for\x20dispute\x20flow.','evidence':'operation='+a['operation']+',\x20claimed_by_set=true'};return null;}},R_O_4_01={'id':'R-O-4-01','category':'lifecycle','trigger':'Attempt\x20to\x20create\x20Order\x20independently\x20(not\x20via\x20service::buy)','check':a=>{if(a['is_buy_operation']===![]&&a['operation']==='service_buy'&&!a['object'])return{'id':'R-O-4-01','level':'CRITICAL','category':'lifecycle','title':'Order\x20cannot\x20be\x20created\x20independently\x20(compound\x20creation\x20only)','description':'order::new()\x20is\x20package-only\x20—\x20only\x20service::buy()\x20can\x20create\x20Orders.\x20Any\x20attempt\x20to\x20call\x20order::new\x20directly\x20will\x20fail\x20at\x20the\x20Move\x20module\x20boundary.\x20Order\x20+\x20Allocation\x20+\x20Progress\x20are\x20created\x20atomically\x20in\x20one\x20transaction.','affected_stakeholders':['system','owner'],'scenario':'Developer\x20tries\x20to\x20construct\x20Order\x20independently\x20for\x20testing','mitigation':'Always\x20use\x20service::buy()\x20to\x20create\x20Orders.\x20For\x20testing,\x20deploy\x20a\x20minimal\x20Service\x20with\x20machine/allocators\x20configured.','evidence':'independent_creation_attempted'};return null;}},R_O_4_02={'id':'R-O-4-02','category':'lifecycle','trigger':'agent_set\x20or\x20owner_change\x20attempted\x20after\x20Progress\x20binding','check':a=>{if(!a['operation'])return null;if(a['operation']==='agent_set'&&a['progress_bound'])return{'id':'R-O-4-02','level':'HIGH','category':'lifecycle','title':'agent_set\x20blocked\x20—\x20Progress\x20binding\x20frozen\x20owner/agent','description':'Once\x20order.progress\x20is\x20set\x20(during\x20service::buy\x20if\x20Service\x20has\x20machine),\x20agent_set\x20and\x20owner_change\x20abort\x20E_PROGRESS_NOT_SPECIFIED.\x20Owner/agent\x20must\x20be\x20finalized\x20BEFORE\x20buy.','affected_stakeholders':['owner','agent'],'scenario':'Buyer\x20wants\x20to\x20add\x20agent\x20mid-fulfillment\x20after\x20Progress\x20is\x20bound','mitigation':'Set\x20agent\x20list\x20BEFORE\x20service::buy\x20(via\x20pre-buy\x20configuration).\x20If\x20post-buy\x20agent\x20change\x20is\x20needed,\x20use\x20transfer_to\x20a\x20new\x20owner\x20who\x20has\x20the\x20desired\x20agents.','evidence':'operation=agent_set,\x20progress_bound='+a['progress_bound']};return null;}},R_O_4_03={'id':'R-O-4-03','category':'lifecycle','trigger':'Progress\x20advance\x20attempted\x20without\x20progress\x20bound','check':a=>{if(a['operation']==='progress_advance'&&a['progress_bound']===![])return{'id':'R-O-4-03','level':'HIGH','category':'lifecycle','title':'Cannot\x20advance\x20Progress\x20—\x20no\x20Progress\x20bound\x20to\x20Order','description':'Order\x20has\x20no\x20progress\x20field\x20set\x20(Service\x20had\x20no\x20machine\x20configured).\x20Cannot\x20advance\x20a\x20non-existent\x20Progress.\x20SDK\x20CallOrder\x20validates\x20this\x20pre-flight\x20(CallOrder_Data.progress\x20requires\x20order.machine\x20and\x20order.progress).','affected_stakeholders':['owner','agent'],'scenario':'Buyer\x20tries\x20to\x20advance\x20Progress\x20on\x20an\x20Order\x20created\x20from\x20a\x20Service\x20without\x20machine','mitigation':'Use\x20a\x20Service\x20with\x20machine\x20configured.\x20If\x20manual\x20lifecycle\x20is\x20needed,\x20track\x20state\x20off-chain.','evidence':'operation=progress_advance,\x20progress_bound=false'};return null;}},R_O_4_04={'id':'R-O-4-04','category':'lifecycle','trigger':'arb_confirm/arb_objection/arb_claim_compensation\x20(irreversible\x20Arb\x20operations)','check':a=>{if(!a['operation'])return null;if(a['operation']==='arb_confirm'||a['operation']==='arb_objection'||a['operation']==='arb_claim_compensation')return{'id':'R-O-4-04','level':'HIGH','category':'lifecycle','title':a['operation']+'\x20is\x20irreversible\x20(triggers\x20Arb\x20flow)','description':a['operation']+'\x20triggers\x20the\x20Arbitration\x20workflow\x20which\x20cannot\x20be\x20undone.\x20arb_confirm\x20files\x20a\x20new\x20dispute,\x20arb_objection\x20requests\x20re-arbitration,\x20arb_claim_compensation\x20sets\x20claimed_by\x20permanently.','affected_stakeholders':['owner','agent','arbitrator'],'scenario':'User\x20accidentally\x20files\x20arb_confirm\x20without\x20understanding\x20consequences','mitigation':'Add\x20explicit\x20user\x20confirmation\x20(C-O-08,\x20C-O-11,\x20C-O-12)\x20before\x20these\x20operations.\x20Show\x20warning\x20text\x20describing\x20irreversibility.','evidence':'operation='+a['operation']};return null;}},R_O_4_05={'id':'R-O-4-05','category':'lifecycle','trigger':'receive\x20attempted\x20while\x20Progress\x20not\x20at\x20terminal\x20node','check':a=>{if(a['operation']==='receive'&&a['progress_bound']&&!a['progress_at_terminal'])return{'id':'R-O-4-05','level':'HIGH','category':'lifecycle','title':'receive\x20blocked\x20—\x20Order\x20still\x20delivering\x20(E_ORDER_DELIVERING)','description':'owner_receive\x20aborts\x20E_ORDER_DELIVERING\x20when\x20Progress\x20has\x20not\x20reached\x20a\x20terminal\x20node.\x20Funds\x20cannot\x20be\x20collected\x20until\x20fulfillment\x20completes.','affected_stakeholders':['owner'],'scenario':'Buyer\x20tries\x20to\x20collect\x20refund\x20before\x20Progress\x20reaches\x20\x27completed\x27\x20or\x20\x27cancelled\x27','mitigation':'Wait\x20for\x20Progress\x20to\x20reach\x20terminal/cancel\x20node.\x20If\x20urgent,\x20file\x20arb_confirm\x20to\x20dispute.','evidence':'operation=receive,\x20progress_at_terminal='+a['progress_at_terminal']};return null;}},R_O_4_06={'id':'R-O-4-06','category':'lifecycle','trigger':'transfer_to\x20attempted\x20(irreversible\x20ownership\x20transfer)','check':a=>{if(a['operation']!=='transfer_to')return null;return{'id':'R-O-4-06','level':'CRITICAL','category':'lifecycle','title':'transfer_to\x20is\x20IRREVERSIBLE\x20—\x20new\x20owner\x20takes\x20over\x20ALL\x20permissions','description':'Ownership\x20transfer\x20to\x20'+(a['transfer_to_new_owner']??'(unknown)')+'\x20is\x20permanent.\x20New\x20owner\x20becomes\x20the\x20sole\x20receiver\x20of\x20payments\x20and\x20gains\x20full\x20L1\x20control.\x20Original\x20owner\x20loses\x20ALL\x20access.','affected_stakeholders':['owner'],'scenario':'Buyer\x20transfers\x20Order\x20to\x20wrong\x20address\x20by\x20mistake','mitigation':'1)\x20Verify\x20new\x20owner\x20address\x20twice.\x202)\x20Coordinate\x20with\x20new\x20owner\x20before\x20transfer.\x203)\x20Add\x20explicit\x20user\x20confirmation\x20(C-O-09).\x20Note:\x20transfer_to\x20is\x20NOT\x20blocked\x20by\x20progress\x20binding\x20(unlike\x20agent_set).','evidence':'new_owner='+a['transfer_to_new_owner']};}},R_O_5_01={'id':'R-O-5-01','category':'cross_object','trigger':'Service.machine\x20upgraded\x20after\x20Order\x20creation\x20(snapshot\x20divergence)','check':a=>{if(a['is_buy_operation'])return{'id':'R-O-5-01','level':'LOW','category':'cross_object','title':'Service\x20snapshot\x20mechanism\x20—\x20order.machine\x20is\x20a\x20copy,\x20not\x20a\x20reference','description':'When\x20service::buy()\x20creates\x20an\x20Order,\x20order.machine\x20is\x20COPIED\x20from\x20service.machine.\x20Future\x20Service.machine\x20upgrades\x20do\x20NOT\x20affect\x20this\x20Order.\x20Same\x20Service\x20may\x20have\x20Orders\x20running\x20different\x20Machine\x20versions.','affected_stakeholders':['owner','service_provider','arbitrator'],'scenario':'Service\x20provider\x20upgrades\x20Machine\x20workflow\x20—\x20old\x20Orders\x20keep\x20old\x20workflow','mitigation':'Track\x20Machine\x20version\x20per\x20Order\x20(via\x20order.machine\x20address).\x20Plan\x20migration\x20paths\x20for\x20legacy\x20Orders.\x20Document\x20that\x20old\x20Orders\x20are\x20decoupled.','evidence':'snapshot_mechanism'};return null;}},R_O_5_02={'id':'R-O-5-02','category':'cross_object','trigger':'Order\x20references\x20Progress\x20that\x20no\x20longer\x20exists\x20or\x20is\x20corrupted','check':a=>{if(a['progress_bound']&&a['object'])return{'id':'R-O-5-02','level':'MEDIUM','category':'cross_object','title':'Order-Progress\x201:1\x20binding\x20(E_PROGRESS_ALREADY_SPECIFIED)','description':'Order.progress\x20is\x20one-time-set\x20via\x20on_progress\x20(package-only).\x20Cannot\x20be\x20rebound.\x20If\x20Progress\x20object\x20is\x20corrupted,\x20Order\x20becomes\x20stuck\x20—\x20cannot\x20advance,\x20cannot\x20rebind.','affected_stakeholders':['owner','agent'],'scenario':'Progress\x20object\x20becomes\x20unresponsive\x20or\x20corrupted','mitigation':'Ensure\x20Progress\x20integrity\x20via\x20Machine\x20audit\x20before\x20publishing\x20Service.\x20Use\x20arb_claim_compensation\x20as\x20escape\x20hatch\x20if\x20Progress\x20is\x20stuck.','evidence':'progress_bound='+a['progress_bound']};return null;}},R_O_5_03={'id':'R-O-5-03','category':'cross_object','trigger':'Order\x20references\x20Allocation\x20that\x20no\x20longer\x20exists\x20or\x20is\x20corrupted','check':a=>{if(a['object']&&a['progress_bound'])return{'id':'R-O-5-03','level':'MEDIUM','category':'cross_object','title':'Order-Allocation\x201:1\x20binding\x20(E_ALLOCATION_ALREADY_SPECIFIED)','description':'Order.allocation\x20is\x20one-time-set\x20via\x20on_allocation\x20(package-only).\x20Cannot\x20be\x20rebound.\x20If\x20Allocation\x20object\x20is\x20corrupted,\x20fund\x20distribution\x20is\x20blocked.','affected_stakeholders':['owner','service_provider'],'scenario':'Allocation\x20object\x20has\x20wrong\x20allocator\x20configuration','mitigation':'Audit\x20order_allocators\x20configuration\x20on\x20Service\x20BEFORE\x20publishing.\x20Use\x20compensation_fund\x20as\x20fallback\x20fund\x20source.','evidence':'allocation_binding'};return null;}},R_O_5_04={'id':'R-O-5-04','category':'cross_object','trigger':'Arbitration\x20dispute\x20appended\x20to\x20Order.dispute\x20list','check':a=>{if(a['operation']==='arb_confirm')return{'id':'R-O-5-04','level':'LOW','category':'cross_object','title':'Arb\x20object\x20will\x20be\x20appended\x20to\x20order.dispute\x20(package-only\x20dispute())','description':'arb_confirm\x20triggers\x20Arb\x20module\x20to\x20call\x20order::dispute(arb_address),\x20appending\x20the\x20Arb\x20object\x20to\x20order.dispute\x20list.\x20Max\x2010\x20disputes\x20(MAX_DISPUTE_COUNT).\x20Frozen\x20when\x20claimed_by\x20is\x20set.','affected_stakeholders':['arbitrator','owner','agent'],'scenario':'Multiple\x20arb_confirm\x20calls\x20create\x20multiple\x20Arb\x20objects\x20on\x20same\x20Order','mitigation':'Track\x20dispute\x20count.\x20Once\x20at\x2010,\x20no\x20more\x20disputes\x20can\x20be\x20filed.\x20Resolve\x20existing\x20disputes\x20before\x20filing\x20new\x20ones.','evidence':'operation=arb_confirm,\x20current_disputes='+(a['current_dispute_count']??0x0)};return null;}},R_O_5_05={'id':'R-O-5-05','category':'cross_object','trigger':'External\x20system\x20expects\x20OrderCompletedEvent\x20(does\x20not\x20exist)','check':a=>{if(a['is_buy_operation']||a['object'])return{'id':'R-O-5-05','level':'MEDIUM','category':'cross_object','title':'Only\x20NewOrderEvent\x20emitted\x20—\x20no\x20OrderCompletedEvent','description':'Move\x20contract\x20ONLY\x20emits\x20NewOrderEvent\x20at\x20creation.\x20Order\x20completion/cancellation/refund\x20are\x20IMPLICIT\x20—\x20must\x20be\x20inferred\x20by\x20querying\x20Progress.current_node\x20(terminal?\x20cancel?)\x20or\x20Order.claimed_by.\x20External\x20monitoring\x20requires\x20polling,\x20not\x20event-driven.','affected_stakeholders':['system'],'scenario':'Analytics\x20dashboard\x20expects\x20OrderCompletedEvent\x20to\x20track\x20completion\x20rate','mitigation':'Build\x20composite\x20query:\x20NewOrderEvent\x20+\x20Order.progress\x20query\x20→\x20infer\x20completion.\x20Document\x20this\x20limitation\x20in\x20monitoring\x20tools.\x20Long-term:\x20advocate\x20for\x20Move\x20upgrade\x20to\x20add\x20OrderCompletedEvent.','evidence':'no_order_completed_event'};return null;}},R_O_5_06={'id':'R-O-5-06','category':'cross_object','trigger':'service::buy\x20pre-flight:\x20Service\x20not\x20published\x20or\x20paused','check':a=>{if(!a['is_buy_operation'])return null;if(a['service_published']===![])return{'id':'R-O-5-06','level':'CRITICAL','category':'cross_object','title':'Service\x20not\x20published\x20—\x20service::buy\x20will\x20abort\x20E_NOT_PUBLISHED','description':'Cannot\x20create\x20Order\x20from\x20an\x20unpublished\x20Service.\x20Service\x20must\x20be\x20published\x20(bPublished=true)\x20before\x20service::buy()\x20can\x20be\x20called.','affected_stakeholders':['owner'],'scenario':'Buyer\x20attempts\x20to\x20purchase\x20from\x20a\x20draft\x20Service','mitigation':'Verify\x20Service.bPublished=true\x20before\x20service::buy().\x20Service\x20owner\x20must\x20call\x20service::publish()\x20first.','evidence':'service_published='+a['service_published']};if(a['service_paused']===!![])return{'id':'R-O-5-06','level':'CRITICAL','category':'cross_object','title':'Service\x20paused\x20—\x20service::buy\x20will\x20abort\x20E_PAUSED','description':'Cannot\x20create\x20Order\x20from\x20a\x20paused\x20Service.\x20Service\x20must\x20be\x20unpaused\x20before\x20service::buy()\x20can\x20be\x20called.','affected_stakeholders':['owner'],'scenario':'Buyer\x20attempts\x20to\x20purchase\x20from\x20a\x20paused\x20Service\x20(e.g.\x20during\x20maintenance)','mitigation':'Wait\x20for\x20Service\x20owner\x20to\x20call\x20service::pause(false).\x20Check\x20Service.paused\x20before\x20service::buy().','evidence':'service_paused='+a['service_paused']};return null;}},ALL_RULES=[R_O_1_01,R_O_1_02,R_O_1_03,R_O_1_04,R_O_1_05,R_O_2_01,R_O_2_02,R_O_2_03,R_O_2_04,R_O_3_01,R_O_3_02,R_O_3_03,R_O_3_04,R_O_4_01,R_O_4_02,R_O_4_03,R_O_4_04,R_O_4_05,R_O_4_06,R_O_5_01,R_O_5_02,R_O_5_03,R_O_5_04,R_O_5_05,R_O_5_06];export const ORDER_RISK_VERSION='1.0.0';export function getAllOrderRiskRules(){return[...ALL_RULES];}export function getOrderRiskRulesCount(){return ALL_RULES['length'];}export function getOrderRiskRulesByCategory(a){return ALL_RULES['filter'](b=>b['category']===a);}export function getOrderRiskRuleById(a){return ALL_RULES['find'](b=>b['id']===a);}export function assessOrderRisks(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={};for(const i of b){d[i['category']]=(d[i['category']]??0x0)+0x1;}const e={};for(const j of b){for(const k of j['affected_stakeholders']){if(!e[k])e[k]=[];e[k]['push'](j['id']+':\x20'+j['mitigation']);}}let f;if(a['operation']){const l={'agent_set':'order_set_agent','required_info_update':'order_required_info','progress_advance':'order_advance','arb_confirm':'order_arb_confirm','arb_objection':'order_arb_objection','arb_claim_compensation':'order_arb_claim_compensation','receive':'order_receive','transfer_to':'order_transfer','service_buy':'order_create'};f=findSceneById(l[a['operation']]??'');}return{'summary':'Assessed\x20'+b['length']+'\x20risk(s)\x20across\x20'+Object['keys'](d)['length']+'\x20categories','scene':f,'risks':b,'overall_risk':c,'risks_by_category':d,'stakeholder_advice':e,'needs_human_review':b['some'](m=>m['level']==='CRITICAL'||m['level']==='HIGH')};}export function checkPermissionLayer(a,b,c){const d=['receive','transfer_to','owner_change','agent_set'],e=['required_info_update','progress_advance','arb_confirm','arb_objection','arb_claim_compensation'],f=['on_progress','on_allocation','dispute','compensate'];if(f['includes'](a))return{'allowed':![],'layer':'L3_package_only','reason':'Package-only\x20—\x20not\x20callable\x20externally'};if(d['includes'](a)){if(!b)return{'allowed':![],'layer':'L1_owner_only','reason':'Owner-only\x20operation\x20('+a+')\x20—\x20agent\x20or\x20unauthorized\x20caller'};return{'allowed':!![],'layer':'L1_owner_only'};}if(e['includes'](a)){if(!b&&!c)return{'allowed':![],'layer':'L2_owner_or_agent','reason':'Requires\x20owner\x20or\x20agent\x20permission\x20('+a+')'};return{'allowed':!![],'layer':'L2_owner_or_agent'};}return{'allowed':![],'layer':'L3_package_only','reason':'Unknown\x20operation:\x20'+a};}