@ref0/git 0.12.0 → 0.20.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 (436) hide show
  1. package/dist/access/private-refs.mjs +3 -3
  2. package/dist/auth/access-jwt.mjs +2 -2
  3. package/dist/auth/auth.d.mts +2 -2
  4. package/dist/auth/auth.mjs +3 -6
  5. package/dist/auth/authorize.mjs +4 -20
  6. package/dist/auth/fences.d.mts +1 -2
  7. package/dist/auth/fences.mjs +3 -3
  8. package/dist/auth/grants.mjs +4 -4
  9. package/dist/auth/helpers.mjs +3 -11
  10. package/dist/auth/host-function.mjs +18 -1
  11. package/dist/auth/host-services.mjs +11 -0
  12. package/dist/auth/identify.d.mts +1 -1
  13. package/dist/auth/identify.mjs +3 -3
  14. package/dist/auth/policy.d.mts +27 -7
  15. package/dist/auth/policy.mjs +8 -4
  16. package/dist/auth/token-cleanup.mjs +67 -0
  17. package/dist/auth/token-rows.mjs +1 -1
  18. package/dist/auth/token-text.mjs +9 -1
  19. package/dist/auth/tokens-base.d.mts +35 -0
  20. package/dist/auth/tokens-base.mjs +13 -0
  21. package/dist/auth/tokens-layer.d.mts +2 -28
  22. package/dist/auth/tokens-layer.mjs +6 -12
  23. package/dist/auth/tokens-public.d.mts +3 -3
  24. package/dist/auth/tokens.d.mts +7 -17
  25. package/dist/auth/tokens.mjs +9 -87
  26. package/dist/auth.d.mts +1 -4
  27. package/dist/auth.mjs +1 -3
  28. package/dist/client/answer.mjs +21 -42
  29. package/dist/client/client.d.mts +2 -4
  30. package/dist/client/git-http.mjs +35 -11
  31. package/dist/client/local.mjs +14 -13
  32. package/dist/client/push-upload.mjs +39 -12
  33. package/dist/client/remote.mjs +95 -31
  34. package/dist/client/run-remote-helper.d.mts +1 -0
  35. package/dist/client/run-remote-helper.mjs +58 -24
  36. package/dist/client/slice-push.d.mts +1 -1
  37. package/dist/client/transport.mjs +105 -46
  38. package/dist/contracts/access.d.mts +8 -8
  39. package/dist/contracts/actors.d.mts +2 -34
  40. package/dist/contracts/blobs.d.mts +57 -10
  41. package/dist/contracts/blobs.mjs +16 -2
  42. package/dist/contracts/call-allowance.d.mts +13 -0
  43. package/dist/contracts/call-allowance.mjs +44 -0
  44. package/dist/contracts/calls-spent.mjs +8 -3
  45. package/dist/contracts/client.d.mts +23 -19
  46. package/dist/contracts/commits.d.mts +34 -26
  47. package/dist/contracts/commits.mjs +9 -1
  48. package/dist/contracts/engine.d.mts +6 -1
  49. package/dist/contracts/engine.mjs +10 -1
  50. package/dist/contracts/files.d.mts +12 -12
  51. package/dist/contracts/forks.d.mts +27 -17
  52. package/dist/contracts/git-events.d.mts +29 -1
  53. package/dist/contracts/git-hooks.d.mts +1 -1
  54. package/dist/contracts/git.d.mts +39 -7
  55. package/dist/contracts/git.mjs +3 -2
  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 -9
  59. package/dist/contracts/merges.d.mts +3 -2
  60. package/dist/contracts/objects.d.mts +103 -35
  61. package/dist/contracts/operations.d.mts +3 -0
  62. package/dist/contracts/operations.mjs +12 -2
  63. package/dist/contracts/push-uploads.d.mts +44 -5
  64. package/dist/contracts/push-uploads.mjs +7 -3
  65. package/dist/contracts/queue.d.mts +40 -12
  66. package/dist/contracts/queue.mjs +3 -4
  67. package/dist/contracts/refs.d.mts +50 -25
  68. package/dist/contracts/remote.d.mts +6 -7
  69. package/dist/contracts/remote.mjs +5 -4
  70. package/dist/contracts/repo-records.d.mts +1 -0
  71. package/dist/contracts/repos.d.mts +106 -127
  72. package/dist/contracts/repos.mjs +33 -4
  73. package/dist/contracts/result.d.mts +49 -25
  74. package/dist/contracts/result.mjs +52 -11
  75. package/dist/contracts/rules.d.mts +22 -22
  76. package/dist/contracts/server.d.mts +37 -111
  77. package/dist/contracts/services.d.mts +1 -1
  78. package/dist/contracts/signin.d.mts +1 -1
  79. package/dist/contracts/store.d.mts +6 -5
  80. package/dist/contracts/sync.d.mts +90 -26
  81. package/dist/contracts/sync.mjs +45 -11
  82. package/dist/contracts/tags.d.mts +10 -10
  83. package/dist/contracts/time.d.mts +3 -0
  84. package/dist/contracts/{promises.mjs → time.mjs} +1 -1
  85. package/dist/contracts/tokens.d.mts +15 -22
  86. package/dist/contracts/tokens.mjs +3 -3
  87. package/dist/contracts/topics.d.mts +1 -6
  88. package/dist/contracts/trees.d.mts +12 -12
  89. package/dist/contracts/work.d.mts +87 -12
  90. package/dist/contracts/work.mjs +8 -1
  91. package/dist/core/access.d.mts +1 -2
  92. package/dist/core/access.mjs +46 -13
  93. package/dist/core/ancestry.d.mts +10 -0
  94. package/dist/core/ancestry.mjs +6 -6
  95. package/dist/core/asked.mjs +43 -5
  96. package/dist/core/call-names.mjs +7 -1
  97. package/dist/core/call-services.mjs +13 -4
  98. package/dist/core/events/deliver.d.mts +1 -2
  99. package/dist/core/events/deliver.mjs +48 -33
  100. package/dist/core/events/retired.mjs +119 -0
  101. package/dist/core/forks.mjs +931 -435
  102. package/dist/core/hooks/groups.mjs +1 -1
  103. package/dist/core/imports.mjs +159 -15
  104. package/dist/core/index-job.mjs +128 -37
  105. package/dist/core/index-lost.d.mts +1 -2
  106. package/dist/core/index-lost.mjs +2 -2
  107. package/dist/core/job-view.mjs +8 -9
  108. package/dist/core/loose-tally.mjs +1 -1
  109. package/dist/core/mirror-rows.mjs +19 -4
  110. package/dist/core/objects/blobs.mjs +129 -3
  111. package/dist/core/objects/commits.mjs +16 -6
  112. package/dist/core/objects/lines.mjs +2 -2
  113. package/dist/core/objects/merges.mjs +4 -1
  114. package/dist/core/objects/objects-layer.d.mts +1 -1
  115. package/dist/core/objects/objects-layer.mjs +3 -3
  116. package/dist/core/objects/reading.mjs +24 -13
  117. package/dist/core/objects/tags.mjs +4 -1
  118. package/dist/core/objects/trees.mjs +2 -2
  119. package/dist/core/objects/writing.mjs +2 -2
  120. package/dist/core/own-writes.mjs +1 -1
  121. package/dist/core/parts.d.mts +10 -6
  122. package/dist/core/parts.mjs +3 -11
  123. package/dist/core/promise.mjs +9 -12
  124. package/dist/core/purge.mjs +316 -42
  125. package/dist/core/push-decide.mjs +3 -1
  126. package/dist/core/push-files.d.mts +12 -0
  127. package/dist/core/push-files.mjs +225 -0
  128. package/dist/core/push-repo.d.mts +8 -0
  129. package/dist/core/push-repo.mjs +56 -0
  130. package/dist/core/push.d.mts +17 -0
  131. package/dist/core/push.mjs +153 -70
  132. package/dist/core/receipts.mjs +34 -13
  133. package/dist/core/ref-index-job.mjs +4 -4
  134. package/dist/core/ref-view.mjs +61 -7
  135. package/dist/core/refs.mjs +18 -13
  136. package/dist/core/registered-rows.mjs +2 -2
  137. package/dist/core/repack.mjs +46 -28
  138. package/dist/core/repo-info.mjs +19 -12
  139. package/dist/core/repos.mjs +50 -22
  140. package/dist/core/rules/commit-changes.d.mts +0 -1
  141. package/dist/core/saved-caller-views.d.mts +7 -2
  142. package/dist/core/saved-caller-views.mjs +2 -2
  143. package/dist/core/saved-callers.d.mts +19 -2
  144. package/dist/core/seam.d.mts +16 -26
  145. package/dist/core/seam.mjs +7 -28
  146. package/dist/core/tokens.mjs +1 -1
  147. package/dist/core/view.d.mts +6 -0
  148. package/dist/core/view.mjs +51 -26
  149. package/dist/core/work.mjs +105 -35
  150. package/dist/effect.d.mts +5 -12
  151. package/dist/effect.mjs +3 -10
  152. package/dist/engine/failures.mjs +2 -1
  153. package/dist/engine/reads.mjs +17 -10
  154. package/dist/engine/walk.mjs +4 -4
  155. package/dist/event-streams/event-streams.d.mts +1 -1
  156. package/dist/event-streams/event-streams.mjs +1 -1
  157. package/dist/event-streams/stream.d.mts +3 -3
  158. package/dist/event-streams/stream.mjs +38 -15
  159. package/dist/extend.d.mts +4 -5
  160. package/dist/extend.mjs +3 -2
  161. package/dist/http/answers.mjs +12 -7
  162. package/dist/http/core-parts.mjs +129 -64
  163. package/dist/http/handler.mjs +36 -9
  164. package/dist/http/node.d.mts +14 -1
  165. package/dist/http/node.mjs +61 -31
  166. package/dist/http/parts.d.mts +2 -0
  167. package/dist/http/push-upload-job.mjs +507 -0
  168. package/dist/http/push-uploads.d.mts +1 -0
  169. package/dist/http/push-uploads.mjs +142 -69
  170. package/dist/http/upload-pack.mjs +10 -9
  171. package/dist/index.d.mts +27 -28
  172. package/dist/index.mjs +5 -8
  173. package/dist/lfs/answer.mjs +37 -0
  174. package/dist/lfs/base.d.mts +9 -3
  175. package/dist/lfs/base.mjs +27 -2
  176. package/dist/lfs/copy.d.mts +60 -0
  177. package/dist/lfs/copy.mjs +109 -0
  178. package/dist/lfs/layer.d.mts +15 -1
  179. package/dist/lfs/layer.mjs +28 -13
  180. package/dist/lfs/locks.mjs +2 -2
  181. package/dist/lfs/objects.d.mts +7 -0
  182. package/dist/lfs/objects.mjs +152 -55
  183. package/dist/lfs/pointers.mjs +2 -2
  184. package/dist/lfs/rows.d.mts +13 -0
  185. package/dist/lfs/rows.mjs +42 -8
  186. package/dist/lfs/service.d.mts +1 -7
  187. package/dist/lfs/service.mjs +1 -9
  188. package/dist/lfs/upkeep.mjs +48 -14
  189. package/dist/lfs/upload-most.mjs +5 -5
  190. package/dist/lfs/wire.mjs +6 -31
  191. package/dist/merges/merges.mjs +2 -2
  192. package/dist/node.d.mts +3 -3
  193. package/dist/protocol/bytes/buffers.mjs +13 -5
  194. package/dist/protocol/bytes/reader.mjs +6 -1
  195. package/dist/protocol/bytes/sha256-hasher.d.mts +15 -0
  196. package/dist/protocol/bytes/sha256.d.mts +32 -0
  197. package/dist/protocol/bytes/sha256.mjs +105 -49
  198. package/dist/protocol/bytes/streams.mjs +27 -1
  199. package/dist/protocol/diff/read.d.mts +4 -3
  200. package/dist/protocol/diff/read.mjs +8 -3
  201. package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
  202. package/dist/protocol/objects/lfs-pointer.mjs +1 -3
  203. package/dist/protocol/objects/links-raw.mjs +24 -10
  204. package/dist/protocol/objects/tag.d.mts +1 -1
  205. package/dist/protocol/objects/tree.mjs +23 -6
  206. package/dist/protocol/packs/delta.d.mts +6 -3
  207. package/dist/protocol/packs/delta.mjs +96 -32
  208. package/dist/protocol/packs/idx.d.mts +2 -1
  209. package/dist/protocol/packs/idx.mjs +22 -3
  210. package/dist/protocol/packs/parts.d.mts +4 -1
  211. package/dist/protocol/packs/parts.mjs +10 -7
  212. package/dist/protocol/packs/reader.d.mts +5 -0
  213. package/dist/protocol/packs/reader.mjs +3 -2
  214. package/dist/protocol/packs/writer.mjs +26 -8
  215. package/dist/protocol/wire/advertisement.mjs +9 -4
  216. package/dist/protocol/wire/lines.d.mts +4 -2
  217. package/dist/protocol/wire/lines.mjs +11 -5
  218. package/dist/protocol/wire/push-uploads.mjs +13 -1
  219. package/dist/protocol/wire/v2.mjs +2 -2
  220. package/dist/protocol.d.mts +3 -1
  221. package/dist/protocol.mjs +3 -1
  222. package/dist/queue/advance.mjs +22 -25
  223. package/dist/queue/base.d.mts +55 -0
  224. package/dist/queue/base.mjs +44 -0
  225. package/dist/queue/calls.mjs +51 -54
  226. package/dist/queue/commit.mjs +1 -1
  227. package/dist/queue/host.d.mts +2 -22
  228. package/dist/queue/host.mjs +2 -13
  229. package/dist/queue/layer.d.mts +2 -1
  230. package/dist/queue/layer.mjs +11 -4
  231. package/dist/queue/limits.mjs +2 -0
  232. package/dist/queue/push-option.mjs +9 -24
  233. package/dist/queue/schedule.mjs +1 -1
  234. package/dist/queue/state.mjs +2 -10
  235. package/dist/queue/trim.mjs +6 -4
  236. package/dist/rest/blobs.mjs +29 -5
  237. package/dist/rest/caller.d.mts +4 -4231
  238. package/dist/rest/caller.mjs +5 -1
  239. package/dist/rest/client.d.mts +15 -5
  240. package/dist/rest/client.mjs +23 -2
  241. package/dist/rest/events.mjs +1 -2
  242. package/dist/rest/handler.mjs +4 -57
  243. package/dist/rest/handlers.mjs +68 -9
  244. package/dist/rest/layer.d.mts +2 -2
  245. package/dist/rest/layer.mjs +7 -13
  246. package/dist/rest/me.d.mts +3 -428
  247. package/dist/rest/paths.mjs +1 -0
  248. package/dist/rest/work.mjs +8 -0
  249. package/dist/server/check-fetch.mjs +3 -3
  250. package/dist/server/edge-node.d.mts +14 -15
  251. package/dist/server/edge-node.mjs +12 -12
  252. package/dist/server/edge.d.mts +21 -7
  253. package/dist/server/edge.mjs +32 -11
  254. package/dist/server/extension.mjs +1 -1
  255. package/dist/server/git-layer.d.mts +6 -11
  256. package/dist/server/git-layer.mjs +29 -23
  257. package/dist/server/git-namespace.d.mts +5 -4
  258. package/dist/server/git-namespace.mjs +3 -2
  259. package/dist/server/joined.d.mts +21 -40
  260. package/dist/server/joined.mjs +11 -62
  261. package/dist/server/lifecycle.mjs +65 -69
  262. package/dist/server/registry.mjs +28 -3
  263. package/dist/server/server.mjs +245 -465
  264. package/dist/signin/context.d.mts +1 -2
  265. package/dist/signin/layer.d.mts +1 -1
  266. package/dist/signin/layer.mjs +1 -1
  267. package/dist/storage/allotted.mjs +18 -3
  268. package/dist/storage/batch-upkeep.mjs +274 -0
  269. package/dist/{core/purge.d.mts → storage/batches.d.mts} +4 -4
  270. package/dist/storage/batches.mjs +344 -0
  271. package/dist/storage/budget.mjs +2 -2
  272. package/dist/storage/calls.d.mts +1 -2
  273. package/dist/storage/calls.mjs +144 -158
  274. package/dist/storage/chunks.d.mts +9 -0
  275. package/dist/storage/chunks.mjs +297 -0
  276. package/dist/storage/clean-up.mjs +85 -19
  277. package/dist/storage/counted-bucket.mjs +4 -4
  278. package/dist/storage/fetch.d.mts +1 -0
  279. package/dist/storage/fetch.mjs +298 -216
  280. package/dist/storage/file-limits.mjs +24 -0
  281. package/dist/storage/host-bucket.mjs +1 -2
  282. package/dist/storage/id-mix.mjs +19 -5
  283. package/dist/storage/index-bitmaps.mjs +9 -2
  284. package/dist/storage/index-build.d.mts +1 -1
  285. package/dist/storage/index-build.mjs +185 -84
  286. package/dist/storage/index-fetch.mjs +128 -74
  287. package/dist/storage/index-files.d.mts +3 -0
  288. package/dist/storage/index-files.mjs +10 -5
  289. package/dist/storage/index-graph.mjs +72 -22
  290. package/dist/storage/index-reach.mjs +33 -5
  291. package/dist/storage/index-remap.mjs +208 -65
  292. package/dist/storage/index-shallow.mjs +5 -3
  293. package/dist/storage/index-whole.mjs +127 -0
  294. package/dist/storage/largest-files.mjs +48 -0
  295. package/dist/storage/layout.mjs +23 -0
  296. package/dist/storage/lfs-pointers.mjs +10 -1
  297. package/dist/storage/loose.d.mts +7 -4
  298. package/dist/storage/loose.mjs +214 -67
  299. package/dist/storage/memory-budget.mjs +44 -8
  300. package/dist/storage/merge-plan.mjs +3 -2
  301. package/dist/storage/merge-row.mjs +7 -1
  302. package/dist/storage/merge-stream.mjs +164 -25
  303. package/dist/storage/merge-walk.mjs +8 -4
  304. package/dist/storage/merge-write.mjs +1 -1
  305. package/dist/storage/merge.d.mts +1 -1
  306. package/dist/storage/merge.mjs +1 -1
  307. package/dist/storage/object-rows.d.mts +1 -0
  308. package/dist/storage/object-rows.mjs +385 -65
  309. package/dist/storage/oid-table.mjs +171 -0
  310. package/dist/storage/pack-order.mjs +8 -4
  311. package/dist/storage/pack-ranges.d.mts +1 -2
  312. package/dist/storage/pack-ranges.mjs +4 -5
  313. package/dist/storage/pack-reads.d.mts +2 -1
  314. package/dist/storage/pack-reads.mjs +165 -49
  315. package/dist/storage/pack-receive.d.mts +1 -1
  316. package/dist/storage/pack-receive.mjs +85 -27
  317. package/dist/storage/packs.d.mts +1 -1
  318. package/dist/storage/packs.mjs +172 -86
  319. package/dist/storage/placed-reads.mjs +1 -1
  320. package/dist/storage/plan-columns.d.mts +4 -0
  321. package/dist/storage/plan-columns.mjs +238 -0
  322. package/dist/storage/prune-keep.mjs +299 -37
  323. package/dist/storage/prune-walk.mjs +240 -62
  324. package/dist/storage/prune.mjs +749 -213
  325. package/dist/storage/push-allotment.mjs +91 -12
  326. package/dist/storage/push-uploads.mjs +40 -16
  327. package/dist/storage/pushed-commits.mjs +4 -2
  328. package/dist/storage/quarantine.d.mts +1 -1
  329. package/dist/storage/quarantine.mjs +9 -9
  330. package/dist/storage/range-cache.mjs +125 -8
  331. package/dist/storage/ready.d.mts +1 -1
  332. package/dist/storage/ready.mjs +55 -25
  333. package/dist/storage/receive-bounds.mjs +51 -15
  334. package/dist/storage/receive-state.mjs +8 -0
  335. package/dist/storage/receive-steps.mjs +71 -18
  336. package/dist/storage/repack-backlog.mjs +6 -3
  337. package/dist/storage/repack.d.mts +2 -2
  338. package/dist/storage/repack.mjs +1 -8
  339. package/dist/storage/rows.d.mts +1 -1
  340. package/dist/storage/rows.mjs +13 -2
  341. package/dist/storage/runs.mjs +195 -43
  342. package/dist/storage/send-list.d.mts +1 -0
  343. package/dist/storage/send-list.mjs +54 -10
  344. package/dist/storage/shallow.d.mts +1 -0
  345. package/dist/storage/shallow.mjs +26 -4
  346. package/dist/storage/single-flight.mjs +13 -7
  347. package/dist/storage/stream-whole.mjs +132 -28
  348. package/dist/storage/unpack.mjs +371 -79
  349. package/dist/storage/visible.mjs +31 -3
  350. package/dist/storage/walk.mjs +194 -39
  351. package/dist/storage/wants.mjs +5 -5
  352. package/dist/store/bodies.mjs +38 -0
  353. package/dist/store/call-count.d.mts +8 -12
  354. package/dist/store/call-count.mjs +34 -46
  355. package/dist/store/catalogue.d.mts +2 -2
  356. package/dist/store/catalogue.mjs +146 -35
  357. package/dist/store/crossing.mjs +1 -3
  358. package/dist/store/cursor-seal-namespace.d.mts +2 -0
  359. package/dist/store/cursor-seal-public.d.mts +5 -0
  360. package/dist/store/cursor-seal-public.mjs +5 -0
  361. package/dist/store/cursor-seal.d.mts +16 -3
  362. package/dist/store/cursor-seal.mjs +40 -18
  363. package/dist/store/door.mjs +183 -0
  364. package/dist/store/errors.d.mts +3 -4
  365. package/dist/store/errors.mjs +24 -34
  366. package/dist/store/git-store.mjs +25 -7
  367. package/dist/store/job-try.mjs +9 -32
  368. package/dist/store/list-job.mjs +44 -8
  369. package/dist/store/records.d.mts +5 -0
  370. package/dist/store/records.mjs +12 -6
  371. package/dist/store/repo-record.d.mts +10 -9
  372. package/dist/store/repo-record.mjs +123 -28
  373. package/dist/store/reservations.mjs +1 -1
  374. package/dist/store/scopes.mjs +21 -2
  375. package/dist/store/settle.mjs +4 -4
  376. package/dist/sync/bound.d.mts +2 -0
  377. package/dist/sync/bound.mjs +11 -2
  378. package/dist/sync/github.d.mts +6 -1
  379. package/dist/sync/github.mjs +56 -44
  380. package/dist/sync/http.mjs +36 -1
  381. package/dist/sync/import.mjs +32 -18
  382. package/dist/sync/layer.mjs +6 -2
  383. package/dist/sync/lfs-batch.mjs +118 -0
  384. package/dist/sync/lfs-copy.mjs +262 -0
  385. package/dist/sync/mirror.mjs +227 -151
  386. package/dist/sync/said.mjs +16 -37
  387. package/dist/sync/smart-http.mjs +4 -2
  388. package/dist/sync/step.mjs +58 -30
  389. package/dist/sync/tries.mjs +52 -21
  390. package/dist/sync.d.mts +2 -2
  391. package/dist/topics/advance.mjs +10 -11
  392. package/dist/topics/base.d.mts +15 -0
  393. package/dist/topics/base.mjs +8 -0
  394. package/dist/topics/host.mjs +2 -20
  395. package/dist/topics/layer.d.mts +4 -9
  396. package/dist/topics/layer.mjs +3 -4
  397. package/dist/topics/members.mjs +4 -4
  398. package/dist/topics/public.d.mts +2 -1
  399. package/dist/topics/topic.mjs +2 -2
  400. package/package.json +5 -9
  401. package/dist/auth/bridge.mjs +0 -30
  402. package/dist/auth/helpers.d.mts +0 -17
  403. package/dist/contracts/promises.d.mts +0 -39
  404. package/dist/core/call-names.d.mts +0 -3
  405. package/dist/core/clock.mjs +0 -18
  406. package/dist/core/registered-rows.d.mts +0 -5
  407. package/dist/core/repack.d.mts +0 -11
  408. package/dist/http/handler.d.mts +0 -2
  409. package/dist/lfs/calls.mjs +0 -26
  410. package/dist/rest/api.d.mts +0 -23
  411. package/dist/rest/blobs.d.mts +0 -825
  412. package/dist/rest/commits.d.mts +0 -3510
  413. package/dist/rest/errors.d.mts +0 -2104
  414. package/dist/rest/events.d.mts +0 -423
  415. package/dist/rest/files.d.mts +0 -1330
  416. package/dist/rest/forks.d.mts +0 -2136
  417. package/dist/rest/handler.d.mts +0 -21
  418. package/dist/rest/handlers.d.mts +0 -8
  419. package/dist/rest/merges.d.mts +0 -473
  420. package/dist/rest/queue.d.mts +0 -5861
  421. package/dist/rest/refs.d.mts +0 -2959
  422. package/dist/rest/repos.d.mts +0 -2539
  423. package/dist/rest/tags.d.mts +0 -1304
  424. package/dist/rest/tokens.d.mts +0 -2590
  425. package/dist/rest/topics.d.mts +0 -2204
  426. package/dist/rest/trees.d.mts +0 -1693
  427. package/dist/rest/work.d.mts +0 -1248
  428. package/dist/rest.d.mts +0 -2
  429. package/dist/rest.mjs +0 -1
  430. package/dist/server/lifecycle.d.mts +0 -2
  431. package/dist/server/registry.d.mts +0 -16
  432. package/dist/server/server.d.mts +0 -36
  433. package/dist/storage/repack-job.d.mts +0 -3
  434. package/dist/store/promises.d.mts +0 -11
  435. package/dist/store/promises.mjs +0 -327
  436. package/dist/topics/host.d.mts +0 -7
@@ -6,17 +6,20 @@ import { repoScope } from "../store/scopes.mjs";
6
6
  import { anySet, bitCount, clearBit, isSet, nextSet, setBit } from "./bits.mjs";
7
7
  import { bitmapWords } from "./ewah.mjs";
8
8
  import { ewahMostWords } from "./index-bitmaps.mjs";
9
- import { builtIndexOf, coveredPacks, coversAll, decodeIndexValue } from "./index-build.mjs";
10
- import { openTypes, typeOfCode } from "./index-files.mjs";
9
+ import { builtIndexOf, builtOver, coveredPacks, coversAll, decodeIndexValue } from "./index-build.mjs";
10
+ import { openBases, openTypes, typeOfCode } from "./index-files.mjs";
11
11
  import { indexShallow, numberIn, numbersIn } from "./index-shallow.mjs";
12
+ import { oidTable } from "./oid-table.mjs";
12
13
  import { listOf } from "./send-list.mjs";
13
- import { ByGeneration, graphChunk, graphRows, openGraphLayers, openIndexGraph } from "./index-graph.mjs";
14
+ import { ByGeneration, graphChunk, graphRows, keptIdsBytes, openGraphLayers, openIndexGraph } from "./index-graph.mjs";
14
15
  import { openLayerBitmaps, openLayout, orWords } from "./index-layers.mjs";
15
16
  import { indexFiles, indexRowKey, isPackId, packFiles } from "./layout.mjs";
17
+ import { heldFiles, indexFilesOf, wholeFiles } from "./index-whole.mjs";
16
18
  import { rangeCached, rangeEntriesBytes } from "./range-cache.mjs";
17
19
  import { joinBytes, missing } from "./link-join.mjs";
18
20
  import { placedReads } from "./placed-reads.mjs";
19
- import { lost, notHeld } from "./walk.mjs";
21
+ import { withRootsSent } from "./shallow.mjs";
22
+ import { idsIn, lost, notHeld } from "./walk.mjs";
20
23
  import * as Effect from "effect/Effect";
21
24
  import * as Data from "effect/Data";
22
25
  // src/storage/index-fetch.ts
@@ -47,6 +50,16 @@ const rangeCacheMost = 16777216;
47
50
  */
48
51
  const rankBytes = 8;
49
52
  /**
53
+ * The largest `.idx` ID window a pack adds to the walk's range allowance, 1 MiB: a pack of 52,428
54
+ * objects or fewer, whose joins then read the window once, not once a level (#2523). Past it, #522
55
+ * stands: a larger pack adds no ID window, as holding its IDs would hold most of what loading its
56
+ * `.idx` holds. It sizes the fetch's one allowance, which every pack's ranges share: it doesn't
57
+ * choose whose windows stay, so a larger pack's may stay in a smaller one's share.
58
+ */
59
+ const keptIdWindowMost = 1048576;
60
+ /** What a pack of `objects` adds to the walk's range allowance: its `.pos` places, and its ID window under the bound. */
61
+ const keptRangeBytes = (objects) => objects * rankBytes + (objects * 20 <= keptIdWindowMost ? objects * 20 : 0) + rangeEntriesBytes;
62
+ /**
50
63
  * What one stored bitmap holds once its layer's bitmaps are open: its table row as read and its
51
64
  * words copied, its entry, and its places in `openLayerBitmaps`' maps and `numberAt`. Measured on
52
65
  * Node 26 at 268–282 B a bitmap over 1,000 to 100,000 of them; 320 leaves room.
@@ -90,12 +103,13 @@ const rowsOf = (layer) => layer.groups.reduce((sum, group) => sum + group.rows,
90
103
  /**
91
104
  * The most bucket calls opening an index's layers for a fetch makes: each layer's `.graph`'s two
92
105
  * (head and fanout, tail), its `.bitmaps`' three when it has any (head, table, tail), its
93
- * `.types` header's one, its region's one when it has rows, and each of its packs' `.idx` head
94
- * and fanout and `.pos` header. No covered pack's `.idx` and `.rev` are loaded whole: the layout
95
- * and the send list read them by range. The row's own read is the one store call before it (#522).
106
+ * `.types` header's one, its region's one when it has rows, its `.bases`' two when it has deltas
107
+ * (head, block index, #2523), and each of its packs' `.idx` head and fanout and `.pos` header. No
108
+ * covered pack's `.idx` and `.rev` are loaded whole: the layout and the send list read them by
109
+ * range. The row's own read is the one store call before it (#522).
96
110
  */
97
111
  const fetchOpenCalls = (layers) => ({
98
- bucket: layers.reduce((sum, layer) => sum + 2 + (layer.bitmaps > 0 ? 3 : 0) + 1 + (rowsOf(layer) > 0 ? 1 : 0) + 2 * packsOf(layer), 0),
112
+ bucket: layers.reduce((sum, layer) => sum + 2 + (layer.bitmaps > 0 ? 3 : 0) + 1 + (rowsOf(layer) > 0 ? 1 : 0) + (layer.deltas > 0 ? 2 : 0) + 2 * packsOf(layer), 0),
99
113
  store: 0
100
114
  });
101
115
  /**
@@ -108,6 +122,27 @@ const regionBytes = (layers) => {
108
122
  return rows * 24 + (runs > 1 ? rows * 84 : 0);
109
123
  };
110
124
  /**
125
+ * `source`'s bucket with the index's files held, when they're small: each read whole, at once, one
126
+ * call each, so the walk and the send list wait on one round, not one a range (#2523). The least
127
+ * they can be, from the row and the listing, is checked first. Then `wholeMost` is charged before
128
+ * any read, the reads stop there, and what the files don't hold goes back. `undefined` when they'd
129
+ * pass it, or did, so the index is read by range as before.
130
+ */
131
+ const heldIndex = /* @__PURE__ */ Effect.fnUntraced(function* (source, row, covered, ahead, read) {
132
+ const most = source.wholeMost ?? 1048576;
133
+ const packs = source.listed.packs.filter(({ id }) => covered.has(id));
134
+ const files = indexFilesOf(source.listed.repo, row.layers, packs);
135
+ if (files === void 0 || files.reduce((sum, file) => sum + file.least, 0) > most) return void 0;
136
+ yield* ahead({
137
+ bucket: files.length,
138
+ store: 0
139
+ });
140
+ yield* read.hold(most);
141
+ const whole = yield* wholeFiles(source.bucket, files, most);
142
+ yield* read.release(most - (whole?.bytes ?? 0));
143
+ return whole === void 0 ? void 0 : heldFiles(source.bucket, whole.files);
144
+ });
145
+ /**
111
146
  * The repo's index, opened: its row read through the request's store, 1 call, then its layers'
112
147
  * files, `fetchOpenCalls` gets, forecast before any is made. `undefined` when there's no row, a
113
148
  * refused one, or one whose layers don't cover `listed`, as when a row newer than it names a
@@ -115,7 +150,7 @@ const regionBytes = (layers) => {
115
150
  */
116
151
  const openFetchIndex = /* @__PURE__ */ Effect.fnUntraced(function* (source, ahead, read) {
117
152
  const { hold } = read;
118
- const { store, bucket, listed } = source;
153
+ const { store, listed } = source;
119
154
  yield* ahead({
120
155
  bucket: 0,
121
156
  store: 1
@@ -125,34 +160,41 @@ const openFetchIndex = /* @__PURE__ */ Effect.fnUntraced(function* (source, ahea
125
160
  reads: [indexRowKey]
126
161
  });
127
162
  const row = builtIndexOf(decodeIndexValue(snapshot.results[0]?.[0]?.value));
128
- if (row === void 0 || !coversAll(row.layers, listed)) return void 0;
163
+ if (row === void 0 || !builtOver(row, read.roots) || !coversAll(row.layers, listed)) return void 0;
129
164
  if (source.opened !== void 0) source.opened.opened = true;
130
- yield* ahead(fetchOpenCalls(row.layers));
131
- yield* hold(regionBytes(row.layers));
132
- const graphs = [];
133
- let first = 0;
134
- for (const layer of row.layers) {
135
- const key = indexFiles(listed.repo, layer.build).graph;
136
- const graph = yield* openIndexGraph(bucket, key, layer.graphFirst);
137
- if (layer.graphFirst !== first || graph.commits !== layer.commits) return yield* Effect.fail(loss(`${key} holds ${graph.commits} from ${layer.graphFirst}, its row ${layer.commits}, where the layers below end at ${first}`));
138
- graphs.push(graph);
139
- first += graph.commits;
140
- }
141
165
  const covered = coveredPacks(row.layers);
166
+ const held = yield* heldIndex(source, row, covered, ahead, read);
167
+ const bucket = held ?? source.bucket;
168
+ yield* ahead(held === void 0 ? fetchOpenCalls(row.layers) : noCalls);
169
+ yield* hold(regionBytes(row.layers));
142
170
  yield* hold(openedBitmapBytes * row.layers.reduce((sum, layer) => sum + layer.bitmaps, 0));
143
- const bitmaps = yield* openLayerBitmaps(bucket, listed.repo, row.layers);
144
- const types = yield* Effect.forEach(row.layers, (layer) => openTypes(bucket, indexFiles(listed.repo, layer.build).types, layer.positions));
145
- const rangeBytes = Math.min(rangeCacheMost, listed.packs.filter(({ id }) => covered.has(id)).reduce((sum, pack) => sum + pack.objects * rankBytes + rangeEntriesBytes, 0));
171
+ const keepIds = held === void 0;
172
+ if (keepIds) yield* hold(row.layers.reduce((sum, layer) => sum + keptIdsBytes(layer.commits), 0));
173
+ const rangeBytes = held !== void 0 ? 0 : Math.min(rangeCacheMost, listed.packs.filter(({ id }) => covered.has(id)).reduce((sum, pack) => sum + keptRangeBytes(pack.objects), 0));
146
174
  yield* hold(rangeBytes);
147
175
  const ranges = rangeCached(bucket, rangeBytes, { evict: false });
148
176
  const told = read.onLoading?.((id) => {
149
177
  if (isPackId(id)) ranges.forget(packFiles(id).idx);
150
178
  });
151
179
  const { loadedOf } = read;
152
- const layout = yield* openLayout(ranges.bucket, listed, row.layers, void 0, loadedOf === void 0 ? { cached: true } : {
153
- cached: true,
154
- loadedOf
155
- });
180
+ const deltaLayers = row.layers.filter((layer) => layer.deltas > 0);
181
+ const [graphs, bitmaps, types, layout, opened] = yield* Effect.all([
182
+ Effect.forEach(row.layers, (layer) => openIndexGraph(bucket, indexFiles(listed.repo, layer.build).graph, layer.graphFirst, { keepIds }), { concurrency: "unbounded" }),
183
+ openLayerBitmaps(bucket, listed.repo, row.layers),
184
+ Effect.forEach(row.layers, (layer) => openTypes(bucket, indexFiles(listed.repo, layer.build).types, layer.positions), { concurrency: "unbounded" }),
185
+ openLayout(ranges.bucket, listed, row.layers, void 0, loadedOf === void 0 ? { cached: true } : {
186
+ cached: true,
187
+ loadedOf
188
+ }),
189
+ Effect.forEach(deltaLayers, (layer) => openBases(bucket, indexFiles(listed.repo, layer.build).bases, layer.first + layer.positions, layer.deltas), { concurrency: "unbounded" })
190
+ ], { concurrency: "unbounded" });
191
+ const bases = new Map(deltaLayers.map((layer, at) => [layer, opened[at]]));
192
+ let first = 0;
193
+ for (const [at, layer] of row.layers.entries()) {
194
+ const graph = graphs[at];
195
+ if (graph === void 0 || layer.graphFirst !== first || graph.commits !== layer.commits) return yield* Effect.fail(loss(`${indexFiles(listed.repo, layer.build).graph} holds ${graph?.commits} from ${layer.graphFirst}, its row ${layer.commits}, where the layers below end at ${first}`));
196
+ first += graph.commits;
197
+ }
156
198
  const letRangesGo = Effect.andThen(Effect.sync(() => {
157
199
  told?.();
158
200
  ranges.clear();
@@ -171,50 +213,41 @@ const openFetchIndex = /* @__PURE__ */ Effect.fnUntraced(function* (source, ahea
171
213
  types,
172
214
  layout,
173
215
  numberAt,
174
- letRangesGo
216
+ letRangesGo,
217
+ bucket,
218
+ bases,
219
+ held: held !== void 0
175
220
  };
176
221
  });
177
222
  /**
178
- * IDs, 20 bytes each, and a kind for each, grown as a level's trees name them. An ID is kept once:
179
- * a slot table, twice its capacity, finds one already added, so a level holds what's distinct in
180
- * it, not every snapshot's entries (#1702).
223
+ * A level's IDs, each kept once in an ID table, and a kind for each by its ordinal, grown as the
224
+ * level's trees name them: so a level holds what's distinct in it, not every snapshot's entries
225
+ * (#1702). Both double together when the table is full, its slots twice its capacity.
181
226
  */
182
227
  var Frontier = class {
183
- ids = /* @__PURE__ */ new Uint8Array(1280);
228
+ table = oidTable(64);
184
229
  kinds = /* @__PURE__ */ new Uint8Array(64);
185
- slots = /* @__PURE__ */ new Uint32Array(128);
186
- count = 0;
230
+ get count() {
231
+ return this.table.size;
232
+ }
233
+ /** Its IDs end to end, as a pack index's join reads them. */
234
+ get ids() {
235
+ return this.table.ids;
236
+ }
187
237
  add(id, kind) {
188
- if (this.count === this.kinds.length) {
189
- const ids = new Uint8Array(this.ids.length * 2);
190
- ids.set(this.ids);
191
- this.ids = ids;
192
- const kinds = new Uint8Array(this.kinds.length * 2);
238
+ if (this.table.size === this.table.capacity) {
239
+ const capacity = this.table.capacity * 2;
240
+ this.table.grow(capacity);
241
+ const kinds = new Uint8Array(capacity);
193
242
  kinds.set(this.kinds);
194
243
  this.kinds = kinds;
195
- this.slots = new Uint32Array(this.slots.length * 2);
196
- for (let at = 0; at < this.count; at += 1) this.slots[this.free(this.ids, at * 20)] = at + 1;
197
244
  }
198
- const slot = this.free(id, 0);
199
- if (this.slots[slot] !== 0) return;
200
- this.ids.set(id, this.count * 20);
201
- this.kinds[this.count] = kind;
202
- this.count += 1;
203
- this.slots[slot] = this.count;
245
+ const next = this.table.size;
246
+ if (this.table.addBytes(id) === next) this.kinds[next] = kind;
204
247
  }
205
- /** The slot holding the ID at `from` in `bytes`, or the empty one it goes in. */
206
- free(bytes, from) {
207
- const mask = this.slots.length - 1;
208
- let slot = ((bytes[from] ?? 0) | (bytes[from + 1] ?? 0) << 8 | (bytes[from + 2] ?? 0) << 16 | (bytes[from + 3] ?? 0) << 24) & mask;
209
- for (;;) {
210
- const held = this.slots[slot] ?? 0;
211
- if (held === 0 || this.same(held - 1, bytes, from)) return slot;
212
- slot = slot + 1 & mask;
213
- }
214
- }
215
- same(at, bytes, from) {
216
- for (let byte = 0; byte < 20; byte += 1) if (this.ids[at * 20 + byte] !== bytes[from + byte]) return false;
217
- return true;
248
+ /** The ID at `at`, in hex. */
249
+ oidAt(at) {
250
+ return this.table.oidAt(at);
218
251
  }
219
252
  /** What it holds at most, grown twice over: `fetchRootFrontierBytes` an ID. */
220
253
  static bytes(count) {
@@ -228,6 +261,11 @@ const blobKind = 2;
228
261
  * today's walk does. See the file's comment for how; the bounds are `shape-2.md`'s §6.
229
262
  */
230
263
  const indexSendSet = (input) => indexSendSetOrNot(input).pipe(Effect.catchTag("Unindexed", () => Effect.succeed(void 0)));
264
+ /** The index path over `source`. */
265
+ const indexPath = (source) => ({
266
+ source,
267
+ send: indexSendSet
268
+ });
231
269
  const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
232
270
  const { source, read, request, ahead } = input;
233
271
  const { indexed, sizesAt, heldAt, unplaced: unplacedOf } = read;
@@ -241,12 +279,13 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
241
279
  ranges: layout.ranges,
242
280
  layers: row.layers,
243
281
  listed: source.listed,
244
- bucket: source.bucket,
282
+ bucket: index.bucket,
245
283
  read,
246
284
  indexed,
247
285
  heldAt,
248
286
  outside,
249
- ahead
287
+ ahead,
288
+ bases: index.bases
250
289
  });
251
290
  /** `placed`'s objects read at their positions, and `beside`'s, which the index doesn't place, past it. */
252
291
  const readSplit = Effect.fnUntraced(function* (placed, beside, newLevel = true) {
@@ -343,13 +382,13 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
343
382
  const position = positions[at] ?? 4294967295;
344
383
  if (level < 0) {
345
384
  if (reads) {
346
- reading.push(hexOf(frontier.ids.subarray(at * 20, at * 20 + 20)));
385
+ reading.push(frontier.oidAt(at));
347
386
  placed.push(position);
348
387
  }
349
388
  continue;
350
389
  }
351
390
  if (position === 4294967295) {
352
- const oid = hexOf(frontier.ids.subarray(at * 20, at * 20 + 20));
391
+ const oid = frontier.oidAt(at);
353
392
  if (heldExtras.has(oid) || side === "wanted" && sentExtras.has(oid)) continue;
354
393
  if (side === "held") {
355
394
  yield* read.hold(heldExtraBytes);
@@ -367,7 +406,7 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
367
406
  if (blocked(side, position)) continue;
368
407
  setBit(bits, position);
369
408
  if (kind === "tree" && reads) {
370
- reading.push(hexOf(frontier.ids.subarray(at * 20, at * 20 + 20)));
409
+ reading.push(frontier.oidAt(at));
371
410
  placed.push(position);
372
411
  }
373
412
  }
@@ -400,10 +439,11 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
400
439
  if (tree.type !== "tree" || tree.entries === void 0) return yield* Effect.fail(loss(`${oid}, named as a tree, is a ${tree.type}`));
401
440
  const extra = side === "wanted" && position === 4294967295 ? sentExtras.get(oid) : void 0;
402
441
  if (extra !== void 0) extra.size = tree.size;
403
- const growing = next.count + tree.entries.trees.length + tree.entries.blobs.length;
442
+ const { trees, blobs } = tree.entries;
443
+ const growing = next.count + idsIn(trees) + idsIn(blobs);
404
444
  yield* holdStep(Frontier.bytes(frontier.count) + frontier.count * 4 + Frontier.bytes(growing));
405
- for (const entry of tree.entries.trees) next.add(oidBytes(entry), treeKind);
406
- for (const entry of tree.entries.blobs) next.add(oidBytes(entry), blobKind);
445
+ for (let at = 0; at < trees.length; at += 20) next.add(trees.subarray(at, at + 20), treeKind);
446
+ for (let at = 0; at < blobs.length; at += 20) next.add(blobs.subarray(at, at + 20), blobKind);
407
447
  read.letGo(tree);
408
448
  }
409
449
  yield* read.letGoReads(asked.length);
@@ -668,6 +708,18 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
668
708
  if (position === 4294967295 ? heldExtras.has(tag) : isSet(held, position)) had.add(tag);
669
709
  }
670
710
  }
711
+ const rootsSent = /* @__PURE__ */ new Set();
712
+ const rootsAt = row.layers.flatMap((layer) => (layer.roots ?? []).filter((position) => isSet(send, position)));
713
+ const packed = rootsAt.filter((position) => layout.ranges.some((pack) => position >= pack.base && position < pack.base + pack.count));
714
+ if (packed.length > 0) yield* ahead({
715
+ bucket: index.held ? packed.length : 2 * packed.length,
716
+ store: 0
717
+ });
718
+ for (const position of rootsAt) {
719
+ const root = hexOf(yield* layout.idAt(position));
720
+ if (read.roots.has(root)) rootsSent.add(root);
721
+ }
722
+ for (const root of read.roots) if (sentExtras.get(root)?.kind === "commit") rootsSent.add(root);
671
723
  yield* index.letRangesGo;
672
724
  const windows = [];
673
725
  for (const [at, layer] of row.layers.entries()) {
@@ -685,7 +737,7 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
685
737
  }
686
738
  }
687
739
  yield* ahead({
688
- bucket: windows.length,
740
+ bucket: index.held ? 0 : windows.length,
689
741
  store: 0
690
742
  });
691
743
  let sending = 0;
@@ -723,9 +775,11 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
723
775
  ranges,
724
776
  layers: row.layers,
725
777
  listed: source.listed,
726
- bucket: source.bucket,
778
+ bucket: index.bucket,
727
779
  read,
728
- ahead
780
+ ahead,
781
+ bases: index.bases,
782
+ indexHeld: index.held
729
783
  };
730
784
  if (filter?.kind === "blob:limit") {
731
785
  listInput.blobsUnder = filter.bytes;
@@ -777,7 +831,7 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
777
831
  return restIds.has(oid) || position !== 4294967295 && isSet(send, position);
778
832
  }));
779
833
  }),
780
- deepened
834
+ deepened: withRootsSent(deepened, rootsSent)
781
835
  };
782
836
  });
783
- export { fetchOpenCalls, indexEligible, indexSendSet };
837
+ export { fetchOpenCalls, indexEligible, indexPath, indexSendSet, keptRangeBytes };
@@ -0,0 +1,3 @@
1
+ import "../contracts/objects.mjs";
2
+ import "../contracts/result.mjs";
3
+ import "effect/Effect";
@@ -201,12 +201,17 @@ const codes = (bytes, skip, count) => {
201
201
  }
202
202
  return codes;
203
203
  };
204
- /** The `.bases` at `key` opened: its header, then its block index. */
205
- const openBases = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, positions) {
206
- const head = yield* readExactly(bucket, key, 0, 16);
207
- const deltas = (yield* checkHeader(key, head, basesMagic, positions)).getUint32(12);
204
+ /**
205
+ * The `.bases` at `key` opened: its header, then its block index. Given the `deltas` its index row
206
+ * lists, it reads both at once (#2523), and fails as lost when the header lists other.
207
+ */
208
+ const openBases = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, positions, listed) {
208
209
  const count = Math.ceil(positions / basesBlock);
209
- const indexed = yield* readExactly(bucket, key, 16 + deltas * 8, count * 4);
210
+ const blockIndex = (deltas) => readExactly(bucket, key, 16 + deltas * 8, count * 4);
211
+ const [head, early] = listed === void 0 ? [yield* readExactly(bucket, key, 0, 16), void 0] : yield* Effect.all([readExactly(bucket, key, 0, 16), blockIndex(listed)], { concurrency: "unbounded" });
212
+ const deltas = (yield* checkHeader(key, head, basesMagic, positions)).getUint32(12);
213
+ if (listed !== void 0 && deltas !== listed) return yield* Effect.fail(lost(`${key} holds ${deltas} deltas, its index row ${listed}`));
214
+ const indexed = early ?? (yield* blockIndex(deltas));
210
215
  const blocks = new DataView(indexed.buffer, indexed.byteOffset, indexed.byteLength);
211
216
  const firstOf = (block) => block >= count ? deltas : blocks.getUint32(block * 4);
212
217
  return {
@@ -8,6 +8,7 @@ import { graphMagic } from "../protocol/packs/graph.mjs";
8
8
  import { PackTransportError, boundedSource, packReadBytes } from "../protocol/packs/reader.mjs";
9
9
  import { bucketStream } from "./calls.mjs";
10
10
  import { startPut } from "./merge.mjs";
11
+ import { keepUnclosed } from "./index-bitmaps.mjs";
11
12
  import { readExactly } from "./pack-ranges.mjs";
12
13
  import { compareIds, idsBytes, orderById } from "./raw-ids.mjs";
13
14
  import * as Effect from "effect/Effect";
@@ -126,7 +127,7 @@ const same = (a, b) => a.length === b.length && a.every((byte, at) => byte === b
126
127
  * as the file passes it, and a file that ends short of it is refused once its trailer is read.
127
128
  */
128
129
  const openPackGraph = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, size) {
129
- const source = yield* Effect.uninterruptibleMask((restore) => Effect.flatMap(restore(bucketStream(bucket, key)), (body) => {
130
+ const source = yield* Effect.uninterruptible(Effect.flatMap(bucketStream(bucket, key), (body) => {
130
131
  if (body === void 0) return Effect.fail(lost(`${key} is missing`));
131
132
  const opened = boundedSource(body, /* @__PURE__ */ new Uint8Array(0), new BufferMeter(graphPieceBytes));
132
133
  return Effect.as(Effect.addFinalizer(() => opened.cancel), opened);
@@ -656,8 +657,36 @@ const generationsBelow = /* @__PURE__ */ Effect.fnUntraced(function* (below, ref
656
657
  });
657
658
  /** Commits a chunked read of the graph takes at a time: 640 KiB of IDs. */
658
659
  const graphChunk = 32768;
659
- /** The index graph at `key`, opened: its header and fanout. A layer's commits start at `first`. */
660
- const openIndexGraph = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, first = 0) {
660
+ /**
661
+ * What a graph of `commits` keeps of its IDs with `keepIds`: one chunk, its last read, 20 B a
662
+ * commit. The caller charges it before the open.
663
+ */
664
+ const keptIdsBytes = (commits) => Math.min(commits, graphChunk) * 20;
665
+ /** A `KeptIds` that holds nothing yet: `keptIdsBytes` at most, its maker's to charge. */
666
+ const keptIdsOf = () => {
667
+ let kept;
668
+ let dropped = false;
669
+ return {
670
+ at: (from) => kept?.from === from ? kept.bytes : void 0,
671
+ keep: (from, bytes) => {
672
+ if (!dropped) kept = {
673
+ from,
674
+ bytes
675
+ };
676
+ },
677
+ drop: () => {
678
+ kept = void 0;
679
+ dropped = true;
680
+ }
681
+ };
682
+ };
683
+ /**
684
+ * The index graph at `key`, opened: its header and fanout. A layer's commits start at `first`.
685
+ * With `keepIds`, the last chunk of IDs a lookup read is kept, so the next lookup in it reads none
686
+ * (#2523): `keptIdsBytes` at most, the caller's to charge. With `kept`, it's kept there, for a
687
+ * caller that lets it go before the graph's end.
688
+ */
689
+ const openIndexGraph = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, first = 0, { keepIds = false, kept } = {}) {
661
690
  const head = yield* readExactly(bucket, key, 0, 1040);
662
691
  if (magic.some((byte, at) => head[at] !== byte) || word(head, 4) !== 1) return yield* Effect.fail(lost(`${key} isn't a version 1 graph`));
663
692
  const commits = word(head, 8);
@@ -741,13 +770,22 @@ const openIndexGraph = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key,
741
770
  rows: yield* rowsAt(from, count)
742
771
  };
743
772
  });
773
+ const keptIds = kept ?? (keepIds ? keptIdsOf() : void 0);
774
+ const idsChunk = (from, length) => {
775
+ const found = keptIds?.at(from);
776
+ if (found !== void 0) return Effect.succeed(found);
777
+ return Effect.map(readExactly(bucket, key, ids + from * 20, length * 20), (bytes) => {
778
+ keptIds?.keep(from, bytes);
779
+ return bytes;
780
+ });
781
+ };
744
782
  const numbersOf = Effect.fnUntraced(function* (wanted, count) {
745
783
  const order = orderById(wanted, count);
746
784
  const out = new Uint32Array(count).fill(absent);
747
785
  let next = 0;
748
786
  for (let from = 0; from < commits && next < count; from += graphChunk) {
749
787
  const length = Math.min(graphChunk, commits - from);
750
- const chunk = yield* readExactly(bucket, key, ids + from * 20, length * 20);
788
+ const chunk = yield* idsChunk(from, length);
751
789
  let at = 0;
752
790
  while (next < count && at < length) {
753
791
  const each = order[next] ?? 0;
@@ -775,7 +813,7 @@ const openIndexGraph = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key,
775
813
  const local = number - first;
776
814
  const from = local - local % graphChunk;
777
815
  const length = Math.min(graphChunk, commits - from);
778
- const chunk = yield* readExactly(bucket, key, start + from * width, length * width);
816
+ const chunk = start === ids && width === 20 ? yield* idsChunk(from, length) : yield* readExactly(bucket, key, start + from * width, length * width);
779
817
  for (; next < order.length; next += 1) {
780
818
  const place = order[next] ?? 0;
781
819
  const at = (numbers[place] ?? 0) - first - from;
@@ -921,11 +959,12 @@ const layerCursor = (graph) => {
921
959
  };
922
960
  /**
923
961
  * Each commit of `graphs` in ID order, each ID once, to `each`: its merged number, the oldest
924
- * layer's copy of it, and every layer's. It answers how many it gave.
962
+ * layer's copy of it, and every layer's; but an ID `drops` names, which takes no number. It
963
+ * answers how many it gave.
925
964
  */
926
- const eachMerged = /* @__PURE__ */ Effect.fnUntraced(function* (graphs, each) {
965
+ const eachMerged = /* @__PURE__ */ Effect.fnUntraced(function* (graphs, each, drops) {
927
966
  const cursors = graphs.map(layerCursor);
928
- for (let number = 0;; number += 1) {
967
+ for (let number = 0;;) {
929
968
  const heads = [];
930
969
  for (const cursor of cursors) {
931
970
  const head = yield* cursor.head;
@@ -939,8 +978,10 @@ const eachMerged = /* @__PURE__ */ Effect.fnUntraced(function* (graphs, each) {
939
978
  if (least === void 0) return number;
940
979
  const taken = least;
941
980
  const holding = heads.filter(({ head }) => compareIds(head.ids, head.offset, taken.ids, taken.offset) === 0);
942
- const step = each(number, taken, holding.map(({ head }) => head));
981
+ const given = drops?.(taken.ids, taken.offset) !== true;
982
+ const step = given ? each(number, taken, holding.map(({ head }) => head)) : void 0;
943
983
  if (step !== void 0) yield* step;
984
+ if (given) number += 1;
944
985
  for (const { advance } of holding) advance();
945
986
  }
946
987
  });
@@ -958,13 +999,14 @@ const mergeHeldBytes = (layers) => layers * graphChunk * 44 + mostParents * 8 +
958
999
  /**
959
1000
  * `input.graphs`, layers of one index, merged into one index graph at `input.key`, numbered from 0
960
1001
  * as `writeIndexGraph` numbers a whole one: every commit once in ID order, an ID two layers hold
961
- * taken from the oldest, its parents renumbered, its octopus list carried and its generation kept.
962
- * The first pass numbers the commits and counts them, the next three write the IDs, the rows and
1002
+ * taken from the oldest, its parents renumbered, its octopus list carried and its generation kept;
1003
+ * but a commit `input.drops` names, left out, which keeps every kept commit's generation, since a
1004
+ * commit's ancestors are kept with it. The first pass numbers the commits and counts them, the next three write the IDs, the rows and
963
1005
  * the octopus table. It holds each layer commit's merged number, 4 bytes each, and
964
1006
  * `mergeHeldBytes`, charged to `input.allotment`, and never a layer whole.
965
1007
  */
966
1008
  const mergeIndexGraphs = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
967
- const { bucket, graphs, key, allotment } = input;
1009
+ const { bucket, graphs, key, allotment, drops } = input;
968
1010
  let total = 0;
969
1011
  for (const graph of graphs) {
970
1012
  if (graph.first !== total) return yield* Effect.die(/* @__PURE__ */ new Error(`a layer starts at ${graph.first}, not ${total}`));
@@ -972,7 +1014,7 @@ const mergeIndexGraphs = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
972
1014
  }
973
1015
  const bytes = total * 4 + mergeHeldBytes(graphs.length);
974
1016
  yield* allotment.grow(bytes);
975
- const merged = new Uint32Array(total);
1017
+ const merged = new Uint32Array(total).fill(none);
976
1018
  const counts = /* @__PURE__ */ new Uint32Array(256);
977
1019
  let octopus = 0;
978
1020
  const commits = yield* eachMerged(graphs, (number, taken, holders) => {
@@ -983,28 +1025,36 @@ const mergeIndexGraphs = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
983
1025
  return list === void 0 ? void 0 : Effect.map(list, (parents) => {
984
1026
  octopus += parents.length;
985
1027
  });
986
- });
1028
+ }, drops);
987
1029
  if (commits >= mostCommits) return yield* Effect.fail(gitError("RESOURCE_EXHAUSTED", `The index layers' ${commits} commits are past the ${mostCommits} a graph numbers`));
988
1030
  const started = yield* startGraph(bucket, key, commits, octopus, counts);
989
- if ((yield* eachMerged(graphs, (_, taken) => started.out.push(taken.ids.subarray(taken.offset, taken.offset + 20)))) !== commits) return yield* Effect.fail(lost("The index layers changed while they were merged"));
1031
+ if ((yield* eachMerged(graphs, (_, taken) => started.out.push(taken.ids.subarray(taken.offset, taken.offset + 20)), drops)) !== commits) return yield* Effect.fail(lost("The index layers changed while they were merged"));
990
1032
  const renumbered = (parent) => parent === 2147483647 ? none : merged[parent] ?? 2147483647;
1033
+ const unclosed = (taken, parents) => Array.from(parents).some((parent) => parent !== 2147483647 && renumbered(parent) === 2147483647) ? Effect.fail(keepUnclosed(`The commit ${hexOf(taken.ids.subarray(taken.offset, taken.offset + 20))} keeps a parent the merge dropped`)) : Effect.void;
991
1034
  const row = /* @__PURE__ */ new Uint32Array(3);
992
1035
  let tableAt = 0;
993
1036
  yield* eachMerged(graphs, (_, taken) => Effect.gen(function* () {
994
1037
  const list = octopusOf(taken);
995
- row[0] = renumbered(taken.rows[taken.row] ?? 2147483647);
1038
+ const first = taken.rows[taken.row] ?? 2147483647;
1039
+ row[0] = renumbered(first);
996
1040
  row[2] = taken.rows[taken.row + 2] ?? 0;
997
- if (list === void 0) row[1] = renumbered(taken.rows[taken.row + 1] ?? 2147483647);
998
- else {
1041
+ if (list === void 0) {
1042
+ const second = taken.rows[taken.row + 1] ?? 2147483647;
1043
+ row[1] = renumbered(second);
1044
+ yield* unclosed(taken, [first, second]);
1045
+ } else {
1046
+ const parents = yield* list;
999
1047
  row[1] = octopusTarget(tableAt);
1000
- tableAt += (yield* list).length;
1048
+ tableAt += parents.length;
1049
+ yield* unclosed(taken, [first, ...parents]);
1001
1050
  }
1002
1051
  yield* started.out.words(row);
1003
- }));
1052
+ }), drops);
1004
1053
  if (octopus > 0) yield* eachMerged(graphs, (_, taken) => {
1005
1054
  const list = octopusOf(taken);
1006
1055
  return list === void 0 ? void 0 : Effect.flatMap(list, (parents) => started.out.words(parents, (parent, at) => at === parents.length - 1 ? (renumbered(parent) | lastFlag) >>> 0 : renumbered(parent)));
1007
- });
1056
+ }, drops);
1057
+ if (input.beforeFinish !== void 0) yield* input.beforeFinish(renumbered);
1008
1058
  yield* started.finish;
1009
1059
  allotment.shrink(bytes);
1010
1060
  return { commits };
@@ -1106,4 +1156,4 @@ var ByGeneration = class {
1106
1156
  return top;
1107
1157
  }
1108
1158
  };
1109
- export { ByGeneration, absent, gathered, graphChunk, graphRefs, graphRows, graphSourceBytes, graphTooLarge, graphTooWide, graphsTooMany, indexGraphBytes, lastFlag, mergeHeldBytes, mergeIndexGraphs, none, octopusFlag, openGraphLayers, openIndexGraph, openPackGraph, writeIndexGraph };
1159
+ export { ByGeneration, absent, gathered, graphChunk, graphRefs, graphRows, graphSourceBytes, graphTooLarge, graphTooWide, graphsTooMany, indexGraphBytes, keptIdsBytes, keptIdsOf, lastFlag, mergeHeldBytes, mergeIndexGraphs, none, octopusFlag, openGraphLayers, openIndexGraph, openPackGraph, writeIndexGraph };
@@ -1,5 +1,6 @@
1
+ import { hexOf } from "../protocol/bytes/hex.mjs";
1
2
  import { bitmapWords } from "./ewah.mjs";
2
- import { builtIndexOf, coversAll, decodeIndexValue } from "./index-build.mjs";
3
+ import { builtIndexOf, builtOver, coversAll, decodeIndexValue } from "./index-build.mjs";
3
4
  import { hasBit, idsOf, openLayerBitmaps, openLayout, orIntoAtOnce, orIntoBytes, orIntoFiles, orWords, reachOf, whileFollowed } from "./index-layers.mjs";
4
5
  import { readReserveBytes } from "./budget.mjs";
5
6
  import { missing } from "./link-join.mjs";
@@ -148,14 +149,18 @@ const outsideOf = /* @__PURE__ */ Effect.fnUntraced(function* (input, tips, most
148
149
  closed: true
149
150
  };
150
151
  });
151
- /** Whether `row` names a built index that covers `listed`, so a reach of it answers. */
152
+ /**
153
+ * Whether `row` names a built index that covers `listed`, so a reach of it may answer: `tipsReach`
154
+ * still walks past one built over other roots.
155
+ */
152
156
  const indexCovers = (input, listed) => {
153
157
  const built = builtIndexOf(decodeIndexValue(input.row));
154
158
  return built !== void 0 && coversAll(built.layers, listed);
155
159
  };
156
160
  /**
157
161
  * What `input.tips` reach, by the index `input.row` names over `listed`, or `undefined` when it
158
- * doesn't cover `listed`, as after a repack took a covered pack out, for the caller's walk. A tip
162
+ * doesn't cover `listed`, as after a repack took a covered pack out, or was built over other
163
+ * roots than `input.roots`, for the caller's walk. A tip
159
164
  * whose reach won't close within `most` sets `pastLimit`. Where `unclosed`, so does one whose walk
160
165
  * meets an object past the bytes it may follow at once, which a fetch's want check refuses as
161
166
  * `levelTooLarge`: a visible set still shows its tips, and what their bitmaps reach. Its walks
@@ -168,7 +173,7 @@ const tipsReach = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, in
168
173
  tooLarge = true;
169
174
  })) : walk;
170
175
  const built = builtIndexOf(decodeIndexValue(input.row));
171
- if (built === void 0 || !coversAll(built.layers, listed)) return void 0;
176
+ if (built === void 0 || !builtOver(built, input.roots) || !coversAll(built.layers, listed)) return void 0;
172
177
  const last = built.layers[built.layers.length - 1];
173
178
  const words = bitmapWords(last === void 0 ? 0 : last.first + last.positions);
174
179
  const files = orIntoFiles(built.layers);
@@ -284,6 +289,29 @@ const reachAnswers = /* @__PURE__ */ Effect.fnUntraced(function* (reach, wants,
284
289
  return answers;
285
290
  });
286
291
  /**
292
+ * Which of `input.roots` the tips reach, by the index `input.row` names over `listed`: each root
293
+ * whose position a layer keeps that the tips' union holds, and each the walk outside the index
294
+ * met. A root's ID is read only where the union holds it, so one the tips don't reach, as one only
295
+ * a hidden ref reaches, costs no call, as a fetch's `rootsSent` reads them (#2462). `undefined`
296
+ * where the index can't give the walk's answer: none covers `listed`, it's over other roots, or
297
+ * a tip's reach won't close.
298
+ */
299
+ const reachedRoots = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, input) {
300
+ const built = builtIndexOf(decodeIndexValue(input.row));
301
+ if (built === void 0) return void 0;
302
+ const reach = yield* tipsReach(parts, listed, input);
303
+ if (reach === void 0 || reach.pastLimit !== void 0) return void 0;
304
+ const roots = input.roots ?? /* @__PURE__ */ new Set();
305
+ const reached = /* @__PURE__ */ new Set();
306
+ for (const layer of built.layers) for (const position of layer.roots ?? []) {
307
+ if (!hasBit(reach.union, position)) continue;
308
+ const root = hexOf(yield* reach.layout.idAt(position));
309
+ if (roots.has(root)) reached.add(root);
310
+ }
311
+ for (const root of roots) if (reach.outside?.has(root) === true) reached.add(root);
312
+ return reached;
313
+ }, Effect.scoped);
314
+ /**
287
315
  * Which of `input.wants` the tips reach, by the index `input.row` names over `listed`, as
288
316
  * `reachAnswers` says. A tip whose reach won't close within `most` leaves the wants it doesn't
289
317
  * show reached unanswered and sets `pastLimit`, and its caller refuses them alike. An index that
@@ -321,4 +349,4 @@ const wantsBy = /* @__PURE__ */ Effect.fnUntraced(function* (reach, wants) {
321
349
  updatesRefused
322
350
  };
323
351
  });
324
- export { ReachCache, indexCovers, indexReach, reachAnswers, reachCacheBytes, tipsReach, wantsBy };
352
+ export { ReachCache, indexCovers, indexReach, reachAnswers, reachCacheBytes, reachedRoots, tipsReach, wantsBy };