@ref0/git 0.4.0 → 0.7.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 +31 -17
- 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 +13 -9
- package/dist/auth/fences.d.mts +1 -1
- package/dist/auth/host-function.mjs +17 -8
- package/dist/auth/identify.d.mts +5 -3
- package/dist/auth/identify.mjs +2 -1
- package/dist/auth/namespaces.d.mts +2 -2
- package/dist/auth/token-rows.mjs +1 -1
- package/dist/auth/tokens-layer.d.mts +42 -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 +29 -0
- package/dist/auth/tokens.d.mts +13 -6
- package/dist/auth/tokens.mjs +13 -12
- package/dist/auth.d.mts +2 -2
- package/dist/auth.mjs +2 -2
- package/dist/client/git-http.mjs +1 -1
- package/dist/client/local.mjs +6 -3
- package/dist/client/remote-helper.mjs +3 -8
- package/dist/client/remote.mjs +26 -7
- package/dist/client/run-remote-helper.d.mts +1 -1
- package/dist/client/run-remote-helper.mjs +2 -2
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/contracts/access.d.mts +24 -12
- package/dist/contracts/access.mjs +17 -0
- package/dist/contracts/actors.d.mts +17 -1
- package/dist/contracts/actors.mjs +8 -1
- package/dist/contracts/authorize.d.mts +21 -14
- package/dist/contracts/blobs.d.mts +1 -1
- package/dist/contracts/blobs.mjs +1 -1
- package/dist/contracts/calls-spent.d.mts +6 -4
- package/dist/contracts/calls-spent.mjs +10 -8
- 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 +64 -26
- package/dist/contracts/events.mjs +26 -6
- package/dist/contracts/files.d.mts +2 -2
- package/dist/contracts/files.mjs +1 -1
- package/dist/contracts/forks.d.mts +58 -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 +37 -0
- package/dist/contracts/git-hooks.mjs +10 -0
- package/dist/contracts/git.d.mts +138 -22
- package/dist/contracts/git.mjs +6 -5
- package/dist/contracts/grants.d.mts +6 -1
- package/dist/contracts/ids.d.mts +16 -0
- package/dist/contracts/ids.mjs +19 -4
- package/dist/contracts/lfs.d.mts +7 -2
- package/dist/contracts/namespaces.d.mts +2 -2
- package/dist/contracts/objects.d.mts +7 -2
- package/dist/contracts/opaque.mjs +9 -0
- package/dist/contracts/operations.d.mts +293 -100
- package/dist/contracts/promises.d.mts +4 -14
- package/dist/contracts/push-uploads.d.mts +5 -2
- package/dist/contracts/push-uploads.mjs +9 -4
- package/dist/contracts/queue.d.mts +233 -54
- package/dist/contracts/queue.mjs +81 -6
- package/dist/contracts/refs.d.mts +30 -8
- package/dist/contracts/refs.mjs +1 -1
- package/dist/contracts/remote.d.mts +42 -21
- package/dist/contracts/remote.mjs +22 -0
- package/dist/contracts/repo-records.d.mts +2 -2
- package/dist/contracts/repos.d.mts +126 -79
- package/dist/contracts/repos.mjs +43 -5
- package/dist/contracts/result.d.mts +50 -31
- package/dist/contracts/result.mjs +48 -16
- package/dist/contracts/rules.d.mts +50 -44
- package/dist/contracts/rules.mjs +5 -1
- package/dist/contracts/server.d.mts +282 -191
- package/dist/contracts/services.d.mts +1 -7
- package/dist/contracts/services.mjs +1 -3
- package/dist/contracts/signin.d.mts +140 -43
- package/dist/contracts/signin.mjs +35 -1
- package/dist/contracts/store.d.mts +1 -1
- package/dist/contracts/sync.d.mts +112 -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 +232 -57
- package/dist/contracts/tokens.mjs +80 -19
- package/dist/contracts/topics.d.mts +22 -10
- package/dist/contracts/topics.mjs +6 -3
- package/dist/contracts/trees.d.mts +2 -2
- package/dist/contracts/trees.mjs +1 -1
- package/dist/contracts/work.d.mts +3 -3
- package/dist/contracts/work.mjs +2 -2
- package/dist/core/access.d.mts +10 -10
- package/dist/core/access.mjs +47 -8
- package/dist/core/call-names.d.mts +3 -1
- package/dist/core/clock.mjs +1 -1
- package/dist/core/events/deliver.d.mts +13 -0
- package/dist/core/events/deliver.mjs +475 -175
- package/dist/core/events/seen.mjs +17 -3
- package/dist/core/forks.mjs +131 -44
- package/dist/core/hooks/groups.d.mts +27 -0
- package/dist/core/hooks/groups.mjs +74 -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 +31 -22
- 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 +3 -3
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +27 -2
- package/dist/core/parts.mjs +5 -3
- package/dist/core/promise.mjs +23 -3
- package/dist/core/purge.d.mts +8 -0
- package/dist/core/purge.mjs +91 -46
- package/dist/core/push-decide.mjs +26 -4
- package/dist/core/push.mjs +104 -86
- package/dist/core/receipts.d.mts +2 -2
- package/dist/core/receipts.mjs +28 -4
- package/dist/core/ref-index-job.mjs +10 -15
- package/dist/core/ref-index.d.mts +1 -0
- package/dist/core/ref-index.mjs +28 -8
- package/dist/core/ref-view.mjs +16 -11
- package/dist/core/refs.mjs +54 -21
- package/dist/core/registered-records.mjs +30 -0
- package/dist/core/registered-rows.d.mts +4 -0
- package/dist/core/registered-rows.mjs +53 -0
- package/dist/core/repack.d.mts +3 -2
- package/dist/core/repack.mjs +70 -120
- package/dist/core/repo-info.mjs +59 -25
- package/dist/core/repos.mjs +22 -16
- package/dist/core/rules/changes.mjs +2 -2
- package/dist/core/rules/check.mjs +7 -6
- package/dist/core/rules/commit-changes.mjs +1 -1
- package/dist/core/rules/context.d.mts +4 -5
- package/dist/core/rules/context.mjs +3 -4
- package/dist/core/rules/fetch.mjs +74 -21
- 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 +67 -9
- package/dist/core/seam.mjs +11 -3
- package/dist/core/still-takes.mjs +75 -0
- package/dist/core/tokens.mjs +5 -1
- package/dist/core/view.d.mts +2 -1
- package/dist/core/view.mjs +9 -10
- package/dist/core/work.mjs +6 -5
- package/dist/effect.d.mts +2 -2
- package/dist/effect.mjs +2 -2
- 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/merge-base-walk.d.mts +2 -2
- package/dist/engine/merge-base-walk.mjs +1 -1
- package/dist/engine/merge-renames.mjs +1 -1
- 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 +5 -4
- package/dist/extend.mjs +3 -2
- package/dist/http/answers.mjs +4 -3
- package/dist/http/core-parts.mjs +21 -13
- package/dist/http/handler.mjs +3 -3
- package/dist/http/node.d.mts +2 -23
- package/dist/http/parts.d.mts +2 -0
- package/dist/http/push-uploads.d.mts +10 -2
- package/dist/http/push-uploads.mjs +38 -39
- package/dist/http/receive-pack.mjs +8 -6
- package/dist/http/upload-pack.mjs +8 -7
- package/dist/index.d.mts +36 -19
- package/dist/index.mjs +14 -6
- package/dist/lfs/base.d.mts +32 -0
- package/dist/lfs/base.mjs +8 -0
- package/dist/lfs/calls.mjs +22 -12
- package/dist/lfs/layer.d.mts +28 -0
- package/dist/lfs/layer.mjs +65 -0
- package/dist/lfs/locks.mjs +16 -30
- package/dist/lfs/namespace.d.mts +2 -0
- package/dist/lfs/objects.d.mts +26 -6
- package/dist/lfs/objects.mjs +197 -98
- package/dist/lfs/pointers.mjs +8 -6
- package/dist/lfs/public.d.mts +5 -0
- package/dist/lfs/public.mjs +8 -0
- package/dist/lfs/purge.mjs +19 -25
- package/dist/lfs/rows.mjs +22 -10
- package/dist/lfs/service.d.mts +9 -4
- package/dist/lfs/service.mjs +3 -12
- package/dist/lfs/upkeep.mjs +45 -56
- package/dist/lfs/wire.mjs +1 -1
- package/dist/node.d.mts +3 -2
- package/dist/node.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/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/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 +5 -11
- package/dist/protocol/wire/advertisement.mjs +17 -13
- package/dist/protocol/wire/fetch.d.mts +1 -1
- package/dist/protocol/wire/fetch.mjs +1 -1
- package/dist/protocol/wire/lines.d.mts +14 -2
- package/dist/protocol/wire/lines.mjs +32 -21
- 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 +5 -16
- package/dist/protocol/wire/v2.mjs +17 -15
- package/dist/queue/advance.mjs +227 -112
- package/dist/queue/callers.mjs +56 -69
- package/dist/queue/calls.mjs +24 -13
- package/dist/queue/commit.mjs +20 -7
- package/dist/queue/host.d.mts +12 -13
- package/dist/queue/host.mjs +15 -7
- package/dist/queue/lanes.mjs +9 -18
- package/dist/queue/layer.d.mts +6 -4
- package/dist/queue/layer.mjs +17 -11
- package/dist/queue/limits.mjs +53 -11
- package/dist/queue/rows.mjs +19 -15
- package/dist/queue/schedule.mjs +6 -5
- package/dist/queue/search.mjs +8 -13
- package/dist/queue/state.mjs +26 -7
- package/dist/queue/steps.mjs +10 -4
- package/dist/queue/trim.mjs +289 -0
- package/dist/rest/api.d.mts +1 -1
- package/dist/rest/blobs.d.mts +35 -35
- package/dist/rest/caller.d.mts +22 -20
- package/dist/rest/client.mjs +6 -6
- package/dist/rest/commits.d.mts +274 -274
- 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 +78 -78
- package/dist/rest/forks.d.mts +170 -170
- package/dist/rest/handler.mjs +17 -8
- package/dist/rest/handlers.mjs +13 -7
- package/dist/rest/layer.d.mts +14 -0
- package/dist/rest/layer.mjs +53 -0
- package/dist/rest/listen.mjs +2 -2
- package/dist/rest/me.d.mts +18 -20
- package/dist/rest/me.mjs +1 -1
- package/dist/rest/merges.d.mts +10 -10
- package/dist/rest/namespace.d.mts +2 -0
- package/dist/rest/queue.d.mts +320 -320
- package/dist/rest/queue.mjs +1 -1
- package/dist/rest/refs.d.mts +207 -207
- package/dist/rest/refs.mjs +1 -1
- package/dist/rest/repos.d.mts +127 -127
- package/dist/rest/tags.d.mts +94 -94
- package/dist/rest/tokens.d.mts +248 -258
- package/dist/rest/tokens.mjs +10 -42
- package/dist/rest/topics.d.mts +154 -154
- package/dist/rest/topics.mjs +1 -1
- package/dist/rest/trees.d.mts +84 -84
- package/dist/rest/wire.d.mts +8 -4
- package/dist/rest/wire.mjs +3 -2
- package/dist/rest/work.d.mts +69 -69
- package/dist/rest/work.mjs +1 -1
- package/dist/server/check-fetch.mjs +9 -0
- package/dist/server/edge-node.d.mts +20 -0
- package/dist/server/edge-node.mjs +20 -0
- package/dist/server/edge.d.mts +10 -0
- package/dist/server/edge.mjs +23 -0
- package/dist/server/extension.mjs +3 -115
- package/dist/server/git-layer.d.mts +34 -6
- package/dist/server/git-layer.mjs +40 -18
- package/dist/server/git-namespace.d.mts +5 -4
- package/dist/server/git-namespace.mjs +10 -5
- package/dist/server/joined.d.mts +83 -0
- package/dist/server/joined.mjs +91 -0
- package/dist/server/registry.d.mts +9 -2
- package/dist/server/registry.mjs +179 -24
- package/dist/server/routes.mjs +2 -2
- package/dist/server/server.d.mts +11 -1
- package/dist/server/server.mjs +331 -201
- package/dist/server/uploads.d.mts +14 -0
- package/dist/server/uploads.mjs +15 -0
- package/dist/signin/context.d.mts +2 -1
- package/dist/signin/context.mjs +32 -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 +7 -8
- package/dist/storage/calls.mjs +17 -17
- package/dist/storage/clean-up.mjs +71 -34
- package/dist/storage/counted-bucket.mjs +34 -51
- package/dist/storage/fetch.mjs +1 -1
- package/dist/storage/host-bucket.mjs +17 -2
- package/dist/storage/index-build.d.mts +2 -2
- package/dist/storage/index-build.mjs +3 -3
- 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/layout.mjs +5 -0
- package/dist/storage/memory-budget.mjs +7 -1
- package/dist/storage/merge-cut.mjs +24 -1
- package/dist/storage/merge-fence.mjs +1 -1
- package/dist/storage/merge-plan.mjs +5 -2
- package/dist/storage/merge-row.mjs +1 -1
- package/dist/storage/merge-stream.mjs +16 -7
- 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 +3 -3
- 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 +7 -9
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +45 -52
- 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 +49 -14
- package/dist/storage/push-uploads.mjs +16 -18
- package/dist/storage/quarantine.d.mts +2 -2
- package/dist/storage/quarantine.mjs +51 -12
- package/dist/storage/ready.d.mts +2 -2
- package/dist/storage/ready.mjs +3 -3
- package/dist/storage/receive-bounds.d.mts +1 -1
- 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 +1 -1
- package/dist/storage/receive-steps.mjs +1 -1
- package/dist/storage/repack-contained.mjs +2 -2
- package/dist/storage/repack-job.d.mts +2 -2
- package/dist/storage/repack-job.mjs +11 -17
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/repack.mjs +9 -3
- package/dist/storage/rows.d.mts +2 -2
- package/dist/storage/rows.mjs +43 -4
- 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 +1 -1
- package/dist/store/call-count.d.mts +1 -1
- package/dist/store/call-count.mjs +125 -34
- 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 +130 -0
- package/dist/store/list-job.mjs +22 -16
- package/dist/store/outbox.d.mts +2 -2
- package/dist/store/outbox.mjs +112 -27
- package/dist/store/promises.d.mts +8 -3
- package/dist/store/promises.mjs +104 -94
- package/dist/store/queue-jobs.mjs +23 -2
- package/dist/store/records.d.mts +2 -2
- package/dist/store/records.mjs +16 -24
- package/dist/store/ref-rows.d.mts +2 -2
- package/dist/store/ref-rows.mjs +6 -6
- package/dist/store/reservations.mjs +35 -8
- package/dist/store/scopes.mjs +6 -14
- 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/bridge.d.mts +6 -0
- package/dist/sync/bridge.mjs +29 -0
- 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 +17 -18
- package/dist/sync/layer.d.mts +9 -0
- package/dist/sync/layer.mjs +68 -0
- package/dist/sync/mirror.mjs +138 -59
- package/dist/sync/publish.mjs +15 -13
- package/dist/sync/step.mjs +221 -79
- 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 +205 -90
- 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 +1 -1
- 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 -213
- package/dist/core/hooks/pre-receive.d.mts +0 -12
- package/dist/core/hooks/pre-receive.mjs +0 -36
- package/dist/lfs/repo.mjs +0 -42
- package/dist/server/extension.d.mts +0 -21
- package/dist/storage/promise-calls.mjs +0 -29
- 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/topics/advance.mjs
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
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 { CoreParts, overStore } from "../core/parts.mjs";
|
|
13
|
-
import { LostTry, defineJob } from "@ref0/infra";
|
|
14
|
-
import * as Schema from "effect/Schema";
|
|
15
|
-
import * as Effect from "effect/Effect";
|
|
16
|
-
import * as Predicate from "effect/Predicate";
|
|
15
|
+
import { CoreParts, QueueParts, overStore } from "../core/parts.mjs";
|
|
17
16
|
import * as Clock$1 from "effect/Clock";
|
|
17
|
+
import * as Effect from "effect/Effect";
|
|
18
18
|
import * as Result from "effect/Result";
|
|
19
|
+
import { CurrentJob, Job, LostTry } from "@ref0/infra";
|
|
20
|
+
import * as Predicate from "effect/Predicate";
|
|
21
|
+
import * as Context from "effect/Context";
|
|
19
22
|
// src/topics/advance.ts
|
|
20
23
|
/**
|
|
21
|
-
* `
|
|
24
|
+
* `topics.advance`, one step at a time, each one commit in one scope, read again before the
|
|
22
25
|
* next: so a crash between any two leaves a topic its next run goes on from.
|
|
23
26
|
*
|
|
24
27
|
* - **Before the decision** (`reserving`, `checking`): it adds the members' entries and reserves
|
|
@@ -42,10 +45,11 @@ const tries = 10;
|
|
|
42
45
|
* Every failed try runs again, 1 second doubling to 5 minutes, so the job is never failed: a topic
|
|
43
46
|
* still open fails once it's out of tries and lets go; one decided only rolls forward.
|
|
44
47
|
*/
|
|
45
|
-
const retry = (failure) => Math.min(1e3 * 2 ** (failure.attempt - 1), 3e5);
|
|
46
48
|
/**
|
|
47
49
|
* 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.
|
|
50
|
+
* own jobs ask `authorize` for an entry's actor. They're its whole caller: no token or grant
|
|
51
|
+
* reaches `topic.add`, which is in no scope's ceiling (`auth/authorize.ts`' `ceilings`) and names
|
|
52
|
+
* no repo for one to cover, so none was there to save.
|
|
49
53
|
*/
|
|
50
54
|
const callerOf = (row) => {
|
|
51
55
|
const caller = {
|
|
@@ -68,9 +72,8 @@ const inOrder = (members) => [...members].sort((a, b) => {
|
|
|
68
72
|
* what it held. Answers whether it committed.
|
|
69
73
|
*/
|
|
70
74
|
const block = /* @__PURE__ */ Effect.fnUntraced(function* (read, failure, row = read.row, more = []) {
|
|
71
|
-
const { waitingOn: _waited, ...rest } = row;
|
|
72
75
|
const next = {
|
|
73
|
-
...
|
|
76
|
+
...unwaited(row),
|
|
74
77
|
state: "failed",
|
|
75
78
|
failure
|
|
76
79
|
};
|
|
@@ -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(", ");
|
|
@@ -232,23 +290,20 @@ const beforeDecision = /* @__PURE__ */ Effect.fnUntraced(function* (host, read)
|
|
|
232
290
|
if (row.state === "reserving") {
|
|
233
291
|
for (const member of inOrder(row.members)) {
|
|
234
292
|
const reserved = yield* reserveMember(member, { topic: read.id });
|
|
235
|
-
if (reserved.held && row.heldSince
|
|
293
|
+
if (reserved.held && row.heldSince !== void 0) continue;
|
|
294
|
+
if (reserved.held) return yield* heldFrom(read, reserved.since);
|
|
295
|
+
if (!sameWait(reserved.waiting, row.waitingOn)) {
|
|
296
|
+
const since = row.heldSince === void 0 ? { waitingSince: row.waitingSince ?? now } : {};
|
|
236
297
|
yield* commitTopic(read, {
|
|
237
298
|
...row,
|
|
238
|
-
|
|
299
|
+
waitingOn: reserved.waiting,
|
|
300
|
+
...since
|
|
239
301
|
});
|
|
240
|
-
return "again";
|
|
241
302
|
}
|
|
242
|
-
if (reserved.held) continue;
|
|
243
|
-
if (!sameWait(reserved.waiting, row.waitingOn)) yield* commitTopic(read, {
|
|
244
|
-
...row,
|
|
245
|
-
waitingOn: reserved.waiting
|
|
246
|
-
});
|
|
247
303
|
return "waits";
|
|
248
304
|
}
|
|
249
|
-
const { waitingOn: _waited, ...rest } = row;
|
|
250
305
|
yield* commitTopic(read, {
|
|
251
|
-
...
|
|
306
|
+
...unwaited(row),
|
|
252
307
|
state: "checking"
|
|
253
308
|
});
|
|
254
309
|
return "again";
|
|
@@ -289,7 +344,8 @@ const beforeDecision = /* @__PURE__ */ Effect.fnUntraced(function* (host, read)
|
|
|
289
344
|
}
|
|
290
345
|
const set = currentSet(row);
|
|
291
346
|
if (set === void 0 || !candidates.every((at) => at.passed === true)) return "waits";
|
|
292
|
-
|
|
347
|
+
const held = yield* Effect.forEach(row.members, (member) => memberRead(member));
|
|
348
|
+
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
349
|
const required = yield* requiredOf(host, read);
|
|
294
350
|
if (required === void 0) return "again";
|
|
295
351
|
if (required) {
|
|
@@ -297,16 +353,54 @@ const beforeDecision = /* @__PURE__ */ Effect.fnUntraced(function* (host, read)
|
|
|
297
353
|
if (report?.set !== set || report.verdict !== "pass") return "waits";
|
|
298
354
|
}
|
|
299
355
|
if (host.prepare !== void 0 && row.prepared !== set) {
|
|
300
|
-
if (row.asked
|
|
301
|
-
|
|
356
|
+
if (row.asked !== set) {
|
|
357
|
+
const ids = candidates.map(({ candidate }) => candidate);
|
|
358
|
+
yield* commitTopic(read, {
|
|
359
|
+
...row,
|
|
360
|
+
asked: set
|
|
361
|
+
}, [], [prepareRow(set, ids)]);
|
|
362
|
+
return "again";
|
|
363
|
+
}
|
|
364
|
+
if (yield* prepareFailedFor(read.id, set)) yield* block(read, { reason: "work-failed" });
|
|
365
|
+
return "waits";
|
|
366
|
+
}
|
|
367
|
+
const from = row.preflight?.set === set ? row.preflight.through : 0;
|
|
368
|
+
const page = row.members.slice(from, from + 200);
|
|
369
|
+
for (const [offset, member] of page.entries()) {
|
|
370
|
+
const at = held[from + offset];
|
|
371
|
+
const candidate = candidates[from + offset];
|
|
372
|
+
const open = at?.candidate;
|
|
373
|
+
if (at === void 0 || open === void 0 || candidate === void 0) return "waits";
|
|
374
|
+
const refused = yield* checkPublish(at.state, open, candidate.commit, signal);
|
|
375
|
+
if (refused === void 0) continue;
|
|
376
|
+
const { repo, entry } = member;
|
|
377
|
+
const named = entry === void 0 ? { repo } : {
|
|
378
|
+
repo,
|
|
379
|
+
entry
|
|
380
|
+
};
|
|
381
|
+
const summary = refused.error.message;
|
|
382
|
+
yield* block(read, {
|
|
383
|
+
reason: "refused",
|
|
384
|
+
...named,
|
|
385
|
+
candidate: candidate.candidate,
|
|
386
|
+
summary
|
|
387
|
+
});
|
|
388
|
+
return "again";
|
|
389
|
+
}
|
|
390
|
+
const through = from + page.length;
|
|
391
|
+
if (through < row.members.length) {
|
|
302
392
|
yield* commitTopic(read, {
|
|
303
393
|
...row,
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
394
|
+
preflight: {
|
|
395
|
+
set,
|
|
396
|
+
through
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
return "more";
|
|
307
400
|
}
|
|
401
|
+
const { preflight: _preflight, ...checked } = row;
|
|
308
402
|
yield* commitTopic(read, {
|
|
309
|
-
...
|
|
403
|
+
...checked,
|
|
310
404
|
state: "publishing",
|
|
311
405
|
decided: set
|
|
312
406
|
});
|
|
@@ -315,12 +409,16 @@ const beforeDecision = /* @__PURE__ */ Effect.fnUntraced(function* (host, read)
|
|
|
315
409
|
/** A step after the publish decision: every member's queue woken, till each merged. */
|
|
316
410
|
const afterDecision = /* @__PURE__ */ Effect.fnUntraced(function* (read) {
|
|
317
411
|
const { row } = read;
|
|
318
|
-
const { store } = yield* CoreParts;
|
|
319
412
|
const reads = yield* Effect.forEach(row.members, (member) => memberRead(member));
|
|
320
413
|
const merged = [];
|
|
414
|
+
let refused;
|
|
321
415
|
for (const [index, member] of row.members.entries()) {
|
|
322
416
|
const at = reads[index];
|
|
323
417
|
const candidate = row.candidates[index];
|
|
418
|
+
if (at?.entry?.state === "failed") {
|
|
419
|
+
refused ??= member;
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
324
422
|
if ((at === void 0 || at.entry?.state === "merged") && member.entry !== void 0 && candidate !== void 0) {
|
|
325
423
|
const { repo, target } = member;
|
|
326
424
|
const { candidate: id, commit } = candidate;
|
|
@@ -335,7 +433,22 @@ const afterDecision = /* @__PURE__ */ Effect.fnUntraced(function* (read) {
|
|
|
335
433
|
continue;
|
|
336
434
|
}
|
|
337
435
|
const jobs = [advanceRow(member.target)];
|
|
338
|
-
yield* storeCall(()
|
|
436
|
+
yield* storeCall((yield* TopicsHost).queue.records.add(repoScope(member.internalId), { jobs }));
|
|
437
|
+
}
|
|
438
|
+
if (refused !== void 0) {
|
|
439
|
+
const { repo, entry } = refused;
|
|
440
|
+
const named = entry === void 0 ? { repo } : {
|
|
441
|
+
repo,
|
|
442
|
+
entry
|
|
443
|
+
};
|
|
444
|
+
const published = merged.map((one) => one.repo).join(", ");
|
|
445
|
+
const summary = `${repo}'s publish was refused, after ${published === "" ? "no member" : published} published`;
|
|
446
|
+
yield* block(read, {
|
|
447
|
+
reason: "refused",
|
|
448
|
+
...named,
|
|
449
|
+
summary
|
|
450
|
+
});
|
|
451
|
+
return "again";
|
|
339
452
|
}
|
|
340
453
|
if (merged.length < row.members.length) return "waits";
|
|
341
454
|
const event = {
|
|
@@ -355,12 +468,12 @@ const afterDecision = /* @__PURE__ */ Effect.fnUntraced(function* (read) {
|
|
|
355
468
|
}]);
|
|
356
469
|
return "again";
|
|
357
470
|
});
|
|
358
|
-
/** One step of `
|
|
359
|
-
const advanceStep = /* @__PURE__ */ Effect.fnUntraced(function* (host, id) {
|
|
471
|
+
/** One step of `topics.advance` for `id`. */
|
|
472
|
+
const advanceStep = /* @__PURE__ */ Effect.fnUntraced(function* (host, id, signal) {
|
|
360
473
|
const read = yield* readTopic(id);
|
|
361
474
|
const { row } = read;
|
|
362
475
|
if (row === void 0) return "done";
|
|
363
|
-
yield* projectTopic((yield*
|
|
476
|
+
yield* projectTopic((yield* TopicsHost).records, id, row);
|
|
364
477
|
const own = {
|
|
365
478
|
...read,
|
|
366
479
|
row
|
|
@@ -371,7 +484,7 @@ const advanceStep = /* @__PURE__ */ Effect.fnUntraced(function* (host, id) {
|
|
|
371
484
|
}
|
|
372
485
|
if (row.state !== "checking" && row.state !== "reserving" && row.state !== "publishing") return "done";
|
|
373
486
|
if (row.state === "publishing") return yield* afterDecision(own);
|
|
374
|
-
return yield* beforeDecision(host, own);
|
|
487
|
+
return yield* beforeDecision(host, own, signal);
|
|
375
488
|
});
|
|
376
489
|
/** Whether a claim of the topic's job, its `attempt`, comes after `tries` failed in a row. */
|
|
377
490
|
const outOfTries = (attempt) => attempt > tries;
|
|
@@ -385,7 +498,7 @@ const workFailedOf = (id, row, job) => ({
|
|
|
385
498
|
name: job.name,
|
|
386
499
|
attempts: job.attempt - 1
|
|
387
500
|
});
|
|
388
|
-
/** How many steps one try of `
|
|
501
|
+
/** How many steps one try of `topics.advance` takes before it asks for more. */
|
|
389
502
|
const stepsPerTry = 20;
|
|
390
503
|
const advance = /* @__PURE__ */ Effect.fnUntraced(function* (host, job) {
|
|
391
504
|
const id = topicIdOf(job);
|
|
@@ -401,7 +514,7 @@ const advance = /* @__PURE__ */ Effect.fnUntraced(function* (host, job) {
|
|
|
401
514
|
} else if (row?.state === "publishing" && saysFailed(job.attempt)) yield* commitTopic(read, row, [workFailedOf(id, row, job)]);
|
|
402
515
|
}
|
|
403
516
|
for (let step = 0; step < stepsPerTry; step += 1) {
|
|
404
|
-
const did = yield* advanceStep(host, id);
|
|
517
|
+
const did = yield* advanceStep(host, id, job.signal);
|
|
405
518
|
if (did === "done") return void 0;
|
|
406
519
|
if (did === "more") return { kind: "more" };
|
|
407
520
|
if (did === "waits") return {
|
|
@@ -449,12 +562,12 @@ const saveAnswer = /* @__PURE__ */ Effect.fnUntraced(function* (id, candidates,
|
|
|
449
562
|
return false;
|
|
450
563
|
});
|
|
451
564
|
/**
|
|
452
|
-
* `
|
|
565
|
+
* `topics.prepare`: the host's `prepare` for the exact set, while every reservation holds. An
|
|
453
566
|
* accept saves it, so the topic decides; a reject fails it `prepare-rejected`, and a throw or a
|
|
454
567
|
* timeout `host-error` at once, as the queue's `merge` throw fails its entry (Q648). An answer the
|
|
455
568
|
* topic couldn't take yet stays with the job, which saves it later without asking again.
|
|
456
569
|
*/
|
|
457
|
-
const prepareStep = /* @__PURE__ */ Effect.fnUntraced(function* (host, job
|
|
570
|
+
const prepareStep = /* @__PURE__ */ Effect.fnUntraced(function* (host, job) {
|
|
458
571
|
const { prepare } = host;
|
|
459
572
|
const id = topicIdOf(job);
|
|
460
573
|
const { candidates } = job.data;
|
|
@@ -478,11 +591,7 @@ const prepareStep = /* @__PURE__ */ Effect.fnUntraced(function* (host, job, sign
|
|
|
478
591
|
attempt: job.attempt
|
|
479
592
|
};
|
|
480
593
|
const { reports } = (yield* CoreParts).checks;
|
|
481
|
-
const
|
|
482
|
-
...input,
|
|
483
|
-
signal: AbortSignal.any([own, signal])
|
|
484
|
-
});
|
|
485
|
-
const answered = yield* hostCall(reports, "topics.prepare", {}, call, { timeout: prepare.timeout }).pipe(Effect.result);
|
|
594
|
+
const answered = yield* hostEffect(reports, "topics.prepare", {}, Effect.suspend(() => prepare.handler(input)), { timeout: prepare.timeout }).pipe(Effect.result);
|
|
486
595
|
answer = Result.isFailure(answered) ? {
|
|
487
596
|
kind: "failed",
|
|
488
597
|
failure: hostError(answered.failure)
|
|
@@ -503,7 +612,7 @@ const rejected = (answer) => ({
|
|
|
503
612
|
summary: answer.message
|
|
504
613
|
});
|
|
505
614
|
/**
|
|
506
|
-
* `
|
|
615
|
+
* `topics.report-timeout`: fails the topic `report-timeout` when its exact set, still current
|
|
507
616
|
* before its decision, has no report by `report.timeout` (Q647).
|
|
508
617
|
*/
|
|
509
618
|
const reportTimeoutStep = /* @__PURE__ */ Effect.fnUntraced(function* (host, job) {
|
|
@@ -519,54 +628,60 @@ const reportTimeoutStep = /* @__PURE__ */ Effect.fnUntraced(function* (host, job
|
|
|
519
628
|
})) return;
|
|
520
629
|
}
|
|
521
630
|
});
|
|
631
|
+
/** Each failure retries indefinitely, capped at five minutes, as before the job move. */
|
|
632
|
+
const topicRetry = (failure) => Math.min(1e3 * 2 ** (failure.attempt - 1), 3e5);
|
|
522
633
|
/**
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
* `Authorize` the server's.
|
|
634
|
+
* Each try and onFailure builds its store inside the try. The core's repo calls use CurrentJob's
|
|
635
|
+
* fenced store; registration.records reads the same fiber's Fence for writes to the topic's own scopes.
|
|
526
636
|
*/
|
|
527
|
-
const overCore =
|
|
637
|
+
const overCore = /* @__PURE__ */ Effect.fnUntraced(function* (host, data, step) {
|
|
638
|
+
const job = yield* CurrentJob.current;
|
|
639
|
+
const store = yield* CurrentJob.store;
|
|
640
|
+
const signal = yield* CurrentJob.signal;
|
|
641
|
+
const current = yield* Effect.context();
|
|
642
|
+
const needs = Context.add(Context.merge(host.queue.needs, current), TopicsHost, host);
|
|
643
|
+
return yield* untilAborted(Effect.provideContext(overStore(store)(step({
|
|
644
|
+
...job,
|
|
645
|
+
data,
|
|
646
|
+
signal
|
|
647
|
+
})), needs), signal);
|
|
648
|
+
});
|
|
528
649
|
/**
|
|
529
|
-
* A
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
* the try's fenced store, until `onFailure`'s own minute aborts its signal.
|
|
650
|
+
* A prepare try's last failure releases its targets, without asking the host again: only while
|
|
651
|
+
* its own set is the one asked for and not yet prepared, so an older set's failure fails no newer
|
|
652
|
+
* set, which has its own job.
|
|
533
653
|
*/
|
|
534
|
-
const prepareFailed = (host) =>
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
const read = yield* readTopic(
|
|
654
|
+
const prepareFailed = (host, data) => overCore(host, data, (job) => Effect.gen(function* () {
|
|
655
|
+
const set = setKeyOf(job.data.candidates.map((candidate) => ({ candidate })));
|
|
656
|
+
for (let tried = 0; tried < commitTries; tried += 1) if (yield* Effect.gen(function* () {
|
|
657
|
+
const read = yield* readTopic(topicIdOf(job));
|
|
538
658
|
const { row } = read;
|
|
539
|
-
|
|
659
|
+
if (!(row?.state === "checking" || row?.state === "reserving") || row.asked !== set || row.prepared === set) return true;
|
|
660
|
+
return yield* block({
|
|
540
661
|
...read,
|
|
541
662
|
row
|
|
542
|
-
}, { reason: "work-failed" })
|
|
663
|
+
}, { reason: "work-failed" });
|
|
664
|
+
}).pipe(Effect.orElseSucceed(() => false))) return;
|
|
665
|
+
}));
|
|
666
|
+
const AdvanceJob = /* @__PURE__ */ Job.make(topicAdvanceName, {
|
|
667
|
+
payload: TopicAdvanceData,
|
|
668
|
+
retry: topicRetry
|
|
669
|
+
});
|
|
670
|
+
const ReportTimeoutJob = /* @__PURE__ */ Job.make(reportTimeoutName, {
|
|
671
|
+
payload: CandidateSetData,
|
|
672
|
+
retry: topicRetry
|
|
673
|
+
});
|
|
674
|
+
/** Topics' three jobs, registered by their own registration. */
|
|
675
|
+
const topicJobs = (host) => {
|
|
676
|
+
const PrepareJob = Job.make(prepareName, {
|
|
677
|
+
payload: PrepareData,
|
|
678
|
+
retry: (failure) => failure.error instanceof LostTry ? 0 : false,
|
|
679
|
+
timeout: (host.prepare?.timeout ?? 0) + saveMargin
|
|
543
680
|
});
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
681
|
+
return [
|
|
682
|
+
gitJob(AdvanceJob, (data) => overCore(host, data, (job) => advance(host, job))),
|
|
683
|
+
gitJob(PrepareJob, (data) => overCore(host, data, (job) => prepareStep(host, job)), { onFailure: (data) => prepareFailed(host, data) }),
|
|
684
|
+
gitJob(ReportTimeoutJob, (data) => overCore(host, data, (job) => reportTimeoutStep(host, job)))
|
|
685
|
+
];
|
|
548
686
|
};
|
|
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
687
|
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;
|