@smoothbricks/nx-plugin 0.6.1 → 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 (104) hide show
  1. package/README.md +264 -55
  2. package/dist/.build-inputs.json +21 -15
  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 +14 -3
  7. package/dist/cargo-retention-hook.d.ts.map +1 -1
  8. package/dist/cargo-retention-hook.js +25 -8
  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 +27 -3
  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/managed-files/files.d.ts.map +1 -1
  51. package/dist/managed-files/files.js +6 -0
  52. package/dist/nx-publish.d.ts +24 -0
  53. package/dist/nx-publish.d.ts.map +1 -0
  54. package/dist/nx-publish.js +150 -0
  55. package/dist/runtime-input-policy.d.ts +14 -0
  56. package/dist/runtime-input-policy.d.ts.map +1 -1
  57. package/dist/runtime-input-policy.js +1 -1
  58. package/dist/tool-bins.d.ts +6 -8
  59. package/dist/tool-bins.d.ts.map +1 -1
  60. package/dist/tool-bins.js +7 -5
  61. package/dist/workspace-index.d.ts +7 -0
  62. package/dist/workspace-index.d.ts.map +1 -1
  63. package/dist/workspace-index.js +11 -0
  64. package/executors.json +1 -1
  65. package/managed/raw/envrc +15 -0
  66. package/managed/raw/patches/ttsc@0.34.1.patch +75 -0
  67. package/managed/raw/tooling/devenv +1 -2
  68. package/managed/raw/tooling/direnv/developer-links.ts +15 -1
  69. package/managed/raw/tooling/direnv/devenv.smoo.nix +45 -13
  70. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -10
  71. package/managed/raw/tooling/direnv/linked-snapshots.ts +50 -13
  72. package/managed/raw/tooling/direnv/setup-environment.ts +36 -9
  73. package/managed/raw/tooling/direnv/ttsc-env.sh +8 -6
  74. package/managed/raw/tooling/git-hooks/pre-push.sh +4 -1
  75. package/managed/raw/tooling/git-reword-commit +151 -0
  76. package/managed/templates/github/actions/cache-node-modules/action.yml +1 -1
  77. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +12 -11
  78. package/package.json +226 -10
  79. package/runtime/nx-publish/cache_adapter.js +45 -0
  80. package/runtime/nx-publish/nx_publish.js +60 -0
  81. package/runtime-input.sh +12 -3
  82. package/src/bin/smoo-nx-publish.ts +4 -0
  83. package/src/cargo-retention-hook.ts +28 -11
  84. package/src/eslint-file-set.ts +4 -1
  85. package/src/eslint-sources.ts +134 -0
  86. package/src/executors/all-verdicts/executor.ts +58 -3
  87. package/src/executors/all-verdicts/schema.json +4 -0
  88. package/src/executors/all-verdicts/schema.ts +14 -0
  89. package/src/executors/bounded-exec/bounds.ts +132 -15
  90. package/src/executors/bounded-exec/executor.ts +303 -27
  91. package/src/executors/bounded-exec/hang-diagnostics.ts +31 -3
  92. package/src/executors/bounded-exec/mbx-pool.ts +82 -5
  93. package/src/executors/bounded-exec/mbx-queue.ts +170 -0
  94. package/src/executors/bounded-exec/progress.ts +168 -15
  95. package/src/executors/bounded-exec/test-result-writer.ts +152 -0
  96. package/src/executors/bounded-exec/test-results.ts +39 -0
  97. package/src/executors/bounded-exec/verdict.ts +108 -5
  98. package/src/index.ts +74 -70
  99. package/src/managed-files/files.ts +6 -0
  100. package/src/nx-publish.ts +157 -0
  101. package/src/runtime-input-policy.ts +1 -1
  102. package/src/tool-bins.ts +13 -9
  103. package/src/workspace-index.ts +12 -0
  104. package/test-timings.json +8 -2
@@ -0,0 +1,152 @@
1
+ import { type ClosedTestResult, parseTestSourceRef, TEST_FAILURES_FILE, TEST_RESULTS_FILE } from './test-results.js';
2
+
3
+ export { taskDirectory } from './verdict.js';
4
+
5
+ import { randomUUID } from 'node:crypto';
6
+ import { appendFileSync } from 'node:fs';
7
+ import { type FileHandle, open, rename, rm } from 'node:fs/promises';
8
+ import { join, relative, resolve, sep } from 'node:path';
9
+ /** A runner's closed observation, before the artifact writer assigns its references. */
10
+ export interface NativeTestResult {
11
+ readonly id: string;
12
+ readonly status: ClosedTestResult['status'];
13
+ readonly source: ClosedTestResult['source'];
14
+ readonly contradictsCursor?: number;
15
+ readonly durationMs: number | null;
16
+ readonly sourceRef: string | null;
17
+ readonly failureOutput: string | null;
18
+ }
19
+
20
+ export interface TestResultWriter {
21
+ /** Completes the evidence write before publishing its referring JSONL record. */
22
+ append(result: NativeTestResult): string | null;
23
+ reconcile(results: readonly NativeTestResult[]): string | null;
24
+ close(): Promise<string | null>;
25
+ }
26
+
27
+ /** The cursor includes its own decimal digits: converge on their width before publishing. */
28
+ function resultLine(result: Omit<ClosedTestResult, 'cursor'>, offset: number): { line: string; cursor: number } {
29
+ let cursor = offset;
30
+ for (;;) {
31
+ const line = `${JSON.stringify({ ...result, cursor })}\n`;
32
+ const next = offset + Buffer.byteLength(line);
33
+ if (next === cursor) return { line, cursor };
34
+ cursor = next;
35
+ }
36
+ }
37
+
38
+ function normalizeSourceRef(sourceRef: string | null, sourceRoot: { cwd: string; root: string }): string | null {
39
+ const location = parseTestSourceRef(sourceRef);
40
+ if (location === null) return null;
41
+ return `${relative(sourceRoot.root, resolve(sourceRoot.cwd, location.path)).split(sep).join('/')}:${location.line}`;
42
+ }
43
+ async function closeResultFiles(
44
+ files: readonly FileHandle[],
45
+ stagedPaths: readonly string[] = [],
46
+ ): Promise<string | null> {
47
+ const results = await Promise.allSettled([
48
+ ...files.map((file) => file.close()),
49
+ ...stagedPaths.map((path) => rm(path, { force: true })),
50
+ ]);
51
+ const failures = results.flatMap((result) => (result.status === 'rejected' ? [String(result.reason)] : []));
52
+ return failures.length === 0 ? null : `closing test result artifacts: ${failures.join('; ')}`;
53
+ }
54
+ /** A new inode and UUID identify a replacement run, even when it has the same byte length. */
55
+ export async function createTestResultWriter(
56
+ directory: string,
57
+ sourceRoot: { readonly cwd: string; readonly root: string },
58
+ ): Promise<{ readonly ok: true; readonly writer: TestResultWriter } | { readonly ok: false; readonly error: string }> {
59
+ const runId = randomUUID();
60
+ const target = join(directory, TEST_RESULTS_FILE);
61
+ const staged = `${target}.${runId}`;
62
+ const causePath = join(directory, TEST_FAILURES_FILE);
63
+ const stagedCauses = `${causePath}.${runId}`;
64
+ const [records, causes] = await Promise.allSettled([open(staged, 'ax'), open(stagedCauses, 'ax')]);
65
+ if (records.status !== 'fulfilled' || causes.status !== 'fulfilled') {
66
+ const cleanup = await closeResultFiles(
67
+ [
68
+ ...(records.status === 'fulfilled' ? [records.value] : []),
69
+ ...(causes.status === 'fulfilled' ? [causes.value] : []),
70
+ ],
71
+ [staged, stagedCauses],
72
+ );
73
+ const failures = [records, causes].flatMap((result) =>
74
+ result.status === 'rejected' ? [String(result.reason)] : [],
75
+ );
76
+ return {
77
+ ok: false,
78
+ error: `initializing test result stream ${target}: ${failures.join('; ')}${cleanup === null ? '' : `; ${cleanup}`}`,
79
+ };
80
+ }
81
+ try {
82
+ await rename(stagedCauses, causePath);
83
+ await rename(staged, target);
84
+ } catch (cause) {
85
+ const cleanup = await closeResultFiles([records.value, causes.value], [staged, stagedCauses]);
86
+ return {
87
+ ok: false,
88
+ error: `initializing test result stream ${target}: ${String(cause)}${cleanup === null ? '' : `; ${cleanup}`}`,
89
+ };
90
+ }
91
+ let offset = 0;
92
+ let causeOffset = 0;
93
+ let failure: string | null = null;
94
+ let closing: Promise<string | null> | null = null;
95
+ const provisional = new Map<string, { status: ClosedTestResult['status']; cursor: number }>();
96
+ return {
97
+ ok: true,
98
+ writer: {
99
+ append(result) {
100
+ if (failure !== null) return failure;
101
+ if (closing !== null) return `appending test result ${result.id} to ${target}: stream is closed`;
102
+ try {
103
+ let causeRef: ClosedTestResult['causeRef'] = null;
104
+ if (result.status === 'fail' && result.failureOutput !== null) {
105
+ const endByte = causeOffset + Buffer.byteLength(result.failureOutput);
106
+ appendFileSync(causes.value.fd, result.failureOutput);
107
+ causeRef = { path: TEST_FAILURES_FILE, startByte: causeOffset, endByte };
108
+ causeOffset = endByte;
109
+ }
110
+ const { line, cursor } = resultLine(
111
+ {
112
+ runId,
113
+ id: result.id,
114
+ status: result.status,
115
+ source: result.source,
116
+ ...(result.contradictsCursor === undefined ? {} : { contradictsCursor: result.contradictsCursor }),
117
+ durationMs: result.durationMs,
118
+ sourceRef: normalizeSourceRef(result.sourceRef, sourceRoot),
119
+ causeRef,
120
+ },
121
+ offset,
122
+ );
123
+ // appendFileSync has no user-space buffering: each LF is visible before append returns.
124
+ appendFileSync(records.value.fd, line);
125
+ offset = cursor;
126
+ if (result.source === 'progress') provisional.set(result.id, { status: result.status, cursor });
127
+ return null;
128
+ } catch (cause) {
129
+ failure = `appending test result ${result.id} to ${target}: ${String(cause)}`;
130
+ return failure;
131
+ }
132
+ },
133
+ reconcile(results) {
134
+ for (const result of results) {
135
+ const prior = provisional.get(result.id);
136
+ if (prior !== undefined && prior.status === result.status) continue;
137
+ const error = this.append({
138
+ ...result,
139
+ source: 'junit',
140
+ ...(prior === undefined ? {} : { contradictsCursor: prior.cursor }),
141
+ });
142
+ if (error !== null) return error;
143
+ }
144
+ return null;
145
+ },
146
+ close() {
147
+ closing ??= closeResultFiles([records.value, causes.value]);
148
+ return closing;
149
+ },
150
+ },
151
+ };
152
+ }
@@ -0,0 +1,39 @@
1
+ import typia, { type tags } from 'typia';
2
+
3
+ export const TEST_RESULTS_FILE = 'test-results.jsonl';
4
+ export const TEST_FAILURES_FILE = 'test-failures.log';
5
+
6
+ type ByteOffset = number & tags.Type<'uint64'> & tags.Maximum<9007199254740991>;
7
+
8
+ /** Live observations, not gate evidence: report.xml and verdict.json remain authoritative. */
9
+ export interface ClosedTestResult {
10
+ readonly runId: string & tags.Format<'uuid'>;
11
+ readonly id: string;
12
+ readonly status: 'pass' | 'fail' | 'skip';
13
+ readonly source: 'native' | 'progress' | 'junit';
14
+ /** Set only on a terminal JUnit correction of a provisional progress observation. */
15
+ readonly contradictsCursor?: ByteOffset;
16
+ /** Null when the native runner reports no duration (for example a skipped test). */
17
+ readonly durationMs: (number & tags.Minimum<0>) | null;
18
+ /** Native file:line, never a location inferred from human output. */
19
+ readonly sourceRef: string | null;
20
+ /** UTF-8 byte range [startByte, endByte), relative to the task artifact directory. */
21
+ readonly causeRef: {
22
+ readonly path: typeof TEST_FAILURES_FILE;
23
+ readonly startByte: ByteOffset;
24
+ readonly endByte: ByteOffset;
25
+ } | null;
26
+ /** Next UTF-8 byte offset in test-results.jsonl, including this record's LF. */
27
+ readonly cursor: ByteOffset;
28
+ }
29
+
30
+ export const isClosedTestResult = typia.createEquals<ClosedTestResult>();
31
+
32
+ /** A producer-normalized workspace-relative declaration location, never inferred from a test name. */
33
+ export function parseTestSourceRef(sourceRef: string | null): { path: string; line: number } | null {
34
+ if (sourceRef === null) return null;
35
+ const match = /^(.+):([1-9]\d*)$/.exec(sourceRef);
36
+ const path = match?.[1];
37
+ const line = Number(match?.[2]);
38
+ return path !== undefined && Number.isSafeInteger(line) ? { path, line } : null;
39
+ }
@@ -1,7 +1,11 @@
1
1
  import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
2
2
  import { join } from 'node:path';
3
+ import typia from 'typia';
3
4
  import type { CpuWaitRow } from './lease-wait.js';
4
5
  import { describeHolders, type LockWait, type Opener } from './lock-wait.js';
6
+ import type { MbxQueuedRequest } from './mbx-queue.js';
7
+ import type { NativeTestResult } from './test-result-writer.js';
8
+ import { TEST_FAILURES_FILE, TEST_RESULTS_FILE } from './test-results.js';
5
9
 
6
10
  /**
7
11
  * Why one bounded run ended, recorded per Nx task so a caller can tell a load-sensitive bound
@@ -21,11 +25,14 @@ import { describeHolders, type LockWait, type Opener } from './lock-wait.js';
21
25
  * - `no-space`: the run failed and its output said a write found no space (ENOSPC). Whatever its tests then reported,
22
26
  * they failed on the disk, not on their own: the verdict names the line that said so and, when the task held one,
23
27
  * its RAM temp volume as it stood when that line arrived.
28
+ * - `queued`: the command failed before any admission after a live task PID was explicitly seen waiting in mbx.
29
+ * Its observed wait and public queue positions describe admission pressure, never a wedged test.
24
30
  * - `failed`: anything else that did not pass. That includes an assertion named in the report,
25
31
  * or a non-zero exit with no report to say why.
26
32
  */
27
33
  export type BoundedExecVerdict =
28
34
  | { readonly outcome: 'passed' }
35
+ | ({ readonly outcome: 'queued'; readonly exitCode: number } & AdmissionQueueWait)
29
36
  | {
30
37
  readonly outcome: 'bound';
31
38
  readonly bound: 'total' | 'fixture';
@@ -44,6 +51,13 @@ export type BoundedExecVerdict =
44
51
  | ({ readonly outcome: 'no-space'; readonly exitCode: number; readonly tests: readonly string[] } & NoSpaceSighting)
45
52
  | { readonly outcome: 'failed'; readonly exitCode: number; readonly tests: readonly string[] };
46
53
 
54
+ /** Observed admission wait, supplied only while the command has never received a grant. */
55
+ export interface AdmissionQueueWait {
56
+ readonly waitedMs: number;
57
+ readonly requests: readonly MbxQueuedRequest[];
58
+ }
59
+ const isQueuedVerdict = typia.createIs<Extract<BoundedExecVerdict, { outcome: 'queued' }>>();
60
+
47
61
  /**
48
62
  * The task's RAM temp volume, read when a line saying ENOSPC arrived: the writer's own lease and the space left on the
49
63
  * volume it was taken on (`measured`), or why there was none to measure: the lease was no longer on that volume
@@ -178,6 +192,64 @@ export function junitFailures(xml: string): JunitFailures {
178
192
  return { timedOut, cancelled, failed };
179
193
  }
180
194
 
195
+ /** Bun's nested suites carry the describe chain; testcase.classname is in the reverse order. */
196
+ export function bunJunitResults(xml: string): NativeTestResult[] {
197
+ const results: NativeTestResult[] = [];
198
+ const suites: string[] = [];
199
+ let current: { attributes: string; body: string } | null = null;
200
+ const text = xml;
201
+ const tags =
202
+ /<!\[CDATA\[[\s\S]*?\]\]>|<!--[\s\S]*?-->|<(\/?)(testsuite|testcase)\b((?:[^>"']|"[^"]*"|'[^']*')*?)(\/?)>/g;
203
+ let end = 0;
204
+ const close = (): void => {
205
+ if (current === null) return;
206
+ const name = attribute(current.attributes, 'name');
207
+ const file = attribute(current.attributes, 'file');
208
+ if (name !== null && file !== null) {
209
+ const failed = /<(?:failure|error)\b/.test(current.body);
210
+ const skipped = /<skipped\b/.test(current.body);
211
+ const line = attribute(current.attributes, 'line');
212
+ const time = attribute(current.attributes, 'time');
213
+ const seconds = time === null ? Number.NaN : Number(time);
214
+ const output =
215
+ /<(?:failure|error)\b((?:[^>"']|"[^"]*"|'[^']*')*?)(?:\/>|>((?:<!\[CDATA\[[\s\S]*?\]\]>|(?!<!\[CDATA\[|<\/(?:failure|error)>)[\s\S])*)<\/(?:failure|error)>)/.exec(
216
+ current.body,
217
+ );
218
+ const failureOutput =
219
+ output === null
220
+ ? null
221
+ : output[2] === undefined || output[2] === ''
222
+ ? (attribute(output[1] ?? '', 'message') ?? '')
223
+ : decodeJunitText(output[2]);
224
+ results.push({
225
+ id: `${file}::${[...suites.slice(1), name].join(' > ')}`,
226
+ status: failed ? 'fail' : skipped ? 'skip' : 'pass',
227
+ source: 'junit',
228
+ durationMs: Number.isFinite(seconds) && seconds >= 0 ? seconds * 1000 : null,
229
+ sourceRef: line === null ? null : `${file}:${line}`,
230
+ failureOutput,
231
+ });
232
+ }
233
+ current = null;
234
+ };
235
+ for (const match of text.matchAll(tags)) {
236
+ if (current !== null) current.body += text.slice(end, match.index);
237
+ end = match.index + match[0].length;
238
+ const [, slash, tag, attributes = '', selfClosing] = match;
239
+ if (tag === undefined) {
240
+ if (current !== null) current.body += match[0];
241
+ } else if (tag === 'testsuite') {
242
+ if (slash === '/') suites.pop();
243
+ else if (selfClosing !== '/') suites.push(attribute(attributes, 'name') ?? '');
244
+ } else if (slash === '/') close();
245
+ else {
246
+ close();
247
+ current = { attributes, body: '' };
248
+ if (selfClosing === '/') close();
249
+ }
250
+ }
251
+ return results;
252
+ }
181
253
  /** One test case of a JUnit report: nextest's binary id (its `classname`), the test's name and its seconds. */
182
254
  export interface JunitCaseTime {
183
255
  readonly binary: string;
@@ -209,6 +281,16 @@ function attribute(attributes: string, name: string): string | null {
209
281
  return decodeEntities(match[2] ?? match[3] ?? '');
210
282
  }
211
283
 
284
+ function decodeJunitText(value: string): string {
285
+ let text = '';
286
+ let end = 0;
287
+ for (const match of value.matchAll(/<!\[CDATA\[([\s\S]*?)\]\]>|<!--[\s\S]*?-->/g)) {
288
+ text += decodeEntities(value.slice(end, match.index));
289
+ text += match[1] ?? '';
290
+ end = match.index + match[0].length;
291
+ }
292
+ return text + decodeEntities(value.slice(end));
293
+ }
212
294
  function decodeEntities(value: string): string {
213
295
  return value.replace(/&(#x[0-9a-fA-F]+|#[0-9]+|amp|lt|gt|quot|apos);/g, (_, entity: string) => {
214
296
  switch (entity) {
@@ -255,6 +337,8 @@ export interface RunEnd {
255
337
  readonly noSpace: NoSpaceSighting | null;
256
338
  /** The lock waits the expiry's snapshot named; empty when none, or when that capture did not complete. */
257
339
  readonly lockWaits: readonly LockWait[];
340
+ /** Explicit observed queue evidence before first admission; absent after any grant. */
341
+ readonly admissionQueue?: AdmissionQueueWait | null;
258
342
  }
259
343
 
260
344
  /**
@@ -270,6 +354,9 @@ export function judgeRun(run: RunEnd): BoundedExecVerdict {
270
354
  const tests = run.report === null ? [] : [...run.report.failed, ...run.report.timedOut, ...run.report.cancelled];
271
355
  return { outcome: 'no-space', exitCode: run.exitCode === 0 ? 1 : run.exitCode, tests, ...run.noSpace };
272
356
  }
357
+ if (run.admissionQueue != null && run.exitCode !== 0) {
358
+ return { outcome: 'queued', exitCode: run.exitCode, ...run.admissionQueue };
359
+ }
273
360
  if (run.expiry?.kind === 'idle') {
274
361
  const tests = [...new Set([...run.expiry.tests, ...(run.report?.cancelled ?? [])])];
275
362
  return { outcome: 'wedged', idleMs: run.expiry.limitMs, elapsedMs: run.elapsedMs, tests, lockWaits: run.lockWaits };
@@ -367,6 +454,8 @@ export async function clearTaskDirectory(directory: string): Promise<void> {
367
454
  await Promise.all([
368
455
  rm(join(directory, VERDICT_FILE), { force: true }),
369
456
  rm(join(directory, JUNIT_FILE), { force: true }),
457
+ rm(join(directory, TEST_RESULTS_FILE), { force: true }),
458
+ rm(join(directory, TEST_FAILURES_FILE), { force: true }),
370
459
  ]);
371
460
  }
372
461
 
@@ -392,13 +481,16 @@ export async function readRecord(directory: string): Promise<BoundedExecRecord |
392
481
  }
393
482
 
394
483
  /** The JUnit report a command wrote into `directory`, or `null` when it wrote none. */
395
- export async function readJunitReport(directory: string): Promise<JunitFailures | null> {
484
+ export async function readJunitReport(
485
+ directory: string,
486
+ bunClosed?: (results: readonly NativeTestResult[]) => void,
487
+ ): Promise<JunitFailures | null> {
396
488
  try {
397
- return junitFailures(await readFile(join(directory, JUNIT_FILE), 'utf8'));
489
+ const xml = await readFile(join(directory, JUNIT_FILE), 'utf8');
490
+ bunClosed?.(bunJunitResults(xml));
491
+ return junitFailures(xml);
398
492
  } catch (error) {
399
- if (isNotFound(error)) {
400
- return null;
401
- }
493
+ if (isNotFound(error)) return null;
402
494
  throw error;
403
495
  }
404
496
  }
@@ -419,6 +511,9 @@ function parseVerdict(value: unknown): BoundedExecVerdict {
419
511
  switch (value.outcome) {
420
512
  case 'passed':
421
513
  return { outcome: 'passed' };
514
+ case 'queued':
515
+ if (isQueuedVerdict(value)) return value;
516
+ break;
422
517
  case 'bound':
423
518
  if (
424
519
  (value.bound === 'total' || value.bound === 'fixture') &&
@@ -568,10 +663,18 @@ export async function failedTasksOfRun(runJson: unknown, workspaceData: string):
568
663
  return failed;
569
664
  }
570
665
 
666
+ /** The same honest admission diagnostic in live output and a terminal verdict. */
667
+ export function describeAdmissionQueue(wait: AdmissionQueueWait): string {
668
+ return `queued for admission ${(wait.waitedMs / 1_000).toFixed(1)} s; mbx ${wait.requests
669
+ .map((request) => `pid=${request.pid} ticket=${request.ticket} queue position=${request.queuePosition}`)
670
+ .join(', ')}`;
671
+ }
571
672
  export function describeVerdict(verdict: BoundedExecVerdict): string {
572
673
  switch (verdict.outcome) {
573
674
  case 'passed':
574
675
  return 'passed';
676
+ case 'queued':
677
+ return `${describeAdmissionQueue(verdict)}; exited ${verdict.exitCode} before first admission`;
575
678
  case 'bound':
576
679
  return verdict.bound === 'test'
577
680
  ? `per-test timeout only: ${verdict.tests.join(', ')}`
package/src/index.ts CHANGED
@@ -23,7 +23,6 @@ import {
23
23
  } from 'nx/src/devkit-exports.js';
24
24
  import { AggregateCreateNodesError } from 'nx/src/project-graph/error-types.js';
25
25
  import { parse as parseToml } from 'smol-toml';
26
- import { type ParsedCommandLine, parseJsonConfigFileContent, readConfigFile, sys as typescriptSys } from 'typescript';
27
26
  import { BOUNDED_TEST_IDLE_TIMEOUT_MS, BOUNDED_TEST_KILL_AFTER_MS } from './bounded-test-policy.js';
28
27
  import { refuseOverlappingOutputs } from './build-state-output-policy.js';
29
28
  import { bunLockDependencies, bunLockInput, bunLockNode } from './bun-lock-scope.js';
@@ -78,7 +77,12 @@ import {
78
77
  } from './cross-check-policy.js';
79
78
  import { eslintConfigClosure } from './eslint-config-closure.js';
80
79
  import type { EslintFileSet } from './eslint-file-set.js';
81
- import { ALL_VERDICTS_EXECUTOR } from './executors/all-verdicts/schema.js';
80
+ import { ESLINT_SOURCES_GLOB, eslintSources } from './eslint-sources.js';
81
+ import {
82
+ ALL_VERDICTS_EXECUTOR,
83
+ type AllVerdictsOptions,
84
+ ESLINT_SOURCES_TOKEN,
85
+ } from './executors/all-verdicts/schema.js';
82
86
  import { closeRunCpuPool, serveRunCpuPool } from './executors/bounded-exec/run-cpu-pool.js';
83
87
  import { ffiPathProblem } from './executors/scriptc-native/ffi-paths.js';
84
88
  import type { ScriptcNativeFfi } from './executors/scriptc-native/schema.js';
@@ -90,7 +94,6 @@ import {
90
94
  preTasksExecution as preProducerReceipts,
91
95
  } from './producer-receipts.js';
92
96
  import { runtimeInput, shellWord } from './runtime-input.js';
93
- import { isNonSourceDirectory } from './source-directories.js';
94
97
  import { inferredTaskKind, refuseBuildTestDependencies } from './task-graph-policy.js';
95
98
  import { postTasksExecution as postTaskResults, preTasksExecution as preTaskResults } from './task-results.js';
96
99
  import { SHARD_TIMINGS_EXECUTOR, SHARD_TIMINGS_TARGET, timingsShardedSuite } from './test-timings.js';
@@ -371,9 +374,6 @@ const ESLINT_CONFIG_FILES = [
371
374
  'eslint.config.cts',
372
375
  ];
373
376
 
374
- /** Every JavaScript and TypeScript module kind ESLint is handed. */
375
- const ESLINT_SOURCES_GLOB = '**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}';
376
-
377
377
  /** What ESLint lints in this workspace and what its configuration loads. */
378
378
  interface EslintWorkspace {
379
379
  /** The JavaScript and TypeScript files of Nx's workspace file index. */
@@ -386,14 +386,15 @@ interface EslintWorkspace {
386
386
  * The ESLint sources and config closure of Nx's workspace file index, listed
387
387
  * once per graph computation; `null` when no workspace ESLint config enables ESLint.
388
388
  *
389
- * The ESLint file list is part of the lint target's command, metadata and
390
- * inputs, and Nx hashes the whole target configuration into every task that
391
- * reaches the project. A walk of the tree also listed gitignored generated
392
- * modules a build had left on disk, so every such task's key depended on
393
- * whether a build had run in that checkout: one workspace's graph listed them
394
- * and a fresh fork's did not, which alone re-keyed 197 of 510 gate tasks.
395
- * Drawing the list from the index makes the plugin and the hasher agree on one
396
- * file set.
389
+ * The lists the graph records for a project (its lint target's metadata, and
390
+ * the inputs that name its program files) are drawn from the index, not from a
391
+ * walk of the tree. A walk also listed gitignored generated modules a build had
392
+ * left on disk, so every such task's key depended on whether a build had run in
393
+ * that checkout: one workspace's graph listed them and a fresh fork's did not,
394
+ * which alone re-keyed 197 of 510 gate tasks. Drawing them from the index makes
395
+ * the plugin and the hasher agree on one file set. What the lint command runs
396
+ * on is in no graph: the executor reads it when the command runs
397
+ * (eslint-sources.ts).
397
398
  *
398
399
  * The configs key every lint target with exactly the workspace files they
399
400
  * load (eslint-config-closure.ts): a glob over the directory holding a
@@ -410,18 +411,6 @@ async function eslintWorkspace(workspaceRoot: string): Promise<EslintWorkspace |
410
411
  };
411
412
  }
412
413
 
413
- /**
414
- * Read a tsconfig with this plugin's own TypeScript. `@nx/js`'s readTsConfig does an
415
- * undeclared `require('typescript')` resolved from its own location: where that lands on the
416
- * TypeScript 7 native package (whose entry exports only its version), `sys` is undefined and
417
- * graph construction dies reading `sys.readFile`. The plugin declares TypeScript 6, whose
418
- * `sys` this uses, so the resolution is the one this package's manifest promises.
419
- */
420
- function readTestTsConfig(testConfig: string): ParsedCommandLine {
421
- const readResult = readConfigFile(testConfig, typescriptSys.readFile);
422
- return parseJsonConfigFileContent(readResult.config, typescriptSys, dirname(testConfig));
423
- }
424
-
425
414
  function projectLintCommands(
426
415
  projectRoot: string,
427
416
  workspaceRoot: string,
@@ -430,54 +419,22 @@ function projectLintCommands(
430
419
  const commands: string[] = [];
431
420
  const inputs: string[] = [];
432
421
  let eslintFileSet: EslintFileSet | null = null;
433
- const absoluteProjectRoot = join(workspaceRoot, projectRoot);
434
422
  const quote = (path: string) => `'${path.replaceAll("'", "'\"'\"'")}'`;
435
423
  if (BIOME_CONFIG_FILES.some((name) => existsSync(join(workspaceRoot, name)))) {
436
424
  commands.push(`biome check --files-ignore-unknown=true ${quote(projectRoot)}`);
437
425
  }
438
426
  if (eslint !== null) {
439
- const sourcePrefix = projectRoot === '.' ? 'src/' : `${posix.normalize(projectRoot)}/src/`;
440
- const sourceFiles = new Set<string>();
441
- for (const path of eslint.sources) {
442
- if (
443
- path.startsWith(sourcePrefix) &&
444
- !path.slice(sourcePrefix.length).split('/').slice(0, -1).some(isNonSourceDirectory)
445
- ) {
446
- sourceFiles.add(path);
447
- }
448
- }
449
- const testConfig = join(absoluteProjectRoot, 'tsconfig.test.json');
450
- if (existsSync(testConfig)) {
451
- // A test program can live anywhere the declaration selects, not just src.
452
- // Use the compiler's file set and the existing declaration-chain hasher,
453
- // so inherited includes and files outside this project keep their keys.
454
- const program: ParsedCommandLine = readTestTsConfig(testConfig);
455
- const errors = program.errors.filter(({ code }) => code !== 18003);
456
- if (errors.length > 0) {
457
- throw new Error(
458
- `${testConfig}: ${errors.map(({ code, messageText }) => `TS${code}: ${JSON.stringify(messageText)}`).join('; ')}`,
459
- );
460
- }
461
- inputs.push('{projectRoot}/tsconfig.test.json');
462
- for (const file of program.fileNames) {
463
- const path = relative(workspaceRoot, file).split(sep).join('/');
464
- if (path === '..' || path.startsWith('../') || isAbsolute(path)) {
465
- throw new Error(`${testConfig}: test source ${file} is outside the workspace and cannot be hashed`);
466
- }
467
- // Only a module Nx indexes is linted and keyed. An ignored one is build
468
- // output that a fresh checkout lacks; a JSON file is not ESLint's.
469
- if (!eslint.sources.has(path) || path.split('/').some(isNonSourceDirectory)) continue;
470
- sourceFiles.add(path);
471
- inputs.push(`{workspaceRoot}/${path}`);
472
- }
473
- }
474
- if (sourceFiles.size > 0) {
475
- const files = [...sourceFiles].sort();
476
- eslintFileSet = { command: `eslint ${files.map(quote).join(' ')}`, files };
427
+ const sources = eslintSources(workspaceRoot, projectRoot, eslint.sources);
428
+ inputs.push(...sources.inputs);
429
+ // The command names no file: a graph the daemon serves past a deletion or an addition would hand ESLint a pattern
430
+ // no file matches, or leave a new file unlinted. The all-verdicts executor resolves the token when it runs, and the
431
+ // list beside the command is the file set this graph resolved, for the inspectors that read it.
432
+ if (sources.files.length > 0) {
433
+ eslintFileSet = { command: `eslint ${ESLINT_SOURCES_TOKEN}`, files: sources.files };
477
434
  commands.push(eslintFileSet.command);
478
435
  }
479
436
  }
480
- return { commands, inputs: [...new Set(inputs)], eslintFileSet };
437
+ return { commands, inputs, eslintFileSet };
481
438
  }
482
439
 
483
440
  type NapiArchitecture = 'arm64' | 'x64';
@@ -1188,8 +1145,9 @@ function isBuildOutputPackageJson(packageJsonPath: string): boolean {
1188
1145
  * hint and the opt-in producer completion receipts. Each sees the same options and run context; neither reads the
1189
1146
  * other's output. The hint is recorded first so a producer-receipt bug cannot cost the controller its evidence. The
1190
1147
  * pair also serves a run that inherits no CPU pool its own, which every task inherits (`run-cpu-pool.ts`), and closes
1191
- * it when the run ends. Last, once every task has finished, the post hook reclaims the
1192
- * superseded Cargo unit generations of each Cargo workspace the run built into (`@smoothbricks/cargo-retain`).
1148
+ * it when the run ends. Last, once every task has finished, the post hook starts the reclaim of the
1149
+ * superseded Cargo unit generations of each Cargo workspace the run built into, in a process of its own, never on
1150
+ * Nx's thread (`@smoothbricks/cargo-retain`).
1193
1151
  */
1194
1152
  export const preTasksExecution: PreTasksExecution<ProducerReceiptsOptions> = async (options, context) => {
1195
1153
  // Before any task is hashed: a workspace that declares the test-walk check
@@ -2354,12 +2312,56 @@ async function createProjectTargets(
2354
2312
  ],
2355
2313
  ...(lintCommands.length > 0
2356
2314
  ? {
2357
- options: { commands: lintCommands, cwd: '.' },
2315
+ options: {
2316
+ commands: lintCommands,
2317
+ cwd: '.',
2318
+ ...(eslintFileSet === null ? {} : { eslintProjectRoot: projectRoot }),
2319
+ } satisfies AllVerdictsOptions,
2358
2320
  }
2359
2321
  : {}),
2360
2322
  };
2361
2323
  }
2362
2324
 
2325
+ // The process-lineage entry has no full API-generator dependency: the generator check itself is bounded work.
2326
+ const lineageProducer = nativeToolDependsOn(nativeTools, 'cowshed', 'lineage-js');
2327
+ if (lineageProducer.length > 0 && packageJson.name === '@smoothbricks/nx-plugin') {
2328
+ for (const name of ['tsc-js', 'typecheck', 'typecheck-tests']) {
2329
+ const target = targets[name];
2330
+ if (target === undefined) continue;
2331
+ target.dependsOn = [...(target.dependsOn ?? []), ...lineageProducer];
2332
+ target.inputs = [
2333
+ ...(target.inputs ?? ['production']),
2334
+ { dependentTasksOutputFiles: '**/dist/lineage/**/*', transitive: false },
2335
+ ];
2336
+ }
2337
+ }
2338
+
2339
+ // Runtime observers need the local addon, not the package aggregate (which can deliberately build only JS).
2340
+ // Declarations retain these prerequisites and output inputs with Nx's ordinary "..." merge token.
2341
+ // The canonical release-check instead judges prebuilt shipping artifacts and must remain dependency-free.
2342
+ const observerProducers = [...nativeToolDependsOn(nativeTools, 'cowshed'), ...lineageProducer];
2343
+ if (observerProducers.length > 0) {
2344
+ for (const name of new Set([...Object.keys(targets), ...Object.keys(declaredTargets)])) {
2345
+ const declared = declaredTargets[name];
2346
+ const executor =
2347
+ isRecord(declared) && declared.executor !== undefined ? declared.executor : targets[name]?.executor;
2348
+ if (executor !== '@smoothbricks/nx-plugin:bounded-exec' || name === 'release-check') continue;
2349
+ // Nx discards an incompatible executor's inferred configuration; only the observer prerequisites belong below it.
2350
+ if (targets[name]?.executor !== undefined && targets[name]?.executor !== executor) {
2351
+ targets[name] = {};
2352
+ }
2353
+ targets[name] ??= {};
2354
+ const target = targets[name];
2355
+ target.dependsOn = [...(target.dependsOn ?? []), ...observerProducers];
2356
+ const inputs =
2357
+ target.inputs ?? (isRecord(declared) && Array.isArray(declared.inputs) ? [] : ['default', '^production']);
2358
+ target.inputs = [
2359
+ ...inputs,
2360
+ { dependentTasksOutputFiles: '**/*.node', transitive: true },
2361
+ { dependentTasksOutputFiles: '**/dist/lineage/**/*.js', transitive: true },
2362
+ ];
2363
+ }
2364
+ }
2363
2365
  // Publish each inferred target's semantic kind (`inferredTaskKind`) as metadata. Nx merges metadata beneath a
2364
2366
  // declaration, so the final graph still says which tasks are build and which are test work after a package rewrites
2365
2367
  // one. Fresh objects: `CARGO_PRODUCER_METADATA` is shared by every producer.
@@ -2386,7 +2388,9 @@ async function createProjectTargets(
2386
2388
  [VERSIONLESS_PRODUCTION_INPUT]: ['production', ...versionlessProjectInputs],
2387
2389
  [VERSIONLESS_DEFAULT_INPUT]: ['default', ...versionlessProjectInputs],
2388
2390
  }),
2389
- ...(Object.keys(targets).some((name) => name.startsWith('cargo-') || name.startsWith('napi-'))
2391
+ ...([...Object.keys(targets), ...Object.keys(declaredTargets)].some(
2392
+ (name) => name.startsWith('cargo-') || name.startsWith('napi-'),
2393
+ )
2390
2394
  ? { [CARGO_TOOLCHAIN_NAMED_INPUT]: cargoToolchainInputs() }
2391
2395
  : {}),
2392
2396
  };
@@ -211,6 +211,12 @@ const managedFiles: ManagedFileDescriptor[] = [
211
211
  target: 'tooling/git-hooks/pre-push.sh',
212
212
  executable: true,
213
213
  },
214
+ {
215
+ kind: 'raw',
216
+ source: 'tooling/git-reword-commit',
217
+ target: 'tooling/git-reword-commit',
218
+ executable: true,
219
+ },
214
220
  {
215
221
  kind: 'raw',
216
222
  source: 'git-format-staged.yml',