@smoothbricks/nx-plugin 0.6.2 → 0.7.0

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 (177) hide show
  1. package/README.md +417 -171
  2. package/dist/.build-inputs.json +39 -28
  3. package/dist/bin/smoo-nx-go-test-build.d.ts +3 -0
  4. package/dist/bin/smoo-nx-go-test-build.d.ts.map +1 -0
  5. package/dist/bin/smoo-nx-go-test-build.js +79 -0
  6. package/dist/bin/smoo-nx-go-test-run.d.ts +3 -0
  7. package/dist/bin/smoo-nx-go-test-run.d.ts.map +1 -0
  8. package/dist/bin/smoo-nx-go-test-run.js +129 -0
  9. package/dist/bin/smoo-nx-publish.d.ts +3 -0
  10. package/dist/bin/smoo-nx-publish.d.ts.map +1 -0
  11. package/dist/bin/smoo-nx-publish.js +3 -0
  12. package/dist/bounded-test-policy.d.ts +1 -1
  13. package/dist/bounded-test-policy.d.ts.map +1 -1
  14. package/dist/bounded-test-policy.js +9 -8
  15. package/dist/cargo-retention-hook.d.ts +6 -2
  16. package/dist/cargo-retention-hook.d.ts.map +1 -1
  17. package/dist/cargo-retention-hook.js +13 -7
  18. package/dist/cargo-workspace.d.ts +10 -20
  19. package/dist/cargo-workspace.d.ts.map +1 -1
  20. package/dist/cargo-workspace.js +12 -22
  21. package/dist/cross-check-policy.d.ts +2 -2
  22. package/dist/cross-check-policy.js +2 -2
  23. package/dist/deploy-policy.d.ts +6 -0
  24. package/dist/deploy-policy.d.ts.map +1 -1
  25. package/dist/deploy-policy.js +11 -0
  26. package/dist/eslint-file-set.d.ts +4 -1
  27. package/dist/eslint-file-set.d.ts.map +1 -1
  28. package/dist/eslint-sources.d.ts +25 -0
  29. package/dist/eslint-sources.d.ts.map +1 -0
  30. package/dist/eslint-sources.js +99 -0
  31. package/dist/executors/all-verdicts/executor.d.ts +2 -1
  32. package/dist/executors/all-verdicts/executor.d.ts.map +1 -1
  33. package/dist/executors/all-verdicts/executor.js +48 -2
  34. package/dist/executors/all-verdicts/schema.d.ts +13 -0
  35. package/dist/executors/all-verdicts/schema.d.ts.map +1 -1
  36. package/dist/executors/all-verdicts/schema.js +7 -0
  37. package/dist/executors/bounded-exec/bounds.d.ts +57 -8
  38. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
  39. package/dist/executors/bounded-exec/bounds.js +100 -11
  40. package/dist/executors/bounded-exec/executor.d.ts +2 -1
  41. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  42. package/dist/executors/bounded-exec/executor.js +289 -34
  43. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +2 -0
  44. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  45. package/dist/executors/bounded-exec/hang-diagnostics.js +2 -2
  46. package/dist/executors/bounded-exec/mbx-pool.d.ts +56 -10
  47. package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
  48. package/dist/executors/bounded-exec/mbx-pool.js +145 -11
  49. package/dist/executors/bounded-exec/mbx-queue.d.ts +30 -0
  50. package/dist/executors/bounded-exec/mbx-queue.d.ts.map +1 -0
  51. package/dist/executors/bounded-exec/mbx-queue.js +229 -0
  52. package/dist/executors/bounded-exec/progress.d.ts +9 -2
  53. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  54. package/dist/executors/bounded-exec/progress.js +151 -25
  55. package/dist/executors/bounded-exec/runner-sizing.d.ts +40 -2
  56. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
  57. package/dist/executors/bounded-exec/runner-sizing.js +55 -4
  58. package/dist/executors/bounded-exec/runtime-pin.js +1 -1
  59. package/dist/executors/bounded-exec/test-result-writer.d.ts +30 -0
  60. package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -0
  61. package/dist/executors/bounded-exec/test-result-writer.js +126 -0
  62. package/dist/executors/bounded-exec/test-results.d.ts +33 -0
  63. package/dist/executors/bounded-exec/test-results.d.ts.map +1 -0
  64. package/dist/executors/bounded-exec/test-results.js +33 -0
  65. package/dist/executors/bounded-exec/verdict.d.ts +26 -2
  66. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  67. package/dist/executors/bounded-exec/verdict.js +108 -4
  68. package/dist/executors/wrangler-deploy/deploy-hash.d.ts +10 -0
  69. package/dist/executors/wrangler-deploy/deploy-hash.d.ts.map +1 -0
  70. package/dist/executors/wrangler-deploy/deploy-hash.js +14 -0
  71. package/dist/executors/wrangler-deploy/executor.d.ts +24 -0
  72. package/dist/executors/wrangler-deploy/executor.d.ts.map +1 -0
  73. package/dist/executors/wrangler-deploy/executor.js +43 -0
  74. package/dist/executors/wrangler-deploy/hasher.d.ts +27 -0
  75. package/dist/executors/wrangler-deploy/hasher.d.ts.map +1 -0
  76. package/dist/executors/wrangler-deploy/hasher.js +90 -0
  77. package/dist/executors/wrangler-deploy/schema.d.ts +5 -0
  78. package/dist/executors/wrangler-deploy/schema.d.ts.map +1 -0
  79. package/dist/go-tests.d.ts +30 -0
  80. package/dist/go-tests.d.ts.map +1 -0
  81. package/dist/go-tests.js +43 -0
  82. package/dist/index.d.ts +12 -4
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +338 -295
  85. package/dist/managed-files/files.d.ts.map +1 -1
  86. package/dist/managed-files/files.js +5 -0
  87. package/dist/nx-publish.d.ts +24 -0
  88. package/dist/nx-publish.d.ts.map +1 -0
  89. package/dist/nx-publish.js +150 -0
  90. package/dist/process-group.js +2 -2
  91. package/dist/runtime-input-policy.d.ts +17 -3
  92. package/dist/runtime-input-policy.d.ts.map +1 -1
  93. package/dist/runtime-input-policy.js +4 -4
  94. package/dist/test-timings.d.ts +23 -4
  95. package/dist/test-timings.d.ts.map +1 -1
  96. package/dist/test-timings.js +72 -12
  97. package/dist/tool-bins.d.ts +6 -8
  98. package/dist/tool-bins.d.ts.map +1 -1
  99. package/dist/tool-bins.js +7 -5
  100. package/dist/version-actions.cjs +10 -11
  101. package/dist/version-actions.d.cts.map +1 -1
  102. package/dist/workspace-config-policy.d.ts.map +1 -1
  103. package/dist/workspace-config-policy.js +17 -22
  104. package/dist/workspace-index.d.ts +7 -0
  105. package/dist/workspace-index.d.ts.map +1 -1
  106. package/dist/workspace-index.js +11 -0
  107. package/dist/workspace-manifest.js +3 -3
  108. package/executors.json +7 -6
  109. package/managed/raw/patches/nx@23.2.1.patch +118 -24
  110. package/managed/raw/patches/ttsc@0.34.1.patch +139 -0
  111. package/managed/raw/tooling/devenv +1 -2
  112. package/managed/raw/tooling/direnv/developer-links.ts +124 -51
  113. package/managed/raw/tooling/direnv/devenv.smoo.nix +34 -15
  114. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -10
  115. package/managed/raw/tooling/direnv/installed-bun-links.ts +7 -6
  116. package/managed/raw/tooling/direnv/setup-environment.ts +49 -24
  117. package/managed/raw/tooling/direnv/ttsc-env.sh +8 -6
  118. package/managed/raw/tooling/git-hooks/pinned-revisions-served.ts +252 -0
  119. package/managed/raw/tooling/git-hooks/pre-push.sh +34 -32
  120. package/managed/templates/github/actions/cache-node-modules/action.yml +1 -1
  121. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +12 -11
  122. package/package.json +277 -11
  123. package/runtime/nx-publish/.build-inputs.json +11 -0
  124. package/runtime/nx-publish/cache_adapter.js +45 -0
  125. package/runtime/nx-publish/nx_publish.js +60 -0
  126. package/runtime-input.sh +62 -26
  127. package/src/bin/smoo-nx-go-test-build.ts +83 -0
  128. package/src/bin/smoo-nx-go-test-run.ts +140 -0
  129. package/src/bin/smoo-nx-publish.ts +4 -0
  130. package/src/bounded-test-policy.ts +9 -8
  131. package/src/cargo-retention-hook.ts +16 -10
  132. package/src/cargo-workspace.ts +12 -24
  133. package/src/cross-check-policy.ts +2 -2
  134. package/src/deploy-policy.ts +11 -0
  135. package/src/eslint-file-set.ts +4 -1
  136. package/src/eslint-sources.ts +134 -0
  137. package/src/executors/all-verdicts/executor.ts +58 -3
  138. package/src/executors/all-verdicts/schema.json +4 -0
  139. package/src/executors/all-verdicts/schema.ts +14 -0
  140. package/src/executors/bounded-exec/bounds.ts +132 -15
  141. package/src/executors/bounded-exec/executor.ts +329 -34
  142. package/src/executors/bounded-exec/hang-diagnostics.ts +3 -2
  143. package/src/executors/bounded-exec/mbx-pool.ts +158 -17
  144. package/src/executors/bounded-exec/mbx-queue.ts +170 -0
  145. package/src/executors/bounded-exec/progress.ts +171 -18
  146. package/src/executors/bounded-exec/runner-sizing.ts +73 -7
  147. package/src/executors/bounded-exec/runtime-pin.ts +1 -1
  148. package/src/executors/bounded-exec/test-result-writer.ts +152 -0
  149. package/src/executors/bounded-exec/test-results.ts +39 -0
  150. package/src/executors/bounded-exec/verdict.ts +115 -5
  151. package/src/executors/wrangler-deploy/deploy-hash.ts +15 -0
  152. package/src/executors/wrangler-deploy/executor.ts +63 -0
  153. package/src/executors/wrangler-deploy/hasher.ts +111 -0
  154. package/src/executors/wrangler-deploy/schema.json +16 -0
  155. package/src/executors/wrangler-deploy/schema.ts +4 -0
  156. package/src/go-tests.ts +67 -0
  157. package/src/index.ts +368 -323
  158. package/src/managed-files/files.ts +5 -0
  159. package/src/nx-publish.ts +157 -0
  160. package/src/process-group.ts +2 -2
  161. package/src/runtime-input-policy.ts +4 -4
  162. package/src/test-timings.ts +72 -14
  163. package/src/tool-bins.ts +13 -9
  164. package/src/version-actions.cts +10 -11
  165. package/src/workspace-config-policy.ts +20 -29
  166. package/src/workspace-index.ts +12 -0
  167. package/src/workspace-manifest.ts +3 -3
  168. package/test-timings.json +131 -125
  169. package/dist/executors/clean-outputs/executor.d.ts +0 -26
  170. package/dist/executors/clean-outputs/executor.d.ts.map +0 -1
  171. package/dist/executors/clean-outputs/executor.js +0 -83
  172. package/dist/executors/clean-outputs/schema.d.ts +0 -4
  173. package/dist/executors/clean-outputs/schema.d.ts.map +0 -1
  174. package/src/executors/clean-outputs/executor.ts +0 -131
  175. package/src/executors/clean-outputs/schema.json +0 -15
  176. package/src/executors/clean-outputs/schema.ts +0 -3
  177. /package/dist/executors/{clean-outputs → wrangler-deploy}/schema.js +0 -0
@@ -140,7 +140,11 @@ export function isTestRunnerTargetName(name) {
140
140
  }
141
141
  const nxJsTypescriptPlugin = '@nx/js/typescript';
142
142
  const smoothBricksNxPlugin = '@smoothbricks/nx-plugin';
143
- const cleanOutputsExecutor = '@smoothbricks/nx-plugin:clean-outputs';
143
+ /**
144
+ * The executor of the retired `clean` target, which deleted declared outputs file by file. Build state is removed whole
145
+ * instead (cowshed rm, mbx gc), so a `targetDefaults.clean` naming it is refused and removed.
146
+ */
147
+ const retiredCleanOutputsExecutor = '@smoothbricks/nx-plugin:clean-outputs';
144
148
  const ciWorkflowNamedInput = ['{workspaceRoot}/.github/workflows/ci.yml'];
145
149
  const inferredTestTypecheckTarget = 'typecheck-tests';
146
150
  /**
@@ -189,6 +193,12 @@ export function checkWorkspaceConfig(nxJson) {
189
193
  'Per-project inference selects current library or build outputs before test typechecking.',
190
194
  });
191
195
  }
196
+ if (isRetiredCleanTargetDefault(targetDefaults, targetName)) {
197
+ issues.push({
198
+ path: 'nx.json',
199
+ message: `targetDefaults.clean names the retired ${retiredCleanOutputsExecutor}; run smoo monorepo update to remove it`,
200
+ });
201
+ }
192
202
  }
193
203
  }
194
204
  // Build target default
@@ -196,8 +206,6 @@ export function checkWorkspaceConfig(nxJson) {
196
206
  // Test target default: dependsOn is inferred per project (cargo-test vs ^build/build)
197
207
  validateTestTargetDefault(nxJson, 'nx.json', issues);
198
208
  validateLintTargetDefault(nxJson, 'nx.json', issues);
199
- // Clean target default
200
- validateCleanTargetDefault(nxJson, 'nx.json', issues);
201
209
  // Named input defaults
202
210
  validateNamedInputDefaults(nxJson, 'nx.json', issues);
203
211
  if (nxJson.cacheDirectory !== CHECKOUT_NX_CACHE_DIRECTORY) {
@@ -243,7 +251,6 @@ export function applyWorkspaceConfig(nxJson) {
243
251
  changed = applyBuildTargetDefault(nxJson) || changed;
244
252
  changed = applyTestTargetDefault(nxJson) || changed;
245
253
  changed = applyLintTargetDefault(nxJson) || changed;
246
- changed = applyCleanTargetDefault(nxJson) || changed;
247
254
  changed = applyNamedInputDefaults(nxJson) || changed;
248
255
  const plugins = validatePlugins(nxJson.plugins === undefined ? [] : nxJson.plugins);
249
256
  if (plugins.success) {
@@ -353,16 +360,6 @@ function validateBuildTargetDefault(nxJson, nxJsonPath, issues) {
353
360
  }
354
361
  }
355
362
  }
356
- function validateCleanTargetDefault(nxJson, nxJsonPath, issues) {
357
- const targetDefaults = recordProperty(nxJson, 'targetDefaults');
358
- const clean = targetDefaults ? recordProperty(targetDefaults, 'clean') : null;
359
- if (!clean || clean.executor !== cleanOutputsExecutor) {
360
- issues.push({ path: nxJsonPath, message: `targetDefaults.clean.executor must be ${cleanOutputsExecutor}` });
361
- }
362
- if (clean?.cache !== false) {
363
- issues.push({ path: nxJsonPath, message: 'targetDefaults.clean.cache must be false' });
364
- }
365
- }
366
363
  function validateNamedInputDefaults(nxJson, nxJsonPath, issues) {
367
364
  const namedInputs = recordProperty(nxJson, 'namedInputs');
368
365
  if (!namedInputs) {
@@ -483,13 +480,6 @@ function applyLintTargetDefault(nxJson) {
483
480
  }
484
481
  return changed;
485
482
  }
486
- function applyCleanTargetDefault(nxJson) {
487
- const targetDefaults = getOrCreateRecord(nxJson, 'targetDefaults');
488
- const clean = getOrCreateRecord(targetDefaults, 'clean');
489
- let changed = setStringProperty(clean, 'executor', cleanOutputsExecutor);
490
- changed = setBooleanProperty(clean, 'cache', false) || changed;
491
- return changed;
492
- }
493
483
  function applyNamedInputDefaults(nxJson) {
494
484
  const namedInputs = getOrCreateRecord(nxJson, 'namedInputs');
495
485
  let changed = false;
@@ -528,13 +518,18 @@ function removeDisallowedTargetDefaults(nxJson) {
528
518
  }
529
519
  let changed = false;
530
520
  for (const targetName of Object.keys(targetDefaults)) {
531
- if (targetName.includes(':') || targetName === inferredTestTypecheckTarget) {
521
+ if (targetName.includes(':') ||
522
+ targetName === inferredTestTypecheckTarget ||
523
+ isRetiredCleanTargetDefault(targetDefaults, targetName)) {
532
524
  delete targetDefaults[targetName];
533
525
  changed = true;
534
526
  }
535
527
  }
536
528
  return changed;
537
529
  }
530
+ function isRetiredCleanTargetDefault(targetDefaults, targetName) {
531
+ return targetName === 'clean' && recordProperty(targetDefaults, 'clean')?.executor === retiredCleanOutputsExecutor;
532
+ }
538
533
  function isPreciseProductionNamedInput(production) {
539
534
  let hasPositiveProjectInput = false;
540
535
  for (const input of production) {
@@ -9,4 +9,11 @@
9
9
  * test fixture or a foreign checkout, is indexed by this process's context.
10
10
  */
11
11
  export declare function globIndexedFiles(workspaceRoot: string, globs: string[]): Promise<string[]>;
12
+ /**
13
+ * Like {@link globIndexedFiles}, read from the filesystem now: a new native context, the same walk and the same ignore
14
+ * rules, never the table of this process or of the daemon. A table only learns of a write when a watcher event reaches
15
+ * it, so one the watcher missed leaves a deleted file listed and an added one unlisted until that process ends. What
16
+ * runs on the files as they are asks here; what describes a graph asks {@link globIndexedFiles}.
17
+ */
18
+ export declare function freshIndexedFiles(workspaceRoot: string, globs: string[]): string[];
12
19
  //# sourceMappingURL=workspace-index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-index.d.ts","sourceRoot":"","sources":["../src/workspace-index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAIhG"}
1
+ {"version":3,"file":"workspace-index.d.ts","sourceRoot":"","sources":["../src/workspace-index.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAIhG;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAElF"}
@@ -1,3 +1,5 @@
1
+ import native from 'nx/src/native/index.js';
2
+ import { workspaceDataDirectoryForWorkspace } from 'nx/src/utils/cache-directory.js';
1
3
  import { globWithWorkspaceContext, globWithWorkspaceContextSync } from 'nx/src/utils/workspace-context.js';
2
4
  import { workspaceRoot as daemonWorkspaceRoot } from 'nx/src/utils/workspace-root.js';
3
5
  /**
@@ -15,3 +17,12 @@ export async function globIndexedFiles(workspaceRoot, globs) {
15
17
  ? globWithWorkspaceContext(workspaceRoot, globs)
16
18
  : globWithWorkspaceContextSync(workspaceRoot, globs);
17
19
  }
20
+ /**
21
+ * Like {@link globIndexedFiles}, read from the filesystem now: a new native context, the same walk and the same ignore
22
+ * rules, never the table of this process or of the daemon. A table only learns of a write when a watcher event reaches
23
+ * it, so one the watcher missed leaves a deleted file listed and an added one unlisted until that process ends. What
24
+ * runs on the files as they are asks here; what describes a graph asks {@link globIndexedFiles}.
25
+ */
26
+ export function freshIndexedFiles(workspaceRoot, globs) {
27
+ return new native.WorkspaceContext(workspaceRoot, workspaceDataDirectoryForWorkspace(workspaceRoot)).glob(globs);
28
+ }
@@ -28,9 +28,9 @@ export function catalogName(value) {
28
28
  /**
29
29
  * Where Bun reads a root manifest's catalogs: from the object form of `workspaces` once it holds `catalog` or
30
30
  * `catalogs`, and then from nowhere else; otherwise from the manifest's own top-level `catalog` and `catalogs`.
31
- * Measured with `bun install` 1.4.3: beside a `workspaces.catalog`, a top-level `catalog` entry is not in the catalog
32
- * and a top-level `catalogs` name is "no catalog named"; beside a `workspaces` object without either, the top level
33
- * resolves.
31
+ * Measured with `bun install` 1.4.3 and 1.4.4: beside a `workspaces.catalog`, a top-level `catalog` entry is not in
32
+ * the catalog and a top-level `catalogs` name is "no catalog named"; beside a `workspaces` object without either, the
33
+ * top level resolves.
34
34
  */
35
35
  function catalogHolder(root) {
36
36
  const workspaces = root.workspaces;
package/executors.json CHANGED
@@ -25,11 +25,6 @@
25
25
  "schema": "./src/executors/scriptc-native/schema.json",
26
26
  "description": "Compile each package bin from the package's transformed JavaScript to one platform's executable with scriptc and zig"
27
27
  },
28
- "clean-outputs": {
29
- "implementation": "./dist/executors/clean-outputs/executor.js",
30
- "schema": "./src/executors/clean-outputs/schema.json",
31
- "description": "Remove declared build output directories unless they contain tracked files"
32
- },
33
28
  "cargo-zigbuild": {
34
29
  "implementation": "./dist/executors/cargo-zigbuild/executor.js",
35
30
  "schema": "./src/executors/cargo-zigbuild/schema.json",
@@ -43,7 +38,13 @@
43
38
  "all-verdicts": {
44
39
  "implementation": "./dist/executors/all-verdicts/executor.js",
45
40
  "schema": "./src/executors/all-verdicts/schema.json",
46
- "description": "Run every command at once to its own verdict and report each one a signal ended or that never ran as UNJUDGED"
41
+ "description": "Run every command at once to its own verdict and report each one a signal ended or that never ran as UNJUDGED; resolve an ESLint sources placeholder against the files that exist when the command runs"
42
+ },
43
+ "wrangler-deploy": {
44
+ "implementation": "./dist/executors/wrangler-deploy/executor.js",
45
+ "hasher": "./dist/executors/wrangler-deploy/hasher.js",
46
+ "schema": "./src/executors/wrangler-deploy/schema.json",
47
+ "description": "Deploy a stage with smoo wrangler deploy-stage, cached on the artifact and the stage while the stage serves that artifact's version"
47
48
  }
48
49
  }
49
50
  }
@@ -400,7 +400,7 @@ index 9bd7b61bf9ad94c72a198dfe6f15fbcb68dfaac3..6b982fae848cc82a310eee9a1036be1a
400
400
  flushSyncGeneratorChangesToDisk(generators: string[]): Promise<FlushSyncGeneratorChangesResult>;
401
401
  getRegisteredSyncGenerators(): Promise<{
402
402
  diff --git a/dist/src/daemon/client/client.js b/dist/src/daemon/client/client.js
403
- index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..8f26121c957183135bc75ad428fb7ef809a5471e 100644
403
+ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..54af453aee4d3aaa56d6fe19c328c814e471c659 100644
404
404
  --- a/dist/src/daemon/client/client.js
405
405
  +++ b/dist/src/daemon/client/client.js
406
406
  @@ -40,7 +40,6 @@ const nx_console_1 = require("../message-types/nx-console");
@@ -744,7 +744,7 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..8f26121c957183135bc75ad428fb7ef8
744
744
  }
745
745
  }
746
746
  establishConnection() {
747
- @@ -998,6 +1124,9 @@ class DaemonClient {
747
+ @@ -998,14 +1124,31 @@ class DaemonClient {
748
748
  return { available: false, refusal };
749
749
  }
750
750
  async sendMessageToDaemon(message, force) {
@@ -754,9 +754,15 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..8f26121c957183135bc75ad428fb7ef8
754
754
  // the first message sent to the daemon includes an env prop
755
755
  // that updates the process.env values on the daemon.
756
756
  if (!this.envReflectionSent && !global.NX_PLUGIN_WORKER) {
757
- @@ -1005,7 +1134,15 @@ class DaemonClient {
757
+ message.env = (0, daemon_environment_1.getDaemonEnv)();
758
758
  this.envReflectionSent = true;
759
759
  }
760
+ + // A plugin worker is no command: its request nests in a daemon operation
761
+ + // already current, so the daemon serves it without a probe of its own
762
+ + // (server.js, handleMessage).
763
+ + if (global.NX_PLUGIN_WORKER) {
764
+ + message.fromPluginWorker = true;
765
+ + }
760
766
  await this.startDaemonIfNecessary();
761
767
  + // The request waits on the daemon its record names. Its socket can outlive it: a
762
768
  + // listener a surviving child inherited accepts the request and never answers, and the
@@ -770,7 +776,7 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..8f26121c957183135bc75ad428fb7ef8
770
776
  return new Promise((resolve, reject) => {
771
777
  perf_hooks_1.performance.mark('sendMessageToDaemon-start');
772
778
  // An open promise isn't enough to keep the event loop
773
- @@ -1016,12 +1153,25 @@ class DaemonClient {
779
+ @@ -1016,12 +1159,25 @@ class DaemonClient {
774
780
  keepAlive = setTimeout(() => {
775
781
  reject(new Error('The daemon timed out while processing ' + message.type));
776
782
  }, 20 * 60 * 1000);
@@ -796,7 +802,7 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..8f26121c957183135bc75ad428fb7ef8
796
802
  });
797
803
  }
798
804
  async registerDaemonProcessWithMetricsService(daemonPid) {
799
- @@ -1055,7 +1205,13 @@ class DaemonClient {
805
+ @@ -1055,7 +1211,13 @@ class DaemonClient {
800
806
  console[parsedResult.level](parsedResult.message);
801
807
  return;
802
808
  }
@@ -811,7 +817,7 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..8f26121c957183135bc75ad428fb7ef8
811
817
  this.currentReject(parsedResult.error);
812
818
  }
813
819
  else {
814
- @@ -1132,8 +1288,11 @@ class DaemonClient {
820
+ @@ -1132,8 +1294,11 @@ class DaemonClient {
815
821
  */
816
822
  const { available, refusal: polled } = await this.waitForServerToBeAvailable({ ignoreVersionMismatch: true });
817
823
  if (available) {
@@ -825,7 +831,7 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..8f26121c957183135bc75ad428fb7ef8
825
831
  }
826
832
  else {
827
833
  // A permission refusal from either source wins, then the poll's errno,
828
- @@ -1161,19 +1320,31 @@ class DaemonClient {
834
+ @@ -1161,19 +1326,31 @@ class DaemonClient {
829
835
  ].join('\n'));
830
836
  }
831
837
  }
@@ -867,7 +873,7 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..8f26121c957183135bc75ad428fb7ef8
867
873
  }
868
874
  }
869
875
  (0, tmp_dir_1.removeSocketDir)();
870
- @@ -1200,6 +1371,44 @@ function isDocker() {
876
+ @@ -1200,6 +1377,44 @@ function isDocker() {
871
877
  function nxJsonIsNotPresent() {
872
878
  return !(0, nx_json_1.hasNxJson)(workspace_root_1.workspaceRoot);
873
879
  }
@@ -912,7 +918,7 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..8f26121c957183135bc75ad428fb7ef8
912
918
  /**
913
919
  * The operating system refused the connection. Most often the socket belongs to
914
920
  * another user, which is the guarantee the owner-only socket directory buys —
915
- @@ -1226,6 +1435,21 @@ function daemonPermissionException(socketPath, cause) {
921
+ @@ -1226,6 +1441,21 @@ function daemonPermissionException(socketPath, cause) {
916
922
  error.daemonPermissionError = true;
917
923
  return error;
918
924
  }
@@ -1218,10 +1224,23 @@ index 427ced7822fb05ba966d0543c224c5760b016572..303548db369472e0f99f31c3bc66ae9b
1218
1224
  }
1219
1225
  function getChangedEnvKeys(before, after) {
1220
1226
  diff --git a/dist/src/daemon/message-types/daemon-message.d.ts b/dist/src/daemon/message-types/daemon-message.d.ts
1221
- index 9dd6123ad6d9adb20a07f7db56fc476be78cbcca..0b1ee217729d63a29806cf6c38d0fc5d4a2161a5 100644
1227
+ index 9dd6123ad6d9adb20a07f7db56fc476be78cbcca..6ea90cf3fea484641b20aa11fd6a07d5a71c65fc 100644
1222
1228
  --- a/dist/src/daemon/message-types/daemon-message.d.ts
1223
1229
  +++ b/dist/src/daemon/message-types/daemon-message.d.ts
1224
- @@ -11,6 +11,8 @@ export type DaemonMessage = {
1230
+ @@ -1,6 +1,12 @@
1231
+ export type DaemonMessage = {
1232
+ type: string;
1233
+ env?: Record<string, string>;
1234
+ + /**
1235
+ + * Set by a plugin worker's daemon client. The daemon serves such a request
1236
+ + * without proving its watcher current: it nests in an operation already
1237
+ + * current.
1238
+ + */
1239
+ + fromPluginWorker?: boolean;
1240
+ /**
1241
+ * Stamped centrally by `DaemonSocketMessenger.sendMessage`, not by the ~30
1242
+ * sites that construct messages — hence optional. It can also be absent on a
1243
+ @@ -11,6 +17,8 @@ export type DaemonMessage = {
1225
1244
  data?: any;
1226
1245
  };
1227
1246
  export declare function isDaemonMessage(msg: unknown): msg is DaemonMessage;
@@ -1230,7 +1249,7 @@ index 9dd6123ad6d9adb20a07f7db56fc476be78cbcca..0b1ee217729d63a29806cf6c38d0fc5d
1230
1249
  /**
1231
1250
  * Any message carrying the sender's workspace root. Structural so the checks
1232
1251
  * below serve the daemon and the plugin worker without either importing the
1233
- @@ -24,7 +26,7 @@ type WorkspaceScopedMessage = {
1252
+ @@ -24,7 +32,7 @@ type WorkspaceScopedMessage = {
1234
1253
  /**
1235
1254
  * A message from a different workspace — two sharing an NX_SOCKET_DIR — must not
1236
1255
  * be processed. Roots are normalized first so that a workspace does not look
@@ -1900,7 +1919,7 @@ index 0000000000000000000000000000000000000000..0c065105dff1ed0847e28672661b1792
1900
1919
  + (0, shutdown_utils_1.handleServerProcessTerminationWithRestart)({ server: daemon.server, reason, sockets: daemon.sockets, notice });
1901
1920
  +}
1902
1921
  diff --git a/dist/src/daemon/server/server.js b/dist/src/daemon/server/server.js
1903
- index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966a83c3074 100644
1922
+ index b1c143e244efd435b28642ed86e999d6c86f7d94..0fa42a0dd66fc6706fa36db9ed608486978a384d 100644
1904
1923
  --- a/dist/src/daemon/server/server.js
1905
1924
  +++ b/dist/src/daemon/server/server.js
1906
1925
  @@ -7,17 +7,13 @@ const fs_1 = require("fs");
@@ -1962,7 +1981,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966
1962
1981
  async function handleMessage(socket, data) {
1963
1982
  if (workspaceWatcherError) {
1964
1983
  await (0, shutdown_utils_1.respondWithErrorAndExit)(socket, `File watcher error in the workspace '${workspace_root_1.workspaceRoot}'.`, workspaceWatcherError);
1965
- @@ -134,9 +134,36 @@ async function handleMessage(socket, data) {
1984
+ @@ -134,9 +134,39 @@ async function handleMessage(socket, data) {
1966
1985
  return;
1967
1986
  }
1968
1987
  }
@@ -1981,8 +2000,11 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966
1981
2000
  + // always did, so a write another process makes while the command runs is
1982
2001
  + // as visible as it was. A watcher that stopped delivering stops the daemon
1983
2002
  + // instead; the client is told so first, and continues without a daemon at
1984
- + // once.
1985
- + if (answersFromFiles(payload) && !provenConnections.has(socket)) {
2003
+ + // once. A plugin worker's request (`fromPluginWorker`) is no command and
2004
+ + // makes no probe: it nests in a daemon operation already current, the
2005
+ + // watcher's own recompute, which must read that recompute's files, or a
2006
+ + // command whose connection made its probe.
2007
+ + if (answersFromFiles(payload) && !payload.fromPluginWorker && !provenConnections.has(socket)) {
1986
2008
  + const stopped = await (0, watcher_1.proveWatcherCurrent)();
1987
2009
  + if (stopped !== undefined) {
1988
2010
  + const error = new Error(`The Nx daemon stopped: ${stopped}. This command continues without it.`);
@@ -1999,7 +2021,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966
1999
2021
  if (payload.type === 'PING') {
2000
2022
  await handleResult(socket, 'PING', () => Promise.resolve({ response: true, description: 'ping' }), mode);
2001
2023
  }
2002
- @@ -185,15 +212,6 @@ async function handleMessage(socket, data) {
2024
+ @@ -185,15 +215,6 @@ async function handleMessage(socket, data) {
2003
2025
  else if ((0, hash_glob_1.isHandleHashMultiGlobMessage)(payload)) {
2004
2026
  await handleResult(socket, hash_glob_1.HASH_GLOB, () => (0, handle_hash_glob_1.handleHashMultiGlob)(payload.globGroups), mode);
2005
2027
  }
@@ -2015,7 +2037,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966
2015
2037
  else if ((0, force_shutdown_1.isHandleForceShutdownMessage)(payload)) {
2016
2038
  await handleResult(socket, 'FORCE_SHUTDOWN', () => (0, handle_force_shutdown_1.handleForceShutdown)(server), mode);
2017
2039
  }
2018
- @@ -231,6 +249,22 @@ async function handleMessage(socket, data) {
2040
+ @@ -231,6 +252,22 @@ async function handleMessage(socket, data) {
2019
2041
  await (0, shutdown_utils_1.respondWithErrorAndExit)(socket, `Invalid payload from the client`, new Error(`Unsupported payload sent to daemon server: ${(0, consume_messages_from_socket_1.describeMessage)(unparsedPayload, { maxBytes: 200 })}`));
2020
2042
  }
2021
2043
  }
@@ -2038,7 +2060,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966
2038
2060
  async function handleResult(socket, type, hrFn, mode) {
2039
2061
  let hr;
2040
2062
  const startMark = new Date();
2041
- @@ -242,7 +276,12 @@ async function handleResult(socket, type, hrFn, mode) {
2063
+ @@ -242,7 +279,12 @@ async function handleResult(socket, type, hrFn, mode) {
2042
2064
  }
2043
2065
  const doneHandlingMark = new Date();
2044
2066
  if (hr.error) {
@@ -2052,7 +2074,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966
2052
2074
  }
2053
2075
  else {
2054
2076
  logger_1.serverLogger.log(`Serializing response for ${type} message in ${mode} mode`);
2055
- @@ -256,9 +295,10 @@ async function handleResult(socket, type, hrFn, mode) {
2077
+ @@ -256,9 +298,10 @@ async function handleResult(socket, type, hrFn, mode) {
2056
2078
  logger_1.serverLogger.log(`Handled ${mode} message ${type}. Handling time: ${doneHandlingMark.getTime() - startMark.getTime()}. Response time: ${endMark.getTime() - doneHandlingMark.getTime()}.`);
2057
2079
  }
2058
2080
  function handleInactivityTimeout() {
@@ -2065,7 +2087,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966
2065
2087
  (0, shutdown_utils_1.resetInactivityTimeout)(handleInactivityTimeout);
2066
2088
  }
2067
2089
  else {
2068
- @@ -287,37 +327,6 @@ function registerProcessTerminationListeners() {
2090
+ @@ -287,37 +330,6 @@ function registerProcessTerminationListeners() {
2069
2091
  sockets: exports.openSockets,
2070
2092
  }));
2071
2093
  }
@@ -2103,7 +2125,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966
2103
2125
  /**
2104
2126
  * When applicable files in the workspaces are changed (created, updated, deleted),
2105
2127
  * we need to recompute the cached serialized project graph so that it is readily
2106
- @@ -339,6 +348,11 @@ const handleWorkspaceChanges = async (err, changeEvents) => {
2128
+ @@ -339,6 +351,11 @@ const handleWorkspaceChanges = async (err, changeEvents) => {
2107
2129
  return;
2108
2130
  }
2109
2131
  logger_1.serverLogger.watcherLog((0, watcher_1.convertChangeEventsToLogMessage)(changeEvents));
@@ -2115,7 +2137,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966
2115
2137
  (0, route_workspace_changes_1.routeWorkspaceChanges)(changeEvents);
2116
2138
  }
2117
2139
  catch (err) {
2118
- @@ -348,65 +362,68 @@ const handleWorkspaceChanges = async (err, changeEvents) => {
2140
+ @@ -348,65 +365,68 @@ const handleWorkspaceChanges = async (err, changeEvents) => {
2119
2141
  (0, file_watcher_sockets_1.notifyFileWatcherSocketsOfError)(err);
2120
2142
  }
2121
2143
  };
@@ -2223,7 +2245,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..cd24ff30639e538422cf813679e80966
2223
2245
  return new Promise(async (resolve, reject) => {
2224
2246
  // `listen` reports a failed bind asynchronously on the server, which the
2225
2247
  // try below cannot catch — without this an EACCES became an uncaught
2226
- @@ -432,25 +449,19 @@ async function startServer() {
2248
+ @@ -432,25 +452,19 @@ async function startServer() {
2227
2249
  // Best effort; the 0700 socket directory is the primary control.
2228
2250
  }
2229
2251
  }
@@ -3149,6 +3171,78 @@ index 332accab74919348073538f4198693328bf68193..a56864600a5e7a9f9e40adea9a7bfc9e
3149
3171
  const plansReference = this.planner.getPlansReference(taskIds, taskGraph);
3150
3172
  return this.inspector.inspectInputs(plansReference);
3151
3173
  }
3174
+ diff --git a/dist/src/hasher/native-task-hasher-impl.js b/dist/src/hasher/native-task-hasher-impl.js
3175
+ index 61b015b9a1b4665c1f0a236d9ef41858dd925163..ea7e1b792faded260e13f101e637d2fedb36cfcf 100644
3176
+ --- a/dist/src/hasher/native-task-hasher-impl.js
3177
+ +++ b/dist/src/hasher/native-task-hasher-impl.js
3178
+ @@ -29,10 +29,65 @@ class NativeTaskHasherImpl {
3179
+ return hashes[0];
3180
+ }
3181
+ async hashTasks(tasks, taskGraph, perTaskEnvs, cwd, collectInputs) {
3182
+ - const plans = this.planner.getPlansReference(tasks.map((t) => t.id), taskGraph);
3183
+ + const taskIds = tasks.map((t) => t.id);
3184
+ + const plans = this.planner.getPlansReference(taskIds, taskGraph);
3185
+ const shouldCollectInputs = collectInputs ?? (0, task_io_service_1.getTaskIOService)().hasTaskInputSubscribers();
3186
+ - const hashes = this.hasher.hashPlans(plans, perTaskEnvs, cwd ?? process.cwd(), shouldCollectInputs);
3187
+ + let hashes;
3188
+ + try {
3189
+ + hashes = this.hasher.hashPlans(plans, perTaskEnvs, cwd ?? process.cwd(), shouldCollectInputs);
3190
+ + }
3191
+ + catch (error) {
3192
+ + throw hashPlansError(error, taskIds, this.planner, taskGraph);
3193
+ + }
3194
+ return tasks.map((t) => hashes[t.id]);
3195
+ }
3196
+ }
3197
+ exports.NativeTaskHasherImpl = NativeTaskHasherImpl;
3198
+ +/** A refusal names this many task ids and counts the rest, as cowshed's refusals do. */
3199
+ +const NAMED_TASKS = 10;
3200
+ +function namedTasks(ids) {
3201
+ + const named = ids.slice(0, NAMED_TASKS);
3202
+ + if (ids.length > NAMED_TASKS) {
3203
+ + named.push(`and ${ids.length - NAMED_TASKS} more`);
3204
+ + }
3205
+ + return named.join(', ');
3206
+ +}
3207
+ +/**
3208
+ + * The native hasher's error names neither the task nor the input it failed on:
3209
+ + * a runtime input whose output is not UTF-8 fails as `invalid utf-8 sequence of
3210
+ + * 1 bytes from index 0`, which any runtime input of any task in the batch could
3211
+ + * have raised. Name the tasks and the runtime inputs their plans hold, read from
3212
+ + * the planner, so the error says where to look; nothing runs again. The native
3213
+ + * message always leads and the native error is the cause: a planner that cannot
3214
+ + * answer costs the listing, never the error it was asked to explain.
3215
+ + */
3216
+ +function hashPlansError(error, taskIds, planner, taskGraph) {
3217
+ + const native = error instanceof Error ? error.message : String(error);
3218
+ + const lines = [`Could not hash ${namedTasks([...taskIds].sort())}: ${native}`];
3219
+ + let plans;
3220
+ + try {
3221
+ + plans = planner.getPlans(taskIds, taskGraph);
3222
+ + }
3223
+ + catch (listing) {
3224
+ + const reason = listing instanceof Error ? listing.message : String(listing);
3225
+ + lines.push(`The runtime inputs of those tasks could not be listed: ${reason}`);
3226
+ + return new Error(lines.join('\n'), { cause: error });
3227
+ + }
3228
+ + const tasksByRuntime = new Map();
3229
+ + for (const taskId of Object.keys(plans).sort()) {
3230
+ + for (const instruction of plans[taskId]) {
3231
+ + if (instruction.startsWith('runtime:')) {
3232
+ + const command = instruction.slice('runtime:'.length);
3233
+ + const tasks = tasksByRuntime.get(command) ?? new Set();
3234
+ + tasksByRuntime.set(command, tasks.add(taskId));
3235
+ + }
3236
+ + }
3237
+ + }
3238
+ + if (tasksByRuntime.size > 0) {
3239
+ + lines.push('Runtime inputs of those tasks:');
3240
+ + for (const command of [...tasksByRuntime.keys()].sort()) {
3241
+ + lines.push(` ${command} (${namedTasks([...tasksByRuntime.get(command)])})`);
3242
+ + }
3243
+ + }
3244
+ + return new Error(lines.join('\n'), { cause: error });
3245
+ +}
3152
3246
  diff --git a/dist/src/hasher/task-hasher.d.ts b/dist/src/hasher/task-hasher.d.ts
3153
3247
  index cf08aa6c0fb9bcbb2fbf10e554f2e0397b1b13d7..f67c434e41a776343e11225bdd12f02cd7570d0c 100644
3154
3248
  --- a/dist/src/hasher/task-hasher.d.ts
@@ -90,6 +90,49 @@ index f6ee81fb1af41deea022b92e838a7c4665eb9778..112faf913ce38b1f4624b38db3783937
90
90
  }
91
91
 
92
92
  // forceNoEmit sets noEmit so the program type-checks without writing files.
93
+ diff --git a/lib/internal/javascriptRuntimeCapabilities.js b/lib/internal/javascriptRuntimeCapabilities.js
94
+ --- a/lib/internal/javascriptRuntimeCapabilities.js
95
+ +++ b/lib/internal/javascriptRuntimeCapabilities.js
96
+ @@ -43,6 +43,19 @@
97
+ * @evidence contracts/performance.md#bound-retention-and-release-resources The synchronous probe owns child completion and fallback captures; finally attempts capture close/removal, whose helper suppresses cleanup failures, so native/file release is unconfirmed on failure. Capability entries retain absolute spellings and path/identity text with no eviction quota; failed identity validation can remove an entry. Returned capability copies transfer to callers.
98
+ */
99
+ function javascriptRuntimeCapabilities(runtime, env, cwd, identities) {
100
+ + // The running process answers for itself. Under Bun, process.execPath names
101
+ + // Bun (pluginDescriptorRuntimeBinary), and a probe of it can fail for reasons
102
+ + // that say nothing about the executable: its 30 s timeout under load, or a
103
+ + // spawn the host refused. Read as "not Bun", that failure handed Bun Node's
104
+ + // `--input-type ""`, which Bun runs as an empty `bun run` script, so the
105
+ + // plugin descriptor produced no output. This process knows what it is.
106
+ + if (node_path_1.default.isAbsolute(runtime) && sameRuntimeExecutable(runtime, process.execPath)) {
107
+ + return {
108
+ + bun: typeof globalThis.Bun === "object",
109
+ + executable: process.execPath,
110
+ + registerHooks: typeof require("node:module").registerHooks === "function",
111
+ + };
112
+ + }
113
+ // Inside a ttsx run this is the user's NODE_OPTIONS, not ttsx's preloads,
114
+ // which would refuse the cache and run in the probe (#1740).
115
+ const effectiveEnv = TtsxNodeOptions_1.TtsxNodeOptions.forHelpers(SidecarEnvironment_1.SidecarEnvironment.merge(process.env, env));
116
+ diff --git a/lib/plugin/internal/source/GoSourceInputs.js b/lib/plugin/internal/source/GoSourceInputs.js
117
+ --- a/lib/plugin/internal/source/GoSourceInputs.js
118
+ +++ b/lib/plugin/internal/source/GoSourceInputs.js
119
+ @@ -73,6 +73,16 @@
120
+ function goBuildEnv(goBinary, goBuildCacheRoot, effectiveEnv = process.env) {
121
+ const env = { ...effectiveEnv };
122
+ env.GOWORK = "auto";
123
+ + // GOWORK=auto puts go in workspace mode wherever a go.work lies (typia's
124
+ + // native plugin ships one), where go accepts only -mod=readonly or
125
+ + // -mod=vendor. A caller's GOFLAGS -mod=mod, a host shell's say, failed
126
+ + // every invocation; ttsc owns the workspace, so it drops that flag and
127
+ + // keeps the caller's others.
128
+ + if (env.GOFLAGS) {
129
+ + env.GOFLAGS = env.GOFLAGS.split(/\s+/)
130
+ + .filter((flag) => flag !== "" && !/^--?mod=/.test(flag))
131
+ + .join(" ");
132
+ + }
133
+ // Only the actual `go build` needs ttsc's GOCACHE; read-only metadata spawns
134
+ // (`go mod edit`, `go env`, `go version`) call goBuildEnv with no cache root
135
+ // and inherit ambient GOCACHE rather than receiving the managed build
93
136
  diff --git a/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js b/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js
94
137
  --- a/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js
95
138
  +++ b/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js
@@ -117,3 +160,99 @@ diff --git a/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js b/lib/
117
160
  worker = created;
118
161
  const retire = () => {
119
162
  if (worker === created)
163
+ diff --git a/lib/plugin/internal/source/inspectPluginBuildLock.js b/lib/plugin/internal/source/inspectPluginBuildLock.js
164
+ --- a/lib/plugin/internal/source/inspectPluginBuildLock.js
165
+ +++ b/lib/plugin/internal/source/inspectPluginBuildLock.js
166
+ @@ -65,9 +65,16 @@
167
+ const PLUGIN_BUILD_LOCK_OBSERVER = node_crypto_1.default.randomBytes(16).toString("hex");
168
+ function inspectV3PluginBuildLock(lockDir) {
169
+ const generationDir = node_path_1.default.join(lockDir, PluginBuildLockProtocol_1.PluginBuildLockProtocol.PLUGIN_BUILD_LOCK_CURRENT_DIR);
170
+ + // `current` changes only by whole-directory renames: a holder retires it
171
+ + // onto its tombstone, and the next holder publishes a directory that
172
+ + // already holds its generation. A read that finds no valid generation
173
+ + // proves the lock malformed only when the same directory was `current`
174
+ + // before and after it. Otherwise the read straddled a handoff of the key,
175
+ + // and a handoff is a release: the caller observes the key again.
176
+ + const observed = pluginBuildLockDirectoryIdentity(generationDir);
177
+ const generation = readPluginBuildLockGeneration(generationDir);
178
+ if (generation === null) {
179
+ - if (pluginBuildLockPathMissing(generationDir)) {
180
+ + if (observed === null || observed !== pluginBuildLockDirectoryIdentity(generationDir)) {
181
+ return { state: "released" };
182
+ }
183
+ throw new Error(`ttsc plugin build lock has no valid ${PluginBuildLockProtocol_1.PluginBuildLockProtocol.PLUGIN_BUILD_LOCK_GENERATION_FILE}: ${generationDir}`);
184
+ @@ -269,6 +276,22 @@
185
+ return null;
186
+ }
187
+ }
188
+ +/**
189
+ + * The device and inode of a lock directory, or null when a lookup proves it
190
+ + * absent. A permission or sharing failure proves nothing and propagates.
191
+ + */
192
+ +function pluginBuildLockDirectoryIdentity(directory) {
193
+ + try {
194
+ + const stat = node_fs_1.default.statSync(directory, { bigint: true });
195
+ + return `${stat.dev}:${stat.ino}`;
196
+ + }
197
+ + catch (error) {
198
+ + if (PluginBuildLockProtocol_1.PluginBuildLockProtocol.isMissingPathError(error)) {
199
+ + return null;
200
+ + }
201
+ + throw error;
202
+ + }
203
+ +}
204
+ /**
205
+ * Whether a path lookup proves absence. Permission and sharing failures are
206
+ * inconclusive, never evidence of a released or old abandoned generation.
207
+ diff --git a/lib/plugin/internal/source/waitForPluginBinary.js b/lib/plugin/internal/source/waitForPluginBinary.js
208
+ --- a/lib/plugin/internal/source/waitForPluginBinary.js
209
+ +++ b/lib/plugin/internal/source/waitForPluginBinary.js
210
+ @@ -25,6 +25,12 @@
211
+ * run. An opted-in synchronous owner can cancel observation or interrupt a
212
+ * polling sleep; cancellation never retires the holder's generation.
213
+ *
214
+ + * A published binary is not admission: the caller registers as its reader
215
+ + * under the key, which only release or retirement frees. Each poll therefore
216
+ + * inspects the lock before it reports publication, so a holder that died
217
+ + * holding the key after its binary was published is reported abandoned
218
+ + * instead of outwaiting the admission budget.
219
+ + *
220
+ * @evidence contracts/common.md#principled-implementation Polling first refuses unknown/malformed native guards, suppresses publication while pending and rechecks after observed release; actual abandoned-owner observations retain their exact generation, while budget expiry fails without revoking a possibly active payload task.
221
+ * @evidence contracts/common.md#clear-and-simple-design The loop separates publication, release, retirement and periodic status reporting; generation interpretation belongs to inspectPluginBuildLock.
222
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Budget expiry throws instead of retiring a live-looking generation and compensating for concurrent callbacks; status output never substitutes for ownership evidence.
223
+ @@ -43,22 +49,9 @@
224
+ OwnedSynchronousProcess_1.OwnedSynchronousProcess.checkpoint();
225
+ SourceNativeRetirement_1.SourceNativeRetirement.assertAvailable(protocolDir);
226
+ const protectedNativeInputs = SourceNativeRetirement_1.SourceNativeRetirement.isProtected(protocolDir);
227
+ - if (!protectedNativeInputs && node_fs_1.default.existsSync(opts.binaryPath)) {
228
+ - OwnedSynchronousProcess_1.OwnedSynchronousProcess.checkpoint();
229
+ - return { outcome: "published" };
230
+ - }
231
+ const clock = performance.now();
232
+ const lock = (0, inspectPluginBuildLock_1.inspectPluginBuildLock)(opts.lockDir);
233
+ OwnedSynchronousProcess_1.OwnedSynchronousProcess.checkpoint();
234
+ - if (lock.state === "released") {
235
+ - // The holder retired its generation between the binary check above and
236
+ - // this observation. That is a normal release, not abandonment: prefer the
237
+ - // binary when it landed inside that window, otherwise hand the free key
238
+ - // back to the caller.
239
+ - return !protectedNativeInputs && node_fs_1.default.existsSync(opts.binaryPath)
240
+ - ? { outcome: "published" }
241
+ - : { outcome: "released" };
242
+ - }
243
+ if (lock.state === "abandoned") {
244
+ return {
245
+ outcome: "abandoned",
246
+ @@ -66,6 +59,12 @@
247
+ fence: lock.fence,
248
+ };
249
+ }
250
+ + if (!protectedNativeInputs && node_fs_1.default.existsSync(opts.binaryPath)) {
251
+ + return { outcome: "published" };
252
+ + }
253
+ + if (lock.state === "released") {
254
+ + return { outcome: "released" };
255
+ + }
256
+ if (clock - startedAt >= opts.timeoutMs) {
257
+ throw new Error(`ttsc: timed out after ${(0, formatDuration_1.formatDuration)(clock - startedAt)} waiting for ` +
258
+ `${opts.lockInfo.label} "${opts.lockInfo.pluginName}" at ${opts.lockDir}; ` +
@@ -4,7 +4,6 @@
4
4
 
5
5
  # Save the current working directory
6
6
  ORIGINAL_PWD="$(pwd)"
7
- SELF_PATH="$(realpath "$0")"
8
7
 
9
8
  # Locate this repository's tooling/ from the INVOCATION path, not from
10
9
  # realpath($0). WHY: tooling/devenv is a symlink into
@@ -29,7 +28,7 @@ fi
29
28
  # Find the actual Nix-built devenv binary, skipping every wrapper script.
30
29
  # WHY: PATH routinely holds more than one of these wrappers at once — this
31
30
  # repo's tooling/devenv, sibling repos' wrappers, and direnv-stacked parent
32
- # environments. A plain "not equal to SELF_PATH" check happily selects a
31
+ # environments. Excluding only this wrapper's own path happily selects a
33
32
  # *different* wrapper and exec's it, so `devenv` bounces into the wrong repo
34
33
  # (or self-execs forever on cheap checks like `devenv version`). The real devenv
35
34
  # is always the Nix-managed executable under /nix/store, so match that and ignore