@jinn-network/client 0.1.0 → 0.1.1-canary.4a6ed8b2

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 (269) hide show
  1. package/README.md +98 -11
  2. package/deployments/deployment-jinn-testnet-faucet-baseSepolia-fast.json +15 -0
  3. package/dist/adapters/claim-registry/abi.d.ts +127 -0
  4. package/dist/adapters/claim-registry/abi.js +93 -0
  5. package/dist/adapters/claim-registry/abi.js.map +1 -0
  6. package/dist/adapters/claim-registry/client.d.ts +89 -0
  7. package/dist/adapters/claim-registry/client.js +205 -0
  8. package/dist/adapters/claim-registry/client.js.map +1 -0
  9. package/dist/adapters/mech/adapter.d.ts +2 -0
  10. package/dist/adapters/mech/adapter.js +110 -41
  11. package/dist/adapters/mech/adapter.js.map +1 -1
  12. package/dist/adapters/mech/contracts.d.ts +2 -0
  13. package/dist/adapters/mech/contracts.js +32 -7
  14. package/dist/adapters/mech/contracts.js.map +1 -1
  15. package/dist/adapters/mech/ipfs.d.ts +8 -0
  16. package/dist/adapters/mech/ipfs.js +12 -0
  17. package/dist/adapters/mech/ipfs.js.map +1 -1
  18. package/dist/adapters/mech/types.d.ts +20 -46
  19. package/dist/adapters/mech/types.js +16 -35
  20. package/dist/adapters/mech/types.js.map +1 -1
  21. package/dist/api/gather-status.js +11 -0
  22. package/dist/api/gather-status.js.map +1 -1
  23. package/dist/api/portfolio-v0-build.d.ts +81 -0
  24. package/dist/api/portfolio-v0-build.js +141 -0
  25. package/dist/api/portfolio-v0-build.js.map +1 -0
  26. package/dist/api/portfolio-v0-doctor.d.ts +37 -0
  27. package/dist/api/portfolio-v0-doctor.js +123 -0
  28. package/dist/api/portfolio-v0-doctor.js.map +1 -0
  29. package/dist/api/server.js +12 -0
  30. package/dist/api/server.js.map +1 -1
  31. package/dist/api/status-build.d.ts +6 -0
  32. package/dist/api/status-build.js +1 -0
  33. package/dist/api/status-build.js.map +1 -1
  34. package/dist/api/status-rollup-build.d.ts +4 -0
  35. package/dist/api/status-rollup-build.js +4 -0
  36. package/dist/api/status-rollup-build.js.map +1 -1
  37. package/dist/bin/jinn-mcp.d.ts +14 -0
  38. package/dist/bin/jinn-mcp.js +19 -0
  39. package/dist/bin/jinn-mcp.js.map +1 -0
  40. package/dist/build-meta.json +1 -1
  41. package/dist/cli/commands/auth.d.ts +3 -0
  42. package/dist/cli/commands/auth.js +236 -0
  43. package/dist/cli/commands/auth.js.map +1 -0
  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 +148 -15
  47. package/dist/cli/commands/doctor.js.map +1 -1
  48. package/dist/cli/commands/fund-requirements.js +69 -1
  49. package/dist/cli/commands/fund-requirements.js.map +1 -1
  50. package/dist/cli/commands/history.js +1 -0
  51. package/dist/cli/commands/history.js.map +1 -1
  52. package/dist/cli/commands/init.js +31 -7
  53. package/dist/cli/commands/init.js.map +1 -1
  54. package/dist/cli/commands/keys-backup.js +142 -10
  55. package/dist/cli/commands/keys-backup.js.map +1 -1
  56. package/dist/cli/commands/logs.js +28 -13
  57. package/dist/cli/commands/logs.js.map +1 -1
  58. package/dist/cli/commands/plugin-install.d.ts +3 -0
  59. package/dist/cli/commands/plugin-install.js +799 -0
  60. package/dist/cli/commands/plugin-install.js.map +1 -0
  61. package/dist/cli/commands/quickstart.d.ts +3 -0
  62. package/dist/cli/commands/quickstart.js +236 -0
  63. package/dist/cli/commands/quickstart.js.map +1 -0
  64. package/dist/cli/commands/run.js +6 -0
  65. package/dist/cli/commands/run.js.map +1 -1
  66. package/dist/cli/commands/stop.js +1 -0
  67. package/dist/cli/commands/stop.js.map +1 -1
  68. package/dist/cli/commands/submit-intent.js +79 -5
  69. package/dist/cli/commands/submit-intent.js.map +1 -1
  70. package/dist/cli/commands/update.d.ts +3 -0
  71. package/dist/cli/commands/update.js +154 -0
  72. package/dist/cli/commands/update.js.map +1 -0
  73. package/dist/cli/commands/version.js +15 -1
  74. package/dist/cli/commands/version.js.map +1 -1
  75. package/dist/cli/deployment-digest.js +20 -4
  76. package/dist/cli/deployment-digest.js.map +1 -1
  77. package/dist/cli/index.js +8 -0
  78. package/dist/cli/index.js.map +1 -1
  79. package/dist/cli/password.d.ts +15 -0
  80. package/dist/cli/password.js +29 -1
  81. package/dist/cli/password.js.map +1 -1
  82. package/dist/config.d.ts +110 -7
  83. package/dist/config.js +38 -5
  84. package/dist/config.js.map +1 -1
  85. package/dist/daemon/balance-topup-loop.d.ts +40 -0
  86. package/dist/daemon/balance-topup-loop.js +96 -0
  87. package/dist/daemon/balance-topup-loop.js.map +1 -0
  88. package/dist/daemon/daemon.d.ts +37 -0
  89. package/dist/daemon/daemon.js +98 -1
  90. package/dist/daemon/daemon.js.map +1 -1
  91. package/dist/dashboard/index.html +500 -0
  92. package/dist/earning/bootstrap.d.ts +3 -1
  93. package/dist/earning/bootstrap.js +138 -17
  94. package/dist/earning/bootstrap.js.map +1 -1
  95. package/dist/earning/contracts.d.ts +24 -0
  96. package/dist/earning/contracts.js +20 -1
  97. package/dist/earning/contracts.js.map +1 -1
  98. package/dist/earning/faucet.d.ts +15 -0
  99. package/dist/earning/faucet.js +64 -0
  100. package/dist/earning/faucet.js.map +1 -0
  101. package/dist/earning/store.d.ts +5 -0
  102. package/dist/earning/store.js +7 -3
  103. package/dist/earning/store.js.map +1 -1
  104. package/dist/errors/unauthorized-account.d.ts +10 -0
  105. package/dist/errors/unauthorized-account.js +14 -0
  106. package/dist/errors/unauthorized-account.js.map +1 -0
  107. package/dist/main.js +128 -1
  108. package/dist/main.js.map +1 -1
  109. package/dist/mcp/operator-server.d.ts +34 -0
  110. package/dist/mcp/operator-server.js +219 -0
  111. package/dist/mcp/operator-server.js.map +1 -0
  112. package/dist/operator-errors.js +11 -0
  113. package/dist/operator-errors.js.map +1 -1
  114. package/dist/preflight/claude-auth.d.ts +68 -0
  115. package/dist/preflight/claude-auth.js +171 -0
  116. package/dist/preflight/claude-auth.js.map +1 -0
  117. package/dist/restorer/engine/canonical-json.d.ts +18 -0
  118. package/dist/restorer/engine/canonical-json.js +59 -0
  119. package/dist/restorer/engine/canonical-json.js.map +1 -0
  120. package/dist/restorer/engine/claim.d.ts +69 -0
  121. package/dist/restorer/engine/claim.js +104 -0
  122. package/dist/restorer/engine/claim.js.map +1 -0
  123. package/dist/restorer/engine/delivery.d.ts +52 -0
  124. package/dist/restorer/engine/delivery.js +63 -0
  125. package/dist/restorer/engine/delivery.js.map +1 -0
  126. package/dist/restorer/engine/engine.d.ts +203 -0
  127. package/dist/restorer/engine/engine.js +658 -0
  128. package/dist/restorer/engine/engine.js.map +1 -0
  129. package/dist/restorer/engine/manifest-assembly.d.ts +67 -0
  130. package/dist/restorer/engine/manifest-assembly.js +79 -0
  131. package/dist/restorer/engine/manifest-assembly.js.map +1 -0
  132. package/dist/restorer/engine/packaging.d.ts +87 -0
  133. package/dist/restorer/engine/packaging.js +350 -0
  134. package/dist/restorer/engine/packaging.js.map +1 -0
  135. package/dist/restorer/engine/persistence.d.ts +170 -0
  136. package/dist/restorer/engine/persistence.js +381 -0
  137. package/dist/restorer/engine/persistence.js.map +1 -0
  138. package/dist/restorer/engine/recovery.d.ts +22 -0
  139. package/dist/restorer/engine/recovery.js +24 -0
  140. package/dist/restorer/engine/recovery.js.map +1 -0
  141. package/dist/restorer/engine/registry.d.ts +62 -0
  142. package/dist/restorer/engine/registry.js +73 -0
  143. package/dist/restorer/engine/registry.js.map +1 -0
  144. package/dist/restorer/engine/signing.d.ts +30 -0
  145. package/dist/restorer/engine/signing.js +39 -0
  146. package/dist/restorer/engine/signing.js.map +1 -0
  147. package/dist/restorer/engine/state.d.ts +42 -0
  148. package/dist/restorer/engine/state.js +87 -0
  149. package/dist/restorer/engine/state.js.map +1 -0
  150. package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.d.ts +64 -0
  151. package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.js +96 -0
  152. package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.js.map +1 -0
  153. package/dist/restorer/impls/claude-mcp-hyperliquid/index.d.ts +88 -0
  154. package/dist/restorer/impls/claude-mcp-hyperliquid/index.js +560 -0
  155. package/dist/restorer/impls/claude-mcp-hyperliquid/index.js.map +1 -0
  156. package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.d.ts +137 -0
  157. package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.js +865 -0
  158. package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.js.map +1 -0
  159. package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.d.ts +74 -0
  160. package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.js +74 -0
  161. package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.js.map +1 -0
  162. package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.d.ts +97 -0
  163. package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js +226 -0
  164. package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js.map +1 -0
  165. package/dist/restorer/impls/legacy-claude/index.d.ts +42 -0
  166. package/dist/restorer/impls/legacy-claude/index.js +60 -0
  167. package/dist/restorer/impls/legacy-claude/index.js.map +1 -0
  168. package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.d.ts +68 -0
  169. package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.js +117 -0
  170. package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.js.map +1 -0
  171. package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.d.ts +49 -0
  172. package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.js +91 -0
  173. package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.js.map +1 -0
  174. package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.d.ts +78 -0
  175. package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.js +274 -0
  176. package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.js.map +1 -0
  177. package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.d.ts +23 -0
  178. package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.js +49 -0
  179. package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.js.map +1 -0
  180. package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.d.ts +25 -0
  181. package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.js +44 -0
  182. package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.js.map +1 -0
  183. package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.d.ts +17 -0
  184. package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.js +43 -0
  185. package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.js.map +1 -0
  186. package/dist/restorer/impls/portfolio-v0-evaluator/index.d.ts +43 -0
  187. package/dist/restorer/impls/portfolio-v0-evaluator/index.js +431 -0
  188. package/dist/restorer/impls/portfolio-v0-evaluator/index.js.map +1 -0
  189. package/dist/restorer/impls/portfolio-v0-evaluator/score.d.ts +21 -0
  190. package/dist/restorer/impls/portfolio-v0-evaluator/score.js +32 -0
  191. package/dist/restorer/impls/portfolio-v0-evaluator/score.js.map +1 -0
  192. package/dist/restorer/impls/portfolio-v0-evaluator/types.d.ts +32 -0
  193. package/dist/restorer/impls/portfolio-v0-evaluator/types.js +8 -0
  194. package/dist/restorer/impls/portfolio-v0-evaluator/types.js.map +1 -0
  195. package/dist/restorer/impls/prediction-v0-baseline/index.d.ts +26 -0
  196. package/dist/restorer/impls/prediction-v0-baseline/index.js +82 -0
  197. package/dist/restorer/impls/prediction-v0-baseline/index.js.map +1 -0
  198. package/dist/restorer/impls/prediction-v0-baseline/strategy.d.ts +8 -0
  199. package/dist/restorer/impls/prediction-v0-baseline/strategy.js +41 -0
  200. package/dist/restorer/impls/prediction-v0-baseline/strategy.js.map +1 -0
  201. package/dist/restorer/impls/prediction-v0-baseline/types.d.ts +7 -0
  202. package/dist/restorer/impls/prediction-v0-baseline/types.js +2 -0
  203. package/dist/restorer/impls/prediction-v0-baseline/types.js.map +1 -0
  204. package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.d.ts +20 -0
  205. package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.js +66 -0
  206. package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.js.map +1 -0
  207. package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.d.ts +9 -0
  208. package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.js +23 -0
  209. package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.js.map +1 -0
  210. package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.d.ts +3 -0
  211. package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.js +13 -0
  212. package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.js.map +1 -0
  213. package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.d.ts +7 -0
  214. package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js +74 -0
  215. package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js.map +1 -0
  216. package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.d.ts +5 -0
  217. package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.js +20 -0
  218. package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.js.map +1 -0
  219. package/dist/restorer/impls/prediction-v0-evaluator/index.d.ts +33 -0
  220. package/dist/restorer/impls/prediction-v0-evaluator/index.js +179 -0
  221. package/dist/restorer/impls/prediction-v0-evaluator/index.js.map +1 -0
  222. package/dist/restorer/impls/prediction-v0-evaluator/score.d.ts +8 -0
  223. package/dist/restorer/impls/prediction-v0-evaluator/score.js +15 -0
  224. package/dist/restorer/impls/prediction-v0-evaluator/score.js.map +1 -0
  225. package/dist/restorer/impls/prediction-v0-evaluator/types.d.ts +7 -0
  226. package/dist/restorer/impls/prediction-v0-evaluator/types.js +2 -0
  227. package/dist/restorer/impls/prediction-v0-evaluator/types.js.map +1 -0
  228. package/dist/restorer/types.d.ts +62 -0
  229. package/dist/restorer/types.js +7 -0
  230. package/dist/restorer/types.js.map +1 -0
  231. package/dist/runner/claude.js +15 -0
  232. package/dist/runner/claude.js.map +1 -1
  233. package/dist/store/store.d.ts +3 -1
  234. package/dist/store/store.js +8 -0
  235. package/dist/store/store.js.map +1 -1
  236. package/dist/tx-retry.js +11 -1
  237. package/dist/tx-retry.js.map +1 -1
  238. package/dist/types/desired-state.d.ts +53 -0
  239. package/dist/types/desired-state.js +20 -0
  240. package/dist/types/desired-state.js.map +1 -1
  241. package/dist/types/index.d.ts +3 -1
  242. package/dist/types/index.js +3 -1
  243. package/dist/types/index.js.map +1 -1
  244. package/dist/types/portfolio.d.ts +1000 -0
  245. package/dist/types/portfolio.js +168 -0
  246. package/dist/types/portfolio.js.map +1 -0
  247. package/dist/types/prediction.d.ts +751 -0
  248. package/dist/types/prediction.js +128 -0
  249. package/dist/types/prediction.js.map +1 -0
  250. package/dist/venues/chainlink/client.d.ts +99 -0
  251. package/dist/venues/chainlink/client.js +130 -0
  252. package/dist/venues/chainlink/client.js.map +1 -0
  253. package/dist/venues/chainlink/feeds.d.ts +8 -0
  254. package/dist/venues/chainlink/feeds.js +9 -0
  255. package/dist/venues/chainlink/feeds.js.map +1 -0
  256. package/dist/venues/hyperliquid/account-value.d.ts +30 -0
  257. package/dist/venues/hyperliquid/account-value.js +30 -0
  258. package/dist/venues/hyperliquid/account-value.js.map +1 -0
  259. package/dist/venues/hyperliquid/client.d.ts +63 -0
  260. package/dist/venues/hyperliquid/client.js +135 -0
  261. package/dist/venues/hyperliquid/client.js.map +1 -0
  262. package/dist/venues/hyperliquid/grid.d.ts +36 -0
  263. package/dist/venues/hyperliquid/grid.js +61 -0
  264. package/dist/venues/hyperliquid/grid.js.map +1 -0
  265. package/dist/venues/hyperliquid/types.d.ts +81 -0
  266. package/dist/venues/hyperliquid/types.js +8 -0
  267. package/dist/venues/hyperliquid/types.js.map +1 -0
  268. package/package.json +18 -3
  269. package/skills/jinn-operator/SKILL.md +213 -0
@@ -0,0 +1,82 @@
1
+ /**
2
+ * prediction-v0-baseline — reference RestorerImpl for prediction.v0.
3
+ *
4
+ * §5 of spec/2026-04-20-prediction-v0-pis-phase-1-design.md
5
+ */
6
+ import { writeFileSync } from 'node:fs';
7
+ import { join } from 'node:path';
8
+ import { createPublicClient, http } from 'viem';
9
+ import { baseSepolia, base } from 'viem/chains';
10
+ import { PredictionV0IntentSchema } from '../../../types/prediction.js';
11
+ import { readChainlinkLatest, scaleToDecimal, } from '../../../venues/chainlink/client.js';
12
+ import { spotCarryPredict } from './strategy.js';
13
+ export class PredictionV0BaselineImpl {
14
+ config;
15
+ name = 'prediction-v0-baseline';
16
+ version = '1.0.0';
17
+ constructor(config = {}) {
18
+ this.config = config;
19
+ }
20
+ supports(ctx) {
21
+ return ctx.kind === 'prediction.v0' && ctx.type !== 'evaluation';
22
+ }
23
+ async canAttempt(intent) {
24
+ const parsed = PredictionV0IntentSchema.safeParse(intent);
25
+ if (!parsed.success)
26
+ return { ok: false, reason: `Invalid prediction.v0 intent: ${parsed.error.message}` };
27
+ if (Date.now() > parsed.data.window.endTs) {
28
+ return { ok: false, reason: 'window already closed' };
29
+ }
30
+ return { ok: true };
31
+ }
32
+ async run(ctx) {
33
+ const { intent, workingDir, log } = ctx;
34
+ const parsed = PredictionV0IntentSchema.parse(intent);
35
+ const { feed, venue } = parsed.spec.oracle;
36
+ log({ level: 'info', msg: 'prediction-v0-baseline: starting', data: { feed, venue } });
37
+ // Read the feed (injection seam for tests)
38
+ const read = this.config._testDeps?.readChainlink;
39
+ let snapshot;
40
+ if (read) {
41
+ snapshot = await read(feed);
42
+ }
43
+ else {
44
+ const expectedChainId = venue === 'chainlink-base' ? 8453 : 84532;
45
+ const chain = venue === 'chainlink-base' ? base : baseSepolia;
46
+ const pc = createPublicClient({ chain, transport: http(this.config.rpcUrl) });
47
+ const actualChainId = await pc.getChainId();
48
+ if (actualChainId !== expectedChainId) {
49
+ throw new Error(`oracle venue mismatch: spec says ${venue} (chainId ${expectedChainId}) but RPC chainId is ${actualChainId}`);
50
+ }
51
+ snapshot = await readChainlinkLatest(feed, pc);
52
+ }
53
+ const currentPrice = scaleToDecimal(snapshot.answer, snapshot.decimals);
54
+ const { probability, modelId } = spotCarryPredict(parsed, currentPrice);
55
+ const submittedAt = Date.now();
56
+ const prediction = { probability, submittedAt, modelId };
57
+ writeFileSync(join(workingDir, 'prediction.json'), JSON.stringify(prediction, null, 2));
58
+ log({ level: 'info', msg: 'prediction-v0-baseline: submitted', data: { currentPrice, probability, modelId } });
59
+ return {
60
+ venueRef: { name: 'chainlink' },
61
+ gating: {
62
+ probability,
63
+ submittedAt: String(submittedAt),
64
+ modelId,
65
+ },
66
+ informational: {
67
+ oracleSnapshot: {
68
+ feed,
69
+ roundId: String(snapshot.roundId),
70
+ answer: String(snapshot.answer),
71
+ updatedAt: snapshot.updatedAt,
72
+ },
73
+ currentPrice,
74
+ },
75
+ artifacts: [
76
+ { path: 'prediction.json', role: 'prediction_submission' },
77
+ ],
78
+ };
79
+ }
80
+ }
81
+ export default PredictionV0BaselineImpl;
82
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/restorer/impls/prediction-v0-baseline/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAIhD,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,mBAAmB,EACnB,cAAc,GAEf,MAAM,qCAAqC,CAAC;AAC7C,OAAO,E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,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAExF,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,mCAAmC,EAAE,IAAI,EAAE,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;QAE/G,OAAO;YACL,QAAQ,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;YAC/B,MAAM,EAAE;gBACN,WAAW;gBACX,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC;gBAChC,OAAO;aACR;YACD,aAAa,EAAE;gBACb,cAAc,EAAE;oBACd,IAAI;oBACJ,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;oBACjC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;oBAC/B,SAAS,EAAE,QAAQ,CAAC,SAAS;iBAC9B;gBACD,YAAY;aACb;YACD,SAAS,EAAE;gBACT,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,uBAAuB,EAAE;aAC3D;SACF,CAAC;IACJ,CAAC;CACF;AAED,eAAe,wBAAwB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Spot-carry baseline — "current state tends to persist."
3
+ *
4
+ * §5.3 of spec/2026-04-20-prediction-v0-pis-phase-1-design.md
5
+ */
6
+ import type { PredictionV0Intent } from '../../../types/prediction.js';
7
+ import type { StrategyPrediction } from './types.js';
8
+ export declare function spotCarryPredict(intent: PredictionV0Intent, currentPrice: string): StrategyPrediction;
@@ -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,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;IACzC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;IACzC,IAAI,GAAG,CA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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,EAAE,CAAC,IAAI,GAAG,CAAC;IAClD,MAAM,GAAG,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC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AC9B,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,74 @@
1
+ import { recoverAddress } from 'viem';
2
+ export function checkWindowBounds(intent) {
3
+ const wDelta = intent.window.endTs - intent.window.startTs;
4
+ if (wDelta !== 3_600_000) {
5
+ return {
6
+ name: 'integrity.window_bounds',
7
+ status: 'FAIL',
8
+ detail: { expected: 3_600_000, got: wDelta },
9
+ };
10
+ }
11
+ const rDelta = intent.spec.question.resolveTs - intent.window.endTs;
12
+ if (rDelta !== 900_000) {
13
+ return {
14
+ name: 'integrity.window_bounds',
15
+ status: 'FAIL',
16
+ detail: { expected: 900_000, got: rDelta, field: 'resolveTs' },
17
+ };
18
+ }
19
+ return { name: 'integrity.window_bounds', status: 'PASS' };
20
+ }
21
+ export function checkManifestFieldsPresent(prediction) {
22
+ const p = Number(prediction.probability);
23
+ if (!Number.isFinite(p) || p < 0 || p > 1) {
24
+ return {
25
+ name: 'integrity.manifest_fields_present',
26
+ status: 'FAIL',
27
+ detail: { field: 'probability', got: prediction.probability },
28
+ };
29
+ }
30
+ if (!prediction.modelId || prediction.modelId.length === 0) {
31
+ return {
32
+ name: 'integrity.manifest_fields_present',
33
+ status: 'FAIL',
34
+ detail: { field: 'modelId' },
35
+ };
36
+ }
37
+ if (!Number.isInteger(prediction.submittedAt)) {
38
+ return {
39
+ name: 'integrity.manifest_fields_present',
40
+ status: 'FAIL',
41
+ detail: { field: 'submittedAt' },
42
+ };
43
+ }
44
+ return { name: 'integrity.manifest_fields_present', status: 'PASS' };
45
+ }
46
+ export async function checkManifestSignature(canonicalHash, signature) {
47
+ if (signature.algo !== 'secp256k1') {
48
+ return { name: 'integrity.manifest_signature', status: 'FAIL', detail: 'non-secp256k1 signature' };
49
+ }
50
+ if (signature.hash !== canonicalHash) {
51
+ return { name: 'integrity.manifest_signature', status: 'FAIL', detail: 'hash mismatch' };
52
+ }
53
+ try {
54
+ const recovered = await recoverAddress({ hash: canonicalHash, signature: signature.sig });
55
+ const ok = recovered.toLowerCase() === signature.signer.toLowerCase();
56
+ return {
57
+ name: 'integrity.manifest_signature',
58
+ status: ok ? 'PASS' : 'FAIL',
59
+ detail: ok ? undefined : { recovered, expected: signature.signer },
60
+ };
61
+ }
62
+ catch (err) {
63
+ return { name: 'integrity.manifest_signature', status: 'FAIL', detail: String(err) };
64
+ }
65
+ }
66
+ /** Verify the restorer's claimed intent CID matches the on-chain request. */
67
+ export function checkIntentRef(manifestIntentCid, expectedIntentCid) {
68
+ return {
69
+ name: 'integrity.intent_ref',
70
+ status: manifestIntentCid === expectedIntentCid ? 'PASS' : 'FAIL',
71
+ detail: manifestIntentCid === expectedIntentCid ? undefined : { manifestIntentCid, expectedIntentCid },
72
+ };
73
+ }
74
+ //# 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,MAAM,UAAU,iBAAiB,CAAC,MAA0B;IAC1D,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;IAC3D,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO;YACL,IAAI,EAAE,yBAAyB;YAC/B,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE;SAC7C,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;IACpE,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;QACvB,OAAO;YACL,IAAI,EAAE,yBAAyB;YAC/B,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE;SAC/D,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,yBAAyB,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,UAAsD;IAEtD,MAAM,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IACzC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAA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C,GAAoB,EAAE,CAAC,CAAC;QAC3G,MAAM,EAAE,GAAG,SAAS,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACtE,OAAO;YACL,IAAI,EAAE,8BAA8B;YACpC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;YAC5B,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,MAAM,EAAE;SACnE,CAAC;IACJ,CAAC;IAAC,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;