@ref0/git 0.0.0-stage → 0.2.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/LICENSE +202 -0
- package/dist/access/private-refs.d.mts +27 -0
- package/dist/access/private-refs.mjs +173 -0
- package/dist/access.d.mts +2 -0
- package/dist/access.mjs +1 -0
- package/dist/auth/access-jwt.d.mts +21 -0
- package/dist/auth/access-jwt.mjs +102 -0
- package/dist/auth/acting.mjs +15 -0
- package/dist/auth/authorize.d.mts +5 -0
- package/dist/auth/authorize.mjs +292 -0
- package/dist/auth/credentials.mjs +57 -0
- package/dist/auth/fences.d.mts +5 -0
- package/dist/auth/fences.mjs +65 -0
- package/dist/auth/grants.mjs +61 -0
- package/dist/auth/helpers.d.mts +17 -0
- package/dist/auth/helpers.mjs +25 -0
- package/dist/auth/host-function.d.mts +4 -0
- package/dist/auth/host-function.mjs +69 -0
- package/dist/auth/identify.d.mts +6 -0
- package/dist/auth/identify.mjs +97 -0
- package/dist/auth/token-rows.mjs +100 -0
- package/dist/auth/token-text.mjs +66 -0
- package/dist/auth/tokens.d.mts +10 -0
- package/dist/auth/tokens.mjs +347 -0
- package/dist/auth.d.mts +7 -0
- package/dist/auth.mjs +6 -0
- package/dist/client/answer.mjs +141 -0
- package/dist/client/client.d.mts +23 -0
- package/dist/client/client.mjs +51 -0
- package/dist/client/git-http.mjs +201 -0
- package/dist/client/helper-node.mjs +19 -0
- package/dist/client/local.mjs +160 -0
- package/dist/client/negotiate.mjs +170 -0
- package/dist/client/push-upload.mjs +53 -0
- package/dist/client/remote-helper.mjs +129 -0
- package/dist/client/remote.mjs +398 -0
- package/dist/client/run-remote-helper.d.mts +35 -0
- package/dist/client/run-remote-helper.mjs +259 -0
- package/dist/client/scrub.d.mts +18 -0
- package/dist/client/scrub.mjs +38 -0
- package/dist/client/transport.d.mts +2 -0
- package/dist/client/transport.mjs +211 -0
- package/dist/contracts/access.d.mts +87 -0
- package/dist/contracts/actors.d.mts +144 -0
- package/dist/contracts/blobs.d.mts +38 -0
- package/dist/contracts/calls-spent.d.mts +11 -0
- package/dist/contracts/calls-spent.mjs +150 -0
- package/dist/contracts/client.d.mts +90 -0
- package/dist/contracts/commits.d.mts +126 -0
- package/dist/contracts/engine.d.mts +134 -0
- package/dist/contracts/events.d.mts +276 -0
- package/dist/contracts/files.d.mts +75 -0
- package/dist/contracts/forks.d.mts +78 -0
- package/dist/contracts/grants.d.mts +60 -0
- package/dist/contracts/handlers.d.mts +10 -0
- package/dist/contracts/ids.d.mts +15 -0
- package/dist/contracts/ids.mjs +15 -0
- package/dist/contracts/lfs.d.mts +27 -0
- package/dist/contracts/merges.d.mts +33 -0
- package/dist/contracts/objects.d.mts +645 -0
- package/dist/contracts/objects.mjs +54 -0
- package/dist/contracts/operations.d.mts +133 -0
- package/dist/contracts/promises.d.mts +63 -0
- package/dist/contracts/push-uploads.d.mts +44 -0
- package/dist/contracts/queue.d.mts +401 -0
- package/dist/contracts/refs.d.mts +95 -0
- package/dist/contracts/remote.d.mts +50 -0
- package/dist/contracts/repos.d.mts +153 -0
- package/dist/contracts/result.d.mts +126 -0
- package/dist/contracts/result.mjs +34 -0
- package/dist/contracts/rules.d.mts +159 -0
- package/dist/contracts/server.d.mts +245 -0
- package/dist/contracts/services.d.mts +36 -0
- package/dist/contracts/services.mjs +13 -0
- package/dist/contracts/signin.d.mts +126 -0
- package/dist/contracts/store.d.mts +41 -0
- package/dist/contracts/sync.d.mts +210 -0
- package/dist/contracts/sync.mjs +8 -0
- package/dist/contracts/tags.d.mts +50 -0
- package/dist/contracts/tags.mjs +6 -0
- package/dist/contracts/tokens.d.mts +87 -0
- package/dist/contracts/tokens.mjs +15 -0
- package/dist/contracts/topics.d.mts +174 -0
- package/dist/contracts/trees.d.mts +84 -0
- package/dist/contracts/work.d.mts +31 -0
- package/dist/core/access.d.mts +22 -0
- package/dist/core/access.mjs +262 -0
- package/dist/core/ancestry.mjs +235 -0
- package/dist/core/clock.mjs +18 -0
- package/dist/core/events/deliver.mjs +468 -0
- package/dist/core/events/stream.d.mts +19 -0
- package/dist/core/events/stream.mjs +290 -0
- package/dist/core/forks.mjs +1027 -0
- package/dist/core/hooks/post-receive.mjs +204 -0
- package/dist/core/hooks/pre-receive.d.mts +5 -0
- package/dist/core/hooks/pre-receive.mjs +34 -0
- package/dist/core/index-job.mjs +198 -0
- package/dist/core/names.mjs +30 -0
- package/dist/core/objects/blobs.mjs +60 -0
- package/dist/core/objects/commit-writes.mjs +185 -0
- package/dist/core/objects/commits.mjs +172 -0
- package/dist/core/objects/files.mjs +211 -0
- package/dist/core/objects/lines.mjs +42 -0
- package/dist/core/objects/merges.mjs +83 -0
- package/dist/core/objects/peel.mjs +166 -0
- package/dist/core/objects/reading.mjs +284 -0
- package/dist/core/objects/tags.mjs +96 -0
- package/dist/core/objects/tree-edits.mjs +266 -0
- package/dist/core/objects/trees.mjs +229 -0
- package/dist/core/objects/writing.mjs +266 -0
- package/dist/core/own-writes.mjs +94 -0
- package/dist/core/promise.mjs +46 -0
- package/dist/core/publish.mjs +142 -0
- package/dist/core/push-decide.mjs +206 -0
- package/dist/core/push.mjs +1069 -0
- package/dist/core/receipts.d.mts +7 -0
- package/dist/core/receipts.mjs +234 -0
- package/dist/core/ref-conflicts.mjs +27 -0
- package/dist/core/refs.mjs +359 -0
- package/dist/core/repack.mjs +521 -0
- package/dist/core/repos.mjs +752 -0
- package/dist/core/rules/changes.mjs +57 -0
- package/dist/core/rules/check.mjs +101 -0
- package/dist/core/rules/commit-changes.mjs +216 -0
- package/dist/core/rules/context.d.mts +9 -0
- package/dist/core/rules/context.mjs +120 -0
- package/dist/core/rules/define.d.mts +5 -0
- package/dist/core/rules/define.mjs +13 -0
- package/dist/core/rules/facts.mjs +13 -0
- package/dist/core/rules/fetch.d.mts +5 -0
- package/dist/core/rules/fetch.mjs +59 -0
- package/dist/core/rules/file-globs.mjs +55 -0
- package/dist/core/rules/files.mjs +142 -0
- package/dist/core/rules/patterns.mjs +23 -0
- package/dist/core/rules/protect.d.mts +9 -0
- package/dist/core/rules/protect.mjs +116 -0
- package/dist/core/seam.d.mts +24 -0
- package/dist/core/seam.mjs +41 -0
- package/dist/core/sight.mjs +99 -0
- package/dist/core/tokens.mjs +95 -0
- package/dist/core/view.d.mts +9 -0
- package/dist/core/view.mjs +221 -0
- package/dist/core/work.mjs +92 -0
- package/dist/effect.d.mts +20 -0
- package/dist/effect.mjs +18 -0
- package/dist/engine/allotted-xdiff.d.mts +4 -0
- package/dist/engine/allotted-xdiff.mjs +80 -0
- package/dist/engine/attribute-patterns.mjs +163 -0
- package/dist/engine/attributes.mjs +226 -0
- package/dist/engine/combined.mjs +653 -0
- package/dist/engine/commits.mjs +90 -0
- package/dist/engine/content.d.mts +4 -0
- package/dist/engine/content.mjs +221 -0
- package/dist/engine/diff.mjs +49 -0
- package/dist/engine/engine.d.mts +25 -0
- package/dist/engine/engine.mjs +49 -0
- package/dist/engine/failures.d.mts +4 -0
- package/dist/engine/failures.mjs +23 -0
- package/dist/engine/line-count.mjs +23 -0
- package/dist/engine/merge-base-walk.d.mts +2 -0
- package/dist/engine/merge-base-walk.mjs +265 -0
- package/dist/engine/merge-bases.mjs +27 -0
- package/dist/engine/merge-renames.mjs +165 -0
- package/dist/engine/merge.mjs +1125 -0
- package/dist/engine/parts.d.mts +8 -0
- package/dist/engine/parts.mjs +9 -0
- package/dist/engine/reads.d.mts +5 -0
- package/dist/engine/reads.mjs +105 -0
- package/dist/engine/walk.mjs +328 -0
- package/dist/engine/xdiff/NOTICE.md +63 -0
- package/dist/engine/xdiff/compiled.d.mts +7 -0
- package/dist/engine/xdiff/compiled.mjs +9 -0
- package/dist/engine/xdiff/embedded.mjs +4 -0
- package/dist/engine/xdiff/node.d.mts +7 -0
- package/dist/engine/xdiff/node.mjs +10 -0
- package/dist/engine/xdiff/upstream/LGPL-2.1 +511 -0
- package/dist/engine/xdiff/xdiff.wasm +0 -0
- package/dist/engine/xdiff.d.mts +34 -0
- package/dist/engine/xdiff.mjs +380 -0
- package/dist/engine.d.mts +3 -0
- package/dist/engine.mjs +3 -0
- package/dist/extend.d.mts +3 -0
- package/dist/extend.mjs +1 -0
- package/dist/http/answers.mjs +74 -0
- package/dist/http/bodies.mjs +143 -0
- package/dist/http/core-parts.mjs +252 -0
- package/dist/http/fetch-depth.mjs +26 -0
- package/dist/http/handler.mjs +94 -0
- package/dist/http/node.d.mts +70 -0
- package/dist/http/node.mjs +178 -0
- package/dist/http/paths.d.mts +9 -0
- package/dist/http/paths.mjs +118 -0
- package/dist/http/push-uploads.mjs +286 -0
- package/dist/http/receive-pack.mjs +235 -0
- package/dist/http/upload-pack.mjs +229 -0
- package/dist/index.d.mts +46 -0
- package/dist/index.mjs +16 -0
- package/dist/lfs/calls.mjs +16 -0
- package/dist/lfs/locks.mjs +161 -0
- package/dist/lfs/objects.mjs +370 -0
- package/dist/lfs/pointers.mjs +141 -0
- package/dist/lfs/repo.mjs +42 -0
- package/dist/lfs/rows.mjs +108 -0
- package/dist/lfs/service.mjs +34 -0
- package/dist/lfs/upkeep.mjs +162 -0
- package/dist/lfs/wire.mjs +102 -0
- package/dist/node.d.mts +3 -0
- package/dist/node.mjs +3 -0
- package/dist/protocol/bytes/buffers.d.mts +38 -0
- package/dist/protocol/bytes/buffers.mjs +62 -0
- package/dist/protocol/bytes/crc32.d.mts +4 -0
- package/dist/protocol/bytes/crc32.mjs +14 -0
- package/dist/protocol/bytes/deflate.d.mts +78 -0
- package/dist/protocol/bytes/deflate.mjs +175 -0
- package/dist/protocol/bytes/errors.d.mts +20 -0
- package/dist/protocol/bytes/errors.mjs +19 -0
- package/dist/protocol/bytes/hex.mjs +16 -0
- package/dist/protocol/bytes/hmac-sha256.mjs +91 -0
- package/dist/protocol/bytes/inflate.d.mts +40 -0
- package/dist/protocol/bytes/inflate.mjs +109 -0
- package/dist/protocol/bytes/joined.d.mts +2 -0
- package/dist/protocol/bytes/joined.mjs +25 -0
- package/dist/protocol/bytes/sha1-hasher.d.mts +20 -0
- package/dist/protocol/bytes/sha1-hasher.mjs +72 -0
- package/dist/protocol/bytes/sha1.d.mts +35 -0
- package/dist/protocol/bytes/sha1.mjs +409 -0
- package/dist/protocol/bytes/sha256.mjs +156 -0
- package/dist/protocol/bytes/streams.mjs +11 -0
- package/dist/protocol/bytes/text.mjs +19 -0
- package/dist/protocol/diff/diff-raw.d.mts +29 -0
- package/dist/protocol/diff/diff-raw.mjs +73 -0
- package/dist/protocol/diff/patch.mjs +92 -0
- package/dist/protocol/diff/paths.mjs +67 -0
- package/dist/protocol/diff/read.d.mts +62 -0
- package/dist/protocol/diff/read.mjs +342 -0
- package/dist/protocol/diff/rename-similarity.mjs +428 -0
- package/dist/protocol/diff/text.mjs +12 -0
- package/dist/protocol/diff/tree-diff.d.mts +41 -0
- package/dist/protocol/diff/tree-diff.mjs +607 -0
- package/dist/protocol/framing/band.d.mts +10 -0
- package/dist/protocol/framing/band.mjs +16 -0
- package/dist/protocol/framing/pkt-line.d.mts +48 -0
- package/dist/protocol/framing/pkt-line.mjs +92 -0
- package/dist/protocol/objects/checked-blobs.mjs +127 -0
- package/dist/protocol/objects/commit.d.mts +25 -0
- package/dist/protocol/objects/commit.mjs +138 -0
- package/dist/protocol/objects/fsck-gitmodules.mjs +296 -0
- package/dist/protocol/objects/fsck-names.mjs +189 -0
- package/dist/protocol/objects/fsck.mjs +297 -0
- package/dist/protocol/objects/headers.mjs +109 -0
- package/dist/protocol/objects/held.mjs +56 -0
- package/dist/protocol/objects/iconv.mjs +145 -0
- package/dist/protocol/objects/ident.mjs +111 -0
- package/dist/protocol/objects/lfs-pointer.d.mts +8 -0
- package/dist/protocol/objects/lfs-pointer.mjs +63 -0
- package/dist/protocol/objects/links-raw.mjs +89 -0
- package/dist/protocol/objects/object-rules.mjs +75 -0
- package/dist/protocol/objects/object.d.mts +16 -0
- package/dist/protocol/objects/object.mjs +29 -0
- package/dist/protocol/objects/tag.d.mts +21 -0
- package/dist/protocol/objects/tag.mjs +96 -0
- package/dist/protocol/objects/tree.d.mts +43 -0
- package/dist/protocol/objects/tree.mjs +162 -0
- package/dist/protocol/objects/utf8-verify.mjs +71 -0
- package/dist/protocol/packs/delta.d.mts +57 -0
- package/dist/protocol/packs/delta.mjs +229 -0
- package/dist/protocol/packs/graph.mjs +78 -0
- package/dist/protocol/packs/idx.d.mts +54 -0
- package/dist/protocol/packs/idx.mjs +274 -0
- package/dist/protocol/packs/indexer.d.mts +167 -0
- package/dist/protocol/packs/indexer.mjs +507 -0
- package/dist/protocol/packs/parts.d.mts +40 -0
- package/dist/protocol/packs/parts.mjs +89 -0
- package/dist/protocol/packs/pos.mjs +51 -0
- package/dist/protocol/packs/reader.d.mts +180 -0
- package/dist/protocol/packs/reader.mjs +414 -0
- package/dist/protocol/packs/rev.d.mts +32 -0
- package/dist/protocol/packs/rev.mjs +99 -0
- package/dist/protocol/packs/step.d.mts +10 -0
- package/dist/protocol/packs/step.mjs +12 -0
- package/dist/protocol/packs/write-error.d.mts +12 -0
- package/dist/protocol/packs/write-error.mjs +27 -0
- package/dist/protocol/packs/writer.d.mts +157 -0
- package/dist/protocol/packs/writer.mjs +353 -0
- package/dist/protocol/wire/advertisement.d.mts +72 -0
- package/dist/protocol/wire/advertisement.mjs +161 -0
- package/dist/protocol/wire/fetch.d.mts +155 -0
- package/dist/protocol/wire/fetch.mjs +458 -0
- package/dist/protocol/wire/lines.mjs +107 -0
- package/dist/protocol/wire/push-uploads.mjs +43 -0
- package/dist/protocol/wire/receive-pack.d.mts +71 -0
- package/dist/protocol/wire/receive-pack.mjs +157 -0
- package/dist/protocol/wire/report-status.d.mts +47 -0
- package/dist/protocol/wire/report-status.mjs +119 -0
- package/dist/protocol/wire/v2.d.mts +90 -0
- package/dist/protocol/wire/v2.mjs +185 -0
- package/dist/protocol.d.mts +31 -0
- package/dist/protocol.mjs +31 -0
- package/dist/queue/advance.mjs +1036 -0
- package/dist/queue/callers.mjs +134 -0
- package/dist/queue/calls.mjs +1154 -0
- package/dist/queue/commit.mjs +85 -0
- package/dist/queue/host.d.mts +15 -0
- package/dist/queue/host.mjs +88 -0
- package/dist/queue/ids.d.mts +5 -0
- package/dist/queue/ids.mjs +21 -0
- package/dist/queue/lanes.mjs +86 -0
- package/dist/queue/limits.mjs +99 -0
- package/dist/queue/pages.mjs +76 -0
- package/dist/queue/push-option.mjs +62 -0
- package/dist/queue/rows.mjs +206 -0
- package/dist/queue/schedule.mjs +132 -0
- package/dist/queue/search.mjs +315 -0
- package/dist/queue/state.mjs +325 -0
- package/dist/queue/steps.mjs +317 -0
- package/dist/remote-helper.d.mts +3 -0
- package/dist/remote-helper.mjs +3 -0
- package/dist/rest/api.d.mts +23 -0
- package/dist/rest/api.mjs +27 -0
- package/dist/rest/blobs.d.mts +58 -0
- package/dist/rest/blobs.mjs +41 -0
- package/dist/rest/caller.d.mts +102 -0
- package/dist/rest/caller.mjs +18 -0
- package/dist/rest/client.d.mts +18 -0
- package/dist/rest/client.mjs +587 -0
- package/dist/rest/commits.d.mts +435 -0
- package/dist/rest/commits.mjs +140 -0
- package/dist/rest/errors.d.mts +44 -0
- package/dist/rest/errors.mjs +186 -0
- package/dist/rest/events.d.mts +38 -0
- package/dist/rest/events.mjs +74 -0
- package/dist/rest/files.d.mts +179 -0
- package/dist/rest/files.mjs +92 -0
- package/dist/rest/forks.d.mts +205 -0
- package/dist/rest/forks.mjs +51 -0
- package/dist/rest/handler.d.mts +17 -0
- package/dist/rest/handler.mjs +106 -0
- package/dist/rest/handlers.d.mts +8 -0
- package/dist/rest/handlers.mjs +592 -0
- package/dist/rest/listen.d.mts +24 -0
- package/dist/rest/listen.mjs +142 -0
- package/dist/rest/me.d.mts +55 -0
- package/dist/rest/me.mjs +21 -0
- package/dist/rest/merges.d.mts +90 -0
- package/dist/rest/merges.mjs +39 -0
- package/dist/rest/paths.mjs +86 -0
- package/dist/rest/queue.d.mts +486 -0
- package/dist/rest/queue.mjs +228 -0
- package/dist/rest/refs.d.mts +232 -0
- package/dist/rest/refs.mjs +86 -0
- package/dist/rest/repos.d.mts +223 -0
- package/dist/rest/repos.mjs +93 -0
- package/dist/rest/tags.d.mts +153 -0
- package/dist/rest/tags.mjs +72 -0
- package/dist/rest/tokens.d.mts +297 -0
- package/dist/rest/tokens.mjs +88 -0
- package/dist/rest/topics.d.mts +257 -0
- package/dist/rest/topics.mjs +116 -0
- package/dist/rest/trees.d.mts +158 -0
- package/dist/rest/trees.mjs +118 -0
- package/dist/rest/wire.mjs +57 -0
- package/dist/rest/work.d.mts +107 -0
- package/dist/rest/work.mjs +77 -0
- package/dist/rest.d.mts +8 -0
- package/dist/rest.mjs +5 -0
- package/dist/server/extension.d.mts +14 -0
- package/dist/server/extension.mjs +85 -0
- package/dist/server/routes.d.mts +25 -0
- package/dist/server/routes.mjs +67 -0
- package/dist/server/server.d.mts +2 -0
- package/dist/server/server.mjs +439 -0
- package/dist/signin/codes.mjs +47 -0
- package/dist/signin/context.d.mts +9 -0
- package/dist/signin/context.mjs +121 -0
- package/dist/signin/device.mjs +122 -0
- package/dist/signin/forms.mjs +157 -0
- package/dist/signin/grants.d.mts +5 -0
- package/dist/signin/grants.mjs +257 -0
- package/dist/signin/route.mjs +68 -0
- package/dist/signin/web.mjs +125 -0
- package/dist/signin/wire.d.mts +42 -0
- package/dist/signin/wire.mjs +43 -0
- package/dist/storage/allotted.mjs +102 -0
- package/dist/storage/budget.mjs +96 -0
- package/dist/storage/calls.d.mts +18 -0
- package/dist/storage/calls.mjs +273 -0
- package/dist/storage/clean-up.mjs +124 -0
- package/dist/storage/distinct-ids.mjs +39 -0
- package/dist/storage/ewah.mjs +97 -0
- package/dist/storage/fetch.d.mts +13 -0
- package/dist/storage/fetch.mjs +792 -0
- package/dist/storage/fsck.mjs +77 -0
- package/dist/storage/held-memo.mjs +188 -0
- package/dist/storage/index-bitmaps.d.mts +4 -0
- package/dist/storage/index-bitmaps.mjs +654 -0
- package/dist/storage/index-build.d.mts +15 -0
- package/dist/storage/index-build.mjs +1433 -0
- package/dist/storage/index-fetch.d.mts +9 -0
- package/dist/storage/index-fetch.mjs +756 -0
- package/dist/storage/index-files.mjs +232 -0
- package/dist/storage/index-graph.d.mts +3 -0
- package/dist/storage/index-graph.mjs +1049 -0
- package/dist/storage/index-layers.mjs +317 -0
- package/dist/storage/index-reach.mjs +216 -0
- package/dist/storage/index-remap.d.mts +8 -0
- package/dist/storage/index-remap.mjs +592 -0
- package/dist/storage/layout.mjs +69 -0
- package/dist/storage/lfs-pointers.d.mts +21 -0
- package/dist/storage/lfs-pointers.mjs +175 -0
- package/dist/storage/link-join.mjs +106 -0
- package/dist/storage/links.mjs +105 -0
- package/dist/storage/loose.d.mts +15 -0
- package/dist/storage/loose.mjs +120 -0
- package/dist/storage/memory-budget.d.mts +8 -0
- package/dist/storage/memory-budget.mjs +546 -0
- package/dist/storage/merge.mjs +416 -0
- package/dist/storage/object-rows.d.mts +6 -0
- package/dist/storage/object-rows.mjs +211 -0
- package/dist/storage/pack-order.d.mts +8 -0
- package/dist/storage/pack-order.mjs +779 -0
- package/dist/storage/pack-ranges.d.mts +5 -0
- package/dist/storage/pack-ranges.mjs +284 -0
- package/dist/storage/pack-reads.d.mts +11 -0
- package/dist/storage/pack-reads.mjs +990 -0
- package/dist/storage/pack-receive.d.mts +11 -0
- package/dist/storage/pack-receive.mjs +449 -0
- package/dist/storage/packs.d.mts +56 -0
- package/dist/storage/packs.mjs +600 -0
- package/dist/storage/prune.mjs +506 -0
- package/dist/storage/push-allotment.mjs +109 -0
- package/dist/storage/push-uploads.mjs +151 -0
- package/dist/storage/pushed-commits.mjs +136 -0
- package/dist/storage/quarantine.mjs +98 -0
- package/dist/storage/raw-ids.mjs +44 -0
- package/dist/storage/ready.d.mts +19 -0
- package/dist/storage/ready.mjs +328 -0
- package/dist/storage/receive-links.mjs +297 -0
- package/dist/storage/repack-job.mjs +48 -0
- package/dist/storage/repack.d.mts +31 -0
- package/dist/storage/repack.mjs +182 -0
- package/dist/storage/roots.mjs +42 -0
- package/dist/storage/rows.d.mts +3 -0
- package/dist/storage/rows.mjs +71 -0
- package/dist/storage/shallow.d.mts +5 -0
- package/dist/storage/shallow.mjs +128 -0
- package/dist/storage/stream-whole.mjs +236 -0
- package/dist/storage/unpack.mjs +236 -0
- package/dist/storage/visible.mjs +137 -0
- package/dist/storage/walk.d.mts +7 -0
- package/dist/storage/walk.mjs +170 -0
- package/dist/storage/wants.mjs +362 -0
- package/dist/store/call-count.d.mts +47 -0
- package/dist/store/call-count.mjs +207 -0
- package/dist/store/catalogue.d.mts +7 -0
- package/dist/store/catalogue.mjs +643 -0
- package/dist/store/crossing.mjs +66 -0
- package/dist/store/cursor-seal.d.mts +2 -0
- package/dist/store/cursor-seal.mjs +85 -0
- package/dist/store/errors.d.mts +12 -0
- package/dist/store/errors.mjs +129 -0
- package/dist/store/git-store.mjs +75 -0
- package/dist/store/list-job.mjs +35 -0
- package/dist/store/outbox.d.mts +7 -0
- package/dist/store/outbox.mjs +295 -0
- package/dist/store/queue-jobs.mjs +43 -0
- package/dist/store/random.mjs +28 -0
- package/dist/store/records.d.mts +4 -0
- package/dist/store/records.mjs +192 -0
- package/dist/store/ref-rows.d.mts +4 -0
- package/dist/store/ref-rows.mjs +30 -0
- package/dist/store/repo-record.mjs +100 -0
- package/dist/store/reservations.mjs +82 -0
- package/dist/store/scopes.mjs +170 -0
- package/dist/store/settle.mjs +63 -0
- package/dist/store/topic-jobs.mjs +62 -0
- package/dist/sync/bound.d.mts +7 -0
- package/dist/sync/bound.mjs +29 -0
- package/dist/sync/github.d.mts +12 -0
- package/dist/sync/github.mjs +297 -0
- package/dist/sync/import.d.mts +8 -0
- package/dist/sync/import.mjs +154 -0
- package/dist/sync/jobs.d.mts +9 -0
- package/dist/sync/jobs.mjs +80 -0
- package/dist/sync/mirror.d.mts +9 -0
- package/dist/sync/mirror.mjs +227 -0
- package/dist/sync/publish.d.mts +5 -0
- package/dist/sync/publish.mjs +117 -0
- package/dist/sync/records.mjs +73 -0
- package/dist/sync/smart-http.d.mts +8 -0
- package/dist/sync/smart-http.mjs +23 -0
- package/dist/sync/step.mjs +334 -0
- package/dist/sync/tries.mjs +126 -0
- package/dist/sync.d.mts +8 -0
- package/dist/sync.mjs +8 -0
- package/dist/topics/advance.mjs +554 -0
- package/dist/topics/calls.mjs +346 -0
- package/dist/topics/directory.mjs +107 -0
- package/dist/topics/host.d.mts +11 -0
- package/dist/topics/host.mjs +71 -0
- package/dist/topics/members.mjs +177 -0
- package/dist/topics/rows.mjs +99 -0
- package/dist/topics/topic.mjs +126 -0
- package/package.json +88 -3
- package/README.md +0 -3
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { allotmentWithin, objectsReadMost } from "../contracts/objects.mjs";
|
|
2
|
+
import { callScope, chargeCall, chargeCalls, handedOn, handedScope, inCallScope } from "../store/call-count.mjs";
|
|
3
|
+
import { resultIn, runIn } from "../store/crossing.mjs";
|
|
4
|
+
import { fromInfra, gitError, resultCall } from "../store/errors.mjs";
|
|
5
|
+
import { tryUnlessSpent } from "../contracts/calls-spent.mjs";
|
|
6
|
+
import { isInfraError } from "@ref0/infra";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Scope$1 from "effect/Scope";
|
|
9
|
+
import * as Deferred from "effect/Deferred";
|
|
10
|
+
// src/storage/calls.ts
|
|
11
|
+
/**
|
|
12
|
+
* A call Git's core made across a Promise, answered as `Result`: run in the scope it handed on in
|
|
13
|
+
* `input`, and with `input`'s signal. Every call into `packs()`' objects answers so.
|
|
14
|
+
*/
|
|
15
|
+
const answerTo = (effect, input) => resultIn(effect, handedScope(input), input?.signal);
|
|
16
|
+
/**
|
|
17
|
+
* `call` across a Promise as `resultCall` makes it, with the call scope in context, its request's
|
|
18
|
+
* count and its budget, handed on in its input, a copy, for `answerTo` to take back on the far side.
|
|
19
|
+
*/
|
|
20
|
+
const handedCall = (input, call) => Effect.flatMap(callScope, (scope) => resultCall((signal) => call(handedOn(input, scope), signal)));
|
|
21
|
+
/**
|
|
22
|
+
* `effect`, `body` cancelled when it fails or is interrupted, so a refused or abandoned push stops
|
|
23
|
+
* its sender. A body a reader holds can't be cancelled here: that reader's clean-up cancels it.
|
|
24
|
+
*/
|
|
25
|
+
const cancelsBody = (body, effect) => effect.pipe(Effect.onError(() => Effect.promise(() => body.cancel().catch(() => void 0))));
|
|
26
|
+
/**
|
|
27
|
+
* The store `open` is given, as Effects, each call handing on its call scope, which the server's
|
|
28
|
+
* runner runs it in again for `storeCall`, the door the call counts at.
|
|
29
|
+
*/
|
|
30
|
+
const effectStore = (store) => ({
|
|
31
|
+
read: (input) => handedCall(input, (at) => store.read(at)),
|
|
32
|
+
commit: (input) => handedCall(input, (at) => store.commit(at)),
|
|
33
|
+
add: (input) => handedCall(input, (at) => store.add(at)),
|
|
34
|
+
listed: (input) => handedCall(input, (at) => store.listed(at))
|
|
35
|
+
});
|
|
36
|
+
const closedReader = gitError("FAILED_PRECONDITION", "This object reader is closed", { hint: "Open a reader for each walk, and read only while it is open" });
|
|
37
|
+
/** `ObjectReader.objects`' refusal of a call asking for none, or past `objectsReadMost`. */
|
|
38
|
+
const objectsCount = (count) => gitError("INVALID_ARGUMENT", `An objects read asks for 1 to ${objectsReadMost} IDs, not ${count}`, { hint: `Ask for at most ${objectsReadMost} at a time` });
|
|
39
|
+
/**
|
|
40
|
+
* `calls` as `GitObjects`' reader: each call refused once the reader is closed, and `close`
|
|
41
|
+
* releasing what `calls` hold, once, then letting go of `calls`: a closed reader still in reach
|
|
42
|
+
* holds nothing, and a body it handed on alone keeps the blocks it reads. Each call runs in
|
|
43
|
+
* `scope`, the one the reader was opened in: a reader is one walk's, never two requests'.
|
|
44
|
+
*/
|
|
45
|
+
const objectReader = (given, scope) => {
|
|
46
|
+
let calls = given;
|
|
47
|
+
const open = (effect) => Effect.suspend(() => calls === void 0 ? Effect.fail(closedReader) : effect(calls));
|
|
48
|
+
return {
|
|
49
|
+
read: (input) => resultIn(open((calls) => calls.object(input.oid, input.signal)), scope, input.signal),
|
|
50
|
+
sizes: (input) => resultIn(open((calls) => calls.sizes(input.oids)), scope, input.signal),
|
|
51
|
+
headers: (input) => resultIn(open((calls) => calls.headers(input.oids)), scope, input.signal),
|
|
52
|
+
held: (input) => resultIn(open((calls) => calls.has(input.oids)), scope, input.signal),
|
|
53
|
+
objects: (input) => resultIn(input.oids.length === 0 || input.oids.length > 1024 ? Effect.fail(objectsCount(input.oids.length)) : open((calls) => calls.objects(input.oids, input.bytes)), scope, input.signal),
|
|
54
|
+
allotment: (most, refusal) => calls === void 0 ? allotmentWithin(0, closedReader) : calls.allotment(most, refusal),
|
|
55
|
+
close: () => {
|
|
56
|
+
const closing = calls;
|
|
57
|
+
calls = void 0;
|
|
58
|
+
closing?.release();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* A reader over `listed` for the scope it's opened in, closed when the scope ends, on success,
|
|
64
|
+
* failure and interrupt alike. Core opens a reader only through this, never with a bare
|
|
65
|
+
* `reader()`, so none outlives its request and keeps its read cache: `calls.test.ts` checks it.
|
|
66
|
+
*/
|
|
67
|
+
const scopedReader = (objects, listed, input) => Effect.acquireRelease(objects.reader(listed, input), (reader) => Effect.sync(() => reader.close()));
|
|
68
|
+
/** `reader`'s calls as Effects. */
|
|
69
|
+
const walkReader = (reader) => ({
|
|
70
|
+
read: (input) => resultCall(() => reader.read(input)),
|
|
71
|
+
sizes: (input) => resultCall(() => reader.sizes(input)),
|
|
72
|
+
headers: (input) => resultCall(() => reader.headers(input)),
|
|
73
|
+
held: (input) => resultCall(() => reader.held(input)),
|
|
74
|
+
objects: (input) => resultCall(() => reader.objects(input)),
|
|
75
|
+
allotment: (most, refusal) => reader.allotment(most, refusal)
|
|
76
|
+
});
|
|
77
|
+
/** `use` on a reader of its own over `listed`, closed once `use` settles: a call with no walk. */
|
|
78
|
+
const once = (objects, listed, input, use) => Effect.scoped(Effect.flatMap(scopedReader(objects, listed, input), (reader) => use(walkReader(reader))));
|
|
79
|
+
/**
|
|
80
|
+
* One read of `listed`'s objects, on a reader of its own, closed once the read settles. A body it
|
|
81
|
+
* hands on keeps the blocks it streams from until it ends.
|
|
82
|
+
*/
|
|
83
|
+
const readOnce = (objects, listed, input) => once(objects, listed, input.listedOnly === true ? { listedOnly: true } : void 0, (reader) => reader.read(input));
|
|
84
|
+
/** `ObjectReader.sizes` of `listed`'s objects, on a reader of its own. */
|
|
85
|
+
const sizesOnce = (objects, listed, input) => once(objects, listed, void 0, (reader) => reader.sizes(input));
|
|
86
|
+
/** `ObjectReader.headers` of `listed`'s objects, on a reader of its own. */
|
|
87
|
+
const headersOnce = (objects, listed, input) => once(objects, listed, void 0, (reader) => reader.headers(input));
|
|
88
|
+
/** `ObjectReader.held` of `listed`'s objects, on a reader of its own. */
|
|
89
|
+
const heldOnce = (objects, listed, input) => once(objects, listed, void 0, (reader) => reader.held(input));
|
|
90
|
+
/** `ObjectReader.objects` of `listed`'s objects, on a reader of its own. */
|
|
91
|
+
const objectsOnce = (objects, listed, input) => once(objects, listed, input.listedOnly === true ? { listedOnly: true } : void 0, (reader) => reader.objects(input));
|
|
92
|
+
/**
|
|
93
|
+
* `objects`' reads for a call with no walk, such as a fork's or the client's have walk: each one
|
|
94
|
+
* `readOnce`, `sizesOnce`, `headersOnce`, `heldOnce` or `objectsOnce`, on a reader of its own.
|
|
95
|
+
*/
|
|
96
|
+
const oneShotReads = (objects) => ({
|
|
97
|
+
read: (listed, input) => readOnce(objects, listed, input),
|
|
98
|
+
sizes: (listed, input) => sizesOnce(objects, listed, input),
|
|
99
|
+
headers: (listed, input) => headersOnce(objects, listed, input),
|
|
100
|
+
held: (listed, input) => heldOnce(objects, listed, input),
|
|
101
|
+
objects: (listed, input) => objectsOnce(objects, listed, input),
|
|
102
|
+
allotment: (_, most, refusal) => Effect.succeed(allotmentWithin(most, refusal))
|
|
103
|
+
});
|
|
104
|
+
/**
|
|
105
|
+
* `objects` for one walk: its `read`, `sizes` and `headers` each go through one reader for each
|
|
106
|
+
* `Listed` they're asked about, by identity, opened at the first call and closed when the walk's
|
|
107
|
+
* scope ends. So a walk that passes the same `Listed` to every read shares one cache, and a
|
|
108
|
+
* walk over the repo and a push's quarantine holds a reader for each. Given a push's allotment, its
|
|
109
|
+
* readers open within it. Every call it makes runs in the call scope the walk was made in, its
|
|
110
|
+
* readers' and the rest alike, so a call made from a Promise of its own counts there still.
|
|
111
|
+
*/
|
|
112
|
+
const walkObjects = Effect.fnUntraced(function* (objects, push) {
|
|
113
|
+
const scope = yield* Effect.scope;
|
|
114
|
+
const calls = yield* callScope;
|
|
115
|
+
const readers = /* @__PURE__ */ new Map();
|
|
116
|
+
const listedOnlyReaders = /* @__PURE__ */ new Map();
|
|
117
|
+
const readerOf = (listed, listedOnly) => Effect.suspend(() => {
|
|
118
|
+
const kept = listedOnly === true ? listedOnlyReaders : readers;
|
|
119
|
+
const opening = kept.get(listed);
|
|
120
|
+
if (opening !== void 0) return Deferred.await(opening);
|
|
121
|
+
const opened = Deferred.makeUnsafe();
|
|
122
|
+
kept.set(listed, opened);
|
|
123
|
+
const input = {};
|
|
124
|
+
if (listedOnly === true) input.listedOnly = true;
|
|
125
|
+
if (push !== void 0) input.push = push;
|
|
126
|
+
const reading = inCallScope(Effect.map(scopedReader(objects, listed, input), walkReader), calls);
|
|
127
|
+
return Effect.provideService(reading, Scope$1.Scope, scope).pipe(Effect.exit, Effect.flatMap((exit) => Deferred.done(opened, exit)), Effect.andThen(Deferred.await(opened)));
|
|
128
|
+
});
|
|
129
|
+
/** `call` in the walk's scope, wherever it's run: a rule's walk calls from a Promise of its own. */
|
|
130
|
+
const inWalk = (call) => (...args) => inCallScope(call(...args), calls);
|
|
131
|
+
return {
|
|
132
|
+
readyShallow: objects.readyShallow,
|
|
133
|
+
reader: inWalk(objects.reader),
|
|
134
|
+
pushedCommits: inWalk(objects.pushedCommits),
|
|
135
|
+
receive: inWalk(objects.receive),
|
|
136
|
+
fetch: inWalk(objects.fetch),
|
|
137
|
+
maintain: inWalk(objects.maintain),
|
|
138
|
+
share: inWalk(objects.share),
|
|
139
|
+
read: (listed, input) => Effect.flatMap(readerOf(listed, input.listedOnly), (reader) => reader.read(input)),
|
|
140
|
+
sizes: (listed, input) => Effect.flatMap(readerOf(listed), (reader) => reader.sizes(input)),
|
|
141
|
+
headers: (listed, input) => Effect.flatMap(readerOf(listed), (reader) => reader.headers(input)),
|
|
142
|
+
held: (listed, input) => Effect.flatMap(readerOf(listed), (reader) => reader.held(input)),
|
|
143
|
+
objects: (listed, input) => Effect.flatMap(readerOf(listed, input.listedOnly), (reader) => reader.objects(input)),
|
|
144
|
+
allotment: (listed, most, refusal) => Effect.map(readerOf(listed), (reader) => reader.allotment(most, refusal))
|
|
145
|
+
};
|
|
146
|
+
});
|
|
147
|
+
/**
|
|
148
|
+
* `objects.receive` in the caller's scope: the answer's hold goes back when the scope closes, on
|
|
149
|
+
* success, failure and interrupt alike. The release is added before the receive starts, so an
|
|
150
|
+
* answer that comes after the scope closed, its fiber interrupted as the receive ran, is released
|
|
151
|
+
* as it comes.
|
|
152
|
+
*/
|
|
153
|
+
const scopedReceive = (objects, listed, input) => Effect.gen(function* () {
|
|
154
|
+
let closed = false;
|
|
155
|
+
let answer;
|
|
156
|
+
yield* Effect.addFinalizer(() => Effect.sync(() => {
|
|
157
|
+
closed = true;
|
|
158
|
+
answer?.allotment?.release();
|
|
159
|
+
}));
|
|
160
|
+
return yield* handedCall(input, (at) => objects.receive(listed, at).then((result) => {
|
|
161
|
+
if (result.kind === "error") return result;
|
|
162
|
+
if (closed) result.value.allotment?.release();
|
|
163
|
+
else answer = result.value;
|
|
164
|
+
return result;
|
|
165
|
+
}));
|
|
166
|
+
});
|
|
167
|
+
/**
|
|
168
|
+
* A server's opened objects, as Effects, for the core's calls, each handing on the request's
|
|
169
|
+
* count, which `packs()` takes back as it answers: so its calls count into the request's.
|
|
170
|
+
*/
|
|
171
|
+
const effectObjects = (objects) => ({
|
|
172
|
+
readyShallow: objects.readyShallow,
|
|
173
|
+
reader: (listed, input) => handedCall(input ?? {}, (at) => objects.reader(listed, at)),
|
|
174
|
+
pushedCommits: (listed, input) => handedCall(input, (at) => objects.pushedCommits(listed, at)),
|
|
175
|
+
receive: (listed, input) => handedCall(input, (at) => objects.receive(listed, at)),
|
|
176
|
+
fetch: (listed, input) => handedCall(input, (at) => objects.fetch(listed, at)),
|
|
177
|
+
maintain: (listed, input) => handedCall(input, (at) => objects.maintain(listed, at)),
|
|
178
|
+
share: (listed, input) => handedCall(input, (at) => objects.share(listed, at))
|
|
179
|
+
});
|
|
180
|
+
/**
|
|
181
|
+
* A bucket call, its refusal as Git's error. Anything else it throws is `UNAVAILABLE`. One of the
|
|
182
|
+
* two doors every call Git, and a package built on it, makes goes through, with `storeCall`: it
|
|
183
|
+
* counts into the request and the `CallBudget` in scope, and never starts past either's bound
|
|
184
|
+
* (Q799). `run` is handed the signal the fiber's interrupt aborts, which it passes to the bucket
|
|
185
|
+
* call as `CallOptions.signal`, so an interrupt or a deadline stops the call's requests and its
|
|
186
|
+
* store's retries.
|
|
187
|
+
*/
|
|
188
|
+
const bucketCall = (run) => Effect.andThen(chargeCall("bucket"), bucketTry(run));
|
|
189
|
+
/**
|
|
190
|
+
* Work on a bucket call already counted, its refusal as `bucketCall`'s: a streaming put's writes
|
|
191
|
+
* and its end, whose calls `bucketStart`'s charges counted first. Never a call of its own. `run`
|
|
192
|
+
* is handed the fiber's signal, as `bucketCall`'s is.
|
|
193
|
+
*/
|
|
194
|
+
const bucketTry = (run) => tryUnlessSpent(run, (cause) => isInfraError(cause) ? fromInfra(cause) : gitError("UNAVAILABLE", "The bucket failed", {
|
|
195
|
+
cause,
|
|
196
|
+
hint: "Try again"
|
|
197
|
+
}));
|
|
198
|
+
/**
|
|
199
|
+
* A put's `PutOptions.retrying`: each call its bucket sends again charged as one more bucket call
|
|
200
|
+
* in the put's own call scope, as it's sent, rejecting with the spent bound past it, so the
|
|
201
|
+
* bucket stops there and aborts within the `end` charged as the put started (Q829).
|
|
202
|
+
*/
|
|
203
|
+
const retryCharge = Effect.map(callScope, (scope) => () => runIn(chargeCalls("bucket", 1), scope));
|
|
204
|
+
/**
|
|
205
|
+
* The most calls a put of `bucket`'s with `options` makes: its own `multipart`'s, in parts of none
|
|
206
|
+
* past its size when it's told one, since the store then puts it whole. A smaller `atMost` changes
|
|
207
|
+
* nothing: a body within it fits one part either way, and one past it is refused at its first byte
|
|
208
|
+
* past.
|
|
209
|
+
*/
|
|
210
|
+
const putMultipart = (bucket, options) => options?.size === void 0 ? bucket.multipart : {
|
|
211
|
+
...bucket.multipart,
|
|
212
|
+
partSize: Number.POSITIVE_INFINITY
|
|
213
|
+
};
|
|
214
|
+
/** Why `multipart` can't count a put, or `undefined`: a part size above 0, and whole calls. */
|
|
215
|
+
const uncountable = ({ partSize, begin, end }) => {
|
|
216
|
+
if (partSize !== Number.POSITIVE_INFINITY && !(Number.isSafeInteger(partSize) && partSize > 0)) return `A bucket's multipart.partSize is a whole number of bytes above 0, not ${partSize}`;
|
|
217
|
+
return [begin, end].every((calls) => Number.isSafeInteger(calls) && calls >= 0) ? void 0 : `A bucket's multipart.begin and end are whole numbers of calls, not ${begin} and ${end}`;
|
|
218
|
+
};
|
|
219
|
+
/** `multipart`'s refusal as a defect when it can't count a put: a bucket's, never a caller's. */
|
|
220
|
+
const counting = (multipart) => Effect.suspend(() => {
|
|
221
|
+
const wrong = uncountable(multipart);
|
|
222
|
+
return wrong === void 0 ? Effect.void : Effect.die(new RangeError(wrong));
|
|
223
|
+
});
|
|
224
|
+
/**
|
|
225
|
+
* A streaming put of `bucket`'s with `options`, `start`'s, its calls charged as Q829 says: as it
|
|
226
|
+
* starts, its `multipart`'s `begin + end` and its first part, so it never starts past a bound, then
|
|
227
|
+
* each part past the first as the bytes written begin it. `end` covers its complete or its abort, so
|
|
228
|
+
* a put refused at a part that would pass a bound, none of that part charged, still ends what it
|
|
229
|
+
* began within it. Its writes and its end go through `bucketTry`.
|
|
230
|
+
*/
|
|
231
|
+
const bucketStart = (bucket, options, start) => Effect.gen(function* () {
|
|
232
|
+
const multipart = putMultipart(bucket, options);
|
|
233
|
+
const { partSize, begin, end } = multipart;
|
|
234
|
+
yield* counting(multipart);
|
|
235
|
+
yield* chargeCalls("bucket", begin + end + 1);
|
|
236
|
+
let parts = 1;
|
|
237
|
+
let sent = 0;
|
|
238
|
+
const upTo = (bytes) => {
|
|
239
|
+
const needed = Math.max(1, Math.ceil(bytes / partSize));
|
|
240
|
+
return needed <= parts ? Effect.void : Effect.map(chargeCalls("bucket", needed - parts), () => void (parts = needed));
|
|
241
|
+
};
|
|
242
|
+
return start({
|
|
243
|
+
sending: (bytes) => Effect.suspend(() => Effect.map(upTo(sent + bytes), () => void (sent += bytes))),
|
|
244
|
+
retrying: yield* retryCharge
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
/**
|
|
248
|
+
* The bucket's stream of `key`, its open interruptible: a stream that comes back after the call
|
|
249
|
+
* was interrupted, by its signal or its deadline, is cancelled, as no one will read it.
|
|
250
|
+
*/
|
|
251
|
+
const bucketStream = (bucket, key, signal) => {
|
|
252
|
+
let opening;
|
|
253
|
+
const late = Effect.sync(() => {
|
|
254
|
+
opening?.then((bytes) => bytes?.cancel(signal?.reason)).catch(() => void 0);
|
|
255
|
+
});
|
|
256
|
+
return bucketCall((fiber) => opening = bucket.read(key, void 0, { signal: fiber })).pipe(Effect.onInterrupt(() => late));
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* A put of `bucket`'s, one body it's told the size of, charged as `bucketStart` charges one of one
|
|
260
|
+
* part: its `multipart`'s `begin + end` and the part, and each call it sends again through the
|
|
261
|
+
* `retrying` `run` passes on. An interruption waits it out: a put left running could land after
|
|
262
|
+
* the push's clean-up deleted its key, leaving bytes no row names. So it takes no signal, and an
|
|
263
|
+
* interrupt or a deadline doesn't stop it: it ends when its store's own tries end. Aborting it
|
|
264
|
+
* wouldn't close that race, as a store may still land a request it already took.
|
|
265
|
+
*/
|
|
266
|
+
const bucketPut = (bucket, run) => Effect.uninterruptible(Effect.gen(function* () {
|
|
267
|
+
const { begin, end } = bucket.multipart;
|
|
268
|
+
yield* counting(bucket.multipart);
|
|
269
|
+
yield* chargeCalls("bucket", begin + end + 1);
|
|
270
|
+
const retrying = yield* retryCharge;
|
|
271
|
+
return yield* bucketTry(() => run(retrying));
|
|
272
|
+
}));
|
|
273
|
+
export { answerTo, bucketCall, bucketPut, bucketStart, bucketStream, bucketTry, cancelsBody, effectObjects, effectStore, handedCall, headersOnce, heldOnce, objectReader, objectsOnce, oneShotReads, readOnce, scopedReader, scopedReceive, sizesOnce, walkObjects };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { repoScope } from "../store/scopes.mjs";
|
|
2
|
+
import { bucketCall } from "./calls.mjs";
|
|
3
|
+
import { markerKey, markerPrefix, objectCollections, packFileKeys } from "./layout.mjs";
|
|
4
|
+
import { LeavingRow, QuarantineRow, decodeHeld, leavingKey, quarantineKey, quarantineRow } from "./rows.mjs";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
/**
|
|
7
|
+
* Rows one read of clean-up's asks for. Each row is under 100 bytes as JSON, so a page stays under
|
|
8
|
+
* 1 MiB, far below the 16 MiB a read may answer, however many rows the repo holds.
|
|
9
|
+
*/
|
|
10
|
+
const cleanPage = 1e4;
|
|
11
|
+
const deleteFiles = (bucket, pack) => Effect.forEach(packFileKeys(pack), (key) => bucketCall((signal) => bucket.delete(key, { signal })), { discard: true });
|
|
12
|
+
/** An abandoned `quarantine` row's pack: its marker, then its bytes. Its row goes after. */
|
|
13
|
+
const endQuarantine = (bucket, listed, pack) => Effect.gen(function* () {
|
|
14
|
+
yield* bucketCall((signal) => bucket.delete(markerKey(pack, listed.repo), { signal }));
|
|
15
|
+
yield* deleteFiles(bucket, pack);
|
|
16
|
+
return quarantineKey(pack);
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* A taken `leaving` row's pack: this repo's own marker first, then the bytes if no other marker is
|
|
20
|
+
* left. Listing first would let two repos letting go at once each keep the pack for the other.
|
|
21
|
+
*/
|
|
22
|
+
const endLeaving = (bucket, listed, pack) => Effect.gen(function* () {
|
|
23
|
+
yield* bucketCall((signal) => bucket.delete(markerKey(pack, listed.repo), { signal }));
|
|
24
|
+
if ((yield* bucketCall((signal) => bucket.list(markerPrefix(pack), { limit: 1 }, { signal }))).items.length === 0) yield* deleteFiles(bucket, pack);
|
|
25
|
+
return leavingKey(pack);
|
|
26
|
+
});
|
|
27
|
+
const sooner = (one, other) => one === void 0 ? other : Math.min(one, other);
|
|
28
|
+
/**
|
|
29
|
+
* `collection`'s rows from its first, a page at a time, until `enough` holds of the rows with work,
|
|
30
|
+
* which `isWork` picks, or none is left. Each step starts again from the first row, so no cursor
|
|
31
|
+
* is kept: rows a step ends are gone from the next one's pages.
|
|
32
|
+
*/
|
|
33
|
+
const scan = (store, scope, collection, schema, isWork, enough) => Effect.gen(function* () {
|
|
34
|
+
const work = [];
|
|
35
|
+
let later;
|
|
36
|
+
let held = false;
|
|
37
|
+
let after;
|
|
38
|
+
for (;;) {
|
|
39
|
+
const page = after === void 0 ? {} : { after };
|
|
40
|
+
const rows = (yield* store.read({
|
|
41
|
+
scope,
|
|
42
|
+
reads: [{
|
|
43
|
+
collection,
|
|
44
|
+
limit: 1e4,
|
|
45
|
+
...page
|
|
46
|
+
}]
|
|
47
|
+
})).results[0] ?? [];
|
|
48
|
+
held ||= rows.length > 0;
|
|
49
|
+
for (const row of rows) {
|
|
50
|
+
const one = yield* decodeHeld(schema, row);
|
|
51
|
+
if (isWork(one)) work.push(one);
|
|
52
|
+
else later = sooner(later, one.value.removeAt);
|
|
53
|
+
}
|
|
54
|
+
const last = rows.at(-1);
|
|
55
|
+
if (rows.length < 1e4 || last === void 0) return {
|
|
56
|
+
held,
|
|
57
|
+
work,
|
|
58
|
+
later,
|
|
59
|
+
whole: true
|
|
60
|
+
};
|
|
61
|
+
if (enough(work)) return {
|
|
62
|
+
held,
|
|
63
|
+
work,
|
|
64
|
+
later,
|
|
65
|
+
whole: false
|
|
66
|
+
};
|
|
67
|
+
after = last.id;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
/**
|
|
71
|
+
* `git.repack`'s clean-up of a repo's `quarantine` and `leaving` rows whose `removeAt` has passed,
|
|
72
|
+
* as one step whose change the core commits:
|
|
73
|
+
* - an open `quarantine` row is committed abandoned first, so its writer's listing is refused;
|
|
74
|
+
* - an abandoned one has its marker and bytes deleted, then its row;
|
|
75
|
+
* - a `leaving` row is committed taken first, so a sync's or a fetch's listing is refused (#394);
|
|
76
|
+
* - a taken one deletes its own marker, then the bytes if no marker is left, then its row.
|
|
77
|
+
* Bucket deletes come before the commit that drops their row, so a cut step leaves the row to do
|
|
78
|
+
* them again. It reads each collection a page at a time, and stops once it has more than a batch
|
|
79
|
+
* of one kind, so `more` holds; `due` is the earliest of the rows left only once it read them all.
|
|
80
|
+
* `undefined` when the repo holds neither kind of row.
|
|
81
|
+
*/
|
|
82
|
+
const cleanUp = Effect.fnUntraced(function* (input) {
|
|
83
|
+
const { store, bucket, listed, at } = input;
|
|
84
|
+
const scope = repoScope(listed.repo);
|
|
85
|
+
const isDue = (row) => row.value.removeAt <= at;
|
|
86
|
+
const isAbandoned = (row) => row.value.state === "abandoned";
|
|
87
|
+
const isTaken = (row) => row.value.taken === true;
|
|
88
|
+
const pastBatch = (rows) => rows.length > 25;
|
|
89
|
+
const quarantined = yield* scan(store, scope, objectCollections.quarantine, QuarantineRow, (row) => isAbandoned(row) || isDue(row), (work) => pastBatch(work.filter(isAbandoned)) || pastBatch(work.filter((row) => !isAbandoned(row))));
|
|
90
|
+
const leaving = yield* scan(store, scope, objectCollections.leaving, LeavingRow, (row) => isTaken(row) || isDue(row), (work) => pastBatch(work.filter(isTaken)) || pastBatch(work.filter((row) => !isTaken(row))));
|
|
91
|
+
if (!quarantined.held && !leaving.held) return void 0;
|
|
92
|
+
const abandoned = quarantined.work.filter(isAbandoned);
|
|
93
|
+
const toEnd = abandoned.slice(0, 25);
|
|
94
|
+
const toAbandon = quarantined.work.filter((row) => !isAbandoned(row)).slice(0, 25);
|
|
95
|
+
const taken = leaving.work.filter(isTaken);
|
|
96
|
+
const toLeave = taken.slice(0, 25);
|
|
97
|
+
const toTake = leaving.work.filter((row) => !isTaken(row)).slice(0, 25);
|
|
98
|
+
const ended = [...yield* Effect.forEach(toEnd, (row) => endQuarantine(bucket, listed, row.pack)), ...yield* Effect.forEach(toLeave, (row) => endLeaving(bucket, listed, row.pack))];
|
|
99
|
+
const put = [...toAbandon.map((row) => quarantineRow(row.pack, {
|
|
100
|
+
...row.value,
|
|
101
|
+
state: "abandoned"
|
|
102
|
+
})), ...toTake.map((row) => ({
|
|
103
|
+
...leavingKey(row.pack),
|
|
104
|
+
value: {
|
|
105
|
+
...row.value,
|
|
106
|
+
taken: true
|
|
107
|
+
}
|
|
108
|
+
}))];
|
|
109
|
+
const more = toAbandon.length > 0 || abandoned.length > toEnd.length || toTake.length > 0 || taken.length > toLeave.length;
|
|
110
|
+
const step = {
|
|
111
|
+
change: {
|
|
112
|
+
put,
|
|
113
|
+
delete: ended
|
|
114
|
+
},
|
|
115
|
+
more
|
|
116
|
+
};
|
|
117
|
+
const whole = quarantined.whole && leaving.whole;
|
|
118
|
+
const later = quarantined.later === void 0 ? leaving.later : sooner(leaving.later, quarantined.later);
|
|
119
|
+
return !whole || later === void 0 ? step : {
|
|
120
|
+
...step,
|
|
121
|
+
due: later
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
export { cleanPage, cleanUp };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { hashOf, keyed, scrambled } from "./held-memo.mjs";
|
|
2
|
+
// src/storage/distinct-ids.ts
|
|
3
|
+
/** A hash's high bits pick its register: 4,096 of them, a byte each. */
|
|
4
|
+
const registerBits = 12;
|
|
5
|
+
const registers = 2 ** registerBits;
|
|
6
|
+
/** HyperLogLog's correction for its harmonic mean, at this many registers. */
|
|
7
|
+
const alpha = .7213 / 1.000263427734375;
|
|
8
|
+
/**
|
|
9
|
+
* A HyperLogLog of the IDs added, hashed by the push's `mix`, which a pusher can't know, then
|
|
10
|
+
* scrambled once more. The memo's slot is its hash's high bits, so the IDs it misses and asks of
|
|
11
|
+
* again share them, and would share registers too: scrambled, they land in any. A
|
|
12
|
+
* high estimate raises the push's limit, and to raise it a pusher would choose IDs whose hashes
|
|
13
|
+
* lead with zeros, which it can't do without the mix. Each register keeps the most leading
|
|
14
|
+
* zeros of the hashes it's given, plus one, so another link to an ID changes nothing.
|
|
15
|
+
*/
|
|
16
|
+
const distinctIds = (mix) => {
|
|
17
|
+
const ranks = new Uint8Array(registers);
|
|
18
|
+
const key = /* @__PURE__ */ new Uint8Array(20);
|
|
19
|
+
return {
|
|
20
|
+
add: (oid) => {
|
|
21
|
+
if (!keyed(oid, key)) return;
|
|
22
|
+
const hash = scrambled(hashOf(key, 0, mix));
|
|
23
|
+
const register = hash >>> 20;
|
|
24
|
+
const rank = Math.min(Math.clz32(hash << registerBits), 20) + 1;
|
|
25
|
+
if (rank > (ranks[register] ?? 0)) ranks[register] = rank;
|
|
26
|
+
},
|
|
27
|
+
estimate: () => {
|
|
28
|
+
let sum = 0;
|
|
29
|
+
let empty = 0;
|
|
30
|
+
for (const rank of ranks) {
|
|
31
|
+
sum += 2 ** -rank;
|
|
32
|
+
if (rank === 0) empty += 1;
|
|
33
|
+
}
|
|
34
|
+
const raw = alpha * registers * registers / sum;
|
|
35
|
+
return raw <= 2.5 * registers && empty > 0 ? registers * Math.log(registers / empty) : raw;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export { distinctIds };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// src/storage/ewah.ts
|
|
2
|
+
/**
|
|
3
|
+
* EWAH over 32-bit words, as the index's bitmaps are kept: a bitmap's words as runs of clean
|
|
4
|
+
* words, all zeros or all ones, each followed by the dirty words after it as they are. Each run
|
|
5
|
+
* starts with a marker word: bit 31 its running bit, bits 16–30 how many dirty words follow it,
|
|
6
|
+
* at most 32,767, and bits 0–15 how many clean words it stands for, at most 65,535. Bit `p` of a
|
|
7
|
+
* bitmap is bit `p % 32` of word `p / 32`, the low bit first.
|
|
8
|
+
*/
|
|
9
|
+
const mostRun = 65535;
|
|
10
|
+
const mostDirty = 32767;
|
|
11
|
+
const ones = 4294967295;
|
|
12
|
+
/** How many words a bitmap of `bits` takes. */
|
|
13
|
+
const bitmapWords = (bits) => Math.ceil(bits / 32);
|
|
14
|
+
/**
|
|
15
|
+
* `words` as EWAH, in two passes: the first counts its words, so the second writes them into an
|
|
16
|
+
* array of just that length, with no growth and no copy.
|
|
17
|
+
*/
|
|
18
|
+
const ewahOf = (words) => {
|
|
19
|
+
let length = 0;
|
|
20
|
+
eachEwahWord(words, () => {
|
|
21
|
+
length += 1;
|
|
22
|
+
});
|
|
23
|
+
const out = new Uint32Array(length);
|
|
24
|
+
let at = 0;
|
|
25
|
+
eachEwahWord(words, (word) => {
|
|
26
|
+
out[at] = word;
|
|
27
|
+
at += 1;
|
|
28
|
+
});
|
|
29
|
+
return out;
|
|
30
|
+
};
|
|
31
|
+
/** Each word of `words`' EWAH, in order. */
|
|
32
|
+
const eachEwahWord = (words, push) => {
|
|
33
|
+
for (let at = 0; at < words.length;) {
|
|
34
|
+
const running = words[at] === ones ? 1 : 0;
|
|
35
|
+
const clean = running === 1 ? ones : 0;
|
|
36
|
+
let run = 0;
|
|
37
|
+
while (at < words.length && words[at] === clean && run < mostRun) {
|
|
38
|
+
run += 1;
|
|
39
|
+
at += 1;
|
|
40
|
+
}
|
|
41
|
+
const from = at;
|
|
42
|
+
while (at < words.length && words[at] !== 0 && words[at] !== ones && at - from < 32767) at += 1;
|
|
43
|
+
push((running << 31 | at - from << 16 | run) >>> 0);
|
|
44
|
+
for (let dirty = from; dirty < at; dirty += 1) push(words[dirty] ?? 0);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* `ewah` ORed into `into`, a bitmap of as many words as it stands for: whether it did, so an
|
|
49
|
+
* EWAH of another length, or cut short, is never half read as whole.
|
|
50
|
+
*/
|
|
51
|
+
const orEwah = (ewah, into) => {
|
|
52
|
+
let word = 0;
|
|
53
|
+
for (let at = 0; at < ewah.length;) {
|
|
54
|
+
const marker = ewah[at] ?? 0;
|
|
55
|
+
const run = marker & mostRun;
|
|
56
|
+
const dirty = marker >>> 16 & mostDirty;
|
|
57
|
+
at += 1;
|
|
58
|
+
if (word + run + dirty > into.length || at + dirty > ewah.length) return false;
|
|
59
|
+
if (marker >>> 31 === 1) into.fill(ones, word, word + run);
|
|
60
|
+
word += run;
|
|
61
|
+
for (let each = 0; each < dirty; each += 1) {
|
|
62
|
+
into[word] = ((into[word] ?? 0) | (ewah[at] ?? 0)) >>> 0;
|
|
63
|
+
word += 1;
|
|
64
|
+
at += 1;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return word === into.length;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* How many words `ewah` stands for, and its last one, read from its markers alone with no bitmap
|
|
71
|
+
* made, or `undefined` when a marker runs past it. A reader checks a bitmap's length and spare
|
|
72
|
+
* bits with it before it ORs it into a larger one.
|
|
73
|
+
*/
|
|
74
|
+
const ewahExtent = (ewah) => {
|
|
75
|
+
let words = 0;
|
|
76
|
+
let last = 0;
|
|
77
|
+
for (let at = 0; at < ewah.length;) {
|
|
78
|
+
const marker = ewah[at] ?? 0;
|
|
79
|
+
const run = marker & mostRun;
|
|
80
|
+
const dirty = marker >>> 16 & mostDirty;
|
|
81
|
+
at += 1 + dirty;
|
|
82
|
+
if (at > ewah.length) return void 0;
|
|
83
|
+
words += run + dirty;
|
|
84
|
+
if (dirty > 0) last = ewah[at - 1] ?? 0;
|
|
85
|
+
else if (run > 0) last = marker >>> 31 === 1 ? ones : 0;
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
words,
|
|
89
|
+
last
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
/** `ewah`'s bitmap of `words` words, or `undefined` when it isn't one of that length. */
|
|
93
|
+
const bitmapOf = (ewah, words) => {
|
|
94
|
+
const into = new Uint32Array(words);
|
|
95
|
+
return orEwah(ewah, into) ? into : void 0;
|
|
96
|
+
};
|
|
97
|
+
export { bitmapOf, bitmapWords, ewahExtent, ewahOf, mostDirty, orEwah };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import "../protocol/packs/writer.mjs";
|
|
2
|
+
import "../protocol/bytes/buffers.mjs";
|
|
3
|
+
import "../protocol/bytes/deflate.mjs";
|
|
4
|
+
import "../protocol.mjs";
|
|
5
|
+
import "../contracts/objects.mjs";
|
|
6
|
+
import "../contracts/calls-spent.mjs";
|
|
7
|
+
import "../store/call-count.mjs";
|
|
8
|
+
import "./object-rows.mjs";
|
|
9
|
+
import "./pack-reads.mjs";
|
|
10
|
+
import "./index-fetch.mjs";
|
|
11
|
+
import "./shallow.mjs";
|
|
12
|
+
import "./walk.mjs";
|
|
13
|
+
import "effect/Effect";
|