@ref0/git 0.7.0 → 0.8.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 +0 -2
- package/dist/auth/authorize.mjs +31 -24
- package/dist/auth/bridge.mjs +8 -8
- package/dist/auth/fences.d.mts +0 -1
- package/dist/auth/fences.mjs +1 -1
- package/dist/auth/grants.d.mts +0 -1
- package/dist/auth/grants.mjs +2 -2
- package/dist/auth/host-function.d.mts +1 -7
- package/dist/auth/host-function.mjs +38 -38
- package/dist/auth/identify.d.mts +0 -1
- package/dist/auth/identify.mjs +1 -1
- package/dist/auth/policy.d.mts +7 -4
- package/dist/auth/policy.mjs +13 -10
- package/dist/auth/token-rows.mjs +2 -5
- package/dist/auth/tokens-layer.d.mts +0 -2
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens-public.mjs +4 -2
- package/dist/auth/tokens.d.mts +6 -1
- package/dist/auth/tokens.mjs +7 -1
- package/dist/client/client.d.mts +22 -15
- package/dist/client/client.mjs +31 -27
- package/dist/client/git-http.mjs +22 -5
- package/dist/client/local.mjs +1 -1
- package/dist/client/namespace.d.mts +2 -0
- package/dist/client/push-upload.d.mts +1 -0
- package/dist/client/push-upload.mjs +169 -2
- package/dist/client/remote-helper.mjs +2 -4
- package/dist/client/remote.mjs +37 -15
- package/dist/client/run-remote-helper.mjs +4 -4
- package/dist/client/transport.mjs +26 -19
- package/dist/contracts/actors.d.mts +57 -28
- package/dist/contracts/actors.mjs +38 -2
- package/dist/contracts/authorize.d.mts +21 -15
- package/dist/contracts/callers.mjs +40 -0
- package/dist/contracts/client.d.mts +16 -9
- package/dist/contracts/events.d.mts +12 -10
- package/dist/contracts/events.mjs +8 -6
- package/dist/contracts/files.d.mts +42 -42
- package/dist/contracts/forks.d.mts +0 -24
- package/dist/contracts/git-hooks.d.mts +217 -0
- package/dist/contracts/git-hooks.mjs +3 -1
- package/dist/contracts/grants.d.mts +46 -27
- package/dist/contracts/lfs.d.mts +17 -4
- package/dist/contracts/merges.d.mts +7 -7
- package/dist/contracts/objects.d.mts +20 -4
- package/dist/contracts/opaque.mjs +19 -1
- package/dist/contracts/operations.d.mts +8 -1
- package/dist/contracts/operations.mjs +209 -0
- package/dist/contracts/queue.d.mts +3 -3
- package/dist/contracts/queue.mjs +5 -18
- package/dist/contracts/remote.d.mts +13 -4
- package/dist/contracts/remote.mjs +3 -3
- package/dist/contracts/repos.d.mts +11 -40
- package/dist/contracts/repos.mjs +11 -10
- package/dist/contracts/result.d.mts +28 -11
- package/dist/contracts/result.mjs +32 -2
- package/dist/contracts/rules.d.mts +706 -46
- package/dist/contracts/rules.mjs +81 -2
- package/dist/contracts/server.d.mts +5 -275
- package/dist/contracts/services.d.mts +0 -3
- package/dist/contracts/services.mjs +1 -3
- package/dist/contracts/signin.d.mts +2 -2
- package/dist/contracts/signin.mjs +4 -5
- package/dist/contracts/sync.d.mts +1 -4
- package/dist/contracts/tokens.d.mts +29 -17
- package/dist/contracts/tokens.mjs +14 -3
- package/dist/contracts/topics.d.mts +38 -11
- package/dist/contracts/topics.mjs +8 -2
- package/dist/core/access.d.mts +0 -2
- package/dist/core/access.mjs +15 -4
- package/dist/core/events/deliver.mjs +19 -1
- package/dist/core/forks.mjs +30 -11
- package/dist/core/hooks/groups.d.mts +0 -1
- package/dist/core/hooks/groups.mjs +8 -9
- package/dist/core/loose-tally.mjs +46 -0
- package/dist/core/objects/writing.mjs +1 -0
- package/dist/core/promise.mjs +1 -15
- package/dist/core/purge.mjs +14 -9
- package/dist/core/push.mjs +13 -6
- package/dist/core/ref-view.mjs +14 -6
- package/dist/core/repack.mjs +19 -14
- package/dist/core/repo-info.mjs +8 -6
- package/dist/core/repos.mjs +1 -0
- package/dist/core/rules/check.mjs +10 -10
- package/dist/core/rules/context.d.mts +3 -1
- package/dist/core/rules/context.mjs +16 -13
- package/dist/core/rules/fetch.mjs +17 -23
- package/dist/core/tokens.mjs +2 -1
- package/dist/effect.d.mts +2 -4
- package/dist/effect.mjs +2 -4
- package/dist/engine/commits.mjs +19 -47
- package/dist/engine/failures.d.mts +1 -2
- package/dist/engine/failures.mjs +1 -3
- package/dist/engine/merge-base-walk.mjs +57 -142
- package/dist/engine/merge-bases.mjs +5 -5
- package/dist/engine/merge.mjs +16 -14
- package/dist/extend.d.mts +1 -2
- package/dist/extend.mjs +1 -2
- package/dist/http/core-parts.mjs +1 -2
- package/dist/http/handler.mjs +11 -31
- package/dist/http/parts.d.mts +0 -1
- package/dist/index.d.mts +28 -21
- package/dist/index.mjs +5 -2
- package/dist/lfs/base.d.mts +6 -3
- package/dist/lfs/base.mjs +2 -1
- package/dist/lfs/layer.d.mts +4 -3
- package/dist/lfs/layer.mjs +23 -9
- package/dist/lfs/objects.mjs +90 -41
- package/dist/lfs/pointers.mjs +69 -18
- package/dist/lfs/purge.mjs +6 -2
- package/dist/lfs/rows.mjs +24 -7
- package/dist/lfs/service.d.mts +6 -3
- package/dist/lfs/service.mjs +8 -2
- package/dist/lfs/upkeep.mjs +44 -26
- package/dist/lfs/upload-most.mjs +41 -0
- package/dist/lfs/uploaded.mjs +59 -0
- package/dist/protocol/bytes/sha256-hasher.mjs +51 -0
- package/dist/protocol/bytes/text.mjs +6 -1
- package/dist/protocol/objects/fsck.mjs +6 -3
- package/dist/queue/advance.mjs +38 -8
- package/dist/queue/calls.mjs +4 -14
- package/dist/queue/lanes.mjs +1 -1
- package/dist/queue/rows.mjs +8 -0
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/search.mjs +3 -4
- package/dist/rest/client-namespace.d.mts +2 -0
- package/dist/rest/client.d.mts +32 -8
- package/dist/rest/client.mjs +308 -382
- package/dist/rest/commits.d.mts +240 -240
- package/dist/rest/files.d.mts +18 -18
- package/dist/rest/forks.d.mts +45 -57
- package/dist/rest/handlers.mjs +2 -1
- package/dist/rest/listen.d.mts +8 -6
- package/dist/rest/listen.mjs +31 -75
- package/dist/rest/me.d.mts +2 -2
- package/dist/rest/merges.d.mts +7 -7
- package/dist/rest/refs.d.mts +139 -139
- package/dist/rest/repos.d.mts +54 -66
- package/dist/rest/tokens.d.mts +12 -12
- package/dist/rest/topics.d.mts +110 -110
- package/dist/rest/trees.d.mts +66 -66
- package/dist/rest/wire.d.mts +1 -1
- package/dist/rest.d.mts +1 -7
- package/dist/rest.mjs +1 -5
- package/dist/server/git-layer.d.mts +10 -2
- package/dist/server/git-layer.mjs +29 -10
- package/dist/server/joined.d.mts +1 -1
- package/dist/server/server.d.mts +0 -1
- package/dist/server/server.mjs +26 -45
- package/dist/signin/context.d.mts +0 -1
- package/dist/signin/context.mjs +5 -9
- package/dist/storage/clean-up.mjs +3 -1
- package/dist/storage/fsck.mjs +12 -2
- package/dist/storage/graph-rebuild.mjs +262 -0
- package/dist/storage/index-build.mjs +100 -12
- package/dist/storage/lfs-pointers.d.mts +5 -5
- package/dist/storage/lfs-pointers.mjs +37 -11
- package/dist/storage/loose.mjs +4 -1
- package/dist/storage/memory-budget.mjs +1 -1
- package/dist/storage/merge-fence.mjs +81 -19
- package/dist/storage/merge-most.mjs +1 -0
- package/dist/storage/merge-row.mjs +16 -4
- package/dist/storage/merge-stream.mjs +9 -6
- package/dist/storage/object-rows.mjs +17 -1
- package/dist/storage/pack-receive.mjs +10 -6
- package/dist/storage/packs.mjs +58 -27
- package/dist/storage/prune.mjs +68 -40
- package/dist/storage/ready.d.mts +1 -1
- package/dist/storage/ready.mjs +12 -3
- package/dist/storage/receive-state.mjs +1 -1
- package/dist/storage/repack-contained.mjs +22 -14
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/repack.mjs +3 -2
- package/dist/storage/unpack.mjs +7 -0
- package/dist/store/call-count.d.mts +23 -3
- package/dist/store/call-count.mjs +36 -13
- package/dist/store/records.mjs +10 -4
- package/dist/store/repo-record.mjs +29 -12
- package/dist/store/scopes.mjs +6 -1
- package/dist/sync/import.mjs +14 -2
- package/dist/sync/layer.d.mts +5 -1
- package/dist/sync/layer.mjs +7 -2
- package/dist/sync/step.mjs +15 -15
- package/dist/topics/advance.mjs +7 -6
- package/dist/topics/members.mjs +38 -9
- package/package.json +3 -3
- package/dist/engine/merge-base-walk.d.mts +0 -3
- package/dist/server/routes.d.mts +0 -32
- package/dist/server/routes.mjs +0 -69
- package/dist/sync/bridge.d.mts +0 -6
- package/dist/sync/bridge.mjs +0 -29
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "../contracts/calls-spent.mjs";
|
|
2
2
|
import "../contracts/objects.mjs";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as HttpClient from "effect/http/HttpClient";
|
|
4
5
|
import { CallLimits } from "@ref0/infra";
|
|
5
6
|
import * as Context from "effect/Context";
|
|
6
7
|
import * as Layer from "effect/Layer";
|
|
@@ -50,9 +51,10 @@ export interface CallBudgetOptions {
|
|
|
50
51
|
}
|
|
51
52
|
declare const CallBudget_base: Context.ServiceClass<CallBudget, "@ref0/git/CallBudget", CallAllowance>;
|
|
52
53
|
/**
|
|
53
|
-
* A limit on the store and bucket calls an Effect makes,
|
|
54
|
-
* Each call Git makes in its scope counts into it as it starts: a store
|
|
55
|
-
* a
|
|
54
|
+
* A limit on the store and bucket calls an Effect makes, and its outbound HTTP requests, below the
|
|
55
|
+
* platform's on its request. Each call Git makes in its scope counts into it as it starts: a store
|
|
56
|
+
* call or a request through a `charged` client as a subrequest, and a bucket call as a bucket call
|
|
57
|
+
* and a subrequest, as `CallLimits` counts them.
|
|
56
58
|
*
|
|
57
59
|
* A budget lives as long as the Layer that built it: provide one around one call or one step,
|
|
58
60
|
* never in a runtime's Layer, where every request would share it until the runtime ends. Each
|
|
@@ -74,6 +76,18 @@ export declare class CallBudget extends /* @__PURE__ */ CallBudget_base {
|
|
|
74
76
|
static readonly make: (limits: CallLimits.CallLimits['Service'], options?: CallBudgetOptions) => Effect.Effect<CallAllowance>;
|
|
75
77
|
/** `make`'s budget, as a Layer: one new budget each time it's built. */
|
|
76
78
|
static readonly layer: (limits: CallLimits.CallLimits['Service'], options?: CallBudgetOptions) => Layer.Layer<CallBudget>;
|
|
79
|
+
/**
|
|
80
|
+
* `http`, each request it sends charged first, as one subrequest, to the request and every
|
|
81
|
+
* budget in scope when it's sent: one that would pass a bound is refused before it's sent with
|
|
82
|
+
* the defect `CallsSpent`, as a store call is. A retry wrapped around the charged client is
|
|
83
|
+
* charged each try, as a platform counts each, so `http` is a host's client with no retry
|
|
84
|
+
* middleware of its own: one beneath the charge would send uncounted. A redirect the client
|
|
85
|
+
* follows itself, as `fetch` does by default, is charged once with the request it answers, up to
|
|
86
|
+
* the 20 hops `fetch` follows; one asked for with `redirect: 'manual'` and followed by its caller
|
|
87
|
+
* is charged each hop. With nothing in scope, as a host's own call outside a job, it charges
|
|
88
|
+
* nothing.
|
|
89
|
+
*/
|
|
90
|
+
static readonly charged: (http: HttpClient.HttpClient) => HttpClient.HttpClient;
|
|
77
91
|
/**
|
|
78
92
|
* Whether the budget in scope, or one it nests in, has spent a kind of call it limits, so the
|
|
79
93
|
* next call of that kind is refused: a host's call answers `RESOURCE_EXHAUSTED`,
|
|
@@ -94,6 +108,12 @@ export interface CallScope {
|
|
|
94
108
|
readonly hold?: RequestHold | undefined;
|
|
95
109
|
/** Whether it runs after its request's deciding commit, as `afterCommit` marks it. */
|
|
96
110
|
readonly afterCommit?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* The loggers and least level where the call began, the host's on `Git.layer`'s runtime: a
|
|
113
|
+
* run across a Promise starts with Effect's defaults, so a line it logs, such as an unreadable
|
|
114
|
+
* index's, would reach the console and not the host's Logger.
|
|
115
|
+
*/
|
|
116
|
+
readonly logging?: Context.Context<never> | undefined;
|
|
97
117
|
}
|
|
98
118
|
/**
|
|
99
119
|
* What one call or one HTTP request keeps until it ends, which `withAudienceMemo` opens around
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { CallsSpent } from "../contracts/calls-spent.mjs";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as HttpClient from "effect/http/HttpClient";
|
|
3
4
|
import * as Option from "effect/Option";
|
|
4
5
|
import * as Predicate from "effect/Predicate";
|
|
5
6
|
import * as Context from "effect/Context";
|
|
6
7
|
import * as Layer from "effect/Layer";
|
|
8
|
+
import * as References from "effect/References";
|
|
7
9
|
// src/store/call-count.ts
|
|
8
10
|
/**
|
|
9
11
|
* The store calls a Git fetch's request makes before its count starts, which its `callLimits`
|
|
@@ -12,7 +14,7 @@ import * as Layer from "effect/Layer";
|
|
|
12
14
|
* refs, its haves and its tags' peels with its pack's (#709). Measured locally, not at a colo, by
|
|
13
15
|
* negotiation-calls.test.ts: a token's request refused at its bound made 1 call more than it
|
|
14
16
|
* counted. The host's own `auth` and grants aren't Git's calls: a host whose run subrequests sets
|
|
15
|
-
* `callLimits` lower by them. Its
|
|
17
|
+
* `callLimits` lower by them. Its fetch rules are `hookCallsBefore`'s.
|
|
16
18
|
*/
|
|
17
19
|
const requestCallsBefore = {
|
|
18
20
|
bucket: 0,
|
|
@@ -20,8 +22,8 @@ const requestCallsBefore = {
|
|
|
20
22
|
};
|
|
21
23
|
/**
|
|
22
24
|
* The calls one of the host's hooks makes before a Git request's count starts, beside
|
|
23
|
-
* `requestCallsBefore`'s:
|
|
24
|
-
*
|
|
25
|
+
* `requestCallsBefore`'s: the fetch rules, on a fetch. B1a's K read measured it on Workers, 2
|
|
26
|
+
* calls before the count with a hook against 1 with none. A hook that
|
|
25
27
|
* makes more sets `callLimits` lower by them.
|
|
26
28
|
*/
|
|
27
29
|
const hookCallsBefore = {
|
|
@@ -194,9 +196,10 @@ const lessBefore = (limits, before = requestCallsBefore) => {
|
|
|
194
196
|
return lessened;
|
|
195
197
|
};
|
|
196
198
|
/**
|
|
197
|
-
* A limit on the store and bucket calls an Effect makes,
|
|
198
|
-
* Each call Git makes in its scope counts into it as it starts: a store
|
|
199
|
-
* a
|
|
199
|
+
* A limit on the store and bucket calls an Effect makes, and its outbound HTTP requests, below the
|
|
200
|
+
* platform's on its request. Each call Git makes in its scope counts into it as it starts: a store
|
|
201
|
+
* call or a request through a `charged` client as a subrequest, and a bucket call as a bucket call
|
|
202
|
+
* and a subrequest, as `CallLimits` counts them.
|
|
200
203
|
*
|
|
201
204
|
* A budget lives as long as the Layer that built it: provide one around one call or one step,
|
|
202
205
|
* never in a runtime's Layer, where every request would share it until the runtime ends. Each
|
|
@@ -222,6 +225,18 @@ var CallBudget = class CallBudget extends (/* @__PURE__ */ Context.Service()("@r
|
|
|
222
225
|
/** `make`'s budget, as a Layer: one new budget each time it's built. */
|
|
223
226
|
static layer = (limits, options = {}) => Layer.effect(CallBudget, CallBudget.make(limits, options));
|
|
224
227
|
/**
|
|
228
|
+
* `http`, each request it sends charged first, as one subrequest, to the request and every
|
|
229
|
+
* budget in scope when it's sent: one that would pass a bound is refused before it's sent with
|
|
230
|
+
* the defect `CallsSpent`, as a store call is. A retry wrapped around the charged client is
|
|
231
|
+
* charged each try, as a platform counts each, so `http` is a host's client with no retry
|
|
232
|
+
* middleware of its own: one beneath the charge would send uncounted. A redirect the client
|
|
233
|
+
* follows itself, as `fetch` does by default, is charged once with the request it answers, up to
|
|
234
|
+
* the 20 hops `fetch` follows; one asked for with `redirect: 'manual'` and followed by its caller
|
|
235
|
+
* is charged each hop. With nothing in scope, as a host's own call outside a job, it charges
|
|
236
|
+
* nothing.
|
|
237
|
+
*/
|
|
238
|
+
static charged = (http) => HttpClient.transform(http, (effect) => Effect.andThen(chargeCall("fetch"), effect));
|
|
239
|
+
/**
|
|
225
240
|
* Whether the budget in scope, or one it nests in, has spent a kind of call it limits, so the
|
|
226
241
|
* next call of that kind is refused: a host's call answers `RESOURCE_EXHAUSTED`,
|
|
227
242
|
* `reason: 'call-budget'`.
|
|
@@ -323,21 +338,28 @@ const noScope = {
|
|
|
323
338
|
calls: void 0,
|
|
324
339
|
budget: void 0
|
|
325
340
|
};
|
|
326
|
-
/**
|
|
341
|
+
/**
|
|
342
|
+
* The call scope in context: its parts `undefined` with neither a request's count nor a budget,
|
|
343
|
+
* and the runtime's loggers, so a run across a Promise logs where the call began.
|
|
344
|
+
*/
|
|
327
345
|
const callScope = Effect.map(Effect.all([
|
|
328
346
|
requestCount,
|
|
329
347
|
Effect.serviceOption(CallBudget),
|
|
330
348
|
Effect.serviceOption(RequestHolding),
|
|
331
|
-
AfterCommit
|
|
332
|
-
|
|
349
|
+
AfterCommit,
|
|
350
|
+
References.CurrentLoggers,
|
|
351
|
+
References.MinimumLogLevel
|
|
352
|
+
]), ([calls, budget, hold, after, loggers, minimum]) => ({
|
|
333
353
|
calls,
|
|
334
354
|
budget: Option.getOrUndefined(budget),
|
|
335
355
|
hold: Option.getOrUndefined(hold),
|
|
336
|
-
afterCommit: after
|
|
337
|
-
|
|
356
|
+
afterCommit: after,
|
|
357
|
+
logging: Context.make(References.CurrentLoggers, loggers).pipe(Context.add(References.MinimumLogLevel, minimum))
|
|
358
|
+
}));
|
|
338
359
|
/**
|
|
339
360
|
* `effect`, run in `scope` and no other: with the request's count, the budget, the hold and
|
|
340
|
-
* the `afterCommit` mark it holds, and with none it doesn't hold, whatever the context had
|
|
361
|
+
* the `afterCommit` mark it holds, and with none it doesn't hold, whatever the context had, and
|
|
362
|
+
* with the loggers it carries, when it carries them. So a reader or a walk opened with no
|
|
341
363
|
* budget never takes one provided around a later call, and a run handed no scope counts nothing.
|
|
342
364
|
*/
|
|
343
365
|
const inCallScope = (effect, scope) => Effect.updateContext(effect, scopedContext(scope));
|
|
@@ -346,7 +368,8 @@ const scopedContext = (scope) => (context) => {
|
|
|
346
368
|
const counted = scope.calls === void 0 ? Context.omit(RequestCount)(context) : Context.add(context, RequestCount, scope.calls);
|
|
347
369
|
const budgeted = scope.budget === void 0 ? Context.omit(CallBudget)(counted) : Context.add(counted, CallBudget, scope.budget);
|
|
348
370
|
const held = scope.hold === void 0 ? Context.omit(RequestHolding)(budgeted) : Context.add(budgeted, RequestHolding, scope.hold);
|
|
349
|
-
|
|
371
|
+
const marked = Context.add(held, AfterCommit, scope.afterCommit === true);
|
|
372
|
+
return scope.logging === void 0 ? marked : Context.merge(marked, scope.logging);
|
|
350
373
|
};
|
|
351
374
|
/**
|
|
352
375
|
* One call of `kind`, counted into the request in scope and every `CallBudget` in scope, or
|
package/dist/store/records.mjs
CHANGED
|
@@ -64,9 +64,6 @@ const KeptRepoInfo = /* @__PURE__ */ Schema.Struct({
|
|
|
64
64
|
packs: Schema.optionalKey(Schema.Int),
|
|
65
65
|
packBytes: Schema.optionalKey(Schema.Int),
|
|
66
66
|
ownBytes: Schema.optionalKey(Schema.Int),
|
|
67
|
-
looseObjects: Schema.optionalKey(Schema.Int),
|
|
68
|
-
looseBytes: Schema.optionalKey(Schema.Int),
|
|
69
|
-
leavingBytes: Schema.optionalKey(Schema.Int),
|
|
70
67
|
pushedAt: Schema.optionalKey(Schema.Int),
|
|
71
68
|
maintainedAt: Schema.optionalKey(Schema.Int)
|
|
72
69
|
}),
|
|
@@ -243,6 +240,15 @@ const importJobName = "sync.import";
|
|
|
243
240
|
*/
|
|
244
241
|
const StatsTime = /* @__PURE__ */ Schema.Struct({ at: Schema.Int });
|
|
245
242
|
/**
|
|
243
|
+
* The repo's object rows, as `ObjectsChange.rows` counts them, in `stats`: how many it holds and
|
|
244
|
+
* their values' bytes, which `RepoStats.ownBytes` counts. Only the commits that move them write
|
|
245
|
+
* it, each at the version it read it at, so it's exact at every version (#2237).
|
|
246
|
+
*/
|
|
247
|
+
const LooseTally = /* @__PURE__ */ Schema.Struct({
|
|
248
|
+
objects: Schema.Int,
|
|
249
|
+
bytes: Schema.Int
|
|
250
|
+
});
|
|
251
|
+
/**
|
|
246
252
|
* A pack's row in `packs`, by its ID: `Pack` without its `id`, which is the row's. So it holds how
|
|
247
253
|
* many objects the pack holds, its bytes and its `.graph`'s; and `holds`, the packs it holds
|
|
248
254
|
* whole, on a pack a merge that kept every object wrote.
|
|
@@ -250,4 +256,4 @@ const StatsTime = /* @__PURE__ */ Schema.Struct({ at: Schema.Int });
|
|
|
250
256
|
const PackRow = Pack.mapFields(Struct.omit(["id"]));
|
|
251
257
|
/** A row's ID by its sequence number, zero-padded so the rows read in order. */
|
|
252
258
|
const versionId = (sequence) => String(sequence).padStart(16, "0");
|
|
253
|
-
export { CatalogueEntry, CreatedRow, ForkOf, ForkRow, KeptRepoInfo, PackRow, PrunedMark, ReachedMark, RefIndexBuilding, RenamedFrom, StatsTime, StoredRepo, callerKey, checkWriteKey, importJobName, keptKey, keyDigest, keyKept, keyLive, markHolds, mirrorJobName, takenBack, versionId };
|
|
259
|
+
export { CatalogueEntry, CreatedRow, ForkOf, ForkRow, KeptRepoInfo, LooseTally, PackRow, PrunedMark, ReachedMark, RefIndexBuilding, RenamedFrom, StatsTime, StoredRepo, callerKey, checkWriteKey, importJobName, keptKey, keyDigest, keyKept, keyLive, markHolds, mirrorJobName, takenBack, versionId };
|
|
@@ -2,8 +2,8 @@ import { checkChurn, decodeRecord, entryOf, project } from "./catalogue.mjs";
|
|
|
2
2
|
import { afterCommit } from "./call-count.mjs";
|
|
3
3
|
import { afterWrites, decodeRow, storeCall } from "./errors.mjs";
|
|
4
4
|
import { listJobRow } from "./list-job.mjs";
|
|
5
|
-
import { StatsTime } from "./records.mjs";
|
|
6
|
-
import { maintainedKey, newChangeId, pushedKey, repoScope, selfKey } from "./scopes.mjs";
|
|
5
|
+
import { LooseTally, StatsTime } from "./records.mjs";
|
|
6
|
+
import { looseKey, maintainedKey, newChangeId, pushedKey, repoScope, selfKey } from "./scopes.mjs";
|
|
7
7
|
import * as Effect from "effect/Effect";
|
|
8
8
|
// src/store/repo-record.ts
|
|
9
9
|
/** A repo's record and its scope's rows, read at one version: `results[0]` is `self`. */
|
|
@@ -50,11 +50,15 @@ const writeRecord = /* @__PURE__ */ Effect.fnUntraced(function* (store, internal
|
|
|
50
50
|
outcome
|
|
51
51
|
};
|
|
52
52
|
});
|
|
53
|
-
/**
|
|
54
|
-
const
|
|
53
|
+
/** A repo's `stats` rows, as `statsRead` reads them. */
|
|
54
|
+
const decodeStats = /* @__PURE__ */ Effect.fnUntraced(function* (rows) {
|
|
55
55
|
const times = {};
|
|
56
56
|
const privately = /* @__PURE__ */ new Map();
|
|
57
57
|
for (const row of rows) {
|
|
58
|
+
if (row.id === looseKey.id) {
|
|
59
|
+
times.loose = yield* decodeRow(LooseTally, row, "The repo's object rows' tally");
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
58
62
|
const { at } = yield* decodeRow(StatsTime, row, `The repo's '${row.id}' time`);
|
|
59
63
|
if (row.id === pushedKey.id) times.pushed = at;
|
|
60
64
|
else if (row.id === maintainedKey.id) times.maintained = at;
|
|
@@ -82,21 +86,34 @@ const timeRow = (key, held, now) => ({
|
|
|
82
86
|
...key,
|
|
83
87
|
value: { at: Math.max(held ?? now, now) }
|
|
84
88
|
});
|
|
85
|
-
/**
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
/**
|
|
90
|
+
* The `stats` row of a commit that moves the repo's object rows by `moved`, from `held`, the tally
|
|
91
|
+
* its read found: none for a commit that moves none, so a repo whose storage keeps no rows writes
|
|
92
|
+
* no tally.
|
|
93
|
+
*/
|
|
94
|
+
const looseRows = (held, moved) => moved.objects === 0 && moved.bytes === 0 ? [] : [{
|
|
95
|
+
...looseKey,
|
|
96
|
+
value: {
|
|
97
|
+
objects: (held?.objects ?? 0) + moved.objects,
|
|
98
|
+
bytes: (held?.bytes ?? 0) + moved.bytes
|
|
99
|
+
}
|
|
100
|
+
}];
|
|
101
|
+
/**
|
|
102
|
+
* A repo's stats, from its record, its refs' count, its listed packs, its `stats` rows and the
|
|
103
|
+
* bytes of the pack kept ready for a shallow clone, which no list names. Its object rows count in
|
|
104
|
+
* `ownBytes` alone, as `RepoStats` says.
|
|
105
|
+
*/
|
|
106
|
+
const repoStats = (record, refs, packs, times, readyBytes) => {
|
|
107
|
+
const packBytes = packs.reduce((sum, pack) => sum + pack.bytes, readyBytes);
|
|
88
108
|
const stats = {
|
|
89
109
|
repo: record.name,
|
|
90
110
|
refs,
|
|
91
111
|
packs: packs.length,
|
|
92
112
|
packBytes,
|
|
93
|
-
ownBytes: packBytes
|
|
94
|
-
looseObjects: 0,
|
|
95
|
-
looseBytes: 0,
|
|
96
|
-
leavingBytes: 0
|
|
113
|
+
ownBytes: packBytes + (times.loose?.bytes ?? 0)
|
|
97
114
|
};
|
|
98
115
|
if (times.pushed !== void 0) stats.pushedAt = times.pushed;
|
|
99
116
|
if (times.maintained !== void 0) stats.maintainedAt = times.maintained;
|
|
100
117
|
return stats;
|
|
101
118
|
};
|
|
102
|
-
export { commitRecord,
|
|
119
|
+
export { commitRecord, decodeStats, looseRows, readRecord, repoStats, seenTimes, timeRow, writeRecord };
|
package/dist/store/scopes.mjs
CHANGED
|
@@ -156,6 +156,11 @@ const maintainedKey = {
|
|
|
156
156
|
collection: collections.stats,
|
|
157
157
|
id: "maintained"
|
|
158
158
|
};
|
|
159
|
+
/** The repo's `LooseTally`: its object rows, which `stats.ownBytes` counts. */
|
|
160
|
+
const looseKey = {
|
|
161
|
+
collection: collections.stats,
|
|
162
|
+
id: "loose"
|
|
163
|
+
};
|
|
159
164
|
/** A new repo's internal ID: `r_` and 12 random bytes. */
|
|
160
165
|
const newInternalId = () => `r_${randomText(12)}`;
|
|
161
166
|
/** The repo a scope is, or `undefined` for a scope that's no repo's, such as a prefix's. */
|
|
@@ -171,4 +176,4 @@ const jobRepo = (job) => {
|
|
|
171
176
|
};
|
|
172
177
|
/** A commit's own ID, for a change no caller's key names. */
|
|
173
178
|
const newChangeId = () => randomText(16);
|
|
174
|
-
export { catalogueScope, collections, forkId, jobRepo, maintainedKey, newChangeId, newInternalId, prunedKey, pushedKey, pushedUnder, reachedKey, repoScope, scopeRepo, selfKey, topicScope, topicsScope };
|
|
179
|
+
export { catalogueScope, collections, forkId, jobRepo, looseKey, maintainedKey, newChangeId, newInternalId, prunedKey, pushedKey, pushedUnder, reachedKey, repoScope, scopeRepo, selfKey, topicScope, topicsScope };
|
package/dist/sync/import.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { fail, gitError } from "../contracts/result.mjs";
|
|
2
2
|
import { openRepo } from "../core/access.mjs";
|
|
3
3
|
import { CoreParts, QueueParts } from "../core/parts.mjs";
|
|
4
|
+
import { creatingRefView } from "../core/ref-view.mjs";
|
|
4
5
|
import { createWith, repoCalls } from "../core/repos.mjs";
|
|
5
6
|
import { hostRecordOf } from "../store/catalogue.mjs";
|
|
6
7
|
import { importJobName } from "../store/records.mjs";
|
|
@@ -13,6 +14,16 @@ import { cancelKey, importEndDeletes, importRow, readImport } from "../core/impo
|
|
|
13
14
|
import * as Effect from "effect/Effect";
|
|
14
15
|
import * as Schema from "effect/Schema";
|
|
15
16
|
// src/sync/import.ts
|
|
17
|
+
/**
|
|
18
|
+
* An importer who doesn't read every private pattern, refused for good (#2103): an import writes
|
|
19
|
+
* the repo's whole history, so who starts it sees the whole repo. `import` refuses one before it
|
|
20
|
+
* records anything, and each step asks again, as a view may narrow between them. Names no pattern.
|
|
21
|
+
*/
|
|
22
|
+
const partialImporter = () => gitError("NOT_ALLOWED", "An import into a repo with private branches needs an importer who reads them all", { hint: "Import as a caller who reads every private pattern" });
|
|
23
|
+
/** `caller`, refused as `partialImporter` unless their view of the repo `name` will be is whole. */
|
|
24
|
+
const wholeImporter = /* @__PURE__ */ Effect.fnUntraced(function* (caller, name) {
|
|
25
|
+
if (!(yield* creatingRefView(caller, name)).whole) return yield* Effect.fail(partialImporter());
|
|
26
|
+
});
|
|
16
27
|
/** The longest `import` waits between reads of the import's record. */
|
|
17
28
|
const pollMost = 2e3;
|
|
18
29
|
/** `sync.import`'s one key in each repo's scope. */
|
|
@@ -120,7 +131,8 @@ const importWith = /* @__PURE__ */ Effect.fnUntraced(function* (bound, input) {
|
|
|
120
131
|
jobs: [bound.importJob.job({
|
|
121
132
|
key: importJobKey,
|
|
122
133
|
data
|
|
123
|
-
})]
|
|
134
|
+
})],
|
|
135
|
+
check: (name) => wholeImporter(caller, name)
|
|
124
136
|
});
|
|
125
137
|
return yield* awaited(bound, input, internalId).pipe(Effect.mapError(afterWrites));
|
|
126
138
|
});
|
|
@@ -146,4 +158,4 @@ const cancelWith = /* @__PURE__ */ Effect.fnUntraced(function* (_bound, input) {
|
|
|
146
158
|
delete: importEndDeletes(read.row)
|
|
147
159
|
})).pipe(Effect.flatMap((committed) => committed.ok ? Effect.void : fail("UNAVAILABLE", `Other writes moved '${input.repo}'`, { hint: "Cancel again" })));
|
|
148
160
|
});
|
|
149
|
-
export { cancelWith, importJobKey, importWith };
|
|
161
|
+
export { cancelWith, importJobKey, importWith, partialImporter };
|
package/dist/sync/layer.d.mts
CHANGED
|
@@ -5,5 +5,9 @@ import { SyncBase } from "../core/parts.mjs";
|
|
|
5
5
|
import "./bound.mjs";
|
|
6
6
|
import * as HttpClient from "effect/http/HttpClient";
|
|
7
7
|
import * as Layer from "effect/Layer";
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Import and mirroring: registers sync and builds both jobs before Git seals its registry. Its
|
|
10
|
+
* provider calls go through the host's `HttpClient`, one with no retry middleware, since each
|
|
11
|
+
* request counts against its try's budget and sync's own retries sit above the charge.
|
|
12
|
+
*/
|
|
9
13
|
export declare const layer: (options: SyncLayerOptions) => Layer.Layer<Sync, GitError, Git | SyncBase | HttpClient.HttpClient>;
|
package/dist/sync/layer.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { fail } from "../contracts/result.mjs";
|
|
|
3
3
|
import { ImportJobData, MirrorJobData, Sync } from "../contracts/sync.mjs";
|
|
4
4
|
import { SyncBase } from "../core/parts.mjs";
|
|
5
5
|
import { withAudienceMemo } from "../core/ref-view.mjs";
|
|
6
|
+
import { CallBudget } from "../store/call-count.mjs";
|
|
6
7
|
import { gitJob } from "../store/job-try.mjs";
|
|
7
8
|
import { importJobName, mirrorJobName } from "../store/records.mjs";
|
|
8
9
|
import { importTryTimeout } from "../storage/receive-bounds.mjs";
|
|
@@ -37,7 +38,7 @@ const layerWith = (options, limits) => Layer.effectContext(Effect.gen(function*
|
|
|
37
38
|
}
|
|
38
39
|
const base = yield* SyncBase;
|
|
39
40
|
const registration = yield* register({ name: "sync" });
|
|
40
|
-
const http = yield* HttpClient.HttpClient;
|
|
41
|
+
const http = CallBudget.charged(yield* HttpClient.HttpClient);
|
|
41
42
|
const importJob = gitJob(Import, () => importTry(bound), { onFailure: (_data, failure) => importFailed(bound, failure) });
|
|
42
43
|
const mirrorJob = gitJob(Mirror, (data) => mirrorTry(bound, data));
|
|
43
44
|
const bound = {
|
|
@@ -63,6 +64,10 @@ const layerWith = (options, limits) => Layer.effectContext(Effect.gen(function*
|
|
|
63
64
|
publishImported: (input) => run(publishWith(bound, input))
|
|
64
65
|
}));
|
|
65
66
|
}));
|
|
66
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Import and mirroring: registers sync and builds both jobs before Git seals its registry. Its
|
|
69
|
+
* provider calls go through the host's `HttpClient`, one with no retry middleware, since each
|
|
70
|
+
* request counts against its try's budget and sync's own retries sit above the charge.
|
|
71
|
+
*/
|
|
67
72
|
const layer = (options) => layerWith(options, importLimits);
|
|
68
73
|
export { layer, layerWith };
|
package/dist/sync/step.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import "../contracts/ids.mjs";
|
|
2
2
|
import { gitError, gitErrorFrom } from "../contracts/result.mjs";
|
|
3
|
+
import { partialImporter } from "./import.mjs";
|
|
3
4
|
import { importedPullRefs } from "../contracts/sync.mjs";
|
|
4
5
|
import { push } from "../core/push.mjs";
|
|
5
6
|
import { refusedLead } from "../client/answer.mjs";
|
|
6
7
|
import { isRefName } from "../core/names.mjs";
|
|
7
|
-
import { utf8 } from "../protocol/bytes/text.mjs";
|
|
8
|
+
import { cutWords, utf8 } from "../protocol/bytes/text.mjs";
|
|
8
9
|
import { negotiate } from "../client/negotiate.mjs";
|
|
9
10
|
import { discover, fetchTerms, remoteRefsAndHeadOf } from "../client/remote.mjs";
|
|
10
11
|
import { objectsFace, oneShotReads, scopedReceiveStep } from "../storage/calls.mjs";
|
|
@@ -124,10 +125,13 @@ const finalRefusal = (failure) => {
|
|
|
124
125
|
if (failure.code === "RESOURCE_EXHAUSTED" && failure.context?.reason === "object-too-large") return failure;
|
|
125
126
|
if (failure.code !== "INVALID_ARGUMENT") return void 0;
|
|
126
127
|
const { context } = failure;
|
|
127
|
-
if (context?.reason === "fsck")
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
if (context?.reason === "fsck") {
|
|
129
|
+
const named = context.msgId === "duplicateEntries";
|
|
130
|
+
return gitErrorFrom(failure, {
|
|
131
|
+
message: named ? failure.message : `An object of the import fails Git's ${context.msgId} check`,
|
|
132
|
+
hint: `An object in the source's history fails Git's checks (${context.msgId}), so this repo can't be imported as it is. Delete this repo to clear it.`
|
|
133
|
+
});
|
|
134
|
+
}
|
|
131
135
|
if (context?.reason === "ofs-delta") return gitErrorFrom(failure, { hint: "The remote sent OFS_DELTA entries without being asked, so this repo can't be imported from that remote. Delete this repo to clear it." });
|
|
132
136
|
if (finalReasons.has(context?.reason)) return failure;
|
|
133
137
|
};
|
|
@@ -138,11 +142,6 @@ const refusedWordsMost = 512;
|
|
|
138
142
|
* bytes as UTF-8, well under a record's 1 MiB, so no refusal's words keep a record from failing.
|
|
139
143
|
*/
|
|
140
144
|
const failedMessageMost = 1024;
|
|
141
|
-
/** `text`'s first `most` UTF-16 units, the first half of a surrogate pair the cut splits dropped. */
|
|
142
|
-
const cutWords = (text, most) => {
|
|
143
|
-
const cut = text.slice(0, most);
|
|
144
|
-
return /[\uD800-\uDBFF]$/u.test(cut) ? cut.slice(0, -1) : cut;
|
|
145
|
-
};
|
|
146
145
|
/**
|
|
147
146
|
* Whether a remote's words may be shown: the import reached `remote` through the platform's own
|
|
148
147
|
* `fetch` with no credential, its own or in its URL. A remote's words may echo a credential, and a
|
|
@@ -377,7 +376,7 @@ const stepAfter = (step, bytes, most) => bytes < most / 4 ? Math.min(step * 2, s
|
|
|
377
376
|
* root is no longer one needs them, in its pack or the repo, whatever its answer claims, so no ref
|
|
378
377
|
* is published on a commit whose parents the repo lacks.
|
|
379
378
|
*/
|
|
380
|
-
const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, cut, remote
|
|
379
|
+
const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, cut, remote) {
|
|
381
380
|
const { bound, context } = attempt;
|
|
382
381
|
const most = bound.limits.packBytes;
|
|
383
382
|
const { store } = yield* CoreParts;
|
|
@@ -406,7 +405,7 @@ const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row,
|
|
|
406
405
|
request,
|
|
407
406
|
objects: oneShotReads(objects),
|
|
408
407
|
listed: opened.listed,
|
|
409
|
-
tips: [...new Set(
|
|
408
|
+
tips: [...new Set(opened.refs.values())],
|
|
410
409
|
held: row.deepest > 0 ? tips : []
|
|
411
410
|
}).pipe(Effect.mapError(fromRemote("negotiate a fetch")));
|
|
412
411
|
yield* report(context, "receive", row);
|
|
@@ -764,15 +763,16 @@ const stepIn = /* @__PURE__ */ Effect.fnUntraced(function* (attempt) {
|
|
|
764
763
|
const viewed = yield* importerView(attempt, row.by);
|
|
765
764
|
if (viewed === void 0) return void 0;
|
|
766
765
|
if (viewed.kind === "refused") return yield* forGood(viewed.error);
|
|
767
|
-
return yield*
|
|
766
|
+
if (!viewed.view.whole) return yield* forGood(partialImporter());
|
|
767
|
+
return yield* asSync(stepAs(attempt, read, row));
|
|
768
768
|
});
|
|
769
769
|
/** The step the record says is next, once who started the import is asked again. */
|
|
770
|
-
const stepAs = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, read, row
|
|
770
|
+
const stepAs = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, read, row) {
|
|
771
771
|
if (row.receiving !== void 0) return yield* resumed(attempt, row, row.receiving, read.cut);
|
|
772
772
|
if (row.copied) return yield* publish(attempt, row);
|
|
773
773
|
const remote = yield* remoteOf(attempt.bound, row.source, attempt.context.signal, "read");
|
|
774
774
|
if (row.tipPages === void 0) return yield* listTips(attempt, read.version, row, remote);
|
|
775
|
-
return yield* fetchSegment(attempt, row, read.cut, remote
|
|
775
|
+
return yield* fetchSegment(attempt, row, read.cut, remote);
|
|
776
776
|
});
|
|
777
777
|
/**
|
|
778
778
|
* Who started the import, asked again as they are now, as `viewAgainOf` asks: their view of the
|
package/dist/topics/advance.mjs
CHANGED
|
@@ -12,7 +12,8 @@ import { TopicsHost, saveMargin } from "./host.mjs";
|
|
|
12
12
|
import { addMember, candidateAt, memberRead, releaseMember, reserveMember } from "./members.mjs";
|
|
13
13
|
import { unwaited } from "./rows.mjs";
|
|
14
14
|
import { commitTopic, currentSet, durationWords, entriesOf, failureOf, readTopic, setKeyOf, topicOf } from "./topic.mjs";
|
|
15
|
-
import {
|
|
15
|
+
import { QueueParts, overStore } from "../core/parts.mjs";
|
|
16
|
+
import { checkedAnswer, plainAnswer } from "../core/rules/context.mjs";
|
|
16
17
|
import * as Clock$1 from "effect/Clock";
|
|
17
18
|
import * as Effect from "effect/Effect";
|
|
18
19
|
import * as Result from "effect/Result";
|
|
@@ -104,8 +105,7 @@ const requiredOf = /* @__PURE__ */ Effect.fnUntraced(function* (host, read) {
|
|
|
104
105
|
topic: read.id,
|
|
105
106
|
entries: entriesOf(read.row)
|
|
106
107
|
};
|
|
107
|
-
const
|
|
108
|
-
const asked = yield* Effect.result(hostCall(reports, "topics.required", {}, () => required(question)));
|
|
108
|
+
const asked = yield* Effect.result(hostCall("topics.required", {}, () => required(question)));
|
|
109
109
|
if (Result.isSuccess(asked)) return asked.success;
|
|
110
110
|
yield* block(read, hostError(asked.failure));
|
|
111
111
|
});
|
|
@@ -287,9 +287,11 @@ const beforeDecision = /* @__PURE__ */ Effect.fnUntraced(function* (host, read,
|
|
|
287
287
|
yield* block(read, ended);
|
|
288
288
|
return "again";
|
|
289
289
|
}
|
|
290
|
+
const waited = row.waitingSince ?? row.heldSince;
|
|
291
|
+
const freeze = waited !== void 0 && now - waited >= millis(waitTimeout) / 2;
|
|
290
292
|
if (row.state === "reserving") {
|
|
291
293
|
for (const member of inOrder(row.members)) {
|
|
292
|
-
const reserved = yield* reserveMember(member, { topic: read.id });
|
|
294
|
+
const reserved = yield* reserveMember(member, { topic: read.id }, freeze);
|
|
293
295
|
if (reserved.held && row.heldSince !== void 0) continue;
|
|
294
296
|
if (reserved.held) return yield* heldFrom(read, reserved.since);
|
|
295
297
|
if (!sameWait(reserved.waiting, row.waitingOn)) {
|
|
@@ -590,8 +592,7 @@ const prepareStep = /* @__PURE__ */ Effect.fnUntraced(function* (host, job) {
|
|
|
590
592
|
key: set,
|
|
591
593
|
attempt: job.attempt
|
|
592
594
|
};
|
|
593
|
-
const
|
|
594
|
-
const answered = yield* hostEffect(reports, "topics.prepare", {}, Effect.suspend(() => prepare.handler(input)), { timeout: prepare.timeout }).pipe(Effect.result);
|
|
595
|
+
const answered = yield* hostEffect("topics.prepare", {}, checkedAnswer("The topic's prepare", plainAnswer, () => prepare.handler(input)), { timeout: prepare.timeout }).pipe(Effect.result);
|
|
595
596
|
answer = Result.isFailure(answered) ? {
|
|
596
597
|
kind: "failed",
|
|
597
598
|
failure: hostError(answered.failure)
|
package/dist/topics/members.mjs
CHANGED
|
@@ -98,16 +98,20 @@ const memberWrite = (member, plan) => queueWrite(Effect.gen(function* () {
|
|
|
98
98
|
* Reserves `member`'s target for `own`: `held` once it's the topic's, `since` the commit that took
|
|
99
99
|
* it, which saved that time with the reservation, else what it waits on first. Not yet while
|
|
100
100
|
* another live topic holds it, or while a candidate or a hold is open on it, which the reservation
|
|
101
|
-
* would stop from publishing: the queue opens none past a waiting member, so the target drains.
|
|
102
|
-
*
|
|
101
|
+
* would stop from publishing: the queue opens none past a waiting member, so the target drains.
|
|
102
|
+
* With `freeze`, once the member has waited half its `waitTimeout`, candidates open on the target
|
|
103
|
+
* freeze it for `own`, unless another live topic froze it first: its queue opens none in another
|
|
104
|
+
* lane or ahead of the member by priority, so it drains within a check (Q1159). A reservation of
|
|
105
|
+
* an ended topic is free, and taken over.
|
|
103
106
|
*/
|
|
104
|
-
const reserveMember = (member, own) => memberWrite(member, (state) => Effect.gen(function* () {
|
|
105
|
-
const { reserved, open, holds, stalled } = state.row;
|
|
107
|
+
const reserveMember = (member, own, freeze = false) => memberWrite(member, (state) => Effect.gen(function* () {
|
|
108
|
+
const { reserved, open, holds, stalled, frozen } = state.row;
|
|
106
109
|
if (reserved?.topic === own.topic) return { answer: {
|
|
107
110
|
held: true,
|
|
108
111
|
since: reserved.since
|
|
109
112
|
} };
|
|
110
|
-
const
|
|
113
|
+
const { store } = yield* CoreParts;
|
|
114
|
+
const taken = reserved !== void 0 && (yield* isLive(store, reserved));
|
|
111
115
|
const at = {
|
|
112
116
|
repo: member.repo,
|
|
113
117
|
target: member.target
|
|
@@ -127,14 +131,35 @@ const reserveMember = (member, own) => memberWrite(member, (state) => Effect.gen
|
|
|
127
131
|
hold
|
|
128
132
|
}
|
|
129
133
|
} };
|
|
130
|
-
|
|
134
|
+
const waits = { answer: {
|
|
131
135
|
held: false,
|
|
132
136
|
waiting: at
|
|
133
137
|
} };
|
|
138
|
+
if (stalled === true) return waits;
|
|
139
|
+
if (open.length > 0) {
|
|
140
|
+
const mine = frozen?.topic === own.topic;
|
|
141
|
+
const other = frozen !== void 0 && !mine && (yield* isLive(store, frozen));
|
|
142
|
+
if (!freeze || mine || other) return waits;
|
|
143
|
+
const now = yield* Clock$1.currentTimeMillis;
|
|
144
|
+
const plan = new QueuePlan(state, now);
|
|
145
|
+
plan.setTarget({
|
|
146
|
+
...plan.row,
|
|
147
|
+
frozen: {
|
|
148
|
+
...own,
|
|
149
|
+
next: plan.next
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
return {
|
|
153
|
+
...waits,
|
|
154
|
+
plan
|
|
155
|
+
};
|
|
156
|
+
}
|
|
134
157
|
const since = yield* Clock$1.currentTimeMillis;
|
|
135
158
|
const plan = new QueuePlan(state, since);
|
|
159
|
+
const { frozen: _ended, ...unfrozen } = plan.row;
|
|
160
|
+
const row = frozen?.topic === own.topic ? unfrozen : plan.row;
|
|
136
161
|
plan.setTarget({
|
|
137
|
-
...
|
|
162
|
+
...row,
|
|
138
163
|
reserved: {
|
|
139
164
|
...own,
|
|
140
165
|
since
|
|
@@ -150,8 +175,8 @@ const reserveMember = (member, own) => memberWrite(member, (state) => Effect.gen
|
|
|
150
175
|
};
|
|
151
176
|
}));
|
|
152
177
|
/**
|
|
153
|
-
* Lets go of what `topic` holds on `member`'s target: its reservation,
|
|
154
|
-
* still open, which leaves the queue `removed` and frees every lane it held.
|
|
178
|
+
* Lets go of what `topic` holds on `member`'s target: its reservation, its freeze, and its
|
|
179
|
+
* member's entry, if still open, which leaves the queue `removed` and frees every lane it held.
|
|
155
180
|
*/
|
|
156
181
|
const releaseMember = /* @__PURE__ */ Effect.fnUntraced(function* (member, topic) {
|
|
157
182
|
const found = (yield* memberRead(member))?.state;
|
|
@@ -167,6 +192,10 @@ const releaseMember = /* @__PURE__ */ Effect.fnUntraced(function* (member, topic
|
|
|
167
192
|
const { reserved: _released, ...free } = plan.row;
|
|
168
193
|
plan.setTarget(free);
|
|
169
194
|
}
|
|
195
|
+
if (plan.row.frozen?.topic === topic.topic) {
|
|
196
|
+
const { frozen: _released, ...free } = plan.row;
|
|
197
|
+
plan.setTarget(free);
|
|
198
|
+
}
|
|
170
199
|
const id = owned.entry;
|
|
171
200
|
const entry = id === void 0 ? void 0 : state.entries.get(id);
|
|
172
201
|
const own = entry !== void 0 && isOpen(entry) && entry.topic?.topic === topic.topic;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ref0/git",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Git hosting as a library: a server, a client and their merges",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -62,12 +62,12 @@
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@ref0/infra": "0.
|
|
65
|
+
"@ref0/infra": "0.8.0",
|
|
66
66
|
"pako": "2.1.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@effect/vitest": "4.1.7",
|
|
70
|
-
"@ref0/xdiff-wasm": "0.
|
|
70
|
+
"@ref0/xdiff-wasm": "0.8.0",
|
|
71
71
|
"effect": "4.1.7",
|
|
72
72
|
"vite-plus": "1.8.0",
|
|
73
73
|
"vitest": "5.1.1"
|
package/dist/server/routes.d.mts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Policy } from "../auth/policy.mjs";
|
|
2
|
-
import { LfsFeature } from "../contracts/lfs.mjs";
|
|
3
|
-
import { ObjectsFactory } from "../contracts/objects.mjs";
|
|
4
|
-
import { GitServerOptions, ServerCalls } from "../contracts/server.mjs";
|
|
5
|
-
import { EffectCalls } from "../contracts/services.mjs";
|
|
6
|
-
import { Bucket, CallLimits, JobQueue, Records } from "@ref0/infra";
|
|
7
|
-
import * as Context from "effect/Context";
|
|
8
|
-
import * as Layer from "effect/Layer";
|
|
9
|
-
import * as HttpRouter from "effect/http/HttpRouter";
|
|
10
|
-
/** What `GitServer.routes` takes: `createGitServer`'s options but those its services give. */
|
|
11
|
-
export interface GitRoutesOptions<Objects extends ObjectsFactory = ObjectsFactory, Lfs extends LfsFeature | undefined = LfsFeature | undefined> extends Omit<GitServerOptions, 'adapter' | 'auth' | 'authorize' | 'objects' | 'lfs'> {
|
|
12
|
-
readonly objects: Objects;
|
|
13
|
-
readonly lfs?: Lfs;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* What the routes need: the host's records, jobs, call limits and `Policy`, and a bucket unless
|
|
17
|
-
* `loose()` without `lfs()`. `Auth` is optional, read if it's there. Any other service the host
|
|
18
|
-
* gives, as `BucketUploads`, the server takes too.
|
|
19
|
-
*/
|
|
20
|
-
export type GitRoutesServices<Objects extends ObjectsFactory, Lfs extends LfsFeature | undefined = undefined> = HttpRouter.HttpRouter | Records.Records | JobQueue.JobQueue | CallLimits.CallLimits | Policy | (Objects extends ObjectsFactory<false> ? [Lfs] extends [undefined] ? never : Bucket.Bucket : Bucket.Bucket);
|
|
21
|
-
/**
|
|
22
|
-
* Git's routes on a host's `HttpRouter`: the server `createGitServer` makes from `options`, over
|
|
23
|
-
* the host's services, its `Records`, `JobQueue`, `CallLimits` and `Bucket`, deciding with its `Policy` and `Auth`.
|
|
24
|
-
* Every URL under `basePath` answers as `createRestHandler`'s `fetch` does: REST's, then Git's
|
|
25
|
-
* protocol, then a JSON `404`. The server closes with the Layer.
|
|
26
|
-
*/
|
|
27
|
-
declare const routes: <Objects extends ObjectsFactory, Lfs extends LfsFeature | undefined = undefined>(options: GitRoutesOptions<Objects, Lfs>) => Layer.Layer<never, never, GitRoutesServices<Objects, Lfs>>;
|
|
28
|
-
/** The server's calls as Effects, and its routes as a Layer a host's router serves. */
|
|
29
|
-
export declare const GitServer: Context.Service<EffectCalls<ServerCalls, never>, EffectCalls<ServerCalls, never>> & {
|
|
30
|
-
routes: typeof routes;
|
|
31
|
-
};
|
|
32
|
-
export {};
|