@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,651 +1 @@
1
- import { MAX_SALE_COUNT, MAX_REPOSITORY_COUNT, MAX_ARBITRATION_COUNT, MAX_DISCOUNT_TOTAL_COUNT, MAX_WIP_LENGTH, MAX_WIP_HASH_LENGTH, } from "@wowok/wowok";
2
- const R_S_1_01 = {
3
- id: "R-S-1-01",
4
- category: "structural",
5
- trigger: "sales count exceeds MAX_SALE_COUNT (50)",
6
- check: (ctx) => {
7
- const count = ctx.current_sales_count ?? 0;
8
- if (ctx.sales && (ctx.sales.op === "add" || ctx.sales.op === "set")) {
9
- const newCount = ctx.sales.op === "set" ? ctx.sales.sales.length : count + ctx.sales.sales.length;
10
- if (newCount > MAX_SALE_COUNT) {
11
- return {
12
- id: "R-S-1-01",
13
- level: "HIGH",
14
- category: "structural",
15
- title: "Sales count exceeds limit",
16
- description: `Service would have ${newCount} sales items, exceeds MAX_SALE_COUNT ${MAX_SALE_COUNT}`,
17
- affected_stakeholders: ["owner", "system"],
18
- scenario: "Adding too many product SKUs",
19
- mitigation: "Split into multiple Service objects or remove discontinued items",
20
- evidence: `sales_count=${newCount}`,
21
- };
22
- }
23
- }
24
- return null;
25
- },
26
- };
27
- const R_S_1_02 = {
28
- id: "R-S-1-02",
29
- category: "structural",
30
- trigger: "repositories count exceeds MAX_REPOSITORY_COUNT (100)",
31
- check: (ctx) => {
32
- const count = ctx.current_repositories_count ?? 0;
33
- if (ctx.repositories && (ctx.repositories.op === "add" || ctx.repositories.op === "set")) {
34
- const newCount = ctx.repositories.op === "set" ? ctx.repositories.objects.length : count + ctx.repositories.objects.length;
35
- if (newCount > MAX_REPOSITORY_COUNT) {
36
- return {
37
- id: "R-S-1-02",
38
- level: "MEDIUM",
39
- category: "structural",
40
- title: "Repositories count exceeds limit",
41
- description: `Service would have ${newCount} repositories, exceeds MAX_REPOSITORY_COUNT ${MAX_REPOSITORY_COUNT}`,
42
- affected_stakeholders: ["owner"],
43
- scenario: "Binding too many data repositories",
44
- mitigation: "Consolidate repositories or remove inactive ones",
45
- evidence: `repositories_count=${newCount}`,
46
- };
47
- }
48
- }
49
- return null;
50
- },
51
- };
52
- const R_S_1_03 = {
53
- id: "R-S-1-03",
54
- category: "structural",
55
- trigger: "arbitrations count exceeds MAX_ARBITRATION_COUNT (20)",
56
- check: (ctx) => {
57
- const count = ctx.current_arbitrations_count ?? 0;
58
- if (ctx.arbitrations && (ctx.arbitrations.op === "add" || ctx.arbitrations.op === "set")) {
59
- const newCount = ctx.arbitrations.op === "set" ? ctx.arbitrations.objects.length : count + ctx.arbitrations.objects.length;
60
- if (newCount > MAX_ARBITRATION_COUNT) {
61
- return {
62
- id: "R-S-1-03",
63
- level: "HIGH",
64
- category: "structural",
65
- title: "Arbitrations count exceeds limit",
66
- description: `Service would have ${newCount} arbitrations, exceeds MAX_ARBITRATION_COUNT ${MAX_ARBITRATION_COUNT}`,
67
- affected_stakeholders: ["owner", "arbitrator"],
68
- scenario: "Binding too many Arbitration objects",
69
- mitigation: "Use 1-3 Arbitration objects covering different dispute scopes",
70
- evidence: `arbitrations_count=${newCount}`,
71
- };
72
- }
73
- }
74
- return null;
75
- },
76
- };
77
- const R_S_1_04 = {
78
- id: "R-S-1-04",
79
- category: "structural",
80
- trigger: "WIP hash length exceeds MAX_WIP_HASH_LENGTH (64) or URL exceeds MAX_WIP_LENGTH (1024)",
81
- check: (ctx) => {
82
- if (ctx.sales && (ctx.sales.op === "add" || ctx.sales.op === "set")) {
83
- for (const s of ctx.sales.sales) {
84
- if (s.wip_hash && s.wip_hash.length > MAX_WIP_HASH_LENGTH) {
85
- return {
86
- id: "R-S-1-04",
87
- level: "HIGH",
88
- category: "structural",
89
- title: "WIP hash length exceeds limit",
90
- description: `Sale "${s.name}" wip_hash length ${s.wip_hash.length} > MAX_WIP_HASH_LENGTH ${MAX_WIP_HASH_LENGTH}`,
91
- affected_stakeholders: ["owner", "customer"],
92
- scenario: "Malformed WIP hash (should be sha256 hex, 64 chars)",
93
- mitigation: "Use sha256 hex hash (64 characters, no prefix)",
94
- evidence: `wip_hash_length=${s.wip_hash.length}`,
95
- };
96
- }
97
- if (s.wip && s.wip.length > MAX_WIP_LENGTH) {
98
- return {
99
- id: "R-S-1-04",
100
- level: "HIGH",
101
- category: "structural",
102
- title: "WIP URL length exceeds limit",
103
- description: `Sale "${s.name}" wip URL length ${s.wip.length} > MAX_WIP_LENGTH ${MAX_WIP_LENGTH}`,
104
- affected_stakeholders: ["owner"],
105
- scenario: "WIP URL too long (use IPFS or short HTTPS URL)",
106
- mitigation: "Use IPFS CID or shorter URL",
107
- evidence: `wip_url_length=${s.wip.length}`,
108
- };
109
- }
110
- }
111
- }
112
- return null;
113
- },
114
- };
115
- const R_S_1_05 = {
116
- id: "R-S-1-05",
117
- category: "structural",
118
- trigger: "sale.wip is a local path / localhost / LAN URL (not network-deployable) — every customer order fails",
119
- check: (ctx) => {
120
- if (ctx.sales && (ctx.sales.op === "add" || ctx.sales.op === "set")) {
121
- for (const s of ctx.sales.sales) {
122
- if (s.wip && s.wip !== "") {
123
- let localType = null;
124
- const w = s.wip;
125
- if (/^[A-Za-z]:[\\/]/.test(w) || w.startsWith("/") || w.startsWith("./") || w.startsWith("../")) {
126
- localType = "local filesystem path";
127
- }
128
- else if (/^https?:\/\/(localhost|127\.0\.0\.1|\[::1\]|0\.0\.0\.0)([:/]|$)/i.test(w)) {
129
- localType = "localhost/loopback URL";
130
- }
131
- else if (/^https?:\/\/(10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})([:/]|$)/i.test(w)) {
132
- localType = "LAN (private IP) URL";
133
- }
134
- else if (!/^https?:\/\//i.test(w) && !w.startsWith("ipfs://") && !w.startsWith("data:")) {
135
- localType = "unrecognized format (not a network URL)";
136
- }
137
- if (localType) {
138
- return {
139
- id: "R-S-1-05",
140
- level: "CRITICAL",
141
- category: "structural",
142
- title: "WIP is not network-deployed — every customer order will fail",
143
- description: `Sale "${s.name}" wip "${s.wip}" is a ${localType}. It passes set-time verification ` +
144
- `on the merchant's own machine but is unreachable by customers on other machines — ` +
145
- `order_new aborts 100% when a customer tries to buy.`,
146
- affected_stakeholders: ["owner", "customer"],
147
- scenario: "Merchant sets wip to a local file path / localhost / LAN URL and publishes the Service; " +
148
- "the on-chain wip points at the merchant's machine; customers cannot fetch it.",
149
- mitigation: "Deploy the .wip file to a public host (GitHub Pages, IPFS, or your own website) and set " +
150
- "sale.wip to the public URL. Or leave sale.wip empty (\"\") to skip WIP verification " +
151
- "(TESTING ONLY — not recommended for production).",
152
- evidence: `sale=${s.name}, wip=${s.wip}`,
153
- };
154
- }
155
- }
156
- }
157
- }
158
- return null;
159
- },
160
- };
161
- const R_S_2_01 = {
162
- id: "R-S-2-01",
163
- category: "semantic",
164
- trigger: "WIP hash tampering risk — owner updates WIP file without updating wip_hash",
165
- check: (ctx) => {
166
- if (ctx.sales && (ctx.sales.op === "add" || ctx.sales.op === "set")) {
167
- for (const s of ctx.sales.sales) {
168
- if (s.wip && !s.wip_hash) {
169
- return {
170
- id: "R-S-2-01",
171
- level: "CRITICAL",
172
- category: "semantic",
173
- title: "WIP hash missing — tampering risk",
174
- description: `Sale "${s.name}" has wip URL but no wip_hash. Owner could replace the WIP file without customers noticing.`,
175
- affected_stakeholders: ["customer", "owner"],
176
- scenario: "Owner sets wip without hash, then changes file content later",
177
- mitigation: "Always compute sha256(wip_file_content) and set as wip_hash. SDK auto-derives if omitted, but explicit hash is safer.",
178
- evidence: `sale=${s.name}`,
179
- };
180
- }
181
- }
182
- }
183
- return null;
184
- },
185
- };
186
- const R_S_2_02 = {
187
- id: "R-S-2-02",
188
- category: "semantic",
189
- trigger: "compensation_fund confused with Service balance (internal Balance<T>)",
190
- check: (ctx) => {
191
- if (ctx.compensation_fund_add) {
192
- return {
193
- id: "R-S-2-02",
194
- level: "HIGH",
195
- category: "semantic",
196
- title: "compensation_fund is internal Balance<T>, NOT Service-owned Treasury",
197
- description: `Depositing ${ctx.compensation_fund_add.balance} to compensation_fund. This balance is internal to Service<T> and is consumed by arbitration::compensation_claim, not by owner withdrawals. Owner can only withdraw via compensation_fund_withdraw (requires bPaused=true + lock_duration expired).`,
198
- affected_stakeholders: ["owner", "arbitrator", "customer"],
199
- scenario: "Owner confuses compensation_fund with general Treasury",
200
- mitigation: "Use external Treasury (referenced via order_allocators.sharing.who=Entity) for general funds. Use compensation_fund only for arbitration payouts.",
201
- evidence: `deposit=${ctx.compensation_fund_add.balance}`,
202
- };
203
- }
204
- return null;
205
- },
206
- };
207
- const R_S_2_03 = {
208
- id: "R-S-2-03",
209
- category: "semantic",
210
- trigger: "quote side effect — stock deduction not rolled back on later failure",
211
- check: (ctx) => {
212
- if (ctx.order_new && ctx.order_new.buy.items.length > 0) {
213
- return {
214
- id: "R-S-2-03",
215
- level: "HIGH",
216
- category: "semantic",
217
- title: "Order flow: stock deducted at quote stage — NOT rolled back on failure",
218
- description: `Order will deduct stock at Stage 3 (quote). If Stages 4-7 fail, stock remains deducted. Customer must manually re-add stock or accept the loss.`,
219
- affected_stakeholders: ["owner", "customer"],
220
- scenario: "Customer's transaction fails after quote but stock is gone",
221
- mitigation: "1) Monitor failed transactions and re-add stock via stock_add. 2) Set sales suspension during high-failure periods. 3) Use small batch orders to limit blast radius.",
222
- evidence: `items=${ctx.order_new.buy.items.length}`,
223
- };
224
- }
225
- return null;
226
- },
227
- };
228
- const R_S_2_04 = {
229
- id: "R-S-2-04",
230
- category: "semantic",
231
- trigger: "Discount issuance — verify type and total count semantics",
232
- check: (ctx) => {
233
- if (ctx.discount) {
234
- const count = ctx.discount.count;
235
- if (count > MAX_DISCOUNT_TOTAL_COUNT) {
236
- return {
237
- id: "R-S-2-04",
238
- level: "MEDIUM",
239
- category: "semantic",
240
- title: "Discount count exceeds total cap",
241
- description: `Issuing ${count} discounts exceeds MAX_DISCOUNT_TOTAL_COUNT ${MAX_DISCOUNT_TOTAL_COUNT}`,
242
- affected_stakeholders: ["owner"],
243
- scenario: "Bulk discount issuance",
244
- mitigation: `Issue in batches of <= 1000 (MAX_DISCOUNT_COUNT_ONCE) and keep total <= ${MAX_DISCOUNT_TOTAL_COUNT}`,
245
- evidence: `count=${count}`,
246
- };
247
- }
248
- }
249
- return null;
250
- },
251
- };
252
- const R_S_2_05 = {
253
- id: "R-S-2-05",
254
- category: "semantic",
255
- trigger: "Order placed without verifying WIP hash — buyer passes empty wip_hash",
256
- check: (ctx) => {
257
- if (ctx.order_new) {
258
- const emptyHashItems = ctx.order_new.buy.items.filter(i => i.wip_hash === "");
259
- if (emptyHashItems.length > 0) {
260
- return {
261
- id: "R-S-2-05",
262
- level: "MEDIUM",
263
- category: "semantic",
264
- title: "Order with empty wip_hash — SDK auto-fills from sale",
265
- description: `${emptyHashItems.length} item(s) have empty wip_hash. SDK will auto-fill from sale.wip_hash at order time. If owner updates the WIP file between viewing and ordering, buyer receives the new (potentially different) content.`,
266
- affected_stakeholders: ["customer"],
267
- scenario: "Time-of-check to time-of-use WIP mismatch",
268
- mitigation: "Buyer should explicitly pass the wip_hash they saw when viewing the product. Empty string is convenience but riskier.",
269
- evidence: `empty_hash_items=${emptyHashItems.length}`,
270
- };
271
- }
272
- }
273
- return null;
274
- },
275
- };
276
- const R_S_3_01 = {
277
- id: "R-S-3-01",
278
- category: "authority",
279
- trigger: "publish operation — requires SERVICE_PUBLISH (311) + prerequisites",
280
- check: (ctx) => {
281
- if (!ctx.publish)
282
- return null;
283
- const blockers = [];
284
- if (!ctx.current_order_allocators_set)
285
- blockers.push("order_allocators not set (F-S-18, E_NO_ALLOCATOR)");
286
- const compBalance = ctx.current_compensation_fund_balance ?? "0";
287
- if (BigInt(compBalance) > 0n && (ctx.current_arbitrations_count ?? 0) === 0) {
288
- blockers.push("compensation_fund > 0 but no arbitrations (F-S-19, E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND)");
289
- }
290
- if (blockers.length > 0) {
291
- return {
292
- id: "R-S-3-01",
293
- level: "CRITICAL",
294
- category: "authority",
295
- title: "Publish blocked — prerequisites not met",
296
- description: `Cannot publish: ${blockers.join("; ")}`,
297
- affected_stakeholders: ["owner"],
298
- scenario: "Owner attempts publish without configuring prerequisites",
299
- mitigation: "Configure order_allocators (and arbitrations if compensation_fund > 0) before publish",
300
- evidence: `blockers=${blockers.length}`,
301
- };
302
- }
303
- return null;
304
- },
305
- };
306
- const R_S_3_02 = {
307
- id: "R-S-3-02",
308
- category: "authority",
309
- trigger: "pause operation — affects new orders but not existing Progress",
310
- check: (ctx) => {
311
- if (ctx.pause === undefined)
312
- return null;
313
- return {
314
- id: "R-S-3-02",
315
- level: "MEDIUM",
316
- category: "authority",
317
- title: ctx.pause ? "Pausing Service — new orders blocked, existing Progress continues" : "Resuming Service — new orders accepted",
318
- description: ctx.pause
319
- ? "Service.bPaused = true will reject new orders (E_SERVICE_PAUSED). Existing orders' Progress continues normally."
320
- : "Service.bPaused = false will allow new orders again.",
321
- affected_stakeholders: ["owner", "customer"],
322
- scenario: ctx.pause ? "Owner pauses for maintenance/stockout" : "Owner resumes after maintenance",
323
- mitigation: ctx.pause ? "Communicate pause to customers. Use compensation_fund_withdraw only when paused." : "Verify stock levels before resuming.",
324
- evidence: `pause=${ctx.pause}`,
325
- };
326
- },
327
- };
328
- const R_S_3_03 = {
329
- id: "R-S-3-03",
330
- category: "authority",
331
- trigger: "buy_guard change — post-publish mutable (unusual exception)",
332
- check: (ctx) => {
333
- if (ctx.buy_guard === undefined)
334
- return null;
335
- if (ctx.current_bPublished) {
336
- return {
337
- id: "R-S-3-03",
338
- level: "MEDIUM",
339
- category: "authority",
340
- title: "buy_guard change post-publish — unusual mutability",
341
- description: `buy_guard is the ONLY publish-locked-field exception: it remains mutable post-publish. Other fields (machine/arbitrations/order_allocators) are immutable.`,
342
- affected_stakeholders: ["owner", "customer"],
343
- scenario: "Owner changes buy_guard strategy after publish (e.g. whitelist → public)",
344
- mitigation: "Document buy_guard changes for transparency. Customers should re-verify buy_guard before ordering.",
345
- evidence: `buy_guard=${ctx.buy_guard ?? "(cleared)"}`,
346
- };
347
- }
348
- return null;
349
- },
350
- };
351
- const R_S_3_04 = {
352
- id: "R-S-3-04",
353
- category: "authority",
354
- trigger: "Ownership transfer (builder field) — irreversible",
355
- check: (ctx) => {
356
- if (!ctx.builder)
357
- return null;
358
- return {
359
- id: "R-S-3-04",
360
- level: "HIGH",
361
- category: "authority",
362
- title: "Service ownership transfer — IRREVERSIBLE",
363
- description: `Transferring Service to ${ctx.builder}. Original owner loses ALL control. New owner inherits permission + compensation_fund + all bindings.`,
364
- affected_stakeholders: ["owner"],
365
- scenario: "Owner transfers Service to new address",
366
- mitigation: "1) Verify new owner address twice. 2) Withdraw compensation_fund first (if applicable). 3) Export Service JSON before transfer.",
367
- evidence: `new_owner=${ctx.builder}`,
368
- };
369
- },
370
- };
371
- const R_S_4_01 = {
372
- id: "R-S-4-01",
373
- category: "lifecycle",
374
- trigger: "publish is irreversible — bPublished cannot be reset to false",
375
- check: (ctx) => {
376
- if (!ctx.publish)
377
- return null;
378
- if (ctx.current_bPublished) {
379
- return {
380
- id: "R-S-4-01",
381
- level: "HIGH",
382
- category: "lifecycle",
383
- title: "Service already published — publish is no-op",
384
- description: "Service.bPublished is already true. Subsequent publish calls have no effect (bPublished is one-shot, cannot revert).",
385
- affected_stakeholders: ["owner"],
386
- scenario: "Owner calls publish again on already-published Service",
387
- mitigation: "Skip publish if already published. To 'reset' a Service, create a new one.",
388
- evidence: `bPublished=true`,
389
- };
390
- }
391
- return {
392
- id: "R-S-4-01",
393
- level: "HIGH",
394
- category: "lifecycle",
395
- title: "Publish is IRREVERSIBLE — 3 fields will be locked forever",
396
- description: "Once published: machine (306), arbitrations (308), order_allocators (313) become permanently immutable. bPublished cannot be reset to false. Clone Service to make changes.",
397
- affected_stakeholders: ["owner", "customer"],
398
- scenario: "Owner publishes Service for the first time",
399
- mitigation: "Verify all configurations before publish. Run pre-publish checklist (service-confirm.ts).",
400
- evidence: `bPublished=false→true`,
401
- };
402
- },
403
- };
404
- const R_S_4_02 = {
405
- id: "R-S-4-02",
406
- category: "lifecycle",
407
- trigger: "setting_lock_duration add — only-increase mechanism",
408
- check: (ctx) => {
409
- if (ctx.setting_lock_duration_add === undefined)
410
- return null;
411
- return {
412
- id: "R-S-4-02",
413
- level: "MEDIUM",
414
- category: "lifecycle",
415
- title: "setting_lock_duration can only INCREASE",
416
- description: `Adding ${ctx.setting_lock_duration_add} ms to setting_lock_duration. New value = old + input (safe_add). Cannot be decreased — protects customers from owner reducing lock to withdraw compensation_fund faster.`,
417
- affected_stakeholders: ["owner", "customer"],
418
- scenario: "Owner extends lock period to build trust",
419
- mitigation: "Ensure extension is intentional. Lock affects rewards/compensation_fund_withdraw/compensation_fund_receive.",
420
- evidence: `add_ms=${ctx.setting_lock_duration_add}`,
421
- };
422
- },
423
- };
424
- const R_S_4_03 = {
425
- id: "R-S-4-03",
426
- category: "lifecycle",
427
- trigger: "machine/arbitrations/order_allocators modification after publish — SDK blocks",
428
- check: (ctx) => {
429
- if (!ctx.current_bPublished)
430
- return null;
431
- const blockedFields = [];
432
- if (ctx.machine !== undefined)
433
- blockedFields.push("machine (306)");
434
- if (ctx.arbitrations !== undefined)
435
- blockedFields.push("arbitrations (308)");
436
- if (ctx.order_allocators !== undefined)
437
- blockedFields.push("order_allocators (313)");
438
- if (blockedFields.length > 0) {
439
- return {
440
- id: "R-S-4-03",
441
- level: "HIGH",
442
- category: "lifecycle",
443
- title: "Post-publish modification blocked by SDK",
444
- description: `Service is published. Cannot modify: ${blockedFields.join(", ")}. SDK checkNotPublished() will abort. To change these fields, clone the Service.`,
445
- affected_stakeholders: ["owner"],
446
- scenario: "Owner attempts to change locked field post-publish",
447
- mitigation: "Create a new Service with the desired configuration. Migrate active orders if needed.",
448
- evidence: `blocked=${blockedFields.join(",")}`,
449
- };
450
- }
451
- return null;
452
- },
453
- };
454
- const R_S_4_04 = {
455
- id: "R-S-4-04",
456
- category: "lifecycle",
457
- trigger: "sales modification — stock/price changes affect future orders only",
458
- check: (ctx) => {
459
- if (!ctx.sales)
460
- return null;
461
- return {
462
- id: "R-S-4-04",
463
- level: "LOW",
464
- category: "lifecycle",
465
- title: "Sales modification affects future orders only",
466
- description: "Sales add/set/remove/clear changes do NOT affect already-created Orders. Existing Orders' Progress continues with the original sale parameters.",
467
- affected_stakeholders: ["owner", "customer"],
468
- scenario: "Owner updates prices mid-campaign",
469
- mitigation: "Communicate price/stock changes to customers. Existing orders are unaffected.",
470
- evidence: `sales_op=${ctx.sales.op}`,
471
- };
472
- },
473
- };
474
- const R_S_5_01 = {
475
- id: "R-S-5-01",
476
- category: "cross_object",
477
- trigger: "Machine binding — post-publish immutable, Progress inherits",
478
- check: (ctx) => {
479
- if (ctx.machine === undefined)
480
- return null;
481
- if (ctx.current_bPublished) {
482
- return {
483
- id: "R-S-5-01",
484
- level: "HIGH",
485
- category: "cross_object",
486
- title: "Machine binding immutable post-publish",
487
- description: `Service is published; machine cannot be changed. All future Progress objects will use the bound Machine.`,
488
- affected_stakeholders: ["owner"],
489
- scenario: "Owner wants to upgrade workflow post-publish",
490
- mitigation: "Create new Service with new Machine. Migrate customers via discounts.",
491
- evidence: `machine=${ctx.machine ?? "(cleared)"}`,
492
- };
493
- }
494
- return {
495
- id: "R-S-5-01",
496
- level: "MEDIUM",
497
- category: "cross_object",
498
- title: "Machine binding — verify Machine is published",
499
- description: `Binding Machine ${ctx.machine}. Ensure Machine is published (machine::publish) — Service cannot bind unpublished Machine.`,
500
- affected_stakeholders: ["owner"],
501
- scenario: "Owner binds Machine before publishing Service",
502
- mitigation: "Verify Machine.bPublished = true before binding.",
503
- evidence: `machine=${ctx.machine}`,
504
- };
505
- },
506
- };
507
- const R_S_5_02 = {
508
- id: "R-S-5-02",
509
- category: "cross_object",
510
- trigger: "Arbitration binding — required when compensation_fund > 0",
511
- check: (ctx) => {
512
- if (!ctx.arbitrations)
513
- return null;
514
- const compBalance = ctx.current_compensation_fund_balance ?? "0";
515
- if (BigInt(compBalance) > 0n && (ctx.current_arbitrations_count ?? 0) === 0) {
516
- return {
517
- id: "R-S-5-02",
518
- level: "HIGH",
519
- category: "cross_object",
520
- title: "Arbitration required — compensation_fund has balance",
521
- description: `compensation_fund balance is ${compBalance}. Publish will fail (E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND) until arbitrations is non-empty.`,
522
- affected_stakeholders: ["owner"],
523
- scenario: "Owner deposits compensation_fund without configuring arbitrations",
524
- mitigation: "Add at least 1 Arbitration object before publish.",
525
- evidence: `compensation_fund=${compBalance}`,
526
- };
527
- }
528
- return null;
529
- },
530
- };
531
- const R_S_5_03 = {
532
- id: "R-S-5-03",
533
- category: "cross_object",
534
- trigger: "order_allocators binding — publish prerequisite, post-publish immutable",
535
- check: (ctx) => {
536
- if (ctx.order_allocators === undefined)
537
- return null;
538
- if (ctx.current_bPublished) {
539
- return {
540
- id: "R-S-5-03",
541
- level: "HIGH",
542
- category: "cross_object",
543
- title: "order_allocators immutable post-publish",
544
- description: "Service is published; order_allocators cannot be changed. Fund distribution strategy is permanently locked.",
545
- affected_stakeholders: ["owner"],
546
- scenario: "Owner wants to adjust fee split post-publish",
547
- mitigation: "Create new Service with new allocators. Cannot migrate existing Orders.",
548
- evidence: `order_allocators=${ctx.order_allocators ? "(set)" : "(cleared)"}`,
549
- };
550
- }
551
- if (ctx.publish && !ctx.order_allocators) {
552
- return {
553
- id: "R-S-5-03",
554
- level: "CRITICAL",
555
- category: "cross_object",
556
- title: "Publish without order_allocators — will fail",
557
- description: "Publish will abort with E_NO_ALLOCATOR. order_allocators is a mandatory publish prerequisite.",
558
- affected_stakeholders: ["owner"],
559
- scenario: "Owner attempts publish without configuring allocators",
560
- mitigation: "Set order_allocators before publish.",
561
- evidence: `order_allocators=null`,
562
- };
563
- }
564
- return null;
565
- },
566
- };
567
- const R_S_5_04 = {
568
- id: "R-S-5-04",
569
- category: "cross_object",
570
- trigger: "Repository/Reward binding — verify object types before adding",
571
- check: (ctx) => {
572
- if (ctx.repositories && (ctx.repositories.op === "add" || ctx.repositories.op === "set")) {
573
- return {
574
- id: "R-S-5-04",
575
- level: "LOW",
576
- category: "cross_object",
577
- title: "Repository binding — verify object types",
578
- description: `Adding ${ctx.repositories.objects.length} repositories. SDK uses queryObjectsWithType to validate each is ObjectType.Repository before binding.`,
579
- affected_stakeholders: ["owner"],
580
- scenario: "Owner adds non-Repository object by mistake",
581
- mitigation: "Use LocalMark names or addresses that are confirmed Repository objects.",
582
- evidence: `objects=${ctx.repositories.objects.length}`,
583
- };
584
- }
585
- if (ctx.rewards && (ctx.rewards.op === "add" || ctx.rewards.op === "set")) {
586
- return {
587
- id: "R-S-5-04",
588
- level: "LOW",
589
- category: "cross_object",
590
- title: "Reward binding — verify object types + lock_duration",
591
- description: `Adding ${ctx.rewards.objects.length} rewards. SDK validates ObjectType.Reward. Note: rewards modification is locked by setting_lock_duration.`,
592
- affected_stakeholders: ["owner"],
593
- scenario: "Owner adds Reward objects",
594
- mitigation: "Verify Reward objects exist and are active. Be aware of lock_duration implications.",
595
- evidence: `objects=${ctx.rewards.objects.length}`,
596
- };
597
- }
598
- return null;
599
- },
600
- };
601
- const ALL_RULES = [
602
- R_S_1_01, R_S_1_02, R_S_1_03, R_S_1_04, R_S_1_05,
603
- R_S_2_01, R_S_2_02, R_S_2_03, R_S_2_04, R_S_2_05,
604
- R_S_3_01, R_S_3_02, R_S_3_03, R_S_3_04,
605
- R_S_4_01, R_S_4_02, R_S_4_03, R_S_4_04,
606
- R_S_5_01, R_S_5_02, R_S_5_03, R_S_5_04,
607
- ];
608
- export const SERVICE_RISK_VERSION = "1.0.0";
609
- export function getAllServiceRiskRules() {
610
- return [...ALL_RULES];
611
- }
612
- export function getServiceRiskRulesCount() {
613
- return ALL_RULES.length;
614
- }
615
- export function getServiceRiskRulesByCategory(category) {
616
- return ALL_RULES.filter(r => r.category === category);
617
- }
618
- export function assessServiceRisks(ctx) {
619
- const risks = [];
620
- for (const rule of ALL_RULES) {
621
- const r = rule.check(ctx);
622
- if (r)
623
- risks.push(r);
624
- }
625
- const overall = risks.length === 0
626
- ? "LOW"
627
- : risks.some(r => r.level === "CRITICAL") ? "CRITICAL"
628
- : risks.some(r => r.level === "HIGH") ? "HIGH"
629
- : risks.some(r => r.level === "MEDIUM") ? "MEDIUM"
630
- : "LOW";
631
- const byCategory = {};
632
- for (const r of risks) {
633
- byCategory[r.category] = (byCategory[r.category] ?? 0) + 1;
634
- }
635
- const advice = {};
636
- for (const r of risks) {
637
- for (const s of r.affected_stakeholders) {
638
- if (!advice[s])
639
- advice[s] = [];
640
- advice[s].push(`${r.id}: ${r.mitigation}`);
641
- }
642
- }
643
- return {
644
- summary: `Assessed ${risks.length} risk(s) across ${Object.keys(byCategory).length} categories`,
645
- risks,
646
- overall_risk: overall,
647
- risks_by_category: byCategory,
648
- stakeholder_advice: advice,
649
- needs_human_review: risks.some(r => r.level === "CRITICAL" || r.level === "HIGH"),
650
- };
651
- }
1
+ import{MAX_SALE_COUNT,MAX_REPOSITORY_COUNT,MAX_ARBITRATION_COUNT,MAX_DISCOUNT_TOTAL_COUNT,MAX_WIP_LENGTH,MAX_WIP_HASH_LENGTH}from'@wowok/wowok';const R_S_1_01={'id':'R-S-1-01','category':'structural','trigger':'sales\x20count\x20exceeds\x20MAX_SALE_COUNT\x20(50)','check':a=>{const b=a['current_sales_count']??0x0;if(a['sales']&&(a['sales']['op']==='add'||a['sales']['op']==='set')){const c=a['sales']['op']==='set'?a['sales']['sales']['length']:b+a['sales']['sales']['length'];if(c>MAX_SALE_COUNT)return{'id':'R-S-1-01','level':'HIGH','category':'structural','title':'Sales\x20count\x20exceeds\x20limit','description':'Service\x20would\x20have\x20'+c+'\x20sales\x20items,\x20exceeds\x20MAX_SALE_COUNT\x20'+MAX_SALE_COUNT,'affected_stakeholders':['owner','system'],'scenario':'Adding\x20too\x20many\x20product\x20SKUs','mitigation':'Split\x20into\x20multiple\x20Service\x20objects\x20or\x20remove\x20discontinued\x20items','evidence':'sales_count='+c};}return null;}},R_S_1_02={'id':'R-S-1-02','category':'structural','trigger':'repositories\x20count\x20exceeds\x20MAX_REPOSITORY_COUNT\x20(100)','check':a=>{const b=a['current_repositories_count']??0x0;if(a['repositories']&&(a['repositories']['op']==='add'||a['repositories']['op']==='set')){const c=a['repositories']['op']==='set'?a['repositories']['objects']['length']:b+a['repositories']['objects']['length'];if(c>MAX_REPOSITORY_COUNT)return{'id':'R-S-1-02','level':'MEDIUM','category':'structural','title':'Repositories\x20count\x20exceeds\x20limit','description':'Service\x20would\x20have\x20'+c+'\x20repositories,\x20exceeds\x20MAX_REPOSITORY_COUNT\x20'+MAX_REPOSITORY_COUNT,'affected_stakeholders':['owner'],'scenario':'Binding\x20too\x20many\x20data\x20repositories','mitigation':'Consolidate\x20repositories\x20or\x20remove\x20inactive\x20ones','evidence':'repositories_count='+c};}return null;}},R_S_1_03={'id':'R-S-1-03','category':'structural','trigger':'arbitrations\x20count\x20exceeds\x20MAX_ARBITRATION_COUNT\x20(20)','check':a=>{const b=a['current_arbitrations_count']??0x0;if(a['arbitrations']&&(a['arbitrations']['op']==='add'||a['arbitrations']['op']==='set')){const c=a['arbitrations']['op']==='set'?a['arbitrations']['objects']['length']:b+a['arbitrations']['objects']['length'];if(c>MAX_ARBITRATION_COUNT)return{'id':'R-S-1-03','level':'HIGH','category':'structural','title':'Arbitrations\x20count\x20exceeds\x20limit','description':'Service\x20would\x20have\x20'+c+'\x20arbitrations,\x20exceeds\x20MAX_ARBITRATION_COUNT\x20'+MAX_ARBITRATION_COUNT,'affected_stakeholders':['owner','arbitrator'],'scenario':'Binding\x20too\x20many\x20Arbitration\x20objects','mitigation':'Use\x201-3\x20Arbitration\x20objects\x20covering\x20different\x20dispute\x20scopes','evidence':'arbitrations_count='+c};}return null;}},R_S_1_04={'id':'R-S-1-04','category':'structural','trigger':'WIP\x20hash\x20length\x20exceeds\x20MAX_WIP_HASH_LENGTH\x20(64)\x20or\x20URL\x20exceeds\x20MAX_WIP_LENGTH\x20(1024)','check':a=>{if(a['sales']&&(a['sales']['op']==='add'||a['sales']['op']==='set'))for(const b of a['sales']['sales']){if(b['wip_hash']&&b['wip_hash']['length']>MAX_WIP_HASH_LENGTH)return{'id':'R-S-1-04','level':'HIGH','category':'structural','title':'WIP\x20hash\x20length\x20exceeds\x20limit','description':'Sale\x20\x22'+b['name']+'\x22\x20wip_hash\x20length\x20'+b['wip_hash']['length']+'\x20>\x20MAX_WIP_HASH_LENGTH\x20'+MAX_WIP_HASH_LENGTH,'affected_stakeholders':['owner','customer'],'scenario':'Malformed\x20WIP\x20hash\x20(should\x20be\x20sha256\x20hex,\x2064\x20chars)','mitigation':'Use\x20sha256\x20hex\x20hash\x20(64\x20characters,\x20no\x20prefix)','evidence':'wip_hash_length='+b['wip_hash']['length']};if(b['wip']&&b['wip']['length']>MAX_WIP_LENGTH)return{'id':'R-S-1-04','level':'HIGH','category':'structural','title':'WIP\x20URL\x20length\x20exceeds\x20limit','description':'Sale\x20\x22'+b['name']+'\x22\x20wip\x20URL\x20length\x20'+b['wip']['length']+'\x20>\x20MAX_WIP_LENGTH\x20'+MAX_WIP_LENGTH,'affected_stakeholders':['owner'],'scenario':'WIP\x20URL\x20too\x20long\x20(use\x20IPFS\x20or\x20short\x20HTTPS\x20URL)','mitigation':'Use\x20IPFS\x20CID\x20or\x20shorter\x20URL','evidence':'wip_url_length='+b['wip']['length']};}return null;}},R_S_1_05={'id':'R-S-1-05','category':'structural','trigger':'sale.wip\x20is\x20a\x20local\x20path\x20/\x20localhost\x20/\x20LAN\x20URL\x20(not\x20network-deployable)\x20—\x20every\x20customer\x20order\x20fails','check':a=>{if(a['sales']&&(a['sales']['op']==='add'||a['sales']['op']==='set'))for(const b of a['sales']['sales']){if(b['wip']&&b['wip']!==''){let c=null;const d=b['wip'];if(/^[A-Za-z]:[\\/]/['test'](d)||d['startsWith']('/')||d['startsWith']('./')||d['startsWith']('../'))c='local\x20filesystem\x20path';else{if(/^https?:\/\/(localhost|127\.0\.0\.1|\[::1\]|0\.0\.0\.0)([:/]|$)/i['test'](d))c='localhost/loopback\x20URL';else{if(/^https?:\/\/(10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})([:/]|$)/i['test'](d))c='LAN\x20(private\x20IP)\x20URL';else!/^https?:\/\//i['test'](d)&&!d['startsWith']('ipfs://')&&!d['startsWith']('data:')&&(c='unrecognized\x20format\x20(not\x20a\x20network\x20URL)');}}if(c)return{'id':'R-S-1-05','level':'CRITICAL','category':'structural','title':'WIP\x20is\x20not\x20network-deployed\x20—\x20every\x20customer\x20order\x20will\x20fail','description':'Sale\x20\x22'+b['name']+'\x22\x20wip\x20\x22'+b['wip']+'\x22\x20is\x20a\x20'+c+'.\x20It\x20passes\x20set-time\x20verification\x20'+'on\x20the\x20merchant\x27s\x20own\x20machine\x20but\x20is\x20unreachable\x20by\x20customers\x20on\x20other\x20machines\x20—\x20'+'order_new\x20aborts\x20100%\x20when\x20a\x20customer\x20tries\x20to\x20buy.','affected_stakeholders':['owner','customer'],'scenario':'Merchant\x20sets\x20wip\x20to\x20a\x20local\x20file\x20path\x20/\x20localhost\x20/\x20LAN\x20URL\x20and\x20publishes\x20the\x20Service;\x20'+'the\x20on-chain\x20wip\x20points\x20at\x20the\x20merchant\x27s\x20machine;\x20customers\x20cannot\x20fetch\x20it.','mitigation':'Deploy\x20the\x20.wip\x20file\x20to\x20a\x20public\x20host\x20(GitHub\x20Pages,\x20IPFS,\x20or\x20your\x20own\x20website)\x20and\x20set\x20'+'sale.wip\x20to\x20the\x20public\x20URL.\x20Or\x20leave\x20sale.wip\x20empty\x20(\x22\x22)\x20to\x20skip\x20WIP\x20verification\x20'+'(TESTING\x20ONLY\x20—\x20not\x20recommended\x20for\x20production).','evidence':'sale='+b['name']+',\x20wip='+b['wip']};}}return null;}},R_S_2_01={'id':'R-S-2-01','category':'semantic','trigger':'WIP\x20hash\x20tampering\x20risk\x20—\x20owner\x20updates\x20WIP\x20file\x20without\x20updating\x20wip_hash','check':a=>{if(a['sales']&&(a['sales']['op']==='add'||a['sales']['op']==='set'))for(const b of a['sales']['sales']){if(b['wip']&&!b['wip_hash'])return{'id':'R-S-2-01','level':'CRITICAL','category':'semantic','title':'WIP\x20hash\x20missing\x20—\x20tampering\x20risk','description':'Sale\x20\x22'+b['name']+'\x22\x20has\x20wip\x20URL\x20but\x20no\x20wip_hash.\x20Owner\x20could\x20replace\x20the\x20WIP\x20file\x20without\x20customers\x20noticing.','affected_stakeholders':['customer','owner'],'scenario':'Owner\x20sets\x20wip\x20without\x20hash,\x20then\x20changes\x20file\x20content\x20later','mitigation':'Always\x20compute\x20sha256(wip_file_content)\x20and\x20set\x20as\x20wip_hash.\x20SDK\x20auto-derives\x20if\x20omitted,\x20but\x20explicit\x20hash\x20is\x20safer.','evidence':'sale='+b['name']};}return null;}},R_S_2_02={'id':'R-S-2-02','category':'semantic','trigger':'compensation_fund\x20confused\x20with\x20Service\x20balance\x20(internal\x20Balance<T>)','check':a=>{if(a['compensation_fund_add'])return{'id':'R-S-2-02','level':'HIGH','category':'semantic','title':'compensation_fund\x20is\x20internal\x20Balance<T>,\x20NOT\x20Service-owned\x20Treasury','description':'Depositing\x20'+a['compensation_fund_add']['balance']+'\x20to\x20compensation_fund.\x20This\x20balance\x20is\x20internal\x20to\x20Service<T>\x20and\x20is\x20consumed\x20by\x20arbitration::compensation_claim,\x20not\x20by\x20owner\x20withdrawals.\x20Owner\x20can\x20only\x20withdraw\x20via\x20compensation_fund_withdraw\x20(requires\x20bPaused=true\x20+\x20lock_duration\x20expired).','affected_stakeholders':['owner','arbitrator','customer'],'scenario':'Owner\x20confuses\x20compensation_fund\x20with\x20general\x20Treasury','mitigation':'Use\x20external\x20Treasury\x20(referenced\x20via\x20order_allocators.sharing.who=Entity)\x20for\x20general\x20funds.\x20Use\x20compensation_fund\x20only\x20for\x20arbitration\x20payouts.','evidence':'deposit='+a['compensation_fund_add']['balance']};return null;}},R_S_2_03={'id':'R-S-2-03','category':'semantic','trigger':'quote\x20side\x20effect\x20—\x20stock\x20deduction\x20not\x20rolled\x20back\x20on\x20later\x20failure','check':a=>{if(a['order_new']&&a['order_new']['buy']['items']['length']>0x0)return{'id':'R-S-2-03','level':'HIGH','category':'semantic','title':'Order\x20flow:\x20stock\x20deducted\x20at\x20quote\x20stage\x20—\x20NOT\x20rolled\x20back\x20on\x20failure','description':'Order\x20will\x20deduct\x20stock\x20at\x20Stage\x203\x20(quote).\x20If\x20Stages\x204-7\x20fail,\x20stock\x20remains\x20deducted.\x20Customer\x20must\x20manually\x20re-add\x20stock\x20or\x20accept\x20the\x20loss.','affected_stakeholders':['owner','customer'],'scenario':'Customer\x27s\x20transaction\x20fails\x20after\x20quote\x20but\x20stock\x20is\x20gone','mitigation':'1)\x20Monitor\x20failed\x20transactions\x20and\x20re-add\x20stock\x20via\x20stock_add.\x202)\x20Set\x20sales\x20suspension\x20during\x20high-failure\x20periods.\x203)\x20Use\x20small\x20batch\x20orders\x20to\x20limit\x20blast\x20radius.','evidence':'items='+a['order_new']['buy']['items']['length']};return null;}},R_S_2_04={'id':'R-S-2-04','category':'semantic','trigger':'Discount\x20issuance\x20—\x20verify\x20type\x20and\x20total\x20count\x20semantics','check':a=>{if(a['discount']){const b=a['discount']['count'];if(b>MAX_DISCOUNT_TOTAL_COUNT)return{'id':'R-S-2-04','level':'MEDIUM','category':'semantic','title':'Discount\x20count\x20exceeds\x20total\x20cap','description':'Issuing\x20'+b+'\x20discounts\x20exceeds\x20MAX_DISCOUNT_TOTAL_COUNT\x20'+MAX_DISCOUNT_TOTAL_COUNT,'affected_stakeholders':['owner'],'scenario':'Bulk\x20discount\x20issuance','mitigation':'Issue\x20in\x20batches\x20of\x20<=\x201000\x20(MAX_DISCOUNT_COUNT_ONCE)\x20and\x20keep\x20total\x20<=\x20'+MAX_DISCOUNT_TOTAL_COUNT,'evidence':'count='+b};}return null;}},R_S_2_05={'id':'R-S-2-05','category':'semantic','trigger':'Order\x20placed\x20without\x20verifying\x20WIP\x20hash\x20—\x20buyer\x20passes\x20empty\x20wip_hash','check':a=>{if(a['order_new']){const b=a['order_new']['buy']['items']['filter'](c=>c['wip_hash']==='');if(b['length']>0x0)return{'id':'R-S-2-05','level':'MEDIUM','category':'semantic','title':'Order\x20with\x20empty\x20wip_hash\x20—\x20SDK\x20auto-fills\x20from\x20sale','description':b['length']+'\x20item(s)\x20have\x20empty\x20wip_hash.\x20SDK\x20will\x20auto-fill\x20from\x20sale.wip_hash\x20at\x20order\x20time.\x20If\x20owner\x20updates\x20the\x20WIP\x20file\x20between\x20viewing\x20and\x20ordering,\x20buyer\x20receives\x20the\x20new\x20(potentially\x20different)\x20content.','affected_stakeholders':['customer'],'scenario':'Time-of-check\x20to\x20time-of-use\x20WIP\x20mismatch','mitigation':'Buyer\x20should\x20explicitly\x20pass\x20the\x20wip_hash\x20they\x20saw\x20when\x20viewing\x20the\x20product.\x20Empty\x20string\x20is\x20convenience\x20but\x20riskier.','evidence':'empty_hash_items='+b['length']};}return null;}},R_S_3_01={'id':'R-S-3-01','category':'authority','trigger':'publish\x20operation\x20—\x20requires\x20SERVICE_PUBLISH\x20(311)\x20+\x20prerequisites','check':a=>{if(!a['publish'])return null;const b=[];if(!a['current_order_allocators_set'])b['push']('order_allocators\x20not\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)');const c=a['current_compensation_fund_balance']??'0';BigInt(c)>0x0n&&(a['current_arbitrations_count']??0x0)===0x0&&b['push']('compensation_fund\x20>\x200\x20but\x20no\x20arbitrations\x20(F-S-19,\x20E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND)');if(b['length']>0x0)return{'id':'R-S-3-01','level':'CRITICAL','category':'authority','title':'Publish\x20blocked\x20—\x20prerequisites\x20not\x20met','description':'Cannot\x20publish:\x20'+b['join'](';\x20'),'affected_stakeholders':['owner'],'scenario':'Owner\x20attempts\x20publish\x20without\x20configuring\x20prerequisites','mitigation':'Configure\x20order_allocators\x20(and\x20arbitrations\x20if\x20compensation_fund\x20>\x200)\x20before\x20publish','evidence':'blockers='+b['length']};return null;}},R_S_3_02={'id':'R-S-3-02','category':'authority','trigger':'pause\x20operation\x20—\x20affects\x20new\x20orders\x20but\x20not\x20existing\x20Progress','check':a=>{if(a['pause']===undefined)return null;return{'id':'R-S-3-02','level':'MEDIUM','category':'authority','title':a['pause']?'Pausing\x20Service\x20—\x20new\x20orders\x20blocked,\x20existing\x20Progress\x20continues':'Resuming\x20Service\x20—\x20new\x20orders\x20accepted','description':a['pause']?'Service.bPaused\x20=\x20true\x20will\x20reject\x20new\x20orders\x20(E_SERVICE_PAUSED).\x20Existing\x20orders\x27\x20Progress\x20continues\x20normally.':'Service.bPaused\x20=\x20false\x20will\x20allow\x20new\x20orders\x20again.','affected_stakeholders':['owner','customer'],'scenario':a['pause']?'Owner\x20pauses\x20for\x20maintenance/stockout':'Owner\x20resumes\x20after\x20maintenance','mitigation':a['pause']?'Communicate\x20pause\x20to\x20customers.\x20Use\x20compensation_fund_withdraw\x20only\x20when\x20paused.':'Verify\x20stock\x20levels\x20before\x20resuming.','evidence':'pause='+a['pause']};}},R_S_3_03={'id':'R-S-3-03','category':'authority','trigger':'buy_guard\x20change\x20—\x20post-publish\x20mutable\x20(unusual\x20exception)','check':a=>{if(a['buy_guard']===undefined)return null;if(a['current_bPublished'])return{'id':'R-S-3-03','level':'MEDIUM','category':'authority','title':'buy_guard\x20change\x20post-publish\x20—\x20unusual\x20mutability','description':'buy_guard\x20is\x20the\x20ONLY\x20publish-locked-field\x20exception:\x20it\x20remains\x20mutable\x20post-publish.\x20Other\x20fields\x20(machine/arbitrations/order_allocators)\x20are\x20immutable.','affected_stakeholders':['owner','customer'],'scenario':'Owner\x20changes\x20buy_guard\x20strategy\x20after\x20publish\x20(e.g.\x20whitelist\x20→\x20public)','mitigation':'Document\x20buy_guard\x20changes\x20for\x20transparency.\x20Customers\x20should\x20re-verify\x20buy_guard\x20before\x20ordering.','evidence':'buy_guard='+(a['buy_guard']??'(cleared)')};return null;}},R_S_3_04={'id':'R-S-3-04','category':'authority','trigger':'Ownership\x20transfer\x20(builder\x20field)\x20—\x20irreversible','check':a=>{if(!a['builder'])return null;return{'id':'R-S-3-04','level':'HIGH','category':'authority','title':'Service\x20ownership\x20transfer\x20—\x20IRREVERSIBLE','description':'Transferring\x20Service\x20to\x20'+a['builder']+'.\x20Original\x20owner\x20loses\x20ALL\x20control.\x20New\x20owner\x20inherits\x20permission\x20+\x20compensation_fund\x20+\x20all\x20bindings.','affected_stakeholders':['owner'],'scenario':'Owner\x20transfers\x20Service\x20to\x20new\x20address','mitigation':'1)\x20Verify\x20new\x20owner\x20address\x20twice.\x202)\x20Withdraw\x20compensation_fund\x20first\x20(if\x20applicable).\x203)\x20Export\x20Service\x20JSON\x20before\x20transfer.','evidence':'new_owner='+a['builder']};}},R_S_4_01={'id':'R-S-4-01','category':'lifecycle','trigger':'publish\x20is\x20irreversible\x20—\x20bPublished\x20cannot\x20be\x20reset\x20to\x20false','check':a=>{if(!a['publish'])return null;if(a['current_bPublished'])return{'id':'R-S-4-01','level':'HIGH','category':'lifecycle','title':'Service\x20already\x20published\x20—\x20publish\x20is\x20no-op','description':'Service.bPublished\x20is\x20already\x20true.\x20Subsequent\x20publish\x20calls\x20have\x20no\x20effect\x20(bPublished\x20is\x20one-shot,\x20cannot\x20revert).','affected_stakeholders':['owner'],'scenario':'Owner\x20calls\x20publish\x20again\x20on\x20already-published\x20Service','mitigation':'Skip\x20publish\x20if\x20already\x20published.\x20To\x20\x27reset\x27\x20a\x20Service,\x20create\x20a\x20new\x20one.','evidence':'bPublished=true'};return{'id':'R-S-4-01','level':'HIGH','category':'lifecycle','title':'Publish\x20is\x20IRREVERSIBLE\x20—\x203\x20fields\x20will\x20be\x20locked\x20forever','description':'Once\x20published:\x20machine\x20(306),\x20arbitrations\x20(308),\x20order_allocators\x20(313)\x20become\x20permanently\x20immutable.\x20bPublished\x20cannot\x20be\x20reset\x20to\x20false.\x20Clone\x20Service\x20to\x20make\x20changes.','affected_stakeholders':['owner','customer'],'scenario':'Owner\x20publishes\x20Service\x20for\x20the\x20first\x20time','mitigation':'Verify\x20all\x20configurations\x20before\x20publish.\x20Run\x20pre-publish\x20checklist\x20(service-confirm.ts).','evidence':'bPublished=false→true'};}},R_S_4_02={'id':'R-S-4-02','category':'lifecycle','trigger':'setting_lock_duration\x20add\x20—\x20only-increase\x20mechanism','check':a=>{if(a['setting_lock_duration_add']===undefined)return null;return{'id':'R-S-4-02','level':'MEDIUM','category':'lifecycle','title':'setting_lock_duration\x20can\x20only\x20INCREASE','description':'Adding\x20'+a['setting_lock_duration_add']+'\x20ms\x20to\x20setting_lock_duration.\x20New\x20value\x20=\x20old\x20+\x20input\x20(safe_add).\x20Cannot\x20be\x20decreased\x20—\x20protects\x20customers\x20from\x20owner\x20reducing\x20lock\x20to\x20withdraw\x20compensation_fund\x20faster.','affected_stakeholders':['owner','customer'],'scenario':'Owner\x20extends\x20lock\x20period\x20to\x20build\x20trust','mitigation':'Ensure\x20extension\x20is\x20intentional.\x20Lock\x20affects\x20rewards/compensation_fund_withdraw/compensation_fund_receive.','evidence':'add_ms='+a['setting_lock_duration_add']};}},R_S_4_03={'id':'R-S-4-03','category':'lifecycle','trigger':'machine/arbitrations/order_allocators\x20modification\x20after\x20publish\x20—\x20SDK\x20blocks','check':a=>{if(!a['current_bPublished'])return null;const b=[];if(a['machine']!==undefined)b['push']('machine\x20(306)');if(a['arbitrations']!==undefined)b['push']('arbitrations\x20(308)');if(a['order_allocators']!==undefined)b['push']('order_allocators\x20(313)');if(b['length']>0x0)return{'id':'R-S-4-03','level':'HIGH','category':'lifecycle','title':'Post-publish\x20modification\x20blocked\x20by\x20SDK','description':'Service\x20is\x20published.\x20Cannot\x20modify:\x20'+b['join'](',\x20')+'.\x20SDK\x20checkNotPublished()\x20will\x20abort.\x20To\x20change\x20these\x20fields,\x20clone\x20the\x20Service.','affected_stakeholders':['owner'],'scenario':'Owner\x20attempts\x20to\x20change\x20locked\x20field\x20post-publish','mitigation':'Create\x20a\x20new\x20Service\x20with\x20the\x20desired\x20configuration.\x20Migrate\x20active\x20orders\x20if\x20needed.','evidence':'blocked='+b['join'](',')};return null;}},R_S_4_04={'id':'R-S-4-04','category':'lifecycle','trigger':'sales\x20modification\x20—\x20stock/price\x20changes\x20affect\x20future\x20orders\x20only','check':a=>{if(!a['sales'])return null;return{'id':'R-S-4-04','level':'LOW','category':'lifecycle','title':'Sales\x20modification\x20affects\x20future\x20orders\x20only','description':'Sales\x20add/set/remove/clear\x20changes\x20do\x20NOT\x20affect\x20already-created\x20Orders.\x20Existing\x20Orders\x27\x20Progress\x20continues\x20with\x20the\x20original\x20sale\x20parameters.','affected_stakeholders':['owner','customer'],'scenario':'Owner\x20updates\x20prices\x20mid-campaign','mitigation':'Communicate\x20price/stock\x20changes\x20to\x20customers.\x20Existing\x20orders\x20are\x20unaffected.','evidence':'sales_op='+a['sales']['op']};}},R_S_4_05={'id':'R-S-4-05','category':'lifecycle','trigger':'Service\x20paused\x20(state-only\x20buyer\x20rule)\x20—\x20new\x20orders\x20are\x20suspended','check':a=>{if(!a['current_bPaused'])return null;return{'id':'R-S-4-05','level':'HIGH','category':'lifecycle','title':'Service\x20is\x20paused\x20—\x20ordering\x20suspended','description':'Service.bPaused\x20is\x20true.\x20The\x20merchant\x20has\x20actively\x20paused\x20the\x20Service;\x20new\x20orders\x20cannot\x20be\x20placed\x20until\x20it\x20resumes.','affected_stakeholders':['customer'],'scenario':'Buyer\x20performs\x20due\x20diligence\x20on\x20a\x20paused\x20Service','mitigation':'Confirm\x20with\x20the\x20merchant\x20(via\x20Messenger)\x20when\x20the\x20Service\x20will\x20resume\x20before\x20ordering.','evidence':'bPaused=true'};}},R_S_4_06={'id':'R-S-4-06','category':'lifecycle','trigger':'Service\x20not\x20published\x20(state-only\x20buyer\x20rule)\x20—\x20cannot\x20be\x20ordered','check':a=>{if(a['current_bPublished']!==![])return null;return{'id':'R-S-4-06','level':'HIGH','category':'lifecycle','title':'Service\x20is\x20not\x20published\x20—\x20cannot\x20be\x20ordered','description':'Service.bPublished\x20is\x20false.\x20The\x20Service\x20is\x20still\x20a\x20draft:\x20it\x20is\x20not\x20visible\x20on\x20the\x20market\x20and\x20order_new\x20will\x20fail.','affected_stakeholders':['customer'],'scenario':'Buyer\x20evaluates\x20a\x20draft\x20Service\x20shared\x20out-of-band','mitigation':'Wait\x20until\x20the\x20merchant\x20publishes\x20the\x20Service\x20(publish\x20is\x20irreversible\x20—\x20configuration\x20is\x20locked\x20at\x20that\x20point).','evidence':'bPublished=false'};}},R_S_5_01={'id':'R-S-5-01','category':'cross_object','trigger':'Machine\x20binding\x20—\x20post-publish\x20immutable,\x20Progress\x20inherits','check':a=>{if(a['machine']===undefined)return null;if(a['current_bPublished'])return{'id':'R-S-5-01','level':'HIGH','category':'cross_object','title':'Machine\x20binding\x20immutable\x20post-publish','description':'Service\x20is\x20published;\x20machine\x20cannot\x20be\x20changed.\x20All\x20future\x20Progress\x20objects\x20will\x20use\x20the\x20bound\x20Machine.','affected_stakeholders':['owner'],'scenario':'Owner\x20wants\x20to\x20upgrade\x20workflow\x20post-publish','mitigation':'Create\x20new\x20Service\x20with\x20new\x20Machine.\x20Migrate\x20customers\x20via\x20discounts.','evidence':'machine='+(a['machine']??'(cleared)')};return{'id':'R-S-5-01','level':'MEDIUM','category':'cross_object','title':'Machine\x20binding\x20—\x20verify\x20Machine\x20is\x20published','description':'Binding\x20Machine\x20'+a['machine']+'.\x20Ensure\x20Machine\x20is\x20published\x20(machine::publish)\x20—\x20Service\x20cannot\x20bind\x20unpublished\x20Machine.','affected_stakeholders':['owner'],'scenario':'Owner\x20binds\x20Machine\x20before\x20publishing\x20Service','mitigation':'Verify\x20Machine.bPublished\x20=\x20true\x20before\x20binding.','evidence':'machine='+a['machine']};}},R_S_5_02={'id':'R-S-5-02','category':'cross_object','trigger':'Arbitration\x20binding\x20—\x20required\x20when\x20compensation_fund\x20>\x200','check':a=>{if(!a['arbitrations'])return null;const b=a['current_compensation_fund_balance']??'0';if(BigInt(b)>0x0n&&(a['current_arbitrations_count']??0x0)===0x0)return{'id':'R-S-5-02','level':'HIGH','category':'cross_object','title':'Arbitration\x20required\x20—\x20compensation_fund\x20has\x20balance','description':'compensation_fund\x20balance\x20is\x20'+b+'.\x20Publish\x20will\x20fail\x20(E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND)\x20until\x20arbitrations\x20is\x20non-empty.','affected_stakeholders':['owner'],'scenario':'Owner\x20deposits\x20compensation_fund\x20without\x20configuring\x20arbitrations','mitigation':'Add\x20at\x20least\x201\x20Arbitration\x20object\x20before\x20publish.','evidence':'compensation_fund='+b};return null;}},R_S_5_03={'id':'R-S-5-03','category':'cross_object','trigger':'order_allocators\x20binding\x20—\x20publish\x20prerequisite,\x20post-publish\x20immutable','check':a=>{if(a['order_allocators']===undefined)return null;if(a['current_bPublished'])return{'id':'R-S-5-03','level':'HIGH','category':'cross_object','title':'order_allocators\x20immutable\x20post-publish','description':'Service\x20is\x20published;\x20order_allocators\x20cannot\x20be\x20changed.\x20Fund\x20distribution\x20strategy\x20is\x20permanently\x20locked.','affected_stakeholders':['owner'],'scenario':'Owner\x20wants\x20to\x20adjust\x20fee\x20split\x20post-publish','mitigation':'Create\x20new\x20Service\x20with\x20new\x20allocators.\x20Cannot\x20migrate\x20existing\x20Orders.','evidence':'order_allocators='+(a['order_allocators']?'(set)':'(cleared)')};if(a['publish']&&!a['order_allocators'])return{'id':'R-S-5-03','level':'CRITICAL','category':'cross_object','title':'Publish\x20without\x20order_allocators\x20—\x20will\x20fail','description':'Publish\x20will\x20abort\x20with\x20E_NO_ALLOCATOR.\x20order_allocators\x20is\x20a\x20mandatory\x20publish\x20prerequisite.','affected_stakeholders':['owner'],'scenario':'Owner\x20attempts\x20publish\x20without\x20configuring\x20allocators','mitigation':'Set\x20order_allocators\x20before\x20publish.','evidence':'order_allocators=null'};return null;}},R_S_5_04={'id':'R-S-5-04','category':'cross_object','trigger':'Repository/Reward\x20binding\x20—\x20verify\x20object\x20types\x20before\x20adding','check':a=>{if(a['repositories']&&(a['repositories']['op']==='add'||a['repositories']['op']==='set'))return{'id':'R-S-5-04','level':'LOW','category':'cross_object','title':'Repository\x20binding\x20—\x20verify\x20object\x20types','description':'Adding\x20'+a['repositories']['objects']['length']+'\x20repositories.\x20SDK\x20uses\x20queryObjectsWithType\x20to\x20validate\x20each\x20is\x20ObjectType.Repository\x20before\x20binding.','affected_stakeholders':['owner'],'scenario':'Owner\x20adds\x20non-Repository\x20object\x20by\x20mistake','mitigation':'Use\x20LocalMark\x20names\x20or\x20addresses\x20that\x20are\x20confirmed\x20Repository\x20objects.','evidence':'objects='+a['repositories']['objects']['length']};if(a['rewards']&&(a['rewards']['op']==='add'||a['rewards']['op']==='set'))return{'id':'R-S-5-04','level':'LOW','category':'cross_object','title':'Reward\x20binding\x20—\x20verify\x20object\x20types\x20+\x20lock_duration','description':'Adding\x20'+a['rewards']['objects']['length']+'\x20rewards.\x20SDK\x20validates\x20ObjectType.Reward.\x20Note:\x20rewards\x20modification\x20is\x20locked\x20by\x20setting_lock_duration.','affected_stakeholders':['owner'],'scenario':'Owner\x20adds\x20Reward\x20objects','mitigation':'Verify\x20Reward\x20objects\x20exist\x20and\x20are\x20active.\x20Be\x20aware\x20of\x20lock_duration\x20implications.','evidence':'objects='+a['rewards']['objects']['length']};return null;}},R_S_5_05={'id':'R-S-5-05','category':'cross_object','trigger':'compensation_fund\x20has\x20balance\x20but\x20no\x20Arbitration\x20bound\x20(state-only\x20buyer\x20rule)','check':a=>{const b=a['current_compensation_fund_balance'];if(b===undefined)return null;let c;try{c=BigInt(b);}catch{return null;}if(c>0x0n&&(a['current_arbitrations_count']??0x0)===0x0)return{'id':'R-S-5-05','level':'HIGH','category':'cross_object','title':'Compensation\x20fund\x20without\x20Arbitration\x20—\x20fund\x20is\x20unclaimable','description':'compensation_fund\x20balance\x20is\x20'+b+'\x20but\x20no\x20Arbitration\x20object\x20is\x20bound.\x20Compensation\x20is\x20claimed\x20via\x20dispute\x20→\x20arbitration()\x20ruling\x20with\x20indemnity\x20→\x20arb_withdraw;\x20without\x20an\x20Arbitration\x20binding\x20there\x20is\x20no\x20dispute\x20path\x20to\x20trigger\x20a\x20payout.','affected_stakeholders':['customer','owner'],'scenario':'Buyer\x20sees\x20a\x20compensation\x20fund\x20but\x20no\x20dispute\x20path\x20to\x20claim\x20it','mitigation':'Require\x20the\x20merchant\x20to\x20bind\x20at\x20least\x20one\x20Arbitration\x20object\x20before\x20ordering.','evidence':'compensation_fund='+b+',\x20arbitrations=0'};return null;}},ALL_RULES=[R_S_1_01,R_S_1_02,R_S_1_03,R_S_1_04,R_S_1_05,R_S_2_01,R_S_2_02,R_S_2_03,R_S_2_04,R_S_2_05,R_S_3_01,R_S_3_02,R_S_3_03,R_S_3_04,R_S_4_01,R_S_4_02,R_S_4_03,R_S_4_04,R_S_4_05,R_S_4_06,R_S_5_01,R_S_5_02,R_S_5_03,R_S_5_04,R_S_5_05];export const SERVICE_RISK_VERSION='1.1.0';export function getAllServiceRiskRules(){return[...ALL_RULES];}export function getServiceRiskRulesCount(){return ALL_RULES['length'];}export function getServiceRiskRulesByCategory(a){return ALL_RULES['filter'](b=>b['category']===a);}export function assessServiceRisks(a){const b=[];for(const f of ALL_RULES){const g=f['check'](a);if(g)b['push'](g);}const c=b['length']===0x0?'LOW':b['some'](h=>h['level']==='CRITICAL')?'CRITICAL':b['some'](h=>h['level']==='HIGH')?'HIGH':b['some'](h=>h['level']==='MEDIUM')?'MEDIUM':'LOW',d={};for(const h of b){d[h['category']]=(d[h['category']]??0x0)+0x1;}const e={};for(const i of b){for(const j of i['affected_stakeholders']){if(!e[j])e[j]=[];e[j]['push'](i['id']+':\x20'+i['mitigation']);}}return{'summary':'Assessed\x20'+b['length']+'\x20risk(s)\x20across\x20'+Object['keys'](d)['length']+'\x20categories','risks':b,'overall_risk':c,'risks_by_category':d,'stakeholder_advice':e,'needs_human_review':b['some'](k=>k['level']==='CRITICAL'||k['level']==='HIGH')};}