@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
@@ -2,18 +2,28 @@ import { gitError } from "../contracts/result.mjs";
2
2
  import { bytesOf } from "../storage/wants.mjs";
3
3
  import { deadlineOf, timed, within } from "../engine/reads.mjs";
4
4
  import { decodeCommit } from "../protocol/objects/commit.mjs";
5
- import { isTreeMode } from "../protocol/objects/object.mjs";
5
+ import { isTreeMode, objectId } from "../protocol/objects/object.mjs";
6
6
  import { parseTreeBytes } from "../protocol/objects/tree.mjs";
7
- import { lfsOidAt, pointersOfBlob } from "../storage/lfs-pointers.mjs";
7
+ import { ownWriter } from "../core/own-writes.mjs";
8
+ import { utf8 } from "../protocol/bytes/text.mjs";
9
+ import { lfsPointerText } from "../protocol/objects/lfs-pointer.mjs";
10
+ import { lfsOidAt, lfsSizeAt, pointersOfBlob } from "../storage/lfs-pointers.mjs";
8
11
  import { listedOf } from "./objects.mjs";
12
+ import { uploadedOf } from "./uploaded.mjs";
13
+ import * as Clock$1 from "effect/Clock";
9
14
  import * as Effect from "effect/Effect";
10
15
  // src/lfs/pointers.ts
11
16
  /**
12
17
  * LFS's push rule: a ref whose new tip holds, in a tree the push carries, a Git LFS pointer the
13
- * push carries to an object the repo never listed is refused, so a clone never meets a pointer it
14
- * can't download. It starts from the pointers the receive found among the push's blobs, and reads
15
- * the listed rows of the oids they name. Only when one is unlisted does it walk each new tip's
16
- * trees, the push's own alone, for where that pointer sits.
18
+ * push carries to an object the repo doesn't hold for the pusher is refused, so a clone never
19
+ * meets a pointer it can't download. The repo holds it for the pusher when it lists the object at
20
+ * the size the pointer names, and, for a pusher whose view is narrowed, as under `access` one who
21
+ * doesn't read every pattern is, when a ref it sees reaches the object's pointer or it sent the
22
+ * object's bytes within `uploadedKept` (#1943). So a hidden object's oid and size alone push no
23
+ * pointer to it, and the refusal is the one an unlisted object gets, telling nothing of it. It
24
+ * starts from the pointers the receive found among the push's blobs, and reads the listed rows of
25
+ * the oids they name. Only when one is refused does it walk each new tip's trees, the push's own
26
+ * alone, for where that pointer sits.
17
27
  */
18
28
  /**
19
29
  * How long the walk for an unlisted pointer may take, across every ref of one push. A push's
@@ -26,8 +36,11 @@ const pushCheckMilliseconds = 6e4;
26
36
  /** A file's modes: a symlink or a submodule is never a pointer. */
27
37
  const fileModes = /* @__PURE__ */ new Set(["100644", "100755"]);
28
38
  /**
29
- * The check, over the repo's listed rows in LFS's claim's `rows`: each ref it refuses, with why.
30
- * It answers only for the refs it's asked of, and may be asked twice.
39
+ * The check, over the repo's listed rows in LFS's registration's `rows`: each ref it refuses, with why.
40
+ * It answers only for the refs it's asked of, and may be asked twice. It checks every push,
41
+ * whatever the repo's `.gitattributes` say: one can come in the same push, sit on another ref or in
42
+ * a folder, so none says which files are pointers. Its cost is bounded already, as the receive
43
+ * reads only the push's new blobs of at most 1,024 bytes for pointers, in its own pass.
31
44
  */
32
45
  const pointerCheck = /* @__PURE__ */ Effect.fnUntraced(function* (rows, input) {
33
46
  const refused = /* @__PURE__ */ new Map();
@@ -40,7 +53,7 @@ const pointerCheck = /* @__PURE__ */ Effect.fnUntraced(function* (rows, input) {
40
53
  }
41
54
  const { lfsPointers } = input.objects;
42
55
  if (lfsPointers.count === 0 || tips.size === 0) return refused;
43
- const unlisted = yield* unlistedOf(rows, input.objects.repo, lfsPointers);
56
+ const unlisted = yield* unlistedOf(rows, input);
44
57
  if (unlisted === void 0) return refused;
45
58
  const deadline = yield* deadlineOf(pushCheckMilliseconds, "walk-limit");
46
59
  const walk = Effect.forEach(tips, ([ref, tip]) => Effect.map(missingAt(input, unlisted, tip, deadline), (missing) => [ref, missing]));
@@ -49,28 +62,66 @@ const pointerCheck = /* @__PURE__ */ Effect.fnUntraced(function* (rows, input) {
49
62
  return refused;
50
63
  });
51
64
  /**
52
- * Which of `pointers` name an object the repo never listed, one bit an entry, or `undefined` when
53
- * every one is listed. It reads a chunk of entries at a time, so it keeps no more than one read's
54
- * rows beside the bits.
65
+ * Which of the push's pointers name an object the repo doesn't hold for the pusher, one bit an
66
+ * entry, or `undefined` when it holds every one: unlisted, or listed at another size, then, of the
67
+ * rest, those `unprovenOf` leaves. It reads a chunk of entries at a time, so it keeps no more than
68
+ * one read's rows beside the bits and the entries left to prove.
55
69
  */
56
- const unlistedOf = /* @__PURE__ */ Effect.fnUntraced(function* (rows, repo, pointers) {
70
+ const unlistedOf = /* @__PURE__ */ Effect.fnUntraced(function* (rows, input) {
71
+ const pointers = input.objects.lfsPointers;
57
72
  const unlisted = new Uint8Array(Math.ceil(pointers.count / 8));
73
+ const listedAt = [];
58
74
  let any = false;
75
+ const refuse = (at) => {
76
+ unlisted[at >>> 3] = (unlisted[at >>> 3] ?? 0) | 1 << (at & 7);
77
+ any = true;
78
+ };
59
79
  for (let from = 0; from < pointers.count; from += 100) {
60
80
  const to = Math.min(from + 100, pointers.count);
61
81
  const oids = Array.from({ length: to - from }, (_, at) => lfsOidAt(pointers, from + at));
62
- const listed = yield* listedOf(rows, repo, [...new Set(oids)]);
63
- for (const [at, oid] of oids.entries()) {
64
- if (listed.has(oid)) continue;
65
- unlisted[from + at >>> 3] = (unlisted[from + at >>> 3] ?? 0) | 1 << (from + at & 7);
66
- any = true;
67
- }
82
+ const listed = yield* listedOf(rows, input.objects.repo, [...new Set(oids)]);
83
+ for (const [at, oid] of oids.entries()) if (listed.get(oid)?.size === lfsSizeAt(pointers, from + at)) listedAt.push(from + at);
84
+ else refuse(from + at);
68
85
  }
86
+ const unproven = yield* unprovenOf(rows, input, listedAt);
87
+ for (const at of listedAt) if (unproven.has(lfsOidAt(pointers, at))) refuse(at);
69
88
  return any ? {
70
89
  pointers,
71
90
  unlisted
72
91
  } : void 0;
73
92
  });
93
+ /**
94
+ * The oids of `entries`, each listed at its pointer's size, that the pusher hasn't shown it holds:
95
+ * none for a pusher whose view isn't narrowed. Else those whose pointer, as git-lfs writes it, no
96
+ * ref the pusher sees reaches, as `seenIn` asks of every one at once, less those the pusher
97
+ * uploaded within `uploadedKept`.
98
+ */
99
+ const unprovenOf = /* @__PURE__ */ Effect.fnUntraced(function* (rows, input, entries) {
100
+ const { lfsPointers: pointers, repo } = input.objects;
101
+ const unproven = /* @__PURE__ */ new Set();
102
+ if (entries.length === 0) return unproven;
103
+ const blobs = /* @__PURE__ */ new Map();
104
+ const sized = new Map(entries.map((at) => [lfsOidAt(pointers, at), lfsSizeAt(pointers, at)]));
105
+ for (const [oid, size] of sized) {
106
+ const text = lfsPointerText({
107
+ oid,
108
+ size
109
+ });
110
+ blobs.set(yield* objectId({
111
+ type: "blob",
112
+ bytes: utf8(text)
113
+ }), oid);
114
+ }
115
+ const seen = yield* input.seen([...blobs.keys()]);
116
+ if (seen === void 0) return unproven;
117
+ const unseen = [...blobs].flatMap(([blob, oid]) => seen.has(blob) ? [] : [oid]);
118
+ if (unseen.length === 0) return unproven;
119
+ const writer = yield* ownWriter(input.caller);
120
+ const at = yield* Clock$1.currentTimeMillis;
121
+ const own = writer === void 0 ? /* @__PURE__ */ new Set() : yield* uploadedOf(rows, repo, writer, unseen, at);
122
+ for (const oid of unseen) if (!own.has(oid)) unproven.add(oid);
123
+ return unproven;
124
+ });
74
125
  /** The unlisted LFS oids the pointers of the blob `blob` name, if any. */
75
126
  const unlistedNamed = ({ pointers, unlisted }, blob) => {
76
127
  const { from, to } = pointersOfBlob(pointers, blob);
@@ -2,7 +2,7 @@ import { bucketDo } from "../storage/calls.mjs";
2
2
  import { decodeRow } from "../store/errors.mjs";
3
3
  import { ListedRow, lfsCollections } from "./rows.mjs";
4
4
  import * as Effect from "effect/Effect";
5
- /** LFS's claim's purge over its `rows` and `bucket`, which charges each call. */
5
+ /** LFS's registration's purge over its `rows` and `bucket`, which charges each call. */
6
6
  const lfsPurge = (rows, bucket) => /* @__PURE__ */ Effect.fnUntraced(function* ({ repo }) {
7
7
  const snapshot = yield* rows.read(repo, [
8
8
  {
@@ -24,11 +24,15 @@ const lfsPurge = (rows, bucket) => /* @__PURE__ */ Effect.fnUntraced(function* (
24
24
  {
25
25
  collection: lfsCollections.locks,
26
26
  limit: 500
27
+ },
28
+ {
29
+ collection: lfsCollections.uploaded,
30
+ limit: 500
27
31
  }
28
32
  ]);
29
- const [uploads = [], staging = [], ending = [], listed = [], locks = []] = snapshot.results;
33
+ const [uploads = [], staging = [], ending = [], listed = [], locks = [], uploaded = []] = snapshot.results;
30
34
  if (uploads.length + staging.length + ending.length > 0) return "waits";
31
- const found = listed.length > 0 ? listed : locks;
35
+ const found = listed.length > 0 ? listed : locks.length > 0 ? locks : uploaded;
32
36
  if (found.length === 0) return "done";
33
37
  const keys = yield* Effect.forEach(listed, (row) => Effect.map(decodeRow(ListedRow, row, `LFS object ${row.id}`), (object) => object.key));
34
38
  yield* Effect.forEach(keys, (key) => bucketDo(bucket.remove(key)), {
package/dist/lfs/rows.mjs CHANGED
@@ -7,18 +7,20 @@ import * as Schema from "effect/Schema";
7
7
  * SHA-256 ever reach. A repo serves only the objects it lists, and lists one only after its bytes
8
8
  * were checked at its key.
9
9
  */
10
- /** LFS's collections in a repo's scope: its claim's rows, under `lfs/`. */
10
+ /** LFS's collections in a repo's scope: its registration's rows, under `lfs/`. */
11
11
  const lfsCollections = {
12
12
  /** Each LFS object the repo lists, by its oid. Only a deleted repo unlists. */
13
13
  objects: "lfs/objects",
14
- /** Each LFS object an upload link was given for, by its oid, until listed. */
14
+ /** Each LFS object an upload link was given for, by its oid and its uploader, until listed. */
15
15
  uploads: "lfs/uploads",
16
16
  /** A Worker upload's staging key, by its due `removeAt` and its ID. */
17
17
  staging: "lfs/staging",
18
18
  /** An LFS object upkeep is deleting, by its oid, which no verify lists. */
19
19
  ending: "lfs/ending",
20
20
  /** Each LFS lock, by its path's SHA-256. */
21
- locks: "lfs/locks"
21
+ locks: "lfs/locks",
22
+ /** Each object a caller sent bytes for, by the day, the caller's writer and the oid. */
23
+ uploaded: "lfs/uploaded"
22
24
  };
23
25
  /**
24
26
  * The largest object LFS takes: R2's largest put in one request, 5 GiB less 5 MiB, since a
@@ -33,6 +35,11 @@ const linkLife = /* @__PURE__ */ millis("15 minutes");
33
35
  */
34
36
  const uploadGrace = /* @__PURE__ */ millis("1 day");
35
37
  /**
38
+ * How long a caller's upload counts as its own, for the pointer rule: a day from its verified
39
+ * bytes, so a pointer it pushes to them passes though no ref it sees reaches them yet.
40
+ */
41
+ const uploadedKept = /* @__PURE__ */ millis("1 day");
42
+ /**
36
43
  * A listed object: its bytes are at `key`, checked. A signed upload's are at its upload row's
37
44
  * `objectKey`, and a Worker upload's stay at the staging key they streamed to, which only they
38
45
  * were ever written to.
@@ -86,10 +93,20 @@ const listedKey = (oid) => ({
86
93
  collection: lfsCollections.objects,
87
94
  id: oid
88
95
  });
89
- const uploadKey = (oid) => ({
96
+ /**
97
+ * Who an upload row is for: `ownWriter`'s SHA-256 of the caller's actor ID, or this for a caller
98
+ * with none. Each uploader's row has its own generation, so its signed links write a key no other
99
+ * caller's links write, and a verify heads only the caller's own: bytes another caller sent prove
100
+ * nothing of this one (#1943).
101
+ */
102
+ const anonymousUploader = "anonymous";
103
+ const uploadId = (oid, uploader) => `${oid}.${uploader}`;
104
+ const uploadKey = (oid, uploader) => ({
90
105
  collection: lfsCollections.uploads,
91
- id: oid
106
+ id: uploadId(oid, uploader)
92
107
  });
108
+ /** The oid an upload row's ID names, before its uploader. */
109
+ const uploadOid = (id) => id.slice(0, id.indexOf("."));
93
110
  /** An ending row's key: its upload's oid and generation, so two generations' rows never meet. */
94
111
  const endingKey = (oid, generation) => ({
95
112
  collection: lfsCollections.ending,
@@ -113,8 +130,8 @@ const listedRead = (oid) => ({
113
130
  collection: lfsCollections.objects,
114
131
  id: oid
115
132
  });
116
- const uploadRead = (oid) => ({
133
+ const uploadRead = (oid, uploader) => ({
117
134
  collection: lfsCollections.uploads,
118
- id: oid
135
+ id: uploadId(oid, uploader)
119
136
  });
120
- export { EndingRow, ListedRow, LockRow, StagingRow, UploadRow, endingKey, largestObject, lfsCollections, linkLife, listedKey, listedRead, lockKey, lockRead, objectKey, stagingId, stagingKey, stagingRead, streamMost, uploadGrace, uploadKey, uploadRead };
137
+ export { EndingRow, ListedRow, LockRow, StagingRow, UploadRow, anonymousUploader, endingKey, largestObject, lfsCollections, linkLife, listedKey, listedRead, lockKey, lockRead, objectKey, stagingId, stagingKey, stagingRead, streamMost, uploadGrace, uploadKey, uploadOid, uploadRead, uploadedKept };
@@ -1,4 +1,4 @@
1
- import { LfsFeature } from "../contracts/lfs.mjs";
1
+ import { LfsFeature, LfsOptions } from "../contracts/lfs.mjs";
2
2
  import { GitError } from "../contracts/result.mjs";
3
3
  import "../core/parts.mjs";
4
4
  import { LfsCall } from "./objects.mjs";
@@ -10,5 +10,8 @@ export interface LfsRoute extends LfsCall {
10
10
  }
11
11
  /** Git LFS's API for a server's repos, its objects in `bucket`. */
12
12
  export type LfsService = (call: LfsRoute) => Effect.Effect<Response, GitError>;
13
- /** Turns on Git LFS, its objects in the adapter's bucket: a server without it has no LFS. */
14
- export declare const lfs: () => LfsFeature;
13
+ /**
14
+ * Turns on Git LFS, its objects in the adapter's bucket: a server without it has no LFS. `options`
15
+ * win over the adapter's `RequestLimits`, as `LfsOptions` says.
16
+ */
17
+ export declare const lfs: (options?: LfsOptions) => LfsFeature;
@@ -4,8 +4,14 @@ import { batch, receive, send, verify } from "./objects.mjs";
4
4
  import { lfsAnswer } from "./wire.mjs";
5
5
  import * as Effect from "effect/Effect";
6
6
  // src/lfs/service.ts
7
- /** Turns on Git LFS, its objects in the adapter's bucket: a server without it has no LFS. */
8
- const lfs = () => ({ kind: "lfs" });
7
+ /**
8
+ * Turns on Git LFS, its objects in the adapter's bucket: a server without it has no LFS. `options`
9
+ * win over the adapter's `RequestLimits`, as `LfsOptions` says.
10
+ */
11
+ const lfs = (options = {}) => ({
12
+ ...options,
13
+ kind: "lfs"
14
+ });
9
15
  const methodNotAllowed = (allow) => Effect.succeed(lfsAnswer(405, { message: "Method not allowed" }, { allow }));
10
16
  /** LFS's routes over `parts`, provided `needs`, the server's services, which `openRepo` reads. */
11
17
  const lfsService = (needs, parts) => (call) => Effect.provideContext(served(parts, call), needs);
@@ -1,23 +1,25 @@
1
1
  import { bucketDo } from "../storage/calls.mjs";
2
2
  import { decodeRow } from "../store/errors.mjs";
3
- import { EndingRow, StagingRow, UploadRow, endingKey, lfsCollections, listedRead, objectKey, uploadKey, uploadRead } from "./rows.mjs";
3
+ import { EndingRow, ListedRow, StagingRow, UploadRow, endingKey, lfsCollections, listedRead, objectKey, uploadOid } from "./rows.mjs";
4
+ import { uploadedSweepOf, uploadedSweepRead } from "./uploaded.mjs";
4
5
  import * as Effect from "effect/Effect";
5
6
  // src/lfs/upkeep.ts
6
7
  /**
7
8
  * LFS's part of a repo's `git.repack`: it deletes the bytes no listing will name. A Worker
8
9
  * upload's staging key goes at its row's `removeAt`, a day after it began, when its stream has
9
10
  * long ended. A signed upload's object key goes at its upload row's `removeAt`, a day after its
10
- * last link expired, if the object is still unlisted: the commit that drops the upload row puts
11
+ * last link expired, if the object is still unlisted or listed at another key: the commit that
12
+ * drops the upload row puts
11
13
  * an ending row naming the key, so verify, which lists only the key its upload row names, never
12
14
  * lists it again, and an upload after gets a key of its own. A delete that lands late, after a try
13
15
  * that sent it timed out, reaches only bytes no listing names. A key is deleted before the row
14
16
  * that names it is dropped, so a crash between leaves the row, and the next step deletes the key
15
- * again.
17
+ * again. Own uploads go once their days are past, as receipts do.
16
18
  */
17
19
  /** The most rows of each kind a step ends. */
18
20
  const upkeepPage = 500;
19
21
  /**
20
- * LFS's claim's upkeep over its `rows` and `bucket`'s objects: `bucket` charges each call, and
22
+ * LFS's registration's upkeep over its `rows` and `bucket`'s objects: `bucket` charges each call, and
21
23
  * `signed` says the host signs LFS's links, so its uploads have upload rows to end.
22
24
  */
23
25
  const lfsUpkeep = (rows, bucket, signed) => ({ repo, at }) => upkeepStep({
@@ -30,18 +32,23 @@ const lfsUpkeep = (rows, bucket, signed) => ({ repo, at }) => upkeepStep({
30
32
  const did = { more: true };
31
33
  const earliest = (a, b) => a === void 0 ? b : b === void 0 ? a : Math.min(a, b);
32
34
  /**
33
- * One step: the ending rows, else the due staging rows, else the due upload rows. Each does a page
34
- * and answers `more`; with nothing due, it answers when the soonest row is.
35
+ * One step: the ending rows, else the due staging rows, else the due upload rows, else the own
36
+ * uploads past their days. Each does a page and answers `more`; with nothing due, it answers when
37
+ * the soonest row is.
35
38
  */
36
39
  const upkeepStep = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep) {
37
- const snapshot = yield* upkeep.rows.read(upkeep.repo, [{
38
- collection: lfsCollections.ending,
39
- limit: upkeepPage
40
- }, {
41
- collection: lfsCollections.staging,
42
- limit: upkeepPage
43
- }]);
44
- const [ending = [], staging = []] = snapshot.results;
40
+ const snapshot = yield* upkeep.rows.read(upkeep.repo, [
41
+ {
42
+ collection: lfsCollections.ending,
43
+ limit: upkeepPage
44
+ },
45
+ {
46
+ collection: lfsCollections.staging,
47
+ limit: upkeepPage
48
+ },
49
+ uploadedSweepRead
50
+ ]);
51
+ const [ending = [], staging = [], uploaded = []] = snapshot.results;
45
52
  const endings = yield* Effect.forEach(ending, (row) => Effect.map(decodeRow(EndingRow, row, `LFS ending row ${row.id}`), (decoded) => ({
46
53
  id: row.id,
47
54
  ...decoded
@@ -54,8 +61,13 @@ const upkeepStep = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep) {
54
61
  const dueStages = stages.filter((stage) => stage.removeAt <= upkeep.at);
55
62
  if (dueStages.length > 0) return yield* endStages(upkeep, snapshot.version, dueStages);
56
63
  const uploads = yield* dueUploads(upkeep);
57
- if (uploads.oids.length > 0) return yield* endUploads(upkeep, uploads.oids);
58
- const due = stages.map((stage) => stage.removeAt).reduce(earliest, uploads.next);
64
+ if (uploads.ids.length > 0) return yield* endUploads(upkeep, uploads.ids);
65
+ const sweep = uploadedSweepOf(uploaded, upkeep.at);
66
+ if (sweep.delete.length > 0) {
67
+ yield* upkeep.rows.commit(upkeep.repo, snapshot.version, { delete: sweep.delete });
68
+ return did;
69
+ }
70
+ const due = stages.map((stage) => stage.removeAt).reduce(earliest, earliest(uploads.next, sweep.due));
59
71
  return due === void 0 ? { more: false } : {
60
72
  more: false,
61
73
  due
@@ -85,9 +97,9 @@ const endStages = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep, version,
85
97
  })) });
86
98
  return did;
87
99
  });
88
- /** Up to a page of the upload rows that are due, and when the soonest of the rest is. */
100
+ /** Up to a page of the upload rows that are due, by ID, and when the soonest of the rest is. */
89
101
  const dueUploads = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep) {
90
- const oids = [];
102
+ const ids = [];
91
103
  let next;
92
104
  let after;
93
105
  for (;;) {
@@ -102,34 +114,41 @@ const dueUploads = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep) {
102
114
  for (const row of rows) {
103
115
  const upload = yield* uploadOf(row);
104
116
  if (upload.removeAt > upkeep.at) next = earliest(next, upload.removeAt);
105
- else if (oids.length < upkeepPage) oids.push(row.id);
117
+ else if (ids.length < upkeepPage) ids.push(row.id);
106
118
  }
107
119
  after = rows.at(-1)?.id;
108
120
  if (rows.length < upkeepPage || after === void 0) return {
109
- oids,
121
+ ids,
110
122
  next
111
123
  };
112
124
  }
113
125
  });
114
126
  const uploadOf = (row) => decodeRow(UploadRow, row, `LFS object ${row.id}'s upload`);
127
+ const listedOf = (row) => decodeRow(ListedRow, row, `LFS object ${row.id}`);
115
128
  /**
116
- * Drops each due upload row, read again at one version. An object still unlisted on a signed
117
- * bucket gets its ending row in the same commit, then its bytes go; a Worker's bytes are at
118
- * staging keys, which their own rows end.
129
+ * Drops each due upload row, by its ID, read again at one version. On a signed bucket, an object
130
+ * still unlisted, or listed at another key, as another uploader's bytes are, gets its ending row in
131
+ * the same commit, then its bytes go; a Worker's bytes are at staging keys, which their own rows end.
119
132
  */
120
- const endUploads = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep, oids) {
121
- const snapshot = yield* upkeep.rows.read(upkeep.repo, oids.flatMap((oid) => [uploadRead(oid), listedRead(oid)]));
133
+ const endUploads = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep, ids) {
134
+ const snapshot = yield* upkeep.rows.read(upkeep.repo, ids.flatMap((id) => [{
135
+ collection: lfsCollections.uploads,
136
+ id
137
+ }, listedRead(uploadOid(id))]));
122
138
  const dropped = [];
123
139
  const ended = [];
124
- for (const [index, oid] of oids.entries()) {
140
+ for (const [index, id] of ids.entries()) {
141
+ const oid = uploadOid(id);
125
142
  const uploadRow = snapshot.results[index * 2]?.[0];
126
- const listed = (snapshot.results[index * 2 + 1]?.length ?? 0) > 0;
143
+ const listedRow = snapshot.results[index * 2 + 1]?.[0];
127
144
  const upload = uploadRow === void 0 ? void 0 : yield* uploadOf(uploadRow);
128
145
  if (upload === void 0 || upload.removeAt > upkeep.at) continue;
129
- dropped.push(oid);
130
- if (upkeep.signed && !listed) ended.push({
146
+ dropped.push(id);
147
+ const key = objectKey(upkeep.repo, oid, upload.generation);
148
+ const listed = listedRow === void 0 ? void 0 : yield* listedOf(listedRow);
149
+ if (upkeep.signed && listed?.key !== key) ended.push({
131
150
  ...endingKey(oid, upload.generation),
132
- key: objectKey(upkeep.repo, oid, upload.generation)
151
+ key
133
152
  });
134
153
  }
135
154
  if (dropped.length === 0) return did;
@@ -139,7 +158,10 @@ const endUploads = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep, oids) {
139
158
  id,
140
159
  value: { key }
141
160
  })),
142
- delete: dropped.map(uploadKey)
161
+ delete: dropped.map((id) => ({
162
+ collection: lfsCollections.uploads,
163
+ id
164
+ }))
143
165
  });
144
166
  if (!committed.ok || ended.length === 0) return did;
145
167
  return yield* endObjects(upkeep, committed.version, ended);
@@ -0,0 +1,41 @@
1
+ import { largestObject } from "./rows.mjs";
2
+ // src/lfs/upload-most.ts
3
+ /**
4
+ * The largest Git LFS upload through the server, `workerUploadMost`, for a bucket that signs no
5
+ * links: the least of what the platform's body cap passes on, what its CPU cap lets the upload
6
+ * hash and store, and `largestObject`. A larger one is refused before a byte streams, at the
7
+ * batch, so git-lfs never starts it.
8
+ */
9
+ /** The share of a request's CPU an upload may spend: the rest is its rows', its put's and the runtime's. */
10
+ const cpuShare = .8;
11
+ /** The bytes `cpuMs` of CPU hashes and stores, at `uploadMsPerMiB` within `cpuShare` of it. */
12
+ const cpuBytes = (cpuMs) => Math.floor(cpuShare * cpuMs / 64 * 1024 ** 2);
13
+ /** The largest upload `caps` let finish: `largestObject` where neither binds below it. */
14
+ const uploadMostOf = (caps) => {
15
+ const bounds = [{
16
+ bytes: largestObject,
17
+ by: "object"
18
+ }];
19
+ if (caps.bodyCap !== void 0) bounds.push({
20
+ bytes: caps.bodyCap,
21
+ by: "body"
22
+ });
23
+ if (caps.cpuMs !== void 0) bounds.push({
24
+ bytes: cpuBytes(caps.cpuMs),
25
+ by: "cpu"
26
+ });
27
+ return bounds.reduce((least, bound) => bound.bytes < least.bytes ? bound : least);
28
+ };
29
+ /** Why `caps` aren't caps: each must be a whole number of bytes or milliseconds above 0. */
30
+ const capsRefusal = (caps) => {
31
+ for (const [name, value] of Object.entries(caps)) if (value !== void 0 && !(Number.isSafeInteger(value) && value > 0)) return `An LFS upload's ${name} is a whole number above 0, not ${String(value)}`;
32
+ };
33
+ /** What each cap that sets the largest upload is, as a refusal names it. */
34
+ const setBy = {
35
+ body: "the largest body its platform passes on",
36
+ cpu: "what its CPU cap lets it hash and store",
37
+ object: "R2's largest single put"
38
+ };
39
+ /** Why an upload of more than `most` is refused, and what takes it. */
40
+ const pastMost = (most) => `An upload through this server is at most ${most.bytes} bytes, ${setBy[most.by]}: a bucket that signs its links takes a larger one straight`;
41
+ export { capsRefusal, cpuShare, pastMost, uploadMostOf };
@@ -0,0 +1,59 @@
1
+ import { dayMs, dayOf, sweepOf } from "../core/receipts.mjs";
2
+ import { decodeRow } from "../store/errors.mjs";
3
+ import { lfsCollections, uploadedKept } from "./rows.mjs";
4
+ import * as Effect from "effect/Effect";
5
+ import * as Schema from "effect/Schema";
6
+ // src/lfs/uploaded.ts
7
+ /**
8
+ * A caller's own upload: an object whose bytes it sent, checked against the oid, which its pushes'
9
+ * pointers may name for `uploadedKept` after, though no ref it sees reaches the object yet. So a
10
+ * caller who sees only some refs proves it holds an object's bytes by sending them, and the
11
+ * pointer rule never takes a hidden object's oid alone as proof (#1943). Only the caller's writer,
12
+ * `ownWriter`'s SHA-256 of its actor's ID, names it, so the row's ID is one length; an anonymous
13
+ * caller keeps none.
14
+ */
15
+ const UploadedRow = /* @__PURE__ */ Schema.Struct({ at: Schema.Int });
16
+ /** An own upload's ID: its day, padded so the oldest read first, its writer and its oid. */
17
+ const uploadedId = (at, writer, oid) => `${dayOf(at)}:${writer}:${oid}`;
18
+ /** The row a verified upload of `oid` by `writer` at `at` puts, in its commit. */
19
+ const uploadedRow = (writer, oid, at) => ({
20
+ collection: lfsCollections.uploaded,
21
+ id: uploadedId(at, writer, oid),
22
+ value: { at }
23
+ });
24
+ /**
25
+ * Which of `oids` `writer` uploaded to `repo` within `uploadedKept` before `at`: one read of each
26
+ * one's rows from today and yesterday, at most `sweepPage` oids a read.
27
+ */
28
+ const uploadedOf = /* @__PURE__ */ Effect.fnUntraced(function* (rows, repo, writer, oids, at) {
29
+ const days = [at, at - dayMs];
30
+ const own = /* @__PURE__ */ new Set();
31
+ for (let from = 0; from < oids.length; from += 500) {
32
+ const chunk = oids.slice(from, from + 500);
33
+ const reads = chunk.flatMap((oid) => days.map((day) => ({
34
+ collection: lfsCollections.uploaded,
35
+ id: uploadedId(day, writer, oid)
36
+ })));
37
+ const snapshot = yield* rows.read(repo, reads);
38
+ for (const [index, found] of snapshot.results.entries()) {
39
+ const oid = chunk[Math.floor(index / days.length)];
40
+ for (const row of found) {
41
+ const upload = yield* decodeRow(UploadedRow, row, `LFS upload '${row.id}'`);
42
+ if (oid !== void 0 && at < upload.at + uploadedKept) own.add(oid);
43
+ }
44
+ }
45
+ }
46
+ return own;
47
+ });
48
+ /** What LFS's upkeep reads to sweep own uploads: the oldest first. */
49
+ const uploadedSweepRead = {
50
+ collection: lfsCollections.uploaded,
51
+ limit: 500
52
+ };
53
+ const uploadedKey = (id) => [{
54
+ collection: lfsCollections.uploaded,
55
+ id
56
+ }];
57
+ /** A sweep of own uploads, of `rows` read by `uploadedSweepRead`: those whose days are past at `at`. */
58
+ const uploadedSweepOf = (rows, at) => sweepOf(rows, at, uploadedKey);
59
+ export { UploadedRow, uploadedOf, uploadedRow, uploadedSweepOf, uploadedSweepRead };
package/dist/lfs/wire.mjs CHANGED
@@ -2,8 +2,8 @@ import { fail, httpStatus } from "../contracts/result.mjs";
2
2
  import { decodeJson } from "../protocol/wire/json.mjs";
3
3
  import { boundedBytes } from "../protocol/bytes/reader.mjs";
4
4
  import { brokenRead, endedEarly, readBody } from "../store/errors.mjs";
5
- import * as Schema from "effect/Schema";
6
5
  import * as Effect from "effect/Effect";
6
+ import * as Schema from "effect/Schema";
7
7
  import * as Result from "effect/Result";
8
8
  // src/lfs/wire.ts
9
9
  /**
@@ -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 Scope from "effect/Scope";
4
4
  /**
5
5
  * The bytes a reading or a writing retains, by the part allotted them, such as `inflater` or
@@ -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
  // src/protocol/bytes/buffers.ts
4
4
  /**
5
5
  * The bytes a reading or a writing retains, by the part allotted them, such as `inflater` or
@@ -1,6 +1,6 @@
1
1
  import { BufferError, BufferMeter } from "./buffers.mjs";
2
- import * as Schema from "effect/Schema";
3
2
  import * as Effect from "effect/Effect";
3
+ import * as Schema from "effect/Schema";
4
4
  import * as Scope from "effect/Scope";
5
5
  /**
6
6
  * One zlib member deflated at a time, as a pack holds one per entry, at zlib's defaults: level 6,
@@ -1,6 +1,6 @@
1
1
  import { allotOrFail, allotScoped, capacityOf } from "./buffers.mjs";
2
- import * as Schema from "effect/Schema";
3
2
  import * as Effect from "effect/Effect";
3
+ import * as Schema from "effect/Schema";
4
4
  import untyped from "pako/lib/zlib/deflate.js";
5
5
  // src/protocol/bytes/deflate.ts
6
6
  /**
@@ -33,8 +33,7 @@ const nodeHmac = (createHmac, key) => {
33
33
  hmac.update(bytes);
34
34
  },
35
35
  digest: async () => Uint8Array.from(hmac.digest()),
36
- abandon: () => void 0,
37
- via: "createHmac"
36
+ abandon: () => void 0
38
37
  };
39
38
  };
40
39
  /**
@@ -59,8 +58,7 @@ const streamedHmac = async (DigestStream, key) => {
59
58
  abandon: () => {
60
59
  stream.digest.catch(() => void 0);
61
60
  writer.abort().catch(() => void 0);
62
- },
63
- via: "DigestStream"
61
+ }
64
62
  };
65
63
  };
66
64
  /** An `HmacSha256` through `Sha256`, in JavaScript. */
@@ -76,8 +74,7 @@ const scriptHmac = (key) => {
76
74
  outer.update(digestOf(inner));
77
75
  return digestOf(outer);
78
76
  },
79
- abandon: () => void 0,
80
- via: "Sha256"
77
+ abandon: () => void 0
81
78
  };
82
79
  };
83
80
  /** An `HmacSha256` under `key`, through the first `on` has: `createHmac`, `DigestStream`, `Sha256`. */
@@ -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 Result from "effect/Result";
4
4
  import * as Scope from "effect/Scope";
5
5
  /** The bytes an inflater keeps between calls, at most: its window, its tables and its state. */
@@ -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 Result from "effect/Result";
4
4
  import untyped from "pako/lib/zlib/inflate.js";
5
5
  // src/protocol/bytes/inflate.ts
@@ -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
  /**
4
4
  * A SHA-1's state between writes: its five words, the bytes it took, and the bytes past its last
5
5
  * whole 64-byte block, as lowercase hex, as many as `length` leaves past a block. Decode stored state through it, so a damaged one fails by
@@ -1,7 +1,7 @@
1
- import * as Schema from "effect/Schema";
2
1
  import * as Effect from "effect/Effect";
3
- import * as Hex from "effect/encoding/Hex";
2
+ import * as Schema from "effect/Schema";
4
3
  import * as Result from "effect/Result";
4
+ import * as Hex from "effect/encoding/Hex";
5
5
  // src/protocol/bytes/sha1.ts
6
6
  /**
7
7
  * SHA-1, as FIPS 180-4 defines it, written a piece at a time, whose state is plain data: a pack's