@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,317 @@
|
|
|
1
|
+
import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
2
|
+
import { rawLinks } from "../protocol/objects/links-raw.mjs";
|
|
3
|
+
import { isTreeMode } from "../protocol/objects/object.mjs";
|
|
4
|
+
import { parseTreeBytes } from "../protocol/objects/tree.mjs";
|
|
5
|
+
import { oidBytes } from "../protocol/packs/idx.mjs";
|
|
6
|
+
import { gitError } from "../store/errors.mjs";
|
|
7
|
+
import { bitmapWords } from "./ewah.mjs";
|
|
8
|
+
import { ewahMostWords, openBitmaps } from "./index-bitmaps.mjs";
|
|
9
|
+
import { indexFiles, isPackId, packFiles } from "./layout.mjs";
|
|
10
|
+
import { joinIds, missing } from "./link-join.mjs";
|
|
11
|
+
import { indexedRanges, openRanges, rangeRanks, rankOf, readExactly, searchReads } from "./pack-ranges.mjs";
|
|
12
|
+
import { readWhole } from "./pack-reads.mjs";
|
|
13
|
+
import { compareIds } from "./raw-ids.mjs";
|
|
14
|
+
import { levelTooLarge } from "./wants.mjs";
|
|
15
|
+
import { tryUnlessSpent } from "../contracts/calls-spent.mjs";
|
|
16
|
+
import * as Effect from "effect/Effect";
|
|
17
|
+
// src/storage/index-layers.ts
|
|
18
|
+
/**
|
|
19
|
+
* The reachability index read across its layers. Each layer is a build of its own, its positions
|
|
20
|
+
* after the layers below: its groups in order, each one's packs in position order, then the rows
|
|
21
|
+
* it read. So a layer added never moves a position below it, and a bitmap stored in any layer is
|
|
22
|
+
* a bitmap of the positions up to its own last, each one after it unset.
|
|
23
|
+
*
|
|
24
|
+
* A reader opens every layer from one `index` row, so it never mixes the layers of two of its
|
|
25
|
+
* versions (the core EM's condition for layers, 22 Nov).
|
|
26
|
+
*/
|
|
27
|
+
const lost = (message) => gitError("DATA_LOSS", message);
|
|
28
|
+
/**
|
|
29
|
+
* The most objects a walk that closes a tip's reach reads, for a tip with no bitmap: about the
|
|
30
|
+
* 100 first-parent commits between bitmaps, and the trees each one changes, at spike C's 8 reads
|
|
31
|
+
* a commit, twice over. Past it the walk ends, and its caller takes the bounded walk.
|
|
32
|
+
*/
|
|
33
|
+
const walkMost = 2e3;
|
|
34
|
+
/** How many IDs `positionsOf` finds by a search each, past which it joins. */
|
|
35
|
+
const searchedMost = 64;
|
|
36
|
+
/**
|
|
37
|
+
* The most bucket calls finding `count` IDs in packs of `packs` objects takes: by a search each,
|
|
38
|
+
* `searchReads` of each pack's `.idx` and one `.pos` read, or by a join of each pack's ranges.
|
|
39
|
+
*/
|
|
40
|
+
const lookupCalls = (count, packs) => ({
|
|
41
|
+
searched: count * (packs.reduce((sum, objects) => sum + searchReads(objects), 0) + 1),
|
|
42
|
+
joined: packs.reduce((sum, objects) => sum + 2 * Math.ceil(objects / rangeRanks), 0)
|
|
43
|
+
});
|
|
44
|
+
const storedOf = (pack) => isPackId(pack.id) ? Effect.succeed({
|
|
45
|
+
id: pack.id,
|
|
46
|
+
bytes: pack.bytes
|
|
47
|
+
}) : Effect.fail(lost(`'${pack.id}' isn't a pack's ID`));
|
|
48
|
+
/** The rows of `runs` by ID, each with its position. */
|
|
49
|
+
const regionOfRuns = (runs) => {
|
|
50
|
+
const only = runs[0];
|
|
51
|
+
if (runs.length === 1 && only !== void 0) return {
|
|
52
|
+
ids: only.ids,
|
|
53
|
+
positions: Uint32Array.from({ length: only.ids.length / 20 }, (_, at) => only.first + at)
|
|
54
|
+
};
|
|
55
|
+
const all = runs.flatMap((run) => Array.from({ length: run.ids.length / 20 }, (_, at) => ({
|
|
56
|
+
run,
|
|
57
|
+
at
|
|
58
|
+
})));
|
|
59
|
+
all.sort((a, b) => compareIds(a.run.ids, a.at * 20, b.run.ids, b.at * 20));
|
|
60
|
+
const ids = new Uint8Array(all.length * 20);
|
|
61
|
+
const positions = new Uint32Array(all.length);
|
|
62
|
+
for (const [index, { run, at }] of all.entries()) {
|
|
63
|
+
ids.set(run.ids.subarray(at * 20, at * 20 + 20), index * 20);
|
|
64
|
+
positions[index] = run.first + at;
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
ids,
|
|
68
|
+
positions
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
/** Where `id` is among the region's rows, by a binary search, or `missing`. */
|
|
72
|
+
const regionPosition = (region, id) => {
|
|
73
|
+
let low = 0;
|
|
74
|
+
let high = region.positions.length;
|
|
75
|
+
while (low < high) {
|
|
76
|
+
const middle = low + high >>> 1;
|
|
77
|
+
const compared = compareIds(id, 0, region.ids, middle * 20);
|
|
78
|
+
if (compared === 0) return region.positions[middle] ?? 4294967295;
|
|
79
|
+
if (compared < 0) high = middle;
|
|
80
|
+
else low = middle + 1;
|
|
81
|
+
}
|
|
82
|
+
return missing;
|
|
83
|
+
};
|
|
84
|
+
/** `.rev`'s header, before its ranks. */
|
|
85
|
+
const revHeaderBytes = 12;
|
|
86
|
+
/**
|
|
87
|
+
* The layers of `spans`, oldest first, over `listed`: each pack's `.idx` and `.pos` opened at its
|
|
88
|
+
* base, and each layer's `.region` read. A pack a layer names that `listed` doesn't hold is
|
|
89
|
+
* `DATA_LOSS`: the caller checks the index covers the listing first.
|
|
90
|
+
*/
|
|
91
|
+
const openLayout = (bucket, listed, spans, indexed) => Effect.gen(function* () {
|
|
92
|
+
const byId = new Map(listed.packs.map((pack) => [pack.id, pack]));
|
|
93
|
+
const ranges = [];
|
|
94
|
+
const runs = [];
|
|
95
|
+
let position = 0;
|
|
96
|
+
for (const span of spans) {
|
|
97
|
+
if (span.first !== position) return yield* Effect.fail(lost(`The index's layer ${span.build} starts at ${span.first}, not ${position}`));
|
|
98
|
+
const rows = span.groups.reduce((sum, group) => sum + group.rows, 0);
|
|
99
|
+
const key = indexFiles(listed.repo, span.build).region;
|
|
100
|
+
const ids = rows === 0 ? /* @__PURE__ */ new Uint8Array(0) : yield* readWhole(bucket, key);
|
|
101
|
+
if (ids?.byteLength !== rows * 20) return yield* Effect.fail(lost(`${key} doesn't hold its layer's ${rows} rows`));
|
|
102
|
+
let row = 0;
|
|
103
|
+
for (const group of span.groups) {
|
|
104
|
+
for (const id of group.packs) {
|
|
105
|
+
const pack = byId.get(id);
|
|
106
|
+
if (pack === void 0) return yield* Effect.fail(lost(`The index's pack ${id} isn't listed`));
|
|
107
|
+
ranges.push(indexed === void 0 ? yield* openRanges(bucket, yield* storedOf(pack), pack.objects, position) : yield* indexedRanges(bucket, yield* indexed(pack), pack.objects, position));
|
|
108
|
+
position += pack.objects;
|
|
109
|
+
}
|
|
110
|
+
if (group.rows > 0) {
|
|
111
|
+
runs.push({
|
|
112
|
+
first: position,
|
|
113
|
+
ids: ids.subarray(row * 20, (row + group.rows) * 20)
|
|
114
|
+
});
|
|
115
|
+
row += group.rows;
|
|
116
|
+
position += group.rows;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const region = regionOfRuns(runs);
|
|
121
|
+
const total = position;
|
|
122
|
+
const idAt = (at) => Effect.gen(function* () {
|
|
123
|
+
for (const pack of ranges) {
|
|
124
|
+
if (at < pack.base || at >= pack.base + pack.count) continue;
|
|
125
|
+
const key = packFiles(pack.pack.id).rev;
|
|
126
|
+
const bytes = yield* readExactly(bucket, key, revHeaderBytes + (at - pack.base) * 4, 4);
|
|
127
|
+
const rank = new DataView(bytes.buffer, bytes.byteOffset, 4).getUint32(0);
|
|
128
|
+
if (rank >= pack.count) return yield* Effect.fail(lost(`${key} names rank ${rank} of ${pack.count}`));
|
|
129
|
+
return yield* pack.ids(rank, 1);
|
|
130
|
+
}
|
|
131
|
+
for (const run of runs) {
|
|
132
|
+
const within = at - run.first;
|
|
133
|
+
if (within >= 0 && within * 20 < run.ids.length) return run.ids.slice(within * 20, within * 20 + 20);
|
|
134
|
+
}
|
|
135
|
+
return yield* Effect.fail(lost(`The index holds no position ${at} of ${total}`));
|
|
136
|
+
});
|
|
137
|
+
const searched = (ids, count) => Effect.gen(function* () {
|
|
138
|
+
const out = new Uint32Array(count).fill(missing);
|
|
139
|
+
for (let at = 0; at < count; at += 1) {
|
|
140
|
+
const id = ids.subarray(at * 20, at * 20 + 20);
|
|
141
|
+
for (const pack of ranges) {
|
|
142
|
+
const rank = yield* rankOf(pack, id);
|
|
143
|
+
if (rank === void 0) continue;
|
|
144
|
+
out[at] = pack.base + ((yield* pack.positions(rank, 1))[0] ?? 0);
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
out[at] = Math.min(out[at] ?? 4294967295, regionPosition(region, id));
|
|
148
|
+
}
|
|
149
|
+
return out;
|
|
150
|
+
});
|
|
151
|
+
const joined = (ids, count) => joinIds(ids, count, ranges, region);
|
|
152
|
+
return {
|
|
153
|
+
ranges,
|
|
154
|
+
region,
|
|
155
|
+
positions: total,
|
|
156
|
+
idAt,
|
|
157
|
+
positionsOf: (ids, count, searchedUpTo = searchedMost) => count <= searchedUpTo ? searched(ids, count) : joined(ids, count)
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
/** How many objects the walk reads at once, and how many bitmap ranges `orInto` does. */
|
|
161
|
+
const readsAtOnce = 16;
|
|
162
|
+
/**
|
|
163
|
+
* What `LayerBitmaps.orInto` holds into a union of `words` words, beside it: an entry's bytes and
|
|
164
|
+
* its words for each range it reads at once, each at most an EWAH of those words.
|
|
165
|
+
*/
|
|
166
|
+
const orIntoBytes = (words) => readsAtOnce * ewahMostWords(words) * 8;
|
|
167
|
+
/** The bitmaps of `layers`, each layer's table read once. */
|
|
168
|
+
const openLayerBitmaps = (bucket, repo, layers) => Effect.gen(function* () {
|
|
169
|
+
const byPosition = /* @__PURE__ */ new Map();
|
|
170
|
+
const numbered = /* @__PURE__ */ new Map();
|
|
171
|
+
for (const layer of layers) {
|
|
172
|
+
if (layer.bitmaps === 0) continue;
|
|
173
|
+
const open = yield* openBitmaps(bucket, indexFiles(repo, layer.build).bitmaps, {
|
|
174
|
+
positions: layer.first + layer.positions,
|
|
175
|
+
count: layer.bitmaps,
|
|
176
|
+
table: layer.table
|
|
177
|
+
});
|
|
178
|
+
for (const entry of open.entries) {
|
|
179
|
+
byPosition.set(entry.position, {
|
|
180
|
+
open,
|
|
181
|
+
entry
|
|
182
|
+
});
|
|
183
|
+
if (entry.number !== 4294967295) numbered.set(entry.number, entry.position);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
count: byPosition.size,
|
|
188
|
+
has: (position) => byPosition.has(position),
|
|
189
|
+
bitmapAt: (position) => {
|
|
190
|
+
const found = byPosition.get(position);
|
|
191
|
+
return found === void 0 ? Effect.succeed(void 0) : found.open.bitmapOf(found.entry);
|
|
192
|
+
},
|
|
193
|
+
orInto: (positions, into) => {
|
|
194
|
+
const byFile = /* @__PURE__ */ new Map();
|
|
195
|
+
for (const position of new Set(positions)) {
|
|
196
|
+
const found = byPosition.get(position);
|
|
197
|
+
if (found === void 0) continue;
|
|
198
|
+
const entries = byFile.get(found.open) ?? [];
|
|
199
|
+
entries.push(found.entry);
|
|
200
|
+
byFile.set(found.open, entries);
|
|
201
|
+
}
|
|
202
|
+
return Effect.forEach(byFile, ([open, entries]) => open.orInto(entries, into, readsAtOnce), { discard: true });
|
|
203
|
+
},
|
|
204
|
+
numbered,
|
|
205
|
+
entries: [...byPosition.values()].map(({ open, entry }) => ({
|
|
206
|
+
from: open,
|
|
207
|
+
entry
|
|
208
|
+
})).sort((a, b) => a.entry.position - b.entry.position)
|
|
209
|
+
};
|
|
210
|
+
});
|
|
211
|
+
/** `from` ORed into `into`, which may be longer: the positions past `from`'s are unset in it. */
|
|
212
|
+
const orWords = (from, into) => {
|
|
213
|
+
const length = Math.min(from.length, into.length);
|
|
214
|
+
for (let at = 0; at < length; at += 1) into[at] = ((into[at] ?? 0) | (from[at] ?? 0)) >>> 0;
|
|
215
|
+
};
|
|
216
|
+
const bytesOf = (object) => tryUnlessSpent(async () => new Uint8Array(await new Response(object.bytes).arrayBuffer()), (cause) => gitError("UNAVAILABLE", `Object ${object.oid} couldn't be read`, {
|
|
217
|
+
cause,
|
|
218
|
+
hint: "Try again"
|
|
219
|
+
}));
|
|
220
|
+
/** A gitlink names a commit of another repo, no object of this one. */
|
|
221
|
+
const gitlinkMode = "160000";
|
|
222
|
+
/** What a walk holds for each link a read object's parse makes: its ID, entry and join's place. */
|
|
223
|
+
const linkHeldBytes = 320;
|
|
224
|
+
/** A tree entry's least bytes: a 5-digit mode, a space, a 1-byte name, a NUL and its ID. */
|
|
225
|
+
const leastEntryBytes = 28;
|
|
226
|
+
/**
|
|
227
|
+
* `follow` of a batch of read objects, with what following them holds charged to `allotment`
|
|
228
|
+
* first and given back after: each one's bytes, and a link for each `leastEntryBytes` of them,
|
|
229
|
+
* the most its parse can make. A blob is never read, so it's charged nothing. Past what the
|
|
230
|
+
* budget holds alone, it's `levelTooLarge`, as the want walk's.
|
|
231
|
+
*/
|
|
232
|
+
const whileFollowed = (allotment, objects, follow) => {
|
|
233
|
+
const bytes = objects.reduce((sum, object) => object === void 0 || object.type === "blob" ? sum : sum + object.size + Math.ceil(object.size / leastEntryBytes) * linkHeldBytes, 0);
|
|
234
|
+
return Effect.acquireUseRelease(allotment.grow(bytes, levelTooLarge), () => follow, () => Effect.sync(() => allotment.shrink(bytes)));
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* The positions `starts` reach, as words over every position, or `undefined` when it can't say:
|
|
238
|
+
* a walk past `most` reads, an object it can't find, or a link to an ID the index doesn't hold,
|
|
239
|
+
* such as one listed after it. A position with a stored bitmap is ORed whole and not walked; any
|
|
240
|
+
* other is read, and its links found by position, a few at a time. A blob is reached and never
|
|
241
|
+
* read. It holds a word for each 32 positions and at most `most` IDs still to read, charged to
|
|
242
|
+
* `allotment`, and each batch it follows, charged by `whileFollowed`.
|
|
243
|
+
*/
|
|
244
|
+
const reachOf = (input, starts) => Effect.gen(function* () {
|
|
245
|
+
const { layout, bitmaps } = input;
|
|
246
|
+
const most = input.most ?? 2e3;
|
|
247
|
+
const words = bitmapWords(layout.positions);
|
|
248
|
+
const held = words * 4 + most * 24;
|
|
249
|
+
yield* Effect.acquireRelease(input.allotment.grow(held), () => Effect.sync(() => input.allotment.shrink(held)));
|
|
250
|
+
const bits = new Uint32Array(words);
|
|
251
|
+
const queue = [];
|
|
252
|
+
const has = (position) => ((bits[position >>> 5] ?? 0) & 1 << (position & 31)) !== 0;
|
|
253
|
+
/** `position`, with what its bitmap holds, or to be read when it has links and none. */
|
|
254
|
+
const take = (position, id, links) => Effect.gen(function* () {
|
|
255
|
+
if (has(position)) return;
|
|
256
|
+
const stored = yield* bitmaps.bitmapAt(position);
|
|
257
|
+
if (stored !== void 0) {
|
|
258
|
+
orWords(stored, bits);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
bits[position >>> 5] = ((bits[position >>> 5] ?? 0) | 1 << (position & 31)) >>> 0;
|
|
262
|
+
if (links) queue.push(id ?? (yield* layout.idAt(position)));
|
|
263
|
+
});
|
|
264
|
+
for (const start of starts) yield* take(start.position, start.id, true);
|
|
265
|
+
let reads = 0;
|
|
266
|
+
while (queue.length > 0) {
|
|
267
|
+
const batch = queue.splice(0, readsAtOnce);
|
|
268
|
+
reads += batch.length;
|
|
269
|
+
if (reads > most) return void 0;
|
|
270
|
+
const objects = yield* Effect.forEach(batch, (id) => input.read(hexOf(id)), { concurrency: readsAtOnce });
|
|
271
|
+
const followed = Effect.gen(function* () {
|
|
272
|
+
const linked = [];
|
|
273
|
+
for (const object of objects) {
|
|
274
|
+
if (object === void 0) return false;
|
|
275
|
+
if (object.type === "blob") {
|
|
276
|
+
yield* Effect.promise(() => object.bytes.cancel());
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
const bytes = yield* bytesOf(object);
|
|
280
|
+
if (object.type === "tree") {
|
|
281
|
+
const entries = yield* Effect.mapError(parseTreeBytes(bytes), (error) => lost(`The tree ${object.oid} is unreadable: ${error.message}`));
|
|
282
|
+
for (const entry of entries) if (entry.mode !== gitlinkMode) linked.push({
|
|
283
|
+
id: oidBytes(entry.oid),
|
|
284
|
+
links: isTreeMode(entry.mode)
|
|
285
|
+
});
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
const malformed = rawLinks(object.type, bytes, (from, at) => linked.push({
|
|
289
|
+
id: from.slice(at, at + 20),
|
|
290
|
+
links: true
|
|
291
|
+
}));
|
|
292
|
+
if (malformed !== void 0) return yield* Effect.fail(lost(`The ${object.type} ${object.oid} is unreadable: ${malformed}`));
|
|
293
|
+
}
|
|
294
|
+
const ids = new Uint8Array(linked.length * 20);
|
|
295
|
+
for (const [at, link] of linked.entries()) ids.set(link.id, at * 20);
|
|
296
|
+
const positions = yield* layout.positionsOf(ids, linked.length);
|
|
297
|
+
for (const [at, link] of linked.entries()) {
|
|
298
|
+
const position = positions[at] ?? 4294967295;
|
|
299
|
+
if (position === 4294967295) return false;
|
|
300
|
+
yield* take(position, link.id, link.links);
|
|
301
|
+
if (reads + queue.length > most) return false;
|
|
302
|
+
}
|
|
303
|
+
return true;
|
|
304
|
+
});
|
|
305
|
+
if (!(yield* whileFollowed(input.allotment, objects, followed))) return void 0;
|
|
306
|
+
}
|
|
307
|
+
return bits;
|
|
308
|
+
}).pipe(Effect.scoped);
|
|
309
|
+
/** Each of `oids` as 20 bytes, in their order. */
|
|
310
|
+
const idsOf = (oids) => {
|
|
311
|
+
const ids = new Uint8Array(oids.length * 20);
|
|
312
|
+
for (const [at, oid] of oids.entries()) ids.set(oidBytes(oid), at * 20);
|
|
313
|
+
return ids;
|
|
314
|
+
};
|
|
315
|
+
/** Whether `position` is set in `bits`. */
|
|
316
|
+
const hasBit = (bits, position) => ((bits[position >>> 5] ?? 0) & 1 << (position & 31)) !== 0;
|
|
317
|
+
export { hasBit, idsOf, lookupCalls, openLayerBitmaps, openLayout, orIntoBytes, orWords, reachOf, walkMost, whileFollowed };
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { bitmapWords } from "./ewah.mjs";
|
|
2
|
+
import { builtIndexOf, coversAll, decodeIndexValue } from "./index-build.mjs";
|
|
3
|
+
import { hasBit, idsOf, openLayerBitmaps, openLayout, orIntoBytes, orWords, reachOf, whileFollowed } from "./index-layers.mjs";
|
|
4
|
+
import { missing } from "./link-join.mjs";
|
|
5
|
+
import { readBusy } from "./memory-budget.mjs";
|
|
6
|
+
import { onward, stepsOf } from "./wants.mjs";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
// src/storage/index-reach.ts
|
|
9
|
+
/**
|
|
10
|
+
* The want check on the reachability index (#596, piece 1): which wants a fetch's tips reach, as
|
|
11
|
+
* the OR of the tips' bitmaps and a bit test each, with no walk of the repo's history.
|
|
12
|
+
*
|
|
13
|
+
* **A tip the index doesn't hold**, as a push's between its commit and its update, or a queue
|
|
14
|
+
* candidate's, which saves none, is walked from until it meets the index, and closed from what it
|
|
15
|
+
* met. Once every tip is closed, the union holds all they reach: what the index holds by its
|
|
16
|
+
* bit, and what it doesn't by the walk, so a want neither has is unreachable, held or not. An
|
|
17
|
+
* import's history arrives whole before its first ref moves, so no object the index holds
|
|
18
|
+
* links to one it doesn't.
|
|
19
|
+
*
|
|
20
|
+
* **A read never saves `git.index`.** Once a run of the job has finished, every tip has a stored
|
|
21
|
+
* bitmap, since an update makes one for each tip that has none. So a read meets a tip with none
|
|
22
|
+
* only between a push's commit and that push's try, and the push saved the try in its commit.
|
|
23
|
+
* Such a read walks that tip's reach itself, from the nearest stored bitmaps, within its own
|
|
24
|
+
* allotment and `walkMost` reads, and keeps what it found in the instance's `ReachCache`, keyed
|
|
25
|
+
* by the layer and the tip, so the next read of it walks nothing (the core EM, 22 Nov).
|
|
26
|
+
*/
|
|
27
|
+
/** The positions set in `bits`, ascending. */
|
|
28
|
+
const positionsIn = (bits) => {
|
|
29
|
+
const found = [];
|
|
30
|
+
for (const [word, value] of bits.entries()) for (let open = value; open !== 0; open &= open - 1) found.push(word * 32 + 31 - Math.clz32(open & -open));
|
|
31
|
+
return found;
|
|
32
|
+
};
|
|
33
|
+
/** The most bytes of walked reaches an instance keeps. */
|
|
34
|
+
const reachCacheBytes = 8388608;
|
|
35
|
+
/** The reaches a read walked for tips with no stored bitmap, by build and position, least lately used gone first. */
|
|
36
|
+
var ReachCache = class {
|
|
37
|
+
#kept = /* @__PURE__ */ new Map();
|
|
38
|
+
#most;
|
|
39
|
+
#bytes = 0;
|
|
40
|
+
constructor(most = reachCacheBytes) {
|
|
41
|
+
this.#most = most;
|
|
42
|
+
}
|
|
43
|
+
get(key) {
|
|
44
|
+
const found = this.#kept.get(key);
|
|
45
|
+
if (found === void 0) return void 0;
|
|
46
|
+
this.#kept.delete(key);
|
|
47
|
+
this.#kept.set(key, found);
|
|
48
|
+
return found;
|
|
49
|
+
}
|
|
50
|
+
set(key, bits) {
|
|
51
|
+
if (bits.byteLength > this.#most) return;
|
|
52
|
+
const old = this.#kept.get(key);
|
|
53
|
+
if (old !== void 0) this.#bytes -= old.byteLength;
|
|
54
|
+
this.#kept.delete(key);
|
|
55
|
+
this.#kept.set(key, bits);
|
|
56
|
+
this.#bytes += bits.byteLength;
|
|
57
|
+
for (const [first, kept] of this.#kept) {
|
|
58
|
+
if (this.#bytes <= this.#most) break;
|
|
59
|
+
this.#kept.delete(first);
|
|
60
|
+
this.#bytes -= kept.byteLength;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
/** What the walk from tips the index doesn't hold charges for each ID outside it it keeps. */
|
|
65
|
+
const outsideIdBytes = 160;
|
|
66
|
+
/**
|
|
67
|
+
* What `tips`, none of which the index holds, reach before they meet it, through `onward`: each
|
|
68
|
+
* object outside the index, read or not, counted, and each position met set in `met`, kept as a
|
|
69
|
+
* bit, not walked. A blob is reached and never read, and an object the repo doesn't hold, as a
|
|
70
|
+
* shallow repo's parent, is left out. Past `most` objects outside it, it stops, not closed. Each
|
|
71
|
+
* batch it follows is charged by `whileFollowed`, and it holds at most `most` IDs between them.
|
|
72
|
+
*/
|
|
73
|
+
const outsideOf = (input, tips, most) => Effect.gen(function* () {
|
|
74
|
+
const words = bitmapWords(input.layout.positions);
|
|
75
|
+
const held = words * 4 + most * outsideIdBytes;
|
|
76
|
+
yield* Effect.acquireRelease(input.allotment.grow(held), () => Effect.sync(() => input.allotment.shrink(held)));
|
|
77
|
+
const ids = new Set(tips);
|
|
78
|
+
const met = new Uint32Array(words);
|
|
79
|
+
let frontier = [...tips];
|
|
80
|
+
while (frontier.length > 0) {
|
|
81
|
+
const level = frontier;
|
|
82
|
+
frontier = [];
|
|
83
|
+
for (let from = 0; from < level.length; from += 16) {
|
|
84
|
+
const batch = level.slice(from, from + 16);
|
|
85
|
+
const objects = yield* Effect.forEach(batch, input.read, { concurrency: 16 });
|
|
86
|
+
const followed = Effect.gen(function* () {
|
|
87
|
+
const read = /* @__PURE__ */ new Set();
|
|
88
|
+
const linked = /* @__PURE__ */ new Set();
|
|
89
|
+
for (const [at, oid] of batch.entries()) {
|
|
90
|
+
const object = objects[at];
|
|
91
|
+
if (object === void 0) {
|
|
92
|
+
ids.delete(oid);
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const steps = yield* stepsOf(object, true);
|
|
96
|
+
for (const each of onward(steps)) if (!ids.has(each)) read.add(each);
|
|
97
|
+
for (const each of steps.reached) if (!ids.has(each)) linked.add(each);
|
|
98
|
+
}
|
|
99
|
+
const next = [.../* @__PURE__ */ new Set([...read, ...linked])];
|
|
100
|
+
const positions = yield* input.layout.positionsOf(idsOf(next), next.length);
|
|
101
|
+
for (const [at, oid] of next.entries()) {
|
|
102
|
+
const position = positions[at] ?? 4294967295;
|
|
103
|
+
if (position !== 4294967295) {
|
|
104
|
+
met[position >>> 5] = ((met[position >>> 5] ?? 0) | 1 << (position & 31)) >>> 0;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (ids.size >= most) return false;
|
|
108
|
+
ids.add(oid);
|
|
109
|
+
if (read.has(oid)) frontier.push(oid);
|
|
110
|
+
}
|
|
111
|
+
return true;
|
|
112
|
+
});
|
|
113
|
+
if (!(yield* whileFollowed(input.allotment, objects, followed))) return {
|
|
114
|
+
ids,
|
|
115
|
+
met,
|
|
116
|
+
closed: false
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
ids,
|
|
122
|
+
met,
|
|
123
|
+
closed: true
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
/**
|
|
127
|
+
* Which of `input.wants` the tips reach, by the index `input.row` names over `listed`. A want the
|
|
128
|
+
* tips' union holds, or their walk outside the index met, is `true`; any other is `false` once
|
|
129
|
+
* every tip's reach is closed. A tip whose reach won't close within `most` leaves those
|
|
130
|
+
* unanswered and sets `pastLimit`, and its caller refuses them alike. An index that doesn't cover
|
|
131
|
+
* `listed`, as after a repack took a covered pack out, answers nothing, for the caller's walk.
|
|
132
|
+
*/
|
|
133
|
+
const indexReach = (parts, listed, input) => Effect.gen(function* () {
|
|
134
|
+
const built = builtIndexOf(decodeIndexValue(input.row));
|
|
135
|
+
if (built === void 0 || !coversAll(built.layers, listed)) return {
|
|
136
|
+
answers: /* @__PURE__ */ new Map(),
|
|
137
|
+
walked: 0
|
|
138
|
+
};
|
|
139
|
+
const last = built.layers[built.layers.length - 1];
|
|
140
|
+
const words = bitmapWords(last === void 0 ? 0 : last.first + last.positions);
|
|
141
|
+
const allotment = yield* parts.budget.allot(words * 4 + orIntoBytes(words), readBusy);
|
|
142
|
+
const layout = yield* openLayout(parts.bucket, listed, built.layers);
|
|
143
|
+
const bitmaps = yield* openLayerBitmaps(parts.bucket, listed.repo, built.layers);
|
|
144
|
+
const reach = {
|
|
145
|
+
layout,
|
|
146
|
+
bitmaps,
|
|
147
|
+
read: yield* parts.objects(listed),
|
|
148
|
+
allotment,
|
|
149
|
+
most: parts.most ?? 2e3
|
|
150
|
+
};
|
|
151
|
+
const tips = [...new Set(input.tips)];
|
|
152
|
+
const tipIds = idsOf(tips);
|
|
153
|
+
const tipPositions = yield* layout.positionsOf(tipIds, tips.length);
|
|
154
|
+
const union = new Uint32Array(words);
|
|
155
|
+
let known = true;
|
|
156
|
+
let walked = 0;
|
|
157
|
+
yield* bitmaps.orInto([...tipPositions].filter((position) => position !== 4294967295 && bitmaps.has(position)), union);
|
|
158
|
+
const uncovered = tips.filter((_, at) => tipPositions[at] === missing);
|
|
159
|
+
const outside = uncovered.length === 0 ? void 0 : yield* outsideOf(reach, uncovered, reach.most);
|
|
160
|
+
if (outside !== void 0) {
|
|
161
|
+
const met = positionsIn(outside.met);
|
|
162
|
+
yield* bitmaps.orInto(met.filter((position) => bitmaps.has(position)), union);
|
|
163
|
+
const rest = met.filter((position) => !hasBit(union, position)).map((position) => ({ position }));
|
|
164
|
+
const closing = () => rest.length === 0 ? Effect.succeed(/* @__PURE__ */ new Uint32Array(0)) : reachOf({
|
|
165
|
+
...reach,
|
|
166
|
+
most: reach.most - outside.ids.size
|
|
167
|
+
}, rest);
|
|
168
|
+
const bits = outside.closed ? yield* closing() : void 0;
|
|
169
|
+
if (bits === void 0) known = false;
|
|
170
|
+
else orWords(bits, union);
|
|
171
|
+
}
|
|
172
|
+
walked += uncovered.length;
|
|
173
|
+
for (const [at, position] of tipPositions.entries()) {
|
|
174
|
+
if (position === 4294967295 || bitmaps.has(position)) continue;
|
|
175
|
+
const key = `${last?.build ?? ""}:${position}`;
|
|
176
|
+
const cached = parts.cache.get(key);
|
|
177
|
+
if (cached !== void 0) {
|
|
178
|
+
orWords(cached, union);
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
const id = tipIds.subarray(at * 20, at * 20 + 20);
|
|
182
|
+
const bits = yield* reachOf(reach, [{
|
|
183
|
+
position,
|
|
184
|
+
id
|
|
185
|
+
}]);
|
|
186
|
+
walked += 1;
|
|
187
|
+
if (bits === void 0) {
|
|
188
|
+
known = false;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
parts.cache.set(key, bits);
|
|
192
|
+
orWords(bits, union);
|
|
193
|
+
}
|
|
194
|
+
const wants = [...new Set(input.wants)];
|
|
195
|
+
const wantPositions = yield* layout.positionsOf(idsOf(wants), wants.length);
|
|
196
|
+
const answers = /* @__PURE__ */ new Map();
|
|
197
|
+
for (const [at, want] of wants.entries()) {
|
|
198
|
+
const position = wantPositions[at] ?? 4294967295;
|
|
199
|
+
if (position === 4294967295 ? outside?.ids.has(want) === true : hasBit(union, position)) answers.set(want, true);
|
|
200
|
+
else if (known) answers.set(want, false);
|
|
201
|
+
}
|
|
202
|
+
if (known) return {
|
|
203
|
+
answers,
|
|
204
|
+
walked
|
|
205
|
+
};
|
|
206
|
+
const past = {
|
|
207
|
+
answers,
|
|
208
|
+
walked,
|
|
209
|
+
pastLimit: reach.most
|
|
210
|
+
};
|
|
211
|
+
return built.refusal === void 0 ? past : {
|
|
212
|
+
...past,
|
|
213
|
+
updatesRefused: true
|
|
214
|
+
};
|
|
215
|
+
}).pipe(Effect.scoped);
|
|
216
|
+
export { ReachCache, indexReach, reachCacheBytes };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "../contracts/objects.mjs";
|
|
2
|
+
import "../contracts/store.mjs";
|
|
3
|
+
import "./index-build.mjs";
|
|
4
|
+
import "../store/call-count.mjs";
|
|
5
|
+
import "./memory-budget.mjs";
|
|
6
|
+
import "../contracts/promises.mjs";
|
|
7
|
+
import { Moment, Row } from "@ref0/infra";
|
|
8
|
+
import "effect/Effect";
|