@smoothbricks/nx-plugin 0.4.27 → 0.4.29

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 (124) hide show
  1. package/README.md +203 -83
  2. package/dist/bounded-test-policy.d.ts +10 -3
  3. package/dist/bounded-test-policy.d.ts.map +1 -1
  4. package/dist/bounded-test-policy.js +19 -25
  5. package/dist/cargo-closure-input.d.ts +12 -0
  6. package/dist/cargo-closure-input.d.ts.map +1 -1
  7. package/dist/cargo-closure-input.js +29 -7
  8. package/dist/cargo-source-hash.d.ts.map +1 -1
  9. package/dist/cargo-source-hash.js +42 -19
  10. package/dist/ensure-built-receipt.d.ts +34 -6
  11. package/dist/ensure-built-receipt.d.ts.map +1 -1
  12. package/dist/ensure-built-receipt.js +265 -159
  13. package/dist/ensure-built-witness.d.ts +27 -2
  14. package/dist/ensure-built-witness.d.ts.map +1 -1
  15. package/dist/ensure-built-witness.js +2176 -15
  16. package/dist/ensure-built.d.ts +99 -1
  17. package/dist/ensure-built.d.ts.map +1 -1
  18. package/dist/ensure-built.js +34 -53
  19. package/dist/executors/bounded-exec/cpu-pool.d.ts +16 -5
  20. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  21. package/dist/executors/bounded-exec/cpu-pool.js +43 -19
  22. package/dist/executors/bounded-exec/executor.d.ts +11 -2
  23. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  24. package/dist/executors/bounded-exec/executor.js +139 -39
  25. package/dist/executors/bounded-exec/ram-temp.d.ts +17 -11
  26. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  27. package/dist/executors/bounded-exec/ram-temp.js +27 -13
  28. package/dist/generators/bun-test-tracing/generator.js +2 -2
  29. package/dist/graph-input-contract.d.ts +98 -0
  30. package/dist/graph-input-contract.d.ts.map +1 -0
  31. package/dist/graph-input-contract.js +624 -0
  32. package/dist/index.d.ts +12 -5
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +17 -3
  35. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  36. package/dist/managed-files/ci-workflow.js +5 -2
  37. package/dist/managed-files/publish-workflow.d.ts +11 -1
  38. package/dist/managed-files/publish-workflow.d.ts.map +1 -1
  39. package/dist/producer-receipts.d.ts +19 -0
  40. package/dist/producer-receipts.d.ts.map +1 -0
  41. package/dist/producer-receipts.js +921 -0
  42. package/dist/testing.d.ts +8 -0
  43. package/dist/testing.d.ts.map +1 -1
  44. package/dist/testing.js +58 -0
  45. package/managed/raw/patches/nx@23.2.1.patch +328 -50
  46. package/managed/raw/tooling/direnv/developer-links.ts +147 -21
  47. package/managed/raw/tooling/direnv/devenv.smoo.nix +7 -7
  48. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -5
  49. package/managed/raw/tooling/direnv/linked-snapshots.ts +206 -40
  50. package/managed/raw/tooling/direnv/repo-path +15 -2
  51. package/managed/raw/tooling/direnv/setup-environment.ts +363 -125
  52. package/managed/templates/github/actions/cache-node-modules/action.yml +9 -0
  53. package/managed/templates/github/actions/setup-devenv/action.yml +63 -7
  54. package/nextest.toml +1 -1
  55. package/package.json +11 -6
  56. package/src/__tests__/fixture-nx-env.ts +7 -0
  57. package/src/__tests__/owned-installation.ts +174 -0
  58. package/src/bin/smoo-nx-bound-failures.test.ts +1 -1
  59. package/src/bounded-test-policy.test.ts +36 -22
  60. package/src/bounded-test-policy.ts +19 -27
  61. package/src/bun-bootstrap.test.ts +1 -1
  62. package/src/cargo-closure-input.test.ts +60 -11
  63. package/src/cargo-closure-input.ts +28 -6
  64. package/src/cargo-resolve-cache.test.ts +140 -25
  65. package/src/cargo-source-hash.test.ts +78 -3
  66. package/src/cargo-source-hash.ts +48 -30
  67. package/src/cross-check-policy.test.ts +2 -2
  68. package/src/ensure-built-receipt.test.ts +111 -16
  69. package/src/ensure-built-receipt.ts +251 -149
  70. package/src/ensure-built-witness.test.ts +197 -13
  71. package/src/ensure-built-witness.ts +187 -15
  72. package/src/ensure-built.test.ts +156 -102
  73. package/src/ensure-built.ts +114 -64
  74. package/src/executors/bounded-exec/cpu-pool.test.ts +116 -32
  75. package/src/executors/bounded-exec/cpu-pool.ts +55 -17
  76. package/src/executors/bounded-exec/cpu-tokens.test.ts +2 -2
  77. package/src/executors/bounded-exec/executor-host.test.ts +51 -41
  78. package/src/executors/bounded-exec/executor.test.ts +155 -35
  79. package/src/executors/bounded-exec/executor.ts +156 -45
  80. package/src/executors/bounded-exec/progress.test.ts +1 -1
  81. package/src/executors/bounded-exec/ram-temp-host.test.ts +46 -17
  82. package/src/executors/bounded-exec/ram-temp.test.ts +65 -3
  83. package/src/executors/bounded-exec/ram-temp.ts +32 -16
  84. package/src/executors/bounded-exec/verdict.test.ts +17 -12
  85. package/src/generators/bounded-test-targets/generator.test.ts +1 -3
  86. package/src/generators/bun-test-tracing/generator.test.ts +2 -2
  87. package/src/generators/bun-test-tracing/generator.ts +2 -2
  88. package/src/graph-input-contract.test.ts +371 -0
  89. package/src/graph-input-contract.ts +605 -0
  90. package/src/index.test.ts +3 -3
  91. package/src/index.ts +24 -3
  92. package/src/linked-snapshots.nx.test.ts +112 -30
  93. package/src/managed-files/ci-workflow.ts +5 -2
  94. package/src/managed-files/publish-workflow.ts +12 -1
  95. package/src/managed-files/repo-path.test.ts +44 -1
  96. package/src/managed-files/setup-devenv-free-disk.test.ts +95 -0
  97. package/src/nextest-code-bound.test.ts +23 -17
  98. package/src/nextest-partitions.test.ts +7 -1
  99. package/src/nx-cache-restore-mtime.test.ts +2 -2
  100. package/src/nx-daemon-claim.test.ts +5 -5
  101. package/src/nx-daemon-idle-cpu.test.ts +0 -1
  102. package/src/nx-daemon-idle-policy.test.ts +56 -0
  103. package/src/nx-daemon-ignore-files.test.ts +2 -2
  104. package/src/nx-daemon-validity.test.ts +31 -9
  105. package/src/nx-dot-input-policy.test.ts +5 -5
  106. package/src/nx-files-archive-racy.test.ts +1 -1
  107. package/src/nx-incomplete-run-summary.test.ts +1 -1
  108. package/src/nx-plugin-load-errors.test.ts +2 -2
  109. package/src/nx-project-graph-errors.test.ts +70 -0
  110. package/src/nx-skipped-task-exit.test.ts +2 -2
  111. package/src/nx-store-resolution.test.ts +7 -25
  112. package/src/nx-task-output-lease.test.ts +3 -3
  113. package/src/nx-use-local.test.ts +7 -5
  114. package/src/producer-receipts.test.ts +164 -0
  115. package/src/producer-receipts.ts +631 -0
  116. package/src/runtime-input.test.ts +1 -1
  117. package/src/serial-group-wiring.test.ts +4 -4
  118. package/src/task-results.test.ts +18 -16
  119. package/src/test-timings.test.ts +2 -2
  120. package/src/testing.test.ts +5 -5
  121. package/src/testing.ts +59 -0
  122. package/src/typecheck-test-policy.test.ts +1 -1
  123. package/src/typescript-resolution.test.ts +76 -0
  124. package/test-timings.json +5 -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
@@ -616,9 +631,8 @@ Concrete targets come from concrete files:
616
631
  replace Cargo's `target` link. Its inputs, like every cargo-derived fileset, are anchored at `{workspaceRoot}`: Nx
617
632
  resolves a `{projectRoot}` glob against only the files its project owns, and a nested package owns the crates under
618
633
  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
634
+ edited crates. Each member crate gets a cached `cargo-test-<package>` run (30s slow-test warning, no per-test kill)
635
+ whose inputs include that crate and its path dependencies, and whose command runs
622
636
  `cargo --frozen nextest run --binaries-metadata … --cargo-metadata … --target-dir-remap … --workspace-remap . -E 'package(<crate>)'`
623
637
  from the archive's one extraction. Runners therefore execute rather than build: they compile nothing in cargo's build
624
638
  tree, and fan out instead of chaining. They do not unpack the archive each: before the run, `smoo-nx-nextest-extract`
@@ -798,6 +812,35 @@ conservative graph witness too. Only Nx's current task hashes and matching artif
798
812
  unrelated edit does not force cached-log replay, and an actual input edit cannot hit an old source snapshot. Argument
799
813
  normalization, per-task environments and plugin pre/post hooks still run.
800
814
 
815
+ A local graph plugin can declare `options.graphInputContract` with `version: 1`, one explicit `kind` (`native-only`,
816
+ `tsconfig-extends` or `reference-scan`), `modules: [{ path, sha256 }]` and `packages: [name]`. Module paths are
817
+ workspace-relative and the first module is the configured entry. The literal SHA-256 values bind the audited
818
+ entry/helper import closure to that input contract; changing code cannot inherit its former proof, and checking a
819
+ declaration never rewrites its approval hashes. The installed `@smoothbricks/nx-plugin/graph-input-contract` factory
820
+ collects a read witness from the owning reader, not a second parser or a guessed file list. Pure native-only callbacks
821
+ need no outside-read trace, but still require their exact audited module and package-resolution closure.
822
+
823
+ The other kinds publish complete or unproved evidence in the existing Nx workspace-data directory as a byproduct of the
824
+ actual callback. A complete witness binds its contract, native file/hash/namespace identity before and after the
825
+ callback, read file/directory stamps, missing paths, physical package resolutions, tools and environment. TypeScript
826
+ extends and reference scans retain their existing results while recording the outside inputs they really read, including
827
+ Git configuration origins and relevant namespace inventories. Installed Nx owns daemon/worker environment normalization;
828
+ loader/preload settings are not silently dropped. Missing or changed declarations, missing traces, stale read evidence
829
+ and unknown loaders, dynamic configuration or unbounded reads make the proof unproved and require the ordinary
830
+ authoritative graph RPC. A declared kind alone is never admission, and this witness never replaces current Nx task
831
+ hashing or artifact comparison.
832
+
833
+ The installed-package census expands each declared `files` set and relative export targets through that workspace's Nx
834
+ native output authority, always retaining the manifest, directory/alias namespace evidence and every resolution edge;
835
+ without a file declaration it conservatively retains the whole package tree.
836
+
837
+ Ancestor directories bind device/inode/type/mode path identity; files and symlinks retain their full stamps, and a
838
+ directory is upgraded to a full nanosecond node/namespace stamp when its membership is actually read.
839
+
840
+ A physically missing required factory after the clean cutover is an invalid installation and fails loudly; it is not a
841
+ proof miss that can fall back to the graph RPC. Consumers adopt the normal static import only after the public producer
842
+ is available.
843
+
801
844
  The daemon's output records are lossy: they are held in memory, tracked per collapsed directory, and erased by writes it
802
845
  processes more than two seconds late — including, on a busy daemon, a restore's own writes. When it cannot vouch for a
803
846
  task's outputs, the working tree is compared with Nx's local cache artifact for that exact task hash, entry by entry as
@@ -813,37 +856,73 @@ for all those nodes. It is evidence of the same previously compared bytes, never
813
856
  rule. Missing/unreadable evidence or moved nodes require a full comparison; mutations to either the cache or working
814
857
  tree, parent symlink replacement, and directory membership changes cannot borrow an old equality verdict.
815
858
 
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.
859
+ `probeBuilt({ target, cwd })` is the distinct typed read-only product operation. Its `hit` is an actual published
860
+ `EnsureBuiltReceipt`, not a cache hit re-probed under the consumer's environment. The producer opts into publication in
861
+ its own Nx plugin options as
862
+ `producerReceipts: { targets: ["lmao:rust-dist", "lmao:cargo-wasm", "lmao:cargo-thread-ffi"] }`, naming every target a
863
+ consumer's snapshot declaration names. The pre-task hook captures the committed HEAD/tree and tracked-source/tool basis;
864
+ the post-task hook uses Nx's actual successful `TaskResults`, hashes/hash details, argv and start/end times, including
865
+ successful uncacheable prerequisites, and atomically publishes the receipt in that checkout's existing Nx
866
+ workspace-data. Disabled publication performs no source prepass, so an ordinary consumer CLI pays none of that producer
867
+ work. No file permission, path, daemon state or cached row can invent a completion receipt. Nx takes one pre/post
868
+ task-hook pair per plugin, so the plugin's pair runs the controller's `COWSHED_NX_TASK_RECEIPT_ID` task-results hint
869
+ first and these producer hooks second, each with the same options and run context and neither reading the other's
870
+ output.
871
+
872
+ The receipt binds the selected target, basis commit SHA and committed tree SHA, actual argv, declared producer
873
+ environment identity and bound tool/module inputs, independent product output SHA-256, measured wall time, and an
874
+ explicit clean tracked-tree assertion. It includes every completed required task's Nx identity and every Nx-expanded
875
+ public output. Files carry SHA-256; symlinks carry text and mode without following them; directories carry mode, ordered
876
+ membership and child-census digest, including empty directories. The producer source/tool/output witnesses must stay
877
+ stable through publication, and every refusal that one moved names the first nodes that did. A tool or installed-module
878
+ node whose device, inode, mode, size and mtime are unchanged and only its ctime moved is re-read and compared with its
879
+ recorded bytes, link text and membership, as any moved stamp requires a full comparison: under `globalStore` the closure
880
+ lives in Bun's install cache, which every checkout on the machine shares, and linking a package's bin on any of their
881
+ installs re-chmods the store file to the mode it already has. The command's stdout/stderr digest is not a product
882
+ digest. The bound tool/module inputs are the installed closures of Nx, this plugin, TypeScript and local graph plugins,
883
+ and the producer executables. A task's npm external inputs (`AllExternalDependencies` and the npm nodes of its project's
884
+ dependency closure) are Nx's lockfile identities: the task's hash details and the committed `bun.lock` bind them, and no
885
+ installed closure is resolved for them, since under Bun's isolated linker most of them do not resolve from the task's
886
+ project.
887
+
888
+ Validity compares the committed tree, not the current HEAD spelling. An empty commit with an identical tree keeps the
889
+ receipt valid and its original basis SHA unchanged; the consumer never rewrites that provenance. A genuinely changed
890
+ tree invalidates the receipt. Multi-target consumers require one tree and retain each producer's actual basis.
891
+
892
+ The consumer validates this stored receipt against its declared target, committed-tree/configuration identity, declared
893
+ environment/tool inputs and actual output census. It never re-hashes the provider's task graph in its own environment. A
894
+ valid receipt is the hit. A missing, mismatched, stale or unbound receipt requires the authoritative graph RPC, then a
895
+ loud miss/refusal without running a target or writing provider outputs. A managed consumer requires the installed
896
+ `probeBuilt` operation and the complete producer-receipt contract; an old receipt lacking it refuses, never falls back
897
+ to `ensureBuilt` or a producer writer. `ensureBuilt` remains the normal build/stream operation with its existing
898
+ hit/built/failed results and Nx's current source/cache/artifact verdict.
899
+
900
+ **A refusal never replaces a receipt.** A run whose products the hooks cannot prove publishes a refusal instead: its
901
+ detail, in its own `producer-refusal-<sha>.json` beside `producer-receipt-<sha>.json`. A refusal says only that this run
902
+ could not prove something; it is no evidence about the products an earlier run proved, and overwriting that run's
903
+ receipt would destroy the evidence a consumer can still check. So a receipt stays until a later receipt replaces it, and
904
+ the consumer validates it on its own evidence as above: one that still validates is the hit, whatever a later run
905
+ refused. A miss names the latest refusal in its detail, and a published receipt removes the refusal it answers. The
906
+ hooks read git under the repository's own configuration (`GIT_CONFIG_GLOBAL=/dev/null`, `GIT_CONFIG_NOSYSTEM=1`): Nx
907
+ runs them in the workspace's Nx daemon, which runs inside the cowshed sandbox under a host client's `HOME`, and the
908
+ sandbox denies the operator's global git configuration (specs/cowshed/04_sandbox.md, the runtime-input contract).
909
+
910
+ A FILE-only source plan does not perform a redundant installation census for absent runtime recipes; the complete
911
+ producer tool/module and output SHA evidence is still captured and independently revalidated on every product probe.
912
+
913
+ Git source provenance is the committed tree and the producer's clean tracked source basis, not an unrelated untracked
914
+ user file in its working directory. An actual FILE input outside HEAD, a modified tracked input, changed membership,
915
+ opaque custom/native input proof or genuinely unbounded runtime source cannot be signed. Bounded runtime/env identity is
916
+ explicitly labelled `nx-task-hash-only`; the existing generator-owned version recipes still require their declared
917
+ cwd/toolchain FILE pins and proved installed closure. Public outputs are excluded precisely from source stability, never
918
+ with broad exclusions that can hide manifests or configuration. A caller probing multiple targets requires the same
919
+ provider committed-tree identity, retaining each original producer basis, before publishing its sealed snapshot. A
920
+ caller from another workspace never lends its socket, database or cache overrides to the provider. Inside a managed
921
+ shell (`DEVENV_RUNTIME`), `ensureBuilt` asks the packaged `nx-socket-dir.sh` owner for the provider's binding: the
922
+ root's verified cowshed runtime link when present, otherwise its canonical checkout spelling under that shell runtime.
923
+ Outside a managed shell, Nx retains its normal defaults. A socket-owner refusal returns `disposition: 'failed'` with
924
+ `reason.kind: 'workspace-socket'`, the selected `taskId`, `workspaceRoot` and operational `detail`, before any task or
925
+ daemon client starts. The owner's actual exit or signal is preserved; the wrapper must not report that the target ran.
847
926
 
848
927
  ```typescript
849
928
  import { ensureBuilt } from '@smoothbricks/nx-plugin/ensure-built';
@@ -927,9 +1006,9 @@ the exact caller-owned developer checkout and the actual shared store. Only reac
927
1006
  grants, never the whole checkout or `.bun` root. Traversal deduplicates exact package identities, not read-grant
928
1007
  prefixes: a covered local `@nx` scope can still contain a binding to the pinned native platform package in the shared
929
1008
  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.
1009
+ directories that travel with the clone. Foreign-daemon retirement witnesses retain the daemon's own standalone root,
1010
+ state and short socket throughout the landing; its actual produced record is only a nomination, and its owner performs
1011
+ cleanup after the identity proof.
933
1012
 
934
1013
  The Nx patch repairs upstream Nx runtime behavior, separately from this plugin's workspace-owner checks:
935
1014
 
@@ -1059,9 +1138,31 @@ The Nx patch repairs upstream Nx runtime behavior, separately from this plugin's
1059
1138
  five-minute idle interval. Cowshed's existing usage-aware keeper remains authoritative for sheds whose tree changes
1060
1139
  without a job, session or task-database holder. No daemon is disabled and the next normal client starts one again. The
1061
1140
  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.
1141
+ compile dependency emits the Typia-transformed product before Bun runs it. The proof gives the daemon a resident
1142
+ plugin worker that asks it for files, holds a real silent client beyond five minutes, disconnects, and records the
1143
+ kernel and daemon-log evidence of the next five-minute departure, workers included. It stays outside the bounded Bun
1144
+ shards; their fast regression checks the actual installed policy export.
1145
+ - **A plugin worker is its daemon's client only while it waits on a reply.** A plugin's `globWithWorkspaceContext`,
1146
+ `hashWithWorkspaceContext` and the other workspace-context reads run through the worker's own daemon client, which
1147
+ kept its connection open after the reply. The daemon keeps a worker with graph hooks for as long as it lives (above),
1148
+ and that open connection retained the daemon, so neither ever reached the idle stop: on 2026-10-17 the 72 shed daemon
1149
+ logs held 573 stops and not one `Server stopped because: "300000ms of inactivity"`, and every daemon a host client
1150
+ started stayed behind as a `ppid 1` process until something signalled it. In a plugin worker the client now drops its
1151
+ connection once its request queue drains, and the daemon is unchanged. The client also ignores the close of a
1152
+ connection it already dropped, which stock Nx let reset whichever request was current. A bounded regression runs a
1153
+ real daemon whose resident worker globs through it and requires zero open connections after the only client exits.
1154
+ Stock Nx keeps a worker until its last registered phase, so a plugin with task hooks keeps the same connection open
1155
+ there after a graph-only request; this hunk does not retire with the worker-retention hunk.
1156
+ - **A daemon whose workspace has gone stops instead of reading it.** Nx 23.2.1's native file worker reads an empty file
1157
+ map as one it has not filled yet and waits on its condition variable for files (`FilesWorker::get_files`,
1158
+ `while guard.len() == 0`). Once every file of a workspace is deleted under a running daemon, as when a checkout is
1159
+ removed or unmounted before its daemon is stopped, the next glob blocks the daemon's only thread for good. It sits at
1160
+ 0% CPU in `WorkspaceContext::multi_glob`, no timer or request runs again, and SIGTERM does nothing because its handler
1161
+ is JavaScript; only SIGKILL ends it. The daemon now stops itself when the workspace's `nx.json` is gone. It checks on
1162
+ every watcher batch before applying it, on every request and on the 5 s safety poll, so the batch that would empty the
1163
+ file map is never applied. A workspace without `nx.json` is no Nx workspace, and its client already runs without a
1164
+ daemon. A bounded regression deletes every tracked file under a real daemon and requires it to exit with that reason;
1165
+ against the unpatched daemon it hangs in that frame and survives its fixture's SIGTERM.
1065
1166
  - **The daemon stops for an ignore file only when its watcher's rules may be stale.** Nx's native watcher reads its
1066
1167
  ignore files once, in `watch()`, and the daemon stopped itself on every watcher event for a `.gitignore` or
1067
1168
  `.nxignore`, whatever the file then held. A rewrite with the same bytes (a checkout, a formatter) reports one, and so
@@ -1126,8 +1227,18 @@ therefore runs as long as it needs, however slow the host, and a test that never
1126
1227
  last test that finished. bun prints nothing per passing test when it believes an agent runs it, so the executor asks a
1127
1228
  lone `bun test` for `--dots`, one dot per finished test. A command that reports no tests makes progress only by exiting.
1128
1229
  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.
1230
+ 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,
1231
+ so every bun leg deletes it with `bun test --timeout=0` (`BUN_TEST_TIMEOUT_FLAG`; `0` means no deadline, measured on the
1232
+ 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
1233
+ that never returns still ends the run through `idleTimeoutMs`. `timeoutMs`, an absolute ceiling, is for commands that
1234
+ report no tests; a target names at least one of the two.
1235
+
1236
+ 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
1237
+ scratch cowshed project, say) writes `{"op":"host-wait"}` on the `BOUNDED_EXEC_CPU_POOL` it inherited and holds the
1238
+ connection while the work waits; while any such wait is held, the idle clock is stopped and keeps the time it had left,
1239
+ and it runs on from there when the last wait closes. stderr says `bounded-exec: idle clock stopped` and `… restarted`,
1240
+ and an expiry names the queued time it did not count (`specs/cowshed/05_gateway.md`, "A queued descendant is not idle").
1241
+ `timeoutMs` is never stopped.
1131
1242
 
1132
1243
  The final-five-second pre-signal snapshot attributes the runner's process tree and observed resources, with explicit
1133
1244
  incomplete/raced results and no delay to termination. Its timing, visibility and evidence contract is defined in
@@ -1139,9 +1250,13 @@ detached when the last live lease ends, since its pages return only on detach. I
1139
1250
  spends none of the AppleDiskImages2 attach budget cowshed counts (`specs/cowshed/01a_apfs.md`, "How the APFS host
1140
1251
  degrades"). A lease whose task died is reclaimed by the next task, unless an image is still attached from a file below
1141
1252
  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.
1253
+ task names them. The task's pid dying does not end what its command started, so before a lease is removed every process
1254
+ working in it is stopped, with everything it started: a process counts when its working directory or the `TMPDIR` it was
1255
+ started with lies in the lease. Most leftovers write there only through `TMPDIR` (a ttsc plugin build copying its Go
1256
+ sources, a Bun or Node compile cache written at exit), and a working-directory census alone let them write into a lease
1257
+ while it was removed, failing the next task's lease with `ENOTEMPTY`. A target's own `env.TMPDIR` wins over the lease.
1258
+ Inside a cowshed sandbox, which cannot write the lock in `/private/tmp`, the task keeps its inherited `TMPDIR` and says
1259
+ so once. A failed task that left the volume nearly full names the volume.
1145
1260
 
1146
1261
  Outside macOS, the executor never provisions an APFS RAM disk: it keeps the inherited `TMPDIR`, or uses the target's
1147
1262
  `env.TMPDIR` override, without reclaiming either directory. The host temp-directory proof runs the real default executor
@@ -1184,8 +1299,10 @@ instead of changing an attached volume. Held leases undergo no permission change
1184
1299
 
1185
1300
  The real RAM-volume regression walks one volume's lifecycle in a single test: unmarked debris and a live-lease refusal,
1186
1301
  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.
1302
+ owner detach and reclaim of that lease while a writer the dead task left still writes into it through `TMPDIR` (stopped,
1303
+ then removed) beside a dead lease nothing works in, and the final detach. External symlink targets and held directory
1304
+ modes stay unchanged, without duplicate provision and teardown; its 60 s case bound is unchanged and its target has the
1305
+ progress bound.
1189
1306
 
1190
1307
  The host target names both owned files with `./` paths: Bun otherwise interprets a bare path as a filter over recursive
1191
1308
  test discovery. This changes no selected case or timeout. The failed-provisioning regression keeps its exact injected
@@ -1235,11 +1352,14 @@ has something attached below it, is named in the task's error instead.
1235
1352
 
1236
1353
  Every `hdiutil` and `diskutil` execution goes through `cowshed disk-command`, including host-test inventory and cleanup.
1237
1354
  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
1355
+ Where `PATH` provides no cowshed, a workspace that itself provides a launcher — its own cowshed package's
1356
+ `packages/cowshed/bin/cowshed`, or a linked one's `node_modules/@smoothbricks/cowshed/bin/cowshed` — names that launcher
1357
+ for the run and its command instead; an environment with no cowshed anywhere keeps the bare name, so its spawn failure
1358
+ names the missing installed tool. A target may set it in its `env`, workspace-relative or absolute: the task's own RAM
1359
+ volume work and its command then both run that cowshed, given to the command as an absolute path. This repository sets
1360
+ it to `packages/cowshed/bin/cowshed`, after `cowshed:build`, on the targets that exercise the facade (both real-APFS
1361
+ groups and `nx-plugin:test-host`), so they test this checkout's cowshed, not an installed one that may predate a command
1362
+ the checkout added. Cowshed alone owns disk-lifecycle leasing. Safe disk commands use
1243
1363
  `cowshed disk-command diskutil --deadline-ms <positive integer> -- <args>`: the CLI owns that total monotonic budget
1244
1364
  across lease admission and child execution, never starts a child after it expires, and kills and reaps an overrun safe
1245
1365
  child before returning. Node waits for the facade's actual terminal exit without a second timer or lease. Only protected
@@ -1272,31 +1392,31 @@ when the command exits, or with the executor's socket when it is killed. The wai
1272
1392
  `cowshed: cpu-tokens wait done elapsed=… tokens=<granted>/<asked>` line. With no gateway listening, the command runs
1273
1393
  exactly as configured and nothing is said; a gateway from before the budget runs it unbudgeted and stderr says so.
1274
1394
 
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.
1395
+ A granted executor serves a private `BOUNDED_EXEC_CPU_POOL` with its actual token count. A nested default executor asks
1396
+ that immediate parent pool for its own demand, instead of taking from the host while the parent holds its grant; the
1397
+ pool grants at most what it can. A lent pool accounts for siblings together; each admitted child serves only its own
1398
+ allocation to grandchildren. Closing a child's connection returns its local allocation, never the parent's upstream
1399
+ grant. Upstream loss revokes the downstream pool, so a dead parent grants nothing more; a command whose grant closes
1400
+ while it runs (a gateway restart, or the lending parent's exit) runs on over budget to its own exit, and stderr says
1401
+ `cowshed: cpu-tokens grant ended`. A bare count or absent endpoint follows normal host admission. A connected parent
1402
+ pool's refusal or protocol failure instead fails admission: taking from the host then could wait on the parent's own
1403
+ grant. `options.env` cannot inject either marker. Parent-pool grants record `cpu.inherited: true` and their actual local
1404
+ wait; the span also says `inherited=true`. Pool setup, listener and cleanup errors fail rather than bypassing
1405
+ accounting. Command bounds stay unchanged.
1285
1406
 
1286
1407
  The absent-parent fixture uses the executor's injectable budget with a real, controlled outer pool as its backing. It
1287
1408
  proves a positive allocation and re-acquires it after the command ends, rather than depending on free tokens in the
1288
1409
  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.
1410
+ land gate (`tooling/land-host.sh`) enters the existing task server with
1411
+ `cowshed exec <workspace> --class gate --host [--want N] -- COMMAND [ARGS...]` after daemon-stop. It requires a real
1412
+ gateway jobserver `class: "gate"` grant for its own orchestrator; its live pool lends nothing of its own and relays
1413
+ 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
1414
+ exec's queued work. No environment-only class or unbudgeted fallback is accepted. The gate waits for its grant with no
1415
+ deadline, ahead of queued background work. Running background tests/FIFOs are never shrunk, frozen or killed to
1416
+ manufacture tokens. Requested/granted count and actual queue wait are logged, and a child's nonzero exit is preserved
1417
+ exactly. Compiling Cargo under the live pool takes a local allocation and receives its own private child pool, so
1418
+ grandchildren never compete with their occupied ancestor. See `specs/cowshed/05_gateway.md`, "Gate admission: FIFO ahead
1419
+ of background, never starving it", for the guarantee and its deliberate limits.
1300
1420
 
1301
1421
  Every `bounded-exec` task records why it ended in `.nx/workspace-data/bounded-exec/<task>/verdict.json`, keyed by the
1302
1422
  task id and the hash it ran at:
@@ -1355,11 +1475,11 @@ Workspace updates preserve no-op test targets rather than adding a second test r
1355
1475
  the check when it reaches at least one local test execution leg and every such leg is bounded, including through nested
1356
1476
  no-op aggregates: `bounded-exec` with a command, a `cwd`, a positive `idleTimeoutMs` and `killAfterMs`, and no
1357
1477
  `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`.
1478
+ compilation/archive targets are ignored by this test-leg check. Each bounded Bun leg must delete Bun's per-test deadline
1479
+ with `BUN_TEST_TIMEOUT_FLAG` (`--timeout=0`) and set no other; a number is refused, since it bounds a test's wall-clock
1480
+ time, which is the host's, rather than its progress. Only a leg that runs `bun test` must start in the project root or
1481
+ its `src/`, where Bun's test-file discovery is cheap; any other command (a cargo workspace's per-crate nextest legs run
1482
+ from the workspace root, a gate may run a script that lives in another project) may use any `cwd`.
1363
1483
 
1364
1484
  ## Test Fixtures That Run Nx
1365
1485
 
@@ -4,11 +4,18 @@ export declare const BOUNDED_TEST_EXECUTOR = "@smoothbricks/nx-plugin:bounded-ex
4
4
  * A test target's one bound: the `idleTimeoutMs` with which no test may go unfinished, the hang backstop of
5
5
  * specs/cowshed/08_testing.md. It is no wall-clock ceiling: a suite that keeps finishing tests runs as long as it
6
6
  * needs. It is the longest any single test may run, so it stays above every slow-timeout class in the plugin's
7
- * nextest.toml and every bun `--timeout`.
7
+ * nextest.toml; a bun leg has no per-test deadline of its own (`BUN_TEST_TIMEOUT_FLAG`).
8
8
  */
9
9
  export declare const BOUNDED_TEST_IDLE_TIMEOUT_MS = 180000;
10
10
  export declare const BOUNDED_TEST_KILL_AFTER_MS = 10000;
11
- export declare const BOUNDED_TEST_PER_TEST_TIMEOUT_MS = 30000;
11
+ /**
12
+ * Deletes Bun's per-test deadline: 5000 ms unless the command sets one, and Bun ignores a bunfig `[test] timeout`, so
13
+ * the flag is the one place to set it. `0` means no deadline (measured on the pinned Bun 1.4.2: a test blocked 12 s in
14
+ * `spawnSync` and one sleeping 7 s both pass under `--timeout=0`). A test waits for the event it is waiting for, and
15
+ * the leg's `idleTimeoutMs` ends a test that never returns; no per-test bound kills a test, however long a loaded host
16
+ * makes its work take (specs/cowshed/08_testing.md).
17
+ */
18
+ export declare const BUN_TEST_TIMEOUT_FLAG = "--timeout=0";
12
19
  export interface BoundedTestPolicyPackageJson {
13
20
  name?: string;
14
21
  workspaces?: unknown;
@@ -64,5 +71,5 @@ export declare function checkWorkspaceCargoTestReachabilityPolicy(root: string,
64
71
  export declare function checkBoundedTestTargetPolicy(packageJson: BoundedTestPolicyPackageJson, options: ApplyBoundedTestTargetPolicyOptions): boolean;
65
72
  export declare function boundedTestScriptAlias(projectName: string): string;
66
73
  export declare function resolveTestCommand(packageJson: BoundedTestPolicyPackageJson, defaultCommand?: string, projectJson?: BoundedTestPolicyProjectJson): string;
67
- export declare function ensureBunTestTimeoutFlag(command: string, timeoutMs?: number): string;
74
+ export declare function ensureBunTestTimeoutFlag(command: string): string;
68
75
  //# sourceMappingURL=bounded-test-policy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bounded-test-policy.d.ts","sourceRoot":"","sources":["../src/bounded-test-policy.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGrG,eAAO,MAAM,qBAAqB,yCAAyC,CAAC;AAC5E;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,SAAU,CAAC;AACpD,eAAO,MAAM,0BAA0B,QAAS,CAAC;AAKjD,eAAO,MAAM,gCAAgC,QAAS,CAAC;AAEvD,MAAM,WAAW,4BAA4B;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,EAAE,CAAC,EAAE;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;KACnD,CAAC;CACH;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mCAAmC;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,4BAA4B,CAAC;IAC3C,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GAC3C,OAAO,CAqBT;AA8KD,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAElE;AAED,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,4BAA4B,EACzC,cAAc,SAAa,EAC3B,WAAW,CAAC,EAAE,4BAA4B,GACzC,MAAM,CAER;AA4CD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAYhE"}
@@ -9,15 +9,18 @@ export const BOUNDED_TEST_EXECUTOR = '@smoothbricks/nx-plugin:bounded-exec';
9
9
  * A test target's one bound: the `idleTimeoutMs` with which no test may go unfinished, the hang backstop of
10
10
  * specs/cowshed/08_testing.md. It is no wall-clock ceiling: a suite that keeps finishing tests runs as long as it
11
11
  * needs. It is the longest any single test may run, so it stays above every slow-timeout class in the plugin's
12
- * nextest.toml and every bun `--timeout`.
12
+ * nextest.toml; a bun leg has no per-test deadline of its own (`BUN_TEST_TIMEOUT_FLAG`).
13
13
  */
14
14
  export const BOUNDED_TEST_IDLE_TIMEOUT_MS = 180_000;
15
15
  export const BOUNDED_TEST_KILL_AFTER_MS = 10_000;
16
- // Per-test timeout passed to `bun test --timeout=<ms>`. Bun's default is
17
- // 5000ms which is too tight for git-fixture tests on slower CI runners
18
- // (Actions). The bunfig.toml `[test] timeout` key is silently ignored by
19
- // Bun — the only working surfaces are this CLI flag and `setDefaultTimeout()`.
20
- export const BOUNDED_TEST_PER_TEST_TIMEOUT_MS = 30_000;
16
+ /**
17
+ * Deletes Bun's per-test deadline: 5000 ms unless the command sets one, and Bun ignores a bunfig `[test] timeout`, so
18
+ * the flag is the one place to set it. `0` means no deadline (measured on the pinned Bun 1.4.2: a test blocked 12 s in
19
+ * `spawnSync` and one sleeping 7 s both pass under `--timeout=0`). A test waits for the event it is waiting for, and
20
+ * the leg's `idleTimeoutMs` ends a test that never returns; no per-test bound kills a test, however long a loaded host
21
+ * makes its work take (specs/cowshed/08_testing.md).
22
+ */
23
+ export const BUN_TEST_TIMEOUT_FLAG = '--timeout=0';
21
24
  export function applyBoundedTestTargetPolicy(packageJson, options) {
22
25
  const command = resolveTestCommand(packageJson, options.defaultCommand ?? 'bun test', options.projectJson);
23
26
  let targetOwner = options.projectJson;
@@ -345,7 +348,7 @@ function isBoundedExecutionTarget(executor, rawOptions, allowedCwds) {
345
348
  // A test leg is bounded by progress alone: a wall-clock ceiling fails a suite that is only slow.
346
349
  rawOptions.timeoutMs === undefined &&
347
350
  isPositiveSafeInteger(rawOptions.idleTimeoutMs) &&
348
- bunTestTimeoutIsBounded(command, rawOptions.idleTimeoutMs) &&
351
+ bunTestHasNoDeadline(command) &&
349
352
  typeof rawOptions.cwd === 'string' &&
350
353
  // `bun test` walks its working directory looking for test files, so it must start where that walk is cheap: the
351
354
  // project root or its `src/`. Any other command names what it runs and has no walk to bound. A cargo workspace's
@@ -354,19 +357,14 @@ function isBoundedExecutionTarget(executor, rawOptions, allowedCwds) {
354
357
  (!BUN_TEST_PREFIX.test(command) || allowedCwds.has(rawOptions.cwd)) &&
355
358
  isPositiveSafeInteger(rawOptions.killAfterMs));
356
359
  }
357
- /** A bun leg's per-test `--timeout` must fire before the leg's progress bound would. */
358
- function bunTestTimeoutIsBounded(command, idleTimeoutMs) {
360
+ /** A bun leg deletes Bun's per-test deadline with `BUN_TEST_TIMEOUT_FLAG` and sets no other. */
361
+ function bunTestHasNoDeadline(command) {
359
362
  if (!BUN_TEST_PREFIX.test(command)) {
360
363
  return true;
361
364
  }
362
365
  let found = false;
363
- for (const match of command.matchAll(/(?:^|\s)--timeout(?==|\s|$)(?:=(\S*)|\s+(\S+))?/g)) {
364
- const value = match[1] ?? match[2];
365
- const perTestTimeoutMs = Number(value);
366
- if (value === undefined ||
367
- !/^\d+$/.test(value) ||
368
- !isPositiveSafeInteger(perTestTimeoutMs) ||
369
- perTestTimeoutMs > idleTimeoutMs) {
366
+ for (const match of command.matchAll(/(?:^|\s)(--timeout(?==|\s|$)\S*)/g)) {
367
+ if (match[1] !== BUN_TEST_TIMEOUT_FLAG) {
370
368
  return false;
371
369
  }
372
370
  found = true;
@@ -486,23 +484,19 @@ function resolveTargetCommand(existingTarget) {
486
484
  }
487
485
  const BUN_TEST_PREFIX = /^bun\s+test(?=\s|$)/;
488
486
  const EXISTING_BUN_TIMEOUT = /(^|\s)--timeout(?:=|\s+)(\S+)/;
489
- // Bun's `[test] timeout` bunfig key is silently ignored — only the CLI flag
490
- // and `setDefaultTimeout()` actually take effect. Normalize every `bun test`
491
- // command so the policy enforces the workspace per-test timeout in the one
492
- // place where Bun will honor it.
493
- export function ensureBunTestTimeoutFlag(command, timeoutMs = BOUNDED_TEST_PER_TEST_TIMEOUT_MS) {
487
+ // Normalize every `bun test` command to `BUN_TEST_TIMEOUT_FLAG`, the one place Bun honors a per-test bound.
488
+ export function ensureBunTestTimeoutFlag(command) {
494
489
  if (!BUN_TEST_PREFIX.test(command)) {
495
490
  return command;
496
491
  }
497
- const flag = `--timeout=${timeoutMs}`;
498
492
  const existing = EXISTING_BUN_TIMEOUT.exec(command);
499
493
  if (!existing) {
500
- return command.replace(BUN_TEST_PREFIX, `bun test ${flag}`);
494
+ return command.replace(BUN_TEST_PREFIX, () => `bun test ${BUN_TEST_TIMEOUT_FLAG}`);
501
495
  }
502
- if (existing[2] === String(timeoutMs)) {
496
+ if (existing[0].trimStart() === BUN_TEST_TIMEOUT_FLAG) {
503
497
  return command;
504
498
  }
505
- return command.replace(EXISTING_BUN_TIMEOUT, `${existing[1]}${flag}`);
499
+ return command.replace(EXISTING_BUN_TIMEOUT, (_match, lead) => `${lead}${BUN_TEST_TIMEOUT_FLAG}`);
506
500
  }
507
501
  function isPackageTestScriptRunnerCommand(command) {
508
502
  return /^(?:bun\s+run|npm(?:\s+run)?|pnpm(?:\s+run)?|yarn(?:\s+run)?)\s+test(?:\s|$)/.test(command.trim());
@@ -18,6 +18,8 @@ export declare class CargoClosureInputError extends Error {
18
18
  */
19
19
  export interface CargoClosureSource {
20
20
  readonly manifest: string;
21
+ /** The Nx workspace root as the computation names it, which Nx's file index is keyed by. */
22
+ readonly workspaceRoot: string;
21
23
  /** The canonical Nx workspace root. */
22
24
  readonly root: string;
23
25
  readonly cargo: CargoResolve;
@@ -56,6 +58,16 @@ export declare function resolveCargoClosureSource(manifest: string, workspaceRoo
56
58
  * An in-workspace member missing from Nx's file index is a typed refusal,
57
59
  * never a whole-workspace runtime hash. Only outside-workspace members need
58
60
  * the external-only runtime input.
61
+ *
62
+ * A compiled-in file is named only when Nx's file index holds both it and the
63
+ * source that includes it. An ignored one is a build output: no fileset can
64
+ * hash its bytes, which reach a consumer through its producer's dependency
65
+ * outputs instead, so naming it would add nothing to any task's key except
66
+ * the names of whatever output last ran. That state is exactly what a project
67
+ * graph must not read (`globIndexedFiles`): a producer that regenerates
68
+ * content-named files would otherwise move every key of the graph it was
69
+ * hashed under, and the run that compiled a tree would leave its verdict
70
+ * under a key no later run of the same tree computes.
59
71
  */
60
72
  export declare function cargoClosureInputs(projectRoot: string, sources: readonly CargoClosureSource[]): Promise<Input[]>;
61
73
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"cargo-closure-input.d.ts","sourceRoot":"","sources":["../src/cargo-closure-input.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,kBAAkB,EAKxB,MAAM,wBAAwB,CAAC;AAIhC;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAElD,KAAK,KAAK,GAAG,WAAW,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,mFAAmF;AACnF,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B,YAAY,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAS9C;CACF;AAgBD;;;GAGG;AACH,MAAM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