@ref0/git 0.0.0 → 0.3.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 +50 -0
- package/dist/client/git-http.mjs +201 -0
- package/dist/client/helper-node.mjs +19 -0
- package/dist/client/local.mjs +170 -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 +151 -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 +11 -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 +38 -0
- package/dist/contracts/promises.mjs +13 -0
- package/dist/contracts/push-uploads.d.mts +44 -0
- package/dist/contracts/queue.d.mts +402 -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 +133 -0
- package/dist/contracts/result.mjs +34 -0
- package/dist/contracts/rules.d.mts +159 -0
- package/dist/contracts/server.d.mts +272 -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 +180 -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/call-names.d.mts +1 -0
- package/dist/core/call-names.mjs +93 -0
- package/dist/core/clock.mjs +18 -0
- package/dist/core/events/deliver.mjs +475 -0
- package/dist/core/events/stream.d.mts +19 -0
- package/dist/core/events/stream.mjs +297 -0
- package/dist/core/forks.mjs +1027 -0
- package/dist/core/hooks/post-receive.mjs +212 -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 +64 -0
- package/dist/core/publish.mjs +142 -0
- package/dist/core/push-decide.mjs +206 -0
- package/dist/core/push.mjs +1070 -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 +26 -0
- package/dist/core/seam.mjs +54 -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 +4 -0
- package/dist/extend.mjs +3 -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 +1037 -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 +18 -0
- package/dist/rest/handler.mjs +129 -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 +17 -0
- package/dist/server/extension.mjs +93 -0
- package/dist/server/lifecycle.d.mts +3 -0
- package/dist/server/lifecycle.mjs +89 -0
- package/dist/server/routes.d.mts +28 -0
- package/dist/server/routes.mjs +60 -0
- package/dist/server/server.d.mts +8 -0
- package/dist/server/server.mjs +615 -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/bits.mjs +41 -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 +15 -0
- package/dist/storage/fetch.mjs +998 -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 +1447 -0
- package/dist/storage/index-fetch.d.mts +10 -0
- package/dist/storage/index-fetch.mjs +677 -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 +121 -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 +781 -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 +1007 -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 +603 -0
- package/dist/storage/prune.mjs +506 -0
- package/dist/storage/push-allotment.mjs +109 -0
- package/dist/storage/push-uploads.mjs +152 -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 +4 -0
- package/dist/storage/rows.mjs +71 -0
- package/dist/storage/send-list.d.mts +8 -0
- package/dist/storage/send-list.mjs +319 -0
- package/dist/storage/shallow.d.mts +4 -0
- package/dist/storage/shallow.mjs +128 -0
- package/dist/storage/stream-whole.mjs +236 -0
- package/dist/storage/unpack.mjs +238 -0
- package/dist/storage/visible.mjs +137 -0
- package/dist/storage/walk.d.mts +8 -0
- package/dist/storage/walk.mjs +176 -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/closed.d.mts +21 -0
- package/dist/store/closed.mjs +34 -0
- package/dist/store/crossing.mjs +69 -0
- package/dist/store/cursor-seal.d.mts +2 -0
- package/dist/store/cursor-seal.mjs +88 -0
- package/dist/store/errors.d.mts +12 -0
- package/dist/store/errors.mjs +135 -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 +297 -0
- package/dist/store/promises.d.mts +5 -0
- package/dist/store/promises.mjs +258 -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 +34 -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 +83 -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 +555 -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 +141 -0
- package/package.json +86 -5
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import "../index.mjs";
|
|
2
|
+
import "./pack-reads.mjs";
|
|
3
|
+
import "../protocol.mjs";
|
|
4
|
+
import "../contracts/promises.mjs";
|
|
5
|
+
import "../contracts/objects.mjs";
|
|
6
|
+
import { RepoStats } from "../contracts/repos.mjs";
|
|
7
|
+
import "../contracts/services.mjs";
|
|
8
|
+
import "../contracts/store.mjs";
|
|
9
|
+
import "./index-remap.mjs";
|
|
10
|
+
import "./object-rows.mjs";
|
|
11
|
+
import "./rows.mjs";
|
|
12
|
+
import { Key, Moment, Row } from "@ref0/infra";
|
|
13
|
+
import "effect/Effect";
|
|
14
|
+
import "effect/Types";
|
|
15
|
+
/**
|
|
16
|
+
* How `packs()` merges a repo's packs: as Git's `repack --geometric=<geometric>`, by object
|
|
17
|
+
* count, so each pack holds at least `geometric` times the objects of all smaller ones together;
|
|
18
|
+
* no merged pack past `maxPackSize` bytes.
|
|
19
|
+
*/
|
|
20
|
+
export interface RepackOptions {
|
|
21
|
+
readonly geometric: number;
|
|
22
|
+
readonly maxPackSize?: number;
|
|
23
|
+
/**
|
|
24
|
+
* The most CPU a merge's remap of the reachability index may forecast, in ms: 30 s, 10% of a
|
|
25
|
+
* Worker's 300 s `cpu_ms`, unless set. Past it, the merge commits without the remap, and the
|
|
26
|
+
* next `git.index` builds again.
|
|
27
|
+
*/
|
|
28
|
+
readonly remapCpuMost?: number;
|
|
29
|
+
}
|
|
30
|
+
/** An option as a value, `false` for none, or chosen from the repo's stats each time it's used. */
|
|
31
|
+
export type Option<T> = T | false | ((stats: RepoStats) => T | false);
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { fixedRoom } from "../protocol/packs/indexer.mjs";
|
|
2
|
+
import { repoScope } from "../store/scopes.mjs";
|
|
3
|
+
import { remapRow } from "./index-remap.mjs";
|
|
4
|
+
import { isPackId, objectCollections } from "./layout.mjs";
|
|
5
|
+
import { writeMerged } from "./merge.mjs";
|
|
6
|
+
import { largeBatch, objectKey, objectOfRow, tooLargeRead } from "./object-rows.mjs";
|
|
7
|
+
import { PackBlocks, blockBytes, blockHeld } from "./pack-reads.mjs";
|
|
8
|
+
import { leavingRow, pruneFloor } from "./rows.mjs";
|
|
9
|
+
import { limits } from "@ref0/infra";
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
import * as Predicate from "effect/Predicate";
|
|
12
|
+
// src/storage/repack.ts
|
|
13
|
+
/** Git's `repack.geometric` of 2, and no pack past 1 GiB. */
|
|
14
|
+
const defaultRepack = {
|
|
15
|
+
geometric: 2,
|
|
16
|
+
maxPackSize: 1024 ** 3
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* `option` for a repo with `stats`, `fallback` when the host set none. A caller that read no
|
|
20
|
+
* stats, as none of its options is a function, gets `fallback` for one that is.
|
|
21
|
+
*/
|
|
22
|
+
const optionFor = (option, fallback, stats) => {
|
|
23
|
+
if (option === void 0) return fallback;
|
|
24
|
+
if (!Predicate.isFunction(option)) return option;
|
|
25
|
+
return stats === void 0 ? fallback : option(stats);
|
|
26
|
+
};
|
|
27
|
+
/** The object rows one step folds at most: the rest wait for the steps after it. */
|
|
28
|
+
const foldedRows = 1e3;
|
|
29
|
+
/**
|
|
30
|
+
* A step's commit writes, of the store's 10,000, its group's take at most: two for each pack it
|
|
31
|
+
* merges, its row's delete and its `leaving` row, and one for each object row it folds. The rest
|
|
32
|
+
* are the core's, for the receipts' sweep and the run's events.
|
|
33
|
+
*/
|
|
34
|
+
const groupWrites = limits.writes / 2;
|
|
35
|
+
/**
|
|
36
|
+
* The objects one merge takes at most. It holds each input's index and an entry for each object
|
|
37
|
+
* while it writes, so a Worker's 128 MiB holds them all.
|
|
38
|
+
*/
|
|
39
|
+
const groupObjects = 2e5;
|
|
40
|
+
/**
|
|
41
|
+
* The repo's object rows, a small push's each, which a merge folds into its pack: the first
|
|
42
|
+
* `foldedRows` of them, or as many of the largest as one read's 16 MiB answer holds. They're
|
|
43
|
+
* `whole` when the read came back short of its limit.
|
|
44
|
+
*/
|
|
45
|
+
const readObjectRows = Effect.fnUntraced(function* (input) {
|
|
46
|
+
const scope = repoScope(input.listed.repo);
|
|
47
|
+
const page = (limit) => Effect.map(input.store.read({
|
|
48
|
+
scope,
|
|
49
|
+
reads: [{
|
|
50
|
+
collection: objectCollections.objects,
|
|
51
|
+
limit
|
|
52
|
+
}]
|
|
53
|
+
}), (snapshot) => {
|
|
54
|
+
const rows = snapshot.results[0] ?? [];
|
|
55
|
+
return {
|
|
56
|
+
rows,
|
|
57
|
+
whole: rows.length < limit
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
return yield* page(foldedRows).pipe(Effect.catchIf(tooLargeRead, () => page(largeBatch)));
|
|
61
|
+
});
|
|
62
|
+
/** Each object row, read whole. */
|
|
63
|
+
const wholeRows = (rows) => Effect.forEach(rows, (row) => objectOfRow(row));
|
|
64
|
+
/** The bytes a row's value takes, as JSON writes it. */
|
|
65
|
+
const rowsBytes = (rows) => rows.reduce((sum, row) => sum + JSON.stringify(row.value).length, 0);
|
|
66
|
+
const namedOf = (pack) => isPackId(pack.id) ? Effect.succeed({
|
|
67
|
+
...pack,
|
|
68
|
+
id: pack.id
|
|
69
|
+
}) : Effect.die(/* @__PURE__ */ new Error(`The pack row '${pack.id}' doesn't name a pack`));
|
|
70
|
+
const loadAll = (input, packs) => Effect.forEach(packs, (pack) => input.indexes.load(input.bucket, pack));
|
|
71
|
+
/** What `writeMerged` takes beside its inputs, for one step. */
|
|
72
|
+
const writeParts = (input) => ({
|
|
73
|
+
store: input.store,
|
|
74
|
+
bucket: input.bucket,
|
|
75
|
+
blocks: new PackBlocks(input.bucket, fixedRoom(8 * blockHeld(blockBytes))),
|
|
76
|
+
repo: input.listed.repo,
|
|
77
|
+
at: input.at,
|
|
78
|
+
prune: input.quarantine
|
|
79
|
+
});
|
|
80
|
+
/** A removed pack's `leaving` row: a fetch still reading it ends first, and never under an hour. */
|
|
81
|
+
const leavingRows = (input, removed) => {
|
|
82
|
+
const removeAt = input.at + Math.max(pruneFloor, input.fetchLimits.milliseconds);
|
|
83
|
+
return removed.map((pack) => leavingRow(pack, removeAt));
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* The change that lists `merged` in place of `removed` and of the folded object `rows`: each
|
|
87
|
+
* removed pack a `leaving` row, and the merged pack's `quarantine` row ended in the same commit.
|
|
88
|
+
*/
|
|
89
|
+
const replacing = (input, merged, removed, rows) => ({
|
|
90
|
+
add: [merged.pack],
|
|
91
|
+
remove: removed.map((pack) => pack.id),
|
|
92
|
+
put: leavingRows(input, removed),
|
|
93
|
+
delete: [merged.quarantine, ...rows.map((row) => objectKey(row.oid))]
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* The members a geometric repack merges, smallest first: Git's `split_pack_geometry`, those
|
|
97
|
+
* below the first pack that holds `factor` times every smaller one's objects together, then
|
|
98
|
+
* rolled up while the next is under `factor` times their total. Capped, smallest first, at
|
|
99
|
+
* `maxPackSize` bytes, `groupObjects` objects and `groupWrites` of a commit's writes; fewer than
|
|
100
|
+
* two merge nothing.
|
|
101
|
+
*/
|
|
102
|
+
const geometricGroup = (members, options) => {
|
|
103
|
+
const sorted = [...members].sort((a, b) => a.objects - b.objects);
|
|
104
|
+
const factor = options.geometric;
|
|
105
|
+
let split = sorted.length - 1;
|
|
106
|
+
for (; split > 0; split -= 1) if ((sorted[split]?.objects ?? 0) < factor * (sorted[split - 1]?.objects ?? 0)) break;
|
|
107
|
+
if (split > 0) split += 1;
|
|
108
|
+
let total = sorted.slice(0, split).reduce((sum, member) => sum + member.objects, 0);
|
|
109
|
+
for (; split < sorted.length; split += 1) {
|
|
110
|
+
const ours = sorted[split]?.objects ?? 0;
|
|
111
|
+
if (ours >= factor * total) break;
|
|
112
|
+
total += ours;
|
|
113
|
+
}
|
|
114
|
+
const most = options.maxPackSize ?? defaultRepack.maxPackSize;
|
|
115
|
+
const group = [];
|
|
116
|
+
const taken = {
|
|
117
|
+
bytes: 0,
|
|
118
|
+
objects: 0,
|
|
119
|
+
writes: 0
|
|
120
|
+
};
|
|
121
|
+
for (const member of sorted.slice(0, split)) {
|
|
122
|
+
if (taken.bytes + member.bytes > most) break;
|
|
123
|
+
if (taken.objects + member.objects > 2e5) break;
|
|
124
|
+
if (taken.writes + member.writes > groupWrites) break;
|
|
125
|
+
group.push(member);
|
|
126
|
+
taken.bytes += member.bytes;
|
|
127
|
+
taken.objects += member.objects;
|
|
128
|
+
taken.writes += member.writes;
|
|
129
|
+
}
|
|
130
|
+
return group.length < 2 ? [] : group;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* One geometric step: the group `geometricGroup` picks among the listed packs but `kept`, with
|
|
134
|
+
* the object rows as one member, merged into one pack under its own `quarantine` row.
|
|
135
|
+
* `undefined` when the repo's packs already make a progression, or when no group of two fits in
|
|
136
|
+
* `maxPackSize` once merged.
|
|
137
|
+
*/
|
|
138
|
+
const geometricStep = Effect.fnUntraced(function* (input, options, objectRows, kept = () => false, remap) {
|
|
139
|
+
const members = [...input.listed.packs.filter((pack) => !kept(pack)).map((pack) => ({
|
|
140
|
+
kind: "pack",
|
|
141
|
+
pack,
|
|
142
|
+
objects: pack.objects,
|
|
143
|
+
bytes: pack.bytes,
|
|
144
|
+
writes: 2
|
|
145
|
+
})), ...objectRows.length === 0 ? [] : [{
|
|
146
|
+
kind: "rows",
|
|
147
|
+
objects: objectRows.length,
|
|
148
|
+
bytes: rowsBytes(objectRows),
|
|
149
|
+
writes: objectRows.length
|
|
150
|
+
}]];
|
|
151
|
+
const most = options.maxPackSize ?? defaultRepack.maxPackSize;
|
|
152
|
+
for (let group = geometricGroup(members, options); group.length >= 2; group = group.slice(0, Math.ceil(group.length / 2))) {
|
|
153
|
+
const chosen = new Set(group.flatMap((member) => member.kind === "pack" ? [member.pack] : []));
|
|
154
|
+
const packs = input.listed.packs.filter((pack) => chosen.has(pack));
|
|
155
|
+
const rows = group.some((member) => member.kind === "rows") ? yield* wholeRows(objectRows) : [];
|
|
156
|
+
const merged = yield* writeMerged({
|
|
157
|
+
...writeParts(input),
|
|
158
|
+
inputs: yield* loadAll(input, packs),
|
|
159
|
+
rows,
|
|
160
|
+
most
|
|
161
|
+
});
|
|
162
|
+
if (merged === "too big") continue;
|
|
163
|
+
if (merged === void 0) return void 0;
|
|
164
|
+
const removed = yield* Effect.forEach(packs, namedOf);
|
|
165
|
+
const step = {
|
|
166
|
+
change: replacing(input, merged, removed, rows),
|
|
167
|
+
more: true,
|
|
168
|
+
quarantine: merged.quarantine
|
|
169
|
+
};
|
|
170
|
+
const index = remap === void 0 ? void 0 : yield* remapRow(remap, {
|
|
171
|
+
bucket: input.bucket,
|
|
172
|
+
listed: input.listed,
|
|
173
|
+
merged,
|
|
174
|
+
taken: new Set(packs.map((pack) => pack.id)),
|
|
175
|
+
folded: rows.map((row) => row.oid),
|
|
176
|
+
at: input.at
|
|
177
|
+
});
|
|
178
|
+
if (index !== void 0) step.index = index;
|
|
179
|
+
return step;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
export { defaultRepack, foldedRows, geometricGroup, geometricStep, groupObjects, groupWrites, leavingRows, loadAll, namedOf, optionFor, readObjectRows, replacing, rowsBytes, wholeRows, writeParts };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import "../contracts/objects.mjs";
|
|
2
|
+
import "../protocol/objects/object.mjs";
|
|
3
|
+
import { linksOf } from "./links.mjs";
|
|
4
|
+
import * as Result from "effect/Result";
|
|
5
|
+
// src/storage/roots.ts
|
|
6
|
+
/**
|
|
7
|
+
* Of a receive's objects, in `oids`, those `named` says none of the others names: its roots. Links
|
|
8
|
+
* form no cycle, so a chain of namers up from any of its objects ends at a root, and once every
|
|
9
|
+
* root is a tip the push moves a ref to, a ref reaches each object it carries. `undefined` past
|
|
10
|
+
* `receivedRootsMost`, which proves nothing. `named` may miss a link, never invent one: a root it
|
|
11
|
+
* shows too many only fails to prove the objects reached (#647).
|
|
12
|
+
*/
|
|
13
|
+
const rootsOf = (oids, named) => {
|
|
14
|
+
const roots = [];
|
|
15
|
+
for (const oid of oids) {
|
|
16
|
+
if (named(oid)) continue;
|
|
17
|
+
if (roots.length === 4e3) return void 0;
|
|
18
|
+
roots.push(oid);
|
|
19
|
+
}
|
|
20
|
+
return roots;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Of whole objects, a small push's rows, their links read again: their roots, and each object they
|
|
24
|
+
* name outside them but the empty tree, which the repo needn't store. `undefined` past the most
|
|
25
|
+
* roots, which proves nothing.
|
|
26
|
+
*/
|
|
27
|
+
const wholeRoots = (objects) => {
|
|
28
|
+
const named = /* @__PURE__ */ new Set();
|
|
29
|
+
for (const object of objects) {
|
|
30
|
+
const links = linksOf(object);
|
|
31
|
+
if (Result.isFailure(links)) return void 0;
|
|
32
|
+
for (const link of links.success) named.add(link.oid);
|
|
33
|
+
}
|
|
34
|
+
const own = new Set(objects.map(({ oid }) => oid));
|
|
35
|
+
const roots = rootsOf(own, (oid) => named.has(oid));
|
|
36
|
+
if (roots === void 0) return void 0;
|
|
37
|
+
return {
|
|
38
|
+
roots,
|
|
39
|
+
outside: [...named].filter((oid) => !own.has(oid) && oid !== "4b825dc642cb6eb9a060e54bf8d69288fbee4904")
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export { rootsOf, wholeRoots };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { millis } from "../contracts/promises.mjs";
|
|
2
|
+
import { decodeRow, fail } from "../store/errors.mjs";
|
|
3
|
+
import { isPackId, objectCollections } from "./layout.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
// src/storage/rows.ts
|
|
7
|
+
/**
|
|
8
|
+
* A pack being written, added before its first byte. `open` while its writer may still list it;
|
|
9
|
+
* `abandoned` once its `removeAt` has passed and clean-up committed it so, which refuses a late
|
|
10
|
+
* writer's listing commit.
|
|
11
|
+
*/
|
|
12
|
+
const QuarantineRow = Schema.Struct({
|
|
13
|
+
removeAt: Schema.Int,
|
|
14
|
+
state: Schema.Literals(["open", "abandoned"])
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* A pack this repo's list no longer names, its marker and bytes kept until `removeAt`, with the
|
|
18
|
+
* size its list gave. A deleted repo's are `deleted`, so a read that holds an older list still
|
|
19
|
+
* finds an object moved into one. A step's never are: its merged pack is listed with what its
|
|
20
|
+
* inputs held, but a pass's dropped objects, which no read may find. `taken` once clean-up has
|
|
21
|
+
* committed it so, before it deletes the marker, which refuses a late sync's or fetch's listing.
|
|
22
|
+
*/
|
|
23
|
+
const LeavingRow = Schema.Struct({
|
|
24
|
+
removeAt: Schema.Int,
|
|
25
|
+
objects: Schema.Int,
|
|
26
|
+
bytes: Schema.Int,
|
|
27
|
+
deleted: Schema.optional(Schema.Literal(true)),
|
|
28
|
+
taken: Schema.optional(Schema.Literal(true))
|
|
29
|
+
});
|
|
30
|
+
const quarantineKey = (pack) => ({
|
|
31
|
+
collection: objectCollections.quarantine,
|
|
32
|
+
id: pack
|
|
33
|
+
});
|
|
34
|
+
const leavingKey = (pack) => ({
|
|
35
|
+
collection: objectCollections.leaving,
|
|
36
|
+
id: pack
|
|
37
|
+
});
|
|
38
|
+
const quarantineRow = (pack, value) => ({
|
|
39
|
+
...quarantineKey(pack),
|
|
40
|
+
value
|
|
41
|
+
});
|
|
42
|
+
const leavingRow = (pack, removeAt, { deleted = false } = {}) => {
|
|
43
|
+
const value = {
|
|
44
|
+
removeAt,
|
|
45
|
+
objects: pack.objects,
|
|
46
|
+
bytes: pack.bytes
|
|
47
|
+
};
|
|
48
|
+
if (deleted) value.deleted = true;
|
|
49
|
+
return {
|
|
50
|
+
...leavingKey(pack.id),
|
|
51
|
+
value
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/** `prune`'s floor, and `fetchLimits`' time's: no server waits less than an hour for either. */
|
|
55
|
+
const pruneFloor = millis("1 hour");
|
|
56
|
+
const defaultPrune = "14 days";
|
|
57
|
+
/** How long `prune` waits, in milliseconds: never under an hour. */
|
|
58
|
+
const pruneWait = (prune) => Math.max(millis(prune), pruneFloor);
|
|
59
|
+
/** When a row written at `at` is due, from `prune` as it is now. */
|
|
60
|
+
const removeAt = (at, prune) => at + pruneWait(prune);
|
|
61
|
+
/** A stored row as `schema`, keyed by a pack's ID; anything else is `DATA_LOSS`. */
|
|
62
|
+
const decodeHeld = (schema, row) => {
|
|
63
|
+
const what = `The ${row.collection} row '${row.id}'`;
|
|
64
|
+
if (!isPackId(row.id)) return fail("DATA_LOSS", `${what} doesn't name a pack`);
|
|
65
|
+
const pack = row.id;
|
|
66
|
+
return Effect.map(decodeRow(schema, row, what), (value) => ({
|
|
67
|
+
pack,
|
|
68
|
+
value
|
|
69
|
+
}));
|
|
70
|
+
};
|
|
71
|
+
export { LeavingRow, QuarantineRow, decodeHeld, defaultPrune, leavingKey, leavingRow, pruneFloor, pruneWait, quarantineKey, quarantineRow, removeAt };
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { gitError } from "../store/errors.mjs";
|
|
2
|
+
import { anySet, clearBit, isSet, nextSet, setBit } from "./bits.mjs";
|
|
3
|
+
import { bitmapWords } from "./ewah.mjs";
|
|
4
|
+
import { basesBlock, openBases } from "./index-files.mjs";
|
|
5
|
+
import { indexFiles } from "./layout.mjs";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
// src/storage/send-list.ts
|
|
8
|
+
/** A pack's entry at `position`: its ID, offset, CRC-32 and length, from the loaded index alone. */
|
|
9
|
+
const entryAt = (pack, position) => {
|
|
10
|
+
const { index, reverse, pack: stored } = pack.indexed;
|
|
11
|
+
const place = position - pack.base;
|
|
12
|
+
const { oid, offset, crc32 } = index.object(reverse.rankAt(place));
|
|
13
|
+
return {
|
|
14
|
+
oid,
|
|
15
|
+
pack: stored,
|
|
16
|
+
offset,
|
|
17
|
+
bytes: (place + 1 < pack.count ? index.offsetAt(reverse.rankAt(place + 1)) : stored.bytes - 20) - offset,
|
|
18
|
+
crc32
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/** The size of the list's `at`th object. */
|
|
22
|
+
const sizeOf = (list, at) => list.large.get(at) ?? list.sizes[at] ?? 0;
|
|
23
|
+
/** The list's objects in order, from its `ordinal`th: each one's place, position and pack. */
|
|
24
|
+
var ListCursor = class ListCursor {
|
|
25
|
+
list;
|
|
26
|
+
ordinal = 0;
|
|
27
|
+
position = 0;
|
|
28
|
+
pack = 0;
|
|
29
|
+
constructor(list, from) {
|
|
30
|
+
this.list = list;
|
|
31
|
+
if (from === void 0) this.#seek(0);
|
|
32
|
+
else ({ordinal: this.ordinal, position: this.position, pack: this.pack} = from);
|
|
33
|
+
}
|
|
34
|
+
/** Another cursor at the same object. */
|
|
35
|
+
copy() {
|
|
36
|
+
return new ListCursor(this.list, this);
|
|
37
|
+
}
|
|
38
|
+
get done() {
|
|
39
|
+
return this.ordinal >= this.list.count;
|
|
40
|
+
}
|
|
41
|
+
/** The pack the object is in. */
|
|
42
|
+
get inPack() {
|
|
43
|
+
const pack = this.list.packs[this.pack];
|
|
44
|
+
if (pack === void 0) throw new Error(`no pack holds position ${this.position}`);
|
|
45
|
+
return pack;
|
|
46
|
+
}
|
|
47
|
+
next() {
|
|
48
|
+
this.ordinal += 1;
|
|
49
|
+
this.#seek(this.position + 1);
|
|
50
|
+
}
|
|
51
|
+
#seek(from) {
|
|
52
|
+
const { packs, send } = this.list;
|
|
53
|
+
for (let at = from; this.pack < packs.length;) {
|
|
54
|
+
const pack = packs[this.pack];
|
|
55
|
+
if (pack === void 0) break;
|
|
56
|
+
const found = nextSet(send, Math.max(at, pack.base), pack.base + pack.count);
|
|
57
|
+
if (found < pack.base + pack.count) {
|
|
58
|
+
this.position = found;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
this.pack += 1;
|
|
62
|
+
at = found;
|
|
63
|
+
}
|
|
64
|
+
this.position = Number.POSITIVE_INFINITY;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
/** The entries `sizesAt` sizes at once. */
|
|
68
|
+
const sizedAtOnce = 1024;
|
|
69
|
+
/** The most `.bases` blocks one read takes: 65,536 positions, 512 KiB of rows at most. */
|
|
70
|
+
const basesRun = 16;
|
|
71
|
+
/**
|
|
72
|
+
* What a run of `.bases` rows holds as it's read, charged once before the first: its bytes, the
|
|
73
|
+
* pairs `rowsOf` builds from them and their array, about 2 MiB measured, with the last run's still
|
|
74
|
+
* held as the next is read.
|
|
75
|
+
*/
|
|
76
|
+
const basesRunBytes = basesRun * basesBlock * 8 * 6;
|
|
77
|
+
/** What a chain's step holds: its entry in `chains`. */
|
|
78
|
+
const chainStepBytes = 64;
|
|
79
|
+
const loss = (message) => gitError("DATA_LOSS", message);
|
|
80
|
+
/** The runs of `.bases` blocks in `[from, to)` that hold a position of `wanted`, as read ranges. */
|
|
81
|
+
const basesRuns = (wanted, from, to) => {
|
|
82
|
+
const runs = [];
|
|
83
|
+
for (let block = Math.floor(from / basesBlock); block * basesBlock < to; block += 1) {
|
|
84
|
+
if (!wanted(block)) continue;
|
|
85
|
+
const start = Math.max(from, block * basesBlock);
|
|
86
|
+
const end = Math.min(to, (block + 1) * basesBlock);
|
|
87
|
+
const last = runs.at(-1);
|
|
88
|
+
if (last !== void 0 && last.to === start && end - last.from <= basesRun * 4096) last.to = end;
|
|
89
|
+
else runs.push({
|
|
90
|
+
from: start,
|
|
91
|
+
to: end
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return runs;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* The send list of `input.send`'s pack positions: sized through the reader's blocks by place,
|
|
98
|
+
* `blob:limit`'s too-large blobs left out, each delta found in its layer's `.bases` and copied
|
|
99
|
+
* when its base is sent, and its bytes. Each `.bases` read is checked against the fetch's calls
|
|
100
|
+
* before it's made, as the walk checks its levels.
|
|
101
|
+
*/
|
|
102
|
+
const listOf = Effect.fnUntraced(function* (input) {
|
|
103
|
+
const { send, kinds, read, ahead } = input;
|
|
104
|
+
const checked = ahead({
|
|
105
|
+
bucket: 0,
|
|
106
|
+
store: 0
|
|
107
|
+
});
|
|
108
|
+
const indexed = read.indexed;
|
|
109
|
+
const sizesAt = read.sizesAt;
|
|
110
|
+
if (indexed === void 0 || sizesAt === void 0) return yield* Effect.die(/* @__PURE__ */ new Error("a send list needs the reader to have loaded its packs"));
|
|
111
|
+
const packs = [];
|
|
112
|
+
for (const ranges of input.ranges) {
|
|
113
|
+
if (!anySet(send, ranges.base, ranges.base + ranges.count)) continue;
|
|
114
|
+
const pack = input.listed.packs.find(({ id }) => id === ranges.pack.id);
|
|
115
|
+
if (pack === void 0) return yield* Effect.fail(loss(`Pack ${ranges.pack.id} isn't listed`));
|
|
116
|
+
packs.push({
|
|
117
|
+
base: ranges.base,
|
|
118
|
+
count: ranges.count,
|
|
119
|
+
indexed: yield* indexed(pack)
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
let count = input.count;
|
|
123
|
+
const sizes = new Uint32Array(count);
|
|
124
|
+
const large = /* @__PURE__ */ new Map();
|
|
125
|
+
const dropped = new Uint32Array(bitmapWords(count));
|
|
126
|
+
let dropping = false;
|
|
127
|
+
let ordinal = 0;
|
|
128
|
+
for (const pack of packs) {
|
|
129
|
+
const end = pack.base + pack.count;
|
|
130
|
+
for (let at = nextSet(send, pack.base, end); at < end;) {
|
|
131
|
+
const batch = [];
|
|
132
|
+
for (; at < end && batch.length < sizedAtOnce; at = nextSet(send, at + 1, end)) {
|
|
133
|
+
const { oid, offset } = entryAt(pack, at);
|
|
134
|
+
batch.push({
|
|
135
|
+
oid,
|
|
136
|
+
offset
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
yield* checked;
|
|
140
|
+
const sized = yield* sizesAt(pack.indexed, batch);
|
|
141
|
+
for (let slot = 0; slot < batch.length; slot += 1) {
|
|
142
|
+
const size = sized[slot] ?? 0;
|
|
143
|
+
if (kinds[ordinal] === 2 && input.blobsUnder !== void 0 && size >= input.blobsUnder) {
|
|
144
|
+
setBit(dropped, ordinal);
|
|
145
|
+
dropping = true;
|
|
146
|
+
}
|
|
147
|
+
if (size > 4294967295) large.set(ordinal, size);
|
|
148
|
+
else sizes[ordinal] = size;
|
|
149
|
+
ordinal += 1;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (dropping) {
|
|
154
|
+
const out = new ListCursor({
|
|
155
|
+
...emptyList(input, packs),
|
|
156
|
+
sizes,
|
|
157
|
+
large
|
|
158
|
+
});
|
|
159
|
+
let kept = 0;
|
|
160
|
+
const moved = /* @__PURE__ */ new Map();
|
|
161
|
+
for (; !out.done; out.next()) {
|
|
162
|
+
if (isSet(dropped, out.ordinal)) {
|
|
163
|
+
clearBit(send, out.position);
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
kinds[kept] = kinds[out.ordinal] ?? 0;
|
|
167
|
+
const size = large.get(out.ordinal);
|
|
168
|
+
if (size === void 0) sizes[kept] = sizes[out.ordinal] ?? 0;
|
|
169
|
+
else moved.set(kept, size);
|
|
170
|
+
kept += 1;
|
|
171
|
+
}
|
|
172
|
+
large.clear();
|
|
173
|
+
for (const [at, size] of moved) large.set(at, size);
|
|
174
|
+
count = kept;
|
|
175
|
+
}
|
|
176
|
+
const listed = {
|
|
177
|
+
...emptyList({
|
|
178
|
+
...input,
|
|
179
|
+
count
|
|
180
|
+
}, packs),
|
|
181
|
+
sizes,
|
|
182
|
+
large
|
|
183
|
+
};
|
|
184
|
+
const { deltas, copied, bases, chains } = yield* copiesOf(input, listed);
|
|
185
|
+
const list = {
|
|
186
|
+
...listed,
|
|
187
|
+
deltas,
|
|
188
|
+
copied,
|
|
189
|
+
bases,
|
|
190
|
+
chains
|
|
191
|
+
};
|
|
192
|
+
let bytes = 0;
|
|
193
|
+
for (const cursor = new ListCursor(list); !cursor.done; cursor.next()) bytes += isSet(copied, cursor.ordinal) ? entryAt(cursor.inPack, cursor.position).bytes : sizeOf(list, cursor.ordinal);
|
|
194
|
+
return {
|
|
195
|
+
...list,
|
|
196
|
+
bytes
|
|
197
|
+
};
|
|
198
|
+
});
|
|
199
|
+
/** A list of `input`'s send set over `packs`, with nothing known of its entries yet. */
|
|
200
|
+
const emptyList = (input, packs) => {
|
|
201
|
+
const words = bitmapWords(input.count);
|
|
202
|
+
return {
|
|
203
|
+
send: input.send,
|
|
204
|
+
count: input.count,
|
|
205
|
+
kinds: input.kinds,
|
|
206
|
+
sizes: /* @__PURE__ */ new Uint32Array(0),
|
|
207
|
+
large: /* @__PURE__ */ new Map(),
|
|
208
|
+
deltas: new Uint32Array(words),
|
|
209
|
+
copied: new Uint32Array(words),
|
|
210
|
+
bases: /* @__PURE__ */ new Uint32Array(0),
|
|
211
|
+
packs,
|
|
212
|
+
chains: /* @__PURE__ */ new Map(),
|
|
213
|
+
bytes: 0
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* Which of `list`'s objects are deltas and which are copied, from each layer's `.bases`, and each
|
|
218
|
+
* written-whole delta's chain of bases down to a whole entry.
|
|
219
|
+
*/
|
|
220
|
+
const copiesOf = Effect.fnUntraced(function* (input, list) {
|
|
221
|
+
const { send, read, ahead } = input;
|
|
222
|
+
const deltas = new Uint32Array(bitmapWords(list.count));
|
|
223
|
+
const copied = new Uint32Array(bitmapWords(list.count));
|
|
224
|
+
const bases = new Uint32Array(list.count);
|
|
225
|
+
const chains = /* @__PURE__ */ new Map();
|
|
226
|
+
const opened = /* @__PURE__ */ new Map();
|
|
227
|
+
const packOf = (position) => list.packs.find((pack) => position >= pack.base && position < pack.base + pack.count);
|
|
228
|
+
yield* read.hold(basesRunBytes);
|
|
229
|
+
const basesOf = Effect.fnUntraced(function* (layer) {
|
|
230
|
+
const known = opened.get(layer);
|
|
231
|
+
if (known !== void 0) return known;
|
|
232
|
+
yield* ahead({
|
|
233
|
+
bucket: 2,
|
|
234
|
+
store: 0
|
|
235
|
+
});
|
|
236
|
+
const key = indexFiles(input.listed.repo, layer.build).bases;
|
|
237
|
+
const bases = yield* openBases(input.bucket, key, layer.first + layer.positions);
|
|
238
|
+
opened.set(layer, bases);
|
|
239
|
+
return bases;
|
|
240
|
+
});
|
|
241
|
+
/** A base checked: before its delta, in the same pack. */
|
|
242
|
+
const baseOf = (position, base) => {
|
|
243
|
+
const pack = packOf(position);
|
|
244
|
+
return pack === void 0 || base >= position || base < pack.base ? Effect.fail(loss(`The index's .bases names ${base} as ${position}'s base, not before it in its pack`)) : Effect.succeed(base);
|
|
245
|
+
};
|
|
246
|
+
let pending = [];
|
|
247
|
+
const cursor = new ListCursor(list);
|
|
248
|
+
for (const layer of input.layers) {
|
|
249
|
+
const end = layer.first + layer.positions;
|
|
250
|
+
if (cursor.done || cursor.position >= end) continue;
|
|
251
|
+
const runs = layer.deltas === 0 ? [] : basesRuns((block) => anySet(send, block * basesBlock, (block + 1) * basesBlock), layer.first, end);
|
|
252
|
+
let rows = /* @__PURE__ */ new Uint32Array(0);
|
|
253
|
+
let row = 0;
|
|
254
|
+
let run = 0;
|
|
255
|
+
let readRun = -1;
|
|
256
|
+
for (; !cursor.done && cursor.position < end; cursor.next()) {
|
|
257
|
+
const { position, ordinal } = cursor;
|
|
258
|
+
while (run < runs.length && (runs[run]?.to ?? 0) <= position) run += 1;
|
|
259
|
+
const reading = runs[run];
|
|
260
|
+
if (reading !== void 0 && reading.from <= position && run !== readRun) {
|
|
261
|
+
const bases = yield* basesOf(layer);
|
|
262
|
+
yield* ahead({
|
|
263
|
+
bucket: 1,
|
|
264
|
+
store: 0
|
|
265
|
+
});
|
|
266
|
+
rows = yield* bases.rowsOf(reading.from, reading.to);
|
|
267
|
+
row = 0;
|
|
268
|
+
readRun = run;
|
|
269
|
+
}
|
|
270
|
+
while (row < rows.length && (rows[row] ?? 0) < position) row += 2;
|
|
271
|
+
if (row < rows.length && rows[row] === position) {
|
|
272
|
+
const base = yield* baseOf(position, rows[row + 1] ?? 0);
|
|
273
|
+
setBit(deltas, ordinal);
|
|
274
|
+
if (isSet(send, base)) {
|
|
275
|
+
setBit(copied, ordinal);
|
|
276
|
+
bases[ordinal] = base;
|
|
277
|
+
} else {
|
|
278
|
+
yield* read.hold(chainStepBytes);
|
|
279
|
+
chains.set(position, base);
|
|
280
|
+
pending.push(base);
|
|
281
|
+
}
|
|
282
|
+
} else setBit(copied, ordinal);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
while (pending.length > 0) {
|
|
286
|
+
const asked = [...new Set(pending)].filter((base) => !chains.has(base)).sort((a, b) => a - b);
|
|
287
|
+
pending = [];
|
|
288
|
+
for (const layer of input.layers) {
|
|
289
|
+
const end = layer.first + layer.positions;
|
|
290
|
+
const inLayer = asked.filter((base) => base >= layer.first && base < end);
|
|
291
|
+
if (inLayer.length === 0 || layer.deltas === 0) continue;
|
|
292
|
+
const blocks = new Set(inLayer.map((base) => Math.floor(base / basesBlock)));
|
|
293
|
+
const bases = yield* basesOf(layer);
|
|
294
|
+
for (const reading of basesRuns((block) => blocks.has(block), layer.first, end)) {
|
|
295
|
+
yield* ahead({
|
|
296
|
+
bucket: 1,
|
|
297
|
+
store: 0
|
|
298
|
+
});
|
|
299
|
+
const rows = yield* bases.rowsOf(reading.from, reading.to);
|
|
300
|
+
const wanted = new Set(inLayer.filter((base) => base >= reading.from && base < reading.to));
|
|
301
|
+
for (let row = 0; row < rows.length; row += 2) {
|
|
302
|
+
const position = rows[row] ?? 0;
|
|
303
|
+
if (!wanted.has(position)) continue;
|
|
304
|
+
const base = yield* baseOf(position, rows[row + 1] ?? 0);
|
|
305
|
+
yield* read.hold(chainStepBytes);
|
|
306
|
+
chains.set(position, base);
|
|
307
|
+
pending.push(base);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return {
|
|
313
|
+
deltas,
|
|
314
|
+
copied,
|
|
315
|
+
bases,
|
|
316
|
+
chains
|
|
317
|
+
};
|
|
318
|
+
});
|
|
319
|
+
export { ListCursor, entryAt, listOf, sizeOf };
|