@ref0/git 0.8.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/contracts/calls-spent.d.mts +2 -12
- package/dist/contracts/calls-spent.mjs +4 -5
- 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/core/ancestry.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/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/repack.mjs +36 -14
- package/dist/core/view.d.mts +10 -1
- package/dist/core/view.mjs +15 -6
- 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 +15 -11
- package/dist/http/core-parts.mjs +17 -8
- package/dist/index.d.mts +2 -2
- package/dist/lfs/objects.mjs +7 -4
- package/dist/lfs/upkeep.mjs +6 -5
- package/dist/lfs/upload-most.mjs +7 -1
- 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 +238 -238
- package/dist/rest/forks.d.mts +71 -71
- package/dist/rest/refs.d.mts +143 -143
- package/dist/rest/repos.d.mts +81 -81
- package/dist/rest/topics.d.mts +112 -112
- package/dist/rest/trees.d.mts +77 -77
- 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/queue/advance.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import { handingOn } from "../protocol/packs/writer.mjs";
|
|
|
16
16
|
import { memoryPack } from "../storage/fetch.mjs";
|
|
17
17
|
import { gitObjectOf } from "../storage/object-rows.mjs";
|
|
18
18
|
import { decodeRow } from "../store/errors.mjs";
|
|
19
|
-
import {
|
|
19
|
+
import { jobParts } from "../store/job-try.mjs";
|
|
20
20
|
import { readRecord } from "../store/repo-record.mjs";
|
|
21
21
|
import { isLive, liveState } from "../store/reservations.mjs";
|
|
22
22
|
import { collections, jobRepo } from "../store/scopes.mjs";
|
|
@@ -731,7 +731,11 @@ const liftCandidateWork = (context, state, now, name, key) => {
|
|
|
731
731
|
};
|
|
732
732
|
/** Why a link couldn't be written: a conflict, too many commits, or the host's `merge` failing. */
|
|
733
733
|
const LinkFailure = /* @__PURE__ */ Schema.Union([Schema.Struct({
|
|
734
|
-
kind: Schema.Literals([
|
|
734
|
+
kind: Schema.Literals([
|
|
735
|
+
"conflict",
|
|
736
|
+
"tooManyCommits",
|
|
737
|
+
"tooLarge"
|
|
738
|
+
]),
|
|
735
739
|
summary: Schema.String
|
|
736
740
|
}), Schema.Struct({
|
|
737
741
|
kind: Schema.Literal("host-error"),
|
|
@@ -755,7 +759,7 @@ const commitsPast = (linking, entry, head, tip) => {
|
|
|
755
759
|
return historyUpTo(linking.opened.read, {
|
|
756
760
|
wants: [head],
|
|
757
761
|
haves: [tip]
|
|
758
|
-
}, most + 1, linking.call).pipe(Effect.flatMap((walked) => {
|
|
762
|
+
}, most + 1, linking.call, linking.opened.roots).pipe(Effect.flatMap((walked) => {
|
|
759
763
|
if (walked.length <= most) return Effect.succeed([...walked].reverse());
|
|
760
764
|
const summary = `${entry} adds more than ${most} commits, as many as queue.entryCommits lets a link read`;
|
|
761
765
|
return Effect.fail(linkFailed(entry, {
|
|
@@ -791,7 +795,7 @@ const planOf = (linking, entry, row, commits) => hostCall("queue.merge", { repo:
|
|
|
791
795
|
/** One entry's link onto `tip`, as its plan's method says: the commit the candidate is at after. */
|
|
792
796
|
const linkOnto = /* @__PURE__ */ Effect.fnUntraced(function* (linking, entry, row, tip) {
|
|
793
797
|
const { head } = row;
|
|
794
|
-
const { bases } = yield* mergeBases(linking.opened.read, { commits: [tip, head] }, linking.call);
|
|
798
|
+
const { bases } = yield* mergeBases(linking.opened.read, { commits: [tip, head] }, linking.call, linking.opened.roots);
|
|
795
799
|
if (bases.includes(head)) return tip;
|
|
796
800
|
const [base] = bases;
|
|
797
801
|
if (base === void 0) {
|
|
@@ -895,7 +899,7 @@ const buildStep = /* @__PURE__ */ Effect.fnUntraced(function* (host$1, context,
|
|
|
895
899
|
const options = yield* host$1.options(repo);
|
|
896
900
|
if (options === void 0) return done;
|
|
897
901
|
const opened = yield* asHost(openRead(host, repo));
|
|
898
|
-
const limits = yield* limitsOf();
|
|
902
|
+
const limits = yield* limitsOf({ milliseconds: host$1.buildMilliseconds });
|
|
899
903
|
const { call } = yield* readerOf(opened, limits, "walk-limit");
|
|
900
904
|
const made = new MadeObjects();
|
|
901
905
|
const read = (input) => {
|
|
@@ -946,8 +950,18 @@ const buildStep = /* @__PURE__ */ Effect.fnUntraced(function* (host$1, context,
|
|
|
946
950
|
candidate: id,
|
|
947
951
|
by
|
|
948
952
|
};
|
|
953
|
+
let first;
|
|
954
|
+
const tooLarge = tried.tooLarge?.candidate === id ? tried.tooLarge : void 0;
|
|
949
955
|
const linkOf = Effect.fnUntraced(function* (entry, entryRow, onto) {
|
|
950
956
|
const key = yield* linkKey(linking, onto, entry, entryRow);
|
|
957
|
+
if (reached.at === from) first = {
|
|
958
|
+
entry,
|
|
959
|
+
key
|
|
960
|
+
};
|
|
961
|
+
if (tooLarge?.key === key) return yield* Effect.fail(linkFailed(entry, {
|
|
962
|
+
kind: "tooLarge",
|
|
963
|
+
summary: tooLarge.summary
|
|
964
|
+
}));
|
|
951
965
|
const kept = last.get(key);
|
|
952
966
|
const before = made.count;
|
|
953
967
|
if (kept !== void 0) for (const { type, bytes } of kept.objects) yield* made.add(type, bytes);
|
|
@@ -969,7 +983,21 @@ const buildStep = /* @__PURE__ */ Effect.fnUntraced(function* (host$1, context,
|
|
|
969
983
|
if (reached.at < links.length && (yield* spent(made, call))) break;
|
|
970
984
|
}
|
|
971
985
|
return reached;
|
|
972
|
-
}).pipe(Effect.catchTag("LinkFailed", (failed) => Effect.succeed({ failed })), Effect.catchIf(
|
|
986
|
+
}).pipe(Effect.catchTag("LinkFailed", (failed) => Effect.succeed({ failed })), Effect.catchIf(atLimit, (error) => {
|
|
987
|
+
if (reached.at > from) return Effect.succeed(reached);
|
|
988
|
+
if (first === void 0) return Effect.fail(error);
|
|
989
|
+
const { entry, key } = first;
|
|
990
|
+
const summary = `${entry} can't be linked within one build try: ${error.message}`;
|
|
991
|
+
tried.tooLarge = {
|
|
992
|
+
candidate: id,
|
|
993
|
+
key,
|
|
994
|
+
summary
|
|
995
|
+
};
|
|
996
|
+
return Effect.succeed({ failed: linkFailed(entry, {
|
|
997
|
+
kind: "tooLarge",
|
|
998
|
+
summary
|
|
999
|
+
}) });
|
|
1000
|
+
}));
|
|
973
1001
|
const plan = new QueuePlan(state, now);
|
|
974
1002
|
if ("failed" in built) {
|
|
975
1003
|
const { entry, failure } = built.failed;
|
|
@@ -1226,7 +1254,8 @@ const AdvanceJob = /* @__PURE__ */ Job.make(advanceName, {
|
|
|
1226
1254
|
});
|
|
1227
1255
|
const BuildJob = /* @__PURE__ */ Job.make(buildName, {
|
|
1228
1256
|
payload: CandidateData,
|
|
1229
|
-
retry: queueJobRetry
|
|
1257
|
+
retry: queueJobRetry,
|
|
1258
|
+
timeout: queueLimits.buildTryMilliseconds
|
|
1230
1259
|
});
|
|
1231
1260
|
const TimeoutJob = /* @__PURE__ */ Job.make(timeoutName, {
|
|
1232
1261
|
payload: CandidateData,
|
|
@@ -1243,9 +1272,9 @@ const queueJobs = (host, onFailure) => {
|
|
|
1243
1272
|
const candidateOf = (job, context) => loadCandidate(context, jobRepo(job), job.data.candidate).pipe(Effect.map((loaded) => loaded?.state));
|
|
1244
1273
|
return [
|
|
1245
1274
|
queueTrimJob(host, onFailure),
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1275
|
+
jobParts(AdvanceJob, (data) => queueTry(data, (job, context) => overCore(host, context, advance(host, job, context))), { onFailure: holdOnFailure(host, targetOf, onFailure, unbatch) }),
|
|
1276
|
+
jobParts(BuildJob, (data) => queueTry(data, (job, context) => Effect.asVoid(overCore(host, context, build(job, context)))), { onFailure: holdOnFailure(host, candidateOf, onFailure) }),
|
|
1277
|
+
jobParts(TimeoutJob, (data) => queueTry(data, (job, context) => Effect.asVoid(overCore(host, context, timeout(job, context)))), { onFailure: holdOnFailure(host, candidateOf, onFailure) })
|
|
1249
1278
|
];
|
|
1250
1279
|
};
|
|
1251
1280
|
export { checkPublish, queueJobs };
|
package/dist/queue/host.d.mts
CHANGED
|
@@ -17,6 +17,8 @@ export interface QueueHost {
|
|
|
17
17
|
readonly options: (repo: RepoName) => Effect.Effect<MergeQueueOptions | undefined, GitError>;
|
|
18
18
|
/** The `keys` every repo's queue has, as `queueKeysOf` reads them: `undefined` for one per repo. */
|
|
19
19
|
readonly keys: QueueKeys | undefined;
|
|
20
|
+
/** How long a build try may link for: `queueLimits.buildMilliseconds`, or the host's `cpuMs` when lower. */
|
|
21
|
+
readonly buildMilliseconds: number;
|
|
20
22
|
}
|
|
21
23
|
declare const QueueInternals_base: Context.ServiceClass<QueueInternals, "@ref0/git/queue/QueueInternals", QueueHost>;
|
|
22
24
|
/** Queue internals available only from MergeQueue.layer, never a host's public service. */
|
|
@@ -25,6 +27,8 @@ declare const QueueBase_base: Context.ServiceClass<QueueBase, "@ref0/git/queue/Q
|
|
|
25
27
|
readonly records: Records.RecordsService;
|
|
26
28
|
readonly needs: Context.Context<QueueNeeds>;
|
|
27
29
|
readonly onFailure: WorkFailed | undefined;
|
|
30
|
+
/** The CPU one try may use, from the adapter's `RequestLimits`: none where it gives none. */
|
|
31
|
+
readonly cpuMs: number | undefined;
|
|
28
32
|
readonly attach: (host: QueueHost) => Effect.Effect<void>;
|
|
29
33
|
}>;
|
|
30
34
|
/**
|
package/dist/queue/layer.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { acting } from "../core/parts.mjs";
|
|
|
5
5
|
import { queueJobs } from "./advance.mjs";
|
|
6
6
|
import { queueCalls } from "./calls.mjs";
|
|
7
7
|
import { QueueBase, QueueInternals, queueKeysOf, queueOptions } from "./host.mjs";
|
|
8
|
+
import { buildMillisecondsOf } from "./limits.mjs";
|
|
8
9
|
import * as Effect from "effect/Effect";
|
|
9
10
|
import * as Option from "effect/Option";
|
|
10
11
|
import * as Context from "effect/Context";
|
|
@@ -51,9 +52,10 @@ const layer = (options) => {
|
|
|
51
52
|
records: base.records,
|
|
52
53
|
needs: Context.add(base.needs, MergeParts, parts.value),
|
|
53
54
|
options: optionsOf,
|
|
54
|
-
keys: queueKeysOf(options)
|
|
55
|
+
keys: queueKeysOf(options),
|
|
56
|
+
buildMilliseconds: buildMillisecondsOf(base.cpuMs)
|
|
55
57
|
};
|
|
56
|
-
for (const job of queueJobs(host, base.onFailure)) yield* registration.addJob
|
|
58
|
+
for (const job of queueJobs(host, base.onFailure)) yield* job(registration.addJob);
|
|
57
59
|
yield* base.attach(host);
|
|
58
60
|
return Context.make(MergeQueue, queueService(host)).pipe(Context.add(QueueInternals, host));
|
|
59
61
|
}));
|
package/dist/queue/limits.mjs
CHANGED
|
@@ -127,8 +127,24 @@ const queueLimits = {
|
|
|
127
127
|
* The most `queue.entryCommits` may be, so the walk never grows past it: an entry of more
|
|
128
128
|
* commits merges by an admin's direct push.
|
|
129
129
|
*/
|
|
130
|
-
entryCommitsMost: 1e4
|
|
130
|
+
entryCommitsMost: 1e4,
|
|
131
|
+
/**
|
|
132
|
+
* How long one build try may link for, past `limitsOf`'s 10 s for a call someone waits on, since
|
|
133
|
+
* a build is a job's try (#1969). At queue-entry-10k's reading, about 3 s of CPU each 10 s of
|
|
134
|
+
* wall, it spends about 18 s of CPU, under Cloudflare's 30,000 ms `cpuMs`. A host whose
|
|
135
|
+
* `RequestLimits` gives a lower `cpuMs` takes that instead. A try's first link past it fails its
|
|
136
|
+
* entry `tooLarge`, since the next try would start it over.
|
|
137
|
+
*/
|
|
138
|
+
buildMilliseconds: 6e4,
|
|
139
|
+
/**
|
|
140
|
+
* A `queue.build` try's timeout: its links' `buildMilliseconds`, and as long again to write
|
|
141
|
+
* their pack and commit. Past the 30 s a job's try has by default, which would cut the links
|
|
142
|
+
* first, and well within a Cloudflare alarm's.
|
|
143
|
+
*/
|
|
144
|
+
buildTryMilliseconds: 12e4
|
|
131
145
|
};
|
|
146
|
+
/** How long a build try may link for on a host whose tries may use `cpuMs` of CPU: the less of the two. */
|
|
147
|
+
const buildMillisecondsOf = (cpuMs) => Math.min(queueLimits.buildMilliseconds, cpuMs ?? queueLimits.buildMilliseconds);
|
|
132
148
|
const encoder = new TextEncoder();
|
|
133
149
|
/** A value's size as UTF-8 JSON, as infra counts a row's. */
|
|
134
150
|
const jsonSize = (value) => encoder.encode(JSON.stringify(value)).length;
|
|
@@ -149,4 +165,4 @@ const targetsFull = () => fail("RESOURCE_EXHAUSTED", `The repo's queues hold ${q
|
|
|
149
165
|
hint: `Queue onto a branch the repo queues onto now, or wait: a target's row goes ${queueLimits.kept / day} days after its queue went idle`,
|
|
150
166
|
context: { reason: "queue-targets-full" }
|
|
151
167
|
});
|
|
152
|
-
export { checkBytes, jsonSize, queueFull, queueJobRetry, queueLimits, targetsFull };
|
|
168
|
+
export { buildMillisecondsOf, checkBytes, jsonSize, queueFull, queueJobRetry, queueLimits, targetsFull };
|
package/dist/queue/rows.mjs
CHANGED
|
@@ -130,7 +130,8 @@ const EntryRow = /* @__PURE__ */ Schema.Struct({
|
|
|
130
130
|
"host-error",
|
|
131
131
|
"interaction",
|
|
132
132
|
"refused",
|
|
133
|
-
"tooManyCommits"
|
|
133
|
+
"tooManyCommits",
|
|
134
|
+
"tooLarge"
|
|
134
135
|
])),
|
|
135
136
|
/** Its candidates' land conflicts, which a `retry` keeps: at `landRestarts`, it's pinned. */
|
|
136
137
|
conflicts: Schema.optionalKey(Schema.Int),
|
package/dist/queue/trim.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { decodeRow, storeCall } from "../store/errors.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { jobParts } from "../store/job-try.mjs";
|
|
3
3
|
import { TrimData, trimName } from "../store/queue-jobs.mjs";
|
|
4
4
|
import { readRecord } from "../store/repo-record.mjs";
|
|
5
5
|
import { collections, jobRepo, newChangeId, repoScope } from "../store/scopes.mjs";
|
|
@@ -285,5 +285,5 @@ const TrimJob = /* @__PURE__ */ Job.make(trimName, {
|
|
|
285
285
|
* failure to `onFailure`, so the host's `repo.work.failed` names it and `work.retry` runs it again:
|
|
286
286
|
* a failed job's row stays failed whatever a target's first write saves.
|
|
287
287
|
*/
|
|
288
|
-
const queueTrimJob = (host, onFailure) =>
|
|
288
|
+
const queueTrimJob = (host, onFailure) => jobParts(TrimJob, (cursor) => Effect.flatMap(Effect.all([CurrentJob.store, CurrentJob.current]), ([store, job]) => Effect.flatMap(Effect.provideContext(Clock$1.currentTimeMillis, host.needs), (now) => trimStep(store, jobRepo(job), cursor, now))), onFailure === void 0 ? {} : { onFailure });
|
|
289
289
|
export { queueTrimJob };
|