@smoothbricks/nx-plugin 0.4.28 → 0.4.30
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 +277 -89
- package/dist/bin/smoo-nx-test-clocks.d.ts +3 -0
- package/dist/bin/smoo-nx-test-clocks.d.ts.map +1 -0
- package/dist/bin/smoo-nx-test-clocks.js +28 -0
- package/dist/bounded-test-policy.d.ts +8 -8
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +18 -30
- package/dist/cargo-closure-input.d.ts +23 -0
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +41 -9
- 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 +40 -6
- package/dist/ensure-built-receipt.d.ts.map +1 -1
- package/dist/ensure-built-receipt.js +297 -159
- package/dist/ensure-built-witness.d.ts +65 -4
- package/dist/ensure-built-witness.d.ts.map +1 -1
- package/dist/ensure-built-witness.js +2237 -23
- package/dist/ensure-built.d.ts +99 -1
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +45 -56
- package/dist/executors/bounded-exec/cpu-pool.d.ts +22 -7
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool.js +51 -22
- package/dist/executors/bounded-exec/executor.d.ts +12 -3
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +174 -51
- package/dist/executors/bounded-exec/no-space.d.ts +8 -0
- package/dist/executors/bounded-exec/no-space.d.ts.map +1 -0
- package/dist/executors/bounded-exec/no-space.js +31 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts +20 -11
- package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
- package/dist/executors/bounded-exec/ram-temp.js +42 -17
- package/dist/executors/bounded-exec/verdict.d.ts +34 -4
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +54 -3
- package/dist/generators/bun-test-tracing/generator.js +2 -2
- package/dist/graph-input-contract.d.ts +102 -0
- package/dist/graph-input-contract.d.ts.map +1 -0
- package/dist/graph-input-contract.js +637 -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/owned-installation.d.ts +14 -0
- package/dist/owned-installation.d.ts.map +1 -0
- package/dist/owned-installation.js +324 -0
- package/dist/producer-receipts.d.ts +19 -0
- package/dist/producer-receipts.d.ts.map +1 -0
- package/dist/producer-receipts.js +926 -0
- package/dist/test-backstop.d.ts +9 -0
- package/dist/test-backstop.d.ts.map +1 -0
- package/dist/test-backstop.js +10 -0
- package/dist/test-clock-policy.d.ts +30 -0
- package/dist/test-clock-policy.d.ts.map +1 -0
- package/dist/test-clock-policy.js +686 -0
- package/dist/testing.d.ts +8 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +66 -1
- package/managed/raw/patches/nx@23.2.1.patch +328 -50
- package/managed/raw/tooling/direnv/developer-links.ts +148 -29
- 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 -115
- 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 +25 -9
- package/src/__tests__/cargo-closure-fixture.ts +113 -0
- package/src/__tests__/counted-cargo.ts +8 -25
- package/src/__tests__/directory-change.ts +27 -0
- package/src/__tests__/fixture-nx-env.ts +7 -0
- package/src/__tests__/owned-installation.ts +14 -0
- package/src/__tests__/past-tick.ts +12 -0
- package/src/bin/smoo-nx-bound-failures.test.ts +1 -1
- package/src/bin/smoo-nx-test-clocks.ts +29 -0
- package/src/bounded-test-policy.test.ts +36 -22
- package/src/bounded-test-policy.ts +18 -32
- package/src/bun-bootstrap.test.ts +1 -1
- package/src/cargo-closure-input.property.test.ts +50 -0
- package/src/cargo-closure-input.test.ts +73 -121
- package/src/cargo-closure-input.ts +47 -8
- package/src/cargo-closure-key.test.ts +239 -0
- package/src/cargo-resolve-cache.test.ts +168 -31
- 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 +294 -149
- package/src/ensure-built-witness.test.ts +306 -13
- package/src/ensure-built-witness.ts +255 -24
- package/src/ensure-built.test.ts +228 -102
- package/src/ensure-built.ts +127 -66
- package/src/executors/bounded-exec/cpu-pool.test.ts +134 -32
- package/src/executors/bounded-exec/cpu-pool.ts +64 -20
- package/src/executors/bounded-exec/cpu-tokens.test.ts +2 -2
- package/src/executors/bounded-exec/disk-lease.test.ts +47 -13
- package/src/executors/bounded-exec/executor-host.test.ts +74 -52
- package/src/executors/bounded-exec/executor.test.ts +343 -97
- package/src/executors/bounded-exec/executor.ts +192 -56
- package/src/executors/bounded-exec/hang-diagnostics.test.ts +14 -8
- package/src/executors/bounded-exec/no-space.ts +40 -0
- package/src/executors/bounded-exec/progress.test.ts +1 -1
- package/src/executors/bounded-exec/ram-temp-host.test.ts +51 -21
- package/src/executors/bounded-exec/ram-temp.test.ts +92 -16
- package/src/executors/bounded-exec/ram-temp.ts +49 -20
- package/src/executors/bounded-exec/verdict.test.ts +127 -22
- package/src/executors/bounded-exec/verdict.ts +78 -3
- 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 +379 -0
- package/src/graph-input-contract.ts +627 -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-extraction.test.ts +114 -4
- 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 +10 -8
- package/src/nx-daemon-idle-cpu.test.ts +0 -1
- package/src/nx-daemon-idle-policy.test.ts +61 -1
- package/src/nx-daemon-ignore-files.test.ts +2 -2
- package/src/nx-daemon-validity.test.ts +36 -22
- 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/owned-installation.ts +174 -0
- package/src/producer-receipts.test.ts +164 -0
- package/src/producer-receipts.ts +636 -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-backstop.ts +11 -0
- package/src/test-clock-policy.test.ts +338 -0
- package/src/test-clock-policy.ts +708 -0
- package/src/test-timings.test.ts +2 -2
- package/src/testing.test.ts +5 -5
- package/src/testing.ts +67 -1
- package/src/typecheck-test-policy.test.ts +1 -1
- package/src/typescript-resolution.test.ts +76 -0
- package/test-timings.json +8 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { PackageTargetPolicyOptions, ResolvedProjectTargets } from './package-target-policy.js';
|
|
2
|
+
export { BOUNDED_TEST_IDLE_TIMEOUT_MS, BOUNDED_TEST_KILL_AFTER_MS } from './test-backstop.js';
|
|
2
3
|
export declare const BOUNDED_TEST_EXECUTOR = "@smoothbricks/nx-plugin:bounded-exec";
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Deletes Bun's per-test deadline: 5000 ms unless the command sets one, and Bun ignores a bunfig `[test] timeout`, so
|
|
6
|
+
* the flag is the one place to set it. `0` means no deadline (measured on the pinned Bun 1.4.2: a test blocked 12 s in
|
|
7
|
+
* `spawnSync` and one sleeping 7 s both pass under `--timeout=0`). A test waits for the event it is waiting for, and
|
|
8
|
+
* the leg's `idleTimeoutMs` ends a test that never returns; no per-test bound kills a test, however long a loaded host
|
|
9
|
+
* makes its work take (specs/cowshed/08_testing.md).
|
|
8
10
|
*/
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const BOUNDED_TEST_KILL_AFTER_MS = 10000;
|
|
11
|
-
export declare const BOUNDED_TEST_PER_TEST_TIMEOUT_MS = 30000;
|
|
11
|
+
export declare const BUN_TEST_TIMEOUT_FLAG = "--timeout=0";
|
|
12
12
|
export interface BoundedTestPolicyPackageJson {
|
|
13
13
|
name?: string;
|
|
14
14
|
workspaces?: unknown;
|
|
@@ -64,5 +64,5 @@ export declare function checkWorkspaceCargoTestReachabilityPolicy(root: string,
|
|
|
64
64
|
export declare function checkBoundedTestTargetPolicy(packageJson: BoundedTestPolicyPackageJson, options: ApplyBoundedTestTargetPolicyOptions): boolean;
|
|
65
65
|
export declare function boundedTestScriptAlias(projectName: string): string;
|
|
66
66
|
export declare function resolveTestCommand(packageJson: BoundedTestPolicyPackageJson, defaultCommand?: string, projectJson?: BoundedTestPolicyProjectJson): string;
|
|
67
|
-
export declare function ensureBunTestTimeoutFlag(command: string
|
|
67
|
+
export declare function ensureBunTestTimeoutFlag(command: string): string;
|
|
68
68
|
//# sourceMappingURL=bounded-test-policy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounded-test-policy.d.ts","sourceRoot":"","sources":["../src/bounded-test-policy.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"bounded-test-policy.d.ts","sourceRoot":"","sources":["../src/bounded-test-policy.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAIrG,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAC9F,eAAO,MAAM,qBAAqB,yCAAyC,CAAC;AAC5E;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,gBAAgB,CAAC;AAEnD,MAAM,WAAW,4BAA4B;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,EAAE,CAAC,EAAE;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;KACnD,CAAC;CACH;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mCAAmC;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,4BAA4B,CAAC;IAC3C,eAAe,CAAC,EAAE,sBAAsB,CAAC;CAC1C;AAED,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,4BAA4B,EACzC,OAAO,EAAE,mCAAmC,GAC3C,IAAI,CAuBN;AAED,wBAAgB,qCAAqC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,0BAA+B,GAAG,OAAO,CAiCrH;AAED,wBAAgB,qCAAqC,CACnD,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,0BAA+B,GACvC,sBAAsB,EAAE,CA4B1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,yCAAyC,CACvD,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,0BAA+B,GACvC,sBAAsB,EAAE,CAwC1B;AAiID,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,4BAA4B,EACzC,OAAO,EAAE,mCAAmC,GAC3C,OAAO,CAqBT;AA8KD,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAElE;AAED,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,4BAA4B,EACzC,cAAc,SAAa,EAC3B,WAAW,CAAC,EAAE,4BAA4B,GACzC,MAAM,CAER;AA4CD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAYhE"}
|
|
@@ -3,21 +3,18 @@ import { dirname, join } from 'node:path';
|
|
|
3
3
|
import { expandWildcardTargetConfiguration } from 'nx/src/tasks-runner/utils.js';
|
|
4
4
|
import { CARGO_TEST_ARCHIVE_TARGET, CARGO_TEST_COMPILE_TARGET, CARGO_TEST_TARGET, listCargoWorkspacePackages, packageNameFromCargoTestTarget, } from './cargo-workspace.js';
|
|
5
5
|
import { writeJsonFile } from './managed-files/managed-format.js';
|
|
6
|
+
import { BOUNDED_TEST_IDLE_TIMEOUT_MS, BOUNDED_TEST_KILL_AFTER_MS } from './test-backstop.js';
|
|
6
7
|
import { isTestRunnerTargetName } from './workspace-config-policy.js';
|
|
8
|
+
export { BOUNDED_TEST_IDLE_TIMEOUT_MS, BOUNDED_TEST_KILL_AFTER_MS } from './test-backstop.js';
|
|
7
9
|
export const BOUNDED_TEST_EXECUTOR = '@smoothbricks/nx-plugin:bounded-exec';
|
|
8
10
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* Deletes Bun's per-test deadline: 5000 ms unless the command sets one, and Bun ignores a bunfig `[test] timeout`, so
|
|
12
|
+
* the flag is the one place to set it. `0` means no deadline (measured on the pinned Bun 1.4.2: a test blocked 12 s in
|
|
13
|
+
* `spawnSync` and one sleeping 7 s both pass under `--timeout=0`). A test waits for the event it is waiting for, and
|
|
14
|
+
* the leg's `idleTimeoutMs` ends a test that never returns; no per-test bound kills a test, however long a loaded host
|
|
15
|
+
* makes its work take (specs/cowshed/08_testing.md).
|
|
13
16
|
*/
|
|
14
|
-
export const
|
|
15
|
-
export const BOUNDED_TEST_KILL_AFTER_MS = 10_000;
|
|
16
|
-
// Per-test timeout passed to `bun test --timeout=<ms>`. Bun's default is
|
|
17
|
-
// 5000ms which is too tight for git-fixture tests on slower CI runners
|
|
18
|
-
// (Actions). The bunfig.toml `[test] timeout` key is silently ignored by
|
|
19
|
-
// Bun — the only working surfaces are this CLI flag and `setDefaultTimeout()`.
|
|
20
|
-
export const BOUNDED_TEST_PER_TEST_TIMEOUT_MS = 30_000;
|
|
17
|
+
export const BUN_TEST_TIMEOUT_FLAG = '--timeout=0';
|
|
21
18
|
export function applyBoundedTestTargetPolicy(packageJson, options) {
|
|
22
19
|
const command = resolveTestCommand(packageJson, options.defaultCommand ?? 'bun test', options.projectJson);
|
|
23
20
|
let targetOwner = options.projectJson;
|
|
@@ -345,7 +342,7 @@ function isBoundedExecutionTarget(executor, rawOptions, allowedCwds) {
|
|
|
345
342
|
// A test leg is bounded by progress alone: a wall-clock ceiling fails a suite that is only slow.
|
|
346
343
|
rawOptions.timeoutMs === undefined &&
|
|
347
344
|
isPositiveSafeInteger(rawOptions.idleTimeoutMs) &&
|
|
348
|
-
|
|
345
|
+
bunTestHasNoDeadline(command) &&
|
|
349
346
|
typeof rawOptions.cwd === 'string' &&
|
|
350
347
|
// `bun test` walks its working directory looking for test files, so it must start where that walk is cheap: the
|
|
351
348
|
// project root or its `src/`. Any other command names what it runs and has no walk to bound. A cargo workspace's
|
|
@@ -354,19 +351,14 @@ function isBoundedExecutionTarget(executor, rawOptions, allowedCwds) {
|
|
|
354
351
|
(!BUN_TEST_PREFIX.test(command) || allowedCwds.has(rawOptions.cwd)) &&
|
|
355
352
|
isPositiveSafeInteger(rawOptions.killAfterMs));
|
|
356
353
|
}
|
|
357
|
-
/** A bun leg's per-test
|
|
358
|
-
function
|
|
354
|
+
/** A bun leg deletes Bun's per-test deadline with `BUN_TEST_TIMEOUT_FLAG` and sets no other. */
|
|
355
|
+
function bunTestHasNoDeadline(command) {
|
|
359
356
|
if (!BUN_TEST_PREFIX.test(command)) {
|
|
360
357
|
return true;
|
|
361
358
|
}
|
|
362
359
|
let found = false;
|
|
363
|
-
for (const match of command.matchAll(/(?:^|\s)--timeout(?==|\s|$)
|
|
364
|
-
|
|
365
|
-
const perTestTimeoutMs = Number(value);
|
|
366
|
-
if (value === undefined ||
|
|
367
|
-
!/^\d+$/.test(value) ||
|
|
368
|
-
!isPositiveSafeInteger(perTestTimeoutMs) ||
|
|
369
|
-
perTestTimeoutMs > idleTimeoutMs) {
|
|
360
|
+
for (const match of command.matchAll(/(?:^|\s)(--timeout(?==|\s|$)\S*)/g)) {
|
|
361
|
+
if (match[1] !== BUN_TEST_TIMEOUT_FLAG) {
|
|
370
362
|
return false;
|
|
371
363
|
}
|
|
372
364
|
found = true;
|
|
@@ -486,23 +478,19 @@ function resolveTargetCommand(existingTarget) {
|
|
|
486
478
|
}
|
|
487
479
|
const BUN_TEST_PREFIX = /^bun\s+test(?=\s|$)/;
|
|
488
480
|
const EXISTING_BUN_TIMEOUT = /(^|\s)--timeout(?:=|\s+)(\S+)/;
|
|
489
|
-
//
|
|
490
|
-
|
|
491
|
-
// command so the policy enforces the workspace per-test timeout in the one
|
|
492
|
-
// place where Bun will honor it.
|
|
493
|
-
export function ensureBunTestTimeoutFlag(command, timeoutMs = BOUNDED_TEST_PER_TEST_TIMEOUT_MS) {
|
|
481
|
+
// Normalize every `bun test` command to `BUN_TEST_TIMEOUT_FLAG`, the one place Bun honors a per-test bound.
|
|
482
|
+
export function ensureBunTestTimeoutFlag(command) {
|
|
494
483
|
if (!BUN_TEST_PREFIX.test(command)) {
|
|
495
484
|
return command;
|
|
496
485
|
}
|
|
497
|
-
const flag = `--timeout=${timeoutMs}`;
|
|
498
486
|
const existing = EXISTING_BUN_TIMEOUT.exec(command);
|
|
499
487
|
if (!existing) {
|
|
500
|
-
return command.replace(BUN_TEST_PREFIX, `bun test ${
|
|
488
|
+
return command.replace(BUN_TEST_PREFIX, () => `bun test ${BUN_TEST_TIMEOUT_FLAG}`);
|
|
501
489
|
}
|
|
502
|
-
if (existing[
|
|
490
|
+
if (existing[0].trimStart() === BUN_TEST_TIMEOUT_FLAG) {
|
|
503
491
|
return command;
|
|
504
492
|
}
|
|
505
|
-
return command.replace(EXISTING_BUN_TIMEOUT, `${
|
|
493
|
+
return command.replace(EXISTING_BUN_TIMEOUT, (_match, lead) => `${lead}${BUN_TEST_TIMEOUT_FLAG}`);
|
|
506
494
|
}
|
|
507
495
|
function isPackageTestScriptRunnerCommand(command) {
|
|
508
496
|
return /^(?:bun\s+run|npm(?:\s+run)?|pnpm(?:\s+run)?|yarn(?:\s+run)?)\s+test(?:\s|$)/.test(command.trim());
|
|
@@ -18,6 +18,8 @@ export declare class CargoClosureInputError extends Error {
|
|
|
18
18
|
*/
|
|
19
19
|
export interface CargoClosureSource {
|
|
20
20
|
readonly manifest: string;
|
|
21
|
+
/** The Nx workspace root as the computation names it, which Nx's file index is keyed by. */
|
|
22
|
+
readonly workspaceRoot: string;
|
|
21
23
|
/** The canonical Nx workspace root. */
|
|
22
24
|
readonly root: string;
|
|
23
25
|
readonly cargo: CargoResolve;
|
|
@@ -56,7 +58,28 @@ export declare function resolveCargoClosureSource(manifest: string, workspaceRoo
|
|
|
56
58
|
* An in-workspace member missing from Nx's file index is a typed refusal,
|
|
57
59
|
* never a whole-workspace runtime hash. Only outside-workspace members need
|
|
58
60
|
* the external-only runtime input.
|
|
61
|
+
*
|
|
62
|
+
* A compiled-in file is named only when Nx's file index holds both it and the
|
|
63
|
+
* source that includes it. An ignored one is a build output: no fileset can
|
|
64
|
+
* hash its bytes, which reach a consumer through its producer's dependency
|
|
65
|
+
* outputs instead, so naming it would add nothing to any task's key except
|
|
66
|
+
* the names of whatever output last ran. That state is exactly what a project
|
|
67
|
+
* graph must not read (`globIndexedFiles`): a producer that regenerates
|
|
68
|
+
* content-named files would otherwise move every key of the graph it was
|
|
69
|
+
* hashed under, and the run that compiled a tree would leave its verdict
|
|
70
|
+
* under a key no later run of the same tree computes.
|
|
59
71
|
*/
|
|
60
72
|
export declare function cargoClosureInputs(projectRoot: string, sources: readonly CargoClosureSource[]): Promise<Input[]>;
|
|
73
|
+
/** A compiled-in file and the source whose `include_str!`/`include_bytes!` names it, relative to the workspace root. */
|
|
74
|
+
export interface CompiledInclusion {
|
|
75
|
+
readonly declaring: string;
|
|
76
|
+
readonly file: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The compiled-in files a `cargoClosure` names, sorted: each one Nx's file index holds together with the source that
|
|
80
|
+
* includes it. `held` is the index's answer for exactly those paths. A file it does not hold is a build output or
|
|
81
|
+
* ignored, and naming it would key the graph on whatever last wrote it rather than on the tree.
|
|
82
|
+
*/
|
|
83
|
+
export declare function indexedCompiledFiles(compiledIn: readonly CompiledInclusion[], held: ReadonlySet<string>): string[];
|
|
61
84
|
export {};
|
|
62
85
|
//# sourceMappingURL=cargo-closure-input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cargo-closure-input.d.ts","sourceRoot":"","sources":["../src/cargo-closure-input.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,kBAAkB,EAKxB,MAAM,wBAAwB,CAAC;AAIhC;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAElD,KAAK,KAAK,GAAG,WAAW,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,mFAAmF;AACnF,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B,YAAY,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAS9C;CACF;AAgBD;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,uCAAuC;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC,CAAC;CAChE;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAE/F;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC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,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,EACrC,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC,GACpD,OAAO,CAAC,kBAAkB,CAAC,CAI7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,SAAS,kBAAkB,EAAE,GACrC,OAAO,CAAC,KAAK,EAAE,CAAC,CAelB;AA8FD,wHAAwH;AACxH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,SAAS,iBAAiB,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAMlH"}
|
|
@@ -48,7 +48,7 @@ export async function indexedCargoManifests(workspaceRoot) {
|
|
|
48
48
|
export async function resolveCargoClosureSource(manifest, workspaceRoot, indexed, compiledFilesCache) {
|
|
49
49
|
const [root, index] = await Promise.all([realpath(workspaceRoot), indexed]);
|
|
50
50
|
const cargo = await readCargoResolve(join(root, manifest), root, index);
|
|
51
|
-
return { manifest, root, cargo, indexed: index, compiledFilesCache };
|
|
51
|
+
return { manifest, workspaceRoot, root, cargo, indexed: index, compiledFilesCache };
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* The `cargoClosure` definition for the project at `projectRoot`: for each
|
|
@@ -69,6 +69,16 @@ export async function resolveCargoClosureSource(manifest, workspaceRoot, indexed
|
|
|
69
69
|
* An in-workspace member missing from Nx's file index is a typed refusal,
|
|
70
70
|
* never a whole-workspace runtime hash. Only outside-workspace members need
|
|
71
71
|
* the external-only runtime input.
|
|
72
|
+
*
|
|
73
|
+
* A compiled-in file is named only when Nx's file index holds both it and the
|
|
74
|
+
* source that includes it. An ignored one is a build output: no fileset can
|
|
75
|
+
* hash its bytes, which reach a consumer through its producer's dependency
|
|
76
|
+
* outputs instead, so naming it would add nothing to any task's key except
|
|
77
|
+
* the names of whatever output last ran. That state is exactly what a project
|
|
78
|
+
* graph must not read (`globIndexedFiles`): a producer that regenerates
|
|
79
|
+
* content-named files would otherwise move every key of the graph it was
|
|
80
|
+
* hashed under, and the run that compiled a tree would leave its verdict
|
|
81
|
+
* under a key no later run of the same tree computes.
|
|
72
82
|
*/
|
|
73
83
|
export async function cargoClosureInputs(projectRoot, sources) {
|
|
74
84
|
const inputs = [];
|
|
@@ -91,7 +101,8 @@ async function workspaceClosureInputs(projectRoot, source) {
|
|
|
91
101
|
const { root, cargo, indexed } = source;
|
|
92
102
|
const packageDirectories = [];
|
|
93
103
|
const files = [];
|
|
94
|
-
const
|
|
104
|
+
const compiledIn = [];
|
|
105
|
+
let compiledFiles = [];
|
|
95
106
|
let external = false;
|
|
96
107
|
try {
|
|
97
108
|
const members = await dependencyClosure(cargo, join(root, projectRoot));
|
|
@@ -106,11 +117,15 @@ async function workspaceClosureInputs(projectRoot, source) {
|
|
|
106
117
|
if (!indexed.has(posix.join(directory, 'Cargo.toml'))) {
|
|
107
118
|
throw new Error(`the Cargo package ${directory} is not in Nx's file index (an ignored directory)`);
|
|
108
119
|
}
|
|
109
|
-
for (const
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
112
|
-
throw new Error(`${directory} compiles ${file}, which Nx's file index cannot hold`);
|
|
113
|
-
|
|
120
|
+
for (const compiled of compiledInFiles(pkg.directory, source.compiledFilesCache)) {
|
|
121
|
+
const file = indexablePath(root, compiled.file);
|
|
122
|
+
if (file === null)
|
|
123
|
+
throw new Error(`${directory} compiles ${compiled.file}, which Nx's file index cannot hold`);
|
|
124
|
+
// The scan starts inside this package's indexable directory, so its sources can always be named.
|
|
125
|
+
const declaring = indexablePath(root, compiled.source);
|
|
126
|
+
if (declaring === null)
|
|
127
|
+
throw new Error(`${compiled.source} was scanned outside ${directory}`);
|
|
128
|
+
compiledIn.push({ declaring, file });
|
|
114
129
|
}
|
|
115
130
|
packageDirectories.push(directory);
|
|
116
131
|
for (const file of [...pkg.sources, pkg.governingManifest]) {
|
|
@@ -120,9 +135,13 @@ async function workspaceClosureInputs(projectRoot, source) {
|
|
|
120
135
|
files.push(path);
|
|
121
136
|
}
|
|
122
137
|
}
|
|
123
|
-
const
|
|
138
|
+
const compiledPaths = [...new Set(compiledIn.flatMap(({ declaring, file }) => [declaring, file]))];
|
|
139
|
+
const unglobbable = [...packageDirectories, ...files, ...compiledPaths].find((path) => GLOB_SYNTAX.test(path));
|
|
124
140
|
if (unglobbable !== undefined)
|
|
125
141
|
throw new Error(`${unglobbable} contains glob syntax, so no fileset can name it`);
|
|
142
|
+
// Literal paths, so each matches exactly itself in the index.
|
|
143
|
+
const held = new Set(compiledPaths.length === 0 ? [] : await globIndexedFiles(source.workspaceRoot, compiledPaths));
|
|
144
|
+
compiledFiles = indexedCompiledFiles(compiledIn, held);
|
|
126
145
|
}
|
|
127
146
|
catch (error) {
|
|
128
147
|
throw new CargoClosureInputError(projectRoot, error);
|
|
@@ -161,11 +180,24 @@ async function workspaceClosureInputs(projectRoot, source) {
|
|
|
161
180
|
...packageGlobs.map((glob) => anchored(glob, PACKAGE_FILES)),
|
|
162
181
|
...packageGlobs.map((glob) => `!${anchored(glob, SKIPPED_TREES)}`),
|
|
163
182
|
...[...ancestors].sort().map((ancestor) => anchored(ancestor, ANCESTOR_FILES)),
|
|
164
|
-
...
|
|
183
|
+
...compiledFiles.map((file) => anchored(file)),
|
|
165
184
|
...[...loose].sort().map((file) => anchored(file)),
|
|
166
185
|
...(external ? [runtimeInput(`${CARGO_HASH_COMMAND} ${closureArguments}`)] : []),
|
|
167
186
|
];
|
|
168
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* The compiled-in files a `cargoClosure` names, sorted: each one Nx's file index holds together with the source that
|
|
190
|
+
* includes it. `held` is the index's answer for exactly those paths. A file it does not hold is a build output or
|
|
191
|
+
* ignored, and naming it would key the graph on whatever last wrote it rather than on the tree.
|
|
192
|
+
*/
|
|
193
|
+
export function indexedCompiledFiles(compiledIn, held) {
|
|
194
|
+
const named = new Set();
|
|
195
|
+
for (const { declaring, file } of compiledIn) {
|
|
196
|
+
if (held.has(declaring) && held.has(file))
|
|
197
|
+
named.add(file);
|
|
198
|
+
}
|
|
199
|
+
return [...named].sort();
|
|
200
|
+
}
|
|
169
201
|
/**
|
|
170
202
|
* `path` relative to the workspace root, `/`-separated, when it is somewhere
|
|
171
203
|
* Nx's file index can hold: inside the workspace and not under `node_modules`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cargo-source-hash.d.ts","sourceRoot":"","sources":["../src/cargo-source-hash.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cargo-source-hash.d.ts","sourceRoot":"","sources":["../src/cargo-source-hash.ts"],"names":[],"mappings":"AAqFA,mFAAmF;AACnF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,iHAAiH;IACjH,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACpC;AAED,kGAAkG;AAClG,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,KAAK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,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAAG,SAAS,EAOvC;CACF;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,CAmF7D;AAoCD,wBAAsB,mBAAmB,CACvC,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,MAAM,CAAC,CA6HjB;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAc5G;AAoGD,yFAAyF;AACzF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAOD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC,GAAG,kBAAkB,EAAE,CA0C5G"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { execFileSync, spawn, spawnSync } from 'node:child_process';
|
|
2
2
|
import { createHash, randomUUID } from 'node:crypto';
|
|
3
3
|
import { channel } from 'node:diagnostics_channel';
|
|
4
|
-
import { constants, existsSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs';
|
|
5
|
-
import {
|
|
4
|
+
import { accessSync, constants, existsSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs';
|
|
5
|
+
import { lstat, mkdir, readdir, readFile, readlink, realpath, rename, rm, stat, writeFile } from 'node:fs/promises';
|
|
6
6
|
import { createRequire } from 'node:module';
|
|
7
7
|
import { homedir } from 'node:os';
|
|
8
8
|
import { delimiter, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
@@ -299,16 +299,16 @@ function resolutionFiles(root, manifest, cargo, indexed) {
|
|
|
299
299
|
const directories = new Set([root]);
|
|
300
300
|
for (const file of paths)
|
|
301
301
|
directories.add(dirname(file));
|
|
302
|
+
const ancestors = new Set();
|
|
302
303
|
for (const directory of directories) {
|
|
303
304
|
paths.add(join(directory, 'Cargo.lock'));
|
|
304
|
-
for (let ancestor = directory
|
|
305
|
+
for (let ancestor = directory; !ancestors.has(ancestor); ancestor = dirname(ancestor)) {
|
|
306
|
+
ancestors.add(ancestor);
|
|
305
307
|
paths.add(join(ancestor, '.cargo/config'));
|
|
306
308
|
paths.add(join(ancestor, '.cargo/config.toml'));
|
|
307
309
|
paths.add(join(ancestor, 'rust-toolchain'));
|
|
308
310
|
paths.add(join(ancestor, 'rust-toolchain.toml'));
|
|
309
311
|
paths.add(join(ancestor, 'Cargo.toml'));
|
|
310
|
-
if (dirname(ancestor) === ancestor)
|
|
311
|
-
break;
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
for (const pin of CARGO_TOOLCHAIN_PIN_INPUTS)
|
|
@@ -319,12 +319,12 @@ function resolutionFiles(root, manifest, cargo, indexed) {
|
|
|
319
319
|
return paths;
|
|
320
320
|
}
|
|
321
321
|
/** Toolchain selection can change even while the declared pin's bytes do not. */
|
|
322
|
-
|
|
322
|
+
function cargoExecutable() {
|
|
323
323
|
for (const directory of (process.env.PATH ?? '').split(delimiter)) {
|
|
324
324
|
const executable = resolve(directory, process.platform === 'win32' ? 'cargo.exe' : 'cargo');
|
|
325
325
|
try {
|
|
326
|
-
|
|
327
|
-
return
|
|
326
|
+
accessSync(executable, constants.X_OK);
|
|
327
|
+
return realpathSync.native(executable);
|
|
328
328
|
}
|
|
329
329
|
catch (error) {
|
|
330
330
|
if (!(error instanceof Error &&
|
|
@@ -335,14 +335,17 @@ async function cargoExecutable() {
|
|
|
335
335
|
}
|
|
336
336
|
return '<cargo-not-on-PATH>';
|
|
337
337
|
}
|
|
338
|
-
|
|
338
|
+
function resolutionKey(root, manifest, cargo, indexed) {
|
|
339
339
|
const cargoHome = resolve(process.env.CARGO_HOME ?? join(homedir(), '.cargo'));
|
|
340
|
-
const executable =
|
|
340
|
+
const executable = cargoExecutable();
|
|
341
341
|
const hash = createHash('sha256').update(`${RESOLVE_CACHE_SCHEMA}\0${root}\0${manifest}\0${cargoHome}\0${executable}\0${process.env.RUSTUP_TOOLCHAIN ?? ''}\0${process.env.RUSTUP_HOME ?? ''}\0`);
|
|
342
342
|
for (const file of [...resolutionFiles(root, manifest, cargo, indexed)].sort()) {
|
|
343
343
|
hash.update(file).update('\0');
|
|
344
344
|
try {
|
|
345
|
-
|
|
345
|
+
// Most ancestor inputs are absent. Read first so those paths need no
|
|
346
|
+
// canonical lookup; small resolution files need no per-file async dispatch.
|
|
347
|
+
const bytes = readFileSync(file);
|
|
348
|
+
const canonical = realpathSync.native(file);
|
|
346
349
|
hash.update(`${canonical}\0${bytes.length}\0`).update(bytes);
|
|
347
350
|
}
|
|
348
351
|
catch (error) {
|
|
@@ -435,7 +438,7 @@ export async function readCargoResolve(manifestPath, cwd, indexed, boundMs = CAR
|
|
|
435
438
|
else
|
|
436
439
|
await state.ready;
|
|
437
440
|
for (let joined = 0; joined <= 3; joined += 1) {
|
|
438
|
-
const key =
|
|
441
|
+
const key = resolutionKey(root, manifest, state.cached?.cargo ?? null, index);
|
|
439
442
|
const pending = state.pending;
|
|
440
443
|
if (pending !== undefined) {
|
|
441
444
|
if (joined === 3)
|
|
@@ -478,6 +481,21 @@ export async function readCargoResolve(manifestPath, cwd, indexed, boundMs = CAR
|
|
|
478
481
|
throw new CargoMetadataError(manifest, error);
|
|
479
482
|
}
|
|
480
483
|
}
|
|
484
|
+
async function observeCacheParent(directory) {
|
|
485
|
+
try {
|
|
486
|
+
const parent = await stat(directory, { bigint: true });
|
|
487
|
+
return { state: 'present', dev: parent.dev.toString(), ino: parent.ino.toString() };
|
|
488
|
+
}
|
|
489
|
+
catch (error) {
|
|
490
|
+
if (!(error instanceof Error))
|
|
491
|
+
throw error;
|
|
492
|
+
return {
|
|
493
|
+
state: 'unavailable',
|
|
494
|
+
code: 'code' in error && typeof error.code === 'string' ? error.code : error.name,
|
|
495
|
+
detail: error.message,
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
}
|
|
481
499
|
async function resolveAndCache(root, manifest, indexed, directory, file, state, boundMs = CARGO_RESOLVE_BOUND_MS) {
|
|
482
500
|
if (IS_WASM)
|
|
483
501
|
throw new Error('Cargo resolution requires the native Nx file lock; a WASM Nx host cannot own Cargo children');
|
|
@@ -485,19 +503,18 @@ async function resolveAndCache(root, manifest, indexed, directory, file, state,
|
|
|
485
503
|
// A warm cache answers with no lock: reading it and keying it spawns nothing and
|
|
486
504
|
// waits for nobody, so an unchanged workspace never queues behind a foreign flight.
|
|
487
505
|
state.cached = await loadResolveCache(file);
|
|
488
|
-
{
|
|
489
|
-
|
|
490
|
-
if (state.cached?.key === key)
|
|
491
|
-
return state.cached.cargo;
|
|
506
|
+
if (state.cached !== null && state.cached.key === resolutionKey(root, manifest, state.cached.cargo, indexed)) {
|
|
507
|
+
return state.cached.cargo;
|
|
492
508
|
}
|
|
493
509
|
const lockFile = join(directory, 'resolve.lock');
|
|
510
|
+
const parentBeforeLock = await observeCacheParent(directory);
|
|
494
511
|
const lock = await acquireCargoResolveLock(lockFile, boundMs);
|
|
495
512
|
try {
|
|
496
513
|
// Another worker may have populated it while this worker waited.
|
|
497
514
|
state.cached = await loadResolveCache(file);
|
|
498
515
|
let inputs = state.cached?.cargo ?? null;
|
|
499
516
|
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
500
|
-
const before =
|
|
517
|
+
const before = resolutionKey(root, manifest, inputs, indexed);
|
|
501
518
|
if (state.cached?.key === before)
|
|
502
519
|
return state.cached.cargo;
|
|
503
520
|
const knownFiles = resolutionFiles(root, manifest, inputs, indexed);
|
|
@@ -509,8 +526,8 @@ async function resolveAndCache(root, manifest, indexed, directory, file, state,
|
|
|
509
526
|
const cargo = cargoFromMetadata(metadata);
|
|
510
527
|
// Capture the published key before validation. Reading it afterwards
|
|
511
528
|
// could pair a post-edit key with Cargo's pre-edit answer.
|
|
512
|
-
const key =
|
|
513
|
-
let changed = before !==
|
|
529
|
+
const key = resolutionKey(root, manifest, cargo, indexed);
|
|
530
|
+
let changed = before !== resolutionKey(root, manifest, inputs, indexed);
|
|
514
531
|
for (const added of resolutionFiles(root, manifest, cargo, indexed)) {
|
|
515
532
|
if (knownFiles.has(added))
|
|
516
533
|
continue;
|
|
@@ -528,10 +545,16 @@ async function resolveAndCache(root, manifest, indexed, directory, file, state,
|
|
|
528
545
|
continue;
|
|
529
546
|
}
|
|
530
547
|
const temporary = `${file}.${process.pid}.${randomUUID()}.tmp`;
|
|
548
|
+
const parentAtTmpOpen = await observeCacheParent(directory);
|
|
531
549
|
try {
|
|
532
550
|
await writeFile(temporary, `${key}\n${JSON.stringify(metadata)}\n`);
|
|
533
551
|
await rename(temporary, file);
|
|
534
552
|
}
|
|
553
|
+
catch (error) {
|
|
554
|
+
const parentAfterFailure = await observeCacheParent(directory);
|
|
555
|
+
const cause = error instanceof Error ? error.message : String(error);
|
|
556
|
+
throw new Error(`Cargo resolution cache publication failed: ${JSON.stringify({ directory, lockFile, temporary, parentBeforeLock, parentAtTmpOpen, parentAfterFailure })}; ${cause}`, { cause: error });
|
|
557
|
+
}
|
|
535
558
|
finally {
|
|
536
559
|
await rm(temporary, { force: true });
|
|
537
560
|
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { Task } from 'nx/src/config/task-graph';
|
|
2
2
|
import type { expandOutputs, HashInputs } from 'nx/src/native';
|
|
3
|
-
import type { EnsureBuiltProbeFailure, EnsureBuiltReceipt } from './ensure-built.js';
|
|
3
|
+
import type { EnsureBuiltOutputReceipt, EnsureBuiltProbeFailure, EnsureBuiltProducerFileInput, EnsureBuiltProducerReceipt, EnsureBuiltReceipt } from './ensure-built.js';
|
|
4
|
+
import { type NodeWitness } from './ensure-built-witness.js';
|
|
5
|
+
export type ReceiptEvidence<T> = {
|
|
6
|
+
readonly ok: true;
|
|
7
|
+
readonly value: T;
|
|
8
|
+
} | {
|
|
9
|
+
readonly ok: false;
|
|
10
|
+
readonly detail: string;
|
|
11
|
+
};
|
|
4
12
|
export interface ProviderInputProof {
|
|
5
13
|
readonly kind: 'exact-file-inputs' | 'conservative-provider-source';
|
|
6
14
|
readonly files: readonly string[];
|
|
@@ -12,14 +20,40 @@ export interface ProviderInputProof {
|
|
|
12
20
|
readonly detail: string;
|
|
13
21
|
};
|
|
14
22
|
}
|
|
15
|
-
|
|
23
|
+
export interface ProducerSourceWitness {
|
|
24
|
+
readonly head: string;
|
|
25
|
+
readonly headTree: string;
|
|
26
|
+
readonly files: readonly EnsureBuiltProducerFileInput[];
|
|
27
|
+
readonly nodes: readonly NodeWitness[];
|
|
28
|
+
readonly outputs: readonly string[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Git as receipts read it: the checkout and nothing of the operator's home. The producer hooks run in whichever process
|
|
32
|
+
* Nx runs plugins in, a workspace's sandboxed daemon included, which adopts a host client's HOME; git with that HOME
|
|
33
|
+
* reads the operator's global configuration, the sandbox denies it, and git dies (specs/cowshed/04_sandbox.md, the
|
|
34
|
+
* runtime-input contract). A receipt's tree, HEAD and tracked-file status are read under the repository's own
|
|
35
|
+
* configuration alone, so a host run and a sandboxed run agree on them.
|
|
36
|
+
*/
|
|
37
|
+
export declare function receiptGit(root: string, args: string[]): ReceiptEvidence<string>;
|
|
38
|
+
/** NUL-delimited paths preserve whitespace, rename sources and index-only changes. */
|
|
16
39
|
export declare function dirtyProviderPaths(status: string): string[];
|
|
17
|
-
|
|
40
|
+
/**
|
|
41
|
+
* One independently read node; absolute paths also serve tool/package closures. A census records the node's stamp as
|
|
42
|
+
* of its `start` (recordedStamp); a re-read against a record records none.
|
|
43
|
+
*/
|
|
44
|
+
export declare function receiptNode(path: string, name: string, census?: {
|
|
45
|
+
readonly start: bigint;
|
|
46
|
+
readonly observed: NodeWitness[];
|
|
47
|
+
}): EnsureBuiltOutputReceipt;
|
|
48
|
+
/** Capture every tracked source byte at pre. Unrelated untracked files are not source basis. */
|
|
49
|
+
export declare function captureProducerSource(root: string, outputs: readonly string[]): ReceiptEvidence<ProducerSourceWitness>;
|
|
50
|
+
export declare function producerSourceUnchanged(root: string, before: ProducerSourceWitness): ReceiptEvidence<true>;
|
|
51
|
+
/** Enumerate exact public nodes; never exempt a broad directory of tracked source. */
|
|
52
|
+
export declare function producerOutputPaths(root: string, tasks: readonly Task[], expand: typeof expandOutputs): string[];
|
|
53
|
+
export declare function providerReceipt(root: string, taskId: string, tasks: readonly Task[], proof: ProviderInputProof, expand: typeof expandOutputs, source: ProducerSourceWitness, producer: Omit<EnsureBuiltProducerReceipt, 'outputSha256'>): {
|
|
18
54
|
readonly disposition: 'hit';
|
|
19
55
|
readonly receipt: EnsureBuiltReceipt;
|
|
20
56
|
} | EnsureBuiltProbeFailure;
|
|
21
|
-
/** Admit only recipes emitted by the
|
|
22
|
-
* No shell parsing or keyword approximation confers file-source provenance.
|
|
23
|
-
*/
|
|
57
|
+
/** Admit only version recipes emitted by the owning generator and declared toolchain pins. */
|
|
24
58
|
export declare function boundedReceiptRuntimes(inputs: Readonly<Record<string, HashInputs>>, directories: readonly string[], files: readonly string[], installationProved: boolean): ProviderInputProof['runtimeSource'];
|
|
25
59
|
//# sourceMappingURL=ensure-built-receipt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensure-built-receipt.d.ts","sourceRoot":"","sources":["../src/ensure-built-receipt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"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