@jinn-network/client 0.1.7 → 0.1.8-canary.09a3b2f6

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 (438) hide show
  1. package/README.md +67 -1
  2. package/dist/adapters/mech/adapter.d.ts +39 -2
  3. package/dist/adapters/mech/adapter.js +178 -20
  4. package/dist/adapters/mech/adapter.js.map +1 -1
  5. package/dist/adapters/mech/contracts.d.ts +22 -1
  6. package/dist/adapters/mech/contracts.js +96 -52
  7. package/dist/adapters/mech/contracts.js.map +1 -1
  8. package/dist/adapters/mech/safe-revert.d.ts +4 -0
  9. package/dist/adapters/mech/safe-revert.js +5 -1
  10. package/dist/adapters/mech/safe-revert.js.map +1 -1
  11. package/dist/adapters/mech/safe.d.ts +1 -1
  12. package/dist/adapters/mech/safe.js +10 -4
  13. package/dist/adapters/mech/safe.js.map +1 -1
  14. package/dist/adapters/mech/types.d.ts +6 -1
  15. package/dist/adapters/mech/types.js.map +1 -1
  16. package/dist/agent/operator-claude.js +8 -0
  17. package/dist/agent/operator-claude.js.map +1 -1
  18. package/dist/api/activity-events-endpoint.d.ts +14 -0
  19. package/dist/api/activity-events-endpoint.js +59 -0
  20. package/dist/api/activity-events-endpoint.js.map +1 -0
  21. package/dist/api/bootstrap-endpoint.d.ts +1 -2
  22. package/dist/api/bootstrap-endpoint.js +42 -24
  23. package/dist/api/bootstrap-endpoint.js.map +1 -1
  24. package/dist/api/codex-doctor-endpoint.d.ts +22 -5
  25. package/dist/api/codex-doctor-endpoint.js +136 -17
  26. package/dist/api/codex-doctor-endpoint.js.map +1 -1
  27. package/dist/api/debug-report-endpoint.d.ts +27 -0
  28. package/dist/api/debug-report-endpoint.js +157 -0
  29. package/dist/api/debug-report-endpoint.js.map +1 -0
  30. package/dist/api/discovery-endpoint.d.ts +1 -0
  31. package/dist/api/discovery-endpoint.js +24 -0
  32. package/dist/api/discovery-endpoint.js.map +1 -1
  33. package/dist/api/fleet-build.d.ts +1 -7
  34. package/dist/api/fleet-build.js +0 -7
  35. package/dist/api/fleet-build.js.map +1 -1
  36. package/dist/api/gather-status.d.ts +39 -0
  37. package/dist/api/gather-status.js +181 -84
  38. package/dist/api/gather-status.js.map +1 -1
  39. package/dist/api/hermes-doctor-endpoint.d.ts +15 -7
  40. package/dist/api/hermes-doctor-endpoint.js +56 -19
  41. package/dist/api/hermes-doctor-endpoint.js.map +1 -1
  42. package/dist/api/launcher-status.d.ts +4 -2
  43. package/dist/api/launcher-status.js +11 -10
  44. package/dist/api/launcher-status.js.map +1 -1
  45. package/dist/api/launcher-tasks.d.ts +1 -1
  46. package/dist/api/launcher-tasks.js +12 -8
  47. package/dist/api/launcher-tasks.js.map +1 -1
  48. package/dist/api/loop-completion-build.d.ts +79 -0
  49. package/dist/api/loop-completion-build.js +155 -0
  50. package/dist/api/loop-completion-build.js.map +1 -0
  51. package/dist/api/operator-artifacts-endpoint.js +73 -6
  52. package/dist/api/operator-artifacts-endpoint.js.map +1 -1
  53. package/dist/api/portfolio-v0-build.d.ts +7 -1
  54. package/dist/api/portfolio-v0-build.js +6 -2
  55. package/dist/api/portfolio-v0-build.js.map +1 -1
  56. package/dist/api/prediction-v1-build.d.ts +6 -0
  57. package/dist/api/prediction-v1-build.js +3 -1
  58. package/dist/api/prediction-v1-build.js.map +1 -1
  59. package/dist/api/server.d.ts +17 -0
  60. package/dist/api/server.js +40 -1
  61. package/dist/api/server.js.map +1 -1
  62. package/dist/api/setup-endpoints.d.ts +13 -9
  63. package/dist/api/setup-endpoints.js +50 -173
  64. package/dist/api/setup-endpoints.js.map +1 -1
  65. package/dist/api/solvernets-endpoints.js +33 -63
  66. package/dist/api/solvernets-endpoints.js.map +1 -1
  67. package/dist/api/status-build.d.ts +140 -17
  68. package/dist/api/status-build.js +47 -34
  69. package/dist/api/status-build.js.map +1 -1
  70. package/dist/api/status-harness-rollup.d.ts +35 -0
  71. package/dist/api/status-harness-rollup.js +45 -0
  72. package/dist/api/status-harness-rollup.js.map +1 -0
  73. package/dist/api/status-rollup-build.d.ts +0 -4
  74. package/dist/api/status-rollup-build.js +0 -4
  75. package/dist/api/status-rollup-build.js.map +1 -1
  76. package/dist/api/task-runs-build.d.ts +8 -0
  77. package/dist/api/task-runs-build.js +5 -1
  78. package/dist/api/task-runs-build.js.map +1 -1
  79. package/dist/build-info.json +4 -4
  80. package/dist/build-meta.json +1 -1
  81. package/dist/captures/live-publisher.js +24 -4
  82. package/dist/captures/live-publisher.js.map +1 -1
  83. package/dist/captures/publish.d.ts +1 -1
  84. package/dist/chain-read-errors.d.ts +12 -0
  85. package/dist/chain-read-errors.js +26 -1
  86. package/dist/chain-read-errors.js.map +1 -1
  87. package/dist/cli/commands/codedigest-revert-check.d.ts +33 -0
  88. package/dist/cli/commands/codedigest-revert-check.js +253 -0
  89. package/dist/cli/commands/codedigest-revert-check.js.map +1 -0
  90. package/dist/cli/commands/doctor.d.ts +3 -0
  91. package/dist/cli/commands/doctor.js +35 -0
  92. package/dist/cli/commands/doctor.js.map +1 -1
  93. package/dist/cli/commands/eval.d.ts +76 -0
  94. package/dist/cli/commands/eval.js +401 -0
  95. package/dist/cli/commands/eval.js.map +1 -0
  96. package/dist/cli/commands/rewards.d.ts +2 -0
  97. package/dist/cli/commands/rewards.js +27 -0
  98. package/dist/cli/commands/rewards.js.map +1 -1
  99. package/dist/cli/commands/solver-nets.d.ts +1 -0
  100. package/dist/cli/commands/solver-nets.js +245 -22
  101. package/dist/cli/commands/solver-nets.js.map +1 -1
  102. package/dist/cli/commands/solver-plugins-block.d.ts +33 -0
  103. package/dist/cli/commands/solver-plugins-block.js +118 -0
  104. package/dist/cli/commands/solver-plugins-block.js.map +1 -0
  105. package/dist/cli/commands/solver-plugins-feedback.d.ts +72 -0
  106. package/dist/cli/commands/solver-plugins-feedback.js +262 -0
  107. package/dist/cli/commands/solver-plugins-feedback.js.map +1 -0
  108. package/dist/cli/commands/solver-plugins-read.d.ts +54 -0
  109. package/dist/cli/commands/solver-plugins-read.js +259 -0
  110. package/dist/cli/commands/solver-plugins-read.js.map +1 -0
  111. package/dist/cli/commands/solver-plugins.d.ts +35 -0
  112. package/dist/cli/commands/solver-plugins.js +399 -2
  113. package/dist/cli/commands/solver-plugins.js.map +1 -1
  114. package/dist/cli/commands/status.js +0 -1
  115. package/dist/cli/commands/status.js.map +1 -1
  116. package/dist/cli/commands/tasks.js +15 -2
  117. package/dist/cli/commands/tasks.js.map +1 -1
  118. package/dist/cli/index.js +4 -0
  119. package/dist/cli/index.js.map +1 -1
  120. package/dist/cli/task-native-readiness.d.ts +7 -0
  121. package/dist/cli/task-native-readiness.js +7 -5
  122. package/dist/cli/task-native-readiness.js.map +1 -1
  123. package/dist/config.d.ts +206 -232
  124. package/dist/config.js +289 -107
  125. package/dist/config.js.map +1 -1
  126. package/dist/daemon/ai-units-gate.d.ts +54 -0
  127. package/dist/daemon/ai-units-gate.js +83 -0
  128. package/dist/daemon/ai-units-gate.js.map +1 -0
  129. package/dist/daemon/creator.js +13 -0
  130. package/dist/daemon/creator.js.map +1 -1
  131. package/dist/daemon/daemon.d.ts +10 -0
  132. package/dist/daemon/daemon.js +205 -30
  133. package/dist/daemon/daemon.js.map +1 -1
  134. package/dist/daemon/eviction-loop.d.ts +7 -0
  135. package/dist/daemon/eviction-loop.js +16 -0
  136. package/dist/daemon/eviction-loop.js.map +1 -1
  137. package/dist/daemon/gate-logger.d.ts +9 -0
  138. package/dist/daemon/gate-logger.js +2 -0
  139. package/dist/daemon/gate-logger.js.map +1 -0
  140. package/dist/daemon/jinn-claim-loop.js +22 -4
  141. package/dist/daemon/jinn-claim-loop.js.map +1 -1
  142. package/dist/daemon/readiness-gate.d.ts +1 -4
  143. package/dist/daemon/readiness-gate.js.map +1 -1
  144. package/dist/daemon/spend-cap-gate.d.ts +40 -0
  145. package/dist/daemon/spend-cap-gate.js +46 -0
  146. package/dist/daemon/spend-cap-gate.js.map +1 -0
  147. package/dist/dashboard/assets/index-3quVQqik.js +167 -0
  148. package/dist/dashboard/assets/index-BVAWkLwY.css +1 -0
  149. package/dist/dashboard/index.html +2 -2
  150. package/dist/discovery/http.d.ts +7 -0
  151. package/dist/discovery/http.js +567 -24
  152. package/dist/discovery/http.js.map +1 -1
  153. package/dist/discovery/onchain.js +197 -5
  154. package/dist/discovery/onchain.js.map +1 -1
  155. package/dist/discovery/types.d.ts +235 -0
  156. package/dist/discovery/types.js +40 -0
  157. package/dist/discovery/types.js.map +1 -1
  158. package/dist/discovery/with-fallback.js +41 -0
  159. package/dist/discovery/with-fallback.js.map +1 -1
  160. package/dist/earning/bootstrap.d.ts +31 -3
  161. package/dist/earning/bootstrap.js +94 -22
  162. package/dist/earning/bootstrap.js.map +1 -1
  163. package/dist/earning/faucet.d.ts +1 -1
  164. package/dist/earning/faucet.js +2 -2
  165. package/dist/earning/faucet.js.map +1 -1
  166. package/dist/earning/safe-adapter.js +34 -11
  167. package/dist/earning/safe-adapter.js.map +1 -1
  168. package/dist/earning/types.d.ts +6 -6
  169. package/dist/earning/viem-clients.d.ts +11 -4
  170. package/dist/earning/viem-clients.js +14 -5
  171. package/dist/earning/viem-clients.js.map +1 -1
  172. package/dist/erc8004/identity.d.ts +19 -3
  173. package/dist/erc8004/identity.js +38 -11
  174. package/dist/erc8004/identity.js.map +1 -1
  175. package/dist/erc8004/index.d.ts +1 -1
  176. package/dist/erc8004/index.js.map +1 -1
  177. package/dist/eval/eval-harness-run.d.ts +63 -0
  178. package/dist/eval/eval-harness-run.js +123 -0
  179. package/dist/eval/eval-harness-run.js.map +1 -0
  180. package/dist/eval/orchestrator.d.ts +163 -0
  181. package/dist/eval/orchestrator.js +232 -0
  182. package/dist/eval/orchestrator.js.map +1 -0
  183. package/dist/eval/paired.d.ts +68 -0
  184. package/dist/eval/paired.js +93 -0
  185. package/dist/eval/paired.js.map +1 -0
  186. package/dist/eval/resolve-slate-tasks.d.ts +35 -0
  187. package/dist/eval/resolve-slate-tasks.js +56 -0
  188. package/dist/eval/resolve-slate-tasks.js.map +1 -0
  189. package/dist/eval/screen-discovery.d.ts +22 -0
  190. package/dist/eval/screen-discovery.js +71 -0
  191. package/dist/eval/screen-discovery.js.map +1 -0
  192. package/dist/eval/screen-progress.d.ts +41 -0
  193. package/dist/eval/screen-progress.js +60 -0
  194. package/dist/eval/screen-progress.js.map +1 -0
  195. package/dist/eval/screen-runner.d.ts +30 -0
  196. package/dist/eval/screen-runner.js +289 -0
  197. package/dist/eval/screen-runner.js.map +1 -0
  198. package/dist/eval/screen.d.ts +107 -0
  199. package/dist/eval/screen.js +159 -0
  200. package/dist/eval/screen.js.map +1 -0
  201. package/dist/eval/slope.d.ts +29 -0
  202. package/dist/eval/slope.js +46 -0
  203. package/dist/eval/slope.js.map +1 -0
  204. package/dist/eval/train-sequence.d.ts +35 -0
  205. package/dist/eval/train-sequence.js +59 -0
  206. package/dist/eval/train-sequence.js.map +1 -0
  207. package/dist/eval/wilson.d.ts +45 -0
  208. package/dist/eval/wilson.js +48 -0
  209. package/dist/eval/wilson.js.map +1 -0
  210. package/dist/events/types.d.ts +2 -2
  211. package/dist/harnesses/cost-estimates.d.ts +10 -31
  212. package/dist/harnesses/cost-estimates.js +11 -43
  213. package/dist/harnesses/cost-estimates.js.map +1 -1
  214. package/dist/harnesses/engine/canonical-json.js +5 -3
  215. package/dist/harnesses/engine/canonical-json.js.map +1 -1
  216. package/dist/harnesses/engine/engine.d.ts +37 -4
  217. package/dist/harnesses/engine/engine.js +151 -20
  218. package/dist/harnesses/engine/engine.js.map +1 -1
  219. package/dist/harnesses/engine/persistence.d.ts +38 -4
  220. package/dist/harnesses/engine/persistence.js +71 -6
  221. package/dist/harnesses/engine/persistence.js.map +1 -1
  222. package/dist/harnesses/engine/state.d.ts +9 -0
  223. package/dist/harnesses/engine/state.js +23 -10
  224. package/dist/harnesses/engine/state.js.map +1 -1
  225. package/dist/harnesses/impls/hermes-agent/adapter.d.ts +2 -0
  226. package/dist/harnesses/impls/hermes-agent/adapter.js +8 -5
  227. package/dist/harnesses/impls/hermes-agent/adapter.js.map +1 -1
  228. package/dist/harnesses/impls/hermes-agent/bootstrap.d.ts +1 -0
  229. package/dist/harnesses/impls/hermes-agent/bootstrap.js +10 -3
  230. package/dist/harnesses/impls/hermes-agent/bootstrap.js.map +1 -1
  231. package/dist/harnesses/impls/hermes-agent/config-builder.d.ts +1 -1
  232. package/dist/harnesses/impls/hermes-agent/config-builder.js +4 -2
  233. package/dist/harnesses/impls/hermes-agent/config-builder.js.map +1 -1
  234. package/dist/harnesses/impls/hermes-agent/harness.d.ts +31 -3
  235. package/dist/harnesses/impls/hermes-agent/harness.js +84 -7
  236. package/dist/harnesses/impls/hermes-agent/harness.js.map +1 -1
  237. package/dist/harnesses/impls/hermes-agent/prompt.d.ts +6 -6
  238. package/dist/harnesses/impls/hermes-agent/prompt.js +6 -6
  239. package/dist/harnesses/impls/index.d.ts +2 -0
  240. package/dist/harnesses/impls/index.js +2 -0
  241. package/dist/harnesses/impls/index.js.map +1 -1
  242. package/dist/harnesses/impls/learner/adapters/claude-code.d.ts +17 -0
  243. package/dist/harnesses/impls/learner/adapters/claude-code.js +118 -14
  244. package/dist/harnesses/impls/learner/adapters/claude-code.js.map +1 -1
  245. package/dist/harnesses/impls/learner/adapters/codex-code.d.ts +9 -0
  246. package/dist/harnesses/impls/learner/adapters/codex-code.js +30 -8
  247. package/dist/harnesses/impls/learner/adapters/codex-code.js.map +1 -1
  248. package/dist/harnesses/impls/learner/harness.d.ts +41 -1
  249. package/dist/harnesses/impls/learner/harness.js +78 -4
  250. package/dist/harnesses/impls/learner/harness.js.map +1 -1
  251. package/dist/harnesses/impls/learner/harvest.d.ts +3 -1
  252. package/dist/harnesses/impls/learner/harvest.js +30 -6
  253. package/dist/harnesses/impls/learner/harvest.js.map +1 -1
  254. package/dist/harnesses/impls/learner/plugin-path.js +1 -0
  255. package/dist/harnesses/impls/learner/plugin-path.js.map +1 -1
  256. package/dist/harnesses/impls/learner/restoration-patch.d.ts +2 -2
  257. package/dist/harnesses/impls/learner/restoration-patch.js +25 -6
  258. package/dist/harnesses/impls/learner/restoration-patch.js.map +1 -1
  259. package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.js +21 -1
  260. package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.js.map +1 -1
  261. package/dist/harnesses/impls/swe-rebench-v2-evaluator/harness.js +3 -1
  262. package/dist/harnesses/impls/swe-rebench-v2-evaluator/harness.js.map +1 -1
  263. package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.d.ts +74 -5
  264. package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.js +103 -32
  265. package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.js.map +1 -1
  266. package/dist/harnesses/impls/swe-rebench-v2-evaluator/index.d.ts +2 -2
  267. package/dist/harnesses/impls/swe-rebench-v2-evaluator/index.js +3 -1
  268. package/dist/harnesses/impls/swe-rebench-v2-evaluator/index.js.map +1 -1
  269. package/dist/harnesses/readiness-registry.d.ts +7 -0
  270. package/dist/harnesses/readiness-registry.js +9 -0
  271. package/dist/harnesses/readiness-registry.js.map +1 -1
  272. package/dist/harnesses/types.d.ts +14 -0
  273. package/dist/learner/revert-decision.d.ts +74 -0
  274. package/dist/learner/revert-decision.js +73 -0
  275. package/dist/learner/revert-decision.js.map +1 -0
  276. package/dist/learner/revert-stats.d.ts +38 -0
  277. package/dist/learner/revert-stats.js +86 -0
  278. package/dist/learner/revert-stats.js.map +1 -0
  279. package/dist/local-provider-url.d.ts +3 -0
  280. package/dist/local-provider-url.js +28 -0
  281. package/dist/local-provider-url.js.map +1 -0
  282. package/dist/main.js +199 -104
  283. package/dist/main.js.map +1 -1
  284. package/dist/mcp/get-codedigest-reward.d.ts +13 -0
  285. package/dist/mcp/get-codedigest-reward.js +23 -0
  286. package/dist/mcp/get-codedigest-reward.js.map +1 -0
  287. package/dist/mcp/server.js +23 -0
  288. package/dist/mcp/server.js.map +1 -1
  289. package/dist/observability/debug-report-assemble.d.ts +43 -0
  290. package/dist/observability/debug-report-assemble.js +80 -0
  291. package/dist/observability/debug-report-assemble.js.map +1 -0
  292. package/dist/observability/emit-event.d.ts +9 -2
  293. package/dist/observability/emit-event.js +36 -2
  294. package/dist/observability/emit-event.js.map +1 -1
  295. package/dist/observability/file-logger.d.ts +69 -0
  296. package/dist/observability/file-logger.js +177 -0
  297. package/dist/observability/file-logger.js.map +1 -0
  298. package/dist/observability/redact-secrets.d.ts +65 -0
  299. package/dist/observability/redact-secrets.js +300 -0
  300. package/dist/observability/redact-secrets.js.map +1 -0
  301. package/dist/observability/tar.d.ts +30 -0
  302. package/dist/observability/tar.js +102 -0
  303. package/dist/observability/tar.js.map +1 -0
  304. package/dist/plugins/learner/.claude-plugin/plugin.json +1 -1
  305. package/dist/plugins/learner/.codex-plugin/plugin.json +1 -1
  306. package/dist/plugins/learner/hooks/session-start +30 -1
  307. package/dist/plugins/learner/skills/learn/consolidator-prompt.md +22 -1
  308. package/dist/plugins/learner/skills/learn/promoter-prompt.md +72 -1
  309. package/dist/preflight/deployment-readiness.d.ts +147 -0
  310. package/dist/preflight/deployment-readiness.js +366 -0
  311. package/dist/preflight/deployment-readiness.js.map +1 -0
  312. package/dist/preflight/pidfile-liveness.d.ts +50 -0
  313. package/dist/preflight/pidfile-liveness.js +117 -0
  314. package/dist/preflight/pidfile-liveness.js.map +1 -0
  315. package/dist/preflight/rpc-network.d.ts +40 -0
  316. package/dist/preflight/rpc-network.js +67 -1
  317. package/dist/preflight/rpc-network.js.map +1 -1
  318. package/dist/rpc/transport.d.ts +145 -0
  319. package/dist/rpc/transport.js +319 -0
  320. package/dist/rpc/transport.js.map +1 -0
  321. package/dist/scripts/donation-consumption-acceptance.js +7 -28
  322. package/dist/scripts/donation-consumption-acceptance.js.map +1 -1
  323. package/dist/scripts/swe-rebench-v2-pytest-missing.json +16 -0
  324. package/dist/solver-nets/prediction-operator-ux.d.ts +1 -2
  325. package/dist/solver-nets/prediction-operator-ux.js +56 -53
  326. package/dist/solver-nets/prediction-operator-ux.js.map +1 -1
  327. package/dist/solver-nets/registry.d.ts +19 -1
  328. package/dist/solver-nets/registry.js +37 -24
  329. package/dist/solver-nets/registry.js.map +1 -1
  330. package/dist/solver-types/_swe-rebench-v2-held-out-slate.d.ts +76 -0
  331. package/dist/solver-types/_swe-rebench-v2-held-out-slate.js +156 -0
  332. package/dist/solver-types/_swe-rebench-v2-held-out-slate.js.map +1 -0
  333. package/dist/solver-types/_swe-rebench-v2-pool-recovery.d.ts +81 -0
  334. package/dist/solver-types/_swe-rebench-v2-pool-recovery.js +116 -0
  335. package/dist/solver-types/_swe-rebench-v2-pool-recovery.js.map +1 -0
  336. package/dist/solver-types/_swe-rebench-v2-pool.d.ts +9 -2
  337. package/dist/solver-types/_swe-rebench-v2-pool.js +15 -20
  338. package/dist/solver-types/_swe-rebench-v2-pool.js.map +1 -1
  339. package/dist/solver-types/_swe-rebench-v2-state.d.ts +24 -0
  340. package/dist/solver-types/_swe-rebench-v2-state.js +33 -0
  341. package/dist/solver-types/_swe-rebench-v2-state.js.map +1 -1
  342. package/dist/solver-types/_swe-rebench-v2-validated-pool.d.ts +116 -2
  343. package/dist/solver-types/_swe-rebench-v2-validated-pool.js +296 -21
  344. package/dist/solver-types/_swe-rebench-v2-validated-pool.js.map +1 -1
  345. package/dist/solver-types/slates/held-out-slate.swe-rebench-v2.v1.json +20 -0
  346. package/dist/solver-types/slates/held-out-slate.swe-rebench-v2.v2.json +19 -0
  347. package/dist/solver-types/slates/held-out-slate.swe-rebench-v2.v2.screening-report.json +628 -0
  348. package/dist/solver-types/solver-type.d.ts +8 -0
  349. package/dist/solver-types/swe-rebench-v2-auto.d.ts +20 -11
  350. package/dist/solver-types/swe-rebench-v2-auto.js +64 -19
  351. package/dist/solver-types/swe-rebench-v2-auto.js.map +1 -1
  352. package/dist/solver-types/swe-rebench-v2.d.ts +10 -2
  353. package/dist/solver-types/swe-rebench-v2.js +233 -13
  354. package/dist/solver-types/swe-rebench-v2.js.map +1 -1
  355. package/dist/solvernets/daemon-init.d.ts +1 -1
  356. package/dist/solvernets/daemon-init.js +19 -4
  357. package/dist/solvernets/daemon-init.js.map +1 -1
  358. package/dist/solvernets/launched-record-dispatcher.d.ts +7 -0
  359. package/dist/solvernets/launched-record-dispatcher.js +10 -4
  360. package/dist/solvernets/launched-record-dispatcher.js.map +1 -1
  361. package/dist/solvernets/registry-client-erc8004.js +40 -37
  362. package/dist/solvernets/registry-client-erc8004.js.map +1 -1
  363. package/dist/solvernets/registry-client.d.ts +6 -0
  364. package/dist/solvernets/store.d.ts +2 -2
  365. package/dist/solvernets/store.js +7 -2
  366. package/dist/solvernets/store.js.map +1 -1
  367. package/dist/spend/ai-units-config.d.ts +49 -0
  368. package/dist/spend/ai-units-config.js +34 -0
  369. package/dist/spend/ai-units-config.js.map +1 -0
  370. package/dist/spend/ai-units.d.ts +140 -0
  371. package/dist/spend/ai-units.js +229 -0
  372. package/dist/spend/ai-units.js.map +1 -0
  373. package/dist/spend/cost-surface-status.d.ts +12 -0
  374. package/dist/spend/cost-surface-status.js +24 -0
  375. package/dist/spend/cost-surface-status.js.map +1 -0
  376. package/dist/spend/credential.d.ts +39 -0
  377. package/dist/spend/credential.js +71 -0
  378. package/dist/spend/credential.js.map +1 -0
  379. package/dist/spend/daemon-config.d.ts +13 -0
  380. package/dist/spend/daemon-config.js +24 -0
  381. package/dist/spend/daemon-config.js.map +1 -0
  382. package/dist/spend/pricing.d.ts +16 -0
  383. package/dist/spend/pricing.js +26 -0
  384. package/dist/spend/pricing.js.map +1 -0
  385. package/dist/spend/record.d.ts +13 -0
  386. package/dist/spend/record.js +43 -0
  387. package/dist/spend/record.js.map +1 -0
  388. package/dist/spend/usage.d.ts +27 -0
  389. package/dist/spend/usage.js +113 -0
  390. package/dist/spend/usage.js.map +1 -0
  391. package/dist/store/store.d.ts +187 -0
  392. package/dist/store/store.js +467 -4
  393. package/dist/store/store.js.map +1 -1
  394. package/dist/trajectory/transcript-parsers/codex-session.d.ts +12 -6
  395. package/dist/trajectory/transcript-parsers/codex-session.js +114 -13
  396. package/dist/trajectory/transcript-parsers/codex-session.js.map +1 -1
  397. package/dist/trajectory/transcript-parsers/types.d.ts +8 -8
  398. package/dist/trajectory/transcript-session-dirs.d.ts +18 -0
  399. package/dist/trajectory/transcript-session-dirs.js +85 -0
  400. package/dist/trajectory/transcript-session-dirs.js.map +1 -0
  401. package/dist/trajectory/transcript-watcher.d.ts +20 -1
  402. package/dist/trajectory/transcript-watcher.js +108 -32
  403. package/dist/trajectory/transcript-watcher.js.map +1 -1
  404. package/dist/tx-retry.d.ts +25 -0
  405. package/dist/tx-retry.js +95 -7
  406. package/dist/tx-retry.js.map +1 -1
  407. package/dist/types/payloads/portfolio-v0.d.ts +3 -3
  408. package/dist/types/payloads/prediction-apy-v0.d.ts +3 -3
  409. package/dist/types/payloads/prediction-v0.d.ts +12 -12
  410. package/dist/vendor/@jinn-network/sdk/dist/payloads/swe-rebench-v2.d.ts +108 -1
  411. package/dist/vendor/@jinn-network/sdk/dist/payloads/swe-rebench-v2.js +25 -1
  412. package/dist/vendor/@jinn-network/sdk/dist/solvernets/swe-rebench-v2-held-out-slate.d.ts +65 -0
  413. package/dist/vendor/@jinn-network/sdk/dist/solvernets/swe-rebench-v2-held-out-slate.js +123 -0
  414. package/dist/vendor/@jinn-network/sdk/dist/solvernets/swe-rebench-v2.d.ts +2 -2
  415. package/dist/vendor/@jinn-network/sdk/dist/solvernets/swe-rebench-v2.js +1 -1
  416. package/dist/vendor/@jinn-network/sdk/package.json +4 -0
  417. package/docker-compose.yml +3 -2
  418. package/package.json +30 -18
  419. package/plugins/learner/.claude-plugin/plugin.json +1 -1
  420. package/plugins/learner/.codex-plugin/plugin.json +1 -1
  421. package/plugins/learner/hooks/session-start +30 -1
  422. package/plugins/learner/skills/learn/consolidator-prompt.md +22 -1
  423. package/plugins/learner/skills/learn/promoter-prompt.md +72 -1
  424. package/plugins/swe-rebench-v2-diffmin/README.md +10 -9
  425. package/plugins/swe-rebench-v2-diffmin/jinn.plugin.json +1 -1
  426. package/plugins/swe-rebench-v2-diffmin/skills/diffmin/SKILL.md +15 -10
  427. package/plugins/swe-rebench-v2-diffmin/skills/test-map/SKILL.md +10 -12
  428. package/plugins/swe-rebench-v2-runtime/.claude-plugin/plugin.json +1 -1
  429. package/plugins/swe-rebench-v2-runtime/.codex-plugin/plugin.json +3 -3
  430. package/plugins/swe-rebench-v2-runtime/README.md +6 -6
  431. package/plugins/swe-rebench-v2-runtime/hooks/hooks.json +16 -0
  432. package/plugins/swe-rebench-v2-runtime/hooks/session-start +74 -0
  433. package/plugins/swe-rebench-v2-runtime/jinn.plugin.json +2 -3
  434. package/plugins/swe-rebench-v2-runtime/skills/task/SKILL.md +81 -0
  435. package/dist/dashboard/assets/index-BUlE8F3Y.js +0 -330
  436. package/dist/dashboard/assets/index-blqc7eqq.css +0 -32
  437. package/plugins/swe-rebench-v2-runtime/skills/orient/SKILL.md +0 -29
  438. package/plugins/swe-rebench-v2-runtime/skills/plan/SKILL.md +0 -53
@@ -228,6 +228,23 @@ CREATE TABLE IF NOT EXISTS envelope_projection_metadata (
228
228
  CREATE INDEX IF NOT EXISTS idx_envelope_projection_metadata_key_value
229
229
  ON envelope_projection_metadata (key, value_text);
230
230
 
231
+ CREATE TABLE IF NOT EXISTS erc8004_anchors (
232
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
233
+ envelope_id TEXT NOT NULL,
234
+ envelope_cid TEXT NOT NULL,
235
+ content_kind TEXT NOT NULL,
236
+ metadata_key TEXT NOT NULL,
237
+ agent_id TEXT NOT NULL,
238
+ chain_id INTEGER NOT NULL,
239
+ identity_registry_address TEXT NOT NULL,
240
+ tx_hash TEXT NOT NULL,
241
+ block_number INTEGER,
242
+ payload_hex TEXT NOT NULL,
243
+ anchored_at INTEGER NOT NULL
244
+ );
245
+ CREATE INDEX IF NOT EXISTS idx_erc8004_anchors_envelope_cid ON erc8004_anchors(envelope_cid);
246
+ CREATE INDEX IF NOT EXISTS idx_erc8004_anchors_envelope_id ON erc8004_anchors(envelope_id);
247
+
231
248
  CREATE TABLE IF NOT EXISTS task_post_locks (
232
249
  creator_safe_address TEXT NOT NULL,
233
250
  source_key TEXT NOT NULL,
@@ -271,6 +288,25 @@ CREATE TABLE IF NOT EXISTS capture_spans (
271
288
  );
272
289
  CREATE INDEX IF NOT EXISTS capture_spans_session ON capture_spans (session_id);
273
290
 
291
+ -- Held-out checkpoint eval results (issue #818). One row per
292
+ -- (checkpoint, slate version, instance). Scores are only comparable WITHIN a
293
+ -- slate version; slate_hash is stored so a version-bump / hash-drift is
294
+ -- detectable. passed is nullable: an unscorable row (Docker down, disk
295
+ -- floor) carries passed = NULL and is EXCLUDED from the denominator -- never
296
+ -- coerced to a fail.
297
+ CREATE TABLE IF NOT EXISTS eval_results (
298
+ checkpoint_cid TEXT NOT NULL,
299
+ slate_hash TEXT NOT NULL,
300
+ slate_version TEXT NOT NULL,
301
+ instance_id TEXT NOT NULL,
302
+ passed INTEGER,
303
+ unscorable INTEGER NOT NULL DEFAULT 0,
304
+ code_digest TEXT NOT NULL,
305
+ run_at_ms INTEGER NOT NULL,
306
+ test_log_excerpt TEXT,
307
+ PRIMARY KEY (checkpoint_cid, slate_version, instance_id)
308
+ );
309
+
274
310
  `;
275
311
  export class Store {
276
312
  /** Exposed for engine persistence layer — treat as package-internal. */
@@ -299,6 +335,7 @@ export class Store {
299
335
  this.ensureNetworkArtifactsPeerCatalogId();
300
336
  this.ensureTaskPostsTaskCoordinatorColumns();
301
337
  this.ensureEnvelopeProjectionColumns();
338
+ this.ensureActivityEventCostColumns();
302
339
  this.backfillActivityEvents();
303
340
  this.recordLegacyRestorationIntentsIgnored();
304
341
  }
@@ -363,6 +400,36 @@ export class Store {
363
400
  this.db.exec(`CREATE INDEX IF NOT EXISTS idx_envelope_projections_solution_ref ON envelope_projections (solution_envelope_ref)`);
364
401
  this.db.exec(`CREATE INDEX IF NOT EXISTS idx_envelope_projections_generated ON envelope_projections (generated_at DESC)`);
365
402
  }
403
+ /** Older local DBs predate the per-credential spend-ledger columns on activity_events. */
404
+ ensureActivityEventCostColumns() {
405
+ const activityCols = new Set(this.db.prepare(`PRAGMA table_info(activity_events)`).all()
406
+ .map(c => c.name));
407
+ const addActivityColumn = (name, ddl) => {
408
+ if (!activityCols.has(name))
409
+ this.db.exec(`ALTER TABLE activity_events ADD COLUMN ${ddl}`);
410
+ };
411
+ addActivityColumn('credential_id', 'credential_id TEXT');
412
+ addActivityColumn('cost_usd_micros', 'cost_usd_micros INTEGER');
413
+ addActivityColumn('model', 'model TEXT');
414
+ // Issue #815 — AI-units ceiling. ai_units is the gate-input projection
415
+ // captured at claim time; claim_status tracks the per-request lifecycle
416
+ // (claimed / claim_failed / delivered); the cost pair splits the
417
+ // estimated-at-claim-time vs actual-at-completion telemetry.
418
+ addActivityColumn('ai_units', 'ai_units REAL');
419
+ addActivityColumn('claim_status', 'claim_status TEXT');
420
+ addActivityColumn('estimated_cost_usd_micros', 'estimated_cost_usd_micros INTEGER');
421
+ addActivityColumn('actual_cost_usd_micros', 'actual_cost_usd_micros INTEGER');
422
+ // Issue #1004 (AC4): whether actual_cost_usd_micros is estimate-backed
423
+ // (1) or harvested telemetry (0/null). A telemetry-less harness such as
424
+ // Hermes still writes a NON-null actual cost via finalizeClaimDelivered,
425
+ // so the column distinguishes a heuristic figure from a metered one. The
426
+ // gate's estimated flag reads this so a heuristic is not shown as metered.
427
+ addActivityColumn('actual_cost_estimated', 'actual_cost_estimated INTEGER');
428
+ this.db.exec(`CREATE INDEX IF NOT EXISTS idx_activity_events_credential ON activity_events (credential_id, ts)`);
429
+ // Per-request lookup for the completion-time update path that fills
430
+ // actualCostUsdMicros / sets claim_status='delivered'.
431
+ this.db.exec(`CREATE INDEX IF NOT EXISTS idx_activity_events_req_claim ON activity_events (request_id, claim_status)`);
432
+ }
366
433
  /**
367
434
  * Task-native startup ignores the retired request-first `restoration_intents`
368
435
  * table. Keep a one-time local marker when old in-flight rows are present so
@@ -417,6 +484,16 @@ export class Store {
417
484
  const ts = new Date().toISOString();
418
485
  this.recordActivityEvent({ ts, kind: role, requestId });
419
486
  }
487
+ /**
488
+ * Membership-only variant of `recordOwnActivity`: writes the
489
+ * `own_activity` row but does NOT emit a generic `activity_events`
490
+ * row. Used by paths that emit their own enriched activity event
491
+ * (e.g. issue #815's claim path attaches credentialId / aiUnits /
492
+ * estimatedCostUsdMicros / claimStatus to the row).
493
+ */
494
+ markOwnActivity(requestId, role) {
495
+ this.db.prepare(`INSERT OR REPLACE INTO own_activity (request_id, role) VALUES (?, ?)`).run(requestId, role);
496
+ }
420
497
  isOwnActivity(requestId) {
421
498
  const row = this.db.prepare('SELECT 1 FROM own_activity WHERE request_id = ?').get(requestId);
422
499
  return row !== undefined;
@@ -746,8 +823,14 @@ export class Store {
746
823
  return legacyRows.map(r => ({ requestId: r.request_id, role: r.role }));
747
824
  }
748
825
  recordActivityEvent(event) {
749
- this.db.prepare(`INSERT INTO activity_events (ts, kind, request_id, service_index, tx_hash, solver_type, outcome, detail)
750
- VALUES (@ts, @kind, @requestId, @serviceIndex, @txHash, @solverType, @outcome, @detail)`).run({
826
+ this.db.prepare(`INSERT INTO activity_events
827
+ (ts, kind, request_id, service_index, tx_hash, solver_type, outcome, detail,
828
+ credential_id, cost_usd_micros, model,
829
+ ai_units, claim_status, estimated_cost_usd_micros, actual_cost_usd_micros)
830
+ VALUES
831
+ (@ts, @kind, @requestId, @serviceIndex, @txHash, @solverType, @outcome, @detail,
832
+ @credentialId, @costUsdMicros, @model,
833
+ @aiUnits, @claimStatus, @estimatedCostUsdMicros, @actualCostUsdMicros)`).run({
751
834
  ts: event.ts ?? null,
752
835
  kind: event.kind,
753
836
  requestId: event.requestId ?? null,
@@ -756,6 +839,13 @@ export class Store {
756
839
  solverType: event.solverType ?? null,
757
840
  outcome: event.outcome ?? null,
758
841
  detail: event.detail ?? null,
842
+ credentialId: event.credentialId ?? null,
843
+ costUsdMicros: event.costUsdMicros ?? null,
844
+ model: event.model ?? null,
845
+ aiUnits: event.aiUnits ?? null,
846
+ claimStatus: event.claimStatus ?? null,
847
+ estimatedCostUsdMicros: event.estimatedCostUsdMicros ?? null,
848
+ actualCostUsdMicros: event.actualCostUsdMicros ?? null,
759
849
  });
760
850
  }
761
851
  getRecentActivityEvents(limit, opts = {}) {
@@ -771,7 +861,9 @@ export class Store {
771
861
  params['cursor'] = opts.cursor;
772
862
  }
773
863
  const where = clauses.length > 0 ? `WHERE ${clauses.join(' AND ')}` : '';
774
- const rows = this.db.prepare(`SELECT id, ts, kind, request_id, service_index, tx_hash, solver_type, outcome, detail
864
+ const rows = this.db.prepare(`SELECT id, ts, kind, request_id, service_index, tx_hash, solver_type, outcome, detail,
865
+ credential_id, cost_usd_micros, model,
866
+ ai_units, claim_status, estimated_cost_usd_micros, actual_cost_usd_micros
775
867
  FROM activity_events
776
868
  ${where}
777
869
  ORDER BY id DESC
@@ -786,13 +878,171 @@ export class Store {
786
878
  solverType: r.solver_type,
787
879
  outcome: r.outcome,
788
880
  detail: r.detail,
881
+ credentialId: r.credential_id,
882
+ costUsdMicros: r.cost_usd_micros,
883
+ model: r.model,
884
+ aiUnits: r.ai_units,
885
+ claimStatus: r.claim_status,
886
+ estimatedCostUsdMicros: r.estimated_cost_usd_micros,
887
+ actualCostUsdMicros: r.actual_cost_usd_micros,
789
888
  }));
790
889
  }
890
+ /**
891
+ * Total cost in micro-dollars recorded against a credential since the most
892
+ * recent UTC midnight. Backs the daily spend cap.
893
+ */
894
+ spentTodayMicros(credentialId, now = new Date()) {
895
+ const midnight = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate())).toISOString();
896
+ const row = this.db.prepare(`SELECT COALESCE(SUM(cost_usd_micros), 0) AS total
897
+ FROM activity_events
898
+ WHERE credential_id = @cid AND ts IS NOT NULL AND ts >= @midnight`).get({ cid: credentialId, midnight });
899
+ return row.total;
900
+ }
901
+ /**
902
+ * Sum of `ai_units` for a credential within the current 6h UTC-aligned
903
+ * block (00:00 / 06:00 / 12:00 / 18:00 boundaries). Reads only rows whose
904
+ * `claim_status = 'claimed'` or `'delivered'` so failed-claim rows
905
+ * (`ai_units = 0`, `claim_status = 'claim_failed'`) don't muddy the sum
906
+ * even though their contribution is already zero.
907
+ *
908
+ * Issue #815. Backs the per-block AI-units ceiling gate.
909
+ */
910
+ aiUnitsThisBlock(credentialId, now = new Date()) {
911
+ const startOfDay = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate());
912
+ const sinceDayStart = now.getTime() - startOfDay;
913
+ const sixHoursMs = 6 * 60 * 60 * 1_000;
914
+ // Cap at 3 — there are 4 blocks per day (indices 0..3). Edge cases
915
+ // where sinceDayStart ≈ 24h (millisecond rounding) would otherwise
916
+ // overshoot into a non-existent 5th block in the *next* day.
917
+ const blocksIn = Math.min(Math.floor(sinceDayStart / sixHoursMs), 3);
918
+ const blockStart = new Date(startOfDay + blocksIn * sixHoursMs).toISOString();
919
+ const blockEnd = new Date(startOfDay + (blocksIn + 1) * sixHoursMs).toISOString();
920
+ const row = this.db.prepare(`SELECT COALESCE(SUM(ai_units), 0) AS total
921
+ FROM activity_events
922
+ WHERE credential_id = @cid
923
+ AND ts IS NOT NULL AND ts >= @blockStart AND ts < @blockEnd
924
+ AND claim_status IN ('claimed', 'delivered')`).get({ cid: credentialId, blockStart, blockEnd });
925
+ return row.total ?? 0;
926
+ }
927
+ /**
928
+ * Sum of `ai_units` for a credential within the trailing 7-day rolling
929
+ * window from `now`. Backs the per-week AI-units safety-net ceiling.
930
+ * Issue #815.
931
+ */
932
+ aiUnitsThisWeek(credentialId, now = new Date()) {
933
+ const weekStart = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1_000).toISOString();
934
+ const row = this.db.prepare(`SELECT COALESCE(SUM(ai_units), 0) AS total
935
+ FROM activity_events
936
+ WHERE credential_id = @cid
937
+ AND ts IS NOT NULL AND ts >= @weekStart
938
+ AND claim_status IN ('claimed', 'delivered')`).get({ cid: credentialId, weekStart });
939
+ return row.total ?? 0;
940
+ }
941
+ /**
942
+ * Actual-spend accumulator for the current 6h UTC block (issue #1004).
943
+ *
944
+ * Sums `COALESCE(actual_cost_usd_micros, estimated_cost_usd_micros, 0)`
945
+ * over rows whose `claim_status` is `'claimed'` or `'delivered'`:
946
+ * - delivered rows contribute the real harvested cost (`actual_*`),
947
+ * - in-flight claimed rows contribute their estimate so a burst of
948
+ * concurrent claims cannot slip the cap before any of them deliver,
949
+ * - failed claims (status `'claim_failed'`) are excluded.
950
+ *
951
+ * `estimated` is true iff the summed figure includes any estimate-backed
952
+ * cost: an in-flight `claimed` row with no `actual_cost_usd_micros` yet,
953
+ * OR a `delivered` row whose actual cost is itself a heuristic
954
+ * (`actual_cost_estimated = 1` — a telemetry-less harness such as Hermes).
955
+ * It is false only when every contributing row is harvested actual
956
+ * telemetry. The gate surfaces this so an estimate-backed figure is not
957
+ * presented as metered. Block boundaries mirror `aiUnitsThisBlock`.
958
+ */
959
+ usdMicrosThisBlock(credentialId, now = new Date()) {
960
+ const startOfDay = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate());
961
+ const sinceDayStart = now.getTime() - startOfDay;
962
+ const sixHoursMs = 6 * 60 * 60 * 1_000;
963
+ const blocksIn = Math.min(Math.floor(sinceDayStart / sixHoursMs), 3);
964
+ const blockStart = new Date(startOfDay + blocksIn * sixHoursMs).toISOString();
965
+ const blockEnd = new Date(startOfDay + (blocksIn + 1) * sixHoursMs).toISOString();
966
+ return this.sumUsdMicros(credentialId, blockStart, blockEnd);
967
+ }
968
+ /**
969
+ * Actual-spend accumulator for the trailing 7-day rolling window from
970
+ * `now` (issue #1004). Same COALESCE + claim_status filter + `estimated`
971
+ * semantics as {@link usdMicrosThisBlock}.
972
+ */
973
+ usdMicrosThisWeek(credentialId, now = new Date()) {
974
+ const weekStart = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1_000).toISOString();
975
+ return this.sumUsdMicros(credentialId, weekStart, undefined);
976
+ }
977
+ /** Shared COALESCE-sum + estimate-flag query for the USD accumulators. */
978
+ sumUsdMicros(credentialId, fromIso, toIso) {
979
+ const upper = toIso ? 'AND ts < @to' : '';
980
+ const row = this.db
981
+ .prepare(`SELECT
982
+ COALESCE(SUM(COALESCE(actual_cost_usd_micros, estimated_cost_usd_micros, 0)), 0) AS total,
983
+ COALESCE(SUM(CASE WHEN actual_cost_usd_micros IS NULL OR actual_cost_estimated = 1 THEN 1 ELSE 0 END), 0) AS estimatedRows
984
+ FROM activity_events
985
+ WHERE credential_id = @cid
986
+ AND ts IS NOT NULL AND ts >= @from ${upper}
987
+ AND claim_status IN ('claimed', 'delivered')`)
988
+ .get({ cid: credentialId, from: fromIso, to: toIso });
989
+ return { usdMicros: row.total ?? 0, estimated: (row.estimatedRows ?? 0) > 0 };
990
+ }
991
+ /**
992
+ * True iff an `ai_units_cap_reached` row exists for the given
993
+ * (credentialId, window, blockId). Used by the daemon to hydrate the
994
+ * AI-units gate's in-memory pause memo across restarts so the
995
+ * "exactly one event per (credential, window, block-id)" guarantee
996
+ * holds across process boundaries (issue #815, finding 1).
997
+ *
998
+ * Lookup is by `credential_id` + `kind` + the `[block=...][window=...]`
999
+ * markers that `daemon.ts` embeds in the row's `detail` string.
1000
+ */
1001
+ hasAiUnitsCapReachedFor(credentialId, window, blockId) {
1002
+ const marker = `[block=${blockId}][window=${window}]`;
1003
+ const row = this.db.prepare(`SELECT 1 AS hit
1004
+ FROM activity_events
1005
+ WHERE kind = 'ai_units_cap_reached'
1006
+ AND credential_id = @cid
1007
+ AND detail LIKE @marker
1008
+ LIMIT 1`).get({ cid: credentialId, marker: `${marker}%` });
1009
+ return row !== undefined;
1010
+ }
1011
+ /**
1012
+ * Mark the per-request `claimed` row as `delivered` and record
1013
+ * `actual_cost_usd_micros` (issue #1004 — the gate's accumulator now
1014
+ * reads this column via COALESCE, so a delivered row's real harvested
1015
+ * cost replaces its claim-time estimate in the running total). The
1016
+ * `ai_units` projection captured at claim time is intentionally NOT
1017
+ * recomputed — it remains the per-task estimate for the legacy unit
1018
+ * surfaces. For subscription credentials the resulting USD figure is a
1019
+ * *proxy* budget, not an exact bound on the provider's plan quota.
1020
+ *
1021
+ * `actualCostEstimated` (issue #1004, AC4) records whether the actual
1022
+ * cost is itself a heuristic — true for a telemetry-less harness such as
1023
+ * Hermes whose `harvestHarnessUsage` falls back to an a-priori estimate,
1024
+ * false when the figure is harvested telemetry. The gate reads it so a
1025
+ * delivered-but-heuristic row reports `estimated: true` rather than being
1026
+ * presented as metered. Idempotent: a no-op when no `claimed` row exists.
1027
+ */
1028
+ finalizeClaimDelivered(requestId, actualCostUsdMicros, actualCostEstimated) {
1029
+ this.db.prepare(`UPDATE activity_events
1030
+ SET claim_status = 'delivered',
1031
+ actual_cost_usd_micros = @actual,
1032
+ actual_cost_estimated = @estimated
1033
+ WHERE request_id = @req AND claim_status = 'claimed'`).run({
1034
+ req: requestId,
1035
+ actual: actualCostUsdMicros,
1036
+ estimated: actualCostEstimated ? 1 : 0,
1037
+ });
1038
+ }
791
1039
  /** Newer events first, then ascending id for `jinn logs --follow` (oldest in batch printed first in caller). */
792
1040
  getActivityEventsAfterId(afterId, limit) {
793
1041
  const effectiveLimit = Math.max(0, Math.min(limit, 1000));
794
1042
  const rows = this.db
795
- .prepare(`SELECT id, ts, kind, request_id, service_index, tx_hash, solver_type, outcome, detail
1043
+ .prepare(`SELECT id, ts, kind, request_id, service_index, tx_hash, solver_type, outcome, detail,
1044
+ credential_id, cost_usd_micros, model,
1045
+ ai_units, claim_status, estimated_cost_usd_micros, actual_cost_usd_micros
796
1046
  FROM activity_events
797
1047
  WHERE id > @afterId
798
1048
  ORDER BY id ASC
@@ -808,8 +1058,99 @@ export class Store {
808
1058
  solverType: r.solver_type,
809
1059
  outcome: r.outcome,
810
1060
  detail: r.detail,
1061
+ credentialId: r.credential_id,
1062
+ costUsdMicros: r.cost_usd_micros,
1063
+ model: r.model,
1064
+ aiUnits: r.ai_units,
1065
+ claimStatus: r.claim_status,
1066
+ estimatedCostUsdMicros: r.estimated_cost_usd_micros,
1067
+ actualCostUsdMicros: r.actual_cost_usd_micros,
811
1068
  }));
812
1069
  }
1070
+ /**
1071
+ * Filtered, id-cursored page of activity events for the dedicated Events
1072
+ * page. Newest-first.
1073
+ *
1074
+ * Cursors on `id` rather than `ts` so startup/shutdown rows with null
1075
+ * timestamps remain reachable.
1076
+ */
1077
+ getActivityEventsPage(opts = {}) {
1078
+ const effectiveLimit = Math.max(1, Math.min(opts.limit ?? 50, 200));
1079
+ const clauses = [];
1080
+ const params = { limit: effectiveLimit };
1081
+ if (opts.kinds && opts.kinds.length > 0) {
1082
+ const placeholders = opts.kinds.map((_, i) => `@kind${i}`);
1083
+ clauses.push(`kind IN (${placeholders.join(', ')})`);
1084
+ opts.kinds.forEach((k, i) => {
1085
+ params[`kind${i}`] = k;
1086
+ });
1087
+ }
1088
+ if (opts.outcome) {
1089
+ clauses.push('outcome = @outcome');
1090
+ params['outcome'] = opts.outcome;
1091
+ }
1092
+ if (opts.requestId) {
1093
+ clauses.push('request_id = @requestId');
1094
+ params['requestId'] = opts.requestId;
1095
+ }
1096
+ if (opts.beforeId !== undefined) {
1097
+ clauses.push('id < @beforeId');
1098
+ params['beforeId'] = opts.beforeId;
1099
+ }
1100
+ const where = clauses.length > 0 ? `WHERE ${clauses.join(' AND ')}` : '';
1101
+ const rows = this.db.prepare(`SELECT id, ts, kind, request_id, service_index, tx_hash, solver_type, outcome, detail,
1102
+ credential_id, cost_usd_micros, model,
1103
+ ai_units, claim_status, estimated_cost_usd_micros, actual_cost_usd_micros
1104
+ FROM activity_events
1105
+ ${where}
1106
+ ORDER BY id DESC
1107
+ LIMIT @limit`).all(params);
1108
+ return rows.map((r) => ({
1109
+ id: r.id,
1110
+ ts: r.ts,
1111
+ kind: r.kind,
1112
+ requestId: r.request_id,
1113
+ serviceIndex: r.service_index,
1114
+ txHash: r.tx_hash,
1115
+ solverType: r.solver_type,
1116
+ outcome: r.outcome,
1117
+ detail: r.detail,
1118
+ credentialId: r.credential_id,
1119
+ costUsdMicros: r.cost_usd_micros,
1120
+ model: r.model,
1121
+ aiUnits: r.ai_units,
1122
+ claimStatus: r.claim_status,
1123
+ estimatedCostUsdMicros: r.estimated_cost_usd_micros,
1124
+ actualCostUsdMicros: r.actual_cost_usd_micros,
1125
+ }));
1126
+ }
1127
+ getActivityEventById(id) {
1128
+ const r = this.db.prepare(`SELECT id, ts, kind, request_id, service_index, tx_hash, solver_type, outcome, detail,
1129
+ credential_id, cost_usd_micros, model,
1130
+ ai_units, claim_status, estimated_cost_usd_micros, actual_cost_usd_micros
1131
+ FROM activity_events
1132
+ WHERE id = ?`).get(id);
1133
+ if (!r)
1134
+ return null;
1135
+ return {
1136
+ id: r.id,
1137
+ ts: r.ts,
1138
+ kind: r.kind,
1139
+ requestId: r.request_id,
1140
+ serviceIndex: r.service_index,
1141
+ txHash: r.tx_hash,
1142
+ solverType: r.solver_type,
1143
+ outcome: r.outcome,
1144
+ detail: r.detail,
1145
+ credentialId: r.credential_id,
1146
+ costUsdMicros: r.cost_usd_micros,
1147
+ model: r.model,
1148
+ aiUnits: r.ai_units,
1149
+ claimStatus: r.claim_status,
1150
+ estimatedCostUsdMicros: r.estimated_cost_usd_micros,
1151
+ actualCostUsdMicros: r.actual_cost_usd_micros,
1152
+ };
1153
+ }
813
1154
  getActivityCountsByKind() {
814
1155
  const rows = this.db.prepare(`SELECT kind, COUNT(*) as c FROM activity_events GROUP BY kind`).all();
815
1156
  const out = {};
@@ -1519,6 +1860,128 @@ export class Store {
1519
1860
  LIMIT @limit`).all(params);
1520
1861
  return rows.map(rowToEnvelopeProjection);
1521
1862
  }
1863
+ saveErc8004Anchor(input) {
1864
+ this.db.prepare(`INSERT INTO erc8004_anchors
1865
+ (envelope_id, envelope_cid, content_kind, metadata_key, agent_id,
1866
+ chain_id, identity_registry_address, tx_hash, block_number,
1867
+ payload_hex, anchored_at)
1868
+ VALUES
1869
+ (@envelopeId, @envelopeCid, @contentKind, @metadataKey, @agentId,
1870
+ @chainId, @identityRegistryAddress, @txHash, @blockNumber,
1871
+ @payloadHex, @anchoredAt)`).run({
1872
+ envelopeId: input.envelopeId,
1873
+ envelopeCid: input.envelopeCid,
1874
+ contentKind: input.contentKind,
1875
+ metadataKey: input.metadataKey,
1876
+ agentId: input.agentId,
1877
+ chainId: input.chainId,
1878
+ identityRegistryAddress: input.identityRegistryAddress,
1879
+ txHash: input.txHash,
1880
+ blockNumber: input.blockNumber,
1881
+ payloadHex: input.payloadHex,
1882
+ anchoredAt: input.anchoredAt,
1883
+ });
1884
+ }
1885
+ listErc8004AnchorsByEnvelopeCids(envelopeCids) {
1886
+ if (envelopeCids.length === 0)
1887
+ return [];
1888
+ const placeholders = envelopeCids.map((_, i) => `@cid${i}`).join(', ');
1889
+ const params = {};
1890
+ envelopeCids.forEach((cid, i) => { params[`cid${i}`] = cid; });
1891
+ const rows = this.db.prepare(`SELECT id, envelope_id, envelope_cid, content_kind, metadata_key, agent_id,
1892
+ chain_id, identity_registry_address, tx_hash, block_number,
1893
+ payload_hex, anchored_at
1894
+ FROM erc8004_anchors
1895
+ WHERE envelope_cid IN (${placeholders})
1896
+ ORDER BY anchored_at ASC, id ASC`).all(params);
1897
+ return rows.map((r) => ({
1898
+ id: r.id,
1899
+ envelopeId: r.envelope_id,
1900
+ envelopeCid: r.envelope_cid,
1901
+ contentKind: r.content_kind,
1902
+ metadataKey: r.metadata_key,
1903
+ agentId: r.agent_id,
1904
+ chainId: r.chain_id,
1905
+ identityRegistryAddress: r.identity_registry_address,
1906
+ txHash: r.tx_hash,
1907
+ blockNumber: r.block_number,
1908
+ payloadHex: r.payload_hex,
1909
+ anchoredAt: r.anchored_at,
1910
+ }));
1911
+ }
1912
+ /**
1913
+ * Upsert one held-out eval result (issue #818). PK is
1914
+ * `(checkpoint_cid, slate_version, instance_id)` so a re-run overwrites.
1915
+ * `passed` is null for `unscorable` rows.
1916
+ */
1917
+ recordEvalResult(args) {
1918
+ this.db
1919
+ .prepare(`INSERT INTO eval_results
1920
+ (checkpoint_cid, slate_hash, slate_version, instance_id, passed, unscorable, code_digest, run_at_ms, test_log_excerpt)
1921
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
1922
+ ON CONFLICT(checkpoint_cid, slate_version, instance_id) DO UPDATE SET
1923
+ slate_hash = excluded.slate_hash,
1924
+ passed = excluded.passed,
1925
+ unscorable = excluded.unscorable,
1926
+ code_digest = excluded.code_digest,
1927
+ run_at_ms = excluded.run_at_ms,
1928
+ test_log_excerpt = excluded.test_log_excerpt`)
1929
+ .run(args.checkpoint_cid, args.slate_hash, args.slate_version, args.instance_id, args.unscorable ? null : args.passed ? 1 : 0, args.unscorable ? 1 : 0, args.code_digest, args.run_at_ms, args.test_log_excerpt ?? null);
1930
+ }
1931
+ /**
1932
+ * Aggregate the eval results for a (checkpoint, slate version):
1933
+ * `scorable` = rows with `unscorable = 0`; `passed` = scorable rows with
1934
+ * `passed = 1`. Unscorable rows are counted separately and never enter the
1935
+ * denominator. A checkpoint with no rows yields all-zero (the orchestrator
1936
+ * reads this to detect a not-yet-evaluated parent).
1937
+ */
1938
+ getEvalAggregate(checkpoint_cid, slate_version) {
1939
+ const row = this.db
1940
+ .prepare(`SELECT
1941
+ COALESCE(SUM(CASE WHEN unscorable = 0 AND passed = 1 THEN 1 ELSE 0 END), 0) AS passed,
1942
+ COALESCE(SUM(CASE WHEN unscorable = 0 THEN 1 ELSE 0 END), 0) AS scorable,
1943
+ COALESCE(SUM(CASE WHEN unscorable = 1 THEN 1 ELSE 0 END), 0) AS unscorable
1944
+ FROM eval_results
1945
+ WHERE checkpoint_cid = ? AND slate_version = ?`)
1946
+ .get(checkpoint_cid, slate_version);
1947
+ return { passed: row.passed, scorable: row.scorable, unscorable: row.unscorable };
1948
+ }
1949
+ /**
1950
+ * Distinct `slate_hash` values recorded for a (checkpoint, slate version).
1951
+ * The eval orchestrator reads this to detect slate-content drift under a
1952
+ * stable version label — the held-out exam is only an honest before/after
1953
+ * when the parent and child were scored on the SAME slate content (defeating
1954
+ * confounder #1, task-selection). Empty when the checkpoint has no rows.
1955
+ */
1956
+ getEvalSlateHashes(checkpoint_cid, slate_version) {
1957
+ const rows = this.db
1958
+ .prepare(`SELECT DISTINCT slate_hash
1959
+ FROM eval_results
1960
+ WHERE checkpoint_cid = ? AND slate_version = ?
1961
+ ORDER BY slate_hash`)
1962
+ .all(checkpoint_cid, slate_version);
1963
+ return rows.map((r) => r.slate_hash);
1964
+ }
1965
+ /** Per-task eval results for a (checkpoint, slate version), ordered by instance_id. */
1966
+ getEvalResults(checkpoint_cid, slate_version) {
1967
+ const rows = this.db
1968
+ .prepare(`SELECT checkpoint_cid, slate_hash, slate_version, instance_id, passed, unscorable, code_digest, run_at_ms, test_log_excerpt
1969
+ FROM eval_results
1970
+ WHERE checkpoint_cid = ? AND slate_version = ?
1971
+ ORDER BY instance_id`)
1972
+ .all(checkpoint_cid, slate_version);
1973
+ return rows.map((r) => ({
1974
+ checkpoint_cid: r.checkpoint_cid,
1975
+ slate_hash: r.slate_hash,
1976
+ slate_version: r.slate_version,
1977
+ instance_id: r.instance_id,
1978
+ passed: r.passed === null ? null : r.passed === 1,
1979
+ unscorable: r.unscorable === 1,
1980
+ code_digest: r.code_digest,
1981
+ run_at_ms: r.run_at_ms,
1982
+ test_log_excerpt: r.test_log_excerpt,
1983
+ }));
1984
+ }
1522
1985
  close() {
1523
1986
  this.db.close();
1524
1987
  }