@wowok/agent-mcp 2.4.3 → 2.5.1

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 (317) hide show
  1. package/dist/config/runtime.d.ts +4 -0
  2. package/dist/config/runtime.js +29 -5
  3. package/dist/harness/auto-escalation.d.ts +27 -0
  4. package/dist/harness/auto-escalation.js +68 -0
  5. package/dist/index.js +21 -0
  6. package/dist/knowledge/allocation-confirm.d.ts +115 -0
  7. package/dist/knowledge/allocation-confirm.js +534 -0
  8. package/dist/knowledge/allocation-context.d.ts +58 -0
  9. package/dist/knowledge/allocation-context.js +249 -0
  10. package/dist/knowledge/allocation-ledger.d.ts +67 -0
  11. package/dist/knowledge/allocation-ledger.js +463 -0
  12. package/dist/knowledge/allocation-puzzle.d.ts +135 -0
  13. package/dist/knowledge/allocation-puzzle.js +298 -0
  14. package/dist/knowledge/allocation-risk.d.ts +78 -0
  15. package/dist/knowledge/allocation-risk.js +568 -0
  16. package/dist/knowledge/allocation-templates.d.ts +38 -0
  17. package/dist/knowledge/allocation-templates.js +970 -0
  18. package/dist/knowledge/allocation-translation.d.ts +72 -0
  19. package/dist/knowledge/allocation-translation.js +585 -0
  20. package/dist/knowledge/arb-risk.d.ts +37 -0
  21. package/dist/knowledge/arb-risk.js +210 -0
  22. package/dist/knowledge/arbitration-confirm.d.ts +135 -0
  23. package/dist/knowledge/arbitration-confirm.js +559 -0
  24. package/dist/knowledge/arbitration-context.d.ts +81 -0
  25. package/dist/knowledge/arbitration-context.js +505 -0
  26. package/dist/knowledge/arbitration-ledger.d.ts +62 -0
  27. package/dist/knowledge/arbitration-ledger.js +521 -0
  28. package/dist/knowledge/arbitration-puzzle.d.ts +84 -0
  29. package/dist/knowledge/arbitration-puzzle.js +304 -0
  30. package/dist/knowledge/arbitration-risk.d.ts +112 -0
  31. package/dist/knowledge/arbitration-risk.js +433 -0
  32. package/dist/knowledge/arbitration-templates.d.ts +38 -0
  33. package/dist/knowledge/arbitration-templates.js +276 -0
  34. package/dist/knowledge/arbitration-translation.d.ts +91 -0
  35. package/dist/knowledge/arbitration-translation.js +487 -0
  36. package/dist/knowledge/bridge-risk.d.ts +36 -0
  37. package/dist/knowledge/bridge-risk.js +263 -0
  38. package/dist/knowledge/contact-risk.d.ts +32 -0
  39. package/dist/knowledge/contact-risk.js +200 -0
  40. package/dist/knowledge/demand-confirm.d.ts +32 -0
  41. package/dist/knowledge/demand-confirm.js +206 -0
  42. package/dist/knowledge/demand-risk.d.ts +30 -0
  43. package/dist/knowledge/demand-risk.js +240 -0
  44. package/dist/knowledge/demand-translation.d.ts +55 -0
  45. package/dist/knowledge/demand-translation.js +354 -0
  46. package/dist/knowledge/deployment-scanner.d.ts +63 -0
  47. package/dist/knowledge/deployment-scanner.js +762 -0
  48. package/dist/knowledge/examples-scanner-cli.d.ts +1 -0
  49. package/dist/knowledge/examples-scanner-cli.js +26 -0
  50. package/dist/knowledge/examples-scanner.d.ts +121 -0
  51. package/dist/knowledge/examples-scanner.js +825 -0
  52. package/dist/knowledge/flywheel-loop.d.ts +3 -0
  53. package/dist/knowledge/flywheel-loop.js +32 -3
  54. package/dist/knowledge/glossary.js +3 -1
  55. package/dist/knowledge/guard-confirm.d.ts +86 -0
  56. package/dist/knowledge/guard-confirm.js +406 -0
  57. package/dist/knowledge/guard-context.d.ts +56 -0
  58. package/dist/knowledge/guard-context.js +287 -0
  59. package/dist/knowledge/guard-design-patterns.d.ts +37 -0
  60. package/dist/knowledge/guard-design-patterns.js +257 -0
  61. package/dist/knowledge/guard-puzzle.js +3 -2
  62. package/dist/knowledge/guard-risk.d.ts +1 -1
  63. package/dist/knowledge/guard-risk.js +12 -14
  64. package/dist/knowledge/guard-templates.js +1 -1
  65. package/dist/knowledge/guard-translation.js +6 -5
  66. package/dist/knowledge/index.d.ts +342 -0
  67. package/dist/knowledge/index.js +344 -0
  68. package/dist/knowledge/machine-confirm.d.ts +102 -0
  69. package/dist/knowledge/machine-confirm.js +559 -0
  70. package/dist/knowledge/machine-context.d.ts +160 -0
  71. package/dist/knowledge/machine-context.js +812 -0
  72. package/dist/knowledge/machine-ledger.d.ts +41 -0
  73. package/dist/knowledge/machine-ledger.js +315 -0
  74. package/dist/knowledge/machine-puzzle.d.ts +206 -0
  75. package/dist/knowledge/machine-puzzle.js +494 -0
  76. package/dist/knowledge/machine-risk.d.ts +75 -0
  77. package/dist/knowledge/machine-risk.js +644 -0
  78. package/dist/knowledge/machine-templates.d.ts +92 -0
  79. package/dist/knowledge/machine-templates.js +1592 -0
  80. package/dist/knowledge/machine-topology.d.ts +57 -0
  81. package/dist/knowledge/machine-topology.js +234 -0
  82. package/dist/knowledge/machine-translation.d.ts +96 -0
  83. package/dist/knowledge/machine-translation.js +513 -0
  84. package/dist/knowledge/mcp-schema-audit-cli.d.ts +1 -0
  85. package/dist/knowledge/mcp-schema-audit-cli.js +45 -0
  86. package/dist/knowledge/mcp-schema-audit.d.ts +90 -0
  87. package/dist/knowledge/mcp-schema-audit.js +772 -0
  88. package/dist/knowledge/onchain-constants.d.ts +4 -0
  89. package/dist/knowledge/onchain-constants.js +35 -0
  90. package/dist/knowledge/order-confirm.d.ts +115 -0
  91. package/dist/knowledge/order-confirm.js +573 -0
  92. package/dist/knowledge/order-context.d.ts +66 -0
  93. package/dist/knowledge/order-context.js +390 -0
  94. package/dist/knowledge/order-ledger.d.ts +69 -0
  95. package/dist/knowledge/order-ledger.js +341 -0
  96. package/dist/knowledge/order-puzzle.d.ts +159 -0
  97. package/dist/knowledge/order-puzzle.js +255 -0
  98. package/dist/knowledge/order-risk.d.ts +66 -0
  99. package/dist/knowledge/order-risk.js +653 -0
  100. package/dist/knowledge/order-templates.d.ts +50 -0
  101. package/dist/knowledge/order-templates.js +368 -0
  102. package/dist/knowledge/order-translation.d.ts +78 -0
  103. package/dist/knowledge/order-translation.js +550 -0
  104. package/dist/knowledge/passport-confirm.d.ts +130 -0
  105. package/dist/knowledge/passport-confirm.js +531 -0
  106. package/dist/knowledge/passport-context.d.ts +59 -0
  107. package/dist/knowledge/passport-context.js +306 -0
  108. package/dist/knowledge/passport-ledger.d.ts +48 -0
  109. package/dist/knowledge/passport-ledger.js +282 -0
  110. package/dist/knowledge/passport-puzzle.d.ts +108 -0
  111. package/dist/knowledge/passport-puzzle.js +333 -0
  112. package/dist/knowledge/passport-risk.d.ts +70 -0
  113. package/dist/knowledge/passport-risk.js +450 -0
  114. package/dist/knowledge/passport-templates.d.ts +40 -0
  115. package/dist/knowledge/passport-templates.js +568 -0
  116. package/dist/knowledge/passport-translation.d.ts +68 -0
  117. package/dist/knowledge/passport-translation.js +516 -0
  118. package/dist/knowledge/payment-risk.d.ts +33 -0
  119. package/dist/knowledge/payment-risk.js +182 -0
  120. package/dist/knowledge/permission-confirm.d.ts +110 -0
  121. package/dist/knowledge/permission-confirm.js +426 -0
  122. package/dist/knowledge/permission-context.d.ts +58 -0
  123. package/dist/knowledge/permission-context.js +224 -0
  124. package/dist/knowledge/permission-ledger.d.ts +38 -0
  125. package/dist/knowledge/permission-ledger.js +403 -0
  126. package/dist/knowledge/permission-puzzle.d.ts +122 -0
  127. package/dist/knowledge/permission-puzzle.js +173 -0
  128. package/dist/knowledge/permission-risk.d.ts +76 -0
  129. package/dist/knowledge/permission-risk.js +411 -0
  130. package/dist/knowledge/permission-templates.d.ts +38 -0
  131. package/dist/knowledge/permission-templates.js +234 -0
  132. package/dist/knowledge/permission-translation.d.ts +57 -0
  133. package/dist/knowledge/permission-translation.js +350 -0
  134. package/dist/knowledge/personal-risk.d.ts +36 -0
  135. package/dist/knowledge/personal-risk.js +212 -0
  136. package/dist/knowledge/progress-confirm.d.ts +108 -0
  137. package/dist/knowledge/progress-confirm.js +456 -0
  138. package/dist/knowledge/progress-context.d.ts +123 -0
  139. package/dist/knowledge/progress-context.js +452 -0
  140. package/dist/knowledge/progress-ledger.d.ts +63 -0
  141. package/dist/knowledge/progress-ledger.js +327 -0
  142. package/dist/knowledge/progress-puzzle.d.ts +82 -0
  143. package/dist/knowledge/progress-puzzle.js +219 -0
  144. package/dist/knowledge/progress-risk.d.ts +74 -0
  145. package/dist/knowledge/progress-risk.js +461 -0
  146. package/dist/knowledge/progress-templates.d.ts +38 -0
  147. package/dist/knowledge/progress-templates.js +228 -0
  148. package/dist/knowledge/progress-translation.d.ts +52 -0
  149. package/dist/knowledge/progress-translation.js +401 -0
  150. package/dist/knowledge/proof-confirm.d.ts +31 -0
  151. package/dist/knowledge/proof-confirm.js +187 -0
  152. package/dist/knowledge/proof-risk.d.ts +33 -0
  153. package/dist/knowledge/proof-risk.js +207 -0
  154. package/dist/knowledge/proof-translation.d.ts +52 -0
  155. package/dist/knowledge/proof-translation.js +283 -0
  156. package/dist/knowledge/registrar-risk.d.ts +34 -0
  157. package/dist/knowledge/registrar-risk.js +217 -0
  158. package/dist/knowledge/repository-confirm.d.ts +36 -0
  159. package/dist/knowledge/repository-confirm.js +242 -0
  160. package/dist/knowledge/repository-risk.d.ts +40 -0
  161. package/dist/knowledge/repository-risk.js +312 -0
  162. package/dist/knowledge/repository-translation.d.ts +58 -0
  163. package/dist/knowledge/repository-translation.js +422 -0
  164. package/dist/knowledge/resource-risk.d.ts +32 -0
  165. package/dist/knowledge/resource-risk.js +157 -0
  166. package/dist/knowledge/reward-confirm.d.ts +113 -0
  167. package/dist/knowledge/reward-confirm.js +496 -0
  168. package/dist/knowledge/reward-context.d.ts +127 -0
  169. package/dist/knowledge/reward-context.js +504 -0
  170. package/dist/knowledge/reward-ledger.d.ts +96 -0
  171. package/dist/knowledge/reward-ledger.js +502 -0
  172. package/dist/knowledge/reward-puzzle.d.ts +97 -0
  173. package/dist/knowledge/reward-puzzle.js +288 -0
  174. package/dist/knowledge/reward-risk.d.ts +84 -0
  175. package/dist/knowledge/reward-risk.js +545 -0
  176. package/dist/knowledge/reward-translation.d.ts +58 -0
  177. package/dist/knowledge/reward-translation.js +501 -0
  178. package/dist/knowledge/safety-rules.js +11 -3
  179. package/dist/knowledge/scenario-modes.d.ts +53 -0
  180. package/dist/knowledge/scenario-modes.js +302 -0
  181. package/dist/knowledge/service-confirm.d.ts +152 -0
  182. package/dist/knowledge/service-confirm.js +699 -0
  183. package/dist/knowledge/service-context.d.ts +66 -0
  184. package/dist/knowledge/service-context.js +403 -0
  185. package/dist/knowledge/service-ledger.d.ts +71 -0
  186. package/dist/knowledge/service-ledger.js +609 -0
  187. package/dist/knowledge/service-puzzle.d.ts +158 -0
  188. package/dist/knowledge/service-puzzle.js +236 -0
  189. package/dist/knowledge/service-risk.d.ts +108 -0
  190. package/dist/knowledge/service-risk.js +615 -0
  191. package/dist/knowledge/service-templates.d.ts +39 -0
  192. package/dist/knowledge/service-templates.js +418 -0
  193. package/dist/knowledge/service-translation.d.ts +103 -0
  194. package/dist/knowledge/service-translation.js +622 -0
  195. package/dist/knowledge/tools-reference.d.ts +17 -0
  196. package/dist/knowledge/tools-reference.js +151 -0
  197. package/dist/knowledge/treasury-confirm.d.ts +133 -0
  198. package/dist/knowledge/treasury-confirm.js +512 -0
  199. package/dist/knowledge/treasury-context.d.ts +64 -0
  200. package/dist/knowledge/treasury-context.js +363 -0
  201. package/dist/knowledge/treasury-ledger.d.ts +42 -0
  202. package/dist/knowledge/treasury-ledger.js +300 -0
  203. package/dist/knowledge/treasury-puzzle.d.ts +163 -0
  204. package/dist/knowledge/treasury-puzzle.js +216 -0
  205. package/dist/knowledge/treasury-risk.d.ts +86 -0
  206. package/dist/knowledge/treasury-risk.js +440 -0
  207. package/dist/knowledge/treasury-templates.d.ts +38 -0
  208. package/dist/knowledge/treasury-templates.js +316 -0
  209. package/dist/knowledge/treasury-translation.d.ts +78 -0
  210. package/dist/knowledge/treasury-translation.js +498 -0
  211. package/dist/knowledge/util-risk.d.ts +30 -0
  212. package/dist/knowledge/util-risk.js +135 -0
  213. package/dist/project/business-puzzle.d.ts +47 -0
  214. package/dist/project/business-puzzle.js +372 -0
  215. package/dist/project/deployment-doc.d.ts +61 -0
  216. package/dist/project/deployment-doc.js +432 -0
  217. package/dist/project/risk-aggregator.d.ts +50 -0
  218. package/dist/project/risk-aggregator.js +280 -0
  219. package/dist/project/substep-trace.d.ts +130 -0
  220. package/dist/project/substep-trace.js +332 -0
  221. package/dist/schema/call/allocation.d.ts +34 -34
  222. package/dist/schema/call/arbitration.d.ts +141 -141
  223. package/dist/schema/call/base.d.ts +386 -386
  224. package/dist/schema/call/base.js +3 -3
  225. package/dist/schema/call/bridge-handler.d.ts +5 -2
  226. package/dist/schema/call/bridge.d.ts +159 -159
  227. package/dist/schema/call/contact.d.ts +110 -110
  228. package/dist/schema/call/demand.d.ts +76 -76
  229. package/dist/schema/call/handler.d.ts +2 -3
  230. package/dist/schema/call/handler.js +1 -1
  231. package/dist/schema/call/machine.d.ts +58 -58
  232. package/dist/schema/call/order.d.ts +98 -110
  233. package/dist/schema/call/permission-handler.d.ts +5 -0
  234. package/dist/schema/call/permission-handler.js +54 -0
  235. package/dist/schema/call/permission.d.ts +108 -108
  236. package/dist/schema/call/personal.d.ts +14 -14
  237. package/dist/schema/call/progress.d.ts +57 -72
  238. package/dist/schema/call/progress.js +7 -4
  239. package/dist/schema/call/proof.d.ts +18 -18
  240. package/dist/schema/call/proof.js +12 -7
  241. package/dist/schema/call/repository.d.ts +154 -154
  242. package/dist/schema/call/reward.d.ts +55 -55
  243. package/dist/schema/call/service.d.ts +231 -231
  244. package/dist/schema/call/treasury.d.ts +93 -93
  245. package/dist/schema/config/index.d.ts +178 -5
  246. package/dist/schema/config/index.js +52 -1
  247. package/dist/schema/local/index.d.ts +3554 -836
  248. package/dist/schema/local/index.js +2 -1
  249. package/dist/schema/messenger/index.d.ts +162 -162
  250. package/dist/schema/operations.d.ts +1058 -1074
  251. package/dist/schema/operations.js +7 -1
  252. package/dist/schema/project/index.d.ts +1412 -6
  253. package/dist/schema/project/index.js +441 -3
  254. package/dist/schema/query/index.d.ts +672 -672
  255. package/dist/schema/schema-query/index.d.ts +23 -3
  256. package/dist/schema/schema-query/index.js +13 -2
  257. package/dist/schema/sync-layer4.d.ts +21 -0
  258. package/dist/schema/sync-layer4.js +261 -0
  259. package/dist/schema/trust/index.d.ts +26 -26
  260. package/dist/schemas/account_operation.output.json +718 -0
  261. package/dist/schemas/config_operation.output.json +173 -0
  262. package/dist/schemas/index.json +9 -1
  263. package/dist/schemas/local_info_operation.output.json +718 -0
  264. package/dist/schemas/local_mark_operation.output.json +718 -0
  265. package/dist/schemas/onchain_operations.output.json +3 -2
  266. package/dist/schemas/onchain_operations.schema.json +1809 -336
  267. package/dist/schemas/onchain_operations_allocation.schema.json +2 -1
  268. package/dist/schemas/onchain_operations_arbitration.schema.json +2 -1
  269. package/dist/schemas/onchain_operations_contact.schema.json +2 -1
  270. package/dist/schemas/onchain_operations_demand.schema.json +2 -1
  271. package/dist/schemas/onchain_operations_gen_passport.schema.json +878 -872
  272. package/dist/schemas/onchain_operations_gen_proof.schema.json +273 -0
  273. package/dist/schemas/onchain_operations_guard.schema.json +578 -579
  274. package/dist/schemas/onchain_operations_machine.schema.json +2 -1
  275. package/dist/schemas/onchain_operations_order.schema.json +13 -9
  276. package/dist/schemas/onchain_operations_payment.schema.json +0 -514
  277. package/dist/schemas/onchain_operations_permission.schema.json +0 -514
  278. package/dist/schemas/onchain_operations_personal.schema.json +0 -514
  279. package/dist/schemas/onchain_operations_progress.schema.json +14 -10
  280. package/dist/schemas/onchain_operations_proof.schema.json +699 -0
  281. package/dist/schemas/onchain_operations_repository.schema.json +2 -1
  282. package/dist/schemas/onchain_operations_reward.schema.json +2 -1
  283. package/dist/schemas/onchain_operations_service.schema.json +2 -1
  284. package/dist/schemas/onchain_operations_treasury.schema.json +2 -1
  285. package/dist/schemas/onchain_table_data.schema.json +32 -1
  286. package/dist/schemas/project_operation.output.json +918 -0
  287. package/dist/schemas/project_operation.schema.json +474 -3
  288. package/dist/schemas/query_toolkit.output.json +14906 -6
  289. package/dist/schemas/schema_query.output.json +38 -1
  290. package/dist/telemetry/index.d.ts +1 -1
  291. package/dist/tools/handlers/config.d.ts +1 -1
  292. package/dist/tools/handlers/config.js +21 -18
  293. package/dist/tools/handlers/file-export.d.ts +2 -2
  294. package/dist/tools/handlers/local.d.ts +3 -30
  295. package/dist/tools/handlers/local.js +14 -3
  296. package/dist/tools/handlers/messenger.d.ts +1 -1
  297. package/dist/tools/handlers/messenger.js +2 -1
  298. package/dist/tools/handlers/onchain.d.ts +1 -1
  299. package/dist/tools/handlers/onchain.js +24 -22
  300. package/dist/tools/handlers/project.d.ts +1 -1
  301. package/dist/tools/handlers/project.js +262 -18
  302. package/dist/tools/handlers/query.d.ts +4 -4
  303. package/dist/tools/handlers/schema-query.d.ts +1 -1
  304. package/dist/tools/handlers/schema-query.js +21 -20
  305. package/dist/tools/handlers/trust.d.ts +1 -1
  306. package/dist/tools/handlers/trust.js +2 -2
  307. package/dist/tools/handlers/wip.d.ts +1 -1
  308. package/dist/tools/handlers/wip.js +1 -1
  309. package/dist/tools/index.d.ts +1 -1
  310. package/dist/tools/index.js +96 -25
  311. package/dist/tools/rules-hook.d.ts +1 -1
  312. package/dist/tools/rules-hook.js +3 -2
  313. package/dist/tools/shared.d.ts +13 -22
  314. package/dist/tools/types.d.ts +5 -5
  315. package/dist/tools/wrap.d.ts +10 -2
  316. package/dist/tools/wrap.js +212 -0
  317. package/package.json +3 -3
@@ -0,0 +1,207 @@
1
+ import { MAX_PROOF_SIZE, MAX_SERVER_PUBKEY_SIZE, MAX_SERVER_SIGNATURE_SIZE, WOWOK_WTS_PROOF_TYPE, } from "@wowok/wowok";
2
+ const R_PR_1_01 = {
3
+ rule: {
4
+ id: "R-PROOF-01",
5
+ level: "HIGH",
6
+ category: "structural",
7
+ title: `proof content exceeds MAX_PROOF_SIZE (${MAX_PROOF_SIZE} bytes)`,
8
+ description: `The 'proof' string field is bounded by MAX_PROOF_SIZE=${MAX_PROOF_SIZE} bytes (Move source: proof.move:27). ` +
9
+ `Exceeding this limit aborts with E_MAX_PROOF_SIZE (1). The proof content typically holds a merkle tree root ` +
10
+ `or similar compact cryptographic digest — large data should be stored in a Repository and referenced by address, ` +
11
+ `not inlined into the Proof object.`,
12
+ affected_stakeholders: ["creator"],
13
+ scenario: "Caller submits a proof string longer than 10240 bytes",
14
+ mitigation: `Keep proof content compact (merkle root, hash digest). For larger payloads, store data in a Repository ` +
15
+ `object and set about_address to the Repository address, or use item_count to indicate the off-chain data size.`,
16
+ related_move_error: "E_MAX_PROOF_SIZE (1)",
17
+ auto_fixable: false,
18
+ },
19
+ check: (ctx) => {
20
+ if (!ctx.proof)
21
+ return null;
22
+ if (ctx.proof.length <= MAX_PROOF_SIZE)
23
+ return null;
24
+ return { ...R_PR_1_01.rule, evidence: `proof.length=${ctx.proof.length}, limit=${MAX_PROOF_SIZE}` };
25
+ },
26
+ };
27
+ const R_PR_1_02 = {
28
+ rule: {
29
+ id: "R-PROOF-02",
30
+ level: "MEDIUM",
31
+ category: "structural",
32
+ title: `server_pubkey exceeds MAX_SERVER_PUBKEY_SIZE (${MAX_SERVER_PUBKEY_SIZE} bytes)`,
33
+ description: `The 'server_pubkey' field is bounded by MAX_SERVER_PUBKEY_SIZE=${MAX_SERVER_PUBKEY_SIZE} bytes (Move source: proof.move:28). ` +
34
+ `Exceeding this limit aborts with E_MAX_SERVER_PUBKEY_SIZE (2). Typical public keys (Ed25519=32 bytes, RSA-2048=256 bytes, ` +
35
+ `BLS12-381 G1=48 bytes, G2=96 bytes) fit comfortably within this limit.`,
36
+ affected_stakeholders: ["creator"],
37
+ scenario: "Caller submits an oversized server public key (e.g. certificate chain instead of raw key)",
38
+ mitigation: "Submit only the raw public key bytes (hex-encoded), not a full certificate or JWK structure.",
39
+ related_move_error: "E_MAX_SERVER_PUBKEY_SIZE (2)",
40
+ auto_fixable: false,
41
+ },
42
+ check: (ctx) => {
43
+ if (!ctx.server_pubkey)
44
+ return null;
45
+ if (ctx.server_pubkey.length <= MAX_SERVER_PUBKEY_SIZE)
46
+ return null;
47
+ return { ...R_PR_1_02.rule, evidence: `server_pubkey.length=${ctx.server_pubkey.length}, limit=${MAX_SERVER_PUBKEY_SIZE}` };
48
+ },
49
+ };
50
+ const R_PR_1_03 = {
51
+ rule: {
52
+ id: "R-PROOF-03",
53
+ level: "MEDIUM",
54
+ category: "structural",
55
+ title: `server_signature exceeds MAX_SERVER_SIGNATURE_SIZE (${MAX_SERVER_SIGNATURE_SIZE} bytes)`,
56
+ description: `The 'server_signature' field is bounded by MAX_SERVER_SIGNATURE_SIZE=${MAX_SERVER_SIGNATURE_SIZE} bytes ` +
57
+ `(Move source: proof.move:29). Exceeding this limit aborts with E_MAX_SERVER_SIGNATURE_SIZE (3). ` +
58
+ `Most signature schemes produce signatures well under this limit (Ed25519=64 bytes, ECDSA=64-72 bytes, ` +
59
+ `BLS12-381=96 bytes, RSA-2048=256 bytes).`,
60
+ affected_stakeholders: ["creator"],
61
+ scenario: "Caller submits an oversized signature (e.g. bundled with metadata)",
62
+ mitigation: "Submit only the raw signature bytes (hex-encoded), not bundled metadata or certificate chains.",
63
+ related_move_error: "E_MAX_SERVER_SIGNATURE_SIZE (3)",
64
+ auto_fixable: false,
65
+ },
66
+ check: (ctx) => {
67
+ if (!ctx.server_signature)
68
+ return null;
69
+ if (ctx.server_signature.length <= MAX_SERVER_SIGNATURE_SIZE)
70
+ return null;
71
+ return { ...R_PR_1_03.rule, evidence: `server_signature.length=${ctx.server_signature.length}, limit=${MAX_SERVER_SIGNATURE_SIZE}` };
72
+ },
73
+ };
74
+ const R_PR_2_01 = {
75
+ rule: {
76
+ id: "R-PROOF-04",
77
+ level: "MEDIUM",
78
+ category: "semantic",
79
+ title: `proof_type in reserved range without authority (1-100 reserved for Wowok)`,
80
+ description: `proof_type=${WOWOK_WTS_PROOF_TYPE} is WOWOK_WTS_PROOF_TYPE (Will-To-Sign). Values 2-100 are reserved for ` +
81
+ `future Wowok-defined proof types. User-defined proof types must use values > 100. While the Move contract ` +
82
+ `does not currently enforce this range at the type level (it accepts any u64), using a reserved value without ` +
83
+ `authority creates semantic confusion: consumers may misinterpret the proof's verification rules.`,
84
+ affected_stakeholders: ["creator", "consumer", "verifier"],
85
+ scenario: "User creates a custom proof with proof_type=5 (a reserved value)",
86
+ mitigation: "Use proof_type > 100 for user-defined proof types. Use proof_type=1 only for WTS proofs signed by an " +
87
+ "off-chain server (with server_pubkey + server_signature). Document the verification rule for custom types.",
88
+ auto_fixable: false,
89
+ },
90
+ check: (ctx) => {
91
+ if (ctx.proof_type === undefined || ctx.proof_type === null)
92
+ return null;
93
+ const n = typeof ctx.proof_type === "string" ? BigInt(ctx.proof_type) : BigInt(ctx.proof_type);
94
+ if (n === BigInt(WOWOK_WTS_PROOF_TYPE) || n > 100n)
95
+ return null;
96
+ return { ...R_PR_2_01.rule, evidence: `proof_type=${ctx.proof_type} (reserved range 2-100)` };
97
+ },
98
+ };
99
+ const R_PR_2_02 = {
100
+ rule: {
101
+ id: "R-PROOF-05",
102
+ level: "LOW",
103
+ category: "semantic",
104
+ title: "about_address not provided — consumers cannot locate the referenced entity",
105
+ description: "about_address is the on-chain address of the entity being proved (e.g. a user, an order, a Repository). " +
106
+ "When null/undefined, the Proof has no on-chain binding — it is a free-standing cryptographic statement. " +
107
+ "Consumers (Repository, Service, etc.) that reference this Proof cannot automatically resolve which entity " +
108
+ "it applies to. This is acceptable for generic proofs but problematic for entity-bound attestations.",
109
+ affected_stakeholders: ["creator", "consumer"],
110
+ scenario: "Caller creates a Proof without about_address, then a Repository tries to bind it to a data entry",
111
+ mitigation: "Set about_address when the Proof attests to a specific on-chain entity. Leave it null only for " +
112
+ "free-standing cryptographic statements (e.g. a server's timestamp attestation).",
113
+ auto_fixable: true,
114
+ },
115
+ check: (ctx) => {
116
+ if (ctx.about_address)
117
+ return null;
118
+ return { ...R_PR_2_02.rule, evidence: "about_address=null/undefined" };
119
+ },
120
+ };
121
+ const R_PR_3_01 = {
122
+ rule: {
123
+ id: "R-PROOF-06",
124
+ level: "LOW",
125
+ category: "lifecycle",
126
+ title: "description missing — Proof hard to identify in queries and audit logs",
127
+ description: "description is a REQUIRED field (PF-D-2=A). The Move contract stores it as a String field and SDK " +
128
+ "passes it to create_wowok_proof. An empty description (\"\") is technically valid but makes the Proof " +
129
+ "hard to identify in query results and audit logs. Non-empty descriptions are strongly recommended.",
130
+ affected_stakeholders: ["creator", "verifier"],
131
+ scenario: "Caller passes description=\"\" to save typing",
132
+ mitigation: "Provide a one-line description like \"KYC attestation for user 0xabc\" or \"merkle root for batch #42\".",
133
+ auto_fixable: false,
134
+ },
135
+ check: (ctx) => {
136
+ if (ctx.description === undefined)
137
+ return null;
138
+ if (ctx.description.length > 0)
139
+ return null;
140
+ return { ...R_PR_3_01.rule, evidence: "description=\"\" (empty)" };
141
+ },
142
+ };
143
+ const R_PR_3_02 = {
144
+ rule: {
145
+ id: "R-PROOF-07",
146
+ level: "HIGH",
147
+ category: "lifecycle",
148
+ title: "Proof is immutable — cannot modify after creation (freeze_object)",
149
+ description: "Proof is created via transfer::freeze_object(obj) in Move (proof.move:65). Once frozen, the object " +
150
+ "cannot be modified, transferred, or deleted. All fields (proof, server_pubkey, server_signature, " +
151
+ "about, proof_type, signer, time, description, item_count) are permanently fixed at the value set " +
152
+ "during create_wowok_proof(). To 'update' a Proof, create a new one and update references.",
153
+ affected_stakeholders: ["creator", "consumer"],
154
+ scenario: "Caller wants to update server_signature after key rotation — cannot, must create new Proof",
155
+ mitigation: "Verify all fields before calling create_wowok_proof. For scenarios requiring key rotation, " +
156
+ "create a new Proof and update the referencing object (Repository data, Service config, etc.) to " +
157
+ "point to the new Proof address.",
158
+ auto_fixable: false,
159
+ },
160
+ check: (ctx) => null,
161
+ };
162
+ const R_PR_4_01 = {
163
+ rule: {
164
+ id: "R-PROOF-08",
165
+ level: "INFO",
166
+ category: "knowledge",
167
+ title: "Knowledge layer & constant sync — RESOLVED",
168
+ description: "All 4 Proof constants (WOWOK_WTS_PROOF_TYPE, MAX_PROOF_SIZE, MAX_SERVER_PUBKEY_SIZE, " +
169
+ "MAX_SERVER_SIGNATURE_SIZE) are now synced to onchain-constants.ts (P-PROOF-P2-5). The MCP Knowledge " +
170
+ "layer now includes proof-risk.ts, proof-confirm.ts, proof-translation.ts (P-PROOF-P2-6). " +
171
+ "This risk rule is retained for historical audit and to detect future regressions.",
172
+ affected_stakeholders: ["system"],
173
+ scenario: "Future regression: someone removes a Proof constant from onchain-constants.ts",
174
+ mitigation: "Run the onchain-constants sync test to detect drift.",
175
+ auto_fixable: false,
176
+ },
177
+ check: (ctx) => {
178
+ if (ctx.constants_synced)
179
+ return null;
180
+ return { ...R_PR_4_01.rule, evidence: "constants_synced=false" };
181
+ },
182
+ };
183
+ export const PROOF_RISK_RULES = [
184
+ R_PR_1_01,
185
+ R_PR_1_02,
186
+ R_PR_1_03,
187
+ R_PR_2_01,
188
+ R_PR_2_02,
189
+ R_PR_3_01,
190
+ R_PR_3_02,
191
+ R_PR_4_01,
192
+ ];
193
+ export function checkProofRisks(ctx) {
194
+ const risks = [];
195
+ for (const rule of PROOF_RISK_RULES) {
196
+ const r = rule.check(ctx);
197
+ if (r)
198
+ risks.push(r);
199
+ }
200
+ if (!risks.find(r => r.id === "R-PROOF-07")) {
201
+ risks.push(R_PR_3_02.rule);
202
+ }
203
+ return risks;
204
+ }
205
+ export function getProofRiskById(id) {
206
+ return PROOF_RISK_RULES.find(r => r.rule.id === id)?.rule;
207
+ }
@@ -0,0 +1,52 @@
1
+ export interface SemanticToProofSchemaRule {
2
+ id: string;
3
+ pattern_name: string;
4
+ proof_type_classification: "wts" | "custom_reserved" | "custom_user";
5
+ semantic_intent: string;
6
+ match_keywords: string[];
7
+ schema_elements: {
8
+ proof_type_value: number | string;
9
+ required_fields: string[];
10
+ optional_fields: string[];
11
+ about_address_recommendation: string;
12
+ };
13
+ constraints: string[];
14
+ example: Record<string, unknown>;
15
+ }
16
+ export declare const SEMANTIC_TO_PROOF_SCHEMA_RULES: SemanticToProofSchemaRule[];
17
+ export interface ProofFieldTranslation {
18
+ field_name: string;
19
+ move_field?: string;
20
+ value_type: string;
21
+ semantic: string;
22
+ format_example: string;
23
+ validation_rules: string[];
24
+ }
25
+ export declare const PROOF_FIELD_TRANSLATIONS: ProofFieldTranslation[];
26
+ export interface ProofConstraintRule {
27
+ id: string;
28
+ name: string;
29
+ description: string;
30
+ validation_logic: string;
31
+ failure_message: string;
32
+ related_field: string;
33
+ }
34
+ export declare const PROOF_CONSTRAINT_RULES: ProofConstraintRule[];
35
+ export interface ProofExplainInput {
36
+ proof_type?: number | bigint | string;
37
+ proof?: string;
38
+ server_pubkey?: string;
39
+ server_signature?: string;
40
+ about_address?: string | null;
41
+ description?: string;
42
+ item_count?: number | bigint | string | null;
43
+ }
44
+ export interface ProofExplanation {
45
+ summary: string;
46
+ proof_type_classification: string;
47
+ binding: string;
48
+ size_status: string;
49
+ warnings: string[];
50
+ recommendations: string[];
51
+ }
52
+ export declare function explainProof(input: ProofExplainInput): ProofExplanation;
@@ -0,0 +1,283 @@
1
+ import { WOWOK_WTS_PROOF_TYPE } from "@wowok/wowok";
2
+ export const SEMANTIC_TO_PROOF_SCHEMA_RULES = [
3
+ {
4
+ id: "P-PROOF-01",
5
+ pattern_name: "Wowok WTS (Will-To-Sign) proof",
6
+ proof_type_classification: "wts",
7
+ semantic_intent: "An off-chain server attests to a fact (identity, timestamp, merkle root) and signs it with server_pubkey. " +
8
+ "On-chain consumers verify the signature off-chain and trust the Proof record as evidence.",
9
+ match_keywords: ["wts", "server-signed", "attestation", "kyc", "merkle root", "timestamp"],
10
+ schema_elements: {
11
+ proof_type_value: WOWOK_WTS_PROOF_TYPE,
12
+ required_fields: ["proof", "server_pubkey", "server_signature", "description"],
13
+ optional_fields: ["item_count", "about_address", "namedNew"],
14
+ about_address_recommendation: "Set about_address when the WTS proof attests to a specific on-chain entity (user address, Repository, etc.). " +
15
+ "Leave null for free-standing attestations (e.g. server timestamp).",
16
+ },
17
+ constraints: [
18
+ `proof_type must equal ${WOWOK_WTS_PROOF_TYPE} (WOWOK_WTS_PROOF_TYPE)`,
19
+ "server_pubkey must be the raw public key (hex-encoded), not a certificate",
20
+ "server_signature must sign the exact bytes of the 'proof' field (or a documented pre-image)",
21
+ "Off-chain verification logic must be documented for consumers",
22
+ ],
23
+ example: {
24
+ proof_type: WOWOK_WTS_PROOF_TYPE,
25
+ proof: "0xabc123...merkle_root_hex...",
26
+ server_pubkey: "0x04a1b2c3...ed25519_or_ecdsa_pubkey_hex...",
27
+ server_signature: "0x9d8e7f6...signature_hex...",
28
+ description: "KYC attestation for user 0xabc (merkle root of 1024 leaves)",
29
+ item_count: 1024,
30
+ about_address: "0xabc...user_address...",
31
+ namedNew: { name: "kyc_user_abc" },
32
+ },
33
+ },
34
+ {
35
+ id: "P-PROOF-02",
36
+ pattern_name: "Custom proof in Wowok reserved range (NOT recommended)",
37
+ proof_type_classification: "custom_reserved",
38
+ semantic_intent: "A custom proof type using a value in the reserved range 2-100. This is NOT recommended because future " +
39
+ "Wowok protocol upgrades may claim these values, breaking semantic compatibility. Use only if you have " +
40
+ "explicit Wowok authority to claim a reserved value.",
41
+ match_keywords: ["reserved", "custom reserved", "wowok-defined"],
42
+ schema_elements: {
43
+ proof_type_value: "2-100 (specific value documented by creator)",
44
+ required_fields: ["proof", "server_pubkey", "server_signature", "description", "proof_type"],
45
+ optional_fields: ["item_count", "about_address", "namedNew"],
46
+ about_address_recommendation: "Same as P-PROOF-01: set about_address for entity-bound attestations.",
47
+ },
48
+ constraints: [
49
+ "Caller must have explicit Wowok authority to claim a reserved proof_type value",
50
+ "Verification logic must be documented and stable across protocol upgrades",
51
+ "Future Wowok upgrades may reassign this value — callers must handle migration",
52
+ ],
53
+ example: {
54
+ proof_type: 5,
55
+ proof: "0x...custom_proof_format...",
56
+ server_pubkey: "0x...pubkey...",
57
+ server_signature: "0x...sig...",
58
+ description: "Custom reserved proof type (documented by authority X)",
59
+ },
60
+ },
61
+ {
62
+ id: "P-PROOF-03",
63
+ pattern_name: "User-defined proof type (>100)",
64
+ proof_type_classification: "custom_user",
65
+ semantic_intent: "A fully custom proof type using a value > 100. The creator defines the verification logic (off-chain). " +
66
+ "This is the recommended range for application-specific proof semantics that Wowok protocol does not cover.",
67
+ match_keywords: ["custom", "user-defined", "application-specific", "custom proof type"],
68
+ schema_elements: {
69
+ proof_type_value: ">100 (user-chosen, must be unique within application scope)",
70
+ required_fields: ["proof", "server_pubkey", "server_signature", "description", "proof_type"],
71
+ optional_fields: ["item_count", "about_address", "namedNew"],
72
+ about_address_recommendation: "Set about_address when the proof is bound to a specific on-chain entity. Leave null for off-chain-only proofs.",
73
+ },
74
+ constraints: [
75
+ "proof_type must be > 100 (user-defined range)",
76
+ "Application must document the verification logic and proof format",
77
+ "Ensure proof_type does not collide with other user-defined types in the same consumer scope",
78
+ ],
79
+ example: {
80
+ proof_type: 200,
81
+ proof: "0x...application_specific_proof_format...",
82
+ server_pubkey: "0x...pubkey...",
83
+ server_signature: "0x...sig...",
84
+ description: "Application-specific attestation (format documented at https://...)",
85
+ about_address: null,
86
+ namedNew: { name: "custom_attestation_001" },
87
+ },
88
+ },
89
+ ];
90
+ export const PROOF_FIELD_TRANSLATIONS = [
91
+ {
92
+ field_name: "proof",
93
+ value_type: "string (hex-encoded)",
94
+ semantic: "The cryptographic proof content. Typically a merkle tree root, a hash digest, or a compact serialized attestation. " +
95
+ "Off-chain verifiers use this together with server_pubkey and server_signature to verify the proof's authenticity.",
96
+ format_example: "0xabc123...merkle_root_64hex...",
97
+ validation_rules: [
98
+ "Non-empty string",
99
+ "Length ≤ MAX_PROOF_SIZE (10240 bytes)",
100
+ "Move aborts with E_MAX_PROOF_SIZE (1) on overflow",
101
+ ],
102
+ },
103
+ {
104
+ field_name: "server_pubkey",
105
+ value_type: "string (hex-encoded)",
106
+ semantic: "The public key of the off-chain server that signed this proof. Consumers use this to verify server_signature " +
107
+ "off-chain. Submit the raw public key bytes, not a certificate chain or JWK structure.",
108
+ format_example: "0x04a1b2c3...ed25519_pubkey_64hex...",
109
+ validation_rules: [
110
+ "Non-empty string",
111
+ "Length ≤ MAX_SERVER_PUBKEY_SIZE (2048 bytes)",
112
+ "Move aborts with E_MAX_SERVER_PUBKEY_SIZE (2) on overflow",
113
+ "Must be a valid public key for the signature scheme used",
114
+ ],
115
+ },
116
+ {
117
+ field_name: "server_signature",
118
+ value_type: "string (hex-encoded)",
119
+ semantic: "The signature produced by the off-chain server using its private key. Verifiers check this against " +
120
+ "server_pubkey and the proof content (or a documented pre-image).",
121
+ format_example: "0x9d8e7f6...signature_hex...",
122
+ validation_rules: [
123
+ "Non-empty string",
124
+ "Length ≤ MAX_SERVER_SIGNATURE_SIZE (40480 bytes)",
125
+ "Move aborts with E_MAX_SERVER_SIGNATURE_SIZE (3) on overflow",
126
+ ],
127
+ },
128
+ {
129
+ field_name: "proof_type",
130
+ value_type: "u64 (number | bigint | numeric string)",
131
+ semantic: `Classifies the proof's verification logic. ${WOWOK_WTS_PROOF_TYPE}=WOWOK_WTS_PROOF_TYPE (Wowok Will-To-Sign, ` +
132
+ `signed by off-chain server). Values 2-100 are reserved for future Wowok-defined types. Values >100 are user-defined.`,
133
+ format_example: `1 (WTS), 200 (custom)`,
134
+ validation_rules: [
135
+ "Required field",
136
+ "Must be ≥ 1 (P-PROOF-P2-2: schema rejects 0 and non-numeric strings)",
137
+ "Value 1 = WOWOK_WTS_PROOF_TYPE",
138
+ "Values 2-100 require explicit Wowok authority",
139
+ "Values >100 are user-defined",
140
+ ],
141
+ },
142
+ {
143
+ field_name: "about_address",
144
+ move_field: "about",
145
+ value_type: "Option<address> (string | null)",
146
+ semantic: "The on-chain address of the entity being proved (e.g. a user, order, Repository). When null, the Proof is a " +
147
+ "free-standing cryptographic statement with no on-chain binding. SDK sends Option::none to Move when null/undefined.",
148
+ format_example: "0xabc...64hex_address... or null",
149
+ validation_rules: [
150
+ "Optional (null/undefined → Option::none) [PF-D-1=A]",
151
+ "When provided, must be a raw 0x-prefixed 64-hex address (NOT a name)",
152
+ "SDK isValidAddress check enforces format",
153
+ ],
154
+ },
155
+ {
156
+ field_name: "description",
157
+ value_type: "string",
158
+ semantic: "Human-readable description of this Proof. Required field (PF-D-2=A). Helps identify the Proof in query results " +
159
+ "and audit logs. Should be a one-line summary (e.g. \"KYC attestation for user 0xabc\").",
160
+ format_example: "KYC attestation for user 0xabc (merkle root of 1024 leaves)",
161
+ validation_rules: [
162
+ "Required field [PF-D-2=A]",
163
+ "Length ≤ MAX_DESCRIPTION_LENGTH (defined in common.ts)",
164
+ "SDK isValidDescription check enforces max length",
165
+ ],
166
+ },
167
+ {
168
+ field_name: "item_count",
169
+ move_field: "item_count",
170
+ value_type: "Option<u64> (number | bigint | numeric string | null)",
171
+ semantic: "Optional count of items in the off-chain data structure (e.g. number of leaves in a merkle tree). " +
172
+ "Used by consumers to interpret the proof content. When null, SDK sends Option::none to Move.",
173
+ format_example: "1024 or null",
174
+ validation_rules: [
175
+ "Optional (null/undefined → Option::none)",
176
+ "When provided, must be ≥ 0",
177
+ ],
178
+ },
179
+ ];
180
+ export const PROOF_CONSTRAINT_RULES = [
181
+ {
182
+ id: "PROOF_C_01",
183
+ name: "proof content non-empty",
184
+ description: "The 'proof' field must be a non-empty string.",
185
+ validation_logic: "proof.length > 0",
186
+ failure_message: "proof field is empty",
187
+ related_field: "proof",
188
+ },
189
+ {
190
+ id: "PROOF_C_02",
191
+ name: "proof content within size limit",
192
+ description: `The 'proof' field must be ≤ MAX_PROOF_SIZE (10240 bytes).`,
193
+ validation_logic: "proof.length <= MAX_PROOF_SIZE",
194
+ failure_message: "proof exceeds MAX_PROOF_SIZE (10240 bytes) — E_MAX_PROOF_SIZE (1)",
195
+ related_field: "proof",
196
+ },
197
+ {
198
+ id: "PROOF_C_03",
199
+ name: "server_pubkey within size limit",
200
+ description: "The 'server_pubkey' field must be ≤ MAX_SERVER_PUBKEY_SIZE (2048 bytes).",
201
+ validation_logic: "server_pubkey.length <= MAX_SERVER_PUBKEY_SIZE",
202
+ failure_message: "server_pubkey exceeds MAX_SERVER_PUBKEY_SIZE (2048 bytes) — E_MAX_SERVER_PUBKEY_SIZE (2)",
203
+ related_field: "server_pubkey",
204
+ },
205
+ {
206
+ id: "PROOF_C_04",
207
+ name: "server_signature within size limit",
208
+ description: "The 'server_signature' field must be ≤ MAX_SERVER_SIGNATURE_SIZE (40480 bytes).",
209
+ validation_logic: "server_signature.length <= MAX_SERVER_SIGNATURE_SIZE",
210
+ failure_message: "server_signature exceeds MAX_SERVER_SIGNATURE_SIZE (40480 bytes) — E_MAX_SERVER_SIGNATURE_SIZE (3)",
211
+ related_field: "server_signature",
212
+ },
213
+ {
214
+ id: "PROOF_C_05",
215
+ name: "proof_type valid range",
216
+ description: `proof_type must be ≥ 1 (WOWOK_WTS_PROOF_TYPE=${WOWOK_WTS_PROOF_TYPE} is the minimum).`,
217
+ validation_logic: "proof_type >= 1",
218
+ failure_message: "proof_type must be ≥ 1 — schema rejects 0 and non-numeric strings",
219
+ related_field: "proof_type",
220
+ },
221
+ {
222
+ id: "PROOF_C_06",
223
+ name: "about_address format (when provided)",
224
+ description: "When about_address is non-null, it must be a valid 0x-prefixed 64-hex address.",
225
+ validation_logic: "about_address == null || /^0x[0-9a-fA-F]{64}$/.test(about_address)",
226
+ failure_message: "about_address is not a valid 0x-prefixed 64-hex address",
227
+ related_field: "about_address",
228
+ },
229
+ ];
230
+ export function explainProof(input) {
231
+ const warnings = [];
232
+ const recommendations = [];
233
+ let classification = "unknown";
234
+ if (input.proof_type !== undefined && input.proof_type !== null) {
235
+ const n = typeof input.proof_type === "string" ? BigInt(input.proof_type) : BigInt(input.proof_type);
236
+ if (n === BigInt(WOWOK_WTS_PROOF_TYPE)) {
237
+ classification = `WTS proof (proof_type=${WOWOK_WTS_PROOF_TYPE}) — signed by off-chain server`;
238
+ }
239
+ else if (n > 1n && n <= 100n) {
240
+ classification = `Custom proof in reserved range (proof_type=${input.proof_type}) — NOT recommended without Wowok authority`;
241
+ warnings.push(`proof_type=${input.proof_type} is in reserved range 2-100 — future Wowok upgrades may reassign this value`);
242
+ }
243
+ else if (n > 100n) {
244
+ classification = `User-defined proof (proof_type=${input.proof_type}) — application-specific verification logic`;
245
+ }
246
+ else {
247
+ classification = `INVALID proof_type=${input.proof_type} (must be ≥ 1)`;
248
+ warnings.push("proof_type is < 1 — schema validation will reject");
249
+ }
250
+ }
251
+ const binding = input.about_address
252
+ ? `Entity-bound: about_address=${input.about_address.substring(0, 10)}... (proof attests to this on-chain entity)`
253
+ : "Free-standing: no on-chain entity binding (about_address=null)";
254
+ const sizeStatus = [];
255
+ if (input.proof) {
256
+ sizeStatus.push(`proof=${input.proof.length} bytes (limit 10240)`);
257
+ }
258
+ if (input.server_pubkey) {
259
+ sizeStatus.push(`server_pubkey=${input.server_pubkey.length} bytes (limit 2048)`);
260
+ }
261
+ if (input.server_signature) {
262
+ sizeStatus.push(`server_signature=${input.server_signature.length} bytes (limit 40480)`);
263
+ }
264
+ if (!input.description || input.description.length === 0) {
265
+ recommendations.push("Provide a non-empty description for audit log discoverability");
266
+ }
267
+ if (!input.about_address) {
268
+ recommendations.push("Consider setting about_address if this Proof attests to a specific on-chain entity");
269
+ }
270
+ if (input.item_count === undefined || input.item_count === null) {
271
+ recommendations.push("Consider setting item_count if the proof references a multi-item data structure");
272
+ }
273
+ const summary = `Proof is a ${classification}. ${binding}. ` +
274
+ (sizeStatus.length > 0 ? `Sizes: ${sizeStatus.join(", ")}.` : "");
275
+ return {
276
+ summary,
277
+ proof_type_classification: classification,
278
+ binding,
279
+ size_status: sizeStatus.join(", "),
280
+ warnings,
281
+ recommendations,
282
+ };
283
+ }
@@ -0,0 +1,34 @@
1
+ export type RegistrarRiskLevel = "CRITICAL" | "HIGH" | "MEDIUM" | "LOW" | "INFO";
2
+ export type RegistrarRiskCategory = "structural" | "semantic" | "lifecycle" | "cross_object" | "knowledge";
3
+ export type RegistrarStakeholder = "user" | "referrer" | "voter" | "system";
4
+ export interface RegistrarRisk {
5
+ id: string;
6
+ level: RegistrarRiskLevel;
7
+ category: RegistrarRiskCategory;
8
+ title: string;
9
+ description: string;
10
+ affected_stakeholders: RegistrarStakeholder[];
11
+ scenario: string;
12
+ mitigation: string;
13
+ evidence?: string;
14
+ related_move_error?: string;
15
+ auto_fixable: boolean;
16
+ }
17
+ export interface RegistrarRiskCheckContext {
18
+ expects_singleton_migration?: boolean;
19
+ address_count?: number;
20
+ uses_reserved_vote_bits?: boolean;
21
+ expects_fresh_resource_on_register?: boolean;
22
+ expects_affiliation_event?: boolean;
23
+ relies_on_typed_value_convention?: boolean;
24
+ is_resource_transfer?: boolean;
25
+ expects_vote_time_only_on_like?: boolean;
26
+ constants_synced?: boolean;
27
+ }
28
+ export declare const REGISTRAR_RISK_RULES: {
29
+ rule: RegistrarRisk;
30
+ check: (ctx: RegistrarRiskCheckContext) => RegistrarRisk | null;
31
+ }[];
32
+ export declare const REGISTRAR_RISK_VERSION = "1.0.0";
33
+ export declare function checkRegistrarRisks(ctx: RegistrarRiskCheckContext): RegistrarRisk[];
34
+ export declare function getRegistrarRiskById(id: string): RegistrarRisk | undefined;