@ref0/git 0.20.0 → 0.26.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 +30 -18
- 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 +13 -12
- 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 +145 -98
- 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 +114 -58
- 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/held-types.mjs +13 -4
- package/dist/storage/host-bucket.mjs +9 -4
- package/dist/storage/index-bitmaps.mjs +340 -65
- package/dist/storage/index-build.d.mts +2 -3
- package/dist/storage/index-build.mjs +274 -56
- 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 +24 -18
- 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
package/dist/storage/visible.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { gitError } from "../contracts/result.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { RequestHolding } from "../store/call-count.mjs";
|
|
3
3
|
import { scopedReader, walkObjects } from "./calls.mjs";
|
|
4
|
+
import { RequestMemoryBudget } from "./request-cache.mjs";
|
|
4
5
|
import { onward, stepsOf, wantWalkMost } from "./wants.mjs";
|
|
5
6
|
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Option from "effect/Option";
|
|
6
8
|
import * as Semaphore from "effect/Semaphore";
|
|
7
9
|
// src/storage/visible.ts
|
|
8
10
|
/**
|
|
@@ -29,55 +31,113 @@ const visibleTooLong = (most) => gitError("RESOURCE_EXHAUSTED", `${tooLongText}
|
|
|
29
31
|
});
|
|
30
32
|
/** Whether `error` is a set's refusal past its walk's bound, which a caller may tell in its own words. */
|
|
31
33
|
const isVisibleTooLong = (error) => error.code === "RESOURCE_EXHAUSTED" && error.message.startsWith(tooLongText);
|
|
34
|
+
/** Hard byte ceiling for one `walkedVisible` walk's passed set (8 MiB, ~87k OIDs). */
|
|
35
|
+
const walkedVisibleBytes = 8388608;
|
|
36
|
+
/** Plain bounded OID set used only when no server `RequestMemoryBudget` is present (e.g. local client). */
|
|
37
|
+
const boundedPassedSet = (maxEntries) => {
|
|
38
|
+
const set = /* @__PURE__ */ new Set();
|
|
39
|
+
return {
|
|
40
|
+
has: (oid) => set.has(oid),
|
|
41
|
+
add: (oid) => {
|
|
42
|
+
if (set.has(oid)) return true;
|
|
43
|
+
if (set.size >= maxEntries) return false;
|
|
44
|
+
set.add(oid);
|
|
45
|
+
return true;
|
|
46
|
+
},
|
|
47
|
+
release: () => set.clear()
|
|
48
|
+
};
|
|
49
|
+
};
|
|
32
50
|
/**
|
|
33
51
|
* The objects `input.tips` reach in `listed`, through no parent of `input.roots`, read through
|
|
34
52
|
* `objects`, the repo's whole objects.
|
|
35
|
-
* Nothing is read until the set is first asked
|
|
36
|
-
* one request's view, for one caller, and is
|
|
37
|
-
*
|
|
38
|
-
* next reads on from the same frontier: a passing
|
|
53
|
+
* Nothing is read or charged until the set is first asked: unqueried sets never register a room.
|
|
54
|
+
* Its walk's state is the set's own: it lives with one request's view, for one caller, and is
|
|
55
|
+
* never shared across callers. A batch of the walk that fails to read changes none of it, so an
|
|
56
|
+
* ask that fails leaves the set as it was, and the next reads on from the same frontier: a passing
|
|
57
|
+
* failure never answers an object as hidden. If budget pressure evicts the room, the whole walk
|
|
58
|
+
* (including any in-flight answer) is invalidated so the in-flight `has` fails closed and the next
|
|
59
|
+
* ask rebuilds coherently from `input.tips`.
|
|
39
60
|
*/
|
|
40
61
|
const walkedVisible = (objects, listed, input, walk = {}) => {
|
|
41
62
|
const { most = wantWalkMost, commits = false } = walk;
|
|
42
63
|
const tips = new Set(input.tips);
|
|
43
|
-
const
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
|
|
64
|
+
const maxEntries = Math.floor(walkedVisibleBytes / 96);
|
|
65
|
+
let kept;
|
|
66
|
+
const openState = (serverBudget, hold) => {
|
|
67
|
+
let state;
|
|
68
|
+
const onEvict = () => {
|
|
69
|
+
state.evicted = true;
|
|
70
|
+
state.exhausted = true;
|
|
71
|
+
state.passed.release();
|
|
72
|
+
if (kept === state) kept = void 0;
|
|
73
|
+
};
|
|
74
|
+
const opened = serverBudget === void 0 ? {
|
|
75
|
+
passed: boundedPassedSet(maxEntries),
|
|
76
|
+
kept: true
|
|
77
|
+
} : serverBudget.openWalkPassed(walkedVisibleBytes, 96, maxEntries, hold, onEvict);
|
|
78
|
+
state = {
|
|
79
|
+
passed: opened.passed,
|
|
80
|
+
frontier: [],
|
|
81
|
+
reads: 0,
|
|
82
|
+
exhausted: false,
|
|
83
|
+
evicted: false
|
|
84
|
+
};
|
|
85
|
+
if (!opened.kept) return {
|
|
86
|
+
state,
|
|
87
|
+
kept: false
|
|
88
|
+
};
|
|
89
|
+
for (const tip of tips) {
|
|
90
|
+
if (!state.passed.add(tip)) {
|
|
91
|
+
state.exhausted = true;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
state.frontier.push(tip);
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
state,
|
|
98
|
+
kept: true
|
|
99
|
+
};
|
|
100
|
+
};
|
|
47
101
|
const turn = Semaphore.makeUnsafe(1).withPermits(1);
|
|
48
102
|
/** Reads on from the frontier until every one of `left` is passed or the walk ends. */
|
|
49
|
-
const walkFor = Effect.fnUntraced(function* (walk, left, signal) {
|
|
103
|
+
const walkFor = Effect.fnUntraced(function* (state, walk, left, signal) {
|
|
104
|
+
if (state.evicted || left.size > 0 && state.exhausted) return yield* Effect.fail(visibleTooLong(most));
|
|
50
105
|
const call = signal === void 0 ? {} : { signal };
|
|
51
|
-
while (left.size > 0 && frontier.length > 0) {
|
|
52
|
-
const batch = frontier.slice(0, walkBatch);
|
|
53
|
-
exhausted ||= reads + batch.length > most;
|
|
54
|
-
if (exhausted) return yield* Effect.fail(visibleTooLong(most));
|
|
106
|
+
while (left.size > 0 && state.frontier.length > 0) {
|
|
107
|
+
const batch = state.frontier.slice(0, walkBatch);
|
|
108
|
+
state.exhausted ||= state.reads + batch.length > most;
|
|
109
|
+
if (state.exhausted) return yield* Effect.fail(visibleTooLong(most));
|
|
55
110
|
const stepped = (oid) => Effect.flatMap(walk.read(listed, {
|
|
56
111
|
oid,
|
|
57
112
|
...call
|
|
58
113
|
}), (object) => object === void 0 ? Effect.succeed(void 0) : stepsOf(object, !commits, input.roots));
|
|
59
114
|
const found = yield* Effect.forEach(batch, stepped, { concurrency: 16 });
|
|
60
|
-
|
|
61
|
-
|
|
115
|
+
if (state.evicted) return yield* Effect.fail(visibleTooLong(most));
|
|
116
|
+
state.frontier = state.frontier.slice(walkBatch);
|
|
117
|
+
state.reads += batch.length;
|
|
62
118
|
for (const steps of found) {
|
|
63
119
|
if (steps === void 0) continue;
|
|
64
|
-
|
|
65
|
-
if (passed.has(oid))
|
|
66
|
-
passed.add(oid);
|
|
120
|
+
const record = (oid, push) => {
|
|
121
|
+
if (state.passed.has(oid)) return true;
|
|
122
|
+
if (!state.passed.add(oid)) return false;
|
|
67
123
|
left.delete(oid);
|
|
68
|
-
frontier.push(oid);
|
|
124
|
+
if (push) state.frontier.push(oid);
|
|
125
|
+
return true;
|
|
126
|
+
};
|
|
127
|
+
for (const oid of onward(steps)) if (!record(oid, true)) {
|
|
128
|
+
state.exhausted = true;
|
|
129
|
+
return yield* Effect.fail(visibleTooLong(most));
|
|
69
130
|
}
|
|
70
|
-
for (const oid of steps.reached) {
|
|
71
|
-
|
|
72
|
-
|
|
131
|
+
for (const oid of steps.reached) if (!record(oid, false)) {
|
|
132
|
+
state.exhausted = true;
|
|
133
|
+
return yield* Effect.fail(visibleTooLong(most));
|
|
73
134
|
}
|
|
74
135
|
}
|
|
75
136
|
}
|
|
76
137
|
});
|
|
77
|
-
|
|
78
|
-
const answerEffect = (oids, leaving, signal) => turn(Effect.gen(function* () {
|
|
138
|
+
const query = Effect.fnUntraced(function* (state, oids, leaving, signal) {
|
|
79
139
|
const asked = [...new Set(oids)];
|
|
80
|
-
const unknown = asked.filter((oid) => !passed.has(oid));
|
|
140
|
+
const unknown = asked.filter((oid) => !state.passed.has(oid));
|
|
81
141
|
if (unknown.length > 0) {
|
|
82
142
|
const call = signal === void 0 ? {} : { signal };
|
|
83
143
|
const walked = Effect.scoped(Effect.gen(function* () {
|
|
@@ -86,11 +146,30 @@ const walkedVisible = (objects, listed, input, walk = {}) => {
|
|
|
86
146
|
oids: unknown,
|
|
87
147
|
...call
|
|
88
148
|
});
|
|
89
|
-
|
|
149
|
+
if (state.evicted) return yield* Effect.fail(visibleTooLong(most));
|
|
150
|
+
yield* walkFor(state, walk, new Set(unknown.filter((oid) => held.has(oid))), signal);
|
|
90
151
|
}));
|
|
91
152
|
yield* leaving ? Effect.catchIf(walked, isVisibleTooLong, () => Effect.void) : walked;
|
|
92
153
|
}
|
|
93
|
-
|
|
154
|
+
if (state.evicted && !leaving) return yield* Effect.fail(visibleTooLong(most));
|
|
155
|
+
return new Set(asked.filter((oid) => state.passed.has(oid)));
|
|
156
|
+
});
|
|
157
|
+
/** `oids` the walk passes; with `leaving`, past `most` the rest are left out, not refused. */
|
|
158
|
+
const answerEffect = (oids, leaving, signal) => turn(Effect.gen(function* () {
|
|
159
|
+
const requestHold = yield* Effect.serviceOption(RequestHolding);
|
|
160
|
+
const serverBudget = walk.budget ?? (yield* RequestMemoryBudget);
|
|
161
|
+
if (Option.isSome(requestHold)) {
|
|
162
|
+
if (kept !== void 0) return yield* query(kept, oids, leaving, signal);
|
|
163
|
+
const opened = openState(serverBudget, requestHold.value);
|
|
164
|
+
if (opened.kept) {
|
|
165
|
+
kept = opened.state;
|
|
166
|
+
requestHold.value.keep(Effect.sync(() => {
|
|
167
|
+
if (kept === opened.state) kept = void 0;
|
|
168
|
+
}));
|
|
169
|
+
return yield* query(opened.state, oids, leaving, signal);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return yield* Effect.acquireUseRelease(Effect.sync(() => openState(serverBudget).state), (state) => query(state, oids, leaving, signal), (state) => Effect.sync(() => state.passed.release()));
|
|
94
173
|
}));
|
|
95
174
|
const has = (oids, call) => answerEffect(oids, false, call?.signal);
|
|
96
175
|
const shown = (oids, call) => answerEffect(oids, true, call?.signal);
|
|
@@ -168,11 +247,10 @@ const withPushed = (set, objects, own) => {
|
|
|
168
247
|
const face = objects;
|
|
169
248
|
const hasEffect = (oids, asked, signal) => Effect.scoped(Effect.gen(function* () {
|
|
170
249
|
const call = signal === void 0 ? {} : { signal };
|
|
171
|
-
const
|
|
172
|
-
const brought = yield* resultCall(() => reader.headers({
|
|
250
|
+
const brought = yield* (yield* scopedReader(face, own, { listedOnly: true })).headers({
|
|
173
251
|
oids,
|
|
174
252
|
...call
|
|
175
|
-
})
|
|
253
|
+
});
|
|
176
254
|
const rest = oids.filter((oid) => !brought.has(oid));
|
|
177
255
|
const seen = rest.length === 0 ? /* @__PURE__ */ new Set() : yield* asked(rest, call);
|
|
178
256
|
return /* @__PURE__ */ new Set([...brought.keys(), ...seen]);
|
|
@@ -182,4 +260,4 @@ const withPushed = (set, objects, own) => {
|
|
|
182
260
|
shown: (oids, call) => hasEffect(oids, set.shown, call?.signal)
|
|
183
261
|
};
|
|
184
262
|
};
|
|
185
|
-
export { isVisibleTooLong, notReachable, seenFetch, visibleOf, walkedRoots, walkedVisible, withPushed };
|
|
263
|
+
export { isVisibleTooLong, notReachable, seenFetch, visibleOf, walkedRoots, walkedVisible, walkedVisibleBytes, withPushed };
|
package/dist/storage/walk.mjs
CHANGED
|
@@ -183,6 +183,7 @@ const countedReads = (reads, readsMost, charge, calls, release) => {
|
|
|
183
183
|
const letGoReads = (objects) => given(objects * 370);
|
|
184
184
|
const placed = {};
|
|
185
185
|
if (reads.indexed !== void 0) placed.indexed = reads.indexed;
|
|
186
|
+
if (reads.cachedIndex !== void 0) placed.cachedIndex = reads.cachedIndex;
|
|
186
187
|
if (reads.loadedOf !== void 0) placed.loadedOf = reads.loadedOf;
|
|
187
188
|
if (reads.onLoading !== void 0) placed.onLoading = reads.onLoading;
|
|
188
189
|
if (reads.heldAt !== void 0) placed.heldAt = reads.heldAt;
|
package/dist/storage/wants.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { objectsReadMost } from "../contracts/object-values.mjs";
|
|
2
2
|
import { gitError } from "../contracts/result.mjs";
|
|
3
3
|
import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
4
|
+
import { boundedBytes, scopedReader } from "../protocol/bytes/reader.mjs";
|
|
4
5
|
import { decodeCommit, noRepoRoots, parentsWithin } from "../protocol/objects/commit.mjs";
|
|
5
6
|
import { decodeTag, readTagTarget } from "../protocol/objects/tag.mjs";
|
|
6
7
|
import { oidBytes } from "../protocol/packs/idx.mjs";
|
|
@@ -37,53 +38,23 @@ const setMarks = () => {
|
|
|
37
38
|
return true;
|
|
38
39
|
} };
|
|
39
40
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
this.error = error;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
41
|
+
const readFailed = (oid) => (cause) => gitError("UNAVAILABLE", `Object ${oid} couldn't be read`, {
|
|
42
|
+
cause,
|
|
43
|
+
hint: "Fetch again"
|
|
44
|
+
});
|
|
47
45
|
/**
|
|
48
46
|
* `object`'s bytes, read whole into one buffer of its header's size, `packObjectBytes` at most:
|
|
49
47
|
* past that it's refused before a read, and a stream that gives more or less than its size is
|
|
50
48
|
* `DATA_LOSS`. Its stream is cancelled, without waiting, if the read stops short, as when it's
|
|
51
49
|
* interrupted, and its reader let go however it ends.
|
|
52
50
|
*/
|
|
53
|
-
const bytesOf = (object)
|
|
54
|
-
if (object.size > 16777216) return Effect.fail(objectTooLarge(object));
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
stop();
|
|
61
|
-
reader.releaseLock();
|
|
62
|
-
};
|
|
63
|
-
let length = 0;
|
|
64
|
-
let done = false;
|
|
65
|
-
signal.addEventListener("abort", interrupted, { once: true });
|
|
66
|
-
try {
|
|
67
|
-
for (;;) {
|
|
68
|
-
const read = await reader.read();
|
|
69
|
-
if (read.done) break;
|
|
70
|
-
if (read.value.byteLength > object.size - length) throw new Unheld(unreadable(object, `it has more than its ${object.size} bytes`));
|
|
71
|
-
whole.set(read.value, length);
|
|
72
|
-
length += read.value.byteLength;
|
|
73
|
-
}
|
|
74
|
-
done = true;
|
|
75
|
-
if (length < object.size) throw new Unheld(unreadable(object, `it has ${length} of its ${object.size} bytes`));
|
|
76
|
-
return whole;
|
|
77
|
-
} finally {
|
|
78
|
-
signal.removeEventListener("abort", interrupted);
|
|
79
|
-
if (!done) stop();
|
|
80
|
-
reader.releaseLock();
|
|
81
|
-
}
|
|
82
|
-
}, (cause) => cause instanceof Unheld ? cause.error : gitError("UNAVAILABLE", `Object ${object.oid} couldn't be read`, {
|
|
83
|
-
cause,
|
|
84
|
-
hint: "Fetch again"
|
|
85
|
-
}));
|
|
86
|
-
};
|
|
51
|
+
const bytesOf = /* @__PURE__ */ Effect.fnUntraced(function* (object) {
|
|
52
|
+
if (object.size > 16777216) return yield* Effect.fail(objectTooLarge(object));
|
|
53
|
+
const whole = yield* boundedBytes(object.bytes, object.size, (reader) => tryUnlessSpent(() => reader.read(), readFailed(object.oid)));
|
|
54
|
+
if (whole === void 0) return yield* Effect.fail(unreadable(object, `it has more than its ${object.size} bytes`));
|
|
55
|
+
if (whole.byteLength < object.size) return yield* Effect.fail(unreadable(object, `it has ${whole.byteLength} of its ${object.size} bytes`));
|
|
56
|
+
return whole;
|
|
57
|
+
});
|
|
87
58
|
/** `bytesOf`'s refusal of an object past what it holds whole. */
|
|
88
59
|
const objectTooLarge = (object) => gitError("RESOURCE_EXHAUSTED", `Object ${object.oid} is past the ${packObjectBytes} bytes this server reads whole`, { context: { reason: "object-too-large" } });
|
|
89
60
|
const unreadable = (object, message) => gitError("DATA_LOSS", `The ${object.type} ${object.oid} is unreadable: ${message}`);
|
|
@@ -393,26 +364,19 @@ const unpeelable = (oid, message) => gitError("DATA_LOSS", `The tag ${oid} can't
|
|
|
393
364
|
* `object`'s first `most` bytes, or all of them when there are no more: what's past them is never
|
|
394
365
|
* read, and the stream is cancelled. It holds `most` bytes, and a chunk at a time.
|
|
395
366
|
*/
|
|
396
|
-
const firstBytes =
|
|
397
|
-
const reader = object.bytes
|
|
367
|
+
const firstBytes = /* @__PURE__ */ Effect.fnUntraced(function* (object, most) {
|
|
368
|
+
const reader = yield* scopedReader(object.bytes);
|
|
398
369
|
const head = new Uint8Array(most);
|
|
399
370
|
let length = 0;
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
length += taken;
|
|
407
|
-
}
|
|
408
|
-
return head;
|
|
409
|
-
} finally {
|
|
410
|
-
await reader.cancel().catch(() => void 0);
|
|
371
|
+
while (length < most) {
|
|
372
|
+
const { done, value } = yield* tryUnlessSpent(() => reader.read(), readFailed(object.oid));
|
|
373
|
+
if (done) return head.subarray(0, length);
|
|
374
|
+
const taken = Math.min(value.byteLength, most - length);
|
|
375
|
+
head.set(value.subarray(0, taken), length);
|
|
376
|
+
length += taken;
|
|
411
377
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
hint: "Fetch again"
|
|
415
|
-
}));
|
|
378
|
+
return head;
|
|
379
|
+
}, Effect.scoped);
|
|
416
380
|
/** What `bytes` of the tag `oid` name, or why a peel can't say. */
|
|
417
381
|
const lookedOf = (oid, bytes) => {
|
|
418
382
|
const read = readTagTarget(bytes);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { CallAllowance } from "../contracts/call-allowance.mjs";
|
|
2
2
|
import "../contracts/calls-spent.mjs";
|
|
3
3
|
import "../contracts/objects.mjs";
|
|
4
|
-
import * as Effect from "effect/Effect";
|
|
5
|
-
import * as HttpClient from "effect/http/HttpClient";
|
|
6
4
|
import { CallLimits } from "@ref0/infra";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
7
6
|
import * as Context from "effect/Context";
|
|
8
7
|
import * as Layer from "effect/Layer";
|
|
8
|
+
import * as HttpClient from "effect/http/HttpClient";
|
|
9
9
|
import "effect/Types";
|
|
10
10
|
/** Calls by the two kinds a platform caps: to the bucket, and of every kind, the bucket's among them. */
|
|
11
11
|
export interface CallCount {
|
|
@@ -1,31 +1,44 @@
|
|
|
1
1
|
import { CallAllowance, allowanceHooks } from "../contracts/call-allowance.mjs";
|
|
2
2
|
import { CallsSpent } from "../contracts/calls-spent.mjs";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
|
-
import * as HttpClient from "effect/http/HttpClient";
|
|
5
|
-
import * as Option from "effect/Option";
|
|
6
4
|
import * as Predicate from "effect/Predicate";
|
|
7
5
|
import * as Context from "effect/Context";
|
|
8
6
|
import * as Layer from "effect/Layer";
|
|
7
|
+
import * as Option from "effect/Option";
|
|
8
|
+
import * as HttpClient from "effect/http/HttpClient";
|
|
9
9
|
import * as References from "effect/References";
|
|
10
10
|
// src/store/call-count.ts
|
|
11
11
|
/**
|
|
12
12
|
* The store calls a Git fetch's request makes before its count starts, which its `callLimits`
|
|
13
|
-
* leave room for:
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
13
|
+
* leave room for: `identify`'s read of a Git token's row, for a `gt_` bearer, plus any calls
|
|
14
|
+
* Cloudflare's deployed Worker makes before the count, and no bucket call. Every call from the
|
|
15
|
+
* serve on counts on the request's one count, the repo's record, its refs, its haves and its tags'
|
|
16
|
+
* peels with its pack's (#709).
|
|
17
|
+
*
|
|
18
|
+
* Deployed reading (#1903): `ci-bench` run https://github.com/ref-0/git/actions/runs/46844130312
|
|
19
|
+
* (benched at `a427c89`, colo `FRA`): `fetch-calls-before-rows` read 2–2 calls before the count
|
|
20
|
+
* (`n=6`) and `fetch-calls-before-packs` read 2–2 (`n=12`), all non-overlapped. Margin rule (EM,
|
|
21
|
+
* 2 Dec): max across the batch's clean runs + 1 = 3.
|
|
22
|
+
* That reserves room for the calls the deployed path makes, not a worst case: a Records call
|
|
23
|
+
* retried before the count, `identify`'s token read or the catalogue read the count charges once,
|
|
24
|
+
* makes up to 4 tries each, which this reading doesn't hold.
|
|
25
|
+
*
|
|
26
|
+
* The host's own `auth` and grants aren't Git's calls: a host whose run subrequests sets
|
|
18
27
|
* `callLimits` lower by them. Its fetch rules are `hookCallsBefore`'s.
|
|
19
28
|
*/
|
|
20
29
|
const requestCallsBefore = {
|
|
21
30
|
bucket: 0,
|
|
22
|
-
subrequests:
|
|
31
|
+
subrequests: 3
|
|
23
32
|
};
|
|
24
33
|
/**
|
|
25
34
|
* The calls one of the host's hooks makes before a Git request's count starts, beside
|
|
26
|
-
* `requestCallsBefore`'s: the fetch rules, on a fetch.
|
|
27
|
-
*
|
|
28
|
-
*
|
|
35
|
+
* `requestCallsBefore`'s: the fetch rules, on a fetch.
|
|
36
|
+
*
|
|
37
|
+
* Deployed reading (#1903): `ci-bench` run https://github.com/ref-0/git/actions/runs/46844130312
|
|
38
|
+
* (benched at `a427c89`, colo `FRA`): `fetch-calls-before-rule` read 3–3 calls before the count
|
|
39
|
+
* (`n=12`, non-overlapped; 1 host call above `rows`/`packs`'s 2). With `requestCallsBefore`'s 3,
|
|
40
|
+
* adding 1 reserves 4 calls before the count for a hooked fetch (max 3 + 1). A hook that makes
|
|
41
|
+
* more sets `callLimits` lower by them.
|
|
29
42
|
*/
|
|
30
43
|
const hookCallsBefore = {
|
|
31
44
|
bucket: 0,
|
|
@@ -3,8 +3,8 @@ import "../contracts/repos.mjs";
|
|
|
3
3
|
import "../contracts/result.mjs";
|
|
4
4
|
import { SettledName } from "./outbox.mjs";
|
|
5
5
|
import { CatalogueEntry, StoredRepo } from "./records.mjs";
|
|
6
|
-
import "effect/Effect";
|
|
7
6
|
import { JobInput, Key, Listing, Page, Read, Records, Row, Snapshot } from "@ref0/infra";
|
|
7
|
+
import "effect/Effect";
|
|
8
8
|
import "effect/Context";
|
|
9
9
|
import "effect/Types";
|
|
10
10
|
/**
|
package/dist/store/catalogue.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { isInternalId } from "../contracts/ids.mjs";
|
|
2
2
|
import { fail } from "../contracts/result.mjs";
|
|
3
|
-
import { countMadeAhead } from "./call-count.mjs";
|
|
4
3
|
import { decodeDerivedRow, decodeRow, storeCall, storeCommit } from "./errors.mjs";
|
|
5
4
|
import { CatalogueEntry, CreatedRow, ForkRow, StoredRepo, keyKept, takenBack } from "./records.mjs";
|
|
5
|
+
import { RequestSnapshot } from "./request-snapshot.mjs";
|
|
6
6
|
import { catalogueScope, collections, forkId, newChangeId, repoScope, selfKey } from "./scopes.mjs";
|
|
7
|
-
import * as Effect from "effect/Effect";
|
|
8
7
|
import { limits } from "@ref0/infra";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
9
|
import * as Context from "effect/Context";
|
|
10
10
|
// src/store/catalogue.ts
|
|
11
11
|
/** How many times a projection reads and commits again when another name's write moved first. */
|
|
@@ -487,6 +487,7 @@ const resolveTries = 3;
|
|
|
487
487
|
/** `name`, which the catalogue gives `record`: the one constructor of a `SettledName`. */
|
|
488
488
|
const settledName = (name) => name;
|
|
489
489
|
const EntryAhead = Context.Reference("@ref0/git/EntryAhead", { defaultValue: () => void 0 });
|
|
490
|
+
const RepoRecordAhead = Context.Reference("@ref0/git/RepoRecordAhead", { defaultValue: () => void 0 });
|
|
490
491
|
/**
|
|
491
492
|
* The repo `name` names now, read from its scope with `reads` at one version, with the name
|
|
492
493
|
* settled: its entry is the record's, revision and all. One the record doesn't hold yet, such as a
|
|
@@ -497,13 +498,24 @@ const EntryAhead = Context.Reference("@ref0/git/EntryAhead", { defaultValue: ()
|
|
|
497
498
|
*/
|
|
498
499
|
const resolveRepo = /* @__PURE__ */ Effect.fnUntraced(function* (store, name, reads = []) {
|
|
499
500
|
const ahead = yield* EntryAhead;
|
|
501
|
+
const recordAhead = yield* RepoRecordAhead;
|
|
502
|
+
const reqSnapshot = yield* RequestSnapshot;
|
|
500
503
|
for (let attempt = 0; attempt < resolveTries; attempt += 1) {
|
|
501
|
-
const
|
|
502
|
-
if (taken !== void 0) yield* countMadeAhead("store", 1);
|
|
503
|
-
const entry = yield* taken ?? entryOf(store, name);
|
|
504
|
+
const entry = yield* (attempt === 0 && ahead?.name === name ? ahead.take() : void 0) ?? entryOf(store, name);
|
|
504
505
|
if (entry === void 0 || entry.deleted === true) return yield* notFound(name, entry);
|
|
505
506
|
const { internalId } = entry;
|
|
506
|
-
const
|
|
507
|
+
const preRead = attempt === 0 && reads.length === 0 ? recordAhead?.take() : void 0;
|
|
508
|
+
if (preRead !== void 0 && preRead.internalId === internalId && preRead.record.deleted !== true && preRead.record.name === name && holdsName(internalId, preRead.record, entry)) return {
|
|
509
|
+
name: settledName(name),
|
|
510
|
+
internalId,
|
|
511
|
+
entry,
|
|
512
|
+
record: preRead.record,
|
|
513
|
+
snapshot: preRead.snapshot
|
|
514
|
+
};
|
|
515
|
+
const scope = repoScope(internalId);
|
|
516
|
+
const baseReads = [selfKey, ...reads];
|
|
517
|
+
const readRepo = (asked) => storeCall(store.read(scope, asked));
|
|
518
|
+
const snapshot = yield* attempt === 0 && reads.length > 0 && reqSnapshot?.readFirst !== void 0 ? reqSnapshot.readFirst(scope, baseReads, readRepo) : readRepo(baseReads);
|
|
507
519
|
const record = yield* decodeRecord(snapshot.results[0]?.[0]);
|
|
508
520
|
if (record === void 0 || record.deleted === true || record.name !== name) return yield* notFound(name, void 0);
|
|
509
521
|
if (holdsName(internalId, record, entry)) return {
|
|
@@ -838,4 +850,4 @@ const forksCreated = /* @__PURE__ */ Effect.fnUntraced(function* (store, source,
|
|
|
838
850
|
});
|
|
839
851
|
/** A repo's `createdKey`, from its record now: `undefined` for an ID of none. */
|
|
840
852
|
const createdKeyOf = (store, internalId) => Effect.map(recordAt(store, internalId), (read) => read === void 0 ? void 0 : createdKey(internalId, read.record.createdAt));
|
|
841
|
-
export { EntryAhead, checkChurn, createdKey, createdKeyOf, decodeRecord, entryOf, folderPrefix, foldersOf, forkFolderPrefix, forkKey, forkOf, forkedFrom, forksCreated, heldName, heldNameAt, hostRecordOf, internalIdOf, isCreatedKey, lands, listCreated, listLimit, listNames, listPublic, nameOf, namedRecordOf, pinOf, project, projectionOf, readEntries, reconcile, recordAt, redirectOf, releaseHold, resolveRepo, upstreamOf };
|
|
853
|
+
export { EntryAhead, RepoRecordAhead, checkChurn, createdKey, createdKeyOf, decodeRecord, entryOf, folderPrefix, foldersOf, forkFolderPrefix, forkKey, forkOf, forkedFrom, forksCreated, heldName, heldNameAt, hostRecordOf, internalIdOf, isCreatedKey, lands, listCreated, listLimit, listNames, listPublic, nameOf, namedRecordOf, pinOf, project, projectionOf, readEntries, reconcile, recordAt, redirectOf, releaseHold, resolveRepo, upstreamOf };
|
package/dist/store/crossing.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { inCallScope } from "./call-count.mjs";
|
|
2
|
-
import { answerOf } from "../contracts/calls-spent.mjs";
|
|
3
2
|
import * as Effect from "effect/Effect";
|
|
4
3
|
import * as Stream from "effect/Stream";
|
|
5
4
|
// src/store/crossing.ts
|
|
@@ -23,11 +22,6 @@ const optionsOf = (signal) => signal === void 0 ? {} : { signal };
|
|
|
23
22
|
const runIn = (effect, crossing, signal) => Effect.runPromise(scoped(effect, crossing), optionsOf(signal));
|
|
24
23
|
/** `effect`'s `Exit` as a Promise, run in `crossing`. */
|
|
25
24
|
const exitIn = (effect, crossing, signal) => Effect.runPromiseExit(scoped(effect, crossing), optionsOf(signal));
|
|
26
|
-
/**
|
|
27
|
-
* An Effect at a Promise surface, run in `crossing`: its failure as data. A call `signal`
|
|
28
|
-
* interrupted throws the signal's reason, and a defect throws as it is.
|
|
29
|
-
*/
|
|
30
|
-
const resultIn = async (effect, crossing, signal) => answerOf(await exitIn(effect, crossing, signal), signal);
|
|
31
25
|
/** `effect` started on a fiber of its own, run in `crossing`. */
|
|
32
26
|
const forkIn = (effect, crossing) => Effect.runFork(scoped(effect, crossing));
|
|
33
27
|
/** `effect`, which must not wait, run now in `crossing`. */
|
|
@@ -58,4 +52,4 @@ const untilAborted = (effect, signal) => {
|
|
|
58
52
|
});
|
|
59
53
|
return Effect.raceFirst(effect, aborted);
|
|
60
54
|
};
|
|
61
|
-
export { Uncounted, exitIn, forkIn, noCall, readableIn,
|
|
55
|
+
export { Uncounted, exitIn, forkIn, noCall, readableIn, runIn, runnerIn, syncIn, uncounted, untilAborted };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GitError } from "../contracts/result.mjs";
|
|
2
|
-
import * as Effect from "effect/Effect";
|
|
3
2
|
import { Addition, Read, Records, Scope, Snapshot } from "@ref0/infra";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
4
|
/** What a seal keeps its key with: a store's reads and adds in its scope, failing as `GitError`. */
|
|
5
5
|
export interface SealRecords {
|
|
6
6
|
readonly read: (scope: Scope, reads: readonly Read[]) => Effect.Effect<Snapshot, GitError>;
|
|
@@ -2,8 +2,8 @@ import { fail } from "../contracts/result.mjs";
|
|
|
2
2
|
import { decodeRow, storeCall } from "./errors.mjs";
|
|
3
3
|
import { bytesFromBase64Url, randomText, toBase64Url, utf8Of } from "./random.mjs";
|
|
4
4
|
import { catalogueScope, collections } from "./scopes.mjs";
|
|
5
|
-
import * as Effect from "effect/Effect";
|
|
6
5
|
import * as Schema from "effect/Schema";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
7
|
// src/store/cursor-seal.ts
|
|
8
8
|
/** The row in a seal's scope that holds the key its cursors are sealed with: `git/repos`' for Git's lists. */
|
|
9
9
|
const cursorKeyRow = {
|
package/dist/store/door.mjs
CHANGED
|
@@ -2,11 +2,11 @@ import { bodyUntilAborted } from "./bodies.mjs";
|
|
|
2
2
|
import { closedError, isServerClosed } from "./closed.mjs";
|
|
3
3
|
import { JobLanded } from "./job-try.mjs";
|
|
4
4
|
import { forkIn, noCall } from "./crossing.mjs";
|
|
5
|
-
import * as Effect from "effect/Effect";
|
|
6
|
-
import * as Exit from "effect/Exit";
|
|
7
5
|
import { JobGate } from "@ref0/infra";
|
|
8
|
-
import * as
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
9
7
|
import * as Stream from "effect/Stream";
|
|
8
|
+
import * as Context from "effect/Context";
|
|
9
|
+
import * as Exit from "effect/Exit";
|
|
10
10
|
import * as Scope$1 from "effect/Scope";
|
|
11
11
|
import * as Scheduler from "effect/Scheduler";
|
|
12
12
|
// src/store/door.ts
|
|
@@ -104,6 +104,7 @@ const doorRecords = (records, context, door) => {
|
|
|
104
104
|
*/
|
|
105
105
|
const doorBucket = (bucket, context, door) => {
|
|
106
106
|
const { call } = doorOf(context, door);
|
|
107
|
+
const through = (fn) => (...args) => call(fn(...args));
|
|
107
108
|
return {
|
|
108
109
|
...bucket,
|
|
109
110
|
put: (key, body, options) => call(bucket.put(key, body, options)),
|
|
@@ -114,7 +115,11 @@ const doorBucket = (bucket, context, door) => {
|
|
|
114
115
|
}),
|
|
115
116
|
remove: (key) => call(bucket.remove(key)),
|
|
116
117
|
removeMany: (keys, options) => call(bucket.removeMany(keys, options)),
|
|
117
|
-
list: (prefix, page) => call(bucket.list(prefix, page))
|
|
118
|
+
list: (prefix, page) => call(bucket.list(prefix, page)),
|
|
119
|
+
beginPut: through(bucket.beginPut),
|
|
120
|
+
putPart: through(bucket.putPart),
|
|
121
|
+
completePut: through(bucket.completePut),
|
|
122
|
+
abortPut: through(bucket.abortPut)
|
|
118
123
|
};
|
|
119
124
|
};
|
|
120
125
|
/** `body`, which errors with the close's error once `door` closes, as `bodyUntilAborted` says. */
|
package/dist/store/errors.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GitError } from "../contracts/result.mjs";
|
|
2
|
-
import * as Effect from "effect/Effect";
|
|
3
|
-
import "effect/Schema";
|
|
4
2
|
import { Row } from "@ref0/infra";
|
|
3
|
+
import "effect/Schema";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
5
|
import "effect/Stream";
|
|
6
6
|
/**
|
|
7
7
|
* A store call, its refusal as Git's error: one of the two doors every call Git makes goes
|