@ref0/git 0.20.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (378) hide show
  1. package/dist/access/private-refs.mjs +1 -1
  2. package/dist/auth/access-jwt.mjs +3 -3
  3. package/dist/auth/auth-namespace.d.mts +3 -3
  4. package/dist/auth/auth-namespace.mjs +3 -2
  5. package/dist/auth/auth.d.mts +3 -3
  6. package/dist/auth/auth.mjs +9 -8
  7. package/dist/auth/authorize.mjs +1 -1
  8. package/dist/auth/fences.d.mts +1 -1
  9. package/dist/auth/host-function.mjs +1 -1
  10. package/dist/auth/host-services.mjs +4 -6
  11. package/dist/auth/identify.d.mts +1 -1
  12. package/dist/auth/identify.mjs +6 -0
  13. package/dist/auth/token-cleanup.mjs +2 -2
  14. package/dist/auth/token-rows.mjs +6 -1
  15. package/dist/auth/token-text.mjs +1 -1
  16. package/dist/auth/tokens-base.d.mts +1 -1
  17. package/dist/auth/tokens.d.mts +1 -1
  18. package/dist/auth/tokens.mjs +1 -1
  19. package/dist/client/client.d.mts +15 -7
  20. package/dist/client/client.mjs +21 -12
  21. package/dist/client/git-http.mjs +1 -1
  22. package/dist/client/local.mjs +60 -24
  23. package/dist/client/negotiate.mjs +3 -3
  24. package/dist/client/push-upload.mjs +26 -10
  25. package/dist/client/remote.mjs +4 -3
  26. package/dist/client/run-remote-helper.d.mts +2 -2
  27. package/dist/client/run-remote-helper.mjs +6 -6
  28. package/dist/client/slice-push.d.mts +1 -1
  29. package/dist/client/transport.mjs +3 -3
  30. package/dist/contracts/blobs.d.mts +3 -3
  31. package/dist/contracts/blobs.mjs +1 -1
  32. package/dist/contracts/calls-spent.mjs +5 -33
  33. package/dist/contracts/client.d.mts +15 -14
  34. package/dist/contracts/commits.d.mts +4 -4
  35. package/dist/contracts/commits.mjs +1 -1
  36. package/dist/contracts/engine.d.mts +2 -2
  37. package/dist/contracts/events.d.mts +1 -1
  38. package/dist/contracts/events.mjs +1 -1
  39. package/dist/contracts/files.d.mts +4 -4
  40. package/dist/contracts/files.mjs +1 -1
  41. package/dist/contracts/forks.d.mts +4 -4
  42. package/dist/contracts/forks.mjs +1 -1
  43. package/dist/contracts/git-hooks.d.mts +1 -1
  44. package/dist/contracts/git.d.mts +9 -5
  45. package/dist/contracts/grants.d.mts +1 -1
  46. package/dist/contracts/merges.d.mts +1 -1
  47. package/dist/contracts/object-values.d.mts +1 -0
  48. package/dist/contracts/object-values.mjs +16 -1
  49. package/dist/contracts/objects.d.mts +20 -17
  50. package/dist/contracts/opaque.mjs +1 -1
  51. package/dist/contracts/operations.mjs +1 -1
  52. package/dist/contracts/queue.d.mts +208 -44
  53. package/dist/contracts/queue.mjs +5 -5
  54. package/dist/contracts/refs.d.mts +5 -5
  55. package/dist/contracts/refs.mjs +1 -1
  56. package/dist/contracts/remote.d.mts +3 -6
  57. package/dist/contracts/repos.d.mts +3 -3
  58. package/dist/contracts/repos.mjs +1 -1
  59. package/dist/contracts/result.d.mts +10 -7
  60. package/dist/contracts/result.mjs +8 -3
  61. package/dist/contracts/rules.d.mts +2 -2
  62. package/dist/contracts/server.d.mts +8 -10
  63. package/dist/contracts/services.d.mts +6 -9
  64. package/dist/contracts/services.mjs +1 -2
  65. package/dist/contracts/signin.d.mts +1 -1
  66. package/dist/contracts/store.d.mts +2 -2
  67. package/dist/contracts/sync.d.mts +63 -6
  68. package/dist/contracts/sync.mjs +3 -2
  69. package/dist/contracts/tags.d.mts +3 -3
  70. package/dist/contracts/tags.mjs +1 -1
  71. package/dist/contracts/tokens.d.mts +2 -2
  72. package/dist/contracts/tokens.mjs +1 -1
  73. package/dist/contracts/topics.d.mts +9 -9
  74. package/dist/contracts/trees.d.mts +4 -4
  75. package/dist/contracts/trees.mjs +1 -1
  76. package/dist/contracts/work.d.mts +4 -4
  77. package/dist/contracts/work.mjs +2 -2
  78. package/dist/core/access.d.mts +1 -1
  79. package/dist/core/ancestry.mjs +30 -34
  80. package/dist/core/{promise.mjs → call-groups.mjs} +7 -30
  81. package/dist/core/call-services.mjs +1 -1
  82. package/dist/core/events/deliver.d.mts +2 -2
  83. package/dist/core/events/deliver.mjs +3 -3
  84. package/dist/core/events/retired.mjs +1 -1
  85. package/dist/core/forks.mjs +5 -5
  86. package/dist/core/hooks/groups.mjs +2 -2
  87. package/dist/core/imports.mjs +101 -21
  88. package/dist/core/index-job.mjs +14 -9
  89. package/dist/core/index-lost.d.mts +1 -1
  90. package/dist/core/loose-tally.mjs +38 -15
  91. package/dist/core/merge-parts.d.mts +17 -4
  92. package/dist/core/merge-parts.mjs +7 -2
  93. package/dist/core/mirror-rows.mjs +31 -1
  94. package/dist/core/objects/blobs.mjs +8 -10
  95. package/dist/core/objects/files.mjs +20 -17
  96. package/dist/core/objects/objects-layer.mjs +1 -1
  97. package/dist/core/objects/peel.mjs +1 -7
  98. package/dist/core/objects/reading.mjs +19 -18
  99. package/dist/core/objects/tree-edits.mjs +1 -1
  100. package/dist/core/objects/trees.mjs +257 -58
  101. package/dist/core/objects/writing.mjs +3 -9
  102. package/dist/core/own-writes.mjs +1 -1
  103. package/dist/core/parts.d.mts +8 -1
  104. package/dist/core/parts.mjs +8 -4
  105. package/dist/core/purge.mjs +31 -18
  106. package/dist/core/push.d.mts +2 -2
  107. package/dist/core/push.mjs +125 -94
  108. package/dist/core/receipts.d.mts +2 -2
  109. package/dist/core/receipts.mjs +9 -2
  110. package/dist/core/ref-index-job.mjs +4 -4
  111. package/dist/core/ref-view.mjs +74 -31
  112. package/dist/core/refs.mjs +3 -3
  113. package/dist/core/repack.mjs +25 -30
  114. package/dist/core/repo-info.mjs +1 -1
  115. package/dist/core/repos.mjs +1 -1
  116. package/dist/core/rules/changes.mjs +18 -40
  117. package/dist/core/rules/check.mjs +6 -5
  118. package/dist/core/rules/commit-changes.mjs +3 -15
  119. package/dist/core/rules/context.d.mts +3 -3
  120. package/dist/core/rules/context.mjs +18 -14
  121. package/dist/core/rules/fetch.mjs +1 -1
  122. package/dist/core/rules/protect.mjs +30 -17
  123. package/dist/core/saved-caller-views.d.mts +1 -1
  124. package/dist/core/saved-caller-views.mjs +3 -3
  125. package/dist/core/saved-callers.d.mts +1 -1
  126. package/dist/core/saved-callers.mjs +1 -1
  127. package/dist/core/seam.d.mts +1 -2
  128. package/dist/core/view.d.mts +6 -3
  129. package/dist/core/view.mjs +11 -10
  130. package/dist/core/work.mjs +2 -2
  131. package/dist/engine/allotted-xdiff.mjs +3 -16
  132. package/dist/engine/combined.d.mts +3 -0
  133. package/dist/engine/combined.mjs +200 -185
  134. package/dist/engine/content.d.mts +2 -2
  135. package/dist/engine/content.mjs +1 -1
  136. package/dist/engine/merge.mjs +7 -9
  137. package/dist/engine/reads.d.mts +2 -2
  138. package/dist/engine/reads.mjs +22 -14
  139. package/dist/engine/xdiff.d.mts +1 -1
  140. package/dist/engine/xdiff.mjs +1 -1
  141. package/dist/event-streams/event-streams.d.mts +1 -1
  142. package/dist/event-streams/event-streams.mjs +1 -1
  143. package/dist/event-streams/stream.d.mts +2 -2
  144. package/dist/event-streams/stream.mjs +3 -3
  145. package/dist/extend.d.mts +2 -6
  146. package/dist/extend.mjs +1 -5
  147. package/dist/http/core-parts.mjs +83 -26
  148. package/dist/http/handler.mjs +54 -9
  149. package/dist/http/parts.d.mts +1 -0
  150. package/dist/http/push-upload-job.mjs +138 -24
  151. package/dist/http/push-uploads.mjs +2 -2
  152. package/dist/http/receive-pack.mjs +14 -53
  153. package/dist/http/request-snapshot.mjs +258 -0
  154. package/dist/http/upload-pack.mjs +23 -18
  155. package/dist/index.d.mts +29 -21
  156. package/dist/index.mjs +11 -2
  157. package/dist/lfs/base.d.mts +1 -1
  158. package/dist/lfs/copy.d.mts +49 -1
  159. package/dist/lfs/copy.mjs +135 -22
  160. package/dist/lfs/layer.d.mts +4 -3
  161. package/dist/lfs/layer.mjs +4 -5
  162. package/dist/lfs/locks.mjs +2 -2
  163. package/dist/lfs/objects.d.mts +1 -1
  164. package/dist/lfs/objects.mjs +3 -3
  165. package/dist/lfs/pointers.mjs +1 -1
  166. package/dist/lfs/rows.d.mts +1 -1
  167. package/dist/lfs/rows.mjs +11 -4
  168. package/dist/lfs/upkeep.mjs +40 -9
  169. package/dist/lfs/uploaded.mjs +1 -1
  170. package/dist/lfs/wire.mjs +1 -1
  171. package/dist/merges/merges.mjs +17 -2
  172. package/dist/protocol/bytes/buffers.d.mts +1 -1
  173. package/dist/protocol/bytes/buffers.mjs +1 -1
  174. package/dist/protocol/bytes/deflate.d.mts +1 -1
  175. package/dist/protocol/bytes/deflate.mjs +1 -1
  176. package/dist/protocol/bytes/inflate.d.mts +1 -1
  177. package/dist/protocol/bytes/inflate.mjs +1 -1
  178. package/dist/protocol/bytes/sha1.d.mts +1 -1
  179. package/dist/protocol/bytes/sha1.mjs +1 -1
  180. package/dist/protocol/diff/read.d.mts +2 -1
  181. package/dist/protocol/diff/read.mjs +102 -8
  182. package/dist/protocol/packs/graph.mjs +1 -1
  183. package/dist/protocol/packs/idx.d.mts +1 -1
  184. package/dist/protocol/packs/idx.mjs +1 -1
  185. package/dist/protocol/packs/parts.mjs +1 -1
  186. package/dist/protocol/packs/reader.d.mts +1 -1
  187. package/dist/protocol/packs/reader.mjs +1 -1
  188. package/dist/protocol/packs/write-error.d.mts +1 -1
  189. package/dist/protocol/packs/write-error.mjs +1 -1
  190. package/dist/protocol/packs/writer.mjs +3 -3
  191. package/dist/protocol/wire/advertisement.d.mts +1 -1
  192. package/dist/protocol/wire/advertisement.mjs +3 -2
  193. package/dist/protocol/wire/fetch.d.mts +1 -1
  194. package/dist/protocol/wire/fetch.mjs +1 -1
  195. package/dist/protocol/wire/lines.d.mts +9 -1
  196. package/dist/protocol/wire/lines.mjs +28 -1
  197. package/dist/protocol/wire/push-uploads.mjs +10 -7
  198. package/dist/protocol/wire/receive-pack.d.mts +1 -1
  199. package/dist/protocol/wire/receive-pack.mjs +1 -1
  200. package/dist/protocol/wire/report-status.d.mts +1 -1
  201. package/dist/protocol/wire/report-status.mjs +1 -1
  202. package/dist/protocol/wire/v2.d.mts +1 -1
  203. package/dist/protocol/wire/v2.mjs +1 -1
  204. package/dist/queue/advance.mjs +31 -24
  205. package/dist/queue/base.d.mts +5 -3
  206. package/dist/queue/calls.mjs +5 -5
  207. package/dist/queue/commit.mjs +1 -1
  208. package/dist/queue/host.d.mts +1 -1
  209. package/dist/queue/layer.d.mts +0 -1
  210. package/dist/queue/layer.mjs +9 -5
  211. package/dist/queue/schedule.mjs +1 -1
  212. package/dist/queue/search.mjs +1 -1
  213. package/dist/queue/state.mjs +1 -1
  214. package/dist/queue/trim.mjs +2 -2
  215. package/dist/rest/client.d.mts +1 -1
  216. package/dist/rest/client.mjs +6 -6
  217. package/dist/rest/errors.mjs +1 -1
  218. package/dist/rest/handler.mjs +2 -2
  219. package/dist/rest/handlers.mjs +16 -6
  220. package/dist/rest/layer.mjs +1 -1
  221. package/dist/rest/listen.mjs +2 -2
  222. package/dist/rest/refs.mjs +1 -1
  223. package/dist/server/edge.mjs +27 -3
  224. package/dist/server/git-layer.d.mts +1 -2
  225. package/dist/server/git-layer.mjs +4 -5
  226. package/dist/server/lifecycle.mjs +1 -1
  227. package/dist/server/registry.mjs +2 -8
  228. package/dist/server/server.mjs +62 -43
  229. package/dist/signin/context.d.mts +1 -1
  230. package/dist/signin/context.mjs +1 -1
  231. package/dist/signin/forms.mjs +1 -1
  232. package/dist/signin/grants.d.mts +2 -2
  233. package/dist/signin/grants.mjs +1 -1
  234. package/dist/signin/wire.mjs +1 -1
  235. package/dist/storage/allotted.mjs +4 -9
  236. package/dist/storage/batch-upkeep.mjs +31 -12
  237. package/dist/storage/batches.d.mts +2 -3
  238. package/dist/storage/batches.mjs +52 -49
  239. package/dist/storage/budget.mjs +23 -1
  240. package/dist/storage/calls.d.mts +1 -1
  241. package/dist/storage/calls.mjs +41 -43
  242. package/dist/storage/charged-cache.mjs +180 -0
  243. package/dist/storage/chunks.d.mts +3 -3
  244. package/dist/storage/chunks.mjs +121 -8
  245. package/dist/storage/counted-bucket.mjs +32 -10
  246. package/dist/storage/fetch-row-cache.d.mts +6 -0
  247. package/dist/storage/fetch-row-cache.mjs +211 -0
  248. package/dist/storage/fetch.d.mts +1 -0
  249. package/dist/storage/fetch.mjs +54 -242
  250. package/dist/storage/held-types.d.mts +0 -1
  251. package/dist/storage/host-bucket.mjs +9 -4
  252. package/dist/storage/index-bitmaps.mjs +77 -49
  253. package/dist/storage/index-build.d.mts +2 -3
  254. package/dist/storage/index-build.mjs +248 -48
  255. package/dist/storage/index-fetch.d.mts +3 -1
  256. package/dist/storage/index-fetch.mjs +60 -21
  257. package/dist/storage/index-graph.mjs +1 -1
  258. package/dist/storage/index-layers.mjs +55 -25
  259. package/dist/storage/index-reach.mjs +15 -22
  260. package/dist/storage/index-whole.d.mts +7 -0
  261. package/dist/storage/index-whole.mjs +145 -37
  262. package/dist/storage/largest-files.mjs +1 -7
  263. package/dist/storage/layout.mjs +17 -1
  264. package/dist/storage/lfs-pointers.mjs +1 -6
  265. package/dist/storage/link-join.mjs +55 -16
  266. package/dist/storage/list-source.d.mts +7 -0
  267. package/dist/storage/list-source.mjs +288 -0
  268. package/dist/storage/loose.d.mts +8 -8
  269. package/dist/storage/loose.mjs +157 -91
  270. package/dist/storage/memory-budget.mjs +226 -22
  271. package/dist/storage/merge-cut.mjs +9 -6
  272. package/dist/storage/merge-fence.mjs +1 -1
  273. package/dist/storage/merge-row.mjs +1 -1
  274. package/dist/storage/merge.d.mts +2 -3
  275. package/dist/storage/merge.mjs +2 -2
  276. package/dist/storage/object-rows.d.mts +3 -3
  277. package/dist/storage/object-rows.mjs +179 -38
  278. package/dist/storage/pack-order.mjs +97 -44
  279. package/dist/storage/pack-ranges.mjs +44 -16
  280. package/dist/storage/pack-reads.d.mts +5 -3
  281. package/dist/storage/pack-reads.mjs +236 -72
  282. package/dist/storage/pack-receive.d.mts +1 -2
  283. package/dist/storage/pack-receive.mjs +21 -17
  284. package/dist/storage/packs.d.mts +1 -1
  285. package/dist/storage/packs.mjs +477 -116
  286. package/dist/storage/placed-reads.mjs +33 -16
  287. package/dist/storage/prune-seen.mjs +1 -1
  288. package/dist/storage/prune-walk.mjs +1 -1
  289. package/dist/storage/prune.mjs +4 -31
  290. package/dist/storage/push-allotment.mjs +26 -14
  291. package/dist/storage/push-uploads.mjs +195 -57
  292. package/dist/storage/pushed-commits.mjs +20 -1
  293. package/dist/storage/quarantine.d.mts +2 -3
  294. package/dist/storage/range-cache.mjs +175 -40
  295. package/dist/storage/raw-ids.mjs +39 -10
  296. package/dist/storage/ready.d.mts +2 -3
  297. package/dist/storage/ready.mjs +114 -38
  298. package/dist/storage/receive-bounds.mjs +31 -9
  299. package/dist/storage/receive-cache.d.mts +7 -0
  300. package/dist/storage/receive-cache.mjs +147 -0
  301. package/dist/storage/receive-files.mjs +1 -1
  302. package/dist/storage/receive-links.mjs +1 -1
  303. package/dist/storage/receive-state.d.mts +2 -2
  304. package/dist/storage/receive-state.mjs +6 -8
  305. package/dist/storage/receive-steps.d.mts +20 -0
  306. package/dist/storage/receive-steps.mjs +298 -13
  307. package/dist/storage/repack-backlog.mjs +1 -6
  308. package/dist/storage/repack-contained.mjs +2 -2
  309. package/dist/storage/repack-job.mjs +1 -1
  310. package/dist/storage/repack.d.mts +2 -3
  311. package/dist/storage/repack.mjs +54 -9
  312. package/dist/storage/request-cache.mjs +57 -0
  313. package/dist/storage/roots.mjs +1 -24
  314. package/dist/storage/rows.d.mts +2 -2
  315. package/dist/storage/rows.mjs +1 -1
  316. package/dist/storage/runs.d.mts +2 -2
  317. package/dist/storage/runs.mjs +1 -1
  318. package/dist/storage/send-list.mjs +62 -25
  319. package/dist/storage/stream-whole.mjs +84 -63
  320. package/dist/storage/swap-walk.mjs +1 -1
  321. package/dist/storage/unpack.mjs +878 -450
  322. package/dist/storage/visible.mjs +110 -32
  323. package/dist/storage/walk.mjs +1 -0
  324. package/dist/storage/wants.mjs +22 -58
  325. package/dist/store/call-count.d.mts +2 -2
  326. package/dist/store/call-count.mjs +24 -11
  327. package/dist/store/catalogue.d.mts +1 -1
  328. package/dist/store/catalogue.mjs +19 -7
  329. package/dist/store/crossing.mjs +1 -7
  330. package/dist/store/cursor-seal.d.mts +1 -1
  331. package/dist/store/cursor-seal.mjs +1 -1
  332. package/dist/store/door.mjs +9 -4
  333. package/dist/store/errors.d.mts +2 -2
  334. package/dist/store/errors.mjs +107 -19
  335. package/dist/store/git-store.mjs +7 -2
  336. package/dist/store/job-try.mjs +90 -9
  337. package/dist/store/list-job.mjs +10 -34
  338. package/dist/store/outbox.d.mts +2 -2
  339. package/dist/store/outbox.mjs +2 -2
  340. package/dist/store/queue-jobs.mjs +6 -12
  341. package/dist/store/records.d.mts +2 -2
  342. package/dist/store/records.mjs +2 -2
  343. package/dist/store/ref-rows.d.mts +2 -2
  344. package/dist/store/ref-rows.mjs +2 -2
  345. package/dist/store/repo-record.d.mts +2 -2
  346. package/dist/store/repo-record.mjs +3 -3
  347. package/dist/store/request-snapshot.mjs +5 -0
  348. package/dist/store/reservations.mjs +2 -2
  349. package/dist/store/topic-jobs.mjs +5 -11
  350. package/dist/sync/bound.d.mts +3 -3
  351. package/dist/sync/bound.mjs +10 -7
  352. package/dist/sync/github.mjs +65 -67
  353. package/dist/sync/http.mjs +1 -1
  354. package/dist/sync/import.mjs +201 -66
  355. package/dist/sync/layer.d.mts +1 -1
  356. package/dist/sync/layer.mjs +6 -6
  357. package/dist/sync/lfs-batch.mjs +1 -1
  358. package/dist/sync/lfs-copy.mjs +175 -15
  359. package/dist/sync/mirror.mjs +5 -10
  360. package/dist/sync/said.mjs +1 -1
  361. package/dist/sync/step.mjs +268 -86
  362. package/dist/sync/tries.mjs +25 -6
  363. package/dist/sync.d.mts +2 -2
  364. package/dist/sync.mjs +2 -2
  365. package/dist/topics/advance.mjs +3 -3
  366. package/dist/topics/calls.mjs +1 -1
  367. package/dist/topics/layer.d.mts +15 -14
  368. package/dist/topics/members.mjs +1 -1
  369. package/dist/topics/topic.mjs +1 -1
  370. package/package.json +3 -13
  371. package/dist/auth/helpers.mjs +0 -17
  372. package/dist/auth.d.mts +0 -5
  373. package/dist/auth.mjs +0 -5
  374. package/dist/core/rules/commit-changes.d.mts +0 -12
  375. package/dist/effect.d.mts +0 -9
  376. package/dist/effect.mjs +0 -7
  377. package/dist/server/joined.d.mts +0 -70
  378. package/dist/server/joined.mjs +0 -41
@@ -4,9 +4,8 @@ import { fromDiff } from "../engine/failures.mjs";
4
4
  import { walkHistory } from "../engine/walk.mjs";
5
5
  import { ReadTally, defaultDiffLimits, drained } from "../protocol/diff/read.mjs";
6
6
  import { decodeCommit, noRepoRoots, parentsWithin } from "../protocol/objects/commit.mjs";
7
- import { CallBudget, budgetedOn, callScope, spentBudget } from "../store/call-count.mjs";
7
+ import { CallBudget, budgetedOn, callScope, inCallScope, spentBudget } from "../store/call-count.mjs";
8
8
  import { isLimitRefusal } from "../store/errors.mjs";
9
- import { runIn } from "../store/crossing.mjs";
10
9
  import * as Effect from "effect/Effect";
11
10
  // src/core/ancestry.ts
12
11
  /**
@@ -125,14 +124,32 @@ const seenOf = (input, limit, walk, scope) => {
125
124
  const read = input.objects.read(input.listed, walk === void 0 ? call : budgetedOn(call, walk));
126
125
  return yield* withinWalks(walk, read);
127
126
  });
127
+ const keep = Effect.fnUntraced(function* (oid, found) {
128
+ if (found.size <= ancestryBytes) room(found.size);
129
+ const data = yield* drained(found, ancestryBytes).pipe(Effect.mapError((error) => error.reason === "object-too-large" ? heldPast() : fromDiff("walk-limit")(error)));
130
+ bytes += data.byteLength;
131
+ cached.set(oid, data);
132
+ const meta = {
133
+ type: found.type,
134
+ size: found.size
135
+ };
136
+ held.set(oid, meta);
137
+ return {
138
+ ...meta,
139
+ bytes: data
140
+ };
141
+ });
128
142
  const type = Effect.fnUntraced(function* (oid) {
129
143
  if (held.has(oid)) return held.get(oid)?.type;
130
144
  const found = yield* fetched(oid);
131
- found?.bytes.cancel();
132
- held.set(oid, found === void 0 ? void 0 : {
133
- type: found.type,
134
- size: found.size
135
- });
145
+ if (found?.type === "commit" && found.size <= ancestryBytes) yield* keep(oid, found);
146
+ else {
147
+ found?.bytes.cancel();
148
+ held.set(oid, found === void 0 ? void 0 : {
149
+ type: found.type,
150
+ size: found.size
151
+ });
152
+ }
136
153
  return found?.type;
137
154
  });
138
155
  const object = Effect.fnUntraced(function* (oid, signal) {
@@ -152,34 +169,13 @@ const seenOf = (input, limit, walk, scope) => {
152
169
  held.set(oid, void 0);
153
170
  return;
154
171
  }
155
- if (found.size <= ancestryBytes) room(found.size);
156
- const data = yield* drained(found, ancestryBytes).pipe(Effect.mapError((error) => error.reason === "object-too-large" ? heldPast() : fromDiff("walk-limit")(error)));
157
- bytes += data.byteLength;
158
- cached.set(oid, data);
159
- held.set(oid, {
160
- type: found.type,
161
- size: found.size
162
- });
163
- return {
164
- type: found.type,
165
- size: found.size,
166
- bytes: data
167
- };
172
+ return yield* keep(oid, found);
168
173
  });
169
- const read = ({ oid, signal }) => runIn(Effect.match(object(oid, signal), {
170
- onSuccess: (value) => ({
171
- kind: "success",
172
- value: value === void 0 ? void 0 : {
173
- ...value,
174
- oid,
175
- bytes: streamOf(value.bytes)
176
- }
177
- }),
178
- onFailure: (error) => ({
179
- kind: "error",
180
- error
181
- })
182
- }), scope, signal);
174
+ const read = ({ oid, signal }) => inCallScope(Effect.map(object(oid, signal), (value) => value === void 0 ? void 0 : {
175
+ ...value,
176
+ oid,
177
+ bytes: streamOf(value.bytes)
178
+ }), scope);
183
179
  return {
184
180
  read,
185
181
  roots: input.roots ?? noRepoRoots,
@@ -1,7 +1,6 @@
1
1
  import { answerSpent } from "../store/errors.mjs";
2
2
  import * as Effect from "effect/Effect";
3
- import * as Schema from "effect/Schema";
4
- Schema.Struct({ signal: Schema.instanceOf(AbortSignal) });
3
+ // src/core/call-groups.ts
5
4
  const isCall = (value) => value instanceof Function;
6
5
  /**
7
6
  * `calls`, each call's Effect as `around` makes it, with the same inputs and answer. A call reads its
@@ -20,17 +19,15 @@ const aroundCalls = (calls, around) => {
20
19
  * it decides with, for a face whose calls need nothing.
21
20
  */
22
21
  const providedCalls = (calls, context) => aroundCalls(calls, (effect) => Effect.provideContext(effect, context));
23
- /** No door at all: the client's, which has no server to close. */
24
- const noDoor = (effect) => effect;
25
22
  /**
26
23
  * `effect` run `through` the server's door: an edge a host calls, where a spent call bound is
27
24
  * answered as its refusal, never a defect. The door refuses once the server is closed and stops
28
- * the run as it closes; the client, with no server, passes `noDoor`. Every Effect face's call goes
29
- * through it, a joined package's `effectRun` and `effectCallsFor` among them (Q830).
25
+ * the run as it closes. Every Effect face's call goes through it, Git's services' among them, as
26
+ * `Git.layer` gives a feature (Q830).
30
27
  */
31
28
  const guardedCall = (through) => (effect) => through(answerSpent(effect));
32
- /** `calls`, each a seam's call that `guardedCall` runs `through` the server's door. */
33
- const guardedCalls = (calls, through) => aroundCalls(calls, guardedCall(through));
29
+ /** `calls`' group `group`, or `undefined` for one it hasn't. */
30
+ const groupOf = (calls, group) => calls[group];
34
31
  /**
35
32
  * Each group `names` holds, each call in it answering `call` with the group's name, its own and its
36
33
  * arguments: a server's calls, made before its runtime is built.
@@ -42,30 +39,10 @@ const lazyGroups = (names, call) => {
42
39
  });
43
40
  return Object.fromEntries(groups);
44
41
  };
45
- /**
46
- * `groups`, with `group` there only while `on()` holds, asked each time it's read or listed: an
47
- * optional group a face names from the start, whose feature attaches after the face was made, as
48
- * `MergeQueue.layer`'s queue does. Until then the face has no such group, as a server with none.
49
- */
50
- const heldGroup = (groups, group, on) => {
51
- if (groups[group] === void 0) return groups;
52
- const hidden = (key) => key === group && !on();
53
- return new Proxy(groups, {
54
- get: (target, key, receiver) => hidden(key) ? void 0 : Reflect.get(target, key, receiver),
55
- has: (target, key) => !hidden(key) && Reflect.has(target, key),
56
- ownKeys: (target) => Reflect.ownKeys(target).filter((key) => !hidden(key)),
57
- getOwnPropertyDescriptor: (target, key) => hidden(key) ? void 0 : Reflect.getOwnPropertyDescriptor(target, key)
58
- });
59
- };
60
- /**
61
- * `callOf`, but `missing` for a group `calls` has none of now, as an optional one is until its
62
- * feature attaches: a face that names every group dispatches each call through this.
63
- */
64
- const callOrMissing = (calls, group, name, missing) => calls[group] === void 0 ? missing : callOf(calls, group, name);
65
42
  /** The call `name` of `calls`' group `group`, which `lazyGroups` names. */
66
43
  const callOf = (calls, group, name) => {
67
- const found = calls[group]?.[name];
44
+ const found = groupOf(calls, group)?.[name];
68
45
  if (!isCall(found)) throw new TypeError(`The server has no call ${group}.${name}`);
69
46
  return found;
70
47
  };
71
- export { aroundCalls, callOf, callOrMissing, guardedCall, guardedCalls, heldGroup, lazyGroups, noDoor, providedCalls };
48
+ export { aroundCalls, callOf, guardedCall, lazyGroups, providedCalls };
@@ -13,7 +13,7 @@ import { fileCalls } from "./objects/files.mjs";
13
13
  import { tagCalls } from "./objects/tags.mjs";
14
14
  import { treeCalls } from "./objects/trees.mjs";
15
15
  import { acting } from "./access.mjs";
16
- import { aroundCalls, providedCalls } from "./promise.mjs";
16
+ import { aroundCalls, providedCalls } from "./call-groups.mjs";
17
17
  import { repoCalls } from "./repos.mjs";
18
18
  import { workCalls } from "./work.mjs";
19
19
  import * as Context from "effect/Context";
@@ -3,9 +3,9 @@ import "../../contracts/objects.mjs";
3
3
  import "../../contracts/git-events.mjs";
4
4
  import { GitError } from "../../contracts/result.mjs";
5
5
  import "../../store/outbox.mjs";
6
- import * as Effect from "effect/Effect";
7
- import "effect/Schema";
8
6
  import { CurrentJob, Failure, Job, JobDefinition, JobInput, JobQueue, JobRef, Moment, Records, Retry, Row, Scope } from "@ref0/infra";
7
+ import "effect/Schema";
8
+ import * as Effect from "effect/Effect";
9
9
  /**
10
10
  * A job's `onFailure` that writes `repo.work.failed`, as `workFailed` makes it: any job's, since
11
11
  * it reads the job from `CurrentJob` and not its data.
@@ -11,9 +11,9 @@ import { decodeRow, storeCall, storeCommit } from "../../store/errors.mjs";
11
11
  import { Delivered, FailedTry, Follower, appendEvents, cursorId, cursorRead, decodeLeading, decodeOutbox, decodeStamps, deliveryCursorId, eventBytes, eventId, eventLimits, failedKeyOf, failedPrefix, headKey, outboxCollections, outboxReads, repoEnvelope, rowBytes, shownEvent } from "../../store/outbox.mjs";
12
12
  import { gitJob } from "../../store/job-try.mjs";
13
13
  import { newChangeId, repoScope, scopeRepo, selfKey } from "../../store/scopes.mjs";
14
- import * as Effect from "effect/Effect";
15
- import * as Schema from "effect/Schema";
16
14
  import { CurrentJob, Job, isInfraError, limits } from "@ref0/infra";
15
+ import * as Schema from "effect/Schema";
16
+ import * as Effect from "effect/Effect";
17
17
  // src/core/events/deliver.ts
18
18
  /** What each delivery's job name starts with: `git.deliver.<name>`. */
19
19
  const deliverJobPrefix = "git.deliver.";
@@ -895,4 +895,4 @@ const deliveryJob = (parts, log, delivery) => {
895
895
  const onFailure = workFailed(parts.store, log, parts.now, tried);
896
896
  return gitJob(DeliverJob, handler, { onFailure });
897
897
  };
898
- export { DeliverData, checkDeliveries, checkDeliveryName, checkDeliveryTimeout, defaultDeliverRetry, deliverJobKey, deliverJobName, deliverTry, deliveryLog, drainCeiling, droppedDelivery, isDeliverJob, keptFor, notFailed, sentThrough, skipFailed, workFailed };
898
+ export { DeliverData, checkDeliveries, checkDeliveryName, checkDeliveryTimeout, defaultDeliverRetry, deliverJobKey, deliverJobName, deliverTry, deliveryLog, deliveryOf, drainCeiling, droppedDelivery, isDeliverJob, keptFor, notFailed, sentThrough, skipFailed, workFailed };
@@ -2,9 +2,9 @@ import { gitError } from "../../contracts/result.mjs";
2
2
  import { decodeRow, storeCall, storeCommit } from "../../store/errors.mjs";
3
3
  import { catalogueScope, collections, newChangeId } from "../../store/scopes.mjs";
4
4
  import { checkDeliveryName } from "./deliver.mjs";
5
+ import * as Schema from "effect/Schema";
5
6
  import * as Effect from "effect/Effect";
6
7
  import * as Ref from "effect/Ref";
7
- import * as Schema from "effect/Schema";
8
8
  /**
9
9
  * Throws an `INVALID_ARGUMENT` `GitError` unless `retired`, a host's `events.retired`, names at
10
10
  * most `retiredLimit` deliveries, each once, each under a delivery name's rules, and none of
@@ -1,6 +1,6 @@
1
1
  import { isRepoName } from "../contracts/ids.mjs";
2
2
  import { fail } from "../contracts/result.mjs";
3
- import { abandonedRow, awaitingUpkeep, batchesRead, fastPath, openBatch, publication, stageRows, stageRowsCalls, stageRowsCounter, stagedBytes, storeSkew } from "../storage/batches.mjs";
3
+ import { abandonedRow, awaitingUpkeep, batchesRead, fastPath, openBatch, stageRows, stageRowsCalls, stageRowsCounter, stagedBytes, stagedPublication, storeSkew } from "../storage/batches.mjs";
4
4
  import { oneShotReads } from "../storage/calls.mjs";
5
5
  import { chunkCopyCalls, chunkedMoved, chunkedOf, chunkedRow, copyChunks } from "../storage/chunks.mjs";
6
6
  import { indexRowKey, isPackId, objectCollections } from "../storage/layout.mjs";
@@ -40,10 +40,10 @@ import { anyOwned, refViewIn } from "./ref-view.mjs";
40
40
  import { SealedObjects } from "./view.mjs";
41
41
  import { CoreParts, ObjectsParts } from "./parts.mjs";
42
42
  import { check } from "../contracts/authorize.mjs";
43
- import * as Clock from "effect/Clock";
44
- import * as Effect from "effect/Effect";
45
43
  import { jsonBytes, limits } from "@ref0/infra";
44
+ import * as Effect from "effect/Effect";
46
45
  import * as Context from "effect/Context";
46
+ import * as Clock from "effect/Clock";
47
47
  // src/core/forks.ts
48
48
  /**
49
49
  * A fork reads its source's refs and packs whole, then copies only the refs its caller sees there
@@ -1042,7 +1042,7 @@ const forkCalls = (bound) => {
1042
1042
  const covered = [...read.listed.packs.flatMap(({ id }) => isPackId(id) ? [leavingKey(id)] : []), ...[...marked.keys()].flatMap((id) => isPackId(id) ? [coverKey(id, tried)] : [])];
1043
1043
  const pushed = read.refs.length === 0 ? [] : [timeRow(pushedKey, void 0, at)];
1044
1044
  const loose = looseRows(void 0, staged?.moved ?? rowsPut(objects));
1045
- const published = staged === void 0 ? [] : publication(staged.batch, [], staged.moved, at).put ?? [];
1045
+ const published = staged === void 0 ? [] : stagedPublication(staged.batch, staged.moved, at).put ?? [];
1046
1046
  const abandoned = batches.flatMap((batch) => batch === staged?.batch ? [] : [abandonedRow(batch)]);
1047
1047
  const rooted = yield* rootsCopied(noRepoRoots, read, []);
1048
1048
  const rows = [
@@ -1421,7 +1421,7 @@ const forkCalls = (bound) => {
1421
1421
  const held = counted.results[0]?.length ?? 0;
1422
1422
  if (held >= 16) return yield* Effect.fail(awaitingUpkeep(held, 16));
1423
1423
  }
1424
- const published = staged === void 0 ? [] : publication(staged.batch, [], staged.moved, into.at).put ?? [];
1424
+ const published = staged === void 0 ? [] : stagedPublication(staged.batch, staged.moved, into.at).put ?? [];
1425
1425
  const abandoned = batches.flatMap((batch) => batch === staged?.batch ? [] : [abandonedRow(batch)]);
1426
1426
  const addable = source.listed.packs.filter(({ id }) => !listing.has(id));
1427
1427
  const weighed = [...into.owned, ...addable];
@@ -46,7 +46,7 @@ const runHookGroups = /* @__PURE__ */ Effect.fnUntraced(function* (groups, check
46
46
  const lost = left.length < write.updates.length;
47
47
  if (left.length === 0 || write.atomic && lost) return void 0;
48
48
  const { about } = checking;
49
- const input = pushContextOf(checking, left, {
49
+ const { input, provide } = pushContextOf(checking, left, {
50
50
  key: "",
51
51
  updates: left
52
52
  }, { atomic: write.atomic });
@@ -58,7 +58,7 @@ const runHookGroups = /* @__PURE__ */ Effect.fnUntraced(function* (groups, check
58
58
  label,
59
59
  timeout: handler.timeout
60
60
  };
61
- const call = hostEffect("hooks", about, checkedAnswer(label, plainAnswer, () => check(input)), options);
61
+ const call = hostEffect("hooks", about, provide(checkedAnswer(label, plainAnswer, () => check(input))), options);
62
62
  const refusal = yield* Effect.matchEffect(call, {
63
63
  onFailure: (error) => Effect.succeed(error),
64
64
  onSuccess: (answer) => {
@@ -1,20 +1,21 @@
1
+ import { fail, gitError } from "../contracts/result.mjs";
1
2
  import { ImportDepth, ImportLfsReason, SyncSource } from "../contracts/sync.mjs";
2
3
  import { readAsked } from "./asked.mjs";
3
- import { KeptError, keptError } from "./receipts.mjs";
4
+ import { KeptError } from "./receipts.mjs";
4
5
  import { SavedCaller } from "./saved-callers.mjs";
5
6
  import { hexOf } from "../protocol/bytes/hex.mjs";
7
+ import { Sha256State } from "../protocol/bytes/sha256.mjs";
6
8
  import { oidBytes } from "../protocol/packs/idx.mjs";
7
9
  import { decodeRow, storeCall, storeCommit } from "../store/errors.mjs";
8
- import { importJobName } from "../store/records.mjs";
10
+ import { RepoRootsRow, importJobName } from "../store/records.mjs";
9
11
  import { refRowBytes, storesPeel } from "../store/ref-rows.mjs";
10
12
  import { isPackId } from "../storage/layout.mjs";
11
- import { receiveKey } from "../storage/receive-steps.mjs";
13
+ import { StagePart, receiveKey } from "../storage/receive-steps.mjs";
12
14
  import { collections, newChangeId, repoScope } from "../store/scopes.mjs";
13
- import { gitError } from "../contracts/result.mjs";
14
- import * as Effect from "effect/Effect";
15
+ import { jsonBytes } from "@ref0/infra";
15
16
  import * as Schema from "effect/Schema";
17
+ import * as Effect from "effect/Effect";
16
18
  import * as Result from "effect/Result";
17
- import { jsonBytes } from "@ref0/infra";
18
19
  import * as Base64 from "effect/encoding/Base64";
19
20
  // src/core/imports.ts
20
21
  /**
@@ -59,11 +60,28 @@ const ImportReceiving = /* @__PURE__ */ Schema.Struct({
59
60
  })
60
61
  });
61
62
  /**
63
+ * The copy of one object past a step's bytes, in parts across tries (#2989): its `oid` and `size`,
64
+ * its stage's `key` and staging row `staged`, the multipart upload's `token`, the `offset` its
65
+ * `parts` reach, and SHA-256's running state over those bytes, so a try goes on from the last part
66
+ * and the whole is checked against the oid before the upload completes.
67
+ */
68
+ const ImportLfsCopying = /* @__PURE__ */ Schema.Struct({
69
+ oid: Schema.String,
70
+ size: Schema.Int,
71
+ key: Schema.String,
72
+ staged: Schema.String,
73
+ token: Schema.String,
74
+ offset: Schema.Int,
75
+ parts: Schema.Array(StagePart),
76
+ sha256: Sha256State
77
+ });
78
+ /**
62
79
  * An import's copy of the Git LFS objects its history points at: `pages` of pointers, which each
63
80
  * segment's landing writes beside the record as its receive found them, as `lfsPageKey` says; the
64
- * copy's cursor, entry `entry` of page `page`; and what it has done so far, `copied` objects of
81
+ * copy's cursor, entry `entry` of page `page`; what it has done so far, `copied` objects of
65
82
  * `bytes`, `missing`, those the source didn't give, and `named`, how many of them the record
66
- * names, as `missedCounted` counts them.
83
+ * names, as `missedCounted` counts them; and `copying`, the object at the cursor while it goes in
84
+ * parts.
67
85
  */
68
86
  const ImportLfs = /* @__PURE__ */ Schema.Struct({
69
87
  pages: Schema.Int,
@@ -72,7 +90,8 @@ const ImportLfs = /* @__PURE__ */ Schema.Struct({
72
90
  copied: Schema.Int,
73
91
  bytes: Schema.Int,
74
92
  missing: Schema.Int,
75
- named: Schema.Int
93
+ named: Schema.Int,
94
+ copying: Schema.optionalKey(ImportLfsCopying)
76
95
  });
77
96
  /** An import's LFS copy before its first page. */
78
97
  const noImportLfs = {
@@ -84,6 +103,23 @@ const noImportLfs = {
84
103
  missing: 0,
85
104
  named: 0
86
105
  };
106
+ /** Keyed deepen receipt reference stored on `ImportDeepen` so publish, fail, and cancel update it atomically. */
107
+ const DeepenReceipt = /* @__PURE__ */ Schema.Struct({
108
+ id: Schema.String,
109
+ input: Schema.String,
110
+ at: Schema.Int
111
+ });
112
+ /**
113
+ * A deepen's own state on `imports/self`, absent for an initial import: `run`, the execution's
114
+ * unique ID; `more`, how many commits deeper to fetch past the starting roots (left out for an
115
+ * unshallow); and `receipt`, the keyed receipt to record the terminal outcome in. The starting
116
+ * roots themselves live in `imports/start-roots` so `imports/self` holds at most two root arrays.
117
+ */
118
+ const ImportDeepen = /* @__PURE__ */ Schema.Struct({
119
+ run: Schema.String,
120
+ more: Schema.optionalKey(ImportDepth),
121
+ receipt: Schema.optionalKey(DeepenReceipt)
122
+ });
87
123
  /**
88
124
  * An import's record. `by`: who started it, as `SavedCaller` keeps them, asked again before each
89
125
  * step, so the import fetches, publishes and offers the remote only what they may still see.
@@ -92,6 +128,7 @@ const ImportRow = /* @__PURE__ */ Schema.Struct({
92
128
  source: SyncSource,
93
129
  by: SavedCaller,
94
130
  depth: Schema.optionalKey(ImportDepth),
131
+ deepen: Schema.optionalKey(ImportDeepen),
95
132
  state: Schema.Literals([
96
133
  "running",
97
134
  "done",
@@ -127,6 +164,38 @@ const cancelKey = {
127
164
  collection: collections.imports,
128
165
  id: "cancel"
129
166
  };
167
+ /**
168
+ * A deepen's immutable starting shallow roots, stored beside `imports/self` so staged `ImportRow`
169
+ * commits hold at most two root arrays (`row.roots` and `receiving.lands.roots`) and fit infra's
170
+ * 1 MiB value limit across the full supported root frontier.
171
+ */
172
+ const startRootsKey = {
173
+ collection: collections.imports,
174
+ id: "start-roots"
175
+ };
176
+ const startRootsRow = (roots) => ({
177
+ ...startRootsKey,
178
+ value: { roots: [...roots] }
179
+ });
180
+ /** Decodes a deepen's starting shallow roots row read from `imports/start-roots`. */
181
+ const startRootsOf = (rows) => {
182
+ const held = rows?.[0];
183
+ return held === void 0 ? fail("DATA_LOSS", "Deepen start roots missing", { hint: failedHint }) : Effect.map(decodeRow(RepoRootsRow, held, "Deepen start roots"), (row) => row.roots);
184
+ };
185
+ /** Optional receipt row updating a keyed deepen's receipt with its terminal `info` or `error`. */
186
+ const deepenReceiptPut = (deepen, outcome) => deepen?.receipt === void 0 ? [] : [{
187
+ collection: collections.receipts,
188
+ id: deepen.receipt.id,
189
+ value: {
190
+ input: deepen.receipt.input,
191
+ at: deepen.receipt.at,
192
+ answer: {
193
+ kind: "deepen",
194
+ run: deepen.run,
195
+ ...outcome
196
+ }
197
+ }
198
+ }];
130
199
  const importRow = (value) => ({
131
200
  ...importKey,
132
201
  value
@@ -248,8 +317,9 @@ const readLfsPage = /* @__PURE__ */ Effect.fnUntraced(function* (store, internal
248
317
  * receiving in steps, whose keys the quarantine's clean-up takes, and the pages of tips it hasn't
249
318
  * published.
250
319
  */
251
- const importEndDeletes = (row) => [
320
+ const importEndDeletes = (row, keepStartRoots = false) => [
252
321
  { ...cutKey },
322
+ ...keepStartRoots ? [] : [{ ...startRootsKey }],
253
323
  ...row?.receiving === void 0 ? [] : [receiveKey(row.receiving.pack)],
254
324
  ...tipPageKeys(row?.publishedPages ?? 0, row?.tipPages ?? 0),
255
325
  ...lfsPageKeys(row?.lfs?.page ?? 0, row?.lfs?.pages ?? 0)
@@ -340,16 +410,26 @@ const failedRow = (row, error) => ({
340
410
  });
341
411
  /** What a failed import's error says to do: no try comes after the last, whatever it said. */
342
412
  const failedHint = "Delete the repo, then import it again";
343
- const stoppedTry = keptError(gitError("UNAVAILABLE", "The import's last try stopped", { hint: failedHint }));
413
+ const stoppedTry = {
414
+ code: "UNAVAILABLE",
415
+ message: "The import's last try stopped",
416
+ hint: failedHint
417
+ };
418
+ const stoppedDeepen = {
419
+ code: "UNAVAILABLE",
420
+ message: "The deepen's last try stopped",
421
+ hint: "Deepen again with a new key"
422
+ };
344
423
  /**
345
424
  * The repo's import row, cancel row and cut, in one read: with `asked`, its record too, held to it
346
- * as `asAsked` says.
425
+ * as `asAsked` says, and any `extra` reads in the same snapshot.
347
426
  */
348
- const readImport = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, asked) {
427
+ const readImport = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, asked, extra = []) {
349
428
  const reads = [
350
429
  { ...importKey },
351
430
  { ...cancelKey },
352
- { ...cutKey }
431
+ { ...cutKey },
432
+ ...extra
353
433
  ];
354
434
  const snapshot = yield* readAsked(store, internalId, reads, [], asked);
355
435
  const [[own] = [], [cancel] = [], [held] = []] = snapshot.results;
@@ -359,7 +439,8 @@ const readImport = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalI
359
439
  row,
360
440
  cancelled: cancel !== void 0,
361
441
  cut,
362
- version: snapshot.version
442
+ version: snapshot.version,
443
+ extra: snapshot.results.slice(3)
363
444
  };
364
445
  });
365
446
  /** What a repo's import's state reads of its scope: its row, its cancel row and its missed LFS objects. */
@@ -403,10 +484,8 @@ const importStatusOf = /* @__PURE__ */ Effect.fnUntraced(function* (results) {
403
484
  }
404
485
  };
405
486
  });
406
- /** `JoinedCalls.importState`: `importStatusOf` the repo `internalId` holds, in one read. */
407
- const importStateOf = (store, internalId) => Effect.flatMap(readAsked(store, internalId, importReads, []), (snapshot) => importStatusOf(snapshot.results));
408
487
  /** Whether the repo's `sync.import` job is waiting or running: a try is due or under way. */
409
- const jobLive = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId) {
488
+ const importJobLive = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId) {
410
489
  const scope = repoScope(internalId);
411
490
  let after;
412
491
  for (;;) {
@@ -432,14 +511,15 @@ const importLive = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalI
432
511
  const read = yield* readImport(store, internalId);
433
512
  const { row } = read;
434
513
  if (row?.state !== "running" || read.cancelled) return false;
435
- if (yield* jobLive(store, internalId)) return true;
514
+ if (yield* importJobLive(store, internalId)) return true;
515
+ const stopped = row.deepen !== void 0 ? stoppedDeepen : stoppedTry;
436
516
  if ((yield* storeCommit(store.commit(repoScope(internalId), {
437
517
  id: newChangeId(),
438
518
  expect: read.version,
439
- put: [importRow(failedRow(row, stoppedTry))],
519
+ put: [importRow(failedRow(row, stopped)), ...deepenReceiptPut(row.deepen, { error: stopped })],
440
520
  delete: importEndDeletes(row)
441
521
  }))).ok) return false;
442
522
  }
443
523
  return true;
444
524
  });
445
- export { ImportLfs, ImportReceiving, ImportRow, cancelKey, cutKey, cutRow, failedHint, failedRow, importEndDeletes, importKey, importLfsMissedMost, importLfsPagesMost, importLive, importReads, importRow, importStateOf, importStatusOf, lfsMissedHeld, lfsPageKey, lfsPageRow, missedCounted, noImportLfs, readImport, readLfsPage, readTipPages, stoppedTry, tipPageKey, tipPageRow, tipPagesOf, tipRowBytes };
525
+ export { DeepenReceipt, ImportDeepen, ImportLfs, ImportLfsCopying, ImportReceiving, ImportRow, cancelKey, cutKey, cutRow, deepenReceiptPut, failedHint, failedRow, importEndDeletes, importJobLive, importKey, importLfsMissedMost, importLfsPagesMost, importLive, importReads, importRow, importStatusOf, lfsMissedHeld, lfsPageKey, lfsPageRow, missedCounted, noImportLfs, readImport, readLfsPage, readTipPages, startRootsKey, startRootsOf, startRootsRow, stoppedDeepen, stoppedTry, tipPageKey, tipPageRow, tipPagesOf, tipRowBytes };
@@ -11,16 +11,17 @@ import { WholeRepo, wholeRefs } from "../store/ref-rows.mjs";
11
11
  import { readRecord, rootsOf } from "../store/repo-record.mjs";
12
12
  import { budgetMade, budgetMost, budgetedInput, callScope, nestsIn, spentBudget } from "../store/call-count.mjs";
13
13
  import { ownSpentOf, spentOf } from "../contracts/calls-spent.mjs";
14
- import { gitJob } from "../store/job-try.mjs";
14
+ import { gitJob, jobTryTimeout } from "../store/job-try.mjs";
15
15
  import { collections, jobRepo, looseKey, newChangeId, repoRootsKey, repoScope } from "../store/scopes.mjs";
16
16
  import { settleName } from "../store/settle.mjs";
17
17
  import { SealedObjects } from "./view.mjs";
18
18
  import { fail } from "../contracts/result.mjs";
19
- import * as Effect from "effect/Effect";
19
+ import { CurrentJob, Job } from "@ref0/infra";
20
20
  import * as Schema from "effect/Schema";
21
+ import * as Effect from "effect/Effect";
21
22
  import * as Cause from "effect/Cause";
22
23
  import * as Exit from "effect/Exit";
23
- import { CurrentJob, Job } from "@ref0/infra";
24
+ import * as Equal from "effect/Equal";
24
25
  import * as DateTime from "effect/DateTime";
25
26
  // src/core/index-job.ts
26
27
  /**
@@ -297,11 +298,13 @@ const chainsWithin = (made, most) => made.bucket <= .25 * most.bucket && made.su
297
298
  const callsLeft = Effect.map(callScope, ({ budget }) => budget === void 0 ? true : chainsWithin(budgetMade(budget), budgetMost(budget)));
298
299
  /**
299
300
  * Whether a try that started at `start` runs another step after `attempt`: one that ended with
300
- * the next step due now, a `more` or a landed row's prune, over a small repo, with the try's
301
- * wall time so far, which its CPU is no more than, and its calls each within `chainedShare`.
301
+ * the next step due now, a `more` that moved on from `given`, the data its step was given, or a
302
+ * landed row's prune, over a small repo, with the try's wall time so far, which its CPU is no more
303
+ * than, and its calls each within `chainedShare`.
302
304
  */
303
- const chainsOn = (parts, attempt, start, signal) => {
305
+ const chainsOn = (parts, attempt, given, start, signal) => {
304
306
  if (!(attempt.ended === "more" || attempt.ended === "landed") || attempt.small !== true || signal.aborted) return Effect.succeed(false);
307
+ if (attempt.ended === "more" && Equal.equals(attempt.next?.data, given)) return Effect.succeed(false);
305
308
  const cpuMs = parts.cpuMs ?? 3e4;
306
309
  return Effect.flatMap(parts.now, (now) => now - start >= .25 * cpuMs ? Effect.succeed(false) : callsLeft);
307
310
  };
@@ -325,10 +328,12 @@ const spentElsewhere = (cause) => Effect.map(callScope, ({ budget }) => {
325
328
  */
326
329
  const indexTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, internalId, data, signal, round, chains) {
327
330
  const start = yield* parts.now;
331
+ let given = data;
328
332
  let attempt = yield* indexAttempt(parts, store, internalId, data, signal, round);
329
- while (chains && attempt.next !== void 0 && (yield* chainsOn(parts, attempt, start, signal))) {
333
+ while (chains && attempt.next !== void 0 && (yield* chainsOn(parts, attempt, given, start, signal))) {
330
334
  const next = attempt.next;
331
- const chained = yield* Effect.exit(indexAttempt(parts, store, internalId, next.data ?? {}, signal, round, { chained: true }));
335
+ given = next.data ?? {};
336
+ const chained = yield* Effect.exit(indexAttempt(parts, store, internalId, given, signal, round, { chained: true }));
332
337
  if (Exit.isFailure(chained)) {
333
338
  if (Cause.hasInterrupts(chained.cause) || (yield* spentElsewhere(chained.cause))) return yield* Effect.failCause(chained.cause);
334
339
  yield* Effect.logDebug("git.index ends a try at a step that failed after another", chained.cause);
@@ -397,7 +402,7 @@ const refusalWrites = 3;
397
402
  */
398
403
  const IndexJob = /* @__PURE__ */ Job.make(indexJobName, {
399
404
  payload: IndexJobData,
400
- timeout: "13 minutes",
405
+ timeout: jobTryTimeout,
401
406
  concurrency: 1,
402
407
  retry: {
403
408
  limit: 25,
@@ -1,8 +1,8 @@
1
1
  import { InternalRepoId } from "../contracts/ids.mjs";
2
2
  import "../contracts/objects.mjs";
3
3
  import { Listed } from "../contracts/store.mjs";
4
- import * as Effect from "effect/Effect";
5
4
  import { JobInput, Moment, Records, Row } from "@ref0/infra";
5
+ import * as Effect from "effect/Effect";
6
6
  /**
7
7
  * A read's ask for the rebuild of the `index` row it read, `row`, once the index it names failed
8
8
  * its own checks: `listed` is the listing the read was at.
@@ -2,39 +2,62 @@ import { objectCollections } from "../storage/layout.mjs";
2
2
  import { storeCall } from "../store/errors.mjs";
3
3
  import { rowBytes } from "../store/outbox.mjs";
4
4
  import { repoScope } from "../store/scopes.mjs";
5
- import * as Effect from "effect/Effect";
6
5
  import { limits } from "@ref0/infra";
6
+ import * as Effect from "effect/Effect";
7
7
  // src/core/loose-tally.ts
8
8
  /**
9
9
  * How `change` moves the repo's object rows committed at `version`: its `rows`, less each object
10
- * row it puts that the repo holds already, which the put only writes again (#2237). Each row is
11
- * counted by its ID, a store read of `limits.counts` at a time: `undefined` when one answers past
12
- * `version`, since a commit that expects it then misses anyway, and its next try counts again.
10
+ * row it puts that the repo holds already, which the put only writes again (#2237). `preCounted`
11
+ * holds counts already read at `version` (for example in `finalRead`'s own `counts[]`); any
12
+ * remaining rows are counted a store read of `limits.counts` at a time, returning `undefined` when
13
+ * a read answers past `version`, since a commit that expects it then misses anyway.
13
14
  */
14
- const rowsAtCommit = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, change, version) {
15
+ const rowsAtCommit = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, change, version, preCounted = []) {
15
16
  const puts = (change.put ?? []).filter((row) => row.collection === objectCollections.objects);
16
17
  const scope = repoScope(internalId);
17
18
  let objects = change.rows.objects;
18
19
  let bytes = change.rows.bytes;
19
- for (let at = 0; at < puts.length; at += limits.counts) {
20
- const batch = puts.slice(at, at + limits.counts);
21
- const counts = batch.map((row) => ({
20
+ const counts = [...preCounted];
21
+ for (let at = counts.length; at < puts.length; at += limits.counts) {
22
+ const batch = puts.slice(at, at + limits.counts).map((row) => ({
22
23
  collection: row.collection,
23
24
  prefix: row.id
24
25
  }));
25
- const snapshot = yield* storeCall(store.read(scope, [], counts));
26
+ const snapshot = yield* storeCall(store.read(scope, [], batch));
26
27
  if (snapshot.version !== version) return void 0;
27
- for (const [index, row] of batch.entries()) {
28
- if ((snapshot.counts[index] ?? 0) === 0) continue;
29
- objects -= 1;
30
- bytes -= rowBytes(row);
31
- }
28
+ counts.push(...snapshot.counts);
29
+ }
30
+ for (const [index, row] of puts.entries()) {
31
+ if ((counts[index] ?? 0) === 0) continue;
32
+ objects -= 1;
33
+ bytes -= rowBytes(row);
32
34
  }
33
35
  return {
34
36
  objects,
35
37
  bytes
36
38
  };
37
39
  });
40
+ /**
41
+ * Whether every object row `change` deletes still exists at `version`, counted in `storeLimits.counts`
42
+ * batches: `'holds'` when every key has count 1 at `version`, `'moved'` when another write moved the
43
+ * store past `version` before all batches finished (with every count read so far at 1), and `'gone'`
44
+ * when any key is missing (for example after a competing fold).
45
+ */
46
+ const deletedRowsHold = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, change, version) {
47
+ const deleted = (change.delete ?? []).filter((key) => key.collection === objectCollections.objects);
48
+ if (deleted.length === 0) return "holds";
49
+ const scope = repoScope(internalId);
50
+ for (let at = 0; at < deleted.length; at += limits.counts) {
51
+ const batch = deleted.slice(at, at + limits.counts).map((key) => ({
52
+ collection: key.collection,
53
+ prefix: key.id
54
+ }));
55
+ const snapshot = yield* storeCall(store.read(scope, [], batch));
56
+ if (snapshot.counts.some((count) => count !== 1)) return "gone";
57
+ if (snapshot.version !== version) return "moved";
58
+ }
59
+ return "holds";
60
+ });
38
61
  /** `rows`' object rows as `ObjectsChange.rows` counts a put of them: each as new. */
39
62
  const rowsPut = (rows) => rows.reduce((moved, row) => row.collection === objectCollections.objects ? {
40
63
  objects: moved.objects + 1,
@@ -43,4 +66,4 @@ const rowsPut = (rows) => rows.reduce((moved, row) => row.collection === objectC
43
66
  objects: 0,
44
67
  bytes: 0
45
68
  });
46
- export { rowsAtCommit, rowsPut };
69
+ export { deletedRowsHold, rowsAtCommit, rowsPut };