@ref0/git 0.0.0 → 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 +86 -5
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
import { hostCall } from "../auth/host-function.mjs";
|
|
2
|
+
import { advanceRow } from "../store/queue-jobs.mjs";
|
|
3
|
+
import { storeCall } from "../store/errors.mjs";
|
|
4
|
+
import { runIn, runJobTry, uncounted } from "../store/crossing.mjs";
|
|
5
|
+
import { repoScope } from "../store/scopes.mjs";
|
|
6
|
+
import { CandidateSetData, PrepareData, TopicAdvanceData, prepareName, prepareRow, reportTimeoutName, reportTimeoutRow, topicAdvanceName, topicAdvanceRow } from "../store/topic-jobs.mjs";
|
|
7
|
+
import { projectTopic } from "./directory.mjs";
|
|
8
|
+
import { saveMargin } from "./host.mjs";
|
|
9
|
+
import { addMember, candidateAt, memberRead, releaseMember, reserveMember } from "./members.mjs";
|
|
10
|
+
import { commitTopic, currentSet, durationWords, entriesOf, failureOf, readTopic, setKeyOf, topicOf } from "./topic.mjs";
|
|
11
|
+
import { LostTry, defineJob, millis } from "@ref0/infra";
|
|
12
|
+
import * as Effect from "effect/Effect";
|
|
13
|
+
import * as Result from "effect/Result";
|
|
14
|
+
import * as Schema from "effect/Schema";
|
|
15
|
+
import * as Predicate from "effect/Predicate";
|
|
16
|
+
// src/topics/advance.ts
|
|
17
|
+
/**
|
|
18
|
+
* `git.topic.advance`, one step at a time, each one commit in one scope, read again before the
|
|
19
|
+
* next: so a crash between any two leaves a topic its next run goes on from.
|
|
20
|
+
*
|
|
21
|
+
* - **Before the decision** (`reserving`, `checking`): it adds the members' entries and reserves
|
|
22
|
+
* each target, in one order for every topic, by repo and then target, so no two topics each
|
|
23
|
+
* hold what the other waits for. A target is taken once its queue has drained, and only then does
|
|
24
|
+
* its member open a candidate. With every target held, it follows each member's candidate and
|
|
25
|
+
* says `topic.opened` once every member has one. With every candidate passed and still on its
|
|
26
|
+
* target's tip, and the report, when required, a pass of that exact set, it saves the publish
|
|
27
|
+
* decision.
|
|
28
|
+
* - **After it** (`publishing`): it wakes each member's queue, which publishes the member under
|
|
29
|
+
* the topic's reservation, and releases it in that commit, till every member merged.
|
|
30
|
+
* - **Once it ends** (`failed`, `removed`): it lets go of every target and removes each entry
|
|
31
|
+
* still open. A reservation of an ended topic is free before then, to every writer. A topic never
|
|
32
|
+
* opens again: new heads take a new key (Q624).
|
|
33
|
+
*/
|
|
34
|
+
/** How often a waiting topic looks again, in ms, beside the wake its members' queues save. */
|
|
35
|
+
const pollEvery = 6e4;
|
|
36
|
+
/** How many tries in a row may fail before a topic not yet decided fails `work-failed`. */
|
|
37
|
+
const tries = 10;
|
|
38
|
+
/**
|
|
39
|
+
* Every failed try runs again, 1 second doubling to 5 minutes, so the job is never failed: a topic
|
|
40
|
+
* still open fails once it's out of tries and lets go; one decided only rolls forward.
|
|
41
|
+
*/
|
|
42
|
+
const retry = (failure) => Math.min(1e3 * 2 ** (failure.attempt - 1), 3e5);
|
|
43
|
+
/** Who a topic's members are added as: the actor and subject of its add. */
|
|
44
|
+
const callerOf = (row) => {
|
|
45
|
+
const caller = { actor: { id: row.actor } };
|
|
46
|
+
if (row.subject !== void 0) caller.subject = { id: row.subject };
|
|
47
|
+
return caller;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* The one order every topic reserves in, by each target's key: its repo's internal ID, which no
|
|
51
|
+
* rename moves, then its name. So no two topics each hold a target the other waits for.
|
|
52
|
+
*/
|
|
53
|
+
const inOrder = (members) => [...members].sort((a, b) => {
|
|
54
|
+
const [left, right] = a.internalId === b.internalId ? [a.target, b.target] : [a.internalId, b.internalId];
|
|
55
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Fails the topic at `read` with `failure`, for good: `topic.failed`, and the job that lets go of
|
|
59
|
+
* what it held. Answers whether it committed.
|
|
60
|
+
*/
|
|
61
|
+
const block = Effect.fnUntraced(function* (host, read, failure, row = read.row, more = []) {
|
|
62
|
+
const { waitingOn: _waited, ...rest } = row;
|
|
63
|
+
const next = {
|
|
64
|
+
...rest,
|
|
65
|
+
state: "failed",
|
|
66
|
+
failure
|
|
67
|
+
};
|
|
68
|
+
const event = {
|
|
69
|
+
type: "topic.failed",
|
|
70
|
+
topic: read.id,
|
|
71
|
+
key: row.key,
|
|
72
|
+
failure: failureOf(row, failure)
|
|
73
|
+
};
|
|
74
|
+
return (yield* commitTopic(host, read, next, [event, ...more], [topicAdvanceRow()])) !== void 0;
|
|
75
|
+
});
|
|
76
|
+
/** A host function's throw, as the failure it blocks a topic with. */
|
|
77
|
+
const hostError = (failure) => {
|
|
78
|
+
const error = failure.context?.id;
|
|
79
|
+
return Predicate.isString(error) ? {
|
|
80
|
+
reason: "host-error",
|
|
81
|
+
error
|
|
82
|
+
} : { reason: "host-error" };
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Whether the host requires the topic report for the topic at `read`. A throw is a bug, not a
|
|
86
|
+
* blip, so it fails the topic `host-error` at once: `undefined` then.
|
|
87
|
+
*/
|
|
88
|
+
const requiredOf = Effect.fnUntraced(function* (host, read) {
|
|
89
|
+
const { required } = host;
|
|
90
|
+
if (required === void 0) return false;
|
|
91
|
+
const question = {
|
|
92
|
+
topic: read.id,
|
|
93
|
+
entries: entriesOf(read.row)
|
|
94
|
+
};
|
|
95
|
+
const { reports } = host.queue.core.checks;
|
|
96
|
+
const asked = yield* Effect.result(hostCall(reports, "topics.required", {}, () => required(question)));
|
|
97
|
+
if (Result.isSuccess(asked)) return asked.success;
|
|
98
|
+
yield* block(host, read, hostError(asked.failure));
|
|
99
|
+
});
|
|
100
|
+
/** The member a failure is of: the first whose entry isn't open. */
|
|
101
|
+
const endedMember = (row, reads) => {
|
|
102
|
+
for (const [index, read] of reads.entries()) {
|
|
103
|
+
const member = row.members[index];
|
|
104
|
+
const { entry } = read;
|
|
105
|
+
if (member?.entry === void 0 || entry === void 0) continue;
|
|
106
|
+
if (entry.state === "waiting" || entry.state === "checking" || entry.state === "held") continue;
|
|
107
|
+
const { candidate } = entry;
|
|
108
|
+
const failure = {
|
|
109
|
+
reason: "entry-failed",
|
|
110
|
+
repo: member.repo,
|
|
111
|
+
entry: member.entry
|
|
112
|
+
};
|
|
113
|
+
return candidate === void 0 ? failure : {
|
|
114
|
+
...failure,
|
|
115
|
+
candidate
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
/** The members whose entries an add hasn't recorded yet: added now, as its actor, then recorded. */
|
|
120
|
+
const addMissing = Effect.fnUntraced(function* (host, read) {
|
|
121
|
+
const { row } = read;
|
|
122
|
+
const own = { topic: read.id };
|
|
123
|
+
const members = [];
|
|
124
|
+
let refused;
|
|
125
|
+
for (const member of row.members) {
|
|
126
|
+
const entry = member.entry ?? (refused ? void 0 : yield* addMember(host, callerOf(row), member, own));
|
|
127
|
+
if (entry === void 0) refused ??= member;
|
|
128
|
+
members.push(entry === void 0 ? member : {
|
|
129
|
+
...member,
|
|
130
|
+
entry
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
if (refused !== void 0) {
|
|
134
|
+
const failure = {
|
|
135
|
+
reason: "refused",
|
|
136
|
+
repo: refused.repo
|
|
137
|
+
};
|
|
138
|
+
yield* block(host, read, failure, {
|
|
139
|
+
...row,
|
|
140
|
+
members
|
|
141
|
+
});
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const next = {
|
|
145
|
+
...row,
|
|
146
|
+
members
|
|
147
|
+
};
|
|
148
|
+
const event = {
|
|
149
|
+
type: "topic.added",
|
|
150
|
+
topic: read.id,
|
|
151
|
+
key: row.key,
|
|
152
|
+
entries: entriesOf(next)
|
|
153
|
+
};
|
|
154
|
+
const by = row.subject === void 0 ? {} : { subject: { id: row.subject } };
|
|
155
|
+
return yield* commitTopic(host, read, next, [{
|
|
156
|
+
...event,
|
|
157
|
+
actor: { id: row.actor },
|
|
158
|
+
...by
|
|
159
|
+
}]);
|
|
160
|
+
});
|
|
161
|
+
/** Whether `a` and `b` are the same candidates, each passed alike. */
|
|
162
|
+
const sameCandidates = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
163
|
+
/** Whether `a` and `b` name the same wait. */
|
|
164
|
+
const sameWait = (a, b) => a.repo === b?.repo && a.target === b.target && a.topic === b.topic && a.hold === b.hold;
|
|
165
|
+
/** A step before the publish decision. */
|
|
166
|
+
const beforeDecision = Effect.fnUntraced(function* (host, read) {
|
|
167
|
+
const { row } = read;
|
|
168
|
+
if (row.members.some((member) => member.entry === void 0)) {
|
|
169
|
+
yield* addMissing(host, read);
|
|
170
|
+
return "again";
|
|
171
|
+
}
|
|
172
|
+
const repos = yield* Effect.forEach(row.members, (member) => memberRead(host, member));
|
|
173
|
+
const gone = row.members.find((_, index) => repos[index] === void 0);
|
|
174
|
+
if (gone !== void 0) {
|
|
175
|
+
yield* block(host, read, {
|
|
176
|
+
reason: "refused",
|
|
177
|
+
repo: gone.repo
|
|
178
|
+
});
|
|
179
|
+
return "again";
|
|
180
|
+
}
|
|
181
|
+
const reads = repos.filter(Predicate.isNotUndefined);
|
|
182
|
+
const { timeout } = host;
|
|
183
|
+
const now = yield* host.queue.core.now;
|
|
184
|
+
if (row.heldSince !== void 0 && now - row.heldSince > millis(timeout)) {
|
|
185
|
+
const held = row.members.filter((_, index) => repos[index]?.state.row.reserved?.topic === read.id);
|
|
186
|
+
const targets = inOrder(held).map(({ repo, target }) => `${repo} ${target}`).join(", ");
|
|
187
|
+
yield* block(host, read, {
|
|
188
|
+
reason: "timeout",
|
|
189
|
+
summary: `Held ${targets} past its ${durationWords(timeout)} timeout`
|
|
190
|
+
});
|
|
191
|
+
return "again";
|
|
192
|
+
}
|
|
193
|
+
const ended = endedMember(row, reads);
|
|
194
|
+
if (ended !== void 0) {
|
|
195
|
+
yield* block(host, read, ended);
|
|
196
|
+
return "again";
|
|
197
|
+
}
|
|
198
|
+
if (row.state === "reserving") {
|
|
199
|
+
for (const member of inOrder(row.members)) {
|
|
200
|
+
const reserved = yield* reserveMember(host, member, { topic: read.id });
|
|
201
|
+
if (reserved.held && row.heldSince === void 0) {
|
|
202
|
+
yield* commitTopic(host, read, {
|
|
203
|
+
...row,
|
|
204
|
+
heldSince: reserved.since
|
|
205
|
+
});
|
|
206
|
+
return "again";
|
|
207
|
+
}
|
|
208
|
+
if (reserved.held) continue;
|
|
209
|
+
if (!sameWait(reserved.waiting, row.waitingOn)) yield* commitTopic(host, read, {
|
|
210
|
+
...row,
|
|
211
|
+
waitingOn: reserved.waiting
|
|
212
|
+
});
|
|
213
|
+
return "waits";
|
|
214
|
+
}
|
|
215
|
+
const { waitingOn: _waited, ...rest } = row;
|
|
216
|
+
yield* commitTopic(host, read, {
|
|
217
|
+
...rest,
|
|
218
|
+
state: "checking"
|
|
219
|
+
});
|
|
220
|
+
return "again";
|
|
221
|
+
}
|
|
222
|
+
const found = row.members.map((member, index) => {
|
|
223
|
+
const at = reads[index];
|
|
224
|
+
return at === void 0 ? void 0 : candidateAt(member, at);
|
|
225
|
+
});
|
|
226
|
+
const candidates = found.every((at) => at !== void 0) ? found : [];
|
|
227
|
+
if (!sameCandidates(candidates, row.candidates)) {
|
|
228
|
+
const next = {
|
|
229
|
+
...row,
|
|
230
|
+
candidates
|
|
231
|
+
};
|
|
232
|
+
const set = currentSet(next);
|
|
233
|
+
const events = [];
|
|
234
|
+
const jobs = [];
|
|
235
|
+
if (set !== void 0 && row.opened !== set) {
|
|
236
|
+
const required = yield* requiredOf(host, read);
|
|
237
|
+
if (required === void 0) return "again";
|
|
238
|
+
next.opened = set;
|
|
239
|
+
const opened = {
|
|
240
|
+
type: "topic.opened",
|
|
241
|
+
topic: read.id,
|
|
242
|
+
key: row.key,
|
|
243
|
+
required
|
|
244
|
+
};
|
|
245
|
+
events.push({
|
|
246
|
+
...opened,
|
|
247
|
+
candidates: topicOf(read.id, next).candidates
|
|
248
|
+
});
|
|
249
|
+
const ids = candidates.map(({ candidate }) => candidate);
|
|
250
|
+
const due = (yield* host.queue.core.now) + millis(host.reportTimeout);
|
|
251
|
+
if (required) jobs.push(reportTimeoutRow(set, ids, due));
|
|
252
|
+
}
|
|
253
|
+
yield* commitTopic(host, read, next, events, jobs);
|
|
254
|
+
return "again";
|
|
255
|
+
}
|
|
256
|
+
const set = currentSet(row);
|
|
257
|
+
if (set === void 0 || !candidates.every((at) => at.passed === true)) return "waits";
|
|
258
|
+
if (!(yield* Effect.forEach(row.members, (member) => memberRead(host, member))).every((at, index) => at !== void 0 && at.state.row.reserved?.topic === read.id && at.candidate !== void 0 && at.candidate.base === at.state.tip && at.entry?.candidate === candidates[index]?.candidate)) return "waits";
|
|
259
|
+
const required = yield* requiredOf(host, read);
|
|
260
|
+
if (required === void 0) return "again";
|
|
261
|
+
if (required) {
|
|
262
|
+
const { report } = row;
|
|
263
|
+
if (report?.set !== set || report.verdict !== "pass") return "waits";
|
|
264
|
+
}
|
|
265
|
+
if (host.prepare !== void 0 && row.prepared !== set) {
|
|
266
|
+
if (row.asked === set) return "waits";
|
|
267
|
+
const ids = candidates.map(({ candidate }) => candidate);
|
|
268
|
+
yield* commitTopic(host, read, {
|
|
269
|
+
...row,
|
|
270
|
+
asked: set
|
|
271
|
+
}, [], [prepareRow(set, ids)]);
|
|
272
|
+
return "again";
|
|
273
|
+
}
|
|
274
|
+
yield* commitTopic(host, read, {
|
|
275
|
+
...row,
|
|
276
|
+
state: "publishing",
|
|
277
|
+
decided: set
|
|
278
|
+
});
|
|
279
|
+
return "again";
|
|
280
|
+
});
|
|
281
|
+
/** A step after the publish decision: every member's queue woken, till each merged. */
|
|
282
|
+
const afterDecision = Effect.fnUntraced(function* (host, read) {
|
|
283
|
+
const { row } = read;
|
|
284
|
+
const { store } = host.queue.core;
|
|
285
|
+
const reads = yield* Effect.forEach(row.members, (member) => memberRead(host, member));
|
|
286
|
+
const merged = [];
|
|
287
|
+
for (const [index, member] of row.members.entries()) {
|
|
288
|
+
const at = reads[index];
|
|
289
|
+
const candidate = row.candidates[index];
|
|
290
|
+
if ((at === void 0 || at.entry?.state === "merged") && member.entry !== void 0 && candidate !== void 0) {
|
|
291
|
+
const { repo, target } = member;
|
|
292
|
+
const { candidate: id, commit } = candidate;
|
|
293
|
+
merged.push({
|
|
294
|
+
repo,
|
|
295
|
+
target,
|
|
296
|
+
entry: member.entry,
|
|
297
|
+
candidate: id,
|
|
298
|
+
commit,
|
|
299
|
+
judged: "tree"
|
|
300
|
+
});
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
const jobs = [advanceRow(member.target)];
|
|
304
|
+
yield* storeCall(() => store.add(repoScope(member.internalId), { jobs }));
|
|
305
|
+
}
|
|
306
|
+
if (merged.length < row.members.length) return "waits";
|
|
307
|
+
const event = {
|
|
308
|
+
type: "topic.merged",
|
|
309
|
+
topic: read.id,
|
|
310
|
+
key: row.key,
|
|
311
|
+
entries: merged,
|
|
312
|
+
actor: { id: row.actor }
|
|
313
|
+
};
|
|
314
|
+
const by = row.subject === void 0 ? {} : { subject: { id: row.subject } };
|
|
315
|
+
yield* commitTopic(host, read, {
|
|
316
|
+
...row,
|
|
317
|
+
state: "merged"
|
|
318
|
+
}, [{
|
|
319
|
+
...event,
|
|
320
|
+
...by
|
|
321
|
+
}]);
|
|
322
|
+
return "again";
|
|
323
|
+
});
|
|
324
|
+
/** One step of `git.topic.advance` for `id`. */
|
|
325
|
+
const advanceStep = Effect.fnUntraced(function* (host, id) {
|
|
326
|
+
const read = yield* readTopic(host, id);
|
|
327
|
+
const { row } = read;
|
|
328
|
+
if (row === void 0) return "done";
|
|
329
|
+
yield* projectTopic(host.queue.core.store, id, row);
|
|
330
|
+
const own = {
|
|
331
|
+
...read,
|
|
332
|
+
row
|
|
333
|
+
};
|
|
334
|
+
if (row.state === "failed" || row.state === "removed") {
|
|
335
|
+
const release = (member) => releaseMember(host, member, { topic: id });
|
|
336
|
+
yield* Effect.forEach(row.members, release, { discard: true });
|
|
337
|
+
}
|
|
338
|
+
if (row.state !== "checking" && row.state !== "reserving" && row.state !== "publishing") return "done";
|
|
339
|
+
if (row.state === "publishing") return yield* afterDecision(host, own);
|
|
340
|
+
return yield* beforeDecision(host, own);
|
|
341
|
+
});
|
|
342
|
+
/** Whether a claim of the topic's job, its `attempt`, comes after `tries` failed in a row. */
|
|
343
|
+
const outOfTries = (attempt) => attempt > tries;
|
|
344
|
+
/** Whether a claim says the tries before it failed, with `topic.work.failed`: each tenth in a row. */
|
|
345
|
+
const saysFailed = (attempt) => outOfTries(attempt) && (attempt - 1) % tries === 0;
|
|
346
|
+
/** `topic.work.failed` for `job`, at its claim: the tries before it failed in a row. */
|
|
347
|
+
const workFailedOf = (id, row, job) => ({
|
|
348
|
+
type: "topic.work.failed",
|
|
349
|
+
topic: id,
|
|
350
|
+
key: row.key,
|
|
351
|
+
name: job.name,
|
|
352
|
+
attempts: job.attempt - 1
|
|
353
|
+
});
|
|
354
|
+
/** How many steps one try of `git.topic.advance` takes before it asks for more. */
|
|
355
|
+
const stepsPerTry = 20;
|
|
356
|
+
const advance = (host, job) => Effect.gen(function* () {
|
|
357
|
+
const id = topicIdOf(job);
|
|
358
|
+
if (outOfTries(job.attempt)) {
|
|
359
|
+
const read = yield* readTopic(host, id);
|
|
360
|
+
const { row } = read;
|
|
361
|
+
if (row?.state === "checking" || row?.state === "reserving") {
|
|
362
|
+
const failed = [workFailedOf(id, row, job)];
|
|
363
|
+
yield* block(host, {
|
|
364
|
+
...read,
|
|
365
|
+
row
|
|
366
|
+
}, { reason: "work-failed" }, row, failed);
|
|
367
|
+
} else if (row?.state === "publishing" && saysFailed(job.attempt)) yield* commitTopic(host, read, row, [workFailedOf(id, row, job)]);
|
|
368
|
+
}
|
|
369
|
+
for (let step = 0; step < stepsPerTry; step += 1) {
|
|
370
|
+
const did = yield* advanceStep(host, id);
|
|
371
|
+
if (did === "done") return void 0;
|
|
372
|
+
if (did === "waits") return {
|
|
373
|
+
kind: "more",
|
|
374
|
+
at: (yield* host.queue.core.now) + pollEvery
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
return { kind: "more" };
|
|
378
|
+
});
|
|
379
|
+
/** The topic a job of its scope runs for. */
|
|
380
|
+
const topicIdOf = (job) => job.scope.slice(10);
|
|
381
|
+
/** The topic at `id` while it's before its decision with the set `candidates` still current. */
|
|
382
|
+
const forSet = Effect.fnUntraced(function* (host, id, candidates) {
|
|
383
|
+
const read = yield* readTopic(host, id);
|
|
384
|
+
const { row } = read;
|
|
385
|
+
if (row === void 0) return void 0;
|
|
386
|
+
const set = setKeyOf(candidates.map((candidate) => ({ candidate })));
|
|
387
|
+
return (row.state === "checking" || row.state === "reserving") && currentSet(row) === set ? {
|
|
388
|
+
...read,
|
|
389
|
+
row,
|
|
390
|
+
set
|
|
391
|
+
} : void 0;
|
|
392
|
+
});
|
|
393
|
+
/** How many times a step that lost its commit to another write reads again and retries it. */
|
|
394
|
+
const commitTries = 8;
|
|
395
|
+
/**
|
|
396
|
+
* Saves `prepare`'s answer to the topic, while it's before its decision with the set still
|
|
397
|
+
* current: an accept as `prepared`, waking advance; a failure fails it. Whether it's saved, or no
|
|
398
|
+
* longer needed; `false` when other writes moved the topic each time.
|
|
399
|
+
*/
|
|
400
|
+
const saveAnswer = Effect.fnUntraced(function* (host, id, candidates, answer) {
|
|
401
|
+
for (let tried = 0; tried < commitTries; tried += 1) {
|
|
402
|
+
const now = yield* forSet(host, id, candidates);
|
|
403
|
+
if (now === void 0 || now.row.prepared === now.set) return true;
|
|
404
|
+
if (answer.kind === "failed") {
|
|
405
|
+
if (yield* block(host, now, answer.failure)) return true;
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
const next = {
|
|
409
|
+
...now.row,
|
|
410
|
+
prepared: now.set
|
|
411
|
+
};
|
|
412
|
+
if ((yield* commitTopic(host, now, next, [], [topicAdvanceRow()])) !== void 0) return true;
|
|
413
|
+
}
|
|
414
|
+
return false;
|
|
415
|
+
});
|
|
416
|
+
/**
|
|
417
|
+
* `git.topic.prepare`: the host's `prepare` for the exact set, while every reservation holds. An
|
|
418
|
+
* accept saves it, so the topic decides; a reject fails it `prepare-rejected`, and a throw or a
|
|
419
|
+
* timeout `host-error` at once, as the queue's `merge` throw fails its entry (Q648). An answer the
|
|
420
|
+
* topic couldn't take yet stays with the job, which saves it later without asking again.
|
|
421
|
+
*/
|
|
422
|
+
const prepareStep = (host, job, signal) => Effect.gen(function* () {
|
|
423
|
+
const { prepare } = host;
|
|
424
|
+
const id = topicIdOf(job);
|
|
425
|
+
const { candidates } = job.data;
|
|
426
|
+
const later = (data) => Effect.map(host.queue.core.now, (now) => ({
|
|
427
|
+
kind: "more",
|
|
428
|
+
at: now + pollEvery,
|
|
429
|
+
data
|
|
430
|
+
}));
|
|
431
|
+
let { answer } = job.data;
|
|
432
|
+
if (answer === void 0) {
|
|
433
|
+
const found = yield* Effect.result(forSet(host, id, candidates));
|
|
434
|
+
if (Result.isFailure(found)) return yield* later({ candidates });
|
|
435
|
+
const read = found.success;
|
|
436
|
+
if (prepare === void 0 || read === void 0 || read.row.prepared === read.set) return;
|
|
437
|
+
const { row, set } = read;
|
|
438
|
+
const input = {
|
|
439
|
+
topic: id,
|
|
440
|
+
entries: entriesOf(row),
|
|
441
|
+
candidates: topicOf(id, row).candidates,
|
|
442
|
+
key: set,
|
|
443
|
+
attempt: job.attempt
|
|
444
|
+
};
|
|
445
|
+
const { reports } = host.queue.core.checks;
|
|
446
|
+
const call = (own) => prepare.handler({
|
|
447
|
+
...input,
|
|
448
|
+
signal: AbortSignal.any([own, signal])
|
|
449
|
+
});
|
|
450
|
+
const answered = yield* hostCall(reports, "topics.prepare", {}, call, { timeout: prepare.timeout }).pipe(Effect.result);
|
|
451
|
+
answer = Result.isFailure(answered) ? {
|
|
452
|
+
kind: "failed",
|
|
453
|
+
failure: hostError(answered.failure)
|
|
454
|
+
} : answered.success.kind === "reject" ? {
|
|
455
|
+
kind: "failed",
|
|
456
|
+
failure: rejected(answered.success)
|
|
457
|
+
} : { kind: "accept" };
|
|
458
|
+
}
|
|
459
|
+
const saved = yield* Effect.result(saveAnswer(host, id, candidates, answer));
|
|
460
|
+
if (Result.isFailure(saved) || !saved.success) return yield* later({
|
|
461
|
+
candidates,
|
|
462
|
+
answer
|
|
463
|
+
});
|
|
464
|
+
});
|
|
465
|
+
/** A `prepare` reject, as the failure it fails its topic with. */
|
|
466
|
+
const rejected = (answer) => ({
|
|
467
|
+
reason: "prepare-rejected",
|
|
468
|
+
summary: answer.message
|
|
469
|
+
});
|
|
470
|
+
/**
|
|
471
|
+
* `git.topic.report-timeout`: fails the topic `report-timeout` when its exact set, still current
|
|
472
|
+
* before its decision, has no report by `report.timeout` (Q647).
|
|
473
|
+
*/
|
|
474
|
+
const reportTimeoutStep = (host, job) => Effect.gen(function* () {
|
|
475
|
+
const id = topicIdOf(job);
|
|
476
|
+
for (let tried = 0; tried < commitTries; tried += 1) {
|
|
477
|
+
const read = yield* forSet(host, id, job.data.candidates);
|
|
478
|
+
if (read === void 0 || read.row.report?.set === read.set) return;
|
|
479
|
+
const words = durationWords(host.reportTimeout);
|
|
480
|
+
const summary = `No report on ${read.set} came within its ${words} report.timeout`;
|
|
481
|
+
if (yield* block(host, read, {
|
|
482
|
+
reason: "report-timeout",
|
|
483
|
+
summary
|
|
484
|
+
})) return;
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
/**
|
|
488
|
+
* `host` for one try of a topics job, or its `onFailure`: its store, the queue's cores' both, is
|
|
489
|
+
* the try's own, fenced by its claim, so a try that lost its claim commits nothing (#780).
|
|
490
|
+
*/
|
|
491
|
+
const fencedHost = (host, context) => {
|
|
492
|
+
const { queue } = host;
|
|
493
|
+
const { store } = context;
|
|
494
|
+
return {
|
|
495
|
+
...host,
|
|
496
|
+
queue: {
|
|
497
|
+
...queue,
|
|
498
|
+
core: {
|
|
499
|
+
...queue.core,
|
|
500
|
+
store
|
|
501
|
+
},
|
|
502
|
+
hostCore: {
|
|
503
|
+
...queue.hostCore,
|
|
504
|
+
store
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
};
|
|
509
|
+
/**
|
|
510
|
+
* A `prepare` try that threw or ran past its time outside the host's call, which `prepareStep`
|
|
511
|
+
* turns into an answer, fails the topic `work-failed` while it's still before its decision, so it
|
|
512
|
+
* lets go of what it holds. It never calls the host: only its own read and commit run again, over
|
|
513
|
+
* the try's fenced store, until `onFailure`'s own minute aborts its signal.
|
|
514
|
+
*/
|
|
515
|
+
const prepareFailed = (host) => async (job, _failure, context) => {
|
|
516
|
+
const own = fencedHost(host, context);
|
|
517
|
+
const id = topicIdOf(job);
|
|
518
|
+
const once = Effect.gen(function* () {
|
|
519
|
+
const read = yield* readTopic(own, id);
|
|
520
|
+
const { row } = read;
|
|
521
|
+
return !(row?.state === "checking" || row?.state === "reserving") || (yield* block(own, {
|
|
522
|
+
...read,
|
|
523
|
+
row
|
|
524
|
+
}, { reason: "work-failed" }));
|
|
525
|
+
});
|
|
526
|
+
for (let tried = 0; tried < commitTries; tried += 1) {
|
|
527
|
+
const run = once.pipe(Effect.orElseSucceed(() => false));
|
|
528
|
+
if (await runIn(run, uncounted("a topic job's try: no request's, so only the platform's cap bounds it"), context.signal)) return;
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
/** Topics' jobs over `host`, which `createGitServer` registers beside its own. */
|
|
532
|
+
const topicJobs = (host) => [
|
|
533
|
+
defineJob({
|
|
534
|
+
name: topicAdvanceName,
|
|
535
|
+
schema: Schema.toStandardSchemaV1(TopicAdvanceData),
|
|
536
|
+
retry,
|
|
537
|
+
handler: (job, context) => runJobTry(advance(fencedHost(host, context), job))
|
|
538
|
+
}),
|
|
539
|
+
defineJob({
|
|
540
|
+
name: prepareName,
|
|
541
|
+
schema: Schema.toStandardSchemaV1(PrepareData),
|
|
542
|
+
retry: (failure) => failure.error instanceof LostTry ? 0 : false,
|
|
543
|
+
timeout: (host.prepare?.timeout ?? 0) + saveMargin,
|
|
544
|
+
handler: (job, context) => runJobTry(prepareStep(fencedHost(host, context), job, context.signal)),
|
|
545
|
+
onFailure: prepareFailed(host)
|
|
546
|
+
}),
|
|
547
|
+
defineJob({
|
|
548
|
+
name: reportTimeoutName,
|
|
549
|
+
schema: Schema.toStandardSchemaV1(CandidateSetData),
|
|
550
|
+
retry,
|
|
551
|
+
handler: (job, context) => runJobTry(reportTimeoutStep(fencedHost(host, context), job))
|
|
552
|
+
})
|
|
553
|
+
];
|
|
554
|
+
export { addMissing, block, inOrder, outOfTries, pollEvery, saysFailed, topicJobs };
|