@ref0/git 0.6.0 → 0.8.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/access/namespace.d.mts +2 -0
- package/dist/access/private-refs.d.mts +6 -29
- package/dist/access/private-refs.mjs +26 -13
- package/dist/access/public.d.mts +6 -0
- package/dist/access/public.mjs +9 -0
- package/dist/auth/access-jwt.d.mts +10 -6
- package/dist/auth/access-jwt.mjs +59 -40
- package/dist/auth/auth-namespace.d.mts +6 -0
- package/dist/auth/auth-namespace.mjs +12 -0
- package/dist/auth/auth.d.mts +3 -6
- package/dist/auth/auth.mjs +2 -9
- package/dist/auth/authorize.mjs +35 -29
- package/dist/auth/bridge.mjs +8 -8
- package/dist/auth/fences.d.mts +1 -2
- package/dist/auth/fences.mjs +1 -1
- package/dist/auth/grants.d.mts +0 -1
- package/dist/auth/grants.mjs +2 -2
- package/dist/auth/host-function.d.mts +1 -7
- package/dist/auth/host-function.mjs +51 -42
- package/dist/auth/identify.d.mts +0 -1
- package/dist/auth/identify.mjs +3 -2
- package/dist/auth/namespaces.d.mts +2 -2
- package/dist/auth/policy.d.mts +7 -4
- package/dist/auth/policy.mjs +13 -10
- package/dist/auth/token-rows.mjs +3 -6
- package/dist/auth/tokens-layer.d.mts +40 -0
- package/dist/auth/tokens-layer.mjs +29 -0
- package/dist/auth/tokens-namespace.d.mts +2 -0
- package/dist/auth/tokens-public.d.mts +6 -0
- package/dist/auth/tokens-public.mjs +31 -0
- package/dist/auth/tokens.d.mts +19 -7
- package/dist/auth/tokens.mjs +12 -6
- package/dist/auth.d.mts +2 -2
- package/dist/auth.mjs +2 -2
- package/dist/client/client.d.mts +22 -15
- package/dist/client/client.mjs +31 -27
- package/dist/client/git-http.mjs +23 -6
- package/dist/client/local.mjs +5 -4
- package/dist/client/namespace.d.mts +2 -0
- package/dist/client/push-upload.d.mts +1 -0
- package/dist/client/push-upload.mjs +169 -2
- package/dist/client/remote-helper.mjs +5 -12
- package/dist/client/remote.mjs +63 -22
- package/dist/client/run-remote-helper.d.mts +1 -1
- package/dist/client/run-remote-helper.mjs +6 -6
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +26 -19
- package/dist/contracts/access.d.mts +18 -10
- package/dist/contracts/access.mjs +17 -0
- package/dist/contracts/actors.d.mts +73 -28
- package/dist/contracts/actors.mjs +45 -2
- package/dist/contracts/authorize.d.mts +26 -17
- package/dist/contracts/blobs.d.mts +1 -1
- package/dist/contracts/blobs.mjs +1 -1
- package/dist/contracts/callers.mjs +40 -0
- package/dist/contracts/calls-spent.d.mts +6 -4
- package/dist/contracts/calls-spent.mjs +10 -8
- package/dist/contracts/client.d.mts +16 -9
- package/dist/contracts/commits.d.mts +2 -2
- package/dist/contracts/commits.mjs +1 -1
- package/dist/contracts/engine.d.mts +1 -1
- package/dist/contracts/events.d.mts +45 -32
- package/dist/contracts/events.mjs +21 -10
- package/dist/contracts/files.d.mts +44 -44
- package/dist/contracts/files.mjs +1 -1
- package/dist/contracts/forks.d.mts +34 -58
- package/dist/contracts/forks.mjs +1 -1
- package/dist/contracts/git-events.d.mts +50 -0
- package/dist/contracts/git-events.mjs +23 -0
- package/dist/contracts/git-hooks.d.mts +254 -0
- package/dist/contracts/git-hooks.mjs +12 -0
- package/dist/contracts/git.d.mts +93 -42
- package/dist/contracts/git.mjs +6 -5
- package/dist/contracts/grants.d.mts +46 -27
- package/dist/contracts/ids.d.mts +16 -0
- package/dist/contracts/ids.mjs +19 -4
- package/dist/contracts/lfs.d.mts +19 -4
- package/dist/contracts/merges.d.mts +7 -7
- package/dist/contracts/namespaces.d.mts +2 -2
- package/dist/contracts/objects.d.mts +21 -5
- package/dist/contracts/opaque.mjs +27 -0
- package/dist/contracts/operations.d.mts +301 -101
- package/dist/contracts/operations.mjs +209 -0
- package/dist/contracts/promises.d.mts +2 -0
- package/dist/contracts/push-uploads.d.mts +4 -1
- package/dist/contracts/push-uploads.mjs +9 -4
- package/dist/contracts/queue.d.mts +220 -49
- package/dist/contracts/queue.mjs +68 -6
- package/dist/contracts/refs.d.mts +30 -8
- package/dist/contracts/refs.mjs +1 -1
- package/dist/contracts/remote.d.mts +53 -23
- package/dist/contracts/remote.mjs +22 -0
- package/dist/contracts/repo-records.d.mts +2 -2
- package/dist/contracts/repos.d.mts +100 -82
- package/dist/contracts/repos.mjs +47 -8
- package/dist/contracts/result.d.mts +73 -41
- package/dist/contracts/result.mjs +74 -17
- package/dist/contracts/rules.d.mts +734 -68
- package/dist/contracts/rules.mjs +84 -1
- package/dist/contracts/server.d.mts +20 -206
- package/dist/contracts/services.d.mts +1 -10
- package/dist/contracts/services.mjs +1 -5
- package/dist/contracts/signin.d.mts +140 -43
- package/dist/contracts/signin.mjs +36 -3
- package/dist/contracts/store.d.mts +1 -1
- package/dist/contracts/sync.d.mts +109 -90
- package/dist/contracts/sync.mjs +34 -7
- package/dist/contracts/tags.d.mts +1 -1
- package/dist/contracts/tags.mjs +1 -1
- package/dist/contracts/tokens.d.mts +247 -60
- package/dist/contracts/tokens.mjs +93 -21
- package/dist/contracts/topics.d.mts +59 -20
- package/dist/contracts/topics.mjs +14 -5
- package/dist/contracts/trees.d.mts +2 -2
- package/dist/contracts/trees.mjs +1 -1
- package/dist/contracts/work.d.mts +2 -2
- package/dist/contracts/work.mjs +2 -2
- package/dist/core/access.d.mts +10 -12
- package/dist/core/access.mjs +45 -11
- package/dist/core/clock.mjs +1 -1
- package/dist/core/events/deliver.d.mts +3 -2
- package/dist/core/events/deliver.mjs +188 -92
- package/dist/core/forks.mjs +78 -34
- package/dist/core/hooks/groups.d.mts +26 -0
- package/dist/core/hooks/groups.mjs +73 -0
- package/dist/core/hooks/namespace.d.mts +2 -0
- package/dist/core/hooks/order.d.mts +2 -2
- package/dist/core/hooks/order.mjs +6 -6
- package/dist/core/hooks/public.d.mts +7 -0
- package/dist/core/hooks/public.mjs +5 -0
- package/dist/core/imports.mjs +94 -10
- package/dist/core/index-job.mjs +11 -8
- package/dist/core/loose-tally.mjs +46 -0
- package/dist/core/merge-parts.d.mts +1 -1
- package/dist/core/merge-parts.mjs +1 -1
- package/dist/core/mirror-rows.mjs +18 -0
- package/dist/core/names.mjs +1 -1
- package/dist/core/namespaces.d.mts +2 -1
- package/dist/core/objects/commit-writes.mjs +5 -5
- package/dist/core/objects/merges.mjs +1 -1
- package/dist/core/objects/objects-layer.mjs +1 -1
- package/dist/core/objects/reading.mjs +52 -7
- package/dist/core/objects/tree-edits.mjs +13 -28
- package/dist/core/objects/trees.mjs +4 -4
- package/dist/core/objects/writing.mjs +4 -3
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +22 -3
- package/dist/core/parts.mjs +5 -3
- package/dist/core/promise.mjs +23 -17
- package/dist/core/purge.d.mts +2 -2
- package/dist/core/purge.mjs +89 -34
- package/dist/core/push.mjs +67 -79
- package/dist/core/receipts.d.mts +2 -2
- package/dist/core/receipts.mjs +28 -4
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +16 -8
- package/dist/core/refs.mjs +41 -10
- package/dist/core/registered-records.mjs +30 -0
- package/dist/core/{claim-rows.mjs → registered-rows.mjs} +6 -6
- package/dist/core/repack.d.mts +2 -2
- package/dist/core/repack.mjs +30 -23
- package/dist/core/repo-info.mjs +62 -26
- package/dist/core/repos.mjs +18 -11
- package/dist/core/rules/changes.mjs +2 -2
- package/dist/core/rules/check.mjs +10 -10
- package/dist/core/rules/commit-changes.mjs +1 -1
- package/dist/core/rules/context.d.mts +7 -6
- package/dist/core/rules/context.mjs +18 -16
- package/dist/core/rules/fetch.mjs +78 -31
- package/dist/core/saved-caller-views.d.mts +72 -0
- package/dist/core/saved-caller-views.mjs +123 -0
- package/dist/core/saved-callers-public.d.mts +5 -0
- package/dist/core/saved-callers-public.mjs +10 -0
- package/dist/core/saved-callers.mjs +95 -0
- package/dist/core/seam.d.mts +12 -1
- package/dist/core/seam.mjs +4 -2
- package/dist/core/tokens.mjs +7 -2
- package/dist/core/view.d.mts +1 -1
- package/dist/core/view.mjs +1 -1
- package/dist/core/work.mjs +6 -5
- package/dist/effect.d.mts +2 -4
- package/dist/effect.mjs +2 -4
- package/dist/engine/commits.mjs +19 -47
- package/dist/engine/content.d.mts +2 -2
- package/dist/engine/content.mjs +1 -1
- package/dist/engine/diff.mjs +2 -2
- package/dist/engine/failures.d.mts +1 -2
- package/dist/engine/failures.mjs +1 -3
- package/dist/engine/merge-base-walk.mjs +57 -142
- package/dist/engine/merge-bases.mjs +5 -5
- package/dist/engine/merge-renames.mjs +1 -1
- package/dist/engine/merge.mjs +16 -14
- package/dist/engine/reads.d.mts +2 -2
- package/dist/engine/reads.mjs +1 -1
- package/dist/engine/xdiff.d.mts +1 -1
- package/dist/engine/xdiff.mjs +2 -2
- package/dist/event-streams/event-streams.d.mts +6 -2
- package/dist/event-streams/event-streams.mjs +6 -2
- package/dist/event-streams/stream.mjs +5 -2
- package/dist/extend.d.mts +2 -3
- package/dist/extend.mjs +2 -2
- package/dist/http/answers.mjs +4 -3
- package/dist/http/core-parts.mjs +3 -4
- package/dist/http/handler.mjs +12 -32
- package/dist/http/parts.d.mts +1 -1
- package/dist/http/push-uploads.mjs +7 -5
- package/dist/http/receive-pack.mjs +3 -3
- package/dist/http/upload-pack.mjs +6 -5
- package/dist/index.d.mts +44 -24
- package/dist/index.mjs +17 -8
- package/dist/lfs/base.d.mts +8 -5
- package/dist/lfs/base.mjs +2 -1
- package/dist/lfs/calls.mjs +3 -2
- package/dist/lfs/layer.d.mts +9 -7
- package/dist/lfs/layer.mjs +37 -22
- package/dist/lfs/locks.mjs +3 -3
- package/dist/lfs/objects.d.mts +3 -2
- package/dist/lfs/objects.mjs +235 -71
- package/dist/lfs/pointers.mjs +70 -19
- package/dist/lfs/purge.mjs +7 -3
- package/dist/lfs/rows.mjs +25 -8
- package/dist/lfs/service.d.mts +6 -3
- package/dist/lfs/service.mjs +8 -2
- package/dist/lfs/upkeep.mjs +53 -31
- package/dist/lfs/upload-most.mjs +41 -0
- package/dist/lfs/uploaded.mjs +59 -0
- package/dist/lfs/wire.mjs +1 -1
- package/dist/protocol/bytes/buffers.d.mts +1 -1
- package/dist/protocol/bytes/buffers.mjs +1 -1
- package/dist/protocol/bytes/deflate.d.mts +1 -1
- package/dist/protocol/bytes/deflate.mjs +1 -1
- package/dist/protocol/bytes/hmac-sha256.mjs +3 -6
- package/dist/protocol/bytes/inflate.d.mts +1 -1
- package/dist/protocol/bytes/inflate.mjs +1 -1
- package/dist/protocol/bytes/sha1.d.mts +1 -1
- package/dist/protocol/bytes/sha1.mjs +2 -2
- package/dist/protocol/bytes/sha256-hasher.mjs +51 -0
- package/dist/protocol/bytes/text.mjs +6 -1
- package/dist/protocol/diff/read.d.mts +1 -1
- package/dist/protocol/diff/read.mjs +1 -1
- package/dist/protocol/diff/tree-diff.d.mts +1 -1
- package/dist/protocol/diff/tree-diff.mjs +11 -11
- package/dist/protocol/objects/fsck.mjs +6 -3
- package/dist/protocol/objects/lfs-pointer.mjs +6 -1
- package/dist/protocol/objects/tag.mjs +1 -1
- package/dist/protocol/objects/tree.mjs +1 -1
- package/dist/protocol/packs/graph.mjs +1 -1
- package/dist/protocol/packs/idx.d.mts +1 -1
- package/dist/protocol/packs/idx.mjs +1 -1
- package/dist/protocol/packs/parts.mjs +1 -1
- package/dist/protocol/packs/reader.d.mts +1 -1
- package/dist/protocol/packs/reader.mjs +2 -2
- package/dist/protocol/packs/write-error.d.mts +1 -1
- package/dist/protocol/packs/write-error.mjs +1 -1
- package/dist/protocol/packs/writer.mjs +4 -4
- package/dist/protocol/wire/advertisement.d.mts +1 -1
- package/dist/protocol/wire/advertisement.mjs +1 -1
- package/dist/protocol/wire/fetch.d.mts +1 -1
- package/dist/protocol/wire/fetch.mjs +1 -1
- package/dist/protocol/wire/lines.d.mts +1 -1
- package/dist/protocol/wire/lines.mjs +2 -2
- package/dist/protocol/wire/push-uploads.mjs +4 -2
- package/dist/protocol/wire/receive-pack.d.mts +1 -1
- package/dist/protocol/wire/receive-pack.mjs +1 -1
- package/dist/protocol/wire/report-status.d.mts +1 -1
- package/dist/protocol/wire/report-status.mjs +1 -1
- package/dist/protocol/wire/v2.d.mts +2 -2
- package/dist/protocol/wire/v2.mjs +2 -2
- package/dist/queue/advance.mjs +190 -68
- package/dist/queue/callers.mjs +56 -69
- package/dist/queue/calls.mjs +10 -11
- package/dist/queue/commit.mjs +28 -22
- package/dist/queue/host.d.mts +10 -11
- package/dist/queue/host.mjs +15 -7
- package/dist/queue/lanes.mjs +9 -18
- package/dist/queue/layer.d.mts +3 -3
- package/dist/queue/layer.mjs +11 -10
- package/dist/queue/limits.mjs +17 -5
- package/dist/queue/rows.mjs +13 -10
- package/dist/queue/schedule.mjs +7 -6
- package/dist/queue/search.mjs +11 -17
- package/dist/queue/state.mjs +7 -2
- package/dist/queue/trim.mjs +10 -5
- package/dist/rest/api.d.mts +1 -1
- package/dist/rest/blobs.d.mts +20 -20
- package/dist/rest/caller.d.mts +22 -20
- package/dist/rest/client-namespace.d.mts +2 -0
- package/dist/rest/client.d.mts +32 -8
- package/dist/rest/client.mjs +314 -388
- package/dist/rest/commits.d.mts +284 -284
- package/dist/rest/errors.d.mts +10 -10
- package/dist/rest/errors.mjs +1 -1
- package/dist/rest/events.d.mts +13 -11
- package/dist/rest/events.mjs +3 -1
- package/dist/rest/files.d.mts +48 -48
- package/dist/rest/forks.d.mts +131 -143
- package/dist/rest/handler.mjs +4 -3
- package/dist/rest/handlers.mjs +15 -8
- package/dist/rest/layer.d.mts +3 -3
- package/dist/rest/layer.mjs +8 -7
- package/dist/rest/listen.d.mts +8 -6
- package/dist/rest/listen.mjs +33 -77
- package/dist/rest/me.d.mts +18 -20
- package/dist/rest/me.mjs +1 -1
- package/dist/rest/merges.d.mts +17 -17
- package/dist/rest/queue.d.mts +140 -140
- package/dist/rest/queue.mjs +1 -1
- package/dist/rest/refs.d.mts +214 -214
- package/dist/rest/refs.mjs +1 -1
- package/dist/rest/repos.d.mts +123 -135
- package/dist/rest/tags.d.mts +30 -30
- package/dist/rest/tokens.d.mts +250 -260
- package/dist/rest/tokens.mjs +10 -42
- package/dist/rest/topics.d.mts +162 -162
- package/dist/rest/topics.mjs +1 -1
- package/dist/rest/trees.d.mts +117 -117
- package/dist/rest/wire.d.mts +7 -5
- package/dist/rest/wire.mjs +4 -3
- package/dist/rest/work.d.mts +69 -69
- package/dist/rest/work.mjs +1 -1
- package/dist/rest.d.mts +1 -7
- package/dist/rest.mjs +1 -5
- package/dist/server/check-fetch.mjs +9 -0
- package/dist/server/extension.mjs +3 -115
- package/dist/server/git-layer.d.mts +30 -5
- package/dist/server/git-layer.mjs +59 -29
- package/dist/server/git-namespace.d.mts +4 -4
- package/dist/server/git-namespace.mjs +6 -4
- package/dist/server/joined.d.mts +83 -0
- package/dist/server/joined.mjs +91 -0
- package/dist/server/registry.d.mts +7 -3
- package/dist/server/registry.mjs +135 -31
- package/dist/server/server.d.mts +9 -3
- package/dist/server/server.mjs +277 -208
- package/dist/signin/context.d.mts +2 -2
- package/dist/signin/context.mjs +28 -37
- package/dist/signin/device.mjs +5 -5
- package/dist/signin/forms.mjs +1 -1
- package/dist/signin/grants.d.mts +2 -3
- package/dist/signin/grants.mjs +5 -5
- package/dist/signin/layer.d.mts +9 -0
- package/dist/signin/layer.mjs +41 -0
- package/dist/signin/namespace.d.mts +2 -0
- package/dist/signin/public.d.mts +6 -0
- package/dist/signin/public.mjs +5 -0
- package/dist/signin/route.mjs +47 -21
- package/dist/signin/web.mjs +3 -3
- package/dist/signin/wire.mjs +1 -1
- package/dist/storage/calls.d.mts +1 -1
- package/dist/storage/calls.mjs +4 -4
- package/dist/storage/clean-up.mjs +15 -6
- package/dist/storage/counted-bucket.mjs +34 -51
- package/dist/storage/fetch.mjs +1 -1
- package/dist/storage/fsck.mjs +12 -2
- package/dist/storage/graph-rebuild.mjs +262 -0
- package/dist/storage/host-bucket.mjs +1 -1
- package/dist/storage/index-build.d.mts +2 -2
- package/dist/storage/index-build.mjs +103 -15
- package/dist/storage/index-fetch.mjs +10 -6
- package/dist/storage/index-graph.mjs +1 -1
- package/dist/storage/index-layers.mjs +1 -1
- package/dist/storage/index-visible.mjs +1 -1
- package/dist/storage/lfs-pointers.d.mts +5 -5
- package/dist/storage/lfs-pointers.mjs +37 -11
- package/dist/storage/loose.mjs +4 -1
- package/dist/storage/memory-budget.mjs +8 -2
- package/dist/storage/merge-cut.mjs +24 -1
- package/dist/storage/merge-fence.mjs +82 -20
- package/dist/storage/merge-most.mjs +1 -0
- package/dist/storage/merge-plan.mjs +5 -2
- package/dist/storage/merge-row.mjs +17 -5
- package/dist/storage/merge-stream.mjs +25 -13
- package/dist/storage/merge-write.mjs +1 -1
- package/dist/storage/merge.d.mts +2 -2
- package/dist/storage/merge.mjs +1 -1
- package/dist/storage/object-rows.d.mts +2 -2
- package/dist/storage/object-rows.mjs +20 -4
- package/dist/storage/pack-ranges.d.mts +3 -1
- package/dist/storage/pack-ranges.mjs +168 -69
- package/dist/storage/pack-reads.mjs +4 -4
- package/dist/storage/pack-receive.d.mts +1 -1
- package/dist/storage/pack-receive.mjs +17 -15
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +103 -79
- package/dist/storage/placed-reads.mjs +81 -15
- package/dist/storage/prune-seen.mjs +126 -0
- package/dist/storage/prune-walk.mjs +87 -99
- package/dist/storage/prune.mjs +113 -50
- package/dist/storage/push-uploads.mjs +4 -2
- package/dist/storage/quarantine.d.mts +2 -2
- package/dist/storage/ready.d.mts +2 -2
- package/dist/storage/ready.mjs +15 -6
- package/dist/storage/receive-files.mjs +1 -1
- package/dist/storage/receive-links.mjs +1 -1
- package/dist/storage/receive-state.d.mts +2 -2
- package/dist/storage/receive-state.mjs +2 -2
- package/dist/storage/receive-steps.mjs +1 -1
- package/dist/storage/repack-contained.mjs +24 -16
- package/dist/storage/repack-job.d.mts +2 -2
- package/dist/storage/repack-job.mjs +5 -4
- package/dist/storage/repack.d.mts +2 -2
- package/dist/storage/repack.mjs +12 -5
- package/dist/storage/rows.d.mts +2 -2
- package/dist/storage/rows.mjs +1 -1
- package/dist/storage/runs.d.mts +2 -2
- package/dist/storage/runs.mjs +15 -6
- package/dist/storage/send-list.mjs +6 -6
- package/dist/storage/single-flight.mjs +2 -2
- package/dist/storage/swap-walk.mjs +1 -1
- package/dist/storage/unpack.mjs +8 -1
- package/dist/store/call-count.d.mts +24 -4
- package/dist/store/call-count.mjs +158 -44
- package/dist/store/catalogue.d.mts +1 -1
- package/dist/store/catalogue.mjs +2 -2
- package/dist/store/crossing.mjs +2 -6
- package/dist/store/cursor-seal.mjs +1 -1
- package/dist/store/errors.d.mts +7 -3
- package/dist/store/errors.mjs +41 -13
- package/dist/store/job-try.mjs +119 -15
- package/dist/store/list-job.mjs +5 -5
- package/dist/store/outbox.d.mts +2 -2
- package/dist/store/outbox.mjs +75 -16
- package/dist/store/promises.d.mts +2 -2
- package/dist/store/promises.mjs +31 -6
- package/dist/store/queue-jobs.mjs +1 -1
- package/dist/store/records.d.mts +2 -2
- package/dist/store/records.mjs +22 -24
- package/dist/store/ref-rows.d.mts +2 -2
- package/dist/store/ref-rows.mjs +6 -6
- package/dist/store/repo-record.mjs +29 -12
- package/dist/store/reservations.mjs +35 -8
- package/dist/store/scopes.mjs +12 -5
- package/dist/store/topic-jobs.mjs +8 -8
- package/dist/sync/bound.d.mts +1 -3
- package/dist/sync/bound.mjs +30 -42
- package/dist/sync/github.d.mts +5 -6
- package/dist/sync/github.mjs +37 -42
- package/dist/sync/http.mjs +15 -0
- package/dist/sync/import.mjs +30 -19
- package/dist/sync/layer.d.mts +13 -0
- package/dist/sync/layer.mjs +73 -0
- package/dist/sync/mirror.mjs +137 -58
- package/dist/sync/publish.mjs +3 -6
- package/dist/sync/step.mjs +223 -85
- package/dist/sync/tries.mjs +22 -15
- package/dist/sync.d.mts +3 -6
- package/dist/sync.mjs +3 -6
- package/dist/topics/advance.mjs +210 -94
- package/dist/topics/calls.mjs +8 -8
- package/dist/topics/directory.mjs +35 -12
- package/dist/topics/host.d.mts +5 -8
- package/dist/topics/host.mjs +42 -19
- package/dist/topics/layer.d.mts +381 -0
- package/dist/topics/layer.mjs +62 -0
- package/dist/topics/members.mjs +39 -10
- package/dist/topics/namespace.d.mts +2 -0
- package/dist/topics/public.d.mts +6 -0
- package/dist/topics/public.mjs +13 -0
- package/dist/topics/rows.mjs +12 -3
- package/dist/topics/topic.mjs +11 -10
- package/package.json +8 -13
- package/dist/access.d.mts +0 -2
- package/dist/access.mjs +0 -1
- package/dist/core/hooks/post-receive.mjs +0 -216
- package/dist/core/hooks/pre-receive.d.mts +0 -12
- package/dist/core/hooks/pre-receive.mjs +0 -36
- package/dist/engine/merge-base-walk.d.mts +0 -3
- package/dist/server/extension.d.mts +0 -21
- package/dist/server/routes.d.mts +0 -32
- package/dist/server/routes.mjs +0 -69
- package/dist/sync/import.d.mts +0 -10
- package/dist/sync/jobs.d.mts +0 -9
- package/dist/sync/jobs.mjs +0 -75
- package/dist/sync/mirror.d.mts +0 -13
- package/dist/sync/publish.d.mts +0 -6
- /package/dist/core/{claim-rows.d.mts → registered-rows.d.mts} +0 -0
package/dist/topics/advance.mjs
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
import { millis } from "../contracts/promises.mjs";
|
|
2
|
-
import { hostCall } from "../auth/host-function.mjs";
|
|
2
|
+
import { hostCall, hostEffect } from "../auth/host-function.mjs";
|
|
3
|
+
import { checkPublish } from "../queue/advance.mjs";
|
|
3
4
|
import { advanceRow } from "../store/queue-jobs.mjs";
|
|
5
|
+
import { gitJob } from "../store/job-try.mjs";
|
|
4
6
|
import { storeCall } from "../store/errors.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { repoScope } from "../store/scopes.mjs";
|
|
7
|
+
import { untilAborted } from "../store/crossing.mjs";
|
|
8
|
+
import { repoScope, topicScope } from "../store/scopes.mjs";
|
|
7
9
|
import { CandidateSetData, PrepareData, TopicAdvanceData, prepareName, prepareRow, reportTimeoutName, reportTimeoutRow, topicAdvanceName, topicAdvanceRow } from "../store/topic-jobs.mjs";
|
|
8
10
|
import { projectTopic } from "./directory.mjs";
|
|
9
|
-
import { saveMargin } from "./host.mjs";
|
|
11
|
+
import { TopicsHost, saveMargin } from "./host.mjs";
|
|
10
12
|
import { addMember, candidateAt, memberRead, releaseMember, reserveMember } from "./members.mjs";
|
|
13
|
+
import { unwaited } from "./rows.mjs";
|
|
11
14
|
import { commitTopic, currentSet, durationWords, entriesOf, failureOf, readTopic, setKeyOf, topicOf } from "./topic.mjs";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import * as Schema from "effect/Schema";
|
|
15
|
-
import * as Effect from "effect/Effect";
|
|
16
|
-
import * as Predicate from "effect/Predicate";
|
|
15
|
+
import { QueueParts, overStore } from "../core/parts.mjs";
|
|
16
|
+
import { checkedAnswer, plainAnswer } from "../core/rules/context.mjs";
|
|
17
17
|
import * as Clock$1 from "effect/Clock";
|
|
18
|
+
import * as Effect from "effect/Effect";
|
|
18
19
|
import * as Result from "effect/Result";
|
|
20
|
+
import { CurrentJob, Job, LostTry } from "@ref0/infra";
|
|
21
|
+
import * as Predicate from "effect/Predicate";
|
|
22
|
+
import * as Context from "effect/Context";
|
|
19
23
|
// src/topics/advance.ts
|
|
20
24
|
/**
|
|
21
|
-
* `
|
|
25
|
+
* `topics.advance`, one step at a time, each one commit in one scope, read again before the
|
|
22
26
|
* next: so a crash between any two leaves a topic its next run goes on from.
|
|
23
27
|
*
|
|
24
28
|
* - **Before the decision** (`reserving`, `checking`): it adds the members' entries and reserves
|
|
@@ -42,10 +46,11 @@ const tries = 10;
|
|
|
42
46
|
* Every failed try runs again, 1 second doubling to 5 minutes, so the job is never failed: a topic
|
|
43
47
|
* still open fails once it's out of tries and lets go; one decided only rolls forward.
|
|
44
48
|
*/
|
|
45
|
-
const retry = (failure) => Math.min(1e3 * 2 ** (failure.attempt - 1), 3e5);
|
|
46
49
|
/**
|
|
47
50
|
* Who a topic's members are added as: the actor and subject of its add, `queued`, as the queue's
|
|
48
|
-
* own jobs ask `authorize` for an entry's actor.
|
|
51
|
+
* own jobs ask `authorize` for an entry's actor. They're its whole caller: no token or grant
|
|
52
|
+
* reaches `topic.add`, which is in no scope's ceiling (`auth/authorize.ts`' `ceilings`) and names
|
|
53
|
+
* no repo for one to cover, so none was there to save.
|
|
49
54
|
*/
|
|
50
55
|
const callerOf = (row) => {
|
|
51
56
|
const caller = {
|
|
@@ -68,9 +73,8 @@ const inOrder = (members) => [...members].sort((a, b) => {
|
|
|
68
73
|
* what it held. Answers whether it committed.
|
|
69
74
|
*/
|
|
70
75
|
const block = /* @__PURE__ */ Effect.fnUntraced(function* (read, failure, row = read.row, more = []) {
|
|
71
|
-
const { waitingOn: _waited, ...rest } = row;
|
|
72
76
|
const next = {
|
|
73
|
-
...
|
|
77
|
+
...unwaited(row),
|
|
74
78
|
state: "failed",
|
|
75
79
|
failure
|
|
76
80
|
};
|
|
@@ -101,8 +105,7 @@ const requiredOf = /* @__PURE__ */ Effect.fnUntraced(function* (host, read) {
|
|
|
101
105
|
topic: read.id,
|
|
102
106
|
entries: entriesOf(read.row)
|
|
103
107
|
};
|
|
104
|
-
const
|
|
105
|
-
const asked = yield* Effect.result(hostCall(reports, "topics.required", {}, () => required(question)));
|
|
108
|
+
const asked = yield* Effect.result(hostCall("topics.required", {}, () => required(question)));
|
|
106
109
|
if (Result.isSuccess(asked)) return asked.success;
|
|
107
110
|
yield* block(read, hostError(asked.failure));
|
|
108
111
|
});
|
|
@@ -196,8 +199,51 @@ const addMissing = /* @__PURE__ */ Effect.fnUntraced(function* (host, read) {
|
|
|
196
199
|
const sameCandidates = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
197
200
|
/** Whether `a` and `b` name the same wait. */
|
|
198
201
|
const sameWait = (a, b) => a.repo === b?.repo && a.target === b.target && a.topic === b.topic && a.hold === b.hold;
|
|
202
|
+
/** The index in `row.members` of the member whose target its topic reserves first. */
|
|
203
|
+
const firstOf = (row) => {
|
|
204
|
+
const [first] = inOrder(row.members);
|
|
205
|
+
return first === void 0 ? void 0 : row.members.indexOf(first);
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Saves that `read`'s topic holds its first target from `since`, that reservation's own time,
|
|
209
|
+
* which ends its wait: its `timeout` counts from then, and its `waitTimeout` no more.
|
|
210
|
+
*/
|
|
211
|
+
const heldFrom = /* @__PURE__ */ Effect.fnUntraced(function* (read, since) {
|
|
212
|
+
const { waitingSince: _since, ...rest } = read.row;
|
|
213
|
+
yield* commitTopic(read, {
|
|
214
|
+
...rest,
|
|
215
|
+
heldSince: since
|
|
216
|
+
});
|
|
217
|
+
return "again";
|
|
218
|
+
});
|
|
219
|
+
/** Pages of a topic's failed `topics.prepare` jobs read for one set's, at most. */
|
|
220
|
+
const failedPreparePages = 4;
|
|
221
|
+
/**
|
|
222
|
+
* Whether the `topics.prepare` job of `set`, keyed by it, failed: only that exact set's row
|
|
223
|
+
* counts, so one absent, waiting, running or done, or another set's, is not failed.
|
|
224
|
+
*/
|
|
225
|
+
const prepareFailedFor = /* @__PURE__ */ Effect.fnUntraced(function* (id, set) {
|
|
226
|
+
const { jobs } = yield* QueueParts;
|
|
227
|
+
const scope = topicScope(id);
|
|
228
|
+
let after;
|
|
229
|
+
for (let page = 0; page < failedPreparePages; page += 1) {
|
|
230
|
+
const request = {
|
|
231
|
+
state: "failed",
|
|
232
|
+
name: prepareName
|
|
233
|
+
};
|
|
234
|
+
const paged = after === void 0 ? request : {
|
|
235
|
+
...request,
|
|
236
|
+
page: { after }
|
|
237
|
+
};
|
|
238
|
+
const listed = yield* storeCall(() => jobs.list(scope, paged));
|
|
239
|
+
if (listed.items.some((item) => item.key === set)) return true;
|
|
240
|
+
after = listed.next;
|
|
241
|
+
if (after === void 0) return false;
|
|
242
|
+
}
|
|
243
|
+
return false;
|
|
244
|
+
});
|
|
199
245
|
/** A step before the publish decision. */
|
|
200
|
-
const beforeDecision = /* @__PURE__ */ Effect.fnUntraced(function* (host, read) {
|
|
246
|
+
const beforeDecision = /* @__PURE__ */ Effect.fnUntraced(function* (host, read, signal) {
|
|
201
247
|
const { row } = read;
|
|
202
248
|
if (row.members.some((member) => member.entry === void 0)) {
|
|
203
249
|
yield* addMissing(host, read);
|
|
@@ -213,8 +259,20 @@ const beforeDecision = /* @__PURE__ */ Effect.fnUntraced(function* (host, read)
|
|
|
213
259
|
return "again";
|
|
214
260
|
}
|
|
215
261
|
const reads = repos.filter(Predicate.isNotUndefined);
|
|
216
|
-
const { timeout } = host;
|
|
262
|
+
const { timeout, waitTimeout } = host;
|
|
217
263
|
const now = yield* Clock$1.currentTimeMillis;
|
|
264
|
+
const { waitingOn, waitingSince } = row;
|
|
265
|
+
const first = row.state === "reserving" && row.heldSince === void 0 ? firstOf(row) : void 0;
|
|
266
|
+
const saved = first === void 0 ? void 0 : repos[first]?.state.row.reserved;
|
|
267
|
+
if (saved?.topic === read.id) return yield* heldFrom(read, saved.since);
|
|
268
|
+
if (waitingSince !== void 0 && now - waitingSince > millis(waitTimeout)) {
|
|
269
|
+
const on = waitingOn === void 0 ? "its first target" : `${waitingOn.repo} ${waitingOn.target}`;
|
|
270
|
+
yield* block(read, {
|
|
271
|
+
reason: "timeout",
|
|
272
|
+
summary: `Waited for ${on} past its ${durationWords(waitTimeout)} waitTimeout`
|
|
273
|
+
});
|
|
274
|
+
return "again";
|
|
275
|
+
}
|
|
218
276
|
if (row.heldSince !== void 0 && now - row.heldSince > millis(timeout)) {
|
|
219
277
|
const held = row.members.filter((_, index) => repos[index]?.state.row.reserved?.topic === read.id);
|
|
220
278
|
const targets = inOrder(held).map(({ repo, target }) => `${repo} ${target}`).join(", ");
|
|
@@ -229,26 +287,25 @@ const beforeDecision = /* @__PURE__ */ Effect.fnUntraced(function* (host, read)
|
|
|
229
287
|
yield* block(read, ended);
|
|
230
288
|
return "again";
|
|
231
289
|
}
|
|
290
|
+
const waited = row.waitingSince ?? row.heldSince;
|
|
291
|
+
const freeze = waited !== void 0 && now - waited >= millis(waitTimeout) / 2;
|
|
232
292
|
if (row.state === "reserving") {
|
|
233
293
|
for (const member of inOrder(row.members)) {
|
|
234
|
-
const reserved = yield* reserveMember(member, { topic: read.id });
|
|
235
|
-
if (reserved.held && row.heldSince
|
|
294
|
+
const reserved = yield* reserveMember(member, { topic: read.id }, freeze);
|
|
295
|
+
if (reserved.held && row.heldSince !== void 0) continue;
|
|
296
|
+
if (reserved.held) return yield* heldFrom(read, reserved.since);
|
|
297
|
+
if (!sameWait(reserved.waiting, row.waitingOn)) {
|
|
298
|
+
const since = row.heldSince === void 0 ? { waitingSince: row.waitingSince ?? now } : {};
|
|
236
299
|
yield* commitTopic(read, {
|
|
237
300
|
...row,
|
|
238
|
-
|
|
301
|
+
waitingOn: reserved.waiting,
|
|
302
|
+
...since
|
|
239
303
|
});
|
|
240
|
-
return "again";
|
|
241
304
|
}
|
|
242
|
-
if (reserved.held) continue;
|
|
243
|
-
if (!sameWait(reserved.waiting, row.waitingOn)) yield* commitTopic(read, {
|
|
244
|
-
...row,
|
|
245
|
-
waitingOn: reserved.waiting
|
|
246
|
-
});
|
|
247
305
|
return "waits";
|
|
248
306
|
}
|
|
249
|
-
const { waitingOn: _waited, ...rest } = row;
|
|
250
307
|
yield* commitTopic(read, {
|
|
251
|
-
...
|
|
308
|
+
...unwaited(row),
|
|
252
309
|
state: "checking"
|
|
253
310
|
});
|
|
254
311
|
return "again";
|
|
@@ -289,7 +346,8 @@ const beforeDecision = /* @__PURE__ */ Effect.fnUntraced(function* (host, read)
|
|
|
289
346
|
}
|
|
290
347
|
const set = currentSet(row);
|
|
291
348
|
if (set === void 0 || !candidates.every((at) => at.passed === true)) return "waits";
|
|
292
|
-
|
|
349
|
+
const held = yield* Effect.forEach(row.members, (member) => memberRead(member));
|
|
350
|
+
if (!held.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";
|
|
293
351
|
const required = yield* requiredOf(host, read);
|
|
294
352
|
if (required === void 0) return "again";
|
|
295
353
|
if (required) {
|
|
@@ -297,16 +355,54 @@ const beforeDecision = /* @__PURE__ */ Effect.fnUntraced(function* (host, read)
|
|
|
297
355
|
if (report?.set !== set || report.verdict !== "pass") return "waits";
|
|
298
356
|
}
|
|
299
357
|
if (host.prepare !== void 0 && row.prepared !== set) {
|
|
300
|
-
if (row.asked
|
|
301
|
-
|
|
358
|
+
if (row.asked !== set) {
|
|
359
|
+
const ids = candidates.map(({ candidate }) => candidate);
|
|
360
|
+
yield* commitTopic(read, {
|
|
361
|
+
...row,
|
|
362
|
+
asked: set
|
|
363
|
+
}, [], [prepareRow(set, ids)]);
|
|
364
|
+
return "again";
|
|
365
|
+
}
|
|
366
|
+
if (yield* prepareFailedFor(read.id, set)) yield* block(read, { reason: "work-failed" });
|
|
367
|
+
return "waits";
|
|
368
|
+
}
|
|
369
|
+
const from = row.preflight?.set === set ? row.preflight.through : 0;
|
|
370
|
+
const page = row.members.slice(from, from + 200);
|
|
371
|
+
for (const [offset, member] of page.entries()) {
|
|
372
|
+
const at = held[from + offset];
|
|
373
|
+
const candidate = candidates[from + offset];
|
|
374
|
+
const open = at?.candidate;
|
|
375
|
+
if (at === void 0 || open === void 0 || candidate === void 0) return "waits";
|
|
376
|
+
const refused = yield* checkPublish(at.state, open, candidate.commit, signal);
|
|
377
|
+
if (refused === void 0) continue;
|
|
378
|
+
const { repo, entry } = member;
|
|
379
|
+
const named = entry === void 0 ? { repo } : {
|
|
380
|
+
repo,
|
|
381
|
+
entry
|
|
382
|
+
};
|
|
383
|
+
const summary = refused.error.message;
|
|
384
|
+
yield* block(read, {
|
|
385
|
+
reason: "refused",
|
|
386
|
+
...named,
|
|
387
|
+
candidate: candidate.candidate,
|
|
388
|
+
summary
|
|
389
|
+
});
|
|
390
|
+
return "again";
|
|
391
|
+
}
|
|
392
|
+
const through = from + page.length;
|
|
393
|
+
if (through < row.members.length) {
|
|
302
394
|
yield* commitTopic(read, {
|
|
303
395
|
...row,
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
396
|
+
preflight: {
|
|
397
|
+
set,
|
|
398
|
+
through
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
return "more";
|
|
307
402
|
}
|
|
403
|
+
const { preflight: _preflight, ...checked } = row;
|
|
308
404
|
yield* commitTopic(read, {
|
|
309
|
-
...
|
|
405
|
+
...checked,
|
|
310
406
|
state: "publishing",
|
|
311
407
|
decided: set
|
|
312
408
|
});
|
|
@@ -315,12 +411,16 @@ const beforeDecision = /* @__PURE__ */ Effect.fnUntraced(function* (host, read)
|
|
|
315
411
|
/** A step after the publish decision: every member's queue woken, till each merged. */
|
|
316
412
|
const afterDecision = /* @__PURE__ */ Effect.fnUntraced(function* (read) {
|
|
317
413
|
const { row } = read;
|
|
318
|
-
const { store } = yield* CoreParts;
|
|
319
414
|
const reads = yield* Effect.forEach(row.members, (member) => memberRead(member));
|
|
320
415
|
const merged = [];
|
|
416
|
+
let refused;
|
|
321
417
|
for (const [index, member] of row.members.entries()) {
|
|
322
418
|
const at = reads[index];
|
|
323
419
|
const candidate = row.candidates[index];
|
|
420
|
+
if (at?.entry?.state === "failed") {
|
|
421
|
+
refused ??= member;
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
324
424
|
if ((at === void 0 || at.entry?.state === "merged") && member.entry !== void 0 && candidate !== void 0) {
|
|
325
425
|
const { repo, target } = member;
|
|
326
426
|
const { candidate: id, commit } = candidate;
|
|
@@ -335,7 +435,22 @@ const afterDecision = /* @__PURE__ */ Effect.fnUntraced(function* (read) {
|
|
|
335
435
|
continue;
|
|
336
436
|
}
|
|
337
437
|
const jobs = [advanceRow(member.target)];
|
|
338
|
-
yield* storeCall(()
|
|
438
|
+
yield* storeCall((yield* TopicsHost).queue.records.add(repoScope(member.internalId), { jobs }));
|
|
439
|
+
}
|
|
440
|
+
if (refused !== void 0) {
|
|
441
|
+
const { repo, entry } = refused;
|
|
442
|
+
const named = entry === void 0 ? { repo } : {
|
|
443
|
+
repo,
|
|
444
|
+
entry
|
|
445
|
+
};
|
|
446
|
+
const published = merged.map((one) => one.repo).join(", ");
|
|
447
|
+
const summary = `${repo}'s publish was refused, after ${published === "" ? "no member" : published} published`;
|
|
448
|
+
yield* block(read, {
|
|
449
|
+
reason: "refused",
|
|
450
|
+
...named,
|
|
451
|
+
summary
|
|
452
|
+
});
|
|
453
|
+
return "again";
|
|
339
454
|
}
|
|
340
455
|
if (merged.length < row.members.length) return "waits";
|
|
341
456
|
const event = {
|
|
@@ -355,12 +470,12 @@ const afterDecision = /* @__PURE__ */ Effect.fnUntraced(function* (read) {
|
|
|
355
470
|
}]);
|
|
356
471
|
return "again";
|
|
357
472
|
});
|
|
358
|
-
/** One step of `
|
|
359
|
-
const advanceStep = /* @__PURE__ */ Effect.fnUntraced(function* (host, id) {
|
|
473
|
+
/** One step of `topics.advance` for `id`. */
|
|
474
|
+
const advanceStep = /* @__PURE__ */ Effect.fnUntraced(function* (host, id, signal) {
|
|
360
475
|
const read = yield* readTopic(id);
|
|
361
476
|
const { row } = read;
|
|
362
477
|
if (row === void 0) return "done";
|
|
363
|
-
yield* projectTopic((yield*
|
|
478
|
+
yield* projectTopic((yield* TopicsHost).records, id, row);
|
|
364
479
|
const own = {
|
|
365
480
|
...read,
|
|
366
481
|
row
|
|
@@ -371,7 +486,7 @@ const advanceStep = /* @__PURE__ */ Effect.fnUntraced(function* (host, id) {
|
|
|
371
486
|
}
|
|
372
487
|
if (row.state !== "checking" && row.state !== "reserving" && row.state !== "publishing") return "done";
|
|
373
488
|
if (row.state === "publishing") return yield* afterDecision(own);
|
|
374
|
-
return yield* beforeDecision(host, own);
|
|
489
|
+
return yield* beforeDecision(host, own, signal);
|
|
375
490
|
});
|
|
376
491
|
/** Whether a claim of the topic's job, its `attempt`, comes after `tries` failed in a row. */
|
|
377
492
|
const outOfTries = (attempt) => attempt > tries;
|
|
@@ -385,7 +500,7 @@ const workFailedOf = (id, row, job) => ({
|
|
|
385
500
|
name: job.name,
|
|
386
501
|
attempts: job.attempt - 1
|
|
387
502
|
});
|
|
388
|
-
/** How many steps one try of `
|
|
503
|
+
/** How many steps one try of `topics.advance` takes before it asks for more. */
|
|
389
504
|
const stepsPerTry = 20;
|
|
390
505
|
const advance = /* @__PURE__ */ Effect.fnUntraced(function* (host, job) {
|
|
391
506
|
const id = topicIdOf(job);
|
|
@@ -401,7 +516,7 @@ const advance = /* @__PURE__ */ Effect.fnUntraced(function* (host, job) {
|
|
|
401
516
|
} else if (row?.state === "publishing" && saysFailed(job.attempt)) yield* commitTopic(read, row, [workFailedOf(id, row, job)]);
|
|
402
517
|
}
|
|
403
518
|
for (let step = 0; step < stepsPerTry; step += 1) {
|
|
404
|
-
const did = yield* advanceStep(host, id);
|
|
519
|
+
const did = yield* advanceStep(host, id, job.signal);
|
|
405
520
|
if (did === "done") return void 0;
|
|
406
521
|
if (did === "more") return { kind: "more" };
|
|
407
522
|
if (did === "waits") return {
|
|
@@ -449,12 +564,12 @@ const saveAnswer = /* @__PURE__ */ Effect.fnUntraced(function* (id, candidates,
|
|
|
449
564
|
return false;
|
|
450
565
|
});
|
|
451
566
|
/**
|
|
452
|
-
* `
|
|
567
|
+
* `topics.prepare`: the host's `prepare` for the exact set, while every reservation holds. An
|
|
453
568
|
* accept saves it, so the topic decides; a reject fails it `prepare-rejected`, and a throw or a
|
|
454
569
|
* timeout `host-error` at once, as the queue's `merge` throw fails its entry (Q648). An answer the
|
|
455
570
|
* topic couldn't take yet stays with the job, which saves it later without asking again.
|
|
456
571
|
*/
|
|
457
|
-
const prepareStep = /* @__PURE__ */ Effect.fnUntraced(function* (host, job
|
|
572
|
+
const prepareStep = /* @__PURE__ */ Effect.fnUntraced(function* (host, job) {
|
|
458
573
|
const { prepare } = host;
|
|
459
574
|
const id = topicIdOf(job);
|
|
460
575
|
const { candidates } = job.data;
|
|
@@ -477,12 +592,7 @@ const prepareStep = /* @__PURE__ */ Effect.fnUntraced(function* (host, job, sign
|
|
|
477
592
|
key: set,
|
|
478
593
|
attempt: job.attempt
|
|
479
594
|
};
|
|
480
|
-
const
|
|
481
|
-
const call = (own) => prepare.handler({
|
|
482
|
-
...input,
|
|
483
|
-
signal: AbortSignal.any([own, signal])
|
|
484
|
-
});
|
|
485
|
-
const answered = yield* hostCall(reports, "topics.prepare", {}, call, { timeout: prepare.timeout }).pipe(Effect.result);
|
|
595
|
+
const answered = yield* hostEffect("topics.prepare", {}, checkedAnswer("The topic's prepare", plainAnswer, () => prepare.handler(input)), { timeout: prepare.timeout }).pipe(Effect.result);
|
|
486
596
|
answer = Result.isFailure(answered) ? {
|
|
487
597
|
kind: "failed",
|
|
488
598
|
failure: hostError(answered.failure)
|
|
@@ -503,7 +613,7 @@ const rejected = (answer) => ({
|
|
|
503
613
|
summary: answer.message
|
|
504
614
|
});
|
|
505
615
|
/**
|
|
506
|
-
* `
|
|
616
|
+
* `topics.report-timeout`: fails the topic `report-timeout` when its exact set, still current
|
|
507
617
|
* before its decision, has no report by `report.timeout` (Q647).
|
|
508
618
|
*/
|
|
509
619
|
const reportTimeoutStep = /* @__PURE__ */ Effect.fnUntraced(function* (host, job) {
|
|
@@ -519,54 +629,60 @@ const reportTimeoutStep = /* @__PURE__ */ Effect.fnUntraced(function* (host, job
|
|
|
519
629
|
})) return;
|
|
520
630
|
}
|
|
521
631
|
});
|
|
632
|
+
/** Each failure retries indefinitely, capped at five minutes, as before the job move. */
|
|
633
|
+
const topicRetry = (failure) => Math.min(1e3 * 2 ** (failure.attempt - 1), 3e5);
|
|
522
634
|
/**
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
* `Authorize` the server's.
|
|
635
|
+
* Each try and onFailure builds its store inside the try. The core's repo calls use CurrentJob's
|
|
636
|
+
* fenced store; registration.records reads the same fiber's Fence for writes to the topic's own scopes.
|
|
526
637
|
*/
|
|
527
|
-
const overCore =
|
|
638
|
+
const overCore = /* @__PURE__ */ Effect.fnUntraced(function* (host, data, step) {
|
|
639
|
+
const job = yield* CurrentJob.current;
|
|
640
|
+
const store = yield* CurrentJob.store;
|
|
641
|
+
const signal = yield* CurrentJob.signal;
|
|
642
|
+
const current = yield* Effect.context();
|
|
643
|
+
const needs = Context.add(Context.merge(host.queue.needs, current), TopicsHost, host);
|
|
644
|
+
return yield* untilAborted(Effect.provideContext(overStore(store)(step({
|
|
645
|
+
...job,
|
|
646
|
+
data,
|
|
647
|
+
signal
|
|
648
|
+
})), needs), signal);
|
|
649
|
+
});
|
|
528
650
|
/**
|
|
529
|
-
* A
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
* the try's fenced store, until `onFailure`'s own minute aborts its signal.
|
|
651
|
+
* A prepare try's last failure releases its targets, without asking the host again: only while
|
|
652
|
+
* its own set is the one asked for and not yet prepared, so an older set's failure fails no newer
|
|
653
|
+
* set, which has its own job.
|
|
533
654
|
*/
|
|
534
|
-
const prepareFailed = (host) =>
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
const read = yield* readTopic(
|
|
655
|
+
const prepareFailed = (host, data) => overCore(host, data, (job) => Effect.gen(function* () {
|
|
656
|
+
const set = setKeyOf(job.data.candidates.map((candidate) => ({ candidate })));
|
|
657
|
+
for (let tried = 0; tried < commitTries; tried += 1) if (yield* Effect.gen(function* () {
|
|
658
|
+
const read = yield* readTopic(topicIdOf(job));
|
|
538
659
|
const { row } = read;
|
|
539
|
-
|
|
660
|
+
if (!(row?.state === "checking" || row?.state === "reserving") || row.asked !== set || row.prepared === set) return true;
|
|
661
|
+
return yield* block({
|
|
540
662
|
...read,
|
|
541
663
|
row
|
|
542
|
-
}, { reason: "work-failed" })
|
|
664
|
+
}, { reason: "work-failed" });
|
|
665
|
+
}).pipe(Effect.orElseSucceed(() => false))) return;
|
|
666
|
+
}));
|
|
667
|
+
const AdvanceJob = /* @__PURE__ */ Job.make(topicAdvanceName, {
|
|
668
|
+
payload: TopicAdvanceData,
|
|
669
|
+
retry: topicRetry
|
|
670
|
+
});
|
|
671
|
+
const ReportTimeoutJob = /* @__PURE__ */ Job.make(reportTimeoutName, {
|
|
672
|
+
payload: CandidateSetData,
|
|
673
|
+
retry: topicRetry
|
|
674
|
+
});
|
|
675
|
+
/** Topics' three jobs, registered by their own registration. */
|
|
676
|
+
const topicJobs = (host) => {
|
|
677
|
+
const PrepareJob = Job.make(prepareName, {
|
|
678
|
+
payload: PrepareData,
|
|
679
|
+
retry: (failure) => failure.error instanceof LostTry ? 0 : false,
|
|
680
|
+
timeout: (host.prepare?.timeout ?? 0) + saveMargin
|
|
543
681
|
});
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
682
|
+
return [
|
|
683
|
+
gitJob(AdvanceJob, (data) => overCore(host, data, (job) => advance(host, job))),
|
|
684
|
+
gitJob(PrepareJob, (data) => overCore(host, data, (job) => prepareStep(host, job)), { onFailure: (data) => prepareFailed(host, data) }),
|
|
685
|
+
gitJob(ReportTimeoutJob, (data) => overCore(host, data, (job) => reportTimeoutStep(host, job)))
|
|
686
|
+
];
|
|
548
687
|
};
|
|
549
|
-
/** Topics' jobs over `host`, which `createGitServer` registers beside its own. */
|
|
550
|
-
const topicJobs = (host) => [
|
|
551
|
-
defineJob({
|
|
552
|
-
name: topicAdvanceName,
|
|
553
|
-
schema: Schema.toStandardSchemaV1(TopicAdvanceData),
|
|
554
|
-
retry,
|
|
555
|
-
handler: (job, context) => runJobTry(overCore(host, context, advance(host, job)))
|
|
556
|
-
}),
|
|
557
|
-
defineJob({
|
|
558
|
-
name: prepareName,
|
|
559
|
-
schema: Schema.toStandardSchemaV1(PrepareData),
|
|
560
|
-
retry: (failure) => failure.error instanceof LostTry ? 0 : false,
|
|
561
|
-
timeout: (host.prepare?.timeout ?? 0) + saveMargin,
|
|
562
|
-
handler: (job, context) => runJobTry(untilAborted(overCore(host, context, prepareStep(host, job, context.signal)), context.signal)),
|
|
563
|
-
onFailure: prepareFailed(host)
|
|
564
|
-
}),
|
|
565
|
-
defineJob({
|
|
566
|
-
name: reportTimeoutName,
|
|
567
|
-
schema: Schema.toStandardSchemaV1(CandidateSetData),
|
|
568
|
-
retry,
|
|
569
|
-
handler: (job, context) => runJobTry(overCore(host, context, reportTimeoutStep(host, job)))
|
|
570
|
-
})
|
|
571
|
-
];
|
|
572
688
|
export { addMissing, block, inOrder, outOfTries, pollEvery, saysFailed, topicJobs };
|
package/dist/topics/calls.mjs
CHANGED
|
@@ -7,12 +7,13 @@ import { limitOf } from "../engine/reads.mjs";
|
|
|
7
7
|
import { checkBytes, jsonSize, queueLimits } from "../queue/limits.mjs";
|
|
8
8
|
import { topicAdvanceRow } from "../store/topic-jobs.mjs";
|
|
9
9
|
import { claimKey, indexPage } from "./directory.mjs";
|
|
10
|
+
import { TopicsHost } from "./host.mjs";
|
|
10
11
|
import { checkOwned } from "../queue/calls.mjs";
|
|
11
12
|
import { admitMember } from "./members.mjs";
|
|
12
|
-
import { TopicReportRow } from "./rows.mjs";
|
|
13
|
+
import { TopicReportRow, unwaited } from "./rows.mjs";
|
|
13
14
|
import { answeredFailure, commitTopic, currentSet, existing, failureOf, hintOf, readTopic, sameMembers, setKeyOf, topicOf } from "./topic.mjs";
|
|
14
|
-
import * as Schema from "effect/Schema";
|
|
15
15
|
import * as Effect from "effect/Effect";
|
|
16
|
+
import * as Schema from "effect/Schema";
|
|
16
17
|
// src/topics/calls.ts
|
|
17
18
|
/** The most members a topic has, as a candidate's entries. */
|
|
18
19
|
const topicMembers = queueLimits.candidateEntries;
|
|
@@ -196,7 +197,7 @@ const shownTopic = (topic, row, refView) => {
|
|
|
196
197
|
}
|
|
197
198
|
return seen;
|
|
198
199
|
};
|
|
199
|
-
const topicCalls = (
|
|
200
|
+
const topicCalls = (bound) => {
|
|
200
201
|
const callerOf = callerFor(bound);
|
|
201
202
|
/** The topic `caller` sees of `row`, or `NOT_FOUND`, as for one that isn't there. */
|
|
202
203
|
const answer = (caller, id, row) => Effect.flatMap(placesSeen(caller, row.members), (places) => answerAt(id, row, places));
|
|
@@ -213,8 +214,8 @@ const topicCalls = (host, bound) => {
|
|
|
213
214
|
caller,
|
|
214
215
|
operation: { kind: "topic.add" }
|
|
215
216
|
});
|
|
216
|
-
const { members, admitted } = yield* admitAll(
|
|
217
|
-
const id = yield* claimKey((yield*
|
|
217
|
+
const { members, admitted } = yield* admitAll(yield* TopicsHost, caller, input);
|
|
218
|
+
const id = yield* claimKey((yield* TopicsHost).records, caller.actor.id, input.key);
|
|
218
219
|
for (let attempt = 0; attempt < callTries; attempt += 1) {
|
|
219
220
|
const read = yield* readTopic(id);
|
|
220
221
|
const { row } = read;
|
|
@@ -257,7 +258,7 @@ const topicCalls = (host, bound) => {
|
|
|
257
258
|
operation: { kind: "topic.read" }
|
|
258
259
|
});
|
|
259
260
|
const limit = yield* limitOf(input.page);
|
|
260
|
-
const { store } = yield*
|
|
261
|
+
const { records: store } = yield* TopicsHost;
|
|
261
262
|
const { ids, next } = yield* indexPage(store, input.state, input.page?.after, limit);
|
|
262
263
|
const items = [];
|
|
263
264
|
for (const id of ids) {
|
|
@@ -285,9 +286,8 @@ const topicCalls = (host, bound) => {
|
|
|
285
286
|
const { row } = read;
|
|
286
287
|
if (row.state === "removed" || row.state === "failed") return yield* answer(caller, topic, row);
|
|
287
288
|
if (row.state === "publishing" || row.state === "merged") return yield* decided(row);
|
|
288
|
-
const { waitingOn: _waited, ...rest } = row;
|
|
289
289
|
const next = {
|
|
290
|
-
...
|
|
290
|
+
...unwaited(row),
|
|
291
291
|
state: "removed"
|
|
292
292
|
};
|
|
293
293
|
const event = {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { TopicState } from "../contracts/topics.mjs";
|
|
2
|
-
import { decodeDerivedRow, decodeRow
|
|
2
|
+
import { decodeDerivedRow, decodeRow } from "../store/errors.mjs";
|
|
3
3
|
import { randomText } from "../store/random.mjs";
|
|
4
4
|
import { topicKey } from "../store/reservations.mjs";
|
|
5
5
|
import { collections, newChangeId, topicScope, topicsScope } from "../store/scopes.mjs";
|
|
6
6
|
import { IndexRow, KeyClaim, TopicRow } from "./rows.mjs";
|
|
7
7
|
import { fail } from "../contracts/result.mjs";
|
|
8
|
+
import { utf8 } from "../protocol/bytes/text.mjs";
|
|
8
9
|
import * as Effect from "effect/Effect";
|
|
9
10
|
// src/topics/directory.ts
|
|
10
11
|
/**
|
|
@@ -18,18 +19,40 @@ import * as Effect from "effect/Effect";
|
|
|
18
19
|
* none needs to: a claim with no topic holds no target, and `topics.list` never shows it.
|
|
19
20
|
* - **`topics/<topic>`** and **`topic-states/<state>/<topic>`**: put by the projection after each of
|
|
20
21
|
* the topic's own commits, only from a revision newer than the one there. A lost projection
|
|
21
|
-
* leaves the rows of an earlier revision, until the topic's next commit or `
|
|
22
|
+
* leaves the rows of an earlier revision, until the topic's next commit or `topics.advance`,
|
|
22
23
|
* which projects first each run, brings them into line. So `topics.list` reads each topic's own
|
|
23
24
|
* row before it shows it, and shows that row's state, never the index's. An index row that
|
|
24
25
|
* doesn't decode holds no revision, so the projection answers it from the topic's own row.
|
|
25
26
|
*/
|
|
26
27
|
/** How many times a write to `git/topics` reads and commits again when another moved it first. */
|
|
27
28
|
const indexTries = 8;
|
|
28
|
-
/**
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
/** A `\`, a NUL or a lone surrogate: what `storedText` escapes. */
|
|
30
|
+
const unstorable = /[\\\0\uD800-\uDFFF]/gu;
|
|
31
|
+
/**
|
|
32
|
+
* `text` as a store ID can hold it: `\` as `\\`, NUL as `\0` and a lone surrogate as `\u` and its
|
|
33
|
+
* four hex digits. A store refuses NUL in an ID and keeps a lone surrogate as U+FFFD, so two keys
|
|
34
|
+
* apart only there would share a row; escaped, the text is well-formed with no NUL, and distinct
|
|
35
|
+
* texts stay distinct in UTF-8.
|
|
36
|
+
*/
|
|
37
|
+
const storedText = (text) => text.replaceAll(unstorable, (char) => {
|
|
38
|
+
if (char === "\\") return "\\\\";
|
|
39
|
+
if (char === "\0") return "\\0";
|
|
40
|
+
return `\\u${char.charCodeAt(0).toString(16)}`;
|
|
32
41
|
});
|
|
42
|
+
/**
|
|
43
|
+
* An actor's key's claim, by the actor's ID, which no rename moves, and the key, each escaped by
|
|
44
|
+
* `storedText`: the escaped ID's UTF-8 length, `:`, the escaped ID, then the escaped key. So
|
|
45
|
+
* distinct pairs never share the bytes a store keeps. The most it takes, at a 256-byte ID of `\`,
|
|
46
|
+
* which escapes to 512, and a key of `queueLimits.nameBytes`, which escapes to at most 254, is 770
|
|
47
|
+
* bytes, inside the store's `limits.idBytes` (Q1157). JSON took up to 1,797.
|
|
48
|
+
*/
|
|
49
|
+
const keyRead = (actor, key) => {
|
|
50
|
+
const storedActor = storedText(actor);
|
|
51
|
+
return {
|
|
52
|
+
collection: collections.topicKeys,
|
|
53
|
+
id: `${utf8(storedActor).length}:${storedActor}${storedText(key)}`
|
|
54
|
+
};
|
|
55
|
+
};
|
|
33
56
|
const indexKey = (topic) => ({
|
|
34
57
|
collection: collections.topicIndex,
|
|
35
58
|
id: topic
|
|
@@ -44,7 +67,7 @@ const newTopicId = () => `t_${randomText(12)}`;
|
|
|
44
67
|
/** The topic `actor`'s `key` names: the one its claim names, or a new one, claimed now. */
|
|
45
68
|
const claimKey = /* @__PURE__ */ Effect.fnUntraced(function* (store, actor, key) {
|
|
46
69
|
for (let attempt = 0; attempt < indexTries; attempt += 1) {
|
|
47
|
-
const { version, results } = yield*
|
|
70
|
+
const { version, results } = yield* store.read(topicsScope, [keyRead(actor, key)]);
|
|
48
71
|
const [row] = results[0] ?? [];
|
|
49
72
|
if (row !== void 0) return (yield* decodeRow(KeyClaim, row, `Topic key '${key}'`)).topic;
|
|
50
73
|
const topic = newTopicId();
|
|
@@ -57,7 +80,7 @@ const claimKey = /* @__PURE__ */ Effect.fnUntraced(function* (store, actor, key)
|
|
|
57
80
|
expect: version,
|
|
58
81
|
put
|
|
59
82
|
};
|
|
60
|
-
if ((yield*
|
|
83
|
+
if ((yield* store.commit("git/topics", change)).ok) return topic;
|
|
61
84
|
}
|
|
62
85
|
return yield* busy();
|
|
63
86
|
});
|
|
@@ -66,7 +89,7 @@ const claimKey = /* @__PURE__ */ Effect.fnUntraced(function* (store, actor, key)
|
|
|
66
89
|
* that row, and nothing deletes it, so a topic with none has lost it: `DATA_LOSS`.
|
|
67
90
|
*/
|
|
68
91
|
const newerOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, topic, row) {
|
|
69
|
-
const { results } = yield*
|
|
92
|
+
const { results } = yield* store.read(topicScope(topic), [topicKey]);
|
|
70
93
|
const [held] = results[0] ?? [];
|
|
71
94
|
if (held === void 0) return yield* fail("DATA_LOSS", `Topic ${topic} has no row`);
|
|
72
95
|
const own = yield* decodeRow(TopicRow, held, `Topic ${topic}`);
|
|
@@ -81,7 +104,7 @@ const newerOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, topic, row)
|
|
|
81
104
|
const projectTopic = /* @__PURE__ */ Effect.fnUntraced(function* (store, topic, caller) {
|
|
82
105
|
let row = caller;
|
|
83
106
|
for (let attempt = 0; attempt < indexTries; attempt += 1) {
|
|
84
|
-
const read = yield*
|
|
107
|
+
const read = yield* store.read(topicsScope, [indexKey(topic)]);
|
|
85
108
|
const [held] = read.results[0] ?? [];
|
|
86
109
|
const before = held === void 0 ? void 0 : yield* decodeDerivedRow(IndexRow, held);
|
|
87
110
|
if (before !== void 0 && before.revision >= row.revision) return;
|
|
@@ -103,7 +126,7 @@ const projectTopic = /* @__PURE__ */ Effect.fnUntraced(function* (store, topic,
|
|
|
103
126
|
}],
|
|
104
127
|
delete: left.map((state) => stateKey(state, topic))
|
|
105
128
|
};
|
|
106
|
-
if ((yield*
|
|
129
|
+
if ((yield* store.commit("git/topics", change)).ok) return;
|
|
107
130
|
}
|
|
108
131
|
return yield* busy();
|
|
109
132
|
});
|
|
@@ -116,7 +139,7 @@ const indexPage = /* @__PURE__ */ Effect.fnUntraced(function* (store, state, aft
|
|
|
116
139
|
};
|
|
117
140
|
if (prefix !== void 0) read.prefix = prefix;
|
|
118
141
|
if (after !== void 0) read.after = `${prefix ?? ""}${after}`;
|
|
119
|
-
const { results } = yield*
|
|
142
|
+
const { results } = yield* store.read(topicsScope, [read]);
|
|
120
143
|
const rows = results[0] ?? [];
|
|
121
144
|
const ids = rows.slice(0, limit).map((row) => row.id.slice(prefix?.length ?? 0));
|
|
122
145
|
return {
|
package/dist/topics/host.d.mts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import "../contracts/promises.mjs";
|
|
2
|
-
import
|
|
2
|
+
import "../contracts/git.mjs";
|
|
3
|
+
import { TopicsFactory, TopicsLayerOptions } from "../contracts/topics.mjs";
|
|
3
4
|
import "../queue/host.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* a `prepare` that isn't a function or `{ handler }`, or one whose `timeout` passes 12 minutes,
|
|
8
|
-
* throws a `TypeError`.
|
|
9
|
-
*/
|
|
10
|
-
export declare const topics: (options?: TopicsOptions) => TopicsFactory;
|
|
5
|
+
import "effect/Context";
|
|
6
|
+
/** The temporary factory, holding the checked options until 2c removes createGitServer. */
|
|
7
|
+
export declare const topics: (options?: TopicsLayerOptions) => TopicsFactory;
|