@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/repack.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { untilAborted } from "../store/crossing.mjs";
|
|
|
5
5
|
import { gitJob } from "../store/job-try.mjs";
|
|
6
6
|
import { decodePacks, featureChange, gitStore, packRow } from "../store/git-store.mjs";
|
|
7
7
|
import { appendEvents, decodeOutbox, outboxReads, repoEnvelope } from "../store/outbox.mjs";
|
|
8
|
-
import { decodeStats, looseRows, readRecord, repoStats, timeRow } from "../store/repo-record.mjs";
|
|
8
|
+
import { decodeStats, heldAdd, heldStore, looseRows, readRecord, repoStats, timeRow } from "../store/repo-record.mjs";
|
|
9
9
|
import { settleName } from "../store/settle.mjs";
|
|
10
10
|
import { replacedAtCommit } from "../storage/index-remap.mjs";
|
|
11
11
|
import { indexRowKey, isPackId, objectCollections } from "../storage/layout.mjs";
|
|
@@ -14,7 +14,7 @@ import { noRows } from "../storage/object-rows.mjs";
|
|
|
14
14
|
import { ReadyRow, readyBytesOf } from "../storage/ready.mjs";
|
|
15
15
|
import { ApartRow, apartAfter, apartKey } from "../storage/repack-contained.mjs";
|
|
16
16
|
import { SwapsSettled, swapsKey, swapsLeft } from "../storage/swap-walk.mjs";
|
|
17
|
-
import { QuarantineRow, decodeHeld, decodeLeft, isLeftKey, leavingKey, leavingLate, leavingRow, leftPack } from "../storage/rows.mjs";
|
|
17
|
+
import { QuarantineRow, decodeHeld, decodeLeft, deletedLeaveAt, isLeftKey, leavingKey, leavingLate, leavingRow, leftPack } from "../storage/rows.mjs";
|
|
18
18
|
import { WholeRepo, wholeRefs } from "../store/ref-rows.mjs";
|
|
19
19
|
import { collections, jobRepo, maintainedKey, newChangeId, prunedKey, reachedKey, repoScope } from "../store/scopes.mjs";
|
|
20
20
|
import { MaintenanceRun, RepackData, maintenanceRunKey, parksPass, pruneJobKey, pruneJobRow, repackJobKey, repackJobName, repackJobRow as repackJobRow$1 } from "../storage/repack-job.mjs";
|
|
@@ -179,14 +179,17 @@ const bothSwept = (receipts, own) => {
|
|
|
179
179
|
return sweep;
|
|
180
180
|
};
|
|
181
181
|
/**
|
|
182
|
-
* A deleted repo's next page of listed packs, each moved to a `leaving` row the server's
|
|
183
|
-
* `fetchLimits`
|
|
184
|
-
* are listed.
|
|
182
|
+
* A deleted repo's next page of listed packs, each moved to a `leaving` row due the server's
|
|
183
|
+
* `fetchLimits` past the delete, at `deletedAt`, so a clone still streaming one finishes first:
|
|
184
|
+
* `undefined` once none are listed. The time is the delete's, not the step's: a deleted repo
|
|
185
|
+
* answers no open, so no fetch begins after it, and a step that runs late lets its packs go at
|
|
186
|
+
* once, as the purge's own guard does. A live repo's packs leave by `leavingRows`, a fetch's limit
|
|
187
|
+
* past the step, since a fetch may begin just before it.
|
|
185
188
|
*/
|
|
186
|
-
const leavingOf = /* @__PURE__ */ Effect.fnUntraced(function* (parts, packs,
|
|
189
|
+
const leavingOf = /* @__PURE__ */ Effect.fnUntraced(function* (parts, packs, deletedAt) {
|
|
187
190
|
const page = packs.slice(0, leavingPage);
|
|
188
191
|
if (page.length === 0) return void 0;
|
|
189
|
-
const removeAt =
|
|
192
|
+
const removeAt = deletedLeaveAt(deletedAt, parts.fetchLimits);
|
|
190
193
|
const named = yield* Effect.forEach(page, (pack) => {
|
|
191
194
|
const { id } = pack;
|
|
192
195
|
return isPackId(id) ? Effect.succeed({
|
|
@@ -518,12 +521,12 @@ const repackStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
|
|
|
518
521
|
if (first.index !== void 0) input.index = first.index.value;
|
|
519
522
|
if (missed >= 5) input.drops = false;
|
|
520
523
|
if (retried) input.retried = true;
|
|
521
|
-
if (first.record.deleted === true) input.deleted =
|
|
524
|
+
if (first.record.deleted === true) input.deleted = first.record.changedAt;
|
|
522
525
|
const held = first.sweep(at).more ? {
|
|
523
526
|
change: { rows: noRows },
|
|
524
527
|
more: false
|
|
525
528
|
} : void 0;
|
|
526
|
-
const step = (first.record.deleted === true ? held ?? (yield* leavingOf(parts, first.packs,
|
|
529
|
+
const step = (first.record.deleted === true ? held ?? (yield* leavingOf(parts, first.packs, first.record.changedAt)) : void 0) ?? (yield* resultCall(() => SealedObjects.whole(parts.objects, upkeepWhole).maintain(listed, input)));
|
|
527
530
|
if (step?.yielded === true) return void 0;
|
|
528
531
|
let read = first;
|
|
529
532
|
for (let tries = 1;; tries += 1) {
|
|
@@ -661,9 +664,11 @@ const repackJobRow = (job, at) => job.job(at === void 0 ? {
|
|
|
661
664
|
* The repo's `git.repack` row made due, for a push refused `packs-awaiting-repack`, so its hint
|
|
662
665
|
* holds: added if it's gone, and retried if it spent its tries, since an add leaves a failed row
|
|
663
666
|
* failed, its data rebuilt once it has compacted. A row already waiting or running is left as it is.
|
|
667
|
+
* A repo deleted since the push read it takes none, as its purge may have dropped its scope (#1911).
|
|
664
668
|
*/
|
|
665
|
-
const ensureRepack = /* @__PURE__ */ Effect.fnUntraced(function* (core, jobs,
|
|
666
|
-
yield*
|
|
669
|
+
const ensureRepack = /* @__PURE__ */ Effect.fnUntraced(function* (core, jobs, repo, fetchLimits) {
|
|
670
|
+
if (!(yield* heldAdd(heldStore(core.store), repo, fetchLimits, { jobs: [core.repackJobRow()] }).pipe(Effect.as(true), Effect.catchTag("RepoGone", () => Effect.succeed(false))))) return;
|
|
671
|
+
const scope = repoScope(repo);
|
|
667
672
|
const job = {
|
|
668
673
|
name: repackJobName,
|
|
669
674
|
key: repackJobKey
|
package/dist/core/repo-info.mjs
CHANGED
|
@@ -3,10 +3,10 @@ import { readyBytesOf } from "../storage/ready.mjs";
|
|
|
3
3
|
import { namedRecordOf } from "../store/catalogue.mjs";
|
|
4
4
|
import { storeCall } from "../store/errors.mjs";
|
|
5
5
|
import { decodePacks } from "../store/git-store.mjs";
|
|
6
|
-
import { decodeStats, repoStats, seenTimes } from "../store/repo-record.mjs";
|
|
7
|
-
import { repoScope } from "../store/scopes.mjs";
|
|
6
|
+
import { decodeStats, repoStats, rootsOf, seenTimes } from "../store/repo-record.mjs";
|
|
7
|
+
import { repoRootsKey, repoScope } from "../store/scopes.mjs";
|
|
8
8
|
import { liveAsAsked, repoAccess, statsReads } from "./access.mjs";
|
|
9
|
-
import { refViewIn, wholeView } from "./ref-view.mjs";
|
|
9
|
+
import { anyOwned, refViewIn, wholeView } from "./ref-view.mjs";
|
|
10
10
|
import { SealedObjects } from "./view.mjs";
|
|
11
11
|
import { CoreParts, ObjectsParts, QueueParts } from "./parts.mjs";
|
|
12
12
|
import { check } from "../contracts/authorize.mjs";
|
|
@@ -19,9 +19,13 @@ import * as Effect from "effect/Effect";
|
|
|
19
19
|
*/
|
|
20
20
|
/**
|
|
21
21
|
* The reads `repoInfo` answers from, after a repo's `self`: `statsReads`, then its `index` row,
|
|
22
|
-
* whose refusal `RepoWork.index` says, in the one read.
|
|
22
|
+
* whose refusal `RepoWork.index` says, and its roots, which `shallow` says, in the one read.
|
|
23
23
|
*/
|
|
24
|
-
const infoReads = [
|
|
24
|
+
const infoReads = [
|
|
25
|
+
...statsReads,
|
|
26
|
+
indexRowKey,
|
|
27
|
+
repoRootsKey
|
|
28
|
+
];
|
|
25
29
|
/** A refusal that stops the repo's index builds, as `RepoWork.index` says it, or none. */
|
|
26
30
|
const indexHoldOf = (status) => {
|
|
27
31
|
if (status?.state === "refused") return {
|
|
@@ -59,13 +63,12 @@ const repoWork = /* @__PURE__ */ Effect.fnUntraced(function* (internalId, sealed
|
|
|
59
63
|
* `readableRedirect` says, so no fork tells a stranger a private source's name.
|
|
60
64
|
*/
|
|
61
65
|
const repoInfo = /* @__PURE__ */ Effect.fnUntraced(function* (caller, internalId, record, results) {
|
|
62
|
-
const core = yield* CoreParts;
|
|
63
66
|
const repo = repoAccess({
|
|
64
67
|
name: record.name,
|
|
65
68
|
record,
|
|
66
69
|
internalId
|
|
67
70
|
});
|
|
68
|
-
const refView =
|
|
71
|
+
const refView = yield* refViewIn(caller, repo);
|
|
69
72
|
return yield* infoIn(caller, internalId, record, results, refView);
|
|
70
73
|
});
|
|
71
74
|
/**
|
|
@@ -78,20 +81,24 @@ const createdInfo = (caller, internalId, record) => infoIn(caller, internalId, r
|
|
|
78
81
|
/** A repo's info for a caller with `refView`, from what `repoInfo` says. */
|
|
79
82
|
const infoIn = /* @__PURE__ */ Effect.fnUntraced(function* (caller, internalId, record, results, refView) {
|
|
80
83
|
const { objects: sealed } = yield* ObjectsParts;
|
|
81
|
-
const
|
|
84
|
+
const { hiddenRefs } = yield* CoreParts;
|
|
85
|
+
const [refRows = [], packRows = [], timeRows = [], readyRows = [], indexRows = [], rootRows] = results;
|
|
82
86
|
const packs = yield* decodePacks(packRows);
|
|
83
87
|
const times = yield* decodeStats(timeRows);
|
|
84
88
|
const readyBytes = yield* readyBytesOf(readyRows);
|
|
85
|
-
const refs = refView.whole ? refRows.length : refRows.filter((row) => refView.sees(row.id)).length;
|
|
89
|
+
const refs = refView.whole && !anyOwned(hiddenRefs()) ? refRows.length : refRows.filter((row) => refView.sees(row.id)).length;
|
|
86
90
|
const whole = repoStats(record, refs, packs, seenTimes(times, refView), readyBytes);
|
|
91
|
+
const shallow = (yield* rootsOf(rootRows)).size > 0;
|
|
87
92
|
const info = refView.whole ? {
|
|
88
93
|
name: record.name,
|
|
89
94
|
public: record.public,
|
|
95
|
+
shallow,
|
|
90
96
|
stats: whole,
|
|
91
97
|
work: yield* repoWork(internalId, sealed, indexRows[0], packs)
|
|
92
98
|
} : {
|
|
93
99
|
name: record.name,
|
|
94
100
|
public: record.public,
|
|
101
|
+
shallow,
|
|
95
102
|
stats: restricted(whole)
|
|
96
103
|
};
|
|
97
104
|
if (refView.sees(record.defaultBranch)) info.defaultBranch = record.defaultBranch;
|
package/dist/core/repos.mjs
CHANGED
|
@@ -4,8 +4,8 @@ import { isTokenOf } from "../auth/token-text.mjs";
|
|
|
4
4
|
import { checkChurn, createdKey, createdKeyOf, entryOf, listCreated, listLimit, listNames, listPublic, readEntries, recordAt } from "../store/catalogue.mjs";
|
|
5
5
|
import { afterCommit } from "../store/call-count.mjs";
|
|
6
6
|
import { listBound } from "../store/cursor-seal.mjs";
|
|
7
|
-
import { appendEvents, decodeOutbox, dropUnconfirmed, emptyOutbox, outboxReads, repoEnvelope } from "../store/outbox.mjs";
|
|
8
|
-
import { commitRecord, readRecord, writeRecord } from "../store/repo-record.mjs";
|
|
7
|
+
import { appendEvents, decodeOutbox, dropUnconfirmed, emptyOutbox, firstSeq, outboxReads, repoEnvelope } from "../store/outbox.mjs";
|
|
8
|
+
import { commitRecord, deleteCommitWithin, readRecord, writeRecord } from "../store/repo-record.mjs";
|
|
9
9
|
import { keptKey, takenBack } from "../store/records.mjs";
|
|
10
10
|
import { refuseLive, reservationOf, reservedRepo } from "../store/reservations.mjs";
|
|
11
11
|
import { collections, newInternalId, reachedKey, repoScope } from "../store/scopes.mjs";
|
|
@@ -14,9 +14,10 @@ import { createdInfo, infoReads, repoInfo } from "./repo-info.mjs";
|
|
|
14
14
|
import { isRefName } from "./names.mjs";
|
|
15
15
|
import { shortRef } from "./rules/patterns.mjs";
|
|
16
16
|
import { hiddenUnder } from "../protocol/wire/lines.mjs";
|
|
17
|
-
import { heldReceipt, receiptId, receiptKeys, receiptReads, receiptWrites, repoAnswer, withJobs } from "./receipts.mjs";
|
|
17
|
+
import { heldReceipt, receiptId, receiptKeys, receiptReads, receiptWrites, renamedAnswer, repoAnswer, withJobs } from "./receipts.mjs";
|
|
18
18
|
import { fail } from "../contracts/result.mjs";
|
|
19
19
|
import { CoreParts } from "./parts.mjs";
|
|
20
|
+
import { pruneJobRow } from "../storage/repack-job.mjs";
|
|
20
21
|
import { check } from "../contracts/authorize.mjs";
|
|
21
22
|
import * as Clock$1 from "effect/Clock";
|
|
22
23
|
import * as Effect from "effect/Effect";
|
|
@@ -118,11 +119,15 @@ const unreserved = /* @__PURE__ */ Effect.fnUntraced(function* (store, rows) {
|
|
|
118
119
|
yield* refuseLive(store, reservation, (held, state) => reservedRepo(row.id, held, state));
|
|
119
120
|
}
|
|
120
121
|
});
|
|
121
|
-
/** A create, update or rename's answer, as its receipt keeps it
|
|
122
|
-
const repoKept = (info) =>
|
|
122
|
+
/** A create, update or rename's answer, as its receipt keeps it: a rename's with its event's `seq`. */
|
|
123
|
+
const repoKept = (info, seq) => seq === void 0 ? {
|
|
123
124
|
kind: "repo",
|
|
124
125
|
info
|
|
125
|
-
}
|
|
126
|
+
} : {
|
|
127
|
+
kind: "repo",
|
|
128
|
+
info,
|
|
129
|
+
seq
|
|
130
|
+
};
|
|
126
131
|
/** The longer of two prefixes when one starts with the other; `undefined` when they part. */
|
|
127
132
|
const narrower = (one, other) => {
|
|
128
133
|
if (one.startsWith(other)) return one;
|
|
@@ -637,7 +642,7 @@ const repoCalls = (bound) => {
|
|
|
637
642
|
},
|
|
638
643
|
repo: access
|
|
639
644
|
})), input.internalId);
|
|
640
|
-
if (keyed?.kind === "answered") return yield*
|
|
645
|
+
if (keyed?.kind === "answered") return yield* renamedAnswer(keyed.receipt);
|
|
641
646
|
const operation = {
|
|
642
647
|
kind: "repo.update",
|
|
643
648
|
repo
|
|
@@ -652,7 +657,7 @@ const repoCalls = (bound) => {
|
|
|
652
657
|
if (opened === void 0) continue;
|
|
653
658
|
const keyRows = opened.snapshot.results.slice(1 + renameReads.length);
|
|
654
659
|
const held = yield* heldReceipt(keyRows.slice(0, keyReads.length), kept);
|
|
655
|
-
if (held !== void 0) return yield*
|
|
660
|
+
if (held !== void 0) return yield* renamedAnswer(held);
|
|
656
661
|
yield* unreserved(store, keyRows[keyReads.length] ?? []);
|
|
657
662
|
yield* check({
|
|
658
663
|
caller,
|
|
@@ -679,7 +684,6 @@ const repoCalls = (bound) => {
|
|
|
679
684
|
renamedFrom
|
|
680
685
|
};
|
|
681
686
|
const info = yield* repoInfo(caller, opened.internalId, moved, results);
|
|
682
|
-
const receipt = receiptWrites(kept, repoKept(info), core.repackJobRow);
|
|
683
687
|
const renamed = {
|
|
684
688
|
type: "repo.renamed",
|
|
685
689
|
...repoEnvelope(caller, to),
|
|
@@ -695,10 +699,16 @@ const repoCalls = (bound) => {
|
|
|
695
699
|
options.from = target.nextSeq;
|
|
696
700
|
options.after = target.internalId;
|
|
697
701
|
}
|
|
702
|
+
const seq = keepsEvents(core.events) ? firstSeq(outbox, options) : void 0;
|
|
703
|
+
const receipt = receiptWrites(kept, repoKept(info, seq), core.repackJobRow);
|
|
698
704
|
const appended = yield* appendEvents(core.events, outbox, [renamed], options);
|
|
705
|
+
const record = seq === void 0 ? moved : {
|
|
706
|
+
...moved,
|
|
707
|
+
renamedSeq: seq
|
|
708
|
+
};
|
|
699
709
|
const written = yield* writeRecord(store, opened.internalId, {
|
|
700
710
|
expect: opened.snapshot.version,
|
|
701
|
-
record
|
|
711
|
+
record,
|
|
702
712
|
put: [...receipt.put, ...appended.put],
|
|
703
713
|
delete: appended.delete,
|
|
704
714
|
jobs: withJobs(appended.jobs, receipt.jobs)
|
|
@@ -709,10 +719,13 @@ const repoCalls = (bound) => {
|
|
|
709
719
|
version: written.version,
|
|
710
720
|
head: appended.head
|
|
711
721
|
};
|
|
712
|
-
yield* afterCommit(takeBackLost(store, opened.internalId,
|
|
722
|
+
yield* afterCommit(takeBackLost(store, opened.internalId, record, lost));
|
|
713
723
|
return yield* alreadyExists(to);
|
|
714
724
|
}
|
|
715
|
-
return info
|
|
725
|
+
return seq === void 0 ? info : {
|
|
726
|
+
...info,
|
|
727
|
+
seq
|
|
728
|
+
};
|
|
716
729
|
}
|
|
717
730
|
return yield* contended();
|
|
718
731
|
}),
|
|
@@ -766,24 +779,27 @@ const repoCalls = (bound) => {
|
|
|
766
779
|
exempt: true,
|
|
767
780
|
confirmed: name
|
|
768
781
|
});
|
|
782
|
+
const deletedAt = yield* Clock$1.currentTimeMillis;
|
|
769
783
|
const deleted = {
|
|
770
784
|
...record,
|
|
771
785
|
deleted: true,
|
|
772
786
|
revision: record.revision + 1,
|
|
773
|
-
changedAt:
|
|
787
|
+
changedAt: deletedAt
|
|
774
788
|
};
|
|
775
789
|
if (keepsEvents(core.events)) deleted.nextSeq = appended.head.next;
|
|
776
790
|
const receipt = receiptWrites(kept, { kind: "done" }, core.repackJobRow);
|
|
777
791
|
if ((yield* writeRecord(store, internalId, {
|
|
778
792
|
expect: snapshot.version,
|
|
793
|
+
by: deletedAt + deleteCommitWithin,
|
|
779
794
|
record: deleted,
|
|
780
795
|
put: [...receipt.put, ...appended.put],
|
|
781
796
|
delete: appended.delete,
|
|
782
797
|
jobs: withJobs([
|
|
783
798
|
core.repackJobRow(),
|
|
799
|
+
pruneJobRow(deletedAt),
|
|
784
800
|
...indexDeleteJobs(core),
|
|
785
801
|
...appended.jobs
|
|
786
|
-
], [...receipt.jobs, ...purgeJobs(core,
|
|
802
|
+
], [...receipt.jobs, ...purgeJobs(core, deletedAt)])
|
|
787
803
|
})) !== void 0) return {};
|
|
788
804
|
}
|
|
789
805
|
return yield* contended();
|
|
@@ -4,6 +4,7 @@ import "../contracts/authorize.mjs";
|
|
|
4
4
|
import { InternalRepoId } from "../contracts/ids.mjs";
|
|
5
5
|
import { GitError } from "../contracts/result.mjs";
|
|
6
6
|
import "./parts.mjs";
|
|
7
|
+
import "./saved-callers.mjs";
|
|
7
8
|
import * as Effect from "effect/Effect";
|
|
8
9
|
import * as Schema from "effect/Schema";
|
|
9
10
|
import * as Context from "effect/Context";
|
|
@@ -52,6 +53,14 @@ declare const SavedCallers_base: Context.ServiceClass<SavedCallers, "@ref0/git/S
|
|
|
52
53
|
* longer `kind` it. A host or store that failed fails, for the try to retry.
|
|
53
54
|
*/
|
|
54
55
|
readonly view: (saved: Saved, repo: InternalRepoId, kind: 'read' | 'fetch') => Effect.Effect<Viewed, GitError>;
|
|
56
|
+
/**
|
|
57
|
+
* The caller who added queue entry `entry`, as its row saved them when it was added: their
|
|
58
|
+
* actor, and the grant that gave them, by its resolver and `id`, never a token. `view` asks
|
|
59
|
+
* it again. `undefined` unless the entry is still in the queue: an ID no queue made, an
|
|
60
|
+
* entry or repo that's gone, and one that merged, failed or was removed name no one, so the
|
|
61
|
+
* work acts for no one, never for its actor alone. A store that failed fails, for a retry.
|
|
62
|
+
*/
|
|
63
|
+
readonly queueEntry: (entry: string) => Effect.Effect<Saved | undefined, GitError>;
|
|
55
64
|
}>;
|
|
56
65
|
/**
|
|
57
66
|
* Work a host's job does later for someone, such as the drop-in's hook deliveries (#1945): who it
|
|
@@ -69,4 +78,13 @@ export declare const save: (actor: string, caller: Caller) => Effect.Effect<{
|
|
|
69
78
|
readonly id: string;
|
|
70
79
|
}, never, SavedCallers>;
|
|
71
80
|
export declare const view: (saved: Saved, repo: InternalRepoId, kind: 'read' | 'fetch') => Effect.Effect<Viewed, GitError, SavedCallers>;
|
|
81
|
+
export declare const queueEntry: (entry: string) => Effect.Effect<{
|
|
82
|
+
readonly kind: "actor";
|
|
83
|
+
readonly actor: string;
|
|
84
|
+
} | {
|
|
85
|
+
readonly kind: "grant";
|
|
86
|
+
readonly actor: string;
|
|
87
|
+
readonly resolver: string;
|
|
88
|
+
readonly id: string;
|
|
89
|
+
} | undefined, GitError, SavedCallers>;
|
|
72
90
|
export {};
|
|
@@ -85,6 +85,16 @@ const askedOf = (saved) => saved.kind === "actor" ? { actor: saved.actor } : {
|
|
|
85
85
|
id: saved.id
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
|
+
/** `saved` as `Saved` keeps it: its actor and its grant, never its token or subject. */
|
|
89
|
+
const keptOf = (saved) => saved.grant === void 0 ? {
|
|
90
|
+
kind: "actor",
|
|
91
|
+
actor: saved.actor
|
|
92
|
+
} : {
|
|
93
|
+
kind: "grant",
|
|
94
|
+
actor: saved.actor,
|
|
95
|
+
resolver: saved.grant.resolver,
|
|
96
|
+
id: saved.grant.id
|
|
97
|
+
};
|
|
88
98
|
/** `use`, with a signal that aborts once its fiber is interrupted, as a grant's `again` reads one. */
|
|
89
99
|
const signalled = (use) => Effect.suspend(() => {
|
|
90
100
|
const interrupted = new AbortController();
|
|
@@ -98,6 +108,7 @@ const signalled = (use) => Effect.suspend(() => {
|
|
|
98
108
|
var SavedCallers = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/SavedCallers")) {};
|
|
99
109
|
const save = (actor, caller) => Effect.flatMap(Effect.service(SavedCallers), (callers) => callers.save(actor, caller));
|
|
100
110
|
const view = (saved, repo, kind) => Effect.flatMap(Effect.service(SavedCallers), (callers) => callers.view(saved, repo, kind));
|
|
111
|
+
const queueEntry = (entry) => Effect.flatMap(Effect.service(SavedCallers), (callers) => callers.queueEntry(entry));
|
|
101
112
|
/** `caller` as `Saved`: its grant by the record Git keeps of it, never the caller's own field. */
|
|
102
113
|
const savedOf = /* @__PURE__ */ Effect.fnUntraced(function* (actor, caller) {
|
|
103
114
|
const grant = yield* grantOf(caller);
|
|
@@ -114,10 +125,12 @@ const savedOf = /* @__PURE__ */ Effect.fnUntraced(function* (actor, caller) {
|
|
|
114
125
|
});
|
|
115
126
|
/**
|
|
116
127
|
* `SavedCallers` over the server's own parts, `needs`, which every call of it runs over: the
|
|
117
|
-
* server's store, never a job try's fenced one
|
|
128
|
+
* server's store, never a job try's fenced one, and a queue entry's adder read by `adderOf`. Core's
|
|
129
|
+
* own jobs call `viewAgainOf` in their try.
|
|
118
130
|
*/
|
|
119
|
-
const savedCallersOf = (needs) => SavedCallers.of({
|
|
131
|
+
const savedCallersOf = (needs, adderOf) => SavedCallers.of({
|
|
120
132
|
save: (actor, caller) => Effect.provideContext(savedOf(actor, caller), needs),
|
|
121
|
-
view: (saved, repo, kind) => Effect.provideContext(signalled((signal) => viewNowOf(askedOf(saved), repo, kind, signal)), needs)
|
|
133
|
+
view: (saved, repo, kind) => Effect.provideContext(signalled((signal) => viewNowOf(askedOf(saved), repo, kind, signal)), needs),
|
|
134
|
+
queueEntry: (entry) => Effect.provideContext(Effect.map(adderOf(entry), (row) => row === void 0 ? void 0 : keptOf(row)), needs)
|
|
122
135
|
});
|
|
123
|
-
export { Saved, SavedCallers, save, savedCallersOf, view, viewAgainOf };
|
|
136
|
+
export { Saved, SavedCallers, queueEntry, save, savedCallersOf, view, viewAgainOf };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Saved, SavedCallers, Viewed, save, view } from "./saved-caller-views.mjs";
|
|
1
|
+
import { Saved, SavedCallers, Viewed, queueEntry, save, view } from "./saved-caller-views.mjs";
|
|
2
2
|
declare namespace saved_callers_public_d_exports {
|
|
3
|
-
export { Saved, SavedCallers, Viewed, save, view };
|
|
3
|
+
export { Saved, SavedCallers, Viewed, queueEntry, save, view };
|
|
4
4
|
}
|
|
5
|
-
export { Saved, SavedCallers, type Viewed, save, saved_callers_public_d_exports, view };
|
|
5
|
+
export { Saved, SavedCallers, type Viewed, queueEntry, save, saved_callers_public_d_exports, view };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
|
-
import { Saved, SavedCallers, save, view } from "./saved-caller-views.mjs";
|
|
2
|
+
import { Saved, SavedCallers, queueEntry, save, view } from "./saved-caller-views.mjs";
|
|
3
3
|
// src/core/saved-callers-public.ts
|
|
4
4
|
var saved_callers_public_exports = /* @__PURE__ */ __exportAll({
|
|
5
5
|
Saved: () => Saved,
|
|
6
6
|
SavedCallers: () => SavedCallers,
|
|
7
|
+
queueEntry: () => queueEntry,
|
|
7
8
|
save: () => save,
|
|
8
9
|
view: () => view
|
|
9
10
|
});
|
|
10
|
-
export { Saved, SavedCallers, save, saved_callers_public_exports, view };
|
|
11
|
+
export { Saved, SavedCallers, queueEntry, save, saved_callers_public_exports, view };
|
package/dist/core/seam.mjs
CHANGED
|
@@ -14,11 +14,11 @@ import * as Context from "effect/Context";
|
|
|
14
14
|
*/
|
|
15
15
|
var ServerSeam = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/ServerSeam")) {};
|
|
16
16
|
const seamByServer = /* @__PURE__ */ new WeakMap();
|
|
17
|
-
/** Called once, by `
|
|
17
|
+
/** Called once for a server, by `openServer` or a test world's face. */
|
|
18
18
|
const attachParts = (server, seam) => {
|
|
19
19
|
seamByServer.set(server, seam);
|
|
20
20
|
};
|
|
21
|
-
/**
|
|
21
|
+
/** A server's seam: `undefined` for one with none attached. */
|
|
22
22
|
const seamOf = (server) => seamByServer.get(server);
|
|
23
23
|
/** `seam`'s parts but its needs and bound, each waiting for the build: a route's, made before it. */
|
|
24
24
|
const lazyParts = (seam) => {
|
package/dist/core/view.d.mts
CHANGED
|
@@ -48,6 +48,12 @@ export declare class SealedObjects {
|
|
|
48
48
|
* `input.row` names, and `fallback` where none covers `at` or the objects keep none.
|
|
49
49
|
*/
|
|
50
50
|
static visibleWhole(sealed: SealedObjects, _whole: WholeRepo, at: Listed, input: VisibleInput, fallback: () => VisibleSet): VisibleSet;
|
|
51
|
+
/**
|
|
52
|
+
* Which of `input.roots` `input.tips` reach at `at`, for one of the readers `WholeRepo` names: the
|
|
53
|
+
* index's `rootsReached` where it can say, else a walk of the commits from the tips to their end,
|
|
54
|
+
* refused past its bound. Either costs the same whatever roots the tips don't reach.
|
|
55
|
+
*/
|
|
56
|
+
static rootsReached(sealed: SealedObjects, _whole: WholeRepo, at: Listed, input: VisibleInput): Effect.Effect<ReadonlySet<Oid>, GitError>;
|
|
51
57
|
/**
|
|
52
58
|
* The objects one caller's `set` holds, for the view `WholeRepo` names: `undefined` for objects
|
|
53
59
|
* sealed with no index, which a server with `access` never has.
|
package/dist/core/view.mjs
CHANGED
|
@@ -6,12 +6,12 @@ import { answeredBy, effectWithin, objectsFace, scopedReader } from "../storage/
|
|
|
6
6
|
import { callScope, inCallScope } from "../store/call-count.mjs";
|
|
7
7
|
import { askingOnLost } from "../storage/index-visible.mjs";
|
|
8
8
|
import { indexRowKey } from "../storage/layout.mjs";
|
|
9
|
-
import { withPushed } from "../storage/visible.mjs";
|
|
9
|
+
import { walkedRoots, withPushed } from "../storage/visible.mjs";
|
|
10
10
|
import { WholeRepo, storedPeel, storesPeel, wholeRefs } from "../store/ref-rows.mjs";
|
|
11
|
-
import { openRepo, repoAccess } from "./access.mjs";
|
|
11
|
+
import { acting, openRepo, repoAccess } from "./access.mjs";
|
|
12
12
|
import { ownWriter, ownWritesOf } from "./own-writes.mjs";
|
|
13
|
-
import { AudienceMemo, refViewIn, viewedIn } from "./ref-view.mjs";
|
|
14
|
-
import { CoreParts, ObjectsParts,
|
|
13
|
+
import { AudienceMemo, anyOwned, refViewIn, viewedIn } from "./ref-view.mjs";
|
|
14
|
+
import { CoreParts, ObjectsParts, coreContext } from "./parts.mjs";
|
|
15
15
|
import * as Effect from "effect/Effect";
|
|
16
16
|
import * as Predicate from "effect/Predicate";
|
|
17
17
|
import * as Context from "effect/Context";
|
|
@@ -90,6 +90,17 @@ var SealedObjects = class SealedObjects {
|
|
|
90
90
|
return sealed.#indexed?.visible(at, input, fallback) ?? fallback();
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
|
+
* Which of `input.roots` `input.tips` reach at `at`, for one of the readers `WholeRepo` names: the
|
|
94
|
+
* index's `rootsReached` where it can say, else a walk of the commits from the tips to their end,
|
|
95
|
+
* refused past its bound. Either costs the same whatever roots the tips don't reach.
|
|
96
|
+
*/
|
|
97
|
+
static rootsReached(sealed, _whole, at, input) {
|
|
98
|
+
const walked = Effect.suspend(() => walkedRoots(objectsFace(sealed.#objects), at, input));
|
|
99
|
+
const fast = sealed.#indexed?.rootsReached;
|
|
100
|
+
if (fast === void 0) return walked;
|
|
101
|
+
return Effect.flatMap(fast(at, input), (reached) => reached === void 0 ? walked : Effect.succeed(reached));
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
93
104
|
* The objects one caller's `set` holds, for the view `WholeRepo` names: `undefined` for objects
|
|
94
105
|
* sealed with no index, which a server with `access` never has.
|
|
95
106
|
*/
|
|
@@ -167,12 +178,25 @@ const objectsOverViews = { read: ({ view, at }) => {
|
|
|
167
178
|
const read = viewObjects.get(view);
|
|
168
179
|
return read === void 0 ? Effect.die(/* @__PURE__ */ new TypeError("Objects.read takes a view that View.open made")) : read(at);
|
|
169
180
|
} };
|
|
181
|
+
/** Each view's roots, by the read they follow: what `rootsSeen` answers, kept as `viewObjects` are. */
|
|
182
|
+
const viewRoots = /* @__PURE__ */ new WeakMap();
|
|
183
|
+
/**
|
|
184
|
+
* Which of `at.roots` `view`'s caller may be told, as a v0 listing's `shallow` lines tell them:
|
|
185
|
+
* every one where the view isn't narrowed, as for a caller who reads every pattern, or on a server
|
|
186
|
+
* with no `access`, with no read; else those the commits `at.tips` reach, by the index's root
|
|
187
|
+
* positions where it covers `at.listed`, or else a walk of those commits to their end, refused
|
|
188
|
+
* past its bound. Neither's cost turns on a root they don't reach (#2462).
|
|
189
|
+
*/
|
|
190
|
+
const rootsSeen = (view, at) => {
|
|
191
|
+
const roots = viewRoots.get(view);
|
|
192
|
+
return roots === void 0 ? Effect.die(/* @__PURE__ */ new TypeError("rootsSeen takes a view that View.open made")) : roots(at);
|
|
193
|
+
};
|
|
170
194
|
/**
|
|
171
195
|
* `refView`, with the refs under a prefix `owner` owns seen too: the merge queue's publish, which
|
|
172
|
-
* runs as the entry's caller, deletes its candidate and moves its target to the candidate's commit
|
|
196
|
+
* runs as the entry's caller, deletes its candidate and moves its target to the candidate's commit,
|
|
197
|
+
* and the drop-in's reads of its merge fences, which even a whole view leaves out, as `owned`.
|
|
173
198
|
*/
|
|
174
199
|
const ownersView = (refView, table, owner) => {
|
|
175
|
-
if (refView.whole) return refView;
|
|
176
200
|
const owns = (ref) => gitsOwnMove(table, owner, ref);
|
|
177
201
|
return {
|
|
178
202
|
...refView,
|
|
@@ -201,10 +225,19 @@ const viewOf = /* @__PURE__ */ Effect.fnUntraced(function* (caller, resolved, ow
|
|
|
201
225
|
refs: Effect.fnUntraced(function* (rows) {
|
|
202
226
|
const all = yield* wholeRefs(viewWhole, rows);
|
|
203
227
|
const seen = yield* refView;
|
|
204
|
-
if (seen.whole) return all;
|
|
228
|
+
if (seen.whole && !anyOwned(core.hiddenRefs())) return all;
|
|
205
229
|
return new Map([...all].filter(([name]) => seen.sees(name)));
|
|
206
230
|
})
|
|
207
231
|
};
|
|
232
|
+
viewRoots.set(view, (at) => Effect.provideContext(Effect.gen(function* () {
|
|
233
|
+
if (at.roots.size === 0 || !(yield* narrowed)) return at.roots;
|
|
234
|
+
const input = {
|
|
235
|
+
tips: at.tips,
|
|
236
|
+
row: at.index,
|
|
237
|
+
roots: at.roots
|
|
238
|
+
};
|
|
239
|
+
return yield* SealedObjects.rootsReached(sealed, viewWhole, at.listed, input);
|
|
240
|
+
}), needs));
|
|
208
241
|
viewObjects.set(view, (at) => Effect.provideContext(Effect.gen(function* () {
|
|
209
242
|
if (!(yield* narrowed)) return whole;
|
|
210
243
|
const tags = new Map(at.refRows?.filter((row) => storesPeel(row.id)).map((row) => [row.id, row]));
|
|
@@ -282,7 +315,7 @@ const viewOf = /* @__PURE__ */ Effect.fnUntraced(function* (caller, resolved, ow
|
|
|
282
315
|
return view;
|
|
283
316
|
});
|
|
284
317
|
/** The repo `operation` names, opened as `openRepo` opens it, as `caller` sees it. */
|
|
285
|
-
const openView = (caller, operation, reads = [], internalId) => Effect.flatMap(openRepo(caller, operation, reads, internalId), (resolved) => viewOf(caller, resolved));
|
|
318
|
+
const openView = (caller, operation, reads = [], internalId, owner) => Effect.flatMap(openRepo(caller, operation, reads, internalId), (resolved) => viewOf(caller, resolved, owner));
|
|
286
319
|
/** How a caller who may not read a fork's parent is refused: its fallback then reaches nothing. */
|
|
287
320
|
const unread = /* @__PURE__ */ new Set([
|
|
288
321
|
"NOT_FOUND",
|
|
@@ -318,14 +351,14 @@ const parentTips = /* @__PURE__ */ Effect.fnUntraced(function* (caller, resolved
|
|
|
318
351
|
var View = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/View")) {};
|
|
319
352
|
const open = (input) => Effect.flatMap(Effect.service(View), (view) => view.open(input));
|
|
320
353
|
/** `View` over `needs`, each open deciding for its `by`: host code's when `by` is `Git.host`. */
|
|
321
|
-
const viewOver = (needs) => ({ open: ({ repo, by, reads = [] }) => {
|
|
354
|
+
const viewOver = (needs) => ({ open: ({ repo, by, reads = [], owner }) => {
|
|
322
355
|
const opened = Predicate.isString(repo) ? openView(by, {
|
|
323
356
|
kind: "read",
|
|
324
357
|
repo
|
|
325
|
-
}, reads) : openView(by, {
|
|
358
|
+
}, reads, void 0, owner) : openView(by, {
|
|
326
359
|
kind: "read",
|
|
327
360
|
repo: repo.name
|
|
328
|
-
}, reads, repo.internalId);
|
|
361
|
+
}, reads, repo.internalId, owner);
|
|
329
362
|
return Effect.provideContext(acting(by, opened), needs);
|
|
330
363
|
} });
|
|
331
|
-
export { SealedObjects, View, objectsFollowRefs, objectsOverViews, open, openView, viewOf, viewOver };
|
|
364
|
+
export { SealedObjects, View, objectsFollowRefs, objectsOverViews, open, openView, rootsSeen, viewOf, viewOver };
|
package/dist/core/work.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { keepsEvents } from "../contracts/events.mjs";
|
|
2
|
+
import { check } from "../contracts/authorize.mjs";
|
|
2
3
|
import { badCursor } from "../engine/reads.mjs";
|
|
3
4
|
import { utf8 } from "../protocol/bytes/text.mjs";
|
|
4
5
|
import { afterCommit } from "../store/call-count.mjs";
|
|
5
6
|
import { listBound } from "../store/cursor-seal.mjs";
|
|
6
7
|
import { storeCall } from "../store/errors.mjs";
|
|
7
8
|
import { keptKey } from "../store/records.mjs";
|
|
9
|
+
import { readRecord } from "../store/repo-record.mjs";
|
|
8
10
|
import { newChangeId, repoScope } from "../store/scopes.mjs";
|
|
9
11
|
import { callerFor, contended, openRepo, repoAccess } from "./access.mjs";
|
|
10
12
|
import { isDeliverJob, skipFailed } from "./events/deliver.mjs";
|
|
@@ -77,6 +79,37 @@ const keepAnswer = /* @__PURE__ */ Effect.fnUntraced(function* (internalId, kept
|
|
|
77
79
|
tries: 5
|
|
78
80
|
}));
|
|
79
81
|
});
|
|
82
|
+
/**
|
|
83
|
+
* A page of the jobs in `internalId`'s scope, as `list` and `listById` answer them, those `shown`
|
|
84
|
+
* keeps. With `access`, a cursor is sealed for `list`'s page of the repo in its state: the store's
|
|
85
|
+
* names the job its page ends on, which may be one the caller doesn't see. A page is left short
|
|
86
|
+
* rather than read on, so its length is the store's page less the jobs the caller can't see;
|
|
87
|
+
* `next` still goes on where the store's page ended.
|
|
88
|
+
*/
|
|
89
|
+
const jobsPage = /* @__PURE__ */ Effect.fnUntraced(function* (internalId, list, input, shown) {
|
|
90
|
+
const core = yield* CoreParts;
|
|
91
|
+
const sealed = core.access !== void 0;
|
|
92
|
+
const bound = listBound(list, internalId, input.state ?? "");
|
|
93
|
+
const sent = input.page?.after;
|
|
94
|
+
const opens = sent === void 0 || !sealed ? sent : yield* core.cursors.open(bound, sent);
|
|
95
|
+
const after = sealed && opens !== void 0 ? storeCursor(opens) : opens;
|
|
96
|
+
if (sent !== void 0 && after === void 0) return yield* badCursor();
|
|
97
|
+
const request = {};
|
|
98
|
+
if (input.state !== void 0) request.state = input.state;
|
|
99
|
+
if (input.page !== void 0) {
|
|
100
|
+
const page = { ...input.page };
|
|
101
|
+
if (after !== void 0) page.after = after;
|
|
102
|
+
request.page = page;
|
|
103
|
+
}
|
|
104
|
+
const { jobs } = yield* QueueParts;
|
|
105
|
+
const listed = yield* storeCall(() => jobs.list(repoScope(internalId), request));
|
|
106
|
+
const items = listed.items.filter(shown);
|
|
107
|
+
if (listed.next === void 0) return { items };
|
|
108
|
+
return {
|
|
109
|
+
items,
|
|
110
|
+
next: sealed ? yield* core.cursors.seal(bound, yield* workCursorText(listed.next)) : listed.next
|
|
111
|
+
};
|
|
112
|
+
});
|
|
80
113
|
/** `work`: a repo's jobs, over the queue's own calls, once `authorize` lets the caller. */
|
|
81
114
|
const workCalls = (bound) => {
|
|
82
115
|
const callerOf = callerFor(bound);
|
|
@@ -129,31 +162,23 @@ const workCalls = (bound) => {
|
|
|
129
162
|
kind: "work.list",
|
|
130
163
|
repo
|
|
131
164
|
}, [], input.internalId);
|
|
132
|
-
const { internalId } = opened;
|
|
133
165
|
const repoOf = repoAccess(opened);
|
|
134
166
|
const refView = yield* refViewIn(caller, repoOf);
|
|
167
|
+
return yield* jobsPage(opened.internalId, "work.list", input, (item) => seesJob(refView, item));
|
|
168
|
+
}),
|
|
169
|
+
listById: Effect.fnUntraced(function* (internalId, input) {
|
|
170
|
+
const caller = callerOf(input);
|
|
171
|
+
yield* check({
|
|
172
|
+
caller,
|
|
173
|
+
operation: {
|
|
174
|
+
kind: "work.listById",
|
|
175
|
+
internalId
|
|
176
|
+
}
|
|
177
|
+
});
|
|
135
178
|
const core = yield* CoreParts;
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const opens = sent === void 0 || !sealed ? sent : yield* core.cursors.open(bound, sent);
|
|
140
|
-
const after = sealed && opens !== void 0 ? storeCursor(opens) : opens;
|
|
141
|
-
if (sent !== void 0 && after === void 0) return yield* badCursor();
|
|
142
|
-
const request = {};
|
|
143
|
-
if (input.state !== void 0) request.state = input.state;
|
|
144
|
-
if (input.page !== void 0) {
|
|
145
|
-
const page = { ...input.page };
|
|
146
|
-
if (after !== void 0) page.after = after;
|
|
147
|
-
request.page = page;
|
|
148
|
-
}
|
|
149
|
-
const { jobs } = yield* QueueParts;
|
|
150
|
-
const listed = yield* storeCall(() => jobs.list(repoScope(internalId), request));
|
|
151
|
-
const items = listed.items.filter((item) => seesJob(refView, item));
|
|
152
|
-
if (listed.next === void 0) return { items };
|
|
153
|
-
return {
|
|
154
|
-
items,
|
|
155
|
-
next: sealed ? yield* core.cursors.seal(bound, yield* workCursorText(listed.next)) : listed.next
|
|
156
|
-
};
|
|
179
|
+
const { record } = yield* readRecord(core.store, internalId);
|
|
180
|
+
if (record === void 0) return yield* fail("NOT_FOUND", `No repo '${internalId}'`);
|
|
181
|
+
return yield* jobsPage(internalId, "work.listById", input, () => true);
|
|
157
182
|
}),
|
|
158
183
|
retry: write("work.retry"),
|
|
159
184
|
discard: write("work.discard")
|
package/dist/effect.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { EffectCalls, GitCaller, GitStore } from "./contracts/services.mjs";
|
|
2
2
|
import { IndexCalls, IndexReachInput, IndexReached, IndexStatus, IndexTip, IndexTry, IndexTryInput } from "./contracts/objects.mjs";
|
|
3
|
+
import { Actor } from "./contracts/actors.mjs";
|
|
4
|
+
import { RepoName } from "./contracts/ids.mjs";
|
|
3
5
|
import { CallAllowance, CallBudget, CallBudgetOptions } from "./store/call-count.mjs";
|
|
4
6
|
import { commitCallsMost, storeCall } from "./store/errors.mjs";
|
|
5
7
|
import { bucketCall } from "./storage/calls.mjs";
|
|
@@ -13,4 +15,4 @@ import { ReposApiGroup } from "./rest/repos.mjs";
|
|
|
13
15
|
import { TokensApiGroup } from "./rest/tokens.mjs";
|
|
14
16
|
import { WorkApiGroup } from "./rest/work.mjs";
|
|
15
17
|
import { SeamAuthorizeInput, TokenRevokeCheck } from "./core/seam.mjs";
|
|
16
|
-
export { type CallAllowance, CallBudget, type CallBudgetOptions, type EffectCalls, GitCaller, GitCallerMiddleware, GitErrors, GitRestApi, GitRestHandlers, GitRestServices, GitStore, type IndexCalls, type IndexReachInput, type IndexReached, type IndexStatus, type IndexTip, type IndexTry, type IndexTryInput, MeApiGroup, RefsApiGroup, ReposApiGroup, type RestServerSeam, type SeamAuthorizeInput, type TokenRevokeCheck, TokensApiGroup, WorkApiGroup, bucketCall, commitCallsMost, storeCall };
|
|
18
|
+
export { Actor, type CallAllowance, CallBudget, type CallBudgetOptions, type EffectCalls, GitCaller, GitCallerMiddleware, GitErrors, GitRestApi, GitRestHandlers, GitRestServices, GitStore, type IndexCalls, type IndexReachInput, type IndexReached, type IndexStatus, type IndexTip, type IndexTry, type IndexTryInput, MeApiGroup, RefsApiGroup, RepoName, ReposApiGroup, type RestServerSeam, type SeamAuthorizeInput, type TokenRevokeCheck, TokensApiGroup, WorkApiGroup, bucketCall, commitCallsMost, storeCall };
|