@wowok/agent-mcp 2.7.0 → 2.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (427) hide show
  1. package/dist/config/index.js +1 -1
  2. package/dist/config/runtime.js +1 -238
  3. package/dist/customer/customer-advice.js +1 -130
  4. package/dist/customer/index.js +1 -11
  5. package/dist/customer/industry-risks.js +1 -438
  6. package/dist/customer/info-puzzle.js +1 -681
  7. package/dist/customer/order-monitor.js +1 -328
  8. package/dist/customer/order-strategy.js +1 -373
  9. package/dist/customer/post-purchase.js +1 -351
  10. package/dist/customer/preorder-compare.js +1 -34
  11. package/dist/customer/reminder-system.js +1 -316
  12. package/dist/customer/risk-assessment.d.ts +5 -1
  13. package/dist/customer/risk-assessment.js +1 -397
  14. package/dist/customer/types.js +1 -13
  15. package/dist/customer/user-preferences.js +1 -460
  16. package/dist/evaluation/arbitration-game.d.ts +23 -0
  17. package/dist/evaluation/arbitration-game.js +1 -0
  18. package/dist/evaluation/builtins/demand-match.d.ts +15 -0
  19. package/dist/evaluation/builtins/demand-match.js +1 -0
  20. package/dist/evaluation/builtins/index.d.ts +3 -0
  21. package/dist/evaluation/builtins/index.js +1 -0
  22. package/dist/evaluation/builtins/service-risk.d.ts +6 -0
  23. package/dist/evaluation/builtins/service-risk.js +1 -0
  24. package/dist/evaluation/capability.d.ts +50 -0
  25. package/dist/evaluation/capability.js +1 -0
  26. package/dist/evaluation/composer.d.ts +13 -0
  27. package/dist/evaluation/composer.js +1 -0
  28. package/dist/evaluation/engine.d.ts +18 -0
  29. package/dist/evaluation/engine.js +1 -0
  30. package/dist/evaluation/extract.d.ts +30 -0
  31. package/dist/evaluation/extract.js +1 -0
  32. package/dist/evaluation/game-strategy.d.ts +27 -0
  33. package/dist/evaluation/game-strategy.js +1 -0
  34. package/dist/evaluation/gap.d.ts +2 -0
  35. package/dist/evaluation/gap.js +1 -0
  36. package/dist/evaluation/index.d.ts +12 -0
  37. package/dist/evaluation/index.js +1 -0
  38. package/dist/evaluation/node-game.d.ts +62 -0
  39. package/dist/evaluation/node-game.js +1 -0
  40. package/dist/evaluation/region.d.ts +10 -0
  41. package/dist/evaluation/region.js +1 -0
  42. package/dist/evaluation/types.d.ts +77 -0
  43. package/dist/evaluation/types.js +1 -0
  44. package/dist/evaluation/user-injection.d.ts +6 -0
  45. package/dist/evaluation/user-injection.js +1 -0
  46. package/dist/examples/education-contact-create.json +40 -0
  47. package/dist/examples/freelance-contact-create.json +40 -0
  48. package/dist/examples/insurance-machine-create.json +1 -1
  49. package/dist/examples/insurance-service-allocators.json +1 -1
  50. package/dist/examples/machine-publish.json +1 -1
  51. package/dist/examples/rental-ziroom-service-create.json +1 -1
  52. package/dist/examples/retail-adv-guard-messenger-proof-create.json +1 -1
  53. package/dist/examples/retail-myshop-service-create.json +1 -1
  54. package/dist/examples/retail-myshop-service-customer-required.json +1 -1
  55. package/dist/examples/subscription-contact-create.json +40 -0
  56. package/dist/examples/threebody-machine-create.json +1 -1
  57. package/dist/examples/travel-machine-create.json +1 -1
  58. package/dist/examples/travel-service-create.json +1 -1
  59. package/dist/experience/experience-reuse.js +1 -103
  60. package/dist/experience/index.js +1 -5
  61. package/dist/experience/intent-distill.js +1 -83
  62. package/dist/experience/realtime-feedback.js +1 -94
  63. package/dist/experience/types.js +1 -1
  64. package/dist/experience/user-profile.js +1 -171
  65. package/dist/extensions/business-modules.js +1 -287
  66. package/dist/extensions/capability-manifest.js +1 -781
  67. package/dist/extensions/constraint-registry.js +1 -198
  68. package/dist/extensions/index.js +1 -6
  69. package/dist/extensions/metric-registry.js +1 -257
  70. package/dist/extensions/mode-evaluator.js +1 -170
  71. package/dist/extensions/modes.js +1 -499
  72. package/dist/extensions/registry.js +1 -717
  73. package/dist/extensions/types.js +1 -1
  74. package/dist/harness/auto-escalation.js +1 -68
  75. package/dist/harness/checkpoint.js +1 -129
  76. package/dist/harness/index.js +1 -78
  77. package/dist/harness/plan.js +1 -276
  78. package/dist/harness/recover.js +1 -139
  79. package/dist/harness/types.js +1 -1
  80. package/dist/harness/verify.js +1 -237
  81. package/dist/index.js +1 -273
  82. package/dist/intent/enrich.d.ts +1 -0
  83. package/dist/intent/enrich.js +1 -0
  84. package/dist/intent/index.d.ts +23 -0
  85. package/dist/intent/index.js +1 -0
  86. package/dist/intent/matcher.d.ts +2 -0
  87. package/dist/intent/matcher.js +1 -0
  88. package/dist/intent/store.d.ts +19 -0
  89. package/dist/intent/store.js +1 -0
  90. package/dist/intent/types.d.ts +33 -0
  91. package/dist/intent/types.js +1 -0
  92. package/dist/knowledge/acquisition-flywheel.js +1 -192
  93. package/dist/knowledge/allocation-confirm.js +1 -534
  94. package/dist/knowledge/allocation-context.js +1 -249
  95. package/dist/knowledge/allocation-ledger.js +1 -463
  96. package/dist/knowledge/allocation-puzzle.js +1 -298
  97. package/dist/knowledge/allocation-risk.js +1 -568
  98. package/dist/knowledge/allocation-templates.js +1 -970
  99. package/dist/knowledge/allocation-translation.js +1 -585
  100. package/dist/knowledge/arb-risk.js +1 -210
  101. package/dist/knowledge/arbitration-confirm.js +1 -559
  102. package/dist/knowledge/arbitration-context.js +1 -505
  103. package/dist/knowledge/arbitration-ledger.js +1 -521
  104. package/dist/knowledge/arbitration-puzzle.js +1 -304
  105. package/dist/knowledge/arbitration-risk.js +1 -433
  106. package/dist/knowledge/arbitration-templates.js +1 -276
  107. package/dist/knowledge/arbitration-translation.js +1 -487
  108. package/dist/knowledge/arbitration-trust.js +1 -117
  109. package/dist/knowledge/audit-rules.js +1 -141
  110. package/dist/knowledge/bridge-risk.js +1 -263
  111. package/dist/knowledge/contact-risk.js +1 -200
  112. package/dist/knowledge/contact-templates.d.ts +27 -0
  113. package/dist/knowledge/contact-templates.js +1 -0
  114. package/dist/knowledge/demand-confirm.js +1 -206
  115. package/dist/knowledge/demand-matching.js +1 -132
  116. package/dist/knowledge/demand-risk.js +1 -240
  117. package/dist/knowledge/demand-translation.js +1 -354
  118. package/dist/knowledge/deployment-scanner.js +1 -823
  119. package/dist/knowledge/dynamic-pricing.js +1 -87
  120. package/dist/knowledge/examples-scanner-cli.js +1 -26
  121. package/dist/knowledge/examples-scanner.js +1 -825
  122. package/dist/knowledge/flywheel-loop.js +1 -404
  123. package/dist/knowledge/fund-layer.js +1 -973
  124. package/dist/knowledge/glossary.js +1 -211
  125. package/dist/knowledge/guard-confirm.js +1 -406
  126. package/dist/knowledge/guard-context.js +1 -287
  127. package/dist/knowledge/guard-design-patterns.js +1 -360
  128. package/dist/knowledge/guard-ledger.js +1 -260
  129. package/dist/knowledge/guard-lint.js +1 -670
  130. package/dist/knowledge/guard-migration.js +1 -228
  131. package/dist/knowledge/guard-puzzle.js +1 -805
  132. package/dist/knowledge/guard-render.js +1 -700
  133. package/dist/knowledge/guard-risk.js +1 -1879
  134. package/dist/knowledge/guard-submission-prompt.js +1 -171
  135. package/dist/knowledge/guard-templates.js +1 -1105
  136. package/dist/knowledge/guard-translation.js +1 -1119
  137. package/dist/knowledge/index.js +1 -436
  138. package/dist/knowledge/industry-evolution.js +1 -323
  139. package/dist/knowledge/industry-generalizer.js +1 -381
  140. package/dist/knowledge/industry-registry.js +1 -174
  141. package/dist/knowledge/intent-metrics.d.ts +4 -3
  142. package/dist/knowledge/intent-metrics.js +1 -566
  143. package/dist/knowledge/machine-confirm.js +1 -559
  144. package/dist/knowledge/machine-context.js +1 -833
  145. package/dist/knowledge/machine-ledger.js +1 -338
  146. package/dist/knowledge/machine-puzzle.js +1 -494
  147. package/dist/knowledge/machine-render.js +1 -565
  148. package/dist/knowledge/machine-risk.js +1 -670
  149. package/dist/knowledge/machine-templates.js +1 -1597
  150. package/dist/knowledge/machine-topology.js +1 -234
  151. package/dist/knowledge/machine-translation.js +1 -513
  152. package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
  153. package/dist/knowledge/mcp-schema-audit.d.ts +1 -1
  154. package/dist/knowledge/mcp-schema-audit.js +1 -773
  155. package/dist/knowledge/onchain-constants.js +1 -35
  156. package/dist/knowledge/order-confirm.js +1 -573
  157. package/dist/knowledge/order-context.js +1 -390
  158. package/dist/knowledge/order-ledger.js +1 -341
  159. package/dist/knowledge/order-puzzle.js +1 -255
  160. package/dist/knowledge/order-risk.js +1 -653
  161. package/dist/knowledge/order-templates.js +1 -368
  162. package/dist/knowledge/order-translation.js +1 -550
  163. package/dist/knowledge/overrides-loader.js +1 -65
  164. package/dist/knowledge/passport-confirm.js +1 -531
  165. package/dist/knowledge/passport-context.js +1 -306
  166. package/dist/knowledge/passport-ledger.js +1 -282
  167. package/dist/knowledge/passport-puzzle.js +1 -333
  168. package/dist/knowledge/passport-risk.js +1 -450
  169. package/dist/knowledge/passport-templates.js +1 -568
  170. package/dist/knowledge/passport-translation.js +1 -516
  171. package/dist/knowledge/payment-risk.js +1 -249
  172. package/dist/knowledge/permission-confirm.js +1 -426
  173. package/dist/knowledge/permission-context.js +1 -224
  174. package/dist/knowledge/permission-ledger.js +1 -403
  175. package/dist/knowledge/permission-puzzle.js +1 -173
  176. package/dist/knowledge/permission-risk.js +1 -411
  177. package/dist/knowledge/permission-templates.js +1 -234
  178. package/dist/knowledge/permission-translation.js +1 -350
  179. package/dist/knowledge/personal-risk.js +1 -212
  180. package/dist/knowledge/process-model.js +1 -160
  181. package/dist/knowledge/progress-confirm.js +1 -456
  182. package/dist/knowledge/progress-context.js +1 -452
  183. package/dist/knowledge/progress-ledger.js +1 -330
  184. package/dist/knowledge/progress-puzzle.js +1 -219
  185. package/dist/knowledge/progress-risk.js +1 -461
  186. package/dist/knowledge/progress-templates.js +1 -228
  187. package/dist/knowledge/progress-translation.js +1 -405
  188. package/dist/knowledge/proof-confirm.js +1 -187
  189. package/dist/knowledge/proof-risk.js +1 -207
  190. package/dist/knowledge/proof-translation.js +1 -283
  191. package/dist/knowledge/registrar-risk.js +1 -217
  192. package/dist/knowledge/repository-confirm.js +1 -286
  193. package/dist/knowledge/repository-risk.js +1 -373
  194. package/dist/knowledge/repository-translation.js +1 -445
  195. package/dist/knowledge/reputation-rules.js +1 -99
  196. package/dist/knowledge/resource-risk.js +1 -157
  197. package/dist/knowledge/reward-confirm.js +1 -526
  198. package/dist/knowledge/reward-context.js +1 -504
  199. package/dist/knowledge/reward-ledger.js +1 -502
  200. package/dist/knowledge/reward-puzzle.js +1 -300
  201. package/dist/knowledge/reward-risk.js +1 -627
  202. package/dist/knowledge/reward-templates.js +1 -197
  203. package/dist/knowledge/reward-translation.js +1 -501
  204. package/dist/knowledge/safety-rules.js +1 -404
  205. package/dist/knowledge/scenario-modes.js +1 -321
  206. package/dist/knowledge/service-confirm.js +1 -807
  207. package/dist/knowledge/service-context.js +1 -403
  208. package/dist/knowledge/service-ledger.js +1 -609
  209. package/dist/knowledge/service-puzzle.js +1 -236
  210. package/dist/knowledge/service-risk.js +1 -615
  211. package/dist/knowledge/service-templates.js +1 -456
  212. package/dist/knowledge/service-translation.js +1 -622
  213. package/dist/knowledge/template-registry.d.ts +1 -1
  214. package/dist/knowledge/template-registry.js +1 -341
  215. package/dist/knowledge/tool-constraints.js +1 -195
  216. package/dist/knowledge/tools-reference.js +1 -155
  217. package/dist/knowledge/treasury-confirm.js +1 -512
  218. package/dist/knowledge/treasury-context.js +1 -363
  219. package/dist/knowledge/treasury-ledger.js +1 -300
  220. package/dist/knowledge/treasury-puzzle.js +1 -216
  221. package/dist/knowledge/treasury-risk.js +1 -440
  222. package/dist/knowledge/treasury-templates.js +1 -358
  223. package/dist/knowledge/treasury-translation.js +1 -498
  224. package/dist/knowledge/trust-metrics.js +1 -198
  225. package/dist/knowledge/util-risk.js +1 -135
  226. package/dist/loop-engineering/aggregate.js +1 -132
  227. package/dist/loop-engineering/context-collect.js +1 -83
  228. package/dist/loop-engineering/diagnose.js +1 -273
  229. package/dist/loop-engineering/improve.js +1 -405
  230. package/dist/loop-engineering/index.js +1 -4
  231. package/dist/loop-engineering/pipeline.js +1 -56
  232. package/dist/mode-market/index.js +1 -3
  233. package/dist/mode-market/registry.js +1 -124
  234. package/dist/mode-market/review.js +1 -214
  235. package/dist/mode-market/submission.js +1 -85
  236. package/dist/participation/collaborator-interest.d.ts +23 -0
  237. package/dist/participation/collaborator-interest.js +1 -0
  238. package/dist/participation/customer-interest.d.ts +25 -0
  239. package/dist/participation/customer-interest.js +1 -0
  240. package/dist/participation/merchant-interest.js +1 -100
  241. package/dist/participation/radar-core.d.ts +13 -3
  242. package/dist/participation/radar-core.js +1 -269
  243. package/dist/participation/supplier-interest.d.ts +25 -0
  244. package/dist/participation/supplier-interest.js +1 -0
  245. package/dist/persona/analyzer.d.ts +16 -0
  246. package/dist/persona/analyzer.js +1 -0
  247. package/dist/persona/bridge.d.ts +5 -0
  248. package/dist/persona/bridge.js +1 -0
  249. package/dist/persona/defaults.d.ts +4 -0
  250. package/dist/persona/defaults.js +1 -0
  251. package/dist/persona/experience-bridge.d.ts +3 -0
  252. package/dist/persona/experience-bridge.js +1 -0
  253. package/dist/persona/index.d.ts +18 -0
  254. package/dist/persona/index.js +1 -0
  255. package/dist/persona/model.d.ts +7 -0
  256. package/dist/persona/model.js +1 -0
  257. package/dist/persona/store.d.ts +19 -0
  258. package/dist/persona/store.js +1 -0
  259. package/dist/persona/types.d.ts +45 -0
  260. package/dist/persona/types.js +1 -0
  261. package/dist/project/business-puzzle.js +1 -383
  262. package/dist/project/context-assembly.js +1 -254
  263. package/dist/project/deployment-bridge.js +1 -120
  264. package/dist/project/deployment-doc.js +1 -1126
  265. package/dist/project/edit-planner.js +1 -1342
  266. package/dist/project/evaluation.js +1 -2011
  267. package/dist/project/game-theory.js +1 -177
  268. package/dist/project/graph-builder.js +1 -656
  269. package/dist/project/graph.js +1 -340
  270. package/dist/project/handlers.d.ts +5 -0
  271. package/dist/project/handlers.js +1 -1762
  272. package/dist/project/index.d.ts +1 -0
  273. package/dist/project/index.js +1 -301
  274. package/dist/project/intent-analyzer.js +1 -149
  275. package/dist/project/machine-nodes.js +1 -36
  276. package/dist/project/merchant-guide.js +1 -264
  277. package/dist/project/migration.js +1 -125
  278. package/dist/project/mode-actions.js +1 -309
  279. package/dist/project/namespace.js +1 -206
  280. package/dist/project/participation-radar.js +1 -428
  281. package/dist/project/pipeline-actions.js +1 -109
  282. package/dist/project/project-store.js +1 -422
  283. package/dist/project/query.js +1 -153
  284. package/dist/project/reverse-mapping.d.ts +34 -0
  285. package/dist/project/reverse-mapping.js +1 -0
  286. package/dist/project/risk-aggregator.js +1 -295
  287. package/dist/project/rollback-policy.js +1 -290
  288. package/dist/project/semantic-assembler.js +1 -345
  289. package/dist/project/semantic-graph.js +1 -245
  290. package/dist/project/stage-gate.js +1 -369
  291. package/dist/project/substep-trace.js +1 -332
  292. package/dist/project/task-tracker.js +1 -78
  293. package/dist/role/derivation.d.ts +18 -0
  294. package/dist/role/derivation.js +1 -0
  295. package/dist/role/index.d.ts +5 -0
  296. package/dist/role/index.js +1 -0
  297. package/dist/role/model.d.ts +8 -0
  298. package/dist/role/model.js +1 -0
  299. package/dist/role/resolution.d.ts +11 -0
  300. package/dist/role/resolution.js +1 -0
  301. package/dist/role/types.d.ts +11 -0
  302. package/dist/role/types.js +1 -0
  303. package/dist/rules.d.ts +2 -0
  304. package/dist/rules.js +1 -9
  305. package/dist/safety/confirm-gate.js +1 -88
  306. package/dist/safety/index.js +1 -3
  307. package/dist/safety/preview.js +1 -52
  308. package/dist/schema/call/allocation.js +1 -34
  309. package/dist/schema/call/arbitration.js +1 -113
  310. package/dist/schema/call/base.d.ts +15 -15
  311. package/dist/schema/call/base.js +1 -370
  312. package/dist/schema/call/bridge-handler.js +1 -265
  313. package/dist/schema/call/bridge.d.ts +7 -7
  314. package/dist/schema/call/bridge.js +1 -458
  315. package/dist/schema/call/contact.js +1 -37
  316. package/dist/schema/call/demand.js +1 -47
  317. package/dist/schema/call/guard.js +1 -161
  318. package/dist/schema/call/handler.js +1 -322
  319. package/dist/schema/call/index.js +1 -20
  320. package/dist/schema/call/machine.js +1 -193
  321. package/dist/schema/call/order.js +1 -35
  322. package/dist/schema/call/payment.js +1 -37
  323. package/dist/schema/call/permission-handler.js +1 -54
  324. package/dist/schema/call/permission.js +1 -105
  325. package/dist/schema/call/personal.js +1 -78
  326. package/dist/schema/call/progress.js +1 -47
  327. package/dist/schema/call/proof.js +1 -33
  328. package/dist/schema/call/repository.js +1 -77
  329. package/dist/schema/call/reward.js +1 -30
  330. package/dist/schema/call/semantic.js +1 -1657
  331. package/dist/schema/call/service.js +1 -178
  332. package/dist/schema/call/treasury.js +1 -71
  333. package/dist/schema/common/index.js +1 -407
  334. package/dist/schema/config/index.js +1 -68
  335. package/dist/schema/evaluation/index.d.ts +4436 -0
  336. package/dist/schema/evaluation/index.js +1 -0
  337. package/dist/schema/index.d.ts +4 -0
  338. package/dist/schema/index.js +1 -13
  339. package/dist/schema/intent-radar/index.d.ts +284 -0
  340. package/dist/schema/intent-radar/index.js +1 -0
  341. package/dist/schema/local/index.d.ts +21 -21
  342. package/dist/schema/local/index.js +1 -927
  343. package/dist/schema/local/wip.js +1 -187
  344. package/dist/schema/messenger/index.d.ts +7 -7
  345. package/dist/schema/messenger/index.js +1 -475
  346. package/dist/schema/operations.d.ts +7 -7
  347. package/dist/schema/operations.js +1 -520
  348. package/dist/schema/persona/index.d.ts +1985 -0
  349. package/dist/schema/persona/index.js +1 -0
  350. package/dist/schema/project/index.d.ts +96 -50
  351. package/dist/schema/project/index.js +1 -2057
  352. package/dist/schema/query/index.d.ts +423 -7
  353. package/dist/schema/query/index.js +1 -1640
  354. package/dist/schema/schema-query/index.js +1 -104
  355. package/dist/schema/schema-version.js +1 -76
  356. package/dist/schema/sync-layer4.d.ts +1 -1
  357. package/dist/schema/sync-layer4.js +1 -282
  358. package/dist/schema/task-status.d.ts +168 -0
  359. package/dist/schema/task-status.js +1 -0
  360. package/dist/schema/trust/index.js +1 -314
  361. package/dist/schema/utils/guard-parser.js +1 -419
  362. package/dist/schema/utils/guard-query-utils.js +1 -46
  363. package/dist/schema/utils/node-parser.js +1 -369
  364. package/dist/schema/utils/object-type-utils.js +1 -35
  365. package/dist/schema/utils/permission-index-utils.js +1 -7
  366. package/dist/schema/utils/permission-machine-check.js +1 -121
  367. package/dist/schema/utils/skills-recommendation.js +1 -77
  368. package/dist/schema-query/index.js +1 -810
  369. package/dist/schemas/account_operation.output.json +5 -2
  370. package/dist/schemas/bridge_operation.output.json +5 -2
  371. package/dist/schemas/evaluation_operation.output.json +782 -0
  372. package/dist/schemas/evaluation_operation.schema.json +990 -0
  373. package/dist/schemas/index.json +25 -1
  374. package/dist/schemas/intent_radar.output.json +232 -0
  375. package/dist/schemas/intent_radar.schema.json +138 -0
  376. package/dist/schemas/local_info_operation.output.json +5 -2
  377. package/dist/schemas/local_mark_operation.output.json +5 -2
  378. package/dist/schemas/messenger_operation.output.json +5 -2
  379. package/dist/schemas/onchain_events.output.json +5 -2
  380. package/dist/schemas/onchain_operations.output.json +5 -2
  381. package/dist/schemas/onchain_operations.schema.json +6 -6
  382. package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
  383. package/dist/schemas/onchain_operations_machine.schema.json +2 -2
  384. package/dist/schemas/onchain_operations_service.schema.json +3 -3
  385. package/dist/schemas/onchain_table_data.output.json +6 -3
  386. package/dist/schemas/persona_operation.output.json +392 -0
  387. package/dist/schemas/persona_operation.schema.json +250 -0
  388. package/dist/schemas/project_operation.output.json +28 -8
  389. package/dist/schemas/query_task_status.output.json +115 -0
  390. package/dist/schemas/query_task_status.schema.json +24 -0
  391. package/dist/schemas/query_toolkit.output.json +9 -6
  392. package/dist/schemas/trust_score.schema.json +1 -1
  393. package/dist/schemas/wowok_buildin_info.output.json +132 -0
  394. package/dist/schemas/wowok_buildin_info.schema.json +14 -0
  395. package/dist/telemetry/index.js +1 -112
  396. package/dist/telemetry/redact.js +1 -23
  397. package/dist/telemetry/storage.js +1 -80
  398. package/dist/tools/handlers/bridge.js +1 -1
  399. package/dist/tools/handlers/config.js +1 -74
  400. package/dist/tools/handlers/evaluation.d.ts +2 -0
  401. package/dist/tools/handlers/evaluation.js +1 -0
  402. package/dist/tools/handlers/file-export.js +1 -90
  403. package/dist/tools/handlers/intent-radar.d.ts +2 -0
  404. package/dist/tools/handlers/intent-radar.js +1 -0
  405. package/dist/tools/handlers/local.js +1 -53
  406. package/dist/tools/handlers/messenger.js +1 -188
  407. package/dist/tools/handlers/onchain.js +1 -1082
  408. package/dist/tools/handlers/persona.d.ts +4 -0
  409. package/dist/tools/handlers/persona.js +1 -0
  410. package/dist/tools/handlers/project.js +1 -211
  411. package/dist/tools/handlers/query.js +1 -434
  412. package/dist/tools/handlers/schema-query.js +1 -176
  413. package/dist/tools/handlers/task-status.d.ts +0 -168
  414. package/dist/tools/handlers/task-status.js +1 -55
  415. package/dist/tools/handlers/trust.js +1 -380
  416. package/dist/tools/handlers/wip.js +1 -90
  417. package/dist/tools/index.js +1 -1306
  418. package/dist/tools/retry.js +1 -85
  419. package/dist/tools/rules-hook.js +1 -23
  420. package/dist/tools/shared.js +1 -130
  421. package/dist/tools/types.js +1 -1
  422. package/dist/tools/upgrade-check.d.ts +19 -0
  423. package/dist/tools/upgrade-check.js +1 -0
  424. package/dist/tools/wip-deploy-assist.d.ts +1 -1
  425. package/dist/tools/wip-deploy-assist.js +1 -278
  426. package/dist/tools/wrap.js +1 -500
  427. package/package.json +5 -3
@@ -1,615 +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: "Permission index not in Service range (300-320) used on Service object",
119
- check: (ctx) => {
120
- if (ctx.target_objects_types?.includes("Service")) {
121
- }
122
- return null;
123
- },
124
- };
125
- const R_S_2_01 = {
126
- id: "R-S-2-01",
127
- category: "semantic",
128
- trigger: "WIP hash tampering risk — owner updates WIP file without updating wip_hash",
129
- check: (ctx) => {
130
- if (ctx.sales && (ctx.sales.op === "add" || ctx.sales.op === "set")) {
131
- for (const s of ctx.sales.sales) {
132
- if (s.wip && !s.wip_hash) {
133
- return {
134
- id: "R-S-2-01",
135
- level: "CRITICAL",
136
- category: "semantic",
137
- title: "WIP hash missing — tampering risk",
138
- description: `Sale "${s.name}" has wip URL but no wip_hash. Owner could replace the WIP file without customers noticing.`,
139
- affected_stakeholders: ["customer", "owner"],
140
- scenario: "Owner sets wip without hash, then changes file content later",
141
- mitigation: "Always compute sha256(wip_file_content) and set as wip_hash. SDK auto-derives if omitted, but explicit hash is safer.",
142
- evidence: `sale=${s.name}`,
143
- };
144
- }
145
- }
146
- }
147
- return null;
148
- },
149
- };
150
- const R_S_2_02 = {
151
- id: "R-S-2-02",
152
- category: "semantic",
153
- trigger: "compensation_fund confused with Service balance (internal Balance<T>)",
154
- check: (ctx) => {
155
- if (ctx.compensation_fund_add) {
156
- return {
157
- id: "R-S-2-02",
158
- level: "HIGH",
159
- category: "semantic",
160
- title: "compensation_fund is internal Balance<T>, NOT Service-owned Treasury",
161
- 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).`,
162
- affected_stakeholders: ["owner", "arbitrator", "customer"],
163
- scenario: "Owner confuses compensation_fund with general Treasury",
164
- mitigation: "Use external Treasury (referenced via order_allocators.sharing.who=Entity) for general funds. Use compensation_fund only for arbitration payouts.",
165
- evidence: `deposit=${ctx.compensation_fund_add.balance}`,
166
- };
167
- }
168
- return null;
169
- },
170
- };
171
- const R_S_2_03 = {
172
- id: "R-S-2-03",
173
- category: "semantic",
174
- trigger: "quote side effect — stock deduction not rolled back on later failure",
175
- check: (ctx) => {
176
- if (ctx.order_new && ctx.order_new.buy.items.length > 0) {
177
- return {
178
- id: "R-S-2-03",
179
- level: "HIGH",
180
- category: "semantic",
181
- title: "Order flow: stock deducted at quote stage — NOT rolled back on failure",
182
- 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.`,
183
- affected_stakeholders: ["owner", "customer"],
184
- scenario: "Customer's transaction fails after quote but stock is gone",
185
- 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.",
186
- evidence: `items=${ctx.order_new.buy.items.length}`,
187
- };
188
- }
189
- return null;
190
- },
191
- };
192
- const R_S_2_04 = {
193
- id: "R-S-2-04",
194
- category: "semantic",
195
- trigger: "Discount issuance — verify type and total count semantics",
196
- check: (ctx) => {
197
- if (ctx.discount) {
198
- const count = ctx.discount.count;
199
- if (count > MAX_DISCOUNT_TOTAL_COUNT) {
200
- return {
201
- id: "R-S-2-04",
202
- level: "MEDIUM",
203
- category: "semantic",
204
- title: "Discount count exceeds total cap",
205
- description: `Issuing ${count} discounts exceeds MAX_DISCOUNT_TOTAL_COUNT ${MAX_DISCOUNT_TOTAL_COUNT}`,
206
- affected_stakeholders: ["owner"],
207
- scenario: "Bulk discount issuance",
208
- mitigation: `Issue in batches of <= 1000 (MAX_DISCOUNT_COUNT_ONCE) and keep total <= ${MAX_DISCOUNT_TOTAL_COUNT}`,
209
- evidence: `count=${count}`,
210
- };
211
- }
212
- }
213
- return null;
214
- },
215
- };
216
- const R_S_2_05 = {
217
- id: "R-S-2-05",
218
- category: "semantic",
219
- trigger: "Order placed without verifying WIP hash — buyer passes empty wip_hash",
220
- check: (ctx) => {
221
- if (ctx.order_new) {
222
- const emptyHashItems = ctx.order_new.buy.items.filter(i => i.wip_hash === "");
223
- if (emptyHashItems.length > 0) {
224
- return {
225
- id: "R-S-2-05",
226
- level: "MEDIUM",
227
- category: "semantic",
228
- title: "Order with empty wip_hash — SDK auto-fills from sale",
229
- 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.`,
230
- affected_stakeholders: ["customer"],
231
- scenario: "Time-of-check to time-of-use WIP mismatch",
232
- mitigation: "Buyer should explicitly pass the wip_hash they saw when viewing the product. Empty string is convenience but riskier.",
233
- evidence: `empty_hash_items=${emptyHashItems.length}`,
234
- };
235
- }
236
- }
237
- return null;
238
- },
239
- };
240
- const R_S_3_01 = {
241
- id: "R-S-3-01",
242
- category: "authority",
243
- trigger: "publish operation — requires SERVICE_PUBLISH (311) + prerequisites",
244
- check: (ctx) => {
245
- if (!ctx.publish)
246
- return null;
247
- const blockers = [];
248
- if (!ctx.current_order_allocators_set)
249
- blockers.push("order_allocators not set (F-S-18, E_NO_ALLOCATOR)");
250
- const compBalance = ctx.current_compensation_fund_balance ?? "0";
251
- if (BigInt(compBalance) > 0n && (ctx.current_arbitrations_count ?? 0) === 0) {
252
- blockers.push("compensation_fund > 0 but no arbitrations (F-S-19, E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND)");
253
- }
254
- if (blockers.length > 0) {
255
- return {
256
- id: "R-S-3-01",
257
- level: "CRITICAL",
258
- category: "authority",
259
- title: "Publish blocked — prerequisites not met",
260
- description: `Cannot publish: ${blockers.join("; ")}`,
261
- affected_stakeholders: ["owner"],
262
- scenario: "Owner attempts publish without configuring prerequisites",
263
- mitigation: "Configure order_allocators (and arbitrations if compensation_fund > 0) before publish",
264
- evidence: `blockers=${blockers.length}`,
265
- };
266
- }
267
- return null;
268
- },
269
- };
270
- const R_S_3_02 = {
271
- id: "R-S-3-02",
272
- category: "authority",
273
- trigger: "pause operation — affects new orders but not existing Progress",
274
- check: (ctx) => {
275
- if (ctx.pause === undefined)
276
- return null;
277
- return {
278
- id: "R-S-3-02",
279
- level: "MEDIUM",
280
- category: "authority",
281
- title: ctx.pause ? "Pausing Service — new orders blocked, existing Progress continues" : "Resuming Service — new orders accepted",
282
- description: ctx.pause
283
- ? "Service.bPaused = true will reject new orders (E_SERVICE_PAUSED). Existing orders' Progress continues normally."
284
- : "Service.bPaused = false will allow new orders again.",
285
- affected_stakeholders: ["owner", "customer"],
286
- scenario: ctx.pause ? "Owner pauses for maintenance/stockout" : "Owner resumes after maintenance",
287
- mitigation: ctx.pause ? "Communicate pause to customers. Use compensation_fund_withdraw only when paused." : "Verify stock levels before resuming.",
288
- evidence: `pause=${ctx.pause}`,
289
- };
290
- },
291
- };
292
- const R_S_3_03 = {
293
- id: "R-S-3-03",
294
- category: "authority",
295
- trigger: "buy_guard change — post-publish mutable (unusual exception)",
296
- check: (ctx) => {
297
- if (ctx.buy_guard === undefined)
298
- return null;
299
- if (ctx.current_bPublished) {
300
- return {
301
- id: "R-S-3-03",
302
- level: "MEDIUM",
303
- category: "authority",
304
- title: "buy_guard change post-publish — unusual mutability",
305
- description: `buy_guard is the ONLY publish-locked-field exception: it remains mutable post-publish. Other fields (machine/arbitrations/order_allocators) are immutable.`,
306
- affected_stakeholders: ["owner", "customer"],
307
- scenario: "Owner changes buy_guard strategy after publish (e.g. whitelist → public)",
308
- mitigation: "Document buy_guard changes for transparency. Customers should re-verify buy_guard before ordering.",
309
- evidence: `buy_guard=${ctx.buy_guard ?? "(cleared)"}`,
310
- };
311
- }
312
- return null;
313
- },
314
- };
315
- const R_S_3_04 = {
316
- id: "R-S-3-04",
317
- category: "authority",
318
- trigger: "Ownership transfer (builder field) — irreversible",
319
- check: (ctx) => {
320
- if (!ctx.builder)
321
- return null;
322
- return {
323
- id: "R-S-3-04",
324
- level: "HIGH",
325
- category: "authority",
326
- title: "Service ownership transfer — IRREVERSIBLE",
327
- description: `Transferring Service to ${ctx.builder}. Original owner loses ALL control. New owner inherits permission + compensation_fund + all bindings.`,
328
- affected_stakeholders: ["owner"],
329
- scenario: "Owner transfers Service to new address",
330
- mitigation: "1) Verify new owner address twice. 2) Withdraw compensation_fund first (if applicable). 3) Export Service JSON before transfer.",
331
- evidence: `new_owner=${ctx.builder}`,
332
- };
333
- },
334
- };
335
- const R_S_4_01 = {
336
- id: "R-S-4-01",
337
- category: "lifecycle",
338
- trigger: "publish is irreversible — bPublished cannot be reset to false",
339
- check: (ctx) => {
340
- if (!ctx.publish)
341
- return null;
342
- if (ctx.current_bPublished) {
343
- return {
344
- id: "R-S-4-01",
345
- level: "HIGH",
346
- category: "lifecycle",
347
- title: "Service already published — publish is no-op",
348
- description: "Service.bPublished is already true. Subsequent publish calls have no effect (bPublished is one-shot, cannot revert).",
349
- affected_stakeholders: ["owner"],
350
- scenario: "Owner calls publish again on already-published Service",
351
- mitigation: "Skip publish if already published. To 'reset' a Service, create a new one.",
352
- evidence: `bPublished=true`,
353
- };
354
- }
355
- return {
356
- id: "R-S-4-01",
357
- level: "HIGH",
358
- category: "lifecycle",
359
- title: "Publish is IRREVERSIBLE — 3 fields will be locked forever",
360
- description: "Once published: machine (306), arbitrations (308), order_allocators (313) become permanently immutable. bPublished cannot be reset to false. Clone Service to make changes.",
361
- affected_stakeholders: ["owner", "customer"],
362
- scenario: "Owner publishes Service for the first time",
363
- mitigation: "Verify all configurations before publish. Run pre-publish checklist (service-confirm.ts).",
364
- evidence: `bPublished=false→true`,
365
- };
366
- },
367
- };
368
- const R_S_4_02 = {
369
- id: "R-S-4-02",
370
- category: "lifecycle",
371
- trigger: "setting_lock_duration add — only-increase mechanism",
372
- check: (ctx) => {
373
- if (ctx.setting_lock_duration_add === undefined)
374
- return null;
375
- return {
376
- id: "R-S-4-02",
377
- level: "MEDIUM",
378
- category: "lifecycle",
379
- title: "setting_lock_duration can only INCREASE",
380
- 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.`,
381
- affected_stakeholders: ["owner", "customer"],
382
- scenario: "Owner extends lock period to build trust",
383
- mitigation: "Ensure extension is intentional. Lock affects rewards/compensation_fund_withdraw/compensation_fund_receive.",
384
- evidence: `add_ms=${ctx.setting_lock_duration_add}`,
385
- };
386
- },
387
- };
388
- const R_S_4_03 = {
389
- id: "R-S-4-03",
390
- category: "lifecycle",
391
- trigger: "machine/arbitrations/order_allocators modification after publish — SDK blocks",
392
- check: (ctx) => {
393
- if (!ctx.current_bPublished)
394
- return null;
395
- const blockedFields = [];
396
- if (ctx.machine !== undefined)
397
- blockedFields.push("machine (306)");
398
- if (ctx.arbitrations !== undefined)
399
- blockedFields.push("arbitrations (308)");
400
- if (ctx.order_allocators !== undefined)
401
- blockedFields.push("order_allocators (313)");
402
- if (blockedFields.length > 0) {
403
- return {
404
- id: "R-S-4-03",
405
- level: "HIGH",
406
- category: "lifecycle",
407
- title: "Post-publish modification blocked by SDK",
408
- description: `Service is published. Cannot modify: ${blockedFields.join(", ")}. SDK checkNotPublished() will abort. To change these fields, clone the Service.`,
409
- affected_stakeholders: ["owner"],
410
- scenario: "Owner attempts to change locked field post-publish",
411
- mitigation: "Create a new Service with the desired configuration. Migrate active orders if needed.",
412
- evidence: `blocked=${blockedFields.join(",")}`,
413
- };
414
- }
415
- return null;
416
- },
417
- };
418
- const R_S_4_04 = {
419
- id: "R-S-4-04",
420
- category: "lifecycle",
421
- trigger: "sales modification — stock/price changes affect future orders only",
422
- check: (ctx) => {
423
- if (!ctx.sales)
424
- return null;
425
- return {
426
- id: "R-S-4-04",
427
- level: "LOW",
428
- category: "lifecycle",
429
- title: "Sales modification affects future orders only",
430
- description: "Sales add/set/remove/clear changes do NOT affect already-created Orders. Existing Orders' Progress continues with the original sale parameters.",
431
- affected_stakeholders: ["owner", "customer"],
432
- scenario: "Owner updates prices mid-campaign",
433
- mitigation: "Communicate price/stock changes to customers. Existing orders are unaffected.",
434
- evidence: `sales_op=${ctx.sales.op}`,
435
- };
436
- },
437
- };
438
- const R_S_5_01 = {
439
- id: "R-S-5-01",
440
- category: "cross_object",
441
- trigger: "Machine binding — post-publish immutable, Progress inherits",
442
- check: (ctx) => {
443
- if (ctx.machine === undefined)
444
- return null;
445
- if (ctx.current_bPublished) {
446
- return {
447
- id: "R-S-5-01",
448
- level: "HIGH",
449
- category: "cross_object",
450
- title: "Machine binding immutable post-publish",
451
- description: `Service is published; machine cannot be changed. All future Progress objects will use the bound Machine.`,
452
- affected_stakeholders: ["owner"],
453
- scenario: "Owner wants to upgrade workflow post-publish",
454
- mitigation: "Create new Service with new Machine. Migrate customers via discounts.",
455
- evidence: `machine=${ctx.machine ?? "(cleared)"}`,
456
- };
457
- }
458
- return {
459
- id: "R-S-5-01",
460
- level: "MEDIUM",
461
- category: "cross_object",
462
- title: "Machine binding — verify Machine is published",
463
- description: `Binding Machine ${ctx.machine}. Ensure Machine is published (machine::publish) — Service cannot bind unpublished Machine.`,
464
- affected_stakeholders: ["owner"],
465
- scenario: "Owner binds Machine before publishing Service",
466
- mitigation: "Verify Machine.bPublished = true before binding.",
467
- evidence: `machine=${ctx.machine}`,
468
- };
469
- },
470
- };
471
- const R_S_5_02 = {
472
- id: "R-S-5-02",
473
- category: "cross_object",
474
- trigger: "Arbitration binding — required when compensation_fund > 0",
475
- check: (ctx) => {
476
- if (!ctx.arbitrations)
477
- return null;
478
- const compBalance = ctx.current_compensation_fund_balance ?? "0";
479
- if (BigInt(compBalance) > 0n && (ctx.current_arbitrations_count ?? 0) === 0) {
480
- return {
481
- id: "R-S-5-02",
482
- level: "HIGH",
483
- category: "cross_object",
484
- title: "Arbitration required — compensation_fund has balance",
485
- description: `compensation_fund balance is ${compBalance}. Publish will fail (E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND) until arbitrations is non-empty.`,
486
- affected_stakeholders: ["owner"],
487
- scenario: "Owner deposits compensation_fund without configuring arbitrations",
488
- mitigation: "Add at least 1 Arbitration object before publish.",
489
- evidence: `compensation_fund=${compBalance}`,
490
- };
491
- }
492
- return null;
493
- },
494
- };
495
- const R_S_5_03 = {
496
- id: "R-S-5-03",
497
- category: "cross_object",
498
- trigger: "order_allocators binding — publish prerequisite, post-publish immutable",
499
- check: (ctx) => {
500
- if (ctx.order_allocators === undefined)
501
- return null;
502
- if (ctx.current_bPublished) {
503
- return {
504
- id: "R-S-5-03",
505
- level: "HIGH",
506
- category: "cross_object",
507
- title: "order_allocators immutable post-publish",
508
- description: "Service is published; order_allocators cannot be changed. Fund distribution strategy is permanently locked.",
509
- affected_stakeholders: ["owner"],
510
- scenario: "Owner wants to adjust fee split post-publish",
511
- mitigation: "Create new Service with new allocators. Cannot migrate existing Orders.",
512
- evidence: `order_allocators=${ctx.order_allocators ? "(set)" : "(cleared)"}`,
513
- };
514
- }
515
- if (ctx.publish && !ctx.order_allocators) {
516
- return {
517
- id: "R-S-5-03",
518
- level: "CRITICAL",
519
- category: "cross_object",
520
- title: "Publish without order_allocators — will fail",
521
- description: "Publish will abort with E_NO_ALLOCATOR. order_allocators is a mandatory publish prerequisite.",
522
- affected_stakeholders: ["owner"],
523
- scenario: "Owner attempts publish without configuring allocators",
524
- mitigation: "Set order_allocators before publish.",
525
- evidence: `order_allocators=null`,
526
- };
527
- }
528
- return null;
529
- },
530
- };
531
- const R_S_5_04 = {
532
- id: "R-S-5-04",
533
- category: "cross_object",
534
- trigger: "Repository/Reward binding — verify object types before adding",
535
- check: (ctx) => {
536
- if (ctx.repositories && (ctx.repositories.op === "add" || ctx.repositories.op === "set")) {
537
- return {
538
- id: "R-S-5-04",
539
- level: "LOW",
540
- category: "cross_object",
541
- title: "Repository binding — verify object types",
542
- description: `Adding ${ctx.repositories.objects.length} repositories. SDK uses queryObjectsWithType to validate each is ObjectType.Repository before binding.`,
543
- affected_stakeholders: ["owner"],
544
- scenario: "Owner adds non-Repository object by mistake",
545
- mitigation: "Use LocalMark names or addresses that are confirmed Repository objects.",
546
- evidence: `objects=${ctx.repositories.objects.length}`,
547
- };
548
- }
549
- if (ctx.rewards && (ctx.rewards.op === "add" || ctx.rewards.op === "set")) {
550
- return {
551
- id: "R-S-5-04",
552
- level: "LOW",
553
- category: "cross_object",
554
- title: "Reward binding — verify object types + lock_duration",
555
- description: `Adding ${ctx.rewards.objects.length} rewards. SDK validates ObjectType.Reward. Note: rewards modification is locked by setting_lock_duration.`,
556
- affected_stakeholders: ["owner"],
557
- scenario: "Owner adds Reward objects",
558
- mitigation: "Verify Reward objects exist and are active. Be aware of lock_duration implications.",
559
- evidence: `objects=${ctx.rewards.objects.length}`,
560
- };
561
- }
562
- return null;
563
- },
564
- };
565
- const ALL_RULES = [
566
- R_S_1_01, R_S_1_02, R_S_1_03, R_S_1_04, R_S_1_05,
567
- R_S_2_01, R_S_2_02, R_S_2_03, R_S_2_04, R_S_2_05,
568
- R_S_3_01, R_S_3_02, R_S_3_03, R_S_3_04,
569
- R_S_4_01, R_S_4_02, R_S_4_03, R_S_4_04,
570
- R_S_5_01, R_S_5_02, R_S_5_03, R_S_5_04,
571
- ];
572
- export const SERVICE_RISK_VERSION = "1.0.0";
573
- export function getAllServiceRiskRules() {
574
- return [...ALL_RULES];
575
- }
576
- export function getServiceRiskRulesCount() {
577
- return ALL_RULES.length;
578
- }
579
- export function getServiceRiskRulesByCategory(category) {
580
- return ALL_RULES.filter(r => r.category === category);
581
- }
582
- export function assessServiceRisks(ctx) {
583
- const risks = [];
584
- for (const rule of ALL_RULES) {
585
- const r = rule.check(ctx);
586
- if (r)
587
- risks.push(r);
588
- }
589
- const overall = risks.length === 0
590
- ? "LOW"
591
- : risks.some(r => r.level === "CRITICAL") ? "CRITICAL"
592
- : risks.some(r => r.level === "HIGH") ? "HIGH"
593
- : risks.some(r => r.level === "MEDIUM") ? "MEDIUM"
594
- : "LOW";
595
- const byCategory = {};
596
- for (const r of risks) {
597
- byCategory[r.category] = (byCategory[r.category] ?? 0) + 1;
598
- }
599
- const advice = {};
600
- for (const r of risks) {
601
- for (const s of r.affected_stakeholders) {
602
- if (!advice[s])
603
- advice[s] = [];
604
- advice[s].push(`${r.id}: ${r.mitigation}`);
605
- }
606
- }
607
- return {
608
- summary: `Assessed ${risks.length} risk(s) across ${Object.keys(byCategory).length} categories`,
609
- risks,
610
- overall_risk: overall,
611
- risks_by_category: byCategory,
612
- stakeholder_advice: advice,
613
- needs_human_review: risks.some(r => r.level === "CRITICAL" || r.level === "HIGH"),
614
- };
615
- }
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_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;}},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_5_01,R_S_5_02,R_S_5_03,R_S_5_04];export const SERVICE_RISK_VERSION='1.0.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')};}