@smoothbricks/nx-plugin 0.7.2 → 0.7.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 (74) hide show
  1. package/README.md +118 -118
  2. package/dist/.build-inputs.json +18 -18
  3. package/dist/cargo-toolchain-paths.d.ts +1 -1
  4. package/dist/cargo-toolchain-paths.js +1 -1
  5. package/dist/cargo-toolchain-policy.d.ts +2 -2
  6. package/dist/cargo-toolchain-policy.js +2 -2
  7. package/dist/cross-check-policy.d.ts +25 -30
  8. package/dist/cross-check-policy.d.ts.map +1 -1
  9. package/dist/cross-check-policy.js +27 -31
  10. package/dist/ensure-built-witness.js +727 -450
  11. package/dist/ensure-built.js +2 -2
  12. package/dist/executors/bounded-exec/bounds.d.ts +6 -3
  13. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
  14. package/dist/executors/bounded-exec/bounds.js +9 -2
  15. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  16. package/dist/executors/bounded-exec/executor.js +24 -19
  17. package/dist/executors/bounded-exec/mbx-pool.d.ts +13 -16
  18. package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
  19. package/dist/executors/bounded-exec/mbx-pool.js +24 -28
  20. package/dist/executors/bounded-exec/runner-lifecycle.d.ts +2 -0
  21. package/dist/executors/bounded-exec/runner-lifecycle.d.ts.map +1 -1
  22. package/dist/executors/bounded-exec/runner-lifecycle.js +9 -5
  23. package/dist/executors/bounded-exec/runner-sizing.d.ts +6 -1
  24. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
  25. package/dist/executors/bounded-exec/runner-sizing.js +7 -2
  26. package/dist/executors/bounded-exec/schema.d.ts +12 -3
  27. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  28. package/dist/executors/cargo-zigbuild/executor.d.ts +10 -0
  29. package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
  30. package/dist/executors/cargo-zigbuild/executor.js +36 -2
  31. package/dist/index.js +9 -7
  32. package/dist/managed-files/files.d.ts +4 -4
  33. package/dist/managed-files/files.js +4 -4
  34. package/dist/owned-installation.d.ts.map +1 -1
  35. package/dist/owned-installation.js +4 -2
  36. package/dist/producer-receipts.js +476 -402
  37. package/dist/task-graph-policy.js +1 -1
  38. package/dist/testing.d.ts +8 -0
  39. package/dist/testing.d.ts.map +1 -1
  40. package/dist/testing.js +15 -0
  41. package/dist/workspace-config-policy.d.ts +1 -1
  42. package/dist/workspace-config-policy.js +1 -1
  43. package/dist/workspace-manifest.d.ts +5 -0
  44. package/dist/workspace-manifest.d.ts.map +1 -1
  45. package/managed/raw/patches/{nx@23.2.1.patch → nx@24.0.3.patch} +1397 -2174
  46. package/managed/raw/tooling/direnv/devenv.smoo.nix +30 -31
  47. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +4 -0
  48. package/managed/raw/tooling/git-hooks/pre-push.sh +21 -21
  49. package/managed/templates/github/actions/setup-devenv/action.yml +20 -5
  50. package/package.json +4 -3
  51. package/runtime/nx-publish/.build-inputs.json +2 -2
  52. package/runtime/nx-publish/cache_adapter.js +24 -11
  53. package/runtime/nx-publish/nx_publish.js +2 -1
  54. package/runtime-input.sh +1 -1
  55. package/src/cargo-toolchain-paths.ts +1 -1
  56. package/src/cargo-toolchain-policy.ts +2 -2
  57. package/src/cross-check-policy.ts +29 -32
  58. package/src/ensure-built.ts +2 -2
  59. package/src/executors/bounded-exec/bounds.ts +13 -4
  60. package/src/executors/bounded-exec/executor.ts +27 -29
  61. package/src/executors/bounded-exec/mbx-pool.ts +36 -30
  62. package/src/executors/bounded-exec/runner-lifecycle.ts +13 -6
  63. package/src/executors/bounded-exec/runner-sizing.ts +8 -2
  64. package/src/executors/bounded-exec/schema.json +5 -1
  65. package/src/executors/bounded-exec/schema.ts +12 -3
  66. package/src/executors/cargo-zigbuild/executor.ts +42 -2
  67. package/src/index.ts +9 -5
  68. package/src/managed-files/files.ts +4 -4
  69. package/src/owned-installation.ts +4 -2
  70. package/src/task-graph-policy.ts +1 -1
  71. package/src/testing.ts +13 -0
  72. package/src/workspace-config-policy.ts +1 -1
  73. package/src/workspace-manifest.ts +5 -0
  74. package/test-timings.json +2 -0
@@ -505,7 +505,7 @@ async function probeBuiltInWorkspace(workspaceRoot, selector) {
505
505
  * pin; opaque commands and unavailable native proof categorically refuse.
506
506
  */
507
507
  export function providerInputProof(workspaceRoot, nxJson, projectGraph, taskGraph, requireNx) {
508
- const { WorkspaceContext, HashPlanInspector, HashPlanner, transferProjectGraph } = requireNx('nx/src/native');
508
+ const { WorkspaceContext, HashPlanInspector, HashPlanner } = requireNx('nx/src/native');
509
509
  const { transformProjectGraphForRust } = requireNx('nx/src/native/transform-objects');
510
510
  const { createProjectRootMappings } = requireNx('nx/src/project-graph/utils/find-project-for-path');
511
511
  const { workspaceDataDirectoryForWorkspace } = requireNx('nx/src/utils/cache-directory');
@@ -519,7 +519,7 @@ export function providerInputProof(workspaceRoot, nxJson, projectGraph, taskGrap
519
519
  runtimeSource: { kind: 'opaque', detail: 'Nx supplied no native file-input proof' },
520
520
  };
521
521
  }
522
- const planner = new HashPlanner(nxJson, transferProjectGraph(transformProjectGraphForRust(projectGraph)));
522
+ const planner = new HashPlanner(nxJson, transformProjectGraphForRust(projectGraph));
523
523
  const inspector = new HashPlanInspector(externalReferences.allWorkspaceFiles, externalReferences.projectFiles, workspaceRoot);
524
524
  const inputs = inspector.inspectInputs(planner.getPlansReference(Object.keys(taskGraph.tasks), taskGraph));
525
525
  const files = new Set();
@@ -3,7 +3,8 @@
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
- * - A scheduled leaf arms nothing until its first grant. Later zero-hold intervals pause only the idle budget.
6
+ * - A scheduled leaf arms nothing until its first grant, but for a fixture that runs before its reservation, whose
7
+ * ceiling starts at spawn. Later zero-hold intervals pause only the idle budget.
7
8
  * - Any explicitly queued task process pauses idle, including alongside held grants; ceilings keep running.
8
9
  * - The fixture ceiling ends with its segment. The idle clock also stops outside the testing lifecycle.
9
10
  * - Finished tests reset the idle budget whether their release byte arrived before or after their output.
@@ -16,7 +17,7 @@ export interface BoundLimits {
16
17
  }
17
18
  /**
18
19
  * 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
+ * its pool's grant, so none is armed yet but a fixture ceiling started at spawn (`fixtureFirst`).
20
21
  */
21
22
  export interface Bounds {
22
23
  readonly idle: number | null;
@@ -31,7 +32,8 @@ export type BoundKind = 'idle' | 'fixture' | 'total';
31
32
  export type BoundEvent =
32
33
  /**
33
34
  * 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
+ * `queued` whether mbx schedules this leaf, as known before spawn, and `fixtureFirst` whether that fixture runs
36
+ * before the leaf's reservation (it counts the leaf's units), so its ceiling starts now, not at the grant.
35
37
  */
36
38
  {
37
39
  readonly kind: 'spawn';
@@ -39,6 +41,7 @@ export type BoundEvent =
39
41
  readonly testing: boolean;
40
42
  readonly fixture: boolean;
41
43
  readonly queued: boolean;
44
+ readonly fixtureFirst: boolean;
42
45
  }
43
46
  /** Each admission begins a hold; the first one starts the queued leaf's ceilings. */
44
47
  | {
@@ -1 +1 @@
1
- {"version":3,"file":"bounds.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/bounds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;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;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QA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AAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACxF;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5D,MAAM,MAAM,kBAAkB,GAC1B;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAC7E;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD,eAAO,MAAM,iBAAiB,EAAE,aAA+D,CAAC;AAEhG,2GAA2G;AAC3G,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED,0GAA0G;AAC1G,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,kBAAkB,GAAG,aAAa,CAK/F"}
@@ -3,7 +3,8 @@
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
- * - A scheduled leaf arms nothing until its first grant. Later zero-hold intervals pause only the idle budget.
6
+ * - A scheduled leaf arms nothing until its first grant, but for a fixture that runs before its reservation, whose
7
+ * ceiling starts at spawn. Later zero-hold intervals pause only the idle budget.
7
8
  * - Any explicitly queued task process pauses idle, including alongside held grants; ceilings keep running.
8
9
  * - The fixture ceiling ends with its segment. The idle clock also stops outside the testing lifecycle.
9
10
  * - Finished tests reset the idle budget whether their release byte arrived before or after their output.
@@ -34,7 +35,13 @@ export function stepBounds(bounds, limits, event) {
34
35
  switch (event.kind) {
35
36
  case 'spawn':
36
37
  return event.queued
37
- ? { ...UNARMED, queued: true, holds: 0, idleRemaining: limits.idleMs ?? null }
38
+ ? {
39
+ ...UNARMED,
40
+ queued: true,
41
+ holds: 0,
42
+ idleRemaining: limits.idleMs ?? null,
43
+ fixture: event.fixtureFirst && limits.fixtureMs !== undefined ? event.at + limits.fixtureMs : null,
44
+ }
38
45
  : armed(limits, event.at, event.testing, event.fixture);
39
46
  case 'granted': {
40
47
  if (bounds.holds === null)
@@ -1 +1 @@
1
- {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/executor.ts"],"names":[],"mappings":"AA0BA,OAAO,EAIL,KAAK,gBAAgB,EAItB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,sBAAsB,EAAmB,MAAM,uBAAuB,CAAC;AAYhF,OAAO,EAA4C,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAE5F,OAAO,EAOL,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EASL,aAAa,EAEd,MAAM,eAAe,CAAC;AAIvB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAGL,KAAK,eAAe,EAerB,MAAM,cAAc,CAAC;AAuBtB,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,wFAAwF;IACxF,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,eAAe,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACtD,uFAAuF;IACvF,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED,qEAAqE;AACrE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,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,EAAE,kBAAkB,EAC3B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAc5B;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,UAAU,GAAG,IAAI,GACzD,OAAO,CAAC,iBAAiB,CAAC,CAsB5B;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,kBAAkB,CAiBxE;AAED;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,iBAAiB,EACzB,UAAU,EAAE,UAAU,GAAG,IAAI,EAC7B,SAAS,GAAE,gBAAgB,GAAG,IAAW,EACzC,kBAAkB,GAAE,OAAO,sBAA+C,EAC1E,KAAK,GAAE,YAAY,GAAG,IAAW,EACjC,SAAS,CAAC,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,GACjD,OAAO,CAAC,iBAAiB,CAAC,CAkiC5B;AAED,wBAAgB,uBAAuB,IAAI,iBAAiB,CAM3D"}
@@ -11,7 +11,7 @@ import { admissionWaitMs, earliestBound, NO_ADMISSION_WAIT, stepAdmissionWait, s
11
11
  import { CPU_POOL_ENV, createCpuPool, readInheritedCpuPool, takeParentCpuTokens, } from './cpu-pool.js';
12
12
  import { GATEWAY_SOCKET } from './gateway-lease.js';
13
13
  import { captureHangDiagnostics, HANG_CAPTURE_MS } from './hang-diagnostics.js';
14
- import { MBX_GRANT_FD, mbxIdleGated, mbxLeaf, mbxPool, nxTaskCores, runsPrebuiltNextest, withMbxLeaf, } from './mbx-pool.js';
14
+ import { MBX_GRANT_FD, mbxIdleGated, mbxLeaf, mbxPool, withCountedReservation, withMbxLeaf } from './mbx-pool.js';
15
15
  import { MBX_QUEUE_POLL_MS, snapshotMbxQueue } from './mbx-queue.js';
16
16
  import { createNoSpaceWatch } from './no-space.js';
17
17
  import { COWSHED_EXECUTABLE_ENV, cowshedSubtreeOwner, HANDLE_FD, readAdmission, SUPERVISOR_SOCKET_ENV, } from './owned-subtree.js';
@@ -196,10 +196,11 @@ export async function runBoundedExec(options, context, killer, tempVolume, inher
196
196
  }
197
197
  };
198
198
  // The fixture pair names one segment: a fixture with no build budget, or a budget with no fixture, is a
199
- // target that does not say what it runs, so it does not run.
199
+ // target that does not say what it runs, so it does not run. Units are counted at the end of that segment.
200
200
  if ((options.fixtureCommand === undefined) !== (options.fixtureTimeoutMs === undefined) ||
201
+ (options.unitsCommand !== undefined && options.fixtureCommand === undefined) ||
201
202
  (fixture !== null && !(fixture.timeoutMs > 0))) {
202
- appendStderr('bounded-exec: fixtureCommand and a positive fixtureTimeoutMs must be named together; refusing to run the command\n');
203
+ appendStderr('bounded-exec: fixtureCommand and a positive fixtureTimeoutMs must be named together, and unitsCommand only with them; refusing to run the command\n');
203
204
  if (context.record !== undefined) {
204
205
  const { task, directory: recordDirectory } = context.record;
205
206
  await writeRecord(recordDirectory, { task: task.id, hash: task.hash, verdict: judgeOperationalFailure(1, null) });
@@ -210,7 +211,7 @@ export async function runBoundedExec(options, context, killer, tempVolume, inher
210
211
  // CPU tokens: a refusal that waited in its pool's queue first would say nothing for minutes.
211
212
  const runtime = await checkRuntimePin({
212
213
  root: context.root,
213
- command: fixture === null ? requested : `${fixture.command} && ${requested}`,
214
+ command: [fixture?.command, options.unitsCommand, requested].filter((part) => part !== undefined).join(' && '),
214
215
  env: { ...withoutPoolEnv(process.env), ...options.env },
215
216
  cwd,
216
217
  pathSource: options.env?.PATH === undefined ? 'the inherited environment' : "the target's env",
@@ -353,11 +354,8 @@ export async function runBoundedExec(options, context, killer, tempVolume, inher
353
354
  // (`run-cpu-pool.ts`), so a task takes its tokens from a parent's pool; a command that inherits none runs exactly as
354
355
  // asked and nothing is said.
355
356
  const cores = availableParallelism();
356
- // A prebuilt nextest leaf under mbx asks for its task's share of the host (`nxTaskCores`), not every core: it knows
357
- // no count of its tests. A declared or named count still wins.
358
357
  const mbx = mbxPool(process.env);
359
- const leafCores = mbx !== null && runsPrebuiltNextest(requested) ? nxTaskCores(cores, { ...process.env, ...options.env }) : cores;
360
- const demand = runnerDemand(requested, options.parallelism, leafCores, process.env, options.env);
358
+ const demand = runnerDemand(requested, options.parallelism, cores, process.env, options.env);
361
359
  const asked = Date.now();
362
360
  // A pool that answered and refused is a live budget, and running beside it would count the run twice: the run fails
363
361
  // instead. A pool whose endpoint is gone (its holder exited) lends nothing, and the run goes on as asked.
@@ -522,20 +520,23 @@ export async function runBoundedExec(options, context, killer, tempVolume, inher
522
520
  ...(leaf?.kind === 'cargo' ? { MBX_GRANT_FD: String(MBX_GRANT_FD) } : {}),
523
521
  };
524
522
  // A fixture rides as segment 0 of the lifecycle. Without the channel (Windows) it is plain shell text ahead
525
- // of the command: the progress bound runs during it and its own ceiling does not.
526
- const hooked = process.platform === 'win32'
527
- ? null
528
- : fixture === null
529
- ? withRunnerLifecycle(command)
530
- : withFixtureLifecycle(fixture.command, command);
523
+ // of the command: the progress bound runs during it and its own ceiling does not. Under mbx a leaf that names its
524
+ // units counts them at the end of that segment, under the fixture's ceiling, its fixture's own output on stderr, and
525
+ // reserves after it (`withCountedReservation`).
526
+ const counted = process.platform !== 'win32' && leaf?.kind === 'reserve' && fixture !== null && options.unitsCommand !== undefined;
527
+ const segment = fixture === null ? null : counted ? `{ ${fixture.command}; } >&2 && ${options.unitsCommand}` : fixture.command;
528
+ const fixtureHooked = process.platform === 'win32' || segment === null ? null : withFixtureLifecycle(segment, command);
529
+ const hooked = process.platform === 'win32' ? null : (fixtureHooked ?? withRunnerLifecycle(command));
531
530
  const lifecycle = hooked === null ? null : createRunnerLifecycle(hooked.runners);
532
531
  let lifecycleFailure = null;
533
532
  const isTesting = () => lifecycleFailure !== null || (lifecycle?.isTesting() ?? true);
534
533
  const startedAt = Date.now();
535
534
  // With a supervisor, `cowshed subtree-root` asks it for a handle on itself, writes the answer to the handle
536
535
  // descriptor, and execs `/bin/sh -c command` in the same process: the command's pid, group and life are unchanged.
537
- const unadmitted = hooked?.command ?? (fixture === null ? command : `${fixture.command} && ${command}`);
538
- const shellCommand = withMbxLeaf(unadmitted, leaf);
536
+ const unadmitted = hooked?.command ?? (segment === null ? command : `${segment} && ${command}`);
537
+ const shellCommand = leaf?.kind === 'reserve' && counted && fixtureHooked !== null
538
+ ? withCountedReservation(fixtureHooked.fixture, fixtureHooked.main, leaf)
539
+ : withMbxLeaf(unadmitted, leaf);
539
540
  // Only leaves known to be scheduled can exclude zero-hold time. Others keep lifecycle hang protection.
540
541
  const queued = mbxIdleGated(leaf, sized.command, { ...process.env, ...env });
541
542
  // fd 4 is unused without a subtree admission, so the grant takes fd 5 either way.
@@ -737,6 +738,9 @@ export async function runBoundedExec(options, context, killer, tempVolume, inher
737
738
  const refreshQueue = async (fresh) => {
738
739
  if (fresh && queueSnapshot !== null)
739
740
  await queueSnapshot;
741
+ // A leaf that counts its units before reserving waits in no reservation queue while its fixture builds.
742
+ if (counted && !fixtureDone)
743
+ return;
740
744
  if (state.settled || state.expiry !== null || queueAbort.signal.aborted || child.pid === undefined)
741
745
  return;
742
746
  const pid = child.pid;
@@ -938,7 +942,7 @@ export async function runBoundedExec(options, context, killer, tempVolume, inher
938
942
  ? ''
939
943
  : `The last mbx admission snapshot failed (${unconfirmedAdmission}), so the wait it could not confirm earned no idle credit\n`}`
940
944
  : bound.kind === 'fixture'
941
- ? `\nFixture command timed out after ${elapsedMs}ms (fixtureTimeoutMs=${bound.limitMs}, cwd=${cwd}): ${fixture?.command ?? command}\n`
945
+ ? `\nFixture command timed out after ${elapsedMs}ms (fixtureTimeoutMs=${bound.limitMs}, cwd=${cwd}): ${segment ?? command}\n`
942
946
  : `\nCommand timed out after ${elapsedMs}ms (timeoutMs=${bound.limitMs}, cwd=${cwd}): ${command}\n`);
943
947
  if (bound.kind === 'idle') {
944
948
  const observed = idleCapture?.result;
@@ -1021,6 +1025,7 @@ export async function runBoundedExec(options, context, killer, tempVolume, inher
1021
1025
  at: Date.now(),
1022
1026
  testing: isTesting(),
1023
1027
  fixture: fixture !== null && lifecycle !== null,
1028
+ fixtureFirst: counted && lifecycle !== null,
1024
1029
  queued,
1025
1030
  });
1026
1031
  // Read every byte after spawn accounting: a chunk can contain several grants and releases. EOF is neither.
@@ -1043,7 +1048,7 @@ export async function runBoundedExec(options, context, killer, tempVolume, inher
1043
1048
  mbxAdmitted = true;
1044
1049
  said = true;
1045
1050
  tell(leaf.kind === 'reserve'
1046
- ? `cowshed: mbx reserve granted elapsed=${Date.now() - startedAt}ms asked=${leaf.demand.want} priority=${leaf.priority}\n`
1051
+ ? `cowshed: mbx reserve granted elapsed=${Date.now() - startedAt}ms priority=${leaf.priority}\n`
1047
1052
  : `cowshed: mbx cargo granted elapsed=${Date.now() - startedAt}ms\n`);
1048
1053
  }
1049
1054
  stepTo({ kind: 'granted', at: Date.now(), testing: isTesting(), fixture: !fixtureDone });
@@ -1095,7 +1100,7 @@ export async function runBoundedExec(options, context, killer, tempVolume, inher
1095
1100
  const code = exitCode ?? signalToExitCode(exitSignal);
1096
1101
  if (code !== 0 && state.expiry === null) {
1097
1102
  appendStderr(fixture !== null && !mainStarted
1098
- ? `Fixture command exited with status ${code}: ${fixture.command}\n`
1103
+ ? `Fixture command exited with status ${code}: ${segment ?? fixture.command}\n`
1099
1104
  : `Command exited with status ${code}: ${command}\n`);
1100
1105
  }
1101
1106
  if (state.expiry !== null && !state.forceKillNeeded) {
@@ -34,6 +34,10 @@ export type MbxLeaf = {
34
34
  readonly priority: 'normal' | 'low';
35
35
  readonly demand: ReservedDemand;
36
36
  };
37
+ /** A leaf mbx's pool reserves for. */
38
+ export type ReservedLeaf = Extract<MbxLeaf, {
39
+ kind: 'reserve';
40
+ }>;
37
41
  /** Whether `command` runs nextest over test binaries already built, which compiles nothing. */
38
42
  export declare function runsPrebuiltNextest(command: string): boolean;
39
43
  /**
@@ -44,18 +48,6 @@ export declare function runsPrebuiltNextest(command: string): boolean;
44
48
  * cores busy while 25 of its tasks queued a minute or more, and a gate's Go test leaf waited 401 s for all 18 cores.
45
49
  */
46
50
  export declare function mbxLeaf(pool: MbxPool, demand: Demand, command: string): MbxLeaf | null;
47
- /**
48
- * The cores one task of an Nx run counts as its own: the host's cores divided among the tasks Nx runs at once, at
49
- * least one. Nx reads that count from `NX_PARALLEL`, a number or a share of the cores (`100%`), else runs three.
50
- *
51
- * A prebuilt nextest leaf asks for this share rather than its runner's own count, every core by default, because it
52
- * does not know how many tests it runs: mbx grants a reservation as many of its cores as are free, so a leaf of a few
53
- * long tests asking for every core would hold the idle rest for its whole run (specs/cowshed/05_gateway.md, "Open
54
- * questions"). Before mbx granted reservations their free cores, every cargo-test leaf of a gate reserved the whole
55
- * pool and they ran one at a time: on 2026-10-30 a gate's 18-core host ran 4.2 cores busy, its leaves each holding
56
- * `mbx reserve --cpus 18`.
57
- */
58
- export declare function nxTaskCores(cores: number, environment: Readonly<NodeJS.ProcessEnv>): number;
59
51
  /**
60
52
  * Only a known scheduled execution may stop its idle clock at zero holds. Plain Cargo tests can run doctests;
61
53
  * archive-file targets, direct binaries and other runners are not proven scheduled at spawn (11_shell.md,
@@ -68,10 +60,15 @@ export declare function mbxIdleGated(leaf: MbxLeaf | null, command: string, envi
68
60
  */
69
61
  export declare const MBX_GRANT_FD = 5;
70
62
  /**
71
- * `command` as the shell runs it under its leaf's admission, or as it is for a leaf in no pool (`null`). A reserved leaf
72
- * asks for its runner's count, and its reservation first sizes the runner to what mbx granted (`grantedSizing`) and says
73
- * so on stderr. `mbx` is the canonical environment's, whose realpath cowshed's admission proved to be the host's pinned
74
- * mbx; it writes the grant on this descriptor itself.
63
+ * `command` as the shell runs it under its leaf's admission, or as it is for a leaf in no pool (`null`): a reserved
64
+ * leaf asks for its runner's count (`reservation`).
75
65
  */
76
66
  export declare function withMbxLeaf(command: string, leaf: MbxLeaf | null): string;
67
+ /**
68
+ * A reserved leaf whose `fixture` segment ends by printing one line per unit its `command` runs (`unitsCommand`): the
69
+ * segment runs first, outside the reservation, since a build's compilers are admitted by mbx one by one, and the leaf
70
+ * asks for its units, at most its runner's count and at least one. A segment that fails fails the run before anything
71
+ * is reserved.
72
+ */
73
+ export declare function withCountedReservation(fixture: string, command: string, leaf: ReservedLeaf): string;
77
74
  //# sourceMappingURL=mbx-pool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mbx-pool.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/mbx-pool.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,KAAK,MAAM,EAAiC,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGrH;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,CAAC;CACrC;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,OAAO,GAAG,IAAI,CAKhF;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,OAAO,GACf;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC1B;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;CACjC,CAAC;AAKN,+FAA+F;AAC/F,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAoBtF;AAKD;;;;;;;;;;GAUG;AACH,wB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+F;AAC/F,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAoBtF;AAQD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,OAAO,CAkDrH;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,IAAI,CAAC;AAE9B;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,GAAG,MAAM,CAKzE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,MAAM,CAInG"}
@@ -1,5 +1,5 @@
1
1
  import { shellTokens } from '../../runtime-input-policy.js';
2
- import { CPU_TOKENS_ENV, grantedSizing, invocationSpan } from './runner-sizing.js';
2
+ import { CPU_TOKENS_ENV, grantedSizing, invocationSpan, WANT_ENV, } from './runner-sizing.js';
3
3
  import { shellQuote } from './verdict.js';
4
4
  /**
5
5
  * The pool the environment names, or `null` where the project has no mbx and cowshed's own pools apply unchanged, or
@@ -48,26 +48,6 @@ export function mbxLeaf(pool, demand, command) {
48
48
  return reserve(demand);
49
49
  }
50
50
  }
51
- /** Nx's own default count of tasks at once, when nothing names one. */
52
- const NX_DEFAULT_PARALLEL = 3;
53
- /**
54
- * The cores one task of an Nx run counts as its own: the host's cores divided among the tasks Nx runs at once, at
55
- * least one. Nx reads that count from `NX_PARALLEL`, a number or a share of the cores (`100%`), else runs three.
56
- *
57
- * A prebuilt nextest leaf asks for this share rather than its runner's own count, every core by default, because it
58
- * does not know how many tests it runs: mbx grants a reservation as many of its cores as are free, so a leaf of a few
59
- * long tests asking for every core would hold the idle rest for its whole run (specs/cowshed/05_gateway.md, "Open
60
- * questions"). Before mbx granted reservations their free cores, every cargo-test leaf of a gate reserved the whole
61
- * pool and they ran one at a time: on 2026-10-30 a gate's 18-core host ran 4.2 cores busy, its leaves each holding
62
- * `mbx reserve --cpus 18`.
63
- */
64
- export function nxTaskCores(cores, environment) {
65
- const named = environment.NX_PARALLEL?.trim() ?? '';
66
- const share = /^(\d+)%$/.exec(named);
67
- const count = share?.[1] !== undefined ? (cores * Number(share[1])) / 100 : /^\d+$/.test(named) ? Number(named) : 0;
68
- const parallel = count >= 1 ? Math.floor(count) : NX_DEFAULT_PARALLEL;
69
- return Math.max(1, Math.floor(cores / parallel));
70
- }
71
51
  /**
72
52
  * The value an in-place runner gives `--target-dir-remap`: smoo-nx-nextest-binaries' answer, quoted. The plugin infers
73
53
  * the native helper; a repository's own runner may name its script through bun, which prints the same path.
@@ -143,16 +123,32 @@ export function mbxIdleGated(leaf, command, environment) {
143
123
  */
144
124
  export const MBX_GRANT_FD = 5;
145
125
  /**
146
- * `command` as the shell runs it under its leaf's admission, or as it is for a leaf in no pool (`null`). A reserved leaf
147
- * asks for its runner's count, and its reservation first sizes the runner to what mbx granted (`grantedSizing`) and says
148
- * so on stderr. `mbx` is the canonical environment's, whose realpath cowshed's admission proved to be the host's pinned
149
- * mbx; it writes the grant on this descriptor itself.
126
+ * `command` as the shell runs it under its leaf's admission, or as it is for a leaf in no pool (`null`): a reserved
127
+ * leaf asks for its runner's count (`reservation`).
150
128
  */
151
129
  export function withMbxLeaf(command, leaf) {
152
130
  if (leaf === null || leaf.kind === 'cargo') {
153
131
  return command;
154
132
  }
155
- const asked = leaf.demand.want;
156
- const said = `printf 'cowshed: mbx reserve running cpus=%s asked=${asked}\\n' "$${CPU_TOKENS_ENV}" >&2; `;
157
- return `mbx reserve --grant-fd ${MBX_GRANT_FD} --cpus ${asked} --priority ${leaf.priority} -- /bin/sh -c ${shellQuote(`${grantedSizing(leaf.demand)}${said}${command}`)}`;
133
+ return `${WANT_ENV}=${leaf.demand.want} && ${reservation(command, leaf)}`;
134
+ }
135
+ /**
136
+ * A reserved leaf whose `fixture` segment ends by printing one line per unit its `command` runs (`unitsCommand`): the
137
+ * segment runs first, outside the reservation, since a build's compilers are admitted by mbx one by one, and the leaf
138
+ * asks for its units, at most its runner's count and at least one. A segment that fails fails the run before anything
139
+ * is reserved.
140
+ */
141
+ export function withCountedReservation(fixture, command, leaf) {
142
+ const most = leaf.demand.want;
143
+ const count = `n=0; while IFS= read -r unit; do if [ -n "$unit" ]; then n=$((n + 1)); fi; done; echo "$(( n < 1 ? 1 : n < ${most} ? n : ${most} ))"`;
144
+ return `bounded_exec_units=$(${fixture}) && ${WANT_ENV}=$(printf '%s\\n' "$bounded_exec_units" | { ${count}; }) && ${reservation(command, leaf)}`;
145
+ }
146
+ /**
147
+ * The reservation of `WANT_ENV` cores, set by the caller, that runs `command` once mbx grants it: the reservation sizes
148
+ * the runner to what mbx granted (`grantedSizing`) and says so on stderr. `mbx` is the canonical environment's, whose
149
+ * realpath cowshed's admission proved to be the host's pinned mbx; it writes the grant on this descriptor itself.
150
+ */
151
+ function reservation(command, leaf) {
152
+ const said = `printf 'cowshed: mbx reserve running cpus=%s asked=%s\\n' "$${CPU_TOKENS_ENV}" "$${WANT_ENV}" >&2; `;
153
+ return `export ${WANT_ENV} && mbx reserve --grant-fd ${MBX_GRANT_FD} --cpus "$${WANT_ENV}" --priority ${leaf.priority} -- /bin/sh -c ${shellQuote(`${grantedSizing(leaf.demand)}${said}${command}`)}`;
158
154
  }
@@ -20,6 +20,8 @@ export declare function withRunnerLifecycle(command: string, firstId?: number):
20
20
  export declare function withFixtureLifecycle(fixtureCommand: string, command: string): {
21
21
  command: string;
22
22
  runners: number;
23
+ fixture: string;
24
+ main: string;
23
25
  };
24
26
  /** A private supervisor channel, not runner output, grants authority to pause the test clock. */
25
27
  export declare function createRunnerLifecycle(runners: number): {
@@ -1 +1 @@
1
- {"version":3,"file":"runner-lifecycle.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/runner-lifecycle.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAC;AAC1D,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,WAAW,CAAC;CACpB;AAYD,qGAAqG;AACrG,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,SAAI,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAoC7G;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAOlH;AAED,iGAAiG;AACjG,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM;IAKjD,SAAS,QAAM,OAAO;IACtB,KAAK,QAAM,MAAM,GAAG,IAAI;IACxB,QAAQ,QAAM,OAAO;IACrB,MAAM,OAAO,MAAM,GAAG,gBAAgB,GAAG,IAAI;EAmChD"}
1
+ {"version":3,"file":"runner-lifecycle.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/runner-lifecycle.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAC;AAC1D,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,WAAW,CAAC;CACpB;AAYD,qGAAqG;AACrG,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,SAAI,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAoC7G;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,MAAM,GACd;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAWrE;AAED,iGAAiG;AACjG,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM;IAKjD,SAAS,QAAM,OAAO;IACtB,KAAK,QAAM,MAAM,GAAG,IAAI;IACxB,QAAQ,QAAM,OAAO;IACrB,MAAM,OAAO,MAAM,GAAG,gBAAgB,GAAG,IAAI;EAmChD"}
@@ -59,11 +59,15 @@ export function withRunnerLifecycle(command, firstId = 0) {
59
59
  */
60
60
  export function withFixtureLifecycle(fixtureCommand, command) {
61
61
  const fixture = hookInvocation(0, 'build', `/bin/sh -c ${shellWord(fixtureCommand)}`);
62
- const main = withRunnerLifecycle(command, 1);
63
- if (main !== null) {
64
- return { command: `${fixture} && { ${main.command}; }`, runners: main.runners + 1 };
65
- }
66
- return { command: `${fixture} && ${hookInvocation(1, 'run', `/bin/sh -c ${shellWord(command)}`)}`, runners: 2 };
62
+ const hooked = withRunnerLifecycle(command, 1);
63
+ const main = hooked?.command ?? hookInvocation(1, 'run', `/bin/sh -c ${shellWord(command)}`);
64
+ const runners = (hooked?.runners ?? 1) + 1;
65
+ return {
66
+ command: hooked === null ? `${fixture} && ${main}` : `${fixture} && { ${main}; }`,
67
+ runners,
68
+ fixture,
69
+ main,
70
+ };
67
71
  }
68
72
  /** A private supervisor channel, not runner output, grants authority to pause the test clock. */
69
73
  export function createRunnerLifecycle(runners) {
@@ -73,6 +73,11 @@ export declare const CPU_TOKENS_ENV = "BOUNDED_EXEC_CPU_TOKENS";
73
73
  * as were free once one was.
74
74
  */
75
75
  export declare const GRANTED_CPUS_ENV = "MBX_RESERVE_CPUS";
76
+ /**
77
+ * The most cores a reserved leaf asks mbx for, as its reservation's shell sets it before reserving: its runner's own
78
+ * count, or fewer when it has fewer units than that (`unitsCommand`).
79
+ */
80
+ export declare const WANT_ENV = "BOUNDED_EXEC_CPU_WANT";
76
81
  type WorkerFlagKind = 'stryker' | 'vitest' | 'go-test';
77
82
  /**
78
83
  * What `command` asks for: its kind by invocation, and `declared` (the target's `parallelism`)
@@ -114,7 +119,7 @@ export declare function sizeRunner(demand: Demand, command: string, tokens: numb
114
119
  /**
115
120
  * The shell statements that run first in a reserved leaf's reservation and size its runner to the grant, which only
116
121
  * the command learns as it starts: `CPU_TOKENS_ENV` becomes the cores mbx granted (`GRANTED_CPUS_ENV`), never more
117
- * than the leaf asked for, its `--cpus` (the runner's own count), which also stands in under an mbx that grants a
122
+ * than the leaf asked for (`WANT_ENV`, set before it reserved), which also stands in under an mbx that grants a
118
123
  * reservation whole and names none. The test-thread variables a sizing sets follow from it, under their inherited
119
124
  * ceilings, outranking the target's own as a numeric grant's do (`sizeRunner`).
120
125
  */
@@ -1 +1 @@
1
- {"version":3,"file":"runner-sizing.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/runner-sizing.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;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,CAAC;I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AAuED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAqBpG;AAOD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,OAAO,GACX,MAAM,CAKR;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAoDlD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAuB5D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAcjF;AASD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAM7E"}
1
+ {"version":3,"file":"runner-sizing.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/runner-sizing.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;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,GA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E,MAAM,EACf,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,EACtC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,GACvC,MAAM,CAiCR;AAuED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAqBpG;AAOD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,OAAO,GACX,MAAM,CAKR;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAoDlD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAuB5D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAcjF;AASD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAM7E"}
@@ -6,6 +6,11 @@ export const CPU_TOKENS_ENV = 'BOUNDED_EXEC_CPU_TOKENS';
6
6
  * as were free once one was.
7
7
  */
8
8
  export const GRANTED_CPUS_ENV = 'MBX_RESERVE_CPUS';
9
+ /**
10
+ * The most cores a reserved leaf asks mbx for, as its reservation's shell sets it before reserving: its runner's own
11
+ * count, or fewer when it has fewer units than that (`unitsCommand`).
12
+ */
13
+ export const WANT_ENV = 'BOUNDED_EXEC_CPU_WANT';
9
14
  const CARGO_BUILD = /(?<=^|[\s;&|()])(?:cargo(?:\s+-\S+)*\s+(?:build|test|check|clippy|rustc|doc|run|nextest\s+archive)|napi\s+build)(?=\s|$)/;
10
15
  const TEST_THREADS = /--test-threads(?:=|\s+)(\d+)/g;
11
16
  /** nextest's `--no-capture` (`--nocapture` past `--`): it runs tests serially and ignores `--test-threads`. */
@@ -257,12 +262,12 @@ export function sizeRunner(demand, command, tokens) {
257
262
  /**
258
263
  * The shell statements that run first in a reserved leaf's reservation and size its runner to the grant, which only
259
264
  * the command learns as it starts: `CPU_TOKENS_ENV` becomes the cores mbx granted (`GRANTED_CPUS_ENV`), never more
260
- * than the leaf asked for, its `--cpus` (the runner's own count), which also stands in under an mbx that grants a
265
+ * than the leaf asked for (`WANT_ENV`, set before it reserved), which also stands in under an mbx that grants a
261
266
  * reservation whole and names none. The test-thread variables a sizing sets follow from it, under their inherited
262
267
  * ceilings, outranking the target's own as a numeric grant's do (`sizeRunner`).
263
268
  */
264
269
  export function grantedSizing(demand) {
265
- const asked = demand.want;
270
+ const asked = `$${WANT_ENV}`;
266
271
  const named = `\${${GRANTED_CPUS_ENV}:-${asked}}`;
267
272
  const tokens = `$${CPU_TOKENS_ENV}`;
268
273
  const atMost = (ceiling) => ceiling === null ? `"${tokens}"` : `"$(( ${tokens} < ${ceiling} ? ${tokens} : ${ceiling} ))"`;
@@ -29,9 +29,11 @@ export interface BoundedExecCommand {
29
29
  idleTimeoutMs?: number;
30
30
  killAfterMs?: number;
31
31
  /**
32
- * A compiler-fixture producer for `command`: a shell command run first, in the same cwd, environment and CPU
33
- * grant, whose whole life is a lifecycle build interval — the progress bound does not run during it, as it does
34
- * not run during a `cargo test` build. Its failure fails the run; `command` starts only after it exits 0.
32
+ * A compiler-fixture producer for `command`: a shell command run first, in the same cwd and environment, inside
33
+ * the run's CPU grant; under mbx inside its leaf's reservation, or before it when `unitsCommand` counts the leaf's
34
+ * units, since then the fixture is a build whose compilers mbx admits one by one.
35
+ * Its whole life is a lifecycle build interval — the progress bound does not run during it, as it does not run
36
+ * during a `cargo test` build. Its failure fails the run; `command` starts only after it exits 0.
35
37
  *
36
38
  * It exists for warmth that lives outside Nx outputs (a compiler plugin cache, a Cargo target directory). As a
37
39
  * separate `cache: false` prerequisite that warmth was paid even when every consumer then hit the cache, since
@@ -45,6 +47,13 @@ export interface BoundedExecCommand {
45
47
  * only the fixture interval, never the command it prepares.
46
48
  */
47
49
  fixtureTimeoutMs?: number;
50
+ /**
51
+ * A shell command that prints one line per unit `command` runs (a test, a file), run at the end of the fixture
52
+ * segment, under its ceiling; refused without `fixtureCommand`. A leaf that mbx's pool reserves for asks for no more
53
+ * cores than it prints lines, at least one: a run of two slow tests holds two cores, not every core its runner could
54
+ * use. Its failure fails the run before anything is reserved.
55
+ */
56
+ unitsCommand?: string;
48
57
  /**
49
58
  * The most threads or processes the command runs at once, which is how many CPU tokens it asks
50
59
  * its live parent pool for. Absent, the runner in the command decides:
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,GAAG,iBAAiB,CAAC;AAExE,MAAM,MAAM,iBAAiB,GACzB;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7C;IAAE,SAAS,CAAC,EAAE,SAAS,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,kGA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AAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB"}
@@ -38,6 +38,16 @@ export declare function zigbuildArtifact(options: Pick<CargoZigbuildOptions, 'bi
38
38
  export declare function zigbuildArgs(options: CargoZigbuildOptions, manifestPath: string): string[];
39
39
  /** `x86_64-unknown-linux-gnu.2.17` → `x86_64-unknown-linux-gnu`. */
40
40
  export declare function cargoTriple(target: string): string;
41
+ /**
42
+ * The remedy for a failed build of `target` on this host, when rustc has no standard library for its triple: every
43
+ * managed shell carries `x86_64-unknown-linux-gnu`'s, and on macOS the rest of the Linux set is the `linux-cross`
44
+ * profile's. A build outside it fails in rustc, which names the missing target but not the profile. `libdir` is what
45
+ * `rustc --print target-libdir --target <triple>` printed, or null when rustc could not answer.
46
+ */
47
+ export declare function missingRustStdRemedy(command: string, target: string, platform: NodeJS.Platform, libdir: {
48
+ readonly path: string;
49
+ readonly exists: boolean;
50
+ } | null): string | null;
41
51
  /**
42
52
  * The environment without any compiler or linker named for this triple.
43
53
  *
@@ -1 +1 @@
1
- {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/cargo-zigbuild/executor.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EAKtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAA0C,KAAK,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGjG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,mBAAmB,CAAC;IAC5B,aAAa,EAAE,MAAM,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AAE,CAAC,CAkE/B"}
@@ -165,6 +165,37 @@ export function cargoTriple(target) {
165
165
  const glibcSuffix = /\.\d+\.\d+$/.exec(target);
166
166
  return glibcSuffix === null ? target : target.slice(0, glibcSuffix.index);
167
167
  }
168
+ /**
169
+ * The remedy for a failed build of `target` on this host, when rustc has no standard library for its triple: every
170
+ * managed shell carries `x86_64-unknown-linux-gnu`'s, and on macOS the rest of the Linux set is the `linux-cross`
171
+ * profile's. A build outside it fails in rustc, which names the missing target but not the profile. `libdir` is what
172
+ * `rustc --print target-libdir --target <triple>` printed, or null when rustc could not answer.
173
+ */
174
+ export function missingRustStdRemedy(command, target, platform, libdir) {
175
+ if (platform !== 'darwin' || libdir === null || libdir.exists)
176
+ return null;
177
+ return (`${command}: rustc has no standard library for ${cargoTriple(target)} (${libdir.path} is absent). On macOS the ` +
178
+ "Linux rust-std set beyond x86_64-unknown-linux-gnu is the linux-cross profile's: tooling/devenv -P linux-cross " +
179
+ 'shell -- nx run <project>:<target>');
180
+ }
181
+ /** What `rustc --print target-libdir` names for the triple of `target`, and whether it exists; null if rustc failed. */
182
+ async function rustLibdir(target) {
183
+ const child = spawn('rustc', ['--print', 'target-libdir', '--target', cargoTriple(target)], {
184
+ stdio: ['ignore', 'pipe', 'ignore'],
185
+ });
186
+ let printed = '';
187
+ child.stdout.setEncoding('utf8');
188
+ child.stdout.on('data', (chunk) => {
189
+ printed += chunk;
190
+ });
191
+ // eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: rustc answers a --print query from its own sysroot without compiling; the enclosing runner's bound ends a hung one
192
+ const code = await new Promise((resolve) => {
193
+ child.once('error', () => resolve(null));
194
+ child.once('close', resolve);
195
+ });
196
+ const libdir = printed.trim();
197
+ return code === 0 && libdir !== '' ? { path: libdir, exists: existsSync(libdir) } : null;
198
+ }
168
199
  /**
169
200
  * The environment without any compiler or linker named for this triple.
170
201
  *
@@ -288,14 +319,17 @@ export default async function cargoZigbuildExecutor(options, context) {
288
319
  }
289
320
  catch (error) {
290
321
  if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
291
- console.error(`${command}: cargo-zigbuild is not on PATH. Linux artifacts build with the linux-cross toolchain; ` +
292
- 'on macOS run the target inside it: tooling/devenv -P linux-cross shell -- nx run <project>:<target>');
322
+ console.error(`${command}: cargo-zigbuild is not on PATH, which every managed devenv shell carries; run the target in the ` +
323
+ "checkout's shell: direnv exec <checkout> nx run <project>:<target>");
293
324
  return { success: false };
294
325
  }
295
326
  throw error;
296
327
  }
297
328
  if (status.code !== 0) {
298
329
  console.error(`${command}: exited with ${status.signal ?? `status ${status.code}`}`);
330
+ const remedy = missingRustStdRemedy(command, options.target, process.platform, await rustLibdir(options.target));
331
+ if (remedy !== null)
332
+ console.error(remedy);
299
333
  return { success: false };
300
334
  }
301
335
  if (built === null) {