@ref0/git 0.8.0 → 0.10.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/contracts/calls-spent.d.mts +2 -12
- package/dist/contracts/calls-spent.mjs +4 -5
- package/dist/contracts/commits.d.mts +14 -2
- package/dist/contracts/commits.mjs +22 -3
- package/dist/contracts/events.d.mts +70 -4
- package/dist/contracts/events.mjs +27 -3
- package/dist/contracts/git.d.mts +13 -3
- package/dist/contracts/objects.d.mts +18 -0
- package/dist/contracts/queue.d.mts +3 -2
- package/dist/contracts/queue.mjs +4 -2
- package/dist/contracts/refs.mjs +3 -1
- package/dist/core/ancestry.mjs +5 -4
- package/dist/core/events/seen.mjs +5 -4
- 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/job-view.mjs +20 -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/parts.d.mts +7 -0
- package/dist/core/publish.mjs +9 -5
- package/dist/core/purge.mjs +16 -3
- package/dist/core/push.mjs +27 -11
- package/dist/core/ref-view.mjs +1 -25
- package/dist/core/repack.mjs +36 -14
- package/dist/core/view.d.mts +10 -1
- package/dist/core/view.mjs +15 -6
- package/dist/core/work.mjs +47 -4
- package/dist/effect.d.mts +2 -3
- package/dist/effect.mjs +2 -3
- package/dist/engine/commits.mjs +4 -3
- package/dist/engine/merge-bases.mjs +5 -3
- package/dist/engine/merge.mjs +4 -3
- package/dist/engine/parts.d.mts +1 -0
- package/dist/engine/parts.mjs +1 -1
- package/dist/engine/walk.mjs +62 -20
- package/dist/http/core-parts.mjs +17 -8
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +3 -3
- package/dist/lfs/objects.mjs +7 -4
- package/dist/lfs/upkeep.mjs +6 -5
- package/dist/lfs/upload-most.mjs +8 -2
- package/dist/protocol/bytes/streams.mjs +84 -2
- 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/queue/advance.mjs +39 -10
- package/dist/queue/host.d.mts +4 -0
- package/dist/queue/layer.mjs +4 -2
- package/dist/queue/limits.mjs +18 -2
- package/dist/queue/rows.mjs +2 -1
- package/dist/queue/trim.mjs +2 -2
- package/dist/rest/commits.d.mts +202 -198
- package/dist/rest/forks.d.mts +99 -99
- package/dist/rest/refs.d.mts +144 -144
- package/dist/rest/repos.d.mts +48 -48
- package/dist/rest/topics.d.mts +112 -112
- package/dist/rest/trees.d.mts +58 -58
- package/dist/rest/wire.d.mts +19 -1
- package/dist/rest/work.d.mts +39 -39
- package/dist/server/joined.d.mts +11 -5
- package/dist/server/joined.mjs +3 -2
- package/dist/server/registry.mjs +11 -5
- package/dist/server/server.mjs +16 -4
- package/dist/storage/index-bitmaps.mjs +16 -10
- package/dist/storage/index-build.mjs +61 -13
- 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/links.mjs +3 -3
- package/dist/storage/pack-order.d.mts +1 -0
- package/dist/storage/pack-order.mjs +18 -1
- package/dist/storage/prune-walk.mjs +5 -2
- package/dist/storage/prune.mjs +107 -37
- package/dist/storage/receive-bounds.mjs +3 -2
- 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 +8 -0
- package/dist/store/call-count.mjs +15 -7
- 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 +17 -2
- package/dist/store/repo-record.mjs +9 -2
- package/dist/store/scopes.mjs +10 -2
- package/dist/sync/bound.d.mts +1 -1
- package/dist/sync/import.mjs +1 -1
- package/dist/sync/layer.mjs +4 -7
- package/dist/sync/mirror.mjs +1 -1
- package/dist/topics/advance.mjs +4 -4
- package/dist/topics/layer.mjs +1 -1
- package/package.json +3 -3
package/dist/rest/work.d.mts
CHANGED
|
@@ -1,13 +1,39 @@
|
|
|
1
1
|
import { GitCallerMiddleware, GitRestServices } from "./caller.mjs";
|
|
2
2
|
import * as Schema from "effect/Schema";
|
|
3
3
|
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/http-api";
|
|
4
|
-
declare const WorkApiGroup_base: HttpApiGroup.HttpApiGroup<"work", HttpApiEndpoint.HttpApiEndpoint<"
|
|
4
|
+
declare const WorkApiGroup_base: HttpApiGroup.HttpApiGroup<"work", HttpApiEndpoint.HttpApiEndpoint<"list", "GET", "/repos/:repo/-/work", Schema.toCodecStringTree<Schema.Struct<{
|
|
5
5
|
repo: Schema.String;
|
|
6
|
-
}>>,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}>>, never,
|
|
6
|
+
}>>, Schema.toCodecStringTree<Schema.Struct<{
|
|
7
|
+
after: Schema.optionalKey<Schema.String>;
|
|
8
|
+
limit: Schema.optionalKey<Schema.Int>;
|
|
9
|
+
state: Schema.optionalKey<Schema.Literals<readonly ["waiting", "running", "failed"]>>;
|
|
10
|
+
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
11
|
+
readonly items: Schema.mutable<Schema.$Array<Schema.Struct<{
|
|
12
|
+
readonly scope: Schema.String;
|
|
13
|
+
readonly name: Schema.String;
|
|
14
|
+
readonly key: Schema.String;
|
|
15
|
+
readonly data: Schema.Unknown;
|
|
16
|
+
readonly due: Schema.Number;
|
|
17
|
+
readonly attempt: Schema.Number;
|
|
18
|
+
readonly trace: Schema.optionalKey<Schema.String>;
|
|
19
|
+
readonly firstTry: Schema.optionalKey<Schema.Number>;
|
|
20
|
+
readonly claim: Schema.optionalKey<Schema.Number>;
|
|
21
|
+
readonly state: Schema.Literals<readonly ["waiting", "running", "failed"]>;
|
|
22
|
+
readonly error: Schema.optionalKey<Schema.String>;
|
|
23
|
+
readonly failedAt: Schema.optionalKey<Schema.Number>;
|
|
24
|
+
readonly progress: Schema.optionalKey<Schema.Struct<{
|
|
25
|
+
readonly phase: Schema.String;
|
|
26
|
+
readonly measures: Schema.$Array<Schema.Struct<{
|
|
27
|
+
readonly unit: Schema.Literals<readonly ["bytes", "objects", "entries", "packs"]>;
|
|
28
|
+
readonly completed: Schema.Number;
|
|
29
|
+
readonly total: Schema.optionalKey<Schema.Number>;
|
|
30
|
+
}>>;
|
|
31
|
+
readonly attempt: Schema.Number;
|
|
32
|
+
readonly at: Schema.Number;
|
|
33
|
+
}>>;
|
|
34
|
+
}>>>;
|
|
35
|
+
readonly next: Schema.optionalKey<Schema.String>;
|
|
36
|
+
}>>, Schema.toCodecJson<HttpApiSchema.encodeToWithHeaders<Schema.Codec<{
|
|
11
37
|
readonly code: "ALREADY_EXISTS";
|
|
12
38
|
readonly message: string;
|
|
13
39
|
readonly hint?: string;
|
|
@@ -406,7 +432,7 @@ declare const WorkApiGroup_base: HttpApiGroup.HttpApiGroup<"work", HttpApiEndpoi
|
|
|
406
432
|
}>, {
|
|
407
433
|
"ref0-code": Schema.String;
|
|
408
434
|
'www-authenticate': Schema.String;
|
|
409
|
-
}>>, GitCallerMiddleware, GitRestServices> | HttpApiEndpoint.HttpApiEndpoint<"
|
|
435
|
+
}>>, GitCallerMiddleware, GitRestServices> | HttpApiEndpoint.HttpApiEndpoint<"discard", "POST", "/repos/:repo/-/work/discard", Schema.toCodecStringTree<Schema.Struct<{
|
|
410
436
|
repo: Schema.String;
|
|
411
437
|
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
412
438
|
readonly name: Schema.String;
|
|
@@ -811,39 +837,13 @@ declare const WorkApiGroup_base: HttpApiGroup.HttpApiGroup<"work", HttpApiEndpoi
|
|
|
811
837
|
}>, {
|
|
812
838
|
"ref0-code": Schema.String;
|
|
813
839
|
'www-authenticate': Schema.String;
|
|
814
|
-
}>>, GitCallerMiddleware, GitRestServices> | HttpApiEndpoint.HttpApiEndpoint<"
|
|
840
|
+
}>>, GitCallerMiddleware, GitRestServices> | HttpApiEndpoint.HttpApiEndpoint<"retry", "POST", "/repos/:repo/-/work/retry", Schema.toCodecStringTree<Schema.Struct<{
|
|
815
841
|
repo: Schema.String;
|
|
816
|
-
}>>, Schema.
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
}>>, never,
|
|
821
|
-
readonly items: Schema.mutable<Schema.$Array<Schema.Struct<{
|
|
822
|
-
readonly scope: Schema.String;
|
|
823
|
-
readonly name: Schema.String;
|
|
824
|
-
readonly key: Schema.String;
|
|
825
|
-
readonly data: Schema.Unknown;
|
|
826
|
-
readonly due: Schema.Number;
|
|
827
|
-
readonly attempt: Schema.Number;
|
|
828
|
-
readonly trace: Schema.optionalKey<Schema.String>;
|
|
829
|
-
readonly firstTry: Schema.optionalKey<Schema.Number>;
|
|
830
|
-
readonly claim: Schema.optionalKey<Schema.Number>;
|
|
831
|
-
readonly state: Schema.Literals<readonly ["waiting", "running", "failed"]>;
|
|
832
|
-
readonly error: Schema.optionalKey<Schema.String>;
|
|
833
|
-
readonly failedAt: Schema.optionalKey<Schema.Number>;
|
|
834
|
-
readonly progress: Schema.optionalKey<Schema.Struct<{
|
|
835
|
-
readonly phase: Schema.String;
|
|
836
|
-
readonly measures: Schema.$Array<Schema.Struct<{
|
|
837
|
-
readonly unit: Schema.Literals<readonly ["bytes", "objects", "entries", "packs"]>;
|
|
838
|
-
readonly completed: Schema.Number;
|
|
839
|
-
readonly total: Schema.optionalKey<Schema.Number>;
|
|
840
|
-
}>>;
|
|
841
|
-
readonly attempt: Schema.Number;
|
|
842
|
-
readonly at: Schema.Number;
|
|
843
|
-
}>>;
|
|
844
|
-
}>>>;
|
|
845
|
-
readonly next: Schema.optionalKey<Schema.String>;
|
|
846
|
-
}>>, Schema.toCodecJson<HttpApiSchema.encodeToWithHeaders<Schema.Codec<{
|
|
842
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
843
|
+
readonly name: Schema.String;
|
|
844
|
+
readonly key: Schema.String;
|
|
845
|
+
readonly requestKey: Schema.optionalKey<Schema.String>;
|
|
846
|
+
}>>, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<HttpApiSchema.encodeToWithHeaders<Schema.Codec<{
|
|
847
847
|
readonly code: "ALREADY_EXISTS";
|
|
848
848
|
readonly message: string;
|
|
849
849
|
readonly hint?: string;
|
package/dist/server/joined.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Caller } from "../contracts/actors.mjs";
|
|
2
2
|
import { InternalRepoId, RepoName } from "../contracts/ids.mjs";
|
|
3
|
-
import { Bucket } from "../contracts/objects.mjs";
|
|
3
|
+
import { Bucket, EffectiveLimits } from "../contracts/objects.mjs";
|
|
4
4
|
import { Clock, Store } from "../contracts/promises.mjs";
|
|
5
5
|
import { QueueKeys } from "../contracts/queue.mjs";
|
|
6
6
|
import { RepoRecord } from "../contracts/repos.mjs";
|
|
@@ -24,8 +24,8 @@ export interface JoinedAdapter {
|
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* What a package joined to a `createGitServer` server reads beside Git's services: the calls
|
|
27
|
-
* `RepoRecords`, `Authorize` and `Refs` don't make, each through the server's door.
|
|
28
|
-
*
|
|
27
|
+
* `RepoRecords`, `Authorize` and `Refs` don't make, each through the server's door. `Git.layer`
|
|
28
|
+
* provides it to the drop-in; the bridge, `joinLayer`, goes with `createGitServer` in 2c-3b.
|
|
29
29
|
*/
|
|
30
30
|
export interface Joined {
|
|
31
31
|
/** The server itself, for what goes through its own `fetch`. */
|
|
@@ -34,6 +34,12 @@ export interface Joined {
|
|
|
34
34
|
/** The server's one queue's `keys`, or `undefined` with no queue. */
|
|
35
35
|
readonly queueKeys: QueueKeys | undefined;
|
|
36
36
|
readonly adapter: JoinedAdapter;
|
|
37
|
+
/**
|
|
38
|
+
* The server's `fetchLimits`: core's purge drops a deleted repo's scopes, its joined package's
|
|
39
|
+
* too, no sooner than `milliseconds` past the delete, so a write that read the repo live and
|
|
40
|
+
* commits within that, less `jobLeaseMargin`, commits before the drop.
|
|
41
|
+
*/
|
|
42
|
+
readonly fetchLimits: EffectiveLimits;
|
|
37
43
|
/**
|
|
38
44
|
* A request's budget: the adapter's `callLimits`, named `request`. Made before `identify`, so the
|
|
39
45
|
* sign-in read counts into it too (#725).
|
|
@@ -75,8 +81,8 @@ export interface Joining<ROut> {
|
|
|
75
81
|
}
|
|
76
82
|
/**
|
|
77
83
|
* Builds `layer` in `git`'s build, over Git's services and `JoinedCalls`, after the server's own
|
|
78
|
-
* features and before its seal, so what it registers is sealed with Git's:
|
|
79
|
-
*
|
|
84
|
+
* features and before its seal, so what it registers is sealed with Git's: a bridge, which 2c-3b
|
|
85
|
+
* removes with `createGitServer`. Refused after the tick
|
|
80
86
|
* that made the server.
|
|
81
87
|
*/
|
|
82
88
|
export declare const joinLayer: <ROut, RIn>(git: GitServer, layer: Layer.Layer<ROut, GitError, RIn>) => Joining<ROut>;
|
package/dist/server/joined.mjs
CHANGED
|
@@ -50,6 +50,7 @@ const joinedOf = (git, built) => {
|
|
|
50
50
|
return attached.queueKeys;
|
|
51
51
|
},
|
|
52
52
|
adapter: built.adapter,
|
|
53
|
+
fetchLimits: attached.fetchLimits,
|
|
53
54
|
request: () => syncIn(requestBudget(built.parts.requestMost), noCall),
|
|
54
55
|
identify: attached.identify,
|
|
55
56
|
callsFor: attached.callsFor,
|
|
@@ -70,8 +71,8 @@ const joinedOf = (git, built) => {
|
|
|
70
71
|
const lateJoin = (call) => `${call} joins a server in the tick createGitServer made it in: call it where the server is made, before any await`;
|
|
71
72
|
/**
|
|
72
73
|
* Builds `layer` in `git`'s build, over Git's services and `JoinedCalls`, after the server's own
|
|
73
|
-
* features and before its seal, so what it registers is sealed with Git's:
|
|
74
|
-
*
|
|
74
|
+
* features and before its seal, so what it registers is sealed with Git's: a bridge, which 2c-3b
|
|
75
|
+
* removes with `createGitServer`. Refused after the tick
|
|
75
76
|
* that made the server.
|
|
76
77
|
*/
|
|
77
78
|
const joinLayer = (git, layer) => {
|
package/dist/server/registry.mjs
CHANGED
|
@@ -7,8 +7,10 @@ import { bindHookGroups } from "../core/hooks/groups.mjs";
|
|
|
7
7
|
import { bandRank, byOrder, orderedOf } from "../core/hooks/order.mjs";
|
|
8
8
|
import { upkeepsOf } from "../core/repack.mjs";
|
|
9
9
|
import { gitsOwnRefs, registeredRow } from "../protocol/wire/lines.mjs";
|
|
10
|
+
import { gitJob } from "../store/job-try.mjs";
|
|
10
11
|
import { answersMethod, bySpecificity, matchPath, routePath } from "./route-match.mjs";
|
|
11
12
|
import * as Effect from "effect/Effect";
|
|
13
|
+
import * as Context from "effect/Context";
|
|
12
14
|
// src/server/registry.ts
|
|
13
15
|
const sealedDefect = () => /* @__PURE__ */ new Error("Git's registry is sealed");
|
|
14
16
|
/** A clash, as the build fails with it. */
|
|
@@ -201,12 +203,15 @@ const openRegistry = (basePath = "") => {
|
|
|
201
203
|
purges.push(orderedOf(name, step));
|
|
202
204
|
}),
|
|
203
205
|
addRoute: (route) => adding(() => routeClash(name, route)),
|
|
204
|
-
addJob: (
|
|
206
|
+
addJob: (job, handler, options) => Effect.flatMap(Effect.context(), (context) => adding(() => {
|
|
207
|
+
const within = (effect) => Effect.updateContext(effect, (current) => Context.merge(context, current));
|
|
208
|
+
const onFailure = options?.onFailure;
|
|
209
|
+
const definition = gitJob(job, (data) => within(handler(data)), onFailure === void 0 ? {} : { onFailure: (data, failure) => within(onFailure(data, failure)) });
|
|
205
210
|
if (!definition.name.startsWith(`${name}.`)) return clash(`${name}'s jobs are named '${name}.…': got '${definition.name}'`);
|
|
206
211
|
const found = jobClash(definition);
|
|
207
212
|
if (found === void 0) pending.push(definition);
|
|
208
213
|
return found;
|
|
209
|
-
}),
|
|
214
|
+
})),
|
|
210
215
|
addGrant: (resolver) => adding(() => grantClash(name, resolver))
|
|
211
216
|
};
|
|
212
217
|
const answer = owner === void 0 ? made : {
|
|
@@ -268,10 +273,11 @@ const openRegistry = (basePath = "") => {
|
|
|
268
273
|
pushRules: () => rules,
|
|
269
274
|
pushChecks: () => ordered(checks),
|
|
270
275
|
hookGroups: () => ordered(hookGroups),
|
|
271
|
-
upkeep: (store, repo, at) => upkeepsOf(ordered(upkeeps).map(({ handler }) => () => handler({
|
|
276
|
+
upkeep: (store, repo, at, deleted) => upkeepsOf(ordered(upkeeps).map(({ handler }) => () => handler({
|
|
272
277
|
repo,
|
|
273
|
-
at
|
|
274
|
-
|
|
278
|
+
at,
|
|
279
|
+
deleted
|
|
280
|
+
})))(store, repo, at, deleted),
|
|
275
281
|
purge: Effect.fnUntraced(function* (_store, repo) {
|
|
276
282
|
for (const { handler } of ordered(purges)) {
|
|
277
283
|
const step = yield* handler({ repo });
|
package/dist/server/server.mjs
CHANGED
|
@@ -32,6 +32,7 @@ import { Events, keepsEvents } from "../contracts/events.mjs";
|
|
|
32
32
|
import { callServices } from "../core/call-services.mjs";
|
|
33
33
|
import { repackJob, repackJobRow, upkeepsOf } from "../core/repack.mjs";
|
|
34
34
|
import { indexJob, indexJobRow } from "../core/index-job.mjs";
|
|
35
|
+
import { indexLostAsk } from "../core/index-lost.mjs";
|
|
35
36
|
import { purgeJob, purgeJobRow } from "../core/purge.mjs";
|
|
36
37
|
import { refIndexJob, refIndexJobRow } from "../core/ref-index-job.mjs";
|
|
37
38
|
import { forkCalls } from "../core/forks.mjs";
|
|
@@ -66,13 +67,14 @@ import { countedBucket } from "../storage/counted-bucket.mjs";
|
|
|
66
67
|
import { hostFailures, hostLinks, hostUploads } from "../storage/host-bucket.mjs";
|
|
67
68
|
import { pushUploadUpkeep } from "../storage/push-uploads.mjs";
|
|
68
69
|
import { checkedLimits, countedMost, hookCallsBefore, lessBefore, noScope } from "../store/call-count.mjs";
|
|
69
|
-
import { jobLimitsOf, jobsWithin } from "../store/job-try.mjs";
|
|
70
|
+
import { gitJob, jobLimitsOf, jobsWithin } from "../store/job-try.mjs";
|
|
70
71
|
import { exitOn, noCall, syncIn, uncounted } from "../store/crossing.mjs";
|
|
71
72
|
import { pruneFloor } from "../storage/rows.mjs";
|
|
72
73
|
import { queueJobs } from "../queue/advance.mjs";
|
|
73
74
|
import { queueCalls } from "../queue/calls.mjs";
|
|
74
75
|
import { QueueBase, QueueInternals, queueKeysOf, queueOptions } from "../queue/host.mjs";
|
|
75
76
|
import { queuePush } from "../queue/push-option.mjs";
|
|
77
|
+
import { buildMillisecondsOf } from "../queue/limits.mjs";
|
|
76
78
|
import { topicsOptions } from "../topics/host.mjs";
|
|
77
79
|
import { TopicsBase, topicsRegistration } from "../topics/layer.mjs";
|
|
78
80
|
import { MergeQueue } from "../contracts/queue.mjs";
|
|
@@ -148,7 +150,7 @@ const namesOf = (optional, tokensOn, queueOn) => {
|
|
|
148
150
|
const partsOnce = (loaded) => {
|
|
149
151
|
const parts = Effect.map(loaded, (context) => Context.get(context, MergeParts));
|
|
150
152
|
return {
|
|
151
|
-
mergeTrees: (read, input, allot, call) => Effect.flatMap(parts, (one) => one.mergeTrees(read, input, allot, call)),
|
|
153
|
+
mergeTrees: (read, input, allot, call, roots) => Effect.flatMap(parts, (one) => one.mergeTrees(read, input, allot, call, roots)),
|
|
152
154
|
lineDiff: (allot) => Effect.flatMap(parts, (one) => one.lineDiff(allot))
|
|
153
155
|
};
|
|
154
156
|
};
|
|
@@ -286,6 +288,13 @@ const wireServer = (options, wiring) => {
|
|
|
286
288
|
cursors: cursorSeal(store)
|
|
287
289
|
};
|
|
288
290
|
if (indexRow !== void 0) parts.indexJobRow = indexRow;
|
|
291
|
+
const status = SealedObjects.indexStatus(sealed);
|
|
292
|
+
if (indexRow !== void 0 && status !== void 0) parts.indexLost = indexLostAsk({
|
|
293
|
+
store,
|
|
294
|
+
indexJobRow: indexRow,
|
|
295
|
+
status,
|
|
296
|
+
now
|
|
297
|
+
});
|
|
289
298
|
parts.purgeJobRow = (at) => purgeJobRow(purge, at + fetchLimits.milliseconds);
|
|
290
299
|
if (refIndex !== void 0) parts.refIndex = refIndex;
|
|
291
300
|
if (rebuild !== void 0) parts.refIndexJobRow = () => refIndexJobRow(rebuild);
|
|
@@ -319,7 +328,8 @@ const wireServer = (options, wiring) => {
|
|
|
319
328
|
needs,
|
|
320
329
|
records: rawRecords,
|
|
321
330
|
options: queueOf,
|
|
322
|
-
keys: wiring.optional.queueKeys
|
|
331
|
+
keys: wiring.optional.queueKeys,
|
|
332
|
+
buildMilliseconds: buildMillisecondsOf(adapter.requestLimits.cpuMs)
|
|
323
333
|
};
|
|
324
334
|
const queueHeld = wiring.queue;
|
|
325
335
|
queueHeld.host = queueHost;
|
|
@@ -327,6 +337,7 @@ const wireServer = (options, wiring) => {
|
|
|
327
337
|
records: rawRecords,
|
|
328
338
|
needs,
|
|
329
339
|
onFailure,
|
|
340
|
+
cpuMs: adapter.requestLimits.cpuMs,
|
|
330
341
|
attach: (host) => Effect.suspend(() => {
|
|
331
342
|
if (queueHeld.host !== void 0) return Effect.die(/* @__PURE__ */ new TypeError("The server has a merge queue: provide MergeQueue.layer once"));
|
|
332
343
|
queueHeld.host = host;
|
|
@@ -361,7 +372,7 @@ const wireServer = (options, wiring) => {
|
|
|
361
372
|
});
|
|
362
373
|
if (queueHost !== void 0) {
|
|
363
374
|
registry.bridge("queue", "refs/queue/");
|
|
364
|
-
const queueJobList = queueJobs(queueHost, onFailure);
|
|
375
|
+
const queueJobList = queueJobs(queueHost, onFailure).map((job) => job(gitJob));
|
|
365
376
|
gits.knowJobs(queueJobList);
|
|
366
377
|
jobs.register(...jobsWithin(jobLimits, queueJobList));
|
|
367
378
|
}
|
|
@@ -759,6 +770,7 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
759
770
|
attachJoins(server, {
|
|
760
771
|
admit: life.admit,
|
|
761
772
|
basePath,
|
|
773
|
+
fetchLimits,
|
|
762
774
|
get queueKeys() {
|
|
763
775
|
return queueHeld.host?.keys;
|
|
764
776
|
},
|
|
@@ -58,22 +58,29 @@ const edgesHeaderBytes = 24;
|
|
|
58
58
|
const noNumber = 4294967295;
|
|
59
59
|
/** A bitmap kept whole, not as the XOR of another. */
|
|
60
60
|
const noBase = 4294967295;
|
|
61
|
+
/** No root positions: a repo with no roots. */
|
|
62
|
+
const noRootPositions = /* @__PURE__ */ new Set();
|
|
61
63
|
/**
|
|
62
64
|
* A slice's edges file from its links and their joined `targets`, those a shallow commit lacks
|
|
63
|
-
* left out
|
|
65
|
+
* left out, and the parents of each commit at one of `roots`, the repo's roots by position, so no
|
|
66
|
+
* reach passes a root: what it covers, and its bytes.
|
|
64
67
|
*/
|
|
65
|
-
const edgesFileOf = (key, first, positions, links, targets) => {
|
|
66
|
-
let kept = 0;
|
|
67
|
-
for (const target of targets) if (target !== 4294967295) kept += 1;
|
|
68
|
+
const edgesFileOf = (key, first, positions, links, targets, roots = noRootPositions) => {
|
|
68
69
|
const sources = links.sources;
|
|
69
|
-
const
|
|
70
|
+
const kept = (source, at, from) => targets[at] !== void 0 && targets[at] !== 4294967295 && !(roots.has(links.positionOf(source)) && links.mayLack(source, at - from));
|
|
71
|
+
let count = 0;
|
|
72
|
+
for (let source = 0; source < sources; source += 1) {
|
|
73
|
+
const [from, to] = links.linksOf(source);
|
|
74
|
+
for (let at = from; at < to; at += 1) if (kept(source, at, from)) count += 1;
|
|
75
|
+
}
|
|
76
|
+
const bytes = new Uint8Array(edgesHeaderBytes + sources * 8 + 4 + count * 4);
|
|
70
77
|
const view = new DataView(bytes.buffer);
|
|
71
78
|
bytes.set(edgesMagic);
|
|
72
79
|
view.setUint32(4, 1);
|
|
73
80
|
view.setUint32(8, first);
|
|
74
81
|
view.setUint32(12, positions);
|
|
75
82
|
view.setUint32(16, sources);
|
|
76
|
-
view.setUint32(20,
|
|
83
|
+
view.setUint32(20, count);
|
|
77
84
|
const starts = edgesHeaderBytes + sources * 4;
|
|
78
85
|
const ends = starts + (sources + 1) * 4;
|
|
79
86
|
let link = 0;
|
|
@@ -82,9 +89,8 @@ const edgesFileOf = (key, first, positions, links, targets) => {
|
|
|
82
89
|
view.setUint32(starts + source * 4, link);
|
|
83
90
|
const [from, to] = links.linksOf(source);
|
|
84
91
|
for (let at = from; at < to; at += 1) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
view.setUint32(ends + link * 4, target);
|
|
92
|
+
if (!kept(source, at, from)) continue;
|
|
93
|
+
view.setUint32(ends + link * 4, targets[at] ?? 4294967295);
|
|
88
94
|
link += 1;
|
|
89
95
|
}
|
|
90
96
|
}
|
|
@@ -95,7 +101,7 @@ const edgesFileOf = (key, first, positions, links, targets) => {
|
|
|
95
101
|
first,
|
|
96
102
|
positions,
|
|
97
103
|
sources,
|
|
98
|
-
links:
|
|
104
|
+
links: count
|
|
99
105
|
},
|
|
100
106
|
bytes
|
|
101
107
|
};
|
|
@@ -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";
|
|
@@ -173,13 +175,17 @@ const IndexRefusal = /* @__PURE__ */ Schema.Struct({
|
|
|
173
175
|
* builds it replaced, still in prune's grace. A reader takes every layer from this one row, so
|
|
174
176
|
* it never mixes layers of two versions. Each layer's region IDs are its `.region` file, so a
|
|
175
177
|
* row that leaves after the build changes nothing. `rounds` is how many rounds of tries the repo
|
|
176
|
-
* 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.
|
|
177
182
|
*/
|
|
178
183
|
const BuiltIndex = /* @__PURE__ */ Schema.Struct({
|
|
179
184
|
rounds: Count,
|
|
180
185
|
layers: Schema.Array(IndexLayer),
|
|
181
186
|
replaced: Schema.Array(ReplacedBuild),
|
|
182
|
-
refusal: Schema.optionalKey(IndexRefusal)
|
|
187
|
+
refusal: Schema.optionalKey(IndexRefusal),
|
|
188
|
+
lost: Schema.optionalKey(Schema.Literal(true))
|
|
183
189
|
});
|
|
184
190
|
/** How long a repo waits after its first refusal for spent tries before a push saves more. */
|
|
185
191
|
const triesWait = 864e5;
|
|
@@ -233,8 +239,30 @@ const decodeRowOption = /* @__PURE__ */ Schema.decodeUnknownOption(IndexRow);
|
|
|
233
239
|
const builtOf = (row) => row === void 0 || "refused" in row || row.layers.length === 0 ? void 0 : row;
|
|
234
240
|
/** An `index` row's value decoded, at the read's boundary: none for one unreadable. */
|
|
235
241
|
const decodeIndexValue = decodeRowOption;
|
|
236
|
-
/**
|
|
237
|
-
|
|
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
|
+
};
|
|
238
266
|
/** A prune's end, with when the next file it kept is due. */
|
|
239
267
|
const prunedAt = (due) => due === void 0 ? { kind: "pruned" } : {
|
|
240
268
|
kind: "pruned",
|
|
@@ -612,9 +640,11 @@ const regionStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, d
|
|
|
612
640
|
const files = indexFiles(listed.repo, data.build);
|
|
613
641
|
const { layout, first, packed } = yield* layoutOf(bucket, listed, data);
|
|
614
642
|
const held = data.below.length === 0 ? void 0 : yield* heldBelow(parts, listed, layout, first);
|
|
643
|
+
const roots = yield* rootsAt(parts, listed);
|
|
615
644
|
const links = new SliceLinks((bytes) => allotment.tryGrow(bytes));
|
|
616
645
|
const types = [];
|
|
617
646
|
const commits = [];
|
|
647
|
+
const rootPositions = /* @__PURE__ */ new Set();
|
|
618
648
|
const parsed = Effect.fnUntraced(function* (object, at) {
|
|
619
649
|
types.push(typeCodes[object.type]);
|
|
620
650
|
if (object.type === "blob") return;
|
|
@@ -631,6 +661,7 @@ const regionStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, d
|
|
|
631
661
|
oid: object.oid,
|
|
632
662
|
parents: named.slice(1)
|
|
633
663
|
});
|
|
664
|
+
if (roots.has(object.oid)) rootPositions.add(packed + at);
|
|
634
665
|
}
|
|
635
666
|
});
|
|
636
667
|
const read = yield* readRegion(parts, listed, (row, at) => Effect.gen(function* () {
|
|
@@ -650,7 +681,7 @@ const regionStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, d
|
|
|
650
681
|
const targets = yield* joinCharged(links, layout.ranges, region, allotment);
|
|
651
682
|
const slice = data.slices.length;
|
|
652
683
|
yield* allotment.grow(edgesMostOf(links) + read.rows + graphFileBytes(commits));
|
|
653
|
-
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);
|
|
654
685
|
yield* putOnce(bucket, edges.slice.key, edges.bytes);
|
|
655
686
|
yield* putOnce(bucket, files.typesPart(slice, read.rows), Uint8Array.from(types));
|
|
656
687
|
yield* putOnce(bucket, files.basesPart(slice, read.rows), /* @__PURE__ */ new Uint8Array(0));
|
|
@@ -677,6 +708,15 @@ const heldBelow = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, la
|
|
|
677
708
|
return held;
|
|
678
709
|
});
|
|
679
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
|
+
/**
|
|
680
720
|
* What the region holds of each row past its links: its ID, twice while the IDs grow, its type,
|
|
681
721
|
* and a commit's entry and its ID as text, rounded up.
|
|
682
722
|
*/
|
|
@@ -695,7 +735,8 @@ const graphStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, da
|
|
|
695
735
|
graphs,
|
|
696
736
|
key: files.graph,
|
|
697
737
|
allotment,
|
|
698
|
-
most: parts.graphMost
|
|
738
|
+
most: parts.graphMost,
|
|
739
|
+
roots: yield* rootsAt(parts, listed)
|
|
699
740
|
};
|
|
700
741
|
if (below !== void 0) graphInput.below = below;
|
|
701
742
|
const written = (yield* storedSize(parts.bucket, files.graph)) === void 0 ? yield* writeIndexGraph(graphInput) : {
|
|
@@ -744,6 +785,7 @@ const storedTypesOf = (bucket, files, slices, base) => Effect.fnUntraced(functio
|
|
|
744
785
|
*/
|
|
745
786
|
const readStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, allotment) {
|
|
746
787
|
const { counted } = parts;
|
|
788
|
+
const roots = yield* rootsAt(parts, listed);
|
|
747
789
|
const counts = data.packs.map((id) => listed.packs.find((each) => each.id === id)?.objects ?? 0);
|
|
748
790
|
const bounds = parts.bounds ?? sliceBounds;
|
|
749
791
|
const entries = data.narrowed?.entries ?? bounds.entries ?? 65536;
|
|
@@ -804,7 +846,8 @@ const readStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, dat
|
|
|
804
846
|
calls: counted === void 0 ? void 0 : {
|
|
805
847
|
made: () => counted.made().bucket,
|
|
806
848
|
most: counted.most.bucket - reserve.bucket
|
|
807
|
-
}
|
|
849
|
+
},
|
|
850
|
+
roots
|
|
808
851
|
});
|
|
809
852
|
through = parts.bucket;
|
|
810
853
|
if (slice.spent !== void 0) return withNarrowed(data, narrowedAfter(data.narrowed, at.position, {
|
|
@@ -817,7 +860,7 @@ const readStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, dat
|
|
|
817
860
|
const targets = yield* joinCharged(links, ranges, region, allotment);
|
|
818
861
|
yield* allotment.grow(edgesMostOf(links) + slice.bases.length * 4);
|
|
819
862
|
const positions = slice.types.length;
|
|
820
|
-
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);
|
|
821
864
|
yield* putOnce(bucket, made.slice.key, made.bytes);
|
|
822
865
|
yield* putOnce(bucket, files.typesPart(number, positions), slice.types);
|
|
823
866
|
yield* putOnce(bucket, files.basesPart(number, positions), wordsBytes(slice.bases));
|
|
@@ -1171,6 +1214,7 @@ const bitmapsWritten = /* @__PURE__ */ Effect.fnUntraced(function* (parts, lower
|
|
|
1171
1214
|
allotment,
|
|
1172
1215
|
bits: walking
|
|
1173
1216
|
};
|
|
1217
|
+
const rootsOnce = yield* Effect.cached(rootsAt(parts, listed));
|
|
1174
1218
|
const below = data.below.length === 0 ? void 0 : {
|
|
1175
1219
|
first,
|
|
1176
1220
|
entries: entriesBelow,
|
|
@@ -1185,7 +1229,10 @@ const bitmapsWritten = /* @__PURE__ */ Effect.fnUntraced(function* (parts, lower
|
|
|
1185
1229
|
};
|
|
1186
1230
|
} };
|
|
1187
1231
|
if (walks.carried?.position === position) carry.from = walks.carried.walk;
|
|
1188
|
-
const walked = yield* reachOf(
|
|
1232
|
+
const walked = yield* reachOf({
|
|
1233
|
+
...reach,
|
|
1234
|
+
roots: yield* rootsOnce
|
|
1235
|
+
}, [{ position }], carry);
|
|
1189
1236
|
if (walked === void 0) return void 0;
|
|
1190
1237
|
const most = ewahMostWords(walked.length) * 4;
|
|
1191
1238
|
yield* allotment.grow(8 + most);
|
|
@@ -1884,7 +1931,8 @@ const indexStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, in
|
|
|
1884
1931
|
refusal: {
|
|
1885
1932
|
reason,
|
|
1886
1933
|
...held
|
|
1887
|
-
}
|
|
1934
|
+
},
|
|
1935
|
+
...kept.lost === true && { lost: true }
|
|
1888
1936
|
}
|
|
1889
1937
|
};
|
|
1890
1938
|
return {
|
|
@@ -1921,14 +1969,14 @@ const indexStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, in
|
|
|
1921
1969
|
if (input.failed !== void 0) return waiting(input.failed.reason);
|
|
1922
1970
|
if (input.data === void 0 && row !== void 0 && !indexSaves(indexStatus(row, limits, input.at, listedIds(listed)))) return prunedAt(yield* prune());
|
|
1923
1971
|
const built = builtOf(row);
|
|
1924
|
-
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;
|
|
1925
1973
|
if (current === true) return prunedAt(yield* prune());
|
|
1926
1974
|
if (current === "moved" && input.lastCheck !== true) return { kind: "moved" };
|
|
1927
1975
|
const fresh = () => built === void 0 || current === "lost" || !coversAll(built.layers, listed) ? started(listed) : built.layers.length < 8 ? startedUpdate(listed, built) : startedMerge(listed, built);
|
|
1928
1976
|
const kept = input.data;
|
|
1929
1977
|
const sameBelow = kept !== void 0 && (kept.below.length === 0 || kept.below.map((layer) => layer.build).join() === (built?.layers ?? []).map((layer) => layer.build).join());
|
|
1930
1978
|
const again = (from) => from.below.length === 0 && from.merge !== true ? started(listed) : fresh();
|
|
1931
|
-
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;
|
|
1932
1980
|
const more = (next) => ({
|
|
1933
1981
|
kind: "more",
|
|
1934
1982
|
data: next
|
|
@@ -2018,4 +2066,4 @@ const indexTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, limits, lis
|
|
|
2018
2066
|
data: ended.data
|
|
2019
2067
|
};
|
|
2020
2068
|
});
|
|
2021
|
-
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, 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";
|