@wowok/agent-mcp 2.7.1 → 2.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (597) hide show
  1. package/dist/config/index.js +1 -1
  2. package/dist/config/runtime.js +1 -238
  3. package/dist/customer/account-events.d.ts +32 -0
  4. package/dist/customer/account-events.js +1 -0
  5. package/dist/customer/customer-advice.d.ts +1 -0
  6. package/dist/customer/customer-advice.js +1 -130
  7. package/dist/customer/index.js +1 -11
  8. package/dist/customer/industry-risks.js +1 -438
  9. package/dist/customer/info-puzzle.js +1 -681
  10. package/dist/customer/order-monitor.js +1 -328
  11. package/dist/customer/order-strategy.d.ts +1 -1
  12. package/dist/customer/order-strategy.js +1 -373
  13. package/dist/customer/post-purchase.js +1 -351
  14. package/dist/customer/preorder-compare.js +1 -34
  15. package/dist/customer/reminder-system.d.ts +2 -0
  16. package/dist/customer/reminder-system.js +1 -316
  17. package/dist/customer/risk-assessment.d.ts +1 -0
  18. package/dist/customer/risk-assessment.js +1 -397
  19. package/dist/customer/types.d.ts +2 -0
  20. package/dist/customer/types.js +1 -13
  21. package/dist/customer/user-preferences.js +1 -460
  22. package/dist/evaluation/arbitration-game.d.ts +9 -2
  23. package/dist/evaluation/arbitration-game.js +1 -48
  24. package/dist/evaluation/builtins/arbitration-score.d.ts +41 -0
  25. package/dist/evaluation/builtins/arbitration-score.js +1 -0
  26. package/dist/evaluation/builtins/demand-match.js +1 -153
  27. package/dist/evaluation/builtins/index.d.ts +1 -0
  28. package/dist/evaluation/builtins/index.js +1 -10
  29. package/dist/evaluation/builtins/service-risk.js +1 -55
  30. package/dist/evaluation/capability.js +1 -13
  31. package/dist/evaluation/category-match-rules.d.ts +30 -0
  32. package/dist/evaluation/category-match-rules.js +1 -0
  33. package/dist/evaluation/composer.js +1 -40
  34. package/dist/evaluation/engine.js +1 -175
  35. package/dist/evaluation/extract.js +1 -115
  36. package/dist/evaluation/game-strategy.d.ts +27 -0
  37. package/dist/evaluation/game-strategy.js +1 -0
  38. package/dist/evaluation/gap.js +1 -100
  39. package/dist/evaluation/index.d.ts +2 -0
  40. package/dist/evaluation/index.js +1 -11
  41. package/dist/evaluation/location-match.d.ts +42 -0
  42. package/dist/evaluation/location-match.js +1 -0
  43. package/dist/evaluation/node-game.d.ts +31 -3
  44. package/dist/evaluation/node-game.js +1 -57
  45. package/dist/evaluation/path-reasoning.d.ts +35 -0
  46. package/dist/evaluation/path-reasoning.js +1 -0
  47. package/dist/evaluation/region.d.ts +6 -0
  48. package/dist/evaluation/region.js +1 -36
  49. package/dist/evaluation/types.d.ts +18 -0
  50. package/dist/evaluation/types.js +1 -1
  51. package/dist/evaluation/user-injection.js +1 -27
  52. package/dist/experience/experience-reuse.js +1 -103
  53. package/dist/experience/index.js +1 -5
  54. package/dist/experience/intent-distill.js +1 -83
  55. package/dist/experience/realtime-feedback.js +1 -94
  56. package/dist/experience/types.js +1 -1
  57. package/dist/experience/user-profile.d.ts +1 -1
  58. package/dist/experience/user-profile.js +1 -171
  59. package/dist/extensions/business-modules.js +1 -287
  60. package/dist/extensions/capability-manifest.js +1 -781
  61. package/dist/extensions/constraint-registry.js +1 -198
  62. package/dist/extensions/index.d.ts +6 -0
  63. package/dist/extensions/index.js +1 -6
  64. package/dist/extensions/industry-layers.d.ts +75 -0
  65. package/dist/extensions/industry-layers.js +1 -0
  66. package/dist/extensions/industry-pack.d.ts +105 -0
  67. package/dist/extensions/industry-pack.js +1 -0
  68. package/dist/extensions/metric-registry.js +1 -257
  69. package/dist/extensions/mode-evaluator.d.ts +1 -1
  70. package/dist/extensions/mode-evaluator.js +1 -170
  71. package/dist/extensions/modes.js +1 -499
  72. package/dist/extensions/registry.d.ts +1 -0
  73. package/dist/extensions/registry.js +1 -717
  74. package/dist/extensions/types.js +1 -1
  75. package/dist/graph/base.d.ts +8 -0
  76. package/dist/graph/base.js +1 -0
  77. package/dist/harness/auto-escalation.js +1 -68
  78. package/dist/harness/checkpoint.js +1 -129
  79. package/dist/harness/index.d.ts +1 -0
  80. package/dist/harness/index.js +1 -78
  81. package/dist/harness/plan.d.ts +2 -0
  82. package/dist/harness/plan.js +1 -315
  83. package/dist/harness/recover.d.ts +1 -1
  84. package/dist/harness/recover.js +1 -139
  85. package/dist/harness/types.d.ts +2 -3
  86. package/dist/harness/types.js +1 -1
  87. package/dist/harness/verify.js +1 -237
  88. package/dist/index.js +1 -273
  89. package/dist/intent/enrich.js +1 -67
  90. package/dist/intent/index.js +1 -60
  91. package/dist/intent/matcher.js +1 -81
  92. package/dist/intent/store.js +1 -55
  93. package/dist/intent/types.js +1 -10
  94. package/dist/knowledge/acquisition-flywheel.js +1 -192
  95. package/dist/knowledge/allocation-confirm.js +1 -534
  96. package/dist/knowledge/allocation-context.js +1 -249
  97. package/dist/knowledge/allocation-ledger.js +1 -463
  98. package/dist/knowledge/allocation-puzzle.js +1 -298
  99. package/dist/knowledge/allocation-risk.js +1 -568
  100. package/dist/knowledge/allocation-templates.js +1 -970
  101. package/dist/knowledge/allocation-translation.js +1 -585
  102. package/dist/knowledge/anti-cheat.d.ts +37 -0
  103. package/dist/knowledge/anti-cheat.js +1 -0
  104. package/dist/knowledge/arb-confirm.d.ts +28 -0
  105. package/dist/knowledge/arb-confirm.js +1 -0
  106. package/dist/knowledge/arb-risk.js +1 -210
  107. package/dist/knowledge/arb-translation.d.ts +48 -0
  108. package/dist/knowledge/arb-translation.js +1 -0
  109. package/dist/knowledge/arbitration-confirm.js +1 -559
  110. package/dist/knowledge/arbitration-context.js +1 -505
  111. package/dist/knowledge/arbitration-ledger.js +1 -521
  112. package/dist/knowledge/arbitration-puzzle.js +1 -304
  113. package/dist/knowledge/arbitration-risk.js +1 -423
  114. package/dist/knowledge/arbitration-templates.js +1 -276
  115. package/dist/knowledge/arbitration-translation.js +1 -487
  116. package/dist/knowledge/audit-rules.js +1 -141
  117. package/dist/knowledge/bridge-confirm.d.ts +26 -0
  118. package/dist/knowledge/bridge-confirm.js +1 -0
  119. package/dist/knowledge/bridge-risk.js +1 -263
  120. package/dist/knowledge/bridge-translation.d.ts +37 -0
  121. package/dist/knowledge/bridge-translation.js +1 -0
  122. package/dist/knowledge/contact-confirm.d.ts +27 -0
  123. package/dist/knowledge/contact-confirm.js +1 -0
  124. package/dist/knowledge/contact-risk.js +1 -200
  125. package/dist/knowledge/contact-templates.js +1 -60
  126. package/dist/knowledge/contact-translation.d.ts +39 -0
  127. package/dist/knowledge/contact-translation.js +1 -0
  128. package/dist/knowledge/demand-confirm.js +1 -206
  129. package/dist/knowledge/demand-context.d.ts +17 -0
  130. package/dist/knowledge/demand-context.js +1 -0
  131. package/dist/knowledge/demand-ledger.d.ts +26 -0
  132. package/dist/knowledge/demand-ledger.js +1 -0
  133. package/dist/knowledge/demand-matching.js +1 -132
  134. package/dist/knowledge/demand-puzzle.d.ts +29 -0
  135. package/dist/knowledge/demand-puzzle.js +1 -0
  136. package/dist/knowledge/demand-risk.js +1 -240
  137. package/dist/knowledge/demand-templates.d.ts +12 -0
  138. package/dist/knowledge/demand-templates.js +1 -0
  139. package/dist/knowledge/demand-translation.js +1 -354
  140. package/dist/knowledge/deployment-scanner.js +1 -823
  141. package/dist/knowledge/dynamic-pricing.js +1 -87
  142. package/dist/knowledge/evidence-review.d.ts +12 -0
  143. package/dist/knowledge/evidence-review.js +1 -0
  144. package/dist/knowledge/examples-scanner-cli.js +1 -26
  145. package/dist/knowledge/examples-scanner.js +1 -843
  146. package/dist/knowledge/flywheel-loop.d.ts +0 -1
  147. package/dist/knowledge/flywheel-loop.js +1 -404
  148. package/dist/knowledge/fund-layer.js +1 -973
  149. package/dist/knowledge/glossary.js +1 -211
  150. package/dist/knowledge/guard-confirm.js +1 -406
  151. package/dist/knowledge/guard-context.js +1 -287
  152. package/dist/knowledge/guard-design-patterns.js +1 -360
  153. package/dist/knowledge/guard-ledger.js +1 -260
  154. package/dist/knowledge/guard-lint.js +1 -670
  155. package/dist/knowledge/guard-migration.d.ts +1 -1
  156. package/dist/knowledge/guard-migration.js +1 -228
  157. package/dist/knowledge/guard-puzzle.js +1 -805
  158. package/dist/knowledge/guard-render.js +1 -700
  159. package/dist/knowledge/guard-risk.js +1 -1879
  160. package/dist/knowledge/guard-submission-prompt.js +1 -171
  161. package/dist/knowledge/guard-templates.js +1 -1105
  162. package/dist/knowledge/guard-translation.js +1 -1119
  163. package/dist/knowledge/index.d.ts +71 -3
  164. package/dist/knowledge/index.js +1 -436
  165. package/dist/knowledge/industry-evolution.js +1 -323
  166. package/dist/knowledge/industry-generalizer.js +1 -381
  167. package/dist/knowledge/industry-registry.js +1 -174
  168. package/dist/knowledge/intent-metrics.d.ts +4 -3
  169. package/dist/knowledge/intent-metrics.js +1 -566
  170. package/dist/knowledge/machine-confirm.js +1 -559
  171. package/dist/knowledge/machine-context.js +1 -833
  172. package/dist/knowledge/machine-ledger.js +1 -338
  173. package/dist/knowledge/machine-puzzle.js +1 -494
  174. package/dist/knowledge/machine-render.js +1 -565
  175. package/dist/knowledge/machine-risk.js +1 -669
  176. package/dist/knowledge/machine-templates.js +1 -1597
  177. package/dist/knowledge/machine-topology.js +1 -234
  178. package/dist/knowledge/machine-translation.js +1 -513
  179. package/dist/knowledge/market-metrics.d.ts +12 -0
  180. package/dist/knowledge/market-metrics.js +1 -0
  181. package/dist/knowledge/market-operations.d.ts +46 -0
  182. package/dist/knowledge/market-operations.js +1 -0
  183. package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
  184. package/dist/knowledge/mcp-schema-audit.d.ts +22 -22
  185. package/dist/knowledge/mcp-schema-audit.js +1 -777
  186. package/dist/knowledge/onchain-constants.js +1 -35
  187. package/dist/knowledge/order-confirm.js +1 -573
  188. package/dist/knowledge/order-context.js +1 -390
  189. package/dist/knowledge/order-ledger.js +1 -341
  190. package/dist/knowledge/order-puzzle.js +1 -255
  191. package/dist/knowledge/order-risk.js +1 -653
  192. package/dist/knowledge/order-templates.js +1 -368
  193. package/dist/knowledge/order-translation.js +1 -550
  194. package/dist/knowledge/overrides-loader.js +1 -65
  195. package/dist/knowledge/passport-confirm.js +1 -531
  196. package/dist/knowledge/passport-context.js +1 -306
  197. package/dist/knowledge/passport-ledger.js +1 -282
  198. package/dist/knowledge/passport-puzzle.js +1 -333
  199. package/dist/knowledge/passport-risk.js +1 -450
  200. package/dist/knowledge/passport-templates.js +1 -568
  201. package/dist/knowledge/passport-translation.js +1 -516
  202. package/dist/knowledge/payment-confirm.d.ts +26 -0
  203. package/dist/knowledge/payment-confirm.js +1 -0
  204. package/dist/knowledge/payment-risk.js +1 -249
  205. package/dist/knowledge/payment-translation.d.ts +37 -0
  206. package/dist/knowledge/payment-translation.js +1 -0
  207. package/dist/knowledge/permission-confirm.js +1 -426
  208. package/dist/knowledge/permission-context.js +1 -224
  209. package/dist/knowledge/permission-ledger.d.ts +11 -0
  210. package/dist/knowledge/permission-ledger.js +1 -403
  211. package/dist/knowledge/permission-puzzle.js +1 -173
  212. package/dist/knowledge/permission-risk.js +1 -411
  213. package/dist/knowledge/permission-templates.js +1 -234
  214. package/dist/knowledge/permission-translation.js +1 -350
  215. package/dist/knowledge/personal-confirm.d.ts +29 -0
  216. package/dist/knowledge/personal-confirm.js +1 -0
  217. package/dist/knowledge/personal-risk.js +1 -212
  218. package/dist/knowledge/personal-translation.d.ts +37 -0
  219. package/dist/knowledge/personal-translation.js +1 -0
  220. package/dist/knowledge/process-model.d.ts +1 -11
  221. package/dist/knowledge/process-model.js +1 -160
  222. package/dist/knowledge/progress-confirm.js +1 -456
  223. package/dist/knowledge/progress-context.js +1 -452
  224. package/dist/knowledge/progress-ledger.js +1 -330
  225. package/dist/knowledge/progress-puzzle.js +1 -219
  226. package/dist/knowledge/progress-risk.js +1 -461
  227. package/dist/knowledge/progress-templates.js +1 -228
  228. package/dist/knowledge/progress-translation.js +1 -405
  229. package/dist/knowledge/proof-confirm.js +1 -187
  230. package/dist/knowledge/proof-context.d.ts +17 -0
  231. package/dist/knowledge/proof-context.js +1 -0
  232. package/dist/knowledge/proof-ledger.d.ts +34 -0
  233. package/dist/knowledge/proof-ledger.js +1 -0
  234. package/dist/knowledge/proof-puzzle.d.ts +35 -0
  235. package/dist/knowledge/proof-puzzle.js +1 -0
  236. package/dist/knowledge/proof-risk.js +1 -207
  237. package/dist/knowledge/proof-templates.d.ts +22 -0
  238. package/dist/knowledge/proof-templates.js +1 -0
  239. package/dist/knowledge/proof-translation.js +1 -283
  240. package/dist/knowledge/registrar-confirm.d.ts +26 -0
  241. package/dist/knowledge/registrar-confirm.js +1 -0
  242. package/dist/knowledge/registrar-risk.js +1 -217
  243. package/dist/knowledge/registrar-translation.d.ts +37 -0
  244. package/dist/knowledge/registrar-translation.js +1 -0
  245. package/dist/knowledge/repository-confirm.js +1 -286
  246. package/dist/knowledge/repository-context.d.ts +12 -0
  247. package/dist/knowledge/repository-context.js +1 -0
  248. package/dist/knowledge/repository-ledger.d.ts +25 -0
  249. package/dist/knowledge/repository-ledger.js +1 -0
  250. package/dist/knowledge/repository-puzzle.d.ts +30 -0
  251. package/dist/knowledge/repository-puzzle.js +1 -0
  252. package/dist/knowledge/repository-risk.js +1 -373
  253. package/dist/knowledge/repository-templates.d.ts +14 -0
  254. package/dist/knowledge/repository-templates.js +1 -0
  255. package/dist/knowledge/repository-translation.js +1 -445
  256. package/dist/knowledge/reputation-rules.js +1 -99
  257. package/dist/knowledge/resource-confirm.d.ts +25 -0
  258. package/dist/knowledge/resource-confirm.js +1 -0
  259. package/dist/knowledge/resource-risk.js +1 -157
  260. package/dist/knowledge/resource-translation.d.ts +37 -0
  261. package/dist/knowledge/resource-translation.js +1 -0
  262. package/dist/knowledge/reward-confirm.js +1 -526
  263. package/dist/knowledge/reward-context.d.ts +2 -2
  264. package/dist/knowledge/reward-context.js +1 -504
  265. package/dist/knowledge/reward-ledger.js +1 -502
  266. package/dist/knowledge/reward-puzzle.js +1 -300
  267. package/dist/knowledge/reward-risk.js +1 -627
  268. package/dist/knowledge/reward-templates.js +1 -197
  269. package/dist/knowledge/reward-translation.js +1 -501
  270. package/dist/knowledge/safety-rules.d.ts +1 -0
  271. package/dist/knowledge/safety-rules.js +1 -404
  272. package/dist/knowledge/scenario-modes.js +1 -321
  273. package/dist/knowledge/service-confirm.js +1 -807
  274. package/dist/knowledge/service-context.js +1 -403
  275. package/dist/knowledge/service-ledger.js +1 -609
  276. package/dist/knowledge/service-puzzle.js +1 -236
  277. package/dist/knowledge/service-risk.d.ts +1 -1
  278. package/dist/knowledge/service-risk.js +1 -651
  279. package/dist/knowledge/service-templates.js +1 -456
  280. package/dist/knowledge/service-translation.js +1 -622
  281. package/dist/knowledge/template-registry.js +1 -353
  282. package/dist/knowledge/tool-constraints.js +1 -195
  283. package/dist/knowledge/tools-reference.js +1 -178
  284. package/dist/knowledge/treasury-confirm.js +1 -512
  285. package/dist/knowledge/treasury-context.js +1 -363
  286. package/dist/knowledge/treasury-ledger.js +1 -300
  287. package/dist/knowledge/treasury-puzzle.js +1 -216
  288. package/dist/knowledge/treasury-risk.js +1 -440
  289. package/dist/knowledge/treasury-templates.js +1 -358
  290. package/dist/knowledge/treasury-translation.js +1 -498
  291. package/dist/knowledge/trust-metrics.js +1 -198
  292. package/dist/knowledge/universal-template.d.ts +22 -0
  293. package/dist/knowledge/universal-template.js +1 -0
  294. package/dist/knowledge/util-confirm.d.ts +24 -0
  295. package/dist/knowledge/util-confirm.js +1 -0
  296. package/dist/knowledge/util-risk.js +1 -135
  297. package/dist/knowledge/util-translation.d.ts +38 -0
  298. package/dist/knowledge/util-translation.js +1 -0
  299. package/dist/knowledge/workflow-guidance.d.ts +116 -0
  300. package/dist/knowledge/workflow-guidance.js +1 -0
  301. package/dist/loop-engineering/aggregate.js +1 -132
  302. package/dist/loop-engineering/context-collect.js +1 -83
  303. package/dist/loop-engineering/diagnose.js +1 -273
  304. package/dist/loop-engineering/improve.js +1 -405
  305. package/dist/loop-engineering/index.js +1 -4
  306. package/dist/loop-engineering/pipeline.js +1 -56
  307. package/dist/mode-market/index.js +1 -3
  308. package/dist/mode-market/registry.js +1 -124
  309. package/dist/mode-market/review.js +1 -214
  310. package/dist/mode-market/submission.js +1 -85
  311. package/dist/participation/collaborator-interest.d.ts +23 -0
  312. package/dist/participation/collaborator-interest.js +1 -0
  313. package/dist/participation/customer-interest.d.ts +25 -0
  314. package/dist/participation/customer-interest.js +1 -0
  315. package/dist/participation/employee-kpi.d.ts +25 -0
  316. package/dist/participation/employee-kpi.js +1 -0
  317. package/dist/participation/employee-store.d.ts +16 -0
  318. package/dist/participation/employee-store.js +1 -0
  319. package/dist/participation/index.d.ts +2 -0
  320. package/dist/participation/index.js +1 -0
  321. package/dist/participation/merchant-interest.js +1 -100
  322. package/dist/participation/radar-core.d.ts +13 -3
  323. package/dist/participation/radar-core.js +1 -269
  324. package/dist/participation/supplier-interest.d.ts +25 -0
  325. package/dist/participation/supplier-interest.js +1 -0
  326. package/dist/persona/analyzer.js +1 -66
  327. package/dist/persona/bridge.js +1 -86
  328. package/dist/persona/defaults.js +1 -195
  329. package/dist/persona/experience-bridge.js +1 -23
  330. package/dist/persona/index.d.ts +9 -2
  331. package/dist/persona/index.js +1 -71
  332. package/dist/persona/local-region.d.ts +20 -0
  333. package/dist/persona/local-region.js +1 -0
  334. package/dist/persona/model.js +1 -111
  335. package/dist/persona/overrides.d.ts +10 -0
  336. package/dist/persona/overrides.js +1 -0
  337. package/dist/persona/pack-personae.d.ts +11 -0
  338. package/dist/persona/pack-personae.js +1 -0
  339. package/dist/persona/store.js +1 -62
  340. package/dist/persona/strategy-intent.d.ts +20 -0
  341. package/dist/persona/strategy-intent.js +1 -0
  342. package/dist/persona/types.d.ts +6 -2
  343. package/dist/persona/types.js +1 -5
  344. package/dist/project/business-puzzle.d.ts +1 -1
  345. package/dist/project/business-puzzle.js +1 -383
  346. package/dist/project/context-assembly.js +1 -254
  347. package/dist/project/deployment-bridge.js +1 -120
  348. package/dist/project/deployment-doc.js +1 -1126
  349. package/dist/project/edit-planner.js +1 -1342
  350. package/dist/project/evaluation.d.ts +37 -1
  351. package/dist/project/evaluation.js +1 -2011
  352. package/dist/project/game-theory.js +1 -177
  353. package/dist/project/graph-builder.js +1 -656
  354. package/dist/project/graph.d.ts +3 -6
  355. package/dist/project/graph.js +1 -340
  356. package/dist/project/handlers.d.ts +33 -2
  357. package/dist/project/handlers.js +1 -1784
  358. package/dist/project/index.d.ts +2 -0
  359. package/dist/project/index.js +1 -301
  360. package/dist/project/intent-analyzer.js +1 -149
  361. package/dist/project/machine-nodes.js +1 -36
  362. package/dist/project/merchant-guide.d.ts +19 -0
  363. package/dist/project/merchant-guide.js +1 -264
  364. package/dist/project/migration.js +1 -125
  365. package/dist/project/mode-actions.js +1 -309
  366. package/dist/project/namespace.js +1 -206
  367. package/dist/project/participation-radar.js +1 -428
  368. package/dist/project/pipeline-actions.js +1 -109
  369. package/dist/project/project-store.js +1 -422
  370. package/dist/project/query.js +1 -153
  371. package/dist/project/reverse-mapping.d.ts +34 -0
  372. package/dist/project/reverse-mapping.js +1 -0
  373. package/dist/project/risk-aggregator.js +1 -295
  374. package/dist/project/rollback-policy.js +1 -290
  375. package/dist/project/semantic-assembler.js +1 -345
  376. package/dist/project/semantic-graph.d.ts +3 -5
  377. package/dist/project/semantic-graph.js +1 -292
  378. package/dist/project/stage-gate.js +1 -369
  379. package/dist/project/substep-trace.js +1 -332
  380. package/dist/project/task-tracker.js +1 -78
  381. package/dist/project/workflow-design-assessment.d.ts +24 -0
  382. package/dist/project/workflow-design-assessment.js +1 -0
  383. package/dist/role/derivation.d.ts +18 -0
  384. package/dist/role/derivation.js +1 -0
  385. package/dist/role/index.d.ts +5 -0
  386. package/dist/role/index.js +1 -0
  387. package/dist/role/model.d.ts +8 -0
  388. package/dist/role/model.js +1 -0
  389. package/dist/role/resolution.d.ts +11 -0
  390. package/dist/role/resolution.js +1 -0
  391. package/dist/role/types.d.ts +11 -0
  392. package/dist/role/types.js +1 -0
  393. package/dist/rules.js +1 -52
  394. package/dist/safety/confirm-gate.d.ts +1 -1
  395. package/dist/safety/confirm-gate.js +1 -88
  396. package/dist/safety/index.js +1 -3
  397. package/dist/safety/preview.js +1 -52
  398. package/dist/schema/call/allocation.d.ts +186 -1385
  399. package/dist/schema/call/allocation.js +1 -34
  400. package/dist/schema/call/arbitration.d.ts +272 -1871
  401. package/dist/schema/call/arbitration.js +1 -113
  402. package/dist/schema/call/base.d.ts +1831 -9076
  403. package/dist/schema/call/base.js +1 -370
  404. package/dist/schema/call/bridge.d.ts +911 -3171
  405. package/dist/schema/call/bridge.js +1 -458
  406. package/dist/schema/call/contact.d.ts +135 -931
  407. package/dist/schema/call/contact.js +1 -37
  408. package/dist/schema/call/demand.d.ts +164 -1194
  409. package/dist/schema/call/demand.js +1 -47
  410. package/dist/schema/call/guard.d.ts +298 -1140
  411. package/dist/schema/call/guard.js +1 -161
  412. package/dist/schema/call/handler.js +1 -322
  413. package/dist/schema/call/index.js +1 -20
  414. package/dist/schema/call/machine.d.ts +459 -5403
  415. package/dist/schema/call/machine.js +1 -193
  416. package/dist/schema/call/order.d.ts +137 -844
  417. package/dist/schema/call/order.js +1 -35
  418. package/dist/schema/call/payment.d.ts +74 -561
  419. package/dist/schema/call/payment.js +1 -37
  420. package/dist/schema/call/permission-handler.js +1 -54
  421. package/dist/schema/call/permission.d.ts +335 -2791
  422. package/dist/schema/call/permission.js +1 -105
  423. package/dist/schema/call/personal.d.ts +227 -1814
  424. package/dist/schema/call/personal.js +1 -78
  425. package/dist/schema/call/progress.d.ts +140 -843
  426. package/dist/schema/call/progress.js +1 -47
  427. package/dist/schema/call/proof.d.ts +42 -258
  428. package/dist/schema/call/proof.js +1 -33
  429. package/dist/schema/call/repository.d.ts +324 -2222
  430. package/dist/schema/call/repository.js +1 -77
  431. package/dist/schema/call/reward.d.ts +153 -1183
  432. package/dist/schema/call/reward.js +1 -30
  433. package/dist/schema/call/semantic.js +1 -1679
  434. package/dist/schema/call/service.d.ts +376 -3431
  435. package/dist/schema/call/service.js +1 -184
  436. package/dist/schema/call/treasury.d.ts +252 -2158
  437. package/dist/schema/call/treasury.js +1 -71
  438. package/dist/schema/common/index.d.ts +222 -697
  439. package/dist/schema/common/index.js +1 -407
  440. package/dist/schema/config/index.d.ts +18 -161
  441. package/dist/schema/config/index.js +1 -68
  442. package/dist/schema/employee/index.d.ts +99 -0
  443. package/dist/schema/employee/index.js +1 -0
  444. package/dist/schema/evaluation/index.d.ts +1062 -3748
  445. package/dist/schema/evaluation/index.js +1 -356
  446. package/dist/schema/index.d.ts +3 -0
  447. package/dist/schema/index.js +1 -17
  448. package/dist/schema/industry-pack/index.d.ts +132 -0
  449. package/dist/schema/industry-pack/index.js +1 -0
  450. package/dist/schema/intent-radar/index.d.ts +92 -245
  451. package/dist/schema/intent-radar/index.js +1 -89
  452. package/dist/schema/local/index.d.ts +2045 -18080
  453. package/dist/schema/local/index.js +1 -927
  454. package/dist/schema/local/wip.d.ts +61 -651
  455. package/dist/schema/local/wip.js +1 -187
  456. package/dist/schema/messenger/index.d.ts +949 -5557
  457. package/dist/schema/messenger/index.js +1 -475
  458. package/dist/schema/operations.d.ts +2969 -26518
  459. package/dist/schema/operations.js +1 -520
  460. package/dist/schema/persona/index.d.ts +469 -1820
  461. package/dist/schema/persona/index.js +1 -148
  462. package/dist/schema/project/index.d.ts +1027 -8408
  463. package/dist/schema/project/index.js +1 -2057
  464. package/dist/schema/query/index.d.ts +12041 -75261
  465. package/dist/schema/query/index.js +1 -1646
  466. package/dist/schema/schema-query/index.d.ts +35 -98
  467. package/dist/schema/schema-query/index.js +1 -104
  468. package/dist/schema/schema-version.js +1 -76
  469. package/dist/schema/task-status.d.ts +26 -132
  470. package/dist/schema/task-status.js +1 -36
  471. package/dist/schema/trust/index.d.ts +194 -1290
  472. package/dist/schema/trust/index.js +1 -314
  473. package/dist/schema/utils/guard-parser.js +1 -419
  474. package/dist/schema/utils/guard-query-utils.js +1 -46
  475. package/dist/schema/utils/node-parser.js +1 -369
  476. package/dist/schema/utils/object-type-utils.js +1 -35
  477. package/dist/schema/utils/permission-index-utils.js +1 -7
  478. package/dist/schema/utils/permission-machine-check.js +1 -121
  479. package/dist/schema/utils/skills-recommendation.d.ts +1 -0
  480. package/dist/schema/utils/skills-recommendation.js +1 -77
  481. package/dist/schema/workspace/index.d.ts +69 -0
  482. package/dist/schema/workspace/index.js +1 -0
  483. package/dist/schema-query-impl/index.js +1 -0
  484. package/dist/schemas/account_operation.output.json +3147 -1652
  485. package/dist/schemas/account_operation.schema.json +225 -218
  486. package/dist/schemas/bridge_operation.output.json +1168 -650
  487. package/dist/schemas/bridge_operation.schema.json +736 -504
  488. package/dist/schemas/config_operation.output.json +185 -179
  489. package/dist/schemas/config_operation.schema.json +21 -26
  490. package/dist/schemas/employee_operation.output.json +207 -0
  491. package/dist/schemas/employee_operation.schema.json +176 -0
  492. package/dist/schemas/evaluation_operation.output.json +2329 -557
  493. package/dist/schemas/evaluation_operation.schema.json +2939 -720
  494. package/dist/schemas/guard2file.output.json +58 -64
  495. package/dist/schemas/guard2file.schema.json +79 -81
  496. package/dist/schemas/index.json +29 -11
  497. package/dist/schemas/industry_pack_operation.output.json +594 -0
  498. package/dist/schemas/industry_pack_operation.schema.json +55 -0
  499. package/dist/schemas/intent_radar.output.json +275 -200
  500. package/dist/schemas/intent_radar.schema.json +124 -123
  501. package/dist/schemas/local_info_operation.output.json +1174 -657
  502. package/dist/schemas/local_info_operation.schema.json +119 -125
  503. package/dist/schemas/local_mark_operation.output.json +1239 -689
  504. package/dist/schemas/local_mark_operation.schema.json +91 -96
  505. package/dist/schemas/machineNode2file.output.json +63 -69
  506. package/dist/schemas/machineNode2file.schema.json +79 -81
  507. package/dist/schemas/messenger_operation.output.json +2722 -1528
  508. package/dist/schemas/messenger_operation.schema.json +1482 -1264
  509. package/dist/schemas/onchain_events.output.json +2590 -975
  510. package/dist/schemas/onchain_events.schema.json +117 -99
  511. package/dist/schemas/onchain_operations.output.json +3957 -2309
  512. package/dist/schemas/onchain_operations.schema.json +20799 -9285
  513. package/dist/schemas/onchain_operations_allocation.schema.json +172 -108
  514. package/dist/schemas/onchain_operations_arbitration.schema.json +233 -146
  515. package/dist/schemas/onchain_operations_contact.schema.json +129 -90
  516. package/dist/schemas/onchain_operations_demand.schema.json +170 -112
  517. package/dist/schemas/onchain_operations_gen_passport.schema.json +61 -646
  518. package/dist/schemas/onchain_operations_gen_proof.schema.json +40 -172
  519. package/dist/schemas/onchain_operations_guard.schema.json +3765 -294
  520. package/dist/schemas/onchain_operations_machine.schema.json +537 -164
  521. package/dist/schemas/onchain_operations_order.schema.json +126 -96
  522. package/dist/schemas/onchain_operations_payment.schema.json +82 -67
  523. package/dist/schemas/onchain_operations_permission.schema.json +331 -93
  524. package/dist/schemas/onchain_operations_personal.schema.json +636 -96
  525. package/dist/schemas/onchain_operations_progress.schema.json +125 -92
  526. package/dist/schemas/onchain_operations_proof.schema.json +76 -69
  527. package/dist/schemas/onchain_operations_repository.schema.json +636 -249
  528. package/dist/schemas/onchain_operations_reward.schema.json +218 -108
  529. package/dist/schemas/onchain_operations_service.schema.json +679 -221
  530. package/dist/schemas/onchain_operations_treasury.schema.json +401 -135
  531. package/dist/schemas/onchain_table_data.output.json +6018 -2430
  532. package/dist/schemas/onchain_table_data.schema.json +544 -430
  533. package/dist/schemas/persona_operation.output.json +1568 -265
  534. package/dist/schemas/persona_operation.schema.json +346 -202
  535. package/dist/schemas/project_operation.output.json +6957 -5147
  536. package/dist/schemas/project_operation.schema.json +1050 -1020
  537. package/dist/schemas/query_task_status.output.json +195 -99
  538. package/dist/schemas/query_task_status.schema.json +12 -18
  539. package/dist/schemas/query_toolkit.output.json +18870 -14566
  540. package/dist/schemas/query_toolkit.schema.json +614 -522
  541. package/dist/schemas/schema_query.output.json +127 -129
  542. package/dist/schemas/schema_query.schema.json +64 -69
  543. package/dist/schemas/trust_score.output.json +678 -587
  544. package/dist/schemas/trust_score.schema.json +289 -277
  545. package/dist/schemas/wip_file.output.json +116 -124
  546. package/dist/schemas/wip_file.schema.json +142 -143
  547. package/dist/schemas/workspace_operation.output.json +277 -0
  548. package/dist/schemas/workspace_operation.schema.json +45 -0
  549. package/dist/schemas/wowok_buildin_info.output.json +1693 -723
  550. package/dist/schemas/wowok_buildin_info.schema.json +576 -512
  551. package/dist/telemetry/index.js +1 -112
  552. package/dist/telemetry/redact.js +1 -23
  553. package/dist/telemetry/storage.js +1 -80
  554. package/dist/tools/handlers/bridge.d.ts +8 -1
  555. package/dist/tools/handlers/bridge.js +1 -1
  556. package/dist/tools/handlers/config.js +1 -74
  557. package/dist/tools/handlers/employee.d.ts +2 -0
  558. package/dist/tools/handlers/employee.js +1 -0
  559. package/dist/tools/handlers/evaluation.js +1 -123
  560. package/dist/tools/handlers/file-export.js +1 -90
  561. package/dist/tools/handlers/industry-pack.d.ts +2 -0
  562. package/dist/tools/handlers/industry-pack.js +1 -0
  563. package/dist/tools/handlers/intent-radar.js +1 -76
  564. package/dist/tools/handlers/local.js +1 -53
  565. package/dist/tools/handlers/messenger.js +1 -188
  566. package/dist/tools/handlers/onchain.js +1 -1180
  567. package/dist/tools/handlers/persona.js +1 -89
  568. package/dist/tools/handlers/project.js +1 -211
  569. package/dist/tools/handlers/query.js +1 -434
  570. package/dist/tools/handlers/schema-query.js +1 -176
  571. package/dist/tools/handlers/task-status.js +1 -26
  572. package/dist/tools/handlers/trust.js +1 -380
  573. package/dist/tools/handlers/wip.js +1 -90
  574. package/dist/tools/handlers/workspace.d.ts +2 -0
  575. package/dist/tools/handlers/workspace.js +1 -0
  576. package/dist/tools/index.d.ts +2 -1
  577. package/dist/tools/index.js +1 -1382
  578. package/dist/tools/retry.js +1 -85
  579. package/dist/tools/rules-hook.d.ts +1 -1
  580. package/dist/tools/rules-hook.js +1 -23
  581. package/dist/tools/shared.d.ts +1 -1
  582. package/dist/tools/shared.js +1 -130
  583. package/dist/tools/types.d.ts +2 -1
  584. package/dist/tools/types.js +1 -1
  585. package/dist/tools/upgrade-check.d.ts +19 -0
  586. package/dist/tools/upgrade-check.js +1 -0
  587. package/dist/tools/wip-deploy-assist.js +1 -306
  588. package/dist/tools/wrap.js +1 -500
  589. package/package.json +7 -6
  590. package/dist/knowledge/arbitration-trust.d.ts +0 -24
  591. package/dist/knowledge/arbitration-trust.js +0 -117
  592. package/dist/schema/call/bridge-handler.d.ts +0 -8
  593. package/dist/schema/call/bridge-handler.js +0 -265
  594. package/dist/schema/sync-layer4.d.ts +0 -21
  595. package/dist/schema/sync-layer4.js +0 -286
  596. package/dist/schema-query/index.js +0 -810
  597. /package/dist/{schema-query → schema-query-impl}/index.d.ts +0 -0
@@ -1,669 +1 @@
1
- import { USER_DEFINED_PERM_INDEX_START, MAX_NODE_COUNT } from "./onchain-constants.js";
2
- export const MACHINE_RISK_RULES = [
3
- {
4
- id: "R-M1-01",
5
- name: "No entry point",
6
- category: "structural",
7
- severity: "critical",
8
- description: "Machine has no Pair with prev_node='' (no entry point). Workflow cannot start.",
9
- detection: "Check if any pair has prev_node === ''",
10
- recommendation: "Add at least one Pair with prev_node='' to serve as entry point.",
11
- auto_fixable: false,
12
- related_constraint: "MC-S-01",
13
- },
14
- {
15
- id: "R-M1-02",
16
- name: "No terminal node",
17
- category: "structural",
18
- severity: "critical",
19
- description: "Machine has no terminal node (all nodes have outgoing Pairs). Workflow never completes.",
20
- detection: "Check if any node has no outgoing Pair",
21
- recommendation: "Designate at least one node as terminal (no outgoing Pair) and bind Allocator to it.",
22
- auto_fixable: false,
23
- related_constraint: "MC-S-02",
24
- },
25
- {
26
- id: "R-M1-03",
27
- name: "Dead-end node (non-terminal)",
28
- category: "structural",
29
- severity: "medium",
30
- description: "Non-terminal node has no outgoing Pair. Workflow stalls at this node.",
31
- detection: "Find nodes with no outgoing Pair that are not intended terminals",
32
- recommendation: "Add outgoing Pair or designate as terminal with Allocator.",
33
- auto_fixable: false,
34
- },
35
- {
36
- id: "R-M1-04",
37
- name: "Orphaned node",
38
- category: "structural",
39
- severity: "high",
40
- description: "Node has no incoming Pair (except entry). Unreachable.",
41
- detection: "Find non-entry nodes with no incoming Pair",
42
- recommendation: "Add Pair from existing node to this orphaned node, or remove it.",
43
- auto_fixable: false,
44
- related_constraint: "MC-S-03",
45
- },
46
- {
47
- id: "R-M1-05",
48
- name: "Dead branch (competing Pair always loses)",
49
- category: "structural",
50
- severity: "high",
51
- description: "A competing Pair's threshold can never be met because users always prefer another path.",
52
- detection: "Analyze threshold achievability across competing Pairs",
53
- recommendation: "Make thresholds balanced, or remove the dead branch.",
54
- auto_fixable: false,
55
- related_constraint: "MC-S-04",
56
- },
57
- {
58
- id: "R-M1-06",
59
- name: "Cycle in DAG",
60
- category: "structural",
61
- severity: "critical",
62
- description: "Workflow has a cycle. Nodes reference each other circularly.",
63
- detection: "DFS cycle detection",
64
- recommendation: "Break the cycle by removing one Pair.",
65
- auto_fixable: false,
66
- related_constraint: "MC-S-05",
67
- },
68
- {
69
- id: "R-M1-07",
70
- name: "Exceeds MAX_NODE_COUNT (100)",
71
- category: "structural",
72
- severity: "critical",
73
- description: "Node count exceeds on-chain limit. Publish will fail.",
74
- detection: `nodes.length > ${MAX_NODE_COUNT}`,
75
- recommendation: "Reduce node count or split into multiple Machines.",
76
- auto_fixable: false,
77
- related_constraint: "MC-C-01",
78
- },
79
- {
80
- id: "R-M1-08",
81
- name: "Exceeds MAX_NODE_PAIR_COUNT (40)",
82
- category: "structural",
83
- severity: "high",
84
- description: "A single node's Pairs exceed on-chain limit. Publish will fail.",
85
- detection: "Find node where pairs.length > 40",
86
- recommendation: "Split node or simplify branches to reduce Pair count per node.",
87
- auto_fixable: false,
88
- related_constraint: "MC-C-02",
89
- },
90
- {
91
- id: "R-M1-09",
92
- name: "Exceeds MAX_FORWARD_COUNT (20)",
93
- category: "structural",
94
- severity: "high",
95
- description: "A single Pair's Forwards exceed on-chain limit. Publish will fail.",
96
- detection: "Find Pair where forwards.length > 20",
97
- recommendation: "Split Pair or merge Forwards to reduce Forward count per Pair.",
98
- auto_fixable: false,
99
- related_constraint: "MC-C-03",
100
- },
101
- {
102
- id: "R-M1-10",
103
- name: "Duplicate node name",
104
- category: "structural",
105
- severity: "critical",
106
- description: "Two nodes have the same name. On-chain will reject.",
107
- detection: "Find duplicate names in nodes array",
108
- recommendation: "Rename one of the duplicates.",
109
- auto_fixable: false,
110
- related_constraint: "MC-C-04",
111
- },
112
- {
113
- id: "R-M1-11",
114
- name: "Dispute anti-pattern — machine illegally models dispute flow",
115
- category: "structural",
116
- severity: "critical",
117
- description: "Machine contains nodes named 'disputed', 'refunded', 'arb', 'arbitration', " +
118
- "'dispute', or 'refund'. This is a CRITICAL design anti-pattern because " +
119
- "dispute is INDEPENDENT of the machine workflow. Dispute flows through: " +
120
- "Order → Arbitration.dispute() → Arb object → arbitration() ruling → " +
121
- "arb_withdraw by order holder. Arbitrators are configured in " +
122
- "Arbitration.voting_guard, NOT in Permission. Merchants who model " +
123
- "dispute in the machine (e.g., 'disputed → refunded' forward guarded " +
124
- "by Permission index 1500) create dead-end paths because no one has " +
125
- "Permission 1500 — arbitrators are NOT Permission holders.",
126
- detection: "Match node names against regex /(^|_)(disputed?|refund(?:ed)?|arbitration|arb)(_|$)/i " +
127
- "(catches both exact names like 'refunded' and compound fund-flow terminals like " +
128
- "'deposit_refunded'/'deposit_deducted'; business states like 'return_approved'/" +
129
- "'damage_confirmed'/'cancelled'/'returned' do NOT match)",
130
- recommendation: "Remove all dispute/refund nodes from the machine. Instead: (1) bind an " +
131
- "Arbitration object to the Service via Service.arbitrations, (2) configure " +
132
- "arbitrators via Arbitration.voting_guard_add, (3) deposit compensation_fund " +
133
- "to the Service. Disputes are then filed via arbitration::dispute(order, " +
134
- "arbitration) — completely independent of the machine workflow.",
135
- auto_fixable: false,
136
- },
137
- {
138
- id: "R-M2-01",
139
- name: "Guard not created",
140
- category: "guard_integration",
141
- severity: "critical",
142
- description: "Forward references a Guard that is not yet created on-chain. Forward execution will fail Guard verification.",
143
- detection: "Check forward.guard against published_guards set",
144
- recommendation: "Create the Guard object before publishing this Machine.",
145
- auto_fixable: false,
146
- related_constraint: "MC-C-09",
147
- },
148
- {
149
- id: "R-M2-02",
150
- name: "Guard not tested via gen_passport",
151
- category: "guard_integration",
152
- severity: "high",
153
- description: "Guard has not been tested via gen_passport. Guard may have bugs, cannot be fixed after publish.",
154
- detection: "Check testnet test records for this Guard",
155
- recommendation: "Run gen_passport on testnet before binding to Machine.",
156
- auto_fixable: false,
157
- },
158
- {
159
- id: "R-M2-03",
160
- name: "Guard + Machine immutability deadlock",
161
- category: "guard_integration",
162
- severity: "critical",
163
- description: "After Machine publish, a Guard bug is discovered. Guard is immutable (cannot be fixed), Machine is immutable (cannot be rebound).",
164
- detection: "Verify all Guards tested before Machine publish",
165
- recommendation: "Keep Machine unpublished until all Guards are verified.",
166
- auto_fixable: false,
167
- },
168
- {
169
- id: "R-M2-04",
170
- name: "retained_submission index mismatch",
171
- category: "guard_integration",
172
- severity: "high",
173
- description: "Forward's retained_submission key does not correspond to Guard table b_submission=true entry. Retained data fails or is incorrect.",
174
- detection: "Cross-check forward.retained_submission against Guard table entries",
175
- recommendation: "Align retained_submission key with Guard table b_submission=true identifier.",
176
- auto_fixable: true,
177
- related_constraint: "MC-C-11",
178
- },
179
- {
180
- id: "R-M2-05",
181
- name: "Guard reentry risk",
182
- category: "guard_integration",
183
- severity: "high",
184
- description: "Guard lacks anti-reentry mechanism (see Guard R-X1-14). Risk of duplicate execution or vote manipulation.",
185
- detection: "For each Guard scene, verify anti-reentry Guard is configured (see Guard semantic layer R-X1-14)",
186
- recommendation: "Add anti-reentry Guard for each scenario (see Guard semantic layer R-X1-14).",
187
- auto_fixable: false,
188
- },
189
- {
190
- id: "R-M2-06",
191
- name: "Guard scene mismatch",
192
- category: "guard_integration",
193
- severity: "medium",
194
- description: "Forward's bound Guard scene does not match Forward's business (e.g., Forward uses reward_guard instead of machine_forward_guard).",
195
- detection: "Cross-check Guard scene against Forward business purpose",
196
- recommendation: "Use the correct Guard scene (machine_forward_guard).",
197
- auto_fixable: false,
198
- },
199
- {
200
- id: "R-M2-07",
201
- name: "Cross-Machine Guard dependency cycle",
202
- category: "guard_integration",
203
- severity: "critical",
204
- description: "Machine A depends on Machine B (via Guard), B depends on A. Circular dependency.",
205
- detection: "Identify cross-Machine Guard references and detect cycles",
206
- recommendation: "Ensure cross-Machine dependencies are unidirectional.",
207
- auto_fixable: false,
208
- },
209
- {
210
- id: "R-M2-08",
211
- name: "Guard references unpublished object",
212
- category: "guard_integration",
213
- severity: "high",
214
- description: "Guard table references an object (e.g., Service) that is not yet published.",
215
- detection: "Cross-check Guard table object references against published objects set",
216
- recommendation: "Use P16 circular reference pattern (name instead of address), or publish referenced objects first.",
217
- auto_fixable: false,
218
- },
219
- {
220
- id: "R-M3-01",
221
- name: "Forward without permission",
222
- category: "permission",
223
- severity: "critical",
224
- description: "Forward has neither namedOperator nor permissionIndex. Cannot be executed.",
225
- detection: "Check each forward has at least one of namedOperator or permissionIndex",
226
- recommendation: "Set namedOperator='' for OrderHolder, or set permissionIndex.",
227
- auto_fixable: false,
228
- related_constraint: "MC-C-07",
229
- },
230
- {
231
- id: "R-M3-02",
232
- name: "permissionIndex out of bounds",
233
- category: "permission",
234
- severity: "critical",
235
- description: "Forward's permissionIndex >= Permission.indices.length. Execution will fail.",
236
- detection: "Check permission_index < Permission.indices.length",
237
- recommendation: "Use a valid permission index or extend Permission.indices.",
238
- auto_fixable: false,
239
- related_constraint: "MC-C-08",
240
- },
241
- {
242
- id: "R-M3-03",
243
- name: "Permission rotation failure",
244
- category: "permission",
245
- severity: "high",
246
- description: "Permission object updated, indices order changed. Original permissionIndex now points to wrong permission.",
247
- detection: "Detect Permission object update that reorders indices",
248
- recommendation: "Use custom Permission; document index meanings; avoid frequent Permission updates.",
249
- auto_fixable: false,
250
- },
251
- {
252
- id: "R-M3-04",
253
- name: "OrderHolder misuse",
254
- category: "permission",
255
- severity: "medium",
256
- description: "namedOperator='' used in non-customer-operation scenarios. Non-intended personnel gain operation permission.",
257
- detection: "Find Forwards with namedOperator='' on non-customer-operation nodes",
258
- recommendation: "Clarify ''=OrderHolder (customer), not 'anyone'. Use namedOperator for specific roles.",
259
- auto_fixable: false,
260
- },
261
- {
262
- id: "R-M3-05",
263
- name: "NamedOperator not assigned at Progress creation",
264
- category: "permission",
265
- severity: "high",
266
- description: "Forward expects namedOperator role but Progress doesn't have it assigned. " +
267
- "Note: MCP API layer supports progress_new.progress_namedOperator (SDK translates to namedOperator_add), " +
268
- "but Move layer progress::new does NOT accept it (see 06 §14.5).",
269
- detection: "Verify progress_namedOperator is provided in Progress creation",
270
- recommendation: "Pass progress_namedOperator in progress_new, or call namedOperator_add separately.",
271
- auto_fixable: false,
272
- },
273
- {
274
- id: "R-M3-06",
275
- name: "Permission game imbalance",
276
- category: "permission",
277
- severity: "medium",
278
- description: "One party has excessive permission, can unilaterally advance workflow. Game theory imbalance.",
279
- detection: "Analyze permission distribution across parties",
280
- recommendation: "Use dual-signature (threshold=2) or multi-signature mechanism to balance power.",
281
- auto_fixable: false,
282
- },
283
- {
284
- id: "R-M3-07",
285
- name: "Permission combination OR semantic misuse",
286
- category: "permission",
287
- severity: "medium",
288
- description: "Both namedOperator and permissionIndex set, but OR semantic not understood. More people than expected can execute Forward.",
289
- detection: "Find Forwards with both namedOperator and permissionIndex set",
290
- recommendation: "Clarify that when both permissions are non-null, it is OR relation (either can execute).",
291
- auto_fixable: false,
292
- },
293
- {
294
- id: "R-M3-08",
295
- name: "permissionIndex below USER_DEFINED_PERM_INDEX_START (1000)",
296
- category: "permission",
297
- severity: "critical",
298
- description: "Forward's permissionIndex < 1000. On-chain constant USER_DEFINED_PERM_INDEX_START = 1000 " +
299
- "in permission.move reserves indexes 0-999 for built-in permissions. Using index < 1000 " +
300
- "causes confusion with built-in permissions and is a hard on-chain constraint (see doc 06 §4.4).",
301
- detection: "Check each forward with permission_index < 1000",
302
- recommendation: "Use permission_index >= 1000 (e.g., 1000, 1001, 1002, ...). Reserve 0-999 for built-in permissions.",
303
- auto_fixable: false,
304
- related_constraint: "MC-C-08",
305
- },
306
- {
307
- id: "R-M4-01",
308
- name: "No backup before publish",
309
- category: "immutability",
310
- severity: "high",
311
- description: "machineNode2file export not created before publish. Cannot restore if publish fails.",
312
- detection: "Check backup_created flag",
313
- recommendation: "Run machineNode2file before publish to create backup.",
314
- auto_fixable: true,
315
- related_constraint: "MC-P-02",
316
- },
317
- {
318
- id: "R-M4-02",
319
- name: "No testnet verification before mainnet",
320
- category: "immutability",
321
- severity: "medium",
322
- description: "Directly publishing to mainnet without testnet verification. Potential bugs may cause fund loss.",
323
- detection: "Check network === 'mainnet' && !testnet_test_passed",
324
- recommendation: "Test on testnet first. Verify Progress runs end-to-end.",
325
- auto_fixable: false,
326
- related_constraint: "MC-P-03",
327
- },
328
- {
329
- id: "R-M4-03",
330
- name: "Guards not all created before publish",
331
- category: "immutability",
332
- severity: "critical",
333
- description: "Some Forward.guard is still null, but design requires Guard. Cannot add Guard after publish (immutability deadlock).",
334
- detection: "Check if all required Guards are created and bound",
335
- recommendation: "Create and bind all Guards before publishing Machine.",
336
- auto_fixable: false,
337
- },
338
- {
339
- id: "R-M4-04",
340
- name: "Publish order incorrect",
341
- category: "immutability",
342
- severity: "critical",
343
- description: "Attempting to publish Machine before creating Guards. Guards cannot bind to already-published Machine.",
344
- detection: "Verify dependency order: Permission → Machine(unpublished) → Guard → bind → publish",
345
- recommendation: "Follow dependency order: Permission → Machine(unpublished) → Guard → bind → publish.",
346
- auto_fixable: false,
347
- },
348
- {
349
- id: "R-M4-05",
350
- name: "Allocation not configured",
351
- category: "immutability",
352
- severity: "medium",
353
- description: "Terminal node not mapped to Allocator. Funds cannot be distributed after workflow completes.",
354
- detection: "Check if terminal nodes have Allocator mapping",
355
- recommendation: "Configure Allocator for each terminal node.",
356
- auto_fixable: false,
357
- },
358
- {
359
- id: "R-M4-06",
360
- name: "clear operation without backup",
361
- category: "immutability",
362
- severity: "high",
363
- description: "Executing node clear before exporting backup. All node data lost, cannot recover.",
364
- detection: "Check if machineNode2file backup created before clear operation",
365
- recommendation: "Run machineNode2file backup before any clear operation.",
366
- auto_fixable: true,
367
- },
368
- {
369
- id: "R-M5-01",
370
- name: "Service not created",
371
- category: "environment",
372
- severity: "high",
373
- description: "Machine design complete but Service not created. Machine cannot bind to Service.",
374
- detection: "Check if Service object is in published_services set",
375
- recommendation: "Create Service first, then design/publish Machine.",
376
- auto_fixable: false,
377
- },
378
- {
379
- id: "R-M5-02",
380
- name: "Permission object mismatch",
381
- category: "environment",
382
- severity: "high",
383
- description: "Machine's Permission differs from Service's Permission. Permission organization inconsistent, may cause operation failure.",
384
- detection: "Cross-check Machine's Permission against Service's Permission",
385
- recommendation: "Use the same Permission for Machine and Service (or explicitly document different organizations).",
386
- auto_fixable: false,
387
- },
388
- {
389
- id: "R-M5-03",
390
- name: "Allocation configuration incomplete",
391
- category: "environment",
392
- severity: "high",
393
- description: "Service's order_allocators not configured or misconfigured. Terminal node funds cannot be distributed.",
394
- detection: "Check if Service.order_allocators is configured for each terminal node",
395
- recommendation: "Configure Service.order_allocators, one Allocator per terminal node.",
396
- auto_fixable: false,
397
- },
398
- {
399
- id: "R-M5-04",
400
- name: "Reward object not created",
401
- category: "environment",
402
- severity: "medium",
403
- description: "Reward incentive scenario referenced but Reward object not created.",
404
- detection: "Check if Reward object is in published_rewards set",
405
- recommendation: "Create Reward object first, then design Guard.",
406
- auto_fixable: false,
407
- },
408
- {
409
- id: "R-M5-05",
410
- name: "Arbitration object not created",
411
- category: "environment",
412
- severity: "medium",
413
- description: "Arbitration scenario referenced but Arbitration object not created.",
414
- detection: "Check if Arbitration object is in published_arbitrations set",
415
- recommendation: "Create Arbitration object first.",
416
- auto_fixable: false,
417
- },
418
- {
419
- id: "R-M5-06",
420
- name: "Cross-Machine dependency not published",
421
- category: "environment",
422
- severity: "critical",
423
- description: "Machine A depends on Machine B, but B is not published. Guard query for Machine B's Progress will fail. " +
424
- "Dependency verification: indirect via progress::new -> assert_published (see 06 §14.6).",
425
- detection: "Check machine_ref against published_machines set",
426
- recommendation: "Ensure upstream Machine is published first.",
427
- auto_fixable: false,
428
- },
429
- {
430
- id: "R-M5-07",
431
- name: "Repository not created",
432
- category: "environment",
433
- severity: "medium",
434
- description: "Guard references Repository but not created. Guard query will fail.",
435
- detection: "Check repository_ref against published repositories set",
436
- recommendation: "Create and publish Repository first. Note: consensus_repositories is declarative-only (see 06 §14.4).",
437
- auto_fixable: false,
438
- },
439
- {
440
- id: "R-M5-08",
441
- name: "Object dependency table incomplete",
442
- category: "environment",
443
- severity: "low",
444
- description: "Project object dependency table missing some objects. Design decisions based on incomplete information.",
445
- detection: "Scan project environment for missing object references",
446
- recommendation: "Use machine-context.ts to scan complete project environment.",
447
- auto_fixable: false,
448
- },
449
- ];
450
- export function assessMachineRisks(machine, context) {
451
- const detected = [];
452
- detected.push(...checkStructuralRisks(machine));
453
- detected.push(...checkGuardIntegrationRisks(machine, context));
454
- detected.push(...checkPermissionRisks(machine));
455
- detected.push(...checkImmutabilityRisks(machine, context));
456
- detected.push(...checkEnvironmentRisks(machine, context));
457
- const summary = {
458
- critical: detected.filter((r) => r.severity === "critical").length,
459
- high: detected.filter((r) => r.severity === "high").length,
460
- medium: detected.filter((r) => r.severity === "medium").length,
461
- low: detected.filter((r) => r.severity === "low").length,
462
- };
463
- let overall_level = "low";
464
- if (summary.critical > 0)
465
- overall_level = "critical";
466
- else if (summary.high > 0)
467
- overall_level = "high";
468
- else if (summary.medium > 0)
469
- overall_level = "medium";
470
- else if (summary.low > 0)
471
- overall_level = "low";
472
- let recommendation;
473
- if (summary.critical > 0) {
474
- recommendation = "do_not_publish";
475
- }
476
- else if (summary.high > 2) {
477
- recommendation = "fix_first";
478
- }
479
- else {
480
- recommendation = "publish";
481
- }
482
- return {
483
- overall_level,
484
- detected_risks: detected,
485
- summary,
486
- recommendation,
487
- };
488
- }
489
- function checkStructuralRisks(machine) {
490
- const risks = [];
491
- const hasEntry = machine.pairs.some((p) => p.prev_node === "");
492
- if (!hasEntry) {
493
- risks.push(makeRisk("R-M1-01", "No Pair with prev_node='' found. Workflow cannot start."));
494
- }
495
- const allPrevNodesForTerminal = new Set(machine.pairs.map((p) => p.prev_node).filter((n) => n !== ""));
496
- const allNodes = new Set(machine.nodes.map((n) => n.name));
497
- const terminals = [...allNodes].filter((n) => !allPrevNodesForTerminal.has(n));
498
- if (terminals.length === 0) {
499
- risks.push(makeRisk("R-M1-02", "No terminal node found. Workflow never completes."));
500
- }
501
- const entryNodes = new Set(machine.pairs.filter((p) => p.prev_node === "").map((p) => p.next_node));
502
- const allPrevNodes = new Set(machine.pairs.map((p) => p.prev_node).filter((n) => n !== ""));
503
- for (const node of machine.nodes) {
504
- if (!entryNodes.has(node.name) && !allPrevNodes.has(node.name)) {
505
- const hasIncoming = machine.pairs.some((p) => p.next_node === node.name);
506
- if (!hasIncoming) {
507
- risks.push(makeRisk("R-M1-04", `Node "${node.name}" is orphaned (no incoming Pair).`));
508
- }
509
- }
510
- }
511
- if (machine.nodes.length > MAX_NODE_COUNT) {
512
- risks.push(makeRisk("R-M1-07", `Node count ${machine.nodes.length} exceeds MAX_NODE_COUNT (${MAX_NODE_COUNT}).`));
513
- }
514
- const pairsPerNode = new Map();
515
- for (const p of machine.pairs) {
516
- pairsPerNode.set(p.next_node, (pairsPerNode.get(p.next_node) ?? 0) + 1);
517
- }
518
- for (const [nodeName, pairCount] of pairsPerNode) {
519
- if (pairCount > 40) {
520
- risks.push(makeRisk("R-M1-08", `Node "${nodeName}" has ${pairCount} Pairs, exceeds MAX_NODE_PAIR_COUNT (40).`));
521
- }
522
- }
523
- for (const pair of machine.pairs) {
524
- if (pair.forwards.length > 20) {
525
- risks.push(makeRisk("R-M1-09", `Pair (${pair.prev_node} -> ${pair.next_node}) has ${pair.forwards.length} Forwards, exceeds MAX_FORWARD_COUNT (20).`));
526
- }
527
- }
528
- const nodeNames = machine.nodes.map((n) => n.name);
529
- const duplicates = nodeNames.filter((name, idx) => nodeNames.indexOf(name) !== idx);
530
- if (duplicates.length > 0) {
531
- risks.push(makeRisk("R-M1-10", `Duplicate node names: ${[...new Set(duplicates)].join(", ")}`));
532
- }
533
- return risks;
534
- }
535
- function checkGuardIntegrationRisks(machine, context) {
536
- const risks = [];
537
- for (const pair of machine.pairs) {
538
- for (const fwd of pair.forwards) {
539
- if (fwd.guard && !context.published_guards.has(fwd.guard)) {
540
- risks.push(makeRisk("R-M2-01", `Forward "${fwd.name}" references Guard "${fwd.guard}" not in published_guards.`));
541
- }
542
- if (fwd.retained_submission && !fwd.guard) {
543
- risks.push(makeRisk("R-M2-04", `Forward "${fwd.name}" has retained_submission but no Guard. retained_submission requires a Guard.`));
544
- }
545
- }
546
- }
547
- return risks;
548
- }
549
- function checkPermissionRisks(machine) {
550
- const risks = [];
551
- for (const pair of machine.pairs) {
552
- for (const fwd of pair.forwards) {
553
- const hasNamed = fwd.named_operator !== undefined && fwd.named_operator !== null;
554
- const hasPerm = fwd.permission_index !== undefined && fwd.permission_index !== null;
555
- if (!hasNamed && !hasPerm) {
556
- risks.push(makeRisk("R-M3-01", `Forward "${fwd.name}" in Pair (${pair.prev_node} -> ${pair.next_node}) has no permission.`));
557
- }
558
- }
559
- }
560
- for (const pair of machine.pairs) {
561
- for (const fwd of pair.forwards) {
562
- const hasNamed = fwd.named_operator !== undefined && fwd.named_operator !== null;
563
- const hasPerm = fwd.permission_index !== undefined && fwd.permission_index !== null;
564
- if (hasNamed && hasPerm) {
565
- risks.push(makeRisk("R-M3-07", `Forward "${fwd.name}" in Pair (${pair.prev_node} -> ${pair.next_node}) has both namedOperator and permissionIndex (OR semantic).`));
566
- }
567
- }
568
- }
569
- for (const pair of machine.pairs) {
570
- for (const fwd of pair.forwards) {
571
- if (fwd.permission_index !== undefined &&
572
- fwd.permission_index !== null &&
573
- fwd.permission_index < USER_DEFINED_PERM_INDEX_START) {
574
- risks.push(makeRisk("R-M3-08", `Forward "${fwd.name}" in Pair (${pair.prev_node} -> ${pair.next_node}) ` +
575
- `has permission_index=${fwd.permission_index} < ${USER_DEFINED_PERM_INDEX_START}. ` +
576
- `Indexes 0-999 are reserved for built-in permissions.`));
577
- }
578
- }
579
- }
580
- return risks;
581
- }
582
- function checkImmutabilityRisks(machine, context) {
583
- const risks = [];
584
- if (context.network === "mainnet" && !context.testnet_test_passed) {
585
- risks.push(makeRisk("R-M4-02", "Mainnet publish attempted without testnet test passing."));
586
- }
587
- const referencedGuards = new Set();
588
- for (const pair of machine.pairs) {
589
- for (const fwd of pair.forwards) {
590
- if (fwd.guard)
591
- referencedGuards.add(fwd.guard);
592
- }
593
- }
594
- const missingGuards = [...referencedGuards].filter((g) => !context.published_guards.has(g));
595
- if (missingGuards.length > 0) {
596
- risks.push(makeRisk("R-M4-03", `Guards not all created before publish. Missing: ${missingGuards.join(", ")}`));
597
- }
598
- return risks;
599
- }
600
- function checkEnvironmentRisks(machine, context) {
601
- const risks = [];
602
- const referencedGuards = new Set();
603
- for (const pair of machine.pairs) {
604
- for (const fwd of pair.forwards) {
605
- if (fwd.guard)
606
- referencedGuards.add(fwd.guard);
607
- }
608
- }
609
- const missingGuards = [...referencedGuards].filter((g) => !context.published_guards.has(g));
610
- if (missingGuards.length > 0) {
611
- risks.push(makeRisk("R-M5-08", `Object dependency table incomplete. Missing Guards: ${missingGuards.join(", ")}`));
612
- }
613
- return risks;
614
- }
615
- function makeRisk(ruleId, detail) {
616
- const rule = MACHINE_RISK_RULES.find((r) => r.id === ruleId);
617
- if (!rule) {
618
- return {
619
- rule_id: ruleId,
620
- name: "Unknown",
621
- severity: "low",
622
- detail,
623
- recommendation: "Investigate manually.",
624
- auto_fixable: false,
625
- };
626
- }
627
- return {
628
- rule_id: rule.id,
629
- name: rule.name,
630
- severity: rule.severity,
631
- detail,
632
- recommendation: rule.recommendation,
633
- auto_fixable: rule.auto_fixable,
634
- };
635
- }
636
- export function getRiskRulesByCategory(category) {
637
- return MACHINE_RISK_RULES.filter((r) => r.category === category);
638
- }
639
- export function getRiskRuleById(id) {
640
- return MACHINE_RISK_RULES.find((r) => r.id === id);
641
- }
642
- export function getRiskRulesBySeverity(severity) {
643
- return MACHINE_RISK_RULES.filter((r) => r.severity === severity);
644
- }
645
- export function getAutoFixableRules() {
646
- return MACHINE_RISK_RULES.filter((r) => r.auto_fixable);
647
- }
648
- export function getRiskSummary(assessment) {
649
- const lines = [
650
- `Overall Risk Level: ${assessment.overall_level.toUpperCase()}`,
651
- `Recommendation: ${assessment.recommendation}`,
652
- "",
653
- "Summary:",
654
- ` Critical: ${assessment.summary.critical}`,
655
- ` High: ${assessment.summary.high}`,
656
- ` Medium: ${assessment.summary.medium}`,
657
- ` Low: ${assessment.summary.low}`,
658
- "",
659
- "Detected Risks:",
660
- ];
661
- for (const risk of assessment.detected_risks) {
662
- lines.push(` [${risk.severity.toUpperCase()}] ${risk.rule_id}: ${risk.name}`);
663
- lines.push(` Detail: ${risk.detail}`);
664
- lines.push(` Fix: ${risk.recommendation}`);
665
- }
666
- return lines.join("\n");
667
- }
668
- export const MACHINE_RISK_VERSION = "1.0.0";
669
- export const MACHINE_RISK_RULES_COUNT = MACHINE_RISK_RULES.length;
1
+ import{USER_DEFINED_PERM_INDEX_START,MAX_NODE_COUNT}from'./onchain-constants.js';export const MACHINE_RISK_RULES=[{'id':'R-M1-01','name':'No\x20entry\x20point','category':'structural','severity':'critical','description':'Machine\x20has\x20no\x20Pair\x20with\x20prev_node=\x27\x27\x20(no\x20entry\x20point).\x20Workflow\x20cannot\x20start.','detection':'Check\x20if\x20any\x20pair\x20has\x20prev_node\x20===\x20\x27\x27','recommendation':'Add\x20at\x20least\x20one\x20Pair\x20with\x20prev_node=\x27\x27\x20to\x20serve\x20as\x20entry\x20point.','auto_fixable':![],'related_constraint':'MC-S-01'},{'id':'R-M1-02','name':'No\x20terminal\x20node','category':'structural','severity':'critical','description':'Machine\x20has\x20no\x20terminal\x20node\x20(all\x20nodes\x20have\x20outgoing\x20Pairs).\x20Workflow\x20never\x20completes.','detection':'Check\x20if\x20any\x20node\x20has\x20no\x20outgoing\x20Pair','recommendation':'Designate\x20at\x20least\x20one\x20node\x20as\x20terminal\x20(no\x20outgoing\x20Pair)\x20and\x20bind\x20Allocator\x20to\x20it.','auto_fixable':![],'related_constraint':'MC-S-02'},{'id':'R-M1-03','name':'Dead-end\x20node\x20(non-terminal)','category':'structural','severity':'medium','description':'Non-terminal\x20node\x20has\x20no\x20outgoing\x20Pair.\x20Workflow\x20stalls\x20at\x20this\x20node.','detection':'Find\x20nodes\x20with\x20no\x20outgoing\x20Pair\x20that\x20are\x20not\x20intended\x20terminals','recommendation':'Add\x20outgoing\x20Pair\x20or\x20designate\x20as\x20terminal\x20with\x20Allocator.','auto_fixable':![]},{'id':'R-M1-04','name':'Orphaned\x20node','category':'structural','severity':'high','description':'Node\x20has\x20no\x20incoming\x20Pair\x20(except\x20entry).\x20Unreachable.','detection':'Find\x20non-entry\x20nodes\x20with\x20no\x20incoming\x20Pair','recommendation':'Add\x20Pair\x20from\x20existing\x20node\x20to\x20this\x20orphaned\x20node,\x20or\x20remove\x20it.','auto_fixable':![],'related_constraint':'MC-S-03'},{'id':'R-M1-05','name':'Dead\x20branch\x20(competing\x20Pair\x20always\x20loses)','category':'structural','severity':'high','description':'A\x20competing\x20Pair\x27s\x20threshold\x20can\x20never\x20be\x20met\x20because\x20users\x20always\x20prefer\x20another\x20path.','detection':'Analyze\x20threshold\x20achievability\x20across\x20competing\x20Pairs','recommendation':'Make\x20thresholds\x20balanced,\x20or\x20remove\x20the\x20dead\x20branch.','auto_fixable':![],'related_constraint':'MC-S-04'},{'id':'R-M1-06','name':'Cycle\x20in\x20DAG','category':'structural','severity':'critical','description':'Workflow\x20has\x20a\x20cycle.\x20Nodes\x20reference\x20each\x20other\x20circularly.','detection':'DFS\x20cycle\x20detection','recommendation':'Break\x20the\x20cycle\x20by\x20removing\x20one\x20Pair.','auto_fixable':![],'related_constraint':'MC-S-05'},{'id':'R-M1-07','name':'Exceeds\x20MAX_NODE_COUNT\x20(100)','category':'structural','severity':'critical','description':'Node\x20count\x20exceeds\x20on-chain\x20limit.\x20Publish\x20will\x20fail.','detection':'nodes.length\x20>\x20'+MAX_NODE_COUNT,'recommendation':'Reduce\x20node\x20count\x20or\x20split\x20into\x20multiple\x20Machines.','auto_fixable':![],'related_constraint':'MC-C-01'},{'id':'R-M1-08','name':'Exceeds\x20MAX_NODE_PAIR_COUNT\x20(40)','category':'structural','severity':'high','description':'A\x20single\x20node\x27s\x20Pairs\x20exceed\x20on-chain\x20limit.\x20Publish\x20will\x20fail.','detection':'Find\x20node\x20where\x20pairs.length\x20>\x2040','recommendation':'Split\x20node\x20or\x20simplify\x20branches\x20to\x20reduce\x20Pair\x20count\x20per\x20node.','auto_fixable':![],'related_constraint':'MC-C-02'},{'id':'R-M1-09','name':'Exceeds\x20MAX_FORWARD_COUNT\x20(20)','category':'structural','severity':'high','description':'A\x20single\x20Pair\x27s\x20Forwards\x20exceed\x20on-chain\x20limit.\x20Publish\x20will\x20fail.','detection':'Find\x20Pair\x20where\x20forwards.length\x20>\x2020','recommendation':'Split\x20Pair\x20or\x20merge\x20Forwards\x20to\x20reduce\x20Forward\x20count\x20per\x20Pair.','auto_fixable':![],'related_constraint':'MC-C-03'},{'id':'R-M1-10','name':'Duplicate\x20node\x20name','category':'structural','severity':'critical','description':'Two\x20nodes\x20have\x20the\x20same\x20name.\x20On-chain\x20will\x20reject.','detection':'Find\x20duplicate\x20names\x20in\x20nodes\x20array','recommendation':'Rename\x20one\x20of\x20the\x20duplicates.','auto_fixable':![],'related_constraint':'MC-C-04'},{'id':'R-M1-11','name':'Dispute\x20anti-pattern\x20—\x20machine\x20illegally\x20models\x20dispute\x20flow','category':'structural','severity':'critical','description':'Machine\x20contains\x20nodes\x20named\x20\x27disputed\x27,\x20\x27refunded\x27,\x20\x27arb\x27,\x20\x27arbitration\x27,\x20'+'\x27dispute\x27,\x20or\x20\x27refund\x27.\x20This\x20is\x20a\x20CRITICAL\x20design\x20anti-pattern\x20because\x20'+'dispute\x20is\x20INDEPENDENT\x20of\x20the\x20machine\x20workflow.\x20Dispute\x20flows\x20through:\x20'+'Order\x20→\x20Arbitration.dispute()\x20→\x20Arb\x20object\x20→\x20arbitration()\x20ruling\x20→\x20'+'arb_withdraw\x20by\x20order\x20holder.\x20Arbitrators\x20are\x20configured\x20in\x20'+'Arbitration.voting_guard,\x20NOT\x20in\x20Permission.\x20Merchants\x20who\x20model\x20'+'dispute\x20in\x20the\x20machine\x20(e.g.,\x20\x27disputed\x20→\x20refunded\x27\x20forward\x20guarded\x20'+'by\x20Permission\x20index\x201500)\x20create\x20dead-end\x20paths\x20because\x20no\x20one\x20has\x20'+'Permission\x201500\x20—\x20arbitrators\x20are\x20NOT\x20Permission\x20holders.','detection':'Match\x20node\x20names\x20against\x20regex\x20/(^|_)(disputed?|refund(?:ed)?|arbitration|arb)(_|$)/i\x20'+'(catches\x20both\x20exact\x20names\x20like\x20\x27refunded\x27\x20and\x20compound\x20fund-flow\x20terminals\x20like\x20'+'\x27deposit_refunded\x27/\x27deposit_deducted\x27;\x20business\x20states\x20like\x20\x27return_approved\x27/'+'\x27damage_confirmed\x27/\x27cancelled\x27/\x27returned\x27\x20do\x20NOT\x20match)','recommendation':'Remove\x20all\x20dispute/refund\x20nodes\x20from\x20the\x20machine.\x20Instead:\x20(1)\x20bind\x20an\x20'+'Arbitration\x20object\x20to\x20the\x20Service\x20via\x20Service.arbitrations,\x20(2)\x20configure\x20'+'arbitrators\x20via\x20Arbitration.voting_guard_add,\x20(3)\x20deposit\x20compensation_fund\x20'+'to\x20the\x20Service.\x20Disputes\x20are\x20then\x20filed\x20via\x20arbitration::dispute(order,\x20'+'arbitration)\x20—\x20completely\x20independent\x20of\x20the\x20machine\x20workflow.','auto_fixable':![]},{'id':'R-M2-01','name':'Guard\x20not\x20created','category':'guard_integration','severity':'critical','description':'Forward\x20references\x20a\x20Guard\x20that\x20is\x20not\x20yet\x20created\x20on-chain.\x20Forward\x20execution\x20will\x20fail\x20Guard\x20verification.','detection':'Check\x20forward.guard\x20against\x20published_guards\x20set','recommendation':'Create\x20the\x20Guard\x20object\x20before\x20publishing\x20this\x20Machine.','auto_fixable':![],'related_constraint':'MC-C-09'},{'id':'R-M2-02','name':'Guard\x20not\x20tested\x20via\x20gen_passport','category':'guard_integration','severity':'high','description':'Guard\x20has\x20not\x20been\x20tested\x20via\x20gen_passport.\x20Guard\x20may\x20have\x20bugs,\x20cannot\x20be\x20fixed\x20after\x20publish.','detection':'Check\x20testnet\x20test\x20records\x20for\x20this\x20Guard','recommendation':'Run\x20gen_passport\x20on\x20testnet\x20before\x20binding\x20to\x20Machine.','auto_fixable':![]},{'id':'R-M2-03','name':'Guard\x20+\x20Machine\x20immutability\x20deadlock','category':'guard_integration','severity':'critical','description':'After\x20Machine\x20publish,\x20a\x20Guard\x20bug\x20is\x20discovered.\x20Guard\x20is\x20immutable\x20(cannot\x20be\x20fixed),\x20Machine\x20is\x20immutable\x20(cannot\x20be\x20rebound).','detection':'Verify\x20all\x20Guards\x20tested\x20before\x20Machine\x20publish','recommendation':'Keep\x20Machine\x20unpublished\x20until\x20all\x20Guards\x20are\x20verified.','auto_fixable':![]},{'id':'R-M2-04','name':'retained_submission\x20index\x20mismatch','category':'guard_integration','severity':'high','description':'Forward\x27s\x20retained_submission\x20key\x20does\x20not\x20correspond\x20to\x20Guard\x20table\x20b_submission=true\x20entry.\x20Retained\x20data\x20fails\x20or\x20is\x20incorrect.','detection':'Cross-check\x20forward.retained_submission\x20against\x20Guard\x20table\x20entries','recommendation':'Align\x20retained_submission\x20key\x20with\x20Guard\x20table\x20b_submission=true\x20identifier.','auto_fixable':!![],'related_constraint':'MC-C-11'},{'id':'R-M2-05','name':'Guard\x20reentry\x20risk','category':'guard_integration','severity':'high','description':'Guard\x20lacks\x20anti-reentry\x20mechanism\x20(see\x20Guard\x20R-X1-14).\x20Risk\x20of\x20duplicate\x20execution\x20or\x20vote\x20manipulation.','detection':'For\x20each\x20Guard\x20scene,\x20verify\x20anti-reentry\x20Guard\x20is\x20configured\x20(see\x20Guard\x20semantic\x20layer\x20R-X1-14)','recommendation':'Add\x20anti-reentry\x20Guard\x20for\x20each\x20scenario\x20(see\x20Guard\x20semantic\x20layer\x20R-X1-14).','auto_fixable':![]},{'id':'R-M2-06','name':'Guard\x20scene\x20mismatch','category':'guard_integration','severity':'medium','description':'Forward\x27s\x20bound\x20Guard\x20scene\x20does\x20not\x20match\x20Forward\x27s\x20business\x20(e.g.,\x20Forward\x20uses\x20reward_guard\x20instead\x20of\x20machine_forward_guard).','detection':'Cross-check\x20Guard\x20scene\x20against\x20Forward\x20business\x20purpose','recommendation':'Use\x20the\x20correct\x20Guard\x20scene\x20(machine_forward_guard).','auto_fixable':![]},{'id':'R-M2-07','name':'Cross-Machine\x20Guard\x20dependency\x20cycle','category':'guard_integration','severity':'critical','description':'Machine\x20A\x20depends\x20on\x20Machine\x20B\x20(via\x20Guard),\x20B\x20depends\x20on\x20A.\x20Circular\x20dependency.','detection':'Identify\x20cross-Machine\x20Guard\x20references\x20and\x20detect\x20cycles','recommendation':'Ensure\x20cross-Machine\x20dependencies\x20are\x20unidirectional.','auto_fixable':![]},{'id':'R-M2-08','name':'Guard\x20references\x20unpublished\x20object','category':'guard_integration','severity':'high','description':'Guard\x20table\x20references\x20an\x20object\x20(e.g.,\x20Service)\x20that\x20is\x20not\x20yet\x20published.','detection':'Cross-check\x20Guard\x20table\x20object\x20references\x20against\x20published\x20objects\x20set','recommendation':'Use\x20P16\x20circular\x20reference\x20pattern\x20(name\x20instead\x20of\x20address),\x20or\x20publish\x20referenced\x20objects\x20first.','auto_fixable':![]},{'id':'R-M3-01','name':'Forward\x20without\x20permission','category':'permission','severity':'critical','description':'Forward\x20has\x20neither\x20namedOperator\x20nor\x20permissionIndex.\x20Cannot\x20be\x20executed.','detection':'Check\x20each\x20forward\x20has\x20at\x20least\x20one\x20of\x20namedOperator\x20or\x20permissionIndex','recommendation':'Set\x20namedOperator=\x27\x27\x20for\x20OrderHolder,\x20or\x20set\x20permissionIndex.','auto_fixable':![],'related_constraint':'MC-C-07'},{'id':'R-M3-02','name':'permissionIndex\x20out\x20of\x20bounds','category':'permission','severity':'critical','description':'Forward\x27s\x20permissionIndex\x20>=\x20Permission.indices.length.\x20Execution\x20will\x20fail.','detection':'Check\x20permission_index\x20<\x20Permission.indices.length','recommendation':'Use\x20a\x20valid\x20permission\x20index\x20or\x20extend\x20Permission.indices.','auto_fixable':![],'related_constraint':'MC-C-08'},{'id':'R-M3-03','name':'Permission\x20rotation\x20failure','category':'permission','severity':'high','description':'Permission\x20object\x20updated,\x20indices\x20order\x20changed.\x20Original\x20permissionIndex\x20now\x20points\x20to\x20wrong\x20permission.','detection':'Detect\x20Permission\x20object\x20update\x20that\x20reorders\x20indices','recommendation':'Use\x20custom\x20Permission;\x20document\x20index\x20meanings;\x20avoid\x20frequent\x20Permission\x20updates.','auto_fixable':![]},{'id':'R-M3-04','name':'OrderHolder\x20misuse','category':'permission','severity':'medium','description':'namedOperator=\x27\x27\x20used\x20in\x20non-customer-operation\x20scenarios.\x20Non-intended\x20personnel\x20gain\x20operation\x20permission.','detection':'Find\x20Forwards\x20with\x20namedOperator=\x27\x27\x20on\x20non-customer-operation\x20nodes','recommendation':'Clarify\x20\x27\x27=OrderHolder\x20(customer),\x20not\x20\x27anyone\x27.\x20Use\x20namedOperator\x20for\x20specific\x20roles.','auto_fixable':![]},{'id':'R-M3-05','name':'NamedOperator\x20not\x20assigned\x20at\x20Progress\x20creation','category':'permission','severity':'high','description':'Forward\x20expects\x20namedOperator\x20role\x20but\x20Progress\x20doesn\x27t\x20have\x20it\x20assigned.\x20'+'Note:\x20MCP\x20API\x20layer\x20supports\x20progress_new.progress_namedOperator\x20(SDK\x20translates\x20to\x20namedOperator_add),\x20'+'but\x20Move\x20layer\x20progress::new\x20does\x20NOT\x20accept\x20it\x20(see\x2006\x20§14.5).','detection':'Verify\x20progress_namedOperator\x20is\x20provided\x20in\x20Progress\x20creation','recommendation':'Pass\x20progress_namedOperator\x20in\x20progress_new,\x20or\x20call\x20namedOperator_add\x20separately.','auto_fixable':![]},{'id':'R-M3-06','name':'Permission\x20game\x20imbalance','category':'permission','severity':'medium','description':'One\x20party\x20has\x20excessive\x20permission,\x20can\x20unilaterally\x20advance\x20workflow.\x20Game\x20theory\x20imbalance.','detection':'Analyze\x20permission\x20distribution\x20across\x20parties','recommendation':'Use\x20dual-signature\x20(threshold=2)\x20or\x20multi-signature\x20mechanism\x20to\x20balance\x20power.','auto_fixable':![]},{'id':'R-M3-07','name':'Permission\x20combination\x20OR\x20semantic\x20misuse','category':'permission','severity':'medium','description':'Both\x20namedOperator\x20and\x20permissionIndex\x20set,\x20but\x20OR\x20semantic\x20not\x20understood.\x20More\x20people\x20than\x20expected\x20can\x20execute\x20Forward.','detection':'Find\x20Forwards\x20with\x20both\x20namedOperator\x20and\x20permissionIndex\x20set','recommendation':'Clarify\x20that\x20when\x20both\x20permissions\x20are\x20non-null,\x20it\x20is\x20OR\x20relation\x20(either\x20can\x20execute).','auto_fixable':![]},{'id':'R-M3-08','name':'permissionIndex\x20below\x20USER_DEFINED_PERM_INDEX_START\x20(1000)','category':'permission','severity':'critical','description':'Forward\x27s\x20permissionIndex\x20<\x201000.\x20On-chain\x20constant\x20USER_DEFINED_PERM_INDEX_START\x20=\x201000\x20'+'in\x20permission.move\x20reserves\x20indexes\x200-999\x20for\x20built-in\x20permissions.\x20Using\x20index\x20<\x201000\x20'+'causes\x20confusion\x20with\x20built-in\x20permissions\x20and\x20is\x20a\x20hard\x20on-chain\x20constraint\x20(see\x20doc\x2006\x20§4.4).','detection':'Check\x20each\x20forward\x20with\x20permission_index\x20<\x201000','recommendation':'Use\x20permission_index\x20>=\x201000\x20(e.g.,\x201000,\x201001,\x201002,\x20...).\x20Reserve\x200-999\x20for\x20built-in\x20permissions.','auto_fixable':![],'related_constraint':'MC-C-08'},{'id':'R-M4-01','name':'No\x20backup\x20before\x20publish','category':'immutability','severity':'high','description':'machineNode2file\x20export\x20not\x20created\x20before\x20publish.\x20Cannot\x20restore\x20if\x20publish\x20fails.','detection':'Check\x20backup_created\x20flag','recommendation':'Run\x20machineNode2file\x20before\x20publish\x20to\x20create\x20backup.','auto_fixable':!![],'related_constraint':'MC-P-02'},{'id':'R-M4-02','name':'No\x20testnet\x20verification\x20before\x20mainnet','category':'immutability','severity':'medium','description':'Directly\x20publishing\x20to\x20mainnet\x20without\x20testnet\x20verification.\x20Potential\x20bugs\x20may\x20cause\x20fund\x20loss.','detection':'Check\x20network\x20===\x20\x27mainnet\x27\x20&&\x20!testnet_test_passed','recommendation':'Test\x20on\x20testnet\x20first.\x20Verify\x20Progress\x20runs\x20end-to-end.','auto_fixable':![],'related_constraint':'MC-P-03'},{'id':'R-M4-03','name':'Guards\x20not\x20all\x20created\x20before\x20publish','category':'immutability','severity':'critical','description':'Some\x20Forward.guard\x20is\x20still\x20null,\x20but\x20design\x20requires\x20Guard.\x20Cannot\x20add\x20Guard\x20after\x20publish\x20(immutability\x20deadlock).','detection':'Check\x20if\x20all\x20required\x20Guards\x20are\x20created\x20and\x20bound','recommendation':'Create\x20and\x20bind\x20all\x20Guards\x20before\x20publishing\x20Machine.','auto_fixable':![]},{'id':'R-M4-04','name':'Publish\x20order\x20incorrect','category':'immutability','severity':'critical','description':'Attempting\x20to\x20publish\x20Machine\x20before\x20creating\x20Guards.\x20Guards\x20cannot\x20bind\x20to\x20already-published\x20Machine.','detection':'Verify\x20dependency\x20order:\x20Permission\x20→\x20Machine(unpublished)\x20→\x20Guard\x20→\x20bind\x20→\x20publish','recommendation':'Follow\x20dependency\x20order:\x20Permission\x20→\x20Machine(unpublished)\x20→\x20Guard\x20→\x20bind\x20→\x20publish.','auto_fixable':![]},{'id':'R-M4-05','name':'Allocation\x20not\x20configured','category':'immutability','severity':'medium','description':'Terminal\x20node\x20not\x20mapped\x20to\x20Allocator.\x20Funds\x20cannot\x20be\x20distributed\x20after\x20workflow\x20completes.','detection':'Check\x20if\x20terminal\x20nodes\x20have\x20Allocator\x20mapping','recommendation':'Configure\x20Allocator\x20for\x20each\x20terminal\x20node.','auto_fixable':![]},{'id':'R-M4-06','name':'clear\x20operation\x20without\x20backup','category':'immutability','severity':'high','description':'Executing\x20node\x20clear\x20before\x20exporting\x20backup.\x20All\x20node\x20data\x20lost,\x20cannot\x20recover.','detection':'Check\x20if\x20machineNode2file\x20backup\x20created\x20before\x20clear\x20operation','recommendation':'Run\x20machineNode2file\x20backup\x20before\x20any\x20clear\x20operation.','auto_fixable':!![]},{'id':'R-M5-01','name':'Service\x20not\x20created','category':'environment','severity':'high','description':'Machine\x20design\x20complete\x20but\x20Service\x20not\x20created.\x20Machine\x20cannot\x20bind\x20to\x20Service.','detection':'Check\x20if\x20Service\x20object\x20is\x20in\x20published_services\x20set','recommendation':'Create\x20Service\x20first,\x20then\x20design/publish\x20Machine.','auto_fixable':![]},{'id':'R-M5-02','name':'Permission\x20object\x20mismatch','category':'environment','severity':'high','description':'Machine\x27s\x20Permission\x20differs\x20from\x20Service\x27s\x20Permission.\x20Permission\x20organization\x20inconsistent,\x20may\x20cause\x20operation\x20failure.','detection':'Cross-check\x20Machine\x27s\x20Permission\x20against\x20Service\x27s\x20Permission','recommendation':'Use\x20the\x20same\x20Permission\x20for\x20Machine\x20and\x20Service\x20(or\x20explicitly\x20document\x20different\x20organizations).','auto_fixable':![]},{'id':'R-M5-03','name':'Allocation\x20configuration\x20incomplete','category':'environment','severity':'high','description':'Service\x27s\x20order_allocators\x20not\x20configured\x20or\x20misconfigured.\x20Terminal\x20node\x20funds\x20cannot\x20be\x20distributed.','detection':'Check\x20if\x20Service.order_allocators\x20is\x20configured\x20for\x20each\x20terminal\x20node','recommendation':'Configure\x20Service.order_allocators,\x20one\x20Allocator\x20per\x20terminal\x20node.','auto_fixable':![]},{'id':'R-M5-04','name':'Reward\x20object\x20not\x20created','category':'environment','severity':'medium','description':'Reward\x20incentive\x20scenario\x20referenced\x20but\x20Reward\x20object\x20not\x20created.','detection':'Check\x20if\x20Reward\x20object\x20is\x20in\x20published_rewards\x20set','recommendation':'Create\x20Reward\x20object\x20first,\x20then\x20design\x20Guard.','auto_fixable':![]},{'id':'R-M5-05','name':'Arbitration\x20object\x20not\x20created','category':'environment','severity':'medium','description':'Arbitration\x20scenario\x20referenced\x20but\x20Arbitration\x20object\x20not\x20created.','detection':'Check\x20if\x20Arbitration\x20object\x20is\x20in\x20published_arbitrations\x20set','recommendation':'Create\x20Arbitration\x20object\x20first.','auto_fixable':![]},{'id':'R-M5-06','name':'Cross-Machine\x20dependency\x20not\x20published','category':'environment','severity':'critical','description':'Machine\x20A\x20depends\x20on\x20Machine\x20B,\x20but\x20B\x20is\x20not\x20published.\x20Guard\x20query\x20for\x20Machine\x20B\x27s\x20Progress\x20will\x20fail.\x20'+'Dependency\x20verification:\x20indirect\x20via\x20progress::new\x20->\x20assert_published\x20(see\x2006\x20§14.6).','detection':'Check\x20machine_ref\x20against\x20published_machines\x20set','recommendation':'Ensure\x20upstream\x20Machine\x20is\x20published\x20first.','auto_fixable':![]},{'id':'R-M5-07','name':'Repository\x20not\x20created','category':'environment','severity':'medium','description':'Guard\x20references\x20Repository\x20but\x20not\x20created.\x20Guard\x20query\x20will\x20fail.','detection':'Check\x20repository_ref\x20against\x20published\x20repositories\x20set','recommendation':'Create\x20and\x20publish\x20Repository\x20first.\x20Note:\x20consensus_repositories\x20is\x20declarative-only\x20(see\x2006\x20§14.4).','auto_fixable':![]},{'id':'R-M5-08','name':'Object\x20dependency\x20table\x20incomplete','category':'environment','severity':'low','description':'Project\x20object\x20dependency\x20table\x20missing\x20some\x20objects.\x20Design\x20decisions\x20based\x20on\x20incomplete\x20information.','detection':'Scan\x20project\x20environment\x20for\x20missing\x20object\x20references','recommendation':'Use\x20machine-context.ts\x20to\x20scan\x20complete\x20project\x20environment.','auto_fixable':![]}];export function assessMachineRisks(a,b){const c=[];c['push'](...checkStructuralRisks(a)),c['push'](...checkGuardIntegrationRisks(a,b)),c['push'](...checkPermissionRisks(a)),c['push'](...checkImmutabilityRisks(a,b)),c['push'](...checkEnvironmentRisks(a,b));const d={'critical':c['filter'](g=>g['severity']==='critical')['length'],'high':c['filter'](g=>g['severity']==='high')['length'],'medium':c['filter'](g=>g['severity']==='medium')['length'],'low':c['filter'](g=>g['severity']==='low')['length']};let e='low';if(d['critical']>0x0)e='critical';else{if(d['high']>0x0)e='high';else{if(d['medium']>0x0)e='medium';else{if(d['low']>0x0)e='low';}}}let f;if(d['critical']>0x0)f='do_not_publish';else d['high']>0x2?f='fix_first':f='publish';return{'overall_level':e,'detected_risks':c,'summary':d,'recommendation':f};}function checkStructuralRisks(a){const b=[],c=a['pairs']['some'](l=>l['prev_node']==='');!c&&b['push'](makeRisk('R-M1-01','No\x20Pair\x20with\x20prev_node=\x27\x27\x20found.\x20Workflow\x20cannot\x20start.'));const d=new Set(a['pairs']['map'](l=>l['prev_node'])['filter'](l=>l!=='')),e=new Set(a['nodes']['map'](l=>l['name'])),f=[...e]['filter'](l=>!d['has'](l));f['length']===0x0&&b['push'](makeRisk('R-M1-02','No\x20terminal\x20node\x20found.\x20Workflow\x20never\x20completes.'));const g=new Set(a['pairs']['filter'](l=>l['prev_node']==='')['map'](l=>l['next_node'])),h=new Set(a['pairs']['map'](l=>l['prev_node'])['filter'](l=>l!==''));for(const l of a['nodes']){if(!g['has'](l['name'])&&!h['has'](l['name'])){const m=a['pairs']['some'](n=>n['next_node']===l['name']);!m&&b['push'](makeRisk('R-M1-04','Node\x20\x22'+l['name']+'\x22\x20is\x20orphaned\x20(no\x20incoming\x20Pair).'));}}a['nodes']['length']>MAX_NODE_COUNT&&b['push'](makeRisk('R-M1-07','Node\x20count\x20'+a['nodes']['length']+'\x20exceeds\x20MAX_NODE_COUNT\x20('+MAX_NODE_COUNT+').'));const i=new Map();for(const n of a['pairs']){i['set'](n['next_node'],(i['get'](n['next_node'])??0x0)+0x1);}for(const [o,q]of i){q>0x28&&b['push'](makeRisk('R-M1-08','Node\x20\x22'+o+'\x22\x20has\x20'+q+'\x20Pairs,\x20exceeds\x20MAX_NODE_PAIR_COUNT\x20(40).'));}for(const r of a['pairs']){r['forwards']['length']>0x14&&b['push'](makeRisk('R-M1-09','Pair\x20('+r['prev_node']+'\x20->\x20'+r['next_node']+')\x20has\x20'+r['forwards']['length']+'\x20Forwards,\x20exceeds\x20MAX_FORWARD_COUNT\x20(20).'));}const j=a['nodes']['map'](s=>s['name']),k=j['filter']((s,t)=>j['indexOf'](s)!==t);return k['length']>0x0&&b['push'](makeRisk('R-M1-10','Duplicate\x20node\x20names:\x20'+[...new Set(k)]['join'](',\x20'))),b;}function checkGuardIntegrationRisks(a,b){const c=[];for(const d of a['pairs']){for(const e of d['forwards']){e['guard']&&!b['published_guards']['has'](e['guard'])&&c['push'](makeRisk('R-M2-01','Forward\x20\x22'+e['name']+'\x22\x20references\x20Guard\x20\x22'+e['guard']+'\x22\x20not\x20in\x20published_guards.')),e['retained_submission']&&!e['guard']&&c['push'](makeRisk('R-M2-04','Forward\x20\x22'+e['name']+'\x22\x20has\x20retained_submission\x20but\x20no\x20Guard.\x20retained_submission\x20requires\x20a\x20Guard.'));}}return c;}function checkPermissionRisks(a){const b=[];for(const c of a['pairs']){for(const d of c['forwards']){const e=d['named_operator']!==undefined&&d['named_operator']!==null,f=d['permission_index']!==undefined&&d['permission_index']!==null;!e&&!f&&b['push'](makeRisk('R-M3-01','Forward\x20\x22'+d['name']+'\x22\x20in\x20Pair\x20('+c['prev_node']+'\x20->\x20'+c['next_node']+')\x20has\x20no\x20permission.'));}}for(const g of a['pairs']){for(const h of g['forwards']){const i=h['named_operator']!==undefined&&h['named_operator']!==null,j=h['permission_index']!==undefined&&h['permission_index']!==null;i&&j&&b['push'](makeRisk('R-M3-07','Forward\x20\x22'+h['name']+'\x22\x20in\x20Pair\x20('+g['prev_node']+'\x20->\x20'+g['next_node']+')\x20has\x20both\x20namedOperator\x20and\x20permissionIndex\x20(OR\x20semantic).'));}}for(const k of a['pairs']){for(const l of k['forwards']){l['permission_index']!==undefined&&l['permission_index']!==null&&l['permission_index']<USER_DEFINED_PERM_INDEX_START&&b['push'](makeRisk('R-M3-08','Forward\x20\x22'+l['name']+'\x22\x20in\x20Pair\x20('+k['prev_node']+'\x20->\x20'+k['next_node']+')\x20'+('has\x20permission_index='+l['permission_index']+'\x20<\x20'+USER_DEFINED_PERM_INDEX_START+'.\x20')+'Indexes\x200-999\x20are\x20reserved\x20for\x20built-in\x20permissions.'));}}return b;}function checkImmutabilityRisks(a,b){const c=[];b['network']==='mainnet'&&!b['testnet_test_passed']&&c['push'](makeRisk('R-M4-02','Mainnet\x20publish\x20attempted\x20without\x20testnet\x20test\x20passing.'));const d=new Set();for(const f of a['pairs']){for(const g of f['forwards']){if(g['guard'])d['add'](g['guard']);}}const e=[...d]['filter'](h=>!b['published_guards']['has'](h));return e['length']>0x0&&c['push'](makeRisk('R-M4-03','Guards\x20not\x20all\x20created\x20before\x20publish.\x20Missing:\x20'+e['join'](',\x20'))),c;}function checkEnvironmentRisks(a,b){const c=[],d=new Set();for(const f of a['pairs']){for(const g of f['forwards']){if(g['guard'])d['add'](g['guard']);}}const e=[...d]['filter'](h=>!b['published_guards']['has'](h));return e['length']>0x0&&c['push'](makeRisk('R-M5-08','Object\x20dependency\x20table\x20incomplete.\x20Missing\x20Guards:\x20'+e['join'](',\x20'))),c;}function makeRisk(a,b){const c=MACHINE_RISK_RULES['find'](d=>d['id']===a);if(!c)return{'rule_id':a,'name':'Unknown','severity':'low','detail':b,'recommendation':'Investigate\x20manually.','auto_fixable':![]};return{'rule_id':c['id'],'name':c['name'],'severity':c['severity'],'detail':b,'recommendation':c['recommendation'],'auto_fixable':c['auto_fixable']};}export function getRiskRulesByCategory(a){return MACHINE_RISK_RULES['filter'](b=>b['category']===a);}export function getRiskRuleById(a){return MACHINE_RISK_RULES['find'](b=>b['id']===a);}export function getRiskRulesBySeverity(a){return MACHINE_RISK_RULES['filter'](b=>b['severity']===a);}export function getAutoFixableRules(){return MACHINE_RISK_RULES['filter'](a=>a['auto_fixable']);}export function getRiskSummary(a){const b=['Overall\x20Risk\x20Level:\x20'+a['overall_level']['toUpperCase'](),'Recommendation:\x20'+a['recommendation'],'','Summary:','\x20\x20Critical:\x20'+a['summary']['critical'],'\x20\x20High:\x20\x20\x20\x20\x20'+a['summary']['high'],'\x20\x20Medium:\x20\x20\x20'+a['summary']['medium'],'\x20\x20Low:\x20\x20\x20\x20\x20\x20'+a['summary']['low'],'','Detected\x20Risks:'];for(const c of a['detected_risks']){b['push']('\x20\x20['+c['severity']['toUpperCase']()+']\x20'+c['rule_id']+':\x20'+c['name']),b['push']('\x20\x20\x20\x20Detail:\x20'+c['detail']),b['push']('\x20\x20\x20\x20Fix:\x20'+c['recommendation']);}return b['join']('\x0a');}export const MACHINE_RISK_VERSION='1.0.0';export const MACHINE_RISK_RULES_COUNT=MACHINE_RISK_RULES['length'];