@ref0/git 0.12.0 → 0.14.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.
- package/dist/access/private-refs.mjs +3 -3
- package/dist/auth/auth.d.mts +2 -2
- package/dist/auth/auth.mjs +3 -6
- package/dist/auth/authorize.mjs +1 -17
- package/dist/auth/helpers.mjs +3 -11
- package/dist/auth/host-services.mjs +11 -0
- package/dist/auth/policy.d.mts +27 -7
- package/dist/auth/policy.mjs +8 -4
- package/dist/auth/tokens-layer.d.mts +1 -2
- package/dist/auth/tokens-layer.mjs +2 -3
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +1 -8
- package/dist/auth/tokens.mjs +1 -8
- package/dist/auth.d.mts +1 -4
- package/dist/auth.mjs +1 -3
- package/dist/client/git-http.mjs +18 -4
- package/dist/client/push-upload.mjs +33 -7
- package/dist/client/remote.mjs +94 -28
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/contracts/access.d.mts +8 -8
- package/dist/contracts/actors.d.mts +2 -34
- package/dist/contracts/blobs.d.mts +2 -2
- package/dist/contracts/client.d.mts +8 -3
- package/dist/contracts/commits.d.mts +10 -2
- package/dist/contracts/commits.mjs +9 -1
- package/dist/contracts/files.d.mts +2 -2
- package/dist/contracts/forks.d.mts +11 -1
- package/dist/contracts/git.d.mts +18 -7
- package/dist/contracts/git.mjs +3 -2
- package/dist/contracts/lfs.d.mts +0 -7
- package/dist/contracts/objects.d.mts +80 -10
- package/dist/contracts/operations.d.mts +3 -0
- package/dist/contracts/operations.mjs +12 -2
- package/dist/contracts/push-uploads.d.mts +44 -5
- package/dist/contracts/push-uploads.mjs +7 -3
- package/dist/contracts/refs.d.mts +28 -6
- package/dist/contracts/remote.mjs +1 -3
- package/dist/contracts/repo-records.d.mts +1 -0
- package/dist/contracts/repos.d.mts +90 -2
- package/dist/contracts/repos.mjs +29 -2
- package/dist/contracts/result.d.mts +23 -18
- package/dist/contracts/result.mjs +17 -4
- package/dist/contracts/rules.d.mts +22 -22
- package/dist/contracts/server.d.mts +28 -77
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/sync.d.mts +79 -19
- package/dist/contracts/sync.mjs +34 -10
- package/dist/contracts/tokens.d.mts +1 -6
- package/dist/contracts/tokens.mjs +1 -2
- package/dist/contracts/topics.d.mts +0 -5
- package/dist/contracts/work.d.mts +66 -2
- package/dist/contracts/work.mjs +8 -1
- package/dist/core/access.mjs +27 -5
- package/dist/core/ancestry.d.mts +9 -0
- package/dist/core/ancestry.mjs +6 -6
- package/dist/core/asked.mjs +42 -4
- package/dist/core/call-names.mjs +1 -0
- package/dist/core/call-services.mjs +2 -1
- package/dist/core/events/deliver.mjs +10 -2
- package/dist/core/forks.mjs +3 -3
- package/dist/core/imports.mjs +147 -9
- package/dist/core/index-job.mjs +9 -6
- package/dist/core/job-view.mjs +8 -9
- package/dist/core/mirror-rows.mjs +19 -4
- package/dist/core/objects/commits.mjs +16 -6
- package/dist/core/parts.d.mts +6 -1
- package/dist/core/parts.mjs +1 -4
- package/dist/core/purge.mjs +76 -6
- package/dist/core/push-decide.mjs +1 -1
- package/dist/core/push-files.d.mts +12 -0
- package/dist/core/push-files.mjs +225 -0
- package/dist/core/push-repo.d.mts +8 -0
- package/dist/core/push-repo.mjs +56 -0
- package/dist/core/push.d.mts +17 -0
- package/dist/core/push.mjs +98 -26
- package/dist/core/receipts.mjs +26 -10
- package/dist/core/ref-view.mjs +59 -5
- package/dist/core/refs.mjs +13 -8
- package/dist/core/repack.mjs +11 -8
- package/dist/core/repo-info.mjs +16 -9
- package/dist/core/repos.mjs +30 -14
- package/dist/core/seam.mjs +2 -2
- package/dist/core/view.d.mts +6 -0
- package/dist/core/view.mjs +45 -12
- package/dist/core/work.mjs +47 -22
- package/dist/effect.d.mts +3 -1
- package/dist/effect.mjs +3 -1
- package/dist/engine/reads.mjs +13 -6
- package/dist/engine/walk.mjs +4 -4
- package/dist/event-streams/event-streams.d.mts +1 -1
- package/dist/event-streams/event-streams.mjs +1 -1
- package/dist/event-streams/stream.d.mts +1 -1
- package/dist/event-streams/stream.mjs +1 -1
- package/dist/extend.d.mts +3 -3
- package/dist/extend.mjs +2 -2
- package/dist/http/answers.mjs +4 -2
- package/dist/http/core-parts.mjs +64 -15
- package/dist/http/handler.mjs +2 -2
- package/dist/http/node.mjs +5 -4
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +503 -0
- package/dist/http/push-uploads.d.mts +1 -0
- package/dist/http/push-uploads.mjs +114 -56
- package/dist/http/upload-pack.mjs +7 -6
- package/dist/index.d.mts +23 -24
- package/dist/index.mjs +4 -7
- package/dist/lfs/base.d.mts +7 -3
- package/dist/lfs/base.mjs +2 -1
- package/dist/lfs/copy.d.mts +46 -0
- package/dist/lfs/copy.mjs +26 -0
- package/dist/lfs/layer.mjs +4 -2
- package/dist/lfs/objects.d.mts +6 -0
- package/dist/lfs/objects.mjs +68 -41
- package/dist/lfs/rows.d.mts +13 -0
- package/dist/lfs/service.d.mts +1 -7
- package/dist/lfs/service.mjs +1 -9
- package/dist/lfs/upload-most.mjs +5 -5
- package/dist/node.d.mts +2 -2
- package/dist/protocol/bytes/sha256-hasher.d.mts +15 -0
- package/dist/protocol/bytes/sha256.d.mts +32 -0
- package/dist/protocol/bytes/sha256.mjs +105 -49
- package/dist/protocol/wire/advertisement.mjs +9 -4
- package/dist/protocol/wire/lines.d.mts +4 -2
- package/dist/protocol/wire/lines.mjs +11 -5
- package/dist/protocol/wire/push-uploads.mjs +13 -1
- package/dist/protocol/wire/v2.mjs +2 -2
- package/dist/protocol.d.mts +3 -1
- package/dist/protocol.mjs +3 -1
- package/dist/queue/advance.mjs +1 -1
- package/dist/queue/host.d.mts +1 -7
- package/dist/queue/host.mjs +1 -7
- package/dist/queue/layer.mjs +1 -1
- package/dist/queue/trim.mjs +1 -1
- package/dist/rest/blobs.d.mts +31 -23
- package/dist/rest/blobs.mjs +1 -1
- package/dist/rest/caller.d.mts +49 -9
- package/dist/rest/caller.mjs +1 -1
- package/dist/rest/client.d.mts +10 -3
- package/dist/rest/client.mjs +4 -0
- package/dist/rest/commits.d.mts +273 -240
- package/dist/rest/errors.d.mts +24 -4
- package/dist/rest/events.d.mts +9 -6
- package/dist/rest/events.mjs +1 -2
- package/dist/rest/files.d.mts +127 -115
- package/dist/rest/forks.d.mts +121 -97
- package/dist/rest/handler.mjs +4 -57
- package/dist/rest/handlers.d.mts +1 -1
- package/dist/rest/handlers.mjs +18 -4
- package/dist/rest/layer.mjs +2 -1
- package/dist/rest/me.d.mts +8 -4
- package/dist/rest/merges.d.mts +8 -4
- package/dist/rest/paths.mjs +1 -0
- package/dist/rest/queue.d.mts +282 -226
- package/dist/rest/refs.d.mts +205 -176
- package/dist/rest/repos.d.mts +108 -80
- package/dist/rest/tags.d.mts +24 -12
- package/dist/rest/tokens.d.mts +235 -211
- package/dist/rest/topics.d.mts +53 -33
- package/dist/rest/trees.d.mts +105 -89
- package/dist/rest/work.d.mts +467 -20
- package/dist/rest/work.mjs +8 -0
- package/dist/server/edge-node.d.mts +9 -13
- package/dist/server/edge-node.mjs +9 -12
- package/dist/server/git-layer.d.mts +1 -6
- package/dist/server/git-layer.mjs +2 -2
- package/dist/server/git-namespace.d.mts +3 -3
- package/dist/server/joined.d.mts +15 -22
- package/dist/server/joined.mjs +5 -29
- package/dist/server/lifecycle.mjs +107 -23
- package/dist/server/registry.mjs +9 -1
- package/dist/server/server.mjs +133 -212
- package/dist/storage/budget.mjs +2 -2
- package/dist/storage/clean-up.mjs +13 -10
- package/dist/storage/fetch.mjs +13 -8
- package/dist/storage/file-limits.mjs +24 -0
- package/dist/storage/index-build.d.mts +1 -0
- package/dist/storage/index-build.mjs +106 -62
- package/dist/storage/index-fetch.mjs +16 -3
- package/dist/storage/index-reach.mjs +33 -5
- package/dist/storage/index-remap.mjs +8 -1
- package/dist/storage/index-shallow.mjs +5 -3
- package/dist/storage/largest-files.mjs +48 -0
- package/dist/storage/lfs-pointers.mjs +10 -1
- package/dist/storage/loose.mjs +3 -1
- package/dist/storage/memory-budget.mjs +28 -4
- package/dist/storage/pack-reads.mjs +8 -8
- package/dist/storage/pack-receive.mjs +83 -25
- package/dist/storage/packs.mjs +37 -21
- package/dist/storage/prune-keep.mjs +203 -34
- package/dist/storage/prune-walk.mjs +54 -16
- package/dist/storage/prune.mjs +629 -196
- package/dist/storage/push-uploads.mjs +36 -12
- package/dist/storage/quarantine.mjs +9 -9
- package/dist/storage/ready.mjs +47 -19
- package/dist/storage/receive-bounds.mjs +29 -8
- package/dist/storage/receive-state.mjs +8 -0
- package/dist/storage/receive-steps.mjs +71 -18
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/repack.mjs +1 -8
- package/dist/storage/rows.mjs +12 -1
- package/dist/storage/shallow.d.mts +1 -0
- package/dist/storage/shallow.mjs +26 -4
- package/dist/storage/stream-whole.mjs +5 -2
- package/dist/storage/visible.mjs +29 -1
- package/dist/storage/walk.mjs +2 -1
- package/dist/store/catalogue.mjs +1 -0
- package/dist/store/cursor-seal-namespace.d.mts +2 -0
- package/dist/store/cursor-seal-public.d.mts +5 -0
- package/dist/store/cursor-seal-public.mjs +5 -0
- package/dist/store/cursor-seal.d.mts +16 -2
- package/dist/store/cursor-seal.mjs +26 -14
- package/dist/store/errors.mjs +9 -1
- package/dist/store/records.d.mts +2 -0
- package/dist/store/records.mjs +9 -6
- package/dist/store/repo-record.d.mts +9 -7
- package/dist/store/repo-record.mjs +102 -19
- package/dist/store/scopes.mjs +10 -2
- package/dist/sync/bound.d.mts +2 -0
- package/dist/sync/bound.mjs +11 -2
- package/dist/sync/github.d.mts +6 -1
- package/dist/sync/github.mjs +55 -43
- package/dist/sync/http.mjs +36 -1
- package/dist/sync/import.mjs +1 -0
- package/dist/sync/layer.mjs +6 -2
- package/dist/sync/lfs-batch.mjs +119 -0
- package/dist/sync/lfs-copy.mjs +251 -0
- package/dist/sync/mirror.mjs +210 -137
- package/dist/sync/smart-http.mjs +4 -2
- package/dist/sync/step.mjs +25 -5
- package/dist/sync/tries.mjs +45 -14
- package/dist/sync.d.mts +2 -2
- package/dist/topics/host.mjs +1 -19
- package/dist/topics/layer.mjs +1 -1
- package/package.json +3 -8
- package/dist/auth/bridge.mjs +0 -30
- package/dist/auth/helpers.d.mts +0 -17
- package/dist/core/purge.d.mts +0 -8
- package/dist/core/registered-rows.d.mts +0 -5
- package/dist/core/repack.d.mts +0 -11
- package/dist/http/handler.d.mts +0 -2
- package/dist/rest/handler.d.mts +0 -21
- package/dist/rest.d.mts +0 -2
- package/dist/rest.mjs +0 -1
- package/dist/server/registry.d.mts +0 -16
- package/dist/server/server.d.mts +0 -36
- package/dist/storage/repack-job.d.mts +0 -3
- package/dist/topics/host.d.mts +0 -7
|
@@ -10,7 +10,7 @@ import { runKey } from "./layout.mjs";
|
|
|
10
10
|
import { pruneIndexFloor, pruneSeenBytes, upkeepMemoryOf, upkeepRuns, upkeepTooLarge } from "./memory-budget.mjs";
|
|
11
11
|
import { blockBytes, blocksHeld, indexBytes, isIndexReloaded, isIndexShort, packReader } from "./pack-reads.mjs";
|
|
12
12
|
import { SeenSaved, seenSet } from "./prune-seen.mjs";
|
|
13
|
-
import { StoredRuns, dedupeTableBytes, dropRuns, mergeHeld, mergeRuns, narrowed, narrowedCalls, runWriter, writerHeld } from "./runs.mjs";
|
|
13
|
+
import { StoredRuns, dedupeTableBytes, dropRuns, mergeHeld, mergeRuns, narrowed, narrowedCalls, runWriter, wholeRows, writerHeld } from "./runs.mjs";
|
|
14
14
|
import { countedReads } from "./walk.mjs";
|
|
15
15
|
import * as Effect from "effect/Effect";
|
|
16
16
|
import * as Schema from "effect/Schema";
|
|
@@ -80,6 +80,15 @@ const pruneWalkSizes = (objects, blocks) => {
|
|
|
80
80
|
blocks: blocksHeld(Math.min(8, Math.max(1, blocks)))
|
|
81
81
|
};
|
|
82
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* The calls a walk `spent` makes, at most, to save where it starts, from at most `start` IDs over
|
|
85
|
+
* `objects` objects: its refs' put, and the save its first admission reserves, `5` and the IDs'
|
|
86
|
+
* puts. A try reserves them before the merge a walk follows, so the walk's start save fits.
|
|
87
|
+
*/
|
|
88
|
+
const pruneWalkStartCalls = (objects, start) => {
|
|
89
|
+
const { runBytes } = pruneWalkSizes(objects, 1);
|
|
90
|
+
return 6 + 2 * Math.ceil(Math.max(1, start) * rowBytes / runBytes);
|
|
91
|
+
};
|
|
83
92
|
/** A walk's sizes at its bounds, the most any repo's take. */
|
|
84
93
|
const boundSizes = /* @__PURE__ */ pruneWalkSizes(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);
|
|
85
94
|
/**
|
|
@@ -122,6 +131,10 @@ const WalkSaved = /* @__PURE__ */ Schema.Union([Schema.Struct({
|
|
|
122
131
|
frontier: StoredRuns,
|
|
123
132
|
at: Schema.optional(Schema.Struct({
|
|
124
133
|
last: LastId,
|
|
134
|
+
merge: Schema.Struct({
|
|
135
|
+
runs: StoredRuns,
|
|
136
|
+
places: Schema.Array(Count)
|
|
137
|
+
}),
|
|
125
138
|
reached: StoredRuns,
|
|
126
139
|
frontier: StoredRuns,
|
|
127
140
|
trees: StoredRuns
|
|
@@ -152,7 +165,8 @@ const walkKeys = (saved) => {
|
|
|
152
165
|
saved.frontier,
|
|
153
166
|
saved.at?.reached,
|
|
154
167
|
saved.at?.frontier,
|
|
155
|
-
saved.at?.trees
|
|
168
|
+
saved.at?.trees,
|
|
169
|
+
saved.at?.merge.runs
|
|
156
170
|
]).flatMap((each) => each?.keys ?? []);
|
|
157
171
|
return saved.phase === "history" ? [...keys, saved.seen.key] : keys;
|
|
158
172
|
};
|
|
@@ -169,18 +183,20 @@ const droppedOnRefusal = (walk, input, pack, _start, _missing, options = {}) =>
|
|
|
169
183
|
* frontier merged against the runs reached so far, which the merge carries on as the next
|
|
170
184
|
* level's, so a tree is read once and a blob put once, by the ID its tree names and never read.
|
|
171
185
|
* `missing` says what an object the repo doesn't hold does to the walk: a tree it passes over is
|
|
172
|
-
* marked reached, unread, so a keep of these runs is given the same `missing` (`
|
|
173
|
-
* fails on the mark. The empty tree is the reader's, held or not, as `
|
|
186
|
+
* marked reached, unread, so a keep of these runs is given the same `missing` (`keepBitsOn`), or
|
|
187
|
+
* fails on the mark. The empty tree is the reader's, held or not, as `keepBitsOn` holds it.
|
|
174
188
|
*
|
|
175
189
|
* With `calls`, a step whose forecast passes what the try has left isn't started: the walk ends
|
|
176
190
|
* with `more`, where it stopped, a history batch, a tree level or a tree partway through one, and a
|
|
177
191
|
* try given it as `saved` goes on from there, never from `start`. A batch reads as many objects as
|
|
178
|
-
* their delta chains' gets fit. A step that passes a whole try is refused by name
|
|
192
|
+
* their delta chains' gets fit. A step that passes a whole try is refused by name, but in a walk
|
|
193
|
+
* `spent`, after the try's other calls: it ends with `more`, where it was given or where it
|
|
194
|
+
* starts, for a fresh try to go on from.
|
|
179
195
|
* `known`'s rows, from an earlier walk, are reached already: a tree they hold isn't read again.
|
|
180
196
|
* A refused fresh walk drops its runs; one given `saved` or `known` keeps them. A test sets
|
|
181
197
|
* `treesAtOnce` below its bound.
|
|
182
198
|
*/
|
|
183
|
-
const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, start, missing, { rows = 0, treesAtOnce = pruneTreesAtOnce, calls, saved, known, roots } = {}) {
|
|
199
|
+
const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, start, missing, { rows = 0, treesAtOnce = pruneTreesAtOnce, calls, saved, known, roots, spent = false } = {}) {
|
|
184
200
|
const { allotment, listed } = input;
|
|
185
201
|
const objects = listed.packs.reduce((sum, each) => sum + each.objects, 0) + rows;
|
|
186
202
|
const blocks = listed.packs.reduce((sum, each) => sum + Math.ceil(each.bytes / blockBytes), 0);
|
|
@@ -205,7 +221,7 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
205
221
|
const canLoad = () => {
|
|
206
222
|
const needs = loadNeeds();
|
|
207
223
|
loads += 1;
|
|
208
|
-
if (loads === 1 || fits(calls, needs)) return true;
|
|
224
|
+
if (loads === 1 && !spent || fits(calls, needs)) return true;
|
|
209
225
|
shortBy = needs;
|
|
210
226
|
return false;
|
|
211
227
|
};
|
|
@@ -320,6 +336,17 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
320
336
|
const reads = merged.lengths.reduce((sum, length) => sum + Math.ceil(length / readBytes), 0);
|
|
321
337
|
return reads + (merged.keys.length > ways ? reads + Math.ceil(merged.keys.length / ways) : 0) + putCalls(objects) + 1;
|
|
322
338
|
};
|
|
339
|
+
/**
|
|
340
|
+
* What a merge going on from its save's places calls yet, a forecast: each run's reads from its
|
|
341
|
+
* place's read, as `mergeRuns` seeks it, none narrowing, and its reached writer's puts (#2231).
|
|
342
|
+
*/
|
|
343
|
+
const restCalls = (merge) => {
|
|
344
|
+
const readBytes = wholeRows(rowBytes, sizes.runs.readBytes);
|
|
345
|
+
return merge.runs.lengths.reduce((sum, length, run) => {
|
|
346
|
+
const start = (merge.places[run] ?? 0) * rowBytes;
|
|
347
|
+
return start >= length ? sum : sum + Math.ceil((length - start + start % readBytes) / readBytes);
|
|
348
|
+
}, 0) + putCalls(objects) + 1;
|
|
349
|
+
};
|
|
323
350
|
const saveCalls = 3 + putCalls(atOnce);
|
|
324
351
|
const findCalls = 2;
|
|
325
352
|
const headerGets = 2;
|
|
@@ -384,6 +411,7 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
384
411
|
let moved = false;
|
|
385
412
|
const most = calls === void 0 ? 0 : Math.min(calls.most.bucket, calls.most.subrequests);
|
|
386
413
|
const tooMany = (step, needs) => new PruneWalkTooLarge({ message: `${step} needs about ${needs} calls, past the ${most} a try makes` });
|
|
414
|
+
const given = spent && saved !== void 0 ? { more: saved } : void 0;
|
|
387
415
|
const pastRoom = (step) => new PruneWalkTooLarge({ message: `${step} needs more packs' indexes than the ${room.bytes} bytes its reader holds` });
|
|
388
416
|
let refs;
|
|
389
417
|
if (saved === void 0) {
|
|
@@ -407,7 +435,7 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
407
435
|
let seenFrom;
|
|
408
436
|
if (history !== void 0) {
|
|
409
437
|
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 + (history.seen.outside === 0 ? 0 : 3 * listed.packs.filter(({ id }) => !history.seen.packs.some((each) => each.id === id)).length);
|
|
410
|
-
if (!fits(calls, rebuild + 6)) return yield* tooMany("a history resume", rebuild + 6);
|
|
438
|
+
if (!fits(calls, rebuild + 6)) return given ?? (yield* tooMany("a history resume", rebuild + 6));
|
|
411
439
|
const bytes = yield* readWhole(input.bucket, history.seen.key);
|
|
412
440
|
if (bytes === void 0) return yield* Effect.fail(gitError("DATA_LOSS", `The walk's seen object ${history.seen.key} is gone`));
|
|
413
441
|
seenFrom = {
|
|
@@ -455,7 +483,7 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
455
483
|
} };
|
|
456
484
|
});
|
|
457
485
|
/** The try ended where it is: saved, or refused if it walked nothing. */
|
|
458
|
-
const stopHere = () => moved ? savedHistory() : Effect.fail(shortBy === void 0 ? pastRoom("a history batch") : tooMany("a history batch", shortBy));
|
|
486
|
+
const stopHere = () => moved || spent ? given !== void 0 && !moved ? Effect.succeed(given) : savedHistory() : Effect.fail(shortBy === void 0 ? pastRoom("a history batch") : tooMany("a history batch", shortBy));
|
|
459
487
|
/**
|
|
460
488
|
* The next IDs to read, the names' before the parents': those the first pack that holds some
|
|
461
489
|
* of them holds, as `nextPack` finds it, or all of them once no listed pack holds any;
|
|
@@ -496,7 +524,8 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
496
524
|
}
|
|
497
525
|
const { count: admits, needs } = admission;
|
|
498
526
|
if (admits === 0) {
|
|
499
|
-
if (!moved
|
|
527
|
+
if (!moved && given !== void 0) return given;
|
|
528
|
+
if (!moved && !spent) return yield* tooMany("a history batch", needs);
|
|
500
529
|
back(at);
|
|
501
530
|
return yield* savedHistory();
|
|
502
531
|
}
|
|
@@ -548,13 +577,14 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
548
577
|
let within = saved?.phase === "trees" ? saved.at : void 0;
|
|
549
578
|
for (let depth = from + 1; next.rows > 0; depth += 1) {
|
|
550
579
|
const merged = joined(runs, next, `join-${depth}.${tried}`);
|
|
551
|
-
const reserve = mergeCalls(merged);
|
|
552
580
|
const goesOn = within;
|
|
553
581
|
within = void 0;
|
|
582
|
+
const reserve = goesOn === void 0 ? mergeCalls(merged) : restCalls(goesOn.merge);
|
|
554
583
|
const needs = reserve + 2 + saveCalls;
|
|
555
584
|
loadNeeds = () => 3 + reserve + saveCalls;
|
|
556
585
|
if (!fits(calls, needs)) {
|
|
557
|
-
if (!moved
|
|
586
|
+
if (!moved && given !== void 0) return given;
|
|
587
|
+
if (!moved && !spent) return yield* tooMany(`level ${depth}`, needs);
|
|
558
588
|
return { more: {
|
|
559
589
|
phase: "trees",
|
|
560
590
|
commits,
|
|
@@ -568,6 +598,8 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
568
598
|
const frontier = frontierWriter(`frontier-${depth}`);
|
|
569
599
|
let trees = [];
|
|
570
600
|
const last = goesOn === void 0 ? /* @__PURE__ */ new Uint8Array(20) : oidBytes(goesOn.last);
|
|
601
|
+
const few = goesOn?.merge.runs ?? (yield* narrowed(input.bucket, pack, merged, sizes.runs));
|
|
602
|
+
let placesOf;
|
|
571
603
|
const readTrees = Effect.fnUntraced(function* () {
|
|
572
604
|
while (trees.length > 0) {
|
|
573
605
|
const [asked, rest] = alone(trees);
|
|
@@ -621,7 +653,8 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
621
653
|
yield* eachOf(goesOn.trees, (id) => void trees.push(hexOf(id)));
|
|
622
654
|
yield* readTrees();
|
|
623
655
|
}
|
|
624
|
-
yield* mergeRuns(input.bucket, pack,
|
|
656
|
+
yield* mergeRuns(input.bucket, pack, few, (bytes, at, _run, places) => {
|
|
657
|
+
placesOf = places;
|
|
625
658
|
if (!pastId(bytes, at, last)) return void 0;
|
|
626
659
|
const id = bytes.subarray(at, at + 20);
|
|
627
660
|
last.set(id);
|
|
@@ -631,18 +664,23 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
631
664
|
if (tag !== tags.tree) return marked;
|
|
632
665
|
trees.push(hexOf(id));
|
|
633
666
|
return trees.length < atOnce ? marked : Effect.andThen(marked, readTrees());
|
|
634
|
-
}, sizes.runs);
|
|
667
|
+
}, sizes.runs, void 0, goesOn?.merge.places);
|
|
635
668
|
if (trees.length > 0) yield* readTrees();
|
|
636
669
|
});
|
|
637
670
|
const stopped = yield* Effect.as(walked, void 0).pipe(Effect.catchTag("WalkStopped", (stop) => Effect.succeed(stop)));
|
|
638
671
|
if (stopped !== void 0) {
|
|
639
|
-
if (!moved
|
|
672
|
+
if (!moved && given !== void 0) return given;
|
|
673
|
+
if (!moved && !spent) return yield* stopped.reloaded === true ? pastRoom(`a tree at level ${depth}`) : tooMany(`a tree at level ${depth}`, stopped.needs);
|
|
640
674
|
const levelRuns = after(goesOn?.reached, yield* level.finish);
|
|
641
675
|
const frontierRuns = after(goesOn?.frontier, yield* frontier.finish);
|
|
642
676
|
const pending = writer(`trees-${depth}`, sizes.runBytes);
|
|
643
677
|
for (const oid of [...stopped.trees, ...trees]) yield* put(pending, oidBytes(oid), tags.tree);
|
|
644
678
|
const at = {
|
|
645
679
|
last: hexOf(last),
|
|
680
|
+
merge: {
|
|
681
|
+
runs: few,
|
|
682
|
+
places: placesOf?.() ?? goesOn?.merge.places ?? few.keys.map(() => 0)
|
|
683
|
+
},
|
|
646
684
|
reached: levelRuns,
|
|
647
685
|
frontier: frontierRuns,
|
|
648
686
|
trees: yield* pending.finish
|
|
@@ -666,4 +704,4 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
666
704
|
refs
|
|
667
705
|
};
|
|
668
706
|
}, droppedOnRefusal);
|
|
669
|
-
export { PruneWalkTooLarge, WalkSaved, pruneTreesAtOnce, pruneWalk, pruneWalkHeld, pruneWalkSizes, pruneWalkTables, reachedRunBytes, walkKeys };
|
|
707
|
+
export { PruneWalkTooLarge, WalkSaved, fits, pruneTreesAtOnce, pruneWalk, pruneWalkHeld, pruneWalkSizes, pruneWalkStartCalls, pruneWalkTables, reachedRunBytes, walkKeys };
|