@ref0/git 0.14.0 → 0.20.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/auth/access-jwt.mjs +2 -2
- package/dist/auth/authorize.mjs +3 -3
- package/dist/auth/fences.d.mts +1 -2
- package/dist/auth/fences.mjs +3 -3
- package/dist/auth/grants.mjs +4 -4
- package/dist/auth/host-function.mjs +18 -1
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +3 -3
- package/dist/auth/token-cleanup.mjs +67 -0
- package/dist/auth/token-rows.mjs +1 -1
- package/dist/auth/token-text.mjs +9 -1
- package/dist/auth/tokens-base.d.mts +35 -0
- package/dist/auth/tokens-base.mjs +13 -0
- package/dist/auth/tokens-layer.d.mts +2 -27
- package/dist/auth/tokens-layer.mjs +6 -11
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +7 -10
- package/dist/auth/tokens.mjs +9 -80
- package/dist/client/answer.mjs +21 -42
- package/dist/client/client.d.mts +2 -4
- package/dist/client/git-http.mjs +17 -7
- package/dist/client/local.mjs +14 -13
- package/dist/client/push-upload.mjs +9 -8
- package/dist/client/remote.mjs +8 -10
- package/dist/client/run-remote-helper.d.mts +1 -0
- package/dist/client/run-remote-helper.mjs +58 -24
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +105 -46
- package/dist/contracts/blobs.d.mts +55 -8
- package/dist/contracts/blobs.mjs +16 -2
- package/dist/contracts/call-allowance.d.mts +13 -0
- package/dist/contracts/call-allowance.mjs +44 -0
- package/dist/contracts/calls-spent.mjs +8 -3
- package/dist/contracts/client.d.mts +15 -16
- package/dist/contracts/commits.d.mts +24 -24
- package/dist/contracts/engine.d.mts +6 -1
- package/dist/contracts/engine.mjs +10 -1
- package/dist/contracts/files.d.mts +10 -10
- package/dist/contracts/forks.d.mts +17 -17
- package/dist/contracts/git-events.d.mts +29 -1
- package/dist/contracts/git-hooks.d.mts +1 -1
- package/dist/contracts/git.d.mts +21 -0
- package/dist/contracts/grants.d.mts +24 -4
- package/dist/contracts/handlers.d.mts +1 -1
- package/dist/contracts/lfs.d.mts +28 -2
- package/dist/contracts/merges.d.mts +3 -2
- package/dist/contracts/objects.d.mts +23 -25
- package/dist/contracts/queue.d.mts +40 -12
- package/dist/contracts/queue.mjs +3 -4
- package/dist/contracts/refs.d.mts +26 -23
- package/dist/contracts/remote.d.mts +6 -7
- package/dist/contracts/remote.mjs +4 -1
- package/dist/contracts/repos.d.mts +29 -138
- package/dist/contracts/repos.mjs +5 -3
- package/dist/contracts/result.d.mts +35 -16
- package/dist/contracts/result.mjs +35 -7
- package/dist/contracts/server.d.mts +25 -50
- package/dist/contracts/services.d.mts +1 -1
- package/dist/contracts/store.d.mts +6 -5
- package/dist/contracts/sync.d.mts +11 -7
- package/dist/contracts/sync.mjs +12 -2
- package/dist/contracts/tags.d.mts +10 -10
- package/dist/contracts/time.d.mts +3 -0
- package/dist/contracts/{promises.mjs → time.mjs} +1 -1
- package/dist/contracts/tokens.d.mts +15 -17
- package/dist/contracts/tokens.mjs +3 -2
- package/dist/contracts/topics.d.mts +1 -1
- package/dist/contracts/trees.d.mts +12 -12
- package/dist/contracts/work.d.mts +24 -13
- package/dist/core/access.d.mts +1 -2
- package/dist/core/access.mjs +20 -9
- package/dist/core/ancestry.d.mts +1 -0
- package/dist/core/asked.mjs +1 -1
- package/dist/core/call-names.mjs +6 -1
- package/dist/core/call-services.mjs +11 -3
- package/dist/core/events/deliver.d.mts +1 -2
- package/dist/core/events/deliver.mjs +43 -36
- package/dist/core/events/retired.mjs +119 -0
- package/dist/core/forks.mjs +928 -432
- package/dist/core/hooks/groups.mjs +1 -1
- package/dist/core/imports.mjs +29 -23
- package/dist/core/index-job.mjs +122 -34
- package/dist/core/index-lost.d.mts +1 -2
- package/dist/core/index-lost.mjs +2 -2
- package/dist/core/loose-tally.mjs +1 -1
- package/dist/core/objects/blobs.mjs +129 -3
- package/dist/core/objects/lines.mjs +2 -2
- package/dist/core/objects/merges.mjs +4 -1
- package/dist/core/objects/objects-layer.d.mts +1 -1
- package/dist/core/objects/objects-layer.mjs +3 -3
- package/dist/core/objects/reading.mjs +24 -13
- package/dist/core/objects/tags.mjs +4 -1
- package/dist/core/objects/trees.mjs +2 -2
- package/dist/core/objects/writing.mjs +2 -2
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +4 -5
- package/dist/core/parts.mjs +3 -8
- package/dist/core/promise.mjs +9 -12
- package/dist/core/purge.mjs +287 -83
- package/dist/core/push-decide.mjs +2 -0
- package/dist/core/push-files.d.mts +1 -1
- package/dist/core/push.mjs +58 -47
- package/dist/core/receipts.mjs +8 -3
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +2 -2
- package/dist/core/refs.mjs +5 -5
- package/dist/core/registered-rows.mjs +2 -2
- package/dist/core/repack.mjs +36 -21
- package/dist/core/repo-info.mjs +3 -3
- package/dist/core/repos.mjs +21 -9
- package/dist/core/rules/commit-changes.d.mts +0 -1
- package/dist/core/saved-caller-views.d.mts +7 -2
- package/dist/core/saved-caller-views.mjs +2 -2
- package/dist/core/saved-callers.d.mts +19 -2
- package/dist/core/seam.d.mts +16 -26
- package/dist/core/seam.mjs +7 -28
- package/dist/core/tokens.mjs +1 -1
- package/dist/core/view.mjs +7 -15
- package/dist/core/work.mjs +59 -14
- package/dist/effect.d.mts +3 -12
- package/dist/effect.mjs +1 -10
- package/dist/engine/failures.mjs +2 -1
- package/dist/engine/reads.mjs +4 -4
- package/dist/event-streams/stream.d.mts +2 -2
- package/dist/event-streams/stream.mjs +37 -14
- package/dist/extend.d.mts +2 -3
- package/dist/extend.mjs +2 -1
- package/dist/http/answers.mjs +8 -5
- package/dist/http/core-parts.mjs +95 -79
- package/dist/http/handler.mjs +34 -7
- package/dist/http/node.d.mts +14 -1
- package/dist/http/node.mjs +56 -27
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +30 -26
- package/dist/http/push-uploads.mjs +36 -21
- package/dist/http/upload-pack.mjs +3 -3
- package/dist/index.d.mts +14 -14
- package/dist/index.mjs +2 -2
- package/dist/lfs/answer.mjs +37 -0
- package/dist/lfs/base.d.mts +2 -0
- package/dist/lfs/base.mjs +25 -1
- package/dist/lfs/copy.d.mts +21 -7
- package/dist/lfs/copy.mjs +89 -6
- package/dist/lfs/layer.d.mts +15 -1
- package/dist/lfs/layer.mjs +24 -11
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +1 -0
- package/dist/lfs/objects.mjs +87 -17
- package/dist/lfs/pointers.mjs +2 -2
- package/dist/lfs/rows.mjs +42 -8
- package/dist/lfs/upkeep.mjs +48 -14
- package/dist/lfs/wire.mjs +6 -31
- package/dist/merges/merges.mjs +2 -2
- package/dist/node.d.mts +2 -2
- package/dist/protocol/bytes/buffers.mjs +13 -5
- package/dist/protocol/bytes/reader.mjs +6 -1
- package/dist/protocol/bytes/streams.mjs +27 -1
- package/dist/protocol/diff/read.d.mts +4 -3
- package/dist/protocol/diff/read.mjs +8 -3
- package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
- package/dist/protocol/objects/lfs-pointer.mjs +1 -3
- package/dist/protocol/objects/links-raw.mjs +24 -10
- package/dist/protocol/objects/tag.d.mts +1 -1
- package/dist/protocol/objects/tree.mjs +23 -6
- package/dist/protocol/packs/delta.d.mts +6 -3
- package/dist/protocol/packs/delta.mjs +96 -32
- package/dist/protocol/packs/idx.d.mts +2 -1
- package/dist/protocol/packs/idx.mjs +22 -3
- package/dist/protocol/packs/parts.d.mts +4 -1
- package/dist/protocol/packs/parts.mjs +10 -7
- package/dist/protocol/packs/reader.d.mts +5 -0
- package/dist/protocol/packs/reader.mjs +3 -2
- package/dist/protocol/packs/writer.mjs +26 -8
- package/dist/queue/advance.mjs +21 -24
- package/dist/queue/base.d.mts +55 -0
- package/dist/queue/base.mjs +44 -0
- package/dist/queue/calls.mjs +51 -54
- package/dist/queue/commit.mjs +1 -1
- package/dist/queue/host.d.mts +1 -15
- package/dist/queue/host.mjs +2 -7
- package/dist/queue/layer.d.mts +2 -1
- package/dist/queue/layer.mjs +10 -3
- package/dist/queue/limits.mjs +2 -0
- package/dist/queue/push-option.mjs +9 -24
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/state.mjs +2 -10
- package/dist/queue/trim.mjs +5 -3
- package/dist/rest/blobs.mjs +29 -5
- package/dist/rest/caller.d.mts +4 -4271
- package/dist/rest/caller.mjs +4 -0
- package/dist/rest/client.d.mts +8 -5
- package/dist/rest/client.mjs +19 -2
- package/dist/rest/handlers.mjs +50 -5
- package/dist/rest/layer.d.mts +2 -2
- package/dist/rest/layer.mjs +5 -12
- package/dist/rest/me.d.mts +3 -432
- package/dist/server/check-fetch.mjs +3 -3
- package/dist/server/edge-node.d.mts +11 -8
- package/dist/server/edge-node.mjs +9 -6
- package/dist/server/edge.d.mts +21 -7
- package/dist/server/edge.mjs +32 -11
- package/dist/server/extension.mjs +1 -1
- package/dist/server/git-layer.d.mts +5 -5
- package/dist/server/git-layer.mjs +28 -22
- package/dist/server/git-namespace.d.mts +4 -3
- package/dist/server/git-namespace.mjs +3 -2
- package/dist/server/joined.d.mts +6 -18
- package/dist/server/joined.mjs +9 -36
- package/dist/server/lifecycle.mjs +18 -106
- package/dist/server/registry.mjs +24 -7
- package/dist/server/server.mjs +205 -346
- package/dist/signin/context.d.mts +1 -2
- package/dist/signin/layer.d.mts +1 -1
- package/dist/signin/layer.mjs +1 -1
- package/dist/storage/allotted.mjs +18 -3
- package/dist/storage/batch-upkeep.mjs +274 -0
- package/dist/storage/batches.d.mts +8 -0
- package/dist/storage/batches.mjs +344 -0
- package/dist/storage/calls.d.mts +1 -2
- package/dist/storage/calls.mjs +144 -158
- package/dist/storage/chunks.d.mts +9 -0
- package/dist/storage/chunks.mjs +297 -0
- package/dist/storage/clean-up.mjs +72 -9
- package/dist/storage/counted-bucket.mjs +4 -4
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +287 -210
- package/dist/storage/host-bucket.mjs +1 -2
- package/dist/storage/id-mix.mjs +19 -5
- package/dist/storage/index-bitmaps.mjs +9 -2
- package/dist/storage/index-build.d.mts +0 -1
- package/dist/storage/index-build.mjs +80 -23
- package/dist/storage/index-fetch.mjs +113 -72
- package/dist/storage/index-files.d.mts +3 -0
- package/dist/storage/index-files.mjs +10 -5
- package/dist/storage/index-graph.mjs +72 -22
- package/dist/storage/index-remap.mjs +200 -64
- package/dist/storage/index-whole.mjs +127 -0
- package/dist/storage/largest-files.mjs +1 -1
- package/dist/storage/layout.mjs +23 -0
- package/dist/storage/loose.d.mts +7 -4
- package/dist/storage/loose.mjs +212 -67
- package/dist/storage/memory-budget.mjs +16 -4
- package/dist/storage/merge-plan.mjs +3 -2
- package/dist/storage/merge-row.mjs +7 -1
- package/dist/storage/merge-stream.mjs +164 -25
- package/dist/storage/merge-walk.mjs +8 -4
- package/dist/storage/merge-write.mjs +1 -1
- package/dist/storage/merge.d.mts +1 -1
- package/dist/storage/merge.mjs +1 -1
- package/dist/storage/object-rows.d.mts +1 -0
- package/dist/storage/object-rows.mjs +385 -65
- package/dist/storage/oid-table.mjs +171 -0
- package/dist/storage/pack-order.mjs +8 -4
- package/dist/storage/pack-ranges.d.mts +1 -2
- package/dist/storage/pack-ranges.mjs +4 -5
- package/dist/storage/pack-reads.d.mts +2 -1
- package/dist/storage/pack-reads.mjs +158 -42
- package/dist/storage/pack-receive.d.mts +1 -1
- package/dist/storage/pack-receive.mjs +2 -2
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +136 -66
- package/dist/storage/placed-reads.mjs +1 -1
- package/dist/storage/plan-columns.d.mts +4 -0
- package/dist/storage/plan-columns.mjs +238 -0
- package/dist/storage/prune-keep.mjs +134 -41
- package/dist/storage/prune-walk.mjs +202 -62
- package/dist/storage/prune.mjs +194 -91
- package/dist/storage/push-allotment.mjs +91 -12
- package/dist/storage/push-uploads.mjs +4 -4
- package/dist/storage/pushed-commits.mjs +4 -2
- package/dist/storage/quarantine.d.mts +1 -1
- package/dist/storage/range-cache.mjs +125 -8
- package/dist/storage/ready.d.mts +1 -1
- package/dist/storage/ready.mjs +8 -6
- package/dist/storage/receive-bounds.mjs +23 -8
- package/dist/storage/repack-backlog.mjs +6 -3
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/rows.d.mts +1 -1
- package/dist/storage/rows.mjs +1 -1
- package/dist/storage/runs.mjs +195 -43
- package/dist/storage/send-list.d.mts +1 -0
- package/dist/storage/send-list.mjs +54 -10
- package/dist/storage/single-flight.mjs +13 -7
- package/dist/storage/stream-whole.mjs +127 -26
- package/dist/storage/unpack.mjs +371 -79
- package/dist/storage/visible.mjs +2 -2
- package/dist/storage/walk.mjs +192 -38
- package/dist/storage/wants.mjs +5 -5
- package/dist/store/bodies.mjs +38 -0
- package/dist/store/call-count.d.mts +8 -12
- package/dist/store/call-count.mjs +34 -46
- package/dist/store/catalogue.d.mts +2 -2
- package/dist/store/catalogue.mjs +145 -35
- package/dist/store/crossing.mjs +1 -3
- package/dist/store/cursor-seal.d.mts +1 -2
- package/dist/store/cursor-seal.mjs +16 -6
- package/dist/store/door.mjs +183 -0
- package/dist/store/errors.d.mts +3 -4
- package/dist/store/errors.mjs +15 -33
- package/dist/store/git-store.mjs +25 -7
- package/dist/store/job-try.mjs +9 -32
- package/dist/store/list-job.mjs +44 -8
- package/dist/store/records.d.mts +3 -0
- package/dist/store/records.mjs +3 -0
- package/dist/store/repo-record.d.mts +1 -2
- package/dist/store/repo-record.mjs +32 -20
- package/dist/store/reservations.mjs +1 -1
- package/dist/store/scopes.mjs +11 -0
- package/dist/store/settle.mjs +4 -4
- package/dist/sync/github.mjs +3 -3
- package/dist/sync/import.mjs +31 -18
- package/dist/sync/lfs-batch.mjs +4 -5
- package/dist/sync/lfs-copy.mjs +17 -6
- package/dist/sync/mirror.mjs +34 -31
- package/dist/sync/said.mjs +16 -37
- package/dist/sync/step.mjs +33 -25
- package/dist/sync/tries.mjs +9 -9
- package/dist/topics/advance.mjs +10 -11
- package/dist/topics/base.d.mts +15 -0
- package/dist/topics/base.mjs +8 -0
- package/dist/topics/host.mjs +1 -1
- package/dist/topics/layer.d.mts +4 -9
- package/dist/topics/layer.mjs +2 -3
- package/dist/topics/members.mjs +4 -4
- package/dist/topics/public.d.mts +2 -1
- package/dist/topics/topic.mjs +2 -2
- package/package.json +5 -4
- package/dist/contracts/promises.d.mts +0 -39
- package/dist/core/call-names.d.mts +0 -3
- package/dist/core/clock.mjs +0 -18
- package/dist/lfs/calls.mjs +0 -26
- package/dist/rest/api.d.mts +0 -23
- package/dist/rest/blobs.d.mts +0 -833
- package/dist/rest/commits.d.mts +0 -3543
- package/dist/rest/errors.d.mts +0 -2124
- package/dist/rest/events.d.mts +0 -426
- package/dist/rest/files.d.mts +0 -1342
- package/dist/rest/forks.d.mts +0 -2160
- package/dist/rest/handlers.d.mts +0 -8
- package/dist/rest/merges.d.mts +0 -477
- package/dist/rest/queue.d.mts +0 -5917
- package/dist/rest/refs.d.mts +0 -2988
- package/dist/rest/repos.d.mts +0 -2567
- package/dist/rest/tags.d.mts +0 -1316
- package/dist/rest/tokens.d.mts +0 -2614
- package/dist/rest/topics.d.mts +0 -2224
- package/dist/rest/trees.d.mts +0 -1709
- package/dist/rest/work.d.mts +0 -1695
- package/dist/server/lifecycle.d.mts +0 -2
- package/dist/store/promises.d.mts +0 -11
- package/dist/store/promises.mjs +0 -327
package/dist/store/errors.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fail, gitError, gitErrorFrom } from "../contracts/result.mjs";
|
|
2
2
|
import { callLimitIn, callLimitTry, catchSpent, fromAnswer, spentAt, spentRefusal } from "../contracts/calls-spent.mjs";
|
|
3
3
|
import { chargeCall, chargeResends, committedNow } from "./call-count.mjs";
|
|
4
|
-
import { isServerClosed
|
|
4
|
+
import { isServerClosed } from "./closed.mjs";
|
|
5
5
|
import * as Effect from "effect/Effect";
|
|
6
6
|
import * as Option from "effect/Option";
|
|
7
7
|
import * as Schema from "effect/Schema";
|
|
@@ -9,8 +9,8 @@ import * as Cause from "effect/Cause";
|
|
|
9
9
|
import * as Exit from "effect/Exit";
|
|
10
10
|
import { isInfraError } from "@ref0/infra";
|
|
11
11
|
import * as Predicate from "effect/Predicate";
|
|
12
|
-
import * as Stream from "effect/Stream";
|
|
13
12
|
import * as Data from "effect/Data";
|
|
13
|
+
import * as Stream from "effect/Stream";
|
|
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" };
|
|
@@ -111,19 +111,25 @@ const routeEdge = (effect, refused) => Effect.catch(answerSpent(effect), (error)
|
|
|
111
111
|
* `spentRefusal`'s, and any other defect a defect still.
|
|
112
112
|
*/
|
|
113
113
|
const answerSpent = (effect) => catchSpent(effect, (spent) => Effect.fail(spentRefusal(spent)));
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
/**
|
|
115
|
+
* A store call, its refusal as Git's error: one of the two doors every call Git makes goes
|
|
116
|
+
* through, with `bucketCall`, and every call a package built on Git makes, as `@ref0/github`'s
|
|
117
|
+
* records (Q826). It counts into the request and the `CallBudget` in scope, and never starts past
|
|
118
|
+
* either's bound (Q799): past one, it dies with `CallsSpent`, which an edge answers, as
|
|
119
|
+
* `spentRefusalOf` does.
|
|
120
|
+
*/
|
|
121
|
+
const storeCall = (run, options) => effectStoreCall(run, options?.resend === true);
|
|
122
|
+
/** A store failure: preserve interruption, spent bounds and closed servers; map adapter throws via `fromInfra`. */
|
|
119
123
|
const effectStoreFailure = (cause, after) => {
|
|
120
124
|
if (Cause.hasInterrupts(cause)) return Effect.failCause(Cause.map(cause, (error) => fromInfra(error, after)));
|
|
121
125
|
const error = Cause.squash(cause);
|
|
122
126
|
const spent = spentAt(error);
|
|
123
127
|
if (spent !== void 0) return Effect.die(spent);
|
|
124
|
-
if (isServerClosed(error)
|
|
128
|
+
if (isServerClosed(error)) return Effect.die(error);
|
|
125
129
|
return Effect.fail(fromInfra(error, after));
|
|
126
130
|
};
|
|
131
|
+
/** A commit through `storeCall`, resending under its own ID when its reply is lost. */
|
|
132
|
+
const storeCommit = (run) => storeCall(run, { resend: true });
|
|
127
133
|
/** A watch, charged once at subscription, with the same failure classification as a store call. */
|
|
128
134
|
const storeWatch = (run) => Stream.unwrap(storeCall(Effect.map(committedNow, (after) => run().pipe(Stream.catchCause((cause) => Stream.fromEffect(effectStoreFailure(cause, after)))))));
|
|
129
135
|
/** An Effect store call, with a commit's resends under the same ID when requested. */
|
|
@@ -167,35 +173,11 @@ const codeErrors = [
|
|
|
167
173
|
* guess costs one resend under the same ID, which the store's receipt answers as the first.
|
|
168
174
|
*/
|
|
169
175
|
const isLostReply = (cause) => Predicate.isTagged(cause, "Unavailable") || !isInfraError(cause) && !codeErrors.some((code) => cause instanceof code);
|
|
170
|
-
/** Each answer a commit's resend gave, with the resends it took, which `storeCall` charges. */
|
|
171
|
-
const resent = /* @__PURE__ */ new WeakMap();
|
|
172
176
|
/**
|
|
173
177
|
* Whether a resend's `cause` is the store's own answer, made past its receipt: an infra refusal
|
|
174
178
|
* other than `Unavailable` or the platform's cap, which refuses a call before it reaches the store.
|
|
175
179
|
*/
|
|
176
180
|
const isAnswered = (cause) => isInfraError(cause) && !Predicate.isTagged(cause, "Unavailable") && !pastCallLimit(cause);
|
|
177
|
-
/**
|
|
178
|
-
* `send`, a commit where infra calls the adapter, sent again under its own ID while the platform
|
|
179
|
-
* fails, up to `commitResendsMost` times: the store's receipt answers as the first send ended, so a
|
|
180
|
-
* commit that landed is never made twice. A defect of code, or a closed server, is never resent.
|
|
181
|
-
* Once a reply is lost, a resend ends as the store answered it or `Unsettled`, whose cause is that
|
|
182
|
-
* first loss alone, so no later refusal, the platform's cap among them, answers a write that may
|
|
183
|
-
* have landed as one that didn't.
|
|
184
|
-
*/
|
|
185
|
-
const resending = async (send) => {
|
|
186
|
-
let lost;
|
|
187
|
-
for (let resends = 0;; resends += 1) try {
|
|
188
|
-
const committed = await send();
|
|
189
|
-
if (resends === 0) return committed;
|
|
190
|
-
const again = { ...committed };
|
|
191
|
-
resent.set(again, resends);
|
|
192
|
-
return again;
|
|
193
|
-
} catch (cause) {
|
|
194
|
-
if (isServerClosed(cause) || (resends === 0 ? !isLostReply(cause) : isAnswered(cause))) throw cause;
|
|
195
|
-
lost ??= cause;
|
|
196
|
-
if (resends === 1 || !isLostReply(cause)) throw new Unsettled("No reply came to a commit", { cause: lost });
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
181
|
/** A stored row whose value should match `schema`; one that doesn't is `DATA_LOSS`. */
|
|
200
182
|
const decodeRow = (schema, row, what) => {
|
|
201
183
|
const decoded = Schema.decodeUnknownOption(schema)(row.value);
|
|
@@ -262,4 +244,4 @@ const endedEarly = (cause) => {
|
|
|
262
244
|
cause
|
|
263
245
|
});
|
|
264
246
|
};
|
|
265
|
-
export { Unsettled, afterWrites, answerSpent, bestEffort, brokenRead, clientWentAway, commitCallsMost, decodeDerivedRow, decodeRow, endedEarly, fetchLess, fromInfra, isLimitRefusal, pastCallLimit, readBody,
|
|
247
|
+
export { Unsettled, afterWrites, answerSpent, bestEffort, brokenRead, clientWentAway, commitCallsMost, decodeDerivedRow, decodeRow, endedEarly, fetchLess, fromInfra, isLimitRefusal, pastCallLimit, readBody, resultCall, routeEdge, storeCall, storeCommit, storeWatch, thrownError };
|
package/dist/store/git-store.mjs
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { isInternalId } from "../contracts/ids.mjs";
|
|
2
2
|
import { fail } from "../contracts/result.mjs";
|
|
3
3
|
import { resolveRepo } from "./catalogue.mjs";
|
|
4
|
-
import { decodeRow, storeCall } from "./errors.mjs";
|
|
4
|
+
import { decodeRow, storeCall, storeCommit } from "./errors.mjs";
|
|
5
|
+
import { JobLanded } from "./job-try.mjs";
|
|
5
6
|
import { outboxCollections } from "./outbox.mjs";
|
|
6
7
|
import { PackRow } from "./records.mjs";
|
|
7
8
|
import { collections, prunedKey, pushedKey, selfKey } from "./scopes.mjs";
|
|
8
9
|
import * as Effect from "effect/Effect";
|
|
10
|
+
import { Records } from "@ref0/infra";
|
|
11
|
+
import * as Context from "effect/Context";
|
|
9
12
|
// src/store/git-store.ts
|
|
10
13
|
const packsRead = { collection: collections.packs };
|
|
11
14
|
/** A repo's listed packs, from its `packs` rows. */
|
|
@@ -65,21 +68,21 @@ const featureChange = (scope, change) => {
|
|
|
65
68
|
return Effect.void;
|
|
66
69
|
};
|
|
67
70
|
/**
|
|
68
|
-
* Git's records over infra's `
|
|
71
|
+
* Git's records over infra's `Records`, under Git's commit rules: only Git's scopes, a repo's
|
|
69
72
|
* by its internal ID, and never the catalogue, a repo's own record or its outbox, which only the core
|
|
70
73
|
* writes.
|
|
71
|
-
*
|
|
74
|
+
* Inside a job try, every commit is fenced by the fiber's `Records.Fence`.
|
|
72
75
|
*/
|
|
73
76
|
const gitStore = (store) => ({
|
|
74
77
|
read: ({ scope, reads }) => {
|
|
75
78
|
const problem = scopeProblem(scope);
|
|
76
|
-
return problem === void 0 ? storeCall(
|
|
79
|
+
return problem === void 0 ? storeCall(store.read(scope, reads)) : fail("INVALID_ARGUMENT", problem);
|
|
77
80
|
},
|
|
78
|
-
commit: ({ scope, change }) => Effect.andThen(featureChange(scope, change),
|
|
81
|
+
commit: ({ scope, change }) => Effect.andThen(featureChange(scope, change), storeCommit(store.commit(scope, change))),
|
|
79
82
|
add: ({ scope, addition }) => {
|
|
80
83
|
if (!scope.startsWith("git/repo/") || scopeProblem(scope) !== void 0) return fail("INVALID_ARGUMENT", "Only a repo's scope, by its internal ID, takes an addition");
|
|
81
84
|
if (touchesOwn(scope, addition.put ?? [])) return ownRefusal();
|
|
82
|
-
return storeCall(
|
|
85
|
+
return storeCall(store.add(scope, addition));
|
|
83
86
|
},
|
|
84
87
|
listed: Effect.fnUntraced(function* ({ repo }) {
|
|
85
88
|
const { internalId, snapshot } = yield* resolveRepo(store, repo, [packsRead]);
|
|
@@ -91,4 +94,19 @@ const gitStore = (store) => ({
|
|
|
91
94
|
};
|
|
92
95
|
})
|
|
93
96
|
});
|
|
94
|
-
|
|
97
|
+
/**
|
|
98
|
+
* `gitStore(store)` bound to the caller fiber's `Records.Fence` and `JobLanded`, so writes through
|
|
99
|
+
* a Promise `GitObjects` boundary (`receiveStep`, `maintain`) stay fenced and mark landed writes.
|
|
100
|
+
*/
|
|
101
|
+
const tryGitStore = (store) => Effect.map(Effect.context(), (context) => {
|
|
102
|
+
const fence = Context.get(context, Records.Fence);
|
|
103
|
+
const landed = Context.get(context, JobLanded);
|
|
104
|
+
const base = gitStore(store);
|
|
105
|
+
const bind = (effect) => effect.pipe(Effect.provideService(Records.Fence, fence), Effect.provideService(JobLanded, landed));
|
|
106
|
+
return {
|
|
107
|
+
...base,
|
|
108
|
+
commit: (input) => bind(base.commit(input)),
|
|
109
|
+
add: (input) => bind(base.add(input))
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
export { decodePacks, featureChange, gitStore, packRow, tryGitStore };
|
package/dist/store/job-try.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { noCall, syncIn } from "./crossing.mjs";
|
|
|
5
5
|
import { jobRepo } from "./scopes.mjs";
|
|
6
6
|
import * as Effect from "effect/Effect";
|
|
7
7
|
import { CurrentJob } from "@ref0/infra";
|
|
8
|
+
import * as Context from "effect/Context";
|
|
8
9
|
// src/store/job-try.ts
|
|
9
10
|
/** A try's `JobLimits` under the adapter's `limits`, checked as a request's are. */
|
|
10
11
|
const jobLimitsOf = (limits) => lessBefore(checkedLimits(limits, "The adapter's callLimits."), jobCallsAround);
|
|
@@ -52,40 +53,18 @@ const stepYielded = (job, spent) => {
|
|
|
52
53
|
return stepSpent("job-step-yielded", `${job}'s ${step} step spent a try's ${callsOf(spent)} after a write landed: the next try goes on from it`, job, step, spent);
|
|
53
54
|
};
|
|
54
55
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
56
|
+
* Mutable landing marker for the job try in scope: set by `doorRecords` once a write through the
|
|
57
|
+
* try lands, so spending the try's call budget after a landed write fails `job-step-yielded`
|
|
58
|
+
* instead of `job-step-calls`.
|
|
58
59
|
*/
|
|
59
|
-
const
|
|
60
|
-
...store,
|
|
61
|
-
commit: async (scope, change) => {
|
|
62
|
-
const committed = await store.commit(scope, change);
|
|
63
|
-
if (committed.ok) saved.landed = true;
|
|
64
|
-
return committed;
|
|
65
|
-
},
|
|
66
|
-
add: async (scope, addition) => {
|
|
67
|
-
await store.add(scope, addition);
|
|
68
|
-
saved.landed = true;
|
|
69
|
-
},
|
|
70
|
-
discard: async (scope, job) => {
|
|
71
|
-
await store.discard(scope, job);
|
|
72
|
-
saved.landed = true;
|
|
73
|
-
},
|
|
74
|
-
retry: async (scope, job, input) => {
|
|
75
|
-
await store.retry(scope, job, input);
|
|
76
|
-
saved.landed = true;
|
|
77
|
-
}
|
|
78
|
-
});
|
|
60
|
+
const JobLanded = Context.Reference("@ref0/git/JobLanded", { defaultValue: () => void 0 });
|
|
79
61
|
/**
|
|
80
|
-
* `run` in a fresh budget of `limits`, named `'job'`, nested in nothing, with
|
|
81
|
-
*
|
|
62
|
+
* `run` in a fresh budget of `limits`, named `'job'`, nested in nothing, with `JobLanded` marking
|
|
63
|
+
* what lands: so a request's budget and a job's never count each other's calls (#2015).
|
|
82
64
|
*/
|
|
83
65
|
const inJobBudget = (limits, run, spent) => Effect.flatMap(inCallScope(CallBudget.make(limits, { name: "job" }), noScope), (budget) => {
|
|
84
66
|
const saved = { landed: false };
|
|
85
|
-
const marked = run(saved)
|
|
86
|
-
...job,
|
|
87
|
-
store: marking(job.store, saved)
|
|
88
|
-
})));
|
|
67
|
+
const marked = Effect.provideService(run(saved), JobLanded, saved);
|
|
89
68
|
const owns = (each) => nestsIn(spentBudget(each), budget);
|
|
90
69
|
return Effect.catchCause(inCallScope(marked, {
|
|
91
70
|
calls: void 0,
|
|
@@ -127,6 +106,4 @@ const jobParts = (job, handler, options) => (take) => take(job, handler, options
|
|
|
127
106
|
const jobsWithin = (limits, jobs) => jobs.map((job) => remakes.get(job)?.(limits) ?? job);
|
|
128
107
|
/** The repo whose scope the try runs in: in any other scope, it's a defect, as `jobRepo` says. */
|
|
129
108
|
const currentRepo = Effect.map(CurrentJob.current, jobRepo);
|
|
130
|
-
|
|
131
|
-
const repoTry = (step) => Effect.flatMap(Effect.all([CurrentJob.store, currentRepo]), ([store, repo]) => step(store, repo));
|
|
132
|
-
export { currentRepo, gitJob, jobLimitsOf, jobParts, jobsWithin, repoTry, stepTooLarge };
|
|
109
|
+
export { JobLanded, currentRepo, gitJob, jobLimitsOf, jobParts, jobsWithin, stepTooLarge };
|
package/dist/store/list-job.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { reconcile } from "./catalogue.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { currentRepo, gitJob } from "./job-try.mjs";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
4
|
import * as Schema from "effect/Schema";
|
|
5
5
|
import { Job, defineJob } from "@ref0/infra";
|
|
@@ -8,12 +8,7 @@ const ListData = /* @__PURE__ */ Schema.Struct({});
|
|
|
8
8
|
const listJobName = "git.list";
|
|
9
9
|
/** The `git.list` job's one key in each repo's scope. */
|
|
10
10
|
const listJobKey = "list";
|
|
11
|
-
|
|
12
|
-
* `git.list`: projects a repo's record into `git/repos`, where its own write didn't get that far,
|
|
13
|
-
* writing an entry only when its revision is newer. Every repo write saves it in the same commit.
|
|
14
|
-
* Its try stops at its timeout, which interrupts it.
|
|
15
|
-
*/
|
|
16
|
-
const listJob = /* @__PURE__ */ gitJob(/* @__PURE__ */ Job.make(listJobName, {
|
|
11
|
+
const ListJob = /* @__PURE__ */ Job.make(listJobName, {
|
|
17
12
|
payload: ListData,
|
|
18
13
|
retry: {
|
|
19
14
|
limit: 10,
|
|
@@ -21,7 +16,48 @@ const listJob = /* @__PURE__ */ gitJob(/* @__PURE__ */ Job.make(listJobName, {
|
|
|
21
16
|
backoff: "exponential",
|
|
22
17
|
maxDelay: "5 minutes"
|
|
23
18
|
}
|
|
24
|
-
})
|
|
19
|
+
});
|
|
20
|
+
const emptySchema = /* @__PURE__ */ Schema.toStandardSchemaV1(ListData);
|
|
21
|
+
/** `git.repack`'s rows, by `defineJob`, for a lost create `git.list` puts aside without importing `storage/`. */
|
|
22
|
+
const repackRows = /* @__PURE__ */ defineJob({
|
|
23
|
+
name: "git.repack",
|
|
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
|
+
});
|
|
37
|
+
/** Cleanup and purge jobs queued when `git.list` puts aside a create that crashed before standing aside (#1911). */
|
|
38
|
+
const lostCreateJobs = (record) => [
|
|
39
|
+
repackRows.job({
|
|
40
|
+
key: "repack",
|
|
41
|
+
data: {},
|
|
42
|
+
at: record.changedAt
|
|
43
|
+
}),
|
|
44
|
+
...record.fork === void 0 ? [] : [repackRows.job({
|
|
45
|
+
key: "prune",
|
|
46
|
+
data: {},
|
|
47
|
+
at: record.changedAt
|
|
48
|
+
})],
|
|
49
|
+
purgeRows.job({
|
|
50
|
+
key: "purge",
|
|
51
|
+
data: {},
|
|
52
|
+
at: record.changedAt
|
|
53
|
+
})
|
|
54
|
+
];
|
|
55
|
+
/**
|
|
56
|
+
* `git.list`: projects a repo's record into `git/repos`, where its own write didn't get that far,
|
|
57
|
+
* writing an entry only when its revision is newer. Every repo write saves it in the same commit.
|
|
58
|
+
* Its try stops at its timeout, which interrupts it.
|
|
59
|
+
*/
|
|
60
|
+
const listJob = (store) => gitJob(ListJob, () => Effect.asVoid(Effect.flatMap(currentRepo, (internalId) => reconcile(store, internalId, lostCreateJobs))));
|
|
25
61
|
/**
|
|
26
62
|
* `git.list`'s rows, by `defineJob`, as `ListJob.encodedJob` makes them: a write saves one beside
|
|
27
63
|
* its record without `Job.make`'s runtime, which only the server that runs `listJob` needs.
|
package/dist/store/records.d.mts
CHANGED
|
@@ -38,6 +38,8 @@ export type CatalogueEntry = typeof CatalogueEntry.Type;
|
|
|
38
38
|
* under, as `core/ref-index.ts` says: a repo made on a server that keeps an index takes its stamp.
|
|
39
39
|
* `refIndexBuilding` is the rebuild mark, `git.ref-index`'s, while it builds another stamp's rows.
|
|
40
40
|
* `renamedSeq` is the `seq` of the `repo.renamed` that gave the repo its name, when events are kept.
|
|
41
|
+
* `staged` marks a fork's create, deleted, that marked packs or staged rows before its record: no
|
|
42
|
+
* name's entry has heard of it, so its purge projects nothing.
|
|
41
43
|
*/
|
|
42
44
|
export declare const StoredRepo: Schema.Struct<{
|
|
43
45
|
readonly name: Schema.String;
|
|
@@ -51,6 +53,7 @@ export declare const StoredRepo: Schema.Struct<{
|
|
|
51
53
|
readonly createdAt: Schema.Int;
|
|
52
54
|
readonly changedAt: Schema.Int;
|
|
53
55
|
readonly deleted: Schema.optionalKey<Schema.Literal<true>>;
|
|
56
|
+
readonly staged: Schema.optionalKey<Schema.Literal<true>>;
|
|
54
57
|
readonly renamedFrom: Schema.optionalKey<Schema.Struct<{
|
|
55
58
|
readonly name: Schema.String;
|
|
56
59
|
readonly revision: Schema.Int;
|
package/dist/store/records.mjs
CHANGED
|
@@ -153,6 +153,8 @@ const ForkRow = /* @__PURE__ */ Schema.Struct({ internalId: InternalRepoId });
|
|
|
153
153
|
* under, as `core/ref-index.ts` says: a repo made on a server that keeps an index takes its stamp.
|
|
154
154
|
* `refIndexBuilding` is the rebuild mark, `git.ref-index`'s, while it builds another stamp's rows.
|
|
155
155
|
* `renamedSeq` is the `seq` of the `repo.renamed` that gave the repo its name, when events are kept.
|
|
156
|
+
* `staged` marks a fork's create, deleted, that marked packs or staged rows before its record: no
|
|
157
|
+
* name's entry has heard of it, so its purge projects nothing.
|
|
156
158
|
*/
|
|
157
159
|
const StoredRepo = /* @__PURE__ */ Schema.Struct({
|
|
158
160
|
name: Schema.String,
|
|
@@ -163,6 +165,7 @@ const StoredRepo = /* @__PURE__ */ Schema.Struct({
|
|
|
163
165
|
createdAt: Schema.Int,
|
|
164
166
|
changedAt: Schema.Int,
|
|
165
167
|
deleted: Schema.optionalKey(Schema.Literal(true)),
|
|
168
|
+
staged: Schema.optionalKey(Schema.Literal(true)),
|
|
166
169
|
renamedFrom: Schema.optionalKey(RenamedFrom),
|
|
167
170
|
renamedSeq: Schema.optionalKey(Schema.Int),
|
|
168
171
|
nextSeq: Schema.optionalKey(NextSeq),
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "../contracts/promises.mjs";
|
|
2
1
|
import "../contracts/access.mjs";
|
|
3
2
|
import { EffectiveLimits } from "../contracts/objects.mjs";
|
|
4
3
|
import "../contracts/ids.mjs";
|
|
@@ -9,7 +8,7 @@ import "../contracts/result.mjs";
|
|
|
9
8
|
import "./records.mjs";
|
|
10
9
|
import * as Effect from "effect/Effect";
|
|
11
10
|
import "effect/Schema";
|
|
12
|
-
import { Addition,
|
|
11
|
+
import { Addition, JobInput, Key, Moment, Read, Records, Row, Scope, Snapshot } from "@ref0/infra";
|
|
13
12
|
import "effect/Context";
|
|
14
13
|
import "effect/Types";
|
|
15
14
|
/**
|
|
@@ -3,11 +3,11 @@ import { noRepoRoots } from "../protocol/objects/commit.mjs";
|
|
|
3
3
|
import { checkChurn, decodeRecord, entryOf, project } from "./catalogue.mjs";
|
|
4
4
|
import { afterCommit } from "./call-count.mjs";
|
|
5
5
|
import { fail } from "../contracts/result.mjs";
|
|
6
|
-
import { afterWrites, decodeRow, storeCall } from "./errors.mjs";
|
|
6
|
+
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
|
|
10
|
+
import * as Clock from "effect/Clock";
|
|
11
11
|
import * as Effect from "effect/Effect";
|
|
12
12
|
import * as Schema from "effect/Schema";
|
|
13
13
|
import { jobLeaseMargin } from "@ref0/infra";
|
|
@@ -17,7 +17,7 @@ import * as Hex from "effect/encoding/Hex";
|
|
|
17
17
|
/** A repo's record and its scope's rows, read at one version: `results[0]` is `self`. */
|
|
18
18
|
const readRecord = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, reads = [], counts = []) {
|
|
19
19
|
const scope = repoScope(internalId);
|
|
20
|
-
const snapshot = yield* storeCall(
|
|
20
|
+
const snapshot = yield* storeCall(store.read(scope, [selfKey, ...reads], [...counts]));
|
|
21
21
|
return {
|
|
22
22
|
record: yield* decodeRecord(snapshot.results[0]?.[0]),
|
|
23
23
|
snapshot
|
|
@@ -29,6 +29,13 @@ const rootsOf = (rows) => {
|
|
|
29
29
|
if (row === void 0) return Effect.succeed(noRepoRoots);
|
|
30
30
|
return Effect.map(decodeRow(RepoRootsRow, row, "The repo's roots"), ({ roots }) => new Set(roots));
|
|
31
31
|
};
|
|
32
|
+
/** `held` once `moves` lands, as `rootsMoved` writes it: `shallow` added, then `unshallow` taken away. */
|
|
33
|
+
const movedRoots = (held, moves) => {
|
|
34
|
+
const after = new Set(held);
|
|
35
|
+
for (const oid of moves.shallow) after.add(oid);
|
|
36
|
+
for (const oid of moves.unshallow) after.delete(oid);
|
|
37
|
+
return after;
|
|
38
|
+
};
|
|
32
39
|
/**
|
|
33
40
|
* The write of a repo's roots once `moves` lands on `held`, the roots its commit reads: those of
|
|
34
41
|
* `shallow` added, and those of `unshallow` taken away, each once, in order. `undefined` when they
|
|
@@ -52,9 +59,7 @@ const rootsMoved = (held, moves, indexed) => {
|
|
|
52
59
|
hint: "Fetch again",
|
|
53
60
|
context: { reason: "changed-while-checked" }
|
|
54
61
|
});
|
|
55
|
-
const after =
|
|
56
|
-
for (const oid of moves.shallow) after.add(oid);
|
|
57
|
-
for (const oid of moves.unshallow) after.delete(oid);
|
|
62
|
+
const after = movedRoots(held, moves);
|
|
58
63
|
if (after.size === held.size && [...after].every((oid) => held.has(oid))) return Effect.succeed(void 0);
|
|
59
64
|
if (after.size > 1e4) return fail("RESOURCE_EXHAUSTED", `A repo holds at most ${repoRootsMost} shallow commits`, {
|
|
60
65
|
hint: "Fetch with a smaller depth, or from fewer branches",
|
|
@@ -105,7 +110,7 @@ const deleteCommitWithin = jobLeaseMargin / 2;
|
|
|
105
110
|
*/
|
|
106
111
|
const heldUntil = (heldAt, fetchLimits) => heldAt + fetchLimits.milliseconds - jobLeaseMargin;
|
|
107
112
|
/** Whether a write may still send its store call, by `heldUntil`'s `by`, at the clock's now. */
|
|
108
|
-
const inTime = (by) => Effect.map(Clock
|
|
113
|
+
const inTime = (by) => Effect.map(Clock.currentTimeMillis, (now) => now < by);
|
|
109
114
|
/**
|
|
110
115
|
* When the writes in scope must land by, as `heldUntil` answered for the caller's own read of the
|
|
111
116
|
* repo's record: a push sets it around its receive, so the pack's quarantine row, an add at no
|
|
@@ -115,13 +120,18 @@ const inTime = (by) => Effect.map(Clock$1.currentTimeMillis, (now) => now < by);
|
|
|
115
120
|
*/
|
|
116
121
|
const HeldBy = Context.Reference("@ref0/git/HeldBy", { defaultValue: () => void 0 });
|
|
117
122
|
/**
|
|
118
|
-
* `addition` with `HeldBy` as its `by`,
|
|
119
|
-
* `UNAVAILABLE` already once the clock is at or
|
|
123
|
+
* `addition` with the sooner of `HeldBy` and its own `by` as its `by`, the value it sends, so the
|
|
124
|
+
* store refuses it as it lands past either: fails `UNAVAILABLE` already once the clock is at or
|
|
125
|
+
* past it, so a write that waited reads again. A staged batch's add carries its `removeAt`, which
|
|
126
|
+
* its sweep's end counts on.
|
|
120
127
|
*/
|
|
121
|
-
const heldAddition = (what, addition) => Effect.flatMap(HeldBy, (
|
|
122
|
-
|
|
123
|
-
by
|
|
124
|
-
|
|
128
|
+
const heldAddition = (what, addition) => Effect.flatMap(HeldBy, (held) => {
|
|
129
|
+
const by = held === void 0 ? addition.by : Math.min(held, addition.by ?? Number.POSITIVE_INFINITY);
|
|
130
|
+
return by === void 0 ? Effect.succeed(addition) : Effect.flatMap(inTime(by), (on) => on ? Effect.succeed({
|
|
131
|
+
...addition,
|
|
132
|
+
by
|
|
133
|
+
}) : fail("UNAVAILABLE", `${what} came late: read the repo again`, { hint: "Push again" }));
|
|
134
|
+
});
|
|
125
135
|
/**
|
|
126
136
|
* A write to a repo's scope refused because the repo is gone: no record, or one deleted, so its
|
|
127
137
|
* purge may drop the scope, or has, and the write would make it again (#1911).
|
|
@@ -129,8 +139,8 @@ const heldAddition = (what, addition) => Effect.flatMap(HeldBy, (by) => by === v
|
|
|
129
139
|
var RepoGone = class extends Schema.TaggedError()("RepoGone", { repo: Schema.String }) {};
|
|
130
140
|
/** `store` as `heldAdd` calls it, each call a `storeCall`. */
|
|
131
141
|
const heldStore = (store) => ({
|
|
132
|
-
read: (scope, reads) => storeCall(
|
|
133
|
-
add: (scope, addition) => storeCall(
|
|
142
|
+
read: (scope, reads) => storeCall(store.read(scope, reads)),
|
|
143
|
+
add: (scope, addition) => storeCall(store.add(scope, addition))
|
|
134
144
|
});
|
|
135
145
|
/**
|
|
136
146
|
* `addition` to `repo`'s scope, an add at no version, only while the repo is live: it reads the
|
|
@@ -139,12 +149,14 @@ const heldStore = (store) => ({
|
|
|
139
149
|
* read stalled past `heldUntil` is `UNAVAILABLE`, for a try that reads again, and so is one whose
|
|
140
150
|
* add the store found past it as it landed, `heldUntil` being the add's `by`. A wake, a job, an
|
|
141
151
|
* upload or a sync's cover made apart from the repo's own read goes through here, and a push's
|
|
142
|
-
* quarantine is held to its first read by `HeldBy`. The adds that don't are a fork create's
|
|
143
|
-
*
|
|
152
|
+
* quarantine is held to its first read by `HeldBy`. The adds that don't are a fork create's
|
|
153
|
+
* staging, after its opener commits its record aside, by the `removeAt` its purge waits out, and a
|
|
154
|
+
* try's rows in its own scope, which its claim fences. A create's cover rows are commits at its
|
|
155
|
+
* version.
|
|
144
156
|
*/
|
|
145
157
|
const heldAdd = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fetchLimits, addition) {
|
|
146
158
|
const scope = repoScope(repo);
|
|
147
|
-
const heldAt = yield* Clock
|
|
159
|
+
const heldAt = yield* Clock.currentTimeMillis;
|
|
148
160
|
const snapshot = yield* store.read(scope, [selfKey]);
|
|
149
161
|
const record = yield* decodeRecord(snapshot.results[0]?.[0]);
|
|
150
162
|
if (record === void 0 || record.deleted === true) return yield* new RepoGone({ repo });
|
|
@@ -174,7 +186,7 @@ const commitRecord = (store, internalId, write) => {
|
|
|
174
186
|
...change,
|
|
175
187
|
by: write.by
|
|
176
188
|
};
|
|
177
|
-
return
|
|
189
|
+
return storeCommit(store.commit(repoScope(internalId), sent));
|
|
178
190
|
};
|
|
179
191
|
/**
|
|
180
192
|
* A repo write's two commits: its record, then its projection into `git/repos`. Answers
|
|
@@ -260,4 +272,4 @@ const repoStats = (record, refs, packs, times, readyBytes) => {
|
|
|
260
272
|
if (times.maintained !== void 0) stats.maintainedAt = times.maintained;
|
|
261
273
|
return stats;
|
|
262
274
|
};
|
|
263
|
-
export { HeldBy, RepoGone, commitRecord, decodeStats, deleteCommitWithin, heldAdd, heldAddition, heldStore, heldUntil, inTime, looseRows, readRecord, repoStats, rootsDigest, rootsMoved, rootsOf, seenTimes, timeRow, writeRecord };
|
|
275
|
+
export { HeldBy, RepoGone, commitRecord, decodeStats, deleteCommitWithin, heldAdd, heldAddition, heldStore, heldUntil, inTime, looseRows, movedRoots, readRecord, repoStats, rootsDigest, rootsMoved, rootsOf, seenTimes, timeRow, writeRecord };
|
|
@@ -76,7 +76,7 @@ const reservationOf = (rows) => {
|
|
|
76
76
|
* nothing.
|
|
77
77
|
*/
|
|
78
78
|
const liveState = /* @__PURE__ */ Effect.fnUntraced(function* (store, reservation) {
|
|
79
|
-
const [row] = (yield* storeCall(
|
|
79
|
+
const [row] = (yield* storeCall(store.read(topicScope(reservation.topic), [topicKey]))).results[0] ?? [];
|
|
80
80
|
if (row === void 0) return void 0;
|
|
81
81
|
const life = yield* decodeRow(TopicLife, row, `Topic ${reservation.topic}`);
|
|
82
82
|
return ended.has(life.state) ? void 0 : life.state;
|
package/dist/store/scopes.mjs
CHANGED
|
@@ -43,6 +43,17 @@ const collections = {
|
|
|
43
43
|
publicCreated: "public-created",
|
|
44
44
|
/** In `git/repos`: the server's own keys, by use: `cursor`, which seals every list's cursor. */
|
|
45
45
|
keys: "keys",
|
|
46
|
+
/**
|
|
47
|
+
* In `git/repos`: a row for each delivery the host has retired, by its name, which each start
|
|
48
|
+
* writes from `events.retired`, so a deleted repo's purge may end that delivery's job.
|
|
49
|
+
*/
|
|
50
|
+
retired: "retired-deliveries",
|
|
51
|
+
/**
|
|
52
|
+
* In `git/repos`: `head`, the stamp of the start that last wrote the `retired` rows, `gen`, how
|
|
53
|
+
* many starts' writes have landed, and `start`, its ID, so a start's write behind a later
|
|
54
|
+
* start's landing is refused.
|
|
55
|
+
*/
|
|
56
|
+
retiredStamp: "retired-stamp",
|
|
46
57
|
/** In a repo's scope: its own record, `self`, and its roots, `roots`. */
|
|
47
58
|
repo: "repo",
|
|
48
59
|
/** In a repo's scope: each ref's `RefRow`, by its full name. */
|
package/dist/store/settle.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { storeCall } from "./errors.mjs";
|
|
1
|
+
import { storeCall, storeCommit } from "./errors.mjs";
|
|
2
2
|
import { entryOf, project } from "./catalogue.mjs";
|
|
3
3
|
import { dropUnconfirmed, headKey } from "./outbox.mjs";
|
|
4
4
|
import { takenBack } from "./records.mjs";
|
|
@@ -30,11 +30,11 @@ const settleName = /* @__PURE__ */ Effect.fnUntraced(function* (store, scope, re
|
|
|
30
30
|
...headKey,
|
|
31
31
|
value: confirmed
|
|
32
32
|
}];
|
|
33
|
-
yield* storeCall(
|
|
33
|
+
yield* storeCall(store.commit(scope, {
|
|
34
34
|
id: newChangeId(),
|
|
35
35
|
expect: version,
|
|
36
36
|
put
|
|
37
|
-
}));
|
|
37
|
+
}), { resend: true });
|
|
38
38
|
return true;
|
|
39
39
|
}
|
|
40
40
|
if (back !== void 0) {
|
|
@@ -55,7 +55,7 @@ const settleName = /* @__PURE__ */ Effect.fnUntraced(function* (store, scope, re
|
|
|
55
55
|
expect: version,
|
|
56
56
|
...dropUnconfirmed(head)
|
|
57
57
|
};
|
|
58
|
-
yield*
|
|
58
|
+
yield* storeCommit(store.commit(scope, change));
|
|
59
59
|
return true;
|
|
60
60
|
});
|
|
61
61
|
/** Whether a name's entry is still this repo's own, and live: the name a lost rename left. */
|
package/dist/sync/github.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { fail, gitError, gitErrorFrom } from "../contracts/result.mjs";
|
|
|
4
4
|
import { sameHash } from "../auth/token-text.mjs";
|
|
5
5
|
import { ProviderRefused, saidOf } from "./said.mjs";
|
|
6
6
|
import { hmacSha256 } from "../protocol/bytes/hmac-sha256.mjs";
|
|
7
|
-
import * as Clock
|
|
7
|
+
import * as Clock from "effect/Clock";
|
|
8
8
|
import * as Effect from "effect/Effect";
|
|
9
9
|
import * as HttpClient from "effect/http/HttpClient";
|
|
10
10
|
import * as Option from "effect/Option";
|
|
@@ -199,7 +199,7 @@ const github = /* @__PURE__ */ Effect.fnUntraced(function* (options) {
|
|
|
199
199
|
});
|
|
200
200
|
/** The App's own JWT, signed with its key, for a minute short of 10. */
|
|
201
201
|
const jwt = Effect.gen(function* () {
|
|
202
|
-
const now = Math.floor((yield* Clock
|
|
202
|
+
const now = Math.floor((yield* Clock.currentTimeMillis) / 1e3);
|
|
203
203
|
const unsigned = `${encodeJson({
|
|
204
204
|
alg: "RS256",
|
|
205
205
|
typ: "JWT"
|
|
@@ -233,7 +233,7 @@ const github = /* @__PURE__ */ Effect.fnUntraced(function* (options) {
|
|
|
233
233
|
const request = new Request(url, init);
|
|
234
234
|
const response = yield* sendCharged(request).pipe(Effect.mapError(() => failed(call)));
|
|
235
235
|
if (response.status !== 201) {
|
|
236
|
-
const said = yield*
|
|
236
|
+
const said = yield* saidOf(request, response, githubKept);
|
|
237
237
|
const refused = failed(call, response.status);
|
|
238
238
|
return yield* Effect.fail(gitErrorFrom(refused, { cause: new ProviderRefused(refused.message, said) }));
|
|
239
239
|
}
|