@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,506 @@
|
|
|
1
|
+
import { decodeRow } from "../store/errors.mjs";
|
|
2
|
+
import { WholeRepo, wholeRef } from "../store/ref-rows.mjs";
|
|
3
|
+
import { collections, repoScope } from "../store/scopes.mjs";
|
|
4
|
+
import { isPackId, objectCollections } from "./layout.mjs";
|
|
5
|
+
import { mergedSize, writeMerged } from "./merge.mjs";
|
|
6
|
+
import { objectKey } from "./object-rows.mjs";
|
|
7
|
+
import { blockBytes, fixedReaderMemory, packReader } from "./pack-reads.mjs";
|
|
8
|
+
import { defaultRepack, groupObjects, groupWrites, leavingRows, loadAll, namedOf, replacing, rowsBytes, wholeRows, writeParts } from "./repack.mjs";
|
|
9
|
+
import { decodeHeld, pruneWait } from "./rows.mjs";
|
|
10
|
+
import { countedReads, lost } from "./walk.mjs";
|
|
11
|
+
import * as Effect from "effect/Effect";
|
|
12
|
+
import * as Schema from "effect/Schema";
|
|
13
|
+
import * as Data from "effect/Data";
|
|
14
|
+
import * as DateTime from "effect/DateTime";
|
|
15
|
+
// src/storage/prune.ts
|
|
16
|
+
/** A cruft pack's row, by its pack: when a prune pass found its objects unreached. */
|
|
17
|
+
const CruftRow = Schema.Struct({ since: Schema.Int });
|
|
18
|
+
/** The last prune pass's row: when its last step ran, so the next waits `prune` after it. */
|
|
19
|
+
const PrunePass = Schema.Struct({ at: Schema.Int });
|
|
20
|
+
const prunePassKey = {
|
|
21
|
+
collection: objectCollections.prune,
|
|
22
|
+
id: "pass"
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A pass's mark, put in a step of its own before the pass first walks: when it began, and when
|
|
26
|
+
* it waits until, if its walk has waited. A pass is under way while its mark is newer than the
|
|
27
|
+
* last pass's row, so a try that died in its walk is known by the retry after it (#662), which
|
|
28
|
+
* writes `waits`, the next period: till then no try walks, whatever its attempt. The pass's row
|
|
29
|
+
* ends it, and the next pass marks again.
|
|
30
|
+
*/
|
|
31
|
+
const PruneStarted = Schema.Struct({
|
|
32
|
+
at: Schema.Int,
|
|
33
|
+
waits: Schema.optional(Schema.Int)
|
|
34
|
+
});
|
|
35
|
+
const pruneStartedKey = {
|
|
36
|
+
collection: objectCollections.prune,
|
|
37
|
+
id: "started"
|
|
38
|
+
};
|
|
39
|
+
const cruftKey = (pack) => ({
|
|
40
|
+
collection: objectCollections.cruft,
|
|
41
|
+
id: pack
|
|
42
|
+
});
|
|
43
|
+
/** The repo's cruft packs, by pack, and its last pass. */
|
|
44
|
+
const readPrune = Effect.fnUntraced(function* (input) {
|
|
45
|
+
const [cruftRows = [], passRows = [], startedRows = []] = (yield* input.store.read({
|
|
46
|
+
scope: repoScope(input.listed.repo),
|
|
47
|
+
reads: [
|
|
48
|
+
{ collection: objectCollections.cruft },
|
|
49
|
+
prunePassKey,
|
|
50
|
+
pruneStartedKey
|
|
51
|
+
]
|
|
52
|
+
})).results;
|
|
53
|
+
const cruft = yield* Effect.forEach(cruftRows, (row) => decodeHeld(CruftRow, row));
|
|
54
|
+
const [passRow] = passRows;
|
|
55
|
+
const pass = passRow === void 0 ? void 0 : yield* decodeRow(PrunePass, passRow, "The last prune pass");
|
|
56
|
+
const [startedRow] = startedRows;
|
|
57
|
+
const started = startedRow === void 0 ? void 0 : yield* decodeRow(PruneStarted, startedRow, "The prune pass's mark");
|
|
58
|
+
return {
|
|
59
|
+
cruft: new Map(cruft.map((row) => [row.pack, row.value])),
|
|
60
|
+
pass,
|
|
61
|
+
started
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
/** The cruft row of `pack`, if it's a cruft pack. */
|
|
65
|
+
const cruftOf = (read, pack) => isPackId(pack.id) ? read.cruft.get(pack.id) : void 0;
|
|
66
|
+
/**
|
|
67
|
+
* What a walk reads on from `object`, apart: the history, a commit's parents, and the trees, a
|
|
68
|
+
* commit's tree and a tree's trees. A blob names nothing, so none is read: `walkFrom` reaches each
|
|
69
|
+
* by its ID. A tag's object may be a blob, so `walkFrom` takes it up in its next round, as it
|
|
70
|
+
* takes `start`.
|
|
71
|
+
*/
|
|
72
|
+
const linksOf = (object) => ({
|
|
73
|
+
history: object.type === "tag" ? [] : object.history,
|
|
74
|
+
trees: [...object.tree === void 0 ? [] : [object.tree], ...object.entries?.trees ?? []]
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* A walk's stop at its reads' cap, which never leaves `pruneStep`: a pass that meets it waits for
|
|
78
|
+
* the next (#662).
|
|
79
|
+
*/
|
|
80
|
+
var WalkCapped = class extends Data.TaggedError("WalkCapped") {};
|
|
81
|
+
/**
|
|
82
|
+
* `bucket`, each ranged read's bytes added to `read` before it's asked, and each read refused once
|
|
83
|
+
* they pass `most`: one batch of the walk, a delta's base resolved again for each of its objects,
|
|
84
|
+
* can't read past the cap before the walk next looks (#662).
|
|
85
|
+
*/
|
|
86
|
+
const counting = (bucket, read, most) => ({
|
|
87
|
+
multipart: bucket.multipart,
|
|
88
|
+
put: (key, body, options) => bucket.put(key, body, options),
|
|
89
|
+
read: (key, range, options) => {
|
|
90
|
+
if (read.bytes > most) return Promise.reject(/* @__PURE__ */ new Error(`The walk read past ${most} bytes`));
|
|
91
|
+
read.bytes += range?.length ?? 0;
|
|
92
|
+
return bucket.read(key, range, options);
|
|
93
|
+
},
|
|
94
|
+
delete: (key, options) => bucket.delete(key, options),
|
|
95
|
+
list: (prefix, page, options) => bucket.list(prefix, page, options)
|
|
96
|
+
});
|
|
97
|
+
/**
|
|
98
|
+
* Every object `start` reaches through `linksOf` but `skip`, read through `reads` in the order
|
|
99
|
+
* that keeps a large pack's walk within its few blocks (#662): the history first, each tree it
|
|
100
|
+
* names kept for after, then the trees a depth at a time, each depth in pack order. A walk from
|
|
101
|
+
* the tip a level at a time reads a commit and the trees new under it together, thousands of
|
|
102
|
+
* small levels across the pack, and its fixed blocks read each block again and again: svelte's
|
|
103
|
+
* first push read 41 blocks 1,487 times.
|
|
104
|
+
*/
|
|
105
|
+
const inOrder = Effect.fnUntraced(function* (reader, reads, start, skip, missing) {
|
|
106
|
+
const seen = /* @__PURE__ */ new Map();
|
|
107
|
+
const unseen = (oid) => !skip.has(oid) && !seen.has(oid);
|
|
108
|
+
let history = new Set(start.filter(unseen));
|
|
109
|
+
let trees = /* @__PURE__ */ new Set();
|
|
110
|
+
while (history.size > 0 || trees.size > 0) {
|
|
111
|
+
const commits = history.size > 0;
|
|
112
|
+
const level = [...commits ? history : trees].filter(unseen);
|
|
113
|
+
if (commits) history = /* @__PURE__ */ new Set();
|
|
114
|
+
else trees = /* @__PURE__ */ new Set();
|
|
115
|
+
const ordered = commits ? level : yield* reader.inPackOrder(level);
|
|
116
|
+
for (let at = 0; at < ordered.length; at += 64) {
|
|
117
|
+
const batch = ordered.slice(at, at + 64);
|
|
118
|
+
const found = yield* reads(batch);
|
|
119
|
+
for (const oid of batch) {
|
|
120
|
+
const object = found.get(oid);
|
|
121
|
+
if (object === void 0) {
|
|
122
|
+
const error = missing(oid);
|
|
123
|
+
if (error !== void 0) return yield* Effect.fail(error);
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
seen.set(oid, object);
|
|
127
|
+
const links = linksOf(object);
|
|
128
|
+
for (const link of links.history) if (unseen(link)) history.add(link);
|
|
129
|
+
for (const link of links.trees) if (unseen(link)) trees.add(link);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return seen;
|
|
134
|
+
});
|
|
135
|
+
/**
|
|
136
|
+
* Every object `start` reaches but `skip`, walked through the listed packs and rows in the order
|
|
137
|
+
* `inOrder` says; `missing` says what an object the repo doesn't hold does to the walk. Its ranged
|
|
138
|
+
* reads stop at the first past `walkReadsMost` times the listed packs' bytes, and the walk fails
|
|
139
|
+
* as `WalkCapped` whatever it failed on after them, so a pack whose order defeats the walk costs
|
|
140
|
+
* a try a bounded read, never all of it. Blobs are reached
|
|
141
|
+
* by their IDs, none of their bytes read, so one past the 16 MiB a read resolves whole is reached
|
|
142
|
+
* too: a whole blob `start` or a tag names by its entry's header, and one a tree names by its rows
|
|
143
|
+
* and the packs' indexes, where one they don't hold is `missing`. Each round walks from the last
|
|
144
|
+
* one's tags' objects, so a round more than the deepest chain of tags.
|
|
145
|
+
*/
|
|
146
|
+
const walkFrom = Effect.fnUntraced(function* (input, start, skip, missing) {
|
|
147
|
+
const objects = input.listed.packs.reduce((sum, pack) => sum + pack.objects, 0);
|
|
148
|
+
const packBytes = input.listed.packs.reduce((sum, pack) => sum + pack.bytes, 0);
|
|
149
|
+
const most = 2 * Math.max(packBytes, blockBytes);
|
|
150
|
+
const read = { bytes: 0 };
|
|
151
|
+
const bucket = counting(input.bucket, read, most);
|
|
152
|
+
const reader = packReader({
|
|
153
|
+
...input,
|
|
154
|
+
bucket,
|
|
155
|
+
memory: fixedReaderMemory()
|
|
156
|
+
});
|
|
157
|
+
const reads = countedReads(reader, objects + 1e6);
|
|
158
|
+
const capped = (effect) => Effect.mapError(effect, (error) => read.bytes > most ? new WalkCapped({ message: `its walk read past ${most} bytes of its packs` }) : error);
|
|
159
|
+
const reached = /* @__PURE__ */ new Set();
|
|
160
|
+
const named = /* @__PURE__ */ new Set();
|
|
161
|
+
for (let next = start; next.length > 0;) {
|
|
162
|
+
const fresh = [...new Set(next)].filter((oid) => !skip.has(oid) && !reached.has(oid));
|
|
163
|
+
const blobs = yield* capped(reader.wholeBlobs(fresh));
|
|
164
|
+
const passed = reached.size === 0 ? skip : /* @__PURE__ */ new Set([...skip, ...reached]);
|
|
165
|
+
const walked = yield* capped(inOrder(reader, reads, fresh.filter((oid) => !blobs.has(oid)), passed, missing));
|
|
166
|
+
for (const oid of [...blobs, ...walked.keys()]) reached.add(oid);
|
|
167
|
+
for (const object of walked.values()) for (const oid of object.entries?.blobs ?? []) named.add(oid);
|
|
168
|
+
next = [...walked.values()].flatMap((object) => object.type === "tag" ? object.history : []);
|
|
169
|
+
}
|
|
170
|
+
const unseen = [...named].filter((oid) => !reached.has(oid) && !skip.has(oid));
|
|
171
|
+
const held = unseen.length === 0 ? /* @__PURE__ */ new Set() : yield* capped(reader.has(unseen));
|
|
172
|
+
for (const oid of unseen) {
|
|
173
|
+
if (held.has(oid)) {
|
|
174
|
+
reached.add(oid);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const error = missing(oid);
|
|
178
|
+
if (error !== void 0) return yield* Effect.fail(error);
|
|
179
|
+
}
|
|
180
|
+
return reached;
|
|
181
|
+
});
|
|
182
|
+
/** Prune keeps what any ref reaches, private or not: it reads the repo's refs whole. */
|
|
183
|
+
const pruneWhole = WholeRepo.mint();
|
|
184
|
+
/** Every object a ref reaches. */
|
|
185
|
+
const reachable = Effect.fnUntraced(function* (input) {
|
|
186
|
+
const snapshot = yield* input.store.read({
|
|
187
|
+
scope: repoScope(input.listed.repo),
|
|
188
|
+
reads: [{ collection: collections.refs }]
|
|
189
|
+
});
|
|
190
|
+
const refs = yield* Effect.forEach(snapshot.results[0] ?? [], (row) => wholeRef(pruneWhole, row));
|
|
191
|
+
return yield* walkFrom(input, [...new Set(refs)], /* @__PURE__ */ new Set(), lost);
|
|
192
|
+
});
|
|
193
|
+
/** Every object `packs` hold. */
|
|
194
|
+
const oidsOf = (packs) => packs.flatMap(({ index }) => Array.from({ length: index.count }, (_, rank) => index.oidAt(rank)));
|
|
195
|
+
const holds = (packs) => (oid) => packs.some((indexed) => indexed.index.find(oid) !== void 0);
|
|
196
|
+
/**
|
|
197
|
+
* A pass's first step, as Git 2.37's cruft packs: the objects of every listed pack but the cruft
|
|
198
|
+
* packs, and of the object rows, that no ref reaches, written as one cruft pack with a `cruft`
|
|
199
|
+
* row of now. It only adds, so a push beside it loses nothing. `undefined` when every object is
|
|
200
|
+
* reached.
|
|
201
|
+
*/
|
|
202
|
+
const cruftStep = Effect.fnUntraced(function* (input, read, objectRows, reached, most) {
|
|
203
|
+
const packs = input.listed.packs.filter((pack) => cruftOf(read, pack) === void 0);
|
|
204
|
+
const merged = yield* writeMerged({
|
|
205
|
+
...writeParts(input),
|
|
206
|
+
inputs: yield* loadAll(input, packs),
|
|
207
|
+
rows: yield* wholeRows(objectRows),
|
|
208
|
+
keep: (oid) => !reached.has(oid),
|
|
209
|
+
most
|
|
210
|
+
});
|
|
211
|
+
if (merged === void 0 || merged === "too big") return merged;
|
|
212
|
+
const { id } = yield* namedOf(merged.pack);
|
|
213
|
+
return {
|
|
214
|
+
change: {
|
|
215
|
+
add: [merged.pack],
|
|
216
|
+
put: [{
|
|
217
|
+
...cruftKey(id),
|
|
218
|
+
value: { since: input.at }
|
|
219
|
+
}],
|
|
220
|
+
delete: [merged.quarantine]
|
|
221
|
+
},
|
|
222
|
+
more: true,
|
|
223
|
+
quarantine: merged.quarantine
|
|
224
|
+
};
|
|
225
|
+
});
|
|
226
|
+
/**
|
|
227
|
+
* The packs a pass step takes: the cruft packs `prune` hasn't passed are `young`, which it only
|
|
228
|
+
* indexes, and so is every cruft pack when `drops` is false.
|
|
229
|
+
*/
|
|
230
|
+
const passPacks = (input, prune, read, drops) => {
|
|
231
|
+
const isOld = (since) => drops && since + pruneWait(prune) <= input.at;
|
|
232
|
+
const young = input.listed.packs.filter((pack) => {
|
|
233
|
+
const cruft = cruftOf(read, pack);
|
|
234
|
+
return cruft !== void 0 && !isOld(cruft.since);
|
|
235
|
+
});
|
|
236
|
+
const merging = input.listed.packs.filter((pack) => !young.includes(pack));
|
|
237
|
+
return {
|
|
238
|
+
young,
|
|
239
|
+
merging,
|
|
240
|
+
old: merging.filter((pack) => cruftOf(read, pack) !== void 0)
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
* A pass step's commit writes: two for each pack it merges, its row's delete and its `leaving`
|
|
245
|
+
* row, one for each old cruft pack's row and each object row it folds, and its pack's add, its
|
|
246
|
+
* `quarantine` row's delete and the pass's row.
|
|
247
|
+
*/
|
|
248
|
+
const passWrites = ({ merging, old }, objectRows) => 2 * merging.length + old.length + objectRows.length + 3;
|
|
249
|
+
/**
|
|
250
|
+
* What a pass step merges: `merging`'s packs and the rows, keeping what a ref reaches and what no
|
|
251
|
+
* young cruft pack holds. With `cruftFirst`, it's the pass that follows a cruft step not yet
|
|
252
|
+
* written, whose pack is young too and holds every unreached object of the other packs and the
|
|
253
|
+
* rows, so those go.
|
|
254
|
+
*/
|
|
255
|
+
const passMerge = Effect.fnUntraced(function* (input, { young, merging, old }, rows, reached, cruftFirst) {
|
|
256
|
+
const inputs = yield* loadAll(input, merging);
|
|
257
|
+
const youngIndexed = yield* loadAll(input, young);
|
|
258
|
+
const fresh = yield* loadAll(input, merging.filter((pack) => !old.includes(pack)));
|
|
259
|
+
const inYoung = holds(youngIndexed);
|
|
260
|
+
const inFresh = holds(fresh);
|
|
261
|
+
const rowOids = new Set(rows.map((row) => row.oid));
|
|
262
|
+
const needed = old.length === 0 ? /* @__PURE__ */ new Set() : yield* walkFrom(input, [
|
|
263
|
+
...oidsOf(youngIndexed),
|
|
264
|
+
...oidsOf(fresh),
|
|
265
|
+
...rowOids
|
|
266
|
+
].filter((oid) => !reached.has(oid)), reached, () => void 0);
|
|
267
|
+
const unheld = (oid) => !cruftFirst || !inFresh(oid) && !rowOids.has(oid);
|
|
268
|
+
const keep = (oid) => reached.has(oid) || !inYoung(oid) && unheld(oid) && (inFresh(oid) || rowOids.has(oid) || needed.has(oid));
|
|
269
|
+
return {
|
|
270
|
+
inputs,
|
|
271
|
+
keep
|
|
272
|
+
};
|
|
273
|
+
});
|
|
274
|
+
/**
|
|
275
|
+
* Whether a pass step whose packs out of cruft are those `packs` and `rows` keep, as `keep` says,
|
|
276
|
+
* leaves both halves of the repo's mark, as `ReachedMark` says: each object they keep is one a ref
|
|
277
|
+
* reaches, and each a ref reaches is in them, none only in a young cruft pack, as one is that a
|
|
278
|
+
* ref reached again after its cruft step, until the pass that finds its pack old (#647). The merge
|
|
279
|
+
* writes only what `keep` keeps, so a reached object it drops leaves the mark off too. Exported
|
|
280
|
+
* for its test alone: `passStep`'s `keep` keeps every reached object, so no pass reaches that case.
|
|
281
|
+
*/
|
|
282
|
+
const reachesOnly = (packs, rows, reached, keep) => {
|
|
283
|
+
const fits = (oid) => reached.has(oid) || !keep(oid);
|
|
284
|
+
for (const { index } of packs) for (let rank = 0; rank < index.count; rank += 1) if (!fits(index.oidAt(rank))) return false;
|
|
285
|
+
if (!rows.every(({ oid }) => fits(oid))) return false;
|
|
286
|
+
const inPacks = holds(packs);
|
|
287
|
+
const rowOids = new Set(rows.map(({ oid }) => oid));
|
|
288
|
+
for (const oid of reached) if (!keep(oid) || !rowOids.has(oid) && !inPacks(oid)) return false;
|
|
289
|
+
return true;
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* A pass's last step, its own commit after the cruft step's: every listed pack but the `young`
|
|
293
|
+
* cruft packs, and the object rows, merged into one pack of what a ref reaches
|
|
294
|
+
* now and of what no cruft pack holds, so an object left unreached since the first step waits
|
|
295
|
+
* for the next pass; a lone member is left as it is only when the pass `written` no cruft pack.
|
|
296
|
+
* A cruft pack past `prune` goes, and with it what of its objects no ref reaches again and no
|
|
297
|
+
* younger object names, however deep: then the step `drops`, so its commit lands only at the
|
|
298
|
+
* version the core read, and moves the repo's `pruned` mark. The pass's row says when it ran. A
|
|
299
|
+
* pass that replaced packs steps again, as a merge does. It runs only once one read holds every
|
|
300
|
+
* object row, as `pruneStep` says.
|
|
301
|
+
*/
|
|
302
|
+
const passStep = Effect.fnUntraced(function* (input, { young, merging, old }, objectRows, reached, written, most) {
|
|
303
|
+
const pass = [{
|
|
304
|
+
...prunePassKey,
|
|
305
|
+
value: { at: input.at }
|
|
306
|
+
}];
|
|
307
|
+
const rows = yield* wholeRows(objectRows);
|
|
308
|
+
if (!written && old.length === 0 && merging.length + (rows.length === 0 ? 0 : 1) < 2) {
|
|
309
|
+
const lone = {
|
|
310
|
+
change: { put: pass },
|
|
311
|
+
more: false
|
|
312
|
+
};
|
|
313
|
+
if (reachesOnly(yield* loadAll(input, merging), rows, reached, () => true)) lone.reaches = true;
|
|
314
|
+
return lone;
|
|
315
|
+
}
|
|
316
|
+
const { inputs, keep } = yield* passMerge(input, {
|
|
317
|
+
young,
|
|
318
|
+
merging,
|
|
319
|
+
old
|
|
320
|
+
}, rows, reached, false);
|
|
321
|
+
const merged = yield* writeMerged({
|
|
322
|
+
...writeParts(input),
|
|
323
|
+
inputs,
|
|
324
|
+
rows,
|
|
325
|
+
keep,
|
|
326
|
+
most
|
|
327
|
+
});
|
|
328
|
+
if (merged === "too big") return merged;
|
|
329
|
+
const removed = yield* Effect.forEach(merging, namedOf);
|
|
330
|
+
const ended = yield* Effect.forEach(old, (pack) => Effect.map(namedOf(pack), (named) => cruftKey(named.id)));
|
|
331
|
+
const step = {
|
|
332
|
+
change: {
|
|
333
|
+
add: merged === void 0 ? [] : [merged.pack],
|
|
334
|
+
remove: removed.map((pack) => pack.id),
|
|
335
|
+
put: [...leavingRows(input, removed), ...pass],
|
|
336
|
+
delete: [
|
|
337
|
+
...merged === void 0 ? [] : [merged.quarantine],
|
|
338
|
+
...rows.map((row) => objectKey(row.oid)),
|
|
339
|
+
...ended
|
|
340
|
+
]
|
|
341
|
+
},
|
|
342
|
+
more: removed.length > 0
|
|
343
|
+
};
|
|
344
|
+
if (merged !== void 0) step.quarantine = merged.quarantine;
|
|
345
|
+
if (old.length > 0) step.drops = true;
|
|
346
|
+
if (reachesOnly(inputs, rows, reached, keep)) step.reaches = true;
|
|
347
|
+
return step;
|
|
348
|
+
});
|
|
349
|
+
/**
|
|
350
|
+
* Whether a pass whose cruft step is next can finish: the objects the cruft step copies keep the
|
|
351
|
+
* repo within `groupObjects`, and the pass step after it, planned with that cruft pack young,
|
|
352
|
+
* fits `most`, its whole objects included. Nothing is written.
|
|
353
|
+
*/
|
|
354
|
+
const startsWhole = Effect.fnUntraced(function* (input, read, packs, objectRows, reached, held, most) {
|
|
355
|
+
const { blocks } = writeParts(input);
|
|
356
|
+
const rows = yield* wholeRows(objectRows);
|
|
357
|
+
const sources = input.listed.packs.filter((pack) => cruftOf(read, pack) === void 0);
|
|
358
|
+
const inputs = yield* loadAll(input, sources);
|
|
359
|
+
const copies = yield* mergedSize({
|
|
360
|
+
blocks,
|
|
361
|
+
inputs,
|
|
362
|
+
rows,
|
|
363
|
+
keep: (oid) => !reached.has(oid)
|
|
364
|
+
});
|
|
365
|
+
if (copies.bytes > most || held + copies.objects > 2e5) return false;
|
|
366
|
+
if (copies.objects === 0) return true;
|
|
367
|
+
const pass = yield* passMerge(input, packs, rows, reached, true);
|
|
368
|
+
return (yield* mergedSize({
|
|
369
|
+
blocks,
|
|
370
|
+
...pass,
|
|
371
|
+
rows
|
|
372
|
+
})).bytes <= most;
|
|
373
|
+
});
|
|
374
|
+
/**
|
|
375
|
+
* A due pass's step while one read holds only some object rows: the rows it read, folded into a
|
|
376
|
+
* pack of their own, with no walk. A row it didn't read may name an old cruft object, and the
|
|
377
|
+
* repo's objects can't be counted, so the pass waits for these steps to fold the rows until one
|
|
378
|
+
* read holds them all.
|
|
379
|
+
*/
|
|
380
|
+
const foldStep = Effect.fnUntraced(function* (input, objectRows, most) {
|
|
381
|
+
const rows = yield* wholeRows(objectRows);
|
|
382
|
+
const merged = yield* writeMerged({
|
|
383
|
+
...writeParts(input),
|
|
384
|
+
inputs: [],
|
|
385
|
+
rows,
|
|
386
|
+
most
|
|
387
|
+
});
|
|
388
|
+
if (merged === void 0 || merged === "too big") return void 0;
|
|
389
|
+
return {
|
|
390
|
+
change: replacing(input, merged, [], rows),
|
|
391
|
+
more: true,
|
|
392
|
+
quarantine: merged.quarantine
|
|
393
|
+
};
|
|
394
|
+
});
|
|
395
|
+
/**
|
|
396
|
+
* Whether a step fits as a geometric group does: the `packs` it merges and the object rows
|
|
397
|
+
* within `most` bytes, and its commit's `writes` within `groupWrites`.
|
|
398
|
+
*/
|
|
399
|
+
const fits = (packs, objectRows, most, writes) => packs.reduce((sum, pack) => sum + pack.bytes, 0) + rowsBytes(objectRows) <= most && writes <= groupWrites;
|
|
400
|
+
/**
|
|
401
|
+
* A marked pass's walk and the step it makes: the cruft step first, then the pass step, or why
|
|
402
|
+
* the pass waits. A merge's chains may need objects written whole, which `fits` doesn't count, so
|
|
403
|
+
* before a cruft step the pass plans both merges as they'll be written: the cruft step's copies,
|
|
404
|
+
* which the repo must still hold within `groupObjects`, and the pass after it, within `most`.
|
|
405
|
+
*/
|
|
406
|
+
const passSteps = Effect.fnUntraced(function* (input, read, packs, rows, held, pending, most) {
|
|
407
|
+
const reached = yield* reachable(input);
|
|
408
|
+
const sources = input.listed.packs.filter((pack) => cruftOf(read, pack) === void 0);
|
|
409
|
+
const copied = [...oidsOf(yield* loadAll(input, sources)), ...rows.map((row) => row.id)];
|
|
410
|
+
const cruftless = pending || copied.every((oid) => reached.has(oid));
|
|
411
|
+
if (!cruftless && !(yield* startsWhole(input, read, packs, rows, reached, held, most))) return { waits: "its cruft and pass steps won't both fit" };
|
|
412
|
+
const cruft = cruftless ? void 0 : yield* cruftStep(input, read, rows, reached, most);
|
|
413
|
+
if (cruft === "too big") return { waits: "its cruft pack is past the pack size" };
|
|
414
|
+
if (cruft !== void 0) return { cruft };
|
|
415
|
+
const pass = yield* passStep(input, packs, rows, reached, pending, most);
|
|
416
|
+
if (pass === "too big") return { waits: "its pack is past the pack size" };
|
|
417
|
+
return { pass };
|
|
418
|
+
});
|
|
419
|
+
/** A moment as ISO 8601, for a log line. */
|
|
420
|
+
const iso = (at) => DateTime.formatIso(DateTime.makeUnsafe(at));
|
|
421
|
+
/**
|
|
422
|
+
* Upkeep's prune, as Q270 says: a pass at most once each `prune`, when each of its steps fits
|
|
423
|
+
* as `fits` says, and the repo holds at most `groupObjects` objects, since its walk holds an entry
|
|
424
|
+
* for each it reaches, as a merge does. Past one read of object rows, `foldStep`s come first. A
|
|
425
|
+
* pass is a step that marks it, then two steps, each one pack under its own `quarantine` row and
|
|
426
|
+
* its own commit: the cruft step, then the pass step, which runs while a cruft pack is newer than
|
|
427
|
+
* the last pass. With `drops` false, the pass leaves every cruft pack. A marked pass whose try is
|
|
428
|
+
* `retried`, after one that died or failed, waits for the next period, as does one whose walk
|
|
429
|
+
* meets its reads' cap or makes no step: each writes the wait to its mark, with a log line. A
|
|
430
|
+
* pass that waits before its walk logs too, and writes nothing. `step` is `undefined` when no pass
|
|
431
|
+
* is due; `next` is when the next one is, and `undefined` for a repo that holds no object.
|
|
432
|
+
*/
|
|
433
|
+
const pruneStep = Effect.fnUntraced(function* (input, prune, repack, read, objectRows, drops, retried = false) {
|
|
434
|
+
if (input.listed.packs.length === 0 && objectRows.rows.length === 0) return {
|
|
435
|
+
step: void 0,
|
|
436
|
+
next: void 0
|
|
437
|
+
};
|
|
438
|
+
const last = read.pass?.at;
|
|
439
|
+
const next = last === void 0 ? input.at : last + pruneWait(prune);
|
|
440
|
+
const pending = [...read.cruft.values()].some((cruft) => last === void 0 || cruft.since > last);
|
|
441
|
+
if (!pending && next > input.at) return {
|
|
442
|
+
step: void 0,
|
|
443
|
+
next
|
|
444
|
+
};
|
|
445
|
+
const most = (repack === false ? void 0 : repack.maxPackSize) ?? defaultRepack.maxPackSize;
|
|
446
|
+
const until = input.at + pruneWait(prune);
|
|
447
|
+
const later = (why) => Effect.as(Effect.logWarning(`git.repack's prune pass of repo ${input.listed.repo}, due ${iso(next)}, waits until ${iso(until)}: ${why}`), {
|
|
448
|
+
step: void 0,
|
|
449
|
+
next: until
|
|
450
|
+
});
|
|
451
|
+
const { rows } = objectRows;
|
|
452
|
+
if (!objectRows.whole) {
|
|
453
|
+
const fold = yield* foldStep(input, rows, most);
|
|
454
|
+
return fold === void 0 ? yield* later("its object rows fold into no pack") : {
|
|
455
|
+
step: fold,
|
|
456
|
+
next
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
const held = input.listed.packs.reduce((sum, pack) => sum + pack.objects, rows.length);
|
|
460
|
+
if (held > 2e5) return yield* later(`it holds ${held} objects, past the ${groupObjects} a walk holds`);
|
|
461
|
+
const packs = passPacks(input, prune, read, drops);
|
|
462
|
+
if (!fits(packs.merging, rows, most, passWrites(packs, rows))) return yield* later("its merge won't fit one step");
|
|
463
|
+
const { started } = read;
|
|
464
|
+
if (!(started !== void 0 && (last === void 0 || started.at > last))) return {
|
|
465
|
+
step: {
|
|
466
|
+
change: { put: [{
|
|
467
|
+
...pruneStartedKey,
|
|
468
|
+
value: { at: input.at }
|
|
469
|
+
}] },
|
|
470
|
+
more: true
|
|
471
|
+
},
|
|
472
|
+
next
|
|
473
|
+
};
|
|
474
|
+
if (started.waits !== void 0 && started.waits > input.at) return {
|
|
475
|
+
step: void 0,
|
|
476
|
+
next: started.waits
|
|
477
|
+
};
|
|
478
|
+
const waits = (why) => Effect.as(later(why), {
|
|
479
|
+
step: {
|
|
480
|
+
change: { put: [{
|
|
481
|
+
...pruneStartedKey,
|
|
482
|
+
value: {
|
|
483
|
+
at: started.at,
|
|
484
|
+
waits: until
|
|
485
|
+
}
|
|
486
|
+
}] },
|
|
487
|
+
more: true
|
|
488
|
+
},
|
|
489
|
+
next: until
|
|
490
|
+
});
|
|
491
|
+
if (retried) return yield* waits("its last try died or failed with the pass under way");
|
|
492
|
+
const stepped = yield* passSteps(input, read, packs, rows, held, pending, most).pipe(Effect.catchTag("WalkCapped", (capped) => Effect.succeed({ waits: capped.message })));
|
|
493
|
+
if ("waits" in stepped) return yield* waits(stepped.waits);
|
|
494
|
+
if ("cruft" in stepped) return {
|
|
495
|
+
step: stepped.cruft,
|
|
496
|
+
next
|
|
497
|
+
};
|
|
498
|
+
return {
|
|
499
|
+
step: {
|
|
500
|
+
...stepped.pass,
|
|
501
|
+
due: until
|
|
502
|
+
},
|
|
503
|
+
next: until
|
|
504
|
+
};
|
|
505
|
+
});
|
|
506
|
+
export { CruftRow, PrunePass, PruneStarted, cruftOf, inOrder, prunePassKey, pruneStartedKey, pruneStep, reachesOnly, readPrune };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { gitError } from "../store/errors.mjs";
|
|
2
|
+
import { openTreeBytes, openTreesFloorBytes, pushReaderFloorsOf } from "./budget.mjs";
|
|
3
|
+
import { readBusy } from "./memory-budget.mjs";
|
|
4
|
+
import { noCall, runIn, runnerIn } from "../store/crossing.mjs";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
// src/storage/push-allotment.ts
|
|
7
|
+
/**
|
|
8
|
+
* The refusal a push's tree walk gets when its open trees found no room within `growWaitMs`. Git
|
|
9
|
+
* shows it as the push's error, so it says what to do.
|
|
10
|
+
*/
|
|
11
|
+
const treesBusy = gitError("UNAVAILABLE", "The server is busy: push again in a minute", {
|
|
12
|
+
hint: "Push again in a minute",
|
|
13
|
+
context: { reason: "busy" }
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* The refusal a tree walk gets past `openTreeBytes` open at once: the push's folders are too deep
|
|
17
|
+
* or too wide to check.
|
|
18
|
+
*/
|
|
19
|
+
const openTreesRefusal = gitError("RESOURCE_EXHAUSTED", `This push's folders are too deep or too wide for the file rule to check: checking them would take more than ${openTreeBytes / 1048576} MiB at once`, {
|
|
20
|
+
hint: "Push to a branch no file rule covers, or ask the host to check it another way",
|
|
21
|
+
context: { reason: "diff-limit" }
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* `packs()`' push allotment: what its receive's allotment keeps past the answer for the push's
|
|
25
|
+
* rules, on an allotment of its own. It holds a floor for the reader of the repo with the push's
|
|
26
|
+
* pack and one for the reader of its pack alone, each taken once, its open trees' floor, and what
|
|
27
|
+
* its pointers hold. Open trees grow past their floor from free bytes to `openTreeBytes`, waiting
|
|
28
|
+
* `growWaitMs` at most. Core releases it in `pushOnto`'s scope; a release is idempotent.
|
|
29
|
+
*/
|
|
30
|
+
var PacksAllotment = class {
|
|
31
|
+
#allotment;
|
|
32
|
+
#floors;
|
|
33
|
+
#taken = {
|
|
34
|
+
repo: false,
|
|
35
|
+
own: false
|
|
36
|
+
};
|
|
37
|
+
/** What the walk holds open, as its grows and shrinks say. */
|
|
38
|
+
#trees = 0;
|
|
39
|
+
/** What the allotment grew past the open trees' floor for them. */
|
|
40
|
+
#grown = 0;
|
|
41
|
+
/** Runs a grow's wait as a Promise, on the clock of the receive that made it. */
|
|
42
|
+
#run;
|
|
43
|
+
/** `context`: the receive's, whose clock a grow's wait runs on. */
|
|
44
|
+
constructor(allotment, size, context) {
|
|
45
|
+
this.#allotment = allotment;
|
|
46
|
+
this.#run = context === void 0 ? (effect) => runIn(effect, noCall) : runnerIn(context);
|
|
47
|
+
this.#floors = {
|
|
48
|
+
repo: pushReaderFloorsOf(size, false),
|
|
49
|
+
own: pushReaderFloorsOf(size, true)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** What it holds now, its readers' floors still in it until they're taken. */
|
|
53
|
+
get bytes() {
|
|
54
|
+
return this.#allotment.bytes;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The allotment for a reader of the repo, or of the push's pack alone when `listedOnly`: its
|
|
58
|
+
* floors, moved out of this allotment, the first time each is asked for. After that, or once it's
|
|
59
|
+
* released, none: that reader is allotted as a read is.
|
|
60
|
+
*/
|
|
61
|
+
take(listedOnly) {
|
|
62
|
+
const slot = listedOnly ? "own" : "repo";
|
|
63
|
+
if (this.#taken[slot] || this.#allotment.released) return void 0;
|
|
64
|
+
this.#taken[slot] = true;
|
|
65
|
+
const floors = this.#floors[slot];
|
|
66
|
+
return {
|
|
67
|
+
allotment: this.#allotment.keep(floors.cache + floors.blocks, readBusy),
|
|
68
|
+
floors
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The walk holds `bytes` more open: within the floor at once, with no wait; past it, at once
|
|
73
|
+
* when free bytes cover it, else a Promise of the grow's answer within `growWaitMs`. Past
|
|
74
|
+
* `openTreeBytes`, refused.
|
|
75
|
+
*/
|
|
76
|
+
grow = (bytes) => {
|
|
77
|
+
const trees = this.#trees + bytes;
|
|
78
|
+
if (trees > 8388608) return openTreesRefusal;
|
|
79
|
+
const needed = trees - openTreesFloorBytes - this.#grown;
|
|
80
|
+
if (needed <= 0 || this.#allotment.tryGrow(needed)) {
|
|
81
|
+
this.#trees = trees;
|
|
82
|
+
this.#grown += Math.max(0, needed);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
this.#trees = trees;
|
|
86
|
+
this.#grown += needed;
|
|
87
|
+
return this.#run(Effect.match(this.#allotment.grow(needed), {
|
|
88
|
+
onFailure: (error) => {
|
|
89
|
+
this.#trees -= bytes;
|
|
90
|
+
this.#grown -= needed;
|
|
91
|
+
return error;
|
|
92
|
+
},
|
|
93
|
+
onSuccess: () => void 0
|
|
94
|
+
}));
|
|
95
|
+
};
|
|
96
|
+
/** The walk let go of `bytes`: what it grew past the floor for them goes back. */
|
|
97
|
+
shrink = (bytes) => {
|
|
98
|
+
this.#trees = Math.max(0, this.#trees - bytes);
|
|
99
|
+
const kept = Math.max(0, this.#trees - openTreesFloorBytes);
|
|
100
|
+
if (this.#grown <= kept) return;
|
|
101
|
+
this.#allotment.shrink(this.#grown - kept);
|
|
102
|
+
this.#grown = kept;
|
|
103
|
+
};
|
|
104
|
+
/** Gives back what it holds, once; its readers give back theirs as they close. */
|
|
105
|
+
release = () => {
|
|
106
|
+
this.#allotment.release();
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
export { PacksAllotment, openTreesRefusal, treesBusy };
|