@smoothbricks/nx-plugin 0.3.11 → 0.3.13

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 (38) hide show
  1. package/README.md +23 -2
  2. package/dist/bounded-test-policy.d.ts +26 -0
  3. package/dist/bounded-test-policy.d.ts.map +1 -1
  4. package/dist/bounded-test-policy.js +194 -0
  5. package/dist/cargo-workspace.d.ts +67 -0
  6. package/dist/cargo-workspace.d.ts.map +1 -0
  7. package/dist/cargo-workspace.js +215 -0
  8. package/dist/cross-check-policy.d.ts +60 -1
  9. package/dist/cross-check-policy.d.ts.map +1 -1
  10. package/dist/cross-check-policy.js +65 -1
  11. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  12. package/dist/executors/bounded-exec/executor.js +86 -51
  13. package/dist/executors/bounded-exec/schema.d.ts +13 -0
  14. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  15. package/dist/index.d.ts +10 -5
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +455 -95
  18. package/dist/package-target-policy.d.ts +2 -1
  19. package/dist/package-target-policy.d.ts.map +1 -1
  20. package/dist/package-target-policy.js +54 -13
  21. package/dist/workspace-config-policy.js +32 -35
  22. package/nextest.toml +79 -0
  23. package/package.json +2 -1
  24. package/src/bounded-test-policy.test.ts +304 -0
  25. package/src/bounded-test-policy.ts +218 -0
  26. package/src/cargo-workspace.ts +243 -0
  27. package/src/cross-check-policy.test.ts +24 -0
  28. package/src/cross-check-policy.ts +80 -1
  29. package/src/executors/bounded-exec/executor.test.ts +147 -3
  30. package/src/executors/bounded-exec/executor.ts +103 -53
  31. package/src/executors/bounded-exec/schema.json +7 -2
  32. package/src/executors/bounded-exec/schema.ts +13 -0
  33. package/src/index.test.ts +531 -99
  34. package/src/index.ts +527 -104
  35. package/src/package-target-policy.test.ts +50 -0
  36. package/src/package-target-policy.ts +58 -9
  37. package/src/workspace-config-policy.test.ts +15 -30
  38. package/src/workspace-config-policy.ts +32 -39
@@ -27,9 +27,10 @@ export declare function checkPackageTargetPolicyTree(tree: Tree, options?: Packa
27
27
  * Returns whether anything changed.
28
28
  */
29
29
  export declare function applyPackageTargetPolicyTree(tree: Tree, options?: PackageTargetPolicyOptions): boolean;
30
- export declare function checkPackageTargets(pkg: Record<string, unknown>, packagePath: string, resolvedTargets?: ReadonlySet<string>): NxPolicyIssue[];
30
+ export declare function checkPackageTargets(pkg: Record<string, unknown>, packagePath: string, resolvedTargets?: ReadonlySet<string>, projectNames?: ReadonlySet<string>): NxPolicyIssue[];
31
31
  export declare function applyPackageTargets(pkg: Record<string, unknown>, packagePath: string, workspaceNames: ReadonlySet<string>, options?: {
32
32
  resolvedTargets?: ReadonlySet<string>;
33
+ projectNames?: ReadonlySet<string>;
33
34
  }): boolean;
34
35
  export declare function checkPackageTargetPolicy(root: string, options?: PackageTargetPolicyOptions): NxPolicyIssue[];
35
36
  export declare function applyPackageTargetPolicy(root: string, options?: PackageTargetPolicyOptions): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"package-target-policy.d.ts","sourceRoot":"","sources":["../src/package-target-policy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAyB,KAAK,IAAI,EAAc,MAAM,0BAA0B,CAAC;AAGxF,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAChG,YAAY,EAAE,aAAa,EAAE,CAAC;AAE9B,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,kBAAkB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IAC5D,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,C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hF;AA6LD,wBAAgB,UAAU,CACxB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,OAAO,EACnB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GACtB,MAAM,CAMR;AA+nBD;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,0BAA+B,GAAG,aAAa,EAAE,CAsBlH;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,0BAA+B,GAAG,OAAO,CA8B1G;AAwJD,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,WAAW,EAAE,MAAM,EACnB,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,EACrC,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GACjC,aAAa,EAAE,CAEjB;AAED,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,EACnC,OAAO,GAAE;IAAE,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAAC,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAAO,GAC1F,OAAO,CAMT;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,0BAA+B,GAAG,aAAa,EAAE,CAoBhH;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,0BAA+B,GAAG,OAAO,CA8BxG"}
@@ -146,6 +146,35 @@ function targetExistsInResolvedProject(targetName, resolvedTargets) {
146
146
  function isBuildOutputDependencyPattern(dependency) {
147
147
  return BUILD_OUTPUT_DEPENDENCIES.some((pattern) => pattern === dependency);
148
148
  }
149
+ /**
150
+ * `project:target` in dependsOn is Nx's cross-project dependency syntax. When
151
+ * the prefix names a real workspace project, the entry references that
152
+ * project's target — it is not a legacy colon-named local target, so neither
153
+ * migration nor validation may touch it.
154
+ */
155
+ function isCrossProjectTargetDependency(dependency, projectNames) {
156
+ const split = dependency.lastIndexOf(':');
157
+ return split > 0 && projectNames?.has(dependency.slice(0, split)) === true;
158
+ }
159
+ function projectNamesFromOptions(options) {
160
+ return options.resolvedTargetsByProject ? new Set(options.resolvedTargetsByProject.keys()) : undefined;
161
+ }
162
+ /**
163
+ * The resolved-target map alone can be absent (unit-scale callers), so the
164
+ * workspace's declared package project names back it up: a dependsOn prefix is
165
+ * cross-project if either source knows the name.
166
+ */
167
+ function collectWorkspaceProjectNames(root, options) {
168
+ const names = new Set(projectNamesFromOptions(options) ?? []);
169
+ for (const packageJsonPath of listWorkspacePackageJsonPaths(root)) {
170
+ const pkg = readJsonObject(packageJsonPath);
171
+ const projectName = pkg ? packageNxProjectName(pkg) : null;
172
+ if (projectName) {
173
+ names.add(projectName);
174
+ }
175
+ }
176
+ return names;
177
+ }
149
178
  function expectedTargetDependencies(targetName) {
150
179
  if (targetName === 'preview')
151
180
  return ['build'];
@@ -437,7 +466,7 @@ function directoryContainsTestFiles(path) {
437
466
  }
438
467
  return false;
439
468
  }
440
- function validateExplicitNxTargets(pkg, packagePath, resolvedProject) {
469
+ function validateExplicitNxTargets(pkg, packagePath, resolvedProject, projectNames) {
441
470
  const issues = validatePlatformTargetDependencies(packagePath, resolvedProject);
442
471
  const nx = recordProperty(pkg, 'nx');
443
472
  const targets = nx ? recordProperty(nx, 'targets') : null;
@@ -455,7 +484,7 @@ function validateExplicitNxTargets(pkg, packagePath, resolvedProject) {
455
484
  if (!isRecord(rawTarget)) {
456
485
  continue;
457
486
  }
458
- issues.push(...validateTargetDependencies(rawTarget, `${packagePath}: nx.targets.${targetName}`, resolvedProjectTargetNames(resolvedProject)));
487
+ issues.push(...validateTargetDependencies(rawTarget, `${packagePath}: nx.targets.${targetName}`, resolvedProjectTargetNames(resolvedProject), projectNames));
459
488
  }
460
489
  return issues;
461
490
  }
@@ -513,7 +542,7 @@ function validatePlatformTargetDependencies(packagePath, resolvedProject) {
513
542
  }
514
543
  return issues;
515
544
  }
516
- function validateTargetDependencies(target, label, resolvedTargets) {
545
+ function validateTargetDependencies(target, label, resolvedTargets, projectNames) {
517
546
  if (!Array.isArray(target.dependsOn)) {
518
547
  return [];
519
548
  }
@@ -522,6 +551,9 @@ function validateTargetDependencies(target, label, resolvedTargets) {
522
551
  if (typeof dependency !== 'string') {
523
552
  continue;
524
553
  }
554
+ if (isCrossProjectTargetDependency(dependency, projectNames)) {
555
+ continue;
556
+ }
525
557
  if (dependency.includes(':')) {
526
558
  issues.push({
527
559
  path: label.split(':')[0]?.trim() ?? label,
@@ -760,7 +792,9 @@ function validateTestEntrypointPresenceTree(tree, packagePath, pkg) {
760
792
  export function checkPackageTargetPolicyTree(tree, options = {}) {
761
793
  const issues = [];
762
794
  const workspaceNames = collectWorkspaceNamesTree(tree);
763
- for (const [projectName, config] of getProjects(tree)) {
795
+ const projects = getProjects(tree);
796
+ const projectNames = new Set([...(projectNamesFromOptions(options) ?? []), ...projects.keys()]);
797
+ for (const [projectName, config] of projects) {
764
798
  const pkgPath = `${config.root}/package.json`;
765
799
  if (!tree.exists(pkgPath)) {
766
800
  continue;
@@ -769,7 +803,7 @@ export function checkPackageTargetPolicyTree(tree, options = {}) {
769
803
  const packagePath = config.root;
770
804
  const resolvedProject = options.resolvedTargetsByProject?.get(projectName);
771
805
  const resolvedTargets = resolvedProjectTargetNames(resolvedProject);
772
- issues.push(...validateExplicitNxTargets(pkg, packagePath, resolvedProject));
806
+ issues.push(...validateExplicitNxTargets(pkg, packagePath, resolvedProject, projectNames));
773
807
  issues.push(...validateTestEntrypointPresenceTree(tree, packagePath, pkg));
774
808
  issues.push(...validatePackageScriptPolicy(pkg, packagePath, workspaceNames, { resolvedTargets }));
775
809
  }
@@ -783,7 +817,9 @@ export function checkPackageTargetPolicyTree(tree, options = {}) {
783
817
  export function applyPackageTargetPolicyTree(tree, options = {}) {
784
818
  let changed = false;
785
819
  const workspaceNames = collectWorkspaceNamesTree(tree);
786
- for (const [projectName, config] of getProjects(tree)) {
820
+ const projects = getProjects(tree);
821
+ const projectNames = new Set([...(projectNamesFromOptions(options) ?? []), ...projects.keys()]);
822
+ for (const [projectName, config] of projects) {
787
823
  const pkgPath = `${config.root}/package.json`;
788
824
  if (!tree.exists(pkgPath)) {
789
825
  continue;
@@ -793,7 +829,7 @@ export function applyPackageTargetPolicyTree(tree, options = {}) {
793
829
  const resolvedTargets = resolvedProjectTargetNames(resolvedProject);
794
830
  updateJson(tree, pkgPath, (pkg) => {
795
831
  let packageChanged = migratePackageColonTargets(pkg, resolvedTargets);
796
- packageChanged = rewriteColonTargetDependenciesInPackage(pkg, resolvedTargets) || packageChanged;
832
+ packageChanged = rewriteColonTargetDependenciesInPackage(pkg, resolvedTargets, projectNames) || packageChanged;
797
833
  packageChanged = removePackageColonTargets(pkg) || packageChanged;
798
834
  packageChanged = removeRedundantNoopBuildTarget(pkg, resolvedProject) || packageChanged;
799
835
  packageChanged =
@@ -821,7 +857,7 @@ function removePackageColonTargets(pkg) {
821
857
  }
822
858
  return changed;
823
859
  }
824
- function rewriteColonTargetDependenciesInPackage(pkg, resolvedTargets) {
860
+ function rewriteColonTargetDependenciesInPackage(pkg, resolvedTargets, projectNames) {
825
861
  const nx = recordProperty(pkg, 'nx');
826
862
  const targets = nx ? recordProperty(nx, 'targets') : null;
827
863
  if (!targets) {
@@ -838,6 +874,9 @@ function rewriteColonTargetDependenciesInPackage(pkg, resolvedTargets) {
838
874
  if (typeof dependency !== 'string' || !dependency.includes(':')) {
839
875
  return dependency;
840
876
  }
877
+ if (isCrossProjectTargetDependency(dependency, projectNames)) {
878
+ return dependency;
879
+ }
841
880
  const next = scriptAliases.get(dependency) ?? replacementTargetName(dependency, null, resolvedTargets);
842
881
  if (!next) {
843
882
  return dependency;
@@ -931,12 +970,12 @@ function isResolvedSelfRecursiveScript(scriptName, alias, projectName, resolvedT
931
970
  resolvedProjectTargetExecutor(resolvedTargets, scriptName) === 'nx:run-script' &&
932
971
  resolvedProjectTargetScript(resolvedTargets, scriptName) === scriptName);
933
972
  }
934
- export function checkPackageTargets(pkg, packagePath, resolvedTargets) {
935
- return [...validateExplicitNxTargets(pkg, packagePath, resolvedTargets)];
973
+ export function checkPackageTargets(pkg, packagePath, resolvedTargets, projectNames) {
974
+ return [...validateExplicitNxTargets(pkg, packagePath, resolvedTargets, projectNames)];
936
975
  }
937
976
  export function applyPackageTargets(pkg, packagePath, workspaceNames, options = {}) {
938
977
  let changed = migratePackageColonTargets(pkg, options.resolvedTargets);
939
- changed = rewriteColonTargetDependenciesInPackage(pkg, options.resolvedTargets) || changed;
978
+ changed = rewriteColonTargetDependenciesInPackage(pkg, options.resolvedTargets, options.projectNames) || changed;
940
979
  changed = removePackageColonTargets(pkg) || changed;
941
980
  changed = applyPackageScriptPolicyForPkg(pkg, packagePath, workspaceNames, options) || changed;
942
981
  return changed;
@@ -944,6 +983,7 @@ export function applyPackageTargets(pkg, packagePath, workspaceNames, options =
944
983
  export function checkPackageTargetPolicy(root, options = {}) {
945
984
  const issues = [];
946
985
  const workspaceNames = getWorkspacePackageNames(root);
986
+ const projectNames = collectWorkspaceProjectNames(root, options);
947
987
  for (const packageJsonPath of listWorkspacePackageJsonPaths(root)) {
948
988
  const pkg = readJsonObject(packageJsonPath);
949
989
  if (!pkg) {
@@ -952,7 +992,7 @@ export function checkPackageTargetPolicy(root, options = {}) {
952
992
  const packagePath = packagePathFromJsonPath(root, packageJsonPath);
953
993
  const projectName = packageNxProjectName(pkg);
954
994
  const resolvedProject = projectName ? options.resolvedTargetsByProject?.get(projectName) : undefined;
955
- issues.push(...validateExplicitNxTargets(pkg, packagePath, resolvedProject));
995
+ issues.push(...validateExplicitNxTargets(pkg, packagePath, resolvedProject, projectNames));
956
996
  issues.push(...validateTestEntrypointPresence(root, packagePath, pkg));
957
997
  issues.push(...validatePackageScriptPolicy(pkg, packagePath, workspaceNames, { resolvedTargets: resolvedProject }));
958
998
  }
@@ -961,6 +1001,7 @@ export function checkPackageTargetPolicy(root, options = {}) {
961
1001
  export function applyPackageTargetPolicy(root, options = {}) {
962
1002
  let changed = false;
963
1003
  const workspaceNames = getWorkspacePackageNames(root);
1004
+ const projectNames = collectWorkspaceProjectNames(root, options);
964
1005
  for (const packageJsonPath of listWorkspacePackageJsonPaths(root)) {
965
1006
  const pkg = readJsonObject(packageJsonPath);
966
1007
  if (!pkg) {
@@ -971,7 +1012,7 @@ export function applyPackageTargetPolicy(root, options = {}) {
971
1012
  const resolvedProject = projectName ? options.resolvedTargetsByProject?.get(projectName) : undefined;
972
1013
  const resolvedTargets = resolvedProjectTargetNames(resolvedProject);
973
1014
  let packageChanged = migratePackageColonTargets(pkg, resolvedTargets);
974
- packageChanged = rewriteColonTargetDependenciesInPackage(pkg, resolvedTargets) || packageChanged;
1015
+ packageChanged = rewriteColonTargetDependenciesInPackage(pkg, resolvedTargets, projectNames) || packageChanged;
975
1016
  packageChanged = removePackageColonTargets(pkg) || packageChanged;
976
1017
  packageChanged = removeRedundantNoopBuildTarget(pkg, resolvedProject) || packageChanged;
977
1018
  packageChanged =
@@ -156,35 +156,35 @@ function validateBuildTargetDefault(nxJson, nxJsonPath, issues) {
156
156
  if (build?.cache !== true) {
157
157
  issues.push({ path: nxJsonPath, message: 'targetDefaults.build.cache must be true' });
158
158
  }
159
- // dependsOn is owned by the inference plugin: the inferred aggregate carries
160
- // the output families PLUS this host's platform-suffixed binary targets, and
161
- // Nx gives targetDefaults precedence over inferred values — a static list
162
- // here would clobber the host-aware edge on every project.
163
- if (build !== null && 'dependsOn' in build) {
164
- issues.push({
165
- path: nxJsonPath,
166
- message: 'targetDefaults.build.dependsOn must not be set; @smoothbricks/nx-plugin infers build dependencies',
167
- });
168
- }
169
- const outputs = build?.outputs;
170
- if (!isValidBuildOutputs(outputs)) {
171
- issues.push({
172
- path: nxJsonPath,
173
- message: 'targetDefaults.build.outputs must contain "{projectRoot}/dist" and only "{projectRoot}/dist-<suffix>" siblings (e.g. "{projectRoot}/dist-node")',
174
- });
159
+ // dependsOn and outputs are both owned by the inference plugin, and Nx gives
160
+ // targetDefaults precedence over inferred values, so anything set here lands
161
+ // on every project regardless of what inference knows about that project.
162
+ //
163
+ // dependsOn: the inferred aggregate carries the output families PLUS this
164
+ // host's platform-suffixed binary targets; a static list here would clobber
165
+ // the host-aware edge.
166
+ //
167
+ // outputs: `build` is an `nx:noop` aggregate that runs no command and writes
168
+ // no file — every artifact under dist belongs to the concrete target that
169
+ // emitted it. A workspace-wide `{projectRoot}/dist` makes the aggregate claim
170
+ // its children's trees, which caches those bytes a second time under the
171
+ // aggregate's hash and, worse, makes `github-ci nx-run-many
172
+ // --collect-outputs` attribute to `build` every file that happens to sit
173
+ // under dist: artifacts of platform targets the collect deliberately
174
+ // excluded, and stale artifacts of a target that did not run at all. The
175
+ // publish workflow then applies two collected trees that both claim the same
176
+ // platform binary and `apply-outputs` rejects the overlap. A project whose
177
+ // `build` genuinely emits files declares its own outputs in package.json,
178
+ // where the claim is scoped to the project that can honour it.
179
+ for (const property of ['dependsOn', 'outputs']) {
180
+ if (build !== null && property in build) {
181
+ issues.push({
182
+ path: nxJsonPath,
183
+ message: `targetDefaults.build.${property} must not be set; @smoothbricks/nx-plugin infers the build aggregate`,
184
+ });
185
+ }
175
186
  }
176
187
  }
177
- /**
178
- * Build outputs must include the canonical dist tree; additional project-root
179
- * dist siblings (dist-node, dist-test, …) are legitimate secondary outputs a
180
- * repo may aggregate into `build` — the policy pins outputs under the project
181
- * root's dist family, not the exact array.
182
- */
183
- function isValidBuildOutputs(outputs) {
184
- return (Array.isArray(outputs) &&
185
- outputs.includes('{projectRoot}/dist') &&
186
- outputs.every((output) => typeof output === 'string' && /^\{projectRoot\}\/dist(-[\w.-]+)?$/.test(output)));
187
- }
188
188
  function validateCleanTargetDefault(nxJson, nxJsonPath, issues) {
189
189
  const targetDefaults = recordProperty(nxJson, 'targetDefaults');
190
190
  const clean = targetDefaults ? recordProperty(targetDefaults, 'clean') : null;
@@ -235,14 +235,11 @@ function applyBuildTargetDefault(nxJson) {
235
235
  const targetDefaults = getOrCreateRecord(nxJson, 'targetDefaults');
236
236
  const build = getOrCreateRecord(targetDefaults, 'build');
237
237
  let changed = setBooleanProperty(build, 'cache', true);
238
- // Reset only invalid outputs: valid extra dist siblings (dist-node, …) are a
239
- // repo decision the fixer must not clobber.
240
- if (!isValidBuildOutputs(build.outputs)) {
241
- changed = setStringArrayProperty(build, 'outputs', ['{projectRoot}/dist']) || changed;
242
- }
243
- if ('dependsOn' in build) {
244
- delete build.dependsOn;
245
- changed = true;
238
+ for (const property of ['dependsOn', 'outputs']) {
239
+ if (property in build) {
240
+ delete build[property];
241
+ changed = true;
242
+ }
246
243
  }
247
244
  return changed;
248
245
  }
package/nextest.toml ADDED
@@ -0,0 +1,79 @@
1
+ # Injected by @smoothbricks/nx-plugin as `--config-file` on inferred cargo-test
2
+ # package targets. `period` matches bun's `--timeout=30000`; `terminate-after = 1`
3
+ # kills at that bound instead of warning then waiting another period.
4
+ [profile.default]
5
+ slow-timeout = { period = "30s", terminate-after = 1 }
6
+
7
+ # Compile-fail tests compile fixture crates (or rustc a negative contract) as
8
+ # their body. `cargo test --no-run` cannot pre-build those; they are generated
9
+ # at test time. Filterset matches the class by test name rather than listing
10
+ # today's two tests (`compile_fail_cases`, `lesser_capabilities_fail_to_compile_*`).
11
+ #
12
+ # 180s is provisional: measure on an idle machine with `--test-threads=1`.
13
+ # An unbounded run phase is how a hung test becomes a hung lane.
14
+ [[profile.default.overrides]]
15
+ filter = 'test(/compile_fail|fail_to_compile/)'
16
+ slow-timeout = { period = "180s", terminate-after = 1 }
17
+
18
+ # Tests that drive the host's REAL APFS stack — creating, attaching, mounting and
19
+ # detaching actual disk images — contend on a single machine-wide serialization
20
+ # point: Disk Arbitration and the APFS driver. Measured on this host, a read-only
21
+ # `diskutil apfs list -plist` costs 0.7s idle at 33 attached images but up to
22
+ # 14.4s while another process is attaching/detaching. Run in parallel these tests
23
+ # manufacture exactly that contention for each other, so each one's wall time
24
+ # becomes a function of how many siblings happen to be mid-attach — a test whose
25
+ # verdict depends on that is measuring the scheduler, not the code.
26
+ #
27
+ # `max-threads = 1` makes the group a mutex across the WHOLE run (groups are
28
+ # run-wide, not per-binary, so the lib unit tests and the apfs_integration binary
29
+ # serialize against each other as intended). The other ~830 tests stay parallel.
30
+ #
31
+ # This bounds contention; it does NOT grant more time. The per-test deadline above
32
+ # is unchanged and each of these tests is expected to fit it on its own merits.
33
+ # Membership is by name: `real_apfs_*` is the class marker, so a new real-APFS
34
+ # test joins the group by being named for what it touches. A bare `real_*` filter
35
+ # would be wrong here — unrelated `real_*` tests exist in columine-arrow,
36
+ # cowshed-cli and cowshed-gateway that touch no disk image at all.
37
+ [test-groups]
38
+ real-apfs = { max-threads = 1 }
39
+
40
+ # The full-lifecycle real-APFS tests cannot meet the default deadline, and
41
+ # `specs/cowshed/08_testing.md` already contains the arithmetic that proves it.
42
+ #
43
+ # That spec sets the house rule for real-substrate timing: "CI asserts with a 3×
44
+ # multiplier to absorb runner noise". `apfs_integration.rs` measured its lifecycle
45
+ # at 14.8s (Sparse) and 10.6s (Asif) on an IDLE host, so under the repo's own noise
46
+ # model CI needs 44.4s and 31.8s. A 30s deadline was therefore unreachable by
47
+ # construction: the test was not slow, the bound contradicted the spec.
48
+ #
49
+ # Nor is the cost reducible. The same spec's "Attach floor verdict: not
50
+ # flag-reducible" records that `-noverify` saves ~15ms (noise), `-noautofsck`
51
+ # nothing, and `diskutil image attach` exposes no equivalent knobs — the ~235-400ms
52
+ # per attach is inherent to DiskImages + APFS mount + DiskArbitration, and halving
53
+ # it would need DiskImages2 or the diskarbitrationd private API, which the spec
54
+ # explicitly forbids budgets from assuming. The lifecycle attaches once per phase
55
+ # across adopt, mount, clone-under-churn, checkpoint, restore, retire, reclaim, GC
56
+ # and detach, so its floor is a multiple of an irreducible constant.
57
+ #
58
+ # The alternative was splitting the lifecycle into phase-scoped tests so each fits
59
+ # 30s. It loses: every split pays that attach constant again, so the suite's total
60
+ # wall time rises to buy a smaller per-test bound. Splitting Sparse from Asif was
61
+ # worth it because it bought failure ATTRIBUTION; splitting phases buys only a
62
+ # number.
63
+ #
64
+ # 60s is 3× the worst idle measurement (44.4s) rounded up, not a guess. It stays
65
+ # bounded because an unbounded run phase is how a hung test becomes a hung lane.
66
+ # Re-derive it if the idle measurements in `apfs_integration.rs` change.
67
+ #
68
+ # Membership is by name and narrower than the group: the fast `real_apfs_*` unit
69
+ # tests in the lib keep the 30s default — they passed at 4.4s and 7.3s and have no
70
+ # claim on more. This override precedes the group-only one so it wins the
71
+ # first-match for both keys it sets.
72
+ [[profile.default.overrides]]
73
+ filter = 'test(/real_apfs_.*_substrate_lifecycle/)'
74
+ slow-timeout = { period = "60s", terminate-after = 1 }
75
+ test-group = 'real-apfs'
76
+
77
+ [[profile.default.overrides]]
78
+ filter = 'test(/real_apfs_/)'
79
+ test-group = 'real-apfs'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smoothbricks/nx-plugin",
3
- "version": "0.3.11",
3
+ "version": "0.3.13",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "main": "./loader.js",
@@ -75,6 +75,7 @@
75
75
  "files": [
76
76
  "dist",
77
77
  "src",
78
+ "nextest.toml",
78
79
  "README.md",
79
80
  "loader.js",
80
81
  "generators.json",