@ref0/git 0.12.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access/private-refs.mjs +3 -3
- package/dist/auth/access-jwt.mjs +2 -2
- package/dist/auth/auth.d.mts +2 -2
- package/dist/auth/auth.mjs +3 -6
- package/dist/auth/authorize.mjs +4 -20
- package/dist/auth/fences.d.mts +1 -2
- package/dist/auth/fences.mjs +3 -3
- package/dist/auth/grants.mjs +4 -4
- package/dist/auth/helpers.mjs +3 -11
- package/dist/auth/host-function.mjs +18 -1
- package/dist/auth/host-services.mjs +11 -0
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +3 -3
- package/dist/auth/policy.d.mts +27 -7
- package/dist/auth/policy.mjs +8 -4
- package/dist/auth/token-cleanup.mjs +67 -0
- package/dist/auth/token-rows.mjs +1 -1
- package/dist/auth/token-text.mjs +9 -1
- package/dist/auth/tokens-base.d.mts +35 -0
- package/dist/auth/tokens-base.mjs +13 -0
- package/dist/auth/tokens-layer.d.mts +2 -28
- package/dist/auth/tokens-layer.mjs +6 -12
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +7 -17
- package/dist/auth/tokens.mjs +9 -87
- package/dist/auth.d.mts +1 -4
- package/dist/auth.mjs +1 -3
- package/dist/client/answer.mjs +21 -42
- package/dist/client/client.d.mts +2 -4
- package/dist/client/git-http.mjs +35 -11
- package/dist/client/local.mjs +14 -13
- package/dist/client/push-upload.mjs +39 -12
- package/dist/client/remote.mjs +95 -31
- package/dist/client/run-remote-helper.d.mts +1 -0
- package/dist/client/run-remote-helper.mjs +58 -24
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +105 -46
- package/dist/contracts/access.d.mts +8 -8
- package/dist/contracts/actors.d.mts +2 -34
- package/dist/contracts/blobs.d.mts +57 -10
- package/dist/contracts/blobs.mjs +16 -2
- package/dist/contracts/call-allowance.d.mts +13 -0
- package/dist/contracts/call-allowance.mjs +44 -0
- package/dist/contracts/calls-spent.mjs +8 -3
- package/dist/contracts/client.d.mts +23 -19
- package/dist/contracts/commits.d.mts +34 -26
- package/dist/contracts/commits.mjs +9 -1
- package/dist/contracts/engine.d.mts +6 -1
- package/dist/contracts/engine.mjs +10 -1
- package/dist/contracts/files.d.mts +12 -12
- package/dist/contracts/forks.d.mts +27 -17
- package/dist/contracts/git-events.d.mts +29 -1
- package/dist/contracts/git-hooks.d.mts +1 -1
- package/dist/contracts/git.d.mts +39 -7
- package/dist/contracts/git.mjs +3 -2
- package/dist/contracts/grants.d.mts +24 -4
- package/dist/contracts/handlers.d.mts +1 -1
- package/dist/contracts/lfs.d.mts +28 -9
- package/dist/contracts/merges.d.mts +3 -2
- package/dist/contracts/objects.d.mts +103 -35
- package/dist/contracts/operations.d.mts +3 -0
- package/dist/contracts/operations.mjs +12 -2
- package/dist/contracts/push-uploads.d.mts +44 -5
- package/dist/contracts/push-uploads.mjs +7 -3
- package/dist/contracts/queue.d.mts +40 -12
- package/dist/contracts/queue.mjs +3 -4
- package/dist/contracts/refs.d.mts +50 -25
- package/dist/contracts/remote.d.mts +6 -7
- package/dist/contracts/remote.mjs +5 -4
- package/dist/contracts/repo-records.d.mts +1 -0
- package/dist/contracts/repos.d.mts +106 -127
- package/dist/contracts/repos.mjs +33 -4
- package/dist/contracts/result.d.mts +49 -25
- package/dist/contracts/result.mjs +52 -11
- package/dist/contracts/rules.d.mts +22 -22
- package/dist/contracts/server.d.mts +37 -111
- package/dist/contracts/services.d.mts +1 -1
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/store.d.mts +6 -5
- package/dist/contracts/sync.d.mts +90 -26
- package/dist/contracts/sync.mjs +45 -11
- package/dist/contracts/tags.d.mts +10 -10
- package/dist/contracts/time.d.mts +3 -0
- package/dist/contracts/{promises.mjs → time.mjs} +1 -1
- package/dist/contracts/tokens.d.mts +15 -22
- package/dist/contracts/tokens.mjs +3 -3
- package/dist/contracts/topics.d.mts +1 -6
- package/dist/contracts/trees.d.mts +12 -12
- package/dist/contracts/work.d.mts +87 -12
- package/dist/contracts/work.mjs +8 -1
- package/dist/core/access.d.mts +1 -2
- package/dist/core/access.mjs +46 -13
- package/dist/core/ancestry.d.mts +10 -0
- package/dist/core/ancestry.mjs +6 -6
- package/dist/core/asked.mjs +43 -5
- package/dist/core/call-names.mjs +7 -1
- package/dist/core/call-services.mjs +13 -4
- package/dist/core/events/deliver.d.mts +1 -2
- package/dist/core/events/deliver.mjs +48 -33
- package/dist/core/events/retired.mjs +119 -0
- package/dist/core/forks.mjs +931 -435
- package/dist/core/hooks/groups.mjs +1 -1
- package/dist/core/imports.mjs +159 -15
- package/dist/core/index-job.mjs +128 -37
- package/dist/core/index-lost.d.mts +1 -2
- package/dist/core/index-lost.mjs +2 -2
- package/dist/core/job-view.mjs +8 -9
- package/dist/core/loose-tally.mjs +1 -1
- package/dist/core/mirror-rows.mjs +19 -4
- package/dist/core/objects/blobs.mjs +129 -3
- package/dist/core/objects/commits.mjs +16 -6
- package/dist/core/objects/lines.mjs +2 -2
- package/dist/core/objects/merges.mjs +4 -1
- package/dist/core/objects/objects-layer.d.mts +1 -1
- package/dist/core/objects/objects-layer.mjs +3 -3
- package/dist/core/objects/reading.mjs +24 -13
- package/dist/core/objects/tags.mjs +4 -1
- package/dist/core/objects/trees.mjs +2 -2
- package/dist/core/objects/writing.mjs +2 -2
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +10 -6
- package/dist/core/parts.mjs +3 -11
- package/dist/core/promise.mjs +9 -12
- package/dist/core/purge.mjs +316 -42
- package/dist/core/push-decide.mjs +3 -1
- package/dist/core/push-files.d.mts +12 -0
- package/dist/core/push-files.mjs +225 -0
- package/dist/core/push-repo.d.mts +8 -0
- package/dist/core/push-repo.mjs +56 -0
- package/dist/core/push.d.mts +17 -0
- package/dist/core/push.mjs +153 -70
- package/dist/core/receipts.mjs +34 -13
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +61 -7
- package/dist/core/refs.mjs +18 -13
- package/dist/core/registered-rows.mjs +2 -2
- package/dist/core/repack.mjs +46 -28
- package/dist/core/repo-info.mjs +19 -12
- package/dist/core/repos.mjs +50 -22
- package/dist/core/rules/commit-changes.d.mts +0 -1
- package/dist/core/saved-caller-views.d.mts +7 -2
- package/dist/core/saved-caller-views.mjs +2 -2
- package/dist/core/saved-callers.d.mts +19 -2
- package/dist/core/seam.d.mts +16 -26
- package/dist/core/seam.mjs +7 -28
- package/dist/core/tokens.mjs +1 -1
- package/dist/core/view.d.mts +6 -0
- package/dist/core/view.mjs +51 -26
- package/dist/core/work.mjs +105 -35
- package/dist/effect.d.mts +5 -12
- package/dist/effect.mjs +3 -10
- package/dist/engine/failures.mjs +2 -1
- package/dist/engine/reads.mjs +17 -10
- package/dist/engine/walk.mjs +4 -4
- 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 +3 -3
- package/dist/event-streams/stream.mjs +38 -15
- package/dist/extend.d.mts +4 -5
- package/dist/extend.mjs +3 -2
- package/dist/http/answers.mjs +12 -7
- package/dist/http/core-parts.mjs +129 -64
- package/dist/http/handler.mjs +36 -9
- package/dist/http/node.d.mts +14 -1
- package/dist/http/node.mjs +61 -31
- package/dist/http/parts.d.mts +2 -0
- package/dist/http/push-upload-job.mjs +507 -0
- package/dist/http/push-uploads.d.mts +1 -0
- package/dist/http/push-uploads.mjs +142 -69
- package/dist/http/upload-pack.mjs +10 -9
- package/dist/index.d.mts +27 -28
- package/dist/index.mjs +5 -8
- package/dist/lfs/answer.mjs +37 -0
- package/dist/lfs/base.d.mts +9 -3
- package/dist/lfs/base.mjs +27 -2
- package/dist/lfs/copy.d.mts +60 -0
- package/dist/lfs/copy.mjs +109 -0
- package/dist/lfs/layer.d.mts +15 -1
- package/dist/lfs/layer.mjs +28 -13
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +7 -0
- package/dist/lfs/objects.mjs +152 -55
- package/dist/lfs/pointers.mjs +2 -2
- package/dist/lfs/rows.d.mts +13 -0
- package/dist/lfs/rows.mjs +42 -8
- package/dist/lfs/service.d.mts +1 -7
- package/dist/lfs/service.mjs +1 -9
- package/dist/lfs/upkeep.mjs +48 -14
- package/dist/lfs/upload-most.mjs +5 -5
- package/dist/lfs/wire.mjs +6 -31
- package/dist/merges/merges.mjs +2 -2
- package/dist/node.d.mts +3 -3
- package/dist/protocol/bytes/buffers.mjs +13 -5
- package/dist/protocol/bytes/reader.mjs +6 -1
- package/dist/protocol/bytes/sha256-hasher.d.mts +15 -0
- package/dist/protocol/bytes/sha256.d.mts +32 -0
- package/dist/protocol/bytes/sha256.mjs +105 -49
- package/dist/protocol/bytes/streams.mjs +27 -1
- package/dist/protocol/diff/read.d.mts +4 -3
- package/dist/protocol/diff/read.mjs +8 -3
- package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
- package/dist/protocol/objects/lfs-pointer.mjs +1 -3
- package/dist/protocol/objects/links-raw.mjs +24 -10
- package/dist/protocol/objects/tag.d.mts +1 -1
- package/dist/protocol/objects/tree.mjs +23 -6
- package/dist/protocol/packs/delta.d.mts +6 -3
- package/dist/protocol/packs/delta.mjs +96 -32
- package/dist/protocol/packs/idx.d.mts +2 -1
- package/dist/protocol/packs/idx.mjs +22 -3
- package/dist/protocol/packs/parts.d.mts +4 -1
- package/dist/protocol/packs/parts.mjs +10 -7
- package/dist/protocol/packs/reader.d.mts +5 -0
- package/dist/protocol/packs/reader.mjs +3 -2
- package/dist/protocol/packs/writer.mjs +26 -8
- package/dist/protocol/wire/advertisement.mjs +9 -4
- package/dist/protocol/wire/lines.d.mts +4 -2
- package/dist/protocol/wire/lines.mjs +11 -5
- package/dist/protocol/wire/push-uploads.mjs +13 -1
- package/dist/protocol/wire/v2.mjs +2 -2
- package/dist/protocol.d.mts +3 -1
- package/dist/protocol.mjs +3 -1
- package/dist/queue/advance.mjs +22 -25
- package/dist/queue/base.d.mts +55 -0
- package/dist/queue/base.mjs +44 -0
- package/dist/queue/calls.mjs +51 -54
- package/dist/queue/commit.mjs +1 -1
- package/dist/queue/host.d.mts +2 -22
- package/dist/queue/host.mjs +2 -13
- package/dist/queue/layer.d.mts +2 -1
- package/dist/queue/layer.mjs +11 -4
- package/dist/queue/limits.mjs +2 -0
- package/dist/queue/push-option.mjs +9 -24
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/state.mjs +2 -10
- package/dist/queue/trim.mjs +6 -4
- package/dist/rest/blobs.mjs +29 -5
- package/dist/rest/caller.d.mts +4 -4231
- package/dist/rest/caller.mjs +5 -1
- package/dist/rest/client.d.mts +15 -5
- package/dist/rest/client.mjs +23 -2
- package/dist/rest/events.mjs +1 -2
- package/dist/rest/handler.mjs +4 -57
- package/dist/rest/handlers.mjs +68 -9
- package/dist/rest/layer.d.mts +2 -2
- package/dist/rest/layer.mjs +7 -13
- package/dist/rest/me.d.mts +3 -428
- package/dist/rest/paths.mjs +1 -0
- package/dist/rest/work.mjs +8 -0
- package/dist/server/check-fetch.mjs +3 -3
- package/dist/server/edge-node.d.mts +14 -15
- package/dist/server/edge-node.mjs +12 -12
- package/dist/server/edge.d.mts +21 -7
- package/dist/server/edge.mjs +32 -11
- package/dist/server/extension.mjs +1 -1
- package/dist/server/git-layer.d.mts +6 -11
- package/dist/server/git-layer.mjs +29 -23
- package/dist/server/git-namespace.d.mts +5 -4
- package/dist/server/git-namespace.mjs +3 -2
- package/dist/server/joined.d.mts +21 -40
- package/dist/server/joined.mjs +11 -62
- package/dist/server/lifecycle.mjs +65 -69
- package/dist/server/registry.mjs +28 -3
- package/dist/server/server.mjs +245 -465
- package/dist/signin/context.d.mts +1 -2
- package/dist/signin/layer.d.mts +1 -1
- package/dist/signin/layer.mjs +1 -1
- package/dist/storage/allotted.mjs +18 -3
- package/dist/storage/batch-upkeep.mjs +274 -0
- package/dist/{core/purge.d.mts → storage/batches.d.mts} +4 -4
- package/dist/storage/batches.mjs +344 -0
- package/dist/storage/budget.mjs +2 -2
- package/dist/storage/calls.d.mts +1 -2
- package/dist/storage/calls.mjs +144 -158
- package/dist/storage/chunks.d.mts +9 -0
- package/dist/storage/chunks.mjs +297 -0
- package/dist/storage/clean-up.mjs +85 -19
- package/dist/storage/counted-bucket.mjs +4 -4
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +298 -216
- package/dist/storage/file-limits.mjs +24 -0
- package/dist/storage/host-bucket.mjs +1 -2
- package/dist/storage/id-mix.mjs +19 -5
- package/dist/storage/index-bitmaps.mjs +9 -2
- package/dist/storage/index-build.d.mts +1 -1
- package/dist/storage/index-build.mjs +185 -84
- package/dist/storage/index-fetch.mjs +128 -74
- package/dist/storage/index-files.d.mts +3 -0
- package/dist/storage/index-files.mjs +10 -5
- package/dist/storage/index-graph.mjs +72 -22
- package/dist/storage/index-reach.mjs +33 -5
- package/dist/storage/index-remap.mjs +208 -65
- package/dist/storage/index-shallow.mjs +5 -3
- package/dist/storage/index-whole.mjs +127 -0
- package/dist/storage/largest-files.mjs +48 -0
- package/dist/storage/layout.mjs +23 -0
- package/dist/storage/lfs-pointers.mjs +10 -1
- package/dist/storage/loose.d.mts +7 -4
- package/dist/storage/loose.mjs +214 -67
- package/dist/storage/memory-budget.mjs +44 -8
- package/dist/storage/merge-plan.mjs +3 -2
- package/dist/storage/merge-row.mjs +7 -1
- package/dist/storage/merge-stream.mjs +164 -25
- package/dist/storage/merge-walk.mjs +8 -4
- package/dist/storage/merge-write.mjs +1 -1
- package/dist/storage/merge.d.mts +1 -1
- package/dist/storage/merge.mjs +1 -1
- package/dist/storage/object-rows.d.mts +1 -0
- package/dist/storage/object-rows.mjs +385 -65
- package/dist/storage/oid-table.mjs +171 -0
- package/dist/storage/pack-order.mjs +8 -4
- package/dist/storage/pack-ranges.d.mts +1 -2
- package/dist/storage/pack-ranges.mjs +4 -5
- package/dist/storage/pack-reads.d.mts +2 -1
- package/dist/storage/pack-reads.mjs +165 -49
- package/dist/storage/pack-receive.d.mts +1 -1
- package/dist/storage/pack-receive.mjs +85 -27
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +172 -86
- package/dist/storage/placed-reads.mjs +1 -1
- package/dist/storage/plan-columns.d.mts +4 -0
- package/dist/storage/plan-columns.mjs +238 -0
- package/dist/storage/prune-keep.mjs +299 -37
- package/dist/storage/prune-walk.mjs +240 -62
- package/dist/storage/prune.mjs +749 -213
- package/dist/storage/push-allotment.mjs +91 -12
- package/dist/storage/push-uploads.mjs +40 -16
- package/dist/storage/pushed-commits.mjs +4 -2
- package/dist/storage/quarantine.d.mts +1 -1
- package/dist/storage/quarantine.mjs +9 -9
- package/dist/storage/range-cache.mjs +125 -8
- package/dist/storage/ready.d.mts +1 -1
- package/dist/storage/ready.mjs +55 -25
- package/dist/storage/receive-bounds.mjs +51 -15
- package/dist/storage/receive-state.mjs +8 -0
- package/dist/storage/receive-steps.mjs +71 -18
- package/dist/storage/repack-backlog.mjs +6 -3
- package/dist/storage/repack.d.mts +2 -2
- package/dist/storage/repack.mjs +1 -8
- package/dist/storage/rows.d.mts +1 -1
- package/dist/storage/rows.mjs +13 -2
- package/dist/storage/runs.mjs +195 -43
- package/dist/storage/send-list.d.mts +1 -0
- package/dist/storage/send-list.mjs +54 -10
- package/dist/storage/shallow.d.mts +1 -0
- package/dist/storage/shallow.mjs +26 -4
- package/dist/storage/single-flight.mjs +13 -7
- package/dist/storage/stream-whole.mjs +132 -28
- package/dist/storage/unpack.mjs +371 -79
- package/dist/storage/visible.mjs +31 -3
- package/dist/storage/walk.mjs +194 -39
- package/dist/storage/wants.mjs +5 -5
- package/dist/store/bodies.mjs +38 -0
- package/dist/store/call-count.d.mts +8 -12
- package/dist/store/call-count.mjs +34 -46
- package/dist/store/catalogue.d.mts +2 -2
- package/dist/store/catalogue.mjs +146 -35
- package/dist/store/crossing.mjs +1 -3
- package/dist/store/cursor-seal-namespace.d.mts +2 -0
- package/dist/store/cursor-seal-public.d.mts +5 -0
- package/dist/store/cursor-seal-public.mjs +5 -0
- package/dist/store/cursor-seal.d.mts +16 -3
- package/dist/store/cursor-seal.mjs +40 -18
- package/dist/store/door.mjs +183 -0
- package/dist/store/errors.d.mts +3 -4
- package/dist/store/errors.mjs +24 -34
- package/dist/store/git-store.mjs +25 -7
- package/dist/store/job-try.mjs +9 -32
- package/dist/store/list-job.mjs +44 -8
- package/dist/store/records.d.mts +5 -0
- package/dist/store/records.mjs +12 -6
- package/dist/store/repo-record.d.mts +10 -9
- package/dist/store/repo-record.mjs +123 -28
- package/dist/store/reservations.mjs +1 -1
- package/dist/store/scopes.mjs +21 -2
- package/dist/store/settle.mjs +4 -4
- package/dist/sync/bound.d.mts +2 -0
- package/dist/sync/bound.mjs +11 -2
- package/dist/sync/github.d.mts +6 -1
- package/dist/sync/github.mjs +56 -44
- package/dist/sync/http.mjs +36 -1
- package/dist/sync/import.mjs +32 -18
- package/dist/sync/layer.mjs +6 -2
- package/dist/sync/lfs-batch.mjs +118 -0
- package/dist/sync/lfs-copy.mjs +262 -0
- package/dist/sync/mirror.mjs +227 -151
- package/dist/sync/said.mjs +16 -37
- package/dist/sync/smart-http.mjs +4 -2
- package/dist/sync/step.mjs +58 -30
- package/dist/sync/tries.mjs +52 -21
- package/dist/sync.d.mts +2 -2
- package/dist/topics/advance.mjs +10 -11
- package/dist/topics/base.d.mts +15 -0
- package/dist/topics/base.mjs +8 -0
- package/dist/topics/host.mjs +2 -20
- package/dist/topics/layer.d.mts +4 -9
- package/dist/topics/layer.mjs +3 -4
- package/dist/topics/members.mjs +4 -4
- package/dist/topics/public.d.mts +2 -1
- package/dist/topics/topic.mjs +2 -2
- package/package.json +5 -9
- package/dist/auth/bridge.mjs +0 -30
- package/dist/auth/helpers.d.mts +0 -17
- package/dist/contracts/promises.d.mts +0 -39
- package/dist/core/call-names.d.mts +0 -3
- package/dist/core/clock.mjs +0 -18
- package/dist/core/registered-rows.d.mts +0 -5
- package/dist/core/repack.d.mts +0 -11
- package/dist/http/handler.d.mts +0 -2
- package/dist/lfs/calls.mjs +0 -26
- package/dist/rest/api.d.mts +0 -23
- package/dist/rest/blobs.d.mts +0 -825
- package/dist/rest/commits.d.mts +0 -3510
- package/dist/rest/errors.d.mts +0 -2104
- package/dist/rest/events.d.mts +0 -423
- package/dist/rest/files.d.mts +0 -1330
- package/dist/rest/forks.d.mts +0 -2136
- package/dist/rest/handler.d.mts +0 -21
- package/dist/rest/handlers.d.mts +0 -8
- package/dist/rest/merges.d.mts +0 -473
- package/dist/rest/queue.d.mts +0 -5861
- package/dist/rest/refs.d.mts +0 -2959
- package/dist/rest/repos.d.mts +0 -2539
- package/dist/rest/tags.d.mts +0 -1304
- package/dist/rest/tokens.d.mts +0 -2590
- package/dist/rest/topics.d.mts +0 -2204
- package/dist/rest/trees.d.mts +0 -1693
- package/dist/rest/work.d.mts +0 -1248
- package/dist/rest.d.mts +0 -2
- package/dist/rest.mjs +0 -1
- package/dist/server/lifecycle.d.mts +0 -2
- package/dist/server/registry.d.mts +0 -16
- package/dist/server/server.d.mts +0 -36
- package/dist/storage/repack-job.d.mts +0 -3
- package/dist/store/promises.d.mts +0 -11
- package/dist/store/promises.mjs +0 -327
- package/dist/topics/host.d.mts +0 -7
package/dist/core/promise.mjs
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import { answerSpent } from "../store/errors.mjs";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Schema from "effect/Schema";
|
|
4
|
-
|
|
5
|
-
const hasSignal = /* @__PURE__ */ Schema.is(Schema.Struct({ signal: Schema.instanceOf(AbortSignal) }));
|
|
6
|
-
/** The `signal` a call's last argument holds: its input, which comes last in every call. */
|
|
7
|
-
const signalOf = (args) => {
|
|
8
|
-
const input = args.at(-1);
|
|
9
|
-
return hasSignal(input) ? input.signal : void 0;
|
|
10
|
-
};
|
|
4
|
+
Schema.Struct({ signal: Schema.instanceOf(AbortSignal) });
|
|
11
5
|
const isCall = (value) => value instanceof Function;
|
|
12
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* `calls`, each call's Effect as `around` makes it, with the same inputs and answer. A call reads its
|
|
8
|
+
* input only once its run starts, so a door `around` puts first answers before a bad input throws.
|
|
9
|
+
*/
|
|
13
10
|
const aroundCalls = (calls, around) => {
|
|
14
11
|
const entries = Object.entries(calls).map(([name, value]) => {
|
|
15
12
|
if (!isCall(value)) return [name, aroundCalls(value, around)];
|
|
16
|
-
const call = (...args) => around(value(...args));
|
|
13
|
+
const call = (...args) => around(Effect.suspend(() => value(...args)));
|
|
17
14
|
return [name, call];
|
|
18
15
|
});
|
|
19
16
|
return Object.fromEntries(entries);
|
|
@@ -28,8 +25,8 @@ const noDoor = (effect) => effect;
|
|
|
28
25
|
/**
|
|
29
26
|
* `effect` run `through` the server's door: an edge a host calls, where a spent call bound is
|
|
30
27
|
* answered as its refusal, never a defect. The door refuses once the server is closed and stops
|
|
31
|
-
* the run as it closes
|
|
32
|
-
* a joined package's `effectRun` and `effectCallsFor` among them (Q830).
|
|
28
|
+
* the run as it closes; the client, with no server, passes `noDoor`. Every Effect face's call goes
|
|
29
|
+
* through it, a joined package's `effectRun` and `effectCallsFor` among them (Q830).
|
|
33
30
|
*/
|
|
34
31
|
const guardedCall = (through) => (effect) => through(answerSpent(effect));
|
|
35
32
|
/** `calls`, each a seam's call that `guardedCall` runs `through` the server's door. */
|
|
@@ -71,4 +68,4 @@ const callOf = (calls, group, name) => {
|
|
|
71
68
|
if (!isCall(found)) throw new TypeError(`The server has no call ${group}.${name}`);
|
|
72
69
|
return found;
|
|
73
70
|
};
|
|
74
|
-
export { aroundCalls, callOf, callOrMissing, guardedCall, guardedCalls, heldGroup, lazyGroups, noDoor, providedCalls
|
|
71
|
+
export { aroundCalls, callOf, callOrMissing, guardedCall, guardedCalls, heldGroup, lazyGroups, noDoor, providedCalls };
|
package/dist/core/purge.mjs
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
+
import { gitError, isGitError } from "../contracts/result.mjs";
|
|
1
2
|
import { repackJobName } from "../storage/repack-job.mjs";
|
|
2
3
|
import { objectCollections } from "../storage/layout.mjs";
|
|
3
4
|
import { tooLargeRead } from "../storage/object-rows.mjs";
|
|
4
5
|
import { forkedFrom, reconcile, releaseHold } from "../store/catalogue.mjs";
|
|
5
|
-
import { storeCall } from "../store/errors.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { storeCall, storeCommit } from "../store/errors.mjs";
|
|
7
|
+
import { currentRepo, gitJob } from "../store/job-try.mjs";
|
|
7
8
|
import { outboxCollections } from "../store/outbox.mjs";
|
|
8
9
|
import { keyKept } from "../store/records.mjs";
|
|
9
10
|
import { readRecord } from "../store/repo-record.mjs";
|
|
10
11
|
import { collections, newChangeId, repoScope } from "../store/scopes.mjs";
|
|
11
|
-
import { isDeliverJob, sentThrough } from "./events/deliver.mjs";
|
|
12
|
+
import { droppedDelivery, isDeliverJob, notFailed, sentThrough } from "./events/deliver.mjs";
|
|
13
|
+
import { retiredAmong } from "./events/retired.mjs";
|
|
12
14
|
import { indexJobName } from "./index-job.mjs";
|
|
13
15
|
import * as Effect from "effect/Effect";
|
|
14
16
|
import * as Schema from "effect/Schema";
|
|
15
|
-
import { Job, limits } from "@ref0/infra";
|
|
17
|
+
import { Job, defineJob, limits } from "@ref0/infra";
|
|
16
18
|
// src/core/purge.ts
|
|
17
19
|
/**
|
|
18
20
|
* `git.purge`, a deleted repo's last job (L61, L130). Not before its delete's `fetchLimits` has
|
|
@@ -39,6 +41,32 @@ const purgeBackstop = 6e5;
|
|
|
39
41
|
*/
|
|
40
42
|
const purgeRunningRelook = 6e4;
|
|
41
43
|
/**
|
|
44
|
+
* How long a purge waits without progress on a stalled or unowned blocker (an orphaned drained
|
|
45
|
+
* row with no drain job, a failed drain job, an unretired dropped delivery, a missing fork record,
|
|
46
|
+
* or a deleted fork whose `git.purge` has failed or is absent) before failing permanently (#2685).
|
|
47
|
+
*/
|
|
48
|
+
const purgeStallLimit = 72e5;
|
|
49
|
+
/**
|
|
50
|
+
* How long a purge waits without progress while an active drain job (`git.repack`, `git.index`, an
|
|
51
|
+
* active delivery, or a running retired delivery) is waiting or running, while a registration
|
|
52
|
+
* purge part answers `waits`, while a deleted fork's own `git.purge` still stands non-failed, or
|
|
53
|
+
* while a fork-hold walk hits its check limit with holds unchecked, before failing permanently:
|
|
54
|
+
* past `defaultDeliverRetry`'s 3-day window and `@ref0/github`'s 24 h 5 m multipart release upload
|
|
55
|
+
* window so legitimate work finishes without changing exported `PurgeStep` (#2685).
|
|
56
|
+
*/
|
|
57
|
+
const purgeDrainLimit = 3456e5;
|
|
58
|
+
/** How many blocking drain jobs a stuck error names at most. */
|
|
59
|
+
const stuckNamesMost = 8;
|
|
60
|
+
/** Built-in retry bounds for transient purge failures (store errors, failed drops). */
|
|
61
|
+
const purgeRetryLimit = 20;
|
|
62
|
+
const purgeRetryDelay = 1e3;
|
|
63
|
+
const purgeRetryMaxDelay = 3e5;
|
|
64
|
+
/**
|
|
65
|
+
* The lease a purge claims a dropped delivery's waiting job under, only to settle it done in the
|
|
66
|
+
* same try: no handler runs under it.
|
|
67
|
+
*/
|
|
68
|
+
const droppedLease = "1 minute";
|
|
69
|
+
/**
|
|
42
70
|
* A step's page where its rows passed one read's `limits.answerBytes`, as object rows can: rows
|
|
43
71
|
* of `limits.valueBytes` each fill half an answer.
|
|
44
72
|
*/
|
|
@@ -49,7 +77,10 @@ const purgeLargePage = /* @__PURE__ */ Math.floor(limits.answerBytes / limits.va
|
|
|
49
77
|
* deletes its index's files, and each delivery's, `git.deliver.<name>`, sends `repo.deleted`. A
|
|
50
78
|
* failed one holds the purge until a host retries or discards it. A delivery's waiting job that
|
|
51
79
|
* has sent `repo.deleted` holds it no longer, since it waits only to trim events the purge
|
|
52
|
-
* deletes itself. A
|
|
80
|
+
* deletes itself. A retired delivery's, one the host names in `events.retired`, holds it only
|
|
81
|
+
* while a try of it runs, on an instance that still runs it in a deploy: then the purge claims it,
|
|
82
|
+
* and ends it if its row is there under the claim, as `endDropped` says. A delivery the server
|
|
83
|
+
* doesn't run and the host hasn't retired holds it as any delivery's does. A new job that deletes a repo's bytes joins this list, or its check below.
|
|
53
84
|
* Every other job ends on the record the purge deletes last: git.list's projection the purge runs
|
|
54
85
|
* itself before it.
|
|
55
86
|
*/
|
|
@@ -96,6 +127,11 @@ const purgeCollections = [
|
|
|
96
127
|
collections.upkeep,
|
|
97
128
|
collections.stats,
|
|
98
129
|
objectCollections.objects,
|
|
130
|
+
objectCollections.stagedObjects,
|
|
131
|
+
objectCollections.stagedSizes,
|
|
132
|
+
objectCollections.objectChunks,
|
|
133
|
+
objectCollections.batches,
|
|
134
|
+
objectCollections.batchQuarantine,
|
|
99
135
|
objectCollections.cruft,
|
|
100
136
|
objectCollections.prune,
|
|
101
137
|
objectCollections.index,
|
|
@@ -110,42 +146,177 @@ const purgeCollections = [
|
|
|
110
146
|
const purgeJobName = "git.purge";
|
|
111
147
|
/** The repo's one `git.purge` row. */
|
|
112
148
|
const purgeJobKey = "purge";
|
|
113
|
-
const
|
|
149
|
+
const WaitKind = /* @__PURE__ */ Schema.Literals(["drain", "stall"]);
|
|
150
|
+
/**
|
|
151
|
+
* No-progress tracking carried across `more` steps: `since` and `wait` bound scheduled post-guard
|
|
152
|
+
* waits (`purgeDrainLimit` for active drain jobs, `purgeStallLimit` for stalled/unowned blockers),
|
|
153
|
+
* and `spins` bounds consecutive immediate-retry misses (`purgeSpinTries`). Every field is optional
|
|
154
|
+
* so `{}` rows decode unchanged, and genuine progress clears all three back to `{}` (#2685).
|
|
155
|
+
*/
|
|
156
|
+
const PurgeData = /* @__PURE__ */ Schema.Struct({
|
|
157
|
+
since: Schema.optionalKey(Schema.Number),
|
|
158
|
+
wait: Schema.optionalKey(WaitKind),
|
|
159
|
+
spins: Schema.optionalKey(Schema.Int)
|
|
160
|
+
});
|
|
114
161
|
const again = { kind: "more" };
|
|
162
|
+
const hasStuckState = (data) => data.since !== void 0 || data.wait !== void 0 || data.spins !== void 0;
|
|
163
|
+
/** Genuine progress made: clears prior stall/spin tracking when any was set. */
|
|
164
|
+
const progressed = (data) => hasStuckState(data) ? {
|
|
165
|
+
kind: "more",
|
|
166
|
+
data: {}
|
|
167
|
+
} : again;
|
|
168
|
+
/** Permanent `git.purge` refusal naming the blocker and the host-level `jobs.retry` recovery path. */
|
|
169
|
+
const purgeStuck = (scope, blocker, detail) => gitError("FAILED_PRECONDITION", `${purgeJobName} of ${scope} is stuck on ${detail}: clear the blocker, then call jobs.retry('${scope}', { name: '${purgeJobName}', key: '${purgeJobKey}' })`, { context: {
|
|
170
|
+
reason: "purge-stuck",
|
|
171
|
+
blocker
|
|
172
|
+
} });
|
|
173
|
+
/** Whether `failure` is a permanent `purge-stuck` refusal, which `purgeRetry` never retries. */
|
|
174
|
+
const isPurgeStuck = (failure) => isGitError(failure.error) && failure.error.code === "FAILED_PRECONDITION" && failure.error.context?.["reason"] === "purge-stuck";
|
|
175
|
+
/** A random share of a wait, at least 0 and under 1, from `crypto.getRandomValues`. */
|
|
176
|
+
const randomShare = () => (crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(1))[0] ?? 0) / 2 ** 32;
|
|
177
|
+
/**
|
|
178
|
+
* `git.purge`'s retry policy: a stuck refusal fails immediately with no further tries, while
|
|
179
|
+
* transient store or drop errors keep the built-in 20-try exponential backoff (1 s to 5 min).
|
|
180
|
+
*/
|
|
181
|
+
const purgeRetry = (failure) => {
|
|
182
|
+
if (isPurgeStuck(failure)) return false;
|
|
183
|
+
if (failure.attempt >= purgeRetryLimit) return false;
|
|
184
|
+
const wait = Math.min(purgeRetryMaxDelay, purgeRetryDelay * 2 ** (failure.attempt - 1));
|
|
185
|
+
return Math.round(wait / 2 + wait / 2 * randomShare());
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* One scheduled post-guard wait of `kind` (`'stall'` or `'drain'`), due at `nextAt`: records
|
|
189
|
+
* `since` on the first wait of that kind, clamps the next look to `since + limit` so a far due
|
|
190
|
+
* time cannot overshoot the cap, and fails permanently once `at - since` reaches its limit.
|
|
191
|
+
*/
|
|
192
|
+
const waitOrFail = (scope, data, at, nextAt, kind, blocker, detail) => {
|
|
193
|
+
const limit = kind === "drain" ? purgeDrainLimit : purgeStallLimit;
|
|
194
|
+
const since = data.wait === kind && data.since !== void 0 ? data.since : at;
|
|
195
|
+
if (at - since >= limit) return Effect.fail(purgeStuck(scope, blocker, detail));
|
|
196
|
+
return Effect.succeed({
|
|
197
|
+
kind: "more",
|
|
198
|
+
at: Math.min(nextAt, since + limit),
|
|
199
|
+
data: {
|
|
200
|
+
since,
|
|
201
|
+
wait: kind
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Classifies a non-live fork hold for `waitOrFail`:
|
|
207
|
+
* - an exhausted walk (more holds than `forkHoldChecks` unchecked) waits under `purgeDrainLimit`;
|
|
208
|
+
* - a dead walk checks at most one `git.purge` listing per deleted fork hold, short-circuiting on
|
|
209
|
+
* the first standing non-failed `git.purge` (`purgeDrainLimit`) so a source waits for a healthy
|
|
210
|
+
* deleted fork's long drain (such as a 24 h 5 m multipart upload);
|
|
211
|
+
* - deleted forks whose `git.purge` has failed or is absent, and gone fork records, wait under
|
|
212
|
+
* `purgeStallLimit`.
|
|
213
|
+
*/
|
|
214
|
+
const forkHoldWait = /* @__PURE__ */ Effect.fnUntraced(function* (store, hold) {
|
|
215
|
+
if (hold.kind === "exhausted") return {
|
|
216
|
+
kind: "drain",
|
|
217
|
+
detail: `fork hold ${hold.hold} (more than ${hold.checked} fork holds unchecked)`
|
|
218
|
+
};
|
|
219
|
+
let firstDeletedHold;
|
|
220
|
+
let firstDeletedReason;
|
|
221
|
+
for (const entry of hold.deleted) {
|
|
222
|
+
const job = (yield* storeCall(store.jobs.list(repoScope(entry.fork), { name: purgeJobName }))).items.find((item) => item.key === purgeJobKey);
|
|
223
|
+
if (job !== void 0 && job.state !== "failed") return {
|
|
224
|
+
kind: "drain",
|
|
225
|
+
detail: `fork hold ${entry.hold} (fork purge ${job.state})`
|
|
226
|
+
};
|
|
227
|
+
if (firstDeletedHold === void 0) {
|
|
228
|
+
firstDeletedHold = entry.hold;
|
|
229
|
+
firstDeletedReason = job === void 0 ? "no purge job" : "purge failed";
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (hold.state === "deleted" && firstDeletedHold !== void 0 && firstDeletedReason !== void 0) return {
|
|
233
|
+
kind: "stall",
|
|
234
|
+
detail: `fork hold ${firstDeletedHold} (fork deleted, ${firstDeletedReason})`
|
|
235
|
+
};
|
|
236
|
+
return {
|
|
237
|
+
kind: "stall",
|
|
238
|
+
detail: `fork hold ${hold.hold} (fork ${hold.state})`
|
|
239
|
+
};
|
|
240
|
+
});
|
|
241
|
+
/**
|
|
242
|
+
* One immediate no-progress retry (CAS miss, scope version move, or dropped-delivery fence miss):
|
|
243
|
+
* counts consecutive spins since last progress and fails permanently at `purgeSpinTries`.
|
|
244
|
+
*/
|
|
245
|
+
const spinOrFail = (scope, data, blocker, detail) => {
|
|
246
|
+
const spins = (data.spins ?? 0) + 1;
|
|
247
|
+
if (spins >= 20) return Effect.fail(purgeStuck(scope, blocker, detail));
|
|
248
|
+
const next = { spins };
|
|
249
|
+
if (data.since !== void 0) next.since = data.since;
|
|
250
|
+
if (data.wait !== void 0) next.wait = data.wait;
|
|
251
|
+
return Effect.succeed({
|
|
252
|
+
kind: "more",
|
|
253
|
+
data: next
|
|
254
|
+
});
|
|
255
|
+
};
|
|
115
256
|
/**
|
|
116
257
|
* When a purge at `at` looks again for one drain job or delivery's: a waiting one's due, a running
|
|
117
258
|
* one's `purgeRunningRelook`, a failed one's `purgeBackstop`. A due time no later than the
|
|
118
|
-
* running re-look's is the queue's to claim at once.
|
|
259
|
+
* running re-look's is the queue's to claim at once. A dropped delivery's waiting job, which only
|
|
260
|
+
* an instance that still runs it claims, is looked at again no sooner than `purgeBackstop`, so a
|
|
261
|
+
* purge held on one that no instance claims steps, and logs, once a backstop.
|
|
119
262
|
*/
|
|
120
|
-
const relookFor = (item, at) => {
|
|
263
|
+
const relookFor = (item, at, dropped) => {
|
|
121
264
|
if (item.state === "failed") return at + purgeBackstop;
|
|
122
|
-
return item.state === "waiting" ? Math.max(item.due, at + purgeRunningRelook) : at + purgeRunningRelook;
|
|
265
|
+
return item.state === "waiting" ? Math.max(item.due, at + (dropped ? purgeBackstop : purgeRunningRelook)) : at + purgeRunningRelook;
|
|
123
266
|
};
|
|
124
267
|
/**
|
|
125
268
|
* When a purge at `at` looks again for the drain jobs and deliveries waiting, running or failed in
|
|
126
|
-
* `scope`, the soonest of theirs
|
|
127
|
-
* is `repo.deleted`'s `seq`, past which a waiting delivery holds nothing; with none,
|
|
269
|
+
* `scope`, the soonest of theirs, `at`: none when none is left. A page of its jobs at a time.
|
|
270
|
+
* `deleted` is `repo.deleted`'s `seq`, past which a waiting delivery holds nothing; with none,
|
|
271
|
+
* each holds. A retired delivery's job holds only while a try of it runs, and a dropped one's the
|
|
272
|
+
* host hasn't retired holds as any delivery's does, with a warning that names it, once a step.
|
|
273
|
+
* `endDropped` reads the rows again once it holds their jobs' claims, so this read only lets go. `dropped` is whether it listed a job of a delivery
|
|
274
|
+
* the server doesn't run, which `endDropped` must end before the step deletes anything.
|
|
128
275
|
*/
|
|
129
|
-
const draining = /* @__PURE__ */ Effect.fnUntraced(function* (store, scope, at, deleted) {
|
|
276
|
+
const draining = /* @__PURE__ */ Effect.fnUntraced(function* (store, scope, at, deleted, deliveries) {
|
|
130
277
|
let after;
|
|
131
278
|
let soonest;
|
|
279
|
+
let anyDropped = false;
|
|
280
|
+
let anyActive = false;
|
|
281
|
+
const blockers = [];
|
|
132
282
|
for (;;) {
|
|
133
283
|
const page = after === void 0 ? {} : { page: { after } };
|
|
134
|
-
const listing = yield* storeCall(
|
|
284
|
+
const listing = yield* storeCall(store.jobs.list(scope, page));
|
|
285
|
+
const names = listing.items.flatMap((item) => droppedDelivery(item, deliveries) ?? []);
|
|
286
|
+
const retired = yield* retiredAmong(store, new Set(names));
|
|
287
|
+
anyDropped ||= names.length > 0;
|
|
135
288
|
for (const item of listing.items) {
|
|
136
289
|
const delivery = isDeliverJob(item);
|
|
137
290
|
if (!drainJobs.has(item.name) && !delivery) continue;
|
|
138
291
|
if (delivery && item.state === "waiting" && deleted !== void 0 && (yield* sentThrough(store, scope, item, deleted))) continue;
|
|
139
|
-
const
|
|
292
|
+
const dropped = droppedDelivery(item, deliveries);
|
|
293
|
+
if (dropped !== void 0 && item.state !== "running" && retired.has(dropped)) continue;
|
|
294
|
+
const unretired = dropped !== void 0 && !retired.has(dropped);
|
|
295
|
+
if (unretired) yield* Effect.logWarning(`git.purge of ${scope} waits on ${item.name}, a delivery this server doesn't run: add '${dropped}' to events.retired`);
|
|
296
|
+
if (item.state !== "failed" && !unretired) anyActive = true;
|
|
297
|
+
if (blockers.length < stuckNamesMost) {
|
|
298
|
+
const note = unretired ? `${item.state}, unretired delivery '${dropped}'` : item.state;
|
|
299
|
+
blockers.push(`${item.name}/${item.key} (${note})`);
|
|
300
|
+
}
|
|
301
|
+
const relook = relookFor(item, at, dropped !== void 0);
|
|
140
302
|
soonest = soonest === void 0 ? relook : Math.min(soonest, relook);
|
|
141
303
|
}
|
|
142
|
-
if (listing.next === void 0)
|
|
304
|
+
if (listing.next === void 0) {
|
|
305
|
+
const kind = anyActive ? "drain" : "stall";
|
|
306
|
+
const detail = `${blockers.length === 1 ? "drain job" : "drain jobs"} ${blockers.join(", ")}`;
|
|
307
|
+
return {
|
|
308
|
+
at: soonest,
|
|
309
|
+
dropped: anyDropped,
|
|
310
|
+
kind,
|
|
311
|
+
detail
|
|
312
|
+
};
|
|
313
|
+
}
|
|
143
314
|
after = listing.next;
|
|
144
315
|
}
|
|
145
316
|
});
|
|
146
317
|
/** One collection's next page of keys, at one version: a smaller page where its rows are large. */
|
|
147
318
|
const pageOf = (store, scope, collection) => {
|
|
148
|
-
const read = (limit) => Effect.map(storeCall(
|
|
319
|
+
const read = (limit) => Effect.map(storeCall(store.read(scope, [{
|
|
149
320
|
collection,
|
|
150
321
|
limit
|
|
151
322
|
}])), (snapshot) => ({
|
|
@@ -166,13 +337,13 @@ const firstLeft = (store, scope) => {
|
|
|
166
337
|
collection,
|
|
167
338
|
limit: 1
|
|
168
339
|
}));
|
|
169
|
-
const together = Effect.map(storeCall(
|
|
340
|
+
const together = Effect.map(storeCall(store.read(scope, reads)), (snapshot) => ({
|
|
170
341
|
version: snapshot.version,
|
|
171
342
|
left: purgeCollections.find((_, index) => (snapshot.results[index]?.length ?? 0) > 0)
|
|
172
343
|
}));
|
|
173
344
|
const apart = Effect.fnUntraced(function* () {
|
|
174
345
|
for (const collection of purgeCollections) {
|
|
175
|
-
const snapshot = yield* storeCall(
|
|
346
|
+
const snapshot = yield* storeCall(store.read(scope, [{
|
|
176
347
|
collection,
|
|
177
348
|
limit: 1
|
|
178
349
|
}]));
|
|
@@ -182,7 +353,7 @@ const firstLeft = (store, scope) => {
|
|
|
182
353
|
};
|
|
183
354
|
}
|
|
184
355
|
return {
|
|
185
|
-
version: (yield* storeCall(
|
|
356
|
+
version: (yield* storeCall(store.read(scope, []))).version,
|
|
186
357
|
left: void 0
|
|
187
358
|
};
|
|
188
359
|
});
|
|
@@ -193,11 +364,11 @@ const discardFailed = /* @__PURE__ */ Effect.fnUntraced(function* (store, scope)
|
|
|
193
364
|
let after;
|
|
194
365
|
for (;;) {
|
|
195
366
|
const page = after === void 0 ? {} : { page: { after } };
|
|
196
|
-
const listing = yield* storeCall(
|
|
367
|
+
const listing = yield* storeCall(store.jobs.list(scope, {
|
|
197
368
|
state: "failed",
|
|
198
369
|
...page
|
|
199
370
|
}));
|
|
200
|
-
yield* Effect.forEach(listing.items, (item) => storeCall(
|
|
371
|
+
yield* Effect.forEach(listing.items, (item) => storeCall(store.jobs.discard(scope, {
|
|
201
372
|
name: item.name,
|
|
202
373
|
key: item.key
|
|
203
374
|
})), { discard: true });
|
|
@@ -213,18 +384,110 @@ const discardFailed = /* @__PURE__ */ Effect.fnUntraced(function* (store, scope)
|
|
|
213
384
|
const dropScopes = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, internalId) {
|
|
214
385
|
const named = yield* parts.scopes(internalId);
|
|
215
386
|
if (named.length > 64) return yield* Effect.die(/* @__PURE__ */ new TypeError(`The registrations name ${named.length} scopes of '${internalId}', past 64`));
|
|
216
|
-
for (const scope of [...named, repoScope(internalId)]) yield* storeCall(
|
|
387
|
+
for (const scope of [...named, repoScope(internalId)]) yield* storeCall(store.drop(scope));
|
|
388
|
+
});
|
|
389
|
+
/**
|
|
390
|
+
* A dropped delivery's waiting job made due at `at`: a save moves a waiting job's due only earlier,
|
|
391
|
+
* so a claim takes it. Its handler never runs, since no queue of this server runs its delivery.
|
|
392
|
+
*/
|
|
393
|
+
const droppedDueAt = (item, at) => defineJob({
|
|
394
|
+
name: item.name,
|
|
395
|
+
schema: Schema.toStandardSchemaV1(Schema.Unknown),
|
|
396
|
+
handler: () => {
|
|
397
|
+
throw new TypeError(`${item.name} is a delivery this server doesn't run`);
|
|
398
|
+
}
|
|
399
|
+
}).job({
|
|
400
|
+
key: item.key,
|
|
401
|
+
data: item.data,
|
|
402
|
+
at
|
|
403
|
+
});
|
|
404
|
+
/**
|
|
405
|
+
* Ends the jobs left in `scope` of deliveries the server doesn't run, a page of them at a time, or
|
|
406
|
+
* answers `false` when the purge must look again first, having deleted nothing. `draining` let each
|
|
407
|
+
* go: retired, or a waiting one that sent `repo.deleted`, through `deleted`. A step runs it before
|
|
408
|
+
* any part or page, so a try of one never reads the repo's rows after a delete took them: an
|
|
409
|
+
* `events` page gone under a try that still owes `repo.deleted` is that event lost.
|
|
410
|
+
*
|
|
411
|
+
* It claims the waiting ones first, each made due at `at`, since no queue of this server claims
|
|
412
|
+
* one, then reads their retirement rows in one read: so what it ends was retired while it held the
|
|
413
|
+
* claim, and a restore that landed before that read finds its job released and every row kept. A
|
|
414
|
+
* waiting job settles done only when its row is there, or it sent `repo.deleted`; a failed one is
|
|
415
|
+
* discarded only when its row is there, and the store refuses that once a `work.retry` took it.
|
|
416
|
+
* Anything else answers `false`: a row gone, a job another instance claimed or ran between the list
|
|
417
|
+
* and the claim, a claim that lapsed under `droppedLease` before its settle, a settle refused, or
|
|
418
|
+
* a discard refused. Each claim it doesn't settle done it releases, so its delivery claims it. A
|
|
419
|
+
* restore that lands after the read is the retire's: the ends it decided stand, though their
|
|
420
|
+
* settles may land after it, as `events.retired` says.
|
|
421
|
+
*/
|
|
422
|
+
const endDropped = /* @__PURE__ */ Effect.fnUntraced(function* (store, scope, at, deleted, deliveries) {
|
|
423
|
+
let after;
|
|
424
|
+
for (;;) {
|
|
425
|
+
const page = after === void 0 ? {} : { page: { after } };
|
|
426
|
+
const listing = yield* storeCall(store.jobs.list(scope, page));
|
|
427
|
+
const dropped = listing.items.filter((item) => droppedDelivery(item, deliveries) !== void 0);
|
|
428
|
+
if (dropped.some((item) => item.state === "running")) return false;
|
|
429
|
+
const waiting = dropped.filter((item) => item.state === "waiting");
|
|
430
|
+
const later = waiting.flatMap((item) => item.due > at ? [droppedDueAt(item, at)] : []);
|
|
431
|
+
if (later.length > 0) yield* storeCall(store.add(scope, { jobs: later }));
|
|
432
|
+
const names = waiting.map((item) => item.name);
|
|
433
|
+
const request = {
|
|
434
|
+
lease: droppedLease,
|
|
435
|
+
names,
|
|
436
|
+
limit: names.length
|
|
437
|
+
};
|
|
438
|
+
const { claims } = waiting.length === 0 ? { claims: [] } : yield* storeCall(store.jobs.claim(scope, request));
|
|
439
|
+
const retired = yield* retiredAmong(store, droppedNames(dropped, deliveries));
|
|
440
|
+
if ((yield* Effect.forEach(claims, (claim) => endClaimed(store, scope, claim, retired, deleted, deliveries, at))).includes(false) || claims.length < waiting.length) return false;
|
|
441
|
+
for (const item of dropped.filter((each) => each.state === "failed")) {
|
|
442
|
+
if (!retired.has(droppedDelivery(item, deliveries) ?? "")) return false;
|
|
443
|
+
const job = {
|
|
444
|
+
name: item.name,
|
|
445
|
+
key: item.key
|
|
446
|
+
};
|
|
447
|
+
if (!(yield* storeCall(store.jobs.discard(scope, job)).pipe(Effect.as(true), Effect.catchIf(notFailed, () => Effect.succeed(false))))) return false;
|
|
448
|
+
}
|
|
449
|
+
if (listing.next === void 0) return true;
|
|
450
|
+
after = listing.next;
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
/** The deliveries `items` name that the server doesn't run. */
|
|
454
|
+
const droppedNames = (items, deliveries) => new Set(items.flatMap((item) => droppedDelivery(item, deliveries) ?? []));
|
|
455
|
+
/**
|
|
456
|
+
* Settles `claim`, a dropped delivery's job, done when its delivery is in `retired`, the read made
|
|
457
|
+
* while the claim held, or it sent `repo.deleted`, and answers whether it did: else, or when the
|
|
458
|
+
* settle hands back a claim of it again, it releases the claim.
|
|
459
|
+
*/
|
|
460
|
+
const endClaimed = /* @__PURE__ */ Effect.fnUntraced(function* (store, scope, claim, retired, deleted, deliveries, at) {
|
|
461
|
+
const delivery = droppedDelivery(claim.job, deliveries);
|
|
462
|
+
const sent = deleted !== void 0 && (yield* sentThrough(store, scope, claim.job, deleted));
|
|
463
|
+
if (!(delivery !== void 0 && (retired.has(delivery) || sent))) {
|
|
464
|
+
yield* storeCall(store.jobs.settle(claim, {
|
|
465
|
+
kind: "released",
|
|
466
|
+
at
|
|
467
|
+
}));
|
|
468
|
+
return false;
|
|
469
|
+
}
|
|
470
|
+
const { ok, next } = yield* storeCall(store.jobs.settle(claim, { kind: "done" }));
|
|
471
|
+
if (next !== void 0) {
|
|
472
|
+
yield* storeCall(store.jobs.settle(next, {
|
|
473
|
+
kind: "released",
|
|
474
|
+
at
|
|
475
|
+
}));
|
|
476
|
+
return false;
|
|
477
|
+
}
|
|
478
|
+
return ok;
|
|
217
479
|
});
|
|
218
480
|
/**
|
|
219
481
|
* One step in the repo's scope: none for a repo that isn't deleted. It waits until its delete's
|
|
220
482
|
* `fetchLimits` has passed, nor while a receipt it holds still answers, `keyKept` past the delete;
|
|
221
483
|
* then while a drain job or a drained row stands, or a fork holds the
|
|
222
|
-
* repo, each wait till its own time to look again; else
|
|
484
|
+
* repo, each wait till its own time to look again; else the dropped deliveries' jobs ended, then
|
|
485
|
+
* each part's step, then a page of
|
|
223
486
|
* `purgeCollections`, then the fork's hold on its source, then the record, then the drops. A repo
|
|
224
487
|
* with no record is one whose record this purge deleted, since only a delete queues it: its
|
|
225
488
|
* drops run again, each done already or done now.
|
|
226
489
|
*/
|
|
227
|
-
const purgeStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, internalId) {
|
|
490
|
+
const purgeStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, internalId, data) {
|
|
228
491
|
const scope = repoScope(internalId);
|
|
229
492
|
const drainedReads = drainedCollections.map((collection) => ({
|
|
230
493
|
collection,
|
|
@@ -255,51 +518,62 @@ const purgeStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, int
|
|
|
255
518
|
at: at + purgeBackstop
|
|
256
519
|
};
|
|
257
520
|
const deleted = record.nextSeq === void 0 ? void 0 : record.nextSeq - 1;
|
|
258
|
-
const drain = yield* draining(store, scope, at, deleted);
|
|
259
|
-
if (drain !== void 0) return
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
if (
|
|
264
|
-
|
|
521
|
+
const drain = yield* draining(store, scope, at, deleted, parts.deliveries);
|
|
522
|
+
if (drain.at !== void 0) return yield* waitOrFail(scope, data, at, drain.at, drain.kind, "drain", drain.detail);
|
|
523
|
+
const drainedLeft = drainedCollections.filter((_, index) => (drained[index]?.length ?? 0) > 0);
|
|
524
|
+
if (drainedLeft.length > 0) return yield* waitOrFail(scope, data, at, at + purgeBackstop, "stall", "drained-rows", `drained rows with no drain job (${drainedLeft.join(", ")})`);
|
|
525
|
+
const hold = yield* forkedFrom(store, internalId);
|
|
526
|
+
if (hold?.kind === "live") return hasStuckState(data) ? {
|
|
527
|
+
...backstop,
|
|
528
|
+
data: {}
|
|
529
|
+
} : backstop;
|
|
530
|
+
if (hold !== void 0) {
|
|
531
|
+
const waiting = yield* forkHoldWait(store, hold);
|
|
532
|
+
return yield* waitOrFail(scope, data, at, at + purgeBackstop, waiting.kind, "fork-hold", waiting.detail);
|
|
533
|
+
}
|
|
534
|
+
if (drain.dropped && !(yield* endDropped(store, scope, at, deleted, parts.deliveries))) return yield* spinOrFail(scope, data, "end-dropped", "ending dropped delivery jobs");
|
|
265
535
|
for (const part of parts.parts) {
|
|
266
536
|
const step = yield* part(store, internalId);
|
|
267
|
-
if (step === "
|
|
268
|
-
if (step === "did") return
|
|
537
|
+
if (step === "done") continue;
|
|
538
|
+
if (step === "did") return progressed(data);
|
|
539
|
+
const detail = step === "waits" ? "a purge part waiting" : `purge part '${step.waits}' waiting`;
|
|
540
|
+
return yield* waitOrFail(scope, data, at, at + purgeBackstop, "drain", "part", detail);
|
|
269
541
|
}
|
|
270
542
|
const { left, version } = yield* firstLeft(store, scope);
|
|
271
543
|
if (left !== void 0) {
|
|
272
544
|
const page = yield* pageOf(store, scope, left);
|
|
273
|
-
yield*
|
|
545
|
+
const committed = yield* storeCommit(store.commit(scope, {
|
|
274
546
|
id: newChangeId(),
|
|
275
547
|
expect: page.version,
|
|
276
548
|
delete: page.keys
|
|
277
549
|
}));
|
|
278
|
-
return
|
|
550
|
+
if (!committed.ok || page.keys.length === 0) return yield* spinOrFail(scope, data, "page-commit", `deleting collection '${left}' (${committed.ok ? "empty page" : "commit contended"})`);
|
|
551
|
+
return progressed(data);
|
|
279
552
|
}
|
|
280
|
-
yield* reconcile(store, internalId);
|
|
281
|
-
if (!(yield* releaseHold(store, internalId, record))) return
|
|
553
|
+
if (record.staged !== true) yield* reconcile(store, internalId);
|
|
554
|
+
if (!(yield* releaseHold(store, internalId, record))) return yield* spinOrFail(scope, data, "release-hold", "releasing fork hold (catalogue contended)");
|
|
282
555
|
yield* discardFailed(store, scope);
|
|
283
556
|
const own = yield* pageOf(store, scope, collections.repo);
|
|
284
|
-
if (own.version !== version) return
|
|
285
|
-
if (!(yield*
|
|
557
|
+
if (own.version !== version || version !== snapshot.version) return yield* spinOrFail(scope, data, "record-version", "deleting repo record (scope moved)");
|
|
558
|
+
if (!(yield* storeCommit(store.commit(scope, {
|
|
286
559
|
id: newChangeId(),
|
|
287
560
|
expect: version,
|
|
288
561
|
delete: own.keys
|
|
289
|
-
}))).ok) return
|
|
562
|
+
}))).ok) return yield* spinOrFail(scope, data, "record-commit", "deleting repo record (commit contended)");
|
|
290
563
|
return yield* dropScopes(parts, store, internalId);
|
|
291
564
|
});
|
|
292
565
|
const PurgeJob = /* @__PURE__ */ Job.make(purgeJobName, {
|
|
293
566
|
payload: PurgeData,
|
|
294
567
|
concurrency: 1,
|
|
568
|
+
retry: purgeRetry,
|
|
295
569
|
rebuild: () => ({})
|
|
296
570
|
});
|
|
297
571
|
/** `git.purge`, over one server's parts: each try one page of the repo's rows. */
|
|
298
|
-
const purgeJob = (parts) => gitJob(PurgeJob, () =>
|
|
572
|
+
const purgeJob = (parts) => gitJob(PurgeJob, (data) => Effect.flatMap(currentRepo, (repo) => purgeStep(parts, parts.store, repo, data)));
|
|
299
573
|
/** The repo's `git.purge` row, due at `at`. */
|
|
300
574
|
const purgeJobRow = (job, at) => job.job({
|
|
301
575
|
key: purgeJobKey,
|
|
302
576
|
data: {},
|
|
303
577
|
at
|
|
304
578
|
});
|
|
305
|
-
export { purgeBackstop, purgeCollections, purgeJob, purgeJobKey, purgeJobName, purgeJobRow, purgePage, purgeRunningRelook };
|
|
579
|
+
export { purgeBackstop, purgeCollections, purgeDrainLimit, purgeJob, purgeJobKey, purgeJobName, purgeJobRow, purgePage, purgeRunningRelook, purgeStallLimit };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { awaitingUpkeep } from "../storage/batches.mjs";
|
|
1
2
|
import { gitError } from "../contracts/result.mjs";
|
|
2
3
|
import { packRow } from "../store/git-store.mjs";
|
|
3
4
|
import { refBytesMost, refRowBytes, storesPeel } from "../store/ref-rows.mjs";
|
|
@@ -11,7 +12,7 @@ import { jsonBytes, limits } from "@ref0/infra";
|
|
|
11
12
|
const pushRefLimit = 4e3;
|
|
12
13
|
/**
|
|
13
14
|
* What a push at `pushRefLimit` leaves of a commit's writes for its other rows: 2,000. Its mirror
|
|
14
|
-
* jobs, `mirrorLimits.mirrors` at most, its `git.queue.advance` jobs, one a moved target and
|
|
15
|
+
* jobs, one a destination and `mirrorLimits.mirrors` at most, its `git.queue.advance` jobs, one a moved target and
|
|
15
16
|
* `queueLimits.targets` at most, its delivery jobs, one a delivery and `deliveryLimit` at most,
|
|
16
17
|
* and its fixed rows stay within it by construction.
|
|
17
18
|
*/
|
|
@@ -98,6 +99,7 @@ const problemOf = (read, command, update) => {
|
|
|
98
99
|
const requestProblem = (read, command, index) => {
|
|
99
100
|
if (read.revoked !== void 0) return read.revoked;
|
|
100
101
|
if (command.received?.quarantine !== void 0 && read.quarantine !== "open") return gitError("UNAVAILABLE", "The push's pack outlived its quarantine, so it may be gone", { hint: "Push again" });
|
|
102
|
+
if (read.batches !== void 0 && read.batches + 1 > 16) return awaitingUpkeep(read.batches, 16);
|
|
101
103
|
const most = pushRefLimitOf(index);
|
|
102
104
|
const where = index === void 0 ? "" : " on a server that keeps a ref index";
|
|
103
105
|
if (command.updates.length > most) return gitError("RESOURCE_EXHAUSTED", `A push moves at most ${most} refs${where}`, {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "../contracts/ids.mjs";
|
|
2
|
+
import "../contracts/objects.mjs";
|
|
3
|
+
import "../contracts/push-uploads.mjs";
|
|
4
|
+
import "../contracts/result.mjs";
|
|
5
|
+
import "../contracts/call-allowance.mjs";
|
|
6
|
+
import "./ancestry.mjs";
|
|
7
|
+
import "effect/Effect";
|
|
8
|
+
/** A server's sizes for a pushed file, `pushes.files` resolved: a warning only when there's one. */
|
|
9
|
+
export interface PushFiles {
|
|
10
|
+
readonly warnAbove: number | undefined;
|
|
11
|
+
readonly refuseAbove: number;
|
|
12
|
+
}
|