@smoothbricks/nx-plugin 0.6.2 → 0.6.3-0

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 (97) hide show
  1. package/README.md +281 -73
  2. package/dist/.build-inputs.json +20 -14
  3. package/dist/bin/smoo-nx-publish.d.ts +3 -0
  4. package/dist/bin/smoo-nx-publish.d.ts.map +1 -0
  5. package/dist/bin/smoo-nx-publish.js +3 -0
  6. package/dist/cargo-retention-hook.d.ts +6 -2
  7. package/dist/cargo-retention-hook.d.ts.map +1 -1
  8. package/dist/cargo-retention-hook.js +13 -7
  9. package/dist/eslint-file-set.d.ts +4 -1
  10. package/dist/eslint-file-set.d.ts.map +1 -1
  11. package/dist/eslint-sources.d.ts +25 -0
  12. package/dist/eslint-sources.d.ts.map +1 -0
  13. package/dist/eslint-sources.js +99 -0
  14. package/dist/executors/all-verdicts/executor.d.ts +2 -1
  15. package/dist/executors/all-verdicts/executor.d.ts.map +1 -1
  16. package/dist/executors/all-verdicts/executor.js +48 -2
  17. package/dist/executors/all-verdicts/schema.d.ts +13 -0
  18. package/dist/executors/all-verdicts/schema.d.ts.map +1 -1
  19. package/dist/executors/all-verdicts/schema.js +7 -0
  20. package/dist/executors/bounded-exec/bounds.d.ts +57 -8
  21. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
  22. package/dist/executors/bounded-exec/bounds.js +100 -11
  23. package/dist/executors/bounded-exec/executor.d.ts +2 -1
  24. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  25. package/dist/executors/bounded-exec/executor.js +270 -27
  26. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +2 -0
  27. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  28. package/dist/executors/bounded-exec/hang-diagnostics.js +2 -2
  29. package/dist/executors/bounded-exec/mbx-pool.d.ts +20 -3
  30. package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
  31. package/dist/executors/bounded-exec/mbx-pool.js +84 -4
  32. package/dist/executors/bounded-exec/mbx-queue.d.ts +30 -0
  33. package/dist/executors/bounded-exec/mbx-queue.d.ts.map +1 -0
  34. package/dist/executors/bounded-exec/mbx-queue.js +229 -0
  35. package/dist/executors/bounded-exec/progress.d.ts +9 -2
  36. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  37. package/dist/executors/bounded-exec/progress.js +148 -22
  38. package/dist/executors/bounded-exec/test-result-writer.d.ts +30 -0
  39. package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -0
  40. package/dist/executors/bounded-exec/test-result-writer.js +126 -0
  41. package/dist/executors/bounded-exec/test-results.d.ts +33 -0
  42. package/dist/executors/bounded-exec/test-results.d.ts.map +1 -0
  43. package/dist/executors/bounded-exec/test-results.js +33 -0
  44. package/dist/executors/bounded-exec/verdict.d.ts +20 -2
  45. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  46. package/dist/executors/bounded-exec/verdict.js +102 -4
  47. package/dist/index.d.ts +3 -2
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +67 -65
  50. package/dist/nx-publish.d.ts +24 -0
  51. package/dist/nx-publish.d.ts.map +1 -0
  52. package/dist/nx-publish.js +150 -0
  53. package/dist/runtime-input-policy.d.ts +14 -0
  54. package/dist/runtime-input-policy.d.ts.map +1 -1
  55. package/dist/runtime-input-policy.js +1 -1
  56. package/dist/tool-bins.d.ts +6 -8
  57. package/dist/tool-bins.d.ts.map +1 -1
  58. package/dist/tool-bins.js +7 -5
  59. package/dist/workspace-index.d.ts +7 -0
  60. package/dist/workspace-index.d.ts.map +1 -1
  61. package/dist/workspace-index.js +11 -0
  62. package/executors.json +1 -1
  63. package/managed/raw/patches/ttsc@0.34.1.patch +75 -0
  64. package/managed/raw/tooling/devenv +1 -2
  65. package/managed/raw/tooling/direnv/developer-links.ts +3 -0
  66. package/managed/raw/tooling/direnv/devenv.smoo.nix +34 -15
  67. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -10
  68. package/managed/raw/tooling/direnv/setup-environment.ts +35 -20
  69. package/managed/raw/tooling/direnv/ttsc-env.sh +8 -6
  70. package/managed/templates/github/actions/cache-node-modules/action.yml +1 -1
  71. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +12 -11
  72. package/package.json +223 -7
  73. package/runtime/nx-publish/cache_adapter.js +45 -0
  74. package/runtime/nx-publish/nx_publish.js +60 -0
  75. package/runtime-input.sh +12 -3
  76. package/src/bin/smoo-nx-publish.ts +4 -0
  77. package/src/cargo-retention-hook.ts +16 -10
  78. package/src/eslint-file-set.ts +4 -1
  79. package/src/eslint-sources.ts +134 -0
  80. package/src/executors/all-verdicts/executor.ts +58 -3
  81. package/src/executors/all-verdicts/schema.json +4 -0
  82. package/src/executors/all-verdicts/schema.ts +14 -0
  83. package/src/executors/bounded-exec/bounds.ts +132 -15
  84. package/src/executors/bounded-exec/executor.ts +303 -27
  85. package/src/executors/bounded-exec/hang-diagnostics.ts +3 -2
  86. package/src/executors/bounded-exec/mbx-pool.ts +82 -5
  87. package/src/executors/bounded-exec/mbx-queue.ts +170 -0
  88. package/src/executors/bounded-exec/progress.ts +168 -15
  89. package/src/executors/bounded-exec/test-result-writer.ts +152 -0
  90. package/src/executors/bounded-exec/test-results.ts +39 -0
  91. package/src/executors/bounded-exec/verdict.ts +108 -5
  92. package/src/index.ts +74 -70
  93. package/src/nx-publish.ts +157 -0
  94. package/src/runtime-input-policy.ts +1 -1
  95. package/src/tool-bins.ts +13 -9
  96. package/src/workspace-index.ts +12 -0
  97. package/test-timings.json +8 -3
@@ -15,8 +15,12 @@ export declare const CARGO_PRODUCER_METADATA: {
15
15
  export declare function mbxManagesTargets(environment: Readonly<NodeJS.ProcessEnv>): boolean;
16
16
  /**
17
17
  * After a run that executed a Cargo producer task ({@link CARGO_PRODUCER_METADATA}), check whether
18
- * each Cargo workspace is due for its daily maintenance. A successful receipt schedules only;
19
- * every due pass reads the current graph under Cargo's locks and is awaited by this Nx process.
18
+ * each Cargo workspace is due for its daily maintenance, and start each due pass in a process of its own
19
+ * (`startRetentionPass`). Nx awaits this hook, inside its daemon when one serves the run, so the pass never runs here:
20
+ * its unlinks are synchronous, and one freeing a large trash on a loaded volume held a daemon, and every client waiting
21
+ * on it, for more than thirty minutes. Here only the gate answers (not due, busy, refused); the started pass reads the
22
+ * current graph under Cargo's locks and records its outcome in the target's receipt, and neither this process nor its
23
+ * exit waits on it. A successful receipt schedules only.
20
24
  * Maintenance never fails the run it follows: every outcome, a refused or busy pass included, is only reported. In an
21
25
  * mbx project ({@link mbxManagesTargets}) it does nothing.
22
26
  */
@@ -1 +1 @@
1
- {"version":3,"file":"cargo-retention-hook.d.ts","sourceRoot":"","sources":["../src/cargo-retention-hook.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAuB5F;;;;GAIG;AACH,eAAO,MAAM,uBAAuB;aAAK,aAAa;CAAiB,CAAC;AAExE;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,OAAO,CAEnF;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8C7G"}
1
+ {"version":3,"file":"cargo-retention-hook.d.ts","sourceRoot":"","sources":["../src/cargo-retention-hook.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAuB5F;;;;GAIG;AACH,eAAO,MAAM,uBAAuB;aAAK,aAAa;CAAiB,CAAC;AAExE;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,OAAO,CAEnF;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+C7G"}
@@ -1,5 +1,6 @@
1
1
  import { join, relative } from 'node:path';
2
- import { describeRetention, describeRetentionError, refusedAnywhere, retainCargoWorkspace, } from '@smoothbricks/cargo-retain';
2
+ import { describeRetentionError, describeRetentionStart, refusedAnywhere, startRetentionPass, } from '@smoothbricks/cargo-retain';
3
+ import { launchNodeCli } from '@smoothbricks/cargo-retain/launch-node';
3
4
  import { nodeLocks } from '@smoothbricks/cargo-retain/locks-node';
4
5
  import { logger, readCachedProjectGraph } from 'nx/src/devkit-exports.js';
5
6
  function describeCause(error) {
@@ -35,8 +36,12 @@ export function mbxManagesTargets(environment) {
35
36
  }
36
37
  /**
37
38
  * After a run that executed a Cargo producer task ({@link CARGO_PRODUCER_METADATA}), check whether
38
- * each Cargo workspace is due for its daily maintenance. A successful receipt schedules only;
39
- * every due pass reads the current graph under Cargo's locks and is awaited by this Nx process.
39
+ * each Cargo workspace is due for its daily maintenance, and start each due pass in a process of its own
40
+ * (`startRetentionPass`). Nx awaits this hook, inside its daemon when one serves the run, so the pass never runs here:
41
+ * its unlinks are synchronous, and one freeing a large trash on a loaded volume held a daemon, and every client waiting
42
+ * on it, for more than thirty minutes. Here only the gate answers (not due, busy, refused); the started pass reads the
43
+ * current graph under Cargo's locks and records its outcome in the target's receipt, and neither this process nor its
44
+ * exit waits on it. A successful receipt schedules only.
40
45
  * Maintenance never fails the run it follows: every outcome, a refused or busy pass included, is only reported. In an
41
46
  * mbx project ({@link mbxManagesTargets}) it does nothing.
42
47
  */
@@ -69,7 +74,7 @@ export async function postTasksExecution(_options, context) {
69
74
  const cpu = process.cpuUsage();
70
75
  let result;
71
76
  try {
72
- result = await retainCargoWorkspace(root, { apply: true, automatic: true, now: Date.now() }, nodeLocks);
77
+ result = await startRetentionPass(root, Date.now(), nodeLocks, launchNodeCli);
73
78
  }
74
79
  catch (error) {
75
80
  // Maintenance never fails the run it follows: say what escaped, then go on to the next workspace.
@@ -86,9 +91,10 @@ export async function postTasksExecution(_options, context) {
86
91
  logger.warn(`Cargo retention for ${root}: ${describeRetentionError(result.error)}`);
87
92
  continue;
88
93
  }
89
- done.push(result.value.workspaceRoot);
90
- const line = describeRetention(result.value);
91
- if (refusedAnywhere(result.value))
94
+ const start = result.value;
95
+ done.push(start.kind === 'answered' ? start.report.workspaceRoot : start.workspaceRoot);
96
+ const line = describeRetentionStart(start);
97
+ if (start.kind === 'answered' && refusedAnywhere(start.report))
92
98
  logger.warn(line);
93
99
  else
94
100
  logger.info(line);
@@ -1,4 +1,7 @@
1
- /** The exact command and sources source-aware ESLint inference retains for cache inspectors. */
1
+ /**
2
+ * What source-aware ESLint inference retains for cache inspectors: the command, which names no file, and the sources
3
+ * the graph that wrote it resolved. The run reads the sources it lints when it starts.
4
+ */
2
5
  export interface EslintFileSet {
3
6
  readonly command: string;
4
7
  readonly files: readonly string[];
@@ -1 +1 @@
1
- {"version":3,"file":"eslint-file-set.d.ts","sourceRoot":"","sources":["../src/eslint-file-set.ts"],"names":[],"mappings":"AAEA,gGAAgG;AAChG,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED,eAAO,MAAM,eAAe,4CAAsC,CAAC"}
1
+ {"version":3,"file":"eslint-file-set.d.ts","sourceRoot":"","sources":["../src/eslint-file-set.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED,eAAO,MAAM,eAAe,4CAAsC,CAAC"}
@@ -0,0 +1,25 @@
1
+ /** Every JavaScript and TypeScript module kind ESLint is handed, as one glob. */
2
+ export declare const ESLINT_SOURCES_GLOB = "**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}";
3
+ /** What ESLint lints for one project, and the lint inputs that key its verdict beyond the project's own files. */
4
+ export interface EslintSources {
5
+ /** The files ESLint is handed, workspace-relative and sorted. */
6
+ readonly files: readonly string[];
7
+ /**
8
+ * The test declaration, then a glob for each directory its include patterns walk and each other program file by
9
+ * name: a file the program gains later is keyed without the graph naming it.
10
+ */
11
+ readonly inputs: readonly string[];
12
+ }
13
+ /**
14
+ * What ESLint lints for `projectRoot`, out of `indexed`, the JavaScript and TypeScript modules of an Nx workspace file
15
+ * index (.gitignore and .nxignore applied): its `src` files, and the files its `tsconfig.test.json` declares wherever
16
+ * they live. Only an indexed module counts: an ignored one is build output a fresh checkout lacks, and a JSON file is
17
+ * not ESLint's. Which index `indexed` comes from is the caller's: the graph's to describe a project, the filesystem's
18
+ * now to run ESLint on it.
19
+ */
20
+ export declare function eslintSources(workspaceRoot: string, projectRoot: string, indexed: ReadonlySet<string>): EslintSources;
21
+ /** What ESLint lints for `projectRoot` as the filesystem holds it now, through a fresh workspace file index. */
22
+ export declare function freshEslintSources(workspaceRoot: string, projectRoot: string): EslintSources;
23
+ /** `command` with each {@link ESLINT_SOURCES_TOKEN} replaced by the shell words of `files`. */
24
+ export declare function expandEslintSources(command: string, files: readonly string[]): string;
25
+ //# sourceMappingURL=eslint-sources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eslint-sources.d.ts","sourceRoot":"","sources":["../src/eslint-sources.ts"],"names":[],"mappings":"AAiBA,iFAAiF;AACjF,eAAO,MAAM,mBAAmB,yCAAyB,CAAC;AAK1D,kHAAkH;AAClH,MAAM,WAAW,aAAa;IAC5B,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAmCD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,aAAa,CAgDrH;AAED,gHAAgH;AAChH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa,CAE5F;AAED,+FAA+F;AAC/F,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAGrF"}
@@ -0,0 +1,99 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { dirname, isAbsolute, join, posix, relative, sep } from 'node:path';
3
+ import { parseJsonConfigFileContent, readConfigFile, sys as typescriptSys, WatchDirectoryFlags, } from 'typescript';
4
+ import { ESLINT_SOURCES_TOKEN } from './executors/all-verdicts/schema.js';
5
+ import { shellWord } from './runtime-input.js';
6
+ import { isNonSourceDirectory } from './source-directories.js';
7
+ import { freshIndexedFiles } from './workspace-index.js';
8
+ /** The module kinds ESLint is handed. */
9
+ const SOURCE_KINDS = '{js,jsx,cjs,mjs,ts,tsx,cts,mts}';
10
+ /** Every JavaScript and TypeScript module kind ESLint is handed, as one glob. */
11
+ export const ESLINT_SOURCES_GLOB = `**/*.${SOURCE_KINDS}`;
12
+ /** TypeScript's code for a declaration that selects no file: a test program of none, not a broken one. */
13
+ const NO_INPUTS_FOUND = 18003;
14
+ /**
15
+ * Read a tsconfig with this plugin's own TypeScript. `@nx/js`'s readTsConfig does an
16
+ * undeclared `require('typescript')` resolved from its own location: where that lands on the
17
+ * TypeScript 7 native package (whose entry exports only its version), `sys` is undefined and
18
+ * graph construction dies reading `sys.readFile`. The plugin declares TypeScript 6, whose
19
+ * `sys` this uses, so the resolution is the one this package's manifest promises.
20
+ */
21
+ function readTestTsConfig(testConfig) {
22
+ const readResult = readConfigFile(testConfig, typescriptSys.readFile);
23
+ return parseJsonConfigFileContent(readResult.config, typescriptSys, dirname(testConfig));
24
+ }
25
+ /** The workspace-relative POSIX path of `absolute`, or null when it lies outside the workspace. */
26
+ function insideWorkspace(workspaceRoot, absolute) {
27
+ const path = relative(workspaceRoot, absolute).split(sep).join('/');
28
+ return path === '..' || path.startsWith('../') || isAbsolute(path) ? null : path;
29
+ }
30
+ function walks({ directory, recursive }, path) {
31
+ const within = directory === '' ? path : path.startsWith(`${directory}/`) ? path.slice(directory.length + 1) : null;
32
+ return within !== null && (recursive || !within.includes('/'));
33
+ }
34
+ function walkedInput({ directory, recursive }) {
35
+ return `{workspaceRoot}/${directory === '' ? '' : `${directory}/`}${recursive ? '**/' : ''}*.${SOURCE_KINDS}`;
36
+ }
37
+ /**
38
+ * What ESLint lints for `projectRoot`, out of `indexed`, the JavaScript and TypeScript modules of an Nx workspace file
39
+ * index (.gitignore and .nxignore applied): its `src` files, and the files its `tsconfig.test.json` declares wherever
40
+ * they live. Only an indexed module counts: an ignored one is build output a fresh checkout lacks, and a JSON file is
41
+ * not ESLint's. Which index `indexed` comes from is the caller's: the graph's to describe a project, the filesystem's
42
+ * now to run ESLint on it.
43
+ */
44
+ export function eslintSources(workspaceRoot, projectRoot, indexed) {
45
+ const files = new Set();
46
+ const sourcePrefix = projectRoot === '.' ? 'src/' : `${posix.normalize(projectRoot)}/src/`;
47
+ for (const path of indexed) {
48
+ if (path.startsWith(sourcePrefix) &&
49
+ !path.slice(sourcePrefix.length).split('/').slice(0, -1).some(isNonSourceDirectory)) {
50
+ files.add(path);
51
+ }
52
+ }
53
+ const inputs = [];
54
+ const testConfig = join(workspaceRoot, projectRoot, 'tsconfig.test.json');
55
+ if (existsSync(testConfig)) {
56
+ // A test program can live anywhere the declaration selects, not just src.
57
+ // Use the compiler's file set and the existing declaration-chain hasher,
58
+ // so inherited includes and files outside this project keep their keys.
59
+ const program = readTestTsConfig(testConfig);
60
+ const errors = program.errors.filter(({ code }) => code !== NO_INPUTS_FOUND);
61
+ if (errors.length > 0) {
62
+ throw new Error(`${testConfig}: ${errors.map(({ code, messageText }) => `TS${code}: ${JSON.stringify(messageText)}`).join('; ')}`);
63
+ }
64
+ inputs.push('{projectRoot}/tsconfig.test.json');
65
+ // The directories the include patterns walk are keyed as globs, so a file added to one is keyed the moment it
66
+ // exists, and the compiler's own set of walked directories says which they are.
67
+ const walked = [];
68
+ for (const [absolute, flags] of Object.entries(program.wildcardDirectories ?? {})) {
69
+ const directory = insideWorkspace(workspaceRoot, absolute);
70
+ if (directory !== null && !directory.split('/').some(isNonSourceDirectory)) {
71
+ walked.push({ directory, recursive: (flags & WatchDirectoryFlags.Recursive) !== 0 });
72
+ }
73
+ }
74
+ inputs.push(...walked.map(walkedInput).sort());
75
+ const named = [];
76
+ for (const absolute of program.fileNames) {
77
+ const path = insideWorkspace(workspaceRoot, absolute);
78
+ if (path === null) {
79
+ throw new Error(`${testConfig}: test source ${absolute} is outside the workspace and cannot be hashed`);
80
+ }
81
+ if (!indexed.has(path) || path.split('/').some(isNonSourceDirectory))
82
+ continue;
83
+ files.add(path);
84
+ if (!walked.some((entry) => walks(entry, path)))
85
+ named.push(`{workspaceRoot}/${path}`);
86
+ }
87
+ inputs.push(...named.sort());
88
+ }
89
+ return { files: [...files].sort(), inputs: [...new Set(inputs)] };
90
+ }
91
+ /** What ESLint lints for `projectRoot` as the filesystem holds it now, through a fresh workspace file index. */
92
+ export function freshEslintSources(workspaceRoot, projectRoot) {
93
+ return eslintSources(workspaceRoot, projectRoot, new Set(freshIndexedFiles(workspaceRoot, [ESLINT_SOURCES_GLOB])));
94
+ }
95
+ /** `command` with each {@link ESLINT_SOURCES_TOKEN} replaced by the shell words of `files`. */
96
+ export function expandEslintSources(command, files) {
97
+ const words = files.map((file) => shellWord(file)).join(' ');
98
+ return command.replaceAll(ESLINT_SOURCES_TOKEN, () => words);
99
+ }
@@ -1,4 +1,4 @@
1
- import type { AllVerdictsOptions } from './schema.js';
1
+ import { type AllVerdictsOptions } from './schema.js';
2
2
  /**
3
3
  * A command's verdict. Only a command that exited reached one. A command a signal ended, one that never started and
4
4
  * one still running when the run itself was signalled are unjudged: never a pass, and never left out of the report.
@@ -26,6 +26,7 @@ export declare function verdictReport(verdicts: readonly CommandVerdict[]): stri
26
26
  * another's until a later run. Here no command ends another. Each command's output prints as one block when it closes,
27
27
  * then every command's verdict. A signal to the run ends every command's process group, reports each command still
28
28
  * running UNJUDGED, and ends the run by the same signal. The run succeeds only when every command passed.
29
+ * A command that names the ESLint sources placeholder is resolved first, and the verdicts name it as it ran.
29
30
  */
30
31
  export default function allVerdictsExecutor(options: AllVerdictsOptions, context: {
31
32
  readonly root: string;
@@ -1 +1 @@
1
- {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/all-verdicts/executor.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,OAAO,GACf;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1D,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED,6GAA6G;AAC7G,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,GAAG,OAAO,CAIzF;AAoBD,0GAA0G;AAC1G,wBAAgB,aAAa,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,CAQzE;AA6DD;;;;;;GAMG;AACH,wBAA8B,mBAAmB,CAC/C,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjC,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAsC/B"}
1
+ {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/all-verdicts/executor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,kBAAkB,EAAwB,MAAM,aAAa,CAAC;AAE5E;;;GAGG;AACH,MAAM,MAAM,OAAO,GACf;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1D,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED,6GAA6G;AAC7G,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,GAAG,OAAO,CAIzF;AAoBD,0GAA0G;AAC1G,wBAAgB,aAAa,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,CAQzE;AA4FD;;;;;;;GAOG;AACH,wBAA8B,mBAAmB,CAC/C,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjC,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CA6D/B"}
@@ -1,5 +1,6 @@
1
1
  import { spawn } from 'node:child_process';
2
2
  import { resolve } from 'node:path';
3
+ import { ESLINT_SOURCES_TOKEN } from './schema.js';
3
4
  /** The verdict of a process that closed with exit `code`, or, when `code` is null, was ended by `signal`. */
4
5
  export function closedVerdict(code, signal) {
5
6
  if (code === 0)
@@ -84,12 +85,37 @@ function judge(run, cwd) {
84
85
  child.once('close', (code, signal) => close(closedVerdict(code, signal)));
85
86
  });
86
87
  }
88
+ /**
89
+ * The commands as they run now. A command that names {@link ESLINT_SOURCES_TOKEN} gets the files ESLint is handed for
90
+ * `eslintProjectRoot` as the filesystem holds them at this moment, read through a fresh workspace file index: a graph the
91
+ * daemon serves past a deletion or an addition its watcher never reported still lints the files that exist. A project
92
+ * with none has nothing to lint, and no ESLint process starts for it.
93
+ */
94
+ async function planCommands(options, root) {
95
+ if (!options.commands.some((command) => command.includes(ESLINT_SOURCES_TOKEN))) {
96
+ return options.commands.map((command) => ({ command }));
97
+ }
98
+ const projectRoot = options.eslintProjectRoot;
99
+ if (projectRoot === undefined) {
100
+ throw new Error(`a command names ${ESLINT_SOURCES_TOKEN}, and the target names no eslintProjectRoot to resolve it for`);
101
+ }
102
+ const { expandEslintSources, freshEslintSources } = await import('../../eslint-sources.js');
103
+ const { files } = freshEslintSources(root, projectRoot);
104
+ return options.commands.map((command) => {
105
+ if (!command.includes(ESLINT_SOURCES_TOKEN))
106
+ return { command };
107
+ if (files.length === 0)
108
+ return { command, noRun: `no ESLint sources under ${projectRoot}: nothing to lint` };
109
+ return { command: expandEslintSources(command, files) };
110
+ });
111
+ }
87
112
  /**
88
113
  * Starts every command at once and lets each reach its own verdict. Nx's run-commands cannot: in parallel it terminates
89
114
  * the other commands once one fails, and serially it never starts the ones after a failure, so one tool's errors hide
90
115
  * another's until a later run. Here no command ends another. Each command's output prints as one block when it closes,
91
116
  * then every command's verdict. A signal to the run ends every command's process group, reports each command still
92
117
  * running UNJUDGED, and ends the run by the same signal. The run succeeds only when every command passed.
118
+ * A command that names the ESLint sources placeholder is resolved first, and the verdicts name it as it ran.
93
119
  */
94
120
  export default async function allVerdictsExecutor(options, context) {
95
121
  if (options.commands.length === 0) {
@@ -97,7 +123,20 @@ export default async function allVerdictsExecutor(options, context) {
97
123
  return { success: false };
98
124
  }
99
125
  const cwd = resolve(context.root, options.cwd);
100
- const runs = options.commands.map((command) => ({ command, output: [], pid: undefined, verdict: null }));
126
+ let planned;
127
+ try {
128
+ planned = await planCommands(options, context.root);
129
+ }
130
+ catch (error) {
131
+ process.stderr.write(`all-verdicts: cannot resolve the commands to run: ${error instanceof Error ? error.message : String(error)}\n`);
132
+ return { success: false };
133
+ }
134
+ const runs = planned.map(({ command, noRun }) => ({
135
+ command,
136
+ output: noRun === undefined ? [] : [`${noRun}\n`],
137
+ pid: undefined,
138
+ verdict: noRun === undefined ? null : { kind: 'pass' },
139
+ }));
101
140
  const onExit = () => {
102
141
  for (const run of runs) {
103
142
  if (run.verdict === null && run.pid !== undefined)
@@ -126,7 +165,14 @@ export default async function allVerdictsExecutor(options, context) {
126
165
  process.on('exit', onExit);
127
166
  for (const [signal, listener] of listeners)
128
167
  process.on(signal, listener);
129
- const verdicts = await Promise.all(runs.map(async (run) => ({ command: run.command, verdict: await judge(run, cwd) })));
168
+ // A command that needs no run is already judged: its block prints now, the others' as they close.
169
+ for (const run of runs)
170
+ if (run.verdict !== null)
171
+ process.stdout.write(block(run));
172
+ const verdicts = await Promise.all(runs.map(async (run) => ({
173
+ command: run.command,
174
+ verdict: run.verdict ?? (await judge(run, cwd)),
175
+ })));
130
176
  detach();
131
177
  process.stdout.write(verdictReport(verdicts));
132
178
  return { success: verdicts.every(({ verdict }) => verdict.kind === 'pass') };
@@ -1,10 +1,23 @@
1
1
  /** The executor the inferred `lint` target runs its tool commands with. */
2
2
  export declare const ALL_VERDICTS_EXECUTOR = "@smoothbricks/nx-plugin:all-verdicts";
3
+ /**
4
+ * Where an inferred ESLint command names its files. The graph holds no list of them: a list is the files of the moment
5
+ * the graph was computed, and a run that outlives that moment fails on a file since deleted (ESLint refuses a pattern
6
+ * no file matches) and skips one since added. The executor replaces each occurrence with the files ESLint is handed
7
+ * when the command runs.
8
+ */
9
+ export declare const ESLINT_SOURCES_TOKEN = "{eslintSources}";
3
10
  /** Options of `@smoothbricks/nx-plugin:all-verdicts`. */
4
11
  export interface AllVerdictsOptions {
5
12
  /** Shell commands, all started at once; none ends another. An empty list is refused: it could never fail. */
6
13
  readonly commands: readonly string[];
7
14
  /** Where every command runs, relative to the workspace root. */
8
15
  readonly cwd: string;
16
+ /**
17
+ * The project, by workspace-relative root, whose ESLint sources replace {@link ESLINT_SOURCES_TOKEN} in a command when
18
+ * it runs: its `src` files and those its `tsconfig.test.json` declares, read from a fresh workspace file index. A
19
+ * command that names the token with no project is refused. A project with none passes without running ESLint.
20
+ */
21
+ readonly eslintProjectRoot?: string;
9
22
  }
10
23
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/executors/all-verdicts/schema.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,eAAO,MAAM,qBAAqB,yCAAyC,CAAC;AAE5E,yDAAyD;AACzD,MAAM,WAAW,kBAAkB;IACjC,6GAA6G;IAC7G,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,gEAAgE;IAChE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/executors/all-verdicts/schema.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,eAAO,MAAM,qBAAqB,yCAAyC,CAAC;AAE5E;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,oBAAoB,CAAC;AAEtD,yDAAyD;AACzD,MAAM,WAAW,kBAAkB;IACjC,6GAA6G;IAC7G,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,gEAAgE;IAChE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACrC"}
@@ -1,2 +1,9 @@
1
1
  /** The executor the inferred `lint` target runs its tool commands with. */
2
2
  export const ALL_VERDICTS_EXECUTOR = '@smoothbricks/nx-plugin:all-verdicts';
3
+ /**
4
+ * Where an inferred ESLint command names its files. The graph holds no list of them: a list is the files of the moment
5
+ * the graph was computed, and a run that outlives that moment fails on a file since deleted (ESLint refuses a pattern
6
+ * no file matches) and skips one since added. The executor replaces each occurrence with the files ESLint is handed
7
+ * when the command runs.
8
+ */
9
+ export const ESLINT_SOURCES_TOKEN = '{eslintSources}';
@@ -3,11 +3,10 @@
3
3
  * a pure function of the run's events and the times they happened at, so a table can test it with no clock and no
4
4
  * process (verdict.ts says why the bounds are separate).
5
5
  *
6
- * - The total ceiling runs from the spawn.
7
- * - The fixture ceiling runs from the spawn while a supervised fixture runs, and ends with the fixture's segment.
8
- * - The progress bound runs only while the runner is testing (runner-lifecycle.ts): from the spawn when the runner is
9
- * testing then (startup is bounded until a build declares itself), restarted by a finished test or by the clock
10
- * starting again after a build, and stopped while nothing tests.
6
+ * - A scheduled leaf arms nothing until its first grant. Later zero-hold intervals pause only the idle budget.
7
+ * - Any explicitly queued task process pauses idle, including alongside held grants; ceilings keep running.
8
+ * - The fixture ceiling ends with its segment. The idle clock also stops outside the testing lifecycle.
9
+ * - Finished tests reset the idle budget whether their release byte arrived before or after their output.
11
10
  */
12
11
  /** The limits a run was given, in milliseconds; an absent one never expires. */
13
12
  export interface BoundLimits {
@@ -15,20 +14,48 @@ export interface BoundLimits {
15
14
  readonly fixtureMs?: number;
16
15
  readonly totalMs?: number;
17
16
  }
18
- /** When each armed bound expires, in the clock's milliseconds; `null` when it is not armed. */
17
+ /**
18
+ * When each armed bound expires, in the clock's milliseconds; `null` when it is not armed. `queued`: the run waits for
19
+ * its pool's grant, so none is armed yet.
20
+ */
19
21
  export interface Bounds {
20
22
  readonly idle: number | null;
21
23
  readonly fixture: number | null;
22
24
  readonly total: number | null;
25
+ readonly queued: boolean;
26
+ readonly holds: number | null;
27
+ readonly idleRemaining: number | null;
28
+ readonly admissionWaiting: boolean;
23
29
  }
24
- export type BoundKind = keyof Bounds;
30
+ export type BoundKind = 'idle' | 'fixture' | 'total';
25
31
  export type BoundEvent =
26
- /** The command started; `testing` is the lifecycle's answer then, `fixture` whether a supervised fixture leads it. */
32
+ /**
33
+ * The command started; `testing` is the lifecycle's answer then, `fixture` whether a supervised fixture leads it,
34
+ * `queued` whether mbx schedules this leaf, as known before spawn.
35
+ */
27
36
  {
28
37
  readonly kind: 'spawn';
29
38
  readonly at: number;
30
39
  readonly testing: boolean;
31
40
  readonly fixture: boolean;
41
+ readonly queued: boolean;
42
+ }
43
+ /** Each admission begins a hold; the first one starts the queued leaf's ceilings. */
44
+ | {
45
+ readonly kind: 'granted';
46
+ readonly at: number;
47
+ readonly testing: boolean;
48
+ readonly fixture: boolean;
49
+ } | {
50
+ readonly kind: 'released';
51
+ readonly at: number;
52
+ }
53
+ /** A successful public snapshot proved whether a live task process is queued; `at` is completion, not poll start. */
54
+ | {
55
+ readonly kind: 'admission-queue';
56
+ readonly at: number;
57
+ readonly waiting: boolean;
58
+ readonly testing: boolean;
32
59
  }
33
60
  /**
34
61
  * The runner's state may have moved: a test finished (`finished`), a phase changed, or the lifecycle failed.
@@ -53,4 +80,26 @@ export declare function earliestBound(bounds: Bounds): {
53
80
  readonly kind: BoundKind;
54
81
  readonly at: number;
55
82
  } | null;
83
+ /** Observed queue duration on a monotonic clock; stopping closes its interval permanently, before cleanup begins. */
84
+ export type AdmissionWait = {
85
+ readonly kind: 'observing';
86
+ readonly since: number | null;
87
+ readonly waitedMs: number;
88
+ } | {
89
+ readonly kind: 'stopped';
90
+ readonly waitedMs: number;
91
+ };
92
+ export type AdmissionWaitEvent = {
93
+ readonly kind: 'snapshot';
94
+ readonly at: number;
95
+ readonly waiting: boolean;
96
+ } | {
97
+ readonly kind: 'stop';
98
+ readonly at: number;
99
+ };
100
+ export declare const NO_ADMISSION_WAIT: AdmissionWait;
101
+ /** Read the observed duration, not the time later spent tearing down the command or reading its report. */
102
+ export declare function admissionWaitMs(wait: AdmissionWait, at: number): number;
103
+ /** A successful completed observation opens/closes an interval; terminal/cancellation stops freeze it. */
104
+ export declare function stepAdmissionWait(wait: AdmissionWait, event: AdmissionWaitEvent): AdmissionWait;
56
105
  //# sourceMappingURL=bounds.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bounds.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/bounds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,gFAAgF;AAChF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,+FAA+F;AAC/F,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC;AAErC,MAAM,MAAM,UAAU;AACpB,sHAAsH;AACpH;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE;AACvG;;;GAGG;GACD;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AACH,kEAAkE;GAChE;IAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAA;CAAE,CAAC;AAEtC,eAAO,MAAM,OAAO,EAAE,MAAmD,CAAC;AAE1E,gCAAgC;AAChC,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAiBzF;AAED,sHAAsH;AACtH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAOtG"}
1
+ {"version":3,"file":"bounds.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/bounds.ts"],"names":[],"mappings":"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"}
@@ -3,29 +3,103 @@
3
3
  * a pure function of the run's events and the times they happened at, so a table can test it with no clock and no
4
4
  * process (verdict.ts says why the bounds are separate).
5
5
  *
6
- * - The total ceiling runs from the spawn.
7
- * - The fixture ceiling runs from the spawn while a supervised fixture runs, and ends with the fixture's segment.
8
- * - The progress bound runs only while the runner is testing (runner-lifecycle.ts): from the spawn when the runner is
9
- * testing then (startup is bounded until a build declares itself), restarted by a finished test or by the clock
10
- * starting again after a build, and stopped while nothing tests.
6
+ * - A scheduled leaf arms nothing until its first grant. Later zero-hold intervals pause only the idle budget.
7
+ * - Any explicitly queued task process pauses idle, including alongside held grants; ceilings keep running.
8
+ * - The fixture ceiling ends with its segment. The idle clock also stops outside the testing lifecycle.
9
+ * - Finished tests reset the idle budget whether their release byte arrived before or after their output.
11
10
  */
12
- export const UNARMED = { idle: null, fixture: null, total: null };
11
+ export const UNARMED = {
12
+ idle: null,
13
+ fixture: null,
14
+ total: null,
15
+ queued: false,
16
+ admissionWaiting: false,
17
+ holds: null,
18
+ idleRemaining: null,
19
+ };
20
+ /** The bounds a command that starts running at `at` arms. */
21
+ function armed(limits, at, testing, fixture) {
22
+ return {
23
+ idle: testing && limits.idleMs !== undefined ? at + limits.idleMs : null,
24
+ fixture: fixture && limits.fixtureMs !== undefined ? at + limits.fixtureMs : null,
25
+ total: limits.totalMs !== undefined ? at + limits.totalMs : null,
26
+ queued: false,
27
+ admissionWaiting: false,
28
+ holds: null,
29
+ idleRemaining: limits.idleMs ?? null,
30
+ };
31
+ }
13
32
  /** The bounds after `event`. */
14
33
  export function stepBounds(bounds, limits, event) {
15
34
  switch (event.kind) {
16
35
  case 'spawn':
36
+ return event.queued
37
+ ? { ...UNARMED, queued: true, holds: 0, idleRemaining: limits.idleMs ?? null }
38
+ : armed(limits, event.at, event.testing, event.fixture);
39
+ case 'granted': {
40
+ if (bounds.holds === null)
41
+ return bounds;
42
+ if (bounds.queued) {
43
+ const admitted = armed(limits, event.at, event.testing, event.fixture);
44
+ return {
45
+ ...admitted,
46
+ holds: 1,
47
+ admissionWaiting: bounds.admissionWaiting,
48
+ idle: bounds.admissionWaiting ? null : admitted.idle,
49
+ };
50
+ }
51
+ return {
52
+ ...bounds,
53
+ holds: bounds.holds + 1,
54
+ idle: bounds.holds === 0 && !bounds.admissionWaiting && event.testing && bounds.idleRemaining !== null
55
+ ? event.at + bounds.idleRemaining
56
+ : bounds.idle,
57
+ };
58
+ }
59
+ case 'admission-queue': {
60
+ if (bounds.admissionWaiting === event.waiting)
61
+ return bounds;
62
+ if (event.waiting) {
63
+ return {
64
+ ...bounds,
65
+ admissionWaiting: true,
66
+ idle: null,
67
+ idleRemaining: bounds.idle === null ? bounds.idleRemaining : Math.max(0, bounds.idle - event.at),
68
+ };
69
+ }
17
70
  return {
18
- idle: event.testing && limits.idleMs !== undefined ? event.at + limits.idleMs : null,
19
- fixture: event.fixture && limits.fixtureMs !== undefined ? event.at + limits.fixtureMs : null,
20
- total: limits.totalMs !== undefined ? event.at + limits.totalMs : null,
71
+ ...bounds,
72
+ admissionWaiting: false,
73
+ idle: !bounds.queued && bounds.holds !== 0 && event.testing && bounds.idleRemaining !== null
74
+ ? event.at + bounds.idleRemaining
75
+ : null,
21
76
  };
77
+ }
78
+ case 'released': {
79
+ if (bounds.holds === null || bounds.holds === 0)
80
+ return bounds;
81
+ if (bounds.holds > 1)
82
+ return { ...bounds, holds: bounds.holds - 1 };
83
+ return {
84
+ ...bounds,
85
+ holds: 0,
86
+ idle: null,
87
+ idleRemaining: bounds.idle === null ? bounds.idleRemaining : Math.max(0, bounds.idle - event.at),
88
+ };
89
+ }
22
90
  case 'progress': {
91
+ if (bounds.queued)
92
+ return event.finished ? { ...bounds, idleRemaining: limits.idleMs ?? null } : bounds;
23
93
  if (!event.testing)
24
- return { ...bounds, idle: null };
94
+ return { ...bounds, idle: null, idleRemaining: limits.idleMs ?? null };
25
95
  const restart = event.finished || !event.wasTesting;
26
96
  if (!restart || limits.idleMs === undefined)
27
97
  return bounds;
28
- return { ...bounds, idle: event.at + limits.idleMs };
98
+ return {
99
+ ...bounds,
100
+ idle: bounds.holds === 0 || bounds.admissionWaiting ? null : event.at + limits.idleMs,
101
+ idleRemaining: limits.idleMs,
102
+ };
29
103
  }
30
104
  case 'fixture-done':
31
105
  return { ...bounds, fixture: null };
@@ -41,3 +115,18 @@ export function earliestBound(bounds) {
41
115
  }
42
116
  return earliest;
43
117
  }
118
+ export const NO_ADMISSION_WAIT = { kind: 'observing', since: null, waitedMs: 0 };
119
+ /** Read the observed duration, not the time later spent tearing down the command or reading its report. */
120
+ export function admissionWaitMs(wait, at) {
121
+ return wait.waitedMs + (wait.kind === 'observing' && wait.since !== null ? at - wait.since : 0);
122
+ }
123
+ /** A successful completed observation opens/closes an interval; terminal/cancellation stops freeze it. */
124
+ export function stepAdmissionWait(wait, event) {
125
+ if (wait.kind === 'stopped')
126
+ return wait;
127
+ if (event.kind === 'stop')
128
+ return { kind: 'stopped', waitedMs: admissionWaitMs(wait, event.at) };
129
+ if (event.waiting)
130
+ return wait.since === null ? { ...wait, since: event.at } : wait;
131
+ return wait.since === null ? wait : { kind: 'observing', since: null, waitedMs: admissionWaitMs(wait, event.at) };
132
+ }
@@ -1,5 +1,6 @@
1
1
  import { type InheritedCpuPool } from './cpu-pool.js';
2
2
  import { captureHangDiagnostics } from './hang-diagnostics.js';
3
+ import { snapshotMbxQueue } from './mbx-queue.js';
3
4
  import { type SubtreeOwner } from './owned-subtree.js';
4
5
  import { RamTempVolume } from './ram-temp.js';
5
6
  import type { BoundedExecOptions } from './schema.js';
@@ -69,6 +70,6 @@ export declare function recordContext(context: NxTaskContext): BoundedExecContex
69
70
  * connection closes while the command runs (the lending parent's exit) ends its accounting, never the command: the
70
71
  * command runs on over budget to its own exit, and the run says so.
71
72
  */
72
- export declare function runBoundedExec(options: BoundedExecOptions, context: BoundedExecContext, killer: ProcessTreeKiller, tempVolume: TempVolume | null, inherited?: InheritedCpuPool | null, captureDiagnostics?: typeof captureHangDiagnostics, owner?: SubtreeOwner | null): Promise<BoundedExecResult>;
73
+ export declare function runBoundedExec(options: BoundedExecOptions, context: BoundedExecContext, killer: ProcessTreeKiller, tempVolume: TempVolume | null, inherited?: InheritedCpuPool | null, captureDiagnostics?: typeof captureHangDiagnostics, owner?: SubtreeOwner | null, queueHost?: Parameters<typeof snapshotMbxQueue>[3]): Promise<BoundedExecResult>;
73
74
  export declare function createProcessTreeKiller(): ProcessTreeKiller;
74
75
  //# sourceMappingURL=executor.d.ts.map