@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
@@ -2,22 +2,19 @@ import { gitError } from "../contracts/result.mjs";
2
2
  import { BufferMeter } from "../protocol/bytes/buffers.mjs";
3
3
  import { crc32Update } from "../protocol/bytes/crc32.mjs";
4
4
  import { deflatedMost } from "../protocol/bytes/deflate.mjs";
5
+ import { hexOf } from "../protocol/bytes/hex.mjs";
5
6
  import { Sha1 } from "../protocol/bytes/sha1.mjs";
6
- import "../protocol/objects/object.mjs";
7
+ import { emptyTree } from "../protocol/objects/object.mjs";
7
8
  import { entryHeader, packStream, writePack } from "../protocol/packs/writer.mjs";
8
9
  import { untilAborted } from "../store/crossing.mjs";
9
10
  import { fetchLess } from "../store/errors.mjs";
10
11
  import { catchSpent, ownSpentOf } from "../contracts/calls-spent.mjs";
11
- import { hexOf } from "../protocol/bytes/hex.mjs";
12
- import "./pack-reads.mjs";
13
- import { isSet } from "./bits.mjs";
14
- import { typeOfCode } from "./index-files.mjs";
15
- import { ListCursor, sizeOf } from "./send-list.mjs";
16
- import { indexSendSet } from "./index-fetch.mjs";
12
+ import { entryHolds, planColumns } from "./plan-columns.mjs";
13
+ import { oidSet } from "./oid-table.mjs";
17
14
  import { planShallow, withRootsSent } from "./shallow.mjs";
18
- import { countedReads, fetchReadsOf, historyOf, lost, notHeld, unreadable, walk } from "./walk.mjs";
19
- import * as Clock$1 from "effect/Clock";
15
+ import { countedReads, fetchReadsOf, historyOf, lost, noIds, notHeld, unreadable, walk } from "./walk.mjs";
20
16
  import * as Effect from "effect/Effect";
17
+ import * as Clock from "effect/Clock";
21
18
  // src/storage/fetch.ts
22
19
  /**
23
20
  * `Git.layer`'s `fetchLimits` when it names none: a clone of a large repo fits within them.
@@ -85,13 +82,13 @@ const checkedCopy = (entry, read) => {
85
82
  let crc = 0;
86
83
  return {
87
84
  bytes: entry.bytes,
88
- read: Effect.fnUntraced(function* (at) {
85
+ read: (at) => {
89
86
  if (at === 0) crc = 0;
90
- const bytes = yield* read(at);
91
- crc = crc32Update(crc, bytes);
92
- if (at + bytes.byteLength >= entry.bytes && crc !== entry.crc32) return yield* Effect.fail(corrupt(entry));
93
- return bytes;
94
- })
87
+ return Effect.flatMap(read(at), (bytes) => {
88
+ crc = crc32Update(crc, bytes);
89
+ return at + bytes.byteLength >= entry.bytes && crc !== entry.crc32 ? Effect.fail(corrupt(entry)) : Effect.succeed(bytes);
90
+ });
91
+ }
95
92
  };
96
93
  };
97
94
  /**
@@ -101,18 +98,35 @@ const checkedCopy = (entry, read) => {
101
98
  * but for `rows`, read before the first byte, each taken from them as its window comes.
102
99
  */
103
100
  const plannedSource = (reads, plan, rows) => {
104
- const { objects, copies } = plan;
105
- const places = new Map(objects.map((object, at) => [object.oid, at]));
101
+ const { columns } = plan;
102
+ const { count } = columns;
103
+ const { size } = columns.columns;
106
104
  let window = /* @__PURE__ */ new Map();
105
+ let after = 0;
106
+ const placeOf = (ordinal) => {
107
+ if (ordinal === void 0) return count;
108
+ for (let at = after; at < count; at += 1) if (columns.sentAt(at) === ordinal) return at;
109
+ for (let at = 0; at < Math.min(after, count); at += 1) if (columns.sentAt(at) === ordinal) return at;
110
+ return count;
111
+ };
107
112
  const load = Effect.fnUntraced(function* (oid) {
108
113
  const oids = [];
109
114
  let bytes = 0;
110
- for (const object of objects.slice(places.get(oid) ?? objects.length)) {
111
- if (copies.has(object.oid)) continue;
112
- if (oids.length > 0 && bytes + object.size > 1048576) break;
113
- oids.push(object.oid);
114
- bytes += object.size;
115
+ let at = placeOf(columns.find(oid));
116
+ for (; at < count; at += 1) {
117
+ const ordinal = columns.sentAt(at);
118
+ if (columns.copiedAt(ordinal)) continue;
119
+ const each = size[ordinal] ?? 0;
120
+ const kind = columns.kindAt(ordinal);
121
+ if (kind !== void 0 && reads.ranged?.handles({
122
+ kind,
123
+ size: each
124
+ }) === true) continue;
125
+ if (oids.length > 0 && bytes + each > 1048576) break;
126
+ oids.push(columns.oidAt(ordinal));
127
+ bytes += each;
115
128
  }
129
+ after = at;
116
130
  if (rows === void 0) {
117
131
  window = yield* reads.held(oids);
118
132
  return;
@@ -129,9 +143,14 @@ const plannedSource = (reads, plan, rows) => {
129
143
  window = loaded;
130
144
  });
131
145
  return {
132
- count: objects.length,
133
- page: (from, most) => Effect.succeed(objects.slice(from, from + most)),
146
+ count,
147
+ page: (from, most) => Effect.sync(() => Array.from({ length: Math.max(0, Math.min(most, count - from)) }, (_, at) => columns.sent(from + at))),
134
148
  read: Effect.fnUntraced(function* (object, at) {
149
+ if (reads.ranged?.handles(object) === true) {
150
+ const piece = yield* reads.ranged.read(object.oid, at);
151
+ if (piece === void 0) return yield* Effect.fail(gone(object.oid));
152
+ return piece;
153
+ }
135
154
  if (!window.has(object.oid)) yield* load(object.oid);
136
155
  const whole = window.get(object.oid);
137
156
  if (whole === void 0) return yield* Effect.fail(gone(object.oid));
@@ -145,240 +164,13 @@ const plannedSource = (reads, plan, rows) => {
145
164
  }),
146
165
  end: Effect.void,
147
166
  copy: (object) => {
148
- const entry = copies.get(object.oid);
167
+ const ordinal = columns.find(object.oid);
168
+ const entry = ordinal === void 0 || !columns.copiedAt(ordinal) ? void 0 : columns.entryAt(ordinal);
149
169
  const { stored } = reads;
150
170
  return entry === void 0 || stored === void 0 ? void 0 : checkedCopy(entry, (at) => stored.read(entry, at));
151
171
  }
152
172
  };
153
173
  };
154
- /** A pack entry's type, in its header's first byte: 1 to 4 for the kinds, 7 for a `REF_DELTA`. */
155
- const entryTypes = {
156
- commit: 1,
157
- tree: 2,
158
- blob: 3,
159
- tag: 4
160
- };
161
- const refDeltaType = 7;
162
- /**
163
- * `copy`, refused with `DATA_LOSS` before its first range is handed over when its header's type
164
- * isn't what the index says it is: `kind` for a whole entry, a `REF_DELTA` for a delta. A copied
165
- * delta's header must name `base` too, the ID at the base position its `.bases` row gives,
166
- * checked before the range that completes the header's ID is handed over.
167
- */
168
- const typeChecked = (copy, entry, type, base) => {
169
- const wrong = gitError("DATA_LOSS", `Object ${entry.oid} in pack ${entry.pack.id} isn't the entry the index's .types and .bases say`);
170
- let head = /* @__PURE__ */ new Uint8Array(0);
171
- let checked = true;
172
- /** The base ID a `REF_DELTA`'s header names, past its type and size, once `bytes` hold it. */
173
- const named = (bytes) => {
174
- let at = 1;
175
- while (at <= bytes.byteLength && ((bytes[at - 1] ?? 0) & 128) !== 0) at += 1;
176
- return bytes.byteLength < at + 20 ? void 0 : hexOf(bytes.subarray(at, at + 20));
177
- };
178
- return {
179
- bytes: copy.bytes,
180
- read: (at) => Effect.flatMap(copy.read(at), (bytes) => {
181
- if (at === 0 && ((bytes[0] ?? 0) >> 4 & 7) !== type) return Effect.fail(wrong);
182
- if (at === 0) {
183
- head = /* @__PURE__ */ new Uint8Array(0);
184
- checked = base === void 0;
185
- }
186
- if (checked) return Effect.succeed(bytes);
187
- head = Uint8Array.from([...head, ...bytes.subarray(0, 64 - head.byteLength)]);
188
- const found = named(head);
189
- if (found === void 0 && at + bytes.byteLength < copy.bytes) return Effect.succeed(bytes);
190
- checked = true;
191
- return found === base ? Effect.succeed(bytes) : Effect.fail(wrong);
192
- })
193
- };
194
- };
195
- /**
196
- * The whole objects of `list` the writer reads at once from `cursor` on, as `plannedSource` reads
197
- * its windows: those it doesn't copy, up to `windowBytes` of them or the one.
198
- */
199
- const windowFrom = (cursor) => {
200
- const { list } = cursor;
201
- const window = [];
202
- let bytes = 0;
203
- for (const at = cursor.copy(); !at.done; at.next()) {
204
- if (isSet(list.copied, at.ordinal)) continue;
205
- const size = sizeOf(list, at.ordinal);
206
- if (window.length > 0 && bytes + size > 1048576) break;
207
- window.push({
208
- ordinal: at.ordinal,
209
- position: at.position,
210
- pack: at.inPack
211
- });
212
- bytes += size;
213
- }
214
- return window;
215
- };
216
- /**
217
- * The stored entries the writer reads through the reader's blocks for `list`, in its order, as
218
- * `writerCalls` forecasts a plan's: for each window of objects written whole, each one's entry and
219
- * the bases down its chain, as the reader resolves it. Its copies are read through `listRuns`.
220
- * None is held past `PackBlocks.gets`' count.
221
- */
222
- function* listReads(list) {
223
- let windowEnd = 0;
224
- for (const cursor = new ListCursor(list); !cursor.done; cursor.next()) {
225
- if (isSet(list.copied, cursor.ordinal) || cursor.ordinal < windowEnd) continue;
226
- const window = windowFrom(cursor);
227
- windowEnd = (window.at(-1)?.ordinal ?? cursor.ordinal) + 1;
228
- for (const each of window) for (let at = each.position, steps = 0; at !== void 0 && steps <= list.chains.size; at = list.chains.get(at), steps += 1) yield each.pack.at(at);
229
- }
230
- }
231
- /**
232
- * `list`'s copies as runs, in its order: each copy joins the run before it when it's in the same
233
- * pack and starts at most `blockBytes` past that run's end, the gap read and let go. So each run
234
- * starts in a block no run before it reads, and runs are never more gets than the blocks the
235
- * copies' bytes span. A full clone of one pack is one run (#647).
236
- */
237
- function* listRuns(list) {
238
- let run;
239
- let pack = -1;
240
- for (const cursor = new ListCursor(list); !cursor.done; cursor.next()) {
241
- if (!isSet(list.copied, cursor.ordinal)) continue;
242
- const entry = cursor.inPack.at(cursor.position);
243
- const end = entry.offset + entry.bytes;
244
- if (run !== void 0 && cursor.pack === pack && entry.offset <= run.to + 1048576) {
245
- run.to = end;
246
- run.last = cursor.ordinal;
247
- continue;
248
- }
249
- if (run !== void 0) yield run;
250
- pack = cursor.pack;
251
- run = {
252
- pack: entry.pack,
253
- from: entry.offset,
254
- to: end,
255
- first: cursor.ordinal,
256
- last: cursor.ordinal
257
- };
258
- }
259
- if (run !== void 0) yield run;
260
- }
261
- /**
262
- * The bucket gets the writer makes for `list`'s objects, with no I/O: one a run of its copies, and
263
- * its windows' reads as `PackBlocks.gets` forecasts them, as `writerCalls` forecasts a plan's
264
- * (#522).
265
- */
266
- const listCalls = (stored, list) => {
267
- let runs = 0;
268
- for (const _run of listRuns(list)) runs += 1;
269
- return {
270
- bucket: runs + stored.gets(listReads(list)),
271
- store: 0
272
- };
273
- };
274
- /**
275
- * `list`'s objects as the writer takes them, a page at a time: each one's ID, kind and size from
276
- * the index and the list, held for its page alone. A copy is its stored entry, read through its
277
- * run's one ranged get, its CRC-32 checked as it's read and its type against the index's; the rest
278
- * are read whole a window at a time, as `plannedSource` reads them. Every read is a listed pack's,
279
- * so the store is read no more. A second write, from the first object again, reads its runs again.
280
- */
281
- const listSource = (reads, list) => {
282
- let cursor = new ListCursor(list);
283
- let paged = /* @__PURE__ */ new Map();
284
- let window = /* @__PURE__ */ new Map();
285
- let runs = listRuns(list);
286
- let run;
287
- let reading;
288
- const closeRun = Effect.suspend(() => {
289
- const open = reading;
290
- reading = void 0;
291
- return open?.close ?? Effect.void;
292
- });
293
- const load = Effect.fnUntraced(function* (from) {
294
- const at = windowFrom(from).map(({ pack, position }) => {
295
- const { oid, offset } = pack.at(position);
296
- return {
297
- oid,
298
- lookup: pack.lookup,
299
- offset
300
- };
301
- });
302
- if (reads.heldAt !== void 0) window = yield* reads.heldAt(at);
303
- });
304
- /**
305
- * The copy at `ordinal`'s bytes from `at`, through its run: a run is opened as the writer reaches
306
- * it, and another from the entry on only for a read behind the one open.
307
- */
308
- const copied = Effect.fnUntraced(function* (stored, ordinal, entry, at) {
309
- while (run === void 0 || run.last < ordinal) {
310
- yield* closeRun;
311
- const next = runs.next();
312
- if (next.done === true) return yield* Effect.die(/* @__PURE__ */ new Error(`no run of the list holds its copy ${ordinal}`));
313
- run = next.value;
314
- }
315
- if (ordinal < run.first) return yield* Effect.die(/* @__PURE__ */ new Error(`the list's copy ${ordinal} is read before its run`));
316
- const offset = entry.offset + at;
317
- const open = reading !== void 0 && reading.reads(offset);
318
- if (!open && stored.kept(entry.pack, offset)) return yield* stored.read(entry, at);
319
- if (reading === void 0 || !open) {
320
- yield* closeRun;
321
- reading = stored.run(run.pack, offset, run.to);
322
- }
323
- return yield* reading.read(offset, entry.offset + entry.bytes);
324
- });
325
- return {
326
- count: list.count,
327
- page: Effect.fnUntraced(function* (from, most) {
328
- if (from === 0 && cursor.ordinal > 0) {
329
- yield* closeRun;
330
- cursor = new ListCursor(list);
331
- window = /* @__PURE__ */ new Map();
332
- runs = listRuns(list);
333
- run = void 0;
334
- }
335
- if (from !== cursor.ordinal) return yield* Effect.die(/* @__PURE__ */ new Error(`the list pages in order: ${from} isn't its next`));
336
- const page = [];
337
- paged = /* @__PURE__ */ new Map();
338
- for (; page.length < most && !cursor.done; cursor.next()) {
339
- const { oid } = cursor.inPack.at(cursor.position);
340
- const kind = typeOfCode[list.kinds[cursor.ordinal] ?? 0] ?? "blob";
341
- const size = sizeOf(list, cursor.ordinal);
342
- page.push(isSet(list.copied, cursor.ordinal) ? {
343
- oid,
344
- kind,
345
- storedBytes: size
346
- } : {
347
- oid,
348
- kind,
349
- size
350
- });
351
- paged.set(oid, cursor.copy());
352
- }
353
- return page;
354
- }),
355
- read: Effect.fnUntraced(function* (object, at) {
356
- const placed = paged.get(object.oid);
357
- if (!window.has(object.oid) && placed !== void 0) yield* load(placed);
358
- const whole = window.get(object.oid);
359
- if (whole === void 0) return yield* Effect.fail(gone(object.oid));
360
- const bytes = whole.bytes.slice(at, at + rangeBytes);
361
- if (at + bytes.byteLength >= whole.bytes.byteLength) {
362
- const left = new Map(window);
363
- left.delete(object.oid);
364
- window = left;
365
- }
366
- return bytes;
367
- }),
368
- end: closeRun,
369
- close: closeRun,
370
- copy: (object) => {
371
- const placed = paged.get(object.oid);
372
- const { stored } = reads;
373
- if (placed === void 0 || stored === void 0 || !isSet(list.copied, placed.ordinal)) return void 0;
374
- const entry = placed.inPack.at(placed.position);
375
- const copy = checkedCopy(entry, (at) => copied(stored, placed.ordinal, entry, at));
376
- if (!isSet(list.deltas, placed.ordinal)) return typeChecked(copy, entry, entryTypes[object.kind]);
377
- const base = placed.inPack.at(list.bases[placed.ordinal] ?? 0).oid;
378
- return typeChecked(copy, entry, refDeltaType, base);
379
- }
380
- };
381
- };
382
174
  /** `first`'s objects, then `second`'s, as one source: a page across the seam takes from both. */
383
175
  const joinedSources = (first, second) => {
384
176
  let fromFirst = /* @__PURE__ */ new Set();
@@ -406,7 +198,7 @@ const memorySource = (objects) => {
406
198
  kind: object.type,
407
199
  size: object.bytes.byteLength
408
200
  }))),
409
- read: (object, at) => Effect.sync(() => byOid.get(object.oid)?.bytes.slice(at, at + rangeBytes) ?? /* @__PURE__ */ new Uint8Array(0)),
201
+ read: (object, at) => Effect.sync(() => byOid.get(object.oid)?.bytes.slice(at, at + 1048576) ?? /* @__PURE__ */ new Uint8Array(0)),
410
202
  end: Effect.void
411
203
  };
412
204
  };
@@ -444,15 +236,15 @@ const fits = (filter, bytes) => filter?.kind !== "blob:limit" || bytes < filter.
444
236
  /** The IDs a walk adds before it pays for them: a chunk's slots are all it holds unpaid. */
445
237
  const chargeChunk = 4096;
446
238
  /**
447
- * Adds each of `oids` that `add` takes, charging `bytes` for each it took, a `chargeChunk` at a
448
- * time: an ID a tree names twice is paid once, and no more than a chunk is held unpaid. Gives how
449
- * many it took.
239
+ * Adds each of `ids`, 20 bytes each end to end, that `add` takes, charging `bytes` for each it
240
+ * took, a `chargeChunk` at a time: an ID a tree names twice is paid once, and no more than a chunk
241
+ * is held unpaid. Gives how many it took.
450
242
  */
451
- const addCharged = /* @__PURE__ */ Effect.fnUntraced(function* (read, oids, bytes, add) {
243
+ const addCharged = /* @__PURE__ */ Effect.fnUntraced(function* (read, ids, bytes, add) {
452
244
  let took = 0;
453
245
  let unpaid = 0;
454
- for (const oid of oids) {
455
- if (!add(oid)) continue;
246
+ for (let at = 0; at < ids.length; at += 20) {
247
+ if (!add(ids, at)) continue;
456
248
  took += 1;
457
249
  unpaid += 1;
458
250
  if (unpaid < chargeChunk) continue;
@@ -465,36 +257,29 @@ const addCharged = /* @__PURE__ */ Effect.fnUntraced(function* (read, oids, byte
465
257
  /**
466
258
  * The trees and blobs below `roots` that the client holds, its trees read and its blobs only
467
259
  * named: what a sent commit's tree leaves out. Each blob a tree names is charged
468
- * `fetchNamedBytes`, its string held by the tree's decode charge until the tree goes back, and each
469
- * tree `fetchObjectBytes`, once, as it's added, so a wide tree is refused before its names are held.
260
+ * `fetchNamedBytes`, and each tree `fetchObjectBytes`, once, as it's added, so a wide tree is
261
+ * refused before its names are held. Each is asked and added as bytes, and only a level's trees
262
+ * are made text, for their read.
470
263
  */
471
264
  const heldBelow = /* @__PURE__ */ Effect.fnUntraced(function* (read, roots) {
472
- const kept = /* @__PURE__ */ new Set();
473
- let frontier = [...new Set(roots)];
474
- const named = (blob) => {
475
- if (kept.has(blob)) return false;
476
- kept.add(blob);
477
- return true;
478
- };
265
+ const kept = oidSet();
266
+ let frontier = [...oidSet(roots).values()];
267
+ const named = (ids, at) => kept.addBytes(ids, at);
479
268
  const nameBelow = Effect.fnUntraced(function* (found, oid, below) {
480
269
  const entries = found.get(oid)?.entries;
481
270
  found.delete(oid);
482
271
  if (entries === void 0) return;
483
- const took = yield* addCharged(read, entries.blobs, 164, named);
484
- yield* addCharged(read, entries.trees, 530, below);
485
- read.letGo({ entries }, took);
272
+ yield* addCharged(read, entries.blobs, 90, named);
273
+ yield* addCharged(read, entries.trees, 370, below);
274
+ read.letGo({ entries });
486
275
  });
487
276
  for (let level = 0; frontier.length > 0; level += 1) {
488
277
  for (const oid of frontier) kept.add(oid);
489
278
  const found = yield* read(frontier, level > 0);
490
- const next = /* @__PURE__ */ new Set();
491
- const below = (tree) => {
492
- if (kept.has(tree) || next.has(tree)) return false;
493
- next.add(tree);
494
- return true;
495
- };
279
+ const next = oidSet();
280
+ const below = (ids, at) => !kept.hasBytes(ids, at) && next.addBytes(ids, at);
496
281
  for (const oid of frontier) yield* nameBelow(found, oid, below);
497
- frontier = [...next];
282
+ frontier = [...next.values()];
498
283
  }
499
284
  return kept;
500
285
  });
@@ -507,65 +292,57 @@ const tooManyObjects = (objects) => gitError("RESOURCE_EXHAUSTED", `This fetch n
507
292
  * trees it wants, a level at a time so each is placed at its least depth, as
508
293
  * `git rev-list --filter` places it: a commit's tree at 0, and a wanted tree's entries at 0 too.
509
294
  * What `filter` leaves out by kind or level is never read or sized. Each is charged
510
- * `fetchObjectBytes` once, as it's queued for its level, less `fetchIdBytes` while the tree that
511
- * names it still holds its string, which moves into its charge as the tree goes back. Trees are
512
- * read `fetchBatch` at a time and let go once their entries are queued; blobs are only sized, a
513
- * level's at once in the order storage keeps them, and `blob:limit` drops by that size. `skip` is
514
- * what the client holds or the pack sends already. It stops once `held` and what it keeps pass
515
- * `objects`.
295
+ * `fetchObjectBytes` once, as it's queued for its level. Trees are read `fetchBatch` at a time and
296
+ * let go once their entries are queued; blobs are only sized, a level's at once in the order
297
+ * storage keeps them, and `blob:limit` drops by that size. Entries are asked of `skip`, what the
298
+ * client holds or the pack sends already, and of what's queued, as bytes, and only what's queued
299
+ * is made text, for its read or its size. It stops once `held` and what it keeps pass `objects`.
516
300
  */
517
301
  const contentBelow = /* @__PURE__ */ Effect.fnUntraced(function* (read, roots, wanted, skip, filter, limits) {
518
302
  const sent = [];
519
- const seen = new Set(skip);
303
+ const seen = oidSet();
520
304
  const keep = (object) => {
521
305
  sent.push(object);
522
306
  return limits.held + sent.length > limits.objects ? Effect.fail(tooManyObjects(limits.objects)) : Effect.void;
523
307
  };
524
- const queue = Effect.fnUntraced(function* (entries, level, queued, next, bytes) {
525
- let took = 0;
308
+ const queue = Effect.fnUntraced(function* (entries, level, next) {
526
309
  for (const kind of ["tree", "blob"]) {
527
- const asks = (oid) => {
528
- if (seen.has(oid) || queued.has(oid) || !passes(filter, kind, level)) return false;
529
- queued.add(oid);
310
+ const asks = (ids, at) => {
311
+ if (!passes(filter, kind, level) || skip.hasBytes(ids, at)) return false;
312
+ if (!seen.addBytes(ids, at)) return false;
530
313
  next.push({
531
- oid,
314
+ oid: hexOf(ids.subarray(at, at + 20)),
532
315
  kind
533
316
  });
534
317
  return true;
535
318
  };
536
- took += yield* addCharged(read, entries[`${kind}s`], bytes, asks);
319
+ yield* addCharged(read, entries[`${kind}s`], 370, asks);
537
320
  }
538
- return took;
539
321
  });
540
- const sendTree = Effect.fnUntraced(function* (found, oid, level, queued, next) {
322
+ const sendTree = Effect.fnUntraced(function* (found, oid, level, next) {
541
323
  const object = found.get(oid);
542
324
  found.delete(oid);
543
325
  if (object === void 0) return yield* Effect.fail(lost(oid));
544
326
  if (object.entries === void 0) return yield* Effect.fail(unreadable(object, "a tree names it as a tree"));
545
327
  yield* keep(packObjectOf(object));
546
- const took = yield* queue(object.entries, level + 1, queued, next, 474);
547
- read.letGo(object, took);
328
+ yield* queue(object.entries, level + 1, next);
329
+ read.letGo(object);
548
330
  });
549
331
  let frontier = [];
550
- const started = /* @__PURE__ */ new Set();
551
332
  yield* queue({
552
333
  trees: roots,
553
- blobs: []
554
- }, 0, started, frontier, 530);
555
- for (const entries of wanted) yield* queue(entries, 0, started, frontier, 530);
334
+ blobs: noIds
335
+ }, 0, frontier);
336
+ for (const entries of wanted) yield* queue(entries, 0, frontier);
556
337
  for (let level = 0; frontier.length > 0; level += 1) {
557
338
  const trees = [];
558
339
  const blobs = [];
559
- for (const below of frontier) {
560
- seen.add(below.oid);
561
- (below.kind === "tree" ? trees : blobs).push(below.oid);
562
- }
340
+ for (const below of frontier) (below.kind === "tree" ? trees : blobs).push(below.oid);
563
341
  const next = [];
564
- const queued = /* @__PURE__ */ new Set();
565
342
  for (let at = 0; at < trees.length; at += 64) {
566
343
  const batch = trees.slice(at, at + 64);
567
344
  const found = yield* read(batch, true);
568
- for (const oid of batch) yield* sendTree(found, oid, level, queued, next);
345
+ for (const oid of batch) yield* sendTree(found, oid, level, next);
569
346
  }
570
347
  const sizes = yield* read.sizes(blobs, true);
571
348
  const missing = blobs.find((oid) => !sizes.has(oid));
@@ -588,19 +365,20 @@ const contentBelow = /* @__PURE__ */ Effect.fnUntraced(function* (read, roots, w
588
365
  */
589
366
  const followedTags = /* @__PURE__ */ Effect.fnUntraced(function* (read, tags, skip, sentOf) {
590
367
  const chains = /* @__PURE__ */ new Map();
591
- const passed = new Set(skip);
592
- const sent = /* @__PURE__ */ new Set();
593
- for (let level = [...new Set(tags)].filter((oid) => !passed.has(oid)); level.length > 0;) {
368
+ const reached = oidSet();
369
+ const passed = (oid) => skip.has(oid) || reached.has(oid);
370
+ const sent = oidSet();
371
+ for (let level = [...oidSet(tags).values()].filter((oid) => !passed(oid)); level.length > 0;) {
594
372
  for (const oid of yield* sentOf(level)) sent.add(oid);
595
373
  const unread = level.filter((oid) => !sent.has(oid));
596
374
  const found = unread.length === 0 ? /* @__PURE__ */ new Map() : yield* read(unread);
597
375
  const next = /* @__PURE__ */ new Set();
598
- for (const oid of level) passed.add(oid);
376
+ for (const oid of level) reached.add(oid);
599
377
  for (const object of found.values()) {
600
378
  chains.set(object.oid, object);
601
379
  if (object.type === "tag") for (const target of historyOf(object)) next.add(target);
602
380
  }
603
- level = [...next].filter((oid) => !passed.has(oid));
381
+ level = [...next].filter((oid) => !passed(oid));
604
382
  }
605
383
  const added = /* @__PURE__ */ new Map();
606
384
  for (const ref of new Set(tags)) {
@@ -636,19 +414,34 @@ const planFetch = /* @__PURE__ */ Effect.fnUntraced(function* (read, request, ta
636
414
  const { clientShallows, cut } = planned;
637
415
  const ends = /* @__PURE__ */ new Set([...clientShallows, ...cut]);
638
416
  const haves = yield* walk(read, request.haves, (object) => ends.has(object.oid) ? [] : historyOf(object), /* @__PURE__ */ new Set(), () => void 0);
639
- const had = /* @__PURE__ */ new Set([...haves.keys(), ...planned.unshallow]);
417
+ const unshallowed = oidSet(planned.unshallow);
418
+ const had = { has: (oid) => haves.has(oid) || unshallowed.has(oid) };
640
419
  const wanted = new Set(request.wants);
641
420
  const history = yield* walk(read, [...request.wants, ...planned.starts], (object) => cut.has(object.oid) ? [] : historyOf(object), had, (oid) => wanted.has(oid) ? notHeld(oid) : lost(oid));
642
- const deepened = read.roots.size === 0 ? planned : withRootsSent(planned, [...read.roots].filter((oid) => history.get(oid)?.type === "commit"));
643
- const edges = /* @__PURE__ */ new Set();
644
- for (const object of history.values()) {
645
- if (object.type !== "commit" || cut.has(object.oid)) continue;
646
- for (const parent of historyOf(object)) if (had.has(parent)) edges.add(parent);
421
+ const deepened = read.roots.size === 0 ? planned : withRootsSent(planned, [...read.roots].filter((oid) => history.typeOf(oid) === "commit"));
422
+ const hadAt = (bytes, at) => haves.hasBytes(bytes, at) || unshallowed.hasBytes(bytes, at);
423
+ const edges = oidSet();
424
+ for (let ordinal = 0; ordinal < history.size; ordinal += 1) {
425
+ if (history.typeAt(ordinal) !== "commit") continue;
426
+ if (cut.size > 0 && cut.has(history.oidAt(ordinal))) continue;
427
+ const parents = history.historyAt(ordinal);
428
+ for (let at = 0; at < parents.length; at += 20) if (hadAt(parents, at)) edges.addBytes(parents, at);
647
429
  }
648
430
  const edgeTrees = [];
649
- for (const commit of (yield* read([...edges])).values()) if (commit.tree !== void 0) edgeTrees.push(commit.tree);
431
+ const unreadEdges = [];
432
+ for (const oid of edges.values()) {
433
+ const have = haves.get(oid);
434
+ if (have !== void 0) {
435
+ if (have.tree !== void 0) edgeTrees.push(have.tree);
436
+ continue;
437
+ }
438
+ unreadEdges.push(oid);
439
+ }
440
+ if (unreadEdges.length > 0) {
441
+ for (const commit of (yield* read(unreadEdges)).values()) if (commit.tree !== void 0) edgeTrees.push(commit.tree);
442
+ }
650
443
  const byId = request.wants.some((oid) => {
651
- const type = history.get(oid)?.type;
444
+ const type = history.typeOf(oid);
652
445
  return type === "tree" || type === "blob";
653
446
  });
654
447
  const shallow = request.depth !== void 0 || request.shallows.length > 0;
@@ -658,26 +451,46 @@ const planFetch = /* @__PURE__ */ Effect.fnUntraced(function* (read, request, ta
658
451
  if (have?.tree !== void 0) edgeTrees.push(have.tree);
659
452
  }
660
453
  const kept = yield* heldBelow(read, edgeTrees);
661
- const sentHistory = [...history.values()].filter((object) => !kept.has(object.oid));
662
- const roots = [];
663
- for (const object of sentHistory) if (object.tree !== void 0) roots.push(object.tree);
664
- const rooted = new Set(roots);
665
- const listed = sentHistory.filter((object) => object.type !== "tree" || !rooted.has(object.oid));
454
+ const rooted = oidSet();
455
+ for (let ordinal = 0; ordinal < history.size; ordinal += 1) {
456
+ const tree = history.treeAt(ordinal);
457
+ if (tree !== void 0 && !kept.hasBytes(history.bytesAt(ordinal))) rooted.addBytes(tree);
458
+ }
459
+ const listedAt = (ordinal) => {
460
+ const id = history.bytesAt(ordinal);
461
+ return !kept.hasBytes(id) && (history.typeAt(ordinal) !== "tree" || !rooted.hasBytes(id));
462
+ };
666
463
  const listedEntries = [];
667
- for (const object of listed) if (object.entries !== void 0) listedEntries.push(object.entries);
668
- const skip = new Set(kept);
669
- for (const oid of had) skip.add(oid);
670
- for (const object of listed) skip.add(object.oid);
671
- const content = yield* contentBelow(read, roots, listedEntries, skip, request.filter, {
464
+ let held = 0;
465
+ for (let ordinal = 0; ordinal < history.size; ordinal += 1) {
466
+ if (!listedAt(ordinal)) continue;
467
+ held += 1;
468
+ const entries = history.entriesAt(ordinal);
469
+ if (entries !== void 0) listedEntries.push(entries);
470
+ }
471
+ const below = yield* contentBelow(read, rooted.table.ids, listedEntries, { hasBytes: (ids, at) => {
472
+ if (kept.hasBytes(ids, at) || hadAt(ids, at)) return true;
473
+ const ordinal = history.ordinalOfBytes(ids, at);
474
+ return ordinal !== void 0 && (history.typeAt(ordinal) !== "tree" || !rooted.hasBytes(ids, at));
475
+ } }, request.filter, {
672
476
  objects: objectsMost,
673
- held: listed.length
477
+ held
674
478
  });
675
- const objects = [...listed.map(packObjectOf), ...content];
479
+ const objects = [];
480
+ for (let ordinal = 0; ordinal < history.size; ordinal += 1) {
481
+ if (!listedAt(ordinal)) continue;
482
+ objects.push({
483
+ oid: history.oidAt(ordinal),
484
+ kind: history.typeAt(ordinal),
485
+ size: history.sizeAt(ordinal)
486
+ });
487
+ }
488
+ for (const object of below) objects.push(object);
676
489
  if (!request.includeTag || tags.length === 0) return {
677
490
  deepened,
678
491
  objects
679
492
  };
680
- const sent = new Set(objects.map((object) => object.oid));
493
+ const sent = oidSet(objects.map((object) => object.oid));
681
494
  const followed = yield* followedTags(read, tags, had, (oids) => Effect.succeed(new Set(oids.filter((oid) => sent.has(oid)))));
682
495
  return {
683
496
  deepened,
@@ -701,6 +514,13 @@ const restReads = (reads, unplaced) => {
701
514
  stored: {
702
515
  ...stored,
703
516
  find: joined(stored.find, outside.find),
517
+ into: (columns, ordinals) => {
518
+ const asked = Uint32Array.from(ordinals);
519
+ const beside = (ordinal) => unplaced.oids.has(columns.oidAt(ordinal));
520
+ const placed = asked.filter((ordinal) => !beside(ordinal));
521
+ const rest = asked.filter(beside);
522
+ return Effect.andThen(placed.length === 0 ? Effect.void : stored.into(columns, placed), rest.length === 0 ? Effect.void : outside.into(columns, rest));
523
+ },
704
524
  packed: (asked) => parted(asked, (placed, rest) => Effect.map(Effect.all([placed.length === 0 ? Effect.succeed(/* @__PURE__ */ new Set()) : stored.packed(placed), rest.length === 0 ? Effect.succeed(/* @__PURE__ */ new Set()) : outside.packed(rest)]), ([first, second]) => /* @__PURE__ */ new Set([...first, ...second])))
705
525
  }
706
526
  };
@@ -717,58 +537,65 @@ const restReads = (reads, unplaced) => {
717
537
  * `packs.test.ts`' "sends every stored entry's bytes as stored" and "writes whole a delta whose
718
538
  * base the client has" hold both; `entriesIn` throws for a delta whose base isn't before it.
719
539
  */
720
- const reuse = (objects, stored) => {
721
- const planned = new Map(objects.map((object) => [object.oid, object]));
722
- const copies = /* @__PURE__ */ new Map();
723
- for (const object of objects) {
724
- const entry = stored.get(object.oid);
725
- if (entry === void 0) continue;
726
- const { holds } = entry;
727
- const whole = holds.kind === "whole" && holds.type === object.kind && holds.size === object.size;
728
- const delta = holds.kind === "delta" && holds.base !== object.oid && planned.has(holds.base);
729
- if (whole || delta) copies.set(object.oid, entry);
540
+ const reuse = (columns, sorted) => {
541
+ const { count } = columns;
542
+ for (let ordinal = 0; ordinal < count; ordinal += 1) {
543
+ const base = columns.baseAt(ordinal);
544
+ const whole = columns.holdsAt(ordinal) === entryHolds.whole;
545
+ const delta = base !== void 0 && base !== ordinal && base < count;
546
+ columns.setCopied(ordinal, whole || delta);
730
547
  }
731
- const order = [];
732
- const placed = /* @__PURE__ */ new Set();
733
- for (const first of objects) {
548
+ const open = 1;
549
+ const placed = 2;
550
+ const state = new Uint8Array(count);
551
+ const order = new Uint32Array(count);
552
+ let sent = 0;
553
+ for (const first of sorted) {
734
554
  const chain = [];
735
- const open = /* @__PURE__ */ new Set();
736
- for (let object = planned.get(first.oid); object !== void 0 && !placed.has(object.oid);) {
737
- if (open.has(object.oid)) {
555
+ for (let ordinal = first; ordinal !== void 0;) {
556
+ if (state[ordinal] === placed) break;
557
+ if (state[ordinal] === open) {
738
558
  const last = chain.at(-1);
739
- if (last !== void 0) copies.delete(last.oid);
559
+ if (last !== void 0) columns.setCopied(last, false);
740
560
  break;
741
561
  }
742
- open.add(object.oid);
743
- chain.push(object);
744
- const holds = copies.get(object.oid)?.holds;
745
- object = holds?.kind === "delta" ? planned.get(holds.base) : void 0;
562
+ state[ordinal] = open;
563
+ chain.push(ordinal);
564
+ ordinal = columns.copiedAt(ordinal) ? columns.baseAt(ordinal) : void 0;
746
565
  }
747
- for (const object of chain.reverse()) {
748
- placed.add(object.oid);
749
- order.push(object);
566
+ for (let at = chain.length - 1; at >= 0; at -= 1) {
567
+ const ordinal = chain[at] ?? 0;
568
+ state[ordinal] = placed;
569
+ order[sent] = ordinal;
570
+ sent += 1;
750
571
  }
751
572
  }
752
- return {
753
- objects: order,
754
- copies
755
- };
573
+ columns.setOrder(order);
756
574
  };
757
575
  /**
758
- * `objects` with each one a stored pack holds in that pack's order, the packs by ID, then those no
759
- * pack holds in the plan's order: the writer then reads each 1 MiB block about once, not once for
760
- * each object in it (#647). `reuse` still brings a copied delta's base before it.
576
+ * The plan's ordinals with each one a stored pack holds in that pack's order, the packs by ID, then
577
+ * those no pack holds in the plan's order: the writer then reads each 1 MiB block about once, not
578
+ * once for each object in it (#647). `reuse` still brings a copied delta's base before it.
761
579
  */
762
- const inStoreOrder = (objects, stored) => {
763
- const packed = objects.flatMap((object) => {
764
- const entry = stored.get(object.oid);
765
- return entry === void 0 ? [] : [{
766
- object,
767
- entry
768
- }];
580
+ const inStoreOrder = (columns) => {
581
+ const { count, packs } = columns;
582
+ const { pack, offset } = columns.columns;
583
+ const ordinals = Uint32Array.from({ length: count }, (_, at) => at);
584
+ const packed = ordinals.filter((ordinal) => columns.hasEntry(ordinal));
585
+ const idOf = (ordinal) => packs[(pack[ordinal] ?? 1) - 1]?.id ?? "";
586
+ packed.sort((a, b) => {
587
+ const [packA, packB] = [idOf(a), idOf(b)];
588
+ return packA === packB ? (offset[a] ?? 0) - (offset[b] ?? 0) : packA < packB ? -1 : 1;
769
589
  });
770
- packed.sort(({ entry: a }, { entry: b }) => a.pack.id === b.pack.id ? a.offset - b.offset : a.pack.id < b.pack.id ? -1 : 1);
771
- return [...packed.map(({ object }) => object), ...objects.filter(({ oid }) => !stored.has(oid))];
590
+ const sorted = new Uint32Array(count);
591
+ sorted.set(packed);
592
+ let at = packed.length;
593
+ for (const ordinal of ordinals) {
594
+ if (columns.hasEntry(ordinal)) continue;
595
+ sorted[at] = ordinal;
596
+ at += 1;
597
+ }
598
+ return sorted;
772
599
  };
773
600
  /**
774
601
  * The refusal of a fetch that `needs` more store calls than `most`, before its pack's first byte:
@@ -809,9 +636,10 @@ const requestSpent = (spent, calls, clone, behind = false) => {
809
636
  bucket: unbound,
810
637
  subrequests: spent.most
811
638
  };
639
+ const past = (made, kind) => (spent.bound === kind ? Math.max(made, spent.most) : made) + 1;
812
640
  const needs = {
813
- bucket: calls.bucket + 1,
814
- subrequests: calls.subrequests + 1
641
+ bucket: past(calls.bucket, "bucket"),
642
+ subrequests: past(calls.subrequests, "subrequests")
815
643
  };
816
644
  return tooManyCalls(needs, most, clone, behind);
817
645
  };
@@ -864,75 +692,112 @@ const noCalls = {
864
692
  * pack, would forecast every object a row and no get. A stored pack holds no offset delta, which a
865
693
  * push may not send, so each delta's base is in `bases` (#704).
866
694
  */
867
- const writerCalls = /* @__PURE__ */ Effect.fnUntraced(function* (stored, plan, bases) {
868
- const { objects, copies } = plan;
869
- const whole = objects.filter(({ oid }) => !copies.has(oid));
870
- const packed = stored === void 0 ? /* @__PURE__ */ new Set() : yield* stored.packed(whole.map(({ oid }) => oid));
871
- const windows = /* @__PURE__ */ new Map();
872
- for (let at = 0; at < whole.length;) {
873
- const window = [];
874
- let bytes = 0;
875
- for (const object of whole.slice(at)) {
876
- if (window.length > 0 && bytes + object.size > 1048576) break;
877
- window.push(object);
878
- bytes += object.size;
879
- }
880
- windows.set(window[0]?.oid ?? "", window);
881
- at += window.length;
882
- }
883
- const read = [];
884
- const chainOf = (oid) => {
885
- for (let at = bases.get(oid), seen = /* @__PURE__ */ new Set(); at !== void 0;) {
886
- if (seen.has(at)) break;
695
+ const writerCalls = /* @__PURE__ */ Effect.fnUntraced(function* (stored, columns) {
696
+ const { count } = columns;
697
+ const { size } = columns.columns;
698
+ const whole = Uint32Array.from({ length: count }, (_, at) => columns.sentAt(at)).filter((ordinal) => !columns.copiedAt(ordinal));
699
+ const packed = stored === void 0 ? new Uint8Array(count) : yield* packedOf(stored, columns, whole);
700
+ function* chainOf(first) {
701
+ const seen = /* @__PURE__ */ new Set();
702
+ for (let at = first; at !== void 0 && !seen.has(at);) {
703
+ const entry = columns.entryAt(at);
704
+ if (entry === void 0) break;
887
705
  seen.add(at);
888
- read.push(at);
889
- at = at.holds.kind === "delta" ? bases.get(at.holds.base) : void 0;
706
+ yield entry;
707
+ at = columns.baseAt(at);
890
708
  }
891
- };
892
- for (const { oid } of objects) {
893
- const copied = copies.get(oid);
894
- if (copied !== void 0) {
895
- read.push(copied);
896
- continue;
709
+ }
710
+ function* readsInTurn() {
711
+ let windowEnd = 0;
712
+ for (let at = 0; at < count; at += 1) {
713
+ const ordinal = columns.sentAt(at);
714
+ if (columns.copiedAt(ordinal)) {
715
+ const entry = columns.entryAt(ordinal);
716
+ if (entry !== void 0) yield entry;
717
+ continue;
718
+ }
719
+ if (at < windowEnd) continue;
720
+ let bytes = 0;
721
+ let members = 0;
722
+ let next = at;
723
+ for (; next < count; next += 1) {
724
+ const member = columns.sentAt(next);
725
+ if (columns.copiedAt(member)) continue;
726
+ const each = size[member] ?? 0;
727
+ if (members > 0 && bytes + each > 1048576) break;
728
+ members += 1;
729
+ bytes += each;
730
+ if (packed[member] === 1) yield* chainOf(member);
731
+ }
732
+ windowEnd = next;
897
733
  }
898
- const window = windows.get(oid);
899
- if (window === void 0) continue;
900
- for (const object of window) if (packed.has(object.oid)) chainOf(object.oid);
901
734
  }
902
- const rows = whole.flatMap(({ oid }) => packed.has(oid) || oid === "4b825dc642cb6eb9a060e54bf8d69288fbee4904" ? [] : [oid]);
735
+ const rows = Array.from(whole).filter((ordinal) => packed[ordinal] !== 1).map((ordinal) => columns.oidAt(ordinal)).filter((oid) => oid !== emptyTree);
736
+ const sizeOf = (oid) => size[columns.find(oid) ?? columns.size] ?? 0;
737
+ let store;
738
+ if (rows.length === 0) store = 0;
739
+ else if (stored?.cachedRow !== void 0 && stored.pinCachedRows !== void 0) {
740
+ const rowBytes = rows.reduce((sum, oid) => sum + sizeOf(oid), 0);
741
+ if (stored.pinCachedRows(2 * rowBytes)) {
742
+ store = 0;
743
+ for (let at = 0; at < rows.length; at += 100) {
744
+ const end = Math.min(rows.length, at + 100);
745
+ for (let i = at; i < end; i += 1) {
746
+ const oid = rows[i];
747
+ if (oid !== void 0 && !stored.cachedRow(oid)) {
748
+ store += 1;
749
+ break;
750
+ }
751
+ }
752
+ }
753
+ } else store = Math.ceil(rows.length / 100);
754
+ } else store = Math.ceil(rows.length / 100);
903
755
  return {
904
756
  forecast: {
905
- bucket: stored?.gets(read) ?? 0,
906
- store: Math.ceil(rows.length / 100)
757
+ bucket: stored?.gets(readsInTurn()) ?? 0,
758
+ store
907
759
  },
908
760
  rows
909
761
  };
910
762
  });
911
763
  /**
912
- * `stored`, with the entries of each base down the chains of the deltas `plan` writes whole: one
913
- * look-up a step down them, through the reads' own counted calls.
764
+ * Which of `ordinals` the listed packs hold, as `StoredEntries.packed` answers, marked by ordinal:
765
+ * their IDs as text only for the one ask.
914
766
  */
915
- const basesOf = /* @__PURE__ */ Effect.fnUntraced(function* (reads, plan, stored) {
916
- const found = new Map(stored);
917
- let asked = plan.objects.flatMap(({ oid }) => plan.copies.has(oid) ? [] : [oid]);
918
- const passed = new Set(asked);
767
+ const packedOf = /* @__PURE__ */ Effect.fnUntraced(function* (stored, columns, ordinals) {
768
+ const marks = new Uint8Array(columns.count);
769
+ const held = yield* stored.packed(Array.from(ordinals, (ordinal) => columns.oidAt(ordinal)));
770
+ for (const ordinal of ordinals) if (held.has(columns.oidAt(ordinal))) marks[ordinal] = 1;
771
+ return marks;
772
+ });
773
+ /**
774
+ * Into `columns`, the entries of each base down the chains of the deltas the plan writes whole: one
775
+ * look-up a step down them, through the reads' own counted calls. A base among the plan's own
776
+ * objects was looked up with them.
777
+ */
778
+ const basesOf = /* @__PURE__ */ Effect.fnUntraced(function* (reads, columns) {
779
+ const { count } = columns;
780
+ const reached = /* @__PURE__ */ new Set();
781
+ const passed = (ordinal) => ordinal < count && !columns.copiedAt(ordinal) || reached.has(ordinal);
782
+ let asked = Uint32Array.from({ length: count }, (_, at) => at).filter((ordinal) => !columns.copiedAt(ordinal));
919
783
  while (asked.length > 0 && reads.stored !== void 0) {
920
- const bases = asked.flatMap((oid) => {
921
- const holds = found.get(oid)?.holds;
922
- return holds?.kind === "delta" && !passed.has(holds.base) ? [holds.base] : [];
923
- });
924
- for (const oid of bases) passed.add(oid);
925
- const missing = bases.filter((oid) => !found.has(oid));
926
- if (missing.length > 0) for (const [oid, entry] of yield* reads.stored.find(missing)) found.set(oid, entry);
784
+ const bases = [];
785
+ for (let at = 0; at < asked.length; at += 1) {
786
+ const base = columns.baseAt(asked[at] ?? 0);
787
+ if (base === void 0 || passed(base)) continue;
788
+ reached.add(base);
789
+ bases.push(base);
790
+ }
791
+ const missing = bases.filter((ordinal) => ordinal >= count && !columns.hasEntry(ordinal));
792
+ if (missing.length > 0) yield* reads.stored.into(columns, missing);
927
793
  asked = bases;
928
794
  }
929
- return found;
930
795
  });
931
796
  /**
932
797
  * What's left of `limits.milliseconds` since `started`, the moment a fetch or a build began: one
933
798
  * deadline across all it does.
934
799
  */
935
- const timeLeft = (limits, started) => Effect.map(Clock$1.currentTimeMillis, (now) => limits.milliseconds - (now - started));
800
+ const timeLeft = (limits, started) => Effect.map(Clock.currentTimeMillis, (now) => limits.milliseconds - (now - started));
936
801
  /**
937
802
  * A fetch's objects: from the repo's index build where `within.index` names one that answers the
938
803
  * request, else today's walk, `planFetch`. The index path answers a shallow request's lines from the
@@ -943,17 +808,17 @@ const objectsPlanned = /* @__PURE__ */ Effect.fnUntraced(function* (read, reques
943
808
  const { index, calls, clone } = within;
944
809
  if (index === void 0) return yield* planFetch(read, request, tags, objectsMost);
945
810
  const sending = {
946
- source: index,
811
+ source: index.source,
947
812
  read,
948
813
  request,
949
814
  tags,
950
815
  objectsMost,
951
816
  ahead: (forecast) => callsAhead(calls, forecast, clone),
952
817
  tooMany: tooManyObjects(objectsMost),
953
- extras: index.extras ?? calls?.extras ?? { met: false }
818
+ extras: index.source.extras ?? calls?.extras ?? { met: false }
954
819
  };
955
820
  if (within.thin) sending.thin = true;
956
- const sent = yield* indexSendSet(sending);
821
+ const sent = yield* index.send(sending);
957
822
  if (sent === void 0) return yield* planFetch(read, request, tags, objectsMost);
958
823
  const { list, rest, covered, had, sentOf, deepened } = sent;
959
824
  const followed = !request.includeTag || tags.length === 0 ? [] : yield* followedTags(read, tags, had, sentOf);
@@ -969,6 +834,28 @@ const objectsPlanned = /* @__PURE__ */ Effect.fnUntraced(function* (read, reques
969
834
  };
970
835
  });
971
836
  /**
837
+ * The planned objects as columns, each added once in the plan's order, and the rest of what was
838
+ * planned beside them: the objects' list let go once they're in.
839
+ */
840
+ const columnsOf = (planned) => {
841
+ const { deepened, objects, list, unplaced } = planned;
842
+ const columns = planColumns(objects.length);
843
+ for (const object of objects) columns.add(object);
844
+ return {
845
+ deepened,
846
+ list,
847
+ unplaced,
848
+ columns
849
+ };
850
+ };
851
+ /** `listed` and the bytes the plan's objects send: a copy's own, and any other's size. */
852
+ const sentBytes = (columns, listed) => {
853
+ const { size, bytes } = columns.columns;
854
+ let sum = listed;
855
+ for (let ordinal = 0; ordinal < columns.count; ordinal += 1) sum += columns.copiedAt(ordinal) ? bytes[ordinal] ?? 0 : size[ordinal] ?? 0;
856
+ return sum;
857
+ };
858
+ /**
972
859
  * A fetch's plan over the objects `reads` reads: `loose()`'s rows, or `packs()`' rows and listed
973
860
  * packs, with `input.tags` for `include-tag`. Over a bound, it's refused before any byte: it reads
974
861
  * each object once and holds one at a time, keeping only its links, and reads or sizes at most
@@ -978,7 +865,7 @@ const planFetchWithin = /* @__PURE__ */ Effect.fnUntraced(function* (reads, inpu
978
865
  const { request, limits } = input;
979
866
  const left = within.left ?? limits.milliseconds;
980
867
  if (left <= 0) return yield* Effect.fail(planTooSlow(limits));
981
- const { deepened, objects, copies, rows, list, unplaced } = yield* Effect.gen(function* () {
868
+ const { deepened, columns, rows, list, unplaced } = yield* Effect.gen(function* () {
982
869
  const clone = request.haves.length === 0;
983
870
  const checked = callsChecked(within.calls, clone);
984
871
  const roots = input.roots;
@@ -986,26 +873,23 @@ const planFetchWithin = /* @__PURE__ */ Effect.fnUntraced(function* (reads, inpu
986
873
  ...reads,
987
874
  roots: new Set(roots)
988
875
  }, within.readsMost ?? fetchReadsOf(limits), within.charge, checked, within.release);
989
- const planned = yield* objectsPlanned(read, request, input.tags ?? [], limits.objects, {
876
+ const { deepened, list, unplaced, columns } = columnsOf(yield* objectsPlanned(read, request, input.tags ?? [], limits.objects, {
990
877
  ...within,
991
878
  clone,
992
879
  thin: input.thin === true
993
- });
994
- const { deepened, objects } = planned;
995
- const list = "list" in planned ? planned.list : void 0;
996
- const unplaced = "unplaced" in planned ? planned.unplaced : void 0;
880
+ }));
997
881
  const restRead = restReads(reads, unplaced);
998
- const stored = yield* restRead.stored?.find(objects.map((object) => object.oid)) ?? Effect.succeed(/* @__PURE__ */ new Map());
999
- const reused = reuse(inStoreOrder(objects, stored), stored);
882
+ if (restRead.stored !== void 0) yield* restRead.stored.into(columns, Uint32Array.from({ length: columns.count }, (_, at) => at));
883
+ reuse(columns, inStoreOrder(columns));
1000
884
  const { calls, walked } = within;
1001
885
  let rows = [];
1002
886
  let forecast;
1003
887
  if (reads.stored !== void 0) {
1004
- const bases = calls === void 0 ? stored : yield* basesOf(restRead, reused, stored);
1005
- const writer = yield* writerCalls(restRead.stored, reused, bases);
888
+ if (calls !== void 0) yield* basesOf(restRead, columns);
889
+ const writer = yield* writerCalls(restRead.stored, columns);
1006
890
  rows = writer.rows;
1007
891
  if (calls !== void 0) {
1008
- const listed = list === void 0 ? noCalls : listCalls(reads.stored, list);
892
+ const listed = list === void 0 || within.index === void 0 ? noCalls : within.index.calls(reads.stored, list);
1009
893
  forecast = {
1010
894
  bucket: listed.bucket + writer.forecast.bucket,
1011
895
  store: listed.store + writer.forecast.store
@@ -1019,26 +903,29 @@ const planFetchWithin = /* @__PURE__ */ Effect.fnUntraced(function* (reads, inpu
1019
903
  rows,
1020
904
  list,
1021
905
  unplaced,
1022
- ...reused
906
+ columns
1023
907
  };
1024
908
  }).pipe(Effect.timeoutOrElse({
1025
909
  duration: left,
1026
910
  orElse: () => Effect.fail(planTooSlow(limits))
1027
911
  }));
1028
- const bytes = objects.reduce((sum, object) => sum + (copies.get(object.oid)?.bytes ?? object.size), list?.bytes ?? 0);
1029
- const count = objects.length + (list?.count ?? 0);
912
+ const bytes = sentBytes(columns, list?.bytes ?? 0);
913
+ const count = columns.count + (list?.count ?? 0);
1030
914
  if (count > limits.objects || bytes > limits.bytes) return yield* Effect.fail(gitError("RESOURCE_EXHAUSTED", `This fetch needs ${count} objects, ${bytes} bytes: at most ${limits.objects}, ${limits.bytes}`, {
1031
915
  hint: "Fetch fewer refs at a time",
1032
916
  context: { reason: "fetch-plan-too-large" }
1033
917
  }));
1034
918
  const plan = {
1035
919
  deepened,
1036
- objects,
1037
- copies,
920
+ columns,
1038
921
  bytes,
1039
922
  rows
1040
923
  };
1041
- if (list !== void 0) plan.list = list;
924
+ if (list !== void 0) {
925
+ plan.list = list;
926
+ const { index } = within;
927
+ if (index !== void 0) plan.listSource = (from) => index.sourceOf(from, list);
928
+ }
1042
929
  if (unplaced !== void 0) plan.unplaced = unplaced;
1043
930
  return plan;
1044
931
  });
@@ -1048,9 +935,9 @@ const planFetchWithin = /* @__PURE__ */ Effect.fnUntraced(function* (reads, inpu
1048
935
  * read that fails then ends the stream, and so does the call's signal aborting.
1049
936
  */
1050
937
  const packOfPlan = /* @__PURE__ */ Effect.fnUntraced(function* (reads, plan, limits, writing, rows) {
1051
- const { deepened, list } = plan;
938
+ const { deepened } = plan;
1052
939
  const planned = plannedSource(restReads(reads, plan.unplaced), plan, rows);
1053
- const listed = list === void 0 ? void 0 : listSource(reads, list);
940
+ const listed = plan.listSource?.(reads);
1054
941
  const source = listed === void 0 ? planned : joinedSources(listed, planned);
1055
942
  const meter = new BufferMeter(writerBytes);
1056
943
  const writeLimits = {
@@ -1096,7 +983,7 @@ const fetchPack = /* @__PURE__ */ Effect.fnUntraced(function* (reads, input, fet
1096
983
  const { started, ended, charge, calls, index, release, walked, planned } = held;
1097
984
  const refused = pastLimits(input.limits, fetchLimits);
1098
985
  if (refused !== void 0) return yield* Effect.fail(refused);
1099
- const since = started ?? (yield* Clock$1.currentTimeMillis);
986
+ const since = started ?? (yield* Clock.currentTimeMillis);
1100
987
  const within = { left: yield* timeLeft(input.limits, since) };
1101
988
  if (charge !== void 0) within.charge = charge;
1102
989
  if (calls !== void 0) within.calls = calls;
@@ -1128,12 +1015,14 @@ const fetchPack = /* @__PURE__ */ Effect.fnUntraced(function* (reads, input, fet
1128
1015
  * never less.
1129
1016
  */
1130
1017
  const rowsFirst = /* @__PURE__ */ Effect.fnUntraced(function* (reads, plan, charge) {
1131
- const sizes = new Map(plan.objects.map((object) => [object.oid, object.size]));
1018
+ const { columns } = plan;
1019
+ const { size } = columns.columns;
1020
+ const sizeOf = (oid) => size[columns.find(oid) ?? columns.size] ?? 0;
1132
1021
  const rows = /* @__PURE__ */ new Map();
1133
1022
  const { held } = restReads(reads, plan.unplaced);
1134
1023
  for (let at = 0; at < plan.rows.length; at += 100) {
1135
1024
  const batch = plan.rows.slice(at, at + 100);
1136
- if (charge !== void 0) yield* charge(2 * batch.reduce((sum, oid) => sum + (sizes.get(oid) ?? 0), 0));
1025
+ if (charge !== void 0) yield* charge(2 * batch.reduce((sum, oid) => sum + sizeOf(oid), 0));
1137
1026
  const read = yield* held(batch);
1138
1027
  for (const oid of batch) {
1139
1028
  const whole = read.get(oid);
@@ -1143,4 +1032,4 @@ const rowsFirst = /* @__PURE__ */ Effect.fnUntraced(function* (reads, plan, char
1143
1032
  }
1144
1033
  return rows;
1145
1034
  });
1146
- export { awaitingIndex, callsAhead, checkedCopy, defaultFetchLimits, fetchPack, fetchTooLarge, listCalls, listRuns, listSource, memoryPack, packOfPlan, pastLimits, planFetchWithin, planTooSlow, refusedWhenSpent, requestSpent, timeLeft, tooManyCalls, unreadPackMs, windowBytes };
1035
+ export { awaitingIndex, callsAhead, checkedCopy, defaultFetchLimits, fetchPack, fetchTooLarge, gone, memoryPack, packOfPlan, pastLimits, planFetchWithin, planTooSlow, rangeBytes, refusedWhenSpent, requestSpent, timeLeft, tooManyCalls, unreadPackMs, windowBytes };