@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/repack.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { keepsEvents } from "../contracts/events.mjs";
|
|
1
2
|
import { fail } from "../contracts/result.mjs";
|
|
2
3
|
import { bestEffort, decodeRow, resultCall, storeCall, thrownError } from "../store/errors.mjs";
|
|
3
4
|
import { untilAborted } from "../store/crossing.mjs";
|
|
4
|
-
import {
|
|
5
|
+
import { gitJob } from "../store/job-try.mjs";
|
|
5
6
|
import { decodePacks, featureChange, gitStore, packRow } from "../store/git-store.mjs";
|
|
6
7
|
import { appendEvents, decodeOutbox, outboxReads, repoEnvelope } from "../store/outbox.mjs";
|
|
7
8
|
import { decodeTimes, readRecord, repoStats, timeRow } from "../store/repo-record.mjs";
|
|
@@ -23,8 +24,8 @@ import { ownSweepOf, ownSweepRead } from "./own-writes.mjs";
|
|
|
23
24
|
import { sweepOf, sweepRead } from "./receipts.mjs";
|
|
24
25
|
import { heldId, isAbandon, isReadyPut, isTake, ownRows, stillTakes } from "./still-takes.mjs";
|
|
25
26
|
import { SealedObjects } from "./view.mjs";
|
|
26
|
-
import { CurrentJob, Job, jobLeaseMargin } from "@ref0/infra";
|
|
27
27
|
import * as Effect from "effect/Effect";
|
|
28
|
+
import { CurrentJob, Job, jobLeaseMargin } from "@ref0/infra";
|
|
28
29
|
import * as Predicate from "effect/Predicate";
|
|
29
30
|
// src/core/repack.ts
|
|
30
31
|
/** Upkeep keeps every ref's objects, private or not: it reads the repo whole. */
|
|
@@ -189,10 +190,10 @@ const isStagedPut = (row) => row.collection === objectCollections.staged;
|
|
|
189
190
|
/** A row a step may put at a newer version than it read: a prune pass's, or a walk's `apart`. */
|
|
190
191
|
const isUpkeepMark = (row) => row.collection === objectCollections.prune || row.collection === objectCollections.apart;
|
|
191
192
|
/**
|
|
192
|
-
* Clean-up's delete: an ended `quarantine` row and its
|
|
193
|
-
* `cover` row, or a swept `staged` row.
|
|
193
|
+
* Clean-up's delete: an ended `quarantine` row, its receive's record and its merge's row, a taken
|
|
194
|
+
* `leaving` or `cover` row, or a swept `staged` row.
|
|
194
195
|
*/
|
|
195
|
-
const isEnded = (key) => key.collection === objectCollections.quarantine || key.collection === objectCollections.receive || isLeftKey(key) || key.collection === objectCollections.staged;
|
|
196
|
+
const isEnded = (key) => key.collection === objectCollections.quarantine || key.collection === objectCollections.receive || isLeftKey(key) || key.collection === objectCollections.staged || key.collection === objectCollections.merge;
|
|
196
197
|
/**
|
|
197
198
|
* The rows a missed step's reread checks, or `undefined` for a step that never reads again: its
|
|
198
199
|
* own `quarantine` rows (Q269), every one its change ends, and the ready row a ready pack's step puts; none for a prune
|
|
@@ -200,7 +201,8 @@ const isEnded = (key) => key.collection === objectCollections.quarantine || key.
|
|
|
200
201
|
* against its listing again (#1148); and, for clean-up's change
|
|
201
202
|
* alone, the `quarantine` rows it abandons (#326), the `leaving` rows it takes (#394) and the
|
|
202
203
|
* `leaving` rows it deletes (#1490), each as a `cover` row too (#1582), and the `leaving` row of
|
|
203
|
-
* each `cover` row's pack it takes, with the `staged` rows it puts and sweeps
|
|
204
|
+
* each `cover` row's pack it takes, with the `staged` rows it puts and sweeps, and the `merge` row
|
|
205
|
+
* of each pack it abandons, unchecked (#1558, #1927).
|
|
204
206
|
* A step that abandons a row and also prunes or merges commits only at its first read's version
|
|
205
207
|
* (Q438).
|
|
206
208
|
*/
|
|
@@ -316,7 +318,7 @@ const commitStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
|
|
|
316
318
|
};
|
|
317
319
|
const listing = listedIds(read, step?.change);
|
|
318
320
|
const fenced = (step?.fenced ?? []).filter(({ pack }) => listing.includes(pack));
|
|
319
|
-
const report = parts.events
|
|
321
|
+
const report = !keepsEvents(parts.events) || deleted ? {
|
|
320
322
|
put: [],
|
|
321
323
|
delete: [],
|
|
322
324
|
jobs: []
|
|
@@ -390,7 +392,7 @@ const commitStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
|
|
|
390
392
|
};
|
|
391
393
|
});
|
|
392
394
|
/** Whether a read must settle a rename first, which it commits itself (Q186). */
|
|
393
|
-
const settles = (parts, store, internalId, read) => parts.events
|
|
395
|
+
const settles = (parts, store, internalId, read) => !keepsEvents(parts.events) ? Effect.succeed(false) : settleName(store, repoScope(internalId), {
|
|
394
396
|
version: read.version,
|
|
395
397
|
head: read.outbox.head,
|
|
396
398
|
record: read.record
|
|
@@ -617,7 +619,7 @@ const RepackJob = /* @__PURE__ */ Job.make(repackJobName, {
|
|
|
617
619
|
});
|
|
618
620
|
const repackJob = (parts) => {
|
|
619
621
|
const { onFailure } = parts;
|
|
620
|
-
return
|
|
622
|
+
return gitJob(RepackJob, repackTry(parts), onFailure === void 0 ? {} : { onFailure });
|
|
621
623
|
};
|
|
622
624
|
/** The repo's one `git.repack` row, due at `at` or now. */
|
|
623
625
|
const repackJobRow = (job, at) => job.job(at === void 0 ? {
|
package/dist/core/repo-info.mjs
CHANGED
|
@@ -4,13 +4,13 @@ import { storeCall } from "../store/errors.mjs";
|
|
|
4
4
|
import { decodePacks } from "../store/git-store.mjs";
|
|
5
5
|
import { decodeTimes, repoStats, seenTimes } from "../store/repo-record.mjs";
|
|
6
6
|
import { repoScope } from "../store/scopes.mjs";
|
|
7
|
-
import { repoAccess, statsReads } from "./access.mjs";
|
|
7
|
+
import { liveAsAsked, repoAccess, statsReads } from "./access.mjs";
|
|
8
8
|
import { refViewIn, wholeView } from "./ref-view.mjs";
|
|
9
9
|
import { SealedObjects } from "./view.mjs";
|
|
10
10
|
import { CoreParts, ObjectsParts, QueueParts } from "./parts.mjs";
|
|
11
11
|
import { check } from "../contracts/authorize.mjs";
|
|
12
|
-
import * as Effect from "effect/Effect";
|
|
13
12
|
import * as Clock$1 from "effect/Clock";
|
|
13
|
+
import * as Effect from "effect/Effect";
|
|
14
14
|
// src/core/repo-info.ts
|
|
15
15
|
/**
|
|
16
16
|
* A repo's info, as `repos` and `forks` answer it: its stats, its work and its upstream, for one
|
|
@@ -30,39 +30,67 @@ const indexHoldOf = (status) => {
|
|
|
30
30
|
return status?.state === "too-large" ? { state: "too-large" } : void 0;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
|
+
* The stats a caller a private pattern restricts is told: only what its own view counts, as
|
|
34
|
+
* `RepoInfoStats` says. A hidden push moves the rest, so they're left out.
|
|
35
|
+
*/
|
|
36
|
+
const restricted = ({ repo, refs, pushedAt }) => pushedAt === void 0 ? {
|
|
37
|
+
repo,
|
|
38
|
+
refs
|
|
39
|
+
} : {
|
|
40
|
+
repo,
|
|
41
|
+
refs,
|
|
42
|
+
pushedAt
|
|
43
|
+
};
|
|
44
|
+
/** The repo's jobs, and `index` while a refusal stops its index builds, as `RepoWork` says. */
|
|
45
|
+
const repoWork = /* @__PURE__ */ Effect.fnUntraced(function* (internalId, sealed, indexRow, packs) {
|
|
46
|
+
const { jobs } = yield* QueueParts;
|
|
47
|
+
const counts = yield* storeCall(() => jobs.count(repoScope(internalId)));
|
|
48
|
+
const status = SealedObjects.indexStatus(sealed)?.(indexRow, yield* Clock$1.currentTimeMillis, packs.map(({ id }) => id));
|
|
49
|
+
const index = indexHoldOf(status);
|
|
50
|
+
return index === void 0 ? counts : {
|
|
51
|
+
...counts,
|
|
52
|
+
index
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
/**
|
|
33
56
|
* A repo's info for `caller`, from its record, the rows `infoReads` read, and its jobs' counts. A
|
|
34
57
|
* fork's `upstream` names its source as it's named now, told only to a caller that may read it, as
|
|
35
58
|
* `readableRedirect` says, so no fork tells a stranger a private source's name.
|
|
36
59
|
*/
|
|
37
60
|
const repoInfo = /* @__PURE__ */ Effect.fnUntraced(function* (caller, internalId, record, results) {
|
|
38
61
|
const core = yield* CoreParts;
|
|
39
|
-
const { objects: sealed } = yield* ObjectsParts;
|
|
40
|
-
const packs = yield* decodePacks(results[1] ?? []);
|
|
41
|
-
const times = yield* decodeTimes(results[2] ?? []);
|
|
42
|
-
const refRows = results[0] ?? [];
|
|
43
|
-
const { access } = core;
|
|
44
|
-
const hides = access !== void 0 && (times.privately !== void 0 || access.patternOf(record.defaultBranch) !== void 0 || refRows.some((row) => access.patternOf(row.id) !== void 0));
|
|
45
62
|
const repo = repoAccess({
|
|
46
63
|
name: record.name,
|
|
47
64
|
record,
|
|
48
65
|
internalId
|
|
49
66
|
});
|
|
50
|
-
const refView =
|
|
67
|
+
const refView = core.access === void 0 ? wholeView : yield* refViewIn(caller, repo);
|
|
68
|
+
return yield* infoIn(caller, internalId, record, results, refView);
|
|
69
|
+
});
|
|
70
|
+
/**
|
|
71
|
+
* A repo's info as `repos.create` answers it, before its commit: whole, with no `refs.private`
|
|
72
|
+
* asked, since the catalogue doesn't name the repo yet. The create writes no ref, pack or push, and
|
|
73
|
+
* `privateDefault` refuses a default branch a private pattern matches, so every caller is told the
|
|
74
|
+
* same.
|
|
75
|
+
*/
|
|
76
|
+
const createdInfo = (caller, internalId, record) => infoIn(caller, internalId, record, [], wholeView);
|
|
77
|
+
/** A repo's info for a caller with `refView`, from what `repoInfo` says. */
|
|
78
|
+
const infoIn = /* @__PURE__ */ Effect.fnUntraced(function* (caller, internalId, record, results, refView) {
|
|
79
|
+
const { objects: sealed } = yield* ObjectsParts;
|
|
80
|
+
const packs = yield* decodePacks(results[1] ?? []);
|
|
81
|
+
const times = yield* decodeTimes(results[2] ?? []);
|
|
82
|
+
const refRows = results[0] ?? [];
|
|
51
83
|
const refs = refView.whole ? refRows.length : refRows.filter((row) => refView.sees(row.id)).length;
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
index
|
|
60
|
-
};
|
|
61
|
-
const info = {
|
|
84
|
+
const whole = repoStats(record, refs, packs, seenTimes(times, refView));
|
|
85
|
+
const info = refView.whole ? {
|
|
86
|
+
name: record.name,
|
|
87
|
+
public: record.public,
|
|
88
|
+
stats: whole,
|
|
89
|
+
work: yield* repoWork(internalId, sealed, results[3]?.[0], packs)
|
|
90
|
+
} : {
|
|
62
91
|
name: record.name,
|
|
63
92
|
public: record.public,
|
|
64
|
-
stats
|
|
65
|
-
work
|
|
93
|
+
stats: restricted(whole)
|
|
66
94
|
};
|
|
67
95
|
if (refView.sees(record.defaultBranch)) info.defaultBranch = record.defaultBranch;
|
|
68
96
|
const upstream = yield* readableUpstream(caller, record);
|
|
@@ -74,7 +102,9 @@ const repoInfo = /* @__PURE__ */ Effect.fnUntraced(function* (caller, internalId
|
|
|
74
102
|
* says: `undefined` for a repo that isn't a fork, once its source is deleted, and for a caller that
|
|
75
103
|
* may not read it. The source is read and asked of `authorize` by the internal ID the fork's
|
|
76
104
|
* record keeps, never opened again by the name that read gave, so a rename landing between the
|
|
77
|
-
* two never hides a live source.
|
|
105
|
+
* two never hides a live source. Once `authorize` answers, the source is read again, as
|
|
106
|
+
* `liveAsAsked` says: told by the name it holds then, the new one past a rename, and `undefined`
|
|
107
|
+
* once it's deleted or made public or private meanwhile. A host's outage still fails.
|
|
78
108
|
*/
|
|
79
109
|
const readableUpstream = /* @__PURE__ */ Effect.fnUntraced(function* (caller, record) {
|
|
80
110
|
const core = yield* CoreParts;
|
|
@@ -87,13 +117,17 @@ const readableUpstream = /* @__PURE__ */ Effect.fnUntraced(function* (caller, re
|
|
|
87
117
|
...source,
|
|
88
118
|
internalId
|
|
89
119
|
});
|
|
90
|
-
|
|
120
|
+
const asked = check({
|
|
91
121
|
caller,
|
|
92
122
|
operation: {
|
|
93
123
|
kind: "read",
|
|
94
124
|
repo: name
|
|
95
125
|
},
|
|
96
126
|
repo
|
|
97
|
-
})
|
|
127
|
+
});
|
|
128
|
+
return yield* Effect.andThen(asked, liveAsAsked({
|
|
129
|
+
...source,
|
|
130
|
+
internalId
|
|
131
|
+
})).pipe(Effect.map((now) => now?.name), Effect.catch((error) => error.code === "UNAVAILABLE" ? Effect.fail(error) : Effect.succeed(void 0)));
|
|
98
132
|
});
|
|
99
|
-
export { infoReads, repoInfo };
|
|
133
|
+
export { createdInfo, infoReads, repoInfo };
|
package/dist/core/repos.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { keepsEvents } from "../contracts/events.mjs";
|
|
1
2
|
import { isRepoName } from "../contracts/ids.mjs";
|
|
2
3
|
import { isTokenOf } from "../auth/token-text.mjs";
|
|
3
4
|
import { checkChurn, createdKey, createdKeyOf, entryOf, listCreated, listLimit, listNames, listPublic, readEntries, recordAt } from "../store/catalogue.mjs";
|
|
@@ -9,7 +10,7 @@ import { keptKey, takenBack } from "../store/records.mjs";
|
|
|
9
10
|
import { refuseLive, reservationOf, reservedRepo } from "../store/reservations.mjs";
|
|
10
11
|
import { collections, newInternalId, reachedKey, repoScope } from "../store/scopes.mjs";
|
|
11
12
|
import { alreadyExists, callerFor, contended, contendedAfterWrites, indexDeleteJobs, keyedRecord, nameMoved, openKeyed, openRepo, purgeJobs, repoAccess, unlessHidden } from "./access.mjs";
|
|
12
|
-
import { infoReads, repoInfo } from "./repo-info.mjs";
|
|
13
|
+
import { createdInfo, infoReads, repoInfo } from "./repo-info.mjs";
|
|
13
14
|
import { isRefName } from "./names.mjs";
|
|
14
15
|
import { shortRef } from "./rules/patterns.mjs";
|
|
15
16
|
import { hiddenUnder } from "../protocol/wire/lines.mjs";
|
|
@@ -17,8 +18,8 @@ import { heldReceipt, receiptId, receiptKeys, receiptReads, receiptWrites, repoA
|
|
|
17
18
|
import { fail } from "../contracts/result.mjs";
|
|
18
19
|
import { CoreParts } from "./parts.mjs";
|
|
19
20
|
import { check } from "../contracts/authorize.mjs";
|
|
20
|
-
import * as Effect from "effect/Effect";
|
|
21
21
|
import * as Clock$1 from "effect/Clock";
|
|
22
|
+
import * as Effect from "effect/Effect";
|
|
22
23
|
// src/core/repos.ts
|
|
23
24
|
const defaultBranch = "refs/heads/main";
|
|
24
25
|
/**
|
|
@@ -100,8 +101,12 @@ const privateDefault = /* @__PURE__ */ Effect.fnUntraced(function* (branch) {
|
|
|
100
101
|
});
|
|
101
102
|
/** What `repos.rename` reads besides the record: its stats' rows, then its outbox. */
|
|
102
103
|
const renameReads = [...infoReads, ...outboxReads];
|
|
103
|
-
/**
|
|
104
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Every merge queue target's reservation row, which a delete or rename reads for a topic's
|
|
106
|
+
* reservation: `queueLimits.targets` at most, each under `reservationRowBytesMost`, never the
|
|
107
|
+
* targets' own rows, which can pass 16 MiB together (#1971).
|
|
108
|
+
*/
|
|
109
|
+
const targetsRead = { collection: collections.queueReservations };
|
|
105
110
|
/**
|
|
106
111
|
* Refused while a topic's live reservation holds one of the repo's targets, `rows`, which a delete
|
|
107
112
|
* or rename would take from under it after its check: the topic is named, and how to release it
|
|
@@ -327,7 +332,7 @@ const createWith = /* @__PURE__ */ Effect.fnUntraced(function* (caller, input, a
|
|
|
327
332
|
changedAt: at
|
|
328
333
|
};
|
|
329
334
|
if (core.refIndex !== void 0) record.refIndex = core.refIndex.stamp;
|
|
330
|
-
const info = yield*
|
|
335
|
+
const info = yield* createdInfo(caller, internalId, record);
|
|
331
336
|
const receipt = receiptWrites(kept, repoKept(info), core.repackJobRow);
|
|
332
337
|
const created = {
|
|
333
338
|
type: "repo.created",
|
|
@@ -385,7 +390,8 @@ const repoCalls = (bound) => {
|
|
|
385
390
|
repo
|
|
386
391
|
};
|
|
387
392
|
const caller = callerOf(input);
|
|
388
|
-
const
|
|
393
|
+
const confirm = input.unconfirmed === true ? "skip" : "read";
|
|
394
|
+
const opened = yield* openRepo(caller, operation, infoReads, input.internalId, confirm);
|
|
389
395
|
return yield* repoInfo(caller, opened.internalId, opened.record, opened.snapshot.results.slice(1));
|
|
390
396
|
});
|
|
391
397
|
const list = Effect.fnUntraced(function* (input) {
|
|
@@ -555,7 +561,7 @@ const repoCalls = (bound) => {
|
|
|
555
561
|
...infoReads,
|
|
556
562
|
...keyReads,
|
|
557
563
|
...flipReads
|
|
558
|
-
], input.internalId);
|
|
564
|
+
], input.internalId, "skip");
|
|
559
565
|
const results = snapshot.results.slice(1);
|
|
560
566
|
const keyRows = results.slice(infoReads.length, infoReads.length + keyReads.length);
|
|
561
567
|
const held = yield* heldReceipt(keyRows, kept);
|
|
@@ -641,7 +647,7 @@ const repoCalls = (bound) => {
|
|
|
641
647
|
...keyReads,
|
|
642
648
|
targetsRead
|
|
643
649
|
];
|
|
644
|
-
const opened = yield* openKeyed(caller, operation, reads, keyed, input.internalId);
|
|
650
|
+
const opened = yield* openKeyed(caller, operation, reads, keyed, input.internalId, "skip");
|
|
645
651
|
if (opened === void 0) continue;
|
|
646
652
|
const keyRows = opened.snapshot.results.slice(1 + renameReads.length);
|
|
647
653
|
const held = yield* heldReceipt(keyRows.slice(0, keyReads.length), kept);
|
|
@@ -662,7 +668,7 @@ const repoCalls = (bound) => {
|
|
|
662
668
|
name: repo,
|
|
663
669
|
revision: opened.record.revision + 1
|
|
664
670
|
};
|
|
665
|
-
if (core.events
|
|
671
|
+
if (keepsEvents(core.events)) renamedFrom.nextSeq = outbox.head.next;
|
|
666
672
|
if (kept !== void 0) renamedFrom.receipt = receiptId(kept.at, kept.key);
|
|
667
673
|
const moved = {
|
|
668
674
|
...opened.record,
|
|
@@ -742,7 +748,7 @@ const repoCalls = (bound) => {
|
|
|
742
748
|
...keyReads,
|
|
743
749
|
targetsRead
|
|
744
750
|
];
|
|
745
|
-
const opened = yield* openKeyed(caller, operation, reads, keyed, input.internalId);
|
|
751
|
+
const opened = yield* openKeyed(caller, operation, reads, keyed, input.internalId, "skip");
|
|
746
752
|
if (opened === void 0) continue;
|
|
747
753
|
const { name, internalId, record, snapshot } = opened;
|
|
748
754
|
const keyRows = snapshot.results.slice(1 + outboxReads.length);
|
|
@@ -765,7 +771,7 @@ const repoCalls = (bound) => {
|
|
|
765
771
|
revision: record.revision + 1,
|
|
766
772
|
changedAt: at
|
|
767
773
|
};
|
|
768
|
-
if (core.events
|
|
774
|
+
if (keepsEvents(core.events)) deleted.nextSeq = appended.head.next;
|
|
769
775
|
const receipt = receiptWrites(kept, { kind: "done" }, core.repackJobRow);
|
|
770
776
|
if ((yield* writeRecord(store, internalId, {
|
|
771
777
|
expect: snapshot.version,
|
|
@@ -20,7 +20,7 @@ const withEmptyTree = (read) => async (input) => input.oid === "4b825dc642cb6eb9
|
|
|
20
20
|
}
|
|
21
21
|
} : read(input);
|
|
22
22
|
/** A commit, or `undefined` for a tip that isn't one, such as a tag's. */
|
|
23
|
-
const commitOf =
|
|
23
|
+
const commitOf = /* @__PURE__ */ Effect.fnUntraced(function* (read, oid, signal) {
|
|
24
24
|
const found = yield* Effect.promise(() => read({
|
|
25
25
|
oid,
|
|
26
26
|
signal
|
|
@@ -42,7 +42,7 @@ const treeOf = (read, oid, signal) => Effect.map(commitOf(read, oid, signal), (c
|
|
|
42
42
|
* The files that differ between `from`'s and `to`'s trees, as `diff-tree -r -M` lists them: a
|
|
43
43
|
* create from the empty tree, a delete to it. A tip that isn't a commit changes no files.
|
|
44
44
|
*/
|
|
45
|
-
const changesBetween = (read, from, to, signal, objects)
|
|
45
|
+
const changesBetween = /* @__PURE__ */ Effect.fnUntraced(function* (read, from, to, signal, objects) {
|
|
46
46
|
const reads = withEmptyTree(read);
|
|
47
47
|
const base = from === void 0 ? emptyTree : yield* treeOf(reads, from, signal);
|
|
48
48
|
const head = to === void 0 ? emptyTree : yield* treeOf(reads, to, signal);
|
|
@@ -7,8 +7,8 @@ import { openTreesRefusal } from "../../storage/push-allotment.mjs";
|
|
|
7
7
|
import { answerFailed } from "../../contracts/calls-spent.mjs";
|
|
8
8
|
import { commitOf, treeOf, withEmptyTree } from "./changes.mjs";
|
|
9
9
|
import * as Effect from "effect/Effect";
|
|
10
|
-
import * as Predicate from "effect/Predicate";
|
|
11
10
|
import * as Option from "effect/Option";
|
|
11
|
+
import * as Predicate from "effect/Predicate";
|
|
12
12
|
import * as Stream from "effect/Stream";
|
|
13
13
|
// src/core/rules/commit-changes.ts
|
|
14
14
|
/** Whether `received` brings any object at all: a pack, or rows. */
|
|
@@ -21,7 +21,6 @@ export interface CheckInput {
|
|
|
21
21
|
readonly atomic: boolean;
|
|
22
22
|
readonly pushOptions?: readonly string[];
|
|
23
23
|
readonly request?: Request;
|
|
24
|
-
readonly signal?: AbortSignal;
|
|
25
24
|
readonly push: {
|
|
26
25
|
readonly bytes: number;
|
|
27
26
|
readonly objects: number;
|
|
@@ -30,7 +29,7 @@ export interface CheckInput {
|
|
|
30
29
|
/** Refs refused before the checks, which no rule sees. */
|
|
31
30
|
readonly refused: ReadonlyMap<RefName, GitError>;
|
|
32
31
|
readonly stats: RepoStats;
|
|
33
|
-
/** The push's call scope, which a check's reads carry, so a hook's
|
|
32
|
+
/** The push's call scope, which a check's reads carry, so a hook group's reads count into it too. */
|
|
34
33
|
readonly scope: CallScope;
|
|
35
34
|
/** `Kinds.exact`: a force's kind with no trust in the clock. */
|
|
36
35
|
readonly exact: (update: RefUpdate) => Effect.Effect<RefUpdateKind, GitError>;
|
|
@@ -57,10 +56,10 @@ export interface PushedObjects {
|
|
|
57
56
|
readonly lfsPointers: LfsPointers;
|
|
58
57
|
}
|
|
59
58
|
/**
|
|
60
|
-
* A check after the host's rules, in its
|
|
61
|
-
* no earlier check refused. A
|
|
59
|
+
* A check after the host's rules, in its registration's band: the refs it refuses among `updates`, those
|
|
60
|
+
* no earlier check refused. A registration's push check is one, LFS's pointer check among them.
|
|
62
61
|
*/
|
|
63
|
-
export type
|
|
62
|
+
export type RegisteredCheck = Ordered<(input: CheckInput, updates: readonly RefUpdate[]) => Effect.Effect<ReadonlyMap<RefName, GitError>, GitError>>;
|
|
64
63
|
/** What a rule such as `Rules.files` tells the walk: the refs it covers, and a path it refuses. */
|
|
65
64
|
export interface JudgingRule {
|
|
66
65
|
readonly covers: (ref: RefName) => boolean;
|
|
@@ -3,10 +3,10 @@ import { actingOf } from "../../auth/acting.mjs";
|
|
|
3
3
|
import { WalkRefused } from "../../engine/combined.mjs";
|
|
4
4
|
import { inCallScope, scopedContext } from "../../store/call-count.mjs";
|
|
5
5
|
import * as Effect from "effect/Effect";
|
|
6
|
-
import * as Predicate from "effect/Predicate";
|
|
7
|
-
import * as Result from "effect/Result";
|
|
8
|
-
import * as Exit from "effect/Exit";
|
|
9
6
|
import * as Option from "effect/Option";
|
|
7
|
+
import * as Exit from "effect/Exit";
|
|
8
|
+
import * as Result from "effect/Result";
|
|
9
|
+
import * as Predicate from "effect/Predicate";
|
|
10
10
|
import * as Stream from "effect/Stream";
|
|
11
11
|
import * as Deferred from "effect/Deferred";
|
|
12
12
|
// src/core/rules/context.ts
|
|
@@ -88,7 +88,6 @@ const checking = (input) => {
|
|
|
88
88
|
actor: input.caller.actor
|
|
89
89
|
},
|
|
90
90
|
scope: input.scope,
|
|
91
|
-
...input.signal !== void 0 && { signal: input.signal },
|
|
92
91
|
contextOf,
|
|
93
92
|
changes: readOnce((changed) => input.changes(changed.updates)),
|
|
94
93
|
commitChanges: (changed, by) => input.commitChanges(changed.updates, by),
|
|
@@ -1,24 +1,55 @@
|
|
|
1
|
+
import { gitError } from "../../contracts/result.mjs";
|
|
2
|
+
import { RuledDepth } from "../../contracts/rules.mjs";
|
|
1
3
|
import { hostEffect, rejectedError, reportRefusal } from "../../auth/host-function.mjs";
|
|
4
|
+
import { CoreParts } from "../parts.mjs";
|
|
2
5
|
import { checkedAnswer } from "./context.mjs";
|
|
3
6
|
import { fetchRulesOf } from "./service.mjs";
|
|
4
7
|
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Schema from "effect/Schema";
|
|
5
9
|
// src/core/rules/fetch.ts
|
|
10
|
+
/** What a rule's input holds for `check`, besides its actor and repo. */
|
|
11
|
+
const inputOf = (check) => {
|
|
12
|
+
const { actor } = check.caller;
|
|
13
|
+
if ("fetch" in check) {
|
|
14
|
+
const { fetch } = check;
|
|
15
|
+
return {
|
|
16
|
+
...fetch,
|
|
17
|
+
kind: "git",
|
|
18
|
+
wants: [...fetch.wants],
|
|
19
|
+
haves: [...fetch.haves],
|
|
20
|
+
shallows: [...fetch.shallows],
|
|
21
|
+
actor,
|
|
22
|
+
repo: check.repo,
|
|
23
|
+
request: check.request
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const read = {
|
|
27
|
+
...check.read,
|
|
28
|
+
actor,
|
|
29
|
+
repo: check.repo
|
|
30
|
+
};
|
|
31
|
+
if (check.request !== void 0) read.request = check.request;
|
|
32
|
+
return read;
|
|
33
|
+
};
|
|
34
|
+
/** Whether a rule's depth is one: no type guard, so a refused depth keeps its number type. */
|
|
35
|
+
const isRuledDepth = /* @__PURE__ */ Schema.is(RuledDepth);
|
|
6
36
|
/** A rule's depth, when it set one: a whole number above 0, or the rule's own bug. */
|
|
7
37
|
const depthOf = (name, answer) => {
|
|
8
38
|
if (answer.kind === "reject") return void 0;
|
|
9
39
|
const depth = answer.value?.depth;
|
|
10
|
-
if (depth === void 0 ||
|
|
40
|
+
if (depth === void 0 || isRuledDepth(depth)) return depth;
|
|
11
41
|
throw new TypeError(`${name} set a depth that isn't a whole number above 0: ${depth}`);
|
|
12
42
|
};
|
|
13
43
|
/**
|
|
14
|
-
* A clone's or fetch's rules, the host's `Rules`, in order: any `reject()` refuses it,
|
|
15
|
-
* to reject says, and a rule that fails or dies
|
|
16
|
-
* depth any rule set, or `undefined` when none set one
|
|
17
|
-
*
|
|
44
|
+
* A clone's or fetch's rules, the host's `Rules`, in order, or a read's: any `reject()` refuses it,
|
|
45
|
+
* as the first to reject says, answered as its value, and a rule that fails or dies fails it as the
|
|
46
|
+
* host's failure. Otherwise the smallest depth any rule set, or `undefined` when none set one. A
|
|
47
|
+
* read keeps no history to cut, so a depth set on one refuses it, `NOT_ALLOWED` for
|
|
48
|
+
* `fetch-depth-unsupported`. Each refusal is reported once. No rule sets a filter.
|
|
18
49
|
*/
|
|
19
|
-
const
|
|
50
|
+
const ruledBy = /* @__PURE__ */ Effect.fnUntraced(function* (reports, check) {
|
|
20
51
|
const rules = yield* fetchRulesOf();
|
|
21
|
-
if (rules.length === 0) return void 0;
|
|
52
|
+
if (rules.length === 0) return { depth: void 0 };
|
|
22
53
|
const { actor } = check.caller;
|
|
23
54
|
const about = {
|
|
24
55
|
repo: check.repo,
|
|
@@ -31,27 +62,49 @@ const runFetchRules = /* @__PURE__ */ Effect.fnUntraced(function* (reports, chec
|
|
|
31
62
|
const depths = [];
|
|
32
63
|
for (const rule of rules) {
|
|
33
64
|
const name = `The fetch rule '${rule.name}'`;
|
|
34
|
-
const input =
|
|
35
|
-
...check.fetch,
|
|
36
|
-
wants: [...check.fetch.wants],
|
|
37
|
-
haves: [...check.fetch.haves],
|
|
38
|
-
shallows: [...check.fetch.shallows],
|
|
39
|
-
actor,
|
|
40
|
-
repo: check.repo,
|
|
41
|
-
request: check.request
|
|
42
|
-
};
|
|
65
|
+
const input = inputOf(check);
|
|
43
66
|
const answered = Effect.flatMap(checkedAnswer(name, () => rule.check(input)), (answer) => answer.kind === "reject" ? Effect.succeed(answer) : Effect.sync(() => ({
|
|
44
67
|
kind: "accept",
|
|
45
68
|
depth: depthOf(name, answer)
|
|
46
69
|
})));
|
|
47
70
|
const depth = yield* hostEffect(reports, "rules.fetch", about, answered);
|
|
48
71
|
if (depth.kind === "reject") {
|
|
49
|
-
const
|
|
50
|
-
reportRefusal(reports, "rules.fetch", about,
|
|
51
|
-
return
|
|
72
|
+
const refused = rejectedError(depth);
|
|
73
|
+
reportRefusal(reports, "rules.fetch", about, refused);
|
|
74
|
+
return { refused };
|
|
52
75
|
}
|
|
53
76
|
if (depth.depth !== void 0) depths.push(depth.depth);
|
|
54
77
|
}
|
|
55
|
-
|
|
78
|
+
if (depths.length === 0) return { depth: void 0 };
|
|
79
|
+
if ("read" in check) {
|
|
80
|
+
const refused = gitError("NOT_ALLOWED", "A fetch rule set a depth, which a read of bytes keeps no history for", { context: { reason: "fetch-depth-unsupported" } });
|
|
81
|
+
reportRefusal(reports, "rules.fetch", about, refused);
|
|
82
|
+
return { refused };
|
|
83
|
+
}
|
|
84
|
+
return { depth: Math.min(...depths) };
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
87
|
+
* A clone's or fetch's rules, as `ruledBy` asks them, failing with a refusal as the rule wrote it.
|
|
88
|
+
* Answers the smallest depth any rule set; `withRuledDepth` says how the fetch takes it.
|
|
89
|
+
*/
|
|
90
|
+
const runFetchRules = (reports, check) => Effect.flatMap(ruledBy(reports, check), (ruled) => ruled.refused === void 0 ? Effect.succeed(ruled.depth) : Effect.fail(ruled.refused));
|
|
91
|
+
/**
|
|
92
|
+
* `input`'s read of `repo`, asked of the host's fetch rules as `ruledBy` says: the refusal, or
|
|
93
|
+
* `undefined` when they accept it. A rule's failure fails it, as the host's. Only a target Git
|
|
94
|
+
* already found visible to the caller is asked about.
|
|
95
|
+
*/
|
|
96
|
+
const readRefusal = /* @__PURE__ */ Effect.fnUntraced(function* (repo, input) {
|
|
97
|
+
const core = yield* CoreParts;
|
|
98
|
+
return (yield* ruledBy(core.checks.reports, {
|
|
99
|
+
caller: input.caller,
|
|
100
|
+
repo,
|
|
101
|
+
read: input.target,
|
|
102
|
+
request: input.request
|
|
103
|
+
})).refused;
|
|
104
|
+
});
|
|
105
|
+
/** `Git.checkFetch`: `readRefusal`'s check, failing with the refusal as the rule wrote it. */
|
|
106
|
+
const checkRead = /* @__PURE__ */ Effect.fnUntraced(function* (repo, input) {
|
|
107
|
+
const refused = yield* readRefusal(repo, input);
|
|
108
|
+
if (refused !== void 0) return yield* Effect.fail(refused);
|
|
56
109
|
});
|
|
57
|
-
export { runFetchRules };
|
|
110
|
+
export { checkRead, readRefusal, runFetchRules };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { RefView } from "../contracts/access.mjs";
|
|
2
|
+
import { Caller, RepoAccess } from "../contracts/actors.mjs";
|
|
3
|
+
import "../contracts/authorize.mjs";
|
|
4
|
+
import { InternalRepoId } from "../contracts/ids.mjs";
|
|
5
|
+
import { GitError } from "../contracts/result.mjs";
|
|
6
|
+
import "./parts.mjs";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Schema from "effect/Schema";
|
|
9
|
+
import * as Context from "effect/Context";
|
|
10
|
+
/**
|
|
11
|
+
* A saved caller as asked again, with the repo as it is now, its name and visibility, and their
|
|
12
|
+
* view of it, or why they no longer hold there.
|
|
13
|
+
*/
|
|
14
|
+
export type Viewed = {
|
|
15
|
+
readonly kind: 'caller';
|
|
16
|
+
readonly caller: Caller;
|
|
17
|
+
readonly repo: RepoAccess;
|
|
18
|
+
readonly view: RefView;
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: 'refused';
|
|
21
|
+
readonly error: GitError;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Who a host's work acts for later, as `SavedCallers.save` keeps them: the actor's ID and its kind,
|
|
25
|
+
* and nothing it was given. No token, no grant's answer and no view is kept: each `view` asks the
|
|
26
|
+
* host's policy afresh.
|
|
27
|
+
* - `actor`: a person or a service acting as itself. One that came with a token keeps no token, so
|
|
28
|
+
* revoking the token doesn't stop a retry, and that's correct. The person is asked again under
|
|
29
|
+
* the host's current policy, and a token is only how they arrived.
|
|
30
|
+
* - `grant`: one an extension's grant gave, named by the resolver and the `id` Git's record of it
|
|
31
|
+
* holds. `view` asks that resolver for it afresh, by name and `id`. An App no longer installed on
|
|
32
|
+
* the host, an installation removed or a grant with no record is refused.
|
|
33
|
+
*/
|
|
34
|
+
export declare const Saved: Schema.Union<readonly [Schema.Struct<{
|
|
35
|
+
readonly kind: Schema.Literal<"actor">;
|
|
36
|
+
readonly actor: Schema.String;
|
|
37
|
+
}>, Schema.Struct<{
|
|
38
|
+
readonly kind: Schema.Literal<"grant">;
|
|
39
|
+
readonly actor: Schema.String;
|
|
40
|
+
readonly resolver: Schema.String;
|
|
41
|
+
readonly id: Schema.String;
|
|
42
|
+
}>]>;
|
|
43
|
+
export type Saved = typeof Saved.Type;
|
|
44
|
+
declare const SavedCallers_base: Context.ServiceClass<SavedCallers, "@ref0/git/SavedCallers", {
|
|
45
|
+
/** `caller` as work keeps it, its actor named `actor`: its kind and IDs, nothing more. */
|
|
46
|
+
readonly save: (actor: string, caller: Caller) => Effect.Effect<Saved>;
|
|
47
|
+
/**
|
|
48
|
+
* `saved` asked again now, its grant's resolver asked afresh, then its view for `kind` of
|
|
49
|
+
* the repo `repo` names, read now, under its current name and visibility, asked of the
|
|
50
|
+
* host's `authorize` as it is now. `refused`, with the error the caller's own call would
|
|
51
|
+
* get, when the caller no longer exists, its grant ended, the repo is gone or they may no
|
|
52
|
+
* longer `kind` it. A host or store that failed fails, for the try to retry.
|
|
53
|
+
*/
|
|
54
|
+
readonly view: (saved: Saved, repo: InternalRepoId, kind: 'read' | 'fetch') => Effect.Effect<Viewed, GitError>;
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Work a host's job does later for someone, such as the drop-in's hook deliveries (#1945): who it
|
|
58
|
+
* is for, saved by `save`, and that caller's view of a repo, asked again by `view` on every try.
|
|
59
|
+
* `Git.layer` provides it, over the server's own parts, as it does `Authorize`.
|
|
60
|
+
*/
|
|
61
|
+
export declare class SavedCallers extends /* @__PURE__ */ SavedCallers_base {}
|
|
62
|
+
export declare const save: (actor: string, caller: Caller) => Effect.Effect<{
|
|
63
|
+
readonly kind: "actor";
|
|
64
|
+
readonly actor: string;
|
|
65
|
+
} | {
|
|
66
|
+
readonly kind: "grant";
|
|
67
|
+
readonly actor: string;
|
|
68
|
+
readonly resolver: string;
|
|
69
|
+
readonly id: string;
|
|
70
|
+
}, never, SavedCallers>;
|
|
71
|
+
export declare const view: (saved: Saved, repo: InternalRepoId, kind: 'read' | 'fetch') => Effect.Effect<Viewed, GitError, SavedCallers>;
|
|
72
|
+
export {};
|