@smoothbricks/nx-plugin 0.5.1 → 0.5.2

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 (53) hide show
  1. package/README.md +55 -11
  2. package/dist/bin/smoo-nx-test-clocks.js +2 -2
  3. package/dist/bin/smoo-nx-test-walks.js +6 -9
  4. package/dist/cargo-closure-input.d.ts.map +1 -1
  5. package/dist/cargo-closure-input.js +25 -15
  6. package/dist/ensure-built-witness.d.ts +33 -5
  7. package/dist/ensure-built-witness.d.ts.map +1 -1
  8. package/dist/ensure-built-witness.js +84 -18
  9. package/dist/ensure-built.d.ts.map +1 -1
  10. package/dist/ensure-built.js +19 -5
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +4 -0
  13. package/dist/owned-installation.d.ts +6 -5
  14. package/dist/owned-installation.d.ts.map +1 -1
  15. package/dist/owned-installation.js +324 -201
  16. package/dist/test-walk-policy.d.ts +8 -0
  17. package/dist/test-walk-policy.d.ts.map +1 -1
  18. package/dist/test-walk-policy.js +34 -0
  19. package/dist/workspace-manifest.d.ts +5 -5
  20. package/dist/workspace-manifest.d.ts.map +1 -1
  21. package/managed/raw/patches/nx@23.2.1.patch +14 -3
  22. package/managed/raw/tooling/direnv/developer-links.ts +37 -10
  23. package/managed/raw/tooling/direnv/linked-snapshots.ts +31 -4
  24. package/managed/raw/tooling/direnv/setup-environment.ts +2 -0
  25. package/managed/raw/tooling/git-hooks/pre-push.sh +34 -11
  26. package/package.json +3 -3
  27. package/runtime-input.sh +21 -9
  28. package/src/__tests__/cargo-closure-filesets.ts +94 -0
  29. package/src/__tests__/owned-installation.ts +5 -6
  30. package/src/bin/smoo-nx-test-clocks.ts +2 -2
  31. package/src/bin/smoo-nx-test-walks.ts +6 -9
  32. package/src/cargo-closure-filesets.test.ts +63 -0
  33. package/src/cargo-closure-input.test.ts +1 -1
  34. package/src/cargo-closure-input.ts +23 -15
  35. package/src/cargo-closure-key.test.ts +1 -1
  36. package/src/cargo-resolve-cache.test.ts +1 -1
  37. package/src/cross-check-policy.test.ts +53 -12
  38. package/src/ensure-built-witness.test.ts +53 -2
  39. package/src/ensure-built-witness.ts +103 -18
  40. package/src/ensure-built.test.ts +40 -5
  41. package/src/ensure-built.ts +28 -6
  42. package/src/index.ts +4 -0
  43. package/src/linked-snapshots.nx.test.ts +1 -1
  44. package/src/nextest-partitions.test.ts +1 -1
  45. package/src/nx-daemon-validity.test.ts +51 -0
  46. package/src/owned-installation.test.ts +105 -0
  47. package/src/owned-installation.ts +335 -93
  48. package/src/runtime-input.test.ts +22 -1
  49. package/src/task-results.test.ts +1 -1
  50. package/src/test-walk-policy.test.ts +35 -0
  51. package/src/test-walk-policy.ts +32 -0
  52. package/src/workspace-manifest.ts +5 -5
  53. package/test-timings.json +94 -92
@@ -612,6 +612,19 @@ export function upstreamBase(root) {
612
612
  break;
613
613
  }
614
614
  }
615
+ if (upstream === 'main') {
616
+ // No upstream ref answered: say so as its own reason rather than letting
617
+ // merge-base fail against a local main that may not exist (a fresh shed
618
+ // has none until it fetches).
619
+ const local = exists('main');
620
+ if (!local.ok)
621
+ return local;
622
+ if (!local.value)
623
+ return {
624
+ ok: false,
625
+ reason: 'no main ref in this shed: neither refs/remotes/main/main, refs/remotes/origin/main nor a local main exists (fetch main, set refs/remotes/main/main, or export NX_BASE)',
626
+ };
627
+ }
615
628
  }
616
629
  const args = ['merge-base', 'HEAD', upstream];
617
630
  const result = git(root, args);
@@ -622,6 +635,27 @@ export function upstreamBase(root) {
622
635
  };
623
636
  return { ok: true, value: result.stdout.trim() };
624
637
  }
638
+ /**
639
+ * The upstream base as a run precondition, checked before Nx hashes anything:
640
+ * only a workspace whose own root package.json declares the test-walk check
641
+ * (this repository) is gated, and a missing main ref fails the run with the
642
+ * check's own reason instead of an error smuggled through a runtime input's
643
+ * byte channel. Workspaces that never declare the check are untouched.
644
+ */
645
+ export function assertUpstreamBasePrecondition(workspaceRoot) {
646
+ let rootPackage;
647
+ try {
648
+ rootPackage = readFileSync(join(workspaceRoot, 'package.json'), 'utf8');
649
+ }
650
+ catch {
651
+ return;
652
+ }
653
+ if (!rootPackage.includes('smoo-nx-test-walks'))
654
+ return;
655
+ const base = upstreamBase(workspaceRoot);
656
+ if (!base.ok)
657
+ throw new Error(`${TEST_ONE_WALK.id} cannot find the upstream base: ${base.reason}`);
658
+ }
625
659
  /**
626
660
  * The files changed since `base`, tracked or untracked, and the new-side line ranges of each change; an untracked
627
661
  * file is changed throughout.
@@ -236,7 +236,8 @@ export interface DeveloperLinkSnapshot {
236
236
  /** A declared checkout whose aliases bind a snapshot of it instead of the live directory. */
237
237
  export interface DeveloperLinkSnapshotDeclaration {
238
238
  directory: DeveloperLinkDirectory;
239
- snapshot: DeveloperLinkSnapshot;
239
+ /** A sealed content ID pins an existing snapshot; a target declaration opts into capture at each entry. */
240
+ snapshot: (string & typia.tags.Pattern<'^[0-9a-f]{64}$'>) | DeveloperLinkSnapshot;
240
241
  }
241
242
  export interface PackageSmooConfig {
242
243
  github?: PackageSmooGithub;
@@ -252,10 +253,9 @@ export interface PackageSmooConfig {
252
253
  * every checkout gets it. Shell entry links each tree that installed the
253
254
  * package, a directory the machine lacks keeps the installed version, and CI
254
255
  * links nothing (tooling/direnv/developer-links.ts, which validates the same
255
- * shape at runtime). A `{ directory, snapshot }` declaration binds a sealed,
256
- * Nx-attested snapshot of that checkout instead, so the provider's own builds
257
- * never change a file a running consumer task resolves. Nx is
258
- * lockfile/patch-owned and cannot be declared here.
256
+ * shape at runtime). A `{ directory, snapshot: "<64-hex ID>" }` declaration pins a sealed,
257
+ * Nx-attested snapshot in the consumer store until explicitly moved, even when the provider changes or disappears.
258
+ * A snapshot object opts into capture from the current provider. Nx is lockfile/patch-owned and cannot be declared here.
259
259
  */
260
260
  developerLinks?: Record<string, DeveloperLinkDirectory | DeveloperLinkSnapshotDeclaration>;
261
261
  }
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-manifest.d.ts","sourceRoot":"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E,OAAO,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAChD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,MAAM;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;CAChF;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,iBAAiB,GAAG,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,CAE3F"}
@@ -694,10 +694,10 @@ index 0000000000000000000000000000000000000000..28f263f82b7b698ec1bf88943924696b
694
694
  +export declare function stopDaemonIfWorkspaceGone(): boolean;
695
695
  diff --git a/dist/src/daemon/server/restart-checks.js b/dist/src/daemon/server/restart-checks.js
696
696
  new file mode 100644
697
- index 0000000000000000000000000000000000000000..5f7aa0aa874dfe389388169c8acb0c0ab45f5180
697
+ index 0000000000000000000000000000000000000000..6bd6df6e26cdbc306b33c01b363dc4b3d4475ada
698
698
  --- /dev/null
699
699
  +++ b/dist/src/daemon/server/restart-checks.js
700
- @@ -0,0 +1,295 @@
700
+ @@ -0,0 +1,306 @@
701
701
  +"use strict";
702
702
  +Object.defineProperty(exports, "__esModule", { value: true });
703
703
  +exports.relativeServerProcess = exports.DAEMON_VALIDITY_SAFETY_INTERVAL_MS = void 0;
@@ -721,6 +721,12 @@ index 0000000000000000000000000000000000000000..5f7aa0aa874dfe389388169c8acb0c0a
721
721
  +// Adapted from nrwl/nx#37113. Kept apart from server.js: importing it starts a server.
722
722
  +let daemon;
723
723
  +let terminating = false;
724
+ +// The process that starts a daemon owns its restart. A supervisor that keeps
725
+ +// this daemon (cowshed's keeper job) starts it as `start.js --kept` and starts
726
+ +// its successor itself; a successor spawned here would run outside that job,
727
+ +// where its owner cannot prove it. argv, read once at boot, is the launcher's
728
+ +// own word: no client's environment, which this daemon adopts, can change it.
729
+ +const keptByLauncher = process.argv.slice(2).includes('--kept');
724
730
  +function registerDaemonForRestartChecks(server, sockets, socketPath) {
725
731
  + daemon = { server, sockets, socketPath };
726
732
  + terminating = false;
@@ -986,10 +992,15 @@ index 0000000000000000000000000000000000000000..5f7aa0aa874dfe389388169c8acb0c0a
986
992
  +}
987
993
  +function restartDaemon(reason) {
988
994
  + if (!daemon || terminating) return;
995
+ + logger_1.serverLogger.log(`[Server] Daemon outdated: ${reason}`);
996
+ + if (keptByLauncher) {
997
+ + logger_1.serverLogger.log('[Server] Stopping: the process that started this daemon (--kept) starts its successor');
998
+ + stopDaemon(reason);
999
+ + return;
1000
+ + }
989
1001
  + // Do not spawn multiple replacements or answer queued requests while the
990
1002
  + // asynchronous restart releases ownership and starts the successor.
991
1003
  + terminating = true;
992
- + logger_1.serverLogger.log(`[Server] Daemon outdated: ${reason}`);
993
1004
  + logger_1.serverLogger.log('[Server] Restarting daemon...');
994
1005
  + (0, shutdown_utils_1.handleServerProcessTerminationWithRestart)({ server: daemon.server, reason, sockets: daemon.sockets });
995
1006
  +}
@@ -66,6 +66,11 @@
66
66
  * CI never applies them: it builds against the published packages the
67
67
  * lockfile names (setup-environment.ts `--links`).
68
68
  *
69
+ * A stable declaration names `{ "directory": …, "snapshot": "<64-hex ID>" }`:
70
+ * only the consumer's verified sealed snapshot resolves. Provider HEAD drift
71
+ * is reported and continues with the pin; a missing or invalid pin refuses.
72
+ * The directory is a freshness hint, never an input to pinned execution.
73
+ *
69
74
  * A declaration may also ask for a snapshot: `{ "directory": …, "snapshot":
70
75
  * { "targets": [...], "artifactModules": [...] } }` binds every alias to a
71
76
  * sealed copy of that checkout instead of the live directory, so the
@@ -118,6 +123,8 @@ import {
118
123
  import path from 'node:path';
119
124
  import type { KeepDeveloperLinksOptions } from '@smoothbricks/nx-plugin/managed-assets';
120
125
  import {
126
+ type ProducerProbe,
127
+ pinnedSnapshot,
121
128
  pluginProbe,
122
129
  recordedSnapshot,
123
130
  type SealedSnapshot,
@@ -415,6 +422,8 @@ export type UnavailableDeclaredLink =
415
422
  export interface DeclaredLinksPlan {
416
423
  readonly changes: readonly DeclaredLinkChange[];
417
424
  readonly unavailable: readonly UnavailableDeclaredLink[];
425
+ /** Verified pins whose provider HEAD differs or cannot be inspected; linking still succeeds. */
426
+ readonly reports: readonly string[];
418
427
  }
419
428
 
420
429
  /**
@@ -435,22 +444,24 @@ export interface DeclaredLinksPlan {
435
444
  export async function planDeclaredLinks(root: string): Promise<DeclaredLinksPlan> {
436
445
  const declared = readDeclaredLinks(root);
437
446
  if (declared.length === 0) {
438
- return { changes: [], unavailable: [] };
447
+ return { changes: [], unavailable: [], reports: [] };
439
448
  }
440
449
  const anchor = linkAnchor(root);
441
450
  const canonicalRoot = realpathSync(root);
442
451
  const trees = nodeModulesTrees(root);
443
452
  const recorded = readDeclaredRecord(root);
444
- const probe = pluginProbe(snapshotPluginRoot(root, anchor, declared));
453
+ const probe: ProducerProbe = (target, providerRoot) =>
454
+ pluginProbe(snapshotPluginRoot(root, anchor, declared))(target, providerRoot);
445
455
  const changes: DeclaredLinkChange[] = [];
446
456
  const unavailable: UnavailableDeclaredLink[] = [];
457
+ const reports: string[] = [];
447
458
  for (const { name, directory: relative, snapshot } of declared) {
448
459
  const source = declaredTarget(root, anchor, relative);
449
460
  const contained = containsPath(path.resolve(root), source);
450
- if (contained) {
461
+ if (contained && typeof snapshot !== 'string') {
451
462
  assertOwnedPath(canonicalRoot, path.resolve(canonicalRoot, path.relative(path.resolve(root), source)));
452
463
  }
453
- const reason = unavailableReason(source);
464
+ const reason = typeof snapshot === 'string' ? null : unavailableReason(source);
454
465
  if (reason !== null) {
455
466
  if (contained) assertNoInheritedBinding(root, anchor, name, relative, source);
456
467
  unavailable.push({ kind: 'absent', name, target: source, reason });
@@ -460,16 +471,20 @@ export async function planDeclaredLinks(root: string): Promise<DeclaredLinksPlan
460
471
  if (snapshot !== undefined) {
461
472
  const outcome = await snapshotBinding(root, name, source, snapshot, probe);
462
473
  if (outcome.kind === 'refused') {
474
+ if (typeof snapshot === 'string')
475
+ throw new Error(`smoo.developerLinks ${name}: cannot resolve pinned snapshot ${snapshot}: ${outcome.reason}`);
463
476
  const kept = keptSnapshots(root, trees, name, recorded);
464
477
  changes.push(...kept.changes);
465
478
  unavailable.push({ kind: 'snapshot-refused', name, source, reason: outcome.reason, ...kept.said });
466
479
  continue;
467
480
  }
468
481
  binding = { kind: 'snapshot', target: outcome.directory, id: outcome.id };
482
+ if (outcome.report !== undefined) reports.push(`! smoo.developerLinks ${name}: ${outcome.report}`);
469
483
  }
470
484
  const target = binding.target;
471
485
  // The live checkout a snapshot replaces, by physical identity: a link spelled through another path is the same one.
472
- const sourcePhysical = binding.kind === 'snapshot' ? realpathSync(source) : undefined;
486
+ const sourcePhysical =
487
+ binding.kind === 'snapshot' && typeof snapshot !== 'string' ? realpathSync(source) : undefined;
473
488
  for (const tree of trees) {
474
489
  const entry = path.join(tree, name);
475
490
  const at = path.join(root, entry);
@@ -488,8 +503,13 @@ export async function planDeclaredLinks(root: string): Promise<DeclaredLinksPlan
488
503
  const inherited = inheritedContainedBinding(anchor, relative, current);
489
504
  const managed = recorded.get(entry)?.target === text;
490
505
  if (current === target && text === packageAliasTarget(root, at, target)) continue;
491
- const physical = sourcePhysical === undefined ? undefined : realpathOrNull(current);
492
- if (binding.kind === 'snapshot' && foreign && !inherited && !managed && physical === sourcePhysical) {
506
+ if (
507
+ sourcePhysical !== undefined &&
508
+ foreign &&
509
+ !inherited &&
510
+ !managed &&
511
+ realpathOrNull(current) === sourcePhysical
512
+ ) {
493
513
  unavailable.push({ kind: 'snapshot-unclaimed', name, path: entry, source });
494
514
  continue;
495
515
  }
@@ -498,7 +518,7 @@ export async function planDeclaredLinks(root: string): Promise<DeclaredLinksPlan
498
518
  changes.push({ path: entry, binding });
499
519
  }
500
520
  }
501
- return { changes, unavailable };
521
+ return { changes, unavailable, reports };
502
522
  }
503
523
 
504
524
  /**
@@ -560,6 +580,7 @@ function snapshotPluginRoot(root: string, anchor: string, declared: readonly Dec
560
580
  const plugin = declared.find(({ name }) => name === '@smoothbricks/nx-plugin');
561
581
  if (plugin === undefined) return root;
562
582
  const source = declaredTarget(root, anchor, plugin.directory);
583
+ if (typeof plugin.snapshot === 'string') return pinnedSnapshot(root, plugin.name, source, plugin.snapshot).directory;
563
584
  return unavailableReason(source) === null ? source : root;
564
585
  }
565
586
 
@@ -586,6 +607,7 @@ function assertNoInheritedBinding(root: string, anchor: string, name: string, re
586
607
  * which declarations this machine cannot honour.
587
608
  */
588
609
  export function applyDeclaredLinks(root: string, plan: DeclaredLinksPlan): void {
610
+ for (const report of plan.reports) console.error(report);
589
611
  for (const unavailable of plan.unavailable) {
590
612
  switch (unavailable.kind) {
591
613
  case 'absent':
@@ -732,13 +754,13 @@ const TARGET = /^[^:\s]+:[^:\s]+(?::[^:\s]+)?$/;
732
754
  interface DeclaredLink {
733
755
  readonly name: string;
734
756
  readonly directory: string;
735
- readonly snapshot: SnapshotDeclaration | undefined;
757
+ readonly snapshot: SnapshotDeclaration | string | undefined;
736
758
  }
737
759
 
738
760
  /**
739
761
  * `smoo.developerLinks` from the root manifest: each package name with its
740
762
  * checkout directory, relative, given alone or as `{ directory, snapshot }`
741
- * where `snapshot` names the provider targets that build it and its native
763
+ * where `snapshot` names a sealed snapshot ID or the provider targets that build it and its native
742
764
  * artifact modules (linked-snapshots.ts). Hand-validated, like
743
765
  * secret-references.ts validates `smoo.secrets`: this runs before anything is
744
766
  * installed. The shape is `PackageSmooConfig.developerLinks` in the
@@ -773,6 +795,11 @@ function readDeclaredLinks(root: string): DeclaredLink[] {
773
795
  }
774
796
  if (!object) return { name, directory, snapshot: undefined };
775
797
  const snapshot: unknown = Reflect.get(declaration, 'snapshot');
798
+ if (typeof snapshot === 'string') {
799
+ if (!/^[0-9a-f]{64}$/.test(snapshot))
800
+ throw new Error(`${manifestPath}: smoo.developerLinks ${name}.snapshot must be 64 lowercase hex digits`);
801
+ return { name, directory, snapshot };
802
+ }
776
803
  const targets: unknown =
777
804
  typeof snapshot === 'object' && snapshot !== null ? Reflect.get(snapshot, 'targets') : undefined;
778
805
  const artifactModules: unknown =
@@ -8,6 +8,9 @@
8
8
  * resolved the live directory would then read bytes no key of it describes. A
9
9
  * snapshot is copied from one provider state and never changes: a provider
10
10
  * change reaches the consumer only as another snapshot under another name.
11
+ * An explicit snapshot ID resolves only from the consumer's existing store;
12
+ * provider HEAD changes are informational and never select another snapshot.
13
+ * Only a capture declaration opts into the provider's current state.
11
14
  *
12
15
  * What a snapshot holds, laid out as in the provider checkout so relative
13
16
  * resolution means what it meant there (exports, tsconfig `paths`, and the
@@ -140,6 +143,8 @@ export interface SealedSnapshot {
140
143
  readonly kind: 'snapshot';
141
144
  readonly id: string;
142
145
  readonly directory: string;
146
+ /** Informational pin freshness only; never a request to recapture or refuse a verified pin. */
147
+ readonly report?: string;
143
148
  }
144
149
 
145
150
  export type SnapshotBinding = SealedSnapshot | { readonly kind: 'refused'; readonly reason: string };
@@ -174,18 +179,18 @@ type ProducerRecord = Extract<EnsureBuiltProbeResult, { readonly disposition: 'h
174
179
  const PRODUCER_VERSION = 1;
175
180
 
176
181
  /**
177
- * The snapshot `source` binds to now: its provider is probed, copied and attested every time, and the result is
178
- * the sealed snapshot of exactly that census and receipt, published now or verified when it already exists. A
179
- * refusal names its cause and leaves every binding as it was.
182
+ * A snapshot ID resolves only from the consumer's store. A capture declaration instead probes, copies and attests
183
+ * the provider's current state. A refusal names its cause and leaves every binding as it was.
180
184
  */
181
185
  export async function snapshotBinding(
182
186
  root: string,
183
187
  name: string,
184
188
  source: string,
185
- declaration: SnapshotDeclaration,
189
+ declaration: SnapshotDeclaration | string,
186
190
  probe: ProducerProbe,
187
191
  ): Promise<SnapshotBinding> {
188
192
  try {
193
+ if (typeof declaration === 'string') return pinnedSnapshot(root, name, source, declaration);
189
194
  const store = snapshotStore(root);
190
195
  const plan = planSnapshot(source, name, declaration, bunCacheRoot(root));
191
196
  const id = await capture(store, plan, declaration, probe, fingerprintOf(plan));
@@ -199,6 +204,28 @@ export async function snapshotBinding(
199
204
  }
200
205
  }
201
206
 
207
+ /** Resolve an explicit content pin, never reading provider bytes or asking its producer to run. */
208
+ export function pinnedSnapshot(root: string, name: string, source: string, id: string): SealedSnapshot {
209
+ if (!/^[0-9a-f]{64}$/.test(id)) throw new SnapshotRefusal(`snapshot pin ${id} must be 64 lowercase hex digits`);
210
+ const sealed = path.resolve(root, SNAPSHOT_STORE, id);
211
+ const receipt = verifySnapshot(sealed);
212
+ if (receipt.name !== name) throw new SnapshotRefusal(`snapshot ${id} contains ${receipt.name}, not ${name}`);
213
+ if (!contained(receipt.packagePath))
214
+ throw new SnapshotRefusal(`snapshot ${id} has an invalid package path ${receipt.packagePath}`);
215
+ const directory = path.join(sealed, receipt.packagePath);
216
+ const head = spawnSync('git', ['-C', source, 'rev-parse', '--verify', 'HEAD'], {
217
+ encoding: 'utf8',
218
+ env: { ...process.env, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1' },
219
+ });
220
+ const report =
221
+ head.error !== undefined || head.status !== 0
222
+ ? `cannot inspect ${source} HEAD for snapshot pin ${id}: ${head.error?.message ?? head.stderr.trim()}; continuing with the pin`
223
+ : head.stdout.trim() !== receipt.provenance.head
224
+ ? `stale pin ${id}: captured HEAD ${receipt.provenance.head} differs from ${source} HEAD ${head.stdout.trim()}; continuing with the pin; move snapshot explicitly to select another build`
225
+ : undefined;
226
+ return { kind: 'snapshot', id, directory, ...(report === undefined ? {} : { report }) };
227
+ }
228
+
202
229
  /**
203
230
  * The store under `root`. A cowshed checkout keeps it on its build volume: until a refresh has linked it there,
204
231
  * an empty directory is left for that refresh to adopt and the capture refuses.
@@ -249,6 +249,8 @@ try {
249
249
  // A refused or unclaimed snapshot is current only when said: the exec that follows names its cause.
250
250
  const current =
251
251
  plan.changes.length === 0 && plan.unavailable.every((unavailable) => unavailable.kind === 'absent');
252
+ // A stale pin is informational, not a stale install: say it even when devenv skips the exec.
253
+ if (current && plan.reports.length > 0) applyDeclaredLinks(projectRoot, plan);
252
254
  process.exit(
253
255
  current && !hasStaleDeveloperLinks(projectRoot, ['nx']) && danglingStoreLinks(projectRoot).length === 0 ? 0 : 1,
254
256
  );
@@ -14,15 +14,25 @@
14
14
  # present. From a plain shell the cross target itself never compiles here: on
15
15
  # a miss its guard refuses. Its dependencies are ordinary Nx tasks whose outputs
16
16
  # the cross key reads, so Nx restores them from the cache or, for a tree no gate
17
- # ran, builds them. A refusal names the one command that fixes it; any other Nx
17
+ # ran, builds them. A refusal names the one command that fixes it; any other
18
18
  # failure is said as that, never as a cache miss.
19
19
  #
20
+ # Nx runs in this checkout's environment, `direnv exec <checkout>`, which is the
21
+ # environment the land gate runs in, never in the environment of whatever shell
22
+ # ran `git push`. devenv declares this checkout's tooling and the environment it
23
+ # builds with (the macOS SDK it links against among it), and tasks key on that
24
+ # environment as well as on the tree: a push from a shell carrying another
25
+ # directory's devenv keyed the gate's tasks on that shell's SDKROOT and
26
+ # DEVELOPER_DIR, missed every one of them, and then built them against the wrong
27
+ # SDK. Under the checkout's environment the keys are the gate's, and a dependency
28
+ # that does miss builds the way the gate builds it.
29
+ #
20
30
  # Why the cross target never compiles here. The cross-clippy needs zig and
21
31
  # cargo-zigbuild, which a macOS host carries only in the linux-cross devenv
22
- # profile. A hook that entered that profile spent minutes compiling on a push
23
- # the user expected to take a second, and it did so in an environment they
24
- # never asked for. Pushing is not the place to discover that the tree has not
25
- # been compiled for Linux: the land gate, or `bun run check:linux`, is.
32
+ # profile, not in the default shell `direnv exec` enters. A hook that entered
33
+ # that profile spent minutes compiling on a push the user expected to take a
34
+ # second. Pushing is not the place to discover that the tree has not been
35
+ # compiled for Linux: the land gate, or `bun run check:linux`, is.
26
36
  #
27
37
  # The target's own guard refuses to start when cargo-zigbuild is not on PATH,
28
38
  # which is what turns a miss into a refusal here. A push made from a shell that
@@ -30,8 +40,9 @@
30
40
  # guard, so there a miss runs the check itself: the same clippy `check:linux`
31
41
  # runs, in the toolchain the user entered for it.
32
42
  #
33
- # Everything in tooling depends only on devenv.nix packages, so this hook also
34
- # works with no devenv on PATH. It must never pretend a check ran that did not.
43
+ # The denylist gate needs only tooling/direnv/repo-path's PATH; the cross gate
44
+ # needs direnv on the caller's PATH, and the checkout's own devenv through it,
45
+ # not a devenv the caller entered. It must never pretend a check ran that did not.
35
46
 
36
47
  cd "$(git rev-parse --show-toplevel)"
37
48
  TOOLING="$PWD/tooling"
@@ -66,13 +77,24 @@ case "$(uname -s)" in
66
77
  *) exit 0 ;;
67
78
  esac
68
79
 
80
+ # The refusal uses shell builtins alone: without direnv nothing proves the
81
+ # caller's PATH carries coreutils, and a Nix-built host's /usr/bin and /bin
82
+ # hold none of them.
83
+ if ! command -v direnv >/dev/null; then
84
+ printf '%s\n' \
85
+ 'pre-push: direnv is not on PATH, so the Linux cross-compile check cannot run in' \
86
+ "this checkout's environment, and a check run in any other environment keys on" \
87
+ 'values the land gate never used. Put direnv on PATH, then push again.' >&2
88
+ exit 1
89
+ fi
90
+
69
91
  # The guard's refusal (nx-plugin cross-check-policy.ts CARGO_CROSS_LINT_REFUSAL)
70
92
  # is the one line that means the key missed. Nx exits 1 for every task failure,
71
93
  # so the hook reads the output for it rather than guessing from the status.
72
94
  output=$(mktemp "${TMPDIR:-/tmp}/pre-push-cross.XXXXXX") || exit 1
73
95
  trap 'rm -f "$output"' EXIT
74
96
  set -o pipefail
75
- nx run-many -t cargo-lint-cross --output-style=static 2>&1 | tee "$output"
97
+ direnv exec "$PWD" nx run-many -t cargo-lint-cross --output-style=static 2>&1 | tee "$output"
76
98
  status=$?
77
99
  [ "$status" -eq 0 ] && exit 0
78
100
 
@@ -90,9 +112,10 @@ EOF
90
112
  else
91
113
  cat >&2 <<EOF
92
114
 
93
- pre-push: Nx failed (exit $status) before the Linux cross-compile check reached
94
- a cache verdict; the output above names why. This is not a cache miss, and
95
- bun run check:linux will not fix it.
115
+ pre-push: the Linux cross-compile check failed (exit $status) before it reached
116
+ a cache verdict, in Nx or in direnv entering this checkout's environment; the
117
+ output above names why. This is not a cache miss, and bun run check:linux will
118
+ not fix it.
96
119
  EOF
97
120
  fi
98
121
  exit 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smoothbricks/nx-plugin",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "main": "./loader.js",
@@ -312,8 +312,8 @@
312
312
  "yaml": "^2.9.0"
313
313
  },
314
314
  "devDependencies": {
315
- "@smoothbricks/lmao": "0.5.5",
316
- "@smoothbricks/validation": "0.1.11",
315
+ "@smoothbricks/lmao": "0.5.6",
316
+ "@smoothbricks/validation": "0.1.12",
317
317
  "fast-check": "^4.4.0"
318
318
  }
319
319
  }
package/runtime-input.sh CHANGED
@@ -20,10 +20,17 @@
20
20
  # exit status, the byte is redundant and can go.
21
21
  #
22
22
  # Nx drops runtime stderr, so it is not a reliable diagnostic channel. Failures
23
- # retain private argv, byte-exact stderr, status and a readable report below
24
- # $PWD/.runtime-input-failures/, outside Nx and temporary state. Read them with
25
- # `cat .runtime-input-failures/*/report` after a decoder error. Stderr and a
26
- # controlling /dev/tty also name the failure where those channels are visible.
23
+ # retain private argv, byte-exact stdout and stderr, status and a readable
24
+ # report below $PWD/.runtime-input-failures/, outside Nx and temporary state.
25
+ # Read them with `cat .runtime-input-failures/*/report` after a decoder error.
26
+ # Stderr and a controlling /dev/tty also name the failure where those channels
27
+ # are visible.
28
+ #
29
+ # A failed command's own stdout never reaches the hasher either: it is
30
+ # captured to a file from the start, retained in the failure record, and the
31
+ # only byte this script emits on failure is the 0xFF poison above. Nothing
32
+ # from a failure path flows into the hash as input bytes. Successful stdout
33
+ # is replayed from the capture file byte-exact.
27
34
  #
28
35
  # The command's stderr is not part of the value; it surfaces only on failure.
29
36
  # Diagnostics name temp paths, process ids and the boundary the input ran in
@@ -35,15 +42,17 @@ if [ "$#" -eq 0 ]; then
35
42
  printf '\377'
36
43
  exit 64
37
44
  fi
38
- if diagnostic=$(mktemp "${TMPDIR:-/tmp}/nx-runtime-input.XXXXXXXXXX"); then
45
+ if diagnostic=$(mktemp "${TMPDIR:-/tmp}/nx-runtime-input-stderr.XXXXXXXXXX") &&
46
+ captured=$(mktemp "${TMPDIR:-/tmp}/nx-runtime-input-stdout.XXXXXXXXXX"); then
39
47
  :
40
48
  else
41
- printf 'runtime input could not capture stderr: %s\n' "$*" >&2
49
+ printf 'runtime input could not capture streams: %s\n' "$*" >&2
42
50
  printf '\377'
43
51
  exit 73
44
52
  fi
45
- if "$@" 2>"$diagnostic"; then
46
- rm -f "$diagnostic"
53
+ if "$@" >"$captured" 2>"$diagnostic"; then
54
+ cat "$captured"
55
+ rm -f "$diagnostic" "$captured"
47
56
  exit 0
48
57
  else
49
58
  status=$?
@@ -53,7 +62,8 @@ if record=$(umask 077; mkdir -p "$PWD/.runtime-input-failures" &&
53
62
  mktemp -d "$PWD/.runtime-input-failures/failure.XXXXXXXXXX"); then
54
63
  if printf '%s\000' "$@" >"$record/argv" &&
55
64
  printf '%s\n' "$status" >"$record/exit-status" &&
56
- mv "$diagnostic" "$record/stderr" && {
65
+ mv "$diagnostic" "$record/stderr" &&
66
+ mv "$captured" "$record/stdout" && {
57
67
  printf 'runtime input exited %s: %s\n' "$status" "$*"
58
68
  printf 'working directory: %s\n' "$PWD"
59
69
  index=0
@@ -64,6 +74,8 @@ if record=$(umask 077; mkdir -p "$PWD/.runtime-input-failures" &&
64
74
  done
65
75
  printf 'original stderr:\n'
66
76
  cat "$record/stderr"
77
+ printf 'original stdout (never hashed):\n'
78
+ cat "$record/stdout"
67
79
  } >"$record/report"; then
68
80
  printf '\nruntime input exited %s: %s; evidence: %s/report\n' "$status" "$*" "$record" >&2
69
81
  # A detached daemon may have no terminal. Preserve that error too, rather
@@ -0,0 +1,94 @@
1
+ import { join, posix } from 'node:path';
2
+ import type { CargoClosureSource } from '../cargo-closure-input.js';
3
+ import { CARGO_ANCESTOR_INPUTS, HASH_SKIPPED_DIRECTORIES } from '../cargo-source-hash.js';
4
+
5
+ /** Resolved metadata with the per-graph source scans already cached, as on later project visits. */
6
+ export function filesetSource(
7
+ root: string,
8
+ directories: readonly string[],
9
+ files: readonly string[],
10
+ ): CargoClosureSource {
11
+ const local = directories.map((directory, index) => ({
12
+ id: String(index),
13
+ name: `package-${index}`,
14
+ version: '1.0.0',
15
+ directory: join(root, directory),
16
+ manifest: join(root, directory, 'Cargo.toml'),
17
+ sources: [join(root, directory, 'src/lib.rs'), ...files.map((file) => join(root, file))],
18
+ governingManifest: join(root, 'Cargo.toml'),
19
+ }));
20
+ return {
21
+ manifest: 'Cargo.toml',
22
+ workspaceRoot: root,
23
+ root,
24
+ cargo: {
25
+ root,
26
+ members: new Set(local.map(({ id }) => id)),
27
+ local,
28
+ edges: new Map(local.map(({ id }) => [id, []])),
29
+ },
30
+ indexed: new Set(directories.map((directory) => posix.join(directory, 'Cargo.toml'))),
31
+ compiledFilesCache: new Map(local.map(({ directory }) => [directory, []])),
32
+ };
33
+ }
34
+
35
+ export interface ExpansionCopies {
36
+ directoryEntries: number;
37
+ siblingNames: number;
38
+ }
39
+
40
+ /** The pre-cutover fileset reduction, retained only as a differential oracle. */
41
+ export function expandedFilesets(
42
+ packageDirectories: readonly string[],
43
+ files: readonly string[],
44
+ copies?: ExpansionCopies,
45
+ ): string[] {
46
+ const parent = (path: string): string | null => {
47
+ if (path === '') return null;
48
+ const directory = posix.dirname(path);
49
+ return directory === '.' ? '' : directory;
50
+ };
51
+ const contains = (directory: string, path: string) =>
52
+ directory === '' || path === directory || path.startsWith(`${directory}/`);
53
+ const directories = [...new Set(packageDirectories)].sort().filter((directory, index, sorted) => {
54
+ if (copies !== undefined) copies.directoryEntries += index;
55
+ return !sorted.slice(0, index).some((outer) => contains(outer, directory));
56
+ });
57
+ const ancestors = new Set<string>();
58
+ for (const directory of directories) {
59
+ for (let ancestor = parent(directory); ancestor !== null; ancestor = parent(ancestor)) {
60
+ const candidate = ancestor;
61
+ if (!directories.some((outer) => contains(outer, candidate))) ancestors.add(candidate);
62
+ }
63
+ }
64
+ const loose = new Set(
65
+ files.filter(
66
+ (file) =>
67
+ !directories.some((directory) => contains(directory, file)) &&
68
+ !(posix.basename(file) === 'Cargo.toml' && ancestors.has(parent(file) ?? '')),
69
+ ),
70
+ );
71
+ const siblings = new Map<string, string[]>();
72
+ for (const directory of directories) {
73
+ const key = parent(directory);
74
+ if (key === null) continue;
75
+ if (copies !== undefined) copies.siblingNames += siblings.get(key)?.length ?? 0;
76
+ siblings.set(key, [...(siblings.get(key) ?? []), posix.basename(directory)]);
77
+ }
78
+ const packageGlobs = directories.includes('')
79
+ ? ['']
80
+ : [...siblings].map(([under, names]) =>
81
+ posix.join(under, names.length === 1 ? names.join('') : `{${names.join(',')}}`),
82
+ );
83
+ const anchored = (path: string, pattern = '') => posix.join('{workspaceRoot}', path, pattern);
84
+ // cargoClosureInputs removes duplicate inputs, including a loose lockfile.
85
+ return [
86
+ ...new Set([
87
+ '{workspaceRoot}/Cargo.lock',
88
+ ...packageGlobs.map((glob) => anchored(glob, '**/{*.rs,Cargo.toml,.cargo/config,.cargo/config.toml}')),
89
+ ...packageGlobs.map((glob) => `!${anchored(glob, `**/{${HASH_SKIPPED_DIRECTORIES.join(',')}}/**`)}`),
90
+ ...[...ancestors].sort().map((ancestor) => anchored(ancestor, `{${CARGO_ANCESTOR_INPUTS.join(',')}}`)),
91
+ ...[...loose].sort().map((file) => anchored(file)),
92
+ ]),
93
+ ];
94
+ }