@wowok/agent-mcp 2.7.1 → 2.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (597) hide show
  1. package/dist/config/index.js +1 -1
  2. package/dist/config/runtime.js +1 -238
  3. package/dist/customer/account-events.d.ts +32 -0
  4. package/dist/customer/account-events.js +1 -0
  5. package/dist/customer/customer-advice.d.ts +1 -0
  6. package/dist/customer/customer-advice.js +1 -130
  7. package/dist/customer/index.js +1 -11
  8. package/dist/customer/industry-risks.js +1 -438
  9. package/dist/customer/info-puzzle.js +1 -681
  10. package/dist/customer/order-monitor.js +1 -328
  11. package/dist/customer/order-strategy.d.ts +1 -1
  12. package/dist/customer/order-strategy.js +1 -373
  13. package/dist/customer/post-purchase.js +1 -351
  14. package/dist/customer/preorder-compare.js +1 -34
  15. package/dist/customer/reminder-system.d.ts +2 -0
  16. package/dist/customer/reminder-system.js +1 -316
  17. package/dist/customer/risk-assessment.d.ts +1 -0
  18. package/dist/customer/risk-assessment.js +1 -397
  19. package/dist/customer/types.d.ts +2 -0
  20. package/dist/customer/types.js +1 -13
  21. package/dist/customer/user-preferences.js +1 -460
  22. package/dist/evaluation/arbitration-game.d.ts +9 -2
  23. package/dist/evaluation/arbitration-game.js +1 -48
  24. package/dist/evaluation/builtins/arbitration-score.d.ts +41 -0
  25. package/dist/evaluation/builtins/arbitration-score.js +1 -0
  26. package/dist/evaluation/builtins/demand-match.js +1 -153
  27. package/dist/evaluation/builtins/index.d.ts +1 -0
  28. package/dist/evaluation/builtins/index.js +1 -10
  29. package/dist/evaluation/builtins/service-risk.js +1 -55
  30. package/dist/evaluation/capability.js +1 -13
  31. package/dist/evaluation/category-match-rules.d.ts +30 -0
  32. package/dist/evaluation/category-match-rules.js +1 -0
  33. package/dist/evaluation/composer.js +1 -40
  34. package/dist/evaluation/engine.js +1 -175
  35. package/dist/evaluation/extract.js +1 -115
  36. package/dist/evaluation/game-strategy.d.ts +27 -0
  37. package/dist/evaluation/game-strategy.js +1 -0
  38. package/dist/evaluation/gap.js +1 -100
  39. package/dist/evaluation/index.d.ts +2 -0
  40. package/dist/evaluation/index.js +1 -11
  41. package/dist/evaluation/location-match.d.ts +42 -0
  42. package/dist/evaluation/location-match.js +1 -0
  43. package/dist/evaluation/node-game.d.ts +31 -3
  44. package/dist/evaluation/node-game.js +1 -57
  45. package/dist/evaluation/path-reasoning.d.ts +35 -0
  46. package/dist/evaluation/path-reasoning.js +1 -0
  47. package/dist/evaluation/region.d.ts +6 -0
  48. package/dist/evaluation/region.js +1 -36
  49. package/dist/evaluation/types.d.ts +18 -0
  50. package/dist/evaluation/types.js +1 -1
  51. package/dist/evaluation/user-injection.js +1 -27
  52. package/dist/experience/experience-reuse.js +1 -103
  53. package/dist/experience/index.js +1 -5
  54. package/dist/experience/intent-distill.js +1 -83
  55. package/dist/experience/realtime-feedback.js +1 -94
  56. package/dist/experience/types.js +1 -1
  57. package/dist/experience/user-profile.d.ts +1 -1
  58. package/dist/experience/user-profile.js +1 -171
  59. package/dist/extensions/business-modules.js +1 -287
  60. package/dist/extensions/capability-manifest.js +1 -781
  61. package/dist/extensions/constraint-registry.js +1 -198
  62. package/dist/extensions/index.d.ts +6 -0
  63. package/dist/extensions/index.js +1 -6
  64. package/dist/extensions/industry-layers.d.ts +75 -0
  65. package/dist/extensions/industry-layers.js +1 -0
  66. package/dist/extensions/industry-pack.d.ts +105 -0
  67. package/dist/extensions/industry-pack.js +1 -0
  68. package/dist/extensions/metric-registry.js +1 -257
  69. package/dist/extensions/mode-evaluator.d.ts +1 -1
  70. package/dist/extensions/mode-evaluator.js +1 -170
  71. package/dist/extensions/modes.js +1 -499
  72. package/dist/extensions/registry.d.ts +1 -0
  73. package/dist/extensions/registry.js +1 -717
  74. package/dist/extensions/types.js +1 -1
  75. package/dist/graph/base.d.ts +8 -0
  76. package/dist/graph/base.js +1 -0
  77. package/dist/harness/auto-escalation.js +1 -68
  78. package/dist/harness/checkpoint.js +1 -129
  79. package/dist/harness/index.d.ts +1 -0
  80. package/dist/harness/index.js +1 -78
  81. package/dist/harness/plan.d.ts +2 -0
  82. package/dist/harness/plan.js +1 -315
  83. package/dist/harness/recover.d.ts +1 -1
  84. package/dist/harness/recover.js +1 -139
  85. package/dist/harness/types.d.ts +2 -3
  86. package/dist/harness/types.js +1 -1
  87. package/dist/harness/verify.js +1 -237
  88. package/dist/index.js +1 -273
  89. package/dist/intent/enrich.js +1 -67
  90. package/dist/intent/index.js +1 -60
  91. package/dist/intent/matcher.js +1 -81
  92. package/dist/intent/store.js +1 -55
  93. package/dist/intent/types.js +1 -10
  94. package/dist/knowledge/acquisition-flywheel.js +1 -192
  95. package/dist/knowledge/allocation-confirm.js +1 -534
  96. package/dist/knowledge/allocation-context.js +1 -249
  97. package/dist/knowledge/allocation-ledger.js +1 -463
  98. package/dist/knowledge/allocation-puzzle.js +1 -298
  99. package/dist/knowledge/allocation-risk.js +1 -568
  100. package/dist/knowledge/allocation-templates.js +1 -970
  101. package/dist/knowledge/allocation-translation.js +1 -585
  102. package/dist/knowledge/anti-cheat.d.ts +37 -0
  103. package/dist/knowledge/anti-cheat.js +1 -0
  104. package/dist/knowledge/arb-confirm.d.ts +28 -0
  105. package/dist/knowledge/arb-confirm.js +1 -0
  106. package/dist/knowledge/arb-risk.js +1 -210
  107. package/dist/knowledge/arb-translation.d.ts +48 -0
  108. package/dist/knowledge/arb-translation.js +1 -0
  109. package/dist/knowledge/arbitration-confirm.js +1 -559
  110. package/dist/knowledge/arbitration-context.js +1 -505
  111. package/dist/knowledge/arbitration-ledger.js +1 -521
  112. package/dist/knowledge/arbitration-puzzle.js +1 -304
  113. package/dist/knowledge/arbitration-risk.js +1 -423
  114. package/dist/knowledge/arbitration-templates.js +1 -276
  115. package/dist/knowledge/arbitration-translation.js +1 -487
  116. package/dist/knowledge/audit-rules.js +1 -141
  117. package/dist/knowledge/bridge-confirm.d.ts +26 -0
  118. package/dist/knowledge/bridge-confirm.js +1 -0
  119. package/dist/knowledge/bridge-risk.js +1 -263
  120. package/dist/knowledge/bridge-translation.d.ts +37 -0
  121. package/dist/knowledge/bridge-translation.js +1 -0
  122. package/dist/knowledge/contact-confirm.d.ts +27 -0
  123. package/dist/knowledge/contact-confirm.js +1 -0
  124. package/dist/knowledge/contact-risk.js +1 -200
  125. package/dist/knowledge/contact-templates.js +1 -60
  126. package/dist/knowledge/contact-translation.d.ts +39 -0
  127. package/dist/knowledge/contact-translation.js +1 -0
  128. package/dist/knowledge/demand-confirm.js +1 -206
  129. package/dist/knowledge/demand-context.d.ts +17 -0
  130. package/dist/knowledge/demand-context.js +1 -0
  131. package/dist/knowledge/demand-ledger.d.ts +26 -0
  132. package/dist/knowledge/demand-ledger.js +1 -0
  133. package/dist/knowledge/demand-matching.js +1 -132
  134. package/dist/knowledge/demand-puzzle.d.ts +29 -0
  135. package/dist/knowledge/demand-puzzle.js +1 -0
  136. package/dist/knowledge/demand-risk.js +1 -240
  137. package/dist/knowledge/demand-templates.d.ts +12 -0
  138. package/dist/knowledge/demand-templates.js +1 -0
  139. package/dist/knowledge/demand-translation.js +1 -354
  140. package/dist/knowledge/deployment-scanner.js +1 -823
  141. package/dist/knowledge/dynamic-pricing.js +1 -87
  142. package/dist/knowledge/evidence-review.d.ts +12 -0
  143. package/dist/knowledge/evidence-review.js +1 -0
  144. package/dist/knowledge/examples-scanner-cli.js +1 -26
  145. package/dist/knowledge/examples-scanner.js +1 -843
  146. package/dist/knowledge/flywheel-loop.d.ts +0 -1
  147. package/dist/knowledge/flywheel-loop.js +1 -404
  148. package/dist/knowledge/fund-layer.js +1 -973
  149. package/dist/knowledge/glossary.js +1 -211
  150. package/dist/knowledge/guard-confirm.js +1 -406
  151. package/dist/knowledge/guard-context.js +1 -287
  152. package/dist/knowledge/guard-design-patterns.js +1 -360
  153. package/dist/knowledge/guard-ledger.js +1 -260
  154. package/dist/knowledge/guard-lint.js +1 -670
  155. package/dist/knowledge/guard-migration.d.ts +1 -1
  156. package/dist/knowledge/guard-migration.js +1 -228
  157. package/dist/knowledge/guard-puzzle.js +1 -805
  158. package/dist/knowledge/guard-render.js +1 -700
  159. package/dist/knowledge/guard-risk.js +1 -1879
  160. package/dist/knowledge/guard-submission-prompt.js +1 -171
  161. package/dist/knowledge/guard-templates.js +1 -1105
  162. package/dist/knowledge/guard-translation.js +1 -1119
  163. package/dist/knowledge/index.d.ts +71 -3
  164. package/dist/knowledge/index.js +1 -436
  165. package/dist/knowledge/industry-evolution.js +1 -323
  166. package/dist/knowledge/industry-generalizer.js +1 -381
  167. package/dist/knowledge/industry-registry.js +1 -174
  168. package/dist/knowledge/intent-metrics.d.ts +4 -3
  169. package/dist/knowledge/intent-metrics.js +1 -566
  170. package/dist/knowledge/machine-confirm.js +1 -559
  171. package/dist/knowledge/machine-context.js +1 -833
  172. package/dist/knowledge/machine-ledger.js +1 -338
  173. package/dist/knowledge/machine-puzzle.js +1 -494
  174. package/dist/knowledge/machine-render.js +1 -565
  175. package/dist/knowledge/machine-risk.js +1 -669
  176. package/dist/knowledge/machine-templates.js +1 -1597
  177. package/dist/knowledge/machine-topology.js +1 -234
  178. package/dist/knowledge/machine-translation.js +1 -513
  179. package/dist/knowledge/market-metrics.d.ts +12 -0
  180. package/dist/knowledge/market-metrics.js +1 -0
  181. package/dist/knowledge/market-operations.d.ts +46 -0
  182. package/dist/knowledge/market-operations.js +1 -0
  183. package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
  184. package/dist/knowledge/mcp-schema-audit.d.ts +22 -22
  185. package/dist/knowledge/mcp-schema-audit.js +1 -777
  186. package/dist/knowledge/onchain-constants.js +1 -35
  187. package/dist/knowledge/order-confirm.js +1 -573
  188. package/dist/knowledge/order-context.js +1 -390
  189. package/dist/knowledge/order-ledger.js +1 -341
  190. package/dist/knowledge/order-puzzle.js +1 -255
  191. package/dist/knowledge/order-risk.js +1 -653
  192. package/dist/knowledge/order-templates.js +1 -368
  193. package/dist/knowledge/order-translation.js +1 -550
  194. package/dist/knowledge/overrides-loader.js +1 -65
  195. package/dist/knowledge/passport-confirm.js +1 -531
  196. package/dist/knowledge/passport-context.js +1 -306
  197. package/dist/knowledge/passport-ledger.js +1 -282
  198. package/dist/knowledge/passport-puzzle.js +1 -333
  199. package/dist/knowledge/passport-risk.js +1 -450
  200. package/dist/knowledge/passport-templates.js +1 -568
  201. package/dist/knowledge/passport-translation.js +1 -516
  202. package/dist/knowledge/payment-confirm.d.ts +26 -0
  203. package/dist/knowledge/payment-confirm.js +1 -0
  204. package/dist/knowledge/payment-risk.js +1 -249
  205. package/dist/knowledge/payment-translation.d.ts +37 -0
  206. package/dist/knowledge/payment-translation.js +1 -0
  207. package/dist/knowledge/permission-confirm.js +1 -426
  208. package/dist/knowledge/permission-context.js +1 -224
  209. package/dist/knowledge/permission-ledger.d.ts +11 -0
  210. package/dist/knowledge/permission-ledger.js +1 -403
  211. package/dist/knowledge/permission-puzzle.js +1 -173
  212. package/dist/knowledge/permission-risk.js +1 -411
  213. package/dist/knowledge/permission-templates.js +1 -234
  214. package/dist/knowledge/permission-translation.js +1 -350
  215. package/dist/knowledge/personal-confirm.d.ts +29 -0
  216. package/dist/knowledge/personal-confirm.js +1 -0
  217. package/dist/knowledge/personal-risk.js +1 -212
  218. package/dist/knowledge/personal-translation.d.ts +37 -0
  219. package/dist/knowledge/personal-translation.js +1 -0
  220. package/dist/knowledge/process-model.d.ts +1 -11
  221. package/dist/knowledge/process-model.js +1 -160
  222. package/dist/knowledge/progress-confirm.js +1 -456
  223. package/dist/knowledge/progress-context.js +1 -452
  224. package/dist/knowledge/progress-ledger.js +1 -330
  225. package/dist/knowledge/progress-puzzle.js +1 -219
  226. package/dist/knowledge/progress-risk.js +1 -461
  227. package/dist/knowledge/progress-templates.js +1 -228
  228. package/dist/knowledge/progress-translation.js +1 -405
  229. package/dist/knowledge/proof-confirm.js +1 -187
  230. package/dist/knowledge/proof-context.d.ts +17 -0
  231. package/dist/knowledge/proof-context.js +1 -0
  232. package/dist/knowledge/proof-ledger.d.ts +34 -0
  233. package/dist/knowledge/proof-ledger.js +1 -0
  234. package/dist/knowledge/proof-puzzle.d.ts +35 -0
  235. package/dist/knowledge/proof-puzzle.js +1 -0
  236. package/dist/knowledge/proof-risk.js +1 -207
  237. package/dist/knowledge/proof-templates.d.ts +22 -0
  238. package/dist/knowledge/proof-templates.js +1 -0
  239. package/dist/knowledge/proof-translation.js +1 -283
  240. package/dist/knowledge/registrar-confirm.d.ts +26 -0
  241. package/dist/knowledge/registrar-confirm.js +1 -0
  242. package/dist/knowledge/registrar-risk.js +1 -217
  243. package/dist/knowledge/registrar-translation.d.ts +37 -0
  244. package/dist/knowledge/registrar-translation.js +1 -0
  245. package/dist/knowledge/repository-confirm.js +1 -286
  246. package/dist/knowledge/repository-context.d.ts +12 -0
  247. package/dist/knowledge/repository-context.js +1 -0
  248. package/dist/knowledge/repository-ledger.d.ts +25 -0
  249. package/dist/knowledge/repository-ledger.js +1 -0
  250. package/dist/knowledge/repository-puzzle.d.ts +30 -0
  251. package/dist/knowledge/repository-puzzle.js +1 -0
  252. package/dist/knowledge/repository-risk.js +1 -373
  253. package/dist/knowledge/repository-templates.d.ts +14 -0
  254. package/dist/knowledge/repository-templates.js +1 -0
  255. package/dist/knowledge/repository-translation.js +1 -445
  256. package/dist/knowledge/reputation-rules.js +1 -99
  257. package/dist/knowledge/resource-confirm.d.ts +25 -0
  258. package/dist/knowledge/resource-confirm.js +1 -0
  259. package/dist/knowledge/resource-risk.js +1 -157
  260. package/dist/knowledge/resource-translation.d.ts +37 -0
  261. package/dist/knowledge/resource-translation.js +1 -0
  262. package/dist/knowledge/reward-confirm.js +1 -526
  263. package/dist/knowledge/reward-context.d.ts +2 -2
  264. package/dist/knowledge/reward-context.js +1 -504
  265. package/dist/knowledge/reward-ledger.js +1 -502
  266. package/dist/knowledge/reward-puzzle.js +1 -300
  267. package/dist/knowledge/reward-risk.js +1 -627
  268. package/dist/knowledge/reward-templates.js +1 -197
  269. package/dist/knowledge/reward-translation.js +1 -501
  270. package/dist/knowledge/safety-rules.d.ts +1 -0
  271. package/dist/knowledge/safety-rules.js +1 -404
  272. package/dist/knowledge/scenario-modes.js +1 -321
  273. package/dist/knowledge/service-confirm.js +1 -807
  274. package/dist/knowledge/service-context.js +1 -403
  275. package/dist/knowledge/service-ledger.js +1 -609
  276. package/dist/knowledge/service-puzzle.js +1 -236
  277. package/dist/knowledge/service-risk.d.ts +1 -1
  278. package/dist/knowledge/service-risk.js +1 -651
  279. package/dist/knowledge/service-templates.js +1 -456
  280. package/dist/knowledge/service-translation.js +1 -622
  281. package/dist/knowledge/template-registry.js +1 -353
  282. package/dist/knowledge/tool-constraints.js +1 -195
  283. package/dist/knowledge/tools-reference.js +1 -178
  284. package/dist/knowledge/treasury-confirm.js +1 -512
  285. package/dist/knowledge/treasury-context.js +1 -363
  286. package/dist/knowledge/treasury-ledger.js +1 -300
  287. package/dist/knowledge/treasury-puzzle.js +1 -216
  288. package/dist/knowledge/treasury-risk.js +1 -440
  289. package/dist/knowledge/treasury-templates.js +1 -358
  290. package/dist/knowledge/treasury-translation.js +1 -498
  291. package/dist/knowledge/trust-metrics.js +1 -198
  292. package/dist/knowledge/universal-template.d.ts +22 -0
  293. package/dist/knowledge/universal-template.js +1 -0
  294. package/dist/knowledge/util-confirm.d.ts +24 -0
  295. package/dist/knowledge/util-confirm.js +1 -0
  296. package/dist/knowledge/util-risk.js +1 -135
  297. package/dist/knowledge/util-translation.d.ts +38 -0
  298. package/dist/knowledge/util-translation.js +1 -0
  299. package/dist/knowledge/workflow-guidance.d.ts +116 -0
  300. package/dist/knowledge/workflow-guidance.js +1 -0
  301. package/dist/loop-engineering/aggregate.js +1 -132
  302. package/dist/loop-engineering/context-collect.js +1 -83
  303. package/dist/loop-engineering/diagnose.js +1 -273
  304. package/dist/loop-engineering/improve.js +1 -405
  305. package/dist/loop-engineering/index.js +1 -4
  306. package/dist/loop-engineering/pipeline.js +1 -56
  307. package/dist/mode-market/index.js +1 -3
  308. package/dist/mode-market/registry.js +1 -124
  309. package/dist/mode-market/review.js +1 -214
  310. package/dist/mode-market/submission.js +1 -85
  311. package/dist/participation/collaborator-interest.d.ts +23 -0
  312. package/dist/participation/collaborator-interest.js +1 -0
  313. package/dist/participation/customer-interest.d.ts +25 -0
  314. package/dist/participation/customer-interest.js +1 -0
  315. package/dist/participation/employee-kpi.d.ts +25 -0
  316. package/dist/participation/employee-kpi.js +1 -0
  317. package/dist/participation/employee-store.d.ts +16 -0
  318. package/dist/participation/employee-store.js +1 -0
  319. package/dist/participation/index.d.ts +2 -0
  320. package/dist/participation/index.js +1 -0
  321. package/dist/participation/merchant-interest.js +1 -100
  322. package/dist/participation/radar-core.d.ts +13 -3
  323. package/dist/participation/radar-core.js +1 -269
  324. package/dist/participation/supplier-interest.d.ts +25 -0
  325. package/dist/participation/supplier-interest.js +1 -0
  326. package/dist/persona/analyzer.js +1 -66
  327. package/dist/persona/bridge.js +1 -86
  328. package/dist/persona/defaults.js +1 -195
  329. package/dist/persona/experience-bridge.js +1 -23
  330. package/dist/persona/index.d.ts +9 -2
  331. package/dist/persona/index.js +1 -71
  332. package/dist/persona/local-region.d.ts +20 -0
  333. package/dist/persona/local-region.js +1 -0
  334. package/dist/persona/model.js +1 -111
  335. package/dist/persona/overrides.d.ts +10 -0
  336. package/dist/persona/overrides.js +1 -0
  337. package/dist/persona/pack-personae.d.ts +11 -0
  338. package/dist/persona/pack-personae.js +1 -0
  339. package/dist/persona/store.js +1 -62
  340. package/dist/persona/strategy-intent.d.ts +20 -0
  341. package/dist/persona/strategy-intent.js +1 -0
  342. package/dist/persona/types.d.ts +6 -2
  343. package/dist/persona/types.js +1 -5
  344. package/dist/project/business-puzzle.d.ts +1 -1
  345. package/dist/project/business-puzzle.js +1 -383
  346. package/dist/project/context-assembly.js +1 -254
  347. package/dist/project/deployment-bridge.js +1 -120
  348. package/dist/project/deployment-doc.js +1 -1126
  349. package/dist/project/edit-planner.js +1 -1342
  350. package/dist/project/evaluation.d.ts +37 -1
  351. package/dist/project/evaluation.js +1 -2011
  352. package/dist/project/game-theory.js +1 -177
  353. package/dist/project/graph-builder.js +1 -656
  354. package/dist/project/graph.d.ts +3 -6
  355. package/dist/project/graph.js +1 -340
  356. package/dist/project/handlers.d.ts +33 -2
  357. package/dist/project/handlers.js +1 -1784
  358. package/dist/project/index.d.ts +2 -0
  359. package/dist/project/index.js +1 -301
  360. package/dist/project/intent-analyzer.js +1 -149
  361. package/dist/project/machine-nodes.js +1 -36
  362. package/dist/project/merchant-guide.d.ts +19 -0
  363. package/dist/project/merchant-guide.js +1 -264
  364. package/dist/project/migration.js +1 -125
  365. package/dist/project/mode-actions.js +1 -309
  366. package/dist/project/namespace.js +1 -206
  367. package/dist/project/participation-radar.js +1 -428
  368. package/dist/project/pipeline-actions.js +1 -109
  369. package/dist/project/project-store.js +1 -422
  370. package/dist/project/query.js +1 -153
  371. package/dist/project/reverse-mapping.d.ts +34 -0
  372. package/dist/project/reverse-mapping.js +1 -0
  373. package/dist/project/risk-aggregator.js +1 -295
  374. package/dist/project/rollback-policy.js +1 -290
  375. package/dist/project/semantic-assembler.js +1 -345
  376. package/dist/project/semantic-graph.d.ts +3 -5
  377. package/dist/project/semantic-graph.js +1 -292
  378. package/dist/project/stage-gate.js +1 -369
  379. package/dist/project/substep-trace.js +1 -332
  380. package/dist/project/task-tracker.js +1 -78
  381. package/dist/project/workflow-design-assessment.d.ts +24 -0
  382. package/dist/project/workflow-design-assessment.js +1 -0
  383. package/dist/role/derivation.d.ts +18 -0
  384. package/dist/role/derivation.js +1 -0
  385. package/dist/role/index.d.ts +5 -0
  386. package/dist/role/index.js +1 -0
  387. package/dist/role/model.d.ts +8 -0
  388. package/dist/role/model.js +1 -0
  389. package/dist/role/resolution.d.ts +11 -0
  390. package/dist/role/resolution.js +1 -0
  391. package/dist/role/types.d.ts +11 -0
  392. package/dist/role/types.js +1 -0
  393. package/dist/rules.js +1 -52
  394. package/dist/safety/confirm-gate.d.ts +1 -1
  395. package/dist/safety/confirm-gate.js +1 -88
  396. package/dist/safety/index.js +1 -3
  397. package/dist/safety/preview.js +1 -52
  398. package/dist/schema/call/allocation.d.ts +186 -1385
  399. package/dist/schema/call/allocation.js +1 -34
  400. package/dist/schema/call/arbitration.d.ts +272 -1871
  401. package/dist/schema/call/arbitration.js +1 -113
  402. package/dist/schema/call/base.d.ts +1831 -9076
  403. package/dist/schema/call/base.js +1 -370
  404. package/dist/schema/call/bridge.d.ts +911 -3171
  405. package/dist/schema/call/bridge.js +1 -458
  406. package/dist/schema/call/contact.d.ts +135 -931
  407. package/dist/schema/call/contact.js +1 -37
  408. package/dist/schema/call/demand.d.ts +164 -1194
  409. package/dist/schema/call/demand.js +1 -47
  410. package/dist/schema/call/guard.d.ts +298 -1140
  411. package/dist/schema/call/guard.js +1 -161
  412. package/dist/schema/call/handler.js +1 -322
  413. package/dist/schema/call/index.js +1 -20
  414. package/dist/schema/call/machine.d.ts +459 -5403
  415. package/dist/schema/call/machine.js +1 -193
  416. package/dist/schema/call/order.d.ts +137 -844
  417. package/dist/schema/call/order.js +1 -35
  418. package/dist/schema/call/payment.d.ts +74 -561
  419. package/dist/schema/call/payment.js +1 -37
  420. package/dist/schema/call/permission-handler.js +1 -54
  421. package/dist/schema/call/permission.d.ts +335 -2791
  422. package/dist/schema/call/permission.js +1 -105
  423. package/dist/schema/call/personal.d.ts +227 -1814
  424. package/dist/schema/call/personal.js +1 -78
  425. package/dist/schema/call/progress.d.ts +140 -843
  426. package/dist/schema/call/progress.js +1 -47
  427. package/dist/schema/call/proof.d.ts +42 -258
  428. package/dist/schema/call/proof.js +1 -33
  429. package/dist/schema/call/repository.d.ts +324 -2222
  430. package/dist/schema/call/repository.js +1 -77
  431. package/dist/schema/call/reward.d.ts +153 -1183
  432. package/dist/schema/call/reward.js +1 -30
  433. package/dist/schema/call/semantic.js +1 -1679
  434. package/dist/schema/call/service.d.ts +376 -3431
  435. package/dist/schema/call/service.js +1 -184
  436. package/dist/schema/call/treasury.d.ts +252 -2158
  437. package/dist/schema/call/treasury.js +1 -71
  438. package/dist/schema/common/index.d.ts +222 -697
  439. package/dist/schema/common/index.js +1 -407
  440. package/dist/schema/config/index.d.ts +18 -161
  441. package/dist/schema/config/index.js +1 -68
  442. package/dist/schema/employee/index.d.ts +99 -0
  443. package/dist/schema/employee/index.js +1 -0
  444. package/dist/schema/evaluation/index.d.ts +1062 -3748
  445. package/dist/schema/evaluation/index.js +1 -356
  446. package/dist/schema/index.d.ts +3 -0
  447. package/dist/schema/index.js +1 -17
  448. package/dist/schema/industry-pack/index.d.ts +132 -0
  449. package/dist/schema/industry-pack/index.js +1 -0
  450. package/dist/schema/intent-radar/index.d.ts +92 -245
  451. package/dist/schema/intent-radar/index.js +1 -89
  452. package/dist/schema/local/index.d.ts +2045 -18080
  453. package/dist/schema/local/index.js +1 -927
  454. package/dist/schema/local/wip.d.ts +61 -651
  455. package/dist/schema/local/wip.js +1 -187
  456. package/dist/schema/messenger/index.d.ts +949 -5557
  457. package/dist/schema/messenger/index.js +1 -475
  458. package/dist/schema/operations.d.ts +2969 -26518
  459. package/dist/schema/operations.js +1 -520
  460. package/dist/schema/persona/index.d.ts +469 -1820
  461. package/dist/schema/persona/index.js +1 -148
  462. package/dist/schema/project/index.d.ts +1027 -8408
  463. package/dist/schema/project/index.js +1 -2057
  464. package/dist/schema/query/index.d.ts +12041 -75261
  465. package/dist/schema/query/index.js +1 -1646
  466. package/dist/schema/schema-query/index.d.ts +35 -98
  467. package/dist/schema/schema-query/index.js +1 -104
  468. package/dist/schema/schema-version.js +1 -76
  469. package/dist/schema/task-status.d.ts +26 -132
  470. package/dist/schema/task-status.js +1 -36
  471. package/dist/schema/trust/index.d.ts +194 -1290
  472. package/dist/schema/trust/index.js +1 -314
  473. package/dist/schema/utils/guard-parser.js +1 -419
  474. package/dist/schema/utils/guard-query-utils.js +1 -46
  475. package/dist/schema/utils/node-parser.js +1 -369
  476. package/dist/schema/utils/object-type-utils.js +1 -35
  477. package/dist/schema/utils/permission-index-utils.js +1 -7
  478. package/dist/schema/utils/permission-machine-check.js +1 -121
  479. package/dist/schema/utils/skills-recommendation.d.ts +1 -0
  480. package/dist/schema/utils/skills-recommendation.js +1 -77
  481. package/dist/schema/workspace/index.d.ts +69 -0
  482. package/dist/schema/workspace/index.js +1 -0
  483. package/dist/schema-query-impl/index.js +1 -0
  484. package/dist/schemas/account_operation.output.json +3147 -1652
  485. package/dist/schemas/account_operation.schema.json +225 -218
  486. package/dist/schemas/bridge_operation.output.json +1168 -650
  487. package/dist/schemas/bridge_operation.schema.json +736 -504
  488. package/dist/schemas/config_operation.output.json +185 -179
  489. package/dist/schemas/config_operation.schema.json +21 -26
  490. package/dist/schemas/employee_operation.output.json +207 -0
  491. package/dist/schemas/employee_operation.schema.json +176 -0
  492. package/dist/schemas/evaluation_operation.output.json +2329 -557
  493. package/dist/schemas/evaluation_operation.schema.json +2939 -720
  494. package/dist/schemas/guard2file.output.json +58 -64
  495. package/dist/schemas/guard2file.schema.json +79 -81
  496. package/dist/schemas/index.json +29 -11
  497. package/dist/schemas/industry_pack_operation.output.json +594 -0
  498. package/dist/schemas/industry_pack_operation.schema.json +55 -0
  499. package/dist/schemas/intent_radar.output.json +275 -200
  500. package/dist/schemas/intent_radar.schema.json +124 -123
  501. package/dist/schemas/local_info_operation.output.json +1174 -657
  502. package/dist/schemas/local_info_operation.schema.json +119 -125
  503. package/dist/schemas/local_mark_operation.output.json +1239 -689
  504. package/dist/schemas/local_mark_operation.schema.json +91 -96
  505. package/dist/schemas/machineNode2file.output.json +63 -69
  506. package/dist/schemas/machineNode2file.schema.json +79 -81
  507. package/dist/schemas/messenger_operation.output.json +2722 -1528
  508. package/dist/schemas/messenger_operation.schema.json +1482 -1264
  509. package/dist/schemas/onchain_events.output.json +2590 -975
  510. package/dist/schemas/onchain_events.schema.json +117 -99
  511. package/dist/schemas/onchain_operations.output.json +3957 -2309
  512. package/dist/schemas/onchain_operations.schema.json +20799 -9285
  513. package/dist/schemas/onchain_operations_allocation.schema.json +172 -108
  514. package/dist/schemas/onchain_operations_arbitration.schema.json +233 -146
  515. package/dist/schemas/onchain_operations_contact.schema.json +129 -90
  516. package/dist/schemas/onchain_operations_demand.schema.json +170 -112
  517. package/dist/schemas/onchain_operations_gen_passport.schema.json +61 -646
  518. package/dist/schemas/onchain_operations_gen_proof.schema.json +40 -172
  519. package/dist/schemas/onchain_operations_guard.schema.json +3765 -294
  520. package/dist/schemas/onchain_operations_machine.schema.json +537 -164
  521. package/dist/schemas/onchain_operations_order.schema.json +126 -96
  522. package/dist/schemas/onchain_operations_payment.schema.json +82 -67
  523. package/dist/schemas/onchain_operations_permission.schema.json +331 -93
  524. package/dist/schemas/onchain_operations_personal.schema.json +636 -96
  525. package/dist/schemas/onchain_operations_progress.schema.json +125 -92
  526. package/dist/schemas/onchain_operations_proof.schema.json +76 -69
  527. package/dist/schemas/onchain_operations_repository.schema.json +636 -249
  528. package/dist/schemas/onchain_operations_reward.schema.json +218 -108
  529. package/dist/schemas/onchain_operations_service.schema.json +679 -221
  530. package/dist/schemas/onchain_operations_treasury.schema.json +401 -135
  531. package/dist/schemas/onchain_table_data.output.json +6018 -2430
  532. package/dist/schemas/onchain_table_data.schema.json +544 -430
  533. package/dist/schemas/persona_operation.output.json +1568 -265
  534. package/dist/schemas/persona_operation.schema.json +346 -202
  535. package/dist/schemas/project_operation.output.json +6957 -5147
  536. package/dist/schemas/project_operation.schema.json +1050 -1020
  537. package/dist/schemas/query_task_status.output.json +195 -99
  538. package/dist/schemas/query_task_status.schema.json +12 -18
  539. package/dist/schemas/query_toolkit.output.json +18870 -14566
  540. package/dist/schemas/query_toolkit.schema.json +614 -522
  541. package/dist/schemas/schema_query.output.json +127 -129
  542. package/dist/schemas/schema_query.schema.json +64 -69
  543. package/dist/schemas/trust_score.output.json +678 -587
  544. package/dist/schemas/trust_score.schema.json +289 -277
  545. package/dist/schemas/wip_file.output.json +116 -124
  546. package/dist/schemas/wip_file.schema.json +142 -143
  547. package/dist/schemas/workspace_operation.output.json +277 -0
  548. package/dist/schemas/workspace_operation.schema.json +45 -0
  549. package/dist/schemas/wowok_buildin_info.output.json +1693 -723
  550. package/dist/schemas/wowok_buildin_info.schema.json +576 -512
  551. package/dist/telemetry/index.js +1 -112
  552. package/dist/telemetry/redact.js +1 -23
  553. package/dist/telemetry/storage.js +1 -80
  554. package/dist/tools/handlers/bridge.d.ts +8 -1
  555. package/dist/tools/handlers/bridge.js +1 -1
  556. package/dist/tools/handlers/config.js +1 -74
  557. package/dist/tools/handlers/employee.d.ts +2 -0
  558. package/dist/tools/handlers/employee.js +1 -0
  559. package/dist/tools/handlers/evaluation.js +1 -123
  560. package/dist/tools/handlers/file-export.js +1 -90
  561. package/dist/tools/handlers/industry-pack.d.ts +2 -0
  562. package/dist/tools/handlers/industry-pack.js +1 -0
  563. package/dist/tools/handlers/intent-radar.js +1 -76
  564. package/dist/tools/handlers/local.js +1 -53
  565. package/dist/tools/handlers/messenger.js +1 -188
  566. package/dist/tools/handlers/onchain.js +1 -1180
  567. package/dist/tools/handlers/persona.js +1 -89
  568. package/dist/tools/handlers/project.js +1 -211
  569. package/dist/tools/handlers/query.js +1 -434
  570. package/dist/tools/handlers/schema-query.js +1 -176
  571. package/dist/tools/handlers/task-status.js +1 -26
  572. package/dist/tools/handlers/trust.js +1 -380
  573. package/dist/tools/handlers/wip.js +1 -90
  574. package/dist/tools/handlers/workspace.d.ts +2 -0
  575. package/dist/tools/handlers/workspace.js +1 -0
  576. package/dist/tools/index.d.ts +2 -1
  577. package/dist/tools/index.js +1 -1382
  578. package/dist/tools/retry.js +1 -85
  579. package/dist/tools/rules-hook.d.ts +1 -1
  580. package/dist/tools/rules-hook.js +1 -23
  581. package/dist/tools/shared.d.ts +1 -1
  582. package/dist/tools/shared.js +1 -130
  583. package/dist/tools/types.d.ts +2 -1
  584. package/dist/tools/types.js +1 -1
  585. package/dist/tools/upgrade-check.d.ts +19 -0
  586. package/dist/tools/upgrade-check.js +1 -0
  587. package/dist/tools/wip-deploy-assist.js +1 -306
  588. package/dist/tools/wrap.js +1 -500
  589. package/package.json +7 -6
  590. package/dist/knowledge/arbitration-trust.d.ts +0 -24
  591. package/dist/knowledge/arbitration-trust.js +0 -117
  592. package/dist/schema/call/bridge-handler.d.ts +0 -8
  593. package/dist/schema/call/bridge-handler.js +0 -265
  594. package/dist/schema/sync-layer4.d.ts +0 -21
  595. package/dist/schema/sync-layer4.js +0 -286
  596. package/dist/schema-query/index.js +0 -810
  597. /package/dist/{schema-query → schema-query-impl}/index.d.ts +0 -0
@@ -1,445 +1 @@
1
- import { MAX_POLICY_COUNT, MAX_POLICY_DESCRIPTION_LEN, MAX_POLICY_GUARD_COUNT, MAX_DATA_SIZE, MAX_ID_COUNT_ONCE, MAX_REWARD_COUNT, } from "@wowok/wowok";
2
- export const SEMANTIC_TO_REPOSITORY_SCHEMA_RULES = [
3
- {
4
- id: "P-REP-01",
5
- pattern_name: "Clock-routed data (id=timestamp)",
6
- routing_mode: "clock",
7
- semantic_intent: "Data is keyed by current timestamp (id_from=Clock). Each write produces a unique timestamp-keyed entry. " +
8
- "Suitable for append-only logs, time-series records, and audit trails. write_guard may be empty (id is " +
9
- "auto-generated and predictable) or non-empty with data_from_submission set (guard supplies the data " +
10
- "payload while id comes from the clock — e.g. oracle-fed time-series).",
11
- match_keywords: ["timestamp", "log", "audit trail", "time-series", "append-only", "clock"],
12
- schema_elements: {
13
- id_from_value: 1,
14
- required_policy_fields: ["name", "description", "id_from", "value_type", "write_guard"],
15
- write_guard_requirement: "either",
16
- move_entry_point: "data_when_id_from_set",
17
- caller_input_shape: "{ name, data } — no id, no write_guard, no Passport",
18
- },
19
- constraints: [
20
- "id_from MUST be Clock (1)",
21
- "write_guard MAY be empty OR non-empty (R-D-1 refined)",
22
- "If write_guard is non-empty, every PolicyGuard.id_from_submission MUST be None (E_POLICY_ID_FROM_SUBMISSION_FORBIDDEN=23)",
23
- "data_from_submission MAY be set (used by data_when_id_from_set_with_passport)",
24
- "Caller uses data_when_id_from_set (no guard) or data_when_id_from_set_with_passport (with guard)",
25
- "ID is auto-generated from clock::timestamp_ms",
26
- ],
27
- example: {
28
- name: "audit_log",
29
- description: "Append-only audit log keyed by timestamp",
30
- id_from: "Clock",
31
- value_type: 0,
32
- write_guard: [],
33
- },
34
- },
35
- {
36
- id: "P-REP-02",
37
- pattern_name: "Signer-routed data (id=signer address)",
38
- routing_mode: "signer",
39
- semantic_intent: "Data is keyed by signer address (id_from=Signer). Each user has at most one data entry per policy. " +
40
- "Suitable for user profiles, KYC attestations, per-user settings. write_guard may be empty (signer " +
41
- "writes their own data) or non-empty with data_from_submission set (guard supplies the data payload " +
42
- "while id comes from the signer — e.g. verified credential insertion).",
43
- match_keywords: ["profile", "user data", "kyc", "per-user", "signer", "identity"],
44
- schema_elements: {
45
- id_from_value: 2,
46
- required_policy_fields: ["name", "description", "id_from", "value_type", "write_guard"],
47
- write_guard_requirement: "either",
48
- move_entry_point: "data_when_id_from_set",
49
- caller_input_shape: "{ name, data } — no id, no write_guard, no Passport",
50
- },
51
- constraints: [
52
- "id_from MUST be Signer (2)",
53
- "write_guard MAY be empty OR non-empty (R-D-1 refined)",
54
- "If write_guard is non-empty, every PolicyGuard.id_from_submission MUST be None (E_POLICY_ID_FROM_SUBMISSION_FORBIDDEN=23)",
55
- "data_from_submission MAY be set (used by data_when_id_from_set_with_passport)",
56
- "Caller uses data_when_id_from_set (no guard) or data_when_id_from_set_with_passport (with guard)",
57
- "ID is auto-generated from ctx.sender()",
58
- ],
59
- example: {
60
- name: "user_profile",
61
- description: "Per-user profile data keyed by signer address",
62
- id_from: "Signer",
63
- value_type: 0,
64
- write_guard: [],
65
- },
66
- },
67
- {
68
- id: "P-REP-03",
69
- pattern_name: "Guard-protected with caller-provided id (Mode 4)",
70
- routing_mode: "guard_caller",
71
- semantic_intent: "Data is keyed by caller-provided id (id_from=None). Write authorization requires a Passport submission " +
72
- "verifying the guard. Suitable for application-specific keys (order IDs, content hashes, custom identifiers). " +
73
- "The guard enforces WHO can write; the caller decides WHAT id to use.",
74
- match_keywords: ["custom id", "order id", "content hash", "application key", "guard protected", "passport"],
75
- schema_elements: {
76
- id_from_value: 0,
77
- required_policy_fields: ["name", "description", "id_from", "value_type", "write_guard"],
78
- write_guard_requirement: "non_empty",
79
- move_entry_point: "id_data_with_passport",
80
- caller_input_shape: "{ name, items: [{ id, data, write_guard }] } — id and data provided by caller, Passport verifies guard",
81
- },
82
- constraints: [
83
- "id_from MUST be None (0)",
84
- "write_guard MUST be non-empty (R-D-1: E_POLICY_WRITE_GUARD_REQUIRED=22)",
85
- "Each PolicyGuard MUST have id_from_submission=None AND data_from_submission=None",
86
- "Caller uses id_data_with_passport entry point",
87
- "Passport must verify one of the policy's write_guards",
88
- ],
89
- example: {
90
- name: "order_metadata",
91
- description: "Order-specific metadata keyed by order id, guard-protected",
92
- id_from: "None",
93
- value_type: 0,
94
- write_guard: [
95
- { guard: "0xguard_addr...", id_from_submission: null, data_from_submission: null },
96
- ],
97
- },
98
- },
99
- {
100
- id: "P-REP-04",
101
- pattern_name: "Guard-protected with submission-derived id/data (Mode 5)",
102
- routing_mode: "guard_submission",
103
- semantic_intent: "Data id and/or data payload are derived from Guard submission values in the Passport. This is the most " +
104
- "flexible mode: the guard can compute both the key and the value from its internal table. Suitable for " +
105
- "bridges (where the guard verifies an external event and outputs the bridged amount), oracle-fed data, " +
106
- "and complex authorization patterns.",
107
- match_keywords: ["oracle", "bridge", "submission", "guard derived", "computed id", "computed data"],
108
- schema_elements: {
109
- id_from_value: 0,
110
- required_policy_fields: ["name", "description", "id_from", "value_type", "write_guard"],
111
- write_guard_requirement: "non_empty",
112
- move_entry_point: "id_data_mixed_with_passport",
113
- caller_input_shape: "{ name, items: [{ write_guard, id?, data? }] } — id/data omitted where submission provides them",
114
- },
115
- constraints: [
116
- "id_from MUST be None (0)",
117
- "write_guard MUST be non-empty (R-D-1: E_POLICY_WRITE_GUARD_REQUIRED=22)",
118
- "Each PolicyGuard may have id_from_submission and/or data_from_submission set",
119
- "Caller uses id_data_mixed_with_passport entry point",
120
- "SDK hasSubmissionSettings must check BOTH id_from_submission AND data_from_submission (P1-1 fix)",
121
- "Passport must verify the specified write_guards",
122
- ],
123
- example: {
124
- name: "oracle_price",
125
- description: "Oracle-fed price data, id and data both from guard submission",
126
- id_from: "None",
127
- value_type: 0,
128
- write_guard: [
129
- {
130
- guard: "0xoracle_guard_addr...",
131
- id_from_submission: 0,
132
- data_from_submission: 1,
133
- },
134
- ],
135
- },
136
- },
137
- ];
138
- export const REPOSITORY_FIELD_TRANSLATIONS = [
139
- {
140
- field_name: "policies",
141
- value_type: "PolicyRule[]",
142
- semantic: "List of policy rules defining data write permissions and routing. Each policy is a named data slot " +
143
- "with its own write_guard list and id_from routing mode. Operations (data_add/data_remove) reference " +
144
- "policies by name.",
145
- format_example: "[{ name: 'audit_log', id_from: 'Clock', ... }]",
146
- validation_rules: [
147
- `Array length ≤ MAX_POLICY_COUNT (${MAX_POLICY_COUNT})`,
148
- "Each policy name must be unique within the Repository",
149
- "Move aborts with E_POLICY_COUNT_EXCEEDED (3) on overflow",
150
- "Move aborts with E_POLICY_NOT_FOUND (7) when name not found",
151
- ],
152
- },
153
- {
154
- field_name: "policies[].name",
155
- move_field: "PolicyRule.name",
156
- value_type: "string",
157
- semantic: "Policy name. Acts as the key for data_add/data_remove operations. Must be unique within the Repository. " +
158
- "Cannot be empty if NAME_ALLOW_EMPTY is not set.",
159
- format_example: "audit_log",
160
- validation_rules: [
161
- "Non-empty string (unless NAME_ALLOW_EMPTY)",
162
- "Must match an existing policy name in data_add/data_remove operations",
163
- ],
164
- },
165
- {
166
- field_name: "policies[].description",
167
- move_field: "PolicyRule.description",
168
- value_type: "string",
169
- semantic: "Human-readable description of what the policy is for. Helps with auditing and tooling.",
170
- format_example: "Append-only audit log keyed by timestamp",
171
- validation_rules: [
172
- `Length ≤ MAX_POLICY_DESCRIPTION_LEN (${MAX_POLICY_DESCRIPTION_LEN})`,
173
- "Move aborts with E_POLICY_DESCRIPTION_EXCEEDED (1)",
174
- ],
175
- },
176
- {
177
- field_name: "policies[].id_from",
178
- move_field: "PolicyRule.id_from",
179
- value_type: "u8 (number | 'None' | 'Clock' | 'Signer')",
180
- semantic: "Source of data ID when writing data. None (0): caller provides id; Clock (1): id=timestamp; " +
181
- "Signer (2): id=signer address. Determines which entry point to use for data operations. " +
182
- "SDK parseIdFrom normalizes string forms before comparison [P1-2 fix].",
183
- format_example: "0, 1, 2, 'None', 'Clock', 'Signer'",
184
- validation_rules: [
185
- "Must be one of: 0, 1, 2, 'None', 'Clock', 'Signer' (case-insensitive)",
186
- "Move aborts with E_INVALID_ID_FROM (18) for invalid u8 values",
187
- "R-D-1 (refined): None requires non-empty write_guard; Clock/Signer allows non-empty write_guard but every PolicyGuard.id_from_submission MUST be None (data_from_submission still allowed)",
188
- ],
189
- },
190
- {
191
- field_name: "policies[].write_guard",
192
- move_field: "PolicyRule.write_guard",
193
- value_type: "PolicyGuard[]",
194
- semantic: "List of Guard objects that must be verified (via Passport) to write data. Each PolicyGuard maps to a " +
195
- "Guard object and optionally specifies id_from_submission / data_from_submission for Mode 4/5 routing. " +
196
- "R-D-1 (refined): must be non-empty when id_from=None; when id_from=Clock/Signer, MAY be non-empty but " +
197
- "every PolicyGuard.id_from_submission MUST be None (data_from_submission is still allowed, enabling Mode 2b " +
198
- "where id is auto-generated from clock/signer while data comes from the guard submission).",
199
- format_example: "[{ guard: '0xaddr...', id_from_submission: 0, data_from_submission: 1 }]",
200
- validation_rules: [
201
- `Array length ≤ MAX_POLICY_GUARD_COUNT (${MAX_POLICY_GUARD_COUNT}) per policy`,
202
- "Move aborts with E_POLICY_GUARD_COUNT_EXCEEDED (2)",
203
- "R-D-1: E_POLICY_WRITE_GUARD_REQUIRED (22) if empty when id_from=None",
204
- "R-D-1: E_POLICY_ID_FROM_SUBMISSION_FORBIDDEN (23) if any PolicyGuard.id_from_submission is non-null when id_from=Clock/Signer (data_from_submission still allowed)",
205
- ],
206
- },
207
- {
208
- field_name: "policies[].write_guard[].id_from_submission",
209
- move_field: "PolicyGuard.id_from_submission",
210
- value_type: "Option<u8> (number | null)",
211
- semantic: "Guard table data index whose value is the ID of the data to be written. When set, the ID comes from " +
212
- "the Passport submission (Mode 5). When null, the caller must provide the ID (Mode 4). " +
213
- "R-D-1 (refined): MUST be null when policy id_from=Clock/Signer (id is auto-generated; setting this " +
214
- "would conflict with id_from routing). data_from_submission is still allowed in that case (Mode 2b).",
215
- format_example: "0, 1, 2, or null",
216
- validation_rules: [
217
- "Optional (null → caller provides id)",
218
- "Guard must have is_identifier_address_compatible(identifier)",
219
- "Move aborts with E_INVALID_ID_IN_GUARD_TABLE (16) if incompatible",
220
- "R-D-1: MUST be null when policy id_from=Clock/Signer (E_POLICY_ID_FROM_SUBMISSION_FORBIDDEN=23)",
221
- ],
222
- },
223
- {
224
- field_name: "policies[].write_guard[].data_from_submission",
225
- move_field: "PolicyGuard.data_from_submission",
226
- value_type: "Option<u8> (number | null)",
227
- semantic: "Guard table data index whose value is the data to be written. When set, the data comes from the " +
228
- "Passport submission (Mode 5). When null, the caller provides the data (Mode 4). " +
229
- "R-D-2: must be null for id_data_remove_with_passport (removal cannot consume submission data).",
230
- format_example: "0, 1, 2, or null",
231
- validation_rules: [
232
- "Optional (null → caller provides data)",
233
- "Guard must have has_identifier(identifier)",
234
- "Move aborts with E_INVALID_DATA_IN_GUARD_TABLE (17) if missing",
235
- "R-D-2: E_GUARD_SPECIFIED_ID_FROM_SUBMISSION (11) if set in id_data_remove_with_passport",
236
- ],
237
- },
238
- {
239
- field_name: "data_add / data_remove",
240
- value_type: "SignerOrClock | { name, items }",
241
- semantic: "Data operations. For Clock/Signer policies, use SignerOrClock form ({name, data} or {name}). " +
242
- "For None policies, use items form with id + write_guard per item. SDK hasSubmissionSettings helper " +
243
- "routes to the correct Move entry point based on PolicyGuard settings [P1-1 fix].",
244
- format_example: "{ name: 'audit_log', data: ... } or { name: 'order_meta', items: [{ id, data, write_guard }] }",
245
- validation_rules: [
246
- "Policy name must exist in Repository (E_POLICY_NOT_FOUND=7)",
247
- "write_guard must be in policy (E_GUARD_SPECIFIED_NOT_IN_POLICY=13)",
248
- "ID count ≤ MAX_ID_COUNT_ONCE per call",
249
- "Data size ≤ MAX_DATA_SIZE per value",
250
- ],
251
- },
252
- {
253
- field_name: "rewards",
254
- value_type: "{ op: 'add'|'set'|'remove'|'clear', objects: string[] }",
255
- semantic: "Reward objects referenced by this Repository. Rewards incentivize data contribution. When a writer " +
256
- "adds data, they may claim a reward (if the guard verifies eligibility).",
257
- format_example: "{ op: 'add', objects: ['0xreward1...', '0xreward2...'] }",
258
- validation_rules: [
259
- `Total reward count ≤ MAX_REWARD_COUNT (${MAX_REWARD_COUNT})`,
260
- "Move aborts with E_MAX_REWARD_COUNT_EXCEEDED (19)",
261
- "Reward objects must be properly configured (guard, amounts, recipients)",
262
- ],
263
- },
264
- ];
265
- export const REPOSITORY_CONSTRAINT_RULES = [
266
- {
267
- id: "REP_C_01",
268
- name: "policy count within limit",
269
- description: `Total policies in a Repository must be ≤ MAX_POLICY_COUNT (${MAX_POLICY_COUNT}).`,
270
- validation_logic: "existing_policies + new_policies <= MAX_POLICY_COUNT",
271
- failure_message: `Policy count exceeds MAX_POLICY_COUNT (${MAX_POLICY_COUNT}) — E_POLICY_COUNT_EXCEEDED (3)`,
272
- related_field: "policies",
273
- },
274
- {
275
- id: "REP_C_02",
276
- name: "write_guard required when id_from=None (R-D-1)",
277
- description: "When id_from is None, write_guard MUST be non-empty to prevent unauthorized writes.",
278
- validation_logic: "id_from == None => write_guard.length > 0",
279
- failure_message: "id_from=None requires non-empty write_guard — E_POLICY_WRITE_GUARD_REQUIRED (22)",
280
- related_field: "policies[].write_guard",
281
- },
282
- {
283
- id: "REP_C_03",
284
- name: "id_from_submission forbidden when id_from=Clock/Signer (R-D-1 refined)",
285
- description: "When id_from is Clock or Signer, every PolicyGuard.id_from_submission MUST be None (id is auto-generated; data_from_submission is still allowed).",
286
- validation_logic: "(id_from == Clock || id_from == Signer) => all write_guard[].id_from_submission == null",
287
- failure_message: "id_from=Clock/Signer requires id_from_submission=null on all guards — E_POLICY_ID_FROM_SUBMISSION_FORBIDDEN (23)",
288
- related_field: "policies[].write_guard[].id_from_submission",
289
- },
290
- {
291
- id: "REP_C_04",
292
- name: "policy guard count within limit",
293
- description: `Each policy write_guard list must be ≤ MAX_POLICY_GUARD_COUNT (${MAX_POLICY_GUARD_COUNT}).`,
294
- validation_logic: "policy.write_guard.length <= MAX_POLICY_GUARD_COUNT",
295
- failure_message: `Policy guard count exceeds MAX_POLICY_GUARD_COUNT (${MAX_POLICY_GUARD_COUNT}) — E_POLICY_GUARD_COUNT_EXCEEDED (2)`,
296
- related_field: "policies[].write_guard",
297
- },
298
- {
299
- id: "REP_C_05",
300
- name: "data size within limit",
301
- description: `Each data value must be ≤ MAX_DATA_SIZE (${MAX_DATA_SIZE}) bytes.`,
302
- validation_logic: "data.length <= MAX_DATA_SIZE",
303
- failure_message: `Data value exceeds MAX_DATA_SIZE (${MAX_DATA_SIZE} bytes) — E_DATA_EXCEEDED (4)`,
304
- related_field: "data_add.data",
305
- },
306
- {
307
- id: "REP_C_06",
308
- name: "id count per op within limit",
309
- description: `A single Repository call may operate on at most MAX_ID_COUNT_ONCE (${MAX_ID_COUNT_ONCE}) IDs.`,
310
- validation_logic: "id_count <= MAX_ID_COUNT_ONCE",
311
- failure_message: `ID count exceeds MAX_ID_COUNT_ONCE (${MAX_ID_COUNT_ONCE}) — E_ID_COUNT_EXCEEDED (5)`,
312
- related_field: "data_add.items[].id / data_remove.items[].id",
313
- },
314
- {
315
- id: "REP_C_07",
316
- name: "data_from_submission null in id_data_remove_with_passport (R-D-2)",
317
- description: "id_data_remove_with_passport only removes data by caller id; it cannot consume Passport submissions. " +
318
- "Both id_from_submission AND data_from_submission must be None.",
319
- validation_logic: "is_data_remove_with_passport => !has_id_from_submission && !has_data_from_submission",
320
- failure_message: "id_data_remove_with_passport cannot have id_from_submission or data_from_submission — E_GUARD_SPECIFIED_ID_FROM_SUBMISSION (11)",
321
- related_field: "policies[].write_guard[].data_from_submission",
322
- },
323
- {
324
- id: "REP_C_08",
325
- name: "hasSubmissionSettings checks both submission fields (P1-1)",
326
- description: "SDK hasSubmissionSettings helper must check BOTH id_from_submission AND data_from_submission to " +
327
- "correctly route Mode 5 (id_data_mixed_with_passport).",
328
- validation_logic: "hasSubmissionSettings = (id_from_submission != null) || (data_from_submission != null)",
329
- failure_message: "Mode 5 routing missed if only id_from_submission is checked (P1-1 fix)",
330
- related_field: "policies[].write_guard",
331
- },
332
- {
333
- id: "REP_C_09",
334
- name: "quote_guard must be is_depended (immutable + rep=true + no relies)",
335
- description: "When quote_guard is set on a policy, it MUST satisfy guard::is_depended (guard.move#L133-135): " +
336
- "immutable=true, relies empty, rep=true. Move aborts with E_NEED_DEPENDENT_GUARD (repository.move#L422). " +
337
- "VERIFIED: passport.rs#L545-612 — check_repository_quote_guard enforces this when any guard queries " +
338
- "this Repository's data (query 1167). quote_guard is a RIGID verification requirement.",
339
- validation_logic: "quote_guard != null => guard.is_depended (immutable && relies.empty && rep)",
340
- failure_message: "quote_guard must be is_depended — E_NEED_DEPENDENT_GUARD (repository.move#L422)",
341
- related_field: "policies[].quote_guard",
342
- },
343
- {
344
- id: "REP_C_10",
345
- name: "quote_guard data subscription design (Payment verification + owner_receive)",
346
- description: "For data subscription pattern: (1) quote_guard should verify Payment (for_object matches Repository, " +
347
- "amount meets subscription price); (2) Repository should have owner_receive<T> configured to accept " +
348
- "Payment as subscription revenue (repository.move#L714-717). " +
349
- "DESIGN: user submits Payment via Passport → quote_guard verifies → impack_list updated → repository " +
350
- "data query passes. 'On-chain data is consumed by guard verifiers.'",
351
- validation_logic: "quote_guard != null => quote_guard_verifies_payment && repository_has_owner_receive",
352
- failure_message: "quote_guard subscription incomplete: missing Payment verification or owner_receive revenue",
353
- related_field: "policies[].quote_guard",
354
- },
355
- ];
356
- function normalizeIdFrom(v) {
357
- if (typeof v === "number")
358
- return v;
359
- const lower = String(v).toLowerCase();
360
- if (lower === "none")
361
- return 0;
362
- if (lower === "clock")
363
- return 1;
364
- if (lower === "signer")
365
- return 2;
366
- const parsed = Number(v);
367
- return Number.isNaN(parsed) ? -1 : parsed;
368
- }
369
- export function explainRepository(input) {
370
- const warnings = [];
371
- const recommendations = [];
372
- const routingModes = [];
373
- let rD1Violations = 0;
374
- let rD2Violations = 0;
375
- let p11Correct = true;
376
- let p12Recognized = true;
377
- if (input.policies) {
378
- for (const p of input.policies) {
379
- const idFrom = normalizeIdFrom(p.id_from);
380
- if (idFrom < 0 || idFrom > 2) {
381
- p12Recognized = false;
382
- warnings.push(`Policy "${p.name}": id_from="${p.id_from}" not recognized (P1-2 parseIdFrom)`);
383
- }
384
- if (idFrom === 0 && p.write_guard_count === 0) {
385
- rD1Violations++;
386
- warnings.push(`Policy "${p.name}": id_from=None + empty write_guard violates R-D-1 (E_POLICY_WRITE_GUARD_REQUIRED=22)`);
387
- }
388
- if ((idFrom === 1 || idFrom === 2) && p.has_id_from_submission) {
389
- rD1Violations++;
390
- warnings.push(`Policy "${p.name}": id_from=Clock/Signer + id_from_submission set violates R-D-1 (E_POLICY_ID_FROM_SUBMISSION_FORBIDDEN=23)`);
391
- }
392
- if (input.is_data_remove_with_passport && p.has_data_from_submission) {
393
- rD2Violations++;
394
- warnings.push(`Policy "${p.name}": data_from_submission set but used in id_data_remove_with_passport violates R-D-2`);
395
- }
396
- if (idFrom === 0 && (p.has_id_from_submission || p.has_data_from_submission)) {
397
- if (p.has_data_from_submission && !p.has_id_from_submission) {
398
- routingModes.push(`${p.name}: Mode 5 (data_from_submission only) — SDK hasSubmissionSettings correctly detects [P1-1]`);
399
- }
400
- else {
401
- routingModes.push(`${p.name}: Mode 5 (id_data_mixed_with_passport)`);
402
- }
403
- }
404
- else if (idFrom === 0 && p.write_guard_count > 0) {
405
- routingModes.push(`${p.name}: Mode 4 (Guard + caller id, id_data_with_passport)`);
406
- }
407
- else if ((idFrom === 1 || idFrom === 2) && p.write_guard_count > 0) {
408
- routingModes.push(`${p.name}: Mode 2b (auto-id + guard, data_when_id_from_set_with_passport)`);
409
- }
410
- else if (idFrom === 1) {
411
- routingModes.push(`${p.name}: Mode 1 (Clock-routed, data_when_id_from_set)`);
412
- }
413
- else if (idFrom === 2) {
414
- routingModes.push(`${p.name}: Mode 2 (Signer-routed, data_when_id_from_set)`);
415
- }
416
- else {
417
- routingModes.push(`${p.name}: unknown/invalid routing`);
418
- }
419
- }
420
- }
421
- if (rD1Violations > 0)
422
- recommendations.push("Fix R-D-1 violations: align write_guard presence with id_from");
423
- if (rD2Violations > 0)
424
- recommendations.push("Fix R-D-2 violations: remove data_from_submission for id_data_remove_with_passport");
425
- if (!p12Recognized)
426
- recommendations.push("Use recognized id_from values: 0/1/2 or 'None'/'Clock'/'Signer'");
427
- if (routingModes.length === 0)
428
- recommendations.push("Define at least one policy to enable data operations");
429
- const rD1Status = rD1Violations === 0 ? "PASS (all policies satisfy R-D-1)" : `FAIL (${rD1Violations} violation(s))`;
430
- const rD2Status = rD2Violations === 0 ? "PASS (no R-D-2 violations)" : `FAIL (${rD2Violations} violation(s))`;
431
- const p11Status = p11Correct ? "PASS (hasSubmissionSettings checks both fields)" : "FAIL";
432
- const p12Status = p12Recognized ? "PASS (all id_from values recognized)" : "FAIL (unrecognized id_from values)";
433
- const summary = `Repository has ${input.policies?.length ?? 0} policy(ies). ` +
434
- `R-D-1: ${rD1Status}. R-D-2: ${rD2Status}. P1-1: ${p11Status}. P1-2: ${p12Status}.`;
435
- return {
436
- summary,
437
- routing_modes: routingModes,
438
- r_d_1_status: rD1Status,
439
- r_d_2_status: rD2Status,
440
- p1_1_status: p11Status,
441
- p1_2_status: p12Status,
442
- warnings,
443
- recommendations,
444
- };
445
- }
1
+ import{MAX_POLICY_COUNT,MAX_POLICY_DESCRIPTION_LEN,MAX_POLICY_GUARD_COUNT,MAX_DATA_SIZE,MAX_ID_COUNT_ONCE,MAX_REWARD_COUNT}from'@wowok/wowok';export const SEMANTIC_TO_REPOSITORY_SCHEMA_RULES=[{'id':'P-REP-01','pattern_name':'Clock-routed\x20data\x20(id=timestamp)','routing_mode':'clock','semantic_intent':'Data\x20is\x20keyed\x20by\x20current\x20timestamp\x20(id_from=Clock).\x20Each\x20write\x20produces\x20a\x20unique\x20timestamp-keyed\x20entry.\x20'+'Suitable\x20for\x20append-only\x20logs,\x20time-series\x20records,\x20and\x20audit\x20trails.\x20write_guard\x20may\x20be\x20empty\x20(id\x20is\x20'+'auto-generated\x20and\x20predictable)\x20or\x20non-empty\x20with\x20data_from_submission\x20set\x20(guard\x20supplies\x20the\x20data\x20'+'payload\x20while\x20id\x20comes\x20from\x20the\x20clock\x20—\x20e.g.\x20oracle-fed\x20time-series).','match_keywords':['timestamp','log','audit\x20trail','time-series','append-only','clock'],'schema_elements':{'id_from_value':0x1,'required_policy_fields':['name','description','id_from','value_type','write_guard'],'write_guard_requirement':'either','move_entry_point':'data_when_id_from_set','caller_input_shape':'{\x20name,\x20data\x20}\x20—\x20no\x20id,\x20no\x20write_guard,\x20no\x20Passport'},'constraints':['id_from\x20MUST\x20be\x20Clock\x20(1)','write_guard\x20MAY\x20be\x20empty\x20OR\x20non-empty\x20(R-D-1\x20refined)','If\x20write_guard\x20is\x20non-empty,\x20every\x20PolicyGuard.id_from_submission\x20MUST\x20be\x20None\x20(E_POLICY_ID_FROM_SUBMISSION_FORBIDDEN=23)','data_from_submission\x20MAY\x20be\x20set\x20(used\x20by\x20data_when_id_from_set_with_passport)','Caller\x20uses\x20data_when_id_from_set\x20(no\x20guard)\x20or\x20data_when_id_from_set_with_passport\x20(with\x20guard)','ID\x20is\x20auto-generated\x20from\x20clock::timestamp_ms'],'example':{'name':'audit_log','description':'Append-only\x20audit\x20log\x20keyed\x20by\x20timestamp','id_from':'Clock','value_type':0x0,'write_guard':[]}},{'id':'P-REP-02','pattern_name':'Signer-routed\x20data\x20(id=signer\x20address)','routing_mode':'signer','semantic_intent':'Data\x20is\x20keyed\x20by\x20signer\x20address\x20(id_from=Signer).\x20Each\x20user\x20has\x20at\x20most\x20one\x20data\x20entry\x20per\x20policy.\x20'+'Suitable\x20for\x20user\x20profiles,\x20KYC\x20attestations,\x20per-user\x20settings.\x20write_guard\x20may\x20be\x20empty\x20(signer\x20'+'writes\x20their\x20own\x20data)\x20or\x20non-empty\x20with\x20data_from_submission\x20set\x20(guard\x20supplies\x20the\x20data\x20payload\x20'+'while\x20id\x20comes\x20from\x20the\x20signer\x20—\x20e.g.\x20verified\x20credential\x20insertion).','match_keywords':['profile','user\x20data','kyc','per-user','signer','identity'],'schema_elements':{'id_from_value':0x2,'required_policy_fields':['name','description','id_from','value_type','write_guard'],'write_guard_requirement':'either','move_entry_point':'data_when_id_from_set','caller_input_shape':'{\x20name,\x20data\x20}\x20—\x20no\x20id,\x20no\x20write_guard,\x20no\x20Passport'},'constraints':['id_from\x20MUST\x20be\x20Signer\x20(2)','write_guard\x20MAY\x20be\x20empty\x20OR\x20non-empty\x20(R-D-1\x20refined)','If\x20write_guard\x20is\x20non-empty,\x20every\x20PolicyGuard.id_from_submission\x20MUST\x20be\x20None\x20(E_POLICY_ID_FROM_SUBMISSION_FORBIDDEN=23)','data_from_submission\x20MAY\x20be\x20set\x20(used\x20by\x20data_when_id_from_set_with_passport)','Caller\x20uses\x20data_when_id_from_set\x20(no\x20guard)\x20or\x20data_when_id_from_set_with_passport\x20(with\x20guard)','ID\x20is\x20auto-generated\x20from\x20ctx.sender()'],'example':{'name':'user_profile','description':'Per-user\x20profile\x20data\x20keyed\x20by\x20signer\x20address','id_from':'Signer','value_type':0x0,'write_guard':[]}},{'id':'P-REP-03','pattern_name':'Guard-protected\x20with\x20caller-provided\x20id\x20(Mode\x204)','routing_mode':'guard_caller','semantic_intent':'Data\x20is\x20keyed\x20by\x20caller-provided\x20id\x20(id_from=None).\x20Write\x20authorization\x20requires\x20a\x20Passport\x20submission\x20'+'verifying\x20the\x20guard.\x20Suitable\x20for\x20application-specific\x20keys\x20(order\x20IDs,\x20content\x20hashes,\x20custom\x20identifiers).\x20'+'The\x20guard\x20enforces\x20WHO\x20can\x20write;\x20the\x20caller\x20decides\x20WHAT\x20id\x20to\x20use.','match_keywords':['custom\x20id','order\x20id','content\x20hash','application\x20key','guard\x20protected','passport'],'schema_elements':{'id_from_value':0x0,'required_policy_fields':['name','description','id_from','value_type','write_guard'],'write_guard_requirement':'non_empty','move_entry_point':'id_data_with_passport','caller_input_shape':'{\x20name,\x20items:\x20[{\x20id,\x20data,\x20write_guard\x20}]\x20}\x20—\x20id\x20and\x20data\x20provided\x20by\x20caller,\x20Passport\x20verifies\x20guard'},'constraints':['id_from\x20MUST\x20be\x20None\x20(0)','write_guard\x20MUST\x20be\x20non-empty\x20(R-D-1:\x20E_POLICY_WRITE_GUARD_REQUIRED=22)','Each\x20PolicyGuard\x20MUST\x20have\x20id_from_submission=None\x20AND\x20data_from_submission=None','Caller\x20uses\x20id_data_with_passport\x20entry\x20point','Passport\x20must\x20verify\x20one\x20of\x20the\x20policy\x27s\x20write_guards'],'example':{'name':'order_metadata','description':'Order-specific\x20metadata\x20keyed\x20by\x20order\x20id,\x20guard-protected','id_from':'None','value_type':0x0,'write_guard':[{'guard':'0xguard_addr...','id_from_submission':null,'data_from_submission':null}]}},{'id':'P-REP-04','pattern_name':'Guard-protected\x20with\x20submission-derived\x20id/data\x20(Mode\x205)','routing_mode':'guard_submission','semantic_intent':'Data\x20id\x20and/or\x20data\x20payload\x20are\x20derived\x20from\x20Guard\x20submission\x20values\x20in\x20the\x20Passport.\x20This\x20is\x20the\x20most\x20'+'flexible\x20mode:\x20the\x20guard\x20can\x20compute\x20both\x20the\x20key\x20and\x20the\x20value\x20from\x20its\x20internal\x20table.\x20Suitable\x20for\x20'+'bridges\x20(where\x20the\x20guard\x20verifies\x20an\x20external\x20event\x20and\x20outputs\x20the\x20bridged\x20amount),\x20oracle-fed\x20data,\x20'+'and\x20complex\x20authorization\x20patterns.','match_keywords':['oracle','bridge','submission','guard\x20derived','computed\x20id','computed\x20data'],'schema_elements':{'id_from_value':0x0,'required_policy_fields':['name','description','id_from','value_type','write_guard'],'write_guard_requirement':'non_empty','move_entry_point':'id_data_mixed_with_passport','caller_input_shape':'{\x20name,\x20items:\x20[{\x20write_guard,\x20id?,\x20data?\x20}]\x20}\x20—\x20id/data\x20omitted\x20where\x20submission\x20provides\x20them'},'constraints':['id_from\x20MUST\x20be\x20None\x20(0)','write_guard\x20MUST\x20be\x20non-empty\x20(R-D-1:\x20E_POLICY_WRITE_GUARD_REQUIRED=22)','Each\x20PolicyGuard\x20may\x20have\x20id_from_submission\x20and/or\x20data_from_submission\x20set','Caller\x20uses\x20id_data_mixed_with_passport\x20entry\x20point','SDK\x20hasSubmissionSettings\x20must\x20check\x20BOTH\x20id_from_submission\x20AND\x20data_from_submission\x20(P1-1\x20fix)','Passport\x20must\x20verify\x20the\x20specified\x20write_guards'],'example':{'name':'oracle_price','description':'Oracle-fed\x20price\x20data,\x20id\x20and\x20data\x20both\x20from\x20guard\x20submission','id_from':'None','value_type':0x0,'write_guard':[{'guard':'0xoracle_guard_addr...','id_from_submission':0x0,'data_from_submission':0x1}]}}];export const REPOSITORY_FIELD_TRANSLATIONS=[{'field_name':'policies','value_type':'PolicyRule[]','semantic':'List\x20of\x20policy\x20rules\x20defining\x20data\x20write\x20permissions\x20and\x20routing.\x20Each\x20policy\x20is\x20a\x20named\x20data\x20slot\x20'+'with\x20its\x20own\x20write_guard\x20list\x20and\x20id_from\x20routing\x20mode.\x20Operations\x20(data_add/data_remove)\x20reference\x20'+'policies\x20by\x20name.','format_example':'[{\x20name:\x20\x27audit_log\x27,\x20id_from:\x20\x27Clock\x27,\x20...\x20}]','validation_rules':['Array\x20length\x20≤\x20MAX_POLICY_COUNT\x20('+MAX_POLICY_COUNT+')','Each\x20policy\x20name\x20must\x20be\x20unique\x20within\x20the\x20Repository','Move\x20aborts\x20with\x20E_POLICY_COUNT_EXCEEDED\x20(3)\x20on\x20overflow','Move\x20aborts\x20with\x20E_POLICY_NOT_FOUND\x20(7)\x20when\x20name\x20not\x20found']},{'field_name':'policies[].name','move_field':'PolicyRule.name','value_type':'string','semantic':'Policy\x20name.\x20Acts\x20as\x20the\x20key\x20for\x20data_add/data_remove\x20operations.\x20Must\x20be\x20unique\x20within\x20the\x20Repository.\x20'+'Cannot\x20be\x20empty\x20if\x20NAME_ALLOW_EMPTY\x20is\x20not\x20set.','format_example':'audit_log','validation_rules':['Non-empty\x20string\x20(unless\x20NAME_ALLOW_EMPTY)','Must\x20match\x20an\x20existing\x20policy\x20name\x20in\x20data_add/data_remove\x20operations']},{'field_name':'policies[].description','move_field':'PolicyRule.description','value_type':'string','semantic':'Human-readable\x20description\x20of\x20what\x20the\x20policy\x20is\x20for.\x20Helps\x20with\x20auditing\x20and\x20tooling.','format_example':'Append-only\x20audit\x20log\x20keyed\x20by\x20timestamp','validation_rules':['Length\x20≤\x20MAX_POLICY_DESCRIPTION_LEN\x20('+MAX_POLICY_DESCRIPTION_LEN+')','Move\x20aborts\x20with\x20E_POLICY_DESCRIPTION_EXCEEDED\x20(1)']},{'field_name':'policies[].id_from','move_field':'PolicyRule.id_from','value_type':'u8\x20(number\x20|\x20\x27None\x27\x20|\x20\x27Clock\x27\x20|\x20\x27Signer\x27)','semantic':'Source\x20of\x20data\x20ID\x20when\x20writing\x20data.\x20None\x20(0):\x20caller\x20provides\x20id;\x20Clock\x20(1):\x20id=timestamp;\x20'+'Signer\x20(2):\x20id=signer\x20address.\x20Determines\x20which\x20entry\x20point\x20to\x20use\x20for\x20data\x20operations.\x20'+'SDK\x20parseIdFrom\x20normalizes\x20string\x20forms\x20before\x20comparison\x20[P1-2\x20fix].','format_example':'0,\x201,\x202,\x20\x27None\x27,\x20\x27Clock\x27,\x20\x27Signer\x27','validation_rules':['Must\x20be\x20one\x20of:\x200,\x201,\x202,\x20\x27None\x27,\x20\x27Clock\x27,\x20\x27Signer\x27\x20(case-insensitive)','Move\x20aborts\x20with\x20E_INVALID_ID_FROM\x20(18)\x20for\x20invalid\x20u8\x20values','R-D-1\x20(refined):\x20None\x20requires\x20non-empty\x20write_guard;\x20Clock/Signer\x20allows\x20non-empty\x20write_guard\x20but\x20every\x20PolicyGuard.id_from_submission\x20MUST\x20be\x20None\x20(data_from_submission\x20still\x20allowed)']},{'field_name':'policies[].write_guard','move_field':'PolicyRule.write_guard','value_type':'PolicyGuard[]','semantic':'List\x20of\x20Guard\x20objects\x20that\x20must\x20be\x20verified\x20(via\x20Passport)\x20to\x20write\x20data.\x20Each\x20PolicyGuard\x20maps\x20to\x20a\x20'+'Guard\x20object\x20and\x20optionally\x20specifies\x20id_from_submission\x20/\x20data_from_submission\x20for\x20Mode\x204/5\x20routing.\x20'+'R-D-1\x20(refined):\x20must\x20be\x20non-empty\x20when\x20id_from=None;\x20when\x20id_from=Clock/Signer,\x20MAY\x20be\x20non-empty\x20but\x20'+'every\x20PolicyGuard.id_from_submission\x20MUST\x20be\x20None\x20(data_from_submission\x20is\x20still\x20allowed,\x20enabling\x20Mode\x202b\x20'+'where\x20id\x20is\x20auto-generated\x20from\x20clock/signer\x20while\x20data\x20comes\x20from\x20the\x20guard\x20submission).','format_example':'[{\x20guard:\x20\x270xaddr...\x27,\x20id_from_submission:\x200,\x20data_from_submission:\x201\x20}]','validation_rules':['Array\x20length\x20≤\x20MAX_POLICY_GUARD_COUNT\x20('+MAX_POLICY_GUARD_COUNT+')\x20per\x20policy','Move\x20aborts\x20with\x20E_POLICY_GUARD_COUNT_EXCEEDED\x20(2)','R-D-1:\x20E_POLICY_WRITE_GUARD_REQUIRED\x20(22)\x20if\x20empty\x20when\x20id_from=None','R-D-1:\x20E_POLICY_ID_FROM_SUBMISSION_FORBIDDEN\x20(23)\x20if\x20any\x20PolicyGuard.id_from_submission\x20is\x20non-null\x20when\x20id_from=Clock/Signer\x20(data_from_submission\x20still\x20allowed)']},{'field_name':'policies[].write_guard[].id_from_submission','move_field':'PolicyGuard.id_from_submission','value_type':'Option<u8>\x20(number\x20|\x20null)','semantic':'Guard\x20table\x20data\x20index\x20whose\x20value\x20is\x20the\x20ID\x20of\x20the\x20data\x20to\x20be\x20written.\x20When\x20set,\x20the\x20ID\x20comes\x20from\x20'+'the\x20Passport\x20submission\x20(Mode\x205).\x20When\x20null,\x20the\x20caller\x20must\x20provide\x20the\x20ID\x20(Mode\x204).\x20'+'R-D-1\x20(refined):\x20MUST\x20be\x20null\x20when\x20policy\x20id_from=Clock/Signer\x20(id\x20is\x20auto-generated;\x20setting\x20this\x20'+'would\x20conflict\x20with\x20id_from\x20routing).\x20data_from_submission\x20is\x20still\x20allowed\x20in\x20that\x20case\x20(Mode\x202b).','format_example':'0,\x201,\x202,\x20or\x20null','validation_rules':['Optional\x20(null\x20→\x20caller\x20provides\x20id)','Guard\x20must\x20have\x20is_identifier_address_compatible(identifier)','Move\x20aborts\x20with\x20E_INVALID_ID_IN_GUARD_TABLE\x20(16)\x20if\x20incompatible','R-D-1:\x20MUST\x20be\x20null\x20when\x20policy\x20id_from=Clock/Signer\x20(E_POLICY_ID_FROM_SUBMISSION_FORBIDDEN=23)']},{'field_name':'policies[].write_guard[].data_from_submission','move_field':'PolicyGuard.data_from_submission','value_type':'Option<u8>\x20(number\x20|\x20null)','semantic':'Guard\x20table\x20data\x20index\x20whose\x20value\x20is\x20the\x20data\x20to\x20be\x20written.\x20When\x20set,\x20the\x20data\x20comes\x20from\x20the\x20'+'Passport\x20submission\x20(Mode\x205).\x20When\x20null,\x20the\x20caller\x20provides\x20the\x20data\x20(Mode\x204).\x20'+'R-D-2:\x20must\x20be\x20null\x20for\x20id_data_remove_with_passport\x20(removal\x20cannot\x20consume\x20submission\x20data).','format_example':'0,\x201,\x202,\x20or\x20null','validation_rules':['Optional\x20(null\x20→\x20caller\x20provides\x20data)','Guard\x20must\x20have\x20has_identifier(identifier)','Move\x20aborts\x20with\x20E_INVALID_DATA_IN_GUARD_TABLE\x20(17)\x20if\x20missing','R-D-2:\x20E_GUARD_SPECIFIED_ID_FROM_SUBMISSION\x20(11)\x20if\x20set\x20in\x20id_data_remove_with_passport']},{'field_name':'data_add\x20/\x20data_remove','value_type':'SignerOrClock\x20|\x20{\x20name,\x20items\x20}','semantic':'Data\x20operations.\x20For\x20Clock/Signer\x20policies,\x20use\x20SignerOrClock\x20form\x20({name,\x20data}\x20or\x20{name}).\x20'+'For\x20None\x20policies,\x20use\x20items\x20form\x20with\x20id\x20+\x20write_guard\x20per\x20item.\x20SDK\x20hasSubmissionSettings\x20helper\x20'+'routes\x20to\x20the\x20correct\x20Move\x20entry\x20point\x20based\x20on\x20PolicyGuard\x20settings\x20[P1-1\x20fix].','format_example':'{\x20name:\x20\x27audit_log\x27,\x20data:\x20...\x20}\x20or\x20{\x20name:\x20\x27order_meta\x27,\x20items:\x20[{\x20id,\x20data,\x20write_guard\x20}]\x20}','validation_rules':['Policy\x20name\x20must\x20exist\x20in\x20Repository\x20(E_POLICY_NOT_FOUND=7)','write_guard\x20must\x20be\x20in\x20policy\x20(E_GUARD_SPECIFIED_NOT_IN_POLICY=13)','ID\x20count\x20≤\x20MAX_ID_COUNT_ONCE\x20per\x20call','Data\x20size\x20≤\x20MAX_DATA_SIZE\x20per\x20value']},{'field_name':'rewards','value_type':'{\x20op:\x20\x27add\x27|\x27set\x27|\x27remove\x27|\x27clear\x27,\x20objects:\x20string[]\x20}','semantic':'Reward\x20objects\x20referenced\x20by\x20this\x20Repository.\x20Rewards\x20incentivize\x20data\x20contribution.\x20When\x20a\x20writer\x20'+'adds\x20data,\x20they\x20may\x20claim\x20a\x20reward\x20(if\x20the\x20guard\x20verifies\x20eligibility).','format_example':'{\x20op:\x20\x27add\x27,\x20objects:\x20[\x270xreward1...\x27,\x20\x270xreward2...\x27]\x20}','validation_rules':['Total\x20reward\x20count\x20≤\x20MAX_REWARD_COUNT\x20('+MAX_REWARD_COUNT+')','Move\x20aborts\x20with\x20E_MAX_REWARD_COUNT_EXCEEDED\x20(19)','Reward\x20objects\x20must\x20be\x20properly\x20configured\x20(guard,\x20amounts,\x20recipients)']}];export const REPOSITORY_CONSTRAINT_RULES=[{'id':'REP_C_01','name':'policy\x20count\x20within\x20limit','description':'Total\x20policies\x20in\x20a\x20Repository\x20must\x20be\x20≤\x20MAX_POLICY_COUNT\x20('+MAX_POLICY_COUNT+').','validation_logic':'existing_policies\x20+\x20new_policies\x20<=\x20MAX_POLICY_COUNT','failure_message':'Policy\x20count\x20exceeds\x20MAX_POLICY_COUNT\x20('+MAX_POLICY_COUNT+')\x20—\x20E_POLICY_COUNT_EXCEEDED\x20(3)','related_field':'policies'},{'id':'REP_C_02','name':'write_guard\x20required\x20when\x20id_from=None\x20(R-D-1)','description':'When\x20id_from\x20is\x20None,\x20write_guard\x20MUST\x20be\x20non-empty\x20to\x20prevent\x20unauthorized\x20writes.','validation_logic':'id_from\x20==\x20None\x20=>\x20write_guard.length\x20>\x200','failure_message':'id_from=None\x20requires\x20non-empty\x20write_guard\x20—\x20E_POLICY_WRITE_GUARD_REQUIRED\x20(22)','related_field':'policies[].write_guard'},{'id':'REP_C_03','name':'id_from_submission\x20forbidden\x20when\x20id_from=Clock/Signer\x20(R-D-1\x20refined)','description':'When\x20id_from\x20is\x20Clock\x20or\x20Signer,\x20every\x20PolicyGuard.id_from_submission\x20MUST\x20be\x20None\x20(id\x20is\x20auto-generated;\x20data_from_submission\x20is\x20still\x20allowed).','validation_logic':'(id_from\x20==\x20Clock\x20||\x20id_from\x20==\x20Signer)\x20=>\x20all\x20write_guard[].id_from_submission\x20==\x20null','failure_message':'id_from=Clock/Signer\x20requires\x20id_from_submission=null\x20on\x20all\x20guards\x20—\x20E_POLICY_ID_FROM_SUBMISSION_FORBIDDEN\x20(23)','related_field':'policies[].write_guard[].id_from_submission'},{'id':'REP_C_04','name':'policy\x20guard\x20count\x20within\x20limit','description':'Each\x20policy\x20write_guard\x20list\x20must\x20be\x20≤\x20MAX_POLICY_GUARD_COUNT\x20('+MAX_POLICY_GUARD_COUNT+').','validation_logic':'policy.write_guard.length\x20<=\x20MAX_POLICY_GUARD_COUNT','failure_message':'Policy\x20guard\x20count\x20exceeds\x20MAX_POLICY_GUARD_COUNT\x20('+MAX_POLICY_GUARD_COUNT+')\x20—\x20E_POLICY_GUARD_COUNT_EXCEEDED\x20(2)','related_field':'policies[].write_guard'},{'id':'REP_C_05','name':'data\x20size\x20within\x20limit','description':'Each\x20data\x20value\x20must\x20be\x20≤\x20MAX_DATA_SIZE\x20('+MAX_DATA_SIZE+')\x20bytes.','validation_logic':'data.length\x20<=\x20MAX_DATA_SIZE','failure_message':'Data\x20value\x20exceeds\x20MAX_DATA_SIZE\x20('+MAX_DATA_SIZE+'\x20bytes)\x20—\x20E_DATA_EXCEEDED\x20(4)','related_field':'data_add.data'},{'id':'REP_C_06','name':'id\x20count\x20per\x20op\x20within\x20limit','description':'A\x20single\x20Repository\x20call\x20may\x20operate\x20on\x20at\x20most\x20MAX_ID_COUNT_ONCE\x20('+MAX_ID_COUNT_ONCE+')\x20IDs.','validation_logic':'id_count\x20<=\x20MAX_ID_COUNT_ONCE','failure_message':'ID\x20count\x20exceeds\x20MAX_ID_COUNT_ONCE\x20('+MAX_ID_COUNT_ONCE+')\x20—\x20E_ID_COUNT_EXCEEDED\x20(5)','related_field':'data_add.items[].id\x20/\x20data_remove.items[].id'},{'id':'REP_C_07','name':'data_from_submission\x20null\x20in\x20id_data_remove_with_passport\x20(R-D-2)','description':'id_data_remove_with_passport\x20only\x20removes\x20data\x20by\x20caller\x20id;\x20it\x20cannot\x20consume\x20Passport\x20submissions.\x20'+'Both\x20id_from_submission\x20AND\x20data_from_submission\x20must\x20be\x20None.','validation_logic':'is_data_remove_with_passport\x20=>\x20!has_id_from_submission\x20&&\x20!has_data_from_submission','failure_message':'id_data_remove_with_passport\x20cannot\x20have\x20id_from_submission\x20or\x20data_from_submission\x20—\x20E_GUARD_SPECIFIED_ID_FROM_SUBMISSION\x20(11)','related_field':'policies[].write_guard[].data_from_submission'},{'id':'REP_C_08','name':'hasSubmissionSettings\x20checks\x20both\x20submission\x20fields\x20(P1-1)','description':'SDK\x20hasSubmissionSettings\x20helper\x20must\x20check\x20BOTH\x20id_from_submission\x20AND\x20data_from_submission\x20to\x20'+'correctly\x20route\x20Mode\x205\x20(id_data_mixed_with_passport).','validation_logic':'hasSubmissionSettings\x20=\x20(id_from_submission\x20!=\x20null)\x20||\x20(data_from_submission\x20!=\x20null)','failure_message':'Mode\x205\x20routing\x20missed\x20if\x20only\x20id_from_submission\x20is\x20checked\x20(P1-1\x20fix)','related_field':'policies[].write_guard'},{'id':'REP_C_09','name':'quote_guard\x20must\x20be\x20is_depended\x20(immutable\x20+\x20rep=true\x20+\x20no\x20relies)','description':'When\x20quote_guard\x20is\x20set\x20on\x20a\x20policy,\x20it\x20MUST\x20satisfy\x20guard::is_depended\x20(guard.move#L133-135):\x20'+'immutable=true,\x20relies\x20empty,\x20rep=true.\x20Move\x20aborts\x20with\x20E_NEED_DEPENDENT_GUARD\x20(repository.move#L422).\x20'+'VERIFIED:\x20passport.rs#L545-612\x20—\x20check_repository_quote_guard\x20enforces\x20this\x20when\x20any\x20guard\x20queries\x20'+'this\x20Repository\x27s\x20data\x20(query\x201167).\x20quote_guard\x20is\x20a\x20RIGID\x20verification\x20requirement.','validation_logic':'quote_guard\x20!=\x20null\x20=>\x20guard.is_depended\x20(immutable\x20&&\x20relies.empty\x20&&\x20rep)','failure_message':'quote_guard\x20must\x20be\x20is_depended\x20—\x20E_NEED_DEPENDENT_GUARD\x20(repository.move#L422)','related_field':'policies[].quote_guard'},{'id':'REP_C_10','name':'quote_guard\x20data\x20subscription\x20design\x20(Payment\x20verification\x20+\x20owner_receive)','description':'For\x20data\x20subscription\x20pattern:\x20(1)\x20quote_guard\x20should\x20verify\x20Payment\x20(for_object\x20matches\x20Repository,\x20'+'amount\x20meets\x20subscription\x20price);\x20(2)\x20Repository\x20should\x20have\x20owner_receive<T>\x20configured\x20to\x20accept\x20'+'Payment\x20as\x20subscription\x20revenue\x20(repository.move#L714-717).\x20'+'DESIGN:\x20user\x20submits\x20Payment\x20via\x20Passport\x20→\x20quote_guard\x20verifies\x20→\x20impack_list\x20updated\x20→\x20repository\x20'+'data\x20query\x20passes.\x20\x27On-chain\x20data\x20is\x20consumed\x20by\x20guard\x20verifiers.\x27','validation_logic':'quote_guard\x20!=\x20null\x20=>\x20quote_guard_verifies_payment\x20&&\x20repository_has_owner_receive','failure_message':'quote_guard\x20subscription\x20incomplete:\x20missing\x20Payment\x20verification\x20or\x20owner_receive\x20revenue','related_field':'policies[].quote_guard'}];function normalizeIdFrom(a){if(typeof a==='number')return a;const b=String(a)['toLowerCase']();if(b==='none')return 0x0;if(b==='clock')return 0x1;if(b==='signer')return 0x2;const c=Number(a);return Number['isNaN'](c)?-0x1:c;}export function explainRepository(a){const b=[],c=[],d=[];let e=0x0,f=0x0,g=!![],h=!![];if(a['policies'])for(const n of a['policies']){const o=normalizeIdFrom(n['id_from']);(o<0x0||o>0x2)&&(h=![],b['push']('Policy\x20\x22'+n['name']+'\x22:\x20id_from=\x22'+n['id_from']+'\x22\x20not\x20recognized\x20(P1-2\x20parseIdFrom)'));o===0x0&&n['write_guard_count']===0x0&&(e++,b['push']('Policy\x20\x22'+n['name']+'\x22:\x20id_from=None\x20+\x20empty\x20write_guard\x20violates\x20R-D-1\x20(E_POLICY_WRITE_GUARD_REQUIRED=22)'));(o===0x1||o===0x2)&&n['has_id_from_submission']&&(e++,b['push']('Policy\x20\x22'+n['name']+'\x22:\x20id_from=Clock/Signer\x20+\x20id_from_submission\x20set\x20violates\x20R-D-1\x20(E_POLICY_ID_FROM_SUBMISSION_FORBIDDEN=23)'));a['is_data_remove_with_passport']&&n['has_data_from_submission']&&(f++,b['push']('Policy\x20\x22'+n['name']+'\x22:\x20data_from_submission\x20set\x20but\x20used\x20in\x20id_data_remove_with_passport\x20violates\x20R-D-2'));if(o===0x0&&(n['has_id_from_submission']||n['has_data_from_submission']))n['has_data_from_submission']&&!n['has_id_from_submission']?d['push'](n['name']+':\x20Mode\x205\x20(data_from_submission\x20only)\x20—\x20SDK\x20hasSubmissionSettings\x20correctly\x20detects\x20[P1-1]'):d['push'](n['name']+':\x20Mode\x205\x20(id_data_mixed_with_passport)');else{if(o===0x0&&n['write_guard_count']>0x0)d['push'](n['name']+':\x20Mode\x204\x20(Guard\x20+\x20caller\x20id,\x20id_data_with_passport)');else{if((o===0x1||o===0x2)&&n['write_guard_count']>0x0)d['push'](n['name']+':\x20Mode\x202b\x20(auto-id\x20+\x20guard,\x20data_when_id_from_set_with_passport)');else{if(o===0x1)d['push'](n['name']+':\x20Mode\x201\x20(Clock-routed,\x20data_when_id_from_set)');else o===0x2?d['push'](n['name']+':\x20Mode\x202\x20(Signer-routed,\x20data_when_id_from_set)'):d['push'](n['name']+':\x20unknown/invalid\x20routing');}}}}if(e>0x0)c['push']('Fix\x20R-D-1\x20violations:\x20align\x20write_guard\x20presence\x20with\x20id_from');if(f>0x0)c['push']('Fix\x20R-D-2\x20violations:\x20remove\x20data_from_submission\x20for\x20id_data_remove_with_passport');if(!h)c['push']('Use\x20recognized\x20id_from\x20values:\x200/1/2\x20or\x20\x27None\x27/\x27Clock\x27/\x27Signer\x27');if(d['length']===0x0)c['push']('Define\x20at\x20least\x20one\x20policy\x20to\x20enable\x20data\x20operations');const i=e===0x0?'PASS\x20(all\x20policies\x20satisfy\x20R-D-1)':'FAIL\x20('+e+'\x20violation(s))',j=f===0x0?'PASS\x20(no\x20R-D-2\x20violations)':'FAIL\x20('+f+'\x20violation(s))',k=g?'PASS\x20(hasSubmissionSettings\x20checks\x20both\x20fields)':'FAIL',l=h?'PASS\x20(all\x20id_from\x20values\x20recognized)':'FAIL\x20(unrecognized\x20id_from\x20values)',m='Repository\x20has\x20'+(a['policies']?.['length']??0x0)+'\x20policy(ies).\x20'+('R-D-1:\x20'+i+'.\x20R-D-2:\x20'+j+'.\x20P1-1:\x20'+k+'.\x20P1-2:\x20'+l+'.');return{'summary':m,'routing_modes':d,'r_d_1_status':i,'r_d_2_status':j,'p1_1_status':k,'p1_2_status':l,'warnings':b,'recommendations':c};}
@@ -1,99 +1 @@
1
- export const REPUTATION_RULES_VERSION = 1;
2
- export function buildReviewRepositorySetup(serviceName) {
3
- return {
4
- repositoryName: `${serviceName}_reviews`,
5
- guardName: `${serviceName}_review_guard`,
6
- guardRules: "Verify that the submitter has a completed order for this Service (query order history == completed) — anti-review-spam",
7
- setupSteps: [
8
- `1. Create Guard: name='${serviceName}_review_guard', rule verifies buyer identity`,
9
- `2. Create Repository: name='${serviceName}_reviews', attach Guard`,
10
- `3. Associate Repository with Service: onchain_operations service modify`,
11
- `4. When user submits a review: onchain_operations repository write (Guard auto-validates)`,
12
- `5. Query reviews: onchain_table_data repository query`,
13
- ],
14
- };
15
- }
16
- export function computeReviewStats(reviews) {
17
- if (reviews.length === 0) {
18
- return {
19
- total: 0,
20
- likes: 0,
21
- dislikes: 0,
22
- likeRate: 0,
23
- verifiedCount: 0,
24
- topTags: [],
25
- recentTrend: "stable",
26
- };
27
- }
28
- const likes = reviews.filter((r) => r.rating === "like").length;
29
- const dislikes = reviews.filter((r) => r.rating === "dislike").length;
30
- const verifiedCount = reviews.filter((r) => r.verified).length;
31
- const tagCounts = new Map();
32
- for (const r of reviews) {
33
- if (r.tags) {
34
- for (const t of r.tags) {
35
- tagCounts.set(t, (tagCounts.get(t) ?? 0) + 1);
36
- }
37
- }
38
- }
39
- const topTags = Array.from(tagCounts.entries())
40
- .sort((a, b) => b[1] - a[1])
41
- .slice(0, 5)
42
- .map(([tag, count]) => ({ tag, count }));
43
- const sorted = [...reviews].sort((a, b) => (a.timestamp ?? 0) - (b.timestamp ?? 0));
44
- const midPoint = Math.floor(sorted.length / 2);
45
- const firstHalf = sorted.slice(0, midPoint);
46
- const secondHalf = sorted.slice(midPoint);
47
- const firstLikeRate = firstHalf.length > 0 ? firstHalf.filter((r) => r.rating === "like").length / firstHalf.length : 0.5;
48
- const secondLikeRate = secondHalf.length > 0 ? secondHalf.filter((r) => r.rating === "like").length / secondHalf.length : 0.5;
49
- let recentTrend = "stable";
50
- if (secondLikeRate > firstLikeRate + 0.15)
51
- recentTrend = "improving";
52
- else if (secondLikeRate < firstLikeRate - 0.15)
53
- recentTrend = "declining";
54
- return {
55
- total: reviews.length,
56
- likes,
57
- dislikes,
58
- likeRate: likes / reviews.length,
59
- verifiedCount,
60
- topTags,
61
- recentTrend,
62
- };
63
- }
64
- export function isVerifiedReview(review, orderHistory) {
65
- if (!review.orderRef)
66
- return false;
67
- const order = orderHistory.find((o) => o.id === review.orderRef);
68
- return order?.status === "completed" || order?.status === "success";
69
- }
70
- export function filterVerifiedReviews(reviews, orderHistory) {
71
- return reviews.map((r) => ({
72
- ...r,
73
- verified: isVerifiedReview(r, orderHistory),
74
- }));
75
- }
76
- export function detectReviewManipulation(reviews) {
77
- const reasons = [];
78
- const reviewerCounts = new Map();
79
- for (const r of reviews) {
80
- reviewerCounts.set(r.reviewer, (reviewerCounts.get(r.reviewer) ?? 0) + 1);
81
- }
82
- const duplicates = Array.from(reviewerCounts.entries()).filter(([, count]) => count > 1);
83
- if (duplicates.length > 0) {
84
- reasons.push(`${duplicates.length} address(es) submitted multiple reviews`);
85
- }
86
- const allLikes = reviews.every((r) => r.rating === "like");
87
- const noneVerified = reviews.every((r) => !r.verified);
88
- if (allLikes && reviews.length > 5 && noneVerified) {
89
- reasons.push("All likes but no verified reviews; possible review spam");
90
- }
91
- if (reviews.length > 10) {
92
- const sorted = [...reviews].sort((a, b) => (a.timestamp ?? 0) - (b.timestamp ?? 0));
93
- const timeSpan = (sorted[sorted.length - 1].timestamp ?? 0) - (sorted[0].timestamp ?? 0);
94
- if (timeSpan > 0 && timeSpan < 3600 * 1000) {
95
- reasons.push(`${reviews.length} reviews submitted within 1 hour; abnormally concentrated timing`);
96
- }
97
- }
98
- return { suspicious: reasons.length > 0, reasons };
99
- }
1
+ export const REPUTATION_RULES_VERSION=0x1;export function buildReviewRepositorySetup(a){return{'repositoryName':a+'_reviews','guardName':a+'_review_guard','guardRules':'Verify\x20that\x20the\x20submitter\x20has\x20a\x20completed\x20order\x20for\x20this\x20Service\x20(query\x20order\x20history\x20==\x20completed)\x20—\x20anti-review-spam','setupSteps':['1.\x20Create\x20Guard:\x20name=\x27'+a+'_review_guard\x27,\x20rule\x20verifies\x20buyer\x20identity','2.\x20Create\x20Repository:\x20name=\x27'+a+'_reviews\x27,\x20attach\x20Guard','3.\x20Associate\x20Repository\x20with\x20Service:\x20onchain_operations\x20service\x20modify','4.\x20When\x20user\x20submits\x20a\x20review:\x20onchain_operations\x20repository\x20write\x20(Guard\x20auto-validates)','5.\x20Query\x20reviews:\x20onchain_table_data\x20repository\x20query']};}export function computeReviewStats(a){if(a['length']===0x0)return{'total':0x0,'likes':0x0,'dislikes':0x0,'likeRate':0x0,'verifiedCount':0x0,'topTags':[],'recentTrend':'stable'};const b=a['filter'](n=>n['rating']==='like')['length'],c=a['filter'](n=>n['rating']==='dislike')['length'],d=a['filter'](n=>n['verified'])['length'],e=new Map();for(const n of a){if(n['tags'])for(const o of n['tags']){e['set'](o,(e['get'](o)??0x0)+0x1);}}const f=Array['from'](e['entries']())['sort']((p,q)=>q[0x1]-p[0x1])['slice'](0x0,0x5)['map'](([p,q])=>({'tag':p,'count':q})),g=[...a]['sort']((p,q)=>(p['timestamp']??0x0)-(q['timestamp']??0x0)),h=Math['floor'](g['length']/0x2),i=g['slice'](0x0,h),j=g['slice'](h),k=i['length']>0x0?i['filter'](p=>p['rating']==='like')['length']/ i['length']:0.5,l=j['length']>0x0?j['filter'](p=>p['rating']==='like')['length']/j['length']:0.5;let m='stable';if(l>k+0.15)m='improving';else{if(l<k-0.15)m='declining';}return{'total':a['length'],'likes':b,'dislikes':c,'likeRate':b/a['length'],'verifiedCount':d,'topTags':f,'recentTrend':m};}export function isVerifiedReview(a,b){if(!a['orderRef'])return![];const c=b['find'](d=>d['id']===a['orderRef']);return c?.['status']==='completed'||c?.['status']==='success';}export function filterVerifiedReviews(a,b){return a['map'](c=>({...c,'verified':isVerifiedReview(c,b)}));}export function detectReviewManipulation(a){const b=[],c=new Map();for(const g of a){c['set'](g['reviewer'],(c['get'](g['reviewer'])??0x0)+0x1);}const d=Array['from'](c['entries']())['filter'](([,h])=>h>0x1);d['length']>0x0&&b['push'](d['length']+'\x20address(es)\x20submitted\x20multiple\x20reviews');const e=a['every'](h=>h['rating']==='like'),f=a['every'](h=>!h['verified']);e&&a['length']>0x5&&f&&b['push']('All\x20likes\x20but\x20no\x20verified\x20reviews;\x20possible\x20review\x20spam');if(a['length']>0xa){const h=[...a]['sort']((j,k)=>(j['timestamp']??0x0)-(k['timestamp']??0x0)),i=(h[h['length']-0x1]['timestamp']??0x0)-(h[0x0]['timestamp']??0x0);i>0x0&&i<0xe10*0x3e8&&b['push'](a['length']+'\x20reviews\x20submitted\x20within\x201\x20hour;\x20abnormally\x20concentrated\x20timing');}return{'suspicious':b['length']>0x0,'reasons':b};}
@@ -0,0 +1,25 @@
1
+ export declare const RESOURCE_CONFIRM_VERSION = "1.0.0";
2
+ export type ConfirmSeverity = "block" | "warn" | "info";
3
+ export interface ResourceConfirmItem {
4
+ id: string;
5
+ severity: ConfirmSeverity;
6
+ title: string;
7
+ description: string;
8
+ passed: boolean;
9
+ evidence?: string;
10
+ fix_hint?: string;
11
+ }
12
+ export interface ResourceOpCheckInput {
13
+ tags_count?: number;
14
+ tag_set_return_ignored?: boolean;
15
+ is_destroy?: boolean;
16
+ expects_resource_permission?: boolean;
17
+ }
18
+ export declare function preCheckResourceOp(input: ResourceOpCheckInput): ResourceConfirmItem[];
19
+ export declare function canProceedResourceOp(input: ResourceOpCheckInput): {
20
+ canProceed: boolean;
21
+ blockers: ResourceConfirmItem[];
22
+ warnings: ResourceConfirmItem[];
23
+ info: ResourceConfirmItem[];
24
+ };
25
+ export declare function formatResourceOpSummary(input: ResourceOpCheckInput): string;