@ref0/git 0.0.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LICENSE +202 -0
- package/dist/access/private-refs.d.mts +27 -0
- package/dist/access/private-refs.mjs +173 -0
- package/dist/access.d.mts +2 -0
- package/dist/access.mjs +1 -0
- package/dist/auth/access-jwt.d.mts +21 -0
- package/dist/auth/access-jwt.mjs +102 -0
- package/dist/auth/acting.mjs +15 -0
- package/dist/auth/authorize.d.mts +5 -0
- package/dist/auth/authorize.mjs +292 -0
- package/dist/auth/credentials.mjs +57 -0
- package/dist/auth/fences.d.mts +5 -0
- package/dist/auth/fences.mjs +65 -0
- package/dist/auth/grants.mjs +61 -0
- package/dist/auth/helpers.d.mts +17 -0
- package/dist/auth/helpers.mjs +25 -0
- package/dist/auth/host-function.d.mts +4 -0
- package/dist/auth/host-function.mjs +69 -0
- package/dist/auth/identify.d.mts +6 -0
- package/dist/auth/identify.mjs +97 -0
- package/dist/auth/token-rows.mjs +100 -0
- package/dist/auth/token-text.mjs +66 -0
- package/dist/auth/tokens.d.mts +10 -0
- package/dist/auth/tokens.mjs +347 -0
- package/dist/auth.d.mts +7 -0
- package/dist/auth.mjs +6 -0
- package/dist/client/answer.mjs +141 -0
- package/dist/client/client.d.mts +23 -0
- package/dist/client/client.mjs +50 -0
- package/dist/client/git-http.mjs +201 -0
- package/dist/client/helper-node.mjs +19 -0
- package/dist/client/local.mjs +170 -0
- package/dist/client/negotiate.mjs +170 -0
- package/dist/client/push-upload.mjs +53 -0
- package/dist/client/remote-helper.mjs +129 -0
- package/dist/client/remote.mjs +398 -0
- package/dist/client/run-remote-helper.d.mts +35 -0
- package/dist/client/run-remote-helper.mjs +259 -0
- package/dist/client/scrub.d.mts +18 -0
- package/dist/client/scrub.mjs +38 -0
- package/dist/client/transport.d.mts +2 -0
- package/dist/client/transport.mjs +211 -0
- package/dist/contracts/access.d.mts +87 -0
- package/dist/contracts/actors.d.mts +144 -0
- package/dist/contracts/blobs.d.mts +38 -0
- package/dist/contracts/calls-spent.d.mts +11 -0
- package/dist/contracts/calls-spent.mjs +151 -0
- package/dist/contracts/client.d.mts +90 -0
- package/dist/contracts/commits.d.mts +126 -0
- package/dist/contracts/engine.d.mts +134 -0
- package/dist/contracts/events.d.mts +276 -0
- package/dist/contracts/files.d.mts +75 -0
- package/dist/contracts/forks.d.mts +78 -0
- package/dist/contracts/grants.d.mts +60 -0
- package/dist/contracts/handlers.d.mts +11 -0
- package/dist/contracts/ids.d.mts +15 -0
- package/dist/contracts/ids.mjs +15 -0
- package/dist/contracts/lfs.d.mts +27 -0
- package/dist/contracts/merges.d.mts +33 -0
- package/dist/contracts/objects.d.mts +645 -0
- package/dist/contracts/objects.mjs +54 -0
- package/dist/contracts/operations.d.mts +133 -0
- package/dist/contracts/promises.d.mts +38 -0
- package/dist/contracts/promises.mjs +13 -0
- package/dist/contracts/push-uploads.d.mts +44 -0
- package/dist/contracts/queue.d.mts +402 -0
- package/dist/contracts/refs.d.mts +95 -0
- package/dist/contracts/remote.d.mts +50 -0
- package/dist/contracts/repos.d.mts +153 -0
- package/dist/contracts/result.d.mts +133 -0
- package/dist/contracts/result.mjs +34 -0
- package/dist/contracts/rules.d.mts +159 -0
- package/dist/contracts/server.d.mts +272 -0
- package/dist/contracts/services.d.mts +36 -0
- package/dist/contracts/services.mjs +13 -0
- package/dist/contracts/signin.d.mts +126 -0
- package/dist/contracts/store.d.mts +41 -0
- package/dist/contracts/sync.d.mts +210 -0
- package/dist/contracts/sync.mjs +8 -0
- package/dist/contracts/tags.d.mts +50 -0
- package/dist/contracts/tags.mjs +6 -0
- package/dist/contracts/tokens.d.mts +87 -0
- package/dist/contracts/tokens.mjs +15 -0
- package/dist/contracts/topics.d.mts +180 -0
- package/dist/contracts/trees.d.mts +84 -0
- package/dist/contracts/work.d.mts +31 -0
- package/dist/core/access.d.mts +22 -0
- package/dist/core/access.mjs +262 -0
- package/dist/core/ancestry.mjs +235 -0
- package/dist/core/call-names.d.mts +1 -0
- package/dist/core/call-names.mjs +93 -0
- package/dist/core/clock.mjs +18 -0
- package/dist/core/events/deliver.mjs +475 -0
- package/dist/core/events/stream.d.mts +19 -0
- package/dist/core/events/stream.mjs +297 -0
- package/dist/core/forks.mjs +1027 -0
- package/dist/core/hooks/post-receive.mjs +212 -0
- package/dist/core/hooks/pre-receive.d.mts +5 -0
- package/dist/core/hooks/pre-receive.mjs +34 -0
- package/dist/core/index-job.mjs +198 -0
- package/dist/core/names.mjs +30 -0
- package/dist/core/objects/blobs.mjs +60 -0
- package/dist/core/objects/commit-writes.mjs +185 -0
- package/dist/core/objects/commits.mjs +172 -0
- package/dist/core/objects/files.mjs +211 -0
- package/dist/core/objects/lines.mjs +42 -0
- package/dist/core/objects/merges.mjs +83 -0
- package/dist/core/objects/peel.mjs +166 -0
- package/dist/core/objects/reading.mjs +284 -0
- package/dist/core/objects/tags.mjs +96 -0
- package/dist/core/objects/tree-edits.mjs +266 -0
- package/dist/core/objects/trees.mjs +229 -0
- package/dist/core/objects/writing.mjs +266 -0
- package/dist/core/own-writes.mjs +94 -0
- package/dist/core/promise.mjs +64 -0
- package/dist/core/publish.mjs +142 -0
- package/dist/core/push-decide.mjs +206 -0
- package/dist/core/push.mjs +1070 -0
- package/dist/core/receipts.d.mts +7 -0
- package/dist/core/receipts.mjs +234 -0
- package/dist/core/ref-conflicts.mjs +27 -0
- package/dist/core/refs.mjs +359 -0
- package/dist/core/repack.mjs +521 -0
- package/dist/core/repos.mjs +752 -0
- package/dist/core/rules/changes.mjs +57 -0
- package/dist/core/rules/check.mjs +101 -0
- package/dist/core/rules/commit-changes.mjs +216 -0
- package/dist/core/rules/context.d.mts +9 -0
- package/dist/core/rules/context.mjs +120 -0
- package/dist/core/rules/define.d.mts +5 -0
- package/dist/core/rules/define.mjs +13 -0
- package/dist/core/rules/facts.mjs +13 -0
- package/dist/core/rules/fetch.d.mts +5 -0
- package/dist/core/rules/fetch.mjs +59 -0
- package/dist/core/rules/file-globs.mjs +55 -0
- package/dist/core/rules/files.mjs +142 -0
- package/dist/core/rules/patterns.mjs +23 -0
- package/dist/core/rules/protect.d.mts +9 -0
- package/dist/core/rules/protect.mjs +116 -0
- package/dist/core/seam.d.mts +26 -0
- package/dist/core/seam.mjs +54 -0
- package/dist/core/sight.mjs +99 -0
- package/dist/core/tokens.mjs +95 -0
- package/dist/core/view.d.mts +9 -0
- package/dist/core/view.mjs +221 -0
- package/dist/core/work.mjs +92 -0
- package/dist/effect.d.mts +20 -0
- package/dist/effect.mjs +18 -0
- package/dist/engine/allotted-xdiff.d.mts +4 -0
- package/dist/engine/allotted-xdiff.mjs +80 -0
- package/dist/engine/attribute-patterns.mjs +163 -0
- package/dist/engine/attributes.mjs +226 -0
- package/dist/engine/combined.mjs +653 -0
- package/dist/engine/commits.mjs +90 -0
- package/dist/engine/content.d.mts +4 -0
- package/dist/engine/content.mjs +221 -0
- package/dist/engine/diff.mjs +49 -0
- package/dist/engine/engine.d.mts +25 -0
- package/dist/engine/engine.mjs +49 -0
- package/dist/engine/failures.d.mts +4 -0
- package/dist/engine/failures.mjs +23 -0
- package/dist/engine/line-count.mjs +23 -0
- package/dist/engine/merge-base-walk.d.mts +2 -0
- package/dist/engine/merge-base-walk.mjs +265 -0
- package/dist/engine/merge-bases.mjs +27 -0
- package/dist/engine/merge-renames.mjs +165 -0
- package/dist/engine/merge.mjs +1125 -0
- package/dist/engine/parts.d.mts +8 -0
- package/dist/engine/parts.mjs +9 -0
- package/dist/engine/reads.d.mts +5 -0
- package/dist/engine/reads.mjs +105 -0
- package/dist/engine/walk.mjs +328 -0
- package/dist/engine/xdiff/NOTICE.md +63 -0
- package/dist/engine/xdiff/compiled.d.mts +7 -0
- package/dist/engine/xdiff/compiled.mjs +9 -0
- package/dist/engine/xdiff/embedded.mjs +4 -0
- package/dist/engine/xdiff/node.d.mts +7 -0
- package/dist/engine/xdiff/node.mjs +10 -0
- package/dist/engine/xdiff/upstream/LGPL-2.1 +511 -0
- package/dist/engine/xdiff/xdiff.wasm +0 -0
- package/dist/engine/xdiff.d.mts +34 -0
- package/dist/engine/xdiff.mjs +380 -0
- package/dist/engine.d.mts +3 -0
- package/dist/engine.mjs +3 -0
- package/dist/extend.d.mts +4 -0
- package/dist/extend.mjs +3 -0
- package/dist/http/answers.mjs +74 -0
- package/dist/http/bodies.mjs +143 -0
- package/dist/http/core-parts.mjs +252 -0
- package/dist/http/fetch-depth.mjs +26 -0
- package/dist/http/handler.mjs +94 -0
- package/dist/http/node.d.mts +70 -0
- package/dist/http/node.mjs +178 -0
- package/dist/http/paths.d.mts +9 -0
- package/dist/http/paths.mjs +118 -0
- package/dist/http/push-uploads.mjs +286 -0
- package/dist/http/receive-pack.mjs +235 -0
- package/dist/http/upload-pack.mjs +229 -0
- package/dist/index.d.mts +46 -0
- package/dist/index.mjs +16 -0
- package/dist/lfs/calls.mjs +16 -0
- package/dist/lfs/locks.mjs +161 -0
- package/dist/lfs/objects.mjs +370 -0
- package/dist/lfs/pointers.mjs +141 -0
- package/dist/lfs/repo.mjs +42 -0
- package/dist/lfs/rows.mjs +108 -0
- package/dist/lfs/service.mjs +34 -0
- package/dist/lfs/upkeep.mjs +162 -0
- package/dist/lfs/wire.mjs +102 -0
- package/dist/node.d.mts +3 -0
- package/dist/node.mjs +3 -0
- package/dist/protocol/bytes/buffers.d.mts +38 -0
- package/dist/protocol/bytes/buffers.mjs +62 -0
- package/dist/protocol/bytes/crc32.d.mts +4 -0
- package/dist/protocol/bytes/crc32.mjs +14 -0
- package/dist/protocol/bytes/deflate.d.mts +78 -0
- package/dist/protocol/bytes/deflate.mjs +175 -0
- package/dist/protocol/bytes/errors.d.mts +20 -0
- package/dist/protocol/bytes/errors.mjs +19 -0
- package/dist/protocol/bytes/hex.mjs +16 -0
- package/dist/protocol/bytes/hmac-sha256.mjs +91 -0
- package/dist/protocol/bytes/inflate.d.mts +40 -0
- package/dist/protocol/bytes/inflate.mjs +109 -0
- package/dist/protocol/bytes/joined.d.mts +2 -0
- package/dist/protocol/bytes/joined.mjs +25 -0
- package/dist/protocol/bytes/sha1-hasher.d.mts +20 -0
- package/dist/protocol/bytes/sha1-hasher.mjs +72 -0
- package/dist/protocol/bytes/sha1.d.mts +35 -0
- package/dist/protocol/bytes/sha1.mjs +409 -0
- package/dist/protocol/bytes/sha256.mjs +156 -0
- package/dist/protocol/bytes/streams.mjs +11 -0
- package/dist/protocol/bytes/text.mjs +19 -0
- package/dist/protocol/diff/diff-raw.d.mts +29 -0
- package/dist/protocol/diff/diff-raw.mjs +73 -0
- package/dist/protocol/diff/patch.mjs +92 -0
- package/dist/protocol/diff/paths.mjs +67 -0
- package/dist/protocol/diff/read.d.mts +62 -0
- package/dist/protocol/diff/read.mjs +342 -0
- package/dist/protocol/diff/rename-similarity.mjs +428 -0
- package/dist/protocol/diff/text.mjs +12 -0
- package/dist/protocol/diff/tree-diff.d.mts +41 -0
- package/dist/protocol/diff/tree-diff.mjs +607 -0
- package/dist/protocol/framing/band.d.mts +10 -0
- package/dist/protocol/framing/band.mjs +16 -0
- package/dist/protocol/framing/pkt-line.d.mts +48 -0
- package/dist/protocol/framing/pkt-line.mjs +92 -0
- package/dist/protocol/objects/checked-blobs.mjs +127 -0
- package/dist/protocol/objects/commit.d.mts +25 -0
- package/dist/protocol/objects/commit.mjs +138 -0
- package/dist/protocol/objects/fsck-gitmodules.mjs +296 -0
- package/dist/protocol/objects/fsck-names.mjs +189 -0
- package/dist/protocol/objects/fsck.mjs +297 -0
- package/dist/protocol/objects/headers.mjs +109 -0
- package/dist/protocol/objects/held.mjs +56 -0
- package/dist/protocol/objects/iconv.mjs +145 -0
- package/dist/protocol/objects/ident.mjs +111 -0
- package/dist/protocol/objects/lfs-pointer.d.mts +8 -0
- package/dist/protocol/objects/lfs-pointer.mjs +63 -0
- package/dist/protocol/objects/links-raw.mjs +89 -0
- package/dist/protocol/objects/object-rules.mjs +75 -0
- package/dist/protocol/objects/object.d.mts +16 -0
- package/dist/protocol/objects/object.mjs +29 -0
- package/dist/protocol/objects/tag.d.mts +21 -0
- package/dist/protocol/objects/tag.mjs +96 -0
- package/dist/protocol/objects/tree.d.mts +43 -0
- package/dist/protocol/objects/tree.mjs +162 -0
- package/dist/protocol/objects/utf8-verify.mjs +71 -0
- package/dist/protocol/packs/delta.d.mts +57 -0
- package/dist/protocol/packs/delta.mjs +229 -0
- package/dist/protocol/packs/graph.mjs +78 -0
- package/dist/protocol/packs/idx.d.mts +54 -0
- package/dist/protocol/packs/idx.mjs +274 -0
- package/dist/protocol/packs/indexer.d.mts +167 -0
- package/dist/protocol/packs/indexer.mjs +507 -0
- package/dist/protocol/packs/parts.d.mts +40 -0
- package/dist/protocol/packs/parts.mjs +89 -0
- package/dist/protocol/packs/pos.mjs +51 -0
- package/dist/protocol/packs/reader.d.mts +180 -0
- package/dist/protocol/packs/reader.mjs +414 -0
- package/dist/protocol/packs/rev.d.mts +32 -0
- package/dist/protocol/packs/rev.mjs +99 -0
- package/dist/protocol/packs/step.d.mts +10 -0
- package/dist/protocol/packs/step.mjs +12 -0
- package/dist/protocol/packs/write-error.d.mts +12 -0
- package/dist/protocol/packs/write-error.mjs +27 -0
- package/dist/protocol/packs/writer.d.mts +157 -0
- package/dist/protocol/packs/writer.mjs +353 -0
- package/dist/protocol/wire/advertisement.d.mts +72 -0
- package/dist/protocol/wire/advertisement.mjs +161 -0
- package/dist/protocol/wire/fetch.d.mts +155 -0
- package/dist/protocol/wire/fetch.mjs +458 -0
- package/dist/protocol/wire/lines.mjs +107 -0
- package/dist/protocol/wire/push-uploads.mjs +43 -0
- package/dist/protocol/wire/receive-pack.d.mts +71 -0
- package/dist/protocol/wire/receive-pack.mjs +157 -0
- package/dist/protocol/wire/report-status.d.mts +47 -0
- package/dist/protocol/wire/report-status.mjs +119 -0
- package/dist/protocol/wire/v2.d.mts +90 -0
- package/dist/protocol/wire/v2.mjs +185 -0
- package/dist/protocol.d.mts +31 -0
- package/dist/protocol.mjs +31 -0
- package/dist/queue/advance.mjs +1037 -0
- package/dist/queue/callers.mjs +134 -0
- package/dist/queue/calls.mjs +1154 -0
- package/dist/queue/commit.mjs +85 -0
- package/dist/queue/host.d.mts +15 -0
- package/dist/queue/host.mjs +88 -0
- package/dist/queue/ids.d.mts +5 -0
- package/dist/queue/ids.mjs +21 -0
- package/dist/queue/lanes.mjs +86 -0
- package/dist/queue/limits.mjs +99 -0
- package/dist/queue/pages.mjs +76 -0
- package/dist/queue/push-option.mjs +62 -0
- package/dist/queue/rows.mjs +206 -0
- package/dist/queue/schedule.mjs +132 -0
- package/dist/queue/search.mjs +315 -0
- package/dist/queue/state.mjs +325 -0
- package/dist/queue/steps.mjs +317 -0
- package/dist/remote-helper.d.mts +3 -0
- package/dist/remote-helper.mjs +3 -0
- package/dist/rest/api.d.mts +23 -0
- package/dist/rest/api.mjs +27 -0
- package/dist/rest/blobs.d.mts +58 -0
- package/dist/rest/blobs.mjs +41 -0
- package/dist/rest/caller.d.mts +102 -0
- package/dist/rest/caller.mjs +18 -0
- package/dist/rest/client.d.mts +18 -0
- package/dist/rest/client.mjs +587 -0
- package/dist/rest/commits.d.mts +435 -0
- package/dist/rest/commits.mjs +140 -0
- package/dist/rest/errors.d.mts +44 -0
- package/dist/rest/errors.mjs +186 -0
- package/dist/rest/events.d.mts +38 -0
- package/dist/rest/events.mjs +74 -0
- package/dist/rest/files.d.mts +179 -0
- package/dist/rest/files.mjs +92 -0
- package/dist/rest/forks.d.mts +205 -0
- package/dist/rest/forks.mjs +51 -0
- package/dist/rest/handler.d.mts +18 -0
- package/dist/rest/handler.mjs +129 -0
- package/dist/rest/handlers.d.mts +8 -0
- package/dist/rest/handlers.mjs +592 -0
- package/dist/rest/listen.d.mts +24 -0
- package/dist/rest/listen.mjs +142 -0
- package/dist/rest/me.d.mts +55 -0
- package/dist/rest/me.mjs +21 -0
- package/dist/rest/merges.d.mts +90 -0
- package/dist/rest/merges.mjs +39 -0
- package/dist/rest/paths.mjs +86 -0
- package/dist/rest/queue.d.mts +486 -0
- package/dist/rest/queue.mjs +228 -0
- package/dist/rest/refs.d.mts +232 -0
- package/dist/rest/refs.mjs +86 -0
- package/dist/rest/repos.d.mts +223 -0
- package/dist/rest/repos.mjs +93 -0
- package/dist/rest/tags.d.mts +153 -0
- package/dist/rest/tags.mjs +72 -0
- package/dist/rest/tokens.d.mts +297 -0
- package/dist/rest/tokens.mjs +88 -0
- package/dist/rest/topics.d.mts +257 -0
- package/dist/rest/topics.mjs +116 -0
- package/dist/rest/trees.d.mts +158 -0
- package/dist/rest/trees.mjs +118 -0
- package/dist/rest/wire.mjs +57 -0
- package/dist/rest/work.d.mts +107 -0
- package/dist/rest/work.mjs +77 -0
- package/dist/rest.d.mts +8 -0
- package/dist/rest.mjs +5 -0
- package/dist/server/extension.d.mts +17 -0
- package/dist/server/extension.mjs +93 -0
- package/dist/server/lifecycle.d.mts +3 -0
- package/dist/server/lifecycle.mjs +89 -0
- package/dist/server/routes.d.mts +28 -0
- package/dist/server/routes.mjs +60 -0
- package/dist/server/server.d.mts +8 -0
- package/dist/server/server.mjs +615 -0
- package/dist/signin/codes.mjs +47 -0
- package/dist/signin/context.d.mts +9 -0
- package/dist/signin/context.mjs +121 -0
- package/dist/signin/device.mjs +122 -0
- package/dist/signin/forms.mjs +157 -0
- package/dist/signin/grants.d.mts +5 -0
- package/dist/signin/grants.mjs +257 -0
- package/dist/signin/route.mjs +68 -0
- package/dist/signin/web.mjs +125 -0
- package/dist/signin/wire.d.mts +42 -0
- package/dist/signin/wire.mjs +43 -0
- package/dist/storage/allotted.mjs +102 -0
- package/dist/storage/bits.mjs +41 -0
- package/dist/storage/budget.mjs +96 -0
- package/dist/storage/calls.d.mts +18 -0
- package/dist/storage/calls.mjs +273 -0
- package/dist/storage/clean-up.mjs +124 -0
- package/dist/storage/distinct-ids.mjs +39 -0
- package/dist/storage/ewah.mjs +97 -0
- package/dist/storage/fetch.d.mts +15 -0
- package/dist/storage/fetch.mjs +998 -0
- package/dist/storage/fsck.mjs +77 -0
- package/dist/storage/held-memo.mjs +188 -0
- package/dist/storage/index-bitmaps.d.mts +4 -0
- package/dist/storage/index-bitmaps.mjs +654 -0
- package/dist/storage/index-build.d.mts +15 -0
- package/dist/storage/index-build.mjs +1447 -0
- package/dist/storage/index-fetch.d.mts +10 -0
- package/dist/storage/index-fetch.mjs +677 -0
- package/dist/storage/index-files.mjs +232 -0
- package/dist/storage/index-graph.d.mts +3 -0
- package/dist/storage/index-graph.mjs +1049 -0
- package/dist/storage/index-layers.mjs +317 -0
- package/dist/storage/index-reach.mjs +216 -0
- package/dist/storage/index-remap.d.mts +8 -0
- package/dist/storage/index-remap.mjs +592 -0
- package/dist/storage/layout.mjs +69 -0
- package/dist/storage/lfs-pointers.d.mts +21 -0
- package/dist/storage/lfs-pointers.mjs +175 -0
- package/dist/storage/link-join.mjs +106 -0
- package/dist/storage/links.mjs +105 -0
- package/dist/storage/loose.d.mts +15 -0
- package/dist/storage/loose.mjs +121 -0
- package/dist/storage/memory-budget.d.mts +8 -0
- package/dist/storage/memory-budget.mjs +546 -0
- package/dist/storage/merge.mjs +416 -0
- package/dist/storage/object-rows.d.mts +6 -0
- package/dist/storage/object-rows.mjs +211 -0
- package/dist/storage/pack-order.d.mts +8 -0
- package/dist/storage/pack-order.mjs +781 -0
- package/dist/storage/pack-ranges.d.mts +5 -0
- package/dist/storage/pack-ranges.mjs +284 -0
- package/dist/storage/pack-reads.d.mts +11 -0
- package/dist/storage/pack-reads.mjs +1007 -0
- package/dist/storage/pack-receive.d.mts +11 -0
- package/dist/storage/pack-receive.mjs +449 -0
- package/dist/storage/packs.d.mts +56 -0
- package/dist/storage/packs.mjs +603 -0
- package/dist/storage/prune.mjs +506 -0
- package/dist/storage/push-allotment.mjs +109 -0
- package/dist/storage/push-uploads.mjs +152 -0
- package/dist/storage/pushed-commits.mjs +136 -0
- package/dist/storage/quarantine.mjs +98 -0
- package/dist/storage/raw-ids.mjs +44 -0
- package/dist/storage/ready.d.mts +19 -0
- package/dist/storage/ready.mjs +328 -0
- package/dist/storage/receive-links.mjs +297 -0
- package/dist/storage/repack-job.mjs +48 -0
- package/dist/storage/repack.d.mts +31 -0
- package/dist/storage/repack.mjs +182 -0
- package/dist/storage/roots.mjs +42 -0
- package/dist/storage/rows.d.mts +4 -0
- package/dist/storage/rows.mjs +71 -0
- package/dist/storage/send-list.d.mts +8 -0
- package/dist/storage/send-list.mjs +319 -0
- package/dist/storage/shallow.d.mts +4 -0
- package/dist/storage/shallow.mjs +128 -0
- package/dist/storage/stream-whole.mjs +236 -0
- package/dist/storage/unpack.mjs +238 -0
- package/dist/storage/visible.mjs +137 -0
- package/dist/storage/walk.d.mts +8 -0
- package/dist/storage/walk.mjs +176 -0
- package/dist/storage/wants.mjs +362 -0
- package/dist/store/call-count.d.mts +47 -0
- package/dist/store/call-count.mjs +207 -0
- package/dist/store/catalogue.d.mts +7 -0
- package/dist/store/catalogue.mjs +643 -0
- package/dist/store/closed.d.mts +21 -0
- package/dist/store/closed.mjs +34 -0
- package/dist/store/crossing.mjs +69 -0
- package/dist/store/cursor-seal.d.mts +2 -0
- package/dist/store/cursor-seal.mjs +88 -0
- package/dist/store/errors.d.mts +12 -0
- package/dist/store/errors.mjs +135 -0
- package/dist/store/git-store.mjs +75 -0
- package/dist/store/list-job.mjs +35 -0
- package/dist/store/outbox.d.mts +7 -0
- package/dist/store/outbox.mjs +297 -0
- package/dist/store/promises.d.mts +5 -0
- package/dist/store/promises.mjs +258 -0
- package/dist/store/queue-jobs.mjs +43 -0
- package/dist/store/random.mjs +28 -0
- package/dist/store/records.d.mts +4 -0
- package/dist/store/records.mjs +192 -0
- package/dist/store/ref-rows.d.mts +4 -0
- package/dist/store/ref-rows.mjs +30 -0
- package/dist/store/repo-record.mjs +100 -0
- package/dist/store/reservations.mjs +82 -0
- package/dist/store/scopes.mjs +170 -0
- package/dist/store/settle.mjs +63 -0
- package/dist/store/topic-jobs.mjs +62 -0
- package/dist/sync/bound.d.mts +7 -0
- package/dist/sync/bound.mjs +34 -0
- package/dist/sync/github.d.mts +12 -0
- package/dist/sync/github.mjs +297 -0
- package/dist/sync/import.d.mts +8 -0
- package/dist/sync/import.mjs +154 -0
- package/dist/sync/jobs.d.mts +9 -0
- package/dist/sync/jobs.mjs +83 -0
- package/dist/sync/mirror.d.mts +9 -0
- package/dist/sync/mirror.mjs +227 -0
- package/dist/sync/publish.d.mts +5 -0
- package/dist/sync/publish.mjs +117 -0
- package/dist/sync/records.mjs +73 -0
- package/dist/sync/smart-http.d.mts +8 -0
- package/dist/sync/smart-http.mjs +23 -0
- package/dist/sync/step.mjs +334 -0
- package/dist/sync/tries.mjs +126 -0
- package/dist/sync.d.mts +8 -0
- package/dist/sync.mjs +8 -0
- package/dist/topics/advance.mjs +555 -0
- package/dist/topics/calls.mjs +346 -0
- package/dist/topics/directory.mjs +107 -0
- package/dist/topics/host.d.mts +11 -0
- package/dist/topics/host.mjs +71 -0
- package/dist/topics/members.mjs +177 -0
- package/dist/topics/rows.mjs +99 -0
- package/dist/topics/topic.mjs +141 -0
- package/package.json +86 -5
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { collections } from "./scopes.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
import * as Hex from "effect/encoding/Hex";
|
|
5
|
+
// src/store/records.ts
|
|
6
|
+
/** A repo's `InternalRepoId`, as rows store it. */
|
|
7
|
+
const InternalRepoId = Schema.TemplateLiteral(["r_", Schema.String]);
|
|
8
|
+
const Revision = Schema.Int;
|
|
9
|
+
/** The `seq` a name's next event takes, kept on its tombstone so a repo made again goes on from it. */
|
|
10
|
+
const NextSeq = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1));
|
|
11
|
+
/**
|
|
12
|
+
* A repo that held a name before its entry's, `until` its receipts can no longer answer:
|
|
13
|
+
* `keyKept` past when it was moved off the name.
|
|
14
|
+
*/
|
|
15
|
+
const HeldBefore = Schema.Struct({
|
|
16
|
+
internalId: InternalRepoId,
|
|
17
|
+
until: Schema.Int
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* A name's entry in `git/repos`: `RepoCatalogueEntry`, as it's stored. `before` holds the repos
|
|
21
|
+
* that held the name before, newest first, so a write sent again by name finds the receipt its
|
|
22
|
+
* key left, whichever repo holds the name now.
|
|
23
|
+
*/
|
|
24
|
+
const CatalogueEntry = Schema.Struct({
|
|
25
|
+
internalId: InternalRepoId,
|
|
26
|
+
sourceRevision: Revision,
|
|
27
|
+
deleted: Schema.optionalKey(Schema.Literal(true)),
|
|
28
|
+
renamedTo: Schema.optionalKey(Schema.String),
|
|
29
|
+
before: Schema.optionalKey(Schema.Array(HeldBefore)),
|
|
30
|
+
nextSeq: Schema.optionalKey(NextSeq)
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* A repo's place in create order, in `git/repos`: the name it has now, which a rename rewrites
|
|
34
|
+
* under the same key, so the repo keeps its place.
|
|
35
|
+
*/
|
|
36
|
+
const CreatedRow = Schema.Struct({ name: Schema.String });
|
|
37
|
+
/**
|
|
38
|
+
* How long a write's key answers as it first did, in milliseconds: 24 hours, for every keyed
|
|
39
|
+
* write. From `at`, a write sent again answers as a new one.
|
|
40
|
+
*/
|
|
41
|
+
const keyKept = 864e5;
|
|
42
|
+
/** A repo write's first answer, `RepoInfo`, as its key keeps it. */
|
|
43
|
+
const KeptRepoInfo = Schema.Struct({
|
|
44
|
+
id: Schema.String,
|
|
45
|
+
defaultBranch: Schema.optionalKey(Schema.String),
|
|
46
|
+
public: Schema.Boolean,
|
|
47
|
+
upstream: Schema.optionalKey(Schema.String),
|
|
48
|
+
stats: Schema.Struct({
|
|
49
|
+
repo: Schema.String,
|
|
50
|
+
refs: Schema.Int,
|
|
51
|
+
packs: Schema.Int,
|
|
52
|
+
packBytes: Schema.Int,
|
|
53
|
+
ownBytes: Schema.Int,
|
|
54
|
+
looseObjects: Schema.Int,
|
|
55
|
+
looseBytes: Schema.Int,
|
|
56
|
+
leavingBytes: Schema.Int,
|
|
57
|
+
pushedAt: Schema.optionalKey(Schema.Int),
|
|
58
|
+
maintainedAt: Schema.optionalKey(Schema.Int)
|
|
59
|
+
}),
|
|
60
|
+
work: Schema.Struct({
|
|
61
|
+
waiting: Schema.Int,
|
|
62
|
+
oldestDue: Schema.optionalKey(Schema.Int),
|
|
63
|
+
failed: Schema.Int,
|
|
64
|
+
oldestFailed: Schema.optionalKey(Schema.Int)
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
/** A part of a caller's key with no `:` in it: `%` and `:` escaped, `~` first when there is one. */
|
|
68
|
+
const keyPart = (part) => part === void 0 ? "" : `~${part.replaceAll("%", "%25").replaceAll(":", "%3A")}`;
|
|
69
|
+
/**
|
|
70
|
+
* `key` as `caller` sent it: the actor's ID, the token's when the caller came with one, then the
|
|
71
|
+
* key, joined by `:`, which no part holds. Two callers' keys never meet, so Pip's and Mo's
|
|
72
|
+
* writes with one key both apply.
|
|
73
|
+
*/
|
|
74
|
+
const callerKey = (caller, key) => [
|
|
75
|
+
keyPart(caller.actor.anonymous === true ? void 0 : caller.actor.id),
|
|
76
|
+
keyPart(caller.token?.id),
|
|
77
|
+
keyPart(key)
|
|
78
|
+
].join(":");
|
|
79
|
+
/**
|
|
80
|
+
* The SHA-256 of `key` as `caller` sent it, as lowercase hex: all a receipt keeps of the key, so
|
|
81
|
+
* each receipt's ID is the same length however long its key, and a page of them stays small. It
|
|
82
|
+
* hashes the key as JSON, which spells out a lone surrogate that UTF-8 would turn into U+FFFD.
|
|
83
|
+
*/
|
|
84
|
+
const keyDigest = (caller, key) => {
|
|
85
|
+
const bytes = new TextEncoder().encode(JSON.stringify(callerKey(caller, key)));
|
|
86
|
+
return Effect.promise(() => crypto.subtle.digest("SHA-256", bytes)).pipe(Effect.map((digest) => Hex.encode(new Uint8Array(digest))));
|
|
87
|
+
};
|
|
88
|
+
/** The key `caller` sent a write with at `at`, kept beside `input`: its kind and what it asked. */
|
|
89
|
+
const keptKey = (caller, key, input, at) => key === void 0 ? Effect.succeed(void 0) : Effect.map(keyDigest(caller, key), (digest) => ({
|
|
90
|
+
key: digest,
|
|
91
|
+
input: JSON.stringify(input),
|
|
92
|
+
at
|
|
93
|
+
}));
|
|
94
|
+
/** Whether a key taken at `taken` still answers at `at`: until `keyKept` has passed. */
|
|
95
|
+
const keyLive = (taken, at) => at < taken + keyKept;
|
|
96
|
+
/**
|
|
97
|
+
* The name a repo left on its last rename, at the revision its tombstone takes, and the `seq` that
|
|
98
|
+
* name's next event takes. `receipt`: a keyed rename's receipt row, which a takeback deletes, so
|
|
99
|
+
* the rename sent again is refused as the lost one was.
|
|
100
|
+
*/
|
|
101
|
+
const RenamedFrom = Schema.Struct({
|
|
102
|
+
name: Schema.String,
|
|
103
|
+
revision: Revision,
|
|
104
|
+
nextSeq: Schema.optionalKey(NextSeq),
|
|
105
|
+
receipt: Schema.optionalKey(Schema.String)
|
|
106
|
+
});
|
|
107
|
+
/**
|
|
108
|
+
* What a fork's record keeps of its source: `upstreamInternalId`, which follows it across renames,
|
|
109
|
+
* so its name is read from its record when a read names it, and `holder`, whom the fork is for.
|
|
110
|
+
*/
|
|
111
|
+
const ForkOf = Schema.Struct({
|
|
112
|
+
upstreamInternalId: InternalRepoId,
|
|
113
|
+
holder: Schema.String
|
|
114
|
+
});
|
|
115
|
+
/** A fork's row in `git/repos`' `forks`: the holder's fork, by its source's ID and the holder. */
|
|
116
|
+
const ForkRow = Schema.Struct({ internalId: InternalRepoId });
|
|
117
|
+
/**
|
|
118
|
+
* A repo's own record, `repo/self` in its scope: the source `git/repos` is projected from. `name`
|
|
119
|
+
* and `revision` are its name's, and `renamedFrom` the name it left; `deleted` marks a repo
|
|
120
|
+
* deleted, or a create that lost its name to another. `changedAt` is when the record was last
|
|
121
|
+
* written, which its projection dates the repos it moves off a name by. A deleted repo's `nextSeq`
|
|
122
|
+
* is the `seq` its name's next event takes, which its tombstone keeps. A fork's `fork` says
|
|
123
|
+
* what it was made from.
|
|
124
|
+
*/
|
|
125
|
+
const StoredRepo = Schema.Struct({
|
|
126
|
+
name: Schema.String,
|
|
127
|
+
revision: Revision,
|
|
128
|
+
defaultBranch: Schema.String,
|
|
129
|
+
public: Schema.Boolean,
|
|
130
|
+
fork: Schema.optionalKey(ForkOf),
|
|
131
|
+
createdAt: Schema.Int,
|
|
132
|
+
changedAt: Schema.Int,
|
|
133
|
+
deleted: Schema.optionalKey(Schema.Literal(true)),
|
|
134
|
+
renamedFrom: Schema.optionalKey(RenamedFrom),
|
|
135
|
+
nextSeq: Schema.optionalKey(NextSeq)
|
|
136
|
+
});
|
|
137
|
+
/**
|
|
138
|
+
* A rename's record once it lost its new name to a repo made there first: the name it left, which
|
|
139
|
+
* its entry still holds, since a rename leaves its old name only when it wins the new one, at a
|
|
140
|
+
* revision past the tombstone a win would have left there, with the rename's receipt and its index row deleted.
|
|
141
|
+
* `undefined` for any other record.
|
|
142
|
+
*/
|
|
143
|
+
const takenBack = (record) => {
|
|
144
|
+
const { renamedFrom, ...rest } = record;
|
|
145
|
+
if (renamedFrom === void 0 || record.deleted === true) return void 0;
|
|
146
|
+
const back = {
|
|
147
|
+
...rest,
|
|
148
|
+
name: renamedFrom.name,
|
|
149
|
+
revision: renamedFrom.revision + 1
|
|
150
|
+
};
|
|
151
|
+
const { receipt } = renamedFrom;
|
|
152
|
+
return {
|
|
153
|
+
record: back,
|
|
154
|
+
delete: receipt === void 0 ? [] : [{
|
|
155
|
+
collection: collections.receipts,
|
|
156
|
+
id: receipt
|
|
157
|
+
}, {
|
|
158
|
+
collection: collections.receiptIndex,
|
|
159
|
+
id: receipt
|
|
160
|
+
}]
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
/** The repo's `pruned` mark in `upkeep`: the ID the last prune that dropped objects gave it. */
|
|
164
|
+
const PrunedMark = Schema.Struct({ id: Schema.String });
|
|
165
|
+
Schema.Struct({ since: Schema.Number });
|
|
166
|
+
/**
|
|
167
|
+
* A mirror's row in `mirrors`, by its ref's full name: where it pushes, by provider name, and
|
|
168
|
+
* whether it's paused. A push that moves the ref saves the mirror's job while it's `active`.
|
|
169
|
+
*/
|
|
170
|
+
const MirrorRow = Schema.Struct({
|
|
171
|
+
destination: Schema.Struct({
|
|
172
|
+
provider: Schema.String,
|
|
173
|
+
repo: Schema.String
|
|
174
|
+
}),
|
|
175
|
+
state: Schema.Literals(["active", "paused"]),
|
|
176
|
+
paused: Schema.optionalKey(Schema.Literals(["diverged", "refused"]))
|
|
177
|
+
});
|
|
178
|
+
/** The job a push saves for each ref an active mirror names, keyed by the ref. */
|
|
179
|
+
const mirrorJobName = "git.sync.mirror";
|
|
180
|
+
/**
|
|
181
|
+
* A time in `stats`, `pushed` or `maintained`: put at the later of the time it held and the
|
|
182
|
+
* committing try's clock, so it never moves back when another isolate's clock is behind.
|
|
183
|
+
*/
|
|
184
|
+
const StatsTime = Schema.Struct({ at: Schema.Int });
|
|
185
|
+
/** A pack's row in `packs`, by its ID: how many objects it holds, and its bytes. */
|
|
186
|
+
const PackRow = Schema.Struct({
|
|
187
|
+
objects: Schema.Int,
|
|
188
|
+
bytes: Schema.Int
|
|
189
|
+
});
|
|
190
|
+
/** A row's ID by its sequence number, zero-padded so the rows read in order. */
|
|
191
|
+
const versionId = (sequence) => String(sequence).padStart(16, "0");
|
|
192
|
+
export { CatalogueEntry, CreatedRow, ForkOf, ForkRow, InternalRepoId, KeptRepoInfo, MirrorRow, PackRow, PrunedMark, RenamedFrom, StatsTime, StoredRepo, callerKey, keptKey, keyDigest, keyKept, keyLive, mirrorJobName, takenBack, versionId };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { decodeRow } from "./errors.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
// src/store/ref-rows.ts
|
|
5
|
+
/** A ref's row in `refs`, keyed by its full name, such as `refs/heads/main`. */
|
|
6
|
+
const RefRow = Schema.Struct({ oid: Schema.String.check(Schema.isPattern(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/)) });
|
|
7
|
+
/**
|
|
8
|
+
* Leave to read every ref of a repo, whoever the caller is. A call made for a caller reads refs
|
|
9
|
+
* through its `RepoView`, which leaves out the refs the caller doesn't see, and only the readers
|
|
10
|
+
* that need every ref hold one of these: the view itself, the push's decide, forks' copy, the
|
|
11
|
+
* queue's state, sync, upkeep, the index's build, the client's own repo and storage's prune. `lint/view-boundary.test.ts`
|
|
12
|
+
* lists the files that mint one, so a new reader that skips the view is a change that test sees.
|
|
13
|
+
*/
|
|
14
|
+
var WholeRepo = class WholeRepo {
|
|
15
|
+
#whole = true;
|
|
16
|
+
constructor() {}
|
|
17
|
+
/** Leave for one of the readers above. */
|
|
18
|
+
static mint() {
|
|
19
|
+
return new WholeRepo();
|
|
20
|
+
}
|
|
21
|
+
/** Whether `value` is leave from `mint`. */
|
|
22
|
+
static is(value) {
|
|
23
|
+
return value instanceof WholeRepo && value.#whole;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
/** One ref row's tip, read with `whole`. */
|
|
27
|
+
const wholeRef = (_whole, row, what = `Ref '${row.id}'`) => Effect.map(decodeRow(RefRow, row, what), ({ oid }) => oid);
|
|
28
|
+
/** A repo's refs by name, every one of them, from its `refs` rows, read with `whole`. */
|
|
29
|
+
const wholeRefs = (whole, rows) => Effect.map(Effect.forEach(rows, (row) => Effect.map(wholeRef(whole, row), (oid) => [row.id, oid])), (entries) => new Map(entries));
|
|
30
|
+
export { WholeRepo, wholeRef, wholeRefs };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { checkChurn, decodeRecord, entryOf, project } from "./catalogue.mjs";
|
|
2
|
+
import { decodeRow, storeCall } from "./errors.mjs";
|
|
3
|
+
import { listJobRow } from "./list-job.mjs";
|
|
4
|
+
import { StatsTime } from "./records.mjs";
|
|
5
|
+
import { maintainedKey, newChangeId, pushedKey, repoScope, selfKey } from "./scopes.mjs";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
// src/store/repo-record.ts
|
|
8
|
+
/** A repo's record and its scope's rows, read at one version: `results[0]` is `self`. */
|
|
9
|
+
const readRecord = Effect.fnUntraced(function* (store, internalId, reads = [], counts = []) {
|
|
10
|
+
const scope = repoScope(internalId);
|
|
11
|
+
const snapshot = yield* storeCall(() => store.read(scope, [selfKey, ...reads], [...counts]));
|
|
12
|
+
return {
|
|
13
|
+
record: yield* decodeRecord(snapshot.results[0]?.[0]),
|
|
14
|
+
snapshot
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* The first of a repo write's two commits: its record, in its own scope, with `git.list` saved
|
|
19
|
+
* beside it, so the catalogue's projection happens even if the second never does.
|
|
20
|
+
*/
|
|
21
|
+
const commitRecord = (store, internalId, write) => {
|
|
22
|
+
const change = {
|
|
23
|
+
id: write.id ?? newChangeId(),
|
|
24
|
+
expect: write.expect,
|
|
25
|
+
put: [{
|
|
26
|
+
...selfKey,
|
|
27
|
+
value: write.record
|
|
28
|
+
}, ...write.put ?? []],
|
|
29
|
+
delete: [...write.delete ?? []],
|
|
30
|
+
jobs: [listJobRow(), ...write.jobs ?? []]
|
|
31
|
+
};
|
|
32
|
+
return storeCall(() => store.commit(repoScope(internalId), change));
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* A repo write's two commits: its record, then its projection into `git/repos`. Answers
|
|
36
|
+
* `undefined` when the scope moved since `expect`, else whether the record's name is its own.
|
|
37
|
+
* A live record is checked against its name's entry first, so every write that puts a repo on
|
|
38
|
+
* a name refuses `name-churn` before it commits, whichever call makes it (#128).
|
|
39
|
+
*/
|
|
40
|
+
const writeRecord = Effect.fnUntraced(function* (store, internalId, write) {
|
|
41
|
+
const { record } = write;
|
|
42
|
+
if (record.deleted !== true) yield* checkChurn(internalId, record, yield* entryOf(store, record.name));
|
|
43
|
+
const committed = yield* commitRecord(store, internalId, write);
|
|
44
|
+
if (!committed.ok) return void 0;
|
|
45
|
+
const outcome = yield* project(store, internalId, record);
|
|
46
|
+
return {
|
|
47
|
+
version: committed.version,
|
|
48
|
+
outcome
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
/** The times in a repo's `stats` rows, as `statsRead` reads them. */
|
|
52
|
+
const decodeTimes = Effect.fnUntraced(function* (rows) {
|
|
53
|
+
const times = {};
|
|
54
|
+
const privately = /* @__PURE__ */ new Map();
|
|
55
|
+
for (const row of rows) {
|
|
56
|
+
const { at } = yield* decodeRow(StatsTime, row, `The repo's '${row.id}' time`);
|
|
57
|
+
if (row.id === pushedKey.id) times.pushed = at;
|
|
58
|
+
else if (row.id === maintainedKey.id) times.maintained = at;
|
|
59
|
+
else if (row.id.startsWith(privatePushed)) privately.set(row.id.slice(privatePushed.length), at);
|
|
60
|
+
}
|
|
61
|
+
if (privately.size > 0) times.privately = privately;
|
|
62
|
+
return times;
|
|
63
|
+
});
|
|
64
|
+
const privatePushed = "pushed/";
|
|
65
|
+
/** `times` as a caller with `sight` sees them: its `pushed` the latest of the patterns it reads. */
|
|
66
|
+
const seenTimes = (times, sight) => {
|
|
67
|
+
const seen = [...times.privately ?? []].flatMap(([pattern, at]) => sight.reads(pattern) ? [at] : []);
|
|
68
|
+
const { privately: _privately, ...rest } = times;
|
|
69
|
+
if (seen.length === 0) return rest;
|
|
70
|
+
return {
|
|
71
|
+
...rest,
|
|
72
|
+
pushed: Math.max(times.pushed ?? 0, ...seen)
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* A `stats` time's row for a commit at `now`: never before the time it held, since the clocks of
|
|
77
|
+
* two isolates can differ, and the commit's own read holds the row it replaces.
|
|
78
|
+
*/
|
|
79
|
+
const timeRow = (key, held, now) => ({
|
|
80
|
+
...key,
|
|
81
|
+
value: { at: Math.max(held ?? now, now) }
|
|
82
|
+
});
|
|
83
|
+
/** A repo's stats, from its record, its refs' count, its listed packs and its `stats` times. */
|
|
84
|
+
const repoStats = (record, refs, packs, times) => {
|
|
85
|
+
const packBytes = packs.reduce((sum, pack) => sum + pack.bytes, 0);
|
|
86
|
+
const stats = {
|
|
87
|
+
repo: record.name,
|
|
88
|
+
refs,
|
|
89
|
+
packs: packs.length,
|
|
90
|
+
packBytes,
|
|
91
|
+
ownBytes: packBytes,
|
|
92
|
+
looseObjects: 0,
|
|
93
|
+
looseBytes: 0,
|
|
94
|
+
leavingBytes: 0
|
|
95
|
+
};
|
|
96
|
+
if (times.pushed !== void 0) stats.pushedAt = times.pushed;
|
|
97
|
+
if (times.maintained !== void 0) stats.maintainedAt = times.maintained;
|
|
98
|
+
return stats;
|
|
99
|
+
};
|
|
100
|
+
export { commitRecord, decodeTimes, readRecord, repoStats, seenTimes, timeRow, writeRecord };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { decodeRow, gitError, storeCall } from "./errors.mjs";
|
|
2
|
+
import { collections, topicScope } from "./scopes.mjs";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
// src/store/reservations.ts
|
|
6
|
+
/**
|
|
7
|
+
* A target's reservation, a field of its `queue-targets` row in its repo's scope, so the push
|
|
8
|
+
* decide reads it in the commit it refuses: the topic that holds the target (Q557). A topic
|
|
9
|
+
* reserves its targets in separate commits, so each reservation has its own way out: once its topic
|
|
10
|
+
* ends, it's free, whether or not the topic's job has released it.
|
|
11
|
+
*/
|
|
12
|
+
const Reservation = Schema.Struct({ topic: Schema.String });
|
|
13
|
+
/** A topic's states, as its own row keeps them. */
|
|
14
|
+
const TopicState = Schema.Literals([
|
|
15
|
+
"checking",
|
|
16
|
+
"reserving",
|
|
17
|
+
"publishing",
|
|
18
|
+
"failed",
|
|
19
|
+
"merged",
|
|
20
|
+
"removed"
|
|
21
|
+
]);
|
|
22
|
+
/** What a reservation's life reads of its topic's row: its state. The other fields are its own. */
|
|
23
|
+
const TopicLife = Schema.Struct({ state: TopicState });
|
|
24
|
+
/** A topic's own row, in its scope. */
|
|
25
|
+
const topicKey = {
|
|
26
|
+
collection: collections.topic,
|
|
27
|
+
id: "self"
|
|
28
|
+
};
|
|
29
|
+
/** The states a topic never leaves: its key is never opened again (Q624). */
|
|
30
|
+
const ended = /* @__PURE__ */ new Set([
|
|
31
|
+
"failed",
|
|
32
|
+
"merged",
|
|
33
|
+
"removed"
|
|
34
|
+
]);
|
|
35
|
+
/** The fields of a target's row a reservation's readers decode. */
|
|
36
|
+
const Reserved = Schema.Struct({ reserved: Schema.optionalKey(Reservation) });
|
|
37
|
+
/** The reservation on a target's row, if the row is there and holds one. */
|
|
38
|
+
const reservationOf = (rows) => {
|
|
39
|
+
const [row] = rows ?? [];
|
|
40
|
+
if (row === void 0) return Effect.succeed(void 0);
|
|
41
|
+
return Effect.map(decodeRow(Reserved, row, "A merge queue's target"), (read) => read.reserved);
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Its topic's state while `reservation` still holds, `publishing` once its publish decision is
|
|
45
|
+
* saved, or `undefined` once it's free. It holds till its topic ends. Read in the topic's scope,
|
|
46
|
+
* apart from the write it decides: a topic that ended stays ended, so a write that reads it ended
|
|
47
|
+
* may go on, and one that reads it live is refused, to be sent again. A topic with no row holds
|
|
48
|
+
* nothing.
|
|
49
|
+
*/
|
|
50
|
+
const liveState = Effect.fnUntraced(function* (store, reservation) {
|
|
51
|
+
const [row] = (yield* storeCall(() => store.read(topicScope(reservation.topic), [topicKey]))).results[0] ?? [];
|
|
52
|
+
if (row === void 0) return void 0;
|
|
53
|
+
const life = yield* decodeRow(TopicLife, row, `Topic ${reservation.topic}`);
|
|
54
|
+
return ended.has(life.state) ? void 0 : life.state;
|
|
55
|
+
});
|
|
56
|
+
/** Whether `reservation` still holds, as `liveState` reads it. */
|
|
57
|
+
const isLive = (store, reservation) => Effect.map(liveState(store, reservation), (state) => state !== void 0);
|
|
58
|
+
/** Fails with `refusal` while `held`, a topic's reservation, is live. */
|
|
59
|
+
const refuseLive = Effect.fnUntraced(function* (store, held, refusal) {
|
|
60
|
+
const state = held === void 0 ? void 0 : yield* liveState(store, held);
|
|
61
|
+
if (held !== void 0 && state !== void 0) return yield* Effect.fail(refusal(held, state));
|
|
62
|
+
});
|
|
63
|
+
/** The live reservation of each target in `rows`, by `rows`' index: `undefined` where none. */
|
|
64
|
+
const liveReservations = (store, rows) => Effect.forEach(rows, (row) => Effect.flatMap(reservationOf(row), (reservation) => reservation === void 0 ? Effect.succeed(void 0) : Effect.map(isLive(store, reservation), (live) => live ? reservation : void 0)));
|
|
65
|
+
/**
|
|
66
|
+
* How a write gets past `topic`, live in `state`: before its publish decision, a `topics.remove`
|
|
67
|
+
* of it always works and frees what it holds, so the hint says to remove it first. Once it's
|
|
68
|
+
* publishing, it can't be removed, and the hint says to wait for it to merge. A refusal that
|
|
69
|
+
* didn't read its state, as a push's, names both.
|
|
70
|
+
*/
|
|
71
|
+
const liveHint = (topic, state) => {
|
|
72
|
+
if (state === "publishing") return `Topic ${topic} is publishing its saved decision: wait for it to merge`;
|
|
73
|
+
const remove = `Remove topic ${topic} with topics.remove first`;
|
|
74
|
+
return state === void 0 ? `${remove}, or wait for it to merge` : remove;
|
|
75
|
+
};
|
|
76
|
+
/** A write to a target a live reservation holds, its topic in `state`: refused, naming the topic. */
|
|
77
|
+
const reservedTarget = (target, reservation, state) => gitError("FAILED_PRECONDITION", `${target} is reserved by topic ${reservation.topic}`, { hint: liveHint(reservation.topic, state) });
|
|
78
|
+
/** A delete or rename of a repo with a target a live reservation holds: refused, naming the topic. */
|
|
79
|
+
const reservedRepo = (target, reservation, state) => gitError("FAILED_PRECONDITION", `The repo's ${target} is reserved by topic ${reservation.topic}`, { hint: liveHint(reservation.topic, state) });
|
|
80
|
+
/** A write to a live topic's member, its topic in `state`: refused, naming the topic. */
|
|
81
|
+
const topicMember = (entry, reservation, state) => gitError("FAILED_PRECONDITION", `${entry} is a member of topic ${reservation.topic}`, { hint: liveHint(reservation.topic, state) });
|
|
82
|
+
export { Reservation, TopicState, isLive, liveReservations, liveState, refuseLive, reservationOf, reservedRepo, reservedTarget, topicKey, topicMember };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { isInternalId } from "../contracts/ids.mjs";
|
|
2
|
+
import { randomText } from "./random.mjs";
|
|
3
|
+
// src/store/scopes.ts
|
|
4
|
+
/** The catalogue: each name's entry, by `RepoId`. */
|
|
5
|
+
const catalogueScope = "git/repos";
|
|
6
|
+
const repoScope = (internalId) => `git/repo/${internalId}`;
|
|
7
|
+
const topicScope = (topic) => `git/topic/${topic}`;
|
|
8
|
+
/** The index across topics, `topics/directory.ts` says: no decision reads its state rows. */
|
|
9
|
+
const topicsScope = "git/topics";
|
|
10
|
+
const collections = {
|
|
11
|
+
/** In `git/repos`: a name's `RepoCatalogueEntry`. */
|
|
12
|
+
catalogue: "repos",
|
|
13
|
+
/** In `git/repos`: each fork's `ForkRow`, by `forkId`, so a source has one fork a holder. */
|
|
14
|
+
forks: "forks",
|
|
15
|
+
/**
|
|
16
|
+
* In `git/repos`: each fork's `ForkRow` again under each folder of its name, by its source's
|
|
17
|
+
* internal ID, the folder and the fork's `createdKey`, so `forks.list` reads a source's forks the
|
|
18
|
+
* newest first, under its token's reach alone. They commit and go with the fork's created rows.
|
|
19
|
+
*/
|
|
20
|
+
forksCreated: "forks-created",
|
|
21
|
+
/**
|
|
22
|
+
* In `git/repos`: each repo's `CreatedRow` under each folder of its name, `''` and each ending in
|
|
23
|
+
* a `/`, by the folder and its `createdKey`, so a list in create order reads exactly the repos
|
|
24
|
+
* under its reach, the oldest or the newest first, and never a row it may not show.
|
|
25
|
+
*/
|
|
26
|
+
folderCreated: "folder-created",
|
|
27
|
+
/**
|
|
28
|
+
* In `git/repos`: each public repo's `ForkRow`, its internal ID, by its name, so a signed-out
|
|
29
|
+
* list by name reads only public repos (#209). It commits with the entry that wins the name.
|
|
30
|
+
*/
|
|
31
|
+
publicNames: "public-names",
|
|
32
|
+
/**
|
|
33
|
+
* In `git/repos`: each public repo's `CreatedRow` under `''` and its owner's folder, by the
|
|
34
|
+
* folder and its `createdKey`, so a signed-out list in create order reads only public repos.
|
|
35
|
+
* Create order takes no deeper prefix, so a repo has two, beside its entry's commit.
|
|
36
|
+
*/
|
|
37
|
+
publicCreated: "public-created",
|
|
38
|
+
/** In `git/repos`: the server's own keys, by use: `cursor`, which seals every list's cursor. */
|
|
39
|
+
keys: "keys",
|
|
40
|
+
/** In a repo's scope: its own record, `self`. */
|
|
41
|
+
repo: "repo",
|
|
42
|
+
/** In a repo's scope: each ref's `RefRow`, by its full name. */
|
|
43
|
+
refs: "refs",
|
|
44
|
+
/** In a repo's scope: each push `hooks.postReceive` owes, by the version its commit made. */
|
|
45
|
+
pushes: "pushes",
|
|
46
|
+
/** In a repo's scope: how far `git.post-receive` has gone, newest first, by `cursorId`. */
|
|
47
|
+
postReceive: "post-receive",
|
|
48
|
+
packs: "packs",
|
|
49
|
+
/** In a repo's scope: a keyed write's receipt, by its padded day and its key's SHA-256. */
|
|
50
|
+
receipts: "receipts",
|
|
51
|
+
/**
|
|
52
|
+
* In a repo's scope: an empty row beside each receipt, by its ID, which upkeep's sweep reads in
|
|
53
|
+
* place of the receipts, so a page of them stays small whatever each receipt holds.
|
|
54
|
+
*/
|
|
55
|
+
receiptIndex: "receipt-index",
|
|
56
|
+
/**
|
|
57
|
+
* In a repo's scope: each own write, an object a caller wrote through an object write, by its
|
|
58
|
+
* day, its actor's digest and its ID, which that caller reads for a day (Q773).
|
|
59
|
+
*/
|
|
60
|
+
ownWrites: "own-writes",
|
|
61
|
+
/** In a repo's scope: its import's `ImportRow`, `self`, and `cancel` once it's cancelled. */
|
|
62
|
+
imports: "imports",
|
|
63
|
+
/** In a repo's scope: each mirror's `MirrorRow`, by the full name of the ref it pushes. */
|
|
64
|
+
mirrors: "mirrors",
|
|
65
|
+
tokens: "tokens",
|
|
66
|
+
/** A token's write key, so a key sent again is refused: the secret is shown once. */
|
|
67
|
+
tokenKeys: "token-keys",
|
|
68
|
+
/** A token's ID after its padded `expiresAt`, so cleanup reads the oldest first. */
|
|
69
|
+
tokenExpiry: "token-expiry",
|
|
70
|
+
/** In a repo's scope: each LFS object the repo lists, by its oid. Only a deleted repo unlists. */
|
|
71
|
+
lfsObjects: "lfs-objects",
|
|
72
|
+
/** In a repo's scope: each LFS object an upload link was given for, by its oid, until listed. */
|
|
73
|
+
lfsUploads: "lfs-uploads",
|
|
74
|
+
/** In a repo's scope: a Worker upload's staging key, by its due `removeAt` and its ID. */
|
|
75
|
+
lfsStaging: "lfs-staging",
|
|
76
|
+
/** In a repo's scope: an LFS object upkeep is deleting, by its oid, which no verify lists. */
|
|
77
|
+
lfsEnding: "lfs-ending",
|
|
78
|
+
/** In a repo's scope: each LFS lock, by its path's SHA-256. */
|
|
79
|
+
lfsLocks: "lfs-locks",
|
|
80
|
+
/**
|
|
81
|
+
* In a repo's scope: each large push's pack uploading to the bucket, by its handle, until it's
|
|
82
|
+
* pushed or upkeep ends it.
|
|
83
|
+
*/
|
|
84
|
+
pushUploads: "push-uploads",
|
|
85
|
+
/** In a topic's scope: its own row, `self`, with its state. */
|
|
86
|
+
topic: "topic",
|
|
87
|
+
/** In `git/topics`: each key's topic, claimed by the first `topics.add` that names the key. */
|
|
88
|
+
topicKeys: "topic-keys",
|
|
89
|
+
/** In `git/topics`: each topic's state and the revision of its row it was projected from. */
|
|
90
|
+
topicIndex: "topics",
|
|
91
|
+
/** In `git/topics`: each topic again, by `<state>/<topic>`, so a list by state reads a prefix. */
|
|
92
|
+
topicStates: "topic-states",
|
|
93
|
+
/** In a repo's scope: the merge queue's `self`, which numbers its IDs. */
|
|
94
|
+
queue: "queue",
|
|
95
|
+
/** In a repo's scope: each target's open entries, candidates and holds, by its full name. */
|
|
96
|
+
queueTargets: "queue-targets",
|
|
97
|
+
queueEntries: "queue-entries",
|
|
98
|
+
queueCandidates: "queue-candidates",
|
|
99
|
+
queueHolds: "queue-holds",
|
|
100
|
+
/** In a repo's scope: an entry's `meta`, by the entry's ID, which no write of its target reads. */
|
|
101
|
+
queueMeta: "queue-meta",
|
|
102
|
+
/** In a repo's scope: a candidate's report, by the candidate's ID, which an entry it judged reads. */
|
|
103
|
+
queueReports: "queue-reports",
|
|
104
|
+
/** In a repo's scope: the entry each key merged last, by `[target, key]` as JSON. */
|
|
105
|
+
queueKeys: "queue-keys",
|
|
106
|
+
/** In a repo's scope: upkeep's own rows, such as the `pruned` mark. */
|
|
107
|
+
upkeep: "upkeep",
|
|
108
|
+
/**
|
|
109
|
+
* In a repo's scope: the times its stats show, each a `StatsTime`: `pushed`, put by every commit
|
|
110
|
+
* that moves a ref, and `maintained`, by repack's last step.
|
|
111
|
+
*/
|
|
112
|
+
stats: "stats"
|
|
113
|
+
};
|
|
114
|
+
/** A fork's row's ID in `git/repos`' `forks`: its source's internal ID and its holder. */
|
|
115
|
+
const forkId = (source, holder) => `${source}:${holder}`;
|
|
116
|
+
/** A repo's own record, in its scope: Git's alone, which no feature's commit may touch. */
|
|
117
|
+
const selfKey = {
|
|
118
|
+
collection: collections.repo,
|
|
119
|
+
id: "self"
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* The repo's prune mark: a new ID each time a prune drops objects. A push reads it first and
|
|
123
|
+
* again at its commit, and fails if it moved, so no ref names an object a prune dropped (Q270).
|
|
124
|
+
*/
|
|
125
|
+
const prunedKey = {
|
|
126
|
+
collection: collections.upkeep,
|
|
127
|
+
id: "pruned"
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* The repo's `ReachedMark`: written when a repo is made, cleared by any commit that can't show both
|
|
131
|
+
* its halves, and written again by a prune pass that shows them, as `ReachedMark` says.
|
|
132
|
+
*/
|
|
133
|
+
const reachedKey = {
|
|
134
|
+
collection: collections.upkeep,
|
|
135
|
+
id: "reached"
|
|
136
|
+
};
|
|
137
|
+
/** When a commit last moved one of the repo's refs, whatever the path: `stats.pushedAt`. */
|
|
138
|
+
const pushedKey = {
|
|
139
|
+
collection: collections.stats,
|
|
140
|
+
id: "pushed"
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* On a server with `access`, when a commit last moved a ref private by `pattern`: `pushedKey`
|
|
144
|
+
* then counts public refs alone, so a hidden push moves only what its readers see.
|
|
145
|
+
*/
|
|
146
|
+
const pushedUnder = (pattern) => ({
|
|
147
|
+
collection: collections.stats,
|
|
148
|
+
id: `pushed/${pattern}`
|
|
149
|
+
});
|
|
150
|
+
/** When repack last finished a run on the repo: `stats.maintainedAt`. */
|
|
151
|
+
const maintainedKey = {
|
|
152
|
+
collection: collections.stats,
|
|
153
|
+
id: "maintained"
|
|
154
|
+
};
|
|
155
|
+
/** A new repo's internal ID: `r_` and 12 random bytes. */
|
|
156
|
+
const newInternalId = () => `r_${randomText(12)}`;
|
|
157
|
+
/** The repo a scope is, or `undefined` for a scope that's no repo's, such as a prefix's. */
|
|
158
|
+
const scopeRepo = (scope) => {
|
|
159
|
+
const id = scope.slice(9);
|
|
160
|
+
return scope.startsWith("git/repo/") && isInternalId(id) ? id : void 0;
|
|
161
|
+
};
|
|
162
|
+
/** The repo whose scope one of Git's per-repo jobs runs in: in any other scope, it's a defect. */
|
|
163
|
+
const jobRepo = (job) => {
|
|
164
|
+
const id = scopeRepo(job.scope);
|
|
165
|
+
if (id === void 0) throw new TypeError(`'${job.name}' ran in '${job.scope}', which isn't a repo's scope`);
|
|
166
|
+
return id;
|
|
167
|
+
};
|
|
168
|
+
/** A commit's own ID, for a change no caller's key names. */
|
|
169
|
+
const newChangeId = () => randomText(16);
|
|
170
|
+
export { catalogueScope, collections, forkId, jobRepo, maintainedKey, newChangeId, newInternalId, prunedKey, pushedKey, pushedUnder, reachedKey, repoScope, scopeRepo, selfKey, topicScope, topicsScope };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { storeCall } from "./errors.mjs";
|
|
2
|
+
import { entryOf, project } from "./catalogue.mjs";
|
|
3
|
+
import { dropUnconfirmed, headKey } from "./outbox.mjs";
|
|
4
|
+
import { takenBack } from "./records.mjs";
|
|
5
|
+
import { writeRecord } from "./repo-record.mjs";
|
|
6
|
+
import { newChangeId, scopeRepo } from "./scopes.mjs";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
// src/store/settle.ts
|
|
9
|
+
/**
|
|
10
|
+
* Settles a create's or rename's name that no write has confirmed, as `git.list` would: its event
|
|
11
|
+
* is kept once the catalogue gives the repo the name, and dropped once it's lost, in one commit
|
|
12
|
+
* with the record taken back to the name a rename kept and its receipt deleted (Q171). A write that adds events without
|
|
13
|
+
* opening the repo by name settles it first, so nothing is ever behind that one event, and a
|
|
14
|
+
* lost rename's repo keeps every event since, under the name it kept (Q186). Answers whether it
|
|
15
|
+
* wrote, so the caller reads again.
|
|
16
|
+
*/
|
|
17
|
+
const settleName = Effect.fnUntraced(function* (store, scope, read) {
|
|
18
|
+
const { version, head, record } = read;
|
|
19
|
+
const { unconfirmed } = head;
|
|
20
|
+
const internalId = scopeRepo(scope);
|
|
21
|
+
if (unconfirmed === void 0 || internalId === void 0) return false;
|
|
22
|
+
const named = record?.deleted !== true && record?.name === unconfirmed.name ? record : void 0;
|
|
23
|
+
const outcome = named === void 0 ? "lost" : yield* project(store, internalId, named);
|
|
24
|
+
const back = outcome === "lost" && named !== void 0 ? takenBack(named) : void 0;
|
|
25
|
+
const left = back === void 0 ? void 0 : yield* entryOf(store, back.record.name);
|
|
26
|
+
if (outcome === "won" || back !== void 0 && !ownLive(left, internalId)) {
|
|
27
|
+
const confirmed = { ...head };
|
|
28
|
+
delete confirmed.unconfirmed;
|
|
29
|
+
const put = [{
|
|
30
|
+
...headKey,
|
|
31
|
+
value: confirmed
|
|
32
|
+
}];
|
|
33
|
+
yield* storeCall(() => store.commit(scope, {
|
|
34
|
+
id: newChangeId(),
|
|
35
|
+
expect: version,
|
|
36
|
+
put
|
|
37
|
+
}));
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
if (back !== void 0) {
|
|
41
|
+
const dropped = dropUnconfirmed(head);
|
|
42
|
+
const write = {
|
|
43
|
+
expect: version,
|
|
44
|
+
record: back.record,
|
|
45
|
+
put: dropped.put
|
|
46
|
+
};
|
|
47
|
+
yield* writeRecord(store, internalId, {
|
|
48
|
+
...write,
|
|
49
|
+
delete: [...back.delete, ...dropped.delete]
|
|
50
|
+
});
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
const change = {
|
|
54
|
+
id: newChangeId(),
|
|
55
|
+
expect: version,
|
|
56
|
+
...dropUnconfirmed(head)
|
|
57
|
+
};
|
|
58
|
+
yield* storeCall(() => store.commit(scope, change));
|
|
59
|
+
return true;
|
|
60
|
+
});
|
|
61
|
+
/** Whether a name's entry is still this repo's own, and live: the name a lost rename left. */
|
|
62
|
+
const ownLive = (entry, internalId) => entry?.internalId === internalId && entry.deleted !== true;
|
|
63
|
+
export { settleName };
|