@ref0/git 0.20.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access/private-refs.mjs +1 -1
- package/dist/auth/access-jwt.mjs +3 -3
- package/dist/auth/auth-namespace.d.mts +3 -3
- package/dist/auth/auth-namespace.mjs +3 -2
- package/dist/auth/auth.d.mts +3 -3
- package/dist/auth/auth.mjs +9 -8
- package/dist/auth/authorize.mjs +1 -1
- package/dist/auth/fences.d.mts +1 -1
- package/dist/auth/host-function.mjs +1 -1
- package/dist/auth/host-services.mjs +4 -6
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +6 -0
- package/dist/auth/token-cleanup.mjs +2 -2
- package/dist/auth/token-rows.mjs +6 -1
- package/dist/auth/token-text.mjs +1 -1
- package/dist/auth/tokens-base.d.mts +1 -1
- package/dist/auth/tokens.d.mts +1 -1
- package/dist/auth/tokens.mjs +1 -1
- package/dist/client/client.d.mts +15 -7
- package/dist/client/client.mjs +21 -12
- package/dist/client/git-http.mjs +1 -1
- package/dist/client/local.mjs +60 -24
- package/dist/client/negotiate.mjs +3 -3
- package/dist/client/push-upload.mjs +26 -10
- package/dist/client/remote.mjs +4 -3
- package/dist/client/run-remote-helper.d.mts +2 -2
- package/dist/client/run-remote-helper.mjs +6 -6
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +3 -3
- package/dist/contracts/blobs.d.mts +3 -3
- package/dist/contracts/blobs.mjs +1 -1
- package/dist/contracts/calls-spent.mjs +5 -33
- package/dist/contracts/client.d.mts +15 -14
- package/dist/contracts/commits.d.mts +4 -4
- package/dist/contracts/commits.mjs +1 -1
- package/dist/contracts/engine.d.mts +2 -2
- package/dist/contracts/events.d.mts +1 -1
- package/dist/contracts/events.mjs +1 -1
- package/dist/contracts/files.d.mts +4 -4
- package/dist/contracts/files.mjs +1 -1
- package/dist/contracts/forks.d.mts +4 -4
- package/dist/contracts/forks.mjs +1 -1
- package/dist/contracts/git-hooks.d.mts +1 -1
- package/dist/contracts/git.d.mts +9 -5
- package/dist/contracts/grants.d.mts +1 -1
- package/dist/contracts/merges.d.mts +1 -1
- package/dist/contracts/object-values.d.mts +1 -0
- package/dist/contracts/object-values.mjs +16 -1
- package/dist/contracts/objects.d.mts +20 -17
- package/dist/contracts/opaque.mjs +1 -1
- package/dist/contracts/operations.mjs +1 -1
- package/dist/contracts/queue.d.mts +208 -44
- package/dist/contracts/queue.mjs +5 -5
- package/dist/contracts/refs.d.mts +5 -5
- package/dist/contracts/refs.mjs +1 -1
- package/dist/contracts/remote.d.mts +3 -6
- package/dist/contracts/repos.d.mts +3 -3
- package/dist/contracts/repos.mjs +1 -1
- package/dist/contracts/result.d.mts +10 -7
- package/dist/contracts/result.mjs +8 -3
- package/dist/contracts/rules.d.mts +2 -2
- package/dist/contracts/server.d.mts +8 -10
- package/dist/contracts/services.d.mts +6 -9
- package/dist/contracts/services.mjs +1 -2
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/store.d.mts +2 -2
- package/dist/contracts/sync.d.mts +63 -6
- package/dist/contracts/sync.mjs +3 -2
- package/dist/contracts/tags.d.mts +3 -3
- package/dist/contracts/tags.mjs +1 -1
- package/dist/contracts/tokens.d.mts +2 -2
- package/dist/contracts/tokens.mjs +1 -1
- package/dist/contracts/topics.d.mts +9 -9
- package/dist/contracts/trees.d.mts +4 -4
- package/dist/contracts/trees.mjs +1 -1
- package/dist/contracts/work.d.mts +4 -4
- package/dist/contracts/work.mjs +2 -2
- package/dist/core/access.d.mts +1 -1
- package/dist/core/ancestry.mjs +30 -34
- package/dist/core/{promise.mjs → call-groups.mjs} +7 -30
- package/dist/core/call-services.mjs +1 -1
- package/dist/core/events/deliver.d.mts +2 -2
- package/dist/core/events/deliver.mjs +3 -3
- package/dist/core/events/retired.mjs +1 -1
- package/dist/core/forks.mjs +5 -5
- package/dist/core/hooks/groups.mjs +2 -2
- package/dist/core/imports.mjs +101 -21
- package/dist/core/index-job.mjs +14 -9
- package/dist/core/index-lost.d.mts +1 -1
- package/dist/core/loose-tally.mjs +38 -15
- package/dist/core/merge-parts.d.mts +17 -4
- package/dist/core/merge-parts.mjs +7 -2
- package/dist/core/mirror-rows.mjs +31 -1
- package/dist/core/objects/blobs.mjs +8 -10
- package/dist/core/objects/files.mjs +20 -17
- package/dist/core/objects/objects-layer.mjs +1 -1
- package/dist/core/objects/peel.mjs +1 -7
- package/dist/core/objects/reading.mjs +19 -18
- package/dist/core/objects/tree-edits.mjs +1 -1
- package/dist/core/objects/trees.mjs +257 -58
- package/dist/core/objects/writing.mjs +3 -9
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +8 -1
- package/dist/core/parts.mjs +8 -4
- package/dist/core/purge.mjs +31 -18
- package/dist/core/push.d.mts +2 -2
- package/dist/core/push.mjs +125 -94
- package/dist/core/receipts.d.mts +2 -2
- package/dist/core/receipts.mjs +9 -2
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +74 -31
- package/dist/core/refs.mjs +3 -3
- package/dist/core/repack.mjs +25 -30
- package/dist/core/repo-info.mjs +1 -1
- package/dist/core/repos.mjs +1 -1
- package/dist/core/rules/changes.mjs +18 -40
- package/dist/core/rules/check.mjs +6 -5
- package/dist/core/rules/commit-changes.mjs +3 -15
- package/dist/core/rules/context.d.mts +3 -3
- package/dist/core/rules/context.mjs +18 -14
- package/dist/core/rules/fetch.mjs +1 -1
- package/dist/core/rules/protect.mjs +30 -17
- package/dist/core/saved-caller-views.d.mts +1 -1
- package/dist/core/saved-caller-views.mjs +3 -3
- package/dist/core/saved-callers.d.mts +1 -1
- package/dist/core/saved-callers.mjs +1 -1
- package/dist/core/seam.d.mts +1 -2
- package/dist/core/view.d.mts +6 -3
- package/dist/core/view.mjs +11 -10
- package/dist/core/work.mjs +2 -2
- package/dist/engine/allotted-xdiff.mjs +3 -16
- package/dist/engine/combined.d.mts +3 -0
- package/dist/engine/combined.mjs +200 -185
- package/dist/engine/content.d.mts +2 -2
- package/dist/engine/content.mjs +1 -1
- package/dist/engine/merge.mjs +7 -9
- package/dist/engine/reads.d.mts +2 -2
- package/dist/engine/reads.mjs +22 -14
- package/dist/engine/xdiff.d.mts +1 -1
- package/dist/engine/xdiff.mjs +1 -1
- package/dist/event-streams/event-streams.d.mts +1 -1
- package/dist/event-streams/event-streams.mjs +1 -1
- package/dist/event-streams/stream.d.mts +2 -2
- package/dist/event-streams/stream.mjs +3 -3
- package/dist/extend.d.mts +2 -6
- package/dist/extend.mjs +1 -5
- package/dist/http/core-parts.mjs +83 -26
- package/dist/http/handler.mjs +54 -9
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +138 -24
- package/dist/http/push-uploads.mjs +2 -2
- package/dist/http/receive-pack.mjs +14 -53
- package/dist/http/request-snapshot.mjs +258 -0
- package/dist/http/upload-pack.mjs +23 -18
- package/dist/index.d.mts +29 -21
- package/dist/index.mjs +11 -2
- package/dist/lfs/base.d.mts +1 -1
- package/dist/lfs/copy.d.mts +49 -1
- package/dist/lfs/copy.mjs +135 -22
- package/dist/lfs/layer.d.mts +4 -3
- package/dist/lfs/layer.mjs +4 -5
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +1 -1
- package/dist/lfs/objects.mjs +3 -3
- package/dist/lfs/pointers.mjs +1 -1
- package/dist/lfs/rows.d.mts +1 -1
- package/dist/lfs/rows.mjs +11 -4
- package/dist/lfs/upkeep.mjs +40 -9
- package/dist/lfs/uploaded.mjs +1 -1
- package/dist/lfs/wire.mjs +1 -1
- package/dist/merges/merges.mjs +17 -2
- package/dist/protocol/bytes/buffers.d.mts +1 -1
- package/dist/protocol/bytes/buffers.mjs +1 -1
- package/dist/protocol/bytes/deflate.d.mts +1 -1
- package/dist/protocol/bytes/deflate.mjs +1 -1
- package/dist/protocol/bytes/inflate.d.mts +1 -1
- package/dist/protocol/bytes/inflate.mjs +1 -1
- package/dist/protocol/bytes/sha1.d.mts +1 -1
- package/dist/protocol/bytes/sha1.mjs +1 -1
- package/dist/protocol/diff/read.d.mts +2 -1
- package/dist/protocol/diff/read.mjs +102 -8
- package/dist/protocol/packs/graph.mjs +1 -1
- package/dist/protocol/packs/idx.d.mts +1 -1
- package/dist/protocol/packs/idx.mjs +1 -1
- package/dist/protocol/packs/parts.mjs +1 -1
- package/dist/protocol/packs/reader.d.mts +1 -1
- package/dist/protocol/packs/reader.mjs +1 -1
- package/dist/protocol/packs/write-error.d.mts +1 -1
- package/dist/protocol/packs/write-error.mjs +1 -1
- package/dist/protocol/packs/writer.mjs +3 -3
- package/dist/protocol/wire/advertisement.d.mts +1 -1
- package/dist/protocol/wire/advertisement.mjs +3 -2
- package/dist/protocol/wire/fetch.d.mts +1 -1
- package/dist/protocol/wire/fetch.mjs +1 -1
- package/dist/protocol/wire/lines.d.mts +9 -1
- package/dist/protocol/wire/lines.mjs +28 -1
- package/dist/protocol/wire/push-uploads.mjs +10 -7
- package/dist/protocol/wire/receive-pack.d.mts +1 -1
- package/dist/protocol/wire/receive-pack.mjs +1 -1
- package/dist/protocol/wire/report-status.d.mts +1 -1
- package/dist/protocol/wire/report-status.mjs +1 -1
- package/dist/protocol/wire/v2.d.mts +1 -1
- package/dist/protocol/wire/v2.mjs +1 -1
- package/dist/queue/advance.mjs +31 -24
- package/dist/queue/base.d.mts +5 -3
- package/dist/queue/calls.mjs +5 -5
- package/dist/queue/commit.mjs +1 -1
- package/dist/queue/host.d.mts +1 -1
- package/dist/queue/layer.d.mts +0 -1
- package/dist/queue/layer.mjs +9 -5
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/search.mjs +1 -1
- package/dist/queue/state.mjs +1 -1
- package/dist/queue/trim.mjs +2 -2
- package/dist/rest/client.d.mts +1 -1
- package/dist/rest/client.mjs +6 -6
- package/dist/rest/errors.mjs +1 -1
- package/dist/rest/handler.mjs +2 -2
- package/dist/rest/handlers.mjs +16 -6
- package/dist/rest/layer.mjs +1 -1
- package/dist/rest/listen.mjs +2 -2
- package/dist/rest/refs.mjs +1 -1
- package/dist/server/edge.mjs +27 -3
- package/dist/server/git-layer.d.mts +1 -2
- package/dist/server/git-layer.mjs +4 -5
- package/dist/server/lifecycle.mjs +1 -1
- package/dist/server/registry.mjs +2 -8
- package/dist/server/server.mjs +62 -43
- package/dist/signin/context.d.mts +1 -1
- package/dist/signin/context.mjs +1 -1
- package/dist/signin/forms.mjs +1 -1
- package/dist/signin/grants.d.mts +2 -2
- package/dist/signin/grants.mjs +1 -1
- package/dist/signin/wire.mjs +1 -1
- package/dist/storage/allotted.mjs +4 -9
- package/dist/storage/batch-upkeep.mjs +31 -12
- package/dist/storage/batches.d.mts +2 -3
- package/dist/storage/batches.mjs +52 -49
- package/dist/storage/budget.mjs +23 -1
- package/dist/storage/calls.d.mts +1 -1
- package/dist/storage/calls.mjs +41 -43
- package/dist/storage/charged-cache.mjs +180 -0
- package/dist/storage/chunks.d.mts +3 -3
- package/dist/storage/chunks.mjs +121 -8
- package/dist/storage/counted-bucket.mjs +32 -10
- package/dist/storage/fetch-row-cache.d.mts +6 -0
- package/dist/storage/fetch-row-cache.mjs +211 -0
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +54 -242
- package/dist/storage/held-types.d.mts +0 -1
- package/dist/storage/host-bucket.mjs +9 -4
- package/dist/storage/index-bitmaps.mjs +77 -49
- package/dist/storage/index-build.d.mts +2 -3
- package/dist/storage/index-build.mjs +248 -48
- package/dist/storage/index-fetch.d.mts +3 -1
- package/dist/storage/index-fetch.mjs +60 -21
- package/dist/storage/index-graph.mjs +1 -1
- package/dist/storage/index-layers.mjs +55 -25
- package/dist/storage/index-reach.mjs +15 -22
- package/dist/storage/index-whole.d.mts +7 -0
- package/dist/storage/index-whole.mjs +145 -37
- package/dist/storage/largest-files.mjs +1 -7
- package/dist/storage/layout.mjs +17 -1
- package/dist/storage/lfs-pointers.mjs +1 -6
- package/dist/storage/link-join.mjs +55 -16
- package/dist/storage/list-source.d.mts +7 -0
- package/dist/storage/list-source.mjs +288 -0
- package/dist/storage/loose.d.mts +8 -8
- package/dist/storage/loose.mjs +157 -91
- package/dist/storage/memory-budget.mjs +226 -22
- package/dist/storage/merge-cut.mjs +9 -6
- package/dist/storage/merge-fence.mjs +1 -1
- package/dist/storage/merge-row.mjs +1 -1
- package/dist/storage/merge.d.mts +2 -3
- package/dist/storage/merge.mjs +2 -2
- package/dist/storage/object-rows.d.mts +3 -3
- package/dist/storage/object-rows.mjs +179 -38
- package/dist/storage/pack-order.mjs +97 -44
- package/dist/storage/pack-ranges.mjs +44 -16
- package/dist/storage/pack-reads.d.mts +5 -3
- package/dist/storage/pack-reads.mjs +236 -72
- package/dist/storage/pack-receive.d.mts +1 -2
- package/dist/storage/pack-receive.mjs +21 -17
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +477 -116
- package/dist/storage/placed-reads.mjs +33 -16
- package/dist/storage/prune-seen.mjs +1 -1
- package/dist/storage/prune-walk.mjs +1 -1
- package/dist/storage/prune.mjs +4 -31
- package/dist/storage/push-allotment.mjs +26 -14
- package/dist/storage/push-uploads.mjs +195 -57
- package/dist/storage/pushed-commits.mjs +20 -1
- package/dist/storage/quarantine.d.mts +2 -3
- package/dist/storage/range-cache.mjs +175 -40
- package/dist/storage/raw-ids.mjs +39 -10
- package/dist/storage/ready.d.mts +2 -3
- package/dist/storage/ready.mjs +114 -38
- package/dist/storage/receive-bounds.mjs +31 -9
- package/dist/storage/receive-cache.d.mts +7 -0
- package/dist/storage/receive-cache.mjs +147 -0
- package/dist/storage/receive-files.mjs +1 -1
- package/dist/storage/receive-links.mjs +1 -1
- package/dist/storage/receive-state.d.mts +2 -2
- package/dist/storage/receive-state.mjs +6 -8
- package/dist/storage/receive-steps.d.mts +20 -0
- package/dist/storage/receive-steps.mjs +298 -13
- package/dist/storage/repack-backlog.mjs +1 -6
- package/dist/storage/repack-contained.mjs +2 -2
- package/dist/storage/repack-job.mjs +1 -1
- package/dist/storage/repack.d.mts +2 -3
- package/dist/storage/repack.mjs +54 -9
- package/dist/storage/request-cache.mjs +57 -0
- package/dist/storage/roots.mjs +1 -24
- package/dist/storage/rows.d.mts +2 -2
- package/dist/storage/rows.mjs +1 -1
- package/dist/storage/runs.d.mts +2 -2
- package/dist/storage/runs.mjs +1 -1
- package/dist/storage/send-list.mjs +62 -25
- package/dist/storage/stream-whole.mjs +84 -63
- package/dist/storage/swap-walk.mjs +1 -1
- package/dist/storage/unpack.mjs +878 -450
- package/dist/storage/visible.mjs +110 -32
- package/dist/storage/walk.mjs +1 -0
- package/dist/storage/wants.mjs +22 -58
- package/dist/store/call-count.d.mts +2 -2
- package/dist/store/call-count.mjs +24 -11
- package/dist/store/catalogue.d.mts +1 -1
- package/dist/store/catalogue.mjs +19 -7
- package/dist/store/crossing.mjs +1 -7
- package/dist/store/cursor-seal.d.mts +1 -1
- package/dist/store/cursor-seal.mjs +1 -1
- package/dist/store/door.mjs +9 -4
- package/dist/store/errors.d.mts +2 -2
- package/dist/store/errors.mjs +107 -19
- package/dist/store/git-store.mjs +7 -2
- package/dist/store/job-try.mjs +90 -9
- package/dist/store/list-job.mjs +10 -34
- package/dist/store/outbox.d.mts +2 -2
- package/dist/store/outbox.mjs +2 -2
- package/dist/store/queue-jobs.mjs +6 -12
- package/dist/store/records.d.mts +2 -2
- package/dist/store/records.mjs +2 -2
- package/dist/store/ref-rows.d.mts +2 -2
- package/dist/store/ref-rows.mjs +2 -2
- package/dist/store/repo-record.d.mts +2 -2
- package/dist/store/repo-record.mjs +3 -3
- package/dist/store/request-snapshot.mjs +5 -0
- package/dist/store/reservations.mjs +2 -2
- package/dist/store/topic-jobs.mjs +5 -11
- package/dist/sync/bound.d.mts +3 -3
- package/dist/sync/bound.mjs +10 -7
- package/dist/sync/github.mjs +65 -67
- package/dist/sync/http.mjs +1 -1
- package/dist/sync/import.mjs +201 -66
- package/dist/sync/layer.d.mts +1 -1
- package/dist/sync/layer.mjs +6 -6
- package/dist/sync/lfs-batch.mjs +1 -1
- package/dist/sync/lfs-copy.mjs +175 -15
- package/dist/sync/mirror.mjs +5 -10
- package/dist/sync/said.mjs +1 -1
- package/dist/sync/step.mjs +268 -86
- package/dist/sync/tries.mjs +25 -6
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +2 -2
- package/dist/topics/advance.mjs +3 -3
- package/dist/topics/calls.mjs +1 -1
- package/dist/topics/layer.d.mts +15 -14
- package/dist/topics/members.mjs +1 -1
- package/dist/topics/topic.mjs +1 -1
- package/package.json +3 -13
- package/dist/auth/helpers.mjs +0 -17
- package/dist/auth.d.mts +0 -5
- package/dist/auth.mjs +0 -5
- package/dist/core/rules/commit-changes.d.mts +0 -12
- package/dist/effect.d.mts +0 -9
- package/dist/effect.mjs +0 -7
- package/dist/server/joined.d.mts +0 -70
- package/dist/server/joined.mjs +0 -41
package/dist/store/errors.mjs
CHANGED
|
@@ -1,21 +1,114 @@
|
|
|
1
|
-
import { fail, gitError, gitErrorFrom } from "../contracts/result.mjs";
|
|
2
|
-
import { callLimitIn, callLimitTry, catchSpent,
|
|
1
|
+
import { fail, gitError, gitErrorFrom, isGitError } from "../contracts/result.mjs";
|
|
2
|
+
import { callLimitIn, callLimitTry, catchSpent, spentAt, spentRefusal } from "../contracts/calls-spent.mjs";
|
|
3
3
|
import { chargeCall, chargeResends, committedNow } from "./call-count.mjs";
|
|
4
4
|
import { isServerClosed } from "./closed.mjs";
|
|
5
|
+
import { Records, Unavailable, isInfraError } from "@ref0/infra";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
5
7
|
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Predicate from "effect/Predicate";
|
|
9
|
+
import * as Stream from "effect/Stream";
|
|
6
10
|
import * as Option from "effect/Option";
|
|
7
|
-
import * as Schema from "effect/Schema";
|
|
8
11
|
import * as Cause from "effect/Cause";
|
|
9
|
-
import * as Exit from "effect/Exit";
|
|
10
|
-
import { isInfraError } from "@ref0/infra";
|
|
11
|
-
import * as Predicate from "effect/Predicate";
|
|
12
12
|
import * as Data from "effect/Data";
|
|
13
|
-
import * as
|
|
13
|
+
import * as Exit from "effect/Exit";
|
|
14
14
|
// src/store/errors.ts
|
|
15
15
|
const savedHint = "Read it back before you try again";
|
|
16
16
|
const savedContext = { reason: "may-have-saved" };
|
|
17
17
|
/** What a caller does with a write that landed past its `by`: it wrote nothing, so read again. */
|
|
18
18
|
const lateHint = "Try again";
|
|
19
|
+
/** What a caller hears when Cloudflare reports a Durable Object is overloaded. */
|
|
20
|
+
const overloadedMessage = "The store is overloaded";
|
|
21
|
+
/** The words that say a credential comes next, as an `Authorization` header's do. */
|
|
22
|
+
const credentialNext = /^(authorization:?|bearer|basic|digest|token|aws4-hmac-sha256)$/i;
|
|
23
|
+
/**
|
|
24
|
+
* `word` as the log keeps it, after `before`: a URL cut to its scheme and host, since a signed URL
|
|
25
|
+
* keeps its signature in its query or path and a URL its credentials before the host; a path cut
|
|
26
|
+
* after its first part; a word after `Authorization` or `Bearer` cut; and any word that holds a
|
|
27
|
+
* query, an assignment, an `@` or an inner colon cut whole, as a key's value or a credential could.
|
|
28
|
+
*/
|
|
29
|
+
const keptWord = (word, before) => {
|
|
30
|
+
if (word.trim() === "") return word;
|
|
31
|
+
if (word.includes("//")) {
|
|
32
|
+
const url = word.startsWith("//") ? `x:${word}` : word;
|
|
33
|
+
if (!URL.canParse(url)) return "<url>";
|
|
34
|
+
const parsed = new URL(url);
|
|
35
|
+
return `${word.startsWith("//") ? "" : parsed.protocol}//${parsed.host}/…`;
|
|
36
|
+
}
|
|
37
|
+
if (before !== void 0 && credentialNext.test(before) && !credentialNext.test(word)) return "…";
|
|
38
|
+
if (/[?=@]|:./.test(word)) return "…";
|
|
39
|
+
return word.includes("/") ? `${word.slice(0, word.indexOf("/"))}/…` : word;
|
|
40
|
+
};
|
|
41
|
+
/** `text`, with URLs, credentials and key/value tokens redacted for logs. */
|
|
42
|
+
const redactWords = (text) => {
|
|
43
|
+
const words = text.split(/(\s+)/);
|
|
44
|
+
return words.map((word, at) => keptWord(word, words[at - 2])).join("");
|
|
45
|
+
};
|
|
46
|
+
/** A string property on `cause`, if present. */
|
|
47
|
+
const stringProp = (cause, key) => Predicate.hasProperty(cause, key) && Predicate.isString(cause[key]) ? cause[key] : void 0;
|
|
48
|
+
const causeText = (cause, withName) => {
|
|
49
|
+
try {
|
|
50
|
+
if (cause instanceof Error) return withName ? `${cause.name}: ${cause.message}` : cause.message;
|
|
51
|
+
return stringProp(cause, "message") ?? (Predicate.isString(cause) ? cause : Object.prototype.toString.call(cause));
|
|
52
|
+
} catch {
|
|
53
|
+
return "a value whose words throw";
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* What threw beneath `cause`, past each Git error that kept another as its cause, as `pushLess`
|
|
58
|
+
* does, at most 8 deep: its name and message, or its kind when it has no words, each word cut as
|
|
59
|
+
* `keptWord` cuts it. It never throws, whatever was thrown.
|
|
60
|
+
*/
|
|
61
|
+
const thrownWords = (cause) => {
|
|
62
|
+
let thrown = cause;
|
|
63
|
+
for (let depth = 0; depth < 8 && isGitError(thrown) && thrown.cause !== void 0; depth += 1) thrown = thrown.cause;
|
|
64
|
+
return redactWords(causeText(thrown, true));
|
|
65
|
+
};
|
|
66
|
+
/** Whether `cause` carries Cloudflare's boolean Durable Object error `flag: true`. */
|
|
67
|
+
const hasFlag = (cause, flag) => {
|
|
68
|
+
try {
|
|
69
|
+
return Predicate.hasProperty(cause, flag) && cause[flag] === true;
|
|
70
|
+
} catch {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const causeNameOf = (cause) => {
|
|
75
|
+
try {
|
|
76
|
+
return cause instanceof Error ? cause.name : stringProp(cause, "name") ?? Object.prototype.toString.call(cause);
|
|
77
|
+
} catch {
|
|
78
|
+
return "unknown";
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
/** Unwraps `Unsettled` and infra's `Unavailable` (at most 8 deep) into its structured details. */
|
|
82
|
+
const platformCauseOf = (cause) => {
|
|
83
|
+
let current = cause;
|
|
84
|
+
for (let depth = 0; depth < 8 && (current instanceof Unsettled || current instanceof Unavailable) && current.cause !== void 0; depth += 1) current = current.cause;
|
|
85
|
+
return {
|
|
86
|
+
name: redactWords(causeNameOf(current)),
|
|
87
|
+
message: redactWords(causeText(current, false)),
|
|
88
|
+
retryable: hasFlag(current, "retryable"),
|
|
89
|
+
overloaded: hasFlag(current, "overloaded")
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
/** Whether `cause`, or an `Unavailable`/`Unsettled` wrapping it, carries Cloudflare's `overloaded` flag. */
|
|
93
|
+
const isOverloaded = (cause) => platformCauseOf(cause).overloaded;
|
|
94
|
+
/**
|
|
95
|
+
* Logs one structured error event when `fromInfra` maps an unknown platform error (or infra's
|
|
96
|
+
* `Unavailable`) to `UNAVAILABLE`, carrying the underlying cause's name, redacted message, and
|
|
97
|
+
* Cloudflare's `retryable` and `overloaded` flags. The HTTP response never carries the cause.
|
|
98
|
+
*/
|
|
99
|
+
const logStoreFailure = (cause, error) => {
|
|
100
|
+
if (error.code !== "UNAVAILABLE" || isInfraError(cause) && !(cause instanceof Unavailable)) return Effect.void;
|
|
101
|
+
const details = platformCauseOf(cause);
|
|
102
|
+
return Effect.logError(`A store call failed: ${error.message}`).pipe(Effect.annotateLogs({
|
|
103
|
+
code: error.code,
|
|
104
|
+
causeName: details.name,
|
|
105
|
+
causeMessage: details.message,
|
|
106
|
+
retryable: details.retryable,
|
|
107
|
+
overloaded: details.overloaded
|
|
108
|
+
}));
|
|
109
|
+
};
|
|
110
|
+
/** Logs a structured event for unknown platform failures, then fails with `error`. */
|
|
111
|
+
const failLogged = (cause, error) => Effect.andThen(logStoreFailure(cause, error), Effect.fail(error));
|
|
19
112
|
/**
|
|
20
113
|
* `error`, met once a write of the call's own has landed: any `UNAVAILABLE` is `may-have-saved`,
|
|
21
114
|
* since what another reason says about sending the same call again holds only for a call that
|
|
@@ -50,12 +143,12 @@ const afterWrites = (error) => {
|
|
|
50
143
|
*/
|
|
51
144
|
const fromInfra = (cause, after = false) => {
|
|
52
145
|
const failed = !isInfraError(cause) || Predicate.isTagged(cause, "Unavailable");
|
|
53
|
-
if (cause instanceof Unsettled || failed && after) return gitError("UNAVAILABLE", "The store may have saved this write", {
|
|
146
|
+
if (cause instanceof Unsettled || cause instanceof Unavailable && cause.mayHaveSaved === true || failed && after) return gitError("UNAVAILABLE", "The store may have saved this write", {
|
|
54
147
|
cause,
|
|
55
148
|
hint: savedHint,
|
|
56
149
|
context: savedContext
|
|
57
150
|
});
|
|
58
|
-
if (failed) return gitError("UNAVAILABLE", "The store failed", {
|
|
151
|
+
if (failed) return gitError("UNAVAILABLE", isOverloaded(cause) ? overloadedMessage : "The store failed", {
|
|
59
152
|
cause,
|
|
60
153
|
hint: "Try again"
|
|
61
154
|
});
|
|
@@ -118,7 +211,7 @@ const answerSpent = (effect) => catchSpent(effect, (spent) => Effect.fail(spentR
|
|
|
118
211
|
* either's bound (Q799): past one, it dies with `CallsSpent`, which an edge answers, as
|
|
119
212
|
* `spentRefusalOf` does.
|
|
120
213
|
*/
|
|
121
|
-
const storeCall = (run, options) => effectStoreCall(run, options?.resend === true);
|
|
214
|
+
const storeCall = (run, options) => effectStoreCall(Effect.provideService(run, Records.OnRetry, chargeCall("store")), options?.resend === true);
|
|
122
215
|
/** A store failure: preserve interruption, spent bounds and closed servers; map adapter throws via `fromInfra`. */
|
|
123
216
|
const effectStoreFailure = (cause, after) => {
|
|
124
217
|
if (Cause.hasInterrupts(cause)) return Effect.failCause(Cause.map(cause, (error) => fromInfra(error, after)));
|
|
@@ -126,7 +219,7 @@ const effectStoreFailure = (cause, after) => {
|
|
|
126
219
|
const spent = spentAt(error);
|
|
127
220
|
if (spent !== void 0) return Effect.die(spent);
|
|
128
221
|
if (isServerClosed(error)) return Effect.die(error);
|
|
129
|
-
return
|
|
222
|
+
return failLogged(error, fromInfra(error, after));
|
|
130
223
|
};
|
|
131
224
|
/** A commit through `storeCall`, resending under its own ID when its reply is lost. */
|
|
132
225
|
const storeCommit = (run) => storeCall(run, { resend: true });
|
|
@@ -146,7 +239,7 @@ const effectStoreCall = /* @__PURE__ */ Effect.fnUntraced(function* (run, resend
|
|
|
146
239
|
if (isServerClosed(cause)) return yield* effectStoreFailure(exit.cause, after);
|
|
147
240
|
if (!resend || (resends === 0 ? !isLostReply(cause) : isAnswered(cause))) return yield* effectStoreFailure(exit.cause, after);
|
|
148
241
|
lost ??= cause;
|
|
149
|
-
if (resends === 1 || !isLostReply(cause)) return yield*
|
|
242
|
+
if (resends === 1 || !isLostReply(cause)) return yield* failLogged(lost, fromInfra(new Unsettled("No reply came to a commit", { cause: lost }), after));
|
|
150
243
|
yield* chargeResends(1);
|
|
151
244
|
}
|
|
152
245
|
});
|
|
@@ -172,7 +265,7 @@ const codeErrors = [
|
|
|
172
265
|
* `Unavailable`, or any throw that's neither another infra error nor a defect of code. A wrong
|
|
173
266
|
* guess costs one resend under the same ID, which the store's receipt answers as the first.
|
|
174
267
|
*/
|
|
175
|
-
const isLostReply = (cause) => Predicate.isTagged(cause, "Unavailable") || !isInfraError(cause) && !codeErrors.some((code) => cause instanceof code);
|
|
268
|
+
const isLostReply = (cause) => !isOverloaded(cause) && !(cause instanceof Unavailable && cause.mayHaveSaved === true) && (Predicate.isTagged(cause, "Unavailable") || !isInfraError(cause) && !codeErrors.some((code) => cause instanceof code));
|
|
176
269
|
/**
|
|
177
270
|
* Whether a resend's `cause` is the store's own answer, made past its receipt: an infra refusal
|
|
178
271
|
* other than `Unavailable` or the platform's cap, which refuses a call before it reaches the store.
|
|
@@ -198,11 +291,6 @@ const decodeDerivedRow = (schema, row) => Option.match(Schema.decodeUnknownOptio
|
|
|
198
291
|
}), Effect.as(void 0)),
|
|
199
292
|
onSome: (derived) => Effect.succeed(derived)
|
|
200
293
|
});
|
|
201
|
-
/**
|
|
202
|
-
* A call that answers `Result`, as an Effect: its value, or its error failed. A throw is a defect.
|
|
203
|
-
* The call is handed a signal that aborts when the Effect is interrupted.
|
|
204
|
-
*/
|
|
205
|
-
const resultCall = (call) => Effect.flatMap(Effect.promise(call), fromAnswer);
|
|
206
294
|
/** Git's error as a Promise throws it, with the error as its `cause`. */
|
|
207
295
|
const thrownError = (error) => new Error(error.message, { cause: error });
|
|
208
296
|
/** Requests whose body read broke off because the client went away. */
|
|
@@ -244,4 +332,4 @@ const endedEarly = (cause) => {
|
|
|
244
332
|
cause
|
|
245
333
|
});
|
|
246
334
|
};
|
|
247
|
-
export { Unsettled, afterWrites, answerSpent, bestEffort, brokenRead, clientWentAway, commitCallsMost, decodeDerivedRow, decodeRow, endedEarly, fetchLess, fromInfra, isLimitRefusal, pastCallLimit, readBody,
|
|
335
|
+
export { Unsettled, afterWrites, answerSpent, bestEffort, brokenRead, clientWentAway, commitCallsMost, decodeDerivedRow, decodeRow, endedEarly, fetchLess, fromInfra, isLimitRefusal, pastCallLimit, readBody, routeEdge, storeCall, storeCommit, storeWatch, thrownError, thrownWords };
|
package/dist/store/git-store.mjs
CHANGED
|
@@ -5,9 +5,10 @@ import { decodeRow, storeCall, storeCommit } from "./errors.mjs";
|
|
|
5
5
|
import { JobLanded } from "./job-try.mjs";
|
|
6
6
|
import { outboxCollections } from "./outbox.mjs";
|
|
7
7
|
import { PackRow } from "./records.mjs";
|
|
8
|
+
import { RequestSnapshot } from "./request-snapshot.mjs";
|
|
8
9
|
import { collections, prunedKey, pushedKey, selfKey } from "./scopes.mjs";
|
|
9
|
-
import * as Effect from "effect/Effect";
|
|
10
10
|
import { Records } from "@ref0/infra";
|
|
11
|
+
import * as Effect from "effect/Effect";
|
|
11
12
|
import * as Context from "effect/Context";
|
|
12
13
|
// src/store/git-store.ts
|
|
13
14
|
const packsRead = { collection: collections.packs };
|
|
@@ -76,7 +77,11 @@ const featureChange = (scope, change) => {
|
|
|
76
77
|
const gitStore = (store) => ({
|
|
77
78
|
read: ({ scope, reads }) => {
|
|
78
79
|
const problem = scopeProblem(scope);
|
|
79
|
-
|
|
80
|
+
if (problem !== void 0) return fail("INVALID_ARGUMENT", problem);
|
|
81
|
+
return Effect.flatMap(RequestSnapshot, (snapshot) => {
|
|
82
|
+
const hit = snapshot?.answer(scope, reads);
|
|
83
|
+
return hit !== void 0 ? Effect.succeed(hit) : storeCall(store.read(scope, reads));
|
|
84
|
+
});
|
|
80
85
|
},
|
|
81
86
|
commit: ({ scope, change }) => Effect.andThen(featureChange(scope, change), storeCommit(store.commit(scope, change))),
|
|
82
87
|
add: ({ scope, addition }) => {
|
package/dist/store/job-try.mjs
CHANGED
|
@@ -3,12 +3,45 @@ import { gitError } from "../contracts/result.mjs";
|
|
|
3
3
|
import { CallBudget, checkedLimits, inCallScope, jobCallsAround, lessBefore, nestsIn, noScope, spentBudget } from "./call-count.mjs";
|
|
4
4
|
import { noCall, syncIn } from "./crossing.mjs";
|
|
5
5
|
import { jobRepo } from "./scopes.mjs";
|
|
6
|
+
import { CallLimits, CurrentJob } from "@ref0/infra";
|
|
6
7
|
import * as Effect from "effect/Effect";
|
|
7
|
-
import { CurrentJob } from "@ref0/infra";
|
|
8
8
|
import * as Context from "effect/Context";
|
|
9
|
+
import * as Option from "effect/Option";
|
|
10
|
+
import * as Scheduler from "effect/Scheduler";
|
|
9
11
|
// src/store/job-try.ts
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The longest a try of Git's long jobs runs: `git.index`'s, `git.repack`'s, `git.ref-index`'s and
|
|
14
|
+
* a push upload's, 3.5 minutes. An import's and a mirror's is `importTryTimeout`, longer until
|
|
15
|
+
* their transfers resume across tries. With the minute a host's `onFailure` may
|
|
16
|
+
* take, that's 270 s, which leaves 30 s of a Vercel Hobby function's 300 s for the run's own
|
|
17
|
+
* claim and settle (#2900). A step is cut at `jobBucketCallsDefault`'s 1,000 bucket calls, about
|
|
18
|
+
* 100 s at 100 ms a call, and no step is cut by CPU: s1m's heaviest, `git.index`'s bitmaps, took
|
|
19
|
+
* 35,138 ms of CPU in one try (s1m-upkeep run 46099393357), so its try fits with 75 s to spare. A
|
|
20
|
+
* Worker's alarm, 15 minutes, holds it on every platform, so it's one number everywhere.
|
|
21
|
+
*/
|
|
22
|
+
const jobTryTimeout = "210 seconds";
|
|
23
|
+
/**
|
|
24
|
+
* The bucket calls a try may make where the adapter bounds none, as Node's and Vercel's stores
|
|
25
|
+
* don't: Workers' 1,000, so a step that stops at a Worker's bound and goes on in its next try stops
|
|
26
|
+
* there on every platform. Without it, on Vercel, a step such as `git.index`'s `bitmaps`, 999
|
|
27
|
+
* calls a try on Workers for a million objects (#1132), ran on past a function's 300 s on calls
|
|
28
|
+
* alone (#2900). A request's calls stay the adapter's, unbounded where it gives none.
|
|
29
|
+
*/
|
|
30
|
+
const jobBucketCallsDefault = 1e3;
|
|
31
|
+
/**
|
|
32
|
+
* Checked `limits`, with `jobBucketCallsDefault` bucket calls where they bound none, `Infinity`
|
|
33
|
+
* included: what a job's try counts against, and what `packs()` plans each job's step on, so a
|
|
34
|
+
* step that stops at the bound saves where it got to, as on Workers.
|
|
35
|
+
*/
|
|
36
|
+
const jobCallLimitsOf = (limits) => {
|
|
37
|
+
const checked = checkedLimits(limits, "The adapter's callLimits.");
|
|
38
|
+
return checked.bucket === void 0 ? {
|
|
39
|
+
...checked,
|
|
40
|
+
bucket: jobBucketCallsDefault
|
|
41
|
+
} : checked;
|
|
42
|
+
};
|
|
43
|
+
/** A try's `JobLimits` under the adapter's `limits`: `jobCallLimitsOf`'s, less `jobCallsAround`. */
|
|
44
|
+
const jobLimitsOf = (limits) => lessBefore(jobCallLimitsOf(limits), jobCallsAround);
|
|
12
45
|
/** The step `jobStep` named, by each spent bound that ended it. */
|
|
13
46
|
const stepNames = /* @__PURE__ */ new WeakMap();
|
|
14
47
|
/** The step `spent` ended: `jobStep`'s name, or the spent budget's, or `whole` for the try's own. */
|
|
@@ -58,6 +91,19 @@ const stepYielded = (job, spent) => {
|
|
|
58
91
|
* instead of `job-step-calls`.
|
|
59
92
|
*/
|
|
60
93
|
const JobLanded = Context.Reference("@ref0/git/JobLanded", { defaultValue: () => void 0 });
|
|
94
|
+
const minLimit = (base, live) => base === void 0 ? live : live === void 0 ? base : Math.min(base, live);
|
|
95
|
+
/** Tightens `base` by a chained try's remaining invocation `live` `CallLimits` (#596). */
|
|
96
|
+
const narrowLimits = (base, live) => {
|
|
97
|
+
const bucket = minLimit(base.bucket, live.bucket);
|
|
98
|
+
const subrequests = minLimit(base.subrequests, live.subrequests);
|
|
99
|
+
if (bucket !== void 0 && subrequests !== void 0) return {
|
|
100
|
+
bucket,
|
|
101
|
+
subrequests
|
|
102
|
+
};
|
|
103
|
+
if (bucket !== void 0) return { bucket };
|
|
104
|
+
if (subrequests !== void 0) return { subrequests };
|
|
105
|
+
return {};
|
|
106
|
+
};
|
|
61
107
|
/**
|
|
62
108
|
* `run` in a fresh budget of `limits`, named `'job'`, nested in nothing, with `JobLanded` marking
|
|
63
109
|
* what lands: so a request's budget and a job's never count each other's calls (#2015).
|
|
@@ -71,16 +117,41 @@ const inJobBudget = (limits, run, spent) => Effect.flatMap(inCallScope(CallBudge
|
|
|
71
117
|
budget
|
|
72
118
|
}), (cause) => {
|
|
73
119
|
const own = ownSpentOf(cause, owns);
|
|
74
|
-
return own === void 0 ? Effect.failCause(cause) : spent(own, saved);
|
|
120
|
+
return own === void 0 ? Effect.failCause(cause) : spent(own, saved, budget);
|
|
75
121
|
});
|
|
76
122
|
});
|
|
77
123
|
/**
|
|
78
124
|
* A try of `name` in a budget of `limits`: one that spends it after a write landed fails as
|
|
79
125
|
* `stepYielded`, and the next try goes on from what it saved on a fresh count; one that saved
|
|
80
|
-
* nothing fails as `stepTooLarge`. Either way the job's retry policy bounds its tries. A
|
|
81
|
-
*
|
|
126
|
+
* nothing fails as `stepTooLarge`. Either way the job's retry policy bounds its tries. A chained
|
|
127
|
+
* try whose budget was narrowed by the invocation's remaining `CallLimits` yields `{ kind: 'more' }`
|
|
128
|
+
* without failing or consuming an attempt so a fresh alarm completes it under its full budget
|
|
129
|
+
* (#596). A spend never runs anything again within the try.
|
|
130
|
+
*/
|
|
131
|
+
const shrunkBound = (liveJob, base, bound) => {
|
|
132
|
+
const liveBound = liveJob?.[bound];
|
|
133
|
+
const baseBound = base[bound];
|
|
134
|
+
return liveBound !== void 0 && (baseBound === void 0 || liveBound < baseBound);
|
|
135
|
+
};
|
|
136
|
+
const budgetedTry = (limits, name, handler) => (data) => Effect.flatMap(Effect.serviceOption(CallLimits.CallLimits), (live) => {
|
|
137
|
+
const liveJob = Option.isSome(live) ? lessBefore(checkedLimits(live.value, "The adapter's callLimits."), jobCallsAround) : void 0;
|
|
138
|
+
return inJobBudget(liveJob === void 0 ? limits : narrowLimits(limits, liveJob), () => handler(data), (spent, saved, outer) => spentBudget(spent) === outer && shrunkBound(liveJob, limits, spent.bound) ? Effect.succeed({ kind: "more" }) : Effect.fail(saved.landed ? stepYielded(name, spent) : stepTooLarge(name, spent)));
|
|
139
|
+
});
|
|
140
|
+
/**
|
|
141
|
+
* Private brand shared with `@ref0/infra`'s `longestOf` so Cloudflare/Alchemy job objects chain
|
|
142
|
+
* only Git's allow-listed heavy definitions whose schemas and call bounds admission relies on (#596).
|
|
143
|
+
*/
|
|
144
|
+
const chainableJob = Symbol.for("@ref0/infra/chainableJob");
|
|
145
|
+
/**
|
|
146
|
+
* Git's own heavy job names whose entire handler runs through Git's budgeted doors with no host or
|
|
147
|
+
* registration callback, so Cloudflare/Alchemy job objects may safely chain their `more`
|
|
148
|
+
* continuations inside one alarm (#596). Left unmarked because they invoke host/registration
|
|
149
|
+
* callbacks that can call infra `Records`/`Bucket` outside `budgetedTry`: `git.deliver.*`
|
|
150
|
+
* (`addDelivery`), `git.repack` (`addUpkeep`), `git.purge` (`addPurge`), and `git.push-upload`
|
|
151
|
+
* (push `Policy`, `Rules`, `addPushCheck`, and `GitHooks` on landing), plus light jobs (`git.list`,
|
|
152
|
+
* `git.tokens.cleanup`) and external `addJob` definitions.
|
|
82
153
|
*/
|
|
83
|
-
const
|
|
154
|
+
const chainableGitJobs = /* @__PURE__ */ new Set(["git.index", "git.ref-index"]);
|
|
84
155
|
/** Each `gitJob`'s definition, remade in other limits by `jobsWithin`. */
|
|
85
156
|
const remakes = /* @__PURE__ */ new WeakMap();
|
|
86
157
|
/**
|
|
@@ -89,10 +160,20 @@ const remakes = /* @__PURE__ */ new WeakMap();
|
|
|
89
160
|
* them, or no bound till then. An `onFailure` that spends its budget fails as `stepTooLarge`, its
|
|
90
161
|
* step `onFailure`, which the queue logs before it settles the job failed with the try's failure. Every Git job is made here, which `lint/call-crossings.test.ts`
|
|
91
162
|
* holds, with no service but `CurrentJob`: Git's jobs close over the parts they run with.
|
|
163
|
+
*
|
|
164
|
+
* `Job.make` keeps the services its definition is made in, and `syncIn` runs on `runSync`'s
|
|
165
|
+
* scheduler, which hands a yielding fiber on through a microtask: a try kept on it would never let
|
|
166
|
+
* the host's timers or IO run while it works. So each definition is made with no scheduler in its
|
|
167
|
+
* services, and its tries run on Effect's default, yielding to the event loop as any other run of
|
|
168
|
+
* Git's does (#2888).
|
|
92
169
|
*/
|
|
93
170
|
const gitJob = (job, handler, options = {}) => {
|
|
94
171
|
const { onFailure } = options;
|
|
95
|
-
const made = (limits) =>
|
|
172
|
+
const made = (limits) => {
|
|
173
|
+
const built = syncIn(job.definition(budgetedTry(limits, job.name, handler), { ...onFailure && { onFailure: (data, failure) => inJobBudget(limits, () => onFailure(data, failure), (spent) => Effect.fail(stepTooLarge(job.name, spent, "onFailure"))) } }).pipe(Effect.updateContext((services) => Context.omit(Scheduler.Scheduler)(services))), noCall);
|
|
174
|
+
if (chainableGitJobs.has(job.name)) Object.defineProperty(built, chainableJob, { value: true });
|
|
175
|
+
return built;
|
|
176
|
+
};
|
|
96
177
|
const definition = made({});
|
|
97
178
|
remakes.set(definition, made);
|
|
98
179
|
return definition;
|
|
@@ -106,4 +187,4 @@ const jobParts = (job, handler, options) => (take) => take(job, handler, options
|
|
|
106
187
|
const jobsWithin = (limits, jobs) => jobs.map((job) => remakes.get(job)?.(limits) ?? job);
|
|
107
188
|
/** The repo whose scope the try runs in: in any other scope, it's a defect, as `jobRepo` says. */
|
|
108
189
|
const currentRepo = Effect.map(CurrentJob.current, jobRepo);
|
|
109
|
-
export { JobLanded, currentRepo, gitJob, jobLimitsOf, jobParts, jobsWithin, stepTooLarge };
|
|
190
|
+
export { JobLanded, chainableGitJobs, currentRepo, gitJob, jobBucketCallsDefault, jobCallLimitsOf, jobLimitsOf, jobParts, jobTryTimeout, jobsWithin, stepTooLarge };
|
package/dist/store/list-job.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { reconcile } from "./catalogue.mjs";
|
|
2
2
|
import { currentRepo, gitJob } from "./job-try.mjs";
|
|
3
|
-
import
|
|
3
|
+
import { Job } from "@ref0/infra";
|
|
4
4
|
import * as Schema from "effect/Schema";
|
|
5
|
-
import
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
6
|
// src/store/list-job.ts
|
|
7
7
|
const ListData = /* @__PURE__ */ Schema.Struct({});
|
|
8
8
|
const listJobName = "git.list";
|
|
@@ -17,36 +17,23 @@ const ListJob = /* @__PURE__ */ Job.make(listJobName, {
|
|
|
17
17
|
maxDelay: "5 minutes"
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
schema: emptySchema,
|
|
25
|
-
handler: () => {
|
|
26
|
-
throw new TypeError("'git.repack' runs under repackJob");
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
/** `git.purge`'s row, by `defineJob`, for a lost create `git.list` puts aside without importing `core/`. */
|
|
30
|
-
const purgeRows = /* @__PURE__ */ defineJob({
|
|
31
|
-
name: "git.purge",
|
|
32
|
-
schema: emptySchema,
|
|
33
|
-
handler: () => {
|
|
34
|
-
throw new TypeError("'git.purge' runs under purgeJob");
|
|
35
|
-
}
|
|
36
|
-
});
|
|
20
|
+
/** `git.repack`'s rows, for a lost create `git.list` puts aside without importing `storage/`. */
|
|
21
|
+
const repackRows = /* @__PURE__ */ Job.make("git.repack", { payload: ListData });
|
|
22
|
+
/** `git.purge`'s row, for a lost create `git.list` puts aside without importing `core/`. */
|
|
23
|
+
const purgeRows = /* @__PURE__ */ Job.make("git.purge", { payload: ListData });
|
|
37
24
|
/** Cleanup and purge jobs queued when `git.list` puts aside a create that crashed before standing aside (#1911). */
|
|
38
25
|
const lostCreateJobs = (record) => [
|
|
39
|
-
repackRows.
|
|
26
|
+
repackRows.encodedJob({
|
|
40
27
|
key: "repack",
|
|
41
28
|
data: {},
|
|
42
29
|
at: record.changedAt
|
|
43
30
|
}),
|
|
44
|
-
...record.fork === void 0 ? [] : [repackRows.
|
|
31
|
+
...record.fork === void 0 ? [] : [repackRows.encodedJob({
|
|
45
32
|
key: "prune",
|
|
46
33
|
data: {},
|
|
47
34
|
at: record.changedAt
|
|
48
35
|
})],
|
|
49
|
-
purgeRows.
|
|
36
|
+
purgeRows.encodedJob({
|
|
50
37
|
key: "purge",
|
|
51
38
|
data: {},
|
|
52
39
|
at: record.changedAt
|
|
@@ -58,19 +45,8 @@ const lostCreateJobs = (record) => [
|
|
|
58
45
|
* Its try stops at its timeout, which interrupts it.
|
|
59
46
|
*/
|
|
60
47
|
const listJob = (store) => gitJob(ListJob, () => Effect.asVoid(Effect.flatMap(currentRepo, (internalId) => reconcile(store, internalId, lostCreateJobs))));
|
|
61
|
-
/**
|
|
62
|
-
* `git.list`'s rows, by `defineJob`, as `ListJob.encodedJob` makes them: a write saves one beside
|
|
63
|
-
* its record without `Job.make`'s runtime, which only the server that runs `listJob` needs.
|
|
64
|
-
*/
|
|
65
|
-
const listRows = /* @__PURE__ */ defineJob({
|
|
66
|
-
name: listJobName,
|
|
67
|
-
schema: Schema.toStandardSchemaV1(ListData),
|
|
68
|
-
handler: () => {
|
|
69
|
-
throw new TypeError(`'${listJobName}' runs under listJob`);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
48
|
/** The job a repo's write saves beside its record. */
|
|
73
|
-
const listJobRow = () =>
|
|
49
|
+
const listJobRow = () => ListJob.encodedJob({
|
|
74
50
|
key: listJobKey,
|
|
75
51
|
data: {}
|
|
76
52
|
});
|
package/dist/store/outbox.d.mts
CHANGED
|
@@ -2,9 +2,9 @@ import "../contracts/events.mjs";
|
|
|
2
2
|
import "../contracts/actors.mjs";
|
|
3
3
|
import { RepoName } from "../contracts/ids.mjs";
|
|
4
4
|
import "../contracts/result.mjs";
|
|
5
|
-
import "effect/Effect";
|
|
6
|
-
import "effect/Schema";
|
|
7
5
|
import { JobInput, Key, Moment, Read, Row, Scope } from "@ref0/infra";
|
|
6
|
+
import "effect/Schema";
|
|
7
|
+
import "effect/Effect";
|
|
8
8
|
import "effect/Types";
|
|
9
9
|
declare const settledBrand: unique symbol;
|
|
10
10
|
/**
|
package/dist/store/outbox.mjs
CHANGED
|
@@ -4,11 +4,11 @@ import { fail } from "../contracts/result.mjs";
|
|
|
4
4
|
import { decodeRow } from "./errors.mjs";
|
|
5
5
|
import { versionId } from "./records.mjs";
|
|
6
6
|
import { repoScope, scopeRepo } from "./scopes.mjs";
|
|
7
|
+
import { jsonBytes } from "@ref0/infra";
|
|
8
|
+
import * as Schema from "effect/Schema";
|
|
7
9
|
import * as Effect from "effect/Effect";
|
|
8
10
|
import * as Option from "effect/Option";
|
|
9
|
-
import * as Schema from "effect/Schema";
|
|
10
11
|
import * as Result from "effect/Result";
|
|
11
|
-
import { jsonBytes } from "@ref0/infra";
|
|
12
12
|
// src/store/outbox.ts
|
|
13
13
|
/**
|
|
14
14
|
* The branches and tags of one write that one private pattern holds, as `AccessOption.patternOf`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Job } from "@ref0/infra";
|
|
1
2
|
import * as Schema from "effect/Schema";
|
|
2
|
-
import { defineJob } from "@ref0/infra";
|
|
3
3
|
// src/store/queue-jobs.ts
|
|
4
4
|
/**
|
|
5
5
|
* The merge queue's jobs' names, data and rows, which the queue's writes save, and a push from
|
|
@@ -25,29 +25,23 @@ const TrimData = /* @__PURE__ */ Schema.Struct({
|
|
|
25
25
|
* Makes a queue job's rows, beside the rows that need it. The server's definitions, with the same
|
|
26
26
|
* names and schemas, run them; these are never registered.
|
|
27
27
|
*/
|
|
28
|
-
const rowsOf = (name, schema) =>
|
|
29
|
-
name,
|
|
30
|
-
schema: Schema.toStandardSchemaV1(schema),
|
|
31
|
-
handler: () => {
|
|
32
|
-
throw new TypeError(`'${name}' runs under the server's definition`);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
28
|
+
const rowsOf = (name, schema) => Job.make(name, { payload: schema });
|
|
35
29
|
const advanceRows = /* @__PURE__ */ rowsOf(advanceName, AdvanceData);
|
|
36
30
|
const buildRows = /* @__PURE__ */ rowsOf(buildName, CandidateData);
|
|
37
31
|
const timeoutRows = /* @__PURE__ */ rowsOf(timeoutName, CandidateData);
|
|
38
32
|
const trimRows = /* @__PURE__ */ rowsOf(trimName, TrimData);
|
|
39
33
|
/** `queue.advance` for `target`, due now: one row a target, which a later save leaves due. */
|
|
40
|
-
const advanceRow = (target) => advanceRows.
|
|
34
|
+
const advanceRow = (target) => advanceRows.encodedJob({
|
|
41
35
|
key: target,
|
|
42
36
|
data: { target }
|
|
43
37
|
});
|
|
44
38
|
/** `queue.build` for a candidate just opened. */
|
|
45
|
-
const buildRow = (candidate) => buildRows.
|
|
39
|
+
const buildRow = (candidate) => buildRows.encodedJob({
|
|
46
40
|
key: candidate,
|
|
47
41
|
data: { candidate }
|
|
48
42
|
});
|
|
49
43
|
/** `queue.report-timeout` for a candidate opened for checks, due when its report is late. */
|
|
50
|
-
const timeoutRow = (candidate, at) => timeoutRows.
|
|
44
|
+
const timeoutRow = (candidate, at) => timeoutRows.encodedJob({
|
|
51
45
|
key: candidate,
|
|
52
46
|
data: { candidate },
|
|
53
47
|
at
|
|
@@ -56,7 +50,7 @@ const timeoutRow = (candidate, at) => timeoutRows.job({
|
|
|
56
50
|
* `queue.trim` for the repo, due `at`, a target's first write saves: one row a repo, which a save
|
|
57
51
|
* while it's due sooner, or mid-pass, leaves as it is.
|
|
58
52
|
*/
|
|
59
|
-
const trimRow = (at) => trimRows.
|
|
53
|
+
const trimRow = (at) => trimRows.encodedJob({
|
|
60
54
|
key: "trim",
|
|
61
55
|
data: { phase: "targets" },
|
|
62
56
|
at
|
package/dist/store/records.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "../contracts/actors.mjs";
|
|
2
2
|
import "../contracts/result.mjs";
|
|
3
|
-
import "effect/Effect";
|
|
4
|
-
import * as Schema from "effect/Schema";
|
|
5
3
|
import { Key } from "@ref0/infra";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
import "effect/Effect";
|
|
6
6
|
/**
|
|
7
7
|
* A name's entry in `git/repos`: `RepoCatalogueEntry`, as it's stored. `before` holds the repos
|
|
8
8
|
* that held the name before, newest first, so a write sent again by name finds the receipt its
|
package/dist/store/records.mjs
CHANGED
|
@@ -3,10 +3,10 @@ import { fail } from "../contracts/result.mjs";
|
|
|
3
3
|
import { Pack } from "../contracts/store.mjs";
|
|
4
4
|
import { utf8 } from "../protocol/bytes/text.mjs";
|
|
5
5
|
import { collections } from "./scopes.mjs";
|
|
6
|
-
import * as Effect from "effect/Effect";
|
|
7
6
|
import * as Schema from "effect/Schema";
|
|
8
|
-
import * as
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
9
8
|
import * as Hex from "effect/encoding/Hex";
|
|
9
|
+
import * as Struct from "effect/Struct";
|
|
10
10
|
// src/store/records.ts
|
|
11
11
|
const Revision = Schema.Int;
|
|
12
12
|
/** The `seq` a name's next event takes, kept on its tombstone so a repo made again goes on from it. */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "../contracts/result.mjs";
|
|
2
2
|
import "../contracts/ids.mjs";
|
|
3
|
-
import "effect/Effect";
|
|
4
|
-
import "effect/Schema";
|
|
5
3
|
import { Row } from "@ref0/infra";
|
|
4
|
+
import "effect/Schema";
|
|
5
|
+
import "effect/Effect";
|
|
6
6
|
/**
|
|
7
7
|
* Leave to read every ref of a repo, whoever the caller is. A call made for a caller reads refs
|
|
8
8
|
* through its `RepoView`, which leaves out the refs the caller doesn't see, and only the readers
|
package/dist/store/ref-rows.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { decodeRow } from "./errors.mjs";
|
|
2
2
|
import { collections } from "./scopes.mjs";
|
|
3
3
|
import { fail } from "../contracts/result.mjs";
|
|
4
|
-
import * as Effect from "effect/Effect";
|
|
5
|
-
import * as Schema from "effect/Schema";
|
|
6
4
|
import { jsonBytes, limits } from "@ref0/infra";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
7
|
const oid = Schema.String.check(Schema.isPattern(new RegExp(`^(?:[0-9a-f]{40}|[0-9a-f]{64})$`)));
|
|
8
8
|
/**
|
|
9
9
|
* A ref's row in `refs`, keyed by its full name, such as `refs/heads/main`. `peeled` means one of
|
|
@@ -6,9 +6,9 @@ import "../contracts/store.mjs";
|
|
|
6
6
|
import "../protocol/objects/commit.mjs";
|
|
7
7
|
import "../contracts/result.mjs";
|
|
8
8
|
import "./records.mjs";
|
|
9
|
-
import * as Effect from "effect/Effect";
|
|
10
|
-
import "effect/Schema";
|
|
11
9
|
import { Addition, JobInput, Key, Moment, Read, Records, Row, Scope, Snapshot } from "@ref0/infra";
|
|
10
|
+
import "effect/Schema";
|
|
11
|
+
import * as Effect from "effect/Effect";
|
|
12
12
|
import "effect/Context";
|
|
13
13
|
import "effect/Types";
|
|
14
14
|
/**
|
|
@@ -7,11 +7,11 @@ import { afterWrites, decodeRow, storeCall, storeCommit } from "./errors.mjs";
|
|
|
7
7
|
import { listJobRow } from "./list-job.mjs";
|
|
8
8
|
import { LooseTally, RepoRootsRow, StatsTime, repoRootsMost } from "./records.mjs";
|
|
9
9
|
import { looseKey, maintainedKey, newChangeId, pushedKey, reachedKey, repoRootsKey, repoScope, selfKey } from "./scopes.mjs";
|
|
10
|
-
import * as Clock from "effect/Clock";
|
|
11
|
-
import * as Effect from "effect/Effect";
|
|
12
|
-
import * as Schema from "effect/Schema";
|
|
13
10
|
import { jobLeaseMargin } from "@ref0/infra";
|
|
11
|
+
import * as Schema from "effect/Schema";
|
|
12
|
+
import * as Effect from "effect/Effect";
|
|
14
13
|
import * as Context from "effect/Context";
|
|
14
|
+
import * as Clock from "effect/Clock";
|
|
15
15
|
import * as Hex from "effect/encoding/Hex";
|
|
16
16
|
// src/store/repo-record.ts
|
|
17
17
|
/** A repo's record and its scope's rows, read at one version: `results[0]` is `self`. */
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
// src/store/request-snapshot.ts
|
|
3
|
+
/** The active request's read snapshot, if any (`undefined` outside Git HTTP routes). */
|
|
4
|
+
const RequestSnapshot = Context.Reference("@ref0/git/RequestSnapshot", { defaultValue: () => void 0 });
|
|
5
|
+
export { RequestSnapshot };
|
|
@@ -2,9 +2,9 @@ import "../contracts/ids.mjs";
|
|
|
2
2
|
import { gitError } from "../contracts/result.mjs";
|
|
3
3
|
import { decodeRow, storeCall } from "./errors.mjs";
|
|
4
4
|
import { collections, topicScope } from "./scopes.mjs";
|
|
5
|
-
import * as Effect from "effect/Effect";
|
|
6
|
-
import * as Schema from "effect/Schema";
|
|
7
5
|
import { jsonBytes } from "@ref0/infra";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
8
|
// src/store/reservations.ts
|
|
9
9
|
/**
|
|
10
10
|
* A target's reservation, a field of its `queue-targets` row in its repo's scope, and of its
|