@smoothbricks/nx-plugin 0.7.6 → 0.7.8

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 (35) hide show
  1. package/README.md +4 -1
  2. package/dist/.build-inputs.json +9 -9
  3. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  4. package/dist/executors/bounded-exec/executor.js +17 -17
  5. package/dist/executors/bounded-exec/host-memory.d.ts +7 -0
  6. package/dist/executors/bounded-exec/host-memory.d.ts.map +1 -1
  7. package/dist/executors/bounded-exec/host-memory.darwin.d.ts.map +1 -1
  8. package/dist/executors/bounded-exec/host-memory.darwin.js +76 -1
  9. package/dist/executors/bounded-exec/host-memory.linux.d.ts.map +1 -1
  10. package/dist/executors/bounded-exec/host-memory.linux.js +34 -1
  11. package/dist/executors/bounded-exec/leaf-peak.d.ts +5 -4
  12. package/dist/executors/bounded-exec/leaf-peak.d.ts.map +1 -1
  13. package/dist/executors/bounded-exec/leaf-peak.js +5 -4
  14. package/dist/executors/bounded-exec/mbx-reservations.d.ts +22 -0
  15. package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -1
  16. package/dist/executors/bounded-exec/mbx-reservations.js +22 -0
  17. package/dist/executors/bounded-exec/peak-waiter.js +27 -1
  18. package/dist/managed-files/ci-workflow.d.ts +7 -0
  19. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  20. package/dist/managed-files/ci-workflow.js +11 -4
  21. package/dist/managed-files/publish-workflow.d.ts.map +1 -1
  22. package/dist/managed-files/publish-workflow.js +13 -4
  23. package/managed/raw/patches/ttsc@0.34.1.patch +388 -0
  24. package/managed/templates/github/actions/setup-devenv/action.yml +69 -3
  25. package/package.json +3 -3
  26. package/src/executors/bounded-exec/executor.ts +18 -18
  27. package/src/executors/bounded-exec/host-memory.darwin.ts +104 -1
  28. package/src/executors/bounded-exec/host-memory.linux.ts +33 -1
  29. package/src/executors/bounded-exec/host-memory.ts +7 -0
  30. package/src/executors/bounded-exec/leaf-peak.ts +5 -4
  31. package/src/executors/bounded-exec/mbx-reservations.ts +30 -0
  32. package/src/executors/bounded-exec/peak-waiter.ts +37 -4
  33. package/src/managed-files/ci-workflow.ts +12 -4
  34. package/src/managed-files/publish-workflow.ts +15 -3
  35. package/test-timings.json +2 -0
@@ -2,7 +2,7 @@
2
2
  import { isMap, isScalar, parseDocument } from 'yaml';
3
3
  import { LINUX_PLATFORM_TARGET_GLOBS, MACOS_PLATFORM_TARGET_GLOBS, RELEASE_CONFIGURATION, } from '../platform-targets.js';
4
4
  import { isSmoothBricksCodebasePackageName } from '../workspace-package-policy.js';
5
- import { artifactStepLines, CiWorkflowStepKind, cargoCredentialJobEnvLines, cargoCredentialStepLines, deployStepSecretEnvLines, githubActionPins, remoteCacheJobEnvLines, sourceCheckoutsStepLines, TRACE_DB_ARTIFACT_GLOB, } from './ci-workflow.js';
5
+ import { artifactStepLines, CI_JOB_ID, CI_WORKFLOW_NAME, CiWorkflowStepKind, cargoCredentialJobEnvLines, cargoCredentialStepLines, deployStepSecretEnvLines, githubActionPins, remoteCacheJobEnvLines, sourceCheckoutsStepLines, TRACE_DB_ARTIFACT_GLOB, } from './ci-workflow.js';
6
6
  import { GITHUB_HOSTED_LINUX_RUNNER, renderRunsOnLine } from './github-runs-on.js';
7
7
  /**
8
8
  * Carried by every step that builds what ships: the build aggregate and each
@@ -394,6 +394,15 @@ function commentLinesForStep(step) {
394
394
  }
395
395
  return [` # Step ${step.number}`];
396
396
  }
397
+ /** The setup-devenv step's `uses` and the scope its task records start from: a release's tests are CI's. */
398
+ function setupDevenvUsesLines() {
399
+ return [
400
+ ' uses: ./.github/actions/setup-devenv',
401
+ ' with:',
402
+ ` records-workflow: ${CI_WORKFLOW_NAME}`,
403
+ ` records-job: ${CI_JOB_ID}`,
404
+ ];
405
+ }
397
406
  function yamlLinesForStep(step, options) {
398
407
  switch (step.kind) {
399
408
  case PublishWorkflowStepKind.Checkout:
@@ -414,7 +423,7 @@ function yamlLinesForStep(step, options) {
414
423
  case PublishWorkflowStepKind.CargoCredentials:
415
424
  return cargoCredentialsStepLines(options);
416
425
  case PublishWorkflowStepKind.SetupDevenv:
417
- return [` - name: ${step.name}`, ' id: setup', ' uses: ./.github/actions/setup-devenv'];
426
+ return [` - name: ${step.name}`, ' id: setup', ...setupDevenvUsesLines()];
418
427
  case PublishWorkflowStepKind.ConfigureReleaseAuthor:
419
428
  return [
420
429
  ` - name: ${step.name}`,
@@ -819,7 +828,7 @@ function renderMacosPlatformSteps(options) {
819
828
  if (siblingSourceCheckouts.length > 0) {
820
829
  lines.push('', ` # Step ${stepNumber++}`, ...siblingSourceCheckouts);
821
830
  }
822
- lines.push('', ` # Step ${stepNumber++}. Composite action internals do not affect top-level job step`, ' # anchors; update these comments if top-level steps move.', ' - name: 🧱 Setup Nix/devenv', ' id: setup', ' uses: ./.github/actions/setup-devenv');
831
+ lines.push('', ` # Step ${stepNumber++}. Composite action internals do not affect top-level job step`, ' # anchors; update these comments if top-level steps move.', ' - name: 🧱 Setup Nix/devenv', ' id: setup', ...setupDevenvUsesLines());
823
832
  if (isSmoothBricksCodebasePackageName(options.repoName)) {
824
833
  lines.push('', ` # Step ${stepNumber++}`, ' - name: 🏗️ Build smoo Nx version actions', ' # Nx Release loads @smoothbricks/nx-plugin/version-actions through the', ' # export map in its own node process, and versioning runs before the', ' # build phase, so the hook must exist in dist first. Downstream', ' # consumers install the published package and skip this bootstrap.', ' #', ' # `nx` cannot do it: the project graph loads this very plugin, so', ' # `nx build nx-plugin` deadlocks on the executor it is building.', ' # ttsc needs only the package tsconfig -- the bootstrap the shell entry', ' # runs (tooling/direnv/enter-shell.ts) -- and emits as the typescript-emit', ' # executor does (EMIT_OVERRIDES), so dist holds no build info.', ' working-directory: packages/nx-plugin', ' run: bun ../../tooling/ttsc-emit.ts');
825
834
  }
@@ -874,7 +883,7 @@ function renderFinalLinuxPublishSteps(options) {
874
883
  if (siblingSourceCheckouts.length > 0) {
875
884
  lines.push('', ` # Step ${stepNumber++}`, ...siblingSourceCheckouts);
876
885
  }
877
- lines.push('', ` # Step ${stepNumber++}`, ' - name: 🧱 Setup Nix/devenv', ' # Pending release repair builds historical npm gaps before the current', ' # verified artifacts are restored, so this job still needs the full', ' # toolchain even though current release publishing is prebuilt-only.', ' id: setup', ' uses: ./.github/actions/setup-devenv', '', ` # Step ${stepNumber++}`, ...artifactStepLines(options.actionsProvider, '📥 Download candidate artifacts', 'download', [
886
+ lines.push('', ` # Step ${stepNumber++}`, ' - name: 🧱 Setup Nix/devenv', ' # Pending release repair builds historical npm gaps before the current', ' # verified artifacts are restored, so this job still needs the full', ' # toolchain even though current release publishing is prebuilt-only.', ' id: setup', ...setupDevenvUsesLines(), '', ` # Step ${stepNumber++}`, ...artifactStepLines(options.actionsProvider, '📥 Download candidate artifacts', 'download', [
878
887
  `pattern: publish-*-${githubExpression('github.run_id')}`,
879
888
  `path: ${githubExpression('runner.temp')}/publish-artifacts`,
880
889
  'merge-multiple: false',
@@ -113,6 +113,62 @@ diff --git a/lib/internal/javascriptRuntimeCapabilities.js b/lib/internal/javasc
113
113
  // Inside a ttsx run this is the user's NODE_OPTIONS, not ttsx's preloads,
114
114
  // which would refuse the cache and run in the probe (#1740).
115
115
  const effectiveEnv = TtsxNodeOptions_1.TtsxNodeOptions.forHelpers(SidecarEnvironment_1.SidecarEnvironment.merge(process.env, env));
116
+ diff --git a/lib/plugin/internal/load/loadProjectPlugins.js b/lib/plugin/internal/load/loadProjectPlugins.js
117
+ --- a/lib/plugin/internal/load/loadProjectPlugins.js
118
+ +++ b/lib/plugin/internal/load/loadProjectPlugins.js
119
+ @@ -275,10 +275,14 @@
120
+ // With the witness of each such reading, so a build of a directory package
121
+ // selection already read keys on that reading instead of probing Go again.
122
+ const environmentWitnesses = new Map();
123
+ + // And one walk of each SDK those readings key on, shared while the load runs
124
+ + // synchronously. A watch delivery ends that batch: the owner may await, and
125
+ + // time and edits pass, so the readings after it walk again.
126
+ const readings = {
127
+ sources: sourceDigests,
128
+ environments: environmentDigests,
129
+ witnesses: environmentWitnesses,
130
+ + goRoots: new Map(),
131
+ };
132
+ // Records describing sources must never land inside one, so the store is
133
+ // admitted for source proofs only once every source of the load is known.
134
+ @@ -314,6 +318,7 @@
135
+ // A worker owns the watch baseline now. Complete this handoff before Go
136
+ // metadata or source proof consumes the roots, preserving #1728 (#1758).
137
+ yield options.onWatchInputs([...interests].sort(), sourceIdentities);
138
+ + readings.goRoots.clear();
139
+ const initialSize = interests.size;
140
+ for (const candidate of candidates) {
141
+ // Nested source-only proposals replace the outer root manifests. Do not
142
+ @@ -324,8 +329,10 @@
143
+ if (reportsPluginSource(directory))
144
+ interests.add(directory);
145
+ }
146
+ - if (interests.size !== initialSize)
147
+ + if (interests.size !== initialSize) {
148
+ yield options.onWatchInputs([...interests].sort(), sourceIdentities);
149
+ + readings.goRoots.clear();
150
+ + }
151
+ }
152
+ const proposals = NativeSourcePackages_1.NativeSourcePackages.propose(candidates.map((candidate) => ({
153
+ ...candidate,
154
+ @@ -370,6 +377,8 @@
155
+ // Admission can now narrow the provisional interests without restamping the
156
+ // retained package/module baselines. Final host errors still keep these roots.
157
+ yield options.onWatchInputs?.(buildDirectories, sourceIdentities);
158
+ + if (options.onWatchInputs !== undefined)
159
+ + readings.goRoots.clear();
160
+ const keyedDirectories = new Set(buildDirectories);
161
+ const linkedContributors = records
162
+ .filter((record) => record.stage === "transform")
163
+ @@ -564,7 +573,7 @@
164
+ env: effectiveEnv,
165
+ sourceDigest,
166
+ environment: environmentDigests.get(directory) ??
167
+ - (0, pluginBuildEnvironment_1.pluginBuildEnvironment)(directory, effectiveEnv, undefined, sourceIdentities),
168
+ + (0, pluginBuildEnvironment_1.pluginBuildEnvironment)(directory, effectiveEnv, undefined, sourceIdentities, readings.goRoots),
169
+ }),
170
+ ])),
171
+ project,
116
172
  diff --git a/lib/plugin/internal/source/GoSourceInputs.js b/lib/plugin/internal/source/GoSourceInputs.js
117
173
  --- a/lib/plugin/internal/source/GoSourceInputs.js
118
174
  +++ b/lib/plugin/internal/source/GoSourceInputs.js
@@ -133,6 +189,40 @@ diff --git a/lib/plugin/internal/source/GoSourceInputs.js b/lib/plugin/internal/
133
189
  // Only the actual `go build` needs ttsc's GOCACHE; read-only metadata spawns
134
190
  // (`go mod edit`, `go env`, `go version`) call goBuildEnv with no cache root
135
191
  // and inherit ambient GOCACHE rather than receiving the managed build
192
+ diff --git a/lib/plugin/internal/source/NativeSourcePackages.d.ts b/lib/plugin/internal/source/NativeSourcePackages.d.ts
193
+ --- a/lib/plugin/internal/source/NativeSourcePackages.d.ts
194
+ +++ b/lib/plugin/internal/source/NativeSourcePackages.d.ts
195
+ @@ -1,5 +1,6 @@
196
+ import { PluginBuildEnvironmentWitness } from "./PluginBuildEnvironmentWitness";
197
+ import { PluginContentIdentities } from "./PluginContentIdentities";
198
+ +import type { GoRootBatch } from "./hashPluginBuildEnvironment";
199
+ import { SourcePluginWorkspace } from "./SourcePluginWorkspace";
200
+ /**
201
+ * Observe Go-selected packages under the native builder's workspace policy.
202
+ @@ -68,6 +69,11 @@
203
+ * directory keys on that reading instead of probing Go again.
204
+ */
205
+ witnesses?: Map<string, PluginBuildEnvironmentWitness.Record>;
206
+ + /**
207
+ + * The load's synchronous batch of SDK observations
208
+ + * (`hashPluginBuildEnvironment`), cleared at each watch delivery.
209
+ + */
210
+ + goRoots?: GoRootBatch;
211
+ }
212
+ /**
213
+ * Observe entries together in a private module layout for their context.
214
+ diff --git a/lib/plugin/internal/source/NativeSourcePackages.js b/lib/plugin/internal/source/NativeSourcePackages.js
215
+ --- a/lib/plugin/internal/source/NativeSourcePackages.js
216
+ +++ b/lib/plugin/internal/source/NativeSourcePackages.js
217
+ @@ -391,7 +391,7 @@
218
+ if (environment === undefined) {
219
+ const hash = node_crypto_1.default.createHash("sha256");
220
+ const witness = new Map();
221
+ - (0, hashPluginBuildEnvironment_1.hashPluginBuildEnvironment)(hash, goBinary, moduleRoot, env, { readFile: (location) => node_fs_1.default.readFileSync(location) }, witness, identities);
222
+ + (0, hashPluginBuildEnvironment_1.hashPluginBuildEnvironment)(hash, goBinary, moduleRoot, env, { readFile: (location) => node_fs_1.default.readFileSync(location) }, witness, identities, readings.goRoots);
223
+ environment = hash.digest("hex");
224
+ readings.environments?.set(resolvedRoot, environment);
225
+ readings.witnesses?.set(resolvedRoot, witness);
136
226
  diff --git a/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js b/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js
137
227
  --- a/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js
138
228
  +++ b/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js
@@ -160,6 +250,245 @@ diff --git a/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js b/lib/
160
250
  worker = created;
161
251
  const retire = () => {
162
252
  if (worker === created)
253
+ diff --git a/lib/plugin/internal/source/collectPluginSourceFiles.d.ts b/lib/plugin/internal/source/collectPluginSourceFiles.d.ts
254
+ --- a/lib/plugin/internal/source/collectPluginSourceFiles.d.ts
255
+ +++ b/lib/plugin/internal/source/collectPluginSourceFiles.d.ts
256
+ @@ -21,7 +21,11 @@
257
+ * A link (a symbolic link or a Windows junction) outside those directories is
258
+ * refused rather than skipped. The build would compile what it names, which
259
+ * neither this list nor anything keyed on it covers; a Go module zip excludes
260
+ - * links from a module's content for the same reason.
261
+ + * links from a module's content for the same reason. A link at or below a name
262
+ + * the go tool passes over (one beginning with `.` or `_`, or `testdata`; `go
263
+ + * help packages`) is skipped like one in an excluded directory: Go neither
264
+ + * compiles it nor embeds a link. Tools keep links there, as cowshed does for a
265
+ + * package's `.cache/lmao`, and refusing one cost the module its source identity.
266
+ *
267
+ * @param root The source directory: a plugin's Go module root, an overlay
268
+ * module, a contributor's source, or a `replace` target outside the module.
269
+ diff --git a/lib/plugin/internal/source/collectPluginSourceFiles.js b/lib/plugin/internal/source/collectPluginSourceFiles.js
270
+ --- a/lib/plugin/internal/source/collectPluginSourceFiles.js
271
+ +++ b/lib/plugin/internal/source/collectPluginSourceFiles.js
272
+ @@ -30,7 +30,11 @@
273
+ * A link (a symbolic link or a Windows junction) outside those directories is
274
+ * refused rather than skipped. The build would compile what it names, which
275
+ * neither this list nor anything keyed on it covers; a Go module zip excludes
276
+ - * links from a module's content for the same reason.
277
+ + * links from a module's content for the same reason. A link at or below a name
278
+ + * the go tool passes over (one beginning with `.` or `_`, or `testdata`; `go
279
+ + * help packages`) is skipped like one in an excluded directory: Go neither
280
+ + * compiles it nor embeds a link. Tools keep links there, as cowshed does for a
281
+ + * package's `.cache/lmao`, and refusing one cost the module its source identity.
282
+ *
283
+ * @param root The source directory: a plugin's Go module root, an overlay
284
+ * module, a contributor's source, or a `replace` target outside the module.
285
+ @@ -72,7 +76,8 @@
286
+ // list, the key, nor a watch covers, and a copy of the module cannot
287
+ // recreate a link without the symlink privilege on Windows.
288
+ if (GoSourceInputs_1.GoSourceInputs.shouldPruneDirectory(entry.name) ||
289
+ - GoSourceInputs_1.GoSourceInputs.shouldOmitSourceFile(entry.name))
290
+ + GoSourceInputs_1.GoSourceInputs.shouldOmitSourceFile(entry.name) ||
291
+ + goToolIgnores(root, full))
292
+ continue;
293
+ throw new Error(`ttsc: plugin source ${root} contains a link at ${full}. A plugin's Go ` +
294
+ `sources are its own files, as a Go module zip holds them: replace the ` +
295
+ @@ -92,4 +97,15 @@
296
+ out.push(full);
297
+ }
298
+ }
299
+ +/**
300
+ + * Whether the go tool passes over `full`: it ignores every directory and file
301
+ + * whose name begins with "." or "_", and directories named "testdata" (`go help
302
+ + * packages`), so nothing at or below such a name is compiled.
303
+ + */
304
+ +function goToolIgnores(root, full) {
305
+ + return node_path_1.default
306
+ + .relative(root, full)
307
+ + .split(node_path_1.default.sep)
308
+ + .some((name) => name.startsWith(".") || name.startsWith("_") || name === "testdata");
309
+ +}
310
+ //# sourceMappingURL=collectPluginSourceFiles.js.map
311
+
312
+ diff --git a/lib/plugin/internal/source/hashPluginBuildEnvironment.d.ts b/lib/plugin/internal/source/hashPluginBuildEnvironment.d.ts
313
+ --- a/lib/plugin/internal/source/hashPluginBuildEnvironment.d.ts
314
+ +++ b/lib/plugin/internal/source/hashPluginBuildEnvironment.d.ts
315
+ @@ -37,6 +37,10 @@
316
+ * @param identities Record store that lets a new process prove the GOROOT
317
+ * corpus and executable bytes from their metadata (`PluginContentIdentities`,
318
+ * #1722); without it every process reads them.
319
+ + * @param goRoots The caller's synchronous batch of SDK observations, by
320
+ + * resolved GOROOT: readings passed the same map walk each SDK once and take
321
+ + * its witness entries from that walk. The caller clears it at any await,
322
+ + * delivery or publication boundary; without it the SDK is walked fresh.
323
+ * @evidence contracts/common.md#principled-implementation Fixed artifact flags, observed compiler bytes/version, selected reported-or-fallback build values, named command executables and selected SDK files enter the same framed identity used by source-state reporting. Fallback values and metadata-qualified reuse are explicit premises, not complete observation of arbitrary toolchain inputs. GOFLAGS enters without ttsc's own compiler-target tag, so the caller's environment reproduces a 7.1 load's digest; targets are separated by their overlay modules in the build key.
324
+ * @evidence contracts/common.md#clear-and-simple-design Private helpers separate compiler identity, Go-reported settings, external variables and SDK content while sharing one hash sink and optional pre-read witness.
325
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Cache signatures include real identity/change metadata and effective invocation context; failed SDK witnessing refuses reuse rather than accepting a VERSION-only proxy.
326
+ @@ -48,4 +52,18 @@
327
+ */
328
+ export declare function hashPluginBuildEnvironment(hash: {
329
+ update(data: string): unknown;
330
+ -}, goBinary: string | undefined, directory: string, env: NodeJS.ProcessEnv, filesystem: SourceBuildFilesystemOperations, witness?: PluginBuildEnvironmentWitness.Record, identities?: PluginContentIdentities.Store): void;
331
+ +}, goBinary: string | undefined, directory: string, env: NodeJS.ProcessEnv, filesystem: SourceBuildFilesystemOperations, witness?: PluginBuildEnvironmentWitness.Record, identities?: PluginContentIdentities.Store, goRoots?: GoRootBatch): void;
332
+ +/** One synchronous batch's SDK observations, by resolved GOROOT (`hashPluginBuildEnvironment`). */
333
+ +export type GoRootBatch = Map<string, GoRootObservation>;
334
+ +/** One SDK walk: the store references it was judged against, its witness entries and its snapshot. */
335
+ +export interface GoRootObservation {
336
+ + readonly references: ReadonlyMap<bigint, bigint> | undefined;
337
+ + readonly observations: PluginBuildEnvironmentWitness.Record;
338
+ + readonly snapshot: {
339
+ + readonly complete: boolean;
340
+ + readonly files: readonly string[];
341
+ + readonly topology: readonly string[];
342
+ + readonly signature: string;
343
+ + readonly separable: boolean;
344
+ + };
345
+ +}
346
+ diff --git a/lib/plugin/internal/source/hashPluginBuildEnvironment.js b/lib/plugin/internal/source/hashPluginBuildEnvironment.js
347
+ --- a/lib/plugin/internal/source/hashPluginBuildEnvironment.js
348
+ +++ b/lib/plugin/internal/source/hashPluginBuildEnvironment.js
349
+ @@ -50,6 +50,10 @@
350
+ * @param identities Record store that lets a new process prove the GOROOT
351
+ * corpus and executable bytes from their metadata (`PluginContentIdentities`,
352
+ * #1722); without it every process reads them.
353
+ + * @param goRoots The caller's synchronous batch of SDK observations, by
354
+ + * resolved GOROOT: readings passed the same map walk each SDK once and take
355
+ + * its witness entries from that walk. The caller clears it at any await,
356
+ + * delivery or publication boundary; without it the SDK is walked fresh.
357
+ * @evidence contracts/common.md#principled-implementation Fixed artifact flags, observed compiler bytes/version, selected reported-or-fallback build values, named command executables and selected SDK files enter the same framed identity used by source-state reporting. Fallback values and metadata-qualified reuse are explicit premises, not complete observation of arbitrary toolchain inputs. GOFLAGS enters without ttsc's own compiler-target tag, so the caller's environment reproduces a 7.1 load's digest; targets are separated by their overlay modules in the build key.
358
+ * @evidence contracts/common.md#clear-and-simple-design Private helpers separate compiler identity, Go-reported settings, external variables and SDK content while sharing one hash sink and optional pre-read witness.
359
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Cache signatures include real identity/change metadata and effective invocation context; failed SDK witnessing refuses reuse rather than accepting a VERSION-only proxy.
360
+ @@ -59,7 +63,7 @@
361
+ * @evidence contracts/performance.md#reuse-equivalent-work Compiler memo identity includes selected path/file metadata and invocation cwd/environment; SDK aggregate reuse requires matching complete ordered metadata/topology. With a record store, a new process reuses the SDK aggregate and executable digests only while their signatures match the recorded ones and every stamp is separable from a freshly minted reference (#1722); `go version` and `go env` stay live because they report toolchain selection no file metadata shows. All of this relies on native metadata distinguishability and sequential observation premises. Physical directories expand once per selection policy while aliases retain edges; optional caller witnesses receive reached selected dependencies.
362
+ * @evidence contracts/performance.md#bound-retention-and-release-resources Compiler, Go-environment-path and SDK maps retain historical distinct tool/context/root keys without eviction; persisted records belong to the single-file collector. SDK population/topology and full individual file reads contribute transient bytes; synchronous probes delegate process/capture lifetime to their owner and do not certify arbitrary descendants are gone. No independent entry/record/file/output byte ceiling is imposed here.
363
+ */
364
+ -function hashPluginBuildEnvironment(hash, goBinary, directory, env, filesystem, witness, identities) {
365
+ +function hashPluginBuildEnvironment(hash, goBinary, directory, env, filesystem, witness, identities, goRoots) {
366
+ // Fixed artifact policy must invalidate binaries and reported source states
367
+ // together, including binaries cached before this policy was introduced.
368
+ hash.update(JSON.stringify(["source-build-flags", GoSourceInputs_1.GoSourceInputs.BUILD_FLAGS]));
369
+ @@ -69,7 +73,7 @@
370
+ resolveGoCompilerIdentity(goBinary, env, directory, witness, identities),
371
+ ]));
372
+ }
373
+ - hashGoBuildEnvironment(hash, goBinary, directory, env, filesystem, witness, identities);
374
+ + hashGoBuildEnvironment(hash, goBinary, directory, env, filesystem, witness, identities, goRoots);
375
+ hashExternalGoBuildEnvironment(hash, env);
376
+ }
377
+ // Go build environment values that can change the produced binary or decide
378
+ @@ -296,8 +300,8 @@
379
+ hash.update(node_fs_1.default.readFileSync(file));
380
+ return hash.digest("hex");
381
+ }
382
+ -function hashGoBuildEnvironment(hash, goBinary, cwd, env, filesystem, witness, identities) {
383
+ - const values = resolveGoBuildEnvironment(goBinary, cwd, env, filesystem, witness, identities);
384
+ +function hashGoBuildEnvironment(hash, goBinary, cwd, env, filesystem, witness, identities, goRoots) {
385
+ + const values = resolveGoBuildEnvironment(goBinary, cwd, env, filesystem, witness, identities, goRoots);
386
+ for (const key of GO_BUILD_ENV_KEYS) {
387
+ const value = values.get(key);
388
+ if (value !== undefined && value !== "") {
389
+ @@ -305,7 +309,7 @@
390
+ }
391
+ }
392
+ }
393
+ -function resolveGoBuildEnvironment(goBinary, cwd, env, filesystem, witness, identities) {
394
+ +function resolveGoBuildEnvironment(goBinary, cwd, env, filesystem, witness, identities, goRoots) {
395
+ const values = new Map();
396
+ if (goBinary !== undefined) {
397
+ const parsed = GoEnvironmentReading_1.GoEnvironmentReading.read(goBinary, cwd, env, GO_BUILD_ENV_KEYS, witness, identities);
398
+ @@ -314,7 +318,7 @@
399
+ for (const key of GO_BUILD_ENV_KEYS) {
400
+ const raw = parsed[key];
401
+ if (typeof raw === "string" && raw !== "") {
402
+ - values.set(key, normalizeGoBuildEnvValue(key, raw, env, filesystem, witness, identities));
403
+ + values.set(key, normalizeGoBuildEnvValue(key, raw, env, filesystem, witness, identities, goRoots));
404
+ }
405
+ }
406
+ }
407
+ @@ -329,19 +333,19 @@
408
+ continue;
409
+ const value = env[key];
410
+ if (value !== undefined && value !== "") {
411
+ - values.set(key, normalizeGoBuildEnvValue(key, value, env, filesystem, witness, identities));
412
+ + values.set(key, normalizeGoBuildEnvValue(key, value, env, filesystem, witness, identities, goRoots));
413
+ }
414
+ }
415
+ return values;
416
+ }
417
+ -function normalizeGoBuildEnvValue(key, value, env, filesystem, witness, identities) {
418
+ +function normalizeGoBuildEnvValue(key, value, env, filesystem, witness, identities, goRoots) {
419
+ if (key === "GOROOT") {
420
+ // Root/version observations also cover a missing SDK. The complete SDK
421
+ // manifest below witnesses contributing files and directories, including
422
+ // nested content changes that do not move the root or VERSION metadata.
423
+ PluginBuildEnvironmentWitness_1.PluginBuildEnvironmentWitness.add(witness, value);
424
+ PluginBuildEnvironmentWitness_1.PluginBuildEnvironmentWitness.add(witness, node_path_1.default.join(value, "VERSION"));
425
+ - return resolveGoRootCacheIdentity(value, filesystem, witness, identities);
426
+ + return resolveGoRootCacheIdentity(value, filesystem, witness, identities, goRoots);
427
+ }
428
+ if (key === "GOFLAGS") {
429
+ // ttsc's compiler-target tag is not the caller's Go environment. Omitting
430
+ @@ -445,10 +449,12 @@
431
+ }
432
+ }
433
+ // GOROOT is usually stable but its selected source/tool payloads contribute to
434
+ -// every plugin key. Retain only the final aggregate
435
+ -// identity, guarded by a fresh metadata/topology manifest on every call. A
436
+ -// changed or incomplete manifest falls through to the record store, then to a
437
+ -// full content read.
438
+ +// every plugin key. Retain only the final aggregate identity, guarded by a
439
+ +// metadata/topology manifest observed once per synchronous batch: a caller's
440
+ +// `goRoots` map (one load between its watch deliveries, cleared at each) shares
441
+ +// one walk and its witness entries across the batch's readings, and a call with
442
+ +// no batch walks fresh. A changed or incomplete manifest falls through to the
443
+ +// record store, then to a full content read.
444
+ //
445
+ // WARNING (#1186, #1722): this map lives only as long as the process. #1186
446
+ // stopped at it, so every CLI launch, worker and bundler restart still read the
447
+ @@ -456,12 +462,12 @@
448
+ // below is what carries the identity across processes; never drop it in favor
449
+ // of this memo alone.
450
+ const goRootIdentityCache = new Map();
451
+ -function resolveGoRootCacheIdentity(goRoot, filesystem, witness, identities) {
452
+ +function resolveGoRootCacheIdentity(goRoot, filesystem, witness, identities, goRoots) {
453
+ const resolved = resolveRealPath(goRoot);
454
+ if (!node_fs_1.default.existsSync(resolved)) {
455
+ return `missing:${goRoot}`;
456
+ }
457
+ - const snapshot = collectGoRootIdentitySnapshot(resolved, witness, identities?.references);
458
+ + const snapshot = observeGoRoot(resolved, witness, identities?.references, goRoots);
459
+ if (!snapshot.complete)
460
+ PluginBuildEnvironmentWitness_1.PluginBuildEnvironmentWitness.refuse(witness, resolved);
461
+ if (snapshot.complete) {
462
+ @@ -502,6 +508,29 @@
463
+ }
464
+ return identity;
465
+ }
466
+ +// One SDK walk per synchronous batch. A reading the batch already walked this
467
+ +// root for takes that walk's snapshot and its first-observed witness entries,
468
+ +// which a later holds() compares against current metadata as it would its own.
469
+ +// A different record store's references make another walk.
470
+ +function observeGoRoot(resolved, witness, references, goRoots) {
471
+ + let observed = goRoots?.get(resolved);
472
+ + if (observed === undefined || observed.references !== references) {
473
+ + if (goRoots === undefined)
474
+ + return collectGoRootIdentitySnapshot(resolved, witness, references);
475
+ + const observations = new Map();
476
+ + observed = {
477
+ + observations,
478
+ + references,
479
+ + snapshot: collectGoRootIdentitySnapshot(resolved, observations, references),
480
+ + };
481
+ + goRoots.set(resolved, observed);
482
+ + }
483
+ + if (witness !== undefined)
484
+ + for (const [key, signature] of observed.observations)
485
+ + if (!witness.has(key))
486
+ + witness.set(key, signature);
487
+ + return observed.snapshot;
488
+ +}
489
+ function collectGoRootIdentitySnapshot(root, witness, references) {
490
+ const out = [];
491
+ const state = { complete: true, separable: references !== undefined };
163
492
  diff --git a/lib/plugin/internal/source/inspectPluginBuildLock.js b/lib/plugin/internal/source/inspectPluginBuildLock.js
164
493
  --- a/lib/plugin/internal/source/inspectPluginBuildLock.js
165
494
  +++ b/lib/plugin/internal/source/inspectPluginBuildLock.js
@@ -204,6 +533,65 @@ diff --git a/lib/plugin/internal/source/inspectPluginBuildLock.js b/lib/plugin/i
204
533
  /**
205
534
  * Whether a path lookup proves absence. Permission and sharing failures are
206
535
  * inconclusive, never evidence of a released or old abandoned generation.
536
+ diff --git a/lib/plugin/internal/source/pluginBuildEnvironment.d.ts b/lib/plugin/internal/source/pluginBuildEnvironment.d.ts
537
+ --- a/lib/plugin/internal/source/pluginBuildEnvironment.d.ts
538
+ +++ b/lib/plugin/internal/source/pluginBuildEnvironment.d.ts
539
+ @@ -1,5 +1,6 @@
540
+ import type { PluginBuildEnvironmentWitness } from "./PluginBuildEnvironmentWitness";
541
+ import type { PluginContentIdentities } from "./PluginContentIdentities";
542
+ +import type { GoRootBatch } from "./hashPluginBuildEnvironment";
543
+ /**
544
+ * The digest of the environment a plugin build in `directory` is keyed on: the
545
+ * Go compiler the build resolves there, the Go build environment `go env`
546
+ @@ -23,6 +24,8 @@
547
+ * carries (`hashPluginBuildEnvironment`).
548
+ * @param identities Record store that lets a new process prove the SDK and
549
+ * executables from metadata (#1722).
550
+ + * @param goRoots The caller's synchronous batch of SDK observations
551
+ + * (`hashPluginBuildEnvironment`), or `undefined` to walk the SDK fresh.
552
+ * @evidence contracts/common.md#principled-implementation The digest uses the same resolved compiler and environment serializer as the binary key, so reported toolchain state denotes the inputs actually used by the build.
553
+ * @evidence contracts/common.md#clear-and-simple-design Compiler selection, executable resolution and hashing each stay with their owning helper; this function only composes one environment reading.
554
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The result comes from real Go/environment inputs, not a fixed compiler version or a caller-specific substitute.
555
+ @@ -30,7 +33,7 @@
556
+ * @evidence contracts/portability.md#os-neutral-implementation Executable identity is resolved before probing, and Node filesystem/process boundaries implement native spelling rather than assuming Windows or POSIX paths are interchangeable.
557
+ * @evidence contracts/performance.md#efficient-algorithms The wrapper resolves the compiler/tool under the supplied environment before delegating full environment hashing. Native resolution/probes, SDK metadata/name/path sorting and changed-manifest full content reads contribute cost; the final hash output is fixed-width but streamed identity/input text and full-file buffers are not. No independent duplicate source-directory digest scan is added here.
558
+ *
559
+ - * @evidence contracts/performance.md#reuse-equivalent-work This is the fresh-reading boundary required by builds: the Go probes run on every call. Content digests of the SDK and executables are shared across processes only through the supplied record store's separable-signature proof; processPluginBuildEnvironment owns reuse of the whole reading when a consumer permits it.
560
+ + * @evidence contracts/performance.md#reuse-equivalent-work This is the fresh-reading boundary required by builds: the Go probes run on every call. The SDK walk is fresh too, except inside the caller's synchronous batch (`goRoots`: one load between its watch deliveries, cleared at each), whose readings share one SDK observation as the witness contract allows. Content digests of the SDK and executables are shared across processes only through the supplied record store's separable-signature proof; processPluginBuildEnvironment owns reuse of the whole reading when a consumer permits it.
561
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources Its digest and filesystem adapter are call-local; retained compiler/content memo ownership belongs to the hasher.
562
+ */
563
+ -export declare function pluginBuildEnvironment(directory: string, env?: NodeJS.ProcessEnv, witness?: PluginBuildEnvironmentWitness.Record, identities?: PluginContentIdentities.Store): string;
564
+ +export declare function pluginBuildEnvironment(directory: string, env?: NodeJS.ProcessEnv, witness?: PluginBuildEnvironmentWitness.Record, identities?: PluginContentIdentities.Store, goRoots?: GoRootBatch): string;
565
+ diff --git a/lib/plugin/internal/source/pluginBuildEnvironment.js b/lib/plugin/internal/source/pluginBuildEnvironment.js
566
+ --- a/lib/plugin/internal/source/pluginBuildEnvironment.js
567
+ +++ b/lib/plugin/internal/source/pluginBuildEnvironment.js
568
+ @@ -32,6 +32,8 @@
569
+ * carries (`hashPluginBuildEnvironment`).
570
+ * @param identities Record store that lets a new process prove the SDK and
571
+ * executables from metadata (#1722).
572
+ + * @param goRoots The caller's synchronous batch of SDK observations
573
+ + * (`hashPluginBuildEnvironment`), or `undefined` to walk the SDK fresh.
574
+ * @evidence contracts/common.md#principled-implementation The digest uses the same resolved compiler and environment serializer as the binary key, so reported toolchain state denotes the inputs actually used by the build.
575
+ * @evidence contracts/common.md#clear-and-simple-design Compiler selection, executable resolution and hashing each stay with their owning helper; this function only composes one environment reading.
576
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The result comes from real Go/environment inputs, not a fixed compiler version or a caller-specific substitute.
577
+ @@ -39,13 +41,13 @@
578
+ * @evidence contracts/portability.md#os-neutral-implementation Executable identity is resolved before probing, and Node filesystem/process boundaries implement native spelling rather than assuming Windows or POSIX paths are interchangeable.
579
+ * @evidence contracts/performance.md#efficient-algorithms The wrapper resolves the compiler/tool under the supplied environment before delegating full environment hashing. Native resolution/probes, SDK metadata/name/path sorting and changed-manifest full content reads contribute cost; the final hash output is fixed-width but streamed identity/input text and full-file buffers are not. No independent duplicate source-directory digest scan is added here.
580
+ *
581
+ - * @evidence contracts/performance.md#reuse-equivalent-work This is the fresh-reading boundary required by builds: the Go probes run on every call. Content digests of the SDK and executables are shared across processes only through the supplied record store's separable-signature proof; processPluginBuildEnvironment owns reuse of the whole reading when a consumer permits it.
582
+ + * @evidence contracts/performance.md#reuse-equivalent-work This is the fresh-reading boundary required by builds: the Go probes run on every call. The SDK walk is fresh too, except inside the caller's synchronous batch (`goRoots`: one load between its watch deliveries, cleared at each), whose readings share one SDK observation as the witness contract allows. Content digests of the SDK and executables are shared across processes only through the supplied record store's separable-signature proof; processPluginBuildEnvironment owns reuse of the whole reading when a consumer permits it.
583
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources Its digest and filesystem adapter are call-local; retained compiler/content memo ownership belongs to the hasher.
584
+ */
585
+ -function pluginBuildEnvironment(directory, env = process.env, witness, identities) {
586
+ +function pluginBuildEnvironment(directory, env = process.env, witness, identities, goRoots) {
587
+ const goBinary = GoToolResolution_1.GoToolResolution.resolveGoToolForBuild((0, resolveGoCompiler_1.resolveGoCompiler)(env).binary, env, directory, witness);
588
+ const hash = node_crypto_1.default.createHash("sha256");
589
+ - (0, hashPluginBuildEnvironment_1.hashPluginBuildEnvironment)(hash, goBinary, directory, env, { readFile: (location) => node_fs_1.default.readFileSync(location) }, witness, identities);
590
+ + (0, hashPluginBuildEnvironment_1.hashPluginBuildEnvironment)(hash, goBinary, directory, env, { readFile: (location) => node_fs_1.default.readFileSync(location) }, witness, identities, goRoots);
591
+ return hash.digest("hex");
592
+ }
593
+ //# sourceMappingURL=pluginBuildEnvironment.js.map
594
+
207
595
  diff --git a/lib/plugin/internal/source/waitForPluginBinary.js b/lib/plugin/internal/source/waitForPluginBinary.js
208
596
  --- a/lib/plugin/internal/source/waitForPluginBinary.js
209
597
  +++ b/lib/plugin/internal/source/waitForPluginBinary.js
@@ -5,6 +5,18 @@ description: >
5
5
  the store cache (host store). On ephemeral runners installs a single-user Nix and restores /nix itself from the
6
6
  actions cache: store paths and the Nix database come back as files, so no NAR is imported and no daemon is needed.
7
7
 
8
+ inputs:
9
+ records-workflow:
10
+ description: >
11
+ The workflow whose pushes keep the bounded-exec task records this job's scope starts from, for a workflow whose
12
+ tests are another workflow's (a release's are CI's). Blank means this workflow.
13
+ required: false
14
+ default: ''
15
+ records-job:
16
+ description: The job of that workflow. Blank means this job.
17
+ required: false
18
+ default: ''
19
+
8
20
  outputs:
9
21
  devenv-cache-hit:
10
22
  description: Whether the devenv/direnv cache restored from the exact primary key.
@@ -83,17 +95,71 @@ runs:
83
95
  # Hash the exact identity (not a lossy path slug); keep cache artifacts
84
96
  # and their metadata DB together, warm across runs of the same pull
85
97
  # request or ref and job.
98
+ #
99
+ # A scope starts from the task records of other pushes. Each bounded-exec
100
+ # leaf is charged its task's last recorded memory peak
101
+ # (specs/cowshed/05_gateway.md, "Without mbx, every Nx run budgets
102
+ # itself"), and a task whose record the scope lacks is charged nothing, so
103
+ # the scope's first run of it admits the leaf on CPU tokens alone. A pull
104
+ # request starts from its base branch's pushes, which the same workflow and
105
+ # job run in the base's scope. A workflow whose tests are another
106
+ # workflow's (a release's are CI's) names that workflow and job in
107
+ # records-workflow and records-job, and starts from the pushes to its own
108
+ # ref there. A scope that holds no record of a task takes a copy of the
109
+ # last one its starting scope holds (its verdict.json, nothing beside it),
110
+ # and its own runs replace it. The copy is the record itself, never a
111
+ # second store.
86
112
  - name: 📂 Locate the Nx cache on the shared bind
87
113
  if: steps.runner-kind.outputs.host == 'true'
88
114
  shell: bash
89
115
  env:
116
+ NX_CACHE_BIND: /var/cache/ci/nx
90
117
  NX_CACHE_REPO: ${{ github.repository }}
91
118
  NX_CACHE_LANE: ${{ github.workflow }}
92
119
  SCOPE_REF: ${{ github.event.pull_request.number || github.ref }}
120
+ # A pull request's base branch, whose pushes run under refs/heads/<it>;
121
+ # empty for a push.
122
+ BASE_REF: ${{ github.base_ref }}
123
+ # The workflow and job whose pushes keep the records this scope starts
124
+ # from, when they are not this workflow's and job's; empty for both.
125
+ RECORDS_WORKFLOW: ${{ inputs.records-workflow }}
126
+ RECORDS_JOB: ${{ inputs.records-job }}
93
127
  run: |
94
- lane=$(printf '%s' "$NX_CACHE_LANE" | tr '[:upper:]' '[:lower:]' | tr -cs 'a-z0-9._-' '-')
95
- scope=$(printf '%s\0%s\0%s\0%s\0%s' "$GITHUB_WORKFLOW" "$SCOPE_REF" "$GITHUB_JOB" "$RUNNER_OS" "$RUNNER_ARCH" | git hash-object --stdin)
96
- NX_CACHE_ROOT="/var/cache/ci/nx/$NX_CACHE_REPO/${lane:-default}/$scope"
128
+ # A workflow's directory under the shared bind: its name, slugged.
129
+ lane_of() { printf '%s' "$1" | tr '[:upper:]' '[:lower:]' | tr -cs 'a-z0-9._-' '-'; }
130
+ lane=$(lane_of "$NX_CACHE_LANE")
131
+ # The cache root of the run identity SCOPE_REF names.
132
+ scope_root() {
133
+ scope=$(printf '%s\0%s\0%s\0%s\0%s' "$GITHUB_WORKFLOW" "$SCOPE_REF" "$GITHUB_JOB" "$RUNNER_OS" "$RUNNER_ARCH" | git hash-object --stdin)
134
+ printf '%s' "$NX_CACHE_BIND/$NX_CACHE_REPO/${lane:-default}/$scope"
135
+ }
136
+ NX_CACHE_ROOT=$(scope_root)
137
+ records="$NX_CACHE_ROOT/workspace-data/bounded-exec"
138
+ # The cache root of the scope that job $2 of workflow $1 runs the pushes to ref $3 in.
139
+ scope_root_of() {
140
+ lane=$(lane_of "$1") GITHUB_WORKFLOW="$1" GITHUB_JOB="$2" SCOPE_REF="$3" scope_root
141
+ }
142
+ from_workflow=${RECORDS_WORKFLOW:-$GITHUB_WORKFLOW}
143
+ from_ref=${BASE_REF:+refs/heads/$BASE_REF}
144
+ from_ref=${from_ref:-$SCOPE_REF}
145
+ from=$(scope_root_of "$from_workflow" "${RECORDS_JOB:-$GITHUB_JOB}" "$from_ref")
146
+ if [ "$from" != "$NX_CACHE_ROOT" ]; then
147
+ copied=0
148
+ for verdict in "$from"/workspace-data/bounded-exec/*/verdict.json; do
149
+ [ -e "$verdict" ] || continue
150
+ task=$(basename "$(dirname "$verdict")")
151
+ [ -e "$records/$task/verdict.json" ] && continue
152
+ mkdir -p "$records/$task"
153
+ # A task that starts again in the scope it came from clears its record first: one gone since the
154
+ # listing has none to give.
155
+ if cp "$verdict" "$records/$task/verdict.json"; then
156
+ copied=$((copied + 1))
157
+ elif [ -e "$verdict" ]; then
158
+ exit 1
159
+ fi
160
+ done
161
+ if [ "$copied" -gt 0 ]; then echo "task records: $copied from the $from_workflow scope of $from_ref"; fi
162
+ fi
97
163
  mkdir -p "$NX_CACHE_ROOT/cache" "$NX_CACHE_ROOT/workspace-data"
98
164
  {
99
165
  echo "NX_CACHE_DIRECTORY=$NX_CACHE_ROOT/cache"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smoothbricks/nx-plugin",
3
- "version": "0.7.6",
3
+ "version": "0.7.8",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "main": "./loader.js",
@@ -435,7 +435,7 @@
435
435
  "{workspaceRoot}/packages/cowshed/crates/cowshed-core/src/port_zero.cjs"
436
436
  ],
437
437
  "options": {
438
- "command": "bun test --timeout=0 ./src/executors/bounded-exec/__tests__/cpu-pool.silence.ts",
438
+ "command": "bun test --config=/dev/null --timeout=0 ./src/executors/bounded-exec/__tests__/cpu-pool.silence.ts",
439
439
  "cwd": "{projectRoot}",
440
440
  "idleTimeoutMs": 180000,
441
441
  "killAfterMs": 10000
@@ -652,7 +652,7 @@
652
652
  "@nx/js": "24.0.3",
653
653
  "@smoothbricks/build-inputs": "0.0.2",
654
654
  "@smoothbricks/cargo-retain": "0.0.2",
655
- "@smoothbricks/cowshed": "0.4.5",
655
+ "@smoothbricks/cowshed": "0.4.6",
656
656
  "@smoothbricks/nextest-extract": "0.0.2",
657
657
  "jsonc-parser": "^3.3.1",
658
658
  "minimatch": "10.2.5",