@ref0/git 0.20.0 → 0.26.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/private-refs.mjs +1 -1
- package/dist/auth/access-jwt.mjs +3 -3
- package/dist/auth/auth-namespace.d.mts +3 -3
- package/dist/auth/auth-namespace.mjs +3 -2
- package/dist/auth/auth.d.mts +3 -3
- package/dist/auth/auth.mjs +9 -8
- package/dist/auth/authorize.mjs +1 -1
- package/dist/auth/fences.d.mts +1 -1
- package/dist/auth/host-function.mjs +1 -1
- package/dist/auth/host-services.mjs +4 -6
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +6 -0
- package/dist/auth/token-cleanup.mjs +2 -2
- package/dist/auth/token-rows.mjs +6 -1
- package/dist/auth/token-text.mjs +1 -1
- package/dist/auth/tokens-base.d.mts +1 -1
- package/dist/auth/tokens.d.mts +1 -1
- package/dist/auth/tokens.mjs +1 -1
- package/dist/client/client.d.mts +15 -7
- package/dist/client/client.mjs +21 -12
- package/dist/client/git-http.mjs +1 -1
- package/dist/client/local.mjs +60 -24
- package/dist/client/negotiate.mjs +3 -3
- package/dist/client/push-upload.mjs +26 -10
- package/dist/client/remote.mjs +4 -3
- package/dist/client/run-remote-helper.d.mts +2 -2
- package/dist/client/run-remote-helper.mjs +6 -6
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +3 -3
- package/dist/contracts/blobs.d.mts +3 -3
- package/dist/contracts/blobs.mjs +1 -1
- package/dist/contracts/calls-spent.mjs +5 -33
- package/dist/contracts/client.d.mts +15 -14
- package/dist/contracts/commits.d.mts +4 -4
- package/dist/contracts/commits.mjs +1 -1
- package/dist/contracts/engine.d.mts +2 -2
- package/dist/contracts/events.d.mts +1 -1
- package/dist/contracts/events.mjs +1 -1
- package/dist/contracts/files.d.mts +4 -4
- package/dist/contracts/files.mjs +1 -1
- package/dist/contracts/forks.d.mts +4 -4
- package/dist/contracts/forks.mjs +1 -1
- package/dist/contracts/git-hooks.d.mts +1 -1
- package/dist/contracts/git.d.mts +9 -5
- package/dist/contracts/grants.d.mts +1 -1
- package/dist/contracts/merges.d.mts +1 -1
- package/dist/contracts/object-values.d.mts +1 -0
- package/dist/contracts/object-values.mjs +16 -1
- package/dist/contracts/objects.d.mts +30 -18
- package/dist/contracts/opaque.mjs +1 -1
- package/dist/contracts/operations.mjs +1 -1
- package/dist/contracts/queue.d.mts +208 -44
- package/dist/contracts/queue.mjs +5 -5
- package/dist/contracts/refs.d.mts +5 -5
- package/dist/contracts/refs.mjs +1 -1
- package/dist/contracts/remote.d.mts +3 -6
- package/dist/contracts/repos.d.mts +3 -3
- package/dist/contracts/repos.mjs +1 -1
- package/dist/contracts/result.d.mts +10 -7
- package/dist/contracts/result.mjs +8 -3
- package/dist/contracts/rules.d.mts +13 -12
- package/dist/contracts/server.d.mts +8 -10
- package/dist/contracts/services.d.mts +6 -9
- package/dist/contracts/services.mjs +1 -2
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/store.d.mts +2 -2
- package/dist/contracts/sync.d.mts +63 -6
- package/dist/contracts/sync.mjs +3 -2
- package/dist/contracts/tags.d.mts +3 -3
- package/dist/contracts/tags.mjs +1 -1
- package/dist/contracts/tokens.d.mts +2 -2
- package/dist/contracts/tokens.mjs +1 -1
- package/dist/contracts/topics.d.mts +9 -9
- package/dist/contracts/trees.d.mts +4 -4
- package/dist/contracts/trees.mjs +1 -1
- package/dist/contracts/work.d.mts +4 -4
- package/dist/contracts/work.mjs +2 -2
- package/dist/core/access.d.mts +1 -1
- package/dist/core/ancestry.mjs +30 -34
- package/dist/core/{promise.mjs → call-groups.mjs} +7 -30
- package/dist/core/call-services.mjs +1 -1
- package/dist/core/events/deliver.d.mts +2 -2
- package/dist/core/events/deliver.mjs +3 -3
- package/dist/core/events/retired.mjs +1 -1
- package/dist/core/forks.mjs +5 -5
- package/dist/core/hooks/groups.mjs +2 -2
- package/dist/core/imports.mjs +101 -21
- package/dist/core/index-job.mjs +14 -9
- package/dist/core/index-lost.d.mts +1 -1
- package/dist/core/loose-tally.mjs +38 -15
- package/dist/core/merge-parts.d.mts +17 -4
- package/dist/core/merge-parts.mjs +7 -2
- package/dist/core/mirror-rows.mjs +31 -1
- package/dist/core/objects/blobs.mjs +8 -10
- package/dist/core/objects/files.mjs +20 -17
- package/dist/core/objects/objects-layer.mjs +1 -1
- package/dist/core/objects/peel.mjs +1 -7
- package/dist/core/objects/reading.mjs +19 -18
- package/dist/core/objects/tree-edits.mjs +1 -1
- package/dist/core/objects/trees.mjs +257 -58
- package/dist/core/objects/writing.mjs +3 -9
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +8 -1
- package/dist/core/parts.mjs +8 -4
- package/dist/core/purge.mjs +31 -18
- package/dist/core/push.d.mts +2 -2
- package/dist/core/push.mjs +145 -98
- package/dist/core/receipts.d.mts +2 -2
- package/dist/core/receipts.mjs +9 -2
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +74 -31
- package/dist/core/refs.mjs +3 -3
- package/dist/core/repack.mjs +25 -30
- package/dist/core/repo-info.mjs +1 -1
- package/dist/core/repos.mjs +1 -1
- package/dist/core/rules/changes.mjs +18 -40
- package/dist/core/rules/check.mjs +6 -5
- package/dist/core/rules/commit-changes.mjs +114 -58
- package/dist/core/rules/context.d.mts +3 -3
- package/dist/core/rules/context.mjs +18 -14
- package/dist/core/rules/fetch.mjs +1 -1
- package/dist/core/rules/protect.mjs +30 -17
- package/dist/core/saved-caller-views.d.mts +1 -1
- package/dist/core/saved-caller-views.mjs +3 -3
- package/dist/core/saved-callers.d.mts +1 -1
- package/dist/core/saved-callers.mjs +1 -1
- package/dist/core/seam.d.mts +1 -2
- package/dist/core/view.d.mts +6 -3
- package/dist/core/view.mjs +11 -10
- package/dist/core/work.mjs +2 -2
- package/dist/engine/allotted-xdiff.mjs +3 -16
- package/dist/engine/combined.d.mts +3 -0
- package/dist/engine/combined.mjs +200 -185
- package/dist/engine/content.d.mts +2 -2
- package/dist/engine/content.mjs +1 -1
- package/dist/engine/merge.mjs +7 -9
- package/dist/engine/reads.d.mts +2 -2
- package/dist/engine/reads.mjs +22 -14
- package/dist/engine/xdiff.d.mts +1 -1
- package/dist/engine/xdiff.mjs +1 -1
- package/dist/event-streams/event-streams.d.mts +1 -1
- package/dist/event-streams/event-streams.mjs +1 -1
- package/dist/event-streams/stream.d.mts +2 -2
- package/dist/event-streams/stream.mjs +3 -3
- package/dist/extend.d.mts +2 -6
- package/dist/extend.mjs +1 -5
- package/dist/http/core-parts.mjs +83 -26
- package/dist/http/handler.mjs +54 -9
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +138 -24
- package/dist/http/push-uploads.mjs +2 -2
- package/dist/http/receive-pack.mjs +14 -53
- package/dist/http/request-snapshot.mjs +258 -0
- package/dist/http/upload-pack.mjs +23 -18
- package/dist/index.d.mts +29 -21
- package/dist/index.mjs +11 -2
- package/dist/lfs/base.d.mts +1 -1
- package/dist/lfs/copy.d.mts +49 -1
- package/dist/lfs/copy.mjs +135 -22
- package/dist/lfs/layer.d.mts +4 -3
- package/dist/lfs/layer.mjs +4 -5
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +1 -1
- package/dist/lfs/objects.mjs +3 -3
- package/dist/lfs/pointers.mjs +1 -1
- package/dist/lfs/rows.d.mts +1 -1
- package/dist/lfs/rows.mjs +11 -4
- package/dist/lfs/upkeep.mjs +40 -9
- package/dist/lfs/uploaded.mjs +1 -1
- package/dist/lfs/wire.mjs +1 -1
- package/dist/merges/merges.mjs +17 -2
- 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/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 +1 -1
- package/dist/protocol/diff/read.d.mts +2 -1
- package/dist/protocol/diff/read.mjs +102 -8
- 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 +1 -1
- 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 +3 -3
- package/dist/protocol/wire/advertisement.d.mts +1 -1
- package/dist/protocol/wire/advertisement.mjs +3 -2
- package/dist/protocol/wire/fetch.d.mts +1 -1
- package/dist/protocol/wire/fetch.mjs +1 -1
- package/dist/protocol/wire/lines.d.mts +9 -1
- package/dist/protocol/wire/lines.mjs +28 -1
- package/dist/protocol/wire/push-uploads.mjs +10 -7
- 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 +1 -1
- package/dist/protocol/wire/v2.mjs +1 -1
- package/dist/queue/advance.mjs +31 -24
- package/dist/queue/base.d.mts +5 -3
- package/dist/queue/calls.mjs +5 -5
- package/dist/queue/commit.mjs +1 -1
- package/dist/queue/host.d.mts +1 -1
- package/dist/queue/layer.d.mts +0 -1
- package/dist/queue/layer.mjs +9 -5
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/search.mjs +1 -1
- package/dist/queue/state.mjs +1 -1
- package/dist/queue/trim.mjs +2 -2
- package/dist/rest/client.d.mts +1 -1
- package/dist/rest/client.mjs +6 -6
- package/dist/rest/errors.mjs +1 -1
- package/dist/rest/handler.mjs +2 -2
- package/dist/rest/handlers.mjs +16 -6
- package/dist/rest/layer.mjs +1 -1
- package/dist/rest/listen.mjs +2 -2
- package/dist/rest/refs.mjs +1 -1
- package/dist/server/edge.mjs +27 -3
- package/dist/server/git-layer.d.mts +1 -2
- package/dist/server/git-layer.mjs +4 -5
- package/dist/server/lifecycle.mjs +1 -1
- package/dist/server/registry.mjs +2 -8
- package/dist/server/server.mjs +62 -43
- package/dist/signin/context.d.mts +1 -1
- package/dist/signin/context.mjs +1 -1
- package/dist/signin/forms.mjs +1 -1
- package/dist/signin/grants.d.mts +2 -2
- package/dist/signin/grants.mjs +1 -1
- package/dist/signin/wire.mjs +1 -1
- package/dist/storage/allotted.mjs +4 -9
- package/dist/storage/batch-upkeep.mjs +31 -12
- package/dist/storage/batches.d.mts +2 -3
- package/dist/storage/batches.mjs +52 -49
- package/dist/storage/budget.mjs +23 -1
- package/dist/storage/calls.d.mts +1 -1
- package/dist/storage/calls.mjs +41 -43
- package/dist/storage/charged-cache.mjs +180 -0
- package/dist/storage/chunks.d.mts +3 -3
- package/dist/storage/chunks.mjs +121 -8
- package/dist/storage/counted-bucket.mjs +32 -10
- package/dist/storage/fetch-row-cache.d.mts +6 -0
- package/dist/storage/fetch-row-cache.mjs +211 -0
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +54 -242
- package/dist/storage/held-types.d.mts +0 -1
- package/dist/storage/held-types.mjs +13 -4
- package/dist/storage/host-bucket.mjs +9 -4
- package/dist/storage/index-bitmaps.mjs +340 -65
- package/dist/storage/index-build.d.mts +2 -3
- package/dist/storage/index-build.mjs +274 -56
- package/dist/storage/index-fetch.d.mts +3 -1
- package/dist/storage/index-fetch.mjs +60 -21
- package/dist/storage/index-graph.mjs +1 -1
- package/dist/storage/index-layers.mjs +55 -25
- package/dist/storage/index-reach.mjs +15 -22
- package/dist/storage/index-whole.d.mts +7 -0
- package/dist/storage/index-whole.mjs +145 -37
- package/dist/storage/largest-files.mjs +1 -7
- package/dist/storage/layout.mjs +17 -1
- package/dist/storage/lfs-pointers.mjs +1 -6
- package/dist/storage/link-join.mjs +55 -16
- package/dist/storage/list-source.d.mts +7 -0
- package/dist/storage/list-source.mjs +288 -0
- package/dist/storage/loose.d.mts +8 -8
- package/dist/storage/loose.mjs +157 -91
- package/dist/storage/memory-budget.mjs +226 -22
- package/dist/storage/merge-cut.mjs +9 -6
- package/dist/storage/merge-fence.mjs +1 -1
- package/dist/storage/merge-row.mjs +1 -1
- package/dist/storage/merge.d.mts +2 -3
- package/dist/storage/merge.mjs +2 -2
- package/dist/storage/object-rows.d.mts +3 -3
- package/dist/storage/object-rows.mjs +179 -38
- package/dist/storage/pack-order.mjs +97 -44
- package/dist/storage/pack-ranges.mjs +44 -16
- package/dist/storage/pack-reads.d.mts +5 -3
- package/dist/storage/pack-reads.mjs +236 -72
- package/dist/storage/pack-receive.d.mts +1 -2
- package/dist/storage/pack-receive.mjs +24 -18
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +477 -116
- package/dist/storage/placed-reads.mjs +33 -16
- package/dist/storage/prune-seen.mjs +1 -1
- package/dist/storage/prune-walk.mjs +1 -1
- package/dist/storage/prune.mjs +4 -31
- package/dist/storage/push-allotment.mjs +26 -14
- package/dist/storage/push-uploads.mjs +195 -57
- package/dist/storage/pushed-commits.mjs +20 -1
- package/dist/storage/quarantine.d.mts +2 -3
- package/dist/storage/range-cache.mjs +175 -40
- package/dist/storage/raw-ids.mjs +39 -10
- package/dist/storage/ready.d.mts +2 -3
- package/dist/storage/ready.mjs +114 -38
- package/dist/storage/receive-bounds.mjs +31 -9
- package/dist/storage/receive-cache.d.mts +7 -0
- package/dist/storage/receive-cache.mjs +147 -0
- 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 +6 -8
- package/dist/storage/receive-steps.d.mts +20 -0
- package/dist/storage/receive-steps.mjs +298 -13
- package/dist/storage/repack-backlog.mjs +1 -6
- package/dist/storage/repack-contained.mjs +2 -2
- package/dist/storage/repack-job.mjs +1 -1
- package/dist/storage/repack.d.mts +2 -3
- package/dist/storage/repack.mjs +54 -9
- package/dist/storage/request-cache.mjs +57 -0
- package/dist/storage/roots.mjs +1 -24
- 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 +1 -1
- package/dist/storage/send-list.mjs +62 -25
- package/dist/storage/stream-whole.mjs +84 -63
- package/dist/storage/swap-walk.mjs +1 -1
- package/dist/storage/unpack.mjs +878 -450
- package/dist/storage/visible.mjs +110 -32
- package/dist/storage/walk.mjs +1 -0
- package/dist/storage/wants.mjs +22 -58
- package/dist/store/call-count.d.mts +2 -2
- package/dist/store/call-count.mjs +24 -11
- package/dist/store/catalogue.d.mts +1 -1
- package/dist/store/catalogue.mjs +19 -7
- package/dist/store/crossing.mjs +1 -7
- package/dist/store/cursor-seal.d.mts +1 -1
- package/dist/store/cursor-seal.mjs +1 -1
- package/dist/store/door.mjs +9 -4
- package/dist/store/errors.d.mts +2 -2
- package/dist/store/errors.mjs +107 -19
- package/dist/store/git-store.mjs +7 -2
- package/dist/store/job-try.mjs +90 -9
- package/dist/store/list-job.mjs +10 -34
- package/dist/store/outbox.d.mts +2 -2
- package/dist/store/outbox.mjs +2 -2
- package/dist/store/queue-jobs.mjs +6 -12
- package/dist/store/records.d.mts +2 -2
- package/dist/store/records.mjs +2 -2
- package/dist/store/ref-rows.d.mts +2 -2
- package/dist/store/ref-rows.mjs +2 -2
- package/dist/store/repo-record.d.mts +2 -2
- package/dist/store/repo-record.mjs +3 -3
- package/dist/store/request-snapshot.mjs +5 -0
- package/dist/store/reservations.mjs +2 -2
- package/dist/store/topic-jobs.mjs +5 -11
- package/dist/sync/bound.d.mts +3 -3
- package/dist/sync/bound.mjs +10 -7
- package/dist/sync/github.mjs +65 -67
- package/dist/sync/http.mjs +1 -1
- package/dist/sync/import.mjs +201 -66
- package/dist/sync/layer.d.mts +1 -1
- package/dist/sync/layer.mjs +6 -6
- package/dist/sync/lfs-batch.mjs +1 -1
- package/dist/sync/lfs-copy.mjs +175 -15
- package/dist/sync/mirror.mjs +5 -10
- package/dist/sync/said.mjs +1 -1
- package/dist/sync/step.mjs +268 -86
- package/dist/sync/tries.mjs +25 -6
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +2 -2
- package/dist/topics/advance.mjs +3 -3
- package/dist/topics/calls.mjs +1 -1
- package/dist/topics/layer.d.mts +15 -14
- package/dist/topics/members.mjs +1 -1
- package/dist/topics/topic.mjs +1 -1
- package/package.json +3 -13
- package/dist/auth/helpers.mjs +0 -17
- package/dist/auth.d.mts +0 -5
- package/dist/auth.mjs +0 -5
- package/dist/core/rules/commit-changes.d.mts +0 -12
- package/dist/effect.d.mts +0 -9
- package/dist/effect.mjs +0 -7
- package/dist/server/joined.d.mts +0 -70
- package/dist/server/joined.mjs +0 -41
package/dist/core/push.mjs
CHANGED
|
@@ -2,42 +2,41 @@ import { fail, gitError } from "../contracts/result.mjs";
|
|
|
2
2
|
import { openTreeBytes } from "../storage/budget.mjs";
|
|
3
3
|
import { scopedReceive, walkObjects } from "../storage/calls.mjs";
|
|
4
4
|
import { isUnindexedRead } from "../storage/index-visible.mjs";
|
|
5
|
+
import { walkedVisible } from "../storage/visible.mjs";
|
|
5
6
|
import { openTreesRefusal } from "../storage/push-allotment.mjs";
|
|
6
7
|
import { isLoose } from "../storage/loose.mjs";
|
|
7
8
|
import { listedIds } from "../storage/listed-ids.mjs";
|
|
8
|
-
import { indexRowKey, isPackId, objectCollections } from "../storage/layout.mjs";
|
|
9
|
+
import { indexRowKey, isPackId, objectCollections, pruneClearedKey } from "../storage/layout.mjs";
|
|
9
10
|
import { noLfsPointers } from "../storage/lfs-pointers.mjs";
|
|
10
11
|
import { isShallowRoot } from "../storage/links.mjs";
|
|
11
|
-
import {
|
|
12
|
+
import { repackJobKey, repackJobName } from "../storage/repack-job.mjs";
|
|
12
13
|
import { allottedRows } from "../storage/allotted.mjs";
|
|
13
14
|
import { chunkedOf } from "../storage/chunks.mjs";
|
|
14
15
|
import { gitObjectOf, headerOfRow, noRows, receivedObject, receivedRows } from "../storage/object-rows.mjs";
|
|
15
|
-
import { pruneClearedKey } from "../storage/prune.mjs";
|
|
16
16
|
import { abandonOwn } from "../storage/quarantine.mjs";
|
|
17
17
|
import { readyBytesOf, readyKey } from "../storage/ready.mjs";
|
|
18
18
|
import { QuarantineRow } from "../storage/rows.mjs";
|
|
19
19
|
import { promoteOwn } from "../storage/batch-upkeep.mjs";
|
|
20
|
-
import { abandonBatch, batchesRead, isStagedReceive, stagedBatchOf } from "../storage/batches.mjs";
|
|
21
|
-
import { bestEffort, decodeRow, fromInfra, storeCommit } from "../store/errors.mjs";
|
|
20
|
+
import { abandonBatch, batchesRead, isStagedReceive, stagedBatchOf, stagedOwnOf } from "../storage/batches.mjs";
|
|
21
|
+
import { bestEffort, decodeRow, fromInfra, storeCall, storeCommit } from "../store/errors.mjs";
|
|
22
22
|
import { callScope } from "../store/call-count.mjs";
|
|
23
23
|
import { decodePacks, gitStore } from "../store/git-store.mjs";
|
|
24
24
|
import { WholeRepo, refBytesOf, storesPeel, wholeRefs } from "../store/ref-rows.mjs";
|
|
25
25
|
import { dropBody } from "../protocol/bytes/reader.mjs";
|
|
26
|
-
import {
|
|
26
|
+
import { anyoneMoves, hiddenUnder, movesAsGitsOwn } from "../protocol/wire/lines.mjs";
|
|
27
27
|
import { sliceOf } from "../protocol/wire/push-limits.mjs";
|
|
28
28
|
import { pushCounts } from "./events/seen.mjs";
|
|
29
29
|
import { refViewIn } from "./ref-view.mjs";
|
|
30
30
|
import { appendEvents, decodeOutbox, firstSeq, outboxReads, repoEnvelope } from "../store/outbox.mjs";
|
|
31
31
|
import { rowsAtCommit } from "./loose-tally.mjs";
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import { HeldBy, decodeStats, heldUntil, looseRows, movedRoots, readRecord, repoStats, rootsMoved, rootsOf, timeRow } from "../store/repo-record.mjs";
|
|
32
|
+
import { LooseTally, PrunedMark } from "../store/records.mjs";
|
|
33
|
+
import { HeldBy, decodeStats, heldAdd, heldStore, heldUntil, looseRows, movedRoots, readRecord, repoStats, rootsMoved, rootsOf, timeRow } from "../store/repo-record.mjs";
|
|
35
34
|
import { advanceRow } from "../store/queue-jobs.mjs";
|
|
36
35
|
import { liveReservations, reservedTarget } from "../store/reservations.mjs";
|
|
37
36
|
import { settleName } from "../store/settle.mjs";
|
|
38
|
-
import { collections, newChangeId, prunedKey, pushedKey, pushedUnder, reachedKey, repoRootsKey, repoScope } from "../store/scopes.mjs";
|
|
37
|
+
import { collections, looseKey, newChangeId, prunedKey, pushedKey, pushedUnder, reachedKey, repoRootsKey, repoScope } from "../store/scopes.mjs";
|
|
39
38
|
import { headOf, indexJobs, openKeyed, openRepo, refIndexJobs, repoAccess } from "./access.mjs";
|
|
40
|
-
import { kindsOf } from "./ancestry.mjs";
|
|
39
|
+
import { ancestryLimit, kindsOf } from "./ancestry.mjs";
|
|
41
40
|
import { isRefName } from "./names.mjs";
|
|
42
41
|
import { runHookGroups } from "./hooks/groups.mjs";
|
|
43
42
|
import { Changes } from "./changes.mjs";
|
|
@@ -49,8 +48,8 @@ import { changedWhileChecked, factsHeld, tipsOf } from "./rules/facts.mjs";
|
|
|
49
48
|
import { clearsMark, decidePush, otherWritesProblem, pushOptionsProblem } from "./push-decide.mjs";
|
|
50
49
|
import { heldReceipt, receiptReads, receiptWrites, refsAnswer, refsKept, withJobs } from "./receipts.mjs";
|
|
51
50
|
import { SealedObjects, viewOf } from "./view.mjs";
|
|
51
|
+
import { notFailed } from "./events/deliver.mjs";
|
|
52
52
|
import { ownWriter, ownWritesOf } from "./own-writes.mjs";
|
|
53
|
-
import { ensureRepack } from "./repack.mjs";
|
|
54
53
|
import { publishable, unpublished } from "./publish.mjs";
|
|
55
54
|
import { peeledAll, peeledOf } from "../storage/wants.mjs";
|
|
56
55
|
import { CoreParts, ObjectsParts } from "./parts.mjs";
|
|
@@ -58,11 +57,11 @@ import { defaultPushFiles, filesChecked } from "./push-files.mjs";
|
|
|
58
57
|
import { addedBytes, defaultPushRepo, repoChecked } from "./push-repo.mjs";
|
|
59
58
|
import { Authorize, check } from "../contracts/authorize.mjs";
|
|
60
59
|
import { read } from "./objects/objects.mjs";
|
|
61
|
-
import
|
|
60
|
+
import { checkWrites, limits } from "@ref0/infra";
|
|
62
61
|
import * as Effect from "effect/Effect";
|
|
63
62
|
import * as Exit from "effect/Exit";
|
|
64
63
|
import * as Result from "effect/Result";
|
|
65
|
-
import
|
|
64
|
+
import * as Clock from "effect/Clock";
|
|
66
65
|
import * as Equal from "effect/Equal";
|
|
67
66
|
// src/core/push.ts
|
|
68
67
|
/**
|
|
@@ -71,6 +70,11 @@ import * as Equal from "effect/Equal";
|
|
|
71
70
|
* name it can't write is `unseenRef`'s, the same whatever is there.
|
|
72
71
|
*/
|
|
73
72
|
const pushWhole = /* @__PURE__ */ WholeRepo.mint();
|
|
73
|
+
/** How far a walk of what a ref's old tip reaches goes, past which a move's walk is refused. */
|
|
74
|
+
const judgedWalk = {
|
|
75
|
+
most: ancestryLimit,
|
|
76
|
+
commits: true
|
|
77
|
+
};
|
|
74
78
|
const packsRead = { collection: collections.packs };
|
|
75
79
|
const refsRead = { collection: collections.refs };
|
|
76
80
|
const timesRead = { collection: collections.stats };
|
|
@@ -206,7 +210,8 @@ const firstRead = (caller, operation, internalId) => openRepo(caller, {
|
|
|
206
210
|
}, [
|
|
207
211
|
packsRead,
|
|
208
212
|
prunedKey,
|
|
209
|
-
repoRootsKey
|
|
213
|
+
repoRootsKey,
|
|
214
|
+
looseKey
|
|
210
215
|
], internalId, "skip");
|
|
211
216
|
/** `firstRead` for a keyed push: `undefined` once `missed`'s repo moved, as `openKeyed` says. */
|
|
212
217
|
const keyedRead = (caller, operation, missed, internalId) => openKeyed(caller, {
|
|
@@ -215,7 +220,8 @@ const keyedRead = (caller, operation, missed, internalId) => openKeyed(caller, {
|
|
|
215
220
|
}, [
|
|
216
221
|
packsRead,
|
|
217
222
|
prunedKey,
|
|
218
|
-
repoRootsKey
|
|
223
|
+
repoRootsKey,
|
|
224
|
+
looseKey
|
|
219
225
|
], missed, internalId, "skip");
|
|
220
226
|
/**
|
|
221
227
|
* The first read's repo once `authorize` lets the caller push to it: its list, for the pack to be
|
|
@@ -238,6 +244,8 @@ const listedFor = /* @__PURE__ */ Effect.fnUntraced(function* (request, operatio
|
|
|
238
244
|
};
|
|
239
245
|
const mark = yield* markOf(resolved.snapshot.results[2] ?? []);
|
|
240
246
|
const roots = yield* rootsOf(resolved.snapshot.results[3]);
|
|
247
|
+
const [looseRow] = resolved.snapshot.results[4] ?? [];
|
|
248
|
+
const loose = looseRow === void 0 ? void 0 : yield* decodeRow(LooseTally, looseRow, "The repo's object rows' tally");
|
|
241
249
|
const views = yield* Effect.forEach(decidingFor(request), (one) => viewOf(one, resolved, request.as));
|
|
242
250
|
const [view = yield* viewOf(caller, resolved, request.as)] = views;
|
|
243
251
|
return {
|
|
@@ -245,6 +253,7 @@ const listedFor = /* @__PURE__ */ Effect.fnUntraced(function* (request, operatio
|
|
|
245
253
|
defaultBranch: headOf(resolved.record.defaultBranch),
|
|
246
254
|
mark,
|
|
247
255
|
roots,
|
|
256
|
+
hasLooseRows: (loose?.objects ?? 0) > 0,
|
|
248
257
|
repo,
|
|
249
258
|
view,
|
|
250
259
|
views,
|
|
@@ -291,13 +300,21 @@ const seenRefsOf = /* @__PURE__ */ Effect.fnUntraced(function* (view, listed, ro
|
|
|
291
300
|
*/
|
|
292
301
|
const pushedOf = (objects, listed, received) => {
|
|
293
302
|
if (received === void 0) return () => Effect.succeed(void 0);
|
|
294
|
-
const
|
|
303
|
+
const staged = stagedOwnOf(received.change);
|
|
304
|
+
const rows = staged === void 0 ? receivedRows(received.change) : void 0;
|
|
295
305
|
const own = {
|
|
296
306
|
...listed,
|
|
297
307
|
packs: received.change.add ?? []
|
|
298
308
|
};
|
|
299
309
|
return (input) => {
|
|
300
|
-
|
|
310
|
+
if (staged !== void 0) {
|
|
311
|
+
if (!staged.headers.has(input.oid)) return own.packs.length === 0 ? Effect.succeed(void 0) : objects.read(own, {
|
|
312
|
+
...input,
|
|
313
|
+
listedOnly: true
|
|
314
|
+
});
|
|
315
|
+
return Effect.flatMap(staged.readRow(input.oid), (row) => row === void 0 ? Effect.succeed(void 0) : Effect.map(receivedObject(received.change, row), gitObjectOf));
|
|
316
|
+
}
|
|
317
|
+
const row = rows?.get(input.oid);
|
|
301
318
|
if (row !== void 0) return Effect.map(receivedObject(received.change, row), gitObjectOf);
|
|
302
319
|
return own.packs.length === 0 ? Effect.succeed(void 0) : objects.read(own, {
|
|
303
320
|
...input,
|
|
@@ -310,35 +327,6 @@ const pushedOf = (objects, listed, received) => {
|
|
|
310
327
|
* reads one, its bytes let go unread. A read that fails throws, so the walk trusts nothing.
|
|
311
328
|
*/
|
|
312
329
|
const broughtCommit = (pushed) => (oid) => Effect.flatMap(pushed({ oid }), (object) => Effect.as(dropBody(object?.bytes), object?.type === "commit"));
|
|
313
|
-
/** The refs the repo mirrors, among `rows` of `mirrors`: each one an active mirror names, with its destination. */
|
|
314
|
-
const activeMirrors = /* @__PURE__ */ Effect.fnUntraced(function* (rows) {
|
|
315
|
-
const active = /* @__PURE__ */ new Map();
|
|
316
|
-
for (const row of rows) {
|
|
317
|
-
const mirror = yield* decodeRow(MirrorRow, row, `Mirror '${row.id}'`);
|
|
318
|
-
if (mirror.state === "active") active.set(row.id, mirror.destination);
|
|
319
|
-
}
|
|
320
|
-
return active;
|
|
321
|
-
});
|
|
322
|
-
/**
|
|
323
|
-
* `sync.mirror`'s row for each destination an active mirror of a ref the commit moves names, one
|
|
324
|
-
* however many of its refs move, found by name among the jobs the server knows: none until
|
|
325
|
-
* `Sync.layer` has bound them.
|
|
326
|
-
*/
|
|
327
|
-
const mirrorJobs = (core, moved, mirrored) => {
|
|
328
|
-
const definition = core.jobOf?.(mirrorJobName);
|
|
329
|
-
if (definition === void 0) return [];
|
|
330
|
-
const jobs = /* @__PURE__ */ new Map();
|
|
331
|
-
for (const { ref } of moved) {
|
|
332
|
-
const destination = mirrored.get(ref);
|
|
333
|
-
if (destination === void 0) continue;
|
|
334
|
-
const key = mirrorJobKey(destination);
|
|
335
|
-
jobs.set(key, definition.job({
|
|
336
|
-
key,
|
|
337
|
-
data: { destination }
|
|
338
|
-
}));
|
|
339
|
-
}
|
|
340
|
-
return [...jobs.values()];
|
|
341
|
-
};
|
|
342
330
|
/** The repo's stored packs and the received pack's, before the commit lists it: a push's changes read both. */
|
|
343
331
|
const withReceived = (listed, received) => received === void 0 ? listed : {
|
|
344
332
|
...listed,
|
|
@@ -347,26 +335,37 @@ const withReceived = (listed, received) => received === void 0 ? listed : {
|
|
|
347
335
|
/** The objects, with the rows a receive puts read first: they're written only by the commit. */
|
|
348
336
|
const withReceivedRows = (objects, received) => {
|
|
349
337
|
const change = received?.change;
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
338
|
+
const staged = stagedOwnOf(change);
|
|
339
|
+
const rows = staged === void 0 ? receivedRows(change) : void 0;
|
|
340
|
+
const hasOwn = (oid) => staged !== void 0 ? staged.headers.has(oid) : rows?.has(oid) ?? false;
|
|
341
|
+
if ((staged !== void 0 ? staged.headers.size : rows?.size ?? 0) === 0) return objects;
|
|
342
|
+
const rowOf = (oid) => staged !== void 0 ? staged.readRow(oid) : Effect.succeed(rows?.get(oid));
|
|
343
|
+
const rowsOf = (before) => Effect.fnUntraced(function* (oids, each) {
|
|
344
|
+
const fetched = staged !== void 0 ? yield* staged.readRows(oids) : oids.map((oid) => rows?.get(oid));
|
|
345
|
+
for (const [index, oid] of oids.entries()) {
|
|
346
|
+
const row = fetched[index];
|
|
347
|
+
if (row === void 0) continue;
|
|
348
|
+
const chunked = chunkedOf(row.value);
|
|
349
|
+
if (chunked !== void 0 && before !== void 0 && !(yield* before(oid, chunked.size))) continue;
|
|
350
|
+
yield* each(yield* receivedObject(change, row));
|
|
351
|
+
}
|
|
352
|
+
});
|
|
359
353
|
return {
|
|
360
354
|
...objects,
|
|
361
355
|
read: (listed, input) => {
|
|
362
|
-
|
|
363
|
-
return row === void 0 ? objects.read(listed, input) : Effect.map(receivedObject(change, row), gitObjectOf);
|
|
356
|
+
if (!hasOwn(input.oid)) return objects.read(listed, input);
|
|
357
|
+
return Effect.flatMap(rowOf(input.oid), (row) => row === void 0 ? objects.read(listed, input) : Effect.map(receivedObject(change, row), gitObjectOf));
|
|
364
358
|
},
|
|
365
359
|
headers: Effect.fnUntraced(function* (listed, input) {
|
|
366
360
|
const answer = /* @__PURE__ */ new Map();
|
|
367
|
-
const stored = input.oids.filter((oid) => !
|
|
361
|
+
const stored = input.oids.filter((oid) => !hasOwn(oid));
|
|
368
362
|
for (const oid of input.oids) {
|
|
369
|
-
|
|
363
|
+
if (staged !== void 0) {
|
|
364
|
+
const header = staged.headers.get(oid);
|
|
365
|
+
if (header !== void 0) answer.set(oid, header);
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
const row = rows?.get(oid);
|
|
370
369
|
if (row === void 0) continue;
|
|
371
370
|
answer.set(oid, yield* headerOfRow(row));
|
|
372
371
|
}
|
|
@@ -379,17 +378,17 @@ const withReceivedRows = (objects, received) => {
|
|
|
379
378
|
objects: Effect.fnUntraced(function* (listed, input) {
|
|
380
379
|
const asked = [...new Set(input.oids)];
|
|
381
380
|
const [first] = asked;
|
|
382
|
-
if (first === void 0 || !asked.some(
|
|
381
|
+
if (first === void 0 || !asked.some(hasOwn)) return yield* objects.objects(listed, {
|
|
383
382
|
...input,
|
|
384
383
|
oids: asked
|
|
385
384
|
});
|
|
386
|
-
const fromRows =
|
|
387
|
-
const own = asked.filter((oid) =>
|
|
385
|
+
const fromRows = hasOwn(first);
|
|
386
|
+
const own = asked.filter((oid) => hasOwn(oid) === fromRows);
|
|
388
387
|
const answered = fromRows ? yield* allottedRows(rowsOf, own, input.bytes) : yield* objects.objects(listed, {
|
|
389
388
|
...input,
|
|
390
389
|
oids: own
|
|
391
390
|
});
|
|
392
|
-
const left = /* @__PURE__ */ new Set([...answered.left, ...asked.filter((oid) =>
|
|
391
|
+
const left = /* @__PURE__ */ new Set([...answered.left, ...asked.filter((oid) => hasOwn(oid) !== fromRows)]);
|
|
393
392
|
return {
|
|
394
393
|
objects: answered.objects,
|
|
395
394
|
left: asked.filter((oid) => left.has(oid))
|
|
@@ -441,7 +440,8 @@ const buildFence = (build) => [
|
|
|
441
440
|
* answers, it fails, to be sent again (Q270). `changed`: whether a row of a build's fence,
|
|
442
441
|
* `unchanged`, holds another value than its plan read.
|
|
443
442
|
*/
|
|
444
|
-
const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (
|
|
443
|
+
const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (core, repo, fence, received, kept, mark, branches, touched, guard, unchanged = [], countPuts = true) {
|
|
444
|
+
const { store } = core;
|
|
445
445
|
const own = received?.quarantine === void 0 ? [] : [received.quarantine];
|
|
446
446
|
const batched = isStagedReceive(received) ? [batchesRead] : [];
|
|
447
447
|
const keyed = receiptReads(kept);
|
|
@@ -450,10 +450,16 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
|
|
|
450
450
|
id
|
|
451
451
|
}));
|
|
452
452
|
const linkedRows = received?.linked?.rows ?? [];
|
|
453
|
-
const rowCounts = linkedRows.map((
|
|
453
|
+
const rowCounts = linkedRows.map((prefix) => ({
|
|
454
454
|
collection: objectCollections.objects,
|
|
455
|
-
prefix
|
|
455
|
+
prefix
|
|
456
456
|
}));
|
|
457
|
+
if (countPuts) {
|
|
458
|
+
for (const { collection, id } of received?.change.put ?? []) if (rowCounts.length < limits.counts && collection === objectCollections.objects) rowCounts.push({
|
|
459
|
+
collection,
|
|
460
|
+
prefix: id
|
|
461
|
+
});
|
|
462
|
+
}
|
|
457
463
|
const { record, snapshot } = yield* readRecord(store, repo.internalId, [
|
|
458
464
|
refsRead,
|
|
459
465
|
...outboxReads,
|
|
@@ -508,7 +514,7 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
|
|
|
508
514
|
const refs = yield* wholeRefs(pushWhole, refRows);
|
|
509
515
|
const outbox = yield* decodeOutbox([headRows, cursorRows]);
|
|
510
516
|
const held = ownRow === void 0 ? void 0 : yield* decodeRow(QuarantineRow, ownRow, `The push's quarantine row '${ownRow.id}'`);
|
|
511
|
-
const
|
|
517
|
+
const mirrorJobs = core.mirrorJobs === void 0 || core.jobOf === void 0 ? void 0 : yield* core.mirrorJobs(mirrorRows, core.jobOf);
|
|
512
518
|
const revoked = yield* Effect.match(fence.check(fenced), {
|
|
513
519
|
onFailure: (error) => error,
|
|
514
520
|
onSuccess: () => void 0
|
|
@@ -547,7 +553,7 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
|
|
|
547
553
|
receipt,
|
|
548
554
|
outbox,
|
|
549
555
|
record,
|
|
550
|
-
|
|
556
|
+
mirrorJobs,
|
|
551
557
|
facts,
|
|
552
558
|
stats,
|
|
553
559
|
times,
|
|
@@ -555,6 +561,7 @@ const finalRead = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, fenc
|
|
|
555
561
|
reserved,
|
|
556
562
|
indexRow,
|
|
557
563
|
changed,
|
|
564
|
+
counts: snapshot.counts.slice(linkedRows.length),
|
|
558
565
|
roots: yield* rootsOf(rootRows)
|
|
559
566
|
};
|
|
560
567
|
});
|
|
@@ -566,16 +573,17 @@ const settingsOf = (record) => ({
|
|
|
566
573
|
/** The rules, the registrations' checks, then the hook groups, once, at the first read the push decides on. */
|
|
567
574
|
const runChecks = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input, facts) {
|
|
568
575
|
const context = checking(input);
|
|
569
|
-
const ruled = yield*
|
|
576
|
+
const ruled = yield* runPushRules(checks, input, context);
|
|
577
|
+
const refused = yield* registeredAfter(checks, input, ruled.updates, ruled.refused);
|
|
570
578
|
const whole = yield* runHookGroups(checks.groups?.() ?? [], context, {
|
|
571
579
|
atomic: input.atomic,
|
|
572
580
|
updates: ruled.updates,
|
|
573
|
-
refused
|
|
581
|
+
refused
|
|
574
582
|
});
|
|
575
583
|
const checked = {
|
|
576
584
|
facts,
|
|
577
585
|
updates: ruled.updates,
|
|
578
|
-
refused
|
|
586
|
+
refused,
|
|
579
587
|
filesAllowed: ruled.filesAllowed,
|
|
580
588
|
bypassed: ruled.bypassed
|
|
581
589
|
};
|
|
@@ -622,20 +630,18 @@ const checkAll = /* @__PURE__ */ Effect.fnUntraced(function* (checks, request, i
|
|
|
622
630
|
};
|
|
623
631
|
});
|
|
624
632
|
/**
|
|
625
|
-
*
|
|
626
|
-
* then registration name, on the refs none before it refused, so a ref's first
|
|
633
|
+
* `before`, the refusals so far, with the refs among `updates` the registered checks refuse: each in
|
|
634
|
+
* turn, by band then registration name, on the refs none before it refused, so a ref's first
|
|
635
|
+
* refusal is its answer.
|
|
627
636
|
*/
|
|
628
|
-
const registeredAfter = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input,
|
|
629
|
-
const refused = new Map(
|
|
637
|
+
const registeredAfter = /* @__PURE__ */ Effect.fnUntraced(function* (checks, input, moved, before) {
|
|
638
|
+
const refused = new Map(before);
|
|
630
639
|
for (const { handler } of checks.registered?.() ?? []) {
|
|
631
|
-
const updates =
|
|
640
|
+
const updates = moved.filter((update) => !refused.has(update.ref));
|
|
632
641
|
if (updates.length === 0) break;
|
|
633
642
|
for (const [ref, error] of yield* handler(input, updates)) if (!refused.has(ref)) refused.set(ref, error);
|
|
634
643
|
}
|
|
635
|
-
return
|
|
636
|
-
...ruled,
|
|
637
|
-
refused
|
|
638
|
-
};
|
|
644
|
+
return refused;
|
|
639
645
|
});
|
|
640
646
|
/** Whether a push has anything to check: a rule, a registered check, or a hook group. */
|
|
641
647
|
const checksOf = /* @__PURE__ */ Effect.fnUntraced(function* (core) {
|
|
@@ -816,7 +822,7 @@ const unindexedPush = () => gitError("RESOURCE_EXHAUSTED", "This push can't be c
|
|
|
816
822
|
/** `error`, a read by ID the index can't close yet told as the push's own. */
|
|
817
823
|
const asPushCheck = (error) => isUnindexedRead(error) ? unindexedPush() : error;
|
|
818
824
|
/** The request's pack into its quarantine, or `undefined` for a push with none. */
|
|
819
|
-
const receive = (objects, listed, request) => {
|
|
825
|
+
const receive = (objects, listed, request, hasLooseRows) => {
|
|
820
826
|
const { pack, shallow, signal } = request;
|
|
821
827
|
if (pack === void 0) return Effect.succeed({
|
|
822
828
|
received: void 0,
|
|
@@ -832,7 +838,8 @@ const receive = (objects, listed, request) => {
|
|
|
832
838
|
});
|
|
833
839
|
const input = {
|
|
834
840
|
pack: pack.bytes,
|
|
835
|
-
objects: pack.objects
|
|
841
|
+
objects: pack.objects,
|
|
842
|
+
hasLooseRows
|
|
836
843
|
};
|
|
837
844
|
if (pack.length !== void 0) input.length = pack.length;
|
|
838
845
|
if (pack.atMost !== void 0) input.atMost = pack.atMost;
|
|
@@ -897,7 +904,7 @@ const lists = (body, own) => body.delete.some((key) => key.collection === own.co
|
|
|
897
904
|
* only, refused as the commit would be, its `writes` or none, and answered before it, for
|
|
898
905
|
* `checkPush`: nothing before that point writes, reserves or enqueues, with no pack.
|
|
899
906
|
*/
|
|
900
|
-
const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRepo, view, views, heldAt }, key, answers, checking = false) => Effect.scoped(Effect.gen(function* () {
|
|
907
|
+
const pushOnto = (request, { listed, defaultBranch, mark, roots, hasLooseRows, repo: checkedRepo, view, views, heldAt }, key, answers, checking = false) => Effect.scoped(Effect.gen(function* () {
|
|
901
908
|
const core = yield* CoreParts;
|
|
902
909
|
const { objects: sealed, fetchLimits, files = defaultPushFiles, repo: repoSizes = defaultPushRepo } = yield* ObjectsParts;
|
|
903
910
|
const authorize = yield* Authorize;
|
|
@@ -908,7 +915,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
|
|
|
908
915
|
const { received, rooted } = yield* receive(yield* read({
|
|
909
916
|
view,
|
|
910
917
|
at: seen
|
|
911
|
-
}), listed, request).pipe(Effect.provideService(HeldBy, heldUntil(heldAt, fetchLimits)), Effect.tapError((error) => isAwaitingUpkeep(error) ? bestEffort(ensureRepack(core, core.jobs, listed.repo, fetchLimits)) : Effect.void), Effect.mapError(asPushCheck));
|
|
918
|
+
}), listed, request, hasLooseRows).pipe(Effect.provideService(HeldBy, heldUntil(heldAt, fetchLimits)), Effect.tapError((error) => isAwaitingUpkeep(error) ? bestEffort(ensureRepack(core, core.jobs, listed.repo, fetchLimits)) : Effect.void), Effect.mapError(asPushCheck));
|
|
912
919
|
const ownedPack = ownPack(request, received);
|
|
913
920
|
let listing = false;
|
|
914
921
|
if (ownedPack !== void 0) yield* Effect.addFinalizer((exit) => listing || Exit.hasInterrupts(exit) ? Effect.void : Effect.flatMap(Clock.currentTimeMillis, (at) => abandonOwn({
|
|
@@ -995,7 +1002,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
|
|
|
995
1002
|
});
|
|
996
1003
|
const headsOf = (edit) => edit.to === null ? void 0 : request.publishes?.get(edit.ref);
|
|
997
1004
|
const publishedAt = Effect.fnUntraced(function* (refs, at, index) {
|
|
998
|
-
const plain = request.edits.filter((edit) => headsOf(edit) === void 0);
|
|
1005
|
+
const plain = request.edits.filter((edit) => headsOf(edit) === void 0 && !movesAsGitsOwn(hidden, request.as, edit.ref));
|
|
999
1006
|
const refused = new Map(yield* unpublishedAt(refs, at, index, refView, plain, ownOf));
|
|
1000
1007
|
for (const edit of request.edits) {
|
|
1001
1008
|
const heads = headsOf(edit);
|
|
@@ -1038,9 +1045,10 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
|
|
|
1038
1045
|
const fence = fenceAll(request, decidingFor(request).map((one) => core.fences(one, target)));
|
|
1039
1046
|
const ready = objects.readyShallow && request.edits.some((edit) => edit.ref === defaultBranch || edit.ref.startsWith("refs/tags/"));
|
|
1040
1047
|
const jobs = (received?.change.add?.length ?? 0) > 0 || isStagedReceive(received) || ready ? [core.repackJobRow()] : [];
|
|
1041
|
-
const own = updates.filter((update) =>
|
|
1042
|
-
const outside = updates.filter((update) => !
|
|
1043
|
-
const
|
|
1048
|
+
const own = updates.filter((update) => movesAsGitsOwn(hidden, request.as, update.ref));
|
|
1049
|
+
const outside = updates.filter((update) => !movesAsGitsOwn(hidden, request.as, update.ref));
|
|
1050
|
+
const segments = own.filter((update) => anyoneMoves(hidden, update.ref));
|
|
1051
|
+
const checks = outside.length === 0 && segments.length === 0 ? void 0 : yield* checksOf(core);
|
|
1044
1052
|
const branches = request.source === "queue" ? [] : outside.map((update) => update.ref).filter((ref) => ref.startsWith("refs/heads/") && isRefName(ref));
|
|
1045
1053
|
const touched = updates.map(({ ref }) => ref).filter(isRefName);
|
|
1046
1054
|
const scope = yield* callScope;
|
|
@@ -1088,14 +1096,14 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
|
|
|
1088
1096
|
let checked;
|
|
1089
1097
|
for (let tries = 0; tries < 10; tries += 1) {
|
|
1090
1098
|
const at = yield* Clock.currentTimeMillis;
|
|
1091
|
-
const decide = yield* finalRead(
|
|
1092
|
-
const { read, receipt, outbox, record,
|
|
1099
|
+
const decide = yield* finalRead(core, target, fence, received, key, mark, branches, touched, request.guard, request.writes?.unchanged, tries > 0 || hasLooseRows);
|
|
1100
|
+
const { read, receipt, outbox, record, mirrorJobs, facts, stats, times, queued, reserved, indexRow } = decide;
|
|
1093
1101
|
const indexed = SealedObjects.whole(sealed, pushWhole).index?.status(indexRow, at, listedIds(decide.at, received?.change));
|
|
1094
1102
|
if (receipt !== void 0) return yield* answers.held(receipt);
|
|
1095
1103
|
const published = yield* publishedAt(read.refs, decide.at, indexRow);
|
|
1096
1104
|
const { writes } = request;
|
|
1097
1105
|
if (writes !== void 0 && (writes.unchanged === void 0 ? read.version !== writes.version : decide.changed)) return yield* Effect.fail(queueMoved(repo));
|
|
1098
|
-
const rowsMoved = received === void 0 ? noRows : yield* rowsAtCommit(store, listed.repo, received.change, read.version);
|
|
1106
|
+
const rowsMoved = received === void 0 ? noRows : (times.loose?.objects ?? 0) === 0 ? received.change.rows : yield* rowsAtCommit(store, listed.repo, received.change, read.version, decide.counts);
|
|
1099
1107
|
if (rowsMoved === void 0) continue;
|
|
1100
1108
|
const added = addedBytes(received?.change, rowsMoved);
|
|
1101
1109
|
const sized = repoChecked(repoSizes, stats.ownBytes, added);
|
|
@@ -1120,17 +1128,34 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
|
|
|
1120
1128
|
...changing,
|
|
1121
1129
|
signal: unaborted
|
|
1122
1130
|
};
|
|
1123
|
-
|
|
1131
|
+
judging.reach = (tips) => SealedObjects.visibleWhole(sealed, pushWhole, decide.at, {
|
|
1132
|
+
tips,
|
|
1133
|
+
row: indexRow?.value,
|
|
1134
|
+
roots
|
|
1135
|
+
}, () => walkedVisible(whole, decide.at, {
|
|
1136
|
+
tips,
|
|
1137
|
+
roots
|
|
1138
|
+
}, judgedWalk));
|
|
1139
|
+
judging.roots = roots;
|
|
1140
|
+
if (by !== void 0) judging.covered = coveredTips(read.refs, (ref) => by.covers(ref) && !movesAsGitsOwn(hidden, request.as, ref));
|
|
1124
1141
|
if (by !== void 0) judging.refuses = by.refuses;
|
|
1125
1142
|
if (by?.covers(read.head) === true) judging.defaultTip = read.refs.get(read.head);
|
|
1126
1143
|
return commitChangesOf(judging, updates);
|
|
1127
1144
|
}
|
|
1128
1145
|
};
|
|
1129
|
-
|
|
1146
|
+
const ruled = outside.length === 0 ? void 0 : yield* checkAll(checks, request, input, seen, (one) => (operation) => authorize.check({
|
|
1130
1147
|
caller: one,
|
|
1131
1148
|
operation,
|
|
1132
1149
|
repo: checkedRepo
|
|
1133
1150
|
}));
|
|
1151
|
+
checked = {
|
|
1152
|
+
facts: seen,
|
|
1153
|
+
updates: [],
|
|
1154
|
+
filesAllowed: /* @__PURE__ */ new Map(),
|
|
1155
|
+
bypassed: /* @__PURE__ */ new Map(),
|
|
1156
|
+
...ruled,
|
|
1157
|
+
refused: yield* registeredAfter(checks, input, segments, ruled?.refused ?? input.refused)
|
|
1158
|
+
};
|
|
1134
1159
|
} else if (checked !== void 0 && !factsHeld(checked.facts, seen)) return yield* Effect.fail(changedWhileChecked());
|
|
1135
1160
|
if (checked?.whole !== void 0) return yield* Effect.fail(checked.whole);
|
|
1136
1161
|
const decided = checked === void 0 ? {
|
|
@@ -1183,7 +1208,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
|
|
|
1183
1208
|
if (yield* settleName(store, scope, settling)) continue;
|
|
1184
1209
|
const envelope = repoEnvelope(caller, name);
|
|
1185
1210
|
const id = newChangeId();
|
|
1186
|
-
const shown = planned.moved.filter((move) => !
|
|
1211
|
+
const shown = planned.moved.filter((move) => !movesAsGitsOwn(core.hiddenRefs(), request.as, move.ref));
|
|
1187
1212
|
const optionsPast = pushOptionsProblem(request.pushOptions, shown.length);
|
|
1188
1213
|
if (optionsPast !== void 0) return yield* Effect.fail(optionsPast);
|
|
1189
1214
|
const push = pushOf(core.access, id, shown, request);
|
|
@@ -1212,6 +1237,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
|
|
|
1212
1237
|
const pushed = pushedRows(core.access, shown, times, at);
|
|
1213
1238
|
const moved = planned.moves ? rowsMoved : noRows;
|
|
1214
1239
|
const loose = looseRows(times.loose, moved);
|
|
1240
|
+
const foldLoose = moved.bytes > 0 && (loose[0]?.value.bytes ?? 0) > 16777216 ? [core.repackJobRow()] : [];
|
|
1215
1241
|
const body = {
|
|
1216
1242
|
id,
|
|
1217
1243
|
expect: planned.expect,
|
|
@@ -1233,7 +1259,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
|
|
|
1233
1259
|
jobs: withJobs([
|
|
1234
1260
|
...planned.jobs,
|
|
1235
1261
|
...appended.jobs,
|
|
1236
|
-
...mirrorJobs(
|
|
1262
|
+
...mirrorJobs?.(planned.moved) ?? [],
|
|
1237
1263
|
...writes?.jobs ?? [],
|
|
1238
1264
|
...woken,
|
|
1239
1265
|
...shown.length > 0 ? indexJobs(core, indexed) : [],
|
|
@@ -1241,7 +1267,8 @@ const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRe
|
|
|
1241
1267
|
], [
|
|
1242
1268
|
...kept.jobs,
|
|
1243
1269
|
...also?.jobs ?? [],
|
|
1244
|
-
...rooted?.jobs ?? []
|
|
1270
|
+
...rooted?.jobs ?? [],
|
|
1271
|
+
...foldLoose
|
|
1245
1272
|
])
|
|
1246
1273
|
};
|
|
1247
1274
|
const objects = (received?.change.put?.length ?? 0) + (received?.change.delete?.length ?? 0);
|
|
@@ -1338,4 +1365,24 @@ const keyedPushWith = /* @__PURE__ */ Effect.fnUntraced(function* (request, answ
|
|
|
1338
1365
|
});
|
|
1339
1366
|
/** `keyedPushWith` for `refs.update`, answering the decide's ref answer. */
|
|
1340
1367
|
const keyedPush = (request, keyed) => keyedPushWith(request, refsAnswers, keyed);
|
|
1341
|
-
|
|
1368
|
+
/**
|
|
1369
|
+
* Whether `error` refuses a push until upkeep runs, by its reason: `awaitingRepack`'s, or
|
|
1370
|
+
* `awaitingUpkeep`'s for a repo whose published batches are at `batchesMost`.
|
|
1371
|
+
*/
|
|
1372
|
+
const isAwaitingUpkeep = (error) => error.code === "UNAVAILABLE" && (error.context?.reason === "packs-awaiting-repack" || error.context?.reason === "batches-awaiting-upkeep");
|
|
1373
|
+
/**
|
|
1374
|
+
* The repo's `git.repack` row made due, for a push refused `packs-awaiting-repack`, so its hint
|
|
1375
|
+
* holds: added if it's gone, and retried if it spent its tries, since an add leaves a failed row
|
|
1376
|
+
* failed, its data rebuilt once it has compacted. A row already waiting or running is left as it is.
|
|
1377
|
+
* A repo deleted since the push read it takes none, as its purge may have dropped its scope (#1911).
|
|
1378
|
+
*/
|
|
1379
|
+
const ensureRepack = /* @__PURE__ */ Effect.fnUntraced(function* (core, jobs, repo, fetchLimits) {
|
|
1380
|
+
if (!(yield* heldAdd(heldStore(core.store), repo, fetchLimits, { jobs: [core.repackJobRow()] }).pipe(Effect.as(true), Effect.catchTag("RepoGone", () => Effect.succeed(false))))) return;
|
|
1381
|
+
const scope = repoScope(repo);
|
|
1382
|
+
const job = {
|
|
1383
|
+
name: repackJobName,
|
|
1384
|
+
key: repackJobKey
|
|
1385
|
+
};
|
|
1386
|
+
yield* storeCall(jobs.retry(scope, job)).pipe(Effect.catchIf(notFailed, () => Effect.void));
|
|
1387
|
+
});
|
|
1388
|
+
export { buildFence, checkPush, ensureRepack, gitPush, isQueueMoved, keyedGitPush, 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 { JobInput, Key, Moment, Read, Row } from "@ref0/infra";
|
|
7
7
|
import "effect/Schema";
|
|
8
|
-
import
|
|
8
|
+
import "effect/Effect";
|
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 Effect from "effect/Effect";
|
|
6
5
|
import * as Schema from "effect/Schema";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
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
|
|
@@ -63,7 +63,13 @@ const KeptAnswer = /* @__PURE__ */ Schema.Union([
|
|
|
63
63
|
answer: Schema.Json
|
|
64
64
|
}),
|
|
65
65
|
Schema.Struct({ kind: Schema.Literal("done") }),
|
|
66
|
-
Schema.Struct({ kind: Schema.Literal("fork") })
|
|
66
|
+
Schema.Struct({ kind: Schema.Literal("fork") }),
|
|
67
|
+
Schema.Struct({
|
|
68
|
+
kind: Schema.Literal("deepen"),
|
|
69
|
+
run: Schema.String,
|
|
70
|
+
info: Schema.optionalKey(KeptRepoInfo),
|
|
71
|
+
error: Schema.optionalKey(KeptError)
|
|
72
|
+
})
|
|
67
73
|
]);
|
|
68
74
|
/**
|
|
69
75
|
* A keyed write's receipt, in the scope it wrote, saved in the write's own commit: the input its
|
|
@@ -260,6 +266,7 @@ const receiptAnswered = (held) => {
|
|
|
260
266
|
case "queue":
|
|
261
267
|
case "done": return true;
|
|
262
268
|
case "fork": return true;
|
|
269
|
+
case "deepen": return held.answer.info !== void 0 || held.answer.error !== void 0;
|
|
263
270
|
}
|
|
264
271
|
};
|
|
265
272
|
/** The answer a repo create, update or rename's receipt kept, for the write sent again. */
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { storeCommit } from "../store/errors.mjs";
|
|
2
|
-
import { currentRepo, gitJob } from "../store/job-try.mjs";
|
|
2
|
+
import { currentRepo, gitJob, jobTryTimeout } 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 * as Effect from "effect/Effect";
|
|
7
|
-
import * as Schema from "effect/Schema";
|
|
8
6
|
import { Job } from "@ref0/infra";
|
|
7
|
+
import * as Schema from "effect/Schema";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
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
|
|
@@ -157,7 +157,7 @@ const rebuildTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
|
|
|
157
157
|
const rebuildFailed = (_data, failure) => Effect.flatMap(currentRepo, (repo) => Effect.logError(`git.ref-index left repo ${repo}'s ref index stale: ${failure.error instanceof Error ? failure.error.message : String(failure.error)}`));
|
|
158
158
|
const RefIndexJob = /* @__PURE__ */ Job.make(refIndexJobName, {
|
|
159
159
|
payload: RefIndexJobData,
|
|
160
|
-
timeout:
|
|
160
|
+
timeout: jobTryTimeout,
|
|
161
161
|
retry: {
|
|
162
162
|
limit: 10,
|
|
163
163
|
delay: "1 second",
|