@ref0/git 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access/private-refs.mjs +3 -4
- package/dist/auth/authorize.mjs +9 -4
- package/dist/auth/identify.d.mts +5 -3
- package/dist/auth/tokens.mjs +12 -11
- package/dist/client/local.mjs +2 -0
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/contracts/access.d.mts +6 -2
- package/dist/contracts/authorize.d.mts +14 -10
- package/dist/contracts/events.d.mts +32 -5
- package/dist/contracts/events.mjs +14 -3
- package/dist/contracts/git.d.mts +68 -3
- package/dist/contracts/grants.d.mts +6 -1
- package/dist/contracts/lfs.d.mts +5 -2
- package/dist/contracts/objects.d.mts +7 -2
- package/dist/contracts/promises.d.mts +2 -14
- package/dist/contracts/push-uploads.d.mts +1 -1
- package/dist/contracts/queue.d.mts +15 -7
- package/dist/contracts/refs.d.mts +1 -1
- package/dist/contracts/result.d.mts +9 -5
- package/dist/contracts/result.mjs +5 -0
- package/dist/contracts/server.d.mts +13 -6
- package/dist/contracts/work.d.mts +1 -1
- package/dist/core/access.mjs +17 -1
- package/dist/core/call-names.d.mts +3 -1
- package/dist/core/claim-rows.d.mts +4 -0
- package/dist/core/claim-rows.mjs +53 -0
- package/dist/core/events/deliver.d.mts +12 -0
- package/dist/core/events/deliver.mjs +367 -145
- package/dist/core/events/seen.mjs +17 -3
- package/dist/core/forks.mjs +82 -20
- package/dist/core/hooks/post-receive.mjs +20 -17
- package/dist/core/index-job.mjs +23 -17
- package/dist/core/parts.d.mts +6 -0
- package/dist/core/purge.d.mts +8 -0
- package/dist/core/purge.mjs +16 -21
- package/dist/core/push-decide.mjs +26 -4
- package/dist/core/push.mjs +57 -20
- package/dist/core/ref-index-job.mjs +9 -14
- package/dist/core/ref-index.d.mts +1 -0
- package/dist/core/ref-index.mjs +28 -8
- package/dist/core/ref-view.mjs +14 -9
- package/dist/core/refs.mjs +13 -11
- package/dist/core/repack.d.mts +2 -1
- package/dist/core/repack.mjs +66 -118
- package/dist/core/repos.mjs +5 -5
- package/dist/core/rules/check.mjs +7 -6
- package/dist/core/rules/context.d.mts +1 -1
- package/dist/core/seam.d.mts +56 -9
- package/dist/core/seam.mjs +7 -1
- package/dist/core/still-takes.mjs +75 -0
- package/dist/core/view.d.mts +1 -0
- package/dist/core/view.mjs +8 -9
- package/dist/core/work.mjs +1 -1
- package/dist/extend.d.mts +2 -1
- package/dist/http/core-parts.mjs +19 -11
- package/dist/http/handler.mjs +2 -2
- package/dist/http/node.d.mts +2 -23
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-uploads.d.mts +10 -2
- package/dist/http/push-uploads.mjs +31 -34
- package/dist/http/receive-pack.mjs +5 -3
- package/dist/http/upload-pack.mjs +2 -2
- package/dist/index.d.mts +11 -7
- package/dist/index.mjs +5 -3
- package/dist/lfs/base.d.mts +32 -0
- package/dist/lfs/base.mjs +8 -0
- package/dist/lfs/calls.mjs +21 -12
- package/dist/lfs/layer.d.mts +27 -0
- package/dist/lfs/layer.mjs +64 -0
- package/dist/lfs/locks.mjs +13 -27
- package/dist/lfs/namespace.d.mts +2 -0
- package/dist/lfs/objects.d.mts +23 -4
- package/dist/lfs/objects.mjs +65 -81
- package/dist/lfs/pointers.mjs +8 -6
- package/dist/lfs/public.d.mts +5 -0
- package/dist/lfs/public.mjs +8 -0
- package/dist/lfs/purge.mjs +19 -25
- package/dist/lfs/rows.mjs +22 -10
- package/dist/lfs/service.d.mts +9 -4
- package/dist/lfs/service.mjs +3 -12
- package/dist/lfs/upkeep.mjs +34 -49
- package/dist/node.d.mts +3 -2
- package/dist/node.mjs +1 -1
- package/dist/protocol/wire/advertisement.d.mts +4 -10
- package/dist/protocol/wire/advertisement.mjs +16 -12
- package/dist/protocol/wire/lines.d.mts +14 -2
- package/dist/protocol/wire/lines.mjs +32 -21
- package/dist/protocol/wire/v2.d.mts +4 -15
- package/dist/protocol/wire/v2.mjs +16 -14
- package/dist/queue/advance.mjs +78 -55
- package/dist/queue/calls.mjs +4 -2
- package/dist/queue/commit.mjs +20 -13
- package/dist/queue/host.d.mts +2 -2
- package/dist/queue/layer.d.mts +4 -2
- package/dist/queue/layer.mjs +8 -3
- package/dist/queue/limits.mjs +36 -6
- package/dist/queue/rows.mjs +14 -5
- package/dist/queue/state.mjs +19 -5
- package/dist/queue/steps.mjs +10 -4
- package/dist/queue/trim.mjs +284 -0
- package/dist/rest/blobs.d.mts +19 -19
- package/dist/rest/caller.d.mts +4 -4
- package/dist/rest/commits.d.mts +96 -96
- package/dist/rest/errors.d.mts +2 -2
- package/dist/rest/events.d.mts +2 -2
- package/dist/rest/files.d.mts +54 -54
- package/dist/rest/forks.d.mts +87 -87
- package/dist/rest/handler.mjs +13 -5
- package/dist/rest/layer.d.mts +14 -0
- package/dist/rest/layer.mjs +52 -0
- package/dist/rest/me.d.mts +2 -2
- package/dist/rest/merges.d.mts +2 -2
- package/dist/rest/namespace.d.mts +2 -0
- package/dist/rest/queue.d.mts +208 -208
- package/dist/rest/refs.d.mts +131 -131
- package/dist/rest/repos.d.mts +12 -12
- package/dist/rest/tags.d.mts +70 -70
- package/dist/rest/tokens.d.mts +23 -23
- package/dist/rest/topics.d.mts +111 -111
- package/dist/rest/trees.d.mts +57 -57
- package/dist/rest/wire.d.mts +2 -0
- package/dist/rest/wire.mjs +2 -2
- package/dist/rest/work.d.mts +6 -6
- package/dist/server/edge-node.d.mts +20 -0
- package/dist/server/edge-node.mjs +20 -0
- package/dist/server/edge.d.mts +10 -0
- package/dist/server/edge.mjs +23 -0
- package/dist/server/extension.mjs +1 -1
- package/dist/server/git-layer.d.mts +15 -4
- package/dist/server/git-layer.mjs +13 -2
- package/dist/server/git-namespace.d.mts +5 -4
- package/dist/server/git-namespace.mjs +6 -3
- package/dist/server/registry.d.mts +3 -0
- package/dist/server/registry.mjs +58 -7
- package/dist/server/server.d.mts +3 -0
- package/dist/server/server.mjs +81 -39
- package/dist/server/uploads.d.mts +14 -0
- package/dist/server/uploads.mjs +15 -0
- package/dist/storage/calls.d.mts +7 -8
- package/dist/storage/calls.mjs +14 -14
- package/dist/storage/clean-up.mjs +59 -29
- package/dist/storage/host-bucket.mjs +16 -1
- package/dist/storage/index-build.d.mts +1 -1
- package/dist/storage/layout.mjs +5 -0
- package/dist/storage/merge.d.mts +1 -1
- package/dist/storage/push-uploads.mjs +12 -16
- package/dist/storage/quarantine.d.mts +1 -1
- package/dist/storage/quarantine.mjs +51 -12
- package/dist/storage/receive-bounds.d.mts +1 -1
- package/dist/storage/repack-job.d.mts +1 -1
- package/dist/storage/repack-job.mjs +7 -14
- package/dist/storage/rows.mjs +42 -3
- package/dist/storage/runs.d.mts +1 -1
- package/dist/store/job-try.mjs +26 -0
- package/dist/store/list-job.mjs +22 -16
- package/dist/store/outbox.mjs +38 -12
- package/dist/store/promises.d.mts +6 -1
- package/dist/store/promises.mjs +74 -89
- package/dist/store/queue-jobs.mjs +22 -1
- package/dist/store/scopes.mjs +0 -10
- package/dist/sync/mirror.d.mts +1 -1
- package/dist/sync/mirror.mjs +1 -1
- package/dist/sync/publish.mjs +12 -7
- package/dist/sync/step.mjs +4 -0
- package/package.json +3 -3
- package/dist/lfs/repo.mjs +0 -42
- package/dist/storage/promise-calls.mjs +0 -29
package/dist/core/push.mjs
CHANGED
|
@@ -5,17 +5,18 @@ import { isUnindexedRead } from "../storage/index-visible.mjs";
|
|
|
5
5
|
import { openTreesRefusal } from "../storage/push-allotment.mjs";
|
|
6
6
|
import { isLoose } from "../storage/loose.mjs";
|
|
7
7
|
import { listedIds } from "../storage/listed-ids.mjs";
|
|
8
|
-
import { indexRowKey, objectCollections } from "../storage/layout.mjs";
|
|
8
|
+
import { indexRowKey, isPackId, objectCollections } from "../storage/layout.mjs";
|
|
9
9
|
import { noLfsPointers } from "../storage/lfs-pointers.mjs";
|
|
10
10
|
import { isShallowRoot } from "../storage/links.mjs";
|
|
11
11
|
import { isAwaitingRepack } from "../storage/repack-backlog.mjs";
|
|
12
12
|
import { allottedRows } from "../storage/allotted.mjs";
|
|
13
13
|
import { gitObjectOf, objectOfRow, receivedRows } from "../storage/object-rows.mjs";
|
|
14
14
|
import { pruneClearedKey } from "../storage/prune.mjs";
|
|
15
|
+
import { abandonOwn } from "../storage/quarantine.mjs";
|
|
15
16
|
import { QuarantineRow, decodeHeld } from "../storage/rows.mjs";
|
|
16
17
|
import { bestEffort, decodeRow, storeCall } from "../store/errors.mjs";
|
|
17
18
|
import { callScope } from "../store/call-count.mjs";
|
|
18
|
-
import { decodePacks } from "../store/git-store.mjs";
|
|
19
|
+
import { decodePacks, gitStore } from "../store/git-store.mjs";
|
|
19
20
|
import { WholeRepo, refBytesOf, storesPeel, wholeRefs } from "../store/ref-rows.mjs";
|
|
20
21
|
import { gitsOwnMove, hiddenUnder } from "../protocol/wire/lines.mjs";
|
|
21
22
|
import { sliceOf } from "../protocol/wire/push-limits.mjs";
|
|
@@ -38,7 +39,7 @@ import { commitChangesOf, coveredTips } from "./rules/commit-changes.mjs";
|
|
|
38
39
|
import { gitsOwnRef, pushRulesFor, runPushRules, unseenRef } from "./rules/check.mjs";
|
|
39
40
|
import { checking } from "./rules/context.mjs";
|
|
40
41
|
import { changedWhileChecked, factsHeld, tipsOf } from "./rules/facts.mjs";
|
|
41
|
-
import { clearsMark, decidePush, otherWritesProblem } from "./push-decide.mjs";
|
|
42
|
+
import { clearsMark, decidePush, otherWritesProblem, pushOptionsProblem } from "./push-decide.mjs";
|
|
42
43
|
import { heldReceipt, receiptReads, receiptWrites, refsAnswer, refsKept, withJobs } from "./receipts.mjs";
|
|
43
44
|
import { SealedObjects, viewOf } from "./view.mjs";
|
|
44
45
|
import { ownWriter, ownWritesOf } from "./own-writes.mjs";
|
|
@@ -52,6 +53,7 @@ import { checkWrites } from "@ref0/infra";
|
|
|
52
53
|
import * as Effect from "effect/Effect";
|
|
53
54
|
import * as Clock$1 from "effect/Clock";
|
|
54
55
|
import * as Result from "effect/Result";
|
|
56
|
+
import * as Exit from "effect/Exit";
|
|
55
57
|
import * as Equal from "effect/Equal";
|
|
56
58
|
// src/core/push.ts
|
|
57
59
|
/**
|
|
@@ -204,7 +206,7 @@ const keyedRead = (caller, operation, missed, internalId) => openKeyed(caller, {
|
|
|
204
206
|
* `pruned` mark.
|
|
205
207
|
*/
|
|
206
208
|
const listedFor = /* @__PURE__ */ Effect.fnUntraced(function* (request, operation, resolved) {
|
|
207
|
-
const { caller
|
|
209
|
+
const { caller } = request;
|
|
208
210
|
const repo = repoAccess(resolved);
|
|
209
211
|
if (request.queued === void 0) yield* check({
|
|
210
212
|
caller,
|
|
@@ -218,8 +220,8 @@ const listedFor = /* @__PURE__ */ Effect.fnUntraced(function* (request, operatio
|
|
|
218
220
|
packs
|
|
219
221
|
};
|
|
220
222
|
const mark = yield* markOf(resolved.snapshot.results[2] ?? []);
|
|
221
|
-
const views = yield* Effect.forEach(decidingFor(request), (one) => viewOf(one, resolved,
|
|
222
|
-
const [view = yield* viewOf(caller, resolved,
|
|
223
|
+
const views = yield* Effect.forEach(decidingFor(request), (one) => viewOf(one, resolved, request.as));
|
|
224
|
+
const [view = yield* viewOf(caller, resolved, request.as)] = views;
|
|
223
225
|
return {
|
|
224
226
|
listed,
|
|
225
227
|
defaultBranch: headOf(resolved.record.defaultBranch),
|
|
@@ -772,8 +774,8 @@ const receive = (objects, listed, request) => {
|
|
|
772
774
|
};
|
|
773
775
|
/**
|
|
774
776
|
* `ref.updated`'s `push`: the write, how many branches and tags it moved and each private
|
|
775
|
-
* pattern's part of them (`pushCounts`), its source,
|
|
776
|
-
*
|
|
777
|
+
* pattern's part of them (`pushCounts`), its source, the slice its push options name, if they do
|
|
778
|
+
* (Q901), and those options, if it sent any.
|
|
777
779
|
*/
|
|
778
780
|
const pushOf = (access, id, moved, request) => {
|
|
779
781
|
const push = {
|
|
@@ -783,9 +785,22 @@ const pushOf = (access, id, moved, request) => {
|
|
|
783
785
|
};
|
|
784
786
|
const slice = sliceOf(request.pushOptions ?? []);
|
|
785
787
|
if (slice !== void 0) push.slice = slice;
|
|
788
|
+
const options = request.pushOptions ?? [];
|
|
789
|
+
if (options.length > 0) push.options = options;
|
|
786
790
|
return push;
|
|
787
791
|
};
|
|
788
792
|
/**
|
|
793
|
+
* Each of `moved` with its kind from `updates`, the push's decided updates. Every moved ref is
|
|
794
|
+
* among them, so the `force` fallback, the kind that claims least, is never taken.
|
|
795
|
+
*/
|
|
796
|
+
const movedKinds = (updates, moved) => {
|
|
797
|
+
const kinds = new Map(updates.map((update) => [update.ref, update.kind]));
|
|
798
|
+
return moved.map((move) => ({
|
|
799
|
+
...move,
|
|
800
|
+
kind: kinds.get(move.ref) ?? "force"
|
|
801
|
+
}));
|
|
802
|
+
};
|
|
803
|
+
/**
|
|
789
804
|
* What a push's commit saves for `hooks.postReceive`, when the host passed one: the push, with
|
|
790
805
|
* the refs it moved and their kinds, at the version the commit makes, and the repo's
|
|
791
806
|
* `git.post-receive` row. Its ID is the commit's own.
|
|
@@ -796,11 +811,7 @@ const savedPush = (checks, push) => {
|
|
|
796
811
|
put: [],
|
|
797
812
|
jobs: []
|
|
798
813
|
};
|
|
799
|
-
const
|
|
800
|
-
const updates = push.moved.map((move) => ({
|
|
801
|
-
...move,
|
|
802
|
-
kind: kinds.get(move.ref) ?? "force"
|
|
803
|
-
}));
|
|
814
|
+
const updates = movedKinds(push.updates, push.moved);
|
|
804
815
|
const { pushOptions, source } = push.request;
|
|
805
816
|
const saved = {
|
|
806
817
|
pushId: push.id,
|
|
@@ -816,6 +827,17 @@ const savedPush = (checks, push) => {
|
|
|
816
827
|
};
|
|
817
828
|
};
|
|
818
829
|
/**
|
|
830
|
+
* The pack a push's own receive put under its `quarantine` row: none for a push with no pack, one
|
|
831
|
+
* of rows alone, or a caller's `received`, which stays its caller's to end.
|
|
832
|
+
*/
|
|
833
|
+
const ownPack = (request, received) => {
|
|
834
|
+
const id = received?.quarantine?.id;
|
|
835
|
+
if (request.pack === void 0 || "received" in request.pack || id === void 0) return void 0;
|
|
836
|
+
return isPackId(id) ? id : void 0;
|
|
837
|
+
};
|
|
838
|
+
/** Whether a commit lists `pack`: its change deletes the pack's own `quarantine` row. */
|
|
839
|
+
const lists = (body, pack) => body.delete.some((key) => key.collection === objectCollections.quarantine && key.id === pack);
|
|
840
|
+
/**
|
|
819
841
|
* The push decide's loop past its first read, onto `listed`, keeping its answer under `key`:
|
|
820
842
|
* the pack received into its quarantine; each edit's kind from the objects; then a read of the
|
|
821
843
|
* refs, the push's `quarantine` row and the caller's fence; a held receipt's answer; the rules and
|
|
@@ -835,6 +857,15 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
|
|
|
835
857
|
view,
|
|
836
858
|
at: seen
|
|
837
859
|
}), listed, request).pipe(Effect.tapError((error) => isAwaitingRepack(error) ? bestEffort(ensureRepack(core, core.jobs, repoScope(listed.repo))) : Effect.void), Effect.mapError(asPushCheck));
|
|
860
|
+
const ownedPack = ownPack(request, received);
|
|
861
|
+
let listing = false;
|
|
862
|
+
if (ownedPack !== void 0) yield* Effect.addFinalizer((exit) => listing || Exit.hasInterrupts(exit) ? Effect.void : Effect.flatMap(Clock$1.currentTimeMillis, (at) => abandonOwn({
|
|
863
|
+
store: gitStore(store),
|
|
864
|
+
repo: listed.repo,
|
|
865
|
+
pack: ownedPack,
|
|
866
|
+
at,
|
|
867
|
+
repackJobRow: core.repackJobRow
|
|
868
|
+
})));
|
|
838
869
|
const viewed = received === void 0 ? seen : {
|
|
839
870
|
...seen,
|
|
840
871
|
pushed: received
|
|
@@ -858,8 +889,9 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
|
|
|
858
889
|
const fetchedOff = yield* fetchedRefused(kinds, request);
|
|
859
890
|
const { forced } = fetchedOff;
|
|
860
891
|
const refused = new Map(fetchedOff.refused);
|
|
892
|
+
const hidden = core.hiddenRefs();
|
|
861
893
|
for (const update of kinds.updates) {
|
|
862
|
-
const own = gitsOwnRef(update.ref, request.
|
|
894
|
+
const own = gitsOwnRef(hidden, update.ref, request.as);
|
|
863
895
|
if (own !== void 0 && !refused.has(update.ref)) refused.set(update.ref, own);
|
|
864
896
|
}
|
|
865
897
|
const refViews = yield* Effect.forEach(views, (one) => one.refView);
|
|
@@ -873,7 +905,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
|
|
|
873
905
|
const whole = objectsFace(SealedObjects.whole(sealed, pushWhole));
|
|
874
906
|
const wholePushed = access === void 0 || !barred && request.publishes === void 0 ? void 0 : withReceivedRows(yield* walkObjects(whole, received?.allotment), received);
|
|
875
907
|
const refView = refViews[0] ?? (yield* view.refView);
|
|
876
|
-
const publishedRefs = (refs) => new Map([...refs].filter(([ref]) => hiddenUnder(ref) === void 0));
|
|
908
|
+
const publishedRefs = (refs) => new Map([...refs].filter(([ref]) => hiddenUnder(hidden, ref) === void 0));
|
|
877
909
|
const writer = access === void 0 ? void 0 : yield* ownWriter(caller);
|
|
878
910
|
const made = new Set(request.own);
|
|
879
911
|
const ownOf = writer === void 0 ? void 0 : (oids) => {
|
|
@@ -943,8 +975,8 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
|
|
|
943
975
|
const fence = fenceAll(request, decidingFor(request).map((one) => core.fences(one, target)));
|
|
944
976
|
const ready = objects.readyShallow && request.edits.some((edit) => edit.ref === defaultBranch || edit.ref.startsWith("refs/tags/"));
|
|
945
977
|
const jobs = (received?.change.add?.length ?? 0) > 0 || ready ? [core.repackJobRow()] : [];
|
|
946
|
-
const own = updates.filter((update) => gitsOwnMove(request.
|
|
947
|
-
const outside = updates.filter((update) => !gitsOwnMove(request.
|
|
978
|
+
const own = updates.filter((update) => gitsOwnMove(hidden, request.as, update.ref));
|
|
979
|
+
const outside = updates.filter((update) => !gitsOwnMove(hidden, request.as, update.ref));
|
|
948
980
|
const checks = outside.length === 0 ? void 0 : yield* checksOf(core);
|
|
949
981
|
const branches = request.source === "queue" ? [] : outside.map((update) => update.ref).filter((ref) => ref.startsWith("refs/heads/"));
|
|
950
982
|
const scope = yield* callScope;
|
|
@@ -1080,9 +1112,11 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
|
|
|
1080
1112
|
if (yield* settleName(store, scope, settling)) continue;
|
|
1081
1113
|
const envelope = repoEnvelope(caller, name);
|
|
1082
1114
|
const id = newChangeId();
|
|
1083
|
-
const shown = planned.moved.filter((move) => !gitsOwnMove(request.
|
|
1115
|
+
const shown = planned.moved.filter((move) => !gitsOwnMove(core.hiddenRefs(), request.as, move.ref));
|
|
1116
|
+
const optionsPast = pushOptionsProblem(request.pushOptions, shown.length);
|
|
1117
|
+
if (optionsPast !== void 0) return yield* Effect.fail(optionsPast);
|
|
1084
1118
|
const push = pushOf(core.access, id, shown, request);
|
|
1085
|
-
const events = shown.map((move) => {
|
|
1119
|
+
const events = movedKinds(decided.updates, shown).map((move) => {
|
|
1086
1120
|
const updated = {
|
|
1087
1121
|
type: "ref.updated",
|
|
1088
1122
|
...envelope,
|
|
@@ -1151,7 +1185,10 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
|
|
|
1151
1185
|
moved: planned.moved.length
|
|
1152
1186
|
}, core.refIndex);
|
|
1153
1187
|
if (past !== void 0) return yield* Effect.fail(past);
|
|
1154
|
-
if ((yield* storeCall(() => store.commit(scope, body)).pipe(Effect.mapError(commitTooLarge(received, body)))).ok)
|
|
1188
|
+
if ((yield* storeCall(() => store.commit(scope, body)).pipe(Effect.mapError(commitTooLarge(received, body)))).ok) {
|
|
1189
|
+
listing = ownedPack !== void 0 && lists(body, ownedPack);
|
|
1190
|
+
return final;
|
|
1191
|
+
}
|
|
1155
1192
|
}
|
|
1156
1193
|
return yield* fail("UNAVAILABLE", `Other writes kept moving '${repo}' through 10 tries`, { hint: "Push again" });
|
|
1157
1194
|
}));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { runJobTry } from "../store/crossing.mjs";
|
|
2
1
|
import { storeCall } from "../store/errors.mjs";
|
|
2
|
+
import { currentRepo, madeJob, repoTry } from "../store/job-try.mjs";
|
|
3
3
|
import { readRecord } from "../store/repo-record.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { newChangeId, repoScope, selfKey } from "../store/scopes.mjs";
|
|
5
5
|
import { copyRead, indexCopies, indexRowKeys, otherRowsReads, ownRowsRead } from "./ref-index.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { Job } from "@ref0/infra";
|
|
7
7
|
import * as Schema from "effect/Schema";
|
|
8
8
|
import * as Effect from "effect/Effect";
|
|
9
9
|
// src/core/ref-index-job.ts
|
|
@@ -36,7 +36,6 @@ const refIndexJobKey = "rebuild";
|
|
|
36
36
|
const refIndexStepRows = 1e3;
|
|
37
37
|
/** The job's data: none, since the record holds its state. */
|
|
38
38
|
const RefIndexJobData = /* @__PURE__ */ Schema.Struct({});
|
|
39
|
-
const refIndexJobSchema = /* @__PURE__ */ Schema.toStandardSchemaV1(RefIndexJobData);
|
|
40
39
|
/** The step a live record at the server's stamp takes next, by its stamp and rebuild mark. */
|
|
41
40
|
const stepOf = (index, record, rows) => {
|
|
42
41
|
if (record.refIndex === index.stamp) return {
|
|
@@ -154,14 +153,10 @@ const rebuildTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
|
|
|
154
153
|
}));
|
|
155
154
|
return again;
|
|
156
155
|
});
|
|
157
|
-
/** `git.ref-index`'s try, in the repo's scope: one step of its rebuild. */
|
|
158
|
-
const refIndexHandler = (parts) => (job, context) => runJobTry(rebuildTry(parts, context.store, jobRepo(job)));
|
|
159
156
|
/** A rebuild whose step's tries are spent, logged, since no read says why it stopped. */
|
|
160
|
-
const rebuildFailed = (
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
name: refIndexJobName,
|
|
164
|
-
schema: refIndexJobSchema,
|
|
157
|
+
const rebuildFailed = (_data, failure) => Effect.flatMap(currentRepo, (repo) => Effect.logError(`git.ref-index left repo ${repo}'s ref index stale: ${failure.error instanceof Error ? failure.error.message : String(failure.error)}`));
|
|
158
|
+
const RefIndexJob = /* @__PURE__ */ Job.make(refIndexJobName, {
|
|
159
|
+
payload: RefIndexJobData,
|
|
165
160
|
timeout: "5 minutes",
|
|
166
161
|
retry: {
|
|
167
162
|
limit: 10,
|
|
@@ -169,13 +164,13 @@ const refIndexJob = (parts) => defineJob({
|
|
|
169
164
|
backoff: "exponential",
|
|
170
165
|
maxDelay: "5 minutes"
|
|
171
166
|
},
|
|
172
|
-
handler: refIndexHandler(parts),
|
|
173
|
-
onFailure: rebuildFailed,
|
|
174
167
|
rebuild: () => ({})
|
|
175
168
|
});
|
|
169
|
+
/** `git.ref-index`, over the server's ref index: each try one step of its rebuild, whose `more` starts its tries again. */
|
|
170
|
+
const refIndexJob = (parts) => madeJob(RefIndexJob.definition(() => repoTry((store, repo) => rebuildTry(parts, store, repo)), { onFailure: rebuildFailed }));
|
|
176
171
|
/** The repo's `git.ref-index` row, due now. */
|
|
177
172
|
const refIndexJobRow = (job) => job.job({
|
|
178
173
|
key: refIndexJobKey,
|
|
179
174
|
data: {}
|
|
180
175
|
});
|
|
181
|
-
export { RefIndexJobData,
|
|
176
|
+
export { RefIndexJobData, refIndexJob, refIndexJobKey, refIndexJobName, refIndexJobRow, refIndexStepRows };
|
|
@@ -2,6 +2,7 @@ import "../contracts/access.mjs";
|
|
|
2
2
|
import { RefName } from "../contracts/ids.mjs";
|
|
3
3
|
import "../store/records.mjs";
|
|
4
4
|
import "../store/ref-rows.mjs";
|
|
5
|
+
import "../protocol/wire/lines.mjs";
|
|
5
6
|
import { Key, Read, Row } from "@ref0/infra";
|
|
6
7
|
/**
|
|
7
8
|
* A server's ref index (#668), when its `access` has a classed pattern: one whose `*` matches no
|
package/dist/core/ref-index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { sha1Now } from "../protocol/bytes/sha1-hasher.mjs";
|
|
2
2
|
import { collections, selfKey } from "../store/scopes.mjs";
|
|
3
|
-
import { hiddenUnder } from "../protocol/wire/lines.mjs";
|
|
3
|
+
import { gitsOwnRefs, hiddenUnder } from "../protocol/wire/lines.mjs";
|
|
4
4
|
import { isClassedPattern } from "./rules/patterns.mjs";
|
|
5
5
|
import * as Hex from "effect/encoding/Hex";
|
|
6
6
|
// src/core/ref-index.ts
|
|
@@ -10,17 +10,37 @@ import * as Hex from "effect/encoding/Hex";
|
|
|
10
10
|
*/
|
|
11
11
|
const plainClass = "plain";
|
|
12
12
|
/**
|
|
13
|
-
* The `stampDigits` hex digits that name `patterns`, in order: a ref's
|
|
14
|
-
* before its own,
|
|
13
|
+
* The `stampDigits` hex digits that name `patterns`, in order, then the hidden prefixes: a ref's
|
|
14
|
+
* class turns on each pattern before its own, and on whether a prefix hides it, so any change to
|
|
15
|
+
* either list is a new stamp. No pattern holds a newline, and none is empty, so the empty line
|
|
16
|
+
* between them is where the prefixes start.
|
|
15
17
|
*/
|
|
16
|
-
const stampOf = (patterns) => Hex.encode(sha1Now([new TextEncoder().encode(
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
const stampOf = (patterns, prefixes) => Hex.encode(sha1Now([new TextEncoder().encode([
|
|
19
|
+
...patterns,
|
|
20
|
+
"",
|
|
21
|
+
...prefixes
|
|
22
|
+
].join("\n"))])).slice(0, 16);
|
|
23
|
+
/**
|
|
24
|
+
* `access`'s ref index, or `undefined` when no pattern is classed, so no write keeps one. `hidden`
|
|
25
|
+
* is the registry's table, read at each call, since the index is made before the registry's seal.
|
|
26
|
+
*/
|
|
27
|
+
const refIndexOf = (access, hidden = () => gitsOwnRefs) => {
|
|
19
28
|
if (access === void 0 || !access.patterns.some(isClassedPattern)) return void 0;
|
|
29
|
+
let stamped;
|
|
20
30
|
return {
|
|
21
|
-
stamp
|
|
31
|
+
get stamp() {
|
|
32
|
+
const table = hidden();
|
|
33
|
+
if (stamped?.table !== table) {
|
|
34
|
+
const prefixes = table.map(({ owner }) => owner.prefix);
|
|
35
|
+
stamped = {
|
|
36
|
+
table,
|
|
37
|
+
stamp: stampOf(access.patterns, prefixes)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return stamped.stamp;
|
|
41
|
+
},
|
|
22
42
|
classOf: (ref) => {
|
|
23
|
-
if (hiddenUnder(ref) !== void 0) return plainClass;
|
|
43
|
+
if (hiddenUnder(hidden(), ref) !== void 0) return plainClass;
|
|
24
44
|
const pattern = access.patternOf(ref);
|
|
25
45
|
return pattern !== void 0 && isClassedPattern(pattern) ? pattern : plainClass;
|
|
26
46
|
}
|
package/dist/core/ref-view.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fail } from "../contracts/result.mjs";
|
|
2
2
|
import { readToken, tokenState } from "../auth/token-rows.mjs";
|
|
3
3
|
import { withRequestHold } from "../store/call-count.mjs";
|
|
4
|
-
import { advanceName, buildName, timeoutName } from "../store/queue-jobs.mjs";
|
|
4
|
+
import { advanceName, buildName, timeoutName, trimName } from "../store/queue-jobs.mjs";
|
|
5
5
|
import { mirrorJobName } from "../store/records.mjs";
|
|
6
6
|
import { CoreParts } from "./parts.mjs";
|
|
7
7
|
import { Authorize, audience, check, grantOf } from "../contracts/authorize.mjs";
|
|
@@ -31,13 +31,15 @@ const wholeOnly = (refView) => refView.whole;
|
|
|
31
31
|
* sees the ref: `list`, `retry` and `discard` answer a job of a ref it can't see as a missing one,
|
|
32
32
|
* and the event stream leaves out its `repo.work.failed`. A mirror's ref and a queue's target are
|
|
33
33
|
* the key, and a candidate's key is its ID, whose ref under `refs/queue/` only a caller who sees
|
|
34
|
-
* every ref sees (Q749)
|
|
34
|
+
* every ref sees (Q749), as does `queue.trim`, whose data names the target or the ID it trimmed up
|
|
35
|
+
* to. A kind left out names no ref.
|
|
35
36
|
*/
|
|
36
37
|
const refKeyedJobs = /* @__PURE__ */ new Map([
|
|
37
38
|
[mirrorJobName, keyRef],
|
|
38
39
|
[advanceName, keyRef],
|
|
39
40
|
[buildName, wholeOnly],
|
|
40
|
-
[timeoutName, wholeOnly]
|
|
41
|
+
[timeoutName, wholeOnly],
|
|
42
|
+
[trimName, wholeOnly]
|
|
41
43
|
]);
|
|
42
44
|
/** Whether a caller with `refView` sees `job`: any job of a kind `refKeyedJobs` leaves out. */
|
|
43
45
|
const seesJob = (refView, job) => {
|
|
@@ -109,20 +111,23 @@ const memoKey = (internalId, caller) => Effect.map(grantOf(caller), (grant) => J
|
|
|
109
111
|
grant ?? null
|
|
110
112
|
]));
|
|
111
113
|
/** `caller`'s ref view of `repo`'s refs, asked of `authorize` each time it runs: no held answer. */
|
|
112
|
-
|
|
114
|
+
/** The prefixes of the registry's table, as `AccessOption.refViewOf` takes them. */
|
|
115
|
+
const prefixesOf = (table) => table.map(({ owner }) => owner.prefix);
|
|
116
|
+
const askRefView = (access, caller, repo, hidden) => {
|
|
113
117
|
if (access === void 0) return Effect.succeed(wholeView);
|
|
114
118
|
return Effect.map(Effect.suspend(() => audience({
|
|
115
119
|
caller,
|
|
116
120
|
repo,
|
|
117
121
|
patterns: access.patterns
|
|
118
|
-
})), (audience) => access.refViewOf(audience));
|
|
122
|
+
})), (audience) => access.refViewOf(audience, hidden));
|
|
119
123
|
};
|
|
120
124
|
/** `caller`'s ref view of `repo`'s refs, asked of `authorize` once per request at most. */
|
|
121
125
|
const refViewIn = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo) {
|
|
122
|
-
const { access } = yield* CoreParts;
|
|
126
|
+
const { access, hiddenRefs } = yield* CoreParts;
|
|
123
127
|
if (access === void 0) return wholeView;
|
|
128
|
+
const hidden = prefixesOf(hiddenRefs());
|
|
124
129
|
const authorize = yield* Authorize;
|
|
125
|
-
const ask = Effect.provideService(askRefView(access, caller, repo), Authorize, authorize);
|
|
130
|
+
const ask = Effect.provideService(askRefView(access, caller, repo, hidden), Authorize, authorize);
|
|
126
131
|
const memo = yield* Effect.serviceOption(AudienceMemo);
|
|
127
132
|
if (Option.isNone(memo)) return yield* ask;
|
|
128
133
|
const key = yield* memoKey(repo.internalId, caller);
|
|
@@ -159,8 +164,8 @@ const accessAgain = /* @__PURE__ */ Effect.fnUntraced(function* (caller, kind, r
|
|
|
159
164
|
});
|
|
160
165
|
/** `accessAgain`, then `caller`'s ref view of `repo` itself, asked afresh, never a held answer. */
|
|
161
166
|
const refViewAgain = /* @__PURE__ */ Effect.fnUntraced(function* (caller, kind, repo) {
|
|
162
|
-
const { access } = yield* CoreParts;
|
|
167
|
+
const { access, hiddenRefs } = yield* CoreParts;
|
|
163
168
|
yield* accessAgain(caller, kind, repo);
|
|
164
|
-
return yield* askRefView(access, caller, repo);
|
|
169
|
+
return yield* askRefView(access, caller, repo, prefixesOf(hiddenRefs()));
|
|
165
170
|
});
|
|
166
171
|
export { AudienceMemo, ViewedMemo, accessAgain, refViewAgain, refViewIn, seesJob, viewedIn, wholeView, withAudienceMemo };
|
package/dist/core/refs.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { open } from "./view.mjs";
|
|
|
11
11
|
import { isRefName } from "./names.mjs";
|
|
12
12
|
import { keyedPush, push } from "./push.mjs";
|
|
13
13
|
import { isWellFormed } from "../protocol/bytes/text.mjs";
|
|
14
|
-
import {
|
|
14
|
+
import { gitsOwnRefs, hostLists } from "../protocol/wire/lines.mjs";
|
|
15
15
|
import { notFailed } from "./events/deliver.mjs";
|
|
16
16
|
import { refsAnswer } from "./receipts.mjs";
|
|
17
17
|
import { plainClass, refIndexId } from "./ref-index.mjs";
|
|
@@ -26,12 +26,13 @@ import * as Clock$1 from "effect/Clock";
|
|
|
26
26
|
const maxRefLimit = 1e3;
|
|
27
27
|
/**
|
|
28
28
|
* The most ranges one store call of a listing's page reads under `access`. Each span the caller
|
|
29
|
-
* can't see starts and ends at two of the patterns' own bounds, or Git's own
|
|
30
|
-
* are at most as many as those. Each gives the gap after it a read by
|
|
31
|
-
* cursor's gap adds one, and each classed pattern the caller reads adds
|
|
32
|
-
* index. A pattern is a span or a class, never both, so 64 patterns
|
|
29
|
+
* can't see starts and ends at two of the patterns' own bounds, or a hidden prefix's, Git's own or
|
|
30
|
+
* a registered one, so there are at most as many as those. Each gives the gap after it a read by
|
|
31
|
+
* ID and a read after it, the cursor's gap adds one, and each classed pattern the caller reads adds
|
|
32
|
+
* its range of the ref index. A pattern is a span or a class, never both, so 64 patterns and 8
|
|
33
|
+
* registered prefixes give 147 (#668).
|
|
33
34
|
*/
|
|
34
|
-
const refListRangesMost = 2 * (
|
|
35
|
+
const refListRangesMost = 2 * (72 + gitsOwnRefs.length) + 1;
|
|
35
36
|
/** A longest ref name, of `"` past `refs/`, which JSON doubles. */
|
|
36
37
|
const longestName = `refs/${"\"".repeat(maxRefNameLength - 5)}`;
|
|
37
38
|
/** A longest class: a pattern as written, as long as a name, with the `*` that classes it. */
|
|
@@ -104,7 +105,7 @@ const indexRun = (stamp, cls) => ({
|
|
|
104
105
|
* U+0000: the count stops at the name, or starts at it, and a read of that one name adds or takes
|
|
105
106
|
* it back. Each count's sign is in `signs`, and each name's beside it.
|
|
106
107
|
*/
|
|
107
|
-
const countTerms = (prefix, spans, run = byName) => {
|
|
108
|
+
const countTerms = (table, prefix, spans, run = byName) => {
|
|
108
109
|
const counts = [];
|
|
109
110
|
const signs = [];
|
|
110
111
|
const points = [];
|
|
@@ -140,8 +141,8 @@ const countTerms = (prefix, spans, run = byName) => {
|
|
|
140
141
|
const inside = clipped(span, prefix);
|
|
141
142
|
if (inside !== void 0) add(-1, inside, prefix);
|
|
142
143
|
}
|
|
143
|
-
const hostHidden =
|
|
144
|
-
for (const { prefix: under } of hostHidden) {
|
|
144
|
+
const hostHidden = table.filter(({ owner }) => owner.prefix.startsWith(prefix) && !prefix.startsWith(owner.prefix));
|
|
145
|
+
for (const { owner: { prefix: under } } of hostHidden) {
|
|
145
146
|
add(-1, {}, under);
|
|
146
147
|
for (const span of spans) {
|
|
147
148
|
const inside = clipped(span, under);
|
|
@@ -316,7 +317,8 @@ const refCalls = (bound) => {
|
|
|
316
317
|
if (sent !== void 0 && after === void 0) return yield* badCursor();
|
|
317
318
|
if (after !== void 0) read.after = after;
|
|
318
319
|
const rules = yield* pushRulesFor(core.checks);
|
|
319
|
-
const
|
|
320
|
+
const hidden = core.hiddenRefs();
|
|
321
|
+
const kept = (name, oid) => hostLists(hidden, name, asked) && (input.pointsAt === void 0 || oid === input.pointsAt) && (input.protected === void 0 || refProtection(rules, name) !== void 0 === input.protected);
|
|
320
322
|
const listed = (seen) => [...seen].flatMap(([name, oid]) => kept(name, oid) ? [{
|
|
321
323
|
name,
|
|
322
324
|
oid
|
|
@@ -532,7 +534,7 @@ const refCalls = (bound) => {
|
|
|
532
534
|
const index = refView.whole ? void 0 : core.refIndex;
|
|
533
535
|
const run = index === void 0 ? byName : indexRun(index.stamp, plainClass);
|
|
534
536
|
const spans = index === void 0 ? refView.hiddenSpans(prefix) : refView.plainSpans(prefix);
|
|
535
|
-
const terms = countTerms(prefix, spans, run);
|
|
537
|
+
const terms = countTerms(core.hiddenRefs(), prefix, spans, run);
|
|
536
538
|
const classes = index === void 0 ? [] : classesOf(refView, prefix).map((cls) => ({
|
|
537
539
|
collection: collections.refIndex,
|
|
538
540
|
prefix: refIndexId(index.stamp, cls, prefix)
|
package/dist/core/repack.d.mts
CHANGED
|
@@ -5,6 +5,7 @@ import "../contracts/git.mjs";
|
|
|
5
5
|
import "../contracts/objects.mjs";
|
|
6
6
|
import "../contracts/result.mjs";
|
|
7
7
|
import "../storage/repack-job.mjs";
|
|
8
|
+
import "./events/deliver.mjs";
|
|
8
9
|
import "./view.mjs";
|
|
9
|
-
import { JobDefinition,
|
|
10
|
+
import { JobDefinition, JobInput, Moment } from "@ref0/infra";
|
|
10
11
|
import "effect/Effect";
|