@smoothbricks/nx-plugin 0.5.2 → 0.5.4

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.
Files changed (31) hide show
  1. package/README.md +40 -9
  2. package/dist/cargo-source-hash.d.ts +2 -2
  3. package/dist/cargo-source-hash.d.ts.map +1 -1
  4. package/dist/cargo-source-hash.js +106 -46
  5. package/dist/executors/bounded-exec/cpu-tokens.d.ts +13 -0
  6. package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +1 -1
  7. package/dist/executors/bounded-exec/cpu-tokens.js +9 -9
  8. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  9. package/dist/executors/bounded-exec/executor.js +20 -6
  10. package/dist/executors/bounded-exec/progress.d.ts +8 -3
  11. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  12. package/dist/executors/bounded-exec/progress.js +100 -10
  13. package/dist/executors/bounded-exec/verdict.d.ts +5 -4
  14. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  15. package/dist/executors/bounded-exec/verdict.js +1 -0
  16. package/dist/testing.js +1 -1
  17. package/managed/raw/patches/nx@23.2.1.patch +208 -45
  18. package/package.json +2 -2
  19. package/src/cargo-source-hash.test.ts +143 -2
  20. package/src/cargo-source-hash.ts +108 -44
  21. package/src/executors/bounded-exec/cpu-tokens.ts +15 -9
  22. package/src/executors/bounded-exec/executor.test.ts +26 -23
  23. package/src/executors/bounded-exec/executor.ts +19 -4
  24. package/src/executors/bounded-exec/go-progress-host.test.ts +171 -0
  25. package/src/executors/bounded-exec/progress.test.ts +73 -0
  26. package/src/executors/bounded-exec/progress.ts +95 -12
  27. package/src/executors/bounded-exec/verdict.ts +5 -4
  28. package/src/nx-daemon-start-never.test.ts +155 -0
  29. package/src/nx-task-output-lease.test.ts +136 -0
  30. package/src/testing.ts +1 -1
  31. package/test-timings.json +92 -91
package/README.md CHANGED
@@ -426,8 +426,25 @@ toolchain pins, wrapper scripts, N-API configuration and CLI version.
426
426
  Runtime file identities are rooted in Cargo package name/version and the declared input role, not in the consuming
427
427
  checkout's absolute path or depth. Source paths are package-relative; compiled-in data keeps its declaring source and
428
428
  literal path as its identity. Identical main/shed inputs therefore share a key, while changed bytes, module names and
429
- symlink targets still move it. Shared bytes are read once, and all identities are sorted before hashing. The Cargo
430
- resolution memo schema retains package names/versions; refreshing that memo does not reset the Nx task database.
429
+ symlink targets still move it. File identities retain their globally sorted `cargo-path-inputs-v2` transcript, including
430
+ the original insertion order for equal identities. The Cargo resolution memo schema retains package names/versions;
431
+ refreshing that memo does not reset the Nx task database.
432
+
433
+ Runtime include discovery is a bounded fuse, not a source-byte cache. Ordinary scheduled Rust sources are read once:
434
+ their buffer supplies both the existing literal scanner and SHA-256. `file` identities precede the same package's
435
+ `include` identities; packages sharing an identity are processed together. An earlier package's include can consume a
436
+ later package's source, but only its discovered references survive until that later identity's boundary. Retention is
437
+ one live file buffer plus the current UTF-8 decode/tokens and path metadata, including across package boundaries.
438
+ Literal spellings are copied into path-sized storage with the same UTF-8 encoding, without Unicode normalization, so
439
+ substring views cannot pin decoded source files.
440
+
441
+ Discovery still scans ignored sources, just as the graph scanner does. Discovery-only sources that are later included
442
+ (for example through an unignored symlink that resolves to an ignored `.rs`) are read twice: serving those from one read
443
+ would require retaining bytes across their discovery and sorted hash positions. This exception preserves the old digest
444
+ rather than introducing a workspace-sized cache. No source bytes or runtime discovery memo survive an invocation.
445
+ Read-count, timing, corpus-equivalence and retention evidence is recorded in
446
+ `benchmarks/cargo-source-read.results.json`; `benchmarks/cargo-source-read.bench.ts` measures real filesystem reads in a
447
+ Node bundle (Bun does not refresh named builtin imports when the benchmark installs its read observers).
431
448
 
432
449
  Members the file index cannot hold, outside the Nx workspace or under `node_modules`, are hashed by one runtime
433
450
  `smoo-nx-cargo-hash --closure <projectRoot> <Cargo.toml>` entry, present only while such members exist. Its cached
@@ -1311,13 +1328,27 @@ result line or dot. Output that finishes no test is not progress: nextest's `SLO
1311
1328
  period for a test still running, and a hung test's heartbeat both keep printing. A suite that keeps finishing tests
1312
1329
  therefore runs as long as it needs, however slow the host, and a test that never returns ends the run 180 s after the
1313
1330
  last test that finished. bun prints nothing per passing test when it believes an agent runs it, so the executor asks a
1314
- lone `bun test` for `--dots`, one dot per finished test. A command that reports no tests makes progress only by exiting.
1315
- nextest's slow-timeout and the serial groups' code-time classes only warn; no per-test bound kills a test or fails one
1316
- that passed. Bun has a per-test deadline of its own, 5000 ms unless the command sets one, and it reads no bunfig for it,
1317
- so every bun leg deletes it with `bun test --timeout=0` (`BUN_TEST_TIMEOUT_FLAG`; `0` means no deadline, measured on the
1318
- pinned Bun 1.4.2). A test waits for the event it is waiting for, however long a loaded host makes the work take; one
1319
- that never returns still ends the run through `idleTimeoutMs`. `timeoutMs`, an absolute ceiling, is for commands that
1320
- report no tests; a target names at least one of the two.
1331
+ lone `bun test` for `--dots`, one dot per finished test. Without a recognised execution lifecycle, the clock starts at
1332
+ command spawn; a command that reports no tests makes progress only by exiting. nextest's slow-timeout and the serial
1333
+ groups' code-time classes only warn; no per-test bound kills a test or fails one that passed. Bun has a per-test
1334
+ deadline of its own, 5000 ms unless the command sets one, and it reads no bunfig for it, so every bun leg deletes it
1335
+ with `bun test --timeout=0` (`BUN_TEST_TIMEOUT_FLAG`; `0` means no deadline, measured on the pinned Bun 1.4.2). A test
1336
+ waits for the event it is waiting for, however long a loaded host makes the work take; one that never returns still ends
1337
+ the run through `idleTimeoutMs`. `timeoutMs`, an absolute ceiling, is for commands that report no tests; a target names
1338
+ at least one of the two.
1339
+
1340
+ Direct `go test` invocations, including sequential `&&`, `||`, and `;` chains, are requested with `-json`. Go emits a
1341
+ package's `Action:start` only after its build dependencies settle; a package terminal (`pass`, `fail`, or `skip`) ends
1342
+ that execution interval. The unchanged idle bound runs while any package is executing, re-arms on test/package
1343
+ completion, and stops when none is executing. Initial linking and inter-package compilation therefore spend no test idle
1344
+ budget, while a stuck test or `TestMain` still expires after 180 s without a completion. `output`, `build-output`,
1345
+ pause/continue events, and arbitrary compiler activity are not progress. Mixed runner commands and unknown wrappers keep
1346
+ the existing spawn-based clock; Bun and Rust fixture compilation inside an active test gets no exemption.
1347
+
1348
+ Process-group timeout fixtures retain cleanup authority only until the command leader exits and every descendant closes
1349
+ its inherited lifetime FIFO. EOF is the terminal ownership event; a later `afterEach` must not signal the retired PGID
1350
+ again. Darwin can answer `EPERM` for an unreaped zombie-only group, and an ambient `ps` scan is not an ownership proof.
1351
+ Failed fixtures retain their cleanup obligation rather than suppressing signal errors.
1321
1352
 
1322
1353
  A job waiting for a CPU token is queued, not idle. A descendant whose own work waits in the host's CPU queue (a test's
1323
1354
  scratch cowshed project, say) writes `{"op":"host-wait"}` on the `BOUNDED_EXEC_CPU_POOL` it inherited and holds the
@@ -83,8 +83,8 @@ export interface CompiledCargoInput {
83
83
  }
84
84
  /**
85
85
  * Existing literal include_str!/include_bytes! files read by this package's Rust sources.
86
- * One graph owns the memo; runtime hashes use a fresh memo. Nested packages own their
87
- * sources separately. Computed paths and arbitrary build-script reads remain explicit inputs.
86
+ * One graph owns the memo; runtime hashing consumes the same discovery alongside source
87
+ * bytes. Nested packages own their sources separately. Computed paths remain explicit inputs.
88
88
  */
89
89
  export declare function compiledInFiles(root: string, cache: Map<string, CompiledCargoInput[]>): CompiledCargoInput[];
90
90
  //# sourceMappingURL=cargo-source-hash.d.ts.map
@@ -1 +1 @@
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;IACj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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;AAgDD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC,GAAG,kBAAkB,EAAE,CAU5G"}
@@ -697,6 +697,7 @@ export async function hashCargoPathInputs(manifestPath, workspaceRoot, options)
697
697
  const inputKey = (pkg, role, path) => JSON.stringify([pkg.name, pkg.version, role, path.split(sep).join('/')]);
698
698
  const directories = new Map();
699
699
  const files = new Map();
700
+ const compareInputs = (left, right) => left.key < right.key ? -1 : left.key > right.key ? 1 : left.order - right.order;
700
701
  const ancestors = new Set();
701
702
  const links = new Map();
702
703
  const packageSources = [];
@@ -704,8 +705,12 @@ export async function hashCargoPathInputs(manifestPath, workspaceRoot, options)
704
705
  // deterministic without using a consuming checkout's mount path as an input.
705
706
  const includeFile = (file, key) => {
706
707
  const prior = files.get(file);
707
- if (prior === undefined || key < prior)
708
- files.set(file, key);
708
+ if (prior !== undefined && key >= prior.key)
709
+ return undefined;
710
+ // Rekeying must retain the old Map insertion order for equal v2 identities.
711
+ const input = { file, key, order: prior?.order ?? files.size };
712
+ files.set(file, input);
713
+ return input;
709
714
  };
710
715
  const packages = [...cargo.local].sort((left, right) => left.name < right.name
711
716
  ? -1
@@ -782,14 +787,21 @@ export async function hashCargoPathInputs(manifestPath, workspaceRoot, options)
782
787
  }
783
788
  for (const [directory, owner] of directories)
784
789
  await walk(directory, owner, '');
785
- const compiledCache = new Map();
790
+ const scans = new Map();
791
+ const groups = new Map();
786
792
  for (const [directory, owner] of directories) {
787
- for (const input of compiledInFiles(directory, compiledCache)) {
788
- if (!ignored(input.file)) {
789
- includeFile(await realpath(input.file), inputKey(owner, 'include', relative(directory, input.source) + '\0' + input.literal));
790
- }
791
- }
793
+ const scan = { directory, owner, sources: [...compiledSourceFiles(directory)], found: new Map() };
794
+ for (const source of scan.sources)
795
+ scans.set(source, scan);
796
+ // Equal package identities can interleave, so their discovery shares one boundary.
797
+ const prefix = JSON.stringify([owner.name, owner.version]).slice(0, -1) + ',';
798
+ const group = groups.get(prefix);
799
+ if (group === undefined)
800
+ groups.set(prefix, [scan]);
801
+ else
802
+ group.push(scan);
792
803
  }
804
+ const scheduled = [...files.values()].sort(compareInputs);
793
805
  const hash = createHash('sha256');
794
806
  hash.update('cargo-path-inputs-v2\0');
795
807
  for (const { key, target } of [...links.values()].sort((left, right) => left.key < right.key ? -1 : left.key > right.key ? 1 : 0)) {
@@ -798,14 +810,54 @@ export async function hashCargoPathInputs(manifestPath, workspaceRoot, options)
798
810
  hash.update(target);
799
811
  hash.update('\0');
800
812
  }
801
- for (const [file, key] of [...files].sort((left, right) => (left[1] < right[1] ? -1 : left[1] > right[1] ? 1 : 0))) {
802
- const bytes = await readFile(file);
803
- hash.update(key);
813
+ async function consume(input) {
814
+ if (files.get(input.file) !== input)
815
+ return;
816
+ const bytes = await readFile(input.file);
817
+ const scan = scans.get(input.file);
818
+ if (scan !== undefined) {
819
+ scans.delete(input.file);
820
+ collectCompiledInputs(input.file, bytes.toString('utf8'), scan.found);
821
+ }
822
+ hash.update(input.key);
804
823
  hash.update('\0');
805
824
  hash.update(String(bytes.length));
806
825
  hash.update('\0');
807
826
  hash.update(bytes);
808
827
  }
828
+ let next = 0;
829
+ for (const [prefix, group] of [...groups].sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))) {
830
+ // All ordinary sources have a file identity before this package's include identities.
831
+ // Earlier includes may already have consumed a later package's source; only its
832
+ // discovered references survive that boundary, never the source buffer.
833
+ const boundary = prefix + '"include",';
834
+ while (next < scheduled.length && scheduled[next].key < boundary)
835
+ await consume(scheduled[next++]);
836
+ const included = [];
837
+ for (const scan of group) {
838
+ for (const source of scan.sources) {
839
+ if (!scans.delete(source))
840
+ continue;
841
+ // Discovery also visits ignored sources. They have no scheduled identity;
842
+ // if an include alias later names one, preserve the old read-then-hash path.
843
+ collectCompiledInputs(source, readFileSync(source, 'utf8'), scan.found);
844
+ }
845
+ for (const input of [...scan.found.values()].sort((left, right) => left.file < right.file ? -1 : left.file > right.file ? 1 : 0)) {
846
+ if (ignored(input.file))
847
+ continue;
848
+ const accepted = includeFile(await realpath(input.file), inputKey(scan.owner, 'include', relative(scan.directory, input.source) + '\0' + input.literal));
849
+ if (accepted !== undefined)
850
+ included.push(accepted);
851
+ }
852
+ scan.found.clear();
853
+ }
854
+ for (const input of included.sort(compareInputs))
855
+ await consume(input);
856
+ while (next < scheduled.length && scheduled[next].key.startsWith(prefix))
857
+ await consume(scheduled[next++]);
858
+ }
859
+ while (next < scheduled.length)
860
+ await consume(scheduled[next++]);
809
861
  return hash.digest('hex');
810
862
  }
811
863
  /**
@@ -929,16 +981,7 @@ function gitRepository(directory) {
929
981
  const INCLUDE_CLOSERS = { '(': ')', '[': ']', '{': '}' };
930
982
  const INCLUDE_STRING = /^"([^"\\\r\n]*)"$/u;
931
983
  const INCLUDE_RAW_STRING = /^r(#*)"([\s\S]*)"\1$/u;
932
- /**
933
- * Existing literal include_str!/include_bytes! files read by this package's Rust sources.
934
- * One graph owns the memo; runtime hashes use a fresh memo. Nested packages own their
935
- * sources separately. Computed paths and arbitrary build-script reads remain explicit inputs.
936
- */
937
- export function compiledInFiles(root, cache) {
938
- const cached = cache.get(root);
939
- if (cached !== undefined)
940
- return cached;
941
- const found = new Map();
984
+ function* compiledSourceFiles(root) {
942
985
  const skipped = HASH_SKIPPED_DIRECTORIES;
943
986
  const scan = [root];
944
987
  while (scan.length > 0) {
@@ -952,34 +995,51 @@ export function compiledInFiles(root, cache) {
952
995
  scan.push(child);
953
996
  }
954
997
  else if (entry.isFile() && entry.name.endsWith('.rs')) {
955
- const text = readFileSync(child, 'utf8');
956
- if (!text.includes('include_'))
957
- continue;
958
- const tokens = rustTokens(text);
959
- for (let index = 0; index < tokens.length; index += 1) {
960
- if (tokens[index]?.text !== 'include_str' && tokens[index]?.text !== 'include_bytes')
961
- continue;
962
- if (tokens[index + 1]?.text !== '!')
963
- continue;
964
- const closing = INCLUDE_CLOSERS[tokens[index + 2]?.text ?? ''];
965
- const end = tokens[index + 4]?.text === ',' ? index + 5 : index + 4;
966
- if (closing === undefined || tokens[end]?.text !== closing)
967
- continue;
968
- const literal = tokens[index + 3]?.text ?? '';
969
- const path = INCLUDE_STRING.exec(literal)?.[1] ?? INCLUDE_RAW_STRING.exec(literal)?.[2];
970
- if (path === undefined || path === '')
971
- continue;
972
- const file = resolve(current, path);
973
- if (statSync(file, { throwIfNoEntry: false })?.isFile()) {
974
- const prior = found.get(file);
975
- if (prior === undefined || child < prior.source || (child === prior.source && path < prior.literal)) {
976
- found.set(file, { file, source: child, literal: path });
977
- }
978
- }
979
- }
998
+ yield child;
999
+ }
1000
+ }
1001
+ }
1002
+ }
1003
+ function collectCompiledInputs(source, text, found) {
1004
+ if (!text.includes('include_'))
1005
+ return;
1006
+ const tokens = rustTokens(text);
1007
+ for (let index = 0; index < tokens.length; index += 1) {
1008
+ if (tokens[index]?.text !== 'include_str' && tokens[index]?.text !== 'include_bytes')
1009
+ continue;
1010
+ if (tokens[index + 1]?.text !== '!')
1011
+ continue;
1012
+ const closing = INCLUDE_CLOSERS[tokens[index + 2]?.text ?? ''];
1013
+ const end = tokens[index + 4]?.text === ',' ? index + 5 : index + 4;
1014
+ if (closing === undefined || tokens[end]?.text !== closing)
1015
+ continue;
1016
+ // Own the spelling before matching: captures (and RegExp's last-match state)
1017
+ // must reference path-sized storage, not a view into the decoded source.
1018
+ const literal = Buffer.from(tokens[index + 3]?.text ?? '', 'utf8').toString('utf8');
1019
+ const path = INCLUDE_STRING.exec(literal)?.[1] ?? INCLUDE_RAW_STRING.exec(literal)?.[2];
1020
+ if (path === undefined || path === '')
1021
+ continue;
1022
+ const file = resolve(dirname(source), path);
1023
+ if (statSync(file, { throwIfNoEntry: false })?.isFile()) {
1024
+ const prior = found.get(file);
1025
+ if (prior === undefined || source < prior.source || (source === prior.source && path < prior.literal)) {
1026
+ found.set(file, { file, source, literal: path });
980
1027
  }
981
1028
  }
982
1029
  }
1030
+ }
1031
+ /**
1032
+ * Existing literal include_str!/include_bytes! files read by this package's Rust sources.
1033
+ * One graph owns the memo; runtime hashing consumes the same discovery alongside source
1034
+ * bytes. Nested packages own their sources separately. Computed paths remain explicit inputs.
1035
+ */
1036
+ export function compiledInFiles(root, cache) {
1037
+ const cached = cache.get(root);
1038
+ if (cached !== undefined)
1039
+ return cached;
1040
+ const found = new Map();
1041
+ for (const source of compiledSourceFiles(root))
1042
+ collectCompiledInputs(source, readFileSync(source, 'utf8'), found);
983
1043
  const files = [...found.values()].sort((left, right) => left.file < right.file ? -1 : left.file > right.file ? 1 : 0);
984
1044
  cache.set(root, files);
985
1045
  return files;
@@ -62,6 +62,19 @@ type WorkerFlagKind = 'stryker' | 'vitest' | 'go-test';
62
62
  * configured counts may only lower them.
63
63
  */
64
64
  export declare function runnerDemand(command: string, declared: number | undefined, cores: number, inherited: Readonly<NodeJS.ProcessEnv>, configured?: Readonly<NodeJS.ProcessEnv>): Demand;
65
+ /**
66
+ * Where `invocation` ends in `command`, and where its own arguments end: the next `;`, `&`, `|`, `(` or `)` outside
67
+ * quotes and `$(…)`.
68
+ */
69
+ export declare function invocationSpan(command: string, invocation: RegExp): {
70
+ end: number;
71
+ argsEnd: number;
72
+ };
73
+ /**
74
+ * `command` with every `flag` in `invocation`'s own arguments replaced by `value`; when it names none, `value` is
75
+ * added right after the invocation if `add` says so.
76
+ */
77
+ export declare function withInvocationFlag(command: string, invocation: RegExp, flag: RegExp, value: string, add: boolean): string;
65
78
  /**
66
79
  * Size the runner to the lesser of its bounded demand and grant, keeping the test-thread ceilings. Rewrite named flags
67
80
  * so they cannot outrank that size. `CPU_TOKENS_ENV` still reports the actual held grant.
@@ -1 +1 @@
1
- {"version":3,"file":"cpu-tokens.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/cpu-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnF;;;;;;;;;;GAUG;AAEH,kGAAkG;AAClG,MAAM,MAAM,UAAU;AACpB,mFAAmF;AACjF,SAAS;AACX,mDAAmD;GACjD,cAAc;AAChB,2EAA2E;GACzE,cAAc;AAChB,yHAAyH;GACvH,eAAe;AACjB,kGAAkG;GAChG,OAAO;AACT,2FAA2F;GACzF,SAAS,CAAC;AAEd;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,GACd;IAAE,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,kBAAkB,CAAA;CAAE,GAC5E;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,GAAG,eAAe,GAAG,SAAS,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvF,kGAAkG;AAClG,eAAO,MAAM,cAAc,4BAA4B,CAAC;AAkBxD,KAAK,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AA+CvD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,QAAQ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ST, GO_TEST, NEXTEST_RUN } from './verdict.js';
3
3
  /** Every budgeted command learns its grant here, so a script that starts a runner can size it. */
4
4
  export const CPU_TOKENS_ENV = 'BOUNDED_EXEC_CPU_TOKENS';
5
5
  const CARGO_BUILD = /(?<=^|[\s;&|()])(?:cargo(?:\s+-\S+)*\s+(?:build|test|check|clippy|rustc|doc|run|nextest\s+archive)|napi\s+build)(?=\s|$)/;
@@ -36,7 +36,7 @@ const WORKER_FLAGS = {
36
36
  },
37
37
  /** `go test -p`: packages built and tested at once, `GOMAXPROCS` by default, normally one per core. */
38
38
  'go-test': {
39
- invocation: /(?<=^|[\s;&|()])go\s+test(?=\s|$)/,
39
+ invocation: GO_TEST,
40
40
  flag: new RegExp(String.raw `(?<![\w-])-p(?:=|\s+)${WORD}`, 'g'),
41
41
  sized: (count) => `-p=${count}`,
42
42
  ownDefault: (cores, env) => parseInheritedTokens(env.GOMAXPROCS) ?? cores,
@@ -148,7 +148,7 @@ function namedCounts(text, flag) {
148
148
  * Where `invocation` ends in `command`, and where its own arguments end: the next `;`, `&`, `|`, `(` or `)` outside
149
149
  * quotes and `$(…)`.
150
150
  */
151
- function invocationSpan(command, invocation) {
151
+ export function invocationSpan(command, invocation) {
152
152
  const found = invocation.exec(command);
153
153
  const end = found === null ? command.length : found.index + found[0].length;
154
154
  let quote = null;
@@ -179,13 +179,13 @@ function invocationArgs(command, invocation) {
179
179
  return command.slice(end, argsEnd);
180
180
  }
181
181
  /**
182
- * `command` with every `flag` in `invocation`'s own arguments replaced by `sized`; when it names none, `sized` is
182
+ * `command` with every `flag` in `invocation`'s own arguments replaced by `value`; when it names none, `value` is
183
183
  * added right after the invocation if `add` says so.
184
184
  */
185
- function withSizedFlag(command, invocation, flag, sized, add) {
185
+ export function withInvocationFlag(command, invocation, flag, value, add) {
186
186
  const { end, argsEnd } = invocationSpan(command, invocation);
187
187
  const args = command.slice(end, argsEnd);
188
- const sizedArgs = args.search(flag) === -1 && add ? ` ${sized}${args}` : args.replace(flag, sized);
188
+ const sizedArgs = args.search(flag) === -1 && add ? ` ${value}${args}` : args.replace(flag, value);
189
189
  return `${command.slice(0, end)}${sizedArgs}${command.slice(argsEnd)}`;
190
190
  }
191
191
  /**
@@ -226,7 +226,7 @@ export function sizeRunner(demand, command, tokens) {
226
226
  case 'go-test': {
227
227
  const runner = WORKER_FLAGS[demand.kind];
228
228
  return {
229
- command: withSizedFlag(command, runner.invocation, runner.flag, runner.sized(runnerCount), true),
229
+ command: withInvocationFlag(command, runner.invocation, runner.flag, runner.sized(runnerCount), true),
230
230
  env: { [CPU_TOKENS_ENV]: held },
231
231
  };
232
232
  }
@@ -235,9 +235,9 @@ export function sizeRunner(demand, command, tokens) {
235
235
  // `--jobs` is lowered only where it was set: cargo-mutants refuses it beside `--in-place`.
236
236
  const jobs = Math.min(demand.jobs, runnerCount);
237
237
  const share = String(Math.max(1, Math.floor(runnerCount / jobs)));
238
- const tasks = withSizedFlag(command, CARGO_MUTANTS, JOBSERVER_TASKS, `--jobserver-tasks=${count}`, true);
238
+ const tasks = withInvocationFlag(command, CARGO_MUTANTS, JOBSERVER_TASKS, `--jobserver-tasks=${count}`, true);
239
239
  return {
240
- command: withSizedFlag(tasks, CARGO_MUTANTS, MUTANTS_JOBS, `--jobs=${jobs}`, false),
240
+ command: withInvocationFlag(tasks, CARGO_MUTANTS, MUTANTS_JOBS, `--jobs=${jobs}`, false),
241
241
  env: {
242
242
  [CPU_TOKENS_ENV]: held,
243
243
  ...(demand.jobs > 1 ? { CARGO_MUTANTS_JOBS: String(jobs) } : {}),
@@ -1 +1 @@
1
- {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/executor.ts"],"names":[],"mappings":"AAMA,OAAO,EAKL,KAAK,gBAAgB,EAGtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,KAAK,SAAS,EAKf,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,sBAAsB,EAAmB,MAAM,uBAAuB,CAAC;A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AM,GAAG,SAAS,CAiBpB;AAED,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,iBAAiB,CAAC,CAE5B;AAED,mGAAmG;AACnG,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CA2B5B;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,kBAAkB,CAiBxE;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,iBAAiB,EACzB,UAAU,EAAE,UAAU,GAAG,IAAI,EAC7B,MAAM,EAAE,SAAS,GAAG,IAAI,EACxB,SAAS,GAAE,gBAAgB,GAAG,IAAW,EACzC,kBAAkB,GAAE,OAAO,sBAA+C,GACzE,OAAO,CAAC,iBAAiB,CAAC,CA6jB5B;AAED,wBAAgB,uBAAuB,IAAI,iBAAiB,CAM3D"}
@@ -343,7 +343,7 @@ export async function runBoundedExec(options, context, killer, tempVolume, budge
343
343
  return refuse(`cowshed: could not start the command: ${error instanceof Error ? error.message : String(error)}\n`);
344
344
  }
345
345
  // Progress is a finished test, not output: a runner's SLOW warnings and a hung test's heartbeat keep printing.
346
- const progress = createRunProgress();
346
+ const progress = createRunProgress(command);
347
347
  // A write that found no space is said once, in the output, by whatever made it; the volume is read when it is said,
348
348
  // since the writer usually removes what it half-wrote before it exits and the volume no longer looks full by then.
349
349
  const noSpace = createNoSpaceWatch();
@@ -405,7 +405,7 @@ export async function runBoundedExec(options, context, killer, tempVolume, budge
405
405
  idleTimer = setTimeout(() => expire({ kind: 'idle', limitMs, tests: progress.inFlight() }, queuedMs), leftMs);
406
406
  };
407
407
  const armIdleTimer = () => {
408
- if (idleTimeoutMs === undefined || state.settled || state.expiry !== null) {
408
+ if (idleTimeoutMs === undefined || state.settled || state.expiry !== null || !progress.isTesting()) {
409
409
  return;
410
410
  }
411
411
  idleLeftMs = idleTimeoutMs;
@@ -438,6 +438,10 @@ export async function runBoundedExec(options, context, killer, tempVolume, budge
438
438
  const waitedMs = Date.now() - queuedSinceMs;
439
439
  queuedMs += waitedMs;
440
440
  queuedSinceMs = null;
441
+ if (!progress.isTesting()) {
442
+ appendStderr(`bounded-exec: host CPU wait ended after ${waitedMs}ms; no test runner is active\n`);
443
+ return;
444
+ }
441
445
  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`);
442
446
  scheduleIdle(idleTimeoutMs, idleLeftMs);
443
447
  },
@@ -445,10 +449,21 @@ export async function runBoundedExec(options, context, killer, tempVolume, budge
445
449
  // Only the CHILD's own output is read for progress. The diagnostics below go
446
450
  // through appendStderr as well, and re-arming on those would let a teardown
447
451
  // message extend the very bound that just fired.
452
+ const scanProgress = (stream, text) => {
453
+ const wasTesting = progress.isTesting();
454
+ const finished = progress.scan(stream, text);
455
+ if (!progress.isTesting()) {
456
+ clearTimeout(idleTimer);
457
+ cancelCapture();
458
+ idleCapture = undefined;
459
+ }
460
+ else if (finished || !wasTesting) {
461
+ armIdleTimer();
462
+ }
463
+ };
448
464
  child.stdout?.on('data', (chunk) => {
449
465
  const text = chunk.toString();
450
- if (progress.scan('stdout', text))
451
- armIdleTimer();
466
+ scanProgress('stdout', text);
452
467
  const said = noSpace.scan('stdout', text);
453
468
  if (said !== null)
454
469
  state.noSpace = sight(said);
@@ -456,8 +471,7 @@ export async function runBoundedExec(options, context, killer, tempVolume, budge
456
471
  });
457
472
  child.stderr?.on('data', (chunk) => {
458
473
  const text = chunk.toString();
459
- if (progress.scan('stderr', text))
460
- armIdleTimer();
474
+ scanProgress('stderr', text);
461
475
  const said = noSpace.scan('stderr', text);
462
476
  if (said !== null)
463
477
  state.noSpace = sight(said);
@@ -15,17 +15,22 @@
15
15
  * - bun: a line of dots, one per test finished (`--dots`, which `withProgressReport` asks for: bun prints nothing
16
16
  * per passing test when it believes an agent runs it), or a `(pass)`/`(fail)`/`(skip)`/`(todo)` line. bun names
17
17
  * no test before it finishes, so a bun run names nothing in flight.
18
+ * - go: structured `go test -json` package `start` follows the package's build dependencies; package `pass`,
19
+ * `fail`, or `skip` ends that execution interval. Test terminals re-arm the bound, but `output` and
20
+ * `build-output` never do. Initial and inter-package builds are outside an active test interval.
18
21
  *
19
- * A command that reports no tests makes progress only by exiting.
22
+ * A command without a recognised execution lifecycle remains bounded from spawn.
20
23
  */
21
24
  export interface RunProgress {
22
- /** One chunk of one of the command's output streams; true when it reports at least one finished test. */
25
+ /** One chunk of one of the command's output streams; true when it reports a finished test or Go package. */
23
26
  scan(stream: OutputStream, chunk: string): boolean;
24
27
  /** The tests the runner reported running and has not reported finished, in the order it first named them. */
25
28
  inFlight(): string[];
29
+ /** Whether test idle time is currently chargeable; unknown runner lifecycles stay chargeable. */
30
+ isTesting(): boolean;
26
31
  }
27
32
  export type OutputStream = 'stdout' | 'stderr';
28
- export declare function createRunProgress(): RunProgress;
33
+ export declare function createRunProgress(command?: string): RunProgress;
29
34
  /**
30
35
  * `command` with its one `bun test` asked for a line of dots, one per finished test: the only per-test report bun
31
36
  * prints whoever runs it. A command that runs no bun, more than one runner, or already chose bun's dots is returned
@@ -1 +1 @@
1
- {"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/progress.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,WAAW;IAC1B,yGAAyG;IACzG,IAAI,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IACnD,6GAA6G;IAC7G,QAAQ,IAAI,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAsB/C,wBAAgB,iBAAiB,IAAI,WAAW,CAoD/C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAO1D"}
1
+ {"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/progress.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,WAAW;IAC1B,4GAA4G;IAC5G,IAAI,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IACnD,6GAA6G;IAC7G,QAAQ,IAAI,MAAM,EAAE,CAAC;IACrB,iGAAiG;IACjG,SAAS,IAAI,OAAO,CAAC;CACtB;AAED,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAqD/C,wBAAgB,iBAAiB,CAAC,OAAO,SAAK,GAAG,WAAW,CAqF3D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAmB1D"}