@ref0/git 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (476) hide show
  1. package/dist/access/namespace.d.mts +2 -0
  2. package/dist/access/private-refs.d.mts +6 -29
  3. package/dist/access/private-refs.mjs +26 -13
  4. package/dist/access/public.d.mts +6 -0
  5. package/dist/access/public.mjs +9 -0
  6. package/dist/auth/access-jwt.d.mts +10 -6
  7. package/dist/auth/access-jwt.mjs +59 -40
  8. package/dist/auth/auth-namespace.d.mts +6 -0
  9. package/dist/auth/auth-namespace.mjs +12 -0
  10. package/dist/auth/auth.d.mts +3 -6
  11. package/dist/auth/auth.mjs +2 -9
  12. package/dist/auth/authorize.mjs +35 -29
  13. package/dist/auth/bridge.mjs +8 -8
  14. package/dist/auth/fences.d.mts +1 -2
  15. package/dist/auth/fences.mjs +1 -1
  16. package/dist/auth/grants.d.mts +0 -1
  17. package/dist/auth/grants.mjs +2 -2
  18. package/dist/auth/host-function.d.mts +1 -7
  19. package/dist/auth/host-function.mjs +51 -42
  20. package/dist/auth/identify.d.mts +0 -1
  21. package/dist/auth/identify.mjs +3 -2
  22. package/dist/auth/namespaces.d.mts +2 -2
  23. package/dist/auth/policy.d.mts +7 -4
  24. package/dist/auth/policy.mjs +13 -10
  25. package/dist/auth/token-rows.mjs +3 -6
  26. package/dist/auth/tokens-layer.d.mts +40 -0
  27. package/dist/auth/tokens-layer.mjs +29 -0
  28. package/dist/auth/tokens-namespace.d.mts +2 -0
  29. package/dist/auth/tokens-public.d.mts +6 -0
  30. package/dist/auth/tokens-public.mjs +31 -0
  31. package/dist/auth/tokens.d.mts +19 -7
  32. package/dist/auth/tokens.mjs +12 -6
  33. package/dist/auth.d.mts +2 -2
  34. package/dist/auth.mjs +2 -2
  35. package/dist/client/client.d.mts +22 -15
  36. package/dist/client/client.mjs +31 -27
  37. package/dist/client/git-http.mjs +23 -6
  38. package/dist/client/local.mjs +5 -4
  39. package/dist/client/namespace.d.mts +2 -0
  40. package/dist/client/push-upload.d.mts +1 -0
  41. package/dist/client/push-upload.mjs +169 -2
  42. package/dist/client/remote-helper.mjs +5 -12
  43. package/dist/client/remote.mjs +63 -22
  44. package/dist/client/run-remote-helper.d.mts +1 -1
  45. package/dist/client/run-remote-helper.mjs +6 -6
  46. package/dist/client/slice-push.d.mts +1 -1
  47. package/dist/client/transport.mjs +26 -19
  48. package/dist/contracts/access.d.mts +18 -10
  49. package/dist/contracts/access.mjs +17 -0
  50. package/dist/contracts/actors.d.mts +73 -28
  51. package/dist/contracts/actors.mjs +45 -2
  52. package/dist/contracts/authorize.d.mts +26 -17
  53. package/dist/contracts/blobs.d.mts +1 -1
  54. package/dist/contracts/blobs.mjs +1 -1
  55. package/dist/contracts/callers.mjs +40 -0
  56. package/dist/contracts/calls-spent.d.mts +6 -4
  57. package/dist/contracts/calls-spent.mjs +10 -8
  58. package/dist/contracts/client.d.mts +16 -9
  59. package/dist/contracts/commits.d.mts +2 -2
  60. package/dist/contracts/commits.mjs +1 -1
  61. package/dist/contracts/engine.d.mts +1 -1
  62. package/dist/contracts/events.d.mts +45 -32
  63. package/dist/contracts/events.mjs +21 -10
  64. package/dist/contracts/files.d.mts +44 -44
  65. package/dist/contracts/files.mjs +1 -1
  66. package/dist/contracts/forks.d.mts +34 -58
  67. package/dist/contracts/forks.mjs +1 -1
  68. package/dist/contracts/git-events.d.mts +50 -0
  69. package/dist/contracts/git-events.mjs +23 -0
  70. package/dist/contracts/git-hooks.d.mts +254 -0
  71. package/dist/contracts/git-hooks.mjs +12 -0
  72. package/dist/contracts/git.d.mts +93 -42
  73. package/dist/contracts/git.mjs +6 -5
  74. package/dist/contracts/grants.d.mts +46 -27
  75. package/dist/contracts/ids.d.mts +16 -0
  76. package/dist/contracts/ids.mjs +19 -4
  77. package/dist/contracts/lfs.d.mts +19 -4
  78. package/dist/contracts/merges.d.mts +7 -7
  79. package/dist/contracts/namespaces.d.mts +2 -2
  80. package/dist/contracts/objects.d.mts +21 -5
  81. package/dist/contracts/opaque.mjs +27 -0
  82. package/dist/contracts/operations.d.mts +301 -101
  83. package/dist/contracts/operations.mjs +209 -0
  84. package/dist/contracts/promises.d.mts +2 -0
  85. package/dist/contracts/push-uploads.d.mts +4 -1
  86. package/dist/contracts/push-uploads.mjs +9 -4
  87. package/dist/contracts/queue.d.mts +220 -49
  88. package/dist/contracts/queue.mjs +68 -6
  89. package/dist/contracts/refs.d.mts +30 -8
  90. package/dist/contracts/refs.mjs +1 -1
  91. package/dist/contracts/remote.d.mts +53 -23
  92. package/dist/contracts/remote.mjs +22 -0
  93. package/dist/contracts/repo-records.d.mts +2 -2
  94. package/dist/contracts/repos.d.mts +100 -82
  95. package/dist/contracts/repos.mjs +47 -8
  96. package/dist/contracts/result.d.mts +73 -41
  97. package/dist/contracts/result.mjs +74 -17
  98. package/dist/contracts/rules.d.mts +734 -68
  99. package/dist/contracts/rules.mjs +84 -1
  100. package/dist/contracts/server.d.mts +20 -206
  101. package/dist/contracts/services.d.mts +1 -10
  102. package/dist/contracts/services.mjs +1 -5
  103. package/dist/contracts/signin.d.mts +140 -43
  104. package/dist/contracts/signin.mjs +36 -3
  105. package/dist/contracts/store.d.mts +1 -1
  106. package/dist/contracts/sync.d.mts +109 -90
  107. package/dist/contracts/sync.mjs +34 -7
  108. package/dist/contracts/tags.d.mts +1 -1
  109. package/dist/contracts/tags.mjs +1 -1
  110. package/dist/contracts/tokens.d.mts +247 -60
  111. package/dist/contracts/tokens.mjs +93 -21
  112. package/dist/contracts/topics.d.mts +59 -20
  113. package/dist/contracts/topics.mjs +14 -5
  114. package/dist/contracts/trees.d.mts +2 -2
  115. package/dist/contracts/trees.mjs +1 -1
  116. package/dist/contracts/work.d.mts +2 -2
  117. package/dist/contracts/work.mjs +2 -2
  118. package/dist/core/access.d.mts +10 -12
  119. package/dist/core/access.mjs +45 -11
  120. package/dist/core/clock.mjs +1 -1
  121. package/dist/core/events/deliver.d.mts +3 -2
  122. package/dist/core/events/deliver.mjs +188 -92
  123. package/dist/core/forks.mjs +78 -34
  124. package/dist/core/hooks/groups.d.mts +26 -0
  125. package/dist/core/hooks/groups.mjs +73 -0
  126. package/dist/core/hooks/namespace.d.mts +2 -0
  127. package/dist/core/hooks/order.d.mts +2 -2
  128. package/dist/core/hooks/order.mjs +6 -6
  129. package/dist/core/hooks/public.d.mts +7 -0
  130. package/dist/core/hooks/public.mjs +5 -0
  131. package/dist/core/imports.mjs +94 -10
  132. package/dist/core/index-job.mjs +11 -8
  133. package/dist/core/loose-tally.mjs +46 -0
  134. package/dist/core/merge-parts.d.mts +1 -1
  135. package/dist/core/merge-parts.mjs +1 -1
  136. package/dist/core/mirror-rows.mjs +18 -0
  137. package/dist/core/names.mjs +1 -1
  138. package/dist/core/namespaces.d.mts +2 -1
  139. package/dist/core/objects/commit-writes.mjs +5 -5
  140. package/dist/core/objects/merges.mjs +1 -1
  141. package/dist/core/objects/objects-layer.mjs +1 -1
  142. package/dist/core/objects/reading.mjs +52 -7
  143. package/dist/core/objects/tree-edits.mjs +13 -28
  144. package/dist/core/objects/trees.mjs +4 -4
  145. package/dist/core/objects/writing.mjs +4 -3
  146. package/dist/core/own-writes.mjs +1 -1
  147. package/dist/core/parts.d.mts +22 -3
  148. package/dist/core/parts.mjs +5 -3
  149. package/dist/core/promise.mjs +23 -17
  150. package/dist/core/purge.d.mts +2 -2
  151. package/dist/core/purge.mjs +89 -34
  152. package/dist/core/push.mjs +67 -79
  153. package/dist/core/receipts.d.mts +2 -2
  154. package/dist/core/receipts.mjs +28 -4
  155. package/dist/core/ref-index-job.mjs +4 -4
  156. package/dist/core/ref-view.mjs +16 -8
  157. package/dist/core/refs.mjs +41 -10
  158. package/dist/core/registered-records.mjs +30 -0
  159. package/dist/core/{claim-rows.mjs → registered-rows.mjs} +6 -6
  160. package/dist/core/repack.d.mts +2 -2
  161. package/dist/core/repack.mjs +30 -23
  162. package/dist/core/repo-info.mjs +62 -26
  163. package/dist/core/repos.mjs +18 -11
  164. package/dist/core/rules/changes.mjs +2 -2
  165. package/dist/core/rules/check.mjs +10 -10
  166. package/dist/core/rules/commit-changes.mjs +1 -1
  167. package/dist/core/rules/context.d.mts +7 -6
  168. package/dist/core/rules/context.mjs +18 -16
  169. package/dist/core/rules/fetch.mjs +78 -31
  170. package/dist/core/saved-caller-views.d.mts +72 -0
  171. package/dist/core/saved-caller-views.mjs +123 -0
  172. package/dist/core/saved-callers-public.d.mts +5 -0
  173. package/dist/core/saved-callers-public.mjs +10 -0
  174. package/dist/core/saved-callers.mjs +95 -0
  175. package/dist/core/seam.d.mts +12 -1
  176. package/dist/core/seam.mjs +4 -2
  177. package/dist/core/tokens.mjs +7 -2
  178. package/dist/core/view.d.mts +1 -1
  179. package/dist/core/view.mjs +1 -1
  180. package/dist/core/work.mjs +6 -5
  181. package/dist/effect.d.mts +2 -4
  182. package/dist/effect.mjs +2 -4
  183. package/dist/engine/commits.mjs +19 -47
  184. package/dist/engine/content.d.mts +2 -2
  185. package/dist/engine/content.mjs +1 -1
  186. package/dist/engine/diff.mjs +2 -2
  187. package/dist/engine/failures.d.mts +1 -2
  188. package/dist/engine/failures.mjs +1 -3
  189. package/dist/engine/merge-base-walk.mjs +57 -142
  190. package/dist/engine/merge-bases.mjs +5 -5
  191. package/dist/engine/merge-renames.mjs +1 -1
  192. package/dist/engine/merge.mjs +16 -14
  193. package/dist/engine/reads.d.mts +2 -2
  194. package/dist/engine/reads.mjs +1 -1
  195. package/dist/engine/xdiff.d.mts +1 -1
  196. package/dist/engine/xdiff.mjs +2 -2
  197. package/dist/event-streams/event-streams.d.mts +6 -2
  198. package/dist/event-streams/event-streams.mjs +6 -2
  199. package/dist/event-streams/stream.mjs +5 -2
  200. package/dist/extend.d.mts +2 -3
  201. package/dist/extend.mjs +2 -2
  202. package/dist/http/answers.mjs +4 -3
  203. package/dist/http/core-parts.mjs +3 -4
  204. package/dist/http/handler.mjs +12 -32
  205. package/dist/http/parts.d.mts +1 -1
  206. package/dist/http/push-uploads.mjs +7 -5
  207. package/dist/http/receive-pack.mjs +3 -3
  208. package/dist/http/upload-pack.mjs +6 -5
  209. package/dist/index.d.mts +44 -24
  210. package/dist/index.mjs +17 -8
  211. package/dist/lfs/base.d.mts +8 -5
  212. package/dist/lfs/base.mjs +2 -1
  213. package/dist/lfs/calls.mjs +3 -2
  214. package/dist/lfs/layer.d.mts +9 -7
  215. package/dist/lfs/layer.mjs +37 -22
  216. package/dist/lfs/locks.mjs +3 -3
  217. package/dist/lfs/objects.d.mts +3 -2
  218. package/dist/lfs/objects.mjs +235 -71
  219. package/dist/lfs/pointers.mjs +70 -19
  220. package/dist/lfs/purge.mjs +7 -3
  221. package/dist/lfs/rows.mjs +25 -8
  222. package/dist/lfs/service.d.mts +6 -3
  223. package/dist/lfs/service.mjs +8 -2
  224. package/dist/lfs/upkeep.mjs +53 -31
  225. package/dist/lfs/upload-most.mjs +41 -0
  226. package/dist/lfs/uploaded.mjs +59 -0
  227. package/dist/lfs/wire.mjs +1 -1
  228. package/dist/protocol/bytes/buffers.d.mts +1 -1
  229. package/dist/protocol/bytes/buffers.mjs +1 -1
  230. package/dist/protocol/bytes/deflate.d.mts +1 -1
  231. package/dist/protocol/bytes/deflate.mjs +1 -1
  232. package/dist/protocol/bytes/hmac-sha256.mjs +3 -6
  233. package/dist/protocol/bytes/inflate.d.mts +1 -1
  234. package/dist/protocol/bytes/inflate.mjs +1 -1
  235. package/dist/protocol/bytes/sha1.d.mts +1 -1
  236. package/dist/protocol/bytes/sha1.mjs +2 -2
  237. package/dist/protocol/bytes/sha256-hasher.mjs +51 -0
  238. package/dist/protocol/bytes/text.mjs +6 -1
  239. package/dist/protocol/diff/read.d.mts +1 -1
  240. package/dist/protocol/diff/read.mjs +1 -1
  241. package/dist/protocol/diff/tree-diff.d.mts +1 -1
  242. package/dist/protocol/diff/tree-diff.mjs +11 -11
  243. package/dist/protocol/objects/fsck.mjs +6 -3
  244. package/dist/protocol/objects/lfs-pointer.mjs +6 -1
  245. package/dist/protocol/objects/tag.mjs +1 -1
  246. package/dist/protocol/objects/tree.mjs +1 -1
  247. package/dist/protocol/packs/graph.mjs +1 -1
  248. package/dist/protocol/packs/idx.d.mts +1 -1
  249. package/dist/protocol/packs/idx.mjs +1 -1
  250. package/dist/protocol/packs/parts.mjs +1 -1
  251. package/dist/protocol/packs/reader.d.mts +1 -1
  252. package/dist/protocol/packs/reader.mjs +2 -2
  253. package/dist/protocol/packs/write-error.d.mts +1 -1
  254. package/dist/protocol/packs/write-error.mjs +1 -1
  255. package/dist/protocol/packs/writer.mjs +4 -4
  256. package/dist/protocol/wire/advertisement.d.mts +1 -1
  257. package/dist/protocol/wire/advertisement.mjs +1 -1
  258. package/dist/protocol/wire/fetch.d.mts +1 -1
  259. package/dist/protocol/wire/fetch.mjs +1 -1
  260. package/dist/protocol/wire/lines.d.mts +1 -1
  261. package/dist/protocol/wire/lines.mjs +2 -2
  262. package/dist/protocol/wire/push-uploads.mjs +4 -2
  263. package/dist/protocol/wire/receive-pack.d.mts +1 -1
  264. package/dist/protocol/wire/receive-pack.mjs +1 -1
  265. package/dist/protocol/wire/report-status.d.mts +1 -1
  266. package/dist/protocol/wire/report-status.mjs +1 -1
  267. package/dist/protocol/wire/v2.d.mts +2 -2
  268. package/dist/protocol/wire/v2.mjs +2 -2
  269. package/dist/queue/advance.mjs +190 -68
  270. package/dist/queue/callers.mjs +56 -69
  271. package/dist/queue/calls.mjs +10 -11
  272. package/dist/queue/commit.mjs +28 -22
  273. package/dist/queue/host.d.mts +10 -11
  274. package/dist/queue/host.mjs +15 -7
  275. package/dist/queue/lanes.mjs +9 -18
  276. package/dist/queue/layer.d.mts +3 -3
  277. package/dist/queue/layer.mjs +11 -10
  278. package/dist/queue/limits.mjs +17 -5
  279. package/dist/queue/rows.mjs +13 -10
  280. package/dist/queue/schedule.mjs +7 -6
  281. package/dist/queue/search.mjs +11 -17
  282. package/dist/queue/state.mjs +7 -2
  283. package/dist/queue/trim.mjs +10 -5
  284. package/dist/rest/api.d.mts +1 -1
  285. package/dist/rest/blobs.d.mts +20 -20
  286. package/dist/rest/caller.d.mts +22 -20
  287. package/dist/rest/client-namespace.d.mts +2 -0
  288. package/dist/rest/client.d.mts +32 -8
  289. package/dist/rest/client.mjs +314 -388
  290. package/dist/rest/commits.d.mts +284 -284
  291. package/dist/rest/errors.d.mts +10 -10
  292. package/dist/rest/errors.mjs +1 -1
  293. package/dist/rest/events.d.mts +13 -11
  294. package/dist/rest/events.mjs +3 -1
  295. package/dist/rest/files.d.mts +48 -48
  296. package/dist/rest/forks.d.mts +131 -143
  297. package/dist/rest/handler.mjs +4 -3
  298. package/dist/rest/handlers.mjs +15 -8
  299. package/dist/rest/layer.d.mts +3 -3
  300. package/dist/rest/layer.mjs +8 -7
  301. package/dist/rest/listen.d.mts +8 -6
  302. package/dist/rest/listen.mjs +33 -77
  303. package/dist/rest/me.d.mts +18 -20
  304. package/dist/rest/me.mjs +1 -1
  305. package/dist/rest/merges.d.mts +17 -17
  306. package/dist/rest/queue.d.mts +140 -140
  307. package/dist/rest/queue.mjs +1 -1
  308. package/dist/rest/refs.d.mts +214 -214
  309. package/dist/rest/refs.mjs +1 -1
  310. package/dist/rest/repos.d.mts +123 -135
  311. package/dist/rest/tags.d.mts +30 -30
  312. package/dist/rest/tokens.d.mts +250 -260
  313. package/dist/rest/tokens.mjs +10 -42
  314. package/dist/rest/topics.d.mts +162 -162
  315. package/dist/rest/topics.mjs +1 -1
  316. package/dist/rest/trees.d.mts +117 -117
  317. package/dist/rest/wire.d.mts +7 -5
  318. package/dist/rest/wire.mjs +4 -3
  319. package/dist/rest/work.d.mts +69 -69
  320. package/dist/rest/work.mjs +1 -1
  321. package/dist/rest.d.mts +1 -7
  322. package/dist/rest.mjs +1 -5
  323. package/dist/server/check-fetch.mjs +9 -0
  324. package/dist/server/extension.mjs +3 -115
  325. package/dist/server/git-layer.d.mts +30 -5
  326. package/dist/server/git-layer.mjs +59 -29
  327. package/dist/server/git-namespace.d.mts +4 -4
  328. package/dist/server/git-namespace.mjs +6 -4
  329. package/dist/server/joined.d.mts +83 -0
  330. package/dist/server/joined.mjs +91 -0
  331. package/dist/server/registry.d.mts +7 -3
  332. package/dist/server/registry.mjs +135 -31
  333. package/dist/server/server.d.mts +9 -3
  334. package/dist/server/server.mjs +277 -208
  335. package/dist/signin/context.d.mts +2 -2
  336. package/dist/signin/context.mjs +28 -37
  337. package/dist/signin/device.mjs +5 -5
  338. package/dist/signin/forms.mjs +1 -1
  339. package/dist/signin/grants.d.mts +2 -3
  340. package/dist/signin/grants.mjs +5 -5
  341. package/dist/signin/layer.d.mts +9 -0
  342. package/dist/signin/layer.mjs +41 -0
  343. package/dist/signin/namespace.d.mts +2 -0
  344. package/dist/signin/public.d.mts +6 -0
  345. package/dist/signin/public.mjs +5 -0
  346. package/dist/signin/route.mjs +47 -21
  347. package/dist/signin/web.mjs +3 -3
  348. package/dist/signin/wire.mjs +1 -1
  349. package/dist/storage/calls.d.mts +1 -1
  350. package/dist/storage/calls.mjs +4 -4
  351. package/dist/storage/clean-up.mjs +15 -6
  352. package/dist/storage/counted-bucket.mjs +34 -51
  353. package/dist/storage/fetch.mjs +1 -1
  354. package/dist/storage/fsck.mjs +12 -2
  355. package/dist/storage/graph-rebuild.mjs +262 -0
  356. package/dist/storage/host-bucket.mjs +1 -1
  357. package/dist/storage/index-build.d.mts +2 -2
  358. package/dist/storage/index-build.mjs +103 -15
  359. package/dist/storage/index-fetch.mjs +10 -6
  360. package/dist/storage/index-graph.mjs +1 -1
  361. package/dist/storage/index-layers.mjs +1 -1
  362. package/dist/storage/index-visible.mjs +1 -1
  363. package/dist/storage/lfs-pointers.d.mts +5 -5
  364. package/dist/storage/lfs-pointers.mjs +37 -11
  365. package/dist/storage/loose.mjs +4 -1
  366. package/dist/storage/memory-budget.mjs +8 -2
  367. package/dist/storage/merge-cut.mjs +24 -1
  368. package/dist/storage/merge-fence.mjs +82 -20
  369. package/dist/storage/merge-most.mjs +1 -0
  370. package/dist/storage/merge-plan.mjs +5 -2
  371. package/dist/storage/merge-row.mjs +17 -5
  372. package/dist/storage/merge-stream.mjs +25 -13
  373. package/dist/storage/merge-write.mjs +1 -1
  374. package/dist/storage/merge.d.mts +2 -2
  375. package/dist/storage/merge.mjs +1 -1
  376. package/dist/storage/object-rows.d.mts +2 -2
  377. package/dist/storage/object-rows.mjs +20 -4
  378. package/dist/storage/pack-ranges.d.mts +3 -1
  379. package/dist/storage/pack-ranges.mjs +168 -69
  380. package/dist/storage/pack-reads.mjs +4 -4
  381. package/dist/storage/pack-receive.d.mts +1 -1
  382. package/dist/storage/pack-receive.mjs +17 -15
  383. package/dist/storage/packs.d.mts +1 -1
  384. package/dist/storage/packs.mjs +103 -79
  385. package/dist/storage/placed-reads.mjs +81 -15
  386. package/dist/storage/prune-seen.mjs +126 -0
  387. package/dist/storage/prune-walk.mjs +87 -99
  388. package/dist/storage/prune.mjs +113 -50
  389. package/dist/storage/push-uploads.mjs +4 -2
  390. package/dist/storage/quarantine.d.mts +2 -2
  391. package/dist/storage/ready.d.mts +2 -2
  392. package/dist/storage/ready.mjs +15 -6
  393. package/dist/storage/receive-files.mjs +1 -1
  394. package/dist/storage/receive-links.mjs +1 -1
  395. package/dist/storage/receive-state.d.mts +2 -2
  396. package/dist/storage/receive-state.mjs +2 -2
  397. package/dist/storage/receive-steps.mjs +1 -1
  398. package/dist/storage/repack-contained.mjs +24 -16
  399. package/dist/storage/repack-job.d.mts +2 -2
  400. package/dist/storage/repack-job.mjs +5 -4
  401. package/dist/storage/repack.d.mts +2 -2
  402. package/dist/storage/repack.mjs +12 -5
  403. package/dist/storage/rows.d.mts +2 -2
  404. package/dist/storage/rows.mjs +1 -1
  405. package/dist/storage/runs.d.mts +2 -2
  406. package/dist/storage/runs.mjs +15 -6
  407. package/dist/storage/send-list.mjs +6 -6
  408. package/dist/storage/single-flight.mjs +2 -2
  409. package/dist/storage/swap-walk.mjs +1 -1
  410. package/dist/storage/unpack.mjs +8 -1
  411. package/dist/store/call-count.d.mts +24 -4
  412. package/dist/store/call-count.mjs +158 -44
  413. package/dist/store/catalogue.d.mts +1 -1
  414. package/dist/store/catalogue.mjs +2 -2
  415. package/dist/store/crossing.mjs +2 -6
  416. package/dist/store/cursor-seal.mjs +1 -1
  417. package/dist/store/errors.d.mts +7 -3
  418. package/dist/store/errors.mjs +41 -13
  419. package/dist/store/job-try.mjs +119 -15
  420. package/dist/store/list-job.mjs +5 -5
  421. package/dist/store/outbox.d.mts +2 -2
  422. package/dist/store/outbox.mjs +75 -16
  423. package/dist/store/promises.d.mts +2 -2
  424. package/dist/store/promises.mjs +31 -6
  425. package/dist/store/queue-jobs.mjs +1 -1
  426. package/dist/store/records.d.mts +2 -2
  427. package/dist/store/records.mjs +22 -24
  428. package/dist/store/ref-rows.d.mts +2 -2
  429. package/dist/store/ref-rows.mjs +6 -6
  430. package/dist/store/repo-record.mjs +29 -12
  431. package/dist/store/reservations.mjs +35 -8
  432. package/dist/store/scopes.mjs +12 -5
  433. package/dist/store/topic-jobs.mjs +8 -8
  434. package/dist/sync/bound.d.mts +1 -3
  435. package/dist/sync/bound.mjs +30 -42
  436. package/dist/sync/github.d.mts +5 -6
  437. package/dist/sync/github.mjs +37 -42
  438. package/dist/sync/http.mjs +15 -0
  439. package/dist/sync/import.mjs +30 -19
  440. package/dist/sync/layer.d.mts +13 -0
  441. package/dist/sync/layer.mjs +73 -0
  442. package/dist/sync/mirror.mjs +137 -58
  443. package/dist/sync/publish.mjs +3 -6
  444. package/dist/sync/step.mjs +223 -85
  445. package/dist/sync/tries.mjs +22 -15
  446. package/dist/sync.d.mts +3 -6
  447. package/dist/sync.mjs +3 -6
  448. package/dist/topics/advance.mjs +210 -94
  449. package/dist/topics/calls.mjs +8 -8
  450. package/dist/topics/directory.mjs +35 -12
  451. package/dist/topics/host.d.mts +5 -8
  452. package/dist/topics/host.mjs +42 -19
  453. package/dist/topics/layer.d.mts +381 -0
  454. package/dist/topics/layer.mjs +62 -0
  455. package/dist/topics/members.mjs +39 -10
  456. package/dist/topics/namespace.d.mts +2 -0
  457. package/dist/topics/public.d.mts +6 -0
  458. package/dist/topics/public.mjs +13 -0
  459. package/dist/topics/rows.mjs +12 -3
  460. package/dist/topics/topic.mjs +11 -10
  461. package/package.json +8 -13
  462. package/dist/access.d.mts +0 -2
  463. package/dist/access.mjs +0 -1
  464. package/dist/core/hooks/post-receive.mjs +0 -216
  465. package/dist/core/hooks/pre-receive.d.mts +0 -12
  466. package/dist/core/hooks/pre-receive.mjs +0 -36
  467. package/dist/engine/merge-base-walk.d.mts +0 -3
  468. package/dist/server/extension.d.mts +0 -21
  469. package/dist/server/routes.d.mts +0 -32
  470. package/dist/server/routes.mjs +0 -69
  471. package/dist/sync/import.d.mts +0 -10
  472. package/dist/sync/jobs.d.mts +0 -9
  473. package/dist/sync/jobs.mjs +0 -75
  474. package/dist/sync/mirror.d.mts +0 -13
  475. package/dist/sync/publish.d.mts +0 -6
  476. /package/dist/core/{claim-rows.d.mts → registered-rows.d.mts} +0 -0
@@ -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 };
@@ -12,16 +12,16 @@ import { decodeRefused, refusedRead } from "./merge-fence.mjs";
12
12
  import { decodeMerges, droppedStep, mergeKey, mergeRead, takenOf, writtenOf } from "./merge-row.mjs";
13
13
  import { mergeInputsMost } from "./merge-most.mjs";
14
14
  import { opensWithin, resumeMerge, streamMerge } from "./merge-stream.mjs";
15
- import { objectKey } from "./object-rows.mjs";
15
+ import { noRows, objectKey, rowsMoved } 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,33 @@ 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. The next pass's first step drops
154
+ * them, or a deleted repo's step, which no pass follows.
148
155
  */
149
- const walkPackOf = (at, kind) => `p_${kind}${at.toString(36).padStart(15, "0")}`;
156
+ 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");
157
+ /**
158
+ * The bucket keys `started` names under its pass's scratch packs: each walk's runs, saved or
159
+ * done, and its classes object. Bounded by the mark's record, so a drop of them takes one call.
160
+ */
161
+ const markKeys = (started, repo, at) => {
162
+ const keys = /* @__PURE__ */ new Set();
163
+ const carries = [started?.walks?.r, started?.walks?.n];
164
+ for (const carry of carries) {
165
+ if (carry === void 0) continue;
166
+ for (const key of carry.refs?.keys ?? []) keys.add(key);
167
+ if ("done" in carry) for (const key of carry.done.keys) keys.add(key);
168
+ else for (const key of walkKeys(carry.saved)) keys.add(key);
169
+ }
170
+ if (started?.classes !== void 0) keys.add(classesKey(repo, at, started.classes.n));
171
+ return keys;
172
+ };
150
173
  /**
151
174
  * A pass's reach, as a set: an ID is in it when the bits' rows hold it, or its first pack among
152
175
  * `packs` keeps it at its rank, as D3's `keptAt` says. Its IDs run each pack's set bits, then the
@@ -273,7 +296,7 @@ const sameIds = (a, b) => {
273
296
  return a.length === b.length && b.every((id) => named.has(id));
274
297
  };
275
298
  /** 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);
299
+ const classesKey = (repo, at, n) => runKey(walkPackOf(repo, at, "r"), "classes", n);
277
300
  const ClassesHeader = /* @__PURE__ */ Schema.fromJsonString(Schema.Struct({ packs: Schema.Array(Schema.Struct({
278
301
  pack: Schema.String.pipe(Schema.refine(isPackId)),
279
302
  count: Schema.Int.check(Schema.isBetween({
@@ -371,7 +394,8 @@ const cruftListing = (landed) => Effect.fnUntraced(function* (input, merge) {
371
394
  ...cruftKey(pack.id),
372
395
  value: { since: input.at }
373
396
  })),
374
- delete: [...quarantines, mergeKey(merge.pack)]
397
+ delete: [...quarantines, mergeKey(merge.pack)],
398
+ rows: noRows
375
399
  },
376
400
  more: true,
377
401
  quarantine: first,
@@ -399,7 +423,8 @@ const keptListing = (read, seen, rows, landed) => Effect.fnUntraced(function* (i
399
423
  ...quarantines,
400
424
  ...dropped.map((pack) => cruftKey(pack.id)),
401
425
  mergeKey(merge.pack)
402
- ]
426
+ ],
427
+ rows: noRows
403
428
  },
404
429
  more: true,
405
430
  quarantine: first,
@@ -455,7 +480,8 @@ const rowsCruft = /* @__PURE__ */ Effect.fnUntraced(function* (input, rows, most
455
480
  ...cruftKey(id),
456
481
  value: { since: input.at }
457
482
  }],
458
- delete: [merged.quarantine]
483
+ delete: [merged.quarantine],
484
+ rows: noRows
459
485
  },
460
486
  more: true,
461
487
  quarantine: merged.quarantine
@@ -470,7 +496,10 @@ const rowsStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, rows, keep,
470
496
  });
471
497
  if (merged === "too big") return { waits: "its rows pack is past the pack size" };
472
498
  const step = {
473
- change: merged === void 0 ? { delete: rows.map((row) => objectKey(row.oid)) } : replacing(input, merged, [], rows),
499
+ change: merged === void 0 ? {
500
+ delete: rows.map((row) => objectKey(row.oid)),
501
+ rows: rowsMoved(rows, "deleted")
502
+ } : replacing(input, merged, [], rows),
474
503
  more: true
475
504
  };
476
505
  if (merged !== void 0) step.quarantine = merged.quarantine;
@@ -478,7 +507,9 @@ const rowsStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, rows, keep,
478
507
  });
479
508
  /**
480
509
  * The step that unlists each pack of `emptied`, whose every object the pass drops, with no merge:
481
- * each a `leaving` row, and an old cruft pack's `cruft` row ended, so the step `drops`.
510
+ * each a `leaving` row, and an old cruft pack's `cruft` row ended, so the step `drops`. It makes
511
+ * the `repack` row due, whose clean-up deletes the packs' bytes once their rows are, so on a repo
512
+ * that takes no push they don't wait for the row's next run.
482
513
  */
483
514
  const emptiedStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, emptied) {
484
515
  const ids = new Set(emptied.map((each) => each.pack));
@@ -488,9 +519,11 @@ const emptiedStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, em
488
519
  change: {
489
520
  remove: removed.map((pack) => pack.id),
490
521
  put: leavingRows(input, removed),
491
- delete: dropped.map((pack) => cruftKey(pack.id))
522
+ delete: dropped.map((pack) => cruftKey(pack.id)),
523
+ rows: noRows
492
524
  },
493
- more: true
525
+ more: true,
526
+ repack: input.at
494
527
  };
495
528
  if (dropped.length > 0) step.drops = true;
496
529
  return step;
@@ -528,10 +561,10 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
528
561
  const carried = read.started?.walks ?? {};
529
562
  const classes = read.started?.classes;
530
563
  const redos = read.started?.redos ?? 0;
531
- const scratch = walkPackOf(at, "r");
564
+ const scratch = walkPackOf(input.listed.repo, at, "r");
532
565
  const saving = (walks) => ({
533
566
  step: {
534
- change: {},
567
+ change: { rows: noRows },
535
568
  more: true
536
569
  },
537
570
  mark: { walks }
@@ -575,7 +608,7 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
575
608
  };
576
609
  if (classes.kind === "cruft" || merge.value.pass !== "commit" || seenHolds(classes)) return went(yield* resumeMerge(input, merge, most, calls, listingOf(classes)), classes.kind);
577
610
  }
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;
611
+ 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
612
  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
613
  const reachedRuns = carry.done;
581
614
  const bits = yield* keepBits(input, scratch, reachedRuns, rowOids, lost);
@@ -627,7 +660,7 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
627
660
  const copies = (yield* classBits(input, fresh, (indexed, rank) => !reachedAt(indexed, rank) && !apart(indexed.index.oidAt(rank)))).filter((each) => each.set > 0);
628
661
  if (copies.length === 0) return { start };
629
662
  const n = (classes?.n ?? -1) + 1;
630
- const bytes = yield* putClasses(input, classesKey(at, n), copies);
663
+ const bytes = yield* putClasses(input, classesKey(input.listed.repo, at, n), copies);
631
664
  return { classes: {
632
665
  kind: "cruft",
633
666
  n,
@@ -639,12 +672,12 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
639
672
  if ("cruft" in first) return first.cruft;
640
673
  if ("classes" in first) return {
641
674
  step: {
642
- change: {},
675
+ change: { rows: noRows },
643
676
  more: true
644
677
  },
645
678
  mark: { classes: first.classes }
646
679
  };
647
- const named = walkPackOf(at, "n");
680
+ const named = walkPackOf(input.listed.repo, at, "n");
648
681
  const neededCarry = carried.n;
649
682
  if (packs.old.length > 0 && (neededCarry === void 0 || "saved" in neededCarry)) {
650
683
  const start = neededCarry === void 0 ? first.start : [];
@@ -676,7 +709,7 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
676
709
  const inRows = new Set(rowOids);
677
710
  const keep = (oid) => reached.has(oid) || !apart(oid) && (inFresh(oid) || inRows.has(oid) || needed.has(oid));
678
711
  if (merge !== void 0 && classes !== void 0) {
679
- const before = yield* readClasses(input, classesKey(at, classes.n), classes.bytes);
712
+ const before = yield* readClasses(input, classesKey(input.listed.repo, at, classes.n), classes.bytes);
680
713
  const byPack = new Map((before ?? []).map((each) => [each.pack, each.bits]));
681
714
  const inputs = new Set(merge.value.inputs);
682
715
  if (!merging.some(({ pack, index }) => {
@@ -709,28 +742,37 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
709
742
  if (emptied.length > 0) return { step: yield* emptiedStep(input, read, emptied) };
710
743
  if (rewrites.length > 0) {
711
744
  const n = (classes?.n ?? -1) + 1;
745
+ const value = {
746
+ kind: "kept",
747
+ n,
748
+ packs: ids,
749
+ reads: digest,
750
+ bytes: yield* putClasses(input, classesKey(input.listed.repo, at, n), rewrites)
751
+ };
712
752
  return {
713
753
  step: {
714
- change: {},
754
+ change: { rows: noRows },
715
755
  more: true
716
756
  },
717
- mark: { classes: {
718
- kind: "kept",
719
- n,
720
- packs: ids,
721
- reads: digest,
722
- bytes: yield* putClasses(input, classesKey(at, n), rewrites)
723
- } }
757
+ mark: { classes: value }
724
758
  };
725
759
  }
726
760
  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);
761
+ const marked = markKeys(read.started, input.listed.repo, at);
762
+ const scratchDropped = yield* dropRuns(input.bucket, scratch, marked);
763
+ const namedDropped = yield* dropRuns(input.bucket, named, marked);
764
+ if (scratchDropped === "more" || namedDropped === "more") return { step: {
765
+ change: { rows: noRows },
766
+ more: true
767
+ } };
729
768
  const step = {
730
- change: { put: [{
731
- ...prunePassKey,
732
- value: { at: input.at }
733
- }] },
769
+ change: {
770
+ put: [{
771
+ ...prunePassKey,
772
+ value: { at: input.at }
773
+ }],
774
+ rows: noRows
775
+ },
734
776
  more: false
735
777
  };
736
778
  const whole = (oid) => keep(oid) || inFenced(oid);
@@ -814,12 +856,23 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
814
856
  next: after
815
857
  };
816
858
  }
859
+ const ended = read.started?.at;
860
+ if (ended !== void 0 && last !== void 0 && ended <= last && (yield* passScratch(input, ended)) === "more") return {
861
+ step: {
862
+ change: { rows: noRows },
863
+ more: true
864
+ },
865
+ next
866
+ };
817
867
  if (markHeld && read.cruft.size === 0 && merge === void 0) return {
818
868
  step: {
819
- change: { put: [{
820
- ...prunePassKey,
821
- value: { at: input.at }
822
- }] },
869
+ change: {
870
+ put: [{
871
+ ...prunePassKey,
872
+ value: { at: input.at }
873
+ }],
874
+ rows: noRows
875
+ },
823
876
  more: true
824
877
  },
825
878
  next: input.at + pruneWait(prune)
@@ -842,10 +895,13 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
842
895
  const { started } = read;
843
896
  if (!(started !== void 0 && (last === void 0 || started.at > last))) return {
844
897
  step: {
845
- change: { put: [{
846
- ...pruneStartedKey,
847
- value: { at: input.at }
848
- }] },
898
+ change: {
899
+ put: [{
900
+ ...pruneStartedKey,
901
+ value: { at: input.at }
902
+ }],
903
+ rows: noRows
904
+ },
849
905
  more: true
850
906
  },
851
907
  next
@@ -863,9 +919,13 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
863
919
  }
864
920
  };
865
921
  const step = {
866
- change: merge === void 0 ? { put: [mark] } : {
922
+ change: merge === void 0 ? {
923
+ put: [mark],
924
+ rows: noRows
925
+ } : {
867
926
  put: [mark],
868
- delete: [mergeKey(merge.pack)]
927
+ delete: [mergeKey(merge.pack)],
928
+ rows: noRows
869
929
  },
870
930
  more: true
871
931
  };
@@ -890,10 +950,13 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
890
950
  }
891
951
  };
892
952
  if ("last" in stepped) {
893
- const rewalk = { put: [{
894
- ...pruneStartedKey,
895
- value: { at: started.at }
896
- }] };
953
+ const rewalk = {
954
+ put: [{
955
+ ...pruneStartedKey,
956
+ value: { at: started.at }
957
+ }],
958
+ rows: noRows
959
+ };
897
960
  return {
898
961
  step: {
899
962
  ...step.reaches === true ? {
@@ -910,4 +973,4 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
910
973
  next
911
974
  };
912
975
  });
913
- export { CruftRow, PassClasses, PruneCleared, PrunePass, PruneStarted, bitsOf, cruftOf, mergesAlone, passDue, pruneClearedKey, prunePassKey, pruneStartedKey, pruneStep, reachesOnly, readPrune, walkPackOf };
976
+ export { CruftRow, PassClasses, PruneCleared, PrunePass, PruneStarted, bitsOf, cruftOf, mergesAlone, passDue, passScratch, pruneClearedKey, prunePassKey, pruneStartedKey, pruneStep, reachesOnly, readPrune, walkPackOf };