@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,26 +1,21 @@
1
1
  import { gitError } from "../contracts/result.mjs";
2
2
  import { hexOf } from "../protocol/bytes/hex.mjs";
3
3
  import { oidBytes } from "../protocol/packs/idx.mjs";
4
- import { checkTypesHeader, typeAt, typeCode } from "../protocol/packs/types-file.mjs";
5
4
  import { bestEffort } from "../store/errors.mjs";
6
5
  import { randomText } from "../store/random.mjs";
7
6
  import { readerFloors, readerMost } from "./budget.mjs";
8
- import { typesRunRanks } from "./held-types.mjs";
9
- import { isPackId, packFiles } from "./layout.mjs";
10
- import { upkeepMemoryOf, upkeepRuns, upkeepTooLarge } from "./memory-budget.mjs";
11
- import { readExactly } from "./pack-ranges.mjs";
7
+ import { readWhole } from "./calls.mjs";
8
+ import { putOnce } from "./index-build.mjs";
9
+ import { runKey } from "./layout.mjs";
10
+ import { pruneSeenBytes, upkeepMemoryOf, upkeepRuns, upkeepTooLarge } from "./memory-budget.mjs";
12
11
  import { blockBytes, blocksHeld, indexBytes, packReader } from "./pack-reads.mjs";
13
- import { StoredRuns, dedupeTableBytes, dropRuns, mergeHeld, mergeRuns, narrowed, runWriter, writerHeld } from "./runs.mjs";
12
+ import { SeenSaved, seenSet } from "./prune-seen.mjs";
13
+ import { StoredRuns, dedupeTableBytes, dropRuns, mergeHeld, mergeRuns, narrowed, narrowedCalls, runWriter, writerHeld } from "./runs.mjs";
14
14
  import { countedReads } from "./walk.mjs";
15
- import * as Schema from "effect/Schema";
16
15
  import * as Effect from "effect/Effect";
16
+ import * as Schema from "effect/Schema";
17
17
  import * as Data from "effect/Data";
18
18
  // src/storage/prune-walk.ts
19
- /**
20
- * The most history objects, commits and tags, a prune pass's walk holds in its table: about
21
- * 34 MB at `historySlotBytes` (maintenance-1m, invariant 2). A repo past it is refused by name.
22
- */
23
- const pruneCommitsMost = 1e6;
24
19
  /** The tree IDs a level reads at once, in pack order, at `fetchEntryBytes` each: about 9.2 MB. */
25
20
  const pruneTreesAtOnce = 131072;
26
21
  /** The bytes of a reached run, and of a frontier's. */
@@ -46,8 +41,6 @@ const frontierDedupe = {
46
41
  },
47
42
  hash: (bytes, at) => (bytes[at] ?? 0) << 24 | (bytes[at + 1] ?? 0) << 16 | (bytes[at + 2] ?? 0) << 8 | (bytes[at + 3] ?? 0)
48
43
  };
49
- /** The history table's bytes a slot: a 20-byte ID, at most 60% full, so about 34 B an object. */
50
- const historySlotBytes = 20;
51
44
  /** `a`'s runs and `b`'s, of one width, as one: `kind` names where a merge of them narrows. */
52
45
  const joined = (a, b, kind = a.kind) => {
53
46
  const { keys, lengths, rows } = b;
@@ -90,33 +83,31 @@ const pruneWalkSizes = (objects, blocks) => {
90
83
  /** A walk's sizes at its bounds, the most any repo's take. */
91
84
  const boundSizes = /* @__PURE__ */ pruneWalkSizes(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);
92
85
  /**
93
- * What a walk at `sizes` holds besides its history table and its reader's: its trees, its
86
+ * What a walk at `sizes` holds besides its seen set and its reader's: its trees, its
94
87
  * writers and the frontier's dedupe table, and its merge. At the bounds unless given.
95
88
  */
96
89
  const pruneWalkTables = (sizes = boundSizes) => sizes.trees * 70 + 2 * writerHeld(rowBytes, sizes.runBytes) + dedupeTableBytes(sizes.runBytes, rowBytes) + mergeHeld(rowBytes, sizes.runs);
97
- /** The slots a history table for `count` objects is made with, so it's at most 60% full. */
98
- const historySlots = (count) => Math.max(1, Math.ceil(count * 5 / 3));
99
90
  /**
100
- * What a walk of `history` history objects at `sizes` holds at its most, its reader's indexes
101
- * aside: its tables, its history table made once for them, and its reader's blocks and cache at
102
- * their most. At `pruneCommitsMost` and the bounds, the walk's worst try (maintenance-1m,
103
- * invariant 2).
91
+ * What a walk at `sizes` holds at its most besides its seen set, the IDs it starts from and its
92
+ * reader's indexes: its tables, and its reader's blocks and cache at their most. At the bounds
93
+ * unless given.
104
94
  */
105
- const pruneWalkHeld = (history = pruneCommitsMost, sizes = boundSizes) => pruneWalkTables(sizes) + historySlots(history) * historySlotBytes + sizes.blocks + readerMost.cache;
95
+ const pruneWalkHeld = (sizes = boundSizes) => pruneWalkTables(sizes) + sizes.blocks + readerMost.cache;
106
96
  /** A save's count, checked as a row's is, so a bad one is refused at its decode. */
107
97
  const Count = /* @__PURE__ */ Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
108
98
  /** The ID a save's merge stopped at, likewise. */
109
99
  const LastId = /* @__PURE__ */ Schema.String.check(Schema.isPattern(/^[0-9a-f]{40}$/));
110
100
  /**
111
101
  * Where a walk stopped, for its next try to go on from, as `PruneStarted.walk` holds it: in its
112
- * history, the runs it has put, the IDs it has yet to read and its table's count; or after a tree
113
- * level, the runs reached so far and the next level's frontier, and with `at` partway through the
114
- * level after it. `refs` holds the `start` its first
102
+ * history, the runs it has put, the IDs it has yet to read, how many history objects it has seen
103
+ * and its seen set's object; or after a tree level, the runs reached so far and the next level's
104
+ * frontier, and with `at` partway through the level after it. `refs` holds the `start` its first
115
105
  * try was given, which a later try walks from whatever the refs are then.
116
106
  */
117
107
  const WalkSaved = /* @__PURE__ */ Schema.Union([Schema.Struct({
118
108
  phase: Schema.Literal("history"),
119
109
  count: Count,
110
+ seen: SeenSaved,
120
111
  refs: StoredRuns,
121
112
  reached: StoredRuns,
122
113
  frontier: StoredRuns,
@@ -142,67 +133,30 @@ const fits = (calls, needs) => {
142
133
  const made = calls.made();
143
134
  return made.bucket + needs < calls.most.bucket && made.subrequests + needs < calls.most.subrequests;
144
135
  };
145
- /**
146
- * A walk refused: its history past `pruneCommitsMost`, its charge past its allotment, or one step
147
- * past a whole try's calls.
148
- */
136
+ /** A walk refused: its charge past its allotment, or one step past a whole try's calls. */
149
137
  var PruneWalkTooLarge = class extends Data.TaggedError("PruneWalkTooLarge") {};
150
- /** The all-zero ID, which names no object: a free slot's. */
151
- const empty = /* @__PURE__ */ new Uint8Array(20);
152
- /** Whether the 20-byte IDs at `a`'s `at` and `b`'s `bt` are one. */
153
- const sameId = (a, at, b, bt) => {
154
- for (let i = 0; i < 20; i += 1) if (a[at + i] !== b[bt + i]) return false;
155
- return true;
156
- };
157
138
  /**
158
- * The history objects a walk reaches, by ID, in a table of 20-byte slots made once for `count`
159
- * of them, never grown: `add` answers whether `id` is new, or `'full'` past `count`.
139
+ * The bucket keys `saved` names: its runs, and in its history its seen set's object, so a pass
140
+ * that drops what its walks left can keep what its mark still reads.
160
141
  */
161
- const historyTable = (count) => {
162
- const capacity = historySlots(count);
163
- const slots = new Uint8Array(capacity * historySlotBytes);
164
- let size = 0;
165
- const add = (id) => {
166
- const start = ((id[0] ?? 0) * 65536 + (id[1] ?? 0) * 256 + (id[2] ?? 0)) % capacity;
167
- for (let slot = start;; slot = (slot + 1) % capacity) {
168
- const at = slot * historySlotBytes;
169
- if (sameId(slots, at, id, 0)) return false;
170
- if (!sameId(slots, at, empty, 0)) continue;
171
- if (size >= count) return "full";
172
- slots.set(id, at);
173
- size += 1;
174
- return true;
175
- }
176
- };
177
- return {
178
- add,
179
- size: () => size
180
- };
142
+ const walkKeys = (saved) => {
143
+ const keys = (saved.phase === "history" ? [
144
+ saved.refs,
145
+ saved.reached,
146
+ saved.frontier,
147
+ saved.pending,
148
+ saved.known
149
+ ] : [
150
+ saved.refs,
151
+ saved.reached,
152
+ saved.frontier,
153
+ saved.at?.reached,
154
+ saved.at?.frontier,
155
+ saved.at?.trees
156
+ ]).flatMap((each) => each?.keys ?? []);
157
+ return saved.phase === "history" ? [...keys, saved.seen.key] : keys;
181
158
  };
182
159
  /**
183
- * The most history objects a walk from `refs` can reach: the commits and tags the listed packs'
184
- * `.types` count, an object each tag names, each ref's own and each of `rows` object rows. Read
185
- * by range, `typesRunRanks` bytes at a time.
186
- */
187
- const historyCount = /* @__PURE__ */ Effect.fnUntraced(function* (input, refs, rows) {
188
- const commit = typeCode("commit");
189
- const tag = typeCode("tag");
190
- let commits = 0;
191
- let tags = 0;
192
- for (const pack of input.listed.packs) {
193
- const key = isPackId(pack.id) ? packFiles(pack.id).types : pack.id;
194
- const head = yield* readExactly(input.bucket, key, 0, 12);
195
- yield* Effect.mapError(checkTypesHeader(head, pack.objects), (error) => gitError("DATA_LOSS", `Pack ${pack.id}'s types: ${error.message}`));
196
- for (let rank = 0; rank < pack.objects; rank += typesRunRanks) {
197
- const length = Math.min(typesRunRanks, pack.objects - rank);
198
- const types = yield* readExactly(input.bucket, key, typeAt(rank), length);
199
- for (const byte of types) if (byte === commit) commits += 1;
200
- else if (byte === tag) tags += 1;
201
- }
202
- }
203
- return commits + 2 * tags + refs + rows;
204
- });
205
- /**
206
160
  * `walk` in its own scope, a fresh walk's runs dropped once it's refused, so it keeps none. A walk
207
161
  * that goes on from `saved` or `known` keeps them: the pass's mark names them, and the parked
208
162
  * pass's retry goes on from there.
@@ -210,7 +164,8 @@ const historyCount = /* @__PURE__ */ Effect.fnUntraced(function* (input, refs, r
210
164
  const droppedOnRefusal = (walk, input, pack, _start, _missing, options = {}) => Effect.tapError(Effect.scoped(walk), (error) => error instanceof PruneWalkTooLarge && options.saved === void 0 && options.known === void 0 ? bestEffort(dropRuns(input.bucket, pack)) : Effect.void);
211
165
  /**
212
166
  * Every object `start` reaches, as reached runs under `pack`: the history first, commits and tags
213
- * in a table bounded by `pruneCommitsMost`; then the trees a level at a time, each level's
167
+ * each marked in a seen set of a bit an object of the listed packs; then the trees a level at a
168
+ * time, each level's
214
169
  * frontier merged against the runs reached so far, which the merge carries on as the next
215
170
  * level's, so a tree is read once and a blob put once, by the ID its tree names and never read.
216
171
  * `missing` says what an object the repo doesn't hold does to the walk: a tree it passes over is
@@ -222,10 +177,10 @@ const droppedOnRefusal = (walk, input, pack, _start, _missing, options = {}) =>
222
177
  * try given it as `saved` goes on from there, never from `start`. A batch reads as many objects as
223
178
  * their delta chains' gets fit. A step that passes a whole try is refused by name.
224
179
  * `known`'s rows, from an earlier walk, are reached already: a tree they hold isn't read again.
225
- * A refused fresh walk drops its runs; one given `saved` or `known` keeps them. A test sets `commitsMost` and `treesAtOnce` below their bounds.
226
- * Unwired until PR D4.
180
+ * A refused fresh walk drops its runs; one given `saved` or `known` keeps them. A test sets
181
+ * `treesAtOnce` below its bound.
227
182
  */
228
- const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, start, missing, { rows = 0, commitsMost = pruneCommitsMost, treesAtOnce = pruneTreesAtOnce, calls, saved, known } = {}) {
183
+ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, start, missing, { rows = 0, treesAtOnce = pruneTreesAtOnce, calls, saved, known } = {}) {
229
184
  const { allotment, listed } = input;
230
185
  const objects = listed.packs.reduce((sum, each) => sum + each.objects, 0) + rows;
231
186
  const blocks = listed.packs.reduce((sum, each) => sum + Math.ceil(each.bytes / blockBytes), 0);
@@ -238,14 +193,14 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
238
193
  const knownRuns = history?.known ?? known;
239
194
  if (knownRuns !== void 0 && knownRuns.width !== rowBytes) return yield* Effect.fail(gitError("DATA_LOSS", `The known runs are not ${rowBytes}-byte rows`));
240
195
  const named = new Set(start).size;
241
- const count = history?.count ?? (saved === void 0 ? Math.min(yield* historyCount(input, named, rows), commitsMost) : 0);
196
+ const outsideMost = rows + named;
242
197
  const namesBytes = (saved === void 0 ? named : history?.pending.rows ?? 0) * 70;
243
- const historyBytes = historySlots(count) * historySlotBytes + namesBytes;
198
+ const seenBytes = saved?.phase === "trees" ? 0 : pruneSeenBytes(listed.packs, outsideMost);
244
199
  const indexes = listed.packs.reduce((sum, each) => sum + indexBytes(each), 0);
245
- const charge = pruneWalkHeld(count, sizes) + namesBytes + indexes;
200
+ const charge = pruneWalkHeld(sizes) + namesBytes + seenBytes + indexes;
246
201
  if (charge - own > allotment.growable) return yield* new PruneWalkTooLarge({ message: `its walk charges ${charge} bytes with its packs' indexes, past the ${own + allotment.growable} its allotment holds: the repo is past what one prune walk holds` });
247
- yield* Effect.acquireRelease(allotment.grow(historyBytes, upkeepTooLarge), () => Effect.sync(() => allotment.shrink(historyBytes)));
248
- const table = historyTable(count);
202
+ const heldBytes = namesBytes + seenBytes;
203
+ yield* Effect.acquireRelease(allotment.grow(heldBytes, upkeepTooLarge), () => Effect.sync(() => allotment.shrink(heldBytes)));
249
204
  const reader = packReader({
250
205
  ...input,
251
206
  memory
@@ -260,6 +215,25 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
260
215
  allotment.shrink(bytes);
261
216
  });
262
217
  const reads = countedReads(reader, objects + 1e6, charged, void 0, release);
218
+ /** Where each of `oids` is for the seen set: its first listed pack and its rank there. */
219
+ const ranksOf = Effect.fnUntraced(function* (oids) {
220
+ const at = /* @__PURE__ */ new Map();
221
+ let left = [...oids];
222
+ for (const pack of listed.packs) {
223
+ if (left.length === 0) break;
224
+ const { index } = yield* reader.indexed(pack);
225
+ left = left.filter((oid) => {
226
+ const rank = index.rankOf(oid);
227
+ if (rank === void 0) return true;
228
+ at.set(oid, {
229
+ pack: pack.id,
230
+ rank
231
+ });
232
+ return false;
233
+ });
234
+ }
235
+ return at;
236
+ });
263
237
  /** Lets go of what `found` holds of `batch`, once each of it is put. */
264
238
  const letGo = (found, batch) => {
265
239
  for (const object of found.values()) reads.letGo(object);
@@ -388,9 +362,16 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
388
362
  let names = [...new Set(start)];
389
363
  let parents = [];
390
364
  let prior;
365
+ let seenFrom;
391
366
  if (history !== void 0) {
392
- const rebuild = mergeCalls(history.reached) + mergeCalls(history.frontier) + mergeCalls(history.pending);
367
+ const rebuild = narrowedCalls(history.reached.lengths, rowBytes, sizes.runs, input.bucket.multipart).calls + narrowedCalls(history.frontier.lengths, rowBytes, sizes.runs, input.bucket.multipart).calls + mergeCalls(history.pending) + 1;
393
368
  if (!fits(calls, rebuild + 6)) return yield* tooMany("a history resume", rebuild + 6);
369
+ const bytes = yield* readWhole(input.bucket, history.seen.key);
370
+ if (bytes === void 0) return yield* Effect.fail(gitError("DATA_LOSS", `The walk's seen object ${history.seen.key} is gone`));
371
+ seenFrom = {
372
+ saved: history.seen,
373
+ bytes
374
+ };
394
375
  const narrow = (runs, kind) => narrowed(input.bucket, pack, {
395
376
  ...runs,
396
377
  kind: `${kind}.${tried}`
@@ -400,9 +381,12 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
400
381
  frontier: yield* narrow(history.frontier, "frontier-h")
401
382
  };
402
383
  names = [];
403
- yield* eachOf(prior.reached, (id) => void table.add(id));
404
384
  yield* eachOf(history.pending, (id, tag) => (tag === tags.tree ? names : parents).push(hexOf(id)));
405
385
  }
386
+ const seen = yield* seenSet(listed.packs, outsideMost, seenFrom === void 0 ? void 0 : {
387
+ ...seenFrom,
388
+ place: ranksOf
389
+ });
406
390
  const reached = writer("reached-0", sizes.runBytes);
407
391
  const frontier = frontierWriter("frontier-0");
408
392
  while (names.length > 0 || parents.length > 0) {
@@ -412,7 +396,7 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
412
396
  else parents = [];
413
397
  for (let at = 0; at < level.length;) {
414
398
  const left = level.length - at + names.length + parents.length;
415
- const { count: admits, needs } = yield* admitted(level.slice(at, at + 64), 4 + putCalls(left));
399
+ const { count: admits, needs } = yield* admitted(level.slice(at, at + 64), 5 + putCalls(left));
416
400
  if (admits === 0) {
417
401
  if (!moved) return yield* tooMany("a history batch", needs);
418
402
  const reachedRuns = yield* reached.finish;
@@ -421,9 +405,13 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
421
405
  const rest = level.slice(at);
422
406
  for (const oid of fromNames ? [...rest, ...names] : names) yield* put(pending, oidBytes(oid), tags.tree);
423
407
  for (const oid of fromNames ? parents : [...rest, ...parents]) yield* put(pending, oidBytes(oid), tags.reached);
408
+ const key = runKey(pack, `seen.${tried}`, 0);
409
+ const { layout, bytes } = seen.saved(key);
410
+ yield* putOnce(input.bucket, key, bytes);
424
411
  return { more: {
425
412
  phase: "history",
426
- count,
413
+ count: seen.size(),
414
+ seen: layout,
427
415
  refs,
428
416
  reached: after(prior?.reached, reachedRuns),
429
417
  frontier: after(prior?.frontier, frontierRuns),
@@ -435,12 +423,12 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
435
423
  const slice = level.slice(at, at + admits);
436
424
  at += admits;
437
425
  const blobs = fromNames ? yield* reader.wholeBlobs(slice) : /* @__PURE__ */ new Set();
426
+ const ranked = yield* ranksOf(slice);
438
427
  const batch = [];
439
428
  for (const oid of slice) {
440
429
  const id = oidBytes(oid);
441
- const added = table.add(id);
442
- if (added === "full" && count === commitsMost) return yield* new PruneWalkTooLarge({ message: `its walk holds ${count + 1} commits, past the ${commitsMost} a prune pass holds` });
443
- if (added === "full") return yield* Effect.fail(gitError("DATA_LOSS", `The packs' types count ${count} history objects: the walk reaches more`));
430
+ const added = seen.add(oid, ranked.get(oid));
431
+ if (added === "full") return yield* Effect.fail(gitError("DATA_LOSS", `The walk reaches more than ${outsideMost} objects no listed pack holds: past its rows and refs`));
444
432
  if (!added) continue;
445
433
  if (blobs.has(oid)) yield* put(reached, id, tags.reached);
446
434
  else batch.push(oid);
@@ -465,7 +453,7 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
465
453
  runs = after(prior?.reached, yield* reached.finish);
466
454
  next = after(prior?.frontier, yield* frontier.finish);
467
455
  if (knownRuns !== void 0) runs = joined(runs, knownRuns);
468
- commits = table.size();
456
+ commits = seen.size();
469
457
  }
470
458
  let within = saved?.phase === "trees" ? saved.at : void 0;
471
459
  for (let depth = from + 1; next.rows > 0; depth += 1) {
@@ -575,4 +563,4 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
575
563
  refs
576
564
  };
577
565
  }, droppedOnRefusal);
578
- export { PruneWalkTooLarge, WalkSaved, pruneCommitsMost, pruneTreesAtOnce, pruneWalk, pruneWalkHeld, pruneWalkSizes, pruneWalkTables, reachedRunBytes };
566
+ export { PruneWalkTooLarge, WalkSaved, pruneTreesAtOnce, pruneWalk, pruneWalkHeld, pruneWalkSizes, pruneWalkTables, reachedRunBytes, walkKeys };
@@ -14,14 +14,14 @@ import { mergeInputsMost } from "./merge-most.mjs";
14
14
  import { opensWithin, resumeMerge, streamMerge } from "./merge-stream.mjs";
15
15
  import { objectKey } from "./object-rows.mjs";
16
16
  import { bitsBytes, hasBit, keepBits, keptAt, setBit } from "./prune-keep.mjs";
17
- import { WalkSaved, pruneWalk } from "./prune-walk.mjs";
17
+ import { WalkSaved, pruneWalk, walkKeys } from "./prune-walk.mjs";
18
18
  import { defaultRepack, leavingRows, loadAll, mergeWith, namedOf, replacing, wholeRows } from "./repack.mjs";
19
19
  import { decodeHeld, pruneFloor, pruneWait } from "./rows.mjs";
20
20
  import { StoredRuns, dropRuns, mergeHeld, mergeRuns } from "./runs.mjs";
21
21
  import { lost } from "./walk.mjs";
22
- import * as Schema from "effect/Schema";
23
22
  import * as Effect from "effect/Effect";
24
23
  import * as Option from "effect/Option";
24
+ import * as Schema from "effect/Schema";
25
25
  import * as DateTime from "effect/DateTime";
26
26
  // src/storage/prune.ts
27
27
  /** A cruft pack's row, by its pack: when a prune pass found its objects unreached. */
@@ -143,10 +143,32 @@ const cruftOf = (read, pack) => isPackId(pack.id) ? read.cruft.get(pack.id) : vo
143
143
  const pruneWhole = /* @__PURE__ */ WholeRepo.mint();
144
144
  /**
145
145
  * The scratch pack a pass's walk of `kind` puts its runs under: `r` for what the refs reach, `n`
146
- * for what the unreached objects name. One a pass, by its mark's time, so a try that dies leaves
147
- * runs the next try's step drops before it walks again.
146
+ * for what the unreached objects name. One a pass, by its repo and its mark's time, so a try that
147
+ * dies leaves runs the next try's step drops before it walks again, and two repos whose passes
148
+ * are marked at one moment, in the one bucket every repo's packs share, never share one.
149
+ */
150
+ const walkPackOf = (repo, at, kind) => `p_${kind}${repo.slice(2)}${at.toString(36).padStart(15, "0")}`;
151
+ /**
152
+ * The scratch packs of the pass marked at `at` dropped, pages at most each, once its commit is
153
+ * in: `'more'` while keys are left, for the next step to drop.
148
154
  */
149
- const walkPackOf = (at, kind) => `p_${kind}${at.toString(36).padStart(15, "0")}`;
155
+ const passScratch = (input, at) => Effect.map(Effect.all([dropRuns(input.bucket, walkPackOf(input.listed.repo, at, "r")), dropRuns(input.bucket, walkPackOf(input.listed.repo, at, "n"))]), (drops) => drops.includes("more") ? "more" : "done");
156
+ /**
157
+ * The bucket keys `started` names under its pass's scratch packs: each walk's runs, saved or
158
+ * done, and its classes object. Bounded by the mark's record, so a drop of them takes one call.
159
+ */
160
+ const markKeys = (started, repo, at) => {
161
+ const keys = /* @__PURE__ */ new Set();
162
+ const carries = [started?.walks?.r, started?.walks?.n];
163
+ for (const carry of carries) {
164
+ if (carry === void 0) continue;
165
+ for (const key of carry.refs?.keys ?? []) keys.add(key);
166
+ if ("done" in carry) for (const key of carry.done.keys) keys.add(key);
167
+ else for (const key of walkKeys(carry.saved)) keys.add(key);
168
+ }
169
+ if (started?.classes !== void 0) keys.add(classesKey(repo, at, started.classes.n));
170
+ return keys;
171
+ };
150
172
  /**
151
173
  * A pass's reach, as a set: an ID is in it when the bits' rows hold it, or its first pack among
152
174
  * `packs` keeps it at its rank, as D3's `keptAt` says. Its IDs run each pack's set bits, then the
@@ -273,7 +295,7 @@ const sameIds = (a, b) => {
273
295
  return a.length === b.length && b.every((id) => named.has(id));
274
296
  };
275
297
  /** The key of a pass's classes object `n`, under its `r` walk's scratch, which its last step drops. */
276
- const classesKey = (at, n) => runKey(walkPackOf(at, "r"), "classes", n);
298
+ const classesKey = (repo, at, n) => runKey(walkPackOf(repo, at, "r"), "classes", n);
277
299
  const ClassesHeader = /* @__PURE__ */ Schema.fromJsonString(Schema.Struct({ packs: Schema.Array(Schema.Struct({
278
300
  pack: Schema.String.pipe(Schema.refine(isPackId)),
279
301
  count: Schema.Int.check(Schema.isBetween({
@@ -528,7 +550,7 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
528
550
  const carried = read.started?.walks ?? {};
529
551
  const classes = read.started?.classes;
530
552
  const redos = read.started?.redos ?? 0;
531
- const scratch = walkPackOf(at, "r");
553
+ const scratch = walkPackOf(input.listed.repo, at, "r");
532
554
  const saving = (walks) => ({
533
555
  step: {
534
556
  change: {},
@@ -575,7 +597,7 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
575
597
  };
576
598
  if (classes.kind === "cruft" || merge.value.pass !== "commit" || seenHolds(classes)) return went(yield* resumeMerge(input, merge, most, calls, listingOf(classes)), classes.kind);
577
599
  }
578
- const chosen = merge === void 0 && classes !== void 0 && (classes.kind === "cruft" ? sameIds(classes.packs, ids) : seenHolds(classes)) ? yield* readClasses(input, classesKey(at, classes.n), classes.bytes) : void 0;
600
+ const chosen = merge === void 0 && classes !== void 0 && (classes.kind === "cruft" ? sameIds(classes.packs, ids) : seenHolds(classes)) ? yield* readClasses(input, classesKey(input.listed.repo, at, classes.n), classes.bytes) : void 0;
579
601
  if (chosen !== void 0 && classes !== void 0 && !chosen.some((each) => youngIds.has(each.pack))) return went(yield* classMerge(input, read, chosen, most, calls, listingOf(classes)), classes.kind);
580
602
  const reachedRuns = carry.done;
581
603
  const bits = yield* keepBits(input, scratch, reachedRuns, rowOids, lost);
@@ -627,7 +649,7 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
627
649
  const copies = (yield* classBits(input, fresh, (indexed, rank) => !reachedAt(indexed, rank) && !apart(indexed.index.oidAt(rank)))).filter((each) => each.set > 0);
628
650
  if (copies.length === 0) return { start };
629
651
  const n = (classes?.n ?? -1) + 1;
630
- const bytes = yield* putClasses(input, classesKey(at, n), copies);
652
+ const bytes = yield* putClasses(input, classesKey(input.listed.repo, at, n), copies);
631
653
  return { classes: {
632
654
  kind: "cruft",
633
655
  n,
@@ -644,7 +666,7 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
644
666
  },
645
667
  mark: { classes: first.classes }
646
668
  };
647
- const named = walkPackOf(at, "n");
669
+ const named = walkPackOf(input.listed.repo, at, "n");
648
670
  const neededCarry = carried.n;
649
671
  if (packs.old.length > 0 && (neededCarry === void 0 || "saved" in neededCarry)) {
650
672
  const start = neededCarry === void 0 ? first.start : [];
@@ -676,7 +698,7 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
676
698
  const inRows = new Set(rowOids);
677
699
  const keep = (oid) => reached.has(oid) || !apart(oid) && (inFresh(oid) || inRows.has(oid) || needed.has(oid));
678
700
  if (merge !== void 0 && classes !== void 0) {
679
- const before = yield* readClasses(input, classesKey(at, classes.n), classes.bytes);
701
+ const before = yield* readClasses(input, classesKey(input.listed.repo, at, classes.n), classes.bytes);
680
702
  const byPack = new Map((before ?? []).map((each) => [each.pack, each.bits]));
681
703
  const inputs = new Set(merge.value.inputs);
682
704
  if (!merging.some(({ pack, index }) => {
@@ -719,13 +741,18 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
719
741
  n,
720
742
  packs: ids,
721
743
  reads: digest,
722
- bytes: yield* putClasses(input, classesKey(at, n), rewrites)
744
+ bytes: yield* putClasses(input, classesKey(input.listed.repo, at, n), rewrites)
723
745
  } }
724
746
  };
725
747
  }
726
748
  const held = carry.refs === void 0 || (yield* refsHeld(input, scratch, carry.refs, refs));
727
- yield* dropRuns(input.bucket, scratch);
728
- yield* dropRuns(input.bucket, named);
749
+ const marked = markKeys(read.started, input.listed.repo, at);
750
+ const scratchDropped = yield* dropRuns(input.bucket, scratch, marked);
751
+ const namedDropped = yield* dropRuns(input.bucket, named, marked);
752
+ if (scratchDropped === "more" || namedDropped === "more") return { step: {
753
+ change: {},
754
+ more: true
755
+ } };
729
756
  const step = {
730
757
  change: { put: [{
731
758
  ...prunePassKey,
@@ -814,6 +841,14 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
814
841
  next: after
815
842
  };
816
843
  }
844
+ const ended = read.started?.at;
845
+ if (ended !== void 0 && last !== void 0 && ended <= last && (yield* passScratch(input, ended)) === "more") return {
846
+ step: {
847
+ change: {},
848
+ more: true
849
+ },
850
+ next
851
+ };
817
852
  if (markHeld && read.cruft.size === 0 && merge === void 0) return {
818
853
  step: {
819
854
  change: { put: [{
@@ -2,10 +2,10 @@ import { millis } from "../contracts/promises.mjs";
2
2
  import { gitError } from "../contracts/result.mjs";
3
3
  import { decodeRow, storeCall } from "../store/errors.mjs";
4
4
  import { collections, newChangeId, repoScope } from "../store/scopes.mjs";
5
- import { bucketCall } from "./calls.mjs";
6
- import { limits } from "@ref0/infra";
7
- import * as Schema from "effect/Schema";
5
+ import { bucketCall, bucketDo } from "./calls.mjs";
8
6
  import * as Effect from "effect/Effect";
7
+ import * as Schema from "effect/Schema";
8
+ import { limits } from "@ref0/infra";
9
9
  // src/storage/push-uploads.ts
10
10
  /**
11
11
  * A large push's pack, uploaded to the bucket in parts before the push: its row in the repo's
@@ -65,6 +65,8 @@ const PushUploadRow = /* @__PURE__ */ Schema.Struct({
65
65
  atomic: Schema.Boolean,
66
66
  /** Whether its begin asked for `ref0-push-reasons`, which complete's report tells. */
67
67
  reasons: Schema.Boolean,
68
+ /** Its begin's `shallow` lines, which complete's push reads: none for a whole clone. */
69
+ shallow: Schema.Array(Schema.String),
68
70
  /** When its last part link expires. */
69
71
  expiresAt: Schema.Int,
70
72
  /** When upkeep aborts its parts, and deletes its key and the row. */
@@ -100,16 +102,13 @@ const partBytes = (bytes, part, size) => Math.min(size, bytes - (part - 1) * siz
100
102
  * `limits.valueBytes`, so a page of 8 stays within half of one answer's `limits.answerBytes`.
101
103
  */
102
104
  const upkeepPage = /* @__PURE__ */ Math.floor(limits.answerBytes / limits.valueBytes / 2);
103
- /** The bucket, when it signs parts and joins them: only then does a server take push uploads. */
104
- const signedUploadOf = (bucket) => joinsParts(bucket) ? bucket : void 0;
105
- /** A bucket made to sign parts, as `r2()` given S3 credentials makes one, has all five. */
106
- const joinsParts = (bucket) => "beginUpload" in bucket && "uploadUrl" in bucket && "listParts" in bucket && "completeUpload" in bucket && "abortUpload" in bucket;
107
105
  /**
108
- * Ends the push uploads due at `at` in `repo`: each one's parts aborted, its key deleted, then its
109
- * row, at the version the rows were read. A crash between leaves the row, and the next step ends
110
- * it again: aborting an ended upload, and deleting a key that's gone, do nothing.
106
+ * Ends the push uploads due at `at` in `repo`: each one's parts aborted, where the host has
107
+ * `uploads`, its key deleted from `bucket`, which charges each call, then its row, at the version
108
+ * the rows were read. A crash between leaves the row, and the next step ends it again: aborting an
109
+ * ended upload, and deleting a key that's gone, do nothing.
111
110
  */
112
- const pushUploadUpkeep = (bucket) => Effect.fnUntraced(function* (store, repo, at) {
111
+ const pushUploadUpkeep = (bucket, uploads) => Effect.fnUntraced(function* (store, repo, at) {
113
112
  const scope = repoScope(repo);
114
113
  const due = [];
115
114
  let next;
@@ -141,7 +140,7 @@ const pushUploadUpkeep = (bucket) => Effect.fnUntraced(function* (store, repo, a
141
140
  more: false,
142
141
  due: next
143
142
  };
144
- yield* Effect.forEach(due, ({ row }) => endUpload(bucket, row), {
143
+ yield* Effect.forEach(due, ({ row }) => endUpload(bucket, uploads, row), {
145
144
  concurrency: 8,
146
145
  discard: true
147
146
  });
@@ -152,10 +151,9 @@ const pushUploadUpkeep = (bucket) => Effect.fnUntraced(function* (store, repo, a
152
151
  }));
153
152
  return { more: true };
154
153
  });
155
- /** An upload's parts aborted, where the bucket joins them, then its key deleted. */
156
- const endUpload = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, row) {
157
- const signed = signedUploadOf(bucket);
158
- if (signed !== void 0) yield* bucketCall((signal) => signed.abortUpload(row.key, row.uploadId, { signal }));
159
- yield* bucketCall((signal) => bucket.delete(row.key, { signal }));
154
+ /** An upload's parts aborted, where the host has `uploads`, then its key deleted. */
155
+ const endUpload = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, uploads, row) {
156
+ if (uploads !== void 0) yield* bucketCall(uploads.abortUpload(row.key, row.uploadId));
157
+ yield* bucketDo(bucket.remove(row.key));
160
158
  });
161
- export { PushUploadRow, completeMost, endUpload, partBytes, partLinkLife, partSizeOf, partsOf, pushPackTooLarge, pushUploadGrace, pushUploadKey, pushUploadLife, pushUploadMost, pushUploadPart, pushUploadRead, pushUploadRowKey, pushUploadUpkeep, signedUploadOf };
159
+ export { PushUploadRow, completeMost, endUpload, partBytes, partLinkLife, partSizeOf, partsOf, pushPackTooLarge, pushUploadGrace, pushUploadKey, pushUploadLife, pushUploadMost, pushUploadPart, pushUploadRead, pushUploadRowKey, pushUploadUpkeep };
@@ -6,5 +6,5 @@ import "../contracts/services.mjs";
6
6
  import "../contracts/store.mjs";
7
7
  import "./layout.mjs";
8
8
  import "./pack-reads.mjs";
9
- import { Key, Moment, Row } from "@ref0/infra";
10
- import "effect/Effect";
9
+ import "effect/Effect";
10
+ import { JobInput, Key, Moment, Row } from "@ref0/infra";
@@ -27,6 +27,10 @@ const sharePacks = (bucket, packs, into) => Effect.forEach(packs, (pack) => isPa
27
27
  * again; then its marker, named by the repo's internal ID. The pack's bytes go only after both.
28
28
  * The add leaves a failed `git.repack` row failed, so clean-up past an outage longer than that
29
29
  * row's tries, `repackRetry`'s week, waits for a host's retry (#1662).
30
+ *
31
+ * The row is read again after the marker's put: clean-up may have taken it between the two, and
32
+ * listed the pack's markers before this one was there (#1582). Then the marker goes again, and
33
+ * the write fails before any byte, so nothing is left that clean-up doesn't see.
30
34
  */
31
35
  const openQuarantine = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
32
36
  const { store, bucket, repo, at, prune } = input;
@@ -43,6 +47,14 @@ const openQuarantine = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
43
47
  }
44
48
  });
45
49
  yield* putMarker(bucket, pack, repo);
50
+ if ((yield* quarantineState({
51
+ store,
52
+ repo,
53
+ pack
54
+ })) !== "open") {
55
+ yield* bucketDo(bucket.remove(markerKey(pack, repo)));
56
+ return yield* fail("UNAVAILABLE", "Clean-up ended the push's pack before its marker was put", { hint: "Push again" });
57
+ }
46
58
  return {
47
59
  pack,
48
60
  quarantine: quarantineKey(pack),
@@ -69,18 +81,11 @@ const stillOpen = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
69
81
  return yield* fail("UNAVAILABLE", "The push's pack outlived its quarantine, so it may be gone", { hint: "Push again" });
70
82
  });
71
83
  /**
72
- * After a receive or a merge failed, its kept indexes let go, then its marker, files and
73
- * `quarantine` row deleted before its refusal is answered, marker first, as clean-up orders them,
74
- * so a refused write keeps nothing. A row clean-up abandoned meanwhile is clean-up's to delete. A
75
- * delete that fails, or other commits that keep moving the repo, leave the row for clean-up to end
76
- * at its `removeAt`. Its own failure is dropped: the write's is the one its caller sees.
84
+ * Commits `body` over a pack's `quarantine` row while it's still `open`, each try at its own
85
+ * read's version, `dropTries` tries at most as other commits move the repo.
77
86
  */
78
- const dropRefused = (input) => bestEffort(Effect.gen(function* () {
79
- const { store, bucket, repo, pack } = input;
80
- input.indexes.forget(pack);
87
+ const whileOpen = /* @__PURE__ */ Effect.fnUntraced(function* ({ store, repo, pack }, body) {
81
88
  const scope = repoScope(repo);
82
- const keys = [markerKey(pack, repo), ...packFileKeys(pack)];
83
- yield* Effect.forEach(keys, (key) => bucketDo(bucket.remove(key)), { discard: true });
84
89
  for (let tried = 0; tried < 3; tried++) {
85
90
  const snapshot = yield* store.read({
86
91
  scope,
@@ -90,12 +95,46 @@ const dropRefused = (input) => bestEffort(Effect.gen(function* () {
90
95
  const change = {
91
96
  id: newChangeId(),
92
97
  expect: snapshot.version,
93
- delete: [quarantineKey(pack)]
98
+ ...body
94
99
  };
95
100
  if ((yield* store.commit({
96
101
  scope,
97
102
  change
98
103
  })).ok) return;
99
104
  }
105
+ });
106
+ /**
107
+ * After a receive or a merge failed, its kept indexes let go, then its marker, files and
108
+ * `quarantine` row deleted before its refusal is answered, marker first, as clean-up orders them,
109
+ * so a refused write keeps nothing. A row clean-up abandoned meanwhile is clean-up's to delete. A
110
+ * delete that fails, or other commits that keep moving the repo, leave the row for clean-up to end
111
+ * at its `removeAt`. Its own failure is dropped: the write's is the one its caller sees.
112
+ */
113
+ const dropRefused = (input) => bestEffort(Effect.gen(function* () {
114
+ const { store, bucket, repo, pack } = input;
115
+ input.indexes.forget(pack);
116
+ const keys = [markerKey(pack, repo), ...packFileKeys(pack)];
117
+ yield* Effect.forEach(keys, (key) => bucketDo(bucket.remove(key)), { discard: true });
118
+ yield* whileOpen({
119
+ store,
120
+ repo,
121
+ pack
122
+ }, { delete: [quarantineKey(pack)] });
123
+ }));
124
+ /**
125
+ * A push that ends with no commit that listed its pack commits its own `quarantine` row
126
+ * abandoned, due at `at`, with `git.repack` due then too, so the next clean-up deletes its marker,
127
+ * bytes and row, not one at its `removeAt`. Each try commits at its own read's version, over a row
128
+ * still `open`: a listing that landed, one whose answer was lost too, has taken the row, and one
129
+ * still on its way is refused by the version this moves. It deletes nothing itself, as a pack's
130
+ * bytes may be listed. Other commits that keep moving the repo, past `dropTries`, or a failure,
131
+ * leave the row for clean-up at its `removeAt`; its own failure is dropped.
132
+ */
133
+ const abandonOwn = ({ at, repackJobRow: repackAt, ...input }) => bestEffort(whileOpen(input, {
134
+ put: [quarantineRow(input.pack, {
135
+ removeAt: at,
136
+ state: "abandoned"
137
+ })],
138
+ jobs: [repackAt(at)]
100
139
  }));
101
- export { deletePackFiles, dropRefused, openQuarantine, putMarker, quarantineOf, quarantineState, sharePacks, stillOpen };
140
+ export { abandonOwn, deletePackFiles, dropRefused, openQuarantine, putMarker, quarantineOf, quarantineState, sharePacks, stillOpen };