@wowok/agent-mcp 2.7.1 → 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 (375) 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.js +1 -397
  13. package/dist/customer/types.js +1 -13
  14. package/dist/customer/user-preferences.js +1 -460
  15. package/dist/evaluation/arbitration-game.d.ts +9 -2
  16. package/dist/evaluation/arbitration-game.js +1 -48
  17. package/dist/evaluation/builtins/demand-match.js +1 -153
  18. package/dist/evaluation/builtins/index.js +1 -10
  19. package/dist/evaluation/builtins/service-risk.js +1 -55
  20. package/dist/evaluation/capability.js +1 -13
  21. package/dist/evaluation/composer.js +1 -40
  22. package/dist/evaluation/engine.js +1 -175
  23. package/dist/evaluation/extract.js +1 -115
  24. package/dist/evaluation/game-strategy.d.ts +27 -0
  25. package/dist/evaluation/game-strategy.js +1 -0
  26. package/dist/evaluation/gap.js +1 -100
  27. package/dist/evaluation/index.d.ts +1 -0
  28. package/dist/evaluation/index.js +1 -11
  29. package/dist/evaluation/node-game.d.ts +31 -3
  30. package/dist/evaluation/node-game.js +1 -57
  31. package/dist/evaluation/region.js +1 -36
  32. package/dist/evaluation/types.d.ts +1 -0
  33. package/dist/evaluation/types.js +1 -1
  34. package/dist/evaluation/user-injection.js +1 -27
  35. package/dist/experience/experience-reuse.js +1 -103
  36. package/dist/experience/index.js +1 -5
  37. package/dist/experience/intent-distill.js +1 -83
  38. package/dist/experience/realtime-feedback.js +1 -94
  39. package/dist/experience/types.js +1 -1
  40. package/dist/experience/user-profile.js +1 -171
  41. package/dist/extensions/business-modules.js +1 -287
  42. package/dist/extensions/capability-manifest.js +1 -781
  43. package/dist/extensions/constraint-registry.js +1 -198
  44. package/dist/extensions/index.js +1 -6
  45. package/dist/extensions/metric-registry.js +1 -257
  46. package/dist/extensions/mode-evaluator.js +1 -170
  47. package/dist/extensions/modes.js +1 -499
  48. package/dist/extensions/registry.js +1 -717
  49. package/dist/extensions/types.js +1 -1
  50. package/dist/harness/auto-escalation.js +1 -68
  51. package/dist/harness/checkpoint.js +1 -129
  52. package/dist/harness/index.js +1 -78
  53. package/dist/harness/plan.js +1 -315
  54. package/dist/harness/recover.js +1 -139
  55. package/dist/harness/types.js +1 -1
  56. package/dist/harness/verify.js +1 -237
  57. package/dist/index.js +1 -273
  58. package/dist/intent/enrich.js +1 -67
  59. package/dist/intent/index.js +1 -60
  60. package/dist/intent/matcher.js +1 -81
  61. package/dist/intent/store.js +1 -55
  62. package/dist/intent/types.js +1 -10
  63. package/dist/knowledge/acquisition-flywheel.js +1 -192
  64. package/dist/knowledge/allocation-confirm.js +1 -534
  65. package/dist/knowledge/allocation-context.js +1 -249
  66. package/dist/knowledge/allocation-ledger.js +1 -463
  67. package/dist/knowledge/allocation-puzzle.js +1 -298
  68. package/dist/knowledge/allocation-risk.js +1 -568
  69. package/dist/knowledge/allocation-templates.js +1 -970
  70. package/dist/knowledge/allocation-translation.js +1 -585
  71. package/dist/knowledge/arb-risk.js +1 -210
  72. package/dist/knowledge/arbitration-confirm.js +1 -559
  73. package/dist/knowledge/arbitration-context.js +1 -505
  74. package/dist/knowledge/arbitration-ledger.js +1 -521
  75. package/dist/knowledge/arbitration-puzzle.js +1 -304
  76. package/dist/knowledge/arbitration-risk.js +1 -423
  77. package/dist/knowledge/arbitration-templates.js +1 -276
  78. package/dist/knowledge/arbitration-translation.js +1 -487
  79. package/dist/knowledge/arbitration-trust.js +1 -117
  80. package/dist/knowledge/audit-rules.js +1 -141
  81. package/dist/knowledge/bridge-risk.js +1 -263
  82. package/dist/knowledge/contact-risk.js +1 -200
  83. package/dist/knowledge/contact-templates.js +1 -60
  84. package/dist/knowledge/demand-confirm.js +1 -206
  85. package/dist/knowledge/demand-matching.js +1 -132
  86. package/dist/knowledge/demand-risk.js +1 -240
  87. package/dist/knowledge/demand-translation.js +1 -354
  88. package/dist/knowledge/deployment-scanner.js +1 -823
  89. package/dist/knowledge/dynamic-pricing.js +1 -87
  90. package/dist/knowledge/examples-scanner-cli.js +1 -26
  91. package/dist/knowledge/examples-scanner.js +1 -843
  92. package/dist/knowledge/flywheel-loop.js +1 -404
  93. package/dist/knowledge/fund-layer.js +1 -973
  94. package/dist/knowledge/glossary.js +1 -211
  95. package/dist/knowledge/guard-confirm.js +1 -406
  96. package/dist/knowledge/guard-context.js +1 -287
  97. package/dist/knowledge/guard-design-patterns.js +1 -360
  98. package/dist/knowledge/guard-ledger.js +1 -260
  99. package/dist/knowledge/guard-lint.js +1 -670
  100. package/dist/knowledge/guard-migration.js +1 -228
  101. package/dist/knowledge/guard-puzzle.js +1 -805
  102. package/dist/knowledge/guard-render.js +1 -700
  103. package/dist/knowledge/guard-risk.js +1 -1879
  104. package/dist/knowledge/guard-submission-prompt.js +1 -171
  105. package/dist/knowledge/guard-templates.js +1 -1105
  106. package/dist/knowledge/guard-translation.js +1 -1119
  107. package/dist/knowledge/index.js +1 -436
  108. package/dist/knowledge/industry-evolution.js +1 -323
  109. package/dist/knowledge/industry-generalizer.js +1 -381
  110. package/dist/knowledge/industry-registry.js +1 -174
  111. package/dist/knowledge/intent-metrics.d.ts +4 -3
  112. package/dist/knowledge/intent-metrics.js +1 -566
  113. package/dist/knowledge/machine-confirm.js +1 -559
  114. package/dist/knowledge/machine-context.js +1 -833
  115. package/dist/knowledge/machine-ledger.js +1 -338
  116. package/dist/knowledge/machine-puzzle.js +1 -494
  117. package/dist/knowledge/machine-render.js +1 -565
  118. package/dist/knowledge/machine-risk.js +1 -669
  119. package/dist/knowledge/machine-templates.js +1 -1597
  120. package/dist/knowledge/machine-topology.js +1 -234
  121. package/dist/knowledge/machine-translation.js +1 -513
  122. package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
  123. package/dist/knowledge/mcp-schema-audit.js +1 -777
  124. package/dist/knowledge/onchain-constants.js +1 -35
  125. package/dist/knowledge/order-confirm.js +1 -573
  126. package/dist/knowledge/order-context.js +1 -390
  127. package/dist/knowledge/order-ledger.js +1 -341
  128. package/dist/knowledge/order-puzzle.js +1 -255
  129. package/dist/knowledge/order-risk.js +1 -653
  130. package/dist/knowledge/order-templates.js +1 -368
  131. package/dist/knowledge/order-translation.js +1 -550
  132. package/dist/knowledge/overrides-loader.js +1 -65
  133. package/dist/knowledge/passport-confirm.js +1 -531
  134. package/dist/knowledge/passport-context.js +1 -306
  135. package/dist/knowledge/passport-ledger.js +1 -282
  136. package/dist/knowledge/passport-puzzle.js +1 -333
  137. package/dist/knowledge/passport-risk.js +1 -450
  138. package/dist/knowledge/passport-templates.js +1 -568
  139. package/dist/knowledge/passport-translation.js +1 -516
  140. package/dist/knowledge/payment-risk.js +1 -249
  141. package/dist/knowledge/permission-confirm.js +1 -426
  142. package/dist/knowledge/permission-context.js +1 -224
  143. package/dist/knowledge/permission-ledger.js +1 -403
  144. package/dist/knowledge/permission-puzzle.js +1 -173
  145. package/dist/knowledge/permission-risk.js +1 -411
  146. package/dist/knowledge/permission-templates.js +1 -234
  147. package/dist/knowledge/permission-translation.js +1 -350
  148. package/dist/knowledge/personal-risk.js +1 -212
  149. package/dist/knowledge/process-model.js +1 -160
  150. package/dist/knowledge/progress-confirm.js +1 -456
  151. package/dist/knowledge/progress-context.js +1 -452
  152. package/dist/knowledge/progress-ledger.js +1 -330
  153. package/dist/knowledge/progress-puzzle.js +1 -219
  154. package/dist/knowledge/progress-risk.js +1 -461
  155. package/dist/knowledge/progress-templates.js +1 -228
  156. package/dist/knowledge/progress-translation.js +1 -405
  157. package/dist/knowledge/proof-confirm.js +1 -187
  158. package/dist/knowledge/proof-risk.js +1 -207
  159. package/dist/knowledge/proof-translation.js +1 -283
  160. package/dist/knowledge/registrar-risk.js +1 -217
  161. package/dist/knowledge/repository-confirm.js +1 -286
  162. package/dist/knowledge/repository-risk.js +1 -373
  163. package/dist/knowledge/repository-translation.js +1 -445
  164. package/dist/knowledge/reputation-rules.js +1 -99
  165. package/dist/knowledge/resource-risk.js +1 -157
  166. package/dist/knowledge/reward-confirm.js +1 -526
  167. package/dist/knowledge/reward-context.js +1 -504
  168. package/dist/knowledge/reward-ledger.js +1 -502
  169. package/dist/knowledge/reward-puzzle.js +1 -300
  170. package/dist/knowledge/reward-risk.js +1 -627
  171. package/dist/knowledge/reward-templates.js +1 -197
  172. package/dist/knowledge/reward-translation.js +1 -501
  173. package/dist/knowledge/safety-rules.js +1 -404
  174. package/dist/knowledge/scenario-modes.js +1 -321
  175. package/dist/knowledge/service-confirm.js +1 -807
  176. package/dist/knowledge/service-context.js +1 -403
  177. package/dist/knowledge/service-ledger.js +1 -609
  178. package/dist/knowledge/service-puzzle.js +1 -236
  179. package/dist/knowledge/service-risk.js +1 -651
  180. package/dist/knowledge/service-templates.js +1 -456
  181. package/dist/knowledge/service-translation.js +1 -622
  182. package/dist/knowledge/template-registry.js +1 -353
  183. package/dist/knowledge/tool-constraints.js +1 -195
  184. package/dist/knowledge/tools-reference.js +1 -178
  185. package/dist/knowledge/treasury-confirm.js +1 -512
  186. package/dist/knowledge/treasury-context.js +1 -363
  187. package/dist/knowledge/treasury-ledger.js +1 -300
  188. package/dist/knowledge/treasury-puzzle.js +1 -216
  189. package/dist/knowledge/treasury-risk.js +1 -440
  190. package/dist/knowledge/treasury-templates.js +1 -358
  191. package/dist/knowledge/treasury-translation.js +1 -498
  192. package/dist/knowledge/trust-metrics.js +1 -198
  193. package/dist/knowledge/util-risk.js +1 -135
  194. package/dist/loop-engineering/aggregate.js +1 -132
  195. package/dist/loop-engineering/context-collect.js +1 -83
  196. package/dist/loop-engineering/diagnose.js +1 -273
  197. package/dist/loop-engineering/improve.js +1 -405
  198. package/dist/loop-engineering/index.js +1 -4
  199. package/dist/loop-engineering/pipeline.js +1 -56
  200. package/dist/mode-market/index.js +1 -3
  201. package/dist/mode-market/registry.js +1 -124
  202. package/dist/mode-market/review.js +1 -214
  203. package/dist/mode-market/submission.js +1 -85
  204. package/dist/participation/collaborator-interest.d.ts +23 -0
  205. package/dist/participation/collaborator-interest.js +1 -0
  206. package/dist/participation/customer-interest.d.ts +25 -0
  207. package/dist/participation/customer-interest.js +1 -0
  208. package/dist/participation/merchant-interest.js +1 -100
  209. package/dist/participation/radar-core.d.ts +13 -3
  210. package/dist/participation/radar-core.js +1 -269
  211. package/dist/participation/supplier-interest.d.ts +25 -0
  212. package/dist/participation/supplier-interest.js +1 -0
  213. package/dist/persona/analyzer.js +1 -66
  214. package/dist/persona/bridge.js +1 -86
  215. package/dist/persona/defaults.js +1 -195
  216. package/dist/persona/experience-bridge.js +1 -23
  217. package/dist/persona/index.js +1 -71
  218. package/dist/persona/model.js +1 -111
  219. package/dist/persona/store.js +1 -62
  220. package/dist/persona/types.d.ts +3 -1
  221. package/dist/persona/types.js +1 -5
  222. package/dist/project/business-puzzle.js +1 -383
  223. package/dist/project/context-assembly.js +1 -254
  224. package/dist/project/deployment-bridge.js +1 -120
  225. package/dist/project/deployment-doc.js +1 -1126
  226. package/dist/project/edit-planner.js +1 -1342
  227. package/dist/project/evaluation.js +1 -2011
  228. package/dist/project/game-theory.js +1 -177
  229. package/dist/project/graph-builder.js +1 -656
  230. package/dist/project/graph.js +1 -340
  231. package/dist/project/handlers.js +1 -1784
  232. package/dist/project/index.d.ts +1 -0
  233. package/dist/project/index.js +1 -301
  234. package/dist/project/intent-analyzer.js +1 -149
  235. package/dist/project/machine-nodes.js +1 -36
  236. package/dist/project/merchant-guide.js +1 -264
  237. package/dist/project/migration.js +1 -125
  238. package/dist/project/mode-actions.js +1 -309
  239. package/dist/project/namespace.js +1 -206
  240. package/dist/project/participation-radar.js +1 -428
  241. package/dist/project/pipeline-actions.js +1 -109
  242. package/dist/project/project-store.js +1 -422
  243. package/dist/project/query.js +1 -153
  244. package/dist/project/reverse-mapping.d.ts +34 -0
  245. package/dist/project/reverse-mapping.js +1 -0
  246. package/dist/project/risk-aggregator.js +1 -295
  247. package/dist/project/rollback-policy.js +1 -290
  248. package/dist/project/semantic-assembler.js +1 -345
  249. package/dist/project/semantic-graph.js +1 -292
  250. package/dist/project/stage-gate.js +1 -369
  251. package/dist/project/substep-trace.js +1 -332
  252. package/dist/project/task-tracker.js +1 -78
  253. package/dist/role/derivation.d.ts +18 -0
  254. package/dist/role/derivation.js +1 -0
  255. package/dist/role/index.d.ts +5 -0
  256. package/dist/role/index.js +1 -0
  257. package/dist/role/model.d.ts +8 -0
  258. package/dist/role/model.js +1 -0
  259. package/dist/role/resolution.d.ts +11 -0
  260. package/dist/role/resolution.js +1 -0
  261. package/dist/role/types.d.ts +11 -0
  262. package/dist/role/types.js +1 -0
  263. package/dist/rules.js +1 -52
  264. package/dist/safety/confirm-gate.js +1 -88
  265. package/dist/safety/index.js +1 -3
  266. package/dist/safety/preview.js +1 -52
  267. package/dist/schema/call/allocation.js +1 -34
  268. package/dist/schema/call/arbitration.js +1 -113
  269. package/dist/schema/call/base.d.ts +15 -15
  270. package/dist/schema/call/base.js +1 -370
  271. package/dist/schema/call/bridge-handler.js +1 -265
  272. package/dist/schema/call/bridge.d.ts +7 -7
  273. package/dist/schema/call/bridge.js +1 -458
  274. package/dist/schema/call/contact.js +1 -37
  275. package/dist/schema/call/demand.js +1 -47
  276. package/dist/schema/call/guard.js +1 -161
  277. package/dist/schema/call/handler.js +1 -322
  278. package/dist/schema/call/index.js +1 -20
  279. package/dist/schema/call/machine.js +1 -193
  280. package/dist/schema/call/order.js +1 -35
  281. package/dist/schema/call/payment.js +1 -37
  282. package/dist/schema/call/permission-handler.js +1 -54
  283. package/dist/schema/call/permission.js +1 -105
  284. package/dist/schema/call/personal.js +1 -78
  285. package/dist/schema/call/progress.js +1 -47
  286. package/dist/schema/call/proof.js +1 -33
  287. package/dist/schema/call/repository.js +1 -77
  288. package/dist/schema/call/reward.js +1 -30
  289. package/dist/schema/call/semantic.js +1 -1679
  290. package/dist/schema/call/service.js +1 -184
  291. package/dist/schema/call/treasury.js +1 -71
  292. package/dist/schema/common/index.js +1 -407
  293. package/dist/schema/config/index.js +1 -68
  294. package/dist/schema/evaluation/index.d.ts +213 -16
  295. package/dist/schema/evaluation/index.js +1 -356
  296. package/dist/schema/index.js +1 -17
  297. package/dist/schema/intent-radar/index.d.ts +13 -13
  298. package/dist/schema/intent-radar/index.js +1 -89
  299. package/dist/schema/local/index.d.ts +21 -21
  300. package/dist/schema/local/index.js +1 -927
  301. package/dist/schema/local/wip.js +1 -187
  302. package/dist/schema/messenger/index.d.ts +7 -7
  303. package/dist/schema/messenger/index.js +1 -475
  304. package/dist/schema/operations.d.ts +7 -7
  305. package/dist/schema/operations.js +1 -520
  306. package/dist/schema/persona/index.d.ts +54 -54
  307. package/dist/schema/persona/index.js +1 -148
  308. package/dist/schema/project/index.d.ts +94 -48
  309. package/dist/schema/project/index.js +1 -2057
  310. package/dist/schema/query/index.d.ts +423 -7
  311. package/dist/schema/query/index.js +1 -1646
  312. package/dist/schema/schema-query/index.js +1 -104
  313. package/dist/schema/schema-version.js +1 -76
  314. package/dist/schema/sync-layer4.js +1 -286
  315. package/dist/schema/task-status.js +1 -36
  316. package/dist/schema/trust/index.js +1 -314
  317. package/dist/schema/utils/guard-parser.js +1 -419
  318. package/dist/schema/utils/guard-query-utils.js +1 -46
  319. package/dist/schema/utils/node-parser.js +1 -369
  320. package/dist/schema/utils/object-type-utils.js +1 -35
  321. package/dist/schema/utils/permission-index-utils.js +1 -7
  322. package/dist/schema/utils/permission-machine-check.js +1 -121
  323. package/dist/schema/utils/skills-recommendation.js +1 -77
  324. package/dist/schema-query/index.js +1 -810
  325. package/dist/schemas/account_operation.output.json +5 -2
  326. package/dist/schemas/bridge_operation.output.json +5 -2
  327. package/dist/schemas/evaluation_operation.output.json +112 -7
  328. package/dist/schemas/evaluation_operation.schema.json +93 -6
  329. package/dist/schemas/index.json +1 -1
  330. package/dist/schemas/intent_radar.output.json +4 -1
  331. package/dist/schemas/intent_radar.schema.json +4 -1
  332. package/dist/schemas/local_info_operation.output.json +5 -2
  333. package/dist/schemas/local_mark_operation.output.json +5 -2
  334. package/dist/schemas/messenger_operation.output.json +5 -2
  335. package/dist/schemas/onchain_events.output.json +5 -2
  336. package/dist/schemas/onchain_operations.output.json +5 -2
  337. package/dist/schemas/onchain_operations.schema.json +4 -4
  338. package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
  339. package/dist/schemas/onchain_operations_machine.schema.json +2 -2
  340. package/dist/schemas/onchain_operations_service.schema.json +1 -1
  341. package/dist/schemas/onchain_table_data.output.json +6 -3
  342. package/dist/schemas/persona_operation.output.json +4 -1
  343. package/dist/schemas/persona_operation.schema.json +4 -1
  344. package/dist/schemas/project_operation.output.json +28 -8
  345. package/dist/schemas/query_toolkit.output.json +8 -5
  346. package/dist/schemas/wowok_buildin_info.output.json +132 -0
  347. package/dist/schemas/wowok_buildin_info.schema.json +14 -0
  348. package/dist/telemetry/index.js +1 -112
  349. package/dist/telemetry/redact.js +1 -23
  350. package/dist/telemetry/storage.js +1 -80
  351. package/dist/tools/handlers/bridge.js +1 -1
  352. package/dist/tools/handlers/config.js +1 -74
  353. package/dist/tools/handlers/evaluation.js +1 -123
  354. package/dist/tools/handlers/file-export.js +1 -90
  355. package/dist/tools/handlers/intent-radar.js +1 -76
  356. package/dist/tools/handlers/local.js +1 -53
  357. package/dist/tools/handlers/messenger.js +1 -188
  358. package/dist/tools/handlers/onchain.js +1 -1180
  359. package/dist/tools/handlers/persona.js +1 -89
  360. package/dist/tools/handlers/project.js +1 -211
  361. package/dist/tools/handlers/query.js +1 -434
  362. package/dist/tools/handlers/schema-query.js +1 -176
  363. package/dist/tools/handlers/task-status.js +1 -26
  364. package/dist/tools/handlers/trust.js +1 -380
  365. package/dist/tools/handlers/wip.js +1 -90
  366. package/dist/tools/index.js +1 -1382
  367. package/dist/tools/retry.js +1 -85
  368. package/dist/tools/rules-hook.js +1 -23
  369. package/dist/tools/shared.js +1 -130
  370. package/dist/tools/types.js +1 -1
  371. package/dist/tools/upgrade-check.d.ts +19 -0
  372. package/dist/tools/upgrade-check.js +1 -0
  373. package/dist/tools/wip-deploy-assist.js +1 -306
  374. package/dist/tools/wrap.js +1 -500
  375. package/package.json +4 -2
@@ -1,627 +1 @@
1
- import { MAX_GUARD_COUNT_REWARD, MAX_RECORD_COUNT_REWARD, } from "./onchain-constants.js";
2
- import { resolveGuardConstructor, } from "./reward-ledger.js";
3
- const R_R_1_01 = {
4
- id: "R-R-1-01",
5
- category: "structural",
6
- trigger: "guard_add would exceed MAX_GUARD_COUNT_REWARD (200)",
7
- check: (ctx) => {
8
- if (!ctx.guard_add || ctx.guard_add.length === 0)
9
- return null;
10
- const current = ctx.current_guard_count ?? 0;
11
- const wouldAdd = ctx.guard_add.length;
12
- if (current + wouldAdd > MAX_GUARD_COUNT_REWARD) {
13
- return {
14
- id: "R-R-1-01",
15
- level: "HIGH",
16
- category: "structural",
17
- title: "guard_add would exceed MAX_GUARD_COUNT_REWARD",
18
- description: `Reward has ${current} guards, adding ${wouldAdd} would total ${current + wouldAdd}, ` +
19
- `exceeds MAX_GUARD_COUNT_REWARD ${MAX_GUARD_COUNT_REWARD}. Move aborts with E_GUARD_COUNT_EXCEEDED (3).`,
20
- affected_stakeholders: ["owner", "service_provider"],
21
- scenario: "Adding too many guards to a single Reward (e.g. milestone reward with > 200 recipients)",
22
- mitigation: "Split into multiple Reward objects, or use GuardIdentifier recipient to handle multiple recipients with a single guard.",
23
- evidence: `current=${current}, add=${wouldAdd}`,
24
- related_move_error: "E_GUARD_COUNT_EXCEEDED (3)",
25
- auto_fixable: false,
26
- };
27
- }
28
- return null;
29
- },
30
- };
31
- const R_R_1_02 = {
32
- id: "R-R-1-02",
33
- category: "structural",
34
- trigger: "claim would push recipient record count to MAX_RECORD_COUNT_REWARD (5200)",
35
- check: (ctx) => {
36
- if (!ctx.claim)
37
- return null;
38
- const current = ctx.current_record_count_for_recipient ?? 0;
39
- if (current >= MAX_RECORD_COUNT_REWARD) {
40
- return {
41
- id: "R-R-1-02",
42
- level: "HIGH",
43
- category: "structural",
44
- title: "claim blocked — recipient record count at limit",
45
- description: `Recipient already has ${current} records, at MAX_RECORD_COUNT_REWARD ${MAX_RECORD_COUNT_REWARD}. ` +
46
- `Next claim will abort with E_RECORD_COUNT_EXCEEDED (8). The recipient can no longer claim from this Reward.`,
47
- affected_stakeholders: ["claimer"],
48
- scenario: "High-frequency claimer hits the 5200-record ceiling (e.g. cashback on every micro-order)",
49
- mitigation: "Owner can create a new Reward for the same recipient, OR redesign the Guard to batch claims (larger amount per claim).",
50
- evidence: `recipient_records=${current}`,
51
- related_move_error: "E_RECORD_COUNT_EXCEEDED (8)",
52
- auto_fixable: false,
53
- };
54
- }
55
- return null;
56
- },
57
- };
58
- const R_R_1_03 = {
59
- id: "R-R-1-03",
60
- category: "structural",
61
- trigger: "guard_add batch size > MAX_GUARD_COUNT_REWARD (200) — schema-level overflow",
62
- check: (ctx) => {
63
- if (!ctx.guard_add)
64
- return null;
65
- if (ctx.guard_add.length > MAX_GUARD_COUNT_REWARD) {
66
- return {
67
- id: "R-R-1-03",
68
- level: "CRITICAL",
69
- category: "structural",
70
- title: "guard_add batch exceeds absolute limit",
71
- description: `Single guard_add call tries to add ${ctx.guard_add.length} guards in one transaction, ` +
72
- `exceeds MAX_GUARD_COUNT_REWARD ${MAX_GUARD_COUNT_REWARD}. SDK rejects this in operate().`,
73
- affected_stakeholders: ["owner"],
74
- scenario: "Bulk guard addition without splitting transactions",
75
- mitigation: `Split into multiple transactions, each ≤ ${MAX_GUARD_COUNT_REWARD} new guards.`,
76
- evidence: `batch_size=${ctx.guard_add.length}`,
77
- auto_fixable: true,
78
- };
79
- }
80
- return null;
81
- },
82
- };
83
- const R_R_2_01 = {
84
- id: "R-R-2-01",
85
- category: "semantic",
86
- trigger: "guard_add with GuardIdentifier recipient where identifier type is not address",
87
- check: (ctx) => {
88
- if (!ctx.guard_add)
89
- return null;
90
- for (let i = 0; i < ctx.guard_add.length; i++) {
91
- const g = ctx.guard_add[i];
92
- if ("GuardIdentifier" in g.recipient) {
93
- const id = g.recipient.GuardIdentifier;
94
- if (ctx.passport_identifier_is_address && ctx.passport_identifier_is_address[id] === false) {
95
- return {
96
- id: "R-R-2-01",
97
- level: "HIGH",
98
- category: "semantic",
99
- title: `guard_add[${i}]: recipient GuardIdentifier ${id} is not address-typed`,
100
- description: `RewardGuard constructor calls is_identifier_address(guard, ${id}). If the identifier type is not address, ` +
101
- `Move aborts with E_RECIPIENT_IDENTIFIER_NOT_ADDRESS (4).`,
102
- affected_stakeholders: ["owner"],
103
- scenario: "Misconfigured Guard — recipient identifier is u64/bool instead of address",
104
- mitigation: "Use a Guard with an address-typed identifier for recipient, OR switch to Entity/Signer recipient.",
105
- evidence: `guard_add[${i}].recipient.GuardIdentifier=${id}, is_address=false`,
106
- related_move_error: "E_RECIPIENT_IDENTIFIER_NOT_ADDRESS (4)",
107
- auto_fixable: false,
108
- };
109
- }
110
- }
111
- }
112
- return null;
113
- },
114
- };
115
- const R_R_2_02 = {
116
- id: "R-R-2-02",
117
- category: "semantic",
118
- trigger: "guard_add with GuardU64Identifier amount where identifier type is not u64",
119
- check: (ctx) => {
120
- if (!ctx.guard_add)
121
- return null;
122
- for (let i = 0; i < ctx.guard_add.length; i++) {
123
- const g = ctx.guard_add[i];
124
- const amountTypeStr = String(g.amount.type).toUpperCase();
125
- if (amountTypeStr === "GUARDU64IDENTIFIER" || amountTypeStr === "GUARD_U64_IDENTIFIER") {
126
- if (typeof g.amount.value !== "number")
127
- continue;
128
- const id = g.amount.value;
129
- if (ctx.passport_submission_value_types && ctx.passport_submission_value_types[id] !== "u64") {
130
- return {
131
- id: "R-R-2-02",
132
- level: "HIGH",
133
- category: "semantic",
134
- title: `guard_add[${i}]: amount GuardU64Identifier ${id} is not u64-typed`,
135
- description: `RewardGuard constructor calls get_submission_value_type(guard, ${id}); if None or ≠ TYPE_U64, ` +
136
- `Move aborts with E_AMOUNT_NOT_U64 (5).`,
137
- affected_stakeholders: ["owner"],
138
- scenario: "Misconfigured Guard — amount identifier is not u64-typed",
139
- mitigation: "Use a Guard with a u64-typed identifier for amount, OR switch to Fixed amount.",
140
- evidence: `guard_add[${i}].amount.value=${id}, value_type=${ctx.passport_submission_value_types[id] ?? "unknown"}`,
141
- related_move_error: "E_AMOUNT_NOT_U64 (5)",
142
- auto_fixable: false,
143
- };
144
- }
145
- }
146
- }
147
- return null;
148
- },
149
- };
150
- const R_R_2_03 = {
151
- id: "R-R-2-03",
152
- category: "semantic",
153
- trigger: "guard_add with store_from_id set but identifier is not number/address compatible",
154
- check: (ctx) => {
155
- if (!ctx.guard_add)
156
- return null;
157
- for (let i = 0; i < ctx.guard_add.length; i++) {
158
- const g = ctx.guard_add[i];
159
- if (g.store_from_id == null)
160
- continue;
161
- if (ctx.guard_store_from_id_compatible && ctx.guard_store_from_id_compatible[g.guard] === false) {
162
- return {
163
- id: "R-R-2-03",
164
- level: "MEDIUM",
165
- category: "semantic",
166
- title: `guard_add[${i}]: store_from_id incompatible with guard`,
167
- description: `RewardGuard constructor with store_from_id=Some calls is_identifier_address_compatible(guard, store_from_id). ` +
168
- `If the identifier type is not number or address, Move aborts with E_STORE_FROM_ID_NOT_COMPATIBLE (12).`,
169
- affected_stakeholders: ["owner"],
170
- scenario: "Misconfigured Guard — store_from_id points to a non-address/non-number identifier",
171
- mitigation: "Use a compatible identifier, OR drop store_from_id (set to null) if cross-reference is not needed.",
172
- evidence: `guard=${g.guard}, store_from_id=${g.store_from_id}`,
173
- related_move_error: "E_STORE_FROM_ID_NOT_COMPATIBLE (12)",
174
- auto_fixable: true,
175
- };
176
- }
177
- }
178
- return null;
179
- },
180
- };
181
- const R_R_2_04 = {
182
- id: "R-R-2-04",
183
- category: "semantic",
184
- trigger: "guard_add with invalid Recipient × Amount pairing (no matching constructor)",
185
- check: (ctx) => {
186
- if (!ctx.guard_add)
187
- return null;
188
- const recipientTypeMap = {
189
- GuardIdentifier: "GuardIdentifier",
190
- Entity: "Entity",
191
- Signer: "Signer",
192
- };
193
- for (let i = 0; i < ctx.guard_add.length; i++) {
194
- const g = ctx.guard_add[i];
195
- const recipientKey = Object.keys(g.recipient)[0];
196
- const recipientType = recipientTypeMap[recipientKey];
197
- const amountTypeStr = String(g.amount.type).toUpperCase();
198
- const amountType = amountTypeStr === "FIXED" ? "Fixed" : "GuardU64Identifier";
199
- const constructor = resolveGuardConstructor(recipientType, amountType);
200
- if (!constructor) {
201
- return {
202
- id: "R-R-2-04",
203
- level: "HIGH",
204
- category: "semantic",
205
- title: `guard_add[${i}]: invalid Recipient × Amount pairing`,
206
- description: `recipient=${recipientType}, amount=${amountType} — no matching Move constructor. ` +
207
- `SDK reward_guard() will W_ERROR with "Invalid recipient or amount type combination".`,
208
- affected_stakeholders: ["owner"],
209
- scenario: "Schema validation bypassed or stale client",
210
- mitigation: "Use one of the 6 valid pairings: guard_u8_u8, guard_u8_u64, guard_entity_u8, guard_entity_u64, guard_signer_u8, guard_signer_u64.",
211
- evidence: `recipient=${recipientType}, amount=${amountType}`,
212
- auto_fixable: false,
213
- };
214
- }
215
- }
216
- return null;
217
- },
218
- };
219
- const R_R_3_01 = {
220
- id: "R-R-3-01",
221
- category: "permission",
222
- trigger: "claim attempted without permission context — claim is passport-driven",
223
- check: (ctx) => {
224
- if (!ctx.claim)
225
- return null;
226
- return {
227
- id: "R-R-3-01",
228
- level: "MEDIUM",
229
- category: "permission",
230
- title: "claim is permission-free — anyone with a valid Passport can claim",
231
- description: `reward::claim() does NOT assert any permission index. Eligibility is determined entirely by the ` +
232
- `Guard verification (passport::result_for_guard). If the Guard is too permissive, funds can be drained by anyone.`,
233
- affected_stakeholders: ["owner", "service_provider"],
234
- scenario: "Loose Guard allows unauthorized claims (e.g. time-only Guard without service binding)",
235
- mitigation: "1) Use Guards that bind to specific Service/Order context. 2) Set expiration_time. 3) Monitor balance and refill only what's needed.",
236
- evidence: `claim=${ctx.claim}`,
237
- auto_fixable: false,
238
- };
239
- },
240
- };
241
- const R_R_3_02 = {
242
- id: "R-R-3-02",
243
- category: "permission",
244
- trigger: "owner_receive (156) — broad blast radius, owner can drain balance",
245
- check: (ctx) => {
246
- if (ctx.owner_receive == null)
247
- return null;
248
- return {
249
- id: "R-R-3-02",
250
- level: "HIGH",
251
- category: "permission",
252
- title: "owner_receive drains balance to Permission owner",
253
- description: `reward::owner_receive (156 permission) unwraps Receiving<K> / CoinWrapper<K> and forwards to Permission owner. ` +
254
- `If 156 is granted too broadly, any 156-holder can sweep receivables. (Note: owner_receive does NOT directly drain balance — ` +
255
- `only Receiving<K> envelopes sent to the Reward's id.)`,
256
- affected_stakeholders: ["owner", "service_provider"],
257
- scenario: "Compromised 156-holder sweeps receivables before owner",
258
- mitigation: "1) Grant 156 only to the Permission owner address. 2) Reconcile Receiving<K> inflows vs owner_receive events.",
259
- evidence: `owner_receive set`,
260
- auto_fixable: false,
261
- };
262
- },
263
- };
264
- const R_R_3_03 = {
265
- id: "R-R-3-03",
266
- category: "permission",
267
- trigger: "guard_expiration_time_add (155) — can permanently lock guard additions",
268
- check: (ctx) => {
269
- if (ctx.guard_expiration_time === undefined)
270
- return null;
271
- if (ctx.guard_expiration_time !== null && ctx.current_clock_ms !== undefined) {
272
- const lockDurationMs = ctx.guard_expiration_time - ctx.current_clock_ms;
273
- const oneYearMs = 365 * 24 * 60 * 60 * 1000;
274
- if (lockDurationMs > oneYearMs) {
275
- return {
276
- id: "R-R-3-03",
277
- level: "MEDIUM",
278
- category: "permission",
279
- title: "guard_expiration_time_add locks guard additions for > 1 year",
280
- description: `Setting guard_not_added_expiration_time to ${ctx.guard_expiration_time} ` +
281
- `(> 1 year from now) effectively freezes the guard list. While this is sometimes intentional ` +
282
- `(milestone rewards), it cannot be undone without setting a new time (which itself requires 155 permission).`,
283
- affected_stakeholders: ["owner"],
284
- scenario: "Operator sets excessively long lock period by mistake",
285
- mitigation: "Confirm intent. If wrong, call guard_expiration_time_add again with a shorter time (must be ≥ current clock per E_GUARD_LOCKED_TIME_NOT_INCREASING).",
286
- evidence: `lock_until=${ctx.guard_expiration_time}, clock=${ctx.current_clock_ms}`,
287
- auto_fixable: false,
288
- };
289
- }
290
- }
291
- return null;
292
- },
293
- };
294
- const R_R_4_01 = {
295
- id: "R-R-4-01",
296
- category: "lifecycle",
297
- trigger: "claim on guard with expiration_time < now (E_GUARD_EXPIRED)",
298
- check: (ctx) => {
299
- if (!ctx.claim)
300
- return null;
301
- return null;
302
- },
303
- };
304
- const R_R_4_02 = {
305
- id: "R-R-4-02",
306
- category: "lifecycle",
307
- trigger: "claim: balance < amount (E_INSUFFICIENT_BALANCE)",
308
- check: (ctx) => {
309
- if (!ctx.claim)
310
- return null;
311
- if (ctx.current_balance !== undefined && ctx.current_guard_count !== undefined) {
312
- const balance = BigInt(ctx.current_balance);
313
- if (balance === 0n) {
314
- return {
315
- id: "R-R-4-02",
316
- level: "HIGH",
317
- category: "lifecycle",
318
- title: "claim on Reward with zero balance",
319
- description: `Reward balance is 0. Any claim will abort with E_INSUFFICIENT_BALANCE (6). ` +
320
- `Owner must coin_add (153) or receive (154) to replenish.`,
321
- affected_stakeholders: ["claimer", "owner"],
322
- scenario: "Marketing campaign budget exhausted but guards remain active",
323
- mitigation: "1) Owner: coin_add to replenish. 2) Owner: guard_remove_expired + guard_expiration_time_add to deactivate. 3) Claimer: wait for replenishment.",
324
- evidence: `balance=0`,
325
- related_move_error: "E_INSUFFICIENT_BALANCE (6)",
326
- auto_fixable: false,
327
- };
328
- }
329
- }
330
- return null;
331
- },
332
- };
333
- const R_R_4_03 = {
334
- id: "R-R-4-03",
335
- category: "lifecycle",
336
- trigger: "guard_add while guard_not_added_expiration_time is Some and clock ≤ expiration (E_GUARD_LOCKED_TIME)",
337
- check: (ctx) => {
338
- if (!ctx.guard_add || ctx.guard_add.length === 0)
339
- return null;
340
- if (ctx.current_guard_not_added_expiration_time == null)
341
- return null;
342
- if (ctx.current_clock_ms === undefined)
343
- return null;
344
- if (ctx.current_clock_ms <= ctx.current_guard_not_added_expiration_time) {
345
- return {
346
- id: "R-R-4-03",
347
- level: "HIGH",
348
- category: "lifecycle",
349
- title: "guard_add blocked by time-lock (guard_not_added_expiration_time)",
350
- description: `guard_not_added_expiration_time is Some(${ctx.current_guard_not_added_expiration_time}); ` +
351
- `clock is ${ctx.current_clock_ms}. Move asserts clock > expiration_time ` +
352
- `(E_GUARD_LOCKED_TIME = 10).`,
353
- affected_stakeholders: ["owner"],
354
- scenario: "Trying to add guards during a flash sale lock period",
355
- mitigation: "1) Wait until clock > expiration_time. 2) Call guard_expiration_time_add (155) to extend the lock (cannot shorten below current clock).",
356
- evidence: `lock_until=${ctx.current_guard_not_added_expiration_time}, clock=${ctx.current_clock_ms}`,
357
- related_move_error: "E_GUARD_LOCKED_TIME (10)",
358
- auto_fixable: false,
359
- };
360
- }
361
- return null;
362
- },
363
- };
364
- const R_R_4_04 = {
365
- id: "R-R-4-04",
366
- category: "lifecycle",
367
- trigger: "guard_expiration_time_add regression (new time < current clock)",
368
- check: (ctx) => {
369
- if (ctx.guard_expiration_time === undefined)
370
- return null;
371
- if (ctx.guard_expiration_time === null)
372
- return null;
373
- if (ctx.current_clock_ms === undefined)
374
- return null;
375
- if (ctx.guard_expiration_time <= ctx.current_clock_ms) {
376
- return {
377
- id: "R-R-4-04",
378
- level: "HIGH",
379
- category: "lifecycle",
380
- title: "guard_expiration_time_add: new time must be in the future",
381
- description: `New guard_not_added_expiration_time = ${ctx.guard_expiration_time} ≤ clock ${ctx.current_clock_ms}. ` +
382
- `Move aborts with E_GUARD_LOCKED_TIME_INVALID (11).`,
383
- affected_stakeholders: ["owner"],
384
- scenario: "Operator sets lock time in the past by mistake",
385
- mitigation: `Set guard_expiration_time to a value > ${ctx.current_clock_ms} (current clock).`,
386
- evidence: `new_time=${ctx.guard_expiration_time}, clock=${ctx.current_clock_ms}`,
387
- related_move_error: "E_GUARD_LOCKED_TIME_INVALID (11)",
388
- auto_fixable: true,
389
- };
390
- }
391
- return null;
392
- },
393
- };
394
- const R_R_5_01 = {
395
- id: "R-R-5-01",
396
- category: "cross_object",
397
- trigger: "claim: guard not found in self.guards (E_GUARD_NOT_FOUND)",
398
- check: (ctx) => {
399
- if (!ctx.claim)
400
- return null;
401
- if (!ctx.target_guard_addresses)
402
- return null;
403
- if (!ctx.target_guard_addresses.includes(ctx.claim)) {
404
- return {
405
- id: "R-R-5-01",
406
- level: "HIGH",
407
- category: "cross_object",
408
- title: "claim: supplied guard not in Reward.guards",
409
- description: `Guard ${ctx.claim} is not in the Reward's guard list. Move iterates self.guards and ` +
410
- `aborts with E_GUARD_NOT_FOUND (7) if no match.`,
411
- affected_stakeholders: ["claimer"],
412
- scenario: "Claimer uses the wrong Guard object (typo or wrong Service)",
413
- mitigation: "1) Verify the Guard address via query ObjectReward. 2) Ensure the Guard was added via guard_add (152).",
414
- evidence: `claim_guard=${ctx.claim}, known_guards=${ctx.target_guard_addresses.join(",")}`,
415
- related_move_error: "E_GUARD_NOT_FOUND (7)",
416
- auto_fixable: false,
417
- };
418
- }
419
- return null;
420
- },
421
- };
422
- const R_R_5_02 = {
423
- id: "R-R-5-02",
424
- category: "cross_object",
425
- trigger: "coin_add: coin type T mismatch with Reward<T>",
426
- check: (ctx) => {
427
- if (!ctx.coin_add || !ctx.reward_type)
428
- return null;
429
- if (ctx.coin_add.coin_type !== ctx.reward_type) {
430
- return {
431
- id: "R-R-5-02",
432
- level: "CRITICAL",
433
- category: "cross_object",
434
- title: "coin_add: coin type T mismatch",
435
- description: `Reward is Reward<${ctx.reward_type}> but coin_add passes Coin<${ctx.coin_add.coin_type}>. ` +
436
- `Move type-system mismatch; SDK W_ERROR in operate().`,
437
- affected_stakeholders: ["owner"],
438
- scenario: "Operator tries to deposit wrong coin type (e.g. USDC into a WOW Reward)",
439
- mitigation: `Use Coin<${ctx.reward_type}> for coin_add.`,
440
- evidence: `reward_type=${ctx.reward_type}, coin_type=${ctx.coin_add.coin_type}`,
441
- auto_fixable: false,
442
- };
443
- }
444
- return null;
445
- },
446
- };
447
- const R_R_5_03 = {
448
- id: "R-R-5-03",
449
- category: "cross_object",
450
- trigger: "receive: Payment<T> type mismatch with Reward<T>",
451
- check: (ctx) => {
452
- if (!ctx.receive || !ctx.reward_type)
453
- return null;
454
- if (ctx.receive.token_type !== ctx.reward_type) {
455
- return {
456
- id: "R-R-5-03",
457
- level: "CRITICAL",
458
- category: "cross_object",
459
- title: "receive: Payment token_type mismatch",
460
- description: `Reward is Reward<${ctx.reward_type}> but receive's Payment<CoinWrapper<${ctx.receive.token_type}>>. ` +
461
- `SDK W_ERROR in operate().`,
462
- affected_stakeholders: ["owner"],
463
- scenario: "Operator tries to receive wrong-token Payment",
464
- mitigation: `Use Payment<${ctx.reward_type}> for receive.`,
465
- evidence: `reward_type=${ctx.reward_type}, payment_token=${ctx.receive.token_type}`,
466
- auto_fixable: false,
467
- };
468
- }
469
- return null;
470
- },
471
- };
472
- const R_R_6_01 = {
473
- id: "R-R-6-01",
474
- category: "business_semantic",
475
- trigger: "intent mentions praise/positive-review but Guard checks non-wonder progress node",
476
- check: (ctx) => {
477
- if (!ctx.user_intent_phrases || ctx.user_intent_phrases.length === 0)
478
- return null;
479
- if (!ctx.guard_expected_progress_state)
480
- return null;
481
- const intentLower = ctx.user_intent_phrases.join(" ").toLowerCase();
482
- const praiseKeywords = [
483
- "praise", "wonder", "thumbs_up",
484
- "positive review", "satisfaction reward", "praise reward",
485
- ];
486
- const isPraiseIntent = praiseKeywords.some(kw => intentLower.includes(kw.toLowerCase()));
487
- if (!isPraiseIntent)
488
- return null;
489
- if (ctx.machine_has_wonder_node === false)
490
- return null;
491
- const expected = ctx.guard_expected_progress_state;
492
- if (expected !== "wonder") {
493
- return {
494
- id: "R-R-6-01",
495
- level: "HIGH",
496
- category: "business_semantic",
497
- title: `Guard checks progress=="${expected}" but intent indicates praise reward (wonder node)`,
498
- description: `User intent mentions praise/positive-review/wonder, which maps to the 'wonder' progress node ` +
499
- `(customer gives positive review AFTER service completion). But the Guard's table bakes ` +
500
- `expected state="${expected}", allowing reward claim at the wrong lifecycle stage. ` +
501
- `This violates the business semantics: "praise reward" should only be claimable AFTER the ` +
502
- `customer advances to the 'wonder' node, not before. ` +
503
- `Guard is immutable — fixing this requires creating a new Guard + Reward pair.`,
504
- affected_stakeholders: ["owner", "service_provider", "claimer"],
505
- scenario: "Designer builds Guard checking 'completed' instead of 'wonder' for a praise reward",
506
- mitigation: "Set the Guard table's expected progress state to 'wonder' (the positive-review node). " +
507
- "The correct pattern: ordered → in_service → completed → wonder (praise) triggers reward claim. " +
508
- "Reference: reward-templates.ts wonder_praise template.",
509
- evidence: `intent="${intentLower}", expected_state="${expected}", expected_wonder=true`,
510
- auto_fixable: false,
511
- };
512
- }
513
- return null;
514
- },
515
- };
516
- const R_R_6_02 = {
517
- id: "R-R-6-02",
518
- category: "business_semantic",
519
- trigger: "Guard checks wonder node but intent does not mention praise",
520
- check: (ctx) => {
521
- if (!ctx.user_intent_phrases || ctx.user_intent_phrases.length === 0)
522
- return null;
523
- if (!ctx.guard_expected_progress_state)
524
- return null;
525
- if (ctx.guard_expected_progress_state !== "wonder")
526
- return null;
527
- const intentLower = ctx.user_intent_phrases.join(" ").toLowerCase();
528
- const praiseKeywords = [
529
- "praise", "wonder", "thumbs_up",
530
- "positive review", "satisfaction reward", "praise reward",
531
- ];
532
- const isPraiseIntent = praiseKeywords.some(kw => intentLower.includes(kw.toLowerCase()));
533
- if (isPraiseIntent)
534
- return null;
535
- return {
536
- id: "R-R-6-02",
537
- level: "MEDIUM",
538
- category: "business_semantic",
539
- title: "Guard checks wonder node but intent does not mention praise",
540
- description: `Guard's expected progress state is "wonder" (positive-review node), but the user intent ` +
541
- `does not mention any praise/positive-review keyword. This may be a copy-paste from a wonder_praise ` +
542
- `template without adjusting the Guard for the actual business semantics. If this is a ` +
543
- `general feedback reward (wonder_feedback), this is fine. Otherwise, verify the node choice.`,
544
- affected_stakeholders: ["owner"],
545
- scenario: "Designer copies wonder_praise template but actually wants a completion-based reward",
546
- mitigation: "Verify: if intent is praise reward, add 'praise/positive review' to description. " +
547
- "If intent is completion-based reward, change Guard to check 'completed' node.",
548
- evidence: `expected_state="wonder", intent="${intentLower}" (no praise keyword)`,
549
- auto_fixable: false,
550
- };
551
- },
552
- };
553
- const ALL_RULES = [
554
- R_R_1_01, R_R_1_02, R_R_1_03,
555
- R_R_2_01, R_R_2_02, R_R_2_03, R_R_2_04,
556
- R_R_3_01, R_R_3_02, R_R_3_03,
557
- R_R_4_01, R_R_4_02, R_R_4_03, R_R_4_04,
558
- R_R_5_01, R_R_5_02, R_R_5_03,
559
- R_R_6_01, R_R_6_02,
560
- ];
561
- export const REWARD_RISK_VERSION = "1.0.0";
562
- export function getAllRewardRiskRules() {
563
- return [...ALL_RULES];
564
- }
565
- export function getRewardRiskRulesCount() {
566
- return ALL_RULES.length;
567
- }
568
- export function getRewardRiskRulesByCategory(category) {
569
- return ALL_RULES.filter(r => r.category === category);
570
- }
571
- export function assessRewardRisks(ctx) {
572
- const risks = [];
573
- for (const rule of ALL_RULES) {
574
- const r = rule.check(ctx);
575
- if (r)
576
- risks.push(r);
577
- }
578
- const overall = risks.length === 0
579
- ? "LOW"
580
- : risks.some(r => r.level === "CRITICAL") ? "CRITICAL"
581
- : risks.some(r => r.level === "HIGH") ? "HIGH"
582
- : risks.some(r => r.level === "MEDIUM") ? "MEDIUM"
583
- : "LOW";
584
- const byCategory = {};
585
- for (const r of risks) {
586
- byCategory[r.category] = (byCategory[r.category] ?? 0) + 1;
587
- }
588
- const advice = {};
589
- for (const r of risks) {
590
- for (const s of r.affected_stakeholders) {
591
- if (!advice[s])
592
- advice[s] = [];
593
- advice[s].push(`${r.id}: ${r.mitigation}`);
594
- }
595
- }
596
- return {
597
- summary: `Assessed ${risks.length} risk(s) across ${Object.keys(byCategory).length} categories`,
598
- risks,
599
- overall_risk: overall,
600
- risks_by_category: byCategory,
601
- stakeholder_advice: advice,
602
- needs_human_review: risks.some(r => r.level === "CRITICAL" || r.level === "HIGH"),
603
- };
604
- }
605
- export const REWARD_STAKEHOLDERS = [
606
- "owner",
607
- "claimer",
608
- "service_provider",
609
- "system",
610
- ];
611
- export function getRewardRiskRulesByStakeholder(stakeholder) {
612
- return ALL_RULES.filter(rule => {
613
- if (stakeholder === "owner") {
614
- return ["structural", "permission", "lifecycle", "business_semantic"].includes(rule.category);
615
- }
616
- if (stakeholder === "claimer") {
617
- return rule.id.startsWith("R-R-4-0") || rule.id === "R-R-5-01" || rule.id === "R-R-1-02" || rule.id === "R-R-6-01";
618
- }
619
- if (stakeholder === "service_provider") {
620
- return rule.id === "R-R-4-02" || rule.id === "R-R-3-01" || rule.id === "R-R-3-02" || rule.id === "R-R-6-01";
621
- }
622
- if (stakeholder === "system") {
623
- return rule.category === "cross_object";
624
- }
625
- return false;
626
- });
627
- }
1
+ import{MAX_GUARD_COUNT_REWARD,MAX_RECORD_COUNT_REWARD}from'./onchain-constants.js';import{resolveGuardConstructor}from'./reward-ledger.js';const R_R_1_01={'id':'R-R-1-01','category':'structural','trigger':'guard_add\x20would\x20exceed\x20MAX_GUARD_COUNT_REWARD\x20(200)','check':a=>{if(!a['guard_add']||a['guard_add']['length']===0x0)return null;const b=a['current_guard_count']??0x0,c=a['guard_add']['length'];if(b+c>MAX_GUARD_COUNT_REWARD)return{'id':'R-R-1-01','level':'HIGH','category':'structural','title':'guard_add\x20would\x20exceed\x20MAX_GUARD_COUNT_REWARD','description':'Reward\x20has\x20'+b+'\x20guards,\x20adding\x20'+c+'\x20would\x20total\x20'+(b+c)+',\x20'+('exceeds\x20MAX_GUARD_COUNT_REWARD\x20'+MAX_GUARD_COUNT_REWARD+'.\x20Move\x20aborts\x20with\x20E_GUARD_COUNT_EXCEEDED\x20(3).'),'affected_stakeholders':['owner','service_provider'],'scenario':'Adding\x20too\x20many\x20guards\x20to\x20a\x20single\x20Reward\x20(e.g.\x20milestone\x20reward\x20with\x20>\x20200\x20recipients)','mitigation':'Split\x20into\x20multiple\x20Reward\x20objects,\x20or\x20use\x20GuardIdentifier\x20recipient\x20to\x20handle\x20multiple\x20recipients\x20with\x20a\x20single\x20guard.','evidence':'current='+b+',\x20add='+c,'related_move_error':'E_GUARD_COUNT_EXCEEDED\x20(3)','auto_fixable':![]};return null;}},R_R_1_02={'id':'R-R-1-02','category':'structural','trigger':'claim\x20would\x20push\x20recipient\x20record\x20count\x20to\x20MAX_RECORD_COUNT_REWARD\x20(5200)','check':a=>{if(!a['claim'])return null;const b=a['current_record_count_for_recipient']??0x0;if(b>=MAX_RECORD_COUNT_REWARD)return{'id':'R-R-1-02','level':'HIGH','category':'structural','title':'claim\x20blocked\x20—\x20recipient\x20record\x20count\x20at\x20limit','description':'Recipient\x20already\x20has\x20'+b+'\x20records,\x20at\x20MAX_RECORD_COUNT_REWARD\x20'+MAX_RECORD_COUNT_REWARD+'.\x20'+'Next\x20claim\x20will\x20abort\x20with\x20E_RECORD_COUNT_EXCEEDED\x20(8).\x20The\x20recipient\x20can\x20no\x20longer\x20claim\x20from\x20this\x20Reward.','affected_stakeholders':['claimer'],'scenario':'High-frequency\x20claimer\x20hits\x20the\x205200-record\x20ceiling\x20(e.g.\x20cashback\x20on\x20every\x20micro-order)','mitigation':'Owner\x20can\x20create\x20a\x20new\x20Reward\x20for\x20the\x20same\x20recipient,\x20OR\x20redesign\x20the\x20Guard\x20to\x20batch\x20claims\x20(larger\x20amount\x20per\x20claim).','evidence':'recipient_records='+b,'related_move_error':'E_RECORD_COUNT_EXCEEDED\x20(8)','auto_fixable':![]};return null;}},R_R_1_03={'id':'R-R-1-03','category':'structural','trigger':'guard_add\x20batch\x20size\x20>\x20MAX_GUARD_COUNT_REWARD\x20(200)\x20—\x20schema-level\x20overflow','check':a=>{if(!a['guard_add'])return null;if(a['guard_add']['length']>MAX_GUARD_COUNT_REWARD)return{'id':'R-R-1-03','level':'CRITICAL','category':'structural','title':'guard_add\x20batch\x20exceeds\x20absolute\x20limit','description':'Single\x20guard_add\x20call\x20tries\x20to\x20add\x20'+a['guard_add']['length']+'\x20guards\x20in\x20one\x20transaction,\x20'+('exceeds\x20MAX_GUARD_COUNT_REWARD\x20'+MAX_GUARD_COUNT_REWARD+'.\x20SDK\x20rejects\x20this\x20in\x20operate().'),'affected_stakeholders':['owner'],'scenario':'Bulk\x20guard\x20addition\x20without\x20splitting\x20transactions','mitigation':'Split\x20into\x20multiple\x20transactions,\x20each\x20≤\x20'+MAX_GUARD_COUNT_REWARD+'\x20new\x20guards.','evidence':'batch_size='+a['guard_add']['length'],'auto_fixable':!![]};return null;}},R_R_2_01={'id':'R-R-2-01','category':'semantic','trigger':'guard_add\x20with\x20GuardIdentifier\x20recipient\x20where\x20identifier\x20type\x20is\x20not\x20address','check':a=>{if(!a['guard_add'])return null;for(let b=0x0;b<a['guard_add']['length'];b++){const c=a['guard_add'][b];if('GuardIdentifier'in c['recipient']){const d=c['recipient']['GuardIdentifier'];if(a['passport_identifier_is_address']&&a['passport_identifier_is_address'][d]===![])return{'id':'R-R-2-01','level':'HIGH','category':'semantic','title':'guard_add['+b+']:\x20recipient\x20GuardIdentifier\x20'+d+'\x20is\x20not\x20address-typed','description':'RewardGuard\x20constructor\x20calls\x20is_identifier_address(guard,\x20'+d+').\x20If\x20the\x20identifier\x20type\x20is\x20not\x20address,\x20'+'Move\x20aborts\x20with\x20E_RECIPIENT_IDENTIFIER_NOT_ADDRESS\x20(4).','affected_stakeholders':['owner'],'scenario':'Misconfigured\x20Guard\x20—\x20recipient\x20identifier\x20is\x20u64/bool\x20instead\x20of\x20address','mitigation':'Use\x20a\x20Guard\x20with\x20an\x20address-typed\x20identifier\x20for\x20recipient,\x20OR\x20switch\x20to\x20Entity/Signer\x20recipient.','evidence':'guard_add['+b+'].recipient.GuardIdentifier='+d+',\x20is_address=false','related_move_error':'E_RECIPIENT_IDENTIFIER_NOT_ADDRESS\x20(4)','auto_fixable':![]};}}return null;}},R_R_2_02={'id':'R-R-2-02','category':'semantic','trigger':'guard_add\x20with\x20GuardU64Identifier\x20amount\x20where\x20identifier\x20type\x20is\x20not\x20u64','check':a=>{if(!a['guard_add'])return null;for(let b=0x0;b<a['guard_add']['length'];b++){const c=a['guard_add'][b],d=String(c['amount']['type'])['toUpperCase']();if(d==='GUARDU64IDENTIFIER'||d==='GUARD_U64_IDENTIFIER'){if(typeof c['amount']['value']!=='number')continue;const e=c['amount']['value'];if(a['passport_submission_value_types']&&a['passport_submission_value_types'][e]!=='u64')return{'id':'R-R-2-02','level':'HIGH','category':'semantic','title':'guard_add['+b+']:\x20amount\x20GuardU64Identifier\x20'+e+'\x20is\x20not\x20u64-typed','description':'RewardGuard\x20constructor\x20calls\x20get_submission_value_type(guard,\x20'+e+');\x20if\x20None\x20or\x20≠\x20TYPE_U64,\x20'+'Move\x20aborts\x20with\x20E_AMOUNT_NOT_U64\x20(5).','affected_stakeholders':['owner'],'scenario':'Misconfigured\x20Guard\x20—\x20amount\x20identifier\x20is\x20not\x20u64-typed','mitigation':'Use\x20a\x20Guard\x20with\x20a\x20u64-typed\x20identifier\x20for\x20amount,\x20OR\x20switch\x20to\x20Fixed\x20amount.','evidence':'guard_add['+b+'].amount.value='+e+',\x20value_type='+(a['passport_submission_value_types'][e]??'unknown'),'related_move_error':'E_AMOUNT_NOT_U64\x20(5)','auto_fixable':![]};}}return null;}},R_R_2_03={'id':'R-R-2-03','category':'semantic','trigger':'guard_add\x20with\x20store_from_id\x20set\x20but\x20identifier\x20is\x20not\x20number/address\x20compatible','check':a=>{if(!a['guard_add'])return null;for(let b=0x0;b<a['guard_add']['length'];b++){const c=a['guard_add'][b];if(c['store_from_id']==null)continue;if(a['guard_store_from_id_compatible']&&a['guard_store_from_id_compatible'][c['guard']]===![])return{'id':'R-R-2-03','level':'MEDIUM','category':'semantic','title':'guard_add['+b+']:\x20store_from_id\x20incompatible\x20with\x20guard','description':'RewardGuard\x20constructor\x20with\x20store_from_id=Some\x20calls\x20is_identifier_address_compatible(guard,\x20store_from_id).\x20'+'If\x20the\x20identifier\x20type\x20is\x20not\x20number\x20or\x20address,\x20Move\x20aborts\x20with\x20E_STORE_FROM_ID_NOT_COMPATIBLE\x20(12).','affected_stakeholders':['owner'],'scenario':'Misconfigured\x20Guard\x20—\x20store_from_id\x20points\x20to\x20a\x20non-address/non-number\x20identifier','mitigation':'Use\x20a\x20compatible\x20identifier,\x20OR\x20drop\x20store_from_id\x20(set\x20to\x20null)\x20if\x20cross-reference\x20is\x20not\x20needed.','evidence':'guard='+c['guard']+',\x20store_from_id='+c['store_from_id'],'related_move_error':'E_STORE_FROM_ID_NOT_COMPATIBLE\x20(12)','auto_fixable':!![]};}return null;}},R_R_2_04={'id':'R-R-2-04','category':'semantic','trigger':'guard_add\x20with\x20invalid\x20Recipient\x20×\x20Amount\x20pairing\x20(no\x20matching\x20constructor)','check':a=>{if(!a['guard_add'])return null;const b={'GuardIdentifier':'GuardIdentifier','Entity':'Entity','Signer':'Signer'};for(let c=0x0;c<a['guard_add']['length'];c++){const d=a['guard_add'][c],e=Object['keys'](d['recipient'])[0x0],f=b[e],h=String(d['amount']['type'])['toUpperCase'](),j=h==='FIXED'?'Fixed':'GuardU64Identifier',k=resolveGuardConstructor(f,j);if(!k)return{'id':'R-R-2-04','level':'HIGH','category':'semantic','title':'guard_add['+c+']:\x20invalid\x20Recipient\x20×\x20Amount\x20pairing','description':'recipient='+f+',\x20amount='+j+'\x20—\x20no\x20matching\x20Move\x20constructor.\x20'+'SDK\x20reward_guard()\x20will\x20W_ERROR\x20with\x20\x22Invalid\x20recipient\x20or\x20amount\x20type\x20combination\x22.','affected_stakeholders':['owner'],'scenario':'Schema\x20validation\x20bypassed\x20or\x20stale\x20client','mitigation':'Use\x20one\x20of\x20the\x206\x20valid\x20pairings:\x20guard_u8_u8,\x20guard_u8_u64,\x20guard_entity_u8,\x20guard_entity_u64,\x20guard_signer_u8,\x20guard_signer_u64.','evidence':'recipient='+f+',\x20amount='+j,'auto_fixable':![]};}return null;}},R_R_3_01={'id':'R-R-3-01','category':'permission','trigger':'claim\x20attempted\x20without\x20permission\x20context\x20—\x20claim\x20is\x20passport-driven','check':a=>{if(!a['claim'])return null;return{'id':'R-R-3-01','level':'MEDIUM','category':'permission','title':'claim\x20is\x20permission-free\x20—\x20anyone\x20with\x20a\x20valid\x20Passport\x20can\x20claim','description':'reward::claim()\x20does\x20NOT\x20assert\x20any\x20permission\x20index.\x20Eligibility\x20is\x20determined\x20entirely\x20by\x20the\x20'+'Guard\x20verification\x20(passport::result_for_guard).\x20If\x20the\x20Guard\x20is\x20too\x20permissive,\x20funds\x20can\x20be\x20drained\x20by\x20anyone.','affected_stakeholders':['owner','service_provider'],'scenario':'Loose\x20Guard\x20allows\x20unauthorized\x20claims\x20(e.g.\x20time-only\x20Guard\x20without\x20service\x20binding)','mitigation':'1)\x20Use\x20Guards\x20that\x20bind\x20to\x20specific\x20Service/Order\x20context.\x202)\x20Set\x20expiration_time.\x203)\x20Monitor\x20balance\x20and\x20refill\x20only\x20what\x27s\x20needed.','evidence':'claim='+a['claim'],'auto_fixable':![]};}},R_R_3_02={'id':'R-R-3-02','category':'permission','trigger':'owner_receive\x20(156)\x20—\x20broad\x20blast\x20radius,\x20owner\x20can\x20drain\x20balance','check':a=>{if(a['owner_receive']==null)return null;return{'id':'R-R-3-02','level':'HIGH','category':'permission','title':'owner_receive\x20drains\x20balance\x20to\x20Permission\x20owner','description':'reward::owner_receive\x20(156\x20permission)\x20unwraps\x20Receiving<K>\x20/\x20CoinWrapper<K>\x20and\x20forwards\x20to\x20Permission\x20owner.\x20'+'If\x20156\x20is\x20granted\x20too\x20broadly,\x20any\x20156-holder\x20can\x20sweep\x20receivables.\x20(Note:\x20owner_receive\x20does\x20NOT\x20directly\x20drain\x20balance\x20—\x20'+'only\x20Receiving<K>\x20envelopes\x20sent\x20to\x20the\x20Reward\x27s\x20id.)','affected_stakeholders':['owner','service_provider'],'scenario':'Compromised\x20156-holder\x20sweeps\x20receivables\x20before\x20owner','mitigation':'1)\x20Grant\x20156\x20only\x20to\x20the\x20Permission\x20owner\x20address.\x202)\x20Reconcile\x20Receiving<K>\x20inflows\x20vs\x20owner_receive\x20events.','evidence':'owner_receive\x20set','auto_fixable':![]};}},R_R_3_03={'id':'R-R-3-03','category':'permission','trigger':'guard_expiration_time_add\x20(155)\x20—\x20can\x20permanently\x20lock\x20guard\x20additions','check':a=>{if(a['guard_expiration_time']===undefined)return null;if(a['guard_expiration_time']!==null&&a['current_clock_ms']!==undefined){const b=a['guard_expiration_time']-a['current_clock_ms'],c=0x16d*0x18*0x3c*0x3c*0x3e8;if(b>c)return{'id':'R-R-3-03','level':'MEDIUM','category':'permission','title':'guard_expiration_time_add\x20locks\x20guard\x20additions\x20for\x20>\x201\x20year','description':'Setting\x20guard_not_added_expiration_time\x20to\x20'+a['guard_expiration_time']+'\x20'+'(>\x201\x20year\x20from\x20now)\x20effectively\x20freezes\x20the\x20guard\x20list.\x20While\x20this\x20is\x20sometimes\x20intentional\x20'+'(milestone\x20rewards),\x20it\x20cannot\x20be\x20undone\x20without\x20setting\x20a\x20new\x20time\x20(which\x20itself\x20requires\x20155\x20permission).','affected_stakeholders':['owner'],'scenario':'Operator\x20sets\x20excessively\x20long\x20lock\x20period\x20by\x20mistake','mitigation':'Confirm\x20intent.\x20If\x20wrong,\x20call\x20guard_expiration_time_add\x20again\x20with\x20a\x20shorter\x20time\x20(must\x20be\x20≥\x20current\x20clock\x20per\x20E_GUARD_LOCKED_TIME_NOT_INCREASING).','evidence':'lock_until='+a['guard_expiration_time']+',\x20clock='+a['current_clock_ms'],'auto_fixable':![]};}return null;}},R_R_4_01={'id':'R-R-4-01','category':'lifecycle','trigger':'claim\x20on\x20guard\x20with\x20expiration_time\x20<\x20now\x20(E_GUARD_EXPIRED)','check':a=>{if(!a['claim'])return null;return null;}},R_R_4_02={'id':'R-R-4-02','category':'lifecycle','trigger':'claim:\x20balance\x20<\x20amount\x20(E_INSUFFICIENT_BALANCE)','check':a=>{if(!a['claim'])return null;if(a['current_balance']!==undefined&&a['current_guard_count']!==undefined){const b=BigInt(a['current_balance']);if(b===0x0n)return{'id':'R-R-4-02','level':'HIGH','category':'lifecycle','title':'claim\x20on\x20Reward\x20with\x20zero\x20balance','description':'Reward\x20balance\x20is\x200.\x20Any\x20claim\x20will\x20abort\x20with\x20E_INSUFFICIENT_BALANCE\x20(6).\x20'+'Owner\x20must\x20coin_add\x20(153)\x20or\x20receive\x20(154)\x20to\x20replenish.','affected_stakeholders':['claimer','owner'],'scenario':'Marketing\x20campaign\x20budget\x20exhausted\x20but\x20guards\x20remain\x20active','mitigation':'1)\x20Owner:\x20coin_add\x20to\x20replenish.\x202)\x20Owner:\x20guard_remove_expired\x20+\x20guard_expiration_time_add\x20to\x20deactivate.\x203)\x20Claimer:\x20wait\x20for\x20replenishment.','evidence':'balance=0','related_move_error':'E_INSUFFICIENT_BALANCE\x20(6)','auto_fixable':![]};}return null;}},R_R_4_03={'id':'R-R-4-03','category':'lifecycle','trigger':'guard_add\x20while\x20guard_not_added_expiration_time\x20is\x20Some\x20and\x20clock\x20≤\x20expiration\x20(E_GUARD_LOCKED_TIME)','check':a=>{if(!a['guard_add']||a['guard_add']['length']===0x0)return null;if(a['current_guard_not_added_expiration_time']==null)return null;if(a['current_clock_ms']===undefined)return null;if(a['current_clock_ms']<=a['current_guard_not_added_expiration_time'])return{'id':'R-R-4-03','level':'HIGH','category':'lifecycle','title':'guard_add\x20blocked\x20by\x20time-lock\x20(guard_not_added_expiration_time)','description':'guard_not_added_expiration_time\x20is\x20Some('+a['current_guard_not_added_expiration_time']+');\x20'+('clock\x20is\x20'+a['current_clock_ms']+'.\x20Move\x20asserts\x20clock\x20>\x20expiration_time\x20')+'(E_GUARD_LOCKED_TIME\x20=\x2010).','affected_stakeholders':['owner'],'scenario':'Trying\x20to\x20add\x20guards\x20during\x20a\x20flash\x20sale\x20lock\x20period','mitigation':'1)\x20Wait\x20until\x20clock\x20>\x20expiration_time.\x202)\x20Call\x20guard_expiration_time_add\x20(155)\x20to\x20extend\x20the\x20lock\x20(cannot\x20shorten\x20below\x20current\x20clock).','evidence':'lock_until='+a['current_guard_not_added_expiration_time']+',\x20clock='+a['current_clock_ms'],'related_move_error':'E_GUARD_LOCKED_TIME\x20(10)','auto_fixable':![]};return null;}},R_R_4_04={'id':'R-R-4-04','category':'lifecycle','trigger':'guard_expiration_time_add\x20regression\x20(new\x20time\x20<\x20current\x20clock)','check':a=>{if(a['guard_expiration_time']===undefined)return null;if(a['guard_expiration_time']===null)return null;if(a['current_clock_ms']===undefined)return null;if(a['guard_expiration_time']<=a['current_clock_ms'])return{'id':'R-R-4-04','level':'HIGH','category':'lifecycle','title':'guard_expiration_time_add:\x20new\x20time\x20must\x20be\x20in\x20the\x20future','description':'New\x20guard_not_added_expiration_time\x20=\x20'+a['guard_expiration_time']+'\x20≤\x20clock\x20'+a['current_clock_ms']+'.\x20'+'Move\x20aborts\x20with\x20E_GUARD_LOCKED_TIME_INVALID\x20(11).','affected_stakeholders':['owner'],'scenario':'Operator\x20sets\x20lock\x20time\x20in\x20the\x20past\x20by\x20mistake','mitigation':'Set\x20guard_expiration_time\x20to\x20a\x20value\x20>\x20'+a['current_clock_ms']+'\x20(current\x20clock).','evidence':'new_time='+a['guard_expiration_time']+',\x20clock='+a['current_clock_ms'],'related_move_error':'E_GUARD_LOCKED_TIME_INVALID\x20(11)','auto_fixable':!![]};return null;}},R_R_5_01={'id':'R-R-5-01','category':'cross_object','trigger':'claim:\x20guard\x20not\x20found\x20in\x20self.guards\x20(E_GUARD_NOT_FOUND)','check':a=>{if(!a['claim'])return null;if(!a['target_guard_addresses'])return null;if(!a['target_guard_addresses']['includes'](a['claim']))return{'id':'R-R-5-01','level':'HIGH','category':'cross_object','title':'claim:\x20supplied\x20guard\x20not\x20in\x20Reward.guards','description':'Guard\x20'+a['claim']+'\x20is\x20not\x20in\x20the\x20Reward\x27s\x20guard\x20list.\x20Move\x20iterates\x20self.guards\x20and\x20'+'aborts\x20with\x20E_GUARD_NOT_FOUND\x20(7)\x20if\x20no\x20match.','affected_stakeholders':['claimer'],'scenario':'Claimer\x20uses\x20the\x20wrong\x20Guard\x20object\x20(typo\x20or\x20wrong\x20Service)','mitigation':'1)\x20Verify\x20the\x20Guard\x20address\x20via\x20query\x20ObjectReward.\x202)\x20Ensure\x20the\x20Guard\x20was\x20added\x20via\x20guard_add\x20(152).','evidence':'claim_guard='+a['claim']+',\x20known_guards='+a['target_guard_addresses']['join'](','),'related_move_error':'E_GUARD_NOT_FOUND\x20(7)','auto_fixable':![]};return null;}},R_R_5_02={'id':'R-R-5-02','category':'cross_object','trigger':'coin_add:\x20coin\x20type\x20T\x20mismatch\x20with\x20Reward<T>','check':a=>{if(!a['coin_add']||!a['reward_type'])return null;if(a['coin_add']['coin_type']!==a['reward_type'])return{'id':'R-R-5-02','level':'CRITICAL','category':'cross_object','title':'coin_add:\x20coin\x20type\x20T\x20mismatch','description':'Reward\x20is\x20Reward<'+a['reward_type']+'>\x20but\x20coin_add\x20passes\x20Coin<'+a['coin_add']['coin_type']+'>.\x20'+'Move\x20type-system\x20mismatch;\x20SDK\x20W_ERROR\x20in\x20operate().','affected_stakeholders':['owner'],'scenario':'Operator\x20tries\x20to\x20deposit\x20wrong\x20coin\x20type\x20(e.g.\x20USDC\x20into\x20a\x20WOW\x20Reward)','mitigation':'Use\x20Coin<'+a['reward_type']+'>\x20for\x20coin_add.','evidence':'reward_type='+a['reward_type']+',\x20coin_type='+a['coin_add']['coin_type'],'auto_fixable':![]};return null;}},R_R_5_03={'id':'R-R-5-03','category':'cross_object','trigger':'receive:\x20Payment<T>\x20type\x20mismatch\x20with\x20Reward<T>','check':a=>{if(!a['receive']||!a['reward_type'])return null;if(a['receive']['token_type']!==a['reward_type'])return{'id':'R-R-5-03','level':'CRITICAL','category':'cross_object','title':'receive:\x20Payment\x20token_type\x20mismatch','description':'Reward\x20is\x20Reward<'+a['reward_type']+'>\x20but\x20receive\x27s\x20Payment<CoinWrapper<'+a['receive']['token_type']+'>>.\x20'+'SDK\x20W_ERROR\x20in\x20operate().','affected_stakeholders':['owner'],'scenario':'Operator\x20tries\x20to\x20receive\x20wrong-token\x20Payment','mitigation':'Use\x20Payment<'+a['reward_type']+'>\x20for\x20receive.','evidence':'reward_type='+a['reward_type']+',\x20payment_token='+a['receive']['token_type'],'auto_fixable':![]};return null;}},R_R_6_01={'id':'R-R-6-01','category':'business_semantic','trigger':'intent\x20mentions\x20praise/positive-review\x20but\x20Guard\x20checks\x20non-wonder\x20progress\x20node','check':a=>{if(!a['user_intent_phrases']||a['user_intent_phrases']['length']===0x0)return null;if(!a['guard_expected_progress_state'])return null;const b=a['user_intent_phrases']['join']('\x20')['toLowerCase'](),c=['praise','wonder','thumbs_up','positive\x20review','satisfaction\x20reward','praise\x20reward'],d=c['some'](f=>b['includes'](f['toLowerCase']()));if(!d)return null;if(a['machine_has_wonder_node']===![])return null;const e=a['guard_expected_progress_state'];if(e!=='wonder')return{'id':'R-R-6-01','level':'HIGH','category':'business_semantic','title':'Guard\x20checks\x20progress==\x22'+e+'\x22\x20but\x20intent\x20indicates\x20praise\x20reward\x20(wonder\x20node)','description':'User\x20intent\x20mentions\x20praise/positive-review/wonder,\x20which\x20maps\x20to\x20the\x20\x27wonder\x27\x20progress\x20node\x20'+'(customer\x20gives\x20positive\x20review\x20AFTER\x20service\x20completion).\x20But\x20the\x20Guard\x27s\x20table\x20bakes\x20'+('expected\x20state=\x22'+e+'\x22,\x20allowing\x20reward\x20claim\x20at\x20the\x20wrong\x20lifecycle\x20stage.\x20')+'This\x20violates\x20the\x20business\x20semantics:\x20\x22praise\x20reward\x22\x20should\x20only\x20be\x20claimable\x20AFTER\x20the\x20'+'customer\x20advances\x20to\x20the\x20\x27wonder\x27\x20node,\x20not\x20before.\x20'+'Guard\x20is\x20immutable\x20—\x20fixing\x20this\x20requires\x20creating\x20a\x20new\x20Guard\x20+\x20Reward\x20pair.','affected_stakeholders':['owner','service_provider','claimer'],'scenario':'Designer\x20builds\x20Guard\x20checking\x20\x27completed\x27\x20instead\x20of\x20\x27wonder\x27\x20for\x20a\x20praise\x20reward','mitigation':'Set\x20the\x20Guard\x20table\x27s\x20expected\x20progress\x20state\x20to\x20\x27wonder\x27\x20(the\x20positive-review\x20node).\x20'+'The\x20correct\x20pattern:\x20ordered\x20→\x20in_service\x20→\x20completed\x20→\x20wonder\x20(praise)\x20triggers\x20reward\x20claim.\x20'+'Reference:\x20reward-templates.ts\x20wonder_praise\x20template.','evidence':'intent=\x22'+b+'\x22,\x20expected_state=\x22'+e+'\x22,\x20expected_wonder=true','auto_fixable':![]};return null;}},R_R_6_02={'id':'R-R-6-02','category':'business_semantic','trigger':'Guard\x20checks\x20wonder\x20node\x20but\x20intent\x20does\x20not\x20mention\x20praise','check':a=>{if(!a['user_intent_phrases']||a['user_intent_phrases']['length']===0x0)return null;if(!a['guard_expected_progress_state'])return null;if(a['guard_expected_progress_state']!=='wonder')return null;const b=a['user_intent_phrases']['join']('\x20')['toLowerCase'](),c=['praise','wonder','thumbs_up','positive\x20review','satisfaction\x20reward','praise\x20reward'],d=c['some'](e=>b['includes'](e['toLowerCase']()));if(d)return null;return{'id':'R-R-6-02','level':'MEDIUM','category':'business_semantic','title':'Guard\x20checks\x20wonder\x20node\x20but\x20intent\x20does\x20not\x20mention\x20praise','description':'Guard\x27s\x20expected\x20progress\x20state\x20is\x20\x22wonder\x22\x20(positive-review\x20node),\x20but\x20the\x20user\x20intent\x20'+'does\x20not\x20mention\x20any\x20praise/positive-review\x20keyword.\x20This\x20may\x20be\x20a\x20copy-paste\x20from\x20a\x20wonder_praise\x20'+'template\x20without\x20adjusting\x20the\x20Guard\x20for\x20the\x20actual\x20business\x20semantics.\x20If\x20this\x20is\x20a\x20'+'general\x20feedback\x20reward\x20(wonder_feedback),\x20this\x20is\x20fine.\x20Otherwise,\x20verify\x20the\x20node\x20choice.','affected_stakeholders':['owner'],'scenario':'Designer\x20copies\x20wonder_praise\x20template\x20but\x20actually\x20wants\x20a\x20completion-based\x20reward','mitigation':'Verify:\x20if\x20intent\x20is\x20praise\x20reward,\x20add\x20\x27praise/positive\x20review\x27\x20to\x20description.\x20'+'If\x20intent\x20is\x20completion-based\x20reward,\x20change\x20Guard\x20to\x20check\x20\x27completed\x27\x20node.','evidence':'expected_state=\x22wonder\x22,\x20intent=\x22'+b+'\x22\x20(no\x20praise\x20keyword)','auto_fixable':![]};}},ALL_RULES=[R_R_1_01,R_R_1_02,R_R_1_03,R_R_2_01,R_R_2_02,R_R_2_03,R_R_2_04,R_R_3_01,R_R_3_02,R_R_3_03,R_R_4_01,R_R_4_02,R_R_4_03,R_R_4_04,R_R_5_01,R_R_5_02,R_R_5_03,R_R_6_01,R_R_6_02];export const REWARD_RISK_VERSION='1.0.0';export function getAllRewardRiskRules(){return[...ALL_RULES];}export function getRewardRiskRulesCount(){return ALL_RULES['length'];}export function getRewardRiskRulesByCategory(a){return ALL_RULES['filter'](b=>b['category']===a);}export function assessRewardRisks(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')};}export const REWARD_STAKEHOLDERS=['owner','claimer','service_provider','system'];export function getRewardRiskRulesByStakeholder(a){return ALL_RULES['filter'](b=>{if(a==='owner')return['structural','permission','lifecycle','business_semantic']['includes'](b['category']);if(a==='claimer')return b['id']['startsWith']('R-R-4-0')||b['id']==='R-R-5-01'||b['id']==='R-R-1-02'||b['id']==='R-R-6-01';if(a==='service_provider')return b['id']==='R-R-4-02'||b['id']==='R-R-3-01'||b['id']==='R-R-3-02'||b['id']==='R-R-6-01';if(a==='system')return b['category']==='cross_object';return![];});}