niceeval 0.13.2 → 0.13.3

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 (494) hide show
  1. package/dist/agents/bub.cjs +4 -4
  2. package/dist/agents/bub.cjs.map +1 -1
  3. package/dist/agents/bub.d.cts +2 -2
  4. package/dist/agents/bub.d.mts +2 -2
  5. package/dist/agents/bub.d.ts +2 -2
  6. package/dist/agents/claude-code-native.cjs +213 -0
  7. package/dist/agents/claude-code-native.cjs.map +1 -0
  8. package/dist/agents/claude-code-native.d.cts +5 -0
  9. package/dist/agents/claude-code-native.d.mts +5 -0
  10. package/dist/agents/claude-code-native.d.ts +5 -0
  11. package/dist/agents/claude-code-native.js +6 -0
  12. package/dist/agents/claude-code-native.js.map +1 -0
  13. package/dist/agents/claude-code.cjs +26 -80
  14. package/dist/agents/claude-code.cjs.map +1 -1
  15. package/dist/agents/codex-app-server.cjs +314 -0
  16. package/dist/agents/codex-app-server.cjs.map +1 -0
  17. package/dist/agents/codex-app-server.d.cts +9 -0
  18. package/dist/agents/codex-app-server.d.mts +9 -0
  19. package/dist/agents/codex-app-server.d.ts +9 -0
  20. package/dist/agents/codex-app-server.js +6 -0
  21. package/dist/agents/codex-app-server.js.map +1 -0
  22. package/dist/agents/codex.cjs +19 -68
  23. package/dist/agents/codex.cjs.map +1 -1
  24. package/dist/agents/codex.d.cts +3 -3
  25. package/dist/agents/codex.d.mts +3 -3
  26. package/dist/agents/codex.d.ts +3 -3
  27. package/dist/agents/index.cjs +3 -1
  28. package/dist/agents/index.cjs.map +1 -1
  29. package/dist/agents/index.d.cts +1 -0
  30. package/dist/agents/index.d.mts +1 -0
  31. package/dist/agents/index.d.ts +1 -0
  32. package/dist/agents/index.js +84 -82
  33. package/dist/agents/index.mjs +84 -82
  34. package/dist/agents/managed-jsonl.cjs +207 -0
  35. package/dist/agents/managed-jsonl.cjs.map +1 -0
  36. package/dist/agents/managed-jsonl.d.cts +39 -0
  37. package/dist/agents/managed-jsonl.d.mts +39 -0
  38. package/dist/agents/managed-jsonl.d.ts +39 -0
  39. package/dist/agents/managed-jsonl.js +6 -0
  40. package/dist/agents/managed-jsonl.js.map +1 -0
  41. package/dist/agents/managed-process.cjs +31 -0
  42. package/dist/agents/managed-process.cjs.map +1 -0
  43. package/dist/agents/managed-process.d.cts +3 -0
  44. package/dist/agents/managed-process.d.mts +3 -0
  45. package/dist/agents/managed-process.d.ts +3 -0
  46. package/dist/agents/managed-process.js +6 -0
  47. package/dist/agents/managed-process.js.map +1 -0
  48. package/dist/agents/omp.cjs +18 -1
  49. package/dist/agents/omp.cjs.map +1 -1
  50. package/dist/agents/sdk-streams.cjs +11 -4
  51. package/dist/agents/sdk-streams.cjs.map +1 -1
  52. package/dist/agents/types.cjs.map +1 -1
  53. package/dist/agents/types.d.cts +8 -0
  54. package/dist/agents/types.d.mts +8 -0
  55. package/dist/agents/types.d.ts +8 -0
  56. package/dist/analysis/bindings.cjs +74 -19
  57. package/dist/analysis/bindings.cjs.map +1 -1
  58. package/dist/analysis/bindings.d.cts +534 -156
  59. package/dist/analysis/bindings.d.mts +534 -156
  60. package/dist/analysis/bindings.d.ts +534 -156
  61. package/dist/analysis/domain-view.cjs.map +1 -1
  62. package/dist/analysis/domain-view.d.cts +137 -8
  63. package/dist/analysis/domain-view.d.mts +137 -8
  64. package/dist/analysis/domain-view.d.ts +137 -8
  65. package/dist/analysis/index.cjs.map +1 -1
  66. package/dist/analysis/index.d.cts +1 -1
  67. package/dist/analysis/index.d.mts +1 -1
  68. package/dist/analysis/index.d.ts +1 -1
  69. package/dist/assertions/api.cjs.map +1 -1
  70. package/dist/assertions/api.d.cts +62 -0
  71. package/dist/assertions/api.d.mts +62 -0
  72. package/dist/assertions/api.d.ts +62 -0
  73. package/dist/assertions/judge.cjs +56 -5
  74. package/dist/assertions/judge.cjs.map +1 -1
  75. package/dist/assertions/match.cjs +66 -42
  76. package/dist/assertions/match.cjs.map +1 -1
  77. package/dist/assertions/match.d.cts +13 -0
  78. package/dist/assertions/match.d.mts +13 -0
  79. package/dist/assertions/match.d.ts +13 -0
  80. package/dist/assertions/record/attachment.cjs +104 -33
  81. package/dist/assertions/record/attachment.cjs.map +1 -1
  82. package/dist/assertions/record/attachment.d.cts +294 -57
  83. package/dist/assertions/record/attachment.d.mts +294 -57
  84. package/dist/assertions/record/attachment.d.ts +294 -57
  85. package/dist/assertions/record/codec.cjs +91 -17
  86. package/dist/assertions/record/codec.cjs.map +1 -1
  87. package/dist/assertions/record/codec.d.cts +280 -52
  88. package/dist/assertions/record/codec.d.mts +280 -52
  89. package/dist/assertions/record/codec.d.ts +280 -52
  90. package/dist/assertions/record/index.js +2 -0
  91. package/dist/assertions/record/model.cjs +16 -0
  92. package/dist/assertions/record/model.cjs.map +1 -1
  93. package/dist/assertions/record/model.d.cts +120 -13
  94. package/dist/assertions/record/model.d.mts +120 -13
  95. package/dist/assertions/record/model.d.ts +120 -13
  96. package/dist/assertions/record/model.js +2 -0
  97. package/dist/assertions/record/producer.cjs +70 -50
  98. package/dist/assertions/record/producer.cjs.map +1 -1
  99. package/dist/assertions/record/producer.d.cts +8 -7
  100. package/dist/assertions/record/producer.d.mts +8 -7
  101. package/dist/assertions/record/producer.d.ts +8 -7
  102. package/dist/assertions/runtime.cjs +49 -7
  103. package/dist/assertions/runtime.cjs.map +1 -1
  104. package/dist/cli/application.cjs +40 -0
  105. package/dist/cli/application.cjs.map +1 -0
  106. package/dist/cli/application.d.cts +129 -0
  107. package/dist/cli/application.d.mts +129 -0
  108. package/dist/cli/application.d.ts +129 -0
  109. package/dist/cli/application.js +24 -0
  110. package/dist/cli/application.js.map +1 -0
  111. package/dist/cli/bootstrap.cjs +10 -4
  112. package/dist/cli/bootstrap.cjs.map +1 -1
  113. package/dist/cli/node-application.cjs +123 -0
  114. package/dist/cli/node-application.cjs.map +1 -0
  115. package/dist/cli/node-application.d.cts +14 -0
  116. package/dist/cli/node-application.d.mts +14 -0
  117. package/dist/cli/node-application.d.ts +14 -0
  118. package/dist/cli/node-application.js +26 -0
  119. package/dist/cli/node-application.js.map +1 -0
  120. package/dist/cli/program.cjs +2807 -0
  121. package/dist/cli/program.cjs.map +1 -0
  122. package/dist/cli/program.d.cts +352 -0
  123. package/dist/cli/program.d.mts +352 -0
  124. package/dist/cli/program.d.ts +352 -0
  125. package/dist/cli/program.js +36 -0
  126. package/dist/cli/program.js.map +1 -0
  127. package/dist/cli/project-configuration.cjs +134 -0
  128. package/dist/cli/project-configuration.cjs.map +1 -0
  129. package/dist/cli/project-configuration.d.cts +64 -0
  130. package/dist/cli/project-configuration.d.mts +64 -0
  131. package/dist/cli/project-configuration.d.ts +64 -0
  132. package/dist/cli/project-configuration.js +22 -0
  133. package/dist/cli/project-configuration.js.map +1 -0
  134. package/dist/cli/record.cjs +20 -4
  135. package/dist/cli/record.cjs.map +1 -1
  136. package/dist/cli/record.d.cts +3 -3
  137. package/dist/cli/record.d.mts +3 -3
  138. package/dist/cli/record.d.ts +3 -3
  139. package/dist/cli.cjs +19 -3130
  140. package/dist/cli.cjs.map +1 -1
  141. package/dist/cli.d.cts +2 -148
  142. package/dist/cli.d.mts +2 -148
  143. package/dist/cli.d.ts +2 -148
  144. package/dist/cli.js +22 -30
  145. package/dist/context/assert-first.cjs +21 -15
  146. package/dist/context/assert-first.cjs.map +1 -1
  147. package/dist/context/assert-first.d.cts +1 -0
  148. package/dist/context/assert-first.d.mts +1 -0
  149. package/dist/context/assert-first.d.ts +1 -0
  150. package/dist/context/attempt-resources.cjs +13 -0
  151. package/dist/context/attempt-resources.cjs.map +1 -0
  152. package/dist/context/attempt-resources.d.cts +3 -0
  153. package/dist/context/attempt-resources.d.mts +3 -0
  154. package/dist/context/attempt-resources.d.ts +3 -0
  155. package/dist/context/attempt-resources.js +8 -0
  156. package/dist/context/attempt-resources.js.map +1 -0
  157. package/dist/context/session.cjs +4 -3
  158. package/dist/context/session.cjs.map +1 -1
  159. package/dist/context/session.d.cts +1 -0
  160. package/dist/context/session.d.mts +1 -0
  161. package/dist/context/session.d.ts +1 -0
  162. package/dist/eval/record/verdict.cjs +3 -2
  163. package/dist/eval/record/verdict.cjs.map +1 -1
  164. package/dist/experiment/host/index.cjs +1 -6
  165. package/dist/experiment/host/index.cjs.map +1 -1
  166. package/dist/experiment/host/index.d.cts +1 -0
  167. package/dist/experiment/host/index.d.mts +1 -0
  168. package/dist/experiment/host/index.d.ts +1 -0
  169. package/dist/load-config.cjs +13 -4
  170. package/dist/load-config.cjs.map +1 -1
  171. package/dist/load-config.d.cts +4 -3
  172. package/dist/load-config.d.mts +4 -3
  173. package/dist/load-config.d.ts +4 -3
  174. package/dist/load-config.js +4 -2
  175. package/dist/o11y/parsers/codex.cjs +29 -7
  176. package/dist/o11y/parsers/codex.cjs.map +1 -1
  177. package/dist/record/codec/core.d.cts +0 -2
  178. package/dist/record/codec/core.d.mts +0 -2
  179. package/dist/record/codec/core.d.ts +0 -2
  180. package/dist/record/codec/identifiers.cjs +2 -3
  181. package/dist/record/codec/identifiers.cjs.map +1 -1
  182. package/dist/record/codec/identifiers.d.cts +1 -2
  183. package/dist/record/codec/identifiers.d.mts +1 -2
  184. package/dist/record/codec/identifiers.d.ts +1 -2
  185. package/dist/record/codec/identifiers.js +10 -12
  186. package/dist/record/codec/index.js +42 -44
  187. package/dist/record/definition/attachment.cjs +1 -0
  188. package/dist/record/definition/attachment.cjs.map +1 -1
  189. package/dist/record/definition/attachment.d.cts +14 -0
  190. package/dist/record/definition/attachment.d.mts +14 -0
  191. package/dist/record/definition/attachment.d.ts +14 -0
  192. package/dist/record/family/assertions-v1.cjs +104 -0
  193. package/dist/record/family/assertions-v1.cjs.map +1 -0
  194. package/dist/record/family/assertions-v1.d.cts +2 -0
  195. package/dist/record/family/assertions-v1.d.mts +2 -0
  196. package/dist/record/family/assertions-v1.d.ts +2 -0
  197. package/dist/record/family/assertions-v1.js +6 -0
  198. package/dist/record/family/assertions-v1.js.map +1 -0
  199. package/dist/record/family/assertions.cjs +16 -5
  200. package/dist/record/family/assertions.cjs.map +1 -1
  201. package/dist/record/family/assertions.d.cts +510 -56
  202. package/dist/record/family/assertions.d.mts +510 -56
  203. package/dist/record/family/assertions.d.ts +510 -56
  204. package/dist/record/family/assertions.js +14 -10
  205. package/dist/record/family/catalog.cjs +17 -1
  206. package/dist/record/family/catalog.cjs.map +1 -1
  207. package/dist/record/family/catalog.d.cts +1292 -104
  208. package/dist/record/family/catalog.d.mts +1292 -104
  209. package/dist/record/family/catalog.d.ts +1292 -104
  210. package/dist/record/family/catalog.js +22 -20
  211. package/dist/record/family/index.js +144 -138
  212. package/dist/record/family/observability-v1.cjs +5 -0
  213. package/dist/record/family/observability-v1.cjs.map +1 -1
  214. package/dist/record/family/observability.cjs +1 -1
  215. package/dist/record/family/observability.cjs.map +1 -1
  216. package/dist/record/host/runtime.cjs +323 -173
  217. package/dist/record/host/runtime.cjs.map +1 -1
  218. package/dist/record/host/types.cjs.map +1 -1
  219. package/dist/record/host/types.d.cts +9 -7
  220. package/dist/record/host/types.d.mts +9 -7
  221. package/dist/record/host/types.d.ts +9 -7
  222. package/dist/record/model/core.cjs.map +1 -1
  223. package/dist/record/model/core.d.cts +1 -2
  224. package/dist/record/model/core.d.mts +1 -2
  225. package/dist/record/model/core.d.ts +1 -2
  226. package/dist/record/model/definition.cjs +1 -2
  227. package/dist/record/model/definition.cjs.map +1 -1
  228. package/dist/record/model/definition.d.cts +1 -7
  229. package/dist/record/model/definition.d.mts +1 -7
  230. package/dist/record/model/definition.d.ts +1 -7
  231. package/dist/record/model/identifiers.cjs +2 -3
  232. package/dist/record/model/identifiers.cjs.map +1 -1
  233. package/dist/record/model/identifiers.d.cts +1 -3
  234. package/dist/record/model/identifiers.d.mts +1 -3
  235. package/dist/record/model/identifiers.d.ts +1 -3
  236. package/dist/record/model/identifiers.js +36 -38
  237. package/dist/record/model/index.js +60 -62
  238. package/dist/record/platform/node.cjs +17 -7
  239. package/dist/record/platform/node.cjs.map +1 -1
  240. package/dist/record/platform/services.cjs.map +1 -1
  241. package/dist/record/platform/services.d.cts +8 -3
  242. package/dist/record/platform/services.d.mts +8 -3
  243. package/dist/record/platform/services.d.ts +8 -3
  244. package/dist/record/reader/format.cjs +16 -65
  245. package/dist/record/reader/format.cjs.map +1 -1
  246. package/dist/record/reader/format.d.cts +5 -9
  247. package/dist/record/reader/format.d.mts +5 -9
  248. package/dist/record/reader/format.d.ts +5 -9
  249. package/dist/record/reader/index.js +10 -8
  250. package/dist/record/reader/runtime.cjs +63 -32
  251. package/dist/record/reader/runtime.cjs.map +1 -1
  252. package/dist/record/reader/runtime.d.cts +40 -4
  253. package/dist/record/reader/runtime.d.mts +40 -4
  254. package/dist/record/reader/runtime.d.ts +40 -4
  255. package/dist/record/reader/runtime.js +6 -4
  256. package/dist/report/assets/enhance.js +5 -5
  257. package/dist/report/assets/styles.css +190 -24
  258. package/dist/report/built-in/result-components.cjs +8 -5
  259. package/dist/report/built-in/result-components.cjs.map +1 -1
  260. package/dist/report/built-in/standard.cjs +3 -0
  261. package/dist/report/built-in/standard.cjs.map +1 -1
  262. package/dist/report/built-in/standard.d.cts +2 -0
  263. package/dist/report/built-in/standard.d.mts +2 -0
  264. package/dist/report/built-in/standard.d.ts +2 -0
  265. package/dist/report/client-dist/app.js +53 -0
  266. package/dist/report/components/attempt-detail/compute.cjs +108 -231
  267. package/dist/report/components/attempt-detail/compute.cjs.map +1 -1
  268. package/dist/report/components/attempt-detail/compute.d.cts +11 -45
  269. package/dist/report/components/attempt-detail/compute.d.mts +11 -45
  270. package/dist/report/components/attempt-detail/compute.d.ts +11 -45
  271. package/dist/report/components/attempt-detail/compute.js +2 -4
  272. package/dist/report/components/attempt-detail/content.cjs +4 -4
  273. package/dist/report/components/attempt-detail/content.cjs.map +1 -1
  274. package/dist/report/components/attempt-detail/validate.cjs +47 -4
  275. package/dist/report/components/attempt-detail/validate.cjs.map +1 -1
  276. package/dist/report/components/entity-lists/compute.cjs +9 -15
  277. package/dist/report/components/entity-lists/compute.cjs.map +1 -1
  278. package/dist/report/components/entity-lists/content.cjs +53 -40
  279. package/dist/report/components/entity-lists/content.cjs.map +1 -1
  280. package/dist/report/components/entity-lists/index.cjs +1 -3
  281. package/dist/report/components/entity-lists/index.cjs.map +1 -1
  282. package/dist/report/components/experiment-detail/compute.cjs +4 -6
  283. package/dist/report/components/experiment-detail/compute.cjs.map +1 -1
  284. package/dist/report/components/summaries/index.cjs +5 -1
  285. package/dist/report/components/summaries/index.cjs.map +1 -1
  286. package/dist/report/definition/cell.cjs +14 -7
  287. package/dist/report/definition/cell.cjs.map +1 -1
  288. package/dist/report/definition/cell.d.cts +4 -0
  289. package/dist/report/definition/cell.d.mts +4 -0
  290. package/dist/report/definition/cell.d.ts +4 -0
  291. package/dist/report/definition/primitives/assertion-evidence.cjs +96 -0
  292. package/dist/report/definition/primitives/assertion-evidence.cjs.map +1 -0
  293. package/dist/report/definition/primitives/assertion-evidence.d.cts +11 -0
  294. package/dist/report/definition/primitives/assertion-evidence.d.mts +11 -0
  295. package/dist/report/definition/primitives/assertion-evidence.d.ts +11 -0
  296. package/dist/report/definition/primitives/assertion-evidence.js +6 -0
  297. package/dist/report/definition/primitives/assertion-evidence.js.map +1 -0
  298. package/dist/report/definition/primitives/conversation.cjs +7 -0
  299. package/dist/report/definition/primitives/conversation.cjs.map +1 -1
  300. package/dist/report/definition/primitives/conversation.d.cts +2 -0
  301. package/dist/report/definition/primitives/conversation.d.mts +2 -0
  302. package/dist/report/definition/primitives/conversation.d.ts +2 -0
  303. package/dist/report/definition/primitives/turn-trace.cjs +53 -3
  304. package/dist/report/definition/primitives/turn-trace.cjs.map +1 -1
  305. package/dist/report/definition/primitives.cjs +14 -1
  306. package/dist/report/definition/primitives.cjs.map +1 -1
  307. package/dist/report/definition/report.cjs +16 -8
  308. package/dist/report/definition/report.cjs.map +1 -1
  309. package/dist/report/definition/report.d.cts +6 -0
  310. package/dist/report/definition/report.d.mts +6 -0
  311. package/dist/report/definition/report.d.ts +6 -0
  312. package/dist/report/definition/table-text.cjs +12 -3
  313. package/dist/report/definition/table-text.cjs.map +1 -1
  314. package/dist/report/definition/table-text.d.cts +6 -1
  315. package/dist/report/definition/table-text.d.mts +6 -1
  316. package/dist/report/definition/table-text.d.ts +6 -1
  317. package/dist/report/execution/model.cjs +6 -14
  318. package/dist/report/execution/model.cjs.map +1 -1
  319. package/dist/report/execution/model.d.cts +5 -10
  320. package/dist/report/execution/model.d.mts +5 -10
  321. package/dist/report/execution/model.d.ts +5 -10
  322. package/dist/report/execution/model.js +6 -6
  323. package/dist/report/execution/paths.cjs +0 -11
  324. package/dist/report/execution/paths.cjs.map +1 -1
  325. package/dist/report/execution/paths.d.cts +0 -1
  326. package/dist/report/execution/paths.d.mts +0 -1
  327. package/dist/report/execution/paths.d.ts +0 -1
  328. package/dist/report/execution/paths.js +6 -8
  329. package/dist/report/host/execute.cjs +13 -22
  330. package/dist/report/host/execute.cjs.map +1 -1
  331. package/dist/report/host/execute.d.cts +1 -4
  332. package/dist/report/host/execute.d.mts +1 -4
  333. package/dist/report/host/execute.d.ts +1 -4
  334. package/dist/report/host/from-record.cjs +3 -0
  335. package/dist/report/host/from-record.cjs.map +1 -1
  336. package/dist/report/host/from-record.d.cts +4 -1
  337. package/dist/report/host/from-record.d.mts +4 -1
  338. package/dist/report/host/from-record.d.ts +4 -1
  339. package/dist/report/host/site-assets.cjs +1 -2
  340. package/dist/report/host/site-assets.cjs.map +1 -1
  341. package/dist/report/host/site-assets.d.cts +0 -1
  342. package/dist/report/host/site-assets.d.mts +0 -1
  343. package/dist/report/host/site-assets.d.ts +0 -1
  344. package/dist/report/host/site-assets.js +2 -4
  345. package/dist/report/host/static.cjs +71 -346
  346. package/dist/report/host/static.cjs.map +1 -1
  347. package/dist/report/host/static.d.cts +1 -3
  348. package/dist/report/host/static.d.mts +1 -3
  349. package/dist/report/host/static.d.ts +1 -3
  350. package/dist/report/host/static.js +2 -2
  351. package/dist/report/host/view-session.cjs.map +1 -1
  352. package/dist/report/host/view-session.d.cts +1 -1
  353. package/dist/report/host/view-session.d.mts +1 -1
  354. package/dist/report/host/view-session.d.ts +1 -1
  355. package/dist/report/model/locale.cjs +1 -1
  356. package/dist/report/model/locale.cjs.map +1 -1
  357. package/dist/report/model/locale.d.cts +1 -1
  358. package/dist/report/model/locale.d.mts +1 -1
  359. package/dist/report/model/locale.d.ts +1 -1
  360. package/dist/report/model/pricing.cjs +2 -2
  361. package/dist/report/model/pricing.cjs.map +1 -1
  362. package/dist/report/react/enhance.js +5 -5
  363. package/dist/report/react/styles.css +190 -24
  364. package/dist/runner/adoption.cjs +4 -7
  365. package/dist/runner/adoption.cjs.map +1 -1
  366. package/dist/runner/attempt-resources.cjs +60 -0
  367. package/dist/runner/attempt-resources.cjs.map +1 -0
  368. package/dist/runner/attempt-resources.d.cts +13 -0
  369. package/dist/runner/attempt-resources.d.mts +13 -0
  370. package/dist/runner/attempt-resources.d.ts +13 -0
  371. package/dist/runner/attempt-resources.js +6 -0
  372. package/dist/runner/attempt-resources.js.map +1 -0
  373. package/dist/runner/attempt.cjs +37 -3
  374. package/dist/runner/attempt.cjs.map +1 -1
  375. package/dist/runner/feedback/failure.cjs +77 -2
  376. package/dist/runner/feedback/failure.cjs.map +1 -1
  377. package/dist/runner/feedback/failure.d.cts +2 -1
  378. package/dist/runner/feedback/failure.d.mts +2 -1
  379. package/dist/runner/feedback/failure.d.ts +2 -1
  380. package/dist/runner/project-current.cjs +2 -13
  381. package/dist/runner/project-current.cjs.map +1 -1
  382. package/dist/runner/project-current.d.cts +4 -2
  383. package/dist/runner/project-current.d.mts +4 -2
  384. package/dist/runner/project-current.d.ts +4 -2
  385. package/dist/runner/reporters/braintrust.cjs +7 -7
  386. package/dist/runner/reporters/braintrust.cjs.map +1 -1
  387. package/dist/runner/reuse-readback.cjs +3 -4
  388. package/dist/runner/reuse-readback.cjs.map +1 -1
  389. package/dist/runner/run.cjs +5 -2
  390. package/dist/runner/run.cjs.map +1 -1
  391. package/dist/sandbox/backend.cjs +32 -2
  392. package/dist/sandbox/backend.cjs.map +1 -1
  393. package/dist/sandbox/backend.d.cts +12 -1
  394. package/dist/sandbox/backend.d.mts +12 -1
  395. package/dist/sandbox/backend.d.ts +12 -1
  396. package/dist/sandbox/backend.js +28 -22
  397. package/dist/sandbox/docker.cjs +140 -0
  398. package/dist/sandbox/docker.cjs.map +1 -1
  399. package/dist/sandbox/docker.d.cts +3 -1
  400. package/dist/sandbox/docker.d.mts +3 -1
  401. package/dist/sandbox/docker.d.ts +3 -1
  402. package/dist/sandbox/e2b.cjs +42 -0
  403. package/dist/sandbox/e2b.cjs.map +1 -1
  404. package/dist/sandbox/e2b.d.cts +2 -0
  405. package/dist/sandbox/e2b.d.mts +2 -0
  406. package/dist/sandbox/e2b.d.ts +2 -0
  407. package/dist/sandbox/local.cjs +64 -0
  408. package/dist/sandbox/local.cjs.map +1 -1
  409. package/dist/sandbox/local.d.cts +3 -1
  410. package/dist/sandbox/local.d.mts +3 -1
  411. package/dist/sandbox/local.d.ts +3 -1
  412. package/dist/sandbox/managed-process.cjs +49 -0
  413. package/dist/sandbox/managed-process.cjs.map +1 -0
  414. package/dist/sandbox/managed-process.d.cts +11 -0
  415. package/dist/sandbox/managed-process.d.mts +11 -0
  416. package/dist/sandbox/managed-process.d.ts +11 -0
  417. package/dist/sandbox/managed-process.js +6 -0
  418. package/dist/sandbox/managed-process.js.map +1 -0
  419. package/dist/sandbox/types.cjs.map +1 -1
  420. package/dist/sandbox/types.d.cts +24 -0
  421. package/dist/sandbox/types.d.mts +24 -0
  422. package/dist/sandbox/types.d.ts +24 -0
  423. package/dist/sandbox/vercel.cjs +1 -0
  424. package/dist/sandbox/vercel.cjs.map +1 -1
  425. package/dist/sandbox/vercel.d.cts +1 -0
  426. package/dist/sandbox/vercel.d.mts +1 -0
  427. package/dist/sandbox/vercel.d.ts +1 -0
  428. package/dist/view/server.cjs +2 -37
  429. package/dist/view/server.cjs.map +1 -1
  430. package/dist/view/server.d.cts +0 -3
  431. package/dist/view/server.d.mts +0 -3
  432. package/dist/view/server.d.ts +0 -3
  433. package/docs-site/zh/reference/builtin-agents.mdx +7 -7
  434. package/docs-site/zh/reference/official-adapters.mdx +4 -4
  435. package/docs-site/zh/reference/report-components.mdx +2 -2
  436. package/docs-site/zh/tutorials/configuration.mdx +2 -2
  437. package/docs-site/zh/tutorials/deploy-report-site.mdx +24 -2
  438. package/docs-site/zh/tutorials/publish-report.mdx +4 -4
  439. package/docs-site/zh/tutorials/sandbox-agent.mdx +5 -5
  440. package/docs-site/zh/tutorials/theming.mdx +2 -2
  441. package/package.json +4 -6
  442. package/dist/record/migration/index.cjs +0 -5
  443. package/dist/record/migration/index.cjs.map +0 -1
  444. package/dist/record/migration/index.d.cts +0 -11
  445. package/dist/record/migration/index.d.mts +0 -11
  446. package/dist/record/migration/index.d.ts +0 -11
  447. package/dist/record/migration/index.js +0 -6
  448. package/dist/record/migration/index.js.map +0 -1
  449. package/dist/report/host/site-runtime.cjs +0 -92
  450. package/dist/report/host/site-runtime.cjs.map +0 -1
  451. package/dist/report/host/site-runtime.d.cts +0 -9
  452. package/dist/report/host/site-runtime.d.mts +0 -9
  453. package/dist/report/host/site-runtime.d.ts +0 -9
  454. package/dist/report/host/site-runtime.js +0 -10
  455. package/dist/report/host/site-runtime.js.map +0 -1
  456. package/dist/view/client-dist/app.css +0 -2
  457. package/dist/view/client-dist/app.js +0 -49
  458. package/dist/view/data.cjs +0 -3
  459. package/dist/view/data.cjs.map +0 -1
  460. package/dist/view/data.d.cts +0 -9
  461. package/dist/view/data.d.mts +0 -9
  462. package/dist/view/data.d.ts +0 -9
  463. package/dist/view/data.js +0 -4
  464. package/dist/view/data.js.map +0 -1
  465. package/dist/view/index.cjs +0 -24
  466. package/dist/view/index.cjs.map +0 -1
  467. package/dist/view/index.d.cts +0 -9
  468. package/dist/view/index.d.mts +0 -9
  469. package/dist/view/index.d.ts +0 -9
  470. package/dist/view/index.js +0 -28
  471. package/dist/view/index.js.map +0 -1
  472. package/dist/view/report-view-cache.cjs +0 -200
  473. package/dist/view/report-view-cache.cjs.map +0 -1
  474. package/dist/view/report-view-cache.d.cts +0 -67
  475. package/dist/view/report-view-cache.d.mts +0 -67
  476. package/dist/view/report-view-cache.d.ts +0 -67
  477. package/dist/view/report-view-cache.js +0 -8
  478. package/dist/view/report-view-cache.js.map +0 -1
  479. package/dist/view/shared/types.cjs +0 -3
  480. package/dist/view/shared/types.cjs.map +0 -1
  481. package/dist/view/shared/types.d.cts +0 -51
  482. package/dist/view/shared/types.d.mts +0 -51
  483. package/dist/view/shared/types.d.ts +0 -51
  484. package/dist/view/shared/types.js +0 -4
  485. package/dist/view/shared/types.js.map +0 -1
  486. package/dist/view/site.cjs +0 -32
  487. package/dist/view/site.cjs.map +0 -1
  488. package/dist/view/site.d.cts +0 -24
  489. package/dist/view/site.d.mts +0 -24
  490. package/dist/view/site.d.ts +0 -24
  491. package/dist/view/site.js +0 -8
  492. package/dist/view/site.js.map +0 -1
  493. package/dist/view/styles.css +0 -170
  494. package/dist/view/template.html +0 -17
@@ -117,8 +117,8 @@ function sameRoot(left, right) {
117
117
  leftPaths.portableRoot === rightPaths.portableRoot;
118
118
  }
119
119
  function currentFormatInspection(fileSystem, root) {
120
- return (0, format_ts_1.readRecordFormatForMaintenance)(fileSystem, root).pipe(effect_1.Effect.flatMap((format) => effect_1.Effect.map(planAttachmentMigration({ fileSystem, root }), (attachments) => ({
121
- state: format.sourceSchemaVersion === identifiers_ts_1.RECORD_SCHEMA_VERSION && attachments.targets.length === 0
120
+ return (0, format_ts_1.readRecordFormatForMaintenance)(fileSystem, root).pipe(effect_1.Effect.flatMap(() => effect_1.Effect.map(planAttachmentMigration({ fileSystem, root }), (attachments) => ({
121
+ state: attachments.targets.length === 0
122
122
  ? "already-current"
123
123
  : "migration-required",
124
124
  format: identifiers_ts_1.RECORD_FORMAT,
@@ -359,49 +359,25 @@ function scanSelection(runtime, fileSystem, request) {
359
359
  const wanted = request?.runIds === undefined
360
360
  ? undefined
361
361
  : new Set(request.runIds);
362
- const entries = orderedEntries(yield* fileSystem.listDirectory({
363
- directory: recordPath(runtime.root, "runs"),
364
- maximumEntries: MAXIMUM_RUN_ENTRIES,
365
- }));
366
362
  const snapshot = yield* readSealedCoreSnapshot(runtime, fileSystem);
367
- const found = new Set();
368
363
  const warnings = [];
369
364
  const problems = [];
370
365
  const documents = [];
371
- for (const entry of entries) {
372
- if (entry.kind !== "directory")
373
- continue;
374
- const runId = decodeRunId(entry.name);
375
- if (runId === undefined)
376
- continue;
377
- found.add(runId);
378
- const sealed = yield* isSealedRun(fileSystem, runtime.root, runId);
379
- if (!sealed) {
380
- warnings.push(Object.freeze({
381
- code: "incomplete-run",
382
- runId,
383
- cleanupCommand: "niceeval clean",
384
- }));
385
- if (wanted?.has(runId)) {
386
- problems.push(Object.freeze({ code: "incomplete-run", runId }));
387
- }
388
- continue;
389
- }
390
- if (wanted !== undefined && !wanted.has(runId))
391
- continue;
392
- const core = snapshot.state === "available" ? snapshot.byRunId.get(runId) : undefined;
393
- if (core === undefined) {
366
+ if (snapshot.state === "core-invalid") {
367
+ for (const runId of wanted ?? []) {
394
368
  problems.push(Object.freeze({ code: "record-core-invalid", runId }));
395
369
  }
396
- else {
397
- documents.push(core.run);
398
- }
399
370
  }
400
- if (wanted !== undefined) {
371
+ else if (wanted === undefined) {
372
+ documents.push(...[...snapshot.byRunId.values()].map((core) => core.run));
373
+ }
374
+ else {
401
375
  for (const runId of wanted) {
402
- if (!found.has(runId)) {
376
+ const core = snapshot.byRunId.get(runId);
377
+ if (core === undefined)
403
378
  problems.push(Object.freeze({ code: "selection-run-missing", runId }));
404
- }
379
+ else
380
+ documents.push(core.run);
405
381
  }
406
382
  }
407
383
  const orderedDocuments = documents.sort((left, right) => (0, identifiers_ts_1.compareCanonicalIdentity)(left.runId, right.runId));
@@ -752,7 +728,6 @@ function mintRecordDocument(entropy) {
752
728
  ? effect_1.Effect.fail(coreInvalid())
753
729
  : effect_1.Effect.succeed(Object.freeze({
754
730
  format: format.right,
755
- schemaVersion: identifiers_ts_1.RECORD_SCHEMA_VERSION,
756
731
  recordId: id.right,
757
732
  }));
758
733
  });
@@ -803,8 +778,6 @@ function openCurrentRead(input) {
803
778
  return yield* effect_1.Effect.fail(migrationInterrupted());
804
779
  }
805
780
  const current = yield* (0, format_ts_1.readCurrentRecordFormat)(fileSystem, input.root);
806
- yield* ensureOrdinaryCurrentAttachments({ fileSystem, root: input.root });
807
- yield* coordination.verifyRecordIdentity({ root: input.root, recordId: current.document.recordId });
808
781
  const lifecycle = { closed: false };
809
782
  const runtime = {
810
783
  root: input.root,
@@ -817,6 +790,15 @@ function openCurrentRead(input) {
817
790
  attemptsByKey: new Map(),
818
791
  sealedCoreSnapshot: undefined,
819
792
  };
793
+ const snapshot = yield* readSealedCoreSnapshot(runtime, fileSystem);
794
+ if (snapshot.state === "core-invalid")
795
+ return yield* effect_1.Effect.fail(bootstrapInvalid());
796
+ yield* ensureOrdinaryCurrentAttachments({
797
+ fileSystem,
798
+ root: input.root,
799
+ runIds: new Set(snapshot.byRunId.keys()),
800
+ });
801
+ yield* coordination.verifyRecordIdentity({ root: input.root, recordId: current.document.recordId });
820
802
  yield* effect_1.Effect.addFinalizer(() => effect_1.Effect.sync(() => { lifecycle.closed = true; }));
821
803
  return makeReadSession(runtime, fileSystem);
822
804
  });
@@ -1703,16 +1685,10 @@ function migrationDescriptor(descriptor) {
1703
1685
  return descriptor;
1704
1686
  }
1705
1687
  const runMigrationDescriptors = Object.freeze([
1706
- migrationDescriptor(catalog_ts_1.NiceEvalRecordFamilyCatalog.observability.run),
1707
- migrationDescriptor(catalog_ts_1.NiceEvalRecordFamilyCatalog.sources),
1708
- migrationDescriptor(catalog_ts_1.NiceEvalRecordFamilyCatalog.artifacts.run),
1688
+ ...catalog_ts_1.NiceEvalRecordFamilyDescriptorsByOwner.run.map(migrationDescriptor),
1709
1689
  ]);
1710
1690
  const attemptMigrationDescriptors = Object.freeze([
1711
- migrationDescriptor(catalog_ts_1.NiceEvalRecordFamilyCatalog.assertions),
1712
- migrationDescriptor(catalog_ts_1.NiceEvalRecordFamilyCatalog.observability.attempt),
1713
- migrationDescriptor(catalog_ts_1.NiceEvalRecordFamilyCatalog.fileChanges),
1714
- migrationDescriptor(catalog_ts_1.NiceEvalRecordFamilyCatalog.sourceNavigation),
1715
- migrationDescriptor(catalog_ts_1.NiceEvalRecordFamilyCatalog.artifacts.attempt),
1691
+ ...catalog_ts_1.NiceEvalRecordFamilyDescriptorsByOwner.attempt.map(migrationDescriptor),
1716
1692
  ]);
1717
1693
  function validateAttachmentDirectoryInventory(input) {
1718
1694
  return effect_1.Effect.gen(function* () {
@@ -1738,7 +1714,7 @@ function validateAttachmentDirectoryInventory(input) {
1738
1714
  }
1739
1715
  });
1740
1716
  }
1741
- function validateCurrentFamilyInventory(fileSystem, root) {
1717
+ function validateCurrentFamilyInventory(fileSystem, root, runIds) {
1742
1718
  const runFamilies = new Set(runMigrationDescriptors.map((descriptor) => descriptor.family));
1743
1719
  const attemptFamilies = new Set(attemptMigrationDescriptors.map((descriptor) => descriptor.family));
1744
1720
  return effect_1.Effect.gen(function* () {
@@ -1752,6 +1728,8 @@ function validateCurrentFamilyInventory(fileSystem, root) {
1752
1728
  const runId = decodeRunId(entry.name);
1753
1729
  if (runId === undefined || !(yield* isSealedRun(fileSystem, root, runId)))
1754
1730
  continue;
1731
+ if (runIds !== undefined && !runIds.has(runId))
1732
+ continue;
1755
1733
  yield* validateAttachmentDirectoryInventory({
1756
1734
  fileSystem,
1757
1735
  directory: (0, services_ts_1.recordPortablePath)(root, "runs", runId, "attachments"),
@@ -1798,7 +1776,7 @@ function migrationReaderLocation(location) {
1798
1776
  * never enumerates an attachment directory, so unknown families cannot enter
1799
1777
  * the migration graph or be rewritten as a side effect.
1800
1778
  */
1801
- function knownMigrationAttachments(fileSystem, root) {
1779
+ function knownMigrationAttachments(fileSystem, root, runIds) {
1802
1780
  return effect_1.Effect.gen(function* () {
1803
1781
  const locations = [];
1804
1782
  const runs = yield* fileSystem.listDirectory({
@@ -1811,6 +1789,8 @@ function knownMigrationAttachments(fileSystem, root) {
1811
1789
  const runId = decodeRunId(entry.name);
1812
1790
  if (runId === undefined)
1813
1791
  continue;
1792
+ if (runIds !== undefined && !runIds.has(runId))
1793
+ continue;
1814
1794
  // Draft directories are not Runs and belong exclusively to `niceeval
1815
1795
  // clean`; maintenance must preserve every byte beneath them.
1816
1796
  if (!(yield* isSealedRun(fileSystem, root, runId)))
@@ -1871,17 +1851,78 @@ function migrationFailureCode(error) {
1871
1851
  const code = Reflect.get(error, "code");
1872
1852
  return typeof code === "string" ? code : "record-command-failed";
1873
1853
  }
1874
- function migrationTarget(location) {
1854
+ function normalizedMigrationRetention(value) {
1855
+ if (typeof value !== "object" || value === null || Array.isArray(value))
1856
+ return undefined;
1857
+ const retention = value;
1858
+ const retainedFacts = retention.retainedFacts;
1859
+ const droppedFacts = retention.droppedFacts;
1860
+ const rerunRecommendation = retention.rerunRecommendation;
1861
+ if (!Array.isArray(retainedFacts) || retainedFacts.some((fact) => typeof fact !== "string" || fact.length === 0) ||
1862
+ !Array.isArray(droppedFacts) || droppedFacts.some((fact) => typeof fact !== "string" || fact.length === 0) ||
1863
+ (rerunRecommendation !== null &&
1864
+ (typeof rerunRecommendation !== "string" || rerunRecommendation.length === 0)))
1865
+ return undefined;
1866
+ return Object.freeze({
1867
+ retainedFacts: Object.freeze([...retainedFacts]),
1868
+ droppedFacts: Object.freeze([...droppedFacts]),
1869
+ rerunRecommendation,
1870
+ });
1871
+ }
1872
+ function migrationTarget(location, fromSchemaVersion, toSchemaVersion, retention) {
1875
1873
  return Object.freeze({
1876
1874
  family: location.descriptor.family,
1877
1875
  owner: location.owner,
1878
1876
  runId: location.runId,
1879
1877
  ...(location.attemptId === undefined ? {} : { attemptId: location.attemptId }),
1880
- fromSchemaVersion: 1,
1881
- toSchemaVersion: location.descriptor.schemaVersion,
1878
+ fromSchemaVersion,
1879
+ toSchemaVersion,
1880
+ retention,
1882
1881
  });
1883
1882
  }
1884
- const RECORD_MIGRATION_IMPLEMENTATION_ID = "niceeval.record/root-1-observability-1-to-root-2-observability-2/v1";
1883
+ function migrationLocationKey(owner, runId, attemptId, family) {
1884
+ return `${owner}\u0000${runId}\u0000${attemptId ?? ""}\u0000${family}`;
1885
+ }
1886
+ function validateProspectiveCrossFamilyJoins(values) {
1887
+ const byLocation = new Map(values.map(({ location, payload }) => [
1888
+ migrationLocationKey(location.owner, location.runId, location.attemptId, location.descriptor.family),
1889
+ payload,
1890
+ ]));
1891
+ for (const { location, payload } of values) {
1892
+ const runSources = () => byLocation.get(migrationLocationKey("run", location.runId, undefined, catalog_ts_1.NiceEvalRecordFamilyCatalog.sources.family));
1893
+ if (isObservabilityDescriptor(location.descriptor)) {
1894
+ const observability = payload;
1895
+ if (hasSourceFrames(observability)) {
1896
+ const sources = runSources();
1897
+ if (sources === undefined || (0, observability_ts_1.observabilitySourceFrameIntegrityIssues)(observability, sources).length > 0) {
1898
+ return false;
1899
+ }
1900
+ }
1901
+ }
1902
+ else if (isAssertionsDescriptor(location.descriptor)) {
1903
+ const assertions = payload;
1904
+ if (assertions.sourceSites.length > 0) {
1905
+ const sources = runSources();
1906
+ if (sources === undefined || (0, assertions_ts_1.assertionsSourceSiteIntegrityIssues)(assertions, sources).length > 0) {
1907
+ return false;
1908
+ }
1909
+ }
1910
+ }
1911
+ else if (isSourceNavigationDescriptor(location.descriptor)) {
1912
+ if (location.attemptId === undefined)
1913
+ return false;
1914
+ const navigation = payload;
1915
+ const observability = byLocation.get(migrationLocationKey("attempt", location.runId, location.attemptId, catalog_ts_1.NiceEvalRecordFamilyCatalog.observability.attempt.family));
1916
+ const sources = hasMappedNavigationRows(navigation) ? runSources() : undefined;
1917
+ if (observability === undefined ||
1918
+ (hasMappedNavigationRows(navigation) && sources === undefined) ||
1919
+ (0, source_navigation_ts_1.sourceNavigationIntegrityIssues)({ payload: navigation, observability, sources }).length > 0)
1920
+ return false;
1921
+ }
1922
+ }
1923
+ return true;
1924
+ }
1925
+ const RECORD_MIGRATION_IMPLEMENTATION_ID = "niceeval.record/current-attachments/v2";
1885
1926
  const migrationPlanSources = new WeakMap();
1886
1927
  function bytesEqual(left, right) {
1887
1928
  return left.byteLength === right.byteLength && left.every((byte, index) => byte === right[index]);
@@ -1896,11 +1937,9 @@ function sameMigrationPlan(left, right) {
1896
1937
  return true;
1897
1938
  if (JSON.stringify(left.backup) !== JSON.stringify(right.backup))
1898
1939
  return false;
1899
- if (JSON.stringify(left.root) !== JSON.stringify(right.root))
1900
- return false;
1901
1940
  if (left.attachments.length !== right.attachments.length)
1902
1941
  return false;
1903
- return left.attachments.every((target, index) => {
1942
+ if (!left.attachments.every((target, index) => {
1904
1943
  const candidate = right.attachments[index];
1905
1944
  return candidate !== undefined &&
1906
1945
  target.family === candidate.family &&
@@ -1908,23 +1947,46 @@ function sameMigrationPlan(left, right) {
1908
1947
  target.runId === candidate.runId &&
1909
1948
  target.attemptId === candidate.attemptId &&
1910
1949
  target.fromSchemaVersion === candidate.fromSchemaVersion &&
1911
- target.toSchemaVersion === candidate.toSchemaVersion;
1950
+ target.toSchemaVersion === candidate.toSchemaVersion &&
1951
+ JSON.stringify(target.retention) === JSON.stringify(candidate.retention);
1952
+ }))
1953
+ return false;
1954
+ const leftSources = migrationPlanSources.get(left);
1955
+ const rightSources = migrationPlanSources.get(right);
1956
+ if (leftSources === undefined || rightSources === undefined ||
1957
+ leftSources.implementationIdentity !== rightSources.implementationIdentity ||
1958
+ !bytesEqual(leftSources.rootIdentityBytes, rightSources.rootIdentityBytes) ||
1959
+ leftSources.attachments.length !== rightSources.attachments.length)
1960
+ return false;
1961
+ return leftSources.attachments.every((source, index) => {
1962
+ const candidate = rightSources.attachments[index];
1963
+ return candidate !== undefined &&
1964
+ bytesEqual(source.envelopeBytes, candidate.envelopeBytes) &&
1965
+ bytesEqual(source.payloadBytes, candidate.payloadBytes) &&
1966
+ source.rewritePayload === candidate.rewritePayload &&
1967
+ source.removedBlobs.length === candidate.removedBlobs.length &&
1968
+ source.removedBlobs.every((blob, blobIndex) => {
1969
+ const other = candidate.removedBlobs[blobIndex];
1970
+ return other !== undefined && blob.key === other.key && bytesEqual(blob.bytes, other.bytes);
1971
+ });
1912
1972
  });
1913
1973
  }
1914
1974
  function planAttachmentMigration(input) {
1915
1975
  return effect_1.Effect.gen(function* () {
1916
- yield* validateCurrentFamilyInventory(input.fileSystem, input.root);
1976
+ yield* validateCurrentFamilyInventory(input.fileSystem, input.root, input.runIds);
1917
1977
  const targets = [];
1918
1978
  const sources = [];
1919
- for (const location of yield* knownMigrationAttachments(input.fileSystem, input.root)) {
1979
+ const prospective = [];
1980
+ for (const location of yield* knownMigrationAttachments(input.fileSystem, input.root, input.runIds)) {
1920
1981
  const read = yield* readKnownMigrationAttachment(input.fileSystem, input.root, location);
1921
- if (read.state === "available")
1982
+ if (read.state === "available") {
1983
+ prospective.push(Object.freeze({ location, payload: read.value }));
1922
1984
  continue;
1923
- if (read.state === "migration-required" &&
1924
- location.descriptor.family === catalog_ts_1.NiceEvalRecordAttachments.observability.family &&
1925
- read.fromSchemaVersion === 1 &&
1926
- read.toSchemaVersion === 2) {
1927
- const target = migrationTarget(location);
1985
+ }
1986
+ const migrationLink = read.state === "migration-required"
1987
+ ? location.descriptor.adjacentMigrationLinks.find((link) => link.fromSchemaVersion === read.fromSchemaVersion && link.toSchemaVersion === read.toSchemaVersion)
1988
+ : undefined;
1989
+ if (read.state === "migration-required" && migrationLink !== undefined) {
1928
1990
  const envelopeBytes = yield* input.fileSystem.readFile({
1929
1991
  file: migrationEnvelopePath(input.root, location),
1930
1992
  maximumBytes: limits_ts_1.RECORD_JSON_MAXIMUM_BYTES,
@@ -1932,8 +1994,47 @@ function planAttachmentMigration(input) {
1932
1994
  if (envelopeBytes === undefined) {
1933
1995
  return yield* effect_1.Effect.fail(migrationInvalid(location.descriptor.family));
1934
1996
  }
1997
+ const facet = yield* loadAttachmentMaintenance(location.descriptor);
1998
+ const historical = facet.historicalCodecs.find((codec) => codec.schemaVersion === read.fromSchemaVersion);
1999
+ const step = facet.adjacentMigrations.find((migration) => migration.fromSchemaVersion === read.fromSchemaVersion &&
2000
+ migration.toSchemaVersion === read.toSchemaVersion);
2001
+ if (historical === undefined || step === undefined) {
2002
+ return yield* effect_1.Effect.fail(migrationInvalid(location.descriptor.family));
2003
+ }
2004
+ const retention = normalizedMigrationRetention(step.retention);
2005
+ if (retention === undefined) {
2006
+ return yield* effect_1.Effect.fail(migrationInvalid(location.descriptor.family));
2007
+ }
2008
+ const target = migrationTarget(location, read.fromSchemaVersion, read.toSchemaVersion, retention);
2009
+ const prepared = yield* (0, runtime_ts_1.validateFixedRecordAttachmentMigrationSource)({
2010
+ fileSystem: input.fileSystem,
2011
+ root: input.root,
2012
+ location: migrationReaderLocation(location),
2013
+ descriptor: location.descriptor,
2014
+ fromSchemaVersion: read.fromSchemaVersion,
2015
+ decodeHistorical: historical.decode,
2016
+ ...(historical.verify === undefined ? {} : { verifyHistorical: historical.verify }),
2017
+ migrate: step.migrate,
2018
+ });
2019
+ if (prepared === false || prepared.rewritePayload !== migrationLink.rewritePayload) {
2020
+ return yield* effect_1.Effect.fail(migrationInvalid(location.descriptor.family));
2021
+ }
2022
+ prospective.push(Object.freeze({ location, payload: prepared.payload }));
2023
+ const payloadBytes = yield* input.fileSystem.readFile({
2024
+ file: (0, services_ts_1.recordPortablePath)(input.root, ...migrationAttachmentDirectory(input.root, location).segments, "payload.json"),
2025
+ maximumBytes: limits_ts_1.RECORD_JSON_MAXIMUM_BYTES,
2026
+ });
2027
+ if (payloadBytes === undefined)
2028
+ return yield* effect_1.Effect.fail(migrationInvalid(location.descriptor.family));
1935
2029
  targets.push(target);
1936
- sources.push(Object.freeze({ target, envelopeBytes }));
2030
+ sources.push(Object.freeze({
2031
+ target,
2032
+ location,
2033
+ envelopeBytes,
2034
+ payloadBytes,
2035
+ removedBlobs: prepared.removedBlobs,
2036
+ rewritePayload: migrationLink.rewritePayload,
2037
+ }));
1937
2038
  continue;
1938
2039
  }
1939
2040
  if (read.state === "unsupported") {
@@ -1944,6 +2045,9 @@ function planAttachmentMigration(input) {
1944
2045
  }
1945
2046
  return yield* effect_1.Effect.fail(migrationInvalid(location.descriptor.family));
1946
2047
  }
2048
+ if (!validateProspectiveCrossFamilyJoins(prospective)) {
2049
+ return yield* effect_1.Effect.fail(migrationInvalid("niceeval.record cross-family"));
2050
+ }
1947
2051
  return Object.freeze({
1948
2052
  targets: Object.freeze(targets),
1949
2053
  sources: Object.freeze(sources),
@@ -1951,29 +2055,41 @@ function planAttachmentMigration(input) {
1951
2055
  });
1952
2056
  }
1953
2057
  function ensureOrdinaryCurrentAttachments(input) {
1954
- return planAttachmentMigration(input).pipe(effect_1.Effect.flatMap((plan) => plan.targets.length === 0
1955
- ? effect_1.Effect.void
1956
- : effect_1.Effect.fail(new errors_ts_3.RecordMigrationRequired({
1957
- code: "record-migration-required",
1958
- source: "niceeval.record attachment predecessor",
1959
- target: `${identifiers_ts_1.RECORD_FORMAT}@${identifiers_ts_1.RECORD_SCHEMA_VERSION}`,
1960
- command: "niceeval migrate",
1961
- }))), effect_1.Effect.mapError((error) => error instanceof errors_ts_3.RecordMigrationInvalid
1962
- ? bootstrapInvalid()
1963
- : error));
2058
+ return effect_1.Effect.gen(function* () {
2059
+ yield* validateCurrentFamilyInventory(input.fileSystem, input.root, input.runIds);
2060
+ for (const location of yield* knownMigrationAttachments(input.fileSystem, input.root, input.runIds)) {
2061
+ const envelope = yield* (0, runtime_ts_1.inspectFixedRecordAttachmentEnvelope)({
2062
+ fileSystem: input.fileSystem,
2063
+ root: input.root,
2064
+ location: migrationReaderLocation(location),
2065
+ descriptor: location.descriptor,
2066
+ });
2067
+ if (envelope.state === "current" || envelope.state === "unavailable")
2068
+ continue;
2069
+ if (envelope.state === "migration-required") {
2070
+ return yield* effect_1.Effect.fail(new errors_ts_3.RecordMigrationRequired({
2071
+ code: "record-migration-required",
2072
+ source: `${envelope.family}@${envelope.fromSchemaVersion}`,
2073
+ target: `${envelope.family}@${envelope.toSchemaVersion}`,
2074
+ command: "niceeval migrate",
2075
+ }));
2076
+ }
2077
+ if (envelope.state === "unsupported") {
2078
+ return yield* effect_1.Effect.fail(new errors_ts_3.RecordFormatUnsupported({
2079
+ code: "record-format-unsupported",
2080
+ format: `${envelope.family}@${envelope.schemaVersion}`,
2081
+ }));
2082
+ }
2083
+ return yield* effect_1.Effect.fail(bootstrapInvalid());
2084
+ }
2085
+ });
1964
2086
  }
1965
2087
  function migrationPlan(input) {
1966
2088
  return effect_1.Effect.gen(function* () {
1967
2089
  const format = yield* (0, format_ts_1.readRecordFormatForMaintenance)(input.fileSystem, input.root);
1968
2090
  yield* validateSealedCoreForMigration(input.fileSystem, input.root, format.document);
1969
2091
  const attachments = yield* planAttachmentMigration(input);
1970
- const rootMigration = format.sourceSchemaVersion === identifiers_ts_1.RECORD_SCHEMA_VERSION
1971
- ? null
1972
- : Object.freeze({
1973
- fromSchemaVersion: format.sourceSchemaVersion,
1974
- toSchemaVersion: identifiers_ts_1.RECORD_SCHEMA_VERSION,
1975
- });
1976
- if (rootMigration === null && attachments.targets.length === 0) {
2092
+ if (attachments.targets.length === 0) {
1977
2093
  return Object.freeze({ state: "already-current", format: identifiers_ts_1.RECORD_FORMAT });
1978
2094
  }
1979
2095
  const backup = yield* input.git.inspectBackupState(input.root);
@@ -1981,13 +2097,11 @@ function migrationPlan(input) {
1981
2097
  state: "migration-required",
1982
2098
  format: identifiers_ts_1.RECORD_FORMAT,
1983
2099
  backup,
1984
- root: rootMigration,
1985
2100
  attachments: attachments.targets,
1986
2101
  });
1987
2102
  migrationPlanSources.set(plan, Object.freeze({
1988
2103
  attachments: attachments.sources,
1989
- rootBytes: rootMigration === null ? null : format.sourceBytes,
1990
- record: format.document,
2104
+ rootIdentityBytes: format.sourceBytes,
1991
2105
  implementationIdentity: RECORD_MIGRATION_IMPLEMENTATION_ID,
1992
2106
  }));
1993
2107
  return plan;
@@ -1998,39 +2112,35 @@ function validateSealedCoreForMigration(fileSystem, root, record) {
1998
2112
  ? effect_1.Effect.void
1999
2113
  : effect_1.Effect.fail(migrationInvalid("niceeval.core")));
2000
2114
  }
2001
- function loadObservabilityV1Maintenance() {
2002
- const loader = catalog_ts_1.NiceEvalRecordAttachments.observability.maintenance;
2115
+ function loadAttachmentMaintenance(descriptor) {
2116
+ const loader = descriptor.maintenance;
2003
2117
  if (loader === undefined)
2004
- return effect_1.Effect.fail(migrationInvalid(catalog_ts_1.NiceEvalRecordAttachments.observability.family));
2118
+ return effect_1.Effect.fail(migrationInvalid(descriptor.family));
2005
2119
  return effect_1.Effect.tryPromise({
2006
2120
  try: loader,
2007
- catch: () => migrationInvalid(catalog_ts_1.NiceEvalRecordAttachments.observability.family),
2121
+ catch: () => migrationInvalid(descriptor.family),
2008
2122
  });
2009
2123
  }
2010
- function migrateObservabilityAttachment(input) {
2124
+ function migrateKnownAttachment(input) {
2011
2125
  return effect_1.Effect.gen(function* () {
2012
- if (input.target.family !== catalog_ts_1.NiceEvalRecordAttachments.observability.family ||
2013
- input.target.fromSchemaVersion !== 1 ||
2014
- input.target.toSchemaVersion !== 2) {
2126
+ const descriptor = input.location.descriptor;
2127
+ const migrationLink = descriptor.adjacentMigrationLinks.find((link) => link.fromSchemaVersion === input.target.fromSchemaVersion &&
2128
+ link.toSchemaVersion === input.target.toSchemaVersion);
2129
+ if (migrationLink === undefined || migrationLink.rewritePayload !== input.rewritePayload) {
2015
2130
  return yield* effect_1.Effect.fail(migrationInvalid(input.target.family));
2016
2131
  }
2017
- const descriptor = input.target.owner === "run"
2018
- ? migrationDescriptor(catalog_ts_1.NiceEvalRecordFamilyCatalog.observability.run)
2019
- : migrationDescriptor(catalog_ts_1.NiceEvalRecordFamilyCatalog.observability.attempt);
2020
- const location = input.target.owner === "run"
2021
- ? Object.freeze({ owner: "run", runId: input.target.runId, descriptor })
2022
- : Object.freeze({
2023
- owner: "attempt",
2024
- runId: input.target.runId,
2025
- attemptId: input.target.attemptId,
2026
- descriptor,
2027
- });
2028
- const facet = yield* loadObservabilityV1Maintenance();
2029
- const historical = facet.historicalCodecs.find((codec) => codec.schemaVersion === 1);
2030
- const step = facet.adjacentMigrations.find((migration) => migration.fromSchemaVersion === 1 && migration.toSchemaVersion === 2);
2132
+ const location = input.location;
2133
+ const facet = yield* loadAttachmentMaintenance(descriptor);
2134
+ const historical = facet.historicalCodecs.find((codec) => codec.schemaVersion === input.target.fromSchemaVersion);
2135
+ const step = facet.adjacentMigrations.find((migration) => migration.fromSchemaVersion === input.target.fromSchemaVersion &&
2136
+ migration.toSchemaVersion === input.target.toSchemaVersion);
2031
2137
  if (historical === undefined || step === undefined) {
2032
2138
  return yield* effect_1.Effect.fail(migrationInvalid(input.target.family));
2033
2139
  }
2140
+ const retention = normalizedMigrationRetention(step.retention);
2141
+ if (retention === undefined || JSON.stringify(retention) !== JSON.stringify(input.target.retention)) {
2142
+ return yield* effect_1.Effect.fail(migrationInvalid(input.target.family));
2143
+ }
2034
2144
  const envelopePath = migrationEnvelopePath(input.root, location);
2035
2145
  const sourceBeforeValidation = yield* input.fileSystem.readFile({
2036
2146
  file: envelopePath,
@@ -2039,16 +2149,25 @@ function migrateObservabilityAttachment(input) {
2039
2149
  if (sourceBeforeValidation === undefined || !bytesEqual(sourceBeforeValidation, input.expectedEnvelopeBytes)) {
2040
2150
  return yield* effect_1.Effect.fail(migrationPlanStale());
2041
2151
  }
2042
- const valid = yield* (0, runtime_ts_1.validateFixedRecordAttachmentMigrationSource)({
2152
+ const payloadPath = (0, services_ts_1.recordPortablePath)(input.root, ...migrationAttachmentDirectory(input.root, location).segments, "payload.json");
2153
+ const payloadBeforeValidation = yield* input.fileSystem.readFile({
2154
+ file: payloadPath,
2155
+ maximumBytes: limits_ts_1.RECORD_JSON_MAXIMUM_BYTES,
2156
+ });
2157
+ if (payloadBeforeValidation === undefined || !bytesEqual(payloadBeforeValidation, input.expectedPayloadBytes)) {
2158
+ return yield* effect_1.Effect.fail(migrationPlanStale());
2159
+ }
2160
+ const validated = yield* (0, runtime_ts_1.validateFixedRecordAttachmentMigrationSource)({
2043
2161
  fileSystem: input.fileSystem,
2044
2162
  root: input.root,
2045
2163
  location: migrationReaderLocation(location),
2046
2164
  descriptor,
2047
- fromSchemaVersion: 1,
2165
+ fromSchemaVersion: input.target.fromSchemaVersion,
2048
2166
  decodeHistorical: historical.decode,
2167
+ ...(historical.verify === undefined ? {} : { verifyHistorical: historical.verify }),
2049
2168
  migrate: step.migrate,
2050
2169
  });
2051
- if (!valid) {
2170
+ if (validated === false) {
2052
2171
  const sourceAfterInvalid = yield* input.fileSystem.readFile({
2053
2172
  file: envelopePath,
2054
2173
  maximumBytes: limits_ts_1.RECORD_JSON_MAXIMUM_BYTES,
@@ -2059,8 +2178,8 @@ function migrateObservabilityAttachment(input) {
2059
2178
  return yield* effect_1.Effect.fail(migrationInvalid(input.target.family));
2060
2179
  }
2061
2180
  const envelope = (0, catalog_ts_1.encodeFixedRecordAttachmentEnvelope)({
2062
- family: catalog_ts_1.NiceEvalRecordAttachments.observability.family,
2063
- schemaVersion: 2,
2181
+ family: descriptor.family,
2182
+ schemaVersion: input.target.toSchemaVersion,
2064
2183
  });
2065
2184
  if (effect_1.Either.isLeft(envelope))
2066
2185
  return yield* effect_1.Effect.fail(migrationInvalid(input.target.family));
@@ -2071,6 +2190,44 @@ function migrateObservabilityAttachment(input) {
2071
2190
  if (sourceBeforeWrite === undefined || !bytesEqual(sourceBeforeWrite, input.expectedEnvelopeBytes)) {
2072
2191
  return yield* effect_1.Effect.fail(migrationPlanStale());
2073
2192
  }
2193
+ if (validated.rewritePayload !== input.rewritePayload) {
2194
+ return yield* effect_1.Effect.fail(migrationInvalid(input.target.family));
2195
+ }
2196
+ if (validated.removedBlobs.length !== input.expectedRemovedBlobs.length ||
2197
+ validated.removedBlobs.some((blob, index) => {
2198
+ const expected = input.expectedRemovedBlobs[index];
2199
+ return expected === undefined || blob.key !== expected.key || !bytesEqual(blob.bytes, expected.bytes);
2200
+ })) {
2201
+ return yield* effect_1.Effect.fail(migrationPlanStale());
2202
+ }
2203
+ if (input.rewritePayload) {
2204
+ const encodedPayload = descriptor.write.encodePayload(validated.payload);
2205
+ if (effect_1.Either.isLeft(encodedPayload))
2206
+ return yield* effect_1.Effect.fail(migrationInvalid(input.target.family));
2207
+ const durablePayload = (0, attachment_payload_ts_1.encodeAttachmentPayloadForStorage)({
2208
+ payload: encodedPayload.right,
2209
+ blobKeys: validated.blobKeys,
2210
+ });
2211
+ if (effect_1.Either.isLeft(durablePayload))
2212
+ return yield* effect_1.Effect.fail(migrationInvalid(input.target.family));
2213
+ yield* input.fileSystem.writeFile({
2214
+ file: payloadPath,
2215
+ bytes: jsonBytes(durablePayload.right),
2216
+ maximumBytes: limits_ts_1.RECORD_JSON_MAXIMUM_BYTES,
2217
+ mode: "replace-no-follow",
2218
+ });
2219
+ }
2220
+ for (const blob of input.expectedRemovedBlobs) {
2221
+ const blobPath = (0, services_ts_1.recordPortablePath)(input.root, ...migrationAttachmentDirectory(input.root, location).segments, "blobs", blob.key);
2222
+ const beforeDelete = yield* input.fileSystem.readFile({
2223
+ file: blobPath,
2224
+ maximumBytes: descriptor.write.budget.maximumBlobBytes,
2225
+ });
2226
+ if (beforeDelete === undefined || !bytesEqual(beforeDelete, blob.bytes)) {
2227
+ return yield* effect_1.Effect.fail(migrationPlanStale());
2228
+ }
2229
+ yield* input.fileSystem.removeFile((0, services_ts_1.recordPortablePath)(input.root, ...migrationAttachmentDirectory(input.root, location).segments, "blobs", blob.key));
2230
+ }
2074
2231
  yield* input.fileSystem.writeFile({
2075
2232
  file: envelopePath,
2076
2233
  bytes: jsonBytes(envelope.right),
@@ -2102,35 +2259,10 @@ function validateCurrentKnownAttachments(input) {
2102
2259
  }
2103
2260
  function migrationRecoveryIsSafe(input) {
2104
2261
  return effect_1.Effect.gen(function* () {
2105
- const encoded = (0, catalog_ts_1.encodeFixedRecordAttachmentEnvelope)({
2106
- family: catalog_ts_1.NiceEvalRecordAttachments.observability.family,
2107
- schemaVersion: 2,
2108
- });
2109
- if (effect_1.Either.isLeft(encoded))
2110
- return false;
2111
- const currentEnvelopeBytes = jsonBytes(encoded.right);
2112
- const expectedPaths = [(0, services_ts_1.recordPortablePath)(input.root, "migration.in-progress")];
2113
- const currentRoot = yield* input.fileSystem.readFile({
2114
- file: (0, services_ts_1.recordPortablePath)(input.root, "record.json"),
2115
- maximumBytes: format_ts_1.RECORD_FORMAT_DOCUMENT_MAXIMUM_BYTES,
2116
- });
2117
- if (currentRoot !== undefined) {
2118
- const parsed = parseJson(currentRoot);
2119
- if (typeof parsed === "object" && parsed !== null &&
2120
- Reflect.get(parsed, "schemaVersion") === identifiers_ts_1.RECORD_SCHEMA_VERSION)
2121
- expectedPaths.push((0, services_ts_1.recordPortablePath)(input.root, "record.json"));
2122
- }
2123
- for (const location of yield* knownMigrationAttachments(input.fileSystem, input.root)) {
2124
- if (location.descriptor.family !== catalog_ts_1.NiceEvalRecordAttachments.observability.family)
2125
- continue;
2126
- const path = migrationEnvelopePath(input.root, location);
2127
- const bytes = yield* input.fileSystem.readFile({
2128
- file: path,
2129
- maximumBytes: limits_ts_1.RECORD_JSON_MAXIMUM_BYTES,
2130
- });
2131
- if (bytes !== undefined && bytesEqual(bytes, currentEnvelopeBytes))
2132
- expectedPaths.push(path);
2133
- }
2262
+ const expectedPaths = [
2263
+ (0, services_ts_1.recordPortablePath)(input.root, "migration.in-progress"),
2264
+ ...input.expectedRelativePaths.map((relative) => (0, services_ts_1.recordPortablePath)(input.root, ...relative.split("/"))),
2265
+ ];
2134
2266
  return yield* input.git.recoveryChangesAreExpected({
2135
2267
  root: input.root,
2136
2268
  restoreCommit: input.restoreCommit,
@@ -2145,11 +2277,17 @@ function openMaintenance(input) {
2145
2277
  const git = yield* services_ts_1.RecordGit;
2146
2278
  yield* coordination.enterRecordMaintenance(input.root);
2147
2279
  if (yield* fileSystem.migrationSentinelPresent(input.root)) {
2148
- const restoreCommit = yield* fileSystem.readMigrationSentinelRestoreCommit(input.root);
2149
- const restoreSafe = restoreCommit === undefined
2280
+ const sentinel = yield* fileSystem.readMigrationSentinel(input.root);
2281
+ const restoreSafe = sentinel === undefined
2150
2282
  ? false
2151
- : yield* migrationRecoveryIsSafe({ fileSystem, git, root: input.root, restoreCommit });
2152
- return yield* effect_1.Effect.fail(migrationInterrupted(restoreCommit, restoreSafe));
2283
+ : yield* migrationRecoveryIsSafe({
2284
+ fileSystem,
2285
+ git,
2286
+ root: input.root,
2287
+ restoreCommit: sentinel.restoreCommit,
2288
+ expectedRelativePaths: sentinel.expectedRelativePaths,
2289
+ });
2290
+ return yield* effect_1.Effect.fail(migrationInterrupted(sentinel?.restoreCommit, restoreSafe));
2153
2291
  }
2154
2292
  const inspect = () => currentFormatInspection(fileSystem, input.root);
2155
2293
  const planMigrate = () => effect_1.Effect.gen(function* () {
@@ -2183,14 +2321,32 @@ function openMaintenance(input) {
2183
2321
  const plannedSources = migrationPlanSources.get(currentPlan);
2184
2322
  if (plannedSources === undefined ||
2185
2323
  plannedSources.implementationIdentity !== RECORD_MIGRATION_IMPLEMENTATION_ID ||
2186
- plannedSources.attachments.length !== currentPlan.attachments.length ||
2187
- (currentPlan.root === null) !== (plannedSources.rootBytes === null)) {
2188
- return yield* effect_1.Effect.fail(migrationInvalid(catalog_ts_1.NiceEvalRecordAttachments.observability.family));
2324
+ plannedSources.attachments.length !== currentPlan.attachments.length) {
2325
+ return yield* effect_1.Effect.fail(migrationInvalid("niceeval.core"));
2189
2326
  }
2190
2327
  let portableTargetWritten = false;
2328
+ const expectedRelativePaths = Object.freeze([
2329
+ ...plannedSources.attachments.flatMap((source) => {
2330
+ const base = migrationAttachmentDirectory(input.root, source.location).segments.join("/");
2331
+ return source.rewritePayload
2332
+ ? [
2333
+ `${base}/attachment.json`,
2334
+ `${base}/payload.json`,
2335
+ ...source.removedBlobs.map((blob) => `${base}/blobs/${blob.key}`),
2336
+ ]
2337
+ : [`${base}/attachment.json`];
2338
+ }),
2339
+ ]);
2340
+ const rootBeforeSentinel = yield* fileSystem.readFile({
2341
+ file: (0, services_ts_1.recordPortablePath)(input.root, "record.json"),
2342
+ maximumBytes: format_ts_1.RECORD_FORMAT_DOCUMENT_MAXIMUM_BYTES,
2343
+ });
2344
+ if (rootBeforeSentinel === undefined ||
2345
+ !bytesEqual(rootBeforeSentinel, plannedSources.rootIdentityBytes))
2346
+ return yield* effect_1.Effect.fail(migrationPlanStale());
2191
2347
  // The sentinel is the first portable write. Any later failure or
2192
2348
  // interruption intentionally leaves it behind for Git recovery.
2193
- yield* fileSystem.createMigrationSentinel(input.root, restoreCommit);
2349
+ yield* fileSystem.createMigrationSentinel(input.root, restoreCommit, expectedRelativePaths);
2194
2350
  const sentinelOnly = yield* git.recoveryChangesAreExpected({
2195
2351
  root: input.root,
2196
2352
  restoreCommit,
@@ -2202,31 +2358,15 @@ function openMaintenance(input) {
2202
2358
  }
2203
2359
  yield* effect_1.Effect.gen(function* () {
2204
2360
  for (const source of plannedSources.attachments) {
2205
- yield* migrateObservabilityAttachment({
2361
+ yield* migrateKnownAttachment({
2206
2362
  fileSystem,
2207
2363
  root: input.root,
2364
+ location: source.location,
2208
2365
  target: source.target,
2209
2366
  expectedEnvelopeBytes: source.envelopeBytes,
2210
- });
2211
- portableTargetWritten = true;
2212
- }
2213
- if (plannedSources.rootBytes !== null) {
2214
- const rootPath = (0, services_ts_1.recordPortablePath)(input.root, "record.json");
2215
- const sourceBeforeRootWrite = yield* fileSystem.readFile({
2216
- file: rootPath,
2217
- maximumBytes: format_ts_1.RECORD_FORMAT_DOCUMENT_MAXIMUM_BYTES,
2218
- });
2219
- if (sourceBeforeRootWrite === undefined ||
2220
- !bytesEqual(sourceBeforeRootWrite, plannedSources.rootBytes))
2221
- return yield* effect_1.Effect.fail(migrationPlanStale());
2222
- const encodedRoot = (0, index_ts_1.encodeRecordDocument)(plannedSources.record);
2223
- if (effect_1.Either.isLeft(encodedRoot))
2224
- return yield* effect_1.Effect.fail(migrationInvalid("niceeval.core"));
2225
- yield* fileSystem.writeFile({
2226
- file: rootPath,
2227
- bytes: jsonBytes(encodedRoot.right),
2228
- maximumBytes: format_ts_1.RECORD_FORMAT_DOCUMENT_MAXIMUM_BYTES,
2229
- mode: "replace-no-follow",
2367
+ expectedPayloadBytes: source.payloadBytes,
2368
+ expectedRemovedBlobs: source.removedBlobs,
2369
+ rewritePayload: source.rewritePayload,
2230
2370
  });
2231
2371
  portableTargetWritten = true;
2232
2372
  }
@@ -2235,7 +2375,13 @@ function openMaintenance(input) {
2235
2375
  yield* validateCurrentKnownAttachments({ fileSystem, root: input.root });
2236
2376
  yield* fileSystem.removeMigrationSentinel(input.root);
2237
2377
  }).pipe(effect_1.Effect.catchAll((error) => {
2238
- const recoveryRequired = () => effect_1.Effect.flatMap(migrationRecoveryIsSafe({ fileSystem, git, root: input.root, restoreCommit }), (restoreSafe) => effect_1.Effect.fail(new errors_ts_3.RecordMigrationRecoveryRequired({
2378
+ const recoveryRequired = () => effect_1.Effect.flatMap(migrationRecoveryIsSafe({
2379
+ fileSystem,
2380
+ git,
2381
+ root: input.root,
2382
+ restoreCommit,
2383
+ expectedRelativePaths,
2384
+ }), (restoreSafe) => effect_1.Effect.fail(new errors_ts_3.RecordMigrationRecoveryRequired({
2239
2385
  code: "record-migration-recovery-required",
2240
2386
  causeCode: migrationFailureCode(error),
2241
2387
  restoreCommit,
@@ -2249,7 +2395,11 @@ function openMaintenance(input) {
2249
2395
  }
2250
2396
  return recoveryRequired();
2251
2397
  }));
2252
- return Object.freeze({ state: "migrated", format: identifiers_ts_1.RECORD_FORMAT });
2398
+ return Object.freeze({
2399
+ state: "migrated",
2400
+ format: identifiers_ts_1.RECORD_FORMAT,
2401
+ attachments: currentPlan.attachments,
2402
+ });
2253
2403
  }),
2254
2404
  });
2255
2405
  });