@ref0/git 0.11.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access/private-refs.mjs +8 -7
- package/dist/auth/auth.d.mts +2 -2
- package/dist/auth/auth.mjs +3 -6
- package/dist/auth/authorize.mjs +1 -17
- package/dist/auth/helpers.mjs +3 -11
- package/dist/auth/host-services.mjs +11 -0
- package/dist/auth/policy.d.mts +27 -7
- package/dist/auth/policy.mjs +8 -4
- package/dist/auth/tokens-layer.d.mts +1 -2
- package/dist/auth/tokens-layer.mjs +2 -3
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +1 -8
- package/dist/auth/tokens.mjs +1 -8
- package/dist/auth.d.mts +1 -4
- package/dist/auth.mjs +1 -3
- package/dist/client/git-http.mjs +18 -4
- package/dist/client/push-upload.mjs +33 -7
- package/dist/client/remote.mjs +94 -28
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/contracts/access.d.mts +8 -8
- package/dist/contracts/actors.d.mts +2 -34
- package/dist/contracts/blobs.d.mts +2 -2
- package/dist/contracts/client.d.mts +8 -3
- package/dist/contracts/commits.d.mts +10 -2
- package/dist/contracts/commits.mjs +9 -1
- package/dist/contracts/files.d.mts +2 -2
- package/dist/contracts/forks.d.mts +14 -3
- package/dist/contracts/git.d.mts +41 -12
- package/dist/contracts/git.mjs +3 -2
- package/dist/contracts/lfs.d.mts +0 -7
- package/dist/contracts/objects.d.mts +80 -10
- package/dist/contracts/operations.d.mts +3 -0
- package/dist/contracts/operations.mjs +12 -2
- package/dist/contracts/push-uploads.d.mts +44 -5
- package/dist/contracts/push-uploads.mjs +7 -3
- package/dist/contracts/refs.d.mts +28 -6
- package/dist/contracts/remote.mjs +1 -3
- package/dist/contracts/repo-records.d.mts +1 -0
- package/dist/contracts/repos.d.mts +90 -2
- package/dist/contracts/repos.mjs +29 -2
- package/dist/contracts/result.d.mts +30 -23
- package/dist/contracts/result.mjs +24 -9
- package/dist/contracts/rules.d.mts +22 -22
- package/dist/contracts/server.d.mts +28 -77
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/sync.d.mts +90 -19
- package/dist/contracts/sync.mjs +34 -10
- package/dist/contracts/tokens.d.mts +1 -6
- package/dist/contracts/tokens.mjs +1 -2
- package/dist/contracts/topics.d.mts +0 -5
- package/dist/contracts/work.d.mts +66 -2
- package/dist/contracts/work.mjs +8 -1
- package/dist/core/access.d.mts +1 -0
- package/dist/core/access.mjs +34 -13
- package/dist/core/ancestry.d.mts +9 -0
- package/dist/core/ancestry.mjs +6 -6
- package/dist/core/asked.mjs +68 -0
- package/dist/core/call-names.mjs +1 -0
- package/dist/core/call-services.mjs +2 -1
- package/dist/core/events/deliver.d.mts +1 -0
- package/dist/core/events/deliver.mjs +15 -3
- package/dist/core/forks.mjs +42 -16
- package/dist/core/imports.mjs +156 -13
- package/dist/core/index-job.mjs +9 -6
- package/dist/core/job-view.mjs +8 -9
- package/dist/core/mirror-rows.mjs +19 -4
- package/dist/core/objects/commits.mjs +16 -6
- package/dist/core/objects/reading.mjs +17 -9
- package/dist/core/parts.d.mts +8 -2
- package/dist/core/parts.mjs +1 -4
- package/dist/core/purge.mjs +76 -6
- package/dist/core/push-decide.mjs +1 -1
- package/dist/core/push-files.d.mts +12 -0
- package/dist/core/push-files.mjs +225 -0
- package/dist/core/push-repo.d.mts +8 -0
- package/dist/core/push-repo.mjs +56 -0
- package/dist/core/push.d.mts +17 -0
- package/dist/core/push.mjs +107 -32
- package/dist/core/receipts.mjs +26 -10
- package/dist/core/ref-view.mjs +59 -5
- package/dist/core/refs.mjs +18 -10
- package/dist/core/registered-rows.mjs +7 -5
- package/dist/core/repack.mjs +16 -11
- package/dist/core/repo-info.mjs +16 -9
- package/dist/core/repos.mjs +30 -14
- package/dist/core/saved-caller-views.d.mts +18 -0
- package/dist/core/saved-caller-views.mjs +17 -4
- package/dist/core/saved-callers-public.d.mts +3 -3
- package/dist/core/saved-callers-public.mjs +3 -2
- package/dist/core/saved-callers.d.mts +7 -0
- package/dist/core/seam.mjs +2 -2
- package/dist/core/view.d.mts +6 -0
- package/dist/core/view.mjs +45 -12
- package/dist/core/work.mjs +47 -22
- package/dist/effect.d.mts +3 -1
- package/dist/effect.mjs +3 -1
- package/dist/engine/reads.mjs +13 -6
- package/dist/engine/walk.mjs +4 -4
- package/dist/event-streams/event-streams.d.mts +1 -1
- package/dist/event-streams/event-streams.mjs +1 -1
- package/dist/event-streams/stream.d.mts +1 -1
- package/dist/event-streams/stream.mjs +1 -1
- package/dist/extend.d.mts +4 -3
- package/dist/extend.mjs +3 -2
- package/dist/http/answers.mjs +4 -2
- package/dist/http/core-parts.mjs +64 -15
- package/dist/http/handler.mjs +2 -2
- package/dist/http/node.mjs +5 -4
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +503 -0
- package/dist/http/push-uploads.d.mts +1 -0
- package/dist/http/push-uploads.mjs +120 -59
- package/dist/http/upload-pack.mjs +7 -6
- package/dist/index.d.mts +23 -24
- package/dist/index.mjs +4 -7
- package/dist/lfs/base.d.mts +7 -3
- package/dist/lfs/base.mjs +2 -1
- package/dist/lfs/copy.d.mts +46 -0
- package/dist/lfs/copy.mjs +26 -0
- package/dist/lfs/layer.mjs +4 -2
- package/dist/lfs/locks.mjs +14 -9
- package/dist/lfs/objects.d.mts +6 -0
- package/dist/lfs/objects.mjs +95 -61
- package/dist/lfs/rows.d.mts +13 -0
- package/dist/lfs/service.d.mts +1 -7
- package/dist/lfs/service.mjs +1 -9
- package/dist/lfs/upload-most.mjs +5 -5
- package/dist/node.d.mts +2 -2
- package/dist/protocol/bytes/sha256-hasher.d.mts +15 -0
- package/dist/protocol/bytes/sha256.d.mts +32 -0
- package/dist/protocol/bytes/sha256.mjs +105 -49
- package/dist/protocol/wire/advertisement.mjs +9 -4
- package/dist/protocol/wire/lines.d.mts +4 -2
- package/dist/protocol/wire/lines.mjs +11 -5
- package/dist/protocol/wire/push-uploads.mjs +13 -1
- package/dist/protocol/wire/v2.mjs +2 -2
- package/dist/protocol.d.mts +3 -1
- package/dist/protocol.mjs +3 -1
- package/dist/queue/advance.mjs +1 -1
- package/dist/queue/calls.mjs +21 -1
- package/dist/queue/host.d.mts +1 -7
- package/dist/queue/host.mjs +1 -7
- package/dist/queue/layer.mjs +1 -1
- package/dist/queue/trim.mjs +1 -1
- package/dist/rest/blobs.d.mts +16 -8
- package/dist/rest/blobs.mjs +1 -1
- package/dist/rest/caller.d.mts +49 -9
- package/dist/rest/caller.mjs +1 -1
- package/dist/rest/client.d.mts +10 -3
- package/dist/rest/client.mjs +4 -0
- package/dist/rest/commits.d.mts +272 -239
- package/dist/rest/errors.d.mts +24 -4
- package/dist/rest/events.d.mts +9 -6
- package/dist/rest/events.mjs +1 -2
- package/dist/rest/files.d.mts +112 -100
- package/dist/rest/forks.d.mts +146 -122
- package/dist/rest/handler.mjs +4 -57
- package/dist/rest/handlers.d.mts +1 -1
- package/dist/rest/handlers.mjs +18 -4
- package/dist/rest/layer.mjs +10 -2
- package/dist/rest/me.d.mts +8 -4
- package/dist/rest/merges.d.mts +8 -4
- package/dist/rest/paths.mjs +1 -0
- package/dist/rest/queue.d.mts +292 -236
- package/dist/rest/refs.d.mts +98 -69
- package/dist/rest/repos.d.mts +133 -105
- package/dist/rest/tags.d.mts +100 -88
- package/dist/rest/tokens.d.mts +192 -168
- package/dist/rest/topics.d.mts +154 -134
- package/dist/rest/trees.d.mts +32 -16
- package/dist/rest/work.d.mts +467 -20
- package/dist/rest/work.mjs +8 -0
- package/dist/server/edge-node.d.mts +9 -13
- package/dist/server/edge-node.mjs +9 -12
- package/dist/server/git-layer.d.mts +1 -6
- package/dist/server/git-layer.mjs +2 -2
- package/dist/server/git-namespace.d.mts +4 -4
- package/dist/server/joined.d.mts +15 -22
- package/dist/server/joined.mjs +5 -29
- package/dist/server/lifecycle.mjs +107 -23
- package/dist/server/registry.mjs +9 -1
- package/dist/server/server.mjs +139 -216
- package/dist/storage/budget.mjs +2 -2
- package/dist/storage/clean-up.mjs +13 -10
- package/dist/storage/fetch.mjs +13 -8
- package/dist/storage/file-limits.mjs +24 -0
- package/dist/storage/index-build.d.mts +1 -0
- package/dist/storage/index-build.mjs +106 -62
- package/dist/storage/index-fetch.mjs +16 -3
- package/dist/storage/index-reach.mjs +33 -5
- package/dist/storage/index-remap.mjs +8 -1
- package/dist/storage/index-shallow.mjs +5 -3
- package/dist/storage/largest-files.mjs +48 -0
- package/dist/storage/lfs-pointers.mjs +10 -1
- package/dist/storage/loose.mjs +3 -1
- package/dist/storage/memory-budget.mjs +154 -8
- package/dist/storage/merge-cut.mjs +5 -4
- package/dist/storage/pack-reads.mjs +246 -34
- package/dist/storage/pack-receive.mjs +83 -25
- package/dist/storage/packs.mjs +37 -21
- package/dist/storage/prune-keep.mjs +203 -34
- package/dist/storage/prune-seen.mjs +11 -6
- package/dist/storage/prune-walk.mjs +219 -81
- package/dist/storage/prune.mjs +629 -196
- package/dist/storage/push-uploads.mjs +36 -12
- package/dist/storage/quarantine.mjs +9 -7
- package/dist/storage/ready.mjs +47 -19
- package/dist/storage/receive-bounds.mjs +29 -8
- package/dist/storage/receive-state.mjs +8 -0
- package/dist/storage/receive-steps.mjs +71 -18
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/repack.mjs +1 -8
- package/dist/storage/rows.mjs +12 -1
- package/dist/storage/shallow.d.mts +1 -0
- package/dist/storage/shallow.mjs +26 -4
- package/dist/storage/stream-whole.mjs +5 -2
- package/dist/storage/visible.mjs +29 -1
- package/dist/storage/walk.mjs +2 -1
- package/dist/store/catalogue.mjs +1 -0
- package/dist/store/cursor-seal-namespace.d.mts +2 -0
- package/dist/store/cursor-seal-public.d.mts +5 -0
- package/dist/store/cursor-seal-public.mjs +5 -0
- package/dist/store/cursor-seal.d.mts +16 -2
- package/dist/store/cursor-seal.mjs +26 -14
- package/dist/store/errors.mjs +9 -1
- package/dist/store/records.d.mts +2 -0
- package/dist/store/records.mjs +9 -6
- package/dist/store/repo-record.d.mts +27 -0
- package/dist/store/repo-record.mjs +141 -4
- package/dist/store/scopes.mjs +10 -2
- package/dist/sync/bound.d.mts +2 -0
- package/dist/sync/bound.mjs +11 -2
- package/dist/sync/github.d.mts +6 -1
- package/dist/sync/github.mjs +63 -42
- package/dist/sync/http.mjs +36 -1
- package/dist/sync/import.mjs +4 -2
- package/dist/sync/layer.mjs +6 -2
- package/dist/sync/lfs-batch.mjs +119 -0
- package/dist/sync/lfs-copy.mjs +251 -0
- package/dist/sync/mirror.mjs +227 -147
- package/dist/sync/said.mjs +204 -0
- package/dist/sync/smart-http.mjs +4 -2
- package/dist/sync/step.mjs +33 -13
- package/dist/sync/tries.mjs +71 -24
- package/dist/sync.d.mts +2 -2
- package/dist/topics/advance.mjs +10 -3
- package/dist/topics/host.mjs +1 -19
- package/dist/topics/layer.mjs +1 -1
- package/package.json +3 -8
- package/dist/auth/bridge.mjs +0 -30
- package/dist/auth/helpers.d.mts +0 -17
- package/dist/core/purge.d.mts +0 -8
- package/dist/core/registered-rows.d.mts +0 -4
- package/dist/core/repack.d.mts +0 -11
- package/dist/http/handler.d.mts +0 -2
- package/dist/rest/handler.d.mts +0 -21
- package/dist/rest.d.mts +0 -2
- package/dist/rest.mjs +0 -1
- package/dist/server/registry.d.mts +0 -16
- package/dist/server/server.d.mts +0 -36
- package/dist/storage/repack-job.d.mts +0 -3
- package/dist/topics/host.d.mts +0 -7
package/dist/core/push.mjs
CHANGED
|
@@ -25,9 +25,9 @@ import { pushCounts } from "./events/seen.mjs";
|
|
|
25
25
|
import { refViewIn } from "./ref-view.mjs";
|
|
26
26
|
import { appendEvents, decodeOutbox, firstSeq, outboxReads, repoEnvelope } from "../store/outbox.mjs";
|
|
27
27
|
import { rowsAtCommit } from "./loose-tally.mjs";
|
|
28
|
-
import { MirrorRow } from "./mirror-rows.mjs";
|
|
28
|
+
import { MirrorRow, mirrorJobKey } from "./mirror-rows.mjs";
|
|
29
29
|
import { PrunedMark, mirrorJobName } from "../store/records.mjs";
|
|
30
|
-
import { decodeStats, looseRows, readRecord, repoStats, rootsOf, timeRow } from "../store/repo-record.mjs";
|
|
30
|
+
import { HeldBy, decodeStats, heldUntil, looseRows, readRecord, repoStats, rootsMoved, rootsOf, timeRow } from "../store/repo-record.mjs";
|
|
31
31
|
import { advanceRow } from "../store/queue-jobs.mjs";
|
|
32
32
|
import { liveReservations, reservedTarget } from "../store/reservations.mjs";
|
|
33
33
|
import { settleName } from "../store/settle.mjs";
|
|
@@ -50,6 +50,8 @@ import { ensureRepack } from "./repack.mjs";
|
|
|
50
50
|
import { publishable, unpublished } from "./publish.mjs";
|
|
51
51
|
import { peeledAll, peeledOf } from "../storage/wants.mjs";
|
|
52
52
|
import { CoreParts, ObjectsParts } from "./parts.mjs";
|
|
53
|
+
import { defaultPushFiles, filesChecked } from "./push-files.mjs";
|
|
54
|
+
import { addedBytes, defaultPushRepo, repoChecked } from "./push-repo.mjs";
|
|
53
55
|
import { Authorize, check } from "../contracts/authorize.mjs";
|
|
54
56
|
import { read } from "./objects/objects.mjs";
|
|
55
57
|
import * as Clock$1 from "effect/Clock";
|
|
@@ -164,9 +166,9 @@ const bypassNotes = (updated, bypassed) => updated.updates.flatMap((update) => {
|
|
|
164
166
|
});
|
|
165
167
|
/** A `git push`'s answers: unkeyed, so never kept or held but as `refs.update`'s are. */
|
|
166
168
|
const gitAnswers = {
|
|
167
|
-
answer: (updated, _, bypassed) => Effect.succeed({
|
|
169
|
+
answer: (updated, _, bypassed, warned) => Effect.succeed({
|
|
168
170
|
updated,
|
|
169
|
-
notes: bypassNotes(updated, bypassed)
|
|
171
|
+
notes: [...warned, ...bypassNotes(updated, bypassed)]
|
|
170
172
|
}),
|
|
171
173
|
kept: ({ updated }) => refsKept(updated),
|
|
172
174
|
held: (receipt) => Effect.map(refsAnswer(receipt), (updated) => ({
|
|
@@ -216,7 +218,7 @@ const keyedRead = (caller, operation, missed, internalId) => openKeyed(caller, {
|
|
|
216
218
|
* received against, its default branch, whose move rebuilds the ready shallow pack, and its
|
|
217
219
|
* `pruned` mark.
|
|
218
220
|
*/
|
|
219
|
-
const listedFor = /* @__PURE__ */ Effect.fnUntraced(function* (request, operation, resolved) {
|
|
221
|
+
const listedFor = /* @__PURE__ */ Effect.fnUntraced(function* (request, operation, resolved, heldAt) {
|
|
220
222
|
const { caller } = request;
|
|
221
223
|
const repo = repoAccess(resolved);
|
|
222
224
|
if (request.queued === void 0) yield* check({
|
|
@@ -241,15 +243,16 @@ const listedFor = /* @__PURE__ */ Effect.fnUntraced(function* (request, operatio
|
|
|
241
243
|
roots,
|
|
242
244
|
repo,
|
|
243
245
|
view,
|
|
244
|
-
views
|
|
246
|
+
views,
|
|
247
|
+
heldAt
|
|
245
248
|
};
|
|
246
249
|
});
|
|
247
250
|
/**
|
|
248
251
|
* The refs a push's objects follow, for its view: none read when the view's objects are whole, as
|
|
249
252
|
* for a caller who sees every ref of a repo that isn't a fork under `access`; else every ref the
|
|
250
253
|
* caller sees, read after `authorize` let the caller in, at a version of their own, which the
|
|
251
|
-
* push's objects read at too. `roots` are the first read's:
|
|
252
|
-
*
|
|
254
|
+
* push's objects read at too. `roots` are the first read's: `rootsMoved`, their one writer, moves
|
|
255
|
+
* them with the refs whose history they stop, in one commit.
|
|
253
256
|
*/
|
|
254
257
|
const seenRefsOf = /* @__PURE__ */ Effect.fnUntraced(function* (view, listed, roots) {
|
|
255
258
|
const core = yield* CoreParts;
|
|
@@ -303,23 +306,34 @@ const pushedOf = (objects, listed, received) => {
|
|
|
303
306
|
* reads one, its bytes let go unread. A read that fails throws, so the walk trusts nothing.
|
|
304
307
|
*/
|
|
305
308
|
const broughtCommit = (pushed) => (oid) => Effect.flatMap(pushed({ oid }), (object) => Effect.as(Effect.promise(() => object?.bytes.cancel().catch(() => void 0) ?? Promise.resolve()), object?.type === "commit"));
|
|
306
|
-
/** The refs the repo mirrors, among `rows` of `mirrors`: each one an active mirror names. */
|
|
309
|
+
/** The refs the repo mirrors, among `rows` of `mirrors`: each one an active mirror names, with its destination. */
|
|
307
310
|
const activeMirrors = /* @__PURE__ */ Effect.fnUntraced(function* (rows) {
|
|
308
|
-
const active = /* @__PURE__ */ new
|
|
309
|
-
for (const row of rows)
|
|
311
|
+
const active = /* @__PURE__ */ new Map();
|
|
312
|
+
for (const row of rows) {
|
|
313
|
+
const mirror = yield* decodeRow(MirrorRow, row, `Mirror '${row.id}'`);
|
|
314
|
+
if (mirror.state === "active") active.set(row.id, mirror.destination);
|
|
315
|
+
}
|
|
310
316
|
return active;
|
|
311
317
|
});
|
|
312
318
|
/**
|
|
313
|
-
* `sync.mirror`'s row for each ref the commit moves
|
|
314
|
-
* name among the jobs the server knows: none until
|
|
319
|
+
* `sync.mirror`'s row for each destination an active mirror of a ref the commit moves names, one
|
|
320
|
+
* however many of its refs move, found by name among the jobs the server knows: none until
|
|
321
|
+
* `Sync.layer` has bound them.
|
|
315
322
|
*/
|
|
316
323
|
const mirrorJobs = (core, moved, mirrored) => {
|
|
317
324
|
const definition = core.jobOf?.(mirrorJobName);
|
|
318
325
|
if (definition === void 0) return [];
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
326
|
+
const jobs = /* @__PURE__ */ new Map();
|
|
327
|
+
for (const { ref } of moved) {
|
|
328
|
+
const destination = mirrored.get(ref);
|
|
329
|
+
if (destination === void 0) continue;
|
|
330
|
+
const key = mirrorJobKey(destination);
|
|
331
|
+
jobs.set(key, definition.job({
|
|
332
|
+
key,
|
|
333
|
+
data: { destination }
|
|
334
|
+
}));
|
|
335
|
+
}
|
|
336
|
+
return [...jobs.values()];
|
|
323
337
|
};
|
|
324
338
|
/** The repo's stored packs and the received pack's, before the commit lists it: a push's changes read both. */
|
|
325
339
|
const withReceived = (listed, received) => received === void 0 ? listed : {
|
|
@@ -445,6 +459,7 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
|
|
|
445
459
|
indexRowKey,
|
|
446
460
|
reachedKey,
|
|
447
461
|
readyKey,
|
|
462
|
+
repoRootsKey,
|
|
448
463
|
...own,
|
|
449
464
|
...keyed,
|
|
450
465
|
...targets,
|
|
@@ -461,7 +476,7 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
|
|
|
461
476
|
], rowCounts);
|
|
462
477
|
if (record === void 0 || record.deleted === true) return yield* fail("NOT_FOUND", `No repo '${repo.name}'`);
|
|
463
478
|
const [, refRows = [], headRows = [], cursorRows = [], packRows = [], ...more] = snapshot.results;
|
|
464
|
-
const [markRows = [], timeRows = [], cruftRows = [], indexRows = [], reachedRows = [], readyRows = [], ...rest] = more;
|
|
479
|
+
const [markRows = [], timeRows = [], cruftRows = [], indexRows = [], reachedRows = [], readyRows = [], rootRows = [], ...rest] = more;
|
|
465
480
|
const receipt = yield* heldReceipt(rest.slice(own.length, own.length + keyed.length), kept);
|
|
466
481
|
if (receipt === void 0 && (yield* markOf(markRows)) !== mark) return yield* fail("UNAVAILABLE", "The repo was pruned during the push", { hint: "Push again" });
|
|
467
482
|
const targeted = rest.slice(own.length + keyed.length, own.length + keyed.length + targets.length);
|
|
@@ -530,7 +545,8 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
|
|
|
530
545
|
queued,
|
|
531
546
|
reserved,
|
|
532
547
|
indexRow,
|
|
533
|
-
changed
|
|
548
|
+
changed,
|
|
549
|
+
roots: yield* rootsOf(rootRows)
|
|
534
550
|
};
|
|
535
551
|
});
|
|
536
552
|
const settingsOf = (record) => ({
|
|
@@ -643,6 +659,38 @@ const clearedAt = (decision, at) => decision.kind === "commit" ? {
|
|
|
643
659
|
}
|
|
644
660
|
} : decision;
|
|
645
661
|
/**
|
|
662
|
+
* `decision` with a fetch's roots in its commit, the reached mark's delete once. A decision that
|
|
663
|
+
* commits nothing commits the roots alone, at `version`, so a deepen that moves no ref keeps its
|
|
664
|
+
* edge. A refusal stays one.
|
|
665
|
+
*/
|
|
666
|
+
const withRoots = (decision, write, version) => {
|
|
667
|
+
if (write === void 0) return decision;
|
|
668
|
+
if (decision.kind === "answer") {
|
|
669
|
+
const { answer } = decision;
|
|
670
|
+
if (answer.kind === "error") return decision;
|
|
671
|
+
return {
|
|
672
|
+
kind: "commit",
|
|
673
|
+
expect: version,
|
|
674
|
+
change: {
|
|
675
|
+
put: [...write.put],
|
|
676
|
+
delete: [...write.delete]
|
|
677
|
+
},
|
|
678
|
+
answer: answer.value,
|
|
679
|
+
moved: []
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
const held = decision.change.delete ?? [];
|
|
683
|
+
const drops = write.delete.filter((key) => !held.includes(key));
|
|
684
|
+
const change = {
|
|
685
|
+
put: [...decision.change.put, ...write.put],
|
|
686
|
+
delete: [...held, ...drops]
|
|
687
|
+
};
|
|
688
|
+
return {
|
|
689
|
+
...decision,
|
|
690
|
+
change
|
|
691
|
+
};
|
|
692
|
+
};
|
|
693
|
+
/**
|
|
646
694
|
* What a decision commits: its writes and jobs at `expect`, or, for an answer that moves no ref,
|
|
647
695
|
* nothing, which a keyed write's receipt still commits at the read's version. A refusal fails.
|
|
648
696
|
*/
|
|
@@ -769,6 +817,10 @@ const receive = (objects, listed, request) => {
|
|
|
769
817
|
received: pack.received,
|
|
770
818
|
rooted: void 0
|
|
771
819
|
});
|
|
820
|
+
if ("rooted" in pack) return Effect.succeed({
|
|
821
|
+
received: void 0,
|
|
822
|
+
rooted: pack.rooted
|
|
823
|
+
});
|
|
772
824
|
const input = {
|
|
773
825
|
pack: pack.bytes,
|
|
774
826
|
objects: pack.objects
|
|
@@ -824,7 +876,7 @@ const movedKinds = (updates, moved) => {
|
|
|
824
876
|
*/
|
|
825
877
|
const ownPack = (request, received) => {
|
|
826
878
|
const id = received?.quarantine?.id;
|
|
827
|
-
if (request.pack === void 0 || "
|
|
879
|
+
if (request.pack === void 0 || !("bytes" in request.pack) || id === void 0) return void 0;
|
|
828
880
|
return isPackId(id) ? id : void 0;
|
|
829
881
|
};
|
|
830
882
|
/** Whether a commit lists `pack`: its change deletes the pack's own `quarantine` row. */
|
|
@@ -839,9 +891,9 @@ const lists = (body, pack) => body.delete.some((key) => key.collection === objec
|
|
|
839
891
|
* only, refused as the commit would be, its `writes` or none, and answered before it, for
|
|
840
892
|
* `checkPush`: nothing before that point writes, reserves or enqueues, with no pack.
|
|
841
893
|
*/
|
|
842
|
-
const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRepo, view, views }, key, answers, checking = false) => Effect.scoped(Effect.gen(function* () {
|
|
894
|
+
const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRepo, view, views, heldAt }, key, answers, checking = false) => Effect.scoped(Effect.gen(function* () {
|
|
843
895
|
const core = yield* CoreParts;
|
|
844
|
-
const { objects: sealed } = yield* ObjectsParts;
|
|
896
|
+
const { objects: sealed, fetchLimits, files = defaultPushFiles, repo: repoSizes = defaultPushRepo } = yield* ObjectsParts;
|
|
845
897
|
const authorize = yield* Authorize;
|
|
846
898
|
const { store } = core;
|
|
847
899
|
const { caller, repo, signal } = request;
|
|
@@ -850,7 +902,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
|
|
|
850
902
|
const { received, rooted } = yield* receive(yield* read({
|
|
851
903
|
view,
|
|
852
904
|
at: seen
|
|
853
|
-
}), listed, request).pipe(Effect.tapError((error) => isAwaitingRepack(error) ? bestEffort(ensureRepack(core, core.jobs,
|
|
905
|
+
}), listed, request).pipe(Effect.provideService(HeldBy, heldUntil(heldAt, fetchLimits)), Effect.tapError((error) => isAwaitingRepack(error) ? bestEffort(ensureRepack(core, core.jobs, listed.repo, fetchLimits)) : Effect.void), Effect.mapError(asPushCheck));
|
|
854
906
|
const ownedPack = ownPack(request, received);
|
|
855
907
|
let listing = false;
|
|
856
908
|
if (ownedPack !== void 0) yield* Effect.addFinalizer((exit) => listing || Exit.hasInterrupts(exit) ? Effect.void : Effect.flatMap(Clock$1.currentTimeMillis, (at) => abandonOwn({
|
|
@@ -881,6 +933,11 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
|
|
|
881
933
|
};
|
|
882
934
|
if (rooted !== void 0) kindsInput.missing = rooted;
|
|
883
935
|
const kinds = yield* kindsOf(kindsInput).pipe(Effect.mapError(asPushCheck));
|
|
936
|
+
const tips = kinds.updates.flatMap(({ ref, to }) => to === null ? [] : [{
|
|
937
|
+
ref,
|
|
938
|
+
oid: to
|
|
939
|
+
}]);
|
|
940
|
+
const warned = yield* filesChecked(files, received, pushed, tips);
|
|
884
941
|
const fetchedOff = yield* fetchedRefused(kinds, request);
|
|
885
942
|
const { forced } = fetchedOff;
|
|
886
943
|
const refused = new Map(fetchedOff.refused);
|
|
@@ -1029,6 +1086,11 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
|
|
|
1029
1086
|
const published = yield* publishedAt(read.refs, decide.at, indexRow);
|
|
1030
1087
|
const { writes } = request;
|
|
1031
1088
|
if (writes !== void 0 && (writes.unchanged === void 0 ? read.version !== writes.version : decide.changed)) return yield* Effect.fail(queueMoved(repo));
|
|
1089
|
+
const rowsMoved = received === void 0 ? noRows : yield* rowsAtCommit(store, listed.repo, received.change, read.version);
|
|
1090
|
+
if (rowsMoved === void 0) continue;
|
|
1091
|
+
const added = addedBytes(received?.change, rowsMoved);
|
|
1092
|
+
const sized = repoChecked(repoSizes, stats.ownBytes, added);
|
|
1093
|
+
if (sized.refused !== void 0) return yield* Effect.fail(sized.refused);
|
|
1032
1094
|
const seen = {
|
|
1033
1095
|
...facts,
|
|
1034
1096
|
tips: tipsOf(read.refs, outside)
|
|
@@ -1080,11 +1142,13 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
|
|
|
1080
1142
|
...unseen
|
|
1081
1143
|
])
|
|
1082
1144
|
};
|
|
1083
|
-
const
|
|
1145
|
+
const fetchedRoots = request.fetched?.roots;
|
|
1146
|
+
const rooted = fetchedRoots === void 0 ? void 0 : yield* rootsMoved(decide.roots, fetchedRoots, indexJobs(core, indexed));
|
|
1147
|
+
const chosen = withRoots(decidePush({
|
|
1084
1148
|
read,
|
|
1085
1149
|
command: decided,
|
|
1086
1150
|
index: core.refIndex
|
|
1087
|
-
});
|
|
1151
|
+
}), rooted, read.version);
|
|
1088
1152
|
const clears = read.marked === true && clearsMark(chosen);
|
|
1089
1153
|
const decision = clears ? clearedAt(chosen, at) : chosen;
|
|
1090
1154
|
const upkept = clears && jobs.length === 0 ? [core.repackJobRow()] : jobs;
|
|
@@ -1094,7 +1158,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
|
|
|
1094
1158
|
if (refusal !== void 0) return yield* Effect.fail(refusal);
|
|
1095
1159
|
const movedRefs = new Set(planned.moved.map((move) => move.ref));
|
|
1096
1160
|
const liftedOnMoves = [...checked?.bypassed ?? none].filter(([ref]) => movedRefs.has(ref));
|
|
1097
|
-
const answer = yield* answers.answer(planned.answer, forced, new Map(liftedOnMoves));
|
|
1161
|
+
const answer = yield* answers.answer(planned.answer, forced, new Map(liftedOnMoves), [...warned, ...sized.warned]);
|
|
1098
1162
|
if (checking) return answer;
|
|
1099
1163
|
const also = planned.answer.updates.some((update) => update.kind === "rejected") || request.also === void 0 ? void 0 : request.also(yield* Clock$1.currentTimeMillis, received);
|
|
1100
1164
|
const alsoWrites = (also?.put.length ?? 0) + (also?.delete?.length ?? 0);
|
|
@@ -1137,8 +1201,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
|
|
|
1137
1201
|
const kept = receiptWrites(key, answers.kept(final), core.repackJobRow);
|
|
1138
1202
|
const woken = shown.filter((move) => queued.has(move.ref)).map((move) => advanceRow(move.ref));
|
|
1139
1203
|
const pushed = pushedRows(core.access, shown, times, at);
|
|
1140
|
-
const moved =
|
|
1141
|
-
if (moved === void 0) continue;
|
|
1204
|
+
const moved = planned.moves ? rowsMoved : noRows;
|
|
1142
1205
|
const loose = looseRows(times.loose, moved);
|
|
1143
1206
|
const body = {
|
|
1144
1207
|
id,
|
|
@@ -1166,7 +1229,11 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
|
|
|
1166
1229
|
...woken,
|
|
1167
1230
|
...shown.length > 0 ? indexJobs(core, indexed) : [],
|
|
1168
1231
|
...planned.moves ? refIndexJobs(core, record) : []
|
|
1169
|
-
], [
|
|
1232
|
+
], [
|
|
1233
|
+
...kept.jobs,
|
|
1234
|
+
...also?.jobs ?? [],
|
|
1235
|
+
...rooted?.jobs ?? []
|
|
1236
|
+
])
|
|
1170
1237
|
};
|
|
1171
1238
|
const objects = (received?.change.put?.length ?? 0) + (received?.change.delete?.length ?? 0);
|
|
1172
1239
|
const written = body.put.length + body.delete.length + body.jobs.length;
|
|
@@ -1205,8 +1272,9 @@ const pushWith = (request, answers, key) => pushThrough(request, answers, key, f
|
|
|
1205
1272
|
/** `pushWith`, or with `checking`, its checks alone, as `pushOnto` says. */
|
|
1206
1273
|
const pushThrough = /* @__PURE__ */ Effect.fnUntraced(function* (request, answers, key, checking) {
|
|
1207
1274
|
const operation = operationOf(request);
|
|
1275
|
+
const heldAt = yield* Clock$1.currentTimeMillis;
|
|
1208
1276
|
const resolved = yield* firstRead(request.caller, operation, request.internalId).pipe(Effect.tapError((error) => retriedCodes.has(error.code) ? Effect.void : refuseQueued(request, [error], "access")));
|
|
1209
|
-
const opened = yield* listedFor(request, operation, resolved);
|
|
1277
|
+
const opened = yield* listedFor(request, operation, resolved, heldAt);
|
|
1210
1278
|
return yield* pushOnto(request, opened, key, answers, checking);
|
|
1211
1279
|
});
|
|
1212
1280
|
/** A push or an unkeyed `refs.update`, answering the decide's ref answer. */
|
|
@@ -1220,6 +1288,12 @@ const push = (request) => pushWith(request, refsAnswers);
|
|
|
1220
1288
|
const checkPush = (request) => request.pack === void 0 ? pushThrough(request, refsAnswers, void 0, true) : fail("INTERNAL", "A push is checked with no pack");
|
|
1221
1289
|
/** A `git push`, as `push`, with the lines Git prints for the rules `authorize` lifted. */
|
|
1222
1290
|
const gitPush = (request) => pushWith(request, gitAnswers);
|
|
1291
|
+
/**
|
|
1292
|
+
* `gitPush` for a write's key, whose receipt keeps each ref's answer, as a push upload's job lands:
|
|
1293
|
+
* sent again, it answers what its receipt kept, with no lines for band 2. `undefined` when the
|
|
1294
|
+
* name holds a repo other than the one its key's lookup saw.
|
|
1295
|
+
*/
|
|
1296
|
+
const keyedGitPush = (request, keyed) => keyedPushWith(request, gitAnswers, keyed);
|
|
1223
1297
|
/** A ref a forced fetch moved past its diverged tip, answered `force`; the rest as they are. */
|
|
1224
1298
|
const forcedOf = (forced) => (update) => update.kind === "applied" && forced.has(update.ref) ? {
|
|
1225
1299
|
kind: "force",
|
|
@@ -1245,11 +1319,12 @@ const pushFetched = (request) => pushWith(request, {
|
|
|
1245
1319
|
*/
|
|
1246
1320
|
const keyedPushWith = /* @__PURE__ */ Effect.fnUntraced(function* (request, answers, keyed) {
|
|
1247
1321
|
const operation = operationOf(request);
|
|
1322
|
+
const heldAt = yield* Clock$1.currentTimeMillis;
|
|
1248
1323
|
const resolved = yield* keyedRead(request.caller, operation, keyed.missed, request.internalId);
|
|
1249
1324
|
if (resolved === void 0) return void 0;
|
|
1250
|
-
const opened = yield* listedFor(request, operation, resolved);
|
|
1325
|
+
const opened = yield* listedFor(request, operation, resolved, heldAt);
|
|
1251
1326
|
return yield* pushOnto(request, opened, keyed.key, answers);
|
|
1252
1327
|
});
|
|
1253
1328
|
/** `keyedPushWith` for `refs.update`, answering the decide's ref answer. */
|
|
1254
1329
|
const keyedPush = (request, keyed) => keyedPushWith(request, refsAnswers, keyed);
|
|
1255
|
-
export { buildFence, checkPush, gitPush, isQueueMoved, keyedPush, keyedPushWith, push, pushFetched, pushWith, retriedCodes };
|
|
1330
|
+
export { buildFence, checkPush, gitPush, isQueueMoved, keyedGitPush, keyedPush, keyedPushWith, push, pushFetched, pushWith, retriedCodes };
|
package/dist/core/receipts.mjs
CHANGED
|
@@ -25,6 +25,7 @@ const KeptError = /* @__PURE__ */ Schema.Struct({
|
|
|
25
25
|
hint: Schema.optionalKey(Schema.String),
|
|
26
26
|
context: Schema.optionalKey(Schema.Record(Schema.String, ContextValue))
|
|
27
27
|
});
|
|
28
|
+
/** One ref's answer as a receipt keeps it. */
|
|
28
29
|
const KeptUpdate = /* @__PURE__ */ Schema.Union([Schema.Struct({
|
|
29
30
|
kind: Schema.Literal("applied"),
|
|
30
31
|
ref: Schema.String
|
|
@@ -47,7 +48,9 @@ const KeptAnswer = /* @__PURE__ */ Schema.Union([
|
|
|
47
48
|
}),
|
|
48
49
|
Schema.Struct({
|
|
49
50
|
kind: Schema.Literal("repo"),
|
|
50
|
-
info: KeptRepoInfo
|
|
51
|
+
info: KeptRepoInfo,
|
|
52
|
+
/** A rename's `repo.renamed` place in its sequence, when the server keeps events. */
|
|
53
|
+
seq: Schema.optionalKey(Schema.Int)
|
|
51
54
|
}),
|
|
52
55
|
Schema.Struct({
|
|
53
56
|
kind: Schema.Literal("object"),
|
|
@@ -215,20 +218,24 @@ const keptError = (error) => {
|
|
|
215
218
|
* rejected ref, or an import's failure.
|
|
216
219
|
*/
|
|
217
220
|
const heldError = (kept) => gitErrorFrom(kept);
|
|
221
|
+
/** Each ref's answer as a row keeps it: an applied ref as it is, a rejected one's error kept. */
|
|
222
|
+
const keptUpdates = (answer) => answer.updates.map((update) => update.kind === "applied" ? update : {
|
|
223
|
+
...update,
|
|
224
|
+
error: keptError(update.error)
|
|
225
|
+
});
|
|
226
|
+
/** Kept answers as `RefsUpdated` again, each rejected ref's error tagged. */
|
|
227
|
+
const heldUpdates = (updates) => ({ updates: updates.map((update) => update.kind === "applied" ? update : {
|
|
228
|
+
...update,
|
|
229
|
+
error: heldError(update.error)
|
|
230
|
+
}) });
|
|
218
231
|
/** A `refs.update`'s answer as its receipt keeps it. */
|
|
219
232
|
const refsKept = (answer) => ({
|
|
220
233
|
kind: "refs",
|
|
221
|
-
updates: answer
|
|
222
|
-
...update,
|
|
223
|
-
error: keptError(update.error)
|
|
224
|
-
})
|
|
234
|
+
updates: keptUpdates(answer)
|
|
225
235
|
});
|
|
226
236
|
const noAnswer = (held, kind) => fail("DATA_LOSS", `A receipt kept no ${kind} answer`, { context: { input: held.input } });
|
|
227
237
|
/** The answer a `refs.update`'s receipt kept, for the write sent again. */
|
|
228
|
-
const refsAnswer = (held) => held.answer?.kind === "refs" ? Effect.succeed(
|
|
229
|
-
...update,
|
|
230
|
-
error: heldError(update.error)
|
|
231
|
-
}) }) : noAnswer(held, "refs");
|
|
238
|
+
const refsAnswer = (held) => held.answer?.kind === "refs" ? Effect.succeed(heldUpdates(held.answer.updates)) : noAnswer(held, "refs");
|
|
232
239
|
/**
|
|
233
240
|
* A fork create's receipt: its answer is asked of the view after its commit, so it keeps none, and
|
|
234
241
|
* the create sent again reads the fork again.
|
|
@@ -252,6 +259,15 @@ const receiptAnswered = (held) => {
|
|
|
252
259
|
};
|
|
253
260
|
/** The answer a repo create, update or rename's receipt kept, for the write sent again. */
|
|
254
261
|
const repoAnswer = (held) => held.answer?.kind === "repo" ? Effect.succeed(held.answer.info) : noAnswer(held, "repo");
|
|
262
|
+
/** The answer a rename's receipt kept, with its event's `seq` when it kept one. */
|
|
263
|
+
const renamedAnswer = (held) => {
|
|
264
|
+
const { answer } = held;
|
|
265
|
+
if (answer?.kind !== "repo") return noAnswer(held, "repo");
|
|
266
|
+
return Effect.succeed(answer.seq === void 0 ? answer.info : {
|
|
267
|
+
...answer.info,
|
|
268
|
+
seq: answer.seq
|
|
269
|
+
});
|
|
270
|
+
};
|
|
255
271
|
/** The object a create, merge, revert or pick's receipt kept, for the write sent again. */
|
|
256
272
|
const objectAnswer = (held) => held.answer?.kind === "object" ? Effect.succeed(writtenOf(held.answer)) : noAnswer(held, "object");
|
|
257
273
|
/** A kept object answer as its write answered it, `renamesSkipped` only where it was kept. */
|
|
@@ -263,4 +279,4 @@ const writtenOf = (kept) => {
|
|
|
263
279
|
if (kept.renamesSkipped !== void 0) written.renamesSkipped = kept.renamesSkipped;
|
|
264
280
|
return written;
|
|
265
281
|
};
|
|
266
|
-
export { KeptError, ReceiptRow, dayMs, dayOf, forkKept, heldError, heldReceipt, keptError, liveReceipt, matchedReceipt, objectAnswer, receiptAnswered, receiptId, receiptKeys, receiptReads, receiptRow, receiptWrites, refsAnswer, refsKept, repoAnswer, sweepDue, sweepOf, sweepRead, withJobs };
|
|
282
|
+
export { KeptError, KeptUpdate, ReceiptRow, dayMs, dayOf, forkKept, heldError, heldReceipt, heldUpdates, keptError, keptUpdates, liveReceipt, matchedReceipt, objectAnswer, receiptAnswered, receiptId, receiptKeys, receiptReads, receiptRow, receiptWrites, refsAnswer, refsKept, renamedAnswer, repoAnswer, sweepDue, sweepOf, sweepRead, withJobs };
|
package/dist/core/ref-view.mjs
CHANGED
|
@@ -2,10 +2,12 @@ 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
4
|
import { CoreParts } from "./parts.mjs";
|
|
5
|
+
import { ownedAway } from "../protocol/wire/lines.mjs";
|
|
5
6
|
import { Authorize, audience, check, grantOf } from "../contracts/authorize.mjs";
|
|
6
7
|
import * as Clock$1 from "effect/Clock";
|
|
7
8
|
import * as Effect from "effect/Effect";
|
|
8
9
|
import * as Option from "effect/Option";
|
|
10
|
+
import { byBytes } from "@ref0/infra";
|
|
9
11
|
import * as Context from "effect/Context";
|
|
10
12
|
// src/core/ref-view.ts
|
|
11
13
|
/**
|
|
@@ -45,8 +47,8 @@ const withAudienceMemo = (effect) => Effect.suspend(() => withRequestHold(effect
|
|
|
45
47
|
* The objects `caller` reads of a repo at `version` from `tips`, `make`'s, kept for the request.
|
|
46
48
|
* A held set is answered only for the same tips, compared in full as sets, so a tip named twice
|
|
47
49
|
* counts once: the same version can be asked by other tips, as a push's own refs are. `make`
|
|
48
|
-
* answers `undefined` only for objects sealed with no index, which `
|
|
49
|
-
*
|
|
50
|
+
* answers `undefined` only for objects sealed with no index, which `PrivateRefs.layer` never
|
|
51
|
+
* takes, so that fails closed.
|
|
50
52
|
*/
|
|
51
53
|
const viewedIn = /* @__PURE__ */ Effect.fnUntraced(function* (caller, internalId, version, tips, make) {
|
|
52
54
|
const memo = yield* Effect.serviceOption(ViewedMemo);
|
|
@@ -97,8 +99,54 @@ const askRefView = (access, caller, about, hidden) => {
|
|
|
97
99
|
...about
|
|
98
100
|
})), (audience) => access.refViewOf(audience, hidden));
|
|
99
101
|
};
|
|
100
|
-
/**
|
|
102
|
+
/**
|
|
103
|
+
* Whether `table` has an `owned` prefix, whose refs a view leaves out for all but its owner, even
|
|
104
|
+
* a whole one: a whole view's fast paths, which skip `sees`, filter only when it does.
|
|
105
|
+
*/
|
|
106
|
+
const anyOwned = (table) => table.some((hidden) => hidden.underPrefix === "owned");
|
|
107
|
+
/**
|
|
108
|
+
* The names under `prefix` in `table`'s `owned` prefixes, as `RefView.hiddenSpans` answers them:
|
|
109
|
+
* all of them when `prefix` is under one, and otherwise each one under `prefix`, which ends before
|
|
110
|
+
* its last `/` would be `0`. Registered prefixes meet no other, so the spans are apart and, sorted
|
|
111
|
+
* by their prefixes, in id order.
|
|
112
|
+
*/
|
|
113
|
+
const ownedSpans = (table, prefix) => {
|
|
114
|
+
const owned = table.flatMap(({ owner, underPrefix }) => underPrefix === "owned" ? [owner.prefix] : []);
|
|
115
|
+
if (owned.some((under) => prefix.startsWith(under))) return [{ from: prefix }];
|
|
116
|
+
return owned.flatMap((under) => under.startsWith(prefix) ? [{
|
|
117
|
+
from: under,
|
|
118
|
+
to: `${under.slice(0, -1)}0`
|
|
119
|
+
}] : []).toSorted((one, other) => byBytes(one.from, other.from));
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* `view` less the refs under `table`'s `owned` prefixes, which no caller sees but their owner. A
|
|
123
|
+
* whole view keeps `whole`, as its fast paths ask `anyOwned` first, and answers the prefixes as its
|
|
124
|
+
* spans, so a listing reads past them and a count leaves them out. A view that isn't whole holds
|
|
125
|
+
* them already, as Git's own prefixes.
|
|
126
|
+
*/
|
|
127
|
+
const ownedOut = (view, table) => {
|
|
128
|
+
if (!anyOwned(table)) return view;
|
|
129
|
+
const out = {
|
|
130
|
+
...view,
|
|
131
|
+
sees: (ref) => !ownedAway(table, ref) && view.sees(ref),
|
|
132
|
+
creates: (ref) => !ownedAway(table, ref) && view.creates(ref)
|
|
133
|
+
};
|
|
134
|
+
return view.whole ? {
|
|
135
|
+
...out,
|
|
136
|
+
hiddenSpans: (prefix) => ownedSpans(table, prefix),
|
|
137
|
+
plainSpans: (prefix) => ownedSpans(table, prefix)
|
|
138
|
+
} : out;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* `caller`'s ref view of `repo`'s refs, asked of `authorize` once per request at most, less any
|
|
142
|
+
* ref under an `owned` prefix, which only its owner's view, `viewOf`'s, sees.
|
|
143
|
+
*/
|
|
101
144
|
const refViewIn = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo) {
|
|
145
|
+
const { hiddenRefs } = yield* CoreParts;
|
|
146
|
+
return ownedOut(yield* askedRefView(caller, repo), hiddenRefs());
|
|
147
|
+
});
|
|
148
|
+
/** `refViewIn`'s view as `authorize` answers it, with every ref the caller's patterns let it see. */
|
|
149
|
+
const askedRefView = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo) {
|
|
102
150
|
const { access, hiddenRefs } = yield* CoreParts;
|
|
103
151
|
if (access === void 0) return wholeView;
|
|
104
152
|
const hidden = prefixesOf(hiddenRefs());
|
|
@@ -138,7 +186,13 @@ const accessAgain = /* @__PURE__ */ Effect.fnUntraced(function* (caller, kind, r
|
|
|
138
186
|
if (!(held !== void 0 && tokenState(held.row, now) === "active")) return yield* fail("UNAUTHENTICATED", "The token is revoked or past its expiry");
|
|
139
187
|
}
|
|
140
188
|
});
|
|
141
|
-
/**
|
|
189
|
+
/**
|
|
190
|
+
* `accessAgain`, then `caller`'s ref view of `repo` itself, asked afresh, never a held answer. It
|
|
191
|
+
* doesn't leave out owned prefixes' refs, as `refViewIn` does, so no caller of it may hand a client
|
|
192
|
+
* the refs it sees. `viewAgainOf` serves mirrors, imports, the queue and `SavedCallers.view`, whose
|
|
193
|
+
* inputs refuse or filter registered prefixes, and an event stream's `recheck` filters events, none
|
|
194
|
+
* of which names an owned ref's move.
|
|
195
|
+
*/
|
|
142
196
|
const refViewAgain = /* @__PURE__ */ Effect.fnUntraced(function* (caller, kind, repo) {
|
|
143
197
|
const { access, hiddenRefs } = yield* CoreParts;
|
|
144
198
|
yield* accessAgain(caller, kind, repo);
|
|
@@ -152,4 +206,4 @@ const creatingRefView = /* @__PURE__ */ Effect.fnUntraced(function* (caller, nam
|
|
|
152
206
|
const { access, hiddenRefs } = yield* CoreParts;
|
|
153
207
|
return yield* askRefView(access, caller, { creating: name }, prefixesOf(hiddenRefs()));
|
|
154
208
|
});
|
|
155
|
-
export { AudienceMemo, ViewedMemo, accessAgain, creatingRefView, refViewAgain, refViewIn, viewedIn, wholeView, withAudienceMemo };
|
|
209
|
+
export { AudienceMemo, ViewedMemo, accessAgain, anyOwned, creatingRefView, ownedSpans, refViewAgain, refViewIn, viewedIn, wholeView, withAudienceMemo };
|
package/dist/core/refs.mjs
CHANGED
|
@@ -4,10 +4,11 @@ import "../contracts/ids.mjs";
|
|
|
4
4
|
import { badCursor } from "../engine/reads.mjs";
|
|
5
5
|
import { listBound } from "../store/cursor-seal.mjs";
|
|
6
6
|
import { storeCall } from "../store/errors.mjs";
|
|
7
|
+
import { heldAdd, heldStore } from "../store/repo-record.mjs";
|
|
7
8
|
import { keptKey } from "../store/records.mjs";
|
|
8
9
|
import { refRowBytes } from "../store/ref-rows.mjs";
|
|
9
10
|
import { collections, repoScope } from "../store/scopes.mjs";
|
|
10
|
-
import { callerFor, contended, keyedRecord, openRepo, refIndexJobs } from "./access.mjs";
|
|
11
|
+
import { acting, callerFor, contended, keyedRecord, openRepo, refIndexJobs } from "./access.mjs";
|
|
11
12
|
import { open } from "./view.mjs";
|
|
12
13
|
import { isRefName } from "./names.mjs";
|
|
13
14
|
import { keyedPush, push } from "./push.mjs";
|
|
@@ -16,10 +17,11 @@ import { gitsOwnRefs, hostLists } from "../protocol/wire/lines.mjs";
|
|
|
16
17
|
import { notFailed } from "./events/deliver.mjs";
|
|
17
18
|
import { refsAnswer } from "./receipts.mjs";
|
|
18
19
|
import { plainClass, refIndexId } from "./ref-index.mjs";
|
|
20
|
+
import { ownedSpans } from "./ref-view.mjs";
|
|
19
21
|
import { pushRulesFor } from "./rules/check.mjs";
|
|
20
22
|
import { refProtection } from "./rules/protect.mjs";
|
|
21
23
|
import { fail } from "../contracts/result.mjs";
|
|
22
|
-
import { CoreParts,
|
|
24
|
+
import { CoreParts, ObjectsParts } from "./parts.mjs";
|
|
23
25
|
import { bypassKinds, hostAuthorize } from "../auth/authorize.mjs";
|
|
24
26
|
import { Authorize, check } from "../contracts/authorize.mjs";
|
|
25
27
|
import * as Clock$1 from "effect/Clock";
|
|
@@ -220,7 +222,8 @@ const refCalls = (bound) => {
|
|
|
220
222
|
const view = yield* open({
|
|
221
223
|
repo: pinnedOf(repo, input),
|
|
222
224
|
by: callerOf(input),
|
|
223
|
-
reads: [read]
|
|
225
|
+
reads: [read],
|
|
226
|
+
owner: input.owner
|
|
224
227
|
});
|
|
225
228
|
const oid = (yield* view.refs(view.resolved.snapshot.results[1] ?? [])).get(ref);
|
|
226
229
|
if (oid === void 0) return yield* fail("NOT_FOUND", `No ref '${ref}' in '${repo}'`);
|
|
@@ -282,8 +285,10 @@ const refCalls = (bound) => {
|
|
|
282
285
|
const core = yield* CoreParts;
|
|
283
286
|
const jobs = refIndexJobs(core, view.resolved.record);
|
|
284
287
|
if (jobs.length === 0) return;
|
|
285
|
-
|
|
286
|
-
const
|
|
288
|
+
const { internalId } = view.resolved;
|
|
289
|
+
const { fetchLimits } = yield* ObjectsParts;
|
|
290
|
+
if (!(yield* heldAdd(heldStore(core.store), internalId, fetchLimits, { jobs }).pipe(Effect.as(true), Effect.catchTag("RepoGone", () => Effect.succeed(false))))) return;
|
|
291
|
+
const scope = repoScope(internalId);
|
|
287
292
|
for (const { name, key } of jobs) yield* storeCall(() => core.jobs.retry(scope, {
|
|
288
293
|
name,
|
|
289
294
|
key
|
|
@@ -325,7 +330,7 @@ const refCalls = (bound) => {
|
|
|
325
330
|
name,
|
|
326
331
|
oid
|
|
327
332
|
}] : []);
|
|
328
|
-
if (sealed) {
|
|
333
|
+
if (sealed || ownedSpans(hidden, asked ?? "").length > 0) {
|
|
329
334
|
const view = yield* open({
|
|
330
335
|
repo: pinnedOf(repo, input),
|
|
331
336
|
by: callerOf(input)
|
|
@@ -352,7 +357,8 @@ const refCalls = (bound) => {
|
|
|
352
357
|
limit,
|
|
353
358
|
listed,
|
|
354
359
|
bound,
|
|
355
|
-
runs
|
|
360
|
+
runs,
|
|
361
|
+
sealed
|
|
356
362
|
});
|
|
357
363
|
}
|
|
358
364
|
const view = yield* open({
|
|
@@ -383,7 +389,8 @@ const refCalls = (bound) => {
|
|
|
383
389
|
*/
|
|
384
390
|
const seenPage = Effect.fnUntraced(function* (view, page) {
|
|
385
391
|
const core = yield* CoreParts;
|
|
386
|
-
const { prefix, limit, listed, bound, runs } = page;
|
|
392
|
+
const { prefix, limit, listed, bound, runs, sealed } = page;
|
|
393
|
+
const cursor = (name) => sealed ? core.cursors.seal(bound, name) : Effect.succeed(name);
|
|
387
394
|
const scope = repoScope(view.resolved.internalId);
|
|
388
395
|
const items = [];
|
|
389
396
|
let after = page.after;
|
|
@@ -453,8 +460,8 @@ const refCalls = (bound) => {
|
|
|
453
460
|
const shown = items.slice(0, limit);
|
|
454
461
|
const end = shown.at(-1);
|
|
455
462
|
const listing = { items: shown };
|
|
456
|
-
if (stopped !== void 0) listing.next = yield*
|
|
457
|
-
else if ((short || items.length > limit) && end !== void 0) listing.next = yield*
|
|
463
|
+
if (stopped !== void 0) listing.next = yield* cursor(stopped);
|
|
464
|
+
else if ((short || items.length > limit) && end !== void 0) listing.next = yield* cursor(end.name);
|
|
458
465
|
return listing;
|
|
459
466
|
});
|
|
460
467
|
/**
|
|
@@ -480,6 +487,7 @@ const refCalls = (bound) => {
|
|
|
480
487
|
if (input.signal !== void 0) request.signal = input.signal;
|
|
481
488
|
if (input.internalId !== void 0) request.internalId = input.internalId;
|
|
482
489
|
if (input.onBehalfOf !== void 0) request.onBehalfOf = true;
|
|
490
|
+
if (input.owner !== void 0) request.as = input.owner;
|
|
483
491
|
const edits = input.updates.map(({ ref, from, to }) => [
|
|
484
492
|
ref,
|
|
485
493
|
from,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { fail } from "../contracts/result.mjs";
|
|
2
|
+
import { asAsked, readAsked } from "./asked.mjs";
|
|
2
3
|
import { storeCall } from "../store/errors.mjs";
|
|
3
|
-
import { readRecord } from "../store/repo-record.mjs";
|
|
4
|
+
import { heldAdd, heldStore, readRecord } from "../store/repo-record.mjs";
|
|
4
5
|
import { newChangeId, repoScope } from "../store/scopes.mjs";
|
|
5
6
|
import * as Effect from "effect/Effect";
|
|
6
7
|
// src/core/registered-rows.ts
|
|
@@ -21,13 +22,14 @@ const registeredRows = (name, base) => {
|
|
|
21
22
|
});
|
|
22
23
|
const jobsOf = (bound, writes) => writes.wake === void 0 ? [] : [bound.repackJobRow(writes.wake)];
|
|
23
24
|
return {
|
|
24
|
-
read: (repo, reads) => within(reads, (bound) => Effect.map(
|
|
25
|
+
read: (repo, reads, asked) => within(reads, (bound) => Effect.map(readAsked(bound.store, repo, reads, [], asked), ({ version, results }) => ({
|
|
25
26
|
version,
|
|
26
27
|
results
|
|
27
28
|
}))),
|
|
28
|
-
readFenced: (caller, repo, reads) => within(reads, (bound) => Effect.gen(function* () {
|
|
29
|
+
readFenced: (caller, repo, reads, asked) => within(reads, (bound) => Effect.gen(function* () {
|
|
29
30
|
const fence = bound.fences(caller, repo);
|
|
30
31
|
const { record, snapshot } = yield* readRecord(bound.store, repo.internalId, [...reads, ...fence.reads]);
|
|
32
|
+
if (asked !== void 0) yield* asAsked(asked, record);
|
|
31
33
|
if (record === void 0 || record.deleted === true) return yield* fail("NOT_FOUND", `No repo '${repo.name}'`);
|
|
32
34
|
const results = snapshot.results.slice(1);
|
|
33
35
|
yield* fence.check(results.slice(reads.length));
|
|
@@ -44,10 +46,10 @@ const registeredRows = (name, base) => {
|
|
|
44
46
|
delete: [...writes.delete ?? []],
|
|
45
47
|
jobs: jobsOf(bound, writes)
|
|
46
48
|
}))),
|
|
47
|
-
add: (repo, writes) => within(writes.put ?? [], (bound) =>
|
|
49
|
+
add: (repo, writes) => within(writes.put ?? [], (bound) => heldAdd(heldStore(bound.store), repo, bound.fetchLimits, {
|
|
48
50
|
put: [...writes.put ?? []],
|
|
49
51
|
jobs: jobsOf(bound, writes)
|
|
50
|
-
})))
|
|
52
|
+
}).pipe(Effect.catchTag("RepoGone", () => fail("NOT_FOUND", `No repo '${repo}'`))))
|
|
51
53
|
};
|
|
52
54
|
};
|
|
53
55
|
export { registeredRows };
|