@ref0/git 0.12.0 → 0.20.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 (436) hide show
  1. package/dist/access/private-refs.mjs +3 -3
  2. package/dist/auth/access-jwt.mjs +2 -2
  3. package/dist/auth/auth.d.mts +2 -2
  4. package/dist/auth/auth.mjs +3 -6
  5. package/dist/auth/authorize.mjs +4 -20
  6. package/dist/auth/fences.d.mts +1 -2
  7. package/dist/auth/fences.mjs +3 -3
  8. package/dist/auth/grants.mjs +4 -4
  9. package/dist/auth/helpers.mjs +3 -11
  10. package/dist/auth/host-function.mjs +18 -1
  11. package/dist/auth/host-services.mjs +11 -0
  12. package/dist/auth/identify.d.mts +1 -1
  13. package/dist/auth/identify.mjs +3 -3
  14. package/dist/auth/policy.d.mts +27 -7
  15. package/dist/auth/policy.mjs +8 -4
  16. package/dist/auth/token-cleanup.mjs +67 -0
  17. package/dist/auth/token-rows.mjs +1 -1
  18. package/dist/auth/token-text.mjs +9 -1
  19. package/dist/auth/tokens-base.d.mts +35 -0
  20. package/dist/auth/tokens-base.mjs +13 -0
  21. package/dist/auth/tokens-layer.d.mts +2 -28
  22. package/dist/auth/tokens-layer.mjs +6 -12
  23. package/dist/auth/tokens-public.d.mts +3 -3
  24. package/dist/auth/tokens.d.mts +7 -17
  25. package/dist/auth/tokens.mjs +9 -87
  26. package/dist/auth.d.mts +1 -4
  27. package/dist/auth.mjs +1 -3
  28. package/dist/client/answer.mjs +21 -42
  29. package/dist/client/client.d.mts +2 -4
  30. package/dist/client/git-http.mjs +35 -11
  31. package/dist/client/local.mjs +14 -13
  32. package/dist/client/push-upload.mjs +39 -12
  33. package/dist/client/remote.mjs +95 -31
  34. package/dist/client/run-remote-helper.d.mts +1 -0
  35. package/dist/client/run-remote-helper.mjs +58 -24
  36. package/dist/client/slice-push.d.mts +1 -1
  37. package/dist/client/transport.mjs +105 -46
  38. package/dist/contracts/access.d.mts +8 -8
  39. package/dist/contracts/actors.d.mts +2 -34
  40. package/dist/contracts/blobs.d.mts +57 -10
  41. package/dist/contracts/blobs.mjs +16 -2
  42. package/dist/contracts/call-allowance.d.mts +13 -0
  43. package/dist/contracts/call-allowance.mjs +44 -0
  44. package/dist/contracts/calls-spent.mjs +8 -3
  45. package/dist/contracts/client.d.mts +23 -19
  46. package/dist/contracts/commits.d.mts +34 -26
  47. package/dist/contracts/commits.mjs +9 -1
  48. package/dist/contracts/engine.d.mts +6 -1
  49. package/dist/contracts/engine.mjs +10 -1
  50. package/dist/contracts/files.d.mts +12 -12
  51. package/dist/contracts/forks.d.mts +27 -17
  52. package/dist/contracts/git-events.d.mts +29 -1
  53. package/dist/contracts/git-hooks.d.mts +1 -1
  54. package/dist/contracts/git.d.mts +39 -7
  55. package/dist/contracts/git.mjs +3 -2
  56. package/dist/contracts/grants.d.mts +24 -4
  57. package/dist/contracts/handlers.d.mts +1 -1
  58. package/dist/contracts/lfs.d.mts +28 -9
  59. package/dist/contracts/merges.d.mts +3 -2
  60. package/dist/contracts/objects.d.mts +103 -35
  61. package/dist/contracts/operations.d.mts +3 -0
  62. package/dist/contracts/operations.mjs +12 -2
  63. package/dist/contracts/push-uploads.d.mts +44 -5
  64. package/dist/contracts/push-uploads.mjs +7 -3
  65. package/dist/contracts/queue.d.mts +40 -12
  66. package/dist/contracts/queue.mjs +3 -4
  67. package/dist/contracts/refs.d.mts +50 -25
  68. package/dist/contracts/remote.d.mts +6 -7
  69. package/dist/contracts/remote.mjs +5 -4
  70. package/dist/contracts/repo-records.d.mts +1 -0
  71. package/dist/contracts/repos.d.mts +106 -127
  72. package/dist/contracts/repos.mjs +33 -4
  73. package/dist/contracts/result.d.mts +49 -25
  74. package/dist/contracts/result.mjs +52 -11
  75. package/dist/contracts/rules.d.mts +22 -22
  76. package/dist/contracts/server.d.mts +37 -111
  77. package/dist/contracts/services.d.mts +1 -1
  78. package/dist/contracts/signin.d.mts +1 -1
  79. package/dist/contracts/store.d.mts +6 -5
  80. package/dist/contracts/sync.d.mts +90 -26
  81. package/dist/contracts/sync.mjs +45 -11
  82. package/dist/contracts/tags.d.mts +10 -10
  83. package/dist/contracts/time.d.mts +3 -0
  84. package/dist/contracts/{promises.mjs → time.mjs} +1 -1
  85. package/dist/contracts/tokens.d.mts +15 -22
  86. package/dist/contracts/tokens.mjs +3 -3
  87. package/dist/contracts/topics.d.mts +1 -6
  88. package/dist/contracts/trees.d.mts +12 -12
  89. package/dist/contracts/work.d.mts +87 -12
  90. package/dist/contracts/work.mjs +8 -1
  91. package/dist/core/access.d.mts +1 -2
  92. package/dist/core/access.mjs +46 -13
  93. package/dist/core/ancestry.d.mts +10 -0
  94. package/dist/core/ancestry.mjs +6 -6
  95. package/dist/core/asked.mjs +43 -5
  96. package/dist/core/call-names.mjs +7 -1
  97. package/dist/core/call-services.mjs +13 -4
  98. package/dist/core/events/deliver.d.mts +1 -2
  99. package/dist/core/events/deliver.mjs +48 -33
  100. package/dist/core/events/retired.mjs +119 -0
  101. package/dist/core/forks.mjs +931 -435
  102. package/dist/core/hooks/groups.mjs +1 -1
  103. package/dist/core/imports.mjs +159 -15
  104. package/dist/core/index-job.mjs +128 -37
  105. package/dist/core/index-lost.d.mts +1 -2
  106. package/dist/core/index-lost.mjs +2 -2
  107. package/dist/core/job-view.mjs +8 -9
  108. package/dist/core/loose-tally.mjs +1 -1
  109. package/dist/core/mirror-rows.mjs +19 -4
  110. package/dist/core/objects/blobs.mjs +129 -3
  111. package/dist/core/objects/commits.mjs +16 -6
  112. package/dist/core/objects/lines.mjs +2 -2
  113. package/dist/core/objects/merges.mjs +4 -1
  114. package/dist/core/objects/objects-layer.d.mts +1 -1
  115. package/dist/core/objects/objects-layer.mjs +3 -3
  116. package/dist/core/objects/reading.mjs +24 -13
  117. package/dist/core/objects/tags.mjs +4 -1
  118. package/dist/core/objects/trees.mjs +2 -2
  119. package/dist/core/objects/writing.mjs +2 -2
  120. package/dist/core/own-writes.mjs +1 -1
  121. package/dist/core/parts.d.mts +10 -6
  122. package/dist/core/parts.mjs +3 -11
  123. package/dist/core/promise.mjs +9 -12
  124. package/dist/core/purge.mjs +316 -42
  125. package/dist/core/push-decide.mjs +3 -1
  126. package/dist/core/push-files.d.mts +12 -0
  127. package/dist/core/push-files.mjs +225 -0
  128. package/dist/core/push-repo.d.mts +8 -0
  129. package/dist/core/push-repo.mjs +56 -0
  130. package/dist/core/push.d.mts +17 -0
  131. package/dist/core/push.mjs +153 -70
  132. package/dist/core/receipts.mjs +34 -13
  133. package/dist/core/ref-index-job.mjs +4 -4
  134. package/dist/core/ref-view.mjs +61 -7
  135. package/dist/core/refs.mjs +18 -13
  136. package/dist/core/registered-rows.mjs +2 -2
  137. package/dist/core/repack.mjs +46 -28
  138. package/dist/core/repo-info.mjs +19 -12
  139. package/dist/core/repos.mjs +50 -22
  140. package/dist/core/rules/commit-changes.d.mts +0 -1
  141. package/dist/core/saved-caller-views.d.mts +7 -2
  142. package/dist/core/saved-caller-views.mjs +2 -2
  143. package/dist/core/saved-callers.d.mts +19 -2
  144. package/dist/core/seam.d.mts +16 -26
  145. package/dist/core/seam.mjs +7 -28
  146. package/dist/core/tokens.mjs +1 -1
  147. package/dist/core/view.d.mts +6 -0
  148. package/dist/core/view.mjs +51 -26
  149. package/dist/core/work.mjs +105 -35
  150. package/dist/effect.d.mts +5 -12
  151. package/dist/effect.mjs +3 -10
  152. package/dist/engine/failures.mjs +2 -1
  153. package/dist/engine/reads.mjs +17 -10
  154. package/dist/engine/walk.mjs +4 -4
  155. package/dist/event-streams/event-streams.d.mts +1 -1
  156. package/dist/event-streams/event-streams.mjs +1 -1
  157. package/dist/event-streams/stream.d.mts +3 -3
  158. package/dist/event-streams/stream.mjs +38 -15
  159. package/dist/extend.d.mts +4 -5
  160. package/dist/extend.mjs +3 -2
  161. package/dist/http/answers.mjs +12 -7
  162. package/dist/http/core-parts.mjs +129 -64
  163. package/dist/http/handler.mjs +36 -9
  164. package/dist/http/node.d.mts +14 -1
  165. package/dist/http/node.mjs +61 -31
  166. package/dist/http/parts.d.mts +2 -0
  167. package/dist/http/push-upload-job.mjs +507 -0
  168. package/dist/http/push-uploads.d.mts +1 -0
  169. package/dist/http/push-uploads.mjs +142 -69
  170. package/dist/http/upload-pack.mjs +10 -9
  171. package/dist/index.d.mts +27 -28
  172. package/dist/index.mjs +5 -8
  173. package/dist/lfs/answer.mjs +37 -0
  174. package/dist/lfs/base.d.mts +9 -3
  175. package/dist/lfs/base.mjs +27 -2
  176. package/dist/lfs/copy.d.mts +60 -0
  177. package/dist/lfs/copy.mjs +109 -0
  178. package/dist/lfs/layer.d.mts +15 -1
  179. package/dist/lfs/layer.mjs +28 -13
  180. package/dist/lfs/locks.mjs +2 -2
  181. package/dist/lfs/objects.d.mts +7 -0
  182. package/dist/lfs/objects.mjs +152 -55
  183. package/dist/lfs/pointers.mjs +2 -2
  184. package/dist/lfs/rows.d.mts +13 -0
  185. package/dist/lfs/rows.mjs +42 -8
  186. package/dist/lfs/service.d.mts +1 -7
  187. package/dist/lfs/service.mjs +1 -9
  188. package/dist/lfs/upkeep.mjs +48 -14
  189. package/dist/lfs/upload-most.mjs +5 -5
  190. package/dist/lfs/wire.mjs +6 -31
  191. package/dist/merges/merges.mjs +2 -2
  192. package/dist/node.d.mts +3 -3
  193. package/dist/protocol/bytes/buffers.mjs +13 -5
  194. package/dist/protocol/bytes/reader.mjs +6 -1
  195. package/dist/protocol/bytes/sha256-hasher.d.mts +15 -0
  196. package/dist/protocol/bytes/sha256.d.mts +32 -0
  197. package/dist/protocol/bytes/sha256.mjs +105 -49
  198. package/dist/protocol/bytes/streams.mjs +27 -1
  199. package/dist/protocol/diff/read.d.mts +4 -3
  200. package/dist/protocol/diff/read.mjs +8 -3
  201. package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
  202. package/dist/protocol/objects/lfs-pointer.mjs +1 -3
  203. package/dist/protocol/objects/links-raw.mjs +24 -10
  204. package/dist/protocol/objects/tag.d.mts +1 -1
  205. package/dist/protocol/objects/tree.mjs +23 -6
  206. package/dist/protocol/packs/delta.d.mts +6 -3
  207. package/dist/protocol/packs/delta.mjs +96 -32
  208. package/dist/protocol/packs/idx.d.mts +2 -1
  209. package/dist/protocol/packs/idx.mjs +22 -3
  210. package/dist/protocol/packs/parts.d.mts +4 -1
  211. package/dist/protocol/packs/parts.mjs +10 -7
  212. package/dist/protocol/packs/reader.d.mts +5 -0
  213. package/dist/protocol/packs/reader.mjs +3 -2
  214. package/dist/protocol/packs/writer.mjs +26 -8
  215. package/dist/protocol/wire/advertisement.mjs +9 -4
  216. package/dist/protocol/wire/lines.d.mts +4 -2
  217. package/dist/protocol/wire/lines.mjs +11 -5
  218. package/dist/protocol/wire/push-uploads.mjs +13 -1
  219. package/dist/protocol/wire/v2.mjs +2 -2
  220. package/dist/protocol.d.mts +3 -1
  221. package/dist/protocol.mjs +3 -1
  222. package/dist/queue/advance.mjs +22 -25
  223. package/dist/queue/base.d.mts +55 -0
  224. package/dist/queue/base.mjs +44 -0
  225. package/dist/queue/calls.mjs +51 -54
  226. package/dist/queue/commit.mjs +1 -1
  227. package/dist/queue/host.d.mts +2 -22
  228. package/dist/queue/host.mjs +2 -13
  229. package/dist/queue/layer.d.mts +2 -1
  230. package/dist/queue/layer.mjs +11 -4
  231. package/dist/queue/limits.mjs +2 -0
  232. package/dist/queue/push-option.mjs +9 -24
  233. package/dist/queue/schedule.mjs +1 -1
  234. package/dist/queue/state.mjs +2 -10
  235. package/dist/queue/trim.mjs +6 -4
  236. package/dist/rest/blobs.mjs +29 -5
  237. package/dist/rest/caller.d.mts +4 -4231
  238. package/dist/rest/caller.mjs +5 -1
  239. package/dist/rest/client.d.mts +15 -5
  240. package/dist/rest/client.mjs +23 -2
  241. package/dist/rest/events.mjs +1 -2
  242. package/dist/rest/handler.mjs +4 -57
  243. package/dist/rest/handlers.mjs +68 -9
  244. package/dist/rest/layer.d.mts +2 -2
  245. package/dist/rest/layer.mjs +7 -13
  246. package/dist/rest/me.d.mts +3 -428
  247. package/dist/rest/paths.mjs +1 -0
  248. package/dist/rest/work.mjs +8 -0
  249. package/dist/server/check-fetch.mjs +3 -3
  250. package/dist/server/edge-node.d.mts +14 -15
  251. package/dist/server/edge-node.mjs +12 -12
  252. package/dist/server/edge.d.mts +21 -7
  253. package/dist/server/edge.mjs +32 -11
  254. package/dist/server/extension.mjs +1 -1
  255. package/dist/server/git-layer.d.mts +6 -11
  256. package/dist/server/git-layer.mjs +29 -23
  257. package/dist/server/git-namespace.d.mts +5 -4
  258. package/dist/server/git-namespace.mjs +3 -2
  259. package/dist/server/joined.d.mts +21 -40
  260. package/dist/server/joined.mjs +11 -62
  261. package/dist/server/lifecycle.mjs +65 -69
  262. package/dist/server/registry.mjs +28 -3
  263. package/dist/server/server.mjs +245 -465
  264. package/dist/signin/context.d.mts +1 -2
  265. package/dist/signin/layer.d.mts +1 -1
  266. package/dist/signin/layer.mjs +1 -1
  267. package/dist/storage/allotted.mjs +18 -3
  268. package/dist/storage/batch-upkeep.mjs +274 -0
  269. package/dist/{core/purge.d.mts → storage/batches.d.mts} +4 -4
  270. package/dist/storage/batches.mjs +344 -0
  271. package/dist/storage/budget.mjs +2 -2
  272. package/dist/storage/calls.d.mts +1 -2
  273. package/dist/storage/calls.mjs +144 -158
  274. package/dist/storage/chunks.d.mts +9 -0
  275. package/dist/storage/chunks.mjs +297 -0
  276. package/dist/storage/clean-up.mjs +85 -19
  277. package/dist/storage/counted-bucket.mjs +4 -4
  278. package/dist/storage/fetch.d.mts +1 -0
  279. package/dist/storage/fetch.mjs +298 -216
  280. package/dist/storage/file-limits.mjs +24 -0
  281. package/dist/storage/host-bucket.mjs +1 -2
  282. package/dist/storage/id-mix.mjs +19 -5
  283. package/dist/storage/index-bitmaps.mjs +9 -2
  284. package/dist/storage/index-build.d.mts +1 -1
  285. package/dist/storage/index-build.mjs +185 -84
  286. package/dist/storage/index-fetch.mjs +128 -74
  287. package/dist/storage/index-files.d.mts +3 -0
  288. package/dist/storage/index-files.mjs +10 -5
  289. package/dist/storage/index-graph.mjs +72 -22
  290. package/dist/storage/index-reach.mjs +33 -5
  291. package/dist/storage/index-remap.mjs +208 -65
  292. package/dist/storage/index-shallow.mjs +5 -3
  293. package/dist/storage/index-whole.mjs +127 -0
  294. package/dist/storage/largest-files.mjs +48 -0
  295. package/dist/storage/layout.mjs +23 -0
  296. package/dist/storage/lfs-pointers.mjs +10 -1
  297. package/dist/storage/loose.d.mts +7 -4
  298. package/dist/storage/loose.mjs +214 -67
  299. package/dist/storage/memory-budget.mjs +44 -8
  300. package/dist/storage/merge-plan.mjs +3 -2
  301. package/dist/storage/merge-row.mjs +7 -1
  302. package/dist/storage/merge-stream.mjs +164 -25
  303. package/dist/storage/merge-walk.mjs +8 -4
  304. package/dist/storage/merge-write.mjs +1 -1
  305. package/dist/storage/merge.d.mts +1 -1
  306. package/dist/storage/merge.mjs +1 -1
  307. package/dist/storage/object-rows.d.mts +1 -0
  308. package/dist/storage/object-rows.mjs +385 -65
  309. package/dist/storage/oid-table.mjs +171 -0
  310. package/dist/storage/pack-order.mjs +8 -4
  311. package/dist/storage/pack-ranges.d.mts +1 -2
  312. package/dist/storage/pack-ranges.mjs +4 -5
  313. package/dist/storage/pack-reads.d.mts +2 -1
  314. package/dist/storage/pack-reads.mjs +165 -49
  315. package/dist/storage/pack-receive.d.mts +1 -1
  316. package/dist/storage/pack-receive.mjs +85 -27
  317. package/dist/storage/packs.d.mts +1 -1
  318. package/dist/storage/packs.mjs +172 -86
  319. package/dist/storage/placed-reads.mjs +1 -1
  320. package/dist/storage/plan-columns.d.mts +4 -0
  321. package/dist/storage/plan-columns.mjs +238 -0
  322. package/dist/storage/prune-keep.mjs +299 -37
  323. package/dist/storage/prune-walk.mjs +240 -62
  324. package/dist/storage/prune.mjs +749 -213
  325. package/dist/storage/push-allotment.mjs +91 -12
  326. package/dist/storage/push-uploads.mjs +40 -16
  327. package/dist/storage/pushed-commits.mjs +4 -2
  328. package/dist/storage/quarantine.d.mts +1 -1
  329. package/dist/storage/quarantine.mjs +9 -9
  330. package/dist/storage/range-cache.mjs +125 -8
  331. package/dist/storage/ready.d.mts +1 -1
  332. package/dist/storage/ready.mjs +55 -25
  333. package/dist/storage/receive-bounds.mjs +51 -15
  334. package/dist/storage/receive-state.mjs +8 -0
  335. package/dist/storage/receive-steps.mjs +71 -18
  336. package/dist/storage/repack-backlog.mjs +6 -3
  337. package/dist/storage/repack.d.mts +2 -2
  338. package/dist/storage/repack.mjs +1 -8
  339. package/dist/storage/rows.d.mts +1 -1
  340. package/dist/storage/rows.mjs +13 -2
  341. package/dist/storage/runs.mjs +195 -43
  342. package/dist/storage/send-list.d.mts +1 -0
  343. package/dist/storage/send-list.mjs +54 -10
  344. package/dist/storage/shallow.d.mts +1 -0
  345. package/dist/storage/shallow.mjs +26 -4
  346. package/dist/storage/single-flight.mjs +13 -7
  347. package/dist/storage/stream-whole.mjs +132 -28
  348. package/dist/storage/unpack.mjs +371 -79
  349. package/dist/storage/visible.mjs +31 -3
  350. package/dist/storage/walk.mjs +194 -39
  351. package/dist/storage/wants.mjs +5 -5
  352. package/dist/store/bodies.mjs +38 -0
  353. package/dist/store/call-count.d.mts +8 -12
  354. package/dist/store/call-count.mjs +34 -46
  355. package/dist/store/catalogue.d.mts +2 -2
  356. package/dist/store/catalogue.mjs +146 -35
  357. package/dist/store/crossing.mjs +1 -3
  358. package/dist/store/cursor-seal-namespace.d.mts +2 -0
  359. package/dist/store/cursor-seal-public.d.mts +5 -0
  360. package/dist/store/cursor-seal-public.mjs +5 -0
  361. package/dist/store/cursor-seal.d.mts +16 -3
  362. package/dist/store/cursor-seal.mjs +40 -18
  363. package/dist/store/door.mjs +183 -0
  364. package/dist/store/errors.d.mts +3 -4
  365. package/dist/store/errors.mjs +24 -34
  366. package/dist/store/git-store.mjs +25 -7
  367. package/dist/store/job-try.mjs +9 -32
  368. package/dist/store/list-job.mjs +44 -8
  369. package/dist/store/records.d.mts +5 -0
  370. package/dist/store/records.mjs +12 -6
  371. package/dist/store/repo-record.d.mts +10 -9
  372. package/dist/store/repo-record.mjs +123 -28
  373. package/dist/store/reservations.mjs +1 -1
  374. package/dist/store/scopes.mjs +21 -2
  375. package/dist/store/settle.mjs +4 -4
  376. package/dist/sync/bound.d.mts +2 -0
  377. package/dist/sync/bound.mjs +11 -2
  378. package/dist/sync/github.d.mts +6 -1
  379. package/dist/sync/github.mjs +56 -44
  380. package/dist/sync/http.mjs +36 -1
  381. package/dist/sync/import.mjs +32 -18
  382. package/dist/sync/layer.mjs +6 -2
  383. package/dist/sync/lfs-batch.mjs +118 -0
  384. package/dist/sync/lfs-copy.mjs +262 -0
  385. package/dist/sync/mirror.mjs +227 -151
  386. package/dist/sync/said.mjs +16 -37
  387. package/dist/sync/smart-http.mjs +4 -2
  388. package/dist/sync/step.mjs +58 -30
  389. package/dist/sync/tries.mjs +52 -21
  390. package/dist/sync.d.mts +2 -2
  391. package/dist/topics/advance.mjs +10 -11
  392. package/dist/topics/base.d.mts +15 -0
  393. package/dist/topics/base.mjs +8 -0
  394. package/dist/topics/host.mjs +2 -20
  395. package/dist/topics/layer.d.mts +4 -9
  396. package/dist/topics/layer.mjs +3 -4
  397. package/dist/topics/members.mjs +4 -4
  398. package/dist/topics/public.d.mts +2 -1
  399. package/dist/topics/topic.mjs +2 -2
  400. package/package.json +5 -9
  401. package/dist/auth/bridge.mjs +0 -30
  402. package/dist/auth/helpers.d.mts +0 -17
  403. package/dist/contracts/promises.d.mts +0 -39
  404. package/dist/core/call-names.d.mts +0 -3
  405. package/dist/core/clock.mjs +0 -18
  406. package/dist/core/registered-rows.d.mts +0 -5
  407. package/dist/core/repack.d.mts +0 -11
  408. package/dist/http/handler.d.mts +0 -2
  409. package/dist/lfs/calls.mjs +0 -26
  410. package/dist/rest/api.d.mts +0 -23
  411. package/dist/rest/blobs.d.mts +0 -825
  412. package/dist/rest/commits.d.mts +0 -3510
  413. package/dist/rest/errors.d.mts +0 -2104
  414. package/dist/rest/events.d.mts +0 -423
  415. package/dist/rest/files.d.mts +0 -1330
  416. package/dist/rest/forks.d.mts +0 -2136
  417. package/dist/rest/handler.d.mts +0 -21
  418. package/dist/rest/handlers.d.mts +0 -8
  419. package/dist/rest/merges.d.mts +0 -473
  420. package/dist/rest/queue.d.mts +0 -5861
  421. package/dist/rest/refs.d.mts +0 -2959
  422. package/dist/rest/repos.d.mts +0 -2539
  423. package/dist/rest/tags.d.mts +0 -1304
  424. package/dist/rest/tokens.d.mts +0 -2590
  425. package/dist/rest/topics.d.mts +0 -2204
  426. package/dist/rest/trees.d.mts +0 -1693
  427. package/dist/rest/work.d.mts +0 -1248
  428. package/dist/rest.d.mts +0 -2
  429. package/dist/rest.mjs +0 -1
  430. package/dist/server/lifecycle.d.mts +0 -2
  431. package/dist/server/registry.d.mts +0 -16
  432. package/dist/server/server.d.mts +0 -36
  433. package/dist/storage/repack-job.d.mts +0 -3
  434. package/dist/store/promises.d.mts +0 -11
  435. package/dist/store/promises.mjs +0 -327
  436. package/dist/topics/host.d.mts +0 -7
@@ -5,16 +5,16 @@ import { Sha1 } from "../protocol/bytes/sha1.mjs";
5
5
  import { writeCommitGraph } from "../protocol/packs/graph.mjs";
6
6
  import { IndexerCache } from "../protocol/packs/indexer.mjs";
7
7
  import { oidBytes } from "../protocol/packs/idx.mjs";
8
+ import { noRepoRoots } from "../protocol/objects/commit.mjs";
8
9
  import { rawLinks } from "../protocol/objects/links-raw.mjs";
9
- import { rootsOf } from "../store/repo-record.mjs";
10
- import { repoRootsKey, repoScope } from "../store/scopes.mjs";
10
+ import { rootsDigest } from "../store/repo-record.mjs";
11
11
  import { randomText } from "../store/random.mjs";
12
12
  import { allottableOf, uploadPartBytes } from "./budget.mjs";
13
- import { bucketDo, bucketPut, joined, readWhole, sizedPutCalls, streamedPutCalls } from "./calls.mjs";
13
+ import { bucketDo, bucketPut, joined, readEach, readWhole, sizedPutCalls, streamedPutCalls } from "./calls.mjs";
14
14
  import { BitmapsPart, EdgeFiles, bitmapOrder, bitmapsMostBytes, bitmapsPut, copyBitmaps, copyHeldBytes, copyRunBytes, edgesBytesOf, edgesFileOf, ewahMostWords, noNumber, orderKey, partBitmaps, partBytesMost, runsMost, storedBitmaps, storedSize, writeBitmaps } from "./index-bitmaps.mjs";
15
15
  import { BasesWriter, TypesWriter, indexBasesBytes, indexTypesBytes, openBases, openTypes, typeCodes } from "./index-files.mjs";
16
16
  import { bitmapOf, bitmapWords, ewahOf, orEwah } from "./ewah.mjs";
17
- import { graphChunk, indexGraphBytes, mergeHeldBytes, mergeIndexGraphs, openGraphLayers, openIndexGraph, writeIndexGraph } from "./index-graph.mjs";
17
+ import { absent, graphChunk, indexGraphBytes, keptIdsBytes, keptIdsOf, mergeHeldBytes, mergeIndexGraphs, openGraphLayers, openIndexGraph, writeIndexGraph } from "./index-graph.mjs";
18
18
  import { hasBit, idsOf, lookupCalls, openLayerBitmaps, openLayout, orIntoBytes, reachOf } from "./index-layers.mjs";
19
19
  import { indexFiles, indexPrefix, indexRowKey, isPackId, packFiles } from "./layout.mjs";
20
20
  import { listedIds } from "./listed-ids.mjs";
@@ -25,14 +25,13 @@ import { eachPageAt, objectOfRow } from "./object-rows.mjs";
25
25
  import { SliceLinks, SliceRefused, cutAtSpent, isSliceRefused, linksPastMemory, nothingSettled, readSlice, slicePackOf, sliceRefusal, spentOf } from "./pack-order.mjs";
26
26
  import { PackBlocks, blocksHeld, packIndexerLimits } from "./pack-reads.mjs";
27
27
  import { rangeRanks, readExactly } from "./pack-ranges.mjs";
28
- import { rangeCached } from "./range-cache.mjs";
28
+ import { rangeCached, wholeCached } from "./range-cache.mjs";
29
29
  import { compareIds } from "./raw-ids.mjs";
30
30
  import * as Effect from "effect/Effect";
31
31
  import * as Option from "effect/Option";
32
32
  import * as Schema from "effect/Schema";
33
33
  import * as Cause from "effect/Cause";
34
34
  import * as Result from "effect/Result";
35
- import * as Stream from "effect/Stream";
36
35
  // src/storage/index-build.ts
37
36
  /**
38
37
  * The reachability index's first build, `git.index`'s steps, one a try: the region's rows read,
@@ -89,7 +88,9 @@ const IndexLayer = /* @__PURE__ */ Schema.Struct({
89
88
  commits: Count,
90
89
  deltas: Count,
91
90
  bitmaps: Count,
92
- table: Count
91
+ table: Count,
92
+ /** The positions of the repo's roots among its own, sorted: none in a repo with none. */
93
+ roots: Schema.optionalKey(Schema.Array(Count))
93
94
  });
94
95
  /**
95
96
  * A build under way: its ID, the packs it covers in position order, its region's rows and their
@@ -122,7 +123,11 @@ const IndexData = /* @__PURE__ */ Schema.Struct({
122
123
  */
123
124
  dense: Schema.optionalKey(Schema.Literal(false)),
124
125
  /** A whole build's bitmaps written so far, a part a try: none before its first part. */
125
- bitmapsCut: Schema.optionalKey(Schema.suspend(() => BitmapsCut))
126
+ bitmapsCut: Schema.optionalKey(Schema.suspend(() => BitmapsCut)),
127
+ /** The digest of the roots the build is over, `rootsKeyOf`'s: none in a repo with none. */
128
+ roots: Schema.optionalKey(Schema.String),
129
+ /** The positions of the roots its region and slices have met so far, sorted: none, none yet. */
130
+ rootPositions: Schema.optionalKey(Schema.Array(Count))
126
131
  });
127
132
  /**
128
133
  * A whole build's bitmaps under way (#1068): the key of the order they're made in, how many of
@@ -179,13 +184,20 @@ const IndexRefusal = /* @__PURE__ */ Schema.Struct({
179
184
  * a row whose files a read found failing their own checks (`lostIndexRow`): no read answers from
180
185
  * it, and the next try builds whole, its row unmarked (Q839 (5)). A refusal over its layers keeps
181
186
  * the mark, and so does every other row that keeps them: only a whole build's row drops it.
187
+ * Each layer keeps where the repo's roots sit among its positions, so a fetch tells which it
188
+ * sends by its bits, with no lookup by ID.
182
189
  */
183
190
  const BuiltIndex = /* @__PURE__ */ Schema.Struct({
184
191
  rounds: Count,
185
192
  layers: Schema.Array(IndexLayer),
186
193
  replaced: Schema.Array(ReplacedBuild),
187
194
  refusal: Schema.optionalKey(IndexRefusal),
188
- lost: Schema.optionalKey(Schema.Literal(true))
195
+ lost: Schema.optionalKey(Schema.Literal(true)),
196
+ /**
197
+ * The digest of the roots every layer was built over, `rootsKeyOf`'s: none in a repo with none.
198
+ * An index over other roots than a read's is stale, so the read walks instead.
199
+ */
200
+ roots: Schema.optionalKey(Schema.String)
189
201
  });
190
202
  /** How long a repo waits after its first refusal for spent tries before a push saves more. */
191
203
  const triesWait = 864e5;
@@ -263,6 +275,18 @@ const lostIndexRow = (row) => {
263
275
  }
264
276
  };
265
277
  };
278
+ /**
279
+ * The digest an index keeps of the roots it's over: `rootsDigest`'s, the one the ready pack keeps
280
+ * too, and none for a repo with none, as most are.
281
+ */
282
+ const rootsKeyOf = (roots) => {
283
+ const ids = [...roots];
284
+ return ids.length === 0 ? void 0 : rootsDigest(ids);
285
+ };
286
+ /** Whether `built` is over `roots`, which a read was given: else it's stale for that read. */
287
+ const builtOver = (built, roots = noRepoRoots) => built.roots === rootsKeyOf(roots);
288
+ /** `positions` and `more`, sorted, each once. */
289
+ const withPositions = (positions, more) => [.../* @__PURE__ */ new Set([...positions ?? [], ...more])].sort((a, b) => a - b);
266
290
  /** A prune's end, with when the next file it kept is due. */
267
291
  const prunedAt = (due) => due === void 0 ? { kind: "pruned" } : {
268
292
  kind: "pruned",
@@ -324,7 +348,7 @@ const wordsOf = (bytes) => {
324
348
  */
325
349
  const keptReaches = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, words, allotment) {
326
350
  const chunks = [];
327
- yield* bucketDo(Stream.runForEach(bucket.read(key), (chunk) => {
351
+ yield* bucketDo(readEach(bucket, key, void 0, (chunk) => {
328
352
  chunks.push(chunk);
329
353
  return allotment.grow(chunk.byteLength);
330
354
  }));
@@ -350,7 +374,7 @@ const startedUpdate = (listed, built) => {
350
374
  ...started({
351
375
  ...listed,
352
376
  packs: listed.packs.filter((pack) => !covered.has(pack.id))
353
- }),
377
+ }, built.roots),
354
378
  below: built.layers
355
379
  };
356
380
  };
@@ -362,28 +386,32 @@ const startedMerge = (listed, built) => ({
362
386
  ...started({
363
387
  ...listed,
364
388
  packs: []
365
- }),
389
+ }, built.roots),
366
390
  below: built.layers,
367
391
  merge: true,
368
392
  step: "merge"
369
393
  });
370
- /** A fresh build of `listed`. */
371
- const started = (listed) => ({
372
- below: [],
373
- merge: false,
374
- build: newBuildId(),
375
- packs: positionOrder(listed.packs).map(({ id }) => id),
376
- rows: 0,
377
- region: "",
378
- step: "region",
379
- pack: 0,
380
- offset: 12,
381
- position: 0,
382
- slices: [],
383
- commits: 0,
384
- bitmaps: 0,
385
- table: 0
386
- });
394
+ /** A fresh build of `listed`, over the roots `roots`, `rootsKeyOf`'s digest. */
395
+ const started = (listed, roots) => {
396
+ const data = {
397
+ below: [],
398
+ merge: false,
399
+ build: newBuildId(),
400
+ packs: positionOrder(listed.packs).map(({ id }) => id),
401
+ rows: 0,
402
+ region: "",
403
+ step: "region",
404
+ pack: 0,
405
+ offset: 12,
406
+ position: 0,
407
+ slices: [],
408
+ commits: 0,
409
+ bitmaps: 0,
410
+ table: 0
411
+ };
412
+ if (roots !== void 0) data.roots = roots;
413
+ return data;
414
+ };
387
415
  /** The positions the layers below `data` hold, where its own start. */
388
416
  const firstOf = (below) => {
389
417
  const last = below[below.length - 1];
@@ -640,7 +668,7 @@ const regionStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, d
640
668
  const files = indexFiles(listed.repo, data.build);
641
669
  const { layout, first, packed } = yield* layoutOf(bucket, listed, data);
642
670
  const held = data.below.length === 0 ? void 0 : yield* heldBelow(parts, listed, layout, first);
643
- const roots = yield* rootsAt(parts, listed);
671
+ const roots = rootsIn(parts);
644
672
  const links = new SliceLinks((bytes) => allotment.tryGrow(bytes));
645
673
  const types = [];
646
674
  const commits = [];
@@ -676,6 +704,7 @@ const regionStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, d
676
704
  region: read.digest,
677
705
  step: "graph"
678
706
  };
707
+ if (rootPositions.size > 0) done.rootPositions = withPositions(data.rootPositions, rootPositions);
679
708
  if (read.rows === 0) return done;
680
709
  const region = withRows(layout.region, packed, read.ids);
681
710
  const targets = yield* joinCharged(links, layout.ranges, region, allotment);
@@ -707,36 +736,32 @@ const heldBelow = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, la
707
736
  for (let at = 0; at < read.rows; at += 1) if ((positions[at] ?? 4294967295) < first) held.add(hexOf(read.ids.subarray(at * 20, at * 20 + 20)));
708
737
  return held;
709
738
  });
710
- /**
711
- * The repo's roots, which a build writes with no parents in its graph and no parent edges, so
712
- * neither its bitmaps nor its generations pass one. Read on their own: an index try's own reads
713
- * are of its objects, and roots change only at the import's landing, before any ref names them.
714
- */
715
- const rootsAt = (parts, listed) => Effect.flatMap(parts.store.read({
716
- scope: repoScope(listed.repo),
717
- reads: [repoRootsKey]
718
- }), (snapshot) => rootsOf(snapshot.results[0]));
739
+ /** The repo's roots the try was given, read with its row: none when it was given none. */
740
+ const rootsIn = (parts) => parts.roots ?? noRepoRoots;
719
741
  /**
720
742
  * What the region holds of each row past its links: its ID, twice while the IDs grow, its type,
721
743
  * and a commit's entry and its ID as text, rounded up.
722
744
  */
723
745
  const regionRowBytes = 256;
724
- /** Each of `layers`' graphs, opened at its first graph number. */
725
- const belowGraphs = (bucket, repo, layers) => Effect.forEach(layers, (layer) => openIndexGraph(bucket, indexFiles(repo, layer.build).graph, layer.graphFirst));
746
+ /** Each of `layers`' graphs, opened at its first graph number, its IDs kept in `kept`'s when given. */
747
+ const belowGraphs = (bucket, repo, layers, kept) => Effect.forEach(layers, (layer, at) => openIndexGraph(bucket, indexFiles(repo, layer.build).graph, layer.graphFirst, { kept: kept?.[at] }));
726
748
  /** The graph step: every pack's `.graph` and the region's, merged. */
727
749
  const graphStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, allotment) {
728
750
  const files = indexFiles(listed.repo, data.build);
729
751
  const graphs = data.packs.map((id) => isPackId(id) ? packFiles(id).graph : id);
730
752
  if (data.rows > 0) graphs.push(files.regionGraph);
753
+ const sizes = graphSizesOf(listed, data);
754
+ const cached = yield* roomy(allotment, [...sizes.values()].reduce((total, size) => total + size + 320, 0), () => wholeCached(parts.bucket, sizes), (whole) => whole.clear());
755
+ const kept = yield* roomy(allotment, data.below.reduce((total, layer) => total + keptIdsBytes(layer.commits), 0), () => data.below.map(() => keptIdsOf()), (all) => all.forEach((ids) => ids.drop()));
731
756
  const graphFirst = graphFirstOf(data.below);
732
- const below = data.below.length === 0 ? void 0 : openGraphLayers(yield* belowGraphs(parts.bucket, listed.repo, data.below)).below(data.below.length);
757
+ const below = data.below.length === 0 ? void 0 : openGraphLayers(yield* belowGraphs(parts.bucket, listed.repo, data.below, kept)).below(data.below.length);
733
758
  const graphInput = {
734
- bucket: parts.bucket,
759
+ bucket: cached?.bucket ?? parts.bucket,
735
760
  graphs,
736
761
  key: files.graph,
737
762
  allotment,
738
763
  most: parts.graphMost,
739
- roots: yield* rootsAt(parts, listed)
764
+ roots: rootsIn(parts)
740
765
  };
741
766
  if (below !== void 0) graphInput.below = below;
742
767
  const written = (yield* storedSize(parts.bucket, files.graph)) === void 0 ? yield* writeIndexGraph(graphInput) : {
@@ -750,7 +775,15 @@ const graphStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, da
750
775
  commits: written.commits,
751
776
  step
752
777
  };
753
- });
778
+ }, Effect.scoped);
779
+ /**
780
+ * Each listed pack's `.graph` the step merges, by key, at the size its row records: a region's
781
+ * isn't listed, so it streams each pass.
782
+ */
783
+ const graphSizesOf = (listed, data) => {
784
+ const merged = new Set(data.packs);
785
+ return new Map(listed.packs.flatMap(({ id, graphBytes }) => merged.has(id) && isPackId(id) && graphBytes > 0 ? [[packFiles(id).graph, graphBytes]] : []));
786
+ };
754
787
  /**
755
788
  * The type codes `slices` stored at positions of the pack whose order starts at repo position
756
789
  * `base`: for each slice that holds any, one ranged read of its `.types` part, from the first it
@@ -785,7 +818,7 @@ const storedTypesOf = (bucket, files, slices, base) => Effect.fnUntraced(functio
785
818
  */
786
819
  const readStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, allotment) {
787
820
  const { counted } = parts;
788
- const roots = yield* rootsAt(parts, listed);
821
+ const roots = rootsIn(parts);
789
822
  const counts = data.packs.map((id) => listed.packs.find((each) => each.id === id)?.objects ?? 0);
790
823
  const bounds = parts.bounds ?? sliceBounds;
791
824
  const entries = data.narrowed?.entries ?? bounds.entries ?? 65536;
@@ -815,7 +848,8 @@ const readStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, dat
815
848
  offset: data.offset,
816
849
  position: data.position
817
850
  };
818
- const opened = yield* Effect.result(cutAtSpent(layoutOf(bucket, listed, data)));
851
+ const joins = yield* roomyJoins(bucket, listed, data, allotment);
852
+ const opened = yield* Effect.result(cutAtSpent(joins === void 0 ? layoutOf(bucket, listed, data) : layoutOf(joins.bucket, listed, data, { cached: true })));
819
853
  if (Result.isFailure(opened)) {
820
854
  const spent = spentOf(opened.failure);
821
855
  if (spent === void 0) return yield* Effect.fail(opened.failure);
@@ -870,7 +904,11 @@ const readStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, dat
870
904
  ...edges.slice,
871
905
  deltas: slice.bases.length / 2
872
906
  }];
873
- const { narrowed: _narrowed, ...past } = data;
907
+ const { narrowed: _narrowed, ...kept } = data;
908
+ const past = slice.roots.size === 0 ? kept : {
909
+ ...kept,
910
+ rootPositions: withPositions(data.rootPositions, slice.roots)
911
+ };
874
912
  if (slice.next !== void 0) {
875
913
  const after = narrowedAfter(data.narrowed, at.position, { next: slice.next.position });
876
914
  const moved = {
@@ -1108,28 +1146,66 @@ const bitmapsJoinMost = 25165824;
1108
1146
  * `bitmapsJoinMost`. It's what a join can read, from the counts alone, never what a try did.
1109
1147
  */
1110
1148
  const bitmapsJoinHeld = (objects) => Math.min(bitmapsJoinMost, objects.reduce((sum, count) => sum + count * 24 + Math.ceil(count / rangeRanks) * 2 * 320, 0));
1149
+ /** What a step keeps of its layout's join ranges, `bitmapsJoinHeld` over the packs `data` covers. */
1150
+ const joinsHeldOf = (listed, data) => {
1151
+ const covered = new Set([...data.below, spanOf(data)].flatMap((layer) => layer.groups.flatMap((group) => group.packs)));
1152
+ return bitmapsJoinHeld(listed.packs.filter(({ id }) => covered.has(id)).map((pack) => pack.objects));
1153
+ };
1111
1154
  /**
1112
1155
  * The step's kept join ranges over `bucket`, charged at `bitmapsJoinHeld` before any read and let
1113
1156
  * go as its scope ends, however the step ends: each walk below's batch joins every covered pack's
1114
1157
  * ranges, which are read once a step this way, not once a batch.
1115
1158
  */
1116
1159
  const keptJoins = (bucket, listed, data, allotment) => {
1117
- const covered = new Set([...data.below, spanOf(data)].flatMap((layer) => layer.groups.flatMap((group) => group.packs)));
1118
- const held = bitmapsJoinHeld(listed.packs.filter(({ id }) => covered.has(id)).map((pack) => pack.objects));
1160
+ const held = joinsHeldOf(listed, data);
1119
1161
  return Effect.acquireRelease(Effect.map(allotment.grow(held), () => rangeCached(bucket, held, { evict: false })), (ranges) => Effect.sync(() => {
1120
1162
  ranges.clear();
1121
1163
  allotment.shrink(held);
1122
1164
  }));
1123
1165
  };
1166
+ /**
1167
+ * What `make` makes, in a room of `allotment` that has `held` at once: none with no room at once,
1168
+ * and `drop`ped when the budget shrinks the room, the step's own grow or another's, or as the
1169
+ * scope ends. Its maker reads again what it would have kept: never a wait or a refusal (#2518).
1170
+ * `drop` lets go at once of all it holds, reads under way included, as the room's charge goes back.
1171
+ */
1172
+ const roomy = (allotment, held, make, drop) => {
1173
+ const room = allotment.room(0, held);
1174
+ return Effect.acquireRelease(Effect.sync(() => {
1175
+ if (!room.grow(held)) return void 0;
1176
+ const made = make();
1177
+ room.watch((left) => {
1178
+ if (left < held) drop(made);
1179
+ });
1180
+ return made;
1181
+ }), (made) => Effect.sync(() => {
1182
+ if (made !== void 0) drop(made);
1183
+ allotment.endRoom(room);
1184
+ }));
1185
+ };
1186
+ /**
1187
+ * The step's join ranges kept as `keptJoins` keeps them, in a room, so the layout a step opens and
1188
+ * the join that reads it again read each range once a step (#2518).
1189
+ */
1190
+ const roomyJoins = (bucket, listed, data, allotment) => {
1191
+ const held = joinsHeldOf(listed, data);
1192
+ return roomy(allotment, held, () => rangeCached(bucket, held, { evict: false }), (ranges) => ranges.clear());
1193
+ };
1194
+ /**
1195
+ * A first build's tips' numbers and then the numbers' IDs read the same chunk of the graph's IDs:
1196
+ * kept in a room of `keptIdsBytes`, so it's read once a step (#2518).
1197
+ */
1198
+ const roomyIds = (data, allotment) => roomy(allotment, keptIdsBytes(data.commits), keptIdsOf, (kept) => kept.drop());
1124
1199
  /** `bitmapsStep`'s reads and writes, through `lower` when given, each walk below in `walks`. */
1125
1200
  const bitmapsWritten = /* @__PURE__ */ Effect.fnUntraced(function* (parts, lower, listed, data, input, allotment, walks) {
1126
1201
  const bucket = lower?.bucket ?? parts.bucket;
1127
1202
  const files = indexFiles(listed.repo, data.build);
1128
- const joins = data.below.length === 0 ? void 0 : yield* keptJoins(bucket, listed, data, allotment);
1203
+ const joins = data.below.length === 0 ? yield* roomyJoins(bucket, listed, data, allotment) : yield* keptJoins(bucket, listed, data, allotment);
1129
1204
  const { layout, first } = joins === void 0 ? yield* layoutOf(bucket, listed, data) : yield* layoutOf(joins.bucket, listed, data, { cached: true });
1130
1205
  const { positions } = layout;
1131
1206
  const graphFirst = graphFirstOf(data.below);
1132
- const own = yield* openIndexGraph(bucket, files.graph, graphFirst);
1207
+ const kept = data.below.length === 0 ? yield* roomyIds(data, allotment) : void 0;
1208
+ const own = yield* openIndexGraph(bucket, files.graph, graphFirst, { kept });
1133
1209
  const graph = openGraphLayers([...yield* belowGraphs(bucket, listed.repo, data.below), own]);
1134
1210
  yield* allotment.grow(own.commits * 12);
1135
1211
  const rows = yield* own.rows;
@@ -1214,7 +1290,6 @@ const bitmapsWritten = /* @__PURE__ */ Effect.fnUntraced(function* (parts, lower
1214
1290
  allotment,
1215
1291
  bits: walking
1216
1292
  };
1217
- const rootsOnce = yield* Effect.cached(rootsAt(parts, listed));
1218
1293
  const below = data.below.length === 0 ? void 0 : {
1219
1294
  first,
1220
1295
  entries: entriesBelow,
@@ -1231,7 +1306,7 @@ const bitmapsWritten = /* @__PURE__ */ Effect.fnUntraced(function* (parts, lower
1231
1306
  if (walks.carried?.position === position) carry.from = walks.carried.walk;
1232
1307
  const walked = yield* reachOf({
1233
1308
  ...reach,
1234
- roots: yield* rootsOnce
1309
+ roots: rootsIn(parts)
1235
1310
  }, [{ position }], carry);
1236
1311
  if (walked === void 0) return void 0;
1237
1312
  const most = ewahMostWords(walked.length) * 4;
@@ -1520,20 +1595,28 @@ const liveBitmaps = /* @__PURE__ */ Effect.fnUntraced(function* (layout, stored,
1520
1595
  yield* stored.orInto(bitmapped, live);
1521
1596
  return stored.entries.filter(({ entry }) => hasBit(live, entry.position));
1522
1597
  });
1598
+ /** `numbered`'s bitmaps' numbers in the merged graph at `key`, read by their IDs in `graphs`. */
1599
+ const numbersIn = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, graphs, numbered) {
1600
+ const merged = yield* openIndexGraph(bucket, key);
1601
+ const ids = yield* openGraphLayers(graphs).idsAt(numbered.map(({ entry }) => entry.number));
1602
+ return yield* merged.numbersOf(ids, numbered.length);
1603
+ });
1523
1604
  /**
1524
1605
  * `kept`'s bitmaps copied to `files.bitmaps` over `positions`, each numbered again by the merged
1525
- * graph at `files.graph`, which `graphs` were merged into: its bits and its position as `move`
1526
- * moves them, or where they were. A file a try that died already put is kept. Its caller charges
1527
- * the bitmaps' entries, `mergeEntryBytes` each; the copy charges its own.
1606
+ * graph at `files.graph`, which `graphs` were merged into, or by `renumbered`, the merge's own
1607
+ * numbering, while that file isn't finished: its bits and its position as `move` moves them, or
1608
+ * where they were. A file a try that died already put is kept. Its caller charges the bitmaps'
1609
+ * entries, `mergeEntryBytes` each; the copy charges its own.
1528
1610
  */
1529
1611
  const copyMergedBitmaps = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
1530
- const { bucket, files, positions, kept } = input;
1612
+ const { bucket, files, positions, kept, renumbered } = input;
1531
1613
  const stored = yield* storedSize(bucket, files.bitmaps);
1532
1614
  if (stored !== void 0) return yield* storedBitmaps(bucket, files.bitmaps, positions, stored);
1533
1615
  const numbered = kept.filter(({ entry }) => entry.number !== noNumber);
1534
- const merged = yield* openIndexGraph(bucket, files.graph);
1535
- const ids = yield* openGraphLayers(input.graphs).idsAt(numbered.map(({ entry }) => entry.number));
1536
- const numbers = yield* merged.numbersOf(ids, numbered.length);
1616
+ const numbers = renumbered === void 0 ? yield* numbersIn(bucket, files.graph, input.graphs, numbered) : numbered.map(({ entry }) => {
1617
+ const number = renumbered(entry.number);
1618
+ return number === 2147483647 ? absent : number;
1619
+ });
1537
1620
  const copied = [];
1538
1621
  let place = 0;
1539
1622
  for (const { from, entry } of kept) {
@@ -1728,9 +1811,19 @@ const roundsAfter = (input) => (input.round ?? 0) + 1;
1728
1811
  * the repo's version during its read, and finds at its commit that it was.
1729
1812
  */
1730
1813
  const addsNothing = (data) => data.merge !== true && data.below.length > 0 && data.packs.length === 0 && data.rows === 0 && data.commits === 0 && data.bitmaps === 0;
1814
+ /** `layer` with the roots at `positions`, sorted: none kept where there are none. */
1815
+ const withRoots = (layer, positions) => positions.length === 0 ? layer : {
1816
+ ...layer,
1817
+ roots: positions
1818
+ };
1819
+ /** `row` over the roots `roots`, `rootsKeyOf`'s digest: none kept where the repo has none. */
1820
+ const rootedRow = (row, roots) => roots === void 0 ? row : {
1821
+ ...row,
1822
+ roots
1823
+ };
1731
1824
  /**
1732
1825
  * The commit step: the row, its layers those below the build and the build's own, over the packs
1733
- * it began with and its region.
1826
+ * it began with and its region, and over the roots it began with, each layer's at its positions.
1734
1827
  */
1735
1828
  const commitStep = (listed, data, input) => Effect.sync(() => {
1736
1829
  if (data.merge) {
@@ -1746,13 +1839,16 @@ const commitStep = (listed, data, input) => Effect.sync(() => {
1746
1839
  bitmaps: data.bitmaps,
1747
1840
  table: data.table
1748
1841
  };
1842
+ const roots = withPositions([], data.below.flatMap((layer) => layer.roots ?? []));
1843
+ const layer = withRoots(merged, roots);
1844
+ const row = {
1845
+ rounds: roundsAfter(input),
1846
+ layers: [layer],
1847
+ replaced: replacedBy(input, [layer])
1848
+ };
1749
1849
  return {
1750
1850
  kind: "done",
1751
- row: {
1752
- rounds: roundsAfter(input),
1753
- layers: [merged],
1754
- replaced: replacedBy(input, [merged])
1755
- },
1851
+ row: rootedRow(row, data.roots),
1756
1852
  data
1757
1853
  };
1758
1854
  }
@@ -1771,14 +1867,15 @@ const commitStep = (listed, data, input) => Effect.sync(() => {
1771
1867
  bitmaps: data.bitmaps,
1772
1868
  table: data.table
1773
1869
  };
1774
- const layers = [...data.below, layer];
1870
+ const layers = [...data.below, withRoots(layer, data.rootPositions ?? [])];
1871
+ const row = {
1872
+ rounds: roundsAfter(input),
1873
+ layers,
1874
+ replaced: replacedBy(input, layers)
1875
+ };
1775
1876
  return {
1776
1877
  kind: "done",
1777
- row: {
1778
- rounds: roundsAfter(input),
1779
- layers,
1780
- replaced: replacedBy(input, layers)
1781
- },
1878
+ row: rootedRow(row, data.roots),
1782
1879
  data
1783
1880
  };
1784
1881
  });
@@ -1924,7 +2021,7 @@ const indexStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, in
1924
2021
  const kept = builtOf(row);
1925
2022
  if (kept !== void 0) return {
1926
2023
  kind: "done",
1927
- row: {
2024
+ row: rootedRow({
1928
2025
  rounds,
1929
2026
  layers: kept.layers,
1930
2027
  replaced: replacedBy(input, kept.layers),
@@ -1933,7 +2030,7 @@ const indexStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, in
1933
2030
  ...held
1934
2031
  },
1935
2032
  ...kept.lost === true && { lost: true }
1936
- }
2033
+ }, kept.roots)
1937
2034
  };
1938
2035
  return {
1939
2036
  kind: "done",
@@ -1967,21 +2064,23 @@ const indexStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, in
1967
2064
  });
1968
2065
  };
1969
2066
  if (input.failed !== void 0) return waiting(input.failed.reason);
1970
- if (input.data === void 0 && row !== void 0 && !indexSaves(indexStatus(row, limits, input.at, listedIds(listed)))) return prunedAt(yield* prune());
2067
+ const rootsKey = rootsKeyOf(rootsIn(parts));
1971
2068
  const built = builtOf(row);
1972
- const current = input.data === void 0 && built?.lost === true ? "lost" : input.data === void 0 && built !== void 0 && coversAll(built.layers, listed) ? yield* upToDate(parts, listed, built, input.tips).pipe(Effect.catchIf(isLost, (error) => Effect.as(layersLost(listed, error), "lost"))) : false;
2069
+ const stale = built !== void 0 && !builtOver(built, rootsIn(parts));
2070
+ if (input.data === void 0 && row !== void 0 && !stale && !indexSaves(indexStatus(row, limits, input.at, listedIds(listed)))) return prunedAt(yield* prune());
2071
+ const current = input.data === void 0 && built?.lost === true ? "lost" : input.data === void 0 && built !== void 0 && !stale && coversAll(built.layers, listed) ? yield* upToDate(parts, listed, built, input.tips).pipe(Effect.catchIf(isLost, (error) => Effect.as(layersLost(listed, error), "lost"))) : false;
1973
2072
  if (current === true) return prunedAt(yield* prune());
1974
2073
  if (current === "moved" && input.lastCheck !== true) return { kind: "moved" };
1975
- const fresh = () => built === void 0 || current === "lost" || !coversAll(built.layers, listed) ? started(listed) : built.layers.length < 8 ? startedUpdate(listed, built) : startedMerge(listed, built);
2074
+ const fresh = () => built === void 0 || stale || current === "lost" || !coversAll(built.layers, listed) ? started(listed, rootsKey) : built.layers.length < 8 ? startedUpdate(listed, built) : startedMerge(listed, built);
1976
2075
  const kept = input.data;
1977
2076
  const sameBelow = kept !== void 0 && (kept.below.length === 0 || kept.below.map((layer) => layer.build).join() === (built?.layers ?? []).map((layer) => layer.build).join());
1978
- const again = (from) => from.below.length === 0 && from.merge !== true ? started(listed) : fresh();
1979
- const data = kept !== void 0 && built?.lost === true && kept.below.length > 0 ? started(listed) : kept === void 0 || !covers(kept, listed) || !sameBelow ? fresh() : kept.step === "region" ? again(kept) : kept;
2077
+ const again = (from) => from.below.length === 0 && from.merge !== true ? started(listed, rootsKey) : fresh();
2078
+ const data = kept !== void 0 && built?.lost === true && kept.below.length > 0 ? started(listed, rootsKey) : kept === void 0 || kept.roots !== rootsKey || !covers(kept, listed) || !sameBelow ? fresh() : kept.step === "region" ? again(kept) : kept;
1980
2079
  const more = (next) => ({
1981
2080
  kind: "more",
1982
2081
  data: next
1983
2082
  });
1984
- const orWhole = (step) => data.below.length === 0 ? step : step.pipe(Effect.catchIf(isLost, (error) => Effect.as(layersLost(listed, error), started(listed))));
2083
+ const orWhole = (step) => data.below.length === 0 ? step : step.pipe(Effect.catchIf(isLost, (error) => Effect.as(layersLost(listed, error), started(listed, rootsKey))));
1985
2084
  if (input.lastCheck === true && input.data === void 0) return more(data);
1986
2085
  if (data.step === "region") yield* prune(data.build);
1987
2086
  if (data.step === "commit" && addsNothing(data)) {
@@ -2022,7 +2121,7 @@ const indexStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, in
2022
2121
  return yield* Effect.fail(read.failure);
2023
2122
  }
2024
2123
  const bitmaps = yield* Effect.result(named(orWhole(bitmapsStep(parts, listed, data, input, allotment))));
2025
- if (Result.isSuccess(bitmaps)) return more(bitmaps.success ?? started(listed));
2124
+ if (Result.isSuccess(bitmaps)) return more(bitmaps.success ?? started(listed, rootsKey));
2026
2125
  if (isSliceRefused(bitmaps.failure)) return final(bitmaps.failure);
2027
2126
  return yield* Effect.fail(bitmaps.failure);
2028
2127
  }, Effect.scoped);
@@ -2052,9 +2151,11 @@ const indexTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, limits, lis
2052
2151
  if (input.deleted !== void 0) step.deleted = input.deleted;
2053
2152
  if (input.failed !== void 0) step.failed = input.failed;
2054
2153
  if (input.lastCheck === true) step.lastCheck = true;
2154
+ const roots = new Set(input.roots ?? []);
2055
2155
  const ended = yield* indexStep({
2056
2156
  ...parts,
2057
- graphMost: limits.graphMost
2157
+ graphMost: limits.graphMost,
2158
+ roots
2058
2159
  }, listed, step);
2059
2160
  if (ended.kind !== "done") return ended;
2060
2161
  return {
@@ -2066,4 +2167,4 @@ const indexTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, limits, lis
2066
2167
  data: ended.data
2067
2168
  };
2068
2169
  });
2069
- export { BitmapsCut, BuiltIndex, IndexBounds, IndexData, IndexGroup, IndexLayer, IndexRefusal, IndexRow, IndexSlice, IndexTries, Narrowed, RefusedIndex, ReplacedBuild, belowGraphs, bitmapsJoinHeld, bitmapsJoinMost, boundsOf, builtIndexOf, chooseCommits, copyMergedBitmaps, coveredPacks, coversAll, decodeIndexValue, denseBelow, denseBelowReads, edgesMost, entriesHeld, floors, graphMostOf, indexBitmapsCallsAfter, indexReadCallsAfter, indexRowOf, indexSaves, indexStatus, indexStep, indexSteps, indexTry, limitsOf, lostIndexRow, madeMost, mergeCallsAfterOpen, mergeChunk, mergeHeldMost, narrowedAfter, newBuildId, positionOrder, pruneBuilds, putOnce, reachesBytes, reachesOf, readFurther, rowsOfLayer, sliceBounds, storedTypesOf, triesWait, triesWaitMost, triesWaitOf, wordsOf };
2170
+ export { BitmapsCut, BuiltIndex, IndexBounds, IndexData, IndexGroup, IndexLayer, IndexRefusal, IndexRow, IndexSlice, IndexTries, Narrowed, RefusedIndex, ReplacedBuild, belowGraphs, bitmapsJoinHeld, bitmapsJoinMost, boundsOf, builtIndexOf, builtOver, chooseCommits, copyMergedBitmaps, coveredPacks, coversAll, decodeIndexValue, denseBelow, denseBelowReads, edgesMost, entriesHeld, floors, graphMostOf, indexBitmapsCallsAfter, indexReadCallsAfter, indexRowOf, indexSaves, indexStatus, indexStep, indexSteps, indexTry, limitsOf, lostIndexRow, madeMost, mergeCallsAfterOpen, mergeChunk, mergeHeldMost, narrowedAfter, newBuildId, positionOrder, pruneBuilds, putOnce, reachesBytes, reachesOf, readFurther, roomy, rootsKeyOf, rowsOfLayer, sliceBounds, storedTypesOf, triesWait, triesWaitMost, triesWaitOf, wordsOf };