@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
package/dist/storage/unpack.mjs
CHANGED
|
@@ -1,38 +1,77 @@
|
|
|
1
|
-
import { gitError } from "../contracts/result.mjs";
|
|
1
|
+
import { fail, gitError } from "../contracts/result.mjs";
|
|
2
2
|
import { BufferError, BufferMeter } from "../protocol/bytes/buffers.mjs";
|
|
3
|
+
import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
3
4
|
import { joinedBytes } from "../protocol/bytes/joined.mjs";
|
|
4
5
|
import { nativeSha1Hasher } from "../protocol/bytes/sha1-hasher.mjs";
|
|
5
6
|
import { fsckObject } from "../protocol/objects/fsck.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
7
|
+
import { rawLinks } from "../protocol/objects/links-raw.mjs";
|
|
8
|
+
import { emptyTree, objectId } from "../protocol/objects/object.mjs";
|
|
9
|
+
import { readTagTarget } from "../protocol/objects/tag.mjs";
|
|
10
|
+
import { DeltaRun, appliedDelta, deltaResultSize } from "../protocol/packs/delta.mjs";
|
|
8
11
|
import { PackError, PackTransportError, boundedSource, readPack } from "../protocol/packs/reader.mjs";
|
|
12
|
+
import { deltaPartBytes, fastPath, stagedBytes, stagedDeltaKey, stagedKey } from "./batches.mjs";
|
|
13
|
+
import { ChunkWriter, chunkRawBytes, chunkedMoved, chunkedOf, fitsRow, wholeObjectId } from "./chunks.mjs";
|
|
9
14
|
import { checkedFilesRefused, checkedOverflow, fsckRefusal, receiveChecked } from "./fsck.mjs";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
15
|
+
import { LargestFiles } from "./largest-files.mjs";
|
|
16
|
+
import { ReceivedPointers } from "./lfs-pointers.mjs";
|
|
17
|
+
import { boundaryNotInPack, linkReader, objectMissing, segmentCut, segmentTooLarge, shallowLinks, shallowRoot, tagTargetMissing, wrongType } from "./links.mjs";
|
|
18
|
+
import { objectOfRow, objectRow, rowValueBytes } from "./object-rows.mjs";
|
|
19
|
+
import "./receive-bounds.mjs";
|
|
20
|
+
import { rootsOf } from "./roots.mjs";
|
|
21
|
+
import { limits } from "@ref0/infra";
|
|
12
22
|
import * as Effect from "effect/Effect";
|
|
23
|
+
import * as Predicate from "effect/Predicate";
|
|
13
24
|
import * as Result from "effect/Result";
|
|
14
|
-
import
|
|
25
|
+
import * as Base64 from "effect/encoding/Base64";
|
|
15
26
|
// src/storage/unpack.ts
|
|
16
|
-
/**
|
|
17
|
-
const
|
|
27
|
+
/** Internal inflated-byte cap per receive (pack entries, thin bases read once, and delta results). */
|
|
28
|
+
const maxInflatedBytes = 268435456;
|
|
29
|
+
/** The bytes of resolved base objects kept in memory by the receive's LRU. */
|
|
30
|
+
const baseLruBytes = 16777216;
|
|
31
|
+
/** Pending delta instructions held in memory before spilling to `stagedDeltas`. */
|
|
32
|
+
const pendingHeldMost = 25165824;
|
|
33
|
+
/** Maximum known serialized bytes requested in one Phase B round read call. */
|
|
34
|
+
const roundReadBytes = 7340032;
|
|
35
|
+
/** Spilled resolution rounds allowed before refusing `delta-chain-too-deep` (Git's `pack.depth` cap). */
|
|
36
|
+
const deltaRoundsMost = 4095;
|
|
37
|
+
/** Estimated JSON bytes for a base64-encoded row holding `raw` raw bytes. */
|
|
38
|
+
const encodedBytes = (raw) => Math.ceil(raw * 4 / 3) + 64;
|
|
39
|
+
/** Where the large object at `offset` puts its chunks, which a receive's batch holds once. */
|
|
40
|
+
const partAt = (offset) => `p${offset}`;
|
|
18
41
|
/** What the reader may hold besides the entries it hands on: its inflater and buffers. */
|
|
19
42
|
const readerBytes = 1048576;
|
|
20
|
-
const
|
|
43
|
+
const fmtBytes = (bytes) => bytes.toLocaleString("en-US");
|
|
44
|
+
const packBucketHint = "Use Objects.layer() storage, which keeps a push's objects in the bucket";
|
|
45
|
+
const largeBucketHint = "Use Objects.layer() storage, which keeps a large object in the bucket";
|
|
46
|
+
const tooLarge = (bytes, most) => gitError("RESOURCE_EXHAUSTED", `push takes ${fmtBytes(bytes)} bytes; this server takes ${fmtBytes(most)}`, {
|
|
21
47
|
hint: "Push fewer objects at a time",
|
|
22
|
-
hostHint:
|
|
48
|
+
hostHint: packBucketHint,
|
|
23
49
|
context: { reason: "too-large" }
|
|
24
50
|
});
|
|
25
|
-
/** A push whose
|
|
26
|
-
const
|
|
27
|
-
hint: "
|
|
28
|
-
hostHint:
|
|
29
|
-
context: {
|
|
51
|
+
/** A push whose spilled pending deltas need more than `most` resolution rounds. */
|
|
52
|
+
const deltaChainTooDeep = (most) => gitError("RESOURCE_EXHAUSTED", `push's delta chain needs more than ${fmtBytes(most)} resolution rounds`, {
|
|
53
|
+
hint: "Repack with a lower pack.depth and push again",
|
|
54
|
+
hostHint: packBucketHint,
|
|
55
|
+
context: {
|
|
56
|
+
reason: "delta-chain-too-deep",
|
|
57
|
+
most
|
|
58
|
+
}
|
|
30
59
|
});
|
|
31
60
|
/** An object whose row passes one row's 1 MiB: `RESOURCE_EXHAUSTED`, reason `object-too-large`. */
|
|
32
|
-
const rowTooLarge = (oid, bytes) => gitError("RESOURCE_EXHAUSTED", `object ${oid} takes ${bytes
|
|
33
|
-
hostHint:
|
|
61
|
+
const rowTooLarge = (oid, bytes) => gitError("RESOURCE_EXHAUSTED", `object ${oid} takes ${fmtBytes(bytes)} bytes as a row; one row holds ${fmtBytes(limits.valueBytes)}`, {
|
|
62
|
+
hostHint: largeBucketHint,
|
|
34
63
|
context: { reason: "object-too-large" }
|
|
35
64
|
});
|
|
65
|
+
/** An object past `most`, the bytes one object takes: `RESOURCE_EXHAUSTED`, reason `object-too-large`. */
|
|
66
|
+
const fileTooLarge = (bytes, most) => gitError("RESOURCE_EXHAUSTED", `push has an object of ${fmtBytes(bytes)} bytes; this server takes ${fmtBytes(most)} per object`, {
|
|
67
|
+
hint: objectPastHint,
|
|
68
|
+
hostHint: largeBucketHint,
|
|
69
|
+
context: { reason: "object-too-large" }
|
|
70
|
+
});
|
|
71
|
+
/** A pack whose header counts more objects than its push declared or its unpack cap allows. */
|
|
72
|
+
const pastDeclared = (count) => gitError("INVALID_ARGUMENT", `The pack's header counts ${count} objects, past what its push said`, { hint: "Push again" });
|
|
73
|
+
/** A pack holding an object twice, refused as Git's receive with fsck refuses it, by `index-pack --strict`. */
|
|
74
|
+
const twiceInPack = (oid) => gitError("INVALID_ARGUMENT", `The pack is malformed: the same object ${oid} appears twice in the pack`, { hint: "Push again, with each object once" });
|
|
36
75
|
/** An `OFS_DELTA` entry where a storage takes `REF_DELTA` only, the same at any size of push. */
|
|
37
76
|
const ofsRefused = /* @__PURE__ */ gitError("INVALID_ARGUMENT", "The pack has an OFS_DELTA entry", {
|
|
38
77
|
hint: "This server takes REF_DELTA only, as its capabilities say: push with a client that doesn't send ofs-delta",
|
|
@@ -54,221 +93,902 @@ const readFailure = (error) => {
|
|
|
54
93
|
});
|
|
55
94
|
return error;
|
|
56
95
|
};
|
|
96
|
+
/** Bounded byte-size LRU cache of resolved whole objects used as delta bases. */
|
|
97
|
+
var BaseLru = class {
|
|
98
|
+
#entries = /* @__PURE__ */ new Map();
|
|
99
|
+
#limit;
|
|
100
|
+
#used = 0;
|
|
101
|
+
constructor(limit) {
|
|
102
|
+
this.#limit = limit;
|
|
103
|
+
}
|
|
104
|
+
has(oid) {
|
|
105
|
+
return this.#entries.has(oid);
|
|
106
|
+
}
|
|
107
|
+
get(oid) {
|
|
108
|
+
const got = this.#entries.get(oid);
|
|
109
|
+
if (got !== void 0) {
|
|
110
|
+
this.#entries.delete(oid);
|
|
111
|
+
this.#entries.set(oid, got);
|
|
112
|
+
}
|
|
113
|
+
return got;
|
|
114
|
+
}
|
|
115
|
+
set(oid, object) {
|
|
116
|
+
const size = object.bytes.byteLength;
|
|
117
|
+
if (size > this.#limit) return;
|
|
118
|
+
const existing = this.#entries.get(oid);
|
|
119
|
+
if (existing !== void 0) {
|
|
120
|
+
this.#used -= existing.bytes.byteLength;
|
|
121
|
+
this.#entries.delete(oid);
|
|
122
|
+
}
|
|
123
|
+
this.#entries.set(oid, object);
|
|
124
|
+
this.#used += size;
|
|
125
|
+
for (const [evictedOid, oldest] of this.#entries) {
|
|
126
|
+
if (this.#used <= this.#limit) break;
|
|
127
|
+
this.#entries.delete(evictedOid);
|
|
128
|
+
this.#used -= oldest.bytes.byteLength;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
clear() {
|
|
132
|
+
this.#entries.clear();
|
|
133
|
+
this.#used = 0;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const stagedLoss = (id) => fail("DATA_LOSS", `Staged row '${id}' is missing`);
|
|
137
|
+
/** Decodes one `stagedDeltas` row `{ data: base64 }` back to raw delta instructions. */
|
|
138
|
+
const decodeDeltaPart = (row, id) => {
|
|
139
|
+
const value = row?.value;
|
|
140
|
+
const decoded = Predicate.isObject(value) && "data" in value && Predicate.isString(value.data) ? Base64.decode(value.data) : void 0;
|
|
141
|
+
return decoded !== void 0 && Result.isSuccess(decoded) ? Effect.succeed(decoded.success) : stagedLoss(id);
|
|
142
|
+
};
|
|
57
143
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
144
|
+
* The links of a commit or a tag, from its first lines alone, never its message: a commit's tree
|
|
145
|
+
* and parents by `rawLinks`, which reads what `linksOf` does of any object fsck passes
|
|
146
|
+
* (`receive-fsck.git.test.ts`), and a tag's object by `readTagTarget`, from its first two lines and
|
|
147
|
+
* the third's first byte. A blob names none.
|
|
60
148
|
*/
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
|
|
149
|
+
const headLinks = (object) => {
|
|
150
|
+
const malformed = (message) => Result.fail(gitError("INVALID_ARGUMENT", `The ${object.type} ${object.oid} is malformed: ${message}`));
|
|
151
|
+
if (object.type === "tag") {
|
|
152
|
+
const first = object.bytes.indexOf(10);
|
|
153
|
+
const second = first < 0 ? -1 : object.bytes.indexOf(10, first + 1);
|
|
154
|
+
const start = second < 0 ? object.bytes : object.bytes.subarray(0, second + 2);
|
|
155
|
+
const target = readTagTarget(start);
|
|
156
|
+
if (Result.isFailure(target)) return malformed(target.failure.message);
|
|
157
|
+
return Result.succeed([{
|
|
158
|
+
oid: target.success.object,
|
|
159
|
+
type: target.success.type
|
|
160
|
+
}]);
|
|
161
|
+
}
|
|
162
|
+
const oids = [];
|
|
163
|
+
const fault = rawLinks(object.type, object.bytes, (bytes, at) => oids.push(hexOf(bytes.subarray(at, at + 20))));
|
|
164
|
+
if (fault !== void 0) return malformed(fault);
|
|
165
|
+
return Result.succeed(oids.map((oid, at) => ({
|
|
166
|
+
oid,
|
|
167
|
+
type: at === 0 ? "tree" : "commit"
|
|
168
|
+
})));
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* A received pack unpacked in a streaming pass (Phase A) plus bounded delta resolution (Phase B):
|
|
172
|
+
* - Wire bytes are counted before inflation against `limits.bytes`.
|
|
173
|
+
* - Inflated bytes (pack entries, thin bases read once, and delta results) are counted against
|
|
174
|
+
* `maxInflatedBytes` (256 MiB); delta result sizes are checked before allocation.
|
|
175
|
+
* - Whole objects and ready deltas are hashed, fsck'd, and streamed to the single `BatchStager`
|
|
176
|
+
* once the push passes `fastPath` (keeping inline pushes under `fastPath` batch-free).
|
|
177
|
+
* - Pending deltas stay in memory up to `pendingHeld` (24 MiB) and spill past it to `stagedDeltas`
|
|
178
|
+
* through the same `BatchStager`.
|
|
179
|
+
* - Phase B resolves in-memory subtrees with zero calls, streams thin bases via `eachHeld`, and
|
|
180
|
+
* resolves spilled deltas in rounds of <= 7 MiB with OFS descendant prefetch, capped at
|
|
181
|
+
* `deltaRoundsMost` (4,095) rounds before refusing `delta-chain-too-deep`.
|
|
182
|
+
*/
|
|
183
|
+
const unpackObjects = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
184
|
+
const { receive, limits: limits$1, large, staging, memory } = input;
|
|
185
|
+
if (receive.objects > limits$1.objects) return yield* Effect.fail(input.tooMany(receive.objects));
|
|
186
|
+
const past = segmentTooLarge(receive);
|
|
187
|
+
if (past !== void 0) return yield* Effect.fail(past);
|
|
188
|
+
const inflatedCap = input.inflatedBytes ?? 268435456;
|
|
189
|
+
const pendingCap = input.pendingHeld ?? 25165824;
|
|
190
|
+
const roundCap = input.roundBytes ?? 7340032;
|
|
191
|
+
const inlineBytesCap = input.stageBytes ?? fastPath.bytes;
|
|
192
|
+
const roundsCap = input.roundsMost ?? 4095;
|
|
193
|
+
const lru = memory?.lru ?? new BaseLru(input.lruBytes ?? 16777216);
|
|
194
|
+
const growMem = (bytes) => memory === void 0 ? Effect.void : memory.grow(bytes);
|
|
195
|
+
const shrinkMem = (bytes) => memory?.shrink(bytes);
|
|
196
|
+
const pageCap = () => memory?.page(roundCap) ?? roundCap;
|
|
197
|
+
const stagedRowKey = (oid) => stagedKey(activeStager.opened.batch, oid);
|
|
198
|
+
const eachExternal = (oids, take) => input.eachHeld !== void 0 ? input.eachHeld(oids, take) : Effect.flatMap(input.held(oids), (m) => Effect.forEach(m.values(), take, { discard: true }));
|
|
199
|
+
let inflated = 0;
|
|
200
|
+
const chargeInflated = (bytes) => {
|
|
201
|
+
inflated += bytes;
|
|
202
|
+
return inflated > inflatedCap ? Effect.fail(tooLarge(inflated, inflatedCap)) : Effect.void;
|
|
203
|
+
};
|
|
204
|
+
const headers = /* @__PURE__ */ new Map();
|
|
205
|
+
const offsetToOid = /* @__PURE__ */ new Map();
|
|
206
|
+
const chunked = /* @__PURE__ */ new Map();
|
|
207
|
+
const commits = [];
|
|
208
|
+
const headEntries = [];
|
|
209
|
+
const packTrees = [];
|
|
210
|
+
const largest = new LargestFiles();
|
|
211
|
+
const pointers = new ReceivedPointers();
|
|
212
|
+
const checked = receiveChecked();
|
|
213
|
+
let inlineRows = [];
|
|
214
|
+
const inlineByOid = /* @__PURE__ */ new Map();
|
|
215
|
+
let inlineStagedBytes = 0;
|
|
216
|
+
let inlineHeld = 0;
|
|
217
|
+
let activeStager;
|
|
218
|
+
const moved = {
|
|
219
|
+
objects: 0,
|
|
220
|
+
bytes: 0
|
|
221
|
+
};
|
|
222
|
+
const ensureStager = Effect.fnUntraced(function* () {
|
|
223
|
+
if (activeStager !== void 0) return activeStager;
|
|
224
|
+
if (staging === void 0) return yield* Effect.fail(tooLarge(inlineStagedBytes, fastPath.bytes));
|
|
225
|
+
const stager = yield* staging.stager();
|
|
226
|
+
activeStager = stager;
|
|
227
|
+
shrinkMem(inlineHeld);
|
|
228
|
+
inlineHeld = 0;
|
|
229
|
+
for (const row of inlineRows) yield* stager.push(row);
|
|
230
|
+
inlineRows = [];
|
|
231
|
+
inlineByOid.clear();
|
|
232
|
+
inlineStagedBytes = 0;
|
|
233
|
+
return stager;
|
|
234
|
+
});
|
|
235
|
+
const emitChunkedManifest = (item) => {
|
|
236
|
+
const row = large.row(item);
|
|
237
|
+
const counted = chunkedMoved(chunkedOf(row.value));
|
|
238
|
+
moved.objects += counted.objects;
|
|
239
|
+
moved.bytes += counted.bytes;
|
|
240
|
+
return Effect.flatMap(ensureStager(), (stager) => stager.push(row));
|
|
241
|
+
};
|
|
242
|
+
const waitingByOffset = /* @__PURE__ */ new Map();
|
|
243
|
+
const waitingByOid = /* @__PURE__ */ new Map();
|
|
244
|
+
let nextSeq = 0;
|
|
245
|
+
let pendingBytes = 0;
|
|
246
|
+
let unresolved = 0;
|
|
247
|
+
const enqueuePending = (delta) => {
|
|
248
|
+
unresolved += 1;
|
|
249
|
+
const put = (map, key) => {
|
|
250
|
+
const list = map.get(key);
|
|
251
|
+
if (list === void 0) map.set(key, [delta]);
|
|
252
|
+
else list.push(delta);
|
|
253
|
+
};
|
|
254
|
+
if (delta.base.kind === "offset") put(waitingByOffset, delta.base.offset);
|
|
255
|
+
else put(waitingByOid, delta.base.oid);
|
|
256
|
+
};
|
|
257
|
+
/** Looks up an already-resolved object in memory (LRU, inline buffer, or unflushed stager buffer). */
|
|
258
|
+
const readInMemory = (oid) => {
|
|
259
|
+
const cached = lru.get(oid) ?? inlineByOid.get(oid);
|
|
260
|
+
if (cached !== void 0) return Effect.succeed(cached);
|
|
261
|
+
const buffered = activeStager?.bufferedRow(oid);
|
|
262
|
+
return buffered !== void 0 && chunkedOf(buffered.value) === void 0 ? objectOfRow(buffered) : Effect.succeed(void 0);
|
|
263
|
+
};
|
|
264
|
+
const readChunked = (item) => {
|
|
265
|
+
const takes = large;
|
|
266
|
+
lru.clear();
|
|
267
|
+
return Effect.flatMap(takes.hold(item.size), () => Effect.map(takes.staged(item), (bytes) => ({
|
|
268
|
+
oid: item.oid,
|
|
269
|
+
type: item.type,
|
|
270
|
+
bytes
|
|
271
|
+
})));
|
|
272
|
+
};
|
|
273
|
+
const readLocal = (oid) => Effect.flatMap(readInMemory(oid), (inMem) => {
|
|
274
|
+
if (inMem !== void 0) return Effect.succeed(inMem);
|
|
275
|
+
const largeObj = chunked.get(oid);
|
|
276
|
+
return largeObj !== void 0 && large !== void 0 ? readChunked(largeObj) : Effect.succeed(void 0);
|
|
277
|
+
});
|
|
278
|
+
/** Reads an already-resolved own object from memory, `large.staged`, or flushed `stagedObjects`. */
|
|
279
|
+
const readOwnObject = (oid) => Effect.flatMap(readLocal(oid), (local) => local !== void 0 || activeStager === void 0 || staging === void 0 || !headers.has(oid) ? Effect.succeed(local) : Effect.flatMap(staging.readStaged([stagedRowKey(oid)]), ([row]) => row === void 0 ? Effect.succeed(void 0) : objectOfRow(row)));
|
|
280
|
+
const recordWhole = Effect.fnUntraced(function* (offset, object, isChunkedNonBlob) {
|
|
281
|
+
const { oid, type, bytes } = object;
|
|
282
|
+
if (headers.has(oid)) return yield* Effect.fail(twiceInPack(oid));
|
|
283
|
+
const fault = fsckObject(object, checked);
|
|
284
|
+
if (fault !== void 0) return yield* Effect.fail(fsckRefusal(oid, fault));
|
|
285
|
+
const overflow = checkedOverflow(checked);
|
|
286
|
+
if (overflow !== void 0) return yield* Effect.fail(overflow);
|
|
287
|
+
const size = bytes.byteLength;
|
|
288
|
+
headers.set(oid, {
|
|
289
|
+
type,
|
|
290
|
+
size
|
|
291
|
+
});
|
|
292
|
+
offsetToOid.set(offset, oid);
|
|
293
|
+
if (type === "blob") {
|
|
294
|
+
largest.add(oid, size);
|
|
295
|
+
yield* pointers.add(oid, bytes);
|
|
296
|
+
} else if (type === "tree") packTrees.push(oid);
|
|
297
|
+
else {
|
|
298
|
+
const links = yield* Effect.fromResult(headLinks(object));
|
|
299
|
+
headEntries.push({
|
|
300
|
+
oid,
|
|
301
|
+
type,
|
|
302
|
+
links
|
|
303
|
+
});
|
|
304
|
+
if (type === "commit") commits.push({
|
|
305
|
+
oid,
|
|
306
|
+
parents: links.slice(1).map((link) => link.oid)
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
if (isChunkedNonBlob) {
|
|
310
|
+
const part = partAt(offset);
|
|
311
|
+
const writer = yield* ChunkWriter.make(type, size, part, large.stage);
|
|
312
|
+
yield* writer.write(bytes);
|
|
313
|
+
yield* writer.end();
|
|
314
|
+
const item = {
|
|
315
|
+
oid,
|
|
316
|
+
type,
|
|
317
|
+
size,
|
|
318
|
+
part
|
|
319
|
+
};
|
|
320
|
+
chunked.set(oid, item);
|
|
321
|
+
yield* emitChunkedManifest(item);
|
|
322
|
+
} else {
|
|
323
|
+
const row = objectRow(object);
|
|
324
|
+
const valueBytes = rowValueBytes(row.value);
|
|
325
|
+
if (valueBytes > limits.valueBytes) return yield* Effect.fail(rowTooLarge(oid, valueBytes));
|
|
326
|
+
moved.objects += 1;
|
|
327
|
+
moved.bytes += valueBytes;
|
|
328
|
+
if (activeStager !== void 0) yield* activeStager.push(row);
|
|
329
|
+
else {
|
|
330
|
+
const rowSize = stagedBytes(row);
|
|
331
|
+
const inlineDelta = rowSize + size;
|
|
332
|
+
if (staging !== void 0 && (inlineRows.length + 1 > fastPath.rows || inlineStagedBytes + rowSize > inlineBytesCap || memory?.tryGrow(inlineDelta) === false)) yield* (yield* ensureStager()).push(row);
|
|
333
|
+
else {
|
|
334
|
+
if (staging === void 0) yield* growMem(inlineDelta);
|
|
335
|
+
inlineRows.push(row);
|
|
336
|
+
inlineByOid.set(oid, object);
|
|
337
|
+
inlineStagedBytes += rowSize;
|
|
338
|
+
inlineHeld += inlineDelta;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
lru.set(oid, object);
|
|
343
|
+
return {
|
|
344
|
+
oid,
|
|
345
|
+
offset,
|
|
346
|
+
object
|
|
347
|
+
};
|
|
348
|
+
});
|
|
349
|
+
const recordChunkedBlob = (offset, item) => {
|
|
350
|
+
const { oid, type, size } = item;
|
|
351
|
+
if (headers.has(oid)) return Effect.fail(twiceInPack(oid));
|
|
352
|
+
headers.set(oid, {
|
|
353
|
+
type,
|
|
354
|
+
size
|
|
355
|
+
});
|
|
356
|
+
offsetToOid.set(offset, oid);
|
|
357
|
+
chunked.set(oid, item);
|
|
358
|
+
largest.add(oid, size);
|
|
359
|
+
return Effect.as(emitChunkedManifest(item), {
|
|
360
|
+
oid,
|
|
361
|
+
offset,
|
|
362
|
+
item
|
|
363
|
+
});
|
|
364
|
+
};
|
|
365
|
+
const resolveDelta = Effect.fnUntraced(function* (base, offset, instructions, shrinkBytes) {
|
|
366
|
+
const malformed = (message) => malformedPack(`the delta at ${offset}: ${message}`);
|
|
367
|
+
const type = base.type;
|
|
368
|
+
const size = deltaResultSize(instructions);
|
|
369
|
+
if (size !== void 0) {
|
|
370
|
+
if (large !== void 0 && size > large.fileBytes) return yield* Effect.fail(fileTooLarge(size, large.fileBytes));
|
|
371
|
+
if (inflated + size > inflatedCap) return yield* Effect.fail(tooLarge(inflated + size, inflatedCap));
|
|
372
|
+
if (large !== void 0 && !fitsRow(type, size)) {
|
|
373
|
+
yield* chargeInflated(size);
|
|
374
|
+
if (type === "blob") {
|
|
375
|
+
const part = partAt(offset);
|
|
376
|
+
const writer = yield* ChunkWriter.make("blob", size, part, large.stage);
|
|
377
|
+
let waitingBytes = [];
|
|
378
|
+
let waitingSize = 0;
|
|
379
|
+
let given = false;
|
|
380
|
+
const run = new DeltaRun({
|
|
381
|
+
instructions: () => given ? void 0 : (given = true, instructions),
|
|
382
|
+
baseSize: base.bytes.byteLength,
|
|
383
|
+
base: (at, length) => base.bytes.subarray(at, at + length)
|
|
384
|
+
}, {
|
|
385
|
+
size: () => {},
|
|
386
|
+
write: (bytes) => {
|
|
387
|
+
waitingBytes.push(bytes.slice());
|
|
388
|
+
waitingSize += bytes.byteLength;
|
|
389
|
+
return waitingSize >= chunkRawBytes;
|
|
390
|
+
}
|
|
391
|
+
}, large.fileBytes);
|
|
392
|
+
for (;;) {
|
|
393
|
+
const ran = run.run();
|
|
394
|
+
for (const bytes of waitingBytes) yield* writer.write(bytes);
|
|
395
|
+
waitingBytes = [];
|
|
396
|
+
waitingSize = 0;
|
|
397
|
+
if (ran === "paused") continue;
|
|
398
|
+
if (Result.isFailure(ran)) return yield* Effect.fail(malformed(ran.failure.message));
|
|
399
|
+
const oid = yield* writer.end();
|
|
400
|
+
shrinkMem(shrinkBytes);
|
|
401
|
+
return yield* recordChunkedBlob(offset, {
|
|
402
|
+
oid,
|
|
403
|
+
type,
|
|
404
|
+
size,
|
|
405
|
+
part
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
lru.clear();
|
|
410
|
+
yield* large.hold(size);
|
|
411
|
+
const whole = appliedDelta(base.bytes, instructions, large.fileBytes);
|
|
412
|
+
if (Result.isFailure(whole)) return yield* Effect.fail(malformed(whole.failure.message));
|
|
413
|
+
const bytes = whole.success;
|
|
414
|
+
const oid = yield* wholeObjectId(type, bytes);
|
|
415
|
+
shrinkMem(shrinkBytes);
|
|
416
|
+
return yield* recordWhole(offset, {
|
|
417
|
+
oid,
|
|
418
|
+
type,
|
|
419
|
+
bytes
|
|
420
|
+
}, true);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
const remaining = Math.max(0, inflatedCap - inflated);
|
|
424
|
+
const maxResult = large === void 0 ? Math.min(remaining, limits.valueBytes) : remaining;
|
|
425
|
+
const result = appliedDelta(base.bytes, instructions, maxResult);
|
|
426
|
+
if (Result.isFailure(result)) {
|
|
427
|
+
if (result.failure.fault === "too big" && size !== void 0) {
|
|
428
|
+
if (large === void 0 && !fitsRow(type, size)) return yield* Effect.fail(rowTooLarge(emptyTree, size));
|
|
429
|
+
return yield* Effect.fail(tooLarge(inflated + size, inflatedCap));
|
|
430
|
+
}
|
|
431
|
+
return yield* Effect.fail(malformed(result.failure.message));
|
|
432
|
+
}
|
|
433
|
+
const bytes = result.success;
|
|
434
|
+
yield* chargeInflated(bytes.byteLength);
|
|
435
|
+
const oid = yield* objectId({
|
|
436
|
+
type,
|
|
437
|
+
bytes
|
|
438
|
+
});
|
|
439
|
+
if (large === void 0 && !fitsRow(type, bytes.byteLength)) return yield* Effect.fail(rowTooLarge(oid, rowValueBytes(objectRow({
|
|
440
|
+
oid,
|
|
441
|
+
type,
|
|
442
|
+
bytes
|
|
443
|
+
}).value)));
|
|
444
|
+
shrinkMem(shrinkBytes);
|
|
445
|
+
return yield* recordWhole(offset, {
|
|
446
|
+
oid,
|
|
447
|
+
type,
|
|
448
|
+
bytes
|
|
449
|
+
}, false);
|
|
450
|
+
});
|
|
451
|
+
const readyForSpilled = /* @__PURE__ */ new Set();
|
|
452
|
+
const readyOffsetsForSpilled = /* @__PURE__ */ new Set();
|
|
453
|
+
/** Takes in-memory pending children of `base`, leaving any spilled children in the waiting maps. */
|
|
454
|
+
const takeInMemoryChildren = (oid, offset) => {
|
|
455
|
+
const taken = [];
|
|
456
|
+
const pull = (map, key, ready) => {
|
|
457
|
+
const list = map.get(key);
|
|
458
|
+
if (list === void 0) return;
|
|
459
|
+
const kept = [];
|
|
460
|
+
for (const delta of list) if (delta.data !== void 0) {
|
|
461
|
+
pendingBytes -= delta.data.byteLength;
|
|
462
|
+
unresolved -= 1;
|
|
463
|
+
taken.push(delta);
|
|
464
|
+
} else kept.push(delta);
|
|
465
|
+
if (kept.length === 0) map.delete(key);
|
|
466
|
+
else {
|
|
467
|
+
map.set(key, kept);
|
|
468
|
+
ready.add(key);
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
pull(waitingByOid, oid, readyForSpilled);
|
|
472
|
+
if (offset !== void 0) pull(waitingByOffset, offset, readyOffsetsForSpilled);
|
|
473
|
+
return taken;
|
|
474
|
+
};
|
|
475
|
+
const baseOfSeed = (seed) => "object" in seed ? Effect.succeed(seed.object) : readChunked(seed.item);
|
|
476
|
+
/** Zero-call iterative DFS over in-memory pending descendants, materializing one sibling at a time. */
|
|
477
|
+
const resolveInMemoryTree = Effect.fnUntraced(function* (seed) {
|
|
478
|
+
const first = takeInMemoryChildren(seed.oid, seed.offset);
|
|
479
|
+
if (first.length === 0) return;
|
|
480
|
+
const stack = [{
|
|
481
|
+
oid: seed.oid,
|
|
482
|
+
base: yield* baseOfSeed(seed),
|
|
483
|
+
list: first,
|
|
484
|
+
at: 0
|
|
485
|
+
}];
|
|
486
|
+
while (stack.length > 0) {
|
|
487
|
+
const frame = stack[stack.length - 1];
|
|
488
|
+
if (frame.at >= frame.list.length) {
|
|
489
|
+
stack.pop();
|
|
490
|
+
continue;
|
|
491
|
+
}
|
|
492
|
+
const base = frame.base ?? (yield* readOwnObject(frame.oid));
|
|
493
|
+
if (base === void 0) {
|
|
494
|
+
stack.pop();
|
|
495
|
+
continue;
|
|
496
|
+
}
|
|
497
|
+
frame.base = base;
|
|
498
|
+
const delta = frame.list[frame.at++];
|
|
499
|
+
const data = delta.data;
|
|
500
|
+
const recorded = yield* resolveDelta(base, delta.offset, data, data.byteLength);
|
|
501
|
+
const grandkids = takeInMemoryChildren(recorded.oid, recorded.offset);
|
|
502
|
+
if (grandkids.length === 0) continue;
|
|
503
|
+
if (frame.at >= frame.list.length) stack.pop();
|
|
504
|
+
else if (headers.has(frame.oid)) frame.base = void 0;
|
|
505
|
+
stack.push({
|
|
506
|
+
oid: recorded.oid,
|
|
507
|
+
base: yield* baseOfSeed(recorded),
|
|
508
|
+
list: grandkids,
|
|
509
|
+
at: 0
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
const walk = (seed) => Effect.flatMap(seed, resolveInMemoryTree);
|
|
64
514
|
let pieces = [];
|
|
65
|
-
let
|
|
515
|
+
let chunkWriter;
|
|
516
|
+
let wholeBuf;
|
|
517
|
+
let spill;
|
|
518
|
+
let directBase;
|
|
519
|
+
const resetEntry = () => {
|
|
520
|
+
pieces = [];
|
|
521
|
+
chunkWriter = void 0;
|
|
522
|
+
wholeBuf = void 0;
|
|
523
|
+
spill = void 0;
|
|
524
|
+
directBase = void 0;
|
|
525
|
+
};
|
|
526
|
+
const flushSpillPart = Effect.fnUntraced(function* (active, force) {
|
|
527
|
+
while (active.bytes >= 768e3 || force && active.bytes > 0) {
|
|
528
|
+
const joined = joinedBytes(active.buf);
|
|
529
|
+
const take = Math.min(joined.byteLength, deltaPartBytes);
|
|
530
|
+
const rest = joined.subarray(take);
|
|
531
|
+
yield* (yield* ensureStager()).pushDelta(active.seq, active.parts.length, joined.subarray(0, take));
|
|
532
|
+
active.parts.push(take);
|
|
533
|
+
active.buf = rest.byteLength > 0 ? [rest] : [];
|
|
534
|
+
active.bytes = rest.byteLength;
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
memory?.free?.(ensureStager, [waitingByOid, waitingByOffset], (bytes) => {
|
|
538
|
+
pendingBytes -= bytes;
|
|
539
|
+
}, () => inlineHeld > 0);
|
|
66
540
|
const sink = {
|
|
67
|
-
begin: ({ count }) => count >
|
|
541
|
+
begin: ({ count }) => count > limits$1.objects ? Effect.fail(input.tooMany(count)) : count > receive.objects ? Effect.fail(pastDeclared(count)) : Effect.void,
|
|
68
542
|
entry: (entry) => {
|
|
69
543
|
if (entry.kind === "ofs" && input.offsetDeltas === "refuse") return Effect.fail(ofsRefused);
|
|
70
|
-
|
|
71
|
-
|
|
544
|
+
resetEntry();
|
|
545
|
+
if (entry.base !== void 0) {
|
|
546
|
+
if (large === void 0 && entry.size > 7340032) return Effect.fail(rowTooLarge(emptyTree, entry.size));
|
|
547
|
+
const base = entry.base;
|
|
548
|
+
const baseOid = base.kind === "offset" ? offsetToOid.get(base.offset) : base.oid;
|
|
549
|
+
return Effect.flatMap(baseOid === void 0 ? Effect.succeed(void 0) : readInMemory(baseOid), (inMem) => {
|
|
550
|
+
if (inMem !== void 0) {
|
|
551
|
+
directBase = inMem;
|
|
552
|
+
return growMem(entry.size);
|
|
553
|
+
}
|
|
554
|
+
const canHold = pendingBytes + entry.size <= pendingCap;
|
|
555
|
+
return Effect.map(memory === void 0 ? Effect.succeed(canHold) : memory.delta(entry.size, canHold, Math.min(entry.size, deltaPartBytes)), (hold) => {
|
|
556
|
+
if (!hold) spill = {
|
|
557
|
+
seq: nextSeq++,
|
|
558
|
+
offset: entry.offset,
|
|
559
|
+
base,
|
|
560
|
+
size: entry.size,
|
|
561
|
+
parts: [],
|
|
562
|
+
buf: [],
|
|
563
|
+
bytes: 0
|
|
564
|
+
};
|
|
565
|
+
});
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
const type = entry.kind;
|
|
569
|
+
if (large !== void 0) {
|
|
570
|
+
if (entry.size > large.fileBytes) return Effect.fail(fileTooLarge(entry.size, large.fileBytes));
|
|
571
|
+
if (!fitsRow(type, entry.size)) {
|
|
572
|
+
if (inflated + entry.size > inflatedCap) return Effect.fail(tooLarge(inflated + entry.size, inflatedCap));
|
|
573
|
+
if (type === "blob") return Effect.map(ChunkWriter.make(type, entry.size, partAt(entry.offset), large.stage), (writer) => {
|
|
574
|
+
chunkWriter = writer;
|
|
575
|
+
});
|
|
576
|
+
lru.clear();
|
|
577
|
+
return Effect.map(large.hold(entry.size), () => {
|
|
578
|
+
wholeBuf = {
|
|
579
|
+
bytes: new Uint8Array(entry.size),
|
|
580
|
+
at: 0
|
|
581
|
+
};
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
} else if (!fitsRow(type, entry.size)) return Effect.fail(rowTooLarge(emptyTree, entry.size));
|
|
72
585
|
},
|
|
73
586
|
data: (bytes) => {
|
|
74
|
-
|
|
75
|
-
if (
|
|
587
|
+
const over = chargeInflated(bytes.byteLength);
|
|
588
|
+
if (inflated > inflatedCap) return over;
|
|
589
|
+
if (chunkWriter !== void 0) return chunkWriter.write(bytes);
|
|
590
|
+
if (wholeBuf !== void 0) {
|
|
591
|
+
if (wholeBuf.at + bytes.byteLength > wholeBuf.bytes.byteLength) return Effect.fail(malformedPack("an object passes its size"));
|
|
592
|
+
wholeBuf.bytes.set(bytes, wholeBuf.at);
|
|
593
|
+
wholeBuf.at += bytes.byteLength;
|
|
594
|
+
return Effect.void;
|
|
595
|
+
}
|
|
596
|
+
if (spill !== void 0) {
|
|
597
|
+
spill.buf.push(bytes.slice());
|
|
598
|
+
spill.bytes += bytes.byteLength;
|
|
599
|
+
return spill.bytes >= 768e3 ? flushSpillPart(spill, false) : Effect.void;
|
|
600
|
+
}
|
|
76
601
|
pieces.push(bytes.slice());
|
|
77
602
|
return Effect.void;
|
|
78
603
|
},
|
|
79
|
-
entryEnd:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
604
|
+
entryEnd: Effect.fnUntraced(function* (entry) {
|
|
605
|
+
const streamed = chunkWriter;
|
|
606
|
+
const body = wholeBuf;
|
|
607
|
+
const spilling = spill;
|
|
608
|
+
const baseReady = directBase;
|
|
609
|
+
const entryPieces = pieces;
|
|
610
|
+
resetEntry();
|
|
611
|
+
if (streamed !== void 0) {
|
|
612
|
+
const oid = yield* streamed.end();
|
|
613
|
+
return yield* walk(recordChunkedBlob(entry.offset, {
|
|
614
|
+
oid,
|
|
615
|
+
type: streamed.type,
|
|
616
|
+
size: streamed.size,
|
|
617
|
+
part: streamed.part
|
|
618
|
+
}));
|
|
619
|
+
}
|
|
620
|
+
if (body !== void 0) {
|
|
621
|
+
if (body.at !== body.bytes.byteLength) return yield* Effect.fail(malformedPack(`an object of ${body.bytes.byteLength} bytes ended at ${body.at}`));
|
|
622
|
+
const type = entry.kind;
|
|
623
|
+
const oid = yield* wholeObjectId(type, body.bytes);
|
|
624
|
+
return yield* walk(recordWhole(entry.offset, {
|
|
625
|
+
oid,
|
|
626
|
+
type,
|
|
627
|
+
bytes: body.bytes
|
|
628
|
+
}, true));
|
|
629
|
+
}
|
|
630
|
+
if (spilling !== void 0) {
|
|
631
|
+
yield* flushSpillPart(spilling, true);
|
|
632
|
+
shrinkMem(Math.min(spilling.size, deltaPartBytes));
|
|
633
|
+
enqueuePending(spilling);
|
|
634
|
+
if (spilling.base.kind === "offset") {
|
|
635
|
+
if (offsetToOid.has(spilling.base.offset)) readyOffsetsForSpilled.add(spilling.base.offset);
|
|
636
|
+
} else if (headers.has(spilling.base.oid)) readyForSpilled.add(spilling.base.oid);
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
if (entry.base !== void 0) {
|
|
640
|
+
const data = joinedBytes(entryPieces);
|
|
641
|
+
if (baseReady !== void 0) return yield* walk(resolveDelta(baseReady, entry.offset, data, data.byteLength));
|
|
642
|
+
pendingBytes += data.byteLength;
|
|
643
|
+
enqueuePending({
|
|
644
|
+
seq: nextSeq++,
|
|
645
|
+
offset: entry.offset,
|
|
646
|
+
base: entry.base,
|
|
647
|
+
size: data.byteLength,
|
|
648
|
+
data
|
|
649
|
+
});
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
const type = entry.kind;
|
|
653
|
+
const bytes = joinedBytes(entryPieces);
|
|
654
|
+
const oid = yield* objectId({
|
|
655
|
+
type,
|
|
656
|
+
bytes
|
|
83
657
|
});
|
|
84
|
-
|
|
85
|
-
|
|
658
|
+
return yield* walk(recordWhole(entry.offset, {
|
|
659
|
+
oid,
|
|
660
|
+
type,
|
|
661
|
+
bytes
|
|
662
|
+
}, false));
|
|
86
663
|
})
|
|
87
664
|
};
|
|
88
665
|
const meter = new BufferMeter(readerBytes);
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
666
|
+
const rawSource = boundedSource(receive.pack, /* @__PURE__ */ new Uint8Array(0), meter);
|
|
667
|
+
const wireCap = receive.objects === 0 ? Math.max(limits$1.bytes, 32) : limits$1.bytes;
|
|
668
|
+
let wireBytes = 0;
|
|
669
|
+
const objectBytes = large === void 0 ? inflatedCap : Math.max(inflatedCap, large.fileBytes);
|
|
670
|
+
const packRead = yield* readPack({ read: Effect.flatMap(rawSource.read, (chunk) => {
|
|
671
|
+
if (chunk === void 0) return Effect.succeed(void 0);
|
|
672
|
+
const total = wireBytes += chunk.byteLength;
|
|
673
|
+
return total > wireCap ? Effect.fail(tooLarge(total, wireCap)) : Effect.succeed(chunk);
|
|
674
|
+
}) }, nativeSha1Hasher(), sink, {
|
|
675
|
+
objectBytes,
|
|
676
|
+
deltaBytes: inflatedCap
|
|
677
|
+
}, meter).pipe(Effect.mapError(readFailure), Effect.ensuring(rawSource.cancel));
|
|
678
|
+
const externalBases = /* @__PURE__ */ new Map();
|
|
679
|
+
const baseOf = (item) => item.oid ?? offsetToOid.get(item.offset);
|
|
680
|
+
let rounds = 0;
|
|
681
|
+
const drainSpilledRounds = Effect.fnUntraced(function* () {
|
|
682
|
+
while (readyForSpilled.size > 0 || readyOffsetsForSpilled.size > 0) {
|
|
683
|
+
const wave = [];
|
|
684
|
+
let needsSpillRound = false;
|
|
685
|
+
const take = (delta, item) => {
|
|
686
|
+
if (delta.data !== void 0) pendingBytes -= delta.data.byteLength;
|
|
687
|
+
else needsSpillRound = true;
|
|
688
|
+
unresolved -= 1;
|
|
689
|
+
wave.push(item);
|
|
690
|
+
};
|
|
691
|
+
const drainReady = (ready, map, oidOf) => {
|
|
692
|
+
for (const key of ready) {
|
|
693
|
+
const list = map.get(key);
|
|
694
|
+
const baseOid = oidOf(key);
|
|
695
|
+
if (list === void 0 || baseOid === void 0) continue;
|
|
696
|
+
map.delete(key);
|
|
697
|
+
const start = wave.length;
|
|
698
|
+
for (const delta of list) take(delta, {
|
|
699
|
+
delta,
|
|
700
|
+
oid: baseOid
|
|
701
|
+
});
|
|
702
|
+
for (let i = start; i < wave.length; i++) {
|
|
703
|
+
const parent = wave[i].delta;
|
|
704
|
+
const kids = waitingByOffset.get(parent.offset);
|
|
705
|
+
if (kids === void 0) continue;
|
|
706
|
+
waitingByOffset.delete(parent.offset);
|
|
707
|
+
for (const kid of kids) take(kid, {
|
|
708
|
+
delta: kid,
|
|
709
|
+
offset: parent.offset
|
|
710
|
+
});
|
|
711
|
+
}
|
|
129
712
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
if (
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
713
|
+
ready.clear();
|
|
714
|
+
};
|
|
715
|
+
drainReady(readyForSpilled, waitingByOid, (oid) => oid);
|
|
716
|
+
drainReady(readyOffsetsForSpilled, waitingByOffset, (offset) => offsetToOid.get(offset));
|
|
717
|
+
if (wave.length === 0) break;
|
|
718
|
+
if (needsSpillRound) {
|
|
719
|
+
rounds += 1;
|
|
720
|
+
if (rounds > roundsCap) return yield* Effect.fail(deltaChainTooDeep(roundsCap));
|
|
721
|
+
}
|
|
722
|
+
for (let waveAt = 0; waveAt < wave.length;) {
|
|
723
|
+
const page = [];
|
|
724
|
+
const pageBases = /* @__PURE__ */ new Set();
|
|
725
|
+
let pageBytes = 0;
|
|
726
|
+
while (waveAt < wave.length) {
|
|
727
|
+
const item = wave[waveAt];
|
|
728
|
+
const oid = baseOf(item);
|
|
729
|
+
let bytes = item.delta.data === void 0 ? encodedBytes(item.delta.size) : 0;
|
|
730
|
+
if (oid !== void 0 && !pageBases.has(oid) && !lru.has(oid) && !chunked.has(oid) && !inlineByOid.has(oid) && activeStager?.bufferedRow(oid) === void 0) {
|
|
731
|
+
const size = headers.get(oid)?.size ?? externalBases.get(oid) ?? 0;
|
|
732
|
+
if (size > 0) bytes += encodedBytes(size);
|
|
733
|
+
}
|
|
734
|
+
if (page.length > 0 && pageBytes + bytes > pageCap()) break;
|
|
735
|
+
page.push(item);
|
|
736
|
+
if (oid !== void 0) pageBases.add(oid);
|
|
737
|
+
pageBytes += bytes;
|
|
738
|
+
waveAt += 1;
|
|
739
|
+
}
|
|
740
|
+
let pageHeld = 0;
|
|
741
|
+
if (page.length === 1 && large !== void 0) {
|
|
742
|
+
const only = page[0].delta;
|
|
743
|
+
if (only.data === void 0 && only.size > roundCap) yield* large.hold(only.size - roundCap);
|
|
744
|
+
}
|
|
745
|
+
const fetchedBases = /* @__PURE__ */ new Map();
|
|
746
|
+
const fetchedInstructions = /* @__PURE__ */ new Map();
|
|
747
|
+
const missingExternal = [];
|
|
748
|
+
const toRead = [];
|
|
749
|
+
for (const { delta } of page) {
|
|
750
|
+
if (delta.data !== void 0) {
|
|
751
|
+
fetchedInstructions.set(delta.seq, delta.data);
|
|
752
|
+
continue;
|
|
753
|
+
}
|
|
754
|
+
yield* growMem(delta.size);
|
|
755
|
+
pageHeld += delta.size;
|
|
756
|
+
const buf = new Uint8Array(delta.size);
|
|
757
|
+
fetchedInstructions.set(delta.seq, buf);
|
|
758
|
+
let at = 0;
|
|
759
|
+
for (const [partIdx, rawSize] of (delta.parts ?? []).entries()) {
|
|
760
|
+
const buffered = activeStager?.bufferedDelta(delta.seq, partIdx);
|
|
761
|
+
if (buffered !== void 0) buf.set(buffered, at);
|
|
762
|
+
else toRead.push({
|
|
763
|
+
key: stagedDeltaKey(activeStager.opened.batch, delta.seq, partIdx),
|
|
764
|
+
bytes: encodedBytes(rawSize),
|
|
765
|
+
buf,
|
|
766
|
+
offset: at
|
|
767
|
+
});
|
|
768
|
+
at += rawSize;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
for (const oid of pageBases) {
|
|
772
|
+
const local = yield* readLocal(oid);
|
|
773
|
+
if (local !== void 0) {
|
|
774
|
+
fetchedBases.set(oid, local);
|
|
775
|
+
continue;
|
|
776
|
+
}
|
|
777
|
+
if (externalBases.has(oid)) {
|
|
778
|
+
missingExternal.push(oid);
|
|
779
|
+
continue;
|
|
780
|
+
}
|
|
781
|
+
const header = headers.get(oid);
|
|
782
|
+
if (header !== void 0 && activeStager !== void 0) toRead.push({
|
|
783
|
+
key: stagedRowKey(oid),
|
|
784
|
+
bytes: encodedBytes(header.size),
|
|
785
|
+
oid
|
|
160
786
|
});
|
|
161
|
-
unresolved -= 1;
|
|
162
787
|
}
|
|
163
|
-
|
|
788
|
+
if (toRead.length > 0 && staging !== void 0) for (let at = 0; at < toRead.length;) {
|
|
789
|
+
const batch = [];
|
|
790
|
+
let bytes = 0;
|
|
791
|
+
while (at < toRead.length) {
|
|
792
|
+
const item = toRead[at];
|
|
793
|
+
if (batch.length > 0 && bytes + item.bytes > roundCap) break;
|
|
794
|
+
batch.push(item);
|
|
795
|
+
bytes += item.bytes;
|
|
796
|
+
at += 1;
|
|
797
|
+
}
|
|
798
|
+
const rows = yield* staging.readStaged(batch.map(({ key }) => key));
|
|
799
|
+
for (const [i, item] of batch.entries()) {
|
|
800
|
+
const row = rows[i];
|
|
801
|
+
if ("oid" in item) {
|
|
802
|
+
if (row === void 0) return yield* stagedLoss(item.oid);
|
|
803
|
+
const obj = yield* objectOfRow(row);
|
|
804
|
+
yield* growMem(obj.bytes.byteLength);
|
|
805
|
+
pageHeld += obj.bytes.byteLength;
|
|
806
|
+
fetchedBases.set(obj.oid, obj);
|
|
807
|
+
lru.set(obj.oid, obj);
|
|
808
|
+
} else item.buf.set(yield* decodeDeltaPart(row, item.key.id), item.offset);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
const runItem = (item, base) => {
|
|
812
|
+
const instructions = fetchedInstructions.get(item.delta.seq);
|
|
813
|
+
if (instructions === void 0) return Effect.void;
|
|
814
|
+
fetchedInstructions.delete(item.delta.seq);
|
|
815
|
+
return walk(resolveDelta(base, item.delta.offset, instructions, item.delta.data?.byteLength ?? 0));
|
|
816
|
+
};
|
|
817
|
+
if (missingExternal.length > 0) yield* eachExternal(missingExternal, (base) => {
|
|
818
|
+
lru.set(base.oid, base);
|
|
819
|
+
return Effect.forEach(page, (item) => baseOf(item) === base.oid ? runItem(item, base) : Effect.void, { discard: true });
|
|
820
|
+
});
|
|
821
|
+
for (const item of page) {
|
|
822
|
+
if (!fetchedInstructions.has(item.delta.seq)) continue;
|
|
823
|
+
const baseOid = baseOf(item);
|
|
824
|
+
const base = baseOid === void 0 ? void 0 : fetchedBases.get(baseOid) ?? (yield* readOwnObject(baseOid));
|
|
825
|
+
if (base !== void 0) yield* runItem(item, base);
|
|
826
|
+
}
|
|
827
|
+
shrinkMem(pageHeld);
|
|
164
828
|
}
|
|
165
829
|
}
|
|
166
830
|
});
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
for (const object of objects.values()) {
|
|
185
|
-
const fault = fsckObject(object, checked);
|
|
186
|
-
if (fault !== void 0) return yield* Effect.fail(fsckRefusal(object.oid, fault));
|
|
187
|
-
const overflow = checkedOverflow(checked);
|
|
188
|
-
if (overflow !== void 0) return yield* Effect.fail(overflow);
|
|
831
|
+
for (const offset of waitingByOffset.keys()) if (offsetToOid.has(offset)) readyOffsetsForSpilled.add(offset);
|
|
832
|
+
for (const oid of waitingByOid.keys()) if (headers.has(oid)) readyForSpilled.add(oid);
|
|
833
|
+
yield* drainSpilledRounds();
|
|
834
|
+
const outsideOids = [...waitingByOid.keys()].filter((oid) => !headers.has(oid));
|
|
835
|
+
if (outsideOids.length > 0) {
|
|
836
|
+
yield* eachExternal(outsideOids, (base) => Effect.flatMap(chargeInflated(base.bytes.byteLength), () => {
|
|
837
|
+
externalBases.set(base.oid, base.bytes.byteLength);
|
|
838
|
+
lru.set(base.oid, base);
|
|
839
|
+
return Effect.map(resolveInMemoryTree({
|
|
840
|
+
oid: base.oid,
|
|
841
|
+
offset: void 0,
|
|
842
|
+
object: base
|
|
843
|
+
}), () => {
|
|
844
|
+
if (waitingByOid.has(base.oid)) readyForSpilled.add(base.oid);
|
|
845
|
+
});
|
|
846
|
+
}));
|
|
847
|
+
yield* drainSpilledRounds();
|
|
189
848
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
* partial pack may leave out both, but for its tags' objects, which Git's server sends with them
|
|
196
|
-
* through any depth or filter: a missing one is `tagTargetMissing`, as the stored receive says. An
|
|
197
|
-
* import segment's boundary is its own commits, and their parents it leaves out are never asked of
|
|
198
|
-
* the repo; those it holds are checked as any link is.
|
|
199
|
-
*/
|
|
200
|
-
const connected = /* @__PURE__ */ Effect.fnUntraced(function* (input, objects) {
|
|
201
|
-
const partial = input.receive.partial === true;
|
|
202
|
-
const shallow = new Set(input.receive.shallow);
|
|
203
|
-
const boundary = new Set(input.receive.boundary);
|
|
204
|
-
const links = [];
|
|
849
|
+
if (unresolved > 0) return yield* Effect.fail(gitError("INVALID_ARGUMENT", `pack has ${unresolved} unresolved deltas`, { hint: "Push again, with every object the pack needs" }));
|
|
850
|
+
yield* checkedFilesRefused(checked, readOwnObject, input.held);
|
|
851
|
+
const partial = receive.partial === true;
|
|
852
|
+
const shallow = new Set(receive.shallow);
|
|
853
|
+
const boundary = new Set(receive.boundary);
|
|
205
854
|
const parents = [];
|
|
206
855
|
const tagged = /* @__PURE__ */ new Map();
|
|
207
|
-
for (const oid of boundary) if (
|
|
208
|
-
const segment = segmentCut(
|
|
209
|
-
|
|
856
|
+
for (const oid of boundary) if (headers.get(oid)?.type !== "commit") return yield* Effect.fail(boundaryNotInPack(oid));
|
|
857
|
+
const segment = segmentCut(receive.cutMost);
|
|
858
|
+
const inPack = (oid) => headers.has(oid);
|
|
859
|
+
let wrong;
|
|
860
|
+
let linkCount = 0;
|
|
861
|
+
let waitingLinks = [];
|
|
862
|
+
const asked = /* @__PURE__ */ new Map();
|
|
863
|
+
const typed = (at, link, type) => {
|
|
864
|
+
if (type !== link.type && (wrong === void 0 || at < wrong.at)) wrong = {
|
|
865
|
+
at,
|
|
866
|
+
error: wrongType(link, type)
|
|
867
|
+
};
|
|
868
|
+
};
|
|
869
|
+
const checkLinks = Effect.fnUntraced(function* (missing) {
|
|
870
|
+
if (waitingLinks.length === 0) return;
|
|
871
|
+
const batch = waitingLinks;
|
|
872
|
+
waitingLinks = [];
|
|
873
|
+
const repoHeaders = yield* input.headers([...new Set(batch.map(({ link }) => link.oid))]);
|
|
874
|
+
for (const { at, link } of batch) {
|
|
875
|
+
const type = repoHeaders.get(link.oid)?.type;
|
|
876
|
+
if (type === void 0) return yield* Effect.fail(missing(link));
|
|
877
|
+
typed(at, link, type);
|
|
878
|
+
}
|
|
879
|
+
for (const [oid, { type }] of repoHeaders) if (asked.size < 1e5) asked.set(oid, type);
|
|
880
|
+
});
|
|
881
|
+
const missingLink = (link) => partial ? tagTargetMissing(link.oid, tagged.get(link.oid)) : objectMissing(link.oid);
|
|
882
|
+
const queueLink = (link, missing = missingLink) => {
|
|
883
|
+
const at = linkCount++;
|
|
884
|
+
const type = link.oid === "4b825dc642cb6eb9a060e54bf8d69288fbee4904" ? "tree" : headers.get(link.oid)?.type ?? asked.get(link.oid);
|
|
885
|
+
if (type !== void 0) typed(at, link, type);
|
|
886
|
+
else waitingLinks.push({
|
|
887
|
+
at,
|
|
888
|
+
link
|
|
889
|
+
});
|
|
890
|
+
return waitingLinks.length >= 1e3 ? checkLinks(missing) : Effect.void;
|
|
891
|
+
};
|
|
892
|
+
const trackRoots = !partial && receive.boundary === void 0;
|
|
893
|
+
const namedInPack = /* @__PURE__ */ new Set();
|
|
894
|
+
let outside = trackRoots ? /* @__PURE__ */ new Set() : void 0;
|
|
895
|
+
const trackLink = (oid) => {
|
|
896
|
+
if (headers.has(oid)) namedInPack.add(oid);
|
|
897
|
+
else if (oid !== "4b825dc642cb6eb9a060e54bf8d69288fbee4904" && outside !== void 0) {
|
|
898
|
+
if (outside.size >= 1e5) outside = void 0;
|
|
899
|
+
else outside.add(oid);
|
|
900
|
+
}
|
|
901
|
+
};
|
|
902
|
+
for (const oid of receive.needs ?? []) yield* queueLink({
|
|
210
903
|
oid,
|
|
211
904
|
type: "commit"
|
|
212
905
|
});
|
|
213
|
-
for (const
|
|
214
|
-
if (partial &&
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
906
|
+
for (const entry of headEntries) {
|
|
907
|
+
if (partial && entry.type !== "tag") continue;
|
|
908
|
+
if (trackRoots) for (const link of entry.links) trackLink(link.oid);
|
|
909
|
+
const split = shallowLinks(entry, entry.links, shallow);
|
|
910
|
+
if (partial) for (const link of split.needed) tagged.set(link.oid, entry.oid);
|
|
911
|
+
const cut = shallowLinks(entry, split.needed, boundary);
|
|
912
|
+
for (const link of cut.needed) yield* queueLink(link);
|
|
219
913
|
for (const parent of cut.parents) {
|
|
220
|
-
const
|
|
221
|
-
if (
|
|
222
|
-
if (
|
|
914
|
+
const pastCut = segment.add(entry.oid, parent.oid);
|
|
915
|
+
if (pastCut !== void 0) return yield* Effect.fail(pastCut);
|
|
916
|
+
if (inPack(parent.oid)) yield* queueLink(parent);
|
|
223
917
|
}
|
|
224
918
|
for (const parent of split.parents) parents.push(parent);
|
|
225
919
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
*
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
920
|
+
if (!partial && packTrees.length > 0) {
|
|
921
|
+
const checkTreeObject = Effect.fnUntraced(function* (tree) {
|
|
922
|
+
const next = linkReader(tree);
|
|
923
|
+
for (let read = next();; read = next()) {
|
|
924
|
+
if (Result.isFailure(read)) return yield* Effect.fail(read.failure);
|
|
925
|
+
if (read.success === void 0) break;
|
|
926
|
+
if (trackRoots) trackLink(read.success.oid);
|
|
927
|
+
yield* queueLink(read.success);
|
|
928
|
+
}
|
|
929
|
+
});
|
|
930
|
+
const evictedTrees = [];
|
|
931
|
+
for (const oid of packTrees) {
|
|
932
|
+
const largeTree = chunked.get(oid);
|
|
933
|
+
const tree = (yield* readInMemory(oid)) ?? (largeTree !== void 0 && large !== void 0 ? {
|
|
934
|
+
oid,
|
|
935
|
+
type: "tree",
|
|
936
|
+
bytes: yield* large.staged(largeTree)
|
|
937
|
+
} : void 0);
|
|
938
|
+
if (tree !== void 0) yield* checkTreeObject(tree);
|
|
939
|
+
else evictedTrees.push(oid);
|
|
940
|
+
}
|
|
941
|
+
if (evictedTrees.length > 0 && activeStager !== void 0 && staging !== void 0) for (let at = 0; at < evictedTrees.length;) {
|
|
942
|
+
const page = [];
|
|
943
|
+
let pageBytes = 0;
|
|
944
|
+
while (at < evictedTrees.length) {
|
|
945
|
+
const oid = evictedTrees[at];
|
|
946
|
+
const est = encodedBytes(headers.get(oid)?.size ?? 0);
|
|
947
|
+
if (page.length > 0 && pageBytes + est > pageCap()) break;
|
|
948
|
+
page.push(oid);
|
|
949
|
+
pageBytes += est;
|
|
950
|
+
at += 1;
|
|
951
|
+
}
|
|
952
|
+
yield* growMem(pageBytes);
|
|
953
|
+
const rows = yield* staging.readStaged(page.map(stagedRowKey));
|
|
954
|
+
for (const [i, oid] of page.entries()) {
|
|
955
|
+
const row = rows[i];
|
|
956
|
+
if (row === void 0) return yield* stagedLoss(oid);
|
|
957
|
+
yield* checkTreeObject(yield* objectOfRow(row));
|
|
958
|
+
}
|
|
959
|
+
shrinkMem(pageBytes);
|
|
960
|
+
}
|
|
259
961
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
962
|
+
yield* checkLinks(missingLink);
|
|
963
|
+
for (const parent of parents) yield* queueLink(parent, shallowRoot);
|
|
964
|
+
yield* checkLinks(shallowRoot);
|
|
965
|
+
if (wrong !== void 0) return yield* Effect.fail(wrong.error);
|
|
966
|
+
if (activeStager !== void 0) yield* activeStager.flush();
|
|
967
|
+
const readRows = (oids) => activeStager === void 0 || staging === void 0 || oids.length === 0 ? Effect.succeed(oids.map(() => void 0)) : staging.readStaged(oids.map(stagedRowKey));
|
|
968
|
+
const own = {
|
|
969
|
+
headers,
|
|
970
|
+
commits,
|
|
971
|
+
readRow: (oid) => headers.has(oid) ? Effect.map(readRows([oid]), ([row]) => row) : Effect.succeed(void 0),
|
|
972
|
+
readRows
|
|
265
973
|
};
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
974
|
+
const roots = trackRoots ? rootsOf(headers.keys(), (oid) => namedInPack.has(oid)) : void 0;
|
|
975
|
+
const unpacked = {
|
|
976
|
+
inlineObjects: [...inlineByOid.values()],
|
|
977
|
+
inlineRows,
|
|
978
|
+
staged: activeStager !== void 0,
|
|
979
|
+
own,
|
|
980
|
+
chunked: [...chunked.values()],
|
|
981
|
+
count: headers.size,
|
|
269
982
|
moved,
|
|
270
|
-
bytes,
|
|
271
|
-
cut
|
|
983
|
+
bytes: packRead.bytes,
|
|
984
|
+
cut: segment.leftOut(inPack),
|
|
985
|
+
lfsPointers: pointers.finish(),
|
|
986
|
+
largest: largest.finish()
|
|
272
987
|
};
|
|
988
|
+
if (roots !== void 0) {
|
|
989
|
+
unpacked.roots = roots;
|
|
990
|
+
if (outside !== void 0) unpacked.outside = [...outside];
|
|
991
|
+
}
|
|
992
|
+
return unpacked;
|
|
273
993
|
});
|
|
274
|
-
export {
|
|
994
|
+
export { baseLruBytes, deltaChainTooDeep, deltaRoundsMost, malformedPack, maxInflatedBytes, ofsRefused, pastDeclared, pendingHeldMost, readFailure, roundReadBytes, rowTooLarge, unpackObjects };
|