@ref0/git 0.6.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 (431) 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 +28 -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 +4 -5
  13. package/dist/auth/fences.d.mts +1 -1
  14. package/dist/auth/host-function.mjs +17 -8
  15. package/dist/auth/identify.mjs +2 -1
  16. package/dist/auth/namespaces.d.mts +2 -2
  17. package/dist/auth/token-rows.mjs +1 -1
  18. package/dist/auth/tokens-layer.d.mts +42 -0
  19. package/dist/auth/tokens-layer.mjs +29 -0
  20. package/dist/auth/tokens-namespace.d.mts +2 -0
  21. package/dist/auth/tokens-public.d.mts +6 -0
  22. package/dist/auth/tokens-public.mjs +29 -0
  23. package/dist/auth/tokens.d.mts +13 -6
  24. package/dist/auth/tokens.mjs +5 -5
  25. package/dist/auth.d.mts +2 -2
  26. package/dist/auth.mjs +2 -2
  27. package/dist/client/git-http.mjs +1 -1
  28. package/dist/client/local.mjs +4 -3
  29. package/dist/client/remote-helper.mjs +3 -8
  30. package/dist/client/remote.mjs +26 -7
  31. package/dist/client/run-remote-helper.d.mts +1 -1
  32. package/dist/client/run-remote-helper.mjs +2 -2
  33. package/dist/client/slice-push.d.mts +1 -1
  34. package/dist/contracts/access.d.mts +18 -10
  35. package/dist/contracts/access.mjs +17 -0
  36. package/dist/contracts/actors.d.mts +17 -1
  37. package/dist/contracts/actors.mjs +8 -1
  38. package/dist/contracts/authorize.d.mts +7 -4
  39. package/dist/contracts/blobs.d.mts +1 -1
  40. package/dist/contracts/blobs.mjs +1 -1
  41. package/dist/contracts/calls-spent.d.mts +6 -4
  42. package/dist/contracts/calls-spent.mjs +10 -8
  43. package/dist/contracts/commits.d.mts +2 -2
  44. package/dist/contracts/commits.mjs +1 -1
  45. package/dist/contracts/engine.d.mts +1 -1
  46. package/dist/contracts/events.d.mts +33 -22
  47. package/dist/contracts/events.mjs +13 -4
  48. package/dist/contracts/files.d.mts +2 -2
  49. package/dist/contracts/files.mjs +1 -1
  50. package/dist/contracts/forks.d.mts +58 -58
  51. package/dist/contracts/forks.mjs +1 -1
  52. package/dist/contracts/git-events.d.mts +50 -0
  53. package/dist/contracts/git-events.mjs +23 -0
  54. package/dist/contracts/git-hooks.d.mts +37 -0
  55. package/dist/contracts/git-hooks.mjs +10 -0
  56. package/dist/contracts/git.d.mts +93 -42
  57. package/dist/contracts/git.mjs +6 -5
  58. package/dist/contracts/ids.d.mts +16 -0
  59. package/dist/contracts/ids.mjs +19 -4
  60. package/dist/contracts/lfs.d.mts +2 -0
  61. package/dist/contracts/namespaces.d.mts +2 -2
  62. package/dist/contracts/objects.d.mts +1 -1
  63. package/dist/contracts/opaque.mjs +9 -0
  64. package/dist/contracts/operations.d.mts +293 -100
  65. package/dist/contracts/promises.d.mts +2 -0
  66. package/dist/contracts/push-uploads.d.mts +4 -1
  67. package/dist/contracts/push-uploads.mjs +9 -4
  68. package/dist/contracts/queue.d.mts +218 -47
  69. package/dist/contracts/queue.mjs +81 -6
  70. package/dist/contracts/refs.d.mts +30 -8
  71. package/dist/contracts/refs.mjs +1 -1
  72. package/dist/contracts/remote.d.mts +42 -21
  73. package/dist/contracts/remote.mjs +22 -0
  74. package/dist/contracts/repo-records.d.mts +2 -2
  75. package/dist/contracts/repos.d.mts +126 -79
  76. package/dist/contracts/repos.mjs +43 -5
  77. package/dist/contracts/result.d.mts +46 -31
  78. package/dist/contracts/result.mjs +43 -16
  79. package/dist/contracts/rules.d.mts +50 -44
  80. package/dist/contracts/rules.mjs +5 -1
  81. package/dist/contracts/server.d.mts +282 -198
  82. package/dist/contracts/services.d.mts +1 -7
  83. package/dist/contracts/services.mjs +1 -3
  84. package/dist/contracts/signin.d.mts +140 -43
  85. package/dist/contracts/signin.mjs +35 -1
  86. package/dist/contracts/store.d.mts +1 -1
  87. package/dist/contracts/sync.d.mts +112 -90
  88. package/dist/contracts/sync.mjs +34 -7
  89. package/dist/contracts/tags.d.mts +1 -1
  90. package/dist/contracts/tags.mjs +1 -1
  91. package/dist/contracts/tokens.d.mts +232 -57
  92. package/dist/contracts/tokens.mjs +80 -19
  93. package/dist/contracts/topics.d.mts +22 -10
  94. package/dist/contracts/topics.mjs +6 -3
  95. package/dist/contracts/trees.d.mts +2 -2
  96. package/dist/contracts/trees.mjs +1 -1
  97. package/dist/contracts/work.d.mts +2 -2
  98. package/dist/contracts/work.mjs +2 -2
  99. package/dist/core/access.d.mts +10 -10
  100. package/dist/core/access.mjs +31 -8
  101. package/dist/core/clock.mjs +1 -1
  102. package/dist/core/events/deliver.d.mts +3 -2
  103. package/dist/core/events/deliver.mjs +170 -92
  104. package/dist/core/forks.mjs +49 -24
  105. package/dist/core/hooks/groups.d.mts +27 -0
  106. package/dist/core/hooks/groups.mjs +74 -0
  107. package/dist/core/hooks/namespace.d.mts +2 -0
  108. package/dist/core/hooks/order.d.mts +2 -2
  109. package/dist/core/hooks/order.mjs +6 -6
  110. package/dist/core/hooks/public.d.mts +7 -0
  111. package/dist/core/hooks/public.mjs +5 -0
  112. package/dist/core/imports.mjs +94 -10
  113. package/dist/core/index-job.mjs +11 -8
  114. package/dist/core/merge-parts.d.mts +1 -1
  115. package/dist/core/merge-parts.mjs +1 -1
  116. package/dist/core/mirror-rows.mjs +18 -0
  117. package/dist/core/names.mjs +1 -1
  118. package/dist/core/namespaces.d.mts +2 -1
  119. package/dist/core/objects/commit-writes.mjs +5 -5
  120. package/dist/core/objects/merges.mjs +1 -1
  121. package/dist/core/objects/objects-layer.mjs +1 -1
  122. package/dist/core/objects/reading.mjs +52 -7
  123. package/dist/core/objects/tree-edits.mjs +13 -28
  124. package/dist/core/objects/trees.mjs +4 -4
  125. package/dist/core/objects/writing.mjs +3 -3
  126. package/dist/core/own-writes.mjs +1 -1
  127. package/dist/core/parts.d.mts +22 -3
  128. package/dist/core/parts.mjs +5 -3
  129. package/dist/core/promise.mjs +23 -3
  130. package/dist/core/purge.d.mts +2 -2
  131. package/dist/core/purge.mjs +80 -30
  132. package/dist/core/push.mjs +55 -74
  133. package/dist/core/receipts.d.mts +2 -2
  134. package/dist/core/receipts.mjs +28 -4
  135. package/dist/core/ref-index-job.mjs +4 -4
  136. package/dist/core/ref-view.mjs +2 -2
  137. package/dist/core/refs.mjs +41 -10
  138. package/dist/core/registered-records.mjs +30 -0
  139. package/dist/core/{claim-rows.mjs → registered-rows.mjs} +6 -6
  140. package/dist/core/repack.d.mts +2 -2
  141. package/dist/core/repack.mjs +11 -9
  142. package/dist/core/repo-info.mjs +59 -25
  143. package/dist/core/repos.mjs +17 -11
  144. package/dist/core/rules/changes.mjs +2 -2
  145. package/dist/core/rules/commit-changes.mjs +1 -1
  146. package/dist/core/rules/context.d.mts +4 -5
  147. package/dist/core/rules/context.mjs +3 -4
  148. package/dist/core/rules/fetch.mjs +74 -21
  149. package/dist/core/saved-caller-views.d.mts +72 -0
  150. package/dist/core/saved-caller-views.mjs +123 -0
  151. package/dist/core/saved-callers-public.d.mts +5 -0
  152. package/dist/core/saved-callers-public.mjs +10 -0
  153. package/dist/core/saved-callers.mjs +95 -0
  154. package/dist/core/seam.d.mts +12 -1
  155. package/dist/core/seam.mjs +4 -2
  156. package/dist/core/tokens.mjs +5 -1
  157. package/dist/core/view.d.mts +1 -1
  158. package/dist/core/view.mjs +1 -1
  159. package/dist/core/work.mjs +6 -5
  160. package/dist/effect.d.mts +2 -2
  161. package/dist/effect.mjs +2 -2
  162. package/dist/engine/content.d.mts +2 -2
  163. package/dist/engine/content.mjs +1 -1
  164. package/dist/engine/diff.mjs +2 -2
  165. package/dist/engine/merge-base-walk.d.mts +2 -2
  166. package/dist/engine/merge-base-walk.mjs +1 -1
  167. package/dist/engine/merge-renames.mjs +1 -1
  168. package/dist/engine/reads.d.mts +2 -2
  169. package/dist/engine/reads.mjs +1 -1
  170. package/dist/engine/xdiff.d.mts +1 -1
  171. package/dist/engine/xdiff.mjs +2 -2
  172. package/dist/event-streams/event-streams.d.mts +6 -2
  173. package/dist/event-streams/event-streams.mjs +6 -2
  174. package/dist/event-streams/stream.mjs +5 -2
  175. package/dist/extend.d.mts +3 -3
  176. package/dist/extend.mjs +3 -2
  177. package/dist/http/answers.mjs +4 -3
  178. package/dist/http/core-parts.mjs +2 -2
  179. package/dist/http/handler.mjs +1 -1
  180. package/dist/http/parts.d.mts +1 -0
  181. package/dist/http/push-uploads.mjs +7 -5
  182. package/dist/http/receive-pack.mjs +3 -3
  183. package/dist/http/upload-pack.mjs +6 -5
  184. package/dist/index.d.mts +33 -20
  185. package/dist/index.mjs +13 -7
  186. package/dist/lfs/base.d.mts +2 -2
  187. package/dist/lfs/calls.mjs +3 -2
  188. package/dist/lfs/layer.d.mts +5 -4
  189. package/dist/lfs/layer.mjs +17 -16
  190. package/dist/lfs/locks.mjs +3 -3
  191. package/dist/lfs/objects.d.mts +3 -2
  192. package/dist/lfs/objects.mjs +149 -34
  193. package/dist/lfs/pointers.mjs +1 -1
  194. package/dist/lfs/purge.mjs +1 -1
  195. package/dist/lfs/rows.mjs +1 -1
  196. package/dist/lfs/upkeep.mjs +13 -9
  197. package/dist/lfs/wire.mjs +1 -1
  198. package/dist/protocol/bytes/buffers.d.mts +1 -1
  199. package/dist/protocol/bytes/buffers.mjs +1 -1
  200. package/dist/protocol/bytes/deflate.d.mts +1 -1
  201. package/dist/protocol/bytes/deflate.mjs +1 -1
  202. package/dist/protocol/bytes/hmac-sha256.mjs +3 -6
  203. package/dist/protocol/bytes/inflate.d.mts +1 -1
  204. package/dist/protocol/bytes/inflate.mjs +1 -1
  205. package/dist/protocol/bytes/sha1.d.mts +1 -1
  206. package/dist/protocol/bytes/sha1.mjs +2 -2
  207. package/dist/protocol/diff/read.d.mts +1 -1
  208. package/dist/protocol/diff/read.mjs +1 -1
  209. package/dist/protocol/diff/tree-diff.d.mts +1 -1
  210. package/dist/protocol/diff/tree-diff.mjs +11 -11
  211. package/dist/protocol/objects/lfs-pointer.mjs +6 -1
  212. package/dist/protocol/objects/tag.mjs +1 -1
  213. package/dist/protocol/objects/tree.mjs +1 -1
  214. package/dist/protocol/packs/graph.mjs +1 -1
  215. package/dist/protocol/packs/idx.d.mts +1 -1
  216. package/dist/protocol/packs/idx.mjs +1 -1
  217. package/dist/protocol/packs/parts.mjs +1 -1
  218. package/dist/protocol/packs/reader.d.mts +1 -1
  219. package/dist/protocol/packs/reader.mjs +2 -2
  220. package/dist/protocol/packs/write-error.d.mts +1 -1
  221. package/dist/protocol/packs/write-error.mjs +1 -1
  222. package/dist/protocol/packs/writer.mjs +4 -4
  223. package/dist/protocol/wire/advertisement.d.mts +1 -1
  224. package/dist/protocol/wire/advertisement.mjs +1 -1
  225. package/dist/protocol/wire/fetch.d.mts +1 -1
  226. package/dist/protocol/wire/fetch.mjs +1 -1
  227. package/dist/protocol/wire/lines.d.mts +1 -1
  228. package/dist/protocol/wire/lines.mjs +2 -2
  229. package/dist/protocol/wire/push-uploads.mjs +4 -2
  230. package/dist/protocol/wire/receive-pack.d.mts +1 -1
  231. package/dist/protocol/wire/receive-pack.mjs +1 -1
  232. package/dist/protocol/wire/report-status.d.mts +1 -1
  233. package/dist/protocol/wire/report-status.mjs +1 -1
  234. package/dist/protocol/wire/v2.d.mts +2 -2
  235. package/dist/protocol/wire/v2.mjs +2 -2
  236. package/dist/queue/advance.mjs +155 -63
  237. package/dist/queue/callers.mjs +56 -69
  238. package/dist/queue/calls.mjs +20 -11
  239. package/dist/queue/commit.mjs +28 -22
  240. package/dist/queue/host.d.mts +10 -11
  241. package/dist/queue/host.mjs +15 -7
  242. package/dist/queue/lanes.mjs +9 -18
  243. package/dist/queue/layer.d.mts +3 -3
  244. package/dist/queue/layer.mjs +11 -10
  245. package/dist/queue/limits.mjs +17 -5
  246. package/dist/queue/rows.mjs +5 -10
  247. package/dist/queue/schedule.mjs +6 -5
  248. package/dist/queue/search.mjs +8 -13
  249. package/dist/queue/state.mjs +7 -2
  250. package/dist/queue/trim.mjs +10 -5
  251. package/dist/rest/api.d.mts +1 -1
  252. package/dist/rest/blobs.d.mts +20 -20
  253. package/dist/rest/caller.d.mts +22 -20
  254. package/dist/rest/client.mjs +6 -6
  255. package/dist/rest/commits.d.mts +335 -335
  256. package/dist/rest/errors.d.mts +10 -10
  257. package/dist/rest/errors.mjs +1 -1
  258. package/dist/rest/events.d.mts +13 -11
  259. package/dist/rest/events.mjs +3 -1
  260. package/dist/rest/files.d.mts +30 -30
  261. package/dist/rest/forks.d.mts +150 -150
  262. package/dist/rest/handler.mjs +4 -3
  263. package/dist/rest/handlers.mjs +13 -7
  264. package/dist/rest/layer.d.mts +3 -3
  265. package/dist/rest/layer.mjs +8 -7
  266. package/dist/rest/listen.mjs +2 -2
  267. package/dist/rest/me.d.mts +18 -20
  268. package/dist/rest/me.mjs +1 -1
  269. package/dist/rest/merges.d.mts +10 -10
  270. package/dist/rest/queue.d.mts +140 -140
  271. package/dist/rest/queue.mjs +1 -1
  272. package/dist/rest/refs.d.mts +95 -95
  273. package/dist/rest/refs.mjs +1 -1
  274. package/dist/rest/repos.d.mts +127 -127
  275. package/dist/rest/tags.d.mts +30 -30
  276. package/dist/rest/tokens.d.mts +250 -260
  277. package/dist/rest/tokens.mjs +10 -42
  278. package/dist/rest/topics.d.mts +63 -63
  279. package/dist/rest/topics.mjs +1 -1
  280. package/dist/rest/trees.d.mts +106 -106
  281. package/dist/rest/wire.d.mts +6 -4
  282. package/dist/rest/wire.mjs +4 -3
  283. package/dist/rest/work.d.mts +69 -69
  284. package/dist/rest/work.mjs +1 -1
  285. package/dist/server/check-fetch.mjs +9 -0
  286. package/dist/server/extension.mjs +3 -115
  287. package/dist/server/git-layer.d.mts +20 -3
  288. package/dist/server/git-layer.mjs +30 -19
  289. package/dist/server/git-namespace.d.mts +4 -4
  290. package/dist/server/git-namespace.mjs +6 -4
  291. package/dist/server/joined.d.mts +83 -0
  292. package/dist/server/joined.mjs +91 -0
  293. package/dist/server/registry.d.mts +7 -3
  294. package/dist/server/registry.mjs +135 -31
  295. package/dist/server/routes.mjs +2 -2
  296. package/dist/server/server.d.mts +9 -2
  297. package/dist/server/server.mjs +279 -191
  298. package/dist/signin/context.d.mts +2 -1
  299. package/dist/signin/context.mjs +32 -37
  300. package/dist/signin/device.mjs +5 -5
  301. package/dist/signin/forms.mjs +1 -1
  302. package/dist/signin/grants.d.mts +2 -3
  303. package/dist/signin/grants.mjs +5 -5
  304. package/dist/signin/layer.d.mts +9 -0
  305. package/dist/signin/layer.mjs +41 -0
  306. package/dist/signin/namespace.d.mts +2 -0
  307. package/dist/signin/public.d.mts +6 -0
  308. package/dist/signin/public.mjs +5 -0
  309. package/dist/signin/route.mjs +47 -21
  310. package/dist/signin/web.mjs +3 -3
  311. package/dist/signin/wire.mjs +1 -1
  312. package/dist/storage/calls.d.mts +1 -1
  313. package/dist/storage/calls.mjs +4 -4
  314. package/dist/storage/clean-up.mjs +12 -5
  315. package/dist/storage/counted-bucket.mjs +34 -51
  316. package/dist/storage/fetch.mjs +1 -1
  317. package/dist/storage/host-bucket.mjs +1 -1
  318. package/dist/storage/index-build.d.mts +2 -2
  319. package/dist/storage/index-build.mjs +3 -3
  320. package/dist/storage/index-fetch.mjs +10 -6
  321. package/dist/storage/index-graph.mjs +1 -1
  322. package/dist/storage/index-layers.mjs +1 -1
  323. package/dist/storage/index-visible.mjs +1 -1
  324. package/dist/storage/memory-budget.mjs +7 -1
  325. package/dist/storage/merge-cut.mjs +24 -1
  326. package/dist/storage/merge-fence.mjs +1 -1
  327. package/dist/storage/merge-plan.mjs +5 -2
  328. package/dist/storage/merge-row.mjs +1 -1
  329. package/dist/storage/merge-stream.mjs +16 -7
  330. package/dist/storage/merge-write.mjs +1 -1
  331. package/dist/storage/merge.d.mts +2 -2
  332. package/dist/storage/merge.mjs +1 -1
  333. package/dist/storage/object-rows.d.mts +2 -2
  334. package/dist/storage/object-rows.mjs +3 -3
  335. package/dist/storage/pack-ranges.d.mts +3 -1
  336. package/dist/storage/pack-ranges.mjs +168 -69
  337. package/dist/storage/pack-reads.mjs +4 -4
  338. package/dist/storage/pack-receive.d.mts +1 -1
  339. package/dist/storage/pack-receive.mjs +7 -9
  340. package/dist/storage/packs.d.mts +1 -1
  341. package/dist/storage/packs.mjs +45 -52
  342. package/dist/storage/placed-reads.mjs +81 -15
  343. package/dist/storage/prune-seen.mjs +126 -0
  344. package/dist/storage/prune-walk.mjs +87 -99
  345. package/dist/storage/prune.mjs +49 -14
  346. package/dist/storage/push-uploads.mjs +4 -2
  347. package/dist/storage/quarantine.d.mts +2 -2
  348. package/dist/storage/ready.d.mts +2 -2
  349. package/dist/storage/ready.mjs +3 -3
  350. package/dist/storage/receive-files.mjs +1 -1
  351. package/dist/storage/receive-links.mjs +1 -1
  352. package/dist/storage/receive-state.d.mts +2 -2
  353. package/dist/storage/receive-state.mjs +1 -1
  354. package/dist/storage/receive-steps.mjs +1 -1
  355. package/dist/storage/repack-contained.mjs +2 -2
  356. package/dist/storage/repack-job.d.mts +2 -2
  357. package/dist/storage/repack-job.mjs +5 -4
  358. package/dist/storage/repack.d.mts +1 -1
  359. package/dist/storage/repack.mjs +9 -3
  360. package/dist/storage/rows.d.mts +2 -2
  361. package/dist/storage/rows.mjs +1 -1
  362. package/dist/storage/runs.d.mts +2 -2
  363. package/dist/storage/runs.mjs +15 -6
  364. package/dist/storage/send-list.mjs +6 -6
  365. package/dist/storage/single-flight.mjs +2 -2
  366. package/dist/storage/swap-walk.mjs +1 -1
  367. package/dist/storage/unpack.mjs +1 -1
  368. package/dist/store/call-count.d.mts +1 -1
  369. package/dist/store/call-count.mjs +125 -34
  370. package/dist/store/catalogue.d.mts +1 -1
  371. package/dist/store/catalogue.mjs +2 -2
  372. package/dist/store/crossing.mjs +2 -6
  373. package/dist/store/cursor-seal.mjs +1 -1
  374. package/dist/store/errors.d.mts +7 -3
  375. package/dist/store/errors.mjs +41 -13
  376. package/dist/store/job-try.mjs +119 -15
  377. package/dist/store/list-job.mjs +5 -5
  378. package/dist/store/outbox.d.mts +2 -2
  379. package/dist/store/outbox.mjs +75 -16
  380. package/dist/store/promises.d.mts +2 -2
  381. package/dist/store/promises.mjs +31 -6
  382. package/dist/store/queue-jobs.mjs +1 -1
  383. package/dist/store/records.d.mts +2 -2
  384. package/dist/store/records.mjs +16 -24
  385. package/dist/store/ref-rows.d.mts +2 -2
  386. package/dist/store/ref-rows.mjs +6 -6
  387. package/dist/store/reservations.mjs +35 -8
  388. package/dist/store/scopes.mjs +6 -4
  389. package/dist/store/topic-jobs.mjs +8 -8
  390. package/dist/sync/bound.d.mts +1 -3
  391. package/dist/sync/bound.mjs +30 -42
  392. package/dist/sync/bridge.d.mts +6 -0
  393. package/dist/sync/bridge.mjs +29 -0
  394. package/dist/sync/github.d.mts +5 -6
  395. package/dist/sync/github.mjs +37 -42
  396. package/dist/sync/http.mjs +15 -0
  397. package/dist/sync/import.mjs +17 -18
  398. package/dist/sync/layer.d.mts +9 -0
  399. package/dist/sync/layer.mjs +68 -0
  400. package/dist/sync/mirror.mjs +137 -58
  401. package/dist/sync/publish.mjs +3 -6
  402. package/dist/sync/step.mjs +217 -79
  403. package/dist/sync/tries.mjs +22 -15
  404. package/dist/sync.d.mts +3 -6
  405. package/dist/sync.mjs +3 -6
  406. package/dist/topics/advance.mjs +205 -90
  407. package/dist/topics/calls.mjs +8 -8
  408. package/dist/topics/directory.mjs +35 -12
  409. package/dist/topics/host.d.mts +5 -8
  410. package/dist/topics/host.mjs +42 -19
  411. package/dist/topics/layer.d.mts +381 -0
  412. package/dist/topics/layer.mjs +62 -0
  413. package/dist/topics/members.mjs +1 -1
  414. package/dist/topics/namespace.d.mts +2 -0
  415. package/dist/topics/public.d.mts +6 -0
  416. package/dist/topics/public.mjs +13 -0
  417. package/dist/topics/rows.mjs +12 -3
  418. package/dist/topics/topic.mjs +11 -10
  419. package/package.json +8 -13
  420. package/dist/access.d.mts +0 -2
  421. package/dist/access.mjs +0 -1
  422. package/dist/core/hooks/post-receive.mjs +0 -216
  423. package/dist/core/hooks/pre-receive.d.mts +0 -12
  424. package/dist/core/hooks/pre-receive.mjs +0 -36
  425. package/dist/server/extension.d.mts +0 -21
  426. package/dist/sync/import.d.mts +0 -10
  427. package/dist/sync/jobs.d.mts +0 -9
  428. package/dist/sync/jobs.mjs +0 -75
  429. package/dist/sync/mirror.d.mts +0 -13
  430. package/dist/sync/publish.d.mts +0 -6
  431. /package/dist/core/{claim-rows.d.mts → registered-rows.d.mts} +0 -0
@@ -1,12 +1,65 @@
1
1
  import { gitError } from "../contracts/result.mjs";
2
2
  import { hexOf } from "../protocol/bytes/hex.mjs";
3
+ import "../protocol/packs/idx.mjs";
3
4
  import { stepEffect } from "../protocol/packs/step.mjs";
4
5
  import { basesBlock, openBases } from "./index-files.mjs";
5
6
  import { indexFiles } from "./layout.mjs";
6
7
  import { indexBytes, loadedLookup, rangedLookup } from "./pack-reads.mjs";
7
- import { openReverseRanges, placedEntries, placedEntriesBytes, placedEntriesGets, searchReads } from "./pack-ranges.mjs";
8
+ import { openPlacedTables, placedEntries, placedEntriesBytes, placedEntriesGets, rangeRanks, searchReads } from "./pack-ranges.mjs";
8
9
  import { basesReadBytes, basesRuns } from "./send-list.mjs";
9
10
  import * as Effect from "effect/Effect";
11
+ // src/storage/placed-reads.ts
12
+ /**
13
+ * #1722: the trees and commits a fetch's walk holds positions for, read whole at their place in
14
+ * their pack rather than by ID, so a near have's walk loads no covered pack's `.idx` and `.rev`
15
+ * whole. Each pack of a read is read one of three ways:
16
+ *
17
+ * - **Loaded:** the reader holds its `.idx` and `.rev` already, so each place's offset is read
18
+ * from them, with no get.
19
+ * - **By place:** each `REF_DELTA`'s chain of bases found by position in its layer's `.bases`,
20
+ * then every place's ID and offset read by range, as `placedEntries` reads them, and each object
21
+ * resolved from its offset, its bases found among those IDs.
22
+ * - **Whole:** past `placedReadGetsMost(pack, levels)` gets spent by place on that pack or
23
+ * `placedReadGetsCap` across the fetch, or where its `.idx` and `.rev` hold no more than reading
24
+ * by place would, they're loaded, as a read by ID loads them, and read as a loaded pack is. So a
25
+ * walk spends at most that bound's gets more than a read by ID would.
26
+ *
27
+ * A position past every pack is a region row, read through `outside`.
28
+ */
29
+ /**
30
+ * One-time bucket gets opening a pack's `.rev` header (1) and its layer's `.bases` header and
31
+ * tail (2) cost on the first placed read.
32
+ */
33
+ const placedReadOpenGets = 3;
34
+ /**
35
+ * The fewest bucket gets one pack's placed reads are allowed once walked: matches the former
36
+ * fixed budget so no small pack with a delta chain crossing several `.bases` blocks is worse off
37
+ * than on `main` (#522).
38
+ */
39
+ const placedReadGetsFloor = 64;
40
+ /**
41
+ * Sizing heuristic for one walk level of `pack` read by place (not a strict upper bound: a single
42
+ * delta chain can cross more than `2` `.bases` blocks within one level, which `placedReadGetsFloor`
43
+ * covers for small packs): its most spans of ranks, one for every other `rangeRanks` (32,768)
44
+ * window, as `placedEntries` reads them, each span's `.idx` tables (`3` under 2 GiB, `4` past it)
45
+ * and a `.rev` span, and `2` `.bases` runs for a level straddling a 4,096-position block boundary.
46
+ *
47
+ * - 48k pack (2 windows, 1 span): `6` (+ 3 open = `9` -> floored to `64` at depth 1 and depth 3).
48
+ * - 83k pack (3 windows, 2 spans, 3-pack 250k `deep7`): `10` (+ 3 open = `13` -> `64` at depth 1, `93` at depth 9).
49
+ * - 168.5k pack (6 windows, 3 spans, 1-pack `clone-svelte`): `14` (+ 3 open = `17` -> `64` at depth 1, `115` at depth 8).
50
+ * - 250k pack (8 windows, 4 spans, 1-pack `flat50`): `18` (+ 3 open = `21` -> `64` at depth 1 and depth 3).
51
+ * - 1M pack (31 windows, 16 spans): `66` under 2 GiB / `82` past 2 GiB (+ 3 open = `69` / `85` at depth 1).
52
+ */
53
+ const placedReadLevelGets = (pack) => {
54
+ return Math.ceil(Math.ceil(pack.count / rangeRanks) / 2) * ((pack.pack.bytes > 2147483647 ? 4 : 3) + 1) + 2;
55
+ };
56
+ /**
57
+ * The most bucket gets reading `pack` by place may spend over `levels` walk levels (1 for commits,
58
+ * 2 for commits + root trees, ...): a sizing heuristic floored at `placedReadGetsFloor` (64) so no
59
+ * small pack is worse off than before and capped at `placedReadGetsCap` (512) so a wide or very
60
+ * deep walk loads whole instead of outspending a Worker's bucket call limit (#522).
61
+ */
62
+ const placedReadGetsMost = (pack, levels) => levels <= 0 ? 0 : Math.min(512, Math.max(placedReadGetsFloor, placedReadOpenGets + levels * placedReadLevelGets(pack)));
10
63
  /** The gets reading `places` of `pack` by place makes: its `.rev`'s header unless it's `open`. */
11
64
  const placedReadGets = (pack, places, open) => (open ? 0 : 1) + placedEntriesGets(pack.count, pack.pack.bytes, places);
12
65
  const loss = (message) => gitError("DATA_LOSS", message);
@@ -30,12 +83,20 @@ const baseIn = (rows, position) => {
30
83
  const placedReads = (input) => {
31
84
  const { ranges, layers, listed, bucket, read, ahead } = input;
32
85
  const listedOf = new Map(listed.packs.map((pack) => [pack.id, pack]));
33
- const reverses = /* @__PURE__ */ new Map();
86
+ const opens = /* @__PURE__ */ new Map();
34
87
  const opened = /* @__PURE__ */ new Map();
35
88
  let spent = 0;
36
- const fits = (gets) => spent + gets <= 64;
37
- const spend = (gets) => {
89
+ let level = 0;
90
+ const packSpent = /* @__PURE__ */ new Map();
91
+ const packLevels = /* @__PURE__ */ new Map();
92
+ const packLastLevel = /* @__PURE__ */ new Map();
93
+ const fits = (pack, gets) => {
94
+ const limit = placedReadGetsMost(pack, packLevels.get(pack.pack.id) ?? 0);
95
+ return spent + gets <= 512 && (packSpent.get(pack.pack.id) ?? 0) + gets <= limit;
96
+ };
97
+ const spend = (pack, gets) => {
38
98
  spent += gets;
99
+ packSpent.set(pack.pack.id, (packSpent.get(pack.pack.id) ?? 0) + gets);
39
100
  return ahead({
40
101
  bucket: gets,
41
102
  store: 0
@@ -86,8 +147,8 @@ const placedReads = (input) => {
86
147
  const runs = basesRuns((block) => blocks.has(block) && !rows.has(block), layer.first, end);
87
148
  const open = opened.get(layer);
88
149
  const gets = runs.length + (open === void 0 ? 2 : 0);
89
- if (!fits(gets + placedReadGets(pack, placesOf(pack, all), reverses.has(pack.pack.id)))) return yield* Effect.as(read.release(held), void 0);
90
- yield* spend(gets);
150
+ if (!fits(pack, gets + placedReadGets(pack, placesOf(pack, all), opens.has(pack.pack.id)))) return yield* Effect.as(read.release(held), void 0);
151
+ yield* spend(pack, gets);
91
152
  const bases = open ?? (yield* openBases(bucket, indexFiles(listed.repo, layer.build).bases, end));
92
153
  opened.set(layer, bases);
93
154
  for (const run of runs) {
@@ -126,20 +187,20 @@ const placedReads = (input) => {
126
187
  const all = yield* chainsOf(pack, asked);
127
188
  if (all === void 0 || whole(all.size)) return void 0;
128
189
  const places = placesOf(pack, all);
129
- const known = reverses.get(pack.pack.id);
190
+ const known = opens.get(pack.pack.id);
130
191
  const gets = placedReadGets(pack, places, known !== void 0);
131
- if (!fits(gets)) return void 0;
132
- yield* spend(gets);
133
- const reverse = known ?? (yield* openReverseRanges(bucket, pack.pack, pack.count));
134
- reverses.set(pack.pack.id, reverse);
192
+ if (!fits(pack, gets)) return void 0;
193
+ yield* spend(pack, gets);
194
+ const tables = known ?? (yield* openPlacedTables(bucket, pack.pack, pack.count));
195
+ opens.set(pack.pack.id, tables);
135
196
  yield* read.hold(placedEntriesBytes(places.length) + places.length * 64);
136
- const entries = yield* placedEntries(pack, reverse, places);
197
+ const entries = yield* placedEntries(tables, places);
137
198
  const found = /* @__PURE__ */ new Map();
138
199
  for (let slot = 0; slot < places.length; slot += 1) found.set(hexOf(entries.ids.subarray(slot * 20, slot * 20 + 20)), entries.offsets[slot] ?? 0);
139
200
  yield* read.release(placedEntriesBytes(places.length));
140
201
  const search = rangedLookup(pack);
141
202
  const searched = Effect.fnUntraced(function* (oid) {
142
- yield* spend(searchReads(pack.count) + 1);
203
+ yield* spend(pack, searchReads(pack.count) + 1);
143
204
  return yield* stepEffect(search.find(oid));
144
205
  });
145
206
  const lookup = {
@@ -160,7 +221,8 @@ const placedReads = (input) => {
160
221
  kept: places.length * 64
161
222
  };
162
223
  });
163
- return { read: Effect.fnUntraced(function* (asked) {
224
+ return { read: Effect.fnUntraced(function* (asked, newLevel = true) {
225
+ if (newLevel || level === 0) level += 1;
164
226
  const byPack = /* @__PURE__ */ new Map();
165
227
  const beside = [];
166
228
  for (const ask of asked) {
@@ -178,6 +240,10 @@ const placedReads = (input) => {
178
240
  for (const [pack, group] of byPack) {
179
241
  const listedPack = listedOf.get(pack.pack.id);
180
242
  if (listedPack === void 0) return yield* Effect.fail(loss(`Pack ${pack.pack.id} isn't listed`));
243
+ if (packLastLevel.get(pack.pack.id) !== level) {
244
+ packLastLevel.set(pack.pack.id, level);
245
+ packLevels.set(pack.pack.id, (packLevels.get(pack.pack.id) ?? 0) + 1);
246
+ }
181
247
  const loaded = read.loadedOf?.(listedPack);
182
248
  const placed = loaded === void 0 ? yield* placedAt(pack, listedPack, group) : void 0;
183
249
  kept += placed?.kept ?? 0;
@@ -202,4 +268,4 @@ const placedReads = (input) => {
202
268
  };
203
269
  /** The places of `positions` in `pack`, ascending. */
204
270
  const placesOf = (pack, positions) => Uint32Array.from(positions, (position) => position - pack.base).sort();
205
- export { placedReadGets, placedReads };
271
+ export { placedReadGets, placedReadGetsMost, placedReads };
@@ -0,0 +1,126 @@
1
+ import { gitError } from "../contracts/result.mjs";
2
+ import { hexOf } from "../protocol/bytes/hex.mjs";
3
+ import { oidBytes } from "../protocol/packs/idx.mjs";
4
+ import * as Effect from "effect/Effect";
5
+ import * as Schema from "effect/Schema";
6
+ // src/storage/prune-seen.ts
7
+ /**
8
+ * #2019: the history objects a prune walk has seen, in place of a table of their IDs: a bit for
9
+ * each object of each listed pack, at its rank in the first pack that lists it, and for an object
10
+ * no listed pack holds, a row's or one listed since, its ID in a set of at most `outsideMost`. Its
11
+ * bytes grow with the repo's objects at an eighth of a byte each, never with what the walk reaches,
12
+ * and a part's save puts them whole, so the next try reads one object, not every ID reached.
13
+ *
14
+ * Its bits are kept by each pack's ID, not by where the listing names it, since a later try may
15
+ * list other packs: one a repack listed since reads back as nothing seen, and one it let go of
16
+ * takes its bits with it. What those packs held is seen again, so the walk reads it again, and
17
+ * the tree levels' merge drops the rows it reaches twice: work, never an object missed.
18
+ */
19
+ /** A listed pack a seen set holds bits for: its ID and its objects, one bit each. */
20
+ const SeenPack = /* @__PURE__ */ Schema.Struct({
21
+ id: Schema.String,
22
+ objects: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))
23
+ });
24
+ /**
25
+ * A seen set as a save names it: its object's key, and the layout of its bytes, each pack's bits
26
+ * in turn, then `outside` IDs of 20 bytes.
27
+ */
28
+ const SeenSaved = /* @__PURE__ */ Schema.Struct({
29
+ key: Schema.String,
30
+ packs: Schema.Array(SeenPack),
31
+ outside: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))
32
+ });
33
+ /** The bytes of `packs`' bits and `outside` IDs, as a save puts them. */
34
+ const seenLength = (packs, outside) => packs.reduce((sum, pack) => sum + Math.ceil(pack.objects / 8), 0) + outside * 20;
35
+ /**
36
+ * A seen set over `packs`, at most `outsideMost` objects outside them, empty or from `from`, a
37
+ * save's bytes and layout: the bits of each pack the save and `packs` both hold, by its ID, and
38
+ * each outside ID. A pack the save doesn't hold starts with none seen, and one it holds that
39
+ * `packs` doesn't is let go: what it held is seen again where the walk finds it now. An ID outside
40
+ * the save's listing that `packs` now hold, as a fold of the rows lists them, is `from.place`'s
41
+ * bit, so only those still outside count. Bytes that aren't the layout's, or more outside IDs
42
+ * than `outsideMost` once placed, are `DATA_LOSS`.
43
+ */
44
+ const seenSet = /* @__PURE__ */ Effect.fnUntraced(function* (packs, outsideMost, from) {
45
+ const bits = new Map(packs.map((pack) => [pack.id, new Uint8Array(Math.ceil(pack.objects / 8))]));
46
+ const outside = /* @__PURE__ */ new Set();
47
+ let count = 0;
48
+ /**
49
+ * Whether `oid`, at `at` or outside the listed packs, is seen for the first time, and marks it:
50
+ * `'full'` when it's outside and the set holds `outsideMost` such already.
51
+ */
52
+ const add = (oid, at) => {
53
+ const set = at === void 0 ? void 0 : bits.get(at.pack);
54
+ if (set !== void 0 && at !== void 0) {
55
+ const byte = at.rank >>> 3;
56
+ const bit = 1 << (at.rank & 7);
57
+ if (((set[byte] ?? 0) & bit) !== 0) return false;
58
+ set[byte] = (set[byte] ?? 0) | bit;
59
+ count += 1;
60
+ return true;
61
+ }
62
+ if (outside.has(oid)) return false;
63
+ if (outside.size >= outsideMost) return "full";
64
+ outside.add(oid);
65
+ count += 1;
66
+ return true;
67
+ };
68
+ if (from !== void 0) {
69
+ const { saved, bytes, place } = from;
70
+ const length = seenLength(saved.packs, saved.outside);
71
+ if (bytes.byteLength !== length) return yield* Effect.fail(gitError("DATA_LOSS", `A walk's seen object holds ${bytes.byteLength} bytes; its save says ${length}`));
72
+ let at = 0;
73
+ for (const pack of saved.packs) {
74
+ const length = Math.ceil(pack.objects / 8);
75
+ const into = bits.get(pack.id);
76
+ const held = bytes.subarray(at, at + length);
77
+ at += length;
78
+ if (into?.byteLength !== length) continue;
79
+ into.set(held);
80
+ for (const byte of held) count += popCount(byte);
81
+ }
82
+ for (let first = 0; first < saved.outside; first += 64) {
83
+ const batch = [];
84
+ for (let id = first; id < Math.min(saved.outside, first + 64); id += 1) batch.push(hexOf(bytes.subarray(at + id * 20, at + id * 20 + 20)));
85
+ const placed = yield* place(batch);
86
+ for (const oid of batch) if (add(oid, placed.get(oid)) === "full") return yield* Effect.fail(gitError("DATA_LOSS", `A walk's save holds more than ${outsideMost} objects no listed pack holds`));
87
+ }
88
+ }
89
+ /** The set's bytes, and the layout a save names them by under `key`. */
90
+ const saved = (key) => {
91
+ const layout = {
92
+ key,
93
+ packs: packs.map(({ id, objects }) => ({
94
+ id,
95
+ objects
96
+ })),
97
+ outside: outside.size
98
+ };
99
+ const bytes = new Uint8Array(seenLength(layout.packs, layout.outside));
100
+ let at = 0;
101
+ for (const pack of packs) {
102
+ const set = bits.get(pack.id);
103
+ if (set !== void 0) bytes.set(set, at);
104
+ at += Math.ceil(pack.objects / 8);
105
+ }
106
+ for (const oid of [...outside].sort()) {
107
+ bytes.set(oidBytes(oid), at);
108
+ at += 20;
109
+ }
110
+ return {
111
+ layout,
112
+ bytes
113
+ };
114
+ };
115
+ return {
116
+ add,
117
+ saved,
118
+ size: () => count
119
+ };
120
+ });
121
+ const popCount = (byte) => {
122
+ let bits = 0;
123
+ for (let rest = byte; rest !== 0; rest &= rest - 1) bits += 1;
124
+ return bits;
125
+ };
126
+ export { SeenSaved, seenLength, seenSet };
@@ -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 };