@smoothbricks/nx-plugin 0.4.28 → 0.4.30

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 (158) hide show
  1. package/README.md +277 -89
  2. package/dist/bin/smoo-nx-test-clocks.d.ts +3 -0
  3. package/dist/bin/smoo-nx-test-clocks.d.ts.map +1 -0
  4. package/dist/bin/smoo-nx-test-clocks.js +28 -0
  5. package/dist/bounded-test-policy.d.ts +8 -8
  6. package/dist/bounded-test-policy.d.ts.map +1 -1
  7. package/dist/bounded-test-policy.js +18 -30
  8. package/dist/cargo-closure-input.d.ts +23 -0
  9. package/dist/cargo-closure-input.d.ts.map +1 -1
  10. package/dist/cargo-closure-input.js +41 -9
  11. package/dist/cargo-source-hash.d.ts.map +1 -1
  12. package/dist/cargo-source-hash.js +42 -19
  13. package/dist/ensure-built-receipt.d.ts +40 -6
  14. package/dist/ensure-built-receipt.d.ts.map +1 -1
  15. package/dist/ensure-built-receipt.js +297 -159
  16. package/dist/ensure-built-witness.d.ts +65 -4
  17. package/dist/ensure-built-witness.d.ts.map +1 -1
  18. package/dist/ensure-built-witness.js +2237 -23
  19. package/dist/ensure-built.d.ts +99 -1
  20. package/dist/ensure-built.d.ts.map +1 -1
  21. package/dist/ensure-built.js +45 -56
  22. package/dist/executors/bounded-exec/cpu-pool.d.ts +22 -7
  23. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  24. package/dist/executors/bounded-exec/cpu-pool.js +51 -22
  25. package/dist/executors/bounded-exec/executor.d.ts +12 -3
  26. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  27. package/dist/executors/bounded-exec/executor.js +174 -51
  28. package/dist/executors/bounded-exec/no-space.d.ts +8 -0
  29. package/dist/executors/bounded-exec/no-space.d.ts.map +1 -0
  30. package/dist/executors/bounded-exec/no-space.js +31 -0
  31. package/dist/executors/bounded-exec/ram-temp.d.ts +20 -11
  32. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  33. package/dist/executors/bounded-exec/ram-temp.js +42 -17
  34. package/dist/executors/bounded-exec/verdict.d.ts +34 -4
  35. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  36. package/dist/executors/bounded-exec/verdict.js +54 -3
  37. package/dist/generators/bun-test-tracing/generator.js +2 -2
  38. package/dist/graph-input-contract.d.ts +102 -0
  39. package/dist/graph-input-contract.d.ts.map +1 -0
  40. package/dist/graph-input-contract.js +637 -0
  41. package/dist/index.d.ts +12 -5
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +17 -3
  44. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  45. package/dist/managed-files/ci-workflow.js +5 -2
  46. package/dist/managed-files/publish-workflow.d.ts +11 -1
  47. package/dist/managed-files/publish-workflow.d.ts.map +1 -1
  48. package/dist/owned-installation.d.ts +14 -0
  49. package/dist/owned-installation.d.ts.map +1 -0
  50. package/dist/owned-installation.js +324 -0
  51. package/dist/producer-receipts.d.ts +19 -0
  52. package/dist/producer-receipts.d.ts.map +1 -0
  53. package/dist/producer-receipts.js +926 -0
  54. package/dist/test-backstop.d.ts +9 -0
  55. package/dist/test-backstop.d.ts.map +1 -0
  56. package/dist/test-backstop.js +10 -0
  57. package/dist/test-clock-policy.d.ts +30 -0
  58. package/dist/test-clock-policy.d.ts.map +1 -0
  59. package/dist/test-clock-policy.js +686 -0
  60. package/dist/testing.d.ts +8 -0
  61. package/dist/testing.d.ts.map +1 -1
  62. package/dist/testing.js +66 -1
  63. package/managed/raw/patches/nx@23.2.1.patch +328 -50
  64. package/managed/raw/tooling/direnv/developer-links.ts +148 -29
  65. package/managed/raw/tooling/direnv/devenv.smoo.nix +7 -7
  66. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -5
  67. package/managed/raw/tooling/direnv/linked-snapshots.ts +206 -40
  68. package/managed/raw/tooling/direnv/repo-path +15 -2
  69. package/managed/raw/tooling/direnv/setup-environment.ts +179 -115
  70. package/managed/templates/github/actions/cache-node-modules/action.yml +9 -0
  71. package/managed/templates/github/actions/setup-devenv/action.yml +63 -7
  72. package/nextest.toml +1 -1
  73. package/package.json +25 -9
  74. package/src/__tests__/cargo-closure-fixture.ts +113 -0
  75. package/src/__tests__/counted-cargo.ts +8 -25
  76. package/src/__tests__/directory-change.ts +27 -0
  77. package/src/__tests__/fixture-nx-env.ts +7 -0
  78. package/src/__tests__/owned-installation.ts +14 -0
  79. package/src/__tests__/past-tick.ts +12 -0
  80. package/src/bin/smoo-nx-bound-failures.test.ts +1 -1
  81. package/src/bin/smoo-nx-test-clocks.ts +29 -0
  82. package/src/bounded-test-policy.test.ts +36 -22
  83. package/src/bounded-test-policy.ts +18 -32
  84. package/src/bun-bootstrap.test.ts +1 -1
  85. package/src/cargo-closure-input.property.test.ts +50 -0
  86. package/src/cargo-closure-input.test.ts +73 -121
  87. package/src/cargo-closure-input.ts +47 -8
  88. package/src/cargo-closure-key.test.ts +239 -0
  89. package/src/cargo-resolve-cache.test.ts +168 -31
  90. package/src/cargo-source-hash.test.ts +78 -3
  91. package/src/cargo-source-hash.ts +48 -30
  92. package/src/cross-check-policy.test.ts +2 -2
  93. package/src/ensure-built-receipt.test.ts +111 -16
  94. package/src/ensure-built-receipt.ts +294 -149
  95. package/src/ensure-built-witness.test.ts +306 -13
  96. package/src/ensure-built-witness.ts +255 -24
  97. package/src/ensure-built.test.ts +228 -102
  98. package/src/ensure-built.ts +127 -66
  99. package/src/executors/bounded-exec/cpu-pool.test.ts +134 -32
  100. package/src/executors/bounded-exec/cpu-pool.ts +64 -20
  101. package/src/executors/bounded-exec/cpu-tokens.test.ts +2 -2
  102. package/src/executors/bounded-exec/disk-lease.test.ts +47 -13
  103. package/src/executors/bounded-exec/executor-host.test.ts +74 -52
  104. package/src/executors/bounded-exec/executor.test.ts +343 -97
  105. package/src/executors/bounded-exec/executor.ts +192 -56
  106. package/src/executors/bounded-exec/hang-diagnostics.test.ts +14 -8
  107. package/src/executors/bounded-exec/no-space.ts +40 -0
  108. package/src/executors/bounded-exec/progress.test.ts +1 -1
  109. package/src/executors/bounded-exec/ram-temp-host.test.ts +51 -21
  110. package/src/executors/bounded-exec/ram-temp.test.ts +92 -16
  111. package/src/executors/bounded-exec/ram-temp.ts +49 -20
  112. package/src/executors/bounded-exec/verdict.test.ts +127 -22
  113. package/src/executors/bounded-exec/verdict.ts +78 -3
  114. package/src/generators/bounded-test-targets/generator.test.ts +1 -3
  115. package/src/generators/bun-test-tracing/generator.test.ts +2 -2
  116. package/src/generators/bun-test-tracing/generator.ts +2 -2
  117. package/src/graph-input-contract.test.ts +379 -0
  118. package/src/graph-input-contract.ts +627 -0
  119. package/src/index.test.ts +3 -3
  120. package/src/index.ts +24 -3
  121. package/src/linked-snapshots.nx.test.ts +112 -30
  122. package/src/managed-files/ci-workflow.ts +5 -2
  123. package/src/managed-files/publish-workflow.ts +12 -1
  124. package/src/managed-files/repo-path.test.ts +44 -1
  125. package/src/managed-files/setup-devenv-free-disk.test.ts +95 -0
  126. package/src/nextest-code-bound.test.ts +23 -17
  127. package/src/nextest-extraction.test.ts +114 -4
  128. package/src/nextest-partitions.test.ts +7 -1
  129. package/src/nx-cache-restore-mtime.test.ts +2 -2
  130. package/src/nx-daemon-claim.test.ts +10 -8
  131. package/src/nx-daemon-idle-cpu.test.ts +0 -1
  132. package/src/nx-daemon-idle-policy.test.ts +61 -1
  133. package/src/nx-daemon-ignore-files.test.ts +2 -2
  134. package/src/nx-daemon-validity.test.ts +36 -22
  135. package/src/nx-dot-input-policy.test.ts +5 -5
  136. package/src/nx-files-archive-racy.test.ts +1 -1
  137. package/src/nx-incomplete-run-summary.test.ts +1 -1
  138. package/src/nx-plugin-load-errors.test.ts +2 -2
  139. package/src/nx-project-graph-errors.test.ts +70 -0
  140. package/src/nx-skipped-task-exit.test.ts +2 -2
  141. package/src/nx-store-resolution.test.ts +7 -25
  142. package/src/nx-task-output-lease.test.ts +3 -3
  143. package/src/nx-use-local.test.ts +7 -5
  144. package/src/owned-installation.ts +174 -0
  145. package/src/producer-receipts.test.ts +164 -0
  146. package/src/producer-receipts.ts +636 -0
  147. package/src/runtime-input.test.ts +1 -1
  148. package/src/serial-group-wiring.test.ts +4 -4
  149. package/src/task-results.test.ts +18 -16
  150. package/src/test-backstop.ts +11 -0
  151. package/src/test-clock-policy.test.ts +338 -0
  152. package/src/test-clock-policy.ts +708 -0
  153. package/src/test-timings.test.ts +2 -2
  154. package/src/testing.test.ts +5 -5
  155. package/src/testing.ts +67 -1
  156. package/src/typecheck-test-policy.test.ts +1 -1
  157. package/src/typescript-resolution.test.ts +76 -0
  158. package/test-timings.json +8 -0
package/README.md CHANGED
@@ -202,7 +202,9 @@ outside it — enough to make a pre-push cross-compile probe unsatisfiable. Keep
202
202
  build-script reads or custom environment variables that Cargo metadata cannot name.
203
203
 
204
204
  A target whose inputs a repository DECLARES replaces the inferred list, pin included. Name the two `devenv.lock` entries
205
- in that declaration, or in the named input it uses, or a toolchain bump will not invalidate it.
205
+ in that declaration, or in the named input it uses, or a toolchain bump will not invalidate it. The replaced list also
206
+ held the target's `externalDependencies` entry described below; restate it (`[]` for a target that runs only cargo), or
207
+ every lockfile change re-keys the target.
206
208
 
207
209
  Every cached cargo target names the npm packages its command runs as `externalDependencies`: none for cargo itself, and
208
210
  `@smoothbricks/nx-plugin` for a target that runs its executor or reads its installed files (the nextest tool config, the
@@ -254,6 +256,11 @@ atomic rename; failed resolutions are never cached. A corrupt cache is reported
254
256
  during resolution are retried at most three times, then refused with the cause intact. A WASM-only Nx host cannot
255
257
  provide the native lock and receives a typed refusal rather than an unserialized fallback.
256
258
 
259
+ A cache-publication refusal retains the original filesystem cause, logical directory/lock/temporary paths, and parent
260
+ device/inode observations immediately before lock construction, at the temporary open, and after failure (or the exact
261
+ stat error). This distinguishes a missing namespace from a rebound one without recreating directories, retrying
262
+ publication or changing warm-cache behavior.
263
+
257
264
  A persisted warm cache is checked before waiting for the cold-fill lock. Each Cargo resolution child and the
258
265
  asynchronous wait for a foreign resolution lock have a 300-second bound. A refusal names the child or lock, the
259
266
  workspace and elapsed bound; a timed-out child and its owned process group are killed. These bounds do not change the
@@ -360,6 +367,11 @@ unknown). A successful flight holds the lease until closing the child's stdin re
360
367
  A timed-out Cargo command is killed, and resolution refuses instead of hanging graph construction or returning a stale
361
368
  closure.
362
369
 
370
+ Resolution expands shared ancestors once and reads current file bytes directly, without per-file asynchronous dispatch
371
+ or canonical-path probes for missing files. Standalone calls retain a fresh native manifest census; graph callers use
372
+ the graph's existing index. Canonical paths and contents still key metadata, including ignored and external packages;
373
+ source bytes are read on every hash call, not kept in a runtime-result cache.
374
+
363
375
  ### Cargo closure input
364
376
 
365
377
  Custom Cargo targets that replace inferred inputs need the source closure of the crates they build. The plugin infers it
@@ -390,10 +402,13 @@ with unchanged resolution inputs starts no Cargo process either.
390
402
 
391
403
  Literal `include_str!` and `include_bytes!` files also belong to the closure, including data inside a crate and tracked
392
404
  files outside its directory (such as a shipped Markdown skill). One Rust lexer excludes comments and example strings;
393
- computed paths and arbitrary build-script reads still need explicit inputs. External path-package digests include the
394
- same literal data bytes. Inferred `napi-*` and repository-root `cargo-wasm` builds use this resolved closure rather than
395
- every Rust file in the workspace, while retaining their toolchain pins, wrapper scripts, N-API configuration and CLI
396
- version.
405
+ computed paths and arbitrary build-script reads still need explicit inputs. A compiled-in file is named only when Nx's
406
+ file index holds both it and the source including it: an ignored one is a build output, whose bytes no fileset can hash
407
+ and which reaches consumers through its producer's dependency outputs. Naming it would only key the project graph on the
408
+ names the last producer run left on disk, so a run regenerating content-named files would move every key it was hashed
409
+ under. External path-package digests include the same literal data bytes. Inferred `napi-*` and repository-root
410
+ `cargo-wasm` builds use this resolved closure rather than every Rust file in the workspace, while retaining their
411
+ toolchain pins, wrapper scripts, N-API configuration and CLI version.
397
412
 
398
413
  Runtime file identities are rooted in Cargo package name/version and the declared input role, not in the consuming
399
414
  checkout's absolute path or depth. Source paths are package-relative; compiled-in data keeps its declaring source and
@@ -589,6 +604,35 @@ reviewer, who decide whether the variants share one walk:
589
604
  A separate case stays only for a distinct boundary or edge: its setup or path diverges, or it needs a state the walk's
590
605
  earlier steps destroy. Each diagnostic names the file, both cases, the shared statement count and that remedy.
591
606
 
607
+ ## Test Clock Policy
608
+
609
+ A test's duration is a property of its work, not of the host ("Bounded Test Targets"). Consuming repositories enforce
610
+ this in their root Nx lint with the `smoo-nx-test-clocks` bin, which refuses four kinds of site in test code with
611
+ `error[TEST-CLOCK-ORACLE]`:
612
+
613
+ - **runner-deadline:** a deadline handed to the test runner: a number or `{ timeout }` after a `test`/`it`/`test.each`
614
+ body, or `setDefaultTimeout`. Delete it and put nothing in its place.
615
+ - **test-deadline:** a Rust test's own deadline: `recv_timeout`, `park_timeout` or `timeout` bounded by a literal
616
+ `Duration` below the no-progress backstop, whose expiry fails the case (`.expect`, `.unwrap`). A quiet window
617
+ (`timeout(d, f).await.is_err()`) is not a deadline.
618
+ - **clock-delta:** an assertion that elapsed host time stays under a bound, such as
619
+ `expect(Date.now() - started).toBeLessThan(5_000)` or `assert!(started.elapsed() < d)`. Lower bounds, ordering against
620
+ a product timestamp, epoch stamps, CPU time and injected clocks pass.
621
+ - **clocked-bound:** a literal product bound below the backstop in a case whose stand-in a timer or sleep ends
622
+ (`{ command: 'node -e "setTimeout(() => {}, 5000)"', timeoutMs: 50 }`). The bound races the stand-in's clock. A bound
623
+ that is the case's subject, with the event that would beat it held off by construction (a child that never answers),
624
+ passes. So does one that cannot decide: `0` (disabled) or at `BOUNDED_TEST_IDLE_TIMEOUT_MS`.
625
+
626
+ A Rust fn on paused tokio time (`tokio::time::pause()`, `start_paused = true`) runs on virtual time and is not examined.
627
+ Like `smoo-nx-test-walks`, the bin judges only what changed since `upstreamBase`, the same base the lint target's
628
+ runtime input already prints. A site in a case that overlaps a change is judged; the whole case is read, so an edit
629
+ cannot keep an old site. A site outside any case is judged when its own line changed. The check stops new sites and
630
+ removes none, so existing sites need no allowance table. It cannot see: a bound passed positionally or held outside the
631
+ case; a stand-in in another file; a bound below the backstop beside untimed real work; a clock read through a helper;
632
+ `if (…) throw` and `while` deadline guards; Rust socket-option deadlines; timer waits themselves.
633
+ `findClockOracles(root, files, changes)` and `formatClockOracle` are exported from
634
+ `@smoothbricks/nx-plugin/test-clock-policy`.
635
+
592
636
  ## Nx Target Naming
593
637
 
594
638
  Target names are `{tool}-{output}` names. Use names like `tsc-js`, `tsdown-js`, and `cargo-wasm`; `build` and `lint` are
@@ -616,9 +660,8 @@ Concrete targets come from concrete files:
616
660
  replace Cargo's `target` link. Its inputs, like every cargo-derived fileset, are anchored at `{workspaceRoot}`: Nx
617
661
  resolves a `{projectRoot}` glob against only the files its project owns, and a nested package owns the crates under
618
662
  it, so a root workspace's archive spelled that way hashes none of its members and replays stale binaries against
619
- edited crates. Each member crate gets a cached `cargo-test-<package>` run (30s slow-test warning like
620
- `bun test --timeout=30000`, no per-test kill) whose inputs include that crate and its path dependencies, and whose
621
- command runs
663
+ edited crates. Each member crate gets a cached `cargo-test-<package>` run (30s slow-test warning, no per-test kill)
664
+ whose inputs include that crate and its path dependencies, and whose command runs
622
665
  `cargo --frozen nextest run --binaries-metadata … --cargo-metadata … --target-dir-remap … --workspace-remap . -E 'package(<crate>)'`
623
666
  from the archive's one extraction. Runners therefore execute rather than build: they compile nothing in cargo's build
624
667
  tree, and fan out instead of chaining. They do not unpack the archive each: before the run, `smoo-nx-nextest-extract`
@@ -629,8 +672,12 @@ Concrete targets come from concrete files:
629
672
  `cargo metadata` reports for the runner's Cargo workspace, so a `build.target-dir` setting moves the extractions with
630
673
  the build tree. An extraction is per-checkout tool state like the rest of that tree, never an Nx output: it lives in
631
674
  Cargo's build tree, which a checkout with a build volume keeps off its source tree, and it never sits under a declared
632
- output such as `.cache/nextest`. `cargo clean` removes it. `--workspace-remap` is required — an archive records the
633
- producing tree's absolute paths, and without it a restored archive hands tests another checkout's
675
+ output such as `.cache/nextest`. `cargo clean` removes it. A repository's own target that runs tests from the
676
+ workspace archive calls the same helper and passes the same reuse flags: `nextest run --archive-file` unpacks the
677
+ whole archive into a fresh directory under its `TMPDIR`, which for a `bounded-exec` task on macOS is a lease on the
678
+ shared RAM volume (measured: a 548 MB archive unpacks to 1.97 GiB, and four such tasks filled the 8 GiB volume). The
679
+ RAM lease holds what tests write, never the binaries they run. `--workspace-remap` is required — an archive records
680
+ the producing tree's absolute paths, and without it a restored archive hands tests another checkout's
634
681
  `CARGO_MANIFEST_DIR`. With it the archive is relocatable, so one cache entry serves every checkout of the same commit;
635
682
  nextest re-points `CARGO_BIN_EXE_<name>`/`NEXTEST_BIN_EXE_<name>` at the extracted binaries at runtime, but a test
636
683
  that reads them through the compile-time `env!` macro keeps the producing tree's path. Per-crate runners accept an
@@ -798,6 +845,49 @@ conservative graph witness too. Only Nx's current task hashes and matching artif
798
845
  unrelated edit does not force cached-log replay, and an actual input edit cannot hit an old source snapshot. Argument
799
846
  normalization, per-task environments and plugin pre/post hooks still run.
800
847
 
848
+ A local graph plugin can declare `options.graphInputContract` with `version: 1`, one explicit `kind` (`native-only`,
849
+ `tsconfig-extends` or `reference-scan`), `modules: [{ path, sha256 }]` and `packages: [name]`. Module paths are
850
+ workspace-relative and the first module is the configured entry. The literal SHA-256 values bind the audited
851
+ entry/helper import closure to that input contract; changing code cannot inherit its former proof, and checking a
852
+ declaration never rewrites its approval hashes. The installed `@smoothbricks/nx-plugin/graph-input-contract` factory
853
+ collects a read witness from the owning reader, not a second parser or a guessed file list. Pure native-only callbacks
854
+ need no outside-read trace, but still require their exact audited module and package-resolution closure.
855
+
856
+ The other kinds publish complete or unproved evidence in the existing Nx workspace-data directory as a byproduct of the
857
+ actual callback. A complete witness binds its contract, native file/hash/namespace identity before and after the
858
+ callback, read file/directory stamps, missing paths, physical package resolutions, tools and environment. TypeScript
859
+ extends and reference scans retain their existing results while recording the outside inputs they really read, including
860
+ Git configuration origins and relevant namespace inventories. Installed Nx owns daemon/worker environment normalization;
861
+ loader/preload settings are not silently dropped. Missing or changed declarations, missing traces, stale read evidence
862
+ and unknown loaders, dynamic configuration or unbounded reads make the proof unproved and require the ordinary
863
+ authoritative graph RPC. A declared kind alone is never admission, and this witness never replaces current Nx task
864
+ hashing or artifact comparison.
865
+
866
+ The installed-package census expands each declared `files` set and relative export targets through that workspace's Nx
867
+ native output authority, always retaining the manifest, directory/alias namespace evidence and every resolution edge;
868
+ without a file declaration it conservatively retains the whole package tree.
869
+
870
+ Ancestor directories bind device/inode/type/mode path identity; files and symlinks retain their full stamps, and a
871
+ directory is upgraded to a full nanosecond node/namespace stamp when its membership is actually read.
872
+
873
+ **A stamp read in the tick its node changed in is unproven, not unchanged.** A filesystem dates a change by the kernel's
874
+ clock. On Linux, on a filesystem without fine-grained timestamps such as ZFS, that clock moves once a jiffy: 1 ms at
875
+ `CONFIG_HZ=1000`, as on CI's runner, and 10 ms at `CONFIG_HZ=100`, the slowest. A same-size rewrite in the tick a stamp
876
+ was read in leaves every field of that stamp as it was. So a census reads the clock before its first stat, and records a
877
+ node whose later of ctime and mtime is within 10 ms of that time with its ctime `unproven`, which no later read equals.
878
+ This is git's racily clean rule (`Documentation/technical/racy-git.txt`), and the Nx archive repair below applies it to
879
+ Nx's own file hashes. Node can read neither the jiffy nor a filesystem's granularity, and a shorter window reopens the
880
+ gap on a slower kernel, so the window is the slowest tick and is not an option. A reader that meets an unproven stamp
881
+ re-reads the node against its recorded bytes, link text or membership, as it does a node whose ctime alone moved; one
882
+ that holds nothing to re-read it against counts it moved. A census whose stamps stand in for no bytes of their own (the
883
+ installed-package census and the local plugin modules, which hash every byte on every read) records them as read. So
884
+ does a workspace capture's own stability check, which compares the stamps it read: only the capture after it distrusts
885
+ them.
886
+
887
+ A physically missing required factory after the clean cutover is an invalid installation and fails loudly; it is not a
888
+ proof miss that can fall back to the graph RPC. Consumers adopt the normal static import only after the public producer
889
+ is available.
890
+
801
891
  The daemon's output records are lossy: they are held in memory, tracked per collapsed directory, and erased by writes it
802
892
  processes more than two seconds late — including, on a busy daemon, a restore's own writes. When it cannot vouch for a
803
893
  task's outputs, the working tree is compared with Nx's local cache artifact for that exact task hash, entry by entry as
@@ -809,41 +899,81 @@ error, or a write observed during the comparison is a miss.
809
899
  A successful byte comparison may retain a cache-bound node inventory in that same Nx workspace-data directory. It binds
810
900
  the exact task hashes, declared outputs and artifact paths to every compared working-tree/cache node and both sets of
811
901
  real parent directories. Reuse requires the same device, inode, type/permission mode, length and nanosecond mtime/ctime
812
- for all those nodes. It is evidence of the same previously compared bytes, never source identity or an mtime freshness
813
- rule. Missing/unreadable evidence or moved nodes require a full comparison; mutations to either the cache or working
814
- tree, parent symlink replacement, and directory membership changes cannot borrow an old equality verdict.
815
-
816
- `probeBuilt({ target, cwd })` is the distinct typed read-only provider operation. It returns `EnsureBuiltProbeResult`: a
817
- `miss` with its `MissReason` without starting Nx's runner or writing producer outputs; the existing operational socket
818
- failure; a loud `provider-proof` failure; or a `hit` with `EnsureBuiltReceipt`. `ensureBuilt` is build/stream-only and
819
- its CLI callers retain the existing hit/built/failed result. With the daemon disabled, `probeBuilt` returns a no-daemon
820
- miss instead of running the target. Both operations preserve Nx argument normalization, hooks, per-task environments and
821
- local cache parity; the read-only operation additionally requires exact-cache artifact equality. A managed consumer
822
- requires the installed module's `probeBuilt` function before making any producer call; a missing operation refuses
823
- loudly without falling back to `ensureBuilt` or writing provider outputs.
824
-
825
- A probe receipt names the real provider workspace, Git HEAD and HEAD's tree, every task id/current Nx hash in the
826
- selected target's dependency graph, and an independently read census of every Nx-expanded public output. Files carry
827
- SHA-256; symlinks carry their text and mode without following them; directories carry mode, ordered membership and a
828
- child-census digest, including empty directories. Source/revision/output nodes must remain unchanged across capture.
829
- Missing, unreadable or stale output evidence refuses, never starts a build and never signs daemon-state identity.
830
-
831
- Git provenance covers Nx's planned FILE inputs and the owning project/dependency manifests and root graph configuration.
832
- Dirty matched inputs (including new or index-only changes) refuse. The native inspector cannot prove deleted membership
833
- or a custom hasher's opaque reads: a deleted provider source or a bounded runtime/env input therefore uses conservative
834
- any-dirty-provider-source refusal, excluding public outputs rather than treating them as committed source. Runtime/env
835
- values remain explicitly labelled `nx-task-hash-only`, not Git provenance. Only the existing toolchain generator's exact
836
- version-only recipe with declared cwd, a declared toolchain FILE pin and proved installed-module closure is bounded;
837
- arbitrary shell/file/runtime commands and unavailable custom/native input proofs categorically refuse receipts. A caller
838
- probing multiple targets uses the existing single-target API and rejects differing provider HEAD/tree identities before
839
- publishing its immutable snapshot. This producer evidence binds a managed linked-package snapshot to one current build;
840
- Nx alone decides whether its current keys and cache/output bytes match. A caller from another workspace never lends its
841
- socket, database or cache overrides to the provider. Inside a managed shell (`DEVENV_RUNTIME`), `ensureBuilt` asks the
842
- packaged `nx-socket-dir.sh` owner for the provider's binding: the root's verified cowshed runtime link when present,
843
- otherwise its canonical checkout spelling under that shell runtime. Outside a managed shell, Nx retains its normal
844
- defaults. A socket-owner refusal returns `disposition: 'failed'` with `reason.kind: 'workspace-socket'`, the selected
845
- `taskId`, `workspaceRoot` and operational `detail`, before any task or daemon client starts. The owner's actual exit or
846
- signal is preserved; the wrapper must not report that the target ran.
902
+ for all those nodes, and a node the comparison read in the tick it changed in is recorded unproven, so the next
903
+ comparison is a full one. It is evidence of the same previously compared bytes, never source identity or an mtime
904
+ freshness rule. Missing/unreadable evidence or moved nodes require a full comparison; mutations to either the cache or
905
+ working tree, parent symlink replacement, and directory membership changes cannot borrow an old equality verdict.
906
+
907
+ `probeBuilt({ target, cwd })` is the distinct typed read-only product operation. Its `hit` is an actual published
908
+ `EnsureBuiltReceipt`, not a cache hit re-probed under the consumer's environment. The producer opts into publication in
909
+ its own Nx plugin options as
910
+ `producerReceipts: { targets: ["lmao:rust-dist", "lmao:cargo-wasm", "lmao:cargo-thread-ffi"] }`, naming every target a
911
+ consumer's snapshot declaration names. The pre-task hook captures the committed HEAD/tree and tracked-source/tool basis;
912
+ the post-task hook uses Nx's actual successful `TaskResults`, hashes/hash details, argv and start/end times, including
913
+ successful uncacheable prerequisites, and atomically publishes the receipt in that checkout's existing Nx
914
+ workspace-data. Disabled publication performs no source prepass, so an ordinary consumer CLI pays none of that producer
915
+ work. No file permission, path, daemon state or cached row can invent a completion receipt. Nx takes one pre/post
916
+ task-hook pair per plugin, so the plugin's pair runs the controller's `COWSHED_NX_TASK_RECEIPT_ID` task-results hint
917
+ first and these producer hooks second, each with the same options and run context and neither reading the other's
918
+ output.
919
+
920
+ The receipt binds the selected target, basis commit SHA and committed tree SHA, actual argv, declared producer
921
+ environment identity and bound tool/module inputs, independent product output SHA-256, measured wall time, and an
922
+ explicit clean tracked-tree assertion. It includes every completed required task's Nx identity and every Nx-expanded
923
+ public output. Files carry SHA-256; symlinks carry text and mode without following them; directories carry mode, ordered
924
+ membership and child-census digest, including empty directories. The producer source/tool/output witnesses must stay
925
+ stable through publication, and every refusal that one moved names the first nodes that did. A tool or installed-module
926
+ node whose device, inode, mode, size and mtime are unchanged and only its ctime moved is re-read and compared with its
927
+ recorded bytes, link text and membership, as any moved stamp requires a full comparison: under `globalStore` the closure
928
+ lives in Bun's install cache, which every checkout on the machine shares, and linking a package's bin on any of their
929
+ installs re-chmods the store file to the mode it already has. A source, tool or output node the census read in the tick
930
+ it changed in, as a task's last writes are, is recorded unproven and re-read the same way. The command's stdout/stderr
931
+ digest is not a product digest. The bound tool/module inputs are the installed closures of Nx, this plugin, TypeScript
932
+ and local graph plugins, and the producer executables. A task's npm external inputs (`AllExternalDependencies` and the
933
+ npm nodes of its project's dependency closure) are Nx's lockfile identities: the task's hash details and the committed
934
+ `bun.lock` bind them, and no installed closure is resolved for them, since under Bun's isolated linker most of them do
935
+ not resolve from the task's project.
936
+
937
+ Validity compares the committed tree, not the current HEAD spelling. An empty commit with an identical tree keeps the
938
+ receipt valid and its original basis SHA unchanged; the consumer never rewrites that provenance. A genuinely changed
939
+ tree invalidates the receipt. Multi-target consumers require one tree and retain each producer's actual basis.
940
+
941
+ The consumer validates this stored receipt against its declared target, committed-tree/configuration identity, declared
942
+ environment/tool inputs and actual output census. It never re-hashes the provider's task graph in its own environment.
943
+ Its read of the recorded tools must stay stable through that census on the same terms as the producer's: a tool node
944
+ whose ctime alone moved is re-read and compared with the receipt, and a refusal names the nodes that moved. A valid
945
+ receipt is the hit. A missing, mismatched, stale or unbound receipt requires the authoritative graph RPC, then a loud
946
+ miss/refusal without running a target or writing provider outputs. A managed consumer requires the installed
947
+ `probeBuilt` operation and the complete producer-receipt contract; an old receipt lacking it refuses, never falls back
948
+ to `ensureBuilt` or a producer writer. `ensureBuilt` remains the normal build/stream operation with its existing
949
+ hit/built/failed results and Nx's current source/cache/artifact verdict.
950
+
951
+ **A refusal never replaces a receipt.** A run whose products the hooks cannot prove publishes a refusal instead: its
952
+ detail, in its own `producer-refusal-<sha>.json` beside `producer-receipt-<sha>.json`. A refusal says only that this run
953
+ could not prove something; it is no evidence about the products an earlier run proved, and overwriting that run's
954
+ receipt would destroy the evidence a consumer can still check. So a receipt stays until a later receipt replaces it, and
955
+ the consumer validates it on its own evidence as above: one that still validates is the hit, whatever a later run
956
+ refused. A miss names the latest refusal in its detail, and a published receipt removes the refusal it answers. The
957
+ hooks read git under the repository's own configuration (`GIT_CONFIG_GLOBAL=/dev/null`, `GIT_CONFIG_NOSYSTEM=1`): Nx
958
+ runs them in the workspace's Nx daemon, which runs inside the cowshed sandbox under a host client's `HOME`, and the
959
+ sandbox denies the operator's global git configuration (specs/cowshed/04_sandbox.md, the runtime-input contract).
960
+
961
+ A FILE-only source plan does not perform a redundant installation census for absent runtime recipes; the complete
962
+ producer tool/module and output SHA evidence is still captured and independently revalidated on every product probe.
963
+
964
+ Git source provenance is the committed tree and the producer's clean tracked source basis, not an unrelated untracked
965
+ user file in its working directory. An actual FILE input outside HEAD, a modified tracked input, changed membership,
966
+ opaque custom/native input proof or genuinely unbounded runtime source cannot be signed. Bounded runtime/env identity is
967
+ explicitly labelled `nx-task-hash-only`; the existing generator-owned version recipes still require their declared
968
+ cwd/toolchain FILE pins and proved installed closure. Public outputs are excluded precisely from source stability, never
969
+ with broad exclusions that can hide manifests or configuration. A caller probing multiple targets requires the same
970
+ provider committed-tree identity, retaining each original producer basis, before publishing its sealed snapshot. A
971
+ caller from another workspace never lends its socket, database or cache overrides to the provider. Inside a managed
972
+ shell (`DEVENV_RUNTIME`), `ensureBuilt` asks the packaged `nx-socket-dir.sh` owner for the provider's binding: the
973
+ root's verified cowshed runtime link when present, otherwise its canonical checkout spelling under that shell runtime.
974
+ Outside a managed shell, Nx retains its normal defaults. A socket-owner refusal returns `disposition: 'failed'` with
975
+ `reason.kind: 'workspace-socket'`, the selected `taskId`, `workspaceRoot` and operational `detail`, before any task or
976
+ daemon client starts. The owner's actual exit or signal is preserved; the wrapper must not report that the target ran.
847
977
 
848
978
  ```typescript
849
979
  import { ensureBuilt } from '@smoothbricks/nx-plugin/ensure-built';
@@ -927,9 +1057,9 @@ the exact caller-owned developer checkout and the actual shared store. Only reac
927
1057
  grants, never the whole checkout or `.bun` root. Traversal deduplicates exact package identities, not read-grant
928
1058
  prefixes: a covered local `@nx` scope can still contain a binding to the pinned native platform package in the shared
929
1059
  store. A normal Bun store entry is never presented as a developer binding. Local file providers are checkout-relative
930
- directories that travel with the clone.
931
- Foreign-daemon retirement witnesses retain the daemon's own standalone root, state and short socket throughout the
932
- landing; its actual produced record is only a nomination, and its owner performs cleanup after the identity proof.
1060
+ directories that travel with the clone. Foreign-daemon retirement witnesses retain the daemon's own standalone root,
1061
+ state and short socket throughout the landing; its actual produced record is only a nomination, and its owner performs
1062
+ cleanup after the identity proof.
933
1063
 
934
1064
  The Nx patch repairs upstream Nx runtime behavior, separately from this plugin's workspace-owner checks:
935
1065
 
@@ -1059,9 +1189,31 @@ The Nx patch repairs upstream Nx runtime behavior, separately from this plugin's
1059
1189
  five-minute idle interval. Cowshed's existing usage-aware keeper remains authoritative for sheds whose tree changes
1060
1190
  without a job, session or task-database holder. No daemon is disabled and the next normal client starts one again. The
1061
1191
  non-default, uncached host proof is `bun nx run tooling:nx-daemon-idle-proof` from the checkout root. Its declared
1062
- compile dependency emits the Typia-transformed product before Bun runs it. The proof holds a real silent client beyond
1063
- five minutes, disconnects, and records the kernel and daemon-log evidence of the next five-minute departure. It stays
1064
- outside the bounded Bun shards; their fast regression checks the actual installed policy export.
1192
+ compile dependency emits the Typia-transformed product before Bun runs it. The proof gives the daemon a resident
1193
+ plugin worker that asks it for files, holds a real silent client beyond five minutes, disconnects, and records the
1194
+ kernel and daemon-log evidence of the next five-minute departure, workers included. It stays outside the bounded Bun
1195
+ shards; their fast regression checks the actual installed policy export.
1196
+ - **A plugin worker is its daemon's client only while it waits on a reply.** A plugin's `globWithWorkspaceContext`,
1197
+ `hashWithWorkspaceContext` and the other workspace-context reads run through the worker's own daemon client, which
1198
+ kept its connection open after the reply. The daemon keeps a worker with graph hooks for as long as it lives (above),
1199
+ and that open connection retained the daemon, so neither ever reached the idle stop: on 2026-10-17 the 72 shed daemon
1200
+ logs held 573 stops and not one `Server stopped because: "300000ms of inactivity"`, and every daemon a host client
1201
+ started stayed behind as a `ppid 1` process until something signalled it. In a plugin worker the client now drops its
1202
+ connection once its request queue drains, and the daemon is unchanged. The client also ignores the close of a
1203
+ connection it already dropped, which stock Nx let reset whichever request was current. A bounded regression runs a
1204
+ real daemon whose resident worker globs through it and requires zero open connections after the only client exits.
1205
+ Stock Nx keeps a worker until its last registered phase, so a plugin with task hooks keeps the same connection open
1206
+ there after a graph-only request; this hunk does not retire with the worker-retention hunk.
1207
+ - **A daemon whose workspace has gone stops instead of reading it.** Nx 23.2.1's native file worker reads an empty file
1208
+ map as one it has not filled yet and waits on its condition variable for files (`FilesWorker::get_files`,
1209
+ `while guard.len() == 0`). Once every file of a workspace is deleted under a running daemon, as when a checkout is
1210
+ removed or unmounted before its daemon is stopped, the next glob blocks the daemon's only thread for good. It sits at
1211
+ 0% CPU in `WorkspaceContext::multi_glob`, no timer or request runs again, and SIGTERM does nothing because its handler
1212
+ is JavaScript; only SIGKILL ends it. The daemon now stops itself when the workspace's `nx.json` is gone. It checks on
1213
+ every watcher batch before applying it, on every request and on the 5 s safety poll, so the batch that would empty the
1214
+ file map is never applied. A workspace without `nx.json` is no Nx workspace, and its client already runs without a
1215
+ daemon. A bounded regression deletes every tracked file under a real daemon and requires it to exit with that reason;
1216
+ against the unpatched daemon it hangs in that frame and survives its fixture's SIGTERM.
1065
1217
  - **The daemon stops for an ignore file only when its watcher's rules may be stale.** Nx's native watcher reads its
1066
1218
  ignore files once, in `watch()`, and the daemon stopped itself on every watcher event for a `.gitignore` or
1067
1219
  `.nxignore`, whatever the file then held. A rewrite with the same bytes (a checkout, a formatter) reports one, and so
@@ -1126,8 +1278,18 @@ therefore runs as long as it needs, however slow the host, and a test that never
1126
1278
  last test that finished. bun prints nothing per passing test when it believes an agent runs it, so the executor asks a
1127
1279
  lone `bun test` for `--dots`, one dot per finished test. A command that reports no tests makes progress only by exiting.
1128
1280
  nextest's slow-timeout and the serial groups' code-time classes only warn; no per-test bound kills a test or fails one
1129
- that passed. `timeoutMs`, an absolute ceiling, is for commands that report no tests; a target names at least one of the
1130
- two.
1281
+ that passed. Bun has a per-test deadline of its own, 5000 ms unless the command sets one, and it reads no bunfig for it,
1282
+ so every bun leg deletes it with `bun test --timeout=0` (`BUN_TEST_TIMEOUT_FLAG`; `0` means no deadline, measured on the
1283
+ pinned Bun 1.4.2). A test waits for the event it is waiting for, however long a loaded host makes the work take; one
1284
+ that never returns still ends the run through `idleTimeoutMs`. `timeoutMs`, an absolute ceiling, is for commands that
1285
+ report no tests; a target names at least one of the two.
1286
+
1287
+ A job waiting for a CPU token is queued, not idle. A descendant whose own work waits in the host's CPU queue (a test's
1288
+ scratch cowshed project, say) writes `{"op":"host-wait"}` on the `BOUNDED_EXEC_CPU_POOL` it inherited and holds the
1289
+ connection while the work waits; while any such wait is held, the idle clock is stopped and keeps the time it had left,
1290
+ and it runs on from there when the last wait closes. stderr says `bounded-exec: idle clock stopped` and `… restarted`,
1291
+ and an expiry names the queued time it did not count (`specs/cowshed/05_gateway.md`, "A queued descendant is not idle").
1292
+ `timeoutMs` is never stopped.
1131
1293
 
1132
1294
  The final-five-second pre-signal snapshot attributes the runner's process tree and observed resources, with explicit
1133
1295
  incomplete/raced results and no delay to termination. Its timing, visibility and evidence contract is defined in
@@ -1139,9 +1301,16 @@ detached when the last live lease ends, since its pages return only on detach. I
1139
1301
  spends none of the AppleDiskImages2 attach budget cowshed counts (`specs/cowshed/01a_apfs.md`, "How the APFS host
1140
1302
  degrades"). A lease whose task died is reclaimed by the next task, unless an image is still attached from a file below
1141
1303
  it or a mount sits below it: those belong to whoever attached them, so the lease and the volume are kept and every new
1142
- task names them. A target's own `env.TMPDIR` wins over the lease. Inside a cowshed sandbox, which cannot write the lock
1143
- in `/private/tmp`, the task keeps its inherited `TMPDIR` and says so once. A failed task that left the volume nearly
1144
- full names the volume.
1304
+ task names them. The task's pid dying does not end what its command started, so before a lease is removed every process
1305
+ working in it is stopped, with everything it started: a process counts when its working directory or the `TMPDIR` it was
1306
+ started with lies in the lease. Most leftovers write there only through `TMPDIR` (a ttsc plugin build copying its Go
1307
+ sources, a Bun or Node compile cache written at exit), and a working-directory census alone let them write into a lease
1308
+ while it was removed, failing the next task's lease with `ENOTEMPTY`. A target's own `env.TMPDIR` wins over the lease.
1309
+ Inside a cowshed sandbox, which cannot write the lock in `/private/tmp`, the task keeps its inherited `TMPDIR` and says
1310
+ so once. A failed task whose output said ENOSPC (`ENOSPC`, or `strerror`'s `No space left on device`) names it, the
1311
+ writer's task and lease, and the volume's free space read when that line arrived, and records the `no-space` verdict:
1312
+ the writer usually removes what it half-wrote before it exits, so the volume no longer looks full by then. A failed task
1313
+ that printed no such line but left the volume nearly full names the volume.
1145
1314
 
1146
1315
  Outside macOS, the executor never provisions an APFS RAM disk: it keeps the inherited `TMPDIR`, or uses the target's
1147
1316
  `env.TMPDIR` override, without reclaiming either directory. The host temp-directory proof runs the real default executor
@@ -1184,8 +1353,10 @@ instead of changing an attached volume. Held leases undergo no permission change
1184
1353
 
1185
1354
  The real RAM-volume regression walks one volume's lifecycle in a single test: unmarked debris and a live-lease refusal,
1186
1355
  recovery over the debris, concurrent leases, failed-acquire lease/claim rollback, read-only cleanup, a held dead lease,
1187
- owner detach and reclaim, and the final detach. External symlink targets and held directory modes stay unchanged,
1188
- without duplicate provision and teardown; its 60 s case bound is unchanged and its target has the progress bound.
1356
+ owner detach and reclaim of that lease while a writer the dead task left still writes into it through `TMPDIR` (stopped,
1357
+ then removed) beside a dead lease nothing works in, and the final detach. External symlink targets and held directory
1358
+ modes stay unchanged, without duplicate provision and teardown; its 60 s case bound is unchanged and its target has the
1359
+ progress bound.
1189
1360
 
1190
1361
  The host target names both owned files with `./` paths: Bun otherwise interprets a bare path as a filter over recursive
1191
1362
  test discovery. This changes no selected case or timeout. The failed-provisioning regression keeps its exact injected
@@ -1235,11 +1406,14 @@ has something attached below it, is named in the task's error instead.
1235
1406
 
1236
1407
  Every `hdiutil` and `diskutil` execution goes through `cowshed disk-command`, including host-test inventory and cleanup.
1237
1408
  The cowshed is the installed one on `PATH`, which must provide this command, unless `COWSHED_EXECUTABLE` names another.
1238
- A target may set it in its `env`, workspace-relative or absolute: the task's own RAM volume work and its command then
1239
- both run that cowshed, given to the command as an absolute path. This repository sets it to
1240
- `packages/cowshed/bin/cowshed`, after `cowshed:build`, on the targets that exercise the facade (both real-APFS groups
1241
- and `nx-plugin:test-host`), so they test this checkout's cowshed, not an installed one that may predate a command the
1242
- checkout added. Cowshed alone owns disk-lifecycle leasing. Safe disk commands use
1409
+ Where `PATH` provides no cowshed, a workspace that itself provides a launcher — its own cowshed package's
1410
+ `packages/cowshed/bin/cowshed`, or a linked one's `node_modules/@smoothbricks/cowshed/bin/cowshed` — names that launcher
1411
+ for the run and its command instead; an environment with no cowshed anywhere keeps the bare name, so its spawn failure
1412
+ names the missing installed tool. A target may set it in its `env`, workspace-relative or absolute: the task's own RAM
1413
+ volume work and its command then both run that cowshed, given to the command as an absolute path. This repository sets
1414
+ it to `packages/cowshed/bin/cowshed`, after `cowshed:build`, on the targets that exercise the facade (both real-APFS
1415
+ groups and `nx-plugin:test-host`), so they test this checkout's cowshed, not an installed one that may predate a command
1416
+ the checkout added. Cowshed alone owns disk-lifecycle leasing. Safe disk commands use
1243
1417
  `cowshed disk-command diskutil --deadline-ms <positive integer> -- <args>`: the CLI owns that total monotonic budget
1244
1418
  across lease admission and child execution, never starts a child after it expires, and kills and reaps an overrun safe
1245
1419
  child before returning. Node waits for the facade's actual terminal exit without a second timer or lease. Only protected
@@ -1272,31 +1446,31 @@ when the command exits, or with the executor's socket when it is killed. The wai
1272
1446
  `cowshed: cpu-tokens wait done elapsed=… tokens=<granted>/<asked>` line. With no gateway listening, the command runs
1273
1447
  exactly as configured and nothing is said; a gateway from before the budget runs it unbudgeted and stderr says so.
1274
1448
 
1275
- A granted executor serves a private `BOUNDED_EXEC_CPU_POOL` with its actual token count. A nested default executor takes
1276
- from that immediate parent pool, capped at `min(asked, inherited, ceil(cores/2))`, instead of taking from the host while
1277
- the parent holds its grant. The pool accounts for siblings together; each admitted child serves only its own allocation
1278
- to grandchildren. Closing a child's connection returns its local allocation, never the parent's upstream grant. Upstream
1279
- loss revokes the downstream pool; losing a borrowed grant stops the command and records an ordinary failure, not a
1280
- timeout. A bare count or absent endpoint follows normal host admission. A connected parent pool's refusal or protocol
1281
- failure instead fails admission: taking from the host then could wait on the parent's own grant. `options.env` cannot
1282
- inject either marker. Parent-pool grants record `cpu.inherited: true` and their actual local wait; the span also says
1283
- `inherited=true`. Pool setup, listener and cleanup errors fail rather than bypassing accounting. Command bounds stay
1284
- unchanged.
1449
+ A granted executor serves a private `BOUNDED_EXEC_CPU_POOL` with its actual token count. A nested default executor asks
1450
+ that immediate parent pool for its own demand, instead of taking from the host while the parent holds its grant; the
1451
+ pool grants at most what it can. A lent pool accounts for siblings together; each admitted child serves only its own
1452
+ allocation to grandchildren. Closing a child's connection returns its local allocation, never the parent's upstream
1453
+ grant. Upstream loss revokes the downstream pool, so a dead parent grants nothing more; a command whose grant closes
1454
+ while it runs (a gateway restart, or the lending parent's exit) runs on over budget to its own exit, and stderr says
1455
+ `cowshed: cpu-tokens grant ended`. A bare count or absent endpoint follows normal host admission. A connected parent
1456
+ pool's refusal or protocol failure instead fails admission: taking from the host then could wait on the parent's own
1457
+ grant. `options.env` cannot inject either marker. Parent-pool grants record `cpu.inherited: true` and their actual local
1458
+ wait; the span also says `inherited=true`. Pool setup, listener and cleanup errors fail rather than bypassing
1459
+ accounting. Command bounds stay unchanged.
1285
1460
 
1286
1461
  The absent-parent fixture uses the executor's injectable budget with a real, controlled outer pool as its backing. It
1287
1462
  proves a positive allocation and re-acquires it after the command ends, rather than depending on free tokens in the
1288
1463
  host-wide gateway while the test runner itself holds an allocation. A bare count or unbudgeted success is not proof. A
1289
- land gate enters the existing task server with
1290
- `cowshed exec <workspace> --class gate --host --want N [--wait-ms N] -- COMMAND [ARGS...]` before daemon-stop and Nx
1291
- gate work. It requires a real gateway jobserver `class: "gate"` grant and serves that exact count as an existing live
1292
- parent CPU pool; no environment-only class or unbudgeted fallback is accepted. The default **120000 ms** admission wait
1293
- is explicitly overridable per invocation. A queued gate stops new background root admissions and takes whole tokens as
1294
- in-flight grants end. Running background tests/FIFOs are never shrunk, frozen or killed to manufacture tokens. An
1295
- expired wait returns `gate-admission-timeout` naming the wait and current checkout holders; it changes no task wall/idle
1296
- bound. Requested/granted count and actual queue wait are logged, and a child's nonzero exit is preserved exactly.
1297
- Compiling Cargo under the live pool borrows a sibling-accounted local allocation and receives its own private child
1298
- pool, so grandchildren never compete with their occupied ancestor. See `specs/cowshed/05_gateway.md`, "Gate admission by
1299
- whole-grant drain", for the guarantee and its deliberate limits.
1464
+ land gate (`tooling/land-host.sh`) enters the existing task server with
1465
+ `cowshed exec <workspace> --class gate --host [--want N] -- COMMAND [ARGS...]` after daemon-stop. It requires a real
1466
+ gateway jobserver `class: "gate"` grant for its own orchestrator; its live pool lends nothing of its own and relays
1467
+ every child's ask to the host as a gate-class request, so each task the gate starts is served FIFO ahead of every other
1468
+ exec's queued work. No environment-only class or unbudgeted fallback is accepted. The gate waits for its grant with no
1469
+ deadline, ahead of queued background work. Running background tests/FIFOs are never shrunk, frozen or killed to
1470
+ manufacture tokens. Requested/granted count and actual queue wait are logged, and a child's nonzero exit is preserved
1471
+ exactly. Compiling Cargo under the live pool takes a local allocation and receives its own private child pool, so
1472
+ grandchildren never compete with their occupied ancestor. See `specs/cowshed/05_gateway.md`, "Gate admission: FIFO ahead
1473
+ of background, never starving it", for the guarantee and its deliberate limits.
1300
1474
 
1301
1475
  Every `bounded-exec` task records why it ended in `.nx/workspace-data/bounded-exec/<task>/verdict.json`, keyed by the
1302
1476
  task id and the hash it ran at:
@@ -1312,6 +1486,10 @@ task id and the hash it ran at:
1312
1486
  this is a hang, never load. Its `tests` name the tests still running: those the runner said were running (nextest's
1313
1487
  `SLOW`, libtest's `has been running for over`) and never said finished, and those the JUnit report says it aborted
1314
1488
  when the bound stopped it.
1489
+ - `no-space`: the command failed after its output said a write found no space (`ENOSPC` or `No space left on device`).
1490
+ Its tests failed on the disk, not on their own, whatever bound or hang followed: it records that line and, when the
1491
+ task held a RAM lease, the lease, the volume and its free bytes when the line arrived. A passing run that printed such
1492
+ a line passed.
1315
1493
  - `failed`: a test failed on its own, or the command exited non-zero with no report naming a timeout.
1316
1494
  - `passed`.
1317
1495
 
@@ -1355,11 +1533,11 @@ Workspace updates preserve no-op test targets rather than adding a second test r
1355
1533
  the check when it reaches at least one local test execution leg and every such leg is bounded, including through nested
1356
1534
  no-op aggregates: `bounded-exec` with a command, a `cwd`, a positive `idleTimeoutMs` and `killAfterMs`, and no
1357
1535
  `timeoutMs`. Upstream and non-test prerequisites such as `^build`, `build`, `typecheck-tests`, and Cargo
1358
- compilation/archive targets are ignored by this test-leg check. Each bounded Bun leg must declare a positive per-test
1359
- `--timeout` no greater than its own `idleTimeoutMs`; the migration's 30-second default is not a limit on explicitly
1360
- bounded lanes. Only a leg that runs `bun test` must start in the project root or its `src/`, where Bun's test-file
1361
- discovery is cheap; any other command (a cargo workspace's per-crate nextest legs run from the workspace root, a gate
1362
- may run a script that lives in another project) may use any `cwd`.
1536
+ compilation/archive targets are ignored by this test-leg check. Each bounded Bun leg must delete Bun's per-test deadline
1537
+ with `BUN_TEST_TIMEOUT_FLAG` (`--timeout=0`) and set no other; a number is refused, since it bounds a test's wall-clock
1538
+ time, which is the host's, rather than its progress. Only a leg that runs `bun test` must start in the project root or
1539
+ its `src/`, where Bun's test-file discovery is cheap; any other command (a cargo workspace's per-crate nextest legs run
1540
+ from the workspace root, a gate may run a script that lives in another project) may use any `cwd`.
1363
1541
 
1364
1542
  ## Test Fixtures That Run Nx
1365
1543
 
@@ -1422,6 +1600,16 @@ tests) owns those roots:
1422
1600
  A fixture retires on every exit path, a throwing body included: stop its daemon, unlink its socket alias, then delete
1423
1601
  its root. A daemon that outlives the stop keeps the alias and the root, so the next run's sweep still finds both.
1424
1602
 
1603
+ A fixture workspace that runs real Nx with this plugin links an installation it owns, never the host's.
1604
+ `@smoothbricks/nx-plugin/owned-installation`'s `ownedInstallation(censusRoot, makeRoot)` copies the closure the graph
1605
+ witness's installation census resolves from `censusRoot` (Nx, this plugin and TypeScript, each package with its
1606
+ dependency edges relinked beside it and the top-level bins in `.bin`) into the empty directory `makeRoot` creates, on
1607
+ the first `nodeModules()`, and proves the copy. `retire()` fails, naming the changed nodes, if a fixture wrote into it,
1608
+ then deletes it. The host's closure moves under a fixture that reads it: a shared Bun store relinked by another install,
1609
+ or, in a workspace that developer-links this plugin, the checkout its author is editing and rebuilding. Either fails the
1610
+ producer receipt's installation proof for work that is not the test's. This package's tests bind `censusRoot` to this
1611
+ repository; a consumer binds it to its own workspace root.
1612
+
1425
1613
  ## Managed workspace files
1426
1614
 
1427
1615
  `nx generate @smoothbricks/nx-plugin:managed-files` stages the same managed files as `smoo monorepo update`, without
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=smoo-nx-test-clocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smoo-nx-test-clocks.d.ts","sourceRoot":"","sources":["../../src/bin/smoo-nx-test-clocks.ts"],"names":[],"mappings":""}
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+ import { findClockOracles, formatClockOracle, TEST_CLOCK_ORACLE } from '../test-clock-policy.js';
3
+ import { diffScope, upstreamBase } from '../test-walk-policy.js';
4
+ // TEST-CLOCK-ORACLE over the current directory's repository, judged on the cases changed since the upstream merge base
5
+ // (`upstreamBase`, the base `smoo-nx-test-walks --base` prints for the lint target's runtime input). Every finding
6
+ // prints `error[…]` and exits 1. Exit 2 when git cannot answer.
7
+ if (process.argv.length > 2) {
8
+ process.stderr.write('usage: smoo-nx-test-clocks\n');
9
+ process.exit(2);
10
+ }
11
+ const root = process.cwd();
12
+ const base = upstreamBase(root);
13
+ if (!base.ok) {
14
+ process.stderr.write(`${TEST_CLOCK_ORACLE.id} cannot find the upstream base: ${base.reason}\n`);
15
+ process.exit(2);
16
+ }
17
+ const scope = diffScope(root, base.value);
18
+ if (!scope.ok) {
19
+ process.stderr.write(`${TEST_CLOCK_ORACLE.id} cannot read the changes since ${base.value}: ${scope.reason}\n`);
20
+ process.exit(2);
21
+ }
22
+ const oracles = findClockOracles(root, scope.value.files, scope.value.changes);
23
+ for (const oracle of oracles)
24
+ process.stderr.write(`${formatClockOracle(oracle)}\n`);
25
+ if (oracles.length > 0)
26
+ process.exit(1);
27
+ process.stdout.write(`${TEST_CLOCK_ORACLE.id} passed: no changed test case carries a runner deadline, bounds elapsed host time or races ` +
28
+ `a configured bound against a timer (base ${base.value}).\n`);