@ref0/git 0.14.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (492) hide show
  1. package/dist/access/private-refs.mjs +1 -1
  2. package/dist/auth/access-jwt.mjs +4 -4
  3. package/dist/auth/auth-namespace.d.mts +3 -3
  4. package/dist/auth/auth-namespace.mjs +3 -2
  5. package/dist/auth/auth.d.mts +3 -3
  6. package/dist/auth/auth.mjs +9 -8
  7. package/dist/auth/authorize.mjs +4 -4
  8. package/dist/auth/fences.d.mts +1 -2
  9. package/dist/auth/fences.mjs +3 -3
  10. package/dist/auth/grants.mjs +4 -4
  11. package/dist/auth/host-function.mjs +19 -2
  12. package/dist/auth/host-services.mjs +4 -6
  13. package/dist/auth/identify.d.mts +1 -1
  14. package/dist/auth/identify.mjs +9 -3
  15. package/dist/auth/token-cleanup.mjs +67 -0
  16. package/dist/auth/token-rows.mjs +7 -2
  17. package/dist/auth/token-text.mjs +9 -1
  18. package/dist/auth/tokens-base.d.mts +35 -0
  19. package/dist/auth/tokens-base.mjs +13 -0
  20. package/dist/auth/tokens-layer.d.mts +2 -27
  21. package/dist/auth/tokens-layer.mjs +6 -11
  22. package/dist/auth/tokens-public.d.mts +3 -3
  23. package/dist/auth/tokens.d.mts +7 -10
  24. package/dist/auth/tokens.mjs +10 -81
  25. package/dist/client/answer.mjs +21 -42
  26. package/dist/client/client.d.mts +17 -11
  27. package/dist/client/client.mjs +21 -12
  28. package/dist/client/git-http.mjs +18 -8
  29. package/dist/client/local.mjs +74 -37
  30. package/dist/client/negotiate.mjs +3 -3
  31. package/dist/client/push-upload.mjs +34 -17
  32. package/dist/client/remote.mjs +12 -13
  33. package/dist/client/run-remote-helper.d.mts +2 -1
  34. package/dist/client/run-remote-helper.mjs +61 -27
  35. package/dist/client/slice-push.d.mts +1 -1
  36. package/dist/client/transport.mjs +105 -46
  37. package/dist/contracts/blobs.d.mts +58 -11
  38. package/dist/contracts/blobs.mjs +17 -3
  39. package/dist/contracts/call-allowance.d.mts +13 -0
  40. package/dist/contracts/call-allowance.mjs +44 -0
  41. package/dist/contracts/calls-spent.mjs +12 -35
  42. package/dist/contracts/client.d.mts +18 -18
  43. package/dist/contracts/commits.d.mts +28 -28
  44. package/dist/contracts/commits.mjs +1 -1
  45. package/dist/contracts/engine.d.mts +8 -3
  46. package/dist/contracts/engine.mjs +10 -1
  47. package/dist/contracts/events.d.mts +1 -1
  48. package/dist/contracts/events.mjs +1 -1
  49. package/dist/contracts/files.d.mts +14 -14
  50. package/dist/contracts/files.mjs +1 -1
  51. package/dist/contracts/forks.d.mts +21 -21
  52. package/dist/contracts/forks.mjs +1 -1
  53. package/dist/contracts/git-events.d.mts +29 -1
  54. package/dist/contracts/git-hooks.d.mts +2 -2
  55. package/dist/contracts/git.d.mts +30 -5
  56. package/dist/contracts/grants.d.mts +24 -4
  57. package/dist/contracts/handlers.d.mts +1 -1
  58. package/dist/contracts/lfs.d.mts +28 -2
  59. package/dist/contracts/merges.d.mts +3 -2
  60. package/dist/contracts/object-values.d.mts +1 -0
  61. package/dist/contracts/object-values.mjs +16 -1
  62. package/dist/contracts/objects.d.mts +42 -41
  63. package/dist/contracts/opaque.mjs +1 -1
  64. package/dist/contracts/operations.mjs +1 -1
  65. package/dist/contracts/queue.d.mts +247 -55
  66. package/dist/contracts/queue.mjs +8 -9
  67. package/dist/contracts/refs.d.mts +30 -27
  68. package/dist/contracts/refs.mjs +1 -1
  69. package/dist/contracts/remote.d.mts +8 -12
  70. package/dist/contracts/remote.mjs +4 -1
  71. package/dist/contracts/repos.d.mts +32 -141
  72. package/dist/contracts/repos.mjs +6 -4
  73. package/dist/contracts/result.d.mts +40 -18
  74. package/dist/contracts/result.mjs +42 -9
  75. package/dist/contracts/rules.d.mts +2 -2
  76. package/dist/contracts/server.d.mts +25 -52
  77. package/dist/contracts/services.d.mts +6 -9
  78. package/dist/contracts/services.mjs +1 -2
  79. package/dist/contracts/signin.d.mts +1 -1
  80. package/dist/contracts/store.d.mts +7 -6
  81. package/dist/contracts/sync.d.mts +73 -12
  82. package/dist/contracts/sync.mjs +14 -3
  83. package/dist/contracts/tags.d.mts +13 -13
  84. package/dist/contracts/tags.mjs +1 -1
  85. package/dist/contracts/time.d.mts +3 -0
  86. package/dist/contracts/{promises.mjs → time.mjs} +1 -1
  87. package/dist/contracts/tokens.d.mts +17 -19
  88. package/dist/contracts/tokens.mjs +4 -3
  89. package/dist/contracts/topics.d.mts +10 -10
  90. package/dist/contracts/trees.d.mts +16 -16
  91. package/dist/contracts/trees.mjs +1 -1
  92. package/dist/contracts/work.d.mts +28 -17
  93. package/dist/contracts/work.mjs +2 -2
  94. package/dist/core/access.d.mts +1 -2
  95. package/dist/core/access.mjs +20 -9
  96. package/dist/core/ancestry.d.mts +1 -0
  97. package/dist/core/ancestry.mjs +30 -34
  98. package/dist/core/asked.mjs +1 -1
  99. package/dist/core/call-groups.mjs +48 -0
  100. package/dist/core/call-names.mjs +6 -1
  101. package/dist/core/call-services.mjs +11 -3
  102. package/dist/core/events/deliver.d.mts +2 -3
  103. package/dist/core/events/deliver.mjs +45 -38
  104. package/dist/core/events/retired.mjs +119 -0
  105. package/dist/core/forks.mjs +929 -433
  106. package/dist/core/hooks/groups.mjs +3 -3
  107. package/dist/core/imports.mjs +127 -41
  108. package/dist/core/index-job.mjs +131 -38
  109. package/dist/core/index-lost.d.mts +1 -2
  110. package/dist/core/index-lost.mjs +2 -2
  111. package/dist/core/loose-tally.mjs +38 -15
  112. package/dist/core/merge-parts.d.mts +17 -4
  113. package/dist/core/merge-parts.mjs +7 -2
  114. package/dist/core/mirror-rows.mjs +31 -1
  115. package/dist/core/objects/blobs.mjs +127 -3
  116. package/dist/core/objects/files.mjs +20 -17
  117. package/dist/core/objects/lines.mjs +2 -2
  118. package/dist/core/objects/merges.mjs +4 -1
  119. package/dist/core/objects/objects-layer.d.mts +1 -1
  120. package/dist/core/objects/objects-layer.mjs +4 -4
  121. package/dist/core/objects/peel.mjs +1 -7
  122. package/dist/core/objects/reading.mjs +41 -29
  123. package/dist/core/objects/tags.mjs +4 -1
  124. package/dist/core/objects/tree-edits.mjs +1 -1
  125. package/dist/core/objects/trees.mjs +257 -58
  126. package/dist/core/objects/writing.mjs +4 -10
  127. package/dist/core/own-writes.mjs +2 -2
  128. package/dist/core/parts.d.mts +11 -5
  129. package/dist/core/parts.mjs +9 -10
  130. package/dist/core/purge.mjs +310 -93
  131. package/dist/core/push-decide.mjs +2 -0
  132. package/dist/core/push-files.d.mts +1 -1
  133. package/dist/core/push.d.mts +2 -2
  134. package/dist/core/push.mjs +170 -128
  135. package/dist/core/receipts.d.mts +2 -2
  136. package/dist/core/receipts.mjs +17 -5
  137. package/dist/core/ref-index-job.mjs +7 -7
  138. package/dist/core/ref-view.mjs +75 -32
  139. package/dist/core/refs.mjs +7 -7
  140. package/dist/core/registered-rows.mjs +2 -2
  141. package/dist/core/repack.mjs +58 -48
  142. package/dist/core/repo-info.mjs +3 -3
  143. package/dist/core/repos.mjs +21 -9
  144. package/dist/core/rules/changes.mjs +18 -40
  145. package/dist/core/rules/check.mjs +6 -5
  146. package/dist/core/rules/commit-changes.mjs +3 -15
  147. package/dist/core/rules/context.d.mts +3 -3
  148. package/dist/core/rules/context.mjs +18 -14
  149. package/dist/core/rules/fetch.mjs +1 -1
  150. package/dist/core/rules/protect.mjs +30 -17
  151. package/dist/core/saved-caller-views.d.mts +8 -3
  152. package/dist/core/saved-caller-views.mjs +4 -4
  153. package/dist/core/saved-callers.d.mts +19 -2
  154. package/dist/core/saved-callers.mjs +1 -1
  155. package/dist/core/seam.d.mts +17 -28
  156. package/dist/core/seam.mjs +7 -28
  157. package/dist/core/tokens.mjs +1 -1
  158. package/dist/core/view.d.mts +6 -3
  159. package/dist/core/view.mjs +18 -25
  160. package/dist/core/work.mjs +60 -15
  161. package/dist/engine/allotted-xdiff.mjs +3 -16
  162. package/dist/engine/combined.d.mts +3 -0
  163. package/dist/engine/combined.mjs +200 -185
  164. package/dist/engine/content.d.mts +2 -2
  165. package/dist/engine/content.mjs +1 -1
  166. package/dist/engine/failures.mjs +2 -1
  167. package/dist/engine/merge.mjs +7 -9
  168. package/dist/engine/reads.d.mts +2 -2
  169. package/dist/engine/reads.mjs +25 -17
  170. package/dist/engine/xdiff.d.mts +1 -1
  171. package/dist/engine/xdiff.mjs +1 -1
  172. package/dist/event-streams/event-streams.d.mts +1 -1
  173. package/dist/event-streams/event-streams.mjs +1 -1
  174. package/dist/event-streams/stream.d.mts +3 -3
  175. package/dist/event-streams/stream.mjs +39 -16
  176. package/dist/extend.d.mts +2 -7
  177. package/dist/extend.mjs +1 -4
  178. package/dist/http/answers.mjs +8 -5
  179. package/dist/http/core-parts.mjs +169 -96
  180. package/dist/http/handler.mjs +82 -10
  181. package/dist/http/node.d.mts +14 -1
  182. package/dist/http/node.mjs +56 -27
  183. package/dist/http/parts.d.mts +2 -0
  184. package/dist/http/push-upload-job.mjs +165 -47
  185. package/dist/http/push-uploads.mjs +37 -22
  186. package/dist/http/receive-pack.mjs +14 -53
  187. package/dist/http/request-snapshot.mjs +258 -0
  188. package/dist/http/upload-pack.mjs +25 -20
  189. package/dist/index.d.mts +36 -28
  190. package/dist/index.mjs +12 -3
  191. package/dist/lfs/answer.mjs +37 -0
  192. package/dist/lfs/base.d.mts +3 -1
  193. package/dist/lfs/base.mjs +25 -1
  194. package/dist/lfs/copy.d.mts +70 -8
  195. package/dist/lfs/copy.mjs +217 -21
  196. package/dist/lfs/layer.d.mts +19 -4
  197. package/dist/lfs/layer.mjs +25 -13
  198. package/dist/lfs/locks.mjs +3 -3
  199. package/dist/lfs/objects.d.mts +2 -1
  200. package/dist/lfs/objects.mjs +89 -19
  201. package/dist/lfs/pointers.mjs +2 -2
  202. package/dist/lfs/rows.d.mts +1 -1
  203. package/dist/lfs/rows.mjs +50 -9
  204. package/dist/lfs/upkeep.mjs +82 -17
  205. package/dist/lfs/uploaded.mjs +1 -1
  206. package/dist/lfs/wire.mjs +7 -32
  207. package/dist/merges/merges.mjs +19 -4
  208. package/dist/node.d.mts +2 -2
  209. package/dist/protocol/bytes/buffers.d.mts +1 -1
  210. package/dist/protocol/bytes/buffers.mjs +14 -6
  211. package/dist/protocol/bytes/deflate.d.mts +1 -1
  212. package/dist/protocol/bytes/deflate.mjs +1 -1
  213. package/dist/protocol/bytes/inflate.d.mts +1 -1
  214. package/dist/protocol/bytes/inflate.mjs +1 -1
  215. package/dist/protocol/bytes/reader.mjs +6 -1
  216. package/dist/protocol/bytes/sha1.d.mts +1 -1
  217. package/dist/protocol/bytes/sha1.mjs +1 -1
  218. package/dist/protocol/bytes/streams.mjs +27 -1
  219. package/dist/protocol/diff/read.d.mts +6 -4
  220. package/dist/protocol/diff/read.mjs +110 -11
  221. package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
  222. package/dist/protocol/objects/lfs-pointer.mjs +1 -3
  223. package/dist/protocol/objects/links-raw.mjs +24 -10
  224. package/dist/protocol/objects/tag.d.mts +1 -1
  225. package/dist/protocol/objects/tree.mjs +23 -6
  226. package/dist/protocol/packs/delta.d.mts +6 -3
  227. package/dist/protocol/packs/delta.mjs +96 -32
  228. package/dist/protocol/packs/graph.mjs +1 -1
  229. package/dist/protocol/packs/idx.d.mts +3 -2
  230. package/dist/protocol/packs/idx.mjs +23 -4
  231. package/dist/protocol/packs/parts.d.mts +4 -1
  232. package/dist/protocol/packs/parts.mjs +10 -7
  233. package/dist/protocol/packs/reader.d.mts +6 -1
  234. package/dist/protocol/packs/reader.mjs +4 -3
  235. package/dist/protocol/packs/write-error.d.mts +1 -1
  236. package/dist/protocol/packs/write-error.mjs +1 -1
  237. package/dist/protocol/packs/writer.mjs +26 -8
  238. package/dist/protocol/wire/advertisement.d.mts +1 -1
  239. package/dist/protocol/wire/advertisement.mjs +3 -2
  240. package/dist/protocol/wire/fetch.d.mts +1 -1
  241. package/dist/protocol/wire/fetch.mjs +1 -1
  242. package/dist/protocol/wire/lines.d.mts +9 -1
  243. package/dist/protocol/wire/lines.mjs +28 -1
  244. package/dist/protocol/wire/push-uploads.mjs +10 -7
  245. package/dist/protocol/wire/receive-pack.d.mts +1 -1
  246. package/dist/protocol/wire/receive-pack.mjs +1 -1
  247. package/dist/protocol/wire/report-status.d.mts +1 -1
  248. package/dist/protocol/wire/report-status.mjs +1 -1
  249. package/dist/protocol/wire/v2.d.mts +1 -1
  250. package/dist/protocol/wire/v2.mjs +1 -1
  251. package/dist/queue/advance.mjs +48 -44
  252. package/dist/queue/base.d.mts +57 -0
  253. package/dist/queue/base.mjs +44 -0
  254. package/dist/queue/calls.mjs +54 -57
  255. package/dist/queue/commit.mjs +2 -2
  256. package/dist/queue/host.d.mts +2 -16
  257. package/dist/queue/host.mjs +2 -7
  258. package/dist/queue/layer.d.mts +2 -2
  259. package/dist/queue/layer.mjs +19 -8
  260. package/dist/queue/limits.mjs +2 -0
  261. package/dist/queue/push-option.mjs +9 -24
  262. package/dist/queue/schedule.mjs +2 -2
  263. package/dist/queue/search.mjs +1 -1
  264. package/dist/queue/state.mjs +3 -11
  265. package/dist/queue/trim.mjs +6 -4
  266. package/dist/rest/blobs.mjs +29 -5
  267. package/dist/rest/caller.d.mts +4 -4271
  268. package/dist/rest/caller.mjs +4 -0
  269. package/dist/rest/client.d.mts +9 -6
  270. package/dist/rest/client.mjs +25 -8
  271. package/dist/rest/errors.mjs +1 -1
  272. package/dist/rest/handler.mjs +2 -2
  273. package/dist/rest/handlers.mjs +66 -11
  274. package/dist/rest/layer.d.mts +2 -2
  275. package/dist/rest/layer.mjs +6 -13
  276. package/dist/rest/listen.mjs +2 -2
  277. package/dist/rest/me.d.mts +3 -432
  278. package/dist/rest/refs.mjs +1 -1
  279. package/dist/server/check-fetch.mjs +3 -3
  280. package/dist/server/edge-node.d.mts +11 -8
  281. package/dist/server/edge-node.mjs +9 -6
  282. package/dist/server/edge.d.mts +21 -7
  283. package/dist/server/edge.mjs +56 -11
  284. package/dist/server/extension.mjs +1 -1
  285. package/dist/server/git-layer.d.mts +5 -6
  286. package/dist/server/git-layer.mjs +28 -23
  287. package/dist/server/git-namespace.d.mts +4 -3
  288. package/dist/server/git-namespace.mjs +3 -2
  289. package/dist/server/lifecycle.mjs +19 -107
  290. package/dist/server/registry.mjs +24 -13
  291. package/dist/server/server.mjs +249 -371
  292. package/dist/signin/context.d.mts +1 -2
  293. package/dist/signin/context.mjs +1 -1
  294. package/dist/signin/forms.mjs +1 -1
  295. package/dist/signin/grants.d.mts +2 -2
  296. package/dist/signin/grants.mjs +1 -1
  297. package/dist/signin/layer.d.mts +1 -1
  298. package/dist/signin/layer.mjs +1 -1
  299. package/dist/signin/wire.mjs +1 -1
  300. package/dist/storage/allotted.mjs +22 -12
  301. package/dist/storage/batch-upkeep.mjs +293 -0
  302. package/dist/storage/batches.d.mts +7 -0
  303. package/dist/storage/batches.mjs +347 -0
  304. package/dist/storage/budget.mjs +23 -1
  305. package/dist/storage/calls.d.mts +2 -3
  306. package/dist/storage/calls.mjs +166 -182
  307. package/dist/storage/charged-cache.mjs +180 -0
  308. package/dist/storage/chunks.d.mts +9 -0
  309. package/dist/storage/chunks.mjs +410 -0
  310. package/dist/storage/clean-up.mjs +72 -9
  311. package/dist/storage/counted-bucket.mjs +35 -13
  312. package/dist/storage/fetch-row-cache.d.mts +6 -0
  313. package/dist/storage/fetch-row-cache.mjs +211 -0
  314. package/dist/storage/fetch.d.mts +2 -0
  315. package/dist/storage/fetch.mjs +339 -450
  316. package/dist/storage/held-types.d.mts +0 -1
  317. package/dist/storage/host-bucket.mjs +10 -6
  318. package/dist/storage/id-mix.mjs +19 -5
  319. package/dist/storage/index-bitmaps.mjs +86 -51
  320. package/dist/storage/index-build.d.mts +2 -4
  321. package/dist/storage/index-build.mjs +324 -67
  322. package/dist/storage/index-fetch.d.mts +3 -1
  323. package/dist/storage/index-fetch.mjs +163 -83
  324. package/dist/storage/index-files.d.mts +3 -0
  325. package/dist/storage/index-files.mjs +10 -5
  326. package/dist/storage/index-graph.mjs +73 -23
  327. package/dist/storage/index-layers.mjs +55 -25
  328. package/dist/storage/index-reach.mjs +15 -22
  329. package/dist/storage/index-remap.mjs +200 -64
  330. package/dist/storage/index-whole.d.mts +7 -0
  331. package/dist/storage/index-whole.mjs +235 -0
  332. package/dist/storage/largest-files.mjs +1 -7
  333. package/dist/storage/layout.mjs +40 -1
  334. package/dist/storage/lfs-pointers.mjs +1 -6
  335. package/dist/storage/link-join.mjs +55 -16
  336. package/dist/storage/list-source.d.mts +7 -0
  337. package/dist/storage/list-source.mjs +288 -0
  338. package/dist/storage/loose.d.mts +10 -7
  339. package/dist/storage/loose.mjs +293 -82
  340. package/dist/storage/memory-budget.mjs +242 -26
  341. package/dist/storage/merge-cut.mjs +9 -6
  342. package/dist/storage/merge-fence.mjs +1 -1
  343. package/dist/storage/merge-plan.mjs +3 -2
  344. package/dist/storage/merge-row.mjs +8 -2
  345. package/dist/storage/merge-stream.mjs +164 -25
  346. package/dist/storage/merge-walk.mjs +8 -4
  347. package/dist/storage/merge-write.mjs +1 -1
  348. package/dist/storage/merge.d.mts +3 -4
  349. package/dist/storage/merge.mjs +3 -3
  350. package/dist/storage/object-rows.d.mts +4 -3
  351. package/dist/storage/object-rows.mjs +545 -84
  352. package/dist/storage/oid-table.mjs +171 -0
  353. package/dist/storage/pack-order.mjs +104 -47
  354. package/dist/storage/pack-ranges.d.mts +1 -2
  355. package/dist/storage/pack-ranges.mjs +48 -21
  356. package/dist/storage/pack-reads.d.mts +6 -3
  357. package/dist/storage/pack-reads.mjs +378 -98
  358. package/dist/storage/pack-receive.d.mts +2 -3
  359. package/dist/storage/pack-receive.mjs +22 -18
  360. package/dist/storage/packs.d.mts +2 -2
  361. package/dist/storage/packs.mjs +587 -156
  362. package/dist/storage/placed-reads.mjs +34 -17
  363. package/dist/storage/plan-columns.d.mts +4 -0
  364. package/dist/storage/plan-columns.mjs +238 -0
  365. package/dist/storage/prune-keep.mjs +134 -41
  366. package/dist/storage/prune-seen.mjs +1 -1
  367. package/dist/storage/prune-walk.mjs +203 -63
  368. package/dist/storage/prune.mjs +197 -121
  369. package/dist/storage/push-allotment.mjs +116 -25
  370. package/dist/storage/push-uploads.mjs +196 -58
  371. package/dist/storage/pushed-commits.mjs +24 -3
  372. package/dist/storage/quarantine.d.mts +3 -4
  373. package/dist/storage/range-cache.mjs +293 -41
  374. package/dist/storage/raw-ids.mjs +39 -10
  375. package/dist/storage/ready.d.mts +3 -4
  376. package/dist/storage/ready.mjs +121 -43
  377. package/dist/storage/receive-bounds.mjs +50 -13
  378. package/dist/storage/receive-cache.d.mts +7 -0
  379. package/dist/storage/receive-cache.mjs +147 -0
  380. package/dist/storage/receive-files.mjs +1 -1
  381. package/dist/storage/receive-links.mjs +1 -1
  382. package/dist/storage/receive-state.d.mts +2 -2
  383. package/dist/storage/receive-state.mjs +6 -8
  384. package/dist/storage/receive-steps.d.mts +20 -0
  385. package/dist/storage/receive-steps.mjs +298 -13
  386. package/dist/storage/repack-backlog.mjs +1 -3
  387. package/dist/storage/repack-contained.mjs +2 -2
  388. package/dist/storage/repack-job.mjs +1 -1
  389. package/dist/storage/repack.d.mts +3 -4
  390. package/dist/storage/repack.mjs +54 -9
  391. package/dist/storage/request-cache.mjs +57 -0
  392. package/dist/storage/roots.mjs +1 -24
  393. package/dist/storage/rows.d.mts +3 -3
  394. package/dist/storage/rows.mjs +2 -2
  395. package/dist/storage/runs.d.mts +2 -2
  396. package/dist/storage/runs.mjs +196 -44
  397. package/dist/storage/send-list.d.mts +1 -0
  398. package/dist/storage/send-list.mjs +112 -31
  399. package/dist/storage/single-flight.mjs +13 -7
  400. package/dist/storage/stream-whole.mjs +188 -66
  401. package/dist/storage/swap-walk.mjs +1 -1
  402. package/dist/storage/unpack.mjs +919 -199
  403. package/dist/storage/visible.mjs +112 -34
  404. package/dist/storage/walk.mjs +193 -38
  405. package/dist/storage/wants.mjs +27 -63
  406. package/dist/store/bodies.mjs +38 -0
  407. package/dist/store/call-count.d.mts +10 -14
  408. package/dist/store/call-count.mjs +58 -57
  409. package/dist/store/catalogue.d.mts +2 -2
  410. package/dist/store/catalogue.mjs +158 -36
  411. package/dist/store/crossing.mjs +1 -9
  412. package/dist/store/cursor-seal.d.mts +1 -2
  413. package/dist/store/cursor-seal.mjs +17 -7
  414. package/dist/store/door.mjs +188 -0
  415. package/dist/store/errors.d.mts +4 -5
  416. package/dist/store/errors.mjs +119 -49
  417. package/dist/store/git-store.mjs +30 -7
  418. package/dist/store/job-try.mjs +98 -40
  419. package/dist/store/list-job.mjs +32 -20
  420. package/dist/store/outbox.d.mts +2 -2
  421. package/dist/store/outbox.mjs +2 -2
  422. package/dist/store/queue-jobs.mjs +6 -12
  423. package/dist/store/records.d.mts +5 -2
  424. package/dist/store/records.mjs +5 -2
  425. package/dist/store/ref-rows.d.mts +2 -2
  426. package/dist/store/ref-rows.mjs +2 -2
  427. package/dist/store/repo-record.d.mts +2 -3
  428. package/dist/store/repo-record.mjs +34 -22
  429. package/dist/store/request-snapshot.mjs +5 -0
  430. package/dist/store/reservations.mjs +3 -3
  431. package/dist/store/scopes.mjs +11 -0
  432. package/dist/store/settle.mjs +4 -4
  433. package/dist/store/topic-jobs.mjs +5 -11
  434. package/dist/sync/bound.d.mts +3 -3
  435. package/dist/sync/bound.mjs +10 -7
  436. package/dist/sync/github.mjs +67 -69
  437. package/dist/sync/http.mjs +1 -1
  438. package/dist/sync/import.mjs +205 -57
  439. package/dist/sync/layer.d.mts +1 -1
  440. package/dist/sync/layer.mjs +6 -6
  441. package/dist/sync/lfs-batch.mjs +5 -6
  442. package/dist/sync/lfs-copy.mjs +191 -20
  443. package/dist/sync/mirror.mjs +34 -36
  444. package/dist/sync/said.mjs +17 -38
  445. package/dist/sync/step.mjs +292 -102
  446. package/dist/sync/tries.mjs +34 -15
  447. package/dist/sync.d.mts +2 -2
  448. package/dist/sync.mjs +2 -2
  449. package/dist/topics/advance.mjs +12 -13
  450. package/dist/topics/base.d.mts +15 -0
  451. package/dist/topics/base.mjs +8 -0
  452. package/dist/topics/calls.mjs +1 -1
  453. package/dist/topics/host.mjs +1 -1
  454. package/dist/topics/layer.d.mts +17 -21
  455. package/dist/topics/layer.mjs +2 -3
  456. package/dist/topics/members.mjs +4 -4
  457. package/dist/topics/public.d.mts +2 -1
  458. package/dist/topics/topic.mjs +2 -2
  459. package/package.json +5 -14
  460. package/dist/auth/helpers.mjs +0 -17
  461. package/dist/auth.d.mts +0 -5
  462. package/dist/auth.mjs +0 -5
  463. package/dist/contracts/promises.d.mts +0 -39
  464. package/dist/core/call-names.d.mts +0 -3
  465. package/dist/core/clock.mjs +0 -18
  466. package/dist/core/promise.mjs +0 -74
  467. package/dist/core/rules/commit-changes.d.mts +0 -13
  468. package/dist/effect.d.mts +0 -18
  469. package/dist/effect.mjs +0 -16
  470. package/dist/lfs/calls.mjs +0 -26
  471. package/dist/rest/api.d.mts +0 -23
  472. package/dist/rest/blobs.d.mts +0 -833
  473. package/dist/rest/commits.d.mts +0 -3543
  474. package/dist/rest/errors.d.mts +0 -2124
  475. package/dist/rest/events.d.mts +0 -426
  476. package/dist/rest/files.d.mts +0 -1342
  477. package/dist/rest/forks.d.mts +0 -2160
  478. package/dist/rest/handlers.d.mts +0 -8
  479. package/dist/rest/merges.d.mts +0 -477
  480. package/dist/rest/queue.d.mts +0 -5917
  481. package/dist/rest/refs.d.mts +0 -2988
  482. package/dist/rest/repos.d.mts +0 -2567
  483. package/dist/rest/tags.d.mts +0 -1316
  484. package/dist/rest/tokens.d.mts +0 -2614
  485. package/dist/rest/topics.d.mts +0 -2224
  486. package/dist/rest/trees.d.mts +0 -1709
  487. package/dist/rest/work.d.mts +0 -1695
  488. package/dist/server/joined.d.mts +0 -82
  489. package/dist/server/joined.mjs +0 -68
  490. package/dist/server/lifecycle.d.mts +0 -2
  491. package/dist/store/promises.d.mts +0 -11
  492. package/dist/store/promises.mjs +0 -327
@@ -12,12 +12,12 @@ import { isPackId, objectCollections, packFiles } from "./layout.mjs";
12
12
  import { noRows } from "./object-rows.mjs";
13
13
  import { openQuarantine } from "./quarantine.mjs";
14
14
  import { leavingRow, removeAt } from "./rows.mjs";
15
- import * as Clock$1 from "effect/Clock";
16
- import * as Effect from "effect/Effect";
17
15
  import * as Schema from "effect/Schema";
16
+ import * as Effect from "effect/Effect";
18
17
  import * as Exit from "effect/Exit";
19
- import * as Hex from "effect/encoding/Hex";
20
18
  import * as Deferred from "effect/Deferred";
19
+ import * as Clock from "effect/Clock";
20
+ import * as Hex from "effect/encoding/Hex";
21
21
  // src/storage/ready.ts
22
22
  /** `git clone --depth 1` of the default branch, within 20,000 objects. */
23
23
  const defaultShallow = {
@@ -34,6 +34,19 @@ const readyBytesMost = 67108864;
34
34
  * the row stays well under a store's 1 MiB.
35
35
  */
36
36
  const readyShallowsMost = 1e4;
37
+ /**
38
+ * The most a shallow clone that missed waits for its ask for the ready pack to save, before its
39
+ * pack is planned: past it the ask is dropped, and a later clone asks again. Well under a stream's
40
+ * 30 s unread bound, though the ask is made before the stream is (#2898).
41
+ */
42
+ const readyAskMs = 2e3;
43
+ /**
44
+ * What a shallow clone that missed keeps of its fetch's time for its own plan and pack, before it
45
+ * gives any to its ask: with less left, it doesn't ask. Planning and sending a first clone of 825
46
+ * and of 4,951 objects took 61 and 178 ms locally, so 5 s leaves room for a host's slower store
47
+ * (#2898).
48
+ */
49
+ const readyAskRoomMs = 5e3;
37
50
  /** How long a ready pack's build may take to write: a third of `git.repack`'s 15 minutes. */
38
51
  const readyMilliseconds = 3e5;
39
52
  const PackIdText = /* @__PURE__ */ Schema.String.check(Schema.isPattern(/^p_[A-Za-z0-9_-]{16}$/));
@@ -65,6 +78,21 @@ const readyRow = (value) => ({
65
78
  ...readyKey,
66
79
  value
67
80
  });
81
+ /**
82
+ * A shallow clone's ask for a ready pack, in `ready` by `wanted`: the tip it cloned, when it found
83
+ * none for that tip. Added, never put, so the repo holds one until `git.repack`'s ready step takes
84
+ * it: it builds the pack when the ask names the default branch's tip, and drops it otherwise.
85
+ */
86
+ const ReadyWanted = /* @__PURE__ */ Schema.Struct({ tip: Schema.String });
87
+ const wantedKey = {
88
+ collection: objectCollections.ready,
89
+ id: "wanted"
90
+ };
91
+ /** The row a missed clone of `tip` adds. */
92
+ const wantedRow = (tip) => ({
93
+ ...wantedKey,
94
+ value: { tip }
95
+ });
68
96
  /** The tags a fetch may follow, as one digest: the sorted IDs, each once, hashed. */
69
97
  const tagsDigest = (tags) => {
70
98
  const sha = new Sha1();
@@ -80,6 +108,7 @@ const readyRequest = (tip, depth) => ({
80
108
  includeTag: true
81
109
  });
82
110
  const decodeReady = (row) => row === void 0 ? Effect.succeed(void 0) : decodeRow(ReadyRow, row, "The ready shallow pack's row");
111
+ const decodeWanted = (row) => row === void 0 ? Effect.succeed(void 0) : decodeRow(ReadyWanted, row, "The ready shallow pack's ask");
83
112
  const readOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed) {
84
113
  const snapshot = yield* store.read({
85
114
  scope: repoScope(listed.repo),
@@ -88,17 +117,34 @@ const readOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed) {
88
117
  return yield* decodeReady(snapshot.results[0]?.[0]);
89
118
  });
90
119
  /**
91
- * The ready row and the repo's roots, in one read: a step builds over the roots as they are now,
92
- * with no fetch to pass them, as `git.index`'s build reads them.
120
+ * Whether a clone's ask waits already: read only by a clone that would ask, apart from the ready
121
+ * row, which a request's snapshot answers from memory (#2899), so a clone the ready pack serves
122
+ * reads no more than before.
123
+ */
124
+ const askWaits = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed) {
125
+ const snapshot = yield* store.read({
126
+ scope: repoScope(listed.repo),
127
+ reads: [wantedKey]
128
+ });
129
+ return (yield* decodeWanted(snapshot.results[0]?.[0])) !== void 0;
130
+ });
131
+ /**
132
+ * The ready row, the repo's roots and the ask for a pack, in one read: a step builds over the
133
+ * roots as they are now, with no fetch to pass them, as `git.index`'s build reads them.
93
134
  */
94
135
  const readWithRoots = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed) {
95
136
  const snapshot = yield* store.read({
96
137
  scope: repoScope(listed.repo),
97
- reads: [readyKey, repoRootsKey]
138
+ reads: [
139
+ readyKey,
140
+ repoRootsKey,
141
+ wantedKey
142
+ ]
98
143
  });
99
144
  return {
100
145
  ready: yield* decodeReady(snapshot.results[0]?.[0]),
101
- roots: yield* rootsOf(snapshot.results[1])
146
+ roots: yield* rootsOf(snapshot.results[1]),
147
+ wanted: yield* decodeWanted(snapshot.results[2]?.[0])
102
148
  };
103
149
  });
104
150
  /** The bytes of the ready pack `rows`, a read of `readyKey`, hold: 0 with none kept. */
@@ -108,6 +154,11 @@ const readyBytesOf = /* @__PURE__ */ Effect.fnUntraced(function* (rows) {
108
154
  return (yield* decodeRow(ReadyRow, row, "The ready shallow pack's row")).pack?.bytes ?? 0;
109
155
  });
110
156
  /**
157
+ * Whether a ready shallow pack can ever answer `request` before reading its row: one want, no
158
+ * haves or client shallows, an explicit shallow depth, no `deepen-relative`, and no filter.
159
+ */
160
+ const readyEligible = (request) => request.haves.length === 0 && request.shallows.length === 0 && request.depth !== void 0 && request.deepenRelative !== true && request.filter === void 0 && new Set(request.wants).size === 1;
161
+ /**
111
162
  * Whether a ready pack answers `input` exactly, as its plan would now: the one want its tip, no
112
163
  * haves and no shallow commits, its depth, no `deepen-relative` and no filter, `include-tag`
113
164
  * over the same tags, so a tag a rule hides from the caller never reaches them, and the same roots. The objects a tip
@@ -119,7 +170,7 @@ const answers = (ready, input) => {
119
170
  if (pack === void 0) return false;
120
171
  const tags = request.includeTag ? tagsDigest(input.tags ?? []) === ready.tags : pack.tagged === 0;
121
172
  const roots = () => rootsDigest(input.roots ?? []) === ready.roots;
122
- return new Set(request.wants).size === 1 && request.wants[0] === ready.tip && request.haves.length === 0 && request.shallows.length === 0 && request.depth === ready.depth && request.deepenRelative !== true && request.filter === void 0 && tags && pack.objects <= limits.objects && pack.bytes <= limits.bytes && roots();
173
+ return readyEligible(request) && request.wants[0] === ready.tip && request.depth === ready.depth && tags && pack.objects <= limits.objects && pack.bytes <= limits.bytes && roots();
123
174
  };
124
175
  /**
125
176
  * `bytes`, ended as a planned pack's stream is: when `signal` aborts, its reader gets the signal's
@@ -198,7 +249,7 @@ const untilEnded = /* @__PURE__ */ Effect.fnUntraced(function* (bytes, signal, l
198
249
  }
199
250
  signal?.addEventListener("abort", aborted, { once: true });
200
251
  const totalWait = Math.max(0, left);
201
- const startedAt = yield* Clock$1.currentTimeMillis;
252
+ const startedAt = yield* Clock.currentTimeMillis;
202
253
  const waitForEnd = (duration) => Deferred.await(over).pipe(Effect.timeoutOrElse({
203
254
  duration: Math.max(0, duration),
204
255
  orElse: () => Effect.sync(() => stop(timedOut))
@@ -210,51 +261,60 @@ const untilEnded = /* @__PURE__ */ Effect.fnUntraced(function* (bytes, signal, l
210
261
  })
211
262
  }), Effect.andThen(Effect.suspend(() => {
212
263
  if (stopped) return Effect.void;
213
- return Effect.flatMap(Clock$1.currentTimeMillis, (now) => waitForEnd(startedAt + totalWait - now));
264
+ return Effect.flatMap(Clock.currentTimeMillis, (now) => waitForEnd(startedAt + totalWait - now));
214
265
  }))) : waitForEnd(totalWait);
215
266
  yield* Effect.forkDetach(timer);
216
267
  return stream;
217
268
  });
218
269
  /**
219
- * The ready pack that answers `input` exactly, and its stream from the bucket, or `undefined`. Its
220
- * one get is checked against `calls` before it's made.
270
+ * The ready pack that answers `input` exactly, and its stream from the bucket, as `opened`; or,
271
+ * when none does, the tip to ask one for, as `want`: a clone at `depth` of a tip no ready row
272
+ * names, with no ask waiting. Its one get is checked against `calls` before it's made.
221
273
  */
222
- const readyOpened = /* @__PURE__ */ Effect.fnUntraced(function* (store, bucket, listed, input, calls) {
274
+ const readyOpened = /* @__PURE__ */ Effect.fnUntraced(function* (store, bucket, listed, input, depth, calls) {
223
275
  const ready = yield* readOf(store, listed);
224
- if (ready?.pack === void 0 || !answers(ready, input)) return void 0;
276
+ if (ready?.pack === void 0 || !answers(ready, input)) {
277
+ const [tip] = input.request.wants;
278
+ if (tip === void 0 || input.request.depth !== depth) return {};
279
+ if (ready?.tip === tip && ready.depth === depth && ready.roots === rootsDigest(input.roots ?? [])) return {};
280
+ return (yield* askWaits(store, listed)) ? {} : { want: tip };
281
+ }
225
282
  const { id, objects, shallow } = ready.pack;
226
- if (!isPackId(id)) return void 0;
283
+ if (!isPackId(id)) return {};
227
284
  yield* callsAhead(calls, {
228
285
  bucket: 1,
229
286
  store: 0
230
287
  }, input.request.haves.length === 0);
231
- return {
288
+ return { opened: {
232
289
  bytes: yield* bucketBody(bucket, packFiles(id).pack),
233
290
  objects,
234
291
  shallow
235
- };
292
+ } };
236
293
  });
237
294
  /**
238
- * The ready pack's answer to `input`, its bytes streamed from the bucket as they were written, or
239
- * `undefined` when it doesn't answer it exactly, and the fetch is planned. Its bytes are read only
240
- * as its reader pulls them, so bytes that are gone fail the stream. The fetch's one deadline, from `started`, holds the look-up and the stream, and the call's
241
- * signal ends the stream, as each does a planned pack's. `calls` counts what the fetch made before.
295
+ * The ready pack's answer to `input`, its bytes streamed from the bucket as they were written, as
296
+ * `answer`; when it doesn't answer it exactly, and the fetch is planned, none, and with a clone at
297
+ * `depth`, the shallow pack's, the tip to ask one for, as `want`. Its bytes are read only as its
298
+ * reader pulls them, so bytes that are gone fail the stream. The fetch's one deadline, from
299
+ * `started`, holds the look-up and the stream, and the call's signal ends the stream, as each does
300
+ * a planned pack's. `calls` counts what the fetch made before.
242
301
  */
243
- const readyAnswer = /* @__PURE__ */ Effect.fnUntraced(function* (store, bucket, listed, input, started, calls) {
302
+ const readyLookup = /* @__PURE__ */ Effect.fnUntraced(function* (store, bucket, listed, input, started, depth, calls) {
303
+ if (!readyEligible(input.request)) return {};
244
304
  const { limits } = input;
245
- const opened = yield* readyOpened(store, bucket, listed, input, calls).pipe(Effect.timeoutOrElse({
305
+ const { opened, want } = yield* readyOpened(store, bucket, listed, input, depth, calls).pipe(Effect.timeoutOrElse({
246
306
  duration: Math.max(0, yield* timeLeft(limits, started)),
247
307
  orElse: () => Effect.fail(planTooSlow(limits))
248
308
  }));
249
- if (opened === void 0) return void 0;
309
+ if (opened === void 0) return want === void 0 ? {} : { want };
250
310
  const left = yield* timeLeft(limits, started);
251
311
  const pack = yield* untilEnded(opened.bytes, input.signal, left, limits);
252
- return {
312
+ return { answer: {
253
313
  shallow: opened.shallow,
254
314
  unshallow: [],
255
315
  objects: opened.objects,
256
316
  pack
257
- };
317
+ } };
258
318
  });
259
319
  const readyLimits = (shallow) => ({
260
320
  objects: shallow.maxObjects,
@@ -328,11 +388,13 @@ const keepPack = /* @__PURE__ */ Effect.fnUntraced(function* (input, shallow, pl
328
388
  const left = yield* timeLeft(limits, started);
329
389
  const answer = yield* handingOn(packOfPlan(input.reads, plan, limits, { left }));
330
390
  yield* putWhole(bucket, packFiles(opened.pack).pack, answer.pack);
331
- const followed = plan.objects.filter((object) => object.kind === "tag").length;
391
+ const { columns } = plan;
392
+ let followed = 0;
393
+ for (let ordinal = 0; ordinal < columns.count; ordinal += 1) if (columns.kindAt(ordinal) === "tag") followed += 1;
332
394
  return {
333
395
  pack: {
334
396
  id: opened.pack,
335
- objects: plan.objects.length,
397
+ objects: columns.count,
336
398
  bytes: plan.bytes,
337
399
  tagged: followed,
338
400
  shallow: [...plan.deepened.shallow]
@@ -343,19 +405,23 @@ const keepPack = /* @__PURE__ */ Effect.fnUntraced(function* (input, shallow, pl
343
405
  /**
344
406
  * `git.repack`'s step for the ready shallow pack, after clean-up's, as a change the core commits:
345
407
  * - with the default branch's tip, its depth and its tags as the row says, nothing to do;
346
- * - otherwise its pack is planned, and within its limits written to the bucket and its row put,
347
- * its `quarantine` row gone; past them, or at a tip naming an object the repo lacks, its row
348
- * put with no pack, so only a moved tip plans it again;
408
+ * - otherwise, with a clone's ask for that tip, its pack is planned, and within its limits
409
+ * written to the bucket and its row put, its `quarantine` row gone; past them, or at a tip
410
+ * naming an object the repo lacks, its row put with no pack, so only a moved tip plans it
411
+ * again;
412
+ * - without one, the row is deleted, its pack leaving, so a push no shallow clone follows costs
413
+ * no walk and no write, and the next clone that misses asks;
349
414
  * - a pack the row named before leaves through a `leaving` row, so a clone still streaming it
350
415
  * can finish, and clean-up ends its marker and bytes after: at prune's time, or a deleted
351
416
  * repo's `leaveAt` when that's sooner;
352
417
  * - with no tip, a deleted repo's or one whose default branch isn't there, or `shallow: false`,
353
- * the row is deleted, its pack leaving.
418
+ * the row is deleted, its pack leaving;
419
+ * - an ask is taken by whichever of these meets it, in the same change.
354
420
  * `undefined` when there is nothing to do.
355
421
  */
356
422
  const readyStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
357
423
  const { shallow, tip, at, prune, leaveAt } = input;
358
- const { ready, roots: rooted } = yield* readWithRoots(input.store, input.listed);
424
+ const { ready, roots: rooted, wanted } = yield* readWithRoots(input.store, input.listed);
359
425
  const roots = [...rooted];
360
426
  const tags = tagsDigest(input.tags);
361
427
  const rootsAt = rootsDigest(roots);
@@ -368,29 +434,40 @@ const readyStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
368
434
  ...old,
369
435
  id: old.id
370
436
  }, due));
371
- if (shallow === false || tip === void 0) {
372
- if (ready === void 0) return void 0;
373
- const removed = {
437
+ const asked = wanted === void 0 ? [] : [wantedKey];
438
+ const removed = () => {
439
+ if (ready === void 0 && wanted === void 0) return void 0;
440
+ const drops = [...ready === void 0 ? [] : [readyKey], ...asked];
441
+ const change = {
374
442
  change: {
375
443
  put,
376
- delete: [readyKey],
444
+ delete: drops,
377
445
  rows: noRows
378
446
  },
379
447
  more: false
380
448
  };
381
- return old === void 0 ? removed : {
382
- ...removed,
449
+ return old === void 0 ? change : {
450
+ ...change,
383
451
  due
384
452
  };
385
- }
386
- if (ready?.tip === tip && ready.depth === shallow.depth && ready.tags === tags && ready.roots === rootsAt) return void 0;
453
+ };
454
+ if (shallow === false || tip === void 0) return removed();
455
+ if (ready?.tip === tip && ready.depth === shallow.depth && ready.tags === tags && ready.roots === rootsAt) return wanted === void 0 ? void 0 : {
456
+ change: {
457
+ put: [],
458
+ delete: asked,
459
+ rows: noRows
460
+ },
461
+ more: false
462
+ };
463
+ if (wanted?.tip !== tip) return removed();
387
464
  const kept = yield* Effect.scoped(Effect.gen(function* () {
388
465
  const build = {
389
466
  ...input,
390
467
  reads: yield* input.reads,
391
468
  roots
392
469
  };
393
- const started = yield* Clock$1.currentTimeMillis;
470
+ const started = yield* Clock.currentTimeMillis;
394
471
  const plan = yield* readyPlan(build, shallow, tip, started);
395
472
  const left = yield* timeLeft(readyLimits(shallow), started);
396
473
  return plan !== void 0 && left > 0 ? yield* keepPack(build, shallow, plan, started).pipe(Effect.catchIf(isLimitRefusal, () => Effect.succeed(void 0))) : void 0;
@@ -401,6 +478,7 @@ const readyStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
401
478
  tags,
402
479
  roots: rootsAt
403
480
  };
481
+ del.push(...asked);
404
482
  if (kept !== void 0) {
405
483
  value.pack = kept.pack;
406
484
  del.push(kept.quarantine);
@@ -423,4 +501,4 @@ const readyStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
423
501
  due
424
502
  };
425
503
  });
426
- export { ReadyRow, defaultShallow, readyAnswer, readyBytesMost, readyBytesOf, readyKey, readyRequest, readyShallowsMost, readyStep, tagsDigest, untilEnded };
504
+ export { ReadyRow, ReadyWanted, defaultShallow, readyAskMs, readyAskRoomMs, readyBytesMost, readyBytesOf, readyKey, readyLookup, readyRequest, readyShallowsMost, readyStep, tagsDigest, untilEnded, wantedKey, wantedRow };
@@ -1,4 +1,4 @@
1
- import { millis } from "../contracts/promises.mjs";
1
+ import { millis } from "../contracts/time.mjs";
2
2
  import { repoRootsMost } from "../store/records.mjs";
3
3
  import { graphBytes } from "../protocol/packs/graph.mjs";
4
4
  import { packIndexBytes } from "../protocol/packs/idx.mjs";
@@ -36,6 +36,17 @@ const receiveLinkSpillBytes = 64 * mib;
36
36
  */
37
37
  const receiveLinksMost = 8e7;
38
38
  /**
39
+ * The links outside a pack a receive of rows asks the repo's headers of at once, 1,000: each batch
40
+ * read, checked and let go, so a tree of any width holds one batch of them. Ten of `rowReadBatch`.
41
+ */
42
+ const receiveLinksAskedBatch = 1e3;
43
+ /**
44
+ * The IDs outside a pack whose types a receive of rows keeps once asked, 100,000, about 10 MB: each
45
+ * asked once while it holds them, and again past it, so a push of many trees naming one file asks
46
+ * once, and one naming a million files holds no more.
47
+ */
48
+ const receiveLinksAskedMost = 1e5;
49
+ /**
39
50
  * The most bytes a receive's check rows are held before they're put, 1 MiB: an object whose check
40
51
  * waited for the sweeps is a row of 4 B, so a full buffer's sort, `sortRowBytes` a row, takes
41
52
  * 5.5 MB, under the deferred rows' 7.3 MB at `receiveRunBytes`.
@@ -85,26 +96,34 @@ const receiveCutParentsMost = 2 * receiveBoundaryMost;
85
96
  */
86
97
  const receiveDropPage = 1e3;
87
98
  /**
88
- * One try of an import, a mirror or a push upload: a segment of history under 100 MB, one push of
89
- * a ref, or one step of an uploaded pack. At it, the queue aborts the try's signal, which every
90
- * receive step's bucket and store calls take.
99
+ * One try of an import or a mirror, 13 minutes, longer than every other long job's
100
+ * `jobTryTimeout`. An import copies each LFS object its history points at in one streamed put, and
101
+ * a mirror sends what its upstream lacks in one push, neither with a cursor in its bytes, so a try
102
+ * shorter than the largest transfer at a slow peer starts it again every try. Both stay at 13
103
+ * minutes until their transfers resume across tries (#2900), so a stock Vercel host can't set
104
+ * `longestTry` yet.
91
105
  */
92
106
  const importTryTimeout = "13 minutes";
93
107
  /**
94
108
  * How long after a receive's keys may last have been put clean-up waits to delete them: its
95
109
  * `staged` row's wait, from the landing, the end or the drop that left them. A step puts them
96
- * only inside an import's or a push upload's try, after its claim and its read of its quarantine,
97
- * so it's bound by how long that try's calls can run:
110
+ * only inside an import's try, which the queue aborts at `importTryTimeout`, or a push upload's,
111
+ * which it aborts sooner, at `jobTryTimeout`, after its claim and its read of its quarantine, so
112
+ * it's bound by how long the longer of those tries' calls can run:
98
113
  * - On Cloudflare, an alarm's `alarmWallTime`, 15 minutes from before the claim. R2's calls
99
114
  * through its binding take no signal, so one started before the try's timeout runs on, but
100
115
  * the alarm's end stops it.
101
- * - On a host with no such cap, a queue on Node, Bun or Deno, `importTryTimeout`: at it the
102
- * signal aborts, `bucketCall` starts no call, and a call under way ends at once. `disk()`'s
103
- * calls take no signal, but they're local writes that end within a call. S3's and Vercel
104
- * Blob's take it, so a request already sent can only commit within its own trip.
116
+ * - On Node, Bun or Deno, `importTryTimeout`: at it the signal aborts, `bucketCall` starts no
117
+ * call, and a call under way ends at once. S3's and Vercel Blob's take it, so a request
118
+ * already sent can only commit within its own trip. The disk bucket's calls take no signal: the
119
+ * bound assumes its local writes, an fsync then a link, end within the grace. A queue on
120
+ * `Node.workerThreads()` caps any call: a second past the abort, it ends the handler's thread.
105
121
  * Then `jobLeaseMargin`, the queue's own room past a try's end, covers that last call's commit.
106
- * So 15.5 minutes. A bucket that ignores the signal on a host with no invocation cap breaks this
107
- * bound, as before-production.md says.
122
+ * So 15.5 minutes, on every bucket and host Git ships, given that local I/O. A call that outlasts
123
+ * it on a queue run in-process, the disk bucket's on a disk that stalls, or a host's own bucket's
124
+ * that its interrupt doesn't stop, which the `Bucket` service forbids, can put a key after clean-up.
125
+ * That key belongs to the receive's fresh pack ID, under its prefix or among its pack files, such
126
+ * as `packs/<pack ID>.idx`, which nothing reads again, so it only orphans those bytes.
108
127
  */
109
128
  const receiveStepGrace = Math.max(millis(importTryTimeout), alarmWallTime) + jobLeaseMargin;
110
129
  /**
@@ -138,6 +157,24 @@ const pushStepLeast = mib;
138
157
  */
139
158
  const pushStepBytesOf = (cpuMs) => Math.floor(receiveCpuShare * (cpuMs ?? 3e4) / 400 * mib);
140
159
  /**
160
+ * One part of a stepped staging multipart put, 8 MiB: above S3 and R2's 5 MiB minimum, matching
161
+ * `uploadPartBytes`, keeping peak staging JS heap at 8 MiB (within a 128 MB isolate's budget),
162
+ * and producing at most 128 parts for a 1 GiB pack (~8 KB of JSON in `PushUploadSteps.staging`).
163
+ */
164
+ const stagePartBytes = 8 * mib;
165
+ /** The largest staging slice a single try writes, 128 MiB (16 parts at `stagePartBytes`). */
166
+ const stageSliceMost = 128 * mib;
167
+ /**
168
+ * The bytes one staging try reads and uploads as multipart parts, rounded down to a whole multiple
169
+ * of `stagePartBytes` (so every non-final part meets S3/R2's 5 MiB minimum), floored at
170
+ * `stagePartBytes` and capped at `stageSliceMost`. At Workers' 30 s it is 64 MiB.
171
+ */
172
+ const stageSliceBytesOf = (cpuMs) => {
173
+ const raw = Math.floor(receiveCpuShare * (cpuMs ?? 3e4) / 375 * mib);
174
+ const aligned = Math.floor(raw / stagePartBytes) * stagePartBytes;
175
+ return Math.min(stageSliceMost, Math.max(stagePartBytes, aligned));
176
+ };
177
+ /**
141
178
  * The found rows a receive's join may still write, from its `links` and the pack's `objects`: one
142
179
  * for each ID a link names that the table finds among the pack's objects, so at most a link row
143
180
  * and at most an object. A join that finds more is refused `foundWrongly`.
@@ -221,4 +258,4 @@ const receiveCallsAfter = (written, multipart, batch) => {
221
258
  const runs = written.others + objects.length + commits.length + found.length + links.length + joined.runs + merges.reduce((sum, merge) => sum + merge.runs, 0);
222
259
  return lastRuns.reduce((sum, length) => sum + sizedPutCalls(multipart, length), 0) + merges.reduce((sum, merge) => sum + merge.calls, 0) + files.reduce((sum, bytes) => sum + sizedPutCalls(multipart, bytes), 0) + dropRunsCalls(runs, batch);
223
260
  };
224
- export { dropRunsCalls, importTryTimeout, joinFoundMost, mergeCallsOf, pushStepBytesOf, pushStepLeast, receiveBoundaryMost, receiveCallsAfter, receiveCheckRunBytes, receiveCpuShare, receiveCutParentsMost, receiveDeferredSpillBytes, receiveDropPage, receiveLinkSpillBytes, receiveLinksMost, receiveMergeReadBytes, receiveRunBytes, receiveStepFloor, receiveStepGrace, receiveSweepHeldBytes, receiveTableMost, tryCpuMsDefault };
261
+ export { dropRunsCalls, importTryTimeout, joinFoundMost, mergeCallsOf, pushStepBytesOf, pushStepLeast, receiveBoundaryMost, receiveCallsAfter, receiveCheckRunBytes, receiveCpuShare, receiveCutParentsMost, receiveDeferredSpillBytes, receiveDropPage, receiveLinkSpillBytes, receiveLinksAskedBatch, receiveLinksAskedMost, receiveLinksMost, receiveMergeReadBytes, receiveRunBytes, receiveStepFloor, receiveStepGrace, receiveSweepHeldBytes, receiveTableMost, stagePartBytes, stageSliceBytesOf, stageSliceMost, tryCpuMsDefault };
@@ -0,0 +1,7 @@
1
+ import "../contracts/ids.mjs";
2
+ import "../contracts/objects.mjs";
3
+ import "../contracts/result.mjs";
4
+ import "./object-rows.mjs";
5
+ import "./pack-reads.mjs";
6
+ import { Row } from "@ref0/infra";
7
+ import "effect/Effect";
@@ -0,0 +1,147 @@
1
+ import { chargedCache } from "./charged-cache.mjs";
2
+ import { chunkedOf } from "./chunks.mjs";
3
+ import { objectOfRow } from "./object-rows.mjs";
4
+ import * as Effect from "effect/Effect";
5
+ // src/storage/receive-cache.ts
6
+ /**
7
+ * The most bytes of stored base objects kept from one `receiveRows` call to reuse in that same
8
+ * push's `headers`, `held`, and `kindsOf` reads (#2899). Past this cap, additional bodies are not
9
+ * cached and subsequent reads fall back to the store or packs.
10
+ */
11
+ const receiveBaseBytes = 1048576;
12
+ /**
13
+ * The most object locations (`packId` or loose row `undefined`) remembered from one `receiveRows`
14
+ * call so `linkedPacks` reuses what `unpackObjects` already resolved (#2899). Past this cap,
15
+ * additional locations are not recorded and `linkedPacks` falls back to `reader.heldIn`.
16
+ */
17
+ const receiveLocatedMost = 4096;
18
+ /** Per-entry map and key overhead charged to the push's memory allotment for each cached entry. */
19
+ const receiveEntryOverheadBytes = 96;
20
+ /** Inline base64 row payload bytes counted against `receiveBaseBytes` and the push's allotment. */
21
+ const rowBodyBytes = (size) => Math.ceil(size * 4 / 3);
22
+ const cachedBaseBytes = (entry) => entry.kind === "row" ? rowBodyBytes(entry.header.size) : entry.object.bytes.byteLength;
23
+ /**
24
+ * A bounded per-receive cache for one `receiveRows` call: observes what `headers` and `held` read
25
+ * (within `receiveBaseBytes`, `receiveLocatedMost`, and `charge`) and answers repeat `headers`,
26
+ * `held`, and `heldIn` asks without re-reading the store. Past any bound or with no memory room,
27
+ * misses fall back to `reader`.
28
+ */
29
+ const createReceiveCache = (charge) => {
30
+ const bodies = chargedCache(charge, {
31
+ maxBytes: receiveBaseBytes,
32
+ entryOverhead: receiveEntryOverheadBytes,
33
+ weight: cachedBaseBytes,
34
+ evict: "none"
35
+ });
36
+ const locations = chargedCache(charge, {
37
+ maxBytes: 0,
38
+ maxEntries: receiveLocatedMost,
39
+ entryOverhead: receiveEntryOverheadBytes,
40
+ weight: () => 0,
41
+ evict: "none"
42
+ });
43
+ const keepWhole = (object) => {
44
+ const existing = bodies.get(object.oid);
45
+ if (existing !== void 0 && existing.kind !== "row") return;
46
+ bodies.set(object.oid, {
47
+ kind: "whole",
48
+ object
49
+ });
50
+ };
51
+ const observe = {
52
+ located: (oid, pack) => {
53
+ if (locations.has(oid)) return;
54
+ locations.set(oid, pack);
55
+ },
56
+ row: (row, header) => {
57
+ if (bodies.has(row.id) || chunkedOf(row.value) !== void 0) return;
58
+ bodies.set(row.id, {
59
+ kind: "row",
60
+ row,
61
+ header
62
+ });
63
+ },
64
+ whole: keepWhole
65
+ };
66
+ const wrap = (reader) => ({
67
+ each: Effect.fnUntraced(function* (oids, take) {
68
+ const seen = /* @__PURE__ */ new Set();
69
+ const missing = [];
70
+ for (const oid of oids) {
71
+ if (seen.has(oid)) continue;
72
+ seen.add(oid);
73
+ const kept = bodies.get(oid);
74
+ if (kept !== void 0) {
75
+ const object = kept.kind === "whole" ? kept.object : yield* objectOfRow(kept.row);
76
+ if (kept.kind === "row") keepWhole(object);
77
+ yield* take(object);
78
+ } else missing.push(oid);
79
+ }
80
+ if (missing.length > 0) yield* reader.each(missing, take);
81
+ }),
82
+ headers: Effect.fnUntraced(function* (oids) {
83
+ const answer = /* @__PURE__ */ new Map();
84
+ const missing = [];
85
+ for (const oid of oids) {
86
+ const kept = bodies.get(oid);
87
+ if (kept !== void 0) answer.set(oid, kept.kind === "row" ? kept.header : {
88
+ type: kept.object.type,
89
+ size: kept.object.bytes.byteLength
90
+ });
91
+ else missing.push(oid);
92
+ }
93
+ if (missing.length > 0) for (const [oid, header] of yield* reader.headers(missing)) answer.set(oid, header);
94
+ return answer;
95
+ }),
96
+ held: Effect.fnUntraced(function* (oids) {
97
+ const answer = /* @__PURE__ */ new Map();
98
+ const missing = [];
99
+ for (const oid of oids) {
100
+ const kept = bodies.get(oid);
101
+ if (kept !== void 0) {
102
+ const object = kept.kind === "whole" ? kept.object : yield* objectOfRow(kept.row);
103
+ if (kept.kind === "row") keepWhole(object);
104
+ answer.set(oid, object);
105
+ } else missing.push(oid);
106
+ }
107
+ if (missing.length > 0) for (const [oid, object] of yield* reader.held(missing)) answer.set(oid, object);
108
+ return answer;
109
+ }),
110
+ heldIn: Effect.fnUntraced(function* (oids) {
111
+ const answer = /* @__PURE__ */ new Map();
112
+ const missing = [];
113
+ for (const oid of oids) if (locations.has(oid)) answer.set(oid, locations.get(oid));
114
+ else missing.push(oid);
115
+ if (missing.length > 0) for (const [oid, pack] of yield* reader.heldIn(missing)) answer.set(oid, pack);
116
+ return answer;
117
+ })
118
+ });
119
+ const dropLocations = () => {
120
+ locations.clear();
121
+ };
122
+ const release = () => {
123
+ locations.release();
124
+ bodies.release();
125
+ };
126
+ const clear = () => {
127
+ locations.release();
128
+ bodies.release();
129
+ };
130
+ return {
131
+ observe,
132
+ bodies,
133
+ get bodyBytes() {
134
+ return bodies.bytes;
135
+ },
136
+ get chargedBytes() {
137
+ return bodies.chargedBytes + locations.chargedBytes;
138
+ },
139
+ wrap,
140
+ dropLocations,
141
+ release,
142
+ clear
143
+ };
144
+ };
145
+ /** Decodes a cached base object as a `WholeObject`, hashing inline rows on demand. */
146
+ const wholeOfCached = (cached) => cached.kind === "whole" ? Effect.succeed(cached.object) : objectOfRow(cached.row);
147
+ export { createReceiveCache, receiveBaseBytes, receiveEntryOverheadBytes, receiveLocatedMost, rowBodyBytes, wholeOfCached };
@@ -8,8 +8,8 @@ import { packTypesBytes, typeCode, typeOfByte, writePackTypes } from "../protoco
8
8
  import { compareIds } from "./raw-ids.mjs";
9
9
  import { receiveRunBytes } from "./receive-bounds.mjs";
10
10
  import { StoredRuns, firstBytesOf, mergeRuns, mergedCursor, receiveRuns, steppedWriter } from "./runs.mjs";
11
- import * as Effect from "effect/Effect";
12
11
  import * as Schema from "effect/Schema";
12
+ import * as Effect from "effect/Effect";
13
13
  const noParent = 4294967295;
14
14
  const linkedMark = 2147483648;
15
15
  /**
@@ -7,8 +7,8 @@ import { compareIds } from "./raw-ids.mjs";
7
7
  import { mistyped, objectMissing, shallowRoot, wrongType } from "./links.mjs";
8
8
  import { receiveLinkSpillBytes, receiveLinksMost, receiveRunBytes } from "./receive-bounds.mjs";
9
9
  import { StoredRuns, mergedCursor, steppedWriter } from "./runs.mjs";
10
- import * as Effect from "effect/Effect";
11
10
  import * as Schema from "effect/Schema";
11
+ import * as Effect from "effect/Effect";
12
12
  /** A link's place in the push's order: the low 30 bits of its row's word. */
13
13
  const placeMask = 2 ** 30 - 1;
14
14
  const receiveLinkLimits = {
@@ -5,5 +5,5 @@ import "./receive-table.mjs";
5
5
  import "../protocol/objects/checked-blobs.mjs";
6
6
  import "./layout.mjs";
7
7
  import "./memory-budget.mjs";
8
- import "effect/Effect";
9
- import "effect/Schema";
8
+ import "effect/Schema";
9
+ import "effect/Effect";
@@ -1,4 +1,4 @@
1
- import { bucketReading, readWhole } from "./calls.mjs";
1
+ import { bucketReading, bucketTry, readWhole } from "./calls.mjs";
2
2
  import { checkedCarried, receiveChecked, receiveCheckedLimits } from "./fsck.mjs";
3
3
  import { putOnce } from "./index-build.mjs";
4
4
  import { stepKey } from "./layout.mjs";
@@ -9,8 +9,8 @@ import { LinksCarry } from "./receive-links.mjs";
9
9
  import { receiveTableOf } from "./receive-table.mjs";
10
10
  import { StoredRuns } from "./runs.mjs";
11
11
  import { fail } from "../contracts/result.mjs";
12
- import * as Effect from "effect/Effect";
13
12
  import * as Schema from "effect/Schema";
13
+ import * as Effect from "effect/Effect";
14
14
  // src/storage/receive-state.ts
15
15
  const objectType = /* @__PURE__ */ Schema.Literals([
16
16
  "blob",
@@ -109,23 +109,21 @@ const putStepState = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, keys,
109
109
  * `key`'s records of `width` bytes, each handed to `each` as it comes, so none is held whole past
110
110
  * its chunk: the bytes read, past `most` no more, and whether `each` took every one.
111
111
  */
112
- const readRecords = (bucket, key, width, most, each) => bucketReading(bucket, key, void 0, async (body) => {
113
- if (body === void 0) return void 0;
114
- const reader = body.getReader();
112
+ const readRecords = (bucket, key, width, most, each) => bucketReading(bucket, key, void 0, Effect.fnUntraced(function* (reader) {
113
+ if (reader === void 0) return void 0;
115
114
  const record = new Uint8Array(width);
116
115
  let bytes = 0;
117
116
  let taken = true;
118
- for (let next = await reader.read(); !next.done && bytes <= most; next = await reader.read()) for (const byte of next.value) {
117
+ for (let next = yield* bucketTry(() => reader.read()); !next.done && bytes <= most; next = yield* bucketTry(() => reader.read())) for (const byte of next.value) {
119
118
  record[bytes % width] = byte;
120
119
  bytes += 1;
121
120
  if (bytes % width === 0 && bytes <= most) taken = each(record) && taken;
122
121
  }
123
- if (bytes > most) await reader.cancel();
124
122
  return {
125
123
  bytes,
126
124
  taken
127
125
  };
128
- });
126
+ }));
129
127
  /**
130
128
  * The state, table and records a committed step put, which the record names. A state or table
131
129
  * missing or unreadable is `INTERNAL`; records missing, cut short, too long, or holding what no step