open-multi-agent-kit 0.98.4 → 0.99.0

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 (357) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +4 -2
  3. package/dist/cli/help.d.ts.map +1 -1
  4. package/dist/cli/help.js +1 -0
  5. package/dist/cli/help.js.map +1 -1
  6. package/dist/commands/run-command.d.ts +2 -1
  7. package/dist/commands/run-command.d.ts.map +1 -1
  8. package/dist/commands/run-command.js +9 -1
  9. package/dist/commands/run-command.js.map +1 -1
  10. package/dist/commands/verified-run-cli.d.ts +6 -0
  11. package/dist/commands/verified-run-cli.d.ts.map +1 -0
  12. package/dist/commands/verified-run-cli.js +190 -0
  13. package/dist/commands/verified-run-cli.js.map +1 -0
  14. package/dist/core/agent-session-services.d.ts +8 -1
  15. package/dist/core/agent-session-services.d.ts.map +1 -1
  16. package/dist/core/agent-session-services.js +41 -0
  17. package/dist/core/agent-session-services.js.map +1 -1
  18. package/dist/core/agent-session.d.ts +7 -8
  19. package/dist/core/agent-session.d.ts.map +1 -1
  20. package/dist/core/agent-session.js +80 -43
  21. package/dist/core/agent-session.js.map +1 -1
  22. package/dist/core/devin-harness-dispatch.d.ts +12 -0
  23. package/dist/core/devin-harness-dispatch.d.ts.map +1 -0
  24. package/dist/core/devin-harness-dispatch.js +12 -0
  25. package/dist/core/devin-harness-dispatch.js.map +1 -0
  26. package/dist/core/devin-harness.d.ts +53 -0
  27. package/dist/core/devin-harness.d.ts.map +1 -0
  28. package/dist/core/devin-harness.js +112 -0
  29. package/dist/core/devin-harness.js.map +1 -0
  30. package/dist/core/domain-dispatch.d.ts +4 -1
  31. package/dist/core/domain-dispatch.d.ts.map +1 -1
  32. package/dist/core/domain-dispatch.js +5 -0
  33. package/dist/core/domain-dispatch.js.map +1 -1
  34. package/dist/core/domain-loadouts-provider-harness.d.ts +12 -0
  35. package/dist/core/domain-loadouts-provider-harness.d.ts.map +1 -0
  36. package/dist/core/domain-loadouts-provider-harness.js +122 -0
  37. package/dist/core/domain-loadouts-provider-harness.js.map +1 -0
  38. package/dist/core/domain-loadouts.d.ts +2 -33
  39. package/dist/core/domain-loadouts.d.ts.map +1 -1
  40. package/dist/core/domain-loadouts.js +3 -56
  41. package/dist/core/domain-loadouts.js.map +1 -1
  42. package/dist/core/domain-profile.d.ts +40 -0
  43. package/dist/core/domain-profile.d.ts.map +1 -0
  44. package/dist/core/domain-profile.js +7 -0
  45. package/dist/core/domain-profile.js.map +1 -0
  46. package/dist/core/grok-harness-dispatch.d.ts +6 -20
  47. package/dist/core/grok-harness-dispatch.d.ts.map +1 -1
  48. package/dist/core/grok-harness-dispatch.js +6 -55
  49. package/dist/core/grok-harness-dispatch.js.map +1 -1
  50. package/dist/core/grok-harness.d.ts +7 -9
  51. package/dist/core/grok-harness.d.ts.map +1 -1
  52. package/dist/core/grok-harness.js +9 -23
  53. package/dist/core/grok-harness.js.map +1 -1
  54. package/dist/core/harness-skills.d.ts +20 -0
  55. package/dist/core/harness-skills.d.ts.map +1 -0
  56. package/dist/core/harness-skills.js +36 -0
  57. package/dist/core/harness-skills.js.map +1 -0
  58. package/dist/core/loadout-runtime-state.d.ts +25 -0
  59. package/dist/core/loadout-runtime-state.d.ts.map +1 -0
  60. package/dist/core/loadout-runtime-state.js +39 -0
  61. package/dist/core/loadout-runtime-state.js.map +1 -0
  62. package/dist/core/loadout-runtime.d.ts +2 -12
  63. package/dist/core/loadout-runtime.d.ts.map +1 -1
  64. package/dist/core/loadout-runtime.js +6 -13
  65. package/dist/core/loadout-runtime.js.map +1 -1
  66. package/dist/core/model-resolver.d.ts +1 -41
  67. package/dist/core/model-resolver.d.ts.map +1 -1
  68. package/dist/core/model-resolver.js +2 -49
  69. package/dist/core/model-resolver.js.map +1 -1
  70. package/dist/core/prompt-settlement.d.ts +4 -3
  71. package/dist/core/prompt-settlement.d.ts.map +1 -1
  72. package/dist/core/prompt-settlement.js.map +1 -1
  73. package/dist/core/provider-default-models.d.ts +42 -0
  74. package/dist/core/provider-default-models.d.ts.map +1 -0
  75. package/dist/core/provider-default-models.js +50 -0
  76. package/dist/core/provider-default-models.js.map +1 -0
  77. package/dist/core/provider-display-names.d.ts.map +1 -1
  78. package/dist/core/provider-display-names.js +1 -0
  79. package/dist/core/provider-display-names.js.map +1 -1
  80. package/dist/core/provider-harness-dispatch.d.ts +63 -0
  81. package/dist/core/provider-harness-dispatch.d.ts.map +1 -0
  82. package/dist/core/provider-harness-dispatch.js +60 -0
  83. package/dist/core/provider-harness-dispatch.js.map +1 -0
  84. package/dist/core/provider-usage-devin.d.ts +16 -0
  85. package/dist/core/provider-usage-devin.d.ts.map +1 -0
  86. package/dist/core/provider-usage-devin.js +61 -0
  87. package/dist/core/provider-usage-devin.js.map +1 -0
  88. package/dist/core/provider-usage-text.d.ts +5 -0
  89. package/dist/core/provider-usage-text.d.ts.map +1 -0
  90. package/dist/core/provider-usage-text.js +15 -0
  91. package/dist/core/provider-usage-text.js.map +1 -0
  92. package/dist/core/provider-usage-types.d.ts +2 -1
  93. package/dist/core/provider-usage-types.d.ts.map +1 -1
  94. package/dist/core/provider-usage-types.js.map +1 -1
  95. package/dist/core/provider-usage.d.ts +1 -2
  96. package/dist/core/provider-usage.d.ts.map +1 -1
  97. package/dist/core/provider-usage.js +12 -7
  98. package/dist/core/provider-usage.js.map +1 -1
  99. package/dist/core/run-budget-policy.d.ts +18 -0
  100. package/dist/core/run-budget-policy.d.ts.map +1 -0
  101. package/dist/core/run-budget-policy.js +52 -0
  102. package/dist/core/run-budget-policy.js.map +1 -0
  103. package/dist/core/run-budget.d.ts +33 -0
  104. package/dist/core/run-budget.d.ts.map +1 -0
  105. package/dist/core/run-budget.js +89 -0
  106. package/dist/core/run-budget.js.map +1 -0
  107. package/dist/core/run-execution-api.d.ts +15 -0
  108. package/dist/core/run-execution-api.d.ts.map +1 -0
  109. package/dist/core/run-execution-api.js +7 -0
  110. package/dist/core/run-execution-api.js.map +1 -0
  111. package/dist/core/run-journal.d.ts.map +1 -1
  112. package/dist/core/run-journal.js +30 -208
  113. package/dist/core/run-journal.js.map +1 -1
  114. package/dist/core/sdk.d.ts.map +1 -1
  115. package/dist/core/sdk.js +23 -18
  116. package/dist/core/sdk.js.map +1 -1
  117. package/dist/core/session-bash-service.d.ts +2 -2
  118. package/dist/core/session-bash-service.d.ts.map +1 -1
  119. package/dist/core/session-bash-service.js +21 -9
  120. package/dist/core/session-bash-service.js.map +1 -1
  121. package/dist/core/session-failure-cause.d.ts.map +1 -1
  122. package/dist/core/session-failure-cause.js +5 -0
  123. package/dist/core/session-failure-cause.js.map +1 -1
  124. package/dist/core/session-prompt-lifecycle.d.ts +25 -0
  125. package/dist/core/session-prompt-lifecycle.d.ts.map +1 -0
  126. package/dist/core/session-prompt-lifecycle.js +87 -0
  127. package/dist/core/session-prompt-lifecycle.js.map +1 -0
  128. package/dist/core/session-run-budget.d.ts +28 -0
  129. package/dist/core/session-run-budget.d.ts.map +1 -0
  130. package/dist/core/session-run-budget.js +127 -0
  131. package/dist/core/session-run-budget.js.map +1 -0
  132. package/dist/core/session-run-termination.d.ts.map +1 -1
  133. package/dist/core/session-run-termination.js +14 -3
  134. package/dist/core/session-run-termination.js.map +1 -1
  135. package/dist/core/session-termination-types.d.ts +97 -0
  136. package/dist/core/session-termination-types.d.ts.map +1 -0
  137. package/dist/core/session-termination-types.js +26 -0
  138. package/dist/core/session-termination-types.js.map +1 -0
  139. package/dist/core/session-termination.d.ts +3 -97
  140. package/dist/core/session-termination.d.ts.map +1 -1
  141. package/dist/core/session-termination.js +24 -28
  142. package/dist/core/session-termination.js.map +1 -1
  143. package/dist/core/slash-commands.d.ts.map +1 -1
  144. package/dist/core/slash-commands.js +1 -0
  145. package/dist/core/slash-commands.js.map +1 -1
  146. package/dist/core/subagent-lane-launcher.d.ts +3 -2
  147. package/dist/core/subagent-lane-launcher.d.ts.map +1 -1
  148. package/dist/core/subagent-lane-launcher.js +24 -13
  149. package/dist/core/subagent-lane-launcher.js.map +1 -1
  150. package/dist/core/verified-run/broker.d.ts +26 -0
  151. package/dist/core/verified-run/broker.d.ts.map +1 -0
  152. package/dist/core/verified-run/broker.js +210 -0
  153. package/dist/core/verified-run/broker.js.map +1 -0
  154. package/dist/core/verified-run/candidate.d.ts +24 -0
  155. package/dist/core/verified-run/candidate.d.ts.map +1 -0
  156. package/dist/core/verified-run/candidate.js +167 -0
  157. package/dist/core/verified-run/candidate.js.map +1 -0
  158. package/dist/core/verified-run/check-receipt.d.ts +18 -0
  159. package/dist/core/verified-run/check-receipt.d.ts.map +1 -0
  160. package/dist/core/verified-run/check-receipt.js +92 -0
  161. package/dist/core/verified-run/check-receipt.js.map +1 -0
  162. package/dist/core/verified-run/coordinator.d.ts +39 -0
  163. package/dist/core/verified-run/coordinator.d.ts.map +1 -0
  164. package/dist/core/verified-run/coordinator.js +190 -0
  165. package/dist/core/verified-run/coordinator.js.map +1 -0
  166. package/dist/core/verified-run/dag-candidates.d.ts +8 -0
  167. package/dist/core/verified-run/dag-candidates.d.ts.map +1 -0
  168. package/dist/core/verified-run/dag-candidates.js +65 -0
  169. package/dist/core/verified-run/dag-candidates.js.map +1 -0
  170. package/dist/core/verified-run/dag-phase.d.ts +7 -0
  171. package/dist/core/verified-run/dag-phase.d.ts.map +1 -0
  172. package/dist/core/verified-run/dag-phase.js +130 -0
  173. package/dist/core/verified-run/dag-phase.js.map +1 -0
  174. package/dist/core/verified-run/dag-projection.d.ts +7 -0
  175. package/dist/core/verified-run/dag-projection.d.ts.map +1 -0
  176. package/dist/core/verified-run/dag-projection.js +103 -0
  177. package/dist/core/verified-run/dag-projection.js.map +1 -0
  178. package/dist/core/verified-run/dag-recovery.d.ts +13 -0
  179. package/dist/core/verified-run/dag-recovery.d.ts.map +1 -0
  180. package/dist/core/verified-run/dag-recovery.js +98 -0
  181. package/dist/core/verified-run/dag-recovery.js.map +1 -0
  182. package/dist/core/verified-run/dag-retry-projection.d.ts +9 -0
  183. package/dist/core/verified-run/dag-retry-projection.d.ts.map +1 -0
  184. package/dist/core/verified-run/dag-retry-projection.js +43 -0
  185. package/dist/core/verified-run/dag-retry-projection.js.map +1 -0
  186. package/dist/core/verified-run/dag-types.d.ts +58 -0
  187. package/dist/core/verified-run/dag-types.d.ts.map +1 -0
  188. package/dist/core/verified-run/dag-types.js +2 -0
  189. package/dist/core/verified-run/dag-types.js.map +1 -0
  190. package/dist/core/verified-run/event-parser.d.ts +3 -0
  191. package/dist/core/verified-run/event-parser.d.ts.map +1 -0
  192. package/dist/core/verified-run/event-parser.js +154 -0
  193. package/dist/core/verified-run/event-parser.js.map +1 -0
  194. package/dist/core/verified-run/events.d.ts +4 -0
  195. package/dist/core/verified-run/events.d.ts.map +1 -0
  196. package/dist/core/verified-run/events.js +3 -0
  197. package/dist/core/verified-run/events.js.map +1 -0
  198. package/dist/core/verified-run/evidence-binding.d.ts +18 -0
  199. package/dist/core/verified-run/evidence-binding.d.ts.map +1 -0
  200. package/dist/core/verified-run/evidence-binding.js +81 -0
  201. package/dist/core/verified-run/evidence-binding.js.map +1 -0
  202. package/dist/core/verified-run/evidence.d.ts +27 -0
  203. package/dist/core/verified-run/evidence.d.ts.map +1 -0
  204. package/dist/core/verified-run/evidence.js +100 -0
  205. package/dist/core/verified-run/evidence.js.map +1 -0
  206. package/dist/core/verified-run/journal.d.ts +32 -0
  207. package/dist/core/verified-run/journal.d.ts.map +1 -0
  208. package/dist/core/verified-run/journal.js +103 -0
  209. package/dist/core/verified-run/journal.js.map +1 -0
  210. package/dist/core/verified-run/namespace-identity.d.ts +11 -0
  211. package/dist/core/verified-run/namespace-identity.d.ts.map +1 -0
  212. package/dist/core/verified-run/namespace-identity.js +77 -0
  213. package/dist/core/verified-run/namespace-identity.js.map +1 -0
  214. package/dist/core/verified-run/owned-execution.d.ts +22 -0
  215. package/dist/core/verified-run/owned-execution.d.ts.map +1 -0
  216. package/dist/core/verified-run/owned-execution.js +49 -0
  217. package/dist/core/verified-run/owned-execution.js.map +1 -0
  218. package/dist/core/verified-run/phase-context.d.ts +9 -0
  219. package/dist/core/verified-run/phase-context.d.ts.map +1 -0
  220. package/dist/core/verified-run/phase-context.js +2 -0
  221. package/dist/core/verified-run/phase-context.js.map +1 -0
  222. package/dist/core/verified-run/process-gate.d.ts +5 -0
  223. package/dist/core/verified-run/process-gate.d.ts.map +1 -0
  224. package/dist/core/verified-run/process-gate.js +31 -0
  225. package/dist/core/verified-run/process-gate.js.map +1 -0
  226. package/dist/core/verified-run/process-projection.d.ts +13 -0
  227. package/dist/core/verified-run/process-projection.d.ts.map +1 -0
  228. package/dist/core/verified-run/process-projection.js +82 -0
  229. package/dist/core/verified-run/process-projection.js.map +1 -0
  230. package/dist/core/verified-run/projection.d.ts +4 -0
  231. package/dist/core/verified-run/projection.d.ts.map +1 -0
  232. package/dist/core/verified-run/projection.js +175 -0
  233. package/dist/core/verified-run/projection.js.map +1 -0
  234. package/dist/core/verified-run/recovery-clock.d.ts +19 -0
  235. package/dist/core/verified-run/recovery-clock.d.ts.map +1 -0
  236. package/dist/core/verified-run/recovery-clock.js +69 -0
  237. package/dist/core/verified-run/recovery-clock.js.map +1 -0
  238. package/dist/core/verified-run/recovery-command.d.ts +11 -0
  239. package/dist/core/verified-run/recovery-command.d.ts.map +1 -0
  240. package/dist/core/verified-run/recovery-command.js +73 -0
  241. package/dist/core/verified-run/recovery-command.js.map +1 -0
  242. package/dist/core/verified-run/recovery-projection.d.ts +12 -0
  243. package/dist/core/verified-run/recovery-projection.d.ts.map +1 -0
  244. package/dist/core/verified-run/recovery-projection.js +88 -0
  245. package/dist/core/verified-run/recovery-projection.js.map +1 -0
  246. package/dist/core/verified-run/recovery.d.ts +12 -0
  247. package/dist/core/verified-run/recovery.d.ts.map +1 -0
  248. package/dist/core/verified-run/recovery.js +115 -0
  249. package/dist/core/verified-run/recovery.js.map +1 -0
  250. package/dist/core/verified-run/run-types.d.ts +104 -0
  251. package/dist/core/verified-run/run-types.d.ts.map +1 -0
  252. package/dist/core/verified-run/run-types.js +2 -0
  253. package/dist/core/verified-run/run-types.js.map +1 -0
  254. package/dist/core/verified-run/scripted-writer.d.ts +15 -0
  255. package/dist/core/verified-run/scripted-writer.d.ts.map +1 -0
  256. package/dist/core/verified-run/scripted-writer.js +94 -0
  257. package/dist/core/verified-run/scripted-writer.js.map +1 -0
  258. package/dist/core/verified-run/session-port.d.ts +27 -0
  259. package/dist/core/verified-run/session-port.d.ts.map +1 -0
  260. package/dist/core/verified-run/session-port.js +2 -0
  261. package/dist/core/verified-run/session-port.js.map +1 -0
  262. package/dist/core/verified-run/storage.d.ts +15 -0
  263. package/dist/core/verified-run/storage.d.ts.map +1 -0
  264. package/dist/core/verified-run/storage.js +96 -0
  265. package/dist/core/verified-run/storage.js.map +1 -0
  266. package/dist/core/verified-run/task-execution.d.ts +9 -0
  267. package/dist/core/verified-run/task-execution.d.ts.map +1 -0
  268. package/dist/core/verified-run/task-execution.js +29 -0
  269. package/dist/core/verified-run/task-execution.js.map +1 -0
  270. package/dist/core/verified-run/verification-phase.d.ts +5 -0
  271. package/dist/core/verified-run/verification-phase.d.ts.map +1 -0
  272. package/dist/core/verified-run/verification-phase.js +56 -0
  273. package/dist/core/verified-run/verification-phase.js.map +1 -0
  274. package/dist/core/verified-run/work-recovery.d.ts +8 -0
  275. package/dist/core/verified-run/work-recovery.d.ts.map +1 -0
  276. package/dist/core/verified-run/work-recovery.js +44 -0
  277. package/dist/core/verified-run/work-recovery.js.map +1 -0
  278. package/dist/core/verified-run/writer-completion.d.ts +4 -0
  279. package/dist/core/verified-run/writer-completion.d.ts.map +1 -0
  280. package/dist/core/verified-run/writer-completion.js +27 -0
  281. package/dist/core/verified-run/writer-completion.js.map +1 -0
  282. package/dist/core/verified-run/writer-phase.d.ts +8 -0
  283. package/dist/core/verified-run/writer-phase.d.ts.map +1 -0
  284. package/dist/core/verified-run/writer-phase.js +76 -0
  285. package/dist/core/verified-run/writer-phase.js.map +1 -0
  286. package/dist/core/verified-run/writer-projection.d.ts +11 -0
  287. package/dist/core/verified-run/writer-projection.d.ts.map +1 -0
  288. package/dist/core/verified-run/writer-projection.js +71 -0
  289. package/dist/core/verified-run/writer-projection.js.map +1 -0
  290. package/dist/core/verified-run/writer-recovery.d.ts +16 -0
  291. package/dist/core/verified-run/writer-recovery.d.ts.map +1 -0
  292. package/dist/core/verified-run/writer-recovery.js +107 -0
  293. package/dist/core/verified-run/writer-recovery.js.map +1 -0
  294. package/dist/core/workload-permit-pool.d.ts +1 -3
  295. package/dist/core/workload-permit-pool.d.ts.map +1 -1
  296. package/dist/core/workload-permit-pool.js +11 -11
  297. package/dist/core/workload-permit-pool.js.map +1 -1
  298. package/dist/index.d.ts +3 -2
  299. package/dist/index.d.ts.map +1 -1
  300. package/dist/index.js +2 -2
  301. package/dist/index.js.map +1 -1
  302. package/dist/main.d.ts.map +1 -1
  303. package/dist/main.js +2 -8
  304. package/dist/main.js.map +1 -1
  305. package/dist/modes/interactive/components/session-failure.d.ts +13 -0
  306. package/dist/modes/interactive/components/session-failure.d.ts.map +1 -0
  307. package/dist/modes/interactive/components/session-failure.js +81 -0
  308. package/dist/modes/interactive/components/session-failure.js.map +1 -0
  309. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  310. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  311. package/dist/modes/interactive/interactive-mode.js +47 -36
  312. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  313. package/dist/modes/interactive/resource-description.d.ts +3 -0
  314. package/dist/modes/interactive/resource-description.d.ts.map +1 -0
  315. package/dist/modes/interactive/resource-description.js +15 -0
  316. package/dist/modes/interactive/resource-description.js.map +1 -0
  317. package/dist/modes/interactive/tui-diagnostics.d.ts +36 -0
  318. package/dist/modes/interactive/tui-diagnostics.d.ts.map +1 -0
  319. package/dist/modes/interactive/tui-diagnostics.js +105 -0
  320. package/dist/modes/interactive/tui-diagnostics.js.map +1 -0
  321. package/dist/modes/interactive/tui-runtime-info.d.ts +20 -0
  322. package/dist/modes/interactive/tui-runtime-info.d.ts.map +1 -0
  323. package/dist/modes/interactive/tui-runtime-info.js +76 -0
  324. package/dist/modes/interactive/tui-runtime-info.js.map +1 -0
  325. package/docs/development.md +10 -0
  326. package/docs/devin-harness.md +121 -0
  327. package/docs/docs.json +4 -0
  328. package/docs/environment-variables.md +2 -1
  329. package/docs/index.md +1 -0
  330. package/docs/keybindings.md +1 -1
  331. package/docs/loadout-domains/README.md +2 -1
  332. package/docs/loadout-domains/devin-harness.md +72 -0
  333. package/docs/metrics.md +57 -16
  334. package/docs/providers.md +76 -0
  335. package/docs/release-audit-0.98.5.md +101 -0
  336. package/docs/release-audit-0.99.0.md +68 -0
  337. package/docs/run-protocol.md +34 -1
  338. package/docs/runtime-algorithms.md +30 -1
  339. package/docs/sdk.md +198 -1
  340. package/docs/settings.md +1 -1
  341. package/docs/startup-resource-labels-testing.md +47 -0
  342. package/docs/tb21-audit.md +18 -4
  343. package/docs/usage.md +59 -0
  344. package/docs/verified-run-remaining-design.md +881 -0
  345. package/docs/verified-run-testing.md +508 -0
  346. package/docs/verified-run.md +409 -0
  347. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  348. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  349. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  350. package/examples/extensions/gondolin/package-lock.json +2 -2
  351. package/examples/extensions/gondolin/package.json +1 -1
  352. package/examples/extensions/sandbox/package-lock.json +2 -2
  353. package/examples/extensions/sandbox/package.json +1 -1
  354. package/examples/extensions/with-deps/package-lock.json +2 -2
  355. package/examples/extensions/with-deps/package.json +1 -1
  356. package/npm-shrinkwrap.json +18 -18
  357. package/package.json +6 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/storage.ts"],"names":[],"mappings":"AAMA,qBAAa,gBAAiB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,YAAY,IAAI,EAAE,MAAM,EAIvB;CACD;AAED,eAAO,MAAM,WAAW,yDAA2F,CAAC;AACpH,eAAO,MAAM,YAAY,4BAAgE,CAAC;AAE1F,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAetE;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,SAAU,GAAG,OAAO,CAOlE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAOlE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAIlE;AAED,wGAAwG;AACxG,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAG7D;AAED,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAwBtF;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAElD","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { closeSync, constants, fstatSync, lstatSync, openSync, readFileSync, realpathSync } from \"node:fs\";\nimport { basename, dirname, join, relative, resolve } from \"node:path\";\nimport { writeExclusiveFileDurablySync } from \"../durable-file-io.ts\";\nimport { canonicalJson } from \"../run-journal.ts\";\n\nexport class VerifiedRunError extends Error {\n\treadonly code: string;\n\tconstructor(code: string) {\n\t\tsuper(`verified-run: ${code}`);\n\t\tthis.name = \"VerifiedRunError\";\n\t\tthis.code = code;\n\t}\n}\n\nexport const digestBytes = (bytes: Uint8Array | string): string => createHash(\"sha256\").update(bytes).digest(\"hex\");\nexport const digestObject = (value: unknown): string => digestBytes(canonicalJson(value));\n\nexport function readRegularFile(path: string, maxBytes: number): Buffer {\n\tconst fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);\n\ttry {\n\t\tconst before = fstatSync(fd, { bigint: true });\n\t\tif (!before.isFile() || before.nlink !== 1n) throw new VerifiedRunError(\"file_type\");\n\t\tif (before.size > BigInt(maxBytes)) throw new VerifiedRunError(\"storage_limit\");\n\t\tconst bytes = readFileSync(fd);\n\t\tconst after = fstatSync(fd, { bigint: true });\n\t\tif (before.size !== after.size || before.ctimeNs !== after.ctimeNs || BigInt(bytes.length) !== before.size) {\n\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t}\n\t\treturn bytes;\n\t} finally {\n\t\tcloseSync(fd);\n\t}\n}\n\nexport function readJson(path: string, maxBytes = 1048576): unknown {\n\ttry {\n\t\treturn JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(readRegularFile(path, maxBytes)));\n\t} catch (error) {\n\t\tif (error instanceof SyntaxError || error instanceof TypeError) throw new VerifiedRunError(\"integrity\");\n\t\tthrow error;\n\t}\n}\n\nexport function publishBytes(path: string, bytes: Uint8Array): void {\n\ttry {\n\t\twriteExclusiveFileDurablySync(path, bytes);\n\t} catch (error) {\n\t\tif (!(error instanceof Error && \"code\" in error && error.code === \"EEXIST\")) throw error;\n\t\tif (!readRegularFile(path, bytes.length).equals(Buffer.from(bytes))) throw new VerifiedRunError(\"integrity\");\n\t}\n}\n\nexport function publishObject(path: string, value: unknown): string {\n\tconst bytes = Buffer.from(canonicalJson(value));\n\tpublishBytes(path, bytes);\n\treturn digestBytes(bytes);\n}\n\n/** Resolve existing parents without creating state. State must never be part of a mounted workspace. */\nexport function stateRunPath(root: string, id: string): string {\n\tif (!/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/.test(id)) throw new VerifiedRunError(\"run_id\");\n\treturn join(resolve(root), id);\n}\n\nexport function assertStateOutsideWorkspace(stateRoot: string, workspace: string): void {\n\tlet cursor = resolve(stateRoot);\n\tconst tail: string[] = [];\n\twhile (true) {\n\t\ttry {\n\t\t\tcursor = join(realpathSync(cursor), ...tail);\n\t\t\tbreak;\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof Error && \"code\" in error && error.code === \"ENOENT\")) throw error;\n\t\t\ttail.unshift(basename(cursor));\n\t\t\tcursor = dirname(cursor);\n\t\t}\n\t}\n\tconst base = realpathSync(workspace);\n\tconst under = relative(base, cursor);\n\tconst contains = relative(cursor, base);\n\tif (\n\t\tunder === \"\" ||\n\t\t(!under.startsWith(\"../\") && under !== \"..\") ||\n\t\tcontains === \"\" ||\n\t\t(!contains.startsWith(\"../\") && contains !== \"..\")\n\t) {\n\t\tthrow new VerifiedRunError(\"state_scope\");\n\t}\n}\n\nexport function assertDirectory(path: string): void {\n\tif (!lstatSync(path).isDirectory() || realpathSync(path) !== resolve(path)) throw new VerifiedRunError(\"file_type\");\n}\n"]}
@@ -0,0 +1,96 @@
1
+ import { createHash } from "node:crypto";
2
+ import { closeSync, constants, fstatSync, lstatSync, openSync, readFileSync, realpathSync } from "node:fs";
3
+ import { basename, dirname, join, relative, resolve } from "node:path";
4
+ import { writeExclusiveFileDurablySync } from "../durable-file-io.js";
5
+ import { canonicalJson } from "../run-journal.js";
6
+ export class VerifiedRunError extends Error {
7
+ code;
8
+ constructor(code) {
9
+ super(`verified-run: ${code}`);
10
+ this.name = "VerifiedRunError";
11
+ this.code = code;
12
+ }
13
+ }
14
+ export const digestBytes = (bytes) => createHash("sha256").update(bytes).digest("hex");
15
+ export const digestObject = (value) => digestBytes(canonicalJson(value));
16
+ export function readRegularFile(path, maxBytes) {
17
+ const fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
18
+ try {
19
+ const before = fstatSync(fd, { bigint: true });
20
+ if (!before.isFile() || before.nlink !== 1n)
21
+ throw new VerifiedRunError("file_type");
22
+ if (before.size > BigInt(maxBytes))
23
+ throw new VerifiedRunError("storage_limit");
24
+ const bytes = readFileSync(fd);
25
+ const after = fstatSync(fd, { bigint: true });
26
+ if (before.size !== after.size || before.ctimeNs !== after.ctimeNs || BigInt(bytes.length) !== before.size) {
27
+ throw new VerifiedRunError("integrity");
28
+ }
29
+ return bytes;
30
+ }
31
+ finally {
32
+ closeSync(fd);
33
+ }
34
+ }
35
+ export function readJson(path, maxBytes = 1048576) {
36
+ try {
37
+ return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(readRegularFile(path, maxBytes)));
38
+ }
39
+ catch (error) {
40
+ if (error instanceof SyntaxError || error instanceof TypeError)
41
+ throw new VerifiedRunError("integrity");
42
+ throw error;
43
+ }
44
+ }
45
+ export function publishBytes(path, bytes) {
46
+ try {
47
+ writeExclusiveFileDurablySync(path, bytes);
48
+ }
49
+ catch (error) {
50
+ if (!(error instanceof Error && "code" in error && error.code === "EEXIST"))
51
+ throw error;
52
+ if (!readRegularFile(path, bytes.length).equals(Buffer.from(bytes)))
53
+ throw new VerifiedRunError("integrity");
54
+ }
55
+ }
56
+ export function publishObject(path, value) {
57
+ const bytes = Buffer.from(canonicalJson(value));
58
+ publishBytes(path, bytes);
59
+ return digestBytes(bytes);
60
+ }
61
+ /** Resolve existing parents without creating state. State must never be part of a mounted workspace. */
62
+ export function stateRunPath(root, id) {
63
+ if (!/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/.test(id))
64
+ throw new VerifiedRunError("run_id");
65
+ return join(resolve(root), id);
66
+ }
67
+ export function assertStateOutsideWorkspace(stateRoot, workspace) {
68
+ let cursor = resolve(stateRoot);
69
+ const tail = [];
70
+ while (true) {
71
+ try {
72
+ cursor = join(realpathSync(cursor), ...tail);
73
+ break;
74
+ }
75
+ catch (error) {
76
+ if (!(error instanceof Error && "code" in error && error.code === "ENOENT"))
77
+ throw error;
78
+ tail.unshift(basename(cursor));
79
+ cursor = dirname(cursor);
80
+ }
81
+ }
82
+ const base = realpathSync(workspace);
83
+ const under = relative(base, cursor);
84
+ const contains = relative(cursor, base);
85
+ if (under === "" ||
86
+ (!under.startsWith("../") && under !== "..") ||
87
+ contains === "" ||
88
+ (!contains.startsWith("../") && contains !== "..")) {
89
+ throw new VerifiedRunError("state_scope");
90
+ }
91
+ }
92
+ export function assertDirectory(path) {
93
+ if (!lstatSync(path).isDirectory() || realpathSync(path) !== resolve(path))
94
+ throw new VerifiedRunError("file_type");
95
+ }
96
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/core/verified-run/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3G,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACjC,IAAI,CAAS;IACtB,YAAY,IAAY,EAAE;QACzB,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAAA,CACjB;CACD;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAA0B,EAAU,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACpH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAc,EAAU,EAAE,CAAC,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;AAE1F,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,QAAgB,EAAU;IACvE,MAAM,EAAE,GAAG,QAAQ,CAAC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CAAC,WAAW,CAAC,CAAC;AAAA,CACpH","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { closeSync, constants, fstatSync, lstatSync, openSync, readFileSync, realpathSync } from \"node:fs\";\nimport { basename, dirname, join, relative, resolve } from \"node:path\";\nimport { writeExclusiveFileDurablySync } from \"../durable-file-io.ts\";\nimport { canonicalJson } from \"../run-journal.ts\";\n\nexport class VerifiedRunError extends Error {\n\treadonly code: string;\n\tconstructor(code: string) {\n\t\tsuper(`verified-run: ${code}`);\n\t\tthis.name = \"VerifiedRunError\";\n\t\tthis.code = code;\n\t}\n}\n\nexport const digestBytes = (bytes: Uint8Array | string): string => createHash(\"sha256\").update(bytes).digest(\"hex\");\nexport const digestObject = (value: unknown): string => digestBytes(canonicalJson(value));\n\nexport function readRegularFile(path: string, maxBytes: number): Buffer {\n\tconst fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);\n\ttry {\n\t\tconst before = fstatSync(fd, { bigint: true });\n\t\tif (!before.isFile() || before.nlink !== 1n) throw new VerifiedRunError(\"file_type\");\n\t\tif (before.size > BigInt(maxBytes)) throw new VerifiedRunError(\"storage_limit\");\n\t\tconst bytes = readFileSync(fd);\n\t\tconst after = fstatSync(fd, { bigint: true });\n\t\tif (before.size !== after.size || before.ctimeNs !== after.ctimeNs || BigInt(bytes.length) !== before.size) {\n\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t}\n\t\treturn bytes;\n\t} finally {\n\t\tcloseSync(fd);\n\t}\n}\n\nexport function readJson(path: string, maxBytes = 1048576): unknown {\n\ttry {\n\t\treturn JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(readRegularFile(path, maxBytes)));\n\t} catch (error) {\n\t\tif (error instanceof SyntaxError || error instanceof TypeError) throw new VerifiedRunError(\"integrity\");\n\t\tthrow error;\n\t}\n}\n\nexport function publishBytes(path: string, bytes: Uint8Array): void {\n\ttry {\n\t\twriteExclusiveFileDurablySync(path, bytes);\n\t} catch (error) {\n\t\tif (!(error instanceof Error && \"code\" in error && error.code === \"EEXIST\")) throw error;\n\t\tif (!readRegularFile(path, bytes.length).equals(Buffer.from(bytes))) throw new VerifiedRunError(\"integrity\");\n\t}\n}\n\nexport function publishObject(path: string, value: unknown): string {\n\tconst bytes = Buffer.from(canonicalJson(value));\n\tpublishBytes(path, bytes);\n\treturn digestBytes(bytes);\n}\n\n/** Resolve existing parents without creating state. State must never be part of a mounted workspace. */\nexport function stateRunPath(root: string, id: string): string {\n\tif (!/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/.test(id)) throw new VerifiedRunError(\"run_id\");\n\treturn join(resolve(root), id);\n}\n\nexport function assertStateOutsideWorkspace(stateRoot: string, workspace: string): void {\n\tlet cursor = resolve(stateRoot);\n\tconst tail: string[] = [];\n\twhile (true) {\n\t\ttry {\n\t\t\tcursor = join(realpathSync(cursor), ...tail);\n\t\t\tbreak;\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof Error && \"code\" in error && error.code === \"ENOENT\")) throw error;\n\t\t\ttail.unshift(basename(cursor));\n\t\t\tcursor = dirname(cursor);\n\t\t}\n\t}\n\tconst base = realpathSync(workspace);\n\tconst under = relative(base, cursor);\n\tconst contains = relative(cursor, base);\n\tif (\n\t\tunder === \"\" ||\n\t\t(!under.startsWith(\"../\") && under !== \"..\") ||\n\t\tcontains === \"\" ||\n\t\t(!contains.startsWith(\"../\") && contains !== \"..\")\n\t) {\n\t\tthrow new VerifiedRunError(\"state_scope\");\n\t}\n}\n\nexport function assertDirectory(path: string): void {\n\tif (!lstatSync(path).isDirectory() || realpathSync(path) !== resolve(path)) throw new VerifiedRunError(\"file_type\");\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import type { RunEvent, WriterReduction } from "./run-types.ts";
2
+ /** Associate a process with exactly one current attempt, including old serial journals without taskId. */
3
+ export declare function bindTaskExecution(context: WriterReduction, event: Extract<RunEvent, {
4
+ kind: "dispatch";
5
+ }>): void;
6
+ export declare function endTaskExecution(context: WriterReduction, event: Extract<RunEvent, {
7
+ kind: "exited";
8
+ }>): void;
9
+ //# sourceMappingURL=task-execution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-execution.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/task-execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGhE,0GAA0G;AAC1G,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,GAAG,IAAI,CAWhH;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,GAAG,IAAI,CAc7G","sourcesContent":["import type { RunEvent, WriterReduction } from \"./run-types.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\n/** Associate a process with exactly one current attempt, including old serial journals without taskId. */\nexport function bindTaskExecution(context: WriterReduction, event: Extract<RunEvent, { kind: \"dispatch\" }>): void {\n\tconst { contract, state } = context;\n\tif (contract.profile !== \"linux-command-dag-v1\") throw new VerifiedRunError(\"integrity\");\n\tconst running = state.tasks.filter((task) => task.status === \"running\");\n\tif (event.taskId === undefined && ((contract.writer.maxConcurrentTasks ?? 1) !== 1 || running.length !== 1))\n\t\tthrow new VerifiedRunError(\"task_not_ready\");\n\tconst task = event.taskId === undefined ? running[0] : running.find((task) => task.taskId === event.taskId);\n\tif (!task || task.status !== \"running\" || task.generation !== state.generation || task.execution.kind !== \"ready\")\n\t\tthrow new VerifiedRunError(\"task_not_ready\");\n\tconst next = { ...task, execution: Object.freeze({ kind: \"running\" as const, executionId: event.executionId }) };\n\tcontext.state = { ...state, tasks: state.tasks.map((item) => (item.taskId === next.taskId ? next : item)) };\n}\n\nexport function endTaskExecution(context: WriterReduction, event: Extract<RunEvent, { kind: \"exited\" }>): void {\n\tconst state = context.state;\n\tconst task = state.tasks.find(\n\t\t(task) =>\n\t\t\ttask.status === \"running\" &&\n\t\t\ttask.execution.kind === \"running\" &&\n\t\t\ttask.execution.executionId === event.executionId,\n\t);\n\tif (!task || task.status !== \"running\") throw new VerifiedRunError(\"integrity\");\n\tconst next = {\n\t\t...task,\n\t\texecution: Object.freeze({ kind: \"exited\" as const, executionId: event.executionId, failure: event.failure }),\n\t};\n\tcontext.state = { ...state, tasks: state.tasks.map((item) => (item.taskId === next.taskId ? next : item)) };\n}\n"]}
@@ -0,0 +1,29 @@
1
+ import { VerifiedRunError } from "./storage.js";
2
+ /** Associate a process with exactly one current attempt, including old serial journals without taskId. */
3
+ export function bindTaskExecution(context, event) {
4
+ const { contract, state } = context;
5
+ if (contract.profile !== "linux-command-dag-v1")
6
+ throw new VerifiedRunError("integrity");
7
+ const running = state.tasks.filter((task) => task.status === "running");
8
+ if (event.taskId === undefined && ((contract.writer.maxConcurrentTasks ?? 1) !== 1 || running.length !== 1))
9
+ throw new VerifiedRunError("task_not_ready");
10
+ const task = event.taskId === undefined ? running[0] : running.find((task) => task.taskId === event.taskId);
11
+ if (!task || task.status !== "running" || task.generation !== state.generation || task.execution.kind !== "ready")
12
+ throw new VerifiedRunError("task_not_ready");
13
+ const next = { ...task, execution: Object.freeze({ kind: "running", executionId: event.executionId }) };
14
+ context.state = { ...state, tasks: state.tasks.map((item) => (item.taskId === next.taskId ? next : item)) };
15
+ }
16
+ export function endTaskExecution(context, event) {
17
+ const state = context.state;
18
+ const task = state.tasks.find((task) => task.status === "running" &&
19
+ task.execution.kind === "running" &&
20
+ task.execution.executionId === event.executionId);
21
+ if (!task || task.status !== "running")
22
+ throw new VerifiedRunError("integrity");
23
+ const next = {
24
+ ...task,
25
+ execution: Object.freeze({ kind: "exited", executionId: event.executionId, failure: event.failure }),
26
+ };
27
+ context.state = { ...state, tasks: state.tasks.map((item) => (item.taskId === next.taskId ? next : item)) };
28
+ }
29
+ //# sourceMappingURL=task-execution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-execution.js","sourceRoot":"","sources":["../../../src/core/verified-run/task-execution.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,0GAA0G;AAC1G,MAAM,UAAU,iBAAiB,CAAC,OAAwB,EAAE,KAA8C,EAAQ;IACjH,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IACpC,IAAI,QAAQ,CAAC,OAAO,KAAK,sBAAsB;QAAE,MAAM,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACzF,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC;IACxE,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,kBAAkB,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC;QAC1G,MAAM,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IAC9C,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5G,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,UAAU,KAAK,KAAK,CAAC,UAAU,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK,OAAO;QAChH,MAAM,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;I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CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;AAAA,CAC5G","sourcesContent":["import type { RunEvent, WriterReduction } from \"./run-types.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\n/** Associate a process with exactly one current attempt, including old serial journals without taskId. */\nexport function bindTaskExecution(context: WriterReduction, event: Extract<RunEvent, { kind: \"dispatch\" }>): void {\n\tconst { contract, state } = context;\n\tif (contract.profile !== \"linux-command-dag-v1\") throw new VerifiedRunError(\"integrity\");\n\tconst running = state.tasks.filter((task) => task.status === \"running\");\n\tif (event.taskId === undefined && ((contract.writer.maxConcurrentTasks ?? 1) !== 1 || running.length !== 1))\n\t\tthrow new VerifiedRunError(\"task_not_ready\");\n\tconst task = event.taskId === undefined ? running[0] : running.find((task) => task.taskId === event.taskId);\n\tif (!task || task.status !== \"running\" || task.generation !== state.generation || task.execution.kind !== \"ready\")\n\t\tthrow new VerifiedRunError(\"task_not_ready\");\n\tconst next = { ...task, execution: Object.freeze({ kind: \"running\" as const, executionId: event.executionId }) };\n\tcontext.state = { ...state, tasks: state.tasks.map((item) => (item.taskId === next.taskId ? next : item)) };\n}\n\nexport function endTaskExecution(context: WriterReduction, event: Extract<RunEvent, { kind: \"exited\" }>): void {\n\tconst state = context.state;\n\tconst task = state.tasks.find(\n\t\t(task) =>\n\t\t\ttask.status === \"running\" &&\n\t\t\ttask.execution.kind === \"running\" &&\n\t\t\ttask.execution.executionId === event.executionId,\n\t);\n\tif (!task || task.status !== \"running\") throw new VerifiedRunError(\"integrity\");\n\tconst next = {\n\t\t...task,\n\t\texecution: Object.freeze({ kind: \"exited\" as const, executionId: event.executionId, failure: event.failure }),\n\t};\n\tcontext.state = { ...state, tasks: state.tasks.map((item) => (item.taskId === next.taskId ? next : item)) };\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { RunPhaseContext } from "./phase-context.ts";
2
+ import type { RunProjection } from "./run-types.ts";
3
+ /** Both start and resume use this same verification path; no writer/model code is reachable here. */
4
+ export declare function verifyCandidate(context: RunPhaseContext): Promise<RunProjection>;
5
+ //# sourceMappingURL=verification-phase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verification-phase.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/verification-phase.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGpD,qGAAqG;AACrG,wBAAsB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC,CAiDtF","sourcesContent":["import { join } from \"node:path\";\nimport { performance } from \"node:perf_hooks\";\nimport { commandEnvironmentDigest } from \"./broker.ts\";\nimport { captureCandidate, loadCandidate, materializeCandidate } from \"./candidate.ts\";\nimport { storeCheckReceipt } from \"./check-receipt.ts\";\nimport { type CheckObservation, issueRunEvidence } from \"./evidence.ts\";\nimport { executeRunCommand } from \"./owned-execution.ts\";\nimport type { RunPhaseContext } from \"./phase-context.ts\";\nimport { localVerificationDeadline } from \"./recovery-clock.ts\";\nimport type { RunProjection } from \"./run-types.ts\";\nimport { digestBytes, VerifiedRunError } from \"./storage.ts\";\n\n/** Both start and resume use this same verification path; no writer/model code is reachable here. */\nexport async function verifyCandidate(context: RunPhaseContext): Promise<RunProjection> {\n\tconst { contract, journal, runPath } = context;\n\tconst state = journal.state;\n\tif (!state.candidateDigest || !state.budget || state.verificationDeadlineMs === null || !state.environmentDigest)\n\t\tthrow new VerifiedRunError(\"resume_unavailable\");\n\tconst deadline = localVerificationDeadline(state.budget, state.verificationDeadlineMs);\n\tif (commandEnvironmentDigest(contract, \"gated-v1\") !== state.environmentDigest)\n\t\tthrow new VerifiedRunError(\"environment_changed\");\n\tconst candidate = loadCandidate(runPath, state.candidateDigest, contract.budget);\n\tconst fixed = join(runPath, state.generation === 1 ? \"candidate\" : `candidate-${state.generation}`);\n\tmaterializeCandidate(candidate, fixed);\n\tconst checks: CheckObservation[] = [];\n\tfor (const check of contract.checks) {\n\t\tconst { executionId, result, timeoutMs } = await executeRunCommand(\n\t\t\tjournal,\n\t\t\t{ role: \"verifier\", argv: check.argv, workspace: fixed, deadline, claimId: check.claimId },\n\t\t\t{ ...contract.budget, ...(context.signal ? { signal: context.signal } : {}) },\n\t\t);\n\t\tchecks.push({\n\t\t\tclaimId: check.claimId,\n\t\t\texecutionId,\n\t\t\tstdoutDigest: digestBytes(result.stdout),\n\t\t\tstderrDigest: digestBytes(result.stderr),\n\t\t\texitCode: result.exitCode,\n\t\t\tfailure: result.failure,\n\t\t\treceiptCoreDigest: storeCheckReceipt(runPath, contract, {\n\t\t\t\tcheck,\n\t\t\t\texecutionId,\n\t\t\t\tresult,\n\t\t\t\ttimeoutMs,\n\t\t\t\tmanifest: candidate.manifest,\n\t\t\t}),\n\t\t});\n\t}\n\tif (\n\t\tcaptureCandidate(fixed, contract.budget).digest !== state.candidateDigest ||\n\t\tcommandEnvironmentDigest(contract, \"gated-v1\") !== state.environmentDigest\n\t)\n\t\tthrow new VerifiedRunError(\"integrity\");\n\tif (performance.now() >= deadline) throw new VerifiedRunError(\"deadline\");\n\tconst receipt = issueRunEvidence(runPath, contract, {\n\t\tgeneration: state.generation,\n\t\tcandidateDigest: state.candidateDigest,\n\t\tenvironmentDigest: state.environmentDigest,\n\t\tchecks,\n\t});\n\tif (performance.now() >= deadline || journal.state.generation !== state.generation)\n\t\tthrow new VerifiedRunError(\"deadline\");\n\treturn journal.append({ kind: \"evaluated\", receiptDigest: receipt.digest, verified: receipt.verified });\n}\n"]}
@@ -0,0 +1,56 @@
1
+ import { join } from "node:path";
2
+ import { performance } from "node:perf_hooks";
3
+ import { commandEnvironmentDigest } from "./broker.js";
4
+ import { captureCandidate, loadCandidate, materializeCandidate } from "./candidate.js";
5
+ import { storeCheckReceipt } from "./check-receipt.js";
6
+ import { issueRunEvidence } from "./evidence.js";
7
+ import { executeRunCommand } from "./owned-execution.js";
8
+ import { localVerificationDeadline } from "./recovery-clock.js";
9
+ import { digestBytes, VerifiedRunError } from "./storage.js";
10
+ /** Both start and resume use this same verification path; no writer/model code is reachable here. */
11
+ export async function verifyCandidate(context) {
12
+ const { contract, journal, runPath } = context;
13
+ const state = journal.state;
14
+ if (!state.candidateDigest || !state.budget || state.verificationDeadlineMs === null || !state.environmentDigest)
15
+ throw new VerifiedRunError("resume_unavailable");
16
+ const deadline = localVerificationDeadline(state.budget, state.verificationDeadlineMs);
17
+ if (commandEnvironmentDigest(contract, "gated-v1") !== state.environmentDigest)
18
+ throw new VerifiedRunError("environment_changed");
19
+ const candidate = loadCandidate(runPath, state.candidateDigest, contract.budget);
20
+ const fixed = join(runPath, state.generation === 1 ? "candidate" : `candidate-${state.generation}`);
21
+ materializeCandidate(candidate, fixed);
22
+ const checks = [];
23
+ for (const check of contract.checks) {
24
+ const { executionId, result, timeoutMs } = await executeRunCommand(journal, { role: "verifier", argv: check.argv, workspace: fixed, deadline, claimId: check.claimId }, { ...contract.budget, ...(context.signal ? { signal: context.signal } : {}) });
25
+ checks.push({
26
+ claimId: check.claimId,
27
+ executionId,
28
+ stdoutDigest: digestBytes(result.stdout),
29
+ stderrDigest: digestBytes(result.stderr),
30
+ exitCode: result.exitCode,
31
+ failure: result.failure,
32
+ receiptCoreDigest: storeCheckReceipt(runPath, contract, {
33
+ check,
34
+ executionId,
35
+ result,
36
+ timeoutMs,
37
+ manifest: candidate.manifest,
38
+ }),
39
+ });
40
+ }
41
+ if (captureCandidate(fixed, contract.budget).digest !== state.candidateDigest ||
42
+ commandEnvironmentDigest(contract, "gated-v1") !== state.environmentDigest)
43
+ throw new VerifiedRunError("integrity");
44
+ if (performance.now() >= deadline)
45
+ throw new VerifiedRunError("deadline");
46
+ const receipt = issueRunEvidence(runPath, contract, {
47
+ generation: state.generation,
48
+ candidateDigest: state.candidateDigest,
49
+ environmentDigest: state.environmentDigest,
50
+ checks,
51
+ });
52
+ if (performance.now() >= deadline || journal.state.generation !== state.generation)
53
+ throw new VerifiedRunError("deadline");
54
+ return journal.append({ kind: "evaluated", receiptDigest: receipt.digest, verified: receipt.verified });
55
+ }
56
+ //# sourceMappingURL=verification-phase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verification-phase.js","sourceRoot":"","sources":["../../../src/core/verified-run/verification-phase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAyB,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE7D,qGAAqG;AACrG,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAAwB,EAA0B;IACvF,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC/C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC5B,IAAI,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,sBAAsB,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,iBAAiB;QAC/G,MAAM,IAAI,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;IAClD,MAAM,QAAQ,GAAG,yBAAyB,CAAC,KA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AAQ;YACzB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,iBAAiB,EAAE,iBAAiB,CAAC,OAAO,EAAE,QAAQ,EAAE;gBACvD,KAAK;gBACL,WAAW;gBACX,MAAM;gBACN,SAAS;gBACT,QAAQ,EAAE,SAAS,CAAC,QAAQ;aAC5B,CAAC;SACF,CAAC,CAAC;IACJ,CAAC;IACD,IACC,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,KAAK,CAAC,eAAe;QACzE,wBAAwB,CAAC,QAAQ,EAAE,UAAU,CAAC,KAAK,KAAK,CAAC,iBAAiB;QAE1E,MAAM,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACzC,IAAI,WAAW,CAAC,GAAG,EAAE,IAAI,QAAQ;QAAE,MAAM,IAAI,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC1E,MAAM,OAAO,GAAG,gBAAgB,CAAC,OAAO,EAAE,QAAQ,EAAE;QACnD,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,eAAe,EAAE,KAAK,CAAC,eAAe;QACtC,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,MAAM;KACN,CAAC,CAAC;IACH,IAAI,WAAW,CAAC,GAAG,EAAE,IAAI,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,UAAU;QACjF,MAAM,IAAI,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,OAAO,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;AAAA,CACxG","sourcesContent":["import { join } from \"node:path\";\nimport { performance } from \"node:perf_hooks\";\nimport { commandEnvironmentDigest } from \"./broker.ts\";\nimport { captureCandidate, loadCandidate, materializeCandidate } from \"./candidate.ts\";\nimport { storeCheckReceipt } from \"./check-receipt.ts\";\nimport { type CheckObservation, issueRunEvidence } from \"./evidence.ts\";\nimport { executeRunCommand } from \"./owned-execution.ts\";\nimport type { RunPhaseContext } from \"./phase-context.ts\";\nimport { localVerificationDeadline } from \"./recovery-clock.ts\";\nimport type { RunProjection } from \"./run-types.ts\";\nimport { digestBytes, VerifiedRunError } from \"./storage.ts\";\n\n/** Both start and resume use this same verification path; no writer/model code is reachable here. */\nexport async function verifyCandidate(context: RunPhaseContext): Promise<RunProjection> {\n\tconst { contract, journal, runPath } = context;\n\tconst state = journal.state;\n\tif (!state.candidateDigest || !state.budget || state.verificationDeadlineMs === null || !state.environmentDigest)\n\t\tthrow new VerifiedRunError(\"resume_unavailable\");\n\tconst deadline = localVerificationDeadline(state.budget, state.verificationDeadlineMs);\n\tif (commandEnvironmentDigest(contract, \"gated-v1\") !== state.environmentDigest)\n\t\tthrow new VerifiedRunError(\"environment_changed\");\n\tconst candidate = loadCandidate(runPath, state.candidateDigest, contract.budget);\n\tconst fixed = join(runPath, state.generation === 1 ? \"candidate\" : `candidate-${state.generation}`);\n\tmaterializeCandidate(candidate, fixed);\n\tconst checks: CheckObservation[] = [];\n\tfor (const check of contract.checks) {\n\t\tconst { executionId, result, timeoutMs } = await executeRunCommand(\n\t\t\tjournal,\n\t\t\t{ role: \"verifier\", argv: check.argv, workspace: fixed, deadline, claimId: check.claimId },\n\t\t\t{ ...contract.budget, ...(context.signal ? { signal: context.signal } : {}) },\n\t\t);\n\t\tchecks.push({\n\t\t\tclaimId: check.claimId,\n\t\t\texecutionId,\n\t\t\tstdoutDigest: digestBytes(result.stdout),\n\t\t\tstderrDigest: digestBytes(result.stderr),\n\t\t\texitCode: result.exitCode,\n\t\t\tfailure: result.failure,\n\t\t\treceiptCoreDigest: storeCheckReceipt(runPath, contract, {\n\t\t\t\tcheck,\n\t\t\t\texecutionId,\n\t\t\t\tresult,\n\t\t\t\ttimeoutMs,\n\t\t\t\tmanifest: candidate.manifest,\n\t\t\t}),\n\t\t});\n\t}\n\tif (\n\t\tcaptureCandidate(fixed, contract.budget).digest !== state.candidateDigest ||\n\t\tcommandEnvironmentDigest(contract, \"gated-v1\") !== state.environmentDigest\n\t)\n\t\tthrow new VerifiedRunError(\"integrity\");\n\tif (performance.now() >= deadline) throw new VerifiedRunError(\"deadline\");\n\tconst receipt = issueRunEvidence(runPath, contract, {\n\t\tgeneration: state.generation,\n\t\tcandidateDigest: state.candidateDigest,\n\t\tenvironmentDigest: state.environmentDigest,\n\t\tchecks,\n\t});\n\tif (performance.now() >= deadline || journal.state.generation !== state.generation)\n\t\tthrow new VerifiedRunError(\"deadline\");\n\treturn journal.append({ kind: \"evaluated\", receiptDigest: receipt.digest, verified: receipt.verified });\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import { type RunContract } from "omk-protocol";
2
+ import type { JournalSnapshot } from "./journal.ts";
3
+ /** Common immutable-input, original-budget and observed-process boundary for local work recovery. */
4
+ export declare function assertWorkRecoverable(runPath: string, snapshot: JournalSnapshot): {
5
+ readonly contract: RunContract;
6
+ readonly remainingMs: number;
7
+ };
8
+ //# sourceMappingURL=work-recovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"work-recovery.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/work-recovery.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAG9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAKpD,qGAAqG;AACrG,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,eAAe,GACvB;IAAE,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAiClE","sourcesContent":["import { join } from \"node:path\";\nimport { MAX_VERIFIED_RUN_GENERATIONS, type RunContract } from \"omk-protocol\";\nimport { commandEnvironmentDigest } from \"./broker.ts\";\nimport { loadCandidate } from \"./candidate.ts\";\nimport type { JournalSnapshot } from \"./journal.ts\";\nimport { probeNamespace } from \"./namespace-identity.ts\";\nimport { readRunClock, remainingRunTime } from \"./recovery-clock.ts\";\nimport { readRegularFile, VerifiedRunError } from \"./storage.ts\";\n\n/** Common immutable-input, original-budget and observed-process boundary for local work recovery. */\nexport function assertWorkRecoverable(\n\trunPath: string,\n\tsnapshot: JournalSnapshot,\n): { readonly contract: RunContract; readonly remainingMs: number } {\n\tconst state = snapshot.state;\n\tconst first = snapshot.records[0]?.event;\n\tif (state.execution === \"failed\" || state.receiptDigest) throw new VerifiedRunError(\"resume_terminal\");\n\tif (first?.kind !== \"created\" || !state.inputDigest || !state.budget || !state.environmentDigest)\n\t\tthrow new VerifiedRunError(\"input_checkpoint_missing\");\n\tif (state.candidateDigest || state.verificationDeadlineMs !== null) throw new VerifiedRunError(\"candidate_present\");\n\tif (state.generation >= MAX_VERIFIED_RUN_GENERATIONS) throw new VerifiedRunError(\"recovery_limit\");\n\tconst clock = readRunClock();\n\tconst remainingMs = remainingRunTime(state.budget, state.budget.workDeadlineMs, clock);\n\tif (clock.nowMs < (state.lastClockMs ?? state.budget.startedMs)) throw new VerifiedRunError(\"clock_rollback\");\n\tif (remainingMs <= 0) throw new VerifiedRunError(\"deadline\");\n\tfor (const id of state.activeExecutionIds) {\n\t\tconst dispatch = snapshot.records.find(\n\t\t\t(record) =>\n\t\t\t\trecord.generation === state.generation &&\n\t\t\t\trecord.event.kind === \"dispatch\" &&\n\t\t\t\trecord.event.executionId === id,\n\t\t)?.event;\n\t\tconst identity = state.processes.find((item) => item.executionId === id)?.identity;\n\t\tif (\n\t\t\tdispatch?.kind !== \"dispatch\" ||\n\t\t\tdispatch.role !== \"writer\" ||\n\t\t\t!identity ||\n\t\t\tprobeNamespace(identity) !== \"gone\"\n\t\t)\n\t\t\tthrow new VerifiedRunError(\"unsettled\");\n\t}\n\tif (readRegularFile(join(runPath, \"issuer.key\"), 32).length !== 32) throw new VerifiedRunError(\"integrity\");\n\tloadCandidate(runPath, state.inputDigest, first.contract.budget);\n\tif (commandEnvironmentDigest(first.contract, \"gated-v1\") !== state.environmentDigest)\n\t\tthrow new VerifiedRunError(\"integrity\");\n\treturn { contract: first.contract, remainingMs };\n}\n"]}
@@ -0,0 +1,44 @@
1
+ import { join } from "node:path";
2
+ import { MAX_VERIFIED_RUN_GENERATIONS } from "omk-protocol";
3
+ import { commandEnvironmentDigest } from "./broker.js";
4
+ import { loadCandidate } from "./candidate.js";
5
+ import { probeNamespace } from "./namespace-identity.js";
6
+ import { readRunClock, remainingRunTime } from "./recovery-clock.js";
7
+ import { readRegularFile, VerifiedRunError } from "./storage.js";
8
+ /** Common immutable-input, original-budget and observed-process boundary for local work recovery. */
9
+ export function assertWorkRecoverable(runPath, snapshot) {
10
+ const state = snapshot.state;
11
+ const first = snapshot.records[0]?.event;
12
+ if (state.execution === "failed" || state.receiptDigest)
13
+ throw new VerifiedRunError("resume_terminal");
14
+ if (first?.kind !== "created" || !state.inputDigest || !state.budget || !state.environmentDigest)
15
+ throw new VerifiedRunError("input_checkpoint_missing");
16
+ if (state.candidateDigest || state.verificationDeadlineMs !== null)
17
+ throw new VerifiedRunError("candidate_present");
18
+ if (state.generation >= MAX_VERIFIED_RUN_GENERATIONS)
19
+ throw new VerifiedRunError("recovery_limit");
20
+ const clock = readRunClock();
21
+ const remainingMs = remainingRunTime(state.budget, state.budget.workDeadlineMs, clock);
22
+ if (clock.nowMs < (state.lastClockMs ?? state.budget.startedMs))
23
+ throw new VerifiedRunError("clock_rollback");
24
+ if (remainingMs <= 0)
25
+ throw new VerifiedRunError("deadline");
26
+ for (const id of state.activeExecutionIds) {
27
+ const dispatch = snapshot.records.find((record) => record.generation === state.generation &&
28
+ record.event.kind === "dispatch" &&
29
+ record.event.executionId === id)?.event;
30
+ const identity = state.processes.find((item) => item.executionId === id)?.identity;
31
+ if (dispatch?.kind !== "dispatch" ||
32
+ dispatch.role !== "writer" ||
33
+ !identity ||
34
+ probeNamespace(identity) !== "gone")
35
+ throw new VerifiedRunError("unsettled");
36
+ }
37
+ if (readRegularFile(join(runPath, "issuer.key"), 32).length !== 32)
38
+ throw new VerifiedRunError("integrity");
39
+ loadCandidate(runPath, state.inputDigest, first.contract.budget);
40
+ if (commandEnvironmentDigest(first.contract, "gated-v1") !== state.environmentDigest)
41
+ throw new VerifiedRunError("integrity");
42
+ return { contract: first.contract, remainingMs };
43
+ }
44
+ //# sourceMappingURL=work-recovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"work-recovery.js","sourceRoot":"","sources":["../../../src/core/verified-run/work-recovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,4BAA4B,EAAoB,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEjE,qGAAqG;AACrG,MAAM,UAAU,qBAAqB,CACpC,OAAe,EACf,QAAyB,EAC0C;IACnE,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC7B,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC;IACzC,IAAI,KAAK,CAAC,SAAS,KAAK,QAAQ,IAAI,KAAK,CAAC,aAAa;QAAE,MAAM,IAAI,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;IACvG,IAAI,KAAK,EAAE,IAAI,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK,CAA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B,CAAC,QAAQ;YACT,cAAc,CAAC,QAAQ,CAAC,KAAK,MAAM;YAEnC,MAAM,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAC1C,CAAC;IACD,IAAI,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,KAAK,EAAE;QAAE,MAAM,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAC5G,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjE,IAAI,wBAAwB,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC,KAAK,KAAK,CAAC,iBAAiB;QACnF,MAAM,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACzC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAC;AAAA,CACjD","sourcesContent":["import { join } from \"node:path\";\nimport { MAX_VERIFIED_RUN_GENERATIONS, type RunContract } from \"omk-protocol\";\nimport { commandEnvironmentDigest } from \"./broker.ts\";\nimport { loadCandidate } from \"./candidate.ts\";\nimport type { JournalSnapshot } from \"./journal.ts\";\nimport { probeNamespace } from \"./namespace-identity.ts\";\nimport { readRunClock, remainingRunTime } from \"./recovery-clock.ts\";\nimport { readRegularFile, VerifiedRunError } from \"./storage.ts\";\n\n/** Common immutable-input, original-budget and observed-process boundary for local work recovery. */\nexport function assertWorkRecoverable(\n\trunPath: string,\n\tsnapshot: JournalSnapshot,\n): { readonly contract: RunContract; readonly remainingMs: number } {\n\tconst state = snapshot.state;\n\tconst first = snapshot.records[0]?.event;\n\tif (state.execution === \"failed\" || state.receiptDigest) throw new VerifiedRunError(\"resume_terminal\");\n\tif (first?.kind !== \"created\" || !state.inputDigest || !state.budget || !state.environmentDigest)\n\t\tthrow new VerifiedRunError(\"input_checkpoint_missing\");\n\tif (state.candidateDigest || state.verificationDeadlineMs !== null) throw new VerifiedRunError(\"candidate_present\");\n\tif (state.generation >= MAX_VERIFIED_RUN_GENERATIONS) throw new VerifiedRunError(\"recovery_limit\");\n\tconst clock = readRunClock();\n\tconst remainingMs = remainingRunTime(state.budget, state.budget.workDeadlineMs, clock);\n\tif (clock.nowMs < (state.lastClockMs ?? state.budget.startedMs)) throw new VerifiedRunError(\"clock_rollback\");\n\tif (remainingMs <= 0) throw new VerifiedRunError(\"deadline\");\n\tfor (const id of state.activeExecutionIds) {\n\t\tconst dispatch = snapshot.records.find(\n\t\t\t(record) =>\n\t\t\t\trecord.generation === state.generation &&\n\t\t\t\trecord.event.kind === \"dispatch\" &&\n\t\t\t\trecord.event.executionId === id,\n\t\t)?.event;\n\t\tconst identity = state.processes.find((item) => item.executionId === id)?.identity;\n\t\tif (\n\t\t\tdispatch?.kind !== \"dispatch\" ||\n\t\t\tdispatch.role !== \"writer\" ||\n\t\t\t!identity ||\n\t\t\tprobeNamespace(identity) !== \"gone\"\n\t\t)\n\t\t\tthrow new VerifiedRunError(\"unsettled\");\n\t}\n\tif (readRegularFile(join(runPath, \"issuer.key\"), 32).length !== 32) throw new VerifiedRunError(\"integrity\");\n\tloadCandidate(runPath, state.inputDigest, first.contract.budget);\n\tif (commandEnvironmentDigest(first.contract, \"gated-v1\") !== state.environmentDigest)\n\t\tthrow new VerifiedRunError(\"integrity\");\n\treturn { contract: first.contract, remainingMs };\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { RunPhaseContext } from "./phase-context.ts";
2
+ /** Seal output only against the input that was durably pinned before this run's first writer. */
3
+ export declare function publishWriterCandidate(context: RunPhaseContext, workspace: string, workDeadline: number): void;
4
+ //# sourceMappingURL=writer-completion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer-completion.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/writer-completion.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAI1D,iGAAiG;AACjG,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAqB9G","sourcesContent":["import { performance } from \"node:perf_hooks\";\nimport { assertCandidateScope, captureCandidate, loadCandidate, storeCandidate } from \"./candidate.ts\";\nimport type { RunPhaseContext } from \"./phase-context.ts\";\nimport { readRunClock } from \"./recovery-clock.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\n/** Seal output only against the input that was durably pinned before this run's first writer. */\nexport function publishWriterCandidate(context: RunPhaseContext, workspace: string, workDeadline: number): void {\n\tconst { contract, journal, runPath } = context;\n\tconst state = journal.state;\n\tif (!state.inputDigest || !state.budget) throw new VerifiedRunError(\"input_checkpoint_missing\");\n\tconst base = loadCandidate(runPath, state.inputDigest, contract.budget);\n\tconst candidate = captureCandidate(workspace, contract.budget);\n\tassertCandidateScope(base.manifest, candidate.manifest, contract.writablePaths);\n\tstoreCandidate(candidate, runPath);\n\tconst observed = readRunClock();\n\tif (\n\t\tobserved.bootId !== state.budget.bootId ||\n\t\tobserved.nowMs > state.budget.workDeadlineMs ||\n\t\tperformance.now() >= workDeadline\n\t)\n\t\tthrow new VerifiedRunError(\"deadline\");\n\tjournal.append({\n\t\tkind: \"candidate\",\n\t\tdigest: candidate.digest,\n\t\tobservedMs: observed.nowMs,\n\t\tverificationDeadlineMs: Math.min(observed.nowMs + contract.budget.verifyMs, state.budget.verifyCapMs),\n\t});\n}\n"]}
@@ -0,0 +1,27 @@
1
+ import { performance } from "node:perf_hooks";
2
+ import { assertCandidateScope, captureCandidate, loadCandidate, storeCandidate } from "./candidate.js";
3
+ import { readRunClock } from "./recovery-clock.js";
4
+ import { VerifiedRunError } from "./storage.js";
5
+ /** Seal output only against the input that was durably pinned before this run's first writer. */
6
+ export function publishWriterCandidate(context, workspace, workDeadline) {
7
+ const { contract, journal, runPath } = context;
8
+ const state = journal.state;
9
+ if (!state.inputDigest || !state.budget)
10
+ throw new VerifiedRunError("input_checkpoint_missing");
11
+ const base = loadCandidate(runPath, state.inputDigest, contract.budget);
12
+ const candidate = captureCandidate(workspace, contract.budget);
13
+ assertCandidateScope(base.manifest, candidate.manifest, contract.writablePaths);
14
+ storeCandidate(candidate, runPath);
15
+ const observed = readRunClock();
16
+ if (observed.bootId !== state.budget.bootId ||
17
+ observed.nowMs > state.budget.workDeadlineMs ||
18
+ performance.now() >= workDeadline)
19
+ throw new VerifiedRunError("deadline");
20
+ journal.append({
21
+ kind: "candidate",
22
+ digest: candidate.digest,
23
+ observedMs: observed.nowMs,
24
+ verificationDeadlineMs: Math.min(observed.nowMs + contract.budget.verifyMs, state.budget.verifyCapMs),
25
+ });
26
+ }
27
+ //# sourceMappingURL=writer-completion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer-completion.js","sourceRoot":"","sources":["../../../src/core/verified-run/writer-completion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEvG,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,iGAAiG;AACjG,MAAM,UAAU,sBAAsB,CAAC,OAAwB,EAAE,SAAiB,EAAE,YAAoB,EAAQ;IAC/G,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC/C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC5B,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,MAAM,IAAI,gBAAgB,CAAC,0BAA0B,CAAC,CAAC;IAChG,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACxE,MAAM,SAAS,GAAG,gBAAgB,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC/D,oBAAoB,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IAChF,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACnC,MAAM,QAAQ,GAAG,YAAY,EAAE,CAAC;IAChC,IACC,QAAQ,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,CAAC,MAAM;QACvC,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,cAAc;QAC5C,WAAW,CAAC,GAAG,EAAE,IAAI,YAAY;QAEjC,MAAM,IAAI,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,OAAO,CAAC,MAAM,CAAC;QACd,IAAI,EAAE,WAAW;QACjB,MAAM,EAAE,SAAS,CAAC,MAAM;QACxB,UAAU,EAAE,QAAQ,CAAC,KAAK;QAC1B,sBAAsB,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC;KACrG,CAAC,CAAC;AAAA,CACH","sourcesContent":["import { performance } from \"node:perf_hooks\";\nimport { assertCandidateScope, captureCandidate, loadCandidate, storeCandidate } from \"./candidate.ts\";\nimport type { RunPhaseContext } from \"./phase-context.ts\";\nimport { readRunClock } from \"./recovery-clock.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\n/** Seal output only against the input that was durably pinned before this run's first writer. */\nexport function publishWriterCandidate(context: RunPhaseContext, workspace: string, workDeadline: number): void {\n\tconst { contract, journal, runPath } = context;\n\tconst state = journal.state;\n\tif (!state.inputDigest || !state.budget) throw new VerifiedRunError(\"input_checkpoint_missing\");\n\tconst base = loadCandidate(runPath, state.inputDigest, contract.budget);\n\tconst candidate = captureCandidate(workspace, contract.budget);\n\tassertCandidateScope(base.manifest, candidate.manifest, contract.writablePaths);\n\tstoreCandidate(candidate, runPath);\n\tconst observed = readRunClock();\n\tif (\n\t\tobserved.bootId !== state.budget.bootId ||\n\t\tobserved.nowMs > state.budget.workDeadlineMs ||\n\t\tperformance.now() >= workDeadline\n\t)\n\t\tthrow new VerifiedRunError(\"deadline\");\n\tjournal.append({\n\t\tkind: \"candidate\",\n\t\tdigest: candidate.digest,\n\t\tobservedMs: observed.nowMs,\n\t\tverificationDeadlineMs: Math.min(observed.nowMs + contract.budget.verifyMs, state.budget.verifyCapMs),\n\t});\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import type { RunPhaseContext } from "./phase-context.ts";
2
+ import type { VerifiedRunRuntime } from "./session-port.ts";
3
+ export declare function executeWriter(context: RunPhaseContext, options: {
4
+ readonly workspace: string;
5
+ readonly deadline: number;
6
+ readonly runtime?: VerifiedRunRuntime;
7
+ }): Promise<void>;
8
+ //# sourceMappingURL=writer-phase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer-phase.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/writer-phase.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAG5D,wBAAsB,aAAa,CAClC,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE;IACR,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC;CACtC,GACC,OAAO,CAAC,IAAI,CAAC,CA+Df","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { performance } from \"node:perf_hooks\";\nimport { executeDag } from \"./dag-phase.ts\";\nimport { executeRunCommand, type OwnedRunCommand } from \"./owned-execution.ts\";\nimport type { RunPhaseContext } from \"./phase-context.ts\";\nimport { executeScriptedWriter } from \"./scripted-writer.ts\";\nimport type { VerifiedRunRuntime } from \"./session-port.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\nexport async function executeWriter(\n\tcontext: RunPhaseContext,\n\toptions: {\n\t\treadonly workspace: string;\n\t\treadonly deadline: number;\n\t\treadonly runtime?: VerifiedRunRuntime;\n\t},\n): Promise<void> {\n\tconst { contract, journal } = context;\n\tconst execute = (request: OwnedRunCommand, toolSignal?: AbortSignal) => {\n\t\tconst signals = [context.signal, toolSignal].filter((signal): signal is AbortSignal => signal !== undefined);\n\t\treturn executeRunCommand(journal, request, {\n\t\t\t...contract.budget,\n\t\t\t...(signals.length ? { signal: AbortSignal.any(signals) } : {}),\n\t\t});\n\t};\n\tswitch (contract.profile) {\n\t\tcase \"linux-command-dag-v1\":\n\t\t\treturn executeDag(context, options);\n\t\tcase \"linux-command-v1\": {\n\t\t\tconst writer = await execute({\n\t\t\t\trole: \"writer\",\n\t\t\t\targv: contract.writer,\n\t\t\t\tworkspace: options.workspace,\n\t\t\t\tdeadline: options.deadline,\n\t\t\t\tclaimId: null,\n\t\t\t});\n\t\t\tif (writer.result.failure) throw new VerifiedRunError(writer.result.failure);\n\t\t\treturn;\n\t\t}\n\t\tcase \"linux-scripted-agent-v1\": {\n\t\t\tconst runtime = options.runtime;\n\t\t\tif (!runtime) throw new VerifiedRunError(\"writer_backend_missing\");\n\t\t\tconst writer = contract.writer;\n\t\t\tconst requestLimit = writer.maxRequests - journal.state.modelRequests;\n\t\t\tif (requestLimit <= 0) throw new VerifiedRunError(\"model_request_limit\");\n\t\t\tjournal.append({ kind: \"writer_opened\" });\n\t\t\tlet completed = false;\n\t\t\ttry {\n\t\t\t\tawait executeScriptedWriter(writer, contract.goal, {\n\t\t\t\t\truntime,\n\t\t\t\t\tworkspace: options.workspace,\n\t\t\t\t\tdeadline: options.deadline,\n\t\t\t\t\trequestLimit,\n\t\t\t\t\t...(context.signal ? { signal: context.signal } : {}),\n\t\t\t\t\tbeforeRequest: () => {\n\t\t\t\t\t\tif (performance.now() >= options.deadline) throw new VerifiedRunError(\"deadline\");\n\t\t\t\t\t\tjournal.append({ kind: \"model_request\", requestId: randomUUID() });\n\t\t\t\t\t\tif (performance.now() >= options.deadline) throw new VerifiedRunError(\"deadline\");\n\t\t\t\t\t},\n\t\t\t\t\texecuteStep: (index, signal) => {\n\t\t\t\t\t\tconst argv = writer.steps[index];\n\t\t\t\t\t\tif (!argv) throw new VerifiedRunError(\"writer_step\");\n\t\t\t\t\t\treturn execute(\n\t\t\t\t\t\t\t{ role: \"writer\", argv, workspace: options.workspace, deadline: options.deadline, claimId: null },\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tcompleted = true;\n\t\t\t} finally {\n\t\t\t\tif (journal.state.activeExecutionIds.length === 0) journal.append({ kind: \"writer_closed\", completed });\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tdefault: {\n\t\t\tconst exhaustive: never = contract;\n\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t}\n\t}\n}\n"]}
@@ -0,0 +1,76 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { performance } from "node:perf_hooks";
3
+ import { executeDag } from "./dag-phase.js";
4
+ import { executeRunCommand } from "./owned-execution.js";
5
+ import { executeScriptedWriter } from "./scripted-writer.js";
6
+ import { VerifiedRunError } from "./storage.js";
7
+ export async function executeWriter(context, options) {
8
+ const { contract, journal } = context;
9
+ const execute = (request, toolSignal) => {
10
+ const signals = [context.signal, toolSignal].filter((signal) => signal !== undefined);
11
+ return executeRunCommand(journal, request, {
12
+ ...contract.budget,
13
+ ...(signals.length ? { signal: AbortSignal.any(signals) } : {}),
14
+ });
15
+ };
16
+ switch (contract.profile) {
17
+ case "linux-command-dag-v1":
18
+ return executeDag(context, options);
19
+ case "linux-command-v1": {
20
+ const writer = await execute({
21
+ role: "writer",
22
+ argv: contract.writer,
23
+ workspace: options.workspace,
24
+ deadline: options.deadline,
25
+ claimId: null,
26
+ });
27
+ if (writer.result.failure)
28
+ throw new VerifiedRunError(writer.result.failure);
29
+ return;
30
+ }
31
+ case "linux-scripted-agent-v1": {
32
+ const runtime = options.runtime;
33
+ if (!runtime)
34
+ throw new VerifiedRunError("writer_backend_missing");
35
+ const writer = contract.writer;
36
+ const requestLimit = writer.maxRequests - journal.state.modelRequests;
37
+ if (requestLimit <= 0)
38
+ throw new VerifiedRunError("model_request_limit");
39
+ journal.append({ kind: "writer_opened" });
40
+ let completed = false;
41
+ try {
42
+ await executeScriptedWriter(writer, contract.goal, {
43
+ runtime,
44
+ workspace: options.workspace,
45
+ deadline: options.deadline,
46
+ requestLimit,
47
+ ...(context.signal ? { signal: context.signal } : {}),
48
+ beforeRequest: () => {
49
+ if (performance.now() >= options.deadline)
50
+ throw new VerifiedRunError("deadline");
51
+ journal.append({ kind: "model_request", requestId: randomUUID() });
52
+ if (performance.now() >= options.deadline)
53
+ throw new VerifiedRunError("deadline");
54
+ },
55
+ executeStep: (index, signal) => {
56
+ const argv = writer.steps[index];
57
+ if (!argv)
58
+ throw new VerifiedRunError("writer_step");
59
+ return execute({ role: "writer", argv, workspace: options.workspace, deadline: options.deadline, claimId: null }, signal);
60
+ },
61
+ });
62
+ completed = true;
63
+ }
64
+ finally {
65
+ if (journal.state.activeExecutionIds.length === 0)
66
+ journal.append({ kind: "writer_closed", completed });
67
+ }
68
+ return;
69
+ }
70
+ default: {
71
+ const exhaustive = contract;
72
+ throw new VerifiedRunError(String(exhaustive));
73
+ }
74
+ }
75
+ }
76
+ //# sourceMappingURL=writer-phase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer-phase.js","sourceRoot":"","sources":["../../../src/core/verified-run/writer-phase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EA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G,EAAE,IAAI,OAAO,CAAC,QAAQ;4BAAE,MAAM,IAAI,gBAAgB,CAAC,UAAU,CAAC,CAAC;oBAAA,CAClF;oBACD,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC;wBAC/B,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;wBACjC,IAAI,CAAC,IAAI;4BAAE,MAAM,IAAI,gBAAgB,CAAC,aAAa,CAAC,CAAC;wBACrD,OAAO,OAAO,CACb,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,EACjG,MAAM,CACN,CAAC;oBAAA,CACF;iBACD,CAAC,CAAC;gBACH,SAAS,GAAG,IAAI,CAAC;YAClB,CAAC;oBAAS,CAAC;gBACV,IAAI,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,MAAM,KAAK,CAAC;oBAAE,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC;YACzG,CAAC;YACD,OAAO;QACR,CAAC;QACD,SAAS,CAAC;YACT,MAAM,UAAU,GAAU,QAAQ,CAAC;YACnC,MAAM,IAAI,gBAAgB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;QAChD,CAAC;IACF,CAAC;AAAA,CACD","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { performance } from \"node:perf_hooks\";\nimport { executeDag } from \"./dag-phase.ts\";\nimport { executeRunCommand, type OwnedRunCommand } from \"./owned-execution.ts\";\nimport type { RunPhaseContext } from \"./phase-context.ts\";\nimport { executeScriptedWriter } from \"./scripted-writer.ts\";\nimport type { VerifiedRunRuntime } from \"./session-port.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\n\nexport async function executeWriter(\n\tcontext: RunPhaseContext,\n\toptions: {\n\t\treadonly workspace: string;\n\t\treadonly deadline: number;\n\t\treadonly runtime?: VerifiedRunRuntime;\n\t},\n): Promise<void> {\n\tconst { contract, journal } = context;\n\tconst execute = (request: OwnedRunCommand, toolSignal?: AbortSignal) => {\n\t\tconst signals = [context.signal, toolSignal].filter((signal): signal is AbortSignal => signal !== undefined);\n\t\treturn executeRunCommand(journal, request, {\n\t\t\t...contract.budget,\n\t\t\t...(signals.length ? { signal: AbortSignal.any(signals) } : {}),\n\t\t});\n\t};\n\tswitch (contract.profile) {\n\t\tcase \"linux-command-dag-v1\":\n\t\t\treturn executeDag(context, options);\n\t\tcase \"linux-command-v1\": {\n\t\t\tconst writer = await execute({\n\t\t\t\trole: \"writer\",\n\t\t\t\targv: contract.writer,\n\t\t\t\tworkspace: options.workspace,\n\t\t\t\tdeadline: options.deadline,\n\t\t\t\tclaimId: null,\n\t\t\t});\n\t\t\tif (writer.result.failure) throw new VerifiedRunError(writer.result.failure);\n\t\t\treturn;\n\t\t}\n\t\tcase \"linux-scripted-agent-v1\": {\n\t\t\tconst runtime = options.runtime;\n\t\t\tif (!runtime) throw new VerifiedRunError(\"writer_backend_missing\");\n\t\t\tconst writer = contract.writer;\n\t\t\tconst requestLimit = writer.maxRequests - journal.state.modelRequests;\n\t\t\tif (requestLimit <= 0) throw new VerifiedRunError(\"model_request_limit\");\n\t\t\tjournal.append({ kind: \"writer_opened\" });\n\t\t\tlet completed = false;\n\t\t\ttry {\n\t\t\t\tawait executeScriptedWriter(writer, contract.goal, {\n\t\t\t\t\truntime,\n\t\t\t\t\tworkspace: options.workspace,\n\t\t\t\t\tdeadline: options.deadline,\n\t\t\t\t\trequestLimit,\n\t\t\t\t\t...(context.signal ? { signal: context.signal } : {}),\n\t\t\t\t\tbeforeRequest: () => {\n\t\t\t\t\t\tif (performance.now() >= options.deadline) throw new VerifiedRunError(\"deadline\");\n\t\t\t\t\t\tjournal.append({ kind: \"model_request\", requestId: randomUUID() });\n\t\t\t\t\t\tif (performance.now() >= options.deadline) throw new VerifiedRunError(\"deadline\");\n\t\t\t\t\t},\n\t\t\t\t\texecuteStep: (index, signal) => {\n\t\t\t\t\t\tconst argv = writer.steps[index];\n\t\t\t\t\t\tif (!argv) throw new VerifiedRunError(\"writer_step\");\n\t\t\t\t\t\treturn execute(\n\t\t\t\t\t\t\t{ role: \"writer\", argv, workspace: options.workspace, deadline: options.deadline, claimId: null },\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tcompleted = true;\n\t\t\t} finally {\n\t\t\t\tif (journal.state.activeExecutionIds.length === 0) journal.append({ kind: \"writer_closed\", completed });\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tdefault: {\n\t\t\tconst exhaustive: never = contract;\n\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t}\n\t}\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import type { RunEvent, WriterReduction } from "./run-types.ts";
2
+ type WriterEvent = Extract<RunEvent, {
3
+ kind: "writer_opened" | "model_request" | "writer_closed";
4
+ }>;
5
+ export declare function acceptWriterDispatch(context: WriterReduction, event: Extract<RunEvent, {
6
+ kind: "dispatch";
7
+ }>): void;
8
+ /** Mutates only the private replay accumulator; no work, clocks, or caller data are consulted. */
9
+ export declare function reduceWriterEvent(context: WriterReduction, event: WriterEvent): void;
10
+ export {};
11
+ //# sourceMappingURL=writer-projection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer-projection.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/writer-projection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAIhE,KAAK,WAAW,GAAG,OAAO,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,eAAe,GAAG,eAAe,GAAG,eAAe,CAAA;CAAE,CAAC,CAAC;AAEpG,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,GAAG,IAAI,CA8BnH;AAED,kGAAkG;AAClG,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CA0CpF","sourcesContent":["import type { RunEvent, WriterReduction } from \"./run-types.ts\";\nimport { VerifiedRunError } from \"./storage.ts\";\nimport { bindTaskExecution } from \"./task-execution.ts\";\n\ntype WriterEvent = Extract<RunEvent, { kind: \"writer_opened\" | \"model_request\" | \"writer_closed\" }>;\n\nexport function acceptWriterDispatch(context: WriterReduction, event: Extract<RunEvent, { kind: \"dispatch\" }>): void {\n\tconst { state, contract } = context;\n\tif (\n\t\tevent.claimId !== null ||\n\t\tstate.candidateDigest ||\n\t\t(event.taskId !== undefined && contract.profile !== \"linux-command-dag-v1\")\n\t)\n\t\tthrow new VerifiedRunError(\"integrity\");\n\tswitch (contract.profile) {\n\t\tcase \"linux-command-v1\":\n\t\t\tif (context.writerStarted) throw new VerifiedRunError(\"integrity\");\n\t\t\tbreak;\n\t\tcase \"linux-scripted-agent-v1\":\n\t\t\tif (\n\t\t\t\t!state.writerOpen ||\n\t\t\t\tcontext.writerCommands >= contract.writer.steps.length ||\n\t\t\t\tstate.modelRequests - context.requestBaseline <= context.writerCommands\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tbreak;\n\t\tcase \"linux-command-dag-v1\":\n\t\t\tbindTaskExecution(context, event);\n\t\t\treturn;\n\t\tdefault: {\n\t\t\tconst exhaustive: never = contract;\n\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t}\n\t}\n\tcontext.writerStarted = true;\n\tcontext.writerCommands += 1;\n}\n\n/** Mutates only the private replay accumulator; no work, clocks, or caller data are consulted. */\nexport function reduceWriterEvent(context: WriterReduction, event: WriterEvent): void {\n\tconst state = context.state;\n\tconst scripted = context.contract.profile === \"linux-scripted-agent-v1\" ? context.contract.writer : undefined;\n\tswitch (event.kind) {\n\t\tcase \"writer_opened\":\n\t\t\tif (!scripted || context.producerStarted || context.writerStarted || state.candidateDigest)\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tcontext.producerStarted = true;\n\t\t\tcontext.state = { ...state, writerOpen: true, execution: \"running\", settlement: \"open\" };\n\t\t\treturn;\n\t\tcase \"model_request\":\n\t\t\tif (\n\t\t\t\t!scripted ||\n\t\t\t\t!state.writerOpen ||\n\t\t\t\tcontext.requests.has(event.requestId) ||\n\t\t\t\tstate.activeExecutionIds.length ||\n\t\t\t\tstate.modelRequests >= scripted.maxRequests\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"model_request_limit\");\n\t\t\tcontext.requests.add(event.requestId);\n\t\t\tcontext.state = { ...state, modelRequests: state.modelRequests + 1 };\n\t\t\treturn;\n\t\tcase \"writer_closed\":\n\t\t\tif (\n\t\t\t\t!scripted ||\n\t\t\t\t!state.writerOpen ||\n\t\t\t\tstate.activeExecutionIds.length ||\n\t\t\t\t(event.completed &&\n\t\t\t\t\t(!context.writerFinished ||\n\t\t\t\t\t\tstate.failure ||\n\t\t\t\t\t\tcontext.writerCommands !== scripted.steps.length ||\n\t\t\t\t\t\tstate.modelRequests - context.requestBaseline < scripted.steps.length + 1))\n\t\t\t)\n\t\t\t\tthrow new VerifiedRunError(\"integrity\");\n\t\t\tcontext.writerFinished = event.completed;\n\t\t\tcontext.state = { ...state, writerOpen: false, settlement: \"settled\" };\n\t\t\treturn;\n\t\tdefault: {\n\t\t\tconst exhaustive: never = event;\n\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t}\n\t}\n}\n"]}