@ref0/git 0.7.0 → 0.9.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 (245) hide show
  1. package/dist/access/private-refs.mjs +0 -2
  2. package/dist/auth/authorize.mjs +31 -24
  3. package/dist/auth/bridge.mjs +8 -8
  4. package/dist/auth/fences.d.mts +0 -1
  5. package/dist/auth/fences.mjs +1 -1
  6. package/dist/auth/grants.d.mts +0 -1
  7. package/dist/auth/grants.mjs +2 -2
  8. package/dist/auth/host-function.d.mts +1 -7
  9. package/dist/auth/host-function.mjs +38 -38
  10. package/dist/auth/identify.d.mts +0 -1
  11. package/dist/auth/identify.mjs +1 -1
  12. package/dist/auth/policy.d.mts +7 -4
  13. package/dist/auth/policy.mjs +13 -10
  14. package/dist/auth/token-rows.mjs +2 -5
  15. package/dist/auth/tokens-layer.d.mts +0 -2
  16. package/dist/auth/tokens-public.d.mts +3 -3
  17. package/dist/auth/tokens-public.mjs +4 -2
  18. package/dist/auth/tokens.d.mts +6 -1
  19. package/dist/auth/tokens.mjs +7 -1
  20. package/dist/client/client.d.mts +22 -15
  21. package/dist/client/client.mjs +31 -27
  22. package/dist/client/git-http.mjs +22 -5
  23. package/dist/client/local.mjs +1 -1
  24. package/dist/client/namespace.d.mts +2 -0
  25. package/dist/client/push-upload.d.mts +1 -0
  26. package/dist/client/push-upload.mjs +169 -2
  27. package/dist/client/remote-helper.mjs +2 -4
  28. package/dist/client/remote.mjs +37 -15
  29. package/dist/client/run-remote-helper.mjs +4 -4
  30. package/dist/client/transport.mjs +26 -19
  31. package/dist/contracts/actors.d.mts +57 -28
  32. package/dist/contracts/actors.mjs +38 -2
  33. package/dist/contracts/authorize.d.mts +21 -15
  34. package/dist/contracts/callers.mjs +40 -0
  35. package/dist/contracts/calls-spent.d.mts +2 -12
  36. package/dist/contracts/calls-spent.mjs +4 -5
  37. package/dist/contracts/client.d.mts +16 -9
  38. package/dist/contracts/events.d.mts +82 -14
  39. package/dist/contracts/events.mjs +35 -9
  40. package/dist/contracts/files.d.mts +42 -42
  41. package/dist/contracts/forks.d.mts +0 -24
  42. package/dist/contracts/git-hooks.d.mts +217 -0
  43. package/dist/contracts/git-hooks.mjs +3 -1
  44. package/dist/contracts/git.d.mts +13 -3
  45. package/dist/contracts/grants.d.mts +46 -27
  46. package/dist/contracts/lfs.d.mts +17 -4
  47. package/dist/contracts/merges.d.mts +7 -7
  48. package/dist/contracts/objects.d.mts +38 -4
  49. package/dist/contracts/opaque.mjs +19 -1
  50. package/dist/contracts/operations.d.mts +8 -1
  51. package/dist/contracts/operations.mjs +209 -0
  52. package/dist/contracts/queue.d.mts +6 -5
  53. package/dist/contracts/queue.mjs +9 -20
  54. package/dist/contracts/remote.d.mts +13 -4
  55. package/dist/contracts/remote.mjs +3 -3
  56. package/dist/contracts/repos.d.mts +11 -40
  57. package/dist/contracts/repos.mjs +11 -10
  58. package/dist/contracts/result.d.mts +28 -11
  59. package/dist/contracts/result.mjs +32 -2
  60. package/dist/contracts/rules.d.mts +706 -46
  61. package/dist/contracts/rules.mjs +81 -2
  62. package/dist/contracts/server.d.mts +5 -275
  63. package/dist/contracts/services.d.mts +0 -3
  64. package/dist/contracts/services.mjs +1 -3
  65. package/dist/contracts/signin.d.mts +2 -2
  66. package/dist/contracts/signin.mjs +4 -5
  67. package/dist/contracts/sync.d.mts +1 -4
  68. package/dist/contracts/tokens.d.mts +29 -17
  69. package/dist/contracts/tokens.mjs +14 -3
  70. package/dist/contracts/topics.d.mts +38 -11
  71. package/dist/contracts/topics.mjs +8 -2
  72. package/dist/core/access.d.mts +0 -2
  73. package/dist/core/access.mjs +15 -4
  74. package/dist/core/ancestry.mjs +5 -4
  75. package/dist/core/events/deliver.mjs +19 -1
  76. package/dist/core/forks.mjs +30 -11
  77. package/dist/core/hooks/groups.d.mts +0 -1
  78. package/dist/core/hooks/groups.mjs +8 -9
  79. package/dist/core/index-job.mjs +23 -1
  80. package/dist/core/index-lost.d.mts +11 -0
  81. package/dist/core/index-lost.mjs +55 -0
  82. package/dist/core/loose-tally.mjs +46 -0
  83. package/dist/core/objects/commit-writes.mjs +1 -1
  84. package/dist/core/objects/commits.mjs +10 -9
  85. package/dist/core/objects/merges.mjs +1 -1
  86. package/dist/core/objects/reading.mjs +28 -13
  87. package/dist/core/objects/trees.mjs +1 -1
  88. package/dist/core/objects/writing.mjs +1 -0
  89. package/dist/core/parts.d.mts +7 -0
  90. package/dist/core/promise.mjs +1 -15
  91. package/dist/core/publish.mjs +9 -5
  92. package/dist/core/purge.mjs +30 -12
  93. package/dist/core/push.mjs +39 -16
  94. package/dist/core/ref-view.mjs +14 -6
  95. package/dist/core/repack.mjs +54 -27
  96. package/dist/core/repo-info.mjs +8 -6
  97. package/dist/core/repos.mjs +1 -0
  98. package/dist/core/rules/check.mjs +10 -10
  99. package/dist/core/rules/context.d.mts +3 -1
  100. package/dist/core/rules/context.mjs +16 -13
  101. package/dist/core/rules/fetch.mjs +17 -23
  102. package/dist/core/tokens.mjs +2 -1
  103. package/dist/core/view.d.mts +10 -1
  104. package/dist/core/view.mjs +15 -6
  105. package/dist/effect.d.mts +3 -6
  106. package/dist/effect.mjs +3 -6
  107. package/dist/engine/commits.mjs +23 -50
  108. package/dist/engine/failures.d.mts +1 -2
  109. package/dist/engine/failures.mjs +1 -3
  110. package/dist/engine/merge-base-walk.mjs +57 -142
  111. package/dist/engine/merge-bases.mjs +9 -7
  112. package/dist/engine/merge.mjs +20 -17
  113. package/dist/engine/parts.d.mts +1 -0
  114. package/dist/engine/parts.mjs +1 -1
  115. package/dist/engine/walk.mjs +15 -11
  116. package/dist/extend.d.mts +1 -2
  117. package/dist/extend.mjs +1 -2
  118. package/dist/http/core-parts.mjs +18 -10
  119. package/dist/http/handler.mjs +11 -31
  120. package/dist/http/parts.d.mts +0 -1
  121. package/dist/index.d.mts +29 -22
  122. package/dist/index.mjs +5 -2
  123. package/dist/lfs/base.d.mts +6 -3
  124. package/dist/lfs/base.mjs +2 -1
  125. package/dist/lfs/layer.d.mts +4 -3
  126. package/dist/lfs/layer.mjs +23 -9
  127. package/dist/lfs/objects.mjs +93 -41
  128. package/dist/lfs/pointers.mjs +69 -18
  129. package/dist/lfs/purge.mjs +6 -2
  130. package/dist/lfs/rows.mjs +24 -7
  131. package/dist/lfs/service.d.mts +6 -3
  132. package/dist/lfs/service.mjs +8 -2
  133. package/dist/lfs/upkeep.mjs +47 -28
  134. package/dist/lfs/upload-most.mjs +47 -0
  135. package/dist/lfs/uploaded.mjs +59 -0
  136. package/dist/protocol/bytes/sha256-hasher.mjs +51 -0
  137. package/dist/protocol/bytes/streams.mjs +84 -2
  138. package/dist/protocol/bytes/text.mjs +6 -1
  139. package/dist/protocol/diff/read.d.mts +1 -0
  140. package/dist/protocol/diff/read.mjs +5 -2
  141. package/dist/protocol/objects/commit.d.mts +7 -0
  142. package/dist/protocol/objects/commit.mjs +5 -1
  143. package/dist/protocol/objects/fsck.mjs +6 -3
  144. package/dist/queue/advance.mjs +77 -18
  145. package/dist/queue/calls.mjs +4 -14
  146. package/dist/queue/host.d.mts +4 -0
  147. package/dist/queue/lanes.mjs +1 -1
  148. package/dist/queue/layer.mjs +4 -2
  149. package/dist/queue/limits.mjs +18 -2
  150. package/dist/queue/rows.mjs +10 -1
  151. package/dist/queue/schedule.mjs +1 -1
  152. package/dist/queue/search.mjs +3 -4
  153. package/dist/queue/trim.mjs +2 -2
  154. package/dist/rest/client-namespace.d.mts +2 -0
  155. package/dist/rest/client.d.mts +32 -8
  156. package/dist/rest/client.mjs +308 -382
  157. package/dist/rest/commits.d.mts +150 -150
  158. package/dist/rest/files.d.mts +18 -18
  159. package/dist/rest/forks.d.mts +77 -89
  160. package/dist/rest/handlers.mjs +2 -1
  161. package/dist/rest/listen.d.mts +8 -6
  162. package/dist/rest/listen.mjs +31 -75
  163. package/dist/rest/me.d.mts +2 -2
  164. package/dist/rest/merges.d.mts +7 -7
  165. package/dist/rest/refs.d.mts +27 -27
  166. package/dist/rest/repos.d.mts +40 -52
  167. package/dist/rest/tokens.d.mts +12 -12
  168. package/dist/rest/topics.d.mts +13 -13
  169. package/dist/rest/trees.d.mts +66 -66
  170. package/dist/rest/wire.d.mts +20 -2
  171. package/dist/rest/work.d.mts +39 -39
  172. package/dist/rest.d.mts +1 -7
  173. package/dist/rest.mjs +1 -5
  174. package/dist/server/git-layer.d.mts +10 -2
  175. package/dist/server/git-layer.mjs +29 -10
  176. package/dist/server/joined.d.mts +12 -6
  177. package/dist/server/joined.mjs +3 -2
  178. package/dist/server/registry.mjs +11 -5
  179. package/dist/server/server.d.mts +0 -1
  180. package/dist/server/server.mjs +42 -49
  181. package/dist/signin/context.d.mts +0 -1
  182. package/dist/signin/context.mjs +5 -9
  183. package/dist/storage/clean-up.mjs +3 -1
  184. package/dist/storage/fsck.mjs +12 -2
  185. package/dist/storage/graph-rebuild.mjs +262 -0
  186. package/dist/storage/index-bitmaps.mjs +16 -10
  187. package/dist/storage/index-build.mjs +160 -24
  188. package/dist/storage/index-graph.d.mts +1 -0
  189. package/dist/storage/index-graph.mjs +29 -5
  190. package/dist/storage/index-layers.d.mts +1 -0
  191. package/dist/storage/index-layers.mjs +5 -2
  192. package/dist/storage/index-reach.mjs +7 -5
  193. package/dist/storage/index-remap.mjs +5 -5
  194. package/dist/storage/index-visible.mjs +16 -5
  195. package/dist/storage/lfs-pointers.d.mts +5 -5
  196. package/dist/storage/lfs-pointers.mjs +37 -11
  197. package/dist/storage/links.mjs +3 -3
  198. package/dist/storage/loose.mjs +4 -1
  199. package/dist/storage/memory-budget.mjs +1 -1
  200. package/dist/storage/merge-fence.mjs +81 -19
  201. package/dist/storage/merge-most.mjs +1 -0
  202. package/dist/storage/merge-row.mjs +16 -4
  203. package/dist/storage/merge-stream.mjs +9 -6
  204. package/dist/storage/object-rows.mjs +17 -1
  205. package/dist/storage/pack-order.d.mts +1 -0
  206. package/dist/storage/pack-order.mjs +18 -1
  207. package/dist/storage/pack-receive.mjs +10 -6
  208. package/dist/storage/packs.mjs +58 -27
  209. package/dist/storage/prune-walk.mjs +5 -2
  210. package/dist/storage/prune.mjs +168 -70
  211. package/dist/storage/ready.d.mts +1 -1
  212. package/dist/storage/ready.mjs +12 -3
  213. package/dist/storage/receive-bounds.mjs +3 -2
  214. package/dist/storage/receive-state.mjs +1 -1
  215. package/dist/storage/repack-contained.mjs +22 -14
  216. package/dist/storage/repack.d.mts +1 -1
  217. package/dist/storage/repack.mjs +3 -2
  218. package/dist/storage/unpack.mjs +7 -0
  219. package/dist/storage/visible.mjs +3 -2
  220. package/dist/storage/walk.d.mts +1 -0
  221. package/dist/storage/walk.mjs +9 -5
  222. package/dist/storage/wants.mjs +17 -11
  223. package/dist/store/call-count.d.mts +31 -3
  224. package/dist/store/call-count.mjs +51 -20
  225. package/dist/store/errors.d.mts +7 -1
  226. package/dist/store/errors.mjs +7 -1
  227. package/dist/store/job-try.mjs +3 -1
  228. package/dist/store/records.mjs +26 -5
  229. package/dist/store/repo-record.mjs +36 -12
  230. package/dist/store/scopes.mjs +15 -2
  231. package/dist/sync/bound.d.mts +1 -1
  232. package/dist/sync/import.mjs +15 -3
  233. package/dist/sync/layer.d.mts +5 -1
  234. package/dist/sync/layer.mjs +11 -9
  235. package/dist/sync/mirror.mjs +1 -1
  236. package/dist/sync/step.mjs +15 -15
  237. package/dist/topics/advance.mjs +11 -10
  238. package/dist/topics/layer.mjs +1 -1
  239. package/dist/topics/members.mjs +38 -9
  240. package/package.json +3 -3
  241. package/dist/engine/merge-base-walk.d.mts +0 -3
  242. package/dist/server/routes.d.mts +0 -32
  243. package/dist/server/routes.mjs +0 -69
  244. package/dist/sync/bridge.d.mts +0 -6
  245. package/dist/sync/bridge.mjs +0 -29
@@ -1,9 +1,10 @@
1
1
  import { fail, gitError } from "../contracts/result.mjs";
2
2
  import { PackTransportError } from "../protocol/packs/reader.mjs";
3
3
  import { decodeRecord } from "../store/catalogue.mjs";
4
+ import { decodePacks } from "../store/git-store.mjs";
4
5
  import { tryUnlessSpent } from "../contracts/calls-spent.mjs";
5
6
  import { resultCall } from "../store/errors.mjs";
6
- import { decodeTimes, repoStats } from "../store/repo-record.mjs";
7
+ import { decodeStats, repoStats } from "../store/repo-record.mjs";
7
8
  import { collections, newChangeId, repoScope, selfKey } from "../store/scopes.mjs";
8
9
  import { CallBudget, RequestCalls, callScope, checkedLimits, countInto, countedAs, heldCall, noScope, readScope, requestCount, stepBudget, withBound } from "../store/call-count.mjs";
9
10
  import { forkIn, noCall, resultIn } from "../store/crossing.mjs";
@@ -21,21 +22,22 @@ import { ReachCache, indexReach } from "./index-reach.mjs";
21
22
  import { indexedVisible, setReachOf } from "./index-visible.mjs";
22
23
  import { pointersOfObjects } from "./lfs-pointers.mjs";
23
24
  import { PackIndexes, packReader, seedBytes } from "./pack-reads.mjs";
24
- import { copyRowsPage } from "./object-rows.mjs";
25
+ import { copyRowsPage, noRows } from "./object-rows.mjs";
25
26
  import { pushedCommitsPage } from "./pushed-commits.mjs";
26
27
  import { segmentTooLarge } from "./links.mjs";
27
28
  import { walkWithin } from "./swap-walk.mjs";
28
29
  import { receivePack, tooMany } from "./pack-receive.mjs";
29
- import { mergesAlone, passDue, pruneStep, readPrune } from "./prune.mjs";
30
- import { unfenced } from "./merge-fence.mjs";
31
- import { geometricStep, groupedPacks, membersOf, opensWithin, resumeMerge, streamHeld } from "./merge-stream.mjs";
30
+ import { mergesAlone, passDue, passScratch, pruneStartedKey, pruneStep, readPrune } from "./prune.mjs";
31
+ import { rebuildStep } from "./graph-rebuild.mjs";
32
+ import { liftedFences, unfenced } from "./merge-fence.mjs";
33
+ import { freshCalls, geometricStep, groupedPacks, membersOf, opensWithin, resumeMerge, streamHeld } from "./merge-stream.mjs";
32
34
  import { droppedStep, mergeKey } from "./merge-row.mjs";
33
35
  import { parksPass } from "./repack-job.mjs";
34
36
  import { sharePacks } from "./quarantine.mjs";
35
37
  import { burstOptions, defaultRepack, optionFor, readObjectRows } from "./repack.mjs";
36
38
  import { containedPlan, containedWalk, countedMerge } from "./repack-contained.mjs";
37
39
  import { refuseBacklog } from "./repack-backlog.mjs";
38
- import { defaultShallow, readyAnswer, readyStep, untilEnded } from "./ready.mjs";
40
+ import { defaultShallow, readyAnswer, readyBytesOf, readyKey, readyStep, untilEnded } from "./ready.mjs";
39
41
  import { defaultPrune, pruneWait, quarantineKey } from "./rows.mjs";
40
42
  import { readAnswer, receiveStep, stageReceive } from "./receive-steps.mjs";
41
43
  import { memoryOf, openBudget } from "./packs-memory.mjs";
@@ -136,22 +138,28 @@ const rejoined = (chunks, reader) => {
136
138
  const stepLost = fail("UNAVAILABLE", "Another try of this receive's step committed first", { hint: "Try the step again" });
137
139
  const tooManyToUnpack = (count) => gitError("INVALID_ARGUMENT", `The pack's header counts ${count} objects, past what its push said`, { hint: "Push again" });
138
140
  /**
139
- * A repo's stats, read for an option given as a function: its record, refs, `stats` times and
140
- * listed packs.
141
+ * A repo's stats, read for an option given as a function: its record, refs, `stats` times, listed
142
+ * packs and ready shallow pack, all at one version, so the bytes are a total some version held.
143
+ * They're read again rather than taken from the step's `Listed`, which a repack may have moved on
144
+ * from before the ready pack's read.
141
145
  */
142
- const statsOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed) {
143
- const snapshot = yield* store.read({
144
- scope: repoScope(listed.repo),
146
+ const statsOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo) {
147
+ const [selfRows = [], refRows = [], packRows = [], timeRows = [], readyRows = []] = (yield* store.read({
148
+ scope: repoScope(repo),
145
149
  reads: [
146
150
  selfKey,
147
151
  { collection: collections.refs },
148
- { collection: collections.stats }
152
+ { collection: collections.packs },
153
+ { collection: collections.stats },
154
+ readyKey
149
155
  ]
150
- });
151
- const record = yield* decodeRecord(snapshot.results[0]?.[0]);
156
+ })).results;
157
+ const record = yield* decodeRecord(selfRows[0]);
152
158
  if (record === void 0) return yield* fail("NOT_FOUND", "The repo's record is gone");
153
- const times = yield* decodeTimes(snapshot.results[2] ?? []);
154
- return repoStats(record, snapshot.results[1]?.length ?? 0, listed.packs, times);
159
+ const packs = yield* decodePacks(packRows);
160
+ const times = yield* decodeStats(timeRows);
161
+ const readyBytes = yield* readyBytesOf(readyRows);
162
+ return repoStats(record, refRows.length, packs, times, readyBytes);
155
163
  });
156
164
  const hasChange = (step) => {
157
165
  const { add = [], remove = [], put = [], delete: deleted = [] } = step.change;
@@ -224,7 +232,10 @@ const receiveRows = /* @__PURE__ */ Effect.fnUntraced(function* (reader, unpack,
224
232
  });
225
233
  const quarantine = {
226
234
  id: newChangeId(),
227
- change: { put: unpacked.rows },
235
+ change: {
236
+ put: unpacked.rows,
237
+ rows: unpacked.moved
238
+ },
228
239
  bytes: unpacked.bytes,
229
240
  objects: unpacked.objects.length,
230
241
  lfsPointers: yield* pointersOfObjects(unpacked.objects, pointers)
@@ -427,7 +438,7 @@ const packs = (options = {}) => {
427
438
  const stage = Effect.fnUntraced(function* (listed, input) {
428
439
  const past = segmentTooLarge(input);
429
440
  if (past !== void 0) return yield* Effect.fail(past);
430
- const { quarantine: prune } = optionsFor(chosen ? yield* statsOf(calls, listed) : void 0);
441
+ const { quarantine: prune } = optionsFor(chosen ? yield* statsOf(calls, listed.repo) : void 0);
431
442
  const { boundary = [], needs = [], cutMost, length, atMost } = input;
432
443
  return yield* stageReceive({
433
444
  store: calls,
@@ -473,7 +484,7 @@ const packs = (options = {}) => {
473
484
  };
474
485
  }
475
486
  };
476
- const { quarantine: prune } = optionsFor(chosen ? yield* statsOf(calls, listed) : void 0);
487
+ const { quarantine: prune } = optionsFor(chosen ? yield* statsOf(calls, listed.repo) : void 0);
477
488
  const { objects, needs } = input;
478
489
  const receiving = {
479
490
  store: input.store,
@@ -520,7 +531,7 @@ const packs = (options = {}) => {
520
531
  */
521
532
  const seeded = (run) => Effect.scoped(Effect.flatMap(Effect.scope, (answered) => Effect.flatMap(Effect.scoped(run(answered)), (done) => done.seed === void 0 ? Effect.succeed(done.answer) : Effect.as(indexes.seed(done.seed), done.answer))));
522
533
  const receiveWithin = Effect.fnUntraced(function* (listed, input, memory, visible) {
523
- const { unpack, quarantine } = optionsFor(chosen ? yield* statsOf(calls, listed) : void 0);
534
+ const { unpack, quarantine } = optionsFor(chosen ? yield* statsOf(calls, listed.repo) : void 0);
524
535
  const held = readerOf(listed, memory.reader, void 0, visible);
525
536
  if (input.objects === 0) return yield* receiveRows(held, unpack, input, memory.pointers);
526
537
  if (unpack === false || input.objects > unpack.maxObjects) return yield* asPack(listed, input, quarantine, memory, visible);
@@ -691,7 +702,7 @@ const packs = (options = {}) => {
691
702
  more: true
692
703
  };
693
704
  return yield* Effect.flatMap(budget.upkeep(), (allotment) => upkeepSteps(listed, input, allotment, own, raw, cleaned)).pipe(Effect.catchIf((error) => error === readBusy, () => Effect.succeed({
694
- change: {},
705
+ change: { rows: noRows },
695
706
  more: false,
696
707
  due: at + growWaitMs
697
708
  })));
@@ -714,11 +725,16 @@ const packs = (options = {}) => {
714
725
  allotment
715
726
  };
716
727
  const objectRows = yield* readObjectRows(upkeep);
717
- const read = yield* readPrune(upkeep);
728
+ const prior = yield* readPrune(upkeep);
729
+ const fences = liftedFences(prior.refused, freshCalls(counted?.most));
730
+ const read = {
731
+ ...prior,
732
+ refused: fences.refused
733
+ };
718
734
  const { repack: merging, prune: pruning } = read.merges;
719
735
  const orphan = prune === false || input.deleted === true ? pruning : void 0;
720
736
  if (orphan === void 0 && merging !== void 0 && pruning === void 0 && input.steps === "prune") return {
721
- change: {},
737
+ change: { rows: noRows },
722
738
  more: false,
723
739
  yielded: true
724
740
  };
@@ -737,6 +753,16 @@ const packs = (options = {}) => {
737
753
  };
738
754
  const step = yield* Effect.gen(function* () {
739
755
  if (orphan !== void 0) return ending(droppedStep(orphan));
756
+ if (input.deleted === true && read.started !== void 0) return (yield* passScratch(upkeep, read.started.at)) === "more" ? {
757
+ change: { rows: noRows },
758
+ more: true
759
+ } : {
760
+ change: {
761
+ delete: [pruneStartedKey],
762
+ rows: noRows
763
+ },
764
+ more: true
765
+ };
740
766
  if (merging !== void 0 && input.steps !== "prune") return yield* resumeMerge(upkeep, merging, chosen === false ? defaultRepack.maxPackSize : chosen.maxPackSize ?? defaultRepack.maxPackSize, counted === void 0 ? void 0 : {
741
767
  made: counted.made,
742
768
  most: counted.most
@@ -751,10 +777,15 @@ const packs = (options = {}) => {
751
777
  more: true
752
778
  };
753
779
  if (input.steps === "prune") return pruned?.next === void 0 ? void 0 : {
754
- change: {},
780
+ change: { rows: noRows },
755
781
  more: false,
756
782
  due: pruned.next
757
783
  };
784
+ const rebuilt = yield* rebuildStep(upkeep, read.refused, counted === void 0 ? void 0 : {
785
+ made: counted.made,
786
+ most: counted.most
787
+ });
788
+ if (rebuilt !== void 0) return ending(rebuilt);
758
789
  const held = new Set(pruning?.value.inputs);
759
790
  const cruft = mergesAlone(read);
760
791
  const alone = (pack) => cruft(pack) || held.has(pack.id);
@@ -808,14 +839,14 @@ const packs = (options = {}) => {
808
839
  const behind = last === void 0 || last + wait <= at ? { pruneWait: wait } : {};
809
840
  const ended = ready ?? cleaned;
810
841
  const named = passAt === void 0 ? ended : {
811
- change: {},
842
+ change: { rows: noRows },
812
843
  more: false,
813
844
  ...ended,
814
845
  prune: passAt,
815
846
  ...behind
816
847
  };
817
848
  const idle = named ?? {
818
- change: {},
849
+ change: { rows: noRows },
819
850
  more: false
820
851
  };
821
852
  if (due === void 0) return named;
@@ -824,7 +855,7 @@ const packs = (options = {}) => {
824
855
  due
825
856
  };
826
857
  });
827
- return unfenced(step, read.refused, listed.packs);
858
+ return unfenced(step, read.refused, listed.packs, fences.lifted);
828
859
  });
829
860
  /**
830
861
  * The objects, every one, or with `visible`, only those it holds, as `seen` says. Each call
@@ -180,7 +180,7 @@ const droppedOnRefusal = (walk, input, pack, _start, _missing, options = {}) =>
180
180
  * A refused fresh walk drops its runs; one given `saved` or `known` keeps them. A test sets
181
181
  * `treesAtOnce` below its bound.
182
182
  */
183
- const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, start, missing, { rows = 0, treesAtOnce = pruneTreesAtOnce, calls, saved, known } = {}) {
183
+ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, start, missing, { rows = 0, treesAtOnce = pruneTreesAtOnce, calls, saved, known, roots } = {}) {
184
184
  const { allotment, listed } = input;
185
185
  const objects = listed.packs.reduce((sum, each) => sum + each.objects, 0) + rows;
186
186
  const blocks = listed.packs.reduce((sum, each) => sum + Math.ceil(each.bytes / blockBytes), 0);
@@ -214,7 +214,10 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
214
214
  held -= bytes;
215
215
  allotment.shrink(bytes);
216
216
  });
217
- const reads = countedReads(reader, objects + 1e6, charged, void 0, release);
217
+ const reads = countedReads(roots === void 0 ? reader : {
218
+ ...reader,
219
+ roots
220
+ }, objects + 1e6, charged, void 0, release);
218
221
  /** Where each of `oids` is for the seen set: its first listed pack and its rank there. */
219
222
  const ranksOf = Effect.fnUntraced(function* (oids) {
220
223
  const at = /* @__PURE__ */ new Map();