@smoothbricks/nx-plugin 0.7.17 → 0.7.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/README.md +315 -114
  2. package/dist/.build-inputs.json +47 -38
  3. package/dist/built-output-packages.js +1 -1
  4. package/dist/bun-lock-scope.d.ts +128 -20
  5. package/dist/bun-lock-scope.d.ts.map +1 -1
  6. package/dist/bun-lock-scope.js +267 -44
  7. package/dist/cargo-closure-input.d.ts +8 -6
  8. package/dist/cargo-closure-input.d.ts.map +1 -1
  9. package/dist/cargo-closure-input.js +15 -12
  10. package/dist/cargo-source-hash.d.ts +26 -25
  11. package/dist/cargo-source-hash.d.ts.map +1 -1
  12. package/dist/cargo-source-hash.js +84 -105
  13. package/dist/cargo-toolchain-paths.d.ts +2 -2
  14. package/dist/cargo-toolchain-paths.js +2 -2
  15. package/dist/cargo-workspace.d.ts +20 -2
  16. package/dist/cargo-workspace.d.ts.map +1 -1
  17. package/dist/cargo-workspace.js +43 -22
  18. package/dist/ensure-built-receipt.d.ts +3 -2
  19. package/dist/ensure-built-receipt.d.ts.map +1 -1
  20. package/dist/ensure-built-receipt.js +3 -2
  21. package/dist/eslint-config-closure.d.ts +8 -3
  22. package/dist/eslint-config-closure.d.ts.map +1 -1
  23. package/dist/eslint-config-closure.js +24 -5
  24. package/dist/executors/bounded-exec/admission-queue.d.ts +3 -1
  25. package/dist/executors/bounded-exec/admission-queue.d.ts.map +1 -1
  26. package/dist/executors/bounded-exec/admission-queue.js +9 -10
  27. package/dist/executors/bounded-exec/awake-clock.d.ts +5 -0
  28. package/dist/executors/bounded-exec/awake-clock.d.ts.map +1 -0
  29. package/dist/executors/bounded-exec/awake-clock.js +22 -0
  30. package/dist/executors/bounded-exec/bounds.d.ts +19 -6
  31. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
  32. package/dist/executors/bounded-exec/bounds.js +22 -15
  33. package/dist/executors/bounded-exec/case-gate.d.ts +114 -0
  34. package/dist/executors/bounded-exec/case-gate.d.ts.map +1 -0
  35. package/dist/executors/bounded-exec/case-gate.js +342 -0
  36. package/dist/executors/bounded-exec/cpu-pool-thread.d.ts +1 -0
  37. package/dist/executors/bounded-exec/cpu-pool-thread.d.ts.map +1 -1
  38. package/dist/executors/bounded-exec/cpu-pool-thread.js +2 -2
  39. package/dist/executors/bounded-exec/cpu-pool.d.ts +28 -1
  40. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  41. package/dist/executors/bounded-exec/cpu-pool.js +102 -16
  42. package/dist/executors/bounded-exec/cpu-rise.d.ts +73 -0
  43. package/dist/executors/bounded-exec/cpu-rise.d.ts.map +1 -0
  44. package/dist/executors/bounded-exec/cpu-rise.js +111 -0
  45. package/dist/executors/bounded-exec/endpoint-life.d.ts +146 -0
  46. package/dist/executors/bounded-exec/endpoint-life.d.ts.map +1 -0
  47. package/dist/executors/bounded-exec/endpoint-life.js +228 -0
  48. package/dist/executors/bounded-exec/executor.d.ts +1 -1
  49. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  50. package/dist/executors/bounded-exec/executor.js +256 -86
  51. package/dist/executors/bounded-exec/gateway-lease.d.ts +1 -1
  52. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
  53. package/dist/executors/bounded-exec/gateway-lease.js +8 -1
  54. package/dist/executors/bounded-exec/go-run-summary.d.ts +51 -0
  55. package/dist/executors/bounded-exec/go-run-summary.d.ts.map +1 -0
  56. package/dist/executors/bounded-exec/go-run-summary.js +98 -0
  57. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +11 -3
  58. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  59. package/dist/executors/bounded-exec/hang-diagnostics.js +125 -47
  60. package/dist/executors/bounded-exec/lease-wait.d.ts +1 -0
  61. package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -1
  62. package/dist/executors/bounded-exec/lease-wait.js +1 -0
  63. package/dist/executors/bounded-exec/mbx-pool.d.ts +42 -7
  64. package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
  65. package/dist/executors/bounded-exec/mbx-pool.js +45 -8
  66. package/dist/executors/bounded-exec/mbx-reservations.d.ts +12 -6
  67. package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -1
  68. package/dist/executors/bounded-exec/mbx-reservations.js +190 -284
  69. package/dist/executors/bounded-exec/parent-grant.d.ts +2 -0
  70. package/dist/executors/bounded-exec/parent-grant.d.ts.map +1 -1
  71. package/dist/executors/bounded-exec/parent-grant.js +1 -0
  72. package/dist/executors/bounded-exec/pool-admission.d.ts +29 -3
  73. package/dist/executors/bounded-exec/pool-admission.d.ts.map +1 -1
  74. package/dist/executors/bounded-exec/pool-admission.js +47 -1
  75. package/dist/executors/bounded-exec/progress-channel.d.ts +38 -0
  76. package/dist/executors/bounded-exec/progress-channel.d.ts.map +1 -0
  77. package/dist/executors/bounded-exec/progress-channel.js +113 -0
  78. package/dist/executors/bounded-exec/progress.d.ts +5 -1
  79. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  80. package/dist/executors/bounded-exec/progress.js +31 -1
  81. package/dist/executors/bounded-exec/ram-temp.d.ts +24 -1
  82. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  83. package/dist/executors/bounded-exec/ram-temp.js +123 -16
  84. package/dist/executors/bounded-exec/reservation-connection.d.ts +90 -0
  85. package/dist/executors/bounded-exec/reservation-connection.d.ts.map +1 -0
  86. package/dist/executors/bounded-exec/reservation-connection.js +248 -0
  87. package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
  88. package/dist/executors/bounded-exec/run-cpu-pool.js +3 -0
  89. package/dist/executors/bounded-exec/runner-sizing.d.ts +9 -5
  90. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
  91. package/dist/executors/bounded-exec/runner-sizing.js +13 -9
  92. package/dist/executors/bounded-exec/schema.d.ts +7 -2
  93. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  94. package/dist/executors/bounded-exec/schema.js +17 -1
  95. package/dist/executors/bounded-exec/suite-minimum.d.ts +21 -0
  96. package/dist/executors/bounded-exec/suite-minimum.d.ts.map +1 -0
  97. package/dist/executors/bounded-exec/suite-minimum.js +85 -0
  98. package/dist/executors/bounded-exec/test-result-writer.d.ts +2 -0
  99. package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -1
  100. package/dist/executors/bounded-exec/test-result-writer.js +1 -0
  101. package/dist/executors/bounded-exec/test-results.d.ts +5 -0
  102. package/dist/executors/bounded-exec/test-results.d.ts.map +1 -1
  103. package/dist/executors/bounded-exec/test-results.js +2 -2
  104. package/dist/executors/bounded-exec/verdict.d.ts +39 -10
  105. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  106. package/dist/executors/bounded-exec/verdict.js +60 -14
  107. package/dist/executors/cargo-zigbuild/executor.d.ts +10 -8
  108. package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
  109. package/dist/executors/cargo-zigbuild/executor.js +32 -19
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +294 -152
  112. package/dist/managed-files/ci-workflow.d.ts +4 -1
  113. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  114. package/dist/managed-files/ci-workflow.js +9 -14
  115. package/dist/managed-files/files.d.ts +3 -3
  116. package/dist/managed-files/files.js +3 -3
  117. package/dist/managed-files/generator.d.ts +5 -1
  118. package/dist/managed-files/generator.d.ts.map +1 -1
  119. package/dist/managed-files/generator.js +22 -7
  120. package/dist/managed-files/render-memo.d.ts +13 -0
  121. package/dist/managed-files/render-memo.d.ts.map +1 -0
  122. package/dist/managed-files/render-memo.js +94 -0
  123. package/dist/task-results.js +2 -1
  124. package/dist/test-program.d.ts +11 -6
  125. package/dist/test-program.d.ts.map +1 -1
  126. package/dist/test-program.js +39 -35
  127. package/dist/tool-bins.d.ts +12 -0
  128. package/dist/tool-bins.d.ts.map +1 -1
  129. package/dist/tool-bins.js +31 -6
  130. package/dist/typecheck-test-policy.d.ts +10 -1
  131. package/dist/typecheck-test-policy.d.ts.map +1 -1
  132. package/dist/typecheck-test-policy.js +40 -24
  133. package/dist/workspace-config-policy.d.ts.map +1 -1
  134. package/dist/workspace-config-policy.js +135 -42
  135. package/dist/workspace-index.d.ts +14 -1
  136. package/dist/workspace-index.d.ts.map +1 -1
  137. package/dist/workspace-index.js +36 -4
  138. package/executors.json +2 -0
  139. package/managed/raw/envrc +24 -0
  140. package/managed/raw/patches/nx@24.0.3.patch +1851 -221
  141. package/managed/raw/patches/ttsc@0.37.1.patch +1055 -0
  142. package/managed/raw/tooling/direnv/developer-links.ts +122 -14
  143. package/managed/raw/tooling/direnv/devenv.smoo.nix +20 -19
  144. package/managed/templates/github/actions/save-nix-devenv/action.yml +19 -1
  145. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  146. package/package.json +68 -11
  147. package/runtime/nx-publish/.build-inputs.json +2 -2
  148. package/runtime/nx-publish/cache_adapter.js +293 -3
  149. package/runtime/nx-publish/nx_publish.js +36 -14
  150. package/src/built-output-packages.ts +1 -1
  151. package/src/bun-lock-scope.ts +293 -40
  152. package/src/cargo-closure-input.ts +20 -12
  153. package/src/cargo-source-hash.ts +119 -145
  154. package/src/cargo-toolchain-paths.ts +2 -2
  155. package/src/cargo-workspace.ts +59 -21
  156. package/src/ensure-built-receipt.ts +3 -2
  157. package/src/eslint-config-closure.ts +27 -6
  158. package/src/executors/bounded-exec/admission-queue.ts +11 -10
  159. package/src/executors/bounded-exec/awake-clock.ts +20 -0
  160. package/src/executors/bounded-exec/bounds.ts +41 -19
  161. package/src/executors/bounded-exec/case-gate.ts +365 -0
  162. package/src/executors/bounded-exec/cpu-pool-thread.ts +3 -3
  163. package/src/executors/bounded-exec/cpu-pool.ts +139 -12
  164. package/src/executors/bounded-exec/cpu-rise.ts +156 -0
  165. package/src/executors/bounded-exec/endpoint-life.ts +279 -0
  166. package/src/executors/bounded-exec/executor.ts +341 -123
  167. package/src/executors/bounded-exec/gateway-lease.ts +6 -0
  168. package/src/executors/bounded-exec/go-run-summary.ts +137 -0
  169. package/src/executors/bounded-exec/hang-diagnostics.ts +150 -50
  170. package/src/executors/bounded-exec/lease-wait.ts +1 -0
  171. package/src/executors/bounded-exec/mbx-pool.ts +57 -9
  172. package/src/executors/bounded-exec/mbx-reservations.ts +216 -183
  173. package/src/executors/bounded-exec/parent-grant.ts +3 -0
  174. package/src/executors/bounded-exec/pool-admission.ts +59 -2
  175. package/src/executors/bounded-exec/progress-channel.ts +129 -0
  176. package/src/executors/bounded-exec/progress.ts +39 -3
  177. package/src/executors/bounded-exec/ram-temp.ts +137 -17
  178. package/src/executors/bounded-exec/reservation-connection.ts +221 -0
  179. package/src/executors/bounded-exec/run-cpu-pool.ts +2 -0
  180. package/src/executors/bounded-exec/runner-sizing.ts +13 -8
  181. package/src/executors/bounded-exec/schema.json +1 -1
  182. package/src/executors/bounded-exec/schema.ts +21 -2
  183. package/src/executors/bounded-exec/suite-minimum.ts +81 -0
  184. package/src/executors/bounded-exec/test-result-writer.ts +3 -0
  185. package/src/executors/bounded-exec/test-results.ts +5 -0
  186. package/src/executors/bounded-exec/verdict.ts +83 -22
  187. package/src/executors/cargo-zigbuild/executor.ts +30 -19
  188. package/src/index.ts +357 -166
  189. package/src/managed-files/ci-workflow.ts +13 -17
  190. package/src/managed-files/files.ts +3 -3
  191. package/src/managed-files/generator.ts +21 -6
  192. package/src/managed-files/render-memo.ts +135 -0
  193. package/src/test-program.ts +36 -41
  194. package/src/tool-bins.ts +35 -6
  195. package/src/typecheck-test-policy.ts +49 -24
  196. package/src/workspace-config-policy.ts +161 -43
  197. package/src/workspace-index.ts +40 -5
  198. package/test-timings.json +157 -141
  199. package/managed/raw/patches/ttsc@0.36.3.patch +0 -1660
@@ -5,74 +5,16 @@ import { accessSync, constants, existsSync, readdirSync, readFileSync, realpathS
5
5
  import { lstat, mkdir, readdir, readFile, readlink, realpath, rename, rm, stat, writeFile } from 'node:fs/promises';
6
6
  import { createRequire } from 'node:module';
7
7
  import { homedir } from 'node:os';
8
- import { delimiter, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
8
+ import { basename, delimiter, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
9
+ import { buildClosure, cargoEdges, localPackagesUnder, parseCargoMetadata, pinnedPackages, } from '@smoothbricks/build-inputs/cargo-closure';
9
10
  import { CARGO_ANCESTOR_INPUTS } from '@smoothbricks/cargo-retain/cargo-ancestor-inputs';
10
11
  import native from 'nx/src/native/index.js';
11
12
  import { workspaceDataDirectoryForWorkspace } from 'nx/src/utils/cache-directory.js';
12
13
  import { CARGO_TOOLCHAIN_PIN_INPUTS } from './cargo-toolchain-policy.js';
13
14
  import { describeTeardown, killProcessGroupNow, TEARDOWN_PATIENCE } from './process-group.js';
14
15
  import { rustTokens } from './rust-tokens.js';
15
- const { IS_WASM, WorkspaceContext } = native;
16
+ const { IS_WASM, WorkspaceContext, hashArray } = native;
16
17
  const cargoResolveEvents = channel('@smoothbricks/nx-plugin:cargo-resolve');
17
- /**
18
- * Narrowed field by field, not by typia: graph inference imports this module,
19
- * and a workspace that loads the plugin from its sources runs them without
20
- * typia's compile-time transform.
21
- */
22
- function parseCargoMetadata(json) {
23
- const member = (value, key) => typeof value === 'object' && value !== null && key in value ? Reflect.get(value, key) : undefined;
24
- const text = (value, field) => {
25
- if (typeof value !== 'string')
26
- throw new Error(`cargo metadata reported no valid ${field}`);
27
- return value;
28
- };
29
- const list = (value, field) => {
30
- if (!Array.isArray(value))
31
- throw new Error(`cargo metadata reported no valid ${field}`);
32
- return value;
33
- };
34
- const document = JSON.parse(json);
35
- const resolveGraph = member(document, 'resolve');
36
- return {
37
- packages: list(member(document, 'packages'), 'packages').map((pkg) => ({
38
- id: text(member(pkg, 'id'), 'package id'),
39
- name: text(member(pkg, 'name'), 'package name'),
40
- version: text(member(pkg, 'version'), 'package version'),
41
- source: member(pkg, 'source') === null ? null : text(member(pkg, 'source'), 'package source'),
42
- manifest_path: text(member(pkg, 'manifest_path'), 'package manifest_path'),
43
- targets: list(member(pkg, 'targets'), 'package targets').map((target) => ({
44
- src_path: text(member(target, 'src_path'), 'target src_path'),
45
- })),
46
- ...(member(pkg, 'governing_manifest_path') === undefined
47
- ? {}
48
- : { governing_manifest_path: text(member(pkg, 'governing_manifest_path'), 'governing manifest') }),
49
- })),
50
- resolve: resolveGraph === null
51
- ? null
52
- : {
53
- nodes: list(member(resolveGraph, 'nodes'), 'resolve').map((node) => ({
54
- id: text(member(node, 'id'), 'resolve node id'),
55
- deps: list(member(node, 'deps'), 'resolve node deps').map((dependency) => ({
56
- pkg: text(member(dependency, 'pkg'), 'resolve edge'),
57
- dep_kinds: dependencyKinds(member(dependency, 'dep_kinds')),
58
- })),
59
- })),
60
- },
61
- workspace_members: list(member(document, 'workspace_members'), 'workspace_members').map((id) => text(id, 'workspace member')),
62
- workspace_root: text(member(document, 'workspace_root'), 'workspace_root'),
63
- };
64
- }
65
- /** A resolve edge's `dep_kinds`. An edge Cargo reports with no kind is refused: read as dev-only, it would drop a dependency. */
66
- function dependencyKinds(value) {
67
- if (!Array.isArray(value) || value.length === 0)
68
- throw new Error('cargo metadata reported no valid resolve edge kinds');
69
- return value.map((entry) => {
70
- const kind = typeof entry === 'object' && entry !== null ? Reflect.get(entry, 'kind') : undefined;
71
- if (kind !== null && kind !== 'dev' && kind !== 'build')
72
- throw new Error('cargo metadata reported no valid resolve edge kind');
73
- return { kind };
74
- });
75
- }
76
18
  /**
77
19
  * Nx workers handle termination by exiting, so their exit hook kills owned
78
20
  * Cargo groups. Standalone callers need signal forwarding after detaching
@@ -418,13 +360,8 @@ function cargoFromMetadata(metadata) {
418
360
  governingManifest: pkg.governing_manifest_path,
419
361
  };
420
362
  }),
421
- locked: new Map(metadata.packages.flatMap((pkg) => (pkg.source === null ? [] : [[pkg.id, pkg.source]]))),
422
- edges: metadata.resolve === null
423
- ? null
424
- : new Map(metadata.resolve.nodes.map((node) => [
425
- node.id,
426
- node.deps.map((dep) => ({ pkg: dep.pkg, devOnly: dep.dep_kinds.every(({ kind }) => kind === 'dev') })),
427
- ])),
363
+ pinned: pinnedPackages(metadata),
364
+ edges: cargoEdges(metadata),
428
365
  };
429
366
  }
430
367
  async function loadResolveCache(file) {
@@ -867,7 +804,7 @@ export async function hashCargoPathInputs(manifestPath, workspaceRoot, options)
867
804
  const scan = scans.get(input.file);
868
805
  if (scan !== undefined) {
869
806
  scans.delete(input.file);
870
- collectCompiledInputs(input.file, bytes.toString('utf8'), scan.found);
807
+ collectCompiledInputs(input.file, includeSpellings(bytes.toString('utf8')), scan.found);
871
808
  }
872
809
  hash.update(input.key);
873
810
  hash.update('\0');
@@ -890,7 +827,7 @@ export async function hashCargoPathInputs(manifestPath, workspaceRoot, options)
890
827
  continue;
891
828
  // Discovery also visits ignored sources. They have no scheduled identity;
892
829
  // if an include alias later names one, preserve the old read-then-hash path.
893
- collectCompiledInputs(source, readFileSync(source, 'utf8'), scan.found);
830
+ collectCompiledInputs(source, includeSpellings(readFileSync(source, 'utf8')), scan.found);
894
831
  }
895
832
  for (const input of [...scan.found.values()].sort((left, right) => left.file < right.file ? -1 : left.file > right.file ? 1 : 0)) {
896
833
  if (ignored(input.file))
@@ -916,35 +853,11 @@ export async function hashCargoPathInputs(manifestPath, workspaceRoot, options)
916
853
  */
917
854
  export async function dependencyClosure(cargo, directory) {
918
855
  const base = await realpath(directory);
919
- const selected = cargo.local
920
- .filter((pkg) => pkg.directory === base || pkg.directory.startsWith(`${base}${sep}`))
921
- .map((pkg) => pkg.id);
856
+ const selected = localPackagesUnder(cargo.local, base).map((pkg) => pkg.id);
922
857
  if (selected.length === 0)
923
858
  throw new Error(`no local Cargo package lies under ${directory}`);
924
859
  return buildClosure(cargo, selected);
925
860
  }
926
- /**
927
- * The packages Cargo compiles to build, test or run the `selected` ones, each with the dependencies Cargo builds for
928
- * it. A selected package's targets reach every dependency kind: its library and binaries the normal ones, its build
929
- * script the build ones, its tests, examples and benches the dev ones. Below the selection Cargo builds a package for
930
- * its library and build script alone, so a dependency's own dev-dependencies never compile into a selected package's
931
- * binaries and are not part of what it builds.
932
- */
933
- export function buildClosure(cargo, selected) {
934
- if (cargo.edges === null)
935
- throw new Error('cargo metadata reported no dependency resolution');
936
- const roots = new Set(selected);
937
- const reached = new Map();
938
- const pending = [...selected];
939
- for (let id = pending.pop(); id !== undefined; id = pending.pop()) {
940
- if (reached.has(id))
941
- continue;
942
- const built = (cargo.edges.get(id) ?? []).filter((edge) => roots.has(id) || !edge.devOnly).map((edge) => edge.pkg);
943
- reached.set(id, built);
944
- pending.push(...built);
945
- }
946
- return reached;
947
- }
948
861
  /**
949
862
  * Whether git ignores a path beneath one of the package directories. A
950
863
  * package whose own directory is ignored (an installed dependency, say) keeps
@@ -1065,9 +978,13 @@ function* compiledSourceFiles(root) {
1065
978
  }
1066
979
  }
1067
980
  }
1068
- function collectCompiledInputs(source, text, found) {
981
+ /** What a source with no include spells. */
982
+ const NO_SPELLINGS = [];
983
+ /** The paths a Rust source's text spells as literal include_str!/include_bytes! arguments. */
984
+ function includeSpellings(text) {
1069
985
  if (!text.includes('include_'))
1070
- return;
986
+ return NO_SPELLINGS;
987
+ const spellings = [];
1071
988
  const tokens = rustTokens(text);
1072
989
  for (let index = 0; index < tokens.length; index += 1) {
1073
990
  if (tokens[index]?.text !== 'include_str' && tokens[index]?.text !== 'include_bytes')
@@ -1082,8 +999,14 @@ function collectCompiledInputs(source, text, found) {
1082
999
  // must reference path-sized storage, not a view into the decoded source.
1083
1000
  const literal = Buffer.from(tokens[index + 3]?.text ?? '', 'utf8').toString('utf8');
1084
1001
  const path = INCLUDE_STRING.exec(literal)?.[1] ?? INCLUDE_RAW_STRING.exec(literal)?.[2];
1085
- if (path === undefined || path === '')
1086
- continue;
1002
+ if (path !== undefined && path !== '')
1003
+ spellings.push(path);
1004
+ }
1005
+ return spellings;
1006
+ }
1007
+ /** Records each existing file `source` spells, keeping the smallest declaring source and spelling per file. */
1008
+ function collectCompiledInputs(source, spellings, found) {
1009
+ for (const path of spellings) {
1087
1010
  const file = resolve(dirname(source), path);
1088
1011
  if (statSync(file, { throwIfNoEntry: false })?.isFile()) {
1089
1012
  const prior = found.get(file);
@@ -1093,18 +1016,74 @@ function collectCompiledInputs(source, text, found) {
1093
1016
  }
1094
1017
  }
1095
1018
  }
1019
+ /** {@link CargoSourceIndex} of Nx's file data (workspace-relative paths and content hashes) under the canonical `root`. */
1020
+ export function cargoSourceIndex(root, files) {
1021
+ const manifests = new Set();
1022
+ const packageDirectories = new Set();
1023
+ const rustSources = new Map();
1024
+ for (const { file, hash } of files) {
1025
+ if (file === 'Cargo.toml' || file.endsWith('/Cargo.toml')) {
1026
+ manifests.add(file);
1027
+ packageDirectories.add(dirname(join(root, file)));
1028
+ }
1029
+ else if (file.endsWith('.rs')) {
1030
+ rustSources.set(join(root, file), hash);
1031
+ }
1032
+ }
1033
+ return { manifests, packageDirectories, rustSources };
1034
+ }
1096
1035
  /**
1097
- * Existing literal include_str!/include_bytes! files read by this package's Rust sources.
1098
- * One graph owns the memo; runtime hashing consumes the same discovery alongside source
1099
- * bytes. Nested packages own their sources separately. Computed paths remain explicit inputs.
1036
+ * The include spellings of every Rust source text scanned, by Nx's content hash of that text: a source whose hash is
1037
+ * unchanged is not read again. An entry is kept only when the text read hashes to that hash, so a write Nx's index has
1038
+ * not seen yet is scanned but never remembered under the hash of the bytes it replaced. Entries leave when no index
1039
+ * holds their hash any longer ({@link retainIncludeScans}); nothing expires by time.
1100
1040
  */
1101
- export function compiledInFiles(root, cache) {
1041
+ const includeScans = new Map();
1042
+ /** Forgets the scan of every source text `index` no longer holds. */
1043
+ export function retainIncludeScans(index) {
1044
+ const held = new Set(index.rustSources.values());
1045
+ for (const hash of includeScans.keys())
1046
+ if (!held.has(hash))
1047
+ includeScans.delete(hash);
1048
+ }
1049
+ function includeSpellingsOf(source, hash) {
1050
+ const known = includeScans.get(hash);
1051
+ if (known !== undefined)
1052
+ return known;
1053
+ const text = readFileSync(source, 'utf8');
1054
+ const spellings = includeSpellings(text);
1055
+ if (hashArray([text]) === hash)
1056
+ includeScans.set(hash, spellings);
1057
+ return spellings;
1058
+ }
1059
+ const SCAN_SKIPPED = new Set(HASH_SKIPPED_DIRECTORIES);
1060
+ /** The indexed Rust sources of the package at `root`, with their hashes: none beneath a nested package or a skipped directory. */
1061
+ function* packageRustSources(root, index) {
1062
+ const prefix = `${root}${sep}`;
1063
+ sources: for (const [source, hash] of index.rustSources) {
1064
+ if (!source.startsWith(prefix))
1065
+ continue;
1066
+ for (let directory = dirname(source); directory !== root; directory = dirname(directory)) {
1067
+ if (index.packageDirectories.has(directory) || SCAN_SKIPPED.has(basename(directory)))
1068
+ continue sources;
1069
+ }
1070
+ yield [source, hash];
1071
+ }
1072
+ }
1073
+ /**
1074
+ * Existing literal include_str!/include_bytes! files read by this package's Rust sources, as Nx's file index holds
1075
+ * them: a generated (ignored) source is its producer's output and keys a consumer through its dependency outputs.
1076
+ * One graph owns the memo; runtime hashing consumes the same discovery alongside source bytes. Nested packages own
1077
+ * their sources separately. Computed paths remain explicit inputs.
1078
+ */
1079
+ export function compiledInFiles(root, index, cache) {
1102
1080
  const cached = cache.get(root);
1103
1081
  if (cached !== undefined)
1104
1082
  return cached;
1105
1083
  const found = new Map();
1106
- for (const source of compiledSourceFiles(root))
1107
- collectCompiledInputs(source, readFileSync(source, 'utf8'), found);
1084
+ for (const [source, hash] of packageRustSources(root, index)) {
1085
+ collectCompiledInputs(source, includeSpellingsOf(source, hash), found);
1086
+ }
1108
1087
  const files = [...found.values()].sort((left, right) => left.file < right.file ? -1 : left.file > right.file ? 1 : 0);
1109
1088
  cache.set(root, files);
1110
1089
  return files;
@@ -16,8 +16,8 @@
16
16
  * wrapper's object, and one entry covers all three.
17
17
  *
18
18
  * rustc and cargo are not here on purpose. Cargo keys units on the output of `rustc -vV`, never on rustc's path, and the
19
- * version recipe beside this one hashes it. On a non-Linux host the default shell and its linux-cross profile carry
20
- * different rust-std targets, so a rustc path would split one target's key between the two shells.
19
+ * version recipe beside this one hashes it. Shells of one host may carry different rust-std targets, so a rustc path
20
+ * would split one target's key between them.
21
21
  *
22
22
  * Only a path in the Nix store counts. A store object is named by the hash of everything it was built from, so one
23
23
  * shell gives one object on every machine of a platform. A path elsewhere belongs to the machine and takes no part.
@@ -18,8 +18,8 @@ import { delimiter, join } from 'node:path';
18
18
  * wrapper's object, and one entry covers all three.
19
19
  *
20
20
  * rustc and cargo are not here on purpose. Cargo keys units on the output of `rustc -vV`, never on rustc's path, and the
21
- * version recipe beside this one hashes it. On a non-Linux host the default shell and its linux-cross profile carry
22
- * different rust-std targets, so a rustc path would split one target's key between the two shells.
21
+ * version recipe beside this one hashes it. Shells of one host may carry different rust-std targets, so a rustc path
22
+ * would split one target's key between them.
23
23
  *
24
24
  * Only a path in the Nix store counts. A store object is named by the hash of everything it was built from, so one
25
25
  * shell gives one object on every machine of a platform. A path elsewhere belongs to the machine and takes no part.
@@ -1,5 +1,5 @@
1
1
  import { type TomlTable } from 'smol-toml';
2
- import { type CargoResolve, type CompiledCargoInput } from './cargo-source-hash.js';
2
+ import { type CargoResolve, type CargoSourceIndex, type CompiledCargoInput } from './cargo-source-hash.js';
3
3
  export interface CargoWorkspacePackage {
4
4
  name: string;
5
5
  dir: string;
@@ -40,6 +40,8 @@ export interface CargoPackageTestInputsOptions {
40
40
  memberDir: string;
41
41
  /** Cargo's locked resolve of that workspace, which decides the crates the member's tests build. */
42
42
  cargo: CargoResolve;
43
+ /** Nx's indexed Cargo sources, where the crates' Rust sources and nested packages are found. */
44
+ sources: CargoSourceIndex;
43
45
  /** Shared across every call of one graph computation; see {@link createCargoInputsCache}. */
44
46
  cache?: CargoInputsCache;
45
47
  }
@@ -50,7 +52,9 @@ export interface CargoPackageTestInputsOptions {
50
52
  * three targets over ~45 crates that was ~135 derivations and the dominant
51
53
  * cost of loading the graph. The cache lives exactly as long as one
52
54
  * `createNodes` call — Nx recomputes the graph when a manifest changes, so
53
- * nothing here can go stale across runs.
55
+ * nothing here can go stale across runs. What outlives the call is keyed by
56
+ * content, not by time: a Rust source's include scan by Nx's hash of it
57
+ * (`compiledInFiles`), so a recomputation reads only the sources that changed.
54
58
  */
55
59
  export interface CargoInputsCache {
56
60
  readonly manifests: Map<string, Promise<TomlTable>>;
@@ -59,6 +63,20 @@ export interface CargoInputsCache {
59
63
  readonly results: Map<string, Promise<string[]>>;
60
64
  }
61
65
  export declare function createCargoInputsCache(): CargoInputsCache;
66
+ /** A producer output a Cargo target hashes: the files one producer edge writes under one closure file set. */
67
+ export interface CargoProducerOutputInput {
68
+ readonly dependentTasksOutputFiles: string;
69
+ readonly transitive: false;
70
+ }
71
+ /**
72
+ * The outputs of a Cargo target's producers its compile can read: one `dependentTasksOutputFiles` per file set of its
73
+ * closure (`cargoPackageTestInputs`, or the generic fallback rooted at `projectRoot`). A producer that writes a
74
+ * generated crate source, a compiled-in file or a manifest keys the target; one that writes anywhere else, such as a
75
+ * TypeScript package's `dist`, does not. Nx matches the glob against each output file's workspace-relative path (the
76
+ * same `matchGlobPaths` its `--check` uses), so the `{workspaceRoot}/` anchor is dropped. An exclusion or a named input
77
+ * has no output form, and a producer writes into no build directory the exclusions name.
78
+ */
79
+ export declare function cargoProducerOutputInputs(inputs: readonly (string | object)[], projectRoot: string): CargoProducerOutputInput[];
62
80
  export declare function cargoPackageTestInputs(options: CargoPackageTestInputsOptions): Promise<string[]>;
63
81
  /**
64
82
  * Refuses inputs outside the Nx workspace that `nx.json` gives no `externalRustCrates` runtime hash for: no fileset
@@ -1 +1 @@
1
- {"version":3,"file":"cargo-workspace.d.ts","sourceRoot":"","sources":["../src/cargo-workspace.ts"],"names":[],"mappings":"AAIA,OAAO,EAAsB,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAE/D,OAAO,EAAgB,KAAK,YAAY,EAAE,KAAK,kBAAkB,EAAmB,MAAM,wBAAwB,CAAC;AAEnH,MAAM,WAAW,qBAAqB;IACpC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hF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAmB9E;AAQD;;;GAGG;AACH,eAAO,MAAM,0BAA0B,6BAA2B,CAAC;AAEnE;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACnE;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;CAAE,CAAC;AAEnC;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,oFAAoF;IACpF,MAAM,EAAE,MAAM,CAAC;IACf,qGAAqG;IACrG,KAAK,EAAE,oBAAoB,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAAC,iBAAiB,EAAE,MAAM,GAAG,eAAe,EAAE,CAuC7E;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CAMhE;AAmKD,iFAAiF;AACjF,eAAO,MAAM,0BAA0B,sDAAsD,CAAC;AAE9F;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED,+EAA+E;AAC/E,eAAO,MAAM,wBAAwB,yBAAyB,CAAC"}
@@ -1,9 +1,10 @@
1
1
  import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
2
  import { readFile, realpath } from 'node:fs/promises';
3
- import { dirname, isAbsolute, join, posix, relative, resolve, sep } from 'node:path';
3
+ import { basename, dirname, isAbsolute, join, posix, relative, resolve, sep } from 'node:path';
4
+ import { buildClosure } from '@smoothbricks/build-inputs/cargo-closure';
4
5
  import { readNxJson } from 'nx/src/config/nx-json.js';
5
6
  import { parse as parseToml } from 'smol-toml';
6
- import { buildClosure, compiledInFiles } from './cargo-source-hash.js';
7
+ import { compiledInFiles, } from './cargo-source-hash.js';
7
8
  export function listCargoWorkspacePackages(absoluteProjectRoot) {
8
9
  const workspaceTomlPath = join(absoluteProjectRoot, 'Cargo.toml');
9
10
  if (!existsSync(workspaceTomlPath)) {
@@ -173,6 +174,26 @@ export const EXTERNAL_RUST_CRATES_INPUT = 'externalRustCrates';
173
174
  export function createCargoInputsCache() {
174
175
  return { manifests: new Map(), nestedCrateDirs: new Map(), compiledInFiles: new Map(), results: new Map() };
175
176
  }
177
+ /**
178
+ * The outputs of a Cargo target's producers its compile can read: one `dependentTasksOutputFiles` per file set of its
179
+ * closure (`cargoPackageTestInputs`, or the generic fallback rooted at `projectRoot`). A producer that writes a
180
+ * generated crate source, a compiled-in file or a manifest keys the target; one that writes anywhere else, such as a
181
+ * TypeScript package's `dist`, does not. Nx matches the glob against each output file's workspace-relative path (the
182
+ * same `matchGlobPaths` its `--check` uses), so the `{workspaceRoot}/` anchor is dropped. An exclusion or a named input
183
+ * has no output form, and a producer writes into no build directory the exclusions name.
184
+ */
185
+ export function cargoProducerOutputInputs(inputs, projectRoot) {
186
+ const globs = inputs.flatMap((input) => {
187
+ if (typeof input !== 'string')
188
+ return [];
189
+ if (input.startsWith('{workspaceRoot}/'))
190
+ return [input.slice('{workspaceRoot}/'.length)];
191
+ if (input.startsWith('{projectRoot}/'))
192
+ return [posix.join(projectRoot, input.slice('{projectRoot}/'.length))];
193
+ return [];
194
+ });
195
+ return [...new Set(globs)].map((glob) => ({ dependentTasksOutputFiles: glob, transitive: false }));
196
+ }
176
197
  export function cargoPackageTestInputs(options) {
177
198
  const cache = options.cache ?? createCargoInputsCache();
178
199
  const key = `${options.absoluteProjectRoot}\0${options.memberDir}`;
@@ -183,7 +204,7 @@ export function cargoPackageTestInputs(options) {
183
204
  cache.results.set(key, derived);
184
205
  return derived;
185
206
  }
186
- async function deriveCargoPackageTestInputs({ workspaceRoot, absoluteProjectRoot, memberDir, cargo }, cache) {
207
+ async function deriveCargoPackageTestInputs({ workspaceRoot, absoluteProjectRoot, memberDir, cargo, sources }, cache) {
187
208
  // Every fileset is anchored at `{workspaceRoot}`, never `{projectRoot}`: Nx
188
209
  // hashes a `{projectRoot}` glob against only the files its project OWNS, and
189
210
  // a nested Nx project owns the crates under it. A repository-root cargo
@@ -253,7 +274,7 @@ async function deriveCargoPackageTestInputs({ workspaceRoot, absoluteProjectRoot
253
274
  // Cargo packages can compile include_bytes!, headers, schemas and build.rs,
254
275
  // not only Rust sources. Nested packages are separate source owners.
255
276
  inputs.add(`${inputPath(absoluteDir)}/**/*`);
256
- for (const child of nestedCrateDirs(absoluteDir, cache)) {
277
+ for (const child of nestedCrateDirs(absoluteDir, sources, cache)) {
257
278
  const childDir = relative(cargoRoot, child).split(sep).join('/');
258
279
  if (!dirs.has(childDir))
259
280
  exclusions.add(`!${inputPath(child)}/**`);
@@ -261,7 +282,7 @@ async function deriveCargoPackageTestInputs({ workspaceRoot, absoluteProjectRoot
261
282
  // `include_str!("../../../skills/SKILL.md")` compiles a file the package's own
262
283
  // fileset does not reach; a target that does not hash it serves a binary
263
284
  // built from the file's old bytes.
264
- for (const { file } of compiledInFiles(absoluteDir, cache.compiledInFiles)) {
285
+ for (const { file } of compiledInFiles(absoluteDir, sources, cache.compiledInFiles)) {
265
286
  if (isOutsideRoot(relative(absoluteDir, file)))
266
287
  declaredSources.add(file);
267
288
  }
@@ -338,30 +359,30 @@ export function requireExternalRustCratesInput(workspaceRoot, manifest, external
338
359
  'with runtime inputs that hash those external sources and configuration');
339
360
  }
340
361
  /** Every directory beneath `root` that holds its own `Cargo.toml`, the walk stopping at each. */
341
- function nestedCrateDirs(root, cache) {
362
+ /** Directories whose packages are never nested crates of a package: build output, VCS and Nx state, installed packages. */
363
+ const NESTED_CRATE_SKIPPED = new Set(['target', '.git', 'node_modules', '.nx']);
364
+ /**
365
+ * The packages nested in the package at `root`: the indexed package directories beneath it with no other package,
366
+ * and no skipped directory, in between. Read from Nx's file index, so no directory is listed and no path probed.
367
+ */
368
+ function nestedCrateDirs(root, sources, cache) {
342
369
  const cached = cache.nestedCrateDirs.get(root);
343
370
  if (cached !== undefined)
344
371
  return cached;
372
+ const prefix = `${root}${sep}`;
345
373
  const found = [];
346
- const scan = [root];
347
- while (scan.length > 0) {
348
- const current = scan.pop();
349
- if (current === undefined || !existsSync(current))
374
+ nested: for (const directory of sources.packageDirectories) {
375
+ if (!directory.startsWith(prefix))
350
376
  continue;
351
- for (const entry of readdirSync(current, { withFileTypes: true })) {
352
- if (!entry.isDirectory())
353
- continue;
354
- const child = join(current, entry.name);
355
- if (['target', '.git', 'node_modules', '.nx'].includes(entry.name)) {
356
- }
357
- else if (existsSync(join(child, 'Cargo.toml'))) {
358
- found.push(child);
359
- }
360
- else {
361
- scan.push(child);
362
- }
377
+ if (NESTED_CRATE_SKIPPED.has(basename(directory)))
378
+ continue;
379
+ for (let parent = dirname(directory); parent !== root; parent = dirname(parent)) {
380
+ if (sources.packageDirectories.has(parent) || NESTED_CRATE_SKIPPED.has(basename(parent)))
381
+ continue nested;
363
382
  }
383
+ found.push(directory);
364
384
  }
385
+ found.sort();
365
386
  cache.nestedCrateDirs.set(root, found);
366
387
  return found;
367
388
  }
@@ -28,8 +28,9 @@ export interface ProducerSourceWitness {
28
28
  readonly outputs: readonly string[];
29
29
  }
30
30
  /**
31
- * Git as receipts read it: the checkout and nothing of the operator's home. The producer hooks run in whichever process
32
- * Nx runs plugins in, a workspace's sandboxed daemon included, which adopts a host client's HOME; git with that HOME
31
+ * Git as receipts read it: the checkout and nothing of the operator's home. The producer hooks run in the process that
32
+ * runs the tasks (patches/README.md, "A run's task hooks run in its own process"), a host shell's or a sandboxed job's,
33
+ * under whatever HOME that process has; git with the operator's HOME
33
34
  * reads the operator's global configuration, the sandbox denies it, and git dies (specs/cowshed/04_sandbox.md, the
34
35
  * runtime-input contract). A receipt's tree, HEAD and tracked-file status are read under the repository's own
35
36
  * configuration alone, so a host run and a sandboxed run agree on them.
@@ -1 +1 @@
1
- {"version":3,"file":"ensure-built-receipt.d.ts","sourceRoot":"","sources":["../src/ensure-built-receipt.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE/D,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACvB,4BAA4B,EAC5B,0BAA0B,EAC1B,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,UAAU,EAIf,KAAK,WAAW,EAEhB,KAAK,WAAW,EACjB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,MAAM,eAAe,CAAC,CAAC,IACzB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GACxC;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AACpD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,GAAG,8BAA8B,CAAC;IACpE,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IACtD,QAAQ,CAAC,aAAa,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;KAAE,GAAG;QAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7G;AACD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,I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,SAAS,IAAI,EAAE,EACzB,OAAO,EAAE,SAAS,IAAI,EAAE,EACxB,MAAM,EAAE,OAAO,aAAa,EAC5B,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,GAC/B,MAAM,EAAE,CAyBV;AACD,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,KAAK,EAAE,kBAAkB,EACzB,MAAM,EAAE,OAAO,aAAa,EAC5B,MAAM,EAAE,qBAAqB,EAC7B,QAAQ,EAAE,IAAI,CAAC,0BAA0B,EAAE,cAAc,CAAC,GACzD;IAAE,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAA;CAAE,GAAG,uBAAuB,CAyFjG;AACD,2IAA2I;AAC3I,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,EAC5C,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,kBAAkB,EAAE,OAAO,GAC1B,kBAAkB,CAAC,eAAe,CAAC,CAsBrC"}
@@ -5,8 +5,9 @@ import { isAbsolute, join, relative } from 'node:path';
5
5
  import { CARGO_TOOLCHAIN_PIN_INPUTS, cargoRuntimeInput, cargoToolchainPathsInput } from './cargo-toolchain-policy.js';
6
6
  import { censusStart, directoryMembers, movedNodes, recordedStamp, } from './ensure-built-witness.js';
7
7
  /**
8
- * Git as receipts read it: the checkout and nothing of the operator's home. The producer hooks run in whichever process
9
- * Nx runs plugins in, a workspace's sandboxed daemon included, which adopts a host client's HOME; git with that HOME
8
+ * Git as receipts read it: the checkout and nothing of the operator's home. The producer hooks run in the process that
9
+ * runs the tasks (patches/README.md, "A run's task hooks run in its own process"), a host shell's or a sandboxed job's,
10
+ * under whatever HOME that process has; git with the operator's HOME
10
11
  * reads the operator's global configuration, the sandbox denies it, and git dies (specs/cowshed/04_sandbox.md, the
11
12
  * runtime-input contract). A receipt's tree, HEAD and tracked-file status are read under the repository's own
12
13
  * configuration alone, so a host run and a sandboxed run agree on them.
@@ -1,7 +1,12 @@
1
+ import { type PackageLoad } from './bun-lock-scope.js';
1
2
  /**
2
3
  * The workspace-relative files `configs` load, transitively, the configs
3
- * excluded, sorted. `indexed` is Nx's workspace file index (at least its
4
- * JavaScript, TypeScript, JSON and package.json files); a file outside it refuses.
4
+ * excluded, sorted, and the installed packages those modules load by name.
5
+ * `indexed` is Nx's workspace file index (at least its JavaScript,
6
+ * TypeScript, JSON and package.json files); a file outside it refuses.
5
7
  */
6
- export declare function eslintConfigClosure(workspaceRoot: string, configs: readonly string[], indexed: ReadonlySet<string>): string[];
8
+ export declare function eslintConfigClosure(workspaceRoot: string, configs: readonly string[], indexed: ReadonlySet<string>): {
9
+ readonly files: string[];
10
+ readonly packageLoads: PackageLoad[];
11
+ };
7
12
  //# sourceMappingURL=eslint-config-closure.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"eslint-config-closure.d.ts","sourceRoot":"","sources":["../src/eslint-config-closure.ts"],"names":[],"mappings":"AAwEA;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,GAC3B,MAAM,EAAE,CA2CV"}
1
+ {"version":3,"file":"eslint-config-closure.d.ts","sourceRoot":"","sources":["../src/eslint-config-closure.ts"],"names":[],"mappings":"AAwCA,OAAO,EAAE,KAAK,WAAW,EAAoB,MAAM,qBAAqB,CAAC;AAmCzE;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,GAC3B;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,YAAY,EAAE,WAAW,EAAE,CAAA;CAAE,CA4DpE"}
@@ -17,8 +17,10 @@ import * as _assertGuard_1 from "typia/lib/internal/_assertGuard";
17
17
  * `createRequire(module).resolve` and each `import` with
18
18
  * `import.meta.resolve(specifier, module)`.
19
19
  *
20
- * A builtin, or a package installed outside the workspace's own files, adds
21
- * nothing: `bun.lock` and the root manifest key what is installed. A package
20
+ * A builtin adds nothing. A package installed outside the workspace's own
21
+ * files is reported by name with the directory whose module loads it: the
22
+ * lint target keys it by the lock scope that declares it there
23
+ * (bun-lock-scope.ts, `bunLoadScope`). A package
22
24
  * that resolves into the workspace's own files (a workspace member linked into
23
25
  * `node_modules`) is keyed and walked like a relative module. Every loaded
24
26
  * file keys the package.json files that decide how it loads: the nearest one
@@ -36,6 +38,7 @@ import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
36
38
  import { fileURLToPath, pathToFileURL } from 'node:url';
37
39
  import ts from 'typescript';
38
40
  import typia from 'typia';
41
+ import { specifierPackage } from './bun-lock-scope.js';
39
42
  /** The options ESLint creates its jiti with; `fsCache: false` only keeps graph construction from writing a cache. */
40
43
  const JITI_OPTIONS = { moduleCache: false, fsCache: false };
41
44
  const TYPESCRIPT_CONFIG = /\.[mc]?ts$/u;
@@ -55,12 +58,14 @@ console.log(JSON.stringify(loads.map(({ kind, specifier, from }) => {
55
58
  })));`;
56
59
  /**
57
60
  * The workspace-relative files `configs` load, transitively, the configs
58
- * excluded, sorted. `indexed` is Nx's workspace file index (at least its
59
- * JavaScript, TypeScript, JSON and package.json files); a file outside it refuses.
61
+ * excluded, sorted, and the installed packages those modules load by name.
62
+ * `indexed` is Nx's workspace file index (at least its JavaScript,
63
+ * TypeScript, JSON and package.json files); a file outside it refuses.
60
64
  */
61
65
  export function eslintConfigClosure(workspaceRoot, configs, indexed) {
62
66
  const root = realpathSync(workspaceRoot);
63
67
  const keyed = new Set();
68
+ const packageLoads = new Map();
64
69
  const jiti = configs.some((config) => TYPESCRIPT_CONFIG.test(config)) ? workspaceJiti(workspaceRoot) : null;
65
70
  for (const config of configs) {
66
71
  const loader = TYPESCRIPT_CONFIG.test(config) ? jiti : null;
@@ -79,6 +84,11 @@ export function eslintConfigClosure(workspaceRoot, configs, indexed) {
79
84
  const workspacePath = relative(root, real).split(sep).join('/');
80
85
  const installed = workspacePath.split('/').includes('node_modules');
81
86
  if (workspacePath.startsWith('../') || isAbsolute(workspacePath) || installed) {
87
+ if (load.bare) {
88
+ const directory = relative(root, dirname(load.from)).split(sep).join('/') || '.';
89
+ const name = specifierPackage(load.specifier);
90
+ packageLoads.set(`${directory}\0${name}`, { directory, name });
91
+ }
82
92
  if (load.bare || installed)
83
93
  return;
84
94
  throw new Error(`${load.importer} imports '${load.specifier}', which resolves outside the workspace to ${real}`);
@@ -96,7 +106,16 @@ export function eslintConfigClosure(workspaceRoot, configs, indexed) {
96
106
  });
97
107
  }
98
108
  }
99
- return [...keyed].sort();
109
+ return {
110
+ files: [...keyed].sort(),
111
+ packageLoads: [...packageLoads.values()].sort((left, right) => left.directory === right.directory
112
+ ? left.name < right.name
113
+ ? -1
114
+ : 1
115
+ : left.directory < right.directory
116
+ ? -1
117
+ : 1),
118
+ };
100
119
  }
101
120
  /** The loads `module` performs that resolve to a file; refuses a computed load or an unresolvable specifier kind. */
102
121
  function moduleLoads(root, config, module, jiti) {
@@ -22,6 +22,8 @@ export interface ObservationHost {
22
22
  step(event: BoundEvent): void;
23
23
  /** Whether the command is running a test. */
24
24
  testing(): boolean;
25
+ /** Same sleep-excluding clock as the executor's idle bound. */
26
+ awakeNow(): number;
25
27
  readonly queueHost: QueueHost | undefined;
26
28
  }
27
29
  /** One run's view of the admission queue its leaf waits in. */
@@ -37,7 +39,7 @@ export declare class AdmissionObservation {
37
39
  * and ends nothing: the bounds decide, and an idle expiry names it.
38
40
  */
39
41
  private failure;
40
- /** When the last successful snapshot completed (`Date.now()`): credit runs to it and no further. */
42
+ /** When the last successful snapshot completed on the awake clock: credit runs to it and no further. */
41
43
  private confirmedAt;
42
44
  private readonly abort;
43
45
  private timer;
@@ -1 +1 @@
1
- {"version":3,"file":"admission-queue.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/admission-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,UAAU,EAAwC,MAAM,aAAa,CAAC;AAErG,OAAO,EAA4C,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC5F,OAAO,EAAE,KAAK,kBAAkB,EAA0B,MAAM,cAAc,CAAC;AAE/E;;;;GAIG;AAEH,8FAA8F;AAC9F,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/D,oDAAoD;AACpD,MAAM,WAAW,eAAe;IAC9B,4FAA4F;IAC5F,IAAI,IAAI,OAAO,CAAC;IAChB,6CAA6C;IAC7C,GAAG,IAAI,MAAM,GAAG,SAAS,CAAC;IAC1B,kFAAkF;IAClF,WAAW,IAAI,MAAM,CAAC,UAAU,CAAC;IACjC,0BAA0B;IAC1B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,8BAA8B;IAC9B,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9B,6CAA6C;IAC7C,OAAO,IAAI,OAAO,CAAC;IACnB,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC;CAC3C;AAED,+DAA+D;AAC/D,qBAAa,oBAAoB;IAoBnB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAnBjC,sCAAsC;IACtC,QAAQ,UAAS;IACjB,OAAO,CAAC,IAAI,CAAqB;IACjC,OAAO,CAAC,QAAQ,CAAmC;IACnD;;;;OAIG;IACH,OAAO,CAAC,OAAO,CAAuB;IACtC,oGAAoG;IACpG,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAA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