@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
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { bodyUntilAborted } from "./bodies.mjs";
|
|
2
|
+
import { closedError, isServerClosed } from "./closed.mjs";
|
|
3
|
+
import { JobLanded } from "./job-try.mjs";
|
|
4
|
+
import { forkIn, noCall } from "./crossing.mjs";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Exit from "effect/Exit";
|
|
7
|
+
import { JobGate } from "@ref0/infra";
|
|
8
|
+
import * as Context from "effect/Context";
|
|
9
|
+
import * as Stream from "effect/Stream";
|
|
10
|
+
import * as Scope$1 from "effect/Scope";
|
|
11
|
+
import * as Scheduler from "effect/Scheduler";
|
|
12
|
+
// src/store/door.ts
|
|
13
|
+
/** The door of a service with no server to close, as a client's own store: it always runs. */
|
|
14
|
+
const openDoor = {
|
|
15
|
+
refusal: () => void 0,
|
|
16
|
+
closing: new AbortController().signal
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* `effect` through `door`, for a run outside the server's runtime, which `close()` doesn't stop:
|
|
20
|
+
* sync's door, over a seam's, and the server's own, over its closing. It asks first, then
|
|
21
|
+
* races the closing, so a run still going as the server closes dies with the closed error whatever
|
|
22
|
+
* it would have answered, its writes included: each store commit lands whole or not at all. No ask
|
|
23
|
+
* after: the race already listens before the run can end, so a close before its answer always
|
|
24
|
+
* wins. Only a closed refusal counts at the ask, so a failed build answers its own `UNAVAILABLE`,
|
|
25
|
+
* as the run reads it.
|
|
26
|
+
*/
|
|
27
|
+
const throughBridge = (door) => (effect) => Effect.andThen(askClosed(door), Effect.raceFirst(closesOf(door), effect));
|
|
28
|
+
/** `door`'s refusal at the ask, as a defect: only a closed one, as `throughBridge` says. */
|
|
29
|
+
const askClosed = (door) => Effect.suspend(() => {
|
|
30
|
+
const refused = door.refusal();
|
|
31
|
+
return refused !== void 0 && isServerClosed(refused) ? Effect.die(refused) : Effect.void;
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* `door`'s refusal at the ask, any of them, as a defect: a failed build's too. A host's bucket can't
|
|
35
|
+
* read the server's build, as a run in it does, so a call a package holds from `bind` refuses here.
|
|
36
|
+
*/
|
|
37
|
+
const askRefused = (door) => Effect.suspend(() => {
|
|
38
|
+
const refused = door.refusal();
|
|
39
|
+
return refused === void 0 ? Effect.void : Effect.die(refused);
|
|
40
|
+
});
|
|
41
|
+
/** Dies with the closed error as `door` closes. Its listener goes with the run that waits on it. */
|
|
42
|
+
const closesOf = (door) => Effect.callback((resume) => {
|
|
43
|
+
const onAbort = () => resume(Effect.die(closedError()));
|
|
44
|
+
if (door.closing.aborted) return onAbort();
|
|
45
|
+
door.closing.addEventListener("abort", onAbort, { once: true });
|
|
46
|
+
return Effect.sync(() => door.closing.removeEventListener("abort", onAbort));
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* `stream`, released as `door` closes, even while its reader holds it unread. A pull in flight dies
|
|
50
|
+
* with the closed error, as `closesOf` says. With none in flight, the close ends the stream's own
|
|
51
|
+
* scope at once, so what it holds goes with it, and its next pull dies with the closed error: a
|
|
52
|
+
* web stream's reader outside Effect, as a response's body has, holds it so. Its listener goes
|
|
53
|
+
* with the stream.
|
|
54
|
+
*/
|
|
55
|
+
const releasedOnClose = (stream, door) => Stream.unwrap(Effect.gen(function* () {
|
|
56
|
+
const own = Scope$1.makeUnsafe();
|
|
57
|
+
const state = { pulling: false };
|
|
58
|
+
const onClose = () => {
|
|
59
|
+
if (state.pulling) return;
|
|
60
|
+
forkIn(Scope$1.close(own, Exit.die(closedError())), noCall);
|
|
61
|
+
};
|
|
62
|
+
door.closing.addEventListener("abort", onClose, { once: true });
|
|
63
|
+
const stop = Effect.sync(() => door.closing.removeEventListener("abort", onClose));
|
|
64
|
+
yield* Effect.addFinalizer((exit) => Effect.andThen(stop, Scope$1.close(own, exit)));
|
|
65
|
+
const pull = yield* Scope$1.provide(Stream.toPull(stream), own);
|
|
66
|
+
const pulled = Effect.suspend(() => {
|
|
67
|
+
state.pulling = true;
|
|
68
|
+
return Effect.raceFirst(closesOf(door), pull);
|
|
69
|
+
}).pipe(Effect.ensuring(Effect.sync(() => state.pulling = false)));
|
|
70
|
+
return Stream.fromPull(Effect.succeed(pulled));
|
|
71
|
+
}));
|
|
72
|
+
/** Records called by features in their own fibers, retaining the try's fence through the server door. */
|
|
73
|
+
const doorRecords = (records, context, door) => {
|
|
74
|
+
const { over, call } = doorOf(context, door);
|
|
75
|
+
const markLanded = () => Effect.map(Effect.service(JobLanded), (saved) => {
|
|
76
|
+
if (saved !== void 0) saved.landed = true;
|
|
77
|
+
});
|
|
78
|
+
const run = (effect) => call(Effect.suspend(effect));
|
|
79
|
+
const landed = (effect) => Effect.tap(run(effect), markLanded);
|
|
80
|
+
return {
|
|
81
|
+
read: (scope, reads, counts) => run(() => records.read(scope, reads, counts)),
|
|
82
|
+
commit: (scope, change) => Effect.tap(run(() => records.commit(scope, change)), (committed) => committed.ok ? markLanded() : Effect.void),
|
|
83
|
+
add: (scope, addition) => landed(() => records.add(scope, addition)),
|
|
84
|
+
drop: (scope) => run(() => records.drop(scope)),
|
|
85
|
+
watch: (scope, watch) => Stream.unwrap(Effect.as(askRefused(door), releasedOnClose(Stream.suspend(() => records.watch(scope, watch)).pipe(Stream.updateContext(over)), door))),
|
|
86
|
+
jobs: {
|
|
87
|
+
claim: (scope, request) => run(() => records.jobs.claim(scope, request)),
|
|
88
|
+
settle: (claim, outcome) => run(() => records.jobs.settle(claim, outcome)),
|
|
89
|
+
progress: (scope, write) => run(() => records.jobs.progress(scope, write)),
|
|
90
|
+
count: (scope) => run(() => records.jobs.count(scope)),
|
|
91
|
+
list: (scope, request) => run(() => records.jobs.list(scope, request)),
|
|
92
|
+
retry: (scope, job, input) => landed(() => records.jobs.retry(scope, job, input)),
|
|
93
|
+
discard: (scope, job) => landed(() => records.jobs.discard(scope, job))
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* `bucket`, built on `context`, as Git's objects call it from their own fibers: each call reads the
|
|
99
|
+
* caller's context over the built one's services, so the bucket finds its host's and the call still
|
|
100
|
+
* counts into the caller's request, and goes through `door`, so a call or a read still going as the
|
|
101
|
+
* server closes dies with the closed error. Each asks the door's whole refusal first, as
|
|
102
|
+
* `askRefused` says. A put's body runs in the same context, so what it reads
|
|
103
|
+
* counts as the caller's. `context` keeps no `Scheduler`, as `ownScheduler` says.
|
|
104
|
+
*/
|
|
105
|
+
const doorBucket = (bucket, context, door) => {
|
|
106
|
+
const { call } = doorOf(context, door);
|
|
107
|
+
return {
|
|
108
|
+
...bucket,
|
|
109
|
+
put: (key, body, options) => call(bucket.put(key, body, options)),
|
|
110
|
+
read: (key, range) => Effect.suspend(() => {
|
|
111
|
+
let held;
|
|
112
|
+
const opened = Effect.uninterruptible(Effect.tap(bucket.read(key, range), (body) => Effect.sync(() => held = body)));
|
|
113
|
+
return Effect.interruptible(call(opened)).pipe(Effect.onExit((exit) => Exit.isSuccess(exit) ? Effect.void : Effect.sync(() => void held?.cancel().catch(() => void 0))), Effect.map((body) => untilClosed(body, door)), Effect.uninterruptible);
|
|
114
|
+
}),
|
|
115
|
+
remove: (key) => call(bucket.remove(key)),
|
|
116
|
+
removeMany: (keys, options) => call(bucket.removeMany(keys, options)),
|
|
117
|
+
list: (prefix, page) => call(bucket.list(prefix, page))
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
/** `body`, which errors with the close's error once `door` closes, as `bodyUntilAborted` says. */
|
|
121
|
+
const untilClosed = (body, door) => bodyUntilAborted(body, door.closing, closedError);
|
|
122
|
+
/** `links`, built on `context`, each call through `door` on the caller's context, as `doorBucket`'s. */
|
|
123
|
+
const doorLinks = (links, context, door) => {
|
|
124
|
+
const { call } = doorOf(context, door);
|
|
125
|
+
return {
|
|
126
|
+
url: (key, options) => call(links.url(key, options)),
|
|
127
|
+
putUrl: (key, options) => call(links.putUrl(key, options)),
|
|
128
|
+
head: (key) => call(links.head(key))
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
/** `uploads`, built on `context`, each call through `door` on the caller's context, as `doorBucket`'s. */
|
|
132
|
+
const doorUploads = (uploads, context, door) => {
|
|
133
|
+
const { call } = doorOf(context, door);
|
|
134
|
+
return {
|
|
135
|
+
maxParts: uploads.maxParts,
|
|
136
|
+
beginUpload: (key) => call(uploads.beginUpload(key)),
|
|
137
|
+
uploadUrl: (key, options) => call(uploads.uploadUrl(key, options)),
|
|
138
|
+
listParts: (key, upload) => call(uploads.listParts(key, upload)),
|
|
139
|
+
completeUpload: (key, input) => call(uploads.completeUpload(key, input)),
|
|
140
|
+
abortUpload: (key, upload) => call(uploads.abortUpload(key, upload))
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* How a door's service runs a call: on the caller's context over `context`'s services, through
|
|
145
|
+
* `door`, as `doorBucket` says.
|
|
146
|
+
*/
|
|
147
|
+
const doorOf = (context, door) => {
|
|
148
|
+
const host = ownScheduler(context);
|
|
149
|
+
const through = throughBridge(door);
|
|
150
|
+
const over = (caller) => Context.merge(caller, host);
|
|
151
|
+
const call = (effect) => Effect.andThen(askRefused(door), through(Effect.updateContext(effect, over)));
|
|
152
|
+
return {
|
|
153
|
+
over,
|
|
154
|
+
call
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* `context` without its `Scheduler`, so each run keeps the one it started on. A runtime builds on
|
|
159
|
+
* the scheduler of the fiber that started it, so the built context holds an async one: a run at
|
|
160
|
+
* once on it hands its yields to that scheduler, and runSync's one flush leaves the yield after
|
|
161
|
+
* `provideContext` ends, which dies with `AsyncFiberError`.
|
|
162
|
+
*/
|
|
163
|
+
const ownScheduler = (context) => Context.omit(Scheduler.Scheduler)(context);
|
|
164
|
+
/** How long a job's try a closed server holds off waits before the host's queue claims it again. */
|
|
165
|
+
const closedRetry = 6e4;
|
|
166
|
+
/**
|
|
167
|
+
* `queue`, built on `context`, each call through `door` on the caller's context: `addJobs` gates
|
|
168
|
+
* each definition on `door` via `JobGate.later` so a closed server holds off tries and spends no
|
|
169
|
+
* attempt.
|
|
170
|
+
*/
|
|
171
|
+
const doorQueue = (queue, context, door, now) => {
|
|
172
|
+
const { call } = doorOf(context, door);
|
|
173
|
+
const gate = { later: () => door.refusal() === void 0 ? void 0 : now() + closedRetry };
|
|
174
|
+
return {
|
|
175
|
+
addJobs: (...definitions) => call(queue.addJobs(...definitions).pipe(Effect.provideService(JobGate, gate))),
|
|
176
|
+
run: (scope) => call(queue.run(scope)),
|
|
177
|
+
count: (scope) => call(queue.count(scope)),
|
|
178
|
+
list: (scope, request) => call(queue.list(scope, request)),
|
|
179
|
+
retry: (scope, job) => call(queue.retry(scope, job)),
|
|
180
|
+
discard: (scope, job) => call(queue.discard(scope, job))
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
export { doorBucket, doorLinks, doorQueue, doorRecords, doorUploads, openDoor, throughBridge };
|
package/dist/store/errors.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GitError } from "../contracts/result.mjs";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import "effect/Schema";
|
|
4
|
-
import {
|
|
4
|
+
import { Row } from "@ref0/infra";
|
|
5
5
|
import "effect/Stream";
|
|
6
6
|
/**
|
|
7
7
|
* A store call, its refusal as Git's error: one of the two doors every call Git makes goes
|
|
@@ -10,10 +10,9 @@ import "effect/Stream";
|
|
|
10
10
|
* either's bound (Q799): past one, it dies with `CallsSpent`, which an edge answers, as
|
|
11
11
|
* `spentRefusalOf` does.
|
|
12
12
|
*/
|
|
13
|
-
export declare
|
|
14
|
-
export declare function storeCall<A, E, R>(run: Effect.Effect<A, E, R>, options?: {
|
|
13
|
+
export declare const storeCall: <A, E, R>(run: Effect.Effect<A, E, R>, options?: {
|
|
15
14
|
readonly resend?: boolean;
|
|
16
|
-
})
|
|
15
|
+
}) => Effect.Effect<A, GitError, R>;
|
|
17
16
|
/**
|
|
18
17
|
* The most store calls one try at a write makes through `storeCall`: its read, the commit it
|
|
19
18
|
* decides, and that commit sent again as often as a lost reply may send it. A caller that must
|
package/dist/store/errors.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fail, gitError, gitErrorFrom } from "../contracts/result.mjs";
|
|
2
2
|
import { callLimitIn, callLimitTry, catchSpent, fromAnswer, spentAt, spentRefusal } from "../contracts/calls-spent.mjs";
|
|
3
3
|
import { chargeCall, chargeResends, committedNow } from "./call-count.mjs";
|
|
4
|
-
import { isServerClosed
|
|
4
|
+
import { isServerClosed } from "./closed.mjs";
|
|
5
5
|
import * as Effect from "effect/Effect";
|
|
6
6
|
import * as Option from "effect/Option";
|
|
7
7
|
import * as Schema from "effect/Schema";
|
|
@@ -9,11 +9,13 @@ import * as Cause from "effect/Cause";
|
|
|
9
9
|
import * as Exit from "effect/Exit";
|
|
10
10
|
import { isInfraError } from "@ref0/infra";
|
|
11
11
|
import * as Predicate from "effect/Predicate";
|
|
12
|
-
import * as Stream from "effect/Stream";
|
|
13
12
|
import * as Data from "effect/Data";
|
|
13
|
+
import * as Stream from "effect/Stream";
|
|
14
14
|
// src/store/errors.ts
|
|
15
15
|
const savedHint = "Read it back before you try again";
|
|
16
16
|
const savedContext = { reason: "may-have-saved" };
|
|
17
|
+
/** What a caller does with a write that landed past its `by`: it wrote nothing, so read again. */
|
|
18
|
+
const lateHint = "Try again";
|
|
17
19
|
/**
|
|
18
20
|
* `error`, met once a write of the call's own has landed: any `UNAVAILABLE` is `may-have-saved`,
|
|
19
21
|
* since what another reason says about sending the same call again holds only for a call that
|
|
@@ -42,7 +44,9 @@ const afterWrites = (error) => {
|
|
|
42
44
|
* infra's refusal kept as its cause, which `pastCallLimit` reads, and a hint any caller can follow:
|
|
43
45
|
* a door fails with it as the defect `CallsSpent` instead, which an edge answers with this. A commit
|
|
44
46
|
* that never got a reply, and the platform failing `after` the request's deciding commit, may have
|
|
45
|
-
* saved the write, so a caller reads it back before it tries again (#1308).
|
|
47
|
+
* saved the write, so a caller reads it back before it tries again (#1308). A write that landed
|
|
48
|
+
* past its `by` is `UNAVAILABLE` too, having written nothing: the read it was held to is old, so a
|
|
49
|
+
* caller reads again (#2331).
|
|
46
50
|
*/
|
|
47
51
|
const fromInfra = (cause, after = false) => {
|
|
48
52
|
const failed = !isInfraError(cause) || Predicate.isTagged(cause, "Unavailable");
|
|
@@ -64,6 +68,10 @@ const fromInfra = (cause, after = false) => {
|
|
|
64
68
|
hint: callLimitTry
|
|
65
69
|
});
|
|
66
70
|
if (cause.code === "INTERNAL") return gitError("INTERNAL", "The server can't reach its store", { cause });
|
|
71
|
+
if (cause.reason === "late") return gitError("UNAVAILABLE", cause.message, {
|
|
72
|
+
cause,
|
|
73
|
+
hint: lateHint
|
|
74
|
+
});
|
|
67
75
|
return gitError(cause.code, cause.message, { cause });
|
|
68
76
|
};
|
|
69
77
|
/** The smaller fetch a client is told to try, when its fetch was too much for one response. */
|
|
@@ -103,19 +111,25 @@ const routeEdge = (effect, refused) => Effect.catch(answerSpent(effect), (error)
|
|
|
103
111
|
* `spentRefusal`'s, and any other defect a defect still.
|
|
104
112
|
*/
|
|
105
113
|
const answerSpent = (effect) => catchSpent(effect, (spent) => Effect.fail(spentRefusal(spent)));
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
114
|
+
/**
|
|
115
|
+
* A store call, its refusal as Git's error: one of the two doors every call Git makes goes
|
|
116
|
+
* through, with `bucketCall`, and every call a package built on Git makes, as `@ref0/github`'s
|
|
117
|
+
* records (Q826). It counts into the request and the `CallBudget` in scope, and never starts past
|
|
118
|
+
* either's bound (Q799): past one, it dies with `CallsSpent`, which an edge answers, as
|
|
119
|
+
* `spentRefusalOf` does.
|
|
120
|
+
*/
|
|
121
|
+
const storeCall = (run, options) => effectStoreCall(run, options?.resend === true);
|
|
122
|
+
/** A store failure: preserve interruption, spent bounds and closed servers; map adapter throws via `fromInfra`. */
|
|
111
123
|
const effectStoreFailure = (cause, after) => {
|
|
112
124
|
if (Cause.hasInterrupts(cause)) return Effect.failCause(Cause.map(cause, (error) => fromInfra(error, after)));
|
|
113
125
|
const error = Cause.squash(cause);
|
|
114
126
|
const spent = spentAt(error);
|
|
115
127
|
if (spent !== void 0) return Effect.die(spent);
|
|
116
|
-
if (isServerClosed(error)
|
|
128
|
+
if (isServerClosed(error)) return Effect.die(error);
|
|
117
129
|
return Effect.fail(fromInfra(error, after));
|
|
118
130
|
};
|
|
131
|
+
/** A commit through `storeCall`, resending under its own ID when its reply is lost. */
|
|
132
|
+
const storeCommit = (run) => storeCall(run, { resend: true });
|
|
119
133
|
/** A watch, charged once at subscription, with the same failure classification as a store call. */
|
|
120
134
|
const storeWatch = (run) => Stream.unwrap(storeCall(Effect.map(committedNow, (after) => run().pipe(Stream.catchCause((cause) => Stream.fromEffect(effectStoreFailure(cause, after)))))));
|
|
121
135
|
/** An Effect store call, with a commit's resends under the same ID when requested. */
|
|
@@ -159,35 +173,11 @@ const codeErrors = [
|
|
|
159
173
|
* guess costs one resend under the same ID, which the store's receipt answers as the first.
|
|
160
174
|
*/
|
|
161
175
|
const isLostReply = (cause) => Predicate.isTagged(cause, "Unavailable") || !isInfraError(cause) && !codeErrors.some((code) => cause instanceof code);
|
|
162
|
-
/** Each answer a commit's resend gave, with the resends it took, which `storeCall` charges. */
|
|
163
|
-
const resent = /* @__PURE__ */ new WeakMap();
|
|
164
176
|
/**
|
|
165
177
|
* Whether a resend's `cause` is the store's own answer, made past its receipt: an infra refusal
|
|
166
178
|
* other than `Unavailable` or the platform's cap, which refuses a call before it reaches the store.
|
|
167
179
|
*/
|
|
168
180
|
const isAnswered = (cause) => isInfraError(cause) && !Predicate.isTagged(cause, "Unavailable") && !pastCallLimit(cause);
|
|
169
|
-
/**
|
|
170
|
-
* `send`, a commit where infra calls the adapter, sent again under its own ID while the platform
|
|
171
|
-
* fails, up to `commitResendsMost` times: the store's receipt answers as the first send ended, so a
|
|
172
|
-
* commit that landed is never made twice. A defect of code, or a closed server, is never resent.
|
|
173
|
-
* Once a reply is lost, a resend ends as the store answered it or `Unsettled`, whose cause is that
|
|
174
|
-
* first loss alone, so no later refusal, the platform's cap among them, answers a write that may
|
|
175
|
-
* have landed as one that didn't.
|
|
176
|
-
*/
|
|
177
|
-
const resending = async (send) => {
|
|
178
|
-
let lost;
|
|
179
|
-
for (let resends = 0;; resends += 1) try {
|
|
180
|
-
const committed = await send();
|
|
181
|
-
if (resends === 0) return committed;
|
|
182
|
-
const again = { ...committed };
|
|
183
|
-
resent.set(again, resends);
|
|
184
|
-
return again;
|
|
185
|
-
} catch (cause) {
|
|
186
|
-
if (isServerClosed(cause) || (resends === 0 ? !isLostReply(cause) : isAnswered(cause))) throw cause;
|
|
187
|
-
lost ??= cause;
|
|
188
|
-
if (resends === 1 || !isLostReply(cause)) throw new Unsettled("No reply came to a commit", { cause: lost });
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
181
|
/** A stored row whose value should match `schema`; one that doesn't is `DATA_LOSS`. */
|
|
192
182
|
const decodeRow = (schema, row, what) => {
|
|
193
183
|
const decoded = Schema.decodeUnknownOption(schema)(row.value);
|
|
@@ -254,4 +244,4 @@ const endedEarly = (cause) => {
|
|
|
254
244
|
cause
|
|
255
245
|
});
|
|
256
246
|
};
|
|
257
|
-
export { Unsettled, afterWrites, answerSpent, bestEffort, brokenRead, clientWentAway, commitCallsMost, decodeDerivedRow, decodeRow, endedEarly, fetchLess, fromInfra, isLimitRefusal, pastCallLimit, readBody,
|
|
247
|
+
export { Unsettled, afterWrites, answerSpent, bestEffort, brokenRead, clientWentAway, commitCallsMost, decodeDerivedRow, decodeRow, endedEarly, fetchLess, fromInfra, isLimitRefusal, pastCallLimit, readBody, resultCall, routeEdge, storeCall, storeCommit, storeWatch, thrownError };
|
package/dist/store/git-store.mjs
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { isInternalId } from "../contracts/ids.mjs";
|
|
2
2
|
import { fail } from "../contracts/result.mjs";
|
|
3
3
|
import { resolveRepo } from "./catalogue.mjs";
|
|
4
|
-
import { decodeRow, storeCall } from "./errors.mjs";
|
|
4
|
+
import { decodeRow, storeCall, storeCommit } from "./errors.mjs";
|
|
5
|
+
import { JobLanded } from "./job-try.mjs";
|
|
5
6
|
import { outboxCollections } from "./outbox.mjs";
|
|
6
7
|
import { PackRow } from "./records.mjs";
|
|
7
8
|
import { collections, prunedKey, pushedKey, selfKey } from "./scopes.mjs";
|
|
8
9
|
import * as Effect from "effect/Effect";
|
|
10
|
+
import { Records } from "@ref0/infra";
|
|
11
|
+
import * as Context from "effect/Context";
|
|
9
12
|
// src/store/git-store.ts
|
|
10
13
|
const packsRead = { collection: collections.packs };
|
|
11
14
|
/** A repo's listed packs, from its `packs` rows. */
|
|
@@ -65,21 +68,21 @@ const featureChange = (scope, change) => {
|
|
|
65
68
|
return Effect.void;
|
|
66
69
|
};
|
|
67
70
|
/**
|
|
68
|
-
* Git's records over infra's `
|
|
71
|
+
* Git's records over infra's `Records`, under Git's commit rules: only Git's scopes, a repo's
|
|
69
72
|
* by its internal ID, and never the catalogue, a repo's own record or its outbox, which only the core
|
|
70
73
|
* writes.
|
|
71
|
-
*
|
|
74
|
+
* Inside a job try, every commit is fenced by the fiber's `Records.Fence`.
|
|
72
75
|
*/
|
|
73
76
|
const gitStore = (store) => ({
|
|
74
77
|
read: ({ scope, reads }) => {
|
|
75
78
|
const problem = scopeProblem(scope);
|
|
76
|
-
return problem === void 0 ? storeCall(
|
|
79
|
+
return problem === void 0 ? storeCall(store.read(scope, reads)) : fail("INVALID_ARGUMENT", problem);
|
|
77
80
|
},
|
|
78
|
-
commit: ({ scope, change }) => Effect.andThen(featureChange(scope, change),
|
|
81
|
+
commit: ({ scope, change }) => Effect.andThen(featureChange(scope, change), storeCommit(store.commit(scope, change))),
|
|
79
82
|
add: ({ scope, addition }) => {
|
|
80
83
|
if (!scope.startsWith("git/repo/") || scopeProblem(scope) !== void 0) return fail("INVALID_ARGUMENT", "Only a repo's scope, by its internal ID, takes an addition");
|
|
81
84
|
if (touchesOwn(scope, addition.put ?? [])) return ownRefusal();
|
|
82
|
-
return storeCall(
|
|
85
|
+
return storeCall(store.add(scope, addition));
|
|
83
86
|
},
|
|
84
87
|
listed: Effect.fnUntraced(function* ({ repo }) {
|
|
85
88
|
const { internalId, snapshot } = yield* resolveRepo(store, repo, [packsRead]);
|
|
@@ -91,4 +94,19 @@ const gitStore = (store) => ({
|
|
|
91
94
|
};
|
|
92
95
|
})
|
|
93
96
|
});
|
|
94
|
-
|
|
97
|
+
/**
|
|
98
|
+
* `gitStore(store)` bound to the caller fiber's `Records.Fence` and `JobLanded`, so writes through
|
|
99
|
+
* a Promise `GitObjects` boundary (`receiveStep`, `maintain`) stay fenced and mark landed writes.
|
|
100
|
+
*/
|
|
101
|
+
const tryGitStore = (store) => Effect.map(Effect.context(), (context) => {
|
|
102
|
+
const fence = Context.get(context, Records.Fence);
|
|
103
|
+
const landed = Context.get(context, JobLanded);
|
|
104
|
+
const base = gitStore(store);
|
|
105
|
+
const bind = (effect) => effect.pipe(Effect.provideService(Records.Fence, fence), Effect.provideService(JobLanded, landed));
|
|
106
|
+
return {
|
|
107
|
+
...base,
|
|
108
|
+
commit: (input) => bind(base.commit(input)),
|
|
109
|
+
add: (input) => bind(base.add(input))
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
export { decodePacks, featureChange, gitStore, packRow, tryGitStore };
|
package/dist/store/job-try.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { noCall, syncIn } from "./crossing.mjs";
|
|
|
5
5
|
import { jobRepo } from "./scopes.mjs";
|
|
6
6
|
import * as Effect from "effect/Effect";
|
|
7
7
|
import { CurrentJob } from "@ref0/infra";
|
|
8
|
+
import * as Context from "effect/Context";
|
|
8
9
|
// src/store/job-try.ts
|
|
9
10
|
/** A try's `JobLimits` under the adapter's `limits`, checked as a request's are. */
|
|
10
11
|
const jobLimitsOf = (limits) => lessBefore(checkedLimits(limits, "The adapter's callLimits."), jobCallsAround);
|
|
@@ -52,40 +53,18 @@ const stepYielded = (job, spent) => {
|
|
|
52
53
|
return stepSpent("job-step-yielded", `${job}'s ${step} step spent a try's ${callsOf(spent)} after a write landed: the next try goes on from it`, job, step, spent);
|
|
53
54
|
};
|
|
54
55
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
56
|
+
* Mutable landing marker for the job try in scope: set by `doorRecords` once a write through the
|
|
57
|
+
* try lands, so spending the try's call budget after a landed write fails `job-step-yielded`
|
|
58
|
+
* instead of `job-step-calls`.
|
|
58
59
|
*/
|
|
59
|
-
const
|
|
60
|
-
...store,
|
|
61
|
-
commit: async (scope, change) => {
|
|
62
|
-
const committed = await store.commit(scope, change);
|
|
63
|
-
if (committed.ok) saved.landed = true;
|
|
64
|
-
return committed;
|
|
65
|
-
},
|
|
66
|
-
add: async (scope, addition) => {
|
|
67
|
-
await store.add(scope, addition);
|
|
68
|
-
saved.landed = true;
|
|
69
|
-
},
|
|
70
|
-
discard: async (scope, job) => {
|
|
71
|
-
await store.discard(scope, job);
|
|
72
|
-
saved.landed = true;
|
|
73
|
-
},
|
|
74
|
-
retry: async (scope, job, input) => {
|
|
75
|
-
await store.retry(scope, job, input);
|
|
76
|
-
saved.landed = true;
|
|
77
|
-
}
|
|
78
|
-
});
|
|
60
|
+
const JobLanded = Context.Reference("@ref0/git/JobLanded", { defaultValue: () => void 0 });
|
|
79
61
|
/**
|
|
80
|
-
* `run` in a fresh budget of `limits`, named `'job'`, nested in nothing, with
|
|
81
|
-
*
|
|
62
|
+
* `run` in a fresh budget of `limits`, named `'job'`, nested in nothing, with `JobLanded` marking
|
|
63
|
+
* what lands: so a request's budget and a job's never count each other's calls (#2015).
|
|
82
64
|
*/
|
|
83
65
|
const inJobBudget = (limits, run, spent) => Effect.flatMap(inCallScope(CallBudget.make(limits, { name: "job" }), noScope), (budget) => {
|
|
84
66
|
const saved = { landed: false };
|
|
85
|
-
const marked = run(saved)
|
|
86
|
-
...job,
|
|
87
|
-
store: marking(job.store, saved)
|
|
88
|
-
})));
|
|
67
|
+
const marked = Effect.provideService(run(saved), JobLanded, saved);
|
|
89
68
|
const owns = (each) => nestsIn(spentBudget(each), budget);
|
|
90
69
|
return Effect.catchCause(inCallScope(marked, {
|
|
91
70
|
calls: void 0,
|
|
@@ -127,6 +106,4 @@ const jobParts = (job, handler, options) => (take) => take(job, handler, options
|
|
|
127
106
|
const jobsWithin = (limits, jobs) => jobs.map((job) => remakes.get(job)?.(limits) ?? job);
|
|
128
107
|
/** The repo whose scope the try runs in: in any other scope, it's a defect, as `jobRepo` says. */
|
|
129
108
|
const currentRepo = Effect.map(CurrentJob.current, jobRepo);
|
|
130
|
-
|
|
131
|
-
const repoTry = (step) => Effect.flatMap(Effect.all([CurrentJob.store, currentRepo]), ([store, repo]) => step(store, repo));
|
|
132
|
-
export { currentRepo, gitJob, jobLimitsOf, jobParts, jobsWithin, repoTry, stepTooLarge };
|
|
109
|
+
export { JobLanded, currentRepo, gitJob, jobLimitsOf, jobParts, jobsWithin, stepTooLarge };
|
package/dist/store/list-job.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { reconcile } from "./catalogue.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { currentRepo, gitJob } from "./job-try.mjs";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
4
|
import * as Schema from "effect/Schema";
|
|
5
5
|
import { Job, defineJob } from "@ref0/infra";
|
|
@@ -8,12 +8,7 @@ const ListData = /* @__PURE__ */ Schema.Struct({});
|
|
|
8
8
|
const listJobName = "git.list";
|
|
9
9
|
/** The `git.list` job's one key in each repo's scope. */
|
|
10
10
|
const listJobKey = "list";
|
|
11
|
-
|
|
12
|
-
* `git.list`: projects a repo's record into `git/repos`, where its own write didn't get that far,
|
|
13
|
-
* writing an entry only when its revision is newer. Every repo write saves it in the same commit.
|
|
14
|
-
* Its try stops at its timeout, which interrupts it.
|
|
15
|
-
*/
|
|
16
|
-
const listJob = /* @__PURE__ */ gitJob(/* @__PURE__ */ Job.make(listJobName, {
|
|
11
|
+
const ListJob = /* @__PURE__ */ Job.make(listJobName, {
|
|
17
12
|
payload: ListData,
|
|
18
13
|
retry: {
|
|
19
14
|
limit: 10,
|
|
@@ -21,7 +16,48 @@ const listJob = /* @__PURE__ */ gitJob(/* @__PURE__ */ Job.make(listJobName, {
|
|
|
21
16
|
backoff: "exponential",
|
|
22
17
|
maxDelay: "5 minutes"
|
|
23
18
|
}
|
|
24
|
-
})
|
|
19
|
+
});
|
|
20
|
+
const emptySchema = /* @__PURE__ */ Schema.toStandardSchemaV1(ListData);
|
|
21
|
+
/** `git.repack`'s rows, by `defineJob`, for a lost create `git.list` puts aside without importing `storage/`. */
|
|
22
|
+
const repackRows = /* @__PURE__ */ defineJob({
|
|
23
|
+
name: "git.repack",
|
|
24
|
+
schema: emptySchema,
|
|
25
|
+
handler: () => {
|
|
26
|
+
throw new TypeError("'git.repack' runs under repackJob");
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
/** `git.purge`'s row, by `defineJob`, for a lost create `git.list` puts aside without importing `core/`. */
|
|
30
|
+
const purgeRows = /* @__PURE__ */ defineJob({
|
|
31
|
+
name: "git.purge",
|
|
32
|
+
schema: emptySchema,
|
|
33
|
+
handler: () => {
|
|
34
|
+
throw new TypeError("'git.purge' runs under purgeJob");
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
/** Cleanup and purge jobs queued when `git.list` puts aside a create that crashed before standing aside (#1911). */
|
|
38
|
+
const lostCreateJobs = (record) => [
|
|
39
|
+
repackRows.job({
|
|
40
|
+
key: "repack",
|
|
41
|
+
data: {},
|
|
42
|
+
at: record.changedAt
|
|
43
|
+
}),
|
|
44
|
+
...record.fork === void 0 ? [] : [repackRows.job({
|
|
45
|
+
key: "prune",
|
|
46
|
+
data: {},
|
|
47
|
+
at: record.changedAt
|
|
48
|
+
})],
|
|
49
|
+
purgeRows.job({
|
|
50
|
+
key: "purge",
|
|
51
|
+
data: {},
|
|
52
|
+
at: record.changedAt
|
|
53
|
+
})
|
|
54
|
+
];
|
|
55
|
+
/**
|
|
56
|
+
* `git.list`: projects a repo's record into `git/repos`, where its own write didn't get that far,
|
|
57
|
+
* writing an entry only when its revision is newer. Every repo write saves it in the same commit.
|
|
58
|
+
* Its try stops at its timeout, which interrupts it.
|
|
59
|
+
*/
|
|
60
|
+
const listJob = (store) => gitJob(ListJob, () => Effect.asVoid(Effect.flatMap(currentRepo, (internalId) => reconcile(store, internalId, lostCreateJobs))));
|
|
25
61
|
/**
|
|
26
62
|
* `git.list`'s rows, by `defineJob`, as `ListJob.encodedJob` makes them: a write saves one beside
|
|
27
63
|
* its record without `Job.make`'s runtime, which only the server that runs `listJob` needs.
|
package/dist/store/records.d.mts
CHANGED
|
@@ -37,6 +37,9 @@ export type CatalogueEntry = typeof CatalogueEntry.Type;
|
|
|
37
37
|
* what it was made from. `refIndex` is the stamp of the patterns its `refIndex` rows were written
|
|
38
38
|
* under, as `core/ref-index.ts` says: a repo made on a server that keeps an index takes its stamp.
|
|
39
39
|
* `refIndexBuilding` is the rebuild mark, `git.ref-index`'s, while it builds another stamp's rows.
|
|
40
|
+
* `renamedSeq` is the `seq` of the `repo.renamed` that gave the repo its name, when events are kept.
|
|
41
|
+
* `staged` marks a fork's create, deleted, that marked packs or staged rows before its record: no
|
|
42
|
+
* name's entry has heard of it, so its purge projects nothing.
|
|
40
43
|
*/
|
|
41
44
|
export declare const StoredRepo: Schema.Struct<{
|
|
42
45
|
readonly name: Schema.String;
|
|
@@ -50,12 +53,14 @@ export declare const StoredRepo: Schema.Struct<{
|
|
|
50
53
|
readonly createdAt: Schema.Int;
|
|
51
54
|
readonly changedAt: Schema.Int;
|
|
52
55
|
readonly deleted: Schema.optionalKey<Schema.Literal<true>>;
|
|
56
|
+
readonly staged: Schema.optionalKey<Schema.Literal<true>>;
|
|
53
57
|
readonly renamedFrom: Schema.optionalKey<Schema.Struct<{
|
|
54
58
|
readonly name: Schema.String;
|
|
55
59
|
readonly revision: Schema.Int;
|
|
56
60
|
readonly nextSeq: Schema.optionalKey<Schema.Int>;
|
|
57
61
|
readonly receipt: Schema.optionalKey<Schema.String>;
|
|
58
62
|
}>>;
|
|
63
|
+
readonly renamedSeq: Schema.optionalKey<Schema.Int>;
|
|
59
64
|
readonly nextSeq: Schema.optionalKey<Schema.Int>;
|
|
60
65
|
readonly refIndex: Schema.optionalKey<Schema.String>;
|
|
61
66
|
readonly refIndexBuilding: Schema.optionalKey<Schema.Struct<{
|
package/dist/store/records.mjs
CHANGED
|
@@ -58,6 +58,7 @@ const KeptRepoInfo = /* @__PURE__ */ Schema.Struct({
|
|
|
58
58
|
defaultBranch: Schema.optionalKey(Schema.String),
|
|
59
59
|
public: Schema.Boolean,
|
|
60
60
|
upstream: Schema.optionalKey(Schema.String),
|
|
61
|
+
shallow: Schema.Boolean,
|
|
61
62
|
stats: Schema.Struct({
|
|
62
63
|
repo: Schema.String,
|
|
63
64
|
refs: Schema.Int,
|
|
@@ -151,6 +152,9 @@ const ForkRow = /* @__PURE__ */ Schema.Struct({ internalId: InternalRepoId });
|
|
|
151
152
|
* what it was made from. `refIndex` is the stamp of the patterns its `refIndex` rows were written
|
|
152
153
|
* under, as `core/ref-index.ts` says: a repo made on a server that keeps an index takes its stamp.
|
|
153
154
|
* `refIndexBuilding` is the rebuild mark, `git.ref-index`'s, while it builds another stamp's rows.
|
|
155
|
+
* `renamedSeq` is the `seq` of the `repo.renamed` that gave the repo its name, when events are kept.
|
|
156
|
+
* `staged` marks a fork's create, deleted, that marked packs or staged rows before its record: no
|
|
157
|
+
* name's entry has heard of it, so its purge projects nothing.
|
|
154
158
|
*/
|
|
155
159
|
const StoredRepo = /* @__PURE__ */ Schema.Struct({
|
|
156
160
|
name: Schema.String,
|
|
@@ -161,23 +165,25 @@ const StoredRepo = /* @__PURE__ */ Schema.Struct({
|
|
|
161
165
|
createdAt: Schema.Int,
|
|
162
166
|
changedAt: Schema.Int,
|
|
163
167
|
deleted: Schema.optionalKey(Schema.Literal(true)),
|
|
168
|
+
staged: Schema.optionalKey(Schema.Literal(true)),
|
|
164
169
|
renamedFrom: Schema.optionalKey(RenamedFrom),
|
|
170
|
+
renamedSeq: Schema.optionalKey(Schema.Int),
|
|
165
171
|
nextSeq: Schema.optionalKey(NextSeq),
|
|
166
172
|
refIndex: Schema.optionalKey(Schema.String),
|
|
167
173
|
refIndexBuilding: Schema.optionalKey(RefIndexBuilding)
|
|
168
174
|
});
|
|
169
175
|
/**
|
|
170
|
-
* The most roots a repo keeps in its `repo/roots` row, 10,000
|
|
171
|
-
*
|
|
172
|
-
* is this bound too. At 43 B an ID as JSON, its quotes and comma with it, the row is at most 430 KB.
|
|
176
|
+
* The most roots a repo keeps in its `repo/roots` row, 10,000, as `rootsMoved`, the row's one
|
|
177
|
+
* writer, holds them for a client's fetch and an import alike: an import's last segment's boundary
|
|
178
|
+
* becomes the repo's roots when it lands, so `receiveBoundaryMost` is this bound too. At 43 B an ID as JSON, its quotes and comma with it, the row is at most 430 KB.
|
|
173
179
|
*/
|
|
174
180
|
const repoRootsMost = 1e4;
|
|
175
181
|
/** A root's ID as the row keeps it: 40 lowercase hex digits. */
|
|
176
182
|
const RootId = Oid.check(Schema.isPattern(/^[0-9a-f]{40}$/));
|
|
177
183
|
/**
|
|
178
184
|
* A repo's roots, `repo/roots` in its scope: the commits it holds without their parents, as Git's
|
|
179
|
-
* `shallow` file names them, at most `repoRootsMost`, which their
|
|
180
|
-
*
|
|
185
|
+
* `shallow` file names them, at most `repoRootsMost`, which their one writer, `rootsMoved`, holds
|
|
186
|
+
* them to. Every walk sees a root as having no parents (`RepoRoots`). A row of any other ID,
|
|
181
187
|
* or past the bound, doesn't decode, so its read is `DATA_LOSS`.
|
|
182
188
|
*/
|
|
183
189
|
const RepoRootsRow = /* @__PURE__ */ Schema.Struct({ roots: Schema.Array(RootId).check(Schema.isMaxLength(repoRootsMost)) });
|
|
@@ -245,7 +251,7 @@ const ReachedMark = /* @__PURE__ */ Schema.Struct({
|
|
|
245
251
|
});
|
|
246
252
|
/** Whether a mark's row holds both halves: there, and no proof under way. */
|
|
247
253
|
const markHolds = (mark) => mark !== void 0 && mark.pending === void 0;
|
|
248
|
-
/** The job a push saves for each
|
|
254
|
+
/** The job a push saves for each destination an active mirror of a ref it moves names. */
|
|
249
255
|
const mirrorJobName = "sync.mirror";
|
|
250
256
|
/** The job a repo's import runs as: one a repo, in its scope. */
|
|
251
257
|
const importJobName = "sync.import";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "../contracts/promises.mjs";
|
|
2
1
|
import "../contracts/access.mjs";
|
|
3
2
|
import { EffectiveLimits } from "../contracts/objects.mjs";
|
|
4
3
|
import "../contracts/ids.mjs";
|
|
@@ -9,17 +8,19 @@ import "../contracts/result.mjs";
|
|
|
9
8
|
import "./records.mjs";
|
|
10
9
|
import * as Effect from "effect/Effect";
|
|
11
10
|
import "effect/Schema";
|
|
12
|
-
import { Addition,
|
|
11
|
+
import { Addition, JobInput, Key, Moment, Read, Records, Row, Scope, Snapshot } from "@ref0/infra";
|
|
13
12
|
import "effect/Context";
|
|
14
13
|
import "effect/Types";
|
|
15
14
|
/**
|
|
16
|
-
* When a write to a repo's scope must
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
15
|
+
* When a write to a repo's scope must land by, after a read at `heldAt` found the repo's record
|
|
16
|
+
* live: `heldAt` plus `fetchLimits.milliseconds`, less `jobLeaseMargin`. The repo was live at that
|
|
17
|
+
* read, so its delete committed later, and its purge drops its scopes no sooner than `fetchLimits`
|
|
18
|
+
* past the delete's stamp, the record's `changedAt`, which the delete commits within
|
|
19
|
+
* `deleteCommitWithin` of (#1911). The write sends it as its `by`, which the store checks on its
|
|
20
|
+
* own clock as the write lands, so one that stalls in the store lands nothing past it, however
|
|
21
|
+
* long the stall (#2331). The margin covers the delete's commit and the store's clock, as
|
|
22
|
+
* `deleteCommitWithin` splits it, and `HeldWrite.tla` checks that no held write lands after the drop.
|
|
22
23
|
*/
|
|
23
24
|
export declare const heldUntil: (heldAt: Moment, fetchLimits: EffectiveLimits) => Moment;
|
|
24
|
-
/** Whether a write may still
|
|
25
|
+
/** Whether a write may still send its store call, by `heldUntil`'s `by`, at the clock's now. */
|
|
25
26
|
export declare const inTime: (by: Moment) => Effect.Effect<boolean>;
|