@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.
- package/dist/access/private-refs.mjs +0 -2
- package/dist/auth/authorize.mjs +31 -24
- package/dist/auth/bridge.mjs +8 -8
- package/dist/auth/fences.d.mts +0 -1
- package/dist/auth/fences.mjs +1 -1
- package/dist/auth/grants.d.mts +0 -1
- package/dist/auth/grants.mjs +2 -2
- package/dist/auth/host-function.d.mts +1 -7
- package/dist/auth/host-function.mjs +38 -38
- package/dist/auth/identify.d.mts +0 -1
- package/dist/auth/identify.mjs +1 -1
- package/dist/auth/policy.d.mts +7 -4
- package/dist/auth/policy.mjs +13 -10
- package/dist/auth/token-rows.mjs +2 -5
- package/dist/auth/tokens-layer.d.mts +0 -2
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens-public.mjs +4 -2
- package/dist/auth/tokens.d.mts +6 -1
- package/dist/auth/tokens.mjs +7 -1
- package/dist/client/client.d.mts +22 -15
- package/dist/client/client.mjs +31 -27
- package/dist/client/git-http.mjs +22 -5
- package/dist/client/local.mjs +1 -1
- package/dist/client/namespace.d.mts +2 -0
- package/dist/client/push-upload.d.mts +1 -0
- package/dist/client/push-upload.mjs +169 -2
- package/dist/client/remote-helper.mjs +2 -4
- package/dist/client/remote.mjs +37 -15
- package/dist/client/run-remote-helper.mjs +4 -4
- package/dist/client/transport.mjs +26 -19
- package/dist/contracts/actors.d.mts +57 -28
- package/dist/contracts/actors.mjs +38 -2
- package/dist/contracts/authorize.d.mts +21 -15
- package/dist/contracts/callers.mjs +40 -0
- package/dist/contracts/calls-spent.d.mts +2 -12
- package/dist/contracts/calls-spent.mjs +4 -5
- package/dist/contracts/client.d.mts +16 -9
- package/dist/contracts/events.d.mts +82 -14
- package/dist/contracts/events.mjs +35 -9
- package/dist/contracts/files.d.mts +42 -42
- package/dist/contracts/forks.d.mts +0 -24
- package/dist/contracts/git-hooks.d.mts +217 -0
- package/dist/contracts/git-hooks.mjs +3 -1
- package/dist/contracts/git.d.mts +13 -3
- package/dist/contracts/grants.d.mts +46 -27
- package/dist/contracts/lfs.d.mts +17 -4
- package/dist/contracts/merges.d.mts +7 -7
- package/dist/contracts/objects.d.mts +38 -4
- package/dist/contracts/opaque.mjs +19 -1
- package/dist/contracts/operations.d.mts +8 -1
- package/dist/contracts/operations.mjs +209 -0
- package/dist/contracts/queue.d.mts +6 -5
- package/dist/contracts/queue.mjs +9 -20
- package/dist/contracts/remote.d.mts +13 -4
- package/dist/contracts/remote.mjs +3 -3
- package/dist/contracts/repos.d.mts +11 -40
- package/dist/contracts/repos.mjs +11 -10
- package/dist/contracts/result.d.mts +28 -11
- package/dist/contracts/result.mjs +32 -2
- package/dist/contracts/rules.d.mts +706 -46
- package/dist/contracts/rules.mjs +81 -2
- package/dist/contracts/server.d.mts +5 -275
- package/dist/contracts/services.d.mts +0 -3
- package/dist/contracts/services.mjs +1 -3
- package/dist/contracts/signin.d.mts +2 -2
- package/dist/contracts/signin.mjs +4 -5
- package/dist/contracts/sync.d.mts +1 -4
- package/dist/contracts/tokens.d.mts +29 -17
- package/dist/contracts/tokens.mjs +14 -3
- package/dist/contracts/topics.d.mts +38 -11
- package/dist/contracts/topics.mjs +8 -2
- package/dist/core/access.d.mts +0 -2
- package/dist/core/access.mjs +15 -4
- package/dist/core/ancestry.mjs +5 -4
- package/dist/core/events/deliver.mjs +19 -1
- package/dist/core/forks.mjs +30 -11
- package/dist/core/hooks/groups.d.mts +0 -1
- package/dist/core/hooks/groups.mjs +8 -9
- package/dist/core/index-job.mjs +23 -1
- package/dist/core/index-lost.d.mts +11 -0
- package/dist/core/index-lost.mjs +55 -0
- package/dist/core/loose-tally.mjs +46 -0
- package/dist/core/objects/commit-writes.mjs +1 -1
- package/dist/core/objects/commits.mjs +10 -9
- package/dist/core/objects/merges.mjs +1 -1
- package/dist/core/objects/reading.mjs +28 -13
- package/dist/core/objects/trees.mjs +1 -1
- package/dist/core/objects/writing.mjs +1 -0
- package/dist/core/parts.d.mts +7 -0
- package/dist/core/promise.mjs +1 -15
- package/dist/core/publish.mjs +9 -5
- package/dist/core/purge.mjs +30 -12
- package/dist/core/push.mjs +39 -16
- package/dist/core/ref-view.mjs +14 -6
- package/dist/core/repack.mjs +54 -27
- package/dist/core/repo-info.mjs +8 -6
- package/dist/core/repos.mjs +1 -0
- package/dist/core/rules/check.mjs +10 -10
- package/dist/core/rules/context.d.mts +3 -1
- package/dist/core/rules/context.mjs +16 -13
- package/dist/core/rules/fetch.mjs +17 -23
- package/dist/core/tokens.mjs +2 -1
- package/dist/core/view.d.mts +10 -1
- package/dist/core/view.mjs +15 -6
- package/dist/effect.d.mts +3 -6
- package/dist/effect.mjs +3 -6
- package/dist/engine/commits.mjs +23 -50
- package/dist/engine/failures.d.mts +1 -2
- package/dist/engine/failures.mjs +1 -3
- package/dist/engine/merge-base-walk.mjs +57 -142
- package/dist/engine/merge-bases.mjs +9 -7
- package/dist/engine/merge.mjs +20 -17
- package/dist/engine/parts.d.mts +1 -0
- package/dist/engine/parts.mjs +1 -1
- package/dist/engine/walk.mjs +15 -11
- package/dist/extend.d.mts +1 -2
- package/dist/extend.mjs +1 -2
- package/dist/http/core-parts.mjs +18 -10
- package/dist/http/handler.mjs +11 -31
- package/dist/http/parts.d.mts +0 -1
- package/dist/index.d.mts +29 -22
- package/dist/index.mjs +5 -2
- package/dist/lfs/base.d.mts +6 -3
- package/dist/lfs/base.mjs +2 -1
- package/dist/lfs/layer.d.mts +4 -3
- package/dist/lfs/layer.mjs +23 -9
- package/dist/lfs/objects.mjs +93 -41
- package/dist/lfs/pointers.mjs +69 -18
- package/dist/lfs/purge.mjs +6 -2
- package/dist/lfs/rows.mjs +24 -7
- package/dist/lfs/service.d.mts +6 -3
- package/dist/lfs/service.mjs +8 -2
- package/dist/lfs/upkeep.mjs +47 -28
- package/dist/lfs/upload-most.mjs +47 -0
- package/dist/lfs/uploaded.mjs +59 -0
- package/dist/protocol/bytes/sha256-hasher.mjs +51 -0
- package/dist/protocol/bytes/streams.mjs +84 -2
- package/dist/protocol/bytes/text.mjs +6 -1
- package/dist/protocol/diff/read.d.mts +1 -0
- package/dist/protocol/diff/read.mjs +5 -2
- package/dist/protocol/objects/commit.d.mts +7 -0
- package/dist/protocol/objects/commit.mjs +5 -1
- package/dist/protocol/objects/fsck.mjs +6 -3
- package/dist/queue/advance.mjs +77 -18
- package/dist/queue/calls.mjs +4 -14
- package/dist/queue/host.d.mts +4 -0
- package/dist/queue/lanes.mjs +1 -1
- package/dist/queue/layer.mjs +4 -2
- package/dist/queue/limits.mjs +18 -2
- package/dist/queue/rows.mjs +10 -1
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/search.mjs +3 -4
- package/dist/queue/trim.mjs +2 -2
- package/dist/rest/client-namespace.d.mts +2 -0
- package/dist/rest/client.d.mts +32 -8
- package/dist/rest/client.mjs +308 -382
- package/dist/rest/commits.d.mts +150 -150
- package/dist/rest/files.d.mts +18 -18
- package/dist/rest/forks.d.mts +77 -89
- package/dist/rest/handlers.mjs +2 -1
- package/dist/rest/listen.d.mts +8 -6
- package/dist/rest/listen.mjs +31 -75
- package/dist/rest/me.d.mts +2 -2
- package/dist/rest/merges.d.mts +7 -7
- package/dist/rest/refs.d.mts +27 -27
- package/dist/rest/repos.d.mts +40 -52
- package/dist/rest/tokens.d.mts +12 -12
- package/dist/rest/topics.d.mts +13 -13
- package/dist/rest/trees.d.mts +66 -66
- package/dist/rest/wire.d.mts +20 -2
- package/dist/rest/work.d.mts +39 -39
- package/dist/rest.d.mts +1 -7
- package/dist/rest.mjs +1 -5
- package/dist/server/git-layer.d.mts +10 -2
- package/dist/server/git-layer.mjs +29 -10
- package/dist/server/joined.d.mts +12 -6
- package/dist/server/joined.mjs +3 -2
- package/dist/server/registry.mjs +11 -5
- package/dist/server/server.d.mts +0 -1
- package/dist/server/server.mjs +42 -49
- package/dist/signin/context.d.mts +0 -1
- package/dist/signin/context.mjs +5 -9
- package/dist/storage/clean-up.mjs +3 -1
- package/dist/storage/fsck.mjs +12 -2
- package/dist/storage/graph-rebuild.mjs +262 -0
- package/dist/storage/index-bitmaps.mjs +16 -10
- package/dist/storage/index-build.mjs +160 -24
- package/dist/storage/index-graph.d.mts +1 -0
- package/dist/storage/index-graph.mjs +29 -5
- package/dist/storage/index-layers.d.mts +1 -0
- package/dist/storage/index-layers.mjs +5 -2
- package/dist/storage/index-reach.mjs +7 -5
- package/dist/storage/index-remap.mjs +5 -5
- package/dist/storage/index-visible.mjs +16 -5
- package/dist/storage/lfs-pointers.d.mts +5 -5
- package/dist/storage/lfs-pointers.mjs +37 -11
- package/dist/storage/links.mjs +3 -3
- package/dist/storage/loose.mjs +4 -1
- package/dist/storage/memory-budget.mjs +1 -1
- package/dist/storage/merge-fence.mjs +81 -19
- package/dist/storage/merge-most.mjs +1 -0
- package/dist/storage/merge-row.mjs +16 -4
- package/dist/storage/merge-stream.mjs +9 -6
- package/dist/storage/object-rows.mjs +17 -1
- package/dist/storage/pack-order.d.mts +1 -0
- package/dist/storage/pack-order.mjs +18 -1
- package/dist/storage/pack-receive.mjs +10 -6
- package/dist/storage/packs.mjs +58 -27
- package/dist/storage/prune-walk.mjs +5 -2
- package/dist/storage/prune.mjs +168 -70
- package/dist/storage/ready.d.mts +1 -1
- package/dist/storage/ready.mjs +12 -3
- package/dist/storage/receive-bounds.mjs +3 -2
- package/dist/storage/receive-state.mjs +1 -1
- package/dist/storage/repack-contained.mjs +22 -14
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/repack.mjs +3 -2
- package/dist/storage/unpack.mjs +7 -0
- package/dist/storage/visible.mjs +3 -2
- package/dist/storage/walk.d.mts +1 -0
- package/dist/storage/walk.mjs +9 -5
- package/dist/storage/wants.mjs +17 -11
- package/dist/store/call-count.d.mts +31 -3
- package/dist/store/call-count.mjs +51 -20
- package/dist/store/errors.d.mts +7 -1
- package/dist/store/errors.mjs +7 -1
- package/dist/store/job-try.mjs +3 -1
- package/dist/store/records.mjs +26 -5
- package/dist/store/repo-record.mjs +36 -12
- package/dist/store/scopes.mjs +15 -2
- package/dist/sync/bound.d.mts +1 -1
- package/dist/sync/import.mjs +15 -3
- package/dist/sync/layer.d.mts +5 -1
- package/dist/sync/layer.mjs +11 -9
- package/dist/sync/mirror.mjs +1 -1
- package/dist/sync/step.mjs +15 -15
- package/dist/topics/advance.mjs +11 -10
- package/dist/topics/layer.mjs +1 -1
- package/dist/topics/members.mjs +38 -9
- package/package.json +3 -3
- package/dist/engine/merge-base-walk.d.mts +0 -3
- package/dist/server/routes.d.mts +0 -32
- package/dist/server/routes.mjs +0 -69
- package/dist/sync/bridge.d.mts +0 -6
- package/dist/sync/bridge.mjs +0 -29
|
@@ -6,6 +6,8 @@ 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
8
|
import { rawLinks } from "../protocol/objects/links-raw.mjs";
|
|
9
|
+
import { rootsOf } from "../store/repo-record.mjs";
|
|
10
|
+
import { repoRootsKey, repoScope } from "../store/scopes.mjs";
|
|
9
11
|
import { randomText } from "../store/random.mjs";
|
|
10
12
|
import { allottableOf, uploadPartBytes } from "./budget.mjs";
|
|
11
13
|
import { bucketDo, bucketPut, joined, readWhole, sizedPutCalls, streamedPutCalls } from "./calls.mjs";
|
|
@@ -114,6 +116,11 @@ const IndexData = /* @__PURE__ */ Schema.Struct({
|
|
|
114
116
|
narrowed: Schema.optionalKey(Schema.suspend(() => Narrowed)),
|
|
115
117
|
/** The parts of the bitmaps step's walks below that earlier tries closed: none, no part. */
|
|
116
118
|
reaches: Schema.optionalKey(Count),
|
|
119
|
+
/**
|
|
120
|
+
* `false`: the bitmaps step chooses no commit below its layer, as a try that chose some gave
|
|
121
|
+
* them up when its bound ran out before a walk below closed (#2187). None: it chooses them.
|
|
122
|
+
*/
|
|
123
|
+
dense: Schema.optionalKey(Schema.Literal(false)),
|
|
117
124
|
/** A whole build's bitmaps written so far, a part a try: none before its first part. */
|
|
118
125
|
bitmapsCut: Schema.optionalKey(Schema.suspend(() => BitmapsCut))
|
|
119
126
|
});
|
|
@@ -168,13 +175,17 @@ const IndexRefusal = /* @__PURE__ */ Schema.Struct({
|
|
|
168
175
|
* builds it replaced, still in prune's grace. A reader takes every layer from this one row, so
|
|
169
176
|
* it never mixes layers of two versions. Each layer's region IDs are its `.region` file, so a
|
|
170
177
|
* row that leaves after the build changes nothing. `rounds` is how many rounds of tries the repo
|
|
171
|
-
* had used once it was built, or once its update's were spent, as a refused row's.
|
|
178
|
+
* had used once it was built, or once its update's were spent, as a refused row's. `lost` marks
|
|
179
|
+
* a row whose files a read found failing their own checks (`lostIndexRow`): no read answers from
|
|
180
|
+
* it, and the next try builds whole, its row unmarked (Q839 (5)). A refusal over its layers keeps
|
|
181
|
+
* the mark, and so does every other row that keeps them: only a whole build's row drops it.
|
|
172
182
|
*/
|
|
173
183
|
const BuiltIndex = /* @__PURE__ */ Schema.Struct({
|
|
174
184
|
rounds: Count,
|
|
175
185
|
layers: Schema.Array(IndexLayer),
|
|
176
186
|
replaced: Schema.Array(ReplacedBuild),
|
|
177
|
-
refusal: Schema.optionalKey(IndexRefusal)
|
|
187
|
+
refusal: Schema.optionalKey(IndexRefusal),
|
|
188
|
+
lost: Schema.optionalKey(Schema.Literal(true))
|
|
178
189
|
});
|
|
179
190
|
/** How long a repo waits after its first refusal for spent tries before a push saves more. */
|
|
180
191
|
const triesWait = 864e5;
|
|
@@ -228,8 +239,30 @@ const decodeRowOption = /* @__PURE__ */ Schema.decodeUnknownOption(IndexRow);
|
|
|
228
239
|
const builtOf = (row) => row === void 0 || "refused" in row || row.layers.length === 0 ? void 0 : row;
|
|
229
240
|
/** An `index` row's value decoded, at the read's boundary: none for one unreadable. */
|
|
230
241
|
const decodeIndexValue = decodeRowOption;
|
|
231
|
-
/**
|
|
232
|
-
|
|
242
|
+
/**
|
|
243
|
+
* A decoded `index` row as a built index a read answers from, or `undefined` for none, a refusal,
|
|
244
|
+
* no layers, or one marked `lost`, which covers nothing until it's built again.
|
|
245
|
+
*/
|
|
246
|
+
const builtIndexOf = (row) => {
|
|
247
|
+
const built = builtOf(Option.getOrUndefined(row));
|
|
248
|
+
return built?.lost === true ? void 0 : built;
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* The `index` row `row` marked lost, for a read that found its files failing their own checks to
|
|
252
|
+
* commit with the row's `git.index` round, or `undefined` when it's no built index or one marked
|
|
253
|
+
* already. Its readers then cover nothing, and the try builds whole, as over a `.bitmaps` gone,
|
|
254
|
+
* which a payload that fails its checks under a sound table never shows the try.
|
|
255
|
+
*/
|
|
256
|
+
const lostIndexRow = (row) => {
|
|
257
|
+
const built = builtOf(indexRowOf(row));
|
|
258
|
+
return built === void 0 || built.lost === true ? void 0 : {
|
|
259
|
+
...row,
|
|
260
|
+
value: {
|
|
261
|
+
...built,
|
|
262
|
+
lost: true
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
};
|
|
233
266
|
/** A prune's end, with when the next file it kept is due. */
|
|
234
267
|
const prunedAt = (due) => due === void 0 ? { kind: "pruned" } : {
|
|
235
268
|
kind: "pruned",
|
|
@@ -255,6 +288,12 @@ const most = {
|
|
|
255
288
|
*/
|
|
256
289
|
const edgesMost = 12582912;
|
|
257
290
|
const madeMost = 8388608;
|
|
291
|
+
/**
|
|
292
|
+
* The most graph entries `denseBelow` reads in a try bounded to `bucket` calls: a quarter of them
|
|
293
|
+
* at two a commit, its entry and its ID, so the try's walks below keep the rest. Taken from the
|
|
294
|
+
* bound alone, never from what a try has spent, so each try chooses the same commits.
|
|
295
|
+
*/
|
|
296
|
+
const denseBelowReads = (bucket) => Math.floor(bucket / 8);
|
|
258
297
|
/** The listing's packs in position order: biggest first, ties by ID. */
|
|
259
298
|
const positionOrder = (packs) => [...packs].sort((a, b) => b.bytes - a.bytes || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
260
299
|
/** A put that found its key there: a try that died after its put landed, done again. */
|
|
@@ -601,9 +640,11 @@ const regionStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, d
|
|
|
601
640
|
const files = indexFiles(listed.repo, data.build);
|
|
602
641
|
const { layout, first, packed } = yield* layoutOf(bucket, listed, data);
|
|
603
642
|
const held = data.below.length === 0 ? void 0 : yield* heldBelow(parts, listed, layout, first);
|
|
643
|
+
const roots = yield* rootsAt(parts, listed);
|
|
604
644
|
const links = new SliceLinks((bytes) => allotment.tryGrow(bytes));
|
|
605
645
|
const types = [];
|
|
606
646
|
const commits = [];
|
|
647
|
+
const rootPositions = /* @__PURE__ */ new Set();
|
|
607
648
|
const parsed = Effect.fnUntraced(function* (object, at) {
|
|
608
649
|
types.push(typeCodes[object.type]);
|
|
609
650
|
if (object.type === "blob") return;
|
|
@@ -620,6 +661,7 @@ const regionStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, d
|
|
|
620
661
|
oid: object.oid,
|
|
621
662
|
parents: named.slice(1)
|
|
622
663
|
});
|
|
664
|
+
if (roots.has(object.oid)) rootPositions.add(packed + at);
|
|
623
665
|
}
|
|
624
666
|
});
|
|
625
667
|
const read = yield* readRegion(parts, listed, (row, at) => Effect.gen(function* () {
|
|
@@ -639,7 +681,7 @@ const regionStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, d
|
|
|
639
681
|
const targets = yield* joinCharged(links, layout.ranges, region, allotment);
|
|
640
682
|
const slice = data.slices.length;
|
|
641
683
|
yield* allotment.grow(edgesMostOf(links) + read.rows + graphFileBytes(commits));
|
|
642
|
-
const edges = edgesFileOf(files.edges(slice, read.rows), packed, read.rows, links, targets);
|
|
684
|
+
const edges = edgesFileOf(files.edges(slice, read.rows), packed, read.rows, links, targets, rootPositions);
|
|
643
685
|
yield* putOnce(bucket, edges.slice.key, edges.bytes);
|
|
644
686
|
yield* putOnce(bucket, files.typesPart(slice, read.rows), Uint8Array.from(types));
|
|
645
687
|
yield* putOnce(bucket, files.basesPart(slice, read.rows), /* @__PURE__ */ new Uint8Array(0));
|
|
@@ -666,6 +708,15 @@ const heldBelow = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, la
|
|
|
666
708
|
return held;
|
|
667
709
|
});
|
|
668
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]));
|
|
719
|
+
/**
|
|
669
720
|
* What the region holds of each row past its links: its ID, twice while the IDs grow, its type,
|
|
670
721
|
* and a commit's entry and its ID as text, rounded up.
|
|
671
722
|
*/
|
|
@@ -684,7 +735,8 @@ const graphStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, da
|
|
|
684
735
|
graphs,
|
|
685
736
|
key: files.graph,
|
|
686
737
|
allotment,
|
|
687
|
-
most: parts.graphMost
|
|
738
|
+
most: parts.graphMost,
|
|
739
|
+
roots: yield* rootsAt(parts, listed)
|
|
688
740
|
};
|
|
689
741
|
if (below !== void 0) graphInput.below = below;
|
|
690
742
|
const written = (yield* storedSize(parts.bucket, files.graph)) === void 0 ? yield* writeIndexGraph(graphInput) : {
|
|
@@ -733,6 +785,7 @@ const storedTypesOf = (bucket, files, slices, base) => Effect.fnUntraced(functio
|
|
|
733
785
|
*/
|
|
734
786
|
const readStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, allotment) {
|
|
735
787
|
const { counted } = parts;
|
|
788
|
+
const roots = yield* rootsAt(parts, listed);
|
|
736
789
|
const counts = data.packs.map((id) => listed.packs.find((each) => each.id === id)?.objects ?? 0);
|
|
737
790
|
const bounds = parts.bounds ?? sliceBounds;
|
|
738
791
|
const entries = data.narrowed?.entries ?? bounds.entries ?? 65536;
|
|
@@ -793,7 +846,8 @@ const readStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, dat
|
|
|
793
846
|
calls: counted === void 0 ? void 0 : {
|
|
794
847
|
made: () => counted.made().bucket,
|
|
795
848
|
most: counted.most.bucket - reserve.bucket
|
|
796
|
-
}
|
|
849
|
+
},
|
|
850
|
+
roots
|
|
797
851
|
});
|
|
798
852
|
through = parts.bucket;
|
|
799
853
|
if (slice.spent !== void 0) return withNarrowed(data, narrowedAfter(data.narrowed, at.position, {
|
|
@@ -806,7 +860,7 @@ const readStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, dat
|
|
|
806
860
|
const targets = yield* joinCharged(links, ranges, region, allotment);
|
|
807
861
|
yield* allotment.grow(edgesMostOf(links) + slice.bases.length * 4);
|
|
808
862
|
const positions = slice.types.length;
|
|
809
|
-
const made = edgesFileOf(files.edges(number, positions), first, positions, links, targets);
|
|
863
|
+
const made = edgesFileOf(files.edges(number, positions), first, positions, links, targets, slice.roots);
|
|
810
864
|
yield* putOnce(bucket, made.slice.key, made.bytes);
|
|
811
865
|
yield* putOnce(bucket, files.typesPart(number, positions), slice.types);
|
|
812
866
|
yield* putOnce(bucket, files.basesPart(number, positions), wordsBytes(slice.bases));
|
|
@@ -897,26 +951,87 @@ const entriesOf = /* @__PURE__ */ Effect.fnUntraced(function* (rows, first, grap
|
|
|
897
951
|
for (const position of positions) if (position !== 4294967295) found.push(position);
|
|
898
952
|
return found;
|
|
899
953
|
});
|
|
900
|
-
|
|
954
|
+
/**
|
|
955
|
+
* The commits to give bitmaps: every tip; every one of the newest `bitmapEvery` down each tip's
|
|
956
|
+
* first parents, up to `recentMost` of them in all, the tips walked newest first by generation; and
|
|
957
|
+
* every `bitmapEvery`th. A commit walked from one tip isn't walked again. With them, what's left of
|
|
958
|
+
* `recentMost`, and each walk that left the layer before `bitmapEvery` steps, a tip below it at
|
|
959
|
+
* step 0, for `denseBelow` to go on with.
|
|
960
|
+
*/
|
|
961
|
+
const chooseCommits = (rows, tips, first = 0, recentMost = 400) => {
|
|
901
962
|
const commits = rows.length / 3;
|
|
902
963
|
const walked = new Uint8Array(commits);
|
|
903
964
|
const chosen = /* @__PURE__ */ new Set();
|
|
904
|
-
|
|
965
|
+
const inLayer = (number) => number >= first && number - first < commits;
|
|
966
|
+
const generationOf = (number) => inLayer(number) ? rows[(number - first) * 3 + 2] ?? 0 : 0;
|
|
967
|
+
const newestFirst = [...tips].sort((a, b) => generationOf(b) - generationOf(a));
|
|
968
|
+
let recentLeft = recentMost;
|
|
969
|
+
const left = [];
|
|
970
|
+
for (const tip of newestFirst) {
|
|
905
971
|
let number = tip;
|
|
906
|
-
|
|
907
|
-
|
|
972
|
+
let steps = 0;
|
|
973
|
+
if (inLayer(tip)) chosen.add(tip);
|
|
974
|
+
for (; number !== 2147483647 && inLayer(number) && walked[number - first] === 0; steps += 1) {
|
|
908
975
|
walked[number - first] = 1;
|
|
909
976
|
if (steps % 100 === 0) chosen.add(number);
|
|
977
|
+
else if (steps < 100 && recentLeft > 0) {
|
|
978
|
+
chosen.add(number);
|
|
979
|
+
recentLeft -= 1;
|
|
980
|
+
}
|
|
910
981
|
number = rows[(number - first) * 3] ?? 2147483647;
|
|
911
982
|
}
|
|
983
|
+
if (number !== 2147483647 && !inLayer(number) && steps < 100) left.push({
|
|
984
|
+
at: number,
|
|
985
|
+
steps
|
|
986
|
+
});
|
|
912
987
|
}
|
|
913
|
-
return
|
|
988
|
+
return {
|
|
989
|
+
chosen: [...chosen],
|
|
990
|
+
recentLeft,
|
|
991
|
+
left
|
|
992
|
+
};
|
|
914
993
|
};
|
|
915
994
|
/**
|
|
995
|
+
* The commits below the layer to bitmap for being among a tip's newest `bitmapEvery`, for each
|
|
996
|
+
* walk `chooseCommits` saw leave the layer: down its first parents from where it left, to just
|
|
997
|
+
* before the first commit a layer below has a bitmap for, at most `most.recent` in all, reading at
|
|
998
|
+
* most `most.reads` entries. A walk that left on a commit with one reads none, as an update of
|
|
999
|
+
* main does, meeting main's last tip. A tip below the layer, step 0, is chosen as a tip is, so its
|
|
1000
|
+
* walk starts at its first parent, and another walk that meets it stops there: its own walk is the
|
|
1001
|
+
* same line.
|
|
1002
|
+
*/
|
|
1003
|
+
const denseBelow = /* @__PURE__ */ Effect.fnUntraced(function* (left, most, below) {
|
|
1004
|
+
const chosen = [];
|
|
1005
|
+
const seen = new Set(left.flatMap(({ at, steps }) => steps === 0 ? [at] : []));
|
|
1006
|
+
let { recent, reads } = most;
|
|
1007
|
+
for (const { at, steps } of left) {
|
|
1008
|
+
if (recent === 0 || reads === 0) break;
|
|
1009
|
+
let number = at;
|
|
1010
|
+
let step = steps;
|
|
1011
|
+
if (step === 0) {
|
|
1012
|
+
reads -= 1;
|
|
1013
|
+
number = (yield* below.entryOf(at)).parents[0] ?? 2147483647;
|
|
1014
|
+
step = 1;
|
|
1015
|
+
}
|
|
1016
|
+
for (; number !== 2147483647 && step < 100 && recent > 0 && reads > 0 && !seen.has(number) && !below.held(number); step += 1) {
|
|
1017
|
+
seen.add(number);
|
|
1018
|
+
reads -= 1;
|
|
1019
|
+
const entry = yield* below.entryOf(number);
|
|
1020
|
+
chosen.push({
|
|
1021
|
+
number,
|
|
1022
|
+
generation: entry.generation
|
|
1023
|
+
});
|
|
1024
|
+
recent -= 1;
|
|
1025
|
+
number = entry.parents[0] ?? 2147483647;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
return chosen;
|
|
1029
|
+
});
|
|
1030
|
+
/**
|
|
916
1031
|
* The bitmaps step: the tips' and chosen commits' positions, then a walk for each. An update
|
|
917
|
-
* makes a bitmap only for a tip no layer below has one for,
|
|
918
|
-
* own
|
|
919
|
-
* and closes any other position there by reading its objects. `undefined` when one won't close
|
|
1032
|
+
* makes a bitmap only for a tip no layer below has one for, for the commits `chooseCommits`
|
|
1033
|
+
* chooses of its own, and for those `denseBelow` chooses below it. Its walk ORs a stored bitmap
|
|
1034
|
+
* it meets below its layer, and closes any other position there by reading its objects. `undefined` when one won't close
|
|
920
1035
|
* within `walkMost`: the update gives way to a whole build.
|
|
921
1036
|
*
|
|
922
1037
|
* With `parts.counted`, all it reads and writes is through the try's bound less
|
|
@@ -924,7 +1039,8 @@ const chooseCommits = (rows, tips, first = 0) => {
|
|
|
924
1039
|
* through the whole bound, each with every earlier try's, and the next try ORs them with no walk.
|
|
925
1040
|
* The walk it was in goes there too, cut where the bound ran out, and the next try goes on from
|
|
926
1041
|
* it. A try that closed no walk and read no object further refuses, as the next would spend its
|
|
927
|
-
* calls at the same place (#1068)
|
|
1042
|
+
* calls at the same place (#1068), unless it read below its layer for `denseBelow`: it gives those
|
|
1043
|
+
* commits up (`IndexData.dense`), and the next try chooses none there (#2187).
|
|
928
1044
|
* A try that put a part ends as `more`, which counts none of the job's `indexTries` failures, so
|
|
929
1045
|
* an update whose walks below take more than that many tries still lands.
|
|
930
1046
|
*
|
|
@@ -952,6 +1068,10 @@ const bitmapsStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed,
|
|
|
952
1068
|
if (spent === void 0) return yield* Effect.fail(written.failure);
|
|
953
1069
|
const most = counted?.most[spent.bound] ?? spent.most;
|
|
954
1070
|
if (data.below.length === 0) return yield* Effect.fail(bitmapUnwritten(spent.bound, most));
|
|
1071
|
+
if (walks.fresh === 0 && !readFurther(walks) && walks.below === true) return {
|
|
1072
|
+
...data,
|
|
1073
|
+
dense: false
|
|
1074
|
+
};
|
|
955
1075
|
if (walks.fresh === 0 && !readFurther(walks)) return yield* Effect.fail(reachUnsettled(spent.bound, most));
|
|
956
1076
|
const part = data.reaches ?? 0;
|
|
957
1077
|
const reaches = { closed: walks.closed };
|
|
@@ -1024,7 +1144,18 @@ const bitmapsWritten = /* @__PURE__ */ Effect.fnUntraced(function* (parts, lower
|
|
|
1024
1144
|
const tipPositions = yield* layout.positionsOf(tipIds, tips.length);
|
|
1025
1145
|
const tipNumbers = yield* graph.numbersOf(tipIds, tips.length);
|
|
1026
1146
|
const wanting = (at) => wantsBitmap(tipPositions[at] ?? 4294967295, stored);
|
|
1027
|
-
const
|
|
1147
|
+
const choice = chooseCommits(rows, [...tipNumbers].filter((number, at) => number !== 4294967295 && wanting(at)), graphFirst, parts.recent ?? 400);
|
|
1148
|
+
const denser = data.dense === false ? [] : yield* denseBelow(choice.left, {
|
|
1149
|
+
recent: choice.recentLeft,
|
|
1150
|
+
reads: parts.counted === void 0 ? Infinity : denseBelowReads(parts.counted.most.bucket)
|
|
1151
|
+
}, {
|
|
1152
|
+
entryOf: (number) => Effect.suspend(() => {
|
|
1153
|
+
walks.below = true;
|
|
1154
|
+
return graph.entryOf(number);
|
|
1155
|
+
}),
|
|
1156
|
+
held: (number) => stored.numbered.has(number)
|
|
1157
|
+
});
|
|
1158
|
+
const numbers = [...choice.chosen, ...denser.map(({ number }) => number)];
|
|
1028
1159
|
const numberIds = yield* graph.idsAt(numbers);
|
|
1029
1160
|
const numberPositions = yield* layout.positionsOf(numberIds, numbers.length);
|
|
1030
1161
|
let latest = 0;
|
|
@@ -1032,7 +1163,7 @@ const bitmapsWritten = /* @__PURE__ */ Effect.fnUntraced(function* (parts, lower
|
|
|
1032
1163
|
for (const [at, number] of numbers.entries()) {
|
|
1033
1164
|
const position = numberPositions[at] ?? 4294967295;
|
|
1034
1165
|
if (position === 4294967295) return yield* Effect.fail(lost(`The index's commit ${number} has no position`));
|
|
1035
|
-
const generation = rows[(number - graphFirst) * 3 + 2] ?? 0;
|
|
1166
|
+
const generation = denser[at - choice.chosen.length]?.generation ?? rows[(number - graphFirst) * 3 + 2] ?? 0;
|
|
1036
1167
|
latest = Math.max(latest, generation);
|
|
1037
1168
|
chosen.push({
|
|
1038
1169
|
position,
|
|
@@ -1083,6 +1214,7 @@ const bitmapsWritten = /* @__PURE__ */ Effect.fnUntraced(function* (parts, lower
|
|
|
1083
1214
|
allotment,
|
|
1084
1215
|
bits: walking
|
|
1085
1216
|
};
|
|
1217
|
+
const rootsOnce = yield* Effect.cached(rootsAt(parts, listed));
|
|
1086
1218
|
const below = data.below.length === 0 ? void 0 : {
|
|
1087
1219
|
first,
|
|
1088
1220
|
entries: entriesBelow,
|
|
@@ -1097,7 +1229,10 @@ const bitmapsWritten = /* @__PURE__ */ Effect.fnUntraced(function* (parts, lower
|
|
|
1097
1229
|
};
|
|
1098
1230
|
} };
|
|
1099
1231
|
if (walks.carried?.position === position) carry.from = walks.carried.walk;
|
|
1100
|
-
const walked = yield* reachOf(
|
|
1232
|
+
const walked = yield* reachOf({
|
|
1233
|
+
...reach,
|
|
1234
|
+
roots: yield* rootsOnce
|
|
1235
|
+
}, [{ position }], carry);
|
|
1101
1236
|
if (walked === void 0) return void 0;
|
|
1102
1237
|
const most = ewahMostWords(walked.length) * 4;
|
|
1103
1238
|
yield* allotment.grow(8 + most);
|
|
@@ -1796,7 +1931,8 @@ const indexStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, in
|
|
|
1796
1931
|
refusal: {
|
|
1797
1932
|
reason,
|
|
1798
1933
|
...held
|
|
1799
|
-
}
|
|
1934
|
+
},
|
|
1935
|
+
...kept.lost === true && { lost: true }
|
|
1800
1936
|
}
|
|
1801
1937
|
};
|
|
1802
1938
|
return {
|
|
@@ -1833,14 +1969,14 @@ const indexStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, in
|
|
|
1833
1969
|
if (input.failed !== void 0) return waiting(input.failed.reason);
|
|
1834
1970
|
if (input.data === void 0 && row !== void 0 && !indexSaves(indexStatus(row, limits, input.at, listedIds(listed)))) return prunedAt(yield* prune());
|
|
1835
1971
|
const built = builtOf(row);
|
|
1836
|
-
const current = 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;
|
|
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;
|
|
1837
1973
|
if (current === true) return prunedAt(yield* prune());
|
|
1838
1974
|
if (current === "moved" && input.lastCheck !== true) return { kind: "moved" };
|
|
1839
1975
|
const fresh = () => built === void 0 || current === "lost" || !coversAll(built.layers, listed) ? started(listed) : built.layers.length < 8 ? startedUpdate(listed, built) : startedMerge(listed, built);
|
|
1840
1976
|
const kept = input.data;
|
|
1841
1977
|
const sameBelow = kept !== void 0 && (kept.below.length === 0 || kept.below.map((layer) => layer.build).join() === (built?.layers ?? []).map((layer) => layer.build).join());
|
|
1842
1978
|
const again = (from) => from.below.length === 0 && from.merge !== true ? started(listed) : fresh();
|
|
1843
|
-
const data = kept === void 0 || !covers(kept, listed) || !sameBelow ? fresh() : kept.step === "region" ? again(kept) : kept;
|
|
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;
|
|
1844
1980
|
const more = (next) => ({
|
|
1845
1981
|
kind: "more",
|
|
1846
1982
|
data: next
|
|
@@ -1930,4 +2066,4 @@ const indexTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, limits, lis
|
|
|
1930
2066
|
data: ended.data
|
|
1931
2067
|
};
|
|
1932
2068
|
});
|
|
1933
|
-
export { BitmapsCut, BuiltIndex, IndexBounds, IndexData, IndexGroup, IndexLayer, IndexRefusal, IndexRow, IndexSlice, IndexTries, Narrowed, RefusedIndex, ReplacedBuild, belowGraphs, bitmapsJoinHeld, bitmapsJoinMost, boundsOf, builtIndexOf, chooseCommits, copyMergedBitmaps, coveredPacks, coversAll, decodeIndexValue, edgesMost, entriesHeld, floors, graphMostOf, indexBitmapsCallsAfter, indexReadCallsAfter, indexRowOf, indexSaves, indexStatus, indexStep, indexSteps, indexTry, limitsOf, madeMost, mergeCallsAfterOpen, mergeChunk, mergeHeldMost, narrowedAfter, newBuildId, positionOrder, pruneBuilds, putOnce, reachesBytes, reachesOf, readFurther, rowsOfLayer, sliceBounds, storedTypesOf, triesWait, triesWaitMost, triesWaitOf, wordsOf };
|
|
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 };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { gitError } from "../contracts/result.mjs";
|
|
2
2
|
import { BufferError, BufferMeter } from "../protocol/bytes/buffers.mjs";
|
|
3
3
|
import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
4
|
+
import { noRepoRoots } from "../protocol/objects/commit.mjs";
|
|
4
5
|
import { mostParents } from "../protocol/objects/object-rules.mjs";
|
|
5
6
|
import { Sha1 } from "../protocol/bytes/sha1.mjs";
|
|
6
7
|
import { graphMagic } from "../protocol/packs/graph.mjs";
|
|
@@ -8,7 +9,7 @@ import { PackTransportError, boundedSource, packReadBytes } from "../protocol/pa
|
|
|
8
9
|
import { bucketStream } from "./calls.mjs";
|
|
9
10
|
import { startPut } from "./merge.mjs";
|
|
10
11
|
import { readExactly } from "./pack-ranges.mjs";
|
|
11
|
-
import { compareIds, orderById } from "./raw-ids.mjs";
|
|
12
|
+
import { compareIds, idsBytes, orderById } from "./raw-ids.mjs";
|
|
12
13
|
import * as Effect from "effect/Effect";
|
|
13
14
|
import * as Result from "effect/Result";
|
|
14
15
|
import { limits } from "@ref0/infra";
|
|
@@ -240,14 +241,36 @@ const heldBelow = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, graphs, b
|
|
|
240
241
|
bytes: refs * 24 + held.length * 4
|
|
241
242
|
};
|
|
242
243
|
});
|
|
243
|
-
/**
|
|
244
|
-
|
|
244
|
+
/**
|
|
245
|
+
* `graphs`' commits as `eachCommit` gives them, less the merge numbers `held` names, numbered
|
|
246
|
+
* without them, each of `roots`, sorted raw IDs, with no parents.
|
|
247
|
+
*/
|
|
248
|
+
const ownCommits = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, graphs, held, roots, each) {
|
|
245
249
|
let skipped = 0;
|
|
246
250
|
return (yield* eachCommit(bucket, graphs, (number, commit) => {
|
|
247
|
-
if (held[skipped] !== number) return each(number - skipped, commit);
|
|
251
|
+
if (held[skipped] !== number) return each(number - skipped, rootedOf(roots, commit));
|
|
248
252
|
skipped += 1;
|
|
249
253
|
})) - skipped;
|
|
250
254
|
});
|
|
255
|
+
/** Whether `id`'s 20 bytes are among `roots`, sorted raw IDs: a search, with no string made. */
|
|
256
|
+
const isRoot = (roots, id) => {
|
|
257
|
+
let low = 0;
|
|
258
|
+
let high = roots.length / 20;
|
|
259
|
+
while (low < high) {
|
|
260
|
+
const middle = low + high >>> 1;
|
|
261
|
+
const compared = compareIds(roots, middle * 20, id, 0);
|
|
262
|
+
if (compared === 0) return true;
|
|
263
|
+
if (compared < 0) low = middle + 1;
|
|
264
|
+
else high = middle;
|
|
265
|
+
}
|
|
266
|
+
return false;
|
|
267
|
+
};
|
|
268
|
+
/** `commit` as a repo with `roots`, sorted raw IDs, sees it: one of them with no parents. */
|
|
269
|
+
const rootedOf = (roots, commit) => roots.length > 0 && isRoot(roots, commit.id) ? {
|
|
270
|
+
id: commit.id,
|
|
271
|
+
parents: commit.parents.subarray(0, 0),
|
|
272
|
+
count: 0
|
|
273
|
+
} : commit;
|
|
251
274
|
/** Parents still to number: each one's ID, and where its number goes. */
|
|
252
275
|
var ParentRefs = class {
|
|
253
276
|
ids;
|
|
@@ -360,6 +383,7 @@ const graphTooWide = (id, parents) => gitError("RESOURCE_EXHAUSTED", `The repo's
|
|
|
360
383
|
*/
|
|
361
384
|
const writeIndexGraph = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
362
385
|
const { bucket, graphs, allotment, below } = input;
|
|
386
|
+
const roots = idsBytes([...input.roots ?? noRepoRoots]).bytes;
|
|
363
387
|
const refs = input.refs ?? 65536;
|
|
364
388
|
const base = below?.first ?? 0;
|
|
365
389
|
const missBytes = below === void 0 ? 0 : (refs + mostParents) * 32;
|
|
@@ -421,7 +445,7 @@ const writeIndexGraph = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
421
445
|
resolved += 1;
|
|
422
446
|
}
|
|
423
447
|
};
|
|
424
|
-
const counted = yield* ownCommits(bucket, graphs, own.held, (number, commit) => {
|
|
448
|
+
const counted = yield* ownCommits(bucket, graphs, own.held, roots, (number, commit) => {
|
|
425
449
|
const parents = commit.count;
|
|
426
450
|
const start = octopusAt;
|
|
427
451
|
if (parents > 2) octopusAt += parents - 1;
|
|
@@ -2,6 +2,7 @@ import "../contracts/ids.mjs";
|
|
|
2
2
|
import "../contracts/objects.mjs";
|
|
3
3
|
import "../contracts/result.mjs";
|
|
4
4
|
import "../contracts/store.mjs";
|
|
5
|
+
import "../protocol/objects/commit.mjs";
|
|
5
6
|
import "./index-bitmaps.mjs";
|
|
6
7
|
import "./index-build.mjs";
|
|
7
8
|
import "./link-join.mjs";
|
|
@@ -3,6 +3,7 @@ import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
|
3
3
|
import { rawLinks } from "../protocol/objects/links-raw.mjs";
|
|
4
4
|
import { isTreeMode } from "../protocol/objects/object.mjs";
|
|
5
5
|
import { parseTreeBytes } from "../protocol/objects/tree.mjs";
|
|
6
|
+
import { noRepoRoots } from "../protocol/objects/commit.mjs";
|
|
6
7
|
import { oidBytes } from "../protocol/packs/idx.mjs";
|
|
7
8
|
import { bitmapWords } from "./ewah.mjs";
|
|
8
9
|
import { ewahMostWords, openBitmaps } from "./index-bitmaps.mjs";
|
|
@@ -369,7 +370,7 @@ const whileFollowed = (allotment, objects, follow) => {
|
|
|
369
370
|
/**
|
|
370
371
|
* The positions `starts` reach, as words over every position, or `undefined` when it can't say:
|
|
371
372
|
* a walk past `most` reads, an object it can't find, or a link to an ID the index doesn't hold,
|
|
372
|
-
* such as one listed after it. A position with a stored bitmap is ORed whole and not walked; any
|
|
373
|
+
* such as one listed after it. One of `input.roots` leads to its tree alone, never its parents. A position with a stored bitmap is ORed whole and not walked; any
|
|
373
374
|
* other is read, and its links found by position, a few at a time. A blob is reached and never
|
|
374
375
|
* read. It holds a word for each 32 positions, unless it's given `bits`, and at most `most` IDs
|
|
375
376
|
* still to read, charged to `allotment`, and each batch it follows, charged by `whileFollowed`.
|
|
@@ -390,6 +391,7 @@ const whileFollowed = (allotment, objects, follow) => {
|
|
|
390
391
|
const reachOf = /* @__PURE__ */ Effect.fnUntraced(function* (input, starts, carry) {
|
|
391
392
|
const { layout, bitmaps } = input;
|
|
392
393
|
const most = input.most ?? 2e3;
|
|
394
|
+
const roots = input.roots ?? noRepoRoots;
|
|
393
395
|
const words = bitmapWords(layout.positions);
|
|
394
396
|
const held = (input.bits === void 0 ? words * 4 : 0) + most * 24;
|
|
395
397
|
yield* Effect.acquireRelease(input.allotment.grow(held), () => Effect.sync(() => input.allotment.shrink(held)));
|
|
@@ -448,8 +450,9 @@ const reachOf = /* @__PURE__ */ Effect.fnUntraced(function* (input, starts, carr
|
|
|
448
450
|
continue;
|
|
449
451
|
}
|
|
450
452
|
let tree = object.type === "commit";
|
|
453
|
+
const rooted = tree && roots.has(object.oid);
|
|
451
454
|
const malformed = rawLinks(object.type, bytes, (from, at) => {
|
|
452
|
-
linked.push({
|
|
455
|
+
if (tree || !rooted) linked.push({
|
|
453
456
|
id: from.slice(at, at + 20),
|
|
454
457
|
links: true,
|
|
455
458
|
to: tree ? "trees" : "commits"
|
|
@@ -91,7 +91,8 @@ const shrinkOnClose = (allotment, held) => () => Effect.sync(() => allotment.shr
|
|
|
91
91
|
* What `tips`, none of which the index holds, reach before they meet it, through `onward`: each
|
|
92
92
|
* object outside the index, read or not, counted, and each position met set in `met`, kept as a
|
|
93
93
|
* bit, not walked. A blob is reached and never read, and an object the repo doesn't hold, as a
|
|
94
|
-
* shallow repo's parent, is left out
|
|
94
|
+
* shallow repo's parent, is left out, and one of `input.roots` leads to its tree alone, never its
|
|
95
|
+
* parents, as the index's graph has it. Past `most` objects outside it, it stops, not closed. Each
|
|
95
96
|
* batch it follows is charged by `whileFollowed`, and it holds at most `most` IDs between them.
|
|
96
97
|
*/
|
|
97
98
|
const outsideOf = /* @__PURE__ */ Effect.fnUntraced(function* (input, tips, most) {
|
|
@@ -116,7 +117,7 @@ const outsideOf = /* @__PURE__ */ Effect.fnUntraced(function* (input, tips, most
|
|
|
116
117
|
ids.delete(oid);
|
|
117
118
|
continue;
|
|
118
119
|
}
|
|
119
|
-
const steps = yield* stepsOf(object, true);
|
|
120
|
+
const steps = yield* stepsOf(object, true, input.roots);
|
|
120
121
|
for (const each of onward(steps)) if (!ids.has(each)) read.add(each);
|
|
121
122
|
for (const each of steps.reached) if (!ids.has(each)) linked.add(each);
|
|
122
123
|
}
|
|
@@ -157,8 +158,8 @@ const indexCovers = (input, listed) => {
|
|
|
157
158
|
* doesn't cover `listed`, as after a repack took a covered pack out, for the caller's walk. A tip
|
|
158
159
|
* whose reach won't close within `most` sets `pastLimit`. Where `unclosed`, so does one whose walk
|
|
159
160
|
* meets an object past the bytes it may follow at once, which a fetch's want check refuses as
|
|
160
|
-
* `levelTooLarge`: a visible set still shows its tips, and what their bitmaps reach. Its
|
|
161
|
-
* allotment is the scope's.
|
|
161
|
+
* `levelTooLarge`: a visible set still shows its tips, and what their bitmaps reach. Its walks
|
|
162
|
+
* follow no parent of `input.roots`. Its allotment is the scope's.
|
|
162
163
|
*/
|
|
163
164
|
const tipsReach = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, input, unclosed = false) {
|
|
164
165
|
let tooLarge = false;
|
|
@@ -192,7 +193,8 @@ const tipsReach = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, in
|
|
|
192
193
|
bitmaps,
|
|
193
194
|
read,
|
|
194
195
|
allotment,
|
|
195
|
-
most
|
|
196
|
+
most,
|
|
197
|
+
roots: input.roots
|
|
196
198
|
};
|
|
197
199
|
let known = true;
|
|
198
200
|
let walked = 0;
|
|
@@ -515,10 +515,10 @@ const remapIndex = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
515
515
|
});
|
|
516
516
|
/**
|
|
517
517
|
* The `index` row a geometric step's merge leaves, laid again over its pack, or `undefined` when
|
|
518
|
-
* it can't be: the row isn't built, is a refusal for spent tries, or doesn't
|
|
519
|
-
* before the merge; the merge took a pack it doesn't cover; the remap
|
|
520
|
-
* says; or it fails of its own, its calls run out, its allotment can't
|
|
521
|
-
* reads is lost or corrupt, each logged with its cause. Then the listing commits without it, and
|
|
518
|
+
* it can't be: the row isn't built, is a refusal for spent tries, is marked lost, or doesn't
|
|
519
|
+
* cover the listing before the merge; the merge took a pack it doesn't cover; the remap
|
|
520
|
+
* declines, as `remapIndex` says; or it fails of its own, its calls run out, its allotment can't
|
|
521
|
+
* grow, or a stored file it reads is lost or corrupt, each logged with its cause. Then the listing commits without it, and
|
|
522
522
|
* the next `git.index` builds again. A merge it finds incomplete, the merged pack's own files lost
|
|
523
523
|
* or corrupt among it, fails the step, an error in the log; so do an interruption, a defect and
|
|
524
524
|
* any other failure.
|
|
@@ -528,7 +528,7 @@ const remapRow = (parts, input) => Effect.scoped(Effect.gen(function* () {
|
|
|
528
528
|
...indexRowKey,
|
|
529
529
|
value: parts.row
|
|
530
530
|
});
|
|
531
|
-
if (row === void 0 || "refused" in row || row.refusal !== void 0) return void 0;
|
|
531
|
+
if (row === void 0 || "refused" in row || row.refusal !== void 0 || row.lost === true) return void 0;
|
|
532
532
|
if (!coversListing(row.layers, input.listed, parts.holds?.packs)) return void 0;
|
|
533
533
|
const plan = remapPlan(row.layers, input.listed, input.taken, input.merged.pack.objects);
|
|
534
534
|
if (plan === void 0) return void 0;
|
|
@@ -33,6 +33,16 @@ const unindexedRead = () => gitError("RESOURCE_EXHAUSTED", readByIdText, {
|
|
|
33
33
|
const isUnindexedRead = (error) => error.code === "RESOURCE_EXHAUSTED" && error.message === readByIdText;
|
|
34
34
|
/** What each ID a set has answered adds to what it keeps: its hex and its place in the map. */
|
|
35
35
|
const answerBytes = 160;
|
|
36
|
+
/**
|
|
37
|
+
* The core's ask for the rebuild of the `index` row a set's input names, once the index fails its
|
|
38
|
+
* own checks, kept off `VisibleInput`'s contract as a set's reach is.
|
|
39
|
+
*/
|
|
40
|
+
const lostAsks = /* @__PURE__ */ new WeakMap();
|
|
41
|
+
/** `input`, whose set asks `lost` once the index its row names fails its own checks. */
|
|
42
|
+
const askingOnLost = (input, lost) => {
|
|
43
|
+
lostAsks.set(input, lost);
|
|
44
|
+
return input;
|
|
45
|
+
};
|
|
36
46
|
/** Each set `indexedVisible` made, with its `SetReach`, kept off the set's contract. */
|
|
37
47
|
const setReaches = /* @__PURE__ */ new WeakMap();
|
|
38
48
|
/** The want check `set` answers by its own reach, if `indexedVisible` made it. */
|
|
@@ -47,20 +57,21 @@ const setReachOf = (set) => setReaches.get(set);
|
|
|
47
57
|
* never on an ID, and a hidden ID and an absent one still read alike. Outside a request's hold, or
|
|
48
58
|
* once it has closed, an ask builds the reach for itself and lets it go once answered. A tip
|
|
49
59
|
* answers with no lookup, since its caller sees it. An index that fails its own checks,
|
|
50
|
-
* `DATA_LOSS`, gives the set to `fallback` too, with its error in the log
|
|
51
|
-
* is reached that it hasn't shown.
|
|
60
|
+
* `DATA_LOSS`, gives the set to `fallback` too, with its error in the log and the core's ask for
|
|
61
|
+
* the row's rebuild, `askingOnLost`, so it never says an ID is reached that it hasn't shown.
|
|
52
62
|
*/
|
|
53
63
|
const indexedVisible = (parts, listed, input, fallback) => {
|
|
54
64
|
if (!indexCovers(input, listed)) return fallback();
|
|
55
65
|
const tips = {
|
|
56
66
|
row: input.row,
|
|
57
|
-
tips: input.tips
|
|
67
|
+
tips: input.tips,
|
|
68
|
+
roots: input.roots
|
|
58
69
|
};
|
|
59
70
|
const shownTips = new Set(input.tips);
|
|
60
71
|
/** The tips as `tipsReach` walks them: each once, where it first comes. */
|
|
61
72
|
const walkedTips = [...shownTips];
|
|
62
73
|
/** An index that fails its own checks as `value`, its error in the log. */
|
|
63
|
-
const lostAs = (value) => (effect) => effect.pipe(Effect.catchIf((error) => error.code === "DATA_LOSS", (error) => Effect.as(indexUnreadable(listed.repo, error), value)));
|
|
74
|
+
const lostAs = (value) => (effect) => effect.pipe(Effect.catchIf((error) => error.code === "DATA_LOSS", (error) => Effect.as(indexUnreadable(listed.repo, error, lostAsks.get(input)), value)));
|
|
64
75
|
let fell;
|
|
65
76
|
let held;
|
|
66
77
|
let using = 0;
|
|
@@ -165,4 +176,4 @@ const indexedVisible = (parts, listed, input, fallback) => {
|
|
|
165
176
|
setReaches.set(set, reach);
|
|
166
177
|
return set;
|
|
167
178
|
};
|
|
168
|
-
export { indexedVisible, isUnindexedRead, setReachOf, unindexedRead };
|
|
179
|
+
export { askingOnLost, indexedVisible, isUnindexedRead, setReachOf, unindexedRead };
|
|
@@ -6,14 +6,14 @@ import * as Effect from "effect/Effect";
|
|
|
6
6
|
/** Builds a push's `LfsPointers`, as a receive finds them among its blobs. */
|
|
7
7
|
export interface LfsPointersBuilder {
|
|
8
8
|
/**
|
|
9
|
-
* Lists the blob `blob` as a pointer to the LFS object `oid`, its SHA-256, both in lowercase hex
|
|
10
|
-
*
|
|
11
|
-
* `INVALID_ARGUMENT`.
|
|
9
|
+
* Lists the blob `blob` as a pointer to the LFS object `oid`, its SHA-256, both in lowercase hex,
|
|
10
|
+
* of `size` bytes, kept up to `pointerSizeMost`. Past `lfsPointersMost` it fails
|
|
11
|
+
* `too-many-pointers`, and a malformed ID fails `INVALID_ARGUMENT`.
|
|
12
12
|
*/
|
|
13
|
-
readonly add: (blob: Oid, oid: string) => Effect.Effect<void, GitError>;
|
|
13
|
+
readonly add: (blob: Oid, oid: string, size: number) => Effect.Effect<void, GitError>;
|
|
14
14
|
/** The pointers listed, sorted by blob. Nothing more may be added once it's called. */
|
|
15
15
|
readonly finish: () => LfsPointers;
|
|
16
|
-
/** Lists a pointer an earlier step listed, its
|
|
16
|
+
/** Lists a pointer an earlier step listed, its `lfsPointerBytes` as the table holds them. */
|
|
17
17
|
readonly carried: (record: Uint8Array) => void;
|
|
18
18
|
}
|
|
19
19
|
/**
|