@ref0/git 0.6.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 +28 -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 +4 -5
- package/dist/auth/fences.d.mts +1 -1
- package/dist/auth/host-function.mjs +17 -8
- 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 +5 -5
- 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 +4 -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 +18 -10
- 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 +7 -4
- 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 +33 -22
- package/dist/contracts/events.mjs +13 -4
- 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 +93 -42
- package/dist/contracts/git.mjs +6 -5
- package/dist/contracts/ids.d.mts +16 -0
- package/dist/contracts/ids.mjs +19 -4
- package/dist/contracts/lfs.d.mts +2 -0
- package/dist/contracts/namespaces.d.mts +2 -2
- package/dist/contracts/objects.d.mts +1 -1
- package/dist/contracts/opaque.mjs +9 -0
- package/dist/contracts/operations.d.mts +293 -100
- 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 +218 -47
- 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 +46 -31
- package/dist/contracts/result.mjs +43 -16
- package/dist/contracts/rules.d.mts +50 -44
- package/dist/contracts/rules.mjs +5 -1
- package/dist/contracts/server.d.mts +282 -198
- 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 +2 -2
- package/dist/contracts/work.mjs +2 -2
- package/dist/core/access.d.mts +10 -10
- package/dist/core/access.mjs +31 -8
- package/dist/core/clock.mjs +1 -1
- package/dist/core/events/deliver.d.mts +3 -2
- package/dist/core/events/deliver.mjs +170 -92
- package/dist/core/forks.mjs +49 -24
- 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 +11 -8
- 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 +22 -3
- package/dist/core/parts.mjs +5 -3
- package/dist/core/promise.mjs +23 -3
- package/dist/core/purge.d.mts +2 -2
- package/dist/core/purge.mjs +80 -30
- package/dist/core/push.mjs +55 -74
- 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 +2 -2
- 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 +11 -9
- package/dist/core/repo-info.mjs +59 -25
- package/dist/core/repos.mjs +17 -11
- package/dist/core/rules/changes.mjs +2 -2
- 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 +12 -1
- package/dist/core/seam.mjs +4 -2
- package/dist/core/tokens.mjs +5 -1
- 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 -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 +3 -3
- package/dist/extend.mjs +3 -2
- package/dist/http/answers.mjs +4 -3
- package/dist/http/core-parts.mjs +2 -2
- package/dist/http/handler.mjs +1 -1
- package/dist/http/parts.d.mts +1 -0
- 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 +33 -20
- package/dist/index.mjs +13 -7
- package/dist/lfs/base.d.mts +2 -2
- package/dist/lfs/calls.mjs +3 -2
- package/dist/lfs/layer.d.mts +5 -4
- package/dist/lfs/layer.mjs +17 -16
- package/dist/lfs/locks.mjs +3 -3
- package/dist/lfs/objects.d.mts +3 -2
- package/dist/lfs/objects.mjs +149 -34
- package/dist/lfs/pointers.mjs +1 -1
- package/dist/lfs/purge.mjs +1 -1
- package/dist/lfs/rows.mjs +1 -1
- package/dist/lfs/upkeep.mjs +13 -9
- 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/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 +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 +155 -63
- package/dist/queue/callers.mjs +56 -69
- package/dist/queue/calls.mjs +20 -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 +5 -10
- package/dist/queue/schedule.mjs +6 -5
- package/dist/queue/search.mjs +8 -13
- 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.mjs +6 -6
- package/dist/rest/commits.d.mts +335 -335
- 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 +30 -30
- package/dist/rest/forks.d.mts +150 -150
- package/dist/rest/handler.mjs +4 -3
- package/dist/rest/handlers.mjs +13 -7
- package/dist/rest/layer.d.mts +3 -3
- package/dist/rest/layer.mjs +8 -7
- 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/queue.d.mts +140 -140
- package/dist/rest/queue.mjs +1 -1
- package/dist/rest/refs.d.mts +95 -95
- package/dist/rest/refs.mjs +1 -1
- package/dist/rest/repos.d.mts +127 -127
- 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 +63 -63
- package/dist/rest/topics.mjs +1 -1
- package/dist/rest/trees.d.mts +106 -106
- package/dist/rest/wire.d.mts +6 -4
- package/dist/rest/wire.mjs +4 -3
- 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/extension.mjs +3 -115
- package/dist/server/git-layer.d.mts +20 -3
- package/dist/server/git-layer.mjs +30 -19
- 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/routes.mjs +2 -2
- package/dist/server/server.d.mts +9 -2
- package/dist/server/server.mjs +279 -191
- 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 +1 -1
- package/dist/storage/calls.mjs +4 -4
- package/dist/storage/clean-up.mjs +12 -5
- package/dist/storage/counted-bucket.mjs +34 -51
- package/dist/storage/fetch.mjs +1 -1
- package/dist/storage/host-bucket.mjs +1 -1
- 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/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 +4 -2
- package/dist/storage/quarantine.d.mts +2 -2
- package/dist/storage/ready.d.mts +2 -2
- package/dist/storage/ready.mjs +3 -3
- 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 +5 -4
- 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 +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 +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 +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 +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 -4
- 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 +137 -58
- package/dist/sync/publish.mjs +3 -6
- package/dist/sync/step.mjs +217 -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 -216
- package/dist/core/hooks/pre-receive.d.mts +0 -12
- package/dist/core/hooks/pre-receive.mjs +0 -36
- package/dist/server/extension.d.mts +0 -21
- 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/core/push.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import { gitObjectOf, objectOfRow, receivedRows } from "../storage/object-rows.m
|
|
|
14
14
|
import { pruneClearedKey } from "../storage/prune.mjs";
|
|
15
15
|
import { abandonOwn } from "../storage/quarantine.mjs";
|
|
16
16
|
import { QuarantineRow, decodeHeld } from "../storage/rows.mjs";
|
|
17
|
-
import { bestEffort, decodeRow, storeCall } from "../store/errors.mjs";
|
|
17
|
+
import { bestEffort, decodeRow, fromInfra, storeCall } from "../store/errors.mjs";
|
|
18
18
|
import { callScope } from "../store/call-count.mjs";
|
|
19
19
|
import { decodePacks, gitStore } from "../store/git-store.mjs";
|
|
20
20
|
import { WholeRepo, refBytesOf, storesPeel, wholeRefs } from "../store/ref-rows.mjs";
|
|
@@ -23,7 +23,8 @@ import { sliceOf } from "../protocol/wire/push-limits.mjs";
|
|
|
23
23
|
import { pushCounts } from "./events/seen.mjs";
|
|
24
24
|
import { refViewIn } from "./ref-view.mjs";
|
|
25
25
|
import { appendEvents, decodeOutbox, firstSeq, outboxReads, repoEnvelope } from "../store/outbox.mjs";
|
|
26
|
-
import { MirrorRow
|
|
26
|
+
import { MirrorRow } from "./mirror-rows.mjs";
|
|
27
|
+
import { PrunedMark, mirrorJobName } from "../store/records.mjs";
|
|
27
28
|
import { decodeTimes, readRecord, repoStats, timeRow } from "../store/repo-record.mjs";
|
|
28
29
|
import { advanceRow } from "../store/queue-jobs.mjs";
|
|
29
30
|
import { liveReservations, reservedTarget } from "../store/reservations.mjs";
|
|
@@ -31,8 +32,8 @@ import { settleName } from "../store/settle.mjs";
|
|
|
31
32
|
import { collections, newChangeId, prunedKey, pushedKey, pushedUnder, reachedKey, repoScope } from "../store/scopes.mjs";
|
|
32
33
|
import { headOf, indexJobs, openKeyed, openRepo, refIndexJobs, repoAccess } from "./access.mjs";
|
|
33
34
|
import { kindsOf } from "./ancestry.mjs";
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
35
|
+
import { isRefName } from "./names.mjs";
|
|
36
|
+
import { runHookGroups } from "./hooks/groups.mjs";
|
|
36
37
|
import { Changes } from "./changes.mjs";
|
|
37
38
|
import { batchOf, readerOf } from "./rules/changes.mjs";
|
|
38
39
|
import { commitChangesOf, coveredTips } from "./rules/commit-changes.mjs";
|
|
@@ -49,11 +50,11 @@ import { peeledAll, peeledOf } from "../storage/wants.mjs";
|
|
|
49
50
|
import { CoreParts, ObjectsParts } from "./parts.mjs";
|
|
50
51
|
import { Authorize, check } from "../contracts/authorize.mjs";
|
|
51
52
|
import { read } from "./objects/objects.mjs";
|
|
52
|
-
import { checkWrites } from "@ref0/infra";
|
|
53
|
-
import * as Effect from "effect/Effect";
|
|
54
53
|
import * as Clock$1 from "effect/Clock";
|
|
55
|
-
import * as
|
|
54
|
+
import * as Effect from "effect/Effect";
|
|
56
55
|
import * as Exit from "effect/Exit";
|
|
56
|
+
import * as Result from "effect/Result";
|
|
57
|
+
import { checkWrites } from "@ref0/infra";
|
|
57
58
|
import * as Equal from "effect/Equal";
|
|
58
59
|
// src/core/push.ts
|
|
59
60
|
/**
|
|
@@ -194,12 +195,12 @@ const markOf = (rows) => {
|
|
|
194
195
|
const firstRead = (caller, operation, internalId) => openRepo(caller, {
|
|
195
196
|
kind: "read",
|
|
196
197
|
repo: operation.repo
|
|
197
|
-
}, [packsRead, prunedKey], internalId);
|
|
198
|
+
}, [packsRead, prunedKey], internalId, "skip");
|
|
198
199
|
/** `firstRead` for a keyed push: `undefined` once `missed`'s repo moved, as `openKeyed` says. */
|
|
199
200
|
const keyedRead = (caller, operation, missed, internalId) => openKeyed(caller, {
|
|
200
201
|
kind: "read",
|
|
201
202
|
repo: operation.repo
|
|
202
|
-
}, [packsRead, prunedKey], missed, internalId);
|
|
203
|
+
}, [packsRead, prunedKey], missed, internalId, "skip");
|
|
203
204
|
/**
|
|
204
205
|
* The first read's repo once `authorize` lets the caller push to it: its list, for the pack to be
|
|
205
206
|
* received against, its default branch, whose move rebuilds the ready shallow pack, and its
|
|
@@ -294,8 +295,8 @@ const activeMirrors = /* @__PURE__ */ Effect.fnUntraced(function* (rows) {
|
|
|
294
295
|
return active;
|
|
295
296
|
});
|
|
296
297
|
/**
|
|
297
|
-
* `
|
|
298
|
-
* name among the jobs the server knows: none until `
|
|
298
|
+
* `sync.mirror`'s row for each ref the commit moves that an active mirror names, found by
|
|
299
|
+
* name among the jobs the server knows: none until `Sync.layer` has bound them.
|
|
299
300
|
*/
|
|
300
301
|
const mirrorJobs = (core, moved, mirrored) => {
|
|
301
302
|
const definition = core.jobOf?.(mirrorJobName);
|
|
@@ -400,9 +401,9 @@ const buildFence = (build) => [
|
|
|
400
401
|
/**
|
|
401
402
|
* The decide's read, one of the repo's scope: its refs, its outbox, the push's own `quarantine` row
|
|
402
403
|
* if it has one, its key's receipt if it has a key, the mirror of each ref in `touched`, the
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
* does a write with the same key that commits first. A prune that dropped objects since the first
|
|
404
|
+
* reservation row of each branch in `branches`, there while a queue targets it, with the live
|
|
405
|
+
* reservation each holds, and the caller's grant fence, checked on what it read. A revoke after it
|
|
406
|
+
* moves the version, as does a write with the same key that commits first. A prune that dropped objects since the first
|
|
406
407
|
* read moved the `pruned` mark: the push may name one it dropped, so unless its key's receipt
|
|
407
408
|
* answers, it fails, to be sent again (Q270). `changed`: whether a row of a build's fence,
|
|
408
409
|
* `unchanged`, holds another value than its plan read.
|
|
@@ -411,7 +412,7 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
|
|
|
411
412
|
const own = received?.quarantine === void 0 ? [] : [received.quarantine];
|
|
412
413
|
const keyed = receiptReads(kept);
|
|
413
414
|
const targets = branches.map((id) => ({
|
|
414
|
-
collection: collections.
|
|
415
|
+
collection: collections.queueReservations,
|
|
415
416
|
id
|
|
416
417
|
}));
|
|
417
418
|
const linkedRows = received?.linked?.rows ?? [];
|
|
@@ -521,11 +522,11 @@ const settingsOf = (record) => ({
|
|
|
521
522
|
public: record.public,
|
|
522
523
|
defaultBranch: record.defaultBranch
|
|
523
524
|
});
|
|
524
|
-
/** The rules, then
|
|
525
|
+
/** The rules, the registrations' checks, then the hook groups, once, at the first read the push decides on. */
|
|
525
526
|
const runChecks = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input, facts) {
|
|
526
527
|
const context = checking(input);
|
|
527
|
-
const ruled = yield*
|
|
528
|
-
const whole = yield*
|
|
528
|
+
const ruled = yield* registeredAfter(checks, input, yield* runPushRules(checks, input, context));
|
|
529
|
+
const whole = yield* runHookGroups(checks.reports, checks.groups?.() ?? [], context, {
|
|
529
530
|
atomic: input.atomic,
|
|
530
531
|
updates: ruled.updates,
|
|
531
532
|
refused: ruled.refused
|
|
@@ -580,12 +581,12 @@ const checkAll = /* @__PURE__ */ Effect.fnUntraced(function* (checks, request, i
|
|
|
580
581
|
};
|
|
581
582
|
});
|
|
582
583
|
/**
|
|
583
|
-
* The rules' answer, with the refs the
|
|
584
|
-
* then
|
|
584
|
+
* The rules' answer, with the refs the registered checks refuse among the rest: each in turn, by band
|
|
585
|
+
* then registration name, on the refs none before it refused, so a ref's first refusal is its answer.
|
|
585
586
|
*/
|
|
586
|
-
const
|
|
587
|
+
const registeredAfter = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input, ruled) {
|
|
587
588
|
const refused = new Map(ruled.refused);
|
|
588
|
-
for (const { handler } of checks.
|
|
589
|
+
for (const { handler } of checks.registered?.() ?? []) {
|
|
589
590
|
const updates = ruled.updates.filter((update) => !refused.has(update.ref));
|
|
590
591
|
if (updates.length === 0) break;
|
|
591
592
|
for (const [ref, error] of yield* handler(input, updates)) if (!refused.has(ref)) refused.set(ref, error);
|
|
@@ -595,11 +596,11 @@ const claimedAfter = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input,
|
|
|
595
596
|
refused
|
|
596
597
|
};
|
|
597
598
|
});
|
|
598
|
-
/** Whether a push has anything to check: a rule, a
|
|
599
|
+
/** Whether a push has anything to check: a rule, a registered check, or a hook group. */
|
|
599
600
|
const checksOf = /* @__PURE__ */ Effect.fnUntraced(function* (core) {
|
|
600
601
|
const { checks } = core;
|
|
601
602
|
if (checks === void 0) return void 0;
|
|
602
|
-
return (yield* pushRulesFor(checks)).length > 0 || checks.
|
|
603
|
+
return (yield* pushRulesFor(checks)).length > 0 || (checks.registered?.().length ?? 0) > 0 || (checks.groups?.().length ?? 0) > 0 ? checks : void 0;
|
|
603
604
|
});
|
|
604
605
|
/**
|
|
605
606
|
* The repo's objects with the push's own, for the built-in check: `objects` and `listed` read
|
|
@@ -703,8 +704,8 @@ const fetchedRefused = /* @__PURE__ */ Effect.fnUntraced(function* (kinds, reque
|
|
|
703
704
|
/**
|
|
704
705
|
* A commit the store refuses as too large, before it applies any write, for a `loose()` push whose
|
|
705
706
|
* objects are rows of it: its objects fit `loose()`'s limits, but not beside the push's own
|
|
706
|
-
* writes. It gets the hint those limits give. A refusal the push's own writes earn alone
|
|
707
|
-
*
|
|
707
|
+
* writes. It gets the hint those limits give. A refusal the push's own writes earn alone keeps
|
|
708
|
+
* the store's message: fewer objects wouldn't help it.
|
|
708
709
|
* So does `packs()`'s, whose small pushes are rows too: it's on `packs()` already. `loose()` is
|
|
709
710
|
* known by the quarantine it received, so a wrapper that passes it on, as Git's HTTP does, keeps it.
|
|
710
711
|
*/
|
|
@@ -787,6 +788,7 @@ const pushOf = (access, id, moved, request) => {
|
|
|
787
788
|
if (slice !== void 0) push.slice = slice;
|
|
788
789
|
const options = request.pushOptions ?? [];
|
|
789
790
|
if (options.length > 0) push.options = options;
|
|
791
|
+
if (request.onBehalfOf === true) push.onBehalfOf = true;
|
|
790
792
|
return push;
|
|
791
793
|
};
|
|
792
794
|
/**
|
|
@@ -801,32 +803,6 @@ const movedKinds = (updates, moved) => {
|
|
|
801
803
|
}));
|
|
802
804
|
};
|
|
803
805
|
/**
|
|
804
|
-
* What a push's commit saves for `hooks.postReceive`, when the host passed one: the push, with
|
|
805
|
-
* the refs it moved and their kinds, at the version the commit makes, and the repo's
|
|
806
|
-
* `git.post-receive` row. Its ID is the commit's own.
|
|
807
|
-
*/
|
|
808
|
-
const savedPush = (checks, push) => {
|
|
809
|
-
const jobRow = checks?.postReceiveJobRow;
|
|
810
|
-
if (jobRow === void 0 || push.moved.length === 0) return {
|
|
811
|
-
put: [],
|
|
812
|
-
jobs: []
|
|
813
|
-
};
|
|
814
|
-
const updates = movedKinds(push.updates, push.moved);
|
|
815
|
-
const { pushOptions, source } = push.request;
|
|
816
|
-
const saved = {
|
|
817
|
-
pushId: push.id,
|
|
818
|
-
repo: push.name,
|
|
819
|
-
caller: push.caller,
|
|
820
|
-
source,
|
|
821
|
-
updates
|
|
822
|
-
};
|
|
823
|
-
if (pushOptions !== void 0) saved.pushOptions = pushOptions;
|
|
824
|
-
return {
|
|
825
|
-
put: [savedPushRow(push.version, saved)],
|
|
826
|
-
jobs: [jobRow()]
|
|
827
|
-
};
|
|
828
|
-
};
|
|
829
|
-
/**
|
|
830
806
|
* The pack a push's own receive put under its `quarantine` row: none for a push with no pack, one
|
|
831
807
|
* of rows alone, or a caller's `received`, which stays its caller's to end.
|
|
832
808
|
*/
|
|
@@ -841,11 +817,13 @@ const lists = (body, pack) => body.delete.some((key) => key.collection === objec
|
|
|
841
817
|
* The push decide's loop past its first read, onto `listed`, keeping its answer under `key`:
|
|
842
818
|
* the pack received into its quarantine; each edit's kind from the objects; then a read of the
|
|
843
819
|
* refs, the push's `quarantine` row and the caller's fence; a held receipt's answer; the rules and
|
|
844
|
-
*
|
|
845
|
-
* version, with the ref moves, the receipt
|
|
846
|
-
* `answers` says what the call answers and keeps.
|
|
820
|
+
* the hook groups, for a write that moves a ref; the pure decide, and one commit at that read's
|
|
821
|
+
* version, with the ref moves, the receipt and the events.
|
|
822
|
+
* `answers` says what the call answers and keeps. `checking`: the rules, the hook and the decide
|
|
823
|
+
* only, refused as the commit would be, its `writes` or none, and answered before it, for
|
|
824
|
+
* `checkPush`: nothing before that point writes, reserves or enqueues, with no pack.
|
|
847
825
|
*/
|
|
848
|
-
const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, view, views }, key, answers) => Effect.scoped(Effect.gen(function* () {
|
|
826
|
+
const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, view, views }, key, answers, checking = false) => Effect.scoped(Effect.gen(function* () {
|
|
849
827
|
const core = yield* CoreParts;
|
|
850
828
|
const { objects: sealed } = yield* ObjectsParts;
|
|
851
829
|
const authorize = yield* Authorize;
|
|
@@ -978,7 +956,8 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
|
|
|
978
956
|
const own = updates.filter((update) => gitsOwnMove(hidden, request.as, update.ref));
|
|
979
957
|
const outside = updates.filter((update) => !gitsOwnMove(hidden, request.as, update.ref));
|
|
980
958
|
const checks = outside.length === 0 ? void 0 : yield* checksOf(core);
|
|
981
|
-
const branches = request.source === "queue" ? [] : outside.map((update) => update.ref).filter((ref) => ref.startsWith("refs/heads/"));
|
|
959
|
+
const branches = request.source === "queue" ? [] : outside.map((update) => update.ref).filter((ref) => ref.startsWith("refs/heads/") && isRefName(ref));
|
|
960
|
+
const touched = updates.map(({ ref }) => ref).filter(isRefName);
|
|
982
961
|
const scope = yield* callScope;
|
|
983
962
|
const reader = readerOf(pushedObjects, pushedListed, scope);
|
|
984
963
|
const batch = batchOf(pushedObjects, pushedListed, scope);
|
|
@@ -989,7 +968,6 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
|
|
|
989
968
|
repo,
|
|
990
969
|
source: request.source,
|
|
991
970
|
atomic: request.atomic,
|
|
992
|
-
...call,
|
|
993
971
|
push: {
|
|
994
972
|
bytes: received?.bytes ?? 0,
|
|
995
973
|
objects: received?.objects ?? 0
|
|
@@ -1025,7 +1003,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
|
|
|
1025
1003
|
let checked;
|
|
1026
1004
|
for (let tries = 0; tries < 10; tries += 1) {
|
|
1027
1005
|
const at = yield* Clock$1.currentTimeMillis;
|
|
1028
|
-
const decide = yield* finalRead(store, target, fence, received, key, mark, branches,
|
|
1006
|
+
const decide = yield* finalRead(store, target, fence, received, key, mark, branches, touched, request.guard, request.writes?.unchanged);
|
|
1029
1007
|
const { read, receipt, outbox, record, mirrored, facts, stats, times, queued, reserved, indexRow } = decide;
|
|
1030
1008
|
const indexed = SealedObjects.whole(sealed, pushWhole).index?.status(indexRow, at, listedIds(decide.at, received?.change));
|
|
1031
1009
|
if (receipt !== void 0) return yield* answers.held(receipt);
|
|
@@ -1093,11 +1071,12 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
|
|
|
1093
1071
|
const upkept = clears && jobs.length === 0 ? [core.repackJobRow()] : jobs;
|
|
1094
1072
|
const planned = yield* planOf(decision, read.version, upkept);
|
|
1095
1073
|
const { change } = planned;
|
|
1096
|
-
const refusal = writes === void 0 ? void 0 : refusalOf(planned.answer);
|
|
1074
|
+
const refusal = writes === void 0 && !checking ? void 0 : refusalOf(planned.answer);
|
|
1097
1075
|
if (refusal !== void 0) return yield* Effect.fail(refusal);
|
|
1098
1076
|
const movedRefs = new Set(planned.moved.map((move) => move.ref));
|
|
1099
1077
|
const liftedOnMoves = [...checked?.bypassed ?? none].filter(([ref]) => movedRefs.has(ref));
|
|
1100
1078
|
const answer = yield* answers.answer(planned.answer, forced, new Map(liftedOnMoves));
|
|
1079
|
+
if (checking) return answer;
|
|
1101
1080
|
const also = planned.answer.updates.some((update) => update.kind === "rejected") || request.also === void 0 ? void 0 : request.also(yield* Clock$1.currentTimeMillis, received);
|
|
1102
1081
|
const alsoWrites = (also?.put.length ?? 0) + (also?.delete?.length ?? 0);
|
|
1103
1082
|
const quiet = key === void 0 && alsoWrites === 0 && writes === void 0;
|
|
@@ -1137,15 +1116,6 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
|
|
|
1137
1116
|
});
|
|
1138
1117
|
const final = answers.committed?.(answer, appended.head.next - 1) ?? answer;
|
|
1139
1118
|
const kept = receiptWrites(key, answers.kept(final), core.repackJobRow);
|
|
1140
|
-
const saved = savedPush(core.checks, {
|
|
1141
|
-
id,
|
|
1142
|
-
version: planned.expect + 1,
|
|
1143
|
-
caller,
|
|
1144
|
-
name,
|
|
1145
|
-
request,
|
|
1146
|
-
updates: decided.updates,
|
|
1147
|
-
moved: shown
|
|
1148
|
-
});
|
|
1149
1119
|
const woken = shown.filter((move) => queued.has(move.ref)).map((move) => advanceRow(move.ref));
|
|
1150
1120
|
const pushed = pushedRows(core.access, shown, times, at);
|
|
1151
1121
|
const body = {
|
|
@@ -1157,7 +1127,6 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
|
|
|
1157
1127
|
...kept.put,
|
|
1158
1128
|
...also?.put ?? [],
|
|
1159
1129
|
...appended.put,
|
|
1160
|
-
...saved.put,
|
|
1161
1130
|
...writes?.put ?? []
|
|
1162
1131
|
],
|
|
1163
1132
|
delete: [
|
|
@@ -1169,7 +1138,6 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
|
|
|
1169
1138
|
jobs: withJobs([
|
|
1170
1139
|
...planned.jobs,
|
|
1171
1140
|
...appended.jobs,
|
|
1172
|
-
...saved.jobs,
|
|
1173
1141
|
...mirrorJobs(core, planned.moved, mirrored),
|
|
1174
1142
|
...writes?.jobs ?? [],
|
|
1175
1143
|
...woken,
|
|
@@ -1185,6 +1153,10 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
|
|
|
1185
1153
|
moved: planned.moved.length
|
|
1186
1154
|
}, core.refIndex);
|
|
1187
1155
|
if (past !== void 0) return yield* Effect.fail(past);
|
|
1156
|
+
yield* Effect.try({
|
|
1157
|
+
try: () => checkWrites(body),
|
|
1158
|
+
catch: (cause) => fromInfra(cause)
|
|
1159
|
+
}).pipe(Effect.mapError(commitTooLarge(received, body)));
|
|
1188
1160
|
if ((yield* storeCall(() => store.commit(scope, body)).pipe(Effect.mapError(commitTooLarge(received, body)))).ok) {
|
|
1189
1161
|
listing = ownedPack !== void 0 && lists(body, ownedPack);
|
|
1190
1162
|
return final;
|
|
@@ -1206,14 +1178,23 @@ const operationOf = ({ repo, edits }) => edits.length === 0 ? {
|
|
|
1206
1178
|
* reads and decides again. A push cut before its commit leaves an unlisted pack for clean-up, and
|
|
1207
1179
|
* no ref moved.
|
|
1208
1180
|
*/
|
|
1209
|
-
const pushWith =
|
|
1181
|
+
const pushWith = (request, answers, key) => pushThrough(request, answers, key, false);
|
|
1182
|
+
/** `pushWith`, or with `checking`, its checks alone, as `pushOnto` says. */
|
|
1183
|
+
const pushThrough = /* @__PURE__ */ Effect.fnUntraced(function* (request, answers, key, checking) {
|
|
1210
1184
|
const operation = operationOf(request);
|
|
1211
1185
|
const resolved = yield* firstRead(request.caller, operation, request.internalId).pipe(Effect.tapError((error) => retriedCodes.has(error.code) ? Effect.void : refuseQueued(request, [error], "access")));
|
|
1212
1186
|
const opened = yield* listedFor(request, operation, resolved);
|
|
1213
|
-
return yield* pushOnto(request, opened, key, answers);
|
|
1187
|
+
return yield* pushOnto(request, opened, key, answers, checking);
|
|
1214
1188
|
});
|
|
1215
1189
|
/** A push or an unkeyed `refs.update`, answering the decide's ref answer. */
|
|
1216
1190
|
const push = (request) => pushWith(request, refsAnswers);
|
|
1191
|
+
/**
|
|
1192
|
+
* What `push` of `request` would answer, with nothing written, reserved or enqueued: its reads,
|
|
1193
|
+
* `authorize`, its rules and the hook, and the decide, failing as its commit would, a queue's
|
|
1194
|
+
* callers told as its publish tells them. A topic asks it of each member's publish before its
|
|
1195
|
+
* decision (Q1159). For a request with no pack; re-exported from no index.
|
|
1196
|
+
*/
|
|
1197
|
+
const checkPush = (request) => request.pack === void 0 ? pushThrough(request, refsAnswers, void 0, true) : fail("INTERNAL", "A push is checked with no pack");
|
|
1217
1198
|
/** A `git push`, as `push`, with the lines Git prints for the rules `authorize` lifted. */
|
|
1218
1199
|
const gitPush = (request) => pushWith(request, gitAnswers);
|
|
1219
1200
|
/** A ref a forced fetch moved past its diverged tip, answered `force`; the rest as they are. */
|
|
@@ -1248,4 +1229,4 @@ const keyedPushWith = /* @__PURE__ */ Effect.fnUntraced(function* (request, answ
|
|
|
1248
1229
|
});
|
|
1249
1230
|
/** `keyedPushWith` for `refs.update`, answering the decide's ref answer. */
|
|
1250
1231
|
const keyedPush = (request, keyed) => keyedPushWith(request, refsAnswers, keyed);
|
|
1251
|
-
export { buildFence, gitPush, isQueueMoved, keyedPush, keyedPushWith, push, pushFetched, pushWith, retriedCodes };
|
|
1232
|
+
export { buildFence, checkPush, gitPush, isQueueMoved, keyedPush, keyedPushWith, push, pushFetched, pushWith, retriedCodes };
|
package/dist/core/receipts.d.mts
CHANGED
|
@@ -3,6 +3,6 @@ import "../contracts/refs.mjs";
|
|
|
3
3
|
import "../contracts/repos.mjs";
|
|
4
4
|
import "../contracts/result.mjs";
|
|
5
5
|
import "../store/records.mjs";
|
|
6
|
-
import
|
|
6
|
+
import "effect/Effect";
|
|
7
7
|
import "effect/Schema";
|
|
8
|
-
import "
|
|
8
|
+
import { JobInput, Key, Moment, Read, Row } from "@ref0/infra";
|
package/dist/core/receipts.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import { fail, gitErrorFrom, httpStatus } from "../contracts/result.mjs";
|
|
|
2
2
|
import { decodeRow } from "../store/errors.mjs";
|
|
3
3
|
import { KeptRepoInfo, keyLive } from "../store/records.mjs";
|
|
4
4
|
import { collections } from "../store/scopes.mjs";
|
|
5
|
-
import * as Schema from "effect/Schema";
|
|
6
5
|
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
7
|
// src/core/receipts.ts
|
|
8
8
|
/**
|
|
9
9
|
* A receipt row's day, in milliseconds. It's `keyKept` at least, so a receipt `keyKept` hasn't
|
|
@@ -36,7 +36,9 @@ const KeptUpdate = /* @__PURE__ */ Schema.Union([Schema.Struct({
|
|
|
36
36
|
/**
|
|
37
37
|
* A keyed write's first answer: a `refs.update`'s, a repo write's, the object an object write
|
|
38
38
|
* answered and whether it published a ref, which its call reads again to answer, a merge queue
|
|
39
|
-
* call's as it answered, or none, for the rest.
|
|
39
|
+
* call's as it answered, a fork's create, which keeps none, or none, for the rest. A resent fork
|
|
40
|
+
* key answers the fork as it is now, read as `repos.get` reads it for that caller, while every
|
|
41
|
+
* other key answers as it first did.
|
|
40
42
|
*/
|
|
41
43
|
const KeptAnswer = /* @__PURE__ */ Schema.Union([
|
|
42
44
|
Schema.Struct({
|
|
@@ -57,7 +59,8 @@ const KeptAnswer = /* @__PURE__ */ Schema.Union([
|
|
|
57
59
|
kind: Schema.Literal("queue"),
|
|
58
60
|
answer: Schema.Json
|
|
59
61
|
}),
|
|
60
|
-
Schema.Struct({ kind: Schema.Literal("done") })
|
|
62
|
+
Schema.Struct({ kind: Schema.Literal("done") }),
|
|
63
|
+
Schema.Struct({ kind: Schema.Literal("fork") })
|
|
61
64
|
]);
|
|
62
65
|
/**
|
|
63
66
|
* A keyed write's receipt, in the scope it wrote, saved in the write's own commit: the input its
|
|
@@ -226,6 +229,27 @@ const refsAnswer = (held) => held.answer?.kind === "refs" ? Effect.succeed({ upd
|
|
|
226
229
|
...update,
|
|
227
230
|
error: heldError(update.error)
|
|
228
231
|
}) }) : noAnswer(held, "refs");
|
|
232
|
+
/**
|
|
233
|
+
* A fork create's receipt: its answer is asked of the view after its commit, so it keeps none, and
|
|
234
|
+
* the create sent again reads the fork again.
|
|
235
|
+
*/
|
|
236
|
+
const forkKept = { kind: "fork" };
|
|
237
|
+
/**
|
|
238
|
+
* Whether a held receipt's write has answered, so the write sent again answers from it, or is a
|
|
239
|
+
* work write's still `pending`, which calls the queue again. Each kind is named, with no default
|
|
240
|
+
* arm, so a new kind must say which it is.
|
|
241
|
+
*/
|
|
242
|
+
const receiptAnswered = (held) => {
|
|
243
|
+
if (held.answer === void 0) return held.pending !== true;
|
|
244
|
+
switch (held.answer.kind) {
|
|
245
|
+
case "refs":
|
|
246
|
+
case "repo":
|
|
247
|
+
case "object":
|
|
248
|
+
case "queue":
|
|
249
|
+
case "done": return true;
|
|
250
|
+
case "fork": return true;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
229
253
|
/** The answer a repo create, update or rename's receipt kept, for the write sent again. */
|
|
230
254
|
const repoAnswer = (held) => held.answer?.kind === "repo" ? Effect.succeed(held.answer.info) : noAnswer(held, "repo");
|
|
231
255
|
/** The object a create, merge, revert or pick's receipt kept, for the write sent again. */
|
|
@@ -239,4 +263,4 @@ const writtenOf = (kept) => {
|
|
|
239
263
|
if (kept.renamesSkipped !== void 0) written.renamesSkipped = kept.renamesSkipped;
|
|
240
264
|
return written;
|
|
241
265
|
};
|
|
242
|
-
export { KeptError, ReceiptRow, dayMs, dayOf, heldError, heldReceipt, keptError, liveReceipt, matchedReceipt, objectAnswer, receiptId, receiptKeys, receiptReads, receiptRow, receiptWrites, refsAnswer, refsKept, repoAnswer, sweepDue, sweepOf, sweepRead, withJobs };
|
|
266
|
+
export { KeptError, ReceiptRow, dayMs, dayOf, forkKept, heldError, heldReceipt, keptError, liveReceipt, matchedReceipt, objectAnswer, receiptAnswered, receiptId, receiptKeys, receiptReads, receiptRow, receiptWrites, refsAnswer, refsKept, repoAnswer, sweepDue, sweepOf, sweepRead, withJobs };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { storeCall } from "../store/errors.mjs";
|
|
2
|
-
import { currentRepo,
|
|
2
|
+
import { currentRepo, gitJob, repoTry } from "../store/job-try.mjs";
|
|
3
3
|
import { readRecord } from "../store/repo-record.mjs";
|
|
4
4
|
import { newChangeId, repoScope, selfKey } from "../store/scopes.mjs";
|
|
5
5
|
import { copyRead, indexCopies, indexRowKeys, otherRowsReads, ownRowsRead } from "./ref-index.mjs";
|
|
6
|
-
import { Job } from "@ref0/infra";
|
|
7
|
-
import * as Schema from "effect/Schema";
|
|
8
6
|
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Schema from "effect/Schema";
|
|
8
|
+
import { Job } from "@ref0/infra";
|
|
9
9
|
// src/core/ref-index-job.ts
|
|
10
10
|
/**
|
|
11
11
|
* `git.ref-index`, a repo's ref index rebuilt under the server's stamp (#668), as
|
|
@@ -167,7 +167,7 @@ const RefIndexJob = /* @__PURE__ */ Job.make(refIndexJobName, {
|
|
|
167
167
|
rebuild: () => ({})
|
|
168
168
|
});
|
|
169
169
|
/** `git.ref-index`, over the server's ref index: each try one step of its rebuild, whose `more` starts its tries again. */
|
|
170
|
-
const refIndexJob = (parts) =>
|
|
170
|
+
const refIndexJob = (parts) => gitJob(RefIndexJob, () => repoTry((store, repo) => rebuildTry(parts, store, repo)), { onFailure: rebuildFailed });
|
|
171
171
|
/** The repo's `git.ref-index` row, due now. */
|
|
172
172
|
const refIndexJobRow = (job) => job.job({
|
|
173
173
|
key: refIndexJobKey,
|
package/dist/core/ref-view.mjs
CHANGED
|
@@ -5,10 +5,10 @@ import { advanceName, buildName, timeoutName, trimName } from "../store/queue-jo
|
|
|
5
5
|
import { mirrorJobName } from "../store/records.mjs";
|
|
6
6
|
import { CoreParts } from "./parts.mjs";
|
|
7
7
|
import { Authorize, audience, check, grantOf } from "../contracts/authorize.mjs";
|
|
8
|
-
import * as Effect from "effect/Effect";
|
|
9
|
-
import * as Context from "effect/Context";
|
|
10
8
|
import * as Clock$1 from "effect/Clock";
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
11
10
|
import * as Option from "effect/Option";
|
|
11
|
+
import * as Context from "effect/Context";
|
|
12
12
|
// src/core/ref-view.ts
|
|
13
13
|
/**
|
|
14
14
|
* What a caller who reads every pattern, or any caller of a server with no `access`, sees. It has
|
package/dist/core/refs.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { count, get, list, protection, protections, sees, update } from "../contracts/refs.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { isHost } from "../contracts/git.mjs";
|
|
3
|
+
import "../contracts/ids.mjs";
|
|
3
4
|
import { badCursor } from "../engine/reads.mjs";
|
|
4
5
|
import { listBound } from "../store/cursor-seal.mjs";
|
|
5
6
|
import { storeCall } from "../store/errors.mjs";
|
|
@@ -19,10 +20,11 @@ import { pushRulesFor } from "./rules/check.mjs";
|
|
|
19
20
|
import { refProtection } from "./rules/protect.mjs";
|
|
20
21
|
import { fail } from "../contracts/result.mjs";
|
|
21
22
|
import { CoreParts, acting } from "./parts.mjs";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import * as Effect from "effect/Effect";
|
|
23
|
+
import { bypassKinds, hostAuthorize } from "../auth/authorize.mjs";
|
|
24
|
+
import { Authorize, check } from "../contracts/authorize.mjs";
|
|
25
25
|
import * as Clock$1 from "effect/Clock";
|
|
26
|
+
import * as Effect from "effect/Effect";
|
|
27
|
+
import { byBytes, jsonBytes, limits } from "@ref0/infra";
|
|
26
28
|
const maxRefLimit = 1e3;
|
|
27
29
|
/**
|
|
28
30
|
* The most ranges one store call of a listing's page reads under `access`. Each span the caller
|
|
@@ -34,9 +36,9 @@ const maxRefLimit = 1e3;
|
|
|
34
36
|
*/
|
|
35
37
|
const refListRangesMost = 2 * (72 + gitsOwnRefs.length) + 1;
|
|
36
38
|
/** A longest ref name, of `"` past `refs/`, which JSON doubles. */
|
|
37
|
-
const longestName = `refs/${"\"".repeat(
|
|
38
|
-
/** A longest class: a pattern as written,
|
|
39
|
-
const longestClass = `refs/${"\"".repeat(
|
|
39
|
+
const longestName = `refs/${"\"".repeat(763)}`;
|
|
40
|
+
/** A longest class: a pattern as written, at `maxRefPatternLength`, with the `*` that classes it. */
|
|
41
|
+
const longestClass = `refs/${"\"".repeat(186)}*`;
|
|
40
42
|
/** A ref row's longest value: a SHA-256 `oid` and `peeled`. */
|
|
41
43
|
const longestValue = {
|
|
42
44
|
oid: "0".repeat(64),
|
|
@@ -44,14 +46,14 @@ const longestValue = {
|
|
|
44
46
|
};
|
|
45
47
|
/**
|
|
46
48
|
* The most bytes one ref's `refs` row takes in a store's answer, as UTF-8 JSON, its collection
|
|
47
|
-
* included: a longest name and value, about
|
|
49
|
+
* included: a longest name and value, about 1.7 KB. Each read of a listing's call takes as many rows
|
|
48
50
|
* as keep every read full within `limits.answerBytes`, so a page is short before its call is
|
|
49
51
|
* refused. A read by name is sized by this, not by the longer `refIndexRowBytesMost`: one bound
|
|
50
52
|
* for both cut a 1,000-ref page of four reads short, at 975.
|
|
51
53
|
*/
|
|
52
54
|
const refRowBytesMost = refRowBytes(longestName, longestValue);
|
|
53
55
|
/**
|
|
54
|
-
* As `refRowBytesMost`, for a ref's `refIndex` row, about
|
|
56
|
+
* As `refRowBytesMost`, for a ref's `refIndex` row, about 2.1 KB: its stamp and class, a pattern
|
|
55
57
|
* as written, come before its name. Only a read of the index is sized by it.
|
|
56
58
|
*/
|
|
57
59
|
const refIndexRowBytesMost = jsonBytes({
|
|
@@ -477,6 +479,7 @@ const refCalls = (bound) => {
|
|
|
477
479
|
};
|
|
478
480
|
if (input.signal !== void 0) request.signal = input.signal;
|
|
479
481
|
if (input.internalId !== void 0) request.internalId = input.internalId;
|
|
482
|
+
if (input.onBehalfOf !== void 0) request.onBehalfOf = true;
|
|
480
483
|
const edits = input.updates.map(({ ref, from, to }) => [
|
|
481
484
|
ref,
|
|
482
485
|
from,
|
|
@@ -556,6 +559,27 @@ const refCalls = (bound) => {
|
|
|
556
559
|
update
|
|
557
560
|
};
|
|
558
561
|
};
|
|
562
|
+
/**
|
|
563
|
+
* `effect` with its push decided as host code's, `hostAuthorize`'s, which lifts no rule: every
|
|
564
|
+
* other check, its view and the publish rule among them, stays its caller's own.
|
|
565
|
+
*/
|
|
566
|
+
const pushingAsHost = (effect) => Effect.updateService(effect, Authorize, (decider) => ({
|
|
567
|
+
...decider,
|
|
568
|
+
check: (request) => request.operation.kind === "push" || bypassKinds.has(request.operation.kind) ? hostAuthorize(request) : decider.check(request)
|
|
569
|
+
}));
|
|
570
|
+
/**
|
|
571
|
+
* `refs.update`'s `onBehalfOf`: `for`'s own update, but its push decided as the host's, once every
|
|
572
|
+
* ref it moves is under a prefix a registration publishes.
|
|
573
|
+
*/
|
|
574
|
+
const onBehalfOfUpdate = (repo, input, caller) => Effect.flatMap(Effect.service(CoreParts), (core) => {
|
|
575
|
+
const prefixes = core.publishedRefs().map(({ prefix }) => prefix);
|
|
576
|
+
const outside = input.updates.find(({ ref }) => !prefixes.some((one) => ref.startsWith(one)));
|
|
577
|
+
if (outside !== void 0) {
|
|
578
|
+
const allowed = prefixes.length === 0 ? "no registration publishes one" : prefixes.join(", ");
|
|
579
|
+
return fail("INVALID_ARGUMENT", `'onBehalfOf' moves only refs under a published prefix: ${outside.ref} is under none (${allowed})`);
|
|
580
|
+
}
|
|
581
|
+
return pushingAsHost(refCalls(caller).update(repo, input));
|
|
582
|
+
});
|
|
559
583
|
/** `Refs`' calls, each deciding for its `by`, as `refCalls(by)`'s do. */
|
|
560
584
|
const refsCalls = {
|
|
561
585
|
get: (repo, input, by) => acting(by, refCalls(by).get(repo, input)),
|
|
@@ -564,7 +588,14 @@ const refsCalls = {
|
|
|
564
588
|
sees: (repo, input, by) => acting(by, refCalls(by).sees(repo, input)),
|
|
565
589
|
list: (repo, input, by) => acting(by, refCalls(by).list(repo, input)),
|
|
566
590
|
count: (repo, input, by) => acting(by, refCalls(by).count(repo, input)),
|
|
567
|
-
update: (repo, input, by) =>
|
|
591
|
+
update: (repo, input, by) => {
|
|
592
|
+
const { actingAs, onBehalfOf } = input;
|
|
593
|
+
if ((actingAs !== void 0 || onBehalfOf !== void 0) && !isHost(by)) return fail("INVALID_ARGUMENT", "Only Git.host's refs.update names 'actingAs' or 'onBehalfOf'");
|
|
594
|
+
if (actingAs !== void 0 && onBehalfOf !== void 0) return fail("INVALID_ARGUMENT", "A refs.update names 'actingAs' or 'onBehalfOf', never both");
|
|
595
|
+
if (actingAs !== void 0) return refCalls(actingAs).update(repo, input);
|
|
596
|
+
if (onBehalfOf !== void 0) return onBehalfOfUpdate(repo, input, onBehalfOf);
|
|
597
|
+
return acting(by, refCalls(by).update(repo, input));
|
|
598
|
+
}
|
|
568
599
|
};
|
|
569
600
|
/** The `refs` group deciding for `by`, over the `Refs` its runtime holds. */
|
|
570
601
|
const refsAs = (by) => ({
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { storeCall, storeWatch } from "../store/errors.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Stream from "effect/Stream";
|
|
4
|
+
// src/core/registered-records.ts
|
|
5
|
+
/** Whether `scope` belongs to the exact scope or prefix `owned`. */
|
|
6
|
+
const ownsScope = (owned, scope) => owned.endsWith("/") ? scope.startsWith(owned) : scope === owned;
|
|
7
|
+
/** Records restricted to one registration's scopes, read in the calling fiber so its fence survives. */
|
|
8
|
+
const registeredRecords = (name, scopes, base) => {
|
|
9
|
+
const within = (scope, run) => Effect.suspend(() => {
|
|
10
|
+
if (!scopes.some((owned) => ownsScope(owned, scope))) return Effect.die(/* @__PURE__ */ new TypeError(`${name} does not own scope '${scope}'`));
|
|
11
|
+
const records = base();
|
|
12
|
+
return records === void 0 ? Effect.die(/* @__PURE__ */ new Error(`${name}'s records were used before Git.layer wired its store`)) : run(records);
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
read: (scope, reads, counts) => within(scope, (records) => storeCall(records.read(scope, reads, counts))),
|
|
16
|
+
commit: (scope, change) => within(scope, (records) => storeCall(records.commit(scope, change), { resend: true })),
|
|
17
|
+
add: (scope, addition) => within(scope, (records) => storeCall(records.add(scope, addition))),
|
|
18
|
+
watch: (scope, watch) => Stream.unwrap(within(scope, (records) => Effect.succeed(storeWatch(() => records.watch(scope, watch))))),
|
|
19
|
+
jobs: {
|
|
20
|
+
claim: (scope, request) => within(scope, (records) => storeCall(records.jobs.claim(scope, request))),
|
|
21
|
+
settle: (claim, outcome) => within(claim.job.scope, (records) => storeCall(records.jobs.settle(claim, outcome))),
|
|
22
|
+
progress: (scope, write) => within(scope, (records) => storeCall(records.jobs.progress(scope, write))),
|
|
23
|
+
count: (scope) => within(scope, (records) => storeCall(records.jobs.count(scope))),
|
|
24
|
+
list: (scope, request) => within(scope, (records) => storeCall(records.jobs.list(scope, request))),
|
|
25
|
+
retry: (scope, job, input) => within(scope, (records) => storeCall(records.jobs.retry(scope, job, input))),
|
|
26
|
+
discard: (scope, job) => within(scope, (records) => storeCall(records.jobs.discard(scope, job)))
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export { ownsScope, registeredRecords };
|
|
@@ -3,14 +3,14 @@ import { storeCall } from "../store/errors.mjs";
|
|
|
3
3
|
import { readRecord } from "../store/repo-record.mjs";
|
|
4
4
|
import { newChangeId, repoScope } from "../store/scopes.mjs";
|
|
5
5
|
import * as Effect from "effect/Effect";
|
|
6
|
-
// src/core/
|
|
6
|
+
// src/core/registered-rows.ts
|
|
7
7
|
const unbound = (name) => /* @__PURE__ */ new Error(`${name}'s rows were used before Git.layer wired its store`);
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* wiring binds it. A read or a write of any other collection is a defect, so a
|
|
11
|
-
* the repo's record, refs, objects or another
|
|
9
|
+
* Registration `name`'s rows: collections under `<name>/` in each repo's scope, over `base` once the
|
|
10
|
+
* wiring binds it. A read or a write of any other collection is a defect, so a registration never meets
|
|
11
|
+
* the repo's record, refs, objects or another registration's rows.
|
|
12
12
|
*/
|
|
13
|
-
const
|
|
13
|
+
const registeredRows = (name, base) => {
|
|
14
14
|
const prefix = `${name}/`;
|
|
15
15
|
const outside = (touched) => touched.find((one) => !one.collection.startsWith(prefix));
|
|
16
16
|
const within = (touched, run) => Effect.suspend(() => {
|
|
@@ -50,4 +50,4 @@ const claimRows = (name, base) => {
|
|
|
50
50
|
})))
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
|
-
export {
|
|
53
|
+
export { registeredRows };
|
package/dist/core/repack.d.mts
CHANGED
|
@@ -7,5 +7,5 @@ import "../contracts/result.mjs";
|
|
|
7
7
|
import "../storage/repack-job.mjs";
|
|
8
8
|
import "./events/deliver.mjs";
|
|
9
9
|
import "./view.mjs";
|
|
10
|
-
import
|
|
11
|
-
import "
|
|
10
|
+
import "effect/Effect";
|
|
11
|
+
import { JobDefinition, JobInput, Moment } from "@ref0/infra";
|