@ref0/git 0.14.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 (492) hide show
  1. package/dist/access/private-refs.mjs +1 -1
  2. package/dist/auth/access-jwt.mjs +4 -4
  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 +4 -4
  8. package/dist/auth/fences.d.mts +1 -2
  9. package/dist/auth/fences.mjs +3 -3
  10. package/dist/auth/grants.mjs +4 -4
  11. package/dist/auth/host-function.mjs +19 -2
  12. package/dist/auth/host-services.mjs +4 -6
  13. package/dist/auth/identify.d.mts +1 -1
  14. package/dist/auth/identify.mjs +9 -3
  15. package/dist/auth/token-cleanup.mjs +67 -0
  16. package/dist/auth/token-rows.mjs +7 -2
  17. package/dist/auth/token-text.mjs +9 -1
  18. package/dist/auth/tokens-base.d.mts +35 -0
  19. package/dist/auth/tokens-base.mjs +13 -0
  20. package/dist/auth/tokens-layer.d.mts +2 -27
  21. package/dist/auth/tokens-layer.mjs +6 -11
  22. package/dist/auth/tokens-public.d.mts +3 -3
  23. package/dist/auth/tokens.d.mts +7 -10
  24. package/dist/auth/tokens.mjs +10 -81
  25. package/dist/client/answer.mjs +21 -42
  26. package/dist/client/client.d.mts +17 -11
  27. package/dist/client/client.mjs +21 -12
  28. package/dist/client/git-http.mjs +18 -8
  29. package/dist/client/local.mjs +74 -37
  30. package/dist/client/negotiate.mjs +3 -3
  31. package/dist/client/push-upload.mjs +34 -17
  32. package/dist/client/remote.mjs +12 -13
  33. package/dist/client/run-remote-helper.d.mts +2 -1
  34. package/dist/client/run-remote-helper.mjs +61 -27
  35. package/dist/client/slice-push.d.mts +1 -1
  36. package/dist/client/transport.mjs +105 -46
  37. package/dist/contracts/blobs.d.mts +58 -11
  38. package/dist/contracts/blobs.mjs +17 -3
  39. package/dist/contracts/call-allowance.d.mts +13 -0
  40. package/dist/contracts/call-allowance.mjs +44 -0
  41. package/dist/contracts/calls-spent.mjs +12 -35
  42. package/dist/contracts/client.d.mts +18 -18
  43. package/dist/contracts/commits.d.mts +28 -28
  44. package/dist/contracts/commits.mjs +1 -1
  45. package/dist/contracts/engine.d.mts +8 -3
  46. package/dist/contracts/engine.mjs +10 -1
  47. package/dist/contracts/events.d.mts +1 -1
  48. package/dist/contracts/events.mjs +1 -1
  49. package/dist/contracts/files.d.mts +14 -14
  50. package/dist/contracts/files.mjs +1 -1
  51. package/dist/contracts/forks.d.mts +21 -21
  52. package/dist/contracts/forks.mjs +1 -1
  53. package/dist/contracts/git-events.d.mts +29 -1
  54. package/dist/contracts/git-hooks.d.mts +2 -2
  55. package/dist/contracts/git.d.mts +30 -5
  56. package/dist/contracts/grants.d.mts +24 -4
  57. package/dist/contracts/handlers.d.mts +1 -1
  58. package/dist/contracts/lfs.d.mts +28 -2
  59. package/dist/contracts/merges.d.mts +3 -2
  60. package/dist/contracts/object-values.d.mts +1 -0
  61. package/dist/contracts/object-values.mjs +16 -1
  62. package/dist/contracts/objects.d.mts +42 -41
  63. package/dist/contracts/opaque.mjs +1 -1
  64. package/dist/contracts/operations.mjs +1 -1
  65. package/dist/contracts/queue.d.mts +247 -55
  66. package/dist/contracts/queue.mjs +8 -9
  67. package/dist/contracts/refs.d.mts +30 -27
  68. package/dist/contracts/refs.mjs +1 -1
  69. package/dist/contracts/remote.d.mts +8 -12
  70. package/dist/contracts/remote.mjs +4 -1
  71. package/dist/contracts/repos.d.mts +32 -141
  72. package/dist/contracts/repos.mjs +6 -4
  73. package/dist/contracts/result.d.mts +40 -18
  74. package/dist/contracts/result.mjs +42 -9
  75. package/dist/contracts/rules.d.mts +2 -2
  76. package/dist/contracts/server.d.mts +25 -52
  77. package/dist/contracts/services.d.mts +6 -9
  78. package/dist/contracts/services.mjs +1 -2
  79. package/dist/contracts/signin.d.mts +1 -1
  80. package/dist/contracts/store.d.mts +7 -6
  81. package/dist/contracts/sync.d.mts +73 -12
  82. package/dist/contracts/sync.mjs +14 -3
  83. package/dist/contracts/tags.d.mts +13 -13
  84. package/dist/contracts/tags.mjs +1 -1
  85. package/dist/contracts/time.d.mts +3 -0
  86. package/dist/contracts/{promises.mjs → time.mjs} +1 -1
  87. package/dist/contracts/tokens.d.mts +17 -19
  88. package/dist/contracts/tokens.mjs +4 -3
  89. package/dist/contracts/topics.d.mts +10 -10
  90. package/dist/contracts/trees.d.mts +16 -16
  91. package/dist/contracts/trees.mjs +1 -1
  92. package/dist/contracts/work.d.mts +28 -17
  93. package/dist/contracts/work.mjs +2 -2
  94. package/dist/core/access.d.mts +1 -2
  95. package/dist/core/access.mjs +20 -9
  96. package/dist/core/ancestry.d.mts +1 -0
  97. package/dist/core/ancestry.mjs +30 -34
  98. package/dist/core/asked.mjs +1 -1
  99. package/dist/core/call-groups.mjs +48 -0
  100. package/dist/core/call-names.mjs +6 -1
  101. package/dist/core/call-services.mjs +11 -3
  102. package/dist/core/events/deliver.d.mts +2 -3
  103. package/dist/core/events/deliver.mjs +45 -38
  104. package/dist/core/events/retired.mjs +119 -0
  105. package/dist/core/forks.mjs +929 -433
  106. package/dist/core/hooks/groups.mjs +3 -3
  107. package/dist/core/imports.mjs +127 -41
  108. package/dist/core/index-job.mjs +131 -38
  109. package/dist/core/index-lost.d.mts +1 -2
  110. package/dist/core/index-lost.mjs +2 -2
  111. package/dist/core/loose-tally.mjs +38 -15
  112. package/dist/core/merge-parts.d.mts +17 -4
  113. package/dist/core/merge-parts.mjs +7 -2
  114. package/dist/core/mirror-rows.mjs +31 -1
  115. package/dist/core/objects/blobs.mjs +127 -3
  116. package/dist/core/objects/files.mjs +20 -17
  117. package/dist/core/objects/lines.mjs +2 -2
  118. package/dist/core/objects/merges.mjs +4 -1
  119. package/dist/core/objects/objects-layer.d.mts +1 -1
  120. package/dist/core/objects/objects-layer.mjs +4 -4
  121. package/dist/core/objects/peel.mjs +1 -7
  122. package/dist/core/objects/reading.mjs +41 -29
  123. package/dist/core/objects/tags.mjs +4 -1
  124. package/dist/core/objects/tree-edits.mjs +1 -1
  125. package/dist/core/objects/trees.mjs +257 -58
  126. package/dist/core/objects/writing.mjs +4 -10
  127. package/dist/core/own-writes.mjs +2 -2
  128. package/dist/core/parts.d.mts +11 -5
  129. package/dist/core/parts.mjs +9 -10
  130. package/dist/core/purge.mjs +310 -93
  131. package/dist/core/push-decide.mjs +2 -0
  132. package/dist/core/push-files.d.mts +1 -1
  133. package/dist/core/push.d.mts +2 -2
  134. package/dist/core/push.mjs +170 -128
  135. package/dist/core/receipts.d.mts +2 -2
  136. package/dist/core/receipts.mjs +17 -5
  137. package/dist/core/ref-index-job.mjs +7 -7
  138. package/dist/core/ref-view.mjs +75 -32
  139. package/dist/core/refs.mjs +7 -7
  140. package/dist/core/registered-rows.mjs +2 -2
  141. package/dist/core/repack.mjs +58 -48
  142. package/dist/core/repo-info.mjs +3 -3
  143. package/dist/core/repos.mjs +21 -9
  144. package/dist/core/rules/changes.mjs +18 -40
  145. package/dist/core/rules/check.mjs +6 -5
  146. package/dist/core/rules/commit-changes.mjs +3 -15
  147. package/dist/core/rules/context.d.mts +3 -3
  148. package/dist/core/rules/context.mjs +18 -14
  149. package/dist/core/rules/fetch.mjs +1 -1
  150. package/dist/core/rules/protect.mjs +30 -17
  151. package/dist/core/saved-caller-views.d.mts +8 -3
  152. package/dist/core/saved-caller-views.mjs +4 -4
  153. package/dist/core/saved-callers.d.mts +19 -2
  154. package/dist/core/saved-callers.mjs +1 -1
  155. package/dist/core/seam.d.mts +17 -28
  156. package/dist/core/seam.mjs +7 -28
  157. package/dist/core/tokens.mjs +1 -1
  158. package/dist/core/view.d.mts +6 -3
  159. package/dist/core/view.mjs +18 -25
  160. package/dist/core/work.mjs +60 -15
  161. package/dist/engine/allotted-xdiff.mjs +3 -16
  162. package/dist/engine/combined.d.mts +3 -0
  163. package/dist/engine/combined.mjs +200 -185
  164. package/dist/engine/content.d.mts +2 -2
  165. package/dist/engine/content.mjs +1 -1
  166. package/dist/engine/failures.mjs +2 -1
  167. package/dist/engine/merge.mjs +7 -9
  168. package/dist/engine/reads.d.mts +2 -2
  169. package/dist/engine/reads.mjs +25 -17
  170. package/dist/engine/xdiff.d.mts +1 -1
  171. package/dist/engine/xdiff.mjs +1 -1
  172. package/dist/event-streams/event-streams.d.mts +1 -1
  173. package/dist/event-streams/event-streams.mjs +1 -1
  174. package/dist/event-streams/stream.d.mts +3 -3
  175. package/dist/event-streams/stream.mjs +39 -16
  176. package/dist/extend.d.mts +2 -7
  177. package/dist/extend.mjs +1 -4
  178. package/dist/http/answers.mjs +8 -5
  179. package/dist/http/core-parts.mjs +169 -96
  180. package/dist/http/handler.mjs +82 -10
  181. package/dist/http/node.d.mts +14 -1
  182. package/dist/http/node.mjs +56 -27
  183. package/dist/http/parts.d.mts +2 -0
  184. package/dist/http/push-upload-job.mjs +165 -47
  185. package/dist/http/push-uploads.mjs +37 -22
  186. package/dist/http/receive-pack.mjs +14 -53
  187. package/dist/http/request-snapshot.mjs +258 -0
  188. package/dist/http/upload-pack.mjs +25 -20
  189. package/dist/index.d.mts +36 -28
  190. package/dist/index.mjs +12 -3
  191. package/dist/lfs/answer.mjs +37 -0
  192. package/dist/lfs/base.d.mts +3 -1
  193. package/dist/lfs/base.mjs +25 -1
  194. package/dist/lfs/copy.d.mts +70 -8
  195. package/dist/lfs/copy.mjs +217 -21
  196. package/dist/lfs/layer.d.mts +19 -4
  197. package/dist/lfs/layer.mjs +25 -13
  198. package/dist/lfs/locks.mjs +3 -3
  199. package/dist/lfs/objects.d.mts +2 -1
  200. package/dist/lfs/objects.mjs +89 -19
  201. package/dist/lfs/pointers.mjs +2 -2
  202. package/dist/lfs/rows.d.mts +1 -1
  203. package/dist/lfs/rows.mjs +50 -9
  204. package/dist/lfs/upkeep.mjs +82 -17
  205. package/dist/lfs/uploaded.mjs +1 -1
  206. package/dist/lfs/wire.mjs +7 -32
  207. package/dist/merges/merges.mjs +19 -4
  208. package/dist/node.d.mts +2 -2
  209. package/dist/protocol/bytes/buffers.d.mts +1 -1
  210. package/dist/protocol/bytes/buffers.mjs +14 -6
  211. package/dist/protocol/bytes/deflate.d.mts +1 -1
  212. package/dist/protocol/bytes/deflate.mjs +1 -1
  213. package/dist/protocol/bytes/inflate.d.mts +1 -1
  214. package/dist/protocol/bytes/inflate.mjs +1 -1
  215. package/dist/protocol/bytes/reader.mjs +6 -1
  216. package/dist/protocol/bytes/sha1.d.mts +1 -1
  217. package/dist/protocol/bytes/sha1.mjs +1 -1
  218. package/dist/protocol/bytes/streams.mjs +27 -1
  219. package/dist/protocol/diff/read.d.mts +6 -4
  220. package/dist/protocol/diff/read.mjs +110 -11
  221. package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
  222. package/dist/protocol/objects/lfs-pointer.mjs +1 -3
  223. package/dist/protocol/objects/links-raw.mjs +24 -10
  224. package/dist/protocol/objects/tag.d.mts +1 -1
  225. package/dist/protocol/objects/tree.mjs +23 -6
  226. package/dist/protocol/packs/delta.d.mts +6 -3
  227. package/dist/protocol/packs/delta.mjs +96 -32
  228. package/dist/protocol/packs/graph.mjs +1 -1
  229. package/dist/protocol/packs/idx.d.mts +3 -2
  230. package/dist/protocol/packs/idx.mjs +23 -4
  231. package/dist/protocol/packs/parts.d.mts +4 -1
  232. package/dist/protocol/packs/parts.mjs +10 -7
  233. package/dist/protocol/packs/reader.d.mts +6 -1
  234. package/dist/protocol/packs/reader.mjs +4 -3
  235. package/dist/protocol/packs/write-error.d.mts +1 -1
  236. package/dist/protocol/packs/write-error.mjs +1 -1
  237. package/dist/protocol/packs/writer.mjs +26 -8
  238. package/dist/protocol/wire/advertisement.d.mts +1 -1
  239. package/dist/protocol/wire/advertisement.mjs +3 -2
  240. package/dist/protocol/wire/fetch.d.mts +1 -1
  241. package/dist/protocol/wire/fetch.mjs +1 -1
  242. package/dist/protocol/wire/lines.d.mts +9 -1
  243. package/dist/protocol/wire/lines.mjs +28 -1
  244. package/dist/protocol/wire/push-uploads.mjs +10 -7
  245. package/dist/protocol/wire/receive-pack.d.mts +1 -1
  246. package/dist/protocol/wire/receive-pack.mjs +1 -1
  247. package/dist/protocol/wire/report-status.d.mts +1 -1
  248. package/dist/protocol/wire/report-status.mjs +1 -1
  249. package/dist/protocol/wire/v2.d.mts +1 -1
  250. package/dist/protocol/wire/v2.mjs +1 -1
  251. package/dist/queue/advance.mjs +48 -44
  252. package/dist/queue/base.d.mts +57 -0
  253. package/dist/queue/base.mjs +44 -0
  254. package/dist/queue/calls.mjs +54 -57
  255. package/dist/queue/commit.mjs +2 -2
  256. package/dist/queue/host.d.mts +2 -16
  257. package/dist/queue/host.mjs +2 -7
  258. package/dist/queue/layer.d.mts +2 -2
  259. package/dist/queue/layer.mjs +19 -8
  260. package/dist/queue/limits.mjs +2 -0
  261. package/dist/queue/push-option.mjs +9 -24
  262. package/dist/queue/schedule.mjs +2 -2
  263. package/dist/queue/search.mjs +1 -1
  264. package/dist/queue/state.mjs +3 -11
  265. package/dist/queue/trim.mjs +6 -4
  266. package/dist/rest/blobs.mjs +29 -5
  267. package/dist/rest/caller.d.mts +4 -4271
  268. package/dist/rest/caller.mjs +4 -0
  269. package/dist/rest/client.d.mts +9 -6
  270. package/dist/rest/client.mjs +25 -8
  271. package/dist/rest/errors.mjs +1 -1
  272. package/dist/rest/handler.mjs +2 -2
  273. package/dist/rest/handlers.mjs +66 -11
  274. package/dist/rest/layer.d.mts +2 -2
  275. package/dist/rest/layer.mjs +6 -13
  276. package/dist/rest/listen.mjs +2 -2
  277. package/dist/rest/me.d.mts +3 -432
  278. package/dist/rest/refs.mjs +1 -1
  279. package/dist/server/check-fetch.mjs +3 -3
  280. package/dist/server/edge-node.d.mts +11 -8
  281. package/dist/server/edge-node.mjs +9 -6
  282. package/dist/server/edge.d.mts +21 -7
  283. package/dist/server/edge.mjs +56 -11
  284. package/dist/server/extension.mjs +1 -1
  285. package/dist/server/git-layer.d.mts +5 -6
  286. package/dist/server/git-layer.mjs +28 -23
  287. package/dist/server/git-namespace.d.mts +4 -3
  288. package/dist/server/git-namespace.mjs +3 -2
  289. package/dist/server/lifecycle.mjs +19 -107
  290. package/dist/server/registry.mjs +24 -13
  291. package/dist/server/server.mjs +249 -371
  292. package/dist/signin/context.d.mts +1 -2
  293. package/dist/signin/context.mjs +1 -1
  294. package/dist/signin/forms.mjs +1 -1
  295. package/dist/signin/grants.d.mts +2 -2
  296. package/dist/signin/grants.mjs +1 -1
  297. package/dist/signin/layer.d.mts +1 -1
  298. package/dist/signin/layer.mjs +1 -1
  299. package/dist/signin/wire.mjs +1 -1
  300. package/dist/storage/allotted.mjs +22 -12
  301. package/dist/storage/batch-upkeep.mjs +293 -0
  302. package/dist/storage/batches.d.mts +7 -0
  303. package/dist/storage/batches.mjs +347 -0
  304. package/dist/storage/budget.mjs +23 -1
  305. package/dist/storage/calls.d.mts +2 -3
  306. package/dist/storage/calls.mjs +166 -182
  307. package/dist/storage/charged-cache.mjs +180 -0
  308. package/dist/storage/chunks.d.mts +9 -0
  309. package/dist/storage/chunks.mjs +410 -0
  310. package/dist/storage/clean-up.mjs +72 -9
  311. package/dist/storage/counted-bucket.mjs +35 -13
  312. package/dist/storage/fetch-row-cache.d.mts +6 -0
  313. package/dist/storage/fetch-row-cache.mjs +211 -0
  314. package/dist/storage/fetch.d.mts +2 -0
  315. package/dist/storage/fetch.mjs +339 -450
  316. package/dist/storage/held-types.d.mts +0 -1
  317. package/dist/storage/host-bucket.mjs +10 -6
  318. package/dist/storage/id-mix.mjs +19 -5
  319. package/dist/storage/index-bitmaps.mjs +86 -51
  320. package/dist/storage/index-build.d.mts +2 -4
  321. package/dist/storage/index-build.mjs +324 -67
  322. package/dist/storage/index-fetch.d.mts +3 -1
  323. package/dist/storage/index-fetch.mjs +163 -83
  324. package/dist/storage/index-files.d.mts +3 -0
  325. package/dist/storage/index-files.mjs +10 -5
  326. package/dist/storage/index-graph.mjs +73 -23
  327. package/dist/storage/index-layers.mjs +55 -25
  328. package/dist/storage/index-reach.mjs +15 -22
  329. package/dist/storage/index-remap.mjs +200 -64
  330. package/dist/storage/index-whole.d.mts +7 -0
  331. package/dist/storage/index-whole.mjs +235 -0
  332. package/dist/storage/largest-files.mjs +1 -7
  333. package/dist/storage/layout.mjs +40 -1
  334. package/dist/storage/lfs-pointers.mjs +1 -6
  335. package/dist/storage/link-join.mjs +55 -16
  336. package/dist/storage/list-source.d.mts +7 -0
  337. package/dist/storage/list-source.mjs +288 -0
  338. package/dist/storage/loose.d.mts +10 -7
  339. package/dist/storage/loose.mjs +293 -82
  340. package/dist/storage/memory-budget.mjs +242 -26
  341. package/dist/storage/merge-cut.mjs +9 -6
  342. package/dist/storage/merge-fence.mjs +1 -1
  343. package/dist/storage/merge-plan.mjs +3 -2
  344. package/dist/storage/merge-row.mjs +8 -2
  345. package/dist/storage/merge-stream.mjs +164 -25
  346. package/dist/storage/merge-walk.mjs +8 -4
  347. package/dist/storage/merge-write.mjs +1 -1
  348. package/dist/storage/merge.d.mts +3 -4
  349. package/dist/storage/merge.mjs +3 -3
  350. package/dist/storage/object-rows.d.mts +4 -3
  351. package/dist/storage/object-rows.mjs +545 -84
  352. package/dist/storage/oid-table.mjs +171 -0
  353. package/dist/storage/pack-order.mjs +104 -47
  354. package/dist/storage/pack-ranges.d.mts +1 -2
  355. package/dist/storage/pack-ranges.mjs +48 -21
  356. package/dist/storage/pack-reads.d.mts +6 -3
  357. package/dist/storage/pack-reads.mjs +378 -98
  358. package/dist/storage/pack-receive.d.mts +2 -3
  359. package/dist/storage/pack-receive.mjs +22 -18
  360. package/dist/storage/packs.d.mts +2 -2
  361. package/dist/storage/packs.mjs +587 -156
  362. package/dist/storage/placed-reads.mjs +34 -17
  363. package/dist/storage/plan-columns.d.mts +4 -0
  364. package/dist/storage/plan-columns.mjs +238 -0
  365. package/dist/storage/prune-keep.mjs +134 -41
  366. package/dist/storage/prune-seen.mjs +1 -1
  367. package/dist/storage/prune-walk.mjs +203 -63
  368. package/dist/storage/prune.mjs +197 -121
  369. package/dist/storage/push-allotment.mjs +116 -25
  370. package/dist/storage/push-uploads.mjs +196 -58
  371. package/dist/storage/pushed-commits.mjs +24 -3
  372. package/dist/storage/quarantine.d.mts +3 -4
  373. package/dist/storage/range-cache.mjs +293 -41
  374. package/dist/storage/raw-ids.mjs +39 -10
  375. package/dist/storage/ready.d.mts +3 -4
  376. package/dist/storage/ready.mjs +121 -43
  377. package/dist/storage/receive-bounds.mjs +50 -13
  378. package/dist/storage/receive-cache.d.mts +7 -0
  379. package/dist/storage/receive-cache.mjs +147 -0
  380. package/dist/storage/receive-files.mjs +1 -1
  381. package/dist/storage/receive-links.mjs +1 -1
  382. package/dist/storage/receive-state.d.mts +2 -2
  383. package/dist/storage/receive-state.mjs +6 -8
  384. package/dist/storage/receive-steps.d.mts +20 -0
  385. package/dist/storage/receive-steps.mjs +298 -13
  386. package/dist/storage/repack-backlog.mjs +1 -3
  387. package/dist/storage/repack-contained.mjs +2 -2
  388. package/dist/storage/repack-job.mjs +1 -1
  389. package/dist/storage/repack.d.mts +3 -4
  390. package/dist/storage/repack.mjs +54 -9
  391. package/dist/storage/request-cache.mjs +57 -0
  392. package/dist/storage/roots.mjs +1 -24
  393. package/dist/storage/rows.d.mts +3 -3
  394. package/dist/storage/rows.mjs +2 -2
  395. package/dist/storage/runs.d.mts +2 -2
  396. package/dist/storage/runs.mjs +196 -44
  397. package/dist/storage/send-list.d.mts +1 -0
  398. package/dist/storage/send-list.mjs +112 -31
  399. package/dist/storage/single-flight.mjs +13 -7
  400. package/dist/storage/stream-whole.mjs +188 -66
  401. package/dist/storage/swap-walk.mjs +1 -1
  402. package/dist/storage/unpack.mjs +919 -199
  403. package/dist/storage/visible.mjs +112 -34
  404. package/dist/storage/walk.mjs +193 -38
  405. package/dist/storage/wants.mjs +27 -63
  406. package/dist/store/bodies.mjs +38 -0
  407. package/dist/store/call-count.d.mts +10 -14
  408. package/dist/store/call-count.mjs +58 -57
  409. package/dist/store/catalogue.d.mts +2 -2
  410. package/dist/store/catalogue.mjs +158 -36
  411. package/dist/store/crossing.mjs +1 -9
  412. package/dist/store/cursor-seal.d.mts +1 -2
  413. package/dist/store/cursor-seal.mjs +17 -7
  414. package/dist/store/door.mjs +188 -0
  415. package/dist/store/errors.d.mts +4 -5
  416. package/dist/store/errors.mjs +119 -49
  417. package/dist/store/git-store.mjs +30 -7
  418. package/dist/store/job-try.mjs +98 -40
  419. package/dist/store/list-job.mjs +32 -20
  420. package/dist/store/outbox.d.mts +2 -2
  421. package/dist/store/outbox.mjs +2 -2
  422. package/dist/store/queue-jobs.mjs +6 -12
  423. package/dist/store/records.d.mts +5 -2
  424. package/dist/store/records.mjs +5 -2
  425. package/dist/store/ref-rows.d.mts +2 -2
  426. package/dist/store/ref-rows.mjs +2 -2
  427. package/dist/store/repo-record.d.mts +2 -3
  428. package/dist/store/repo-record.mjs +34 -22
  429. package/dist/store/request-snapshot.mjs +5 -0
  430. package/dist/store/reservations.mjs +3 -3
  431. package/dist/store/scopes.mjs +11 -0
  432. package/dist/store/settle.mjs +4 -4
  433. package/dist/store/topic-jobs.mjs +5 -11
  434. package/dist/sync/bound.d.mts +3 -3
  435. package/dist/sync/bound.mjs +10 -7
  436. package/dist/sync/github.mjs +67 -69
  437. package/dist/sync/http.mjs +1 -1
  438. package/dist/sync/import.mjs +205 -57
  439. package/dist/sync/layer.d.mts +1 -1
  440. package/dist/sync/layer.mjs +6 -6
  441. package/dist/sync/lfs-batch.mjs +5 -6
  442. package/dist/sync/lfs-copy.mjs +191 -20
  443. package/dist/sync/mirror.mjs +34 -36
  444. package/dist/sync/said.mjs +17 -38
  445. package/dist/sync/step.mjs +292 -102
  446. package/dist/sync/tries.mjs +34 -15
  447. package/dist/sync.d.mts +2 -2
  448. package/dist/sync.mjs +2 -2
  449. package/dist/topics/advance.mjs +12 -13
  450. package/dist/topics/base.d.mts +15 -0
  451. package/dist/topics/base.mjs +8 -0
  452. package/dist/topics/calls.mjs +1 -1
  453. package/dist/topics/host.mjs +1 -1
  454. package/dist/topics/layer.d.mts +17 -21
  455. package/dist/topics/layer.mjs +2 -3
  456. package/dist/topics/members.mjs +4 -4
  457. package/dist/topics/public.d.mts +2 -1
  458. package/dist/topics/topic.mjs +2 -2
  459. package/package.json +5 -14
  460. package/dist/auth/helpers.mjs +0 -17
  461. package/dist/auth.d.mts +0 -5
  462. package/dist/auth.mjs +0 -5
  463. package/dist/contracts/promises.d.mts +0 -39
  464. package/dist/core/call-names.d.mts +0 -3
  465. package/dist/core/clock.mjs +0 -18
  466. package/dist/core/promise.mjs +0 -74
  467. package/dist/core/rules/commit-changes.d.mts +0 -13
  468. package/dist/effect.d.mts +0 -18
  469. package/dist/effect.mjs +0 -16
  470. package/dist/lfs/calls.mjs +0 -26
  471. package/dist/rest/api.d.mts +0 -23
  472. package/dist/rest/blobs.d.mts +0 -833
  473. package/dist/rest/commits.d.mts +0 -3543
  474. package/dist/rest/errors.d.mts +0 -2124
  475. package/dist/rest/events.d.mts +0 -426
  476. package/dist/rest/files.d.mts +0 -1342
  477. package/dist/rest/forks.d.mts +0 -2160
  478. package/dist/rest/handlers.d.mts +0 -8
  479. package/dist/rest/merges.d.mts +0 -477
  480. package/dist/rest/queue.d.mts +0 -5917
  481. package/dist/rest/refs.d.mts +0 -2988
  482. package/dist/rest/repos.d.mts +0 -2567
  483. package/dist/rest/tags.d.mts +0 -1316
  484. package/dist/rest/tokens.d.mts +0 -2614
  485. package/dist/rest/topics.d.mts +0 -2224
  486. package/dist/rest/trees.d.mts +0 -1709
  487. package/dist/rest/work.d.mts +0 -1695
  488. package/dist/server/joined.d.mts +0 -82
  489. package/dist/server/joined.mjs +0 -68
  490. package/dist/server/lifecycle.d.mts +0 -2
  491. package/dist/store/promises.d.mts +0 -11
  492. package/dist/store/promises.mjs +0 -327
@@ -4,17 +4,17 @@ import { hexOf } from "../protocol/bytes/hex.mjs";
4
4
  import { Sha1 } from "../protocol/bytes/sha1.mjs";
5
5
  import { writeCommitGraph } from "../protocol/packs/graph.mjs";
6
6
  import { IndexerCache } from "../protocol/packs/indexer.mjs";
7
- import { oidBytes } from "../protocol/packs/idx.mjs";
7
+ import { indexHeadBytes, oidBytes, tablesOf } from "../protocol/packs/idx.mjs";
8
8
  import { noRepoRoots } from "../protocol/objects/commit.mjs";
9
9
  import { rawLinks } from "../protocol/objects/links-raw.mjs";
10
10
  import { rootsDigest } from "../store/repo-record.mjs";
11
11
  import { randomText } from "../store/random.mjs";
12
12
  import { allottableOf, uploadPartBytes } from "./budget.mjs";
13
- import { bucketDo, bucketPut, joined, readWhole, sizedPutCalls, streamedPutCalls } from "./calls.mjs";
13
+ import { bucketDeleteMany, bucketDo, bucketPut, joined, readEach, readWhole, sizedPutCalls, streamedPutCalls } from "./calls.mjs";
14
14
  import { BitmapsPart, EdgeFiles, bitmapOrder, bitmapsMostBytes, bitmapsPut, copyBitmaps, copyHeldBytes, copyRunBytes, edgesBytesOf, edgesFileOf, ewahMostWords, noNumber, orderKey, partBitmaps, partBytesMost, runsMost, storedBitmaps, storedSize, writeBitmaps } from "./index-bitmaps.mjs";
15
15
  import { BasesWriter, TypesWriter, indexBasesBytes, indexTypesBytes, openBases, openTypes, typeCodes } from "./index-files.mjs";
16
16
  import { bitmapOf, bitmapWords, ewahOf, orEwah } from "./ewah.mjs";
17
- import { graphChunk, indexGraphBytes, mergeHeldBytes, mergeIndexGraphs, openGraphLayers, openIndexGraph, writeIndexGraph } from "./index-graph.mjs";
17
+ import { absent, graphChunk, indexGraphBytes, keptIdsBytes, keptIdsOf, mergeHeldBytes, mergeIndexGraphs, openGraphLayers, openIndexGraph, writeIndexGraph } from "./index-graph.mjs";
18
18
  import { hasBit, idsOf, lookupCalls, openLayerBitmaps, openLayout, orIntoBytes, reachOf } from "./index-layers.mjs";
19
19
  import { indexFiles, indexPrefix, indexRowKey, isPackId, packFiles } from "./layout.mjs";
20
20
  import { listedIds } from "./listed-ids.mjs";
@@ -25,14 +25,13 @@ import { eachPageAt, objectOfRow } from "./object-rows.mjs";
25
25
  import { SliceLinks, SliceRefused, cutAtSpent, isSliceRefused, linksPastMemory, nothingSettled, readSlice, slicePackOf, sliceRefusal, spentOf } from "./pack-order.mjs";
26
26
  import { PackBlocks, blocksHeld, packIndexerLimits } from "./pack-reads.mjs";
27
27
  import { rangeRanks, readExactly } from "./pack-ranges.mjs";
28
- import { rangeCached } from "./range-cache.mjs";
28
+ import { rangeCached, wholeCached } from "./range-cache.mjs";
29
29
  import { compareIds } from "./raw-ids.mjs";
30
+ import * as Schema from "effect/Schema";
30
31
  import * as Effect from "effect/Effect";
31
32
  import * as Option from "effect/Option";
32
- import * as Schema from "effect/Schema";
33
33
  import * as Cause from "effect/Cause";
34
34
  import * as Result from "effect/Result";
35
- import * as Stream from "effect/Stream";
36
35
  // src/storage/index-build.ts
37
36
  /**
38
37
  * The reachability index's first build, `git.index`'s steps, one a try: the region's rows read,
@@ -47,6 +46,11 @@ import * as Stream from "effect/Stream";
47
46
  * Its files are under `index/<repo>/`, a build's own under its ID, so prune lists one repo's.
48
47
  */
49
48
  const lost = (message) => gitError("DATA_LOSS", message);
49
+ /**
50
+ * Safety wait when a published staged batch holds back `git.index`: `core/repack.ts` wakes
51
+ * `git.index` immediately when the batch finishes promoting, so this only backs up a stalled run.
52
+ */
53
+ const batchWaitMs = 3e4;
50
54
  /** A build's ID, new for each: `i_` and 12 random bytes. */
51
55
  const newBuildId = () => `i_${randomText(12)}`;
52
56
  const Count = /* @__PURE__ */ Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
@@ -137,7 +141,12 @@ const IndexData = /* @__PURE__ */ Schema.Struct({
137
141
  const BitmapsCut = /* @__PURE__ */ Schema.Struct({
138
142
  order: Schema.String,
139
143
  done: Count,
140
- parts: Schema.Array(Count)
144
+ parts: Schema.Array(Count),
145
+ /**
146
+ * Digest (`rootsDigest`) of the tips the cut finished for: when equal to the join try's tips,
147
+ * `bitmapsWritten` joins directly without re-opening pack layout, graph, or region (#596).
148
+ */
149
+ ready: Schema.optionalKey(Schema.String)
141
150
  });
142
151
  /** A build its row no longer names, kept readable until `at` and prune's grace pass. */
143
152
  const ReplacedBuild = /* @__PURE__ */ Schema.Struct({
@@ -349,7 +358,7 @@ const wordsOf = (bytes) => {
349
358
  */
350
359
  const keptReaches = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, words, allotment) {
351
360
  const chunks = [];
352
- yield* bucketDo(Stream.runForEach(bucket.read(key), (chunk) => {
361
+ yield* bucketDo(readEach(bucket, key, void 0, (chunk) => {
353
362
  chunks.push(chunk);
354
363
  return allotment.grow(chunk.byteLength);
355
364
  }));
@@ -630,6 +639,14 @@ const joinCharged = (links, ranges, region, allotment) => {
630
639
  return Effect.acquireUseRelease(allotment.grow(bytes), () => joinLinks(links, ranges, region), () => Effect.sync(() => allotment.shrink(bytes)));
631
640
  };
632
641
  /**
642
+ * Rows to a page of the region's read: a scan at 1,000 objects reads in 2 store reads, not 11,
643
+ * so a commit landing mid-scan rarely moves it (#2974). A page past 16 MiB steps down through
644
+ * `eachPageAt`'s fallback, as a clone's `wholePageRows` page does. The page itself is held
645
+ * uncharged while its rows are parsed, as at 100 rows: one answer is at most 16 MiB either way,
646
+ * and about 140 KiB at 1,000 objects.
647
+ */
648
+ const regionPageRows = 1e3;
649
+ /**
633
650
  * The repo's object rows at `listed`'s version, each one a region position after the packs':
634
651
  * their IDs, the SHA-1 of those, and, for the region step, their types, links and commits.
635
652
  * `undefined` once the repo moved under the read.
@@ -637,7 +654,7 @@ const joinCharged = (links, ranges, region, allotment) => {
637
654
  const readRegion = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, each, skip) {
638
655
  let ids = /* @__PURE__ */ new Uint8Array(1280);
639
656
  let rows = 0;
640
- if (!(yield* eachPageAt(parts.store, listed.repo, listed.version, (page) => Effect.gen(function* () {
657
+ const whole = yield* eachPageAt(parts.store, listed.repo, listed.version, (page) => Effect.gen(function* () {
641
658
  for (const row of page) {
642
659
  if (skip?.has(row.id) === true) continue;
643
660
  if ((rows + 1) * 20 > ids.length) {
@@ -650,7 +667,8 @@ const readRegion = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, e
650
667
  rows += 1;
651
668
  }
652
669
  return true;
653
- })))) return void 0;
670
+ }), void 0, regionPageRows);
671
+ if (whole !== "done") return whole;
654
672
  const sha = new Sha1();
655
673
  sha.update(ids.subarray(0, rows * 20));
656
674
  return {
@@ -664,11 +682,24 @@ const readRegion = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, e
664
682
  * charged to `allotment`: its links as they grow, and each row's ID, type and commit entry and
665
683
  * the row's own bytes while it's parsed.
666
684
  */
667
- const regionStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, allotment) {
685
+ const regionStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, allotment, onStart) {
668
686
  const { bucket } = parts;
669
687
  const files = indexFiles(listed.repo, data.build);
670
- const { layout, first, packed } = yield* layoutOf(bucket, listed, data);
671
- const held = data.below.length === 0 ? void 0 : yield* heldBelow(parts, listed, layout, first);
688
+ let layout;
689
+ let held;
690
+ let packed;
691
+ if (data.below.length > 0) {
692
+ const belowRead = yield* readRegion(parts, listed);
693
+ if (belowRead === "batched") return "batched";
694
+ if (belowRead === "moved") return void 0;
695
+ const opened = yield* layoutOf(bucket, listed, data);
696
+ layout = opened.layout;
697
+ packed = opened.packed;
698
+ held = yield* heldInLayers(belowRead, opened.layout, opened.first);
699
+ } else {
700
+ const byId = new Map(listed.packs.map((pack) => [pack.id, pack]));
701
+ packed = data.packs.reduce((sum, id) => sum + (byId.get(id)?.objects ?? 0), 0);
702
+ }
672
703
  const roots = rootsIn(parts);
673
704
  const links = new SliceLinks((bytes) => allotment.tryGrow(bytes));
674
705
  const types = [];
@@ -698,7 +729,9 @@ const regionStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, d
698
729
  yield* allotment.grow(regionRowBytes + object.bytes.byteLength);
699
730
  yield* parsed(object, at).pipe(Effect.ensuring(Effect.sync(() => allotment.shrink(object.bytes.byteLength))));
700
731
  }), held);
701
- if (read === void 0) return data;
732
+ if (read === "batched") return "batched";
733
+ if (read === "moved") return void 0;
734
+ if (onStart !== void 0) yield* onStart();
702
735
  const done = {
703
736
  ...data,
704
737
  rows: read.rows,
@@ -707,8 +740,9 @@ const regionStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, d
707
740
  };
708
741
  if (rootPositions.size > 0) done.rootPositions = withPositions(data.rootPositions, rootPositions);
709
742
  if (read.rows === 0) return done;
710
- const region = withRows(layout.region, packed, read.ids);
711
- const targets = yield* joinCharged(links, layout.ranges, region, allotment);
743
+ const openedLayout = layout ?? (yield* layoutOf(bucket, listed, data)).layout;
744
+ const region = withRows(openedLayout.region, packed, read.ids);
745
+ const targets = yield* joinCharged(links, openedLayout.ranges, region, allotment);
712
746
  const slice = data.slices.length;
713
747
  yield* allotment.grow(edgesMostOf(links) + read.rows + graphFileBytes(commits));
714
748
  const edges = edgesFileOf(files.edges(slice, read.rows), packed, read.rows, links, targets, rootPositions);
@@ -726,13 +760,12 @@ const regionStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, d
726
760
  };
727
761
  });
728
762
  /**
729
- * The rows the layers below hold, which an update's region leaves at their positions there: the
730
- * repo's rows at `listed`'s version, each found among the layers, and kept by ID.
763
+ * The rows of `read` that the layers below hold, which an update's region leaves at their
764
+ * positions there: each found among the layers below `first`, kept by ID.
731
765
  */
732
- const heldBelow = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, layout, first) {
733
- const read = yield* readRegion(parts, listed);
766
+ const heldInLayers = /* @__PURE__ */ Effect.fnUntraced(function* (read, layout, first) {
734
767
  const held = /* @__PURE__ */ new Set();
735
- if (read === void 0 || read.rows === 0) return held;
768
+ if (read.rows === 0) return held;
736
769
  const positions = yield* layout.positionsOf(read.ids, read.rows);
737
770
  for (let at = 0; at < read.rows; at += 1) if ((positions[at] ?? 4294967295) < first) held.add(hexOf(read.ids.subarray(at * 20, at * 20 + 20)));
738
771
  return held;
@@ -744,17 +777,20 @@ const rootsIn = (parts) => parts.roots ?? noRepoRoots;
744
777
  * and a commit's entry and its ID as text, rounded up.
745
778
  */
746
779
  const regionRowBytes = 256;
747
- /** Each of `layers`' graphs, opened at its first graph number. */
748
- const belowGraphs = (bucket, repo, layers) => Effect.forEach(layers, (layer) => openIndexGraph(bucket, indexFiles(repo, layer.build).graph, layer.graphFirst));
780
+ /** Each of `layers`' graphs, opened at its first graph number, its IDs kept in `kept`'s when given. */
781
+ const belowGraphs = (bucket, repo, layers, kept) => Effect.forEach(layers, (layer, at) => openIndexGraph(bucket, indexFiles(repo, layer.build).graph, layer.graphFirst, { kept: kept?.[at] }));
749
782
  /** The graph step: every pack's `.graph` and the region's, merged. */
750
783
  const graphStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, allotment) {
751
784
  const files = indexFiles(listed.repo, data.build);
752
785
  const graphs = data.packs.map((id) => isPackId(id) ? packFiles(id).graph : id);
753
786
  if (data.rows > 0) graphs.push(files.regionGraph);
787
+ const sizes = graphSizesOf(listed, data);
788
+ const cached = yield* roomy(allotment, [...sizes.values()].reduce((total, size) => total + size + 320, 0), () => wholeCached(parts.bucket, sizes), (whole) => whole.clear());
789
+ const kept = yield* roomy(allotment, data.below.reduce((total, layer) => total + keptIdsBytes(layer.commits), 0), () => data.below.map(() => keptIdsOf()), (all) => all.forEach((ids) => ids.drop()));
754
790
  const graphFirst = graphFirstOf(data.below);
755
- const below = data.below.length === 0 ? void 0 : openGraphLayers(yield* belowGraphs(parts.bucket, listed.repo, data.below)).below(data.below.length);
791
+ const below = data.below.length === 0 ? void 0 : openGraphLayers(yield* belowGraphs(parts.bucket, listed.repo, data.below, kept)).below(data.below.length);
756
792
  const graphInput = {
757
- bucket: parts.bucket,
793
+ bucket: cached?.bucket ?? parts.bucket,
758
794
  graphs,
759
795
  key: files.graph,
760
796
  allotment,
@@ -773,7 +809,15 @@ const graphStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, da
773
809
  commits: written.commits,
774
810
  step
775
811
  };
776
- });
812
+ }, Effect.scoped);
813
+ /**
814
+ * Each listed pack's `.graph` the step merges, by key, at the size its row records: a region's
815
+ * isn't listed, so it streams each pass.
816
+ */
817
+ const graphSizesOf = (listed, data) => {
818
+ const merged = new Set(data.packs);
819
+ return new Map(listed.packs.flatMap(({ id, graphBytes }) => merged.has(id) && isPackId(id) && graphBytes > 0 ? [[packFiles(id).graph, graphBytes]] : []));
820
+ };
777
821
  /**
778
822
  * The type codes `slices` stored at positions of the pack whose order starts at repo position
779
823
  * `base`: for each slice that holds any, one ranged read of its `.types` part, from the first it
@@ -838,7 +882,14 @@ const readStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, dat
838
882
  offset: data.offset,
839
883
  position: data.position
840
884
  };
841
- const opened = yield* Effect.result(cutAtSpent(layoutOf(bucket, listed, data)));
885
+ const primed = yield* roomyReadJoins(bucket, listed, data, allotment);
886
+ const opened = yield* Effect.result(cutAtSpent(primed === void 0 ? layoutOf(bucket, listed, data) : Effect.andThen(Effect.all(primed.prime.map(({ key, offset, length }) => primed.joins.prime(key, {
887
+ offset,
888
+ length
889
+ })), {
890
+ concurrency: 6,
891
+ discard: true
892
+ }), layoutOf(primed.joins.bucket, listed, data, { cached: true }))));
842
893
  if (Result.isFailure(opened)) {
843
894
  const spent = spentOf(opened.failure);
844
895
  if (spent === void 0) return yield* Effect.fail(opened.failure);
@@ -884,9 +935,14 @@ const readStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, dat
884
935
  yield* allotment.grow(edgesMostOf(links) + slice.bases.length * 4);
885
936
  const positions = slice.types.length;
886
937
  const made = edgesFileOf(files.edges(number, positions), first, positions, links, targets, slice.roots);
887
- yield* putOnce(bucket, made.slice.key, made.bytes);
888
- yield* putOnce(bucket, files.typesPart(number, positions), slice.types);
889
- yield* putOnce(bucket, files.basesPart(number, positions), wordsBytes(slice.bases));
938
+ yield* Effect.all([
939
+ putOnce(bucket, made.slice.key, made.bytes),
940
+ putOnce(bucket, files.typesPart(number, positions), slice.types),
941
+ putOnce(bucket, files.basesPart(number, positions), wordsBytes(slice.bases))
942
+ ], {
943
+ concurrency: 3,
944
+ discard: true
945
+ });
890
946
  return made;
891
947
  }).pipe(cutAtSpent, Effect.catchIf((error) => spentOf(error) !== void 0, () => Effect.fail(reserveShort(data.packs[data.pack] ?? "", at.position, whole))));
892
948
  const slices = [...data.slices, {
@@ -1135,28 +1191,137 @@ const bitmapsJoinMost = 25165824;
1135
1191
  * `bitmapsJoinMost`. It's what a join can read, from the counts alone, never what a try did.
1136
1192
  */
1137
1193
  const bitmapsJoinHeld = (objects) => Math.min(bitmapsJoinMost, objects.reduce((sum, count) => sum + count * 24 + Math.ceil(count / rangeRanks) * 2 * 320, 0));
1194
+ /** The `.idx` and `.pos` spans `readStep` primes for a pack of `objects` objects, with offsets when active and non-empty. */
1195
+ const readPackSpans = (objects, withOffsets) => {
1196
+ const spans = [{
1197
+ file: "idx",
1198
+ offset: 0,
1199
+ length: indexHeadBytes + objects * 20
1200
+ }, {
1201
+ file: "pos",
1202
+ offset: 0,
1203
+ length: 12 + objects * 4
1204
+ }];
1205
+ if (withOffsets && objects > 0) spans.push({
1206
+ file: "idx",
1207
+ offset: tablesOf(objects).offsets,
1208
+ length: objects * 4
1209
+ });
1210
+ return spans;
1211
+ };
1212
+ /** The room primed `.idx` and `.pos` spans cost, bytes plus one entry charge a span. */
1213
+ const readSpansCost = (spans) => spans.reduce((sum, span) => sum + span.length + 320, 0);
1214
+ /**
1215
+ * What a read step holds for the primed `.idx` and `.pos` tables of packs of `objects` objects,
1216
+ * the active pack at `active` (0 by default) also holding its `.idx` offsets when non-empty:
1217
+ * derived from `readPackSpans` and capped at `bitmapsJoinMost` (#664).
1218
+ */
1219
+ const readJoinHeld = (objects, active = 0) => Math.min(bitmapsJoinMost, objects.reduce((sum, count, at) => sum + readSpansCost(readPackSpans(count, at === active)), 0));
1220
+ /** The covered packs for `readStep`, active pack first so it gets priming room before the rest. */
1221
+ const readPacksOf = (listed, data) => {
1222
+ const covered = new Set([...data.below, spanOf(data)].flatMap((layer) => layer.groups.flatMap((group) => group.packs)));
1223
+ const activeId = data.packs[data.pack];
1224
+ const packs = listed.packs.filter(({ id }) => covered.has(id));
1225
+ const active = packs.find(({ id }) => id === activeId);
1226
+ return active === void 0 ? packs : [active, ...packs.filter(({ id }) => id !== activeId)];
1227
+ };
1228
+ /** The `.idx` and `.pos` ranges `readStep` primes for one pack, keyed onto `packFiles(pack.id)`. */
1229
+ const readPackRanges = (pack, withOffsets) => {
1230
+ if (!isPackId(pack.id)) return [];
1231
+ const files = packFiles(pack.id);
1232
+ return readPackSpans(pack.objects, withOffsets).map(({ file, offset, length }) => ({
1233
+ key: files[file],
1234
+ offset,
1235
+ length
1236
+ }));
1237
+ };
1238
+ /** What a step keeps of its layout's join ranges, `bitmapsJoinHeld` over the packs `data` covers. */
1239
+ const joinsHeldOf = (listed, data) => {
1240
+ const covered = new Set([...data.below, spanOf(data)].flatMap((layer) => layer.groups.flatMap((group) => group.packs)));
1241
+ return bitmapsJoinHeld(listed.packs.filter(({ id }) => covered.has(id)).map((pack) => pack.objects));
1242
+ };
1138
1243
  /**
1139
1244
  * The step's kept join ranges over `bucket`, charged at `bitmapsJoinHeld` before any read and let
1140
1245
  * go as its scope ends, however the step ends: each walk below's batch joins every covered pack's
1141
1246
  * ranges, which are read once a step this way, not once a batch.
1142
1247
  */
1143
1248
  const keptJoins = (bucket, listed, data, allotment) => {
1144
- const covered = new Set([...data.below, spanOf(data)].flatMap((layer) => layer.groups.flatMap((group) => group.packs)));
1145
- const held = bitmapsJoinHeld(listed.packs.filter(({ id }) => covered.has(id)).map((pack) => pack.objects));
1249
+ const held = joinsHeldOf(listed, data);
1146
1250
  return Effect.acquireRelease(Effect.map(allotment.grow(held), () => rangeCached(bucket, held, { evict: false })), (ranges) => Effect.sync(() => {
1147
1251
  ranges.clear();
1148
1252
  allotment.shrink(held);
1149
1253
  }));
1150
1254
  };
1255
+ /**
1256
+ * What `make` makes, in a room of `allotment` that has `held` at once: none with no room at once,
1257
+ * and `drop`ped when the budget shrinks the room, the step's own grow or another's, or as the
1258
+ * scope ends. Its maker reads again what it would have kept: never a wait or a refusal (#2518).
1259
+ * `drop` lets go at once of all it holds, reads under way included, as the room's charge goes back.
1260
+ */
1261
+ const roomy = (allotment, held, make, drop) => {
1262
+ const room = allotment.room(0, held);
1263
+ return Effect.acquireRelease(Effect.sync(() => {
1264
+ if (!room.grow(held)) return void 0;
1265
+ const made = make();
1266
+ room.watch((left) => {
1267
+ if (left < held) drop(made);
1268
+ });
1269
+ return made;
1270
+ }), (made) => Effect.sync(() => {
1271
+ if (made !== void 0) drop(made);
1272
+ allotment.endRoom(room);
1273
+ }));
1274
+ };
1275
+ /**
1276
+ * The read step's primed `.idx` and `.pos` tables in a room of `readJoinHeld`: granted before any
1277
+ * prime starts, dropped if the room shrinks, and skipped for any pack past what's left (#664).
1278
+ */
1279
+ const roomyReadJoins = (bucket, listed, data, allotment) => {
1280
+ const packs = readPacksOf(listed, data);
1281
+ const activeId = data.packs[data.pack];
1282
+ const held = readJoinHeld(packs.map((pack) => pack.objects), packs[0]?.id === activeId ? 0 : -1);
1283
+ const prime = [];
1284
+ let left = held;
1285
+ for (const [at, pack] of packs.entries()) {
1286
+ const ranges = readPackRanges(pack, at === 0 && pack.id === activeId);
1287
+ const cost = readSpansCost(ranges);
1288
+ if (cost > left) continue;
1289
+ left -= cost;
1290
+ prime.push(...ranges);
1291
+ }
1292
+ return Effect.map(roomy(allotment, held, () => rangeCached(bucket, held, {
1293
+ evict: false,
1294
+ headers: true
1295
+ }), (ranges) => ranges.clear()), (joins) => joins === void 0 ? void 0 : {
1296
+ joins,
1297
+ prime
1298
+ });
1299
+ };
1300
+ /**
1301
+ * The step's join ranges kept as `keptJoins` keeps them, in a room, so the layout a step opens and
1302
+ * the join that reads it again read each range once a step (#2518).
1303
+ */
1304
+ const roomyJoins = (bucket, listed, data, allotment) => {
1305
+ const held = joinsHeldOf(listed, data);
1306
+ return roomy(allotment, held, () => rangeCached(bucket, held, { evict: false }), (ranges) => ranges.clear());
1307
+ };
1308
+ /**
1309
+ * A first build's tips' numbers and then the numbers' IDs read the same chunk of the graph's IDs:
1310
+ * kept in a room of `keptIdsBytes`, so it's read once a step (#2518).
1311
+ */
1312
+ const roomyIds = (data, allotment) => roomy(allotment, keptIdsBytes(data.commits), keptIdsOf, (kept) => kept.drop());
1151
1313
  /** `bitmapsStep`'s reads and writes, through `lower` when given, each walk below in `walks`. */
1152
1314
  const bitmapsWritten = /* @__PURE__ */ Effect.fnUntraced(function* (parts, lower, listed, data, input, allotment, walks) {
1153
1315
  const bucket = lower?.bucket ?? parts.bucket;
1154
1316
  const files = indexFiles(listed.repo, data.build);
1155
- const joins = data.below.length === 0 ? void 0 : yield* keptJoins(bucket, listed, data, allotment);
1317
+ const tipsKey = data.below.length === 0 && lower !== void 0 ? rootsDigest(input.tips) : void 0;
1318
+ if (tipsKey !== void 0 && data.bitmapsCut?.ready === tipsKey) return yield* bitmapsJoined(parts, files, data, data.bitmapsCut, coveredPositions(listed, data), allotment);
1319
+ const joins = data.below.length === 0 ? yield* roomyJoins(bucket, listed, data, allotment) : yield* keptJoins(bucket, listed, data, allotment);
1156
1320
  const { layout, first } = joins === void 0 ? yield* layoutOf(bucket, listed, data) : yield* layoutOf(joins.bucket, listed, data, { cached: true });
1157
1321
  const { positions } = layout;
1158
1322
  const graphFirst = graphFirstOf(data.below);
1159
- const own = yield* openIndexGraph(bucket, files.graph, graphFirst);
1323
+ const kept = data.below.length === 0 ? yield* roomyIds(data, allotment) : void 0;
1324
+ const own = yield* openIndexGraph(bucket, files.graph, graphFirst, { kept });
1160
1325
  const graph = openGraphLayers([...yield* belowGraphs(bucket, listed.repo, data.below), own]);
1161
1326
  yield* allotment.grow(own.commits * 12);
1162
1327
  const rows = yield* own.rows;
@@ -1290,7 +1455,7 @@ const bitmapsWritten = /* @__PURE__ */ Effect.fnUntraced(function* (parts, lower
1290
1455
  kept: Math.min(madeMost, madeAll)
1291
1456
  };
1292
1457
  if (below !== void 0) bitmapsInput.below = below;
1293
- if (data.below.length === 0 && lower !== void 0) return yield* bitmapsCutTry(parts, files, data, bitmapsInput, allotment);
1458
+ if (tipsKey !== void 0) return yield* bitmapsCutTry(parts, files, data, bitmapsInput, tipsKey, allotment);
1294
1459
  const already = yield* storedSize(bucket, files.bitmaps);
1295
1460
  const written = already === void 0 ? yield* writeBitmaps(bitmapsInput) : yield* storedBitmaps(bucket, files.bitmaps, positions, already);
1296
1461
  if (written === void 0) return void 0;
@@ -1308,7 +1473,7 @@ const bitmapsWritten = /* @__PURE__ */ Effect.fnUntraced(function* (parts, lower
1308
1473
  * bitmap the bound cuts is left whole for the next try, and a try that makes none refuses, as the
1309
1474
  * next would spend its calls at the same place.
1310
1475
  */
1311
- const bitmapsCutTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files, data, input, allotment) {
1476
+ const bitmapsCutTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files, data, input, tipsKey, allotment) {
1312
1477
  const order = bitmapOrder(input.chosen);
1313
1478
  const ordered = orderKey(order);
1314
1479
  const cut = data.bitmapsCut?.order === ordered ? data.bitmapsCut : {
@@ -1324,7 +1489,7 @@ const bitmapsCutTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files,
1324
1489
  const count = yield* partCount(key, landed);
1325
1490
  return {
1326
1491
  ...data,
1327
- bitmapsCut: next(cut, count)
1492
+ bitmapsCut: next(cut, count, order.length, tipsKey)
1328
1493
  };
1329
1494
  }
1330
1495
  const into = new BitmapsPart(partBytesMost);
@@ -1343,19 +1508,55 @@ const bitmapsCutTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files,
1343
1508
  return yield* Effect.fail(bitmapUnwritten(spent.bound, most, order[cut.done]?.position ?? 0));
1344
1509
  }
1345
1510
  } else if (into.count === 0) return yield* Effect.fail(lost(`No bitmap of ${input.positions} positions fits a part`));
1511
+ if (cut.parts.length === 0 && Result.isSuccess(made) && into.count === order.length) {
1512
+ const atMost = bitmapsMostBytes(input.positions, into.count);
1513
+ const directNeeds = 1 + Math.max(4, streamedPutCalls(parts.bucket.multipart, atMost));
1514
+ const { counted } = parts;
1515
+ const madeCalls = counted?.made();
1516
+ const callsFit = counted === void 0 || madeCalls === void 0 || directNeeds <= counted.most.bucket - madeCalls.bucket && directNeeds <= counted.most.subrequests - madeCalls.subrequests;
1517
+ const putBuffer = Math.min(atMost, uploadPartBytes);
1518
+ if (callsFit && (putBuffer === 0 || allotment.tryGrow(putBuffer))) return yield* Effect.ensuring(Effect.gen(function* () {
1519
+ const already = yield* storedSize(parts.bucket, files.bitmaps);
1520
+ const written = already === void 0 ? yield* Effect.scoped(Effect.gen(function* () {
1521
+ const bitmaps = partBitmaps(into.finish());
1522
+ if (bitmaps?.length !== into.count) return yield* Effect.fail(lost(`${files.bitmaps} part buffer is unreadable`));
1523
+ const put = yield* bitmapsPut(parts.bucket, files.bitmaps, input.positions, into.count);
1524
+ for (const bitmap of bitmaps) yield* put.addBytes(bitmap.position, bitmap.number, bitmap.bytes);
1525
+ return yield* put.finish;
1526
+ })) : yield* storedBitmaps(parts.bucket, files.bitmaps, input.positions, already);
1527
+ const { bitmapsCut: _, ...rest } = data;
1528
+ return {
1529
+ ...rest,
1530
+ step: "files",
1531
+ bitmaps: written.count,
1532
+ table: written.table
1533
+ };
1534
+ }), Effect.sync(() => {
1535
+ if (putBuffer > 0) allotment.shrink(putBuffer);
1536
+ }));
1537
+ }
1346
1538
  const count = yield* partPut(parts.bucket, key, into);
1347
1539
  if (count === void 0) return data;
1348
1540
  return {
1349
1541
  ...data,
1350
- bitmapsCut: next(cut, count)
1542
+ bitmapsCut: next(cut, count, order.length, tipsKey)
1351
1543
  };
1352
1544
  });
1353
- /** `cut` with its next part, of `count` bitmaps, made. */
1354
- const next = (cut, count) => ({
1355
- order: cut.order,
1356
- done: cut.done + count,
1357
- parts: [...cut.parts, count]
1358
- });
1545
+ /** `cut` with its next part, of `count` bitmaps, made; marked `ready` once all `total` fit. */
1546
+ const next = (cut, count, total, tipsKey) => {
1547
+ const done = cut.done + count;
1548
+ const parts = [...cut.parts, count];
1549
+ return done >= total ? {
1550
+ order: cut.order,
1551
+ done,
1552
+ parts,
1553
+ ready: tipsKey
1554
+ } : {
1555
+ order: cut.order,
1556
+ done,
1557
+ parts
1558
+ };
1559
+ };
1359
1560
  /** How many bitmaps the part at `key` holds, as `bytes` read. */
1360
1561
  const partCount = (key, bytes) => {
1361
1562
  const held = partBitmaps(bytes);
@@ -1401,10 +1602,14 @@ const bitmapsJoined = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files,
1401
1602
  table: written.table
1402
1603
  };
1403
1604
  });
1605
+ /** Maximum concurrent scratch-part reads across `filesStep` (matches `locateReads`). */
1606
+ const filesReads = 6;
1404
1607
  /**
1405
1608
  * The files step: `.types` and `.bases`, each its parts streamed in position order, and each
1406
1609
  * found there on its own when a try that died after its put landed is done again. It holds a
1407
- * part as read, its words, and what it writes of it, charged to `allotment` first.
1610
+ * part as read, its words, and what it writes of it, charged to `allotment` first, running
1611
+ * `.types` and `.bases` concurrently and prefetching scratch parts in bounded waves when
1612
+ * `allotment` has room (#596).
1408
1613
  */
1409
1614
  const filesStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, allotment) {
1410
1615
  const { bucket } = parts;
@@ -1413,13 +1618,42 @@ const filesStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, da
1413
1618
  const every = firstOf(data.below) + positions;
1414
1619
  const deltas = data.slices.reduce((sum, slice) => sum + slice.deltas, 0);
1415
1620
  const ordered = byPosition(data);
1416
- const part = data.slices.reduce((most, slice) => Math.max(most, slice.positions, slice.deltas * 8), 0);
1621
+ const typesPartMost = data.slices.reduce((most, slice) => Math.max(most, slice.positions), 0);
1622
+ const basesPartMost = data.slices.reduce((most, slice) => Math.max(most, slice.deltas * 8), 0);
1623
+ const part = Math.max(typesPartMost, basesPartMost);
1417
1624
  yield* allotment.grow(3 * part + Math.ceil(every / 4096) * 4 + 65536);
1625
+ const [typesSize, basesSize] = yield* Effect.all([storedSize(bucket, files.types), storedSize(bucket, files.bases)], { concurrency: 2 });
1626
+ const needTypes = typesSize === void 0;
1627
+ const needBases = basesSize === void 0;
1628
+ const secondStreamExtra = 3 * part + 65536;
1629
+ const parallelStreams = needTypes && needBases && (secondStreamExtra === 0 || allotment.tryGrow(secondStreamExtra));
1630
+ const perStreamCap = parallelStreams ? Math.max(1, Math.floor(filesReads / 2)) : filesReads;
1631
+ const streamParts = (keys, partBytes, consume) => Effect.suspend(() => {
1632
+ let wave = Math.min(perStreamCap, Math.max(1, keys.length));
1633
+ let extra = 0;
1634
+ while (wave > 1) {
1635
+ const needed = (wave - 1) * partBytes;
1636
+ if (needed === 0 || allotment.tryGrow(needed)) {
1637
+ extra = needed;
1638
+ break;
1639
+ }
1640
+ wave = Math.floor(wave / 2);
1641
+ }
1642
+ return Effect.ensuring(Effect.gen(function* () {
1643
+ for (let at = 0; at < keys.length; at += wave) {
1644
+ const batch = keys.slice(at, at + wave);
1645
+ const loaded = batch.length === 1 ? [yield* readScratch(bucket, batch[0])] : yield* Effect.all(batch.map((key) => readScratch(bucket, key)), { concurrency: wave });
1646
+ for (const bytes of loaded) yield* consume(bytes);
1647
+ }
1648
+ }), Effect.sync(() => {
1649
+ if (extra > 0) allotment.shrink(extra);
1650
+ }));
1651
+ });
1418
1652
  const types = Effect.gen(function* () {
1419
1653
  const writer = new TypesWriter(positions);
1420
1654
  const put = yield* startPut(bucket, files.types, { size: indexTypesBytes(positions) });
1421
1655
  yield* put.write(writer.head());
1422
- for (const [number, slice] of ordered) yield* put.write(yield* writer.part(yield* readScratch(bucket, files.typesPart(number, slice.positions))));
1656
+ yield* streamParts(ordered.map(([number, slice]) => files.typesPart(number, slice.positions)), typesPartMost, (bytes) => Effect.flatMap(writer.part(bytes), (chunk) => put.write(chunk)));
1423
1657
  yield* put.write(yield* writer.end());
1424
1658
  yield* put.finish;
1425
1659
  });
@@ -1427,12 +1661,19 @@ const filesStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, da
1427
1661
  const writer = new BasesWriter(every, deltas);
1428
1662
  const put = yield* startPut(bucket, files.bases, { size: indexBasesBytes(every, deltas) });
1429
1663
  yield* put.write(writer.head());
1430
- for (const [number, slice] of ordered) yield* put.write(yield* writer.rows(wordsOf(yield* readScratch(bucket, files.basesPart(number, slice.positions)))));
1664
+ yield* streamParts(ordered.map(([number, slice]) => files.basesPart(number, slice.positions)), basesPartMost, (bytes) => Effect.flatMap(writer.rows(wordsOf(bytes)), (chunk) => put.write(chunk)));
1431
1665
  yield* put.write(yield* writer.end());
1432
1666
  yield* put.finish;
1433
1667
  });
1434
- if ((yield* storedSize(bucket, files.types)) === void 0) yield* types;
1435
- if ((yield* storedSize(bucket, files.bases)) === void 0) yield* bases;
1668
+ yield* Effect.ensuring(parallelStreams ? Effect.all([types, bases], {
1669
+ concurrency: 2,
1670
+ discard: true
1671
+ }) : Effect.gen(function* () {
1672
+ if (needTypes) yield* types;
1673
+ if (needBases) yield* bases;
1674
+ }), Effect.sync(() => {
1675
+ if (parallelStreams && secondStreamExtra > 0) allotment.shrink(secondStreamExtra);
1676
+ }));
1436
1677
  return {
1437
1678
  ...data,
1438
1679
  step: "commit"
@@ -1546,20 +1787,28 @@ const liveBitmaps = /* @__PURE__ */ Effect.fnUntraced(function* (layout, stored,
1546
1787
  yield* stored.orInto(bitmapped, live);
1547
1788
  return stored.entries.filter(({ entry }) => hasBit(live, entry.position));
1548
1789
  });
1790
+ /** `numbered`'s bitmaps' numbers in the merged graph at `key`, read by their IDs in `graphs`. */
1791
+ const numbersIn = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, graphs, numbered) {
1792
+ const merged = yield* openIndexGraph(bucket, key);
1793
+ const ids = yield* openGraphLayers(graphs).idsAt(numbered.map(({ entry }) => entry.number));
1794
+ return yield* merged.numbersOf(ids, numbered.length);
1795
+ });
1549
1796
  /**
1550
1797
  * `kept`'s bitmaps copied to `files.bitmaps` over `positions`, each numbered again by the merged
1551
- * graph at `files.graph`, which `graphs` were merged into: its bits and its position as `move`
1552
- * moves them, or where they were. A file a try that died already put is kept. Its caller charges
1553
- * the bitmaps' entries, `mergeEntryBytes` each; the copy charges its own.
1798
+ * graph at `files.graph`, which `graphs` were merged into, or by `renumbered`, the merge's own
1799
+ * numbering, while that file isn't finished: its bits and its position as `move` moves them, or
1800
+ * where they were. A file a try that died already put is kept. Its caller charges the bitmaps'
1801
+ * entries, `mergeEntryBytes` each; the copy charges its own.
1554
1802
  */
1555
1803
  const copyMergedBitmaps = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
1556
- const { bucket, files, positions, kept } = input;
1804
+ const { bucket, files, positions, kept, renumbered } = input;
1557
1805
  const stored = yield* storedSize(bucket, files.bitmaps);
1558
1806
  if (stored !== void 0) return yield* storedBitmaps(bucket, files.bitmaps, positions, stored);
1559
1807
  const numbered = kept.filter(({ entry }) => entry.number !== noNumber);
1560
- const merged = yield* openIndexGraph(bucket, files.graph);
1561
- const ids = yield* openGraphLayers(input.graphs).idsAt(numbered.map(({ entry }) => entry.number));
1562
- const numbers = yield* merged.numbersOf(ids, numbered.length);
1808
+ const numbers = renumbered === void 0 ? yield* numbersIn(bucket, files.graph, input.graphs, numbered) : numbered.map(({ entry }) => {
1809
+ const number = renumbered(entry.number);
1810
+ return number === 2147483647 ? absent : number;
1811
+ });
1563
1812
  const copied = [];
1564
1813
  let place = 0;
1565
1814
  for (const { from, entry } of kept) {
@@ -1699,8 +1948,9 @@ const mergeStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, da
1699
1948
  /**
1700
1949
  * Deletes every file under the repo's prefix whose build `keep` doesn't name, once prune's grace
1701
1950
  * has passed since it was replaced, or, for one no row names, since it was written, and never
1702
- * before `from`; and the scratch of a build kept for its stored files alone. Answers when the next
1703
- * file it kept is due: `at` itself once it has deleted `pruneMost`, with more left to look at.
1951
+ * before `from`; and the scratch of a build kept for its stored files alone, each listed page's in
1952
+ * one `bucketDeleteMany`. Answers when the next file it kept is due: `at` itself once it has
1953
+ * deleted `pruneMost`, with more left to look at.
1704
1954
  */
1705
1955
  const pruneBuilds = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, repo, keep, replaced, at, grace, from = 0) {
1706
1956
  const prefix = indexPrefix(repo);
@@ -1710,6 +1960,7 @@ const pruneBuilds = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, repo, k
1710
1960
  let deleted = 0;
1711
1961
  for (;;) {
1712
1962
  const page = yield* bucketDo(bucket.list(prefix, after === void 0 ? {} : { after }));
1963
+ const doomed = [];
1713
1964
  for (const item of page.items) {
1714
1965
  const name = item.key.slice(prefix.length);
1715
1966
  const build = name.split(/[./]/)[0] ?? "";
@@ -1721,10 +1972,12 @@ const pruneBuilds = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, repo, k
1721
1972
  due = Math.min(due ?? Number.POSITIVE_INFINITY, since + grace);
1722
1973
  continue;
1723
1974
  }
1724
- yield* bucketDo(bucket.remove(item.key));
1725
- deleted += 1;
1726
- if (deleted >= 200) return at;
1975
+ doomed.push(item.key);
1976
+ if (deleted + doomed.length >= 200) break;
1727
1977
  }
1978
+ if (doomed.length > 0) yield* bucketDeleteMany(bucket, doomed);
1979
+ deleted += doomed.length;
1980
+ if (deleted >= 200) return at;
1728
1981
  if (page.next === void 0) return due;
1729
1982
  after = page.next;
1730
1983
  }
@@ -1853,10 +2106,10 @@ const layersLost = (listed, error) => Effect.logError(`git.index found repo ${li
1853
2106
  const upToDate = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, built, tips) {
1854
2107
  const covered = coveredPacks(built.layers);
1855
2108
  if (listed.packs.some((pack) => !covered.has(pack.id))) return false;
2109
+ const read = yield* readRegion(parts, listed);
2110
+ if (read === "batched" || read === "moved") return read;
1856
2111
  const allotment = yield* parts.budget.upkeep(0, readBusy);
1857
2112
  const layout = yield* openLayout(parts.bucket, listed, built.layers, void 0, { allotment });
1858
- const read = yield* readRegion(parts, listed);
1859
- if (read === void 0) return "moved";
1860
2113
  if ((yield* layout.positionsOf(read.ids, read.rows)).some((position) => position === 4294967295)) return false;
1861
2114
  const bitmaps = yield* openLayerBitmaps(parts.bucket, listed.repo, built.layers);
1862
2115
  const unique = [...new Set(tips)];
@@ -2013,6 +2266,7 @@ const indexStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, in
2013
2266
  if (input.data === void 0 && row !== void 0 && !stale && !indexSaves(indexStatus(row, limits, input.at, listedIds(listed)))) return prunedAt(yield* prune());
2014
2267
  const current = input.data === void 0 && built?.lost === true ? "lost" : input.data === void 0 && built !== void 0 && !stale && coversAll(built.layers, listed) ? yield* upToDate(parts, listed, built, input.tips).pipe(Effect.catchIf(isLost, (error) => Effect.as(layersLost(listed, error), "lost"))) : false;
2015
2268
  if (current === true) return prunedAt(yield* prune());
2269
+ if (current === "batched") return prunedAt(input.at + batchWaitMs);
2016
2270
  if (current === "moved" && input.lastCheck !== true) return { kind: "moved" };
2017
2271
  const fresh = () => built === void 0 || stale || current === "lost" || !coversAll(built.layers, listed) ? started(listed, rootsKey) : built.layers.length < 8 ? startedUpdate(listed, built) : startedMerge(listed, built);
2018
2272
  const kept = input.data;
@@ -2025,7 +2279,6 @@ const indexStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, in
2025
2279
  });
2026
2280
  const orWhole = (step) => data.below.length === 0 ? step : step.pipe(Effect.catchIf(isLost, (error) => Effect.as(layersLost(listed, error), started(listed, rootsKey))));
2027
2281
  if (input.lastCheck === true && input.data === void 0) return more(data);
2028
- if (data.step === "region") yield* prune(data.build);
2029
2282
  if (data.step === "commit" && addsNothing(data)) {
2030
2283
  yield* prune();
2031
2284
  return prunedAt(input.at);
@@ -2033,7 +2286,11 @@ const indexStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, in
2033
2286
  if (data.step === "commit") return yield* commitStep(listed, data, input);
2034
2287
  const allotment = yield* parts.budget.upkeep(floors.cache + floors.blocks, readBusy);
2035
2288
  const named = spentNamed(data.step, listed.repo);
2036
- if (data.step === "region") return more(yield* named(orWhole(regionStep(parts, listed, data, allotment))));
2289
+ if (data.step === "region") {
2290
+ const region = yield* named(orWhole(regionStep(parts, listed, data, allotment, () => prune(data.build))));
2291
+ if (region === "batched") return prunedAt(input.at + batchWaitMs);
2292
+ return more(region ?? kept ?? data);
2293
+ }
2037
2294
  if (data.step === "files") return more(yield* named(orWhole(filesStep(parts, listed, data, allotment))));
2038
2295
  if (data.step === "merge") {
2039
2296
  const merged = yield* Effect.result(named(orWhole(mergeStep(parts, listed, data, input, allotment))));
@@ -2110,4 +2367,4 @@ const indexTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, limits, lis
2110
2367
  data: ended.data
2111
2368
  };
2112
2369
  });
2113
- export { BitmapsCut, BuiltIndex, IndexBounds, IndexData, IndexGroup, IndexLayer, IndexRefusal, IndexRow, IndexSlice, IndexTries, Narrowed, RefusedIndex, ReplacedBuild, belowGraphs, bitmapsJoinHeld, bitmapsJoinMost, boundsOf, builtIndexOf, builtOver, chooseCommits, copyMergedBitmaps, coveredPacks, coversAll, decodeIndexValue, denseBelow, denseBelowReads, edgesMost, entriesHeld, floors, graphMostOf, indexBitmapsCallsAfter, indexReadCallsAfter, indexRowOf, indexSaves, indexStatus, indexStep, indexSteps, indexTry, limitsOf, lostIndexRow, madeMost, mergeCallsAfterOpen, mergeChunk, mergeHeldMost, narrowedAfter, newBuildId, positionOrder, pruneBuilds, putOnce, reachesBytes, reachesOf, readFurther, rootsKeyOf, rowsOfLayer, sliceBounds, storedTypesOf, triesWait, triesWaitMost, triesWaitOf, wordsOf };
2370
+ export { BitmapsCut, BuiltIndex, IndexBounds, IndexData, IndexGroup, IndexLayer, IndexRefusal, IndexRow, IndexSlice, IndexTries, Narrowed, RefusedIndex, ReplacedBuild, belowGraphs, bitmapsJoinHeld, bitmapsJoinMost, boundsOf, builtIndexOf, builtOver, chooseCommits, copyMergedBitmaps, coveredPacks, coversAll, decodeIndexValue, denseBelow, denseBelowReads, edgesMost, entriesHeld, floors, graphMostOf, indexBitmapsCallsAfter, indexReadCallsAfter, indexRowOf, indexSaves, indexStatus, indexStep, indexSteps, indexTry, limitsOf, lostIndexRow, madeMost, mergeCallsAfterOpen, mergeChunk, mergeHeldMost, narrowedAfter, newBuildId, positionOrder, pruneBuilds, putOnce, reachesBytes, reachesOf, readFurther, readJoinHeld, roomy, rootsKeyOf, rowsOfLayer, sliceBounds, storedTypesOf, triesWait, triesWaitMost, triesWaitOf, wordsOf };