@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,328 @@
|
|
|
1
|
+
import { Sha1 } from "../protocol/bytes/sha1.mjs";
|
|
2
|
+
import { PackWriteError } from "../protocol/packs/write-error.mjs";
|
|
3
|
+
import { decodeRow, isLimitRefusal } from "../store/errors.mjs";
|
|
4
|
+
import { repoScope } from "../store/scopes.mjs";
|
|
5
|
+
import { bucketStream, bucketTry } from "./calls.mjs";
|
|
6
|
+
import { startPut } from "./merge.mjs";
|
|
7
|
+
import { callsAhead, packOfPlan, planFetchWithin, planTooSlow, timeLeft } from "./fetch.mjs";
|
|
8
|
+
import { isPackId, objectCollections, packFiles } from "./layout.mjs";
|
|
9
|
+
import { openQuarantine } from "./quarantine.mjs";
|
|
10
|
+
import { leavingRow, removeAt } from "./rows.mjs";
|
|
11
|
+
import { forkIn, noCall } from "../store/crossing.mjs";
|
|
12
|
+
import * as Effect from "effect/Effect";
|
|
13
|
+
import * as Schema from "effect/Schema";
|
|
14
|
+
import * as Hex from "effect/encoding/Hex";
|
|
15
|
+
import * as Clock from "effect/Clock";
|
|
16
|
+
import * as Fiber from "effect/Fiber";
|
|
17
|
+
// src/storage/ready.ts
|
|
18
|
+
/** `git clone --depth 1` of the default branch, within 20,000 objects. */
|
|
19
|
+
const defaultShallow = {
|
|
20
|
+
depth: 1,
|
|
21
|
+
maxObjects: 2e4
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The most bytes a ready pack's build holds of objects at once, as a fetch's plan counts them,
|
|
25
|
+
* in a job that runs beside the host's requests.
|
|
26
|
+
*/
|
|
27
|
+
const readyBytesMost = 67108864;
|
|
28
|
+
/** The most shallow lines a ready row keeps, so the row stays well under a store's 1 MiB. */
|
|
29
|
+
const readyShallowsMost = 1e4;
|
|
30
|
+
/** How long a ready pack's build may take to write: a third of `git.repack`'s 15 minutes. */
|
|
31
|
+
const readyMilliseconds = 3e5;
|
|
32
|
+
const PackIdText = Schema.String.check(Schema.isPattern(/^p_[A-Za-z0-9_-]{16}$/));
|
|
33
|
+
/**
|
|
34
|
+
* The ready pack's row, in `ready` by `shallow`: what it was built from, the default branch's
|
|
35
|
+
* `tip`, its `depth` and its `tags`' digest, and the pack, if one was kept. A build past its
|
|
36
|
+
* limits keeps a row with no pack, so the next step doesn't build it again.
|
|
37
|
+
*/
|
|
38
|
+
const ReadyRow = Schema.Struct({
|
|
39
|
+
tip: Schema.String,
|
|
40
|
+
depth: Schema.Int,
|
|
41
|
+
tags: Schema.String,
|
|
42
|
+
pack: Schema.optionalKey(Schema.Struct({
|
|
43
|
+
id: PackIdText,
|
|
44
|
+
objects: Schema.Int,
|
|
45
|
+
bytes: Schema.Int,
|
|
46
|
+
/** The annotated tags `include-tag` added to it. */
|
|
47
|
+
tagged: Schema.Int,
|
|
48
|
+
shallow: Schema.Array(Schema.String)
|
|
49
|
+
}))
|
|
50
|
+
});
|
|
51
|
+
const readyKey = {
|
|
52
|
+
collection: objectCollections.ready,
|
|
53
|
+
id: "shallow"
|
|
54
|
+
};
|
|
55
|
+
const readyRow = (value) => ({
|
|
56
|
+
...readyKey,
|
|
57
|
+
value
|
|
58
|
+
});
|
|
59
|
+
/** The tags a fetch may follow, as one digest: the sorted IDs, each once, hashed. */
|
|
60
|
+
const tagsDigest = (tags) => {
|
|
61
|
+
const sha = new Sha1();
|
|
62
|
+
sha.update(new TextEncoder().encode([...new Set(tags)].sort().join("\n")));
|
|
63
|
+
return Hex.encode(sha.digest());
|
|
64
|
+
};
|
|
65
|
+
/** The fetch a ready pack answers: `git clone --depth <n>` of `tip`, its tags followed. */
|
|
66
|
+
const readyRequest = (tip, depth) => ({
|
|
67
|
+
wants: [tip],
|
|
68
|
+
haves: [],
|
|
69
|
+
shallows: [],
|
|
70
|
+
depth,
|
|
71
|
+
includeTag: true
|
|
72
|
+
});
|
|
73
|
+
const readOf = Effect.fnUntraced(function* (store, listed) {
|
|
74
|
+
const row = (yield* store.read({
|
|
75
|
+
scope: repoScope(listed.repo),
|
|
76
|
+
reads: [readyKey]
|
|
77
|
+
})).results[0]?.[0];
|
|
78
|
+
if (row === void 0) return void 0;
|
|
79
|
+
return yield* decodeRow(ReadyRow, row, "The ready shallow pack's row");
|
|
80
|
+
});
|
|
81
|
+
/**
|
|
82
|
+
* Whether a ready pack answers `input` exactly, as its plan would now: the one want its tip, no
|
|
83
|
+
* haves and no shallow commits, its depth, no `deepen-relative` and no filter, and `include-tag`
|
|
84
|
+
* over the same tags, so a tag a rule hides from the caller never reaches them. The objects a tip
|
|
85
|
+
* reaches never change, so a pack built for an older tip still answers a want of that tip.
|
|
86
|
+
*/
|
|
87
|
+
const answers = (ready, input) => {
|
|
88
|
+
const { request, limits } = input;
|
|
89
|
+
const pack = ready.pack;
|
|
90
|
+
if (pack === void 0) return false;
|
|
91
|
+
const tags = request.includeTag ? tagsDigest(input.tags ?? []) === ready.tags : pack.tagged === 0;
|
|
92
|
+
return new Set(request.wants).size === 1 && request.wants[0] === ready.tip && request.haves.length === 0 && request.shallows.length === 0 && request.depth === ready.depth && request.deepenRelative !== true && request.filter === void 0 && tags && pack.objects <= limits.objects && pack.bytes <= limits.bytes;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* `bytes`, ended as a planned pack's stream is: when `signal` aborts, its reader gets the signal's
|
|
96
|
+
* reason, and `left` milliseconds on, the writer's refusal for time naming `limits`. Either way the
|
|
97
|
+
* bucket's read is cancelled, so a client that's gone or past its time leaves no read running.
|
|
98
|
+
*/
|
|
99
|
+
const untilEnded = Effect.fnUntraced(function* (bytes, signal, left, limits) {
|
|
100
|
+
const reader = bytes.getReader();
|
|
101
|
+
let controller;
|
|
102
|
+
let stopped = false;
|
|
103
|
+
let timer;
|
|
104
|
+
const ended = () => {
|
|
105
|
+
stopped = true;
|
|
106
|
+
signal?.removeEventListener("abort", aborted);
|
|
107
|
+
if (timer !== void 0) forkIn(Fiber.interrupt(timer), noCall);
|
|
108
|
+
};
|
|
109
|
+
const timedOut = new PackWriteError({
|
|
110
|
+
fault: "time",
|
|
111
|
+
message: `the pack took past ${limits.milliseconds} ms`
|
|
112
|
+
});
|
|
113
|
+
/** The stream ended for the signal's reason, or past its time, its bucket read cancelled. */
|
|
114
|
+
const stop = (late) => {
|
|
115
|
+
if (stopped) return;
|
|
116
|
+
ended();
|
|
117
|
+
if (late) {
|
|
118
|
+
controller?.error(timedOut);
|
|
119
|
+
reader.cancel(timedOut).catch(() => void 0);
|
|
120
|
+
} else {
|
|
121
|
+
controller?.error(signal?.reason);
|
|
122
|
+
reader.cancel(signal?.reason).catch(() => void 0);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const aborted = () => stop(false);
|
|
126
|
+
const stream = new ReadableStream({
|
|
127
|
+
start: (each) => {
|
|
128
|
+
controller = each;
|
|
129
|
+
},
|
|
130
|
+
pull: async (each) => {
|
|
131
|
+
const read = await reader.read().catch((error) => {
|
|
132
|
+
ended();
|
|
133
|
+
throw error;
|
|
134
|
+
});
|
|
135
|
+
if (stopped) return;
|
|
136
|
+
if (!read.done) return each.enqueue(read.value);
|
|
137
|
+
ended();
|
|
138
|
+
each.close();
|
|
139
|
+
},
|
|
140
|
+
cancel: (reason) => {
|
|
141
|
+
ended();
|
|
142
|
+
return reader.cancel(reason);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
if (signal?.aborted === true) {
|
|
146
|
+
aborted();
|
|
147
|
+
return stream;
|
|
148
|
+
}
|
|
149
|
+
signal?.addEventListener("abort", aborted, { once: true });
|
|
150
|
+
timer = yield* Effect.forkDetach(Effect.andThen(Effect.sleep(Math.max(0, left)), Effect.sync(() => stop(true))));
|
|
151
|
+
if (stopped) yield* Fiber.interrupt(timer);
|
|
152
|
+
return stream;
|
|
153
|
+
});
|
|
154
|
+
/**
|
|
155
|
+
* The ready pack that answers `input` exactly, and its stream from the bucket, or `undefined`. Its
|
|
156
|
+
* one get is checked against `calls` before it's made.
|
|
157
|
+
*/
|
|
158
|
+
const readyOpened = Effect.fnUntraced(function* (store, bucket, listed, input, calls) {
|
|
159
|
+
const ready = yield* readOf(store, listed);
|
|
160
|
+
if (ready?.pack === void 0 || !answers(ready, input)) return void 0;
|
|
161
|
+
const { id, objects, shallow } = ready.pack;
|
|
162
|
+
if (!isPackId(id)) return void 0;
|
|
163
|
+
yield* callsAhead(calls, {
|
|
164
|
+
bucket: 1,
|
|
165
|
+
store: 0
|
|
166
|
+
}, input.request.haves.length === 0);
|
|
167
|
+
const bytes = yield* bucketStream(bucket, packFiles(id).pack, input.signal);
|
|
168
|
+
return bytes === void 0 ? void 0 : {
|
|
169
|
+
bytes,
|
|
170
|
+
objects,
|
|
171
|
+
shallow
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
/**
|
|
175
|
+
* The ready pack's answer to `input`, its bytes streamed from the bucket as they were written, or
|
|
176
|
+
* `undefined` when it doesn't answer it exactly, or its bytes are gone, and the fetch is planned.
|
|
177
|
+
* The fetch's one deadline, from `started`, holds the look-up and the stream, and the call's
|
|
178
|
+
* signal ends the stream, as each does a planned pack's. `calls` counts what the fetch made before.
|
|
179
|
+
*/
|
|
180
|
+
const readyAnswer = Effect.fnUntraced(function* (store, bucket, listed, input, started, calls) {
|
|
181
|
+
const { limits } = input;
|
|
182
|
+
const opened = yield* readyOpened(store, bucket, listed, input, calls).pipe(Effect.timeoutOrElse({
|
|
183
|
+
duration: Math.max(0, yield* timeLeft(limits, started)),
|
|
184
|
+
orElse: () => Effect.fail(planTooSlow(limits))
|
|
185
|
+
}));
|
|
186
|
+
if (opened === void 0) return void 0;
|
|
187
|
+
const left = yield* timeLeft(limits, started);
|
|
188
|
+
const pack = yield* untilEnded(opened.bytes, input.signal, left, limits);
|
|
189
|
+
return {
|
|
190
|
+
shallow: opened.shallow,
|
|
191
|
+
unshallow: [],
|
|
192
|
+
objects: opened.objects,
|
|
193
|
+
pack
|
|
194
|
+
};
|
|
195
|
+
});
|
|
196
|
+
const readyLimits = (shallow) => ({
|
|
197
|
+
objects: shallow.maxObjects,
|
|
198
|
+
bytes: readyBytesMost,
|
|
199
|
+
milliseconds: readyMilliseconds
|
|
200
|
+
});
|
|
201
|
+
/**
|
|
202
|
+
* The ready pack's plan, in the build's time from `started`, or `undefined` when it's past its
|
|
203
|
+
* limits or its row's.
|
|
204
|
+
*/
|
|
205
|
+
const readyPlan = Effect.fnUntraced(function* (input, shallow, tip, started) {
|
|
206
|
+
const request = readyRequest(tip, shallow.depth);
|
|
207
|
+
const limits = readyLimits(shallow);
|
|
208
|
+
const left = yield* timeLeft(limits, started);
|
|
209
|
+
const planned = yield* planFetchWithin(input.reads, {
|
|
210
|
+
request,
|
|
211
|
+
limits,
|
|
212
|
+
tags: input.tags
|
|
213
|
+
}, { left }).pipe(Effect.catchIf(isLimitRefusal, () => Effect.succeed(void 0)));
|
|
214
|
+
return planned !== void 0 && planned.deepened.shallow.length <= 1e4 ? planned : void 0;
|
|
215
|
+
});
|
|
216
|
+
/**
|
|
217
|
+
* `body` put to `key` as it's read, its parts charged as they go, as a merge's pack is: a put of
|
|
218
|
+
* no size past one part is a multipart upload, its calls more than one. A failed read or write
|
|
219
|
+
* aborts the put and cancels the rest of `body`.
|
|
220
|
+
*/
|
|
221
|
+
const putWhole = (bucket, key, body) => Effect.gen(function* () {
|
|
222
|
+
const put = yield* startPut(bucket, key);
|
|
223
|
+
const reader = body.getReader();
|
|
224
|
+
const sent = Effect.gen(function* () {
|
|
225
|
+
for (;;) {
|
|
226
|
+
const read = yield* bucketTry(() => reader.read());
|
|
227
|
+
if (read.done) return;
|
|
228
|
+
yield* put.write(read.value);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
const stopped = Effect.andThen(put.abort, Effect.promise(() => reader.cancel().catch(() => void 0)));
|
|
232
|
+
return yield* Effect.onError(Effect.andThen(sent, put.finish), () => stopped);
|
|
233
|
+
});
|
|
234
|
+
/**
|
|
235
|
+
* A plan's pack written to the bucket under a new `quarantine` row and marker, as a push's is, in
|
|
236
|
+
* what's left of the build's time from `started`: a step cut before its commit, or past that time,
|
|
237
|
+
* leaves the pack for clean-up.
|
|
238
|
+
*/
|
|
239
|
+
const keepPack = Effect.fnUntraced(function* (input, shallow, plan, started) {
|
|
240
|
+
const { store, bucket, listed, at, prune } = input;
|
|
241
|
+
const opened = yield* openQuarantine({
|
|
242
|
+
store,
|
|
243
|
+
bucket,
|
|
244
|
+
repo: listed.repo,
|
|
245
|
+
at,
|
|
246
|
+
prune
|
|
247
|
+
});
|
|
248
|
+
const limits = readyLimits(shallow);
|
|
249
|
+
const left = yield* timeLeft(limits, started);
|
|
250
|
+
const answer = yield* packOfPlan(input.reads, plan, limits, { left });
|
|
251
|
+
yield* putWhole(bucket, packFiles(opened.pack).pack, answer.pack);
|
|
252
|
+
const followed = plan.objects.filter((object) => object.kind === "tag").length;
|
|
253
|
+
return {
|
|
254
|
+
pack: {
|
|
255
|
+
id: opened.pack,
|
|
256
|
+
objects: plan.objects.length,
|
|
257
|
+
bytes: plan.bytes,
|
|
258
|
+
tagged: followed,
|
|
259
|
+
shallow: [...plan.deepened.shallow]
|
|
260
|
+
},
|
|
261
|
+
quarantine: opened.quarantine
|
|
262
|
+
};
|
|
263
|
+
});
|
|
264
|
+
/**
|
|
265
|
+
* `git.repack`'s step for the ready shallow pack, after clean-up's, as a change the core commits:
|
|
266
|
+
* - with the default branch's tip, its depth and its tags as the row says, nothing to do;
|
|
267
|
+
* - otherwise its pack is planned, and within its limits written to the bucket and its row put,
|
|
268
|
+
* its `quarantine` row gone; past them, its row put with no pack;
|
|
269
|
+
* - a pack the row named before leaves through a `leaving` row, so a clone still streaming it
|
|
270
|
+
* can finish, and clean-up ends its marker and bytes after;
|
|
271
|
+
* - with no tip, a deleted repo's or one whose default branch isn't there, or `shallow: false`,
|
|
272
|
+
* the row is deleted, its pack leaving.
|
|
273
|
+
* `undefined` when there is nothing to do.
|
|
274
|
+
*/
|
|
275
|
+
const readyStep = Effect.fnUntraced(function* (input) {
|
|
276
|
+
const { shallow, tip, at, prune } = input;
|
|
277
|
+
const ready = yield* readOf(input.store, input.listed);
|
|
278
|
+
const tags = tagsDigest(input.tags);
|
|
279
|
+
const due = removeAt(at, prune);
|
|
280
|
+
const put = [];
|
|
281
|
+
const del = [];
|
|
282
|
+
const old = ready?.pack;
|
|
283
|
+
if (old !== void 0 && isPackId(old.id)) put.push(leavingRow({
|
|
284
|
+
...old,
|
|
285
|
+
id: old.id
|
|
286
|
+
}, due));
|
|
287
|
+
if (shallow === false || tip === void 0) {
|
|
288
|
+
if (ready === void 0) return void 0;
|
|
289
|
+
const removed = {
|
|
290
|
+
change: {
|
|
291
|
+
put,
|
|
292
|
+
delete: [readyKey]
|
|
293
|
+
},
|
|
294
|
+
more: false
|
|
295
|
+
};
|
|
296
|
+
return old === void 0 ? removed : {
|
|
297
|
+
...removed,
|
|
298
|
+
due
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
if (ready?.tip === tip && ready.depth === shallow.depth && ready.tags === tags) return void 0;
|
|
302
|
+
const started = yield* Clock.currentTimeMillis;
|
|
303
|
+
const plan = yield* readyPlan(input, shallow, tip, started);
|
|
304
|
+
const value = {
|
|
305
|
+
tip,
|
|
306
|
+
depth: shallow.depth,
|
|
307
|
+
tags
|
|
308
|
+
};
|
|
309
|
+
const left = yield* timeLeft(readyLimits(shallow), started);
|
|
310
|
+
if (plan !== void 0 && left > 0) {
|
|
311
|
+
const kept = yield* keepPack(input, shallow, plan, started);
|
|
312
|
+
value.pack = kept.pack;
|
|
313
|
+
del.push(kept.quarantine);
|
|
314
|
+
}
|
|
315
|
+
put.push(readyRow(value));
|
|
316
|
+
const step = {
|
|
317
|
+
change: {
|
|
318
|
+
put,
|
|
319
|
+
delete: del
|
|
320
|
+
},
|
|
321
|
+
more: false
|
|
322
|
+
};
|
|
323
|
+
return old === void 0 ? step : {
|
|
324
|
+
...step,
|
|
325
|
+
due
|
|
326
|
+
};
|
|
327
|
+
});
|
|
328
|
+
export { ReadyRow, defaultShallow, readyAnswer, readyBytesMost, readyKey, readyRequest, readyShallowsMost, readyStep, tagsDigest, untilEnded };
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import "../protocol/objects/object.mjs";
|
|
2
|
+
import { fixedRoom } from "../protocol/packs/indexer.mjs";
|
|
3
|
+
import { gitError } from "../store/errors.mjs";
|
|
4
|
+
import { distinctIds } from "./distinct-ids.mjs";
|
|
5
|
+
import { drawnMix, heldCapacity, heldMemo } from "./held-memo.mjs";
|
|
6
|
+
import { mistyped, shallowRoot, wrongType } from "./links.mjs";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
// src/storage/receive-links.ts
|
|
9
|
+
/**
|
|
10
|
+
* The memo's room outside a memory budget, 6 MiB, and what `heldKept` is counted from. In
|
|
11
|
+
* `packs()`, the memo's room grows from its floor while the budget has room, to hold every link
|
|
12
|
+
* the push may look up, and shrinks back under load.
|
|
13
|
+
*/
|
|
14
|
+
const receiveHeldBytes = 6291456;
|
|
15
|
+
/**
|
|
16
|
+
* What a push's links hold, however many its trees name: the repo is asked which it holds
|
|
17
|
+
* `asked` at a time, and those it holds are remembered while the memo's room has space.
|
|
18
|
+
* The push is refused once it has asked of more links than `heldKept` and `lookupsEach` for each
|
|
19
|
+
* different object it has asked of.
|
|
20
|
+
*/
|
|
21
|
+
const receiveLinkLimits = {
|
|
22
|
+
/** Links asked of the repo at once: a multiple of the 100 rows one store read takes. */
|
|
23
|
+
asked: 4e3,
|
|
24
|
+
/**
|
|
25
|
+
* The lookups a push may make past four for each object, so a later link to one it remembers
|
|
26
|
+
* isn't counted again: as many as a memo keeps in `receiveHeldBytes`, 224,694. A pusher who mines
|
|
27
|
+
* IDs can make it keep fewer, each one more lookup; with random IDs it doesn't keep about 1.4.
|
|
28
|
+
*/
|
|
29
|
+
heldKept: heldCapacity(receiveHeldBytes),
|
|
30
|
+
/**
|
|
31
|
+
* Lookups for each different object asked of, past `heldKept`: a push asks of the repo at most
|
|
32
|
+
* `heldKept + lookupsEach × objects`, where `objects` counts the different IDs it asked of. Main
|
|
33
|
+
* asks each of those IDs once, so a push's lookups are at most `heldKept` and four times the IDs
|
|
34
|
+
* main asks: for Neon's 30 delta trees, 5.2 times main's store reads. Past the memo, a link to an
|
|
35
|
+
* object it forgot is asked again, and delta trees can repeat a link for a few bytes: this is
|
|
36
|
+
* what limits them. A pusher can't raise `objects` but by naming more objects: each is a link a
|
|
37
|
+
* tree's bytes name, and they're counted keyed by the memo's mix, drawn for each push, so
|
|
38
|
+
* IDs can't be mined to count high. The count is within 1.6% for one standard error.
|
|
39
|
+
*
|
|
40
|
+
* What Git takes and this refuses: a folder larger than the memo (224,694 entries), changed in
|
|
41
|
+
* many commits pushed at once. Each commit's copy of the folder asks again of the entries the
|
|
42
|
+
* memo forgot, so 10 commits changing a folder of 450,000 ask about 2,478,000 of 2,024,700. Four
|
|
43
|
+
* at a time ask 1,125,918 against the same limit and pass: push fewer commits at a time.
|
|
44
|
+
*/
|
|
45
|
+
lookupsEach: 4
|
|
46
|
+
};
|
|
47
|
+
/** The refusal of a push whose links asked of the repo `lookups` times, past `most`. */
|
|
48
|
+
const tooManyLookups = (lookups, objects, most) => gitError("RESOURCE_EXHAUSTED", `push's trees link about ${objects.toLocaleString("en-US")} objects outside the pack ${lookups.toLocaleString("en-US")} times; packs() storage looks them up at most ${most.toLocaleString("en-US")} times`, {
|
|
49
|
+
hint: "Push fewer commits at a time",
|
|
50
|
+
context: {
|
|
51
|
+
reason: "too-many-repeated-files",
|
|
52
|
+
total: lookups
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
/**
|
|
56
|
+
* The refusal of a push past its lookup limit after load held its memo smaller than it wanted,
|
|
57
|
+
* by a shrink or a refused grow: what the memo forgot, or never kept, was asked again, so the
|
|
58
|
+
* same push may pass on a quiet server (Q733).
|
|
59
|
+
*/
|
|
60
|
+
const lookupsBusy = gitError("UNAVAILABLE", "The server is busy: push again in a minute", {
|
|
61
|
+
hint: "Push again in a minute",
|
|
62
|
+
context: { reason: "busy" }
|
|
63
|
+
});
|
|
64
|
+
const earlier = (a, b) => a === void 0 || b.seq < a.seq ? b : a;
|
|
65
|
+
/**
|
|
66
|
+
* A push's links, checked as they're read: each names an object of the pack or the repo, of the
|
|
67
|
+
* type it says. It refuses as Git's connectivity check does once the pack is read, by the same
|
|
68
|
+
* link: the first, in the order of links, to an object neither holds, then a shallow client's
|
|
69
|
+
* parent neither holds, then the first first link to an object of another type, then the first
|
|
70
|
+
* later one, then a parent that isn't a commit.
|
|
71
|
+
*
|
|
72
|
+
* It holds an object for each link to one that may still come in the pack, and asks the repo in
|
|
73
|
+
* batches, as links are read and as the pack's objects come. Once more objects aren't the repo's
|
|
74
|
+
* than the pack has left to bring, one is missing: no later link is kept, and of those it holds
|
|
75
|
+
* only the first, one more than the pack has left to bring. Its memo of the repo's objects is in
|
|
76
|
+
* `room`, which keeps every link the push may look up while there's space: a later link to one it
|
|
77
|
+
* doesn't remember, past the room or evicted by a shrink, is asked again and counted as a first:
|
|
78
|
+
* so is which of two wrong links it names. Each ID asked of the repo counts as a lookup, and past
|
|
79
|
+
* the limit `receiveLinkLimits` says, of `heldKept` and `lookupsEach` for each different ID, the
|
|
80
|
+
* push is refused before it asks again: as busy when load held its memo smaller than it wanted
|
|
81
|
+
* during the push, by a shrink or a refused grow, since a quiet server's would have remembered
|
|
82
|
+
* more, and otherwise as too many lookups. The
|
|
83
|
+
* different IDs are counted by `distinctIds`, keyed by the memo's
|
|
84
|
+
* mix: each is a link a tree's bytes name, and a pusher can't choose them to count high.
|
|
85
|
+
*/
|
|
86
|
+
const receiveLinks = (reads, limits = receiveLinkLimits, room = fixedRoom(receiveHeldBytes)) => {
|
|
87
|
+
let seq = 0;
|
|
88
|
+
let overflowed = false;
|
|
89
|
+
const waiting = /* @__PURE__ */ new Map();
|
|
90
|
+
const outside = /* @__PURE__ */ new Map();
|
|
91
|
+
let outsideInOrder = [];
|
|
92
|
+
const mix = drawnMix();
|
|
93
|
+
const distinct = distinctIds(mix);
|
|
94
|
+
let lookups = 0;
|
|
95
|
+
let objects = 0;
|
|
96
|
+
const held = heldMemo({
|
|
97
|
+
room,
|
|
98
|
+
most: () => limits.heldKept + limits.lookupsEach * objects
|
|
99
|
+
}, mix);
|
|
100
|
+
const linked = /* @__PURE__ */ new Set();
|
|
101
|
+
let emptyLinked = false;
|
|
102
|
+
let firstWrong;
|
|
103
|
+
let laterWrong;
|
|
104
|
+
const judged = (oid, link, actual, first) => {
|
|
105
|
+
if (link.type === actual) return;
|
|
106
|
+
const wrong = {
|
|
107
|
+
...link,
|
|
108
|
+
oid,
|
|
109
|
+
actual
|
|
110
|
+
};
|
|
111
|
+
if (first) firstWrong = earlier(firstWrong, wrong);
|
|
112
|
+
else laterWrong = earlier(laterWrong, wrong);
|
|
113
|
+
};
|
|
114
|
+
const settled = (oid, open, actual) => {
|
|
115
|
+
judged(oid, open.first, actual, true);
|
|
116
|
+
if (open.other !== void 0) judged(oid, open.other, actual, false);
|
|
117
|
+
};
|
|
118
|
+
/** Whether a first link at `at` can still be the one a refusal names. */
|
|
119
|
+
const typed = (at) => firstWrong === void 0 || at < firstWrong.seq;
|
|
120
|
+
/**
|
|
121
|
+
* One link, `packed` the type of its object when the pack brought it already, leaving the pack
|
|
122
|
+
* `remaining` more to bring: the repo's answer to the links waiting, once `asking` says.
|
|
123
|
+
*/
|
|
124
|
+
const link = (named, packed, remaining) => {
|
|
125
|
+
if (overflowed) return void 0;
|
|
126
|
+
const { oid, type } = named;
|
|
127
|
+
const seen = {
|
|
128
|
+
seq: seq++,
|
|
129
|
+
type
|
|
130
|
+
};
|
|
131
|
+
if (oid === "4b825dc642cb6eb9a060e54bf8d69288fbee4904") {
|
|
132
|
+
judged(oid, seen, "tree", !emptyLinked);
|
|
133
|
+
emptyLinked = true;
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (packed !== void 0) {
|
|
137
|
+
judged(oid, seen, packed, !linked.has(oid));
|
|
138
|
+
linked.add(oid);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const actual = held.get(oid);
|
|
142
|
+
if (actual !== void 0) {
|
|
143
|
+
if (actual !== "unread") judged(oid, seen, actual, false);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const opened = waiting.get(oid) ?? outside.get(oid);
|
|
147
|
+
if (opened === void 0) waiting.set(oid, {
|
|
148
|
+
first: seen,
|
|
149
|
+
other: void 0
|
|
150
|
+
});
|
|
151
|
+
else if (opened.other === void 0 && type !== opened.first.type) opened.other = seen;
|
|
152
|
+
return asking(remaining);
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Keeps of the objects not the repo's the first, in the order of links, one more than the pack
|
|
156
|
+
* has left to bring, `open`: at most `open` of them come, so the first that never does is kept.
|
|
157
|
+
*/
|
|
158
|
+
const trim = (open) => {
|
|
159
|
+
while (outside.size > open + 1) {
|
|
160
|
+
const last = outsideInOrder.pop();
|
|
161
|
+
if (last === void 0) return;
|
|
162
|
+
outside.delete(last);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* One of the objects not the repo's is missing, as more aren't than the pack has left to bring:
|
|
167
|
+
* no later link is kept, and of those not the repo's only as many are kept as `trim` says.
|
|
168
|
+
*/
|
|
169
|
+
const overflow = (open) => {
|
|
170
|
+
overflowed = true;
|
|
171
|
+
held.clear();
|
|
172
|
+
linked.clear();
|
|
173
|
+
outsideInOrder = [...outside].sort(([, a], [, b]) => a.first.seq - b.first.seq).map(([oid]) => oid);
|
|
174
|
+
trim(open);
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* An object the pack brought, of `type`, leaving it `remaining` more to bring: the repo's answer
|
|
178
|
+
* to the links waiting, once `asking` says, as the pack's objects left to bring fall. Once
|
|
179
|
+
* overflowed, the push is refused as missing one, so an object that comes is only no longer so.
|
|
180
|
+
*/
|
|
181
|
+
const arrived = (oid, type, remaining) => {
|
|
182
|
+
if (overflowed) {
|
|
183
|
+
waiting.delete(oid);
|
|
184
|
+
outside.delete(oid);
|
|
185
|
+
trim(remaining);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const opened = waiting.get(oid) ?? outside.get(oid);
|
|
189
|
+
if (opened !== void 0) {
|
|
190
|
+
settled(oid, opened, type);
|
|
191
|
+
waiting.delete(oid);
|
|
192
|
+
outside.delete(oid);
|
|
193
|
+
linked.add(oid);
|
|
194
|
+
} else if (held.get(oid) !== void 0) linked.add(oid);
|
|
195
|
+
if (outside.size > remaining) overflow(remaining);
|
|
196
|
+
return asking(remaining);
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Counts `oids` as lookups, about to be asked of the repo, refused once they pass the limit
|
|
200
|
+
* `receiveLinks` says. The types the repo is asked of are of some of them, so as many at most.
|
|
201
|
+
*/
|
|
202
|
+
const counted = (oids) => {
|
|
203
|
+
if (oids.length === 0) return Effect.void;
|
|
204
|
+
lookups += oids.length;
|
|
205
|
+
for (const oid of oids) distinct.add(oid);
|
|
206
|
+
objects = Math.round(distinct.estimate());
|
|
207
|
+
const most = limits.heldKept + limits.lookupsEach * objects;
|
|
208
|
+
if (lookups <= most) return Effect.void;
|
|
209
|
+
return Effect.fail(held.constrained() ? lookupsBusy : tooManyLookups(lookups, objects, most));
|
|
210
|
+
};
|
|
211
|
+
/** Asks the repo which of `batch` it holds, and the types of those it does. */
|
|
212
|
+
const askBatch = Effect.fnUntraced(function* (batch) {
|
|
213
|
+
const oids = batch.map(([oid]) => oid);
|
|
214
|
+
yield* counted(oids);
|
|
215
|
+
const holds = yield* reads.has(oids);
|
|
216
|
+
const typing = batch.flatMap(([oid, open]) => holds.has(oid) && typed(open.first.seq) ? [oid] : []);
|
|
217
|
+
const types = typing.length === 0 ? /* @__PURE__ */ new Map() : yield* reads.typesOf(typing);
|
|
218
|
+
for (const [oid, open] of batch) {
|
|
219
|
+
if (!holds.has(oid)) {
|
|
220
|
+
outside.set(oid, open);
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
const actual = types.get(oid);
|
|
224
|
+
if (actual !== void 0) settled(oid, open, actual);
|
|
225
|
+
held.keep(oid, actual ?? "unread");
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
/** Takes the first `most` waiting links, or fewer if fewer wait. */
|
|
229
|
+
const taken = (most) => {
|
|
230
|
+
const batch = [];
|
|
231
|
+
for (const entry of waiting) {
|
|
232
|
+
if (batch.length === most) break;
|
|
233
|
+
batch.push(entry);
|
|
234
|
+
waiting.delete(entry[0]);
|
|
235
|
+
}
|
|
236
|
+
return batch;
|
|
237
|
+
};
|
|
238
|
+
/**
|
|
239
|
+
* Asks the repo of the waiting links, `asked` at a time, leaving fewer waiting than a batch: as
|
|
240
|
+
* many as the pack has left to bring may wait, and one call for all of them would hold their IDs
|
|
241
|
+
* and answers at once.
|
|
242
|
+
*/
|
|
243
|
+
const ask = Effect.fnUntraced(function* (remaining) {
|
|
244
|
+
while (waiting.size >= limits.asked) yield* askBatch(taken(limits.asked));
|
|
245
|
+
if (outside.size > remaining) overflow(remaining);
|
|
246
|
+
});
|
|
247
|
+
/**
|
|
248
|
+
* The repo's answer to the links waiting, when a batch waits and more objects may be outside the
|
|
249
|
+
* pack than it has left to bring, `remaining`, or `undefined`. Asking then keeps the links held
|
|
250
|
+
* within `remaining` and a batch.
|
|
251
|
+
*/
|
|
252
|
+
const asking = (remaining) => waiting.size >= limits.asked && waiting.size + outside.size > remaining ? ask(remaining) : void 0;
|
|
253
|
+
/** The first link, in order, to an object neither the pack nor the repo holds. */
|
|
254
|
+
const missing = () => {
|
|
255
|
+
let first;
|
|
256
|
+
for (const [oid, open] of outside) if (first === void 0 || open.first.seq < first.seq) first = {
|
|
257
|
+
oid,
|
|
258
|
+
seq: open.first.seq
|
|
259
|
+
};
|
|
260
|
+
return first?.oid;
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* Once the pack is read: refused as `receiveLinks` says, `parents` a shallow client's commits'
|
|
264
|
+
* parents and `packed` the type of each object the pack brought.
|
|
265
|
+
*/
|
|
266
|
+
const finish = Effect.fnUntraced(function* (parents, packed) {
|
|
267
|
+
while (waiting.size > 0) yield* askBatch(taken(limits.asked));
|
|
268
|
+
const lost = missing();
|
|
269
|
+
if (lost !== void 0) return yield* Effect.fail(gitError("INVALID_ARGUMENT", "missing necessary objects", { hint: `Push ${lost} and every object it needs` }));
|
|
270
|
+
const unheld = [...parents].filter((oid) => packed(oid) === void 0 && !(oid === "4b825dc642cb6eb9a060e54bf8d69288fbee4904" && emptyLinked));
|
|
271
|
+
yield* counted(unheld);
|
|
272
|
+
const parentsHeld = unheld.length === 0 ? /* @__PURE__ */ new Set() : yield* reads.has(unheld);
|
|
273
|
+
if (unheld.some((oid) => !parentsHeld.has(oid))) return yield* Effect.fail(shallowRoot());
|
|
274
|
+
const wrong = firstWrong ?? laterWrong;
|
|
275
|
+
if (wrong !== void 0) return yield* Effect.fail(wrongType(wrong, wrong.actual));
|
|
276
|
+
const kept = unheld.length === 0 ? /* @__PURE__ */ new Map() : yield* reads.typesOf(unheld);
|
|
277
|
+
const typeOf = (oid) => oid === "4b825dc642cb6eb9a060e54bf8d69288fbee4904" ? "tree" : packed(oid) ?? kept.get(oid);
|
|
278
|
+
const parent = mistyped([...parents].map((oid) => ({
|
|
279
|
+
oid,
|
|
280
|
+
type: "commit"
|
|
281
|
+
})), typeOf);
|
|
282
|
+
if (parent !== void 0) return yield* Effect.fail(parent);
|
|
283
|
+
});
|
|
284
|
+
/**
|
|
285
|
+
* Whether a link from one of the pack's objects named `oid`, one of its own: once it arrived, a
|
|
286
|
+
* link to it, or one before it came that it settled. One the repo was asked of and forgot isn't
|
|
287
|
+
* said, so a receive's roots may show too many, never too few.
|
|
288
|
+
*/
|
|
289
|
+
const named = (oid) => linked.has(oid);
|
|
290
|
+
return {
|
|
291
|
+
link,
|
|
292
|
+
arrived,
|
|
293
|
+
finish,
|
|
294
|
+
named
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
export { lookupsBusy, receiveHeldBytes, receiveLinkLimits, receiveLinks };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { collections } from "../store/scopes.mjs";
|
|
2
|
+
import { defineJob } from "@ref0/infra";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
// src/storage/repack-job.ts
|
|
5
|
+
/**
|
|
6
|
+
* `missed`: the commits of a step that drops objects that missed in a row, each because the
|
|
7
|
+
* version moved before it landed. Left out when none did.
|
|
8
|
+
*/
|
|
9
|
+
const RepackData = Schema.Struct({ missed: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))) });
|
|
10
|
+
const repackJobName = "git.repack";
|
|
11
|
+
/** One row per repo, so one try at a time across every process. */
|
|
12
|
+
const repackJobKey = "repack";
|
|
13
|
+
const repackJobSchema = Schema.toStandardSchemaV1(RepackData);
|
|
14
|
+
/**
|
|
15
|
+
* Makes `git.repack`'s rows, beside the rows that need it: a `quarantine` row's `add` and a
|
|
16
|
+
* `leaving` row's commit. The core's definition, with the same name and schema, runs them over
|
|
17
|
+
* the server's opened objects; this one is never registered.
|
|
18
|
+
*/
|
|
19
|
+
const repackRows = defineJob({
|
|
20
|
+
name: repackJobName,
|
|
21
|
+
schema: repackJobSchema,
|
|
22
|
+
handler: () => {
|
|
23
|
+
throw new TypeError(`'${repackJobName}' runs under the core's definition`);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
/** `git.repack` due at `at`; a repo's row keeps the earliest time it is saved for. */
|
|
27
|
+
const repackJobRow = (at) => repackRows.job({
|
|
28
|
+
key: repackJobKey,
|
|
29
|
+
data: {},
|
|
30
|
+
at
|
|
31
|
+
});
|
|
32
|
+
const Size = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
33
|
+
/**
|
|
34
|
+
* A repack run under way, while its host takes events: the repo's packs and their bytes when its
|
|
35
|
+
* first step began, and the bytes its steps have added since. Written in each step's own commit,
|
|
36
|
+
* and deleted by the last, which writes `repo.maintained` from it.
|
|
37
|
+
*/
|
|
38
|
+
const MaintenanceRun = Schema.Struct({
|
|
39
|
+
packs: Size,
|
|
40
|
+
bytes: Size,
|
|
41
|
+
added: Size
|
|
42
|
+
});
|
|
43
|
+
/** The run's row, beside the repo's own record: the core's alone. */
|
|
44
|
+
const maintenanceRunKey = {
|
|
45
|
+
collection: collections.repo,
|
|
46
|
+
id: "maintaining"
|
|
47
|
+
};
|
|
48
|
+
export { MaintenanceRun, RepackData, maintenanceRunKey, repackJobKey, repackJobName, repackJobRow, repackJobSchema };
|