@jinn-network/client 0.1.1 → 0.1.2-canary.d6e72dfd

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/CHANGELOG.md +14 -0
  2. package/CONTRIBUTING.md +123 -0
  3. package/README.md +210 -37
  4. package/deployments/deployment-claim-registry-baseSepolia.json +13 -0
  5. package/deployments/deployment-jinn-testnet-faucet-baseSepolia-fast.json +15 -0
  6. package/dist/adapters/claim-registry/abi.d.ts +127 -0
  7. package/dist/adapters/claim-registry/abi.js +93 -0
  8. package/dist/adapters/claim-registry/abi.js.map +1 -0
  9. package/dist/adapters/claim-registry/client.d.ts +89 -0
  10. package/dist/adapters/claim-registry/client.js +205 -0
  11. package/dist/adapters/claim-registry/client.js.map +1 -0
  12. package/dist/adapters/mech/adapter.d.ts +1 -0
  13. package/dist/adapters/mech/adapter.js +75 -41
  14. package/dist/adapters/mech/adapter.js.map +1 -1
  15. package/dist/adapters/mech/contracts.d.ts +2 -0
  16. package/dist/adapters/mech/contracts.js +57 -7
  17. package/dist/adapters/mech/contracts.js.map +1 -1
  18. package/dist/adapters/mech/ipfs.d.ts +8 -0
  19. package/dist/adapters/mech/ipfs.js +12 -0
  20. package/dist/adapters/mech/ipfs.js.map +1 -1
  21. package/dist/adapters/mech/types.d.ts +20 -46
  22. package/dist/adapters/mech/types.js +16 -35
  23. package/dist/adapters/mech/types.js.map +1 -1
  24. package/dist/api/gather-status.d.ts +1 -0
  25. package/dist/api/gather-status.js +33 -1
  26. package/dist/api/gather-status.js.map +1 -1
  27. package/dist/api/portfolio-v0-build.d.ts +81 -0
  28. package/dist/api/portfolio-v0-build.js +141 -0
  29. package/dist/api/portfolio-v0-build.js.map +1 -0
  30. package/dist/api/portfolio-v0-doctor.d.ts +37 -0
  31. package/dist/api/portfolio-v0-doctor.js +123 -0
  32. package/dist/api/portfolio-v0-doctor.js.map +1 -0
  33. package/dist/api/rewards-build.js +1 -1
  34. package/dist/api/rewards-build.js.map +1 -1
  35. package/dist/api/status-build.d.ts +7 -0
  36. package/dist/api/status-build.js +1 -0
  37. package/dist/api/status-build.js.map +1 -1
  38. package/dist/bin/jinn-mcp.d.ts +0 -12
  39. package/dist/bin/jinn-mcp.js +5 -14
  40. package/dist/bin/jinn-mcp.js.map +1 -1
  41. package/dist/build-meta.json +1 -1
  42. package/dist/cli/commands/auth.js +115 -25
  43. package/dist/cli/commands/auth.js.map +1 -1
  44. package/dist/cli/commands/bootstrap.js +1 -0
  45. package/dist/cli/commands/bootstrap.js.map +1 -1
  46. package/dist/cli/commands/doctor.js +130 -14
  47. package/dist/cli/commands/doctor.js.map +1 -1
  48. package/dist/cli/commands/fleet-scale.js +1 -0
  49. package/dist/cli/commands/fleet-scale.js.map +1 -1
  50. package/dist/cli/commands/fund-requirements.js +2 -0
  51. package/dist/cli/commands/fund-requirements.js.map +1 -1
  52. package/dist/cli/commands/intents.d.ts +17 -0
  53. package/dist/cli/commands/intents.js +489 -0
  54. package/dist/cli/commands/intents.js.map +1 -0
  55. package/dist/cli/commands/keys-backup.js +13 -11
  56. package/dist/cli/commands/keys-backup.js.map +1 -1
  57. package/dist/cli/commands/mcp.d.ts +3 -0
  58. package/dist/cli/commands/mcp.js +19 -0
  59. package/dist/cli/commands/mcp.js.map +1 -0
  60. package/dist/cli/commands/plugin-install.js +8 -4
  61. package/dist/cli/commands/plugin-install.js.map +1 -1
  62. package/dist/cli/commands/quickstart.js +60 -4
  63. package/dist/cli/commands/quickstart.js.map +1 -1
  64. package/dist/cli/commands/rewards.js +27 -1
  65. package/dist/cli/commands/rewards.js.map +1 -1
  66. package/dist/cli/commands/submit-intent.js +108 -5
  67. package/dist/cli/commands/submit-intent.js.map +1 -1
  68. package/dist/cli/commands/version.js +1 -0
  69. package/dist/cli/commands/version.js.map +1 -1
  70. package/dist/cli/deployment-digest.js +5 -0
  71. package/dist/cli/deployment-digest.js.map +1 -1
  72. package/dist/cli/execution-context.js +1 -0
  73. package/dist/cli/execution-context.js.map +1 -1
  74. package/dist/cli/index.js +4 -0
  75. package/dist/cli/index.js.map +1 -1
  76. package/dist/cli/intent-registry-access.d.ts +64 -0
  77. package/dist/cli/intent-registry-access.js +187 -0
  78. package/dist/cli/intent-registry-access.js.map +1 -0
  79. package/dist/cli/introspection-context.js +1 -0
  80. package/dist/cli/introspection-context.js.map +1 -1
  81. package/dist/cli/password.d.ts +21 -9
  82. package/dist/cli/password.js +45 -24
  83. package/dist/cli/password.js.map +1 -1
  84. package/dist/config.d.ts +110 -8
  85. package/dist/config.js +41 -12
  86. package/dist/config.js.map +1 -1
  87. package/dist/daemon/creator.d.ts +7 -1
  88. package/dist/daemon/creator.js +38 -3
  89. package/dist/daemon/creator.js.map +1 -1
  90. package/dist/daemon/daemon.d.ts +43 -0
  91. package/dist/daemon/daemon.js +87 -2
  92. package/dist/daemon/daemon.js.map +1 -1
  93. package/dist/earning/bootstrap.d.ts +2 -1
  94. package/dist/earning/bootstrap.js +72 -4
  95. package/dist/earning/bootstrap.js.map +1 -1
  96. package/dist/earning/contracts.d.ts +10 -0
  97. package/dist/earning/contracts.js +24 -0
  98. package/dist/earning/contracts.js.map +1 -1
  99. package/dist/earning/jinn-rewards.d.ts +9 -0
  100. package/dist/earning/jinn-rewards.js +7 -0
  101. package/dist/earning/jinn-rewards.js.map +1 -1
  102. package/dist/intents/prediction-apy-v0-auto.d.ts +11 -0
  103. package/dist/intents/prediction-apy-v0-auto.js +46 -0
  104. package/dist/intents/prediction-apy-v0-auto.js.map +1 -0
  105. package/dist/intents/prediction-apy-v0-template.d.ts +8 -0
  106. package/dist/intents/prediction-apy-v0-template.js +22 -0
  107. package/dist/intents/prediction-apy-v0-template.js.map +1 -0
  108. package/dist/intents/prediction-v0-auto.d.ts +53 -0
  109. package/dist/intents/prediction-v0-auto.js +84 -0
  110. package/dist/intents/prediction-v0-auto.js.map +1 -0
  111. package/dist/intents/prediction-v0-template.d.ts +65 -0
  112. package/dist/intents/prediction-v0-template.js +125 -0
  113. package/dist/intents/prediction-v0-template.js.map +1 -0
  114. package/dist/main.js +149 -1
  115. package/dist/main.js.map +1 -1
  116. package/dist/mcp/operator-server.d.ts +1 -1
  117. package/dist/mcp/operator-server.js +1 -1
  118. package/dist/preflight/claude-auth.d.ts +12 -1
  119. package/dist/preflight/claude-auth.js +21 -3
  120. package/dist/preflight/claude-auth.js.map +1 -1
  121. package/dist/restorer/engine/canonical-json.d.ts +18 -0
  122. package/dist/restorer/engine/canonical-json.js +59 -0
  123. package/dist/restorer/engine/canonical-json.js.map +1 -0
  124. package/dist/restorer/engine/claim.d.ts +69 -0
  125. package/dist/restorer/engine/claim.js +104 -0
  126. package/dist/restorer/engine/claim.js.map +1 -0
  127. package/dist/restorer/engine/delivery.d.ts +52 -0
  128. package/dist/restorer/engine/delivery.js +63 -0
  129. package/dist/restorer/engine/delivery.js.map +1 -0
  130. package/dist/restorer/engine/engine.d.ts +203 -0
  131. package/dist/restorer/engine/engine.js +753 -0
  132. package/dist/restorer/engine/engine.js.map +1 -0
  133. package/dist/restorer/engine/manifest-assembly.d.ts +67 -0
  134. package/dist/restorer/engine/manifest-assembly.js +79 -0
  135. package/dist/restorer/engine/manifest-assembly.js.map +1 -0
  136. package/dist/restorer/engine/packaging.d.ts +87 -0
  137. package/dist/restorer/engine/packaging.js +350 -0
  138. package/dist/restorer/engine/packaging.js.map +1 -0
  139. package/dist/restorer/engine/persistence.d.ts +170 -0
  140. package/dist/restorer/engine/persistence.js +381 -0
  141. package/dist/restorer/engine/persistence.js.map +1 -0
  142. package/dist/restorer/engine/recovery.d.ts +22 -0
  143. package/dist/restorer/engine/recovery.js +24 -0
  144. package/dist/restorer/engine/recovery.js.map +1 -0
  145. package/dist/restorer/engine/registry.d.ts +62 -0
  146. package/dist/restorer/engine/registry.js +73 -0
  147. package/dist/restorer/engine/registry.js.map +1 -0
  148. package/dist/restorer/engine/signing.d.ts +30 -0
  149. package/dist/restorer/engine/signing.js +39 -0
  150. package/dist/restorer/engine/signing.js.map +1 -0
  151. package/dist/restorer/engine/state.d.ts +42 -0
  152. package/dist/restorer/engine/state.js +87 -0
  153. package/dist/restorer/engine/state.js.map +1 -0
  154. package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.d.ts +64 -0
  155. package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.js +96 -0
  156. package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.js.map +1 -0
  157. package/dist/restorer/impls/claude-mcp-hyperliquid/index.d.ts +101 -0
  158. package/dist/restorer/impls/claude-mcp-hyperliquid/index.js +710 -0
  159. package/dist/restorer/impls/claude-mcp-hyperliquid/index.js.map +1 -0
  160. package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.d.ts +137 -0
  161. package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.js +865 -0
  162. package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.js.map +1 -0
  163. package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.d.ts +74 -0
  164. package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.js +74 -0
  165. package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.js.map +1 -0
  166. package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.d.ts +97 -0
  167. package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js +226 -0
  168. package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js.map +1 -0
  169. package/dist/restorer/impls/claude-mcp-prediction/index.d.ts +43 -0
  170. package/dist/restorer/impls/claude-mcp-prediction/index.js +230 -0
  171. package/dist/restorer/impls/claude-mcp-prediction/index.js.map +1 -0
  172. package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.d.ts +38 -0
  173. package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.js +135 -0
  174. package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.js.map +1 -0
  175. package/dist/restorer/impls/claude-mcp-prediction/prompt.d.ts +8 -0
  176. package/dist/restorer/impls/claude-mcp-prediction/prompt.js +54 -0
  177. package/dist/restorer/impls/claude-mcp-prediction/prompt.js.map +1 -0
  178. package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.d.ts +36 -0
  179. package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.js +137 -0
  180. package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.js.map +1 -0
  181. package/dist/restorer/impls/claude-mcp-prediction/types.d.ts +82 -0
  182. package/dist/restorer/impls/claude-mcp-prediction/types.js +6 -0
  183. package/dist/restorer/impls/claude-mcp-prediction/types.js.map +1 -0
  184. package/dist/restorer/impls/legacy-claude/index.d.ts +45 -0
  185. package/dist/restorer/impls/legacy-claude/index.js +71 -0
  186. package/dist/restorer/impls/legacy-claude/index.js.map +1 -0
  187. package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.d.ts +68 -0
  188. package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.js +117 -0
  189. package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.js.map +1 -0
  190. package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.d.ts +49 -0
  191. package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.js +91 -0
  192. package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.js.map +1 -0
  193. package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.d.ts +78 -0
  194. package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.js +274 -0
  195. package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.js.map +1 -0
  196. package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.d.ts +23 -0
  197. package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.js +49 -0
  198. package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.js.map +1 -0
  199. package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.d.ts +25 -0
  200. package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.js +44 -0
  201. package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.js.map +1 -0
  202. package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.d.ts +17 -0
  203. package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.js +43 -0
  204. package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.js.map +1 -0
  205. package/dist/restorer/impls/portfolio-v0-evaluator/index.d.ts +43 -0
  206. package/dist/restorer/impls/portfolio-v0-evaluator/index.js +431 -0
  207. package/dist/restorer/impls/portfolio-v0-evaluator/index.js.map +1 -0
  208. package/dist/restorer/impls/portfolio-v0-evaluator/score.d.ts +21 -0
  209. package/dist/restorer/impls/portfolio-v0-evaluator/score.js +32 -0
  210. package/dist/restorer/impls/portfolio-v0-evaluator/score.js.map +1 -0
  211. package/dist/restorer/impls/portfolio-v0-evaluator/types.d.ts +32 -0
  212. package/dist/restorer/impls/portfolio-v0-evaluator/types.js +8 -0
  213. package/dist/restorer/impls/portfolio-v0-evaluator/types.js.map +1 -0
  214. package/dist/restorer/impls/prediction-apy-v0-baseline/index.d.ts +39 -0
  215. package/dist/restorer/impls/prediction-apy-v0-baseline/index.js +98 -0
  216. package/dist/restorer/impls/prediction-apy-v0-baseline/index.js.map +1 -0
  217. package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.d.ts +2 -0
  218. package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.js +7 -0
  219. package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.js.map +1 -0
  220. package/dist/restorer/impls/prediction-apy-v0-baseline/types.d.ts +4 -0
  221. package/dist/restorer/impls/prediction-apy-v0-baseline/types.js +2 -0
  222. package/dist/restorer/impls/prediction-apy-v0-baseline/types.js.map +1 -0
  223. package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.d.ts +2 -0
  224. package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.js +7 -0
  225. package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.js.map +1 -0
  226. package/dist/restorer/impls/prediction-apy-v0-evaluator/index.d.ts +39 -0
  227. package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js +186 -0
  228. package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js.map +1 -0
  229. package/dist/restorer/impls/prediction-apy-v0-evaluator/score.d.ts +9 -0
  230. package/dist/restorer/impls/prediction-apy-v0-evaluator/score.js +20 -0
  231. package/dist/restorer/impls/prediction-apy-v0-evaluator/score.js.map +1 -0
  232. package/dist/restorer/impls/prediction-apy-v0-evaluator/types.d.ts +7 -0
  233. package/dist/restorer/impls/prediction-apy-v0-evaluator/types.js +2 -0
  234. package/dist/restorer/impls/prediction-apy-v0-evaluator/types.js.map +1 -0
  235. package/dist/restorer/impls/prediction-v0-baseline/index.d.ts +29 -0
  236. package/dist/restorer/impls/prediction-v0-baseline/index.js +94 -0
  237. package/dist/restorer/impls/prediction-v0-baseline/index.js.map +1 -0
  238. package/dist/restorer/impls/prediction-v0-baseline/strategy.d.ts +8 -0
  239. package/dist/restorer/impls/prediction-v0-baseline/strategy.js +41 -0
  240. package/dist/restorer/impls/prediction-v0-baseline/strategy.js.map +1 -0
  241. package/dist/restorer/impls/prediction-v0-baseline/types.d.ts +7 -0
  242. package/dist/restorer/impls/prediction-v0-baseline/types.js +2 -0
  243. package/dist/restorer/impls/prediction-v0-baseline/types.js.map +1 -0
  244. package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.d.ts +20 -0
  245. package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.js +66 -0
  246. package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.js.map +1 -0
  247. package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.d.ts +9 -0
  248. package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.js +23 -0
  249. package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.js.map +1 -0
  250. package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.d.ts +3 -0
  251. package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.js +13 -0
  252. package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.js.map +1 -0
  253. package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.d.ts +7 -0
  254. package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js +93 -0
  255. package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js.map +1 -0
  256. package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.d.ts +5 -0
  257. package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.js +20 -0
  258. package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.js.map +1 -0
  259. package/dist/restorer/impls/prediction-v0-evaluator/index.d.ts +33 -0
  260. package/dist/restorer/impls/prediction-v0-evaluator/index.js +208 -0
  261. package/dist/restorer/impls/prediction-v0-evaluator/index.js.map +1 -0
  262. package/dist/restorer/impls/prediction-v0-evaluator/score.d.ts +8 -0
  263. package/dist/restorer/impls/prediction-v0-evaluator/score.js +15 -0
  264. package/dist/restorer/impls/prediction-v0-evaluator/score.js.map +1 -0
  265. package/dist/restorer/impls/prediction-v0-evaluator/types.d.ts +7 -0
  266. package/dist/restorer/impls/prediction-v0-evaluator/types.js +2 -0
  267. package/dist/restorer/impls/prediction-v0-evaluator/types.js.map +1 -0
  268. package/dist/restorer/types.d.ts +177 -0
  269. package/dist/restorer/types.js +7 -0
  270. package/dist/restorer/types.js.map +1 -0
  271. package/dist/store/store.d.ts +3 -1
  272. package/dist/store/store.js +3 -0
  273. package/dist/store/store.js.map +1 -1
  274. package/dist/types/desired-state.d.ts +53 -0
  275. package/dist/types/desired-state.js +20 -0
  276. package/dist/types/desired-state.js.map +1 -1
  277. package/dist/types/index.d.ts +4 -1
  278. package/dist/types/index.js +4 -1
  279. package/dist/types/index.js.map +1 -1
  280. package/dist/types/portfolio.d.ts +1000 -0
  281. package/dist/types/portfolio.js +168 -0
  282. package/dist/types/portfolio.js.map +1 -0
  283. package/dist/types/prediction-apy.d.ts +919 -0
  284. package/dist/types/prediction-apy.js +121 -0
  285. package/dist/types/prediction-apy.js.map +1 -0
  286. package/dist/types/prediction.d.ts +925 -0
  287. package/dist/types/prediction.js +140 -0
  288. package/dist/types/prediction.js.map +1 -0
  289. package/dist/venues/aave-v3/addresses.d.ts +6 -0
  290. package/dist/venues/aave-v3/addresses.js +19 -0
  291. package/dist/venues/aave-v3/addresses.js.map +1 -0
  292. package/dist/venues/aave-v3/client.d.ts +81 -0
  293. package/dist/venues/aave-v3/client.js +97 -0
  294. package/dist/venues/aave-v3/client.js.map +1 -0
  295. package/dist/venues/chainlink/client.d.ts +99 -0
  296. package/dist/venues/chainlink/client.js +130 -0
  297. package/dist/venues/chainlink/client.js.map +1 -0
  298. package/dist/venues/chainlink/feeds.d.ts +8 -0
  299. package/dist/venues/chainlink/feeds.js +9 -0
  300. package/dist/venues/chainlink/feeds.js.map +1 -0
  301. package/dist/venues/hyperliquid/account-value.d.ts +30 -0
  302. package/dist/venues/hyperliquid/account-value.js +30 -0
  303. package/dist/venues/hyperliquid/account-value.js.map +1 -0
  304. package/dist/venues/hyperliquid/client.d.ts +63 -0
  305. package/dist/venues/hyperliquid/client.js +135 -0
  306. package/dist/venues/hyperliquid/client.js.map +1 -0
  307. package/dist/venues/hyperliquid/grid.d.ts +36 -0
  308. package/dist/venues/hyperliquid/grid.js +61 -0
  309. package/dist/venues/hyperliquid/grid.js.map +1 -0
  310. package/dist/venues/hyperliquid/types.d.ts +81 -0
  311. package/dist/venues/hyperliquid/types.js +8 -0
  312. package/dist/venues/hyperliquid/types.js.map +1 -0
  313. package/dist/withdraw/run-withdraw-plan.js +2 -0
  314. package/dist/withdraw/run-withdraw-plan.js.map +1 -1
  315. package/docker-compose.yml +44 -0
  316. package/package.json +12 -1
  317. package/skills/jinn-operator/SKILL.md +85 -0
@@ -0,0 +1,41 @@
1
+ /** Decimal comparison. Both inputs are non-negative decimal strings. */
2
+ function decCmp(a, b) {
3
+ const [ai, af = ''] = a.split('.');
4
+ const [bi, bf = ''] = b.split('.');
5
+ const aiN = ai.replace(/^0+/, '') || '0';
6
+ const biN = bi.replace(/^0+/, '') || '0';
7
+ if (aiN.length !== biN.length)
8
+ return aiN.length - biN.length;
9
+ if (aiN !== biN)
10
+ return aiN < biN ? -1 : 1;
11
+ const maxLen = Math.max(af.length, bf.length);
12
+ const afP = af.padEnd(maxLen, '0');
13
+ const bfP = bf.padEnd(maxLen, '0');
14
+ if (afP === bfP)
15
+ return 0;
16
+ return afP < bfP ? -1 : 1;
17
+ }
18
+ function evaluateQuestion(question, price) {
19
+ if (question.kind === 'threshold') {
20
+ const c = decCmp(price, question.threshold);
21
+ switch (question.operator) {
22
+ case 'GT': return c > 0;
23
+ case 'GTE': return c >= 0;
24
+ case 'LT': return c < 0;
25
+ case 'LTE': return c <= 0;
26
+ }
27
+ }
28
+ else {
29
+ const lowerCmp = decCmp(price, question.lowerBound);
30
+ const upperCmp = decCmp(price, question.upperBound);
31
+ return lowerCmp >= 0 && upperCmp < 0;
32
+ }
33
+ }
34
+ export function spotCarryPredict(intent, currentPrice) {
35
+ const currentlyYes = evaluateQuestion(intent.spec.question, currentPrice);
36
+ return {
37
+ probability: currentlyYes ? '0.55' : '0.45',
38
+ modelId: 'spot-carry.v1',
39
+ };
40
+ }
41
+ //# sourceMappingURL=strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-v0-baseline/strategy.ts"],"names":[],"mappings":"AAQA,wEAAwE;AACxE,SAAS,MAAM,CAAC,CAAS,EAAE,CAAS;IAClC,MAAM,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EA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AAI,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;QACpD,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;QACpD,OAAO,QAAQ,IAAI,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAC;IACvC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAA0B,EAAE,YAAoB;IAC/E,MAAM,YAAY,GAAG,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAC1E,OAAO;QACL,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;QAC3C,OAAO,EAAE,eAAe;KACzB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ export interface StrategyPrediction {
2
+ probability: string;
3
+ modelId: string;
4
+ }
5
+ export interface Strategy {
6
+ predict(intent: import('../../../types/prediction.js').PredictionV0Intent, currentPrice: string): StrategyPrediction;
7
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-v0-baseline/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Canonical metrics for prediction.v0 evaluator.
3
+ *
4
+ * §6 of spec/2026-04-20-prediction-v0-pis-phase-1-design.md
5
+ */
6
+ import type { PredictionV0Intent } from '../../../types/prediction.js';
7
+ /** Compare two non-negative decimal strings. Returns negative/zero/positive. */
8
+ export declare function decCmp(a: string, b: string): number;
9
+ export type GroundTruth = 'YES' | 'NO';
10
+ export declare function resolveGroundTruth(question: PredictionV0Intent['spec']['question'], price: string): GroundTruth;
11
+ /**
12
+ * Brier score scaled to 1e18 fixed-point.
13
+ *
14
+ * score = 1 - (probability - outcome)^2 ∈ [0,1]
15
+ * * probability: decimal string ∈ [0,1]
16
+ * * outcome: 0 | 1
17
+ *
18
+ * Returns: string representation of BigInt (score × 1e18), rounded to nearest.
19
+ */
20
+ export declare function brierScore(probability: string, outcome: 0 | 1): string;
@@ -0,0 +1,66 @@
1
+ /** Compare two non-negative decimal strings. Returns negative/zero/positive. */
2
+ export function decCmp(a, b) {
3
+ const [ai, af = ''] = a.split('.');
4
+ const [bi, bf = ''] = b.split('.');
5
+ const aiN = (ai || '0').replace(/^0+/, '') || '0';
6
+ const biN = (bi || '0').replace(/^0+/, '') || '0';
7
+ if (aiN.length !== biN.length)
8
+ return aiN.length - biN.length;
9
+ if (aiN !== biN)
10
+ return aiN < biN ? -1 : 1;
11
+ const maxLen = Math.max(af.length, bf.length);
12
+ const afP = af.padEnd(maxLen, '0');
13
+ const bfP = bf.padEnd(maxLen, '0');
14
+ if (afP === bfP)
15
+ return 0;
16
+ return afP < bfP ? -1 : 1;
17
+ }
18
+ export function resolveGroundTruth(question, price) {
19
+ if (question.kind === 'threshold') {
20
+ const c = decCmp(price, question.threshold);
21
+ switch (question.operator) {
22
+ case 'GT': return c > 0 ? 'YES' : 'NO';
23
+ case 'GTE': return c >= 0 ? 'YES' : 'NO';
24
+ case 'LT': return c < 0 ? 'YES' : 'NO';
25
+ case 'LTE': return c <= 0 ? 'YES' : 'NO';
26
+ }
27
+ }
28
+ const lo = decCmp(price, question.lowerBound);
29
+ const hi = decCmp(price, question.upperBound);
30
+ return (lo >= 0 && hi < 0) ? 'YES' : 'NO';
31
+ }
32
+ /**
33
+ * Brier score scaled to 1e18 fixed-point.
34
+ *
35
+ * score = 1 - (probability - outcome)^2 ∈ [0,1]
36
+ * * probability: decimal string ∈ [0,1]
37
+ * * outcome: 0 | 1
38
+ *
39
+ * Returns: string representation of BigInt (score × 1e18), rounded to nearest.
40
+ */
41
+ export function brierScore(probability, outcome) {
42
+ const p = Number(probability);
43
+ if (!Number.isFinite(p) || p < 0 || p > 1) {
44
+ throw new Error(`brierScore: probability must be in [0,1], got ${probability}`);
45
+ }
46
+ // Use integer arithmetic to avoid floating-point precision loss.
47
+ // Represent probability as a rational n/d where d = 10^decimalPlaces.
48
+ const dotIdx = probability.indexOf('.');
49
+ const decimals = dotIdx === -1 ? 0 : probability.length - dotIdx - 1;
50
+ const d = BigInt(10 ** decimals);
51
+ const n = BigInt(probability.replace('.', '')); // numerator: p = n/d
52
+ // outcome as BigInt
53
+ const o = BigInt(outcome); // 0 or 1
54
+ // score = 1 - (p - outcome)^2
55
+ // = 1 - ((n - o*d) / d)^2
56
+ // = (d^2 - (n - o*d)^2) / d^2
57
+ const diff = n - o * d; // (p - outcome) * d
58
+ const scoreNum = d * d - diff * diff; // score * d^2
59
+ const scoreDenom = d * d;
60
+ // scale to 1e18: result = scoreNum * 1e18 / scoreDenom (rounded to nearest)
61
+ const SCALE = BigInt('1000000000000000000'); // 1e18
62
+ // Round: (scoreNum * SCALE + scoreDenom/2) / scoreDenom
63
+ const scaled = (scoreNum * SCALE + scoreDenom / 2n) / scoreDenom;
64
+ return scaled.toString();
65
+ }
66
+ //# sourceMappingURL=canonical-metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical-metrics.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-v0-evaluator/canonical-metrics.ts"],"names":[],"mappings":"AAOA,gFAAgF;AAChF,MAAM,UAAU,MAAM,CAAC,CAAS,EAAE,CAAS;IACzC,MAAM,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,GAAG,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE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AG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,qBAAqB;IACrE,oBAAoB;IACpB,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;IACpC,8BAA8B;IAC9B,gCAAgC;IAChC,oCAAoC;IACpC,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAW,oBAAoB;IACtD,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,cAAc;IACpD,MAAM,UAAU,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,4EAA4E;IAC5E,MAAM,KAAK,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,OAAO;IACpD,wDAAwD;IACxD,MAAM,MAAM,GAAG,CAAC,QAAQ,GAAG,KAAK,GAAG,UAAU,GAAG,EAAE,CAAC,GAAG,UAAU,CAAC;IACjE,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Availability checks for prediction.v0.
3
+ *
4
+ * §6.7 of spec/2026-04-20-prediction-v0-pis-phase-1-design.md
5
+ */
6
+ import type { Check } from '../types.js';
7
+ import type { SpanningResult } from '../../../../venues/chainlink/client.js';
8
+ export declare function checkOracleReachable<T>(fetch: () => Promise<T>): Promise<Check>;
9
+ export declare function checkOracleRoundCoversResolveTs(result: Pick<SpanningResult, 'spanning'>): Check;
@@ -0,0 +1,23 @@
1
+ export async function checkOracleReachable(fetch) {
2
+ try {
3
+ await fetch();
4
+ return { name: 'availability.oracle_reachable', status: 'PASS' };
5
+ }
6
+ catch (err) {
7
+ return {
8
+ name: 'availability.oracle_reachable',
9
+ status: 'FAIL',
10
+ detail: { message: err instanceof Error ? err.message : String(err) },
11
+ };
12
+ }
13
+ }
14
+ export function checkOracleRoundCoversResolveTs(result) {
15
+ return {
16
+ name: 'availability.oracle_round_covers_resolve_ts',
17
+ status: result.spanning ? 'PASS' : 'SKIP',
18
+ detail: result.spanning
19
+ ? undefined
20
+ : 'No Chainlink round with updatedAt > resolveTs yet; retry later.',
21
+ };
22
+ }
23
+ //# sourceMappingURL=availability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"availability.js","sourceRoot":"","sources":["../../../../../src/restorer/impls/prediction-v0-evaluator/checks/availability.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,KAAuB;IAEvB,IAAI,CAAC;QACH,MAAM,KAAK,EAAE,CAAC;QACd,OAAO,EAAE,IAAI,EAAE,+BAA+B,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACnE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,IAAI,EAAE,+BAA+B;YACrC,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,EAAE,OAAO,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;SACtE,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC7C,MAAwC;IAExC,OAAO;QACL,IAAI,EAAE,6CAA6C;QACnD,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;QACzC,MAAM,EAAE,MAAM,CAAC,QAAQ;YACrB,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,iEAAiE;KACtE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Check } from '../types.js';
2
+ import type { Window } from '../../../../types/desired-state.js';
3
+ export declare function checkSubmissionWithinWindow(submittedAt: number, window: Window): Check;
@@ -0,0 +1,13 @@
1
+ export function checkSubmissionWithinWindow(submittedAt, window) {
2
+ const within = submittedAt >= window.startTs && submittedAt <= window.endTs;
3
+ return {
4
+ name: 'eligibility.submission_within_window',
5
+ status: within ? 'PASS' : 'FAIL',
6
+ detail: within ? undefined : {
7
+ submittedAt,
8
+ startTs: window.startTs,
9
+ endTs: window.endTs,
10
+ },
11
+ };
12
+ }
13
+ //# sourceMappingURL=eligibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eligibility.js","sourceRoot":"","sources":["../../../../../src/restorer/impls/prediction-v0-evaluator/checks/eligibility.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,2BAA2B,CACzC,WAAmB,EACnB,MAAc;IAEd,MAAM,MAAM,GAAG,WAAW,IAAI,MAAM,CAAC,OAAO,IAAI,WAAW,IAAI,MAAM,CAAC,KAAK,CAAC;IAC5E,OAAO;QACL,IAAI,EAAE,sCAAsC;QAC5C,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;QAChC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;YAC3B,WAAW;YACX,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { Check } from '../types.js';
2
+ import type { PredictionV0Intent, PredictionSubmissionManifest } from '../../../../types/prediction.js';
3
+ export declare function checkWindowBounds(intent: PredictionV0Intent): Check;
4
+ export declare function checkManifestFieldsPresent(prediction: PredictionSubmissionManifest['prediction']): Check;
5
+ export declare function checkManifestSignature(canonicalHash: `0x${string}`, signature: PredictionSubmissionManifest['signature']): Promise<Check>;
6
+ /** Verify the restorer's claimed intent CID matches the on-chain request. */
7
+ export declare function checkIntentRef(manifestIntentCid: string, expectedIntentCid: string): Check;
@@ -0,0 +1,93 @@
1
+ import { recoverAddress } from 'viem';
2
+ /**
3
+ * Window-bounds integrity. We no longer pin an exact duration — the schema
4
+ * enforces sane min/max bounds (1min ≤ window ≤ 24h; 0 ≤ resolveGap ≤ 1h),
5
+ * so this check just re-verifies those invariants at eval time in case the
6
+ * manifest was built against an older schema version.
7
+ */
8
+ const MIN_WINDOW_MS = 60_000;
9
+ const MAX_WINDOW_MS = 86_400_000;
10
+ const MAX_RESOLVE_GAP_MS = 3_600_000;
11
+ export function checkWindowBounds(intent) {
12
+ const wDelta = intent.window.endTs - intent.window.startTs;
13
+ if (wDelta < MIN_WINDOW_MS || wDelta > MAX_WINDOW_MS) {
14
+ return {
15
+ name: 'integrity.window_bounds',
16
+ status: 'FAIL',
17
+ detail: {
18
+ reason: 'window out of bounds',
19
+ got: wDelta,
20
+ min: MIN_WINDOW_MS,
21
+ max: MAX_WINDOW_MS,
22
+ },
23
+ };
24
+ }
25
+ const rDelta = intent.spec.question.resolveTs - intent.window.endTs;
26
+ if (rDelta < 0 || rDelta > MAX_RESOLVE_GAP_MS) {
27
+ return {
28
+ name: 'integrity.window_bounds',
29
+ status: 'FAIL',
30
+ detail: {
31
+ reason: 'resolve gap out of bounds',
32
+ got: rDelta,
33
+ min: 0,
34
+ max: MAX_RESOLVE_GAP_MS,
35
+ },
36
+ };
37
+ }
38
+ return { name: 'integrity.window_bounds', status: 'PASS' };
39
+ }
40
+ export function checkManifestFieldsPresent(prediction) {
41
+ const p = Number(prediction.probability);
42
+ if (!Number.isFinite(p) || p < 0 || p > 1) {
43
+ return {
44
+ name: 'integrity.manifest_fields_present',
45
+ status: 'FAIL',
46
+ detail: { field: 'probability', got: prediction.probability },
47
+ };
48
+ }
49
+ if (!prediction.modelId || prediction.modelId.length === 0) {
50
+ return {
51
+ name: 'integrity.manifest_fields_present',
52
+ status: 'FAIL',
53
+ detail: { field: 'modelId' },
54
+ };
55
+ }
56
+ if (!Number.isInteger(prediction.submittedAt)) {
57
+ return {
58
+ name: 'integrity.manifest_fields_present',
59
+ status: 'FAIL',
60
+ detail: { field: 'submittedAt' },
61
+ };
62
+ }
63
+ return { name: 'integrity.manifest_fields_present', status: 'PASS' };
64
+ }
65
+ export async function checkManifestSignature(canonicalHash, signature) {
66
+ if (signature.algo !== 'secp256k1') {
67
+ return { name: 'integrity.manifest_signature', status: 'FAIL', detail: 'non-secp256k1 signature' };
68
+ }
69
+ if (signature.hash !== canonicalHash) {
70
+ return { name: 'integrity.manifest_signature', status: 'FAIL', detail: 'hash mismatch' };
71
+ }
72
+ try {
73
+ const recovered = await recoverAddress({ hash: canonicalHash, signature: signature.sig });
74
+ const ok = recovered.toLowerCase() === signature.signer.toLowerCase();
75
+ return {
76
+ name: 'integrity.manifest_signature',
77
+ status: ok ? 'PASS' : 'FAIL',
78
+ detail: ok ? undefined : { recovered, expected: signature.signer },
79
+ };
80
+ }
81
+ catch (err) {
82
+ return { name: 'integrity.manifest_signature', status: 'FAIL', detail: String(err) };
83
+ }
84
+ }
85
+ /** Verify the restorer's claimed intent CID matches the on-chain request. */
86
+ export function checkIntentRef(manifestIntentCid, expectedIntentCid) {
87
+ return {
88
+ name: 'integrity.intent_ref',
89
+ status: manifestIntentCid === expectedIntentCid ? 'PASS' : 'FAIL',
90
+ detail: manifestIntentCid === expectedIntentCid ? undefined : { manifestIntentCid, expectedIntentCid },
91
+ };
92
+ }
93
+ //# sourceMappingURL=integrity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integrity.js","sourceRoot":"","sources":["../../../../../src/restorer/impls/prediction-v0-evaluator/checks/integrity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAItC;;;;;GAKG;AACH,MAAM,aAAa,GAAG,MAAM,CAAC;AAC7B,MAAM,aAAa,GAAG,UAAU,CAAC;AACjC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAErC,MAAM,UAAU,iBAAiB,CAAC,MAA0B;IAC1D,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;IAC3D,IAAI,MAAM,GAAG,aAAa,IAAI,MAAM,GAAG,aAAa,EAAE,CAAC;QACrD,OAAO;YACL,IAAI,EAAE,yBA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AC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,EAAE,IAAI,EAAE,8BAA8B,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IACvF,CAAC;AACH,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,cAAc,CAAC,iBAAyB,EAAE,iBAAyB;IACjF,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,MAAM,EAAE,iBAAiB,KAAK,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;QACjE,MAAM,EAAE,iBAAiB,KAAK,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,iBAAiB,EAAE;KACvG,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Check } from '../types.js';
2
+ import type { PredictionV0Intent } from '../../../../types/prediction.js';
3
+ export declare function checkQuestionKindSupported(question: PredictionV0Intent['spec']['question'] | {
4
+ kind: string;
5
+ }): Check;
@@ -0,0 +1,20 @@
1
+ export function checkQuestionKindSupported(question) {
2
+ if (question.kind === 'threshold') {
3
+ const op = question.operator;
4
+ const supported = ['GT', 'GTE', 'LT', 'LTE'].includes(op);
5
+ return {
6
+ name: 'spec.question_kind_supported',
7
+ status: supported ? 'PASS' : 'FAIL',
8
+ detail: supported ? undefined : { operator: op },
9
+ };
10
+ }
11
+ if (question.kind === 'range') {
12
+ return { name: 'spec.question_kind_supported', status: 'PASS' };
13
+ }
14
+ return {
15
+ name: 'spec.question_kind_supported',
16
+ status: 'FAIL',
17
+ detail: { kind: question.kind },
18
+ };
19
+ }
20
+ //# sourceMappingURL=spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec.js","sourceRoot":"","sources":["../../../../../src/restorer/impls/prediction-v0-evaluator/checks/spec.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,0BAA0B,CACxC,QAAmE;IAEnE,IAAI,QAAQ,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAClC,MAAM,EAAE,GAAI,QAAgB,CAAC,QAAQ,CAAC;QACtC,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC1D,OAAO;YACL,IAAI,EAAE,8BAA8B;YACpC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;YACnC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;SACjD,CAAC;IACJ,CAAC;IACD,IAAI,QAAQ,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC9B,OAAO,EAAE,IAAI,EAAE,8BAA8B,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAClE,CAAC;IACD,OAAO;QACL,IAAI,EAAE,8BAA8B;QACpC,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE;KAChC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { RestorerImpl, RestorationContext, RestorationOutput } from '../../types.js';
2
+ import type { DesiredState } from '../../../types/desired-state.js';
3
+ import { type SpanningResult } from '../../../venues/chainlink/client.js';
4
+ export interface PredictionV0EvaluatorConfig {
5
+ /** Evaluator's private key — used to sign the verdict manifest. */
6
+ evaluatorPk: `0x${string}`;
7
+ /** Evaluator's Safe multisig address — written into verdict.evaluator.safeAddress. */
8
+ evaluatorSafeAddress: `0x${string}`;
9
+ rpcUrl?: string;
10
+ _testDeps?: {
11
+ oraclePriceAtResolveTs?: (feed: `0x${string}`, resolveTs: number) => Promise<SpanningResult>;
12
+ /** Override the intentCid we expect to match — bypasses on-chain derivation for tests. */
13
+ expectedIntentCid?: string;
14
+ };
15
+ }
16
+ export declare class PredictionV0Evaluator implements RestorerImpl {
17
+ private readonly config;
18
+ readonly name = "prediction-v0-evaluator";
19
+ readonly version = "1.0.0";
20
+ constructor(config: PredictionV0EvaluatorConfig);
21
+ supports(ctx: {
22
+ kind: string;
23
+ type?: 'restoration' | 'evaluation';
24
+ }): boolean;
25
+ canAttempt(intent: DesiredState): Promise<{
26
+ ok: true;
27
+ } | {
28
+ ok: false;
29
+ reason: string;
30
+ }>;
31
+ run(ctx: RestorationContext): Promise<RestorationOutput>;
32
+ }
33
+ export default PredictionV0Evaluator;
@@ -0,0 +1,208 @@
1
+ /**
2
+ * prediction-v0-evaluator — deterministic verifier for prediction.v0.
3
+ *
4
+ * §6 of spec/2026-04-20-prediction-v0-pis-phase-1-design.md
5
+ *
6
+ * Pipeline: availability → eligibility → integrity → spec → verdict.
7
+ * Score: brier.v1 scaled to 1e18 fixed-point.
8
+ */
9
+ import { writeFileSync } from 'node:fs';
10
+ import { join } from 'node:path';
11
+ import { createPublicClient, http, keccak256, stringToHex } from 'viem';
12
+ import { baseSepolia, base } from 'viem/chains';
13
+ import { privateKeyToAccount } from 'viem/accounts';
14
+ import { PredictionV0IntentSchema, PredictionSubmissionManifestSchema, } from '../../../types/prediction.js';
15
+ import { oraclePriceAtResolveTs, scaleToDecimal, } from '../../../venues/chainlink/client.js';
16
+ import { resolveGroundTruth } from './canonical-metrics.js';
17
+ import { computeScore } from './score.js';
18
+ import { checkOracleReachable, checkOracleRoundCoversResolveTs } from './checks/availability.js';
19
+ import { checkSubmissionWithinWindow } from './checks/eligibility.js';
20
+ import { checkWindowBounds, checkManifestFieldsPresent, checkManifestSignature, checkIntentRef, } from './checks/integrity.js';
21
+ import { checkQuestionKindSupported } from './checks/spec.js';
22
+ function parseRestorationSubmissionManifest(manifestJson) {
23
+ const raw = JSON.parse(manifestJson);
24
+ const direct = PredictionSubmissionManifestSchema.safeParse(raw);
25
+ if (direct.success)
26
+ return direct.data;
27
+ if (raw['schemaVersion'] !== 'portfolio.v0.manifest.v1') {
28
+ return PredictionSubmissionManifestSchema.parse(raw);
29
+ }
30
+ const gating = raw['gating'];
31
+ const informational = raw['informational'];
32
+ const oracleSnapshot = informational?.['oracleSnapshot'];
33
+ const normalized = {
34
+ schemaVersion: 'prediction.v0.submission.v1',
35
+ generatedAt: raw['generatedAt'],
36
+ intent: raw['intent'],
37
+ restorer: raw['restorer'],
38
+ window: raw['window'],
39
+ prediction: {
40
+ probability: String(gating?.['probability'] ?? ''),
41
+ submittedAt: Number(gating?.['submittedAt']),
42
+ modelId: String(gating?.['modelId'] ?? ''),
43
+ },
44
+ ...(oracleSnapshot && typeof oracleSnapshot === 'object'
45
+ ? { oracleSnapshot }
46
+ : {}),
47
+ signature: raw['signature'],
48
+ };
49
+ return PredictionSubmissionManifestSchema.parse(normalized);
50
+ }
51
+ export class PredictionV0Evaluator {
52
+ config;
53
+ name = 'prediction-v0-evaluator';
54
+ version = '1.0.0';
55
+ constructor(config) {
56
+ this.config = config;
57
+ }
58
+ supports(ctx) {
59
+ return ctx.kind === 'prediction.v0' && ctx.type === 'evaluation';
60
+ }
61
+ async canAttempt(intent) {
62
+ if (intent.spec?.kind !== 'prediction.v0')
63
+ return { ok: false, reason: 'spec.kind is not prediction.v0' };
64
+ if (intent.type !== 'evaluation')
65
+ return { ok: false, reason: 'type is not evaluation' };
66
+ if (!intent.restorationRequestId)
67
+ return { ok: false, reason: 'restorationRequestId is required' };
68
+ if (typeof intent.context?.['restorationResult'] !== 'string') {
69
+ return { ok: false, reason: 'context.restorationResult required' };
70
+ }
71
+ return { ok: true };
72
+ }
73
+ async run(ctx) {
74
+ const { intent, workingDir, log } = ctx;
75
+ // Support _testDeps injection from ctx (test) or config (constructor).
76
+ const testDeps = ctx._testDeps ?? this.config._testDeps;
77
+ // 1. Parse intent — same spec the restorer ran under
78
+ const predictionIntent = PredictionV0IntentSchema.parse(intent);
79
+ const { feed, venue } = predictionIntent.spec.oracle;
80
+ // 2. Parse restorer's manifest from inlined context
81
+ const manifestJson = intent.context['restorationResult'];
82
+ const manifest = parseRestorationSubmissionManifest(manifestJson);
83
+ // 3. Fetch Chainlink spanning round
84
+ let spanning;
85
+ if (testDeps?.oraclePriceAtResolveTs) {
86
+ spanning = await testDeps.oraclePriceAtResolveTs(feed, predictionIntent.spec.question.resolveTs);
87
+ }
88
+ else {
89
+ const expectedChainId = venue === 'chainlink-base' ? 8453 : 84532;
90
+ const chain = venue === 'chainlink-base' ? base : baseSepolia;
91
+ const publicClient = createPublicClient({
92
+ chain,
93
+ transport: http(this.config.rpcUrl),
94
+ });
95
+ const actualChainId = await publicClient.getChainId();
96
+ if (actualChainId !== expectedChainId) {
97
+ throw new Error(`oracle venue mismatch: spec says ${venue} (chainId ${expectedChainId}) but RPC chainId is ${actualChainId}`);
98
+ }
99
+ spanning = await oraclePriceAtResolveTs(feed, predictionIntent.spec.question.resolveTs, publicClient);
100
+ }
101
+ // 4. Run checks (order matters: availability → eligibility → integrity → spec)
102
+ const checks = [];
103
+ // availability — oracle reachable (already fetched above; re-wrap to surface errors)
104
+ checks.push(await checkOracleReachable(async () => spanning));
105
+ checks.push(checkOracleRoundCoversResolveTs(spanning));
106
+ // eligibility
107
+ checks.push(checkSubmissionWithinWindow(manifest.prediction.submittedAt, predictionIntent.window));
108
+ // integrity
109
+ checks.push(checkWindowBounds(predictionIntent));
110
+ checks.push(checkManifestFieldsPresent(manifest.prediction));
111
+ checks.push(await checkManifestSignature(manifest.signature.hash, manifest.signature));
112
+ checks.push(checkIntentRef(manifest.intent.cid, testDeps?.expectedIntentCid ?? manifest.intent.cid));
113
+ // spec
114
+ checks.push(checkQuestionKindSupported(predictionIntent.spec.question));
115
+ // 5. Derive verdict
116
+ const verdict = deriveVerdict(checks);
117
+ // 6. Derive ground truth + score
118
+ const priceAtResolve = scaleToDecimal(spanning.round.answer, spanning.round.decimals);
119
+ const groundTruth = resolveGroundTruth(predictionIntent.spec.question, priceAtResolve);
120
+ const { score, scoreBasis, scoreVersion } = computeScore(verdict, manifest.prediction.probability, groundTruth);
121
+ // 7. Assemble + sign verdict manifest
122
+ const evaluatorAccount = privateKeyToAccount(this.config.evaluatorPk);
123
+ const verdictManifestBase = {
124
+ schemaVersion: 'prediction.v0.verdict.v1',
125
+ generatedAt: Date.now(),
126
+ intent: manifest.intent,
127
+ evaluator: { safeAddress: this.config.evaluatorSafeAddress, agentEoa: evaluatorAccount.address },
128
+ window: predictionIntent.window,
129
+ verdict,
130
+ score,
131
+ scoreBasis,
132
+ scoreVersion,
133
+ oracleReading: {
134
+ feed: feed,
135
+ roundId: String(spanning.round.roundId),
136
+ answer: String(spanning.round.answer),
137
+ updatedAt: spanning.round.updatedAt,
138
+ ...(spanning.nextRound ? { nextRoundUpdatedAt: spanning.nextRound.updatedAt } : {}),
139
+ },
140
+ claimed: {
141
+ probability: manifest.prediction.probability,
142
+ submittedAt: manifest.prediction.submittedAt,
143
+ modelId: manifest.prediction.modelId,
144
+ submissionManifestCid: 'inline',
145
+ },
146
+ groundTruth,
147
+ checks,
148
+ };
149
+ const canonical = JSON.stringify(verdictManifestBase);
150
+ const hash = keccak256(stringToHex(canonical));
151
+ // Raw ECDSA — no EIP-191 prefix. recoverAddress (not recoverMessageAddress) on verify.
152
+ const sig = await evaluatorAccount.sign({ hash });
153
+ const verdictManifest = {
154
+ ...verdictManifestBase,
155
+ signature: { algo: 'secp256k1', signer: evaluatorAccount.address, hash, sig },
156
+ };
157
+ writeFileSync(join(workingDir, 'verdict.json'), JSON.stringify(verdictManifest, null, 2));
158
+ log({ level: 'info', msg: 'prediction-v0-evaluator: verdict', data: { verdict, score, groundTruth } });
159
+ return {
160
+ venueRef: { name: 'chainlink' },
161
+ gating: {
162
+ verdict,
163
+ score,
164
+ scoreBasis,
165
+ groundTruth,
166
+ checkCount: checks.length,
167
+ passCount: checks.filter(c => c.status === 'PASS').length,
168
+ failCount: checks.filter(c => c.status === 'FAIL').length,
169
+ skipCount: checks.filter(c => c.status === 'SKIP').length,
170
+ },
171
+ informational: {
172
+ claimedProbability: manifest.prediction.probability,
173
+ oracleReading: verdictManifestBase.oracleReading,
174
+ },
175
+ artifacts: [
176
+ {
177
+ path: 'verdict.json',
178
+ role: 'evaluation_verdict',
179
+ metadata: { verdict, score, schemaVersion: 'prediction.v0.verdict.v1' },
180
+ access: { kind: 'open' },
181
+ },
182
+ ],
183
+ };
184
+ }
185
+ }
186
+ /**
187
+ * Derive verdict from check statuses.
188
+ * Order matters: data-availability failures precede attempt-quality failures.
189
+ */
190
+ function deriveVerdict(checks) {
191
+ // Any availability FAIL → INDETERMINATE (oracle unreachable, data gaps)
192
+ if (checks.some(c => c.name.startsWith('availability.') && c.status === 'FAIL'))
193
+ return 'INDETERMINATE';
194
+ // Any availability SKIP → INDETERMINATE (oracle not yet spanning)
195
+ if (checks.some(c => c.name.startsWith('availability.') && c.status === 'SKIP'))
196
+ return 'INDETERMINATE';
197
+ // Any eligibility FAIL → REJECTED
198
+ if (checks.some(c => c.name.startsWith('eligibility.') && c.status === 'FAIL'))
199
+ return 'REJECTED';
200
+ // Any integrity or spec FAIL → FAIL
201
+ if (checks.some(c => c.name.startsWith('integrity.') && c.status === 'FAIL') ||
202
+ checks.some(c => c.name.startsWith('spec.') && c.status === 'FAIL')) {
203
+ return 'FAIL';
204
+ }
205
+ return 'PASS';
206
+ }
207
+ export default PredictionV0Evaluator;
208
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-v0-evaluator/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,mBAAmB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,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC;QAAE,OAAO,UAAU,CAAC;IAClG,oCAAoC;IACpC,IACE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC;QACxE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,EACnE,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const SCORE_BASIS: "brier.v1";
2
+ export declare const SCORE_VERSION: "1";
3
+ export type Verdict = 'PASS' | 'FAIL' | 'REJECTED' | 'INDETERMINATE';
4
+ export declare function computeScore(verdict: Verdict, probability: string, groundTruth: 'YES' | 'NO'): {
5
+ score: string;
6
+ scoreBasis: typeof SCORE_BASIS;
7
+ scoreVersion: typeof SCORE_VERSION;
8
+ };