@ref0/git 0.4.0 → 0.7.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 (463) 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 +31 -17
  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 +13 -9
  13. package/dist/auth/fences.d.mts +1 -1
  14. package/dist/auth/host-function.mjs +17 -8
  15. package/dist/auth/identify.d.mts +5 -3
  16. package/dist/auth/identify.mjs +2 -1
  17. package/dist/auth/namespaces.d.mts +2 -2
  18. package/dist/auth/token-rows.mjs +1 -1
  19. package/dist/auth/tokens-layer.d.mts +42 -0
  20. package/dist/auth/tokens-layer.mjs +29 -0
  21. package/dist/auth/tokens-namespace.d.mts +2 -0
  22. package/dist/auth/tokens-public.d.mts +6 -0
  23. package/dist/auth/tokens-public.mjs +29 -0
  24. package/dist/auth/tokens.d.mts +13 -6
  25. package/dist/auth/tokens.mjs +13 -12
  26. package/dist/auth.d.mts +2 -2
  27. package/dist/auth.mjs +2 -2
  28. package/dist/client/git-http.mjs +1 -1
  29. package/dist/client/local.mjs +6 -3
  30. package/dist/client/remote-helper.mjs +3 -8
  31. package/dist/client/remote.mjs +26 -7
  32. package/dist/client/run-remote-helper.d.mts +1 -1
  33. package/dist/client/run-remote-helper.mjs +2 -2
  34. package/dist/client/slice-push.d.mts +1 -1
  35. package/dist/contracts/access.d.mts +24 -12
  36. package/dist/contracts/access.mjs +17 -0
  37. package/dist/contracts/actors.d.mts +17 -1
  38. package/dist/contracts/actors.mjs +8 -1
  39. package/dist/contracts/authorize.d.mts +21 -14
  40. package/dist/contracts/blobs.d.mts +1 -1
  41. package/dist/contracts/blobs.mjs +1 -1
  42. package/dist/contracts/calls-spent.d.mts +6 -4
  43. package/dist/contracts/calls-spent.mjs +10 -8
  44. package/dist/contracts/commits.d.mts +2 -2
  45. package/dist/contracts/commits.mjs +1 -1
  46. package/dist/contracts/engine.d.mts +1 -1
  47. package/dist/contracts/events.d.mts +64 -26
  48. package/dist/contracts/events.mjs +26 -6
  49. package/dist/contracts/files.d.mts +2 -2
  50. package/dist/contracts/files.mjs +1 -1
  51. package/dist/contracts/forks.d.mts +58 -58
  52. package/dist/contracts/forks.mjs +1 -1
  53. package/dist/contracts/git-events.d.mts +50 -0
  54. package/dist/contracts/git-events.mjs +23 -0
  55. package/dist/contracts/git-hooks.d.mts +37 -0
  56. package/dist/contracts/git-hooks.mjs +10 -0
  57. package/dist/contracts/git.d.mts +138 -22
  58. package/dist/contracts/git.mjs +6 -5
  59. package/dist/contracts/grants.d.mts +6 -1
  60. package/dist/contracts/ids.d.mts +16 -0
  61. package/dist/contracts/ids.mjs +19 -4
  62. package/dist/contracts/lfs.d.mts +7 -2
  63. package/dist/contracts/namespaces.d.mts +2 -2
  64. package/dist/contracts/objects.d.mts +7 -2
  65. package/dist/contracts/opaque.mjs +9 -0
  66. package/dist/contracts/operations.d.mts +293 -100
  67. package/dist/contracts/promises.d.mts +4 -14
  68. package/dist/contracts/push-uploads.d.mts +5 -2
  69. package/dist/contracts/push-uploads.mjs +9 -4
  70. package/dist/contracts/queue.d.mts +233 -54
  71. package/dist/contracts/queue.mjs +81 -6
  72. package/dist/contracts/refs.d.mts +30 -8
  73. package/dist/contracts/refs.mjs +1 -1
  74. package/dist/contracts/remote.d.mts +42 -21
  75. package/dist/contracts/remote.mjs +22 -0
  76. package/dist/contracts/repo-records.d.mts +2 -2
  77. package/dist/contracts/repos.d.mts +126 -79
  78. package/dist/contracts/repos.mjs +43 -5
  79. package/dist/contracts/result.d.mts +50 -31
  80. package/dist/contracts/result.mjs +48 -16
  81. package/dist/contracts/rules.d.mts +50 -44
  82. package/dist/contracts/rules.mjs +5 -1
  83. package/dist/contracts/server.d.mts +282 -191
  84. package/dist/contracts/services.d.mts +1 -7
  85. package/dist/contracts/services.mjs +1 -3
  86. package/dist/contracts/signin.d.mts +140 -43
  87. package/dist/contracts/signin.mjs +35 -1
  88. package/dist/contracts/store.d.mts +1 -1
  89. package/dist/contracts/sync.d.mts +112 -90
  90. package/dist/contracts/sync.mjs +34 -7
  91. package/dist/contracts/tags.d.mts +1 -1
  92. package/dist/contracts/tags.mjs +1 -1
  93. package/dist/contracts/tokens.d.mts +232 -57
  94. package/dist/contracts/tokens.mjs +80 -19
  95. package/dist/contracts/topics.d.mts +22 -10
  96. package/dist/contracts/topics.mjs +6 -3
  97. package/dist/contracts/trees.d.mts +2 -2
  98. package/dist/contracts/trees.mjs +1 -1
  99. package/dist/contracts/work.d.mts +3 -3
  100. package/dist/contracts/work.mjs +2 -2
  101. package/dist/core/access.d.mts +10 -10
  102. package/dist/core/access.mjs +47 -8
  103. package/dist/core/call-names.d.mts +3 -1
  104. package/dist/core/clock.mjs +1 -1
  105. package/dist/core/events/deliver.d.mts +13 -0
  106. package/dist/core/events/deliver.mjs +475 -175
  107. package/dist/core/events/seen.mjs +17 -3
  108. package/dist/core/forks.mjs +131 -44
  109. package/dist/core/hooks/groups.d.mts +27 -0
  110. package/dist/core/hooks/groups.mjs +74 -0
  111. package/dist/core/hooks/namespace.d.mts +2 -0
  112. package/dist/core/hooks/order.d.mts +2 -2
  113. package/dist/core/hooks/order.mjs +6 -6
  114. package/dist/core/hooks/public.d.mts +7 -0
  115. package/dist/core/hooks/public.mjs +5 -0
  116. package/dist/core/imports.mjs +94 -10
  117. package/dist/core/index-job.mjs +31 -22
  118. package/dist/core/merge-parts.d.mts +1 -1
  119. package/dist/core/merge-parts.mjs +1 -1
  120. package/dist/core/mirror-rows.mjs +18 -0
  121. package/dist/core/names.mjs +1 -1
  122. package/dist/core/namespaces.d.mts +2 -1
  123. package/dist/core/objects/commit-writes.mjs +5 -5
  124. package/dist/core/objects/merges.mjs +1 -1
  125. package/dist/core/objects/objects-layer.mjs +1 -1
  126. package/dist/core/objects/reading.mjs +52 -7
  127. package/dist/core/objects/tree-edits.mjs +13 -28
  128. package/dist/core/objects/trees.mjs +4 -4
  129. package/dist/core/objects/writing.mjs +3 -3
  130. package/dist/core/own-writes.mjs +1 -1
  131. package/dist/core/parts.d.mts +27 -2
  132. package/dist/core/parts.mjs +5 -3
  133. package/dist/core/promise.mjs +23 -3
  134. package/dist/core/purge.d.mts +8 -0
  135. package/dist/core/purge.mjs +91 -46
  136. package/dist/core/push-decide.mjs +26 -4
  137. package/dist/core/push.mjs +104 -86
  138. package/dist/core/receipts.d.mts +2 -2
  139. package/dist/core/receipts.mjs +28 -4
  140. package/dist/core/ref-index-job.mjs +10 -15
  141. package/dist/core/ref-index.d.mts +1 -0
  142. package/dist/core/ref-index.mjs +28 -8
  143. package/dist/core/ref-view.mjs +16 -11
  144. package/dist/core/refs.mjs +54 -21
  145. package/dist/core/registered-records.mjs +30 -0
  146. package/dist/core/registered-rows.d.mts +4 -0
  147. package/dist/core/registered-rows.mjs +53 -0
  148. package/dist/core/repack.d.mts +3 -2
  149. package/dist/core/repack.mjs +70 -120
  150. package/dist/core/repo-info.mjs +59 -25
  151. package/dist/core/repos.mjs +22 -16
  152. package/dist/core/rules/changes.mjs +2 -2
  153. package/dist/core/rules/check.mjs +7 -6
  154. package/dist/core/rules/commit-changes.mjs +1 -1
  155. package/dist/core/rules/context.d.mts +4 -5
  156. package/dist/core/rules/context.mjs +3 -4
  157. package/dist/core/rules/fetch.mjs +74 -21
  158. package/dist/core/saved-caller-views.d.mts +72 -0
  159. package/dist/core/saved-caller-views.mjs +123 -0
  160. package/dist/core/saved-callers-public.d.mts +5 -0
  161. package/dist/core/saved-callers-public.mjs +10 -0
  162. package/dist/core/saved-callers.mjs +95 -0
  163. package/dist/core/seam.d.mts +67 -9
  164. package/dist/core/seam.mjs +11 -3
  165. package/dist/core/still-takes.mjs +75 -0
  166. package/dist/core/tokens.mjs +5 -1
  167. package/dist/core/view.d.mts +2 -1
  168. package/dist/core/view.mjs +9 -10
  169. package/dist/core/work.mjs +6 -5
  170. package/dist/effect.d.mts +2 -2
  171. package/dist/effect.mjs +2 -2
  172. package/dist/engine/content.d.mts +2 -2
  173. package/dist/engine/content.mjs +1 -1
  174. package/dist/engine/diff.mjs +2 -2
  175. package/dist/engine/merge-base-walk.d.mts +2 -2
  176. package/dist/engine/merge-base-walk.mjs +1 -1
  177. package/dist/engine/merge-renames.mjs +1 -1
  178. package/dist/engine/reads.d.mts +2 -2
  179. package/dist/engine/reads.mjs +1 -1
  180. package/dist/engine/xdiff.d.mts +1 -1
  181. package/dist/engine/xdiff.mjs +2 -2
  182. package/dist/event-streams/event-streams.d.mts +6 -2
  183. package/dist/event-streams/event-streams.mjs +6 -2
  184. package/dist/event-streams/stream.mjs +5 -2
  185. package/dist/extend.d.mts +5 -4
  186. package/dist/extend.mjs +3 -2
  187. package/dist/http/answers.mjs +4 -3
  188. package/dist/http/core-parts.mjs +21 -13
  189. package/dist/http/handler.mjs +3 -3
  190. package/dist/http/node.d.mts +2 -23
  191. package/dist/http/parts.d.mts +2 -0
  192. package/dist/http/push-uploads.d.mts +10 -2
  193. package/dist/http/push-uploads.mjs +38 -39
  194. package/dist/http/receive-pack.mjs +8 -6
  195. package/dist/http/upload-pack.mjs +8 -7
  196. package/dist/index.d.mts +36 -19
  197. package/dist/index.mjs +14 -6
  198. package/dist/lfs/base.d.mts +32 -0
  199. package/dist/lfs/base.mjs +8 -0
  200. package/dist/lfs/calls.mjs +22 -12
  201. package/dist/lfs/layer.d.mts +28 -0
  202. package/dist/lfs/layer.mjs +65 -0
  203. package/dist/lfs/locks.mjs +16 -30
  204. package/dist/lfs/namespace.d.mts +2 -0
  205. package/dist/lfs/objects.d.mts +26 -6
  206. package/dist/lfs/objects.mjs +197 -98
  207. package/dist/lfs/pointers.mjs +8 -6
  208. package/dist/lfs/public.d.mts +5 -0
  209. package/dist/lfs/public.mjs +8 -0
  210. package/dist/lfs/purge.mjs +19 -25
  211. package/dist/lfs/rows.mjs +22 -10
  212. package/dist/lfs/service.d.mts +9 -4
  213. package/dist/lfs/service.mjs +3 -12
  214. package/dist/lfs/upkeep.mjs +45 -56
  215. package/dist/lfs/wire.mjs +1 -1
  216. package/dist/node.d.mts +3 -2
  217. package/dist/node.mjs +1 -1
  218. package/dist/protocol/bytes/buffers.d.mts +1 -1
  219. package/dist/protocol/bytes/buffers.mjs +1 -1
  220. package/dist/protocol/bytes/deflate.d.mts +1 -1
  221. package/dist/protocol/bytes/deflate.mjs +1 -1
  222. package/dist/protocol/bytes/hmac-sha256.mjs +3 -6
  223. package/dist/protocol/bytes/inflate.d.mts +1 -1
  224. package/dist/protocol/bytes/inflate.mjs +1 -1
  225. package/dist/protocol/bytes/sha1.d.mts +1 -1
  226. package/dist/protocol/bytes/sha1.mjs +2 -2
  227. package/dist/protocol/diff/read.d.mts +1 -1
  228. package/dist/protocol/diff/read.mjs +1 -1
  229. package/dist/protocol/diff/tree-diff.d.mts +1 -1
  230. package/dist/protocol/diff/tree-diff.mjs +11 -11
  231. package/dist/protocol/objects/lfs-pointer.mjs +6 -1
  232. package/dist/protocol/objects/tag.mjs +1 -1
  233. package/dist/protocol/objects/tree.mjs +1 -1
  234. package/dist/protocol/packs/graph.mjs +1 -1
  235. package/dist/protocol/packs/idx.d.mts +1 -1
  236. package/dist/protocol/packs/idx.mjs +1 -1
  237. package/dist/protocol/packs/parts.mjs +1 -1
  238. package/dist/protocol/packs/reader.d.mts +1 -1
  239. package/dist/protocol/packs/reader.mjs +2 -2
  240. package/dist/protocol/packs/write-error.d.mts +1 -1
  241. package/dist/protocol/packs/write-error.mjs +1 -1
  242. package/dist/protocol/packs/writer.mjs +4 -4
  243. package/dist/protocol/wire/advertisement.d.mts +5 -11
  244. package/dist/protocol/wire/advertisement.mjs +17 -13
  245. package/dist/protocol/wire/fetch.d.mts +1 -1
  246. package/dist/protocol/wire/fetch.mjs +1 -1
  247. package/dist/protocol/wire/lines.d.mts +14 -2
  248. package/dist/protocol/wire/lines.mjs +32 -21
  249. package/dist/protocol/wire/push-uploads.mjs +4 -2
  250. package/dist/protocol/wire/receive-pack.d.mts +1 -1
  251. package/dist/protocol/wire/receive-pack.mjs +1 -1
  252. package/dist/protocol/wire/report-status.d.mts +1 -1
  253. package/dist/protocol/wire/report-status.mjs +1 -1
  254. package/dist/protocol/wire/v2.d.mts +5 -16
  255. package/dist/protocol/wire/v2.mjs +17 -15
  256. package/dist/queue/advance.mjs +227 -112
  257. package/dist/queue/callers.mjs +56 -69
  258. package/dist/queue/calls.mjs +24 -13
  259. package/dist/queue/commit.mjs +20 -7
  260. package/dist/queue/host.d.mts +12 -13
  261. package/dist/queue/host.mjs +15 -7
  262. package/dist/queue/lanes.mjs +9 -18
  263. package/dist/queue/layer.d.mts +6 -4
  264. package/dist/queue/layer.mjs +17 -11
  265. package/dist/queue/limits.mjs +53 -11
  266. package/dist/queue/rows.mjs +19 -15
  267. package/dist/queue/schedule.mjs +6 -5
  268. package/dist/queue/search.mjs +8 -13
  269. package/dist/queue/state.mjs +26 -7
  270. package/dist/queue/steps.mjs +10 -4
  271. package/dist/queue/trim.mjs +289 -0
  272. package/dist/rest/api.d.mts +1 -1
  273. package/dist/rest/blobs.d.mts +35 -35
  274. package/dist/rest/caller.d.mts +22 -20
  275. package/dist/rest/client.mjs +6 -6
  276. package/dist/rest/commits.d.mts +274 -274
  277. package/dist/rest/errors.d.mts +10 -10
  278. package/dist/rest/errors.mjs +1 -1
  279. package/dist/rest/events.d.mts +13 -11
  280. package/dist/rest/events.mjs +3 -1
  281. package/dist/rest/files.d.mts +78 -78
  282. package/dist/rest/forks.d.mts +170 -170
  283. package/dist/rest/handler.mjs +17 -8
  284. package/dist/rest/handlers.mjs +13 -7
  285. package/dist/rest/layer.d.mts +14 -0
  286. package/dist/rest/layer.mjs +53 -0
  287. package/dist/rest/listen.mjs +2 -2
  288. package/dist/rest/me.d.mts +18 -20
  289. package/dist/rest/me.mjs +1 -1
  290. package/dist/rest/merges.d.mts +10 -10
  291. package/dist/rest/namespace.d.mts +2 -0
  292. package/dist/rest/queue.d.mts +320 -320
  293. package/dist/rest/queue.mjs +1 -1
  294. package/dist/rest/refs.d.mts +207 -207
  295. package/dist/rest/refs.mjs +1 -1
  296. package/dist/rest/repos.d.mts +127 -127
  297. package/dist/rest/tags.d.mts +94 -94
  298. package/dist/rest/tokens.d.mts +248 -258
  299. package/dist/rest/tokens.mjs +10 -42
  300. package/dist/rest/topics.d.mts +154 -154
  301. package/dist/rest/topics.mjs +1 -1
  302. package/dist/rest/trees.d.mts +84 -84
  303. package/dist/rest/wire.d.mts +8 -4
  304. package/dist/rest/wire.mjs +3 -2
  305. package/dist/rest/work.d.mts +69 -69
  306. package/dist/rest/work.mjs +1 -1
  307. package/dist/server/check-fetch.mjs +9 -0
  308. package/dist/server/edge-node.d.mts +20 -0
  309. package/dist/server/edge-node.mjs +20 -0
  310. package/dist/server/edge.d.mts +10 -0
  311. package/dist/server/edge.mjs +23 -0
  312. package/dist/server/extension.mjs +3 -115
  313. package/dist/server/git-layer.d.mts +34 -6
  314. package/dist/server/git-layer.mjs +40 -18
  315. package/dist/server/git-namespace.d.mts +5 -4
  316. package/dist/server/git-namespace.mjs +10 -5
  317. package/dist/server/joined.d.mts +83 -0
  318. package/dist/server/joined.mjs +91 -0
  319. package/dist/server/registry.d.mts +9 -2
  320. package/dist/server/registry.mjs +179 -24
  321. package/dist/server/routes.mjs +2 -2
  322. package/dist/server/server.d.mts +11 -1
  323. package/dist/server/server.mjs +331 -201
  324. package/dist/server/uploads.d.mts +14 -0
  325. package/dist/server/uploads.mjs +15 -0
  326. package/dist/signin/context.d.mts +2 -1
  327. package/dist/signin/context.mjs +32 -37
  328. package/dist/signin/device.mjs +5 -5
  329. package/dist/signin/forms.mjs +1 -1
  330. package/dist/signin/grants.d.mts +2 -3
  331. package/dist/signin/grants.mjs +5 -5
  332. package/dist/signin/layer.d.mts +9 -0
  333. package/dist/signin/layer.mjs +41 -0
  334. package/dist/signin/namespace.d.mts +2 -0
  335. package/dist/signin/public.d.mts +6 -0
  336. package/dist/signin/public.mjs +5 -0
  337. package/dist/signin/route.mjs +47 -21
  338. package/dist/signin/web.mjs +3 -3
  339. package/dist/signin/wire.mjs +1 -1
  340. package/dist/storage/calls.d.mts +7 -8
  341. package/dist/storage/calls.mjs +17 -17
  342. package/dist/storage/clean-up.mjs +71 -34
  343. package/dist/storage/counted-bucket.mjs +34 -51
  344. package/dist/storage/fetch.mjs +1 -1
  345. package/dist/storage/host-bucket.mjs +17 -2
  346. package/dist/storage/index-build.d.mts +2 -2
  347. package/dist/storage/index-build.mjs +3 -3
  348. package/dist/storage/index-fetch.mjs +10 -6
  349. package/dist/storage/index-graph.mjs +1 -1
  350. package/dist/storage/index-layers.mjs +1 -1
  351. package/dist/storage/index-visible.mjs +1 -1
  352. package/dist/storage/layout.mjs +5 -0
  353. package/dist/storage/memory-budget.mjs +7 -1
  354. package/dist/storage/merge-cut.mjs +24 -1
  355. package/dist/storage/merge-fence.mjs +1 -1
  356. package/dist/storage/merge-plan.mjs +5 -2
  357. package/dist/storage/merge-row.mjs +1 -1
  358. package/dist/storage/merge-stream.mjs +16 -7
  359. package/dist/storage/merge-write.mjs +1 -1
  360. package/dist/storage/merge.d.mts +2 -2
  361. package/dist/storage/merge.mjs +1 -1
  362. package/dist/storage/object-rows.d.mts +2 -2
  363. package/dist/storage/object-rows.mjs +3 -3
  364. package/dist/storage/pack-ranges.d.mts +3 -1
  365. package/dist/storage/pack-ranges.mjs +168 -69
  366. package/dist/storage/pack-reads.mjs +4 -4
  367. package/dist/storage/pack-receive.d.mts +1 -1
  368. package/dist/storage/pack-receive.mjs +7 -9
  369. package/dist/storage/packs.d.mts +1 -1
  370. package/dist/storage/packs.mjs +45 -52
  371. package/dist/storage/placed-reads.mjs +81 -15
  372. package/dist/storage/prune-seen.mjs +126 -0
  373. package/dist/storage/prune-walk.mjs +87 -99
  374. package/dist/storage/prune.mjs +49 -14
  375. package/dist/storage/push-uploads.mjs +16 -18
  376. package/dist/storage/quarantine.d.mts +2 -2
  377. package/dist/storage/quarantine.mjs +51 -12
  378. package/dist/storage/ready.d.mts +2 -2
  379. package/dist/storage/ready.mjs +3 -3
  380. package/dist/storage/receive-bounds.d.mts +1 -1
  381. package/dist/storage/receive-files.mjs +1 -1
  382. package/dist/storage/receive-links.mjs +1 -1
  383. package/dist/storage/receive-state.d.mts +2 -2
  384. package/dist/storage/receive-state.mjs +1 -1
  385. package/dist/storage/receive-steps.mjs +1 -1
  386. package/dist/storage/repack-contained.mjs +2 -2
  387. package/dist/storage/repack-job.d.mts +2 -2
  388. package/dist/storage/repack-job.mjs +11 -17
  389. package/dist/storage/repack.d.mts +1 -1
  390. package/dist/storage/repack.mjs +9 -3
  391. package/dist/storage/rows.d.mts +2 -2
  392. package/dist/storage/rows.mjs +43 -4
  393. package/dist/storage/runs.d.mts +2 -2
  394. package/dist/storage/runs.mjs +15 -6
  395. package/dist/storage/send-list.mjs +6 -6
  396. package/dist/storage/single-flight.mjs +2 -2
  397. package/dist/storage/swap-walk.mjs +1 -1
  398. package/dist/storage/unpack.mjs +1 -1
  399. package/dist/store/call-count.d.mts +1 -1
  400. package/dist/store/call-count.mjs +125 -34
  401. package/dist/store/catalogue.d.mts +1 -1
  402. package/dist/store/catalogue.mjs +2 -2
  403. package/dist/store/crossing.mjs +2 -6
  404. package/dist/store/cursor-seal.mjs +1 -1
  405. package/dist/store/errors.d.mts +7 -3
  406. package/dist/store/errors.mjs +41 -13
  407. package/dist/store/job-try.mjs +130 -0
  408. package/dist/store/list-job.mjs +22 -16
  409. package/dist/store/outbox.d.mts +2 -2
  410. package/dist/store/outbox.mjs +112 -27
  411. package/dist/store/promises.d.mts +8 -3
  412. package/dist/store/promises.mjs +104 -94
  413. package/dist/store/queue-jobs.mjs +23 -2
  414. package/dist/store/records.d.mts +2 -2
  415. package/dist/store/records.mjs +16 -24
  416. package/dist/store/ref-rows.d.mts +2 -2
  417. package/dist/store/ref-rows.mjs +6 -6
  418. package/dist/store/reservations.mjs +35 -8
  419. package/dist/store/scopes.mjs +6 -14
  420. package/dist/store/topic-jobs.mjs +8 -8
  421. package/dist/sync/bound.d.mts +1 -3
  422. package/dist/sync/bound.mjs +30 -42
  423. package/dist/sync/bridge.d.mts +6 -0
  424. package/dist/sync/bridge.mjs +29 -0
  425. package/dist/sync/github.d.mts +5 -6
  426. package/dist/sync/github.mjs +37 -42
  427. package/dist/sync/http.mjs +15 -0
  428. package/dist/sync/import.mjs +17 -18
  429. package/dist/sync/layer.d.mts +9 -0
  430. package/dist/sync/layer.mjs +68 -0
  431. package/dist/sync/mirror.mjs +138 -59
  432. package/dist/sync/publish.mjs +15 -13
  433. package/dist/sync/step.mjs +221 -79
  434. package/dist/sync/tries.mjs +22 -15
  435. package/dist/sync.d.mts +3 -6
  436. package/dist/sync.mjs +3 -6
  437. package/dist/topics/advance.mjs +205 -90
  438. package/dist/topics/calls.mjs +8 -8
  439. package/dist/topics/directory.mjs +35 -12
  440. package/dist/topics/host.d.mts +5 -8
  441. package/dist/topics/host.mjs +42 -19
  442. package/dist/topics/layer.d.mts +381 -0
  443. package/dist/topics/layer.mjs +62 -0
  444. package/dist/topics/members.mjs +1 -1
  445. package/dist/topics/namespace.d.mts +2 -0
  446. package/dist/topics/public.d.mts +6 -0
  447. package/dist/topics/public.mjs +13 -0
  448. package/dist/topics/rows.mjs +12 -3
  449. package/dist/topics/topic.mjs +11 -10
  450. package/package.json +8 -13
  451. package/dist/access.d.mts +0 -2
  452. package/dist/access.mjs +0 -1
  453. package/dist/core/hooks/post-receive.mjs +0 -213
  454. package/dist/core/hooks/pre-receive.d.mts +0 -12
  455. package/dist/core/hooks/pre-receive.mjs +0 -36
  456. package/dist/lfs/repo.mjs +0 -42
  457. package/dist/server/extension.d.mts +0 -21
  458. package/dist/storage/promise-calls.mjs +0 -29
  459. package/dist/sync/import.d.mts +0 -10
  460. package/dist/sync/jobs.d.mts +0 -9
  461. package/dist/sync/jobs.mjs +0 -75
  462. package/dist/sync/mirror.d.mts +0 -13
  463. package/dist/sync/publish.d.mts +0 -6
@@ -1,54 +1,52 @@
1
1
  import { Sha256 } from "../protocol/bytes/sha256.mjs";
2
- import { contended } from "../core/access.mjs";
3
- import { CoreParts } from "../core/parts.mjs";
4
- import { readRecord } from "../store/repo-record.mjs";
5
- import { decodeRow, storeCall } from "../store/errors.mjs";
2
+ import { contended, openFor } from "../core/access.mjs";
3
+ import { seenIn } from "../core/objects/reading.mjs";
4
+ import { checkRead, readRefusal } from "../core/rules/fetch.mjs";
5
+ import { utf8 } from "../protocol/bytes/text.mjs";
6
+ import { objectId } from "../protocol/objects/object.mjs";
7
+ import { bestEffort, decodeRow } from "../store/errors.mjs";
6
8
  import { randomText } from "../store/random.mjs";
7
- import { collections, newChangeId, repoScope } from "../store/scopes.mjs";
8
- import { fenceFor, fencedRead, openFor } from "./repo.mjs";
9
- import { bucketCall } from "../storage/calls.mjs";
10
- import { promisePut, promiseStream } from "../storage/promise-calls.mjs";
11
- import { isLfsOid } from "../protocol/objects/lfs-pointer.mjs";
12
- import { ListedRow, UploadRow, largestObject, linkLife, listedKey, listedRead, objectKey, stagingId, stagingKey, stagingRead, streamMost, uploadGrace, uploadKey, uploadRead } from "./rows.mjs";
9
+ import { bucketCall, bucketDo, bucketFailed, bucketStream } from "../storage/calls.mjs";
10
+ import { isLfsOid, lfsPointerText } from "../protocol/objects/lfs-pointer.mjs";
11
+ import { ListedRow, UploadRow, largestObject, lfsCollections, linkLife, listedKey, listedRead, objectKey, stagingId, stagingKey, stagingRead, streamMost, uploadGrace, uploadKey, uploadRead } from "./rows.mjs";
13
12
  import { BatchRequest, VerifyRequest, batchMost, bodyOf, lfsAnswer } from "./wire.mjs";
14
- import { fail, gitError } from "../contracts/result.mjs";
15
- import * as Effect from "effect/Effect";
13
+ import { fail, gitError, httpStatus } from "../contracts/result.mjs";
16
14
  import * as Clock$1 from "effect/Clock";
15
+ import * as Effect from "effect/Effect";
16
+ import * as Option from "effect/Option";
17
+ import { Unavailable } from "@ref0/infra";
18
+ import * as Stream from "effect/Stream";
17
19
  import * as DateTime from "effect/DateTime";
18
20
  // src/lfs/objects.ts
19
- /** A bucket's own LFS signing: links to read, and uploads it checks against their SHA-256. */
20
- const signingOf = (bucket) => isSigned(bucket) ? bucket : void 0;
21
- /** A bucket made with signing, as `r2()` given S3 credentials makes one, has all three. */
22
- const isSigned = (bucket) => "url" in bucket && "putUrl" in bucket && "head" in bucket;
23
21
  /**
24
22
  * Each object's rows, read with the repo's record and the fence's rows at one version, the fence
25
23
  * checked; `also`'s rows after them. A repo deleted since it opened is `NOT_FOUND`.
26
24
  */
27
- const objectRows = /* @__PURE__ */ Effect.fnUntraced(function* (core, repo, fence, oids, also = []) {
25
+ const objectRows = /* @__PURE__ */ Effect.fnUntraced(function* (rows, caller, repo, oids, also = []) {
28
26
  const own = oids.flatMap((oid) => [listedRead(oid), uploadRead(oid)]);
29
- const { version, results } = yield* fencedRead(core, repo, fence, [...own, ...also]);
30
- const rows = /* @__PURE__ */ new Map();
27
+ const { version, results } = yield* rows.readFenced(caller, repo, [...own, ...also]);
28
+ const found = /* @__PURE__ */ new Map();
31
29
  for (const [at, oid] of oids.entries()) {
32
30
  const [listedRows = [], uploadRows = []] = results.slice(at * 2, at * 2 + 2);
33
- const found = {};
34
- if (listedRows[0] !== void 0) found.listed = yield* decodeListed(listedRows[0], oid);
35
- if (uploadRows[0] !== void 0) found.upload = yield* decodeUpload(uploadRows[0], oid);
36
- rows.set(oid, found);
31
+ const one = {};
32
+ if (listedRows[0] !== void 0) one.listed = yield* decodeListed(listedRows[0], oid);
33
+ if (uploadRows[0] !== void 0) one.upload = yield* decodeUpload(uploadRows[0], oid);
34
+ found.set(oid, one);
37
35
  }
38
36
  return {
39
37
  version,
40
- rows,
38
+ rows: found,
41
39
  also: results.slice(own.length)
42
40
  };
43
41
  });
44
42
  const decodeListed = (row, oid) => decodeRow(ListedRow, row, `LFS object ${oid}`);
45
43
  const decodeUpload = (row, oid) => decodeRow(UploadRow, row, `LFS object ${oid}'s upload`);
46
44
  /** The repo's listed rows of `oids`, read in chunks. */
47
- const listedOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, oids) {
45
+ const listedOf = /* @__PURE__ */ Effect.fnUntraced(function* (rows, repo, oids) {
48
46
  const listed = /* @__PURE__ */ new Map();
49
47
  for (let at = 0; at < oids.length; at += 100) {
50
48
  const chunk = oids.slice(at, at + 100);
51
- const snapshot = yield* storeCall(() => store.read(repoScope(repo), chunk.map(listedRead)));
49
+ const snapshot = yield* rows.read(repo, chunk.map(listedRead));
52
50
  for (const [index, oid] of chunk.entries()) {
53
51
  const row = snapshot.results[index]?.[0];
54
52
  if (row !== void 0) listed.set(oid, yield* decodeListed(row, oid));
@@ -57,24 +55,64 @@ const listedOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, oids)
57
55
  return listed;
58
56
  });
59
57
  /**
60
- * The listed rows of `oids` a download from `repo` reads: its own, then, for each still missing,
61
- * its source's, up the fork chain by internal ID for at most `forkReads` sources. The first listing
62
- * wins, so a fork's own upload shadows its source's. A deleted source's rows are read too: its LFS
63
- * rows and bytes stay while a fork's row names it, since `git.purge` waits on one.
58
+ * The listed rows of `oids` a download from `repo` reads: its own, then its source's, up the fork
59
+ * chain by internal ID for at most `forkReads` sources. The first listing wins, so a fork's own
60
+ * upload shadows its source's. Each source's rows of every one of `oids` are read, found sooner or
61
+ * not, so the reads made are the same whichever of them are listed, as `unseenOf` needs. A deleted
62
+ * source's rows are read too: its LFS rows and bytes stay while a fork's row names it, since
63
+ * `git.purge` waits on one.
64
64
  */
65
- const chainListed = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, oids) {
66
- const listed = yield* listedOf(store, repo, oids);
65
+ const chainListed = /* @__PURE__ */ Effect.fnUntraced(function* (rows, repo, oids) {
66
+ const listed = yield* listedOf(rows, repo, oids);
67
+ if (oids.length === 0) return listed;
67
68
  let from = repo;
68
69
  for (let read = 0; read < 16; read += 1) {
69
- const missing = oids.filter((oid) => !listed.has(oid));
70
- if (missing.length === 0) break;
71
- const source = (yield* readRecord(store, from)).record?.fork?.upstreamInternalId;
70
+ const source = yield* rows.source(from);
72
71
  if (source === void 0) break;
73
- for (const [oid, row] of yield* listedOf(store, source, missing)) listed.set(oid, row);
72
+ for (const [oid, row] of yield* listedOf(rows, source, oids)) if (!listed.has(oid)) listed.set(oid, row);
74
73
  from = source;
75
74
  }
76
75
  return listed;
77
76
  });
77
+ /**
78
+ * Which of `listed`'s objects `caller` mayn't know `repo` lists. A caller whose view of it is
79
+ * narrowed (`RepoView.narrowed`), as under `access` one who doesn't read every pattern is, knows of
80
+ * a listed object only when a ref it sees reaches its pointer as git-lfs writes it
81
+ * (`lfsPointerText`), so an object only a hidden ref's tree points at answers as one never
82
+ * uploaded. So does one only a pointer of another text names, with an extension or blank lines.
83
+ * The view is asked of a pointer for each of `oids`, listed or not, by the listed size or else 0,
84
+ * so the calls it makes are the same whichever of them are listed. Any other caller knows of every
85
+ * one: its view answers that it isn't narrowed, and nothing more is read.
86
+ */
87
+ const unseenOf = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo, oids, listed) {
88
+ const unseen = /* @__PURE__ */ new Set();
89
+ const pointers = /* @__PURE__ */ new Map();
90
+ for (const oid of new Set(oids)) {
91
+ const text = lfsPointerText({
92
+ oid,
93
+ size: listed.get(oid)?.size ?? 0
94
+ });
95
+ pointers.set(yield* objectId({
96
+ type: "blob",
97
+ bytes: utf8(text)
98
+ }), oid);
99
+ }
100
+ const seen = yield* seenIn(caller, repo, [...pointers.keys()]);
101
+ if (seen === void 0) return unseen;
102
+ for (const [pointer, oid] of pointers) if (listed.has(oid) && !seen.has(pointer)) unseen.add(oid);
103
+ return unseen;
104
+ });
105
+ /** `listed`, less what `caller` mayn't know of, asked for each of `oids`, as `unseenOf` says. */
106
+ const seenListed = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo, oids, listed) {
107
+ const unseen = yield* unseenOf(caller, repo, oids, listed);
108
+ return unseen.size === 0 ? listed : new Map([...listed].filter(([oid]) => !unseen.has(oid)));
109
+ });
110
+ /** Which of `rows`' objects `caller` mayn't know are listed, asked for each of `oids`, as `unseenOf` says. */
111
+ const unseenRows = (caller, repo, oids, rows) => {
112
+ const listed = /* @__PURE__ */ new Map();
113
+ for (const [oid, { listed: row }] of rows) if (row !== void 0) listed.set(oid, row);
114
+ return unseenOf(caller, repo, oids, listed);
115
+ };
78
116
  const isoOf = (at) => DateTime.formatIso(DateTime.makeUnsafe(at));
79
117
  /** An action back to this server, sending the request's own credentials. */
80
118
  const ownAction = (call, path, expiresAt) => {
@@ -113,9 +151,32 @@ const batch = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call) {
113
151
  });
114
152
  });
115
153
  const validSize = (size) => Number.isSafeInteger(size) && size >= 0 && size <= largestObject;
154
+ /**
155
+ * The host's fetch rules' refusals of `listed`'s objects, each listed object the caller knows of
156
+ * asked once, before any link is signed. A host's failure fails the whole batch.
157
+ */
158
+ const refusedOf = /* @__PURE__ */ Effect.fnUntraced(function* (call, listed) {
159
+ const refused = /* @__PURE__ */ new Map();
160
+ for (const [oid, { size }] of listed) {
161
+ const target = {
162
+ kind: "lfs",
163
+ oid,
164
+ size
165
+ };
166
+ const refusal = yield* readRefusal(call.repo, {
167
+ caller: call.caller,
168
+ target,
169
+ request: call.request
170
+ });
171
+ if (refusal !== void 0) refused.set(oid, refusal);
172
+ }
173
+ return refused;
174
+ });
116
175
  const downloads = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, repo, objects) {
117
176
  const oids = objects.map(({ oid }) => oid);
118
- const listed = yield* chainListed(parts.core.store, repo.internalId, oids);
177
+ const chained = yield* chainListed(parts.rows, repo.internalId, oids);
178
+ const listed = yield* seenListed(call.caller, repo, oids, chained);
179
+ const refused = yield* refusedOf(call, listed);
119
180
  const expiresAt = (yield* Clock$1.currentTimeMillis) + linkLife;
120
181
  const answers = /* @__PURE__ */ new Map();
121
182
  for (const { oid, size } of objects) {
@@ -124,13 +185,15 @@ const downloads = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, repo
124
185
  answers.set(oid, objectError(oid, size, 404, "Object does not exist"));
125
186
  continue;
126
187
  }
188
+ const refusal = refused.get(oid);
189
+ if (refusal !== void 0) {
190
+ answers.set(oid, objectError(oid, size, httpStatus[refusal.code], refusal.message));
191
+ continue;
192
+ }
127
193
  const key = row.key;
128
194
  const signed = parts.signed;
129
195
  const download = signed === void 0 ? ownAction(call, `objects/${oid}`, expiresAt) : {
130
- href: yield* bucketCall((signal) => signed.url(key, {
131
- expiresAt,
132
- signal
133
- })),
196
+ href: yield* bucketCall(signed.url(key, { expiresAt })),
134
197
  expires_at: isoOf(expiresAt)
135
198
  };
136
199
  answers.set(oid, {
@@ -149,15 +212,14 @@ const downloads = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, repo
149
212
  * so its links all write one key; a new row gets a new one.
150
213
  */
151
214
  const uploads = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, repo, objects) {
152
- const { core } = parts;
153
- const fence = fenceFor(core, call.caller, repo);
154
215
  const oids = objects.map(({ oid }) => oid);
155
216
  for (let tries = 0; tries < 5; tries += 1) {
156
217
  const at = yield* Clock$1.currentTimeMillis;
157
- const read = yield* objectRows(core, repo, fence, oids);
218
+ const read = yield* objectRows(parts.rows, call.caller, repo, oids);
219
+ const unseen = yield* unseenRows(call.caller, repo, oids, read.rows);
158
220
  const expiresAt = at + linkLife;
159
221
  const removeAt = expiresAt + uploadGrace;
160
- const put = objects.filter(({ oid }) => read.rows.get(oid)?.listed === void 0).map(({ oid, size }) => {
222
+ const put = objects.filter(({ oid }) => read.rows.get(oid)?.listed === void 0 || unseen.has(oid)).map(({ oid, size }) => {
161
223
  const before = read.rows.get(oid)?.upload;
162
224
  const value = {
163
225
  size,
@@ -171,12 +233,10 @@ const uploads = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, repo,
171
233
  };
172
234
  });
173
235
  if (put.length > 0) {
174
- if (!(yield* storeCall(() => core.store.commit(repoScope(repo.internalId), {
175
- id: newChangeId(),
176
- expect: read.version,
236
+ if (!(yield* parts.rows.commit(repo.internalId, read.version, {
177
237
  put,
178
- jobs: [core.repackJobRow(removeAt)]
179
- }))).ok) continue;
238
+ wake: removeAt
239
+ })).ok) continue;
180
240
  }
181
241
  const answers = /* @__PURE__ */ new Map();
182
242
  const generations = new Map(put.map((row) => [row.id, row.value.generation]));
@@ -203,10 +263,9 @@ const uploadActions = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call,
203
263
  const signed = parts.signed;
204
264
  if (signed === void 0) return { upload: ownAction(call, `objects/${oid}`, expiresAt) };
205
265
  return {
206
- upload: yield* bucketCall((signal) => signed.putUrl(key, {
266
+ upload: yield* bucketCall(signed.putUrl(key, {
207
267
  sha256: oid,
208
- expiresAt,
209
- signal
268
+ expiresAt
210
269
  })),
211
270
  verify: ownAction(call, "objects/verify", expiresAt)
212
271
  };
@@ -220,20 +279,19 @@ const uploadActions = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call,
220
279
  const verify = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call) {
221
280
  const { oid, size } = yield* bodyOf(call.request, VerifyRequest);
222
281
  if (!isLfsOid(oid)) return yield* fail("INVALID_ARGUMENT", "An oid is a SHA-256, as 64 lowercase hex digits");
223
- const { core, signed } = parts;
282
+ const { rows: registered, signed } = parts;
224
283
  const repo = yield* openFor(call.caller, call.repo, true);
225
- const fence = fenceFor(core, call.caller, repo);
226
284
  for (let tries = 0; tries < 5; tries += 1) {
227
- const read = yield* objectRows(core, repo, fence, [oid]);
285
+ const read = yield* objectRows(registered, call.caller, repo, [oid]);
228
286
  const rows = read.rows.get(oid);
229
- if (rows?.listed !== void 0) return lfsAnswer(200, { message: "Verified" });
287
+ const unseen = (yield* unseenRows(call.caller, repo, [oid], read.rows)).has(oid);
288
+ if (rows?.listed !== void 0 && !unseen) return lfsAnswer(200, { message: "Verified" });
230
289
  const key = rows?.upload === void 0 ? void 0 : objectKey(repo.internalId, oid, rows.upload.generation);
231
- const stored = signed === void 0 || key === void 0 ? void 0 : yield* bucketCall((signal) => signed.head(key, { signal }));
290
+ const stored = signed === void 0 || key === void 0 ? void 0 : yield* bucketCall(Effect.map(signed.head(key), Option.getOrUndefined));
232
291
  if (stored?.sha256 !== oid) return yield* fail("FAILED_PRECONDITION", "The bucket holds no bytes for this object", { hint: "Upload it again" });
233
292
  if (stored.size !== size) return yield* fail("INVALID_ARGUMENT", `This object is ${stored.size} bytes, not ${size}`);
234
- if ((yield* storeCall(() => core.store.commit(repoScope(repo.internalId), {
235
- id: newChangeId(),
236
- expect: read.version,
293
+ if (unseen) return lfsAnswer(200, { message: "Verified" });
294
+ if ((yield* registered.commit(repo.internalId, read.version, {
237
295
  put: [{
238
296
  ...listedKey(oid),
239
297
  value: {
@@ -242,7 +300,7 @@ const verify = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call) {
242
300
  }
243
301
  }],
244
302
  delete: [uploadKey(oid)]
245
- }))).ok) return lfsAnswer(200, { message: "Verified" });
303
+ })).ok) return lfsAnswer(200, { message: "Verified" });
246
304
  }
247
305
  return yield* contended();
248
306
  });
@@ -253,44 +311,72 @@ const verify = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call) {
253
311
  */
254
312
  const receive = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, oid) {
255
313
  if (!isLfsOid(oid)) return yield* fail("INVALID_ARGUMENT", "An oid is a SHA-256, as 64 lowercase hex digits");
256
- const { core, bucket } = parts;
314
+ const { rows: registered, bucket } = parts;
257
315
  const repo = yield* openFor(call.caller, call.repo, true);
258
- const fence = fenceFor(core, call.caller, repo);
259
316
  const started = yield* Clock$1.currentTimeMillis;
260
- const rows = (yield* objectRows(core, repo, fence, [oid])).rows.get(oid);
261
- if (rows?.listed !== void 0) return yield* answered(call.request);
317
+ const read = yield* objectRows(registered, call.caller, repo, [oid]);
318
+ const rows = read.rows.get(oid);
319
+ const unseen = (yield* unseenRows(call.caller, repo, [oid], read.rows)).has(oid);
320
+ if (rows?.listed !== void 0 && !unseen) return yield* answered(call.request);
262
321
  const upload = rows?.upload;
263
322
  if (upload === void 0 || upload.expiresAt < started) return yield* fail("FAILED_PRECONDITION", "No upload link for this object is live", { hint: "Ask the batch API again" });
264
323
  const id = randomText(16);
265
324
  const key = stagingKey(repo.internalId, id);
266
325
  const staged = stagingId(started + uploadGrace, id);
267
- yield* storeCall(() => core.store.add(repoScope(repo.internalId), {
326
+ yield* registered.add(repo.internalId, {
268
327
  put: [{
269
- collection: collections.lfsStaging,
328
+ collection: lfsCollections.staging,
270
329
  id: staged,
271
330
  value: {
272
331
  key,
273
332
  removeAt: started + uploadGrace
274
333
  }
275
334
  }],
276
- jobs: [core.repackJobRow(started + uploadGrace)]
277
- }));
335
+ wake: started + uploadGrace
336
+ });
278
337
  const hashed = hashing(call.request.body, upload.size);
279
- yield* promisePut(bucket, upload.size, (retrying) => bucket.put(key, hashed.stream, {
280
- size: upload.size,
281
- retrying
282
- })).pipe(Effect.mapError((error) => hashed.past() ? pastSize(upload.size) : error));
283
- if (hashed.sha256() !== oid) return yield* fail("INVALID_ARGUMENT", "The bytes' SHA-256 isn't the oid");
284
- return yield* listStaged(parts, repo, fence, {
338
+ const body = Stream.fromReadableStream({
339
+ evaluate: () => hashed.stream,
340
+ onError: (cause) => new Unavailable({
341
+ message: bucketFailed,
342
+ cause
343
+ })
344
+ });
345
+ yield* Effect.uninterruptible(bucketDo(bucket.put(key, body, { size: upload.size }))).pipe(Effect.mapError((error) => hashed.past() ? pastSize(upload.size) : error));
346
+ if (hashed.sha256() !== oid) {
347
+ yield* dropStaged(parts, repo.internalId, key, staged);
348
+ return yield* fail("INVALID_ARGUMENT", "The bytes' SHA-256 isn't the oid");
349
+ }
350
+ return yield* listStaged(registered, call.caller, repo, {
285
351
  oid,
286
352
  size: upload.size,
287
353
  key,
288
354
  staged,
289
- deadline: started + streamMost
355
+ deadline: started + streamMost,
356
+ unseen
290
357
  });
291
358
  });
359
+ /**
360
+ * Deletes refused bytes at once, then their staging row at the version it's read at (#1940). A
361
+ * failure of either leaves the row, whose wake has upkeep delete the bytes at its removeAt, and is
362
+ * no reason to answer it in place of the refusal.
363
+ */
364
+ const dropStaged = /* @__PURE__ */ Effect.fnUntraced(function* (parts, repo, key, staged) {
365
+ const row = {
366
+ collection: lfsCollections.staging,
367
+ id: staged
368
+ };
369
+ yield* bestEffort(Effect.gen(function* () {
370
+ yield* bucketDo(parts.bucket.remove(key));
371
+ const read = yield* parts.rows.read(repo, [row]);
372
+ yield* parts.rows.commit(repo, read.version, { delete: [row] });
373
+ }));
374
+ });
292
375
  const pastSize = (size) => gitError("INVALID_ARGUMENT", `The bytes run past the ${size} the batch named`);
293
- /** An answer to a request whose body isn't needed: the body is let go first. */
376
+ /**
377
+ * An answer to a request whose body isn't needed: the body is let go first, and a cancel that
378
+ * rejects is no reason to fail an upload that's done.
379
+ */
294
380
  const answered = (request) => Effect.promise(async () => {
295
381
  await request.body?.cancel();
296
382
  return lfsAnswer(200, { message: "Already uploaded" });
@@ -312,15 +398,12 @@ const hashing = (body, most) => {
312
398
  };
313
399
  };
314
400
  /** Lists a Worker upload's bytes at their staging key, in the commit that drops its staging row. */
315
- const listStaged = /* @__PURE__ */ Effect.fnUntraced(function* (parts, repo, fence, staged) {
316
- const { core } = parts;
401
+ const listStaged = /* @__PURE__ */ Effect.fnUntraced(function* (registered, caller, repo, staged) {
317
402
  for (let tries = 0; tries < 5; tries += 1) {
318
- const read = yield* objectRows(core, repo, fence, [staged.oid], [stagingRead(staged.staged)]);
319
- if (read.rows.get(staged.oid)?.listed !== void 0) return lfsAnswer(200, { message: "Already uploaded" });
403
+ const read = yield* objectRows(registered, caller, repo, [staged.oid], [stagingRead(staged.staged)]);
404
+ if (read.rows.get(staged.oid)?.listed !== void 0) return lfsAnswer(200, { message: staged.unseen ? "Uploaded" : "Already uploaded" });
320
405
  if ((read.also[0] ?? []).length === 0 || (yield* Clock$1.currentTimeMillis) > staged.deadline) return yield* fail("DEADLINE_EXCEEDED", "The upload ran too long", { hint: "Upload it again" });
321
- if ((yield* storeCall(() => core.store.commit(repoScope(repo.internalId), {
322
- id: newChangeId(),
323
- expect: read.version,
406
+ if ((yield* registered.commit(repo.internalId, read.version, {
324
407
  put: [{
325
408
  ...listedKey(staged.oid),
326
409
  value: {
@@ -329,26 +412,36 @@ const listStaged = /* @__PURE__ */ Effect.fnUntraced(function* (parts, repo, fen
329
412
  }
330
413
  }],
331
414
  delete: [uploadKey(staged.oid), {
332
- collection: collections.lfsStaging,
415
+ collection: lfsCollections.staging,
333
416
  id: staged.staged
334
417
  }]
335
- }))).ok) return lfsAnswer(200, { message: "Uploaded" });
418
+ })).ok) return lfsAnswer(200, { message: "Uploaded" });
336
419
  }
337
420
  return yield* contended();
338
421
  });
339
422
  /**
340
- * A listed object's bytes, the repo's own or a source's, once the caller may read the repo: with no
341
- * bucket, none is listed. `signal` aborted cancels the bucket's stream, opening or open.
423
+ * A listed object's bytes, the repo's own or a source's, once the caller may read the repo and
424
+ * knows of the object, as `unseenOf` says: else it answers as one never uploaded. The host's fetch
425
+ * rules are asked of it then, before the bucket's stream opens, and their refusal or failure is
426
+ * the read's. `signal` aborted cancels the bucket's stream, opening or open.
342
427
  */
343
- const objectOf = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, read) {
344
- const core = yield* CoreParts;
428
+ const objectOf = /* @__PURE__ */ Effect.fnUntraced(function* (parts, read) {
345
429
  const { oid, size, signal } = read;
346
430
  if (!isLfsOid(oid)) return yield* fail("NOT_FOUND", "Object does not exist");
347
431
  const repo = yield* openFor(read.caller, read.repo, false, read.internalId);
348
- if (bucket === void 0) return yield* fail("NOT_FOUND", "Object does not exist");
349
- const listed = (yield* chainListed(core.store, repo.internalId, [oid])).get(oid);
432
+ const chained = yield* chainListed(parts.rows, repo.internalId, [oid]);
433
+ const listed = (yield* seenListed(read.caller, repo, [oid], chained)).get(oid);
350
434
  if (listed === void 0 || size !== void 0 && size !== listed.size) return yield* fail("NOT_FOUND", "Object does not exist");
351
- const stream = yield* promiseStream(bucket, listed.key, signal);
435
+ yield* checkRead(read.repo, {
436
+ caller: read.caller,
437
+ target: {
438
+ kind: "lfs",
439
+ oid,
440
+ size: listed.size
441
+ },
442
+ request: read.request
443
+ });
444
+ const stream = yield* bucketStream(parts.bucket, listed.key);
352
445
  if (stream === void 0) return yield* fail("DATA_LOSS", `LFS object ${oid}'s bytes are missing`);
353
446
  const bytes = signal === void 0 ? stream : stream.pipeThrough(new TransformStream(), { signal });
354
447
  return {
@@ -357,12 +450,18 @@ const objectOf = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, read) {
357
450
  bytes
358
451
  };
359
452
  });
360
- /** `GET objects/<oid>`, a Worker download: a listed object's bytes, the repo's own or a source's. */
453
+ /**
454
+ * `GET objects/<oid>`, a Worker download: a listed object's bytes, the repo's own or a source's,
455
+ * as `objectOf` reads them. Its fetch rules are asked again, though the batch that gave the link
456
+ * asked them: the link outlives that answer, and a signed bucket's link, which the bucket serves,
457
+ * is asked only at the batch.
458
+ */
361
459
  const send = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, oid) {
362
- const object = yield* objectOf(parts.bucket, {
460
+ const object = yield* objectOf(parts, {
363
461
  caller: call.caller,
364
462
  repo: call.repo,
365
- oid
463
+ oid,
464
+ request: call.request
366
465
  });
367
466
  return new Response(object.bytes, {
368
467
  status: 200,
@@ -372,4 +471,4 @@ const send = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, oid) {
372
471
  }
373
472
  });
374
473
  });
375
- export { batch, listedOf, objectOf, receive, send, signingOf, verify };
474
+ export { batch, listedOf, objectOf, receive, send, verify };
@@ -25,9 +25,11 @@ import * as Effect from "effect/Effect";
25
25
  const pushCheckMilliseconds = 6e4;
26
26
  /** A file's modes: a symlink or a submodule is never a pointer. */
27
27
  const fileModes = /* @__PURE__ */ new Set(["100644", "100755"]);
28
- /** The check, over the repo's listed rows in `store`. */
29
- const pointerCheck = (store) => (input) => checkPointers(store, input);
30
- const checkPointers = /* @__PURE__ */ Effect.fnUntraced(function* (store, input) {
28
+ /**
29
+ * The check, over the repo's listed rows in LFS's registration's `rows`: each ref it refuses, with why.
30
+ * It answers only for the refs it's asked of, and may be asked twice.
31
+ */
32
+ const pointerCheck = /* @__PURE__ */ Effect.fnUntraced(function* (rows, input) {
31
33
  const refused = /* @__PURE__ */ new Map();
32
34
  const tips = /* @__PURE__ */ new Map();
33
35
  for (const update of input.updates) {
@@ -38,7 +40,7 @@ const checkPointers = /* @__PURE__ */ Effect.fnUntraced(function* (store, input)
38
40
  }
39
41
  const { lfsPointers } = input.objects;
40
42
  if (lfsPointers.count === 0 || tips.size === 0) return refused;
41
- const unlisted = yield* unlistedOf(store, input.objects.repo, lfsPointers);
43
+ const unlisted = yield* unlistedOf(rows, input.objects.repo, lfsPointers);
42
44
  if (unlisted === void 0) return refused;
43
45
  const deadline = yield* deadlineOf(pushCheckMilliseconds, "walk-limit");
44
46
  const walk = Effect.forEach(tips, ([ref, tip]) => Effect.map(missingAt(input, unlisted, tip, deadline), (missing) => [ref, missing]));
@@ -51,13 +53,13 @@ const checkPointers = /* @__PURE__ */ Effect.fnUntraced(function* (store, input)
51
53
  * every one is listed. It reads a chunk of entries at a time, so it keeps no more than one read's
52
54
  * rows beside the bits.
53
55
  */
54
- const unlistedOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, pointers) {
56
+ const unlistedOf = /* @__PURE__ */ Effect.fnUntraced(function* (rows, repo, pointers) {
55
57
  const unlisted = new Uint8Array(Math.ceil(pointers.count / 8));
56
58
  let any = false;
57
59
  for (let from = 0; from < pointers.count; from += 100) {
58
60
  const to = Math.min(from + 100, pointers.count);
59
61
  const oids = Array.from({ length: to - from }, (_, at) => lfsOidAt(pointers, from + at));
60
- const listed = yield* listedOf(store, repo, [...new Set(oids)]);
62
+ const listed = yield* listedOf(rows, repo, [...new Set(oids)]);
61
63
  for (const [at, oid] of oids.entries()) {
62
64
  if (listed.has(oid)) continue;
63
65
  unlisted[from + at >>> 3] = (unlisted[from + at >>> 3] ?? 0) | 1 << (from + at & 7);
@@ -0,0 +1,5 @@
1
+ import { Lfs, layer } from "./layer.mjs";
2
+ declare namespace public_d_exports {
3
+ export { Lfs, layer };
4
+ }
5
+ export { Lfs, layer, public_d_exports };
@@ -0,0 +1,8 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
2
+ import { Lfs, layer } from "./layer.mjs";
3
+ // src/lfs/public.ts
4
+ var public_exports = /* @__PURE__ */ __exportAll({
5
+ Lfs: () => Lfs,
6
+ layer: () => layer
7
+ });
8
+ export { Lfs, layer, public_exports };
@@ -1,50 +1,44 @@
1
- import { bucketCall } from "../storage/calls.mjs";
2
- import { decodeRow, storeCall } from "../store/errors.mjs";
3
- import { collections, newChangeId, repoScope } from "../store/scopes.mjs";
4
- import { ListedRow } from "./rows.mjs";
1
+ import { bucketDo } from "../storage/calls.mjs";
2
+ import { decodeRow } from "../store/errors.mjs";
3
+ import { ListedRow, lfsCollections } from "./rows.mjs";
5
4
  import * as Effect from "effect/Effect";
6
- /** LFS's purge over `bucket`, for `purgeJob`'s `parts`. */
7
- const lfsPurge = (bucket) => /* @__PURE__ */ Effect.fnUntraced(function* (store, repo) {
8
- const scope = repoScope(repo);
9
- const snapshot = yield* storeCall(() => store.read(scope, [
5
+ /** LFS's registration's purge over its `rows` and `bucket`, which charges each call. */
6
+ const lfsPurge = (rows, bucket) => /* @__PURE__ */ Effect.fnUntraced(function* ({ repo }) {
7
+ const snapshot = yield* rows.read(repo, [
10
8
  {
11
- collection: collections.lfsUploads,
9
+ collection: lfsCollections.uploads,
12
10
  limit: 1
13
11
  },
14
12
  {
15
- collection: collections.lfsStaging,
13
+ collection: lfsCollections.staging,
16
14
  limit: 1
17
15
  },
18
16
  {
19
- collection: collections.lfsEnding,
17
+ collection: lfsCollections.ending,
20
18
  limit: 1
21
19
  },
22
20
  {
23
- collection: collections.lfsObjects,
21
+ collection: lfsCollections.objects,
24
22
  limit: 500
25
23
  },
26
24
  {
27
- collection: collections.lfsLocks,
25
+ collection: lfsCollections.locks,
28
26
  limit: 500
29
27
  }
30
- ]));
28
+ ]);
31
29
  const [uploads = [], staging = [], ending = [], listed = [], locks = []] = snapshot.results;
32
30
  if (uploads.length + staging.length + ending.length > 0) return "waits";
33
- const rows = listed.length > 0 ? listed : locks;
34
- if (rows.length === 0) return "done";
31
+ const found = listed.length > 0 ? listed : locks;
32
+ if (found.length === 0) return "done";
35
33
  const keys = yield* Effect.forEach(listed, (row) => Effect.map(decodeRow(ListedRow, row, `LFS object ${row.id}`), (object) => object.key));
36
- yield* Effect.forEach(keys, (key) => bucketCall((signal) => bucket.delete(key, { signal })), {
34
+ yield* Effect.forEach(keys, (key) => bucketDo(bucket.remove(key)), {
37
35
  concurrency: 8,
38
36
  discard: true
39
37
  });
40
- yield* storeCall(() => store.commit(scope, {
41
- id: newChangeId(),
42
- expect: snapshot.version,
43
- delete: rows.map((row) => ({
44
- collection: row.collection,
45
- id: row.id
46
- }))
47
- }));
38
+ yield* rows.commit(repo, snapshot.version, { delete: found.map((row) => ({
39
+ collection: row.collection,
40
+ id: row.id
41
+ })) });
48
42
  return "did";
49
43
  });
50
44
  export { lfsPurge };