@ref0/git 0.3.0 → 0.4.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/_virtual/_rolldown/runtime.mjs +12 -0
- package/dist/access/private-refs.d.mts +12 -9
- package/dist/access/private-refs.mjs +69 -46
- package/dist/auth/access-jwt.mjs +7 -7
- package/dist/auth/auth.d.mts +41 -0
- package/dist/auth/auth.mjs +39 -0
- package/dist/auth/authorize.mjs +57 -80
- package/dist/auth/bridge.mjs +30 -0
- package/dist/auth/fences.d.mts +22 -2
- package/dist/auth/fences.mjs +3 -3
- package/dist/auth/grants.d.mts +25 -0
- package/dist/auth/grants.mjs +29 -34
- package/dist/auth/helpers.mjs +4 -4
- package/dist/auth/host-function.d.mts +9 -2
- package/dist/auth/host-function.mjs +35 -8
- package/dist/auth/identify.d.mts +3 -0
- package/dist/auth/identify.mjs +9 -11
- package/dist/auth/namespaces.d.mts +3 -0
- package/dist/auth/policy.d.mts +57 -0
- package/dist/auth/policy.mjs +56 -0
- package/dist/auth/token-rows.mjs +6 -6
- package/dist/auth/token-text.mjs +16 -4
- package/dist/auth/tokens.d.mts +3 -0
- package/dist/auth/tokens.mjs +51 -13
- package/dist/auth.d.mts +2 -1
- package/dist/auth.mjs +2 -1
- package/dist/client/answer.mjs +49 -11
- package/dist/client/client.d.mts +2 -2
- package/dist/client/client.mjs +3 -3
- package/dist/client/git-http.d.mts +6 -0
- package/dist/client/git-http.mjs +23 -36
- package/dist/client/helper-node.d.mts +12 -0
- package/dist/client/helper-node.mjs +108 -5
- package/dist/client/local.mjs +94 -99
- package/dist/client/negotiate.mjs +10 -8
- package/dist/client/push-upload.d.mts +14 -0
- package/dist/client/push-upload.mjs +12 -12
- package/dist/client/remote-helper.mjs +22 -20
- package/dist/client/remote.mjs +28 -22
- package/dist/client/run-remote-helper.d.mts +40 -16
- package/dist/client/run-remote-helper.mjs +147 -154
- package/dist/client/scrub.d.mts +8 -2
- package/dist/client/scrub.mjs +76 -4
- package/dist/client/slice-push.d.mts +77 -0
- package/dist/client/slice-push.mjs +169 -0
- package/dist/client/slice-report.mjs +188 -0
- package/dist/client/slices.d.mts +44 -0
- package/dist/client/slices.mjs +131 -0
- package/dist/client/transport.d.mts +1 -0
- package/dist/client/transport.mjs +30 -26
- package/dist/contracts/access.d.mts +36 -9
- package/dist/contracts/actors.d.mts +28 -10
- package/dist/contracts/actors.mjs +17 -0
- package/dist/contracts/authorize.d.mts +77 -0
- package/dist/contracts/authorize.mjs +25 -0
- package/dist/contracts/blobs.d.mts +48 -15
- package/dist/contracts/blobs.mjs +30 -0
- package/dist/contracts/calls-spent.d.mts +1 -0
- package/dist/contracts/calls-spent.mjs +58 -18
- package/dist/contracts/client.d.mts +14 -16
- package/dist/contracts/commits.d.mts +558 -76
- package/dist/contracts/commits.mjs +147 -0
- package/dist/contracts/engine.d.mts +91 -55
- package/dist/contracts/engine.mjs +103 -0
- package/dist/contracts/events.d.mts +1382 -205
- package/dist/contracts/events.mjs +485 -0
- package/dist/contracts/files.d.mts +295 -50
- package/dist/contracts/files.mjs +100 -0
- package/dist/contracts/forks.d.mts +306 -25
- package/dist/contracts/forks.mjs +39 -0
- package/dist/contracts/git.d.mts +107 -0
- package/dist/contracts/git.mjs +23 -0
- package/dist/contracts/grants.d.mts +2 -2
- package/dist/contracts/ids.d.mts +23 -8
- package/dist/contracts/ids.mjs +40 -5
- package/dist/contracts/lfs.d.mts +9 -4
- package/dist/contracts/merges.d.mts +68 -16
- package/dist/contracts/merges.mjs +27 -0
- package/dist/contracts/namespaces.d.mts +14 -0
- package/dist/contracts/object-values.d.mts +96 -0
- package/dist/contracts/object-values.mjs +104 -0
- package/dist/contracts/objects.d.mts +323 -87
- package/dist/contracts/operations.d.mts +24 -16
- package/dist/contracts/promises.d.mts +13 -2
- package/dist/contracts/push-uploads.d.mts +39 -24
- package/dist/contracts/push-uploads.mjs +54 -0
- package/dist/contracts/queue.d.mts +444 -139
- package/dist/contracts/queue.mjs +197 -0
- package/dist/contracts/refs.d.mts +248 -45
- package/dist/contracts/refs.mjs +117 -0
- package/dist/contracts/repo-records.d.mts +34 -0
- package/dist/contracts/repo-records.mjs +18 -0
- package/dist/contracts/repos.d.mts +411 -58
- package/dist/contracts/repos.mjs +136 -0
- package/dist/contracts/result.d.mts +335 -69
- package/dist/contracts/result.mjs +350 -5
- package/dist/contracts/rules.d.mts +60 -48
- package/dist/contracts/rules.mjs +9 -0
- package/dist/contracts/server.d.mts +113 -47
- package/dist/contracts/services.d.mts +15 -24
- package/dist/contracts/services.mjs +5 -9
- package/dist/contracts/signin.d.mts +64 -31
- package/dist/contracts/signin.mjs +18 -0
- package/dist/contracts/store.d.mts +45 -5
- package/dist/contracts/store.mjs +31 -0
- package/dist/contracts/sync.d.mts +81 -46
- package/dist/contracts/sync.mjs +41 -2
- package/dist/contracts/tags.d.mts +204 -22
- package/dist/contracts/tags.mjs +51 -1
- package/dist/contracts/tokens.d.mts +32 -7
- package/dist/contracts/tokens.mjs +31 -1
- package/dist/contracts/topics.d.mts +123 -67
- package/dist/contracts/topics.mjs +109 -0
- package/dist/contracts/trees.d.mts +132 -52
- package/dist/contracts/trees.mjs +105 -0
- package/dist/contracts/work.d.mts +127 -20
- package/dist/contracts/work.mjs +69 -0
- package/dist/core/access.d.mts +25 -14
- package/dist/core/access.mjs +77 -108
- package/dist/core/ancestry.mjs +86 -18
- package/dist/core/call-names.mjs +1 -0
- package/dist/core/call-services.mjs +73 -0
- package/dist/core/changes.d.mts +31 -0
- package/dist/core/changes.mjs +5 -0
- package/dist/core/clock.mjs +3 -3
- package/dist/core/events/deliver.mjs +119 -33
- package/dist/core/events/seen.mjs +124 -0
- package/dist/core/forks.mjs +371 -159
- package/dist/core/hooks/order.d.mts +9 -0
- package/dist/core/hooks/order.mjs +25 -0
- package/dist/core/hooks/post-receive.mjs +13 -12
- package/dist/core/hooks/pre-receive.d.mts +8 -1
- package/dist/core/hooks/pre-receive.mjs +8 -6
- package/dist/core/imports.mjs +212 -0
- package/dist/core/index-job.mjs +131 -38
- package/dist/core/merge-parts.d.mts +30 -0
- package/dist/core/merge-parts.mjs +31 -0
- package/dist/core/names.mjs +4 -16
- package/dist/core/namespaces.d.mts +2 -0
- package/dist/core/objects/blobs.mjs +4 -4
- package/dist/core/objects/commit-writes.mjs +19 -17
- package/dist/core/objects/commits.mjs +12 -12
- package/dist/core/objects/files.mjs +10 -11
- package/dist/core/objects/lines.mjs +15 -32
- package/dist/core/objects/merges.mjs +4 -4
- package/dist/core/objects/objects-layer.d.mts +21 -0
- package/dist/core/objects/objects-layer.mjs +47 -0
- package/dist/core/objects/objects-namespace.d.mts +6 -0
- package/dist/core/objects/objects-namespace.mjs +13 -0
- package/dist/core/objects/objects.d.mts +49 -0
- package/dist/core/objects/objects.mjs +18 -0
- package/dist/core/objects/peel.mjs +3 -3
- package/dist/core/objects/reading.mjs +135 -40
- package/dist/core/objects/tags.mjs +7 -7
- package/dist/core/objects/tree-edits.mjs +40 -27
- package/dist/core/objects/trees.mjs +23 -18
- package/dist/core/objects/writing.mjs +43 -44
- package/dist/core/own-writes.mjs +3 -3
- package/dist/core/parts.d.mts +125 -0
- package/dist/core/parts.mjs +59 -0
- package/dist/core/promise.mjs +13 -9
- package/dist/core/publish.mjs +27 -17
- package/dist/core/purge.mjs +242 -0
- package/dist/core/push-decide.mjs +93 -28
- package/dist/core/push.mjs +300 -156
- package/dist/core/receipts.d.mts +4 -3
- package/dist/core/receipts.mjs +20 -12
- package/dist/core/ref-conflicts.mjs +70 -4
- package/dist/core/ref-index-job.mjs +181 -0
- package/dist/core/ref-index.d.mts +25 -0
- package/dist/core/ref-index.mjs +136 -0
- package/dist/core/ref-view.mjs +166 -0
- package/dist/core/refs.mjs +313 -95
- package/dist/core/repack.d.mts +10 -0
- package/dist/core/repack.mjs +261 -81
- package/dist/core/repo-info.mjs +99 -0
- package/dist/core/repos.mjs +114 -80
- package/dist/core/rules/changes.mjs +48 -20
- package/dist/core/rules/check.mjs +29 -22
- package/dist/core/rules/commit-changes.d.mts +13 -0
- package/dist/core/rules/commit-changes.mjs +100 -91
- package/dist/core/rules/context.d.mts +67 -8
- package/dist/core/rules/context.mjs +88 -51
- package/dist/core/rules/facts.mjs +1 -1
- package/dist/core/rules/fetch.mjs +24 -26
- package/dist/core/rules/files.d.mts +13 -0
- package/dist/core/rules/files.mjs +27 -28
- package/dist/core/rules/namespace.d.mts +2 -0
- package/dist/core/rules/patterns.mjs +29 -5
- package/dist/core/rules/protect.d.mts +12 -6
- package/dist/core/rules/protect.mjs +22 -20
- package/dist/core/rules/rules-layer.d.mts +17 -0
- package/dist/core/rules/rules-layer.mjs +26 -0
- package/dist/core/rules/rules.d.mts +8 -0
- package/dist/core/rules/rules.mjs +16 -0
- package/dist/core/rules/service.mjs +18 -0
- package/dist/core/seam.d.mts +8 -5
- package/dist/core/seam.mjs +19 -15
- package/dist/core/tokens.mjs +29 -23
- package/dist/core/view.d.mts +105 -6
- package/dist/core/view.mjs +211 -109
- package/dist/core/work.mjs +40 -14
- package/dist/effect.d.mts +3 -4
- package/dist/effect.mjs +2 -3
- package/dist/engine/allotted-xdiff.d.mts +1 -0
- package/dist/engine/allotted-xdiff.mjs +1 -1
- package/dist/engine/attributes.mjs +1 -1
- package/dist/engine/combined.d.mts +18 -0
- package/dist/engine/combined.mjs +39 -44
- package/dist/engine/commits.mjs +5 -4
- package/dist/engine/content.d.mts +3 -2
- package/dist/engine/content.mjs +2 -2
- package/dist/engine/failures.d.mts +2 -2
- package/dist/engine/failures.mjs +2 -9
- package/dist/engine/merge-base-walk.d.mts +3 -2
- package/dist/engine/merge-base-walk.mjs +1 -1
- package/dist/engine/merge-bases.mjs +3 -2
- package/dist/engine/merge.mjs +568 -566
- package/dist/engine/parts.d.mts +3 -2
- package/dist/engine/parts.mjs +40 -7
- package/dist/engine/reads.d.mts +1 -0
- package/dist/engine/reads.mjs +5 -5
- package/dist/engine/walk.mjs +23 -24
- package/dist/engine/xdiff.d.mts +2 -33
- package/dist/engine/xdiff.mjs +6 -3
- package/dist/event-streams/event-streams.d.mts +25 -0
- package/dist/event-streams/event-streams.mjs +22 -0
- package/dist/event-streams/namespace.d.mts +2 -0
- package/dist/event-streams/stream.d.mts +42 -0
- package/dist/{core/events → event-streams}/stream.mjs +106 -49
- package/dist/extend.d.mts +4 -2
- package/dist/http/answers.mjs +8 -4
- package/dist/http/bodies.mjs +84 -56
- package/dist/http/core-parts.mjs +206 -60
- package/dist/http/handler.d.mts +2 -0
- package/dist/http/handler.mjs +17 -11
- package/dist/http/node.mjs +10 -6
- package/dist/http/parts.d.mts +12 -0
- package/dist/http/push-uploads.d.mts +9 -0
- package/dist/http/push-uploads.mjs +76 -66
- package/dist/http/receive-pack.mjs +162 -28
- package/dist/http/upload-pack.mjs +106 -81
- package/dist/index.d.mts +48 -28
- package/dist/index.mjs +29 -7
- package/dist/lfs/calls.mjs +2 -2
- package/dist/lfs/locks.mjs +24 -20
- package/dist/lfs/objects.d.mts +7 -0
- package/dist/lfs/objects.mjs +31 -26
- package/dist/lfs/pointers.mjs +7 -7
- package/dist/lfs/purge.mjs +50 -0
- package/dist/lfs/repo.mjs +5 -5
- package/dist/lfs/rows.mjs +8 -8
- package/dist/lfs/service.d.mts +9 -0
- package/dist/lfs/service.mjs +32 -25
- package/dist/lfs/upkeep.mjs +5 -5
- package/dist/lfs/wire.mjs +80 -38
- package/dist/merges/merges.d.mts +20 -0
- package/dist/merges/merges.mjs +32 -0
- package/dist/merges/namespace.d.mts +2 -0
- package/dist/merges/public.d.mts +6 -0
- package/dist/merges/public.mjs +10 -0
- package/dist/node.d.mts +1 -2
- package/dist/node.mjs +1 -3
- package/dist/protocol/bytes/buffers.d.mts +9 -3
- package/dist/protocol/bytes/buffers.mjs +11 -5
- package/dist/protocol/bytes/deflate.d.mts +7 -5
- package/dist/protocol/bytes/deflate.mjs +59 -23
- package/dist/protocol/bytes/inflate.d.mts +4 -3
- package/dist/protocol/bytes/inflate.mjs +61 -26
- package/dist/protocol/bytes/reader.mjs +61 -0
- package/dist/protocol/bytes/sha1-hasher.d.mts +3 -1
- package/dist/protocol/bytes/sha1-hasher.mjs +13 -3
- package/dist/protocol/bytes/sha1.d.mts +1 -1
- package/dist/protocol/bytes/sha1.mjs +5 -5
- package/dist/protocol/bytes/streams.mjs +16 -6
- package/dist/protocol/diff/patch.d.mts +4 -0
- package/dist/protocol/diff/patch.mjs +1 -1
- package/dist/protocol/diff/paths.mjs +1 -1
- package/dist/protocol/diff/read.d.mts +1 -1
- package/dist/protocol/diff/read.mjs +102 -90
- package/dist/protocol/framing/pkt-line.d.mts +1 -0
- package/dist/protocol/framing/pkt-line.mjs +40 -6
- package/dist/protocol/objects/checked-blobs.d.mts +1 -0
- package/dist/protocol/objects/fsck.mjs +7 -1
- package/dist/protocol/objects/held.mjs +5 -11
- package/dist/protocol/objects/ident.mjs +1 -1
- package/dist/protocol/objects/object-rules.mjs +15 -7
- package/dist/protocol/objects/object.d.mts +6 -2
- package/dist/protocol/objects/object.mjs +5 -2
- package/dist/protocol/objects/tag.d.mts +3 -1
- package/dist/protocol/objects/tag.mjs +27 -1
- package/dist/protocol/objects/tree.mjs +1 -1
- package/dist/protocol/packs/delta.d.mts +1 -1
- package/dist/protocol/packs/delta.mjs +2 -2
- package/dist/protocol/packs/graph.mjs +55 -56
- package/dist/protocol/packs/idx.d.mts +4 -2
- package/dist/protocol/packs/idx.mjs +156 -63
- package/dist/protocol/packs/indexer.d.mts +22 -4
- package/dist/protocol/packs/indexer.mjs +14 -35
- package/dist/protocol/packs/parts.mjs +5 -5
- package/dist/protocol/packs/pos.mjs +12 -5
- package/dist/protocol/packs/reader.d.mts +19 -12
- package/dist/protocol/packs/reader.mjs +252 -25
- package/dist/protocol/packs/rev.d.mts +1 -1
- package/dist/protocol/packs/rev.mjs +42 -24
- package/dist/protocol/packs/types-file.mjs +85 -0
- package/dist/protocol/packs/write-error.d.mts +1 -1
- package/dist/protocol/packs/write-error.mjs +2 -2
- package/dist/protocol/packs/writer.d.mts +40 -15
- package/dist/protocol/packs/writer.mjs +142 -49
- package/dist/protocol/wire/advertisement.d.mts +39 -14
- package/dist/protocol/wire/advertisement.mjs +127 -31
- package/dist/protocol/wire/fetch.d.mts +57 -19
- package/dist/protocol/wire/fetch.mjs +57 -26
- package/dist/protocol/wire/json.mjs +25 -0
- package/dist/protocol/wire/lines.d.mts +10 -0
- package/dist/protocol/wire/lines.mjs +20 -6
- package/dist/protocol/wire/push-limits.d.mts +6 -0
- package/dist/protocol/wire/push-limits.mjs +88 -0
- package/dist/protocol/wire/push-uploads.mjs +3 -28
- package/dist/protocol/wire/receive-pack.d.mts +30 -14
- package/dist/protocol/wire/receive-pack.mjs +29 -2
- package/dist/protocol/wire/report-status.d.mts +30 -11
- package/dist/protocol/wire/report-status.mjs +21 -2
- package/dist/protocol/wire/v2.d.mts +56 -29
- package/dist/protocol/wire/v2.mjs +91 -16
- package/dist/protocol.d.mts +4 -3
- package/dist/protocol.mjs +7 -6
- package/dist/queue/advance.mjs +189 -120
- package/dist/queue/callers.mjs +12 -9
- package/dist/queue/calls.mjs +311 -155
- package/dist/queue/commit.mjs +70 -26
- package/dist/queue/host.d.mts +39 -12
- package/dist/queue/host.mjs +36 -38
- package/dist/queue/lanes.mjs +1 -1
- package/dist/queue/layer.d.mts +14 -0
- package/dist/queue/layer.mjs +55 -0
- package/dist/queue/limits.mjs +13 -2
- package/dist/queue/namespace.d.mts +2 -0
- package/dist/queue/pages.mjs +1 -1
- package/dist/queue/public.d.mts +6 -0
- package/dist/queue/public.mjs +21 -0
- package/dist/queue/push-option.mjs +49 -30
- package/dist/queue/rows.mjs +24 -16
- package/dist/queue/schedule.mjs +22 -22
- package/dist/queue/search.mjs +8 -7
- package/dist/queue/state.mjs +49 -13
- package/dist/queue/steps.mjs +6 -3
- package/dist/remote-helper.d.mts +5 -2
- package/dist/remote-helper.mjs +5 -2
- package/dist/rest/api.d.mts +1 -1
- package/dist/rest/blobs.d.mts +790 -23
- package/dist/rest/blobs.mjs +4 -4
- package/dist/rest/caller.d.mts +4163 -36
- package/dist/rest/caller.mjs +2 -2
- package/dist/rest/client.mjs +80 -70
- package/dist/rest/commits.d.mts +3315 -244
- package/dist/rest/commits.mjs +18 -64
- package/dist/rest/errors.d.mts +2082 -22
- package/dist/rest/errors.mjs +46 -89
- package/dist/rest/events.d.mts +394 -11
- package/dist/rest/events.mjs +13 -9
- package/dist/rest/files.d.mts +1265 -114
- package/dist/rest/files.mjs +11 -42
- package/dist/rest/forks.d.mts +2005 -62
- package/dist/rest/forks.mjs +10 -13
- package/dist/rest/handler.d.mts +3 -0
- package/dist/rest/handler.mjs +22 -14
- package/dist/rest/handlers.mjs +53 -60
- package/dist/rest/listen.d.mts +5 -8
- package/dist/rest/listen.mjs +23 -29
- package/dist/rest/me.d.mts +393 -10
- package/dist/rest/me.mjs +2 -2
- package/dist/rest/merges.d.mts +399 -16
- package/dist/rest/merges.mjs +3 -17
- package/dist/rest/paths.mjs +1 -0
- package/dist/rest/queue.d.mts +5615 -240
- package/dist/rest/queue.mjs +15 -130
- package/dist/rest/refs.d.mts +2859 -132
- package/dist/rest/refs.mjs +19 -39
- package/dist/rest/repos.d.mts +2421 -93
- package/dist/rest/repos.mjs +10 -33
- package/dist/rest/tags.d.mts +1205 -54
- package/dist/rest/tags.mjs +6 -34
- package/dist/rest/tokens.d.mts +2369 -66
- package/dist/rest/tokens.mjs +7 -4
- package/dist/rest/topics.d.mts +2060 -113
- package/dist/rest/topics.mjs +23 -71
- package/dist/rest/trees.d.mts +1610 -75
- package/dist/rest/trees.mjs +16 -57
- package/dist/rest/wire.d.mts +402 -0
- package/dist/rest/wire.mjs +32 -46
- package/dist/rest/work.d.mts +1204 -63
- package/dist/rest/work.mjs +7 -51
- package/dist/rest.d.mts +3 -3
- package/dist/server/extension.d.mts +6 -2
- package/dist/server/extension.mjs +54 -30
- package/dist/server/git-layer.d.mts +23 -0
- package/dist/server/git-layer.mjs +107 -0
- package/dist/server/git-namespace.d.mts +6 -0
- package/dist/server/git-namespace.mjs +15 -0
- package/dist/server/lifecycle.d.mts +1 -2
- package/dist/server/lifecycle.mjs +8 -15
- package/dist/server/namespaces.d.mts +2 -0
- package/dist/server/registry.d.mts +9 -0
- package/dist/server/registry.mjs +167 -0
- package/dist/server/route-match.mjs +88 -0
- package/dist/server/routes.d.mts +12 -8
- package/dist/server/routes.mjs +27 -18
- package/dist/server/server.d.mts +19 -0
- package/dist/server/server.mjs +281 -198
- package/dist/signin/codes.mjs +9 -6
- package/dist/signin/context.d.mts +1 -0
- package/dist/signin/context.mjs +4 -4
- package/dist/signin/device.mjs +8 -8
- package/dist/signin/forms.mjs +11 -29
- package/dist/signin/grants.d.mts +4 -2
- package/dist/signin/grants.mjs +20 -19
- package/dist/signin/route.mjs +2 -2
- package/dist/signin/web.mjs +7 -7
- package/dist/signin/wire.mjs +6 -6
- package/dist/storage/budget.mjs +51 -18
- package/dist/storage/calls.d.mts +22 -4
- package/dist/storage/calls.mjs +347 -110
- package/dist/storage/clean-up.mjs +80 -35
- package/dist/storage/counted-bucket.mjs +115 -0
- package/dist/storage/fetch.d.mts +2 -0
- package/dist/storage/fetch.mjs +243 -100
- package/dist/storage/fsck.mjs +56 -7
- package/dist/storage/held-types.d.mts +7 -0
- package/dist/storage/held-types.mjs +263 -0
- package/dist/storage/host-bucket.mjs +28 -0
- package/dist/storage/id-mix.d.mts +1 -0
- package/dist/storage/id-mix.mjs +55 -0
- package/dist/storage/index-bitmaps.d.mts +2 -1
- package/dist/storage/index-bitmaps.mjs +233 -101
- package/dist/storage/index-build.d.mts +7 -3
- package/dist/storage/index-build.mjs +650 -164
- package/dist/storage/index-fetch.d.mts +3 -1
- package/dist/storage/index-fetch.mjs +297 -195
- package/dist/storage/index-files.mjs +25 -27
- package/dist/storage/index-graph.d.mts +2 -1
- package/dist/storage/index-graph.mjs +127 -91
- package/dist/storage/index-layers.d.mts +11 -0
- package/dist/storage/index-layers.mjs +258 -78
- package/dist/storage/index-reach.mjs +181 -75
- package/dist/storage/index-remap.mjs +74 -32
- package/dist/storage/index-shallow.mjs +311 -0
- package/dist/storage/index-visible.mjs +168 -0
- package/dist/storage/layout.d.mts +1 -0
- package/dist/storage/layout.mjs +39 -8
- package/dist/storage/lfs-pointers.d.mts +3 -1
- package/dist/storage/lfs-pointers.mjs +25 -9
- package/dist/storage/link-join.d.mts +4 -0
- package/dist/storage/link-join.mjs +50 -12
- package/dist/storage/links.mjs +89 -4
- package/dist/storage/listed-ids.mjs +10 -0
- package/dist/storage/loose.d.mts +11 -4
- package/dist/storage/loose.mjs +102 -69
- package/dist/storage/memory-budget.d.mts +5 -0
- package/dist/storage/memory-budget.mjs +530 -102
- package/dist/storage/merge-choose.mjs +258 -0
- package/dist/storage/merge-cut.mjs +47 -0
- package/dist/storage/merge-fence.mjs +89 -0
- package/dist/storage/merge-index.mjs +347 -0
- package/dist/storage/merge-most.mjs +202 -0
- package/dist/storage/merge-plan.mjs +171 -0
- package/dist/storage/merge-row.mjs +258 -0
- package/dist/storage/merge-stream.mjs +497 -0
- package/dist/storage/merge-walk.mjs +199 -0
- package/dist/storage/merge-write.mjs +129 -0
- package/dist/storage/merge.d.mts +10 -0
- package/dist/storage/merge.mjs +82 -306
- package/dist/storage/object-rows.d.mts +4 -2
- package/dist/storage/object-rows.mjs +101 -17
- package/dist/storage/pack-order.d.mts +1 -1
- package/dist/storage/pack-order.mjs +69 -54
- package/dist/storage/pack-ranges.d.mts +1 -1
- package/dist/storage/pack-ranges.mjs +396 -60
- package/dist/storage/pack-reads.d.mts +6 -2
- package/dist/storage/pack-reads.mjs +598 -126
- package/dist/storage/pack-receive.d.mts +5 -0
- package/dist/storage/pack-receive.mjs +820 -237
- package/dist/storage/packs-memory.d.mts +25 -0
- package/dist/storage/packs-memory.mjs +49 -0
- package/dist/storage/packs.d.mts +7 -5
- package/dist/storage/packs.mjs +554 -213
- package/dist/storage/placed-reads.mjs +205 -0
- package/dist/storage/promise-calls.mjs +29 -0
- package/dist/storage/prune-keep.mjs +164 -0
- package/dist/storage/prune-walk.mjs +578 -0
- package/dist/storage/prune.mjs +739 -332
- package/dist/storage/push-allotment.mjs +3 -3
- package/dist/storage/push-uploads.mjs +22 -13
- package/dist/storage/pushed-commits.mjs +8 -9
- package/dist/storage/quarantine.d.mts +10 -0
- package/dist/storage/quarantine.mjs +28 -25
- package/dist/storage/range-cache.mjs +71 -0
- package/dist/storage/raw-ids.mjs +20 -1
- package/dist/storage/ready.d.mts +4 -2
- package/dist/storage/ready.mjs +109 -48
- package/dist/storage/receive-admission.mjs +67 -0
- package/dist/storage/receive-bounds.d.mts +1 -0
- package/dist/storage/receive-bounds.mjs +202 -0
- package/dist/storage/receive-files.mjs +248 -0
- package/dist/storage/receive-links.mjs +281 -244
- package/dist/storage/receive-state.d.mts +9 -0
- package/dist/storage/receive-state.mjs +150 -0
- package/dist/storage/receive-steps.mjs +344 -0
- package/dist/storage/receive-sweep.mjs +160 -0
- package/dist/storage/receive-table.d.mts +3 -0
- package/dist/storage/receive-table.mjs +197 -0
- package/dist/storage/repack-backlog.mjs +70 -0
- package/dist/storage/repack-contained.mjs +269 -0
- package/dist/storage/repack-job.d.mts +3 -0
- package/dist/storage/repack-job.mjs +24 -7
- package/dist/storage/repack.d.mts +4 -4
- package/dist/storage/repack.mjs +156 -77
- package/dist/storage/roots.mjs +23 -7
- package/dist/storage/rows.d.mts +4 -2
- package/dist/storage/rows.mjs +40 -7
- package/dist/storage/runs.d.mts +8 -0
- package/dist/storage/runs.mjs +731 -0
- package/dist/storage/send-list.d.mts +2 -1
- package/dist/storage/send-list.mjs +261 -76
- package/dist/storage/shallow.d.mts +3 -2
- package/dist/storage/shallow.mjs +7 -7
- package/dist/storage/single-flight.mjs +47 -0
- package/dist/storage/stream-whole.mjs +121 -54
- package/dist/storage/swap-walk.mjs +188 -0
- package/dist/storage/unpack.mjs +52 -23
- package/dist/storage/visible.mjs +58 -39
- package/dist/storage/walk.d.mts +2 -0
- package/dist/storage/walk.mjs +20 -7
- package/dist/storage/wants.mjs +185 -33
- package/dist/storage/written-bases.mjs +172 -0
- package/dist/store/call-count.d.mts +69 -4
- package/dist/store/call-count.mjs +193 -51
- package/dist/store/catalogue.d.mts +17 -3
- package/dist/store/catalogue.mjs +135 -48
- package/dist/store/crossing.mjs +2 -4
- package/dist/store/cursor-seal.d.mts +12 -1
- package/dist/store/cursor-seal.mjs +7 -6
- package/dist/store/errors.d.mts +2 -2
- package/dist/store/errors.mjs +112 -24
- package/dist/store/git-store.mjs +21 -2
- package/dist/store/list-job.mjs +5 -5
- package/dist/store/outbox.d.mts +15 -5
- package/dist/store/outbox.mjs +106 -28
- package/dist/store/promises.d.mts +3 -2
- package/dist/store/promises.mjs +94 -35
- package/dist/store/queue-jobs.mjs +12 -12
- package/dist/store/records.d.mts +64 -1
- package/dist/store/records.mjs +101 -32
- package/dist/store/ref-rows.d.mts +18 -2
- package/dist/store/ref-rows.mjs +62 -5
- package/dist/store/repo-record.mjs +11 -9
- package/dist/store/reservations.mjs +9 -8
- package/dist/store/scopes.mjs +13 -1
- package/dist/store/settle.mjs +1 -1
- package/dist/store/topic-jobs.mjs +4 -4
- package/dist/sync/bound.d.mts +5 -3
- package/dist/sync/bound.mjs +32 -3
- package/dist/sync/github.mjs +7 -7
- package/dist/sync/import.d.mts +2 -0
- package/dist/sync/import.mjs +46 -50
- package/dist/sync/jobs.mjs +15 -23
- package/dist/sync/mirror.d.mts +5 -1
- package/dist/sync/mirror.mjs +121 -44
- package/dist/sync/publish.d.mts +1 -0
- package/dist/sync/publish.mjs +10 -12
- package/dist/sync/step.mjs +439 -71
- package/dist/sync/tries.mjs +50 -32
- package/dist/sync.d.mts +3 -3
- package/dist/sync.mjs +2 -2
- package/dist/topics/advance.mjs +103 -86
- package/dist/topics/calls.mjs +97 -67
- package/dist/topics/directory.mjs +31 -11
- package/dist/topics/host.d.mts +0 -1
- package/dist/topics/host.mjs +2 -12
- package/dist/topics/members.mjs +30 -24
- package/dist/topics/rows.mjs +10 -9
- package/dist/topics/topic.mjs +20 -9
- package/package.json +8 -15
- package/dist/auth/authorize.d.mts +0 -5
- package/dist/contracts/objects.mjs +0 -54
- package/dist/core/events/stream.d.mts +0 -19
- package/dist/core/rules/define.d.mts +0 -5
- package/dist/core/rules/define.mjs +0 -13
- package/dist/core/rules/fetch.d.mts +0 -5
- package/dist/core/sight.mjs +0 -99
- package/dist/engine/engine.d.mts +0 -25
- package/dist/engine/engine.mjs +0 -49
- package/dist/engine/xdiff/NOTICE.md +0 -63
- package/dist/engine/xdiff/compiled.d.mts +0 -7
- package/dist/engine/xdiff/compiled.mjs +0 -9
- package/dist/engine/xdiff/embedded.mjs +0 -4
- package/dist/engine/xdiff/node.d.mts +0 -7
- package/dist/engine/xdiff/node.mjs +0 -10
- package/dist/engine/xdiff/upstream/LGPL-2.1 +0 -511
- package/dist/engine/xdiff/xdiff.wasm +0 -0
- package/dist/engine.d.mts +0 -3
- package/dist/engine.mjs +0 -3
- package/dist/storage/distinct-ids.mjs +0 -39
- package/dist/storage/held-memo.mjs +0 -188
- package/dist/storage/index-remap.d.mts +0 -8
- package/dist/sync/records.mjs +0 -73
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { packIndexerLimits } from "./pack-reads.mjs";
|
|
2
|
+
// src/storage/written-bases.ts
|
|
3
|
+
/**
|
|
4
|
+
* The written-bases table: a merge's record of the entries it wrote most recently into the pack
|
|
5
|
+
* it's writing, each by its ID with its chain's depth and instruction bytes as written there, and
|
|
6
|
+
* its position there, so a delta copied on it names its base's position. A
|
|
7
|
+
* `REF_DELTA` is copied as stored only when its base is in the table, so its base was written
|
|
8
|
+
* earlier in the same pack, and only while its chain stays within `deepestChain` deltas and
|
|
9
|
+
* `deltaBytes` of instructions; otherwise the merge resolves it and writes it whole, and its chain
|
|
10
|
+
* starts again. A miss costs bytes, never order: invariant 3 holds at any size of table.
|
|
11
|
+
*
|
|
12
|
+
* It holds a fixed `writtenBasesMost` entries, letting go of the least recently used, in typed
|
|
13
|
+
* arrays sized once, `writtenBasesHeld` bytes whatever the merge writes.
|
|
14
|
+
*/
|
|
15
|
+
/** The most entries the table holds: on s1m's packs it misses none (M2, 26 Nov). */
|
|
16
|
+
const writtenBasesMost = 65536;
|
|
17
|
+
/** The most deltas one chain of a merged pack holds: a read resolves no deeper. */
|
|
18
|
+
const deepestChain = packIndexerLimits.chainReads - 1;
|
|
19
|
+
/** An object ID's bytes, as the table keeps it. */
|
|
20
|
+
const idBytes = 20;
|
|
21
|
+
/** A chain's depth, below 64, fits the low 6 bits of its packed word; its bytes the rest. */
|
|
22
|
+
const depthBits = 64;
|
|
23
|
+
/** The ID slots for `most` entries: at least twice as many, a power of 2, so a probe stays short. */
|
|
24
|
+
const slotsFor = (most) => 2 ** Math.ceil(Math.log2(most * 2));
|
|
25
|
+
/**
|
|
26
|
+
* The bytes a table of `most` entries holds: each entry's ID, its packed chain, its position and
|
|
27
|
+
* its two neighbours in use order, the slots that find it by ID, and their bits of which are taken.
|
|
28
|
+
*/
|
|
29
|
+
const writtenBasesHeld = (most = writtenBasesMost) => {
|
|
30
|
+
const slots = slotsFor(most);
|
|
31
|
+
return most * 32 + slots * 2 + Math.ceil(slots / 8);
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* A written-bases table of `most` entries, at most 65,536, since each entry's number is 16 bits.
|
|
35
|
+
* `wrote` records each entry as the merge writes it, in the pack's order, and answers whether it
|
|
36
|
+
* goes as stored or whole.
|
|
37
|
+
*/
|
|
38
|
+
const writtenBases = (most = writtenBasesMost) => {
|
|
39
|
+
if (!Number.isInteger(most) || most < 1 || most > 65536) throw new RangeError(`A written-bases table holds 1 to 65,536 entries, not ${most}`);
|
|
40
|
+
const slots = slotsFor(most);
|
|
41
|
+
const mask = slots - 1;
|
|
42
|
+
const ids = new Uint8Array(most * idBytes);
|
|
43
|
+
const chains = new Uint32Array(most);
|
|
44
|
+
const positions = new Uint32Array(most);
|
|
45
|
+
const older = new Uint16Array(most);
|
|
46
|
+
const newer = new Uint16Array(most);
|
|
47
|
+
const slot = new Uint16Array(slots);
|
|
48
|
+
const taken = new Uint8Array(Math.ceil(slots / 8));
|
|
49
|
+
let size = 0;
|
|
50
|
+
let newest = 0;
|
|
51
|
+
const isTaken = (at) => (taken[at >>> 3] & 1 << (at & 7)) !== 0;
|
|
52
|
+
const take = (at) => {
|
|
53
|
+
taken[at >>> 3] |= 1 << (at & 7);
|
|
54
|
+
};
|
|
55
|
+
const free = (at) => {
|
|
56
|
+
taken[at >>> 3] &= ~(1 << (at & 7));
|
|
57
|
+
};
|
|
58
|
+
const home = (id, at) => (id[at] << 24 | id[at + 1] << 16 | id[at + 2] << 8 | id[at + 3]) & mask;
|
|
59
|
+
const sameId = (entry, id, at) => {
|
|
60
|
+
const from = entry * idBytes;
|
|
61
|
+
for (let byte = 0; byte < idBytes; byte += 1) if (ids[from + byte] !== id[at + byte]) return false;
|
|
62
|
+
return true;
|
|
63
|
+
};
|
|
64
|
+
/** The slot holding `id`, or the free slot its probe ends at. */
|
|
65
|
+
const probe = (id, at) => {
|
|
66
|
+
let index = home(id, at);
|
|
67
|
+
while (isTaken(index) && !sameId(slot[index], id, at)) index = index + 1 & mask;
|
|
68
|
+
return index;
|
|
69
|
+
};
|
|
70
|
+
/** Lets go of slot `at`, shifting back each entry after it that probed past it. */
|
|
71
|
+
const vacate = (at) => {
|
|
72
|
+
let hole = at;
|
|
73
|
+
let next = at + 1 & mask;
|
|
74
|
+
while (isTaken(next)) {
|
|
75
|
+
const entry = slot[next];
|
|
76
|
+
const start = home(ids, entry * idBytes);
|
|
77
|
+
if (hole <= next ? start <= hole || start > next : start <= hole && start > next) {
|
|
78
|
+
slot[hole] = entry;
|
|
79
|
+
take(hole);
|
|
80
|
+
hole = next;
|
|
81
|
+
}
|
|
82
|
+
next = next + 1 & mask;
|
|
83
|
+
}
|
|
84
|
+
free(hole);
|
|
85
|
+
};
|
|
86
|
+
const unlink = (entry) => {
|
|
87
|
+
newer[older[entry]] = newer[entry];
|
|
88
|
+
older[newer[entry]] = older[entry];
|
|
89
|
+
};
|
|
90
|
+
const linkNewest = (entry) => {
|
|
91
|
+
if (size === 0) {
|
|
92
|
+
older[entry] = entry;
|
|
93
|
+
newer[entry] = entry;
|
|
94
|
+
} else {
|
|
95
|
+
const oldest = older[newest];
|
|
96
|
+
older[entry] = oldest;
|
|
97
|
+
newer[entry] = newest;
|
|
98
|
+
newer[oldest] = entry;
|
|
99
|
+
older[newest] = entry;
|
|
100
|
+
}
|
|
101
|
+
newest = entry;
|
|
102
|
+
};
|
|
103
|
+
const used = (entry) => {
|
|
104
|
+
if (entry === newest) return;
|
|
105
|
+
unlink(entry);
|
|
106
|
+
size -= 1;
|
|
107
|
+
linkNewest(entry);
|
|
108
|
+
size += 1;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Records `id`'s chain and position as written, as the newest entry, letting go of the oldest
|
|
112
|
+
* when full.
|
|
113
|
+
*/
|
|
114
|
+
const put = (id, at, chain, position) => {
|
|
115
|
+
const found = probe(id, at);
|
|
116
|
+
if (isTaken(found)) {
|
|
117
|
+
const entry = slot[found];
|
|
118
|
+
chains[entry] = chain;
|
|
119
|
+
positions[entry] = position;
|
|
120
|
+
used(entry);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
let entry = size;
|
|
124
|
+
if (size === most) {
|
|
125
|
+
entry = older[newest];
|
|
126
|
+
vacate(probe(ids, entry * idBytes));
|
|
127
|
+
unlink(entry);
|
|
128
|
+
size -= 1;
|
|
129
|
+
}
|
|
130
|
+
ids.set(id.subarray(at, at + idBytes), entry * idBytes);
|
|
131
|
+
chains[entry] = chain;
|
|
132
|
+
positions[entry] = position;
|
|
133
|
+
const open = probe(id, at);
|
|
134
|
+
slot[open] = entry;
|
|
135
|
+
take(open);
|
|
136
|
+
linkNewest(entry);
|
|
137
|
+
size += 1;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* The entry `id`, at `at` in its bytes, written next at `position`: an object whole when `base`
|
|
141
|
+
* is `undefined`, or a `REF_DELTA` on the base at `baseAt` in `base`'s bytes, with
|
|
142
|
+
* `instructions` bytes of instructions. It answers `copy` for an object as stored, the base's
|
|
143
|
+
* position for a delta as stored, and `whole` when the merge must resolve it and write it whole,
|
|
144
|
+
* its chain starting again; the table holds its chain either way.
|
|
145
|
+
*/
|
|
146
|
+
const wrote = (id, at, position, base, baseAt = 0, instructions = 0) => {
|
|
147
|
+
if (base === void 0) {
|
|
148
|
+
put(id, at, 0, position);
|
|
149
|
+
return "copy";
|
|
150
|
+
}
|
|
151
|
+
const found = probe(base, baseAt);
|
|
152
|
+
if (isTaken(found)) {
|
|
153
|
+
const entry = slot[found];
|
|
154
|
+
used(entry);
|
|
155
|
+
const below = chains[entry];
|
|
156
|
+
const depth = below % depthBits + 1;
|
|
157
|
+
const bytes = Math.floor(below / depthBits) + instructions;
|
|
158
|
+
if (depth <= deepestChain && bytes <= packIndexerLimits.deltaBytes) {
|
|
159
|
+
const based = positions[entry];
|
|
160
|
+
put(id, at, bytes * depthBits + depth, position);
|
|
161
|
+
return { base: based };
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
put(id, at, 0, position);
|
|
165
|
+
return "whole";
|
|
166
|
+
};
|
|
167
|
+
return {
|
|
168
|
+
wrote,
|
|
169
|
+
size: () => size
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
export { writtenBases, writtenBasesHeld, writtenBasesMost };
|
|
@@ -1,9 +1,36 @@
|
|
|
1
|
+
import "../contracts/calls-spent.mjs";
|
|
1
2
|
import "../contracts/objects.mjs";
|
|
2
3
|
import { CallLimits } from "@ref0/infra";
|
|
3
4
|
import * as Effect from "effect/Effect";
|
|
4
5
|
import * as Context from "effect/Context";
|
|
5
6
|
import * as Layer from "effect/Layer";
|
|
6
7
|
import "effect/Types";
|
|
8
|
+
/** Calls by the two kinds a platform caps: to the bucket, and of every kind, the bucket's among them. */
|
|
9
|
+
export interface CallCount {
|
|
10
|
+
readonly bucket: number;
|
|
11
|
+
readonly subrequests: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* One request's calls so far, and the most it may make: a Git fetch's or push's, from its serve to
|
|
15
|
+
* its answer's last byte. Each store and bucket call made for the request adds to it as it starts,
|
|
16
|
+
* the core's and the objects' alike, at the two doors every call goes through, `storeCall` and
|
|
17
|
+
* `bucketCall`: one count of all it calls, whatever grows with its input (#709, Q799). Internal,
|
|
18
|
+
* as is everything here but `CallBudget`: no host sees it.
|
|
19
|
+
*/
|
|
20
|
+
export declare class RequestCalls {
|
|
21
|
+
bucket: number;
|
|
22
|
+
subrequests: number;
|
|
23
|
+
/** The bound the doors check this count against before each call, or none. */
|
|
24
|
+
readonly most: CallCount | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Whether a call in the request has passed its deciding commit, as `afterCommit` marks it: no
|
|
27
|
+
* bound refuses the request's calls after it, each Git call it makes later included (Q855).
|
|
28
|
+
*/
|
|
29
|
+
committed: boolean;
|
|
30
|
+
constructor(most?: CallCount);
|
|
31
|
+
/** The calls made so far. */
|
|
32
|
+
made(): CallCount;
|
|
33
|
+
}
|
|
7
34
|
/**
|
|
8
35
|
* One `CallBudget`'s allowance: its limits, and its count kept in it. Only `CallBudget.make` makes
|
|
9
36
|
* one, so a budget written by hand, which would count nothing, doesn't type-check.
|
|
@@ -12,8 +39,15 @@ export declare class CallAllowance {
|
|
|
12
39
|
#private;
|
|
13
40
|
/** The most of each kind of call the budget allows. Left out, a kind has no limit. */
|
|
14
41
|
readonly limits: CallLimits.CallLimits['Service'];
|
|
42
|
+
/** The name its spent refusal gives it, as `CallBudget.make` was given it, if any. */
|
|
43
|
+
readonly name: string | undefined;
|
|
15
44
|
private constructor();
|
|
16
45
|
}
|
|
46
|
+
/** What `CallBudget.make` and `layer` take beside a budget's limits. */
|
|
47
|
+
export interface CallBudgetOptions {
|
|
48
|
+
/** What its spent refusal calls it, such as `'review'`: "The review budget's". */
|
|
49
|
+
readonly name?: string;
|
|
50
|
+
}
|
|
17
51
|
declare const CallBudget_base: Context.ServiceClass<CallBudget, "@ref0/git/CallBudget", CallAllowance>;
|
|
18
52
|
/**
|
|
19
53
|
* A limit on the store and bucket calls an Effect makes, below the platform's on its request.
|
|
@@ -23,19 +57,23 @@ declare const CallBudget_base: Context.ServiceClass<CallBudget, "@ref0/git/CallB
|
|
|
23
57
|
* A budget lives as long as the Layer that built it: provide one around one call or one step,
|
|
24
58
|
* never in a runtime's Layer, where every request would share it until the runtime ends. Each
|
|
25
59
|
* `CallBudget.layer(...)` or `make` is a budget of its own. A reader or a walk keeps the scope it
|
|
26
|
-
* was opened in, so a budget provided after it opened doesn't see its calls
|
|
60
|
+
* was opened in, so a budget provided after it opened doesn't see its calls, but for a read Git
|
|
61
|
+
* hands one on with `budgetedOn`.
|
|
27
62
|
*/
|
|
28
|
-
export declare class CallBudget extends CallBudget_base {
|
|
63
|
+
export declare class CallBudget extends /* @__PURE__ */ CallBudget_base {
|
|
29
64
|
/**
|
|
30
65
|
* A budget of `limits`, nested in the budget in scope where it's made, if any: a call it makes
|
|
31
66
|
* counts into that one too, so a nested budget never lets past its parent's limits. Its parent
|
|
32
67
|
* is fixed then: provided under another budget later, it shadows that one, which counts none of
|
|
33
68
|
* its calls, so make it where it's provided, or use `layer`. A limit of `Infinity` is no bound,
|
|
34
69
|
* left out of its `limits`, and one that isn't a whole number of calls, 0 or more, is a defect.
|
|
70
|
+
* Given a `name`, its spent refusal says whose budget it is, "The review budget's 1700
|
|
71
|
+
* subrequests are spent"; without one, "The call budget's". Of nested budgets, the refusal
|
|
72
|
+
* names the one whose limit was passed. A name that's empty or only spaces is a defect.
|
|
35
73
|
*/
|
|
36
|
-
static readonly make: (limits: CallLimits.CallLimits['Service']) => Effect.Effect<CallAllowance>;
|
|
74
|
+
static readonly make: (limits: CallLimits.CallLimits['Service'], options?: CallBudgetOptions) => Effect.Effect<CallAllowance>;
|
|
37
75
|
/** `make`'s budget, as a Layer: one new budget each time it's built. */
|
|
38
|
-
static readonly layer: (limits: CallLimits.CallLimits['Service']) => Layer.Layer<CallBudget>;
|
|
76
|
+
static readonly layer: (limits: CallLimits.CallLimits['Service'], options?: CallBudgetOptions) => Layer.Layer<CallBudget>;
|
|
39
77
|
/**
|
|
40
78
|
* Whether the budget in scope, or one it nests in, has spent a kind of call it limits, so the
|
|
41
79
|
* next call of that kind is refused: a host's call answers `RESOURCE_EXHAUSTED`,
|
|
@@ -44,4 +82,31 @@ export declare class CallBudget extends CallBudget_base {
|
|
|
44
82
|
*/
|
|
45
83
|
static readonly isSpent: Effect.Effect<boolean>;
|
|
46
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* What a call counts into: its request's count and the `CallBudget` in scope, either left out.
|
|
87
|
+
* Taken where a call starts and given back where it runs later or across a Promise, so a call
|
|
88
|
+
* the engine or a stream makes from a Promise of its own still counts where it began.
|
|
89
|
+
*/
|
|
90
|
+
export interface CallScope {
|
|
91
|
+
readonly calls: RequestCalls | undefined;
|
|
92
|
+
readonly budget: CallAllowance | undefined;
|
|
93
|
+
/** What the call's request keeps until it ends, a visible set's reach among it. */
|
|
94
|
+
readonly hold?: RequestHold | undefined;
|
|
95
|
+
/** Whether it runs after its request's deciding commit, as `afterCommit` marks it. */
|
|
96
|
+
readonly afterCommit?: boolean;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* What one call or one HTTP request keeps until it ends, which `withAudienceMemo` opens around
|
|
100
|
+
* each: a visible set's reach, with its allotment, so the set's later asks read none of it again
|
|
101
|
+
* (#596 PR 2c). No stream asks a set past its answer: a fetch's set narrows its wants, haves and
|
|
102
|
+
* shallows before the plan, and its writer reads whole. One that did would find the hold closed
|
|
103
|
+
* and build its reach for itself, kept nowhere.
|
|
104
|
+
*/
|
|
105
|
+
export declare class RequestHold {
|
|
106
|
+
#private;
|
|
107
|
+
/** `end` run as the hold closes: `false`, with nothing kept, once it has closed. */
|
|
108
|
+
keep(end: Effect.Effect<void>): boolean;
|
|
109
|
+
/** The hold closed, each `end` it kept run. */
|
|
110
|
+
readonly close: Effect.Effect<void, never, never>;
|
|
111
|
+
}
|
|
47
112
|
export {};
|
|
@@ -1,15 +1,33 @@
|
|
|
1
1
|
import { CallsSpent } from "../contracts/calls-spent.mjs";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
|
-
import * as Option from "effect/Option";
|
|
4
|
-
import * as Predicate from "effect/Predicate";
|
|
5
3
|
import * as Context from "effect/Context";
|
|
4
|
+
import * as Predicate from "effect/Predicate";
|
|
5
|
+
import * as Option from "effect/Option";
|
|
6
6
|
import * as Layer from "effect/Layer";
|
|
7
7
|
// src/store/call-count.ts
|
|
8
|
+
/**
|
|
9
|
+
* The store calls a Git fetch's request makes before its count starts, which its `callLimits`
|
|
10
|
+
* leave room for: one, `identify`'s read of a Git token's row, for a `gt_` bearer, and no bucket
|
|
11
|
+
* call. Every call from the serve on counts on the request's one count, the repo's record, its
|
|
12
|
+
* refs, its haves and its tags' peels with its pack's (#709). Measured locally, not at a colo, by
|
|
13
|
+
* negotiation-calls.test.ts: a token's request refused at its bound made 1 call more than it
|
|
14
|
+
* counted. The host's own `auth`, grants and `resolve` aren't Git's calls: a host whose run
|
|
15
|
+
* subrequests sets `callLimits` lower by them.
|
|
16
|
+
*/
|
|
17
|
+
const requestCallsBefore = {
|
|
18
|
+
bucket: 0,
|
|
19
|
+
subrequests: 1
|
|
20
|
+
};
|
|
21
|
+
/** `most` less `requestCallsBefore`, never below none: a request's bound once `identify` has read. */
|
|
22
|
+
const lessCallsBefore = (most) => ({
|
|
23
|
+
bucket: Math.max(0, most.bucket - requestCallsBefore.bucket),
|
|
24
|
+
subrequests: Math.max(0, most.subrequests - requestCallsBefore.subrequests)
|
|
25
|
+
});
|
|
8
26
|
/** The kind of `counted`'s calls `kind` would pass `most` of, if any. */
|
|
9
|
-
const spentOf = (counted, most, kind, calls = 1, of = "request") => {
|
|
27
|
+
const spentOf = (counted, most, kind, calls = 1, of = "request", budget) => {
|
|
10
28
|
if (most === void 0) return void 0;
|
|
11
|
-
if (kind === "bucket" && most.bucket !== void 0 && counted.bucket + calls > most.bucket) return new CallsSpent("bucket", most.bucket, of);
|
|
12
|
-
return most.subrequests !== void 0 && counted.subrequests + calls > most.subrequests ? new CallsSpent("subrequests", most.subrequests, of) : void 0;
|
|
29
|
+
if (kind === "bucket" && most.bucket !== void 0 && counted.bucket + calls > most.bucket) return new CallsSpent("bucket", most.bucket, of, void 0, budget);
|
|
30
|
+
return most.subrequests !== void 0 && counted.subrequests + calls > most.subrequests ? new CallsSpent("subrequests", most.subrequests, of, void 0, budget) : void 0;
|
|
13
31
|
};
|
|
14
32
|
/** One call of `kind` added to `counted`. */
|
|
15
33
|
const add = (counted, kind, calls = 1) => {
|
|
@@ -28,6 +46,11 @@ var RequestCalls = class {
|
|
|
28
46
|
subrequests = 0;
|
|
29
47
|
/** The bound the doors check this count against before each call, or none. */
|
|
30
48
|
most;
|
|
49
|
+
/**
|
|
50
|
+
* Whether a call in the request has passed its deciding commit, as `afterCommit` marks it: no
|
|
51
|
+
* bound refuses the request's calls after it, each Git call it makes later included (Q855).
|
|
52
|
+
*/
|
|
53
|
+
committed = false;
|
|
31
54
|
constructor(most) {
|
|
32
55
|
this.most = most;
|
|
33
56
|
}
|
|
@@ -39,10 +62,31 @@ var RequestCalls = class {
|
|
|
39
62
|
};
|
|
40
63
|
}
|
|
41
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* Whether the calls in scope run after the commit that decided their request's answer: each counts
|
|
67
|
+
* as ever, but no bound refuses it, so a write that committed answers its own success, and a retry
|
|
68
|
+
* makes no second record (Q855).
|
|
69
|
+
*/
|
|
70
|
+
const AfterCommit = Context.Reference("@ref0/git/AfterCommit", { defaultValue: () => false });
|
|
42
71
|
/** The count of the request in scope: a Git fetch's or push's, set by its route around all it does. */
|
|
43
|
-
const RequestCount = Context.Service("@ref0/git/RequestCount");
|
|
72
|
+
const RequestCount = /* @__PURE__ */ Context.Service("@ref0/git/RequestCount");
|
|
44
73
|
/** The request in scope's count, or `undefined` outside one. */
|
|
45
74
|
const requestCount = Effect.map(Effect.serviceOption(RequestCount), Option.getOrUndefined);
|
|
75
|
+
/**
|
|
76
|
+
* `effect`, run after its request's deciding commit, as `AfterCommit` says, the request in scope
|
|
77
|
+
* marked `committed` too, so its later Git calls, each a run of its own, are refused no more.
|
|
78
|
+
*/
|
|
79
|
+
const afterCommit = (effect) => Effect.flatMap(requestCount, (request) => {
|
|
80
|
+
if (request !== void 0) request.committed = true;
|
|
81
|
+
return Effect.provideService(effect, AfterCommit, true);
|
|
82
|
+
});
|
|
83
|
+
/** Whether a call in scope runs after its request's deciding commit, as `afterCommit` marks it. */
|
|
84
|
+
const committedNow = Effect.map(Effect.all([requestCount, AfterCommit]), ([request, marked]) => marked || request?.committed === true);
|
|
85
|
+
/**
|
|
86
|
+
* A lost commit's `resends`, counted into the request and its budgets but never refused, and the
|
|
87
|
+
* request left unmarked: each may have landed, and none decided anything yet.
|
|
88
|
+
*/
|
|
89
|
+
const chargeResends = (resends) => resends === 0 ? Effect.void : Effect.provideService(chargeCalls("store", resends), AfterCommit, true);
|
|
46
90
|
/** A budget's calls so far, and the budget it nests in, read only in this module. */
|
|
47
91
|
let madeOf;
|
|
48
92
|
let parentOf;
|
|
@@ -56,6 +100,8 @@ const madeHere = Symbol("ref0/git CallAllowance");
|
|
|
56
100
|
var CallAllowance = class CallAllowance {
|
|
57
101
|
/** The most of each kind of call the budget allows. Left out, a kind has no limit. */
|
|
58
102
|
limits;
|
|
103
|
+
/** The name its spent refusal gives it, as `CallBudget.make` was given it, if any. */
|
|
104
|
+
name;
|
|
59
105
|
#made = {
|
|
60
106
|
bucket: 0,
|
|
61
107
|
subrequests: 0
|
|
@@ -64,11 +110,12 @@ var CallAllowance = class CallAllowance {
|
|
|
64
110
|
static {
|
|
65
111
|
madeOf = (budget) => budget.#made;
|
|
66
112
|
parentOf = (budget) => budget.#parent;
|
|
67
|
-
budgetOf = (limits, parent) => new CallAllowance(madeHere, limits, parent);
|
|
113
|
+
budgetOf = (limits, parent, name) => new CallAllowance(madeHere, limits, parent, name);
|
|
68
114
|
}
|
|
69
|
-
constructor(token, limits, parent) {
|
|
115
|
+
constructor(token, limits, parent, name) {
|
|
70
116
|
if (token !== madeHere) throw new TypeError("A CallAllowance is made only by CallBudget.make");
|
|
71
117
|
this.limits = limits;
|
|
118
|
+
this.name = name;
|
|
72
119
|
this.#parent = parent;
|
|
73
120
|
}
|
|
74
121
|
};
|
|
@@ -95,6 +142,16 @@ const checkedLimits = (limits, what = "A CallBudget's ") => {
|
|
|
95
142
|
}
|
|
96
143
|
return Object.freeze(copied);
|
|
97
144
|
};
|
|
145
|
+
/** `limits` less `requestCallsBefore`, never below none. */
|
|
146
|
+
const lessBefore = (limits) => {
|
|
147
|
+
const less = (most, before) => most === void 0 ? void 0 : Math.max(0, most - before);
|
|
148
|
+
const bucket = less(limits.bucket, requestCallsBefore.bucket);
|
|
149
|
+
const subrequests = less(limits.subrequests, requestCallsBefore.subrequests);
|
|
150
|
+
const lessened = {};
|
|
151
|
+
if (bucket !== void 0) lessened.bucket = bucket;
|
|
152
|
+
if (subrequests !== void 0) lessened.subrequests = subrequests;
|
|
153
|
+
return lessened;
|
|
154
|
+
};
|
|
98
155
|
/**
|
|
99
156
|
* A limit on the store and bucket calls an Effect makes, below the platform's on its request.
|
|
100
157
|
* Each call Git makes in its scope counts into it as it starts: a store call as a subrequest, and
|
|
@@ -103,19 +160,26 @@ const checkedLimits = (limits, what = "A CallBudget's ") => {
|
|
|
103
160
|
* A budget lives as long as the Layer that built it: provide one around one call or one step,
|
|
104
161
|
* never in a runtime's Layer, where every request would share it until the runtime ends. Each
|
|
105
162
|
* `CallBudget.layer(...)` or `make` is a budget of its own. A reader or a walk keeps the scope it
|
|
106
|
-
* was opened in, so a budget provided after it opened doesn't see its calls
|
|
163
|
+
* was opened in, so a budget provided after it opened doesn't see its calls, but for a read Git
|
|
164
|
+
* hands one on with `budgetedOn`.
|
|
107
165
|
*/
|
|
108
|
-
var CallBudget = class CallBudget extends Context.Service()("@ref0/git/CallBudget") {
|
|
166
|
+
var CallBudget = class CallBudget extends (/* @__PURE__ */ Context.Service()("@ref0/git/CallBudget")) {
|
|
109
167
|
/**
|
|
110
168
|
* A budget of `limits`, nested in the budget in scope where it's made, if any: a call it makes
|
|
111
169
|
* counts into that one too, so a nested budget never lets past its parent's limits. Its parent
|
|
112
170
|
* is fixed then: provided under another budget later, it shadows that one, which counts none of
|
|
113
171
|
* its calls, so make it where it's provided, or use `layer`. A limit of `Infinity` is no bound,
|
|
114
172
|
* left out of its `limits`, and one that isn't a whole number of calls, 0 or more, is a defect.
|
|
173
|
+
* Given a `name`, its spent refusal says whose budget it is, "The review budget's 1700
|
|
174
|
+
* subrequests are spent"; without one, "The call budget's". Of nested budgets, the refusal
|
|
175
|
+
* names the one whose limit was passed. A name that's empty or only spaces is a defect.
|
|
115
176
|
*/
|
|
116
|
-
static make = (limits) => Effect.flatMap(Effect.sync(() =>
|
|
177
|
+
static make = (limits, options = {}) => Effect.flatMap(Effect.sync(() => {
|
|
178
|
+
if (options.name?.trim() === "") throw new RangeError(`A CallBudget's name is a word, not "${options.name}"`);
|
|
179
|
+
return checkedLimits(limits);
|
|
180
|
+
}), (checked) => Effect.map(inScope, (parent) => budgetOf(checked, parent, options.name)));
|
|
117
181
|
/** `make`'s budget, as a Layer: one new budget each time it's built. */
|
|
118
|
-
static layer = (limits) => Layer.effect(CallBudget, CallBudget.make(limits));
|
|
182
|
+
static layer = (limits, options = {}) => Layer.effect(CallBudget, CallBudget.make(limits, options));
|
|
119
183
|
/**
|
|
120
184
|
* Whether the budget in scope, or one it nests in, has spent a kind of call it limits, so the
|
|
121
185
|
* next call of that kind is refused: a host's call answers `RESOURCE_EXHAUSTED`,
|
|
@@ -126,51 +190,72 @@ var CallBudget = class CallBudget extends Context.Service()("@ref0/git/CallBudge
|
|
|
126
190
|
};
|
|
127
191
|
/** `effect`, run with `calls` as its request's count, or as it is with none. */
|
|
128
192
|
const countedAs = (effect, calls) => calls === void 0 ? effect : Effect.provideService(effect, RequestCount, calls);
|
|
193
|
+
/**
|
|
194
|
+
* What one call or one HTTP request keeps until it ends, which `withAudienceMemo` opens around
|
|
195
|
+
* each: a visible set's reach, with its allotment, so the set's later asks read none of it again
|
|
196
|
+
* (#596 PR 2c). No stream asks a set past its answer: a fetch's set narrows its wants, haves and
|
|
197
|
+
* shallows before the plan, and its writer reads whole. One that did would find the hold closed
|
|
198
|
+
* and build its reach for itself, kept nowhere.
|
|
199
|
+
*/
|
|
200
|
+
var RequestHold = class {
|
|
201
|
+
#closed = false;
|
|
202
|
+
#ends = [];
|
|
203
|
+
/** `end` run as the hold closes: `false`, with nothing kept, once it has closed. */
|
|
204
|
+
keep(end) {
|
|
205
|
+
if (this.#closed) return false;
|
|
206
|
+
this.#ends.push(end);
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
/** The hold closed, each `end` it kept run. */
|
|
210
|
+
close = Effect.suspend(() => {
|
|
211
|
+
this.#closed = true;
|
|
212
|
+
return Effect.forEach(this.#ends.splice(0), (end) => end, { discard: true });
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
/** The request's hold in scope, which `callScope` takes and `inCallScope` gives back. */
|
|
216
|
+
const RequestHolding = /* @__PURE__ */ Context.Service("@ref0/git/RequestHold");
|
|
217
|
+
/** `effect` holding what its request keeps until it ends. */
|
|
218
|
+
const withRequestHold = (effect) => Effect.suspend(() => {
|
|
219
|
+
const hold = new RequestHold();
|
|
220
|
+
return effect.pipe(Effect.provideService(RequestHolding, hold), Effect.ensuring(hold.close));
|
|
221
|
+
});
|
|
222
|
+
/**
|
|
223
|
+
* `scope`, counting into `calls` too when it holds no request's count of its own: a call a host's
|
|
224
|
+
* code makes for one request, as a package built on Git makes each of its routes' (#725).
|
|
225
|
+
*/
|
|
226
|
+
const countedScope = (scope, calls) => calls === void 0 || scope.calls !== void 0 ? scope : {
|
|
227
|
+
...scope,
|
|
228
|
+
calls
|
|
229
|
+
};
|
|
129
230
|
/** A scope with neither part: what a call taken with nothing in scope counts into. */
|
|
130
231
|
const noScope = {
|
|
131
232
|
calls: void 0,
|
|
132
233
|
budget: void 0
|
|
133
234
|
};
|
|
134
235
|
/** The call scope in context: its parts `undefined` with neither a request's count nor a budget. */
|
|
135
|
-
const callScope = Effect.map(Effect.all([
|
|
236
|
+
const callScope = Effect.map(Effect.all([
|
|
237
|
+
requestCount,
|
|
238
|
+
Effect.serviceOption(CallBudget),
|
|
239
|
+
Effect.serviceOption(RequestHolding),
|
|
240
|
+
AfterCommit
|
|
241
|
+
]), ([calls, budget, hold, after]) => calls === void 0 && Option.isNone(budget) && Option.isNone(hold) && !after ? noScope : {
|
|
136
242
|
calls,
|
|
137
|
-
budget: Option.getOrUndefined(budget)
|
|
243
|
+
budget: Option.getOrUndefined(budget),
|
|
244
|
+
hold: Option.getOrUndefined(hold),
|
|
245
|
+
afterCommit: after
|
|
138
246
|
});
|
|
139
247
|
/**
|
|
140
|
-
* `effect`, run in `scope` and no other: with the request's count
|
|
141
|
-
*
|
|
248
|
+
* `effect`, run in `scope` and no other: with the request's count, the budget, the hold and
|
|
249
|
+
* the `afterCommit` mark it holds, and with none it doesn't hold, whatever the context had. So a reader or a walk opened with no
|
|
142
250
|
* budget never takes one provided around a later call, and a run handed no scope counts nothing.
|
|
143
251
|
*/
|
|
144
|
-
const inCallScope = (effect, scope) => Effect.updateContext(effect, (
|
|
252
|
+
const inCallScope = (effect, scope) => Effect.updateContext(effect, scopedContext(scope));
|
|
253
|
+
/** `inCallScope`'s context: `context` with `scope`'s count, budget, hold and mark, and no other. */
|
|
254
|
+
const scopedContext = (scope) => (context) => {
|
|
145
255
|
const counted = scope.calls === void 0 ? Context.omit(RequestCount)(context) : Context.add(context, RequestCount, scope.calls);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
* The key a call's scope crosses a Promise under, in the call's input: module-private, never
|
|
150
|
-
* `Symbol.for`, and on no public type, so no host's code reads or sets it. Effect's context stops
|
|
151
|
-
* at a Promise, and Git's objects and store are called across one, so `handedOn` puts the scope on
|
|
152
|
-
* the input where Git calls them and `handedScope` takes it back where they run. A host's own
|
|
153
|
-
* objects never hand it on, so their calls count as they did: not at all. Deleted when Q754 1e
|
|
154
|
-
* makes objects Effect services.
|
|
155
|
-
*/
|
|
156
|
-
const handKey = Symbol("ref0/git call scope");
|
|
157
|
-
/** A scope as `handedOn` puts it on an input: its class tells it from anything else there. */
|
|
158
|
-
var Handed = class {
|
|
159
|
-
scope;
|
|
160
|
-
constructor(scope) {
|
|
161
|
-
this.scope = scope;
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
/** `input` with `scope` on it, a copy, for a call across a Promise; `input` itself with none. */
|
|
165
|
-
const handedOn = (input, scope) => scope === noScope ? input : {
|
|
166
|
-
...input,
|
|
167
|
-
[handKey]: new Handed(scope)
|
|
168
|
-
};
|
|
169
|
-
/** The scope `handedOn` put on `input`, or one with neither part. */
|
|
170
|
-
const handedScope = (input) => {
|
|
171
|
-
if (!Predicate.hasProperty(input, handKey)) return noScope;
|
|
172
|
-
const handed = input[handKey];
|
|
173
|
-
return handed instanceof Handed ? handed.scope : noScope;
|
|
256
|
+
const budgeted = scope.budget === void 0 ? Context.omit(CallBudget)(counted) : Context.add(counted, CallBudget, scope.budget);
|
|
257
|
+
const held = scope.hold === void 0 ? Context.omit(RequestHolding)(budgeted) : Context.add(budgeted, RequestHolding, scope.hold);
|
|
258
|
+
return Context.add(held, AfterCommit, scope.afterCommit === true);
|
|
174
259
|
};
|
|
175
260
|
/**
|
|
176
261
|
* One call of `kind`, counted into the request in scope and every `CallBudget` in scope, or
|
|
@@ -183,18 +268,75 @@ const chargeCall = (kind) => chargeCalls(kind, 1);
|
|
|
183
268
|
* `calls` calls of `kind`, charged as `chargeCall` charges one, all or none: when they'd pass a
|
|
184
269
|
* bound, none is counted, so a refused part of a put leaves no call it never made on a count.
|
|
185
270
|
*/
|
|
186
|
-
const chargeCalls = (kind, calls) => Effect.flatMap(Effect.all([
|
|
187
|
-
|
|
271
|
+
const chargeCalls = (kind, calls) => Effect.flatMap(Effect.all([
|
|
272
|
+
requestCount,
|
|
273
|
+
inScope,
|
|
274
|
+
AfterCommit
|
|
275
|
+
]), ([request, budget, marked]) => {
|
|
276
|
+
const after = marked || request?.committed === true;
|
|
277
|
+
const spent = request === void 0 || after ? void 0 : spentOf(request, request.most, kind, calls);
|
|
188
278
|
if (spent !== void 0) return Effect.die(spent);
|
|
189
279
|
const chain = chainOf(budget);
|
|
190
|
-
for (const at of chain) {
|
|
191
|
-
const over = spentOf(madeOf(at), at.limits, kind, calls, "budget");
|
|
192
|
-
if (over
|
|
280
|
+
for (const at of after ? [] : chain) {
|
|
281
|
+
const over = spentOf(madeOf(at), at.limits, kind, calls, "budget", at.name);
|
|
282
|
+
if (over === void 0) continue;
|
|
283
|
+
spentBudgets.set(over, at);
|
|
284
|
+
return Effect.die(over);
|
|
193
285
|
}
|
|
194
286
|
if (request !== void 0) add(request, kind, calls);
|
|
195
287
|
for (const at of chain) add(madeOf(at), kind, calls);
|
|
196
288
|
return Effect.void;
|
|
197
289
|
});
|
|
290
|
+
/**
|
|
291
|
+
* One call of `kind` held back for a call to come, charged now as `chargeCall` charges it, so
|
|
292
|
+
* the calls before it stop one short: what it gives is that call given back, once, to the counts
|
|
293
|
+
* it was charged to, right before the call it was held for (#647).
|
|
294
|
+
*/
|
|
295
|
+
const heldCall = (kind) => Effect.flatMap(Effect.all([requestCount, inScope]), ([request, budget]) => {
|
|
296
|
+
let held = true;
|
|
297
|
+
const given = Effect.sync(() => {
|
|
298
|
+
if (!held) return;
|
|
299
|
+
held = false;
|
|
300
|
+
if (request !== void 0) add(request, kind, -1);
|
|
301
|
+
for (const at of chainOf(budget)) add(madeOf(at), kind, -1);
|
|
302
|
+
});
|
|
303
|
+
return Effect.as(chargeCall(kind), given);
|
|
304
|
+
});
|
|
305
|
+
/** The budget that refused each `CallsSpent` a budget refused, which `spentBudget` reads. */
|
|
306
|
+
const spentBudgets = /* @__PURE__ */ new WeakMap();
|
|
307
|
+
/**
|
|
308
|
+
* The budget that refused `spent`, or `undefined` for a request's count or the platform's cap: so
|
|
309
|
+
* a step that stops at a budget of its own answers that one's spent call, and no other.
|
|
310
|
+
*/
|
|
311
|
+
const spentBudget = (spent) => spentBudgets.get(spent);
|
|
312
|
+
/**
|
|
313
|
+
* The key a read's own budget rides under, on its input: module-private, never `Symbol.for`, and
|
|
314
|
+
* on no public type, so no host's code reads or sets it.
|
|
315
|
+
*/
|
|
316
|
+
const budgetKey = Symbol("ref0/git read budget");
|
|
317
|
+
/**
|
|
318
|
+
* `input` with `budget` on it, a copy, for one read on a reader: the reader counts that read into
|
|
319
|
+
* `budget` too, so a budget made after the reader opened still bounds the read inside it, at the
|
|
320
|
+
* door, as a push's walks bound theirs.
|
|
321
|
+
*/
|
|
322
|
+
const budgetedOn = (input, budget) => ({
|
|
323
|
+
...input,
|
|
324
|
+
[budgetKey]: budget
|
|
325
|
+
});
|
|
326
|
+
/**
|
|
327
|
+
* `scope`, the one a reader was opened in, for one call with `input`: with the budget `budgetedOn`
|
|
328
|
+
* put on `input` in place of the scope's own, when it nests in that one, so the scope's budget
|
|
329
|
+
* still counts the call. Any other input leaves the scope as it is.
|
|
330
|
+
*/
|
|
331
|
+
const readScope = (scope, input) => {
|
|
332
|
+
if (!Predicate.hasProperty(input, budgetKey)) return scope;
|
|
333
|
+
const budget = input[budgetKey];
|
|
334
|
+
if (!(budget instanceof CallAllowance)) return scope;
|
|
335
|
+
return scope.budget === void 0 || chainOf(budget).includes(scope.budget) ? {
|
|
336
|
+
...scope,
|
|
337
|
+
budget
|
|
338
|
+
} : scope;
|
|
339
|
+
};
|
|
198
340
|
/** The bound each `packs()` open counts a request's calls against, by the objects it opened. */
|
|
199
341
|
const objectsBounds = /* @__PURE__ */ new WeakMap();
|
|
200
342
|
/** `objects`, kept as bound by `most`, which `countedMost` reads: `packs()`' own and the adapter's. */
|
|
@@ -204,4 +346,4 @@ const withBound = (objects, most) => {
|
|
|
204
346
|
};
|
|
205
347
|
/** The bound `withBound` kept for `objects`, or `undefined` for objects with none, a host's own. */
|
|
206
348
|
const countedMost = (objects) => objectsBounds.get(objects);
|
|
207
|
-
export { CallAllowance, CallBudget, RequestCalls, RequestCount, callScope, chargeCall, chargeCalls, checkedLimits, countedAs, countedMost,
|
|
349
|
+
export { CallAllowance, CallBudget, RequestCalls, RequestCount, RequestHold, RequestHolding, afterCommit, budgetedOn, callScope, chargeCall, chargeCalls, chargeResends, checkedLimits, committedNow, countedAs, countedMost, countedScope, heldCall, inCallScope, lessBefore, lessCallsBefore, noScope, readScope, requestCallsBefore, requestCount, scopedContext, spentBudget, withBound, withRequestHold };
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import "../contracts/promises.mjs";
|
|
2
|
+
import { InternalRepoId } from "../contracts/ids.mjs";
|
|
2
3
|
import "../contracts/repos.mjs";
|
|
3
|
-
import "
|
|
4
|
-
import "./
|
|
4
|
+
import "../contracts/result.mjs";
|
|
5
|
+
import { SettledName } from "./outbox.mjs";
|
|
6
|
+
import { CatalogueEntry, StoredRepo } from "./records.mjs";
|
|
5
7
|
import { Key, Listing, Page, Read, Row, Snapshot } from "@ref0/infra";
|
|
6
8
|
import "effect/Effect";
|
|
7
|
-
import "effect/Types";
|
|
9
|
+
import "effect/Types";
|
|
10
|
+
/**
|
|
11
|
+
* A repo found by name: its entry, its record, and its scope's snapshot, self first. Its `name` is
|
|
12
|
+
* settled: the catalogue gives it to this very record, the only name a write passes as `confirmed`.
|
|
13
|
+
*/
|
|
14
|
+
export interface ResolvedRepo {
|
|
15
|
+
readonly name: SettledName;
|
|
16
|
+
readonly internalId: InternalRepoId;
|
|
17
|
+
readonly entry: CatalogueEntry;
|
|
18
|
+
readonly record: StoredRepo;
|
|
19
|
+
/** The repo's scope, at one version: `results[0]` is `self`, then the reads asked for. */
|
|
20
|
+
readonly snapshot: Snapshot;
|
|
21
|
+
}
|