@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
|
@@ -17,7 +17,6 @@ import { SavedCallers } from "../core/saved-caller-views.mjs";
|
|
|
17
17
|
import { TopicsBase } from "../topics/base.mjs";
|
|
18
18
|
import { TokensBase } from "../auth/tokens-base.mjs";
|
|
19
19
|
import { QueueBase } from "../queue/base.mjs";
|
|
20
|
-
import { JoinedCalls } from "./joined.mjs";
|
|
21
20
|
import { UploadsBase } from "./uploads.mjs";
|
|
22
21
|
import { BucketUploads } from "@ref0/infra";
|
|
23
22
|
import * as Layer from "effect/Layer";
|
|
@@ -27,7 +26,7 @@ import * as Layer from "effect/Layer";
|
|
|
27
26
|
* `EventStreams` is among them, so a feature's Layer can open a repo's stream as the listen route
|
|
28
27
|
* does. `FeedParts`, which it's built from, stays internal.
|
|
29
28
|
*/
|
|
30
|
-
export type CoreServices = Git | RepoRecords | Authorize | Refs | Objects | Events | CallServices | QueueBase | SyncBase | SavedCallers | ServedParts | LfsBase | UploadsBase | TopicsBase | TokensBase |
|
|
29
|
+
export type CoreServices = Git | RepoRecords | Authorize | Refs | Objects | Events | CallServices | QueueBase | SyncBase | SavedCallers | ServedParts | LfsBase | UploadsBase | TopicsBase | TokensBase | EventStreams;
|
|
31
30
|
/** What `Git.layer` requires: infra's three, the host's `Policy`, and its objects (Q1006). */
|
|
32
31
|
export type GitServices = GitNeeds | Policy | Storage;
|
|
33
32
|
/**
|
|
@@ -9,15 +9,14 @@ import { IndexedStorage, Storage } from "../core/objects/objects.mjs";
|
|
|
9
9
|
import { ServedParts } from "../core/seam.mjs";
|
|
10
10
|
import { refusal } from "../http/answers.mjs";
|
|
11
11
|
import { untilAborted } from "../store/crossing.mjs";
|
|
12
|
-
import { JoinedCalls } from "./joined.mjs";
|
|
13
12
|
import { buildServer } from "./server.mjs";
|
|
14
13
|
import { attachUploads } from "./uploads.mjs";
|
|
15
|
-
import * as Effect from "effect/Effect";
|
|
16
|
-
import * as Option from "effect/Option";
|
|
17
|
-
import * as Cause from "effect/Cause";
|
|
18
14
|
import { Bucket, BucketUploads } from "@ref0/infra";
|
|
15
|
+
import * as Effect from "effect/Effect";
|
|
19
16
|
import * as Context from "effect/Context";
|
|
20
17
|
import * as Layer from "effect/Layer";
|
|
18
|
+
import * as Option from "effect/Option";
|
|
19
|
+
import * as Cause from "effect/Cause";
|
|
21
20
|
// src/server/git-layer.ts
|
|
22
21
|
/** The seal, which `Git.layer`'s last step runs once its features have registered. */
|
|
23
22
|
var Seal = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/Git/Seal")) {};
|
|
@@ -108,7 +107,7 @@ const core = (options) => Layer.effectContext(Effect.gen(function* () {
|
|
|
108
107
|
return (built.bucket === void 0 ? built.services : Context.add(built.services, Bucket.Bucket, built.bucket)).pipe(Context.add(Git, git), Context.add(ServedParts, {
|
|
109
108
|
rest: built.rest,
|
|
110
109
|
needs: built.needs
|
|
111
|
-
}), Context.add(
|
|
110
|
+
}), Context.add(Seal, {
|
|
112
111
|
seal: built.seal,
|
|
113
112
|
retire: built.retire,
|
|
114
113
|
inputs: /* @__PURE__ */ new Map([[Rules.key, Context.get(built.services, Rules)], [PrivateRefs.key, Context.getOrUndefined(context, PrivateRefs)]])
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { gitError, isGitError } from "../contracts/result.mjs";
|
|
2
|
-
import * as Cause from "effect/Cause";
|
|
3
2
|
import { InvalidArgument, Setup } from "@ref0/infra";
|
|
3
|
+
import * as Cause from "effect/Cause";
|
|
4
4
|
// src/server/lifecycle.ts
|
|
5
5
|
/**
|
|
6
6
|
* The server's bounds on rebuilding after a failed build, in ms: the n-th failure waits
|
package/dist/server/registry.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { gitsOwnScopes } from "../contracts/ids.mjs";
|
|
|
2
2
|
import { registeredRows } from "../core/registered-rows.mjs";
|
|
3
3
|
import { ownsScope, registeredRecords } from "../core/registered-records.mjs";
|
|
4
4
|
import { isRefName } from "../core/names.mjs";
|
|
5
|
+
import { stepParts } from "../core/purge.mjs";
|
|
5
6
|
import { gitError, isGitError } from "../contracts/result.mjs";
|
|
6
7
|
import { bindHookGroups } from "../core/hooks/groups.mjs";
|
|
7
8
|
import { bandRank, byOrder, orderedOf } from "../core/hooks/order.mjs";
|
|
@@ -302,14 +303,7 @@ const openRegistry = (served = unserved) => {
|
|
|
302
303
|
at,
|
|
303
304
|
deleted
|
|
304
305
|
})))(store, repo, at, deleted),
|
|
305
|
-
purge: Effect.
|
|
306
|
-
for (const { registration, handler } of ordered(purges)) {
|
|
307
|
-
const step = yield* handler({ repo });
|
|
308
|
-
if (step === "waits") return { waits: registration };
|
|
309
|
-
if (step !== "done") return step;
|
|
310
|
-
}
|
|
311
|
-
return "done";
|
|
312
|
-
}),
|
|
306
|
+
purge: (store, repo) => stepParts(ordered(purges).map(({ registration, handler }) => () => Effect.map(handler({ repo }), (step) => step === "waits" ? { waits: registration } : step)))(store, repo),
|
|
313
307
|
repoScopes: (repo) => Effect.suspend(() => {
|
|
314
308
|
const named = repoScopes.flatMap(({ name, owned, of }) => of(repo).map((scope) => ({
|
|
315
309
|
name,
|
package/dist/server/server.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PrivateRefs } from "../contracts/access.mjs";
|
|
2
2
|
import { pushRefLimitOf } from "../core/push-decide.mjs";
|
|
3
3
|
import { millis } from "../contracts/time.mjs";
|
|
4
|
-
import { fail } from "../contracts/result.mjs";
|
|
4
|
+
import { fail, gitError } from "../contracts/result.mjs";
|
|
5
5
|
import { Authorize } from "../contracts/authorize.mjs";
|
|
6
6
|
import { RepoRecords } from "../contracts/repo-records.mjs";
|
|
7
7
|
import { host } from "../contracts/git.mjs";
|
|
@@ -12,17 +12,17 @@ import { grantFences } from "../auth/fences.mjs";
|
|
|
12
12
|
import { grantAgain, heldGrants } from "../auth/grants.mjs";
|
|
13
13
|
import { identifier } from "../auth/identify.mjs";
|
|
14
14
|
import { tokenCleanupJob } from "../auth/token-cleanup.mjs";
|
|
15
|
-
import { TokensBase
|
|
15
|
+
import { TokensBase } from "../auth/tokens-base.mjs";
|
|
16
16
|
import { blobCalls } from "../core/objects/blobs.mjs";
|
|
17
17
|
import { commitCalls } from "../core/objects/commits.mjs";
|
|
18
18
|
import { fileCalls } from "../core/objects/files.mjs";
|
|
19
19
|
import { mergeCalls } from "../core/objects/merges.mjs";
|
|
20
|
+
import { MergesBase } from "../core/merge-parts.mjs";
|
|
20
21
|
import { tagCalls } from "../core/objects/tags.mjs";
|
|
21
22
|
import { treeCalls } from "../core/objects/trees.mjs";
|
|
22
23
|
import { acting } from "../core/access.mjs";
|
|
23
24
|
import { refIndexOf } from "../core/ref-index.mjs";
|
|
24
|
-
import {
|
|
25
|
-
import { deliveryLog, workFailed } from "../core/events/deliver.mjs";
|
|
25
|
+
import { deliveryLog, deliveryOf, workFailed } from "../core/events/deliver.mjs";
|
|
26
26
|
import { checkRetired, newRetireStart, writeRetired } from "../core/events/retired.mjs";
|
|
27
27
|
import { servedSources } from "../core/rules/protect.mjs";
|
|
28
28
|
import { rulesOf } from "../core/rules/service.mjs";
|
|
@@ -59,19 +59,23 @@ import { doorBucket, doorLinks, doorQueue, doorRecords, doorUploads, throughBrid
|
|
|
59
59
|
import { defaultFetchLimits } from "../storage/fetch.mjs";
|
|
60
60
|
import { countedBucket } from "../storage/counted-bucket.mjs";
|
|
61
61
|
import { hostFailures, hostLinks, hostUploads } from "../storage/host-bucket.mjs";
|
|
62
|
-
import { pushUploadUpkeep } from "../storage/push-uploads.mjs";
|
|
62
|
+
import { pushUploadMost, pushUploadUpkeep } from "../storage/push-uploads.mjs";
|
|
63
|
+
import { stageStepOf } from "../storage/receive-steps.mjs";
|
|
63
64
|
import { checkedLimits, countedMost, hookCallsBefore, lessBefore } from "../store/call-count.mjs";
|
|
64
65
|
import { jobLimitsOf, jobsWithin } from "../store/job-try.mjs";
|
|
66
|
+
import { budgetOfObjects, requestBudgetOf } from "../storage/memory-budget.mjs";
|
|
67
|
+
import { RequestMemoryBudget, serverRequestBudget } from "../storage/request-cache.mjs";
|
|
65
68
|
import { pruneFloor } from "../storage/rows.mjs";
|
|
66
69
|
import { QueueBase, noQueuePush } from "../queue/base.mjs";
|
|
67
70
|
import { TopicsBase } from "../topics/base.mjs";
|
|
68
71
|
import { listJob } from "../store/list-job.mjs";
|
|
72
|
+
import "../store/topic-jobs.mjs";
|
|
69
73
|
import { openExtensions } from "./extension.mjs";
|
|
70
|
-
import { joinedOf } from "./joined.mjs";
|
|
71
74
|
import { retireErrors, retryDelay } from "./lifecycle.mjs";
|
|
72
|
-
import { aroundCalls,
|
|
75
|
+
import { aroundCalls, guardedCall, providedCalls } from "../core/call-groups.mjs";
|
|
73
76
|
import { CoreParts, ObjectsParts, QueueParts, SyncBase } from "../core/parts.mjs";
|
|
74
77
|
import { SavedCallers, savedCallersOf } from "../core/saved-caller-views.mjs";
|
|
78
|
+
import { mirrorJobsOf } from "../core/mirror-rows.mjs";
|
|
75
79
|
import { withAudienceMemo } from "../core/ref-view.mjs";
|
|
76
80
|
import { Changes } from "../core/changes.mjs";
|
|
77
81
|
import { changes } from "../core/rules/changes.mjs";
|
|
@@ -79,14 +83,14 @@ import { SealedObjects, View, objectsOverViews, viewOver } from "../core/view.mj
|
|
|
79
83
|
import { IndexedStorage, Objects, Storage } from "../core/objects/objects.mjs";
|
|
80
84
|
import { pushFilesOf } from "../core/push-files.mjs";
|
|
81
85
|
import { pushRepoOf } from "../core/push-repo.mjs";
|
|
82
|
-
import
|
|
86
|
+
import { Bucket, BucketLinks, BucketUploads, CallLimits, InvalidArgument, JobQueue, Records, RequestLimits } from "@ref0/infra";
|
|
83
87
|
import * as Effect from "effect/Effect";
|
|
88
|
+
import * as Context from "effect/Context";
|
|
84
89
|
import * as Option from "effect/Option";
|
|
85
90
|
import * as Cause from "effect/Cause";
|
|
86
91
|
import * as EffectResult from "effect/Result";
|
|
87
|
-
import { Bucket, BucketLinks, BucketUploads, CallLimits, JobQueue, Records, RequestLimits } from "@ref0/infra";
|
|
88
|
-
import * as Context from "effect/Context";
|
|
89
92
|
import * as References from "effect/References";
|
|
93
|
+
import * as Clock from "effect/Clock";
|
|
90
94
|
import * as Duration from "effect/Duration";
|
|
91
95
|
// src/server/server.ts
|
|
92
96
|
/**
|
|
@@ -117,12 +121,6 @@ const boundOf = (most) => ({
|
|
|
117
121
|
bucket: most?.bucket ?? Number.POSITIVE_INFINITY,
|
|
118
122
|
subrequests: most?.subrequests ?? Number.POSITIVE_INFINITY
|
|
119
123
|
});
|
|
120
|
-
/** The groups a joined face names: every group less `topics`, which is the `Topics` service's. */
|
|
121
|
-
const joinedNamesOf = () => {
|
|
122
|
-
const names = { ...callNames };
|
|
123
|
-
delete names.topics;
|
|
124
|
-
return names;
|
|
125
|
-
};
|
|
126
124
|
/** Git's own wiring over the adapter's services, as the runtime's build runs it. */
|
|
127
125
|
const wireServer = (options, wiring) => {
|
|
128
126
|
const { adapter, fetchLimits, files, repo, deciders, grants, extensions, guard, through, closing } = wiring;
|
|
@@ -141,6 +139,8 @@ const wireServer = (options, wiring) => {
|
|
|
141
139
|
if (wiring.access !== void 0 && options.objects.indexed !== true) throw new TypeError("access hides refs, which needs objects that follow them: pass packs()");
|
|
142
140
|
const indexed = wiring.access === void 0 ? void 0 : indexedOpen(options.objects, opening);
|
|
143
141
|
const objects = indexed ?? options.objects.open(opening);
|
|
142
|
+
const rawBudget = budgetOfObjects(objects);
|
|
143
|
+
const memoryBudget = rawBudget === void 0 ? void 0 : serverRequestBudget(requestBudgetOf(rawBudget));
|
|
144
144
|
const sealed = indexed === void 0 ? new SealedObjects(objects) : SealedObjects.indexed(indexed);
|
|
145
145
|
const cleanup = tokenCleanupJob(store, now);
|
|
146
146
|
const { registry } = extensions;
|
|
@@ -155,7 +155,7 @@ const wireServer = (options, wiring) => {
|
|
|
155
155
|
return events.fill(registered);
|
|
156
156
|
});
|
|
157
157
|
const onFailure = workFailed(store, events, now);
|
|
158
|
-
const upkeep = upkeepsOf([...counted === void 0 ? [] : [pushUploadUpkeep(counted, adapter.uploads)], registry.upkeep]);
|
|
158
|
+
const upkeep = upkeepsOf([...counted === void 0 ? [] : [pushUploadUpkeep(counted, adapter.uploads, stageStepOf(objects))], registry.upkeep]);
|
|
159
159
|
const index = objects.index === void 0 ? void 0 : indexJob({
|
|
160
160
|
store,
|
|
161
161
|
objects: sealed,
|
|
@@ -231,6 +231,7 @@ const wireServer = (options, wiring) => {
|
|
|
231
231
|
repackJobRow: repackRow,
|
|
232
232
|
events,
|
|
233
233
|
jobOf: registry.jobOf,
|
|
234
|
+
mirrorJobs: mirrorJobsOf,
|
|
234
235
|
cursors: cursorSeal(store)
|
|
235
236
|
};
|
|
236
237
|
if (indexRow !== void 0) parts.indexJobRow = indexRow;
|
|
@@ -252,10 +253,6 @@ const wireServer = (options, wiring) => {
|
|
|
252
253
|
grantOf: grants.nameOf,
|
|
253
254
|
grantAgain: ({ resolver, request }) => grantAgain(grants, registry.grants(), resolver, request)
|
|
254
255
|
};
|
|
255
|
-
const records = Context.make(RepoRecords, {
|
|
256
|
-
pin: (name) => pinOf(store, name),
|
|
257
|
-
record: (repo) => hostRecordOf(store, repo)
|
|
258
|
-
});
|
|
259
256
|
const stored = Context.make(Storage, objects).pipe(Context.add(ObjectsParts, {
|
|
260
257
|
objects: sealed,
|
|
261
258
|
fetchLimits,
|
|
@@ -263,7 +260,8 @@ const wireServer = (options, wiring) => {
|
|
|
263
260
|
repo
|
|
264
261
|
}), Context.add(Objects, objectsOverViews), Context.add(Changes, changes));
|
|
265
262
|
const base = Context.make(CoreParts, parts).pipe(Context.add(Rules, wiring.rules), Context.merge(indexed === void 0 ? stored : Context.add(stored, IndexedStorage, indexed)), Context.add(QueueParts, { jobs }), Context.add(Authorize, decider), Context.add(Clock.Clock, runtimeClock), Context.merge(wiring.logging));
|
|
266
|
-
const
|
|
263
|
+
const budgetedBase = memoryBudget === void 0 ? base : Context.add(base, RequestMemoryBudget, memoryBudget);
|
|
264
|
+
const viewed = Context.add(budgetedBase, View, viewOver(budgetedBase));
|
|
267
265
|
const needs = Context.add(viewed, Refs, providedCalls(refsCalls, viewed));
|
|
268
266
|
const streams = streamsOver({
|
|
269
267
|
clock: runtimeClock,
|
|
@@ -277,6 +275,7 @@ const wireServer = (options, wiring) => {
|
|
|
277
275
|
needs,
|
|
278
276
|
onFailure,
|
|
279
277
|
cpuMs: adapter.requestLimits.cpuMs,
|
|
278
|
+
door: guardedCall(wiring.through),
|
|
280
279
|
attach: (queue) => Effect.suspend(() => {
|
|
281
280
|
if (queueHeld.attached !== void 0) return Effect.die(/* @__PURE__ */ new TypeError("The server has a merge queue: provide MergeQueue.layer once"));
|
|
282
281
|
queueHeld.attached = queue;
|
|
@@ -356,10 +355,25 @@ const wireServer = (options, wiring) => {
|
|
|
356
355
|
held: grants,
|
|
357
356
|
now
|
|
358
357
|
});
|
|
359
|
-
const
|
|
358
|
+
const door = guardedCall(wiring.through);
|
|
359
|
+
const doorRecords = RepoRecords.of({
|
|
360
|
+
pin: (name) => door(Effect.suspend(() => pinOf(store, name))),
|
|
361
|
+
record: (repo) => door(Effect.suspend(() => hostRecordOf(store, repo)))
|
|
362
|
+
});
|
|
363
|
+
const doorDecider = {
|
|
364
|
+
check: (request) => door(Effect.suspend(() => decider.check(request))),
|
|
365
|
+
audience: (input) => door(Effect.suspend(() => decider.audience(input))),
|
|
366
|
+
ceiling: (input) => door(Effect.suspend(() => decider.ceiling(input))),
|
|
367
|
+
grantOf: decider.grantOf,
|
|
368
|
+
grantAgain: (input) => door(Effect.suspend(() => decider.grantAgain(input)))
|
|
369
|
+
};
|
|
370
|
+
const decided = Context.make(RepoRecords, doorRecords).pipe(Context.add(Authorize, doorDecider), Context.add(Refs, aroundCalls(Context.get(needs, Refs), (effect) => withAudienceMemo(door(effect), memoryBudget))), Context.add(Rules, wiring.rules), Context.add(Objects, objectsOverViews), Context.merge(callServices(needs, (effect) => withAudienceMemo(guardedCall(wiring.through)(effect), memoryBudget))), Context.add(Events, { log: events }), Context.add(QueueBase, queueBase), Context.add(MergesBase, {
|
|
371
|
+
needs,
|
|
372
|
+
door
|
|
373
|
+
}), Context.add(SyncBase, {
|
|
360
374
|
needs,
|
|
361
375
|
pushRefsMost: pushRefLimitOf(refIndex),
|
|
362
|
-
through: wiring.through
|
|
376
|
+
through: (effect) => wiring.through(withAudienceMemo(effect, memoryBudget))
|
|
363
377
|
}), Context.add(SavedCallers, savedCallersOf(needs, (entry) => queueHeld.attached === void 0 ? Effect.succeed(void 0) : queueHeld.attached.entryAdder(entry))), Context.add(LfsBase, lfsBase), Context.add(UploadsBase, uploadsBase), Context.add(TopicsBase, topicsBase), Context.add(TokensBase, tokensBase));
|
|
364
378
|
const services = Context.add(decided, EventStreams, { feed: streams.feed });
|
|
365
379
|
/**
|
|
@@ -405,7 +419,7 @@ const wireServer = (options, wiring) => {
|
|
|
405
419
|
const clockedIdentify = (request) => Effect.provideService(identify(request), Clock.Clock, runtimeClock);
|
|
406
420
|
const rest = {
|
|
407
421
|
basePath,
|
|
408
|
-
callsFor: (caller) => aroundCalls(
|
|
422
|
+
callsFor: (caller) => aroundCalls(callsAs(caller), (effect) => withAudienceMemo(door(effect), memoryBudget)),
|
|
409
423
|
tokensOn: through(Effect.sync(() => tokensHeld.calls !== void 0)),
|
|
410
424
|
identify: (request) => through(clockedIdentify(request)),
|
|
411
425
|
authorize: (input) => through(Effect.provideContext(seamAuthorize(input), needs)),
|
|
@@ -416,6 +430,7 @@ const wireServer = (options, wiring) => {
|
|
|
416
430
|
const httpOptions = { queue: (...push) => (queueHeld.attached?.push ?? noQueuePush)(...push) };
|
|
417
431
|
if (options.maxDuration !== void 0) httpOptions.maxDuration = millis(options.maxDuration);
|
|
418
432
|
if (objects.pushObjectsMost !== void 0) httpOptions.pushObjectsMost = objects.pushObjectsMost;
|
|
433
|
+
if (objects.stage !== void 0) httpOptions.pushBytesMost = pushUploadMost;
|
|
419
434
|
const fetchHooks = wiring.rules.fetch.length === 0 ? 0 : 1;
|
|
420
435
|
const before = (hooks) => (most) => boundOf(lessBefore(most, {
|
|
421
436
|
bucket: hooks * hookCallsBefore.bucket,
|
|
@@ -425,6 +440,7 @@ const wireServer = (options, wiring) => {
|
|
|
425
440
|
httpOptions.pushCalls = before(0)(callLimits);
|
|
426
441
|
httpOptions.lfs = () => lfsAttached?.service;
|
|
427
442
|
httpOptions.uploads = () => stepping ? uploadsAttached : void 0;
|
|
443
|
+
if (rawBudget !== void 0) httpOptions.snapshotBudget = rawBudget;
|
|
428
444
|
httpParts = make({
|
|
429
445
|
basePath,
|
|
430
446
|
identify: rest.identify,
|
|
@@ -434,6 +450,7 @@ const wireServer = (options, wiring) => {
|
|
|
434
450
|
return {
|
|
435
451
|
rest,
|
|
436
452
|
needs,
|
|
453
|
+
memoryBudget,
|
|
437
454
|
requestMost,
|
|
438
455
|
adapter: { bucket: adapter.bucket },
|
|
439
456
|
callsAs,
|
|
@@ -450,6 +467,23 @@ const wireServer = (options, wiring) => {
|
|
|
450
467
|
ownJobs: own
|
|
451
468
|
};
|
|
452
469
|
};
|
|
470
|
+
/** The option a host lowers for the job named `name`, where the host sets its timeout. */
|
|
471
|
+
const hostTimeoutOf = (name) => {
|
|
472
|
+
if (name === "topics.prepare") return "topics' `prepare` timeout";
|
|
473
|
+
const delivery = deliveryOf(name);
|
|
474
|
+
return delivery === void 0 ? void 0 : `delivery '${delivery}''s timeout`;
|
|
475
|
+
};
|
|
476
|
+
/**
|
|
477
|
+
* `definitions` added to `jobs`, each whose timeout the host sets in a call of its own: a queue
|
|
478
|
+
* whose `longestTry` one passes refuses it as it's added, and the refusal then names what to lower,
|
|
479
|
+
* as an `INVALID_ARGUMENT` whose cause is the queue's (#2900).
|
|
480
|
+
*/
|
|
481
|
+
const addSealed = (jobs, definitions) => {
|
|
482
|
+
const hosts = definitions.filter(({ name }) => hostTimeoutOf(name) !== void 0);
|
|
483
|
+
const rest = definitions.filter(({ name }) => hostTimeoutOf(name) === void 0);
|
|
484
|
+
const named = (definition) => Effect.catchIf(jobs.addJobs(definition), (error) => error instanceof InvalidArgument, (cause) => Effect.fail(gitError("INVALID_ARGUMENT", `Lower ${hostTimeoutOf(definition.name)}: ${cause.message}`, { cause })));
|
|
485
|
+
return Effect.andThen(jobs.addJobs(...rest), Effect.forEach(hosts, named, { discard: true }));
|
|
486
|
+
};
|
|
453
487
|
/** Interrupts as `signal` aborts, as a client that went away or a server that closed stops its run. */
|
|
454
488
|
const interruptedBy = (signal) => Effect.callback((resume) => {
|
|
455
489
|
const interrupt = () => resume(Effect.interrupt);
|
|
@@ -481,9 +515,6 @@ const buildServer = /* @__PURE__ */ Effect.fnUntraced(function* (setup, deciders
|
|
|
481
515
|
const closingWith = (signal) => signal === void 0 ? closing : AbortSignal.any([signal, closing]);
|
|
482
516
|
const tokensHeld = { calls: void 0 };
|
|
483
517
|
const queueHeld = { attached: void 0 };
|
|
484
|
-
const joinedNames = joinedNamesOf();
|
|
485
|
-
const queueOn = () => queueHeld.attached !== void 0;
|
|
486
|
-
const joinedCall = (calls, group, name) => callOrMissing(calls, group, name, () => Effect.fail(noTokens));
|
|
487
518
|
const records = yield* Records.Records;
|
|
488
519
|
const queue = yield* JobQueue.JobQueue;
|
|
489
520
|
const callLimits = yield* CallLimits.CallLimits;
|
|
@@ -534,7 +565,7 @@ const buildServer = /* @__PURE__ */ Effect.fnUntraced(function* (setup, deciders
|
|
|
534
565
|
}));
|
|
535
566
|
const jobLimits = jobLimitsOf(callLimits);
|
|
536
567
|
yield* Effect.orDie(adapter.jobs.addJobs(...jobsWithin(jobLimits, wired.ownJobs)));
|
|
537
|
-
const seal = Effect.flatMap(extensions.registry.seal(), (jobs) => Effect.sync(wired.checkSources).pipe(Effect.andThen(Effect.all(extensions.registry.sealChecks(), { discard: true })), Effect.andThen(Effect.orDie(adapter.jobs
|
|
568
|
+
const seal = Effect.flatMap(extensions.registry.seal(), (jobs) => Effect.sync(wired.checkSources).pipe(Effect.andThen(Effect.all(extensions.registry.sealChecks(), { discard: true })), Effect.andThen(Effect.orDie(addSealed(adapter.jobs, jobsWithin(jobLimits, jobs))))));
|
|
538
569
|
/**
|
|
539
570
|
* `answering`'s answer to `request`, in the caller's fiber, stopped as the client goes away or the
|
|
540
571
|
* server closes. A client that went away, by its signal or mid-body, gets an empty 499, as
|
|
@@ -546,23 +577,12 @@ const buildServer = /* @__PURE__ */ Effect.fnUntraced(function* (setup, deciders
|
|
|
546
577
|
method: request.method,
|
|
547
578
|
path: new URL(request.url).pathname
|
|
548
579
|
})));
|
|
549
|
-
return Effect.suspend(() => isClosed() ? Effect.die(closedError()) : Effect.void).pipe(Effect.andThen(Effect.raceFirst(withAudienceMemo(effect), interruptedBy(closingWith(request.signal)))), Effect.catchCause((cause) => {
|
|
580
|
+
return Effect.suspend(() => isClosed() ? Effect.die(closedError()) : Effect.void).pipe(Effect.andThen(Effect.raceFirst(withAudienceMemo(effect, wired.memoryBudget), interruptedBy(closingWith(request.signal)))), Effect.catchCause((cause) => {
|
|
550
581
|
if (isClosed()) return Effect.die(closedError());
|
|
551
582
|
if (!Cause.hasInterruptsOnly(cause) || !clientWentAway(request)) return Effect.die(Cause.squash(cause));
|
|
552
583
|
return Effect.as(gone, new Response(null, { status: 499 }));
|
|
553
584
|
}), Effect.onInterrupt(() => Effect.andThen(Effect.yieldNow, Effect.suspend(() => !isClosed() && clientWentAway(request) ? gone : Effect.void))), Effect.tap(() => isClosed() ? Effect.die(closedError()) : Effect.void));
|
|
554
585
|
};
|
|
555
|
-
const joined = joinedOf({
|
|
556
|
-
addSealCheck: extensions.registry.addSealCheck,
|
|
557
|
-
basePath,
|
|
558
|
-
fetchLimits,
|
|
559
|
-
get queueKeys() {
|
|
560
|
-
return queueHeld.attached?.host.keys;
|
|
561
|
-
},
|
|
562
|
-
through,
|
|
563
|
-
effectHostCalls: heldGroup(aroundCalls(guardedCalls(lazyGroups(joinedNames, (group, name, args) => Effect.suspend(() => joinedCall(wired.hostCalls, group, name)(...args))), through), withAudienceMemo), "queue", queueOn),
|
|
564
|
-
effectCallsFor: (caller) => heldGroup(lazyGroups(joinedNames, (group, name, args) => guardedCall(through)(Effect.suspend(() => joinedCall(wired.rest.callsFor(caller), group, name)(...args)))), "queue", queueOn)
|
|
565
|
-
}, wired);
|
|
566
586
|
return {
|
|
567
587
|
services: wired.services,
|
|
568
588
|
registry: extensions.registry,
|
|
@@ -572,9 +592,8 @@ const buildServer = /* @__PURE__ */ Effect.fnUntraced(function* (setup, deciders
|
|
|
572
592
|
needs: wired.needs,
|
|
573
593
|
checkFetch: (repo, input) => through(checkFetchOver(wired.needs)(repo, input)),
|
|
574
594
|
bucket: wired.adapter.bucket,
|
|
575
|
-
joined,
|
|
576
595
|
answer: (request) => answering(request, Effect.provideContext(wired.http.route(request), wired.needs)),
|
|
577
|
-
identify: (request) => guardedCall(through)(withAudienceMemo(wired.identify(request)))
|
|
596
|
+
identify: (request) => guardedCall(through)(withAudienceMemo(wired.identify(request), wired.memoryBudget))
|
|
578
597
|
};
|
|
579
598
|
});
|
|
580
599
|
/**
|
|
@@ -3,7 +3,7 @@ import "../contracts/result.mjs";
|
|
|
3
3
|
import "../contracts/signin.mjs";
|
|
4
4
|
import "../auth/tokens.mjs";
|
|
5
5
|
import "./grants.mjs";
|
|
6
|
-
import "effect/Effect";
|
|
7
6
|
import { Moment, Records } from "@ref0/infra";
|
|
7
|
+
import "effect/Effect";
|
|
8
8
|
/** `gh`'s OAuth client ID, which the device flow takes beside the registered clients. */
|
|
9
9
|
export declare const ghClientId = "178c6fc778ccc68e1d6a";
|
package/dist/signin/context.mjs
CHANGED
|
@@ -4,8 +4,8 @@ import { readTarget, tokenExpiry } from "../auth/tokens.mjs";
|
|
|
4
4
|
import { oauthAnswer, oauthError } from "./forms.mjs";
|
|
5
5
|
import { approvalOf } from "./grants.mjs";
|
|
6
6
|
import { accessTokenBody } from "./wire.mjs";
|
|
7
|
-
import * as Effect from "effect/Effect";
|
|
8
7
|
import * as Schema from "effect/Schema";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
9
|
// src/signin/context.ts
|
|
10
10
|
/** `gh`'s OAuth client ID, which the device flow takes beside the registered clients. */
|
|
11
11
|
const ghClientId = "178c6fc778ccc68e1d6a";
|
package/dist/signin/forms.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import { tryUnlessSpent } from "../contracts/calls-spent.mjs";
|
|
|
2
2
|
import { gitError } from "../contracts/result.mjs";
|
|
3
3
|
import { boundedBytes } from "../protocol/bytes/reader.mjs";
|
|
4
4
|
import { accessTokenBody } from "./wire.mjs";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
5
6
|
import * as Effect from "effect/Effect";
|
|
6
7
|
import * as Option from "effect/Option";
|
|
7
|
-
import * as Schema from "effect/Schema";
|
|
8
8
|
// src/signin/forms.ts
|
|
9
9
|
/** The most a sign-in form's body may hold: far more than any of OAuth's needs. */
|
|
10
10
|
const maxBody = 16384;
|
package/dist/signin/grants.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../contracts/ids.mjs";
|
|
2
2
|
import "../contracts/result.mjs";
|
|
3
3
|
import "../contracts/tokens.mjs";
|
|
4
|
-
import "
|
|
4
|
+
import { Moment, Read, Snapshot } from "@ref0/infra";
|
|
5
5
|
import "effect/Schema";
|
|
6
|
-
import
|
|
6
|
+
import "effect/Effect";
|
package/dist/signin/grants.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import { InternalRepoId } from "../contracts/ids.mjs";
|
|
|
2
2
|
import { fail } from "../contracts/result.mjs";
|
|
3
3
|
import { decodeRow } from "../store/errors.mjs";
|
|
4
4
|
import { newChangeId } from "../store/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/signin/grants.ts
|
|
8
8
|
/** Every pending grant's rows, in one scope: each code is found by its hash alone. */
|
|
9
9
|
const signInScope = "git/signin";
|
package/dist/signin/wire.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { growWaits } from "../contracts/object-values.mjs";
|
|
1
2
|
import * as Effect from "effect/Effect";
|
|
2
3
|
import * as Exit from "effect/Exit";
|
|
3
4
|
// src/storage/allotted.ts
|
|
@@ -30,19 +31,13 @@ var AllottedObjects = class {
|
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
32
33
|
* Whether `bytes` more are granted, at once, or an Effect when the allotment waits: `left` once
|
|
33
|
-
* it's full, the refusal when nothing is kept yet. A wait interrupted
|
|
34
|
-
* comes after it.
|
|
34
|
+
* it's full, the refusal when nothing is kept yet. A wait interrupted holds nothing.
|
|
35
35
|
*/
|
|
36
36
|
granted(bytes) {
|
|
37
37
|
if (this.#full) return "left";
|
|
38
38
|
const refused = this.#allotment.grow(bytes);
|
|
39
|
-
if (!(refused
|
|
40
|
-
|
|
41
|
-
refused.then((answered) => {
|
|
42
|
-
if (answered === void 0) this.#allotment.shrink(bytes);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
return Effect.promise(() => refused).pipe(Effect.onInterrupt(() => late), Effect.map((answered) => this.#settled(answered, bytes)));
|
|
39
|
+
if (!growWaits(refused)) return this.#settled(refused, bytes);
|
|
40
|
+
return Effect.map(refused, (answered) => this.#settled(answered, bytes));
|
|
46
41
|
}
|
|
47
42
|
keep(object) {
|
|
48
43
|
this.#answer.set(object.oid, object);
|
|
@@ -8,30 +8,36 @@ import { chunkKeys, chunkedMoved, chunkedOf, chunksPrefix } from "./chunks.mjs";
|
|
|
8
8
|
import { objectCollections } from "./layout.mjs";
|
|
9
9
|
import { heldIdsAt, largeBatch, noRows, objectKey, tooLargeRead } from "./object-rows.mjs";
|
|
10
10
|
import { QuarantineRow } from "./rows.mjs";
|
|
11
|
-
import * as Effect from "effect/Effect";
|
|
12
11
|
import { limits } from "@ref0/infra";
|
|
12
|
+
import * as Effect from "effect/Effect";
|
|
13
13
|
// src/storage/batch-upkeep.ts
|
|
14
14
|
/** The batch quarantine rows one upkeep step reads at most: past it, the next step reads the rest. */
|
|
15
15
|
const quarantinesMost = 64;
|
|
16
|
+
/**
|
|
17
|
+
* The staged rows one upkeep promotion or sweep step reads at most: matches `sweepSizesLimit` and
|
|
18
|
+
* `foldedRows`, well inside `promotable`'s 5,000-write commit budget (3 writes per inline row),
|
|
19
|
+
* falling back to `rowReadBatch` then `largeBatch` past one answer's 16 MiB (#2948).
|
|
20
|
+
*/
|
|
21
|
+
const stagedPageLimit = 1e3;
|
|
16
22
|
/** A step that changes nothing and asks for the next at once: the repo moved under its reads. */
|
|
17
23
|
const readAgain = {
|
|
18
24
|
change: { rows: noRows },
|
|
19
25
|
more: true
|
|
20
26
|
};
|
|
21
|
-
/** One page of a batch's staged rows, `
|
|
22
|
-
const stagedPage = (store, repo, batch, also = []) => {
|
|
23
|
-
const read = (
|
|
27
|
+
/** One page of a batch's staged rows, `limit` or, past 16 MiB, `rowReadBatch` then `largeBatch`. */
|
|
28
|
+
const stagedPage = (store, repo, batch, also = [], limit = stagedPageLimit) => {
|
|
29
|
+
const read = (size) => Effect.map(store.read({
|
|
24
30
|
scope: repoScope(repo),
|
|
25
31
|
reads: [{
|
|
26
32
|
collection: objectCollections.stagedObjects,
|
|
27
33
|
prefix: stagedPrefix(batch),
|
|
28
|
-
limit
|
|
34
|
+
limit: size
|
|
29
35
|
}, ...also]
|
|
30
36
|
}), (snapshot) => ({
|
|
31
37
|
snapshot,
|
|
32
38
|
rows: snapshot.results[0] ?? []
|
|
33
39
|
}));
|
|
34
|
-
return read(100).pipe(Effect.catchIf(tooLargeRead, () => read(largeBatch)));
|
|
40
|
+
return read(limit).pipe(Effect.catchIf(tooLargeRead, () => limit > 100 ? read(100).pipe(Effect.catchIf(tooLargeRead, () => read(largeBatch))) : read(largeBatch)));
|
|
35
41
|
};
|
|
36
42
|
/** One page of an abandoned batch's rows in `collection`, under `prefix`. */
|
|
37
43
|
const prefixPage = (store, repo, collection, prefix, limit) => Effect.map(store.read({
|
|
@@ -51,6 +57,8 @@ const chunksPage = (store, repo, batch) => prefixPage(store, repo, objectCollect
|
|
|
51
57
|
const sweepSizesLimit = 1e3;
|
|
52
58
|
/** One page of an abandoned batch's size markers. */
|
|
53
59
|
const sizesPage = (store, repo, batch) => prefixPage(store, repo, objectCollections.stagedSizes, stagedPrefix(batch), sweepSizesLimit);
|
|
60
|
+
/** One page of a batch's spilled delta parts: `largeBatch` of them, each up to 1 MiB. */
|
|
61
|
+
const deltasPage = (store, repo, batch) => prefixPage(store, repo, objectCollections.stagedDeltas, stagedPrefix(batch), largeBatch);
|
|
54
62
|
/**
|
|
55
63
|
* The writes a staged row may take of a promotion commit: its put (or inline duplicate), staged
|
|
56
64
|
* row delete, size marker delete, and chunks' deletes when a chunked object is a duplicate.
|
|
@@ -83,8 +91,8 @@ const promotable = (rows) => {
|
|
|
83
91
|
* `undefined` once the repo moved between its two reads, since a change from rows read at another
|
|
84
92
|
* version could take a duplicate off the tally twice.
|
|
85
93
|
*/
|
|
86
|
-
const promotionPage = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, batch, also = []) {
|
|
87
|
-
const { snapshot, rows: read } = yield* stagedPage(store, repo, batch, also);
|
|
94
|
+
const promotionPage = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, batch, also = [], limit = stagedPageLimit) {
|
|
95
|
+
const { snapshot, rows: read } = yield* stagedPage(store, repo, batch, also, limit);
|
|
88
96
|
const rows = promotable(read);
|
|
89
97
|
const oids = rows.map(({ id }) => stagedOid(id));
|
|
90
98
|
const held = yield* heldIdsAt(store, repo, snapshot.version, oids);
|
|
@@ -114,7 +122,17 @@ const promotionPage = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo,
|
|
|
114
122
|
value: row.value
|
|
115
123
|
});
|
|
116
124
|
}
|
|
117
|
-
|
|
125
|
+
let done = false;
|
|
126
|
+
if (rows.length === 0) {
|
|
127
|
+
const deltas = yield* deltasPage(store, repo, batch);
|
|
128
|
+
if (deltas.snapshot.version !== snapshot.version) return void 0;
|
|
129
|
+
for (const { collection, id } of deltas.rows) deleted.push({
|
|
130
|
+
collection,
|
|
131
|
+
id
|
|
132
|
+
});
|
|
133
|
+
done = deltas.rows.length < largeBatch;
|
|
134
|
+
if (done) deleted.push(batchKey(batch));
|
|
135
|
+
}
|
|
118
136
|
return {
|
|
119
137
|
change: {
|
|
120
138
|
put,
|
|
@@ -122,7 +140,7 @@ const promotionPage = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo,
|
|
|
122
140
|
rows: dropped
|
|
123
141
|
},
|
|
124
142
|
snapshot,
|
|
125
|
-
done
|
|
143
|
+
done
|
|
126
144
|
};
|
|
127
145
|
});
|
|
128
146
|
/**
|
|
@@ -187,7 +205,8 @@ const maintainBatches = /* @__PURE__ */ Effect.fnUntraced(function* (store, list
|
|
|
187
205
|
for (const page of [
|
|
188
206
|
stagedPage,
|
|
189
207
|
chunksPage,
|
|
190
|
-
sizesPage
|
|
208
|
+
sizesPage,
|
|
209
|
+
deltasPage
|
|
191
210
|
]) {
|
|
192
211
|
const { snapshot, rows } = yield* page(store, repo, batch);
|
|
193
212
|
if (snapshot.version !== version) return { step: readAgain };
|
|
@@ -253,7 +272,7 @@ const looseUpkeep = (store, listed, at) => Effect.map(maintainBatches(store, lis
|
|
|
253
272
|
const promoteOwn = (store, repo, batch, pages) => bestEffort(Effect.gen(function* () {
|
|
254
273
|
const scope = repoScope(repo);
|
|
255
274
|
for (let page = 0; page < pages; page++) {
|
|
256
|
-
const read = yield* promotionPage(store, repo, batch, [looseKey, batchKey(batch)]);
|
|
275
|
+
const read = yield* promotionPage(store, repo, batch, [looseKey, batchKey(batch)], 100);
|
|
257
276
|
if (read === void 0) continue;
|
|
258
277
|
const [, tallyRows = [], batchRows = []] = read.snapshot.results;
|
|
259
278
|
if (batchRows.length === 0) return;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import "../contracts/ids.mjs";
|
|
2
2
|
import "../contracts/objects.mjs";
|
|
3
3
|
import "../contracts/result.mjs";
|
|
4
|
-
import "../contracts/services.mjs";
|
|
5
4
|
import "../contracts/store.mjs";
|
|
6
|
-
import "
|
|
5
|
+
import { Key, Moment, Read, Row } from "@ref0/infra";
|
|
7
6
|
import "effect/Schema";
|
|
8
|
-
import
|
|
7
|
+
import "effect/Effect";
|