@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/core/ref-view.mjs
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { fail } from "../contracts/result.mjs";
|
|
2
2
|
import { readToken, tokenState } from "../auth/token-rows.mjs";
|
|
3
|
+
import { chargedCache } from "../storage/charged-cache.mjs";
|
|
4
|
+
import { RequestMemoryBudget, requestChargeOf } from "../storage/request-cache.mjs";
|
|
3
5
|
import { withRequestHold } from "../store/call-count.mjs";
|
|
4
6
|
import { CoreParts } from "./parts.mjs";
|
|
5
7
|
import { ownedAway } from "../protocol/wire/lines.mjs";
|
|
6
8
|
import { Authorize, audience, check, grantOf } from "../contracts/authorize.mjs";
|
|
7
|
-
import * as Clock from "effect/Clock";
|
|
8
|
-
import * as Effect from "effect/Effect";
|
|
9
|
-
import * as Option from "effect/Option";
|
|
10
9
|
import { byBytes } from "@ref0/infra";
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
11
|
import * as Context from "effect/Context";
|
|
12
|
+
import * as Option from "effect/Option";
|
|
13
|
+
import * as Clock from "effect/Clock";
|
|
12
14
|
// src/core/ref-view.ts
|
|
13
15
|
/**
|
|
14
16
|
* What a caller who reads every pattern, or any caller of a server with no `access`, sees. It has
|
|
@@ -24,25 +26,65 @@ const wholeView = {
|
|
|
24
26
|
reads: () => true,
|
|
25
27
|
publishes: () => true
|
|
26
28
|
};
|
|
29
|
+
/** Byte ceiling for a request's `AudienceMemo` (64 KiB). */
|
|
30
|
+
const audienceMemoBytes = 65536;
|
|
31
|
+
/** Byte ceiling for a request's `ViewedMemo` (256 KiB). */
|
|
32
|
+
const viewedMemoBytes = 262144;
|
|
33
|
+
/**
|
|
34
|
+
* Conservative payload weight for an `AudienceMemo` entry: key string, base closures, every
|
|
35
|
+
* configured private pattern (covering `read`/`publish` Sets and `hidden` entries in `refViewOf`),
|
|
36
|
+
* and every hidden Git prefix compiled into `gitsOwn`. Charged up front before `ask` resolves so
|
|
37
|
+
* completed `Effect.cached` results never sit uncharged in memory.
|
|
38
|
+
*/
|
|
39
|
+
const audiencePayloadBytes = (entry, key) => {
|
|
40
|
+
let bytes = key.length * 2 + 256;
|
|
41
|
+
for (const pattern of entry.patterns) bytes += pattern.length * 2 + 64;
|
|
42
|
+
for (const prefix of entry.hidden) bytes += prefix.length * 2 + 128;
|
|
43
|
+
return bytes;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Conservative payload weight for a `ViewedMemo` entry: key string, wrapper closures, and the
|
|
47
|
+
* retained `tips` set (`walkedVisible`'s own walk set charges its separate `requestRoom`).
|
|
48
|
+
*/
|
|
49
|
+
const viewedPayloadBytes = (entry, key) => key.length * 2 + 256 + entry.tips * 96;
|
|
27
50
|
/**
|
|
28
51
|
* A request's `refs.private` answers, by repo and caller, so a request asks once for each however
|
|
29
52
|
* many times it opens a repo: a write opens it twice, and 10,000 refs make one call.
|
|
30
|
-
* `withAudienceMemo` starts
|
|
53
|
+
* `withAudienceMemo` starts a bounded, charged cache for each call and each HTTP request.
|
|
31
54
|
*/
|
|
32
55
|
const AudienceMemo = /* @__PURE__ */ Context.Service("@ref0/git/AudienceMemo");
|
|
33
56
|
/**
|
|
34
|
-
* A request's narrowed objects, by repo, caller and
|
|
35
|
-
* are read once a request: a write that opens a repo twice, or a fetch's want
|
|
36
|
-
* share one set. Like `AudienceMemo`, one serves one call or one request,
|
|
37
|
-
*
|
|
38
|
-
* tips reach.
|
|
57
|
+
* A request's narrowed objects, by repo, caller, version and canonical tip set, so the objects a
|
|
58
|
+
* caller's refs reach are read once a request: a write that opens a repo twice, or a fetch's want
|
|
59
|
+
* check and its plan, share one set. Like `AudienceMemo`, one serves one call or one request,
|
|
60
|
+
* never two callers, and is bounded and charged to the request's `MemoryBudget`.
|
|
39
61
|
*/
|
|
40
62
|
const ViewedMemo = /* @__PURE__ */ Context.Service("@ref0/git/ViewedMemo");
|
|
63
|
+
const makeMemo = (budget, maxBytes, maxEntries, weight) => chargedCache(requestChargeOf(budget, maxBytes), {
|
|
64
|
+
maxBytes,
|
|
65
|
+
maxEntries,
|
|
66
|
+
entryOverhead: 96,
|
|
67
|
+
weight,
|
|
68
|
+
evict: "lru"
|
|
69
|
+
});
|
|
70
|
+
/**
|
|
71
|
+
* `effect` with bounded, charged memos of its own for `refs.private`'s answers and the objects
|
|
72
|
+
* they narrow to, and a hold for what its sets keep until it ends (`RequestHold`). Both memos
|
|
73
|
+
* charge `budget`, or `RequestMemoryBudget` from context, and release on exit, error, or interrupt.
|
|
74
|
+
*/
|
|
75
|
+
const withAudienceMemo = (effect, budget) => Effect.flatMap(budget !== void 0 ? Effect.succeed(budget) : RequestMemoryBudget, (active) => Effect.acquireUseRelease(Effect.sync(() => ({
|
|
76
|
+
audience: makeMemo(active, audienceMemoBytes, 64, audiencePayloadBytes),
|
|
77
|
+
viewed: makeMemo(active, viewedMemoBytes, 32, viewedPayloadBytes)
|
|
78
|
+
})), ({ audience, viewed }) => withRequestHold(effect.pipe(Effect.provideService(AudienceMemo, audience), Effect.provideService(ViewedMemo, viewed))), ({ audience, viewed }) => Effect.sync(() => {
|
|
79
|
+
audience.release();
|
|
80
|
+
viewed.release();
|
|
81
|
+
})));
|
|
41
82
|
/**
|
|
42
|
-
* `effect`
|
|
43
|
-
*
|
|
83
|
+
* `effect` run outside any outer `AudienceMemo` and cached once for its own caller's reuse, as
|
|
84
|
+
* `viewOf(..., { fresh: true })` asks `refs.private` anew once per page without keeping an
|
|
85
|
+
* uncharged map.
|
|
44
86
|
*/
|
|
45
|
-
const
|
|
87
|
+
const freshRefView = (effect) => Effect.cached(Effect.updateContext(effect, (context) => Context.omit(AudienceMemo)(context)));
|
|
46
88
|
/**
|
|
47
89
|
* The objects `caller` reads of a repo at `version` from `tips`, `make`'s, kept for the request.
|
|
48
90
|
* A held set is answered only for the same tips, compared in full as sets, so a tip named twice
|
|
@@ -52,21 +94,16 @@ const withAudienceMemo = (effect) => Effect.suspend(() => withRequestHold(effect
|
|
|
52
94
|
*/
|
|
53
95
|
const viewedIn = /* @__PURE__ */ Effect.fnUntraced(function* (caller, internalId, version, tips, make) {
|
|
54
96
|
const memo = yield* Effect.serviceOption(ViewedMemo);
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const held = entries?.find((entry) => entry.tips.size === asked.size && tips.every((tip) => entry.tips.has(tip)));
|
|
97
|
+
const asked = [...new Set(tips)].toSorted();
|
|
98
|
+
const key = `${yield* memoKey(internalId, caller)}@${version}\0${asked.join(",")}`;
|
|
99
|
+
const held = Option.isSome(memo) ? memo.value.get(key) : void 0;
|
|
59
100
|
if (held !== void 0) return held.objects;
|
|
60
101
|
const made = make();
|
|
61
102
|
if (made === void 0) return yield* fail("INTERNAL", "access hides objects, which needs objects that keep an index");
|
|
62
|
-
if (Option.isSome(memo)) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
67
|
-
if (entries === void 0) memo.value.set(key, [entry]);
|
|
68
|
-
else entries.push(entry);
|
|
69
|
-
}
|
|
103
|
+
if (Option.isSome(memo)) memo.value.set(key, {
|
|
104
|
+
objects: made,
|
|
105
|
+
tips: asked.length
|
|
106
|
+
});
|
|
70
107
|
return made;
|
|
71
108
|
});
|
|
72
109
|
/**
|
|
@@ -156,11 +193,15 @@ const askedRefView = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo)
|
|
|
156
193
|
if (Option.isNone(memo)) return yield* ask;
|
|
157
194
|
const key = yield* memoKey(repo.internalId, caller);
|
|
158
195
|
const held = memo.value.get(key);
|
|
159
|
-
if (held !== void 0) return yield* held;
|
|
196
|
+
if (held !== void 0) return yield* held.effect;
|
|
160
197
|
const once = yield* Effect.cached(ask);
|
|
161
198
|
const raced = memo.value.get(key);
|
|
162
|
-
if (raced !== void 0) return yield* raced;
|
|
163
|
-
memo.value.set(key,
|
|
199
|
+
if (raced !== void 0) return yield* raced.effect;
|
|
200
|
+
memo.value.set(key, {
|
|
201
|
+
effect: once,
|
|
202
|
+
patterns: access.patterns,
|
|
203
|
+
hidden
|
|
204
|
+
});
|
|
164
205
|
return yield* once;
|
|
165
206
|
});
|
|
166
207
|
/**
|
|
@@ -170,7 +211,7 @@ const askedRefView = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo)
|
|
|
170
211
|
* an event stream's batch or a listing's page (Q884), so a right lost, a repo made private or a
|
|
171
212
|
* token revoked or past its expiry since the read opened refuses the next part.
|
|
172
213
|
*/
|
|
173
|
-
const accessAgain = /* @__PURE__ */ Effect.fnUntraced(function* (caller, kind, repo) {
|
|
214
|
+
const accessAgain = /* @__PURE__ */ Effect.fnUntraced(function* (caller, kind, repo, read = readToken) {
|
|
174
215
|
const core = yield* CoreParts;
|
|
175
216
|
yield* check({
|
|
176
217
|
caller,
|
|
@@ -180,10 +221,12 @@ const accessAgain = /* @__PURE__ */ Effect.fnUntraced(function* (caller, kind, r
|
|
|
180
221
|
},
|
|
181
222
|
repo
|
|
182
223
|
});
|
|
183
|
-
|
|
184
|
-
|
|
224
|
+
const { token } = caller;
|
|
225
|
+
if (token !== void 0) {
|
|
226
|
+
const held = yield* read(core.store, token.id);
|
|
185
227
|
const now = yield* Clock.currentTimeMillis;
|
|
186
228
|
if (!(held !== void 0 && tokenState(held.row, now) === "active")) return yield* fail("UNAUTHENTICATED", "The token is revoked or past its expiry");
|
|
229
|
+
return held;
|
|
187
230
|
}
|
|
188
231
|
});
|
|
189
232
|
/**
|
|
@@ -206,4 +249,4 @@ const creatingRefView = /* @__PURE__ */ Effect.fnUntraced(function* (caller, nam
|
|
|
206
249
|
const { access, hiddenRefs } = yield* CoreParts;
|
|
207
250
|
return yield* askRefView(access, caller, { creating: name }, prefixesOf(hiddenRefs()));
|
|
208
251
|
});
|
|
209
|
-
export { AudienceMemo, ViewedMemo, accessAgain, anyOwned, creatingRefView, ownedSpans, refViewAgain, refViewIn, viewedIn, wholeView, withAudienceMemo };
|
|
252
|
+
export { AudienceMemo, ViewedMemo, accessAgain, anyOwned, audienceMemoBytes, creatingRefView, freshRefView, ownedSpans, refViewAgain, refViewIn, viewedIn, viewedMemoBytes, wholeView, withAudienceMemo };
|
package/dist/core/refs.mjs
CHANGED
|
@@ -24,9 +24,9 @@ import { fail } from "../contracts/result.mjs";
|
|
|
24
24
|
import { CoreParts, ObjectsParts } from "./parts.mjs";
|
|
25
25
|
import { bypassKinds, hostAuthorize } from "../auth/authorize.mjs";
|
|
26
26
|
import { Authorize, check } from "../contracts/authorize.mjs";
|
|
27
|
-
import * as Clock from "effect/Clock";
|
|
28
|
-
import * as Effect from "effect/Effect";
|
|
29
27
|
import { byBytes, jsonBytes, limits } from "@ref0/infra";
|
|
28
|
+
import * as Effect from "effect/Effect";
|
|
29
|
+
import * as Clock from "effect/Clock";
|
|
30
30
|
const maxRefLimit = 1e3;
|
|
31
31
|
/**
|
|
32
32
|
* The most ranges one store call of a listing's page reads under `access`. Each span the caller
|
|
@@ -34,7 +34,7 @@ const maxRefLimit = 1e3;
|
|
|
34
34
|
* a registered one, so there are at most as many as those. Each gives the gap after it a read by
|
|
35
35
|
* ID and a read after it, the cursor's gap adds one, and each classed pattern the caller reads adds
|
|
36
36
|
* its range of the ref index. A pattern is a span or a class, never both, so 64 patterns and 8
|
|
37
|
-
* registered prefixes give
|
|
37
|
+
* registered prefixes give 149, with Git's two own (#668).
|
|
38
38
|
*/
|
|
39
39
|
const refListRangesMost = 2 * (72 + gitsOwnRefs.length) + 1;
|
|
40
40
|
/** A longest ref name, of `"` past `refs/`, which JSON doubles. */
|
package/dist/core/repack.mjs
CHANGED
|
@@ -2,17 +2,16 @@ import { keepsEvents } from "../contracts/events.mjs";
|
|
|
2
2
|
import { fail } from "../contracts/result.mjs";
|
|
3
3
|
import { bestEffort, decodeRow, storeCall, storeCommit, thrownError } from "../store/errors.mjs";
|
|
4
4
|
import { untilAborted } from "../store/crossing.mjs";
|
|
5
|
-
import { gitJob } from "../store/job-try.mjs";
|
|
5
|
+
import { gitJob, jobTryTimeout } from "../store/job-try.mjs";
|
|
6
6
|
import { decodePacks, featureChange, packRow, tryGitStore } from "../store/git-store.mjs";
|
|
7
7
|
import { appendEvents, decodeOutbox, outboxReads, repoEnvelope } from "../store/outbox.mjs";
|
|
8
|
-
import { decodeStats,
|
|
8
|
+
import { decodeStats, looseRows, readRecord, repoStats, timeRow } from "../store/repo-record.mjs";
|
|
9
9
|
import { settleName } from "../store/settle.mjs";
|
|
10
10
|
import { replacedAtCommit } from "../storage/index-remap.mjs";
|
|
11
|
-
import { indexRowKey, isPackId, objectCollections } from "../storage/layout.mjs";
|
|
11
|
+
import { indexRowKey, isPackId, objectCollections, prunePassKey } from "../storage/layout.mjs";
|
|
12
12
|
import { listedIds } from "../storage/listed-ids.mjs";
|
|
13
13
|
import { noRows } from "../storage/object-rows.mjs";
|
|
14
14
|
import { ReadyRow, readyBytesOf } from "../storage/ready.mjs";
|
|
15
|
-
import { prunePassKey } from "../storage/prune.mjs";
|
|
16
15
|
import { ApartRow, apartAfter, apartKey } from "../storage/repack-contained.mjs";
|
|
17
16
|
import { SwapsSettled, swapsKey, swapsLeft } from "../storage/swap-walk.mjs";
|
|
18
17
|
import { QuarantineRow, decodeHeld, decodeLeft, deletedLeaveAt, isLeftKey, leavingKey, leavingLate, leavingRow, leftPack } from "../storage/rows.mjs";
|
|
@@ -25,9 +24,10 @@ import { importLive } from "./imports.mjs";
|
|
|
25
24
|
import { ownSweepOf, ownSweepRead } from "./own-writes.mjs";
|
|
26
25
|
import { sweepOf, sweepRead } from "./receipts.mjs";
|
|
27
26
|
import { heldId, isAbandon, isReadyPut, isTake, ownRows, stillTakes } from "./still-takes.mjs";
|
|
27
|
+
import { deletedRowsHold } from "./loose-tally.mjs";
|
|
28
28
|
import { SealedObjects } from "./view.mjs";
|
|
29
|
-
import * as Effect from "effect/Effect";
|
|
30
29
|
import { CurrentJob, Job, jobLeaseMargin } from "@ref0/infra";
|
|
30
|
+
import * as Effect from "effect/Effect";
|
|
31
31
|
import * as Predicate from "effect/Predicate";
|
|
32
32
|
// src/core/repack.ts
|
|
33
33
|
/** Upkeep keeps every ref's objects, private or not: it reads the repo whole. */
|
|
@@ -398,6 +398,8 @@ const commitStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
|
|
|
398
398
|
const { add = [], remove = [] } = step?.change ?? {};
|
|
399
399
|
const moves = (add.length > 0 || remove.length > 0) && !deleted;
|
|
400
400
|
const pruning = (laid.length > 0 || !moves || read.index === void 0 ? laid : [read.index]).flatMap((row) => index === void 0 || indexJobRow === void 0 ? [] : indexJobs({ indexJobRow }, index.status(row, now, listing)));
|
|
401
|
+
const batchPromoted = !deleted && (step?.change.delete ?? []).some((key) => key.collection === objectCollections.batches);
|
|
402
|
+
const wokenIndex = pruning.length > 0 || !batchPromoted || index === void 0 || indexJobRow === void 0 ? [] : indexJobs({ indexJobRow }, index.status(read.index, now, listing));
|
|
401
403
|
const apart = [...apartAfter(read.apart, step?.change ?? { rows: noRows }), ...swapsLeft(read.swaps, step?.change ?? { rows: noRows })];
|
|
402
404
|
const pass = step?.prune === void 0 || deleted ? [] : [pruneJobRow(step.prune)];
|
|
403
405
|
const loose = looseRows(read.times.loose, step?.change.rows ?? noRows);
|
|
@@ -421,6 +423,7 @@ const commitStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
|
|
|
421
423
|
jobs: [
|
|
422
424
|
...report.jobs,
|
|
423
425
|
...pruning,
|
|
426
|
+
...wokenIndex,
|
|
424
427
|
...pass,
|
|
425
428
|
...others
|
|
426
429
|
]
|
|
@@ -551,6 +554,20 @@ const repackStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
|
|
|
551
554
|
if (step?.yielded === true) return void 0;
|
|
552
555
|
let read = first;
|
|
553
556
|
for (let tries = 1;; tries += 1) {
|
|
557
|
+
if (read === void 0) {
|
|
558
|
+
if (step === void 0 || tries > 5) return again;
|
|
559
|
+
const keys = rereadKeys(step);
|
|
560
|
+
if (keys === void 0) return again;
|
|
561
|
+
const reread = yield* readStep(store, internalId, keys);
|
|
562
|
+
if (reread === void 0 || !stillTakes(reread, step)) return again;
|
|
563
|
+
if (step.change.rows.objects < 0 || step.change.rows.bytes < 0) {
|
|
564
|
+
const held = yield* deletedRowsHold(store, internalId, step.change, reread.version);
|
|
565
|
+
if (held === "gone") return again;
|
|
566
|
+
if (held === "moved") continue;
|
|
567
|
+
}
|
|
568
|
+
if (yield* settles(parts, store, internalId, reread)) return again;
|
|
569
|
+
read = reread;
|
|
570
|
+
}
|
|
554
571
|
const committed = yield* commitStep(parts, store, internalId, read, step, at, read === first, first.index);
|
|
555
572
|
if (committed.ok) {
|
|
556
573
|
if (step?.parks !== void 0) return yield* Effect.fail(step.parks);
|
|
@@ -581,12 +598,7 @@ const repackStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
|
|
|
581
598
|
data: { missed: missed + 1 }
|
|
582
599
|
} : again;
|
|
583
600
|
if (step === void 0 || tries >= 5) return again;
|
|
584
|
-
|
|
585
|
-
if (keys === void 0) return again;
|
|
586
|
-
const reread = yield* readStep(store, internalId, keys);
|
|
587
|
-
if (reread === void 0 || !stillTakes(reread, step)) return again;
|
|
588
|
-
if (yield* settles(parts, store, internalId, reread)) return again;
|
|
589
|
-
read = reread;
|
|
601
|
+
read = void 0;
|
|
590
602
|
}
|
|
591
603
|
});
|
|
592
604
|
/**
|
|
@@ -658,11 +670,9 @@ const repackRetry = (failure) => {
|
|
|
658
670
|
* instead, as `repackStep` says, so a busy repo's prune pass ends without dropping and never
|
|
659
671
|
* fails the job. One at a time in each process, so upkeep never takes a host's every core.
|
|
660
672
|
*/
|
|
661
|
-
/** A `git.repack` try's timeout, in ms. */
|
|
662
|
-
const repackTimeout = 78e4;
|
|
663
673
|
const RepackJob = /* @__PURE__ */ Job.make(repackJobName, {
|
|
664
674
|
payload: RepackData,
|
|
665
|
-
timeout:
|
|
675
|
+
timeout: jobTryTimeout,
|
|
666
676
|
concurrency: 1,
|
|
667
677
|
retry: repackRetry,
|
|
668
678
|
rebuild: () => ({})
|
|
@@ -680,19 +690,4 @@ const repackJobRow = (job, at) => job.job(at === void 0 ? {
|
|
|
680
690
|
data: {},
|
|
681
691
|
at
|
|
682
692
|
});
|
|
683
|
-
|
|
684
|
-
* The repo's `git.repack` row made due, for a push refused `packs-awaiting-repack`, so its hint
|
|
685
|
-
* holds: added if it's gone, and retried if it spent its tries, since an add leaves a failed row
|
|
686
|
-
* failed, its data rebuilt once it has compacted. A row already waiting or running is left as it is.
|
|
687
|
-
* A repo deleted since the push read it takes none, as its purge may have dropped its scope (#1911).
|
|
688
|
-
*/
|
|
689
|
-
const ensureRepack = /* @__PURE__ */ Effect.fnUntraced(function* (core, jobs, repo, fetchLimits) {
|
|
690
|
-
if (!(yield* heldAdd(heldStore(core.store), repo, fetchLimits, { jobs: [core.repackJobRow()] }).pipe(Effect.as(true), Effect.catchTag("RepoGone", () => Effect.succeed(false))))) return;
|
|
691
|
-
const scope = repoScope(repo);
|
|
692
|
-
const job = {
|
|
693
|
-
name: repackJobName,
|
|
694
|
-
key: repackJobKey
|
|
695
|
-
};
|
|
696
|
-
yield* storeCall(jobs.retry(scope, job)).pipe(Effect.catchIf(notFailed, () => Effect.void));
|
|
697
|
-
});
|
|
698
|
-
export { ensureRepack, leavingPage, passParked, repackJob, repackJobRow, repackSlowJitter, repackSlowWait, repackTimeout, upkeepsOf };
|
|
693
|
+
export { leavingPage, passParked, repackJob, repackJobRow, repackSlowJitter, repackSlowWait, upkeepsOf };
|
package/dist/core/repo-info.mjs
CHANGED
|
@@ -10,8 +10,8 @@ import { anyOwned, refViewIn, wholeView } from "./ref-view.mjs";
|
|
|
10
10
|
import { SealedObjects } from "./view.mjs";
|
|
11
11
|
import { CoreParts, ObjectsParts, QueueParts } from "./parts.mjs";
|
|
12
12
|
import { check } from "../contracts/authorize.mjs";
|
|
13
|
-
import * as Clock from "effect/Clock";
|
|
14
13
|
import * as Effect from "effect/Effect";
|
|
14
|
+
import * as Clock from "effect/Clock";
|
|
15
15
|
// src/core/repo-info.ts
|
|
16
16
|
/**
|
|
17
17
|
* A repo's info, as `repos` and `forks` answer it: its stats, its work and its upstream, for one
|
package/dist/core/repos.mjs
CHANGED
|
@@ -20,8 +20,8 @@ import { fail } from "../contracts/result.mjs";
|
|
|
20
20
|
import { CoreParts } from "./parts.mjs";
|
|
21
21
|
import { pruneJobRow } from "../storage/repack-job.mjs";
|
|
22
22
|
import { check } from "../contracts/authorize.mjs";
|
|
23
|
-
import * as Clock from "effect/Clock";
|
|
24
23
|
import * as Effect from "effect/Effect";
|
|
24
|
+
import * as Clock from "effect/Clock";
|
|
25
25
|
// src/core/repos.ts
|
|
26
26
|
const defaultBranch = "refs/heads/main";
|
|
27
27
|
/**
|
|
@@ -4,29 +4,23 @@ import { decodeCommit } from "../../protocol/objects/commit.mjs";
|
|
|
4
4
|
import { boundedBytes } from "../../protocol/bytes/reader.mjs";
|
|
5
5
|
import { objectBytesMost } from "../../protocol/objects/held.mjs";
|
|
6
6
|
import { emptyTree } from "../../protocol/objects/object.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import { callScope } from "../../store/call-count.mjs";
|
|
9
|
-
import { runIn } from "../../store/crossing.mjs";
|
|
7
|
+
import { tryUnlessSpent } from "../../contracts/calls-spent.mjs";
|
|
8
|
+
import { callScope, inCallScope } from "../../store/call-count.mjs";
|
|
10
9
|
import * as Effect from "effect/Effect";
|
|
11
10
|
// src/core/rules/changes.ts
|
|
12
11
|
/** `read`, which also finds the empty tree, which every repo can name and none need store. */
|
|
13
|
-
const withEmptyTree = (read) =>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
bytes: new Blob([]).stream()
|
|
20
|
-
}
|
|
21
|
-
} : read(input);
|
|
12
|
+
const withEmptyTree = (read) => (input) => input.oid === "4b825dc642cb6eb9a060e54bf8d69288fbee4904" ? Effect.sync(() => ({
|
|
13
|
+
oid: input.oid,
|
|
14
|
+
type: "tree",
|
|
15
|
+
size: 0,
|
|
16
|
+
bytes: new Blob([]).stream()
|
|
17
|
+
})) : read(input);
|
|
22
18
|
/** A commit, or `undefined` for a tip that isn't one, such as a tag's. */
|
|
23
19
|
const commitOf = /* @__PURE__ */ Effect.fnUntraced(function* (read, oid, signal) {
|
|
24
|
-
const
|
|
20
|
+
const object = yield* read({
|
|
25
21
|
oid,
|
|
26
22
|
signal
|
|
27
|
-
})
|
|
28
|
-
if (found.kind === "error") return yield* answerFailed(found.error);
|
|
29
|
-
const object = found.value;
|
|
23
|
+
});
|
|
30
24
|
if (object === void 0) return yield* fail("NOT_FOUND", `${oid} isn't in the repo`);
|
|
31
25
|
if (object.type !== "commit") {
|
|
32
26
|
object.bytes.cancel().catch(() => void 0);
|
|
@@ -55,31 +49,15 @@ const changesBetween = /* @__PURE__ */ Effect.fnUntraced(function* (read, from,
|
|
|
55
49
|
return changes;
|
|
56
50
|
});
|
|
57
51
|
/** `objects`' batches as the engine's `ReadObjects`, over `listed`, each run in `scope`. */
|
|
58
|
-
const batchOf = (objects, listed, scope) => (input) =>
|
|
59
|
-
onSuccess: (value) => ({
|
|
60
|
-
kind: "success",
|
|
61
|
-
value
|
|
62
|
-
}),
|
|
63
|
-
onFailure: (error) => ({
|
|
64
|
-
kind: "error",
|
|
65
|
-
error
|
|
66
|
-
})
|
|
67
|
-
}), scope);
|
|
52
|
+
const batchOf = (objects, listed, scope) => (input) => inCallScope(objects.objects(listed, input), scope);
|
|
68
53
|
/** `objects`' reads as the engine's `ReadObject`, over `listed`, each run in `scope`. */
|
|
69
|
-
const readerOf = (objects, listed, scope) => (input) =>
|
|
70
|
-
onSuccess: (value) => ({
|
|
71
|
-
kind: "success",
|
|
72
|
-
value
|
|
73
|
-
}),
|
|
74
|
-
onFailure: (error) => ({
|
|
75
|
-
kind: "error",
|
|
76
|
-
error
|
|
77
|
-
})
|
|
78
|
-
}), scope);
|
|
54
|
+
const readerOf = (objects, listed, scope) => (input) => inCallScope(objects.read(listed, input), scope);
|
|
79
55
|
/**
|
|
80
|
-
* `between` over core's reads
|
|
81
|
-
*
|
|
82
|
-
* and a defect, such as a spent bound, rejects as it is.
|
|
56
|
+
* `between` over core's reads, run directly in the caller's fiber and call scope, with an
|
|
57
|
+
* `AbortSignal` that aborts if the fiber is interrupted.
|
|
83
58
|
*/
|
|
84
|
-
const changes = { between: ({ objects, listed, from, to }) => Effect.flatMap(callScope, (scope) => Effect.
|
|
59
|
+
const changes = { between: ({ objects, listed, from, to }) => Effect.flatMap(callScope, (scope) => Effect.suspend(() => {
|
|
60
|
+
const controller = new AbortController();
|
|
61
|
+
return changesBetween(readerOf(objects, listed, scope), from, to, controller.signal, batchOf(objects, listed, scope)).pipe(Effect.onInterrupt(() => Effect.sync(() => controller.abort())));
|
|
62
|
+
})) };
|
|
85
63
|
export { batchOf, changes, commitOf, readerOf, treeOf, withEmptyTree };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { gitError } from "../../contracts/result.mjs";
|
|
2
2
|
import { hostEffect, logRefusal, rejectedError } from "../../auth/host-function.mjs";
|
|
3
|
-
import { hiddenUnder } from "../../protocol/wire/lines.mjs";
|
|
3
|
+
import { anyoneMoves, hiddenUnder } from "../../protocol/wire/lines.mjs";
|
|
4
4
|
import { inCallScope } from "../../store/call-count.mjs";
|
|
5
5
|
import { checkedAnswer, plainAnswer, pushContextOf } from "./context.mjs";
|
|
6
6
|
import { shortRef } from "./patterns.mjs";
|
|
@@ -17,21 +17,22 @@ const ruleAnswer = (checking, rule, reached, update) => {
|
|
|
17
17
|
updates: [update]
|
|
18
18
|
};
|
|
19
19
|
const authorize = checking.authorizeFor(update.ref, rule.name);
|
|
20
|
-
const input = pushContextOf(checking, reached, changed, {
|
|
20
|
+
const { input, provide } = pushContextOf(checking, reached, changed, {
|
|
21
21
|
update,
|
|
22
22
|
authorize: (asked) => inCallScope(authorize(asked), checking.scope)
|
|
23
23
|
});
|
|
24
|
-
const
|
|
24
|
+
const ruleInput = input;
|
|
25
|
+
const answer = provide(checkedAnswer(`The push rule '${rule.name}'`, plainAnswer, () => rule.check(ruleInput)));
|
|
25
26
|
return hostEffect("rules.push", checking.about, answer);
|
|
26
27
|
};
|
|
27
28
|
/**
|
|
28
29
|
* Whether a push `as` an owner may change `ref`: a ref under one of `table`'s prefixes is its
|
|
29
30
|
* owner's own, the merge queue's or an import's, and no other push or API call moves it, whatever
|
|
30
|
-
* the rules say.
|
|
31
|
+
* the rules say. One under its row's `movedUnder`, as a mirror's segment, is any ref's.
|
|
31
32
|
*/
|
|
32
33
|
const gitsOwnRef = (table, ref, as) => {
|
|
33
34
|
const hidden = hiddenUnder(table, ref);
|
|
34
|
-
if (hidden === void 0 || hidden.owner === as) return void 0;
|
|
35
|
+
if (hidden === void 0 || hidden.owner === as || anyoneMoves(table, ref)) return void 0;
|
|
35
36
|
return gitError("NOT_ALLOWED", `'${ref}' is Git's own: only ${hidden.mover} moves it`, { hint: `Push to a branch, not under ${hidden.owner.prefix}` });
|
|
36
37
|
};
|
|
37
38
|
/**
|