@ref0/git 0.6.0 → 0.8.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 (476) hide show
  1. package/dist/access/namespace.d.mts +2 -0
  2. package/dist/access/private-refs.d.mts +6 -29
  3. package/dist/access/private-refs.mjs +26 -13
  4. package/dist/access/public.d.mts +6 -0
  5. package/dist/access/public.mjs +9 -0
  6. package/dist/auth/access-jwt.d.mts +10 -6
  7. package/dist/auth/access-jwt.mjs +59 -40
  8. package/dist/auth/auth-namespace.d.mts +6 -0
  9. package/dist/auth/auth-namespace.mjs +12 -0
  10. package/dist/auth/auth.d.mts +3 -6
  11. package/dist/auth/auth.mjs +2 -9
  12. package/dist/auth/authorize.mjs +35 -29
  13. package/dist/auth/bridge.mjs +8 -8
  14. package/dist/auth/fences.d.mts +1 -2
  15. package/dist/auth/fences.mjs +1 -1
  16. package/dist/auth/grants.d.mts +0 -1
  17. package/dist/auth/grants.mjs +2 -2
  18. package/dist/auth/host-function.d.mts +1 -7
  19. package/dist/auth/host-function.mjs +51 -42
  20. package/dist/auth/identify.d.mts +0 -1
  21. package/dist/auth/identify.mjs +3 -2
  22. package/dist/auth/namespaces.d.mts +2 -2
  23. package/dist/auth/policy.d.mts +7 -4
  24. package/dist/auth/policy.mjs +13 -10
  25. package/dist/auth/token-rows.mjs +3 -6
  26. package/dist/auth/tokens-layer.d.mts +40 -0
  27. package/dist/auth/tokens-layer.mjs +29 -0
  28. package/dist/auth/tokens-namespace.d.mts +2 -0
  29. package/dist/auth/tokens-public.d.mts +6 -0
  30. package/dist/auth/tokens-public.mjs +31 -0
  31. package/dist/auth/tokens.d.mts +19 -7
  32. package/dist/auth/tokens.mjs +12 -6
  33. package/dist/auth.d.mts +2 -2
  34. package/dist/auth.mjs +2 -2
  35. package/dist/client/client.d.mts +22 -15
  36. package/dist/client/client.mjs +31 -27
  37. package/dist/client/git-http.mjs +23 -6
  38. package/dist/client/local.mjs +5 -4
  39. package/dist/client/namespace.d.mts +2 -0
  40. package/dist/client/push-upload.d.mts +1 -0
  41. package/dist/client/push-upload.mjs +169 -2
  42. package/dist/client/remote-helper.mjs +5 -12
  43. package/dist/client/remote.mjs +63 -22
  44. package/dist/client/run-remote-helper.d.mts +1 -1
  45. package/dist/client/run-remote-helper.mjs +6 -6
  46. package/dist/client/slice-push.d.mts +1 -1
  47. package/dist/client/transport.mjs +26 -19
  48. package/dist/contracts/access.d.mts +18 -10
  49. package/dist/contracts/access.mjs +17 -0
  50. package/dist/contracts/actors.d.mts +73 -28
  51. package/dist/contracts/actors.mjs +45 -2
  52. package/dist/contracts/authorize.d.mts +26 -17
  53. package/dist/contracts/blobs.d.mts +1 -1
  54. package/dist/contracts/blobs.mjs +1 -1
  55. package/dist/contracts/callers.mjs +40 -0
  56. package/dist/contracts/calls-spent.d.mts +6 -4
  57. package/dist/contracts/calls-spent.mjs +10 -8
  58. package/dist/contracts/client.d.mts +16 -9
  59. package/dist/contracts/commits.d.mts +2 -2
  60. package/dist/contracts/commits.mjs +1 -1
  61. package/dist/contracts/engine.d.mts +1 -1
  62. package/dist/contracts/events.d.mts +45 -32
  63. package/dist/contracts/events.mjs +21 -10
  64. package/dist/contracts/files.d.mts +44 -44
  65. package/dist/contracts/files.mjs +1 -1
  66. package/dist/contracts/forks.d.mts +34 -58
  67. package/dist/contracts/forks.mjs +1 -1
  68. package/dist/contracts/git-events.d.mts +50 -0
  69. package/dist/contracts/git-events.mjs +23 -0
  70. package/dist/contracts/git-hooks.d.mts +254 -0
  71. package/dist/contracts/git-hooks.mjs +12 -0
  72. package/dist/contracts/git.d.mts +93 -42
  73. package/dist/contracts/git.mjs +6 -5
  74. package/dist/contracts/grants.d.mts +46 -27
  75. package/dist/contracts/ids.d.mts +16 -0
  76. package/dist/contracts/ids.mjs +19 -4
  77. package/dist/contracts/lfs.d.mts +19 -4
  78. package/dist/contracts/merges.d.mts +7 -7
  79. package/dist/contracts/namespaces.d.mts +2 -2
  80. package/dist/contracts/objects.d.mts +21 -5
  81. package/dist/contracts/opaque.mjs +27 -0
  82. package/dist/contracts/operations.d.mts +301 -101
  83. package/dist/contracts/operations.mjs +209 -0
  84. package/dist/contracts/promises.d.mts +2 -0
  85. package/dist/contracts/push-uploads.d.mts +4 -1
  86. package/dist/contracts/push-uploads.mjs +9 -4
  87. package/dist/contracts/queue.d.mts +220 -49
  88. package/dist/contracts/queue.mjs +68 -6
  89. package/dist/contracts/refs.d.mts +30 -8
  90. package/dist/contracts/refs.mjs +1 -1
  91. package/dist/contracts/remote.d.mts +53 -23
  92. package/dist/contracts/remote.mjs +22 -0
  93. package/dist/contracts/repo-records.d.mts +2 -2
  94. package/dist/contracts/repos.d.mts +100 -82
  95. package/dist/contracts/repos.mjs +47 -8
  96. package/dist/contracts/result.d.mts +73 -41
  97. package/dist/contracts/result.mjs +74 -17
  98. package/dist/contracts/rules.d.mts +734 -68
  99. package/dist/contracts/rules.mjs +84 -1
  100. package/dist/contracts/server.d.mts +20 -206
  101. package/dist/contracts/services.d.mts +1 -10
  102. package/dist/contracts/services.mjs +1 -5
  103. package/dist/contracts/signin.d.mts +140 -43
  104. package/dist/contracts/signin.mjs +36 -3
  105. package/dist/contracts/store.d.mts +1 -1
  106. package/dist/contracts/sync.d.mts +109 -90
  107. package/dist/contracts/sync.mjs +34 -7
  108. package/dist/contracts/tags.d.mts +1 -1
  109. package/dist/contracts/tags.mjs +1 -1
  110. package/dist/contracts/tokens.d.mts +247 -60
  111. package/dist/contracts/tokens.mjs +93 -21
  112. package/dist/contracts/topics.d.mts +59 -20
  113. package/dist/contracts/topics.mjs +14 -5
  114. package/dist/contracts/trees.d.mts +2 -2
  115. package/dist/contracts/trees.mjs +1 -1
  116. package/dist/contracts/work.d.mts +2 -2
  117. package/dist/contracts/work.mjs +2 -2
  118. package/dist/core/access.d.mts +10 -12
  119. package/dist/core/access.mjs +45 -11
  120. package/dist/core/clock.mjs +1 -1
  121. package/dist/core/events/deliver.d.mts +3 -2
  122. package/dist/core/events/deliver.mjs +188 -92
  123. package/dist/core/forks.mjs +78 -34
  124. package/dist/core/hooks/groups.d.mts +26 -0
  125. package/dist/core/hooks/groups.mjs +73 -0
  126. package/dist/core/hooks/namespace.d.mts +2 -0
  127. package/dist/core/hooks/order.d.mts +2 -2
  128. package/dist/core/hooks/order.mjs +6 -6
  129. package/dist/core/hooks/public.d.mts +7 -0
  130. package/dist/core/hooks/public.mjs +5 -0
  131. package/dist/core/imports.mjs +94 -10
  132. package/dist/core/index-job.mjs +11 -8
  133. package/dist/core/loose-tally.mjs +46 -0
  134. package/dist/core/merge-parts.d.mts +1 -1
  135. package/dist/core/merge-parts.mjs +1 -1
  136. package/dist/core/mirror-rows.mjs +18 -0
  137. package/dist/core/names.mjs +1 -1
  138. package/dist/core/namespaces.d.mts +2 -1
  139. package/dist/core/objects/commit-writes.mjs +5 -5
  140. package/dist/core/objects/merges.mjs +1 -1
  141. package/dist/core/objects/objects-layer.mjs +1 -1
  142. package/dist/core/objects/reading.mjs +52 -7
  143. package/dist/core/objects/tree-edits.mjs +13 -28
  144. package/dist/core/objects/trees.mjs +4 -4
  145. package/dist/core/objects/writing.mjs +4 -3
  146. package/dist/core/own-writes.mjs +1 -1
  147. package/dist/core/parts.d.mts +22 -3
  148. package/dist/core/parts.mjs +5 -3
  149. package/dist/core/promise.mjs +23 -17
  150. package/dist/core/purge.d.mts +2 -2
  151. package/dist/core/purge.mjs +89 -34
  152. package/dist/core/push.mjs +67 -79
  153. package/dist/core/receipts.d.mts +2 -2
  154. package/dist/core/receipts.mjs +28 -4
  155. package/dist/core/ref-index-job.mjs +4 -4
  156. package/dist/core/ref-view.mjs +16 -8
  157. package/dist/core/refs.mjs +41 -10
  158. package/dist/core/registered-records.mjs +30 -0
  159. package/dist/core/{claim-rows.mjs → registered-rows.mjs} +6 -6
  160. package/dist/core/repack.d.mts +2 -2
  161. package/dist/core/repack.mjs +30 -23
  162. package/dist/core/repo-info.mjs +62 -26
  163. package/dist/core/repos.mjs +18 -11
  164. package/dist/core/rules/changes.mjs +2 -2
  165. package/dist/core/rules/check.mjs +10 -10
  166. package/dist/core/rules/commit-changes.mjs +1 -1
  167. package/dist/core/rules/context.d.mts +7 -6
  168. package/dist/core/rules/context.mjs +18 -16
  169. package/dist/core/rules/fetch.mjs +78 -31
  170. package/dist/core/saved-caller-views.d.mts +72 -0
  171. package/dist/core/saved-caller-views.mjs +123 -0
  172. package/dist/core/saved-callers-public.d.mts +5 -0
  173. package/dist/core/saved-callers-public.mjs +10 -0
  174. package/dist/core/saved-callers.mjs +95 -0
  175. package/dist/core/seam.d.mts +12 -1
  176. package/dist/core/seam.mjs +4 -2
  177. package/dist/core/tokens.mjs +7 -2
  178. package/dist/core/view.d.mts +1 -1
  179. package/dist/core/view.mjs +1 -1
  180. package/dist/core/work.mjs +6 -5
  181. package/dist/effect.d.mts +2 -4
  182. package/dist/effect.mjs +2 -4
  183. package/dist/engine/commits.mjs +19 -47
  184. package/dist/engine/content.d.mts +2 -2
  185. package/dist/engine/content.mjs +1 -1
  186. package/dist/engine/diff.mjs +2 -2
  187. package/dist/engine/failures.d.mts +1 -2
  188. package/dist/engine/failures.mjs +1 -3
  189. package/dist/engine/merge-base-walk.mjs +57 -142
  190. package/dist/engine/merge-bases.mjs +5 -5
  191. package/dist/engine/merge-renames.mjs +1 -1
  192. package/dist/engine/merge.mjs +16 -14
  193. package/dist/engine/reads.d.mts +2 -2
  194. package/dist/engine/reads.mjs +1 -1
  195. package/dist/engine/xdiff.d.mts +1 -1
  196. package/dist/engine/xdiff.mjs +2 -2
  197. package/dist/event-streams/event-streams.d.mts +6 -2
  198. package/dist/event-streams/event-streams.mjs +6 -2
  199. package/dist/event-streams/stream.mjs +5 -2
  200. package/dist/extend.d.mts +2 -3
  201. package/dist/extend.mjs +2 -2
  202. package/dist/http/answers.mjs +4 -3
  203. package/dist/http/core-parts.mjs +3 -4
  204. package/dist/http/handler.mjs +12 -32
  205. package/dist/http/parts.d.mts +1 -1
  206. package/dist/http/push-uploads.mjs +7 -5
  207. package/dist/http/receive-pack.mjs +3 -3
  208. package/dist/http/upload-pack.mjs +6 -5
  209. package/dist/index.d.mts +44 -24
  210. package/dist/index.mjs +17 -8
  211. package/dist/lfs/base.d.mts +8 -5
  212. package/dist/lfs/base.mjs +2 -1
  213. package/dist/lfs/calls.mjs +3 -2
  214. package/dist/lfs/layer.d.mts +9 -7
  215. package/dist/lfs/layer.mjs +37 -22
  216. package/dist/lfs/locks.mjs +3 -3
  217. package/dist/lfs/objects.d.mts +3 -2
  218. package/dist/lfs/objects.mjs +235 -71
  219. package/dist/lfs/pointers.mjs +70 -19
  220. package/dist/lfs/purge.mjs +7 -3
  221. package/dist/lfs/rows.mjs +25 -8
  222. package/dist/lfs/service.d.mts +6 -3
  223. package/dist/lfs/service.mjs +8 -2
  224. package/dist/lfs/upkeep.mjs +53 -31
  225. package/dist/lfs/upload-most.mjs +41 -0
  226. package/dist/lfs/uploaded.mjs +59 -0
  227. package/dist/lfs/wire.mjs +1 -1
  228. package/dist/protocol/bytes/buffers.d.mts +1 -1
  229. package/dist/protocol/bytes/buffers.mjs +1 -1
  230. package/dist/protocol/bytes/deflate.d.mts +1 -1
  231. package/dist/protocol/bytes/deflate.mjs +1 -1
  232. package/dist/protocol/bytes/hmac-sha256.mjs +3 -6
  233. package/dist/protocol/bytes/inflate.d.mts +1 -1
  234. package/dist/protocol/bytes/inflate.mjs +1 -1
  235. package/dist/protocol/bytes/sha1.d.mts +1 -1
  236. package/dist/protocol/bytes/sha1.mjs +2 -2
  237. package/dist/protocol/bytes/sha256-hasher.mjs +51 -0
  238. package/dist/protocol/bytes/text.mjs +6 -1
  239. package/dist/protocol/diff/read.d.mts +1 -1
  240. package/dist/protocol/diff/read.mjs +1 -1
  241. package/dist/protocol/diff/tree-diff.d.mts +1 -1
  242. package/dist/protocol/diff/tree-diff.mjs +11 -11
  243. package/dist/protocol/objects/fsck.mjs +6 -3
  244. package/dist/protocol/objects/lfs-pointer.mjs +6 -1
  245. package/dist/protocol/objects/tag.mjs +1 -1
  246. package/dist/protocol/objects/tree.mjs +1 -1
  247. package/dist/protocol/packs/graph.mjs +1 -1
  248. package/dist/protocol/packs/idx.d.mts +1 -1
  249. package/dist/protocol/packs/idx.mjs +1 -1
  250. package/dist/protocol/packs/parts.mjs +1 -1
  251. package/dist/protocol/packs/reader.d.mts +1 -1
  252. package/dist/protocol/packs/reader.mjs +2 -2
  253. package/dist/protocol/packs/write-error.d.mts +1 -1
  254. package/dist/protocol/packs/write-error.mjs +1 -1
  255. package/dist/protocol/packs/writer.mjs +4 -4
  256. package/dist/protocol/wire/advertisement.d.mts +1 -1
  257. package/dist/protocol/wire/advertisement.mjs +1 -1
  258. package/dist/protocol/wire/fetch.d.mts +1 -1
  259. package/dist/protocol/wire/fetch.mjs +1 -1
  260. package/dist/protocol/wire/lines.d.mts +1 -1
  261. package/dist/protocol/wire/lines.mjs +2 -2
  262. package/dist/protocol/wire/push-uploads.mjs +4 -2
  263. package/dist/protocol/wire/receive-pack.d.mts +1 -1
  264. package/dist/protocol/wire/receive-pack.mjs +1 -1
  265. package/dist/protocol/wire/report-status.d.mts +1 -1
  266. package/dist/protocol/wire/report-status.mjs +1 -1
  267. package/dist/protocol/wire/v2.d.mts +2 -2
  268. package/dist/protocol/wire/v2.mjs +2 -2
  269. package/dist/queue/advance.mjs +190 -68
  270. package/dist/queue/callers.mjs +56 -69
  271. package/dist/queue/calls.mjs +10 -11
  272. package/dist/queue/commit.mjs +28 -22
  273. package/dist/queue/host.d.mts +10 -11
  274. package/dist/queue/host.mjs +15 -7
  275. package/dist/queue/lanes.mjs +9 -18
  276. package/dist/queue/layer.d.mts +3 -3
  277. package/dist/queue/layer.mjs +11 -10
  278. package/dist/queue/limits.mjs +17 -5
  279. package/dist/queue/rows.mjs +13 -10
  280. package/dist/queue/schedule.mjs +7 -6
  281. package/dist/queue/search.mjs +11 -17
  282. package/dist/queue/state.mjs +7 -2
  283. package/dist/queue/trim.mjs +10 -5
  284. package/dist/rest/api.d.mts +1 -1
  285. package/dist/rest/blobs.d.mts +20 -20
  286. package/dist/rest/caller.d.mts +22 -20
  287. package/dist/rest/client-namespace.d.mts +2 -0
  288. package/dist/rest/client.d.mts +32 -8
  289. package/dist/rest/client.mjs +314 -388
  290. package/dist/rest/commits.d.mts +284 -284
  291. package/dist/rest/errors.d.mts +10 -10
  292. package/dist/rest/errors.mjs +1 -1
  293. package/dist/rest/events.d.mts +13 -11
  294. package/dist/rest/events.mjs +3 -1
  295. package/dist/rest/files.d.mts +48 -48
  296. package/dist/rest/forks.d.mts +131 -143
  297. package/dist/rest/handler.mjs +4 -3
  298. package/dist/rest/handlers.mjs +15 -8
  299. package/dist/rest/layer.d.mts +3 -3
  300. package/dist/rest/layer.mjs +8 -7
  301. package/dist/rest/listen.d.mts +8 -6
  302. package/dist/rest/listen.mjs +33 -77
  303. package/dist/rest/me.d.mts +18 -20
  304. package/dist/rest/me.mjs +1 -1
  305. package/dist/rest/merges.d.mts +17 -17
  306. package/dist/rest/queue.d.mts +140 -140
  307. package/dist/rest/queue.mjs +1 -1
  308. package/dist/rest/refs.d.mts +214 -214
  309. package/dist/rest/refs.mjs +1 -1
  310. package/dist/rest/repos.d.mts +123 -135
  311. package/dist/rest/tags.d.mts +30 -30
  312. package/dist/rest/tokens.d.mts +250 -260
  313. package/dist/rest/tokens.mjs +10 -42
  314. package/dist/rest/topics.d.mts +162 -162
  315. package/dist/rest/topics.mjs +1 -1
  316. package/dist/rest/trees.d.mts +117 -117
  317. package/dist/rest/wire.d.mts +7 -5
  318. package/dist/rest/wire.mjs +4 -3
  319. package/dist/rest/work.d.mts +69 -69
  320. package/dist/rest/work.mjs +1 -1
  321. package/dist/rest.d.mts +1 -7
  322. package/dist/rest.mjs +1 -5
  323. package/dist/server/check-fetch.mjs +9 -0
  324. package/dist/server/extension.mjs +3 -115
  325. package/dist/server/git-layer.d.mts +30 -5
  326. package/dist/server/git-layer.mjs +59 -29
  327. package/dist/server/git-namespace.d.mts +4 -4
  328. package/dist/server/git-namespace.mjs +6 -4
  329. package/dist/server/joined.d.mts +83 -0
  330. package/dist/server/joined.mjs +91 -0
  331. package/dist/server/registry.d.mts +7 -3
  332. package/dist/server/registry.mjs +135 -31
  333. package/dist/server/server.d.mts +9 -3
  334. package/dist/server/server.mjs +277 -208
  335. package/dist/signin/context.d.mts +2 -2
  336. package/dist/signin/context.mjs +28 -37
  337. package/dist/signin/device.mjs +5 -5
  338. package/dist/signin/forms.mjs +1 -1
  339. package/dist/signin/grants.d.mts +2 -3
  340. package/dist/signin/grants.mjs +5 -5
  341. package/dist/signin/layer.d.mts +9 -0
  342. package/dist/signin/layer.mjs +41 -0
  343. package/dist/signin/namespace.d.mts +2 -0
  344. package/dist/signin/public.d.mts +6 -0
  345. package/dist/signin/public.mjs +5 -0
  346. package/dist/signin/route.mjs +47 -21
  347. package/dist/signin/web.mjs +3 -3
  348. package/dist/signin/wire.mjs +1 -1
  349. package/dist/storage/calls.d.mts +1 -1
  350. package/dist/storage/calls.mjs +4 -4
  351. package/dist/storage/clean-up.mjs +15 -6
  352. package/dist/storage/counted-bucket.mjs +34 -51
  353. package/dist/storage/fetch.mjs +1 -1
  354. package/dist/storage/fsck.mjs +12 -2
  355. package/dist/storage/graph-rebuild.mjs +262 -0
  356. package/dist/storage/host-bucket.mjs +1 -1
  357. package/dist/storage/index-build.d.mts +2 -2
  358. package/dist/storage/index-build.mjs +103 -15
  359. package/dist/storage/index-fetch.mjs +10 -6
  360. package/dist/storage/index-graph.mjs +1 -1
  361. package/dist/storage/index-layers.mjs +1 -1
  362. package/dist/storage/index-visible.mjs +1 -1
  363. package/dist/storage/lfs-pointers.d.mts +5 -5
  364. package/dist/storage/lfs-pointers.mjs +37 -11
  365. package/dist/storage/loose.mjs +4 -1
  366. package/dist/storage/memory-budget.mjs +8 -2
  367. package/dist/storage/merge-cut.mjs +24 -1
  368. package/dist/storage/merge-fence.mjs +82 -20
  369. package/dist/storage/merge-most.mjs +1 -0
  370. package/dist/storage/merge-plan.mjs +5 -2
  371. package/dist/storage/merge-row.mjs +17 -5
  372. package/dist/storage/merge-stream.mjs +25 -13
  373. package/dist/storage/merge-write.mjs +1 -1
  374. package/dist/storage/merge.d.mts +2 -2
  375. package/dist/storage/merge.mjs +1 -1
  376. package/dist/storage/object-rows.d.mts +2 -2
  377. package/dist/storage/object-rows.mjs +20 -4
  378. package/dist/storage/pack-ranges.d.mts +3 -1
  379. package/dist/storage/pack-ranges.mjs +168 -69
  380. package/dist/storage/pack-reads.mjs +4 -4
  381. package/dist/storage/pack-receive.d.mts +1 -1
  382. package/dist/storage/pack-receive.mjs +17 -15
  383. package/dist/storage/packs.d.mts +1 -1
  384. package/dist/storage/packs.mjs +103 -79
  385. package/dist/storage/placed-reads.mjs +81 -15
  386. package/dist/storage/prune-seen.mjs +126 -0
  387. package/dist/storage/prune-walk.mjs +87 -99
  388. package/dist/storage/prune.mjs +113 -50
  389. package/dist/storage/push-uploads.mjs +4 -2
  390. package/dist/storage/quarantine.d.mts +2 -2
  391. package/dist/storage/ready.d.mts +2 -2
  392. package/dist/storage/ready.mjs +15 -6
  393. package/dist/storage/receive-files.mjs +1 -1
  394. package/dist/storage/receive-links.mjs +1 -1
  395. package/dist/storage/receive-state.d.mts +2 -2
  396. package/dist/storage/receive-state.mjs +2 -2
  397. package/dist/storage/receive-steps.mjs +1 -1
  398. package/dist/storage/repack-contained.mjs +24 -16
  399. package/dist/storage/repack-job.d.mts +2 -2
  400. package/dist/storage/repack-job.mjs +5 -4
  401. package/dist/storage/repack.d.mts +2 -2
  402. package/dist/storage/repack.mjs +12 -5
  403. package/dist/storage/rows.d.mts +2 -2
  404. package/dist/storage/rows.mjs +1 -1
  405. package/dist/storage/runs.d.mts +2 -2
  406. package/dist/storage/runs.mjs +15 -6
  407. package/dist/storage/send-list.mjs +6 -6
  408. package/dist/storage/single-flight.mjs +2 -2
  409. package/dist/storage/swap-walk.mjs +1 -1
  410. package/dist/storage/unpack.mjs +8 -1
  411. package/dist/store/call-count.d.mts +24 -4
  412. package/dist/store/call-count.mjs +158 -44
  413. package/dist/store/catalogue.d.mts +1 -1
  414. package/dist/store/catalogue.mjs +2 -2
  415. package/dist/store/crossing.mjs +2 -6
  416. package/dist/store/cursor-seal.mjs +1 -1
  417. package/dist/store/errors.d.mts +7 -3
  418. package/dist/store/errors.mjs +41 -13
  419. package/dist/store/job-try.mjs +119 -15
  420. package/dist/store/list-job.mjs +5 -5
  421. package/dist/store/outbox.d.mts +2 -2
  422. package/dist/store/outbox.mjs +75 -16
  423. package/dist/store/promises.d.mts +2 -2
  424. package/dist/store/promises.mjs +31 -6
  425. package/dist/store/queue-jobs.mjs +1 -1
  426. package/dist/store/records.d.mts +2 -2
  427. package/dist/store/records.mjs +22 -24
  428. package/dist/store/ref-rows.d.mts +2 -2
  429. package/dist/store/ref-rows.mjs +6 -6
  430. package/dist/store/repo-record.mjs +29 -12
  431. package/dist/store/reservations.mjs +35 -8
  432. package/dist/store/scopes.mjs +12 -5
  433. package/dist/store/topic-jobs.mjs +8 -8
  434. package/dist/sync/bound.d.mts +1 -3
  435. package/dist/sync/bound.mjs +30 -42
  436. package/dist/sync/github.d.mts +5 -6
  437. package/dist/sync/github.mjs +37 -42
  438. package/dist/sync/http.mjs +15 -0
  439. package/dist/sync/import.mjs +30 -19
  440. package/dist/sync/layer.d.mts +13 -0
  441. package/dist/sync/layer.mjs +73 -0
  442. package/dist/sync/mirror.mjs +137 -58
  443. package/dist/sync/publish.mjs +3 -6
  444. package/dist/sync/step.mjs +223 -85
  445. package/dist/sync/tries.mjs +22 -15
  446. package/dist/sync.d.mts +3 -6
  447. package/dist/sync.mjs +3 -6
  448. package/dist/topics/advance.mjs +210 -94
  449. package/dist/topics/calls.mjs +8 -8
  450. package/dist/topics/directory.mjs +35 -12
  451. package/dist/topics/host.d.mts +5 -8
  452. package/dist/topics/host.mjs +42 -19
  453. package/dist/topics/layer.d.mts +381 -0
  454. package/dist/topics/layer.mjs +62 -0
  455. package/dist/topics/members.mjs +39 -10
  456. package/dist/topics/namespace.d.mts +2 -0
  457. package/dist/topics/public.d.mts +6 -0
  458. package/dist/topics/public.mjs +13 -0
  459. package/dist/topics/rows.mjs +12 -3
  460. package/dist/topics/topic.mjs +11 -10
  461. package/package.json +8 -13
  462. package/dist/access.d.mts +0 -2
  463. package/dist/access.mjs +0 -1
  464. package/dist/core/hooks/post-receive.mjs +0 -216
  465. package/dist/core/hooks/pre-receive.d.mts +0 -12
  466. package/dist/core/hooks/pre-receive.mjs +0 -36
  467. package/dist/engine/merge-base-walk.d.mts +0 -3
  468. package/dist/server/extension.d.mts +0 -21
  469. package/dist/server/routes.d.mts +0 -32
  470. package/dist/server/routes.mjs +0 -69
  471. package/dist/sync/import.d.mts +0 -10
  472. package/dist/sync/jobs.d.mts +0 -9
  473. package/dist/sync/jobs.mjs +0 -75
  474. package/dist/sync/mirror.d.mts +0 -13
  475. package/dist/sync/publish.d.mts +0 -6
  476. /package/dist/core/{claim-rows.d.mts → registered-rows.d.mts} +0 -0
@@ -5,8 +5,8 @@ import { boundedBytes } from "../protocol/bytes/reader.mjs";
5
5
  import { jsonIssue } from "../protocol/wire/json.mjs";
6
6
  import { emptyReads, emptyReadsMost } from "./answer.mjs";
7
7
  import { bodyText, dropped, remoteFetch } from "./transport.mjs";
8
- import * as Schema from "effect/Schema";
9
8
  import * as Effect from "effect/Effect";
9
+ import * as Schema from "effect/Schema";
10
10
  // src/client/git-http.ts
11
11
  /**
12
12
  * Git's smart HTTP as a client sends it, as `gitprotocol-http` says: `info/refs` for a service's
@@ -166,15 +166,32 @@ const gitHttp = (options) => {
166
166
  method: "POST",
167
167
  ...init
168
168
  })), answered));
169
+ /** A POST to `path` of a body `open` streams, a request made afresh for each send. */
170
+ const sendStreamed = (path, init, open) => Effect.suspend(() => {
171
+ const at = `${base}/${path}`;
172
+ const made = () => {
173
+ const streamed = {
174
+ method: "POST",
175
+ ...init,
176
+ body: open(),
177
+ duplex: "half"
178
+ };
179
+ return new Request(at, streamed);
180
+ };
181
+ return Effect.flatMap(answer(made), answered);
182
+ });
169
183
  return {
170
184
  advertisement,
171
- post: (service, protocol, body) => send(service, {
172
- headers: headers(protocol, {
185
+ post: (service, protocol, body) => {
186
+ const init = { headers: headers(protocol, {
173
187
  accept: `application/x-${service}-result`,
174
188
  "content-type": `application/x-${service}-request`
175
- }),
176
- body
177
- }),
189
+ }) };
190
+ return body instanceof Uint8Array ? send(service, {
191
+ ...init,
192
+ body
193
+ }) : sendStreamed(service, init, body);
194
+ },
178
195
  postJson: (path, body) => Effect.flatMap(requestJson(body), (json) => send(path, {
179
196
  headers: { "content-type": "application/json" },
180
197
  body: json
@@ -26,11 +26,11 @@ import { doorBucket, openDoor, promisesClock, promisesStore } from "../store/pro
26
26
  import { newInternalId } from "../store/scopes.mjs";
27
27
  import { defaultFetchLimits } from "../storage/fetch.mjs";
28
28
  import { loose } from "../storage/loose.mjs";
29
- import { Bucket, Records } from "@ref0/infra";
30
29
  import * as Effect from "effect/Effect";
31
- import * as Context from "effect/Context";
32
- import * as Cause from "effect/Cause";
33
30
  import * as Option from "effect/Option";
31
+ import * as Cause from "effect/Cause";
32
+ import { Bucket, Records } from "@ref0/infra";
33
+ import * as Context from "effect/Context";
34
34
  import * as Layer from "effect/Layer";
35
35
  import * as Memory from "@ref0/infra/memory";
36
36
  import * as ManagedRuntime from "effect/ManagedRuntime";
@@ -118,8 +118,9 @@ const localLayer = (options) => Layer.effect(Local, Effect.gen(function* () {
118
118
  check: () => Effect.void
119
119
  }),
120
120
  hiddenRefs: () => gitsOwnRefs,
121
+ publishedRefs: () => [],
121
122
  grants: heldGrants(),
122
- checks: { reports: {} },
123
+ checks: {},
123
124
  repackJobRow: (at) => repackJobRow(repack, at),
124
125
  jobs: noRepackRetry,
125
126
  events: void 0
@@ -0,0 +1,2 @@
1
+ import { client_d_exports } from "./client.mjs";
2
+ export { client_d_exports as GitClient };
@@ -1,6 +1,7 @@
1
1
  import { GitError } from "../contracts/result.mjs";
2
2
  import "./git-http.mjs";
3
3
  import * as Effect from "effect/Effect";
4
+ import "effect/Context";
4
5
  /**
5
6
  * A push's pack uploaded straight to the remote's bucket, as `push-upload=<above>` offers: begin,
6
7
  * then for each part a signed link and the part PUT to it, then complete, which answers as
@@ -1,15 +1,182 @@
1
1
  import { PushUploadPart, PushUploadStarted } from "../contracts/push-uploads.mjs";
2
- import { fail } from "../contracts/result.mjs";
2
+ import { tryUnlessSpent } from "../contracts/calls-spent.mjs";
3
+ import { fail, gitError, isGitError } from "../contracts/result.mjs";
4
+ import { scopedReader } from "../protocol/bytes/reader.mjs";
3
5
  import { decodeJson } from "../protocol/wire/json.mjs";
4
6
  import { pushUploadAbove } from "../protocol/wire/push-uploads.mjs";
7
+ import { readableIn } from "../store/crossing.mjs";
8
+ import { emptyReadsMost } from "./answer.mjs";
5
9
  import { heldBody } from "./git-http.mjs";
6
10
  import * as Effect from "effect/Effect";
11
+ import * as Option from "effect/Option";
12
+ import * as Cause from "effect/Cause";
7
13
  import * as Result from "effect/Result";
14
+ import * as Context from "effect/Context";
15
+ import * as Stream from "effect/Stream";
8
16
  // src/client/push-upload.ts
9
17
  /** The most of a begin's or a part's JSON answer read. */
10
18
  const answerMost = 65536;
11
19
  /** The most parts a push upload takes, as S3's multipart does. */
12
20
  const partsMost = 1e4;
21
+ /**
22
+ * The most of a pack `git-remote-ref0` holds in memory: past it, the pack is spooled to disk and
23
+ * streamed into the push, as Git's own `http.postBuffer` holds 1 MiB before it streams.
24
+ */
25
+ const packHeldMost = 1048576;
26
+ /** How much of a pack a streamed push reads at a time. */
27
+ const packChunk = 65536;
28
+ /**
29
+ * `start`, then `pack` read `packChunk` at a time from its first byte: a plain push's body,
30
+ * streamed afresh each time it's opened, so a send made again reads the pack again. Its pulls run
31
+ * in no call's context: a client reads its own spool and makes no call through Git's doors.
32
+ */
33
+ const packBody = (start, pack) => () => {
34
+ const chunks = Stream.paginate(0, (offset) => {
35
+ const length = Math.min(packChunk, pack.bytes - offset);
36
+ if (length <= 0) return Effect.succeed([[], Option.none()]);
37
+ return Effect.map(pack.read(offset, length), (bytes) => {
38
+ const next = offset + length;
39
+ return [[bytes], next < pack.bytes ? Option.some(next) : Option.none()];
40
+ });
41
+ });
42
+ return readableIn(Stream.concat(Stream.make(start), chunks), Context.empty());
43
+ };
44
+ /** A read of the local repo's pack that failed, for `cause`. */
45
+ const packUnread = (cause) => gitError("UNAVAILABLE", "The local repo's pack couldn't be read", {
46
+ cause,
47
+ hint: "Try again"
48
+ });
49
+ /** A pack read again that came out other than it first did, so an upload of it would be wrong. */
50
+ const packChanged = /* @__PURE__ */ gitError("UNAVAILABLE", "The local repo's pack changed between its reads", { hint: "Push again" });
51
+ /** A read of the local repo's pack that gave more than `emptyReadsMost` empty reads in a row. */
52
+ const packStalled = /* @__PURE__ */ gitError("UNAVAILABLE", `The local repo's pack gave ${emptyReadsMost} empty reads in a row`, { hint: "Push again" });
53
+ /** A read of `reader` that tells a spent call bound from the rest, as `heldBody`'s does. */
54
+ const readOf = (reader) => tryUnlessSpent(() => reader.read(), packUnread);
55
+ /**
56
+ * `pack` read to its end: its chunks held when it ends within `most` bytes, else only counted, the
57
+ * chunks dropped once past `most`, so it holds at most `most` and a chunk. More than
58
+ * `emptyReadsMost` empty reads in a row refuse it.
59
+ */
60
+ const heldOrCounted = (pack, most) => Effect.scoped(Effect.gen(function* () {
61
+ const reader = yield* scopedReader(pack);
62
+ let held = [];
63
+ let bytes = 0;
64
+ let empties = 0;
65
+ for (;;) {
66
+ const next = yield* readOf(reader);
67
+ if (next.done) break;
68
+ if (next.value.byteLength === 0) {
69
+ empties += 1;
70
+ if (empties > 4096) return yield* Effect.fail(packStalled);
71
+ continue;
72
+ }
73
+ empties = 0;
74
+ bytes += next.value.byteLength;
75
+ if (bytes > most) held = void 0;
76
+ else held?.push(next.value);
77
+ }
78
+ return held === void 0 ? {
79
+ kind: "counted",
80
+ bytes
81
+ } : {
82
+ kind: "held",
83
+ chunks: held
84
+ };
85
+ }));
86
+ /**
87
+ * `pack`, a run of the same fetch that `bytes` counted, as a `PackSource` read forward only, as an
88
+ * upload reads its parts: each read starts where the last ended. A run that ends short of `bytes`,
89
+ * or runs past it, is `packChanged`. Its reader is the scope's.
90
+ */
91
+ const packInOrder = /* @__PURE__ */ Effect.fnUntraced(function* (pack, bytes) {
92
+ const reader = yield* scopedReader(pack);
93
+ let at = 0;
94
+ let left = /* @__PURE__ */ new Uint8Array(0);
95
+ return {
96
+ bytes,
97
+ read: Effect.fnUntraced(function* (offset, length) {
98
+ if (offset !== at) return yield* Effect.fail(packChanged);
99
+ const part = new Uint8Array(length);
100
+ let filled = 0;
101
+ let empties = 0;
102
+ while (filled < length) {
103
+ if (left.byteLength === 0) {
104
+ const next = yield* readOf(reader);
105
+ if (next.done) return yield* Effect.fail(packChanged);
106
+ empties = next.value.byteLength === 0 ? empties + 1 : 0;
107
+ if (empties > 4096) return yield* Effect.fail(packStalled);
108
+ left = next.value;
109
+ continue;
110
+ }
111
+ const taken = Math.min(length - filled, left.byteLength);
112
+ part.set(left.subarray(0, taken), filled);
113
+ left = left.subarray(taken);
114
+ filled += taken;
115
+ }
116
+ at += length;
117
+ if (at === bytes && (left.byteLength > 0 || !(yield* endsHere(reader)))) return yield* Effect.fail(packChanged);
118
+ return part;
119
+ })
120
+ };
121
+ });
122
+ /** Whether `reader` has nothing more but empty reads, within `emptyReadsMost` of them. */
123
+ const endsHere = /* @__PURE__ */ Effect.fnUntraced(function* (reader) {
124
+ for (let empties = 0; empties <= emptyReadsMost; empties += 1) {
125
+ const next = yield* readOf(reader);
126
+ if (next.done) return true;
127
+ if (next.value.byteLength > 0) return false;
128
+ }
129
+ return yield* Effect.fail(packStalled);
130
+ });
131
+ /**
132
+ * `pack` as a stream that keeps the first thing that breaks it in `broke`: a failure, or a defect
133
+ * such as a spent call bound's, which dies past the stream's crossing. An interrupt alone, a
134
+ * send that stopped reading, breaks nothing.
135
+ */
136
+ const keptBreak = (pack, broke) => Stream.tapCause(pack, (cause) => Effect.sync(() => {
137
+ if (broke.broke || Cause.hasInterruptsOnly(cause)) return;
138
+ broke.broke = true;
139
+ broke.cause = Cause.squash(cause);
140
+ }));
141
+ const streamOf = (pack) => Stream.fromReadableStream({
142
+ evaluate: () => pack,
143
+ onError: (cause) => cause
144
+ });
145
+ /**
146
+ * `start`, then a pack: a plain push's body, made afresh for each send. The first send takes
147
+ * `first`, the fetch already run, and each later one, a retry or a 401's second send, runs `fetch`
148
+ * again. Its pulls run in `context`, the push's own, so the store calls a run makes count where
149
+ * the push's do. What breaks the last body's pack is kept in `broke`, each body opened afresh, and
150
+ * `unsent` cancels `first` when no send took it.
151
+ */
152
+ const fetchedBody = (start, first, fetch, context) => {
153
+ const broke = {
154
+ broke: false,
155
+ cause: void 0
156
+ };
157
+ let untaken = first;
158
+ const open = () => {
159
+ const taken = untaken;
160
+ untaken = void 0;
161
+ broke.broke = false;
162
+ broke.cause = void 0;
163
+ const pack = taken === void 0 ? Stream.unwrap(Effect.map(fetch, streamOf)) : streamOf(taken);
164
+ return readableIn(Stream.concat(Stream.make(start), keptBreak(pack, broke)), context);
165
+ };
166
+ return {
167
+ open,
168
+ broke,
169
+ unsent: Effect.promise(async () => {
170
+ await untaken?.cancel().catch(() => void 0);
171
+ untaken = void 0;
172
+ })
173
+ };
174
+ };
175
+ /**
176
+ * What a push answers when its pack's read broke, whatever its send answered: the read's own
177
+ * failure, a spent call bound dying as it does, not the send's or the remote's report.
178
+ */
179
+ const brokenBy = (cause) => isGitError(cause) ? Effect.fail(cause) : tryUnlessSpent(() => Promise.reject(cause), packUnread);
13
180
  /** `pack` in memory, as a `PackSource`. */
14
181
  const packInMemory = (pack) => ({
15
182
  bytes: pack.length,
@@ -50,4 +217,4 @@ const uploadPush = /* @__PURE__ */ Effect.fnUntraced(function* (http, begin, pac
50
217
  }
51
218
  return yield* http.postJson(`${upload}/complete`, { parts });
52
219
  });
53
- export { packInMemory, takesUpload, uploadPush };
220
+ export { brokenBy, fetchedBody, heldOrCounted, packBody, packHeldMost, packInMemory, packInOrder, takesUpload, uploadPush };
@@ -1,5 +1,4 @@
1
1
  import { fail } from "../contracts/result.mjs";
2
- import { joinedBytes } from "../protocol/bytes/joined.mjs";
3
2
  import { advertisedSource, pastServiceLine } from "../protocol/wire/advertisement.mjs";
4
3
  import { pushReasonsOf } from "../protocol/wire/push-limits.mjs";
5
4
  import { readPushStart } from "../protocol/wire/receive-pack.mjs";
@@ -7,7 +6,7 @@ import { encodePushReport, readPushReport } from "../protocol/wire/report-status
7
6
  import { advertisementRefused } from "./answer.mjs";
8
7
  import { heldBody } from "./git-http.mjs";
9
8
  import { decodedBy, encodedBy } from "./negotiate.mjs";
10
- import { takesUpload, uploadPush } from "./push-upload.mjs";
9
+ import { packBody, takesUpload, uploadPush } from "./push-upload.mjs";
11
10
  import * as Effect from "effect/Effect";
12
11
  // src/client/remote-helper.ts
13
12
  /**
@@ -66,6 +65,7 @@ const beginOf = (start, bytes) => {
66
65
  if (start.pushOptions.length > 0) begin.pushOptions = start.pushOptions;
67
66
  if (start.capabilities.includes("atomic")) begin.atomic = true;
68
67
  if (start.capabilities.includes("ref0-push-reasons")) begin.reasons = true;
68
+ if (start.shallow.length > 0) begin.shallow = start.shallow;
69
69
  return begin;
70
70
  };
71
71
  /**
@@ -111,21 +111,14 @@ const plainReport = /* @__PURE__ */ Effect.fnUntraced(function* (start, answer)
111
111
  /**
112
112
  * Git's push, `startBytes` and `pack`, sent to the remote: to its bucket in parts when it's past
113
113
  * the remote's `above`, else whole in the push's body as Git wrote it. The report in Git's form,
114
- * and whether the remote unpacked it. A shallow push past `above` is refused, since an upload's
115
- * begin carries no `shallow` lines (Q436).
114
+ * and whether the remote unpacked it. A shallow push's begin names its `shallow` lines.
116
115
  */
117
116
  const relayPush = /* @__PURE__ */ Effect.fnUntraced(function* (http, capabilities, start, startBytes, pack) {
118
- const uploads = forUpload(capabilities, start, pack.bytes);
119
- if (uploads && start.shallow.length > 0) return yield* fail("FAILED_PRECONDITION", "A shallow push can't upload its pack to the bucket", {
120
- context: { reason: "shallow-upload" },
121
- hint: "Push without the helper: a plain push still works, under the platform's request limit"
122
- });
123
- if (uploads) {
117
+ if (forUpload(capabilities, start, pack.bytes)) {
124
118
  const answer = yield* uploadPush(http, beginOf(start, pack.bytes), pack);
125
119
  return yield* askedReport(start, yield* heldBody(answer, reportMost, "report"));
126
120
  }
127
- const packed = pack.bytes === 0 ? /* @__PURE__ */ new Uint8Array() : yield* pack.read(0, pack.bytes);
128
- const answer = yield* http.post("git-receive-pack", "v0", joinedBytes([startBytes, packed]));
121
+ const answer = yield* http.post("git-receive-pack", "v0", packBody(startBytes, pack));
129
122
  return yield* plainReport(start, yield* heldBody(answer, reportMost, "report"));
130
123
  });
131
124
  export { helperAdvertisement, pushStartMost, readHelperStart, relayPush };
@@ -11,6 +11,7 @@ import { joinedBytes } from "../protocol/bytes/joined.mjs";
11
11
  import { isOid } from "../protocol/bytes/text.mjs";
12
12
  import { advertisedSource } from "../protocol/wire/advertisement.mjs";
13
13
  import { encodePushStart, pushOptionsRefusal } from "../protocol/wire/receive-pack.mjs";
14
+ import { pushUploadAbove } from "../protocol/wire/push-uploads.mjs";
14
15
  import { readPushReport } from "../protocol/wire/report-status.mjs";
15
16
  import { encodeV2Request, lsRefsArguments, readLsRefsAnswer, readV2Capabilities } from "../protocol/wire/v2.mjs";
16
17
  import { objectsFace, oneShotReads } from "../storage/calls.mjs";
@@ -20,7 +21,7 @@ import { collections } from "../store/scopes.mjs";
20
21
  import { advertisementRefused } from "./answer.mjs";
21
22
  import { heldBody } from "./git-http.mjs";
22
23
  import { localRepo } from "./local.mjs";
23
- import { packInMemory, takesUpload, uploadPush } from "./push-upload.mjs";
24
+ import { brokenBy, fetchedBody, heldOrCounted, packInOrder, uploadPush } from "./push-upload.mjs";
24
25
  import { decodedBy, encodedBy, negotiate } from "./negotiate.mjs";
25
26
  import * as Effect from "effect/Effect";
26
27
  // src/client/remote.ts
@@ -85,26 +86,45 @@ const discover = /* @__PURE__ */ Effect.fnUntraced(function* (http) {
85
86
  shallows: source.shallows
86
87
  };
87
88
  });
88
- /** The remote's refs under `prefixes`, by name: every one when none is given. */
89
- const remoteRefsOf = /* @__PURE__ */ Effect.fnUntraced(function* (http, upload, prefixes) {
89
+ /**
90
+ * The remote's refs under `prefixes`, by name, every one when none is given, and, `withHead`, the
91
+ * branch its `HEAD` names: v0's `symref` capability, or v2's `ls-refs` asked for `HEAD` and its
92
+ * target in the same call.
93
+ */
94
+ const listedOf = /* @__PURE__ */ Effect.fnUntraced(function* (http, upload, prefixes, withHead) {
90
95
  const under = (name) => name.startsWith("refs/") && (prefixes.length === 0 || prefixes.some((p) => name.startsWith(p)));
91
- if (upload.version === "v0") return new Map([...upload.refs].filter(([name]) => under(name)));
96
+ if (upload.version === "v0") {
97
+ const symref = upload.capabilities.find((capability) => capability.startsWith("symref=HEAD:"));
98
+ const head = withHead ? symref?.slice(12) : void 0;
99
+ return {
100
+ refs: new Map([...upload.refs].filter(([name]) => under(name))),
101
+ head
102
+ };
103
+ }
92
104
  if (featuresOf(upload.capabilities, "ls-refs") === void 0) return yield* Effect.fail(notOffered("a list of its refs", "ls-refs"));
105
+ const asked = withHead && prefixes.length > 0 ? [...prefixes, "HEAD"] : prefixes;
93
106
  const request = yield* encodedBy(encodeV2Request({
94
107
  command: "ls-refs",
95
108
  capabilities: sentCapabilities(upload.capabilities, "v2"),
96
109
  arguments: lsRefsArguments({
97
110
  peel: false,
98
- symrefs: false,
111
+ symrefs: withHead,
99
112
  unborn: false,
100
- prefixes
113
+ prefixes: asked
101
114
  })
102
115
  }));
103
116
  const body = yield* http.post("git-upload-pack", "v2", request);
104
117
  const answer = yield* decodedBy(readLsRefsAnswer(yield* heldBody(body, advertisedMost, "list of refs")));
105
118
  if (answer.refs.length > remoteRefsMost) return yield* Effect.fail(tooManyRefs());
106
- return new Map(answer.refs.filter((ref) => under(ref.name)).map((ref) => [ref.name, ref.oid]));
119
+ return {
120
+ refs: new Map(answer.refs.filter((ref) => under(ref.name)).map((ref) => [ref.name, ref.oid])),
121
+ head: withHead ? answer.head?.target : void 0
122
+ };
107
123
  });
124
+ /** The remote's refs under `prefixes`, by name: every one when none is given. */
125
+ const remoteRefsOf = (http, upload, prefixes) => Effect.map(listedOf(http, upload, prefixes, false), (listed) => listed.refs);
126
+ /** `remoteRefsOf`'s refs, and the branch the remote's `HEAD` names, `undefined` when it names none. */
127
+ const remoteRefsAndHeadOf = (http, upload, prefixes) => listedOf(http, upload, prefixes, true);
108
128
  /** A page's limit, as the local `refs.list` takes it: 100 when left out, at most 1,000. */
109
129
  const limitOf = (limit) => limit === void 0 || Number.isInteger(limit) ? Effect.succeed(Math.min(Math.max(limit ?? 100, 1), maxRefLimit)) : fail("INVALID_ARGUMENT", `A page's limit is a whole number, not ${limit}`);
110
130
  /** `remoteRefs`: the remote's refs under `prefix`, by name, a page at a time. */
@@ -311,7 +331,11 @@ const receiveRefs = (http) => Effect.flatMap(advertisement(http, "git-receive-pa
311
331
  * Each of `updates`, checked, sent with `from` as the tip it expects, and a pack of what their
312
332
  * tips reach and `advertised`'s refs don't, from `source`: to the remote's bucket in parts when it
313
333
  * offers `push-upload=<above>` and the pack is larger, else in the push's own body. The remote
314
- * decides each ref, or all of them with `atomic`, and its report answers each.
334
+ * decides each ref, or all of them with `atomic`, and its report answers each. With no upload
335
+ * offered the pack streams into the body, made again for each send, and a pack whose read broke
336
+ * fails the push for it, whatever the remote answered. With one, it holds at most twice `above`:
337
+ * within it, the pack's chunks and the body they're joined into; past it a first run counts it,
338
+ * since the upload's begin names its size, and a second run's parts go up in order.
315
339
  */
316
340
  const sendPush = /* @__PURE__ */ Effect.fnUntraced(function* (http, source, advertised, updates, terms) {
317
341
  const pushOptions = terms.pushOptions ?? [];
@@ -329,19 +353,18 @@ const sendPush = /* @__PURE__ */ Effect.fnUntraced(function* (http, source, adve
329
353
  shallows: [],
330
354
  includeTag: false
331
355
  };
332
- const pack = wants.length === 0 ? /* @__PURE__ */ new Uint8Array() : yield* Effect.flatMap(objects.fetch(listed, {
356
+ const fetched = Effect.map(objects.fetch(listed, {
333
357
  request,
334
358
  limits
335
- }), (answer) => heldBody(answer.pack, limits.bytes, "pack"));
336
- if (pack.length > 0 && takesUpload(advertised.capabilities, pack.length)) {
337
- const begin = {
338
- bytes: pack.length,
339
- updates
340
- };
341
- if (pushOptions.length > 0) begin.pushOptions = pushOptions;
342
- if (terms.atomic === true) begin.atomic = true;
343
- const answer = yield* uploadPush(http, begin, packInMemory(pack));
344
- return yield* reportedPush(answer, true, updates);
359
+ }), (answer) => answer.pack);
360
+ const above = pushUploadAbove(advertised.capabilities);
361
+ let first;
362
+ let chunks = [];
363
+ if (wants.length > 0 && above === void 0) first = yield* fetched;
364
+ else if (wants.length > 0 && above !== void 0) {
365
+ const read = yield* Effect.flatMap(fetched, (pack) => heldOrCounted(pack, above));
366
+ if (read.kind === "counted") return yield* uploaded(http, Effect.flatMap(fetched, (pack) => packInOrder(pack, read.bytes)), updates, terms);
367
+ chunks = read.chunks;
345
368
  }
346
369
  const sideBand = offered("side-band-64k");
347
370
  const capabilities = [
@@ -362,8 +385,26 @@ const sendPush = /* @__PURE__ */ Effect.fnUntraced(function* (http, source, adve
362
385
  capabilities,
363
386
  pushOptions
364
387
  }));
365
- const body = yield* http.post("git-receive-pack", "v0", joinedBytes([start, pack]));
366
- return yield* reportedPush(body, sideBand, updates);
388
+ if (first === void 0) {
389
+ const body = yield* http.post("git-receive-pack", "v0", joinedBytes([start, ...chunks]));
390
+ return yield* reportedPush(body, sideBand, updates);
391
+ }
392
+ const streamed = fetchedBody(start, first, fetched, yield* Effect.context());
393
+ const brokeOr = (answer) => streamed.broke.broke ? brokenBy(streamed.broke.cause) : answer;
394
+ return yield* http.post("git-receive-pack", "v0", streamed.open).pipe(Effect.flatMap((body) => reportedPush(body, sideBand, updates)), Effect.ensuring(streamed.unsent), Effect.catch((error) => brokeOr(Effect.fail(error))), Effect.flatMap((updated) => brokeOr(Effect.succeed(updated))));
395
+ });
396
+ /** `pack` uploaded to the remote's bucket for `updates`, as `terms` send them, and its report. */
397
+ const uploaded = /* @__PURE__ */ Effect.fnUntraced(function* (http, pack, updates, terms) {
398
+ const answer = yield* Effect.scoped(Effect.flatMap(pack, (source) => {
399
+ const begin = {
400
+ bytes: source.bytes,
401
+ updates
402
+ };
403
+ if (terms.pushOptions !== void 0 && terms.pushOptions.length > 0) begin.pushOptions = terms.pushOptions;
404
+ if (terms.atomic === true) begin.atomic = true;
405
+ return uploadPush(http, begin, source);
406
+ }));
407
+ return yield* reportedPush(answer, true, updates);
367
408
  });
368
409
  /** Each of `updates` as the remote's report in `body` answers it, on side-band-64k or bare. */
369
410
  const reportedPush = /* @__PURE__ */ Effect.fnUntraced(function* (body, sideBand, updates) {
@@ -401,4 +442,4 @@ const pushFrom = (http, local, input) => overLocal(local, Effect.gen(function* (
401
442
  if (input.pushOptions !== void 0) terms.pushOptions = input.pushOptions;
402
443
  return yield* sendPush(http, source, advertised, updates, terms);
403
444
  }));
404
- export { discover, fetchInto, fetchTerms, pushFrom, receiveRefs, remoteRefs, remoteRefsOf, sendPush };
445
+ export { discover, fetchInto, fetchTerms, pushFrom, receiveRefs, remoteRefs, remoteRefsAndHeadOf, remoteRefsOf, sendPush };
@@ -1,5 +1,5 @@
1
- import * as Schema from "effect/Schema";
2
1
  import * as Effect from "effect/Effect";
2
+ import * as Schema from "effect/Schema";
3
3
  import * as Redacted from "effect/Redacted";
4
4
  import * as Runtime from "effect/Runtime";
5
5
  import * as Stdio from "effect/Stdio";
@@ -4,18 +4,18 @@ import { onBand } from "../protocol/framing/band.mjs";
4
4
  import { pushUploadAbove } from "../protocol/wire/push-uploads.mjs";
5
5
  import { gitHttp } from "./git-http.mjs";
6
6
  import { helperNode, nodeLocalGit, spooled } from "./helper-node.mjs";
7
- import { packInMemory } from "./push-upload.mjs";
7
+ import { packHeldMost, packInMemory } from "./push-upload.mjs";
8
8
  import { helperAdvertisement, readHelperStart, relayPush } from "./remote-helper.mjs";
9
9
  import { controlsAllowed, maskedControls, secretScrubber } from "./scrub.mjs";
10
10
  import { packPastLimits } from "./slice-push.mjs";
11
11
  import { slicedHelperPush } from "./slice-report.mjs";
12
12
  import { LocalGit } from "./slices.mjs";
13
- import * as Schema from "effect/Schema";
14
13
  import * as Effect from "effect/Effect";
14
+ import * as Schema from "effect/Schema";
15
15
  import * as Result from "effect/Result";
16
+ import * as Redacted from "effect/Redacted";
16
17
  import * as Stream from "effect/Stream";
17
18
  import * as Base64 from "effect/encoding/Base64";
18
- import * as Redacted from "effect/Redacted";
19
19
  import * as Pull from "effect/Pull";
20
20
  import * as Runtime from "effect/Runtime";
21
21
  import * as Stdio from "effect/Stdio";
@@ -78,14 +78,14 @@ const spoolFile = Effect.gen(function* () {
78
78
  const writeAll = /* @__PURE__ */ Effect.fnUntraced(function* (file, chunk) {
79
79
  for (let at = 0; at < chunk.length;) at += (yield* Effect.promise(() => file.write(chunk.subarray(at)))).bytesWritten;
80
80
  });
81
- /** The pack, the input's rest: in memory, or spooled once it's past `spillAbove`. */
81
+ /** The pack, the input's rest: in memory, or spooled once it's past `spillAbove` bytes. */
82
82
  const packOf = /* @__PURE__ */ Effect.fnUntraced(function* (input, spillAbove) {
83
83
  const chunks = [];
84
84
  let bytes = 0;
85
85
  let file;
86
86
  const add = Effect.fnUntraced(function* (chunk) {
87
87
  bytes += chunk.length;
88
- if (file === void 0 && spillAbove !== void 0 && bytes > spillAbove) {
88
+ if (file === void 0 && bytes > spillAbove) {
89
89
  file = yield* spoolFile;
90
90
  for (const held of chunks.splice(0)) yield* writeAll(file, held);
91
91
  }
@@ -174,7 +174,7 @@ const push = (calls, input, url, { out, err }, hide) => {
174
174
  const { start, packFollows } = read;
175
175
  const startBytes = input.held.subarray(0, start.packOffset);
176
176
  input.held = input.held.subarray(start.packOffset);
177
- const spillAbove = pushUploadAbove(advertised.capabilities);
177
+ const spillAbove = Math.min(pushUploadAbove(advertised.capabilities) ?? Infinity, packHeldMost);
178
178
  const pack = packFollows ? yield* packOf(input, spillAbove) : packInMemory(/* @__PURE__ */ new Uint8Array());
179
179
  const sliced = packFollows && (yield* packPastLimits(advertised.capabilities, pack));
180
180
  const sideBand = start.capabilities.includes("side-band-64k");
@@ -68,7 +68,7 @@ export declare const pushSlices: (push: {
68
68
  };
69
69
  }[];
70
70
  };
71
- reason: "ambiguous" | "atomic-partner" | "awaiting-index" | "body-ended" | "boundary-not-in-pack" | "busy" | "call-budget" | "candidate-cancelled" | "candidate-superseded" | "changed-while-checked" | "cursor-expired" | "delta-too-large" | "diff-limit" | "diverged" | "entry-gone" | "entry-unpublishable" | "events-undelivered" | "events-waiting" | "fetch-plan-too-large" | "files-refused" | "fsck" | "graph-length" | "history-not-imported" | "import-cancelled" | "importing" | "key-reused" | "link-wrong-type" | "may-have-saved" | "merge-conflict" | "merge-incomplete" | "merges-off" | "name-churn" | "newer-format" | "no-copy-rows" | "no-queue" | "no-topics" | "not-a-fork" | "object-missing" | "object-too-large" | "ofs-delta" | "own-repo" | "packs-awaiting-repack" | "provider-unknown" | "prune-walk-too-large" | "queue-full" | "queue-targets-full" | "rate-limited" | "ref-conflict" | "remote-refused" | "response-too-large" | "shallow-root" | "shallow-upload" | "stage-gone" | "sync-unbound" | "tag-target-missing" | "too-many-gitmodules-and-gitattributes" | "too-many-parents" | "too-many-pointers" | "too-many-short-ids" | "too-many-store-calls" | "too-many-writes" | "unrelated-histories" | "unsupported-attribute" | "unsupported-virtual-base" | "walk-limit" | undefined;
71
+ reason: "ambiguous" | "atomic-partner" | "awaiting-index" | "body-ended" | "boundary-not-in-pack" | "busy" | "call-budget" | "candidate-cancelled" | "candidate-superseded" | "changed-while-checked" | "cursor-expired" | "delta-too-large" | "diff-limit" | "diverged" | "entry-gone" | "entry-unpublishable" | "event-version" | "events-undelivered" | "events-waiting" | "fetch-depth-unsupported" | "fetch-plan-too-large" | "files-refused" | "fsck" | "graph-length" | "history-not-imported" | "import-cancelled" | "importing" | "job-step-calls" | "job-step-yielded" | "key-reused" | "link-wrong-type" | "may-have-saved" | "merge-conflict" | "merge-incomplete" | "merges-off" | "name-churn" | "newer-format" | "no-copy-rows" | "no-queue" | "no-releases" | "no-sync" | "no-topics" | "not-a-fork" | "object-missing" | "object-too-large" | "ofs-delta" | "own-repo" | "packs-awaiting-repack" | "provider-unknown" | "prune-walk-too-large" | "queue-full" | "queue-targets-full" | "rate-limited" | "ref-conflict" | "remote-refused" | "response-too-large" | "shallow-root" | "shallow-upload" | "stage-gone" | "tag-target-missing" | "too-many-gitmodules-and-gitattributes" | "too-many-parents" | "too-many-pointers" | "too-many-short-ids" | "too-many-store-calls" | "too-many-writes" | "unrelated-histories" | "unsupported-attribute" | "unsupported-virtual-base" | "walk-limit" | undefined;
72
72
  };
73
73
  } | {
74
74
  refusal?: never;
@@ -39,23 +39,33 @@ const authorization = (credential) => "token" in credential ? `Bearer ${credenti
39
39
  const credentialsFailed = /* @__PURE__ */ gitError("UNAUTHENTICATED", "The credentials function failed, so nothing was sent", { hint: "Check the credential helper or the function the client was given" });
40
40
  const credentialOf = (credentials) => Predicate.isFunction(credentials) ? Effect.tryPromise({
41
41
  try: async (signal) => credentials({ signal }),
42
- catch: () => ({
43
- kind: "refused",
44
- error: credentialsFailed
45
- })
42
+ catch: () => credentialsFailed
46
43
  }) : Effect.succeed(credentials);
47
44
  /**
48
- * A copy of `request` to send, with the credential's header value, aborted with `signal` or with
49
- * `request`'s own: the caller's, which still holds while the answer's body is read.
45
+ * The `authorization` header `credentials` sends, read afresh from a function: none without
46
+ * credentials. One that fails is `credentialsFailed`, and one no header carries `credentialRefused`,
47
+ * both before anything is sent.
48
+ */
49
+ const credentialHeader = (credentials) => Effect.flatMap(credentialOf(credentials), (credential) => {
50
+ if (credential === void 0) return Effect.succeed(void 0);
51
+ const value = authorization(credential);
52
+ return unsendable.test(value) ? Effect.fail(credentialRefused) : Effect.succeed(value);
53
+ });
54
+ /**
55
+ * The request to send, with the credential's header value, aborted with `signal` or with the
56
+ * request's own: the caller's, which still holds while the answer's body is read. A request is
57
+ * sent as a copy, so it's never read; one made afresh is sent itself.
50
58
  */
51
59
  const signed = (request, credential, signal) => {
52
- const headers = new Headers(request.headers);
60
+ const made = request instanceof Request ? request.clone() : request();
61
+ const headers = new Headers(made.headers);
53
62
  if (credential !== void 0) headers.set("authorization", credential);
54
- return new Request(request.clone(), {
63
+ return new Request(made, {
55
64
  headers,
56
- signal: AbortSignal.any([request.signal, signal])
65
+ signal: AbortSignal.any([made.signal, signal])
57
66
  });
58
67
  };
68
+ /** Whether `retry` sends a request again after `failure`, its try `attempt`. */
59
69
  const shouldRetry = (retry, attempt, failure) => {
60
70
  if (retry === void 0 || failure.status === 401) return false;
61
71
  if (Predicate.isFunction(retry)) return retry({
@@ -181,7 +191,8 @@ const refusalOf = (response, failureOf) => {
181
191
  * The remote at `options`: each request sent through `options.transport`, or `fetch`, with the
182
192
  * credential, again as `retry` says, and once more with a fresh credential after a 401 when
183
193
  * `credentials` is a function. `failureOf` reads what a refused answer said: REST's JSON, or
184
- * Git's line of text. Each send is a clone, so `request` itself is never read.
194
+ * Git's line of text. Each send is a clone, so `request` itself is never read, or a request made
195
+ * afresh, when `request` makes one.
185
196
  */
186
197
  const remoteFetch = (options, failureOf) => {
187
198
  const send = options.transport ?? (async (request) => fetch(request));
@@ -202,14 +213,10 @@ const remoteFetch = (options, failureOf) => {
202
213
  onSuccess: (response) => response.status < 400 ? Effect.succeed(response) : Effect.flatMap(refusalOf(response, failureOf), (failure) => again(failure, Effect.succeed(response), dropped(response)))
203
214
  }));
204
215
  };
205
- const signedTries = (request) => Effect.flatMap(credentialOf(options.credentials), (credential) => {
206
- const value = credential === void 0 ? void 0 : authorization(credential);
207
- if (value !== void 0 && unsendable.test(value)) return Effect.fail({
208
- kind: "refused",
209
- error: credentialRefused
210
- });
211
- return tries(request, value, 1);
212
- });
216
+ const signedTries = (request) => credentialHeader(options.credentials).pipe(Effect.mapError((error) => ({
217
+ kind: "refused",
218
+ error
219
+ })), Effect.flatMap((value) => tries(request, value, 1)));
213
220
  return (request) => Effect.flatMap(signedTries(request), (response) => response.status === 401 && Predicate.isFunction(options.credentials) ? Effect.andThen(dropped(response), signedTries(request)) : Effect.succeed(response));
214
221
  };
215
- export { abortable, bodyStart, bodyText, credentialRefused, credentialsFailed, dropped, remoteFetch };
222
+ export { abortable, bodyStart, bodyText, credentialHeader, credentialRefused, credentialsFailed, dropped, pauseOf, remoteFetch, shouldRetry, unanswered };