@ref0/git 0.12.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 +3 -3
- 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 +11 -1
- package/dist/contracts/git.d.mts +18 -7
- 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 +23 -18
- package/dist/contracts/result.mjs +17 -4
- 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 +79 -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.mjs +27 -5
- package/dist/core/ancestry.d.mts +9 -0
- package/dist/core/ancestry.mjs +6 -6
- package/dist/core/asked.mjs +42 -4
- package/dist/core/call-names.mjs +1 -0
- package/dist/core/call-services.mjs +2 -1
- package/dist/core/events/deliver.mjs +10 -2
- package/dist/core/forks.mjs +3 -3
- package/dist/core/imports.mjs +147 -9
- 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/parts.d.mts +6 -1
- 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 +98 -26
- package/dist/core/receipts.mjs +26 -10
- package/dist/core/ref-view.mjs +59 -5
- package/dist/core/refs.mjs +13 -8
- package/dist/core/repack.mjs +11 -8
- package/dist/core/repo-info.mjs +16 -9
- package/dist/core/repos.mjs +30 -14
- 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 +3 -3
- package/dist/extend.mjs +2 -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 +114 -56
- 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/objects.d.mts +6 -0
- package/dist/lfs/objects.mjs +68 -41
- 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/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 +31 -23
- 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 +273 -240
- 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 +127 -115
- package/dist/rest/forks.d.mts +121 -97
- 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 +2 -1
- 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 +282 -226
- package/dist/rest/refs.d.mts +205 -176
- package/dist/rest/repos.d.mts +108 -80
- package/dist/rest/tags.d.mts +24 -12
- package/dist/rest/tokens.d.mts +235 -211
- package/dist/rest/topics.d.mts +53 -33
- package/dist/rest/trees.d.mts +105 -89
- 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 +3 -3
- 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 +133 -212
- 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 +28 -4
- package/dist/storage/pack-reads.mjs +8 -8
- 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-walk.mjs +54 -16
- package/dist/storage/prune.mjs +629 -196
- package/dist/storage/push-uploads.mjs +36 -12
- package/dist/storage/quarantine.mjs +9 -9
- 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 +9 -7
- package/dist/store/repo-record.mjs +102 -19
- 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 +55 -43
- package/dist/sync/http.mjs +36 -1
- package/dist/sync/import.mjs +1 -0
- 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 +210 -137
- package/dist/sync/smart-http.mjs +4 -2
- package/dist/sync/step.mjs +25 -5
- package/dist/sync/tries.mjs +45 -14
- package/dist/sync.d.mts +2 -2
- 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 -5
- 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/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
|
@@ -8,7 +8,7 @@ import { heldAdd, heldStore } from "../store/repo-record.mjs";
|
|
|
8
8
|
import { keptKey } from "../store/records.mjs";
|
|
9
9
|
import { refRowBytes } from "../store/ref-rows.mjs";
|
|
10
10
|
import { collections, repoScope } from "../store/scopes.mjs";
|
|
11
|
-
import { callerFor, contended, keyedRecord, openRepo, refIndexJobs } from "./access.mjs";
|
|
11
|
+
import { acting, callerFor, contended, keyedRecord, openRepo, refIndexJobs } from "./access.mjs";
|
|
12
12
|
import { open } from "./view.mjs";
|
|
13
13
|
import { isRefName } from "./names.mjs";
|
|
14
14
|
import { keyedPush, push } from "./push.mjs";
|
|
@@ -17,10 +17,11 @@ import { gitsOwnRefs, hostLists } from "../protocol/wire/lines.mjs";
|
|
|
17
17
|
import { notFailed } from "./events/deliver.mjs";
|
|
18
18
|
import { refsAnswer } from "./receipts.mjs";
|
|
19
19
|
import { plainClass, refIndexId } from "./ref-index.mjs";
|
|
20
|
+
import { ownedSpans } from "./ref-view.mjs";
|
|
20
21
|
import { pushRulesFor } from "./rules/check.mjs";
|
|
21
22
|
import { refProtection } from "./rules/protect.mjs";
|
|
22
23
|
import { fail } from "../contracts/result.mjs";
|
|
23
|
-
import { CoreParts, ObjectsParts
|
|
24
|
+
import { CoreParts, ObjectsParts } from "./parts.mjs";
|
|
24
25
|
import { bypassKinds, hostAuthorize } from "../auth/authorize.mjs";
|
|
25
26
|
import { Authorize, check } from "../contracts/authorize.mjs";
|
|
26
27
|
import * as Clock$1 from "effect/Clock";
|
|
@@ -221,7 +222,8 @@ const refCalls = (bound) => {
|
|
|
221
222
|
const view = yield* open({
|
|
222
223
|
repo: pinnedOf(repo, input),
|
|
223
224
|
by: callerOf(input),
|
|
224
|
-
reads: [read]
|
|
225
|
+
reads: [read],
|
|
226
|
+
owner: input.owner
|
|
225
227
|
});
|
|
226
228
|
const oid = (yield* view.refs(view.resolved.snapshot.results[1] ?? [])).get(ref);
|
|
227
229
|
if (oid === void 0) return yield* fail("NOT_FOUND", `No ref '${ref}' in '${repo}'`);
|
|
@@ -328,7 +330,7 @@ const refCalls = (bound) => {
|
|
|
328
330
|
name,
|
|
329
331
|
oid
|
|
330
332
|
}] : []);
|
|
331
|
-
if (sealed) {
|
|
333
|
+
if (sealed || ownedSpans(hidden, asked ?? "").length > 0) {
|
|
332
334
|
const view = yield* open({
|
|
333
335
|
repo: pinnedOf(repo, input),
|
|
334
336
|
by: callerOf(input)
|
|
@@ -355,7 +357,8 @@ const refCalls = (bound) => {
|
|
|
355
357
|
limit,
|
|
356
358
|
listed,
|
|
357
359
|
bound,
|
|
358
|
-
runs
|
|
360
|
+
runs,
|
|
361
|
+
sealed
|
|
359
362
|
});
|
|
360
363
|
}
|
|
361
364
|
const view = yield* open({
|
|
@@ -386,7 +389,8 @@ const refCalls = (bound) => {
|
|
|
386
389
|
*/
|
|
387
390
|
const seenPage = Effect.fnUntraced(function* (view, page) {
|
|
388
391
|
const core = yield* CoreParts;
|
|
389
|
-
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);
|
|
390
394
|
const scope = repoScope(view.resolved.internalId);
|
|
391
395
|
const items = [];
|
|
392
396
|
let after = page.after;
|
|
@@ -456,8 +460,8 @@ const refCalls = (bound) => {
|
|
|
456
460
|
const shown = items.slice(0, limit);
|
|
457
461
|
const end = shown.at(-1);
|
|
458
462
|
const listing = { items: shown };
|
|
459
|
-
if (stopped !== void 0) listing.next = yield*
|
|
460
|
-
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);
|
|
461
465
|
return listing;
|
|
462
466
|
});
|
|
463
467
|
/**
|
|
@@ -483,6 +487,7 @@ const refCalls = (bound) => {
|
|
|
483
487
|
if (input.signal !== void 0) request.signal = input.signal;
|
|
484
488
|
if (input.internalId !== void 0) request.internalId = input.internalId;
|
|
485
489
|
if (input.onBehalfOf !== void 0) request.onBehalfOf = true;
|
|
490
|
+
if (input.owner !== void 0) request.as = input.owner;
|
|
486
491
|
const edits = input.updates.map(({ ref, from, to }) => [
|
|
487
492
|
ref,
|
|
488
493
|
from,
|
package/dist/core/repack.mjs
CHANGED
|
@@ -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) {
|
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();
|
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 };
|