@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,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};}