@smoothbricks/nx-plugin 0.6.2 → 0.7.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 (177) hide show
  1. package/README.md +417 -171
  2. package/dist/.build-inputs.json +39 -28
  3. package/dist/bin/smoo-nx-go-test-build.d.ts +3 -0
  4. package/dist/bin/smoo-nx-go-test-build.d.ts.map +1 -0
  5. package/dist/bin/smoo-nx-go-test-build.js +79 -0
  6. package/dist/bin/smoo-nx-go-test-run.d.ts +3 -0
  7. package/dist/bin/smoo-nx-go-test-run.d.ts.map +1 -0
  8. package/dist/bin/smoo-nx-go-test-run.js +129 -0
  9. package/dist/bin/smoo-nx-publish.d.ts +3 -0
  10. package/dist/bin/smoo-nx-publish.d.ts.map +1 -0
  11. package/dist/bin/smoo-nx-publish.js +3 -0
  12. package/dist/bounded-test-policy.d.ts +1 -1
  13. package/dist/bounded-test-policy.d.ts.map +1 -1
  14. package/dist/bounded-test-policy.js +9 -8
  15. package/dist/cargo-retention-hook.d.ts +6 -2
  16. package/dist/cargo-retention-hook.d.ts.map +1 -1
  17. package/dist/cargo-retention-hook.js +13 -7
  18. package/dist/cargo-workspace.d.ts +10 -20
  19. package/dist/cargo-workspace.d.ts.map +1 -1
  20. package/dist/cargo-workspace.js +12 -22
  21. package/dist/cross-check-policy.d.ts +2 -2
  22. package/dist/cross-check-policy.js +2 -2
  23. package/dist/deploy-policy.d.ts +6 -0
  24. package/dist/deploy-policy.d.ts.map +1 -1
  25. package/dist/deploy-policy.js +11 -0
  26. package/dist/eslint-file-set.d.ts +4 -1
  27. package/dist/eslint-file-set.d.ts.map +1 -1
  28. package/dist/eslint-sources.d.ts +25 -0
  29. package/dist/eslint-sources.d.ts.map +1 -0
  30. package/dist/eslint-sources.js +99 -0
  31. package/dist/executors/all-verdicts/executor.d.ts +2 -1
  32. package/dist/executors/all-verdicts/executor.d.ts.map +1 -1
  33. package/dist/executors/all-verdicts/executor.js +48 -2
  34. package/dist/executors/all-verdicts/schema.d.ts +13 -0
  35. package/dist/executors/all-verdicts/schema.d.ts.map +1 -1
  36. package/dist/executors/all-verdicts/schema.js +7 -0
  37. package/dist/executors/bounded-exec/bounds.d.ts +57 -8
  38. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
  39. package/dist/executors/bounded-exec/bounds.js +100 -11
  40. package/dist/executors/bounded-exec/executor.d.ts +2 -1
  41. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  42. package/dist/executors/bounded-exec/executor.js +289 -34
  43. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +2 -0
  44. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  45. package/dist/executors/bounded-exec/hang-diagnostics.js +2 -2
  46. package/dist/executors/bounded-exec/mbx-pool.d.ts +56 -10
  47. package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
  48. package/dist/executors/bounded-exec/mbx-pool.js +145 -11
  49. package/dist/executors/bounded-exec/mbx-queue.d.ts +30 -0
  50. package/dist/executors/bounded-exec/mbx-queue.d.ts.map +1 -0
  51. package/dist/executors/bounded-exec/mbx-queue.js +229 -0
  52. package/dist/executors/bounded-exec/progress.d.ts +9 -2
  53. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  54. package/dist/executors/bounded-exec/progress.js +151 -25
  55. package/dist/executors/bounded-exec/runner-sizing.d.ts +40 -2
  56. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
  57. package/dist/executors/bounded-exec/runner-sizing.js +55 -4
  58. package/dist/executors/bounded-exec/runtime-pin.js +1 -1
  59. package/dist/executors/bounded-exec/test-result-writer.d.ts +30 -0
  60. package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -0
  61. package/dist/executors/bounded-exec/test-result-writer.js +126 -0
  62. package/dist/executors/bounded-exec/test-results.d.ts +33 -0
  63. package/dist/executors/bounded-exec/test-results.d.ts.map +1 -0
  64. package/dist/executors/bounded-exec/test-results.js +33 -0
  65. package/dist/executors/bounded-exec/verdict.d.ts +26 -2
  66. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  67. package/dist/executors/bounded-exec/verdict.js +108 -4
  68. package/dist/executors/wrangler-deploy/deploy-hash.d.ts +10 -0
  69. package/dist/executors/wrangler-deploy/deploy-hash.d.ts.map +1 -0
  70. package/dist/executors/wrangler-deploy/deploy-hash.js +14 -0
  71. package/dist/executors/wrangler-deploy/executor.d.ts +24 -0
  72. package/dist/executors/wrangler-deploy/executor.d.ts.map +1 -0
  73. package/dist/executors/wrangler-deploy/executor.js +43 -0
  74. package/dist/executors/wrangler-deploy/hasher.d.ts +27 -0
  75. package/dist/executors/wrangler-deploy/hasher.d.ts.map +1 -0
  76. package/dist/executors/wrangler-deploy/hasher.js +90 -0
  77. package/dist/executors/wrangler-deploy/schema.d.ts +5 -0
  78. package/dist/executors/wrangler-deploy/schema.d.ts.map +1 -0
  79. package/dist/go-tests.d.ts +30 -0
  80. package/dist/go-tests.d.ts.map +1 -0
  81. package/dist/go-tests.js +43 -0
  82. package/dist/index.d.ts +12 -4
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +338 -295
  85. package/dist/managed-files/files.d.ts.map +1 -1
  86. package/dist/managed-files/files.js +5 -0
  87. package/dist/nx-publish.d.ts +24 -0
  88. package/dist/nx-publish.d.ts.map +1 -0
  89. package/dist/nx-publish.js +150 -0
  90. package/dist/process-group.js +2 -2
  91. package/dist/runtime-input-policy.d.ts +17 -3
  92. package/dist/runtime-input-policy.d.ts.map +1 -1
  93. package/dist/runtime-input-policy.js +4 -4
  94. package/dist/test-timings.d.ts +23 -4
  95. package/dist/test-timings.d.ts.map +1 -1
  96. package/dist/test-timings.js +72 -12
  97. package/dist/tool-bins.d.ts +6 -8
  98. package/dist/tool-bins.d.ts.map +1 -1
  99. package/dist/tool-bins.js +7 -5
  100. package/dist/version-actions.cjs +10 -11
  101. package/dist/version-actions.d.cts.map +1 -1
  102. package/dist/workspace-config-policy.d.ts.map +1 -1
  103. package/dist/workspace-config-policy.js +17 -22
  104. package/dist/workspace-index.d.ts +7 -0
  105. package/dist/workspace-index.d.ts.map +1 -1
  106. package/dist/workspace-index.js +11 -0
  107. package/dist/workspace-manifest.js +3 -3
  108. package/executors.json +7 -6
  109. package/managed/raw/patches/nx@23.2.1.patch +118 -24
  110. package/managed/raw/patches/ttsc@0.34.1.patch +139 -0
  111. package/managed/raw/tooling/devenv +1 -2
  112. package/managed/raw/tooling/direnv/developer-links.ts +124 -51
  113. package/managed/raw/tooling/direnv/devenv.smoo.nix +34 -15
  114. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -10
  115. package/managed/raw/tooling/direnv/installed-bun-links.ts +7 -6
  116. package/managed/raw/tooling/direnv/setup-environment.ts +49 -24
  117. package/managed/raw/tooling/direnv/ttsc-env.sh +8 -6
  118. package/managed/raw/tooling/git-hooks/pinned-revisions-served.ts +252 -0
  119. package/managed/raw/tooling/git-hooks/pre-push.sh +34 -32
  120. package/managed/templates/github/actions/cache-node-modules/action.yml +1 -1
  121. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +12 -11
  122. package/package.json +277 -11
  123. package/runtime/nx-publish/.build-inputs.json +11 -0
  124. package/runtime/nx-publish/cache_adapter.js +45 -0
  125. package/runtime/nx-publish/nx_publish.js +60 -0
  126. package/runtime-input.sh +62 -26
  127. package/src/bin/smoo-nx-go-test-build.ts +83 -0
  128. package/src/bin/smoo-nx-go-test-run.ts +140 -0
  129. package/src/bin/smoo-nx-publish.ts +4 -0
  130. package/src/bounded-test-policy.ts +9 -8
  131. package/src/cargo-retention-hook.ts +16 -10
  132. package/src/cargo-workspace.ts +12 -24
  133. package/src/cross-check-policy.ts +2 -2
  134. package/src/deploy-policy.ts +11 -0
  135. package/src/eslint-file-set.ts +4 -1
  136. package/src/eslint-sources.ts +134 -0
  137. package/src/executors/all-verdicts/executor.ts +58 -3
  138. package/src/executors/all-verdicts/schema.json +4 -0
  139. package/src/executors/all-verdicts/schema.ts +14 -0
  140. package/src/executors/bounded-exec/bounds.ts +132 -15
  141. package/src/executors/bounded-exec/executor.ts +329 -34
  142. package/src/executors/bounded-exec/hang-diagnostics.ts +3 -2
  143. package/src/executors/bounded-exec/mbx-pool.ts +158 -17
  144. package/src/executors/bounded-exec/mbx-queue.ts +170 -0
  145. package/src/executors/bounded-exec/progress.ts +171 -18
  146. package/src/executors/bounded-exec/runner-sizing.ts +73 -7
  147. package/src/executors/bounded-exec/runtime-pin.ts +1 -1
  148. package/src/executors/bounded-exec/test-result-writer.ts +152 -0
  149. package/src/executors/bounded-exec/test-results.ts +39 -0
  150. package/src/executors/bounded-exec/verdict.ts +115 -5
  151. package/src/executors/wrangler-deploy/deploy-hash.ts +15 -0
  152. package/src/executors/wrangler-deploy/executor.ts +63 -0
  153. package/src/executors/wrangler-deploy/hasher.ts +111 -0
  154. package/src/executors/wrangler-deploy/schema.json +16 -0
  155. package/src/executors/wrangler-deploy/schema.ts +4 -0
  156. package/src/go-tests.ts +67 -0
  157. package/src/index.ts +368 -323
  158. package/src/managed-files/files.ts +5 -0
  159. package/src/nx-publish.ts +157 -0
  160. package/src/process-group.ts +2 -2
  161. package/src/runtime-input-policy.ts +4 -4
  162. package/src/test-timings.ts +72 -14
  163. package/src/tool-bins.ts +13 -9
  164. package/src/version-actions.cts +10 -11
  165. package/src/workspace-config-policy.ts +20 -29
  166. package/src/workspace-index.ts +12 -0
  167. package/src/workspace-manifest.ts +3 -3
  168. package/test-timings.json +131 -125
  169. package/dist/executors/clean-outputs/executor.d.ts +0 -26
  170. package/dist/executors/clean-outputs/executor.d.ts.map +0 -1
  171. package/dist/executors/clean-outputs/executor.js +0 -83
  172. package/dist/executors/clean-outputs/schema.d.ts +0 -4
  173. package/dist/executors/clean-outputs/schema.d.ts.map +0 -1
  174. package/src/executors/clean-outputs/executor.ts +0 -131
  175. package/src/executors/clean-outputs/schema.json +0 -15
  176. package/src/executors/clean-outputs/schema.ts +0 -3
  177. /package/dist/executors/{clean-outputs → wrangler-deploy}/schema.js +0 -0
package/README.md CHANGED
@@ -57,16 +57,19 @@ with `tsconfig.lib.json` receives transformer-aware `tsc-js` and native `typeche
57
57
  - `test-watch` from explicit `test` commands for Bun and Vitest packages
58
58
  - Cargo workspace targets from a neighboring workspace-root `Cargo.toml`
59
59
  - aggregate `build` and `lint` targets
60
- - an uncached `shard-timings` check, which `lint` depends on, beside `bun test` targets sharded with `--shard` and
61
- balanced with `--timings`
62
- - an uncached `deploy` for a PRIVATE project with a wrangler manifest, running
63
- `smoo wrangler deploy-stage --stage {args.stage}`
60
+ - a cached `shard-timings` check, which `lint` depends on, beside `bun test` targets sharded with `--shard` and balanced
61
+ with `--timings`
62
+ - a cached `deploy` for a PRIVATE project with a wrangler manifest: the `wrangler-deploy` executor, which runs
63
+ `smoo wrangler deploy-stage --stage <stage>`
64
64
 
65
65
  The deploy is one target that takes whichever stage it is given, never a configuration per stage: pull-request stages
66
66
  are `prN` for unbounded N, so `nx run <project>:deploy --stage=pr42` has to work for a stage no enumeration could list.
67
- It is never cached, because a cache hit would mean "we once uploaded this hash", which a rollback falsifies silently.
68
- Declaring `deploy` locally overrides only the properties it names, so a project adds cross-project ordering with
69
- `"dependsOn": ["...", "backend:deploy"]` and keeps the inferred command; a project that declares `deploy-build` gets
67
+ It is cached on what it uploads (the project's files and its build half's output) and the stage, but the executor's
68
+ hasher answers that hash only while the stage serves the version tagged with it. Any other live version, or none it can
69
+ read, adds a nonce to the hash, so the run misses and deploys, still tagging the artifact's version; a rollback is never
70
+ answered from the cache. Hashing the live tag in instead would never converge, since the version is tagged with the
71
+ hash. Declaring `deploy` locally overrides only the properties it names, so a project adds cross-project ordering with
72
+ `"dependsOn": ["...", "backend:deploy"]` and keeps the inferred executor; a project that declares `deploy-build` gets
70
73
  that edge instead of `build`, and the plugin caches that half without inventing its command.
71
74
 
72
75
  `private: true` is half the detection, because a wrangler manifest alone does not mean deployable: a published library
@@ -77,15 +80,28 @@ question, answered only by the deploy tags the CLI reads (`stage-deploy-target`
77
80
 
78
81
  Lint commands are inferred per project. A workspace Biome configuration enables the project-wide Biome check; an ESLint
79
82
  flat configuration enables ESLint for existing JavaScript/TypeScript files under that project's `src` and the files its
80
- `tsconfig.test.json` declares, wherever they live. TypeScript resolves inherited `include`, `files` and `exclude`; the
81
- same sources, the test declaration and its existing `extends` chain are explicit lint cache inputs. Both lists hold only
82
- files in Nx's workspace file index (.gitignore and .nxignore applied), so a gitignored generated module that a build
83
- left on disk is neither linted nor keyed, and the lint target is the same in every checkout of one tree. Rust-only
83
+ `tsconfig.test.json` declares, wherever they live. TypeScript resolves inherited `include`, `files` and `exclude`. Only
84
+ files in Nx's workspace file index (.gitignore and .nxignore applied) count, so a gitignored generated module that a
85
+ build left on disk is neither linted nor keyed, and the lint target is the same in every checkout of one tree. Rust-only
84
86
  source trees keep their Cargo validation and manifest checks without invoking ESLint on nonexistent JavaScript inputs.
85
87
  Test-config diagnostics retain TypeScript's parsed-command-line types through bootstrap emit; invalid declarations fail
86
- with their diagnostic code and message, while an empty test program (TS18003) contributes no test files. Adding
87
- JavaScript/TypeScript sources or changing the declared test program updates lint coverage automatically. The target's
88
- `metadata.eslintFileSet` retains that exact command and workspace-relative file list for cache inspectors.
88
+ with their diagnostic code and message, while an empty test program (TS18003) contributes no test files.
89
+
90
+ The ESLint command names no file. It is `eslint {eslintSources}`, and the target's `eslintProjectRoot` option names the
91
+ project whose sources the placeholder stands for. A graph holds the files of the moment it was computed, and the daemon
92
+ serves it past a deletion or an addition its watcher never reported: a list in the command made ESLint refuse a pattern
93
+ no file matches, and left a new file unlinted, until the graph recomputed. The `all-verdicts` executor replaces the
94
+ placeholder when the command runs, with the files the rules above select out of a fresh workspace file index: a new
95
+ native context over the filesystem, never the table of the process or of the daemon, which learn of a write only when a
96
+ watcher event reaches them. A project with none passes without starting ESLint. Adding JavaScript/TypeScript sources or
97
+ changing the declared test program changes what the next run lints, with no graph computation in between.
98
+
99
+ The lint inputs key the same program without naming each file: the test declaration and its existing `extends` chain,
100
+ one glob over the JavaScript and TypeScript kinds for each directory the declaration's include patterns walk (none for a
101
+ directory outside the workspace or inside a build output directory), and every other program file by name. A file the
102
+ program gains is keyed the moment it exists. A glob also covers what `exclude` removes from the program: keyed, never
103
+ linted. The target's `metadata.eslintFileSet` retains the command and the workspace-relative file list the graph
104
+ resolved, for cache inspectors: the list describes that graph, and what runs is read when it runs.
89
105
  `@smoothbricks/nx-plugin/eslint-file-set` owns its type and generated validator; an inspector can resolve each file's
90
106
  actual ESLint parser program instead of guessing from the project or target name.
91
107
 
@@ -95,8 +111,8 @@ errors would hide another's until a later run. `all-verdicts` starts every comma
95
111
  command's output prints as one block when it closes, then every command's verdict: `PASS`, `FAIL (exit n)`, or
96
112
  `UNJUDGED` with its cause when a signal ended it, it never started, or the run itself was signalled. A signal to the run
97
113
  ends each command's process group, and the run then ends by the same signal. The target passes only when every command
98
- passed; an empty command list is refused, since it could never fail. The options keep `commands` and `cwd`, so each
99
- tool's command, the inputs that key it and `metadata.eslintFileSet` are what they were.
114
+ passed; an empty command list is refused, since it could never fail. The options are `commands`, `cwd` and, for a
115
+ project with an ESLint command, `eslintProjectRoot`; a command's block and verdict name it as it ran.
100
116
 
101
117
  Lint inputs include dependency production inputs because type-aware ESLint reads dependencies' declarations. This uses
102
118
  `^production` unless the workspace opts into the versionless production input described below. Keep
@@ -206,10 +222,10 @@ last 60 lines before fixture retirement removes them. The record-change and rest
206
222
 
207
223
  The plugin discovers Cargo workspaces beside Nx project manifests at any depth:
208
224
 
209
- - **Workspace owner:** the project beside a workspace `Cargo.toml` owns one `cargo-fetch`, `cargo-test-archive`,
210
- `cargo-lint`, cross-check, mutation, bench, and `cargo-retention` target. Its `cargo-lint` and `cargo-test` aggregates
211
- reach all workspace crates, including a root `[package]`; `cargo-test` is the ordinary suite, and the project's `test`
212
- also reaches the serial test groups (below).
225
+ - **Workspace owner:** the project beside a workspace `Cargo.toml` owns one `cargo-fetch`, `cargo-test-build`,
226
+ `cargo-lint`, cross-check, mutation and bench target. Its `cargo-lint` and `cargo-test` aggregates reach all workspace
227
+ crates, including a root `[package]`; `cargo-test` is the ordinary suite, and the project's `test` also reaches the
228
+ serial test groups (below).
213
229
  - **Crate owner:** the deepest Nx project directory containing a crate owns `cargo-test-<crate>` targets. Its
214
230
  `cargo-lint` delegates to the workspace owner's one verdict, and `lint` never depends on the workspace test suite.
215
231
  Projects can own multiple crates. A nested independent workspace has its own prerequisites and does not inherit those
@@ -218,7 +234,7 @@ The plugin discovers Cargo workspaces beside Nx project manifests at any depth:
218
234
  `cargo --frozen clippy --workspace --all-targets --target-dir target/cargo-lint --config 'build.warnings="deny"'`
219
235
  cover every member. Clippy of a crate is a check build of its whole closure, so a target directory per crate rebuilt
220
236
  every shared dependency once per crate — 49 closures and 11 GiB on one repository — and no per-crate cache hit repaid
221
- it. Clippy writes its own `target/cargo-lint`, so the archive, the Wasm and N-API builds and every other dev build
237
+ it. Clippy writes its own `target/cargo-lint`, so the test build, the Wasm and N-API builds and every other dev build
222
238
  never queue behind a workspace-wide check on Cargo's build-directory lock. The price is that clippy compiles its own
223
239
  host units (build scripts, proc-macros) once per directory. `cargo-lint-cross` keeps `target/cargo-lint-cross` for the
224
240
  same lock reason: a foreign triple's units are distinct anyway, and its own lock keeps the cross check from queueing
@@ -229,74 +245,85 @@ The plugin discovers Cargo workspaces beside Nx project manifests at any depth:
229
245
  lock serializes the invocations that share a directory.
230
246
  - **Retention:** Cargo never deletes a unit generation a later build superseded, so a busy checkout's target directory
231
247
  only grows. After each Nx run that executed a Cargo producer (an inferred target that builds, checks or tests into the
232
- target directory, marked by its `cargoProducer` metadata: `cargo-test-archive`, `cargo-test`, `cargo-lint`,
248
+ target directory, marked by its `cargoProducer` metadata: `cargo-test-build`, `cargo-test`, `cargo-lint`,
233
249
  `cargo-lint-cross`, mutation, bench, and the napi and wasm builds), the plugin's `postTasksExecution` runs its Cargo
234
- retention hook, which calls `@smoothbricks/cargo-retain` for each Cargo workspace that is due for maintenance. In an
235
- mbx project, whose canonical environment names `MBX_CACHE_DIR` beside `MBX_TARGET_VIEWS=1`, the targets are mbx's to
236
- collect and the hook does nothing. Automatic passes run at most once per 24 hours after a successful completed pass,
237
- one that reclaimed in every root; its existing receipt records completion time and configuration/workspace/target
238
- identity. A not-due hook reports that scheduling decision without locks, a fingerprint scan, cleanup or receipt
239
- replacement. It does not claim newer outputs were inspected or the graph is unchanged. Busy, refused, invalid, foreign
240
- or backward-clock receipt evidence never postpones the next attempt. The first executed producer after the interval
241
- runs a current pass; cache replays, fetch and noop tasks start none. Manual preview and apply always run fresh. Due
242
- passes reclaim superseded generations under `<profile>/build/<package>/<META>/`. They keep the newest generation, by
243
- last use, of each unit identity of a workspace member (identity is every fingerprint field but its edges, source state
244
- and toolchain, which is `rustc` and the `--sysroot` flag; integers read exactly, so a newer toolchain supersedes an
245
- older one), every unit used in the last 24 hours (`-Zmtime-on-use` stamps each use; cowshed exports
246
- `CARGO_UNSTABLE_MTIME_ON_USE=true` to every host shell and job of a Cargo project, and a repository outside cowshed
247
- sets `[unstable] mtime-on-use = true`), and the transitive dependency closure of those across every profile, host and
248
- cross alike. A root whose hash files show no stamp (none newer than its compile by more than 24 hours) reports
249
- `recency-unknown: mtime-on-use off`: its last use is then only its last compile. A profile that holds a legacy layout
250
- beside the current one is read for the current one, and its legacy entries are retained as `legacy-layout`. A pass
251
- holds every profile's Cargo locks without waiting: one held lock skips the pass as `busy`, and a profile it cannot
252
- read (unreadable fingerprint, missing `build/` or lock, or a legacy layout's records alone) refuses the whole pass, as
253
- does a lock it cannot attempt at all, with the reason named: under Node, macOS takes its `flock(2)`s in-process
254
- (`open(2)` with `O_EXLOCK | O_NONBLOCK`) and starts no helper, and other platforms hold them in a perl child, so a
255
- sandbox that refuses to exec perl, like a lock file that cannot be opened, refuses the pass instead of failing the
256
- run. The compiled CLI opens and locks through a small C wrapper (`native/flock.c`) that captures `errno` immediately.
257
- Each provider's canonical refusal retains the operation, exact lock path, actual host errno and OS cause: only
258
- contention is `busy`; any other failure refuses the pass. The hook only reports outcomes and never fails the run it
259
- follows: whatever escapes a pass is logged as a warning, and the next workspace is still tried. It moves each
260
- reclaimed generation into the profile's `.smoo-retention-trash/` under that hold, recording its inode first, and
261
- unlinks it after letting go. Each proven generation gets a synchronous, non-symlink-following inode census and one
262
- native recursive removal, not an awaited lstat/unlink for every artifact. The census counts internal hardlinks once;
263
- the pass ledger drops an inode only when its last link is removed, so bytes freed and bytes still linked outside the
264
- removed generations remain distinct. The manifest's root identity is rechecked immediately before removal. A failed
265
- removal is an I/O failure, not a successful reclaim or a new completed maintenance receipt. It writes its last report
266
- to `<target>/.smoo-cargo-retention.json`. Cargo's root-relative fingerprint paths distinguish cross profiles from
267
- nested target roots under the lock; mixed, foreign or unprovable cross-profile roots refuse the pass rather than
268
- silently dropping their dependency edges. That scan finds a nested target root (`target/cargo-lint`,
269
- `target/cargo-lint-cross`) by locking and reading its depth-two profile like the target's own, so a pass held or
270
- refused there reaches no nested root. Each nested root then gets the same pass over its own profiles, host and cross,
271
- under only their Cargo locks and the target's one retention lock, one root after another: units never depend across
272
- roots, so a nested root that is held (a lint running into it) or refused is skipped and reported in the receipt's
273
- `nestedRoots` without holding up the others, and the receipt schedules the next automatic pass only when every root
274
- reclaimed. Only generations are reclaimed, never a root or a profile, and a nested root holding no unit of a workspace
275
- member is retained whole as `foreign-root`. A pre-created target need not carry Cargo's optional backup tag; a present
276
- but invalid tag still refuses the pass. Every pass still reads the current fingerprint graph. The locked scan reuses
277
- directory-entry types and reads its small metadata files synchronously, avoiding duplicate stats and one asynchronous
278
- dispatch per tiny file; it does not walk retained artifact contents or reuse an earlier graph that could miss in-place
279
- recompiles. `cargo-retention` runs that package's native `smoo-nx-cargo-retain` executable to preview the same
280
- selection, nested roots included, without changing anything. Each profile's `incremental/<crate>-<id>/` directories go
281
- in the same pass: rustc keeps one per build variant and never removes the one a feature, profile or flag change
282
- superseded. One is kept while its newest finished session started inside the compile window (`invoked.timestamp` to
283
- the hash file's last write) of a kept unit of the same crate, while it started within the recent-use window, or while
284
- the directory holds an unfinished or unreadable session. The split-debuginfo objects rustc keeps inside current
285
- generations (rust-lang/rust#161824) are not reclaimed, so a target directory is not bounded by them. Empty fingerprint
286
- hashes are kept as unfinished compilations. The preservation proof covers Cargo's current unit and dependency records,
287
- not every debug reference in copied binaries or other checkouts. In particular, a binary copied up before a failed
288
- link can outlive the generation its debug map names; this pass does not establish that machine-wide debug closure.
250
+ retention hook, which starts a pass of `@smoothbricks/cargo-retain` for each Cargo workspace that is due for
251
+ maintenance, in a process of its own (below). In an mbx project, whose canonical environment names `MBX_CACHE_DIR`
252
+ beside `MBX_TARGET_VIEWS=1`, the targets are mbx's to collect and the hook does nothing. Automatic passes run at most
253
+ once per 24 hours after a successful completed pass, one that reclaimed in every root; its existing receipt records
254
+ completion time and configuration/workspace/target identity. A not-due hook reports that scheduling decision without
255
+ locks, a fingerprint scan, cleanup or receipt replacement. It does not claim newer outputs were inspected or the graph
256
+ is unchanged. Busy, refused, invalid, foreign or backward-clock receipt evidence never postpones the next attempt. The
257
+ first executed producer after the interval runs a current pass; cache replays, fetch and noop tasks start none. Manual
258
+ preview and apply always run fresh. Due passes reclaim superseded generations under
259
+ `<profile>/build/<package>/<META>/`. They keep the newest generation, by last use, of each unit identity of a
260
+ workspace member (identity is every fingerprint field but its edges, source state and toolchain, which is `rustc` and
261
+ the `--sysroot` flag; integers read exactly, so a newer toolchain supersedes an older one), every unit used in the
262
+ last 24 hours (`-Zmtime-on-use` stamps each use; cowshed exports `CARGO_UNSTABLE_MTIME_ON_USE=true` to every host
263
+ shell and job of a Cargo project, and a repository outside cowshed sets `[unstable] mtime-on-use = true`), and the
264
+ transitive dependency closure of those across every profile, host and cross alike. A root whose hash files show no
265
+ stamp (none newer than its compile by more than 24 hours) reports `recency-unknown: mtime-on-use off`: its last use is
266
+ then only its last compile. A profile that holds a legacy layout beside the current one is read for the current one,
267
+ and its legacy entries are retained as `legacy-layout`. A pass holds every profile's Cargo locks without waiting: one
268
+ held lock skips the pass as `busy`, and a profile it cannot read (unreadable fingerprint, missing `build/` or lock, or
269
+ a legacy layout's records alone) refuses the whole pass, as does a lock it cannot attempt at all, with the reason
270
+ named: under Node, macOS takes its `flock(2)`s in-process (`open(2)` with `O_EXLOCK | O_NONBLOCK`) and starts no
271
+ helper, and other platforms hold them in a perl child, so a sandbox that refuses to exec perl, like a lock file that
272
+ cannot be opened, refuses the pass instead of failing the run. The compiled CLI opens and locks through a small C
273
+ wrapper (`native/flock.c`) that captures `errno` immediately. Each provider's canonical refusal retains the operation,
274
+ exact lock path, actual host errno and OS cause: only contention is `busy`; any other failure refuses the pass. The
275
+ hook only reports outcomes and never fails the run it follows: whatever escapes a pass is logged as a warning, and the
276
+ next workspace is still tried. The pass itself never runs on Nx's thread: Nx awaits `postTasksExecution`, inside its
277
+ daemon when one serves the run, and a pass unlinks synchronously, so one freeing 80 trashed generations on a loaded
278
+ APFS volume held a land gate's daemon, and every client waiting on it, for more than thirty minutes. The hook answers
279
+ only the gate there (not due, the retention lock busy or unattemptable, each reported as above), lets go of the
280
+ retention lock and starts the due pass as the package's Node CLI, `smoo-nx-cargo-retain --apply --automatic`, detached
281
+ (`startRetentionPass`, `launch-node.ts`). Its standard streams are `/dev/null`, and it inherits no descriptor of the
282
+ run's, so neither the run's exit nor a reader of its output waits for it, and the daemon goes on serving. That process
283
+ goes through the gate again, takes every lock itself and records its outcome in the receipt; while it frees its trash
284
+ it holds the retention lock, so the next run's gate reports `busy` and starts no second pass. It moves each reclaimed
285
+ generation into the profile's `.smoo-retention-trash/` under that hold, recording its inode first, and unlinks it
286
+ after letting go. Each proven generation gets a synchronous, non-symlink-following inode census and one native
287
+ recursive removal, not an awaited lstat/unlink for every artifact. The census counts internal hardlinks once; the pass
288
+ ledger drops an inode only when its last link is removed, so bytes freed and bytes still linked outside the removed
289
+ generations remain distinct. The manifest's root identity is rechecked immediately before removal. A failed removal is
290
+ an I/O failure, not a successful reclaim or a new completed maintenance receipt: the receipt says `failed` with the
291
+ reason, as it does for anything else that fails an applied pass past its gate. It writes its last report to
292
+ `<target>/.smoo-cargo-retention.json`. Cargo's root-relative fingerprint paths distinguish cross profiles from nested
293
+ target roots under the lock; mixed, foreign or unprovable cross-profile roots refuse the pass rather than silently
294
+ dropping their dependency edges. That scan finds a nested target root (`target/cargo-lint`, `target/cargo-lint-cross`)
295
+ by locking and reading its depth-two profile like the target's own, so a pass held or refused there reaches no nested
296
+ root. Each nested root then gets the same pass over its own profiles, host and cross, under only their Cargo locks and
297
+ the target's one retention lock, one root after another: units never depend across roots, so a nested root that is
298
+ held (a lint running into it) or refused is skipped and reported in the receipt's `nestedRoots` without holding up the
299
+ others, and the receipt schedules the next automatic pass only when every root reclaimed. Only generations are
300
+ reclaimed, never a root or a profile, and a nested root holding no unit of a workspace member is retained whole as
301
+ `foreign-root`. A pre-created target need not carry Cargo's optional backup tag; a present but invalid tag still
302
+ refuses the pass. Every pass still reads the current fingerprint graph. The locked scan reuses directory-entry types
303
+ and reads its small metadata files synchronously, avoiding duplicate stats and one asynchronous dispatch per tiny
304
+ file; it does not walk retained artifact contents or reuse an earlier graph that could miss in-place recompiles. That
305
+ package's `smoo-nx-cargo-retain [cargo-workspace-dir]` previews the same selection, nested roots included, without
306
+ changing anything. It is a tool run by hand, not an Nx target: its verdict is about this machine's disk, not the
307
+ commit, and no input could key it. Each profile's `incremental/<crate>-<id>/` directories go in the same pass: rustc
308
+ keeps one per build variant and never removes the one a feature, profile or flag change superseded. One is kept while
309
+ its newest finished session started inside the compile window (`invoked.timestamp` to the hash file's last write) of a
310
+ kept unit of the same crate, while it started within the recent-use window, or while the directory holds an unfinished
311
+ or unreadable session. The split-debuginfo objects rustc keeps inside current generations (rust-lang/rust#161824) are
312
+ not reclaimed, so a target directory is not bounded by them. Empty fingerprint hashes are kept as unfinished
313
+ compilations. The preservation proof covers Cargo's current unit and dependency records, not every debug reference in
314
+ copied binaries or other checkouts. In particular, a binary copied up before a failed link can outlive the generation
315
+ its debug map names; this pass does not establish that machine-wide debug closure.
289
316
  - **Scheduling:** inference never throttles Nx. It sets no `parallelism: false` or `parallel: false`, no cap, and no
290
317
  edge whose only purpose is keeping two cargo writers off one `target/`: Cargo owns that lock, and a second process
291
- waits inside cargo. An edge states a real consumer — fetch before frozen cargo, the archive before the runners,
318
+ waits inside cargo. An edge states a real consumer — fetch before frozen cargo, the test build before the runners,
292
319
  `napi-debug` before the tests that load its addon. A producer and its consumer inside one task are one `&&` command
293
- (`mkdir` then the archive, `cargo build` then `wasm-bindgen`); independent commands (`cargo fmt` and clippy,
320
+ (`mkdir` then the test build, `cargo build` then `wasm-bindgen`); independent commands (`cargo fmt` and clippy,
294
321
  per-manifest `cargo fetch`, Biome and ESLint) stay in a `commands` list that Nx runs side by side.
295
322
  - **Overrides:** normal Nx merging applies. Explicit `nx.targets` fields replace inferred fields, while omitted fields
296
323
  retain their inferred base. Use `"dependsOn": ["...", "extra"]` to preserve inferred prerequisites when adding an
297
324
  edge; replacing the array makes its author responsible for fetching before frozen Cargo commands and producing the
298
- archive before any runner consumes it. This repository also declares the archive producer explicitly in both APFS
299
- runners' owning project targets, so a cold checkout reaches it before extraction.
325
+ test build before any runner consumes it. This repository also declares the test build explicitly in both APFS
326
+ runners' owning project targets, so a cold checkout reaches it before their sweep runs its executable.
300
327
 
301
328
  Member and exclude patterns may use `*` and `?` in any path segment (for example, `packages/*/crates/*`). Unsupported
302
329
  patterns and member patterns that match no directory fail graph construction instead of silently omitting crates.
@@ -322,8 +349,8 @@ layout. Declarations interpolate the same options the commands use, so their out
322
349
  together. The host-resolved `cli-native` and `napi-native` aggregates delegate to the existing platform producers and
323
350
  declare no outputs of their own. Their `production` configuration forwards that same selection to the host producer. A
324
351
  test that executes the CLI or loads the ordinary platform addon names those producers; tests using the explicit test
325
- addon still name `napi-debug`. The land host runs `cowshed:cli-native:production` then the uncached, dependency-free
326
- `cowshed:release-check`; the guard inspects the produced shipping bytes, not a development output or a cache replay.
352
+ addon still name `napi-debug`. The land host runs `cowshed:cli-native:production` then the dependency-free
353
+ `cowshed:release-check`, cached on a runtime digest of the shipping bytes it inspects, never on a development output.
327
354
 
328
355
  After the fast-forward, main's output restoration explicitly requests `build`, `cli-native`, and `napi-native`. The
329
356
  normal build remains JS/dependency-only; this post-land seam restores the source-selected host CLI/addon and their input
@@ -342,17 +369,22 @@ Rust LMAO's opt-in source-revision contract is defined in
342
369
  targets declare `{ "env": "LMAO_GIT_REVISION" }` as an input. Default dev/test runs leave it unset; publishing jobs set
343
370
  it to the dispatch commit, so those builds include the explicit revision in their key without making dev runs
344
371
  commit-keyed. The `production` configuration selects the shipping profile; it does not discover a Git revision. The root
345
- workspace's cached nextest archive hashes that variable too, because it contains the compiled LMAO test binaries.
372
+ workspace's cached test build hashes that variable too, because it compiles the LMAO test binaries.
346
373
 
347
374
  ### Cargo cache boundaries
348
375
 
349
- `cargo-fetch` is uncached because the registry lives outside Nx outputs. `cargo-test-archive` is the one cached cargo
350
- build, and it is the step that compiles the test binaries ahead of the bounded runners; there is no separate uncached
351
- `cargo test --no-run` warm-up, since it compiled the same units the archive does. Cargo's own incremental cache avoids
352
- recompiling unchanged code. Nx never restores or collects shared Cargo build directories; lint and test **results**, and
353
- dedicated Wasm/N-API **outputs**, remain cacheable. Being uncached, `cargo-fetch` keys nothing, and it names what it
354
- reads (the manifests, the lock and the Cargo configuration) so that a producer receipt binds those and not every file of
355
- its project, a repository-root project's symlinked managed files among them.
376
+ Every inferred cargo target that runs work is cached, `cargo-fetch` included. Its download lands in `CARGO_HOME`,
377
+ outside Nx outputs, so its key names the registry's state instead: the manifests, the lock and the Cargo configuration
378
+ it reads, and a runtime input that is `fetched` when an offline `cargo fetch --locked` of each manifest succeeds. A
379
+ registry missing a locked crate gives a value of its own run, which no cached run matches, so the fetch runs; a complete
380
+ one makes an unchanged lock a cache hit. `cargo-test-build` is the one cached cargo build, and it is the step that
381
+ compiles the test binaries ahead of the bounded runners; there is no separate `cargo test --no-run` warm-up, since it
382
+ compiled the same units the test build does. Cargo's own incremental cache avoids recompiling unchanged code. Nx never
383
+ restores or collects shared Cargo build directories; lint and test **results**, and dedicated Wasm/N-API **outputs**,
384
+ remain cacheable. `mutation` and `bench` key on the workspace's crates and toolchain like `cargo-lint`, `mutation` also
385
+ on `.cargo/mutants.toml` and `cargo mutants --version` with `mutants.out` as its output: an unchanged tree measures
386
+ nothing new. A cross-triple test runner keys on its archive's own bytes, the binaries it runs, since the machine that
387
+ runs it did not build them.
356
388
 
357
389
  Validation inputs include the crate's files, every file its sources compile in through a literal `include_str!` or
358
390
  `include_bytes!` path outside the crate's directory (a shipped skill or a shared corpus beside the crates), the crates
@@ -377,7 +409,7 @@ environment probe: a target that runs one must name the script itself as an inpu
377
409
  hash the manifest of every package the workspace build compiles inside the Nx workspace (a member's, and a path
378
410
  package's that reaches the build only as some crate's dev-dependency), because those affect unified features, and the
379
411
  nextest executable/configuration. While the build compiles a path package outside the Nx workspace, every runner also
380
- names externalRustCrates, which then must be declared: a runner's key does not follow archive outputs.
412
+ names externalRustCrates, which then must be declared: a runner's key does not follow the test build's outputs.
381
413
 
382
414
  Nothing machine-local takes part. The ambient cargo environment as a whole and the global `$CARGO_HOME/config.toml` are
383
415
  deliberately not hashed: their values carry per-checkout state directories (`CARGO_INSTALL_ROOT` moves under the active
@@ -401,14 +433,15 @@ build-script names) are not compared: a run that recorded one was started by a `
401
433
 
402
434
  A target whose inputs a repository DECLARES replaces the inferred list, toolchain identity included. Name
403
435
  `cargoToolchain` in that declaration, or in the named input it uses: inference defines it, in every project that has
404
- cargo targets, as the whole identity. A restated lock is not enough, because the identity also holds the runtime input
405
- no fileset can state, and `smoo monorepo check` refuses a cached cargo target that does not reach the name. The replaced
406
- list also held the target's `externalDependencies` entries described below; restate them (`[]` for a target that runs
407
- only cargo, and the lock-scope node of its crates), or every lockfile change re-keys the target.
436
+ inferred or declared cargo targets, as the whole identity. A restated lock is not enough, because the identity also
437
+ holds the runtime input no fileset can state, and `smoo monorepo check` refuses a cached cargo target that does not
438
+ reach the name. The replaced list also held the target's `externalDependencies` entries described below; restate them
439
+ (`[]` for a target that runs only cargo, and the lock-scope node of its crates), or every lockfile change re-keys the
440
+ target.
408
441
 
409
442
  Every cached cargo target names the npm packages its command runs as `externalDependencies`: none for cargo itself, and
410
443
  `@smoothbricks/nx-plugin` for a target that runs its executor or reads its installed files (the nextest tool config, the
411
- archive extractor). Without that input Nx keys a task whose executor is not an `@nx/` one on every package in the
444
+ test-binaries helper). Without that input Nx keys a task whose executor is not an `@nx/` one on every package in the
412
445
  lockfile, so a lockfile-only commit re-ran every cargo verdict. Inside this repository the plugin is a workspace
413
446
  project, which Nx refuses as an external dependency, so the list is empty here. The plugin tells the two apart by the
414
447
  workspace's own `node_modules/@smoothbricks/nx-plugin`: one that resolves inside the workspace and outside every
@@ -521,7 +554,10 @@ Nx 23.2.1 hashes a runtime input's stdout and stderr and ignores its exit status
521
554
  its error text, one string for every history, toolchain or file it could not read, and a result cached under it is
522
555
  replayed for all of them. The script keys on the command's stdout alone and turns a nonzero exit into an Nx error: it
523
556
  ends stdout with the byte 0xFF, and Nx refuses output that is not UTF-8
524
- (`invalid utf-8 sequence of 1 bytes from index N`, exit 1). Nx drops a runtime input's stderr, so a failure that only
557
+ (`invalid utf-8 sequence of 1 bytes from index N`, exit 1). That native message names neither the task nor the input;
558
+ the carried Nx patch's hasher rethrows it as `Could not hash <tasks>: invalid utf-8 sequence …` and lists each runtime
559
+ input of those tasks with the tasks that hash it (`patches/README.md`, "A hash failure names its tasks and runtime
560
+ inputs"). It names the candidates, not the one that failed. Nx drops a runtime input's stderr, so a failure that only
525
561
  wrote to stderr would be invisible. The wrapper retains each failure under the checkout's
526
562
  `.runtime-input-failures/failure.XXXXXXXXXX/`, outside Nx's state and the temporary directory. These private records
527
563
  survive `nx reset`, task-cache cleanup and temporary-directory retirement; they remain until the operator removes them.
@@ -533,16 +569,18 @@ cat .runtime-input-failures/*/report
533
569
 
534
570
  `smoo github-ci nx-smart`, `nx-run-many` and `nx-deploy` print every report retained during a failed Nx run
535
571
  (`runtimeInputFailureReports(root, sinceMs)`, `@smoothbricks/nx-plugin/runtime-input-policy`), so a CI log names the
536
- command and its cause beside Nx's decoder error, which names neither.
572
+ command and its cause beside Nx's error, which names only the candidates.
537
573
 
538
574
  Each readable `report` names the command, its indexed arguments, working directory, exit status and original stderr.
539
575
  `argv` retains the exact NUL-delimited argument vector (including empty arguments), `stderr` retains the original bytes
540
576
  (including trailing newlines), and `exit-status` retains the decimal status. The wrapper also attempts a stderr summary
541
- naming the command and report path, and displays the report on `/dev/tty` when it can open a controlling terminal.
542
- Neither display is guaranteed through Nx's daemon or a headless harness: rely on the retained report, not on Nx
543
- forwarding stderr. A failed terminal write is retained in the record's `terminal-error`. Records can contain arguments
544
- or stderr with credentials; keep them private and inspect before sharing. Evidence-storage errors name the problem and
545
- the surviving stderr capture on stderr; they never remove the refusal byte or replace the command's status.
577
+ naming the command and report path, and displays the report on `/dev/tty` when it can open a controlling terminal. Nx's
578
+ daemon has none (`ENXIO`) and cowshed's sandbox denies it (`EPERM`); having no terminal is no failure of the input, so
579
+ the shell's refusal of the open joins the stderr summary and the record gains nothing. Neither display is guaranteed
580
+ through Nx's daemon or a headless harness: rely on the retained report, not on Nx forwarding stderr. A write that fails
581
+ on a terminal that did open is retained in the record's `terminal-error`. Records can contain arguments or stderr with
582
+ credentials; keep them private and inspect before sharing. Evidence-storage errors name the problem and the surviving
583
+ stderr capture on stderr; they never remove the refusal byte or replace the command's status.
546
584
 
547
585
  Successful commands still emit only their original stdout bytes, discard stderr and retain no failure record: no
548
586
  evidence path, timestamp or diagnostic enters a successful key. `runtime-input.test.ts` compares that byte stream and
@@ -652,8 +690,8 @@ prefixes.
652
690
  `bun packages/nx-plugin/benchmarks/cargo-closure-input.bench.ts` measures the real async inference entry with cached
653
691
  Cargo resolution/source scans at 1–4,096 packages, including a one-package overhead row. Its expansion oracle checks
654
692
  complete ordered input equality before timing; filesystem scanning and Cargo resolution are not part of this
655
- measurement. `bun packages/nx-plugin/benchmarks/compact-candidates.bench.ts` measures the unchanged output-directory
656
- reduction and converging dependency-graph traversal separately, without invoking an executor or gate.
693
+ measurement. `bun packages/nx-plugin/benchmarks/compact-candidates.bench.ts` measures the converging dependency-graph
694
+ traversal, without invoking an executor or gate.
657
695
 
658
696
  Literal `include_str!` and `include_bytes!` files also belong to the closure, including data inside a crate and tracked
659
697
  files outside its directory (such as a shipped Markdown skill). One Rust lexer excludes comments and example strings;
@@ -879,13 +917,34 @@ installed. Every fallback costs cache hits and never trades away invalidation, b
879
917
  reporting a failing one — a fileset that excluded a manifest with no digest replacing it would serve stale results
880
918
  silently.
881
919
 
920
+ ## Accepted task cache publication
921
+
922
+ Declared gates use the emitted `smoo-nx-publish` executable from this package; they do not carry a publisher copy.
923
+ `hashes <run.json> <since-epoch-seconds>` prints the distinct succeeded task hashes as JSON, refusing a summary begun
924
+ before that invocation. Capture each list immediately, before another Nx call overwrites the summary.
925
+ `publish <absolute-checkout> <hashes.json>` sends existing local cache entries to that checkout's accepted-store route.
926
+ Call it only after every gate check passes. Red gates publish nothing, and ordinary shed clients stay read-only.
927
+ Publication prints stored/existing/skipped counts; an operational refusal exits nonzero with its cause. The gate reports
928
+ that cache finding distinctly without changing the checks' verdict (cowshed specs 03, "Nx accepted-task artifact
929
+ service", and 05, "Publication"). No task is rebuilt and no shell is evaluated by the publisher.
930
+
931
+ The canonical cache adapter and native publisher remain in
932
+ `packages/cowshed/crates/cowshed-core/src/build_volume/{cache_adapter.js,nx_publish.js}`. The cached
933
+ `copy-nx-publish-assets` target declares those source inputs and owns `runtime/nx-publish/`, disjoint from the entire
934
+ TypeScript `dist/` output. It copies their unchanged bytes; there is one implementation, not two maintained sources. It
935
+ writes `.build-inputs.json` beside them through `smoo-nx-build-inputs --input`, so a developer link to this checkout
936
+ judges `runtime/nx-publish/` by the bytes it copied (specs/cli/01_workspace_reconciliation.md, "Declared developer link
937
+ pins"). `build` depends on that producer and the emitted executable. `test-nx-publish` depends on the concrete
938
+ JavaScript and runtime-asset producers and loads their bytes; tests never build the publisher or its runtime assets
939
+ inline.
940
+
882
941
  ## Build/Test Graph Boundary
883
942
 
884
943
  The final-graph `createMetadata` hook also calls `refuseBuildTestDependencies(graph, workspaceRoot)` from
885
944
  `@smoothbricks/nx-plugin/task-graph-policy`. A `build` aggregate, an inferred build family, or any non-test target with
886
945
  outputs must not reach test work through `dependsOn`, directly or transitively. Inference publishes its semantic kind in
887
946
  target metadata; declared targets use the same test naming policy, including `test`, `test-*`, `cargo-test-*` and
888
- `*-test`. The archive is test work even though it compiles rather than executes.
947
+ `*-test`. The test build is test work even though it compiles rather than executes.
889
948
 
890
949
  Nx's metadata hook precedes its implicit-project-edge pass. The decision first completes any declared implicit edges
891
950
  with Nx's own `applyImplicitDependencies` and `ProjectGraphBuilder` over an isolated dependency map, leaving the
@@ -1149,61 +1208,67 @@ Concrete targets come from concrete files:
1149
1208
  `ttsc`. Transform plugins' diagnostics are enforced by `tsc-js`, which runs them.
1150
1209
  - `typecheck-tests` is inferred from `tsconfig.test.json` and runs the same compiler on
1151
1210
  `-p tsconfig.test.json --noEmit`. It first rebuilds the current package's `tsc-js` output (or its non-TypeScript
1152
- `build`) so self-imports resolve after `clean`. Transform calls in test files are checked when the test runner
1211
+ `build`) so self-imports resolve from its own outputs. Transform calls in test files are checked when the test runner
1153
1212
  transforms them.
1154
1213
  - `typecheck-tests:watch` is inferred from `tsconfig.test.json` and runs the same typecheck in watch mode.
1155
1214
  - `test-watch` is inferred when the package already defines an explicit Bun or Vitest `test` command. The plugin derives
1156
1215
  the corresponding watch command and makes it depend on `typecheck-tests`.
1157
1216
  - A workspace-root `Cargo.toml` provides `cargo-test`, `test`, `cargo-lint`, `mutation`, and `bench`. Build targets
1158
1217
  compile build outputs only: compiling every test binary makes every build a test build. Test runners depend on their
1159
- workspace's `cargo-test-archive` themselves, and a test that executes a CLI or loads an addon names its producer.
1160
- `cargo-test-archive` runs one `cargo --frozen nextest archive --workspace` into `.cache/nextest/archive.tar.zst` and
1161
- is the only cached Cargo compilation of test binaries: it produces a file outside the build-volume links rather than a
1162
- mutable build tree. Nx cache restoration must never replace Cargo's `target` link. Its inputs, like every
1163
- cargo-derived fileset, are anchored at `{workspaceRoot}`: Nx resolves a `{projectRoot}` glob against only the files
1164
- its project owns, and a nested package owns the crates under it, so a root workspace's archive spelled that way hashes
1165
- none of its members and replays stale binaries against edited crates. Each member crate gets a cached
1218
+ workspace's `cargo-test-build` themselves, and a test that executes a CLI or loads an addon names its producer.
1219
+ `cargo-test-build` runs one `cargo --frozen nextest list --workspace --list-type binaries-only --message-format json`
1220
+ into `.cache/nextest/binaries-metadata.json` and `cargo --frozen metadata --format-version 1 --all-features` into
1221
+ `.cache/nextest/cargo-metadata.json`, and is the only cached Cargo compilation of test binaries: mbx caches the build,
1222
+ and its Nx outputs are nextest's reuse-build metadata and the build's key (`.cache/nextest/build.key`, the task's
1223
+ hash), files outside the build-volume links, never the mutable build tree the binaries stay in. Its last step records
1224
+ that key in the target directory it built. Nx cache restoration must never replace Cargo's `target` link. Its inputs,
1225
+ like every cargo-derived fileset, are anchored at `{workspaceRoot}`: Nx resolves a `{projectRoot}` glob against only
1226
+ the files its project owns, and a nested package owns the crates under it, so a root workspace's test build spelled
1227
+ that way hashes none of its members and replays stale binaries against edited crates. Each member crate gets a cached
1166
1228
  `cargo-test-<package>` run (30s slow-test warning, no per-test kill) whose inputs include the crates Cargo builds for
1167
1229
  that crate's tests (from Cargo's locked resolve: its dependencies and its own dev-dependencies, never the
1168
1230
  dev-dependencies of the crates below it), and whose command runs
1169
1231
  `cargo --frozen nextest run --binaries-metadata … --cargo-metadata … --target-dir-remap … --workspace-remap . -E 'package(<crate>)'`
1170
- from the archive's one extraction. Runners therefore execute rather than build: they compile nothing in cargo's build
1171
- tree, and fan out instead of chaining. They do not unpack the archive each: before the run, the host's native
1172
- `smoo-nx-nextest-extract` (`@smoothbricks/nextest-extract`) reads the archive's key and extracts it into
1173
- `<target_directory>/nextest-extracted/<key>` unless a runner already did — one extracts, the others wait — so a
1174
- workspace with ~200 test binaries and ~25 crates unpacks them once per archive instead of once per crate. The key is
1175
- the hash of the `cargo-test-archive` task that produced the archive, which that task writes beside it
1176
- (`.cache/nextest/archive.tar.zst.key`, a declared output Nx restores with the archive), so nothing reads the archive's
1177
- bytes to identify it, a rebuilt or cache-restored archive of other inputs never runs an older extraction's binaries,
1178
- and publishing one removes the others. An archive without a key, or one rewritten while it is being extracted, is
1179
- refused. The target directory is the one `cargo metadata` reports for the runner's Cargo workspace, so a
1180
- `build.target-dir` setting moves the extractions with the build tree. An extraction is per-checkout tool state like
1181
- the rest of that tree, never an Nx output: it lives in Cargo's build tree, which a checkout with a build volume keeps
1182
- off its source tree, and it never sits under a declared output such as `.cache/nextest`. `cargo clean` removes it. A
1183
- repository's own target that runs tests from the workspace archive calls the same helper and passes the same reuse
1184
- flags: `nextest run --archive-file` unpacks the whole archive into a fresh directory under its `TMPDIR`, which for a
1185
- `bounded-exec` task on macOS is a lease on the shared RAM volume (measured: a 548 MB archive unpacks to 1.97 GiB, and
1186
- four such tasks filled the 8 GiB volume). The RAM lease holds what tests write, never the binaries they run.
1187
- `--workspace-remap` is required — an archive records the producing tree's absolute paths, and without it a restored
1188
- archive hands tests another checkout's `CARGO_MANIFEST_DIR`. With it the archive is relocatable, so one cache entry
1189
- serves every checkout of the same commit; nextest re-points `CARGO_BIN_EXE_<name>`/`NEXTEST_BIN_EXE_<name>` at the
1190
- extracted binaries at runtime, but a test that reads them through the compile-time `env!` macro keeps the producing
1191
- tree's path. Per-crate runners accept an empty nextest selection because a valid workspace member may have no tests
1192
- and a hash partition may legitimately be empty. A crate in the project that builds the debug cdylib runs after
1193
- `napi-debug`, because its tests load that addon from `target/debug`. A crate declaring
1194
- `[package.metadata.smoothbricks.wasm-bindgen]` also receives the cacheable `cargo-wasm` output target in its owning
1195
- project.
1232
+ in place, against the binaries the build left in Cargo's target directory. Runners therefore execute rather than
1233
+ build: they compile nothing in cargo's build tree, copy nothing, and fan out instead of chaining. A test archive
1234
+ exists only for a cross build, whose binaries are built on one platform and run on another (`cross-targets`, below); a
1235
+ same-platform run reuses the build in place, where an archive made every run pay for a copy of the workspace's
1236
+ binaries before its first test (measured: 290 binaries, 678 MB, 4.6s on a quiet host and 21s in a gate, per archive).
1237
+ `--target-dir-remap` names this checkout's target directory, which the host's native `smoo-nx-nextest-binaries`
1238
+ (`@smoothbricks/nextest-extract`) reads from `cargo metadata`, so a `build.target-dir` setting is honoured. The
1239
+ binaries are not Nx outputs, and a binary's path is cargo's `-C metadata` hash, which ignores source content: a
1240
+ checkout whose build was a cache hit holds the metadata without the binaries, or with an older tree's at the very
1241
+ paths it names. Each runner's `bounded-exec` fixture (`smoo-nx-nextest-binaries ensure`) therefore compares the key
1242
+ the target directory records with the build's and stats every binary the metadata names; on any difference it rebuilds
1243
+ with the build's own command through mbx, once for the checkout's runners under a lock of its own, and records the
1244
+ key, inside the fixture's build interval and never the progress-bounded test window. The key output is also what lets
1245
+ a dependent that hashes the build's outputs see a source change the metadata alone would hide. The fixture reports its
1246
+ own duration and mbx's hits and misses apart from the run's, and says `CACHE MISS` naming the crates when mbx
1247
+ compiled. A repository's own target that runs the workspace's test binaries itself ensures them the same way
1248
+ (`ensureInPlace`) and passes the same reuse flags. A cross lane's runner, `nextest run --archive-file`, unpacks the
1249
+ whole archive into a fresh directory under its `TMPDIR`, which for a `bounded-exec` task on macOS is a lease on the
1250
+ shared RAM volume (measured: a 548 MB archive unpacks to 1.97 GiB, and four such tasks filled the 8 GiB volume).
1251
+ `--workspace-remap` is required — the metadata records the producing tree's absolute paths, and without it metadata
1252
+ restored from another checkout hands tests that checkout's `CARGO_MANIFEST_DIR`. With it the metadata is relocatable,
1253
+ so one cache entry serves every checkout of the same commit; nextest re-points
1254
+ `CARGO_BIN_EXE_<name>`/`NEXTEST_BIN_EXE_<name>` at the remapped binaries at runtime, but a test that reads them
1255
+ through the compile-time `env!` macro keeps the producing tree's path. Per-crate runners accept an empty nextest
1256
+ selection because a valid workspace member may have no tests and a hash partition may legitimately be empty. A crate
1257
+ in the project that builds the debug cdylib runs after `napi-debug`, because its tests load that addon from
1258
+ `target/debug`. A crate declaring `[package.metadata.smoothbricks.wasm-bindgen]` also receives the cacheable
1259
+ `cargo-wasm` output target in its owning project.
1196
1260
  - The plugin's own `nextest.toml` is passed as
1197
1261
  `--tool-config-file "smoo:$PWD/<to workspace root>/node_modules/@smoothbricks/nx-plugin/nextest.toml"`, so it is a
1198
1262
  layer BENEATH the repository's `<cargo-workspace>/.config/nextest.toml` rather than a replacement for it: a repository
1199
- can raise a timeout or declare `archive.include` for a cdylib or fixture the archived test binaries need, and its
1200
- settings win. That file is an input of both the archive and every runner, so changing it invalidates the verdicts it
1201
- governs. `$PWD` keeps the command text identical across checkouts while satisfying nextest's requirement that a tool
1202
- config path be absolute, and naming the file through the workspace root's `node_modules` link — never the plugin's
1203
- real location — keeps it identical for a plugin linked from a checkout outside the workspace, whatever depth each
1204
- workspace sits at; `--user-config-file none` still holds, because a developer's `~/.config/nextest` must not decide a
1205
- cached verdict. Runtime hash inputs use that same workspace-relative installed path, never the physical plugin
1206
- checkout. Both the runtime output and the owning target's command declaration therefore remain portable.
1263
+ can raise a timeout or declare, for a cross lane, the `archive.include` of a cdylib or fixture its archived test
1264
+ binaries need, and its settings win. That file is an input of both the test build and every runner, so changing it
1265
+ invalidates the verdicts it governs. `$PWD` keeps the command text identical across checkouts while satisfying
1266
+ nextest's requirement that a tool config path be absolute, and naming the file through the workspace root's
1267
+ `node_modules` link — never the plugin's real location — keeps it identical for a plugin linked from a checkout
1268
+ outside the workspace, whatever depth each workspace sits at; `--user-config-file none` still holds, because a
1269
+ developer's `~/.config/nextest` must not decide a cached verdict. Runtime hash inputs use that same workspace-relative
1270
+ installed path, never the physical plugin checkout. Both the runtime output and the owning target's command
1271
+ declaration therefore remain portable.
1207
1272
  - A crate whose suite is better spread over several runners declares `[package.metadata.smoothbricks.test] shards = N`,
1208
1273
  and gets `cargo-test-<package>-shard1..N`, each running `--partition hash:i/N` under the same progress bound. nextest
1209
1274
  assigns a test to a shard by hashing its name, so the shards stay an exact partition of the crate as tests and test
@@ -1219,10 +1284,10 @@ Concrete targets come from concrete files:
1219
1284
  one there is the whole change to that class. Serial groups are classified separately, by `test-group` overrides in the
1220
1285
  workspace's `.config/nextest.toml`; the plugin's file declares none. Only sharded crates need these targets; an
1221
1286
  unsharded crate already runs all its non-group tests in one process. Empty partitions pass, including platforms where
1222
- the tests are `cfg`-ed out. `nextest-partitions.test.ts` executes the inferred archive and shard commands over 29
1287
+ the tests are `cfg`-ed out. `nextest-partitions.test.ts` executes the inferred test build and shard commands over 29
1223
1288
  tests and asserts that the ordinary shards ran exactly the 13 ordinary tests once and the exceptional shards exactly
1224
- the 12 exceptional ones. The suite builds one shared fixture and archive, then runs separate bounded cases through the
1225
- real default serial-group executor: a successful count and run with the group's probes exactly once each, three
1289
+ the 12 exceptional ones. The suite builds one shared fixture and test build, then runs separate bounded cases through
1290
+ the real default serial-group executor: a successful count and run with the group's probes exactly once each, three
1226
1291
  refusals that run nothing and clear the task's previous verdict, and a failing run whose ordinary failures still run
1227
1292
  the group's remaining probes. The shared fixture first produces one real passing verdict, before any case runs. Each
1228
1293
  refusal copies that seed and removes its own marker log, so neither a timed-out success case nor a prior refusal that
@@ -1244,7 +1309,7 @@ Concrete targets come from concrete files:
1244
1309
  may time only a member that declares `shards`, by test paths a `test(=…)` filter matches literally; anything else
1245
1310
  fails graph construction.
1246
1311
  - A repository's serial test groups each run in one runner, `cargo-test-group-<group>`, owned by the cargo workspace
1247
- root beside `cargo-test-archive`. A group is declared once, in `<cargo-workspace>/.config/nextest.toml`: a
1312
+ root beside `cargo-test-build`. A group is declared once, in `<cargo-workspace>/.config/nextest.toml`: a
1248
1313
  `[test-groups.<group>]` table with `max-threads = 1`, and default-profile overrides that name it with `test-group` and
1249
1314
  `platform = 'cfg(target_os="macos")'`. The runner's filter is the union of those overrides, so the runner and the
1250
1315
  per-crate exclusions cannot drift; every crate piece excludes it with `not (…)`, so each test is selected by exactly
@@ -1268,8 +1333,8 @@ Concrete targets come from concrete files:
1268
1333
  manifest and the repository's nextest config, so a change to an unrelated crate leaves it cached. The filter is read
1269
1334
  as nextest reads it (its precedence, blanks and predicate arguments; `filterScope`): a plain `package(<name>)` or
1270
1335
  `package(=<name>)` bounds a clause to that package, `and`, `&` and `-` keep the narrower side or the left side, and
1271
- `or`, `|` and `+` take every clause. Anything that bounds nothing scopes the group to every member, as the archive is
1272
- hashed: a clause with no package, a glob, substring or regex name, `not`, `deps` or `rdeps`, an argument with a
1336
+ `or`, `|` and `+` take every clause. Anything that bounds nothing scopes the group to every member, as the test build
1337
+ is hashed: a clause with no package, a glob, substring or regex name, `not`, `deps` or `rdeps`, an argument with a
1273
1338
  backslash or a comma, a filter nextest refuses, or packages that exclude each other. A scope that names a package
1274
1339
  which is not a member of the Cargo workspace is refused when the graph is built.
1275
1340
  - Inference orders nothing between two serial groups: each is serial only within its own runner. A repository that needs
@@ -1318,6 +1383,20 @@ A wildcard without a caret selects the current project instead. For example, a w
1318
1383
  this local relationship explicit for inferred `tsc-js` targets that also have inferred `cargo-wasm`. Package-managed
1319
1384
  JavaScript targets with another platform prerequisite must likewise declare that local edge themselves.
1320
1385
 
1386
+ A self-hosted workspace that owns the plugin's cowshed dependency builds its declared `napi-native` and independent
1387
+ `lineage-js` producers before **every bounded-exec task**, including declared Bun targets, inferred Cargo shards and
1388
+ root serial groups. Native tool discovery resolves that local owner from the linked package manifest, not a repository
1389
+ path or project-name alias; an installed consumer takes no local producer edge because its package ships the addon and
1390
+ lineage entry. The plugin's compile and typecheck targets require only `lineage-js`, never the addon or cowshed's full
1391
+ API build. Its runtime-only cowshed project dependency is excluded from ordinary caret build edges, avoiding the
1392
+ executor bootstrap cycle. Bounded targets key on the produced addon and lineage JavaScript bytes through their producer
1393
+ edges, not the workspace’s Rust sources. Declarations that replace `dependsOn` or `inputs` keep the inferred
1394
+ preconditions with Nx’s `"..."` token. When a declaration changes an inferred executor to bounded-exec, its compatible
1395
+ inferred base contains only these runtime prerequisites and output inputs; the incompatible executor’s command and
1396
+ inputs do not leak across the normal Nx override. The canonical dependency-free `release-check` is the exception: it
1397
+ judges already assembled shipping artifacts and verifies the addon is present, without compiling at runtime or disabling
1398
+ the observer (specs/cowshed/06_cli.md, `release-check`).
1399
+
1321
1400
  N-API binaries are not prerequisites of TypeScript declaration emission, so compiler targets do not pull them in by
1322
1401
  default. Aggregate `build` remains the package-completeness boundary and includes every published local output family.
1323
1402
 
@@ -1544,7 +1623,7 @@ an unbounded runtime source closure. `ensure-built-receipt.test.ts` judges this
1544
1623
  graph.
1545
1624
 
1546
1625
  A tracked public output stays in the source basis while it holds HEAD's bytes, so a later task can read it as a FILE
1547
- input: the root `cargo-test-archive` reads the corpus `cowshed:wire-fixtures` regenerates, a tracked file that is both.
1626
+ input: the root `cargo-test-build` reads the corpus `cowshed:wire-fixtures` regenerates, a tracked file that is both.
1548
1627
  Only its stamp is the run's to move (a cache restore or a regeneration moves it). A run that leaves it other bytes
1549
1628
  refuses the receipt, and one that differs from HEAD when the run starts binds no input, so a task that reads it is
1550
1629
  unbound.
@@ -1900,6 +1979,43 @@ waiting for, however long a loaded host makes the work take; one that never retu
1900
1979
  `idleTimeoutMs`. `timeoutMs`, an absolute ceiling, is for commands that report no tests; a target names at least one of
1901
1980
  the two.
1902
1981
 
1982
+ With mbx admission, a reserved leaf and a supported Cargo/nextest test leaf inherit a private grant pipe. mbx writes `g`
1983
+ on every admission and `r` on permit drop (`MBX_GRANT_FD=5` for Cargo, `mbx reserve --grant-fd 5` for reservations). The
1984
+ executor counts overlapping holds: while no hold exists it pauses the test idle budget, resuming the remaining budget on
1985
+ admission; a finished test still resets that budget. Total and fixture ceilings start at the first `g` and do not pause
1986
+ after it. EOF is not a grant or a release; a holder killed without `r` remains counted until command exit.
1987
+
1988
+ Independently of that spawn-time zero-hold rule, **any live task process explicitly queued for mbx admission pauses
1989
+ idle**, even while another task process holds capacity or the runner is otherwise unsupported. The executor polls public
1990
+ `mbx stats --scheduler --json --activity` activity, accepting only `kind: "waiter"`, `live: true` rows whose PID is
1991
+ corroborated by bounded, scoped per-PID lineage reads through cowshed's native `processLineages` owner (libproc on
1992
+ macOS, procfs on Linux), never a spawned ps or a process-table census. Names, private waiter files and decision logs
1993
+ prove nothing. Public `queue_position` is preserved, never recomputed by the consumer. A successful snapshot with no
1994
+ task waiters resumes the remaining budget when the lifecycle and hold count permit it; a finished test resets the paused
1995
+ budget. An idle callback drains any in-flight poll and takes a fresh bounded snapshot before expiring. The stats read
1996
+ and every native lineage batch share one five-second monotonic control-plane budget, independent of the idle clock; late
1997
+ or cancelled snapshots never become queue or empty-membership evidence. Snapshot failures are reported operational
1998
+ failures, never manufactured queue/admission evidence or an idle wedge; an unidentifiable foreign legacy row is
1999
+ diagnosed without claiming task membership. Live diagnostics say `queued for admission N s` with the mbx queue position.
2000
+ A command that fails or is cancelled before its first admission records a distinct `queued` verdict with observed wait
2001
+ duration and its last public PID/ticket/position rows. Queue observation adds no deadline and changes neither total nor
2002
+ fixture ceilings. Queue observations take effect at snapshot completion, never backdated across a finished test's budget
2003
+ reset. Observed wait duration freezes when the command settles or cancellation stops observation, before teardown or
2004
+ report reading. The observer requires the version-2 activity-only report; the full statistics document's cache, savings
2005
+ and memory histories are not polling input. The activity projection omits those walks and encodings instead of raising
2006
+ the observer's output or control-plane limits.
2007
+
2008
+ The decision to use zero-hold pausing is made before spawn, from the canonical scheduling switch and the supported
2009
+ command, never from silence on the pipe. The inferred in-place
2010
+ `cargo --frozen nextest run --binaries-metadata … --target-dir-remap "$(…/smoo-nx-nextest-binaries target-dir)" …`,
2011
+ whose one substitution prints this checkout's target directory, is hold-gated, including chains joined by `&&`, `||`, or
2012
+ `;` when every leg is a supported scheduled Cargo test execution. Each leg is checked separately; a later unscheduled
2013
+ command, pipeline or background command retains conservative idle protection. Plain `cargo test` can also run
2014
+ unscheduled doctests, so it retains its lifecycle idle clock, as do unknown runners, direct binaries, test listings,
2015
+ configuration/toolchain/directory overrides, and `--archive-file` whose target is not known at spawn. Explicit non-doc
2016
+ Cargo target selections can be hold-gated. These conservative cases remain bounded even when they never hold an mbx
2017
+ permit (specs/cowshed/11_shell.md, "Cargo test-runner boundaries").
2018
+
1903
2019
  On POSIX hosts, direct Go and Cargo test commands (including chains joined by `&&`, `||`, or `;`) share one private
1904
2020
  runner lifecycle: `build`, `active`, and `terminal`. A per-command Node supervisor reports phases over an acknowledged
1905
2021
  descriptor that its actual tool child and nested fixtures do not inherit. Shell/supervisor startup is bounded; the tool
@@ -1910,6 +2026,7 @@ watchdog.
1910
2026
  | Runner | Authoritative end of build | End of active execution |
1911
2027
  | --------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
1912
2028
  | Go (`go test -json`) | Native package `Action:start`, after that package's build dependencies | Native package `pass`, `fail`, or `skip`; the clock runs while any package executes |
2029
+ | Prebuilt Go tests (`smoo-nx-go-test-run`) | None: it builds nothing, so it is active from command spawn | Command exit |
1913
2030
  | Cargo (`cargo test --message-format=json-render-diagnostics`) | Native `build-finished`, after `compile_tests` and before `run_unit_tests` | The owned Cargo child's close **and drained output**, never a libtest summary; custom harnesses, doctests, and teardown remain bounded |
1914
2031
  | Bun | No separate authoritative build event; active from command spawn | Command exit |
1915
2032
  | Unknown shell wrappers, mixed unsupported commands, and nextest | No inferred build exemption; active from command spawn | Command exit |
@@ -1926,6 +2043,20 @@ Separately building test binaries and then executing them under the unchanged bo
1926
2043
  without a native lifecycle hook, not evidence that their combined cold-build command is safe. Direct Go/Cargo commands
1927
2044
  use the lifecycle channel instead; unknown wrappers retain conservative spawn accounting.
1928
2045
 
2046
+ A Go module whose test build should be a cached target of its own splits it from the run with two bins of this package.
2047
+ `smoo-nx-go-test-build <out-dir> <package pattern>...`, run in the module, builds one `go test -c` binary for each
2048
+ package with test files that `go list` resolves, and writes `<out-dir>/go-tests.json`:
2049
+ `{"version":1,"tests":[{"binary":…,"dir":…,"importPath":…}]}`, sorted by import path, every path relative to the
2050
+ manifest. It replaces `<out-dir>` whole and refuses a directory that holds no such manifest.
2051
+ `smoo-nx-go-test-run [-p=N] [--allow-empty] <go-tests.json>` runs each binary as `go test -json` runs a package's: in
2052
+ its package directory, under `go tool test2json -t -p <import path>`, with the flags go test passes
2053
+ (`-test.paniconexit0` and the default `-test.timeout=10m0s`), up to `-p` binaries at once (`GOMAXPROCS`, else one per
2054
+ core). Its stdout is the same event stream, one whole line per event, so bounded-exec reads results, in-flight names and
2055
+ the verdict from it and sizes its `-p` as it does for `go test` (`GO_TEST_RUNNER` in `verdict.ts`); having nothing to
2056
+ build, it is active from spawn. A manifest that lists no binary is refused unless `--allow-empty` says none is expected,
2057
+ so a package pattern that matched no tests cannot pass. It exits 1 when any binary failed and 2 when the manifest cannot
2058
+ be run.
2059
+
1929
2060
  A target may name a `fixtureCommand` with its `fixtureTimeoutMs`: a compiler-fixture producer the executor runs first,
1930
2061
  in the same cwd, environment and CPU grant, as segment 0 of the same lifecycle — a build interval for its whole life,
1931
2062
  under its own supervisor and acknowledged like a runner's phases. The command follows under `&&` (a direct Go/Cargo
@@ -2251,21 +2382,21 @@ their runnable work within that tree's count instead of each sizing its runners
2251
2382
  runner's requested parallelism, read from the runner's own flag rather than the core count — nextest's `--test-threads`
2252
2383
  or one per core (one for `--no-capture`, which runs tests serially), `bun test --parallel=N` N, Stryker's
2253
2384
  `--concurrency` N or N% (default one per core less one past four cores), Vitest's `--maxWorkers` N or N% (default one
2254
- per core less one), `go test -p` (default `GOMAXPROCS`), cargo-mutants' `--jobserver-tasks` (default one per core,
2255
- whatever `--jobs` says), a cargo build one per core, anything else one, or the target's `parallelism` option — bounded
2256
- by positive inherited `NEXTEST_TEST_THREADS`/`CARGO_BUILD_JOBS` ceilings. A configured count can lower an inherited
2257
- ceiling, never raise it. The runner uses `min(bounded request, granted tokens)`: nextest's environment and named flag,
2258
- Bun's parallel flag, Stryker's, Vitest's and go's worker flag (added when the command names none), cargo-mutants'
2259
- jobserver tasks, `--jobs` and per-process test threads, and a cargo build's libtest and nextest test threads are sized
2260
- to that limit. Cargo's rustc count needs no flag: the run's sub-pool is a GNU make jobserver fifo that `CARGO_MAKEFLAGS`
2261
- and `MAKEFLAGS` name, so Cargo, its build scripts and every nested `cargo` share the grant's count with the sub-pool's
2262
- socket children, and no grant sets `CARGO_BUILD_JOBS`. A command whose runner the executor cannot see (a script) gets
2263
- `RUST_TEST_THREADS` and `NEXTEST_TEST_THREADS` set to its whole held grant, since test threads take no jobserver token.
2264
- A runner that starts its own workers or jobserver (cargo-mutants, Stryker, Vitest, `go test`) ignores that fifo, so it
2265
- must run under `bounded-exec`, whose runner kinds size its own flag; the inferred `mutation` target does. Test threads
2266
- retain their independent inherited/configured ceilings. `BOUNDED_EXEC_CPU_TOKENS`, the sub-pool and telemetry still name
2267
- the actual held grant. `timeoutMs` and `idleTimeoutMs` start at the grant. The tokens go back when the command exits, or
2268
- with the executor's socket when it is killed. The wait prints one
2385
+ per core less one), `go test -p` and `smoo-nx-go-test-run -p` (default `GOMAXPROCS`), cargo-mutants' `--jobserver-tasks`
2386
+ (default one per core, whatever `--jobs` says), a cargo build one per core, anything else one, or the target's
2387
+ `parallelism` option — bounded by positive inherited `NEXTEST_TEST_THREADS`/`CARGO_BUILD_JOBS` ceilings. A configured
2388
+ count can lower an inherited ceiling, never raise it. The runner uses `min(bounded request, granted tokens)`: nextest's
2389
+ environment and named flag, Bun's parallel flag, Stryker's, Vitest's and go's worker flag (added when the command names
2390
+ none), cargo-mutants' jobserver tasks, `--jobs` and per-process test threads, and a cargo build's libtest and nextest
2391
+ test threads are sized to that limit. Cargo's rustc count needs no flag: the run's sub-pool is a GNU make jobserver fifo
2392
+ that `CARGO_MAKEFLAGS` and `MAKEFLAGS` name, so Cargo, its build scripts and every nested `cargo` share the grant's
2393
+ count with the sub-pool's socket children, and no grant sets `CARGO_BUILD_JOBS`. A command whose runner the executor
2394
+ cannot see (a script) gets `RUST_TEST_THREADS` and `NEXTEST_TEST_THREADS` set to its whole held grant, since test
2395
+ threads take no jobserver token. A runner that starts its own workers or jobserver (cargo-mutants, Stryker, Vitest,
2396
+ `go test`) ignores that fifo, so it must run under `bounded-exec`, whose runner kinds size its own flag; the inferred
2397
+ `mutation` target does. Test threads retain their independent inherited/configured ceilings. `BOUNDED_EXEC_CPU_TOKENS`,
2398
+ the sub-pool and telemetry still name the actual held grant. `timeoutMs` and `idleTimeoutMs` start at the grant. The
2399
+ tokens go back when the command exits, or with the executor's socket when it is killed. The wait prints one
2269
2400
  `cowshed: cpu-pool wait done elapsed=… tokens=<granted>/<asked>` line.
2270
2401
 
2271
2402
  The plugin's `preTasksExecution` serves each Nx run that inherits no pool its own `BOUNDED_EXEC_CPU_POOL`, and
@@ -2348,6 +2479,101 @@ binary the target named. A script that spawns the runner itself passes
2348
2479
  `--reporter=junit --reporter-outfile="$BOUNDED_EXEC_JUNIT"` on; the variable is set for every task. A command with no
2349
2480
  runner, or with two (they would write one report), is judged by its exit alone.
2350
2481
 
2482
+ ### Live per-test closed results
2483
+
2484
+ A task also publishes live observations in `test-results.jsonl`, beside its `report.xml` and `verdict.json` in
2485
+ `.nx/workspace-data/bounded-exec/<encodeURIComponent(taskId)>/` (under Nx's configured workspace-data directory). The
2486
+ public `@smoothbricks/nx-plugin/test-results` entry is pure: it exports `ClosedTestResult`, its generated strict
2487
+ `isClosedTestResult` guard, `TEST_RESULTS_FILE`, `TEST_FAILURES_FILE`, and `parseTestSourceRef`, with no host IO
2488
+ imports. The separate `@smoothbricks/nx-plugin/test-results/host` entry owns the artifact writer and
2489
+ `taskDirectory(workspaceData, taskId)`. These observations let a consumer act on a closed failure while other tests
2490
+ still run. They never replace terminal JUnit or the verdict as gate evidence.
2491
+
2492
+ Both runtime entries always resolve to the declared `dist` products, with no raw-source development condition. A
2493
+ consumer's production bundler may also inherit a development condition from its TypeScript configuration; it must never
2494
+ embed an untransformed Typia macro. The cached `closed-results-runtime-bundle` test-setup producer builds a public-entry
2495
+ fixture under those production conditions after `tsc-js` and `typecheck-tests`. `test-results-runtime` executes only
2496
+ that prebuilt bundle under the standard no-progress bound, without a wall-clock ceiling. The producer is test setup, not
2497
+ a runner in the `test-*` namespace. The test compiles no toolchain or fixture inline, and package tests reach it through
2498
+ their aggregate.
2499
+
2500
+ Each record is one UTF-8 JSON object followed by LF:
2501
+
2502
+ ```json
2503
+ {
2504
+ "runId": "8b608ad0-fb8c-4d65-9a58-7dd140776235",
2505
+ "id": "case.test.ts::outer > test",
2506
+ "status": "fail",
2507
+ "source": "progress",
2508
+ "durationMs": 2.5,
2509
+ "sourceRef": null,
2510
+ "causeRef": { "path": "test-failures.log", "startByte": 0, "endByte": 123 },
2511
+ "cursor": 321
2512
+ }
2513
+ ```
2514
+
2515
+ The numbers above illustrate the fields, not an encoded record's actual byte lengths. `id` is `suite::name`: Bun uses
2516
+ its reported file and outer-to-inner describe/test chain; nextest uses the native name's suite prefix before `$` and its
2517
+ test name (a final retry's appended attempt count is removed); Go uses package and test name. Status is `pass`, `fail`,
2518
+ or `skip`. `durationMs` is the native duration in milliseconds, or `null` when none is reported. `sourceRef` is `null`
2519
+ without a native location; otherwise it is the test declaration's workspace-root-relative, forward-slash `file:line`,
2520
+ with a one-based line. It is not a diagnosis of the production failure. `parseTestSourceRef` projects that location to
2521
+ `{ path, line }`; paths outside the workspace retain `../` and must not qualify local ownership.
2522
+
2523
+ `causeRef` is `null` without failure output. Otherwise its task-directory-relative `path` is `test-failures.log` and
2524
+ `[startByte, endByte)` is the exact UTF-8 byte range of that observation's captured diagnostics. The evidence append
2525
+ completes before the referring JSONL append. Each append is unbuffered at the application boundary and visible before
2526
+ the next record; this is live visibility, not an fsync/crash-durability promise. `cursor` is the exclusive next byte
2527
+ offset in the JSONL file, including LF. Read complete lines only, validate each record, and resume at its cursor; keep
2528
+ an incomplete final line until its LF arrives. Cursor and cause offsets are nonnegative safe integers.
2529
+
2530
+ `runId` is a fresh UUID per invocation. Previous task artifacts are removed at admission; before the command starts, the
2531
+ writer prepares new empty files and atomically replaces the cause file, then the JSONL file, with new inodes. A consumer
2532
+ must detect replacement/truncation, reopen at byte zero and admit the new `runId`, not reuse a previous run's cursor.
2533
+ The producer pins its own append descriptors until terminal/refusal, so an older overlapping invocation cannot append
2534
+ into a replacement run's files. Pin the cause file descriptor for a run if its evidence must survive replacement. The
2535
+ stream is empty for an unsupported runner; no identity or result is guessed from arbitrary output.
2536
+
2537
+ Native channels and provenance: See the [nextest JSON channel](https://nexte.st/docs/machine-readable/libtest-json/) and
2538
+ [Bun reporter documentation](https://bun.com/docs/test/reporters); the Bun live-progress exception below is the owner's
2539
+ explicit contract, not a claim that its console output is a structured reporter API.
2540
+
2541
+ - nextest uses `--message-format=libtest-json-plus --message-format-version=0.1` and
2542
+ `NEXTEST_EXPERIMENTAL_LIBTEST_JSON=1` (pinned nextest 0.9.143). JSON-plus flushes each test terminal; plain
2543
+ `libtest-json` buffers a binary and is not a live channel. A terminal describes the final retry, with the final
2544
+ attempt's duration; suite summaries are not test results. Failure output is the native combined output or reason.
2545
+ These records have `source: "native"`. There is no native source location. No-capture/debugger/tracer commands are
2546
+ left unchanged because raw test output would destroy structured-channel attribution. Ignored-test delivery follows
2547
+ nextest's own channel: an ignored start is not evidence a test ran, and a binary with no executed test may omit its
2548
+ ignored terminals. The human progress display remains the owner of in-flight watchdog names.
2549
+ - Go reuses the existing `go test -json` decoder, for `smoo-nx-go-test-run`'s stream as for `go test`'s: only test-level
2550
+ pass/fail/skip terminals produce records, never package terminals or output heartbeats. Its native test output
2551
+ supplies failure evidence, and `Elapsed` supplies the duration when present. These records have `source: "native"`;
2552
+ the channel supplies no declaration location.
2553
+ - Bun reuses the watchdog's existing named result-line scan, not another console parser. Per the owner's ruling of
2554
+ 2026-10-29 these records have `source: "progress"`, explicitly provisional: publish immediately when a named result
2555
+ closes, never wait for later tests. Bun prints diagnostics before its `(fail)` line, so failure evidence is the
2556
+ captured stderr interval since the preceding named result through this failure line. It can include unrelated output
2557
+ and is not proof of root-cause ownership. Bun's inspector reporter (measured on 1.4.3) loses events at exit and under
2558
+ parallel/isolate execution, while its JUnit reporter writes only at the end; neither is a reliable complete live
2559
+ channel. Dots and agent-mode output omit passing/skip names, so no identities are invented for dots. Terminal Bun
2560
+ JUnit supplies those missing named results as `source: "junit"`. If its status contradicts a provisional record of the
2561
+ same identity, a new `source: "junit"` record carries the authoritative status and `contradictsCursor` pointing to
2562
+ that earlier record's cursor; matching statuses produce no duplicate. Summary reprints are not new completions.
2563
+ Concurrent/parallel workers can interleave file headers and diagnostics, and names containing the describe separator
2564
+ or duplicate names are ambiguous in console output. Consumers must retain the progress provenance and defer uncertain
2565
+ attribution to terminal structured evidence; never infer a source path from the name.
2566
+
2567
+ This contract is covered by the pure native/progress mapping and artifact tests and the real Bun/nextest smoke in
2568
+ `src/executors/bounded-exec/test-results-run.test.ts`: an early failure is visible while later work is held by IPC,
2569
+ before either terminal report exists. Readiness comes from complete LF-terminated records checked by the public schema
2570
+ and the held test's IPC connection, never from console text, ANSI escapes or result symbols. The smoke runs with colored
2571
+ output, reads the referenced UTF-8 cause before releasing the held test, then checks the same run's terminal stream,
2572
+ JUnit and verdict. `nx-plugin:cargo-stream-archive` produces the smoke's nextest archive before any Bun shard starts;
2573
+ the smoke executes that archive and never compiles inside the test progress interval. The reporter smoke likewise
2574
+ executes the transformed `dist/bin/smoo-nx-bound-failures.js` supplied by the shards' `build` dependency, not raw
2575
+ TypeScript whose imports may require schema generation. Test ownership and readiness follow
2576
+ [`specs/cowshed/08_testing.md`](../../specs/cowshed/08_testing.md), “Unit tests” and “Fixtures”.
2351
2577
  `smoo-nx-bound-failures` reads the workspace's last Nx run (`run.json` in Nx's `cacheDir`, the directory
2352
2578
  `StoreRunInformationLifeCycle` writes: the checkout's own `.nx/cache` under smoo's workspace policy) against those
2353
2579
  records and prints one line per failed task. It exits 0 only when the run failed and every failed task's record, for
@@ -2541,12 +2767,32 @@ Files with a `# smoo-local` tail or `# smoo-local-begin` / `# smoo-local-end` bl
2541
2767
  source symlinks are preserved; conflicting local blocks and broken or external links are reported instead of
2542
2768
  overwritten. The generator does not remove a repository-owned file when a capability is disabled.
2543
2769
 
2770
+ `tooling/devenv` is an executable wrapper, whether copied into a consumer or symlinked to the packaged script. It
2771
+ selects `tooling/direnv` beside the invocation path in that checkout, not beside the symlink's resolved source. A
2772
+ missing configuration is refused by name before any devenv process starts.
2773
+
2774
+ The checkout root has no native devenv `allow --from` binding: `.envrc` owns activation and enters `tooling/direnv`
2775
+ before `use devenv`
2776
+ ([canonical activation](../../specs/cowshed/04_sandbox.md#evaluating-an-edited-devenvnix-inside-its-workspace)). Never
2777
+ pass `tooling/devenv` to `devenv --from`: it is a program, not a configuration directory. Native auto-activation
2778
+ canonicalizes that source symlink and attempts to import `<resolved-script>/devenv.nix`. If an old root binding causes
2779
+ that error, run the installed native `devenv revoke` from the checkout root to remove the binding, then enter through
2780
+ `.envrc` or invoke `tooling/devenv` directly. Do not repoint the binding or add another wrapper: a root-scoped native
2781
+ activation would also give the managed shell the wrong `DEVENV_ROOT`.
2782
+
2544
2783
  `tooling/direnv/repo-path` writes the `PATH` every managed shell entry and git hook uses. In a cowshed workspace whose
2545
2784
  `.cowshed/env` lacks `TMPDIR` or `COWSHED_RUNTIME_LINK`, a fork interrupted before its first supervisor start, it says
2546
2785
  so on stderr, runs `cowshed exec <ws> -- true` once through the installed cowshed, and continues on the file that start
2547
2786
  served. It refuses, naming the workspace and the start's exit status and error, only when that start fails or leaves the
2548
2787
  file unserved (cowshed `specs/cowshed/02_workspaces.md`, "Workspace environment").
2549
2788
 
2789
+ CI's shared `github-actions-bootstrap.sh build-shell` captures that activated shell once. It persists its complete
2790
+ `PATH` through `GITHUB_PATH` in the same search order, alongside the changed exported values in `GITHUB_ENV`; workflow
2791
+ steps do not enter a second shell or reconstruct a tool list. The combined profile is not sufficient: mbx excludes the
2792
+ profile directory containing its Cargo shim before launching real Cargo, so the shell's individual package bins must
2793
+ remain available for declared tools such as the macOS linker (`specs/cowshed/16_build_volumes.md`, "One Cargo
2794
+ environment on every path").
2795
+
2550
2796
  ### Workflow security and bounded execution
2551
2797
 
2552
2798
  Managed action references use full commit SHAs with their release tags in comments. Read-only jobs explicitly set