@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { hostEffect, logRefusal, rejectedError } from "../../auth/host-function.mjs";
|
|
2
2
|
import { register } from "../../contracts/git.mjs";
|
|
3
3
|
import { handlersOf } from "../../contracts/git-hooks.mjs";
|
|
4
|
-
import { millis } from "../../contracts/
|
|
4
|
+
import { millis } from "../../contracts/time.mjs";
|
|
5
5
|
import { checkedAnswer, plainAnswer, pushContextOf } from "../rules/context.mjs";
|
|
6
6
|
import * as Effect from "effect/Effect";
|
|
7
7
|
import * as Layer from "effect/Layer";
|
package/dist/core/imports.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ImportLfsReason, SyncSource } from "../contracts/sync.mjs";
|
|
1
|
+
import { ImportDepth, ImportLfsReason, SyncSource } from "../contracts/sync.mjs";
|
|
2
2
|
import { readAsked } from "./asked.mjs";
|
|
3
3
|
import { KeptError, keptError } from "./receipts.mjs";
|
|
4
4
|
import { SavedCaller } from "./saved-callers.mjs";
|
|
5
5
|
import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
6
6
|
import { oidBytes } from "../protocol/packs/idx.mjs";
|
|
7
|
-
import { decodeRow, storeCall } from "../store/errors.mjs";
|
|
7
|
+
import { decodeRow, storeCall, storeCommit } from "../store/errors.mjs";
|
|
8
8
|
import { importJobName } from "../store/records.mjs";
|
|
9
9
|
import { refRowBytes, storesPeel } from "../store/ref-rows.mjs";
|
|
10
10
|
import { isPackId } from "../storage/layout.mjs";
|
|
@@ -29,7 +29,9 @@ import * as Base64 from "effect/encoding/Base64";
|
|
|
29
29
|
* the tips, which `publish` makes the repo's default branch, in the last page's commit;
|
|
30
30
|
* - `roots`: where the history copied so far stops, the remote's `shallow` lines; `deepest`, how
|
|
31
31
|
* many commits from each tip it holds; `step`, how many more the next segment asks for;
|
|
32
|
-
* - `
|
|
32
|
+
* - `depth`: how many commits from each tip the import asked for, none for the whole history;
|
|
33
|
+
* - `copied`: whether the history is whole, as deep as `depth` asks, or as deep as the remote
|
|
34
|
+
* holds it, so the next step publishes, writing `roots`, when any, as the repo's own;
|
|
33
35
|
* - `objects` and `bytes`: what the steps have received;
|
|
34
36
|
* - `receiving`: a segment staged and received in steps, as `ImportReceiving` says;
|
|
35
37
|
* - `restaged`: whether clean-up ended the stage of the segment the import fetches or receives
|
|
@@ -89,6 +91,7 @@ const noImportLfs = {
|
|
|
89
91
|
const ImportRow = /* @__PURE__ */ Schema.Struct({
|
|
90
92
|
source: SyncSource,
|
|
91
93
|
by: SavedCaller,
|
|
94
|
+
depth: Schema.optionalKey(ImportDepth),
|
|
92
95
|
state: Schema.Literals([
|
|
93
96
|
"running",
|
|
94
97
|
"done",
|
|
@@ -227,13 +230,13 @@ const missedCounted = (lfs, missed, held) => {
|
|
|
227
230
|
*/
|
|
228
231
|
const lfsMissedHeld = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, oids) {
|
|
229
232
|
if (oids.length === 0) return /* @__PURE__ */ new Set();
|
|
230
|
-
const snapshot = yield* storeCall(
|
|
233
|
+
const snapshot = yield* storeCall(store.read(repoScope(internalId), oids.map(lfsMissedKey)));
|
|
231
234
|
return new Set(snapshot.results.flatMap(([row]) => row === void 0 ? [] : [row.id.slice(12)]));
|
|
232
235
|
});
|
|
233
236
|
const lfsPageGone = (page) => gitError("DATA_LOSS", `The import's page ${page} of LFS pointers is gone`, { hint: failedHint });
|
|
234
237
|
/** Page `page` of the import's LFS pointers, as the table lays them out. */
|
|
235
238
|
const readLfsPage = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, page) {
|
|
236
|
-
const [[held] = []] = (yield* storeCall(
|
|
239
|
+
const [[held] = []] = (yield* storeCall(store.read(repoScope(internalId), [lfsPageKey(page)]))).results;
|
|
237
240
|
if (held === void 0) return yield* Effect.fail(lfsPageGone(page));
|
|
238
241
|
const { pointers } = yield* decodeRow(LfsPage, held, `The import's LFS page ${page}`);
|
|
239
242
|
const bytes = Base64.decode(pointers);
|
|
@@ -256,7 +259,7 @@ const pageMissing = (page) => gitError("DATA_LOSS", `The import's page ${page} o
|
|
|
256
259
|
const readTipPages = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, from, to) {
|
|
257
260
|
const keys = tipPageKeys(from, to);
|
|
258
261
|
if (keys.length === 0) return [];
|
|
259
|
-
const snapshot = yield* storeCall(
|
|
262
|
+
const snapshot = yield* storeCall(store.read(repoScope(internalId), keys));
|
|
260
263
|
return yield* Effect.forEach(snapshot.results, ([held], at) => held === void 0 ? Effect.fail(pageMissing(from + at)) : decodeRow(TipPage, held, "Import tip page"));
|
|
261
264
|
});
|
|
262
265
|
/**
|
|
@@ -359,22 +362,23 @@ const readImport = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalI
|
|
|
359
362
|
version: snapshot.version
|
|
360
363
|
};
|
|
361
364
|
});
|
|
365
|
+
/** What a repo's import's state reads of its scope: its row, its cancel row and its missed LFS objects. */
|
|
366
|
+
const importReads = [
|
|
367
|
+
{ ...importKey },
|
|
368
|
+
{ ...cancelKey },
|
|
369
|
+
{
|
|
370
|
+
collection: collections.imports,
|
|
371
|
+
prefix: lfsMissedPrefix,
|
|
372
|
+
limit: importLfsMissedMost
|
|
373
|
+
}
|
|
374
|
+
];
|
|
362
375
|
/**
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
376
|
+
* The repo's import as `importReads`' `results` hold it, its row, cancel row and missed LFS
|
|
377
|
+
* objects, or `undefined` for a repo no import made. A running row whose job has gone stays
|
|
378
|
+
* `running`: this read writes nothing, where `importLive` commits it `failed`.
|
|
366
379
|
*/
|
|
367
|
-
const
|
|
368
|
-
const
|
|
369
|
-
{ ...importKey },
|
|
370
|
-
{ ...cancelKey },
|
|
371
|
-
{
|
|
372
|
-
collection: collections.imports,
|
|
373
|
-
prefix: lfsMissedPrefix,
|
|
374
|
-
limit: importLfsMissedMost
|
|
375
|
-
}
|
|
376
|
-
];
|
|
377
|
-
const [[own] = [], [cancel] = [], missedRows = []] = (yield* readAsked(store, internalId, reads, [])).results;
|
|
380
|
+
const importStatusOf = /* @__PURE__ */ Effect.fnUntraced(function* (results) {
|
|
381
|
+
const [[own] = [], [cancel] = [], missedRows = []] = results;
|
|
378
382
|
if (own === void 0) return void 0;
|
|
379
383
|
const row = yield* decodeRow(ImportRow, own, "Import");
|
|
380
384
|
const state = row.state === "running" && cancel !== void 0 ? "cancelled" : row.state;
|
|
@@ -399,13 +403,15 @@ const importStateOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, intern
|
|
|
399
403
|
}
|
|
400
404
|
};
|
|
401
405
|
});
|
|
406
|
+
/** `JoinedCalls.importState`: `importStatusOf` the repo `internalId` holds, in one read. */
|
|
407
|
+
const importStateOf = (store, internalId) => Effect.flatMap(readAsked(store, internalId, importReads, []), (snapshot) => importStatusOf(snapshot.results));
|
|
402
408
|
/** Whether the repo's `sync.import` job is waiting or running: a try is due or under way. */
|
|
403
409
|
const jobLive = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId) {
|
|
404
410
|
const scope = repoScope(internalId);
|
|
405
411
|
let after;
|
|
406
412
|
for (;;) {
|
|
407
413
|
const page = after === void 0 ? {} : { page: { after } };
|
|
408
|
-
const listing = yield* storeCall(
|
|
414
|
+
const listing = yield* storeCall(store.jobs.list(scope, page));
|
|
409
415
|
const job = listing.items.find((item) => item.name === importJobName);
|
|
410
416
|
if (job !== void 0) return job.state !== "failed";
|
|
411
417
|
if (listing.next === void 0) return false;
|
|
@@ -427,7 +433,7 @@ const importLive = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalI
|
|
|
427
433
|
const { row } = read;
|
|
428
434
|
if (row?.state !== "running" || read.cancelled) return false;
|
|
429
435
|
if (yield* jobLive(store, internalId)) return true;
|
|
430
|
-
if ((yield*
|
|
436
|
+
if ((yield* storeCommit(store.commit(repoScope(internalId), {
|
|
431
437
|
id: newChangeId(),
|
|
432
438
|
expect: read.version,
|
|
433
439
|
put: [importRow(failedRow(row, stoppedTry))],
|
|
@@ -436,4 +442,4 @@ const importLive = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalI
|
|
|
436
442
|
}
|
|
437
443
|
return true;
|
|
438
444
|
});
|
|
439
|
-
export { ImportLfs, ImportReceiving, ImportRow, cancelKey, cutKey, cutRow, failedHint, failedRow, importEndDeletes, importKey, importLfsMissedMost, importLfsPagesMost, importLive, importRow, importStateOf, lfsMissedHeld, lfsPageKey, lfsPageRow, missedCounted, noImportLfs, readImport, readLfsPage, readTipPages, stoppedTry, tipPageKey, tipPageRow, tipPagesOf, tipRowBytes };
|
|
445
|
+
export { ImportLfs, ImportReceiving, ImportRow, cancelKey, cutKey, cutRow, failedHint, failedRow, importEndDeletes, importKey, importLfsMissedMost, importLfsPagesMost, importLive, importReads, importRow, importStateOf, importStatusOf, lfsMissedHeld, lfsPageKey, lfsPageRow, missedCounted, noImportLfs, readImport, readLfsPage, readTipPages, stoppedTry, tipPageKey, tipPageRow, tipPagesOf, tipRowBytes };
|
package/dist/core/index-job.mjs
CHANGED
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
import { keepsEvents } from "../contracts/events.mjs";
|
|
2
|
-
import { indexRowOf } from "../storage/index-build.mjs";
|
|
2
|
+
import { indexRowOf, sliceBounds } from "../storage/index-build.mjs";
|
|
3
|
+
import "../storage/receive-bounds.mjs";
|
|
3
4
|
import { liftsHolds } from "../storage/index-remap.mjs";
|
|
4
5
|
import { indexRowKey } from "../storage/layout.mjs";
|
|
5
|
-
import {
|
|
6
|
+
import { decodeRow, storeCommit } from "../store/errors.mjs";
|
|
6
7
|
import { decodePacks } from "../store/git-store.mjs";
|
|
8
|
+
import { LooseTally } from "../store/records.mjs";
|
|
7
9
|
import { appendEvents, decodeOutbox, outboxReads, repoEnvelope } from "../store/outbox.mjs";
|
|
8
10
|
import { WholeRepo, wholeRefs } from "../store/ref-rows.mjs";
|
|
9
11
|
import { readRecord, rootsOf } from "../store/repo-record.mjs";
|
|
10
|
-
import { budgetedInput } from "../store/call-count.mjs";
|
|
12
|
+
import { budgetMade, budgetMost, budgetedInput, callScope, nestsIn, spentBudget } from "../store/call-count.mjs";
|
|
13
|
+
import { ownSpentOf, spentOf } from "../contracts/calls-spent.mjs";
|
|
11
14
|
import { gitJob } from "../store/job-try.mjs";
|
|
12
|
-
import { collections, jobRepo, newChangeId, repoRootsKey, repoScope } from "../store/scopes.mjs";
|
|
15
|
+
import { collections, jobRepo, looseKey, newChangeId, repoRootsKey, repoScope } from "../store/scopes.mjs";
|
|
13
16
|
import { settleName } from "../store/settle.mjs";
|
|
14
17
|
import { SealedObjects } from "./view.mjs";
|
|
15
18
|
import { fail } from "../contracts/result.mjs";
|
|
16
19
|
import * as Effect from "effect/Effect";
|
|
17
20
|
import * as Schema from "effect/Schema";
|
|
21
|
+
import * as Cause from "effect/Cause";
|
|
22
|
+
import * as Exit from "effect/Exit";
|
|
18
23
|
import { CurrentJob, Job } from "@ref0/infra";
|
|
19
24
|
import * as DateTime from "effect/DateTime";
|
|
20
25
|
// src/core/index-job.ts
|
|
21
26
|
/**
|
|
22
27
|
* `git.index`, the reachability index's build (#597) and its upkeep (#596): one step a try, as
|
|
23
|
-
* the objects' `index` says,
|
|
28
|
+
* the objects' `index` says, or on a small repo several back to back while the try's calls and
|
|
29
|
+
* CPU allow (#2525), its cursor in the row's data, until the `index` row the core
|
|
24
30
|
* commits, then a try that builds again if what it covers moved since, or prunes what the build
|
|
25
31
|
* replaced. Every commit that moves a ref saves it, but while a refusal at the server's bound
|
|
26
32
|
* stands: a push, an API write, an import, a sync or a fork's. A repo's delete saves it too, and
|
|
@@ -56,7 +62,8 @@ const tryReads = [
|
|
|
56
62
|
{ collection: collections.refs },
|
|
57
63
|
{ collection: collections.packs },
|
|
58
64
|
indexRowKey,
|
|
59
|
-
repoRootsKey
|
|
65
|
+
repoRootsKey,
|
|
66
|
+
looseKey
|
|
60
67
|
];
|
|
61
68
|
/** A try's reads with `events`: the outbox a refusal's event goes to, too. */
|
|
62
69
|
const eventReads = [...tryReads, ...outboxReads];
|
|
@@ -69,6 +76,12 @@ const refusalOf = (landed, before) => {
|
|
|
69
76
|
if (landed.state === "too-large") return "too-large";
|
|
70
77
|
return landed.state === "refused" ? "spent" : void 0;
|
|
71
78
|
};
|
|
79
|
+
/** The states a row that holds a refusal reads as: a refused row's, or a built one's refused update. */
|
|
80
|
+
const refusing = /* @__PURE__ */ new Set([
|
|
81
|
+
"refused",
|
|
82
|
+
"retry",
|
|
83
|
+
"too-large"
|
|
84
|
+
]);
|
|
72
85
|
/**
|
|
73
86
|
* What a refusal's event says, in the core's words alone: a row's reason may name the host's
|
|
74
87
|
* step, which no event carries (Q851).
|
|
@@ -82,9 +95,12 @@ const refusalError = (refusal) => refusal === "spent" ? `git.index ran out of it
|
|
|
82
95
|
* `round` is the job's, from its key. With `failed`, the round's tries are spent: the step
|
|
83
96
|
* answers a refused row with that reason, and builds nothing. A step that answers `moved` is
|
|
84
97
|
* asked once more over a fresh read, with `lastCheck`, and its answer is the try's: no `moved`
|
|
85
|
-
* leaves the job.
|
|
98
|
+
* leaves the job. A `chained` step, one after another in the same try, commits no refusal: its
|
|
99
|
+
* calls are what the steps before it left, so its row ends `withheld`, and the try ends with the
|
|
100
|
+
* step before it kept, for the next try to run first with the whole budget (#2525).
|
|
86
101
|
*/
|
|
87
|
-
const indexAttempt = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, internalId, data, signal, round,
|
|
102
|
+
const indexAttempt = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, internalId, data, signal, round, options = {}) {
|
|
103
|
+
const { failed, chained } = options;
|
|
88
104
|
const index = SealedObjects.whole(parts.objects, indexWhole).index;
|
|
89
105
|
if (index === void 0) return {
|
|
90
106
|
ended: "none",
|
|
@@ -99,7 +115,7 @@ const indexAttempt = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store,
|
|
|
99
115
|
at,
|
|
100
116
|
lastCheck
|
|
101
117
|
});
|
|
102
|
-
const stepOf = (asked) => Effect.flatMap(budgetedInput(asked.input), (input) =>
|
|
118
|
+
const stepOf = (asked) => Effect.flatMap(budgetedInput(asked.input), (input) => index.step(asked.listed, input));
|
|
103
119
|
const first = yield* read();
|
|
104
120
|
if (first === void 0) return {
|
|
105
121
|
ended: "none",
|
|
@@ -113,13 +129,15 @@ const indexAttempt = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store,
|
|
|
113
129
|
};
|
|
114
130
|
const step = tried === first ? asked : yield* stepOf(tried);
|
|
115
131
|
if (step.kind === "moved") return yield* fail("INTERNAL", "The host's IndexCalls answered moved to a last check");
|
|
116
|
-
const { record, snapshot, listed, packs, row, headRows, cursorRows } = tried;
|
|
132
|
+
const { record, snapshot, listed, packs, loose, row, headRows, cursorRows } = tried;
|
|
133
|
+
const small = smallRepo(packs, loose);
|
|
117
134
|
if (step.kind === "more") return {
|
|
118
135
|
ended: "more",
|
|
119
136
|
next: {
|
|
120
137
|
kind: "more",
|
|
121
138
|
data: { build: step.data }
|
|
122
|
-
}
|
|
139
|
+
},
|
|
140
|
+
small
|
|
123
141
|
};
|
|
124
142
|
if (step.kind === "pruned") return {
|
|
125
143
|
ended: "pruned",
|
|
@@ -127,11 +145,16 @@ const indexAttempt = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store,
|
|
|
127
145
|
kind: "more",
|
|
128
146
|
at: step.due,
|
|
129
147
|
data: {}
|
|
130
|
-
}
|
|
148
|
+
},
|
|
149
|
+
small
|
|
131
150
|
};
|
|
132
151
|
const scope = repoScope(internalId);
|
|
133
152
|
const ids = packs.map(({ id }) => id);
|
|
134
153
|
const landed = index.status(step.row, at, ids);
|
|
154
|
+
if (chained === true && refusing.has(landed.state)) return {
|
|
155
|
+
ended: "withheld",
|
|
156
|
+
next: void 0
|
|
157
|
+
};
|
|
135
158
|
const refusal = refusalOf(landed, index.status(row, at, ids));
|
|
136
159
|
const sends = refusal !== void 0 && keepsEvents(parts.events) && record.deleted !== true;
|
|
137
160
|
const events = sends ? [refusedEvent(record.name, refusal)] : [];
|
|
@@ -156,7 +179,7 @@ const indexAttempt = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store,
|
|
|
156
179
|
});
|
|
157
180
|
const repack = parts.repackJobRow !== void 0 && liftsHolds(indexRowOf(row), indexRowOf(step.row), listed) ? [parts.repackJobRow()] : [];
|
|
158
181
|
const retry = yield* uncoveredRetry(step.row, landed, (when) => index.status(step.row, when, ids));
|
|
159
|
-
const committed = yield*
|
|
182
|
+
const committed = yield* storeCommit(store.commit(scope, {
|
|
160
183
|
id: newChangeId(),
|
|
161
184
|
expect: snapshot.version,
|
|
162
185
|
put: [step.row, ...appended.put],
|
|
@@ -172,7 +195,8 @@ const indexAttempt = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store,
|
|
|
172
195
|
next: {
|
|
173
196
|
kind: "more",
|
|
174
197
|
data: committed.ok ? {} : kept
|
|
175
|
-
}
|
|
198
|
+
},
|
|
199
|
+
small
|
|
176
200
|
};
|
|
177
201
|
});
|
|
178
202
|
/**
|
|
@@ -209,7 +233,7 @@ const readTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, inter
|
|
|
209
233
|
const reads = keepsEvents(parts.events) ? eventReads : tryReads;
|
|
210
234
|
const { record, snapshot } = yield* readRecord(store, internalId, reads);
|
|
211
235
|
if (record === void 0) return void 0;
|
|
212
|
-
const [, refRows = [], packRows = [], indexRows = [], rootRows, headRows = [], cursorRows = []] = snapshot.results;
|
|
236
|
+
const [, refRows = [], packRows = [], indexRows = [], rootRows, looseRows = [], headRows = [], cursorRows = []] = snapshot.results;
|
|
213
237
|
const refs = yield* wholeRefs(indexWhole, refRows);
|
|
214
238
|
const packs = yield* decodePacks(packRows);
|
|
215
239
|
const roots = yield* rootsOf(rootRows);
|
|
@@ -231,28 +255,95 @@ const readTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, inter
|
|
|
231
255
|
if (row !== void 0) input.row = row.value;
|
|
232
256
|
if (roots.size > 0) input.roots = [...roots];
|
|
233
257
|
if (of.lastCheck === true) input.lastCheck = true;
|
|
258
|
+
const [looseRow] = looseRows;
|
|
234
259
|
return {
|
|
235
260
|
record,
|
|
236
261
|
snapshot,
|
|
237
262
|
listed,
|
|
238
263
|
packs,
|
|
264
|
+
loose: looseRow === void 0 ? void 0 : yield* decodeRow(LooseTally, looseRow, "The repo's object rows' tally"),
|
|
239
265
|
row,
|
|
240
266
|
headRows,
|
|
241
267
|
cursorRows,
|
|
242
268
|
input
|
|
243
269
|
};
|
|
244
270
|
});
|
|
245
|
-
/**
|
|
246
|
-
|
|
271
|
+
/**
|
|
272
|
+
* The most a repo's packs hold for a try to run its steps back to back: an eighth of a read
|
|
273
|
+
* slice's bytes and links, so each step over it does at most about an eighth of the work a step
|
|
274
|
+
* is sized to fit a whole try with (#2525).
|
|
275
|
+
*/
|
|
276
|
+
const chainedMost = {
|
|
277
|
+
bytes: sliceBounds.bytes / 8,
|
|
278
|
+
objects: sliceBounds.links / 8
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* The share of a try's CPU, and of its calls, its steps may have used and still start another:
|
|
282
|
+
* a quarter, so one more step at an eighth of a try's work stays well inside both.
|
|
283
|
+
*/
|
|
284
|
+
const chainedShare = 1 / 4;
|
|
285
|
+
/**
|
|
286
|
+
* Whether `packs` and the repo's object rows, `loose`, are small enough together, as
|
|
287
|
+
* `chainedMost` says, for steps back to back: a step reads both.
|
|
288
|
+
*/
|
|
289
|
+
const smallRepo = (packs, loose) => {
|
|
290
|
+
const bytes = packs.reduce((sum, pack) => sum + pack.bytes, loose?.bytes ?? 0);
|
|
291
|
+
const objects = packs.reduce((sum, pack) => sum + pack.objects, loose?.objects ?? 0);
|
|
292
|
+
return bytes <= chainedMost.bytes && objects <= chainedMost.objects;
|
|
293
|
+
};
|
|
294
|
+
/** Whether `made` is no more than `chainedShare` of `most`, bucket calls and subrequests each. */
|
|
295
|
+
const chainsWithin = (made, most) => made.bucket <= .25 * most.bucket && made.subrequests <= .25 * most.subrequests;
|
|
296
|
+
/** Whether the try's budget in scope, if any, has used no more than `chainedShare` of each kind. */
|
|
297
|
+
const callsLeft = Effect.map(callScope, ({ budget }) => budget === void 0 ? true : chainsWithin(budgetMade(budget), budgetMost(budget)));
|
|
298
|
+
/**
|
|
299
|
+
* Whether a try that started at `start` runs another step after `attempt`: one that ended with
|
|
300
|
+
* the next step due now, a `more` or a landed row's prune, over a small repo, with the try's
|
|
301
|
+
* wall time so far, which its CPU is no more than, and its calls each within `chainedShare`.
|
|
302
|
+
*/
|
|
303
|
+
const chainsOn = (parts, attempt, start, signal) => {
|
|
304
|
+
if (!(attempt.ended === "more" || attempt.ended === "landed") || attempt.small !== true || signal.aborted) return Effect.succeed(false);
|
|
305
|
+
const cpuMs = parts.cpuMs ?? 3e4;
|
|
306
|
+
return Effect.flatMap(parts.now, (now) => now - start >= .25 * cpuMs ? Effect.succeed(false) : callsLeft);
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* Whether `cause` holds a spent bound that's no budget the try's own nests: the platform's cap,
|
|
310
|
+
* or a request's count.
|
|
311
|
+
*/
|
|
312
|
+
const spentElsewhere = (cause) => Effect.map(callScope, ({ budget }) => {
|
|
313
|
+
if (spentOf(cause) === void 0) return false;
|
|
314
|
+
const owns = (spent) => {
|
|
315
|
+
const at = spentBudget(spent);
|
|
316
|
+
return budget !== void 0 && at !== void 0 && nestsIn(at, budget);
|
|
317
|
+
};
|
|
318
|
+
return ownSpentOf(cause, owns) === void 0;
|
|
319
|
+
});
|
|
320
|
+
/**
|
|
321
|
+
* `indexAttempt`, as the queue takes it: with `chains`, more steps after it in the same try while
|
|
322
|
+
* `chainsOn` allows, each committing what it commits on its own, as a try of its own would. Only
|
|
323
|
+
* the last step's `next` is kept, so a try lost between steps runs them again from its own data,
|
|
324
|
+
* as a try lost mid-step does; the next try, past a lost one, runs one step (#2525).
|
|
325
|
+
*/
|
|
326
|
+
const indexTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, internalId, data, signal, round, chains) {
|
|
327
|
+
const start = yield* parts.now;
|
|
328
|
+
let attempt = yield* indexAttempt(parts, store, internalId, data, signal, round);
|
|
329
|
+
while (chains && attempt.next !== void 0 && (yield* chainsOn(parts, attempt, start, signal))) {
|
|
330
|
+
const next = attempt.next;
|
|
331
|
+
const chained = yield* Effect.exit(indexAttempt(parts, store, internalId, next.data ?? {}, signal, round, { chained: true }));
|
|
332
|
+
if (Exit.isFailure(chained)) {
|
|
333
|
+
if (Cause.hasInterrupts(chained.cause) || (yield* spentElsewhere(chained.cause))) return yield* Effect.failCause(chained.cause);
|
|
334
|
+
yield* Effect.logDebug("git.index ends a try at a step that failed after another", chained.cause);
|
|
335
|
+
return next;
|
|
336
|
+
}
|
|
337
|
+
if (chained.value.ended === "withheld") return next;
|
|
338
|
+
attempt = chained.value;
|
|
339
|
+
}
|
|
340
|
+
return attempt.next;
|
|
341
|
+
});
|
|
247
342
|
/** `git.index`'s try, in the repo's scope: a step of the build, or past its tries, the refusal. */
|
|
248
|
-
const indexStep = (parts) => (data) => Effect.flatMap(Effect.all([
|
|
249
|
-
|
|
250
|
-
CurrentJob.store,
|
|
251
|
-
CurrentJob.signal
|
|
252
|
-
]), ([job, store, signal]) => job.attempt > 20 ? refusalTry(parts, job, {
|
|
253
|
-
store,
|
|
343
|
+
const indexStep = (parts) => (data) => Effect.flatMap(Effect.all([CurrentJob.current, CurrentJob.signal]), ([job, signal]) => job.attempt > 20 ? refusalTry(parts, job, {
|
|
344
|
+
store: parts.store,
|
|
254
345
|
signal
|
|
255
|
-
}, data, spentReason(lastOf(job))) : indexTry(parts, store, jobRepo(job), data, signal, roundOf(job.key)));
|
|
346
|
+
}, data, spentReason(lastOf(job))) : indexTry(parts, parts.store, jobRepo(job), data, signal, roundOf(job.key), job.attempt === 1));
|
|
256
347
|
/** How the build's last try ended, as the first refusal try's claim says: later ones can't. */
|
|
257
348
|
const lastOf = (job) => {
|
|
258
349
|
if (job.attempt > 21) return "its refusal tried again";
|
|
@@ -274,7 +365,7 @@ const refusalTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, job, cont
|
|
|
274
365
|
const internalId = jobRepo(job);
|
|
275
366
|
const round = roundOf(job.key);
|
|
276
367
|
for (let write = 0; write < refusalWrites; write += 1) {
|
|
277
|
-
const tried = yield* indexAttempt(parts, context.store, internalId, data, context.signal, round, { reason });
|
|
368
|
+
const tried = yield* indexAttempt(parts, context.store, internalId, data, context.signal, round, { failed: { reason } });
|
|
278
369
|
if (tried.ended === "missed") continue;
|
|
279
370
|
if (tried.ended !== "landed") return tried.next;
|
|
280
371
|
const { snapshot } = yield* readRecord(context.store, internalId, [indexRowKey, { collection: collections.packs }]);
|
|
@@ -291,19 +382,16 @@ const refusalTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, job, cont
|
|
|
291
382
|
* its failure logged. A round left failed with no refused row is one an operator's `retry` starts
|
|
292
383
|
* again, since no refusal stands for its try to prune against.
|
|
293
384
|
*/
|
|
294
|
-
const indexFailed = (parts) => (data, failure) => Effect.flatMap(Effect.all([
|
|
295
|
-
|
|
296
|
-
CurrentJob.store,
|
|
297
|
-
CurrentJob.signal
|
|
298
|
-
]), ([job, store, signal]) => Effect.catch(refusalTry(parts, job, {
|
|
299
|
-
store,
|
|
385
|
+
const indexFailed = (parts) => (data, failure) => Effect.flatMap(Effect.all([CurrentJob.current, CurrentJob.signal]), ([job, signal]) => Effect.catch(refusalTry(parts, job, {
|
|
386
|
+
store: parts.store,
|
|
300
387
|
signal
|
|
301
388
|
}, data, spentReason(failure.error instanceof Error ? failure.error.message : String(failure.error))), (error) => Effect.logError(`git.index left repo ${jobRepo(job)} failed, with no refusal: ${error.message}`)).pipe(Effect.asVoid));
|
|
302
389
|
/** How many times a refusal's try reads and writes the refused row before it fails. */
|
|
303
390
|
const refusalWrites = 3;
|
|
304
391
|
/**
|
|
305
|
-
* `git.index`, over one server's objects. A try is one step,
|
|
306
|
-
* `more` puts the row back due now, and starts its
|
|
392
|
+
* `git.index`, over one server's objects. A try is one step, or a small repo's several back to
|
|
393
|
+
* back, so a large repo is many tries; each `more` puts the row back due now, and starts its
|
|
394
|
+
* tries' count again. Past `indexTries` in a
|
|
307
395
|
* row, the next tries leave a refused row, and `indexFailed` is their last chance. One at a time
|
|
308
396
|
* in each process, as `git.repack` runs.
|
|
309
397
|
*/
|
|
@@ -324,4 +412,4 @@ const indexJobRow = (job, round = 0) => job.job({
|
|
|
324
412
|
key: indexJobKeyOf(round),
|
|
325
413
|
data: {}
|
|
326
414
|
});
|
|
327
|
-
export { IndexJobData, indexDeletedKey, indexJob, indexJobKey, indexJobKeyOf, indexJobName, indexJobRow };
|
|
415
|
+
export { IndexJobData, chainedMost, chainedShare, chainsWithin, indexDeletedKey, indexJob, indexJobKey, indexJobKeyOf, indexJobName, indexJobRow, smallRepo };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { InternalRepoId } from "../contracts/ids.mjs";
|
|
2
2
|
import "../contracts/objects.mjs";
|
|
3
|
-
import "../contracts/promises.mjs";
|
|
4
3
|
import { Listed } from "../contracts/store.mjs";
|
|
5
4
|
import * as Effect from "effect/Effect";
|
|
6
|
-
import { JobInput, Moment, Row } from "@ref0/infra";
|
|
5
|
+
import { JobInput, Moment, Records, Row } from "@ref0/infra";
|
|
7
6
|
/**
|
|
8
7
|
* A read's ask for the rebuild of the `index` row it read, `row`, once the index it names failed
|
|
9
8
|
* its own checks: `listed` is the listing the read was at.
|
package/dist/core/index-lost.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bestEffort,
|
|
1
|
+
import { bestEffort, storeCommit } from "../store/errors.mjs";
|
|
2
2
|
import { newChangeId, repoScope } from "../store/scopes.mjs";
|
|
3
3
|
import { lostIndexRow } from "../storage/index-build.mjs";
|
|
4
4
|
import { indexJobs } from "./access.mjs";
|
|
@@ -45,7 +45,7 @@ const indexLostAsk = (parts) => {
|
|
|
45
45
|
put: [marked],
|
|
46
46
|
jobs
|
|
47
47
|
};
|
|
48
|
-
const committed = yield* bestEffort(
|
|
48
|
+
const committed = yield* bestEffort(storeCommit(parts.store.commit(repoScope(repo), change)), failed).pipe(Effect.onInterrupt(() => Effect.sync(() => asked.delete(key))));
|
|
49
49
|
if (committed !== void 0 && !committed.ok) asked.delete(key);
|
|
50
50
|
});
|
|
51
51
|
};
|
|
@@ -22,7 +22,7 @@ const rowsAtCommit = /* @__PURE__ */ Effect.fnUntraced(function* (store, interna
|
|
|
22
22
|
collection: row.collection,
|
|
23
23
|
prefix: row.id
|
|
24
24
|
}));
|
|
25
|
-
const snapshot = yield* storeCall(
|
|
25
|
+
const snapshot = yield* storeCall(store.read(scope, [], counts));
|
|
26
26
|
if (snapshot.version !== version) return void 0;
|
|
27
27
|
for (const [index, row] of batch.entries()) {
|
|
28
28
|
if ((snapshot.counts[index] ?? 0) === 0) continue;
|
|
@@ -1,11 +1,104 @@
|
|
|
1
|
+
import { objectsReadMost } from "../../contracts/object-values.mjs";
|
|
1
2
|
import { deadlineOf, limitsOf, timed } from "../../engine/reads.mjs";
|
|
3
|
+
import { streamThen } from "../../protocol/bytes/streams.mjs";
|
|
4
|
+
import { isOid } from "../../protocol/bytes/text.mjs";
|
|
2
5
|
import { heldBytes } from "../../protocol/objects/held.mjs";
|
|
6
|
+
import { forkIn, noCall } from "../../store/crossing.mjs";
|
|
3
7
|
import { callerFor } from "../access.mjs";
|
|
4
|
-
import { dropped, objectAt, openRead } from "./reading.mjs";
|
|
8
|
+
import { dropped, missingObject, objectAt, openRead } from "./reading.mjs";
|
|
9
|
+
import { notAnOid } from "./trees.mjs";
|
|
5
10
|
import { objectWrite, oidAnswer } from "./writing.mjs";
|
|
6
|
-
import {
|
|
11
|
+
import { answerFailed } from "../../contracts/calls-spent.mjs";
|
|
12
|
+
import { fail, gitError } from "../../contracts/result.mjs";
|
|
13
|
+
import * as Clock from "effect/Clock";
|
|
7
14
|
import * as Effect from "effect/Effect";
|
|
15
|
+
import * as Exit from "effect/Exit";
|
|
16
|
+
import "effect/Fiber";
|
|
17
|
+
import * as Scope from "effect/Scope";
|
|
8
18
|
// src/core/objects/blobs.ts
|
|
19
|
+
/** `getMany`'s refusal of a first blob past what it may hold, which it then streams on its own. */
|
|
20
|
+
const heldPast = (most) => gitError("RESOURCE_EXHAUSTED", `blobs.getMany holds at most ${most} bytes at once`, { context: { reason: "walk-limit" } });
|
|
21
|
+
/**
|
|
22
|
+
* `read`'s answer as `getMany` gives it: the longest run of `oids` it read, in the order asked, then
|
|
23
|
+
* the rest in `left`, so the two are `oids` again. A read in offset order may keep an object past
|
|
24
|
+
* the first it left, which goes to `left` too. An ID in neither `objects` nor `left` the repo
|
|
25
|
+
* lacks, or the caller can't see: `NOT_FOUND`. An object that isn't a blob: `INVALID_ARGUMENT`.
|
|
26
|
+
* Each blob's bytes are a body `bodyOf` makes, once it's answered.
|
|
27
|
+
*/
|
|
28
|
+
const blobsOf = (opened, oids, read, bodyOf) => {
|
|
29
|
+
const left = new Set(read.left);
|
|
30
|
+
const missing = oids.find((oid) => !read.objects.has(oid) && !left.has(oid));
|
|
31
|
+
if (missing !== void 0) return missingObject(opened, missing);
|
|
32
|
+
const notBlob = [...read.objects.values()].find((object) => object.type !== "blob");
|
|
33
|
+
if (notBlob !== void 0) return fail("INVALID_ARGUMENT", `${notBlob.oid} is a ${notBlob.type}, not a blob`);
|
|
34
|
+
const run = oids.findIndex((oid) => !read.objects.has(oid));
|
|
35
|
+
const answered = run === -1 ? oids : oids.slice(0, run);
|
|
36
|
+
const blobs = answered.flatMap((oid) => {
|
|
37
|
+
const object = read.objects.get(oid);
|
|
38
|
+
return object === void 0 ? [] : [{
|
|
39
|
+
oid,
|
|
40
|
+
size: object.bytes.byteLength,
|
|
41
|
+
bytes: bodyOf(object.bytes)
|
|
42
|
+
}];
|
|
43
|
+
});
|
|
44
|
+
return Effect.succeed({
|
|
45
|
+
blobs,
|
|
46
|
+
left: oids.slice(answered.length)
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* `oids[0]` streamed on its own, as `get` reads it, and the rest left: what `getMany` answers when
|
|
51
|
+
* the first blob is past what the call may hold, or past what the server reads whole.
|
|
52
|
+
*/
|
|
53
|
+
const firstStreamed = /* @__PURE__ */ Effect.fnUntraced(function* (opened, oids) {
|
|
54
|
+
const [first, ...rest] = oids;
|
|
55
|
+
const object = yield* objectAt(opened, first);
|
|
56
|
+
if (object.type !== "blob") {
|
|
57
|
+
dropped(object);
|
|
58
|
+
return yield* fail("INVALID_ARGUMENT", `${first} is a ${object.type}, not a blob`);
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
blobs: [{
|
|
62
|
+
oid: object.oid,
|
|
63
|
+
size: object.size,
|
|
64
|
+
bytes: object.bytes
|
|
65
|
+
}],
|
|
66
|
+
left: rest
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* How long `getMany`'s bodies wait to be read once it answers: past it, each still unread fails
|
|
71
|
+
* as `unreadPast` says and lets go of what the batch was read under.
|
|
72
|
+
*/
|
|
73
|
+
const unreadBlobsMs = 3e4;
|
|
74
|
+
/** A `getMany` body left unread past `unreadBlobsMs`. */
|
|
75
|
+
const unreadPast = () => gitError("RESOURCE_EXHAUSTED", `A blob blobs.getMany answered was unread past ${unreadBlobsMs} ms`, {
|
|
76
|
+
hint: "Read or cancel each blob it answers",
|
|
77
|
+
context: { reason: "walk-limit" }
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* Bodies that each hold what their batch was read under until it's read to its end, cancelled or
|
|
81
|
+
* `expire`d, `close` run once after the last: a reader may hold a blob read from chunks charged to
|
|
82
|
+
* the server's budget until its release, so the call can't close it as it answers, while the
|
|
83
|
+
* caller still holds every blob. A body a caller drops unread would hold it for good, so `expire`
|
|
84
|
+
* ends each still unread.
|
|
85
|
+
*/
|
|
86
|
+
const heldBodies = (close) => {
|
|
87
|
+
const expiry = new AbortController();
|
|
88
|
+
let open = 0;
|
|
89
|
+
const done = () => {
|
|
90
|
+
open -= 1;
|
|
91
|
+
if (open === 0) close();
|
|
92
|
+
};
|
|
93
|
+
return {
|
|
94
|
+
bodyOf: (bytes) => {
|
|
95
|
+
open += 1;
|
|
96
|
+
return streamThen(bytes, done, expiry.signal);
|
|
97
|
+
},
|
|
98
|
+
none: () => open === 0,
|
|
99
|
+
expire: () => expiry.abort(unreadPast())
|
|
100
|
+
};
|
|
101
|
+
};
|
|
9
102
|
/**
|
|
10
103
|
* `blobs.get`: a blob's bytes as the objects stream them, never held whole, refused before its
|
|
11
104
|
* first byte only past the `bytes` limit the caller sets, and only past `milliseconds` until it
|
|
@@ -43,6 +136,39 @@ const blobCalls = (bound) => {
|
|
|
43
136
|
bytes: object.bytes
|
|
44
137
|
};
|
|
45
138
|
}, Effect.scoped),
|
|
139
|
+
getMany: Effect.fnUntraced(function* (repo, input) {
|
|
140
|
+
const limits = yield* limitsOf(input.limits);
|
|
141
|
+
const { oids } = input;
|
|
142
|
+
const [first] = oids;
|
|
143
|
+
if (first === void 0 || oids.length > 1024) return yield* fail("INVALID_ARGUMENT", `blobs.getMany takes 1 to ${objectsReadMost} IDs; \`oids\` holds ${oids.length}`, { hint: "Split the IDs" });
|
|
144
|
+
const bad = oids.find((oid) => !isOid(oid));
|
|
145
|
+
if (bad !== void 0) return yield* notAnOid(bad);
|
|
146
|
+
const deadline = yield* deadlineOf(limits.milliseconds, "walk-limit");
|
|
147
|
+
const most = Math.min(limits.reads.fileBytes, limits.reads.bytes);
|
|
148
|
+
const read = Effect.fnUntraced(function* (bodyOf) {
|
|
149
|
+
const opened = yield* openRead(callerOf(input), repo, [], input.internalId);
|
|
150
|
+
const bytes = yield* Effect.acquireRelease(Effect.sync(() => opened.allotment(most, heldPast(most))), (allotment) => Effect.sync(() => allotment.release()));
|
|
151
|
+
const result = yield* Effect.promise((signal) => opened.batch({
|
|
152
|
+
oids: [...new Set(oids)],
|
|
153
|
+
bytes,
|
|
154
|
+
signal
|
|
155
|
+
}));
|
|
156
|
+
if (result.kind === "error" && result.error.code === "RESOURCE_EXHAUSTED") return yield* firstStreamed(opened, [first, ...oids.slice(1)]);
|
|
157
|
+
if (result.kind === "error") return yield* answerFailed(result.error);
|
|
158
|
+
return yield* blobsOf(opened, oids, result.value, bodyOf);
|
|
159
|
+
});
|
|
160
|
+
return yield* Effect.uninterruptibleMask((restore) => Effect.flatMap(Scope.make(), (scope) => {
|
|
161
|
+
const close = Scope.close(scope, Exit.void);
|
|
162
|
+
let timer;
|
|
163
|
+
const bodies = heldBodies(() => {
|
|
164
|
+
timer?.interruptUnsafe();
|
|
165
|
+
forkIn(close, noCall);
|
|
166
|
+
});
|
|
167
|
+
const expiry = (at) => Effect.interruptible(Effect.flatMap(Clock.currentTimeMillis, (now) => Effect.andThen(Effect.sleep(Math.max(0, at - now)), Effect.sync(bodies.expire))));
|
|
168
|
+
const armed = Effect.flatMap(Clock.currentTimeMillis, (now) => Effect.forkDetach(expiry(now + unreadBlobsMs)));
|
|
169
|
+
return restore(Scope.provide(timed(read(bodies.bodyOf), deadline), scope)).pipe(Effect.onError(() => close), Effect.tap(() => bodies.none() ? close : Effect.map(armed, (fiber) => void (timer = fiber))));
|
|
170
|
+
}));
|
|
171
|
+
}),
|
|
46
172
|
create: Effect.fnUntraced(function* (repo, input) {
|
|
47
173
|
const bytes = yield* heldBytes(input.bytes, "blob");
|
|
48
174
|
return yield* objectWrite({
|
|
@@ -57,4 +183,4 @@ const blobCalls = (bound) => {
|
|
|
57
183
|
})
|
|
58
184
|
};
|
|
59
185
|
};
|
|
60
|
-
export { blobCalls };
|
|
186
|
+
export { blobCalls, blobsOf, unreadBlobsMs };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fromDiff } from "../../engine/failures.mjs";
|
|
2
2
|
import { readThrough } from "../../engine/reads.mjs";
|
|
3
3
|
import { countLines } from "../../protocol/diff/tree-diff.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { scopedReader } from "../../storage/calls.mjs";
|
|
5
5
|
import { mergePartsOption } from "../merge-parts.mjs";
|
|
6
6
|
import * as Effect from "effect/Effect";
|
|
7
7
|
import * as Option from "effect/Option";
|
|
@@ -12,7 +12,7 @@ import * as Option from "effect/Option";
|
|
|
12
12
|
* its own, as the queue's builds run, opens one for xdiff's scope, so its merges count on the
|
|
13
13
|
* budget too.
|
|
14
14
|
*/
|
|
15
|
-
const callAllot = (opened) => opened.scoped ? Effect.succeed(opened.allotment) : Effect.map(scopedReader(
|
|
15
|
+
const callAllot = (opened) => opened.scoped ? Effect.succeed(opened.allotment) : Effect.map(scopedReader(opened.objects, opened.listed), (reader) => (most, refusal) => reader.allotment(most, refusal));
|
|
16
16
|
/**
|
|
17
17
|
* Each change's lines, as `git diff --numstat` counts them with Git's default algorithm, Myers,
|
|
18
18
|
* over `Merges`' xdiff, each count allotted as `callAllot` says: within the call's limits, a count
|
|
@@ -44,7 +44,10 @@ const mergeCalls = (bound) => {
|
|
|
44
44
|
}, call, opened.roots);
|
|
45
45
|
if (bases.includes(theirs)) return { oid: tip };
|
|
46
46
|
const [base] = bases;
|
|
47
|
-
if (base === void 0) return yield* fail("FAILED_PRECONDITION", "refusing to merge unrelated histories", {
|
|
47
|
+
if (base === void 0) return yield* fail("FAILED_PRECONDITION", "refusing to merge unrelated histories", {
|
|
48
|
+
hint: `${input.theirs} shares no history with ${ours}`,
|
|
49
|
+
context: { reason: "unrelated-histories" }
|
|
50
|
+
});
|
|
48
51
|
const sides = bases.length === 1 ? {
|
|
49
52
|
base,
|
|
50
53
|
ours: tip,
|