@ref0/git 0.14.0 → 0.20.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/auth/access-jwt.mjs +2 -2
- package/dist/auth/authorize.mjs +3 -3
- package/dist/auth/fences.d.mts +1 -2
- package/dist/auth/fences.mjs +3 -3
- package/dist/auth/grants.mjs +4 -4
- package/dist/auth/host-function.mjs +18 -1
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +3 -3
- package/dist/auth/token-cleanup.mjs +67 -0
- package/dist/auth/token-rows.mjs +1 -1
- package/dist/auth/token-text.mjs +9 -1
- package/dist/auth/tokens-base.d.mts +35 -0
- package/dist/auth/tokens-base.mjs +13 -0
- package/dist/auth/tokens-layer.d.mts +2 -27
- package/dist/auth/tokens-layer.mjs +6 -11
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +7 -10
- package/dist/auth/tokens.mjs +9 -80
- package/dist/client/answer.mjs +21 -42
- package/dist/client/client.d.mts +2 -4
- package/dist/client/git-http.mjs +17 -7
- package/dist/client/local.mjs +14 -13
- package/dist/client/push-upload.mjs +9 -8
- package/dist/client/remote.mjs +8 -10
- package/dist/client/run-remote-helper.d.mts +1 -0
- package/dist/client/run-remote-helper.mjs +58 -24
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +105 -46
- package/dist/contracts/blobs.d.mts +55 -8
- package/dist/contracts/blobs.mjs +16 -2
- package/dist/contracts/call-allowance.d.mts +13 -0
- package/dist/contracts/call-allowance.mjs +44 -0
- package/dist/contracts/calls-spent.mjs +8 -3
- package/dist/contracts/client.d.mts +15 -16
- package/dist/contracts/commits.d.mts +24 -24
- package/dist/contracts/engine.d.mts +6 -1
- package/dist/contracts/engine.mjs +10 -1
- package/dist/contracts/files.d.mts +10 -10
- package/dist/contracts/forks.d.mts +17 -17
- package/dist/contracts/git-events.d.mts +29 -1
- package/dist/contracts/git-hooks.d.mts +1 -1
- package/dist/contracts/git.d.mts +21 -0
- package/dist/contracts/grants.d.mts +24 -4
- package/dist/contracts/handlers.d.mts +1 -1
- package/dist/contracts/lfs.d.mts +28 -2
- package/dist/contracts/merges.d.mts +3 -2
- package/dist/contracts/objects.d.mts +23 -25
- package/dist/contracts/queue.d.mts +40 -12
- package/dist/contracts/queue.mjs +3 -4
- package/dist/contracts/refs.d.mts +26 -23
- package/dist/contracts/remote.d.mts +6 -7
- package/dist/contracts/remote.mjs +4 -1
- package/dist/contracts/repos.d.mts +29 -138
- package/dist/contracts/repos.mjs +5 -3
- package/dist/contracts/result.d.mts +35 -16
- package/dist/contracts/result.mjs +35 -7
- package/dist/contracts/server.d.mts +25 -50
- package/dist/contracts/services.d.mts +1 -1
- package/dist/contracts/store.d.mts +6 -5
- package/dist/contracts/sync.d.mts +11 -7
- package/dist/contracts/sync.mjs +12 -2
- package/dist/contracts/tags.d.mts +10 -10
- package/dist/contracts/time.d.mts +3 -0
- package/dist/contracts/{promises.mjs → time.mjs} +1 -1
- package/dist/contracts/tokens.d.mts +15 -17
- package/dist/contracts/tokens.mjs +3 -2
- package/dist/contracts/topics.d.mts +1 -1
- package/dist/contracts/trees.d.mts +12 -12
- package/dist/contracts/work.d.mts +24 -13
- package/dist/core/access.d.mts +1 -2
- package/dist/core/access.mjs +20 -9
- package/dist/core/ancestry.d.mts +1 -0
- package/dist/core/asked.mjs +1 -1
- package/dist/core/call-names.mjs +6 -1
- package/dist/core/call-services.mjs +11 -3
- package/dist/core/events/deliver.d.mts +1 -2
- package/dist/core/events/deliver.mjs +43 -36
- package/dist/core/events/retired.mjs +119 -0
- package/dist/core/forks.mjs +928 -432
- package/dist/core/hooks/groups.mjs +1 -1
- package/dist/core/imports.mjs +29 -23
- package/dist/core/index-job.mjs +122 -34
- package/dist/core/index-lost.d.mts +1 -2
- package/dist/core/index-lost.mjs +2 -2
- package/dist/core/loose-tally.mjs +1 -1
- package/dist/core/objects/blobs.mjs +129 -3
- package/dist/core/objects/lines.mjs +2 -2
- package/dist/core/objects/merges.mjs +4 -1
- package/dist/core/objects/objects-layer.d.mts +1 -1
- package/dist/core/objects/objects-layer.mjs +3 -3
- package/dist/core/objects/reading.mjs +24 -13
- package/dist/core/objects/tags.mjs +4 -1
- package/dist/core/objects/trees.mjs +2 -2
- package/dist/core/objects/writing.mjs +2 -2
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +4 -5
- package/dist/core/parts.mjs +3 -8
- package/dist/core/promise.mjs +9 -12
- package/dist/core/purge.mjs +287 -83
- package/dist/core/push-decide.mjs +2 -0
- package/dist/core/push-files.d.mts +1 -1
- package/dist/core/push.mjs +58 -47
- package/dist/core/receipts.mjs +8 -3
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +2 -2
- package/dist/core/refs.mjs +5 -5
- package/dist/core/registered-rows.mjs +2 -2
- package/dist/core/repack.mjs +36 -21
- package/dist/core/repo-info.mjs +3 -3
- package/dist/core/repos.mjs +21 -9
- package/dist/core/rules/commit-changes.d.mts +0 -1
- package/dist/core/saved-caller-views.d.mts +7 -2
- package/dist/core/saved-caller-views.mjs +2 -2
- package/dist/core/saved-callers.d.mts +19 -2
- package/dist/core/seam.d.mts +16 -26
- package/dist/core/seam.mjs +7 -28
- package/dist/core/tokens.mjs +1 -1
- package/dist/core/view.mjs +7 -15
- package/dist/core/work.mjs +59 -14
- package/dist/effect.d.mts +3 -12
- package/dist/effect.mjs +1 -10
- package/dist/engine/failures.mjs +2 -1
- package/dist/engine/reads.mjs +4 -4
- package/dist/event-streams/stream.d.mts +2 -2
- package/dist/event-streams/stream.mjs +37 -14
- package/dist/extend.d.mts +2 -3
- package/dist/extend.mjs +2 -1
- package/dist/http/answers.mjs +8 -5
- package/dist/http/core-parts.mjs +95 -79
- package/dist/http/handler.mjs +34 -7
- package/dist/http/node.d.mts +14 -1
- package/dist/http/node.mjs +56 -27
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +30 -26
- package/dist/http/push-uploads.mjs +36 -21
- package/dist/http/upload-pack.mjs +3 -3
- package/dist/index.d.mts +14 -14
- package/dist/index.mjs +2 -2
- package/dist/lfs/answer.mjs +37 -0
- package/dist/lfs/base.d.mts +2 -0
- package/dist/lfs/base.mjs +25 -1
- package/dist/lfs/copy.d.mts +21 -7
- package/dist/lfs/copy.mjs +89 -6
- package/dist/lfs/layer.d.mts +15 -1
- package/dist/lfs/layer.mjs +24 -11
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +1 -0
- package/dist/lfs/objects.mjs +87 -17
- package/dist/lfs/pointers.mjs +2 -2
- package/dist/lfs/rows.mjs +42 -8
- package/dist/lfs/upkeep.mjs +48 -14
- package/dist/lfs/wire.mjs +6 -31
- package/dist/merges/merges.mjs +2 -2
- package/dist/node.d.mts +2 -2
- package/dist/protocol/bytes/buffers.mjs +13 -5
- package/dist/protocol/bytes/reader.mjs +6 -1
- package/dist/protocol/bytes/streams.mjs +27 -1
- package/dist/protocol/diff/read.d.mts +4 -3
- package/dist/protocol/diff/read.mjs +8 -3
- package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
- package/dist/protocol/objects/lfs-pointer.mjs +1 -3
- package/dist/protocol/objects/links-raw.mjs +24 -10
- package/dist/protocol/objects/tag.d.mts +1 -1
- package/dist/protocol/objects/tree.mjs +23 -6
- package/dist/protocol/packs/delta.d.mts +6 -3
- package/dist/protocol/packs/delta.mjs +96 -32
- package/dist/protocol/packs/idx.d.mts +2 -1
- package/dist/protocol/packs/idx.mjs +22 -3
- package/dist/protocol/packs/parts.d.mts +4 -1
- package/dist/protocol/packs/parts.mjs +10 -7
- package/dist/protocol/packs/reader.d.mts +5 -0
- package/dist/protocol/packs/reader.mjs +3 -2
- package/dist/protocol/packs/writer.mjs +26 -8
- package/dist/queue/advance.mjs +21 -24
- package/dist/queue/base.d.mts +55 -0
- package/dist/queue/base.mjs +44 -0
- package/dist/queue/calls.mjs +51 -54
- package/dist/queue/commit.mjs +1 -1
- package/dist/queue/host.d.mts +1 -15
- package/dist/queue/host.mjs +2 -7
- package/dist/queue/layer.d.mts +2 -1
- package/dist/queue/layer.mjs +10 -3
- package/dist/queue/limits.mjs +2 -0
- package/dist/queue/push-option.mjs +9 -24
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/state.mjs +2 -10
- package/dist/queue/trim.mjs +5 -3
- package/dist/rest/blobs.mjs +29 -5
- package/dist/rest/caller.d.mts +4 -4271
- package/dist/rest/caller.mjs +4 -0
- package/dist/rest/client.d.mts +8 -5
- package/dist/rest/client.mjs +19 -2
- package/dist/rest/handlers.mjs +50 -5
- package/dist/rest/layer.d.mts +2 -2
- package/dist/rest/layer.mjs +5 -12
- package/dist/rest/me.d.mts +3 -432
- package/dist/server/check-fetch.mjs +3 -3
- package/dist/server/edge-node.d.mts +11 -8
- package/dist/server/edge-node.mjs +9 -6
- package/dist/server/edge.d.mts +21 -7
- package/dist/server/edge.mjs +32 -11
- package/dist/server/extension.mjs +1 -1
- package/dist/server/git-layer.d.mts +5 -5
- package/dist/server/git-layer.mjs +28 -22
- package/dist/server/git-namespace.d.mts +4 -3
- package/dist/server/git-namespace.mjs +3 -2
- package/dist/server/joined.d.mts +6 -18
- package/dist/server/joined.mjs +9 -36
- package/dist/server/lifecycle.mjs +18 -106
- package/dist/server/registry.mjs +24 -7
- package/dist/server/server.mjs +205 -346
- package/dist/signin/context.d.mts +1 -2
- package/dist/signin/layer.d.mts +1 -1
- package/dist/signin/layer.mjs +1 -1
- package/dist/storage/allotted.mjs +18 -3
- package/dist/storage/batch-upkeep.mjs +274 -0
- package/dist/storage/batches.d.mts +8 -0
- package/dist/storage/batches.mjs +344 -0
- package/dist/storage/calls.d.mts +1 -2
- package/dist/storage/calls.mjs +144 -158
- package/dist/storage/chunks.d.mts +9 -0
- package/dist/storage/chunks.mjs +297 -0
- package/dist/storage/clean-up.mjs +72 -9
- package/dist/storage/counted-bucket.mjs +4 -4
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +287 -210
- package/dist/storage/host-bucket.mjs +1 -2
- package/dist/storage/id-mix.mjs +19 -5
- package/dist/storage/index-bitmaps.mjs +9 -2
- package/dist/storage/index-build.d.mts +0 -1
- package/dist/storage/index-build.mjs +80 -23
- package/dist/storage/index-fetch.mjs +113 -72
- package/dist/storage/index-files.d.mts +3 -0
- package/dist/storage/index-files.mjs +10 -5
- package/dist/storage/index-graph.mjs +72 -22
- package/dist/storage/index-remap.mjs +200 -64
- package/dist/storage/index-whole.mjs +127 -0
- package/dist/storage/largest-files.mjs +1 -1
- package/dist/storage/layout.mjs +23 -0
- package/dist/storage/loose.d.mts +7 -4
- package/dist/storage/loose.mjs +212 -67
- package/dist/storage/memory-budget.mjs +16 -4
- package/dist/storage/merge-plan.mjs +3 -2
- package/dist/storage/merge-row.mjs +7 -1
- package/dist/storage/merge-stream.mjs +164 -25
- package/dist/storage/merge-walk.mjs +8 -4
- package/dist/storage/merge-write.mjs +1 -1
- package/dist/storage/merge.d.mts +1 -1
- package/dist/storage/merge.mjs +1 -1
- package/dist/storage/object-rows.d.mts +1 -0
- package/dist/storage/object-rows.mjs +385 -65
- package/dist/storage/oid-table.mjs +171 -0
- package/dist/storage/pack-order.mjs +8 -4
- package/dist/storage/pack-ranges.d.mts +1 -2
- package/dist/storage/pack-ranges.mjs +4 -5
- package/dist/storage/pack-reads.d.mts +2 -1
- package/dist/storage/pack-reads.mjs +158 -42
- package/dist/storage/pack-receive.d.mts +1 -1
- package/dist/storage/pack-receive.mjs +2 -2
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +136 -66
- package/dist/storage/placed-reads.mjs +1 -1
- package/dist/storage/plan-columns.d.mts +4 -0
- package/dist/storage/plan-columns.mjs +238 -0
- package/dist/storage/prune-keep.mjs +134 -41
- package/dist/storage/prune-walk.mjs +202 -62
- package/dist/storage/prune.mjs +194 -91
- package/dist/storage/push-allotment.mjs +91 -12
- package/dist/storage/push-uploads.mjs +4 -4
- package/dist/storage/pushed-commits.mjs +4 -2
- package/dist/storage/quarantine.d.mts +1 -1
- package/dist/storage/range-cache.mjs +125 -8
- package/dist/storage/ready.d.mts +1 -1
- package/dist/storage/ready.mjs +8 -6
- package/dist/storage/receive-bounds.mjs +23 -8
- package/dist/storage/repack-backlog.mjs +6 -3
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/rows.d.mts +1 -1
- package/dist/storage/rows.mjs +1 -1
- package/dist/storage/runs.mjs +195 -43
- package/dist/storage/send-list.d.mts +1 -0
- package/dist/storage/send-list.mjs +54 -10
- package/dist/storage/single-flight.mjs +13 -7
- package/dist/storage/stream-whole.mjs +127 -26
- package/dist/storage/unpack.mjs +371 -79
- package/dist/storage/visible.mjs +2 -2
- package/dist/storage/walk.mjs +192 -38
- package/dist/storage/wants.mjs +5 -5
- package/dist/store/bodies.mjs +38 -0
- package/dist/store/call-count.d.mts +8 -12
- package/dist/store/call-count.mjs +34 -46
- package/dist/store/catalogue.d.mts +2 -2
- package/dist/store/catalogue.mjs +145 -35
- package/dist/store/crossing.mjs +1 -3
- package/dist/store/cursor-seal.d.mts +1 -2
- package/dist/store/cursor-seal.mjs +16 -6
- package/dist/store/door.mjs +183 -0
- package/dist/store/errors.d.mts +3 -4
- package/dist/store/errors.mjs +15 -33
- package/dist/store/git-store.mjs +25 -7
- package/dist/store/job-try.mjs +9 -32
- package/dist/store/list-job.mjs +44 -8
- package/dist/store/records.d.mts +3 -0
- package/dist/store/records.mjs +3 -0
- package/dist/store/repo-record.d.mts +1 -2
- package/dist/store/repo-record.mjs +32 -20
- package/dist/store/reservations.mjs +1 -1
- package/dist/store/scopes.mjs +11 -0
- package/dist/store/settle.mjs +4 -4
- package/dist/sync/github.mjs +3 -3
- package/dist/sync/import.mjs +31 -18
- package/dist/sync/lfs-batch.mjs +4 -5
- package/dist/sync/lfs-copy.mjs +17 -6
- package/dist/sync/mirror.mjs +34 -31
- package/dist/sync/said.mjs +16 -37
- package/dist/sync/step.mjs +33 -25
- package/dist/sync/tries.mjs +9 -9
- package/dist/topics/advance.mjs +10 -11
- package/dist/topics/base.d.mts +15 -0
- package/dist/topics/base.mjs +8 -0
- package/dist/topics/host.mjs +1 -1
- package/dist/topics/layer.d.mts +4 -9
- package/dist/topics/layer.mjs +2 -3
- package/dist/topics/members.mjs +4 -4
- package/dist/topics/public.d.mts +2 -1
- package/dist/topics/topic.mjs +2 -2
- package/package.json +5 -4
- package/dist/contracts/promises.d.mts +0 -39
- package/dist/core/call-names.d.mts +0 -3
- package/dist/core/clock.mjs +0 -18
- package/dist/lfs/calls.mjs +0 -26
- package/dist/rest/api.d.mts +0 -23
- package/dist/rest/blobs.d.mts +0 -833
- package/dist/rest/commits.d.mts +0 -3543
- package/dist/rest/errors.d.mts +0 -2124
- package/dist/rest/events.d.mts +0 -426
- package/dist/rest/files.d.mts +0 -1342
- package/dist/rest/forks.d.mts +0 -2160
- package/dist/rest/handlers.d.mts +0 -8
- package/dist/rest/merges.d.mts +0 -477
- package/dist/rest/queue.d.mts +0 -5917
- package/dist/rest/refs.d.mts +0 -2988
- package/dist/rest/repos.d.mts +0 -2567
- package/dist/rest/tags.d.mts +0 -1316
- package/dist/rest/tokens.d.mts +0 -2614
- package/dist/rest/topics.d.mts +0 -2224
- package/dist/rest/trees.d.mts +0 -1709
- package/dist/rest/work.d.mts +0 -1695
- package/dist/server/lifecycle.d.mts +0 -2
- package/dist/store/promises.d.mts +0 -11
- package/dist/store/promises.mjs +0 -327
package/dist/core/repos.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import { keptKey, takenBack } from "../store/records.mjs";
|
|
|
10
10
|
import { refuseLive, reservationOf, reservedRepo } from "../store/reservations.mjs";
|
|
11
11
|
import { collections, newInternalId, reachedKey, repoScope } from "../store/scopes.mjs";
|
|
12
12
|
import { alreadyExists, callerFor, contended, contendedAfterWrites, indexDeleteJobs, keyedRecord, nameMoved, openKeyed, openRepo, purgeJobs, repoAccess, unlessHidden } from "./access.mjs";
|
|
13
|
+
import { importReads, importStatusOf } from "./imports.mjs";
|
|
13
14
|
import { createdInfo, infoReads, repoInfo } from "./repo-info.mjs";
|
|
14
15
|
import { isRefName } from "./names.mjs";
|
|
15
16
|
import { shortRef } from "./rules/patterns.mjs";
|
|
@@ -19,7 +20,7 @@ import { fail } from "../contracts/result.mjs";
|
|
|
19
20
|
import { CoreParts } from "./parts.mjs";
|
|
20
21
|
import { pruneJobRow } from "../storage/repack-job.mjs";
|
|
21
22
|
import { check } from "../contracts/authorize.mjs";
|
|
22
|
-
import * as Clock
|
|
23
|
+
import * as Clock from "effect/Clock";
|
|
23
24
|
import * as Effect from "effect/Effect";
|
|
24
25
|
// src/core/repos.ts
|
|
25
26
|
const defaultBranch = "refs/heads/main";
|
|
@@ -304,7 +305,7 @@ const createWith = /* @__PURE__ */ Effect.fnUntraced(function* (caller, input, a
|
|
|
304
305
|
}
|
|
305
306
|
});
|
|
306
307
|
for (let attempt = 0; attempt < 5; attempt += 1) {
|
|
307
|
-
const at = yield* Clock
|
|
308
|
+
const at = yield* Clock.currentTimeMillis;
|
|
308
309
|
const kept = yield* keptKey(caller, input.key, [
|
|
309
310
|
"create",
|
|
310
311
|
id,
|
|
@@ -370,7 +371,8 @@ const createWith = /* @__PURE__ */ Effect.fnUntraced(function* (caller, input, a
|
|
|
370
371
|
...receiptKeys(kept),
|
|
371
372
|
...dropped.delete,
|
|
372
373
|
...also.put.map(keyOf)
|
|
373
|
-
]
|
|
374
|
+
],
|
|
375
|
+
jobs: [...receipt.jobs.length > 0 ? [core.repackJobRow()] : [], ...purgeJobs(core, at)]
|
|
374
376
|
})) === "lost") return yield* alreadyExists(id);
|
|
375
377
|
return {
|
|
376
378
|
info,
|
|
@@ -379,6 +381,8 @@ const createWith = /* @__PURE__ */ Effect.fnUntraced(function* (caller, input, a
|
|
|
379
381
|
}
|
|
380
382
|
return yield* contended();
|
|
381
383
|
});
|
|
384
|
+
/** Whether a read of the repo confirms it once `authorize` answers, as `unconfirmed` says. */
|
|
385
|
+
const confirmOf = (input) => input.unconfirmed === true ? "skip" : "read";
|
|
382
386
|
/**
|
|
383
387
|
* `repos`: each call reads the repo's record, decides the next one, and commits it in the repo's
|
|
384
388
|
* own scope, with `git.list` saved beside it, then projects the record into `git/repos`. The
|
|
@@ -396,10 +400,17 @@ const repoCalls = (bound) => {
|
|
|
396
400
|
repo
|
|
397
401
|
};
|
|
398
402
|
const caller = callerOf(input);
|
|
399
|
-
const
|
|
400
|
-
const opened = yield* openRepo(caller, operation, infoReads, input.internalId, confirm);
|
|
403
|
+
const opened = yield* openRepo(caller, operation, infoReads, input.internalId, confirmOf(input));
|
|
401
404
|
return yield* repoInfo(caller, opened.internalId, opened.record, opened.snapshot.results.slice(1));
|
|
402
405
|
});
|
|
406
|
+
const importState = Effect.fnUntraced(function* (repo, input) {
|
|
407
|
+
const operation = {
|
|
408
|
+
kind: "read",
|
|
409
|
+
repo
|
|
410
|
+
};
|
|
411
|
+
const opened = yield* openRepo(callerOf(input), operation, importReads, input.internalId, confirmOf(input));
|
|
412
|
+
return yield* importStatusOf(opened.snapshot.results.slice(1));
|
|
413
|
+
});
|
|
403
414
|
const list = Effect.fnUntraced(function* (input) {
|
|
404
415
|
const core = yield* CoreParts;
|
|
405
416
|
const { store } = core;
|
|
@@ -540,6 +551,7 @@ const repoCalls = (bound) => {
|
|
|
540
551
|
return {
|
|
541
552
|
create,
|
|
542
553
|
get,
|
|
554
|
+
importState,
|
|
543
555
|
list,
|
|
544
556
|
update: Effect.fnUntraced(function* (repo, input) {
|
|
545
557
|
const core = yield* CoreParts;
|
|
@@ -550,7 +562,7 @@ const repoCalls = (bound) => {
|
|
|
550
562
|
yield* privateDefault(input.defaultBranch);
|
|
551
563
|
}
|
|
552
564
|
for (let attempt = 0; attempt < 5; attempt += 1) {
|
|
553
|
-
const at = yield* Clock
|
|
565
|
+
const at = yield* Clock.currentTimeMillis;
|
|
554
566
|
const caller = callerOf(input);
|
|
555
567
|
const kept = yield* keptKey(caller, input.key, [
|
|
556
568
|
"update",
|
|
@@ -621,7 +633,7 @@ const repoCalls = (bound) => {
|
|
|
621
633
|
if (!isRepoName(to)) return yield* badRepoName(to);
|
|
622
634
|
if (to === repo) return yield* fail("INVALID_ARGUMENT", "A rename names another name");
|
|
623
635
|
for (let attempt = 0; attempt < 5; attempt += 1) {
|
|
624
|
-
const at = yield* Clock
|
|
636
|
+
const at = yield* Clock.currentTimeMillis;
|
|
625
637
|
const kept = yield* keptKey(caller, input.key, [
|
|
626
638
|
"rename",
|
|
627
639
|
repo,
|
|
@@ -734,7 +746,7 @@ const repoCalls = (bound) => {
|
|
|
734
746
|
const { store } = core;
|
|
735
747
|
const caller = callerOf(input);
|
|
736
748
|
for (let attempt = 0; attempt < 5; attempt += 1) {
|
|
737
|
-
const at = yield* Clock
|
|
749
|
+
const at = yield* Clock.currentTimeMillis;
|
|
738
750
|
const kept = yield* keptKey(caller, input.key, ["delete", repo], at);
|
|
739
751
|
const keyed = yield* keyedRecord(store, repo, kept, (access) => Effect.andThen(check({
|
|
740
752
|
caller,
|
|
@@ -779,7 +791,7 @@ const repoCalls = (bound) => {
|
|
|
779
791
|
exempt: true,
|
|
780
792
|
confirmed: name
|
|
781
793
|
});
|
|
782
|
-
const deletedAt = yield* Clock
|
|
794
|
+
const deletedAt = yield* Clock.currentTimeMillis;
|
|
783
795
|
const deleted = {
|
|
784
796
|
...record,
|
|
785
797
|
deleted: true,
|
|
@@ -4,7 +4,6 @@ import "../../contracts/objects.mjs";
|
|
|
4
4
|
import "../../contracts/refs.mjs";
|
|
5
5
|
import { GitError } from "../../contracts/result.mjs";
|
|
6
6
|
import "../../contracts/rules.mjs";
|
|
7
|
-
import "../../contracts/services.mjs";
|
|
8
7
|
import "../../contracts/store.mjs";
|
|
9
8
|
import { WalkRefused } from "../../engine/combined.mjs";
|
|
10
9
|
import "effect/Effect";
|
|
@@ -3,8 +3,8 @@ import { Caller, RepoAccess } from "../contracts/actors.mjs";
|
|
|
3
3
|
import "../contracts/authorize.mjs";
|
|
4
4
|
import { InternalRepoId } from "../contracts/ids.mjs";
|
|
5
5
|
import { GitError } from "../contracts/result.mjs";
|
|
6
|
-
import "./parts.mjs";
|
|
7
|
-
import "./saved-callers.mjs";
|
|
6
|
+
import { QueueNeeds } from "./parts.mjs";
|
|
7
|
+
import { SavedCaller } from "./saved-callers.mjs";
|
|
8
8
|
import * as Effect from "effect/Effect";
|
|
9
9
|
import * as Schema from "effect/Schema";
|
|
10
10
|
import * as Context from "effect/Context";
|
|
@@ -42,6 +42,11 @@ export declare const Saved: Schema.Union<readonly [Schema.Struct<{
|
|
|
42
42
|
readonly id: Schema.String;
|
|
43
43
|
}>]>;
|
|
44
44
|
export type Saved = typeof Saved.Type;
|
|
45
|
+
/**
|
|
46
|
+
* How `SavedCallers.queueEntry` reads who added a queue entry, as its row saved them: the queue's own
|
|
47
|
+
* reader, which sits above the core, as the server hands it.
|
|
48
|
+
*/
|
|
49
|
+
export type EntryAdderOf = (entry: string) => Effect.Effect<SavedCaller | undefined, GitError, QueueNeeds>;
|
|
45
50
|
declare const SavedCallers_base: Context.ServiceClass<SavedCallers, "@ref0/git/SavedCallers", {
|
|
46
51
|
/** `caller` as work keeps it, its actor named `actor`: its kind and IDs, nothing more. */
|
|
47
52
|
readonly save: (actor: string, caller: Caller) => Effect.Effect<Saved>;
|
|
@@ -6,7 +6,7 @@ import { CoreParts } from "./parts.mjs";
|
|
|
6
6
|
import { retriedCodes } from "./push.mjs";
|
|
7
7
|
import { refViewAgain } from "./ref-view.mjs";
|
|
8
8
|
import { askAgain } from "./saved-callers.mjs";
|
|
9
|
-
import * as Clock
|
|
9
|
+
import * as Clock from "effect/Clock";
|
|
10
10
|
import * as Effect from "effect/Effect";
|
|
11
11
|
import * as Schema from "effect/Schema";
|
|
12
12
|
import * as Result from "effect/Result";
|
|
@@ -20,7 +20,7 @@ import * as Context from "effect/Context";
|
|
|
20
20
|
* with a code a try retries, fails, so the try runs again.
|
|
21
21
|
*/
|
|
22
22
|
const viewAgainOf = /* @__PURE__ */ Effect.fnUntraced(function* (saved, repo, kind, signal) {
|
|
23
|
-
const asked = yield* askAgain(saved, yield* Clock
|
|
23
|
+
const asked = yield* askAgain(saved, yield* Clock.currentTimeMillis, signal);
|
|
24
24
|
if (asked.kind === "refused") return asked;
|
|
25
25
|
const view = yield* Effect.result(refViewAgain(asked.caller, kind, repo));
|
|
26
26
|
if (Result.isFailure(view)) {
|
|
@@ -3,5 +3,22 @@ import "../contracts/result.mjs";
|
|
|
3
3
|
import "../contracts/authorize.mjs";
|
|
4
4
|
import "./parts.mjs";
|
|
5
5
|
import "effect/Effect";
|
|
6
|
-
import "effect/Schema";
|
|
7
|
-
import "effect/Types";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
|
+
import "effect/Types";
|
|
8
|
+
/**
|
|
9
|
+
* Who saved work that runs later, a queue entry or a mirror (#679, #1945), as its row keeps it:
|
|
10
|
+
* the actor's ID, the subject's, the ID of the token it came with, never its secret, and the
|
|
11
|
+
* extension's grant that gave it, by its resolver and the `id` it asks that again with. Each try
|
|
12
|
+
* asks it again with `askAgain`, so a credential that ended stops the work. The `meta` it came
|
|
13
|
+
* with was the sign-in's at the save, and isn't kept.
|
|
14
|
+
*/
|
|
15
|
+
export declare const SavedCaller: Schema.Struct<{
|
|
16
|
+
readonly actor: Schema.String;
|
|
17
|
+
readonly subject: Schema.optionalKey<Schema.String>;
|
|
18
|
+
readonly token: Schema.optionalKey<Schema.String>;
|
|
19
|
+
readonly grant: Schema.optionalKey<Schema.Struct<{
|
|
20
|
+
readonly resolver: Schema.String;
|
|
21
|
+
readonly id: Schema.String;
|
|
22
|
+
}>>;
|
|
23
|
+
}>;
|
|
24
|
+
export type SavedCaller = typeof SavedCaller.Type;
|
package/dist/core/seam.d.mts
CHANGED
|
@@ -7,8 +7,6 @@ import { EffectCalls } from "../contracts/services.mjs";
|
|
|
7
7
|
import { TokenId } from "../contracts/tokens.mjs";
|
|
8
8
|
import { Identify } from "../auth/identify.mjs";
|
|
9
9
|
import { CallCount } from "../store/call-count.mjs";
|
|
10
|
-
import { BridgeDoor } from "../store/promises.mjs";
|
|
11
|
-
import { CallNames } from "./call-names.mjs";
|
|
12
10
|
import { FeedItem } from "../contracts/events.mjs";
|
|
13
11
|
import "../contracts/authorize.mjs";
|
|
14
12
|
import { QueueNeeds } from "./parts.mjs";
|
|
@@ -26,15 +24,13 @@ export interface SeamAuthorizeInput {
|
|
|
26
24
|
readonly repo?: RepoName;
|
|
27
25
|
}
|
|
28
26
|
/**
|
|
29
|
-
* What
|
|
30
|
-
*
|
|
31
|
-
* layers put REST below the server, so
|
|
32
|
-
*
|
|
27
|
+
* What REST serves the server's calls through: where it serves, who a request is, the Effect calls
|
|
28
|
+
* for one caller, `authorize` for the calls that trust host code, and where a renamed repo went.
|
|
29
|
+
* The layers put REST below the server, so it sits here. Each part goes through the server's door,
|
|
30
|
+
* so one asked once the server is closed dies closed.
|
|
33
31
|
*/
|
|
34
|
-
export interface
|
|
32
|
+
export interface ServedRest {
|
|
35
33
|
readonly basePath: string;
|
|
36
|
-
/** The context the server's calls run over, which its jobs and routes provide. */
|
|
37
|
-
readonly needs: Context.Context<QueueNeeds>;
|
|
38
34
|
/**
|
|
39
35
|
* The Effect calls, each deciding for `caller`, the one `identify` answered: its token's scope or
|
|
40
36
|
* its grant is the ceiling, whatever actor an input names.
|
|
@@ -48,8 +44,9 @@ export interface ServerParts {
|
|
|
48
44
|
readonly identify: Identify;
|
|
49
45
|
readonly authorize: (input: SeamAuthorizeInput) => Effect.Effect<void, GitError>;
|
|
50
46
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
47
|
+
* Where a renamed repo is today, while nothing has been made under its old name: its name now,
|
|
48
|
+
* found by internal ID past any later rename, never whatever repo took the name it first moved
|
|
49
|
+
* to. Told only to a `caller` that may read it: `undefined` for anyone else.
|
|
53
50
|
*/
|
|
54
51
|
readonly renamedTo: (caller: Caller, repo: RepoName) => Effect.Effect<RepoName | undefined, GitError>;
|
|
55
52
|
/**
|
|
@@ -67,21 +64,14 @@ export interface ServerParts {
|
|
|
67
64
|
}
|
|
68
65
|
/** Opens a repo's event stream for `caller`: `openFeed` over the server's core and clock. */
|
|
69
66
|
export type Listen = (caller: Caller, repo: RepoName, after: number | undefined) => Effect.Effect<ReadableStream<FeedItem>, GitError>;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
readonly
|
|
73
|
-
|
|
74
|
-
/** Whether the server has its queue now, which `names`' `queue` group answers only once it does. */
|
|
75
|
-
readonly queueOn: () => boolean;
|
|
76
|
-
/** The server's door, which a route outside its runtime, such as REST's, asks before and after. */
|
|
77
|
-
readonly door: BridgeDoor;
|
|
78
|
-
/** The parts once the build is done: `UNAVAILABLE`, naming its failure, once it failed. */
|
|
79
|
-
readonly parts: Effect.Effect<ServerParts, GitError>;
|
|
80
|
-
}
|
|
81
|
-
declare const ServerSeam_base: Context.ServiceClass<ServerSeam, "@ref0/git/ServerSeam", Seam>;
|
|
67
|
+
declare const ServedParts_base: Context.ServiceClass<ServedParts, "@ref0/git/ServedParts", {
|
|
68
|
+
readonly rest: ServedRest;
|
|
69
|
+
readonly needs: Context.Context<QueueNeeds>;
|
|
70
|
+
}>;
|
|
82
71
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
72
|
+
* What the server `Git.layer` built hands the features that serve its calls, as `Rest.layer` does,
|
|
73
|
+
* as they build: REST's parts, and the context the server's calls run over, which its jobs and
|
|
74
|
+
* routes provide. Internal: no entry exports it.
|
|
85
75
|
*/
|
|
86
|
-
export declare class
|
|
76
|
+
export declare class ServedParts extends /* @__PURE__ */ ServedParts_base {}
|
|
87
77
|
export {};
|
package/dist/core/seam.mjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { noTokens } from "../auth/tokens-layer.mjs";
|
|
2
1
|
import { redirectOf, resolveRepo } from "../store/catalogue.mjs";
|
|
3
2
|
import { readableRedirect, repoAccess } from "./access.mjs";
|
|
4
|
-
import { callOrMissing, heldGroup, lazyGroups } from "./promise.mjs";
|
|
5
3
|
import { revokeCheck } from "./tokens.mjs";
|
|
6
4
|
import { check } from "../contracts/authorize.mjs";
|
|
7
5
|
import { CoreParts } from "./parts.mjs";
|
|
@@ -9,30 +7,11 @@ import * as Effect from "effect/Effect";
|
|
|
9
7
|
import * as Context from "effect/Context";
|
|
10
8
|
// src/core/seam.ts
|
|
11
9
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* What the server `Git.layer` built hands the features that serve its calls, as `Rest.layer` does,
|
|
11
|
+
* as they build: REST's parts, and the context the server's calls run over, which its jobs and
|
|
12
|
+
* routes provide. Internal: no entry exports it.
|
|
14
13
|
*/
|
|
15
|
-
var
|
|
16
|
-
const seamByServer = /* @__PURE__ */ new WeakMap();
|
|
17
|
-
/** Called once for a server, by `openServer` or a test world's face. */
|
|
18
|
-
const attachParts = (server, seam) => {
|
|
19
|
-
seamByServer.set(server, seam);
|
|
20
|
-
};
|
|
21
|
-
/** A server's seam: `undefined` for one with none attached. */
|
|
22
|
-
const seamOf = (server) => seamByServer.get(server);
|
|
23
|
-
/** `seam`'s parts but its needs and bound, each waiting for the build: a route's, made before it. */
|
|
24
|
-
const lazyParts = (seam) => {
|
|
25
|
-
const { parts } = seam;
|
|
26
|
-
return {
|
|
27
|
-
basePath: seam.basePath,
|
|
28
|
-
callsFor: (caller) => heldGroup(lazyGroups(seam.names, (group, name, args) => Effect.flatMap(parts, (built) => callOrMissing(built.callsFor(caller), group, name, () => Effect.fail(noTokens))(...args))), "queue", seam.queueOn),
|
|
29
|
-
tokensOn: Effect.flatMap(parts, (built) => built.tokensOn),
|
|
30
|
-
identify: (request) => Effect.flatMap(parts, (built) => built.identify(request)),
|
|
31
|
-
authorize: (input) => Effect.flatMap(parts, (built) => built.authorize(input)),
|
|
32
|
-
renamedTo: (caller, repo) => Effect.flatMap(parts, (built) => built.renamedTo(caller, repo)),
|
|
33
|
-
listen: (caller, repo, after) => Effect.flatMap(parts, (built) => built.listen(caller, repo, after))
|
|
34
|
-
};
|
|
35
|
-
};
|
|
14
|
+
var ServedParts = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/ServedParts")) {};
|
|
36
15
|
/**
|
|
37
16
|
* `authorize` for a route: a repo's operation with the repo's access, or a revoke against the
|
|
38
17
|
* token's own coverage. A repo that isn't there is asked without access, and a caller it lets
|
|
@@ -60,7 +39,7 @@ const seamAuthorize = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
60
39
|
/** Where `repo` went, for a route's redirect: only to a caller that may read it there. */
|
|
61
40
|
const renamedTo = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo) {
|
|
62
41
|
const { store } = yield* CoreParts;
|
|
63
|
-
const
|
|
64
|
-
return
|
|
42
|
+
const moved = yield* redirectOf(store, repo);
|
|
43
|
+
return moved === void 0 ? void 0 : yield* readableRedirect(caller, moved.to, moved.internalId);
|
|
65
44
|
});
|
|
66
|
-
export {
|
|
45
|
+
export { ServedParts, renamedTo, seamAuthorize };
|
package/dist/core/tokens.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fail, gitError } from "../contracts/result.mjs";
|
|
2
2
|
import { readToken } from "../auth/token-rows.mjs";
|
|
3
|
-
import { isPrefixTarget, tokenParties } from "../auth/
|
|
3
|
+
import { isPrefixTarget, tokenParties } from "../auth/token-text.mjs";
|
|
4
4
|
import { isHost } from "../contracts/git.mjs";
|
|
5
5
|
import { namedRecordOf } from "../store/catalogue.mjs";
|
|
6
6
|
import { confirmed, openRepo, repoAccess } from "./access.mjs";
|
package/dist/core/view.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { gitsOwnMove } from "../protocol/wire/lines.mjs";
|
|
|
2
2
|
import { answerSpent, resultCall } from "../store/errors.mjs";
|
|
3
3
|
import { upstreamOf } from "../store/catalogue.mjs";
|
|
4
4
|
import { collections } from "../store/scopes.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { scopedReader } from "../storage/calls.mjs";
|
|
6
6
|
import { callScope, inCallScope } from "../store/call-count.mjs";
|
|
7
7
|
import { askingOnLost } from "../storage/index-visible.mjs";
|
|
8
8
|
import { indexRowKey } from "../storage/layout.mjs";
|
|
@@ -47,18 +47,10 @@ var SealedObjects = class SealedObjects {
|
|
|
47
47
|
* error alone, never the objects, so it's no way past a view.
|
|
48
48
|
*/
|
|
49
49
|
static onReceive(sealed, seen) {
|
|
50
|
-
const watch = (objects) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (result.kind === "error") seen(result.error);
|
|
55
|
-
return result;
|
|
56
|
-
};
|
|
57
|
-
return {
|
|
58
|
-
...objects,
|
|
59
|
-
receive: answeredBy(receive, (listed, input) => Effect.tapError(answerSpent(effect(listed, input)), (error) => Effect.sync(() => seen(error))))
|
|
60
|
-
};
|
|
61
|
-
};
|
|
50
|
+
const watch = (objects) => ({
|
|
51
|
+
...objects,
|
|
52
|
+
receive: (listed, input) => Effect.tapError(answerSpent(objects.receive(listed, input)), (error) => Effect.sync(() => seen(error)))
|
|
53
|
+
});
|
|
62
54
|
const indexed = sealed.#indexed;
|
|
63
55
|
if (indexed === void 0) return new SealedObjects(watch(sealed.#objects));
|
|
64
56
|
const watched = watch(indexed);
|
|
@@ -95,7 +87,7 @@ var SealedObjects = class SealedObjects {
|
|
|
95
87
|
* refused past its bound. Either costs the same whatever roots the tips don't reach.
|
|
96
88
|
*/
|
|
97
89
|
static rootsReached(sealed, _whole, at, input) {
|
|
98
|
-
const walked = Effect.suspend(() => walkedRoots(
|
|
90
|
+
const walked = Effect.suspend(() => walkedRoots(sealed.#objects, at, input));
|
|
99
91
|
const fast = sealed.#indexed?.rootsReached;
|
|
100
92
|
if (fast === void 0) return walked;
|
|
101
93
|
return Effect.flatMap(fast(at, input), (reached) => reached === void 0 ? walked : Effect.succeed(reached));
|
|
@@ -291,7 +283,7 @@ const viewOf = /* @__PURE__ */ Effect.fnUntraced(function* (caller, resolved, ow
|
|
|
291
283
|
parted ??= SealedObjects.parted(sealed, viewWhole, at.listed, asked, at.pushed);
|
|
292
284
|
return parted?.[pick];
|
|
293
285
|
};
|
|
294
|
-
const seenAs = (pick) =>
|
|
286
|
+
const seenAs = (pick) => viewedIn(caller, resolved.internalId, `${key}:${pick}`, both, part(pick));
|
|
295
287
|
return {
|
|
296
288
|
refusing: yield* seenAs("refusing"),
|
|
297
289
|
shown: yield* seenAs("shown")
|
package/dist/core/work.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { badCursor } from "../engine/reads.mjs";
|
|
|
4
4
|
import { utf8 } from "../protocol/bytes/text.mjs";
|
|
5
5
|
import { afterCommit } from "../store/call-count.mjs";
|
|
6
6
|
import { listBound } from "../store/cursor-seal.mjs";
|
|
7
|
-
import { storeCall } from "../store/errors.mjs";
|
|
7
|
+
import { storeCall, storeCommit } from "../store/errors.mjs";
|
|
8
8
|
import { keptKey } from "../store/records.mjs";
|
|
9
9
|
import { readRecord } from "../store/repo-record.mjs";
|
|
10
10
|
import { newChangeId, repoScope } from "../store/scopes.mjs";
|
|
@@ -15,7 +15,7 @@ import { refViewIn } from "./ref-view.mjs";
|
|
|
15
15
|
import { heldReceipt, receiptAnswered, receiptReads, receiptWrites } from "./receipts.mjs";
|
|
16
16
|
import { fail } from "../contracts/result.mjs";
|
|
17
17
|
import { CoreParts, QueueParts } from "./parts.mjs";
|
|
18
|
-
import * as Clock
|
|
18
|
+
import * as Clock from "effect/Clock";
|
|
19
19
|
import * as Effect from "effect/Effect";
|
|
20
20
|
import { limits } from "@ref0/infra";
|
|
21
21
|
// src/core/work.ts
|
|
@@ -45,29 +45,29 @@ const storeCursor = (text) => {
|
|
|
45
45
|
return text.slice(start, start + Number(length[1]));
|
|
46
46
|
};
|
|
47
47
|
/** Commits a work write's receipt, and `git.repack` due to sweep it, at the scope's `expect`. */
|
|
48
|
-
const commitReceipt = (internalId, write) => Effect.flatMap(Effect.service(CoreParts), (core) =>
|
|
48
|
+
const commitReceipt = (internalId, write) => Effect.flatMap(Effect.service(CoreParts), (core) => {
|
|
49
49
|
const receipt = receiptWrites(write.kept, write.answer, core.repackJobRow);
|
|
50
50
|
const change = {
|
|
51
51
|
id: newChangeId(),
|
|
52
52
|
expect: write.expect
|
|
53
53
|
};
|
|
54
|
-
return core.store.commit(repoScope(internalId), {
|
|
54
|
+
return storeCommit(core.store.commit(repoScope(internalId), {
|
|
55
55
|
...change,
|
|
56
56
|
put: [...receipt.put],
|
|
57
57
|
jobs: [...receipt.jobs]
|
|
58
|
-
});
|
|
59
|
-
})
|
|
58
|
+
}));
|
|
59
|
+
});
|
|
60
60
|
/**
|
|
61
61
|
* Marks a work write's receipt answered once the queue took the write, so the write sent again
|
|
62
|
-
* answers as it did. The queue's calls join no commit, so a write stopped before this
|
|
63
|
-
*
|
|
62
|
+
* answers as it did. The queue's calls join no commit, so a write stopped before this is sent
|
|
63
|
+
* again to a `pending` receipt, which `ranBefore` reads (Q150).
|
|
64
64
|
*/
|
|
65
65
|
const keepAnswer = /* @__PURE__ */ Effect.fnUntraced(function* (internalId, kept) {
|
|
66
66
|
const core = yield* CoreParts;
|
|
67
67
|
for (let attempt = 0; attempt < 5; attempt += 1) {
|
|
68
68
|
const scope = repoScope(internalId);
|
|
69
69
|
const write = {
|
|
70
|
-
expect: (yield* storeCall(
|
|
70
|
+
expect: (yield* storeCall(core.store.read(scope, []))).version,
|
|
71
71
|
kept,
|
|
72
72
|
answer: { kind: "done" }
|
|
73
73
|
};
|
|
@@ -79,6 +79,44 @@ const keepAnswer = /* @__PURE__ */ Effect.fnUntraced(function* (internalId, kept
|
|
|
79
79
|
tries: 5
|
|
80
80
|
}));
|
|
81
81
|
});
|
|
82
|
+
const unread = { kind: "unread" };
|
|
83
|
+
/** `job`'s failure, from the queue's failed jobs of its name, `failedFindPages` at most. */
|
|
84
|
+
const failureOf = /* @__PURE__ */ Effect.fnUntraced(function* (scope, job) {
|
|
85
|
+
const { jobs } = yield* QueueParts;
|
|
86
|
+
let after;
|
|
87
|
+
for (let page = 0; page < 10; page += 1) {
|
|
88
|
+
const request = {
|
|
89
|
+
state: "failed",
|
|
90
|
+
name: job.name
|
|
91
|
+
};
|
|
92
|
+
if (after !== void 0) request.page = { after };
|
|
93
|
+
const listed = yield* storeCall(jobs.list(scope, request));
|
|
94
|
+
const failed = listed.items.find((item) => item.key === job.key);
|
|
95
|
+
if (failed?.claim !== void 0) return {
|
|
96
|
+
kind: "failed",
|
|
97
|
+
claim: failed.claim
|
|
98
|
+
};
|
|
99
|
+
if (failed !== void 0) return unread;
|
|
100
|
+
if (listed.next === void 0) return { kind: "none" };
|
|
101
|
+
after = listed.next;
|
|
102
|
+
}
|
|
103
|
+
return unread;
|
|
104
|
+
});
|
|
105
|
+
/**
|
|
106
|
+
* Whether a work write sent again to its `pending` receipt finds the first send's queue call ran:
|
|
107
|
+
* the receipt names the claim its job had failed under, and the job is no longer failed under it,
|
|
108
|
+
* retried, discarded, or failed again since. Claims are numbered afresh in a scope, never reused,
|
|
109
|
+
* so a failure under the same claim is the one the first send found. A receipt that names none,
|
|
110
|
+
* or a failure past `failedFindPages`, can't tell, and the write calls the queue again.
|
|
111
|
+
*/
|
|
112
|
+
const ranBefore = (held, now) => {
|
|
113
|
+
if (held.failed === void 0) return false;
|
|
114
|
+
switch (now.kind) {
|
|
115
|
+
case "failed": return now.claim !== held.failed;
|
|
116
|
+
case "none": return true;
|
|
117
|
+
case "unread": return false;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
82
120
|
/**
|
|
83
121
|
* A page of the jobs in `internalId`'s scope, as `list` and `listById` answer them, those `shown`
|
|
84
122
|
* keeps. With `access`, a cursor is sealed for `list`'s page of the repo in its state: the store's
|
|
@@ -102,7 +140,7 @@ const jobsPage = /* @__PURE__ */ Effect.fnUntraced(function* (internalId, list,
|
|
|
102
140
|
request.page = page;
|
|
103
141
|
}
|
|
104
142
|
const { jobs } = yield* QueueParts;
|
|
105
|
-
const listed = yield* storeCall(
|
|
143
|
+
const listed = yield* storeCall(jobs.list(repoScope(internalId), request));
|
|
106
144
|
const items = listed.items.filter(shown);
|
|
107
145
|
if (listed.next === void 0) return { items };
|
|
108
146
|
return {
|
|
@@ -130,7 +168,7 @@ const workCalls = (bound) => {
|
|
|
130
168
|
kind,
|
|
131
169
|
job.name,
|
|
132
170
|
job.key
|
|
133
|
-
], yield* Clock
|
|
171
|
+
], yield* Clock.currentTimeMillis, "requestKey");
|
|
134
172
|
for (let attempt = 0; attempt < 5; attempt += 1) {
|
|
135
173
|
const opened = yield* openRepo(caller, operation, receiptReads(kept), input.internalId, "skip");
|
|
136
174
|
const { internalId, snapshot } = opened;
|
|
@@ -138,18 +176,25 @@ const workCalls = (bound) => {
|
|
|
138
176
|
const seen = seesJob(yield* refViewIn(caller, repoOf), job);
|
|
139
177
|
const held = yield* heldReceipt(snapshot.results.slice(1), kept);
|
|
140
178
|
if (held !== void 0 && receiptAnswered(held)) return;
|
|
179
|
+
const scope = repoScope(internalId);
|
|
180
|
+
const failure = kept !== void 0 && seen ? yield* failureOf(scope, job) : unread;
|
|
181
|
+
if (kept !== void 0 && held !== void 0 && ranBefore(held, failure)) {
|
|
182
|
+
yield* afterCommit(keepAnswer(internalId, kept));
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
141
185
|
if (kept !== void 0 && held === void 0) {
|
|
186
|
+
const answer = { kind: "pending" };
|
|
187
|
+
if (failure.kind === "failed") answer.failed = failure.claim;
|
|
142
188
|
const write = {
|
|
143
189
|
expect: snapshot.version,
|
|
144
190
|
kept,
|
|
145
|
-
answer
|
|
191
|
+
answer
|
|
146
192
|
};
|
|
147
193
|
if (!(yield* commitReceipt(internalId, write)).ok) continue;
|
|
148
194
|
}
|
|
149
|
-
const scope = repoScope(internalId);
|
|
150
195
|
if (!seen && kind === "work.retry") return yield* fail("NOT_FOUND", `No job '${job.name}' '${job.key}'`);
|
|
151
196
|
if (!seen) {} else if (kind === "work.discard" && isDeliverJob(job) && keepsEvents(core.events)) yield* skipFailed(core.store, jobs, scope, job, core.events.deliveries);
|
|
152
|
-
else yield* storeCall(
|
|
197
|
+
else yield* storeCall(kind === "work.retry" ? jobs.retry(scope, job) : jobs.discard(scope, job));
|
|
153
198
|
if (kept !== void 0) yield* afterCommit(keepAnswer(internalId, kept));
|
|
154
199
|
return;
|
|
155
200
|
}
|
package/dist/effect.d.mts
CHANGED
|
@@ -2,17 +2,8 @@ import { EffectCalls, GitCaller, GitStore } from "./contracts/services.mjs";
|
|
|
2
2
|
import { IndexCalls, IndexReachInput, IndexReached, IndexStatus, IndexTip, IndexTry, IndexTryInput } from "./contracts/objects.mjs";
|
|
3
3
|
import { Actor } from "./contracts/actors.mjs";
|
|
4
4
|
import { RepoName } from "./contracts/ids.mjs";
|
|
5
|
-
import { CallAllowance
|
|
5
|
+
import { CallAllowance } from "./contracts/call-allowance.mjs";
|
|
6
|
+
import { CallBudget, CallBudgetOptions } from "./store/call-count.mjs";
|
|
6
7
|
import { commitCallsMost, storeCall } from "./store/errors.mjs";
|
|
7
8
|
import { bucketCall } from "./storage/calls.mjs";
|
|
8
|
-
|
|
9
|
-
import { GitCallerMiddleware, GitRestServices, RestServerSeam } from "./rest/caller.mjs";
|
|
10
|
-
import { GitErrors } from "./rest/errors.mjs";
|
|
11
|
-
import { GitRestHandlers } from "./rest/handlers.mjs";
|
|
12
|
-
import { MeApiGroup } from "./rest/me.mjs";
|
|
13
|
-
import { RefsApiGroup } from "./rest/refs.mjs";
|
|
14
|
-
import { ReposApiGroup } from "./rest/repos.mjs";
|
|
15
|
-
import { TokensApiGroup } from "./rest/tokens.mjs";
|
|
16
|
-
import { WorkApiGroup } from "./rest/work.mjs";
|
|
17
|
-
import { SeamAuthorizeInput, TokenRevokeCheck } from "./core/seam.mjs";
|
|
18
|
-
export { Actor, type CallAllowance, CallBudget, type CallBudgetOptions, type EffectCalls, GitCaller, GitCallerMiddleware, GitErrors, GitRestApi, GitRestHandlers, GitRestServices, GitStore, type IndexCalls, type IndexReachInput, type IndexReached, type IndexStatus, type IndexTip, type IndexTry, type IndexTryInput, MeApiGroup, RefsApiGroup, RepoName, ReposApiGroup, type RestServerSeam, type SeamAuthorizeInput, type TokenRevokeCheck, TokensApiGroup, WorkApiGroup, bucketCall, commitCallsMost, storeCall };
|
|
9
|
+
export { Actor, type CallAllowance, CallBudget, type CallBudgetOptions, type EffectCalls, GitCaller, GitStore, type IndexCalls, type IndexReachInput, type IndexReached, type IndexStatus, type IndexTip, type IndexTry, type IndexTryInput, RepoName, bucketCall, commitCallsMost, storeCall };
|
package/dist/effect.mjs
CHANGED
|
@@ -4,13 +4,4 @@ import { RepoName } from "./contracts/ids.mjs";
|
|
|
4
4
|
import { CallBudget } from "./store/call-count.mjs";
|
|
5
5
|
import { commitCallsMost, storeCall } from "./store/errors.mjs";
|
|
6
6
|
import { bucketCall } from "./storage/calls.mjs";
|
|
7
|
-
|
|
8
|
-
import { GitCallerMiddleware, GitRestServices } from "./rest/caller.mjs";
|
|
9
|
-
import { GitErrors } from "./rest/errors.mjs";
|
|
10
|
-
import { GitRestHandlers } from "./rest/handlers.mjs";
|
|
11
|
-
import { MeApiGroup } from "./rest/me.mjs";
|
|
12
|
-
import { RefsApiGroup } from "./rest/refs.mjs";
|
|
13
|
-
import { ReposApiGroup } from "./rest/repos.mjs";
|
|
14
|
-
import { TokensApiGroup } from "./rest/tokens.mjs";
|
|
15
|
-
import { WorkApiGroup } from "./rest/work.mjs";
|
|
16
|
-
export { Actor, CallBudget, GitCaller, GitCallerMiddleware, GitErrors, GitRestApi, GitRestHandlers, GitRestServices, GitStore, MeApiGroup, RefsApiGroup, RepoName, ReposApiGroup, TokensApiGroup, WorkApiGroup, bucketCall, commitCallsMost, storeCall };
|
|
7
|
+
export { Actor, CallBudget, GitCaller, GitStore, RepoName, bucketCall, commitCallsMost, storeCall };
|
package/dist/engine/failures.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { gitError, isGitError } from "../contracts/result.mjs";
|
|
1
|
+
import { gitError, isGitError, pastRoots } from "../contracts/result.mjs";
|
|
2
2
|
// src/engine/failures.ts
|
|
3
3
|
/** A diff's failure as Git's error: the read's own, or the reader's, a limit as `limit`. */
|
|
4
4
|
const fromDiff = (limit) => (error) => {
|
|
5
5
|
if (isGitError(error)) return error;
|
|
6
6
|
switch (error.reason) {
|
|
7
7
|
case "missing": return gitError("NOT_FOUND", error.message);
|
|
8
|
+
case "past-roots": return pastRoots(error.message, error.oid ?? "");
|
|
8
9
|
case "malformed":
|
|
9
10
|
case "unreadable": return gitError("DATA_LOSS", error.message);
|
|
10
11
|
case "diff-limit": return gitError("RESOURCE_EXHAUSTED", error.message, { context: { reason: limit } });
|
package/dist/engine/reads.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { sha1Of } from "../protocol/bytes/sha1.mjs";
|
|
|
3
3
|
import { utf8 } from "../protocol/bytes/text.mjs";
|
|
4
4
|
import { defaultDiffLimits } from "../protocol/diff/read.mjs";
|
|
5
5
|
import { fromAnswer } from "../contracts/calls-spent.mjs";
|
|
6
|
-
import * as Clock
|
|
6
|
+
import * as Clock from "effect/Clock";
|
|
7
7
|
import * as Effect from "effect/Effect";
|
|
8
8
|
import * as Hex from "effect/encoding/Hex";
|
|
9
9
|
// src/engine/reads.ts
|
|
@@ -37,7 +37,7 @@ const limitsOf = (limits = {}) => {
|
|
|
37
37
|
});
|
|
38
38
|
};
|
|
39
39
|
/** A call's deadline, `milliseconds` from now. */
|
|
40
|
-
const deadlineOf = (milliseconds, reason) => Effect.map(Clock
|
|
40
|
+
const deadlineOf = (milliseconds, reason) => Effect.map(Clock.currentTimeMillis, (now) => ({
|
|
41
41
|
at: now + milliseconds,
|
|
42
42
|
milliseconds,
|
|
43
43
|
reason
|
|
@@ -52,7 +52,7 @@ const stepDeadline = (milliseconds, reason, call) => call === void 0 ? deadlineO
|
|
|
52
52
|
});
|
|
53
53
|
const ranPast = (deadline) => fail("RESOURCE_EXHAUSTED", `The call ran past ${deadline.milliseconds} ms`, { context: { reason: deadline.reason } });
|
|
54
54
|
/** Fails once `deadline` has passed: a check between steps no timer can interrupt. */
|
|
55
|
-
const within = (deadline) => Effect.flatMap(Clock
|
|
55
|
+
const within = (deadline) => Effect.flatMap(Clock.currentTimeMillis, (now) => now > deadline.at ? ranPast(deadline) : Effect.void);
|
|
56
56
|
/**
|
|
57
57
|
* `objects` as the diff's reader batches through it, as `readThrough` reads: the call's deadline
|
|
58
58
|
* checked first, its signal passed on, its error result a failure.
|
|
@@ -76,7 +76,7 @@ const readThrough = (read, deadline) => (oid) => Effect.andThen(within(deadline)
|
|
|
76
76
|
* that can't fire meanwhile. A step of a longer call takes the call's deadline with its own
|
|
77
77
|
* `reason`.
|
|
78
78
|
*/
|
|
79
|
-
const timed = (effect, deadline) => Effect.flatMap(Clock
|
|
79
|
+
const timed = (effect, deadline) => Effect.flatMap(Clock.currentTimeMillis, (now) => Effect.timeoutOrElse(effect, {
|
|
80
80
|
duration: Math.max(0, deadline.at - now),
|
|
81
81
|
orElse: () => ranPast(deadline)
|
|
82
82
|
})).pipe(Effect.catch((error) => Effect.andThen(within(deadline), Effect.fail(error))), Effect.tap(() => within(deadline)));
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Clock } from "../contracts/promises.mjs";
|
|
2
1
|
import { Caller } from "../contracts/actors.mjs";
|
|
3
2
|
import "../contracts/events.mjs";
|
|
4
3
|
import { RepoName } from "../contracts/ids.mjs";
|
|
5
4
|
import { GitError } from "../contracts/result.mjs";
|
|
6
5
|
import { Authorize } from "../contracts/authorize.mjs";
|
|
7
6
|
import { CoreParts } from "../core/parts.mjs";
|
|
7
|
+
import * as EffectClock from "effect/Clock";
|
|
8
8
|
import * as Effect from "effect/Effect";
|
|
9
9
|
import * as Context from "effect/Context";
|
|
10
10
|
import "effect/Stream";
|
|
11
11
|
/** What a stream reads beside the server's core: the adapter's clock, and the server's guard. */
|
|
12
12
|
export interface FeedFields {
|
|
13
|
-
readonly clock: Clock;
|
|
13
|
+
readonly clock: EffectClock.Clock;
|
|
14
14
|
/** Fails once the server is closed. */
|
|
15
15
|
readonly guard: Effect.Effect<void, GitError>;
|
|
16
16
|
/** Aborts as the server closes: it ends the stream, which errors with the closed rejection. */
|