@smoothbricks/nx-plugin 0.7.18 → 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 (143) hide show
  1. package/README.md +160 -99
  2. package/dist/.build-inputs.json +35 -29
  3. package/dist/built-output-packages.js +1 -1
  4. package/dist/cargo-closure-input.js +1 -1
  5. package/dist/cargo-source-hash.d.ts +3 -21
  6. package/dist/cargo-source-hash.d.ts.map +1 -1
  7. package/dist/cargo-source-hash.js +4 -91
  8. package/dist/cargo-toolchain-paths.d.ts +2 -2
  9. package/dist/cargo-toolchain-paths.js +2 -2
  10. package/dist/cargo-workspace.d.ts.map +1 -1
  11. package/dist/cargo-workspace.js +2 -1
  12. package/dist/executors/bounded-exec/admission-queue.d.ts +3 -1
  13. package/dist/executors/bounded-exec/admission-queue.d.ts.map +1 -1
  14. package/dist/executors/bounded-exec/admission-queue.js +9 -10
  15. package/dist/executors/bounded-exec/awake-clock.d.ts +5 -0
  16. package/dist/executors/bounded-exec/awake-clock.d.ts.map +1 -0
  17. package/dist/executors/bounded-exec/awake-clock.js +22 -0
  18. package/dist/executors/bounded-exec/bounds.d.ts +7 -5
  19. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
  20. package/dist/executors/bounded-exec/bounds.js +14 -11
  21. package/dist/executors/bounded-exec/case-gate.d.ts +114 -0
  22. package/dist/executors/bounded-exec/case-gate.d.ts.map +1 -0
  23. package/dist/executors/bounded-exec/case-gate.js +342 -0
  24. package/dist/executors/bounded-exec/cpu-pool-thread.d.ts +1 -0
  25. package/dist/executors/bounded-exec/cpu-pool-thread.d.ts.map +1 -1
  26. package/dist/executors/bounded-exec/cpu-pool-thread.js +2 -2
  27. package/dist/executors/bounded-exec/cpu-pool.d.ts +28 -1
  28. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  29. package/dist/executors/bounded-exec/cpu-pool.js +102 -16
  30. package/dist/executors/bounded-exec/endpoint-life.d.ts +146 -0
  31. package/dist/executors/bounded-exec/endpoint-life.d.ts.map +1 -0
  32. package/dist/executors/bounded-exec/endpoint-life.js +228 -0
  33. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  34. package/dist/executors/bounded-exec/executor.js +207 -69
  35. package/dist/executors/bounded-exec/gateway-lease.d.ts +1 -1
  36. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
  37. package/dist/executors/bounded-exec/gateway-lease.js +8 -1
  38. package/dist/executors/bounded-exec/go-run-summary.d.ts +51 -0
  39. package/dist/executors/bounded-exec/go-run-summary.d.ts.map +1 -0
  40. package/dist/executors/bounded-exec/go-run-summary.js +98 -0
  41. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +3 -3
  42. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  43. package/dist/executors/bounded-exec/hang-diagnostics.js +66 -48
  44. package/dist/executors/bounded-exec/lease-wait.d.ts +1 -0
  45. package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -1
  46. package/dist/executors/bounded-exec/lease-wait.js +1 -0
  47. package/dist/executors/bounded-exec/mbx-pool.d.ts +28 -7
  48. package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
  49. package/dist/executors/bounded-exec/mbx-pool.js +30 -9
  50. package/dist/executors/bounded-exec/mbx-reservations.d.ts +8 -5
  51. package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -1
  52. package/dist/executors/bounded-exec/mbx-reservations.js +187 -283
  53. package/dist/executors/bounded-exec/parent-grant.d.ts +2 -0
  54. package/dist/executors/bounded-exec/parent-grant.d.ts.map +1 -1
  55. package/dist/executors/bounded-exec/parent-grant.js +1 -0
  56. package/dist/executors/bounded-exec/pool-admission.d.ts +29 -3
  57. package/dist/executors/bounded-exec/pool-admission.d.ts.map +1 -1
  58. package/dist/executors/bounded-exec/pool-admission.js +47 -1
  59. package/dist/executors/bounded-exec/progress.d.ts +3 -0
  60. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  61. package/dist/executors/bounded-exec/progress.js +31 -1
  62. package/dist/executors/bounded-exec/reservation-connection.d.ts +90 -0
  63. package/dist/executors/bounded-exec/reservation-connection.d.ts.map +1 -0
  64. package/dist/executors/bounded-exec/reservation-connection.js +248 -0
  65. package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
  66. package/dist/executors/bounded-exec/run-cpu-pool.js +3 -0
  67. package/dist/executors/bounded-exec/runner-sizing.d.ts +9 -5
  68. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
  69. package/dist/executors/bounded-exec/runner-sizing.js +13 -9
  70. package/dist/executors/bounded-exec/schema.d.ts +2 -2
  71. package/dist/executors/bounded-exec/suite-minimum.d.ts +21 -0
  72. package/dist/executors/bounded-exec/suite-minimum.d.ts.map +1 -0
  73. package/dist/executors/bounded-exec/suite-minimum.js +85 -0
  74. package/dist/executors/bounded-exec/test-result-writer.d.ts +2 -0
  75. package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -1
  76. package/dist/executors/bounded-exec/test-result-writer.js +1 -0
  77. package/dist/executors/bounded-exec/test-results.d.ts +5 -0
  78. package/dist/executors/bounded-exec/test-results.d.ts.map +1 -1
  79. package/dist/executors/bounded-exec/test-results.js +2 -2
  80. package/dist/executors/bounded-exec/verdict.d.ts +26 -4
  81. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  82. package/dist/executors/bounded-exec/verdict.js +26 -5
  83. package/dist/executors/cargo-zigbuild/executor.d.ts +10 -8
  84. package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
  85. package/dist/executors/cargo-zigbuild/executor.js +32 -19
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +105 -73
  88. package/dist/managed-files/ci-workflow.d.ts +4 -1
  89. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  90. package/dist/managed-files/ci-workflow.js +9 -14
  91. package/dist/managed-files/files.d.ts +3 -3
  92. package/dist/managed-files/files.js +3 -3
  93. package/dist/task-results.js +2 -1
  94. package/dist/workspace-config-policy.d.ts.map +1 -1
  95. package/dist/workspace-config-policy.js +135 -42
  96. package/executors.json +2 -0
  97. package/managed/raw/envrc +24 -0
  98. package/managed/raw/patches/nx@24.0.3.patch +1179 -133
  99. package/managed/raw/patches/ttsc@0.37.1.patch +1055 -0
  100. package/managed/raw/tooling/direnv/developer-links.ts +105 -11
  101. package/managed/raw/tooling/direnv/devenv.smoo.nix +20 -19
  102. package/package.json +67 -11
  103. package/runtime/nx-publish/.build-inputs.json +2 -2
  104. package/runtime/nx-publish/cache_adapter.js +293 -3
  105. package/runtime/nx-publish/nx_publish.js +36 -14
  106. package/src/built-output-packages.ts +1 -1
  107. package/src/cargo-closure-input.ts +1 -1
  108. package/src/cargo-source-hash.ts +16 -132
  109. package/src/cargo-toolchain-paths.ts +2 -2
  110. package/src/cargo-workspace.ts +1 -2
  111. package/src/executors/bounded-exec/admission-queue.ts +11 -10
  112. package/src/executors/bounded-exec/awake-clock.ts +20 -0
  113. package/src/executors/bounded-exec/bounds.ts +28 -15
  114. package/src/executors/bounded-exec/case-gate.ts +365 -0
  115. package/src/executors/bounded-exec/cpu-pool-thread.ts +3 -3
  116. package/src/executors/bounded-exec/cpu-pool.ts +139 -12
  117. package/src/executors/bounded-exec/endpoint-life.ts +279 -0
  118. package/src/executors/bounded-exec/executor.ts +280 -106
  119. package/src/executors/bounded-exec/gateway-lease.ts +6 -0
  120. package/src/executors/bounded-exec/go-run-summary.ts +137 -0
  121. package/src/executors/bounded-exec/hang-diagnostics.ts +70 -52
  122. package/src/executors/bounded-exec/lease-wait.ts +1 -0
  123. package/src/executors/bounded-exec/mbx-pool.ts +36 -9
  124. package/src/executors/bounded-exec/mbx-reservations.ts +213 -182
  125. package/src/executors/bounded-exec/parent-grant.ts +3 -0
  126. package/src/executors/bounded-exec/pool-admission.ts +59 -2
  127. package/src/executors/bounded-exec/progress.ts +37 -2
  128. package/src/executors/bounded-exec/reservation-connection.ts +221 -0
  129. package/src/executors/bounded-exec/run-cpu-pool.ts +2 -0
  130. package/src/executors/bounded-exec/runner-sizing.ts +13 -8
  131. package/src/executors/bounded-exec/schema.json +1 -1
  132. package/src/executors/bounded-exec/schema.ts +2 -2
  133. package/src/executors/bounded-exec/suite-minimum.ts +81 -0
  134. package/src/executors/bounded-exec/test-result-writer.ts +3 -0
  135. package/src/executors/bounded-exec/test-results.ts +5 -0
  136. package/src/executors/bounded-exec/verdict.ts +39 -6
  137. package/src/executors/cargo-zigbuild/executor.ts +30 -19
  138. package/src/index.ts +112 -78
  139. package/src/managed-files/ci-workflow.ts +13 -17
  140. package/src/managed-files/files.ts +3 -3
  141. package/src/workspace-config-policy.ts +161 -43
  142. package/test-timings.json +157 -147
  143. package/managed/raw/patches/ttsc@0.36.3.patch +0 -1660
@@ -44,7 +44,7 @@ export const GATEWAY_SOCKET = '/private/cowshed/store/gateway.sock';
44
44
  * refusal. CPU admission instead uses its own control/silence policy: no compatibility half-close,
45
45
  * and no total queue bound (specs/cowshed/05_gateway.md, "Deadlines").
46
46
  */
47
- export function holdLease(socket, request, what, bounds, onQueued) {
47
+ export function holdLease(socket, request, what, bounds, onQueued, withdrawn) {
48
48
  // `Promise.withResolvers` would read better but needs lib es2024; this package inherits lib
49
49
  // es2022 from tsconfig.base.json.
50
50
  let resolve;
@@ -212,5 +212,12 @@ export function holdLease(socket, request, what, bounds, onQueued) {
212
212
  socketClosed = true;
213
213
  unleased(`the lease connection for ${what} at ${socket} closed`);
214
214
  });
215
+ if (withdrawn !== undefined) {
216
+ const withdraw = () => unleased(`the request for ${what} at ${socket} was withdrawn`);
217
+ if (withdrawn.aborted)
218
+ withdraw();
219
+ else
220
+ withdrawn.addEventListener('abort', withdraw, { once: true });
221
+ }
215
222
  return promise;
216
223
  }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * A Go run by its top-level tests. `go test -json` reports every event and sums none, and a consumer that keeps only
3
+ * part of a long output cannot count it, so the run that read every event states the sum where its output ends.
4
+ */
5
+ export interface GoRunSummary {
6
+ readonly passed: number;
7
+ readonly failed: number;
8
+ readonly skipped: number;
9
+ readonly packages: number;
10
+ readonly failedTests: readonly GoFailedTest[];
11
+ /** Packages that failed with no failed test of their own: a build that did not compile, a `TestMain` that exited. */
12
+ readonly failedPackages: readonly string[];
13
+ }
14
+ export interface GoFailedTest {
15
+ readonly package: string;
16
+ readonly test: string;
17
+ }
18
+ /** One package as `go list -f GO_LIST_FORMAT` prints it: its directory and its in-package and external test files. */
19
+ export interface GoPackageFiles {
20
+ readonly package: string;
21
+ readonly directory: string;
22
+ readonly files: readonly string[];
23
+ }
24
+ export declare const GO_LIST_FORMAT = "{{.ImportPath}}\t{{.Dir}}\t{{join .TestGoFiles \",\"}}\t{{join .XTestGoFiles \",\"}}";
25
+ export declare function parseGoList(stdout: string): GoPackageFiles[];
26
+ /**
27
+ * The file of a package that declares the top-level function `test`, and its line. Go admits one such function per
28
+ * test package, and a directory holds two test packages (in-package and external): a name both declare has no one
29
+ * file, and neither does a name none declares.
30
+ */
31
+ export declare function declarationOf(test: string, files: readonly {
32
+ readonly path: string;
33
+ readonly text: string;
34
+ }[]): {
35
+ path: string;
36
+ line: number;
37
+ } | null;
38
+ /** Each failed test whose declaration is found, as `<workspace path>:<line>`, keyed `<package>::<test>`. */
39
+ export declare function goDeclarations(failed: readonly GoFailedTest[], root: string, listed: readonly GoPackageFiles[], read: (path: string) => string | null): Map<string, string>;
40
+ /**
41
+ * The lines a Go run's output ends with. A failed test is named at its declaration, the identity a reader matches a
42
+ * source file by; one whose declaration was not found keeps its package, which no reader takes for a file.
43
+ */
44
+ export declare function goRunSummaryText(summary: GoRunSummary, declared: ReadonlyMap<string, string>): string;
45
+ /**
46
+ * The declarations of a run's failed tests, asked of the toolchain that ran them: `go list` names each failed package's
47
+ * directory and test files, and the file that declares the test is found among them. A list that does not answer
48
+ * leaves every test at its package, which the summary then prints.
49
+ */
50
+ export declare function declaredGoTests(failed: readonly GoFailedTest[], cwd: string, root: string, env: NodeJS.ProcessEnv): Map<string, string>;
51
+ //# sourceMappingURL=go-run-summary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"go-run-summary.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/go-run-summary.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,SAAS,YAAY,EAAE,CAAC;IAC9C,qHAAqH;IACrH,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5C;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,sHAAsH;AACtH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED,eAAO,MAAM,cAAc,yFAAqF,CAAC;AAEjH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,EAAE,CAY5D;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,GACjE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAUvC;AAED,4GAA4G;AAC5G,wBAAgB,cAAc,CAC5B,MAAM,EAAE,SAAS,YAAY,EAAE,EAC/B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,SAAS,cAAc,EAAE,EACjC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GACpC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAerB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CASrG;AAKD;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,SAAS,YAAY,EAAE,EAC/B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,CAAC,UAAU,GACrB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAmBrB"}
@@ -0,0 +1,98 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import { readFileSync } from 'node:fs';
3
+ import { join, relative, sep } from 'node:path';
4
+ export const GO_LIST_FORMAT = '{{.ImportPath}}\t{{.Dir}}\t{{join .TestGoFiles ","}}\t{{join .XTestGoFiles ","}}';
5
+ export function parseGoList(stdout) {
6
+ const packages = [];
7
+ for (const line of stdout.split('\n')) {
8
+ const [name, directory, own, external] = line.split('\t');
9
+ if (name === undefined || name === '' || directory === undefined || directory === '')
10
+ continue;
11
+ packages.push({
12
+ package: name,
13
+ directory,
14
+ files: [own ?? '', external ?? ''].flatMap((list) => (list === '' ? [] : list.split(','))),
15
+ });
16
+ }
17
+ return packages;
18
+ }
19
+ /**
20
+ * The file of a package that declares the top-level function `test`, and its line. Go admits one such function per
21
+ * test package, and a directory holds two test packages (in-package and external): a name both declare has no one
22
+ * file, and neither does a name none declares.
23
+ */
24
+ export function declarationOf(test, files) {
25
+ const declares = new RegExp(`^func\\s+${test.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\s*\\(`);
26
+ let found = null;
27
+ for (const file of files) {
28
+ const line = file.text.split('\n').findIndex((text) => declares.test(text));
29
+ if (line === -1)
30
+ continue;
31
+ if (found !== null)
32
+ return null;
33
+ found = { path: file.path, line: line + 1 };
34
+ }
35
+ return found;
36
+ }
37
+ /** Each failed test whose declaration is found, as `<workspace path>:<line>`, keyed `<package>::<test>`. */
38
+ export function goDeclarations(failed, root, listed, read) {
39
+ const declared = new Map();
40
+ for (const { package: name, test } of failed) {
41
+ const found = listed.find((entry) => entry.package === name);
42
+ if (found === undefined)
43
+ continue;
44
+ const files = found.files.flatMap((file) => {
45
+ const path = join(found.directory, file);
46
+ const text = read(path);
47
+ return text === null ? [] : [{ path, text }];
48
+ });
49
+ const declaration = declarationOf(test, files);
50
+ if (declaration === null)
51
+ continue;
52
+ declared.set(`${name}::${test}`, `${relative(root, declaration.path).split(sep).join('/')}:${declaration.line}`);
53
+ }
54
+ return declared;
55
+ }
56
+ /**
57
+ * The lines a Go run's output ends with. A failed test is named at its declaration, the identity a reader matches a
58
+ * source file by; one whose declaration was not found keeps its package, which no reader takes for a file.
59
+ */
60
+ export function goRunSummaryText(summary, declared) {
61
+ const lines = [
62
+ `go test summary: ${summary.passed} passed, ${summary.failed} failed, ${summary.skipped} skipped, ${summary.packages} packages`,
63
+ ...summary.failedTests.map(({ package: name, test }) => `go test failed: ${declared.get(`${name}::${test}`) ?? name} ${test}`),
64
+ ...summary.failedPackages.map((name) => `go test package failed: ${name}`),
65
+ ];
66
+ return `${lines.join('\n')}\n`;
67
+ }
68
+ /** How long `go list` may take to name the failed packages' directories and test files. */
69
+ const GO_LIST_MS = 60_000;
70
+ /**
71
+ * The declarations of a run's failed tests, asked of the toolchain that ran them: `go list` names each failed package's
72
+ * directory and test files, and the file that declares the test is found among them. A list that does not answer
73
+ * leaves every test at its package, which the summary then prints.
74
+ */
75
+ export function declaredGoTests(failed, cwd, root, env) {
76
+ if (failed.length === 0)
77
+ return new Map();
78
+ const packages = [...new Set(failed.map((test) => test.package))];
79
+ const listed = spawnSync('go', ['list', '-f', GO_LIST_FORMAT, ...packages], {
80
+ cwd,
81
+ env,
82
+ encoding: 'utf8',
83
+ timeout: GO_LIST_MS,
84
+ });
85
+ if (listed.status !== 0)
86
+ return new Map();
87
+ return goDeclarations(failed, root, parseGoList(listed.stdout), (path) => {
88
+ try {
89
+ return readFileSync(path, 'utf8');
90
+ }
91
+ catch (error) {
92
+ // A listed file that cannot be read declares nothing here; any other failure is a bug to see.
93
+ if (error instanceof Error && 'code' in error)
94
+ return null;
95
+ throw error;
96
+ }
97
+ });
98
+ }
@@ -23,8 +23,8 @@ export interface HangDiagnostics {
23
23
  export interface HangCaptureRequest {
24
24
  pid: number;
25
25
  pgid: number | null;
26
- expiresAtMs: number;
27
- deadlineMs: number;
26
+ awakeExpiresAtMs: number;
27
+ awakeNow(): number;
28
28
  signal?: AbortSignal;
29
29
  }
30
30
  export type HangProbeResult = {
@@ -58,5 +58,5 @@ export declare function captureHangDiagnostics(request: HangCaptureRequest, sour
58
58
  */
59
59
  export declare function stopProbe(file: string, pid: number): boolean;
60
60
  /** A probe owns its group and output pipes; its deadline never waits for an unresponsive child to reap. */
61
- export declare function runProbe(file: string, args: readonly string[], timeoutMs: number, signal: AbortSignal, environment?: NodeJS.ProcessEnv): Promise<HangProbeResult>;
61
+ export declare function runProbe(file: string, args: readonly string[], timeoutMs: number, signal: AbortSignal, environment?: NodeJS.ProcessEnv, now?: () => number): Promise<HangProbeResult>;
62
62
  //# sourceMappingURL=hang-diagnostics.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hang-diagnostics.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/hang-diagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,OAAO,EAOb,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,KAAK,QAAQ,EAKd,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAS,CAAC;AA4CtC,MAAM,WAAW,e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
2
2
  import { describeTeardown, killProcessGroupNow, TEARDOWN_PATIENCE } from '../../process-group.js';
3
3
  import { withDescendants } from '../../testing.js';
4
+ import { atClockDeadline } from './awake-clock.js';
4
5
  import { CPU_RISING_CLASS, cpuChange, cpuRiseThresholdsMs, describeCpuRise, describeCpuThresholds, parseCpuTime, } from './cpu-rise.js';
5
6
  import { describeHolders, lockCandidates, lockWaits, parseLsofFields, parseLsofTable, } from './lock-wait.js';
6
7
  /**
@@ -20,9 +21,9 @@ const PS_FIELDS = 'pid=,ppid=,pgid=,stat=,%cpu=,etime=,cputime=,lstart=,command=
20
21
  const CPU_INTERVAL_MS = 5_000;
21
22
  /**
22
23
  * Stack samples: `sample` suspends a process every millisecond for one second and reports its threads' call graph. The
23
- * runner and at most this many leaf processes are sampled, all at once. `-mayDie` is not passed: it reads symbols
24
- * before sampling and measured about a second slower under load, and a process that exits mid-sample is a raced
25
- * capture all the same.
24
+ * runner and at most this many leaf processes are sampled, all at once, and then at most this many named lock waiters
25
+ * those left out. `-mayDie` is not passed: it reads symbols before sampling and measured about a second slower under
26
+ * load, and a process that exits mid-sample is a raced capture all the same.
26
27
  */
27
28
  const MAX_SAMPLED_LEAVES = 4;
28
29
  const SAMPLE_SECONDS = 1;
@@ -47,25 +48,30 @@ function callGraph(report) {
47
48
  const end = report.indexOf('\nBinary Images:');
48
49
  return (end === -1 ? report : report.slice(0, end)).trim();
49
50
  }
50
- const host = { platform: process.platform, probe: runProbe, sleep: sleepUnlessAborted };
51
- function sleepUnlessAborted(ms, signal) {
51
+ function sleepUnlessAborted(ms, signal, now) {
52
52
  return new Promise((resolve) => {
53
53
  const done = () => {
54
- clearTimeout(timer);
54
+ cancelTimer();
55
55
  signal.removeEventListener('abort', done);
56
56
  resolve();
57
57
  };
58
- const timer = setTimeout(done, ms);
58
+ const cancelTimer = atClockDeadline(now() + ms, now, done);
59
59
  signal.addEventListener('abort', done, { once: true });
60
60
  if (signal.aborted)
61
61
  done();
62
62
  });
63
63
  }
64
64
  /** A pre-expiry observation, never an assertion that an open file is a contested lock. */
65
- export function captureHangDiagnostics(request, source = host) {
65
+ export function captureHangDiagnostics(request, source = {
66
+ platform: process.platform,
67
+ probe: (file, args, timeoutMs, signal) => runProbe(file, args, timeoutMs, signal, undefined, request.awakeNow),
68
+ sleep: (ms, signal) => sleepUnlessAborted(ms, signal, request.awakeNow),
69
+ }) {
66
70
  const startedAtMs = Date.now();
67
- const budgetMs = Math.max(0, Math.min(HANG_CAPTURE_MS, request.deadlineMs, request.expiresAtMs - startedAtMs));
68
- const endsAtMs = startedAtMs + budgetMs;
71
+ const { awakeNow, awakeExpiresAtMs } = request;
72
+ const startedAwake = awakeNow();
73
+ const endsAtMs = Math.min(startedAwake + HANG_CAPTURE_MS, awakeExpiresAtMs);
74
+ const budgetMs = Math.max(0, Math.min(HANG_CAPTURE_MS, awakeExpiresAtMs - startedAwake));
69
75
  const controller = new AbortController();
70
76
  const lines = [
71
77
  `Hang snapshot: pid=${request.pid} pgid=${request.pgid ?? 'unknown'} startedAtMs=${startedAtMs}`,
@@ -82,11 +88,11 @@ export function captureHangDiagnostics(request, source = host) {
82
88
  if (finished)
83
89
  return;
84
90
  finished = true;
85
- clearTimeout(timer);
91
+ cancelTimer();
86
92
  request.signal?.removeEventListener('abort', cancelled);
87
93
  controller.abort();
88
94
  const capturedAtMs = Date.now();
89
- const offsetFromExpiryMs = request.expiresAtMs - capturedAtMs;
95
+ const offsetFromExpiryMs = awakeExpiresAtMs - awakeNow();
90
96
  resolve({
91
97
  startedAtMs,
92
98
  capturedAtMs,
@@ -97,10 +103,10 @@ export function captureHangDiagnostics(request, source = host) {
97
103
  text: `${lines.join('\n')}\nHang snapshot outcome=${outcome} capturedAtMs=${capturedAtMs} offsetFromExpiryMs=${offsetFromExpiryMs}\n`,
98
104
  });
99
105
  };
100
- const timer = setTimeout(() => {
101
- lines.push(`Capture incomplete: ${budgetMs}ms deadline reached during ${during()}; no empty-holder conclusion.`);
106
+ const cancelTimer = atClockDeadline(endsAtMs, awakeNow, () => {
107
+ lines.push(`Capture incomplete: ${Math.ceil(budgetMs)}ms deadline reached during ${during()}; no empty-holder conclusion.`);
102
108
  finish('incomplete');
103
- }, budgetMs);
109
+ });
104
110
  const cancelled = () => {
105
111
  if (finished)
106
112
  return;
@@ -120,7 +126,7 @@ export function captureHangDiagnostics(request, source = host) {
120
126
  const probe = async (name, file, args, limitMs) => {
121
127
  active.add(name);
122
128
  lines.push(`${name}: ${file} ${args.join(' ')}`);
123
- const result = await source.probe(file, args, Math.max(0, Math.min(limitMs, endsAtMs - Date.now())), controller.signal);
129
+ const result = await source.probe(file, args, Math.max(0, Math.min(limitMs, endsAtMs - awakeNow())), controller.signal);
124
130
  active.delete(name);
125
131
  if (!finished) {
126
132
  lines.push(`${name}: ${result.status}${result.status === 'exited' ? ` code=${result.code}` : ` ${result.detail}`}`);
@@ -178,36 +184,43 @@ export function captureHangDiagnostics(request, source = host) {
178
184
  }
179
185
  return tree;
180
186
  };
181
- /**
182
- * One-second call stacks of the runner and of its tree's leaf processes, taken at once: a stack names the call a
183
- * process waits in, which the open-file census cannot. A sample sudo refuses, or one that does not answer, is named
184
- * as no stack for that process; stacks never change the holder outcome.
185
- */
186
- const stackSamples = async (tree) => {
187
+ /** The runner and up to MAX_SAMPLED_LEAVES leaf processes of `tree` (members with no live child), and the leaves past that bound. */
188
+ const leafSamples = (tree) => {
187
189
  const live = tree.filter((entry) => !entry.stat.startsWith('Z'));
188
190
  const parents = new Set(live.map((entry) => entry.ppid));
189
191
  const leaves = live.filter((entry) => entry.pid !== request.pid && !parents.has(entry.pid));
190
- const omitted = leaves.slice(MAX_SAMPLED_LEAVES).map((entry) => entry.pid);
192
+ return {
193
+ sampled: [request.pid, ...leaves.slice(0, MAX_SAMPLED_LEAVES).map((entry) => entry.pid)],
194
+ omitted: leaves.slice(MAX_SAMPLED_LEAVES).map((entry) => entry.pid),
195
+ };
196
+ };
197
+ /**
198
+ * One one-second call stack of `pid`, until the closing census would have less than its own limit left: a stack
199
+ * names the call a process waits in, which the open-file census cannot. A sample sudo refuses, or one that does
200
+ * not answer, is named as no stack for that process; stacks never change the holder outcome.
201
+ */
202
+ const sampleStack = async (pid) => {
203
+ const name = `stack sample pid ${pid}`;
204
+ // `-file /dev/stdout` writes the report to the probe's pipe alone, not also to a root-owned file in /tmp.
205
+ const args = ['-n', 'sample', String(pid), String(SAMPLE_SECONDS), '-file', '/dev/stdout'];
206
+ const result = await probe(name, 'sudo', args, endsAtMs - awakeNow() - CENSUS_LIMIT_MS);
207
+ if (finished)
208
+ return;
209
+ const report = callGraph(result.stdout);
210
+ if (result.status === 'exited' && result.code === 0 && report !== '') {
211
+ lines.push(`${name} (${SAMPLE_SECONDS}s; binary image list omitted):\n${report}`);
212
+ return;
213
+ }
214
+ if (report !== '')
215
+ lines.push(`Partial ${name} output:\n${report}`);
216
+ lines.push(`${name}: no stack; sudo -n sample did not answer, so the call this process waits in is not observed.`);
217
+ };
218
+ /** The runner's and its tree's leaf processes' stacks, taken at once. */
219
+ const stackSamples = async (tree) => {
220
+ const { sampled, omitted } = leafSamples(tree);
191
221
  if (omitted.length > 0)
192
222
  lines.push(`Stack samples bounded to the runner and ${MAX_SAMPLED_LEAVES} leaf processes; not sampled: pid ${omitted.join(', ')}`);
193
- const limitMs = endsAtMs - Date.now() - CENSUS_LIMIT_MS;
194
- const sampled = [request.pid, ...leaves.slice(0, MAX_SAMPLED_LEAVES).map((entry) => entry.pid)];
195
- await Promise.all(sampled.map(async (pid) => {
196
- const name = `stack sample pid ${pid}`;
197
- // `-file /dev/stdout` writes the report to the probe's pipe alone, not also to a root-owned file in /tmp.
198
- const args = ['-n', 'sample', String(pid), String(SAMPLE_SECONDS), '-file', '/dev/stdout'];
199
- const result = await probe(name, 'sudo', args, limitMs);
200
- if (finished)
201
- return;
202
- const report = callGraph(result.stdout);
203
- if (result.status === 'exited' && result.code === 0 && report !== '') {
204
- lines.push(`${name} (${SAMPLE_SECONDS}s; binary image list omitted):\n${report}`);
205
- return;
206
- }
207
- if (report !== '')
208
- lines.push(`Partial ${name} output:\n${report}`);
209
- lines.push(`${name}: no stack; sudo -n sample did not answer, so the call this process waits in is not observed.`);
210
- }));
223
+ await Promise.all(sampled.map(sampleStack));
211
224
  };
212
225
  /**
213
226
  * A process in an uninterruptible kernel wait (state U) is in a file-system or device call no signal ends, and its
@@ -217,7 +230,7 @@ export function captureHangDiagnostics(request, source = host) {
217
230
  */
218
231
  const kernelWaits = async (tree) => {
219
232
  const waiting = tree.filter((entry) => entry.stat.startsWith('U')).slice(0, MAX_SAMPLED_LEAVES);
220
- const limitMs = endsAtMs - Date.now() - CENSUS_LIMIT_MS;
233
+ const limitMs = endsAtMs - awakeNow() - CENSUS_LIMIT_MS;
221
234
  await Promise.all(waiting.map(async ({ pid }) => {
222
235
  const name = `fs_usage pid ${pid}`;
223
236
  const args = ['-n', 'fs_usage', '-w', '-t', String(FS_USAGE_SECONDS), '-f', 'filesys', String(pid)];
@@ -237,7 +250,7 @@ export function captureHangDiagnostics(request, source = host) {
237
250
  return;
238
251
  if (before === null)
239
252
  return finish('incomplete');
240
- const beforeAtMs = Date.now();
253
+ const beforeAtMs = awakeNow();
241
254
  let incomplete = false;
242
255
  let observed = before.length > 0;
243
256
  if (source.platform === 'darwin') {
@@ -283,6 +296,11 @@ export function captureHangDiagnostics(request, source = host) {
283
296
  }
284
297
  else {
285
298
  waits = lockWaits(rows, new Set(before.map((entry) => entry.pid)), openers);
299
+ // A lock wait is open-handle evidence: only the waiter's own stack says whether it blocks in the lock
300
+ // call. Each named waiter the leaf samples left out is sampled the same way, inside the same window.
301
+ const stacked = new Set(leafSamples(before).sampled);
302
+ const waiters = [...new Set(waits.flatMap((wait) => wait.waiters))].filter((pid) => !stacked.has(pid));
303
+ await Promise.all(waiters.slice(0, MAX_SAMPLED_LEAVES).map(sampleStack));
286
304
  }
287
305
  }
288
306
  };
@@ -294,7 +312,7 @@ export function captureHangDiagnostics(request, source = host) {
294
312
  lines.push(`Open-file census not provided on ${source.platform}; observations below name processes only.`);
295
313
  lines.push(`Stack samples not provided on ${source.platform}; no blocking call is observed.`);
296
314
  }
297
- const settleMs = Math.min(beforeAtMs + CPU_INTERVAL_MS, endsAtMs - CENSUS_LIMIT_MS) - Date.now();
315
+ const settleMs = Math.min(beforeAtMs + CPU_INTERVAL_MS, endsAtMs - CENSUS_LIMIT_MS) - awakeNow();
298
316
  if (settleMs > 0) {
299
317
  active.add('CPU interval');
300
318
  await source.sleep(settleMs, controller.signal);
@@ -307,7 +325,7 @@ export function captureHangDiagnostics(request, source = host) {
307
325
  return;
308
326
  if (after === null)
309
327
  return finish('incomplete');
310
- const afterAtMs = Date.now();
328
+ const afterAtMs = awakeNow();
311
329
  if (before.length !== after.length ||
312
330
  before.some((entry) => !after.some((other) => other.pid === entry.pid &&
313
331
  other.ppid === entry.ppid &&
@@ -366,7 +384,7 @@ export function stopProbe(file, pid) {
366
384
  return killProcessGroupNow(pid, TEARDOWN_PATIENCE);
367
385
  }
368
386
  /** A probe owns its group and output pipes; its deadline never waits for an unresponsive child to reap. */
369
- export function runProbe(file, args, timeoutMs, signal, environment) {
387
+ export function runProbe(file, args, timeoutMs, signal, environment, now = () => performance.now()) {
370
388
  // Keep the package's es2022-compatible event-completion convention.
371
389
  return new Promise((resolve) => {
372
390
  if (signal.aborted) {
@@ -382,7 +400,7 @@ export function runProbe(file, args, timeoutMs, signal, environment) {
382
400
  if (settled)
383
401
  return;
384
402
  settled = true;
385
- clearTimeout(timer);
403
+ cancelTimer();
386
404
  signal.removeEventListener('abort', aborted);
387
405
  child.stdout.destroy();
388
406
  child.stderr.destroy();
@@ -406,7 +424,7 @@ export function runProbe(file, args, timeoutMs, signal, environment) {
406
424
  finish({ status, detail: detail + killFailure, stdout, stderr });
407
425
  };
408
426
  const aborted = () => stop('capture deadline reached');
409
- const timer = setTimeout(() => stop(`probe exceeded ${timeoutMs}ms`), timeoutMs);
427
+ const cancelTimer = atClockDeadline(now() + timeoutMs, now, () => stop(`probe exceeded ${timeoutMs}ms`));
410
428
  signal.addEventListener('abort', aborted, { once: true });
411
429
  const append = (stream, chunk) => {
412
430
  bytes += Buffer.byteLength(chunk);
@@ -1,6 +1,7 @@
1
1
  import type { tags } from 'typia';
2
2
  /** Peer wait classes from specs/cowshed/05_gateway.md, "Deadlines". */
3
3
  export declare const CONTROL_MS = 5000;
4
+ export declare const REAP_MS = 5000;
4
5
  export declare const HEARTBEAT_MS = 5000;
5
6
  export declare const HEARTBEAT_SILENCE_MS = 15000;
6
7
  /** The CPU pool's actor-authored progress, shared by its server and lease client. */
@@ -1 +1 @@
1
- {"version":3,"file":"lease-wait.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/lease-wait.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAElC,uEAAuE;AACvE,eAAO,MAAM,UAAU,OAAQ,CAAC;AAChC,eAAO,MAAM,YAAY,OAAQ,CAAC;AAClC,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAE3C,qFAAqF;AACrF,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,IAAI,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,QAAQ,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;CACtC;AAMD,qFAAqF;AACrF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,QAAQ,EAAE,MAAM,CAAC;IACjB,6GAA6G;IAC7G,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,wGAAwG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AQ,CAAC,CAAC;CACtC;AAMD,qFAAqF;AACrF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,QAAQ,EAAE,MAAM,CAAC;IACjB,6GAA6G;IAC7G,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,wGAAwG;AACxG,MAAM,WAAW,UAAW,SAAQ,cAAc;IAChD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,6FAA6F;AAC7F,qBAAa,YAAY;IAMX,OAAO,CAAC,QAAQ,CAAC,GAAG;IALhC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,KAAK,CAAqC;IAClD,qEAAqE;IACrE,OAAO,CAAC,MAAM,CAAS;IAEvB,YAA6B,GAAG,GAAE,MAAM,MAAgC,EAGvE;IAED,2FAA2F;IAC3F,IAAI,IAAI,IAAI,CAKX;IAED;;;OAGG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAKlC;IAED,qGAAqG;IACrG,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAMnC;IAED;;;;;OAKG;IACH,IAAI,IAAI,IAAI,CAMX;IAED,qEAAqE;IACrE,WAAW,IAAI,MAAM,CAGpB;IAED,2FAA2F;IAC3F,OAAO,IAAI,cAAc,GAAG,IAAI,CAS/B;CACF"}
@@ -1,5 +1,6 @@
1
1
  /** Peer wait classes from specs/cowshed/05_gateway.md, "Deadlines". */
2
2
  export const CONTROL_MS = 5_000;
3
+ export const REAP_MS = 5_000;
3
4
  export const HEARTBEAT_MS = 5_000;
4
5
  export const HEARTBEAT_SILENCE_MS = 15_000;
5
6
  /** Pure CPU admission policy; its injected monotonic clock performs no I/O or scheduling. */
@@ -24,6 +24,12 @@ export interface MbxPool {
24
24
  * belongs to.
25
25
  */
26
26
  export declare function mbxPool(environment: Readonly<NodeJS.ProcessEnv>): MbxPool | null;
27
+ /**
28
+ * Whether the environment names mbx's pool from inside a hold on it: what a held cowshed job, `mbx reserve`'s command
29
+ * and a reserved leaf's shell see (`MBX_SCHED_DISABLE=1` beside the canonical environment). mbx's test shim still
30
+ * starts every nextest case there, so a run under it may gate its cases (mbx-reservations.ts, `learnHeldGate`).
31
+ */
32
+ export declare function mbxHold(environment: Readonly<NodeJS.ProcessEnv>): boolean;
27
33
  /**
28
34
  * How a leaf enters the pool once. A Cargo leaf that builds runs through mbx, which admits its compilers and supported
29
35
  * test work itself, so wrapping it would charge it twice. Any other leaf reserves for its whole run, asking its Nx
@@ -42,6 +48,11 @@ export type MbxLeaf = {
42
48
  readonly kind: 'reserve';
43
49
  readonly priority: MbxPriority;
44
50
  readonly demand: ReservedDemand;
51
+ /**
52
+ * Whether its runner starts every thread of its ask and each case takes a core at the leaf's gate (case-gate.ts):
53
+ * a nextest leaf of a run whose mbx gates its cases. Otherwise its runner is sized to its grant.
54
+ */
55
+ readonly gated: boolean;
45
56
  };
46
57
  /** A leaf mbx's pool reserves for. */
47
58
  export type ReservedLeaf = Extract<MbxLeaf, {
@@ -56,12 +67,12 @@ export declare function runsPrebuiltNextest(command: string): boolean;
56
67
  * kept every reservation queued behind it waiting while the pool drained. On 2026-10-31 a downstream gate ran 4.9 of 18
57
68
  * cores busy while 25 of its tasks queued a minute or more, and a gate's Go test leaf waited 401 s for all 18 cores.
58
69
  */
59
- export declare function mbxLeaf(pool: MbxPool, demand: Demand, command: string): MbxLeaf | null;
70
+ export declare function mbxLeaf(pool: MbxPool, demand: Demand, command: string, testGate: boolean): MbxLeaf | null;
60
71
  /**
61
72
  * Whether a run of `command` under mbx's pool is a Cargo leaf: the one leaf whose admission wait the run reads from
62
73
  * mbx's activity report and its waiters' native lineage (mbx-queue.ts; specs/cowshed/11_shell.md, "Cargo test-runner
63
- * boundaries"), so the only run that loads cowshed's process-lineage entry and its addon. The command alone decides
64
- * it: the pool's priority, the core count and the environment size a leaf, never its kind.
74
+ * boundaries"), through cowshed's process-lineage entry. The command alone decides it: the pool's priority, the core
75
+ * count and the environment size a leaf, never its kind.
65
76
  */
66
77
  export declare function runsAsCargoLeaf(command: string): boolean;
67
78
  /**
@@ -78,14 +89,24 @@ export declare function mbxIdleGated(leaf: MbxLeaf | null, command: string, envi
78
89
  export declare const MBX_GRANT_FD = 5;
79
90
  /**
80
91
  * `command` as the shell runs it under its leaf's admission, or as it is for a leaf in no pool (`null`): a reserved
81
- * leaf asks for its runner's count (`reservation`).
92
+ * leaf asks for its runner's count (`reservation`). A reserved leaf's fixture is never part of `command`
93
+ * (`withReservationAfterFixture`).
82
94
  */
83
95
  export declare function withMbxLeaf(command: string, leaf: MbxLeaf | null): string;
96
+ /**
97
+ * A reserved leaf with a `fixture`: the fixture runs first, outside the reservation, as pooled work like any other
98
+ * build, and the leaf asks for its runner's count only once it has exited 0 (specs/cowshed/05_gateway.md, "A leaf's
99
+ * build precedes its reservation"). A reservation holds cores only while its command can use them: a fixture inside
100
+ * one waits on Cargo's build-directory lock holding its grant, and when reserved leaves hold every core the lock's
101
+ * holder, a pooled build whose compiler waits for one, never gets it. A fixture that fails fails the run before
102
+ * anything is reserved.
103
+ */
104
+ export declare function withReservationAfterFixture(fixture: string, command: string, leaf: ReservedLeaf): string;
84
105
  /**
85
106
  * A reserved leaf whose `fixture` segment ends by printing one line per unit its `command` runs (`unitsCommand`): the
86
- * segment runs first, outside the reservation, since a build's compilers are admitted by mbx one by one, and the leaf
87
- * asks for its units, at most its runner's count and at least one. A segment that fails fails the run before anything
88
- * is reserved.
107
+ * segment runs first, outside the reservation as every fixture does (`withReservationAfterFixture`), and the leaf asks
108
+ * for its units, at most its runner's count and at least one. A segment that fails fails the run before anything is
109
+ * reserved.
89
110
  */
90
111
  export declare function withCountedReservation(fixture: string, command: string, leaf: ReservedLeaf): string;
91
112
  /**
@@ -1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