@ref0/git 0.14.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access/private-refs.mjs +1 -1
- package/dist/auth/access-jwt.mjs +4 -4
- package/dist/auth/auth-namespace.d.mts +3 -3
- package/dist/auth/auth-namespace.mjs +3 -2
- package/dist/auth/auth.d.mts +3 -3
- package/dist/auth/auth.mjs +9 -8
- package/dist/auth/authorize.mjs +4 -4
- package/dist/auth/fences.d.mts +1 -2
- package/dist/auth/fences.mjs +3 -3
- package/dist/auth/grants.mjs +4 -4
- package/dist/auth/host-function.mjs +19 -2
- package/dist/auth/host-services.mjs +4 -6
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +9 -3
- package/dist/auth/token-cleanup.mjs +67 -0
- package/dist/auth/token-rows.mjs +7 -2
- package/dist/auth/token-text.mjs +9 -1
- package/dist/auth/tokens-base.d.mts +35 -0
- package/dist/auth/tokens-base.mjs +13 -0
- package/dist/auth/tokens-layer.d.mts +2 -27
- package/dist/auth/tokens-layer.mjs +6 -11
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +7 -10
- package/dist/auth/tokens.mjs +10 -81
- package/dist/client/answer.mjs +21 -42
- package/dist/client/client.d.mts +17 -11
- package/dist/client/client.mjs +21 -12
- package/dist/client/git-http.mjs +18 -8
- package/dist/client/local.mjs +74 -37
- package/dist/client/negotiate.mjs +3 -3
- package/dist/client/push-upload.mjs +34 -17
- package/dist/client/remote.mjs +12 -13
- package/dist/client/run-remote-helper.d.mts +2 -1
- package/dist/client/run-remote-helper.mjs +61 -27
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +105 -46
- package/dist/contracts/blobs.d.mts +58 -11
- package/dist/contracts/blobs.mjs +17 -3
- package/dist/contracts/call-allowance.d.mts +13 -0
- package/dist/contracts/call-allowance.mjs +44 -0
- package/dist/contracts/calls-spent.mjs +12 -35
- package/dist/contracts/client.d.mts +18 -18
- package/dist/contracts/commits.d.mts +28 -28
- package/dist/contracts/commits.mjs +1 -1
- package/dist/contracts/engine.d.mts +8 -3
- package/dist/contracts/engine.mjs +10 -1
- package/dist/contracts/events.d.mts +1 -1
- package/dist/contracts/events.mjs +1 -1
- package/dist/contracts/files.d.mts +14 -14
- package/dist/contracts/files.mjs +1 -1
- package/dist/contracts/forks.d.mts +21 -21
- package/dist/contracts/forks.mjs +1 -1
- package/dist/contracts/git-events.d.mts +29 -1
- package/dist/contracts/git-hooks.d.mts +2 -2
- package/dist/contracts/git.d.mts +30 -5
- package/dist/contracts/grants.d.mts +24 -4
- package/dist/contracts/handlers.d.mts +1 -1
- package/dist/contracts/lfs.d.mts +28 -2
- package/dist/contracts/merges.d.mts +3 -2
- package/dist/contracts/object-values.d.mts +1 -0
- package/dist/contracts/object-values.mjs +16 -1
- package/dist/contracts/objects.d.mts +42 -41
- package/dist/contracts/opaque.mjs +1 -1
- package/dist/contracts/operations.mjs +1 -1
- package/dist/contracts/queue.d.mts +247 -55
- package/dist/contracts/queue.mjs +8 -9
- package/dist/contracts/refs.d.mts +30 -27
- package/dist/contracts/refs.mjs +1 -1
- package/dist/contracts/remote.d.mts +8 -12
- package/dist/contracts/remote.mjs +4 -1
- package/dist/contracts/repos.d.mts +32 -141
- package/dist/contracts/repos.mjs +6 -4
- package/dist/contracts/result.d.mts +40 -18
- package/dist/contracts/result.mjs +42 -9
- package/dist/contracts/rules.d.mts +2 -2
- package/dist/contracts/server.d.mts +25 -52
- package/dist/contracts/services.d.mts +6 -9
- package/dist/contracts/services.mjs +1 -2
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/store.d.mts +7 -6
- package/dist/contracts/sync.d.mts +73 -12
- package/dist/contracts/sync.mjs +14 -3
- package/dist/contracts/tags.d.mts +13 -13
- package/dist/contracts/tags.mjs +1 -1
- package/dist/contracts/time.d.mts +3 -0
- package/dist/contracts/{promises.mjs → time.mjs} +1 -1
- package/dist/contracts/tokens.d.mts +17 -19
- package/dist/contracts/tokens.mjs +4 -3
- package/dist/contracts/topics.d.mts +10 -10
- package/dist/contracts/trees.d.mts +16 -16
- package/dist/contracts/trees.mjs +1 -1
- package/dist/contracts/work.d.mts +28 -17
- package/dist/contracts/work.mjs +2 -2
- package/dist/core/access.d.mts +1 -2
- package/dist/core/access.mjs +20 -9
- package/dist/core/ancestry.d.mts +1 -0
- package/dist/core/ancestry.mjs +30 -34
- package/dist/core/asked.mjs +1 -1
- package/dist/core/call-groups.mjs +48 -0
- package/dist/core/call-names.mjs +6 -1
- package/dist/core/call-services.mjs +11 -3
- package/dist/core/events/deliver.d.mts +2 -3
- package/dist/core/events/deliver.mjs +45 -38
- package/dist/core/events/retired.mjs +119 -0
- package/dist/core/forks.mjs +929 -433
- package/dist/core/hooks/groups.mjs +3 -3
- package/dist/core/imports.mjs +127 -41
- package/dist/core/index-job.mjs +131 -38
- package/dist/core/index-lost.d.mts +1 -2
- package/dist/core/index-lost.mjs +2 -2
- package/dist/core/loose-tally.mjs +38 -15
- package/dist/core/merge-parts.d.mts +17 -4
- package/dist/core/merge-parts.mjs +7 -2
- package/dist/core/mirror-rows.mjs +31 -1
- package/dist/core/objects/blobs.mjs +127 -3
- package/dist/core/objects/files.mjs +20 -17
- 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 +4 -4
- package/dist/core/objects/peel.mjs +1 -7
- package/dist/core/objects/reading.mjs +41 -29
- package/dist/core/objects/tags.mjs +4 -1
- package/dist/core/objects/tree-edits.mjs +1 -1
- package/dist/core/objects/trees.mjs +257 -58
- package/dist/core/objects/writing.mjs +4 -10
- package/dist/core/own-writes.mjs +2 -2
- package/dist/core/parts.d.mts +11 -5
- package/dist/core/parts.mjs +9 -10
- package/dist/core/purge.mjs +310 -93
- package/dist/core/push-decide.mjs +2 -0
- package/dist/core/push-files.d.mts +1 -1
- package/dist/core/push.d.mts +2 -2
- package/dist/core/push.mjs +170 -128
- package/dist/core/receipts.d.mts +2 -2
- package/dist/core/receipts.mjs +17 -5
- package/dist/core/ref-index-job.mjs +7 -7
- package/dist/core/ref-view.mjs +75 -32
- package/dist/core/refs.mjs +7 -7
- package/dist/core/registered-rows.mjs +2 -2
- package/dist/core/repack.mjs +58 -48
- package/dist/core/repo-info.mjs +3 -3
- package/dist/core/repos.mjs +21 -9
- package/dist/core/rules/changes.mjs +18 -40
- package/dist/core/rules/check.mjs +6 -5
- package/dist/core/rules/commit-changes.mjs +3 -15
- package/dist/core/rules/context.d.mts +3 -3
- package/dist/core/rules/context.mjs +18 -14
- package/dist/core/rules/fetch.mjs +1 -1
- package/dist/core/rules/protect.mjs +30 -17
- package/dist/core/saved-caller-views.d.mts +8 -3
- package/dist/core/saved-caller-views.mjs +4 -4
- package/dist/core/saved-callers.d.mts +19 -2
- package/dist/core/saved-callers.mjs +1 -1
- package/dist/core/seam.d.mts +17 -28
- package/dist/core/seam.mjs +7 -28
- package/dist/core/tokens.mjs +1 -1
- package/dist/core/view.d.mts +6 -3
- package/dist/core/view.mjs +18 -25
- package/dist/core/work.mjs +60 -15
- package/dist/engine/allotted-xdiff.mjs +3 -16
- package/dist/engine/combined.d.mts +3 -0
- package/dist/engine/combined.mjs +200 -185
- package/dist/engine/content.d.mts +2 -2
- package/dist/engine/content.mjs +1 -1
- package/dist/engine/failures.mjs +2 -1
- package/dist/engine/merge.mjs +7 -9
- package/dist/engine/reads.d.mts +2 -2
- package/dist/engine/reads.mjs +25 -17
- package/dist/engine/xdiff.d.mts +1 -1
- package/dist/engine/xdiff.mjs +1 -1
- package/dist/event-streams/event-streams.d.mts +1 -1
- package/dist/event-streams/event-streams.mjs +1 -1
- package/dist/event-streams/stream.d.mts +3 -3
- package/dist/event-streams/stream.mjs +39 -16
- package/dist/extend.d.mts +2 -7
- package/dist/extend.mjs +1 -4
- package/dist/http/answers.mjs +8 -5
- package/dist/http/core-parts.mjs +169 -96
- package/dist/http/handler.mjs +82 -10
- package/dist/http/node.d.mts +14 -1
- package/dist/http/node.mjs +56 -27
- package/dist/http/parts.d.mts +2 -0
- package/dist/http/push-upload-job.mjs +165 -47
- package/dist/http/push-uploads.mjs +37 -22
- package/dist/http/receive-pack.mjs +14 -53
- package/dist/http/request-snapshot.mjs +258 -0
- package/dist/http/upload-pack.mjs +25 -20
- package/dist/index.d.mts +36 -28
- package/dist/index.mjs +12 -3
- package/dist/lfs/answer.mjs +37 -0
- package/dist/lfs/base.d.mts +3 -1
- package/dist/lfs/base.mjs +25 -1
- package/dist/lfs/copy.d.mts +70 -8
- package/dist/lfs/copy.mjs +217 -21
- package/dist/lfs/layer.d.mts +19 -4
- package/dist/lfs/layer.mjs +25 -13
- package/dist/lfs/locks.mjs +3 -3
- package/dist/lfs/objects.d.mts +2 -1
- package/dist/lfs/objects.mjs +89 -19
- package/dist/lfs/pointers.mjs +2 -2
- package/dist/lfs/rows.d.mts +1 -1
- package/dist/lfs/rows.mjs +50 -9
- package/dist/lfs/upkeep.mjs +82 -17
- package/dist/lfs/uploaded.mjs +1 -1
- package/dist/lfs/wire.mjs +7 -32
- package/dist/merges/merges.mjs +19 -4
- package/dist/node.d.mts +2 -2
- package/dist/protocol/bytes/buffers.d.mts +1 -1
- package/dist/protocol/bytes/buffers.mjs +14 -6
- package/dist/protocol/bytes/deflate.d.mts +1 -1
- package/dist/protocol/bytes/deflate.mjs +1 -1
- package/dist/protocol/bytes/inflate.d.mts +1 -1
- package/dist/protocol/bytes/inflate.mjs +1 -1
- package/dist/protocol/bytes/reader.mjs +6 -1
- package/dist/protocol/bytes/sha1.d.mts +1 -1
- package/dist/protocol/bytes/sha1.mjs +1 -1
- package/dist/protocol/bytes/streams.mjs +27 -1
- package/dist/protocol/diff/read.d.mts +6 -4
- package/dist/protocol/diff/read.mjs +110 -11
- 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/graph.mjs +1 -1
- package/dist/protocol/packs/idx.d.mts +3 -2
- package/dist/protocol/packs/idx.mjs +23 -4
- package/dist/protocol/packs/parts.d.mts +4 -1
- package/dist/protocol/packs/parts.mjs +10 -7
- package/dist/protocol/packs/reader.d.mts +6 -1
- package/dist/protocol/packs/reader.mjs +4 -3
- package/dist/protocol/packs/write-error.d.mts +1 -1
- package/dist/protocol/packs/write-error.mjs +1 -1
- package/dist/protocol/packs/writer.mjs +26 -8
- package/dist/protocol/wire/advertisement.d.mts +1 -1
- package/dist/protocol/wire/advertisement.mjs +3 -2
- package/dist/protocol/wire/fetch.d.mts +1 -1
- package/dist/protocol/wire/fetch.mjs +1 -1
- package/dist/protocol/wire/lines.d.mts +9 -1
- package/dist/protocol/wire/lines.mjs +28 -1
- package/dist/protocol/wire/push-uploads.mjs +10 -7
- package/dist/protocol/wire/receive-pack.d.mts +1 -1
- package/dist/protocol/wire/receive-pack.mjs +1 -1
- package/dist/protocol/wire/report-status.d.mts +1 -1
- package/dist/protocol/wire/report-status.mjs +1 -1
- package/dist/protocol/wire/v2.d.mts +1 -1
- package/dist/protocol/wire/v2.mjs +1 -1
- package/dist/queue/advance.mjs +48 -44
- package/dist/queue/base.d.mts +57 -0
- package/dist/queue/base.mjs +44 -0
- package/dist/queue/calls.mjs +54 -57
- package/dist/queue/commit.mjs +2 -2
- package/dist/queue/host.d.mts +2 -16
- package/dist/queue/host.mjs +2 -7
- package/dist/queue/layer.d.mts +2 -2
- package/dist/queue/layer.mjs +19 -8
- package/dist/queue/limits.mjs +2 -0
- package/dist/queue/push-option.mjs +9 -24
- package/dist/queue/schedule.mjs +2 -2
- package/dist/queue/search.mjs +1 -1
- package/dist/queue/state.mjs +3 -11
- package/dist/queue/trim.mjs +6 -4
- package/dist/rest/blobs.mjs +29 -5
- package/dist/rest/caller.d.mts +4 -4271
- package/dist/rest/caller.mjs +4 -0
- package/dist/rest/client.d.mts +9 -6
- package/dist/rest/client.mjs +25 -8
- package/dist/rest/errors.mjs +1 -1
- package/dist/rest/handler.mjs +2 -2
- package/dist/rest/handlers.mjs +66 -11
- package/dist/rest/layer.d.mts +2 -2
- package/dist/rest/layer.mjs +6 -13
- package/dist/rest/listen.mjs +2 -2
- package/dist/rest/me.d.mts +3 -432
- package/dist/rest/refs.mjs +1 -1
- package/dist/server/check-fetch.mjs +3 -3
- package/dist/server/edge-node.d.mts +11 -8
- package/dist/server/edge-node.mjs +9 -6
- package/dist/server/edge.d.mts +21 -7
- package/dist/server/edge.mjs +56 -11
- package/dist/server/extension.mjs +1 -1
- package/dist/server/git-layer.d.mts +5 -6
- package/dist/server/git-layer.mjs +28 -23
- package/dist/server/git-namespace.d.mts +4 -3
- package/dist/server/git-namespace.mjs +3 -2
- package/dist/server/lifecycle.mjs +19 -107
- package/dist/server/registry.mjs +24 -13
- package/dist/server/server.mjs +249 -371
- package/dist/signin/context.d.mts +1 -2
- package/dist/signin/context.mjs +1 -1
- package/dist/signin/forms.mjs +1 -1
- package/dist/signin/grants.d.mts +2 -2
- package/dist/signin/grants.mjs +1 -1
- package/dist/signin/layer.d.mts +1 -1
- package/dist/signin/layer.mjs +1 -1
- package/dist/signin/wire.mjs +1 -1
- package/dist/storage/allotted.mjs +22 -12
- package/dist/storage/batch-upkeep.mjs +293 -0
- package/dist/storage/batches.d.mts +7 -0
- package/dist/storage/batches.mjs +347 -0
- package/dist/storage/budget.mjs +23 -1
- package/dist/storage/calls.d.mts +2 -3
- package/dist/storage/calls.mjs +166 -182
- package/dist/storage/charged-cache.mjs +180 -0
- package/dist/storage/chunks.d.mts +9 -0
- package/dist/storage/chunks.mjs +410 -0
- package/dist/storage/clean-up.mjs +72 -9
- package/dist/storage/counted-bucket.mjs +35 -13
- package/dist/storage/fetch-row-cache.d.mts +6 -0
- package/dist/storage/fetch-row-cache.mjs +211 -0
- package/dist/storage/fetch.d.mts +2 -0
- package/dist/storage/fetch.mjs +339 -450
- package/dist/storage/held-types.d.mts +0 -1
- package/dist/storage/host-bucket.mjs +10 -6
- package/dist/storage/id-mix.mjs +19 -5
- package/dist/storage/index-bitmaps.mjs +86 -51
- package/dist/storage/index-build.d.mts +2 -4
- package/dist/storage/index-build.mjs +324 -67
- package/dist/storage/index-fetch.d.mts +3 -1
- package/dist/storage/index-fetch.mjs +163 -83
- package/dist/storage/index-files.d.mts +3 -0
- package/dist/storage/index-files.mjs +10 -5
- package/dist/storage/index-graph.mjs +73 -23
- package/dist/storage/index-layers.mjs +55 -25
- package/dist/storage/index-reach.mjs +15 -22
- package/dist/storage/index-remap.mjs +200 -64
- package/dist/storage/index-whole.d.mts +7 -0
- package/dist/storage/index-whole.mjs +235 -0
- package/dist/storage/largest-files.mjs +1 -7
- package/dist/storage/layout.mjs +40 -1
- package/dist/storage/lfs-pointers.mjs +1 -6
- package/dist/storage/link-join.mjs +55 -16
- package/dist/storage/list-source.d.mts +7 -0
- package/dist/storage/list-source.mjs +288 -0
- package/dist/storage/loose.d.mts +10 -7
- package/dist/storage/loose.mjs +293 -82
- package/dist/storage/memory-budget.mjs +242 -26
- package/dist/storage/merge-cut.mjs +9 -6
- package/dist/storage/merge-fence.mjs +1 -1
- package/dist/storage/merge-plan.mjs +3 -2
- package/dist/storage/merge-row.mjs +8 -2
- 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 +3 -4
- package/dist/storage/merge.mjs +3 -3
- package/dist/storage/object-rows.d.mts +4 -3
- package/dist/storage/object-rows.mjs +545 -84
- package/dist/storage/oid-table.mjs +171 -0
- package/dist/storage/pack-order.mjs +104 -47
- package/dist/storage/pack-ranges.d.mts +1 -2
- package/dist/storage/pack-ranges.mjs +48 -21
- package/dist/storage/pack-reads.d.mts +6 -3
- package/dist/storage/pack-reads.mjs +378 -98
- package/dist/storage/pack-receive.d.mts +2 -3
- package/dist/storage/pack-receive.mjs +22 -18
- package/dist/storage/packs.d.mts +2 -2
- package/dist/storage/packs.mjs +587 -156
- package/dist/storage/placed-reads.mjs +34 -17
- package/dist/storage/plan-columns.d.mts +4 -0
- package/dist/storage/plan-columns.mjs +238 -0
- package/dist/storage/prune-keep.mjs +134 -41
- package/dist/storage/prune-seen.mjs +1 -1
- package/dist/storage/prune-walk.mjs +203 -63
- package/dist/storage/prune.mjs +197 -121
- package/dist/storage/push-allotment.mjs +116 -25
- package/dist/storage/push-uploads.mjs +196 -58
- package/dist/storage/pushed-commits.mjs +24 -3
- package/dist/storage/quarantine.d.mts +3 -4
- package/dist/storage/range-cache.mjs +293 -41
- package/dist/storage/raw-ids.mjs +39 -10
- package/dist/storage/ready.d.mts +3 -4
- package/dist/storage/ready.mjs +121 -43
- package/dist/storage/receive-bounds.mjs +50 -13
- package/dist/storage/receive-cache.d.mts +7 -0
- package/dist/storage/receive-cache.mjs +147 -0
- package/dist/storage/receive-files.mjs +1 -1
- package/dist/storage/receive-links.mjs +1 -1
- package/dist/storage/receive-state.d.mts +2 -2
- package/dist/storage/receive-state.mjs +6 -8
- package/dist/storage/receive-steps.d.mts +20 -0
- package/dist/storage/receive-steps.mjs +298 -13
- package/dist/storage/repack-backlog.mjs +1 -3
- package/dist/storage/repack-contained.mjs +2 -2
- package/dist/storage/repack-job.mjs +1 -1
- package/dist/storage/repack.d.mts +3 -4
- package/dist/storage/repack.mjs +54 -9
- package/dist/storage/request-cache.mjs +57 -0
- package/dist/storage/roots.mjs +1 -24
- package/dist/storage/rows.d.mts +3 -3
- package/dist/storage/rows.mjs +2 -2
- package/dist/storage/runs.d.mts +2 -2
- package/dist/storage/runs.mjs +196 -44
- package/dist/storage/send-list.d.mts +1 -0
- package/dist/storage/send-list.mjs +112 -31
- package/dist/storage/single-flight.mjs +13 -7
- package/dist/storage/stream-whole.mjs +188 -66
- package/dist/storage/swap-walk.mjs +1 -1
- package/dist/storage/unpack.mjs +919 -199
- package/dist/storage/visible.mjs +112 -34
- package/dist/storage/walk.mjs +193 -38
- package/dist/storage/wants.mjs +27 -63
- package/dist/store/bodies.mjs +38 -0
- package/dist/store/call-count.d.mts +10 -14
- package/dist/store/call-count.mjs +58 -57
- package/dist/store/catalogue.d.mts +2 -2
- package/dist/store/catalogue.mjs +158 -36
- package/dist/store/crossing.mjs +1 -9
- package/dist/store/cursor-seal.d.mts +1 -2
- package/dist/store/cursor-seal.mjs +17 -7
- package/dist/store/door.mjs +188 -0
- package/dist/store/errors.d.mts +4 -5
- package/dist/store/errors.mjs +119 -49
- package/dist/store/git-store.mjs +30 -7
- package/dist/store/job-try.mjs +98 -40
- package/dist/store/list-job.mjs +32 -20
- package/dist/store/outbox.d.mts +2 -2
- package/dist/store/outbox.mjs +2 -2
- package/dist/store/queue-jobs.mjs +6 -12
- package/dist/store/records.d.mts +5 -2
- package/dist/store/records.mjs +5 -2
- package/dist/store/ref-rows.d.mts +2 -2
- package/dist/store/ref-rows.mjs +2 -2
- package/dist/store/repo-record.d.mts +2 -3
- package/dist/store/repo-record.mjs +34 -22
- package/dist/store/request-snapshot.mjs +5 -0
- package/dist/store/reservations.mjs +3 -3
- package/dist/store/scopes.mjs +11 -0
- package/dist/store/settle.mjs +4 -4
- package/dist/store/topic-jobs.mjs +5 -11
- package/dist/sync/bound.d.mts +3 -3
- package/dist/sync/bound.mjs +10 -7
- package/dist/sync/github.mjs +67 -69
- package/dist/sync/http.mjs +1 -1
- package/dist/sync/import.mjs +205 -57
- package/dist/sync/layer.d.mts +1 -1
- package/dist/sync/layer.mjs +6 -6
- package/dist/sync/lfs-batch.mjs +5 -6
- package/dist/sync/lfs-copy.mjs +191 -20
- package/dist/sync/mirror.mjs +34 -36
- package/dist/sync/said.mjs +17 -38
- package/dist/sync/step.mjs +292 -102
- package/dist/sync/tries.mjs +34 -15
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +2 -2
- package/dist/topics/advance.mjs +12 -13
- package/dist/topics/base.d.mts +15 -0
- package/dist/topics/base.mjs +8 -0
- package/dist/topics/calls.mjs +1 -1
- package/dist/topics/host.mjs +1 -1
- package/dist/topics/layer.d.mts +17 -21
- package/dist/topics/layer.mjs +2 -3
- package/dist/topics/members.mjs +4 -4
- package/dist/topics/public.d.mts +2 -1
- package/dist/topics/topic.mjs +2 -2
- package/package.json +5 -14
- package/dist/auth/helpers.mjs +0 -17
- package/dist/auth.d.mts +0 -5
- package/dist/auth.mjs +0 -5
- 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/promise.mjs +0 -74
- package/dist/core/rules/commit-changes.d.mts +0 -13
- package/dist/effect.d.mts +0 -18
- package/dist/effect.mjs +0 -16
- package/dist/lfs/calls.mjs +0 -26
- package/dist/rest/api.d.mts +0 -23
- package/dist/rest/blobs.d.mts +0 -833
- package/dist/rest/commits.d.mts +0 -3543
- package/dist/rest/errors.d.mts +0 -2124
- package/dist/rest/events.d.mts +0 -426
- package/dist/rest/files.d.mts +0 -1342
- package/dist/rest/forks.d.mts +0 -2160
- package/dist/rest/handlers.d.mts +0 -8
- package/dist/rest/merges.d.mts +0 -477
- package/dist/rest/queue.d.mts +0 -5917
- package/dist/rest/refs.d.mts +0 -2988
- package/dist/rest/repos.d.mts +0 -2567
- package/dist/rest/tags.d.mts +0 -1316
- package/dist/rest/tokens.d.mts +0 -2614
- package/dist/rest/topics.d.mts +0 -2224
- package/dist/rest/trees.d.mts +0 -1709
- package/dist/rest/work.d.mts +0 -1695
- package/dist/server/joined.d.mts +0 -82
- package/dist/server/joined.mjs +0 -68
- package/dist/server/lifecycle.d.mts +0 -2
- package/dist/store/promises.d.mts +0 -11
- package/dist/store/promises.mjs +0 -327
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "../contracts/result.mjs";
|
|
2
|
+
import "../contracts/ids.mjs";
|
|
3
|
+
import "../contracts/objects.mjs";
|
|
4
|
+
import "../contracts/store.mjs";
|
|
5
|
+
import "./memory-budget.mjs";
|
|
6
|
+
import "./pack-receive.mjs";
|
|
7
|
+
import "./pack-reads.mjs";
|
|
8
|
+
import "./quarantine.mjs";
|
|
9
|
+
import "./layout.mjs";
|
|
10
|
+
import "./rows.mjs";
|
|
11
|
+
import { Key, Moment, Row } from "@ref0/infra";
|
|
12
|
+
import * as Schema from "effect/Schema";
|
|
13
|
+
import "effect/Effect";
|
|
14
|
+
/** One uploaded multipart receipt kept across staging tries, matching infra's `ListedPart`. */
|
|
15
|
+
export declare const StagePart: Schema.Struct<{
|
|
16
|
+
readonly part: Schema.Int;
|
|
17
|
+
readonly etag: Schema.String;
|
|
18
|
+
readonly size: Schema.Int;
|
|
19
|
+
}>;
|
|
20
|
+
export type StagePart = typeof StagePart.Type;
|
|
@@ -4,20 +4,26 @@ import { bestEffort } from "../store/errors.mjs";
|
|
|
4
4
|
import { randomText } from "../store/random.mjs";
|
|
5
5
|
import { newChangeId, repoScope } from "../store/scopes.mjs";
|
|
6
6
|
import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
7
|
+
import { scopedReader } from "../protocol/bytes/reader.mjs";
|
|
8
|
+
import { Sha1, Sha1State } from "../protocol/bytes/sha1.mjs";
|
|
7
9
|
import { sha1NowHasher } from "../protocol/bytes/sha1-hasher.mjs";
|
|
8
|
-
import { bucketDeleteMany, bucketDo, readWhole } from "./calls.mjs";
|
|
10
|
+
import { bucketDeleteMany, bucketDo, bucketStreamScoped, readWhole } from "./calls.mjs";
|
|
9
11
|
import { putOnce } from "./index-build.mjs";
|
|
10
12
|
import { packPutOptions, startPut } from "./merge.mjs";
|
|
11
13
|
import { storeStep } from "./pack-receive.mjs";
|
|
14
|
+
import { pushUploadMost } from "./push-uploads.mjs";
|
|
12
15
|
import { deletePackFiles, dropRefused, openQuarantine, quarantineOf, quarantineState } from "./quarantine.mjs";
|
|
13
16
|
import { putStepState, readStepState, stepStateKeys } from "./receive-state.mjs";
|
|
14
|
-
import { markerPrefix, objectCollections, packFiles, receivePrefix } from "./layout.mjs";
|
|
17
|
+
import { isPackId, markerPrefix, objectCollections, packFiles, receivePrefix } from "./layout.mjs";
|
|
15
18
|
import { fileBytesMost } from "./file-limits.mjs";
|
|
16
19
|
import { receiveCpuShare, receiveDropPage, receiveStepFloor, receiveStepGrace } from "./receive-bounds.mjs";
|
|
17
20
|
import { decodeHeld, quarantineKey, stagedKey } from "./rows.mjs";
|
|
18
|
-
import * as Effect from "effect/Effect";
|
|
19
21
|
import * as Schema from "effect/Schema";
|
|
22
|
+
import * as Effect from "effect/Effect";
|
|
23
|
+
import * as Predicate from "effect/Predicate";
|
|
20
24
|
import * as Exit from "effect/Exit";
|
|
25
|
+
import * as Result from "effect/Result";
|
|
26
|
+
import * as Hex from "effect/encoding/Hex";
|
|
21
27
|
// src/storage/receive-steps.ts
|
|
22
28
|
/**
|
|
23
29
|
* A receive run in steps, by its pack: where its next step enters, and when its last step
|
|
@@ -152,8 +158,59 @@ const readAnswer = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, pack) {
|
|
|
152
158
|
/** A pack's trailer: the SHA-1 of every byte before it. */
|
|
153
159
|
const trailerBytes = 20;
|
|
154
160
|
const badTrailer = (bytes) => fail("INVALID_ARGUMENT", `The staged pack's ${bytes} bytes don't end in the SHA-1 of the rest`, { hint: "Fetch the segment again" });
|
|
161
|
+
const wrongSize = (expected, actual) => fail("INVALID_ARGUMENT", `The staged pack has ${actual} bytes, not the ${expected} bytes declared`, { hint: "Push again" });
|
|
162
|
+
const missingStageSource = () => fail("INVALID_ARGUMENT", "the push's pack is missing or isn't a pack");
|
|
155
163
|
const stageBroken = (cause) => gitError("UNAVAILABLE", `The segment's pack ended before it was staged: ${String(cause)}`);
|
|
156
164
|
/**
|
|
165
|
+
* A 20-byte sliding tail for streaming SHA-1 trailer verification without copying incoming chunks:
|
|
166
|
+
* bytes past the trailing 20 feed `hash` directly, so a 1 GiB pack allocates only 20 bytes here.
|
|
167
|
+
*/
|
|
168
|
+
var TrailerTail = class TrailerTail {
|
|
169
|
+
#buf = new Uint8Array(trailerBytes);
|
|
170
|
+
#len = 0;
|
|
171
|
+
static fromHex(hex) {
|
|
172
|
+
const tail = new TrailerTail();
|
|
173
|
+
if (hex.length === 0) return tail;
|
|
174
|
+
const bytes = Result.getOrThrow(Hex.decode(hex));
|
|
175
|
+
if (bytes.byteLength > trailerBytes) throw new RangeError("a pack's trailer tail exceeds 20 B");
|
|
176
|
+
tail.#buf.set(bytes, 0);
|
|
177
|
+
tail.#len = bytes.byteLength;
|
|
178
|
+
return tail;
|
|
179
|
+
}
|
|
180
|
+
push(chunk, hash) {
|
|
181
|
+
const n = chunk.byteLength;
|
|
182
|
+
if (n === 0) return;
|
|
183
|
+
if (this.#len + n <= trailerBytes) {
|
|
184
|
+
this.#buf.set(chunk, this.#len);
|
|
185
|
+
this.#len += n;
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (n >= trailerBytes) {
|
|
189
|
+
if (this.#len > 0) hash.update(this.#buf.subarray(0, this.#len));
|
|
190
|
+
const bodyEnd = n - trailerBytes;
|
|
191
|
+
if (bodyEnd > 0) hash.update(chunk.subarray(0, bodyEnd));
|
|
192
|
+
this.#buf.set(chunk.subarray(bodyEnd), 0);
|
|
193
|
+
this.#len = trailerBytes;
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const drop = this.#len + n - trailerBytes;
|
|
197
|
+
hash.update(this.#buf.subarray(0, drop));
|
|
198
|
+
const keep = this.#len - drop;
|
|
199
|
+
if (keep > 0) this.#buf.copyWithin(0, drop, this.#len);
|
|
200
|
+
this.#buf.set(chunk, keep);
|
|
201
|
+
this.#len = trailerBytes;
|
|
202
|
+
}
|
|
203
|
+
get hex() {
|
|
204
|
+
return hexOf(this.#buf.subarray(0, this.#len));
|
|
205
|
+
}
|
|
206
|
+
matches(hash) {
|
|
207
|
+
if (this.#len < trailerBytes) return false;
|
|
208
|
+
const digest = hash.digest();
|
|
209
|
+
for (let i = 0; i < trailerBytes; i += 1) if (digest[i] !== this.#buf[i]) return false;
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
157
214
|
* A segment's pack staged for its steps, in an invocation of its own: a quarantine opened, the
|
|
158
215
|
* pack put to its `.pack` key as it's read, every byte but its trailer hashed, the trailer
|
|
159
216
|
* checked, then its answer put. A pack cut short, past `atMost`, or with another trailer is
|
|
@@ -165,27 +222,23 @@ const stageReceive = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
165
222
|
return yield* Effect.gen(function* () {
|
|
166
223
|
const reader = yield* Effect.acquireRelease(Effect.sync(() => input.pack.getReader()), (held, exit) => Exit.isSuccess(exit) ? Effect.void : Effect.promise(() => held.cancel().catch(() => void 0)));
|
|
167
224
|
const hash = sha1NowHasher();
|
|
225
|
+
const tail = new TrailerTail();
|
|
168
226
|
const put = yield* startPut(bucket, packFiles(pack).pack, packPutOptions(input));
|
|
169
|
-
let held = /* @__PURE__ */ new Uint8Array(0);
|
|
170
227
|
let bytes = 0;
|
|
171
228
|
for (;;) {
|
|
172
229
|
const read = yield* tryUnlessSpent(() => reader.read(), stageBroken);
|
|
173
230
|
if (read.done) break;
|
|
174
231
|
bytes += read.value.byteLength;
|
|
175
|
-
|
|
176
|
-
joined.set(held, 0);
|
|
177
|
-
joined.set(read.value, held.byteLength);
|
|
178
|
-
const cut = Math.max(0, joined.byteLength - trailerBytes);
|
|
179
|
-
hash.update(joined.subarray(0, cut));
|
|
180
|
-
held = joined.slice(cut);
|
|
232
|
+
tail.push(read.value, hash);
|
|
181
233
|
yield* put.write(read.value);
|
|
182
234
|
}
|
|
183
|
-
if (
|
|
235
|
+
if (input.length !== void 0 && bytes !== input.length) return yield* wrongSize(input.length, bytes);
|
|
236
|
+
if (!tail.matches(hash)) return yield* badTrailer(bytes);
|
|
184
237
|
yield* put.finish;
|
|
185
238
|
const answer = {
|
|
186
239
|
...input.answer,
|
|
187
240
|
bytes,
|
|
188
|
-
checksum:
|
|
241
|
+
checksum: tail.hex
|
|
189
242
|
};
|
|
190
243
|
yield* putAnswer(bucket, pack, answer);
|
|
191
244
|
return {
|
|
@@ -200,6 +253,238 @@ const stageReceive = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
200
253
|
pack
|
|
201
254
|
})));
|
|
202
255
|
});
|
|
256
|
+
/** One uploaded multipart receipt kept across staging tries, matching infra's `ListedPart`. */
|
|
257
|
+
const StagePart = /* @__PURE__ */ Schema.Struct({
|
|
258
|
+
part: Schema.Int,
|
|
259
|
+
etag: Schema.String,
|
|
260
|
+
size: Schema.Int
|
|
261
|
+
});
|
|
262
|
+
/**
|
|
263
|
+
* Persisted progress of a stepped staging multipart put (#1931): the quarantine pack ID, its
|
|
264
|
+
* opaque `Bucket.beginPut` token, how many bytes of the uploaded pack have been committed to
|
|
265
|
+
* parts, their receipts, and the incremental SHA-1 + 20-byte tail up to `offset`.
|
|
266
|
+
*/
|
|
267
|
+
const StageProgress = /* @__PURE__ */ Schema.Struct({
|
|
268
|
+
pack: Schema.String,
|
|
269
|
+
token: Schema.String,
|
|
270
|
+
offset: Schema.Int,
|
|
271
|
+
parts: Schema.Array(StagePart),
|
|
272
|
+
sha1: Sha1State,
|
|
273
|
+
tail: Schema.String.check(Schema.isPattern(/^(?:[0-9a-f]{2}){0,20}$/))
|
|
274
|
+
});
|
|
275
|
+
/**
|
|
276
|
+
* Opens a quarantine and server-side multipart put at `packs/<pack>.pack`, returning the initial
|
|
277
|
+
* `StageProgress` at offset 0 for the caller to persist before uploading parts. Drops the
|
|
278
|
+
* quarantine if `beginPut` fails or is interrupted.
|
|
279
|
+
*/
|
|
280
|
+
const openStageReceive = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
281
|
+
const { bucket } = input;
|
|
282
|
+
const { pack } = yield* openQuarantine(input);
|
|
283
|
+
return {
|
|
284
|
+
pack,
|
|
285
|
+
token: yield* bucketDo(bucket.beginPut(packFiles(pack).pack)).pipe(Effect.tapError(() => dropRefused({
|
|
286
|
+
...input,
|
|
287
|
+
pack
|
|
288
|
+
})), Effect.onInterrupt(() => dropRefused({
|
|
289
|
+
...input,
|
|
290
|
+
pack
|
|
291
|
+
}))),
|
|
292
|
+
offset: 0,
|
|
293
|
+
parts: [],
|
|
294
|
+
sha1: new Sha1().state(),
|
|
295
|
+
tail: ""
|
|
296
|
+
};
|
|
297
|
+
});
|
|
298
|
+
/**
|
|
299
|
+
* Streams the final slice from `sourceBucket` into a restored `Sha1` + `TrailerTail` without
|
|
300
|
+
* uploading parts, verifying exact byte length (EOF+1) and SHA-1 trailer. Used during crash
|
|
301
|
+
* recovery when `completePut` already materialized `packs/<pack>.pack` before a crash prior to
|
|
302
|
+
* `putAnswer`.
|
|
303
|
+
*/
|
|
304
|
+
const verifyFinalSlice = /* @__PURE__ */ Effect.fnUntraced(function* (sourceBucket, sourceKey, sliceStart, sliceLen, totalBytes, sha1, tailHex) {
|
|
305
|
+
const stream = yield* bucketStreamScoped(sourceBucket, sourceKey, {
|
|
306
|
+
offset: sliceStart,
|
|
307
|
+
length: sliceLen + 1
|
|
308
|
+
});
|
|
309
|
+
if (stream === void 0) return yield* missingStageSource();
|
|
310
|
+
const reader = yield* scopedReader(stream);
|
|
311
|
+
const hash = new Sha1(sha1);
|
|
312
|
+
const tail = TrailerTail.fromHex(tailHex);
|
|
313
|
+
let sliceRead = 0;
|
|
314
|
+
for (;;) {
|
|
315
|
+
const read = yield* tryUnlessSpent(() => reader.read(), stageBroken);
|
|
316
|
+
if (read.done) break;
|
|
317
|
+
sliceRead += read.value.byteLength;
|
|
318
|
+
if (sliceRead > sliceLen) return yield* wrongSize(totalBytes, sliceStart + sliceRead);
|
|
319
|
+
tail.push(read.value, hash);
|
|
320
|
+
}
|
|
321
|
+
if (sliceRead < sliceLen) return yield* wrongSize(totalBytes, sliceStart + sliceRead);
|
|
322
|
+
if (!tail.matches(hash)) return yield* badTrailer(totalBytes);
|
|
323
|
+
return tail.hex;
|
|
324
|
+
}, Effect.scoped);
|
|
325
|
+
/**
|
|
326
|
+
* Advances a stepped staging multipart put by one bounded slice (`sliceBytes` bytes in `partBytes`
|
|
327
|
+
* parts). On non-final slices, uploads its parts and returns the next `StageProgress` to persist.
|
|
328
|
+
* On the final slice, requests `sliceLen + 1` bytes to detect both truncated and oversized sources,
|
|
329
|
+
* verifies the 20-byte SHA-1 trailer before calling `completePut`, writes `packs/<pack>/answer`,
|
|
330
|
+
* and returns `staged`. Handles crashes after `completePut` (`NotFound` / `AlreadyExists`) by
|
|
331
|
+
* recovering an existing `answer` or verifying and writing it idempotently; treats a missing or
|
|
332
|
+
* expired multipart token with no materialized pack as `stage-gone`.
|
|
333
|
+
*/
|
|
334
|
+
const stageReceiveStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
335
|
+
const { store, bucket, sourceBucket, repo, staging } = input;
|
|
336
|
+
if (!isPackId(staging.pack)) return yield* fail("INVALID_ARGUMENT", `No pack is staged as ${staging.pack}`);
|
|
337
|
+
const pack = staging.pack;
|
|
338
|
+
const packKey = packFiles(pack).pack;
|
|
339
|
+
const totalBytes = input.bytes;
|
|
340
|
+
const sliceStart = staging.offset;
|
|
341
|
+
const isFinal = sliceStart + input.sliceBytes >= totalBytes;
|
|
342
|
+
const sliceLen = Math.max(0, Math.min(input.sliceBytes, totalBytes - sliceStart));
|
|
343
|
+
const qState = yield* quarantineState({
|
|
344
|
+
store,
|
|
345
|
+
repo,
|
|
346
|
+
pack
|
|
347
|
+
});
|
|
348
|
+
const abortOpen = bucketDo(bucket.abortPut(packKey, staging.token)).pipe(Effect.catchIf((error) => error.code === "NOT_FOUND", () => Effect.void));
|
|
349
|
+
if (qState !== "open") {
|
|
350
|
+
const aborted = yield* Effect.result(abortOpen);
|
|
351
|
+
if (Result.isFailure(aborted)) return yield* Effect.fail(aborted.failure);
|
|
352
|
+
return yield* stageGone(`A staged pack's quarantine is ${qState}`);
|
|
353
|
+
}
|
|
354
|
+
const abortBad = Effect.fnUntraced(function* (failed) {
|
|
355
|
+
const aborted = yield* Effect.result(abortOpen);
|
|
356
|
+
if (Result.isSuccess(aborted)) yield* dropRefused({
|
|
357
|
+
store,
|
|
358
|
+
bucket,
|
|
359
|
+
indexes: input.indexes,
|
|
360
|
+
repo,
|
|
361
|
+
pack
|
|
362
|
+
});
|
|
363
|
+
return yield* failed;
|
|
364
|
+
});
|
|
365
|
+
const recoverNotFound = Effect.gen(function* () {
|
|
366
|
+
const existing = yield* readAnswer(bucket, pack).pipe(Effect.catchIf((error) => error.context?.reason === "stage-gone", () => Effect.succeed(void 0)));
|
|
367
|
+
if (existing !== void 0) return {
|
|
368
|
+
kind: "staged",
|
|
369
|
+
pack,
|
|
370
|
+
bytes: existing.bytes
|
|
371
|
+
};
|
|
372
|
+
if (isFinal) {
|
|
373
|
+
if ((yield* bucketDo(bucket.list(packKey, { limit: 1 }))).items.find((item) => item.key === packKey)?.size === totalBytes) {
|
|
374
|
+
const checksum = yield* verifyFinalSlice(sourceBucket, input.sourceKey, sliceStart, sliceLen, totalBytes, staging.sha1, staging.tail).pipe(Effect.catchIf((error) => error.code === "INVALID_ARGUMENT", (error) => abortBad(Effect.fail(error))));
|
|
375
|
+
const answer = {
|
|
376
|
+
...input.answer,
|
|
377
|
+
bytes: totalBytes,
|
|
378
|
+
checksum
|
|
379
|
+
};
|
|
380
|
+
yield* putAnswer(bucket, pack, answer);
|
|
381
|
+
return {
|
|
382
|
+
kind: "staged",
|
|
383
|
+
pack,
|
|
384
|
+
bytes: totalBytes
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
yield* dropRefused({
|
|
389
|
+
store,
|
|
390
|
+
bucket,
|
|
391
|
+
indexes: input.indexes,
|
|
392
|
+
repo,
|
|
393
|
+
pack
|
|
394
|
+
});
|
|
395
|
+
return yield* stageGone(`A staged pack's multipart upload is gone at ${packKey}`);
|
|
396
|
+
});
|
|
397
|
+
return yield* Effect.gen(function* () {
|
|
398
|
+
const readLen = isFinal ? sliceLen + 1 : sliceLen;
|
|
399
|
+
const stream = yield* bucketStreamScoped(sourceBucket, input.sourceKey, {
|
|
400
|
+
offset: sliceStart,
|
|
401
|
+
length: Math.max(1, readLen)
|
|
402
|
+
});
|
|
403
|
+
if (stream === void 0) return yield* abortBad(missingStageSource());
|
|
404
|
+
const reader = yield* scopedReader(stream);
|
|
405
|
+
const hash = new Sha1(staging.sha1);
|
|
406
|
+
const tail = TrailerTail.fromHex(staging.tail);
|
|
407
|
+
const partSize = Math.max(1, Math.min(input.partBytes, Math.max(1, sliceLen)));
|
|
408
|
+
const partBuf = new Uint8Array(partSize);
|
|
409
|
+
const parts = [...staging.parts];
|
|
410
|
+
let nextPart = parts.length + 1;
|
|
411
|
+
let partFilled = 0;
|
|
412
|
+
let sliceRead = 0;
|
|
413
|
+
const flushPart = Effect.fnUntraced(function* (body) {
|
|
414
|
+
const part = nextPart;
|
|
415
|
+
const uploaded = yield* bucketDo(bucket.putPart(packKey, staging.token, part, body));
|
|
416
|
+
parts.push({
|
|
417
|
+
part: uploaded.part,
|
|
418
|
+
etag: uploaded.etag,
|
|
419
|
+
size: uploaded.size
|
|
420
|
+
});
|
|
421
|
+
nextPart += 1;
|
|
422
|
+
partFilled = 0;
|
|
423
|
+
});
|
|
424
|
+
for (;;) {
|
|
425
|
+
const read = yield* tryUnlessSpent(() => reader.read(), stageBroken);
|
|
426
|
+
if (read.done) break;
|
|
427
|
+
const chunk = read.value;
|
|
428
|
+
if (chunk.byteLength === 0) continue;
|
|
429
|
+
sliceRead += chunk.byteLength;
|
|
430
|
+
if (sliceRead > sliceLen) return yield* abortBad(wrongSize(totalBytes, sliceStart + sliceRead));
|
|
431
|
+
tail.push(chunk, hash);
|
|
432
|
+
let at = 0;
|
|
433
|
+
while (at < chunk.byteLength) {
|
|
434
|
+
const take = Math.min(partBuf.byteLength - partFilled, chunk.byteLength - at);
|
|
435
|
+
partBuf.set(chunk.subarray(at, at + take), partFilled);
|
|
436
|
+
partFilled += take;
|
|
437
|
+
at += take;
|
|
438
|
+
if (partFilled === partBuf.byteLength) yield* flushPart(partBuf);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
if (sliceRead < sliceLen) return yield* abortBad(wrongSize(totalBytes, sliceStart + sliceRead));
|
|
442
|
+
if (partFilled > 0) yield* flushPart(partBuf.subarray(0, partFilled));
|
|
443
|
+
if (!isFinal) return {
|
|
444
|
+
kind: "more",
|
|
445
|
+
staging: {
|
|
446
|
+
pack,
|
|
447
|
+
token: staging.token,
|
|
448
|
+
offset: sliceStart + sliceRead,
|
|
449
|
+
parts,
|
|
450
|
+
sha1: hash.state(),
|
|
451
|
+
tail: tail.hex
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
if (!tail.matches(hash)) return yield* abortBad(badTrailer(totalBytes));
|
|
455
|
+
yield* bucketDo(bucket.completePut(packKey, staging.token, parts, {
|
|
456
|
+
size: input.bytes,
|
|
457
|
+
atMost: pushUploadMost
|
|
458
|
+
})).pipe(Effect.catchIf((error) => error.code === "ALREADY_EXISTS", () => Effect.void), Effect.tapError((error) => error.code === "RESOURCE_EXHAUSTED" || error.code === "INVALID_ARGUMENT" ? dropRefused({
|
|
459
|
+
store,
|
|
460
|
+
bucket,
|
|
461
|
+
indexes: input.indexes,
|
|
462
|
+
repo,
|
|
463
|
+
pack
|
|
464
|
+
}) : Effect.void));
|
|
465
|
+
const answer = {
|
|
466
|
+
...input.answer,
|
|
467
|
+
bytes: totalBytes,
|
|
468
|
+
checksum: tail.hex
|
|
469
|
+
};
|
|
470
|
+
yield* putAnswer(bucket, pack, answer);
|
|
471
|
+
return {
|
|
472
|
+
kind: "staged",
|
|
473
|
+
pack,
|
|
474
|
+
bytes: totalBytes
|
|
475
|
+
};
|
|
476
|
+
}).pipe(Effect.scoped).pipe(Effect.catchIf((error) => error.code === "NOT_FOUND", () => recoverNotFound));
|
|
477
|
+
});
|
|
478
|
+
/**
|
|
479
|
+
* Internal handle attached to `packs()`' opened `GitObjects` for stepped multipart staging:
|
|
480
|
+
* module-private symbol (never `Symbol.for`, never on the public `GitObjects` contract).
|
|
481
|
+
*/
|
|
482
|
+
const stageStepKey = Symbol("ref0/git stage step");
|
|
483
|
+
/** Reads the internal stepped-staging handle from `packs()`' opened `GitObjects`, if present. */
|
|
484
|
+
const stageStepOf = (objects) => {
|
|
485
|
+
if (!Predicate.hasProperty(objects, stageStepKey)) return void 0;
|
|
486
|
+
return objects[stageStepKey];
|
|
487
|
+
};
|
|
203
488
|
/**
|
|
204
489
|
* A staged receive no try can land, dropped: every key under its prefix but its markers, then its
|
|
205
490
|
* record deleted and its `staged` row put, for what a step of an earlier try puts after (#1561),
|
|
@@ -394,4 +679,4 @@ const receiveStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
394
679
|
yield* bestEffort(bucketDeleteMany(bucket, Object.values(keys)));
|
|
395
680
|
return ended;
|
|
396
681
|
});
|
|
397
|
-
export { ReceiveAnswer, ReceiveRow, answerKey, commitStep, deleteStaged, dropReceive, newAttempt, putAnswer, readAnswer, readReceive, receiveKey, receiveStep, stageReceive, stagedRow, stepEntryMostOf, stepInflatedMostOf, stepShareOf, streamStepsMost };
|
|
682
|
+
export { ReceiveAnswer, ReceiveRow, StagePart, StageProgress, answerKey, commitStep, deleteStaged, dropReceive, newAttempt, openStageReceive, putAnswer, readAnswer, readReceive, receiveKey, receiveStep, stageReceive, stageReceiveStep, stageStepKey, stageStepOf, stagedRow, stepEntryMostOf, stepInflatedMostOf, stepShareOf, streamStepsMost };
|
|
@@ -54,8 +54,6 @@ const awaitingRepack = (packs, most) => gitError("UNAVAILABLE", `The repo has ${
|
|
|
54
54
|
most
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
|
-
/** Whether `error` is `awaitingRepack`'s, by its reason. */
|
|
58
|
-
const isAwaitingRepack = (error) => error.code === "UNAVAILABLE" && error.context?.reason === "packs-awaiting-repack";
|
|
59
57
|
/**
|
|
60
58
|
* Refuses a push to `listed` past `backlogPacksMost` packs, or whose packs' join would pass
|
|
61
59
|
* `receiveJoinGetsMost`. Its `most` is below the packs listed, since packs split unevenly can cost
|
|
@@ -67,4 +65,4 @@ const refuseBacklog = (listed) => {
|
|
|
67
65
|
const objects = listed.packs.reduce((sum, pack) => sum + pack.objects, 0);
|
|
68
66
|
return Effect.fail(awaitingRepack(packs, Math.min(packsMost(objects), packs - 1)));
|
|
69
67
|
};
|
|
70
|
-
export { awaitingRepack, backlogPacksMost,
|
|
68
|
+
export { awaitingRepack, backlogPacksMost, joinGets, packsMost, refuseBacklog };
|
|
@@ -6,9 +6,9 @@ import { noRows } from "./object-rows.mjs";
|
|
|
6
6
|
import { openIndexRanges } from "./pack-ranges.mjs";
|
|
7
7
|
import { compareIds } from "./raw-ids.mjs";
|
|
8
8
|
import { leavingRows, namedOf } from "./repack.mjs";
|
|
9
|
-
import * as Effect from "effect/Effect";
|
|
10
|
-
import * as Schema from "effect/Schema";
|
|
11
9
|
import { byBytes } from "@ref0/infra";
|
|
10
|
+
import * as Schema from "effect/Schema";
|
|
11
|
+
import * as Effect from "effect/Effect";
|
|
12
12
|
// src/storage/repack-contained.ts
|
|
13
13
|
/**
|
|
14
14
|
* A listed pack whose every object another listed pack holds, which the step's geometric group
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { collections } from "../store/scopes.mjs";
|
|
2
|
-
import * as Schema from "effect/Schema";
|
|
3
2
|
import { Job } from "@ref0/infra";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
4
|
// src/storage/repack-job.ts
|
|
5
5
|
/**
|
|
6
6
|
* `missed`: the commits of a step that drops objects that missed in a row, each because the
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import "../index.mjs";
|
|
2
1
|
import "./merge.mjs";
|
|
3
2
|
import "../contracts/objects.mjs";
|
|
4
|
-
import "../contracts/
|
|
3
|
+
import "../contracts/time.mjs";
|
|
5
4
|
import { RepoStats } from "../contracts/repos.mjs";
|
|
6
|
-
import "../contracts/
|
|
5
|
+
import "../contracts/result.mjs";
|
|
7
6
|
import "../contracts/store.mjs";
|
|
8
7
|
import "./memory-budget.mjs";
|
|
9
8
|
import "./object-rows.mjs";
|
|
10
9
|
import "./pack-reads.mjs";
|
|
11
10
|
import "./rows.mjs";
|
|
12
|
-
import "effect/Effect";
|
|
13
11
|
import { Key, Moment, Row } from "@ref0/infra";
|
|
12
|
+
import "effect/Effect";
|
|
14
13
|
/**
|
|
15
14
|
* How `packs()` merges a repo's packs: as Git's `repack --geometric=<geometric>`, by object
|
|
16
15
|
* count, so each pack holds at least `geometric` times the objects of all smaller ones together;
|
package/dist/storage/repack.mjs
CHANGED
|
@@ -4,10 +4,10 @@ import { backlogPacksMost } from "./repack-backlog.mjs";
|
|
|
4
4
|
import { foldedRows } from "./merge-choose.mjs";
|
|
5
5
|
import "./merge-cut.mjs";
|
|
6
6
|
import { writeMerged } from "./merge.mjs";
|
|
7
|
-
import { largeBatch, objectKey, objectOfRow, rowsMoved, tooLargeRead } from "./object-rows.mjs";
|
|
7
|
+
import { largeBatch, objectKey, objectOfRow, rowsInflatedBytes, rowsMoved, tooLargeRead } from "./object-rows.mjs";
|
|
8
8
|
import { leavingRow, pruneFloor } from "./rows.mjs";
|
|
9
|
-
import * as Effect from "effect/Effect";
|
|
10
9
|
import { byBytes, limits } from "@ref0/infra";
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
11
|
import * as Predicate from "effect/Predicate";
|
|
12
12
|
// src/storage/repack.ts
|
|
13
13
|
/** Git's `repack.geometric` of 2, and no pack past 1 GiB. */
|
|
@@ -122,15 +122,20 @@ const swapsOf = (listed, added, held) => {
|
|
|
122
122
|
};
|
|
123
123
|
/**
|
|
124
124
|
* The repo's object rows, a small push's each, which a merge folds into its pack: the first
|
|
125
|
-
* `foldedRows` of them
|
|
126
|
-
* `
|
|
125
|
+
* `foldedRows` of them (or those after `after` when scanning past page 1), falling back to
|
|
126
|
+
* `rowReadBatch` then `largeBatch` when one read's 16 MiB answer overflows. They're `whole` when
|
|
127
|
+
* the read came back short of its limit.
|
|
127
128
|
*/
|
|
128
|
-
const readObjectRows =
|
|
129
|
+
const readObjectRows = (input, after) => {
|
|
129
130
|
const scope = repoScope(input.listed.repo);
|
|
130
131
|
const page = (limit) => Effect.map(input.store.read({
|
|
131
132
|
scope,
|
|
132
|
-
reads: [{
|
|
133
|
+
reads: [after === void 0 ? {
|
|
134
|
+
collection: objectCollections.objects,
|
|
135
|
+
limit
|
|
136
|
+
} : {
|
|
133
137
|
collection: objectCollections.objects,
|
|
138
|
+
after,
|
|
134
139
|
limit
|
|
135
140
|
}]
|
|
136
141
|
}), (snapshot) => {
|
|
@@ -140,7 +145,47 @@ const readObjectRows = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
140
145
|
whole: rows.length < limit
|
|
141
146
|
};
|
|
142
147
|
});
|
|
143
|
-
return
|
|
148
|
+
return page(foldedRows).pipe(Effect.catchIf(tooLargeRead, () => page(100).pipe(Effect.catchIf(tooLargeRead, () => page(largeBatch)))));
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Whether the repo's object rows total more than `limit` inflated bytes: exact from `first` when
|
|
152
|
+
* it read every row, short-circuited when `stats` already shows loose row JSON bytes at or under
|
|
153
|
+
* `limit` (JSON base64 is always larger than inflated), else scanning subsequent pages past
|
|
154
|
+
* `first`'s last ID up to `rowsScanPagesMost` until the running inflated total passes `limit` or
|
|
155
|
+
* the rows end. If the scan hits `rowsScanPagesMost` without reaching the end, it returns `true`
|
|
156
|
+
* so upkeep folds a bounded page rather than stalling under a small-row prefix.
|
|
157
|
+
*/
|
|
158
|
+
const rowsPastInflated = /* @__PURE__ */ Effect.fnUntraced(function* (input, first, limit, stats) {
|
|
159
|
+
const looseBytes = stats === void 0 ? 0 : stats.ownBytes - stats.packBytes;
|
|
160
|
+
if (looseBytes > 0 && looseBytes <= limit) return false;
|
|
161
|
+
let total = rowsInflatedBytes(first.rows);
|
|
162
|
+
if (total > limit || first.whole) return total > limit;
|
|
163
|
+
let after = first.rows.at(-1)?.id;
|
|
164
|
+
for (let scanned = 0; scanned < 32 && after !== void 0; scanned += 1) {
|
|
165
|
+
const read = yield* readObjectRows(input, after);
|
|
166
|
+
total += rowsInflatedBytes(read.rows);
|
|
167
|
+
if (total > limit) return true;
|
|
168
|
+
if (read.whole) return false;
|
|
169
|
+
after = read.rows.at(-1)?.id;
|
|
170
|
+
}
|
|
171
|
+
return true;
|
|
172
|
+
});
|
|
173
|
+
/**
|
|
174
|
+
* Folds `objectRows` into a pack of their own, with no walk: shared by prune passes whose first
|
|
175
|
+
* read didn't hold every row and by `git.repack` when accumulated rows pass `unpackInflatedMost`.
|
|
176
|
+
*/
|
|
177
|
+
const foldStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, objectRows, most) {
|
|
178
|
+
const rows = yield* wholeRows(objectRows);
|
|
179
|
+
const merged = yield* mergeWith(input, {
|
|
180
|
+
rows,
|
|
181
|
+
most
|
|
182
|
+
});
|
|
183
|
+
if (merged === void 0 || merged === "too big") return void 0;
|
|
184
|
+
return {
|
|
185
|
+
change: replacing(input, merged, [], rows),
|
|
186
|
+
more: true,
|
|
187
|
+
quarantine: merged.quarantine
|
|
188
|
+
};
|
|
144
189
|
});
|
|
145
190
|
/** Each object row, read whole. */
|
|
146
191
|
const wholeRows = (rows) => Effect.forEach(rows, (row) => objectOfRow(row));
|
|
@@ -246,7 +291,7 @@ const geometricGroup = (members, options, inputsMost = Number.POSITIVE_INFINITY,
|
|
|
246
291
|
for (const member of sorted.slice(0, split)) {
|
|
247
292
|
const share = shareOf(member, seen);
|
|
248
293
|
if (most < packMost && share > most && share <= packMost) continue;
|
|
249
|
-
if (taken.objects + member.objects >
|
|
294
|
+
if (taken.objects + member.objects > 5e5) break;
|
|
250
295
|
if (taken.bytes + share > most) break;
|
|
251
296
|
if (taken.writes + member.writes > groupWrites || group.length === inputsMost) break;
|
|
252
297
|
if (!fits([...group, member])) break;
|
|
@@ -258,4 +303,4 @@ const geometricGroup = (members, options, inputsMost = Number.POSITIVE_INFINITY,
|
|
|
258
303
|
}
|
|
259
304
|
return group.length < 2 ? [] : group;
|
|
260
305
|
};
|
|
261
|
-
export { burstGroupBytes, burstOptions, burstPacksMost, burstQuietMs, defaultRepack, geometricGroup, groupWrites, holdingsOf, holdsOf, leavingRows, maxPackSizeMost, mergeWith, namedOf, optionFor, readObjectRows, replacing, rowsBytes, shareOf, swapsOf, wholeRows };
|
|
306
|
+
export { burstGroupBytes, burstOptions, burstPacksMost, burstQuietMs, defaultRepack, foldStep, geometricGroup, groupWrites, holdingsOf, holdsOf, leavingRows, maxPackSizeMost, mergeWith, namedOf, optionFor, readObjectRows, replacing, rowsBytes, rowsPastInflated, shareOf, swapsOf, wholeRows };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { chargedFixedCache } from "./charged-cache.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Context from "effect/Context";
|
|
4
|
+
// src/storage/request-cache.ts
|
|
5
|
+
/** Registers a per-request `ChargedCache` on `hold` so it releases when the request ends; releases at once if already closed. */
|
|
6
|
+
const keepRequestCache = (hold, cache) => {
|
|
7
|
+
if (hold.keep(Effect.sync(() => cache.release()))) return true;
|
|
8
|
+
cache.release();
|
|
9
|
+
return false;
|
|
10
|
+
};
|
|
11
|
+
/** Wraps a `RequestCacheBudget` (`MemoryBudget`) with the server-side `chargedFixedCache` opener. */
|
|
12
|
+
const serverRequestBudget = (budget) => {
|
|
13
|
+
const openWalkPassed = (most, entryBytes, maxEntries, hold, onEvict) => {
|
|
14
|
+
const cache = chargedFixedCache(budget.requestRoom(most), entryBytes, maxEntries, onEvict);
|
|
15
|
+
return {
|
|
16
|
+
passed: {
|
|
17
|
+
has: (key) => cache.has(key),
|
|
18
|
+
add: (key) => cache.set(key, true),
|
|
19
|
+
release: () => cache.release()
|
|
20
|
+
},
|
|
21
|
+
kept: hold === void 0 || keepRequestCache(hold, cache)
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
requestRoom: (most) => budget.requestRoom(most),
|
|
26
|
+
openWalkPassed
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
/** Standalone request charge capped at `most` bytes, used only when no `MemoryBudget` is attached. */
|
|
30
|
+
const localRequestCharge = (most) => {
|
|
31
|
+
let used = 0;
|
|
32
|
+
let closed = false;
|
|
33
|
+
return {
|
|
34
|
+
lifetime: "request",
|
|
35
|
+
released: () => closed,
|
|
36
|
+
tryGrow: (bytes) => {
|
|
37
|
+
if (closed || used + bytes > most) return false;
|
|
38
|
+
used += bytes;
|
|
39
|
+
return true;
|
|
40
|
+
},
|
|
41
|
+
shrink: (bytes) => {
|
|
42
|
+
used = Math.max(0, used - bytes);
|
|
43
|
+
},
|
|
44
|
+
close: () => {
|
|
45
|
+
closed = true;
|
|
46
|
+
used = 0;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
/** Returns a request room on `budget`, or a standalone capped charge when no budget is attached. */
|
|
51
|
+
const requestChargeOf = (budget, most) => budget === void 0 ? localRequestCharge(most) : budget.requestRoom(most);
|
|
52
|
+
/**
|
|
53
|
+
* The active storage `MemoryBudget` in request context, so per-request caches (`AudienceMemo`,
|
|
54
|
+
* `ViewedMemo`, `walkedVisible`) charge the server's budget directly without altering public types.
|
|
55
|
+
*/
|
|
56
|
+
const RequestMemoryBudget = Context.Reference("@ref0/git/RequestMemoryBudget", { defaultValue: () => void 0 });
|
|
57
|
+
export { RequestMemoryBudget, keepRequestCache, localRequestCharge, requestChargeOf, serverRequestBudget };
|
package/dist/storage/roots.mjs
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import "../contracts/object-values.mjs";
|
|
2
|
-
import "../protocol/objects/object.mjs";
|
|
3
|
-
import { linksOf } from "./links.mjs";
|
|
4
|
-
import * as Result from "effect/Result";
|
|
5
2
|
// src/storage/roots.ts
|
|
6
3
|
/**
|
|
7
4
|
* Of a receive's objects, in `oids`, those `named` says none of the others names: its roots. Links
|
|
@@ -35,24 +32,4 @@ const rootsCollected = (named) => {
|
|
|
35
32
|
roots: () => past ? void 0 : roots
|
|
36
33
|
};
|
|
37
34
|
};
|
|
38
|
-
|
|
39
|
-
* Of whole objects, a small push's rows, their links read again: their roots, and each object they
|
|
40
|
-
* name outside them but the empty tree, which the repo needn't store. `undefined` past the most
|
|
41
|
-
* roots, which proves nothing.
|
|
42
|
-
*/
|
|
43
|
-
const wholeRoots = (objects) => {
|
|
44
|
-
const named = /* @__PURE__ */ new Set();
|
|
45
|
-
for (const object of objects) {
|
|
46
|
-
const links = linksOf(object);
|
|
47
|
-
if (Result.isFailure(links)) return void 0;
|
|
48
|
-
for (const link of links.success) named.add(link.oid);
|
|
49
|
-
}
|
|
50
|
-
const own = new Set(objects.map(({ oid }) => oid));
|
|
51
|
-
const roots = rootsOf(own, (oid) => named.has(oid));
|
|
52
|
-
if (roots === void 0) return void 0;
|
|
53
|
-
return {
|
|
54
|
-
roots,
|
|
55
|
-
outside: [...named].filter((oid) => !own.has(oid) && oid !== "4b825dc642cb6eb9a060e54bf8d69288fbee4904")
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
export { rootsCollected, rootsOf, wholeRoots };
|
|
35
|
+
export { rootsCollected, rootsOf };
|
package/dist/storage/rows.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../contracts/
|
|
1
|
+
import "../contracts/time.mjs";
|
|
2
2
|
import "../contracts/result.mjs";
|
|
3
3
|
import "./layout.mjs";
|
|
4
|
-
import "
|
|
4
|
+
import { Key, Moment, Row } from "@ref0/infra";
|
|
5
5
|
import "effect/Schema";
|
|
6
|
-
import
|
|
6
|
+
import "effect/Effect";
|
package/dist/storage/rows.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { millis } from "../contracts/
|
|
1
|
+
import { millis } from "../contracts/time.mjs";
|
|
2
2
|
import { fail } from "../contracts/result.mjs";
|
|
3
3
|
import { decodeRow } from "../store/errors.mjs";
|
|
4
4
|
import { isPackId, objectCollections } from "./layout.mjs";
|
|
5
|
-
import * as Effect from "effect/Effect";
|
|
6
5
|
import * as Schema from "effect/Schema";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
7
|
// src/storage/rows.ts
|
|
8
8
|
/**
|
|
9
9
|
* A pack being written, added before its first byte. `open` while its writer may still list it;
|
package/dist/storage/runs.d.mts
CHANGED
|
@@ -3,6 +3,6 @@ import "../contracts/result.mjs";
|
|
|
3
3
|
import "../protocol/packs/step.mjs";
|
|
4
4
|
import "./layout.mjs";
|
|
5
5
|
import "./receive-bounds.mjs";
|
|
6
|
-
import "
|
|
6
|
+
import { Page } from "@ref0/infra";
|
|
7
7
|
import "effect/Schema";
|
|
8
|
-
import
|
|
8
|
+
import "effect/Effect";
|