@ref0/git 0.25.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contracts/objects.d.mts +10 -1
- package/dist/contracts/rules.d.mts +11 -10
- package/dist/core/push.mjs +20 -4
- package/dist/core/rules/commit-changes.mjs +113 -45
- package/dist/protocol/bytes/buffers.mjs +26 -1
- package/dist/protocol/bytes/inflate.d.mts +11 -6
- package/dist/protocol/bytes/inflate.mjs +184 -119
- package/dist/protocol/bytes/zlib-ng/LICENSE.md +19 -0
- package/dist/protocol/bytes/zlib-ng/README.md +105 -0
- package/dist/protocol/bytes/zlib-ng/bundled.d.mts +5 -0
- package/dist/protocol/bytes/zlib-ng/bundled.mjs +8 -0
- package/dist/protocol/bytes/zlib-ng/compile.d.mts +8 -0
- package/dist/protocol/bytes/zlib-ng/compile.mjs +18 -0
- package/dist/protocol/bytes/zlib-ng/embedded.mjs +4 -0
- package/dist/protocol/bytes/zlib-ng/instance.d.mts +1 -0
- package/dist/protocol/bytes/zlib-ng/instance.mjs +105 -0
- package/dist/protocol/bytes/zlib-ng/zlib-ng.wasm +0 -0
- package/dist/protocol/packs/reader.mjs +35 -30
- package/dist/storage/budget.d.mts +1 -0
- package/dist/storage/budget.mjs +1 -15
- package/dist/storage/held-types.mjs +13 -4
- package/dist/storage/index-bitmaps.mjs +263 -16
- package/dist/storage/index-build.mjs +28 -9
- package/dist/storage/loose.mjs +2 -1
- package/dist/storage/memory-budget.d.mts +1 -0
- package/dist/storage/merge-most.mjs +2 -1
- package/dist/storage/pack-reads.mjs +1 -1
- package/dist/storage/pack-receive.mjs +3 -1
- package/dist/storage/packs-memory.mjs +2 -1
- package/dist/storage/packs.mjs +2 -1
- package/package.json +12 -3
|
@@ -209,13 +209,22 @@ export interface ReceiveInput extends CallInput {
|
|
|
209
209
|
* `too-large`. Sync's import alone sets it.
|
|
210
210
|
*/
|
|
211
211
|
readonly cutMost?: number;
|
|
212
|
+
/**
|
|
213
|
+
* Whether the repo held any loose object rows at `listed.version`, as core's opening snapshot
|
|
214
|
+
* read `stats/loose`. When `false`, the receive skips reading object rows upfront and checks
|
|
215
|
+
* listed packs directly, falling back to object rows only for IDs still unresolved after listed
|
|
216
|
+
* packs and before unlisted-pack discovery (so a stale `false` costs at most extra reads on a
|
|
217
|
+
* miss); when `true` or left out, it reads rows upfront as usual. A host whose own objects
|
|
218
|
+
* ignore it keeps reading rows.
|
|
219
|
+
*/
|
|
220
|
+
readonly hasLooseRows?: boolean;
|
|
212
221
|
}
|
|
213
222
|
/**
|
|
214
223
|
* A pack to stage for its receive in steps, an import segment's or a push upload's: its bytes, as
|
|
215
224
|
* `receive` takes them, and the boundary, needs and cut's most, or the shallow lines, its steps
|
|
216
225
|
* check as `ReceiveInput` says. Sync's import and a push upload's job stage one.
|
|
217
226
|
*/
|
|
218
|
-
export type StageInput = Omit<ReceiveInput, 'partial'>;
|
|
227
|
+
export type StageInput = Omit<ReceiveInput, 'partial' | 'hasLooseRows'>;
|
|
219
228
|
/** A segment's pack staged: its ID, which each step and the landing name, and its bytes. */
|
|
220
229
|
export interface Staged {
|
|
221
230
|
readonly pack: string;
|
|
@@ -68,16 +68,17 @@ export type PushContext = Acting & {
|
|
|
68
68
|
*/
|
|
69
69
|
readonly changes: Effect.Effect<readonly TreeChange[], GitError>;
|
|
70
70
|
/**
|
|
71
|
-
* The push's changes commit by commit, read only as it's pulled, in the push's call scope: each
|
|
72
|
-
* in each the paths whose entry differs from every parent's that the
|
|
73
|
-
* ref's old tip, names only, one commit at a time, a commit with none
|
|
74
|
-
* moved onto a commit the push doesn't bring, and a write through the
|
|
75
|
-
*
|
|
76
|
-
* as a merge commit's other parent, is listed as its own. `Rules.files` also
|
|
77
|
-
* the tip of a ref it covers, and, on a refusal, one on the first-parent chain
|
|
78
|
-
* tip or of a default branch it covers, 1,000 commits back (Q732, Q734). A push
|
|
79
|
-
* lists its commits once, for each ref. A walk past its allotment fails with the
|
|
80
|
-
* refusal,
|
|
71
|
+
* The push's changes commit by commit, read only as it's pulled, in the push's call scope: each
|
|
72
|
+
* commit the push brings, and in each the paths whose entry differs from every parent's that the
|
|
73
|
+
* push brings or that's the ref's old tip, names only, one commit at a time, a commit with none
|
|
74
|
+
* counted as a root. A ref moved onto a commit the push doesn't bring, and a write through the
|
|
75
|
+
* API, list each commit the move adds to the ref the same way, so what one takes from a commit no
|
|
76
|
+
* rule saw, such as a merge commit's other parent, is listed as its own. `Rules.files` also
|
|
77
|
+
* counts a parent at the tip of a ref it covers, and, on a refusal, one on the first-parent chain
|
|
78
|
+
* of the ref's old tip or of a default branch it covers, 1,000 commits back (Q732, Q734). A push
|
|
79
|
+
* of several refs lists its commits once, for each ref. A walk past its allotment fails with the
|
|
80
|
+
* allotment's refusal, and a move's past 10,000 commits it adds, a merge counted once for each
|
|
81
|
+
* parent, with `walk-limit`: `Rules.files` answers each as its own.
|
|
81
82
|
*/
|
|
82
83
|
readonly commitChanges: Stream.Stream<CommitChange, GitError>;
|
|
83
84
|
};
|
package/dist/core/push.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { fail, gitError } from "../contracts/result.mjs";
|
|
|
2
2
|
import { openTreeBytes } from "../storage/budget.mjs";
|
|
3
3
|
import { scopedReceive, walkObjects } from "../storage/calls.mjs";
|
|
4
4
|
import { isUnindexedRead } from "../storage/index-visible.mjs";
|
|
5
|
+
import { walkedVisible } from "../storage/visible.mjs";
|
|
5
6
|
import { openTreesRefusal } from "../storage/push-allotment.mjs";
|
|
6
7
|
import { isLoose } from "../storage/loose.mjs";
|
|
7
8
|
import { listedIds } from "../storage/listed-ids.mjs";
|
|
@@ -35,7 +36,7 @@ import { liveReservations, reservedTarget } from "../store/reservations.mjs";
|
|
|
35
36
|
import { settleName } from "../store/settle.mjs";
|
|
36
37
|
import { collections, looseKey, newChangeId, prunedKey, pushedKey, pushedUnder, reachedKey, repoRootsKey, repoScope } from "../store/scopes.mjs";
|
|
37
38
|
import { headOf, indexJobs, openKeyed, openRepo, refIndexJobs, repoAccess } from "./access.mjs";
|
|
38
|
-
import { kindsOf } from "./ancestry.mjs";
|
|
39
|
+
import { ancestryLimit, kindsOf } from "./ancestry.mjs";
|
|
39
40
|
import { isRefName } from "./names.mjs";
|
|
40
41
|
import { runHookGroups } from "./hooks/groups.mjs";
|
|
41
42
|
import { Changes } from "./changes.mjs";
|
|
@@ -69,6 +70,11 @@ import * as Equal from "effect/Equal";
|
|
|
69
70
|
* name it can't write is `unseenRef`'s, the same whatever is there.
|
|
70
71
|
*/
|
|
71
72
|
const pushWhole = /* @__PURE__ */ WholeRepo.mint();
|
|
73
|
+
/** How far a walk of what a ref's old tip reaches goes, past which a move's walk is refused. */
|
|
74
|
+
const judgedWalk = {
|
|
75
|
+
most: ancestryLimit,
|
|
76
|
+
commits: true
|
|
77
|
+
};
|
|
72
78
|
const packsRead = { collection: collections.packs };
|
|
73
79
|
const refsRead = { collection: collections.refs };
|
|
74
80
|
const timesRead = { collection: collections.stats };
|
|
@@ -816,7 +822,7 @@ const unindexedPush = () => gitError("RESOURCE_EXHAUSTED", "This push can't be c
|
|
|
816
822
|
/** `error`, a read by ID the index can't close yet told as the push's own. */
|
|
817
823
|
const asPushCheck = (error) => isUnindexedRead(error) ? unindexedPush() : error;
|
|
818
824
|
/** The request's pack into its quarantine, or `undefined` for a push with none. */
|
|
819
|
-
const receive = (objects, listed, request) => {
|
|
825
|
+
const receive = (objects, listed, request, hasLooseRows) => {
|
|
820
826
|
const { pack, shallow, signal } = request;
|
|
821
827
|
if (pack === void 0) return Effect.succeed({
|
|
822
828
|
received: void 0,
|
|
@@ -832,7 +838,8 @@ const receive = (objects, listed, request) => {
|
|
|
832
838
|
});
|
|
833
839
|
const input = {
|
|
834
840
|
pack: pack.bytes,
|
|
835
|
-
objects: pack.objects
|
|
841
|
+
objects: pack.objects,
|
|
842
|
+
hasLooseRows
|
|
836
843
|
};
|
|
837
844
|
if (pack.length !== void 0) input.length = pack.length;
|
|
838
845
|
if (pack.atMost !== void 0) input.atMost = pack.atMost;
|
|
@@ -908,7 +915,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, hasLooseRows, r
|
|
|
908
915
|
const { received, rooted } = yield* receive(yield* read({
|
|
909
916
|
view,
|
|
910
917
|
at: seen
|
|
911
|
-
}), listed, request).pipe(Effect.provideService(HeldBy, heldUntil(heldAt, fetchLimits)), Effect.tapError((error) => isAwaitingUpkeep(error) ? bestEffort(ensureRepack(core, core.jobs, listed.repo, fetchLimits)) : Effect.void), Effect.mapError(asPushCheck));
|
|
918
|
+
}), listed, request, hasLooseRows).pipe(Effect.provideService(HeldBy, heldUntil(heldAt, fetchLimits)), Effect.tapError((error) => isAwaitingUpkeep(error) ? bestEffort(ensureRepack(core, core.jobs, listed.repo, fetchLimits)) : Effect.void), Effect.mapError(asPushCheck));
|
|
912
919
|
const ownedPack = ownPack(request, received);
|
|
913
920
|
let listing = false;
|
|
914
921
|
if (ownedPack !== void 0) yield* Effect.addFinalizer((exit) => listing || Exit.hasInterrupts(exit) ? Effect.void : Effect.flatMap(Clock.currentTimeMillis, (at) => abandonOwn({
|
|
@@ -1121,6 +1128,15 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, hasLooseRows, r
|
|
|
1121
1128
|
...changing,
|
|
1122
1129
|
signal: unaborted
|
|
1123
1130
|
};
|
|
1131
|
+
judging.reach = (tips) => SealedObjects.visibleWhole(sealed, pushWhole, decide.at, {
|
|
1132
|
+
tips,
|
|
1133
|
+
row: indexRow?.value,
|
|
1134
|
+
roots
|
|
1135
|
+
}, () => walkedVisible(whole, decide.at, {
|
|
1136
|
+
tips,
|
|
1137
|
+
roots
|
|
1138
|
+
}, judgedWalk));
|
|
1139
|
+
judging.roots = roots;
|
|
1124
1140
|
if (by !== void 0) judging.covered = coveredTips(read.refs, (ref) => by.covers(ref) && !movesAsGitsOwn(hidden, request.as, ref));
|
|
1125
1141
|
if (by !== void 0) judging.refuses = by.refuses;
|
|
1126
1142
|
if (by?.covers(read.head) === true) judging.defaultTip = read.refs.get(read.head);
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { gitError } from "../../contracts/result.mjs";
|
|
1
2
|
import { emptyTree } from "../../protocol/objects/object.mjs";
|
|
2
|
-
import { combinedPaths } from "../../engine/combined.mjs";
|
|
3
|
+
import { WalkRefused, combinedPaths } from "../../engine/combined.mjs";
|
|
4
|
+
import { noRepoRoots, parentsWithin } from "../../protocol/objects/commit.mjs";
|
|
3
5
|
import { allotmentWithin } from "../../contracts/object-values.mjs";
|
|
4
6
|
import { openTreeBytes } from "../../storage/budget.mjs";
|
|
5
7
|
import { openTreesRefusal } from "../../storage/push-allotment.mjs";
|
|
8
|
+
import "../ancestry.mjs";
|
|
6
9
|
import { commitOf, treeOf, withEmptyTree } from "./changes.mjs";
|
|
7
10
|
import * as Effect from "effect/Effect";
|
|
8
11
|
import * as Predicate from "effect/Predicate";
|
|
@@ -66,10 +69,9 @@ const chainSearch = (input, starts) => {
|
|
|
66
69
|
};
|
|
67
70
|
/**
|
|
68
71
|
* `commit`'s paths against the parents that count. On the first path the rule refuses, when a
|
|
69
|
-
* parent was left out, it searches the chains for those left out
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* the walk goes on, and the path is listed. A push with no refused path pays for no search.
|
|
72
|
+
* parent was left out, it searches the chains for those left out (Q734): a parent it finds counts,
|
|
73
|
+
* and the commit is walked again against it and each parent at a covered tip. Otherwise the walk
|
|
74
|
+
* goes on, and the path is listed. A push with no refused path pays for no search.
|
|
73
75
|
*/
|
|
74
76
|
const judgedPaths = (input, commit, search, allotment) => {
|
|
75
77
|
const { refuses } = input;
|
|
@@ -77,20 +79,18 @@ const judgedPaths = (input, commit, search, allotment) => {
|
|
|
77
79
|
oid: commit.oid,
|
|
78
80
|
parents: commit.counted
|
|
79
81
|
};
|
|
80
|
-
if (!(refuses !== void 0 &&
|
|
82
|
+
if (!(refuses !== void 0 && commit.left.length > 0)) return commitPaths(input, walked, allotment);
|
|
81
83
|
return Stream.suspend(() => {
|
|
82
|
-
const candidates = commit.self === void 0 ? commit.left : [commit.self, ...commit.left];
|
|
83
84
|
let trusted;
|
|
84
85
|
const listed = (change) => {
|
|
85
86
|
if (trusted !== void 0 || !refuses(change)) return Effect.succeed(change);
|
|
86
|
-
return Effect.map(search(
|
|
87
|
+
return Effect.map(search(commit.left), (found) => {
|
|
87
88
|
trusted = found;
|
|
88
89
|
return found.length > 0 ? void 0 : change;
|
|
89
90
|
});
|
|
90
91
|
};
|
|
91
92
|
const again = Stream.suspend(() => {
|
|
92
93
|
if (trusted === void 0 || trusted.length === 0) return Stream.empty;
|
|
93
|
-
if (commit.self !== void 0 && trusted.includes(commit.self)) return Stream.empty;
|
|
94
94
|
const counts = /* @__PURE__ */ new Set([...commit.counted, ...trusted]);
|
|
95
95
|
const parents = commit.parents.filter((parent) => counts.has(parent) || input.covered?.(parent) === true);
|
|
96
96
|
return commitPaths(input, {
|
|
@@ -102,36 +102,108 @@ const judgedPaths = (input, commit, search, allotment) => {
|
|
|
102
102
|
});
|
|
103
103
|
};
|
|
104
104
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* or the tip of a ref `covered` holds, it's walked against that parent and each later one that
|
|
108
|
-
* counts, so a merge commit of a covered branch is judged as a push of that one commit is.
|
|
109
|
-
* Otherwise it's walked against the old tip, or as a root for a ref it makes, so what the tip takes
|
|
110
|
-
* from a commit the rule never saw, made unpublished, a fork's pull head or an older commit of a
|
|
111
|
-
* covered branch, is listed, unless a refusal's search finds it judged. A squash, a rebase and a
|
|
112
|
-
* fast-forward still differ from the old tip by what they bring.
|
|
105
|
+
* A move's walk past `limit` commits it adds: what it adds can't be judged, so the rule refuses the
|
|
106
|
+
* ref with it, as it does a walk its allotment stops.
|
|
113
107
|
*/
|
|
114
|
-
const
|
|
108
|
+
const movePastLimit = (limit) => new WalkRefused({ refusal: gitError("RESOURCE_EXHAUSTED", `This move adds over ${limit} commits to check, a merge counted per parent`, {
|
|
109
|
+
hint: "Move the ref in steps",
|
|
110
|
+
context: { reason: "walk-limit" }
|
|
111
|
+
}) });
|
|
112
|
+
/** What the old tip reaches, past its walk's bound, refuses the ref as the walk's limit does. */
|
|
113
|
+
const refusedPastBound = (error) => Effect.fail(error.code === "RESOURCE_EXHAUSTED" ? new WalkRefused({ refusal: error }) : error);
|
|
114
|
+
/**
|
|
115
|
+
* The commits from `to` down to `ends` and the repo's roots, each read once, less those `held`
|
|
116
|
+
* answers for and the commits behind them: none past `limit`, each counted for its parents.
|
|
117
|
+
*/
|
|
118
|
+
const walkedDown = /* @__PURE__ */ Effect.fnUntraced(function* (input, to, ends, held, limit) {
|
|
119
|
+
const read = withEmptyTree(input.read);
|
|
120
|
+
const added = [];
|
|
121
|
+
const passed = /* @__PURE__ */ new Set([to]);
|
|
122
|
+
let frontier = [to];
|
|
123
|
+
let taken = 0;
|
|
124
|
+
while (frontier.length > 0) {
|
|
125
|
+
const open = frontier.filter((oid) => !ends(oid));
|
|
126
|
+
const kept = held === void 0 || open.length === 0 ? /* @__PURE__ */ new Set() : yield* held(open);
|
|
127
|
+
frontier = [];
|
|
128
|
+
for (const oid of open) {
|
|
129
|
+
if (kept.has(oid)) continue;
|
|
130
|
+
if (taken >= limit) return void 0;
|
|
131
|
+
const commit = yield* commitOf(read, oid, input.signal);
|
|
132
|
+
if (commit === void 0) continue;
|
|
133
|
+
const parents = parentsWithin(input.roots ?? noRepoRoots, oid, commit.parents);
|
|
134
|
+
taken += Math.max(1, parents.length);
|
|
135
|
+
added.push({
|
|
136
|
+
oid,
|
|
137
|
+
parents
|
|
138
|
+
});
|
|
139
|
+
for (const parent of parents) {
|
|
140
|
+
if (passed.has(parent)) continue;
|
|
141
|
+
passed.add(parent);
|
|
142
|
+
frontier.push(parent);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return added;
|
|
147
|
+
});
|
|
148
|
+
/** The commits of `walked` whose parents lead down to `from`: newer than it, so none it reaches. */
|
|
149
|
+
const leadingTo = (walked, from) => {
|
|
150
|
+
const children = /* @__PURE__ */ new Map();
|
|
151
|
+
for (const commit of walked) for (const parent of commit.parents) children.set(parent, [...children.get(parent) ?? [], commit.oid]);
|
|
152
|
+
const leads = /* @__PURE__ */ new Set();
|
|
153
|
+
const waiting = [...children.get(from) ?? []];
|
|
154
|
+
for (let oid = waiting.pop(); oid !== void 0; oid = waiting.pop()) {
|
|
155
|
+
if (leads.has(oid)) continue;
|
|
156
|
+
leads.add(oid);
|
|
157
|
+
waiting.push(...children.get(oid) ?? []);
|
|
158
|
+
}
|
|
159
|
+
return leads;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Which of `oids`, commits newer than the old tip, the default branch reaches when the rule covers
|
|
163
|
+
* it and it isn't the old tip itself: none past its walk's bound, so those are judged, never let
|
|
164
|
+
* through unread.
|
|
165
|
+
*/
|
|
166
|
+
const defaultHolds = (input, from, oids) => {
|
|
167
|
+
const { defaultTip } = input;
|
|
168
|
+
const reach = defaultTip === void 0 || defaultTip === from ? void 0 : input.reach?.([defaultTip]);
|
|
169
|
+
if (reach === void 0 || oids.length === 0) return Effect.succeed(/* @__PURE__ */ new Set());
|
|
170
|
+
return reach.has(oids, { signal: input.signal }).pipe(Effect.catchIf((error) => error.code === "RESOURCE_EXHAUSTED", () => Effect.succeed(/* @__PURE__ */ new Set())));
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* The commits a move's new tip adds to its ref, one that brings no commits of its own: an API
|
|
174
|
+
* write, or a push of a ref onto a commit it doesn't bring. A walk from the tip ends at each commit
|
|
175
|
+
* already on the ref, which the old tip reaches, as `reach` answers, or on the default branch when
|
|
176
|
+
* the rule covers it, and at each covered tip, which a rule judged on its way there, but not at a
|
|
177
|
+
* covered tip's older commits. Each commit it adds is then walked as a push's brought one is
|
|
178
|
+
* (#3016), so a commit made unpublished and moved onto later, deleting what its parent added,
|
|
179
|
+
* can't hide the parent's paths. Past `limit` commits it's refused, as a push's walks are past
|
|
180
|
+
* `ancestryLimit`.
|
|
181
|
+
*
|
|
182
|
+
* It walks first without `reach`, within `limit`, and asks the old tip's and the default branch's
|
|
183
|
+
* of the commits whose parents don't lead down to the old tip. Those that do, newer than it, are
|
|
184
|
+
* asked of the default branch's alone: a fast-forward, or a merge commit onto the old tip, of a
|
|
185
|
+
* branch the default isn't, so a repo with no reachability index never walks the ref's whole
|
|
186
|
+
* history to answer that its new commits aren't in it. A move onto older history, past `limit`
|
|
187
|
+
* that way, walks again asking.
|
|
188
|
+
*/
|
|
189
|
+
const addedBy = /* @__PURE__ */ Effect.fnUntraced(function* (input, update) {
|
|
115
190
|
const { to, from } = update;
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
left: parents,
|
|
133
|
-
self: to
|
|
134
|
-
};
|
|
191
|
+
const limit = input.limit ?? 1e4;
|
|
192
|
+
const tips = [from, input.defaultTip].filter((tip) => tip !== null && tip !== void 0);
|
|
193
|
+
const judged = tips.length === 0 ? void 0 : input.reach?.(tips);
|
|
194
|
+
const ends = (oid) => oid === from || input.covered?.(oid) === true;
|
|
195
|
+
const asking = judged === void 0 ? void 0 : (open) => judged.has(open, { signal: input.signal }).pipe(Effect.catch(refusedPastBound));
|
|
196
|
+
const walked = yield* walkedDown(input, to, ends, void 0, limit);
|
|
197
|
+
if (walked !== void 0) {
|
|
198
|
+
const leads = leadingTo(walked, from);
|
|
199
|
+
const asked = walked.filter((commit) => !leads.has(commit.oid)).map((commit) => commit.oid);
|
|
200
|
+
const held = asking === void 0 || asked.length === 0 ? /* @__PURE__ */ new Set() : yield* asking(asked);
|
|
201
|
+
const onDefault = yield* defaultHolds(input, from, [...leads]);
|
|
202
|
+
return walked.filter((commit) => !held.has(commit.oid) && !onDefault.has(commit.oid));
|
|
203
|
+
}
|
|
204
|
+
const added = asking === void 0 ? void 0 : yield* walkedDown(input, to, ends, asking, limit);
|
|
205
|
+
if (added === void 0) return yield* Effect.fail(movePastLimit(limit));
|
|
206
|
+
return added;
|
|
135
207
|
});
|
|
136
208
|
/**
|
|
137
209
|
* `CommitChangesInput.covered` for a rule over the refs `covers` names: whether a commit is the
|
|
@@ -153,7 +225,7 @@ const commitChangesOf = (input, updates) => Stream.unwrap(Effect.gen(function* (
|
|
|
153
225
|
const olds = updates.map((update) => update.from);
|
|
154
226
|
const search = chainSearch(input, [...olds, input.defaultTip]);
|
|
155
227
|
const tips = /* @__PURE__ */ new Set();
|
|
156
|
-
const pushedPaths = (commit, listed) => Stream.unwrap(Effect.map(
|
|
228
|
+
const pushedPaths = (commit, listed, judges = input.source === "git") => Stream.unwrap(Effect.map(judges ? pushedJudged(input, commit, listed, olds) : Effect.succeed({
|
|
157
229
|
...commit,
|
|
158
230
|
counted: commit.parents,
|
|
159
231
|
left: []
|
|
@@ -179,16 +251,12 @@ const commitChangesOf = (input, updates) => Stream.unwrap(Effect.gen(function* (
|
|
|
179
251
|
const moved = Stream.fromIterable(updates).pipe(Stream.flatMap((update) => Stream.unwrap(Effect.gen(function* () {
|
|
180
252
|
const { to } = update;
|
|
181
253
|
if (to === null || tips.has(to)) return Stream.empty;
|
|
182
|
-
const
|
|
254
|
+
const added = yield* addedBy(input, {
|
|
183
255
|
...update,
|
|
184
256
|
to
|
|
185
257
|
});
|
|
186
|
-
|
|
187
|
-
return
|
|
188
|
-
commit: to,
|
|
189
|
-
root: false,
|
|
190
|
-
change
|
|
191
|
-
})));
|
|
258
|
+
const listed = new Set(added.map((commit) => commit.oid));
|
|
259
|
+
return Stream.fromIterable(added).pipe(Stream.flatMap((commit) => pushedPaths(commit, listed, true)));
|
|
192
260
|
}))));
|
|
193
261
|
return Stream.concat(pushed, moved);
|
|
194
262
|
}));
|
|
@@ -73,4 +73,29 @@ const allotOrFail = (meter, part, bytes) => Effect.suspend(() => {
|
|
|
73
73
|
const allotScoped = (meter, part, bytes) => Effect.acquireRelease(allotOrFail(meter, part, bytes), () => Effect.sync(() => meter.free(part)));
|
|
74
74
|
/** The capacity a view keeps alive: its whole buffer's. */
|
|
75
75
|
const capacityOf = (bytes) => bytes.buffer.byteLength;
|
|
76
|
-
|
|
76
|
+
/** A Worker isolate's 128 MB, read as decimal: the memory `packs()` runs in unless told. */
|
|
77
|
+
const defaultMemory = 128e6;
|
|
78
|
+
/**
|
|
79
|
+
* What an `examples/git-worker` isolate holds outside any allotment, so the allotted and the
|
|
80
|
+
* headroom fit the most a request's work holds on Workers before the isolate is replaced:
|
|
81
|
+
* 128,000,000 less 120,061,952, read in SJC at 3795e0349 on a3ac998ae (Q893, 25 Nov 2026). That's
|
|
82
|
+
* a cold isolate's lowest fill of JS heap, 123,207,680, less the 3,145,728 a Git request's or a
|
|
83
|
+
* `git.repack` try's own state keeps on top. ArrayBuffers aren't counted at once, so nothing is
|
|
84
|
+
* sized from their fills.
|
|
85
|
+
*/
|
|
86
|
+
const idleHeapBytes = 7938048;
|
|
87
|
+
/** What `packs()` leaves free of `memory`, for what no allotment counts. */
|
|
88
|
+
const headroomBytes = 16777216;
|
|
89
|
+
/** What operations are allotted of `memory`: all of it but an idle heap and the headroom. */
|
|
90
|
+
const allottableOf = (memory) => memory - idleHeapBytes - headroomBytes;
|
|
91
|
+
/** WebAssembly's page: a memory grows a page at a time. */
|
|
92
|
+
const wasmPageBytes = 65536;
|
|
93
|
+
/**
|
|
94
|
+
* The most zlib-ng's memory grows to in an isolate, set by the host side, never zlib-ng's: what a
|
|
95
|
+
* 128 MB isolate's operations are allotted, in whole pages, 103,284,736 bytes. Each inflater is
|
|
96
|
+
* charged to its read's meter as `inflaterBytes`; this holds them all together within the
|
|
97
|
+
* isolate. An inflater that would take it past fails to open, as `InflateError`, and those open
|
|
98
|
+
* go on.
|
|
99
|
+
*/
|
|
100
|
+
const inflaterMemoryBytes = Math.floor(allottableOf(defaultMemory) / wasmPageBytes) * wasmPageBytes;
|
|
101
|
+
export { BufferError, BufferMeter, allotNow, allotOrFail, allotScoped, allottableOf, capacityOf, defaultMemory, headroomBytes, idleHeapBytes, inflaterMemoryBytes };
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
+
import "./zlib-ng/instance.mjs";
|
|
1
2
|
import * as Schema from "effect/Schema";
|
|
2
3
|
import * as Effect from "effect/Effect";
|
|
3
4
|
import * as Result from "effect/Result";
|
|
4
5
|
import * as Scope from "effect/Scope";
|
|
5
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* The bytes an inflater keeps between calls, at most, all in the instance's memory: its stream,
|
|
8
|
+
* window and state, 42,144 bytes with zlib-ng 2.3.3, and its two buffers, `inflateWindow` each.
|
|
9
|
+
* `zlib-ng/instance.test.ts` measures it.
|
|
10
|
+
*/
|
|
6
11
|
export declare const inflaterBytes: number;
|
|
7
12
|
declare const InflateError_base: Schema.Class<InflateError, Schema.TaggedStruct<"InflateError", {
|
|
8
13
|
readonly fault: Schema.Literals<readonly ["zlib", "no progress", "start"]>;
|
|
9
14
|
readonly message: Schema.String;
|
|
10
15
|
}>, import("effect/Cause").YieldableError>;
|
|
11
16
|
/**
|
|
12
|
-
* A member that couldn't be inflated: `zlib` for bytes zlib refused
|
|
13
|
-
* that neither used its input nor filled its output, and `start` for an
|
|
14
|
-
* start.
|
|
17
|
+
* A member that couldn't be inflated: `zlib` for bytes zlib refused or an instance that trapped,
|
|
18
|
+
* `no progress` for a call that neither used its input nor filled its output, and `start` for an
|
|
19
|
+
* inflater that didn't start.
|
|
15
20
|
*/
|
|
16
21
|
export declare class InflateError extends InflateError_base {}
|
|
17
22
|
/**
|
|
@@ -34,8 +39,8 @@ export interface MemberInflater {
|
|
|
34
39
|
readonly reset: () => Result.Result<void, InflateError>;
|
|
35
40
|
}
|
|
36
41
|
/**
|
|
37
|
-
* An inflater of zlib members, one after another, `reset` between them, its
|
|
38
|
-
*
|
|
42
|
+
* An inflater of zlib members, one after another, `reset` between them, its stream freed when
|
|
43
|
+
* its scope closes.
|
|
39
44
|
*/
|
|
40
45
|
export declare const memberInflater: Effect.Effect<MemberInflater, InflateError, Scope.Scope>;
|
|
41
46
|
export {};
|