@smoothbricks/nx-plugin 0.4.28 → 0.4.29
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 +203 -83
- package/dist/bounded-test-policy.d.ts +10 -3
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +19 -25
- package/dist/cargo-closure-input.d.ts +12 -0
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +29 -7
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +42 -19
- package/dist/ensure-built-receipt.d.ts +34 -6
- package/dist/ensure-built-receipt.d.ts.map +1 -1
- package/dist/ensure-built-receipt.js +265 -159
- package/dist/ensure-built-witness.d.ts +27 -2
- package/dist/ensure-built-witness.d.ts.map +1 -1
- package/dist/ensure-built-witness.js +2176 -15
- package/dist/ensure-built.d.ts +99 -1
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +34 -53
- package/dist/executors/bounded-exec/cpu-pool.d.ts +16 -5
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool.js +43 -19
- package/dist/executors/bounded-exec/executor.d.ts +11 -2
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +139 -39
- package/dist/executors/bounded-exec/ram-temp.d.ts +17 -11
- package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
- package/dist/executors/bounded-exec/ram-temp.js +27 -13
- package/dist/generators/bun-test-tracing/generator.js +2 -2
- package/dist/graph-input-contract.d.ts +98 -0
- package/dist/graph-input-contract.d.ts.map +1 -0
- package/dist/graph-input-contract.js +624 -0
- package/dist/index.d.ts +12 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -3
- package/dist/managed-files/ci-workflow.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.js +5 -2
- package/dist/managed-files/publish-workflow.d.ts +11 -1
- package/dist/managed-files/publish-workflow.d.ts.map +1 -1
- package/dist/producer-receipts.d.ts +19 -0
- package/dist/producer-receipts.d.ts.map +1 -0
- package/dist/producer-receipts.js +921 -0
- package/dist/testing.d.ts +8 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +58 -0
- package/managed/raw/patches/nx@23.2.1.patch +328 -50
- package/managed/raw/tooling/direnv/developer-links.ts +147 -21
- package/managed/raw/tooling/direnv/devenv.smoo.nix +7 -7
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -5
- package/managed/raw/tooling/direnv/linked-snapshots.ts +206 -40
- package/managed/raw/tooling/direnv/repo-path +15 -2
- package/managed/raw/tooling/direnv/setup-environment.ts +179 -114
- package/managed/templates/github/actions/cache-node-modules/action.yml +9 -0
- package/managed/templates/github/actions/setup-devenv/action.yml +63 -7
- package/nextest.toml +1 -1
- package/package.json +11 -6
- package/src/__tests__/fixture-nx-env.ts +7 -0
- package/src/__tests__/owned-installation.ts +174 -0
- package/src/bin/smoo-nx-bound-failures.test.ts +1 -1
- package/src/bounded-test-policy.test.ts +36 -22
- package/src/bounded-test-policy.ts +19 -27
- package/src/bun-bootstrap.test.ts +1 -1
- package/src/cargo-closure-input.test.ts +60 -11
- package/src/cargo-closure-input.ts +28 -6
- package/src/cargo-resolve-cache.test.ts +140 -25
- package/src/cargo-source-hash.test.ts +78 -3
- package/src/cargo-source-hash.ts +48 -30
- package/src/cross-check-policy.test.ts +2 -2
- package/src/ensure-built-receipt.test.ts +111 -16
- package/src/ensure-built-receipt.ts +251 -149
- package/src/ensure-built-witness.test.ts +197 -13
- package/src/ensure-built-witness.ts +187 -15
- package/src/ensure-built.test.ts +156 -102
- package/src/ensure-built.ts +114 -64
- package/src/executors/bounded-exec/cpu-pool.test.ts +116 -32
- package/src/executors/bounded-exec/cpu-pool.ts +55 -17
- package/src/executors/bounded-exec/cpu-tokens.test.ts +2 -2
- package/src/executors/bounded-exec/executor-host.test.ts +51 -41
- package/src/executors/bounded-exec/executor.test.ts +155 -35
- package/src/executors/bounded-exec/executor.ts +156 -45
- package/src/executors/bounded-exec/progress.test.ts +1 -1
- package/src/executors/bounded-exec/ram-temp-host.test.ts +46 -17
- package/src/executors/bounded-exec/ram-temp.test.ts +65 -3
- package/src/executors/bounded-exec/ram-temp.ts +32 -16
- package/src/executors/bounded-exec/verdict.test.ts +17 -12
- package/src/generators/bounded-test-targets/generator.test.ts +1 -3
- package/src/generators/bun-test-tracing/generator.test.ts +2 -2
- package/src/generators/bun-test-tracing/generator.ts +2 -2
- package/src/graph-input-contract.test.ts +371 -0
- package/src/graph-input-contract.ts +605 -0
- package/src/index.test.ts +3 -3
- package/src/index.ts +24 -3
- package/src/linked-snapshots.nx.test.ts +112 -30
- package/src/managed-files/ci-workflow.ts +5 -2
- package/src/managed-files/publish-workflow.ts +12 -1
- package/src/managed-files/repo-path.test.ts +44 -1
- package/src/managed-files/setup-devenv-free-disk.test.ts +95 -0
- package/src/nextest-code-bound.test.ts +23 -17
- package/src/nextest-partitions.test.ts +7 -1
- package/src/nx-cache-restore-mtime.test.ts +2 -2
- package/src/nx-daemon-claim.test.ts +5 -5
- package/src/nx-daemon-idle-cpu.test.ts +0 -1
- package/src/nx-daemon-idle-policy.test.ts +56 -0
- package/src/nx-daemon-ignore-files.test.ts +2 -2
- package/src/nx-daemon-validity.test.ts +31 -9
- package/src/nx-dot-input-policy.test.ts +5 -5
- package/src/nx-files-archive-racy.test.ts +1 -1
- package/src/nx-incomplete-run-summary.test.ts +1 -1
- package/src/nx-plugin-load-errors.test.ts +2 -2
- package/src/nx-project-graph-errors.test.ts +70 -0
- package/src/nx-skipped-task-exit.test.ts +2 -2
- package/src/nx-store-resolution.test.ts +7 -25
- package/src/nx-task-output-lease.test.ts +3 -3
- package/src/nx-use-local.test.ts +7 -5
- package/src/producer-receipts.test.ts +164 -0
- package/src/producer-receipts.ts +631 -0
- package/src/runtime-input.test.ts +1 -1
- package/src/serial-group-wiring.test.ts +4 -4
- package/src/task-results.test.ts +18 -16
- package/src/test-timings.test.ts +2 -2
- package/src/testing.test.ts +5 -5
- package/src/testing.ts +59 -0
- package/src/typecheck-test-policy.test.ts +1 -1
- package/src/typescript-resolution.test.ts +76 -0
- package/test-timings.json +5 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
+
import { accessSync, constants } from 'node:fs';
|
|
2
3
|
import { availableParallelism, userInfo } from 'node:os';
|
|
3
|
-
import { isAbsolute, join, resolve as resolvePath } from 'node:path';
|
|
4
|
+
import { delimiter, isAbsolute, join, resolve as resolvePath } from 'node:path';
|
|
4
5
|
import { workspaceDataDirectoryForWorkspace } from 'nx/src/utils/cache-directory.js';
|
|
5
6
|
import { CPU_POOL_ENV, createCpuPool, readInheritedCpuPool, takeParentCpuTokens, } from './cpu-pool.js';
|
|
6
7
|
import { CPU_TOKENS_ENV, gatewayCpuBudget, runnerDemand, sizeRunner, } from './cpu-tokens.js';
|
|
@@ -17,6 +18,48 @@ const EXIT_CODE_BY_SIGNAL = {
|
|
|
17
18
|
};
|
|
18
19
|
/** The variables the CPU budget sets for the command it grants: no target's environment may set them. */
|
|
19
20
|
const BUDGET_ENV = [CPU_TOKENS_ENV, CPU_POOL_ENV];
|
|
21
|
+
/** Workspace-provided cowshed launchers, in the order a workspace that provides one names them. */
|
|
22
|
+
const WORKSPACE_COWSHED_LAUNCHERS = [
|
|
23
|
+
'packages/cowshed/bin/cowshed',
|
|
24
|
+
'node_modules/@smoothbricks/cowshed/bin/cowshed',
|
|
25
|
+
];
|
|
26
|
+
/**
|
|
27
|
+
* The cowshed a run's disk commands use, in precedence order: the target's named one, an
|
|
28
|
+
* explicit one inherited from the parent process, the installed one on PATH, and — only when
|
|
29
|
+
* PATH provides none — the launcher this workspace itself provides (its own cowshed package,
|
|
30
|
+
* or a linked one's bin). An environment with no cowshed anywhere keeps the bare name, so
|
|
31
|
+
* its spawn failure names the missing installed tool.
|
|
32
|
+
*/
|
|
33
|
+
export function resolveCowshedExecutable(root, named, inherited, pathValue, cwd, exists = (path) => {
|
|
34
|
+
try {
|
|
35
|
+
accessSync(path, constants.X_OK);
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}) {
|
|
42
|
+
// A target-named executable is workspace-relative or absolute against the workspace root.
|
|
43
|
+
// An inherited explicit keeps the coordinate the parent gave it, exactly as the host
|
|
44
|
+
// commands always spawned it: an absolute one verbatim, a relative or bare one for
|
|
45
|
+
// spawn's own resolution — retargeting it to the root would silently change the tool.
|
|
46
|
+
if (named !== undefined)
|
|
47
|
+
return resolvePath(root, named);
|
|
48
|
+
if (inherited !== undefined)
|
|
49
|
+
return inherited;
|
|
50
|
+
// An empty PATH component names the spawning process's current directory, as POSIX
|
|
51
|
+
// spawn resolution does — the executor never chdirs, so that is the caller's cwd,
|
|
52
|
+
// not the workspace root.
|
|
53
|
+
const onPath = (pathValue ?? '').split(delimiter).some((dir) => exists(join(dir === '' ? cwd : dir, 'cowshed')));
|
|
54
|
+
if (onPath)
|
|
55
|
+
return undefined;
|
|
56
|
+
for (const candidate of WORKSPACE_COWSHED_LAUNCHERS) {
|
|
57
|
+
const launcher = join(root, candidate);
|
|
58
|
+
if (exists(launcher))
|
|
59
|
+
return launcher;
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
20
63
|
export default function boundedExecExecutor(options, context) {
|
|
21
64
|
return runDefaultBoundedExec(options, recordContext(context));
|
|
22
65
|
}
|
|
@@ -26,7 +69,7 @@ export function runDefaultBoundedExec(options, context) {
|
|
|
26
69
|
// for its command alike. Nx resolves `{workspaceRoot}/…` in an option to a workspace-relative path, which the
|
|
27
70
|
// command, starting in another directory, could not find: it gets the absolute one.
|
|
28
71
|
const named = options.env?.[COWSHED_EXECUTABLE_ENV];
|
|
29
|
-
const cowshed =
|
|
72
|
+
const cowshed = resolveCowshedExecutable(context.root, named, process.env[COWSHED_EXECUTABLE_ENV], process.env.PATH, process.cwd());
|
|
30
73
|
const run = cowshed === undefined ? options : { ...options, env: { ...options.env, [COWSHED_EXECUTABLE_ENV]: cowshed } };
|
|
31
74
|
// Only macOS has `hdiutil ram://`; elsewhere the command keeps the inherited TMPDIR.
|
|
32
75
|
const tempVolume = process.platform === 'darwin'
|
|
@@ -66,8 +109,9 @@ export function recordContext(context) {
|
|
|
66
109
|
*
|
|
67
110
|
* `inherited` is the parent's CPU pool (`cpu-pool.ts`) that lends this run its tokens. The run asks that pool first
|
|
68
111
|
* and the host budget only when the pool refuses. Whatever it is granted, the run serves its own sub-pool to its
|
|
69
|
-
* descendants, closed before the grant returns. A
|
|
70
|
-
*
|
|
112
|
+
* descendants, closed before the grant returns. A grant whose connection closes while the command runs (a gateway
|
|
113
|
+
* restart, or the lending parent's exit) ends its accounting, never the command: the command runs on over budget to
|
|
114
|
+
* its own exit, and the run says so.
|
|
71
115
|
*/
|
|
72
116
|
export async function runBoundedExec(options, context, killer, tempVolume, budget, inherited = null, captureDiagnostics = captureHangDiagnostics) {
|
|
73
117
|
const cwd = resolveCwd(options.cwd, context.root);
|
|
@@ -85,7 +129,6 @@ export async function runBoundedExec(options, context, killer, tempVolume, budge
|
|
|
85
129
|
settled: false,
|
|
86
130
|
expiry: null,
|
|
87
131
|
forceKillNeeded: false,
|
|
88
|
-
grantLost: false,
|
|
89
132
|
poolCloseError: null,
|
|
90
133
|
};
|
|
91
134
|
const appendStdout = (chunk) => {
|
|
@@ -157,7 +200,7 @@ export async function runBoundedExec(options, context, killer, tempVolume, budge
|
|
|
157
200
|
let grant = null;
|
|
158
201
|
let parentRefusal = null;
|
|
159
202
|
if (inherited !== null) {
|
|
160
|
-
const fromParent = await takeParentCpuTokens(inherited, demand.want
|
|
203
|
+
const fromParent = await takeParentCpuTokens(inherited, demand.want);
|
|
161
204
|
if (fromParent.granted) {
|
|
162
205
|
grant = fromParent;
|
|
163
206
|
}
|
|
@@ -209,8 +252,8 @@ export async function runBoundedExec(options, context, killer, tempVolume, budge
|
|
|
209
252
|
return cpuReleased;
|
|
210
253
|
};
|
|
211
254
|
// Records the run's verdict when it has a task to record as. An `expiry` is set only when a bound ended the run.
|
|
212
|
-
// An `operational` run failed on its CPU budget (a
|
|
213
|
-
//
|
|
255
|
+
// An `operational` run failed on its CPU budget (a sub-pool that did not close): an ordinary failure, whatever
|
|
256
|
+
// bound also fired, so it is never judged as a bound.
|
|
214
257
|
const recordRun = async (exitCode, expiry, elapsedMs, operational) => {
|
|
215
258
|
if (context.record === undefined) {
|
|
216
259
|
return;
|
|
@@ -236,10 +279,27 @@ export async function runBoundedExec(options, context, killer, tempVolume, budge
|
|
|
236
279
|
if (parentRefusal !== null) {
|
|
237
280
|
return refuse(`cowshed: cpu-tokens parent pool refused: ${parentRefusal}; refusing to run the command without asking the host budget\n`);
|
|
238
281
|
}
|
|
282
|
+
// Descendant work queued for host CPU tokens, as its pool hears it (`host-wait`): while any is held the idle clock
|
|
283
|
+
// is stopped, because a queued job is not an idle one (specs/cowshed/05_gateway.md, "The bounds start at the
|
|
284
|
+
// grant"). The clock it stops is made with the command below; a wait held before then is counted and honoured there.
|
|
285
|
+
let heldWaits = 0;
|
|
286
|
+
let idleClock = null;
|
|
287
|
+
const hostWaits = {
|
|
288
|
+
begin: () => {
|
|
289
|
+
heldWaits += 1;
|
|
290
|
+
if (heldWaits === 1)
|
|
291
|
+
idleClock?.stop();
|
|
292
|
+
},
|
|
293
|
+
end: () => {
|
|
294
|
+
heldWaits -= 1;
|
|
295
|
+
if (heldWaits === 0)
|
|
296
|
+
idleClock?.restart();
|
|
297
|
+
},
|
|
298
|
+
};
|
|
239
299
|
// A granted run serves a sub-pool of its own grant, so its descendants draw from that and never from above it.
|
|
240
300
|
// A pool that cannot be set up refuses the run: no command runs unbudgeted.
|
|
241
301
|
if (grant !== null) {
|
|
242
|
-
const created = await createCpuPool(grant.tokens, grant.closed);
|
|
302
|
+
const created = await createCpuPool(grant.tokens, grant.closed, hostWaits);
|
|
243
303
|
if (!created.ok) {
|
|
244
304
|
return refuse(`cowshed: cpu pool unavailable: ${created.error}; refusing to run the command\n`);
|
|
245
305
|
}
|
|
@@ -282,14 +342,17 @@ export async function runBoundedExec(options, context, killer, tempVolume, budge
|
|
|
282
342
|
clearTimeout(captureTimer);
|
|
283
343
|
idleCapture?.controller.abort();
|
|
284
344
|
};
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
345
|
+
// What is left of the current no-progress interval. A finished test sets it back to `idleTimeoutMs`; a held host
|
|
346
|
+
// wait keeps it unspent: the clock is stopped while descendant work is queued for CPU tokens, and runs on from where
|
|
347
|
+
// it stopped once the last wait ends. `queuedMs` is the queued time this interval has not counted, for the report.
|
|
348
|
+
let idleLeftMs = idleTimeoutMs ?? 0;
|
|
349
|
+
let queuedMs = 0;
|
|
350
|
+
let queuedSinceMs = null;
|
|
351
|
+
const scheduleIdle = (limitMs, leftMs) => {
|
|
289
352
|
clearTimeout(idleTimer);
|
|
290
353
|
cancelCapture();
|
|
291
354
|
const capture = {
|
|
292
|
-
expiresAtMs: Date.now() +
|
|
355
|
+
expiresAtMs: Date.now() + leftMs,
|
|
293
356
|
controller: new AbortController(),
|
|
294
357
|
result: { kind: 'pending', startedAtMs: null },
|
|
295
358
|
};
|
|
@@ -322,8 +385,46 @@ export async function runBoundedExec(options, context, killer, tempVolume, budge
|
|
|
322
385
|
};
|
|
323
386
|
}
|
|
324
387
|
});
|
|
325
|
-
}, Math.max(0,
|
|
326
|
-
idleTimer = setTimeout(() => expire({ kind: 'idle', limitMs
|
|
388
|
+
}, Math.max(0, leftMs - HANG_CAPTURE_MS));
|
|
389
|
+
idleTimer = setTimeout(() => expire({ kind: 'idle', limitMs, tests: progress.inFlight() }, queuedMs), leftMs);
|
|
390
|
+
};
|
|
391
|
+
const armIdleTimer = () => {
|
|
392
|
+
if (idleTimeoutMs === undefined || state.settled || state.expiry !== null) {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
idleLeftMs = idleTimeoutMs;
|
|
396
|
+
queuedMs = 0;
|
|
397
|
+
if (queuedSinceMs !== null) {
|
|
398
|
+
queuedSinceMs = Date.now();
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
scheduleIdle(idleTimeoutMs, idleLeftMs);
|
|
402
|
+
};
|
|
403
|
+
idleClock = {
|
|
404
|
+
stop: () => {
|
|
405
|
+
if (idleTimeoutMs === undefined || state.settled || state.expiry !== null || queuedSinceMs !== null) {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
const now = Date.now();
|
|
409
|
+
queuedSinceMs = now;
|
|
410
|
+
if (idleCapture !== undefined) {
|
|
411
|
+
idleLeftMs = Math.max(0, idleCapture.expiresAtMs - now);
|
|
412
|
+
}
|
|
413
|
+
clearTimeout(idleTimer);
|
|
414
|
+
cancelCapture();
|
|
415
|
+
idleCapture = undefined;
|
|
416
|
+
appendStderr(`bounded-exec: idle clock stopped: a descendant's work is queued for host CPU tokens; ${idleLeftMs}ms of idleTimeoutMs=${idleTimeoutMs} left\n`);
|
|
417
|
+
},
|
|
418
|
+
restart: () => {
|
|
419
|
+
if (idleTimeoutMs === undefined || state.settled || state.expiry !== null || queuedSinceMs === null) {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
const waitedMs = Date.now() - queuedSinceMs;
|
|
423
|
+
queuedMs += waitedMs;
|
|
424
|
+
queuedSinceMs = null;
|
|
425
|
+
appendStderr(`bounded-exec: idle clock restarted: no descendant's work is queued for host CPU tokens after ${waitedMs}ms; ${idleLeftMs}ms of idleTimeoutMs=${idleTimeoutMs} left\n`);
|
|
426
|
+
scheduleIdle(idleTimeoutMs, idleLeftMs);
|
|
427
|
+
},
|
|
327
428
|
};
|
|
328
429
|
// Only the CHILD's own output is read for progress. The diagnostics below go
|
|
329
430
|
// through appendStderr as well, and re-arming on those would let a teardown
|
|
@@ -391,8 +492,9 @@ export async function runBoundedExec(options, context, killer, tempVolume, budge
|
|
|
391
492
|
// the reader unable to tell a wedged toolchain from a loaded machine — the
|
|
392
493
|
// two have opposite fixes.
|
|
393
494
|
let termination = Promise.resolve();
|
|
394
|
-
|
|
395
|
-
|
|
495
|
+
// `queuedMs` is the time the idle interval did not count because descendant work was queued for host CPU tokens.
|
|
496
|
+
const expire = (bound, queuedMs = 0) => {
|
|
497
|
+
if (state.settled || state.expiry !== null) {
|
|
396
498
|
return;
|
|
397
499
|
}
|
|
398
500
|
state.expiry = bound;
|
|
@@ -400,7 +502,7 @@ export async function runBoundedExec(options, context, killer, tempVolume, budge
|
|
|
400
502
|
clearTimeout(idleTimer);
|
|
401
503
|
const elapsedMs = Date.now() - startedAt;
|
|
402
504
|
appendStderr(bound.kind === 'idle'
|
|
403
|
-
? `\nCommand made no progress: no test finished for ${bound.limitMs}ms (idleTimeoutMs=${bound.limitMs}) after ${elapsedMs}ms of runtime; ${bound.tests.length > 0
|
|
505
|
+
? `\nCommand made no progress: no test finished for ${bound.limitMs}ms (idleTimeoutMs=${bound.limitMs})${queuedMs > 0 ? `, not counting ${queuedMs}ms queued for host CPU tokens,` : ''} after ${elapsedMs}ms of runtime; ${bound.tests.length > 0
|
|
404
506
|
? `still running: ${bound.tests.join(', ')}`
|
|
405
507
|
: 'the runner named no test still running'} (cwd=${cwd}): ${command}\n`
|
|
406
508
|
: `\nCommand timed out after ${elapsedMs}ms (timeoutMs=${bound.limitMs}, cwd=${cwd}): ${command}\n`);
|
|
@@ -448,23 +550,21 @@ export async function runBoundedExec(options, context, killer, tempVolume, budge
|
|
|
448
550
|
};
|
|
449
551
|
const totalTimer = timeoutMs === undefined ? undefined : setTimeout(() => expire({ kind: 'total', limitMs: timeoutMs }), timeoutMs);
|
|
450
552
|
armIdleTimer();
|
|
451
|
-
// A
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
if (grant?.inherited) {
|
|
467
|
-
void grant.closed.then(onGrantLost);
|
|
553
|
+
// A wait its pool heard before the command started stops the clock it was not yet there to stop.
|
|
554
|
+
if (heldWaits > 0)
|
|
555
|
+
idleClock.stop();
|
|
556
|
+
// A grant's connection is a ledger entry, not the command's owner (05_gateway.md "Host CPU budget": a gateway
|
|
557
|
+
// restart forgets every grant, and what runs under it runs on over budget until it finishes). Its close, while the
|
|
558
|
+
// command runs, is said and changes nothing else; only a bound or a signal stops the command. Our own release after
|
|
559
|
+
// the command settled is not a loss; `cpuReleased` marks it.
|
|
560
|
+
if (grant !== null) {
|
|
561
|
+
const held = grant;
|
|
562
|
+
void held.closed.then(() => {
|
|
563
|
+
if (state.settled || cpuReleased !== null) {
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
appendStderr(`cowshed: cpu-tokens grant ended: the ${held.inherited ? 'parent pool' : 'gateway'} closed its ${held.tokens}-token grant while the command ran; it runs on over budget until it ends: ${command}\n`);
|
|
567
|
+
});
|
|
468
568
|
}
|
|
469
569
|
const { code: exitCode, signal: exitSignal } = await exitPromise;
|
|
470
570
|
await termination;
|
|
@@ -488,9 +588,9 @@ export async function runBoundedExec(options, context, killer, tempVolume, budge
|
|
|
488
588
|
appendStderr(`${describeRamTempError(full)}\n`);
|
|
489
589
|
}
|
|
490
590
|
await releaseLease();
|
|
491
|
-
// A run whose
|
|
492
|
-
//
|
|
493
|
-
const operationalFailure = state.
|
|
591
|
+
// A run whose sub-pool did not close cleanly fails even when the command exited 0, and whatever bound also fired:
|
|
592
|
+
// its verdict is an ordinary failure, never a bound.
|
|
593
|
+
const operationalFailure = state.poolCloseError !== null;
|
|
494
594
|
await recordRun(code, state.expiry, Date.now() - startedAt, operationalFailure);
|
|
495
595
|
return {
|
|
496
596
|
success: !operationalFailure && state.expiry === null && code === 0,
|
|
@@ -24,15 +24,15 @@ export interface HostCommands {
|
|
|
24
24
|
*/
|
|
25
25
|
export interface LeaseProcesses {
|
|
26
26
|
/**
|
|
27
|
-
* End every process
|
|
28
|
-
* and answer each as `<pid> (<command>)`.
|
|
29
|
-
* would not rejects with its name.
|
|
27
|
+
* End every process that works in `directory` — its working directory or the `TMPDIR` it was
|
|
28
|
+
* started with is there — and everything those started, and answer each as `<pid> (<command>)`.
|
|
29
|
+
* Every one has exited when this settles; one that would not rejects with its name.
|
|
30
30
|
*/
|
|
31
31
|
stopWorkingIn(directory: string): Promise<string[]>;
|
|
32
32
|
}
|
|
33
33
|
/** The host reads and signals cleanup uses; a seam for process ordering and signal failures. */
|
|
34
34
|
export interface ProcessHost {
|
|
35
|
-
/** The processes whose working directory is `directory` or lies beneath it. */
|
|
35
|
+
/** The processes whose working directory, or the `TMPDIR` they were started with, is `directory` or lies beneath it. */
|
|
36
36
|
workingIn(directory: string): Promise<number[]>;
|
|
37
37
|
/** Every process on the host. */
|
|
38
38
|
table(): Promise<ProcessEntry[]>;
|
|
@@ -40,13 +40,17 @@ export interface ProcessHost {
|
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* The processes `host` reads. A lease belongs to one task and its command is gone by the time the
|
|
43
|
-
* lease ends, so what still works in it is what the command left behind.
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
43
|
+
* lease ends, so what still works in it is what the command left behind. Most of that works in the
|
|
44
|
+
* lease only through `TMPDIR`, never by working directory: a test's ttsc plugin build copies the
|
|
45
|
+
* typescript-go sources into `$TMPDIR` from a process working in its project, and a Bun or Node
|
|
46
|
+
* process writes its compile cache there as it exits. Neither is known to the task's pid, and
|
|
47
|
+
* whichever outlived that pid would write into a lease being removed (measured 2026-10-18: `rm`
|
|
48
|
+
* failing ENOTEMPTY under a ttsc copy whose task had died). A fixture's Nx daemon is another: Nx
|
|
49
|
+
* detaches it into a session of its own, so the process-group kill that ends a timed-out command
|
|
50
|
+
* never reaches it, and a test process that is killed runs no teardown of its own. Deleting the
|
|
51
|
+
* lease asks such a daemon to leave only by deleting its record, which it notices within a second
|
|
52
|
+
* when it is idle and not at all while it is wedged; a signal does not depend on the daemon
|
|
53
|
+
* noticing, and a process left on the volume is what keeps it from detaching.
|
|
50
54
|
*
|
|
51
55
|
* A leftover keeps running while it is looked for, and a child it starts after the process table
|
|
52
56
|
* was read is in no table that was. So each one found is held with SIGSTOP and the table is read
|
|
@@ -58,6 +62,8 @@ export interface ProcessHost {
|
|
|
58
62
|
* again what works in it, including when that table names nothing, to recover reparented children.
|
|
59
63
|
*/
|
|
60
64
|
export declare function leaseProcessesOn(host: ProcessHost): LeaseProcesses;
|
|
65
|
+
/** What works in `directory` on this host: by working directory, and by the `TMPDIR` it was started with. */
|
|
66
|
+
export declare function pidsInLease(directory: string): Promise<number[]>;
|
|
61
67
|
export declare const hostLeaseProcesses: LeaseProcesses;
|
|
62
68
|
export interface RamTempPaths {
|
|
63
69
|
/** Where DiskArbitration mounts the volume: `/Volumes/<volumeName>`. Short for sun_path (104 bytes). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ram-temp.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/ram-temp.ts"],"names":[],"mappings":"AAqBA,OAAO,EAEL,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"ram-temp.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/ram-temp.ts"],"names":[],"mappings":"AAqBA,OAAO,EAEL,KAAK,YAAY,EAMlB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAe,KAAK,UAAU,EAAgC,MAAM,iBAAiB,CAAC;AAqH7F;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,QAA6C,CAAC;AAOlF,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAA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AS;YA4DT,aAAa;YAYb,QAAQ;YAwBR,aAAa;YA6Cb,MAAM;YAkDN,aAAa;IAY3B;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;CAUpB;AAmQD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAI5E;AAED,iGAAiG;AACjG,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAEnE;AAED,wFAAwF;AACxF,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE3D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,CAiBlD;AAkBD,8FAA8F;AAC9F,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,UAAU,EAAE,MAAM,GACjB;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,WAAW,GAAG,cAAc,CAAA;CAAE,GAAG,IAAI,CAanE;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,uBAAuB,CAAC;AAe3D;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,iBAAiB,GAAE,MAAiC,EACpD,aAAa,GAAE,MAAuB,EACtC,WAAW,GAAE,UAA4B,EACzC,OAAO,SAAmD,GACzD,YAAY,CAwCd"}
|
|
@@ -5,7 +5,7 @@ import { lstat, mkdir, mkdtemp, open, readdir, readFile, rename, rm, rmdir, stat
|
|
|
5
5
|
import { Socket } from 'node:net';
|
|
6
6
|
import { basename, join } from 'node:path';
|
|
7
7
|
import { setTimeout as sleep } from 'node:timers/promises';
|
|
8
|
-
import { awaitExit, pidsWorkingIn, processTable, terminate, withDescendants, } from '../../testing.js';
|
|
8
|
+
import { awaitExit, pidsWithTempIn, pidsWorkingIn, processTable, terminate, withDescendants, } from '../../testing.js';
|
|
9
9
|
import { isRecord } from '../../type-guards.js';
|
|
10
10
|
import { diskClassOf, recordedShare, takeDiskLease } from './disk-lease.js';
|
|
11
11
|
import { GATEWAY_SOCKET } from './gateway-lease.js';
|
|
@@ -51,7 +51,11 @@ import { captureHeldVerdict, parseHeldVerdict, validateHeldVerdict, } from './ra
|
|
|
51
51
|
* checks that the volume, the lease directory and its own claim are still as
|
|
52
52
|
* it claimed them. A lease is a directory named after the task process's pid;
|
|
53
53
|
* a lease whose pid is gone is reclaimed by the next task, and the volume is
|
|
54
|
-
* detached when the last lease ends.
|
|
54
|
+
* detached when the last lease ends. The pid's death proves only that the task
|
|
55
|
+
* process is gone, not what it started: its command runs in a process group of
|
|
56
|
+
* its own, and every process started with the lease as its `TMPDIR` writes
|
|
57
|
+
* there wherever it works. So a dead lease is removed only once every process
|
|
58
|
+
* working in it, by working directory or by `TMPDIR`, has been stopped.
|
|
55
59
|
*
|
|
56
60
|
* The volume is created under its final name and never renamed. It is mounted by `mount_apfs` at a
|
|
57
61
|
* private staging directory and marked there; the kernel then unmounts it (`umount`) and `diskutil mount`, the
|
|
@@ -135,13 +139,17 @@ const LEFTOVER_GRACE_MS = 5_000;
|
|
|
135
139
|
const STARTS_NOTHING = /^[TtZ]/;
|
|
136
140
|
/**
|
|
137
141
|
* The processes `host` reads. A lease belongs to one task and its command is gone by the time the
|
|
138
|
-
* lease ends, so what still works in it is what the command left behind.
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
142
|
+
* lease ends, so what still works in it is what the command left behind. Most of that works in the
|
|
143
|
+
* lease only through `TMPDIR`, never by working directory: a test's ttsc plugin build copies the
|
|
144
|
+
* typescript-go sources into `$TMPDIR` from a process working in its project, and a Bun or Node
|
|
145
|
+
* process writes its compile cache there as it exits. Neither is known to the task's pid, and
|
|
146
|
+
* whichever outlived that pid would write into a lease being removed (measured 2026-10-18: `rm`
|
|
147
|
+
* failing ENOTEMPTY under a ttsc copy whose task had died). A fixture's Nx daemon is another: Nx
|
|
148
|
+
* detaches it into a session of its own, so the process-group kill that ends a timed-out command
|
|
149
|
+
* never reaches it, and a test process that is killed runs no teardown of its own. Deleting the
|
|
150
|
+
* lease asks such a daemon to leave only by deleting its record, which it notices within a second
|
|
151
|
+
* when it is idle and not at all while it is wedged; a signal does not depend on the daemon
|
|
152
|
+
* noticing, and a process left on the volume is what keeps it from detaching.
|
|
145
153
|
*
|
|
146
154
|
* A leftover keeps running while it is looked for, and a child it starts after the process table
|
|
147
155
|
* was read is in no table that was. So each one found is held with SIGSTOP and the table is read
|
|
@@ -219,8 +227,13 @@ export function leaseProcessesOn(host) {
|
|
|
219
227
|
},
|
|
220
228
|
};
|
|
221
229
|
}
|
|
230
|
+
/** What works in `directory` on this host: by working directory, and by the `TMPDIR` it was started with. */
|
|
231
|
+
export async function pidsInLease(directory) {
|
|
232
|
+
const [working, temp] = await Promise.all([pidsWorkingIn(directory), pidsWithTempIn(directory)]);
|
|
233
|
+
return [...new Set([...working, ...temp])];
|
|
234
|
+
}
|
|
222
235
|
export const hostLeaseProcesses = leaseProcessesOn({
|
|
223
|
-
workingIn:
|
|
236
|
+
workingIn: pidsInLease,
|
|
224
237
|
table: processTable,
|
|
225
238
|
signal: terminate,
|
|
226
239
|
});
|
|
@@ -760,9 +773,10 @@ export class RamTempVolume {
|
|
|
760
773
|
}
|
|
761
774
|
const reaped = [];
|
|
762
775
|
for (const candidate of candidates) {
|
|
763
|
-
// Its task is gone, so what works in it is what that task left: stopped before the lease
|
|
764
|
-
//
|
|
765
|
-
|
|
776
|
+
// Its task is gone, so what works in it is what that task left: stopped before the lease is
|
|
777
|
+
// removed, even where the removal is refused below. An empty lease is asked too: a leftover
|
|
778
|
+
// that has not written yet writes once it runs again. A task reaps its own (`reap`).
|
|
779
|
+
if (!candidate.own) {
|
|
766
780
|
reaped.push(...(await this.processes.stopWorkingIn(candidate.directory)));
|
|
767
781
|
}
|
|
768
782
|
}
|
|
@@ -82,8 +82,8 @@ function writeBunfig(tree, projectRoot) {
|
|
|
82
82
|
// Bun silently ignores `[test] timeout` in bunfig.toml — only the `--timeout`
|
|
83
83
|
// CLI flag and `setDefaultTimeout()` actually take effect. Strip any stale
|
|
84
84
|
// `timeout = N` lines so the file isn't lying about what's enforced; the real
|
|
85
|
-
// per-test timeout is
|
|
86
|
-
//
|
|
85
|
+
// per-test timeout is the leg's `--timeout`, which the bounded-test policy
|
|
86
|
+
// derives from bounded-exec's progress bound (see BUN_TEST_TIMEOUT_FLAG).
|
|
87
87
|
const current = stripBunTestTimeoutLine(tree.read(bunfigPath, 'utf-8') ?? '');
|
|
88
88
|
// Already has the package specifier preloads
|
|
89
89
|
if (current.includes('@smoothbricks/lmao/bun/preload')) {
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { NxJsonConfiguration } from 'nx/src/config/nx-json';
|
|
2
|
+
import type { NodeWitness, WorkspaceSnapshot } from './ensure-built-witness.js';
|
|
3
|
+
/** An owner-approved contract, pinned to the reviewed module bytes, never an inferred approval. */
|
|
4
|
+
export interface GraphInputContract {
|
|
5
|
+
readonly version: 1;
|
|
6
|
+
readonly kind: 'native-only' | 'tsconfig-extends' | 'reference-scan';
|
|
7
|
+
readonly modules: readonly {
|
|
8
|
+
readonly path: string;
|
|
9
|
+
readonly sha256: string;
|
|
10
|
+
}[];
|
|
11
|
+
readonly packages: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
interface ResolutionWitness {
|
|
14
|
+
readonly kind: 'node' | 'bun';
|
|
15
|
+
readonly from: string;
|
|
16
|
+
readonly specifier: string;
|
|
17
|
+
readonly target: string | null;
|
|
18
|
+
}
|
|
19
|
+
interface ToolWitness {
|
|
20
|
+
readonly name: 'node' | 'bun' | 'git';
|
|
21
|
+
readonly path: string;
|
|
22
|
+
}
|
|
23
|
+
interface GitQueryWitness {
|
|
24
|
+
readonly cwd: string;
|
|
25
|
+
readonly args: readonly ['config', '--show-origin', '--null', '--list'] | readonly ['ls-files', '-z', '--cached', '--others', '--exclude-standard'] | readonly ['check-attr', '--all', '-z', '--stdin'] | readonly ['var', 'GIT_ATTR_SYSTEM'] | readonly ['var', 'GIT_ATTR_GLOBAL'] | readonly ['rev-parse', '--shared-index-path'];
|
|
26
|
+
readonly stdin: string;
|
|
27
|
+
readonly sha256: string;
|
|
28
|
+
}
|
|
29
|
+
interface ReadWitnessBasis {
|
|
30
|
+
readonly version: 1;
|
|
31
|
+
readonly workspaceRoot: string;
|
|
32
|
+
readonly plugin: string;
|
|
33
|
+
readonly contractSha256: string;
|
|
34
|
+
}
|
|
35
|
+
export type GraphInputReadWitness = (ReadWitnessBasis & {
|
|
36
|
+
readonly status: 'complete';
|
|
37
|
+
readonly nativeIdentity: string;
|
|
38
|
+
readonly nativeNodes: readonly NodeWitness[];
|
|
39
|
+
readonly nodes: readonly GraphInputNodeWitness[];
|
|
40
|
+
readonly missing: readonly string[];
|
|
41
|
+
readonly resolutions: readonly ResolutionWitness[];
|
|
42
|
+
readonly tools: readonly ToolWitness[];
|
|
43
|
+
readonly gitQueries: readonly GitQueryWitness[];
|
|
44
|
+
readonly environmentIdentity: string;
|
|
45
|
+
}) | (ReadWitnessBasis & {
|
|
46
|
+
readonly status: 'unproved';
|
|
47
|
+
readonly detail: string;
|
|
48
|
+
});
|
|
49
|
+
export interface GraphInputContractProof {
|
|
50
|
+
readonly plugins: readonly string[];
|
|
51
|
+
readonly identity: string;
|
|
52
|
+
readonly packages: readonly {
|
|
53
|
+
readonly name: string;
|
|
54
|
+
readonly from: string;
|
|
55
|
+
}[];
|
|
56
|
+
}
|
|
57
|
+
/** Ancestors prove path binding; only a read directory's membership belongs to the input closure. */
|
|
58
|
+
interface GraphInputNodeWitness extends NodeWitness {
|
|
59
|
+
readonly scope: 'path' | 'node';
|
|
60
|
+
}
|
|
61
|
+
/** Retain read/resolution byproducts at the reader; never reconstruct its extends/import algorithm. */
|
|
62
|
+
export declare class GraphInputReadCollector {
|
|
63
|
+
readonly workspaceRoot: string;
|
|
64
|
+
readonly plugin: string;
|
|
65
|
+
private readonly contract;
|
|
66
|
+
private readonly before;
|
|
67
|
+
private readonly environment;
|
|
68
|
+
private readonly nodes;
|
|
69
|
+
private readonly missing;
|
|
70
|
+
private readonly resolutions;
|
|
71
|
+
private readonly tools;
|
|
72
|
+
private readonly gitQueries;
|
|
73
|
+
private readonly scanned;
|
|
74
|
+
private readonly gitScopes;
|
|
75
|
+
private detail;
|
|
76
|
+
constructor(workspaceRoot: string, plugin: string, options: unknown);
|
|
77
|
+
refuse(detail: string): void;
|
|
78
|
+
private protect;
|
|
79
|
+
/** Observe each alias and its physical target, including a missing candidate's exact path. */
|
|
80
|
+
file(path: string): void;
|
|
81
|
+
private observe;
|
|
82
|
+
read<T>(path: string, reader: () => T): T;
|
|
83
|
+
exists(path: string): boolean;
|
|
84
|
+
/** The whole immediate candidate directory, including absent/alternative extensions and alias nodes. */
|
|
85
|
+
directory(path: string): void;
|
|
86
|
+
/** A finite candidate namespace: every node and alias, not only the previously selected file. */
|
|
87
|
+
namespace(path: string): void;
|
|
88
|
+
private walk;
|
|
89
|
+
resolve(from: string, specifier: string, resolver: () => string, kind?: ResolutionWitness['kind']): string;
|
|
90
|
+
executable(name: ToolWitness['name'], actual?: string): string | undefined;
|
|
91
|
+
/** Git itself supplies effective config/include origins, membership and attributes; no config reparser. */
|
|
92
|
+
git(root: string, paths: readonly string[]): void;
|
|
93
|
+
finish(): GraphInputReadWitness;
|
|
94
|
+
}
|
|
95
|
+
/** Every local plugin must prove its own approved code and actual outside-input byproducts. */
|
|
96
|
+
export declare function graphInputContractIdentity(root: string, nxJson: NxJsonConfiguration, snapshot: WorkspaceSnapshot): GraphInputContractProof | null;
|
|
97
|
+
export {};
|
|
98
|
+
//# sourceMappingURL=graph-input-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph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