@jinn-network/client 0.1.7 → 0.1.8-canary.0a152013

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 (361) hide show
  1. package/README.md +67 -1
  2. package/dist/adapters/mech/adapter.d.ts +19 -1
  3. package/dist/adapters/mech/adapter.js +130 -14
  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 +34 -24
  7. package/dist/adapters/mech/contracts.js.map +1 -1
  8. package/dist/adapters/mech/safe.d.ts +1 -1
  9. package/dist/adapters/mech/safe.js +5 -3
  10. package/dist/adapters/mech/safe.js.map +1 -1
  11. package/dist/adapters/mech/types.d.ts +6 -1
  12. package/dist/adapters/mech/types.js.map +1 -1
  13. package/dist/agent/operator-claude.js +8 -0
  14. package/dist/agent/operator-claude.js.map +1 -1
  15. package/dist/api/activity-events-endpoint.d.ts +14 -0
  16. package/dist/api/activity-events-endpoint.js +59 -0
  17. package/dist/api/activity-events-endpoint.js.map +1 -0
  18. package/dist/api/bootstrap-endpoint.d.ts +1 -2
  19. package/dist/api/bootstrap-endpoint.js +42 -24
  20. package/dist/api/bootstrap-endpoint.js.map +1 -1
  21. package/dist/api/codex-doctor-endpoint.d.ts +22 -5
  22. package/dist/api/codex-doctor-endpoint.js +136 -17
  23. package/dist/api/codex-doctor-endpoint.js.map +1 -1
  24. package/dist/api/debug-report-endpoint.d.ts +27 -0
  25. package/dist/api/debug-report-endpoint.js +157 -0
  26. package/dist/api/debug-report-endpoint.js.map +1 -0
  27. package/dist/api/discovery-endpoint.d.ts +1 -0
  28. package/dist/api/discovery-endpoint.js +24 -0
  29. package/dist/api/discovery-endpoint.js.map +1 -1
  30. package/dist/api/gather-status.d.ts +33 -0
  31. package/dist/api/gather-status.js +211 -26
  32. package/dist/api/gather-status.js.map +1 -1
  33. package/dist/api/hermes-doctor-endpoint.d.ts +15 -7
  34. package/dist/api/hermes-doctor-endpoint.js +56 -19
  35. package/dist/api/hermes-doctor-endpoint.js.map +1 -1
  36. package/dist/api/launcher-status.d.ts +4 -2
  37. package/dist/api/launcher-status.js +11 -10
  38. package/dist/api/launcher-status.js.map +1 -1
  39. package/dist/api/launcher-tasks.d.ts +1 -1
  40. package/dist/api/launcher-tasks.js +12 -8
  41. package/dist/api/launcher-tasks.js.map +1 -1
  42. package/dist/api/operator-artifacts-endpoint.js +73 -6
  43. package/dist/api/operator-artifacts-endpoint.js.map +1 -1
  44. package/dist/api/portfolio-v0-build.d.ts +7 -1
  45. package/dist/api/portfolio-v0-build.js +6 -2
  46. package/dist/api/portfolio-v0-build.js.map +1 -1
  47. package/dist/api/prediction-v1-build.d.ts +6 -0
  48. package/dist/api/prediction-v1-build.js +3 -1
  49. package/dist/api/prediction-v1-build.js.map +1 -1
  50. package/dist/api/server.d.ts +17 -0
  51. package/dist/api/server.js +40 -1
  52. package/dist/api/server.js.map +1 -1
  53. package/dist/api/setup-endpoints.d.ts +0 -9
  54. package/dist/api/setup-endpoints.js +11 -153
  55. package/dist/api/setup-endpoints.js.map +1 -1
  56. package/dist/api/solvernets-endpoints.js +30 -63
  57. package/dist/api/solvernets-endpoints.js.map +1 -1
  58. package/dist/api/status-build.d.ts +115 -2
  59. package/dist/api/status-build.js +47 -11
  60. package/dist/api/status-build.js.map +1 -1
  61. package/dist/api/status-harness-rollup.d.ts +35 -0
  62. package/dist/api/status-harness-rollup.js +45 -0
  63. package/dist/api/status-harness-rollup.js.map +1 -0
  64. package/dist/api/task-runs-build.d.ts +8 -0
  65. package/dist/api/task-runs-build.js +5 -1
  66. package/dist/api/task-runs-build.js.map +1 -1
  67. package/dist/build-info.json +4 -4
  68. package/dist/build-meta.json +1 -1
  69. package/dist/captures/live-publisher.js +24 -4
  70. package/dist/captures/live-publisher.js.map +1 -1
  71. package/dist/captures/publish.d.ts +1 -1
  72. package/dist/chain-read-errors.d.ts +12 -0
  73. package/dist/chain-read-errors.js +26 -1
  74. package/dist/chain-read-errors.js.map +1 -1
  75. package/dist/cli/commands/codedigest-revert-check.d.ts +33 -0
  76. package/dist/cli/commands/codedigest-revert-check.js +249 -0
  77. package/dist/cli/commands/codedigest-revert-check.js.map +1 -0
  78. package/dist/cli/commands/eval.d.ts +76 -0
  79. package/dist/cli/commands/eval.js +391 -0
  80. package/dist/cli/commands/eval.js.map +1 -0
  81. package/dist/cli/commands/solver-nets.d.ts +1 -0
  82. package/dist/cli/commands/solver-nets.js +177 -22
  83. package/dist/cli/commands/solver-nets.js.map +1 -1
  84. package/dist/cli/commands/solver-plugins-block.d.ts +33 -0
  85. package/dist/cli/commands/solver-plugins-block.js +118 -0
  86. package/dist/cli/commands/solver-plugins-block.js.map +1 -0
  87. package/dist/cli/commands/solver-plugins-feedback.d.ts +72 -0
  88. package/dist/cli/commands/solver-plugins-feedback.js +262 -0
  89. package/dist/cli/commands/solver-plugins-feedback.js.map +1 -0
  90. package/dist/cli/commands/solver-plugins-read.d.ts +54 -0
  91. package/dist/cli/commands/solver-plugins-read.js +259 -0
  92. package/dist/cli/commands/solver-plugins-read.js.map +1 -0
  93. package/dist/cli/commands/solver-plugins.d.ts +35 -0
  94. package/dist/cli/commands/solver-plugins.js +399 -2
  95. package/dist/cli/commands/solver-plugins.js.map +1 -1
  96. package/dist/cli/commands/tasks.js +15 -2
  97. package/dist/cli/commands/tasks.js.map +1 -1
  98. package/dist/cli/index.js +4 -0
  99. package/dist/cli/index.js.map +1 -1
  100. package/dist/cli/task-native-readiness.d.ts +7 -0
  101. package/dist/cli/task-native-readiness.js +7 -5
  102. package/dist/cli/task-native-readiness.js.map +1 -1
  103. package/dist/config.d.ts +199 -232
  104. package/dist/config.js +268 -107
  105. package/dist/config.js.map +1 -1
  106. package/dist/daemon/ai-units-gate.d.ts +54 -0
  107. package/dist/daemon/ai-units-gate.js +82 -0
  108. package/dist/daemon/ai-units-gate.js.map +1 -0
  109. package/dist/daemon/creator.js +13 -0
  110. package/dist/daemon/creator.js.map +1 -1
  111. package/dist/daemon/daemon.d.ts +10 -0
  112. package/dist/daemon/daemon.js +203 -30
  113. package/dist/daemon/daemon.js.map +1 -1
  114. package/dist/daemon/eviction-loop.d.ts +7 -0
  115. package/dist/daemon/eviction-loop.js +16 -0
  116. package/dist/daemon/eviction-loop.js.map +1 -1
  117. package/dist/daemon/gate-logger.d.ts +9 -0
  118. package/dist/daemon/gate-logger.js +2 -0
  119. package/dist/daemon/gate-logger.js.map +1 -0
  120. package/dist/daemon/jinn-claim-loop.js +22 -4
  121. package/dist/daemon/jinn-claim-loop.js.map +1 -1
  122. package/dist/daemon/readiness-gate.d.ts +1 -4
  123. package/dist/daemon/readiness-gate.js.map +1 -1
  124. package/dist/daemon/spend-cap-gate.d.ts +40 -0
  125. package/dist/daemon/spend-cap-gate.js +46 -0
  126. package/dist/daemon/spend-cap-gate.js.map +1 -0
  127. package/dist/dashboard/assets/index-CldYENtT.js +359 -0
  128. package/dist/dashboard/assets/index-CzKxvMcU.css +32 -0
  129. package/dist/dashboard/index.html +2 -2
  130. package/dist/discovery/http.js +411 -2
  131. package/dist/discovery/http.js.map +1 -1
  132. package/dist/discovery/onchain.js +123 -5
  133. package/dist/discovery/onchain.js.map +1 -1
  134. package/dist/discovery/types.d.ts +202 -0
  135. package/dist/discovery/types.js +40 -0
  136. package/dist/discovery/types.js.map +1 -1
  137. package/dist/discovery/with-fallback.js +34 -0
  138. package/dist/discovery/with-fallback.js.map +1 -1
  139. package/dist/earning/bootstrap.d.ts +25 -3
  140. package/dist/earning/bootstrap.js +69 -15
  141. package/dist/earning/bootstrap.js.map +1 -1
  142. package/dist/earning/safe-adapter.js +34 -11
  143. package/dist/earning/safe-adapter.js.map +1 -1
  144. package/dist/earning/types.d.ts +6 -6
  145. package/dist/earning/viem-clients.d.ts +11 -4
  146. package/dist/earning/viem-clients.js +14 -5
  147. package/dist/earning/viem-clients.js.map +1 -1
  148. package/dist/erc8004/identity.d.ts +19 -3
  149. package/dist/erc8004/identity.js +38 -11
  150. package/dist/erc8004/identity.js.map +1 -1
  151. package/dist/erc8004/index.d.ts +1 -1
  152. package/dist/erc8004/index.js.map +1 -1
  153. package/dist/eval/eval-harness-run.d.ts +63 -0
  154. package/dist/eval/eval-harness-run.js +123 -0
  155. package/dist/eval/eval-harness-run.js.map +1 -0
  156. package/dist/eval/orchestrator.d.ts +146 -0
  157. package/dist/eval/orchestrator.js +221 -0
  158. package/dist/eval/orchestrator.js.map +1 -0
  159. package/dist/eval/resolve-slate-tasks.d.ts +35 -0
  160. package/dist/eval/resolve-slate-tasks.js +56 -0
  161. package/dist/eval/resolve-slate-tasks.js.map +1 -0
  162. package/dist/eval/slope.d.ts +29 -0
  163. package/dist/eval/slope.js +46 -0
  164. package/dist/eval/slope.js.map +1 -0
  165. package/dist/eval/train-sequence.d.ts +35 -0
  166. package/dist/eval/train-sequence.js +59 -0
  167. package/dist/eval/train-sequence.js.map +1 -0
  168. package/dist/eval/wilson.d.ts +45 -0
  169. package/dist/eval/wilson.js +48 -0
  170. package/dist/eval/wilson.js.map +1 -0
  171. package/dist/events/types.d.ts +2 -2
  172. package/dist/harnesses/cost-estimates.d.ts +10 -31
  173. package/dist/harnesses/cost-estimates.js +11 -43
  174. package/dist/harnesses/cost-estimates.js.map +1 -1
  175. package/dist/harnesses/engine/canonical-json.js +5 -3
  176. package/dist/harnesses/engine/canonical-json.js.map +1 -1
  177. package/dist/harnesses/engine/engine.d.ts +37 -4
  178. package/dist/harnesses/engine/engine.js +138 -17
  179. package/dist/harnesses/engine/engine.js.map +1 -1
  180. package/dist/harnesses/engine/persistence.d.ts +21 -4
  181. package/dist/harnesses/engine/persistence.js +43 -6
  182. package/dist/harnesses/engine/persistence.js.map +1 -1
  183. package/dist/harnesses/engine/state.d.ts +9 -0
  184. package/dist/harnesses/engine/state.js +23 -10
  185. package/dist/harnesses/engine/state.js.map +1 -1
  186. package/dist/harnesses/impls/hermes-agent/bootstrap.js +4 -2
  187. package/dist/harnesses/impls/hermes-agent/bootstrap.js.map +1 -1
  188. package/dist/harnesses/impls/hermes-agent/config-builder.d.ts +1 -1
  189. package/dist/harnesses/impls/hermes-agent/config-builder.js +4 -2
  190. package/dist/harnesses/impls/hermes-agent/config-builder.js.map +1 -1
  191. package/dist/harnesses/impls/hermes-agent/harness.d.ts +14 -0
  192. package/dist/harnesses/impls/hermes-agent/harness.js +16 -2
  193. package/dist/harnesses/impls/hermes-agent/harness.js.map +1 -1
  194. package/dist/harnesses/impls/hermes-agent/prompt.d.ts +6 -6
  195. package/dist/harnesses/impls/hermes-agent/prompt.js +6 -6
  196. package/dist/harnesses/impls/learner/adapters/claude-code.d.ts +17 -0
  197. package/dist/harnesses/impls/learner/adapters/claude-code.js +113 -14
  198. package/dist/harnesses/impls/learner/adapters/claude-code.js.map +1 -1
  199. package/dist/harnesses/impls/learner/adapters/codex-code.d.ts +9 -0
  200. package/dist/harnesses/impls/learner/adapters/codex-code.js +30 -8
  201. package/dist/harnesses/impls/learner/adapters/codex-code.js.map +1 -1
  202. package/dist/harnesses/impls/learner/harness.d.ts +24 -0
  203. package/dist/harnesses/impls/learner/harness.js +33 -4
  204. package/dist/harnesses/impls/learner/harness.js.map +1 -1
  205. package/dist/harnesses/impls/learner/harvest.d.ts +3 -1
  206. package/dist/harnesses/impls/learner/harvest.js +30 -6
  207. package/dist/harnesses/impls/learner/harvest.js.map +1 -1
  208. package/dist/harnesses/impls/learner/restoration-patch.d.ts +2 -2
  209. package/dist/harnesses/impls/learner/restoration-patch.js +25 -6
  210. package/dist/harnesses/impls/learner/restoration-patch.js.map +1 -1
  211. package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.js +21 -1
  212. package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.js.map +1 -1
  213. package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.d.ts +74 -5
  214. package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.js +103 -32
  215. package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.js.map +1 -1
  216. package/dist/harnesses/readiness-registry.d.ts +7 -0
  217. package/dist/harnesses/readiness-registry.js +9 -0
  218. package/dist/harnesses/readiness-registry.js.map +1 -1
  219. package/dist/learner/revert-decision.d.ts +59 -0
  220. package/dist/learner/revert-decision.js +53 -0
  221. package/dist/learner/revert-decision.js.map +1 -0
  222. package/dist/learner/revert-stats.d.ts +24 -0
  223. package/dist/learner/revert-stats.js +44 -0
  224. package/dist/learner/revert-stats.js.map +1 -0
  225. package/dist/main.js +178 -104
  226. package/dist/main.js.map +1 -1
  227. package/dist/mcp/get-codedigest-reward.d.ts +13 -0
  228. package/dist/mcp/get-codedigest-reward.js +23 -0
  229. package/dist/mcp/get-codedigest-reward.js.map +1 -0
  230. package/dist/mcp/server.js +23 -0
  231. package/dist/mcp/server.js.map +1 -1
  232. package/dist/observability/debug-report-assemble.d.ts +43 -0
  233. package/dist/observability/debug-report-assemble.js +80 -0
  234. package/dist/observability/debug-report-assemble.js.map +1 -0
  235. package/dist/observability/emit-event.d.ts +9 -2
  236. package/dist/observability/emit-event.js +36 -2
  237. package/dist/observability/emit-event.js.map +1 -1
  238. package/dist/observability/file-logger.d.ts +69 -0
  239. package/dist/observability/file-logger.js +177 -0
  240. package/dist/observability/file-logger.js.map +1 -0
  241. package/dist/observability/redact-secrets.d.ts +65 -0
  242. package/dist/observability/redact-secrets.js +300 -0
  243. package/dist/observability/redact-secrets.js.map +1 -0
  244. package/dist/observability/tar.d.ts +30 -0
  245. package/dist/observability/tar.js +102 -0
  246. package/dist/observability/tar.js.map +1 -0
  247. package/dist/plugins/learner/hooks/session-start +18 -1
  248. package/dist/plugins/learner/skills/learn/consolidator-prompt.md +18 -1
  249. package/dist/plugins/learner/skills/learn/promoter-prompt.md +72 -1
  250. package/dist/preflight/pidfile-liveness.d.ts +50 -0
  251. package/dist/preflight/pidfile-liveness.js +117 -0
  252. package/dist/preflight/pidfile-liveness.js.map +1 -0
  253. package/dist/preflight/rpc-network.d.ts +40 -0
  254. package/dist/preflight/rpc-network.js +67 -1
  255. package/dist/preflight/rpc-network.js.map +1 -1
  256. package/dist/rpc/transport.d.ts +109 -0
  257. package/dist/rpc/transport.js +220 -0
  258. package/dist/rpc/transport.js.map +1 -0
  259. package/dist/scripts/donation-consumption-acceptance.js +7 -28
  260. package/dist/scripts/donation-consumption-acceptance.js.map +1 -1
  261. package/dist/scripts/swe-rebench-v2-pytest-missing.json +16 -0
  262. package/dist/solver-nets/prediction-operator-ux.d.ts +1 -2
  263. package/dist/solver-nets/prediction-operator-ux.js +56 -53
  264. package/dist/solver-nets/prediction-operator-ux.js.map +1 -1
  265. package/dist/solver-nets/registry.d.ts +19 -1
  266. package/dist/solver-nets/registry.js +37 -24
  267. package/dist/solver-nets/registry.js.map +1 -1
  268. package/dist/solver-types/_swe-rebench-v2-held-out-slate.d.ts +64 -0
  269. package/dist/solver-types/_swe-rebench-v2-held-out-slate.js +139 -0
  270. package/dist/solver-types/_swe-rebench-v2-held-out-slate.js.map +1 -0
  271. package/dist/solver-types/_swe-rebench-v2-pool.d.ts +9 -2
  272. package/dist/solver-types/_swe-rebench-v2-pool.js +15 -20
  273. package/dist/solver-types/_swe-rebench-v2-pool.js.map +1 -1
  274. package/dist/solver-types/_swe-rebench-v2-state.d.ts +15 -0
  275. package/dist/solver-types/_swe-rebench-v2-state.js +19 -0
  276. package/dist/solver-types/_swe-rebench-v2-state.js.map +1 -1
  277. package/dist/solver-types/_swe-rebench-v2-validated-pool.d.ts +116 -2
  278. package/dist/solver-types/_swe-rebench-v2-validated-pool.js +296 -21
  279. package/dist/solver-types/_swe-rebench-v2-validated-pool.js.map +1 -1
  280. package/dist/solver-types/slates/held-out-slate.swe-rebench-v2.v1.json +20 -0
  281. package/dist/solver-types/solver-type.d.ts +8 -0
  282. package/dist/solver-types/swe-rebench-v2-auto.d.ts +20 -11
  283. package/dist/solver-types/swe-rebench-v2-auto.js +64 -19
  284. package/dist/solver-types/swe-rebench-v2-auto.js.map +1 -1
  285. package/dist/solver-types/swe-rebench-v2.d.ts +8 -2
  286. package/dist/solver-types/swe-rebench-v2.js +151 -12
  287. package/dist/solver-types/swe-rebench-v2.js.map +1 -1
  288. package/dist/solvernets/daemon-init.d.ts +1 -1
  289. package/dist/solvernets/daemon-init.js +19 -4
  290. package/dist/solvernets/daemon-init.js.map +1 -1
  291. package/dist/solvernets/launched-record-dispatcher.d.ts +4 -0
  292. package/dist/solvernets/launched-record-dispatcher.js +10 -4
  293. package/dist/solvernets/launched-record-dispatcher.js.map +1 -1
  294. package/dist/solvernets/registry-client-erc8004.js +11 -0
  295. package/dist/solvernets/registry-client-erc8004.js.map +1 -1
  296. package/dist/solvernets/store.d.ts +2 -2
  297. package/dist/solvernets/store.js +7 -2
  298. package/dist/solvernets/store.js.map +1 -1
  299. package/dist/spend/ai-units-config.d.ts +39 -0
  300. package/dist/spend/ai-units-config.js +28 -0
  301. package/dist/spend/ai-units-config.js.map +1 -0
  302. package/dist/spend/ai-units.d.ts +89 -0
  303. package/dist/spend/ai-units.js +156 -0
  304. package/dist/spend/ai-units.js.map +1 -0
  305. package/dist/spend/cost-surface-status.d.ts +12 -0
  306. package/dist/spend/cost-surface-status.js +24 -0
  307. package/dist/spend/cost-surface-status.js.map +1 -0
  308. package/dist/spend/credential.d.ts +39 -0
  309. package/dist/spend/credential.js +71 -0
  310. package/dist/spend/credential.js.map +1 -0
  311. package/dist/spend/daemon-config.d.ts +13 -0
  312. package/dist/spend/daemon-config.js +24 -0
  313. package/dist/spend/daemon-config.js.map +1 -0
  314. package/dist/spend/pricing.d.ts +16 -0
  315. package/dist/spend/pricing.js +26 -0
  316. package/dist/spend/pricing.js.map +1 -0
  317. package/dist/spend/record.d.ts +13 -0
  318. package/dist/spend/record.js +36 -0
  319. package/dist/spend/record.js.map +1 -0
  320. package/dist/spend/usage.d.ts +27 -0
  321. package/dist/spend/usage.js +113 -0
  322. package/dist/spend/usage.js.map +1 -0
  323. package/dist/store/store.d.ts +144 -0
  324. package/dist/store/store.js +396 -4
  325. package/dist/store/store.js.map +1 -1
  326. package/dist/trajectory/transcript-parsers/codex-session.d.ts +12 -6
  327. package/dist/trajectory/transcript-parsers/codex-session.js +114 -13
  328. package/dist/trajectory/transcript-parsers/codex-session.js.map +1 -1
  329. package/dist/trajectory/transcript-parsers/types.d.ts +8 -8
  330. package/dist/trajectory/transcript-session-dirs.d.ts +18 -0
  331. package/dist/trajectory/transcript-session-dirs.js +85 -0
  332. package/dist/trajectory/transcript-session-dirs.js.map +1 -0
  333. package/dist/trajectory/transcript-watcher.d.ts +20 -1
  334. package/dist/trajectory/transcript-watcher.js +108 -32
  335. package/dist/trajectory/transcript-watcher.js.map +1 -1
  336. package/dist/tx-retry.d.ts +25 -0
  337. package/dist/tx-retry.js +95 -7
  338. package/dist/tx-retry.js.map +1 -1
  339. package/dist/types/payloads/portfolio-v0.d.ts +3 -3
  340. package/dist/types/payloads/prediction-apy-v0.d.ts +3 -3
  341. package/dist/types/payloads/prediction-v0.d.ts +12 -12
  342. package/dist/vendor/@jinn-network/sdk/dist/solvernets/swe-rebench-v2-held-out-slate.d.ts +65 -0
  343. package/dist/vendor/@jinn-network/sdk/dist/solvernets/swe-rebench-v2-held-out-slate.js +123 -0
  344. package/dist/vendor/@jinn-network/sdk/package.json +4 -0
  345. package/package.json +21 -12
  346. package/plugins/learner/hooks/session-start +18 -1
  347. package/plugins/learner/skills/learn/consolidator-prompt.md +18 -1
  348. package/plugins/learner/skills/learn/promoter-prompt.md +72 -1
  349. package/plugins/swe-rebench-v2-diffmin/README.md +10 -9
  350. package/plugins/swe-rebench-v2-diffmin/jinn.plugin.json +1 -1
  351. package/plugins/swe-rebench-v2-diffmin/skills/diffmin/SKILL.md +15 -10
  352. package/plugins/swe-rebench-v2-diffmin/skills/test-map/SKILL.md +10 -12
  353. package/plugins/swe-rebench-v2-runtime/.claude-plugin/plugin.json +1 -1
  354. package/plugins/swe-rebench-v2-runtime/.codex-plugin/plugin.json +3 -3
  355. package/plugins/swe-rebench-v2-runtime/README.md +6 -6
  356. package/plugins/swe-rebench-v2-runtime/jinn.plugin.json +2 -3
  357. package/plugins/swe-rebench-v2-runtime/skills/task/SKILL.md +81 -0
  358. package/dist/dashboard/assets/index-BUlE8F3Y.js +0 -330
  359. package/dist/dashboard/assets/index-blqc7eqq.css +0 -32
  360. package/plugins/swe-rebench-v2-runtime/skills/orient/SKILL.md +0 -29
  361. package/plugins/swe-rebench-v2-runtime/skills/plan/SKILL.md +0 -53
@@ -17,14 +17,15 @@
17
17
  * Heuristic shape per the spec:
18
18
  * per-1k-token rate × typical task length, by model id.
19
19
  *
20
- * Subscription harnesses (Claude Code, Codex) are flagged via
21
- * `subscriptionPath: true` on the harness; in that case the surface shows
22
- * "Included in subscription, no per-task API cost" and **does not** trigger
23
- * the confirmation gate, regardless of the model selected.
20
+ * Subscription billing paths (`usesPaidApiKey: false` from daemon
21
+ * `/v1/status` `costSurface`) show "Included in subscription, no per-task
22
+ * API cost" and **do not** trigger the confirmation gate.
24
23
  *
25
24
  * To add a new model: append an entry to `MODEL_COST_TABLE`. The id is the
26
- * exact `model` string persisted to `joinedSolverNets[<cid>].model`. To
27
- * shape a new harness: append to `HARNESS_BILLING`. Keep the units
25
+ * exact `model` string persisted to `joinedSolverNets[<cid>].model`. Paid
26
+ * vs subscription is resolved on the daemon via `resolveCredentialId` and
27
+ * exposed on `GET /v1/status` as `costSurface.harnesses[<canonical>]`.
28
+ * Keep the units
28
29
  * consistent: token counts in tokens, rates in USD-per-1k-tokens.
29
30
  *
30
31
  * Units note: Anthropic + OpenAI publish prices per million tokens; we
@@ -69,21 +70,6 @@ export interface ModelCostEntry {
69
70
  * `claudeModels.ts` is the source of truth for which ids appear here.
70
71
  */
71
72
  export declare const MODEL_COST_TABLE: Readonly<Record<string, ModelCostEntry>>;
72
- /**
73
- * Harness-level billing classification.
74
- *
75
- * `subscriptionPath: true` means the harness shells out to a
76
- * subscription-billed CLI (Claude Code, Codex) and the operator does NOT
77
- * incur per-task API charges — the cost surface is suppressed entirely
78
- * and the confirmation gate is never triggered.
79
- *
80
- * `subscriptionPath: false` means the harness routes to a paid API key
81
- * (Hermes via OpenRouter / Anthropic API / Nous Portal). The cost surface
82
- * is shown and the gate fires above the configured threshold.
83
- */
84
- export declare const HARNESS_BILLING: Readonly<Record<string, {
85
- subscriptionPath: boolean;
86
- }>>;
87
73
  /** Default per-task USD threshold above which the confirmation gate fires. */
88
74
  export declare const DEFAULT_HIGH_COST_THRESHOLD_USD = 1;
89
75
  export interface CostEstimate {
@@ -106,13 +92,6 @@ export interface CostEstimate {
106
92
  * that as "unknown, don't surface a number" rather than rendering $0.
107
93
  */
108
94
  export declare function estimateModelCost(modelId: string): CostEstimate | null;
109
- /**
110
- * `true` when the harness routes through a paid API key. Subscription
111
- * harnesses (Claude Code, Codex) return `false`; unknown harnesses
112
- * conservatively return `true` so a misnamed harness doesn't silently
113
- * skip the cost surface.
114
- */
115
- export declare function harnessUsesPaidApiKey(harness: string | undefined): boolean;
116
95
  export interface CostSurfaceDecision {
117
96
  /** Whether to show a numeric cost-per-task estimate at all. */
118
97
  showEstimate: boolean;
@@ -133,11 +112,11 @@ export interface CostSurfaceDecision {
133
112
  *
134
113
  * Defaults:
135
114
  * - threshold: $1 / task (see DEFAULT_HIGH_COST_THRESHOLD_USD).
136
- * - subscription harness → suppress surface + skip gate.
137
- * - unknown model on a paid harness → show estimate slot (caller may
115
+ * - `usesPaidApiKey: false` → suppress surface + skip gate.
116
+ * - unknown model on a paid path → show estimate slot (caller may
138
117
  * render "estimate unavailable") but DO NOT trigger the gate.
139
118
  */
140
- export declare function decideCostSurface(harness: string | undefined, modelId: string | undefined, thresholdUsd?: number): CostSurfaceDecision;
119
+ export declare function decideCostSurface(usesPaidApiKey: boolean, modelId: string | undefined, thresholdUsd?: number): CostSurfaceDecision;
141
120
  /**
142
121
  * Format a USD amount for compact display in the dashboard. Picks the
143
122
  * smallest fraction count that still distinguishes the value from $0.
@@ -17,14 +17,15 @@
17
17
  * Heuristic shape per the spec:
18
18
  * per-1k-token rate × typical task length, by model id.
19
19
  *
20
- * Subscription harnesses (Claude Code, Codex) are flagged via
21
- * `subscriptionPath: true` on the harness; in that case the surface shows
22
- * "Included in subscription, no per-task API cost" and **does not** trigger
23
- * the confirmation gate, regardless of the model selected.
20
+ * Subscription billing paths (`usesPaidApiKey: false` from daemon
21
+ * `/v1/status` `costSurface`) show "Included in subscription, no per-task
22
+ * API cost" and **do not** trigger the confirmation gate.
24
23
  *
25
24
  * To add a new model: append an entry to `MODEL_COST_TABLE`. The id is the
26
- * exact `model` string persisted to `joinedSolverNets[<cid>].model`. To
27
- * shape a new harness: append to `HARNESS_BILLING`. Keep the units
25
+ * exact `model` string persisted to `joinedSolverNets[<cid>].model`. Paid
26
+ * vs subscription is resolved on the daemon via `resolveCredentialId` and
27
+ * exposed on `GET /v1/status` as `costSurface.harnesses[<canonical>]`.
28
+ * Keep the units
28
29
  * consistent: token counts in tokens, rates in USD-per-1k-tokens.
29
30
  *
30
31
  * Units note: Anthropic + OpenAI publish prices per million tokens; we
@@ -43,7 +44,6 @@
43
44
  * These are heuristics. Provider-API reconciliation (actual usage) is
44
45
  * deferred to the P1 follow-up tracked in #331.
45
46
  */
46
- import { CLAUDE_CODE_HARNESS, CODEX_HARNESS, HERMES_AGENT_HARNESS, canonicalHarnessName, } from './names.js';
47
47
  /**
48
48
  * Per-model cost entries. Keyed by the exact `model` id persisted to
49
49
  * `joinedSolverNets[<cid>].model`. The dashboard model dropdown in
@@ -187,23 +187,6 @@ export const MODEL_COST_TABLE = {
187
187
  typicalOutputTokens: 20_000,
188
188
  },
189
189
  };
190
- /**
191
- * Harness-level billing classification.
192
- *
193
- * `subscriptionPath: true` means the harness shells out to a
194
- * subscription-billed CLI (Claude Code, Codex) and the operator does NOT
195
- * incur per-task API charges — the cost surface is suppressed entirely
196
- * and the confirmation gate is never triggered.
197
- *
198
- * `subscriptionPath: false` means the harness routes to a paid API key
199
- * (Hermes via OpenRouter / Anthropic API / Nous Portal). The cost surface
200
- * is shown and the gate fires above the configured threshold.
201
- */
202
- export const HARNESS_BILLING = {
203
- [CLAUDE_CODE_HARNESS]: { subscriptionPath: true },
204
- [CODEX_HARNESS]: { subscriptionPath: true },
205
- [HERMES_AGENT_HARNESS]: { subscriptionPath: false },
206
- };
207
190
  /** Default per-task USD threshold above which the confirmation gate fires. */
208
191
  export const DEFAULT_HIGH_COST_THRESHOLD_USD = 1;
209
192
  /**
@@ -226,33 +209,18 @@ export function estimateModelCost(modelId) {
226
209
  entry,
227
210
  };
228
211
  }
229
- /**
230
- * `true` when the harness routes through a paid API key. Subscription
231
- * harnesses (Claude Code, Codex) return `false`; unknown harnesses
232
- * conservatively return `true` so a misnamed harness doesn't silently
233
- * skip the cost surface.
234
- */
235
- export function harnessUsesPaidApiKey(harness) {
236
- if (!harness)
237
- return false;
238
- const canonical = canonicalHarnessName(harness);
239
- const billing = HARNESS_BILLING[canonical];
240
- if (!billing)
241
- return true;
242
- return !billing.subscriptionPath;
243
- }
244
212
  /**
245
213
  * Decide what the cost surface should render for a given harness + model
246
214
  * combination, plus whether the confirmation gate fires.
247
215
  *
248
216
  * Defaults:
249
217
  * - threshold: $1 / task (see DEFAULT_HIGH_COST_THRESHOLD_USD).
250
- * - subscription harness → suppress surface + skip gate.
251
- * - unknown model on a paid harness → show estimate slot (caller may
218
+ * - `usesPaidApiKey: false` → suppress surface + skip gate.
219
+ * - unknown model on a paid path → show estimate slot (caller may
252
220
  * render "estimate unavailable") but DO NOT trigger the gate.
253
221
  */
254
- export function decideCostSurface(harness, modelId, thresholdUsd = DEFAULT_HIGH_COST_THRESHOLD_USD) {
255
- if (!harnessUsesPaidApiKey(harness)) {
222
+ export function decideCostSurface(usesPaidApiKey, modelId, thresholdUsd = DEFAULT_HIGH_COST_THRESHOLD_USD) {
223
+ if (!usesPaidApiKey) {
256
224
  return {
257
225
  showEstimate: false,
258
226
  estimate: null,
@@ -1 +1 @@
1
- {"version":3,"file":"cost-estim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Q,EAAE,IAAI;YACd,oBAAoB,EAAE,KAAK;YAC3B,gBAAgB,EAAE,iDAAiD;SACpE,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7D,MAAM,0BAA0B,GAC9B,QAAQ,EAAE,KAAK,CAAC,gBAAgB,KAAK,IAAI,CAAC;IAC5C,IAAI,0BAA0B,EAAE,CAAC;QAC/B,OAAO;YACL,YAAY,EAAE,KAAK;YACnB,QAAQ,EAAE,IAAI;YACd,oBAAoB,EAAE,KAAK;YAC3B,gBAAgB,EAAE,iDAAiD;SACpE,CAAC;IACJ,CAAC;IACD,OAAO;QACL,YAAY,EAAE,IAAI;QAClB,QAAQ;QACR,oBAAoB,EAAE,QAAQ,KAAK,IAAI,IAAI,QAAQ,CAAC,GAAG,GAAG,YAAY;QACtE,gBAAgB,EAAE,IAAI;KACvB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,MAAc;IACtC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,GAAG,CAAC;IACzC,IAAI,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9B,IAAI,MAAM,GAAG,IAAI;QAAE,OAAO,QAAQ,CAAC;IACnC,IAAI,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/C,IAAI,MAAM,GAAG,EAAE;QAAE,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IAChD,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;AACjC,CAAC"}
@@ -22,9 +22,11 @@
22
22
  * Used for manifest signing: produce a deterministic byte string that two
23
23
  * independent parties can reproduce from the same object graph.
24
24
  */
25
- import { createRequire } from 'node:module';
26
- const require = createRequire(import.meta.url);
27
- const canonicalize = require('canonicalize');
25
+ // canonicalize v3 is ESM-only (no CJS entry); the client is `"type": "module"`
26
+ // so a native ESM default import is the correct interop (replaces the v2-era
27
+ // createRequire shim). v3 is packaging-only vs v2 — its RFC 8785 output is
28
+ // byte-identical, so existing content hashes / manifest signatures are stable.
29
+ import canonicalize from 'canonicalize';
28
30
  /**
29
31
  * Recursively replace NaN / ±Infinity with null so that canonicalize does not
30
32
  * throw — matching the JSON.stringify behaviour that the rest of the codebase
@@ -1 +1 @@
1
- {"version":3,"file":"canonical-json.js","sourceRoot":"","sources":["../../../src/harnesses/engine/canonical-json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,YAAY,GAAG,OAAO,CAAC,cAAc,CAA2C,CAAC;AAEvF;;;;;GAKG;AACH,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC/D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC5D,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,mEAAmE;QACnE,qEAAqE;QACrE,sEAAsE;QACtE,WAAW;QACX,MAAM,MAAM,GAAI,KAAoC,CAAC,MAAM,CAAC;QAC5D,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;YACjC,OAAO,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAC7C,CAAC;QACD,MAA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K,UAAU,EAAE,CAAC;YACjC,OAAO,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAC7C,CAAC;QACD,MAAM,GAAG,GAA4B,EAAE,CAAC;QACxC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,GAAG,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;QACxE,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IAEvC,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IACrC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,wEAAwE;QACxE,uEAAuE;QACvE,kCAAkC;QAClC,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -329,9 +329,15 @@ export declare class TaskEngine {
329
329
  * Performance contract (issue #398): this runs once per task announcement,
330
330
  * on the engine-watcher hot path, for every observed task. It MUST NOT
331
331
  * perform per-task blocking I/O. In particular it does not probe
332
- * `impl.isReady()` — for the Hermes harness that runs two blocking
333
- * `spawnSync` child processes, so a backlog would pay per-task blocking
334
- * spawns and starve the daemon event loop.
332
+ * `impl.isReady()` — historically the Hermes harness ran child processes
333
+ * inside its readiness probe, so a backlog would pay per-task blocking
334
+ * spawns and starve the daemon event loop. (#778 converted the matching
335
+ * post-execution `git diff` wedge in harvest.ts to async + 60s timeout;
336
+ * the #778 follow-up converted the readiness-probe spawns themselves —
337
+ * Hermes `doctor` / `auth list` and the codex-doctor `--version` probe —
338
+ * to async, so the registry's background refresh loop no longer blocks the
339
+ * main thread either. The readiness path remains O(1) here via the cache
340
+ * below.)
335
341
  *
336
342
  * Harness readiness for the claim gate is instead served O(1) from the
337
343
  * daemon's cached `HarnessReadinessRegistry` snapshot: the engine-watcher
@@ -561,9 +567,36 @@ export declare class TaskEngine {
561
567
  * when a previous run already produced the data.
562
568
  */
563
569
  private dataDrivenAdvance;
570
+ /**
571
+ * Classify a transition error and mark the task terminal accordingly.
572
+ *
573
+ * - `SafeInnerRevertError` with a non-recoverable inner name (the same
574
+ * set the daemon's pre-claim catch in `emitTickErrorOrRaceLost` uses):
575
+ * the on-chain slot is already pruned (TCMaxVerdictsReached,
576
+ * TCAttemptAlreadyFinalized, …). We mark the row RACE_LOST and emit a
577
+ * `kind=race_lost` activity event so operators can audit prunes
578
+ * without inflating the FAILED counter (#896).
579
+ * - A transport-transient error (e.g. `AllRpcsFailedError` — every provider
580
+ * in the L2 fallback chain failed at once) on a task whose delivery window
581
+ * is still open: leave the row in its current in-flight state so the next
582
+ * tick re-drives it once the RPCs recover, and emit a `tick_error` (warn)
583
+ * event instead of inflating the FAILED counter. Without this the daemon
584
+ * stamped the row FAILED, dropping it from `getInFlight()` permanently, so
585
+ * L2 work went silent until a manual restart (#912). Past-window transient
586
+ * errors still terminalize to avoid churning on work that can no longer
587
+ * settle.
588
+ * - Everything else: existing markFailed behaviour. When invoked from
589
+ * recovery, `contextLabel === 'recovery'` so the failure_reason
590
+ * carries the `recovery:` prefix the original code path used.
591
+ *
592
+ * Returns the classification so callers can log appropriately.
593
+ */
594
+ private _classifyAndMarkTerminal;
564
595
  /**
565
596
  * Wraps a transition method call with error handling: if the transition
566
- * throws, the task is marked FAILED with the error message.
597
+ * throws, the task is marked terminal (FAILED or RACE_LOST per
598
+ * `_classifyAndMarkTerminal`) and the error is rethrown so the caller can
599
+ * surface it.
567
600
  */
568
601
  private _runTransition;
569
602
  /**
@@ -16,8 +16,11 @@ import { provisionWorkingDir, provisionImplStateDir, walkArtifacts, uploadArtifa
16
16
  import { DONATION_ARTIFACT_ENCODING } from './artifact-scrub.js';
17
17
  import { assembleAndSignEnvelope, } from './envelope-assembly.js';
18
18
  import { deliverAndClaim, } from './delivery.js';
19
+ import { SafeInnerRevertError, isNonRecoverableInnerRevert, formatDecodedRevert, } from '../../adapters/mech/safe-revert.js';
20
+ import { emitEvent } from '../../observability/emit-event.js';
21
+ import { isRecoverableTransactionError } from '../../tx-retry.js';
19
22
  import { SkippableError } from '../types.js';
20
- import { submitEvaluatorFeedback, codeDigestSha256ToBytes32, modeStringToFlag, } from '../../erc8004/index.js';
23
+ import { submitEvaluatorFeedback, codeDigestSha256ToBytes32, encodeExecutionPayload, encodeExecutionPayloadV2, modeStringToFlag, } from '../../erc8004/index.js';
21
24
  import { TrajectoryCollector, emitTrajectory } from '../../trajectory/index.js';
22
25
  import { uploadToIpfs } from '../../adapters/mech/ipfs.js';
23
26
  import { VerdictCode } from '../../adapters/mech/verdict-code.js';
@@ -25,6 +28,7 @@ import { buildInfo } from '../../build-info.js';
25
28
  import { getSolverNetContract } from '../../vendor/@jinn-network/sdk/dist/solvernets/index.js';
26
29
  import { runHarnessWithFreezeFence, } from '../../daemon/freeze-fence.js';
27
30
  import { harnessStateDirName } from '../names.js';
31
+ import { recordTaskCost } from '../../spend/record.js';
28
32
  // ── Sentinel error ────────────────────────────────────────────────────────────
29
33
  export class NotImplementedError extends Error {
30
34
  transitionName;
@@ -150,9 +154,15 @@ export class TaskEngine {
150
154
  * Performance contract (issue #398): this runs once per task announcement,
151
155
  * on the engine-watcher hot path, for every observed task. It MUST NOT
152
156
  * perform per-task blocking I/O. In particular it does not probe
153
- * `impl.isReady()` — for the Hermes harness that runs two blocking
154
- * `spawnSync` child processes, so a backlog would pay per-task blocking
155
- * spawns and starve the daemon event loop.
157
+ * `impl.isReady()` — historically the Hermes harness ran child processes
158
+ * inside its readiness probe, so a backlog would pay per-task blocking
159
+ * spawns and starve the daemon event loop. (#778 converted the matching
160
+ * post-execution `git diff` wedge in harvest.ts to async + 60s timeout;
161
+ * the #778 follow-up converted the readiness-probe spawns themselves —
162
+ * Hermes `doctor` / `auth list` and the codex-doctor `--version` probe —
163
+ * to async, so the registry's background refresh loop no longer blocks the
164
+ * main thread either. The readiness path remains O(1) here via the cache
165
+ * below.)
156
166
  *
157
167
  * Harness readiness for the claim gate is instead served O(1) from the
158
168
  * daemon's cached `HarnessReadinessRegistry` snapshot: the engine-watcher
@@ -388,6 +398,7 @@ export class TaskEngine {
388
398
  break;
389
399
  case TaskRunState.COMPLETE:
390
400
  case TaskRunState.FAILED:
401
+ case TaskRunState.RACE_LOST:
391
402
  // Terminal — nothing to do.
392
403
  break;
393
404
  }
@@ -887,6 +898,18 @@ export class TaskEngine {
887
898
  clearTimeout(endTimer);
888
899
  }
889
900
  console.log(`[harness-engine] ${task.requestId} RUNNING → POST_SNAPSHOT via impl=${impl.name}`);
901
+ // Record the run's cost once it has cleanly reached POST_SNAPSHOT — i.e. the
902
+ // harness completed. Captures cost regardless of whether on-chain delivery
903
+ // later succeeds. Pre-completion early-exits (SkippableError, freeze-fence
904
+ // violation) intentionally do not record: the spend cap is an approximate
905
+ // graceful-pause control (design spec §2), not a precise ledger.
906
+ recordTaskCost(this.store, {
907
+ requestId: task.requestId,
908
+ harness: impl.name,
909
+ model: solverNet?.model,
910
+ workingDir,
911
+ solverType: task.solverType ?? null,
912
+ });
890
913
  }
891
914
  async takePostSnapshot(_intent) {
892
915
  throw new NotImplementedError('takePostSnapshot');
@@ -1312,6 +1335,8 @@ export class TaskEngine {
1312
1335
  !!harnessImplName;
1313
1336
  try {
1314
1337
  let pubTxHash;
1338
+ let pubBlockNumber;
1339
+ let payloadHex;
1315
1340
  if (canEmitV2) {
1316
1341
  const v2Payload = {
1317
1342
  version: 2,
@@ -1323,11 +1348,14 @@ export class TaskEngine {
1323
1348
  implName: harnessImplName,
1324
1349
  modeFlag: modeStringToFlag(task.executorMode),
1325
1350
  };
1326
- pubTxHash = await this.identityPublisher.publishContentV2({
1351
+ payloadHex = encodeExecutionPayloadV2(v2Payload);
1352
+ const result = await this.identityPublisher.publishContentV2({
1327
1353
  kind: metadataKind,
1328
1354
  cid: manifestCid,
1329
1355
  payload: v2Payload,
1330
1356
  });
1357
+ pubTxHash = result.txHash;
1358
+ pubBlockNumber = result.blockNumber;
1331
1359
  console.log(`[harness-engine] ${requestId}: setMetadata ${metadataKind}:${manifestCid} tx=${pubTxHash} (payload v2 mode=${task.executorMode} impl=${harnessImplName})`);
1332
1360
  }
1333
1361
  else {
@@ -1338,13 +1366,34 @@ export class TaskEngine {
1338
1366
  attestationQuoteCid: '0x',
1339
1367
  sourceMeasurement: '0x0000000000000000000000000000000000000000000000000000000000000000',
1340
1368
  };
1341
- pubTxHash = await this.identityPublisher.publishContent({
1369
+ payloadHex = encodeExecutionPayload(v1Payload);
1370
+ const result = await this.identityPublisher.publishContent({
1342
1371
  kind: metadataKind,
1343
1372
  cid: manifestCid,
1344
1373
  payload: v1Payload,
1345
1374
  });
1375
+ pubTxHash = result.txHash;
1376
+ pubBlockNumber = result.blockNumber;
1346
1377
  console.log(`[harness-engine] ${requestId}: setMetadata ${metadataKind}:${manifestCid} tx=${pubTxHash} (payload v1)`);
1347
1378
  }
1379
+ try {
1380
+ this.store.saveErc8004Anchor({
1381
+ envelopeId: manifestHashHex,
1382
+ envelopeCid: manifestCid,
1383
+ contentKind: metadataKind,
1384
+ metadataKey: `${metadataKind}:${manifestCid}`,
1385
+ agentId: this.identityPublisher.agent.toString(),
1386
+ chainId: this.identityPublisher.chainId,
1387
+ identityRegistryAddress: this.identityPublisher.registry,
1388
+ txHash: pubTxHash,
1389
+ blockNumber: pubBlockNumber,
1390
+ payloadHex,
1391
+ anchoredAt: Math.floor(Date.now() / 1000),
1392
+ });
1393
+ }
1394
+ catch (anchorErr) {
1395
+ console.warn(`[harness-engine] ${requestId}: failed to record erc8004 anchor (non-fatal): ${anchorErr instanceof Error ? anchorErr.message : anchorErr}`);
1396
+ }
1348
1397
  }
1349
1398
  catch (err) {
1350
1399
  console.warn(`[harness-engine] ${requestId}: setMetadata ${metadataKind} publish failed (non-fatal): ${err instanceof Error ? err.message : err}`);
@@ -1573,9 +1622,73 @@ export class TaskEngine {
1573
1622
  return null;
1574
1623
  }
1575
1624
  }
1625
+ /**
1626
+ * Classify a transition error and mark the task terminal accordingly.
1627
+ *
1628
+ * - `SafeInnerRevertError` with a non-recoverable inner name (the same
1629
+ * set the daemon's pre-claim catch in `emitTickErrorOrRaceLost` uses):
1630
+ * the on-chain slot is already pruned (TCMaxVerdictsReached,
1631
+ * TCAttemptAlreadyFinalized, …). We mark the row RACE_LOST and emit a
1632
+ * `kind=race_lost` activity event so operators can audit prunes
1633
+ * without inflating the FAILED counter (#896).
1634
+ * - A transport-transient error (e.g. `AllRpcsFailedError` — every provider
1635
+ * in the L2 fallback chain failed at once) on a task whose delivery window
1636
+ * is still open: leave the row in its current in-flight state so the next
1637
+ * tick re-drives it once the RPCs recover, and emit a `tick_error` (warn)
1638
+ * event instead of inflating the FAILED counter. Without this the daemon
1639
+ * stamped the row FAILED, dropping it from `getInFlight()` permanently, so
1640
+ * L2 work went silent until a manual restart (#912). Past-window transient
1641
+ * errors still terminalize to avoid churning on work that can no longer
1642
+ * settle.
1643
+ * - Everything else: existing markFailed behaviour. When invoked from
1644
+ * recovery, `contextLabel === 'recovery'` so the failure_reason
1645
+ * carries the `recovery:` prefix the original code path used.
1646
+ *
1647
+ * Returns the classification so callers can log appropriately.
1648
+ */
1649
+ _classifyAndMarkTerminal(task, err, contextLabel) {
1650
+ if (err instanceof SafeInnerRevertError &&
1651
+ isNonRecoverableInnerRevert(err.decodedName)) {
1652
+ // decodedName is non-null by virtue of isNonRecoverableInnerRevert.
1653
+ const detail = formatDecodedRevert(err.decodedName, err.decodedArgs);
1654
+ this.persistence.markRaceLost(task.requestId, detail);
1655
+ emitEvent(this.store, {
1656
+ kind: 'race_lost',
1657
+ requestId: task.requestId,
1658
+ solverType: task.solverType ?? undefined,
1659
+ outcome: 'ok',
1660
+ detail,
1661
+ }, 'harness-engine');
1662
+ return 'race_lost';
1663
+ }
1664
+ const reason = err instanceof Error ? err.message : String(err);
1665
+ // A transport-transient failure (all RPC providers in the fallback chain
1666
+ // blipped at once, 429s, timeouts, …) is not the task's fault and is not
1667
+ // permanent. Leave the row in its in-flight state — do NOT call
1668
+ // markFailed, which would drop it from getInFlight() forever (#912) — so
1669
+ // the engine-tick loop re-drives it once the RPCs recover. The tick loop
1670
+ // IS the retry; there is no per-task attempt counter. Skip this only once
1671
+ // the delivery window has closed, so we never churn on work that can no
1672
+ // longer settle on-chain.
1673
+ if (task.windowEndTs > Date.now() && isRecoverableTransactionError(err)) {
1674
+ emitEvent(this.store, {
1675
+ kind: 'tick_error',
1676
+ requestId: task.requestId,
1677
+ solverType: task.solverType ?? undefined,
1678
+ outcome: 'warn',
1679
+ detail: `transient RPC failure in ${contextLabel}; left ${task.state} for retry: ${reason}`,
1680
+ }, 'harness-engine');
1681
+ return 'transient';
1682
+ }
1683
+ const stamped = contextLabel === 'recovery' ? `recovery: ${reason}` : reason;
1684
+ this.persistence.markFailed(task.requestId, stamped);
1685
+ return 'failed';
1686
+ }
1576
1687
  /**
1577
1688
  * Wraps a transition method call with error handling: if the transition
1578
- * throws, the task is marked FAILED with the error message.
1689
+ * throws, the task is marked terminal (FAILED or RACE_LOST per
1690
+ * `_classifyAndMarkTerminal`) and the error is rethrown so the caller can
1691
+ * surface it.
1579
1692
  */
1580
1693
  async _runTransition(task, fn) {
1581
1694
  // Each transition method (claim, takePreSnapshot, runImpl, pack, deliver)
@@ -1583,14 +1696,12 @@ export class TaskEngine {
1583
1696
  // deliveryTx, impl name). We deliberately don't emit a generic
1584
1697
  // `oldState → newState` line here: doing so produced duplicate
1585
1698
  // transition lines in the operator log (jinn-mono-kzan). On failure,
1586
- // the catch below marks the task FAILED and rethrows so the caller can
1587
- // surface the error.
1699
+ // the catch below routes through the race-loss classifier and rethrows.
1588
1700
  try {
1589
1701
  await fn();
1590
1702
  }
1591
1703
  catch (err) {
1592
- const reason = err instanceof Error ? err.message : String(err);
1593
- this.persistence.markFailed(task.requestId, reason);
1704
+ this._classifyAndMarkTerminal(task, err, 'transition');
1594
1705
  throw err;
1595
1706
  }
1596
1707
  }
@@ -1603,15 +1714,25 @@ export class TaskEngine {
1603
1714
  await this._recoverDispatch(task);
1604
1715
  }
1605
1716
  catch (err) {
1606
- // If recovery itself throws (e.g. NotImplementedError stub), mark failed.
1607
- // NotImplementedError is expected during development; don't swallow it in prod.
1608
- const reason = err instanceof Error ? err.message : String(err);
1609
- // Only mark failed if the task is still in the same non-terminal state
1717
+ // If recovery itself throws (e.g. NotImplementedError stub), classify
1718
+ // the error and mark the row terminal. NotImplementedError is expected
1719
+ // during development; don't swallow it in prod.
1720
+ // Only act if the task is still in the same non-terminal state
1610
1721
  // (another concurrent recovery pass might have already advanced it).
1611
1722
  const current = this.persistence.getByRequestId(task.requestId);
1612
1723
  if (current && current.state === task.state) {
1613
- this.persistence.markFailed(task.requestId, `recovery: ${reason}`);
1614
- console.error(`[harness-engine] resume failed for ${task.requestId}: ${reason}`);
1724
+ const classification = this._classifyAndMarkTerminal(task, err, 'recovery');
1725
+ const reason = err instanceof Error ? err.message : String(err);
1726
+ // 'transient' leaves the row in-flight (not terminal); the next tick
1727
+ // re-drives it once the RPCs recover (#912). Log it at warn so the
1728
+ // stall is visible without firing the error-level alerting that a
1729
+ // genuine failure does.
1730
+ const { log, verb } = {
1731
+ race_lost: { log: console.log, verb: 'pruned' },
1732
+ transient: { log: console.warn, verb: 'deferred (transient RPC)' },
1733
+ failed: { log: console.error, verb: 'failed' },
1734
+ }[classification];
1735
+ log(`[harness-engine] resume ${verb} for ${task.requestId}: ${reason}`);
1615
1736
  }
1616
1737
  throw err;
1617
1738
  }