@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,266 @@
|
|
|
1
|
+
import { fromDiff } from "../../engine/failures.mjs";
|
|
2
|
+
import { limitsOf } from "../../engine/reads.mjs";
|
|
3
|
+
import { drained } from "../../protocol/diff/read.mjs";
|
|
4
|
+
import { decodeCommit, encodeCommit } from "../../protocol/objects/commit.mjs";
|
|
5
|
+
import { objectBytesMost, objectTooLarge } from "../../protocol/objects/held.mjs";
|
|
6
|
+
import { objectId } from "../../protocol/objects/object.mjs";
|
|
7
|
+
import { memoryPack } from "../../storage/fetch.mjs";
|
|
8
|
+
import { fail, gitError } from "../../store/errors.mjs";
|
|
9
|
+
import { keptKey } from "../../store/records.mjs";
|
|
10
|
+
import { contended, keyedRecord } from "../access.mjs";
|
|
11
|
+
import { keyedPushWith, pushWith } from "../push.mjs";
|
|
12
|
+
import { ownWriter, ownWrites } from "../own-writes.mjs";
|
|
13
|
+
import { objectAnswer } from "../receipts.mjs";
|
|
14
|
+
import { objectIn, openKeyedRead } from "./reading.mjs";
|
|
15
|
+
import { tryUnlessSpent } from "../../contracts/calls-spent.mjs";
|
|
16
|
+
import { limits } from "@ref0/infra";
|
|
17
|
+
import * as Effect from "effect/Effect";
|
|
18
|
+
import * as Predicate from "effect/Predicate";
|
|
19
|
+
import * as Hex from "effect/encoding/Hex";
|
|
20
|
+
/** The most the objects one write makes hold together. */
|
|
21
|
+
const writeBytesMost = 67108864;
|
|
22
|
+
/**
|
|
23
|
+
* The most objects one write makes on a server with `access`, 4,950: each takes up to two of a
|
|
24
|
+
* commit's 10,000 writes, its own write and its row where objects are rows, as `loose()` keeps
|
|
25
|
+
* every object and `packs()` a small push, beside the push's other rows. Past it the write is
|
|
26
|
+
* refused before its pack is built, for every caller alike, an owner too, so the refusal says
|
|
27
|
+
* nothing of what the caller sees (Q790).
|
|
28
|
+
*/
|
|
29
|
+
const accessObjectsMost = Math.floor((limits.writes - 100) / 2);
|
|
30
|
+
/** A write past `accessObjectsMost`, before its pack is built. */
|
|
31
|
+
const tooManyMade = (count) => fail("RESOURCE_EXHAUSTED", `The write makes ${count} objects, past the ${accessObjectsMost} one write makes on a server with private refs`, {
|
|
32
|
+
hint: "Write the objects in smaller groups",
|
|
33
|
+
context: { reason: "too-large" }
|
|
34
|
+
});
|
|
35
|
+
/** The objects one write makes, by ID, each once, within the write's limits. */
|
|
36
|
+
var MadeObjects = class {
|
|
37
|
+
#made = /* @__PURE__ */ new Map();
|
|
38
|
+
#bytes = 0;
|
|
39
|
+
/** The objects made, in the order first made. */
|
|
40
|
+
get objects() {
|
|
41
|
+
return [...this.#made.values()];
|
|
42
|
+
}
|
|
43
|
+
/** How many objects are made. */
|
|
44
|
+
get count() {
|
|
45
|
+
return this.#made.size;
|
|
46
|
+
}
|
|
47
|
+
/** The bytes they hold. */
|
|
48
|
+
get bytes() {
|
|
49
|
+
return this.#bytes;
|
|
50
|
+
}
|
|
51
|
+
get(oid) {
|
|
52
|
+
return this.#made.get(oid);
|
|
53
|
+
}
|
|
54
|
+
/** An object made: its ID. One past `objectBytesMost`, or the write past `writeBytesMost`, fails. */
|
|
55
|
+
add(type, bytes) {
|
|
56
|
+
return Effect.gen({ self: this }, function* () {
|
|
57
|
+
if (bytes.byteLength > 16777216) return yield* objectTooLarge(type, bytes.byteLength);
|
|
58
|
+
const oid = yield* objectId({
|
|
59
|
+
type,
|
|
60
|
+
bytes
|
|
61
|
+
});
|
|
62
|
+
if (this.#made.has(oid)) return oid;
|
|
63
|
+
this.#bytes += bytes.byteLength;
|
|
64
|
+
if (this.#bytes > 67108864) return yield* fail("RESOURCE_EXHAUSTED", `The write makes past ${writeBytesMost} bytes`, {
|
|
65
|
+
hint: "Write the objects in smaller groups",
|
|
66
|
+
context: { reason: "too-large" }
|
|
67
|
+
});
|
|
68
|
+
this.#made.set(oid, {
|
|
69
|
+
oid,
|
|
70
|
+
type,
|
|
71
|
+
bytes
|
|
72
|
+
});
|
|
73
|
+
return oid;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const encoder = new TextEncoder();
|
|
78
|
+
const isParts = (part) => Array.isArray(part);
|
|
79
|
+
/** Bytes over a buffer of their own, for Web Crypto: a view without a copy, or a copy of shared. */
|
|
80
|
+
const ownBuffer = (bytes) => bytes.buffer instanceof ArrayBuffer ? new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength) : new Uint8Array(bytes);
|
|
81
|
+
const sha256 = async (bytes) => new Uint8Array(await crypto.subtle.digest("SHA-256", ownBuffer(bytes)));
|
|
82
|
+
/** A record's fields in the order of their names, so the order a caller built it in is no part. */
|
|
83
|
+
const sortedFields = (record) => Object.fromEntries(Object.entries(record).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
|
|
84
|
+
/** Each distinct byte array among a write's parts, so an array many edits name is hashed once. */
|
|
85
|
+
const arraysIn = (parts) => {
|
|
86
|
+
const found = /* @__PURE__ */ new Set();
|
|
87
|
+
JSON.stringify(parts, (_key, value) => {
|
|
88
|
+
if (!(value instanceof Uint8Array)) return value;
|
|
89
|
+
found.add(value);
|
|
90
|
+
return null;
|
|
91
|
+
});
|
|
92
|
+
return [...found];
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* A write's input as the JSON its digest is of: the call and its parts, each record's fields by
|
|
96
|
+
* name and each byte array as its bytes' SHA-256, so equal bytes digest alike, shared or not.
|
|
97
|
+
*/
|
|
98
|
+
const digestText = (call, parts, hashes) => JSON.stringify([call, parts], (_key, value) => {
|
|
99
|
+
if (value instanceof Uint8Array) return { bytes: hashes.get(value) ?? "" };
|
|
100
|
+
return value === null || isParts(value) || Predicate.isString(value) || Predicate.isNumber(value) || Predicate.isBoolean(value) ? value : sortedFields(value);
|
|
101
|
+
});
|
|
102
|
+
/**
|
|
103
|
+
* The SHA-256 of a write's input, which its receipt keeps: the SHA-256 of its `digestText`. Each
|
|
104
|
+
* distinct byte array is hashed once, one at a time, since Web Crypto copies what it hashes.
|
|
105
|
+
*/
|
|
106
|
+
const writeDigest = (call, parts) => Effect.promise(async () => {
|
|
107
|
+
const hashes = /* @__PURE__ */ new Map();
|
|
108
|
+
for (const array of arraysIn(parts)) hashes.set(array, Hex.encode(await sha256(array)));
|
|
109
|
+
return Hex.encode(await sha256(encoder.encode(digestText(call, parts, hashes))));
|
|
110
|
+
});
|
|
111
|
+
/** The objects a merge made, read whole into `made`. */
|
|
112
|
+
const takeWrites = (made, writes) => Effect.gen(function* () {
|
|
113
|
+
const held = yield* tryUnlessSpent(async () => {
|
|
114
|
+
const all = [];
|
|
115
|
+
for await (const write of writes) all.push(write);
|
|
116
|
+
return all;
|
|
117
|
+
}, (cause) => gitError("INTERNAL", `The merge's objects failed mid-read: ${String(cause)}`));
|
|
118
|
+
for (const write of held) {
|
|
119
|
+
const bytes = yield* Effect.mapError(drained(write, objectBytesMost, { copy: true }), fromDiff("diff-limit"));
|
|
120
|
+
yield* made.add(write.type, new Uint8Array(bytes));
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
/** A commit made, its fields checked as Git writes them: one it can't write is refused. */
|
|
124
|
+
const madeCommit = (made, commit) => encodeCommit(commit).pipe(Effect.mapError((error) => gitError("INVALID_ARGUMENT", `The commit can't be written: ${error.message}`)), Effect.flatMap((bytes) => made.add("commit", bytes)));
|
|
125
|
+
/** A commit's answer, decoded from the commit a write made. */
|
|
126
|
+
const commitAnswer = (oid, object) => Effect.gen(function* () {
|
|
127
|
+
const { bytes } = yield* object();
|
|
128
|
+
return {
|
|
129
|
+
oid,
|
|
130
|
+
...yield* Effect.mapError(decodeCommit(bytes), (error) => gitError("DATA_LOSS", `The commit ${oid} is unreadable: ${error.message}`))
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
/** The ref edit a write's `ref` names, to the object it made. */
|
|
134
|
+
const publishOf = (ref, oid) => ref === void 0 ? void 0 : {
|
|
135
|
+
ref: refNameOf(ref.name),
|
|
136
|
+
from: ref.from,
|
|
137
|
+
to: oid
|
|
138
|
+
};
|
|
139
|
+
/** The answer `made` gives: its object, and the ref edit, if it names one. */
|
|
140
|
+
const madeOf = (oid, publish) => publish === void 0 ? { oid } : {
|
|
141
|
+
oid,
|
|
142
|
+
publish
|
|
143
|
+
};
|
|
144
|
+
/** A ref a write publishes: a full name as it is, a bare one as a branch. */
|
|
145
|
+
const refNameOf = (name) => name.startsWith("refs/") ? name : `refs/heads/${name}`;
|
|
146
|
+
/** An answer of the object's ID alone. */
|
|
147
|
+
const oidAnswer = (oid) => Effect.succeed({ oid });
|
|
148
|
+
/** An object a write made, read back whole from the repo it went to, for a write sent again. */
|
|
149
|
+
const readMade = Effect.fnUntraced(function* (core, repo, oid) {
|
|
150
|
+
const object = yield* objectIn(core, repo, oid);
|
|
151
|
+
const bytes = yield* Effect.mapError(drained(object, writeBytesMost), (error) => gitError("DATA_LOSS", `The object ${oid} is unreadable: ${error.message}`));
|
|
152
|
+
return {
|
|
153
|
+
oid,
|
|
154
|
+
type: object.type,
|
|
155
|
+
bytes: new Uint8Array(bytes)
|
|
156
|
+
};
|
|
157
|
+
});
|
|
158
|
+
/** A ref the decide refused fails the write, so nothing it made commits. */
|
|
159
|
+
const objectAnswers = (written) => ({
|
|
160
|
+
answer: (updated) => {
|
|
161
|
+
for (const update of updated.updates) if (update.kind === "rejected") return Effect.fail(update.error);
|
|
162
|
+
return Effect.succeed(written);
|
|
163
|
+
},
|
|
164
|
+
kept: (answer) => ({
|
|
165
|
+
kind: "object",
|
|
166
|
+
...answer
|
|
167
|
+
}),
|
|
168
|
+
held: objectAnswer
|
|
169
|
+
});
|
|
170
|
+
/**
|
|
171
|
+
* An object write: its key's receipt looked for, as `keyedRecord` says, which answers a write sent
|
|
172
|
+
* again; finding none, the repo opened with `read` and `object.create` authorized, the write's
|
|
173
|
+
* objects made, then one push of their pack, publishing its ref in the same commit. A write sent
|
|
174
|
+
* again finding no receipt writes only to the repo its look saw, and looks again once the name
|
|
175
|
+
* holds another, as `refs.update` does.
|
|
176
|
+
*/
|
|
177
|
+
const objectWrite = (core, write) => Effect.scoped(Effect.gen(function* () {
|
|
178
|
+
const { caller, repo, input } = write;
|
|
179
|
+
const limits = yield* limitsOf(input.limits);
|
|
180
|
+
const digest = input.key === void 0 ? "" : yield* writeDigest(write.call, write.parts);
|
|
181
|
+
const writer = core.access === void 0 ? void 0 : yield* ownWriter(caller);
|
|
182
|
+
for (let attempt = 0; attempt < 5; attempt += 1) {
|
|
183
|
+
const at = yield* core.now;
|
|
184
|
+
const kept = yield* keptKey(caller, input.key, [write.call, digest], at);
|
|
185
|
+
const keyed = yield* keyedRecord(core.store, repo, kept, (access) => Effect.andThen(core.authorize({
|
|
186
|
+
caller,
|
|
187
|
+
operation: {
|
|
188
|
+
kind: "read",
|
|
189
|
+
repo: access.id
|
|
190
|
+
},
|
|
191
|
+
repo: access
|
|
192
|
+
}), core.authorize({
|
|
193
|
+
caller,
|
|
194
|
+
operation: {
|
|
195
|
+
kind: "object.create",
|
|
196
|
+
repo: access.id
|
|
197
|
+
},
|
|
198
|
+
repo: access
|
|
199
|
+
})), input.internalId);
|
|
200
|
+
if (keyed?.kind === "answered") {
|
|
201
|
+
const { oid, published, renamesSkipped } = yield* objectAnswer(keyed.receipt);
|
|
202
|
+
const object = () => readMade(core, keyed.repo, oid);
|
|
203
|
+
return yield* write.answer(oid, object, published, renamesSkipped);
|
|
204
|
+
}
|
|
205
|
+
const opened = yield* openKeyedRead(core, caller, repo, write.revisions ?? [], keyed, input.internalId);
|
|
206
|
+
if (opened === void 0) continue;
|
|
207
|
+
const target = {
|
|
208
|
+
id: opened.name,
|
|
209
|
+
public: opened.record.public,
|
|
210
|
+
internalId: opened.internalId
|
|
211
|
+
};
|
|
212
|
+
yield* core.authorize({
|
|
213
|
+
caller,
|
|
214
|
+
operation: {
|
|
215
|
+
kind: "object.create",
|
|
216
|
+
repo
|
|
217
|
+
},
|
|
218
|
+
repo: target
|
|
219
|
+
});
|
|
220
|
+
const made = new MadeObjects();
|
|
221
|
+
const answer = ({ oid, published, renamesSkipped }) => write.answer(oid, () => {
|
|
222
|
+
const object = made.get(oid);
|
|
223
|
+
return object === void 0 ? readMade(core, target, oid) : Effect.succeed(object);
|
|
224
|
+
}, published, renamesSkipped);
|
|
225
|
+
const { oid, publish, renamesSkipped } = yield* write.make(opened, made, limits);
|
|
226
|
+
const written = (published) => renamesSkipped === void 0 ? {
|
|
227
|
+
oid,
|
|
228
|
+
published
|
|
229
|
+
} : {
|
|
230
|
+
oid,
|
|
231
|
+
published,
|
|
232
|
+
renamesSkipped
|
|
233
|
+
};
|
|
234
|
+
if (made.objects.length === 0 && publish === void 0 && kept === void 0) return yield* answer(written(false));
|
|
235
|
+
const request = {
|
|
236
|
+
caller,
|
|
237
|
+
repo,
|
|
238
|
+
source: "api",
|
|
239
|
+
edits: publish === void 0 ? [] : [publish],
|
|
240
|
+
atomic: true
|
|
241
|
+
};
|
|
242
|
+
if (core.access !== void 0 && made.count > accessObjectsMost) return yield* tooManyMade(made.count);
|
|
243
|
+
if (writer !== void 0 && made.count > 0) {
|
|
244
|
+
const oids = made.objects.map((object) => object.oid);
|
|
245
|
+
request.also = (committed) => ownWrites(writer, oids, committed, core.repackJobRow);
|
|
246
|
+
request.own = oids;
|
|
247
|
+
}
|
|
248
|
+
if (made.objects.length > 0) request.pack = {
|
|
249
|
+
bytes: (yield* memoryPack(made.objects, {
|
|
250
|
+
bytes: made.bytes,
|
|
251
|
+
milliseconds: limits.milliseconds
|
|
252
|
+
}).pipe(Effect.mapError((error) => gitError("RESOURCE_EXHAUSTED", error.message, { context: { reason: "too-large" } })))).stream,
|
|
253
|
+
objects: made.objects.length
|
|
254
|
+
};
|
|
255
|
+
if (input.signal !== void 0) request.signal = input.signal;
|
|
256
|
+
if (input.internalId !== void 0) request.internalId = input.internalId;
|
|
257
|
+
const answers = objectAnswers(written(publish !== void 0));
|
|
258
|
+
const answered = kept === void 0 || keyed === void 0 ? yield* pushWith(core, request, answers) : yield* keyedPushWith(core, request, answers, {
|
|
259
|
+
key: kept,
|
|
260
|
+
missed: keyed
|
|
261
|
+
});
|
|
262
|
+
if (answered !== void 0) return yield* answer(answered);
|
|
263
|
+
}
|
|
264
|
+
return yield* contended();
|
|
265
|
+
}));
|
|
266
|
+
export { MadeObjects, accessObjectsMost, commitAnswer, madeCommit, madeOf, objectWrite, oidAnswer, publishOf, refNameOf, takeWrites, writeBytesMost, writeDigest };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { decodeRow, storeCall } from "../store/errors.mjs";
|
|
2
|
+
import { collections, repoScope } from "../store/scopes.mjs";
|
|
3
|
+
import { dayMs, dayOf, sweepDue, sweepOf } from "./receipts.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
import * as Hex from "effect/encoding/Hex";
|
|
7
|
+
// src/core/own-writes.ts
|
|
8
|
+
/**
|
|
9
|
+
* An own write: an object a caller made through an object write, `blobs.create`, `trees.create`,
|
|
10
|
+
* `trees.merge`, `commits.create` and the rest, which that caller reads for a day after, or until
|
|
11
|
+
* a prune pass drops it, though no ref it sees reaches it yet (Q773). Each object the write
|
|
12
|
+
* produces counts, whether or not the repo held it already, so writing an object answers the same
|
|
13
|
+
* whatever the repo holds. A push keeps none: its objects are reached from the refs it moves.
|
|
14
|
+
*
|
|
15
|
+
* - Only the actor that wrote it reads it so, and only through the API's reads and writes: a
|
|
16
|
+
* fetch reads only what the refs it sees reach, so a bare ID it fetches is refused, as any
|
|
17
|
+
* unreachable object is, and a have of one is no common base, until a ref it sees reaches it.
|
|
18
|
+
* - It's read only while the repo holds the object: one a prune pass dropped reads as missing,
|
|
19
|
+
* though its row's day isn't out, as `packs()`' `prune` may be shorter than a day, since every
|
|
20
|
+
* lookup through a view answers only what storage holds (`narrowedTo`,
|
|
21
|
+
* `storage/pack-reads.ts`).
|
|
22
|
+
* - The same actor writing the same object on a later day keeps it a day from then.
|
|
23
|
+
* - An object a ref reached when the caller wrote it, which is hidden since, stays readable to
|
|
24
|
+
* that caller through its own write for at most the day (Q773).
|
|
25
|
+
*/
|
|
26
|
+
const OwnWrite = Schema.Struct({ at: Schema.Int });
|
|
27
|
+
/** How long a caller reads what it wrote: a day from when it wrote it. */
|
|
28
|
+
const ownWriteKept = dayMs;
|
|
29
|
+
/**
|
|
30
|
+
* The writer of `caller`'s own writes: the SHA-256 of its actor's ID, so every row's ID is one
|
|
31
|
+
* length whatever the host's IDs hold. None for an anonymous actor, which has no ID to keep them
|
|
32
|
+
* by, so it reads only what its refs reach.
|
|
33
|
+
*/
|
|
34
|
+
const ownWriter = (caller) => {
|
|
35
|
+
const { actor } = caller;
|
|
36
|
+
if (actor.anonymous === true) return Effect.succeed(void 0);
|
|
37
|
+
const bytes = new TextEncoder().encode(JSON.stringify(actor.id));
|
|
38
|
+
return Effect.promise(() => crypto.subtle.digest("SHA-256", bytes)).pipe(Effect.map((digest) => Hex.encode(new Uint8Array(digest))));
|
|
39
|
+
};
|
|
40
|
+
/** An own write's ID: the day it was written in, padded so the oldest read first, its writer and its object. */
|
|
41
|
+
const ownWriteId = (at, writer, oid) => `${dayOf(at)}:${writer}:${oid}`;
|
|
42
|
+
/**
|
|
43
|
+
* What an object write adds to its push's commit: a row for each object it made, kept for
|
|
44
|
+
* `writer` from `at`, the commit's own time, and `git.repack` due when they're swept, from
|
|
45
|
+
* `repackJobRow`. A write whose objects the repo held already adds no pack, so its push schedules
|
|
46
|
+
* no step of its own.
|
|
47
|
+
*/
|
|
48
|
+
const ownWrites = (writer, oids, at, repackJobRow) => ({
|
|
49
|
+
put: oids.map((oid) => ({
|
|
50
|
+
collection: collections.ownWrites,
|
|
51
|
+
id: ownWriteId(at, writer, oid),
|
|
52
|
+
value: { at }
|
|
53
|
+
})),
|
|
54
|
+
jobs: oids.length === 0 ? [] : [repackJobRow(sweepDue(at))]
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* Which of `oids` `writer` wrote in repo `internalId` within the day before `at`: one read of
|
|
58
|
+
* each one's rows from today and yesterday, one call for every ID.
|
|
59
|
+
*/
|
|
60
|
+
const ownWritesOf = Effect.fnUntraced(function* (store, internalId, writer, oids, at) {
|
|
61
|
+
const days = [at, at - dayMs];
|
|
62
|
+
const reads = oids.flatMap((oid) => days.map((day) => ({
|
|
63
|
+
collection: collections.ownWrites,
|
|
64
|
+
id: ownWriteId(day, writer, oid)
|
|
65
|
+
})));
|
|
66
|
+
const snapshot = yield* storeCall(() => store.read(repoScope(internalId), reads));
|
|
67
|
+
const own = /* @__PURE__ */ new Set();
|
|
68
|
+
for (const [index, rows] of snapshot.results.entries()) {
|
|
69
|
+
const oid = oids[Math.floor(index / days.length)];
|
|
70
|
+
for (const row of rows) {
|
|
71
|
+
const write = yield* decodeRow(OwnWrite, row, `Own write '${row.id}'`);
|
|
72
|
+
if (oid !== void 0 && at < write.at + ownWriteKept) own.add(oid);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return own;
|
|
76
|
+
});
|
|
77
|
+
/** What `git.repack` reads to sweep own writes: the oldest first. */
|
|
78
|
+
const ownSweepRead = {
|
|
79
|
+
collection: collections.ownWrites,
|
|
80
|
+
limit: 500
|
|
81
|
+
};
|
|
82
|
+
const ownKey = (id) => [{
|
|
83
|
+
collection: collections.ownWrites,
|
|
84
|
+
id
|
|
85
|
+
}];
|
|
86
|
+
/**
|
|
87
|
+
* A sweep step's own writes, of `rows` read by `ownSweepRead`: those whose days are past at
|
|
88
|
+
* `at`, or, for a repo that's deleted, every one, whatever its age, before its packs go.
|
|
89
|
+
*/
|
|
90
|
+
const ownSweepOf = (rows, at, deleted) => deleted ? {
|
|
91
|
+
delete: rows.flatMap(({ id }) => ownKey(id)),
|
|
92
|
+
more: rows.length === 500
|
|
93
|
+
} : sweepOf(rows, at, ownKey);
|
|
94
|
+
export { OwnWrite, ownSweepOf, ownSweepRead, ownWriteKept, ownWriter, ownWrites, ownWritesOf };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { handedScope } from "../store/call-count.mjs";
|
|
2
|
+
import { answerSpent } from "../store/errors.mjs";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
// src/core/promise.ts
|
|
6
|
+
const hasSignal = Schema.is(Schema.Struct({ signal: Schema.instanceOf(AbortSignal) }));
|
|
7
|
+
/** The `signal` a call's last argument holds: its input, which comes last in every call. */
|
|
8
|
+
const signalOf = (args) => {
|
|
9
|
+
const input = args.at(-1);
|
|
10
|
+
return hasSignal(input) ? input.signal : void 0;
|
|
11
|
+
};
|
|
12
|
+
const isCall = (value) => value instanceof Function;
|
|
13
|
+
/** `calls`, each call's Effect as `around` makes it, with the same inputs and answer. */
|
|
14
|
+
const aroundCalls = (calls, around) => {
|
|
15
|
+
const entries = Object.entries(calls).map(([name, value]) => {
|
|
16
|
+
if (!isCall(value)) return [name, aroundCalls(value, around)];
|
|
17
|
+
const call = (...args) => around(value(...args));
|
|
18
|
+
return [name, call];
|
|
19
|
+
});
|
|
20
|
+
return Object.fromEntries(entries);
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* `effect` run after `guard`: an edge a host calls, where a spent call bound is answered as its
|
|
24
|
+
* refusal, never a defect. The server's `guard` marks it started for the call and refuses once
|
|
25
|
+
* it's closed, as `promiseCalls`' `run` does; the client, with no server, passes `Effect.void`.
|
|
26
|
+
* Every Effect face's call goes through it, the twins `ExtendedGit` gives beside its Promise
|
|
27
|
+
* reads among them (Q830).
|
|
28
|
+
*/
|
|
29
|
+
const guardedCall = (guard) => (effect) => Effect.andThen(guard, answerSpent(effect));
|
|
30
|
+
/** `calls`, each a seam's call that `guardedCall` runs after `guard`. */
|
|
31
|
+
const guardedCalls = (calls, guard) => aroundCalls(calls, guardedCall(guard));
|
|
32
|
+
/**
|
|
33
|
+
* The Promise surface over `calls`, each call its Effect twin run by `run` with the input's
|
|
34
|
+
* `signal`, in the scope Git's own caller handed on in it, so its calls count at the doors into
|
|
35
|
+
* that request and its budget. Every call here answers a `Result`, which `EffectCalls` turns into
|
|
36
|
+
* the error channel.
|
|
37
|
+
*/
|
|
38
|
+
const promiseCalls = (calls, run) => {
|
|
39
|
+
const entries = Object.entries(calls).map(([name, value]) => {
|
|
40
|
+
if (!isCall(value)) return [name, promiseCalls(value, run)];
|
|
41
|
+
const call = (...args) => run(value(...args), handedScope(args.at(-1)), signalOf(args));
|
|
42
|
+
return [name, call];
|
|
43
|
+
});
|
|
44
|
+
return Object.fromEntries(entries);
|
|
45
|
+
};
|
|
46
|
+
export { aroundCalls, guardedCall, guardedCalls, promiseCalls };
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { handedCall, walkObjects } from "../storage/calls.mjs";
|
|
2
|
+
import { walkedVisible } from "../storage/visible.mjs";
|
|
3
|
+
import { onward, stepsOf } from "../storage/wants.mjs";
|
|
4
|
+
import { gitError } from "../store/errors.mjs";
|
|
5
|
+
import { ancestryLimit } from "./ancestry.mjs";
|
|
6
|
+
import { shortRef } from "./rules/patterns.mjs";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
// src/core/publish.ts
|
|
9
|
+
/** A publish walk past its bound, a public one's or a pattern's the caller reads. */
|
|
10
|
+
const walkTooLong = () => gitError("RESOURCE_EXHAUSTED", `Checking what this push would publish passed ${ancestryLimit.toLocaleString("en-US")} commits`, {
|
|
11
|
+
hint: "Push onto a newer commit, or ask someone who may publish every private pattern to push it",
|
|
12
|
+
context: { reason: "walk-limit" }
|
|
13
|
+
});
|
|
14
|
+
/** `error`, or the publish walk's own refusal for a set's walk past its bound. */
|
|
15
|
+
const asPublishWalk = (error) => error.code === "RESOURCE_EXHAUSTED" && error.context?.reason === "walk-limit" ? walkTooLong() : error;
|
|
16
|
+
/** What `set` holds of `oids`, a walk past its bound refused as the publish walk's. */
|
|
17
|
+
const heldBy = (set, oids, call) => handedCall(call, (at) => set.has(oids, at)).pipe(Effect.mapError(asPublishWalk));
|
|
18
|
+
/** Which of `oids` the repo's packs at `listed` hold, by ID, with no walk. */
|
|
19
|
+
const heldInRepo = (objects, listed, oids, call) => Effect.scoped(Effect.gen(function* () {
|
|
20
|
+
const held = yield* (yield* walkObjects(objects)).headers(listed, {
|
|
21
|
+
oids,
|
|
22
|
+
...call
|
|
23
|
+
});
|
|
24
|
+
return oids.filter((oid) => held.has(oid));
|
|
25
|
+
}));
|
|
26
|
+
/** A reader's refusal: the pattern's first ref the caller sees whose history the move exposes. */
|
|
27
|
+
const publishesRead = (ref, count, from, pattern) => gitError("NOT_ALLOWED", `Moving ${shortRef(ref)} would publish ${count} ${count === 1 ? "commit" : "commits"} from ${shortRef(from)}, which you can read but not publish`, { hint: `Ask someone who may publish ${pattern} to merge it` });
|
|
28
|
+
/** A non-reader's refusal, which names nothing they can't read (the coordinator, 22 Nov). */
|
|
29
|
+
const publishesUnread = (ref) => gitError("NOT_ALLOWED", `Moving ${shortRef(ref)} would publish commits you may not publish`, { hint: "Ask the repo's owner" });
|
|
30
|
+
/**
|
|
31
|
+
* The commits `tip` reaches that `audience` doesn't, read through `objects`: a walk from the tip
|
|
32
|
+
* down to the first commits the audience reaches, the push's own new commits among them.
|
|
33
|
+
*/
|
|
34
|
+
const exposedFrom = Effect.fnUntraced(function* (objects, listed, tip, audience, signal) {
|
|
35
|
+
const call = signal === void 0 ? {} : { signal };
|
|
36
|
+
const exposed = [];
|
|
37
|
+
const passed = /* @__PURE__ */ new Set([tip]);
|
|
38
|
+
let frontier = [tip];
|
|
39
|
+
while (frontier.length > 0) {
|
|
40
|
+
if (passed.size > 1e4) return yield* Effect.fail(walkTooLong());
|
|
41
|
+
const inside = yield* heldBy(audience, frontier, call);
|
|
42
|
+
const outside = frontier.filter((oid) => !inside.has(oid));
|
|
43
|
+
const read = (oid) => objects.read(listed, {
|
|
44
|
+
oid,
|
|
45
|
+
...call
|
|
46
|
+
});
|
|
47
|
+
const found = yield* Effect.forEach(outside, read, { concurrency: 16 });
|
|
48
|
+
frontier = [];
|
|
49
|
+
for (const object of found) {
|
|
50
|
+
if (object === void 0) continue;
|
|
51
|
+
if (object.type === "commit") exposed.push(object.oid);
|
|
52
|
+
const steps = yield* stepsOf(object, false);
|
|
53
|
+
for (const oid of onward(steps)) {
|
|
54
|
+
if (passed.has(oid)) continue;
|
|
55
|
+
passed.add(oid);
|
|
56
|
+
frontier.push(oid);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return exposed;
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* Whether `sight` may publish `pattern`: only when it reads the pattern too, whatever its
|
|
64
|
+
* `publishes` says, since a caller can't publish history it can't read (the coordinator, 22 Nov).
|
|
65
|
+
*/
|
|
66
|
+
const publishable = (sight, pattern) => sight.reads(pattern) && sight.publishes(pattern);
|
|
67
|
+
/**
|
|
68
|
+
* A reader's refusal of a move to `ref` that exposes `exposed`: the first barred pattern the
|
|
69
|
+
* caller reads, other than `own`, that reaches one of them, named with how many and the first of
|
|
70
|
+
* its refs, by name, whose own history holds one.
|
|
71
|
+
*/
|
|
72
|
+
const readRefusal = Effect.fnUntraced(function* (input, ref, own, exposed, walked, reach, named) {
|
|
73
|
+
const call = input.signal === void 0 ? {} : { signal: input.signal };
|
|
74
|
+
for (const [pattern, set] of walked) {
|
|
75
|
+
if (pattern === own || publishable(input.sight, pattern)) continue;
|
|
76
|
+
const held = yield* heldBy(set, exposed, call);
|
|
77
|
+
if (held.size === 0) continue;
|
|
78
|
+
const shown = [...held];
|
|
79
|
+
let from = pattern;
|
|
80
|
+
for (const [name, oid] of named) {
|
|
81
|
+
if (input.access.patternOf(name) !== pattern) continue;
|
|
82
|
+
if ((yield* heldBy(reach([oid]), shown, call)).size > 0) {
|
|
83
|
+
from = name;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return publishesRead(ref, held.size, from, pattern);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
/** Each edit `input` refuses as publishing what its caller may not, with why. */
|
|
91
|
+
const unpublished = Effect.fnUntraced(function* (input) {
|
|
92
|
+
const { access, sight, refs } = input;
|
|
93
|
+
const refused = /* @__PURE__ */ new Map();
|
|
94
|
+
const barred = access.patterns.filter((pattern) => !publishable(sight, pattern));
|
|
95
|
+
const moves = input.edits.filter((edit) => edit.to !== null);
|
|
96
|
+
if (barred.length === 0 || moves.length === 0) return refused;
|
|
97
|
+
const call = input.signal === void 0 ? {} : { signal: input.signal };
|
|
98
|
+
const bound = {
|
|
99
|
+
most: ancestryLimit,
|
|
100
|
+
commits: true
|
|
101
|
+
};
|
|
102
|
+
const reach = (tips) => walkedVisible(input.objects, input.listed, { tips }, bound);
|
|
103
|
+
const named = [...refs].toSorted(([one], [other]) => one < other ? -1 : 1);
|
|
104
|
+
const tipsOf = (keep) => named.flatMap(([ref, oid]) => keep(access.patternOf(ref)) ? [oid] : []);
|
|
105
|
+
const walked = new Map(access.patterns.filter((pattern) => sight.reads(pattern)).map((pattern) => [pattern, reach(tipsOf((one) => one === pattern))]));
|
|
106
|
+
const unread = barred.some((pattern) => !sight.reads(pattern));
|
|
107
|
+
const audiences = /* @__PURE__ */ new Map();
|
|
108
|
+
/** Each move whose exposed commits no walk answered, for the repo's packs to, by ID. */
|
|
109
|
+
const byId = [];
|
|
110
|
+
for (const edit of moves) {
|
|
111
|
+
const to = edit.to;
|
|
112
|
+
if (to === null) continue;
|
|
113
|
+
const own = access.patternOf(edit.ref);
|
|
114
|
+
const audience = audiences.get(own) ?? reach(tipsOf((one) => one === void 0 || one === own));
|
|
115
|
+
audiences.set(own, audience);
|
|
116
|
+
let left = yield* exposedFrom(input.pushed, input.pushedListed, to, audience, input.signal);
|
|
117
|
+
for (const [pattern, set] of walked) {
|
|
118
|
+
if (left.length === 0) break;
|
|
119
|
+
if (pattern === own || !publishable(sight, pattern)) continue;
|
|
120
|
+
const held = yield* heldBy(set, left, call);
|
|
121
|
+
left = left.filter((oid) => !held.has(oid));
|
|
122
|
+
}
|
|
123
|
+
if (left.length === 0) continue;
|
|
124
|
+
const refusal = yield* readRefusal(input, edit.ref, own, left, walked, reach, named);
|
|
125
|
+
if (refusal !== void 0) {
|
|
126
|
+
refused.set(edit.ref, refusal);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (unread) byId.push({
|
|
130
|
+
ref: edit.ref,
|
|
131
|
+
left
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
const asked = [...new Set(byId.flatMap(({ left }) => left))];
|
|
135
|
+
const written = input.own === void 0 || asked.length === 0 ? /* @__PURE__ */ new Set() : yield* input.own(asked);
|
|
136
|
+
for (const { ref, left } of byId) {
|
|
137
|
+
const others = left.filter((oid) => !written.has(oid));
|
|
138
|
+
if ((others.length === 0 ? [] : yield* heldInRepo(input.objects, input.listed, others, call)).length > 0) refused.set(ref, publishesUnread(ref));
|
|
139
|
+
}
|
|
140
|
+
return refused;
|
|
141
|
+
});
|
|
142
|
+
export { publishable, unpublished };
|