@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
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { fail } from "../../contracts/result.mjs";
|
|
1
|
+
import { fail, gitError, pastRoots } from "../../contracts/result.mjs";
|
|
2
2
|
import { isOid } from "../../protocol/bytes/text.mjs";
|
|
3
|
-
import { badCursor, deadlineOf, inputDigest, readThrough } from "../../engine/reads.mjs";
|
|
3
|
+
import { badCursor, deadlineOf, inputDigest, readThrough, readsThrough } from "../../engine/reads.mjs";
|
|
4
4
|
import { DiffReader, ReadTally } from "../../protocol/diff/read.mjs";
|
|
5
|
+
import { noRepoRoots } from "../../protocol/objects/commit.mjs";
|
|
5
6
|
import { decodePacks } from "../../store/git-store.mjs";
|
|
6
7
|
import { readRecord, rootsOf } from "../../store/repo-record.mjs";
|
|
7
8
|
import { WholeRepo } from "../../store/ref-rows.mjs";
|
|
@@ -9,20 +10,18 @@ import { collections, repoRootsKey } from "../../store/scopes.mjs";
|
|
|
9
10
|
import { indexRowKey } from "../../storage/layout.mjs";
|
|
10
11
|
import { isVisibleTooLong } from "../../storage/visible.mjs";
|
|
11
12
|
import { heldOf as heldOf$1 } from "../../storage/wants.mjs";
|
|
12
|
-
import {
|
|
13
|
-
import { callScope } from "../../store/call-count.mjs";
|
|
14
|
-
import { resultIn } from "../../store/crossing.mjs";
|
|
13
|
+
import { objectsOnce, readOnce, scopedReader, sizesOnce, startingOnce } from "../../storage/calls.mjs";
|
|
14
|
+
import { callScope, inCallScope } from "../../store/call-count.mjs";
|
|
15
15
|
import { allotmentWithin } from "../../contracts/object-values.mjs";
|
|
16
16
|
import { confirmed, openKeyed, openRepo } from "../access.mjs";
|
|
17
17
|
import { asAsked } from "../asked.mjs";
|
|
18
18
|
import { isRefName } from "../names.mjs";
|
|
19
19
|
import { SealedObjects, viewOf } from "../view.mjs";
|
|
20
|
-
import { answerFailed } from "../../contracts/calls-spent.mjs";
|
|
21
20
|
import { CoreParts, ObjectsParts } from "../parts.mjs";
|
|
22
21
|
import { read } from "./objects.mjs";
|
|
22
|
+
import * as Schema from "effect/Schema";
|
|
23
23
|
import * as Effect from "effect/Effect";
|
|
24
24
|
import * as Option from "effect/Option";
|
|
25
|
-
import * as Schema from "effect/Schema";
|
|
26
25
|
import * as SchemaTransformation from "effect/SchemaTransformation";
|
|
27
26
|
import * as Scope from "effect/Scope";
|
|
28
27
|
// src/core/objects/reading.ts
|
|
@@ -99,13 +98,18 @@ const readsOf = (revisions) => Effect.map(askedOf(revisions), (asked) => ({
|
|
|
99
98
|
}));
|
|
100
99
|
/** `listed`'s objects a batch at a time, with no walk: each batch `objectsOnce`, in `scope`. */
|
|
101
100
|
const oneShotObjects = (seen, listed, scope) => {
|
|
102
|
-
const objects =
|
|
103
|
-
return (input) =>
|
|
101
|
+
const objects = seen;
|
|
102
|
+
return (input) => inCallScope(objectsOnce(objects, listed, input), scope);
|
|
104
103
|
};
|
|
105
104
|
/** `listed`'s objects as the engine's `ReadObject`, with no walk: each read `readOnce`, in `scope`. */
|
|
106
105
|
const oneShotRead = (seen, listed, scope) => {
|
|
107
|
-
const objects =
|
|
108
|
-
return (input) =>
|
|
106
|
+
const objects = seen;
|
|
107
|
+
return (input) => inCallScope(readOnce(objects, listed, input), scope);
|
|
108
|
+
};
|
|
109
|
+
/** `listed`'s object sizes, with no walk: each call `sizesOnce`, in `scope`. */
|
|
110
|
+
const oneShotSizes = (seen, listed, scope) => {
|
|
111
|
+
const objects = seen;
|
|
112
|
+
return (input) => inCallScope(sizesOnce(objects, listed, input), scope);
|
|
109
113
|
};
|
|
110
114
|
/**
|
|
111
115
|
* A repo resolved with `reads`, its revisions resolved too, as `openRead` says. With `first-read`,
|
|
@@ -160,7 +164,7 @@ const readOpened = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo, re
|
|
|
160
164
|
roots
|
|
161
165
|
}
|
|
162
166
|
});
|
|
163
|
-
const starting = (prefix) => startingOnce(
|
|
167
|
+
const starting = (prefix) => startingOnce(objects, listed, {
|
|
164
168
|
prefix,
|
|
165
169
|
most: shortIdMost
|
|
166
170
|
});
|
|
@@ -177,16 +181,20 @@ const readOpened = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo, re
|
|
|
177
181
|
}
|
|
178
182
|
});
|
|
179
183
|
const once = /* @__PURE__ */ new Map();
|
|
180
|
-
for (const [revision, at] of distinct) once.set(revision, yield* resolved(revision, asked[at] ?? [], held, defaultBranch,
|
|
184
|
+
for (const [revision, at] of distinct) once.set(revision, yield* resolved(revision, asked[at] ?? [], held, defaultBranch, {
|
|
185
|
+
name: repo,
|
|
186
|
+
roots
|
|
187
|
+
}, starting));
|
|
181
188
|
const oids = revisions.flatMap((revision) => {
|
|
182
189
|
const oid = once.get(revision);
|
|
183
190
|
return oid === void 0 ? [] : [oid];
|
|
184
191
|
});
|
|
185
192
|
const scope = yield* Effect.serviceOption(Scope.Scope);
|
|
186
|
-
const reader = Option.isSome(scope) ? yield* Effect.provideService(scopedReader(
|
|
193
|
+
const reader = Option.isSome(scope) ? yield* Effect.provideService(scopedReader(objects, listed), Scope.Scope, scope.value) : void 0;
|
|
187
194
|
const scoped = yield* callScope;
|
|
188
195
|
const read$1 = reader === void 0 ? oneShotRead(objects, listed, scoped) : (input) => reader.read(input);
|
|
189
196
|
const batch = reader === void 0 ? oneShotObjects(objects, listed, scoped) : (input) => reader.objects(input);
|
|
197
|
+
const sizes = reader === void 0 ? oneShotSizes(objects, listed, scoped) : (input) => reader.sizes(input);
|
|
190
198
|
const allotment = reader === void 0 ? allotmentWithin : (most, refusal) => reader.allotment(most, refusal);
|
|
191
199
|
return {
|
|
192
200
|
name: repo,
|
|
@@ -195,6 +203,7 @@ const readOpened = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo, re
|
|
|
195
203
|
listed,
|
|
196
204
|
read: read$1,
|
|
197
205
|
batch,
|
|
206
|
+
sizes,
|
|
198
207
|
allotment,
|
|
199
208
|
scoped: reader !== void 0,
|
|
200
209
|
oids,
|
|
@@ -224,7 +233,8 @@ const namedBy = (revision, candidates, held, defaultBranch) => {
|
|
|
224
233
|
* rule (Q861): nothing a request caches, skips or stops on may depend on whether a hidden ID was
|
|
225
234
|
* found, so only reached IDs and tips are remembered, and `hidden-short-ids.fuzz.test.ts` holds it.
|
|
226
235
|
*/
|
|
227
|
-
const resolved = /* @__PURE__ */ Effect.fnUntraced(function* (revision, candidates, held, defaultBranch,
|
|
236
|
+
const resolved = /* @__PURE__ */ Effect.fnUntraced(function* (revision, candidates, held, defaultBranch, opened, starting) {
|
|
237
|
+
const repo = opened.name;
|
|
228
238
|
if (isOid(revision)) return revision;
|
|
229
239
|
const named = namedBy(revision, candidates, held, defaultBranch);
|
|
230
240
|
if (named !== void 0) return named;
|
|
@@ -235,7 +245,7 @@ const resolved = /* @__PURE__ */ Effect.fnUntraced(function* (revision, candidat
|
|
|
235
245
|
}));
|
|
236
246
|
const [only] = found.oids;
|
|
237
247
|
if (only !== void 0 && found.oids.length === 1 && !found.more) return only;
|
|
238
|
-
if (found.oids.length === 0 && !found.more) return yield*
|
|
248
|
+
if (found.oids.length === 0 && !found.more) return yield* missingObject(opened, revision, `No revision '${revision}' in '${repo}'`);
|
|
239
249
|
const many = found.more ? `more than ${shortIdMost}` : `${found.oids.length}`;
|
|
240
250
|
return yield* fail("NOT_FOUND", `Short ID '${revision}' names ${many} objects in '${repo}'`, {
|
|
241
251
|
hint: "Name more of its digits, or its whole ID",
|
|
@@ -287,7 +297,7 @@ const seenIn = /* @__PURE__ */ Effect.fnUntraced(function* (caller, resolved, oi
|
|
|
287
297
|
view,
|
|
288
298
|
at
|
|
289
299
|
});
|
|
290
|
-
return yield* heldOf$1(
|
|
300
|
+
return yield* heldOf$1(objects, listed, [...oids, noObject]);
|
|
291
301
|
});
|
|
292
302
|
/**
|
|
293
303
|
* A write sent again reads back the object it made, which its caller already holds: it reads it
|
|
@@ -311,23 +321,25 @@ const objectIn = /* @__PURE__ */ Effect.fnUntraced(function* (repo, oid) {
|
|
|
311
321
|
const read = oneShotRead(SealedObjects.whole(sealed, madeWhole), listed, yield* callScope);
|
|
312
322
|
return yield* objectAt({
|
|
313
323
|
name: repo.name,
|
|
314
|
-
read
|
|
324
|
+
read,
|
|
325
|
+
roots: noRepoRoots
|
|
315
326
|
}, oid);
|
|
316
327
|
});
|
|
317
328
|
/**
|
|
318
|
-
* An object by its ID, through the repo's reads: `NOT_FOUND` when it holds none. The read
|
|
319
|
-
* the call's
|
|
329
|
+
* An object by its ID, through the repo's reads: `NOT_FOUND` when it holds none. The read runs in
|
|
330
|
+
* the call's fiber, so a call interrupted, or a REST request dropped, stops it.
|
|
320
331
|
*/
|
|
321
332
|
const objectAt = /* @__PURE__ */ Effect.fnUntraced(function* (opened, oid) {
|
|
322
333
|
if (!isOid(oid)) return yield* fail("INVALID_ARGUMENT", `'${oid}' isn't a full object ID`);
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}));
|
|
327
|
-
if (result.kind === "error") return yield* answerFailed(result.error);
|
|
328
|
-
if (result.value === void 0) return yield* fail("NOT_FOUND", `No object ${oid} in '${opened.name}'`);
|
|
329
|
-
return result.value;
|
|
334
|
+
const object = yield* opened.read({ oid });
|
|
335
|
+
if (object === void 0) return yield* missingObject(opened, oid);
|
|
336
|
+
return object;
|
|
330
337
|
});
|
|
338
|
+
/**
|
|
339
|
+
* The repo holds no `oid`: `NOT_FOUND`, and `past-roots` when the repo holds roots, since the
|
|
340
|
+
* object may be history past them. A whole repo answers a plain `NOT_FOUND`, as it always has.
|
|
341
|
+
*/
|
|
342
|
+
const missingObject = (opened, oid, message = `No object ${oid} in '${opened.name}'`) => Effect.fail(opened.roots.size === 0 ? gitError("NOT_FOUND", message) : pastRoots(message, oid));
|
|
331
343
|
/** Cancels an object's stream, left unread. */
|
|
332
344
|
const dropped = (object) => {
|
|
333
345
|
object.bytes.cancel().catch(() => void 0);
|
|
@@ -439,9 +451,9 @@ const readerOf = (opened, limits, reason) => Effect.map(deadlineOf(limits.millis
|
|
|
439
451
|
deadline
|
|
440
452
|
};
|
|
441
453
|
return {
|
|
442
|
-
reader: new DiffReader(readThrough(opened.read, deadline), limits.reads, call.tally,
|
|
454
|
+
reader: new DiffReader(readThrough(opened.read, deadline), limits.reads, call.tally, readsThrough(opened.batch, deadline), opened.roots),
|
|
443
455
|
deadline,
|
|
444
456
|
call
|
|
445
457
|
};
|
|
446
458
|
});
|
|
447
|
-
export { base64Size, dropped, fitting, heldCursor, heldDigest, heldIndex, heldListing, heldOf, innerPage, jsonSize, objectAt, objectIn, openKeyedRead, openRead, readerOf, responseBytes, responseTooLarge, seenIn, withinResponse };
|
|
459
|
+
export { base64Size, dropped, fitting, heldCursor, heldDigest, heldIndex, heldListing, heldOf, innerPage, jsonSize, missingObject, objectAt, objectIn, openKeyedRead, openRead, readerOf, responseBytes, responseTooLarge, seenIn, withinResponse };
|
|
@@ -16,7 +16,7 @@ import * as Effect from "effect/Effect";
|
|
|
16
16
|
/**
|
|
17
17
|
* `tags.get`: an annotated tag, decoded, within the call's limits and its time; a lightweight tag
|
|
18
18
|
* is a ref, which `refs.get` reads. `tags.create`: an annotated tag of an object the repo holds,
|
|
19
|
-
* its type read from it, written as its own commit. It moves no ref: `refs.update` points
|
|
19
|
+
* its type read from it, and refused where `type` names another, written as its own commit. It moves no ref: `refs.update` points
|
|
20
20
|
* `refs/tags/<tag>` at it. `tags.peel`: each of up to `peelMost` IDs peeled to its commit, in one
|
|
21
21
|
* opened repo, as `peeled` reads them.
|
|
22
22
|
*/
|
|
@@ -59,6 +59,7 @@ const tagCalls = (bound) => {
|
|
|
59
59
|
}, Effect.scoped),
|
|
60
60
|
create: Effect.fnUntraced(function* (repo, input) {
|
|
61
61
|
const { object, tag, tagger, message } = input;
|
|
62
|
+
const expected = input.type;
|
|
62
63
|
return yield* objectWrite({
|
|
63
64
|
call: "tags.create",
|
|
64
65
|
caller: callerOf(input),
|
|
@@ -66,6 +67,7 @@ const tagCalls = (bound) => {
|
|
|
66
67
|
input,
|
|
67
68
|
parts: [
|
|
68
69
|
object,
|
|
70
|
+
expected ?? null,
|
|
69
71
|
tag,
|
|
70
72
|
tagger,
|
|
71
73
|
message
|
|
@@ -73,6 +75,7 @@ const tagCalls = (bound) => {
|
|
|
73
75
|
make: Effect.fnUntraced(function* (opened, made, limits) {
|
|
74
76
|
const { reader } = yield* readerOf(opened, limits, "walk-limit");
|
|
75
77
|
const type = yield* typeOf(reader, object);
|
|
78
|
+
if (expected !== void 0 && type !== expected) return yield* fail("INVALID_ARGUMENT", `Object ${object} is a ${type}, not a ${expected}`);
|
|
76
79
|
const bytes = yield* Effect.mapError(encodeTag({
|
|
77
80
|
object,
|
|
78
81
|
type,
|
|
@@ -9,8 +9,8 @@ import { treeBytes } from "../../protocol/objects/tree.mjs";
|
|
|
9
9
|
import { isOid, utf8 } from "../../protocol/bytes/text.mjs";
|
|
10
10
|
import { dropped } from "./reading.mjs";
|
|
11
11
|
import { writeBytesMost } from "./writing.mjs";
|
|
12
|
-
import * as Effect from "effect/Effect";
|
|
13
12
|
import * as Schema from "effect/Schema";
|
|
13
|
+
import * as Effect from "effect/Effect";
|
|
14
14
|
// src/core/objects/tree-edits.ts
|
|
15
15
|
const asRead = fromDiff("walk-limit");
|
|
16
16
|
/** The most edits one `trees.create` or `commits.create` takes. */
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allotmentWithin, grownBy, objectsReadMost } from "../../contracts/object-values.mjs";
|
|
2
|
+
import { fail, gitError } from "../../contracts/result.mjs";
|
|
2
3
|
import { diffTrees } from "../../engine/diff.mjs";
|
|
3
4
|
import { fromDiff } from "../../engine/failures.mjs";
|
|
4
|
-
import {
|
|
5
|
+
import { badCursor, inputDigest, limitOf, limitsOf, timed, treeCursorDepthMost, treeLimitMost } from "../../engine/reads.mjs";
|
|
5
6
|
import { joinedBytes } from "../../protocol/bytes/joined.mjs";
|
|
6
7
|
import { isFolder } from "../../protocol/diff/paths.mjs";
|
|
8
|
+
import { readAheadBytesMost } from "../../protocol/diff/read.mjs";
|
|
7
9
|
import { pathText } from "../../protocol/diff/tree-diff.mjs";
|
|
8
|
-
import
|
|
10
|
+
import "../../protocol/objects/object.mjs";
|
|
9
11
|
import { isOid } from "../../protocol/bytes/text.mjs";
|
|
10
12
|
import { callerFor } from "../access.mjs";
|
|
11
13
|
import { dropped, fitting, jsonSize, openRead, readerOf, withinResponse } from "./reading.mjs";
|
|
@@ -13,7 +15,6 @@ import { mergePartsOrOff } from "../merge-parts.mjs";
|
|
|
13
15
|
import { callAllot } from "./lines.mjs";
|
|
14
16
|
import { editTree, editsWithin } from "./tree-edits.mjs";
|
|
15
17
|
import { objectWrite, oidAnswer, takeWrites } from "./writing.mjs";
|
|
16
|
-
import { answerFailed } from "../../contracts/calls-spent.mjs";
|
|
17
18
|
import { ObjectsParts } from "../parts.mjs";
|
|
18
19
|
import * as Effect from "effect/Effect";
|
|
19
20
|
// src/core/objects/trees.ts
|
|
@@ -41,69 +42,262 @@ const entryOf = (entry, path) => {
|
|
|
41
42
|
if (!full.exact) listed.pathBytes = path;
|
|
42
43
|
return listed;
|
|
43
44
|
};
|
|
45
|
+
const walkLimit = (message) => gitError("RESOURCE_EXHAUSTED", message, { context: { reason: "walk-limit" } });
|
|
46
|
+
const childPathOf = (base, name) => base === void 0 ? name : joinedBytes([
|
|
47
|
+
base,
|
|
48
|
+
slash,
|
|
49
|
+
name
|
|
50
|
+
]);
|
|
51
|
+
/** Materializes the full root-to-entry index path once, when `pageOf` emits `next`. */
|
|
52
|
+
const treeNodePosition = (node) => {
|
|
53
|
+
const indices = [];
|
|
54
|
+
for (let at = node; at !== void 0; at = at.parent) indices.push(at.index);
|
|
55
|
+
return indices.reverse();
|
|
56
|
+
};
|
|
57
|
+
/** Encodes a tree position as `/`-separated non-negative integers (no `.` or `-`, safe in `HeldCursor`). */
|
|
58
|
+
const treePositionText = (position) => position.join("/");
|
|
59
|
+
/**
|
|
60
|
+
* Decodes a tree position from `text`, refusing anything `treePositionText` couldn't write:
|
|
61
|
+
* empty strings, oversized tokens (checked before splitting), leading/trailing slashes, leading
|
|
62
|
+
* zeros, non-digits, unsafe integers, depth past `treeCursorDepthMost`, or multi-segment paths
|
|
63
|
+
* when `recursive` is false.
|
|
64
|
+
*/
|
|
65
|
+
const treePositionOf = (text, recursive) => {
|
|
66
|
+
if (text === void 0) return Effect.succeed(void 0);
|
|
67
|
+
const maxDepth = recursive ? treeCursorDepthMost : 1;
|
|
68
|
+
if (text.length === 0 || text.length > maxDepth * 17) return badCursor();
|
|
69
|
+
const parts = text.split("/");
|
|
70
|
+
if (parts.length > maxDepth) return badCursor();
|
|
71
|
+
const position = [];
|
|
72
|
+
for (const part of parts) {
|
|
73
|
+
const index = Number(part);
|
|
74
|
+
if (!/^(?:0|[1-9]\d*)$/.test(part) || !Number.isSafeInteger(index)) return badCursor();
|
|
75
|
+
position.push(index);
|
|
76
|
+
}
|
|
77
|
+
return Effect.succeed(position);
|
|
78
|
+
};
|
|
79
|
+
/** A `trees.get` cursor: `<digest>.<i0>/<i1>/...`, bound to the content-addressed root OID and mode. */
|
|
80
|
+
const treeCursor = (digest, position) => `${digest}.${treePositionText(position)}`;
|
|
81
|
+
/** Decodes a `trees.get` cursor bound to `digest` and `recursive`, or fails `badCursor()`. */
|
|
82
|
+
const treeAfterOf = (after, digest, recursive) => {
|
|
83
|
+
if (after === void 0) return Effect.succeed(void 0);
|
|
84
|
+
return after.startsWith(`${digest}.`) ? treePositionOf(after.slice(digest.length + 1), recursive) : badCursor();
|
|
85
|
+
};
|
|
86
|
+
/** Opens a scoped allotment for a tree listing's retained stack frames and path bytes. */
|
|
87
|
+
const walkAllotment = (opened, most) => Effect.acquireRelease(Effect.sync(() => opened.allotment(most, walkLimit(`The walk holds past ${most} bytes`))), (allotment) => Effect.sync(() => allotment.release()));
|
|
88
|
+
/** Sentinel refusal for speculative tree read-ahead: stops reading ahead without failing the walk. */
|
|
89
|
+
const readAheadRefused = /* @__PURE__ */ gitError("RESOURCE_EXHAUSTED", `The tree read-ahead holds past ${readAheadBytesMost} bytes`, { context: { reason: "walk-limit" } });
|
|
44
90
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
|
|
91
|
+
* Opens a scoped allotment out of the request's memory budget (`opened.allotment`) for speculative
|
|
92
|
+
* tree read-ahead, capped at `min(readAheadBytesMost, most)`.
|
|
93
|
+
*/
|
|
94
|
+
const readAheadAllotment = (opened, most = readAheadBytesMost) => Effect.acquireRelease(Effect.sync(() => opened.allotment(Math.min(readAheadBytesMost, most), readAheadRefused)), (allotment) => Effect.sync(() => allotment.release()));
|
|
95
|
+
const tooDeep = () => Effect.fail(walkLimit(`The tree nests past ${treeCursorDepthMost} levels`));
|
|
96
|
+
/** How many more object reads `reader` and its call tally allow before hitting `objects`. */
|
|
97
|
+
const objectsLeft = (reader) => Math.min(reader.limits.objects - reader.objects, reader.tally === void 0 ? Infinity : reader.tally.limits.objects - reader.tally.objects);
|
|
98
|
+
/**
|
|
99
|
+
* A tree's entries, after `after` (from the start when `undefined`), at most `most`: in the tree's
|
|
100
|
+
* order, and with `recursive` each folder before what it holds, as `ls-tree -r -t` lists them, a
|
|
101
|
+
* submodule not entered. Paths start with `prefix`. Seeking through `after` reads only the
|
|
102
|
+
* ancestor trees along that path, never earlier siblings (#2960). When `reader` supports batch
|
|
103
|
+
* reads, recursive walks probe one subtree at each depth to estimate entries per folder, then
|
|
104
|
+
* prefetch upcoming folders at that depth (across already-prefetched sibling parents) strictly
|
|
105
|
+
* from object allowance above what the rest of the page could still need without prefetch (#2974).
|
|
106
|
+
* Refuses to descend past `treeCursorDepthMost` with `walk-limit`, so every emitted `next`
|
|
107
|
+
* decodes. Frames keep one parent link (`TreeNode`), charged per level through both `reader` and
|
|
108
|
+
* `allotment`, and `pageOf` materializes the cut entry's full position once when a page ends.
|
|
48
109
|
*/
|
|
49
110
|
const listTree = /* @__PURE__ */ Effect.fnUntraced(function* (reader, tree, options) {
|
|
111
|
+
const { allotment, recursive } = options;
|
|
112
|
+
const readAhead = options.readAhead ?? allotmentWithin(Math.min(524288, reader.limits.bytes), readAheadRefused);
|
|
50
113
|
const entries = [];
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const child
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
114
|
+
const nodes = [];
|
|
115
|
+
const enter = (child) => recursive && isFolder(child) && child.oid !== "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
|
|
116
|
+
const prefetched = /* @__PURE__ */ new Set();
|
|
117
|
+
const depthStats = /* @__PURE__ */ new Map();
|
|
118
|
+
let readAheadStopped = false;
|
|
119
|
+
const recordDepth = (depth, children) => {
|
|
120
|
+
let cost = 1 + children.length;
|
|
121
|
+
for (const child of children) if (enter(child)) cost += 1;
|
|
122
|
+
const stat = depthStats.get(depth);
|
|
123
|
+
if (stat === void 0) depthStats.set(depth, {
|
|
124
|
+
trees: 1,
|
|
125
|
+
entries: cost
|
|
126
|
+
});
|
|
127
|
+
else {
|
|
128
|
+
stat.trees += 1;
|
|
129
|
+
stat.entries += cost;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
const readSubtree = Effect.fnUntraced(function* (oid, depth) {
|
|
133
|
+
const children = yield* reader.treeOf(oid);
|
|
134
|
+
prefetched.add(oid);
|
|
135
|
+
recordDepth(depth, children);
|
|
136
|
+
return children;
|
|
137
|
+
});
|
|
138
|
+
const charge = (bytes) => allotment === void 0 ? reader.charge(bytes) : Effect.flatMap(reader.charge(bytes), () => Effect.flatMap(grownBy(allotment, bytes), (refused) => refused === void 0 ? Effect.void : Effect.fail(refused)));
|
|
139
|
+
const stack = [];
|
|
140
|
+
/**
|
|
141
|
+
* Batches upcoming unprefetched folder trees at `targetDepth` in DFS order, starting with
|
|
142
|
+
* `firstOid`. Waits for one probed subtree at `targetDepth` so fat-directory pages never
|
|
143
|
+
* over-read past `options.most`, inspects prefetched parent folders without charging `bytes`,
|
|
144
|
+
* and holds read-ahead trees under `readAhead` so bytes are charged only when the walk takes
|
|
145
|
+
* each tree. A read-ahead refusal drops the batch and stops reading ahead for the rest of the
|
|
146
|
+
* page without failing the walk.
|
|
147
|
+
*/
|
|
148
|
+
const prefetchLevel = Effect.fnUntraced(function* (targetDepth, firstOid, remaining) {
|
|
149
|
+
if (readAheadStopped || reader.batch === void 0 || prefetched.has(firstOid) || remaining < 2) return;
|
|
150
|
+
const stat = depthStats.get(targetDepth);
|
|
151
|
+
if (stat === void 0) return;
|
|
152
|
+
const left = objectsLeft(reader);
|
|
153
|
+
const allowed = left - Math.min(left, remaining);
|
|
154
|
+
const estimated = Math.max(1, Math.ceil((remaining + 1) / (stat.entries / stat.trees)));
|
|
155
|
+
const want = Math.min(estimated, objectsReadMost, allowed);
|
|
156
|
+
if (want <= 1) return;
|
|
157
|
+
const batch = [firstOid];
|
|
158
|
+
const seen = /* @__PURE__ */ new Set([firstOid]);
|
|
159
|
+
let budgetEntries = remaining - 1;
|
|
160
|
+
const collect = Effect.fnUntraced(function* (list, from, childDepth) {
|
|
161
|
+
for (let at = from; at < list.length && batch.length < want && budgetEntries > 0; at += 1) {
|
|
162
|
+
const entry = list[at];
|
|
163
|
+
if (entry === void 0) continue;
|
|
164
|
+
if (!enter(entry)) {
|
|
165
|
+
budgetEntries -= 1;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (childDepth === targetDepth) {
|
|
169
|
+
if (!prefetched.has(entry.oid) && !seen.has(entry.oid)) {
|
|
170
|
+
seen.add(entry.oid);
|
|
171
|
+
batch.push(entry.oid);
|
|
172
|
+
}
|
|
173
|
+
budgetEntries -= 2;
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
budgetEntries -= 1;
|
|
177
|
+
if (budgetEntries <= 0 || !prefetched.has(entry.oid)) return false;
|
|
178
|
+
const sub = yield* reader.peekTree(entry.oid);
|
|
179
|
+
if (sub === void 0) return false;
|
|
180
|
+
if (!(yield* collect(sub, 0, childDepth + 1))) return false;
|
|
181
|
+
}
|
|
182
|
+
return batch.length < want && budgetEntries > 0;
|
|
183
|
+
});
|
|
184
|
+
for (let level = targetDepth - 1; level >= 0; level -= 1) {
|
|
185
|
+
const ancestor = stack[level];
|
|
186
|
+
if (ancestor === void 0) break;
|
|
187
|
+
if (!(yield* collect(ancestor.c, ancestor.at, level + 1))) break;
|
|
188
|
+
}
|
|
189
|
+
if (batch.length <= 1) return;
|
|
190
|
+
if (!(yield* reader.prefetchAhead(batch, readAhead, readAheadRefused))) {
|
|
191
|
+
readAheadStopped = true;
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
for (const oid of batch) prefetched.add(oid);
|
|
195
|
+
});
|
|
196
|
+
return yield* Effect.gen(function* () {
|
|
197
|
+
const rootHeld = 64 + (options.prefix?.length ?? 0);
|
|
198
|
+
yield* charge(rootHeld);
|
|
199
|
+
if (options.after === void 0) stack.push({
|
|
200
|
+
c: yield* reader.treeOf(tree),
|
|
201
|
+
at: 0,
|
|
202
|
+
p: options.prefix,
|
|
203
|
+
n: void 0,
|
|
204
|
+
h: rootHeld
|
|
205
|
+
});
|
|
206
|
+
else {
|
|
207
|
+
if (options.after.length === 0 || options.after.length > (recursive ? 4096 : 1)) return yield* badCursor();
|
|
208
|
+
let children = yield* reader.treeOf(tree);
|
|
209
|
+
let path = options.prefix;
|
|
210
|
+
let node;
|
|
211
|
+
let held = rootHeld;
|
|
212
|
+
for (let depth = 0; depth < options.after.length; depth += 1) {
|
|
213
|
+
const index = options.after[depth] ?? -1;
|
|
214
|
+
const child = Number.isSafeInteger(index) && index >= 0 ? children[index] : void 0;
|
|
215
|
+
const last = depth === options.after.length - 1;
|
|
216
|
+
if (child === void 0 || !last && !isFolder(child)) return yield* badCursor();
|
|
217
|
+
stack.push({
|
|
218
|
+
c: children,
|
|
219
|
+
at: index + 1,
|
|
220
|
+
p: path,
|
|
221
|
+
n: node,
|
|
222
|
+
h: held
|
|
223
|
+
});
|
|
224
|
+
node = {
|
|
225
|
+
index,
|
|
226
|
+
parent: node
|
|
227
|
+
};
|
|
228
|
+
if (!last || enter(child)) {
|
|
229
|
+
if (stack.length >= 4096) return yield* tooDeep();
|
|
230
|
+
path = childPathOf(path, child.name);
|
|
231
|
+
held = 64 + path.length;
|
|
232
|
+
yield* charge(held);
|
|
233
|
+
children = yield* readSubtree(child.oid, stack.length);
|
|
234
|
+
if (last) stack.push({
|
|
235
|
+
c: children,
|
|
236
|
+
at: 0,
|
|
237
|
+
p: path,
|
|
238
|
+
n: node,
|
|
239
|
+
h: held
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
}
|
|
62
243
|
}
|
|
63
|
-
frame.at
|
|
64
|
-
|
|
65
|
-
frame.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
244
|
+
for (let frame = stack.at(-1); frame !== void 0; frame = stack.at(-1)) {
|
|
245
|
+
const childIndex = frame.at;
|
|
246
|
+
const child = frame.c[childIndex];
|
|
247
|
+
if (child === void 0) {
|
|
248
|
+
stack.pop();
|
|
249
|
+
allotment?.shrink(frame.h);
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
71
252
|
if (entries.length === options.most) return {
|
|
72
253
|
entries,
|
|
254
|
+
nodes,
|
|
73
255
|
more: true
|
|
74
256
|
};
|
|
257
|
+
frame.at += 1;
|
|
258
|
+
const path = childPathOf(frame.p, child.name);
|
|
259
|
+
yield* charge(64 + path.length);
|
|
260
|
+
const node = {
|
|
261
|
+
index: childIndex,
|
|
262
|
+
parent: frame.n
|
|
263
|
+
};
|
|
75
264
|
entries.push(entryOf(child, path));
|
|
265
|
+
nodes.push(node);
|
|
266
|
+
if (enter(child)) {
|
|
267
|
+
if (stack.length >= 4096) return yield* tooDeep();
|
|
268
|
+
yield* charge(64);
|
|
269
|
+
const targetDepth = stack.length;
|
|
270
|
+
yield* prefetchLevel(targetDepth, child.oid, options.most - entries.length);
|
|
271
|
+
stack.push({
|
|
272
|
+
c: yield* readSubtree(child.oid, targetDepth),
|
|
273
|
+
at: 0,
|
|
274
|
+
p: path,
|
|
275
|
+
n: node,
|
|
276
|
+
h: 64
|
|
277
|
+
});
|
|
278
|
+
}
|
|
76
279
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
entries,
|
|
86
|
-
more: false
|
|
87
|
-
};
|
|
280
|
+
return {
|
|
281
|
+
entries,
|
|
282
|
+
nodes,
|
|
283
|
+
more: false
|
|
284
|
+
};
|
|
285
|
+
}).pipe(Effect.ensuring(Effect.sync(() => reader.releaseReadAhead())));
|
|
88
286
|
});
|
|
89
287
|
/**
|
|
90
288
|
* `listed`'s entries, each blob with its size, as `ls-tree -l` gives it: read from the object's
|
|
91
|
-
* header, through `
|
|
92
|
-
* `NOT_FOUND`, as reading it would be, unless the core is `partial`: then it has
|
|
93
|
-
* the client fetches no blob to size it.
|
|
289
|
+
* header, through `opened.sizes` on the call's scoped reader, the blob's bytes never read. A blob
|
|
290
|
+
* the repo lacks is `NOT_FOUND`, as reading it would be, unless the core is `partial`: then it has
|
|
291
|
+
* no `size`, since the client fetches no blob to size it.
|
|
94
292
|
*/
|
|
95
293
|
const sized = /* @__PURE__ */ Effect.fnUntraced(function* (opened, listed) {
|
|
96
294
|
const { partial } = yield* ObjectsParts;
|
|
97
295
|
const blobs = [...new Set(listed.entries.filter((entry) => entry.type === "blob").map((entry) => entry.oid))];
|
|
98
296
|
if (blobs.length === 0) return listed;
|
|
99
|
-
const
|
|
100
|
-
oids: blobs,
|
|
101
|
-
signal
|
|
102
|
-
}))));
|
|
103
|
-
if (answer.kind === "error") return yield* answerFailed(answer.error);
|
|
297
|
+
const sizes = yield* opened.sizes({ oids: blobs });
|
|
104
298
|
const entries = yield* Effect.forEach(listed.entries, (entry) => {
|
|
105
299
|
if (entry.type !== "blob") return Effect.succeed(entry);
|
|
106
|
-
const size =
|
|
300
|
+
const size = sizes.get(entry.oid);
|
|
107
301
|
if (size === void 0 && partial === true) return Effect.succeed(entry);
|
|
108
302
|
if (size === void 0) return fail("NOT_FOUND", `object ${entry.oid} is missing`);
|
|
109
303
|
return Effect.succeed({
|
|
@@ -121,7 +315,7 @@ const treeCalls = (bound) => {
|
|
|
121
315
|
return {
|
|
122
316
|
get: Effect.fnUntraced(function* (repo, input) {
|
|
123
317
|
const limits = yield* limitsOf(input.limits);
|
|
124
|
-
const limit = yield* limitOf(input.page);
|
|
318
|
+
const limit = yield* limitOf(input.page, treeLimitMost);
|
|
125
319
|
const recursive = input.recursive === true;
|
|
126
320
|
if (!isOid(input.oid)) return yield* notAnOid(input.oid);
|
|
127
321
|
const digest = yield* inputDigest([
|
|
@@ -129,15 +323,18 @@ const treeCalls = (bound) => {
|
|
|
129
323
|
input.oid,
|
|
130
324
|
String(recursive)
|
|
131
325
|
]);
|
|
132
|
-
const
|
|
326
|
+
const after = yield* treeAfterOf(input.page?.after, digest, recursive);
|
|
133
327
|
const opened = yield* openRead(callerOf(input), repo, [], input.internalId);
|
|
134
328
|
const { reader, deadline } = yield* readerOf(opened, limits, "walk-limit");
|
|
329
|
+
const allotment = yield* walkAllotment(opened, limits.reads.bytes);
|
|
330
|
+
const readAhead = yield* readAheadAllotment(opened, limits.reads.bytes);
|
|
135
331
|
const listing = treeish(reader, input.oid).pipe(Effect.andThen(listTree(reader, input.oid, {
|
|
136
|
-
prefix: void 0,
|
|
137
332
|
recursive,
|
|
138
|
-
|
|
139
|
-
most: limit
|
|
140
|
-
|
|
333
|
+
after,
|
|
334
|
+
most: limit,
|
|
335
|
+
allotment,
|
|
336
|
+
readAhead
|
|
337
|
+
})), Effect.mapError(fromDiff("walk-limit")), Effect.flatMap((listed) => sized(opened, listed)), Effect.flatMap((listed) => pageOf(listed, "The tree page", (position) => treeCursor(digest, position))));
|
|
141
338
|
return yield* timed(listing, deadline);
|
|
142
339
|
}, Effect.scoped),
|
|
143
340
|
diff: Effect.fnUntraced(function* (repo, input) {
|
|
@@ -221,14 +418,16 @@ const treeish = (reader, oid) => Effect.flatMap(reader.object(oid), (object) =>
|
|
|
221
418
|
return fail("INVALID_ARGUMENT", `${oid} names a blob, not a tree`);
|
|
222
419
|
});
|
|
223
420
|
/**
|
|
224
|
-
* A listing of entries
|
|
225
|
-
*
|
|
421
|
+
* A listing of entries cut to the response bound: `next` the cursor of the last entry kept, when
|
|
422
|
+
* more follow it.
|
|
226
423
|
*/
|
|
227
|
-
const pageOf = (listed,
|
|
424
|
+
const pageOf = (listed, what, cursorOf) => Effect.map(fitting(listed.entries.map(jsonSize), what), (kept) => {
|
|
228
425
|
const items = listed.entries.slice(0, kept);
|
|
229
|
-
|
|
426
|
+
const more = listed.more || kept < listed.entries.length;
|
|
427
|
+
const last = listed.nodes[kept - 1];
|
|
428
|
+
return more && last !== void 0 ? {
|
|
230
429
|
items,
|
|
231
|
-
next: cursorOf(
|
|
430
|
+
next: cursorOf(treeNodePosition(last))
|
|
232
431
|
} : { items };
|
|
233
432
|
});
|
|
234
|
-
export { listTree, notAnOid, pageOf, sized, treeCalls, treeish };
|
|
433
|
+
export { listTree, notAnOid, pageOf, readAheadAllotment, readAheadRefused, sized, treeCalls, treeNodePosition, treePositionOf, treePositionText, treeish, walkAllotment };
|
|
@@ -13,13 +13,12 @@ import { keyedPushWith, pushWith } from "../push.mjs";
|
|
|
13
13
|
import { ownWriter, ownWrites } from "../own-writes.mjs";
|
|
14
14
|
import { objectAnswer } from "../receipts.mjs";
|
|
15
15
|
import { objectIn, openKeyedRead } from "./reading.mjs";
|
|
16
|
-
import { tryUnlessSpent } from "../../contracts/calls-spent.mjs";
|
|
17
16
|
import { CoreParts } from "../parts.mjs";
|
|
18
17
|
import { check } from "../../contracts/authorize.mjs";
|
|
19
|
-
import * as Clock$1 from "effect/Clock";
|
|
20
|
-
import * as Effect from "effect/Effect";
|
|
21
18
|
import { limits } from "@ref0/infra";
|
|
19
|
+
import * as Effect from "effect/Effect";
|
|
22
20
|
import * as Predicate from "effect/Predicate";
|
|
21
|
+
import * as Clock from "effect/Clock";
|
|
23
22
|
import * as Hex from "effect/encoding/Hex";
|
|
24
23
|
/** The most the objects one write makes hold together. */
|
|
25
24
|
const writeBytesMost = 67108864;
|
|
@@ -112,12 +111,7 @@ const writeDigest = (call, parts) => Effect.promise(async () => {
|
|
|
112
111
|
});
|
|
113
112
|
/** The objects a merge made, read whole into `made`. */
|
|
114
113
|
const takeWrites = /* @__PURE__ */ Effect.fnUntraced(function* (made, writes) {
|
|
115
|
-
const
|
|
116
|
-
const all = [];
|
|
117
|
-
for await (const write of writes) all.push(write);
|
|
118
|
-
return all;
|
|
119
|
-
}, (cause) => gitError("INTERNAL", `The merge's objects failed mid-read: ${String(cause)}`));
|
|
120
|
-
for (const write of held) {
|
|
114
|
+
for (const write of writes) {
|
|
121
115
|
const bytes = yield* Effect.mapError(drained(write, objectBytesMost, { copy: true }), fromDiff("diff-limit"));
|
|
122
116
|
yield* made.add(write.type, new Uint8Array(bytes));
|
|
123
117
|
}
|
|
@@ -183,7 +177,7 @@ const objectWrite = (write) => Effect.scoped(Effect.gen(function* () {
|
|
|
183
177
|
const digest = input.key === void 0 ? "" : yield* writeDigest(write.call, write.parts);
|
|
184
178
|
const writer = core.access === void 0 ? void 0 : yield* ownWriter(caller);
|
|
185
179
|
for (let attempt = 0; attempt < 5; attempt += 1) {
|
|
186
|
-
const at = yield* Clock
|
|
180
|
+
const at = yield* Clock.currentTimeMillis;
|
|
187
181
|
const kept = yield* keptKey(caller, input.key, [write.call, digest], at);
|
|
188
182
|
const keyed = yield* keyedRecord(core.store, repo, kept, (access) => Effect.andThen(check({
|
|
189
183
|
caller,
|
package/dist/core/own-writes.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { decodeRow, storeCall } from "../store/errors.mjs";
|
|
2
2
|
import { collections, repoScope } from "../store/scopes.mjs";
|
|
3
3
|
import { dayMs, dayOf, sweepDue, sweepOf } from "./receipts.mjs";
|
|
4
|
-
import * as Effect from "effect/Effect";
|
|
5
4
|
import * as Schema from "effect/Schema";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
6
|
import * as Hex from "effect/encoding/Hex";
|
|
7
7
|
// src/core/own-writes.ts
|
|
8
8
|
/**
|
|
@@ -63,7 +63,7 @@ const ownWritesOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, internal
|
|
|
63
63
|
collection: collections.ownWrites,
|
|
64
64
|
id: ownWriteId(day, writer, oid)
|
|
65
65
|
})));
|
|
66
|
-
const snapshot = yield* storeCall(
|
|
66
|
+
const snapshot = yield* storeCall(store.read(repoScope(internalId), reads));
|
|
67
67
|
const own = /* @__PURE__ */ new Set();
|
|
68
68
|
for (const [index, rows] of snapshot.results.entries()) {
|
|
69
69
|
const oid = oids[Math.floor(index / days.length)];
|