@smoothbricks/nx-plugin 0.7.17 → 0.7.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/README.md +315 -114
  2. package/dist/.build-inputs.json +47 -38
  3. package/dist/built-output-packages.js +1 -1
  4. package/dist/bun-lock-scope.d.ts +128 -20
  5. package/dist/bun-lock-scope.d.ts.map +1 -1
  6. package/dist/bun-lock-scope.js +267 -44
  7. package/dist/cargo-closure-input.d.ts +8 -6
  8. package/dist/cargo-closure-input.d.ts.map +1 -1
  9. package/dist/cargo-closure-input.js +15 -12
  10. package/dist/cargo-source-hash.d.ts +26 -25
  11. package/dist/cargo-source-hash.d.ts.map +1 -1
  12. package/dist/cargo-source-hash.js +84 -105
  13. package/dist/cargo-toolchain-paths.d.ts +2 -2
  14. package/dist/cargo-toolchain-paths.js +2 -2
  15. package/dist/cargo-workspace.d.ts +20 -2
  16. package/dist/cargo-workspace.d.ts.map +1 -1
  17. package/dist/cargo-workspace.js +43 -22
  18. package/dist/ensure-built-receipt.d.ts +3 -2
  19. package/dist/ensure-built-receipt.d.ts.map +1 -1
  20. package/dist/ensure-built-receipt.js +3 -2
  21. package/dist/eslint-config-closure.d.ts +8 -3
  22. package/dist/eslint-config-closure.d.ts.map +1 -1
  23. package/dist/eslint-config-closure.js +24 -5
  24. package/dist/executors/bounded-exec/admission-queue.d.ts +3 -1
  25. package/dist/executors/bounded-exec/admission-queue.d.ts.map +1 -1
  26. package/dist/executors/bounded-exec/admission-queue.js +9 -10
  27. package/dist/executors/bounded-exec/awake-clock.d.ts +5 -0
  28. package/dist/executors/bounded-exec/awake-clock.d.ts.map +1 -0
  29. package/dist/executors/bounded-exec/awake-clock.js +22 -0
  30. package/dist/executors/bounded-exec/bounds.d.ts +19 -6
  31. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
  32. package/dist/executors/bounded-exec/bounds.js +22 -15
  33. package/dist/executors/bounded-exec/case-gate.d.ts +114 -0
  34. package/dist/executors/bounded-exec/case-gate.d.ts.map +1 -0
  35. package/dist/executors/bounded-exec/case-gate.js +342 -0
  36. package/dist/executors/bounded-exec/cpu-pool-thread.d.ts +1 -0
  37. package/dist/executors/bounded-exec/cpu-pool-thread.d.ts.map +1 -1
  38. package/dist/executors/bounded-exec/cpu-pool-thread.js +2 -2
  39. package/dist/executors/bounded-exec/cpu-pool.d.ts +28 -1
  40. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  41. package/dist/executors/bounded-exec/cpu-pool.js +102 -16
  42. package/dist/executors/bounded-exec/cpu-rise.d.ts +73 -0
  43. package/dist/executors/bounded-exec/cpu-rise.d.ts.map +1 -0
  44. package/dist/executors/bounded-exec/cpu-rise.js +111 -0
  45. package/dist/executors/bounded-exec/endpoint-life.d.ts +146 -0
  46. package/dist/executors/bounded-exec/endpoint-life.d.ts.map +1 -0
  47. package/dist/executors/bounded-exec/endpoint-life.js +228 -0
  48. package/dist/executors/bounded-exec/executor.d.ts +1 -1
  49. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  50. package/dist/executors/bounded-exec/executor.js +256 -86
  51. package/dist/executors/bounded-exec/gateway-lease.d.ts +1 -1
  52. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
  53. package/dist/executors/bounded-exec/gateway-lease.js +8 -1
  54. package/dist/executors/bounded-exec/go-run-summary.d.ts +51 -0
  55. package/dist/executors/bounded-exec/go-run-summary.d.ts.map +1 -0
  56. package/dist/executors/bounded-exec/go-run-summary.js +98 -0
  57. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +11 -3
  58. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  59. package/dist/executors/bounded-exec/hang-diagnostics.js +125 -47
  60. package/dist/executors/bounded-exec/lease-wait.d.ts +1 -0
  61. package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -1
  62. package/dist/executors/bounded-exec/lease-wait.js +1 -0
  63. package/dist/executors/bounded-exec/mbx-pool.d.ts +42 -7
  64. package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
  65. package/dist/executors/bounded-exec/mbx-pool.js +45 -8
  66. package/dist/executors/bounded-exec/mbx-reservations.d.ts +12 -6
  67. package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -1
  68. package/dist/executors/bounded-exec/mbx-reservations.js +190 -284
  69. package/dist/executors/bounded-exec/parent-grant.d.ts +2 -0
  70. package/dist/executors/bounded-exec/parent-grant.d.ts.map +1 -1
  71. package/dist/executors/bounded-exec/parent-grant.js +1 -0
  72. package/dist/executors/bounded-exec/pool-admission.d.ts +29 -3
  73. package/dist/executors/bounded-exec/pool-admission.d.ts.map +1 -1
  74. package/dist/executors/bounded-exec/pool-admission.js +47 -1
  75. package/dist/executors/bounded-exec/progress-channel.d.ts +38 -0
  76. package/dist/executors/bounded-exec/progress-channel.d.ts.map +1 -0
  77. package/dist/executors/bounded-exec/progress-channel.js +113 -0
  78. package/dist/executors/bounded-exec/progress.d.ts +5 -1
  79. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  80. package/dist/executors/bounded-exec/progress.js +31 -1
  81. package/dist/executors/bounded-exec/ram-temp.d.ts +24 -1
  82. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  83. package/dist/executors/bounded-exec/ram-temp.js +123 -16
  84. package/dist/executors/bounded-exec/reservation-connection.d.ts +90 -0
  85. package/dist/executors/bounded-exec/reservation-connection.d.ts.map +1 -0
  86. package/dist/executors/bounded-exec/reservation-connection.js +248 -0
  87. package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
  88. package/dist/executors/bounded-exec/run-cpu-pool.js +3 -0
  89. package/dist/executors/bounded-exec/runner-sizing.d.ts +9 -5
  90. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
  91. package/dist/executors/bounded-exec/runner-sizing.js +13 -9
  92. package/dist/executors/bounded-exec/schema.d.ts +7 -2
  93. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  94. package/dist/executors/bounded-exec/schema.js +17 -1
  95. package/dist/executors/bounded-exec/suite-minimum.d.ts +21 -0
  96. package/dist/executors/bounded-exec/suite-minimum.d.ts.map +1 -0
  97. package/dist/executors/bounded-exec/suite-minimum.js +85 -0
  98. package/dist/executors/bounded-exec/test-result-writer.d.ts +2 -0
  99. package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -1
  100. package/dist/executors/bounded-exec/test-result-writer.js +1 -0
  101. package/dist/executors/bounded-exec/test-results.d.ts +5 -0
  102. package/dist/executors/bounded-exec/test-results.d.ts.map +1 -1
  103. package/dist/executors/bounded-exec/test-results.js +2 -2
  104. package/dist/executors/bounded-exec/verdict.d.ts +39 -10
  105. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  106. package/dist/executors/bounded-exec/verdict.js +60 -14
  107. package/dist/executors/cargo-zigbuild/executor.d.ts +10 -8
  108. package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
  109. package/dist/executors/cargo-zigbuild/executor.js +32 -19
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +294 -152
  112. package/dist/managed-files/ci-workflow.d.ts +4 -1
  113. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  114. package/dist/managed-files/ci-workflow.js +9 -14
  115. package/dist/managed-files/files.d.ts +3 -3
  116. package/dist/managed-files/files.js +3 -3
  117. package/dist/managed-files/generator.d.ts +5 -1
  118. package/dist/managed-files/generator.d.ts.map +1 -1
  119. package/dist/managed-files/generator.js +22 -7
  120. package/dist/managed-files/render-memo.d.ts +13 -0
  121. package/dist/managed-files/render-memo.d.ts.map +1 -0
  122. package/dist/managed-files/render-memo.js +94 -0
  123. package/dist/task-results.js +2 -1
  124. package/dist/test-program.d.ts +11 -6
  125. package/dist/test-program.d.ts.map +1 -1
  126. package/dist/test-program.js +39 -35
  127. package/dist/tool-bins.d.ts +12 -0
  128. package/dist/tool-bins.d.ts.map +1 -1
  129. package/dist/tool-bins.js +31 -6
  130. package/dist/typecheck-test-policy.d.ts +10 -1
  131. package/dist/typecheck-test-policy.d.ts.map +1 -1
  132. package/dist/typecheck-test-policy.js +40 -24
  133. package/dist/workspace-config-policy.d.ts.map +1 -1
  134. package/dist/workspace-config-policy.js +135 -42
  135. package/dist/workspace-index.d.ts +14 -1
  136. package/dist/workspace-index.d.ts.map +1 -1
  137. package/dist/workspace-index.js +36 -4
  138. package/executors.json +2 -0
  139. package/managed/raw/envrc +24 -0
  140. package/managed/raw/patches/nx@24.0.3.patch +1851 -221
  141. package/managed/raw/patches/ttsc@0.37.1.patch +1055 -0
  142. package/managed/raw/tooling/direnv/developer-links.ts +122 -14
  143. package/managed/raw/tooling/direnv/devenv.smoo.nix +20 -19
  144. package/managed/templates/github/actions/save-nix-devenv/action.yml +19 -1
  145. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  146. package/package.json +68 -11
  147. package/runtime/nx-publish/.build-inputs.json +2 -2
  148. package/runtime/nx-publish/cache_adapter.js +293 -3
  149. package/runtime/nx-publish/nx_publish.js +36 -14
  150. package/src/built-output-packages.ts +1 -1
  151. package/src/bun-lock-scope.ts +293 -40
  152. package/src/cargo-closure-input.ts +20 -12
  153. package/src/cargo-source-hash.ts +119 -145
  154. package/src/cargo-toolchain-paths.ts +2 -2
  155. package/src/cargo-workspace.ts +59 -21
  156. package/src/ensure-built-receipt.ts +3 -2
  157. package/src/eslint-config-closure.ts +27 -6
  158. package/src/executors/bounded-exec/admission-queue.ts +11 -10
  159. package/src/executors/bounded-exec/awake-clock.ts +20 -0
  160. package/src/executors/bounded-exec/bounds.ts +41 -19
  161. package/src/executors/bounded-exec/case-gate.ts +365 -0
  162. package/src/executors/bounded-exec/cpu-pool-thread.ts +3 -3
  163. package/src/executors/bounded-exec/cpu-pool.ts +139 -12
  164. package/src/executors/bounded-exec/cpu-rise.ts +156 -0
  165. package/src/executors/bounded-exec/endpoint-life.ts +279 -0
  166. package/src/executors/bounded-exec/executor.ts +341 -123
  167. package/src/executors/bounded-exec/gateway-lease.ts +6 -0
  168. package/src/executors/bounded-exec/go-run-summary.ts +137 -0
  169. package/src/executors/bounded-exec/hang-diagnostics.ts +150 -50
  170. package/src/executors/bounded-exec/lease-wait.ts +1 -0
  171. package/src/executors/bounded-exec/mbx-pool.ts +57 -9
  172. package/src/executors/bounded-exec/mbx-reservations.ts +216 -183
  173. package/src/executors/bounded-exec/parent-grant.ts +3 -0
  174. package/src/executors/bounded-exec/pool-admission.ts +59 -2
  175. package/src/executors/bounded-exec/progress-channel.ts +129 -0
  176. package/src/executors/bounded-exec/progress.ts +39 -3
  177. package/src/executors/bounded-exec/ram-temp.ts +137 -17
  178. package/src/executors/bounded-exec/reservation-connection.ts +221 -0
  179. package/src/executors/bounded-exec/run-cpu-pool.ts +2 -0
  180. package/src/executors/bounded-exec/runner-sizing.ts +13 -8
  181. package/src/executors/bounded-exec/schema.json +1 -1
  182. package/src/executors/bounded-exec/schema.ts +21 -2
  183. package/src/executors/bounded-exec/suite-minimum.ts +81 -0
  184. package/src/executors/bounded-exec/test-result-writer.ts +3 -0
  185. package/src/executors/bounded-exec/test-results.ts +5 -0
  186. package/src/executors/bounded-exec/verdict.ts +83 -22
  187. package/src/executors/cargo-zigbuild/executor.ts +30 -19
  188. package/src/index.ts +357 -166
  189. package/src/managed-files/ci-workflow.ts +13 -17
  190. package/src/managed-files/files.ts +3 -3
  191. package/src/managed-files/generator.ts +21 -6
  192. package/src/managed-files/render-memo.ts +135 -0
  193. package/src/test-program.ts +36 -41
  194. package/src/tool-bins.ts +35 -6
  195. package/src/typecheck-test-policy.ts +49 -24
  196. package/src/workspace-config-policy.ts +161 -43
  197. package/src/workspace-index.ts +40 -5
  198. package/test-timings.json +157 -141
  199. package/managed/raw/patches/ttsc@0.36.3.patch +0 -1660
@@ -0,0 +1,73 @@
1
+ import type { tags } from 'typia';
2
+ /**
3
+ * The CPU a run's tree used while its idle bound counted down. A test that runs a compiler is a build inside the test,
4
+ * which is a defect and not a test (specs/cowshed/08_testing.md, "Integration tests (real substrate)"): the pre-signal
5
+ * snapshot names the processes whose CPU time rose between its two process censuses, so the expiry fails as that and
6
+ * not as an anonymous hang. CPU never restarts the idle bound, which counts only finished tests and the progress a
7
+ * running test reports (progress-channel.ts); this says what ran.
8
+ */
9
+ /** What a rising process makes of the expiry, said in the same words by the snapshot and by the verdict. */
10
+ export declare const CPU_RISING_CLASS = "a process in the test's tree was using CPU: likely a build inside the test";
11
+ /**
12
+ * The least gain that names a rise, whatever resolution ps prints CPU time at: 10% of a core over the snapshot's five
13
+ * seconds between censuses.
14
+ */
15
+ export declare const CPU_RISE_FLOOR_MS = 500;
16
+ /**
17
+ * What a printed CPU time resolves to, in milliseconds: the value of its last digit. Whole seconds are 1,000, a
18
+ * fraction of n digits is 10^(3-n); a finer fraction is kept to the millisecond, so none is below 1.
19
+ */
20
+ export type CpuResolutionMs = 1_000 | 100 | 10 | 1;
21
+ /** A CPU time ps printed, with the resolution it was printed at. */
22
+ export interface CpuTime {
23
+ readonly ms: number;
24
+ readonly resolutionMs: CpuResolutionMs;
25
+ }
26
+ /** A process whose CPU time rose between the snapshot's two censuses. */
27
+ export interface CpuRise {
28
+ readonly pid: number & tags.Type<'uint32'> & tags.Minimum<1>;
29
+ readonly command: string;
30
+ readonly gainedMs: number & tags.Minimum<0>;
31
+ }
32
+ /** One process of a census, as far as CPU is concerned. */
33
+ export interface CpuSample {
34
+ readonly pid: number;
35
+ readonly started: string;
36
+ readonly command: string;
37
+ /** Null when ps printed a CPU time that does not parse. */
38
+ readonly cpu: CpuTime | null;
39
+ }
40
+ export interface CpuChange {
41
+ /** Largest gain first. */
42
+ readonly rising: readonly CpuRise[];
43
+ /** Processes in both censuses that one of them gave no readable CPU time for: not counted idle. */
44
+ readonly unread: readonly number[];
45
+ }
46
+ /**
47
+ * A ps CPU time (`cputime=`): `[[D-]HH:]MM:SS` with an optional fraction, as Linux prints it (whole seconds) and macOS
48
+ * does (centiseconds). Null for anything else, such as the `-` ps prints for a process it may not read.
49
+ */
50
+ export declare function parseCpuTime(text: string): CpuTime | null;
51
+ /**
52
+ * The least gain between two readings of one process that names a rise: twice the coarser of their resolutions, and
53
+ * never under {@link CPU_RISE_FLOOR_MS}. A process that crossed a boundary of the last printed digit on a few
54
+ * milliseconds of work gains one resolution, so two are more than one. That is 2,000 ms between whole-second readings
55
+ * and 500 ms between centisecond ones.
56
+ */
57
+ export declare function cpuRiseThresholdMs(before: CpuTime, after: CpuTime): number;
58
+ /**
59
+ * The processes present in both censuses (same pid and start) whose CPU time rose by at least
60
+ * {@link cpuRiseThresholdMs}.
61
+ */
62
+ export declare function cpuChange(before: readonly CpuSample[], after: readonly CpuSample[]): CpuChange;
63
+ /**
64
+ * The gains {@link cpuChange} held these censuses to, each distinct one once, smallest first: one per resolution of the
65
+ * readings compared, and none when no process had a readable CPU time in both.
66
+ */
67
+ export declare function cpuRiseThresholdsMs(before: readonly CpuSample[], after: readonly CpuSample[]): readonly number[];
68
+ /** The gains of {@link cpuRiseThresholdsMs} in seconds, as the snapshot says them: `2 s`, or `0.5 s or 2 s`. */
69
+ export declare function describeCpuThresholds(thresholdsMs: readonly number[]): string;
70
+ export declare function describeCpuRise(rise: CpuRise): string;
71
+ /** The largest gains, named, and how many more there were: a parallel build runs many processes. */
72
+ export declare function describeCpuRises(rises: readonly CpuRise[], named?: number): string;
73
+ //# sourceMappingURL=cpu-rise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cpu-rise.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/cpu-rise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAElC;;;;;;GAMG;AAEH,4GAA4G;AAC5G,eAAO,MAAM,gBAAgB,+EAA+E,CAAC;AAE7G;;;GAGG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,GAAG,GA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AmB,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,EAAE,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,MAAM,EAAE,CAMhH;AAED,gHAAgH;AAChH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAE7E;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAErD;AAED,oGAAoG;AACpG,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,EAAE,KAAK,SAAI,GAAG,MAAM,CAI7E"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * The CPU a run's tree used while its idle bound counted down. A test that runs a compiler is a build inside the test,
3
+ * which is a defect and not a test (specs/cowshed/08_testing.md, "Integration tests (real substrate)"): the pre-signal
4
+ * snapshot names the processes whose CPU time rose between its two process censuses, so the expiry fails as that and
5
+ * not as an anonymous hang. CPU never restarts the idle bound, which counts only finished tests and the progress a
6
+ * running test reports (progress-channel.ts); this says what ran.
7
+ */
8
+ /** What a rising process makes of the expiry, said in the same words by the snapshot and by the verdict. */
9
+ export const CPU_RISING_CLASS = "a process in the test's tree was using CPU: likely a build inside the test";
10
+ /**
11
+ * The least gain that names a rise, whatever resolution ps prints CPU time at: 10% of a core over the snapshot's five
12
+ * seconds between censuses.
13
+ */
14
+ export const CPU_RISE_FLOOR_MS = 500;
15
+ /** The longest command a rise keeps: a compiler's argument list runs to kilobytes, and its name leads it. */
16
+ const COMMAND_CHARS = 160;
17
+ function resolutionOfFraction(digits) {
18
+ switch (digits) {
19
+ case 0:
20
+ return 1_000;
21
+ case 1:
22
+ return 100;
23
+ case 2:
24
+ return 10;
25
+ default:
26
+ return 1;
27
+ }
28
+ }
29
+ /**
30
+ * A ps CPU time (`cputime=`): `[[D-]HH:]MM:SS` with an optional fraction, as Linux prints it (whole seconds) and macOS
31
+ * does (centiseconds). Null for anything else, such as the `-` ps prints for a process it may not read.
32
+ */
33
+ export function parseCpuTime(text) {
34
+ const match = /^(?:(\d+)-)?(?:(\d+):)?(\d+):(\d+(?:\.(\d+))?)$/.exec(text);
35
+ if (match === null)
36
+ return null;
37
+ const [, days, hours, minutes, seconds, fraction] = match;
38
+ if (minutes === undefined || seconds === undefined)
39
+ return null;
40
+ const wholeMinutes = ((Number(days ?? 0) * 24 + Number(hours ?? 0)) * 60 + Number(minutes)) * 60;
41
+ return {
42
+ ms: Math.round((wholeMinutes + Number(seconds)) * 1_000),
43
+ resolutionMs: resolutionOfFraction(fraction?.length ?? 0),
44
+ };
45
+ }
46
+ /**
47
+ * The least gain between two readings of one process that names a rise: twice the coarser of their resolutions, and
48
+ * never under {@link CPU_RISE_FLOOR_MS}. A process that crossed a boundary of the last printed digit on a few
49
+ * milliseconds of work gains one resolution, so two are more than one. That is 2,000 ms between whole-second readings
50
+ * and 500 ms between centisecond ones.
51
+ */
52
+ export function cpuRiseThresholdMs(before, after) {
53
+ return Math.max(CPU_RISE_FLOOR_MS, 2 * Math.max(before.resolutionMs, after.resolutionMs));
54
+ }
55
+ /** Each process present in both censuses (same pid and start), as its earlier and its later sample. */
56
+ function paired(before, after) {
57
+ const earlier = new Map(before.map((sample) => [`${sample.pid} ${sample.started}`, sample]));
58
+ const pairs = [];
59
+ for (const sample of after) {
60
+ const first = earlier.get(`${sample.pid} ${sample.started}`);
61
+ if (first !== undefined)
62
+ pairs.push([first, sample]);
63
+ }
64
+ return pairs;
65
+ }
66
+ /**
67
+ * The processes present in both censuses (same pid and start) whose CPU time rose by at least
68
+ * {@link cpuRiseThresholdMs}.
69
+ */
70
+ export function cpuChange(before, after) {
71
+ const rising = [];
72
+ const unread = [];
73
+ for (const [first, sample] of paired(before, after)) {
74
+ if (first.cpu === null || sample.cpu === null) {
75
+ unread.push(sample.pid);
76
+ continue;
77
+ }
78
+ const gainedMs = sample.cpu.ms - first.cpu.ms;
79
+ if (gainedMs < cpuRiseThresholdMs(first.cpu, sample.cpu))
80
+ continue;
81
+ const command = sample.command.length > COMMAND_CHARS ? `${sample.command.slice(0, COMMAND_CHARS)}…` : sample.command;
82
+ rising.push({ pid: sample.pid, command, gainedMs });
83
+ }
84
+ rising.sort((a, b) => b.gainedMs - a.gainedMs || a.pid - b.pid);
85
+ return { rising, unread };
86
+ }
87
+ /**
88
+ * The gains {@link cpuChange} held these censuses to, each distinct one once, smallest first: one per resolution of the
89
+ * readings compared, and none when no process had a readable CPU time in both.
90
+ */
91
+ export function cpuRiseThresholdsMs(before, after) {
92
+ const thresholds = new Set();
93
+ for (const [first, sample] of paired(before, after)) {
94
+ if (first.cpu !== null && sample.cpu !== null)
95
+ thresholds.add(cpuRiseThresholdMs(first.cpu, sample.cpu));
96
+ }
97
+ return [...thresholds].sort((a, b) => a - b);
98
+ }
99
+ /** The gains of {@link cpuRiseThresholdsMs} in seconds, as the snapshot says them: `2 s`, or `0.5 s or 2 s`. */
100
+ export function describeCpuThresholds(thresholdsMs) {
101
+ return thresholdsMs.map((ms) => `${ms / 1_000} s`).join(' or ');
102
+ }
103
+ export function describeCpuRise(rise) {
104
+ return `pid ${rise.pid} (${rise.command}) gained ${(rise.gainedMs / 1_000).toFixed(1)} s of CPU`;
105
+ }
106
+ /** The largest gains, named, and how many more there were: a parallel build runs many processes. */
107
+ export function describeCpuRises(rises, named = 3) {
108
+ const shown = rises.slice(0, named).map(describeCpuRise);
109
+ const more = rises.length - shown.length;
110
+ return `${shown.join('; ')}${more > 0 ? `; and ${more} more` : ''}`;
111
+ }
@@ -0,0 +1,146 @@
1
+ /**
2
+ * The life of an Nx run's mbx reservation endpoint in the run that started it (mbx-reservations.ts;
3
+ * specs/cowshed/05_gateway.md, "Parallelism inside a job"), as a state machine over what the run can observe of its
4
+ * child. Pure: no I/O, no clock and no timer. The shell maps the child's and the probe's events into `EndpointEvent`s
5
+ * and executes the `EndpointEffect`s each step answers, in their order; it decides nothing.
6
+ *
7
+ * The run waits in four phases, each for events only:
8
+ *
9
+ * - `starting`, for the child's first line on its standard output, or its end. `listening` opens the probe; any other
10
+ * line is refused and the child killed. A child whose standard output ends without a line can say none: its start
11
+ * is refused, by how it ended when it ends within the reap bound, and it is killed when it does not.
12
+ * - `probing`, for the endpoint's answer to `{"type":"capabilities"}` on the probe's connection, or that connection's
13
+ * end: whether the installed mbx's shim gates test cases (05_gateway.md, "A case starts on a core"). The start is
14
+ * then answered served, which publishes the socket to the run's tasks. A child that ends first is refused by how it
15
+ * ended: no task is told of an endpoint that is gone.
16
+ * - `serving`, for the run's end. A child that ends first is `gone`, and the run's end says how.
17
+ * - `ending`, for the child's end once a pipe of it closed (its standard input by the run, its standard output by
18
+ * itself) or it was killed, with the reap timer armed.
19
+ *
20
+ * The start is answered once (`serve` or `refuse`) and a served endpoint's end once (`conclude`); `ended` takes no
21
+ * event.
22
+ */
23
+ export type EndpointLife = {
24
+ readonly phase: 'starting';
25
+ readonly out: string;
26
+ readonly said: string;
27
+ readonly pid: number | undefined;
28
+ } | {
29
+ readonly phase: 'probing';
30
+ readonly reply: string;
31
+ readonly said: string;
32
+ readonly pid: number | undefined;
33
+ } | {
34
+ readonly phase: 'serving';
35
+ readonly said: string;
36
+ readonly pid: number | undefined;
37
+ } | {
38
+ readonly phase: 'gone';
39
+ readonly ended: Ended;
40
+ } | {
41
+ readonly phase: 'ending';
42
+ readonly pid: number | undefined;
43
+ readonly said: string;
44
+ /** Whether the child was sent SIGKILL; otherwise a pipe of it closed and its end is awaited. */
45
+ readonly killed: boolean;
46
+ /**
47
+ * Why its start is refused; null for a served endpoint ending with its run. An unkilled child that ends is
48
+ * refused by how it ended instead, which says more.
49
+ */
50
+ readonly refusing: string | null;
51
+ } | {
52
+ readonly phase: 'ended';
53
+ };
54
+ /** How a served endpoint ended, and whether that was its ordinary end: status 0 with nothing said, unkilled. */
55
+ export interface Ended {
56
+ readonly how: string;
57
+ readonly clean: boolean;
58
+ }
59
+ /** What the shell observes. `run-end` is the run's own: its `postTasksExecution`, or a held run's question answered. */
60
+ export type EndpointEvent = {
61
+ readonly type: 'stdout';
62
+ readonly text: string;
63
+ } | {
64
+ readonly type: 'stdout-end';
65
+ } | {
66
+ readonly type: 'stderr';
67
+ readonly text: string;
68
+ }
69
+ /** Node's `error` of the child: it could not be spawned. */
70
+ | {
71
+ readonly type: 'error';
72
+ readonly message: string;
73
+ }
74
+ /** Node's `close` of the child: it has exited and its pipes have ended. */
75
+ | {
76
+ readonly type: 'close';
77
+ readonly code: number | null;
78
+ readonly signal: string | null;
79
+ } | {
80
+ readonly type: 'probe';
81
+ readonly text: string;
82
+ }
83
+ /** The probe's connection ended or failed. */
84
+ | {
85
+ readonly type: 'probe-end';
86
+ } | {
87
+ readonly type: 'run-end';
88
+ }
89
+ /** The reap timer the last `arm` started has run out. */
90
+ | {
91
+ readonly type: 'expired';
92
+ };
93
+ /** What the shell does. `refuse` and `conclude` remove the socket's directory before they answer. */
94
+ export type EndpointEffect =
95
+ /** Connect to the endpoint's socket and send it `{"type":"capabilities"}`. */
96
+ {
97
+ readonly do: 'probe';
98
+ }
99
+ /** End the probe's connection. */
100
+ | {
101
+ readonly do: 'hang-up';
102
+ }
103
+ /** Answer the start: the endpoint serves, and its mbx gates test cases or does not. */
104
+ | {
105
+ readonly do: 'serve';
106
+ readonly gates: boolean;
107
+ }
108
+ /** Answer the start: no endpoint, and why. */
109
+ | {
110
+ readonly do: 'refuse';
111
+ readonly why: string;
112
+ } | {
113
+ readonly do: 'close-stdin';
114
+ } | {
115
+ readonly do: 'kill';
116
+ }
117
+ /** Stop the child and its pipes from keeping the run alive, without signalling it again. */
118
+ | {
119
+ readonly do: 'unref-child';
120
+ } | {
121
+ readonly do: 'arm';
122
+ readonly ms: number;
123
+ } | {
124
+ readonly do: 'disarm';
125
+ }
126
+ /** Answer the run's end. */
127
+ | {
128
+ readonly do: 'conclude';
129
+ readonly ended: Ended;
130
+ };
131
+ export type EndpointStep = readonly [EndpointLife, readonly EndpointEffect[]];
132
+ /** The life of a child just spawned; `pid` is what names it should it not end when killed. */
133
+ export declare function spawned(pid: number | undefined): EndpointLife;
134
+ /**
135
+ * Whether the mbx that answered `line` to `{"type":"capabilities"}` gates test cases. One that does not know the
136
+ * request answers an error, which gates nothing.
137
+ */
138
+ /**
139
+ * Whether the mbx that answered `line` to `{"type":"capabilities"}` gates test cases. One that does not know the
140
+ * request answers an error, which gates nothing, and so does a line that is no JSON: typia's parse validates what
141
+ * `JSON.parse` returns and throws what it throws.
142
+ */
143
+ export declare function gatesTests(line: string): boolean;
144
+ /** The next state of `life` at `event`, and what the shell does about it. */
145
+ export declare function endpointStep(life: EndpointLife, event: EndpointEvent): EndpointStep;
146
+ //# sourceMappingURL=endpoint-life.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-life.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/endpoint-life.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAC7G;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAC9G;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GACtF;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GACjD;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AC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOhD;AA+BD,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,GAAG,YAAY,CAenF"}
@@ -0,0 +1,228 @@
1
+ import * as _validateReport_1 from "typia/lib/internal/_validateReport";
2
+ import typia from 'typia';
3
+ import { REAP_MS } from './lease-wait.js';
4
+ /** What is kept of the endpoint's stderr to say why it ended: its last bytes. */
5
+ const SAID_BYTES = 4096;
6
+ /** The life of a child just spawned; `pid` is what names it should it not end when killed. */
7
+ export function spawned(pid) {
8
+ return { phase: 'starting', out: '', said: '', pid };
9
+ }
10
+ const ENDED = { phase: 'ended' };
11
+ const parseCapabilities = (() => {
12
+ let errors;
13
+ let _report;
14
+ const _io0 = input => "capabilities" === input.type && "boolean" === typeof input.test_gate;
15
+ const _vo0 = (input, _path, _exceptionable = true) => ["capabilities" === input.type || _report(_exceptionable, {
16
+ path: _path + ".type",
17
+ expected: "\"capabilities\"",
18
+ value: input.type
19
+ }), "boolean" === typeof input.test_gate || _report(_exceptionable, {
20
+ path: _path + ".test_gate",
21
+ expected: "boolean",
22
+ value: input.test_gate
23
+ })].every(flag => flag);
24
+ const __is = input => "object" === typeof input && null !== input && _io0(input);
25
+ const __validate = input => {
26
+ if (false === __is(input)) {
27
+ errors = [];
28
+ _report = _validateReport_1._validateReport(errors);
29
+ ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
30
+ path: _path + "",
31
+ expected: "CapabilitiesReply",
32
+ value: input
33
+ })) && _vo0(input, _path + "", true) || _report(true, {
34
+ path: _path + "",
35
+ expected: "CapabilitiesReply",
36
+ value: input
37
+ }))(input, "$input", true);
38
+ const success = 0 === errors.length;
39
+ return success ? {
40
+ success,
41
+ data: input
42
+ } : {
43
+ success,
44
+ errors,
45
+ data: input
46
+ };
47
+ }
48
+ return {
49
+ success: true,
50
+ data: input
51
+ };
52
+ };
53
+ return input => __validate(JSON.parse(input));
54
+ })();
55
+ /**
56
+ * Whether the mbx that answered `line` to `{"type":"capabilities"}` gates test cases. One that does not know the
57
+ * request answers an error, which gates nothing.
58
+ */
59
+ /**
60
+ * Whether the mbx that answered `line` to `{"type":"capabilities"}` gates test cases. One that does not know the
61
+ * request answers an error, which gates nothing, and so does a line that is no JSON: typia's parse validates what
62
+ * `JSON.parse` returns and throws what it throws.
63
+ */
64
+ export function gatesTests(line) {
65
+ try {
66
+ const reply = parseCapabilities(line);
67
+ return reply.success && reply.data.test_gate;
68
+ }
69
+ catch {
70
+ return false;
71
+ }
72
+ }
73
+ /** `text` up to its first line break, or null while it holds none. */
74
+ function firstLine(text) {
75
+ const end = text.indexOf('\n');
76
+ return end === -1 ? null : text.slice(0, end);
77
+ }
78
+ function saying(said, text) {
79
+ return (said + text).slice(-SAID_BYTES);
80
+ }
81
+ function closed(said, code, signal) {
82
+ const last = said.trim().split('\n').at(-1) ?? '';
83
+ return {
84
+ how: `mbx reservations ended ${signal === null ? `with status ${code}` : `on ${signal}`}${last === '' ? '' : `: ${last}`}`,
85
+ clean: signal === null && code === 0 && last === '',
86
+ };
87
+ }
88
+ function unspawned(message) {
89
+ return { how: `mbx reservations could not run: ${message}`, clean: false };
90
+ }
91
+ /** How the child ended, when `event` is its end. */
92
+ function endOf(said, event) {
93
+ if (event.type === 'close')
94
+ return closed(said, event.code, event.signal);
95
+ if (event.type === 'error')
96
+ return unspawned(event.message);
97
+ return null;
98
+ }
99
+ /** The next state of `life` at `event`, and what the shell does about it. */
100
+ export function endpointStep(life, event) {
101
+ switch (life.phase) {
102
+ case 'starting':
103
+ return starting(life, event);
104
+ case 'probing':
105
+ return probing(life, event);
106
+ case 'serving':
107
+ return serving(life, event);
108
+ case 'gone':
109
+ return event.type === 'run-end' ? [ENDED, [{ do: 'conclude', ended: life.ended }]] : [life, []];
110
+ case 'ending':
111
+ return ending(life, event);
112
+ case 'ended':
113
+ return [life, []];
114
+ }
115
+ }
116
+ function unanswered(phase) {
117
+ throw new Error(`the run's end reached its endpoint while ${phase}: the run holds no endpoint before its start is answered`);
118
+ }
119
+ function starting(life, event) {
120
+ const ended = endOf(life.said, event);
121
+ if (ended !== null)
122
+ return [ENDED, [{ do: 'refuse', why: ended.how }]];
123
+ switch (event.type) {
124
+ case 'stderr':
125
+ return [{ ...life, said: saying(life.said, event.text) }, []];
126
+ case 'stdout': {
127
+ const out = life.out + event.text;
128
+ const line = firstLine(out);
129
+ if (line === null)
130
+ return [{ ...life, out }, []];
131
+ if (line === 'listening') {
132
+ return [{ phase: 'probing', reply: '', said: life.said, pid: life.pid }, [{ do: 'probe' }]];
133
+ }
134
+ return [
135
+ {
136
+ phase: 'ending',
137
+ pid: life.pid,
138
+ said: life.said,
139
+ killed: true,
140
+ refusing: `mbx reservations said ${JSON.stringify(line)}, not that it was listening`,
141
+ },
142
+ [{ do: 'kill' }, { do: 'arm', ms: REAP_MS }],
143
+ ];
144
+ }
145
+ case 'stdout-end': {
146
+ const unsaid = `mbx reservations closed its standard output ${life.out === '' ? '' : `after ${JSON.stringify(life.out)}, `}without saying it was listening`;
147
+ return [
148
+ { phase: 'ending', pid: life.pid, said: life.said, killed: false, refusing: unsaid },
149
+ [{ do: 'arm', ms: REAP_MS }],
150
+ ];
151
+ }
152
+ case 'run-end':
153
+ return unanswered(life.phase);
154
+ default:
155
+ return [life, []];
156
+ }
157
+ }
158
+ function probing(life, event) {
159
+ const served = { phase: 'serving', said: life.said, pid: life.pid };
160
+ const ended = endOf(life.said, event);
161
+ if (ended !== null)
162
+ return [ENDED, [{ do: 'hang-up' }, { do: 'refuse', why: ended.how }]];
163
+ switch (event.type) {
164
+ case 'stderr':
165
+ return [{ ...life, said: saying(life.said, event.text) }, []];
166
+ case 'probe': {
167
+ const reply = life.reply + event.text;
168
+ const line = firstLine(reply);
169
+ if (line === null)
170
+ return [{ ...life, reply }, []];
171
+ return [served, [{ do: 'hang-up' }, { do: 'serve', gates: gatesTests(line) }]];
172
+ }
173
+ case 'probe-end':
174
+ return [served, [{ do: 'serve', gates: false }]];
175
+ case 'run-end':
176
+ return unanswered(life.phase);
177
+ default:
178
+ return [life, []];
179
+ }
180
+ }
181
+ function serving(life, event) {
182
+ const ended = endOf(life.said, event);
183
+ if (ended !== null)
184
+ return [{ phase: 'gone', ended }, []];
185
+ switch (event.type) {
186
+ case 'stderr':
187
+ return [{ ...life, said: saying(life.said, event.text) }, []];
188
+ case 'run-end':
189
+ return [
190
+ { phase: 'ending', said: life.said, pid: life.pid, killed: false, refusing: null },
191
+ [{ do: 'close-stdin' }, { do: 'arm', ms: REAP_MS }],
192
+ ];
193
+ default:
194
+ return [life, []];
195
+ }
196
+ }
197
+ function ending(life, event) {
198
+ const ended = endOf(life.said, event);
199
+ if (ended !== null) {
200
+ if (life.refusing !== null) {
201
+ return [ENDED, [{ do: 'disarm' }, { do: 'refuse', why: life.killed ? life.refusing : ended.how }]];
202
+ }
203
+ const outlived = life.killed
204
+ ? { how: `${ended.how}, killed after it outlived its standard input by ${REAP_MS}ms`, clean: false }
205
+ : ended;
206
+ return [ENDED, [{ do: 'disarm' }, { do: 'conclude', ended: outlived }]];
207
+ }
208
+ switch (event.type) {
209
+ case 'stderr':
210
+ return [{ ...life, said: saying(life.said, event.text) }, []];
211
+ case 'expired': {
212
+ // A closed pipe did not end it within the reap bound: kill it, and wait that bound once more.
213
+ if (!life.killed) {
214
+ const refusing = life.refusing === null ? null : `${life.refusing}, and had not ended ${REAP_MS}ms later`;
215
+ return [{ ...life, killed: true, refusing }, [{ do: 'kill' }, { do: 'arm', ms: REAP_MS }]];
216
+ }
217
+ // Neither did the kill: it is stuck in the kernel, or something it started holds its pipes. The wait ends and
218
+ // says so; the child is left as it is (05_gateway.md, "A child's exit and its output are reap-class waits").
219
+ const left = `${life.pid === undefined ? 'it' : `pid ${life.pid}`} had not ended ${REAP_MS}ms after it was killed and is left as it is`;
220
+ if (life.refusing !== null)
221
+ return [ENDED, [{ do: 'unref-child' }, { do: 'refuse', why: `${life.refusing}; ${left}` }]];
222
+ const how = `mbx reservations outlived its standard input by ${REAP_MS}ms; ${left}`;
223
+ return [ENDED, [{ do: 'unref-child' }, { do: 'conclude', ended: { how, clean: false } }]];
224
+ }
225
+ default:
226
+ return [life, []];
227
+ }
228
+ }
@@ -4,7 +4,7 @@ import { type RunOutcome } from './memory-retry.js';
4
4
  import { type SubtreeOwner } from './owned-subtree.js';
5
5
  import { type InheritedCpuPool } from './pool-environment.js';
6
6
  import { RamTempVolume } from './ram-temp.js';
7
- import type { BoundedExecOptions } from './schema.js';
7
+ import { type BoundedExecOptions } from './schema.js';
8
8
  import { type BoundedExecTask } from './verdict.js';
9
9
  export interface BoundedExecContext {
10
10
  root: string;
@@ -1 +1 @@
1
- {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/executor.ts"],"names":[],"mappings":"AAeA,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAM5E,OAAO,EAAE,sBAAsB,EAAmB,MAAM,uBAAuB,CAAC;AAahF,OAAO,EAAqB,KAAK,UAAU,EAA8B,MAAM,mBAAmB,CAAC;AAEnG,OAAO,EAOL,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAgB,KAAK,gBAAgB,EAAwB,MAAM,uBAAuB,CAAC;AAElG,OAAO,EASL,aAAa,EAEd,MAAM,eAAe,CAAC;AAIvB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAEL,KAAK,eAAe,EAcrB,MAAM,cAAc,CAAC;AAwBtB,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,wFAAwF;IACxF,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,eAAe,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACtD,uFAAuF;IACvF,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;C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