@smoothbricks/nx-plugin 0.7.18 → 0.7.19
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/README.md +160 -99
- package/dist/.build-inputs.json +35 -29
- package/dist/built-output-packages.js +1 -1
- package/dist/cargo-closure-input.js +1 -1
- package/dist/cargo-source-hash.d.ts +3 -21
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +4 -91
- package/dist/cargo-toolchain-paths.d.ts +2 -2
- package/dist/cargo-toolchain-paths.js +2 -2
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +2 -1
- package/dist/executors/bounded-exec/admission-queue.d.ts +3 -1
- package/dist/executors/bounded-exec/admission-queue.d.ts.map +1 -1
- package/dist/executors/bounded-exec/admission-queue.js +9 -10
- package/dist/executors/bounded-exec/awake-clock.d.ts +5 -0
- package/dist/executors/bounded-exec/awake-clock.d.ts.map +1 -0
- package/dist/executors/bounded-exec/awake-clock.js +22 -0
- package/dist/executors/bounded-exec/bounds.d.ts +7 -5
- package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
- package/dist/executors/bounded-exec/bounds.js +14 -11
- package/dist/executors/bounded-exec/case-gate.d.ts +114 -0
- package/dist/executors/bounded-exec/case-gate.d.ts.map +1 -0
- package/dist/executors/bounded-exec/case-gate.js +342 -0
- package/dist/executors/bounded-exec/cpu-pool-thread.d.ts +1 -0
- package/dist/executors/bounded-exec/cpu-pool-thread.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool-thread.js +2 -2
- package/dist/executors/bounded-exec/cpu-pool.d.ts +28 -1
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool.js +102 -16
- package/dist/executors/bounded-exec/endpoint-life.d.ts +146 -0
- package/dist/executors/bounded-exec/endpoint-life.d.ts.map +1 -0
- package/dist/executors/bounded-exec/endpoint-life.js +228 -0
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +207 -69
- package/dist/executors/bounded-exec/gateway-lease.d.ts +1 -1
- package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
- package/dist/executors/bounded-exec/gateway-lease.js +8 -1
- package/dist/executors/bounded-exec/go-run-summary.d.ts +51 -0
- package/dist/executors/bounded-exec/go-run-summary.d.ts.map +1 -0
- package/dist/executors/bounded-exec/go-run-summary.js +98 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +3 -3
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
- package/dist/executors/bounded-exec/hang-diagnostics.js +66 -48
- package/dist/executors/bounded-exec/lease-wait.d.ts +1 -0
- package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -1
- package/dist/executors/bounded-exec/lease-wait.js +1 -0
- package/dist/executors/bounded-exec/mbx-pool.d.ts +28 -7
- package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-pool.js +30 -9
- package/dist/executors/bounded-exec/mbx-reservations.d.ts +8 -5
- package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-reservations.js +187 -283
- package/dist/executors/bounded-exec/parent-grant.d.ts +2 -0
- package/dist/executors/bounded-exec/parent-grant.d.ts.map +1 -1
- package/dist/executors/bounded-exec/parent-grant.js +1 -0
- package/dist/executors/bounded-exec/pool-admission.d.ts +29 -3
- package/dist/executors/bounded-exec/pool-admission.d.ts.map +1 -1
- package/dist/executors/bounded-exec/pool-admission.js +47 -1
- package/dist/executors/bounded-exec/progress.d.ts +3 -0
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
- package/dist/executors/bounded-exec/progress.js +31 -1
- package/dist/executors/bounded-exec/reservation-connection.d.ts +90 -0
- package/dist/executors/bounded-exec/reservation-connection.d.ts.map +1 -0
- package/dist/executors/bounded-exec/reservation-connection.js +248 -0
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/run-cpu-pool.js +3 -0
- package/dist/executors/bounded-exec/runner-sizing.d.ts +9 -5
- package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
- package/dist/executors/bounded-exec/runner-sizing.js +13 -9
- package/dist/executors/bounded-exec/schema.d.ts +2 -2
- package/dist/executors/bounded-exec/suite-minimum.d.ts +21 -0
- package/dist/executors/bounded-exec/suite-minimum.d.ts.map +1 -0
- package/dist/executors/bounded-exec/suite-minimum.js +85 -0
- package/dist/executors/bounded-exec/test-result-writer.d.ts +2 -0
- package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -1
- package/dist/executors/bounded-exec/test-result-writer.js +1 -0
- package/dist/executors/bounded-exec/test-results.d.ts +5 -0
- package/dist/executors/bounded-exec/test-results.d.ts.map +1 -1
- package/dist/executors/bounded-exec/test-results.js +2 -2
- package/dist/executors/bounded-exec/verdict.d.ts +26 -4
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +26 -5
- package/dist/executors/cargo-zigbuild/executor.d.ts +10 -8
- package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
- package/dist/executors/cargo-zigbuild/executor.js +32 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +105 -73
- package/dist/managed-files/ci-workflow.d.ts +4 -1
- package/dist/managed-files/ci-workflow.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.js +9 -14
- package/dist/managed-files/files.d.ts +3 -3
- package/dist/managed-files/files.js +3 -3
- package/dist/task-results.js +2 -1
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +135 -42
- package/executors.json +2 -0
- package/managed/raw/envrc +24 -0
- package/managed/raw/patches/nx@24.0.3.patch +1179 -133
- package/managed/raw/patches/ttsc@0.37.1.patch +1055 -0
- package/managed/raw/tooling/direnv/developer-links.ts +105 -11
- package/managed/raw/tooling/direnv/devenv.smoo.nix +20 -19
- package/package.json +67 -11
- package/runtime/nx-publish/.build-inputs.json +2 -2
- package/runtime/nx-publish/cache_adapter.js +293 -3
- package/runtime/nx-publish/nx_publish.js +36 -14
- package/src/built-output-packages.ts +1 -1
- package/src/cargo-closure-input.ts +1 -1
- package/src/cargo-source-hash.ts +16 -132
- package/src/cargo-toolchain-paths.ts +2 -2
- package/src/cargo-workspace.ts +1 -2
- package/src/executors/bounded-exec/admission-queue.ts +11 -10
- package/src/executors/bounded-exec/awake-clock.ts +20 -0
- package/src/executors/bounded-exec/bounds.ts +28 -15
- package/src/executors/bounded-exec/case-gate.ts +365 -0
- package/src/executors/bounded-exec/cpu-pool-thread.ts +3 -3
- package/src/executors/bounded-exec/cpu-pool.ts +139 -12
- package/src/executors/bounded-exec/endpoint-life.ts +279 -0
- package/src/executors/bounded-exec/executor.ts +280 -106
- package/src/executors/bounded-exec/gateway-lease.ts +6 -0
- package/src/executors/bounded-exec/go-run-summary.ts +137 -0
- package/src/executors/bounded-exec/hang-diagnostics.ts +70 -52
- package/src/executors/bounded-exec/lease-wait.ts +1 -0
- package/src/executors/bounded-exec/mbx-pool.ts +36 -9
- package/src/executors/bounded-exec/mbx-reservations.ts +213 -182
- package/src/executors/bounded-exec/parent-grant.ts +3 -0
- package/src/executors/bounded-exec/pool-admission.ts +59 -2
- package/src/executors/bounded-exec/progress.ts +37 -2
- package/src/executors/bounded-exec/reservation-connection.ts +221 -0
- package/src/executors/bounded-exec/run-cpu-pool.ts +2 -0
- package/src/executors/bounded-exec/runner-sizing.ts +13 -8
- package/src/executors/bounded-exec/schema.json +1 -1
- package/src/executors/bounded-exec/schema.ts +2 -2
- package/src/executors/bounded-exec/suite-minimum.ts +81 -0
- package/src/executors/bounded-exec/test-result-writer.ts +3 -0
- package/src/executors/bounded-exec/test-results.ts +5 -0
- package/src/executors/bounded-exec/verdict.ts +39 -6
- package/src/executors/cargo-zigbuild/executor.ts +30 -19
- package/src/index.ts +112 -78
- package/src/managed-files/ci-workflow.ts +13 -17
- package/src/managed-files/files.ts +3 -3
- package/src/workspace-config-policy.ts +161 -43
- package/test-timings.json +157 -147
- package/managed/raw/patches/ttsc@0.36.3.patch +0 -1660
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import * as _isTypeUint32_1 from "typia/lib/internal/_isTypeUint32";
|
|
2
|
-
import * as _jsonStringifyNumber_1 from "typia/lib/internal/_jsonStringifyNumber";
|
|
3
|
-
import * as _throwTypeGuardError_1 from "typia/lib/internal/_throwTypeGuardError";
|
|
4
|
-
import * as _validateReport_1 from "typia/lib/internal/_validateReport";
|
|
5
1
|
import { spawn } from 'node:child_process';
|
|
6
2
|
import { rm } from 'node:fs/promises';
|
|
7
3
|
import { createConnection } from 'node:net';
|
|
8
4
|
import { join } from 'node:path';
|
|
9
5
|
import { logger } from 'nx/src/devkit-exports.js';
|
|
10
|
-
import typia from 'typia';
|
|
11
6
|
import { ownedSocketDirectory } from '../../testing.js';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
7
|
+
import { TEST_GATE_SERVED_ENV } from './case-gate.js';
|
|
8
|
+
import { endpointStep, spawned } from './endpoint-life.js';
|
|
9
|
+
import { mbxHold, mbxPool } from './mbx-pool.js';
|
|
10
|
+
import { connectionStep, opened, } from './reservation-connection.js';
|
|
14
11
|
/**
|
|
15
12
|
* mbx's reservation endpoint of one Nx run (specs/cowshed/05_gateway.md, "Parallelism inside a job"). A reserved leaf
|
|
16
13
|
* once ran under its own `mbx reserve`, two mbx processes per task whose dynamic loading alone kept the host's vnode
|
|
@@ -45,17 +42,18 @@ export function describeUnserved(endpoint) {
|
|
|
45
42
|
}
|
|
46
43
|
const ENDPOINT_DIRECTORY = 'mbx-r-';
|
|
47
44
|
const ENDPOINT_SOCKET = 'r.sock';
|
|
48
|
-
/** What is kept of the endpoint's stderr to say why it ended: its last bytes. */
|
|
49
|
-
const SAID_BYTES = 4096;
|
|
50
45
|
/** The endpoints this process serves, by Nx run id, until that run's `postTasksExecution`. */
|
|
51
46
|
const endpoints = new Map();
|
|
52
47
|
/**
|
|
53
48
|
* Serve `context`'s run an mbx reservation endpoint and publish it in `env`, which every task inherits, when the
|
|
54
49
|
* environment names mbx's pool (`mbxPool`). An endpoint that does not start is said, and each reserved leaf of the run
|
|
55
|
-
* then refuses to run, naming `RESERVATIONS_ENV`; a leaf in no pool, or one mbx admits itself, runs as before.
|
|
50
|
+
* then refuses to run, naming `RESERVATIONS_ENV`; a leaf in no pool, or one mbx admits itself, runs as before. A run
|
|
51
|
+
* under a hold on mbx's pool is served no endpoint, and learns whether its mbx gates test cases (`learnHeldGate`).
|
|
56
52
|
*/
|
|
57
53
|
export async function serveRunReservations(context, env = process.env) {
|
|
58
54
|
if (mbxPool(env) === null) {
|
|
55
|
+
if (mbxHold(env))
|
|
56
|
+
await learnHeldGate(env);
|
|
59
57
|
return;
|
|
60
58
|
}
|
|
61
59
|
const started = await startEndpoint(env);
|
|
@@ -67,6 +65,34 @@ export async function serveRunReservations(context, env = process.env) {
|
|
|
67
65
|
endpoints.set(context.id, started.endpoint);
|
|
68
66
|
env[RESERVATIONS_ENV] = started.socket;
|
|
69
67
|
delete env[RESERVATIONS_UNSERVED_ENV];
|
|
68
|
+
// A leaf's runner starts every thread of its ask only where the installed mbx's shim takes each case through its gate.
|
|
69
|
+
if (started.gates)
|
|
70
|
+
env[TEST_GATE_SERVED_ENV] = '1';
|
|
71
|
+
else
|
|
72
|
+
delete env[TEST_GATE_SERVED_ENV];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A run under a hold on mbx's pool reserves nothing and serves its own token pool (run-cpu-pool.ts), and its nextest
|
|
76
|
+
* leaves still start every case through mbx's shim. Whether that shim gates is the endpoint's own answer, so the run
|
|
77
|
+
* starts the endpoint once, outside the hold's `MBX_SCHED_DISABLE` and `MBX_SCHED_DIR`, which it refuses to serve
|
|
78
|
+
* under, asks, and ends it; no request is made of it (specs/cowshed/05_gateway.md, "A case starts on a core", Inside a
|
|
79
|
+
* hold). An mbx that does not start it, or does not answer, gates nothing: the run's leaves are sized to their grants.
|
|
80
|
+
*/
|
|
81
|
+
async function learnHeldGate(env) {
|
|
82
|
+
const unheld = { ...env };
|
|
83
|
+
delete unheld.MBX_SCHED_DISABLE;
|
|
84
|
+
delete unheld.MBX_SCHED_DIR;
|
|
85
|
+
const started = await startEndpoint(unheld);
|
|
86
|
+
if (!started.ok) {
|
|
87
|
+
logger.warn(`bounded-exec: the installed mbx did not say whether its test shim gates cases (${started.error}); this run's nextest leaves are sized to their grants`);
|
|
88
|
+
delete env[TEST_GATE_SERVED_ENV];
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
await started.endpoint.end();
|
|
92
|
+
if (started.gates)
|
|
93
|
+
env[TEST_GATE_SERVED_ENV] = '1';
|
|
94
|
+
else
|
|
95
|
+
delete env[TEST_GATE_SERVED_ENV];
|
|
70
96
|
}
|
|
71
97
|
/** Close the endpoint `context`'s run was served, if it was served one: its standard input's end ends it. */
|
|
72
98
|
export async function closeRunReservations(context) {
|
|
@@ -75,322 +101,200 @@ export async function closeRunReservations(context) {
|
|
|
75
101
|
return;
|
|
76
102
|
}
|
|
77
103
|
endpoints.delete(context.id);
|
|
78
|
-
endpoint.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (ended !== 'mbx reservations ended with status 0') {
|
|
82
|
-
logger.warn(`bounded-exec: this run's mbx reservation endpoint did not close cleanly: ${ended}`);
|
|
104
|
+
const ended = await endpoint.end();
|
|
105
|
+
if (!ended.clean) {
|
|
106
|
+
logger.warn(`bounded-exec: this run's mbx reservation endpoint did not close cleanly: ${ended.how}`);
|
|
83
107
|
}
|
|
84
108
|
}
|
|
85
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* Start `mbx reservations` by its PATH name in an owned socket directory, and answer once its life answers its start
|
|
111
|
+
* (endpoint-life.ts). This is that machine's shell: it feeds the child's and the probe's events to `endpointStep` and
|
|
112
|
+
* executes the effects each step answers, and decides nothing itself.
|
|
113
|
+
*/
|
|
86
114
|
async function startEndpoint(env) {
|
|
87
115
|
const directory = await ownedSocketDirectory(ENDPOINT_DIRECTORY, ENDPOINT_SOCKET);
|
|
88
116
|
const socket = join(directory, ENDPOINT_SOCKET);
|
|
89
117
|
const server = spawn('mbx', ['reservations', socket], { env, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
90
|
-
|
|
91
|
-
server.
|
|
92
|
-
|
|
93
|
-
said = (said + text).slice(-SAID_BYTES);
|
|
94
|
-
});
|
|
95
|
-
// eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: a child that runs ends with its run's postTasksExecution, which ends its standard input and bounds its exit (`endedWithin`); one that cannot run says so at once
|
|
96
|
-
const ended = new Promise((resolve) => {
|
|
97
|
-
server.once('error', (error) => resolve(`mbx reservations could not run: ${error.message}`));
|
|
98
|
-
server.once('close', (code, signal) => {
|
|
99
|
-
const last = said.trim().split('\n').at(-1) ?? '';
|
|
100
|
-
resolve(`mbx reservations ended ${signal === null ? `with status ${code}` : `on ${signal}`}${last === '' ? '' : `: ${last}`}`);
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
const endpoint = { server, directory, ended };
|
|
104
|
-
const listening = await saysListening(server.stdout, ended);
|
|
105
|
-
if (listening !== null) {
|
|
106
|
-
server.kill('SIGKILL');
|
|
107
|
-
await endedWithin(endpoint, CONTROL_MS);
|
|
108
|
-
await rm(directory, { recursive: true, force: true });
|
|
109
|
-
return { ok: false, error: listening };
|
|
110
|
-
}
|
|
111
|
-
return { ok: true, endpoint, socket };
|
|
112
|
-
}
|
|
113
|
-
/** Null once the endpoint's first line is `listening`; otherwise why not, within the control-plane bound. */
|
|
114
|
-
function saysListening(stdout, ended) {
|
|
115
|
-
return new Promise((resolve) => {
|
|
116
|
-
let text = '';
|
|
117
|
-
const timer = setTimeout(() => resolve(`mbx reservations did not say it was listening within ${CONTROL_MS}ms`), CONTROL_MS);
|
|
118
|
-
stdout.setEncoding('utf8');
|
|
119
|
-
stdout.on('data', (chunk) => {
|
|
120
|
-
text += chunk;
|
|
121
|
-
const end = text.indexOf('\n');
|
|
122
|
-
if (end === -1)
|
|
123
|
-
return;
|
|
124
|
-
clearTimeout(timer);
|
|
125
|
-
const line = text.slice(0, end);
|
|
126
|
-
resolve(line === 'listening' ? null : `mbx reservations said ${JSON.stringify(line)}, not that it was listening`);
|
|
127
|
-
});
|
|
128
|
-
void ended.then((why) => {
|
|
129
|
-
clearTimeout(timer);
|
|
130
|
-
resolve(why);
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
/** How the endpoint ended, killing it once `ms` pass first. */
|
|
135
|
-
async function endedWithin(endpoint, ms) {
|
|
118
|
+
const remove = () => rm(directory, { recursive: true, force: true });
|
|
119
|
+
let life = spawned(server.pid);
|
|
120
|
+
let probe;
|
|
136
121
|
let timer;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
const stringifyRequest = (() => {
|
|
147
|
-
const _ip0 = input => "number" === typeof input["id"] && _isTypeUint32_1._isTypeUint32(input["id"]);
|
|
148
|
-
const _so0 = input => `{"type":${"\"" + input.type + "\""},"id":${String(_jsonStringifyNumber_1._jsonStringifyNumber(input.id))},"cpus":${String(_jsonStringifyNumber_1._jsonStringifyNumber(input.cpus))},"priority":${"\"" + input.priority + "\""}}`;
|
|
149
|
-
const _so1 = input => `{"type":${"\"" + input.type + "\""},"id":${String(_jsonStringifyNumber_1._jsonStringifyNumber(input.id))}}`;
|
|
150
|
-
const _su0 = input => (() => {
|
|
151
|
-
if ("reserve" === input.type)
|
|
152
|
-
return _so0(input);
|
|
153
|
-
else if ("release" === input.type)
|
|
154
|
-
return _so1(input);
|
|
155
|
-
else
|
|
156
|
-
_throwTypeGuardError_1._throwTypeGuardError({
|
|
157
|
-
method: "typia.json.createStringify",
|
|
158
|
-
expected: "({ type: \"reserve\"; id: Uint; cpus: number & Type<\"uint32\"> & Minimum<1>; priority: \"interactive\" | \"low\" | \"normal\"; } | { type: \"release\"; id: Uint; })",
|
|
159
|
-
value: input
|
|
160
|
-
});
|
|
161
|
-
})();
|
|
162
|
-
const _io0 = input => "reserve" === input.type && _ip0(input) && ("number" === typeof input.cpus && (_isTypeUint32_1._isTypeUint32(input.cpus) && 1 <= input.cpus)) && ("interactive" === input.priority || "low" === input.priority || "normal" === input.priority);
|
|
163
|
-
const _io1 = input => "release" === input.type && _ip0(input);
|
|
164
|
-
return input => _su0(input);
|
|
165
|
-
})();
|
|
166
|
-
const parseReply = (() => {
|
|
167
|
-
let errors;
|
|
168
|
-
let _report;
|
|
169
|
-
const _ip0 = input => "number" === typeof input["id"] && _isTypeUint32_1._isTypeUint32(input["id"]);
|
|
170
|
-
const _ip1 = input => "string" === typeof input["error"];
|
|
171
|
-
const _ve0 = "({ type: \"error\"; error: string; } | { type: \"granted\"; id: Uint; cpus: number & Type<\"uint32\"> & Minimum<1>; } | { type: \"refused\"; id: Uint; error: string; })";
|
|
172
|
-
const _vp0 = (input, _path, _exceptionable = true) => "number" === typeof input["id"] && (_isTypeUint32_1._isTypeUint32(input["id"]) || _report(_exceptionable, {
|
|
173
|
-
path: _path + ".id",
|
|
174
|
-
expected: "number & Type<\"uint32\">",
|
|
175
|
-
value: input["id"]
|
|
176
|
-
})) || _report(_exceptionable, {
|
|
177
|
-
path: _path + ".id",
|
|
178
|
-
expected: "(number & Type<\"uint32\">)",
|
|
179
|
-
value: input["id"]
|
|
122
|
+
// `Promise.withResolvers` would read better but needs lib es2024; this package inherits lib es2022.
|
|
123
|
+
let answer;
|
|
124
|
+
let conclude;
|
|
125
|
+
let fail;
|
|
126
|
+
let failEnd;
|
|
127
|
+
const started = new Promise((resolve, reject) => {
|
|
128
|
+
answer = resolve;
|
|
129
|
+
fail = reject;
|
|
180
130
|
});
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
value: input["error"]
|
|
131
|
+
const ended = new Promise((resolve, reject) => {
|
|
132
|
+
conclude = resolve;
|
|
133
|
+
failEnd = reject;
|
|
185
134
|
});
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
path: _path,
|
|
237
|
-
expected: _ve1,
|
|
238
|
-
value: input
|
|
239
|
-
});
|
|
240
|
-
})();
|
|
241
|
-
const __is = input => "object" === typeof input && null !== input && _iu0(input);
|
|
242
|
-
const __validate = input => {
|
|
243
|
-
if (false === __is(input)) {
|
|
244
|
-
errors = [];
|
|
245
|
-
_report = _validateReport_1._validateReport(errors);
|
|
246
|
-
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
247
|
-
path: _path + "",
|
|
248
|
-
expected: _ve0,
|
|
249
|
-
value: input
|
|
250
|
-
})) && _vu0(input, _path + "", true) || _report(true, {
|
|
251
|
-
path: _path + "",
|
|
252
|
-
expected: _ve0,
|
|
253
|
-
value: input
|
|
254
|
-
}))(input, "$input", true);
|
|
255
|
-
const success = 0 === errors.length;
|
|
256
|
-
return success ? {
|
|
257
|
-
success,
|
|
258
|
-
data: input
|
|
259
|
-
} : {
|
|
260
|
-
success,
|
|
261
|
-
errors,
|
|
262
|
-
data: input
|
|
263
|
-
};
|
|
135
|
+
const endpoint = {
|
|
136
|
+
end() {
|
|
137
|
+
feed({ type: 'run-end' });
|
|
138
|
+
return ended;
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
const execute = (effect) => {
|
|
142
|
+
switch (effect.do) {
|
|
143
|
+
case 'probe': {
|
|
144
|
+
// eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: a Unix-socket connect completes or fails at once, and the probe ends at its answer, its connection's end or the child's end (endpoint-life.ts), which the endpoint's death brings: it is this run's child
|
|
145
|
+
const connection = createConnection(socket);
|
|
146
|
+
probe = connection;
|
|
147
|
+
connection.setEncoding('utf8');
|
|
148
|
+
connection.on('connect', () => connection.write('{"type":"capabilities"}\n'));
|
|
149
|
+
connection.on('data', (text) => feed({ type: 'probe', text }));
|
|
150
|
+
connection.on('error', () => feed({ type: 'probe-end' }));
|
|
151
|
+
connection.on('close', () => feed({ type: 'probe-end' }));
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
case 'hang-up':
|
|
155
|
+
probe?.destroy();
|
|
156
|
+
return;
|
|
157
|
+
case 'arm':
|
|
158
|
+
timer = setTimeout(() => feed({ type: 'expired' }), effect.ms);
|
|
159
|
+
return;
|
|
160
|
+
case 'disarm':
|
|
161
|
+
clearTimeout(timer);
|
|
162
|
+
return;
|
|
163
|
+
case 'kill':
|
|
164
|
+
server.kill('SIGKILL');
|
|
165
|
+
return;
|
|
166
|
+
case 'unref-child': {
|
|
167
|
+
server.unref();
|
|
168
|
+
const pipes = [server.stdin, server.stdout, server.stderr];
|
|
169
|
+
for (const pipe of pipes)
|
|
170
|
+
pipe.unref?.();
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
case 'close-stdin':
|
|
174
|
+
server.stdin.end();
|
|
175
|
+
return;
|
|
176
|
+
case 'serve':
|
|
177
|
+
answer({ ok: true, endpoint, socket, gates: effect.gates });
|
|
178
|
+
return;
|
|
179
|
+
case 'refuse':
|
|
180
|
+
void remove().then(() => answer({ ok: false, error: effect.why }), fail);
|
|
181
|
+
return;
|
|
182
|
+
case 'conclude':
|
|
183
|
+
void remove().then(() => conclude(effect.ended), failEnd);
|
|
184
|
+
return;
|
|
264
185
|
}
|
|
265
|
-
return {
|
|
266
|
-
success: true,
|
|
267
|
-
data: input
|
|
268
|
-
};
|
|
269
186
|
};
|
|
270
|
-
|
|
271
|
-
|
|
187
|
+
const feed = (event) => {
|
|
188
|
+
const [next, effects] = endpointStep(life, event);
|
|
189
|
+
life = next;
|
|
190
|
+
for (const effect of effects)
|
|
191
|
+
execute(effect);
|
|
192
|
+
};
|
|
193
|
+
server.stdout.setEncoding('utf8');
|
|
194
|
+
server.stdout.on('data', (text) => feed({ type: 'stdout', text }));
|
|
195
|
+
server.stdout.on('end', () => feed({ type: 'stdout-end' }));
|
|
196
|
+
server.stderr.setEncoding('utf8');
|
|
197
|
+
server.stderr.on('data', (text) => feed({ type: 'stderr', text }));
|
|
198
|
+
server.once('error', (error) => feed({ type: 'error', message: error.message }));
|
|
199
|
+
server.once('close', (code, signal) => feed({ type: 'close', code, signal }));
|
|
200
|
+
return started;
|
|
201
|
+
}
|
|
272
202
|
/**
|
|
273
|
-
*
|
|
274
|
-
*
|
|
203
|
+
* The socket of one connection to an endpoint, shared by every reservation this process makes there. It is the shell
|
|
204
|
+
* of that connection's machine (reservation-connection.ts): it feeds its callers' requests and its socket's events to
|
|
205
|
+
* `connectionStep` and executes the effects each step answers, keeping each request's answer and each grant's loss to
|
|
206
|
+
* settle; it decides nothing itself.
|
|
275
207
|
*/
|
|
276
|
-
class
|
|
277
|
-
endpoint;
|
|
208
|
+
class EndpointSocket {
|
|
278
209
|
forget;
|
|
279
210
|
#socket;
|
|
280
|
-
#
|
|
211
|
+
#answers = new Map();
|
|
212
|
+
#losses = new Map();
|
|
213
|
+
#connection;
|
|
281
214
|
#nextId = 1;
|
|
282
|
-
#unread = '';
|
|
283
|
-
#closed = null;
|
|
284
215
|
constructor(endpoint, forget) {
|
|
285
|
-
this.endpoint = endpoint;
|
|
286
216
|
this.forget = forget;
|
|
217
|
+
this.#connection = opened(endpoint);
|
|
287
218
|
// eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: a Unix-socket connect completes or fails at once, and a reservation's answer waits as long as the pool's admission holds it, as `mbx reserve`'s did; the connection's end answers every request still waiting
|
|
288
219
|
this.#socket = createConnection(endpoint);
|
|
289
220
|
this.#socket.setEncoding('utf8');
|
|
290
221
|
this.#socket.unref();
|
|
291
|
-
this.#socket.on('data', (text) => this.#
|
|
292
|
-
this.#socket.on('error', (error) => this.#
|
|
293
|
-
|
|
222
|
+
this.#socket.on('data', (text) => this.#feed({ type: 'data', text }));
|
|
223
|
+
this.#socket.on('error', (error) => this.#feed({
|
|
224
|
+
type: 'error',
|
|
225
|
+
message: error.message,
|
|
226
|
+
code: 'code' in error && typeof error.code === 'string' ? error.code : null,
|
|
227
|
+
}));
|
|
228
|
+
this.#socket.on('close', () => this.#feed({ type: 'close' }));
|
|
294
229
|
}
|
|
295
|
-
reserve(cpus, priority) {
|
|
296
|
-
if (this.#closed !== null) {
|
|
297
|
-
return { granted: Promise.resolve({ ok: false, error: this.#closed }), release() { } };
|
|
298
|
-
}
|
|
230
|
+
reserve(cpus, priority, min, name) {
|
|
299
231
|
const id = this.#nextId++;
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
this.#entries.set(id, { kind: 'waiting', answer });
|
|
303
|
-
this.#socket.ref();
|
|
304
|
-
this.#socket.write(`${stringifyRequest({ type: 'reserve', id, cpus, priority })}\n`);
|
|
305
|
-
let released = false;
|
|
232
|
+
const granted = new Promise((resolve) => this.#answers.set(id, resolve));
|
|
233
|
+
this.#feed({ type: 'reserve', id, cpus, priority, min, name });
|
|
306
234
|
return {
|
|
307
235
|
granted,
|
|
308
236
|
release: () => {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
const entry = this.#entries.get(id);
|
|
313
|
-
if (entry === undefined)
|
|
314
|
-
return;
|
|
315
|
-
this.#entries.delete(id);
|
|
316
|
-
if (entry.kind === 'waiting')
|
|
317
|
-
entry.answer({ ok: false, error: 'released while it waited' });
|
|
318
|
-
this.#socket.write(`${stringifyRequest({ type: 'release', id })}\n`);
|
|
319
|
-
if (this.#entries.size === 0)
|
|
320
|
-
this.#socket.unref();
|
|
237
|
+
// A grant given back is no longer one to lose.
|
|
238
|
+
this.#losses.delete(id);
|
|
239
|
+
this.#feed({ type: 'release', id });
|
|
321
240
|
},
|
|
322
241
|
};
|
|
323
242
|
}
|
|
324
|
-
#
|
|
325
|
-
this.#
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
this.#
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
243
|
+
#feed(event) {
|
|
244
|
+
const [next, effects] = connectionStep(this.#connection, event);
|
|
245
|
+
this.#connection = next;
|
|
246
|
+
for (const effect of effects)
|
|
247
|
+
this.#execute(effect);
|
|
248
|
+
}
|
|
249
|
+
#execute(effect) {
|
|
250
|
+
switch (effect.do) {
|
|
251
|
+
case 'ref':
|
|
252
|
+
this.#socket.ref();
|
|
253
|
+
return;
|
|
254
|
+
case 'unref':
|
|
255
|
+
this.#socket.unref();
|
|
256
|
+
return;
|
|
257
|
+
case 'write':
|
|
258
|
+
this.#socket.write(effect.line);
|
|
259
|
+
return;
|
|
260
|
+
case 'answer': {
|
|
261
|
+
const settle = this.#answers.get(effect.id);
|
|
262
|
+
this.#answers.delete(effect.id);
|
|
263
|
+
if (!effect.answer.ok) {
|
|
264
|
+
settle?.(effect.answer);
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
const lost = new Promise((resolve) => this.#losses.set(effect.id, resolve));
|
|
268
|
+
settle?.({ ok: true, cpus: effect.answer.cpus, lost });
|
|
332
269
|
return;
|
|
333
270
|
}
|
|
334
|
-
|
|
335
|
-
|
|
271
|
+
case 'lose':
|
|
272
|
+
this.#losses.get(effect.id)?.(effect.why);
|
|
273
|
+
this.#losses.delete(effect.id);
|
|
274
|
+
return;
|
|
275
|
+
case 'hang-up':
|
|
276
|
+
this.forget();
|
|
277
|
+
this.#socket.destroy();
|
|
336
278
|
return;
|
|
337
279
|
}
|
|
338
280
|
}
|
|
339
|
-
#answer(reply) {
|
|
340
|
-
if (reply.type === 'error') {
|
|
341
|
-
this.#close(`mbx reservation endpoint ${this.endpoint} closed this connection: ${reply.error}`);
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
const entry = this.#entries.get(reply.id);
|
|
345
|
-
// Released before its answer arrived: the endpoint drops what it won.
|
|
346
|
-
if (entry === undefined)
|
|
347
|
-
return;
|
|
348
|
-
if (entry.kind === 'held') {
|
|
349
|
-
this.#close(`mbx reservation endpoint ${this.endpoint} answered reservation ${reply.id} twice`);
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
if (reply.type === 'granted') {
|
|
353
|
-
let lose;
|
|
354
|
-
const lost = new Promise((resolve) => (lose = resolve));
|
|
355
|
-
this.#entries.set(reply.id, { kind: 'held', lose });
|
|
356
|
-
entry.answer({ ok: true, cpus: reply.cpus, lost });
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
this.#entries.delete(reply.id);
|
|
360
|
-
entry.answer({ ok: false, error: reply.error });
|
|
361
|
-
if (this.#entries.size === 0)
|
|
362
|
-
this.#socket.unref();
|
|
363
|
-
}
|
|
364
|
-
#close(why) {
|
|
365
|
-
if (this.#closed !== null)
|
|
366
|
-
return;
|
|
367
|
-
this.#closed = why;
|
|
368
|
-
this.forget();
|
|
369
|
-
for (const entry of this.#entries.values()) {
|
|
370
|
-
if (entry.kind === 'waiting')
|
|
371
|
-
entry.answer({ ok: false, error: why });
|
|
372
|
-
else
|
|
373
|
-
entry.lose(why);
|
|
374
|
-
}
|
|
375
|
-
this.#entries.clear();
|
|
376
|
-
this.#socket.destroy();
|
|
377
|
-
}
|
|
378
281
|
}
|
|
379
282
|
/** This process's connection to each endpoint it has asked. */
|
|
380
283
|
const connections = new Map();
|
|
381
284
|
/**
|
|
382
|
-
* Ask the endpoint at `socket` for at most `cpus` cores at `priority`,
|
|
383
|
-
* opened by its first request and kept while another one
|
|
285
|
+
* Ask the endpoint at `socket` for at most `cpus` cores at `priority`, starting on no fewer than `min` of them until
|
|
286
|
+
* mbx's aging bound, over this process's one connection to it, opened by its first request and kept while another one
|
|
287
|
+
* may come. `name` is the class mbx predicts the reservation by; absent, mbx's own for an unnamed one.
|
|
384
288
|
*/
|
|
385
|
-
export function reserveCores(socket, cpus, priority) {
|
|
289
|
+
export function reserveCores(socket, cpus, priority, min, name) {
|
|
386
290
|
let connection = connections.get(socket);
|
|
387
291
|
if (connection === undefined) {
|
|
388
|
-
const
|
|
389
|
-
if (connections.get(socket) ===
|
|
292
|
+
const fresh = new EndpointSocket(socket, () => {
|
|
293
|
+
if (connections.get(socket) === fresh)
|
|
390
294
|
connections.delete(socket);
|
|
391
295
|
});
|
|
392
|
-
connections.set(socket,
|
|
393
|
-
connection =
|
|
296
|
+
connections.set(socket, fresh);
|
|
297
|
+
connection = fresh;
|
|
394
298
|
}
|
|
395
|
-
return connection.reserve(cpus, priority);
|
|
299
|
+
return connection.reserve(cpus, priority, min, name);
|
|
396
300
|
}
|
|
@@ -27,6 +27,8 @@ export interface Ask {
|
|
|
27
27
|
readonly parallelism: number | null;
|
|
28
28
|
readonly alone: boolean;
|
|
29
29
|
readonly task: string | undefined;
|
|
30
|
+
/** Its cases each ask the pool for a token of their own (case-gate.ts). */
|
|
31
|
+
readonly gated: boolean;
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
34
|
* Ask the parent pool for the run's tokens. A run that inherits no pool runs as asked and says nothing; a pool whose
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parent-grant.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/parent-grant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAuB,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;;;GAIG;AAEH,sDAAsD;AACtD,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC;AAEnE,mHAAmH;AACnH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IACrC,sGAAsG;IACtG,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;IACtC,mCAAmC;IACnC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AAED,gHAAgH;AAChH,MAAM,WAAW,GAAG;IAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,wEAAwE;IACxE,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"parent-grant.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/parent-grant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAuB,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;;;G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: ask.parallelism ?? undefined,
|
|
12
12
|
alone: ask.alone ? true : undefined,
|
|
13
13
|
task: ask.task,
|
|
14
|
+
gated: ask.gated ? true : undefined,
|
|
14
15
|
});
|
|
15
16
|
if (answer.granted) {
|
|
16
17
|
return { grant: answer, refusal: null, wait: undefined, said: [] };
|
|
@@ -27,6 +27,10 @@ export interface PoolAsk {
|
|
|
27
27
|
readonly parallelism?: number | undefined;
|
|
28
28
|
/** A leaf the kernel killed for memory, run again: granted while nothing else holds a grant, and alone. */
|
|
29
29
|
readonly alone?: boolean | undefined;
|
|
30
|
+
/** One token for one test case of a leaf that holds a grant: granted only while no leaf's request waits. */
|
|
31
|
+
readonly lend?: boolean | undefined;
|
|
32
|
+
/** A lent request's leaf's predicted work left, in ms: its cases' last recorded walls, less those that ran. */
|
|
33
|
+
readonly left?: number | undefined;
|
|
30
34
|
}
|
|
31
35
|
/** Who holds a grant when the pool decides: how many leaves, and whether one of them runs alone. */
|
|
32
36
|
export interface Holding {
|
|
@@ -50,13 +54,35 @@ export interface PoolGrant<Ask extends PoolAsk> {
|
|
|
50
54
|
}
|
|
51
55
|
/**
|
|
52
56
|
* The grants of the queue's first requests, in its order, and what the first request left waiting waits for: free
|
|
53
|
-
* tokens (`cpu`), the run's memory (`memory`)
|
|
57
|
+
* tokens (`cpu`), the run's memory (`memory`), the grants others hold (`alone`) or, a lent request, the settle time
|
|
58
|
+
* after a leaf's grant returned (`settle`). `waiting` is null when every request was granted.
|
|
54
59
|
*/
|
|
55
60
|
export interface Admission<Ask extends PoolAsk> {
|
|
56
61
|
readonly grants: readonly PoolGrant<Ask>[];
|
|
57
|
-
readonly waiting: 'cpu' | 'memory' | 'alone' | null;
|
|
62
|
+
readonly waiting: 'cpu' | 'memory' | 'alone' | 'settle' | null;
|
|
58
63
|
}
|
|
59
64
|
/** The bytes `ask` is charged when it is lent `tokens`: its peak, scaled up when that is more than it was measured under. */
|
|
60
65
|
export declare function chargeAt(ask: PoolAsk, tokens: number): number;
|
|
61
|
-
export declare function admit<Ask extends PoolAsk>(queue: readonly Ask[], available: number, memory: MemoryLedger | null, holding?: Holding): Admission<Ask>;
|
|
66
|
+
export declare function admit<Ask extends PoolAsk>(queue: readonly Ask[], available: number, memory: MemoryLedger | null, holding?: Holding, lendable?: boolean): Admission<Ask>;
|
|
67
|
+
/**
|
|
68
|
+
* Where a request joins the queue (specs/cowshed/05_gateway.md, "Without mbx, every Nx run budgets itself"). A leaf the
|
|
69
|
+
* kernel killed, run again alone, has waited once already and goes ahead of the leaves that have not run. A leaf goes
|
|
70
|
+
* behind the leaves and ahead of every lent request: a case is lent only a token no leaf waits for. A lent request goes
|
|
71
|
+
* among the lent ones behind those whose leaves have as much work left or more, so a free token goes to the leaf that
|
|
72
|
+
* would otherwise end last, in arrival order among equals.
|
|
73
|
+
*/
|
|
74
|
+
export declare function place(queue: readonly PoolAsk[], ask: PoolAsk): number;
|
|
75
|
+
/**
|
|
76
|
+
* The token-time a pool's tokens stood idle beside a starved hold: a leaf holding fewer tokens than it asked that
|
|
77
|
+
* cannot ask for more, or a case waiting for a lent token. The pool tells it the idle count and whether a hold is
|
|
78
|
+
* starved at each change, on its own clock; what is counted is the idle count over the time a starved hold stood.
|
|
79
|
+
*/
|
|
80
|
+
export declare class IdleBesideStarved {
|
|
81
|
+
#private;
|
|
82
|
+
constructor(now: number);
|
|
83
|
+
/** From `now` on, `idle` tokens are free and a hold is `starved` or none is. */
|
|
84
|
+
observe(now: number, idle: number, starved: boolean): void;
|
|
85
|
+
/** The token-milliseconds counted up to `now`. */
|
|
86
|
+
tokenMs(now: number): number;
|
|
87
|
+
}
|
|
62
88
|
//# sourceMappingURL=pool-admission.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool-admission.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/pool-admission.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;GAGG;AACH,MAAM,WAAW,OAAO;IAC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