@ref0/git 0.20.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access/private-refs.mjs +1 -1
- package/dist/auth/access-jwt.mjs +3 -3
- package/dist/auth/auth-namespace.d.mts +3 -3
- package/dist/auth/auth-namespace.mjs +3 -2
- package/dist/auth/auth.d.mts +3 -3
- package/dist/auth/auth.mjs +9 -8
- package/dist/auth/authorize.mjs +1 -1
- package/dist/auth/fences.d.mts +1 -1
- package/dist/auth/host-function.mjs +1 -1
- package/dist/auth/host-services.mjs +4 -6
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +6 -0
- package/dist/auth/token-cleanup.mjs +2 -2
- package/dist/auth/token-rows.mjs +6 -1
- package/dist/auth/token-text.mjs +1 -1
- package/dist/auth/tokens-base.d.mts +1 -1
- package/dist/auth/tokens.d.mts +1 -1
- package/dist/auth/tokens.mjs +1 -1
- package/dist/client/client.d.mts +15 -7
- package/dist/client/client.mjs +21 -12
- package/dist/client/git-http.mjs +1 -1
- package/dist/client/local.mjs +60 -24
- package/dist/client/negotiate.mjs +3 -3
- package/dist/client/push-upload.mjs +26 -10
- package/dist/client/remote.mjs +4 -3
- package/dist/client/run-remote-helper.d.mts +2 -2
- package/dist/client/run-remote-helper.mjs +6 -6
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +3 -3
- package/dist/contracts/blobs.d.mts +3 -3
- package/dist/contracts/blobs.mjs +1 -1
- package/dist/contracts/calls-spent.mjs +5 -33
- package/dist/contracts/client.d.mts +15 -14
- package/dist/contracts/commits.d.mts +4 -4
- package/dist/contracts/commits.mjs +1 -1
- package/dist/contracts/engine.d.mts +2 -2
- package/dist/contracts/events.d.mts +1 -1
- package/dist/contracts/events.mjs +1 -1
- package/dist/contracts/files.d.mts +4 -4
- package/dist/contracts/files.mjs +1 -1
- package/dist/contracts/forks.d.mts +4 -4
- package/dist/contracts/forks.mjs +1 -1
- package/dist/contracts/git-hooks.d.mts +1 -1
- package/dist/contracts/git.d.mts +9 -5
- package/dist/contracts/grants.d.mts +1 -1
- package/dist/contracts/merges.d.mts +1 -1
- package/dist/contracts/object-values.d.mts +1 -0
- package/dist/contracts/object-values.mjs +16 -1
- package/dist/contracts/objects.d.mts +20 -17
- package/dist/contracts/opaque.mjs +1 -1
- package/dist/contracts/operations.mjs +1 -1
- package/dist/contracts/queue.d.mts +208 -44
- package/dist/contracts/queue.mjs +5 -5
- package/dist/contracts/refs.d.mts +5 -5
- package/dist/contracts/refs.mjs +1 -1
- package/dist/contracts/remote.d.mts +3 -6
- package/dist/contracts/repos.d.mts +3 -3
- package/dist/contracts/repos.mjs +1 -1
- package/dist/contracts/result.d.mts +10 -7
- package/dist/contracts/result.mjs +8 -3
- package/dist/contracts/rules.d.mts +2 -2
- package/dist/contracts/server.d.mts +8 -10
- package/dist/contracts/services.d.mts +6 -9
- package/dist/contracts/services.mjs +1 -2
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/store.d.mts +2 -2
- package/dist/contracts/sync.d.mts +63 -6
- package/dist/contracts/sync.mjs +3 -2
- package/dist/contracts/tags.d.mts +3 -3
- package/dist/contracts/tags.mjs +1 -1
- package/dist/contracts/tokens.d.mts +2 -2
- package/dist/contracts/tokens.mjs +1 -1
- package/dist/contracts/topics.d.mts +9 -9
- package/dist/contracts/trees.d.mts +4 -4
- package/dist/contracts/trees.mjs +1 -1
- package/dist/contracts/work.d.mts +4 -4
- package/dist/contracts/work.mjs +2 -2
- package/dist/core/access.d.mts +1 -1
- package/dist/core/ancestry.mjs +30 -34
- package/dist/core/{promise.mjs → call-groups.mjs} +7 -30
- package/dist/core/call-services.mjs +1 -1
- package/dist/core/events/deliver.d.mts +2 -2
- package/dist/core/events/deliver.mjs +3 -3
- package/dist/core/events/retired.mjs +1 -1
- package/dist/core/forks.mjs +5 -5
- package/dist/core/hooks/groups.mjs +2 -2
- package/dist/core/imports.mjs +101 -21
- package/dist/core/index-job.mjs +14 -9
- package/dist/core/index-lost.d.mts +1 -1
- package/dist/core/loose-tally.mjs +38 -15
- package/dist/core/merge-parts.d.mts +17 -4
- package/dist/core/merge-parts.mjs +7 -2
- package/dist/core/mirror-rows.mjs +31 -1
- package/dist/core/objects/blobs.mjs +8 -10
- package/dist/core/objects/files.mjs +20 -17
- package/dist/core/objects/objects-layer.mjs +1 -1
- package/dist/core/objects/peel.mjs +1 -7
- package/dist/core/objects/reading.mjs +19 -18
- package/dist/core/objects/tree-edits.mjs +1 -1
- package/dist/core/objects/trees.mjs +257 -58
- package/dist/core/objects/writing.mjs +3 -9
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +8 -1
- package/dist/core/parts.mjs +8 -4
- package/dist/core/purge.mjs +31 -18
- package/dist/core/push.d.mts +2 -2
- package/dist/core/push.mjs +125 -94
- package/dist/core/receipts.d.mts +2 -2
- package/dist/core/receipts.mjs +9 -2
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +74 -31
- package/dist/core/refs.mjs +3 -3
- package/dist/core/repack.mjs +25 -30
- package/dist/core/repo-info.mjs +1 -1
- package/dist/core/repos.mjs +1 -1
- package/dist/core/rules/changes.mjs +18 -40
- package/dist/core/rules/check.mjs +6 -5
- package/dist/core/rules/commit-changes.mjs +3 -15
- package/dist/core/rules/context.d.mts +3 -3
- package/dist/core/rules/context.mjs +18 -14
- package/dist/core/rules/fetch.mjs +1 -1
- package/dist/core/rules/protect.mjs +30 -17
- package/dist/core/saved-caller-views.d.mts +1 -1
- package/dist/core/saved-caller-views.mjs +3 -3
- package/dist/core/saved-callers.d.mts +1 -1
- package/dist/core/saved-callers.mjs +1 -1
- package/dist/core/seam.d.mts +1 -2
- package/dist/core/view.d.mts +6 -3
- package/dist/core/view.mjs +11 -10
- package/dist/core/work.mjs +2 -2
- package/dist/engine/allotted-xdiff.mjs +3 -16
- package/dist/engine/combined.d.mts +3 -0
- package/dist/engine/combined.mjs +200 -185
- package/dist/engine/content.d.mts +2 -2
- package/dist/engine/content.mjs +1 -1
- package/dist/engine/merge.mjs +7 -9
- package/dist/engine/reads.d.mts +2 -2
- package/dist/engine/reads.mjs +22 -14
- package/dist/engine/xdiff.d.mts +1 -1
- package/dist/engine/xdiff.mjs +1 -1
- package/dist/event-streams/event-streams.d.mts +1 -1
- package/dist/event-streams/event-streams.mjs +1 -1
- package/dist/event-streams/stream.d.mts +2 -2
- package/dist/event-streams/stream.mjs +3 -3
- package/dist/extend.d.mts +2 -6
- package/dist/extend.mjs +1 -5
- package/dist/http/core-parts.mjs +83 -26
- package/dist/http/handler.mjs +54 -9
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +138 -24
- package/dist/http/push-uploads.mjs +2 -2
- package/dist/http/receive-pack.mjs +14 -53
- package/dist/http/request-snapshot.mjs +258 -0
- package/dist/http/upload-pack.mjs +23 -18
- package/dist/index.d.mts +29 -21
- package/dist/index.mjs +11 -2
- package/dist/lfs/base.d.mts +1 -1
- package/dist/lfs/copy.d.mts +49 -1
- package/dist/lfs/copy.mjs +135 -22
- package/dist/lfs/layer.d.mts +4 -3
- package/dist/lfs/layer.mjs +4 -5
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +1 -1
- package/dist/lfs/objects.mjs +3 -3
- package/dist/lfs/pointers.mjs +1 -1
- package/dist/lfs/rows.d.mts +1 -1
- package/dist/lfs/rows.mjs +11 -4
- package/dist/lfs/upkeep.mjs +40 -9
- package/dist/lfs/uploaded.mjs +1 -1
- package/dist/lfs/wire.mjs +1 -1
- package/dist/merges/merges.mjs +17 -2
- package/dist/protocol/bytes/buffers.d.mts +1 -1
- package/dist/protocol/bytes/buffers.mjs +1 -1
- package/dist/protocol/bytes/deflate.d.mts +1 -1
- package/dist/protocol/bytes/deflate.mjs +1 -1
- package/dist/protocol/bytes/inflate.d.mts +1 -1
- package/dist/protocol/bytes/inflate.mjs +1 -1
- package/dist/protocol/bytes/sha1.d.mts +1 -1
- package/dist/protocol/bytes/sha1.mjs +1 -1
- package/dist/protocol/diff/read.d.mts +2 -1
- package/dist/protocol/diff/read.mjs +102 -8
- package/dist/protocol/packs/graph.mjs +1 -1
- package/dist/protocol/packs/idx.d.mts +1 -1
- package/dist/protocol/packs/idx.mjs +1 -1
- package/dist/protocol/packs/parts.mjs +1 -1
- package/dist/protocol/packs/reader.d.mts +1 -1
- package/dist/protocol/packs/reader.mjs +1 -1
- package/dist/protocol/packs/write-error.d.mts +1 -1
- package/dist/protocol/packs/write-error.mjs +1 -1
- package/dist/protocol/packs/writer.mjs +3 -3
- package/dist/protocol/wire/advertisement.d.mts +1 -1
- package/dist/protocol/wire/advertisement.mjs +3 -2
- package/dist/protocol/wire/fetch.d.mts +1 -1
- package/dist/protocol/wire/fetch.mjs +1 -1
- package/dist/protocol/wire/lines.d.mts +9 -1
- package/dist/protocol/wire/lines.mjs +28 -1
- package/dist/protocol/wire/push-uploads.mjs +10 -7
- package/dist/protocol/wire/receive-pack.d.mts +1 -1
- package/dist/protocol/wire/receive-pack.mjs +1 -1
- package/dist/protocol/wire/report-status.d.mts +1 -1
- package/dist/protocol/wire/report-status.mjs +1 -1
- package/dist/protocol/wire/v2.d.mts +1 -1
- package/dist/protocol/wire/v2.mjs +1 -1
- package/dist/queue/advance.mjs +31 -24
- package/dist/queue/base.d.mts +5 -3
- package/dist/queue/calls.mjs +5 -5
- package/dist/queue/commit.mjs +1 -1
- package/dist/queue/host.d.mts +1 -1
- package/dist/queue/layer.d.mts +0 -1
- package/dist/queue/layer.mjs +9 -5
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/search.mjs +1 -1
- package/dist/queue/state.mjs +1 -1
- package/dist/queue/trim.mjs +2 -2
- package/dist/rest/client.d.mts +1 -1
- package/dist/rest/client.mjs +6 -6
- package/dist/rest/errors.mjs +1 -1
- package/dist/rest/handler.mjs +2 -2
- package/dist/rest/handlers.mjs +16 -6
- package/dist/rest/layer.mjs +1 -1
- package/dist/rest/listen.mjs +2 -2
- package/dist/rest/refs.mjs +1 -1
- package/dist/server/edge.mjs +27 -3
- package/dist/server/git-layer.d.mts +1 -2
- package/dist/server/git-layer.mjs +4 -5
- package/dist/server/lifecycle.mjs +1 -1
- package/dist/server/registry.mjs +2 -8
- package/dist/server/server.mjs +62 -43
- package/dist/signin/context.d.mts +1 -1
- package/dist/signin/context.mjs +1 -1
- package/dist/signin/forms.mjs +1 -1
- package/dist/signin/grants.d.mts +2 -2
- package/dist/signin/grants.mjs +1 -1
- package/dist/signin/wire.mjs +1 -1
- package/dist/storage/allotted.mjs +4 -9
- package/dist/storage/batch-upkeep.mjs +31 -12
- package/dist/storage/batches.d.mts +2 -3
- package/dist/storage/batches.mjs +52 -49
- package/dist/storage/budget.mjs +23 -1
- package/dist/storage/calls.d.mts +1 -1
- package/dist/storage/calls.mjs +41 -43
- package/dist/storage/charged-cache.mjs +180 -0
- package/dist/storage/chunks.d.mts +3 -3
- package/dist/storage/chunks.mjs +121 -8
- package/dist/storage/counted-bucket.mjs +32 -10
- package/dist/storage/fetch-row-cache.d.mts +6 -0
- package/dist/storage/fetch-row-cache.mjs +211 -0
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +54 -242
- package/dist/storage/held-types.d.mts +0 -1
- package/dist/storage/host-bucket.mjs +9 -4
- package/dist/storage/index-bitmaps.mjs +77 -49
- package/dist/storage/index-build.d.mts +2 -3
- package/dist/storage/index-build.mjs +248 -48
- package/dist/storage/index-fetch.d.mts +3 -1
- package/dist/storage/index-fetch.mjs +60 -21
- package/dist/storage/index-graph.mjs +1 -1
- package/dist/storage/index-layers.mjs +55 -25
- package/dist/storage/index-reach.mjs +15 -22
- package/dist/storage/index-whole.d.mts +7 -0
- package/dist/storage/index-whole.mjs +145 -37
- package/dist/storage/largest-files.mjs +1 -7
- package/dist/storage/layout.mjs +17 -1
- package/dist/storage/lfs-pointers.mjs +1 -6
- package/dist/storage/link-join.mjs +55 -16
- package/dist/storage/list-source.d.mts +7 -0
- package/dist/storage/list-source.mjs +288 -0
- package/dist/storage/loose.d.mts +8 -8
- package/dist/storage/loose.mjs +157 -91
- package/dist/storage/memory-budget.mjs +226 -22
- package/dist/storage/merge-cut.mjs +9 -6
- package/dist/storage/merge-fence.mjs +1 -1
- package/dist/storage/merge-row.mjs +1 -1
- package/dist/storage/merge.d.mts +2 -3
- package/dist/storage/merge.mjs +2 -2
- package/dist/storage/object-rows.d.mts +3 -3
- package/dist/storage/object-rows.mjs +179 -38
- package/dist/storage/pack-order.mjs +97 -44
- package/dist/storage/pack-ranges.mjs +44 -16
- package/dist/storage/pack-reads.d.mts +5 -3
- package/dist/storage/pack-reads.mjs +236 -72
- package/dist/storage/pack-receive.d.mts +1 -2
- package/dist/storage/pack-receive.mjs +21 -17
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +477 -116
- package/dist/storage/placed-reads.mjs +33 -16
- package/dist/storage/prune-seen.mjs +1 -1
- package/dist/storage/prune-walk.mjs +1 -1
- package/dist/storage/prune.mjs +4 -31
- package/dist/storage/push-allotment.mjs +26 -14
- package/dist/storage/push-uploads.mjs +195 -57
- package/dist/storage/pushed-commits.mjs +20 -1
- package/dist/storage/quarantine.d.mts +2 -3
- package/dist/storage/range-cache.mjs +175 -40
- package/dist/storage/raw-ids.mjs +39 -10
- package/dist/storage/ready.d.mts +2 -3
- package/dist/storage/ready.mjs +114 -38
- package/dist/storage/receive-bounds.mjs +31 -9
- package/dist/storage/receive-cache.d.mts +7 -0
- package/dist/storage/receive-cache.mjs +147 -0
- package/dist/storage/receive-files.mjs +1 -1
- package/dist/storage/receive-links.mjs +1 -1
- package/dist/storage/receive-state.d.mts +2 -2
- package/dist/storage/receive-state.mjs +6 -8
- package/dist/storage/receive-steps.d.mts +20 -0
- package/dist/storage/receive-steps.mjs +298 -13
- package/dist/storage/repack-backlog.mjs +1 -6
- package/dist/storage/repack-contained.mjs +2 -2
- package/dist/storage/repack-job.mjs +1 -1
- package/dist/storage/repack.d.mts +2 -3
- package/dist/storage/repack.mjs +54 -9
- package/dist/storage/request-cache.mjs +57 -0
- package/dist/storage/roots.mjs +1 -24
- package/dist/storage/rows.d.mts +2 -2
- package/dist/storage/rows.mjs +1 -1
- package/dist/storage/runs.d.mts +2 -2
- package/dist/storage/runs.mjs +1 -1
- package/dist/storage/send-list.mjs +62 -25
- package/dist/storage/stream-whole.mjs +84 -63
- package/dist/storage/swap-walk.mjs +1 -1
- package/dist/storage/unpack.mjs +878 -450
- package/dist/storage/visible.mjs +110 -32
- package/dist/storage/walk.mjs +1 -0
- package/dist/storage/wants.mjs +22 -58
- package/dist/store/call-count.d.mts +2 -2
- package/dist/store/call-count.mjs +24 -11
- package/dist/store/catalogue.d.mts +1 -1
- package/dist/store/catalogue.mjs +19 -7
- package/dist/store/crossing.mjs +1 -7
- package/dist/store/cursor-seal.d.mts +1 -1
- package/dist/store/cursor-seal.mjs +1 -1
- package/dist/store/door.mjs +9 -4
- package/dist/store/errors.d.mts +2 -2
- package/dist/store/errors.mjs +107 -19
- package/dist/store/git-store.mjs +7 -2
- package/dist/store/job-try.mjs +90 -9
- package/dist/store/list-job.mjs +10 -34
- package/dist/store/outbox.d.mts +2 -2
- package/dist/store/outbox.mjs +2 -2
- package/dist/store/queue-jobs.mjs +6 -12
- package/dist/store/records.d.mts +2 -2
- package/dist/store/records.mjs +2 -2
- package/dist/store/ref-rows.d.mts +2 -2
- package/dist/store/ref-rows.mjs +2 -2
- package/dist/store/repo-record.d.mts +2 -2
- package/dist/store/repo-record.mjs +3 -3
- package/dist/store/request-snapshot.mjs +5 -0
- package/dist/store/reservations.mjs +2 -2
- package/dist/store/topic-jobs.mjs +5 -11
- package/dist/sync/bound.d.mts +3 -3
- package/dist/sync/bound.mjs +10 -7
- package/dist/sync/github.mjs +65 -67
- package/dist/sync/http.mjs +1 -1
- package/dist/sync/import.mjs +201 -66
- package/dist/sync/layer.d.mts +1 -1
- package/dist/sync/layer.mjs +6 -6
- package/dist/sync/lfs-batch.mjs +1 -1
- package/dist/sync/lfs-copy.mjs +175 -15
- package/dist/sync/mirror.mjs +5 -10
- package/dist/sync/said.mjs +1 -1
- package/dist/sync/step.mjs +268 -86
- package/dist/sync/tries.mjs +25 -6
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +2 -2
- package/dist/topics/advance.mjs +3 -3
- package/dist/topics/calls.mjs +1 -1
- package/dist/topics/layer.d.mts +15 -14
- package/dist/topics/members.mjs +1 -1
- package/dist/topics/topic.mjs +1 -1
- package/package.json +3 -13
- package/dist/auth/helpers.mjs +0 -17
- package/dist/auth.d.mts +0 -5
- package/dist/auth.mjs +0 -5
- package/dist/core/rules/commit-changes.d.mts +0 -12
- package/dist/effect.d.mts +0 -9
- package/dist/effect.mjs +0 -7
- package/dist/server/joined.d.mts +0 -70
- package/dist/server/joined.mjs +0 -41
package/dist/sync/step.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "../contracts/ids.mjs";
|
|
2
|
+
import { objectsReadMost } from "../contracts/object-values.mjs";
|
|
2
3
|
import { gitError, gitErrorFrom } from "../contracts/result.mjs";
|
|
3
4
|
import { partialImporter } from "./import.mjs";
|
|
4
5
|
import { importedPullRefs } from "../contracts/sync.mjs";
|
|
@@ -6,9 +7,10 @@ import { push } from "../core/push.mjs";
|
|
|
6
7
|
import { refusedLead } from "../client/answer.mjs";
|
|
7
8
|
import { isRefName } from "../core/names.mjs";
|
|
8
9
|
import { cutWords, utf8 } from "../protocol/bytes/text.mjs";
|
|
10
|
+
import { readCommit } from "../protocol/objects/commit.mjs";
|
|
9
11
|
import { negotiate } from "../client/negotiate.mjs";
|
|
10
12
|
import { discover, fetchTerms, remoteRefsAndHeadOf } from "../client/remote.mjs";
|
|
11
|
-
import { oneShotReads, scopedReceiveStep } from "../storage/calls.mjs";
|
|
13
|
+
import { heldOnce, oneShotReads, scopedReader, scopedReceiveStep } from "../storage/calls.mjs";
|
|
12
14
|
import { isPackId } from "../storage/layout.mjs";
|
|
13
15
|
import { receiveCutParentsMost } from "../storage/receive-bounds.mjs";
|
|
14
16
|
import { ReceiveRow, receiveKey, stagedRow } from "../storage/receive-steps.mjs";
|
|
@@ -21,18 +23,19 @@ import { listJobRow } from "../store/list-job.mjs";
|
|
|
21
23
|
import { StoredRepo } from "../store/records.mjs";
|
|
22
24
|
import { newChangeId, repoScope, selfKey } from "../store/scopes.mjs";
|
|
23
25
|
import { asSync } from "./bound.mjs";
|
|
24
|
-
import { copyLfs, withLfsPages } from "./lfs-copy.mjs";
|
|
25
|
-
import { ImportRow, cancelKey, cutKey, cutRow, failedHint, failedRow, importEndDeletes, importKey, importRow, readImport, readTipPages, stoppedTry, tipPageKey, tipPageRow, tipPagesOf, tipRowBytes } from "../core/imports.mjs";
|
|
26
|
-
import {
|
|
26
|
+
import { copyLfs, leftUpload, withLfsPages } from "./lfs-copy.mjs";
|
|
27
|
+
import { ImportRow, cancelKey, cutKey, cutRow, deepenReceiptPut, failedHint, failedRow, importEndDeletes, importKey, importRow, readImport, readTipPages, startRootsKey, startRootsOf, stoppedDeepen, stoppedTry, tipPageKey, tipPageRow, tipPagesOf, tipRowBytes } from "../core/imports.mjs";
|
|
28
|
+
import { infoReads, repoInfo } from "../core/repo-info.mjs";
|
|
29
|
+
import { ForGood, SyncTryError, forGood, fromRemote, httpOf, keptFieldsOf, openedFor, remoteOf, syncObjects, thrownOf, tooManyRoots, tried } from "./tries.mjs";
|
|
27
30
|
import { currentRepo } from "../store/job-try.mjs";
|
|
28
31
|
import { CoreParts, ObjectsParts } from "../core/parts.mjs";
|
|
29
32
|
import { importOwner } from "../protocol/wire/lines.mjs";
|
|
30
33
|
import { repoAccess } from "../core/access.mjs";
|
|
31
34
|
import { viewAgainOf } from "../core/saved-caller-views.mjs";
|
|
32
|
-
import
|
|
35
|
+
import { CurrentJob } from "@ref0/infra";
|
|
33
36
|
import * as Schema from "effect/Schema";
|
|
37
|
+
import * as Effect from "effect/Effect";
|
|
34
38
|
import * as Result from "effect/Result";
|
|
35
|
-
import { CurrentJob } from "@ref0/infra";
|
|
36
39
|
// src/sync/step.ts
|
|
37
40
|
/**
|
|
38
41
|
* One try of `sync.import`: one step of the import, committed with its record, so a try after
|
|
@@ -57,7 +60,7 @@ import { CurrentJob } from "@ref0/infra";
|
|
|
57
60
|
*/
|
|
58
61
|
/** The deepest a segment's step grows: past it, a segment's history is whole anyway. */
|
|
59
62
|
const stepMost = 1 << 20;
|
|
60
|
-
const noDeepen = () => gitError("FAILED_PRECONDITION", "The remote doesn't take a shallow fetch, so no import of it stops at a depth", { hint: "Import it again without a depth" });
|
|
63
|
+
const noDeepen = (relative = false) => gitError("FAILED_PRECONDITION", relative ? "The remote doesn't take a relative deepen" : "The remote doesn't take a shallow fetch, so no import of it stops at a depth", { hint: relative ? "Pass 'unshallow: true' to fetch the rest of the history" : "Import it again without a depth" });
|
|
61
64
|
const tooManyTips = (limits, bytes) => gitError("RESOURCE_EXHAUSTED", `The remote's branches and tags take ${bytes} bytes as refs`, {
|
|
62
65
|
hint: `An import takes branches and tags of at most ${limits.tipBytes} bytes together, as a repo's refs count them`,
|
|
63
66
|
context: {
|
|
@@ -203,35 +206,34 @@ const saved = (attempt, version, row, deletes = [], puts = []) => Effect.flatMap
|
|
|
203
206
|
})));
|
|
204
207
|
const more = { kind: "more" };
|
|
205
208
|
const endedUnder = () => gitError("FAILED_PRECONDITION", "The import ended while its step ran", { hint: "Its record is no longer running, so the step writes nothing" });
|
|
206
|
-
/** The import's record as a guard's read finds it, failing `endedUnder` unless
|
|
207
|
-
const runningIn = /* @__PURE__ */ Effect.fnUntraced(function* (rows) {
|
|
209
|
+
/** The import's record as a guard's read finds it, failing `endedUnder` unless running for `run`. */
|
|
210
|
+
const runningIn = /* @__PURE__ */ Effect.fnUntraced(function* (rows, run) {
|
|
208
211
|
const [own] = rows ?? [];
|
|
209
212
|
const row = own === void 0 ? void 0 : yield* decodeRow(ImportRow, own, "Import");
|
|
210
|
-
if (row?.state !== "running") return yield* Effect.fail(endedUnder());
|
|
213
|
+
if (row?.state !== "running" || row.deepen?.run !== run) return yield* Effect.fail(endedUnder());
|
|
211
214
|
return row;
|
|
212
215
|
});
|
|
213
216
|
/**
|
|
214
|
-
* A step's push guard: the import's record still `running` in the push's own read, so a
|
|
215
|
-
* import another write ended
|
|
217
|
+
* A step's push guard: the import's record still `running` for `run` in the push's own read, so a
|
|
218
|
+
* step whose import another write ended or superseded writes nothing.
|
|
216
219
|
*/
|
|
217
|
-
const stillRunning = {
|
|
220
|
+
const stillRunning = (run) => ({
|
|
218
221
|
reads: [importKey],
|
|
219
|
-
check: (results) => Effect.asVoid(runningIn(results[0]))
|
|
220
|
-
};
|
|
222
|
+
check: (results) => Effect.asVoid(runningIn(results[0], run))
|
|
223
|
+
});
|
|
221
224
|
const cancelledUnder = () => gitError("FAILED_PRECONDITION", "The import was cancelled while it published", { hint: "It moves no more refs, and answers as cancelled" });
|
|
222
225
|
const pageMovedUnder = () => gitError("UNAVAILABLE", "Another try moved the import's publish past this page first", { hint: "The job tries again, from the page its record names then" });
|
|
223
226
|
/**
|
|
224
|
-
* Publish's push guard for `page`: `stillRunning`, the record's
|
|
225
|
-
* cancel saved beside the record. So a try that read the record
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
* stay readable, as `CancelImport` says.
|
|
227
|
+
* Publish's push guard for `page` and optional deepen `run`: `stillRunning(run)`, the record's
|
|
228
|
+
* cursor still at `page`, and no cancel saved beside the record. So a try that read the record
|
|
229
|
+
* before another's page landed or another deepen replaced it never overwrites the newer run, and a
|
|
230
|
+
* cancel saved since moves no more refs. A landing keeps `stillRunning(run)` alone: a segment in
|
|
231
|
+
* flight as a cancel commits still lands, and its objects stay readable, as `CancelImport` says.
|
|
230
232
|
*/
|
|
231
|
-
const uncancelled = (page) => ({
|
|
232
|
-
reads: [
|
|
233
|
+
const uncancelled = (page, run) => ({
|
|
234
|
+
reads: [importKey, cancelKey],
|
|
233
235
|
check: /* @__PURE__ */ Effect.fnUntraced(function* (results) {
|
|
234
|
-
if (((yield* runningIn(results[0])).publishedPages ?? 0) !== page) return yield* Effect.fail(pageMovedUnder());
|
|
236
|
+
if (((yield* runningIn(results[0], run)).publishedPages ?? 0) !== page) return yield* Effect.fail(pageMovedUnder());
|
|
235
237
|
const [cancel] = results[1] ?? [];
|
|
236
238
|
if (cancel !== void 0) return yield* Effect.fail(cancelledUnder());
|
|
237
239
|
})
|
|
@@ -265,10 +267,61 @@ const pullTips = (refs, own, limits) => {
|
|
|
265
267
|
}
|
|
266
268
|
return kept;
|
|
267
269
|
};
|
|
270
|
+
/** Which of `oids` are already held in `listed`, checked in batches of `objectsReadMost`. */
|
|
271
|
+
const heldBatched = /* @__PURE__ */ Effect.fnUntraced(function* (objects, listed, oids) {
|
|
272
|
+
const held = /* @__PURE__ */ new Set();
|
|
273
|
+
for (let at = 0; at < oids.length; at += objectsReadMost) {
|
|
274
|
+
const found = yield* heldOnce(objects, listed, { oids: oids.slice(at, at + objectsReadMost) });
|
|
275
|
+
for (const oid of found) held.add(oid);
|
|
276
|
+
}
|
|
277
|
+
return held;
|
|
278
|
+
});
|
|
279
|
+
/** Bytes held at once while reading stored shallow-root commits to seed a deepen's cut. */
|
|
280
|
+
const rootReadBytes = 4194304;
|
|
281
|
+
/**
|
|
282
|
+
* The initial cut for a deepen: every stored parent of every shallow root in `roots`, read from
|
|
283
|
+
* the commits' raw stored bytes within an allotment so storage's `needs` check requires every
|
|
284
|
+
* parent of every unshallowed root before any segment lands or any root moves.
|
|
285
|
+
*/
|
|
286
|
+
const cutOfRoots = (objects, listed, roots) => Effect.scoped(Effect.gen(function* () {
|
|
287
|
+
const tooLarge = gitError("RESOURCE_EXHAUSTED", "Shallow root too large", { context: { reason: "too-large" } });
|
|
288
|
+
const reader = yield* scopedReader(objects, listed);
|
|
289
|
+
const bytes = reader.allotment(rootReadBytes, tooLarge);
|
|
290
|
+
const cut = {};
|
|
291
|
+
let total = 0;
|
|
292
|
+
const queue = [...roots];
|
|
293
|
+
while (queue.length > 0) {
|
|
294
|
+
const batch = queue.splice(0, objectsReadMost);
|
|
295
|
+
const read = yield* reader.objects({
|
|
296
|
+
oids: batch,
|
|
297
|
+
bytes
|
|
298
|
+
});
|
|
299
|
+
const leftSet = new Set(read.left);
|
|
300
|
+
for (const oid of batch) {
|
|
301
|
+
if (leftSet.has(oid)) continue;
|
|
302
|
+
const object = read.objects.get(oid);
|
|
303
|
+
if (object !== void 0) bytes.shrink(object.bytes.byteLength);
|
|
304
|
+
const commit = object?.type === "commit" ? readCommit(object.bytes) : void 0;
|
|
305
|
+
if (commit === void 0 || Result.isFailure(commit)) return yield* forGood(gitError("DATA_LOSS", `Shallow root ${oid} unreadable`));
|
|
306
|
+
const { parents } = commit.success;
|
|
307
|
+
if (parents.length === 0) continue;
|
|
308
|
+
total += parents.length;
|
|
309
|
+
if (total > receiveCutParentsMost) return yield* forGood(gitError("RESOURCE_EXHAUSTED", `Over ${receiveCutParentsMost} shallow root parents`, { context: {
|
|
310
|
+
reason: "too-large",
|
|
311
|
+
limit: receiveCutParentsMost
|
|
312
|
+
} }));
|
|
313
|
+
cut[oid] = parents;
|
|
314
|
+
}
|
|
315
|
+
if (read.left.length >= batch.length) return yield* forGood(tooLarge);
|
|
316
|
+
queue.unshift(...read.left);
|
|
317
|
+
}
|
|
318
|
+
return cut;
|
|
319
|
+
}));
|
|
268
320
|
/**
|
|
269
321
|
* Step 1: the remote's branches and tags, and their tips, kept in pages beside the import's
|
|
270
322
|
* record, with the pull requests' heads that fit beside them, in the commit that moves the record
|
|
271
|
-
* past the listing.
|
|
323
|
+
* past the listing. For a deepen, also seeds `imports/cut` from the repo's stored shallow roots
|
|
324
|
+
* and adopts no default branch.
|
|
272
325
|
*/
|
|
273
326
|
const listTips = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, version, row, remote) {
|
|
274
327
|
yield* report(attempt.context, "fetch", row);
|
|
@@ -286,7 +339,7 @@ const listTips = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, version,
|
|
|
286
339
|
const { limits } = attempt.bound;
|
|
287
340
|
if (own > limits.tipBytes) return yield* forGood(tooManyTips(limits, own));
|
|
288
341
|
const all = [...refs, ...pullTips(listing, own, limits)];
|
|
289
|
-
const adopts = head?.startsWith("refs/heads/") === true && refs.has(head) ? head : void 0;
|
|
342
|
+
const adopts = row.deepen === void 0 && head?.startsWith("refs/heads/") === true && refs.has(head) ? head : void 0;
|
|
290
343
|
const pages = tipPagesOf(all.sort(([a], [b]) => a < b ? -1 : 1), adopts, {
|
|
291
344
|
bytes: limits.tipPageBytes,
|
|
292
345
|
most: limits.publishBatch
|
|
@@ -295,10 +348,17 @@ const listTips = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, version,
|
|
|
295
348
|
...row,
|
|
296
349
|
tipPages: pages.length,
|
|
297
350
|
publishedPages: 0,
|
|
298
|
-
copied: all.length === 0
|
|
351
|
+
copied: row.deepen === void 0 && all.length === 0
|
|
299
352
|
};
|
|
300
353
|
if (adopts !== void 0) listedRow.head = adopts;
|
|
301
|
-
|
|
354
|
+
const puts = pages.map((tips, page) => tipPageRow(page, tips));
|
|
355
|
+
if (row.deepen !== void 0) {
|
|
356
|
+
const opened = yield* openedRepo(attempt);
|
|
357
|
+
if (opened === void 0) return void 0;
|
|
358
|
+
const initialCut = yield* cutOfRoots(syncObjects(yield* ObjectsParts), opened.listed, row.roots);
|
|
359
|
+
if (Object.keys(initialCut).length > 0) puts.push(cutRow(row.roots, initialCut));
|
|
360
|
+
}
|
|
361
|
+
yield* saved(attempt, version, listedRow, [], puts);
|
|
302
362
|
return more;
|
|
303
363
|
});
|
|
304
364
|
/**
|
|
@@ -306,6 +366,20 @@ const listTips = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, version,
|
|
|
306
366
|
* check's refusal answers no: a defect in it stays a defect.
|
|
307
367
|
*/
|
|
308
368
|
const deepens = (upload) => Effect.isSuccess(fetchTerms(upload, { depth: 1 }));
|
|
369
|
+
/** Most unreachable shallow root OIDs named verbatim in `unreachableRoots`' error message. */
|
|
370
|
+
const unreachableRootsMost = 8;
|
|
371
|
+
/** Typed refusal when the remote cannot serve history behind one or more hosted shallow roots. */
|
|
372
|
+
const unreachableRoots = (roots) => {
|
|
373
|
+
const shown = roots.slice(0, unreachableRootsMost).join(", ");
|
|
374
|
+
const rest = roots.length > unreachableRootsMost ? ` (+${roots.length - unreachableRootsMost} more)` : "";
|
|
375
|
+
return gitError("FAILED_PRECONDITION", `Remote cannot serve shallow root(s): ${shown}${rest}`, {
|
|
376
|
+
hint: "Pass a source with these commits",
|
|
377
|
+
context: {
|
|
378
|
+
reason: "shallow-roots-unreachable",
|
|
379
|
+
total: roots.length
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
};
|
|
309
383
|
/** The pack as it arrives, counted, and stopped once it runs past `most` bytes. */
|
|
310
384
|
const counted = (bytes, most) => {
|
|
311
385
|
const seen = {
|
|
@@ -394,44 +468,113 @@ const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row,
|
|
|
394
468
|
const { http, heard } = yield* httpOf(remote, keptFieldsOf(bound, row.source));
|
|
395
469
|
const upload = yield* Effect.mapError(discover(http), advertisedFrom(remote, "advertise its refs", heard));
|
|
396
470
|
const shallow = yield* deepens(upload);
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
const
|
|
400
|
-
const
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
const terms = yield* fetchTerms(upload, shallow ? { depth: wanted } : {});
|
|
407
|
-
const negotiated = yield* negotiate({
|
|
471
|
+
const deepening = row.deepen;
|
|
472
|
+
if (!shallow && (deepening === void 0 ? row.depth !== void 0 : deepening.more !== void 0)) return yield* forGood(noDeepen());
|
|
473
|
+
const relative = deepening !== void 0 && shallow && (yield* Effect.isSuccess(fetchTerms(upload, { deepen: 1 }, true)));
|
|
474
|
+
const rootsWithParents = deepening === void 0 ? [] : row.roots.filter((oid) => (cut[oid]?.length ?? 0) > 0);
|
|
475
|
+
const missingParents = [...new Set(rootsWithParents.flatMap((oid) => cut[oid] ?? []))];
|
|
476
|
+
const tipSet = new Set(tips);
|
|
477
|
+
const canWantParents = missingParents.length > 0 && (upload.version === "v2" || upload.capabilities.includes("allow-tip-sha1-in-want") || upload.capabilities.includes("allow-reachable-sha1-in-want") || missingParents.every((oid) => tipSet.has(oid)));
|
|
478
|
+
const deepenStep = deepening?.more === void 0 ? row.step : Math.min(row.step, deepening.more - row.deepest);
|
|
479
|
+
const runNegotiate = (req, reqTerms, useHeld) => negotiate({
|
|
408
480
|
http,
|
|
409
481
|
version: upload.version,
|
|
410
|
-
...
|
|
482
|
+
...reqTerms,
|
|
411
483
|
ofsDelta: false,
|
|
412
|
-
request,
|
|
484
|
+
request: req,
|
|
413
485
|
objects: oneShotReads(objects),
|
|
414
486
|
listed: opened.listed,
|
|
415
|
-
tips: [...new Set(opened.refs.values())],
|
|
416
|
-
held: row.deepest > 0 ? tips : []
|
|
417
|
-
})
|
|
487
|
+
tips: !useHeld ? [] : deepening === void 0 ? [...new Set(opened.refs.values())] : shallow ? [.../* @__PURE__ */ new Set([...opened.refs.values(), ...row.roots])] : [],
|
|
488
|
+
held: useHeld && row.deepest > 0 && shallow ? tips : []
|
|
489
|
+
});
|
|
490
|
+
let negotiated;
|
|
491
|
+
let nextDeepest = infiniteDepth;
|
|
492
|
+
let reachedTarget = true;
|
|
493
|
+
let canHalve = false;
|
|
494
|
+
let parentAnchored = false;
|
|
495
|
+
if (deepening?.more !== void 0 && !relative && tips.length > 0 && !canWantParents) return yield* forGood(noDeepen(true));
|
|
496
|
+
const negotiateError = fromRemote("negotiate a fetch", heard);
|
|
497
|
+
if (deepening === void 0 || tips.length > 0 && (relative || deepening.more === void 0)) {
|
|
498
|
+
const request = {
|
|
499
|
+
wants: tips,
|
|
500
|
+
shallows: shallow ? [...row.roots] : [],
|
|
501
|
+
includeTag: false
|
|
502
|
+
};
|
|
503
|
+
let terms;
|
|
504
|
+
if (deepening === void 0) {
|
|
505
|
+
const asked = row.depth ?? 2147483647;
|
|
506
|
+
const wanted = Math.min(row.deepest + row.step, asked);
|
|
507
|
+
if (shallow) request.depth = wanted;
|
|
508
|
+
terms = yield* fetchTerms(upload, shallow ? { depth: wanted } : {});
|
|
509
|
+
nextDeepest = shallow ? wanted : infiniteDepth;
|
|
510
|
+
reachedTarget = wanted >= asked;
|
|
511
|
+
canHalve = shallow;
|
|
512
|
+
} else if (relative) {
|
|
513
|
+
request.depth = deepenStep;
|
|
514
|
+
request.deepenRelative = true;
|
|
515
|
+
terms = yield* fetchTerms(upload, { deepen: deepenStep }, true);
|
|
516
|
+
nextDeepest = row.deepest + deepenStep;
|
|
517
|
+
reachedTarget = deepening.more !== void 0 && nextDeepest >= deepening.more;
|
|
518
|
+
canHalve = true;
|
|
519
|
+
} else {
|
|
520
|
+
if (shallow) request.depth = infiniteDepth;
|
|
521
|
+
terms = yield* fetchTerms(upload, shallow ? { unshallow: true } : {}, shallow);
|
|
522
|
+
}
|
|
523
|
+
negotiated = yield* runNegotiate(request, terms, true).pipe(Effect.mapError(negotiateError));
|
|
524
|
+
}
|
|
525
|
+
if (deepening !== void 0) {
|
|
526
|
+
const unshallowed = new Set(negotiated?.unshallow ?? []);
|
|
527
|
+
const uncovered = rootsWithParents.filter((oid) => !unshallowed.has(oid));
|
|
528
|
+
if (negotiated === void 0 || uncovered.length > 0) {
|
|
529
|
+
negotiated?.pack.cancel();
|
|
530
|
+
const missed = uncovered.length > 0 ? uncovered : row.roots;
|
|
531
|
+
if (!canWantParents) return yield* forGood(unreachableRoots(missed));
|
|
532
|
+
const depth = shallow ? deepenStep : void 0;
|
|
533
|
+
const parentRequest = {
|
|
534
|
+
wants: missingParents,
|
|
535
|
+
shallows: [],
|
|
536
|
+
includeTag: false
|
|
537
|
+
};
|
|
538
|
+
if (depth !== void 0) parentRequest.depth = depth;
|
|
539
|
+
const parentTerms = yield* fetchTerms(upload, depth !== void 0 ? { depth } : {});
|
|
540
|
+
nextDeepest = shallow ? row.deepest + deepenStep : infiniteDepth;
|
|
541
|
+
reachedTarget = !shallow || deepening.more !== void 0 && nextDeepest >= deepening.more;
|
|
542
|
+
canHalve = shallow;
|
|
543
|
+
negotiated = yield* runNegotiate(parentRequest, parentTerms, false).pipe(Effect.catchIf((error) => error.code === "FAILED_PRECONDITION", () => forGood(unreachableRoots(missed))), Effect.mapError((error) => error instanceof ForGood ? error : negotiateError(error)));
|
|
544
|
+
parentAnchored = true;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
if (negotiated === void 0) return yield* forGood(unreachableRoots(row.roots));
|
|
418
548
|
yield* report(context, "receive", row);
|
|
419
549
|
const { pack } = negotiated;
|
|
420
550
|
const { stream, seen } = counted(pack.bytes, most);
|
|
421
|
-
const roots = shallow ? rootsAfter(row.roots,
|
|
551
|
+
const roots = !shallow ? [] : parentAnchored ? rootsAfter(row.roots, {
|
|
552
|
+
shallow: negotiated.shallow,
|
|
553
|
+
unshallow: rootsWithParents
|
|
554
|
+
}) : rootsAfter(row.roots, negotiated);
|
|
422
555
|
if (roots.length > bound.limits.rootsMost) {
|
|
423
556
|
pack.cancel();
|
|
424
|
-
return yield* forGood(
|
|
425
|
-
reason: "too-large",
|
|
426
|
-
limit: bound.limits.rootsMost
|
|
427
|
-
} }));
|
|
557
|
+
return yield* forGood(tooManyRoots(bound.limits.rootsMost));
|
|
428
558
|
}
|
|
429
|
-
const copied = roots.length === 0 ||
|
|
559
|
+
const copied = roots.length === 0 || reachedTarget || deepening === void 0 && row.roots.length > 0 && sameRoots(roots, row.roots);
|
|
430
560
|
const pushedPack = {
|
|
431
561
|
bytes: stream,
|
|
432
562
|
objects: pack.objects
|
|
433
563
|
};
|
|
434
|
-
|
|
564
|
+
const beforeRoots = new Set(row.roots);
|
|
565
|
+
const candidateBoundary = shallow ? negotiated.shallow.filter((oid) => !beforeRoots.has(oid)) : [];
|
|
566
|
+
let boundary = candidateBoundary;
|
|
567
|
+
if (candidateBoundary.length > 0) boundary = yield* Effect.gen(function* () {
|
|
568
|
+
const heldInRepo = yield* heldBatched(objects, opened.listed, candidateBoundary);
|
|
569
|
+
const inRepo = candidateBoundary.filter((oid) => heldInRepo.has(oid));
|
|
570
|
+
if (inRepo.length === 0) return candidateBoundary;
|
|
571
|
+
const parentsByRoot = yield* cutOfRoots(objects, opened.listed, inRepo);
|
|
572
|
+
const allParents = [...new Set(Object.values(parentsByRoot).flat())];
|
|
573
|
+
const heldParents = yield* heldBatched(objects, opened.listed, allParents);
|
|
574
|
+
const complete = new Set(inRepo.filter((oid) => (parentsByRoot[oid] ?? []).every((p) => heldParents.has(p))));
|
|
575
|
+
return candidateBoundary.filter((oid) => !complete.has(oid));
|
|
576
|
+
}).pipe(Effect.onError(() => Effect.sync(() => pack.cancel())));
|
|
577
|
+
if (boundary.length > 0) pushedPack.boundary = boundary;
|
|
435
578
|
const { needs, kept } = carriedCut(row.roots, roots, cut);
|
|
436
579
|
if (needs.length > 0) pushedPack.needs = needs;
|
|
437
580
|
pushedPack.cutMost = kept.reduce((left, [, parents]) => left - parents.length, receiveCutParentsMost);
|
|
@@ -440,7 +583,7 @@ const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row,
|
|
|
440
583
|
const next = () => ({
|
|
441
584
|
...fetched,
|
|
442
585
|
roots,
|
|
443
|
-
deepest:
|
|
586
|
+
deepest: nextDeepest,
|
|
444
587
|
step: stepAfter(row.step, seen.bytes, most),
|
|
445
588
|
copied,
|
|
446
589
|
objects: row.objects + pack.objects,
|
|
@@ -480,7 +623,7 @@ const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row,
|
|
|
480
623
|
jobs: []
|
|
481
624
|
};
|
|
482
625
|
},
|
|
483
|
-
guard: stillRunning,
|
|
626
|
+
guard: stillRunning(row.deepen?.run),
|
|
484
627
|
signal: stopped.signal
|
|
485
628
|
});
|
|
486
629
|
const pushed = yield* Effect.result(sent.pipe(Effect.mapError((error) => {
|
|
@@ -498,7 +641,7 @@ const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row,
|
|
|
498
641
|
if (final !== void 0) return yield* forGood(final);
|
|
499
642
|
const refused = failure.code === "RESOURCE_EXHAUSTED" && halvedReasons.has(failure.context?.reason);
|
|
500
643
|
if (!seen.over && !refused) return yield* Effect.fail(failure);
|
|
501
|
-
if (!
|
|
644
|
+
if (!canHalve || row.step === 1) return yield* forGood(seen.over ? overBudget(most) : leastRefused(failure, canHalve));
|
|
502
645
|
return yield* unstaged(attempt, row, { step: halvedStep(row) }, halvingRaced);
|
|
503
646
|
});
|
|
504
647
|
/** The fields of `row` a segment's landing writes, as its fetch made them. */
|
|
@@ -523,7 +666,7 @@ const staged = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, stagin
|
|
|
523
666
|
if (!isPackId(pack)) return yield* Effect.fail(unsteppedPack(pack));
|
|
524
667
|
const read = yield* readOwn(attempt);
|
|
525
668
|
const now = read.row;
|
|
526
|
-
const same = now?.state === "running" && now.step === row.step && now.deepest === row.deepest;
|
|
669
|
+
const same = now?.state === "running" && now.deepen?.run === row.deepen?.run && now.step === row.step && now.deepest === row.deepest;
|
|
527
670
|
if (read.cancelled || now === void 0 || !same || now.receiving !== void 0) return;
|
|
528
671
|
if (!(yield* saved(attempt, read.version, {
|
|
529
672
|
...now,
|
|
@@ -611,7 +754,7 @@ const resumedIn = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, rec
|
|
|
611
754
|
jobs: []
|
|
612
755
|
};
|
|
613
756
|
},
|
|
614
|
-
guard: stillRunning
|
|
757
|
+
guard: stillRunning(row.deepen?.run)
|
|
615
758
|
});
|
|
616
759
|
return more;
|
|
617
760
|
});
|
|
@@ -642,7 +785,7 @@ const stageGoneAgain = () => gitError("FAILED_PRECONDITION", "Clean-up ended the
|
|
|
642
785
|
const unstaged = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, next, raced) {
|
|
643
786
|
const read = yield* readOwn(attempt);
|
|
644
787
|
const now = read.row;
|
|
645
|
-
const same = now?.state === "running" && now.step === row.step && now.deepest === row.deepest;
|
|
788
|
+
const same = now?.state === "running" && now.deepen?.run === row.deepen?.run && now.step === row.step && now.deepest === row.deepest;
|
|
646
789
|
if (read.cancelled || now === void 0 || !same) return more;
|
|
647
790
|
const { receiving, restaged: _restaged, ...rest } = now;
|
|
648
791
|
const deletes = receiving === void 0 ? [] : [receiveKey(receiving.pack)];
|
|
@@ -687,18 +830,56 @@ const publishGuard = (read, page) => {
|
|
|
687
830
|
};
|
|
688
831
|
};
|
|
689
832
|
/**
|
|
690
|
-
* Step 3:
|
|
691
|
-
*
|
|
692
|
-
*
|
|
693
|
-
*
|
|
694
|
-
* remote's default branch made the repo's when it's one of the tips, which the listing put on that
|
|
695
|
-
* page. A ref another write moved first fails the try, and the next moves the page's refs from
|
|
696
|
-
* where they are then; a refusal of another kind fails it with that ref's own error.
|
|
833
|
+
* Step 3: for a deepen, moves the repo's shallow roots in one atomic write via `rootsMoved`
|
|
834
|
+
* (moving no ref and adopting no default branch), marks the deepen done, and cleans up temporary
|
|
835
|
+
* import keys. For an initial import, moves the next page's refs to their tips, writing the
|
|
836
|
+
* import's roots on the first page and adopting the remote's default branch on the last.
|
|
697
837
|
*/
|
|
698
|
-
const publish = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row) {
|
|
838
|
+
const publish = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, caller) {
|
|
699
839
|
const opened = yield* openedRepo(attempt);
|
|
700
840
|
if (opened === void 0) return void 0;
|
|
701
841
|
const { store } = yield* CoreParts;
|
|
842
|
+
const baseRequest = {
|
|
843
|
+
caller: attempt.bound.caller,
|
|
844
|
+
repo: opened.name,
|
|
845
|
+
internalId: attempt.internalId,
|
|
846
|
+
source: "import",
|
|
847
|
+
as: importOwner,
|
|
848
|
+
atomic: true
|
|
849
|
+
};
|
|
850
|
+
if (row.deepen !== void 0) {
|
|
851
|
+
const { deepen } = row;
|
|
852
|
+
const [startRootsRows, ...infoResults] = (yield* storeCall(store.read(repoScope(attempt.internalId), [startRootsKey, ...deepen.receipt !== void 0 ? infoReads : []]))).results;
|
|
853
|
+
const startRoots = yield* startRootsOf(startRootsRows).pipe(Effect.catchIf((error) => error.code === "DATA_LOSS", forGood));
|
|
854
|
+
yield* report(attempt.context, "publish", row);
|
|
855
|
+
const startSet = new Set(startRoots);
|
|
856
|
+
const finalSet = new Set(row.roots);
|
|
857
|
+
const shallow = row.roots.filter((oid) => !startSet.has(oid));
|
|
858
|
+
const unshallow = startRoots.filter((oid) => !finalSet.has(oid));
|
|
859
|
+
const receiptPut = deepen.receipt === void 0 ? [] : deepenReceiptPut(deepen, { info: {
|
|
860
|
+
...yield* repoInfo(caller, attempt.internalId, opened.record, infoResults),
|
|
861
|
+
shallow: row.roots.length > 0
|
|
862
|
+
} });
|
|
863
|
+
yield* push({
|
|
864
|
+
...baseRequest,
|
|
865
|
+
edits: [],
|
|
866
|
+
roots: {
|
|
867
|
+
shallow,
|
|
868
|
+
unshallow,
|
|
869
|
+
sent: startRoots
|
|
870
|
+
},
|
|
871
|
+
also: () => ({
|
|
872
|
+
put: [importRow({
|
|
873
|
+
...row,
|
|
874
|
+
state: "done"
|
|
875
|
+
}), ...receiptPut],
|
|
876
|
+
delete: importEndDeletes(row),
|
|
877
|
+
jobs: []
|
|
878
|
+
}),
|
|
879
|
+
guard: uncancelled(0, deepen.run)
|
|
880
|
+
}).pipe(Effect.catchIf((error) => error.code === "FAILED_PRECONDITION" && error.context?.reason === "changed-while-checked" || error.code === "RESOURCE_EXHAUSTED", forGood));
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
702
883
|
const page = row.publishedPages ?? 0;
|
|
703
884
|
const pages = row.tipPages ?? 0;
|
|
704
885
|
const last = page + 1 >= pages;
|
|
@@ -718,13 +899,8 @@ const publish = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row) {
|
|
|
718
899
|
}];
|
|
719
900
|
});
|
|
720
901
|
const request = {
|
|
721
|
-
|
|
722
|
-
repo: opened.name,
|
|
723
|
-
internalId: attempt.internalId,
|
|
724
|
-
source: "import",
|
|
725
|
-
as: importOwner,
|
|
902
|
+
...baseRequest,
|
|
726
903
|
edits,
|
|
727
|
-
atomic: true,
|
|
728
904
|
also: (at) => {
|
|
729
905
|
const cursor = importRow(last ? {
|
|
730
906
|
...next,
|
|
@@ -784,10 +960,11 @@ const stepIn = /* @__PURE__ */ Effect.fnUntraced(function* (attempt) {
|
|
|
784
960
|
if (viewed === void 0) return void 0;
|
|
785
961
|
if (viewed.kind === "refused") return yield* forGood(viewed.error);
|
|
786
962
|
if (!viewed.view.whole) return yield* forGood(partialImporter());
|
|
787
|
-
|
|
963
|
+
const { deepen } = row;
|
|
964
|
+
return yield* asSync(stepAs(attempt, read, row, viewed.caller)).pipe(Effect.catch((error) => deepen === void 0 ? Effect.fail(error) : Effect.flatMap(readOwn(attempt), (now) => now.row?.deepen?.run !== deepen.run ? Effect.succeed(more) : Effect.fail(error))));
|
|
788
965
|
});
|
|
789
966
|
/** The step the record says is next, once who started the import is asked again. */
|
|
790
|
-
const stepAs = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, read, row) {
|
|
967
|
+
const stepAs = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, read, row, caller) {
|
|
791
968
|
if (row.receiving !== void 0) return yield* resumed(attempt, row, row.receiving, read.cut);
|
|
792
969
|
if (row.copied) {
|
|
793
970
|
const { lfs } = row;
|
|
@@ -796,7 +973,7 @@ const stepAs = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, read, row)
|
|
|
796
973
|
yield* copyLfs(attempt, read.version, row, lfs, copy);
|
|
797
974
|
return more;
|
|
798
975
|
}
|
|
799
|
-
return yield* publish(attempt, row);
|
|
976
|
+
return yield* publish(attempt, row, caller);
|
|
800
977
|
}
|
|
801
978
|
const remote = yield* remoteOf(attempt.bound, row.source, attempt.context.signal, "read");
|
|
802
979
|
if (row.tipPages === void 0) return yield* listTips(attempt, read.version, row, remote);
|
|
@@ -844,29 +1021,34 @@ const importTry = /* @__PURE__ */ Effect.fnUntraced(function* (bound) {
|
|
|
844
1021
|
const importFailed = /* @__PURE__ */ Effect.fnUntraced(function* (bound, { error }) {
|
|
845
1022
|
const internalId = yield* currentRepo;
|
|
846
1023
|
const passing = error instanceof SyncTryError && !error.permanent;
|
|
847
|
-
const last = error instanceof SyncTryError ? error.kept : stoppedTry;
|
|
848
|
-
const cut = {
|
|
849
|
-
...last,
|
|
850
|
-
message: cutWords(last.message, failedMessageMost)
|
|
851
|
-
};
|
|
852
|
-
const kept = passing ? {
|
|
853
|
-
...cut,
|
|
854
|
-
hint: failedHint
|
|
855
|
-
} : cut;
|
|
856
1024
|
const marked = Effect.gen(function* () {
|
|
857
1025
|
const { store } = yield* CoreParts;
|
|
858
1026
|
for (;;) {
|
|
859
1027
|
const read = yield* readImport(store, internalId);
|
|
860
1028
|
const { row } = read;
|
|
861
1029
|
if (row === void 0 || row.state !== "running") return;
|
|
1030
|
+
const isDeepen = row.deepen !== void 0;
|
|
1031
|
+
const last = error instanceof SyncTryError ? error.kept : isDeepen ? stoppedDeepen : stoppedTry;
|
|
1032
|
+
const cut = {
|
|
1033
|
+
...last,
|
|
1034
|
+
message: cutWords(last.message, failedMessageMost)
|
|
1035
|
+
};
|
|
1036
|
+
const kept = passing ? {
|
|
1037
|
+
...cut,
|
|
1038
|
+
hint: isDeepen ? "Deepen again with a new key" : failedHint
|
|
1039
|
+
} : cut;
|
|
1040
|
+
const receiptPut = read.cancelled ? [] : deepenReceiptPut(row.deepen, { error: kept });
|
|
862
1041
|
if ((yield* storeCommit(store.commit(repoScope(internalId), {
|
|
863
1042
|
id: newChangeId(),
|
|
864
1043
|
expect: read.version,
|
|
865
|
-
put: read.cancelled ? [] : [importRow(failedRow(row, kept))],
|
|
1044
|
+
put: read.cancelled ? [] : [importRow(failedRow(row, kept)), ...receiptPut],
|
|
866
1045
|
delete: importEndDeletes(row)
|
|
867
|
-
}))).ok) return;
|
|
1046
|
+
}))).ok) return row.lfs?.copying;
|
|
868
1047
|
}
|
|
869
1048
|
});
|
|
870
|
-
yield* Effect.provideContext(marked, bound.needs).pipe(Effect.mapError(thrownOf));
|
|
1049
|
+
const copying = yield* Effect.provideContext(marked, bound.needs).pipe(Effect.mapError(thrownOf));
|
|
1050
|
+
if (copying === void 0) return;
|
|
1051
|
+
const copy = yield* bound.lfs;
|
|
1052
|
+
if (copy !== void 0) yield* leftUpload(copy, copying);
|
|
871
1053
|
});
|
|
872
1054
|
export { advertisedFrom, importFailed, importTry };
|
package/dist/sync/tries.mjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { runnerIn, untilAborted } from "../store/crossing.mjs";
|
|
2
2
|
import { gitError, gitErrorFrom, isGitError } from "../contracts/result.mjs";
|
|
3
3
|
import { openRepo } from "../core/access.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { notFailed } from "../core/events/deliver.mjs";
|
|
5
|
+
import { CoreParts, QueueParts } from "../core/parts.mjs";
|
|
5
6
|
import { KeptError, keptError } from "../core/receipts.mjs";
|
|
6
7
|
import { SealedObjects } from "../core/view.mjs";
|
|
7
8
|
import { gitHttpOver } from "../client/git-http.mjs";
|
|
8
9
|
import { hostRecordOf } from "../store/catalogue.mjs";
|
|
9
|
-
import { answerSpent } from "../store/errors.mjs";
|
|
10
|
+
import { answerSpent, storeCall } from "../store/errors.mjs";
|
|
10
11
|
import { decodePacks } from "../store/git-store.mjs";
|
|
11
12
|
import { WholeRepo, wholeRefs } from "../store/ref-rows.mjs";
|
|
12
13
|
import { collections } from "../store/scopes.mjs";
|
|
@@ -15,11 +16,12 @@ import { quoted } from "../protocol/bytes/text.mjs";
|
|
|
15
16
|
import { responseToWeb } from "./http.mjs";
|
|
16
17
|
import { callLimitIn, spentAt, spentOf, spentRefusalOf } from "../contracts/calls-spent.mjs";
|
|
17
18
|
import { chargeCall } from "../store/call-count.mjs";
|
|
18
|
-
import
|
|
19
|
-
import * as HttpClient from "effect/http/HttpClient";
|
|
19
|
+
import { isInfraError } from "@ref0/infra";
|
|
20
20
|
import * as Schema from "effect/Schema";
|
|
21
|
-
import * as
|
|
21
|
+
import * as Effect from "effect/Effect";
|
|
22
22
|
import * as Predicate from "effect/Predicate";
|
|
23
|
+
import * as Cause from "effect/Cause";
|
|
24
|
+
import * as HttpClient from "effect/http/HttpClient";
|
|
23
25
|
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
24
26
|
// src/sync/tries.ts
|
|
25
27
|
/**
|
|
@@ -195,4 +197,21 @@ const openedFor = /* @__PURE__ */ Effect.fnUntraced(function* (caller, internalI
|
|
|
195
197
|
refs
|
|
196
198
|
};
|
|
197
199
|
});
|
|
198
|
-
|
|
200
|
+
const tooManyRoots = (most) => gitError("RESOURCE_EXHAUSTED", `An import takes at most ${most} shallow roots`, { context: {
|
|
201
|
+
reason: "too-large",
|
|
202
|
+
limit: most
|
|
203
|
+
} });
|
|
204
|
+
/**
|
|
205
|
+
* Revives a failed job row that `commit`'s `save()` skipped, shared by mirror resume and deepen
|
|
206
|
+
* start/replay: retries a failed row, discards and re-adds when its failed data was compacted, and
|
|
207
|
+
* re-adds if a prior crash happened after `discard` and before `add` (`NOT_FOUND`). A waiting or
|
|
208
|
+
* running job is left untouched (`not-failed`).
|
|
209
|
+
*/
|
|
210
|
+
const reviveFailedJob = /* @__PURE__ */ Effect.fnUntraced(function* (scope, job) {
|
|
211
|
+
const { store } = yield* CoreParts;
|
|
212
|
+
const { jobs } = yield* QueueParts;
|
|
213
|
+
const state = yield* storeCall(jobs.retry(scope, job)).pipe(Effect.as(0), Effect.catchIf(notFailed, (error) => Effect.succeed(error.code === "NOT_FOUND" ? 1 : 0)), Effect.catchIf((error) => isInfraError(error.cause) && error.cause.reason === "compacted", () => Effect.succeed(2)));
|
|
214
|
+
if (state === 2) yield* storeCall(jobs.discard(scope, job)).pipe(Effect.catchIf(notFailed, () => Effect.void));
|
|
215
|
+
if (state > 0) yield* storeCall(store.add(scope, { jobs: [job] }));
|
|
216
|
+
});
|
|
217
|
+
export { ForGood, SyncTryError, forGood, fromRemote, httpOf, keptFieldsOf, openedFor, remoteOf, reviveFailedJob, senderOf, syncObjects, syncRetry, syncTryError, syncWhole, thrownOf, tooManyRoots, tried, unknownProvider };
|
package/dist/sync.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { GitHubAppCredentials, ImportJobData, ImportLfsMissed, ImportLfsReason, ImportPhase, ImportProgress, ImportState, ImportStatus, ImportedMove, MirrorJobData, MirrorPause, MirrorState, ReportImportProgress, Sync, SyncCancelInput, SyncGitHubOptions, SyncImportInput, SyncLayerOptions, SyncMirrorInput, SyncMirrorsInput, SyncProvider, SyncPublishInput, SyncRemote, SyncRemoveMirrorInput, SyncSource, SyncTransport, SyncTrigger, cancelImport, importRepo, importedPullRefs, mirror, mirrors, publishImported, removeMirror } from "./contracts/sync.mjs";
|
|
1
|
+
import { GitHubAppCredentials, ImportJobData, ImportLfsMissed, ImportLfsReason, ImportPhase, ImportProgress, ImportState, ImportStatus, ImportedMove, MirrorJobData, MirrorPause, MirrorState, ReportImportProgress, Sync, SyncCancelInput, SyncDeepenInput, SyncDeepenMode, SyncGitHubOptions, SyncImportInput, SyncLayerOptions, SyncMirrorInput, SyncMirrorsInput, SyncProvider, SyncPublishInput, SyncRemote, SyncRemoveMirrorInput, SyncSource, SyncTransport, SyncTrigger, cancelImport, deepen, importRepo, importedPullRefs, mirror, mirrors, publishImported, removeMirror } from "./contracts/sync.mjs";
|
|
2
2
|
import { github, webhookBodyBytes } from "./sync/github.mjs";
|
|
3
3
|
import { partialImporter } from "./sync/import.mjs";
|
|
4
4
|
import { layer } from "./sync/layer.mjs";
|
|
5
5
|
import { smartHttp } from "./sync/smart-http.mjs";
|
|
6
|
-
export { type GitHubAppCredentials, type ImportJobData, type ImportLfsMissed, type ImportLfsReason, type ImportPhase, type ImportProgress, type ImportState, type ImportStatus, type ImportedMove, type MirrorJobData, type MirrorPause, type MirrorState, type ReportImportProgress, Sync, type SyncCancelInput, type SyncGitHubOptions, type SyncImportInput, type SyncLayerOptions, type SyncMirrorInput, type SyncMirrorsInput, type SyncProvider, type SyncPublishInput, type SyncRemote, type SyncRemoveMirrorInput, type SyncSource, type SyncTransport, type SyncTrigger, cancelImport, github, importRepo as import, importedPullRefs, layer, mirror, mirrors, partialImporter, publishImported, removeMirror, smartHttp, webhookBodyBytes };
|
|
6
|
+
export { type GitHubAppCredentials, type ImportJobData, type ImportLfsMissed, type ImportLfsReason, type ImportPhase, type ImportProgress, type ImportState, type ImportStatus, type ImportedMove, type MirrorJobData, type MirrorPause, type MirrorState, type ReportImportProgress, Sync, type SyncCancelInput, type SyncDeepenInput, type SyncDeepenMode, type SyncGitHubOptions, type SyncImportInput, type SyncLayerOptions, type SyncMirrorInput, type SyncMirrorsInput, type SyncProvider, type SyncPublishInput, type SyncRemote, type SyncRemoveMirrorInput, type SyncSource, type SyncTransport, type SyncTrigger, cancelImport, deepen, github, importRepo as import, importedPullRefs, layer, mirror, mirrors, partialImporter, publishImported, removeMirror, smartHttp, webhookBodyBytes };
|
package/dist/sync.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Sync, cancelImport, importRepo, importedPullRefs, mirror, mirrors, publishImported, removeMirror } from "./contracts/sync.mjs";
|
|
1
|
+
import { Sync, cancelImport, deepen, importRepo, importedPullRefs, mirror, mirrors, publishImported, removeMirror } from "./contracts/sync.mjs";
|
|
2
2
|
import { github, webhookBodyBytes } from "./sync/github.mjs";
|
|
3
3
|
import { partialImporter } from "./sync/import.mjs";
|
|
4
4
|
import { layer } from "./sync/layer.mjs";
|
|
5
5
|
import { smartHttp } from "./sync/smart-http.mjs";
|
|
6
|
-
export { Sync, cancelImport, github, importRepo as import, importedPullRefs, layer, mirror, mirrors, partialImporter, publishImported, removeMirror, smartHttp, webhookBodyBytes };
|
|
6
|
+
export { Sync, cancelImport, deepen, github, importRepo as import, importedPullRefs, layer, mirror, mirrors, partialImporter, publishImported, removeMirror, smartHttp, webhookBodyBytes };
|
package/dist/topics/advance.mjs
CHANGED
|
@@ -15,12 +15,12 @@ import { unwaited } from "./rows.mjs";
|
|
|
15
15
|
import { commitTopic, currentSet, durationWords, entriesOf, failureOf, readTopic, setKeyOf, topicOf } from "./topic.mjs";
|
|
16
16
|
import { ObjectsParts, QueueParts } from "../core/parts.mjs";
|
|
17
17
|
import { checkedAnswer, plainAnswer } from "../core/rules/context.mjs";
|
|
18
|
-
import * as Clock from "effect/Clock";
|
|
19
|
-
import * as Effect from "effect/Effect";
|
|
20
|
-
import * as Result from "effect/Result";
|
|
21
18
|
import { CurrentJob, Job, LostTry } from "@ref0/infra";
|
|
19
|
+
import * as Effect from "effect/Effect";
|
|
22
20
|
import * as Predicate from "effect/Predicate";
|
|
23
21
|
import * as Context from "effect/Context";
|
|
22
|
+
import * as Result from "effect/Result";
|
|
23
|
+
import * as Clock from "effect/Clock";
|
|
24
24
|
// src/topics/advance.ts
|
|
25
25
|
/**
|
|
26
26
|
* `topics.advance`, one step at a time, each one commit in one scope, read again before the
|