niceeval 0.13.1 → 0.13.2

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 (548) hide show
  1. package/INDEX.md +25 -2
  2. package/README.md +9 -10
  3. package/README.zh.md +9 -10
  4. package/dist/agents/ai-sdk.cjs.map +1 -1
  5. package/dist/agents/ai-sdk.d.cts +1 -1
  6. package/dist/agents/ai-sdk.d.mts +1 -1
  7. package/dist/agents/ai-sdk.d.ts +1 -1
  8. package/dist/agents/bub-install-spec.cjs +19 -5
  9. package/dist/agents/bub-install-spec.cjs.map +1 -1
  10. package/dist/agents/bub-install-spec.d.cts +9 -2
  11. package/dist/agents/bub-install-spec.d.mts +9 -2
  12. package/dist/agents/bub-install-spec.d.ts +9 -2
  13. package/dist/agents/bub-install-spec.js +14 -12
  14. package/dist/agents/bub.cjs +10 -6
  15. package/dist/agents/bub.cjs.map +1 -1
  16. package/dist/agents/bub.d.cts +2 -2
  17. package/dist/agents/bub.d.mts +2 -2
  18. package/dist/agents/bub.d.ts +2 -2
  19. package/dist/agents/claude-code.cjs.map +1 -1
  20. package/dist/agents/claude-code.d.cts +2 -2
  21. package/dist/agents/claude-code.d.mts +2 -2
  22. package/dist/agents/claude-code.d.ts +2 -2
  23. package/dist/agents/codex.cjs +4 -4
  24. package/dist/agents/codex.cjs.map +1 -1
  25. package/dist/agents/codex.d.cts +3 -3
  26. package/dist/agents/codex.d.mts +3 -3
  27. package/dist/agents/codex.d.ts +3 -3
  28. package/dist/agents/coding-cli-versions.cjs +10 -1
  29. package/dist/agents/coding-cli-versions.cjs.map +1 -1
  30. package/dist/agents/coding-cli-versions.d.cts +8 -3
  31. package/dist/agents/coding-cli-versions.d.mts +8 -3
  32. package/dist/agents/coding-cli-versions.d.ts +8 -3
  33. package/dist/agents/coding-cli-versions.js +18 -12
  34. package/dist/agents/deepseek-harness.cjs +151 -0
  35. package/dist/agents/deepseek-harness.cjs.map +1 -0
  36. package/dist/agents/deepseek-harness.d.cts +14 -0
  37. package/dist/agents/deepseek-harness.d.mts +14 -0
  38. package/dist/agents/deepseek-harness.d.ts +14 -0
  39. package/dist/agents/deepseek-harness.js +7 -0
  40. package/dist/agents/deepseek-harness.js.map +1 -0
  41. package/dist/agents/exact-npm-plugins.cjs +28 -0
  42. package/dist/agents/exact-npm-plugins.cjs.map +1 -0
  43. package/dist/agents/exact-npm-plugins.d.cts +10 -0
  44. package/dist/agents/exact-npm-plugins.d.mts +10 -0
  45. package/dist/agents/exact-npm-plugins.d.ts +10 -0
  46. package/dist/agents/exact-npm-plugins.js +8 -0
  47. package/dist/agents/exact-npm-plugins.js.map +1 -0
  48. package/dist/agents/index.cjs +5 -1
  49. package/dist/agents/index.cjs.map +1 -1
  50. package/dist/agents/index.d.cts +4 -0
  51. package/dist/agents/index.d.mts +4 -0
  52. package/dist/agents/index.d.ts +4 -0
  53. package/dist/agents/index.js +54 -50
  54. package/dist/agents/index.mjs +54 -50
  55. package/dist/agents/omp.cjs +170 -0
  56. package/dist/agents/omp.cjs.map +1 -0
  57. package/dist/agents/omp.d.cts +14 -0
  58. package/dist/agents/omp.d.mts +14 -0
  59. package/dist/agents/omp.d.ts +14 -0
  60. package/dist/agents/omp.js +7 -0
  61. package/dist/agents/omp.js.map +1 -0
  62. package/dist/agents/openclaw.cjs +51 -2
  63. package/dist/agents/openclaw.cjs.map +1 -1
  64. package/dist/agents/openclaw.d.cts +2 -0
  65. package/dist/agents/openclaw.d.mts +2 -0
  66. package/dist/agents/openclaw.d.ts +2 -0
  67. package/dist/agents/types.cjs.map +1 -1
  68. package/dist/agents/types.d.cts +4 -4
  69. package/dist/agents/types.d.mts +4 -4
  70. package/dist/agents/types.d.ts +4 -4
  71. package/dist/agents/ui-message-stream.cjs +24 -7
  72. package/dist/agents/ui-message-stream.cjs.map +1 -1
  73. package/dist/analysis/api.cjs +28 -2
  74. package/dist/analysis/api.cjs.map +1 -1
  75. package/dist/analysis/api.d.cts +22 -1
  76. package/dist/analysis/api.d.mts +22 -1
  77. package/dist/analysis/api.d.ts +22 -1
  78. package/dist/analysis/api.js +8 -6
  79. package/dist/analysis/bindings.cjs +11 -18
  80. package/dist/analysis/bindings.cjs.map +1 -1
  81. package/dist/analysis/bindings.d.cts +177 -49
  82. package/dist/analysis/bindings.d.mts +177 -49
  83. package/dist/analysis/bindings.d.ts +177 -49
  84. package/dist/analysis/contracts.cjs +1 -0
  85. package/dist/analysis/contracts.cjs.map +1 -1
  86. package/dist/analysis/contracts.d.cts +43 -3
  87. package/dist/analysis/contracts.d.mts +43 -3
  88. package/dist/analysis/contracts.d.ts +43 -3
  89. package/dist/analysis/cost-projection.cjs +2 -1
  90. package/dist/analysis/cost-projection.cjs.map +1 -1
  91. package/dist/analysis/cost-projection.d.cts +1 -1
  92. package/dist/analysis/cost-projection.d.mts +1 -1
  93. package/dist/analysis/cost-projection.d.ts +1 -1
  94. package/dist/analysis/cost.cjs +13 -3
  95. package/dist/analysis/cost.cjs.map +1 -1
  96. package/dist/analysis/cost.d.cts +10 -3
  97. package/dist/analysis/cost.d.mts +10 -3
  98. package/dist/analysis/cost.d.ts +10 -3
  99. package/dist/analysis/experiment-groups.cjs +96 -0
  100. package/dist/analysis/experiment-groups.cjs.map +1 -0
  101. package/dist/analysis/experiment-groups.d.cts +9 -0
  102. package/dist/analysis/experiment-groups.d.mts +9 -0
  103. package/dist/analysis/experiment-groups.d.ts +9 -0
  104. package/dist/analysis/experiment-groups.js +10 -0
  105. package/dist/analysis/experiment-groups.js.map +1 -0
  106. package/dist/analysis/index.cjs +4 -1
  107. package/dist/analysis/index.cjs.map +1 -1
  108. package/dist/analysis/index.d.cts +4 -2
  109. package/dist/analysis/index.d.mts +4 -2
  110. package/dist/analysis/index.d.ts +4 -2
  111. package/dist/analysis/index.js +40 -36
  112. package/dist/analysis/index.mjs +40 -36
  113. package/dist/assertions/limits.cjs +4 -0
  114. package/dist/assertions/limits.cjs.map +1 -1
  115. package/dist/assertions/limits.d.cts +4 -0
  116. package/dist/assertions/limits.d.mts +4 -0
  117. package/dist/assertions/limits.d.ts +4 -0
  118. package/dist/assertions/match.cjs +63 -25
  119. package/dist/assertions/match.cjs.map +1 -1
  120. package/dist/assertions/match.d.cts +7 -0
  121. package/dist/assertions/match.d.mts +7 -0
  122. package/dist/assertions/match.d.ts +7 -0
  123. package/dist/assertions/record/attachment.cjs +32 -4
  124. package/dist/assertions/record/attachment.cjs.map +1 -1
  125. package/dist/assertions/record/diff.cjs +10 -4
  126. package/dist/assertions/record/diff.cjs.map +1 -1
  127. package/dist/assertions/record/producer.cjs +101 -4
  128. package/dist/assertions/record/producer.cjs.map +1 -1
  129. package/dist/assertions/record/producer.d.cts +4 -1
  130. package/dist/assertions/record/producer.d.mts +4 -1
  131. package/dist/assertions/record/producer.d.ts +4 -1
  132. package/dist/assertions/runtime.cjs +45 -5
  133. package/dist/assertions/runtime.cjs.map +1 -1
  134. package/dist/cli/record.cjs +113 -8
  135. package/dist/cli/record.cjs.map +1 -1
  136. package/dist/cli/record.d.cts +20 -1
  137. package/dist/cli/record.d.mts +20 -1
  138. package/dist/cli/record.d.ts +20 -1
  139. package/dist/cli/record.js +4 -2
  140. package/dist/cli.cjs +386 -31
  141. package/dist/cli.cjs.map +1 -1
  142. package/dist/cli.d.cts +10 -2
  143. package/dist/cli.d.mts +10 -2
  144. package/dist/cli.d.ts +10 -2
  145. package/dist/context/send-retry.cjs +4 -4
  146. package/dist/context/send-retry.cjs.map +1 -1
  147. package/dist/coordination/host/runtime.cjs +8 -30
  148. package/dist/coordination/host/runtime.cjs.map +1 -1
  149. package/dist/coordination/host/runtime.d.cts +3 -3
  150. package/dist/coordination/host/runtime.d.mts +3 -3
  151. package/dist/coordination/host/runtime.d.ts +3 -3
  152. package/dist/coordination/host/types.cjs.map +1 -1
  153. package/dist/coordination/host/types.d.cts +0 -5
  154. package/dist/coordination/host/types.d.mts +0 -5
  155. package/dist/coordination/host/types.d.ts +0 -5
  156. package/dist/coordination/platform/node.cjs +90 -9
  157. package/dist/coordination/platform/node.cjs.map +1 -1
  158. package/dist/define.cjs +25 -1
  159. package/dist/define.cjs.map +1 -1
  160. package/dist/experiment/host/index.cjs +1 -0
  161. package/dist/experiment/host/index.cjs.map +1 -1
  162. package/dist/i18n/en.cjs +26 -8
  163. package/dist/i18n/en.cjs.map +1 -1
  164. package/dist/i18n/en.d.cts +19 -6
  165. package/dist/i18n/en.d.mts +19 -6
  166. package/dist/i18n/en.d.ts +19 -6
  167. package/dist/index.cjs.map +1 -1
  168. package/dist/index.d.cts +1 -1
  169. package/dist/index.d.mts +1 -1
  170. package/dist/index.d.ts +1 -1
  171. package/dist/o11y/parsers/hermes.cjs +1 -1
  172. package/dist/o11y/parsers/hermes.cjs.map +1 -1
  173. package/dist/o11y/prices.json +1 -1
  174. package/dist/o11y/record/families.cjs +12 -3
  175. package/dist/o11y/record/families.cjs.map +1 -1
  176. package/dist/o11y/record/families.d.cts +8 -8
  177. package/dist/o11y/record/families.d.mts +8 -8
  178. package/dist/o11y/record/families.d.ts +8 -8
  179. package/dist/o11y/record/family-projectors.d.cts +66 -18
  180. package/dist/o11y/record/family-projectors.d.mts +66 -18
  181. package/dist/o11y/record/family-projectors.d.ts +66 -18
  182. package/dist/o11y/record/family-writers.d.cts +11 -3
  183. package/dist/o11y/record/family-writers.d.mts +11 -3
  184. package/dist/o11y/record/family-writers.d.ts +11 -3
  185. package/dist/o11y/record/runner-producer.cjs +14 -4
  186. package/dist/o11y/record/runner-producer.cjs.map +1 -1
  187. package/dist/record/codec/core.d.cts +2 -2
  188. package/dist/record/codec/core.d.mts +2 -2
  189. package/dist/record/codec/core.d.ts +2 -2
  190. package/dist/record/family/catalog.d.cts +44 -12
  191. package/dist/record/family/catalog.d.mts +44 -12
  192. package/dist/record/family/catalog.d.ts +44 -12
  193. package/dist/record/family/index.js +128 -124
  194. package/dist/record/family/observability-v1.cjs +35 -0
  195. package/dist/record/family/observability-v1.cjs.map +1 -0
  196. package/dist/record/family/observability-v1.d.cts +3 -0
  197. package/dist/record/family/observability-v1.d.mts +3 -0
  198. package/dist/record/family/observability-v1.d.ts +3 -0
  199. package/dist/record/family/observability-v1.js +6 -0
  200. package/dist/record/family/observability-v1.js.map +1 -0
  201. package/dist/record/family/observability.cjs +58 -9
  202. package/dist/record/family/observability.cjs.map +1 -1
  203. package/dist/record/family/observability.d.cts +1014 -15
  204. package/dist/record/family/observability.d.mts +1014 -15
  205. package/dist/record/family/observability.d.ts +1014 -15
  206. package/dist/record/family/observability.js +22 -18
  207. package/dist/record/host/runtime.cjs +600 -31
  208. package/dist/record/host/runtime.cjs.map +1 -1
  209. package/dist/record/host/types.cjs.map +1 -1
  210. package/dist/record/host/types.d.cts +33 -9
  211. package/dist/record/host/types.d.mts +33 -9
  212. package/dist/record/host/types.d.ts +33 -9
  213. package/dist/record/maintenance/runtime.cjs +1 -2
  214. package/dist/record/maintenance/runtime.cjs.map +1 -1
  215. package/dist/record/model/core.cjs.map +1 -1
  216. package/dist/record/model/core.d.cts +1 -1
  217. package/dist/record/model/core.d.mts +1 -1
  218. package/dist/record/model/core.d.ts +1 -1
  219. package/dist/record/model/definition.d.cts +6 -6
  220. package/dist/record/model/definition.d.mts +6 -6
  221. package/dist/record/model/definition.d.ts +6 -6
  222. package/dist/record/model/identifiers.cjs +1 -1
  223. package/dist/record/model/identifiers.cjs.map +1 -1
  224. package/dist/record/model/identifiers.d.cts +1 -1
  225. package/dist/record/model/identifiers.d.mts +1 -1
  226. package/dist/record/model/identifiers.d.ts +1 -1
  227. package/dist/record/platform/node.cjs +159 -23
  228. package/dist/record/platform/node.cjs.map +1 -1
  229. package/dist/record/platform/services.cjs.map +1 -1
  230. package/dist/record/platform/services.d.cts +15 -2
  231. package/dist/record/platform/services.d.mts +15 -2
  232. package/dist/record/platform/services.d.ts +15 -2
  233. package/dist/record/reader/errors.cjs +37 -1
  234. package/dist/record/reader/errors.cjs.map +1 -1
  235. package/dist/record/reader/errors.d.cts +49 -1
  236. package/dist/record/reader/errors.d.mts +49 -1
  237. package/dist/record/reader/errors.d.ts +49 -1
  238. package/dist/record/reader/errors.js +22 -12
  239. package/dist/record/reader/format.cjs +76 -17
  240. package/dist/record/reader/format.cjs.map +1 -1
  241. package/dist/record/reader/format.d.cts +11 -4
  242. package/dist/record/reader/format.d.mts +11 -4
  243. package/dist/record/reader/format.d.ts +11 -4
  244. package/dist/record/reader/format.js +2 -0
  245. package/dist/record/reader/index.js +32 -18
  246. package/dist/record/reader/runtime.cjs +64 -0
  247. package/dist/record/reader/runtime.cjs.map +1 -1
  248. package/dist/record/reader/runtime.d.cts +15 -0
  249. package/dist/record/reader/runtime.d.mts +15 -0
  250. package/dist/record/reader/runtime.d.ts +15 -0
  251. package/dist/record/reader/runtime.js +2 -0
  252. package/dist/report/assets/styles.css +53 -29
  253. package/dist/report/built-in/analysis-values.cjs +21 -13
  254. package/dist/report/built-in/analysis-values.cjs.map +1 -1
  255. package/dist/report/built-in/analysis-values.d.cts +11 -22
  256. package/dist/report/built-in/analysis-values.d.mts +11 -22
  257. package/dist/report/built-in/analysis-values.d.ts +11 -22
  258. package/dist/report/built-in/analysis-values.js +4 -6
  259. package/dist/report/built-in/index.cjs +1 -3
  260. package/dist/report/built-in/index.cjs.map +1 -1
  261. package/dist/report/built-in/index.d.cts +1 -1
  262. package/dist/report/built-in/index.d.mts +1 -1
  263. package/dist/report/built-in/index.d.ts +1 -1
  264. package/dist/report/built-in/index.js +4 -8
  265. package/dist/report/built-in/index.mjs +4 -8
  266. package/dist/report/built-in/machine.cjs +0 -2
  267. package/dist/report/built-in/machine.cjs.map +1 -1
  268. package/dist/report/built-in/machine.d.cts +0 -2
  269. package/dist/report/built-in/machine.d.mts +0 -2
  270. package/dist/report/built-in/machine.d.ts +0 -2
  271. package/dist/report/built-in/result-components.cjs +49 -51
  272. package/dist/report/built-in/result-components.cjs.map +1 -1
  273. package/dist/report/built-in/result-components.d.cts +16 -17
  274. package/dist/report/built-in/result-components.d.mts +16 -17
  275. package/dist/report/built-in/result-components.d.ts +16 -17
  276. package/dist/report/built-in/result-components.js +0 -4
  277. package/dist/report/built-in/run-membership-overview.cjs +126 -17
  278. package/dist/report/built-in/run-membership-overview.cjs.map +1 -1
  279. package/dist/report/built-in/run-membership-overview.d.cts +14 -0
  280. package/dist/report/built-in/run-membership-overview.d.mts +14 -0
  281. package/dist/report/built-in/run-membership-overview.d.ts +14 -0
  282. package/dist/report/built-in/run-membership-overview.js +4 -2
  283. package/dist/report/built-in/standard.cjs +80 -45
  284. package/dist/report/built-in/standard.cjs.map +1 -1
  285. package/dist/report/built-in/standard.d.cts +19 -41
  286. package/dist/report/built-in/standard.d.mts +19 -41
  287. package/dist/report/built-in/standard.d.ts +19 -41
  288. package/dist/report/built-in/standard.js +6 -6
  289. package/dist/report/components/attempt-detail/compute.cjs +78 -2
  290. package/dist/report/components/attempt-detail/compute.cjs.map +1 -1
  291. package/dist/report/components/attempt-detail/compute.d.cts +1 -1
  292. package/dist/report/components/attempt-detail/compute.d.mts +1 -1
  293. package/dist/report/components/attempt-detail/compute.d.ts +1 -1
  294. package/dist/report/components/attempt-detail/content.cjs +1 -1
  295. package/dist/report/components/attempt-detail/content.cjs.map +1 -1
  296. package/dist/report/components/entity-lists/compute.cjs +42 -5
  297. package/dist/report/components/entity-lists/compute.cjs.map +1 -1
  298. package/dist/report/components/entity-lists/compute.d.cts +10 -8
  299. package/dist/report/components/entity-lists/compute.d.mts +10 -8
  300. package/dist/report/components/entity-lists/compute.d.ts +10 -8
  301. package/dist/report/components/entity-lists/content.cjs +31 -6
  302. package/dist/report/components/entity-lists/content.cjs.map +1 -1
  303. package/dist/report/components/entity-lists/index.cjs +9 -4
  304. package/dist/report/components/entity-lists/index.cjs.map +1 -1
  305. package/dist/report/components/entity-lists/index.d.cts +4 -7
  306. package/dist/report/components/entity-lists/index.d.mts +4 -7
  307. package/dist/report/components/entity-lists/index.d.ts +4 -7
  308. package/dist/report/components/summaries/compute.cjs +8 -1
  309. package/dist/report/components/summaries/compute.cjs.map +1 -1
  310. package/dist/report/components/summaries/compute.d.cts +9 -1
  311. package/dist/report/components/summaries/compute.d.mts +9 -1
  312. package/dist/report/components/summaries/compute.d.ts +9 -1
  313. package/dist/report/components/summaries/index.cjs +48 -4
  314. package/dist/report/components/summaries/index.cjs.map +1 -1
  315. package/dist/report/components/summaries/index.d.cts +7 -4
  316. package/dist/report/components/summaries/index.d.mts +7 -4
  317. package/dist/report/components/summaries/index.d.ts +7 -4
  318. package/dist/report/definition/cell.cjs +3 -0
  319. package/dist/report/definition/cell.cjs.map +1 -1
  320. package/dist/report/definition/cell.d.cts +2 -0
  321. package/dist/report/definition/cell.d.mts +2 -0
  322. package/dist/report/definition/cell.d.ts +2 -0
  323. package/dist/report/definition/primitives/chart.cjs +8 -5
  324. package/dist/report/definition/primitives/chart.cjs.map +1 -1
  325. package/dist/report/definition/primitives/points-dataset.cjs +1 -0
  326. package/dist/report/definition/primitives/points-dataset.cjs.map +1 -1
  327. package/dist/report/definition/primitives.cjs +15 -2
  328. package/dist/report/definition/primitives.cjs.map +1 -1
  329. package/dist/report/definition/report.cjs +27 -3
  330. package/dist/report/definition/report.cjs.map +1 -1
  331. package/dist/report/definition/report.d.cts +8 -0
  332. package/dist/report/definition/report.d.mts +8 -0
  333. package/dist/report/definition/report.d.ts +8 -0
  334. package/dist/report/execution/machine.cjs +30 -14
  335. package/dist/report/execution/machine.cjs.map +1 -1
  336. package/dist/report/execution/machine.d.cts +20 -10
  337. package/dist/report/execution/machine.d.mts +20 -10
  338. package/dist/report/execution/machine.d.ts +20 -10
  339. package/dist/report/execution/machine.js +6 -6
  340. package/dist/report/host/execute.cjs +25 -16
  341. package/dist/report/host/execute.cjs.map +1 -1
  342. package/dist/report/host/execute.d.cts +4 -0
  343. package/dist/report/host/execute.d.mts +4 -0
  344. package/dist/report/host/execute.d.ts +4 -0
  345. package/dist/report/host/from-record.cjs +22 -5
  346. package/dist/report/host/from-record.cjs.map +1 -1
  347. package/dist/report/host/machine.cjs +53 -11
  348. package/dist/report/host/machine.cjs.map +1 -1
  349. package/dist/report/host/site-runtime.cjs +9 -8
  350. package/dist/report/host/site-runtime.cjs.map +1 -1
  351. package/dist/report/host/site-runtime.d.cts +1 -1
  352. package/dist/report/host/site-runtime.d.mts +1 -1
  353. package/dist/report/host/site-runtime.d.ts +1 -1
  354. package/dist/report/host/static.cjs +56 -9
  355. package/dist/report/host/static.cjs.map +1 -1
  356. package/dist/report/index.cjs.map +1 -1
  357. package/dist/report/index.d.cts +1 -1
  358. package/dist/report/index.d.mts +1 -1
  359. package/dist/report/index.d.ts +1 -1
  360. package/dist/report/model/dataset.cjs +7 -2
  361. package/dist/report/model/dataset.cjs.map +1 -1
  362. package/dist/report/model/locale.cjs +2 -0
  363. package/dist/report/model/locale.cjs.map +1 -1
  364. package/dist/report/model/locale.d.cts +1 -0
  365. package/dist/report/model/locale.d.mts +1 -0
  366. package/dist/report/model/locale.d.ts +1 -0
  367. package/dist/report/model/metrics.cjs +3 -1
  368. package/dist/report/model/metrics.cjs.map +1 -1
  369. package/dist/report/model/pricing.cjs +16 -11
  370. package/dist/report/model/pricing.cjs.map +1 -1
  371. package/dist/report/react/styles.css +53 -29
  372. package/dist/runner/adoption.cjs +1 -0
  373. package/dist/runner/adoption.cjs.map +1 -1
  374. package/dist/runner/attempt.cjs +44 -5
  375. package/dist/runner/attempt.cjs.map +1 -1
  376. package/dist/runner/attempt.d.cts +13 -1
  377. package/dist/runner/attempt.d.mts +13 -1
  378. package/dist/runner/attempt.d.ts +13 -1
  379. package/dist/runner/config-identity.cjs +10 -2
  380. package/dist/runner/config-identity.cjs.map +1 -1
  381. package/dist/runner/config-identity.d.cts +4 -2
  382. package/dist/runner/config-identity.d.mts +4 -2
  383. package/dist/runner/config-identity.d.ts +4 -2
  384. package/dist/runner/feedback/human.cjs +298 -59
  385. package/dist/runner/feedback/human.cjs.map +1 -1
  386. package/dist/runner/feedback/json.cjs +14 -6
  387. package/dist/runner/feedback/json.cjs.map +1 -1
  388. package/dist/runner/feedback/json.d.cts +3 -2
  389. package/dist/runner/feedback/json.d.mts +3 -2
  390. package/dist/runner/feedback/json.d.ts +3 -2
  391. package/dist/runner/feedback/reducer.cjs +2 -0
  392. package/dist/runner/feedback/reducer.cjs.map +1 -1
  393. package/dist/runner/judge-config.cjs +1 -1
  394. package/dist/runner/judge-config.cjs.map +1 -1
  395. package/dist/runner/ledger.cjs +124 -12
  396. package/dist/runner/ledger.cjs.map +1 -1
  397. package/dist/runner/project-current.cjs +13 -5
  398. package/dist/runner/project-current.cjs.map +1 -1
  399. package/dist/runner/run.cjs +564 -256
  400. package/dist/runner/run.cjs.map +1 -1
  401. package/dist/runner/sandbox-pool.cjs +161 -30
  402. package/dist/runner/sandbox-pool.cjs.map +1 -1
  403. package/dist/runner/sandbox-pool.d.cts +34 -2
  404. package/dist/runner/sandbox-pool.d.mts +34 -2
  405. package/dist/runner/sandbox-pool.d.ts +34 -2
  406. package/dist/runner/shared-state-lease.cjs +803 -0
  407. package/dist/runner/shared-state-lease.cjs.map +1 -0
  408. package/dist/runner/shared-state-lease.d.cts +121 -0
  409. package/dist/runner/shared-state-lease.d.mts +121 -0
  410. package/dist/runner/shared-state-lease.d.ts +121 -0
  411. package/dist/runner/shared-state-lease.js +24 -0
  412. package/dist/runner/shared-state-lease.js.map +1 -0
  413. package/dist/runner/teardown-registry.cjs +97 -34
  414. package/dist/runner/teardown-registry.cjs.map +1 -1
  415. package/dist/runner/teardown-registry.d.cts +27 -1
  416. package/dist/runner/teardown-registry.d.mts +27 -1
  417. package/dist/runner/teardown-registry.d.ts +27 -1
  418. package/dist/runner/teardown-registry.js +20 -16
  419. package/dist/runner/types.cjs.map +1 -1
  420. package/dist/runner/types.d.cts +31 -5
  421. package/dist/runner/types.d.mts +31 -5
  422. package/dist/runner/types.d.ts +31 -5
  423. package/dist/sample/analysis.cjs +249 -459
  424. package/dist/sample/analysis.cjs.map +1 -1
  425. package/dist/sample/capability.cjs +138 -7
  426. package/dist/sample/capability.cjs.map +1 -1
  427. package/dist/sample/capability.d.cts +3 -1
  428. package/dist/sample/capability.d.mts +3 -1
  429. package/dist/sample/capability.d.ts +3 -1
  430. package/dist/sample/capability.js +8 -6
  431. package/dist/sandbox/docker-agent-image.cjs +5 -1
  432. package/dist/sandbox/docker-agent-image.cjs.map +1 -1
  433. package/dist/sandbox/docker-agent-image.d.cts +2 -0
  434. package/dist/sandbox/docker-agent-image.d.mts +2 -0
  435. package/dist/sandbox/docker-agent-image.d.ts +2 -0
  436. package/dist/sandbox/docker-agent-image.js +14 -10
  437. package/dist/sandbox/docker-profile/schema.cjs +283 -534
  438. package/dist/sandbox/docker-profile/schema.cjs.map +1 -1
  439. package/dist/sandbox/docker-profile/schema.d.cts +10 -27
  440. package/dist/sandbox/docker-profile/schema.d.mts +10 -27
  441. package/dist/sandbox/docker-profile/schema.d.ts +10 -27
  442. package/dist/sandbox/e2b-agent-template.cjs +5 -2
  443. package/dist/sandbox/e2b-agent-template.cjs.map +1 -1
  444. package/dist/sandbox/index.cjs +4 -2
  445. package/dist/sandbox/index.cjs.map +1 -1
  446. package/dist/sandbox/index.d.cts +1 -1
  447. package/dist/sandbox/index.d.mts +1 -1
  448. package/dist/sandbox/index.d.ts +1 -1
  449. package/dist/sandbox/index.js +120 -116
  450. package/dist/sandbox/index.mjs +120 -116
  451. package/dist/sandbox/keep-registry.cjs +28 -66
  452. package/dist/sandbox/keep-registry.cjs.map +1 -1
  453. package/dist/sandbox/types.cjs.map +1 -1
  454. package/dist/sandbox/types.d.cts +1 -1
  455. package/dist/sandbox/types.d.mts +1 -1
  456. package/dist/sandbox/types.d.ts +1 -1
  457. package/dist/shared/aggregate.cjs +16 -6
  458. package/dist/shared/aggregate.cjs.map +1 -1
  459. package/dist/shared/aggregate.d.cts +12 -4
  460. package/dist/shared/aggregate.d.mts +12 -4
  461. package/dist/shared/aggregate.d.ts +12 -4
  462. package/dist/shared/turn-label.cjs +20 -2
  463. package/dist/shared/turn-label.cjs.map +1 -1
  464. package/dist/shared/turn-label.d.cts +2 -0
  465. package/dist/shared/turn-label.d.mts +2 -0
  466. package/dist/shared/turn-label.d.ts +2 -0
  467. package/dist/shared/turn-label.js +4 -2
  468. package/dist/vendor/remark/remark-gfm.cjs +7 -7
  469. package/dist/vendor/remark/remark-gfm.cjs.map +1 -1
  470. package/dist/vendor/remark/remark-parse.cjs +12 -12
  471. package/dist/vendor/remark/remark-parse.cjs.map +1 -1
  472. package/dist/vendor/remark/remark.cjs +13 -13
  473. package/dist/vendor/remark/remark.cjs.map +1 -1
  474. package/dist/view/server.cjs +6 -0
  475. package/dist/view/server.cjs.map +1 -1
  476. package/docs-site/images/hitl-handshake-zh.svg +3 -3
  477. package/docs-site/zh/examples/ai-agent-application.mdx +1 -1
  478. package/docs-site/zh/examples/coding-agent-extensions.mdx +1 -1
  479. package/docs-site/zh/examples/integrations/ai-sdk-v7.mdx +4 -3
  480. package/docs-site/zh/examples/integrations/claude-sdk.mdx +3 -3
  481. package/docs-site/zh/examples/integrations/codex-sdk.mdx +5 -5
  482. package/docs-site/zh/examples/integrations/langgraph.mdx +4 -4
  483. package/docs-site/zh/examples/integrations/pi-sdk.mdx +5 -5
  484. package/docs-site/zh/explanation/adapter.mdx +5 -5
  485. package/docs-site/zh/explanation/assert.mdx +7 -7
  486. package/docs-site/zh/explanation/drive.mdx +4 -2
  487. package/docs-site/zh/explanation/evals.mdx +10 -8
  488. package/docs-site/zh/explanation/experiment.mdx +2 -2
  489. package/docs-site/zh/explanation/hitl.mdx +9 -9
  490. package/docs-site/zh/explanation/judge.mdx +5 -5
  491. package/docs-site/zh/explanation/overview.mdx +3 -3
  492. package/docs-site/zh/explanation/runner.mdx +1 -1
  493. package/docs-site/zh/index.mdx +3 -3
  494. package/docs-site/zh/reference/builtin-agents.mdx +13 -13
  495. package/docs-site/zh/reference/capabilities.mdx +1 -1
  496. package/docs-site/zh/reference/cli.mdx +18 -12
  497. package/docs-site/zh/reference/define-agent.mdx +130 -5
  498. package/docs-site/zh/reference/define-config.mdx +2 -2
  499. package/docs-site/zh/reference/define-eval.mdx +4 -4
  500. package/docs-site/zh/reference/events.mdx +11 -11
  501. package/docs-site/zh/reference/official-adapters.mdx +6 -6
  502. package/docs-site/zh/reference/results-data.mdx +6 -0
  503. package/docs-site/zh/troubleshooting/debugging.mdx +1 -1
  504. package/docs-site/zh/troubleshooting/recover-after-kill.mdx +37 -5
  505. package/docs-site/zh/tutorials/accept-results.mdx +72 -0
  506. package/docs-site/zh/tutorials/agent-onboarding.mdx +6 -6
  507. package/docs-site/zh/tutorials/authoring.mdx +9 -13
  508. package/docs-site/zh/tutorials/ci-integration.mdx +6 -6
  509. package/docs-site/zh/tutorials/compare-runs.mdx +61 -0
  510. package/docs-site/zh/tutorials/concurrency.mdx +13 -12
  511. package/docs-site/zh/tutorials/configuration.mdx +4 -6
  512. package/docs-site/zh/tutorials/connect-your-agent.mdx +1 -1
  513. package/docs-site/zh/tutorials/control-run-cost.mdx +58 -0
  514. package/docs-site/zh/tutorials/criteria-files.mdx +2 -2
  515. package/docs-site/zh/tutorials/custom-reports.mdx +2 -2
  516. package/docs-site/zh/tutorials/debug-lifecycle-plan.mdx +46 -0
  517. package/docs-site/zh/tutorials/docker-in-docker.mdx +52 -43
  518. package/docs-site/zh/tutorials/eval-groups.mdx +6 -6
  519. package/docs-site/zh/tutorials/evaluation-kinds.mdx +3 -3
  520. package/docs-site/zh/tutorials/experiments.mdx +2 -3
  521. package/docs-site/zh/tutorials/handle-execution-failures.mdx +18 -10
  522. package/docs-site/zh/tutorials/install-custom-sandbox-agent.mdx +16 -8
  523. package/docs-site/zh/tutorials/nixos-managed-dind.mdx +160 -0
  524. package/docs-site/zh/tutorials/plugins.mdx +14 -0
  525. package/docs-site/zh/tutorials/rerun-and-cache.mdx +4 -2
  526. package/docs-site/zh/tutorials/sandbox-agent.mdx +17 -11
  527. package/docs-site/zh/tutorials/sandbox-providers.mdx +17 -13
  528. package/docs-site/zh/tutorials/sandbox-reuse.mdx +12 -19
  529. package/docs-site/zh/tutorials/select-and-preview.mdx +65 -0
  530. package/docs-site/zh/tutorials/verify-judge.mdx +78 -0
  531. package/docs-site/zh/tutorials/viewing-results.mdx +38 -1
  532. package/docs-site/zh/tutorials/write-experiment.mdx +7 -5
  533. package/docs-site/zh/tutorials/write-send.mdx +9 -8
  534. package/package.json +9 -5
  535. package/dist/report/built-in/overview.cjs +0 -44
  536. package/dist/report/built-in/overview.cjs.map +0 -1
  537. package/dist/report/built-in/overview.d.cts +0 -6
  538. package/dist/report/built-in/overview.d.mts +0 -6
  539. package/dist/report/built-in/overview.d.ts +0 -6
  540. package/dist/report/built-in/overview.js +0 -9
  541. package/dist/report/built-in/overview.js.map +0 -1
  542. package/dist/runner/gate-lease.cjs +0 -283
  543. package/dist/runner/gate-lease.cjs.map +0 -1
  544. package/dist/runner/gate-lease.d.cts +0 -62
  545. package/dist/runner/gate-lease.d.mts +0 -62
  546. package/dist/runner/gate-lease.d.ts +0 -62
  547. package/dist/runner/gate-lease.js +0 -22
  548. package/dist/runner/gate-lease.js.map +0 -1
@@ -45,7 +45,7 @@ export type ArtifactId = string & Brand.Brand<typeof ARTIFACT_ID_BRAND>;
45
45
  export type CanonicalProjectRelativePath = string & Brand.Brand<typeof CANONICAL_PROJECT_RELATIVE_PATH_BRAND>;
46
46
  /** Stable root identity; evolution is carried by the separate numeric header. */
47
47
  export declare const RECORD_FORMAT: "niceeval.record";
48
- export declare const RECORD_SCHEMA_VERSION: 1;
48
+ export declare const RECORD_SCHEMA_VERSION: 2;
49
49
  export type RecordFormat = typeof RECORD_FORMAT & Brand.Brand<typeof RECORD_FORMAT_ID_BRAND>;
50
50
  export type RecordSchemaVersion = typeof RECORD_SCHEMA_VERSION;
51
51
  /**
@@ -45,7 +45,7 @@ export type ArtifactId = string & Brand.Brand<typeof ARTIFACT_ID_BRAND>;
45
45
  export type CanonicalProjectRelativePath = string & Brand.Brand<typeof CANONICAL_PROJECT_RELATIVE_PATH_BRAND>;
46
46
  /** Stable root identity; evolution is carried by the separate numeric header. */
47
47
  export declare const RECORD_FORMAT: "niceeval.record";
48
- export declare const RECORD_SCHEMA_VERSION: 1;
48
+ export declare const RECORD_SCHEMA_VERSION: 2;
49
49
  export type RecordFormat = typeof RECORD_FORMAT & Brand.Brand<typeof RECORD_FORMAT_ID_BRAND>;
50
50
  export type RecordSchemaVersion = typeof RECORD_SCHEMA_VERSION;
51
51
  /**
@@ -45,7 +45,7 @@ export type ArtifactId = string & Brand.Brand<typeof ARTIFACT_ID_BRAND>;
45
45
  export type CanonicalProjectRelativePath = string & Brand.Brand<typeof CANONICAL_PROJECT_RELATIVE_PATH_BRAND>;
46
46
  /** Stable root identity; evolution is carried by the separate numeric header. */
47
47
  export declare const RECORD_FORMAT: "niceeval.record";
48
- export declare const RECORD_SCHEMA_VERSION: 1;
48
+ export declare const RECORD_SCHEMA_VERSION: 2;
49
49
  export type RecordFormat = typeof RECORD_FORMAT & Brand.Brand<typeof RECORD_FORMAT_ID_BRAND>;
50
50
  export type RecordSchemaVersion = typeof RECORD_SCHEMA_VERSION;
51
51
  /**
@@ -4,6 +4,7 @@ exports.NodeRecordLive = exports.NodeRecordGitLive = exports.NodeRecordEntropyLi
4
4
  const node_child_process_1 = require("node:child_process");
5
5
  const node_crypto_1 = require("node:crypto");
6
6
  const promises_1 = require("node:fs/promises");
7
+ const node_fs_1 = require("node:fs");
7
8
  const node_path_1 = require("node:path");
8
9
  const effect_1 = require("effect");
9
10
  const node_ts_1 = require("../../coordination/platform/node.cjs");
@@ -14,6 +15,7 @@ const services_ts_1 = require("./services.cjs");
14
15
  const DEFAULT_STREAM_CHUNK_BYTES = 64 * 1024;
15
16
  const GIT_MAX_OUTPUT_BYTES = 1024 * 1024;
16
17
  const GIT_MAX_STATUS_ENTRIES = 10000;
18
+ const MIGRATION_SENTINEL_MAXIMUM_BYTES = 256;
17
19
  function nodeErrorCode(cause) {
18
20
  if (typeof cause !== "object" || cause === null) {
19
21
  return undefined;
@@ -203,17 +205,70 @@ function writeFileHandle(handle, bytes, path) {
203
205
  catch: (cause) => fileSystemError("write-file", path, cause),
204
206
  });
205
207
  }
206
- function openForWrite(path, mode) {
208
+ function openForWrite(path, mode, portableRoot) {
207
209
  // `wx` + 0600 + fsync is Record's create-exclusive publication primitive;
208
210
  // do not replace it with a high-level write that weakens those guarantees.
209
211
  return effect_1.Effect.tryPromise({
210
- try: () => (0, promises_1.open)(path, mode === "exclusive" ? "wx" : "w", 0o600),
211
- catch: (cause) => mode === "exclusive" && isAlreadyExistsError(cause)
212
- ? new errors_ts_1.RecordPathAlreadyExists({
213
- code: "record-path-already-exists",
214
- path,
215
- })
216
- : fileSystemError("write-file", path, cause),
212
+ try: async () => {
213
+ if (mode !== "replace-no-follow") {
214
+ return (0, promises_1.open)(path, mode === "exclusive" ? "wx" : "w", 0o600);
215
+ }
216
+ const relativePath = (0, node_path_1.relative)(portableRoot, path);
217
+ const segments = relativePath.split(node_path_1.sep);
218
+ let current = portableRoot;
219
+ const rootState = await (0, promises_1.lstat)(current);
220
+ if (!rootState.isDirectory()) {
221
+ throw new errors_ts_1.RecordPathTypeInvalid({
222
+ code: "record-path-type-invalid",
223
+ path: current,
224
+ expected: "directory",
225
+ actual: rootState.isFile() ? "file" : "other",
226
+ });
227
+ }
228
+ for (const segment of segments.slice(0, -1)) {
229
+ current = (0, node_path_1.join)(current, segment);
230
+ const state = await (0, promises_1.lstat)(current);
231
+ if (!state.isDirectory()) {
232
+ throw new errors_ts_1.RecordPathTypeInvalid({
233
+ code: "record-path-type-invalid",
234
+ path: current,
235
+ expected: "directory",
236
+ actual: state.isFile() ? "file" : "other",
237
+ });
238
+ }
239
+ }
240
+ const expected = await (0, promises_1.lstat)(path);
241
+ if (!expected.isFile() || expected.nlink !== 1) {
242
+ throw new errors_ts_1.RecordPathTypeInvalid({
243
+ code: "record-path-type-invalid",
244
+ path,
245
+ expected: "file",
246
+ actual: expected.isDirectory() ? "directory" : "other",
247
+ });
248
+ }
249
+ const handle = await (0, promises_1.open)(path, node_fs_1.constants.O_WRONLY | node_fs_1.constants.O_NOFOLLOW, 0o600);
250
+ try {
251
+ const actual = await handle.stat();
252
+ if (!actual.isFile() || actual.nlink !== 1 ||
253
+ actual.dev !== expected.dev || actual.ino !== expected.ino) {
254
+ throw new Error("record replace target identity changed before write");
255
+ }
256
+ await handle.truncate(0);
257
+ return handle;
258
+ }
259
+ catch (cause) {
260
+ await handle.close().catch(() => { });
261
+ throw cause;
262
+ }
263
+ },
264
+ catch: (cause) => isFileSystemError(cause)
265
+ ? cause
266
+ : mode === "exclusive" && isAlreadyExistsError(cause)
267
+ ? new errors_ts_1.RecordPathAlreadyExists({
268
+ code: "record-path-already-exists",
269
+ path,
270
+ })
271
+ : fileSystemError("write-file", path, cause),
217
272
  });
218
273
  }
219
274
  function writeBytesAt(input) {
@@ -224,7 +279,7 @@ function writeBytesAt(input) {
224
279
  }
225
280
  const parent = (0, node_path_1.dirname)(input.path);
226
281
  yield* ensureDirectoryAt(parent);
227
- yield* effect_1.Effect.scoped(effect_1.Effect.acquireRelease(openForWrite(input.path, input.mode), (handle) => closeHandle(handle, "write-file", input.path)).pipe(effect_1.Effect.flatMap((handle) => writeFileHandle(handle, input.bytes, input.path).pipe(effect_1.Effect.zipRight(syncHandle(handle, "sync-file", input.path))))));
282
+ yield* effect_1.Effect.scoped(effect_1.Effect.acquireRelease(openForWrite(input.path, input.mode, input.portableRoot), (handle) => closeHandle(handle, "write-file", input.path)).pipe(effect_1.Effect.flatMap((handle) => writeFileHandle(handle, input.bytes, input.path).pipe(effect_1.Effect.zipRight(syncHandle(handle, "sync-file", input.path))))));
228
283
  yield* syncDirectoryAt(parent);
229
284
  });
230
285
  }
@@ -399,18 +454,29 @@ const nodeFileSystem = {
399
454
  }
400
455
  return readStreamAt(path, input.maximumBytes, chunkBytes);
401
456
  })),
402
- writeFile: (input) => effect_1.Effect.flatMap(resolvePortablePath(input.file, true), (path) => writeBytesAt({
403
- path,
404
- bytes: input.bytes,
405
- maximumBytes: input.maximumBytes,
406
- mode: input.mode,
407
- })),
457
+ writeFile: (input) => effect_1.Effect.flatMap(resolvePortablePath(input.file, true), (path) => {
458
+ const paths = (0, root_ts_1.recordRootPaths)(input.file.root);
459
+ if (paths === undefined) {
460
+ return effect_1.Effect.fail(new errors_ts_1.RecordRootInvalid({ code: "record-root-invalid" }));
461
+ }
462
+ return writeBytesAt({
463
+ path,
464
+ portableRoot: paths.portableRoot,
465
+ bytes: input.bytes,
466
+ maximumBytes: input.maximumBytes,
467
+ mode: input.mode,
468
+ });
469
+ }),
408
470
  writeFileStream: (input) => effect_1.Effect.flatMap(resolvePortablePath(input.file, true), (path) => effect_1.Effect.gen(function* () {
471
+ const paths = (0, root_ts_1.recordRootPaths)(input.file.root);
472
+ if (paths === undefined) {
473
+ return yield* effect_1.Effect.fail(new errors_ts_1.RecordRootInvalid({ code: "record-root-invalid" }));
474
+ }
409
475
  yield* validateLimit("file-bytes", input.maximumBytes);
410
476
  const parent = (0, node_path_1.dirname)(path);
411
477
  yield* ensureDirectoryAt(parent);
412
478
  let written = 0;
413
- yield* effect_1.Effect.scoped(effect_1.Effect.acquireRelease(openForWrite(path, input.mode), (handle) => closeHandle(handle, "write-file", path)).pipe(effect_1.Effect.flatMap((handle) => {
479
+ yield* effect_1.Effect.scoped(effect_1.Effect.acquireRelease(openForWrite(path, input.mode, paths.portableRoot), (handle) => closeHandle(handle, "write-file", path)).pipe(effect_1.Effect.flatMap((handle) => {
414
480
  const writeOne = (chunk) => {
415
481
  const observedAtLeast = written + chunk.byteLength;
416
482
  if (observedAtLeast > input.maximumBytes) {
@@ -435,13 +501,37 @@ const nodeFileSystem = {
435
501
  maximumBytes: 0,
436
502
  mode: "exclusive",
437
503
  })),
504
+ isCompleteMarker: ({ root, runId }) => nodeFileSystem.readFile({
505
+ file: (0, services_ts_1.recordPortablePath)(root, "runs", runId, "complete"),
506
+ maximumBytes: 0,
507
+ }).pipe(effect_1.Effect.map((bytes) => bytes !== undefined && bytes.byteLength === 0), effect_1.Effect.catchTag("RecordResourceLimitExceeded", () => effect_1.Effect.succeed(false)), effect_1.Effect.catchTag("RecordPathTypeInvalid", () => effect_1.Effect.succeed(false))),
438
508
  migrationSentinelPresent: (root) => effect_1.Effect.map(nodeFileSystem.pathKind((0, services_ts_1.recordPortablePath)(root, "migration.in-progress")), (kind) => kind !== "missing"),
439
- createMigrationSentinel: (root) => effect_1.Effect.uninterruptible(nodeFileSystem.writeFile({
509
+ createMigrationSentinel: (root, restoreCommit) => effect_1.Effect.uninterruptible(nodeFileSystem.writeFile({
440
510
  file: (0, services_ts_1.recordPortablePath)(root, "migration.in-progress"),
441
- bytes: new Uint8Array(),
442
- maximumBytes: 0,
511
+ bytes: new TextEncoder().encode(`${JSON.stringify({ restoreCommit })}\n`),
512
+ maximumBytes: MIGRATION_SENTINEL_MAXIMUM_BYTES,
443
513
  mode: "exclusive",
444
514
  })),
515
+ readMigrationSentinelRestoreCommit: (root) => effect_1.Effect.map(nodeFileSystem.readFile({
516
+ file: (0, services_ts_1.recordPortablePath)(root, "migration.in-progress"),
517
+ maximumBytes: MIGRATION_SENTINEL_MAXIMUM_BYTES,
518
+ }), (bytes) => {
519
+ if (bytes === undefined)
520
+ return undefined;
521
+ try {
522
+ const value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
523
+ if (typeof value !== "object" || value === null || Array.isArray(value))
524
+ return undefined;
525
+ const keys = Object.keys(value);
526
+ const restoreCommit = Reflect.get(value, "restoreCommit");
527
+ return keys.length === 1 && typeof restoreCommit === "string" && /^[0-9a-f]{40,64}$/.test(restoreCommit)
528
+ ? restoreCommit
529
+ : undefined;
530
+ }
531
+ catch {
532
+ return undefined;
533
+ }
534
+ }),
445
535
  removeMigrationSentinel: (root) => effect_1.Effect.flatMap(resolvePortablePath((0, services_ts_1.recordPortablePath)(root, "migration.in-progress"), true), (path) => removeFileIfPresentAt(path, "remove-path")),
446
536
  deleteIncompleteRun: ({ root, runId }) => effect_1.Effect.gen(function* () {
447
537
  const runPath = yield* resolvePortablePath((0, services_ts_1.recordPortablePath)(root, "runs", runId), true);
@@ -457,8 +547,7 @@ const nodeFileSystem = {
457
547
  actual: runKind,
458
548
  }));
459
549
  }
460
- const completePath = yield* resolvePortablePath((0, services_ts_1.recordPortablePath)(root, "runs", runId, "complete"), true);
461
- if ((yield* pathKindAt(completePath)) !== "missing") {
550
+ if (yield* nodeFileSystem.isCompleteMarker({ root, runId })) {
462
551
  return { state: "skipped-complete" };
463
552
  }
464
553
  yield* effect_1.Effect.tryPromise({
@@ -514,7 +603,15 @@ function portablePathWithinWorktree(worktree, portableRoot) {
514
603
  }
515
604
  function statusEntries(stdout) {
516
605
  const records = stdout.split("\0").filter((entry) => entry !== "");
517
- const entries = records.map((record) => record.length > 3 ? record.slice(3) : record);
606
+ const entries = [];
607
+ for (let index = 0; index < records.length; index += 1) {
608
+ const record = records[index];
609
+ const status = record.slice(0, 2);
610
+ const path = record.length > 3 ? record.slice(3) : "";
611
+ entries.push(Object.freeze({ status, path }));
612
+ if (status.includes("R") || status.includes("C"))
613
+ index += 1;
614
+ }
518
615
  return Object.freeze(entries);
519
616
  }
520
617
  const nodeGit = {
@@ -560,7 +657,46 @@ const nodeGit = {
560
657
  }
561
658
  return entries.length === 0
562
659
  ? { state: "git-restore-point", commit }
563
- : { state: "portable-root-dirty", entries };
660
+ : {
661
+ state: "portable-root-dirty",
662
+ entries: Object.freeze(entries.map((entry) => `${entry.status} ${entry.path}`)),
663
+ };
664
+ }),
665
+ recoveryChangesAreExpected: (input) => effect_1.Effect.gen(function* () {
666
+ const paths = (0, root_ts_1.recordRootPaths)(input.root);
667
+ if (paths === undefined) {
668
+ return yield* effect_1.Effect.fail(new errors_ts_1.RecordRootInvalid({ code: "record-root-invalid" }));
669
+ }
670
+ const location = yield* effect_1.Effect.either(runGit("locate-worktree", ["rev-parse", "--show-toplevel"], (0, node_path_1.dirname)(paths.portableRoot)));
671
+ if (effect_1.Either.isLeft(location))
672
+ return false;
673
+ const worktree = location.right.stdout.trim();
674
+ const rootRelative = portablePathWithinWorktree(worktree, paths.portableRoot);
675
+ if (rootRelative === undefined)
676
+ return false;
677
+ const head = yield* runGit("read-head", ["rev-parse", "--verify", "HEAD"], worktree);
678
+ if (head.stdout.trim() !== input.restoreCommit)
679
+ return false;
680
+ const expected = new Set();
681
+ for (const path of input.expectedPaths) {
682
+ const resolved = yield* resolvePortablePath(path, true);
683
+ const relativePath = portablePathWithinWorktree(worktree, resolved);
684
+ if (relativePath === undefined)
685
+ return false;
686
+ expected.add(relativePath.split(node_path_1.sep).join("/"));
687
+ }
688
+ const status = yield* runGit("inspect-status", ["status", "--porcelain=v1", "-z", "--ignored", "--untracked-files=all", "--", rootRelative], worktree);
689
+ const entries = statusEntries(status.stdout);
690
+ if (entries.length === 0 || entries.length > GIT_MAX_STATUS_ENTRIES)
691
+ return false;
692
+ return entries.every((entry) => {
693
+ const normalized = entry.path.split(node_path_1.sep).join("/");
694
+ if (!expected.has(normalized))
695
+ return false;
696
+ return normalized.endsWith("/migration.in-progress")
697
+ ? entry.status === "??" || entry.status === "!!"
698
+ : entry.status === " M";
699
+ });
564
700
  }),
565
701
  };
566
702
  exports.NodeRecordFileSystemLive = effect_1.Layer.succeed(services_ts_1.RecordFileSystem, nodeFileSystem);
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","sourceRoot":"","sources":["node.ts"],"names":[],"mappings":";;;AAAA,2DAA8C;AAC9C,6CAAyC;AACzC,+CAA6F;AAE7F,yCAAqE;AACrE,mCAAuD;AACvD,iEAAiF;AACjF,4DAA4D;AAC5D,2CAA2W;AAC3W,uCAA4C;AAC5C,+CAA2Q;AAC3Q,MAAM,0BAA0B,GAAG,EAAE,GAAG,IAAI,CAAC;AAC7C,MAAM,oBAAoB,GAAG,IAAI,GAAG,IAAI,CAAC;AACzC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AACrC,SAAS,aAAa,CAAC,KAAc;IACjC,IAAI,OAAO,KAAK,KAA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CAAC,OAAO,CAAC,8BAAgB,EAAE,cAAc,CAAC,CAAC;AAC3E,QAAA,qBAAqB,GAAG,cAAK,CAAC,OAAO,CAAC,2BAAa,EAAE;IAC9D,IAAI,EAAE,eAAM,CAAC,IAAI,CAAC,wBAAU,CAAC;CAChC,CAAC,CAAC;AACU,QAAA,iBAAiB,GAAG,cAAK,CAAC,OAAO,CAAC,uBAAS,EAAE,OAAO,CAAC,CAAC;AACnE;;;GAGG;AACU,QAAA,cAAc,GAAG,cAAK,CAAC,QAAQ,CAAC,gCAAwB,EAAE,oCAA0B,EAAE,6BAAqB,EAAE,yBAAiB,CAAC,CAAC","sourcesContent":["import { execFile } from \"node:child_process\";\nimport { randomUUID } from \"node:crypto\";\nimport { lstat, mkdir, open, opendir, rm, unlink, type FileHandle, } from \"node:fs/promises\";\nimport type { Dir } from \"node:fs\";\nimport { dirname, isAbsolute, join, relative, sep } from \"node:path\";\nimport { Either, Effect, Layer, Stream } from \"effect\";\nimport { NodeRecordCoordinationLive } from \"../../coordination/platform/node.ts\";\nimport { isPortableSegment } from \"../model/identifiers.ts\";\nimport { RecordGitCommandError, RecordIoError, RecordPathAlreadyExists, RecordPathInvalid, RecordPathTypeInvalid, RecordPermissionError, RecordResourceLimitExceeded, RecordResourceLimitInvalid, RecordRootInvalid, type RecordFileSystemError, type RecordGitError, type RecordPathKind, type RecordPlatformOperation, type RecordPlatformResource, } from \"./errors.ts\";\nimport { recordRootPaths } from \"./root.ts\";\nimport { RecordEntropy, RecordFileSystem, RecordGit, recordPortablePath, type RecordBackupState, type RecordDirectoryEntry, type RecordFileSystemService, type RecordIncompleteRunDelete, type RecordPortablePath, type RecordWriteFileStreamInput, } from \"./services.ts\";\nconst DEFAULT_STREAM_CHUNK_BYTES = 64 * 1024;\nconst GIT_MAX_OUTPUT_BYTES = 1024 * 1024;\nconst GIT_MAX_STATUS_ENTRIES = 10000;\nfunction nodeErrorCode(cause: unknown): string | undefined {\n if (typeof cause !== \"object\" || cause === null) {\n return undefined;\n }\n const code = Reflect.get(cause, \"code\");\n return typeof code === \"string\" ? code : undefined;\n}\nfunction nodeErrorMessage(cause: unknown): string {\n if (typeof cause !== \"object\" || cause === null) {\n return \"\";\n }\n const message = Reflect.get(cause, \"message\");\n return typeof message === \"string\" ? message : \"\";\n}\nfunction isPermissionError(cause: unknown): boolean {\n const code = nodeErrorCode(cause);\n return code === \"EACCES\" || code === \"EPERM\";\n}\nfunction isMissingError(cause: unknown): boolean {\n return nodeErrorCode(cause) === \"ENOENT\";\n}\nfunction isAlreadyExistsError(cause: unknown): boolean {\n return nodeErrorCode(cause) === \"EEXIST\";\n}\nfunction fileSystemError(operation: RecordPlatformOperation, path: string, cause: unknown): RecordIoError | RecordPermissionError {\n return isPermissionError(cause)\n ? new RecordPermissionError({\n code: \"record-permission-denied\",\n operation,\n path,\n cause,\n })\n : new RecordIoError({\n code: \"record-io-error\",\n operation,\n path,\n cause,\n });\n}\nfunction isFileSystemError(cause: unknown): cause is RecordFileSystemError {\n return (cause instanceof RecordRootInvalid ||\n cause instanceof RecordPathInvalid ||\n cause instanceof RecordPathTypeInvalid ||\n cause instanceof RecordPathAlreadyExists ||\n cause instanceof RecordResourceLimitInvalid ||\n cause instanceof RecordResourceLimitExceeded ||\n cause instanceof RecordIoError ||\n cause instanceof RecordPermissionError);\n}\nfunction isFiniteNonNegativeInteger(value: number): boolean {\n return Number.isFinite(value) && Number.isInteger(value) && value >= 0;\n}\nfunction validateLimit(resource: RecordPlatformResource, maximum: number): Effect.Effect<void, RecordResourceLimitInvalid> {\n return isFiniteNonNegativeInteger(maximum)\n ? Effect.void\n : Effect.fail(new RecordResourceLimitInvalid({\n code: \"record-resource-limit-invalid\",\n resource,\n maximum,\n }));\n}\nfunction limitExceeded(resource: RecordPlatformResource, maximum: number, observedAtLeast: number, path: string): RecordResourceLimitExceeded {\n return new RecordResourceLimitExceeded({\n code: \"record-resource-limit-exceeded\",\n resource,\n maximum,\n observedAtLeast,\n path,\n });\n}\ntype PathResolutionError = RecordRootInvalid | RecordPathInvalid;\n/**\n * `recordPortablePath` is convenience data only. Every live call reaches this\n * function, so a copied or forged JS object cannot skip portable-segment\n * validation or escape the issued root.\n */\nfunction resolvePortablePath(path: RecordPortablePath, requireFilePath: boolean): Effect.Effect<string, PathResolutionError> {\n const candidate: unknown = path;\n if (typeof candidate !== \"object\" || candidate === null) {\n return Effect.fail(new RecordPathInvalid({\n code: \"record-path-invalid\",\n reason: \"segment-invalid\",\n segments: [],\n }));\n }\n const root = Reflect.get(candidate, \"root\");\n const paths = recordRootPaths(root);\n if (paths === undefined) {\n return Effect.fail(new RecordRootInvalid({ code: \"record-root-invalid\" }));\n }\n const rawSegments = Reflect.get(candidate, \"segments\");\n if (!Array.isArray(rawSegments)) {\n return Effect.fail(new RecordPathInvalid({\n code: \"record-path-invalid\",\n reason: \"segment-invalid\",\n segments: [],\n }));\n }\n const segments: string[] = [];\n for (const segment of rawSegments) {\n if (typeof segment !== \"string\" || !isPortableSegment(segment)) {\n return Effect.fail(new RecordPathInvalid({\n code: \"record-path-invalid\",\n reason: \"segment-invalid\",\n segments,\n }));\n }\n segments.push(segment);\n }\n if (requireFilePath && segments.length === 0) {\n return Effect.fail(new RecordPathInvalid({\n code: \"record-path-invalid\",\n reason: \"file-path-empty\",\n segments,\n }));\n }\n return Effect.succeed(join(paths.portableRoot, ...segments));\n}\n/**\n * Record must classify a symlink as `other` without following it. The platform\n * FileSystem service exposes following `stat` and names-only directory reads,\n * so this intentionally stays the narrow native no-follow adapter.\n */\nasync function nodePathKind(path: string): Promise<RecordPathKind> {\n try {\n const state = await lstat(path);\n if (state.isFile())\n return \"file\";\n if (state.isDirectory())\n return \"directory\";\n return \"other\";\n }\n catch (cause) {\n if (isMissingError(cause))\n return \"missing\";\n throw cause;\n }\n}\nfunction pathKindAt(path: string): Effect.Effect<RecordPathKind, RecordIoError | RecordPermissionError> {\n return Effect.tryPromise({\n try: () => nodePathKind(path),\n catch: (cause) => fileSystemError(\"read-file\", path, cause),\n });\n}\nfunction ensureDirectoryAt(path: string): Effect.Effect<void, RecordIoError | RecordPermissionError> {\n return Effect.tryPromise({\n try: async () => {\n await mkdir(path, { recursive: true });\n },\n catch: (cause) => fileSystemError(\"create-directory\", path, cause),\n }).pipe(Effect.zipRight(syncDirectoryAt(path)), Effect.zipRight(dirname(path) === path ? Effect.void : syncDirectoryAt(dirname(path))));\n}\nfunction closeHandle(handle: FileHandle, operation: RecordPlatformOperation, path: string): Effect.Effect<void> {\n return Effect.tryPromise({\n try: () => handle.close(),\n catch: (cause) => fileSystemError(operation, path, cause),\n }).pipe(Effect.orDie);\n}\nfunction syncHandle(handle: FileHandle, operation: RecordPlatformOperation, path: string): Effect.Effect<void, RecordIoError | RecordPermissionError> {\n return Effect.tryPromise({\n try: () => handle.sync(),\n catch: (cause) => fileSystemError(operation, path, cause),\n });\n}\nfunction syncDirectoryAt(path: string): Effect.Effect<void, RecordIoError | RecordPermissionError> {\n // Durable publication requires an explicit directory fsync. High-level\n // platform write helpers do not include this parent-directory commit step.\n const acquire = Effect.tryPromise({\n try: () => open(path, \"r\"),\n catch: (cause) => fileSystemError(\"sync-directory\", path, cause),\n });\n return Effect.scoped(Effect.acquireRelease(acquire, (handle) => closeHandle(handle, \"sync-directory\", path)).pipe(Effect.flatMap((handle) => syncHandle(handle, \"sync-directory\", path))));\n}\nfunction createDirectoryAt(path: string): Effect.Effect<void, RecordFileSystemError> {\n return Effect.tryPromise({\n try: () => mkdir(path),\n catch: (cause) => isAlreadyExistsError(cause)\n ? new RecordPathAlreadyExists({\n code: \"record-path-already-exists\",\n path,\n })\n : fileSystemError(\"create-directory\", path, cause),\n }).pipe(Effect.zipRight(syncDirectoryAt(dirname(path))));\n}\nfunction writeFileHandle(handle: FileHandle, bytes: Uint8Array, path: string): Effect.Effect<void, RecordIoError | RecordPermissionError> {\n return Effect.tryPromise({\n try: () => handle.writeFile(bytes),\n catch: (cause) => fileSystemError(\"write-file\", path, cause),\n });\n}\nfunction openForWrite(path: string, mode: \"exclusive\" | \"replace\"): Effect.Effect<FileHandle, RecordFileSystemError> {\n // `wx` + 0600 + fsync is Record's create-exclusive publication primitive;\n // do not replace it with a high-level write that weakens those guarantees.\n return Effect.tryPromise({\n try: () => open(path, mode === \"exclusive\" ? \"wx\" : \"w\", 0o600),\n catch: (cause) => mode === \"exclusive\" && isAlreadyExistsError(cause)\n ? new RecordPathAlreadyExists({\n code: \"record-path-already-exists\",\n path,\n })\n : fileSystemError(\"write-file\", path, cause),\n });\n}\nfunction writeBytesAt(input: {\n readonly path: string;\n readonly bytes: Uint8Array;\n readonly maximumBytes: number;\n readonly mode: \"exclusive\" | \"replace\";\n}): Effect.Effect<void, RecordFileSystemError> {\n return Effect.gen(function* () {\n yield* validateLimit(\"file-bytes\", input.maximumBytes);\n if (input.bytes.byteLength > input.maximumBytes) {\n return yield* Effect.fail(limitExceeded(\"file-bytes\", input.maximumBytes, input.bytes.byteLength, input.path));\n }\n const parent = dirname(input.path);\n yield* ensureDirectoryAt(parent);\n yield* Effect.scoped(Effect.acquireRelease(openForWrite(input.path, input.mode), (handle) => closeHandle(handle, \"write-file\", input.path)).pipe(Effect.flatMap((handle) => writeFileHandle(handle, input.bytes, input.path).pipe(Effect.zipRight(syncHandle(handle, \"sync-file\", input.path))))));\n yield* syncDirectoryAt(parent);\n });\n}\nfunction writeChunk(handle: FileHandle, bytes: Uint8Array, path: string): Effect.Effect<void, RecordIoError | RecordPermissionError> {\n return Effect.tryPromise({\n try: async () => {\n let offset = 0;\n while (offset < bytes.byteLength) {\n const written = await handle.write(bytes, offset, bytes.byteLength - offset);\n if (written.bytesWritten === 0) {\n throw new Error(\"Node wrote zero bytes before the chunk was complete\");\n }\n offset += written.bytesWritten;\n }\n },\n catch: (cause) => fileSystemError(\"write-file\", path, cause),\n });\n}\nasync function* readChunks(handle: FileHandle, path: string, maximumBytes: number, chunkBytes: number): AsyncGenerator<Uint8Array, void, undefined> {\n let observed = 0;\n for (;;) {\n // A one-byte probe after the cap distinguishes exact-size data from an\n // over-limit file without materializing its remainder.\n const capacity = observed < maximumBytes\n ? Math.min(chunkBytes, maximumBytes - observed + 1)\n : 1;\n const chunk = new Uint8Array(capacity);\n const result = await handle.read(chunk, 0, chunk.byteLength, null);\n if (result.bytesRead === 0)\n return;\n observed += result.bytesRead;\n if (observed > maximumBytes) {\n throw limitExceeded(\"file-bytes\", maximumBytes, observed, path);\n }\n yield chunk.slice(0, result.bytesRead);\n }\n}\nfunction readStreamAt(path: string, maximumBytes: number, chunkBytes: number): Stream.Stream<Uint8Array, RecordFileSystemError> {\n const acquire = Effect.tryPromise({\n try: () => open(path, \"r\"),\n catch: (cause) => fileSystemError(\"read-file\", path, cause),\n });\n return Stream.unwrapScoped(Effect.map(Effect.acquireRelease(acquire, (handle) => closeHandle(handle, \"read-file\", path)), (handle) => Stream.fromAsyncIterable(readChunks(handle, path, maximumBytes, chunkBytes), (cause) => isFileSystemError(cause)\n ? cause\n : fileSystemError(\"read-file\", path, cause))));\n}\nfunction concatChunks(chunks: readonly Uint8Array[]): Uint8Array {\n let length = 0;\n for (const chunk of chunks) {\n length += chunk.byteLength;\n }\n const result = new Uint8Array(length);\n let offset = 0;\n for (const chunk of chunks) {\n result.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return result;\n}\nfunction closeDirectory(directory: Dir, path: string): Effect.Effect<void> {\n return Effect.tryPromise({\n try: () => directory.close(),\n catch: (cause) => fileSystemError(\"list-directory\", path, cause),\n }).pipe(Effect.orDie);\n}\nasync function readDirectoryBounded(directory: Dir, maximumEntries: number, path: string): Promise<readonly RecordDirectoryEntry[]> {\n // Dirent classification preserves the same no-follow policy as lstat above;\n // the platform names-only directory API cannot supply these entry kinds.\n const entries: RecordDirectoryEntry[] = [];\n for (;;) {\n const entry = await directory.read();\n if (entry === null)\n break;\n if (entries.length === maximumEntries) {\n throw limitExceeded(\"directory-entries\", maximumEntries, maximumEntries + 1, path);\n }\n entries.push({\n name: entry.name,\n kind: entry.isFile()\n ? \"file\"\n : entry.isDirectory()\n ? \"directory\"\n : \"other\",\n });\n }\n entries.sort((left, right) => left.name === right.name ? 0 : left.name < right.name ? -1 : 1);\n return Object.freeze(entries);\n}\nfunction directoryEntriesAt(path: string, maximumEntries: number): Effect.Effect<readonly RecordDirectoryEntry[], RecordFileSystemError> {\n const acquire = Effect.tryPromise({\n try: () => opendir(path),\n catch: (cause) => fileSystemError(\"list-directory\", path, cause),\n });\n return Effect.scoped(Effect.acquireRelease(acquire, (directory) => closeDirectory(directory, path)).pipe(Effect.flatMap((directory) => Effect.tryPromise({\n try: () => readDirectoryBounded(directory, maximumEntries, path),\n catch: (cause) => isFileSystemError(cause)\n ? cause\n : fileSystemError(\"list-directory\", path, cause),\n }))));\n}\nfunction removeFileIfPresentAt(path: string, operation: \"remove-path\"): Effect.Effect<void, RecordIoError | RecordPermissionError> {\n return Effect.tryPromise({\n try: async () => {\n try {\n await unlink(path);\n }\n catch (cause) {\n if (!isMissingError(cause))\n throw cause;\n }\n },\n catch: (cause) => fileSystemError(operation, path, cause),\n }).pipe(Effect.zipRight(syncDirectoryAt(dirname(path))));\n}\nconst nodeFileSystem: RecordFileSystemService = {\n pathKind: (path) => Effect.flatMap(resolvePortablePath(path, false), (resolved) => pathKindAt(resolved)),\n ensureDirectory: (directory) => Effect.flatMap(resolvePortablePath(directory, false), (resolved) => ensureDirectoryAt(resolved)),\n createDirectory: (directory) => Effect.flatMap(resolvePortablePath(directory, true), (resolved) => createDirectoryAt(resolved)),\n listDirectory: (input) => Effect.gen(function* () {\n const path = yield* resolvePortablePath(input.directory, false);\n yield* validateLimit(\"directory-entries\", input.maximumEntries);\n const kind = yield* pathKindAt(path);\n if (kind === \"missing\")\n return Object.freeze([]) as readonly RecordDirectoryEntry[];\n if (kind !== \"directory\") {\n return yield* Effect.fail(new RecordPathTypeInvalid({\n code: \"record-path-type-invalid\",\n path,\n expected: \"directory\",\n actual: kind,\n }));\n }\n return yield* directoryEntriesAt(path, input.maximumEntries);\n }),\n readFile: (input) => Effect.gen(function* () {\n const path = yield* resolvePortablePath(input.file, true);\n yield* validateLimit(\"file-bytes\", input.maximumBytes);\n const kind = yield* pathKindAt(path);\n if (kind === \"missing\")\n return undefined;\n if (kind !== \"file\") {\n return yield* Effect.fail(new RecordPathTypeInvalid({\n code: \"record-path-type-invalid\",\n path,\n expected: \"file\",\n actual: kind,\n }));\n }\n const chunks = yield* Stream.runFold(readStreamAt(path, input.maximumBytes, DEFAULT_STREAM_CHUNK_BYTES), [] as readonly Uint8Array[], (all, chunk) => [...all, chunk]);\n return concatChunks(chunks);\n }),\n readFileStream: (input) => Stream.unwrap(Effect.gen(function* () {\n const path = yield* resolvePortablePath(input.file, true);\n yield* validateLimit(\"file-bytes\", input.maximumBytes);\n const chunkBytes = input.chunkBytes ?? DEFAULT_STREAM_CHUNK_BYTES;\n yield* validateLimit(\"file-bytes\", chunkBytes);\n if (chunkBytes === 0) {\n return yield* Effect.fail(new RecordResourceLimitInvalid({\n code: \"record-resource-limit-invalid\",\n resource: \"file-bytes\",\n maximum: chunkBytes,\n }));\n }\n const kind = yield* pathKindAt(path);\n if (kind !== \"file\") {\n return yield* Effect.fail(new RecordPathTypeInvalid({\n code: \"record-path-type-invalid\",\n path,\n expected: \"file\",\n actual: kind,\n }));\n }\n return readStreamAt(path, input.maximumBytes, chunkBytes);\n })),\n writeFile: (input) => Effect.flatMap(resolvePortablePath(input.file, true), (path) => writeBytesAt({\n path,\n bytes: input.bytes,\n maximumBytes: input.maximumBytes,\n mode: input.mode,\n })),\n writeFileStream: <E, R>(input: RecordWriteFileStreamInput<E, R>): Effect.Effect<void, RecordFileSystemError | E, R> => Effect.flatMap(resolvePortablePath(input.file, true), (path) => Effect.gen(function* () {\n yield* validateLimit(\"file-bytes\", input.maximumBytes);\n const parent = dirname(path);\n yield* ensureDirectoryAt(parent);\n let written = 0;\n yield* Effect.scoped(Effect.acquireRelease(openForWrite(path, input.mode), (handle) => closeHandle(handle, \"write-file\", path)).pipe(Effect.flatMap((handle) => {\n const writeOne = (chunk: Uint8Array): Effect.Effect<void, RecordFileSystemError> => {\n const observedAtLeast = written + chunk.byteLength;\n if (observedAtLeast > input.maximumBytes) {\n return Effect.fail(limitExceeded(\"file-bytes\", input.maximumBytes, observedAtLeast, path));\n }\n return writeChunk(handle, chunk, path).pipe(Effect.tap(() => Effect.sync(() => {\n written = observedAtLeast;\n })));\n };\n return Stream.runForEach(input.stream, writeOne).pipe(Effect.zipRight(syncHandle(handle, \"sync-file\", path)));\n })));\n yield* syncDirectoryAt(parent);\n })),\n syncDirectory: (directory) => Effect.flatMap(resolvePortablePath(directory, false), (path) => syncDirectoryAt(path)),\n createRunDirectory: ({ root, runId }) => Effect.gen(function* () {\n yield* nodeFileSystem.ensureDirectory(recordPortablePath(root, \"runs\"));\n yield* nodeFileSystem.createDirectory(recordPortablePath(root, \"runs\", runId));\n }),\n createCompleteMarker: ({ root, runId }) => Effect.uninterruptible(nodeFileSystem.writeFile({\n file: recordPortablePath(root, \"runs\", runId, \"complete\"),\n bytes: new Uint8Array(),\n maximumBytes: 0,\n mode: \"exclusive\",\n })),\n migrationSentinelPresent: (root) => Effect.map(nodeFileSystem.pathKind(recordPortablePath(root, \"migration.in-progress\")), (kind) => kind !== \"missing\"),\n createMigrationSentinel: (root) => Effect.uninterruptible(nodeFileSystem.writeFile({\n file: recordPortablePath(root, \"migration.in-progress\"),\n bytes: new Uint8Array(),\n maximumBytes: 0,\n mode: \"exclusive\",\n })),\n removeMigrationSentinel: (root) => Effect.flatMap(resolvePortablePath(recordPortablePath(root, \"migration.in-progress\"), true), (path) => removeFileIfPresentAt(path, \"remove-path\")),\n deleteIncompleteRun: ({ root, runId }) => Effect.gen(function* () {\n const runPath = yield* resolvePortablePath(recordPortablePath(root, \"runs\", runId), true);\n const runKind = yield* pathKindAt(runPath);\n if (runKind === \"missing\") {\n return { state: \"missing\" } satisfies RecordIncompleteRunDelete;\n }\n if (runKind !== \"directory\") {\n return yield* Effect.fail(new RecordPathTypeInvalid({\n code: \"record-path-type-invalid\",\n path: runPath,\n expected: \"directory\",\n actual: runKind,\n }));\n }\n const completePath = yield* resolvePortablePath(recordPortablePath(root, \"runs\", runId, \"complete\"), true);\n if ((yield* pathKindAt(completePath)) !== \"missing\") {\n return { state: \"skipped-complete\" } satisfies RecordIncompleteRunDelete;\n }\n yield* Effect.tryPromise({\n try: () => rm(runPath, { recursive: true, force: true }),\n catch: (cause) => fileSystemError(\"remove-path\", runPath, cause),\n });\n yield* syncDirectoryAt(dirname(runPath));\n return { state: \"deleted\" } satisfies RecordIncompleteRunDelete;\n }),\n};\ninterface GitOutput {\n readonly stdout: string;\n readonly stderr: string;\n}\nfunction executeGit(args: readonly string[], cwd: string, signal: AbortSignal): Promise<GitOutput> {\n // Keep the native adapter: Record requires one bounded collection covering\n // stdout and stderr, exact argv execution, and AbortSignal cancellation.\n // CommandExecutor has no single primitive with all of those guarantees.\n return new Promise((resolve, reject) => {\n execFile(\"git\", [...args], { cwd, encoding: \"utf8\", maxBuffer: GIT_MAX_OUTPUT_BYTES, signal }, (error, stdout, stderr) => {\n if (error !== null) {\n reject(error);\n return;\n }\n resolve({ stdout: String(stdout), stderr: String(stderr) });\n });\n });\n}\nfunction gitError(operation: \"locate-worktree\" | \"read-head\" | \"inspect-status\", cause: unknown): RecordGitError {\n if (nodeErrorCode(cause) === \"ERR_CHILD_PROCESS_STDIO_MAXBUFFER\") {\n return limitExceeded(\"git-output\", GIT_MAX_OUTPUT_BYTES, GIT_MAX_OUTPUT_BYTES, \"git\");\n }\n return new RecordGitCommandError({\n code: \"record-git-command-failed\",\n operation,\n cause,\n });\n}\nfunction runGit(operation: \"locate-worktree\" | \"read-head\" | \"inspect-status\", args: readonly string[], cwd: string): Effect.Effect<GitOutput, RecordGitError> {\n return Effect.tryPromise({\n try: (signal) => executeGit(args, cwd, signal),\n catch: (cause) => gitError(operation, cause),\n });\n}\nfunction isNotGitWorktree(error: RecordGitCommandError): boolean {\n const code = nodeErrorCode(error.cause);\n return code === \"ENOENT\" || nodeErrorMessage(error.cause).includes(\"not a git repository\");\n}\nfunction portablePathWithinWorktree(worktree: string, portableRoot: string): string | undefined {\n const rootRelative = relative(worktree, portableRoot);\n if (rootRelative === \"..\" ||\n rootRelative.startsWith(`..${sep}`) ||\n isAbsolute(rootRelative)) {\n return undefined;\n }\n return rootRelative === \"\" ? \".\" : rootRelative;\n}\nfunction statusEntries(stdout: string): readonly string[] {\n const records = stdout.split(\"\\0\").filter((entry) => entry !== \"\");\n const entries = records.map((record) => record.length > 3 ? record.slice(3) : record);\n return Object.freeze(entries);\n}\nconst nodeGit = {\n inspectBackupState: (root: unknown): Effect.Effect<RecordBackupState, RecordGitError> => Effect.gen(function* () {\n const paths = recordRootPaths(root);\n if (paths === undefined) {\n return yield* Effect.fail(new RecordRootInvalid({ code: \"record-root-invalid\" }));\n }\n const location = yield* Effect.either(runGit(\"locate-worktree\", [\"rev-parse\", \"--show-toplevel\"], dirname(paths.portableRoot)));\n if (Either.isLeft(location)) {\n if (location.left instanceof RecordGitCommandError &&\n isNotGitWorktree(location.left)) {\n return { state: \"not-git-worktree\" } satisfies RecordBackupState;\n }\n return yield* Effect.fail(location.left);\n }\n const worktree = location.right.stdout.trim();\n const rootRelative = portablePathWithinWorktree(worktree, paths.portableRoot);\n if (rootRelative === undefined) {\n return { state: \"root-outside-worktree\" } satisfies RecordBackupState;\n }\n const head = yield* runGit(\"read-head\", [\"rev-parse\", \"--verify\", \"HEAD\"], worktree);\n const commit = head.stdout.trim();\n if (commit === \"\") {\n return yield* Effect.fail(new RecordGitCommandError({\n code: \"record-git-command-failed\",\n operation: \"read-head\",\n cause: new Error(\"git returned an empty HEAD\"),\n }));\n }\n const status = yield* runGit(\"inspect-status\", [\n \"status\",\n \"--porcelain=v1\",\n \"-z\",\n \"--ignored\",\n \"--untracked-files=all\",\n \"--\",\n rootRelative,\n ], worktree);\n const entries = statusEntries(status.stdout);\n if (entries.length > GIT_MAX_STATUS_ENTRIES) {\n return yield* Effect.fail(limitExceeded(\"git-output\", GIT_MAX_STATUS_ENTRIES, GIT_MAX_STATUS_ENTRIES + 1, \"git status\"));\n }\n return entries.length === 0\n ? ({ state: \"git-restore-point\", commit } satisfies RecordBackupState)\n : ({ state: \"portable-root-dirty\", entries } satisfies RecordBackupState);\n }),\n};\nexport const NodeRecordFileSystemLive = Layer.succeed(RecordFileSystem, nodeFileSystem);\nexport const NodeRecordEntropyLive = Layer.succeed(RecordEntropy, {\n uuid: Effect.sync(randomUUID),\n});\nexport const NodeRecordGitLive = Layer.succeed(RecordGit, nodeGit);\n/**\n * Convenience composition for an application boundary. Consumers still name\n * only the Tags they need in their own Effect requirements.\n */\nexport const NodeRecordLive = Layer.mergeAll(NodeRecordFileSystemLive, NodeRecordCoordinationLive, NodeRecordEntropyLive, NodeRecordGitLive);\n"]}
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["node.ts"],"names":[],"mappings":";;;AAAA,2DAA8C;AAC9C,6CAAyC;AACzC,+CAA6F;AAC7F,qCAA8C;AAC9C,yCAAqE;AACrE,mCAAuD;AACvD,iEAAiF;AACjF,4DAA4D;AAC5D,2CAA2W;AAC3W,uCAA4C;AAC5C,+CAA2Q;AAC3Q,MAAM,0BAA0B,GAAG,EAAE,GAAG,IAAI,CAAC;AAC7C,MAAM,oBAAoB,GAAG,IAAI,GAAG,IAAI,CAAC;AACzC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AACrC,MAAM,gCAAgC,GAAG,GAAG,CAAC;AAC7C,SAAS,aAAa,CAAC,KAAc;IACjC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC9C,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACxC,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,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CAAC;AACU,QAAA,iBAAiB,GAAG,cAAK,CAAC,OAAO,CAAC,uBAAS,EAAE,OAAO,CAAC,CAAC;AACnE;;;GAGG;AACU,QAAA,cAAc,GAAG,cAAK,CAAC,QAAQ,CAAC,gCAAwB,EAAE,oCAA0B,EAAE,6BAAqB,EAAE,yBAAiB,CAAC,CAAC","sourcesContent":["import { execFile } from \"node:child_process\";\nimport { randomUUID } from \"node:crypto\";\nimport { lstat, mkdir, open, opendir, rm, unlink, type FileHandle, } from \"node:fs/promises\";\nimport { constants, type Dir } from \"node:fs\";\nimport { dirname, isAbsolute, join, relative, sep } from \"node:path\";\nimport { Either, Effect, Layer, Stream } from \"effect\";\nimport { NodeRecordCoordinationLive } from \"../../coordination/platform/node.ts\";\nimport { isPortableSegment } from \"../model/identifiers.ts\";\nimport { RecordGitCommandError, RecordIoError, RecordPathAlreadyExists, RecordPathInvalid, RecordPathTypeInvalid, RecordPermissionError, RecordResourceLimitExceeded, RecordResourceLimitInvalid, RecordRootInvalid, type RecordFileSystemError, type RecordGitError, type RecordPathKind, type RecordPlatformOperation, type RecordPlatformResource, } from \"./errors.ts\";\nimport { recordRootPaths } from \"./root.ts\";\nimport { RecordEntropy, RecordFileSystem, RecordGit, recordPortablePath, type RecordBackupState, type RecordDirectoryEntry, type RecordFileSystemService, type RecordIncompleteRunDelete, type RecordPortablePath, type RecordWriteFileStreamInput, } from \"./services.ts\";\nconst DEFAULT_STREAM_CHUNK_BYTES = 64 * 1024;\nconst GIT_MAX_OUTPUT_BYTES = 1024 * 1024;\nconst GIT_MAX_STATUS_ENTRIES = 10000;\nconst MIGRATION_SENTINEL_MAXIMUM_BYTES = 256;\nfunction nodeErrorCode(cause: unknown): string | undefined {\n if (typeof cause !== \"object\" || cause === null) {\n return undefined;\n }\n const code = Reflect.get(cause, \"code\");\n return typeof code === \"string\" ? code : undefined;\n}\nfunction nodeErrorMessage(cause: unknown): string {\n if (typeof cause !== \"object\" || cause === null) {\n return \"\";\n }\n const message = Reflect.get(cause, \"message\");\n return typeof message === \"string\" ? message : \"\";\n}\nfunction isPermissionError(cause: unknown): boolean {\n const code = nodeErrorCode(cause);\n return code === \"EACCES\" || code === \"EPERM\";\n}\nfunction isMissingError(cause: unknown): boolean {\n return nodeErrorCode(cause) === \"ENOENT\";\n}\nfunction isAlreadyExistsError(cause: unknown): boolean {\n return nodeErrorCode(cause) === \"EEXIST\";\n}\nfunction fileSystemError(operation: RecordPlatformOperation, path: string, cause: unknown): RecordIoError | RecordPermissionError {\n return isPermissionError(cause)\n ? new RecordPermissionError({\n code: \"record-permission-denied\",\n operation,\n path,\n cause,\n })\n : new RecordIoError({\n code: \"record-io-error\",\n operation,\n path,\n cause,\n });\n}\nfunction isFileSystemError(cause: unknown): cause is RecordFileSystemError {\n return (cause instanceof RecordRootInvalid ||\n cause instanceof RecordPathInvalid ||\n cause instanceof RecordPathTypeInvalid ||\n cause instanceof RecordPathAlreadyExists ||\n cause instanceof RecordResourceLimitInvalid ||\n cause instanceof RecordResourceLimitExceeded ||\n cause instanceof RecordIoError ||\n cause instanceof RecordPermissionError);\n}\nfunction isFiniteNonNegativeInteger(value: number): boolean {\n return Number.isFinite(value) && Number.isInteger(value) && value >= 0;\n}\nfunction validateLimit(resource: RecordPlatformResource, maximum: number): Effect.Effect<void, RecordResourceLimitInvalid> {\n return isFiniteNonNegativeInteger(maximum)\n ? Effect.void\n : Effect.fail(new RecordResourceLimitInvalid({\n code: \"record-resource-limit-invalid\",\n resource,\n maximum,\n }));\n}\nfunction limitExceeded(resource: RecordPlatformResource, maximum: number, observedAtLeast: number, path: string): RecordResourceLimitExceeded {\n return new RecordResourceLimitExceeded({\n code: \"record-resource-limit-exceeded\",\n resource,\n maximum,\n observedAtLeast,\n path,\n });\n}\ntype PathResolutionError = RecordRootInvalid | RecordPathInvalid;\n/**\n * `recordPortablePath` is convenience data only. Every live call reaches this\n * function, so a copied or forged JS object cannot skip portable-segment\n * validation or escape the issued root.\n */\nfunction resolvePortablePath(path: RecordPortablePath, requireFilePath: boolean): Effect.Effect<string, PathResolutionError> {\n const candidate: unknown = path;\n if (typeof candidate !== \"object\" || candidate === null) {\n return Effect.fail(new RecordPathInvalid({\n code: \"record-path-invalid\",\n reason: \"segment-invalid\",\n segments: [],\n }));\n }\n const root = Reflect.get(candidate, \"root\");\n const paths = recordRootPaths(root);\n if (paths === undefined) {\n return Effect.fail(new RecordRootInvalid({ code: \"record-root-invalid\" }));\n }\n const rawSegments = Reflect.get(candidate, \"segments\");\n if (!Array.isArray(rawSegments)) {\n return Effect.fail(new RecordPathInvalid({\n code: \"record-path-invalid\",\n reason: \"segment-invalid\",\n segments: [],\n }));\n }\n const segments: string[] = [];\n for (const segment of rawSegments) {\n if (typeof segment !== \"string\" || !isPortableSegment(segment)) {\n return Effect.fail(new RecordPathInvalid({\n code: \"record-path-invalid\",\n reason: \"segment-invalid\",\n segments,\n }));\n }\n segments.push(segment);\n }\n if (requireFilePath && segments.length === 0) {\n return Effect.fail(new RecordPathInvalid({\n code: \"record-path-invalid\",\n reason: \"file-path-empty\",\n segments,\n }));\n }\n return Effect.succeed(join(paths.portableRoot, ...segments));\n}\n/**\n * Record must classify a symlink as `other` without following it. The platform\n * FileSystem service exposes following `stat` and names-only directory reads,\n * so this intentionally stays the narrow native no-follow adapter.\n */\nasync function nodePathKind(path: string): Promise<RecordPathKind> {\n try {\n const state = await lstat(path);\n if (state.isFile())\n return \"file\";\n if (state.isDirectory())\n return \"directory\";\n return \"other\";\n }\n catch (cause) {\n if (isMissingError(cause))\n return \"missing\";\n throw cause;\n }\n}\nfunction pathKindAt(path: string): Effect.Effect<RecordPathKind, RecordIoError | RecordPermissionError> {\n return Effect.tryPromise({\n try: () => nodePathKind(path),\n catch: (cause) => fileSystemError(\"read-file\", path, cause),\n });\n}\nfunction ensureDirectoryAt(path: string): Effect.Effect<void, RecordIoError | RecordPermissionError> {\n return Effect.tryPromise({\n try: async () => {\n await mkdir(path, { recursive: true });\n },\n catch: (cause) => fileSystemError(\"create-directory\", path, cause),\n }).pipe(Effect.zipRight(syncDirectoryAt(path)), Effect.zipRight(dirname(path) === path ? Effect.void : syncDirectoryAt(dirname(path))));\n}\nfunction closeHandle(handle: FileHandle, operation: RecordPlatformOperation, path: string): Effect.Effect<void> {\n return Effect.tryPromise({\n try: () => handle.close(),\n catch: (cause) => fileSystemError(operation, path, cause),\n }).pipe(Effect.orDie);\n}\nfunction syncHandle(handle: FileHandle, operation: RecordPlatformOperation, path: string): Effect.Effect<void, RecordIoError | RecordPermissionError> {\n return Effect.tryPromise({\n try: () => handle.sync(),\n catch: (cause) => fileSystemError(operation, path, cause),\n });\n}\nfunction syncDirectoryAt(path: string): Effect.Effect<void, RecordIoError | RecordPermissionError> {\n // Durable publication requires an explicit directory fsync. High-level\n // platform write helpers do not include this parent-directory commit step.\n const acquire = Effect.tryPromise({\n try: () => open(path, \"r\"),\n catch: (cause) => fileSystemError(\"sync-directory\", path, cause),\n });\n return Effect.scoped(Effect.acquireRelease(acquire, (handle) => closeHandle(handle, \"sync-directory\", path)).pipe(Effect.flatMap((handle) => syncHandle(handle, \"sync-directory\", path))));\n}\nfunction createDirectoryAt(path: string): Effect.Effect<void, RecordFileSystemError> {\n return Effect.tryPromise({\n try: () => mkdir(path),\n catch: (cause) => isAlreadyExistsError(cause)\n ? new RecordPathAlreadyExists({\n code: \"record-path-already-exists\",\n path,\n })\n : fileSystemError(\"create-directory\", path, cause),\n }).pipe(Effect.zipRight(syncDirectoryAt(dirname(path))));\n}\nfunction writeFileHandle(handle: FileHandle, bytes: Uint8Array, path: string): Effect.Effect<void, RecordIoError | RecordPermissionError> {\n return Effect.tryPromise({\n try: () => handle.writeFile(bytes),\n catch: (cause) => fileSystemError(\"write-file\", path, cause),\n });\n}\nfunction openForWrite(path: string, mode: \"exclusive\" | \"replace\" | \"replace-no-follow\", portableRoot: string): Effect.Effect<FileHandle, RecordFileSystemError> {\n // `wx` + 0600 + fsync is Record's create-exclusive publication primitive;\n // do not replace it with a high-level write that weakens those guarantees.\n return Effect.tryPromise({\n try: async () => {\n if (mode !== \"replace-no-follow\") {\n return open(path, mode === \"exclusive\" ? \"wx\" : \"w\", 0o600);\n }\n const relativePath = relative(portableRoot, path);\n const segments = relativePath.split(sep);\n let current = portableRoot;\n const rootState = await lstat(current);\n if (!rootState.isDirectory()) {\n throw new RecordPathTypeInvalid({\n code: \"record-path-type-invalid\",\n path: current,\n expected: \"directory\",\n actual: rootState.isFile() ? \"file\" : \"other\",\n });\n }\n for (const segment of segments.slice(0, -1)) {\n current = join(current, segment);\n const state = await lstat(current);\n if (!state.isDirectory()) {\n throw new RecordPathTypeInvalid({\n code: \"record-path-type-invalid\",\n path: current,\n expected: \"directory\",\n actual: state.isFile() ? \"file\" : \"other\",\n });\n }\n }\n const expected = await lstat(path);\n if (!expected.isFile() || expected.nlink !== 1) {\n throw new RecordPathTypeInvalid({\n code: \"record-path-type-invalid\",\n path,\n expected: \"file\",\n actual: expected.isDirectory() ? \"directory\" : \"other\",\n });\n }\n const handle = await open(path, constants.O_WRONLY | constants.O_NOFOLLOW, 0o600);\n try {\n const actual = await handle.stat();\n if (!actual.isFile() || actual.nlink !== 1 ||\n actual.dev !== expected.dev || actual.ino !== expected.ino) {\n throw new Error(\"record replace target identity changed before write\");\n }\n await handle.truncate(0);\n return handle;\n }\n catch (cause) {\n await handle.close().catch(() => { });\n throw cause;\n }\n },\n catch: (cause) => isFileSystemError(cause)\n ? cause\n : mode === \"exclusive\" && isAlreadyExistsError(cause)\n ? new RecordPathAlreadyExists({\n code: \"record-path-already-exists\",\n path,\n })\n : fileSystemError(\"write-file\", path, cause),\n });\n}\nfunction writeBytesAt(input: {\n readonly path: string;\n readonly bytes: Uint8Array;\n readonly maximumBytes: number;\n readonly mode: \"exclusive\" | \"replace\" | \"replace-no-follow\";\n readonly portableRoot: string;\n}): Effect.Effect<void, RecordFileSystemError> {\n return Effect.gen(function* () {\n yield* validateLimit(\"file-bytes\", input.maximumBytes);\n if (input.bytes.byteLength > input.maximumBytes) {\n return yield* Effect.fail(limitExceeded(\"file-bytes\", input.maximumBytes, input.bytes.byteLength, input.path));\n }\n const parent = dirname(input.path);\n yield* ensureDirectoryAt(parent);\n yield* Effect.scoped(Effect.acquireRelease(openForWrite(input.path, input.mode, input.portableRoot), (handle) => closeHandle(handle, \"write-file\", input.path)).pipe(Effect.flatMap((handle) => writeFileHandle(handle, input.bytes, input.path).pipe(Effect.zipRight(syncHandle(handle, \"sync-file\", input.path))))));\n yield* syncDirectoryAt(parent);\n });\n}\nfunction writeChunk(handle: FileHandle, bytes: Uint8Array, path: string): Effect.Effect<void, RecordIoError | RecordPermissionError> {\n return Effect.tryPromise({\n try: async () => {\n let offset = 0;\n while (offset < bytes.byteLength) {\n const written = await handle.write(bytes, offset, bytes.byteLength - offset);\n if (written.bytesWritten === 0) {\n throw new Error(\"Node wrote zero bytes before the chunk was complete\");\n }\n offset += written.bytesWritten;\n }\n },\n catch: (cause) => fileSystemError(\"write-file\", path, cause),\n });\n}\nasync function* readChunks(handle: FileHandle, path: string, maximumBytes: number, chunkBytes: number): AsyncGenerator<Uint8Array, void, undefined> {\n let observed = 0;\n for (;;) {\n // A one-byte probe after the cap distinguishes exact-size data from an\n // over-limit file without materializing its remainder.\n const capacity = observed < maximumBytes\n ? Math.min(chunkBytes, maximumBytes - observed + 1)\n : 1;\n const chunk = new Uint8Array(capacity);\n const result = await handle.read(chunk, 0, chunk.byteLength, null);\n if (result.bytesRead === 0)\n return;\n observed += result.bytesRead;\n if (observed > maximumBytes) {\n throw limitExceeded(\"file-bytes\", maximumBytes, observed, path);\n }\n yield chunk.slice(0, result.bytesRead);\n }\n}\nfunction readStreamAt(path: string, maximumBytes: number, chunkBytes: number): Stream.Stream<Uint8Array, RecordFileSystemError> {\n const acquire = Effect.tryPromise({\n try: () => open(path, \"r\"),\n catch: (cause) => fileSystemError(\"read-file\", path, cause),\n });\n return Stream.unwrapScoped(Effect.map(Effect.acquireRelease(acquire, (handle) => closeHandle(handle, \"read-file\", path)), (handle) => Stream.fromAsyncIterable(readChunks(handle, path, maximumBytes, chunkBytes), (cause) => isFileSystemError(cause)\n ? cause\n : fileSystemError(\"read-file\", path, cause))));\n}\nfunction concatChunks(chunks: readonly Uint8Array[]): Uint8Array {\n let length = 0;\n for (const chunk of chunks) {\n length += chunk.byteLength;\n }\n const result = new Uint8Array(length);\n let offset = 0;\n for (const chunk of chunks) {\n result.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return result;\n}\nfunction closeDirectory(directory: Dir, path: string): Effect.Effect<void> {\n return Effect.tryPromise({\n try: () => directory.close(),\n catch: (cause) => fileSystemError(\"list-directory\", path, cause),\n }).pipe(Effect.orDie);\n}\nasync function readDirectoryBounded(directory: Dir, maximumEntries: number, path: string): Promise<readonly RecordDirectoryEntry[]> {\n // Dirent classification preserves the same no-follow policy as lstat above;\n // the platform names-only directory API cannot supply these entry kinds.\n const entries: RecordDirectoryEntry[] = [];\n for (;;) {\n const entry = await directory.read();\n if (entry === null)\n break;\n if (entries.length === maximumEntries) {\n throw limitExceeded(\"directory-entries\", maximumEntries, maximumEntries + 1, path);\n }\n entries.push({\n name: entry.name,\n kind: entry.isFile()\n ? \"file\"\n : entry.isDirectory()\n ? \"directory\"\n : \"other\",\n });\n }\n entries.sort((left, right) => left.name === right.name ? 0 : left.name < right.name ? -1 : 1);\n return Object.freeze(entries);\n}\nfunction directoryEntriesAt(path: string, maximumEntries: number): Effect.Effect<readonly RecordDirectoryEntry[], RecordFileSystemError> {\n const acquire = Effect.tryPromise({\n try: () => opendir(path),\n catch: (cause) => fileSystemError(\"list-directory\", path, cause),\n });\n return Effect.scoped(Effect.acquireRelease(acquire, (directory) => closeDirectory(directory, path)).pipe(Effect.flatMap((directory) => Effect.tryPromise({\n try: () => readDirectoryBounded(directory, maximumEntries, path),\n catch: (cause) => isFileSystemError(cause)\n ? cause\n : fileSystemError(\"list-directory\", path, cause),\n }))));\n}\nfunction removeFileIfPresentAt(path: string, operation: \"remove-path\"): Effect.Effect<void, RecordIoError | RecordPermissionError> {\n return Effect.tryPromise({\n try: async () => {\n try {\n await unlink(path);\n }\n catch (cause) {\n if (!isMissingError(cause))\n throw cause;\n }\n },\n catch: (cause) => fileSystemError(operation, path, cause),\n }).pipe(Effect.zipRight(syncDirectoryAt(dirname(path))));\n}\nconst nodeFileSystem: RecordFileSystemService = {\n pathKind: (path) => Effect.flatMap(resolvePortablePath(path, false), (resolved) => pathKindAt(resolved)),\n ensureDirectory: (directory) => Effect.flatMap(resolvePortablePath(directory, false), (resolved) => ensureDirectoryAt(resolved)),\n createDirectory: (directory) => Effect.flatMap(resolvePortablePath(directory, true), (resolved) => createDirectoryAt(resolved)),\n listDirectory: (input) => Effect.gen(function* () {\n const path = yield* resolvePortablePath(input.directory, false);\n yield* validateLimit(\"directory-entries\", input.maximumEntries);\n const kind = yield* pathKindAt(path);\n if (kind === \"missing\")\n return Object.freeze([]) as readonly RecordDirectoryEntry[];\n if (kind !== \"directory\") {\n return yield* Effect.fail(new RecordPathTypeInvalid({\n code: \"record-path-type-invalid\",\n path,\n expected: \"directory\",\n actual: kind,\n }));\n }\n return yield* directoryEntriesAt(path, input.maximumEntries);\n }),\n readFile: (input) => Effect.gen(function* () {\n const path = yield* resolvePortablePath(input.file, true);\n yield* validateLimit(\"file-bytes\", input.maximumBytes);\n const kind = yield* pathKindAt(path);\n if (kind === \"missing\")\n return undefined;\n if (kind !== \"file\") {\n return yield* Effect.fail(new RecordPathTypeInvalid({\n code: \"record-path-type-invalid\",\n path,\n expected: \"file\",\n actual: kind,\n }));\n }\n const chunks = yield* Stream.runFold(readStreamAt(path, input.maximumBytes, DEFAULT_STREAM_CHUNK_BYTES), [] as readonly Uint8Array[], (all, chunk) => [...all, chunk]);\n return concatChunks(chunks);\n }),\n readFileStream: (input) => Stream.unwrap(Effect.gen(function* () {\n const path = yield* resolvePortablePath(input.file, true);\n yield* validateLimit(\"file-bytes\", input.maximumBytes);\n const chunkBytes = input.chunkBytes ?? DEFAULT_STREAM_CHUNK_BYTES;\n yield* validateLimit(\"file-bytes\", chunkBytes);\n if (chunkBytes === 0) {\n return yield* Effect.fail(new RecordResourceLimitInvalid({\n code: \"record-resource-limit-invalid\",\n resource: \"file-bytes\",\n maximum: chunkBytes,\n }));\n }\n const kind = yield* pathKindAt(path);\n if (kind !== \"file\") {\n return yield* Effect.fail(new RecordPathTypeInvalid({\n code: \"record-path-type-invalid\",\n path,\n expected: \"file\",\n actual: kind,\n }));\n }\n return readStreamAt(path, input.maximumBytes, chunkBytes);\n })),\n writeFile: (input) => Effect.flatMap(resolvePortablePath(input.file, true), (path) => {\n const paths = recordRootPaths(input.file.root);\n if (paths === undefined) {\n return Effect.fail(new RecordRootInvalid({ code: \"record-root-invalid\" }));\n }\n return writeBytesAt({\n path,\n portableRoot: paths.portableRoot,\n bytes: input.bytes,\n maximumBytes: input.maximumBytes,\n mode: input.mode,\n });\n }),\n writeFileStream: <E, R>(input: RecordWriteFileStreamInput<E, R>): Effect.Effect<void, RecordFileSystemError | E, R> => Effect.flatMap(resolvePortablePath(input.file, true), (path) => Effect.gen(function* () {\n const paths = recordRootPaths(input.file.root);\n if (paths === undefined) {\n return yield* Effect.fail(new RecordRootInvalid({ code: \"record-root-invalid\" }));\n }\n yield* validateLimit(\"file-bytes\", input.maximumBytes);\n const parent = dirname(path);\n yield* ensureDirectoryAt(parent);\n let written = 0;\n yield* Effect.scoped(Effect.acquireRelease(openForWrite(path, input.mode, paths.portableRoot), (handle) => closeHandle(handle, \"write-file\", path)).pipe(Effect.flatMap((handle) => {\n const writeOne = (chunk: Uint8Array): Effect.Effect<void, RecordFileSystemError> => {\n const observedAtLeast = written + chunk.byteLength;\n if (observedAtLeast > input.maximumBytes) {\n return Effect.fail(limitExceeded(\"file-bytes\", input.maximumBytes, observedAtLeast, path));\n }\n return writeChunk(handle, chunk, path).pipe(Effect.tap(() => Effect.sync(() => {\n written = observedAtLeast;\n })));\n };\n return Stream.runForEach(input.stream, writeOne).pipe(Effect.zipRight(syncHandle(handle, \"sync-file\", path)));\n })));\n yield* syncDirectoryAt(parent);\n })),\n syncDirectory: (directory) => Effect.flatMap(resolvePortablePath(directory, false), (path) => syncDirectoryAt(path)),\n createRunDirectory: ({ root, runId }) => Effect.gen(function* () {\n yield* nodeFileSystem.ensureDirectory(recordPortablePath(root, \"runs\"));\n yield* nodeFileSystem.createDirectory(recordPortablePath(root, \"runs\", runId));\n }),\n createCompleteMarker: ({ root, runId }) => Effect.uninterruptible(nodeFileSystem.writeFile({\n file: recordPortablePath(root, \"runs\", runId, \"complete\"),\n bytes: new Uint8Array(),\n maximumBytes: 0,\n mode: \"exclusive\",\n })),\n isCompleteMarker: ({ root, runId }) => nodeFileSystem.readFile({\n file: recordPortablePath(root, \"runs\", runId, \"complete\"),\n maximumBytes: 0,\n }).pipe(Effect.map((bytes) => bytes !== undefined && bytes.byteLength === 0), Effect.catchTag(\"RecordResourceLimitExceeded\", () => Effect.succeed(false)), Effect.catchTag(\"RecordPathTypeInvalid\", () => Effect.succeed(false))),\n migrationSentinelPresent: (root) => Effect.map(nodeFileSystem.pathKind(recordPortablePath(root, \"migration.in-progress\")), (kind) => kind !== \"missing\"),\n createMigrationSentinel: (root, restoreCommit) => Effect.uninterruptible(nodeFileSystem.writeFile({\n file: recordPortablePath(root, \"migration.in-progress\"),\n bytes: new TextEncoder().encode(`${JSON.stringify({ restoreCommit })}\\n`),\n maximumBytes: MIGRATION_SENTINEL_MAXIMUM_BYTES,\n mode: \"exclusive\",\n })),\n readMigrationSentinelRestoreCommit: (root) => Effect.map(nodeFileSystem.readFile({\n file: recordPortablePath(root, \"migration.in-progress\"),\n maximumBytes: MIGRATION_SENTINEL_MAXIMUM_BYTES,\n }), (bytes) => {\n if (bytes === undefined)\n return undefined;\n try {\n const value: unknown = JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes));\n if (typeof value !== \"object\" || value === null || Array.isArray(value))\n return undefined;\n const keys = Object.keys(value);\n const restoreCommit = Reflect.get(value, \"restoreCommit\");\n return keys.length === 1 && typeof restoreCommit === \"string\" && /^[0-9a-f]{40,64}$/.test(restoreCommit)\n ? restoreCommit\n : undefined;\n }\n catch {\n return undefined;\n }\n }),\n removeMigrationSentinel: (root) => Effect.flatMap(resolvePortablePath(recordPortablePath(root, \"migration.in-progress\"), true), (path) => removeFileIfPresentAt(path, \"remove-path\")),\n deleteIncompleteRun: ({ root, runId }) => Effect.gen(function* () {\n const runPath = yield* resolvePortablePath(recordPortablePath(root, \"runs\", runId), true);\n const runKind = yield* pathKindAt(runPath);\n if (runKind === \"missing\") {\n return { state: \"missing\" } satisfies RecordIncompleteRunDelete;\n }\n if (runKind !== \"directory\") {\n return yield* Effect.fail(new RecordPathTypeInvalid({\n code: \"record-path-type-invalid\",\n path: runPath,\n expected: \"directory\",\n actual: runKind,\n }));\n }\n if (yield* nodeFileSystem.isCompleteMarker({ root, runId })) {\n return { state: \"skipped-complete\" } satisfies RecordIncompleteRunDelete;\n }\n yield* Effect.tryPromise({\n try: () => rm(runPath, { recursive: true, force: true }),\n catch: (cause) => fileSystemError(\"remove-path\", runPath, cause),\n });\n yield* syncDirectoryAt(dirname(runPath));\n return { state: \"deleted\" } satisfies RecordIncompleteRunDelete;\n }),\n};\ninterface GitOutput {\n readonly stdout: string;\n readonly stderr: string;\n}\nfunction executeGit(args: readonly string[], cwd: string, signal: AbortSignal): Promise<GitOutput> {\n // Keep the native adapter: Record requires one bounded collection covering\n // stdout and stderr, exact argv execution, and AbortSignal cancellation.\n // CommandExecutor has no single primitive with all of those guarantees.\n return new Promise((resolve, reject) => {\n execFile(\"git\", [...args], { cwd, encoding: \"utf8\", maxBuffer: GIT_MAX_OUTPUT_BYTES, signal }, (error, stdout, stderr) => {\n if (error !== null) {\n reject(error);\n return;\n }\n resolve({ stdout: String(stdout), stderr: String(stderr) });\n });\n });\n}\nfunction gitError(operation: \"locate-worktree\" | \"read-head\" | \"inspect-status\", cause: unknown): RecordGitError {\n if (nodeErrorCode(cause) === \"ERR_CHILD_PROCESS_STDIO_MAXBUFFER\") {\n return limitExceeded(\"git-output\", GIT_MAX_OUTPUT_BYTES, GIT_MAX_OUTPUT_BYTES, \"git\");\n }\n return new RecordGitCommandError({\n code: \"record-git-command-failed\",\n operation,\n cause,\n });\n}\nfunction runGit(operation: \"locate-worktree\" | \"read-head\" | \"inspect-status\", args: readonly string[], cwd: string): Effect.Effect<GitOutput, RecordGitError> {\n return Effect.tryPromise({\n try: (signal) => executeGit(args, cwd, signal),\n catch: (cause) => gitError(operation, cause),\n });\n}\nfunction isNotGitWorktree(error: RecordGitCommandError): boolean {\n const code = nodeErrorCode(error.cause);\n return code === \"ENOENT\" || nodeErrorMessage(error.cause).includes(\"not a git repository\");\n}\nfunction portablePathWithinWorktree(worktree: string, portableRoot: string): string | undefined {\n const rootRelative = relative(worktree, portableRoot);\n if (rootRelative === \"..\" ||\n rootRelative.startsWith(`..${sep}`) ||\n isAbsolute(rootRelative)) {\n return undefined;\n }\n return rootRelative === \"\" ? \".\" : rootRelative;\n}\ninterface GitStatusEntry {\n readonly status: string;\n readonly path: string;\n}\nfunction statusEntries(stdout: string): readonly GitStatusEntry[] {\n const records = stdout.split(\"\\0\").filter((entry) => entry !== \"\");\n const entries: GitStatusEntry[] = [];\n for (let index = 0; index < records.length; index += 1) {\n const record = records[index]!;\n const status = record.slice(0, 2);\n const path = record.length > 3 ? record.slice(3) : \"\";\n entries.push(Object.freeze({ status, path }));\n if (status.includes(\"R\") || status.includes(\"C\"))\n index += 1;\n }\n return Object.freeze(entries);\n}\nconst nodeGit = {\n inspectBackupState: (root: unknown): Effect.Effect<RecordBackupState, RecordGitError> => Effect.gen(function* () {\n const paths = recordRootPaths(root);\n if (paths === undefined) {\n return yield* Effect.fail(new RecordRootInvalid({ code: \"record-root-invalid\" }));\n }\n const location = yield* Effect.either(runGit(\"locate-worktree\", [\"rev-parse\", \"--show-toplevel\"], dirname(paths.portableRoot)));\n if (Either.isLeft(location)) {\n if (location.left instanceof RecordGitCommandError &&\n isNotGitWorktree(location.left)) {\n return { state: \"not-git-worktree\" } satisfies RecordBackupState;\n }\n return yield* Effect.fail(location.left);\n }\n const worktree = location.right.stdout.trim();\n const rootRelative = portablePathWithinWorktree(worktree, paths.portableRoot);\n if (rootRelative === undefined) {\n return { state: \"root-outside-worktree\" } satisfies RecordBackupState;\n }\n const head = yield* runGit(\"read-head\", [\"rev-parse\", \"--verify\", \"HEAD\"], worktree);\n const commit = head.stdout.trim();\n if (commit === \"\") {\n return yield* Effect.fail(new RecordGitCommandError({\n code: \"record-git-command-failed\",\n operation: \"read-head\",\n cause: new Error(\"git returned an empty HEAD\"),\n }));\n }\n const status = yield* runGit(\"inspect-status\", [\n \"status\",\n \"--porcelain=v1\",\n \"-z\",\n \"--ignored\",\n \"--untracked-files=all\",\n \"--\",\n rootRelative,\n ], worktree);\n const entries = statusEntries(status.stdout);\n if (entries.length > GIT_MAX_STATUS_ENTRIES) {\n return yield* Effect.fail(limitExceeded(\"git-output\", GIT_MAX_STATUS_ENTRIES, GIT_MAX_STATUS_ENTRIES + 1, \"git status\"));\n }\n return entries.length === 0\n ? ({ state: \"git-restore-point\", commit } satisfies RecordBackupState)\n : ({\n state: \"portable-root-dirty\",\n entries: Object.freeze(entries.map((entry) => `${entry.status} ${entry.path}`)),\n } satisfies RecordBackupState);\n }),\n recoveryChangesAreExpected: (input: {\n readonly root: unknown;\n readonly restoreCommit: string;\n readonly expectedPaths: readonly RecordPortablePath[];\n }): Effect.Effect<boolean, RecordGitError | RecordFileSystemError> => Effect.gen(function* () {\n const paths = recordRootPaths(input.root);\n if (paths === undefined) {\n return yield* Effect.fail(new RecordRootInvalid({ code: \"record-root-invalid\" }));\n }\n const location = yield* Effect.either(runGit(\"locate-worktree\", [\"rev-parse\", \"--show-toplevel\"], dirname(paths.portableRoot)));\n if (Either.isLeft(location))\n return false;\n const worktree = location.right.stdout.trim();\n const rootRelative = portablePathWithinWorktree(worktree, paths.portableRoot);\n if (rootRelative === undefined)\n return false;\n const head = yield* runGit(\"read-head\", [\"rev-parse\", \"--verify\", \"HEAD\"], worktree);\n if (head.stdout.trim() !== input.restoreCommit)\n return false;\n const expected = new Set<string>();\n for (const path of input.expectedPaths) {\n const resolved = yield* resolvePortablePath(path, true);\n const relativePath = portablePathWithinWorktree(worktree, resolved);\n if (relativePath === undefined)\n return false;\n expected.add(relativePath.split(sep).join(\"/\"));\n }\n const status = yield* runGit(\"inspect-status\", [\"status\", \"--porcelain=v1\", \"-z\", \"--ignored\", \"--untracked-files=all\", \"--\", rootRelative], worktree);\n const entries = statusEntries(status.stdout);\n if (entries.length === 0 || entries.length > GIT_MAX_STATUS_ENTRIES)\n return false;\n return entries.every((entry) => {\n const normalized = entry.path.split(sep).join(\"/\");\n if (!expected.has(normalized))\n return false;\n return normalized.endsWith(\"/migration.in-progress\")\n ? entry.status === \"??\" || entry.status === \"!!\"\n : entry.status === \" M\";\n });\n }),\n};\nexport const NodeRecordFileSystemLive = Layer.succeed(RecordFileSystem, nodeFileSystem);\nexport const NodeRecordEntropyLive = Layer.succeed(RecordEntropy, {\n uuid: Effect.sync(randomUUID),\n});\nexport const NodeRecordGitLive = Layer.succeed(RecordGit, nodeGit);\n/**\n * Convenience composition for an application boundary. Consumers still name\n * only the Tags they need in their own Effect requirements.\n */\nexport const NodeRecordLive = Layer.mergeAll(NodeRecordFileSystemLive, NodeRecordCoordinationLive, NodeRecordEntropyLive, NodeRecordGitLive);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"services.js","sourceRoot":"","sources":["services.ts"],"names":[],"mappings":";;;AAWA,gDAEC;AAbD,mCAAiD;AAWjD,SAAgB,kBAAkB,CAAC,IAAgB,EAAE,GAAG,QAA2B;IAC/E,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;AAC3E,CAAC;AAqED,MAAa,gBAAiB,SAAQ,gBAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,EAA6C;CAClI;AADD,4CACC;AAKD,MAAa,aAAc,SAAQ,gBAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,EAAuC;CACtH;AADD,sCACC;AAmBD,MAAa,SAAU,SAAQ,gBAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,EAA+B;CACtG;AADD,8BACC","sourcesContent":["import { Context, Effect, Stream } from \"effect\";\nimport type { RecordFileSystemError, RecordGitError, RecordPathKind, } from \"./errors.ts\";\nimport type { RecordRoot } from \"./root.ts\";\n/**\n * A portable root-relative path request. It is not a capability: every live\n * platform operation validates these data again, including forged JS objects.\n */\nexport interface RecordPortablePath {\n readonly root: RecordRoot;\n readonly segments: readonly string[];\n}\nexport function recordPortablePath(root: RecordRoot, ...segments: readonly string[]): RecordPortablePath {\n return Object.freeze({ root, segments: Object.freeze([...segments]) });\n}\nexport interface RecordDirectoryEntry {\n readonly name: string;\n readonly kind: Exclude<RecordPathKind, \"missing\">;\n}\nexport interface RecordListDirectoryInput {\n readonly directory: RecordPortablePath;\n readonly maximumEntries: number;\n}\nexport interface RecordReadFileInput {\n readonly file: RecordPortablePath;\n readonly maximumBytes: number;\n}\nexport interface RecordReadFileStreamInput extends RecordReadFileInput {\n readonly chunkBytes?: number;\n}\nexport type RecordFileWriteMode = \"exclusive\" | \"replace\";\nexport interface RecordWriteFileInput {\n readonly file: RecordPortablePath;\n readonly bytes: Uint8Array;\n readonly maximumBytes: number;\n readonly mode: RecordFileWriteMode;\n}\nexport interface RecordWriteFileStreamInput<E, R> {\n readonly file: RecordPortablePath;\n readonly stream: Stream.Stream<Uint8Array, E, R>;\n readonly maximumBytes: number;\n readonly mode: RecordFileWriteMode;\n}\nexport type RecordIncompleteRunDelete = {\n readonly state: \"deleted\";\n} | {\n readonly state: \"missing\";\n} | {\n readonly state: \"skipped-complete\";\n};\n/**\n * Portable Record file operations only. Lock files and other live operation\n * state are intentionally owned by the separate lease services below.\n */\nexport interface RecordFileSystemService {\n readonly pathKind: (path: RecordPortablePath) => Effect.Effect<RecordPathKind, RecordFileSystemError>;\n readonly ensureDirectory: (directory: RecordPortablePath) => Effect.Effect<void, RecordFileSystemError>;\n readonly createDirectory: (directory: RecordPortablePath) => Effect.Effect<void, RecordFileSystemError>;\n readonly listDirectory: (input: RecordListDirectoryInput) => Effect.Effect<readonly RecordDirectoryEntry[], RecordFileSystemError>;\n readonly readFile: (input: RecordReadFileInput) => Effect.Effect<Uint8Array | undefined, RecordFileSystemError>;\n readonly readFileStream: (input: RecordReadFileStreamInput) => Stream.Stream<Uint8Array, RecordFileSystemError>;\n readonly writeFile: (input: RecordWriteFileInput) => Effect.Effect<void, RecordFileSystemError>;\n readonly writeFileStream: <E, R>(input: RecordWriteFileStreamInput<E, R>) => Effect.Effect<void, RecordFileSystemError | E, R>;\n readonly syncDirectory: (directory: RecordPortablePath) => Effect.Effect<void, RecordFileSystemError>;\n /** Creates `runs/<RunId>` without publishing it. */\n readonly createRunDirectory: (input: {\n readonly root: RecordRoot;\n readonly runId: string;\n }) => Effect.Effect<void, RecordFileSystemError>;\n /** The only platform operation that creates `runs/<RunId>/complete`. */\n readonly createCompleteMarker: (input: {\n readonly root: RecordRoot;\n readonly runId: string;\n }) => Effect.Effect<void, RecordFileSystemError>;\n readonly migrationSentinelPresent: (root: RecordRoot) => Effect.Effect<boolean, RecordFileSystemError>;\n readonly createMigrationSentinel: (root: RecordRoot) => Effect.Effect<void, RecordFileSystemError>;\n readonly removeMigrationSentinel: (root: RecordRoot) => Effect.Effect<void, RecordFileSystemError>;\n /** The caller already owns the exclusive maintenance lease before deletion. */\n readonly deleteIncompleteRun: (input: {\n readonly root: RecordRoot;\n readonly runId: string;\n }) => Effect.Effect<RecordIncompleteRunDelete, RecordFileSystemError>;\n}\nexport class RecordFileSystem extends Context.Tag(\"@niceeval/record/RecordFileSystem\")<RecordFileSystem, RecordFileSystemService>() {\n}\n/** Entropy is a writer-only capability, not a reader requirement. */\nexport interface RecordEntropyService {\n readonly uuid: Effect.Effect<string>;\n}\nexport class RecordEntropy extends Context.Tag(\"@niceeval/record/RecordEntropy\")<RecordEntropy, RecordEntropyService>() {\n}\n/**\n * A migration asks whether local Git can restore the current portable root;\n * absence of proof is data for the CLI confirmation flow, not an implicit OK.\n */\nexport type RecordBackupState = {\n readonly state: \"git-restore-point\";\n readonly commit: string;\n} | {\n readonly state: \"not-git-worktree\";\n} | {\n readonly state: \"root-outside-worktree\";\n} | {\n readonly state: \"portable-root-dirty\";\n readonly entries: readonly string[];\n};\nexport interface RecordGitService {\n readonly inspectBackupState: (root: RecordRoot) => Effect.Effect<RecordBackupState, RecordGitError>;\n}\nexport class RecordGit extends Context.Tag(\"@niceeval/record/RecordGit\")<RecordGit, RecordGitService>() {\n}\n"]}
1
+ {"version":3,"file":"services.js","sourceRoot":"","sources":["services.ts"],"names":[],"mappings":";;;AAWA,gDAEC;AAbD,mCAAiD;AAWjD,SAAgB,kBAAkB,CAAC,IAAgB,EAAE,GAAG,QAA2B;IAC/E,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;AAC3E,CAAC;AA4ED,MAAa,gBAAiB,SAAQ,gBAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,EAA6C;CAClI;AADD,4CACC;AAKD,MAAa,aAAc,SAAQ,gBAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,EAAuC;CACtH;AADD,sCACC;AAyBD,MAAa,SAAU,SAAQ,gBAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,EAA+B;CACtG;AADD,8BACC","sourcesContent":["import { Context, Effect, Stream } from \"effect\";\nimport type { RecordFileSystemError, RecordGitError, RecordPathKind, } from \"./errors.ts\";\nimport type { RecordRoot } from \"./root.ts\";\n/**\n * A portable root-relative path request. It is not a capability: every live\n * platform operation validates these data again, including forged JS objects.\n */\nexport interface RecordPortablePath {\n readonly root: RecordRoot;\n readonly segments: readonly string[];\n}\nexport function recordPortablePath(root: RecordRoot, ...segments: readonly string[]): RecordPortablePath {\n return Object.freeze({ root, segments: Object.freeze([...segments]) });\n}\nexport interface RecordDirectoryEntry {\n readonly name: string;\n readonly kind: Exclude<RecordPathKind, \"missing\">;\n}\nexport interface RecordListDirectoryInput {\n readonly directory: RecordPortablePath;\n readonly maximumEntries: number;\n}\nexport interface RecordReadFileInput {\n readonly file: RecordPortablePath;\n readonly maximumBytes: number;\n}\nexport interface RecordReadFileStreamInput extends RecordReadFileInput {\n readonly chunkBytes?: number;\n}\nexport type RecordFileWriteMode = \"exclusive\" | \"replace\" | \"replace-no-follow\";\nexport interface RecordWriteFileInput {\n readonly file: RecordPortablePath;\n readonly bytes: Uint8Array;\n readonly maximumBytes: number;\n readonly mode: RecordFileWriteMode;\n}\nexport interface RecordWriteFileStreamInput<E, R> {\n readonly file: RecordPortablePath;\n readonly stream: Stream.Stream<Uint8Array, E, R>;\n readonly maximumBytes: number;\n readonly mode: RecordFileWriteMode;\n}\nexport type RecordIncompleteRunDelete = {\n readonly state: \"deleted\";\n} | {\n readonly state: \"missing\";\n} | {\n readonly state: \"skipped-complete\";\n};\n/**\n * Portable Record file operations only. Lock files and other live operation\n * state are intentionally owned by the separate lease services below.\n */\nexport interface RecordFileSystemService {\n readonly pathKind: (path: RecordPortablePath) => Effect.Effect<RecordPathKind, RecordFileSystemError>;\n readonly ensureDirectory: (directory: RecordPortablePath) => Effect.Effect<void, RecordFileSystemError>;\n readonly createDirectory: (directory: RecordPortablePath) => Effect.Effect<void, RecordFileSystemError>;\n readonly listDirectory: (input: RecordListDirectoryInput) => Effect.Effect<readonly RecordDirectoryEntry[], RecordFileSystemError>;\n readonly readFile: (input: RecordReadFileInput) => Effect.Effect<Uint8Array | undefined, RecordFileSystemError>;\n readonly readFileStream: (input: RecordReadFileStreamInput) => Stream.Stream<Uint8Array, RecordFileSystemError>;\n readonly writeFile: (input: RecordWriteFileInput) => Effect.Effect<void, RecordFileSystemError>;\n readonly writeFileStream: <E, R>(input: RecordWriteFileStreamInput<E, R>) => Effect.Effect<void, RecordFileSystemError | E, R>;\n readonly syncDirectory: (directory: RecordPortablePath) => Effect.Effect<void, RecordFileSystemError>;\n /** Creates `runs/<RunId>` without publishing it. */\n readonly createRunDirectory: (input: {\n readonly root: RecordRoot;\n readonly runId: string;\n }) => Effect.Effect<void, RecordFileSystemError>;\n /** The only platform operation that creates `runs/<RunId>/complete`. */\n readonly createCompleteMarker: (input: {\n readonly root: RecordRoot;\n readonly runId: string;\n }) => Effect.Effect<void, RecordFileSystemError>;\n /** True only for the zero-byte regular file created by `createCompleteMarker`. */\n readonly isCompleteMarker: (input: {\n readonly root: RecordRoot;\n readonly runId: string;\n }) => Effect.Effect<boolean, RecordFileSystemError>;\n readonly migrationSentinelPresent: (root: RecordRoot) => Effect.Effect<boolean, RecordFileSystemError>;\n readonly createMigrationSentinel: (root: RecordRoot, restoreCommit: string) => Effect.Effect<void, RecordFileSystemError>;\n /** Returns the bounded restore commit recorded by a current migration sentinel. */\n readonly readMigrationSentinelRestoreCommit: (root: RecordRoot) => Effect.Effect<string | undefined, RecordFileSystemError>;\n readonly removeMigrationSentinel: (root: RecordRoot) => Effect.Effect<void, RecordFileSystemError>;\n /** The caller already owns the exclusive maintenance lease before deletion. */\n readonly deleteIncompleteRun: (input: {\n readonly root: RecordRoot;\n readonly runId: string;\n }) => Effect.Effect<RecordIncompleteRunDelete, RecordFileSystemError>;\n}\nexport class RecordFileSystem extends Context.Tag(\"@niceeval/record/RecordFileSystem\")<RecordFileSystem, RecordFileSystemService>() {\n}\n/** Entropy is a writer-only capability, not a reader requirement. */\nexport interface RecordEntropyService {\n readonly uuid: Effect.Effect<string>;\n}\nexport class RecordEntropy extends Context.Tag(\"@niceeval/record/RecordEntropy\")<RecordEntropy, RecordEntropyService>() {\n}\n/**\n * A migration asks whether local Git can restore the current portable root;\n * absence of proof is data for the CLI confirmation flow, not an implicit OK.\n */\nexport type RecordBackupState = {\n readonly state: \"git-restore-point\";\n readonly commit: string;\n} | {\n readonly state: \"not-git-worktree\";\n} | {\n readonly state: \"root-outside-worktree\";\n} | {\n readonly state: \"portable-root-dirty\";\n readonly entries: readonly string[];\n};\nexport interface RecordGitService {\n readonly inspectBackupState: (root: RecordRoot) => Effect.Effect<RecordBackupState, RecordGitError>;\n /** Proves HEAD is unchanged and every dirty path is an expected migration write. */\n readonly recoveryChangesAreExpected: (input: {\n readonly root: RecordRoot;\n readonly restoreCommit: string;\n readonly expectedPaths: readonly RecordPortablePath[];\n }) => Effect.Effect<boolean, RecordGitError | RecordFileSystemError>;\n}\nexport class RecordGit extends Context.Tag(\"@niceeval/record/RecordGit\")<RecordGit, RecordGitService>() {\n}\n"]}