@ref0/git 0.20.0 → 0.25.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 +1 -1
- package/dist/auth/access-jwt.mjs +3 -3
- package/dist/auth/auth-namespace.d.mts +3 -3
- package/dist/auth/auth-namespace.mjs +3 -2
- package/dist/auth/auth.d.mts +3 -3
- package/dist/auth/auth.mjs +9 -8
- package/dist/auth/authorize.mjs +1 -1
- package/dist/auth/fences.d.mts +1 -1
- package/dist/auth/host-function.mjs +1 -1
- package/dist/auth/host-services.mjs +4 -6
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +6 -0
- package/dist/auth/token-cleanup.mjs +2 -2
- package/dist/auth/token-rows.mjs +6 -1
- package/dist/auth/token-text.mjs +1 -1
- package/dist/auth/tokens-base.d.mts +1 -1
- package/dist/auth/tokens.d.mts +1 -1
- package/dist/auth/tokens.mjs +1 -1
- package/dist/client/client.d.mts +15 -7
- package/dist/client/client.mjs +21 -12
- package/dist/client/git-http.mjs +1 -1
- package/dist/client/local.mjs +60 -24
- package/dist/client/negotiate.mjs +3 -3
- package/dist/client/push-upload.mjs +26 -10
- package/dist/client/remote.mjs +4 -3
- package/dist/client/run-remote-helper.d.mts +2 -2
- package/dist/client/run-remote-helper.mjs +6 -6
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +3 -3
- package/dist/contracts/blobs.d.mts +3 -3
- package/dist/contracts/blobs.mjs +1 -1
- package/dist/contracts/calls-spent.mjs +5 -33
- package/dist/contracts/client.d.mts +15 -14
- package/dist/contracts/commits.d.mts +4 -4
- package/dist/contracts/commits.mjs +1 -1
- package/dist/contracts/engine.d.mts +2 -2
- package/dist/contracts/events.d.mts +1 -1
- package/dist/contracts/events.mjs +1 -1
- package/dist/contracts/files.d.mts +4 -4
- package/dist/contracts/files.mjs +1 -1
- package/dist/contracts/forks.d.mts +4 -4
- package/dist/contracts/forks.mjs +1 -1
- package/dist/contracts/git-hooks.d.mts +1 -1
- package/dist/contracts/git.d.mts +9 -5
- package/dist/contracts/grants.d.mts +1 -1
- package/dist/contracts/merges.d.mts +1 -1
- package/dist/contracts/object-values.d.mts +1 -0
- package/dist/contracts/object-values.mjs +16 -1
- package/dist/contracts/objects.d.mts +20 -17
- package/dist/contracts/opaque.mjs +1 -1
- package/dist/contracts/operations.mjs +1 -1
- package/dist/contracts/queue.d.mts +208 -44
- package/dist/contracts/queue.mjs +5 -5
- package/dist/contracts/refs.d.mts +5 -5
- package/dist/contracts/refs.mjs +1 -1
- package/dist/contracts/remote.d.mts +3 -6
- package/dist/contracts/repos.d.mts +3 -3
- package/dist/contracts/repos.mjs +1 -1
- package/dist/contracts/result.d.mts +10 -7
- package/dist/contracts/result.mjs +8 -3
- package/dist/contracts/rules.d.mts +2 -2
- package/dist/contracts/server.d.mts +8 -10
- package/dist/contracts/services.d.mts +6 -9
- package/dist/contracts/services.mjs +1 -2
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/store.d.mts +2 -2
- package/dist/contracts/sync.d.mts +63 -6
- package/dist/contracts/sync.mjs +3 -2
- package/dist/contracts/tags.d.mts +3 -3
- package/dist/contracts/tags.mjs +1 -1
- package/dist/contracts/tokens.d.mts +2 -2
- package/dist/contracts/tokens.mjs +1 -1
- package/dist/contracts/topics.d.mts +9 -9
- package/dist/contracts/trees.d.mts +4 -4
- package/dist/contracts/trees.mjs +1 -1
- package/dist/contracts/work.d.mts +4 -4
- package/dist/contracts/work.mjs +2 -2
- package/dist/core/access.d.mts +1 -1
- package/dist/core/ancestry.mjs +30 -34
- package/dist/core/{promise.mjs → call-groups.mjs} +7 -30
- package/dist/core/call-services.mjs +1 -1
- package/dist/core/events/deliver.d.mts +2 -2
- package/dist/core/events/deliver.mjs +3 -3
- package/dist/core/events/retired.mjs +1 -1
- package/dist/core/forks.mjs +5 -5
- package/dist/core/hooks/groups.mjs +2 -2
- package/dist/core/imports.mjs +101 -21
- package/dist/core/index-job.mjs +14 -9
- package/dist/core/index-lost.d.mts +1 -1
- package/dist/core/loose-tally.mjs +38 -15
- package/dist/core/merge-parts.d.mts +17 -4
- package/dist/core/merge-parts.mjs +7 -2
- package/dist/core/mirror-rows.mjs +31 -1
- package/dist/core/objects/blobs.mjs +8 -10
- package/dist/core/objects/files.mjs +20 -17
- package/dist/core/objects/objects-layer.mjs +1 -1
- package/dist/core/objects/peel.mjs +1 -7
- package/dist/core/objects/reading.mjs +19 -18
- package/dist/core/objects/tree-edits.mjs +1 -1
- package/dist/core/objects/trees.mjs +257 -58
- package/dist/core/objects/writing.mjs +3 -9
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +8 -1
- package/dist/core/parts.mjs +8 -4
- package/dist/core/purge.mjs +31 -18
- package/dist/core/push.d.mts +2 -2
- package/dist/core/push.mjs +125 -94
- package/dist/core/receipts.d.mts +2 -2
- package/dist/core/receipts.mjs +9 -2
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +74 -31
- package/dist/core/refs.mjs +3 -3
- package/dist/core/repack.mjs +25 -30
- package/dist/core/repo-info.mjs +1 -1
- package/dist/core/repos.mjs +1 -1
- package/dist/core/rules/changes.mjs +18 -40
- package/dist/core/rules/check.mjs +6 -5
- package/dist/core/rules/commit-changes.mjs +3 -15
- package/dist/core/rules/context.d.mts +3 -3
- package/dist/core/rules/context.mjs +18 -14
- package/dist/core/rules/fetch.mjs +1 -1
- package/dist/core/rules/protect.mjs +30 -17
- package/dist/core/saved-caller-views.d.mts +1 -1
- package/dist/core/saved-caller-views.mjs +3 -3
- package/dist/core/saved-callers.d.mts +1 -1
- package/dist/core/saved-callers.mjs +1 -1
- package/dist/core/seam.d.mts +1 -2
- package/dist/core/view.d.mts +6 -3
- package/dist/core/view.mjs +11 -10
- package/dist/core/work.mjs +2 -2
- package/dist/engine/allotted-xdiff.mjs +3 -16
- package/dist/engine/combined.d.mts +3 -0
- package/dist/engine/combined.mjs +200 -185
- package/dist/engine/content.d.mts +2 -2
- package/dist/engine/content.mjs +1 -1
- package/dist/engine/merge.mjs +7 -9
- package/dist/engine/reads.d.mts +2 -2
- package/dist/engine/reads.mjs +22 -14
- package/dist/engine/xdiff.d.mts +1 -1
- package/dist/engine/xdiff.mjs +1 -1
- 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 +2 -2
- package/dist/event-streams/stream.mjs +3 -3
- package/dist/extend.d.mts +2 -6
- package/dist/extend.mjs +1 -5
- package/dist/http/core-parts.mjs +83 -26
- package/dist/http/handler.mjs +54 -9
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +138 -24
- package/dist/http/push-uploads.mjs +2 -2
- package/dist/http/receive-pack.mjs +14 -53
- package/dist/http/request-snapshot.mjs +258 -0
- package/dist/http/upload-pack.mjs +23 -18
- package/dist/index.d.mts +29 -21
- package/dist/index.mjs +11 -2
- package/dist/lfs/base.d.mts +1 -1
- package/dist/lfs/copy.d.mts +49 -1
- package/dist/lfs/copy.mjs +135 -22
- package/dist/lfs/layer.d.mts +4 -3
- package/dist/lfs/layer.mjs +4 -5
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +1 -1
- package/dist/lfs/objects.mjs +3 -3
- package/dist/lfs/pointers.mjs +1 -1
- package/dist/lfs/rows.d.mts +1 -1
- package/dist/lfs/rows.mjs +11 -4
- package/dist/lfs/upkeep.mjs +40 -9
- package/dist/lfs/uploaded.mjs +1 -1
- package/dist/lfs/wire.mjs +1 -1
- package/dist/merges/merges.mjs +17 -2
- package/dist/protocol/bytes/buffers.d.mts +1 -1
- package/dist/protocol/bytes/buffers.mjs +1 -1
- package/dist/protocol/bytes/deflate.d.mts +1 -1
- package/dist/protocol/bytes/deflate.mjs +1 -1
- package/dist/protocol/bytes/inflate.d.mts +1 -1
- package/dist/protocol/bytes/inflate.mjs +1 -1
- package/dist/protocol/bytes/sha1.d.mts +1 -1
- package/dist/protocol/bytes/sha1.mjs +1 -1
- package/dist/protocol/diff/read.d.mts +2 -1
- package/dist/protocol/diff/read.mjs +102 -8
- package/dist/protocol/packs/graph.mjs +1 -1
- package/dist/protocol/packs/idx.d.mts +1 -1
- package/dist/protocol/packs/idx.mjs +1 -1
- package/dist/protocol/packs/parts.mjs +1 -1
- package/dist/protocol/packs/reader.d.mts +1 -1
- package/dist/protocol/packs/reader.mjs +1 -1
- package/dist/protocol/packs/write-error.d.mts +1 -1
- package/dist/protocol/packs/write-error.mjs +1 -1
- package/dist/protocol/packs/writer.mjs +3 -3
- package/dist/protocol/wire/advertisement.d.mts +1 -1
- package/dist/protocol/wire/advertisement.mjs +3 -2
- package/dist/protocol/wire/fetch.d.mts +1 -1
- package/dist/protocol/wire/fetch.mjs +1 -1
- package/dist/protocol/wire/lines.d.mts +9 -1
- package/dist/protocol/wire/lines.mjs +28 -1
- package/dist/protocol/wire/push-uploads.mjs +10 -7
- package/dist/protocol/wire/receive-pack.d.mts +1 -1
- package/dist/protocol/wire/receive-pack.mjs +1 -1
- package/dist/protocol/wire/report-status.d.mts +1 -1
- package/dist/protocol/wire/report-status.mjs +1 -1
- package/dist/protocol/wire/v2.d.mts +1 -1
- package/dist/protocol/wire/v2.mjs +1 -1
- package/dist/queue/advance.mjs +31 -24
- package/dist/queue/base.d.mts +5 -3
- package/dist/queue/calls.mjs +5 -5
- package/dist/queue/commit.mjs +1 -1
- package/dist/queue/host.d.mts +1 -1
- package/dist/queue/layer.d.mts +0 -1
- package/dist/queue/layer.mjs +9 -5
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/search.mjs +1 -1
- package/dist/queue/state.mjs +1 -1
- package/dist/queue/trim.mjs +2 -2
- package/dist/rest/client.d.mts +1 -1
- package/dist/rest/client.mjs +6 -6
- package/dist/rest/errors.mjs +1 -1
- package/dist/rest/handler.mjs +2 -2
- package/dist/rest/handlers.mjs +16 -6
- package/dist/rest/layer.mjs +1 -1
- package/dist/rest/listen.mjs +2 -2
- package/dist/rest/refs.mjs +1 -1
- package/dist/server/edge.mjs +27 -3
- package/dist/server/git-layer.d.mts +1 -2
- package/dist/server/git-layer.mjs +4 -5
- package/dist/server/lifecycle.mjs +1 -1
- package/dist/server/registry.mjs +2 -8
- package/dist/server/server.mjs +62 -43
- package/dist/signin/context.d.mts +1 -1
- package/dist/signin/context.mjs +1 -1
- package/dist/signin/forms.mjs +1 -1
- package/dist/signin/grants.d.mts +2 -2
- package/dist/signin/grants.mjs +1 -1
- package/dist/signin/wire.mjs +1 -1
- package/dist/storage/allotted.mjs +4 -9
- package/dist/storage/batch-upkeep.mjs +31 -12
- package/dist/storage/batches.d.mts +2 -3
- package/dist/storage/batches.mjs +52 -49
- package/dist/storage/budget.mjs +23 -1
- package/dist/storage/calls.d.mts +1 -1
- package/dist/storage/calls.mjs +41 -43
- package/dist/storage/charged-cache.mjs +180 -0
- package/dist/storage/chunks.d.mts +3 -3
- package/dist/storage/chunks.mjs +121 -8
- package/dist/storage/counted-bucket.mjs +32 -10
- package/dist/storage/fetch-row-cache.d.mts +6 -0
- package/dist/storage/fetch-row-cache.mjs +211 -0
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +54 -242
- package/dist/storage/held-types.d.mts +0 -1
- package/dist/storage/host-bucket.mjs +9 -4
- package/dist/storage/index-bitmaps.mjs +77 -49
- package/dist/storage/index-build.d.mts +2 -3
- package/dist/storage/index-build.mjs +248 -48
- package/dist/storage/index-fetch.d.mts +3 -1
- package/dist/storage/index-fetch.mjs +60 -21
- package/dist/storage/index-graph.mjs +1 -1
- package/dist/storage/index-layers.mjs +55 -25
- package/dist/storage/index-reach.mjs +15 -22
- package/dist/storage/index-whole.d.mts +7 -0
- package/dist/storage/index-whole.mjs +145 -37
- package/dist/storage/largest-files.mjs +1 -7
- package/dist/storage/layout.mjs +17 -1
- package/dist/storage/lfs-pointers.mjs +1 -6
- package/dist/storage/link-join.mjs +55 -16
- package/dist/storage/list-source.d.mts +7 -0
- package/dist/storage/list-source.mjs +288 -0
- package/dist/storage/loose.d.mts +8 -8
- package/dist/storage/loose.mjs +157 -91
- package/dist/storage/memory-budget.mjs +226 -22
- package/dist/storage/merge-cut.mjs +9 -6
- package/dist/storage/merge-fence.mjs +1 -1
- package/dist/storage/merge-row.mjs +1 -1
- package/dist/storage/merge.d.mts +2 -3
- package/dist/storage/merge.mjs +2 -2
- package/dist/storage/object-rows.d.mts +3 -3
- package/dist/storage/object-rows.mjs +179 -38
- package/dist/storage/pack-order.mjs +97 -44
- package/dist/storage/pack-ranges.mjs +44 -16
- package/dist/storage/pack-reads.d.mts +5 -3
- package/dist/storage/pack-reads.mjs +236 -72
- package/dist/storage/pack-receive.d.mts +1 -2
- package/dist/storage/pack-receive.mjs +21 -17
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +477 -116
- package/dist/storage/placed-reads.mjs +33 -16
- package/dist/storage/prune-seen.mjs +1 -1
- package/dist/storage/prune-walk.mjs +1 -1
- package/dist/storage/prune.mjs +4 -31
- package/dist/storage/push-allotment.mjs +26 -14
- package/dist/storage/push-uploads.mjs +195 -57
- package/dist/storage/pushed-commits.mjs +20 -1
- package/dist/storage/quarantine.d.mts +2 -3
- package/dist/storage/range-cache.mjs +175 -40
- package/dist/storage/raw-ids.mjs +39 -10
- package/dist/storage/ready.d.mts +2 -3
- package/dist/storage/ready.mjs +114 -38
- package/dist/storage/receive-bounds.mjs +31 -9
- package/dist/storage/receive-cache.d.mts +7 -0
- package/dist/storage/receive-cache.mjs +147 -0
- package/dist/storage/receive-files.mjs +1 -1
- package/dist/storage/receive-links.mjs +1 -1
- package/dist/storage/receive-state.d.mts +2 -2
- package/dist/storage/receive-state.mjs +6 -8
- package/dist/storage/receive-steps.d.mts +20 -0
- package/dist/storage/receive-steps.mjs +298 -13
- package/dist/storage/repack-backlog.mjs +1 -6
- package/dist/storage/repack-contained.mjs +2 -2
- package/dist/storage/repack-job.mjs +1 -1
- package/dist/storage/repack.d.mts +2 -3
- package/dist/storage/repack.mjs +54 -9
- package/dist/storage/request-cache.mjs +57 -0
- package/dist/storage/roots.mjs +1 -24
- package/dist/storage/rows.d.mts +2 -2
- package/dist/storage/rows.mjs +1 -1
- package/dist/storage/runs.d.mts +2 -2
- package/dist/storage/runs.mjs +1 -1
- package/dist/storage/send-list.mjs +62 -25
- package/dist/storage/stream-whole.mjs +84 -63
- package/dist/storage/swap-walk.mjs +1 -1
- package/dist/storage/unpack.mjs +878 -450
- package/dist/storage/visible.mjs +110 -32
- package/dist/storage/walk.mjs +1 -0
- package/dist/storage/wants.mjs +22 -58
- package/dist/store/call-count.d.mts +2 -2
- package/dist/store/call-count.mjs +24 -11
- package/dist/store/catalogue.d.mts +1 -1
- package/dist/store/catalogue.mjs +19 -7
- package/dist/store/crossing.mjs +1 -7
- package/dist/store/cursor-seal.d.mts +1 -1
- package/dist/store/cursor-seal.mjs +1 -1
- package/dist/store/door.mjs +9 -4
- package/dist/store/errors.d.mts +2 -2
- package/dist/store/errors.mjs +107 -19
- package/dist/store/git-store.mjs +7 -2
- package/dist/store/job-try.mjs +90 -9
- package/dist/store/list-job.mjs +10 -34
- package/dist/store/outbox.d.mts +2 -2
- package/dist/store/outbox.mjs +2 -2
- package/dist/store/queue-jobs.mjs +6 -12
- package/dist/store/records.d.mts +2 -2
- package/dist/store/records.mjs +2 -2
- package/dist/store/ref-rows.d.mts +2 -2
- package/dist/store/ref-rows.mjs +2 -2
- package/dist/store/repo-record.d.mts +2 -2
- package/dist/store/repo-record.mjs +3 -3
- package/dist/store/request-snapshot.mjs +5 -0
- package/dist/store/reservations.mjs +2 -2
- package/dist/store/topic-jobs.mjs +5 -11
- package/dist/sync/bound.d.mts +3 -3
- package/dist/sync/bound.mjs +10 -7
- package/dist/sync/github.mjs +65 -67
- package/dist/sync/http.mjs +1 -1
- package/dist/sync/import.mjs +201 -66
- package/dist/sync/layer.d.mts +1 -1
- package/dist/sync/layer.mjs +6 -6
- package/dist/sync/lfs-batch.mjs +1 -1
- package/dist/sync/lfs-copy.mjs +175 -15
- package/dist/sync/mirror.mjs +5 -10
- package/dist/sync/said.mjs +1 -1
- package/dist/sync/step.mjs +268 -86
- package/dist/sync/tries.mjs +25 -6
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +2 -2
- package/dist/topics/advance.mjs +3 -3
- package/dist/topics/calls.mjs +1 -1
- package/dist/topics/layer.d.mts +15 -14
- package/dist/topics/members.mjs +1 -1
- package/dist/topics/topic.mjs +1 -1
- package/package.json +3 -13
- package/dist/auth/helpers.mjs +0 -17
- package/dist/auth.d.mts +0 -5
- package/dist/auth.mjs +0 -5
- package/dist/core/rules/commit-changes.d.mts +0 -12
- package/dist/effect.d.mts +0 -9
- package/dist/effect.mjs +0 -7
- package/dist/server/joined.d.mts +0 -70
- package/dist/server/joined.mjs +0 -41
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allotmentWithin, grownBy, objectsReadMost } from "../../contracts/object-values.mjs";
|
|
2
|
+
import { fail, gitError } from "../../contracts/result.mjs";
|
|
2
3
|
import { diffTrees } from "../../engine/diff.mjs";
|
|
3
4
|
import { fromDiff } from "../../engine/failures.mjs";
|
|
4
|
-
import {
|
|
5
|
+
import { badCursor, inputDigest, limitOf, limitsOf, timed, treeCursorDepthMost, treeLimitMost } from "../../engine/reads.mjs";
|
|
5
6
|
import { joinedBytes } from "../../protocol/bytes/joined.mjs";
|
|
6
7
|
import { isFolder } from "../../protocol/diff/paths.mjs";
|
|
8
|
+
import { readAheadBytesMost } from "../../protocol/diff/read.mjs";
|
|
7
9
|
import { pathText } from "../../protocol/diff/tree-diff.mjs";
|
|
8
|
-
import
|
|
10
|
+
import "../../protocol/objects/object.mjs";
|
|
9
11
|
import { isOid } from "../../protocol/bytes/text.mjs";
|
|
10
12
|
import { callerFor } from "../access.mjs";
|
|
11
13
|
import { dropped, fitting, jsonSize, openRead, readerOf, withinResponse } from "./reading.mjs";
|
|
@@ -13,7 +15,6 @@ import { mergePartsOrOff } from "../merge-parts.mjs";
|
|
|
13
15
|
import { callAllot } from "./lines.mjs";
|
|
14
16
|
import { editTree, editsWithin } from "./tree-edits.mjs";
|
|
15
17
|
import { objectWrite, oidAnswer, takeWrites } from "./writing.mjs";
|
|
16
|
-
import { answerFailed } from "../../contracts/calls-spent.mjs";
|
|
17
18
|
import { ObjectsParts } from "../parts.mjs";
|
|
18
19
|
import * as Effect from "effect/Effect";
|
|
19
20
|
// src/core/objects/trees.ts
|
|
@@ -41,69 +42,262 @@ const entryOf = (entry, path) => {
|
|
|
41
42
|
if (!full.exact) listed.pathBytes = path;
|
|
42
43
|
return listed;
|
|
43
44
|
};
|
|
45
|
+
const walkLimit = (message) => gitError("RESOURCE_EXHAUSTED", message, { context: { reason: "walk-limit" } });
|
|
46
|
+
const childPathOf = (base, name) => base === void 0 ? name : joinedBytes([
|
|
47
|
+
base,
|
|
48
|
+
slash,
|
|
49
|
+
name
|
|
50
|
+
]);
|
|
51
|
+
/** Materializes the full root-to-entry index path once, when `pageOf` emits `next`. */
|
|
52
|
+
const treeNodePosition = (node) => {
|
|
53
|
+
const indices = [];
|
|
54
|
+
for (let at = node; at !== void 0; at = at.parent) indices.push(at.index);
|
|
55
|
+
return indices.reverse();
|
|
56
|
+
};
|
|
57
|
+
/** Encodes a tree position as `/`-separated non-negative integers (no `.` or `-`, safe in `HeldCursor`). */
|
|
58
|
+
const treePositionText = (position) => position.join("/");
|
|
59
|
+
/**
|
|
60
|
+
* Decodes a tree position from `text`, refusing anything `treePositionText` couldn't write:
|
|
61
|
+
* empty strings, oversized tokens (checked before splitting), leading/trailing slashes, leading
|
|
62
|
+
* zeros, non-digits, unsafe integers, depth past `treeCursorDepthMost`, or multi-segment paths
|
|
63
|
+
* when `recursive` is false.
|
|
64
|
+
*/
|
|
65
|
+
const treePositionOf = (text, recursive) => {
|
|
66
|
+
if (text === void 0) return Effect.succeed(void 0);
|
|
67
|
+
const maxDepth = recursive ? treeCursorDepthMost : 1;
|
|
68
|
+
if (text.length === 0 || text.length > maxDepth * 17) return badCursor();
|
|
69
|
+
const parts = text.split("/");
|
|
70
|
+
if (parts.length > maxDepth) return badCursor();
|
|
71
|
+
const position = [];
|
|
72
|
+
for (const part of parts) {
|
|
73
|
+
const index = Number(part);
|
|
74
|
+
if (!/^(?:0|[1-9]\d*)$/.test(part) || !Number.isSafeInteger(index)) return badCursor();
|
|
75
|
+
position.push(index);
|
|
76
|
+
}
|
|
77
|
+
return Effect.succeed(position);
|
|
78
|
+
};
|
|
79
|
+
/** A `trees.get` cursor: `<digest>.<i0>/<i1>/...`, bound to the content-addressed root OID and mode. */
|
|
80
|
+
const treeCursor = (digest, position) => `${digest}.${treePositionText(position)}`;
|
|
81
|
+
/** Decodes a `trees.get` cursor bound to `digest` and `recursive`, or fails `badCursor()`. */
|
|
82
|
+
const treeAfterOf = (after, digest, recursive) => {
|
|
83
|
+
if (after === void 0) return Effect.succeed(void 0);
|
|
84
|
+
return after.startsWith(`${digest}.`) ? treePositionOf(after.slice(digest.length + 1), recursive) : badCursor();
|
|
85
|
+
};
|
|
86
|
+
/** Opens a scoped allotment for a tree listing's retained stack frames and path bytes. */
|
|
87
|
+
const walkAllotment = (opened, most) => Effect.acquireRelease(Effect.sync(() => opened.allotment(most, walkLimit(`The walk holds past ${most} bytes`))), (allotment) => Effect.sync(() => allotment.release()));
|
|
88
|
+
/** Sentinel refusal for speculative tree read-ahead: stops reading ahead without failing the walk. */
|
|
89
|
+
const readAheadRefused = /* @__PURE__ */ gitError("RESOURCE_EXHAUSTED", `The tree read-ahead holds past ${readAheadBytesMost} bytes`, { context: { reason: "walk-limit" } });
|
|
44
90
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
|
|
91
|
+
* Opens a scoped allotment out of the request's memory budget (`opened.allotment`) for speculative
|
|
92
|
+
* tree read-ahead, capped at `min(readAheadBytesMost, most)`.
|
|
93
|
+
*/
|
|
94
|
+
const readAheadAllotment = (opened, most = readAheadBytesMost) => Effect.acquireRelease(Effect.sync(() => opened.allotment(Math.min(readAheadBytesMost, most), readAheadRefused)), (allotment) => Effect.sync(() => allotment.release()));
|
|
95
|
+
const tooDeep = () => Effect.fail(walkLimit(`The tree nests past ${treeCursorDepthMost} levels`));
|
|
96
|
+
/** How many more object reads `reader` and its call tally allow before hitting `objects`. */
|
|
97
|
+
const objectsLeft = (reader) => Math.min(reader.limits.objects - reader.objects, reader.tally === void 0 ? Infinity : reader.tally.limits.objects - reader.tally.objects);
|
|
98
|
+
/**
|
|
99
|
+
* A tree's entries, after `after` (from the start when `undefined`), at most `most`: in the tree's
|
|
100
|
+
* order, and with `recursive` each folder before what it holds, as `ls-tree -r -t` lists them, a
|
|
101
|
+
* submodule not entered. Paths start with `prefix`. Seeking through `after` reads only the
|
|
102
|
+
* ancestor trees along that path, never earlier siblings (#2960). When `reader` supports batch
|
|
103
|
+
* reads, recursive walks probe one subtree at each depth to estimate entries per folder, then
|
|
104
|
+
* prefetch upcoming folders at that depth (across already-prefetched sibling parents) strictly
|
|
105
|
+
* from object allowance above what the rest of the page could still need without prefetch (#2974).
|
|
106
|
+
* Refuses to descend past `treeCursorDepthMost` with `walk-limit`, so every emitted `next`
|
|
107
|
+
* decodes. Frames keep one parent link (`TreeNode`), charged per level through both `reader` and
|
|
108
|
+
* `allotment`, and `pageOf` materializes the cut entry's full position once when a page ends.
|
|
48
109
|
*/
|
|
49
110
|
const listTree = /* @__PURE__ */ Effect.fnUntraced(function* (reader, tree, options) {
|
|
111
|
+
const { allotment, recursive } = options;
|
|
112
|
+
const readAhead = options.readAhead ?? allotmentWithin(Math.min(524288, reader.limits.bytes), readAheadRefused);
|
|
50
113
|
const entries = [];
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const child
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
114
|
+
const nodes = [];
|
|
115
|
+
const enter = (child) => recursive && isFolder(child) && child.oid !== "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
|
|
116
|
+
const prefetched = /* @__PURE__ */ new Set();
|
|
117
|
+
const depthStats = /* @__PURE__ */ new Map();
|
|
118
|
+
let readAheadStopped = false;
|
|
119
|
+
const recordDepth = (depth, children) => {
|
|
120
|
+
let cost = 1 + children.length;
|
|
121
|
+
for (const child of children) if (enter(child)) cost += 1;
|
|
122
|
+
const stat = depthStats.get(depth);
|
|
123
|
+
if (stat === void 0) depthStats.set(depth, {
|
|
124
|
+
trees: 1,
|
|
125
|
+
entries: cost
|
|
126
|
+
});
|
|
127
|
+
else {
|
|
128
|
+
stat.trees += 1;
|
|
129
|
+
stat.entries += cost;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
const readSubtree = Effect.fnUntraced(function* (oid, depth) {
|
|
133
|
+
const children = yield* reader.treeOf(oid);
|
|
134
|
+
prefetched.add(oid);
|
|
135
|
+
recordDepth(depth, children);
|
|
136
|
+
return children;
|
|
137
|
+
});
|
|
138
|
+
const charge = (bytes) => allotment === void 0 ? reader.charge(bytes) : Effect.flatMap(reader.charge(bytes), () => Effect.flatMap(grownBy(allotment, bytes), (refused) => refused === void 0 ? Effect.void : Effect.fail(refused)));
|
|
139
|
+
const stack = [];
|
|
140
|
+
/**
|
|
141
|
+
* Batches upcoming unprefetched folder trees at `targetDepth` in DFS order, starting with
|
|
142
|
+
* `firstOid`. Waits for one probed subtree at `targetDepth` so fat-directory pages never
|
|
143
|
+
* over-read past `options.most`, inspects prefetched parent folders without charging `bytes`,
|
|
144
|
+
* and holds read-ahead trees under `readAhead` so bytes are charged only when the walk takes
|
|
145
|
+
* each tree. A read-ahead refusal drops the batch and stops reading ahead for the rest of the
|
|
146
|
+
* page without failing the walk.
|
|
147
|
+
*/
|
|
148
|
+
const prefetchLevel = Effect.fnUntraced(function* (targetDepth, firstOid, remaining) {
|
|
149
|
+
if (readAheadStopped || reader.batch === void 0 || prefetched.has(firstOid) || remaining < 2) return;
|
|
150
|
+
const stat = depthStats.get(targetDepth);
|
|
151
|
+
if (stat === void 0) return;
|
|
152
|
+
const left = objectsLeft(reader);
|
|
153
|
+
const allowed = left - Math.min(left, remaining);
|
|
154
|
+
const estimated = Math.max(1, Math.ceil((remaining + 1) / (stat.entries / stat.trees)));
|
|
155
|
+
const want = Math.min(estimated, objectsReadMost, allowed);
|
|
156
|
+
if (want <= 1) return;
|
|
157
|
+
const batch = [firstOid];
|
|
158
|
+
const seen = /* @__PURE__ */ new Set([firstOid]);
|
|
159
|
+
let budgetEntries = remaining - 1;
|
|
160
|
+
const collect = Effect.fnUntraced(function* (list, from, childDepth) {
|
|
161
|
+
for (let at = from; at < list.length && batch.length < want && budgetEntries > 0; at += 1) {
|
|
162
|
+
const entry = list[at];
|
|
163
|
+
if (entry === void 0) continue;
|
|
164
|
+
if (!enter(entry)) {
|
|
165
|
+
budgetEntries -= 1;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (childDepth === targetDepth) {
|
|
169
|
+
if (!prefetched.has(entry.oid) && !seen.has(entry.oid)) {
|
|
170
|
+
seen.add(entry.oid);
|
|
171
|
+
batch.push(entry.oid);
|
|
172
|
+
}
|
|
173
|
+
budgetEntries -= 2;
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
budgetEntries -= 1;
|
|
177
|
+
if (budgetEntries <= 0 || !prefetched.has(entry.oid)) return false;
|
|
178
|
+
const sub = yield* reader.peekTree(entry.oid);
|
|
179
|
+
if (sub === void 0) return false;
|
|
180
|
+
if (!(yield* collect(sub, 0, childDepth + 1))) return false;
|
|
181
|
+
}
|
|
182
|
+
return batch.length < want && budgetEntries > 0;
|
|
183
|
+
});
|
|
184
|
+
for (let level = targetDepth - 1; level >= 0; level -= 1) {
|
|
185
|
+
const ancestor = stack[level];
|
|
186
|
+
if (ancestor === void 0) break;
|
|
187
|
+
if (!(yield* collect(ancestor.c, ancestor.at, level + 1))) break;
|
|
188
|
+
}
|
|
189
|
+
if (batch.length <= 1) return;
|
|
190
|
+
if (!(yield* reader.prefetchAhead(batch, readAhead, readAheadRefused))) {
|
|
191
|
+
readAheadStopped = true;
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
for (const oid of batch) prefetched.add(oid);
|
|
195
|
+
});
|
|
196
|
+
return yield* Effect.gen(function* () {
|
|
197
|
+
const rootHeld = 64 + (options.prefix?.length ?? 0);
|
|
198
|
+
yield* charge(rootHeld);
|
|
199
|
+
if (options.after === void 0) stack.push({
|
|
200
|
+
c: yield* reader.treeOf(tree),
|
|
201
|
+
at: 0,
|
|
202
|
+
p: options.prefix,
|
|
203
|
+
n: void 0,
|
|
204
|
+
h: rootHeld
|
|
205
|
+
});
|
|
206
|
+
else {
|
|
207
|
+
if (options.after.length === 0 || options.after.length > (recursive ? 4096 : 1)) return yield* badCursor();
|
|
208
|
+
let children = yield* reader.treeOf(tree);
|
|
209
|
+
let path = options.prefix;
|
|
210
|
+
let node;
|
|
211
|
+
let held = rootHeld;
|
|
212
|
+
for (let depth = 0; depth < options.after.length; depth += 1) {
|
|
213
|
+
const index = options.after[depth] ?? -1;
|
|
214
|
+
const child = Number.isSafeInteger(index) && index >= 0 ? children[index] : void 0;
|
|
215
|
+
const last = depth === options.after.length - 1;
|
|
216
|
+
if (child === void 0 || !last && !isFolder(child)) return yield* badCursor();
|
|
217
|
+
stack.push({
|
|
218
|
+
c: children,
|
|
219
|
+
at: index + 1,
|
|
220
|
+
p: path,
|
|
221
|
+
n: node,
|
|
222
|
+
h: held
|
|
223
|
+
});
|
|
224
|
+
node = {
|
|
225
|
+
index,
|
|
226
|
+
parent: node
|
|
227
|
+
};
|
|
228
|
+
if (!last || enter(child)) {
|
|
229
|
+
if (stack.length >= 4096) return yield* tooDeep();
|
|
230
|
+
path = childPathOf(path, child.name);
|
|
231
|
+
held = 64 + path.length;
|
|
232
|
+
yield* charge(held);
|
|
233
|
+
children = yield* readSubtree(child.oid, stack.length);
|
|
234
|
+
if (last) stack.push({
|
|
235
|
+
c: children,
|
|
236
|
+
at: 0,
|
|
237
|
+
p: path,
|
|
238
|
+
n: node,
|
|
239
|
+
h: held
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
}
|
|
62
243
|
}
|
|
63
|
-
frame.at
|
|
64
|
-
|
|
65
|
-
frame.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
244
|
+
for (let frame = stack.at(-1); frame !== void 0; frame = stack.at(-1)) {
|
|
245
|
+
const childIndex = frame.at;
|
|
246
|
+
const child = frame.c[childIndex];
|
|
247
|
+
if (child === void 0) {
|
|
248
|
+
stack.pop();
|
|
249
|
+
allotment?.shrink(frame.h);
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
71
252
|
if (entries.length === options.most) return {
|
|
72
253
|
entries,
|
|
254
|
+
nodes,
|
|
73
255
|
more: true
|
|
74
256
|
};
|
|
257
|
+
frame.at += 1;
|
|
258
|
+
const path = childPathOf(frame.p, child.name);
|
|
259
|
+
yield* charge(64 + path.length);
|
|
260
|
+
const node = {
|
|
261
|
+
index: childIndex,
|
|
262
|
+
parent: frame.n
|
|
263
|
+
};
|
|
75
264
|
entries.push(entryOf(child, path));
|
|
265
|
+
nodes.push(node);
|
|
266
|
+
if (enter(child)) {
|
|
267
|
+
if (stack.length >= 4096) return yield* tooDeep();
|
|
268
|
+
yield* charge(64);
|
|
269
|
+
const targetDepth = stack.length;
|
|
270
|
+
yield* prefetchLevel(targetDepth, child.oid, options.most - entries.length);
|
|
271
|
+
stack.push({
|
|
272
|
+
c: yield* readSubtree(child.oid, targetDepth),
|
|
273
|
+
at: 0,
|
|
274
|
+
p: path,
|
|
275
|
+
n: node,
|
|
276
|
+
h: 64
|
|
277
|
+
});
|
|
278
|
+
}
|
|
76
279
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
entries,
|
|
86
|
-
more: false
|
|
87
|
-
};
|
|
280
|
+
return {
|
|
281
|
+
entries,
|
|
282
|
+
nodes,
|
|
283
|
+
more: false
|
|
284
|
+
};
|
|
285
|
+
}).pipe(Effect.ensuring(Effect.sync(() => reader.releaseReadAhead())));
|
|
88
286
|
});
|
|
89
287
|
/**
|
|
90
288
|
* `listed`'s entries, each blob with its size, as `ls-tree -l` gives it: read from the object's
|
|
91
|
-
* header, through `
|
|
92
|
-
* `NOT_FOUND`, as reading it would be, unless the core is `partial`: then it has
|
|
93
|
-
* the client fetches no blob to size it.
|
|
289
|
+
* header, through `opened.sizes` on the call's scoped reader, the blob's bytes never read. A blob
|
|
290
|
+
* the repo lacks is `NOT_FOUND`, as reading it would be, unless the core is `partial`: then it has
|
|
291
|
+
* no `size`, since the client fetches no blob to size it.
|
|
94
292
|
*/
|
|
95
293
|
const sized = /* @__PURE__ */ Effect.fnUntraced(function* (opened, listed) {
|
|
96
294
|
const { partial } = yield* ObjectsParts;
|
|
97
295
|
const blobs = [...new Set(listed.entries.filter((entry) => entry.type === "blob").map((entry) => entry.oid))];
|
|
98
296
|
if (blobs.length === 0) return listed;
|
|
99
|
-
const
|
|
100
|
-
oids: blobs,
|
|
101
|
-
signal
|
|
102
|
-
}))));
|
|
103
|
-
if (answer.kind === "error") return yield* answerFailed(answer.error);
|
|
297
|
+
const sizes = yield* opened.sizes({ oids: blobs });
|
|
104
298
|
const entries = yield* Effect.forEach(listed.entries, (entry) => {
|
|
105
299
|
if (entry.type !== "blob") return Effect.succeed(entry);
|
|
106
|
-
const size =
|
|
300
|
+
const size = sizes.get(entry.oid);
|
|
107
301
|
if (size === void 0 && partial === true) return Effect.succeed(entry);
|
|
108
302
|
if (size === void 0) return fail("NOT_FOUND", `object ${entry.oid} is missing`);
|
|
109
303
|
return Effect.succeed({
|
|
@@ -121,7 +315,7 @@ const treeCalls = (bound) => {
|
|
|
121
315
|
return {
|
|
122
316
|
get: Effect.fnUntraced(function* (repo, input) {
|
|
123
317
|
const limits = yield* limitsOf(input.limits);
|
|
124
|
-
const limit = yield* limitOf(input.page);
|
|
318
|
+
const limit = yield* limitOf(input.page, treeLimitMost);
|
|
125
319
|
const recursive = input.recursive === true;
|
|
126
320
|
if (!isOid(input.oid)) return yield* notAnOid(input.oid);
|
|
127
321
|
const digest = yield* inputDigest([
|
|
@@ -129,15 +323,18 @@ const treeCalls = (bound) => {
|
|
|
129
323
|
input.oid,
|
|
130
324
|
String(recursive)
|
|
131
325
|
]);
|
|
132
|
-
const
|
|
326
|
+
const after = yield* treeAfterOf(input.page?.after, digest, recursive);
|
|
133
327
|
const opened = yield* openRead(callerOf(input), repo, [], input.internalId);
|
|
134
328
|
const { reader, deadline } = yield* readerOf(opened, limits, "walk-limit");
|
|
329
|
+
const allotment = yield* walkAllotment(opened, limits.reads.bytes);
|
|
330
|
+
const readAhead = yield* readAheadAllotment(opened, limits.reads.bytes);
|
|
135
331
|
const listing = treeish(reader, input.oid).pipe(Effect.andThen(listTree(reader, input.oid, {
|
|
136
|
-
prefix: void 0,
|
|
137
332
|
recursive,
|
|
138
|
-
|
|
139
|
-
most: limit
|
|
140
|
-
|
|
333
|
+
after,
|
|
334
|
+
most: limit,
|
|
335
|
+
allotment,
|
|
336
|
+
readAhead
|
|
337
|
+
})), Effect.mapError(fromDiff("walk-limit")), Effect.flatMap((listed) => sized(opened, listed)), Effect.flatMap((listed) => pageOf(listed, "The tree page", (position) => treeCursor(digest, position))));
|
|
141
338
|
return yield* timed(listing, deadline);
|
|
142
339
|
}, Effect.scoped),
|
|
143
340
|
diff: Effect.fnUntraced(function* (repo, input) {
|
|
@@ -221,14 +418,16 @@ const treeish = (reader, oid) => Effect.flatMap(reader.object(oid), (object) =>
|
|
|
221
418
|
return fail("INVALID_ARGUMENT", `${oid} names a blob, not a tree`);
|
|
222
419
|
});
|
|
223
420
|
/**
|
|
224
|
-
* A listing of entries
|
|
225
|
-
*
|
|
421
|
+
* A listing of entries cut to the response bound: `next` the cursor of the last entry kept, when
|
|
422
|
+
* more follow it.
|
|
226
423
|
*/
|
|
227
|
-
const pageOf = (listed,
|
|
424
|
+
const pageOf = (listed, what, cursorOf) => Effect.map(fitting(listed.entries.map(jsonSize), what), (kept) => {
|
|
228
425
|
const items = listed.entries.slice(0, kept);
|
|
229
|
-
|
|
426
|
+
const more = listed.more || kept < listed.entries.length;
|
|
427
|
+
const last = listed.nodes[kept - 1];
|
|
428
|
+
return more && last !== void 0 ? {
|
|
230
429
|
items,
|
|
231
|
-
next: cursorOf(
|
|
430
|
+
next: cursorOf(treeNodePosition(last))
|
|
232
431
|
} : { items };
|
|
233
432
|
});
|
|
234
|
-
export { listTree, notAnOid, pageOf, sized, treeCalls, treeish };
|
|
433
|
+
export { listTree, notAnOid, pageOf, readAheadAllotment, readAheadRefused, sized, treeCalls, treeNodePosition, treePositionOf, treePositionText, treeish, walkAllotment };
|
|
@@ -13,13 +13,12 @@ import { keyedPushWith, pushWith } from "../push.mjs";
|
|
|
13
13
|
import { ownWriter, ownWrites } from "../own-writes.mjs";
|
|
14
14
|
import { objectAnswer } from "../receipts.mjs";
|
|
15
15
|
import { objectIn, openKeyedRead } from "./reading.mjs";
|
|
16
|
-
import { tryUnlessSpent } from "../../contracts/calls-spent.mjs";
|
|
17
16
|
import { CoreParts } from "../parts.mjs";
|
|
18
17
|
import { check } from "../../contracts/authorize.mjs";
|
|
19
|
-
import * as Clock from "effect/Clock";
|
|
20
|
-
import * as Effect from "effect/Effect";
|
|
21
18
|
import { limits } from "@ref0/infra";
|
|
19
|
+
import * as Effect from "effect/Effect";
|
|
22
20
|
import * as Predicate from "effect/Predicate";
|
|
21
|
+
import * as Clock from "effect/Clock";
|
|
23
22
|
import * as Hex from "effect/encoding/Hex";
|
|
24
23
|
/** The most the objects one write makes hold together. */
|
|
25
24
|
const writeBytesMost = 67108864;
|
|
@@ -112,12 +111,7 @@ const writeDigest = (call, parts) => Effect.promise(async () => {
|
|
|
112
111
|
});
|
|
113
112
|
/** The objects a merge made, read whole into `made`. */
|
|
114
113
|
const takeWrites = /* @__PURE__ */ Effect.fnUntraced(function* (made, writes) {
|
|
115
|
-
const
|
|
116
|
-
const all = [];
|
|
117
|
-
for await (const write of writes) all.push(write);
|
|
118
|
-
return all;
|
|
119
|
-
}, (cause) => gitError("INTERNAL", `The merge's objects failed mid-read: ${String(cause)}`));
|
|
120
|
-
for (const write of held) {
|
|
114
|
+
for (const write of writes) {
|
|
121
115
|
const bytes = yield* Effect.mapError(drained(write, objectBytesMost, { copy: true }), fromDiff("diff-limit"));
|
|
122
116
|
yield* made.add(write.type, new Uint8Array(bytes));
|
|
123
117
|
}
|
package/dist/core/own-writes.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { decodeRow, storeCall } from "../store/errors.mjs";
|
|
2
2
|
import { collections, repoScope } from "../store/scopes.mjs";
|
|
3
3
|
import { dayMs, dayOf, sweepDue, sweepOf } from "./receipts.mjs";
|
|
4
|
-
import * as Effect from "effect/Effect";
|
|
5
4
|
import * as Schema from "effect/Schema";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
6
|
import * as Hex from "effect/encoding/Hex";
|
|
7
7
|
// src/core/own-writes.ts
|
|
8
8
|
/**
|
package/dist/core/parts.d.mts
CHANGED
|
@@ -5,6 +5,8 @@ import { GrantFences } from "../auth/fences.mjs";
|
|
|
5
5
|
import { HeldGrants } from "../auth/grants.mjs";
|
|
6
6
|
import { CursorSeal } from "../store/cursor-seal.mjs";
|
|
7
7
|
import { EventLog } from "../contracts/events.mjs";
|
|
8
|
+
import { RefEdit } from "../contracts/refs.mjs";
|
|
9
|
+
import { GitError } from "../contracts/result.mjs";
|
|
8
10
|
import { HiddenRefs } from "../protocol/wire/lines.mjs";
|
|
9
11
|
import { IndexLost } from "./index-lost.mjs";
|
|
10
12
|
import { PushChecks } from "./access.mjs";
|
|
@@ -14,8 +16,8 @@ import { RefIndex } from "./ref-index.mjs";
|
|
|
14
16
|
import { SealedObjects } from "./view.mjs";
|
|
15
17
|
import { Changes } from "./changes.mjs";
|
|
16
18
|
import { Objects } from "./objects/objects.mjs";
|
|
19
|
+
import { JobDefinition, JobInput, JobQueue, Moment, Records, Row } from "@ref0/infra";
|
|
17
20
|
import * as Effect from "effect/Effect";
|
|
18
|
-
import { JobDefinition, JobInput, JobQueue, Moment, Records } from "@ref0/infra";
|
|
19
21
|
import * as Context from "effect/Context";
|
|
20
22
|
/**
|
|
21
23
|
* A prefix a registration publishes, `RegisterInput.publishes`: refs `Git.host` writes under it on
|
|
@@ -101,6 +103,11 @@ export interface CoreFields {
|
|
|
101
103
|
* another package's job in its commit, as a push saves `sync.mirror`. None on a client.
|
|
102
104
|
*/
|
|
103
105
|
readonly jobOf?: (name: string) => JobDefinition | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* Decodes the repo's `mirrors` rows for a push and answers the `sync.mirror` jobs for the refs
|
|
108
|
+
* the commit moves: wired by the server, none on a client, which holds no mirrors.
|
|
109
|
+
*/
|
|
110
|
+
readonly mirrorJobs?: (rows: readonly Row[], jobOf: (name: string) => JobDefinition | undefined) => Effect.Effect<(moved: readonly RefEdit[]) => readonly JobInput[], GitError>;
|
|
104
111
|
/**
|
|
105
112
|
* `true` on host code's parts (Q223), as `asHost` makes them for `Git.host`'s calls: its list
|
|
106
113
|
* reads every repo, where a signed-out caller's reads only public ones.
|
package/dist/core/parts.mjs
CHANGED
|
@@ -3,10 +3,11 @@ import { hostAuthorize } from "../auth/authorize.mjs";
|
|
|
3
3
|
import { Changes } from "./changes.mjs";
|
|
4
4
|
import { Objects } from "./objects/objects.mjs";
|
|
5
5
|
import { Rules } from "../contracts/rules.mjs";
|
|
6
|
-
import
|
|
6
|
+
import { RequestMemoryBudget } from "../storage/request-cache.mjs";
|
|
7
7
|
import * as Effect from "effect/Effect";
|
|
8
|
-
import * as Option from "effect/Option";
|
|
9
8
|
import * as Context from "effect/Context";
|
|
9
|
+
import * as Option from "effect/Option";
|
|
10
|
+
import * as Clock from "effect/Clock";
|
|
10
11
|
import * as Struct from "effect/Struct";
|
|
11
12
|
// src/core/parts.ts
|
|
12
13
|
/** The server's sealed objects, which each boundary provides beside `CoreParts`. */
|
|
@@ -31,8 +32,11 @@ const coreContext = Effect.gen(function* () {
|
|
|
31
32
|
const authorize = yield* Authorize;
|
|
32
33
|
const clock = yield* Effect.clockWith(Effect.succeed);
|
|
33
34
|
const rules = yield* Effect.serviceOption(Rules);
|
|
34
|
-
const
|
|
35
|
-
|
|
35
|
+
const budget = yield* RequestMemoryBudget;
|
|
36
|
+
let needs = Context.make(CoreParts, parts).pipe(Context.add(ObjectsParts, objects), Context.add(Objects, reads), Context.add(Changes, changes), Context.add(Authorize, authorize), Context.add(Clock.Clock, clock));
|
|
37
|
+
if (Option.isSome(rules)) needs = Context.add(needs, Rules, rules.value);
|
|
38
|
+
if (budget !== void 0) needs = Context.add(needs, RequestMemoryBudget, budget);
|
|
39
|
+
return needs;
|
|
36
40
|
});
|
|
37
41
|
/** `effect` deciding with `check` in `Authorize`'s place, its other answers kept. */
|
|
38
42
|
const decidingWith = (check) => (effect) => Effect.updateService(effect, Authorize, (decider) => ({
|
package/dist/core/purge.mjs
CHANGED
|
@@ -12,9 +12,9 @@ import { collections, newChangeId, repoScope } from "../store/scopes.mjs";
|
|
|
12
12
|
import { droppedDelivery, isDeliverJob, notFailed, sentThrough } from "./events/deliver.mjs";
|
|
13
13
|
import { retiredAmong } from "./events/retired.mjs";
|
|
14
14
|
import { indexJobName } from "./index-job.mjs";
|
|
15
|
-
import
|
|
15
|
+
import { Job, limits } from "@ref0/infra";
|
|
16
16
|
import * as Schema from "effect/Schema";
|
|
17
|
-
import
|
|
17
|
+
import * as Effect from "effect/Effect";
|
|
18
18
|
// src/core/purge.ts
|
|
19
19
|
/**
|
|
20
20
|
* `git.purge`, a deleted repo's last job (L61, L130). Not before its delete's `fetchLimits` has
|
|
@@ -129,6 +129,7 @@ const purgeCollections = [
|
|
|
129
129
|
objectCollections.objects,
|
|
130
130
|
objectCollections.stagedObjects,
|
|
131
131
|
objectCollections.stagedSizes,
|
|
132
|
+
objectCollections.stagedDeltas,
|
|
132
133
|
objectCollections.objectChunks,
|
|
133
134
|
objectCollections.batches,
|
|
134
135
|
objectCollections.batchQuarantine,
|
|
@@ -158,6 +159,24 @@ const PurgeData = /* @__PURE__ */ Schema.Struct({
|
|
|
158
159
|
wait: Schema.optionalKey(WaitKind),
|
|
159
160
|
spins: Schema.optionalKey(Schema.Int)
|
|
160
161
|
});
|
|
162
|
+
/**
|
|
163
|
+
* `parts` as one step, in order: the first that did some answers `did`, and one that waits holds
|
|
164
|
+
* none after it, since each deletes only its own rows and bytes. A deleted repo's drop-in sweep
|
|
165
|
+
* can wait days on its own jobs, and LFS's bytes, behind it by name, would wait with it. Once none
|
|
166
|
+
* did, it waits, naming each part that waits, until every one is done.
|
|
167
|
+
*/
|
|
168
|
+
const stepParts = (parts) => Effect.fnUntraced(function* (store, repo) {
|
|
169
|
+
const named = [];
|
|
170
|
+
let waits = false;
|
|
171
|
+
for (const part of parts) {
|
|
172
|
+
const step = yield* part(store, repo);
|
|
173
|
+
if (step === "did") return step;
|
|
174
|
+
if (step === "waits") waits = true;
|
|
175
|
+
else if (step !== "done") named.push(step.waits);
|
|
176
|
+
}
|
|
177
|
+
if (named.length > 0) return { waits: named.join("', '") };
|
|
178
|
+
return waits ? "waits" : "done";
|
|
179
|
+
});
|
|
161
180
|
const again = { kind: "more" };
|
|
162
181
|
const hasStuckState = (data) => data.since !== void 0 || data.wait !== void 0 || data.spins !== void 0;
|
|
163
182
|
/** Genuine progress made: clears prior stall/spin tracking when any was set. */
|
|
@@ -390,13 +409,7 @@ const dropScopes = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
|
|
|
390
409
|
* A dropped delivery's waiting job made due at `at`: a save moves a waiting job's due only earlier,
|
|
391
410
|
* so a claim takes it. Its handler never runs, since no queue of this server runs its delivery.
|
|
392
411
|
*/
|
|
393
|
-
const droppedDueAt = (item, at) =>
|
|
394
|
-
name: item.name,
|
|
395
|
-
schema: Schema.toStandardSchemaV1(Schema.Unknown),
|
|
396
|
-
handler: () => {
|
|
397
|
-
throw new TypeError(`${item.name} is a delivery this server doesn't run`);
|
|
398
|
-
}
|
|
399
|
-
}).job({
|
|
412
|
+
const droppedDueAt = (item, at) => Job.make(item.name, { payload: Schema.Unknown }).encodedJob({
|
|
400
413
|
key: item.key,
|
|
401
414
|
data: item.data,
|
|
402
415
|
at
|
|
@@ -429,11 +442,12 @@ const endDropped = /* @__PURE__ */ Effect.fnUntraced(function* (store, scope, at
|
|
|
429
442
|
const waiting = dropped.filter((item) => item.state === "waiting");
|
|
430
443
|
const later = waiting.flatMap((item) => item.due > at ? [droppedDueAt(item, at)] : []);
|
|
431
444
|
if (later.length > 0) yield* storeCall(store.add(scope, { jobs: later }));
|
|
432
|
-
const names = waiting.map((item) => item.name);
|
|
433
445
|
const request = {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
446
|
+
names: [...new Set(waiting.map((item) => item.name))].map((name) => ({
|
|
447
|
+
name,
|
|
448
|
+
lease: droppedLease
|
|
449
|
+
})),
|
|
450
|
+
limit: waiting.length
|
|
437
451
|
};
|
|
438
452
|
const { claims } = waiting.length === 0 ? { claims: [] } : yield* storeCall(store.jobs.claim(scope, request));
|
|
439
453
|
const retired = yield* retiredAmong(store, droppedNames(dropped, deliveries));
|
|
@@ -532,10 +546,9 @@ const purgeStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, int
|
|
|
532
546
|
return yield* waitOrFail(scope, data, at, at + purgeBackstop, waiting.kind, "fork-hold", waiting.detail);
|
|
533
547
|
}
|
|
534
548
|
if (drain.dropped && !(yield* endDropped(store, scope, at, deleted, parts.deliveries))) return yield* spinOrFail(scope, data, "end-dropped", "ending dropped delivery jobs");
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
if (step === "did") return progressed(data);
|
|
549
|
+
const step = yield* stepParts(parts.parts)(store, internalId);
|
|
550
|
+
if (step === "did") return progressed(data);
|
|
551
|
+
if (step !== "done") {
|
|
539
552
|
const detail = step === "waits" ? "a purge part waiting" : `purge part '${step.waits}' waiting`;
|
|
540
553
|
return yield* waitOrFail(scope, data, at, at + purgeBackstop, "drain", "part", detail);
|
|
541
554
|
}
|
|
@@ -576,4 +589,4 @@ const purgeJobRow = (job, at) => job.job({
|
|
|
576
589
|
data: {},
|
|
577
590
|
at
|
|
578
591
|
});
|
|
579
|
-
export { purgeBackstop, purgeCollections, purgeDrainLimit, purgeJob, purgeJobKey, purgeJobName, purgeJobRow, purgePage, purgeRunningRelook, purgeStallLimit };
|
|
592
|
+
export { purgeBackstop, purgeCollections, purgeDrainLimit, purgeJob, purgeJobKey, purgeJobName, purgeJobRow, purgePage, purgeRunningRelook, purgeStallLimit, stepParts };
|
package/dist/core/push.d.mts
CHANGED
|
@@ -13,5 +13,5 @@ import "../store/records.mjs";
|
|
|
13
13
|
import "../store/repo-record.mjs";
|
|
14
14
|
import "./access.mjs";
|
|
15
15
|
import "./receipts.mjs";
|
|
16
|
-
import "
|
|
17
|
-
import
|
|
16
|
+
import { JobInput, JobQueue, Key, Moment, Records, Row } from "@ref0/infra";
|
|
17
|
+
import "effect/Effect";
|