@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
@@ -12,6 +12,9 @@ import * as Schema from "effect/Schema";
12
12
  * the first, so a kind whose rows start with an ID is in the ID's order. Each run is sorted on its
13
13
  * own, and a merge of them reads every row once, in order. As a row stores them, so a step's next
14
14
  * try merges runs an earlier one put: `lengths` are each run's bytes, a multiple of `width`.
15
+ * `chains` are how many runs each chain holds, in order, when some runs follow on from the one
16
+ * before: a chain's runs are one sorted run cut in parts, each row past every row before it, so a
17
+ * merge reads a chain as one way, a part after the other (#2690). Unset, each run is a chain.
15
18
  */
16
19
  const StoredRuns = /* @__PURE__ */ Schema.Struct({
17
20
  kind: Schema.String,
@@ -27,10 +30,15 @@ const StoredRuns = /* @__PURE__ */ Schema.Struct({
27
30
  rows: Schema.Int.check(Schema.isBetween({
28
31
  minimum: 0,
29
32
  maximum: Number.MAX_SAFE_INTEGER
30
- }))
33
+ })),
34
+ chains: Schema.optionalKey(Schema.Array(Schema.Int.check(Schema.isBetween({
35
+ minimum: 1,
36
+ maximum: Number.MAX_SAFE_INTEGER
37
+ }))))
31
38
  }).check(Schema.makeFilter((runs) => {
32
39
  if (runs.keys.length !== runs.lengths.length) return "its keys and lengths are not one a run";
33
40
  if (runs.lengths.some((length) => length % runs.width !== 0)) return "a run is not whole rows";
41
+ if (runs.chains !== void 0 && runs.chains.reduce((sum, count) => sum + count, 0) !== runs.keys.length) return "its chains are not its runs";
34
42
  return runs.lengths.reduce((sum, length) => sum + length, 0) === runs.rows * runs.width || "its rows are not its runs' rows";
35
43
  }));
36
44
  /** A receive's runs: `receive-bounds.ts`' constants. */
@@ -206,8 +214,60 @@ var ReceiveRoom = class {
206
214
  return this.#grow(more);
207
215
  }
208
216
  };
209
- /** The reads a merge of `runs` holds, `readBytes` of each run at most: a held run's are its writer's. */
210
- const readsOf = (runs, readBytes) => runs.lengths.reduce((sum, length) => sum + Math.min(readBytes, length), 0);
217
+ /** How many runs each of `runs`' chains holds, in order: one each, unless `chains` says. */
218
+ const chainsOf = (runs) => runs.chains ?? runs.keys.map(() => 1);
219
+ /** `lengths` a chain at a time, as `chains` counts them: a run a chain unless it's set. */
220
+ const partsOf = (lengths, chains) => {
221
+ if (chains === void 0) return lengths.map((length) => [length]);
222
+ let from = 0;
223
+ return chains.map((count) => {
224
+ from += count;
225
+ return lengths.slice(from - count, from);
226
+ });
227
+ };
228
+ /** The bytes each of `runs`' chains holds, in order: a merge's ways, as it reads them. */
229
+ const wayLengths = (runs) => partsOf(runs.lengths, runs.chains).map((parts) => parts.reduce((sum, each) => sum + each, 0));
230
+ /** `runs` with `chains`, or without when each run is its own, as a store keeps them. */
231
+ const withChains = (runs, chains) => {
232
+ const { chains: _dropped, ...rest } = runs;
233
+ return chains.every((count) => count === 1) ? rest : {
234
+ ...rest,
235
+ chains
236
+ };
237
+ };
238
+ /**
239
+ * `put`'s runs after `before`'s, as one chain: `put` a `sorted` writer's, which refuses a row out
240
+ * of order, each of its rows past every row of `before`'s, as a writer that goes on past a save's
241
+ * last row puts them. `before` is one chain already, or none.
242
+ */
243
+ const chained = (before, put) => {
244
+ const parts = [...before === void 0 ? [] : [before], put];
245
+ if (put.held !== void 0 || before !== void 0 && chainsOf(before).length > 1) throw new Error(`${put.kind}'s runs are held, or follow more than one chain`);
246
+ const keys = parts.flatMap((runs) => runs.keys);
247
+ const joined = {
248
+ ...put,
249
+ keys,
250
+ lengths: parts.flatMap((runs) => runs.lengths),
251
+ rows: parts.reduce((sum, runs) => sum + runs.rows, 0)
252
+ };
253
+ return withChains(joined, keys.length === 0 ? [] : [keys.length]);
254
+ };
255
+ /**
256
+ * `a`'s runs and then `b`'s, of one width, as one: their chains side by side, `kind` naming where
257
+ * a merge of them narrows.
258
+ */
259
+ const joinedChains = (a, b, kind = a.kind) => withChains({
260
+ ...a,
261
+ kind,
262
+ keys: [...a.keys, ...b.keys],
263
+ lengths: [...a.lengths, ...b.lengths],
264
+ rows: a.rows + b.rows
265
+ }, [...chainsOf(a), ...chainsOf(b)]);
266
+ /**
267
+ * The reads a merge of `runs` holds: of each chain, `readBytes` of its longest run at most. A held
268
+ * run's are its writer's.
269
+ */
270
+ const readsOf = (runs, readBytes) => partsOf(runs.lengths, runs.chains).reduce((sum, parts) => sum + Math.min(readBytes, parts.reduce((most, each) => Math.max(most, each), 0)), 0);
211
271
  /**
212
272
  * The first `order.length` rows of `bytes` put in `order`, in place: one cycle of the order at a
213
273
  * time, through one spare row and a mark a row, so the sort holds no second copy of the rows.
@@ -432,7 +492,33 @@ const runWriter = (bucket, pack, kind, width, { bytes = receiveRunBytes, first =
432
492
  most
433
493
  };
434
494
  };
495
+ /** `cursor` on its chain's `part`th run, nothing of it read. */
496
+ const onPart = (cursor, part) => {
497
+ for (; cursor.part < part; cursor.part += 1) cursor.before += cursor.lengths[cursor.part] ?? 0;
498
+ cursor.key = cursor.keys[part] ?? "";
499
+ cursor.length = cursor.lengths[part] ?? 0;
500
+ cursor.read = 0;
501
+ cursor.chunk = /* @__PURE__ */ new Uint8Array(0);
502
+ cursor.at = 0;
503
+ };
435
504
  const lost = (message) => gitError("DATA_LOSS", message);
505
+ /** A chain's run `key` that starts before the run ahead of it ends: no chain, its rows not in order. */
506
+ const outOfOrder = (key) => lost(`A chain's run ${key} starts before the one ahead of it ends`);
507
+ /**
508
+ * The reads a merge of `runs` from `starts` makes besides each chain's first: one for each chain
509
+ * whose start is a run's first row past the chain's first, which reads the last row of the run
510
+ * ahead to check their order.
511
+ */
512
+ const seekChecks = (runs, starts) => partsOf(runs.lengths, runs.chains).filter((lengths, way) => {
513
+ const start = (starts[way] ?? 0) * runs.width;
514
+ let bytes = 0;
515
+ for (const length of lengths.slice(0, -1)) {
516
+ bytes += length;
517
+ if (bytes === start) return true;
518
+ if (bytes > start) return false;
519
+ }
520
+ return false;
521
+ }).length;
436
522
  /** The next chunk of `cursor`'s run, or an empty one at its end. */
437
523
  const refill = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, cursor, readBytes) {
438
524
  const length = Math.min(readBytes, cursor.length - cursor.read);
@@ -442,10 +528,12 @@ const refill = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, cursor, read
442
528
  cursor.at = 0;
443
529
  });
444
530
  /**
445
- * The rows of `runs`, `bounds.ways` of them at most, in order, a row each `next`: a heap of
446
- * one cursor a run, each holding one read, taken from `room` until the last row is passed. A row's
447
- * bytes stay as they are after the next `next`, since a read takes new bytes, never the old ones.
448
- * Its reads are ⌈length / read⌉ a run. Each run is read from its row of `starts`, when it's given.
531
+ * The rows of `runs`, `bounds.ways` chains of them at most, in order, a row each `next`: a heap of
532
+ * one cursor a chain, each holding one read, taken from `room` until the last row is passed. A
533
+ * chain's runs are read one after the other, the next one's first read as the one before ends. A
534
+ * row's bytes stay as they are after the next `next`, since a read takes new bytes, never the old
535
+ * ones. Its reads are ⌈length / read⌉ a run. Each chain is read from its row of `starts`, when
536
+ * it's given.
449
537
  */
450
538
  const fewCursor = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, runs, bounds, room, starts) {
451
539
  const { width } = runs;
@@ -485,38 +573,66 @@ const fewCursor = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, runs, bou
485
573
  const { held } = runs;
486
574
  const length = held.byteLength;
487
575
  heap.push({
488
- key: "",
489
576
  run: -1,
577
+ keys: [""],
578
+ lengths: [length],
579
+ part: 0,
580
+ before: 0,
581
+ key: "",
490
582
  length,
491
583
  read: length,
492
584
  chunk: held,
493
585
  at: 0
494
586
  });
495
587
  }
496
- if (starts !== void 0 && (starts.length !== runs.keys.length || runs.held !== void 0)) return yield* Effect.fail(lost(`A merge seeks ${starts.length} of ${runs.keys.length} runs`));
497
- for (const [index, key] of runs.keys.entries()) {
588
+ const chains = partsOf(runs.lengths, runs.chains);
589
+ if (starts !== void 0 && (starts.length !== chains.length || runs.held !== void 0)) return yield* Effect.fail(lost(`A merge seeks ${starts.length} of ${chains.length} chains`));
590
+ let first = 0;
591
+ for (const [index, lengths] of chains.entries()) {
592
+ const keys = runs.keys.slice(first, first + lengths.length);
593
+ first += lengths.length;
498
594
  const start = (starts?.[index] ?? 0) * width;
499
595
  const cursor = {
500
- key,
501
596
  run: index,
502
- length: runs.lengths[index] ?? 0,
503
- read: start - start % readBytes,
597
+ keys,
598
+ lengths,
599
+ part: 0,
600
+ before: 0,
601
+ key: "",
602
+ length: 0,
603
+ read: 0,
504
604
  chunk: /* @__PURE__ */ new Uint8Array(0),
505
605
  at: 0
506
606
  };
507
607
  cursors.push(cursor);
508
- if (start > cursor.length) return yield* Effect.fail(lost(`A merge seeks past its run ${key}'s rows`));
509
- if (start === cursor.length) {
510
- cursor.read = start;
608
+ let part = 0;
609
+ for (let bytes = 0; part < lengths.length - 1; part += 1) {
610
+ bytes += lengths[part] ?? 0;
611
+ if (bytes > start) break;
612
+ }
613
+ onPart(cursor, part);
614
+ const inPart = start - cursor.before;
615
+ if (inPart > cursor.length) return yield* Effect.fail(lost(`A merge seeks past its chain ${keys[0] ?? ""}'s rows`));
616
+ if (inPart === cursor.length) {
617
+ cursor.read = inPart;
511
618
  continue;
512
619
  }
620
+ cursor.read = inPart - inPart % readBytes;
513
621
  yield* refill(bucket, cursor, readBytes);
514
- cursor.at = start % readBytes;
622
+ cursor.at = inPart % readBytes;
623
+ if (inPart === 0 && part > 0) {
624
+ const ahead = lengths[part - 1] ?? 0;
625
+ const ended = yield* readExactly(bucket, keys[part - 1] ?? "", ahead - width, width);
626
+ if (compare(cursor.chunk, 0, ended, 0, width) < 0) return yield* Effect.fail(outOfOrder(cursor.key));
627
+ }
515
628
  heap.push(cursor);
516
629
  }
517
630
  for (let at = Math.floor(heap.length / 2) - 1; at >= 0; at -= 1) down(at);
518
- const places = () => cursors.map((cursor) => (cursor.read - cursor.chunk.byteLength + cursor.at) / width);
519
- /** The least cursor moved past the row it answered: refilled, or out of the heap at its end. */
631
+ const places = () => cursors.map((cursor) => (cursor.before + cursor.read - cursor.chunk.byteLength + cursor.at) / width);
632
+ /**
633
+ * The least cursor moved past the row it answered: refilled, on to its chain's next run, or out
634
+ * of the heap at its chain's end.
635
+ */
520
636
  const passed = () => {
521
637
  const least = heap[0];
522
638
  if (least === void 0) return void 0;
@@ -528,6 +644,15 @@ const fewCursor = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, runs, bou
528
644
  if (least.read < least.length) return Effect.map(refill(bucket, least, readBytes), () => {
529
645
  down(0);
530
646
  });
647
+ if (least.part + 1 < least.lengths.length) {
648
+ const ended = least.chunk.subarray(least.chunk.byteLength - width);
649
+ onPart(least, least.part + 1);
650
+ return Effect.flatMap(refill(bucket, least, readBytes), () => {
651
+ if (compare(least.chunk, 0, ended, 0, width) < 0) return Effect.fail(outOfOrder(least.key));
652
+ down(0);
653
+ return Effect.void;
654
+ });
655
+ }
531
656
  const last = heap.pop();
532
657
  if (last === void 0 || heap.length === 0) return void 0;
533
658
  heap[0] = last;
@@ -571,22 +696,27 @@ const eachRow = /* @__PURE__ */ Effect.fnUntraced(function* (cursor, places, eac
571
696
  /** Every row of `runs`, at most `bounds.ways` of them, in order, through `each`, from `starts`. */
572
697
  const mergeFew = (bucket, runs, each, bounds, room, starts) => Effect.flatMap(fewCursor(bucket, runs, bounds, room, starts), ({ next, places }) => eachRow(next, places, each));
573
698
  /**
574
- * `runs` merged `bounds.ways` at a time into fewer, longer runs under `pack`, until no more than
575
- * that many are left: each pass reads and puts every row once, its reads and its chunk taken from
576
- * `room` as it merges. A caller merging the same runs more than once narrows them once first.
699
+ * `runs` merged `bounds.ways` chains at a time into fewer, longer runs under `pack`, until no more
700
+ * than that many chains are left: each pass reads and puts every row once, its reads and its chunk
701
+ * taken from `room` as it merges. Each run it puts is a chain of its own. A caller merging the
702
+ * same runs more than once narrows them once first.
577
703
  */
578
704
  const narrowed = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, pack, runs, bounds, room) {
579
705
  const { ways } = bounds;
580
706
  let current = runs;
581
- for (let pass = 1; current.keys.length > ways; pass += 1) {
707
+ for (let pass = 1; chainsOf(current).length > ways; pass += 1) {
582
708
  const keys = [];
583
709
  const lengths = [];
584
- for (let from = 0; from < current.keys.length; from += ways) {
585
- const group = {
710
+ const chains = chainsOf(current);
711
+ for (let from = 0, first = 0; from < chains.length; from += ways) {
712
+ const counts = chains.slice(from, from + ways);
713
+ const count = counts.reduce((sum, each) => sum + each, 0);
714
+ const group = withChains({
586
715
  ...current,
587
- keys: current.keys.slice(from, from + ways),
588
- lengths: current.lengths.slice(from, from + ways)
589
- };
716
+ keys: current.keys.slice(first, first + count),
717
+ lengths: current.lengths.slice(first, first + count)
718
+ }, counts);
719
+ first += count;
590
720
  const length = group.lengths.reduce((sum, each) => sum + each, 0);
591
721
  const key = runKey(pack, `${runs.kind}.${pass}`, keys.length);
592
722
  const chunkBytes = Math.max(1, Math.floor(writeBytes / runs.width)) * runs.width;
@@ -615,40 +745,61 @@ const narrowed = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, pack, runs
615
745
  keys.push(key);
616
746
  lengths.push(length);
617
747
  }
618
- current = {
748
+ current = withChains({
619
749
  ...current,
620
750
  keys,
621
751
  lengths
622
- };
752
+ }, []);
623
753
  }
624
754
  return current;
625
755
  });
626
756
  /**
627
- * The bucket calls `narrowed` makes over runs of `lengths` bytes of `width`-byte rows, and the runs
628
- * it leaves: each pass's read of every `readBytes` of each run it merges, and the put of each run it
629
- * merges them to.
757
+ * The bucket calls `narrowed` makes over runs of `lengths` bytes of `width`-byte rows, in `chains`
758
+ * when set, and the runs and ways it leaves: each pass's read of every `readBytes` of each run it
759
+ * merges, and the put of each run it merges a group of chains to.
630
760
  */
631
- const narrowedCalls = (lengths, width, bounds, multipart) => {
761
+ const narrowedCalls = (lengths, width, bounds, multipart, chains) => {
632
762
  const readBytes = wholeRows(width, bounds.readBytes);
633
- let current = lengths;
763
+ let current = partsOf(lengths, chains);
634
764
  let calls = 0;
635
765
  while (current.length > bounds.ways) {
636
766
  const next = [];
637
767
  for (let from = 0; from < current.length; from += bounds.ways) {
638
- const group = current.slice(from, from + bounds.ways);
768
+ const group = current.slice(from, from + bounds.ways).flat();
639
769
  const length = group.reduce((sum, each) => sum + each, 0);
640
770
  calls += group.reduce((sum, each) => sum + Math.ceil(each / readBytes), 0);
641
771
  calls += sizedPutCalls(multipart, length);
642
- next.push(length);
772
+ next.push([length]);
643
773
  }
644
774
  current = next;
645
775
  }
646
776
  return {
647
777
  calls,
648
- runs: current.length
778
+ runs: current.flat().length,
779
+ ways: current.length
649
780
  };
650
781
  };
651
782
  /**
783
+ * The bucket calls `mergeRuns` makes over `runs`, a forecast: `narrowedCalls`, then a read of each
784
+ * `readBytes` of the runs it leaves.
785
+ */
786
+ const mergeRunsCalls = (runs, bounds, multipart) => {
787
+ const narrowing = narrowedCalls(runs.lengths, runs.width, bounds, multipart, runs.chains);
788
+ const bytes = runs.lengths.reduce((sum, length) => sum + length, 0);
789
+ return narrowing.calls + Math.ceil(bytes / wholeRows(runs.width, bounds.readBytes)) + narrowing.runs;
790
+ };
791
+ /**
792
+ * The reads a merge of runs of `lengths` bytes of `width`-byte rows makes, at most, to pass `rows`
793
+ * of their rows from `places` and look at the one after: each run it hasn't read out, once at its
794
+ * place and once more as its cursor passes that read's end, and a read for each `readBytes` the
795
+ * rows it passes take beyond those. A run's cursor reads on as soon as it passes a read's end, so
796
+ * many runs read from their places may each read again within a few rows.
797
+ */
798
+ const passedReads = (lengths, width, places, rows, bounds) => {
799
+ const readBytes = wholeRows(width, bounds.readBytes);
800
+ return 2 * lengths.filter((length, run) => (places?.[run] ?? 0) * width < length).length + Math.floor((rows + 1) * width / readBytes);
801
+ };
802
+ /**
652
803
  * Every row of `runs` in order, through `each`, however many runs there are: past `bounds.ways`,
653
804
  * they're first merged into that many under `pack`'s runs. Its reads are taken from `room` as it
654
805
  * reads. Given `starts`, the places an earlier merge of the same runs passed, each run it merges
@@ -668,20 +819,21 @@ const mergedCursor = (bucket, pack, runs, bounds = receiveRuns, room) => Effect.
668
819
  */
669
820
  const stepRunKind = (kind, step, attempt) => `${kind}-${step}-${attempt}`;
670
821
  /**
671
- * The runs of one kind its steps put, as one writer's: each step's keys in order, so a merge reads
672
- * them as it reads one writer's. A step's runs are put always, so none holds rows. Its rows are
673
- * those its runs hold: a deduping writer's `rows` counts the repeats it dropped too.
822
+ * The runs of one kind its steps put, as one writer's: each step's keys in order, and its chains,
823
+ * so a merge reads them as it reads one writer's. A step's runs are put always, so none holds rows.
824
+ * Its rows are those its runs hold: a deduping writer's `rows` counts the repeats it dropped too.
674
825
  */
675
826
  const joinedRuns = (kind, width, steps) => {
676
827
  if (steps.some((runs) => runs.width !== width || runs.held !== void 0)) throw new Error(`a step's ${kind} runs are held, or not ${width}-byte rows`);
677
828
  const lengths = steps.flatMap((runs) => runs.lengths);
678
- return {
829
+ const joined = {
679
830
  kind,
680
831
  width,
681
832
  keys: steps.flatMap((runs) => runs.keys),
682
833
  lengths,
683
834
  rows: lengths.reduce((sum, length) => sum + length, 0) / width
684
835
  };
836
+ return withChains(joined, steps.flatMap(chainsOf));
685
837
  };
686
838
  /**
687
839
  * `runWriter`, or with `step`, one step's of a writer that spans steps: its runs put always under
@@ -737,4 +889,4 @@ const dropRuns = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, pack, kept
737
889
  }
738
890
  return "more";
739
891
  });
740
- export { ReceiveRoom, StoredRuns, cursorHeld, dedupeTableBytes, dropRuns, firstBytesOf, joinedRuns, mergeHeld, mergeRuns, mergedCursor, narrowed, narrowedCalls, receiveRuns, runWriter, sortedWriterHeld, stepRunKind, steppedWriter, wholeRows, writerHeld, writersHeld };
892
+ export { ReceiveRoom, StoredRuns, chained, chainsOf, cursorHeld, dedupeTableBytes, dropRuns, firstBytesOf, joinedChains, joinedRuns, mergeHeld, mergeRuns, mergeRunsCalls, mergedCursor, narrowed, narrowedCalls, passedReads, receiveRuns, runWriter, seekChecks, sortedWriterHeld, stepRunKind, steppedWriter, wayLengths, wholeRows, writerHeld, writersHeld };
@@ -3,6 +3,7 @@ import "../contracts/result.mjs";
3
3
  import "../contracts/store.mjs";
4
4
  import "./fetch.mjs";
5
5
  import "./index-build.mjs";
6
+ import "./index-files.mjs";
6
7
  import "./pack-reads.mjs";
7
8
  import "./pack-ranges.mjs";
8
9
  import "./walk.mjs";
@@ -183,6 +183,14 @@ const basesReadBytes = (positions) => positions * 8 * 6;
183
183
  /** What a run of `.bases` rows holds as it's read, charged once before the first. */
184
184
  const basesRunBytes = basesReadBytes(basesRun * basesBlock);
185
185
  const loss = (message) => gitError("DATA_LOSS", message);
186
+ /**
187
+ * `input`'s forecasts of the index's own reads, its `.bases` and a covered pack's `.idx`: none
188
+ * when it's held whole, as `bucket` then serves them with no call (#2523).
189
+ */
190
+ const indexAheadOf = (input) => input.indexHeld === true ? (forecast) => input.ahead({
191
+ bucket: 0,
192
+ store: forecast.store
193
+ }) : input.ahead;
186
194
  /** The runs of `.bases` blocks in `[from, to)` that hold a position of `wanted`, as read ranges. */
187
195
  const basesRuns = (wanted, from, to) => {
188
196
  const runs = [];
@@ -199,6 +207,14 @@ const basesRuns = (wanted, from, to) => {
199
207
  }
200
208
  return runs;
201
209
  };
210
+ /** `got`, the rows of a `.bases` read over `reading`, into `rows` by block: each its own pairs. */
211
+ const keepBlocks = (rows, reading, got) => {
212
+ for (let block = Math.floor(reading.from / basesBlock), row = 0; block * basesBlock < reading.to; block += 1) {
213
+ const from = row;
214
+ while (row < got.length && (got[row] ?? 0) < (block + 1) * 4096) row += 2;
215
+ rows.set(block, got.subarray(from, row));
216
+ }
217
+ };
202
218
  /** What a list keeps of an entry read by place: its place, ID, offset, CRC-32 and end. */
203
219
  const placedKeptBytes = 44;
204
220
  /**
@@ -286,7 +302,7 @@ const listOf = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
286
302
  bucket: 1,
287
303
  store: 0
288
304
  });
289
- const placed = new RangedPack(ranges, yield* openPlacedTables(input.bucket, ranges.pack, ranges.count), ahead);
305
+ const placed = new RangedPack(ranges, yield* openPlacedTables(input.bucket, ranges.pack, ranges.count), indexAheadOf(input));
290
306
  yield* readPlaces(input, placed, places);
291
307
  packs.push(placed);
292
308
  ranged.push(placed);
@@ -402,13 +418,14 @@ const emptyList = (input, packs) => {
402
418
  * written-whole delta's chain of bases down to a whole entry.
403
419
  */
404
420
  const copiesOf = /* @__PURE__ */ Effect.fnUntraced(function* (input, list) {
405
- const { send, held, read, ahead } = input;
421
+ const { send, held, read } = input;
422
+ const ahead = indexAheadOf(input);
406
423
  const copiesAgainst = (base) => isSet(send, base) || held !== void 0 && isSet(held, base);
407
424
  const deltas = new Uint32Array(bitmapWords(list.count));
408
425
  const copied = new Uint32Array(bitmapWords(list.count));
409
426
  const bases = new Uint32Array(list.count);
410
427
  const chains = /* @__PURE__ */ new Map();
411
- const opened = /* @__PURE__ */ new Map();
428
+ const opened = new Map(input.bases);
412
429
  const packOf = (position) => list.packs.find((pack) => position >= pack.base && position < pack.base + pack.count);
413
430
  yield* read.hold(basesRunBytes);
414
431
  const basesOf = Effect.fnUntraced(function* (layer) {
@@ -428,6 +445,19 @@ const copiesOf = /* @__PURE__ */ Effect.fnUntraced(function* (input, list) {
428
445
  const pack = packOf(position);
429
446
  return pack === void 0 || base >= position || base < pack.base ? Effect.fail(loss(`The index's .bases names ${base} as ${position}'s base, not before it in its pack`)) : Effect.succeed(base);
430
447
  };
448
+ const kept = /* @__PURE__ */ new Map();
449
+ const keptOf = (layer) => {
450
+ const rows = kept.get(layer) ?? /* @__PURE__ */ new Map();
451
+ kept.set(layer, rows);
452
+ return rows;
453
+ };
454
+ let keptBytes = 0;
455
+ const keepRun = Effect.fnUntraced(function* (layer, reading, got) {
456
+ const bytes = basesReadBytes(reading.to - reading.from);
457
+ yield* read.hold(bytes);
458
+ keptBytes += bytes;
459
+ keepBlocks(keptOf(layer), reading, got);
460
+ });
431
461
  let pending = [];
432
462
  const cursor = new ListCursor(list);
433
463
  for (const layer of input.layers) {
@@ -438,11 +468,14 @@ const copiesOf = /* @__PURE__ */ Effect.fnUntraced(function* (input, list) {
438
468
  let row = 0;
439
469
  let run = 0;
440
470
  let readRun = -1;
471
+ let chainsBefore = 0;
441
472
  for (; !cursor.done && cursor.position < end; cursor.next()) {
442
473
  const { position, ordinal } = cursor;
443
474
  while (run < runs.length && (runs[run]?.to ?? 0) <= position) run += 1;
444
475
  const reading = runs[run];
445
476
  if (reading !== void 0 && reading.from <= position && run !== readRun) {
477
+ const done = runs[readRun];
478
+ if (done !== void 0 && pending.length > chainsBefore) yield* keepRun(layer, done, rows);
446
479
  const bases = yield* basesOf(layer);
447
480
  yield* ahead({
448
481
  bucket: 1,
@@ -451,6 +484,7 @@ const copiesOf = /* @__PURE__ */ Effect.fnUntraced(function* (input, list) {
451
484
  rows = yield* bases.rowsOf(reading.from, reading.to);
452
485
  row = 0;
453
486
  readRun = run;
487
+ chainsBefore = pending.length;
454
488
  }
455
489
  while (row < rows.length && (rows[row] ?? 0) < position) row += 2;
456
490
  if (row < rows.length && rows[row] === position) {
@@ -466,6 +500,8 @@ const copiesOf = /* @__PURE__ */ Effect.fnUntraced(function* (input, list) {
466
500
  }
467
501
  } else setBit(copied, ordinal);
468
502
  }
503
+ const done = runs[readRun];
504
+ if (done !== void 0 && pending.length > chainsBefore) yield* keepRun(layer, done, rows);
469
505
  }
470
506
  while (pending.length > 0) {
471
507
  const asked = [...new Set(pending)].filter((base) => !chains.has(base)).sort((a, b) => a - b);
@@ -474,26 +510,34 @@ const copiesOf = /* @__PURE__ */ Effect.fnUntraced(function* (input, list) {
474
510
  const end = layer.first + layer.positions;
475
511
  const inLayer = asked.filter((base) => base >= layer.first && base < end);
476
512
  if (inLayer.length === 0 || layer.deltas === 0) continue;
513
+ const rows = keptOf(layer);
477
514
  const blocks = new Set(inLayer.map((base) => Math.floor(base / basesBlock)));
478
515
  const bases = yield* basesOf(layer);
479
- for (const reading of basesRuns((block) => blocks.has(block), layer.first, end)) {
516
+ const unread = (block) => blocks.has(block) && !rows.has(block);
517
+ for (const reading of basesRuns(unread, layer.first, end)) {
518
+ const bytes = basesReadBytes(reading.to - reading.from);
519
+ yield* read.hold(bytes);
520
+ keptBytes += bytes;
480
521
  yield* ahead({
481
522
  bucket: 1,
482
523
  store: 0
483
524
  });
484
- const rows = yield* bases.rowsOf(reading.from, reading.to);
485
- const wanted = new Set(inLayer.filter((base) => base >= reading.from && base < reading.to));
486
- for (let row = 0; row < rows.length; row += 2) {
487
- const position = rows[row] ?? 0;
488
- if (!wanted.has(position)) continue;
489
- const base = yield* baseOf(position, rows[row + 1] ?? 0);
525
+ keepBlocks(rows, reading, yield* bases.rowsOf(reading.from, reading.to));
526
+ }
527
+ for (const position of inLayer) {
528
+ const found = rows.get(Math.floor(position / 4096)) ?? /* @__PURE__ */ new Uint32Array(0);
529
+ for (let row = 0; row < found.length; row += 2) {
530
+ if (found[row] !== position) continue;
531
+ const base = yield* baseOf(position, found[row + 1] ?? 0);
490
532
  yield* read.hold(64);
491
533
  chains.set(position, base);
492
534
  pending.push(base);
535
+ break;
493
536
  }
494
537
  }
495
538
  }
496
539
  }
540
+ if (keptBytes > 0) yield* read.release(keptBytes);
497
541
  return {
498
542
  deltas,
499
543
  copied,
@@ -1,5 +1,6 @@
1
1
  import "../contracts/result.mjs";
2
2
  import "./object-rows.mjs";
3
+ import "../protocol/objects/commit.mjs";
3
4
  import "./walk.mjs";
4
5
  import "../contracts/ids.mjs";
5
6
  import "effect/Effect";
@@ -9,6 +9,25 @@ import * as Effect from "effect/Effect";
9
9
  const infiniteDepth = 2147483647;
10
10
  const notACommit = (object) => gitError("INVALID_ARGUMENT", `The shallow line names ${object.oid}, a ${object.type}`, { hint: "A shallow clone names only commits it holds without their parents" });
11
11
  /**
12
+ * `deepened` with the repo's roots its pack sends, `sent`, among its shallow lines: each one the
13
+ * client doesn't already hold without its parents, as Git's server names each of a shallow repo's
14
+ * own its walk reaches. A root the pack doesn't send isn't named, so one only a hidden ref reaches,
15
+ * or one below the haves, never is.
16
+ */
17
+ const withRootsSent = (deepened, sent) => {
18
+ const named = new Set(deepened.shallow);
19
+ const shallow = [...deepened.shallow];
20
+ for (const oid of sent) {
21
+ if (named.has(oid) || deepened.clientShallows.has(oid)) continue;
22
+ named.add(oid);
23
+ shallow.push(oid);
24
+ }
25
+ return shallow.length === deepened.shallow.length ? deepened : {
26
+ ...deepened,
27
+ shallow
28
+ };
29
+ };
30
+ /**
12
31
  * The client's shallow commits this repo holds: one it doesn't hold is passed over,
13
32
  * as Git's server does, and one that isn't a commit is refused.
14
33
  */
@@ -87,10 +106,13 @@ const byDepth = /* @__PURE__ */ Effect.fnUntraced(function* (read, starts, depth
87
106
  * - `deepen 2147483647`, without `deepen-relative`, unshallows every one the wants reach, one
88
107
  * behind another too. Git's unshallows every one it holds, but the history behind one no
89
108
  * want reaches isn't the caller's to fetch.
109
+ * A client's shallow commit that is one of the repo's roots is never unshallowed: the repo holds
110
+ * no parents of it to send, so it stays a cut.
90
111
  */
91
112
  const planShallow = /* @__PURE__ */ Effect.fnUntraced(function* (read, request) {
92
- const shallows = yield* clientShallowsOf(read, request.shallows);
93
- const clientShallows = new Set(shallows.keys());
113
+ const held = yield* clientShallowsOf(read, request.shallows);
114
+ const clientShallows = new Set(held.keys());
115
+ const shallows = new Map([...held].filter(([oid]) => !read.roots.has(oid)));
94
116
  const depth = request.depth;
95
117
  if (depth === void 0) return {
96
118
  shallow: [],
@@ -116,7 +138,7 @@ const planShallow = /* @__PURE__ */ Effect.fnUntraced(function* (read, request)
116
138
  const from = relative ? (yield* reachedShallows(read, wants, shallows, false)).map((commit) => commit.oid) : wants;
117
139
  const levels = yield* byDepth(read, from, relative ? depth + 1 : depth);
118
140
  const unshallowed = [...shallows.values()].filter((commit) => levels.within.has(commit.oid));
119
- const kept = [...clientShallows].filter((oid) => !levels.within.has(oid));
141
+ const kept = [...clientShallows].filter((oid) => !shallows.has(oid) || !levels.within.has(oid));
120
142
  return {
121
143
  shallow: levels.edge.filter((oid) => !clientShallows.has(oid)),
122
144
  unshallow: unshallowed.map((commit) => commit.oid),
@@ -125,4 +147,4 @@ const planShallow = /* @__PURE__ */ Effect.fnUntraced(function* (read, request)
125
147
  starts: parentsOf(unshallowed)
126
148
  };
127
149
  });
128
- export { infiniteDepth, notACommit, planShallow };
150
+ export { infiniteDepth, notACommit, planShallow, withRootsSent };
@@ -4,7 +4,6 @@ import * as Option from "effect/Option";
4
4
  import * as Cause from "effect/Cause";
5
5
  import * as Exit from "effect/Exit";
6
6
  import * as Result from "effect/Result";
7
- import * as Deferred from "effect/Deferred";
8
7
  // src/storage/single-flight.ts
9
8
  /**
10
9
  * Whether `exit` stopped for its caller alone, which another caller doesn't share: interrupted, or
@@ -20,6 +19,11 @@ const callersOwn = (exit) => Exit.isFailure(exit) && (Cause.hasInterruptsOnly(ex
20
19
  * concurrent misses"), a shared failure on one read ("fails each of 16 loads waiting on one that
21
20
  * failed"), an interrupt ("finishes the other 15 of 16 cold loads") and a spent bound ("loads a
22
21
  * pack again for a waiter, under its own calls").
22
+ *
23
+ * A run's end is a promise, not a `Deferred`: its waiters may be other requests', and each resumes
24
+ * through the promise's `then`, which it registered as it began to wait, so on a Worker it runs
25
+ * again in its own request. Completing a `Deferred` would resume them in the run's step, which
26
+ * workerd refuses (#2719).
23
27
  */
24
28
  var SingleFlight = class {
25
29
  #running = /* @__PURE__ */ new Map();
@@ -34,13 +38,15 @@ var SingleFlight = class {
34
38
  */
35
39
  run = (key, work) => Effect.uninterruptibleMask((restore) => Effect.suspend(() => {
36
40
  const running = this.#running.get(key);
37
- if (running !== void 0) return restore(Deferred.await(running));
38
- const settled = Deferred.makeUnsafe();
39
- this.#running.set(key, settled);
40
- return restore(work).pipe(Effect.asSome, Effect.onExit((exit) => Effect.suspend(() => {
41
+ if (running !== void 0) return restore(Effect.flatten(Effect.promise(() => running)));
42
+ let settle = () => void 0;
43
+ this.#running.set(key, new Promise((settled) => {
44
+ settle = settled;
45
+ }));
46
+ return restore(work).pipe(Effect.asSome, Effect.onExit((exit) => Effect.sync(() => {
41
47
  this.#running.delete(key);
42
- if (Exit.isSuccess(exit)) return Deferred.succeed(settled, exit.value);
43
- return callersOwn(exit) ? Deferred.succeed(settled, Option.none()) : Deferred.failCause(settled, exit.cause);
48
+ if (Exit.isSuccess(exit) || !callersOwn(exit)) settle(exit);
49
+ else settle(Exit.succeed(Option.none()));
44
50
  })));
45
51
  }));
46
52
  };