@smoothbricks/nx-plugin 0.7.17 → 0.7.19

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 (199) hide show
  1. package/README.md +315 -114
  2. package/dist/.build-inputs.json +47 -38
  3. package/dist/built-output-packages.js +1 -1
  4. package/dist/bun-lock-scope.d.ts +128 -20
  5. package/dist/bun-lock-scope.d.ts.map +1 -1
  6. package/dist/bun-lock-scope.js +267 -44
  7. package/dist/cargo-closure-input.d.ts +8 -6
  8. package/dist/cargo-closure-input.d.ts.map +1 -1
  9. package/dist/cargo-closure-input.js +15 -12
  10. package/dist/cargo-source-hash.d.ts +26 -25
  11. package/dist/cargo-source-hash.d.ts.map +1 -1
  12. package/dist/cargo-source-hash.js +84 -105
  13. package/dist/cargo-toolchain-paths.d.ts +2 -2
  14. package/dist/cargo-toolchain-paths.js +2 -2
  15. package/dist/cargo-workspace.d.ts +20 -2
  16. package/dist/cargo-workspace.d.ts.map +1 -1
  17. package/dist/cargo-workspace.js +43 -22
  18. package/dist/ensure-built-receipt.d.ts +3 -2
  19. package/dist/ensure-built-receipt.d.ts.map +1 -1
  20. package/dist/ensure-built-receipt.js +3 -2
  21. package/dist/eslint-config-closure.d.ts +8 -3
  22. package/dist/eslint-config-closure.d.ts.map +1 -1
  23. package/dist/eslint-config-closure.js +24 -5
  24. package/dist/executors/bounded-exec/admission-queue.d.ts +3 -1
  25. package/dist/executors/bounded-exec/admission-queue.d.ts.map +1 -1
  26. package/dist/executors/bounded-exec/admission-queue.js +9 -10
  27. package/dist/executors/bounded-exec/awake-clock.d.ts +5 -0
  28. package/dist/executors/bounded-exec/awake-clock.d.ts.map +1 -0
  29. package/dist/executors/bounded-exec/awake-clock.js +22 -0
  30. package/dist/executors/bounded-exec/bounds.d.ts +19 -6
  31. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
  32. package/dist/executors/bounded-exec/bounds.js +22 -15
  33. package/dist/executors/bounded-exec/case-gate.d.ts +114 -0
  34. package/dist/executors/bounded-exec/case-gate.d.ts.map +1 -0
  35. package/dist/executors/bounded-exec/case-gate.js +342 -0
  36. package/dist/executors/bounded-exec/cpu-pool-thread.d.ts +1 -0
  37. package/dist/executors/bounded-exec/cpu-pool-thread.d.ts.map +1 -1
  38. package/dist/executors/bounded-exec/cpu-pool-thread.js +2 -2
  39. package/dist/executors/bounded-exec/cpu-pool.d.ts +28 -1
  40. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  41. package/dist/executors/bounded-exec/cpu-pool.js +102 -16
  42. package/dist/executors/bounded-exec/cpu-rise.d.ts +73 -0
  43. package/dist/executors/bounded-exec/cpu-rise.d.ts.map +1 -0
  44. package/dist/executors/bounded-exec/cpu-rise.js +111 -0
  45. package/dist/executors/bounded-exec/endpoint-life.d.ts +146 -0
  46. package/dist/executors/bounded-exec/endpoint-life.d.ts.map +1 -0
  47. package/dist/executors/bounded-exec/endpoint-life.js +228 -0
  48. package/dist/executors/bounded-exec/executor.d.ts +1 -1
  49. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  50. package/dist/executors/bounded-exec/executor.js +256 -86
  51. package/dist/executors/bounded-exec/gateway-lease.d.ts +1 -1
  52. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
  53. package/dist/executors/bounded-exec/gateway-lease.js +8 -1
  54. package/dist/executors/bounded-exec/go-run-summary.d.ts +51 -0
  55. package/dist/executors/bounded-exec/go-run-summary.d.ts.map +1 -0
  56. package/dist/executors/bounded-exec/go-run-summary.js +98 -0
  57. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +11 -3
  58. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  59. package/dist/executors/bounded-exec/hang-diagnostics.js +125 -47
  60. package/dist/executors/bounded-exec/lease-wait.d.ts +1 -0
  61. package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -1
  62. package/dist/executors/bounded-exec/lease-wait.js +1 -0
  63. package/dist/executors/bounded-exec/mbx-pool.d.ts +42 -7
  64. package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
  65. package/dist/executors/bounded-exec/mbx-pool.js +45 -8
  66. package/dist/executors/bounded-exec/mbx-reservations.d.ts +12 -6
  67. package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -1
  68. package/dist/executors/bounded-exec/mbx-reservations.js +190 -284
  69. package/dist/executors/bounded-exec/parent-grant.d.ts +2 -0
  70. package/dist/executors/bounded-exec/parent-grant.d.ts.map +1 -1
  71. package/dist/executors/bounded-exec/parent-grant.js +1 -0
  72. package/dist/executors/bounded-exec/pool-admission.d.ts +29 -3
  73. package/dist/executors/bounded-exec/pool-admission.d.ts.map +1 -1
  74. package/dist/executors/bounded-exec/pool-admission.js +47 -1
  75. package/dist/executors/bounded-exec/progress-channel.d.ts +38 -0
  76. package/dist/executors/bounded-exec/progress-channel.d.ts.map +1 -0
  77. package/dist/executors/bounded-exec/progress-channel.js +113 -0
  78. package/dist/executors/bounded-exec/progress.d.ts +5 -1
  79. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  80. package/dist/executors/bounded-exec/progress.js +31 -1
  81. package/dist/executors/bounded-exec/ram-temp.d.ts +24 -1
  82. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  83. package/dist/executors/bounded-exec/ram-temp.js +123 -16
  84. package/dist/executors/bounded-exec/reservation-connection.d.ts +90 -0
  85. package/dist/executors/bounded-exec/reservation-connection.d.ts.map +1 -0
  86. package/dist/executors/bounded-exec/reservation-connection.js +248 -0
  87. package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
  88. package/dist/executors/bounded-exec/run-cpu-pool.js +3 -0
  89. package/dist/executors/bounded-exec/runner-sizing.d.ts +9 -5
  90. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
  91. package/dist/executors/bounded-exec/runner-sizing.js +13 -9
  92. package/dist/executors/bounded-exec/schema.d.ts +7 -2
  93. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  94. package/dist/executors/bounded-exec/schema.js +17 -1
  95. package/dist/executors/bounded-exec/suite-minimum.d.ts +21 -0
  96. package/dist/executors/bounded-exec/suite-minimum.d.ts.map +1 -0
  97. package/dist/executors/bounded-exec/suite-minimum.js +85 -0
  98. package/dist/executors/bounded-exec/test-result-writer.d.ts +2 -0
  99. package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -1
  100. package/dist/executors/bounded-exec/test-result-writer.js +1 -0
  101. package/dist/executors/bounded-exec/test-results.d.ts +5 -0
  102. package/dist/executors/bounded-exec/test-results.d.ts.map +1 -1
  103. package/dist/executors/bounded-exec/test-results.js +2 -2
  104. package/dist/executors/bounded-exec/verdict.d.ts +39 -10
  105. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  106. package/dist/executors/bounded-exec/verdict.js +60 -14
  107. package/dist/executors/cargo-zigbuild/executor.d.ts +10 -8
  108. package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
  109. package/dist/executors/cargo-zigbuild/executor.js +32 -19
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +294 -152
  112. package/dist/managed-files/ci-workflow.d.ts +4 -1
  113. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  114. package/dist/managed-files/ci-workflow.js +9 -14
  115. package/dist/managed-files/files.d.ts +3 -3
  116. package/dist/managed-files/files.js +3 -3
  117. package/dist/managed-files/generator.d.ts +5 -1
  118. package/dist/managed-files/generator.d.ts.map +1 -1
  119. package/dist/managed-files/generator.js +22 -7
  120. package/dist/managed-files/render-memo.d.ts +13 -0
  121. package/dist/managed-files/render-memo.d.ts.map +1 -0
  122. package/dist/managed-files/render-memo.js +94 -0
  123. package/dist/task-results.js +2 -1
  124. package/dist/test-program.d.ts +11 -6
  125. package/dist/test-program.d.ts.map +1 -1
  126. package/dist/test-program.js +39 -35
  127. package/dist/tool-bins.d.ts +12 -0
  128. package/dist/tool-bins.d.ts.map +1 -1
  129. package/dist/tool-bins.js +31 -6
  130. package/dist/typecheck-test-policy.d.ts +10 -1
  131. package/dist/typecheck-test-policy.d.ts.map +1 -1
  132. package/dist/typecheck-test-policy.js +40 -24
  133. package/dist/workspace-config-policy.d.ts.map +1 -1
  134. package/dist/workspace-config-policy.js +135 -42
  135. package/dist/workspace-index.d.ts +14 -1
  136. package/dist/workspace-index.d.ts.map +1 -1
  137. package/dist/workspace-index.js +36 -4
  138. package/executors.json +2 -0
  139. package/managed/raw/envrc +24 -0
  140. package/managed/raw/patches/nx@24.0.3.patch +1851 -221
  141. package/managed/raw/patches/ttsc@0.37.1.patch +1055 -0
  142. package/managed/raw/tooling/direnv/developer-links.ts +122 -14
  143. package/managed/raw/tooling/direnv/devenv.smoo.nix +20 -19
  144. package/managed/templates/github/actions/save-nix-devenv/action.yml +19 -1
  145. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  146. package/package.json +68 -11
  147. package/runtime/nx-publish/.build-inputs.json +2 -2
  148. package/runtime/nx-publish/cache_adapter.js +293 -3
  149. package/runtime/nx-publish/nx_publish.js +36 -14
  150. package/src/built-output-packages.ts +1 -1
  151. package/src/bun-lock-scope.ts +293 -40
  152. package/src/cargo-closure-input.ts +20 -12
  153. package/src/cargo-source-hash.ts +119 -145
  154. package/src/cargo-toolchain-paths.ts +2 -2
  155. package/src/cargo-workspace.ts +59 -21
  156. package/src/ensure-built-receipt.ts +3 -2
  157. package/src/eslint-config-closure.ts +27 -6
  158. package/src/executors/bounded-exec/admission-queue.ts +11 -10
  159. package/src/executors/bounded-exec/awake-clock.ts +20 -0
  160. package/src/executors/bounded-exec/bounds.ts +41 -19
  161. package/src/executors/bounded-exec/case-gate.ts +365 -0
  162. package/src/executors/bounded-exec/cpu-pool-thread.ts +3 -3
  163. package/src/executors/bounded-exec/cpu-pool.ts +139 -12
  164. package/src/executors/bounded-exec/cpu-rise.ts +156 -0
  165. package/src/executors/bounded-exec/endpoint-life.ts +279 -0
  166. package/src/executors/bounded-exec/executor.ts +341 -123
  167. package/src/executors/bounded-exec/gateway-lease.ts +6 -0
  168. package/src/executors/bounded-exec/go-run-summary.ts +137 -0
  169. package/src/executors/bounded-exec/hang-diagnostics.ts +150 -50
  170. package/src/executors/bounded-exec/lease-wait.ts +1 -0
  171. package/src/executors/bounded-exec/mbx-pool.ts +57 -9
  172. package/src/executors/bounded-exec/mbx-reservations.ts +216 -183
  173. package/src/executors/bounded-exec/parent-grant.ts +3 -0
  174. package/src/executors/bounded-exec/pool-admission.ts +59 -2
  175. package/src/executors/bounded-exec/progress-channel.ts +129 -0
  176. package/src/executors/bounded-exec/progress.ts +39 -3
  177. package/src/executors/bounded-exec/ram-temp.ts +137 -17
  178. package/src/executors/bounded-exec/reservation-connection.ts +221 -0
  179. package/src/executors/bounded-exec/run-cpu-pool.ts +2 -0
  180. package/src/executors/bounded-exec/runner-sizing.ts +13 -8
  181. package/src/executors/bounded-exec/schema.json +1 -1
  182. package/src/executors/bounded-exec/schema.ts +21 -2
  183. package/src/executors/bounded-exec/suite-minimum.ts +81 -0
  184. package/src/executors/bounded-exec/test-result-writer.ts +3 -0
  185. package/src/executors/bounded-exec/test-results.ts +5 -0
  186. package/src/executors/bounded-exec/verdict.ts +83 -22
  187. package/src/executors/cargo-zigbuild/executor.ts +30 -19
  188. package/src/index.ts +357 -166
  189. package/src/managed-files/ci-workflow.ts +13 -17
  190. package/src/managed-files/files.ts +3 -3
  191. package/src/managed-files/generator.ts +21 -6
  192. package/src/managed-files/render-memo.ts +135 -0
  193. package/src/test-program.ts +36 -41
  194. package/src/tool-bins.ts +35 -6
  195. package/src/typecheck-test-policy.ts +49 -24
  196. package/src/workspace-config-policy.ts +161 -43
  197. package/src/workspace-index.ts +40 -5
  198. package/test-timings.json +157 -141
  199. package/managed/raw/patches/ttsc@0.36.3.patch +0 -1660
@@ -1,4 +1,11 @@
1
1
  import { type Demand, type ReservedDemand } from './runner-sizing.js';
2
+ /**
3
+ * mbx's pool priorities, as `MBX_SCHEDULER_PRIORITY` and a reservation name them: interactive work's `interactive`,
4
+ * which mbx ranks first and decays as its job ages, a gate's `normal`, every other job's `low` (cowshed's
5
+ * `PoolPriority`).
6
+ */
7
+ export declare const MBX_PRIORITIES: readonly ['interactive', 'normal', 'low'];
8
+ export type MbxPriority = (typeof MBX_PRIORITIES)[number];
2
9
  /**
3
10
  * mbx's machine-wide pool as a leaf runner meets it (specs/cowshed/05_gateway.md, "Host scheduling", "Parallelism inside
4
11
  * a job"). With the mbx capability the canonical environment names the one pool (`MBX_SCHEDULER=1` beside the shared
@@ -6,7 +13,7 @@ import { type Demand, type ReservedDemand } from './runner-sizing.js';
6
13
  * serves a pool of its own beside it.
7
14
  */
8
15
  export interface MbxPool {
9
- readonly priority: 'normal' | 'low';
16
+ readonly priority: MbxPriority;
10
17
  }
11
18
  /**
12
19
  * The pool the environment names, or `null` where the project has no mbx and cowshed's own pools apply unchanged, or
@@ -17,6 +24,12 @@ export interface MbxPool {
17
24
  * belongs to.
18
25
  */
19
26
  export declare function mbxPool(environment: Readonly<NodeJS.ProcessEnv>): MbxPool | null;
27
+ /**
28
+ * Whether the environment names mbx's pool from inside a hold on it: what a held cowshed job, `mbx reserve`'s command
29
+ * and a reserved leaf's shell see (`MBX_SCHED_DISABLE=1` beside the canonical environment). mbx's test shim still
30
+ * starts every nextest case there, so a run under it may gate its cases (mbx-reservations.ts, `learnHeldGate`).
31
+ */
32
+ export declare function mbxHold(environment: Readonly<NodeJS.ProcessEnv>): boolean;
20
33
  /**
21
34
  * How a leaf enters the pool once. A Cargo leaf that builds runs through mbx, which admits its compilers and supported
22
35
  * test work itself, so wrapping it would charge it twice. Any other leaf reserves for its whole run, asking its Nx
@@ -33,8 +46,13 @@ export type MbxLeaf = {
33
46
  readonly kind: 'cargo';
34
47
  } | {
35
48
  readonly kind: 'reserve';
36
- readonly priority: 'normal' | 'low';
49
+ readonly priority: MbxPriority;
37
50
  readonly demand: ReservedDemand;
51
+ /**
52
+ * Whether its runner starts every thread of its ask and each case takes a core at the leaf's gate (case-gate.ts):
53
+ * a nextest leaf of a run whose mbx gates its cases. Otherwise its runner is sized to its grant.
54
+ */
55
+ readonly gated: boolean;
38
56
  };
39
57
  /** A leaf mbx's pool reserves for. */
40
58
  export type ReservedLeaf = Extract<MbxLeaf, {
@@ -49,7 +67,14 @@ export declare function runsPrebuiltNextest(command: string): boolean;
49
67
  * kept every reservation queued behind it waiting while the pool drained. On 2026-10-31 a downstream gate ran 4.9 of 18
50
68
  * 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.
51
69
  */
52
- export declare function mbxLeaf(pool: MbxPool, demand: Demand, command: string): MbxLeaf | null;
70
+ export declare function mbxLeaf(pool: MbxPool, demand: Demand, command: string, testGate: boolean): MbxLeaf | null;
71
+ /**
72
+ * Whether a run of `command` under mbx's pool is a Cargo leaf: the one leaf whose admission wait the run reads from
73
+ * mbx's activity report and its waiters' native lineage (mbx-queue.ts; specs/cowshed/11_shell.md, "Cargo test-runner
74
+ * boundaries"), through cowshed's process-lineage entry. The command alone decides it: the pool's priority, the core
75
+ * count and the environment size a leaf, never its kind.
76
+ */
77
+ export declare function runsAsCargoLeaf(command: string): boolean;
53
78
  /**
54
79
  * Only a known scheduled execution may stop its idle clock at zero holds. Plain Cargo tests can run doctests;
55
80
  * archive-file targets, direct binaries and other runners are not proven scheduled at spawn (11_shell.md,
@@ -64,14 +89,24 @@ export declare function mbxIdleGated(leaf: MbxLeaf | null, command: string, envi
64
89
  export declare const MBX_GRANT_FD = 5;
65
90
  /**
66
91
  * `command` as the shell runs it under its leaf's admission, or as it is for a leaf in no pool (`null`): a reserved
67
- * leaf asks for its runner's count (`reservation`).
92
+ * leaf asks for its runner's count (`reservation`). A reserved leaf's fixture is never part of `command`
93
+ * (`withReservationAfterFixture`).
68
94
  */
69
95
  export declare function withMbxLeaf(command: string, leaf: MbxLeaf | null): string;
96
+ /**
97
+ * A reserved leaf with a `fixture`: the fixture runs first, outside the reservation, as pooled work like any other
98
+ * build, and the leaf asks for its runner's count only once it has exited 0 (specs/cowshed/05_gateway.md, "A leaf's
99
+ * build precedes its reservation"). A reservation holds cores only while its command can use them: a fixture inside
100
+ * one waits on Cargo's build-directory lock holding its grant, and when reserved leaves hold every core the lock's
101
+ * holder, a pooled build whose compiler waits for one, never gets it. A fixture that fails fails the run before
102
+ * anything is reserved.
103
+ */
104
+ export declare function withReservationAfterFixture(fixture: string, command: string, leaf: ReservedLeaf): string;
70
105
  /**
71
106
  * A reserved leaf whose `fixture` segment ends by printing one line per unit its `command` runs (`unitsCommand`): the
72
- * segment runs first, outside the reservation, since a build's compilers are admitted by mbx one by one, and the leaf
73
- * asks for its units, at most its runner's count and at least one. A segment that fails fails the run before anything
74
- * is reserved.
107
+ * segment runs first, outside the reservation as every fixture does (`withReservationAfterFixture`), and the leaf asks
108
+ * for its units, at most its runner's count and at least one. A segment that fails fails the run before anything is
109
+ * reserved.
75
110
  */
76
111
  export declare function withCountedReservation(fixture: string, command: string, leaf: ReservedLeaf): string;
77
112
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"mbx-pool.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/mbx-pool.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,MAAM,EAIX,KAAK,cAAc,EAEpB,MAAM,oBAAoB,CAAC;AAG5B;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,CAAC;CACrC;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,OAAO,GAAG,IAAI,CAKhF;AAED;;;;;;;;;;;GAWG;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,GAA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,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,OAAO,CAkDrH;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,IAAI,CAAC;AAE9B;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,GAAG,MAAM,CAKzE;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,MAAM,CAExG;AACD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,MAAM,CAInG;AAkBD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIpE"}
@@ -1,6 +1,12 @@
1
1
  import { shellTokens } from '../../runtime-input-policy.js';
2
- import { CPU_TOKENS_ENV, GRANTED_CPUS_ENV, grantedSizing, invocationSpan, WANT_ENV, } from './runner-sizing.js';
2
+ import { CPU_TOKENS_ENV, GRANTED_CPUS_ENV, grantedSizing, invocationSpan, runnerDemand, WANT_ENV, } from './runner-sizing.js';
3
3
  import { shellQuote } from './verdict.js';
4
+ /**
5
+ * mbx's pool priorities, as `MBX_SCHEDULER_PRIORITY` and a reservation name them: interactive work's `interactive`,
6
+ * which mbx ranks first and decays as its job ages, a gate's `normal`, every other job's `low` (cowshed's
7
+ * `PoolPriority`).
8
+ */
9
+ export const MBX_PRIORITIES = ['interactive', 'normal', 'low'];
4
10
  /**
5
11
  * The pool the environment names, or `null` where the project has no mbx and cowshed's own pools apply unchanged, or
6
12
  * where this run is already inside an mbx reservation: whatever holds one hands its work `MBX_SCHED_DISABLE=1` (a
@@ -13,7 +19,16 @@ export function mbxPool(environment) {
13
19
  if (environment.MBX_SCHEDULER !== '1' || !environment.MBX_CACHE_DIR || environment.MBX_SCHED_DISABLE === '1') {
14
20
  return null;
15
21
  }
16
- return { priority: environment.MBX_SCHEDULER_PRIORITY === 'normal' ? 'normal' : 'low' };
22
+ const named = MBX_PRIORITIES.find((priority) => priority === environment.MBX_SCHEDULER_PRIORITY);
23
+ return { priority: named ?? 'low' };
24
+ }
25
+ /**
26
+ * Whether the environment names mbx's pool from inside a hold on it: what a held cowshed job, `mbx reserve`'s command
27
+ * and a reserved leaf's shell see (`MBX_SCHED_DISABLE=1` beside the canonical environment). mbx's test shim still
28
+ * starts every nextest case there, so a run under it may gate its cases (mbx-reservations.ts, `learnHeldGate`).
29
+ */
30
+ export function mbxHold(environment) {
31
+ return environment.MBX_SCHEDULER === '1' && !!environment.MBX_CACHE_DIR && environment.MBX_SCHED_DISABLE === '1';
17
32
  }
18
33
  /** A nextest invocation that runs test binaries already built, from extracted archive metadata or an archive file. */
19
34
  const PREBUILT_NEXTEST = /(?<![\w-])--(?:binaries-metadata|archive-file)(?=[=\s]|$)/;
@@ -28,11 +43,12 @@ export function runsPrebuiltNextest(command) {
28
43
  * kept every reservation queued behind it waiting while the pool drained. On 2026-10-31 a downstream gate ran 4.9 of 18
29
44
  * 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.
30
45
  */
31
- export function mbxLeaf(pool, demand, command) {
46
+ export function mbxLeaf(pool, demand, command, testGate) {
32
47
  const reserve = (reserved) => ({
33
48
  kind: 'reserve',
34
49
  priority: pool.priority,
35
50
  demand: reserved,
51
+ gated: testGate && reserved.kind === 'nextest',
36
52
  });
37
53
  switch (demand.kind) {
38
54
  case 'vitest':
@@ -49,6 +65,15 @@ export function mbxLeaf(pool, demand, command) {
49
65
  return reserve(demand);
50
66
  }
51
67
  }
68
+ /**
69
+ * Whether a run of `command` under mbx's pool is a Cargo leaf: the one leaf whose admission wait the run reads from
70
+ * mbx's activity report and its waiters' native lineage (mbx-queue.ts; specs/cowshed/11_shell.md, "Cargo test-runner
71
+ * boundaries"), through cowshed's process-lineage entry. The command alone decides it: the pool's priority, the core
72
+ * count and the environment size a leaf, never its kind.
73
+ */
74
+ export function runsAsCargoLeaf(command) {
75
+ return mbxLeaf({ priority: 'low' }, runnerDemand(command, undefined, 1, {}), command, false)?.kind === 'cargo';
76
+ }
52
77
  /**
53
78
  * The value an in-place runner gives `--target-dir-remap`: smoo-nx-nextest-binaries' answer, quoted. The plugin infers
54
79
  * the native helper; a repository's own runner may name its script through bun, which prints the same path.
@@ -126,7 +151,8 @@ export function mbxIdleGated(leaf, command, environment) {
126
151
  export const MBX_GRANT_FD = 5;
127
152
  /**
128
153
  * `command` as the shell runs it under its leaf's admission, or as it is for a leaf in no pool (`null`): a reserved
129
- * leaf asks for its runner's count (`reservation`).
154
+ * leaf asks for its runner's count (`reservation`). A reserved leaf's fixture is never part of `command`
155
+ * (`withReservationAfterFixture`).
130
156
  */
131
157
  export function withMbxLeaf(command, leaf) {
132
158
  if (leaf === null || leaf.kind === 'cargo') {
@@ -134,11 +160,22 @@ export function withMbxLeaf(command, leaf) {
134
160
  }
135
161
  return `${WANT_ENV}=${leaf.demand.want} && ${reservation(command, leaf)}`;
136
162
  }
163
+ /**
164
+ * A reserved leaf with a `fixture`: the fixture runs first, outside the reservation, as pooled work like any other
165
+ * build, and the leaf asks for its runner's count only once it has exited 0 (specs/cowshed/05_gateway.md, "A leaf's
166
+ * build precedes its reservation"). A reservation holds cores only while its command can use them: a fixture inside
167
+ * one waits on Cargo's build-directory lock holding its grant, and when reserved leaves hold every core the lock's
168
+ * holder, a pooled build whose compiler waits for one, never gets it. A fixture that fails fails the run before
169
+ * anything is reserved.
170
+ */
171
+ export function withReservationAfterFixture(fixture, command, leaf) {
172
+ return `${fixture} && ${withMbxLeaf(command, leaf)}`;
173
+ }
137
174
  /**
138
175
  * A reserved leaf whose `fixture` segment ends by printing one line per unit its `command` runs (`unitsCommand`): the
139
- * segment runs first, outside the reservation, since a build's compilers are admitted by mbx one by one, and the leaf
140
- * asks for its units, at most its runner's count and at least one. A segment that fails fails the run before anything
141
- * is reserved.
176
+ * segment runs first, outside the reservation as every fixture does (`withReservationAfterFixture`), and the leaf asks
177
+ * for its units, at most its runner's count and at least one. A segment that fails fails the run before anything is
178
+ * reserved.
142
179
  */
143
180
  export function withCountedReservation(fixture, command, leaf) {
144
181
  const most = leaf.demand.want;
@@ -158,7 +195,7 @@ function reservation(command, leaf) {
158
195
  const said = `printf 'cowshed: mbx reserve running cpus=%s asked=%s\\n' "$${CPU_TOKENS_ENV}" "$${WANT_ENV}" >&2; `;
159
196
  const ask = `printf '%s\\n' "$${WANT_ENV}" >&${MBX_GRANT_FD} && IFS= read -r ${GRANTED_CPUS_ENV} <&${MBX_GRANT_FD} && exec ${MBX_GRANT_FD}>&-`;
160
197
  const held = `export ${GRANTED_CPUS_ENV} MBX_SCHED_DISABLE=1 MBX_SCHED_DIR=`;
161
- return `export ${WANT_ENV} && ${ask} && ${held} && eval ${shellQuote(`${grantedSizing(leaf.demand)}${said}${command}`)}`;
198
+ return `export ${WANT_ENV} && ${ask} && ${held} && eval ${shellQuote(`${grantedSizing(leaf.demand, leaf.gated)}${said}${command}`)}`;
162
199
  }
163
200
  /**
164
201
  * The cores a reserved leaf's shell asked for on `MBX_GRANT_FD` (`reservation`): a whole count from one to `most`, the
@@ -1,11 +1,15 @@
1
1
  import type { PostTasksExecutionContext, PreTasksExecutionContext } from 'nx/src/project-graph/plugins/public-api.js';
2
+ import { type MbxPriority } from './mbx-pool.js';
3
+ import { type ReservationRefusal } from './reservation-connection.js';
2
4
  /**
3
5
  * mbx's reservation endpoint of one Nx run (specs/cowshed/05_gateway.md, "Parallelism inside a job"). A reserved leaf
4
6
  * once ran under its own `mbx reserve`, two mbx processes per task whose dynamic loading alone kept the host's vnode
5
7
  * table recycling. With mbx's pool, the run's `preTasksExecution` starts `mbx reservations <socket>` once and publishes
6
8
  * the socket in `RESERVATIONS_ENV`, which every task inherits; each task's executor asks it for its leaf's cores over
7
9
  * one connection per process (`reserveCores`), and the run's `postTasksExecution` closes the endpoint's standard input,
8
- * which ends it. Admission is `mbx reserve`'s: the same pool, priority and order. A grant lasts until its leaf ends, or
10
+ * which ends it. Nx runs both hooks in the process that runs the tasks, never in a daemon (patches/README.md, "A run's
11
+ * task hooks run in its own process"), so the endpoint is a child of the run and ends with it, whatever becomes of the
12
+ * run's daemon. Admission is `mbx reserve`'s: the same pool, priority and order. A grant lasts until its leaf ends, or
9
13
  * until its connection closes, so an executor that dies gives back what it held.
10
14
  */
11
15
  export declare const RESERVATIONS_ENV = "MBX_RESERVATIONS_SOCKET";
@@ -34,7 +38,8 @@ export declare function describeUnserved(endpoint: Exclude<RunEndpoint, {
34
38
  /**
35
39
  * Serve `context`'s run an mbx reservation endpoint and publish it in `env`, which every task inherits, when the
36
40
  * environment names mbx's pool (`mbxPool`). An endpoint that does not start is said, and each reserved leaf of the run
37
- * then refuses to run, naming `RESERVATIONS_ENV`; a leaf in no pool, or one mbx admits itself, runs as before.
41
+ * then refuses to run, naming `RESERVATIONS_ENV`; a leaf in no pool, or one mbx admits itself, runs as before. A run
42
+ * under a hold on mbx's pool is served no endpoint, and learns whether its mbx gates test cases (`learnHeldGate`).
38
43
  */
39
44
  export declare function serveRunReservations(context: Pick<PreTasksExecutionContext, 'id'>, env?: NodeJS.ProcessEnv): Promise<void>;
40
45
  /** Close the endpoint `context`'s run was served, if it was served one: its standard input's end ends it. */
@@ -46,7 +51,7 @@ export type Granted = {
46
51
  readonly lost: Promise<string>;
47
52
  } | {
48
53
  readonly ok: false;
49
- readonly error: string;
54
+ readonly refusal: ReservationRefusal;
50
55
  };
51
56
  /** One request for cores on a run's endpoint. */
52
57
  export interface Reservation {
@@ -56,8 +61,9 @@ export interface Reservation {
56
61
  release(): void;
57
62
  }
58
63
  /**
59
- * Ask the endpoint at `socket` for at most `cpus` cores at `priority`, over this process's one connection to it,
60
- * opened by its first request and kept while another one may come.
64
+ * Ask the endpoint at `socket` for at most `cpus` cores at `priority`, starting on no fewer than `min` of them until
65
+ * mbx's aging bound, over this process's one connection to it, opened by its first request and kept while another one
66
+ * may come. `name` is the class mbx predicts the reservation by; absent, mbx's own for an unnamed one.
61
67
  */
62
- export declare function reserveCores(socket: string, cpus: number, priority: 'normal' | 'low'): Reservation;
68
+ export declare function reserveCores(socket: string, cpus: number, priority: MbxPriority, min: number, name?: string): Reservation;
63
69
  //# sourceMappingURL=mbx-reservations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mbx-reservations.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/mbx-reservations.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAMtH;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,4BAA4B,CAAC;AAE1D;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,uCAAuC,CAAC;AAE9E,wEAAwE;AACxE,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACpD;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACtD;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC;AAErC,mGAAmG;AACnG,wBAAgB,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,WAAW,CAKzE;AAED,sFAAsF;AACtF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,GAAG,MAAM,CAI3F;AAmBD;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,OA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