@ref0/git 0.2.0 → 0.4.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/_virtual/_rolldown/runtime.mjs +12 -0
- package/dist/access/private-refs.d.mts +12 -9
- package/dist/access/private-refs.mjs +69 -46
- package/dist/auth/access-jwt.mjs +7 -7
- package/dist/auth/auth.d.mts +41 -0
- package/dist/auth/auth.mjs +39 -0
- package/dist/auth/authorize.mjs +57 -80
- package/dist/auth/bridge.mjs +30 -0
- package/dist/auth/fences.d.mts +23 -3
- package/dist/auth/fences.mjs +3 -3
- package/dist/auth/grants.d.mts +25 -0
- package/dist/auth/grants.mjs +29 -34
- package/dist/auth/helpers.mjs +4 -4
- package/dist/auth/host-function.d.mts +9 -2
- package/dist/auth/host-function.mjs +36 -9
- package/dist/auth/identify.d.mts +4 -1
- package/dist/auth/identify.mjs +9 -11
- package/dist/auth/namespaces.d.mts +3 -0
- package/dist/auth/policy.d.mts +57 -0
- package/dist/auth/policy.mjs +56 -0
- package/dist/auth/token-rows.mjs +6 -6
- package/dist/auth/token-text.mjs +16 -4
- package/dist/auth/tokens.d.mts +4 -1
- package/dist/auth/tokens.mjs +51 -13
- package/dist/auth.d.mts +2 -1
- package/dist/auth.mjs +2 -1
- package/dist/client/answer.mjs +49 -11
- package/dist/client/client.d.mts +2 -2
- package/dist/client/client.mjs +5 -6
- package/dist/client/git-http.d.mts +6 -0
- package/dist/client/git-http.mjs +23 -36
- package/dist/client/helper-node.d.mts +12 -0
- package/dist/client/helper-node.mjs +108 -5
- package/dist/client/local.mjs +97 -92
- package/dist/client/negotiate.mjs +10 -8
- package/dist/client/push-upload.d.mts +14 -0
- package/dist/client/push-upload.mjs +12 -12
- package/dist/client/remote-helper.mjs +22 -20
- package/dist/client/remote.mjs +28 -22
- package/dist/client/run-remote-helper.d.mts +40 -16
- package/dist/client/run-remote-helper.mjs +147 -154
- package/dist/client/scrub.d.mts +8 -2
- package/dist/client/scrub.mjs +76 -4
- package/dist/client/slice-push.d.mts +77 -0
- package/dist/client/slice-push.mjs +169 -0
- package/dist/client/slice-report.mjs +188 -0
- package/dist/client/slices.d.mts +44 -0
- package/dist/client/slices.mjs +131 -0
- package/dist/client/transport.d.mts +1 -0
- package/dist/client/transport.mjs +30 -26
- package/dist/contracts/access.d.mts +36 -9
- package/dist/contracts/actors.d.mts +28 -10
- package/dist/contracts/actors.mjs +17 -0
- package/dist/contracts/authorize.d.mts +77 -0
- package/dist/contracts/authorize.mjs +25 -0
- package/dist/contracts/blobs.d.mts +48 -15
- package/dist/contracts/blobs.mjs +30 -0
- package/dist/contracts/calls-spent.d.mts +1 -0
- package/dist/contracts/calls-spent.mjs +60 -19
- package/dist/contracts/client.d.mts +14 -16
- package/dist/contracts/commits.d.mts +558 -76
- package/dist/contracts/commits.mjs +147 -0
- package/dist/contracts/engine.d.mts +91 -55
- package/dist/contracts/engine.mjs +103 -0
- package/dist/contracts/events.d.mts +1382 -205
- package/dist/contracts/events.mjs +485 -0
- package/dist/contracts/files.d.mts +295 -50
- package/dist/contracts/files.mjs +100 -0
- package/dist/contracts/forks.d.mts +306 -25
- package/dist/contracts/forks.mjs +39 -0
- package/dist/contracts/git.d.mts +107 -0
- package/dist/contracts/git.mjs +23 -0
- package/dist/contracts/grants.d.mts +2 -2
- package/dist/contracts/handlers.d.mts +2 -1
- package/dist/contracts/ids.d.mts +23 -8
- package/dist/contracts/ids.mjs +40 -5
- package/dist/contracts/lfs.d.mts +9 -4
- package/dist/contracts/merges.d.mts +68 -16
- package/dist/contracts/merges.mjs +27 -0
- package/dist/contracts/namespaces.d.mts +14 -0
- package/dist/contracts/object-values.d.mts +96 -0
- package/dist/contracts/object-values.mjs +104 -0
- package/dist/contracts/objects.d.mts +324 -88
- package/dist/contracts/operations.d.mts +24 -16
- package/dist/contracts/promises.d.mts +17 -31
- package/dist/contracts/promises.mjs +13 -0
- package/dist/contracts/push-uploads.d.mts +39 -24
- package/dist/contracts/push-uploads.mjs +54 -0
- package/dist/contracts/queue.d.mts +445 -139
- package/dist/contracts/queue.mjs +197 -0
- package/dist/contracts/refs.d.mts +248 -45
- package/dist/contracts/refs.mjs +117 -0
- package/dist/contracts/repo-records.d.mts +34 -0
- package/dist/contracts/repo-records.mjs +18 -0
- package/dist/contracts/repos.d.mts +411 -58
- package/dist/contracts/repos.mjs +136 -0
- package/dist/contracts/result.d.mts +342 -69
- package/dist/contracts/result.mjs +350 -5
- package/dist/contracts/rules.d.mts +60 -48
- package/dist/contracts/rules.mjs +9 -0
- package/dist/contracts/server.d.mts +173 -80
- package/dist/contracts/services.d.mts +15 -24
- package/dist/contracts/services.mjs +5 -9
- package/dist/contracts/signin.d.mts +64 -31
- package/dist/contracts/signin.mjs +18 -0
- package/dist/contracts/store.d.mts +45 -5
- package/dist/contracts/store.mjs +31 -0
- package/dist/contracts/sync.d.mts +82 -47
- package/dist/contracts/sync.mjs +41 -2
- package/dist/contracts/tags.d.mts +204 -22
- package/dist/contracts/tags.mjs +51 -1
- package/dist/contracts/tokens.d.mts +32 -7
- package/dist/contracts/tokens.mjs +31 -1
- package/dist/contracts/topics.d.mts +128 -66
- package/dist/contracts/topics.mjs +109 -0
- package/dist/contracts/trees.d.mts +132 -52
- package/dist/contracts/trees.mjs +105 -0
- package/dist/contracts/work.d.mts +127 -20
- package/dist/contracts/work.mjs +69 -0
- package/dist/core/access.d.mts +26 -15
- package/dist/core/access.mjs +77 -108
- package/dist/core/ancestry.mjs +86 -18
- package/dist/core/call-names.d.mts +1 -0
- package/dist/core/call-names.mjs +94 -0
- package/dist/core/call-services.mjs +73 -0
- package/dist/core/changes.d.mts +31 -0
- package/dist/core/changes.mjs +5 -0
- package/dist/core/clock.mjs +3 -3
- package/dist/core/events/deliver.mjs +130 -37
- package/dist/core/events/seen.mjs +124 -0
- package/dist/core/forks.mjs +371 -159
- package/dist/core/hooks/order.d.mts +9 -0
- package/dist/core/hooks/order.mjs +25 -0
- package/dist/core/hooks/post-receive.mjs +25 -16
- package/dist/core/hooks/pre-receive.d.mts +8 -1
- package/dist/core/hooks/pre-receive.mjs +8 -6
- package/dist/core/imports.mjs +212 -0
- package/dist/core/index-job.mjs +131 -38
- package/dist/core/merge-parts.d.mts +30 -0
- package/dist/core/merge-parts.mjs +31 -0
- package/dist/core/names.mjs +4 -16
- package/dist/core/namespaces.d.mts +2 -0
- package/dist/core/objects/blobs.mjs +4 -4
- package/dist/core/objects/commit-writes.mjs +19 -17
- package/dist/core/objects/commits.mjs +12 -12
- package/dist/core/objects/files.mjs +10 -11
- package/dist/core/objects/lines.mjs +15 -32
- package/dist/core/objects/merges.mjs +4 -4
- package/dist/core/objects/objects-layer.d.mts +21 -0
- package/dist/core/objects/objects-layer.mjs +47 -0
- package/dist/core/objects/objects-namespace.d.mts +6 -0
- package/dist/core/objects/objects-namespace.mjs +13 -0
- package/dist/core/objects/objects.d.mts +49 -0
- package/dist/core/objects/objects.mjs +18 -0
- package/dist/core/objects/peel.mjs +3 -3
- package/dist/core/objects/reading.mjs +135 -40
- package/dist/core/objects/tags.mjs +7 -7
- package/dist/core/objects/tree-edits.mjs +40 -27
- package/dist/core/objects/trees.mjs +23 -18
- package/dist/core/objects/writing.mjs +43 -44
- package/dist/core/own-writes.mjs +3 -3
- package/dist/core/parts.d.mts +125 -0
- package/dist/core/parts.mjs +59 -0
- package/dist/core/promise.mjs +39 -17
- package/dist/core/publish.mjs +27 -17
- package/dist/core/purge.mjs +242 -0
- package/dist/core/push-decide.mjs +93 -28
- package/dist/core/push.mjs +301 -156
- package/dist/core/receipts.d.mts +4 -3
- package/dist/core/receipts.mjs +20 -12
- package/dist/core/ref-conflicts.mjs +70 -4
- package/dist/core/ref-index-job.mjs +181 -0
- package/dist/core/ref-index.d.mts +25 -0
- package/dist/core/ref-index.mjs +136 -0
- package/dist/core/ref-view.mjs +166 -0
- package/dist/core/refs.mjs +313 -95
- package/dist/core/repack.d.mts +10 -0
- package/dist/core/repack.mjs +261 -81
- package/dist/core/repo-info.mjs +99 -0
- package/dist/core/repos.mjs +114 -80
- package/dist/core/rules/changes.mjs +48 -20
- package/dist/core/rules/check.mjs +29 -22
- package/dist/core/rules/commit-changes.d.mts +13 -0
- package/dist/core/rules/commit-changes.mjs +100 -91
- package/dist/core/rules/context.d.mts +67 -8
- package/dist/core/rules/context.mjs +88 -51
- package/dist/core/rules/facts.mjs +1 -1
- package/dist/core/rules/fetch.mjs +24 -26
- package/dist/core/rules/files.d.mts +13 -0
- package/dist/core/rules/files.mjs +27 -28
- package/dist/core/rules/namespace.d.mts +2 -0
- package/dist/core/rules/patterns.mjs +29 -5
- package/dist/core/rules/protect.d.mts +12 -6
- package/dist/core/rules/protect.mjs +22 -20
- package/dist/core/rules/rules-layer.d.mts +17 -0
- package/dist/core/rules/rules-layer.mjs +26 -0
- package/dist/core/rules/rules.d.mts +8 -0
- package/dist/core/rules/rules.mjs +16 -0
- package/dist/core/rules/service.mjs +18 -0
- package/dist/core/seam.d.mts +10 -5
- package/dist/core/seam.mjs +36 -19
- package/dist/core/tokens.mjs +29 -23
- package/dist/core/view.d.mts +105 -6
- package/dist/core/view.mjs +211 -109
- package/dist/core/work.mjs +40 -14
- package/dist/effect.d.mts +3 -4
- package/dist/effect.mjs +2 -3
- package/dist/engine/allotted-xdiff.d.mts +1 -0
- package/dist/engine/allotted-xdiff.mjs +1 -1
- package/dist/engine/attributes.mjs +1 -1
- package/dist/engine/combined.d.mts +18 -0
- package/dist/engine/combined.mjs +39 -44
- package/dist/engine/commits.mjs +5 -4
- package/dist/engine/content.d.mts +3 -2
- package/dist/engine/content.mjs +2 -2
- package/dist/engine/failures.d.mts +2 -2
- package/dist/engine/failures.mjs +2 -9
- package/dist/engine/merge-base-walk.d.mts +3 -2
- package/dist/engine/merge-base-walk.mjs +1 -1
- package/dist/engine/merge-bases.mjs +3 -2
- package/dist/engine/merge.mjs +568 -566
- package/dist/engine/parts.d.mts +3 -2
- package/dist/engine/parts.mjs +40 -7
- package/dist/engine/reads.d.mts +1 -0
- package/dist/engine/reads.mjs +5 -5
- package/dist/engine/walk.mjs +23 -24
- package/dist/engine/xdiff.d.mts +2 -33
- package/dist/engine/xdiff.mjs +6 -3
- package/dist/event-streams/event-streams.d.mts +25 -0
- package/dist/event-streams/event-streams.mjs +22 -0
- package/dist/event-streams/namespace.d.mts +2 -0
- package/dist/event-streams/stream.d.mts +42 -0
- package/dist/{core/events → event-streams}/stream.mjs +112 -48
- package/dist/extend.d.mts +5 -2
- package/dist/extend.mjs +3 -1
- package/dist/http/answers.mjs +8 -4
- package/dist/http/bodies.mjs +84 -56
- package/dist/http/core-parts.mjs +206 -60
- package/dist/http/handler.d.mts +2 -0
- package/dist/http/handler.mjs +17 -11
- package/dist/http/node.mjs +10 -6
- package/dist/http/parts.d.mts +12 -0
- package/dist/http/push-uploads.d.mts +9 -0
- package/dist/http/push-uploads.mjs +76 -66
- package/dist/http/receive-pack.mjs +162 -28
- package/dist/http/upload-pack.mjs +106 -81
- package/dist/index.d.mts +48 -28
- package/dist/index.mjs +29 -7
- package/dist/lfs/calls.mjs +2 -2
- package/dist/lfs/locks.mjs +24 -20
- package/dist/lfs/objects.d.mts +7 -0
- package/dist/lfs/objects.mjs +32 -27
- package/dist/lfs/pointers.mjs +7 -7
- package/dist/lfs/purge.mjs +50 -0
- package/dist/lfs/repo.mjs +5 -5
- package/dist/lfs/rows.mjs +9 -9
- package/dist/lfs/service.d.mts +9 -0
- package/dist/lfs/service.mjs +32 -25
- package/dist/lfs/upkeep.mjs +5 -5
- package/dist/lfs/wire.mjs +80 -38
- package/dist/merges/merges.d.mts +20 -0
- package/dist/merges/merges.mjs +32 -0
- package/dist/merges/namespace.d.mts +2 -0
- package/dist/merges/public.d.mts +6 -0
- package/dist/merges/public.mjs +10 -0
- package/dist/node.d.mts +1 -2
- package/dist/node.mjs +1 -3
- package/dist/protocol/bytes/buffers.d.mts +9 -3
- package/dist/protocol/bytes/buffers.mjs +11 -5
- package/dist/protocol/bytes/deflate.d.mts +7 -5
- package/dist/protocol/bytes/deflate.mjs +59 -23
- package/dist/protocol/bytes/inflate.d.mts +4 -3
- package/dist/protocol/bytes/inflate.mjs +61 -26
- package/dist/protocol/bytes/reader.mjs +61 -0
- package/dist/protocol/bytes/sha1-hasher.d.mts +3 -1
- package/dist/protocol/bytes/sha1-hasher.mjs +13 -3
- package/dist/protocol/bytes/sha1.d.mts +1 -1
- package/dist/protocol/bytes/sha1.mjs +5 -5
- package/dist/protocol/bytes/streams.mjs +16 -6
- package/dist/protocol/diff/patch.d.mts +4 -0
- package/dist/protocol/diff/patch.mjs +1 -1
- package/dist/protocol/diff/paths.mjs +1 -1
- package/dist/protocol/diff/read.d.mts +1 -1
- package/dist/protocol/diff/read.mjs +102 -90
- package/dist/protocol/framing/pkt-line.d.mts +1 -0
- package/dist/protocol/framing/pkt-line.mjs +40 -6
- package/dist/protocol/objects/checked-blobs.d.mts +1 -0
- package/dist/protocol/objects/fsck.mjs +7 -1
- package/dist/protocol/objects/held.mjs +5 -11
- package/dist/protocol/objects/ident.mjs +1 -1
- package/dist/protocol/objects/object-rules.mjs +15 -7
- package/dist/protocol/objects/object.d.mts +6 -2
- package/dist/protocol/objects/object.mjs +5 -2
- package/dist/protocol/objects/tag.d.mts +3 -1
- package/dist/protocol/objects/tag.mjs +27 -1
- package/dist/protocol/objects/tree.mjs +1 -1
- package/dist/protocol/packs/delta.d.mts +1 -1
- package/dist/protocol/packs/delta.mjs +2 -2
- package/dist/protocol/packs/graph.mjs +55 -56
- package/dist/protocol/packs/idx.d.mts +4 -2
- package/dist/protocol/packs/idx.mjs +156 -63
- package/dist/protocol/packs/indexer.d.mts +22 -4
- package/dist/protocol/packs/indexer.mjs +14 -35
- package/dist/protocol/packs/parts.mjs +5 -5
- package/dist/protocol/packs/pos.mjs +12 -5
- package/dist/protocol/packs/reader.d.mts +19 -12
- package/dist/protocol/packs/reader.mjs +252 -25
- package/dist/protocol/packs/rev.d.mts +1 -1
- package/dist/protocol/packs/rev.mjs +42 -24
- package/dist/protocol/packs/types-file.mjs +85 -0
- package/dist/protocol/packs/write-error.d.mts +1 -1
- package/dist/protocol/packs/write-error.mjs +2 -2
- package/dist/protocol/packs/writer.d.mts +40 -15
- package/dist/protocol/packs/writer.mjs +142 -49
- package/dist/protocol/wire/advertisement.d.mts +39 -14
- package/dist/protocol/wire/advertisement.mjs +127 -31
- package/dist/protocol/wire/fetch.d.mts +57 -19
- package/dist/protocol/wire/fetch.mjs +57 -26
- package/dist/protocol/wire/json.mjs +25 -0
- package/dist/protocol/wire/lines.d.mts +10 -0
- package/dist/protocol/wire/lines.mjs +20 -6
- package/dist/protocol/wire/push-limits.d.mts +6 -0
- package/dist/protocol/wire/push-limits.mjs +88 -0
- package/dist/protocol/wire/push-uploads.mjs +3 -28
- package/dist/protocol/wire/receive-pack.d.mts +30 -14
- package/dist/protocol/wire/receive-pack.mjs +29 -2
- package/dist/protocol/wire/report-status.d.mts +30 -11
- package/dist/protocol/wire/report-status.mjs +21 -2
- package/dist/protocol/wire/v2.d.mts +56 -29
- package/dist/protocol/wire/v2.mjs +91 -16
- package/dist/protocol.d.mts +4 -3
- package/dist/protocol.mjs +7 -6
- package/dist/queue/advance.mjs +191 -121
- package/dist/queue/callers.mjs +12 -9
- package/dist/queue/calls.mjs +311 -155
- package/dist/queue/commit.mjs +70 -26
- package/dist/queue/host.d.mts +40 -13
- package/dist/queue/host.mjs +37 -39
- package/dist/queue/lanes.mjs +1 -1
- package/dist/queue/layer.d.mts +14 -0
- package/dist/queue/layer.mjs +55 -0
- package/dist/queue/limits.mjs +13 -2
- package/dist/queue/namespace.d.mts +2 -0
- package/dist/queue/pages.mjs +1 -1
- package/dist/queue/public.d.mts +6 -0
- package/dist/queue/public.mjs +21 -0
- package/dist/queue/push-option.mjs +49 -30
- package/dist/queue/rows.mjs +24 -16
- package/dist/queue/schedule.mjs +23 -23
- package/dist/queue/search.mjs +8 -7
- package/dist/queue/state.mjs +49 -13
- package/dist/queue/steps.mjs +6 -3
- package/dist/remote-helper.d.mts +5 -2
- package/dist/remote-helper.mjs +5 -2
- package/dist/rest/api.d.mts +1 -1
- package/dist/rest/blobs.d.mts +799 -32
- package/dist/rest/blobs.mjs +4 -4
- package/dist/rest/caller.d.mts +4163 -36
- package/dist/rest/caller.mjs +2 -2
- package/dist/rest/client.mjs +82 -72
- package/dist/rest/commits.d.mts +3253 -182
- package/dist/rest/commits.mjs +18 -64
- package/dist/rest/errors.d.mts +2082 -22
- package/dist/rest/errors.mjs +46 -89
- package/dist/rest/events.d.mts +394 -11
- package/dist/rest/events.mjs +13 -9
- package/dist/rest/files.d.mts +1239 -88
- package/dist/rest/files.mjs +11 -42
- package/dist/rest/forks.d.mts +2005 -62
- package/dist/rest/forks.mjs +10 -13
- package/dist/rest/handler.d.mts +4 -0
- package/dist/rest/handler.mjs +57 -26
- package/dist/rest/handlers.mjs +55 -62
- package/dist/rest/listen.d.mts +5 -8
- package/dist/rest/listen.mjs +23 -29
- package/dist/rest/me.d.mts +393 -10
- package/dist/rest/me.mjs +2 -2
- package/dist/rest/merges.d.mts +399 -16
- package/dist/rest/merges.mjs +3 -17
- package/dist/rest/paths.mjs +1 -0
- package/dist/rest/queue.d.mts +5615 -240
- package/dist/rest/queue.mjs +15 -130
- package/dist/rest/refs.d.mts +2859 -132
- package/dist/rest/refs.mjs +19 -39
- package/dist/rest/repos.d.mts +2392 -64
- package/dist/rest/repos.mjs +10 -33
- package/dist/rest/tags.d.mts +1211 -60
- package/dist/rest/tags.mjs +6 -34
- package/dist/rest/tokens.d.mts +2473 -170
- package/dist/rest/tokens.mjs +7 -4
- package/dist/rest/topics.d.mts +2060 -113
- package/dist/rest/topics.mjs +23 -71
- package/dist/rest/trees.d.mts +1610 -75
- package/dist/rest/trees.mjs +16 -57
- package/dist/rest/wire.d.mts +402 -0
- package/dist/rest/wire.mjs +32 -46
- package/dist/rest/work.d.mts +1179 -38
- package/dist/rest/work.mjs +7 -51
- package/dist/rest.d.mts +3 -3
- package/dist/server/extension.d.mts +11 -4
- package/dist/server/extension.mjs +85 -53
- package/dist/server/git-layer.d.mts +23 -0
- package/dist/server/git-layer.mjs +107 -0
- package/dist/server/git-namespace.d.mts +6 -0
- package/dist/server/git-namespace.mjs +15 -0
- package/dist/server/lifecycle.d.mts +2 -0
- package/dist/server/lifecycle.mjs +82 -0
- package/dist/server/namespaces.d.mts +2 -0
- package/dist/server/registry.d.mts +9 -0
- package/dist/server/registry.mjs +167 -0
- package/dist/server/route-match.mjs +88 -0
- package/dist/server/routes.d.mts +15 -8
- package/dist/server/routes.mjs +35 -33
- package/dist/server/server.d.mts +27 -2
- package/dist/server/server.mjs +493 -234
- package/dist/signin/codes.mjs +9 -6
- package/dist/signin/context.d.mts +2 -1
- package/dist/signin/context.mjs +4 -4
- package/dist/signin/device.mjs +8 -8
- package/dist/signin/forms.mjs +11 -29
- package/dist/signin/grants.d.mts +5 -3
- package/dist/signin/grants.mjs +20 -19
- package/dist/signin/route.mjs +2 -2
- package/dist/signin/web.mjs +7 -7
- package/dist/signin/wire.mjs +6 -6
- package/dist/storage/bits.mjs +41 -0
- package/dist/storage/budget.mjs +51 -18
- package/dist/storage/calls.d.mts +22 -4
- package/dist/storage/calls.mjs +347 -110
- package/dist/storage/clean-up.mjs +80 -35
- package/dist/storage/counted-bucket.mjs +115 -0
- package/dist/storage/fetch.d.mts +5 -1
- package/dist/storage/fetch.mjs +428 -79
- package/dist/storage/fsck.mjs +56 -7
- package/dist/storage/held-types.d.mts +7 -0
- package/dist/storage/held-types.mjs +263 -0
- package/dist/storage/host-bucket.mjs +28 -0
- package/dist/storage/id-mix.d.mts +1 -0
- package/dist/storage/id-mix.mjs +55 -0
- package/dist/storage/index-bitmaps.d.mts +2 -1
- package/dist/storage/index-bitmaps.mjs +233 -101
- package/dist/storage/index-build.d.mts +7 -3
- package/dist/storage/index-build.mjs +674 -174
- package/dist/storage/index-fetch.d.mts +4 -1
- package/dist/storage/index-fetch.mjs +365 -342
- package/dist/storage/index-files.mjs +25 -27
- package/dist/storage/index-graph.d.mts +2 -1
- package/dist/storage/index-graph.mjs +127 -91
- package/dist/storage/index-layers.d.mts +11 -0
- package/dist/storage/index-layers.mjs +258 -78
- package/dist/storage/index-reach.mjs +181 -75
- package/dist/storage/index-remap.mjs +74 -32
- package/dist/storage/index-shallow.mjs +311 -0
- package/dist/storage/index-visible.mjs +168 -0
- package/dist/storage/layout.d.mts +1 -0
- package/dist/storage/layout.mjs +39 -8
- package/dist/storage/lfs-pointers.d.mts +3 -1
- package/dist/storage/lfs-pointers.mjs +25 -9
- package/dist/storage/link-join.d.mts +4 -0
- package/dist/storage/link-join.mjs +50 -12
- package/dist/storage/links.mjs +89 -4
- package/dist/storage/listed-ids.mjs +10 -0
- package/dist/storage/loose.d.mts +11 -4
- package/dist/storage/loose.mjs +103 -69
- package/dist/storage/memory-budget.d.mts +5 -0
- package/dist/storage/memory-budget.mjs +530 -102
- package/dist/storage/merge-choose.mjs +258 -0
- package/dist/storage/merge-cut.mjs +47 -0
- package/dist/storage/merge-fence.mjs +89 -0
- package/dist/storage/merge-index.mjs +347 -0
- package/dist/storage/merge-most.mjs +202 -0
- package/dist/storage/merge-plan.mjs +171 -0
- package/dist/storage/merge-row.mjs +258 -0
- package/dist/storage/merge-stream.mjs +497 -0
- package/dist/storage/merge-walk.mjs +199 -0
- package/dist/storage/merge-write.mjs +129 -0
- package/dist/storage/merge.d.mts +10 -0
- package/dist/storage/merge.mjs +82 -306
- package/dist/storage/object-rows.d.mts +4 -2
- package/dist/storage/object-rows.mjs +101 -17
- package/dist/storage/pack-order.d.mts +1 -1
- package/dist/storage/pack-order.mjs +71 -54
- package/dist/storage/pack-ranges.d.mts +1 -1
- package/dist/storage/pack-ranges.mjs +396 -60
- package/dist/storage/pack-reads.d.mts +6 -2
- package/dist/storage/pack-reads.mjs +613 -124
- package/dist/storage/pack-receive.d.mts +7 -2
- package/dist/storage/pack-receive.mjs +820 -237
- package/dist/storage/packs-memory.d.mts +25 -0
- package/dist/storage/packs-memory.mjs +49 -0
- package/dist/storage/packs.d.mts +9 -7
- package/dist/storage/packs.mjs +562 -218
- package/dist/storage/placed-reads.mjs +205 -0
- package/dist/storage/promise-calls.mjs +29 -0
- package/dist/storage/prune-keep.mjs +164 -0
- package/dist/storage/prune-walk.mjs +578 -0
- package/dist/storage/prune.mjs +739 -332
- package/dist/storage/push-allotment.mjs +3 -3
- package/dist/storage/push-uploads.mjs +24 -14
- package/dist/storage/pushed-commits.mjs +8 -9
- package/dist/storage/quarantine.d.mts +10 -0
- package/dist/storage/quarantine.mjs +28 -25
- package/dist/storage/range-cache.mjs +71 -0
- package/dist/storage/raw-ids.mjs +20 -1
- package/dist/storage/ready.d.mts +6 -4
- package/dist/storage/ready.mjs +109 -48
- package/dist/storage/receive-admission.mjs +67 -0
- package/dist/storage/receive-bounds.d.mts +1 -0
- package/dist/storage/receive-bounds.mjs +202 -0
- package/dist/storage/receive-files.mjs +248 -0
- package/dist/storage/receive-links.mjs +281 -244
- package/dist/storage/receive-state.d.mts +9 -0
- package/dist/storage/receive-state.mjs +150 -0
- package/dist/storage/receive-steps.mjs +344 -0
- package/dist/storage/receive-sweep.mjs +160 -0
- package/dist/storage/receive-table.d.mts +3 -0
- package/dist/storage/receive-table.mjs +197 -0
- package/dist/storage/repack-backlog.mjs +70 -0
- package/dist/storage/repack-contained.mjs +269 -0
- package/dist/storage/repack-job.d.mts +3 -0
- package/dist/storage/repack-job.mjs +24 -7
- package/dist/storage/repack.d.mts +6 -6
- package/dist/storage/repack.mjs +156 -77
- package/dist/storage/roots.mjs +23 -7
- package/dist/storage/rows.d.mts +6 -3
- package/dist/storage/rows.mjs +41 -8
- package/dist/storage/runs.d.mts +8 -0
- package/dist/storage/runs.mjs +731 -0
- package/dist/storage/send-list.d.mts +9 -0
- package/dist/storage/send-list.mjs +504 -0
- package/dist/storage/shallow.d.mts +3 -3
- package/dist/storage/shallow.mjs +7 -7
- package/dist/storage/single-flight.mjs +47 -0
- package/dist/storage/stream-whole.mjs +121 -54
- package/dist/storage/swap-walk.mjs +188 -0
- package/dist/storage/unpack.mjs +54 -23
- package/dist/storage/visible.mjs +58 -39
- package/dist/storage/walk.d.mts +4 -1
- package/dist/storage/walk.mjs +33 -14
- package/dist/storage/wants.mjs +185 -33
- package/dist/storage/written-bases.mjs +172 -0
- package/dist/store/call-count.d.mts +69 -4
- package/dist/store/call-count.mjs +193 -51
- package/dist/store/catalogue.d.mts +18 -4
- package/dist/store/catalogue.mjs +135 -48
- package/dist/store/closed.d.mts +21 -0
- package/dist/store/closed.mjs +34 -0
- package/dist/store/crossing.mjs +10 -9
- package/dist/store/cursor-seal.d.mts +12 -1
- package/dist/store/cursor-seal.mjs +11 -7
- package/dist/store/errors.d.mts +2 -2
- package/dist/store/errors.mjs +120 -26
- package/dist/store/git-store.mjs +21 -2
- package/dist/store/list-job.mjs +5 -5
- package/dist/store/outbox.d.mts +15 -5
- package/dist/store/outbox.mjs +110 -30
- package/dist/store/promises.d.mts +6 -0
- package/dist/store/promises.mjs +317 -0
- package/dist/store/queue-jobs.mjs +12 -12
- package/dist/store/records.d.mts +64 -1
- package/dist/store/records.mjs +101 -32
- package/dist/store/ref-rows.d.mts +18 -2
- package/dist/store/ref-rows.mjs +62 -5
- package/dist/store/repo-record.mjs +11 -9
- package/dist/store/reservations.mjs +9 -8
- package/dist/store/scopes.mjs +13 -1
- package/dist/store/settle.mjs +1 -1
- package/dist/store/topic-jobs.mjs +4 -4
- package/dist/sync/bound.d.mts +5 -3
- package/dist/sync/bound.mjs +41 -7
- package/dist/sync/github.mjs +7 -7
- package/dist/sync/import.d.mts +2 -0
- package/dist/sync/import.mjs +46 -50
- package/dist/sync/jobs.d.mts +3 -3
- package/dist/sync/jobs.mjs +36 -41
- package/dist/sync/mirror.d.mts +5 -1
- package/dist/sync/mirror.mjs +121 -44
- package/dist/sync/publish.d.mts +1 -0
- package/dist/sync/publish.mjs +10 -12
- package/dist/sync/step.mjs +439 -71
- package/dist/sync/tries.mjs +52 -34
- package/dist/sync.d.mts +3 -3
- package/dist/sync.mjs +2 -2
- package/dist/topics/advance.mjs +105 -87
- package/dist/topics/calls.mjs +99 -69
- package/dist/topics/directory.mjs +31 -11
- package/dist/topics/host.d.mts +1 -2
- package/dist/topics/host.mjs +3 -13
- package/dist/topics/members.mjs +30 -24
- package/dist/topics/rows.mjs +10 -9
- package/dist/topics/topic.mjs +42 -16
- package/package.json +8 -15
- package/dist/auth/authorize.d.mts +0 -5
- package/dist/contracts/objects.mjs +0 -54
- package/dist/core/events/stream.d.mts +0 -19
- package/dist/core/rules/define.d.mts +0 -5
- package/dist/core/rules/define.mjs +0 -13
- package/dist/core/rules/fetch.d.mts +0 -5
- package/dist/core/sight.mjs +0 -99
- package/dist/engine/engine.d.mts +0 -25
- package/dist/engine/engine.mjs +0 -49
- package/dist/engine/xdiff/NOTICE.md +0 -63
- package/dist/engine/xdiff/compiled.d.mts +0 -7
- package/dist/engine/xdiff/compiled.mjs +0 -9
- package/dist/engine/xdiff/embedded.mjs +0 -4
- package/dist/engine/xdiff/node.d.mts +0 -7
- package/dist/engine/xdiff/node.mjs +0 -10
- package/dist/engine/xdiff/upstream/LGPL-2.1 +0 -511
- package/dist/engine/xdiff/xdiff.wasm +0 -0
- package/dist/engine.d.mts +0 -3
- package/dist/engine.mjs +0 -3
- package/dist/storage/distinct-ids.mjs +0 -39
- package/dist/storage/held-memo.mjs +0 -188
- package/dist/storage/index-remap.d.mts +0 -8
- package/dist/sync/records.mjs +0 -73
package/dist/sync/step.mjs
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
|
+
import { gitError, gitErrorFrom } from "../contracts/result.mjs";
|
|
1
2
|
import { importedPullRefs } from "../contracts/sync.mjs";
|
|
2
3
|
import { push } from "../core/push.mjs";
|
|
3
|
-
import {
|
|
4
|
+
import { refusedLead } from "../client/answer.mjs";
|
|
4
5
|
import { negotiate } from "../client/negotiate.mjs";
|
|
5
6
|
import { discover, fetchTerms, remoteRefsOf } from "../client/remote.mjs";
|
|
6
|
-
import {
|
|
7
|
+
import { objectsFace, oneShotReads, scopedReceiveStep } from "../storage/calls.mjs";
|
|
8
|
+
import { isPackId } from "../storage/layout.mjs";
|
|
9
|
+
import { receiveCutParentsMost } from "../storage/receive-bounds.mjs";
|
|
10
|
+
import { ReceiveRow, receiveKey, stagedRow } from "../storage/receive-steps.mjs";
|
|
11
|
+
import { decodeHeld } from "../storage/rows.mjs";
|
|
7
12
|
import { infiniteDepth } from "../storage/shallow.mjs";
|
|
8
|
-
import {
|
|
13
|
+
import { decodeRow, storeCall } from "../store/errors.mjs";
|
|
14
|
+
import { gitStore } from "../store/git-store.mjs";
|
|
9
15
|
import { jobRepo, newChangeId, repoScope } from "../store/scopes.mjs";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
16
|
+
import { asSync } from "./bound.mjs";
|
|
17
|
+
import { ImportRow, cancelKey, cutKey, cutRow, failedHint, failedRow, importEndDeletes, importKey, importRow, readImport, stoppedTry } from "../core/imports.mjs";
|
|
18
|
+
import { ForGood, SyncTryError, forGood, fromRemote, httpOf, openedFor, remoteOf, runTry, syncObjects, thrownOf } from "./tries.mjs";
|
|
19
|
+
import { runIn, uncounted } from "../store/crossing.mjs";
|
|
20
|
+
import { CoreParts, ObjectsParts, overStore } from "../core/parts.mjs";
|
|
13
21
|
import * as Effect from "effect/Effect";
|
|
14
22
|
import * as Result from "effect/Result";
|
|
15
|
-
import * as Exit from "effect/Exit";
|
|
16
23
|
// src/sync/step.ts
|
|
17
24
|
/**
|
|
18
25
|
* One try of `git.sync.import`: one step of the import, committed with its record, so a try after
|
|
@@ -21,8 +28,9 @@ import * as Exit from "effect/Exit";
|
|
|
21
28
|
* newest first, as fit in the room they leave under the limits, each under `importedPullRefs`;
|
|
22
29
|
* 2. fetch the history behind them a segment at a time, each deeper than the last, as
|
|
23
30
|
* `git fetch --deepen` does, and receive it as a push of objects alone: a segment whose pack
|
|
24
|
-
* runs past the limit
|
|
25
|
-
* the storage refuses as `object-too-large`
|
|
31
|
+
* runs past the limit, or that the storage refuses for a reason in `halvedReasons`, is fetched
|
|
32
|
+
* again at half the depth, and one holding an object the storage refuses as `object-too-large`
|
|
33
|
+
* fails the job on that try, with that refusal;
|
|
26
34
|
* 3. publish: move each ref to its tip, in one atomic commit, `source: 'import'`, then mark the
|
|
27
35
|
* import done.
|
|
28
36
|
* A step reads the import's record first, and ends the job for a cancelled import or one that
|
|
@@ -30,7 +38,7 @@ import * as Exit from "effect/Exit";
|
|
|
30
38
|
*/
|
|
31
39
|
/** The deepest a segment's step grows: past it, a segment's history is whole anyway. */
|
|
32
40
|
const stepMost = 1 << 20;
|
|
33
|
-
const
|
|
41
|
+
const shallowRemote = () => gitError("FAILED_PRECONDITION", "The remote is a shallow clone, without its oldest parents", { hint: "Import from a full clone, or run `git fetch --unshallow` in the remote first" });
|
|
34
42
|
const tooManyTips = (limits, count) => gitError("RESOURCE_EXHAUSTED", `The remote has ${count} branches and tags`, {
|
|
35
43
|
hint: `An import takes at most ${limits.tips} branches and tags, and ${limits.tipNameBytes} bytes of their names`,
|
|
36
44
|
context: {
|
|
@@ -38,13 +46,111 @@ const tooManyTips = (limits, count) => gitError("RESOURCE_EXHAUSTED", `The remot
|
|
|
38
46
|
limit: limits.tips
|
|
39
47
|
}
|
|
40
48
|
});
|
|
49
|
+
/** Why a segment can't be made smaller: it's one commit, or the remote takes no deepen. */
|
|
50
|
+
const leastHint = (shallow) => shallow ? "A segment of one commit is the least an import fetches" : "The remote takes no shallow fetch, so an import fetches its history in one segment";
|
|
41
51
|
const overBudget = (most) => gitError("RESOURCE_EXHAUSTED", `One commit's history alone is over ${most} bytes`, {
|
|
42
|
-
hint:
|
|
52
|
+
hint: leastHint(true),
|
|
43
53
|
context: {
|
|
44
54
|
reason: "response-too-large",
|
|
45
55
|
limit: most
|
|
46
56
|
}
|
|
47
57
|
});
|
|
58
|
+
/**
|
|
59
|
+
* The storage's refusals of a segment's pack that a segment of fewer commits may mend, read by
|
|
60
|
+
* reason: its count of objects, or a delta chain too deep (`too-large`); a delta of a file past
|
|
61
|
+
* 16 MiB, which a segment of its own sends whole, since an import asks for no thin pack
|
|
62
|
+
* (`delta-too-large`); and one push's count of checked files and of LFS pointers. None is among
|
|
63
|
+
* `finalRefusal`'s.
|
|
64
|
+
*/
|
|
65
|
+
const halvedReasons = /* @__PURE__ */ new Set([
|
|
66
|
+
"too-large",
|
|
67
|
+
"delta-too-large",
|
|
68
|
+
"too-many-gitmodules-and-gitattributes",
|
|
69
|
+
"too-many-pointers"
|
|
70
|
+
]);
|
|
71
|
+
/**
|
|
72
|
+
* A `halvedReasons` refusal of a segment no smaller one can follow: the storage's own words, with
|
|
73
|
+
* a hint for the import in place of the pusher's, such as "Push fewer commits at a time".
|
|
74
|
+
*/
|
|
75
|
+
const leastRefused = (failure, shallow) => {
|
|
76
|
+
const least = leastHint(shallow);
|
|
77
|
+
const hint = failure.context?.reason === "delta-too-large" ? `${least}, and the remote still sends this file as a delta. Its owner can run \`git config core.bigFileThreshold 16m\` and \`git repack -adf\`, or track the file with Git LFS` : least;
|
|
78
|
+
return gitErrorFrom(failure, { hint });
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* The storage's refusal of a segment's pack that no try or halving mends, with what the import's
|
|
82
|
+
* record tells the person, or `undefined` for one a try may mend. Each is read by its code and
|
|
83
|
+
* reason, never its words: one object past what the storage takes, which keeps its own hint; an
|
|
84
|
+
* object of the source's history that fails Git's checks; an OFS_DELTA the remote sent, though
|
|
85
|
+
* the import asks for REF_DELTA only; and a tag naming an object of another type, or one the
|
|
86
|
+
* segment doesn't send, which the remote serves the same at any try. A body cut short fails in
|
|
87
|
+
* inflate or at its end, never as a well-formed object that fails a check, so every other refusal
|
|
88
|
+
* of a pack tries again.
|
|
89
|
+
*/
|
|
90
|
+
/**
|
|
91
|
+
* A segment refused as the remote sent it: a link of the wrong type, an object neither the segment
|
|
92
|
+
* nor the repo holds, a boundary commit its pack doesn't hold, and a commit of too many parents.
|
|
93
|
+
*/
|
|
94
|
+
const finalReasons = /* @__PURE__ */ new Set([
|
|
95
|
+
"link-wrong-type",
|
|
96
|
+
"object-missing",
|
|
97
|
+
"boundary-not-in-pack",
|
|
98
|
+
"too-many-parents"
|
|
99
|
+
]);
|
|
100
|
+
const finalRefusal = (failure) => {
|
|
101
|
+
if (failure.code === "RESOURCE_EXHAUSTED" && failure.context?.reason === "object-too-large") return failure;
|
|
102
|
+
if (failure.code !== "INVALID_ARGUMENT") return void 0;
|
|
103
|
+
const { context } = failure;
|
|
104
|
+
if (context?.reason === "fsck") return gitErrorFrom(failure, {
|
|
105
|
+
message: `An object of the import fails Git's ${context.msgId} check`,
|
|
106
|
+
hint: `An object in the source's history fails Git's checks (${context.msgId}), so this repo can't be imported as it is. Delete this repo to clear it.`
|
|
107
|
+
});
|
|
108
|
+
if (context?.reason === "ofs-delta") return gitErrorFrom(failure, { hint: "The remote sent OFS_DELTA entries without being asked, so this repo can't be imported from that remote. Delete this repo to clear it." });
|
|
109
|
+
if (finalReasons.has(context?.reason)) return failure;
|
|
110
|
+
};
|
|
111
|
+
/** The most of a remote's words its refusal of an import shows, in UTF-16 units. */
|
|
112
|
+
const refusedWordsMost = 512;
|
|
113
|
+
/**
|
|
114
|
+
* The most of an error's message the import's failed record keeps, in UTF-16 units: at most 3,072
|
|
115
|
+
* bytes as UTF-8, well under a record's 1 MiB, so no refusal's words keep a record from failing.
|
|
116
|
+
*/
|
|
117
|
+
const failedMessageMost = 1024;
|
|
118
|
+
/** `text`'s first `most` UTF-16 units, the first half of a surrogate pair the cut splits dropped. */
|
|
119
|
+
const cutWords = (text, most) => {
|
|
120
|
+
const cut = text.slice(0, most);
|
|
121
|
+
return /[\uD800-\uDBFF]$/u.test(cut) ? cut.slice(0, -1) : cut;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Whether a remote's words may be shown: the import reached `remote` through the platform's own
|
|
125
|
+
* `fetch` with no credential, its own or in its URL. A remote's words may echo a credential, and a
|
|
126
|
+
* host's transport may send one this can't see.
|
|
127
|
+
*/
|
|
128
|
+
const wordsShown = (remote) => {
|
|
129
|
+
const url = URL.parse(remote.url);
|
|
130
|
+
return remote.credentials === void 0 && remote.transport === void 0 && url !== null && url.username === "" && url.password === "";
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* The remote's own refusal of the import: its words, cut to `refusedWordsMost`, only when
|
|
134
|
+
* `wordsShown`.
|
|
135
|
+
*/
|
|
136
|
+
const remoteRefused = (remote, message) => {
|
|
137
|
+
const context = { reason: "remote-refused" };
|
|
138
|
+
const hint = "The job stops here: import again once the remote can be read";
|
|
139
|
+
if (!wordsShown(remote)) return gitError("FAILED_PRECONDITION", "The remote refused the import. Its words aren't shown, since they can echo the credential.", {
|
|
140
|
+
hint,
|
|
141
|
+
context
|
|
142
|
+
});
|
|
143
|
+
const words = cutWords(message.slice(refusedLead.length), refusedWordsMost);
|
|
144
|
+
return gitError("FAILED_PRECONDITION", `The remote refused the import: ${words}`, {
|
|
145
|
+
hint,
|
|
146
|
+
context
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* A failure to read the remote's advertisement: its own `ERR` refusal, by its reason, ends the
|
|
151
|
+
* import, since every try meets it; any other is the remote's, tried again.
|
|
152
|
+
*/
|
|
153
|
+
const advertisedFrom = (remote, call) => (error) => error.code === "FAILED_PRECONDITION" && error.context?.reason === "remote-refused" ? new ForGood({ error: remoteRefused(remote, error.message) }) : fromRemote(call)(error);
|
|
48
154
|
/** `context.progress`, which a claim taken again refuses: the sample's dropped, and the try goes on. */
|
|
49
155
|
const report = (context, phase, row) => Effect.promise(() => context.progress({
|
|
50
156
|
phase,
|
|
@@ -57,14 +163,47 @@ const report = (context, phase, row) => Effect.promise(() => context.progress({
|
|
|
57
163
|
}]
|
|
58
164
|
}).catch(() => void 0));
|
|
59
165
|
/** The repo as this try opens it: `undefined` once it's gone. */
|
|
60
|
-
const openedRepo = (attempt) => openedFor(attempt.
|
|
61
|
-
/** The import's record
|
|
62
|
-
const
|
|
166
|
+
const openedRepo = (attempt) => openedFor(attempt.bound.caller, attempt.internalId);
|
|
167
|
+
/** The import's record, read through this try's store. */
|
|
168
|
+
const readOwn = (attempt) => Effect.flatMap(Effect.service(CoreParts), ({ store }) => readImport(store, attempt.internalId));
|
|
169
|
+
/**
|
|
170
|
+
* The import's record at `row`, committed at `version` with `deletes`: a commit another beat is read
|
|
171
|
+
* next try.
|
|
172
|
+
*/
|
|
173
|
+
const saved = (attempt, version, row, deletes = []) => Effect.flatMap(Effect.service(CoreParts), ({ store }) => storeCall(() => store.commit(repoScope(attempt.internalId), {
|
|
63
174
|
id: newChangeId(),
|
|
64
175
|
expect: version,
|
|
65
|
-
put: [importRow(row)]
|
|
66
|
-
|
|
176
|
+
put: [importRow(row)],
|
|
177
|
+
delete: deletes
|
|
178
|
+
})));
|
|
67
179
|
const more = { kind: "more" };
|
|
180
|
+
const endedUnder = () => gitError("FAILED_PRECONDITION", "The import ended while its step ran", { hint: "Its record is no longer running, so the step writes nothing" });
|
|
181
|
+
/**
|
|
182
|
+
* A step's push guard: the import's record still `running` in the push's own read, so a step whose
|
|
183
|
+
* import another write ended since, such as the core's `failed` for a job gone, writes nothing.
|
|
184
|
+
*/
|
|
185
|
+
const stillRunning = {
|
|
186
|
+
reads: [importKey],
|
|
187
|
+
check: /* @__PURE__ */ Effect.fnUntraced(function* (results) {
|
|
188
|
+
const [own] = results[0] ?? [];
|
|
189
|
+
if ((own === void 0 ? void 0 : yield* decodeRow(ImportRow, own, "Import"))?.state !== "running") return yield* Effect.fail(endedUnder());
|
|
190
|
+
})
|
|
191
|
+
};
|
|
192
|
+
const cancelledUnder = () => gitError("FAILED_PRECONDITION", "The import was cancelled while it published", { hint: "It moves no ref, and answers as cancelled" });
|
|
193
|
+
/**
|
|
194
|
+
* Publish's push guard: `stillRunning`, and no cancel saved beside the record, so a cancel saved
|
|
195
|
+
* since the try read the import moves no ref, and `import` answers `import-cancelled`. A landing
|
|
196
|
+
* keeps `stillRunning` alone: a segment in flight as a cancel commits still lands, and its objects
|
|
197
|
+
* stay readable, as `CancelImport` says.
|
|
198
|
+
*/
|
|
199
|
+
const uncancelled = {
|
|
200
|
+
reads: [...stillRunning.reads, cancelKey],
|
|
201
|
+
check: /* @__PURE__ */ Effect.fnUntraced(function* (results) {
|
|
202
|
+
yield* stillRunning.check(results.slice(0, 1));
|
|
203
|
+
const [cancel] = results[1] ?? [];
|
|
204
|
+
if (cancel !== void 0) return yield* Effect.fail(cancelledUnder());
|
|
205
|
+
})
|
|
206
|
+
};
|
|
68
207
|
/** A pull request's head as the remote names it, `refs/pull/N/head`: its number, or `undefined`. */
|
|
69
208
|
const pullHead = (ref) => {
|
|
70
209
|
const number = /^refs\/pull\/([1-9][0-9]*)\/head$/.exec(ref)?.[1];
|
|
@@ -97,7 +236,7 @@ const pullTips = (refs, own, names, limits) => {
|
|
|
97
236
|
* Step 1: the remote's branches and tags, and their tips, kept in the import's record, with the
|
|
98
237
|
* pull requests' heads that fit beside them.
|
|
99
238
|
*/
|
|
100
|
-
const listTips = Effect.fnUntraced(function* (attempt, version, row, remote) {
|
|
239
|
+
const listTips = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, version, row, remote) {
|
|
101
240
|
yield* report(attempt.context, "fetch", row);
|
|
102
241
|
const http = httpOf(remote);
|
|
103
242
|
const listed = Effect.flatMap(discover(http), (upload) => remoteRefsOf(http, upload, [
|
|
@@ -105,7 +244,7 @@ const listTips = Effect.fnUntraced(function* (attempt, version, row, remote) {
|
|
|
105
244
|
"refs/tags/",
|
|
106
245
|
"refs/pull/"
|
|
107
246
|
]));
|
|
108
|
-
const listing = yield* Effect.mapError(listed,
|
|
247
|
+
const listing = yield* Effect.mapError(listed, advertisedFrom(remote, "list its branches and tags"));
|
|
109
248
|
const refs = new Map([...listing].filter(([ref]) => !ref.startsWith("refs/pull/")));
|
|
110
249
|
const names = [...refs.keys()].reduce((bytes, ref) => bytes + ref.length, 0);
|
|
111
250
|
const { limits } = attempt.bound;
|
|
@@ -119,8 +258,11 @@ const listTips = Effect.fnUntraced(function* (attempt, version, row, remote) {
|
|
|
119
258
|
});
|
|
120
259
|
return more;
|
|
121
260
|
});
|
|
122
|
-
/**
|
|
123
|
-
|
|
261
|
+
/**
|
|
262
|
+
* Whether the remote takes a deepen: one that doesn't sends its whole history at once. Only the
|
|
263
|
+
* check's refusal answers no: a defect in it stays a defect.
|
|
264
|
+
*/
|
|
265
|
+
const deepens = (upload) => Effect.isSuccess(fetchTerms(upload, { depth: 1 }));
|
|
124
266
|
/** The pack as it arrives, counted, and stopped once it runs past `most` bytes. */
|
|
125
267
|
const counted = (bytes, most) => {
|
|
126
268
|
const seen = {
|
|
@@ -146,27 +288,66 @@ const rootsAfter = (roots, answer) => {
|
|
|
146
288
|
return [.../* @__PURE__ */ new Set([...roots.filter((oid) => !unshallowed.has(oid)), ...answer.shallow])].sort();
|
|
147
289
|
};
|
|
148
290
|
const sameRoots = (a, b) => a.length === b.length && a.every((oid, index) => oid === b[index]);
|
|
291
|
+
/**
|
|
292
|
+
* The cut a segment moving the roots from `before` to `roots` carries: the parents each root that
|
|
293
|
+
* leaves the roots left out are needed now, whether its answer unshallowed it or the remote stopped
|
|
294
|
+
* deepening; those of a root that stays shallow are kept, and leave its boundary that much less to
|
|
295
|
+
* leave out.
|
|
296
|
+
*/
|
|
297
|
+
const carriedCut = (before, roots, cut) => {
|
|
298
|
+
const staying = new Set(roots);
|
|
299
|
+
return {
|
|
300
|
+
needs: [...new Set(before.flatMap((root) => staying.has(root) ? [] : cut[root] ?? []))],
|
|
301
|
+
kept: Object.entries(cut).filter(([root]) => staying.has(root))
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
/** The cut a landed segment writes, in the commit that lands it, so a resume never finds it landed without it. */
|
|
305
|
+
const cutAfter = (roots, kept, received) => {
|
|
306
|
+
const after = Object.fromEntries([...kept, ...(received?.cut ?? []).map(({ commit, parents }) => [commit, [...parents]])]);
|
|
307
|
+
return Object.keys(after).length === 0 ? {
|
|
308
|
+
put: [],
|
|
309
|
+
delete: [{ ...cutKey }]
|
|
310
|
+
} : {
|
|
311
|
+
put: [cutRow(roots, after)],
|
|
312
|
+
delete: []
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* The record a segment's landing writes: `lands` over `row`, with no segment receiving, and the
|
|
317
|
+
* next one not yet restaged.
|
|
318
|
+
*/
|
|
319
|
+
const landed = (row, lands) => {
|
|
320
|
+
const { receiving: _receiving, restaged: _restaged, ...rest } = row;
|
|
321
|
+
return {
|
|
322
|
+
...rest,
|
|
323
|
+
...lands
|
|
324
|
+
};
|
|
325
|
+
};
|
|
149
326
|
/** Half the depth after a segment past the limit; twice it after one under a quarter of it. */
|
|
150
327
|
const stepAfter = (step, bytes, most) => bytes < most / 4 ? Math.min(step * 2, stepMost) : step;
|
|
151
328
|
/**
|
|
152
329
|
* Step 2: one segment of the history, `step` commits deeper than the last, received as a push of
|
|
153
|
-
* objects alone with the import's record moved past it in the same commit. Its
|
|
154
|
-
* its
|
|
155
|
-
* whole
|
|
330
|
+
* objects alone with the import's record moved past it in the same commit. Its oldest commits, the
|
|
331
|
+
* remote's `shallow` lines, are its boundary: their parents a later segment brings, so only they
|
|
332
|
+
* may be absent, and every other link is checked as a whole push's is. A remote that takes no
|
|
333
|
+
* deepen sends the whole history in one segment, with no boundary. One whose roots stay as they
|
|
334
|
+
* were is itself shallow, and fails the import for good. The parents a boundary left out are kept
|
|
335
|
+
* as the import's cut, in the commit that lands the segment, and the segment after which their
|
|
336
|
+
* root is no longer one needs them, in its pack or the repo, whatever its answer claims, so no ref
|
|
337
|
+
* is published on a commit whose parents the repo lacks.
|
|
156
338
|
*/
|
|
157
|
-
const fetchSegment = Effect.fnUntraced(function* (attempt,
|
|
339
|
+
const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, cut, remote) {
|
|
158
340
|
const { bound, context } = attempt;
|
|
159
341
|
const most = bound.limits.packBytes;
|
|
160
342
|
const tips = [...new Set(Object.values(row.tips ?? {}))];
|
|
161
343
|
const opened = yield* openedRepo(attempt);
|
|
162
344
|
if (opened === void 0) return void 0;
|
|
345
|
+
const objects = objectsFace(syncObjects(yield* ObjectsParts));
|
|
163
346
|
yield* report(context, "fetch", row);
|
|
164
347
|
const http = httpOf(remote);
|
|
165
|
-
const upload = yield* Effect.mapError(discover(http),
|
|
166
|
-
const shallow = deepens(upload);
|
|
167
|
-
const
|
|
168
|
-
if (!shallow && row.depth !== void 0) return yield* forGood(noDeepen());
|
|
169
|
-
const wanted = Math.min(row.deepest + row.step, asked);
|
|
348
|
+
const upload = yield* Effect.mapError(discover(http), advertisedFrom(remote, "advertise its refs"));
|
|
349
|
+
const shallow = yield* deepens(upload);
|
|
350
|
+
const wanted = row.deepest + row.step;
|
|
170
351
|
const request = {
|
|
171
352
|
wants: tips,
|
|
172
353
|
shallows: [...row.roots],
|
|
@@ -178,18 +359,33 @@ const fetchSegment = Effect.fnUntraced(function* (attempt, version, row, remote)
|
|
|
178
359
|
http,
|
|
179
360
|
version: upload.version,
|
|
180
361
|
...terms,
|
|
362
|
+
ofsDelta: false,
|
|
181
363
|
request,
|
|
182
|
-
objects: oneShotReads(
|
|
364
|
+
objects: oneShotReads(objects),
|
|
183
365
|
listed: opened.listed,
|
|
184
|
-
tips
|
|
366
|
+
tips: [...new Set(opened.refs.values())],
|
|
367
|
+
held: row.deepest > 0 ? tips : []
|
|
185
368
|
}).pipe(Effect.mapError(fromRemote("negotiate a fetch")));
|
|
186
369
|
yield* report(context, "receive", row);
|
|
187
370
|
const { pack } = negotiated;
|
|
188
371
|
const { stream, seen } = counted(pack.bytes, most);
|
|
189
372
|
const roots = shallow ? rootsAfter(row.roots, negotiated) : [];
|
|
190
|
-
|
|
373
|
+
if (roots.length > 0 && row.roots.length > 0 && sameRoots(roots, row.roots)) {
|
|
374
|
+
pack.cancel();
|
|
375
|
+
return yield* forGood(shallowRemote());
|
|
376
|
+
}
|
|
377
|
+
const copied = roots.length === 0;
|
|
378
|
+
const pushedPack = {
|
|
379
|
+
bytes: stream,
|
|
380
|
+
objects: pack.objects
|
|
381
|
+
};
|
|
382
|
+
if (shallow && negotiated.shallow.length > 0) pushedPack.boundary = negotiated.shallow;
|
|
383
|
+
const { needs, kept } = carriedCut(row.roots, roots, cut);
|
|
384
|
+
if (needs.length > 0) pushedPack.needs = needs;
|
|
385
|
+
pushedPack.cutMost = kept.reduce((left, [, parents]) => left - parents.length, receiveCutParentsMost);
|
|
386
|
+
const { restaged: _restaged, ...fetched } = row;
|
|
191
387
|
const next = () => ({
|
|
192
|
-
...
|
|
388
|
+
...fetched,
|
|
193
389
|
roots,
|
|
194
390
|
deepest: shallow ? wanted : infiniteDepth,
|
|
195
391
|
step: stepAfter(row.step, seen.bytes, most),
|
|
@@ -198,24 +394,37 @@ const fetchSegment = Effect.fnUntraced(function* (attempt, version, row, remote)
|
|
|
198
394
|
bytes: row.bytes + seen.bytes
|
|
199
395
|
});
|
|
200
396
|
const stopped = new AbortController();
|
|
201
|
-
const
|
|
397
|
+
const { stage, receiveStep } = objects;
|
|
398
|
+
const sent = stage !== void 0 && receiveStep !== void 0 && pack.objects > 0 ? staged(attempt, row, {
|
|
399
|
+
stage: () => {
|
|
400
|
+
const { bytes: _bytes, ...segment } = pushedPack;
|
|
401
|
+
return stage(opened.listed, {
|
|
402
|
+
...segment,
|
|
403
|
+
pack: stream,
|
|
404
|
+
atMost: most
|
|
405
|
+
});
|
|
406
|
+
},
|
|
407
|
+
lands: () => landsOf(next())
|
|
408
|
+
}) : push({
|
|
202
409
|
caller: bound.caller,
|
|
203
410
|
repo: opened.name,
|
|
204
411
|
internalId: attempt.internalId,
|
|
205
412
|
source: "import",
|
|
206
413
|
edits: [],
|
|
207
414
|
atomic: false,
|
|
208
|
-
pack:
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
415
|
+
pack: pushedPack,
|
|
416
|
+
also: (_at, received) => {
|
|
417
|
+
const written = cutAfter(roots, kept, received);
|
|
418
|
+
return {
|
|
419
|
+
put: [importRow(next()), ...written.put],
|
|
420
|
+
delete: written.delete,
|
|
421
|
+
jobs: []
|
|
422
|
+
};
|
|
212
423
|
},
|
|
213
|
-
|
|
214
|
-
put: [importRow(next())],
|
|
215
|
-
jobs: []
|
|
216
|
-
}),
|
|
424
|
+
guard: stillRunning,
|
|
217
425
|
signal: stopped.signal
|
|
218
|
-
})
|
|
426
|
+
});
|
|
427
|
+
const pushed = yield* Effect.result(sent.pipe(Effect.mapError((error) => {
|
|
219
428
|
const failure = pack.failure();
|
|
220
429
|
return failure === void 0 ? error : fromRemote("send its pack")(failure);
|
|
221
430
|
}), Effect.onInterrupt(() => Effect.sync(() => {
|
|
@@ -226,25 +435,167 @@ const fetchSegment = Effect.fnUntraced(function* (attempt, version, row, remote)
|
|
|
226
435
|
pack.cancel();
|
|
227
436
|
if ((yield* openedRepo(attempt)) === void 0) return void 0;
|
|
228
437
|
const { failure } = pushed;
|
|
229
|
-
|
|
230
|
-
|
|
438
|
+
const final = finalRefusal(failure);
|
|
439
|
+
if (final !== void 0) return yield* forGood(final);
|
|
440
|
+
const refused = failure.code === "RESOURCE_EXHAUSTED" && halvedReasons.has(failure.context?.reason);
|
|
231
441
|
if (!seen.over && !refused) return yield* Effect.fail(failure);
|
|
232
|
-
if (!shallow || row.step === 1) return yield* forGood(overBudget(most));
|
|
233
|
-
yield*
|
|
234
|
-
|
|
235
|
-
|
|
442
|
+
if (!shallow || row.step === 1) return yield* forGood(seen.over ? overBudget(most) : leastRefused(failure, shallow));
|
|
443
|
+
return yield* unstaged(attempt, row, { step: halvedStep(row) }, halvingRaced);
|
|
444
|
+
});
|
|
445
|
+
/** The fields of `row` a segment's landing writes, as its fetch made them. */
|
|
446
|
+
const landsOf = ({ roots, deepest, step, copied, objects, bytes }) => ({
|
|
447
|
+
roots,
|
|
448
|
+
deepest,
|
|
449
|
+
step,
|
|
450
|
+
copied,
|
|
451
|
+
objects,
|
|
452
|
+
bytes
|
|
453
|
+
});
|
|
454
|
+
const stagingRaced = () => gitError("UNAVAILABLE", "Another write moved the import's record while its step staged", { hint: "The job tries again" });
|
|
455
|
+
const unsteppedPack = (pack) => gitError("INTERNAL", `The host's objects staged ${pack}, which is no pack ID`, { hint: "Report it" });
|
|
456
|
+
/**
|
|
457
|
+
* A segment's pack staged for its steps, and the record committed `receiving` it with the record
|
|
458
|
+
* its landing writes, in the store as it holds it now: the staging wrote the pack's quarantine row
|
|
459
|
+
* since the step's read. A record that another write ended or moved on is left as it is, and its
|
|
460
|
+
* staged pack to the quarantine's clean-up.
|
|
461
|
+
*/
|
|
462
|
+
const staged = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, staging) {
|
|
463
|
+
const { pack } = yield* staging.stage();
|
|
464
|
+
if (!isPackId(pack)) return yield* Effect.fail(unsteppedPack(pack));
|
|
465
|
+
const read = yield* readOwn(attempt);
|
|
466
|
+
const now = read.row;
|
|
467
|
+
const same = now?.state === "running" && now.step === row.step && now.deepest === row.deepest;
|
|
468
|
+
if (read.cancelled || now === void 0 || !same || now.receiving !== void 0) return;
|
|
469
|
+
if (!(yield* saved(attempt, read.version, {
|
|
470
|
+
...now,
|
|
471
|
+
receiving: {
|
|
472
|
+
pack,
|
|
473
|
+
lands: staging.lands()
|
|
474
|
+
}
|
|
475
|
+
})).ok) return yield* Effect.fail(stagingRaced());
|
|
476
|
+
});
|
|
477
|
+
/**
|
|
478
|
+
* Whether the receive of `pack` has a record at `joining`, which a join refused for its calls
|
|
479
|
+
* keeps for a try with more. A streaming step's refusal leaves its record at `streaming`, and no
|
|
480
|
+
* try of the same pack gets past it, so only a smaller segment can.
|
|
481
|
+
*/
|
|
482
|
+
const receiveJoining = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, pack) {
|
|
483
|
+
const { store } = yield* CoreParts;
|
|
484
|
+
const held = (yield* storeCall(() => store.read(repoScope(attempt.internalId), [receiveKey(pack)]))).results[0]?.[0];
|
|
485
|
+
if (held === void 0) return false;
|
|
486
|
+
const { value } = yield* decodeHeld(ReceiveRow, held);
|
|
487
|
+
return value.phase === "joining";
|
|
488
|
+
});
|
|
489
|
+
const notStepped = () => gitError("FAILED_PRECONDITION", "The import's segment is staged, but the host's objects have no steps", { hint: "Give the host objects that receive in steps, or import again" });
|
|
490
|
+
/**
|
|
491
|
+
* Step 2 again for a segment staged by an earlier try: one step of its receive, which fetches
|
|
492
|
+
* nothing. A paused step goes on in the next try. A received segment lands as a streamed one does,
|
|
493
|
+
* through a push with no ref, its record as its fetch made it and the cut its join read, in the
|
|
494
|
+
* commit that deletes its receive's record and puts its `staged` row. A refusal a smaller segment may mend halves the step,
|
|
495
|
+
* but a join's, `too-large` with its record kept, fails the try, whose next has fresh calls.
|
|
496
|
+
*/
|
|
497
|
+
const resumedIn = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, receiving, cut) {
|
|
498
|
+
const opened = yield* openedRepo(attempt);
|
|
499
|
+
if (opened === void 0) return void 0;
|
|
500
|
+
const { receiveStep } = syncObjects(yield* ObjectsParts);
|
|
501
|
+
if (receiveStep === void 0) return yield* forGood(notStepped());
|
|
502
|
+
yield* report(attempt.context, "receive", row);
|
|
503
|
+
const { pack, lands } = receiving;
|
|
504
|
+
const { needs, kept } = carriedCut(row.roots, lands.roots, cut);
|
|
505
|
+
const input = {
|
|
506
|
+
store: gitStore((yield* CoreParts).store),
|
|
507
|
+
pack,
|
|
508
|
+
objects: lands.objects - row.objects
|
|
509
|
+
};
|
|
510
|
+
if (needs.length > 0) input.needs = needs;
|
|
511
|
+
const stepped = yield* Effect.result(scopedReceiveStep(receiveStep, opened.listed, input));
|
|
512
|
+
if (Result.isFailure(stepped)) {
|
|
513
|
+
const { failure } = stepped;
|
|
514
|
+
if (failure.context?.reason === "stage-gone") {
|
|
515
|
+
if (row.restaged === true) return yield* forGood(stageGoneAgain());
|
|
516
|
+
return yield* unstaged(attempt, row, {
|
|
517
|
+
step: row.step,
|
|
518
|
+
restaged: true
|
|
519
|
+
}, restagingRaced);
|
|
520
|
+
}
|
|
521
|
+
const final = finalRefusal(failure);
|
|
522
|
+
if (final !== void 0) return yield* forGood(final);
|
|
523
|
+
if (!(failure.code === "RESOURCE_EXHAUSTED" && halvedReasons.has(failure.context?.reason))) return yield* Effect.fail(failure);
|
|
524
|
+
if (failure.context?.reason === "too-large" && (yield* receiveJoining(attempt, pack))) return yield* Effect.fail(failure);
|
|
525
|
+
const shallow = lands.deepest !== infiniteDepth;
|
|
526
|
+
if (!shallow || row.step === 1) return yield* forGood(leastRefused(failure, shallow));
|
|
527
|
+
return yield* unstaged(attempt, row, { step: halvedStep(row) }, halvingRaced);
|
|
528
|
+
}
|
|
529
|
+
const answer = stepped.success;
|
|
530
|
+
if ("paused" in answer) return more;
|
|
531
|
+
yield* push({
|
|
532
|
+
caller: attempt.bound.caller,
|
|
533
|
+
repo: opened.name,
|
|
534
|
+
internalId: attempt.internalId,
|
|
535
|
+
source: "import",
|
|
536
|
+
edits: [],
|
|
537
|
+
atomic: false,
|
|
538
|
+
pack: { received: answer.received },
|
|
539
|
+
also: (at, received) => {
|
|
540
|
+
const written = cutAfter(lands.roots, kept, received);
|
|
541
|
+
return {
|
|
542
|
+
put: [
|
|
543
|
+
importRow(landed(row, lands)),
|
|
544
|
+
stagedRow(pack, at, true),
|
|
545
|
+
...written.put
|
|
546
|
+
],
|
|
547
|
+
delete: [...written.delete, receiveKey(pack)],
|
|
548
|
+
jobs: []
|
|
549
|
+
};
|
|
550
|
+
},
|
|
551
|
+
guard: stillRunning
|
|
236
552
|
});
|
|
237
553
|
return more;
|
|
238
554
|
});
|
|
239
|
-
|
|
240
|
-
const
|
|
555
|
+
const resumed = (attempt, row, receiving, cut) => Effect.scoped(resumedIn(attempt, row, receiving, cut));
|
|
556
|
+
const cutRaced = () => gitError("UNAVAILABLE", "Another write moved the import's record while its cancel's step deleted its cut", { hint: "The job tries again" });
|
|
557
|
+
/** A halved segment's step: half the one refused, of one commit at least. */
|
|
558
|
+
const halvedStep = (row) => Math.max(1, Math.floor(row.step / 2));
|
|
559
|
+
const halvingRaced = () => gitError("UNAVAILABLE", "Another write moved the import's record while its step halved", { hint: "The job tries again" });
|
|
560
|
+
const restagingRaced = () => gitError("UNAVAILABLE", "Another write moved the import's record while its segment's stage went", { hint: "The job tries again" });
|
|
561
|
+
/**
|
|
562
|
+
* A segment whose stage clean-up ended twice: its steps wait out the quarantine's `prune` each
|
|
563
|
+
* time, so a third stage would too.
|
|
564
|
+
*/
|
|
565
|
+
const stageGoneAgain = () => gitError("FAILED_PRECONDITION", "Clean-up ended the quarantine of the import's segment twice before its steps received it", {
|
|
566
|
+
hint: "Import again once the host keeps a staged segment longer",
|
|
567
|
+
hostHint: "Give Objects.layer({ prune }) a prune longer than an import's tries, about 2 hours",
|
|
568
|
+
context: { reason: "stage-gone" }
|
|
569
|
+
});
|
|
570
|
+
/**
|
|
571
|
+
* The import's segment fetched again at `next.step`, marked `restaged` as `next` is, and its
|
|
572
|
+
* receive's record deleted, in its record as
|
|
573
|
+
* the store holds it now, not at the version the step read: a push the storage refused may have
|
|
574
|
+
* written the repo's rows since, such as its quarantine's, and a commit at that version would be
|
|
575
|
+
* refused, leaving the step to fetch the same segment again. A record that another write ended or
|
|
576
|
+
* moved on is left as it is; one that loses a race again fails the try with `raced`, which waits
|
|
577
|
+
* its backoff rather than fetch again at once.
|
|
578
|
+
*/
|
|
579
|
+
const unstaged = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, next, raced) {
|
|
580
|
+
const read = yield* readOwn(attempt);
|
|
581
|
+
const now = read.row;
|
|
582
|
+
const same = now?.state === "running" && now.step === row.step && now.deepest === row.deepest;
|
|
583
|
+
if (read.cancelled || now === void 0 || !same) return more;
|
|
584
|
+
const { receiving, restaged: _restaged, ...rest } = now;
|
|
585
|
+
const deletes = receiving === void 0 ? [] : [receiveKey(receiving.pack)];
|
|
586
|
+
if (!(yield* saved(attempt, read.version, {
|
|
587
|
+
...rest,
|
|
588
|
+
...next
|
|
589
|
+
}, deletes)).ok) return yield* Effect.fail(raced());
|
|
590
|
+
return more;
|
|
591
|
+
});
|
|
241
592
|
const movedUnder = (ref) => gitError("UNAVAILABLE", `Another write moved '${ref}' while the import published it`, { hint: "The job tries again, from the refs as they are then" });
|
|
242
593
|
/**
|
|
243
594
|
* Step 3: each ref moved to its tip and the import marked done, in one atomic commit. A ref another
|
|
244
595
|
* write moved first fails the try, and the next moves every ref from where it is then; a refusal
|
|
245
596
|
* of another kind fails it with that ref's own error.
|
|
246
597
|
*/
|
|
247
|
-
const publish = Effect.fnUntraced(function* (attempt, row) {
|
|
598
|
+
const publish = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row) {
|
|
248
599
|
const opened = yield* openedRepo(attempt);
|
|
249
600
|
if (opened === void 0) return void 0;
|
|
250
601
|
yield* report(attempt.context, "publish", row);
|
|
@@ -256,7 +607,7 @@ const publish = Effect.fnUntraced(function* (attempt, row) {
|
|
|
256
607
|
to
|
|
257
608
|
}];
|
|
258
609
|
});
|
|
259
|
-
const rejected = (yield* push(
|
|
610
|
+
const rejected = (yield* push({
|
|
260
611
|
caller: attempt.bound.caller,
|
|
261
612
|
repo: opened.name,
|
|
262
613
|
internalId: attempt.internalId,
|
|
@@ -268,55 +619,71 @@ const publish = Effect.fnUntraced(function* (attempt, row) {
|
|
|
268
619
|
...row,
|
|
269
620
|
state: "done"
|
|
270
621
|
})],
|
|
622
|
+
delete: importEndDeletes(row),
|
|
271
623
|
jobs: []
|
|
272
|
-
})
|
|
624
|
+
}),
|
|
625
|
+
guard: uncancelled
|
|
273
626
|
})).updates.flatMap((update) => update.kind === "rejected" ? [update] : []);
|
|
274
627
|
const [first] = rejected;
|
|
275
628
|
if (first === void 0) return void 0;
|
|
276
629
|
const now = (yield* openedRepo(attempt))?.refs;
|
|
277
630
|
const moved = edits.find((edit) => (now?.get(edit.ref) ?? null) !== edit.from);
|
|
278
631
|
if (moved !== void 0) return yield* Effect.fail(movedUnder(moved.ref));
|
|
279
|
-
const own = rejected.find((update) => update.error.
|
|
632
|
+
const own = rejected.find((update) => update.error.context?.reason !== "atomic-partner") ?? first;
|
|
280
633
|
return yield* Effect.fail(own.error);
|
|
281
634
|
});
|
|
282
635
|
/** One try's step, as the import's record says it's next. */
|
|
283
|
-
const
|
|
284
|
-
const read = yield*
|
|
636
|
+
const stepIn = /* @__PURE__ */ Effect.fnUntraced(function* (attempt) {
|
|
637
|
+
const read = yield* readOwn(attempt);
|
|
285
638
|
const { row } = read;
|
|
639
|
+
if (read.cancelled && (Object.keys(read.cut).length > 0 || row?.receiving !== void 0)) {
|
|
640
|
+
const { store } = yield* CoreParts;
|
|
641
|
+
if (!(yield* storeCall(() => store.commit(repoScope(attempt.internalId), {
|
|
642
|
+
id: newChangeId(),
|
|
643
|
+
expect: read.version,
|
|
644
|
+
delete: importEndDeletes(row)
|
|
645
|
+
}))).ok) return yield* Effect.fail(cutRaced());
|
|
646
|
+
}
|
|
286
647
|
if (row === void 0 || read.cancelled || row.state !== "running") return void 0;
|
|
648
|
+
if (row.receiving !== void 0) return yield* resumed(attempt, row, row.receiving, read.cut);
|
|
287
649
|
if (row.copied) return yield* publish(attempt, row);
|
|
288
650
|
const remote = yield* remoteOf(attempt.bound, row.source, attempt.context.signal);
|
|
289
651
|
if (row.tips === void 0) return yield* listTips(attempt, read.version, row, remote);
|
|
290
|
-
return yield* fetchSegment(attempt, read.
|
|
652
|
+
return yield* fetchSegment(attempt, row, read.cut, remote);
|
|
291
653
|
});
|
|
654
|
+
/**
|
|
655
|
+
* `stepIn`, with the record read again after a step that failed: once another write ended the
|
|
656
|
+
* import, the step ends with it, having written nothing, rather than count a try.
|
|
657
|
+
*/
|
|
658
|
+
const stepOf = (attempt) => Effect.catch(stepIn(attempt), (error) => Effect.flatMap(readOwn(attempt), ({ row }) => row === void 0 || row.state === "running" ? Effect.fail(error) : Effect.void));
|
|
292
659
|
/** `git.sync.import`'s handler over `bound`: a try's failure thrown as `SyncTryError`. */
|
|
293
660
|
const importTry = (bound) => (job, context) => {
|
|
294
661
|
const attempt = {
|
|
295
662
|
bound,
|
|
296
|
-
core: {
|
|
297
|
-
...bound.host,
|
|
298
|
-
store: context.store
|
|
299
|
-
},
|
|
300
663
|
internalId: jobRepo(job),
|
|
301
664
|
context
|
|
302
665
|
};
|
|
303
|
-
|
|
666
|
+
const step = asSync(overStore(context.store)(stepOf(attempt)));
|
|
667
|
+
return runTry(Effect.provideContext(step, bound.needs), context.signal);
|
|
304
668
|
};
|
|
305
|
-
/** What a failed import's error says to do: no try comes after the last, whatever it said. */
|
|
306
|
-
const failedHint = "Delete the repo, then import it again";
|
|
307
|
-
const stoppedTry = keptError(gitError("UNAVAILABLE", "The import's last try stopped", { hint: failedHint }));
|
|
308
669
|
/**
|
|
309
670
|
* The import's record marked failed with the last try's error, once the job is failed: read again
|
|
310
|
-
* after a commit another write beat, until the queue's bound on `onFailure` aborts the signal.
|
|
671
|
+
* after a commit another write beat, until the queue's bound on `onFailure` aborts the signal. A
|
|
672
|
+
* cancelled import keeps its record as the cancel left it, which reads as `cancelled`, even when
|
|
673
|
+
* the cancel is what failed the last try: only the keys its run kept go.
|
|
311
674
|
*/
|
|
312
675
|
const importFailed = async (job, { error }, context) => {
|
|
313
676
|
const internalId = jobRepo(job);
|
|
314
677
|
const passing = error instanceof SyncTryError && !error.permanent;
|
|
315
678
|
const last = error instanceof SyncTryError ? error.kept : stoppedTry;
|
|
316
|
-
const
|
|
679
|
+
const cut = {
|
|
317
680
|
...last,
|
|
681
|
+
message: cutWords(last.message, failedMessageMost)
|
|
682
|
+
};
|
|
683
|
+
const kept = passing ? {
|
|
684
|
+
...cut,
|
|
318
685
|
hint: failedHint
|
|
319
|
-
} :
|
|
686
|
+
} : cut;
|
|
320
687
|
const marked = Effect.gen(function* () {
|
|
321
688
|
for (;;) {
|
|
322
689
|
const read = yield* readImport(context.store, internalId);
|
|
@@ -325,10 +692,11 @@ const importFailed = async (job, { error }, context) => {
|
|
|
325
692
|
if ((yield* storeCall(() => context.store.commit(repoScope(internalId), {
|
|
326
693
|
id: newChangeId(),
|
|
327
694
|
expect: read.version,
|
|
328
|
-
put: [importRow(failedRow(row, kept))]
|
|
695
|
+
put: read.cancelled ? [] : [importRow(failedRow(row, kept))],
|
|
696
|
+
delete: importEndDeletes(row)
|
|
329
697
|
}))).ok) return;
|
|
330
698
|
}
|
|
331
699
|
});
|
|
332
700
|
await runIn(marked.pipe(Effect.mapError(thrownOf)), uncounted("a sync job's step: no request's, so only the platform's cap bounds it"), context.signal);
|
|
333
701
|
};
|
|
334
|
-
export {
|
|
702
|
+
export { advertisedFrom, importFailed, importTry };
|