@ref0/git 0.20.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (378) hide show
  1. package/dist/access/private-refs.mjs +1 -1
  2. package/dist/auth/access-jwt.mjs +3 -3
  3. package/dist/auth/auth-namespace.d.mts +3 -3
  4. package/dist/auth/auth-namespace.mjs +3 -2
  5. package/dist/auth/auth.d.mts +3 -3
  6. package/dist/auth/auth.mjs +9 -8
  7. package/dist/auth/authorize.mjs +1 -1
  8. package/dist/auth/fences.d.mts +1 -1
  9. package/dist/auth/host-function.mjs +1 -1
  10. package/dist/auth/host-services.mjs +4 -6
  11. package/dist/auth/identify.d.mts +1 -1
  12. package/dist/auth/identify.mjs +6 -0
  13. package/dist/auth/token-cleanup.mjs +2 -2
  14. package/dist/auth/token-rows.mjs +6 -1
  15. package/dist/auth/token-text.mjs +1 -1
  16. package/dist/auth/tokens-base.d.mts +1 -1
  17. package/dist/auth/tokens.d.mts +1 -1
  18. package/dist/auth/tokens.mjs +1 -1
  19. package/dist/client/client.d.mts +15 -7
  20. package/dist/client/client.mjs +21 -12
  21. package/dist/client/git-http.mjs +1 -1
  22. package/dist/client/local.mjs +60 -24
  23. package/dist/client/negotiate.mjs +3 -3
  24. package/dist/client/push-upload.mjs +26 -10
  25. package/dist/client/remote.mjs +4 -3
  26. package/dist/client/run-remote-helper.d.mts +2 -2
  27. package/dist/client/run-remote-helper.mjs +6 -6
  28. package/dist/client/slice-push.d.mts +1 -1
  29. package/dist/client/transport.mjs +3 -3
  30. package/dist/contracts/blobs.d.mts +3 -3
  31. package/dist/contracts/blobs.mjs +1 -1
  32. package/dist/contracts/calls-spent.mjs +5 -33
  33. package/dist/contracts/client.d.mts +15 -14
  34. package/dist/contracts/commits.d.mts +4 -4
  35. package/dist/contracts/commits.mjs +1 -1
  36. package/dist/contracts/engine.d.mts +2 -2
  37. package/dist/contracts/events.d.mts +1 -1
  38. package/dist/contracts/events.mjs +1 -1
  39. package/dist/contracts/files.d.mts +4 -4
  40. package/dist/contracts/files.mjs +1 -1
  41. package/dist/contracts/forks.d.mts +4 -4
  42. package/dist/contracts/forks.mjs +1 -1
  43. package/dist/contracts/git-hooks.d.mts +1 -1
  44. package/dist/contracts/git.d.mts +9 -5
  45. package/dist/contracts/grants.d.mts +1 -1
  46. package/dist/contracts/merges.d.mts +1 -1
  47. package/dist/contracts/object-values.d.mts +1 -0
  48. package/dist/contracts/object-values.mjs +16 -1
  49. package/dist/contracts/objects.d.mts +20 -17
  50. package/dist/contracts/opaque.mjs +1 -1
  51. package/dist/contracts/operations.mjs +1 -1
  52. package/dist/contracts/queue.d.mts +208 -44
  53. package/dist/contracts/queue.mjs +5 -5
  54. package/dist/contracts/refs.d.mts +5 -5
  55. package/dist/contracts/refs.mjs +1 -1
  56. package/dist/contracts/remote.d.mts +3 -6
  57. package/dist/contracts/repos.d.mts +3 -3
  58. package/dist/contracts/repos.mjs +1 -1
  59. package/dist/contracts/result.d.mts +10 -7
  60. package/dist/contracts/result.mjs +8 -3
  61. package/dist/contracts/rules.d.mts +2 -2
  62. package/dist/contracts/server.d.mts +8 -10
  63. package/dist/contracts/services.d.mts +6 -9
  64. package/dist/contracts/services.mjs +1 -2
  65. package/dist/contracts/signin.d.mts +1 -1
  66. package/dist/contracts/store.d.mts +2 -2
  67. package/dist/contracts/sync.d.mts +63 -6
  68. package/dist/contracts/sync.mjs +3 -2
  69. package/dist/contracts/tags.d.mts +3 -3
  70. package/dist/contracts/tags.mjs +1 -1
  71. package/dist/contracts/tokens.d.mts +2 -2
  72. package/dist/contracts/tokens.mjs +1 -1
  73. package/dist/contracts/topics.d.mts +9 -9
  74. package/dist/contracts/trees.d.mts +4 -4
  75. package/dist/contracts/trees.mjs +1 -1
  76. package/dist/contracts/work.d.mts +4 -4
  77. package/dist/contracts/work.mjs +2 -2
  78. package/dist/core/access.d.mts +1 -1
  79. package/dist/core/ancestry.mjs +30 -34
  80. package/dist/core/{promise.mjs → call-groups.mjs} +7 -30
  81. package/dist/core/call-services.mjs +1 -1
  82. package/dist/core/events/deliver.d.mts +2 -2
  83. package/dist/core/events/deliver.mjs +3 -3
  84. package/dist/core/events/retired.mjs +1 -1
  85. package/dist/core/forks.mjs +5 -5
  86. package/dist/core/hooks/groups.mjs +2 -2
  87. package/dist/core/imports.mjs +101 -21
  88. package/dist/core/index-job.mjs +14 -9
  89. package/dist/core/index-lost.d.mts +1 -1
  90. package/dist/core/loose-tally.mjs +38 -15
  91. package/dist/core/merge-parts.d.mts +17 -4
  92. package/dist/core/merge-parts.mjs +7 -2
  93. package/dist/core/mirror-rows.mjs +31 -1
  94. package/dist/core/objects/blobs.mjs +8 -10
  95. package/dist/core/objects/files.mjs +20 -17
  96. package/dist/core/objects/objects-layer.mjs +1 -1
  97. package/dist/core/objects/peel.mjs +1 -7
  98. package/dist/core/objects/reading.mjs +19 -18
  99. package/dist/core/objects/tree-edits.mjs +1 -1
  100. package/dist/core/objects/trees.mjs +257 -58
  101. package/dist/core/objects/writing.mjs +3 -9
  102. package/dist/core/own-writes.mjs +1 -1
  103. package/dist/core/parts.d.mts +8 -1
  104. package/dist/core/parts.mjs +8 -4
  105. package/dist/core/purge.mjs +31 -18
  106. package/dist/core/push.d.mts +2 -2
  107. package/dist/core/push.mjs +125 -94
  108. package/dist/core/receipts.d.mts +2 -2
  109. package/dist/core/receipts.mjs +9 -2
  110. package/dist/core/ref-index-job.mjs +4 -4
  111. package/dist/core/ref-view.mjs +74 -31
  112. package/dist/core/refs.mjs +3 -3
  113. package/dist/core/repack.mjs +25 -30
  114. package/dist/core/repo-info.mjs +1 -1
  115. package/dist/core/repos.mjs +1 -1
  116. package/dist/core/rules/changes.mjs +18 -40
  117. package/dist/core/rules/check.mjs +6 -5
  118. package/dist/core/rules/commit-changes.mjs +3 -15
  119. package/dist/core/rules/context.d.mts +3 -3
  120. package/dist/core/rules/context.mjs +18 -14
  121. package/dist/core/rules/fetch.mjs +1 -1
  122. package/dist/core/rules/protect.mjs +30 -17
  123. package/dist/core/saved-caller-views.d.mts +1 -1
  124. package/dist/core/saved-caller-views.mjs +3 -3
  125. package/dist/core/saved-callers.d.mts +1 -1
  126. package/dist/core/saved-callers.mjs +1 -1
  127. package/dist/core/seam.d.mts +1 -2
  128. package/dist/core/view.d.mts +6 -3
  129. package/dist/core/view.mjs +11 -10
  130. package/dist/core/work.mjs +2 -2
  131. package/dist/engine/allotted-xdiff.mjs +3 -16
  132. package/dist/engine/combined.d.mts +3 -0
  133. package/dist/engine/combined.mjs +200 -185
  134. package/dist/engine/content.d.mts +2 -2
  135. package/dist/engine/content.mjs +1 -1
  136. package/dist/engine/merge.mjs +7 -9
  137. package/dist/engine/reads.d.mts +2 -2
  138. package/dist/engine/reads.mjs +22 -14
  139. package/dist/engine/xdiff.d.mts +1 -1
  140. package/dist/engine/xdiff.mjs +1 -1
  141. package/dist/event-streams/event-streams.d.mts +1 -1
  142. package/dist/event-streams/event-streams.mjs +1 -1
  143. package/dist/event-streams/stream.d.mts +2 -2
  144. package/dist/event-streams/stream.mjs +3 -3
  145. package/dist/extend.d.mts +2 -6
  146. package/dist/extend.mjs +1 -5
  147. package/dist/http/core-parts.mjs +83 -26
  148. package/dist/http/handler.mjs +54 -9
  149. package/dist/http/parts.d.mts +1 -0
  150. package/dist/http/push-upload-job.mjs +138 -24
  151. package/dist/http/push-uploads.mjs +2 -2
  152. package/dist/http/receive-pack.mjs +14 -53
  153. package/dist/http/request-snapshot.mjs +258 -0
  154. package/dist/http/upload-pack.mjs +23 -18
  155. package/dist/index.d.mts +29 -21
  156. package/dist/index.mjs +11 -2
  157. package/dist/lfs/base.d.mts +1 -1
  158. package/dist/lfs/copy.d.mts +49 -1
  159. package/dist/lfs/copy.mjs +135 -22
  160. package/dist/lfs/layer.d.mts +4 -3
  161. package/dist/lfs/layer.mjs +4 -5
  162. package/dist/lfs/locks.mjs +2 -2
  163. package/dist/lfs/objects.d.mts +1 -1
  164. package/dist/lfs/objects.mjs +3 -3
  165. package/dist/lfs/pointers.mjs +1 -1
  166. package/dist/lfs/rows.d.mts +1 -1
  167. package/dist/lfs/rows.mjs +11 -4
  168. package/dist/lfs/upkeep.mjs +40 -9
  169. package/dist/lfs/uploaded.mjs +1 -1
  170. package/dist/lfs/wire.mjs +1 -1
  171. package/dist/merges/merges.mjs +17 -2
  172. package/dist/protocol/bytes/buffers.d.mts +1 -1
  173. package/dist/protocol/bytes/buffers.mjs +1 -1
  174. package/dist/protocol/bytes/deflate.d.mts +1 -1
  175. package/dist/protocol/bytes/deflate.mjs +1 -1
  176. package/dist/protocol/bytes/inflate.d.mts +1 -1
  177. package/dist/protocol/bytes/inflate.mjs +1 -1
  178. package/dist/protocol/bytes/sha1.d.mts +1 -1
  179. package/dist/protocol/bytes/sha1.mjs +1 -1
  180. package/dist/protocol/diff/read.d.mts +2 -1
  181. package/dist/protocol/diff/read.mjs +102 -8
  182. package/dist/protocol/packs/graph.mjs +1 -1
  183. package/dist/protocol/packs/idx.d.mts +1 -1
  184. package/dist/protocol/packs/idx.mjs +1 -1
  185. package/dist/protocol/packs/parts.mjs +1 -1
  186. package/dist/protocol/packs/reader.d.mts +1 -1
  187. package/dist/protocol/packs/reader.mjs +1 -1
  188. package/dist/protocol/packs/write-error.d.mts +1 -1
  189. package/dist/protocol/packs/write-error.mjs +1 -1
  190. package/dist/protocol/packs/writer.mjs +3 -3
  191. package/dist/protocol/wire/advertisement.d.mts +1 -1
  192. package/dist/protocol/wire/advertisement.mjs +3 -2
  193. package/dist/protocol/wire/fetch.d.mts +1 -1
  194. package/dist/protocol/wire/fetch.mjs +1 -1
  195. package/dist/protocol/wire/lines.d.mts +9 -1
  196. package/dist/protocol/wire/lines.mjs +28 -1
  197. package/dist/protocol/wire/push-uploads.mjs +10 -7
  198. package/dist/protocol/wire/receive-pack.d.mts +1 -1
  199. package/dist/protocol/wire/receive-pack.mjs +1 -1
  200. package/dist/protocol/wire/report-status.d.mts +1 -1
  201. package/dist/protocol/wire/report-status.mjs +1 -1
  202. package/dist/protocol/wire/v2.d.mts +1 -1
  203. package/dist/protocol/wire/v2.mjs +1 -1
  204. package/dist/queue/advance.mjs +31 -24
  205. package/dist/queue/base.d.mts +5 -3
  206. package/dist/queue/calls.mjs +5 -5
  207. package/dist/queue/commit.mjs +1 -1
  208. package/dist/queue/host.d.mts +1 -1
  209. package/dist/queue/layer.d.mts +0 -1
  210. package/dist/queue/layer.mjs +9 -5
  211. package/dist/queue/schedule.mjs +1 -1
  212. package/dist/queue/search.mjs +1 -1
  213. package/dist/queue/state.mjs +1 -1
  214. package/dist/queue/trim.mjs +2 -2
  215. package/dist/rest/client.d.mts +1 -1
  216. package/dist/rest/client.mjs +6 -6
  217. package/dist/rest/errors.mjs +1 -1
  218. package/dist/rest/handler.mjs +2 -2
  219. package/dist/rest/handlers.mjs +16 -6
  220. package/dist/rest/layer.mjs +1 -1
  221. package/dist/rest/listen.mjs +2 -2
  222. package/dist/rest/refs.mjs +1 -1
  223. package/dist/server/edge.mjs +27 -3
  224. package/dist/server/git-layer.d.mts +1 -2
  225. package/dist/server/git-layer.mjs +4 -5
  226. package/dist/server/lifecycle.mjs +1 -1
  227. package/dist/server/registry.mjs +2 -8
  228. package/dist/server/server.mjs +62 -43
  229. package/dist/signin/context.d.mts +1 -1
  230. package/dist/signin/context.mjs +1 -1
  231. package/dist/signin/forms.mjs +1 -1
  232. package/dist/signin/grants.d.mts +2 -2
  233. package/dist/signin/grants.mjs +1 -1
  234. package/dist/signin/wire.mjs +1 -1
  235. package/dist/storage/allotted.mjs +4 -9
  236. package/dist/storage/batch-upkeep.mjs +31 -12
  237. package/dist/storage/batches.d.mts +2 -3
  238. package/dist/storage/batches.mjs +52 -49
  239. package/dist/storage/budget.mjs +23 -1
  240. package/dist/storage/calls.d.mts +1 -1
  241. package/dist/storage/calls.mjs +41 -43
  242. package/dist/storage/charged-cache.mjs +180 -0
  243. package/dist/storage/chunks.d.mts +3 -3
  244. package/dist/storage/chunks.mjs +121 -8
  245. package/dist/storage/counted-bucket.mjs +32 -10
  246. package/dist/storage/fetch-row-cache.d.mts +6 -0
  247. package/dist/storage/fetch-row-cache.mjs +211 -0
  248. package/dist/storage/fetch.d.mts +1 -0
  249. package/dist/storage/fetch.mjs +54 -242
  250. package/dist/storage/held-types.d.mts +0 -1
  251. package/dist/storage/host-bucket.mjs +9 -4
  252. package/dist/storage/index-bitmaps.mjs +77 -49
  253. package/dist/storage/index-build.d.mts +2 -3
  254. package/dist/storage/index-build.mjs +248 -48
  255. package/dist/storage/index-fetch.d.mts +3 -1
  256. package/dist/storage/index-fetch.mjs +60 -21
  257. package/dist/storage/index-graph.mjs +1 -1
  258. package/dist/storage/index-layers.mjs +55 -25
  259. package/dist/storage/index-reach.mjs +15 -22
  260. package/dist/storage/index-whole.d.mts +7 -0
  261. package/dist/storage/index-whole.mjs +145 -37
  262. package/dist/storage/largest-files.mjs +1 -7
  263. package/dist/storage/layout.mjs +17 -1
  264. package/dist/storage/lfs-pointers.mjs +1 -6
  265. package/dist/storage/link-join.mjs +55 -16
  266. package/dist/storage/list-source.d.mts +7 -0
  267. package/dist/storage/list-source.mjs +288 -0
  268. package/dist/storage/loose.d.mts +8 -8
  269. package/dist/storage/loose.mjs +157 -91
  270. package/dist/storage/memory-budget.mjs +226 -22
  271. package/dist/storage/merge-cut.mjs +9 -6
  272. package/dist/storage/merge-fence.mjs +1 -1
  273. package/dist/storage/merge-row.mjs +1 -1
  274. package/dist/storage/merge.d.mts +2 -3
  275. package/dist/storage/merge.mjs +2 -2
  276. package/dist/storage/object-rows.d.mts +3 -3
  277. package/dist/storage/object-rows.mjs +179 -38
  278. package/dist/storage/pack-order.mjs +97 -44
  279. package/dist/storage/pack-ranges.mjs +44 -16
  280. package/dist/storage/pack-reads.d.mts +5 -3
  281. package/dist/storage/pack-reads.mjs +236 -72
  282. package/dist/storage/pack-receive.d.mts +1 -2
  283. package/dist/storage/pack-receive.mjs +21 -17
  284. package/dist/storage/packs.d.mts +1 -1
  285. package/dist/storage/packs.mjs +477 -116
  286. package/dist/storage/placed-reads.mjs +33 -16
  287. package/dist/storage/prune-seen.mjs +1 -1
  288. package/dist/storage/prune-walk.mjs +1 -1
  289. package/dist/storage/prune.mjs +4 -31
  290. package/dist/storage/push-allotment.mjs +26 -14
  291. package/dist/storage/push-uploads.mjs +195 -57
  292. package/dist/storage/pushed-commits.mjs +20 -1
  293. package/dist/storage/quarantine.d.mts +2 -3
  294. package/dist/storage/range-cache.mjs +175 -40
  295. package/dist/storage/raw-ids.mjs +39 -10
  296. package/dist/storage/ready.d.mts +2 -3
  297. package/dist/storage/ready.mjs +114 -38
  298. package/dist/storage/receive-bounds.mjs +31 -9
  299. package/dist/storage/receive-cache.d.mts +7 -0
  300. package/dist/storage/receive-cache.mjs +147 -0
  301. package/dist/storage/receive-files.mjs +1 -1
  302. package/dist/storage/receive-links.mjs +1 -1
  303. package/dist/storage/receive-state.d.mts +2 -2
  304. package/dist/storage/receive-state.mjs +6 -8
  305. package/dist/storage/receive-steps.d.mts +20 -0
  306. package/dist/storage/receive-steps.mjs +298 -13
  307. package/dist/storage/repack-backlog.mjs +1 -6
  308. package/dist/storage/repack-contained.mjs +2 -2
  309. package/dist/storage/repack-job.mjs +1 -1
  310. package/dist/storage/repack.d.mts +2 -3
  311. package/dist/storage/repack.mjs +54 -9
  312. package/dist/storage/request-cache.mjs +57 -0
  313. package/dist/storage/roots.mjs +1 -24
  314. package/dist/storage/rows.d.mts +2 -2
  315. package/dist/storage/rows.mjs +1 -1
  316. package/dist/storage/runs.d.mts +2 -2
  317. package/dist/storage/runs.mjs +1 -1
  318. package/dist/storage/send-list.mjs +62 -25
  319. package/dist/storage/stream-whole.mjs +84 -63
  320. package/dist/storage/swap-walk.mjs +1 -1
  321. package/dist/storage/unpack.mjs +878 -450
  322. package/dist/storage/visible.mjs +110 -32
  323. package/dist/storage/walk.mjs +1 -0
  324. package/dist/storage/wants.mjs +22 -58
  325. package/dist/store/call-count.d.mts +2 -2
  326. package/dist/store/call-count.mjs +24 -11
  327. package/dist/store/catalogue.d.mts +1 -1
  328. package/dist/store/catalogue.mjs +19 -7
  329. package/dist/store/crossing.mjs +1 -7
  330. package/dist/store/cursor-seal.d.mts +1 -1
  331. package/dist/store/cursor-seal.mjs +1 -1
  332. package/dist/store/door.mjs +9 -4
  333. package/dist/store/errors.d.mts +2 -2
  334. package/dist/store/errors.mjs +107 -19
  335. package/dist/store/git-store.mjs +7 -2
  336. package/dist/store/job-try.mjs +90 -9
  337. package/dist/store/list-job.mjs +10 -34
  338. package/dist/store/outbox.d.mts +2 -2
  339. package/dist/store/outbox.mjs +2 -2
  340. package/dist/store/queue-jobs.mjs +6 -12
  341. package/dist/store/records.d.mts +2 -2
  342. package/dist/store/records.mjs +2 -2
  343. package/dist/store/ref-rows.d.mts +2 -2
  344. package/dist/store/ref-rows.mjs +2 -2
  345. package/dist/store/repo-record.d.mts +2 -2
  346. package/dist/store/repo-record.mjs +3 -3
  347. package/dist/store/request-snapshot.mjs +5 -0
  348. package/dist/store/reservations.mjs +2 -2
  349. package/dist/store/topic-jobs.mjs +5 -11
  350. package/dist/sync/bound.d.mts +3 -3
  351. package/dist/sync/bound.mjs +10 -7
  352. package/dist/sync/github.mjs +65 -67
  353. package/dist/sync/http.mjs +1 -1
  354. package/dist/sync/import.mjs +201 -66
  355. package/dist/sync/layer.d.mts +1 -1
  356. package/dist/sync/layer.mjs +6 -6
  357. package/dist/sync/lfs-batch.mjs +1 -1
  358. package/dist/sync/lfs-copy.mjs +175 -15
  359. package/dist/sync/mirror.mjs +5 -10
  360. package/dist/sync/said.mjs +1 -1
  361. package/dist/sync/step.mjs +268 -86
  362. package/dist/sync/tries.mjs +25 -6
  363. package/dist/sync.d.mts +2 -2
  364. package/dist/sync.mjs +2 -2
  365. package/dist/topics/advance.mjs +3 -3
  366. package/dist/topics/calls.mjs +1 -1
  367. package/dist/topics/layer.d.mts +15 -14
  368. package/dist/topics/members.mjs +1 -1
  369. package/dist/topics/topic.mjs +1 -1
  370. package/package.json +3 -13
  371. package/dist/auth/helpers.mjs +0 -17
  372. package/dist/auth.d.mts +0 -5
  373. package/dist/auth.mjs +0 -5
  374. package/dist/core/rules/commit-changes.d.mts +0 -12
  375. package/dist/effect.d.mts +0 -9
  376. package/dist/effect.mjs +0 -7
  377. package/dist/server/joined.d.mts +0 -70
  378. package/dist/server/joined.mjs +0 -41
@@ -27,6 +27,12 @@ const objectCollections = {
27
27
  */
28
28
  stagedSizes: "stagedSizes",
29
29
  /**
30
+ * Spilled pending delta instructions of a staged push, by `<batch>/<seq>/<part>`: `{ data }`,
31
+ * parts of at most 768,000 raw bytes as base64, never object rows, deleted by promotion's last
32
+ * page or an abandoned batch's sweep (#2521).
33
+ */
34
+ stagedDeltas: "stagedDeltas",
35
+ /**
30
36
  * A chunked object's bytes, by `<batch>/<part>/<nnnn>`: `{ data }`, `chunkRawBytes` of them as
31
37
  * base64, named by the object's `ChunkedRow`. They stay under the batch that staged them.
32
38
  */
@@ -62,6 +68,16 @@ const indexRowKey = {
62
68
  collection: objectCollections.index,
63
69
  id: "current"
64
70
  };
71
+ /** The last prune pass's row, `pass`: when its last step ran. */
72
+ const prunePassKey = {
73
+ collection: objectCollections.prune,
74
+ id: "pass"
75
+ };
76
+ /** A ref-deletion's prune-clear row, `cleared`: set when a push deletes or rewinds a ref. */
77
+ const pruneClearedKey = {
78
+ collection: objectCollections.prune,
79
+ id: "cleared"
80
+ };
65
81
  /** Where one repo's index files are. */
66
82
  const indexPrefix = (repo) => `index/${repo}/`;
67
83
  /** One build's files: a layer's, since each layer of an index is a build of its own. */
@@ -125,4 +141,4 @@ const markerPrefix = (pack) => `packs/${pack}/by/`;
125
141
  * a host's ID can be made again after a delete, and the new repo would keep the old one's bytes.
126
142
  */
127
143
  const markerKey = (pack, repo) => `${markerPrefix(pack)}${repo}`;
128
- export { indexFiles, indexPrefix, indexRowKey, isPackId, markerKey, markerPrefix, newPackId, objectCollections, packFileKeys, packFiles, receivePrefix, runKey, runsPrefix, stepKey };
144
+ export { indexFiles, indexPrefix, indexRowKey, isPackId, markerKey, markerPrefix, newPackId, objectCollections, packFileKeys, packFiles, pruneClearedKey, prunePassKey, receivePrefix, runKey, runsPrefix, stepKey };
@@ -218,9 +218,4 @@ const pointersOfRecord = (record) => {
218
218
  if (!Number.isInteger(count) || count > 1024) return void 0;
219
219
  return LfsPointers.made(count, [record]);
220
220
  };
221
- /** The pointers among a receive's whole objects, found by `pointers`. */
222
- const pointersOfObjects = /* @__PURE__ */ Effect.fnUntraced(function* (objects, pointers = new ReceivedPointers()) {
223
- for (const object of objects) if (object.type === "blob") yield* pointers.add(object.oid, object.bytes);
224
- return pointers.finish();
225
- });
226
- export { ReceivedPointers, lfsOidAt, lfsPointers, lfsPointersMost, lfsSizeAt, noLfsPointers, pageEntries, pointerSizeMost, pointersOfBlob, pointersOfObjects, pointersOfRecord, pointersRecords };
221
+ export { ReceivedPointers, lfsOidAt, lfsPointers, lfsPointersMost, lfsSizeAt, noLfsPointers, pageEntries, pointerSizeMost, pointersOfBlob, pointersOfRecord, pointersRecords };
@@ -2,7 +2,7 @@ import { gitError } from "../contracts/result.mjs";
2
2
  import { hexOf } from "../protocol/bytes/hex.mjs";
3
3
  import { emptyTree } from "../protocol/objects/object.mjs";
4
4
  import { oidBytes } from "../protocol/packs/idx.mjs";
5
- import { compareIds, orderById } from "./raw-ids.mjs";
5
+ import { compareIds, compareIdsFrom, orderById } from "./raw-ids.mjs";
6
6
  import { rangeRanks } from "./pack-ranges.mjs";
7
7
  import * as Effect from "effect/Effect";
8
8
  // src/storage/link-join.ts
@@ -30,19 +30,35 @@ const lost = (message) => gitError("DATA_LOSS", message);
30
30
  const emptyTreeId = oidBytes(emptyTree);
31
31
  /**
32
32
  * Fills `targets` for the links in `order` that `ids` and `positions` hold: `ids`, ascending,
33
- * the source's from rank `from`, and each one's position. A link an earlier source filled at a
34
- * lower position is left.
33
+ * the source's from rank `from`, and each one's position offset by `base`. A link an earlier
34
+ * source filled at a lower position is left.
35
35
  */
36
- const mergeChunk = (links, order, start, targets, ids, count, position) => {
36
+ const mergeChunk = (links, order, start, targets, ids, count, positions, base) => {
37
37
  let link = start;
38
38
  let rank = 0;
39
+ if (link >= order.length || count === 0) return link;
40
+ let rOff = 0;
41
+ let r0 = ids[0] ?? 0;
42
+ let r1 = ids[1] ?? 0;
39
43
  while (link < order.length && rank < count) {
40
44
  const at = order[link] ?? 0;
41
- const compared = compareIds(links, at * 20, ids, rank * 20);
45
+ const lOff = at * 20;
46
+ let compared = (links[lOff] ?? 0) - r0;
47
+ if (compared === 0) {
48
+ compared = (links[lOff + 1] ?? 0) - r1;
49
+ if (compared === 0) compared = compareIdsFrom(links, lOff, ids, rOff, 2);
50
+ }
42
51
  if (compared < 0) link += 1;
43
- else if (compared > 0) rank += 1;
44
- else {
45
- targets[at] = Math.min(targets[at] ?? 4294967295, position(rank));
52
+ else if (compared > 0) {
53
+ rank += 1;
54
+ if (rank < count) {
55
+ rOff = rank * 20;
56
+ r0 = ids[rOff] ?? 0;
57
+ r1 = ids[rOff + 1] ?? 0;
58
+ }
59
+ } else {
60
+ const pos = base + (positions[rank] ?? 0);
61
+ if (pos < (targets[at] ?? 4294967295)) targets[at] = pos;
46
62
  link += 1;
47
63
  }
48
64
  }
@@ -51,14 +67,37 @@ const mergeChunk = (links, order, start, targets, ids, count, position) => {
51
67
  /** Whether `ids`' `count` IDs ascend strictly, after `previous`'s last, if any. */
52
68
  const ascending = (ids, count, previous) => {
53
69
  if (previous !== void 0 && count > 0 && compareIds(previous, 0, ids, 0) >= 0) return false;
54
- for (let rank = 1; rank < count; rank += 1) if (compareIds(ids, (rank - 1) * 20, ids, rank * 20) >= 0) return false;
70
+ for (let rank = 1; rank < count; rank += 1) {
71
+ const prevOff = (rank - 1) * 20;
72
+ const curOff = rank * 20;
73
+ const diff0 = (ids[prevOff] ?? 0) - (ids[curOff] ?? 0);
74
+ if (diff0 > 0) return false;
75
+ if (diff0 === 0 && compareIdsFrom(ids, prevOff, ids, curOff, 1) >= 0) return false;
76
+ }
55
77
  return true;
56
78
  };
57
79
  /** The first link in `order` at or past `link` whose ID is at or past `ids`' first. */
58
80
  const skipBelow = (links, order, link, ids) => {
59
- let at = link;
60
- while (at < order.length && compareIds(links, (order[at] ?? 0) * 20, ids, 0) < 0) at += 1;
61
- return at;
81
+ if (link >= order.length) return link;
82
+ const first0 = ids[0] ?? 0;
83
+ const first1 = ids[1] ?? 0;
84
+ const cmpAt = (at) => {
85
+ const off = (order[at] ?? 0) * 20;
86
+ const d0 = (links[off] ?? 0) - first0;
87
+ if (d0 !== 0) return d0;
88
+ const d1 = (links[off + 1] ?? 0) - first1;
89
+ if (d1 !== 0) return d1;
90
+ return compareIdsFrom(links, off, ids, 0, 2);
91
+ };
92
+ if (cmpAt(link) >= 0) return link;
93
+ let low = link + 1;
94
+ let high = order.length;
95
+ while (low < high) {
96
+ const middle = low + high >>> 1;
97
+ if (cmpAt(middle) < 0) low = middle + 1;
98
+ else high = middle;
99
+ }
100
+ return low;
62
101
  };
63
102
  /**
64
103
  * Chunk `rank`'s `count` IDs of `ranges`, checked to ascend after `previous`, merged by `merge`,
@@ -94,13 +133,13 @@ const joinIds = /* @__PURE__ */ Effect.fnUntraced(function* (ids, size, packs, r
94
133
  const last = chunk.subarray((count - 1) * 20);
95
134
  if (at >= order.length || compareIds(ids, (order[at] ?? 0) * 20, last, 0) > 0) return at;
96
135
  const positions = yield* ranges.positions(rank, count);
97
- return mergeChunk(ids, order, at, targets, chunk, count, (place) => ranges.base + (positions[place] ?? 0));
136
+ return mergeChunk(ids, order, at, targets, chunk, count, positions, ranges.base);
98
137
  }));
99
138
  previous = step.last;
100
139
  link = step.merged;
101
140
  }
102
141
  }
103
- if (region !== void 0 && region.positions.length > 0) mergeChunk(ids, order, 0, targets, region.ids, region.positions.length, (at) => region.positions[at] ?? 0);
142
+ if (region !== void 0 && region.positions.length > 0) mergeChunk(ids, order, 0, targets, region.ids, region.positions.length, region.positions, 0);
104
143
  return targets;
105
144
  });
106
145
  /**
@@ -116,12 +155,12 @@ const joinAlike = /* @__PURE__ */ Effect.fnUntraced(function* (ids, size, packs,
116
155
  for (let rank = 0; rank < ranges.count; rank += rangeRanks) {
117
156
  const count = Math.min(rangeRanks, ranges.count - rank);
118
157
  const from = link;
119
- const step = yield* chunkStep(ranges, rank, count, previous, (chunk) => Effect.map(ranges.positions(rank, count), (positions) => mergeChunk(ids, order, skipBelow(ids, order, from, chunk), targets, chunk, count, (at) => ranges.base + (positions[at] ?? 0))));
158
+ const step = yield* chunkStep(ranges, rank, count, previous, (chunk) => Effect.map(ranges.positions(rank, count), (positions) => mergeChunk(ids, order, skipBelow(ids, order, from, chunk), targets, chunk, count, positions, ranges.base)));
120
159
  previous = step.last;
121
160
  link = step.merged;
122
161
  }
123
162
  }
124
- if (region !== void 0 && region.positions.length > 0) mergeChunk(ids, order, 0, targets, region.ids, region.positions.length, (at) => region.positions[at] ?? 0);
163
+ if (region !== void 0 && region.positions.length > 0) mergeChunk(ids, order, 0, targets, region.ids, region.positions.length, region.positions, 0);
125
164
  return targets;
126
165
  });
127
166
  /**
@@ -0,0 +1,7 @@
1
+ import "../contracts/result.mjs";
2
+ import "../protocol/packs/writer.mjs";
3
+ import "./fetch.mjs";
4
+ import "./pack-reads.mjs";
5
+ import "./send-list.mjs";
6
+ import "./walk.mjs";
7
+ import "effect/Effect";
@@ -0,0 +1,288 @@
1
+ import { gitError } from "../contracts/result.mjs";
2
+ import { hexOf } from "../protocol/bytes/hex.mjs";
3
+ import { isSet } from "./bits.mjs";
4
+ import { checkedCopy, gone, rangeBytes } from "./fetch.mjs";
5
+ import { typeOfCode } from "./index-files.mjs";
6
+ import "./pack-reads.mjs";
7
+ import { ListCursor, sizeOf } from "./send-list.mjs";
8
+ import * as Effect from "effect/Effect";
9
+ import * as Fiber from "effect/Fiber";
10
+ // src/storage/list-source.ts
11
+ /** A pack entry's type, in its header's first byte: 1 to 4 for the kinds, 7 for a `REF_DELTA`. */
12
+ const entryTypes = {
13
+ commit: 1,
14
+ tree: 2,
15
+ blob: 3,
16
+ tag: 4
17
+ };
18
+ const refDeltaType = 7;
19
+ /**
20
+ * `copy`, refused with `DATA_LOSS` before its first range is handed over when its header's type
21
+ * isn't what the index says it is: `kind` for a whole entry, a `REF_DELTA` for a delta. A copied
22
+ * delta's header must name `base` too, the ID at the base position its `.bases` row gives,
23
+ * checked before the range that completes the header's ID is handed over.
24
+ */
25
+ const typeChecked = (copy, entry, type, base) => {
26
+ const wrong = gitError("DATA_LOSS", `Object ${entry.oid} in pack ${entry.pack.id} isn't the entry the index's .types and .bases say`);
27
+ let head = /* @__PURE__ */ new Uint8Array(0);
28
+ let checked = true;
29
+ /** The base ID a `REF_DELTA`'s header names, past its type and size, once `bytes` hold it. */
30
+ const named = (bytes) => {
31
+ let at = 1;
32
+ while (at <= bytes.byteLength && ((bytes[at - 1] ?? 0) & 128) !== 0) at += 1;
33
+ return bytes.byteLength < at + 20 ? void 0 : hexOf(bytes.subarray(at, at + 20));
34
+ };
35
+ return {
36
+ bytes: copy.bytes,
37
+ read: (at) => Effect.flatMap(copy.read(at), (bytes) => {
38
+ if (at === 0 && ((bytes[0] ?? 0) >> 4 & 7) !== type) return Effect.fail(wrong);
39
+ if (at === 0) {
40
+ head = /* @__PURE__ */ new Uint8Array(0);
41
+ checked = base === void 0;
42
+ }
43
+ if (checked) return Effect.succeed(bytes);
44
+ head = Uint8Array.from([...head, ...bytes.subarray(0, 64 - head.byteLength)]);
45
+ const found = named(head);
46
+ if (found === void 0 && at + bytes.byteLength < copy.bytes) return Effect.succeed(bytes);
47
+ checked = true;
48
+ return found === base ? Effect.succeed(bytes) : Effect.fail(wrong);
49
+ })
50
+ };
51
+ };
52
+ /**
53
+ * The whole objects of `list` the writer reads at once from `cursor` on, as `plannedSource` reads
54
+ * its windows: those it doesn't copy, up to `windowBytes` of them or the one.
55
+ */
56
+ const windowFrom = (cursor) => {
57
+ const { list } = cursor;
58
+ const window = [];
59
+ let bytes = 0;
60
+ for (const at = cursor.copy(); !at.done; at.next()) {
61
+ if (isSet(list.copied, at.ordinal)) continue;
62
+ const size = sizeOf(list, at.ordinal);
63
+ if (window.length > 0 && bytes + size > 1048576) break;
64
+ window.push({
65
+ ordinal: at.ordinal,
66
+ position: at.position,
67
+ pack: at.inPack
68
+ });
69
+ bytes += size;
70
+ }
71
+ return window;
72
+ };
73
+ /**
74
+ * The stored entries the writer reads through the reader's blocks for `list`, in its order, as
75
+ * `writerCalls` forecasts a plan's: for each window of objects written whole, each one's entry and
76
+ * the bases down its chain, as the reader resolves it. Its copies are read through `listRuns`.
77
+ * None is held past `PackBlocks.gets`' count.
78
+ */
79
+ function* listReads(list) {
80
+ let windowEnd = 0;
81
+ for (const cursor = new ListCursor(list); !cursor.done; cursor.next()) {
82
+ if (isSet(list.copied, cursor.ordinal) || cursor.ordinal < windowEnd) continue;
83
+ const window = windowFrom(cursor);
84
+ windowEnd = (window.at(-1)?.ordinal ?? cursor.ordinal) + 1;
85
+ 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);
86
+ }
87
+ }
88
+ /**
89
+ * `list`'s copies as runs, in its order: each copy joins the run before it when it's in the same
90
+ * pack and starts at most `blockBytes` past that run's end, the gap read and let go. So each run
91
+ * starts in a block no run before it reads, and runs are never more gets than the blocks the
92
+ * copies' bytes span. A full clone of one pack is one run (#647).
93
+ */
94
+ function* listRuns(list) {
95
+ let run;
96
+ let pack = -1;
97
+ for (const cursor = new ListCursor(list); !cursor.done; cursor.next()) {
98
+ if (!isSet(list.copied, cursor.ordinal)) continue;
99
+ const entry = cursor.inPack.at(cursor.position);
100
+ const end = entry.offset + entry.bytes;
101
+ if (run !== void 0 && cursor.pack === pack && entry.offset <= run.to + 1048576) {
102
+ run.to = end;
103
+ run.last = cursor.ordinal;
104
+ continue;
105
+ }
106
+ if (run !== void 0) yield run;
107
+ pack = cursor.pack;
108
+ run = {
109
+ pack: entry.pack,
110
+ from: entry.offset,
111
+ to: end,
112
+ first: cursor.ordinal,
113
+ last: cursor.ordinal
114
+ };
115
+ }
116
+ if (run !== void 0) yield run;
117
+ }
118
+ /**
119
+ * The bucket gets the writer makes for `list`'s objects, with no I/O: one a run of its copies, and
120
+ * its windows' reads as `PackBlocks.gets` forecasts them, as `writerCalls` forecasts a plan's
121
+ * (#522).
122
+ */
123
+ const listCalls = (stored, list) => {
124
+ let runs = 0;
125
+ for (const _run of listRuns(list)) runs += 1;
126
+ return {
127
+ bucket: runs + stored.gets(listReads(list)),
128
+ store: 0
129
+ };
130
+ };
131
+ /**
132
+ * `list`'s objects as the writer takes them, a page at a time: each one's ID, kind and size from
133
+ * the index and the list, held for its page alone. A copy is its stored entry, read through its
134
+ * run's one ranged get, its CRC-32 checked as it's read and its type against the index's; the rest
135
+ * are read whole a window at a time, as `plannedSource` reads them. Every read is a listed pack's,
136
+ * so the store is read no more. A second write, from the first object again, reads its runs again.
137
+ */
138
+ const listSource = (reads, list) => {
139
+ let cursor = new ListCursor(list);
140
+ let paged = /* @__PURE__ */ new Map();
141
+ let window = /* @__PURE__ */ new Map();
142
+ let runs = listRuns(list);
143
+ let queued = [];
144
+ let run;
145
+ let reading;
146
+ let readingFiber;
147
+ const closeOne = (open, fiber) => Effect.suspend(() => {
148
+ const stop = open?.close ?? Effect.void;
149
+ return fiber === void 0 ? stop : Effect.andThen(stop, Effect.andThen(Fiber.interrupt(fiber), stop));
150
+ });
151
+ const closeActive = Effect.suspend(() => {
152
+ const open = reading;
153
+ const fiber = readingFiber;
154
+ reading = void 0;
155
+ readingFiber = void 0;
156
+ return closeOne(open, fiber);
157
+ });
158
+ const closeRun = Effect.suspend(() => {
159
+ const open = reading;
160
+ const fiber = readingFiber;
161
+ const pending = queued;
162
+ reading = void 0;
163
+ readingFiber = void 0;
164
+ queued = [];
165
+ return Effect.all([closeOne(open, fiber), ...pending.map((entry) => closeOne(entry.reading, entry.fiber))], {
166
+ concurrency: "unbounded",
167
+ discard: true
168
+ });
169
+ });
170
+ const fillWindow = Effect.fnUntraced(function* (stored) {
171
+ const limit = Math.max(0, 5 - (run !== void 0 || reading !== void 0 ? 1 : 0));
172
+ while (queued.length < limit) {
173
+ const next = runs.next();
174
+ if (next.done === true) break;
175
+ const nextRun = next.value;
176
+ if (stored.kept(nextRun.pack, nextRun.from)) {
177
+ queued.push({
178
+ run: nextRun,
179
+ reading: void 0,
180
+ fiber: void 0
181
+ });
182
+ continue;
183
+ }
184
+ const opened = stored.run(nextRun.pack, nextRun.from, nextRun.to);
185
+ const fiber = yield* Effect.forkChild(opened.start);
186
+ queued.push({
187
+ run: nextRun,
188
+ reading: opened,
189
+ fiber
190
+ });
191
+ }
192
+ });
193
+ const load = Effect.fnUntraced(function* (from) {
194
+ const at = windowFrom(from).map(({ pack, position }) => {
195
+ const { oid, offset } = pack.at(position);
196
+ return {
197
+ oid,
198
+ lookup: pack.lookup,
199
+ offset
200
+ };
201
+ });
202
+ if (reads.heldAt !== void 0) window = yield* reads.heldAt(at);
203
+ });
204
+ /**
205
+ * The copy at `ordinal`'s bytes from `at`, through its run: independent runs open in parallel up
206
+ * to `fetchPacksAtOnce` as the writer streams, and another from the entry on only for a read
207
+ * behind the one open.
208
+ */
209
+ const copied = Effect.fnUntraced(function* (stored, ordinal, entry, at) {
210
+ while (run === void 0 || run.last < ordinal) {
211
+ yield* closeActive;
212
+ run = void 0;
213
+ yield* fillWindow(stored);
214
+ const next = queued.shift();
215
+ if (next === void 0) return yield* Effect.die(/* @__PURE__ */ new Error(`no run of the list holds its copy ${ordinal}`));
216
+ run = next.run;
217
+ reading = next.reading;
218
+ readingFiber = next.fiber;
219
+ yield* fillWindow(stored);
220
+ }
221
+ if (ordinal < run.first) return yield* Effect.die(/* @__PURE__ */ new Error(`the list's copy ${ordinal} is read before its run`));
222
+ const offset = entry.offset + at;
223
+ const open = reading !== void 0 && reading.reads(offset);
224
+ if (!open && stored.kept(entry.pack, offset)) return yield* stored.read(entry, at);
225
+ if (reading === void 0 || !open) {
226
+ yield* closeActive;
227
+ reading = stored.run(run.pack, offset, run.to);
228
+ }
229
+ return yield* reading.read(offset, entry.offset + entry.bytes);
230
+ });
231
+ return {
232
+ count: list.count,
233
+ page: Effect.fnUntraced(function* (from, most) {
234
+ if (from === 0 && cursor.ordinal > 0) {
235
+ yield* closeRun;
236
+ cursor = new ListCursor(list);
237
+ window = /* @__PURE__ */ new Map();
238
+ runs = listRuns(list);
239
+ run = void 0;
240
+ }
241
+ if (from !== cursor.ordinal) return yield* Effect.die(/* @__PURE__ */ new Error(`the list pages in order: ${from} isn't its next`));
242
+ const page = [];
243
+ paged = /* @__PURE__ */ new Map();
244
+ for (; page.length < most && !cursor.done; cursor.next()) {
245
+ const { oid } = cursor.inPack.at(cursor.position);
246
+ const kind = typeOfCode[list.kinds[cursor.ordinal] ?? 0] ?? "blob";
247
+ const size = sizeOf(list, cursor.ordinal);
248
+ page.push(isSet(list.copied, cursor.ordinal) ? {
249
+ oid,
250
+ kind,
251
+ storedBytes: size
252
+ } : {
253
+ oid,
254
+ kind,
255
+ size
256
+ });
257
+ paged.set(oid, cursor.copy());
258
+ }
259
+ return page;
260
+ }),
261
+ read: Effect.fnUntraced(function* (object, at) {
262
+ const placed = paged.get(object.oid);
263
+ if (!window.has(object.oid) && placed !== void 0) yield* load(placed);
264
+ const whole = window.get(object.oid);
265
+ if (whole === void 0) return yield* Effect.fail(gone(object.oid));
266
+ const bytes = whole.bytes.slice(at, at + rangeBytes);
267
+ if (at + bytes.byteLength >= whole.bytes.byteLength) {
268
+ const left = new Map(window);
269
+ left.delete(object.oid);
270
+ window = left;
271
+ }
272
+ return bytes;
273
+ }),
274
+ end: closeRun,
275
+ close: closeRun,
276
+ copy: (object) => {
277
+ const placed = paged.get(object.oid);
278
+ const { stored } = reads;
279
+ if (placed === void 0 || stored === void 0 || !isSet(list.copied, placed.ordinal)) return void 0;
280
+ const entry = placed.inPack.at(placed.position);
281
+ const copy = checkedCopy(entry, (at) => copied(stored, placed.ordinal, entry, at));
282
+ if (!isSet(list.deltas, placed.ordinal)) return typeChecked(copy, entry, entryTypes[object.kind]);
283
+ const base = placed.inPack.at(list.bases[placed.ordinal] ?? 0).oid;
284
+ return typeChecked(copy, entry, refDeltaType, base);
285
+ }
286
+ };
287
+ };
288
+ export { listCalls, listRuns, listSource };
@@ -1,10 +1,10 @@
1
1
  import { ObjectsFactory } from "../contracts/objects.mjs";
2
2
  /**
3
- * What one push may carry into `loose()` storage: its `objects`, the `bytes` of its rows as JSON,
4
- * which its commit holds, and the bytes of each object, `fileBytes`, one past a row kept as chunks.
3
+ * What one push may carry into `loose()` storage: its `objects`, its pack's `bytes` on the wire
4
+ * before inflation, and the bytes of each object, `fileBytes`, one past a row kept as chunks.
5
5
  */
6
6
  export declare const looseLimits: {
7
- readonly objects: 10000;
7
+ readonly objects: 50000;
8
8
  readonly bytes: number;
9
9
  readonly fileBytes: number;
10
10
  };
@@ -16,10 +16,10 @@ export interface LooseLimits {
16
16
  }
17
17
  /**
18
18
  * `loose()`: each object a row of the repo's scope, with no bucket. A push of more than
19
- * `options.objects` objects, 10,000 by default, is refused whole, and so is one whose rows pass
20
- * `options.bytes`, one commit's 8 MiB by default, of rows within one row's 1 MiB. An object past
21
- * one row is kept as chunk rows, to `options.fileBytes`, 32 MiB by default, and one past that is
22
- * refused as `object-too-large`. A whole push names its roots and the rows it links to, so it can
23
- * keep a repo's whole-clone mark. The client's default.
19
+ * `options.objects` objects, 50,000 by default, is refused whole, and so is one whose pack passes
20
+ * `options.bytes`, 64 MiB on the wire by default, before inflation. An object past one row is kept
21
+ * as chunk rows, to `options.fileBytes`, 32 MiB by default, and one past that is refused as
22
+ * `object-too-large`. A whole inline push names its roots and the rows it links to, so it can keep
23
+ * a repo's whole-clone mark. The client's default.
24
24
  */
25
25
  export declare const loose: (options?: LooseLimits) => ObjectsFactory<false>;