@catamorphic/work-server 0.1.0-alpha.39 → 0.1.0-alpha.41
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/NOTICE.txt +7 -0
- package/README.md +9 -9
- package/dist/admission/routes.d.ts +1 -1
- package/dist/admission/routes.d.ts.map +1 -1
- package/dist/agent-capabilities.d.ts.map +1 -1
- package/dist/agents.d.ts +5 -6
- package/dist/agents.d.ts.map +1 -1
- package/dist/auth/fastify-auth.d.ts.map +1 -1
- package/dist/auth/work-auth-types.d.ts +2 -0
- package/dist/auth/work-auth-types.d.ts.map +1 -1
- package/dist/auth/work-auth.d.ts.map +1 -1
- package/dist/chunk-kcck20aw.js +676 -0
- package/dist/chunk-kcck20aw.js.map +11 -0
- package/dist/cluster.d.ts +8 -7
- package/dist/cluster.d.ts.map +1 -1
- package/dist/config.d.ts +5 -15
- package/dist/config.d.ts.map +1 -1
- package/dist/execution-config.d.ts +22 -0
- package/dist/execution-config.d.ts.map +1 -1
- package/dist/fake-agent.d.ts +1 -0
- package/dist/fake-agent.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2730 -2851
- package/dist/index.js.map +28 -28
- package/dist/machines/contract-kit.d.ts +91 -0
- package/dist/machines/contract-kit.d.ts.map +1 -0
- package/dist/machines/contract.d.ts +383 -0
- package/dist/machines/contract.d.ts.map +1 -0
- package/dist/machines/sequencer.d.ts +267 -0
- package/dist/machines/sequencer.d.ts.map +1 -0
- package/dist/machines/simulation.d.ts +124 -0
- package/dist/machines/simulation.d.ts.map +1 -0
- package/dist/machines/work-machines.d.ts +61 -0
- package/dist/machines/work-machines.d.ts.map +1 -0
- package/dist/server.d.ts +15 -11
- package/dist/server.d.ts.map +1 -1
- package/dist/setup/machines.d.ts +9 -17
- package/dist/setup/machines.d.ts.map +1 -1
- package/dist/shares/share-routes.d.ts +1 -1
- package/dist/shares/share-routes.d.ts.map +1 -1
- package/dist/testing.d.ts +8 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +1013 -0
- package/dist/testing.js.map +11 -0
- package/dist/workers/disk-care.d.ts +41 -0
- package/dist/workers/disk-care.d.ts.map +1 -0
- package/dist/workers/harness-sign-ins.d.ts +146 -0
- package/dist/workers/harness-sign-ins.d.ts.map +1 -0
- package/dist/workers/machine-store.d.ts +196 -0
- package/dist/workers/machine-store.d.ts.map +1 -0
- package/dist/workers/member-machine-routes.d.ts +5 -3
- package/dist/workers/member-machine-routes.d.ts.map +1 -1
- package/dist/workers/member-machines.d.ts +47 -28
- package/dist/workers/member-machines.d.ts.map +1 -1
- package/dist/workers/placement.d.ts +23 -40
- package/dist/workers/placement.d.ts.map +1 -1
- package/dist/workers/sign-ins.d.ts +44 -17
- package/dist/workers/sign-ins.d.ts.map +1 -1
- package/dist/workers/worker-protocol.d.ts +5 -2
- package/dist/workers/worker-protocol.d.ts.map +1 -1
- package/dist/workers/worker-registry.d.ts +174 -223
- package/dist/workers/worker-registry.d.ts.map +1 -1
- package/dist/workers/worker-routes.d.ts.map +1 -1
- package/dist/workers/worker-runtime.d.ts.map +1 -1
- package/package.json +31 -21
- package/src/admission/routes.ts +5 -2
- package/src/agent-capabilities.ts +22 -8
- package/src/agents.ts +52 -23
- package/src/auth/fastify-auth.ts +149 -17
- package/src/auth/work-auth-types.ts +2 -0
- package/src/auth/work-auth.ts +27 -0
- package/src/cluster.ts +115 -42
- package/src/config.ts +15 -41
- package/src/execution-config.ts +40 -0
- package/src/fake-agent.ts +21 -4
- package/src/index.ts +26 -12
- package/src/machines/contract-kit.ts +648 -0
- package/src/machines/contract.ts +522 -0
- package/src/machines/sequencer.ts +1010 -0
- package/src/machines/simulation.ts +833 -0
- package/src/machines/work-machines.ts +231 -0
- package/src/server.ts +235 -150
- package/src/setup/machines.ts +128 -121
- package/src/shares/share-routes.ts +17 -1
- package/src/testing.ts +22 -0
- package/src/workers/disk-care.ts +121 -0
- package/src/workers/fake-claude-cli.ts +95 -0
- package/src/workers/fake-codex-cli.ts +11 -4
- package/src/workers/harness-sign-ins.ts +580 -0
- package/src/workers/machine-store.ts +1065 -0
- package/src/workers/member-machine-routes.ts +92 -20
- package/src/workers/member-machines.ts +163 -99
- package/src/workers/placement.ts +59 -70
- package/src/workers/sign-ins.ts +109 -52
- package/src/workers/worker-protocol.ts +5 -2
- package/src/workers/worker-registry.ts +894 -754
- package/src/workers/worker-routes.ts +4 -1
- package/src/workers/worker-runtime.ts +55 -23
- package/dist/test-support.d.ts +0 -133
- package/dist/test-support.d.ts.map +0 -1
- package/dist/workers/codex-sign-ins.d.ts +0 -107
- package/dist/workers/codex-sign-ins.d.ts.map +0 -1
- package/dist/workers/install-script.d.ts +0 -71
- package/dist/workers/install-script.d.ts.map +0 -1
- package/dist/workers/machine-classes.d.ts +0 -115
- package/dist/workers/machine-classes.d.ts.map +0 -1
- package/dist/workers/machine-rules.d.ts +0 -402
- package/dist/workers/machine-rules.d.ts.map +0 -1
- package/src/test-support.ts +0 -404
- package/src/workers/codex-sign-ins.ts +0 -360
- package/src/workers/install-script.ts +0 -394
- package/src/workers/machine-classes.ts +0 -152
- package/src/workers/machine-rules.ts +0 -1954
|
@@ -1,402 +0,0 @@
|
|
|
1
|
-
import type { DB } from "@catamorphic/db";
|
|
2
|
-
import { type HetznerCloudMachines } from "@catamorphic/hetzner";
|
|
3
|
-
import { type Kysely } from "kysely";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import { type InstallTarget } from "./install-script.js";
|
|
6
|
-
import { type MachineClass, type MachinePlatform } from "./machine-classes.js";
|
|
7
|
-
import type { WorkWorkerRegistry } from "./worker-registry.js";
|
|
8
|
-
/** Days a released machine keeps its disk unless its rule says otherwise. */
|
|
9
|
-
export declare const DEFAULT_RETAIN_DAYS = 7;
|
|
10
|
-
/** Minutes a machine on demand stays once idle, unless its rule says otherwise. */
|
|
11
|
-
export declare const DEFAULT_IDLE_MINUTES = 10;
|
|
12
|
-
/** Minutes a machine on demand has to enroll before it is replaced. */
|
|
13
|
-
export declare const DEFAULT_ENROLL_MINUTES = 15;
|
|
14
|
-
/**
|
|
15
|
-
* Machines that come and go with the work waiting for them (ADR 0258): up
|
|
16
|
-
* to `max`, keeping `min` warm, each destroyed once idle for
|
|
17
|
-
* `idleMinutes`, and replaced when it does not enroll within
|
|
18
|
-
* `enrollMinutes`.
|
|
19
|
-
*/
|
|
20
|
-
declare const DemandSchema: z.ZodObject<{
|
|
21
|
-
max: z.ZodNumber;
|
|
22
|
-
min: z.ZodDefault<z.ZodNumber>;
|
|
23
|
-
idleMinutes: z.ZodDefault<z.ZodNumber>;
|
|
24
|
-
enrollMinutes: z.ZodDefault<z.ZodNumber>;
|
|
25
|
-
}, z.core.$strict>;
|
|
26
|
-
export type MachineDemand = z.output<typeof DemandSchema>;
|
|
27
|
-
/** How many machines a rule gives, and to whom. */
|
|
28
|
-
declare const RuleMachinesSchema: z.ZodUnion<readonly [z.ZodLiteral<"each-member">, z.ZodObject<{
|
|
29
|
-
shared: z.ZodNumber;
|
|
30
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
31
|
-
demand: z.ZodObject<{
|
|
32
|
-
max: z.ZodNumber;
|
|
33
|
-
min: z.ZodDefault<z.ZodNumber>;
|
|
34
|
-
idleMinutes: z.ZodDefault<z.ZodNumber>;
|
|
35
|
-
enrollMinutes: z.ZodDefault<z.ZodNumber>;
|
|
36
|
-
}, z.core.$strict>;
|
|
37
|
-
}, z.core.$strict>]>;
|
|
38
|
-
type RuleMachines = z.output<typeof RuleMachinesSchema>;
|
|
39
|
-
/**
|
|
40
|
-
* A machine rule (ADRs 0167, 0205, 0258): every active member of a
|
|
41
|
-
* directory group gets a machine of their own, the group shares a fixed
|
|
42
|
-
* number of machines, or machines come and go with the work waiting for
|
|
43
|
-
* them, of a machine class. Machines on demand serve a group's members or
|
|
44
|
-
* named projects' own work (project chats and automations). A machine
|
|
45
|
-
* nobody should have any more is released and kept for `retainDays` before
|
|
46
|
-
* it is destroyed or reset; a machine on demand keeps nothing.
|
|
47
|
-
*/
|
|
48
|
-
export declare const MachineRuleSchema: z.ZodPipe<z.ZodObject<{
|
|
49
|
-
group: z.ZodOptional<z.ZodEmail>;
|
|
50
|
-
projects: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
|
|
51
|
-
machines: z.ZodUnion<readonly [z.ZodLiteral<"each-member">, z.ZodObject<{
|
|
52
|
-
shared: z.ZodNumber;
|
|
53
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
54
|
-
demand: z.ZodObject<{
|
|
55
|
-
max: z.ZodNumber;
|
|
56
|
-
min: z.ZodDefault<z.ZodNumber>;
|
|
57
|
-
idleMinutes: z.ZodDefault<z.ZodNumber>;
|
|
58
|
-
enrollMinutes: z.ZodDefault<z.ZodNumber>;
|
|
59
|
-
}, z.core.$strict>;
|
|
60
|
-
}, z.core.$strict>]>;
|
|
61
|
-
class: z.ZodString;
|
|
62
|
-
labels: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
63
|
-
trusted: z.ZodDefault<z.ZodBoolean>;
|
|
64
|
-
retainDays: z.ZodOptional<z.ZodNumber>;
|
|
65
|
-
}, z.core.$strict>, z.ZodTransform<{
|
|
66
|
-
group?: string | undefined;
|
|
67
|
-
projects?: string[] | undefined;
|
|
68
|
-
machines: "each-member" | {
|
|
69
|
-
shared: number;
|
|
70
|
-
} | {
|
|
71
|
-
demand: {
|
|
72
|
-
max: number;
|
|
73
|
-
min: number;
|
|
74
|
-
idleMinutes: number;
|
|
75
|
-
enrollMinutes: number;
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
class: string;
|
|
79
|
-
labels: Record<string, string>;
|
|
80
|
-
trusted: boolean;
|
|
81
|
-
retainDays: number;
|
|
82
|
-
}, {
|
|
83
|
-
group?: string | undefined;
|
|
84
|
-
projects?: string[] | undefined;
|
|
85
|
-
machines: "each-member" | {
|
|
86
|
-
shared: number;
|
|
87
|
-
} | {
|
|
88
|
-
demand: {
|
|
89
|
-
max: number;
|
|
90
|
-
min: number;
|
|
91
|
-
idleMinutes: number;
|
|
92
|
-
enrollMinutes: number;
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
class: string;
|
|
96
|
-
labels: Record<string, string>;
|
|
97
|
-
trusted: boolean;
|
|
98
|
-
retainDays?: number | undefined;
|
|
99
|
-
}>>;
|
|
100
|
-
export type MachineRule = z.output<typeof MachineRuleSchema>;
|
|
101
|
-
/** A rule's demand settings, when its machines come and go with demand. */
|
|
102
|
-
export declare function demandOf(rule: {
|
|
103
|
-
machines: RuleMachines;
|
|
104
|
-
}): MachineDemand | undefined;
|
|
105
|
-
/**
|
|
106
|
-
* Creates and destroys worker machines on a platform (a cloud, a
|
|
107
|
-
* virtualization host) for `custom` classes. A created machine starts the
|
|
108
|
-
* Work worker with the given control plane and one-time enrollment code,
|
|
109
|
-
* for example by running `enrollment.cloudInit` through cloud-init; it
|
|
110
|
-
* enrolls itself. `create` throws {@link MachineProvisioningRefusedError}
|
|
111
|
-
* when the platform refused and created nothing, so the next pass tries
|
|
112
|
-
* again with a new code; any other error keeps the code, since the machine
|
|
113
|
-
* may still come up and enroll.
|
|
114
|
-
*
|
|
115
|
-
* Work never calls `create` twice with one enrollment code, so `create` is
|
|
116
|
-
* idempotent per code: use `enrollment.idempotencyKey`, a hash of the code,
|
|
117
|
-
* as the platform's idempotency token, never the name, which a
|
|
118
|
-
* later machine of the same rule reuses once this one is gone. `destroy`
|
|
119
|
-
* removes the machine `ref` names and every machine named `name` (a create
|
|
120
|
-
* that failed uncertainly may have made one with no recorded ref), and
|
|
121
|
-
* says whether they are gone: `{ done: false }` while a destruction is
|
|
122
|
-
* under way or a machine may still appear, and Work asks again on later
|
|
123
|
-
* passes, forgetting the machine only once it is done.
|
|
124
|
-
*/
|
|
125
|
-
export interface MachineProvisioner {
|
|
126
|
-
create(args: {
|
|
127
|
-
name: string;
|
|
128
|
-
class: string;
|
|
129
|
-
/** The rule the machine is for. */
|
|
130
|
-
rule: string;
|
|
131
|
-
/** The class's `options` from `WORK_MACHINES_CONFIG`, as written. */
|
|
132
|
-
options?: Readonly<Record<string, unknown>>;
|
|
133
|
-
/**
|
|
134
|
-
* Machines on demand (ADR 0258): what the work waiting for this
|
|
135
|
-
* machine needs, to size it. Absent for a machine kept warm.
|
|
136
|
-
*/
|
|
137
|
-
waiting?: {
|
|
138
|
-
resources: Readonly<{
|
|
139
|
-
cpuMillis?: number;
|
|
140
|
-
memoryMb?: number;
|
|
141
|
-
storageMb?: number;
|
|
142
|
-
gpu?: boolean;
|
|
143
|
-
}>;
|
|
144
|
-
capabilities: readonly string[];
|
|
145
|
-
};
|
|
146
|
-
labels: Readonly<Record<string, string>>;
|
|
147
|
-
enrollment: {
|
|
148
|
-
controlPlaneUrl: string;
|
|
149
|
-
code: string;
|
|
150
|
-
/** A hash of `code`: the platform's idempotency token for this create. */
|
|
151
|
-
idempotencyKey: string;
|
|
152
|
-
/**
|
|
153
|
-
* Cloud-init user data that installs the worker with this code (ADR
|
|
154
|
-
* 0205), when the server knows its worker image.
|
|
155
|
-
*/
|
|
156
|
-
cloudInit?: string;
|
|
157
|
-
};
|
|
158
|
-
}): Promise<{
|
|
159
|
-
ref: string;
|
|
160
|
-
}>;
|
|
161
|
-
/**
|
|
162
|
-
* Destroy the machine `ref` names and every machine named `name`; done
|
|
163
|
-
* once none is left.
|
|
164
|
-
*/
|
|
165
|
-
destroy(args: {
|
|
166
|
-
name: string;
|
|
167
|
-
ref: string | null;
|
|
168
|
-
}): Promise<{
|
|
169
|
-
done: boolean;
|
|
170
|
-
}>;
|
|
171
|
-
}
|
|
172
|
-
/** A platform refused to create a machine, and created nothing. */
|
|
173
|
-
export declare class MachineProvisioningRefusedError extends Error {
|
|
174
|
-
constructor(message: string);
|
|
175
|
-
}
|
|
176
|
-
/** What one pass changed. */
|
|
177
|
-
export interface ReconcileSummary {
|
|
178
|
-
/** Machines created on a platform. */
|
|
179
|
-
created: string[];
|
|
180
|
-
/** Pooled machines handed to a rule, and released machines handed back. */
|
|
181
|
-
assigned: string[];
|
|
182
|
-
/** Machines whose placement drifted from their rule's. */
|
|
183
|
-
updated: string[];
|
|
184
|
-
/** Machines that now serve nobody and keep their disk for a while. */
|
|
185
|
-
released: string[];
|
|
186
|
-
/** Machines destroyed on their platform. */
|
|
187
|
-
removed: string[];
|
|
188
|
-
/** Machines whose destruction is under way (a snapshot being written). */
|
|
189
|
-
destroying: string[];
|
|
190
|
-
/** Pooled machines reset and free again. */
|
|
191
|
-
reset: string[];
|
|
192
|
-
/** What went wrong, by machine (or rule) and the rule it belongs to. */
|
|
193
|
-
failed: Array<{
|
|
194
|
-
name: string;
|
|
195
|
-
error: string;
|
|
196
|
-
rule?: string;
|
|
197
|
-
}>;
|
|
198
|
-
/** Another replica was reconciling; its pass covers this one. */
|
|
199
|
-
busy?: true;
|
|
200
|
-
}
|
|
201
|
-
/** How a rule's machines stand, for the operator. */
|
|
202
|
-
export interface MachineRuleStatus {
|
|
203
|
-
platform: MachinePlatform | null;
|
|
204
|
-
/** Machines the rule calls for now. */
|
|
205
|
-
desired: number;
|
|
206
|
-
/** Enrolled and serving their people. */
|
|
207
|
-
ready: number;
|
|
208
|
-
/** Created and not yet enrolled. */
|
|
209
|
-
starting: number;
|
|
210
|
-
/** Without a machine: a pool with none free, or not created yet. */
|
|
211
|
-
waiting: number;
|
|
212
|
-
/** Released and kept for their retention. */
|
|
213
|
-
released: number;
|
|
214
|
-
/** Machines on demand: work waiting for one of this rule's machines. */
|
|
215
|
-
queued?: number;
|
|
216
|
-
/**
|
|
217
|
-
* What keeps the rule from being acted on fully: an unknown class (its
|
|
218
|
-
* machines are left as they are), a machine on demand that never
|
|
219
|
-
* connected (no more are made until the rule is written again), or work
|
|
220
|
-
* its machines cannot take.
|
|
221
|
-
*/
|
|
222
|
-
problem?: string;
|
|
223
|
-
/** What failed for the rule's machines in the latest pass. */
|
|
224
|
-
failure?: {
|
|
225
|
-
error: string;
|
|
226
|
-
at: string;
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Keeps workers in step with machine rules and the directory (ADR 0205):
|
|
231
|
-
* creates cloud machines and assigns pooled ones that are missing, updates
|
|
232
|
-
* placement that drifted, releases machines nobody should have any more,
|
|
233
|
-
* and destroys or resets them once their retention ends. Retention runs on
|
|
234
|
-
* the database's clock, so replicas agree on it.
|
|
235
|
-
*/
|
|
236
|
-
export declare class MachineReconciler {
|
|
237
|
-
private readonly deps;
|
|
238
|
-
private running;
|
|
239
|
-
private readonly holder;
|
|
240
|
-
constructor(deps: {
|
|
241
|
-
db: Kysely<DB>;
|
|
242
|
-
tenantId: string;
|
|
243
|
-
workers: WorkWorkerRegistry;
|
|
244
|
-
/** `WORK_MACHINES_CONFIG` classes; none means every class is custom. */
|
|
245
|
-
classes: Readonly<Record<string, MachineClass>>;
|
|
246
|
-
/** The `machineProvisioner` hook, for custom classes. */
|
|
247
|
-
provisioner?: MachineProvisioner;
|
|
248
|
-
/** For hetzner-cloud classes. */
|
|
249
|
-
hetzner?: HetznerCloudMachines;
|
|
250
|
-
/** What machines install, or why they cannot. */
|
|
251
|
-
install: {
|
|
252
|
-
target: InstallTarget;
|
|
253
|
-
} | {
|
|
254
|
-
unavailable: string;
|
|
255
|
-
};
|
|
256
|
-
controlPlaneUrl: string;
|
|
257
|
-
/** A user's sign-in email, for dedicated machines' access. */
|
|
258
|
-
emailOf: (userId: string) => Promise<string | undefined>;
|
|
259
|
-
/** How long a pass holds its claim without renewing (default 2 minutes). */
|
|
260
|
-
leaseMs?: number;
|
|
261
|
-
/**
|
|
262
|
-
* How long a pass waits for one pooled machine's reset (default 3
|
|
263
|
-
* minutes); a slower reset finishes on a later pass.
|
|
264
|
-
*/
|
|
265
|
-
resetWaitMs?: number;
|
|
266
|
-
log?: (line: string) => void;
|
|
267
|
-
});
|
|
268
|
-
rules(): Promise<Record<string, MachineRule>>;
|
|
269
|
-
/**
|
|
270
|
-
* Write a rule. Its class must be one the server knows: a configured
|
|
271
|
-
* class, or any class when only the provisioner hook is configured.
|
|
272
|
-
*/
|
|
273
|
-
setRule(args: {
|
|
274
|
-
name: string;
|
|
275
|
-
rule: unknown;
|
|
276
|
-
}): Promise<MachineRule>;
|
|
277
|
-
/**
|
|
278
|
-
* Remove a rule. Its machines keep the rule's retention, which outlives
|
|
279
|
-
* it, and are released by the next pass.
|
|
280
|
-
*/
|
|
281
|
-
deleteRule(name: string): Promise<boolean>;
|
|
282
|
-
/** Directory groups rules name, for the directory mirror. */
|
|
283
|
-
groups(): Promise<string[]>;
|
|
284
|
-
/** How each rule's machines stand right now. */
|
|
285
|
-
status(): Promise<Record<string, MachineRuleStatus>>;
|
|
286
|
-
/**
|
|
287
|
-
* One pass; concurrent callers share it, and replicas take turns: a pass
|
|
288
|
-
* runs only while this replica holds the tenant's reconciler claim (ADR
|
|
289
|
-
* 0193), renewed as it goes and checked before every change it makes.
|
|
290
|
-
*/
|
|
291
|
-
reconcile(): Promise<ReconcileSummary>;
|
|
292
|
-
/**
|
|
293
|
-
* Start a pass without waiting for it, as after a rule changed: its
|
|
294
|
-
* outcome reaches the rule's status and the log.
|
|
295
|
-
*/
|
|
296
|
-
reconcileSoon(): void;
|
|
297
|
-
/** Waits for a pass in progress (shutdown); starts none. */
|
|
298
|
-
settle(): Promise<void>;
|
|
299
|
-
private get leaseMs();
|
|
300
|
-
private guardedPass;
|
|
301
|
-
/** Each rule's failures in this pass, or none, for its status. */
|
|
302
|
-
private recordFailures;
|
|
303
|
-
/**
|
|
304
|
-
* Records what it changes in `summary`; `fence` throws once another
|
|
305
|
-
* reconciler holds the claim, ending the pass with what it did so far.
|
|
306
|
-
*/
|
|
307
|
-
private pass;
|
|
308
|
-
/**
|
|
309
|
-
* Run one machine's step; a failure is recorded for it and the pass goes
|
|
310
|
-
* on with the next machine. Losing the claim still ends the pass.
|
|
311
|
-
*/
|
|
312
|
-
private step;
|
|
313
|
-
/** Cloud and custom machines: one per desired name. */
|
|
314
|
-
private reconcileProvisioned;
|
|
315
|
-
/**
|
|
316
|
-
* Create a missing machine. Nothing is issued while machines cannot
|
|
317
|
-
* install from this server. A platform that refused creates nothing, so
|
|
318
|
-
* its code is withdrawn and the next pass tries again; after any other
|
|
319
|
-
* failure the code stays, since the machine may still come up and enroll.
|
|
320
|
-
*/
|
|
321
|
-
private create;
|
|
322
|
-
/**
|
|
323
|
-
* Pooled machines (ADR 0205): each place a pool rule calls for holds one
|
|
324
|
-
* free machine of its class. Machines nobody holds any more are released,
|
|
325
|
-
* then reset through their worker once their retention ends.
|
|
326
|
-
*/
|
|
327
|
-
private reconcilePooled;
|
|
328
|
-
/** Create a machine on its class's platform; resolves with its ref. */
|
|
329
|
-
private provision;
|
|
330
|
-
/**
|
|
331
|
-
* Destroy a machine on the platform that made it, by its reference or
|
|
332
|
-
* else by its name. False while the destruction is still under way.
|
|
333
|
-
*/
|
|
334
|
-
private unprovision;
|
|
335
|
-
/**
|
|
336
|
-
* How long a machine holding workspaces may go unseen before it is lost
|
|
337
|
-
* and revoked anyway: its rule's `enrollMinutes` for machines on demand.
|
|
338
|
-
*/
|
|
339
|
-
private lostAfterMs;
|
|
340
|
-
/** Whether machines of this class are known to run plain processes. */
|
|
341
|
-
private runsPlainProcesses;
|
|
342
|
-
/**
|
|
343
|
-
* The class a name refers to: a configured one, or with none configured
|
|
344
|
-
* any class, handled by the provisioner hook.
|
|
345
|
-
*/
|
|
346
|
-
private classOf;
|
|
347
|
-
/** Retention: the rule's now, else what the machine recorded. */
|
|
348
|
-
private retainDaysOf;
|
|
349
|
-
private desired;
|
|
350
|
-
/**
|
|
351
|
-
* What machines on demand decide on (ADR 0258): the work waiting for a
|
|
352
|
-
* machine with a turn queued, tried recently and oldest first, with its
|
|
353
|
-
* owner's directory groups; every machine a rule provisioned; how busy
|
|
354
|
-
* each enrolled one is; and machines that enrolled since their rule was
|
|
355
|
-
* last written and never connected.
|
|
356
|
-
*/
|
|
357
|
-
private demandState;
|
|
358
|
-
/**
|
|
359
|
-
* Whether demand changed since a pass of this replica last looked (ADR
|
|
360
|
-
* 0258): one indexed statement every few seconds, a full pass only when
|
|
361
|
-
* the work waiting for machines, or the work on rules' machines, changed
|
|
362
|
-
* since the latest pass started. A change that came during a pass, or
|
|
363
|
-
* while another replica held the claim, starts one on the next look. Idle
|
|
364
|
-
* machines go on the regular pass. What it remembers is this replica's
|
|
365
|
-
* own shortcut (ADR 0193): another replica looks for itself, and the pass
|
|
366
|
-
* runs under the tenant's claim either way.
|
|
367
|
-
*/
|
|
368
|
-
checkDemand(): Promise<void>;
|
|
369
|
-
/** What the latest pass of this replica saw; see {@link checkDemand}. */
|
|
370
|
-
private demandSeen;
|
|
371
|
-
/** Demand, in one statement; undefined while no rule is on demand. */
|
|
372
|
-
private demandSignature;
|
|
373
|
-
/** Active accounts the directory last placed in the group. */
|
|
374
|
-
private members;
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* A stable worker name for one person's machine under one rule. The class
|
|
378
|
-
* is part of it: a new class means a new machine, never a relabeled one.
|
|
379
|
-
*/
|
|
380
|
-
export declare function dedicatedName(rule: string, userId: string, machineClass: string): string;
|
|
381
|
-
/**
|
|
382
|
-
* A stable worker name for a group's shared machine. The class and the
|
|
383
|
-
* group are part of it: another group never inherits a machine and its disk.
|
|
384
|
-
*/
|
|
385
|
-
export declare function sharedName(rule: string, machineClass: string, group: string, index: number): string;
|
|
386
|
-
/**
|
|
387
|
-
* A stable worker name for a machine on demand. The class and whom it
|
|
388
|
-
* serves (a group, or the projects) are part of it: a machine never moves
|
|
389
|
-
* to other people's work with its disk.
|
|
390
|
-
*/
|
|
391
|
-
export declare function demandName(args: {
|
|
392
|
-
rule: string;
|
|
393
|
-
machineClass: string;
|
|
394
|
-
scope: {
|
|
395
|
-
group: string;
|
|
396
|
-
} | {
|
|
397
|
-
projects: readonly string[];
|
|
398
|
-
};
|
|
399
|
-
index: number;
|
|
400
|
-
}): string;
|
|
401
|
-
export {};
|
|
402
|
-
//# sourceMappingURL=machine-rules.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"machine-rules.d.ts","sourceRoot":"","sources":["../../src/workers/machine-rules.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,KAAK,MAAM,EAAO,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAQ9B,OAAO,KAAK,EAIV,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAI9B,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,mFAAmF;AACnF,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,uEAAuE;AACvE,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAIzC;;;;;GAKG;AACH,QAAA,MAAM,YAAY;;;;;kBAsBd,CAAC;AACL,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC;AAE1D,mDAAmD;AACnD,QAAA,MAAM,kBAAkB;;;;;;;;;oBAItB,CAAC;AACH,KAAK,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAExD;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CzB,CAAC;AACN,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE7D,2EAA2E;AAC3E,wB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