@overkill-dev/run 0.0.74 → 0.0.76

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 (239) hide show
  1. package/assertion-protocol/source-location.js +10 -0
  2. package/assertion-protocol/source-location.js.map +1 -1
  3. package/attachments/run-json-artifact.js +24 -0
  4. package/attachments/run-json-artifact.js.map +1 -0
  5. package/baselines/performance-adapter.d.ts +33 -1
  6. package/baselines/performance-adapter.d.ts.map +1 -1
  7. package/baselines/performance-check.js +18 -0
  8. package/baselines/performance-check.js.map +1 -0
  9. package/baselines/performance-evaluation.js +29 -31
  10. package/baselines/performance-evaluation.js.map +1 -1
  11. package/baselines/performance-presentation.js +76 -0
  12. package/baselines/performance-presentation.js.map +1 -0
  13. package/baselines/performance-report.js +16 -22
  14. package/baselines/performance-report.js.map +1 -1
  15. package/baselines/performance-workflow.js +38 -2
  16. package/baselines/performance-workflow.js.map +1 -1
  17. package/bench/benchmark-run-report.js +17 -0
  18. package/bench/benchmark-run-report.js.map +1 -0
  19. package/config/config.d.ts +4 -2
  20. package/config/config.d.ts.map +1 -1
  21. package/config/config.js +21 -0
  22. package/config/config.js.map +1 -1
  23. package/config/property-policy.js +54 -0
  24. package/config/property-policy.js.map +1 -0
  25. package/config/schema.d.ts +132 -0
  26. package/config/schema.d.ts.map +1 -1
  27. package/config/schema.js +17 -1
  28. package/config/schema.js.map +1 -1
  29. package/config/snapshot.js +12 -0
  30. package/config/snapshot.js.map +1 -1
  31. package/config/types.d.ts +12 -1
  32. package/config/types.d.ts.map +1 -1
  33. package/config/validation.js +25 -3
  34. package/config/validation.js.map +1 -1
  35. package/engine/case-body-execution.js +6 -2
  36. package/engine/case-body-execution.js.map +1 -1
  37. package/engine/case-execution-lifecycle.js +22 -0
  38. package/engine/case-execution-lifecycle.js.map +1 -0
  39. package/engine/engine.d.ts +2 -1
  40. package/engine/engine.d.ts.map +1 -1
  41. package/engine/engine.js +1 -0
  42. package/engine/engine.js.map +1 -1
  43. package/engine/execution-options.d.ts +1 -1
  44. package/engine/execution-options.d.ts.map +1 -1
  45. package/engine/execution-options.js +4 -0
  46. package/engine/execution-options.js.map +1 -1
  47. package/engine/execution-supervision-state.js +2 -0
  48. package/engine/execution-supervision-state.js.map +1 -1
  49. package/engine/execution-test-plan-cases.js +24 -1
  50. package/engine/execution-test-plan-cases.js.map +1 -1
  51. package/engine/identity.d.ts +1 -0
  52. package/engine/identity.d.ts.map +1 -1
  53. package/engine/property-node.d.ts +30 -0
  54. package/engine/property-node.d.ts.map +1 -0
  55. package/engine/property-node.js +9 -0
  56. package/engine/property-node.js.map +1 -0
  57. package/engine/reporter.d.ts.map +1 -1
  58. package/engine/reporter.js +17 -2
  59. package/engine/reporter.js.map +1 -1
  60. package/engine/test-body.d.ts +16 -0
  61. package/engine/test-body.d.ts.map +1 -0
  62. package/engine/test-body.js +23 -0
  63. package/engine/test-body.js.map +1 -1
  64. package/engine/test-node.d.ts +11 -5
  65. package/engine/test-node.d.ts.map +1 -1
  66. package/engine/test-node.js +23 -31
  67. package/engine/test-node.js.map +1 -1
  68. package/engine/test-plan.js +3 -3
  69. package/engine/test-plan.js.map +1 -1
  70. package/package.json +11 -1
  71. package/packages/run/command-line.entry-point.d.ts +1 -1
  72. package/packages/run/command-line.entry-point.d.ts.map +1 -1
  73. package/packages/run/config.entry-point.d.ts +2 -2
  74. package/packages/run/config.entry-point.d.ts.map +1 -1
  75. package/packages/run/run.entry-point.d.ts +11 -3
  76. package/packages/run/run.entry-point.d.ts.map +1 -1
  77. package/packages/run/run.entry-point.js +3 -0
  78. package/packages/run/run.entry-point.js.map +1 -1
  79. package/readme.md +16 -0
  80. package/run/attachment-coordinator-context.js +6 -0
  81. package/run/attachment-coordinator-context.js.map +1 -1
  82. package/run/attachment-eligibility.js +2 -1
  83. package/run/attachment-eligibility.js.map +1 -1
  84. package/run/benchmark-baseline-finalization.js +32 -6
  85. package/run/benchmark-baseline-finalization.js.map +1 -1
  86. package/run/benchmark-command-policy.d.ts +1 -1
  87. package/run/benchmark-command-policy.d.ts.map +1 -1
  88. package/run/benchmark-report-metadata.js +69 -0
  89. package/run/benchmark-report-metadata.js.map +1 -0
  90. package/run/child-process.entry-point.js +3 -1
  91. package/run/child-process.entry-point.js.map +1 -1
  92. package/run/collected-run-plan-schema.js +13 -0
  93. package/run/collected-run-plan-schema.js.map +1 -1
  94. package/run/collected-run-plan.js +5 -14
  95. package/run/collected-run-plan.js.map +1 -1
  96. package/run/command-line-config.js +1 -1
  97. package/run/command-line-config.js.map +1 -1
  98. package/run/command-line-execution.js.map +1 -1
  99. package/run/{current-process-run-orchestrator.d.ts → current-process-run-input.d.ts} +2 -2
  100. package/run/current-process-run-input.d.ts.map +1 -0
  101. package/run/current-process-run-input.js +42 -0
  102. package/run/current-process-run-input.js.map +1 -0
  103. package/run/current-process-run-orchestrator.js +3 -64
  104. package/run/current-process-run-orchestrator.js.map +1 -1
  105. package/run/default-run-engine.js +1 -0
  106. package/run/default-run-engine.js.map +1 -1
  107. package/run/duration-history-schema.js +1 -1
  108. package/run/duration-history-schema.js.map +1 -1
  109. package/run/duration-history.d.ts.map +1 -1
  110. package/run/duration-history.js +4 -0
  111. package/run/duration-history.js.map +1 -1
  112. package/run/execution-failure-schema.d.ts +4 -0
  113. package/run/execution-failure-schema.d.ts.map +1 -0
  114. package/run/execution-failure-schema.js +24 -0
  115. package/run/execution-failure-schema.js.map +1 -0
  116. package/run/execution-failure.d.ts +4 -0
  117. package/run/execution-failure.d.ts.map +1 -0
  118. package/run/execution-failure.js +66 -0
  119. package/run/execution-failure.js.map +1 -0
  120. package/run/execution-session-child.js +28 -0
  121. package/run/execution-session-child.js.map +1 -0
  122. package/run/execution-session-collected.js +41 -0
  123. package/run/execution-session-collected.js.map +1 -0
  124. package/run/execution-session-context.js +9 -0
  125. package/run/execution-session-context.js.map +1 -0
  126. package/run/execution-session-environment.js +23 -0
  127. package/run/execution-session-environment.js.map +1 -0
  128. package/run/execution-session-host.js +60 -0
  129. package/run/execution-session-host.js.map +1 -0
  130. package/run/execution-session-lifecycle.js +88 -0
  131. package/run/execution-session-lifecycle.js.map +1 -0
  132. package/run/execution-session-process.entry-point.js +15 -0
  133. package/run/execution-session-process.entry-point.js.map +1 -0
  134. package/run/execution-session-process.js +56 -0
  135. package/run/execution-session-process.js.map +1 -0
  136. package/run/execution-session-schema.js +48 -0
  137. package/run/execution-session-schema.js.map +1 -0
  138. package/run/execution-session-supervised.js +82 -0
  139. package/run/execution-session-supervised.js.map +1 -0
  140. package/run/execution-session-types.d.ts +46 -0
  141. package/run/execution-session-types.d.ts.map +1 -0
  142. package/run/execution-session.js +97 -0
  143. package/run/execution-session.js.map +1 -0
  144. package/run/frozen-supervised-command-schema.js +18 -1
  145. package/run/frozen-supervised-command-schema.js.map +1 -1
  146. package/run/node-command-line-runner.d.ts +1 -1
  147. package/run/node-command-line-runner.d.ts.map +1 -1
  148. package/run/node-command-line-runner.js.map +1 -1
  149. package/run/{run-orchestrator.d.ts → node-run-orchestrator-dependencies.d.ts} +1 -1
  150. package/run/node-run-orchestrator-dependencies.d.ts.map +1 -0
  151. package/run/node-run-orchestrator-dependencies.js +43 -0
  152. package/run/node-run-orchestrator-dependencies.js.map +1 -0
  153. package/run/property-collection.js +113 -0
  154. package/run/property-collection.js.map +1 -0
  155. package/run/run-cancellation.js.map +1 -1
  156. package/run/run-case-facts.js +28 -0
  157. package/run/run-case-facts.js.map +1 -0
  158. package/run/run-collected-resolution.js +5 -1
  159. package/run/run-collected-resolution.js.map +1 -1
  160. package/run/run-collection-error-result.js +2 -2
  161. package/run/run-collection-error-result.js.map +1 -1
  162. package/run/run-command-schema.js +3 -1
  163. package/run/run-command-schema.js.map +1 -1
  164. package/run/run-empty-shard.js.map +1 -1
  165. package/run/run-engine-primitives.d.ts +10 -1
  166. package/run/run-engine-primitives.d.ts.map +1 -1
  167. package/run/run-engine-selection.js +1 -0
  168. package/run/run-engine-selection.js.map +1 -1
  169. package/run/run-execution.js.map +1 -1
  170. package/run/run-facts.js +8 -13
  171. package/run/run-facts.js.map +1 -1
  172. package/run/run-in-process-execution.js.map +1 -1
  173. package/run/run-input-resolution.js +9 -8
  174. package/run/run-input-resolution.js.map +1 -1
  175. package/run/run-isolated-command.js +13 -4
  176. package/run/run-isolated-command.js.map +1 -1
  177. package/run/run-isolated-process.js.map +1 -1
  178. package/run/run-local-execution.js.map +1 -1
  179. package/run/run-local-planning.js +2 -1
  180. package/run/run-local-planning.js.map +1 -1
  181. package/run/run-local-resolution.js.map +1 -1
  182. package/run/run-local-test-plan.js +10 -2
  183. package/run/run-local-test-plan.js.map +1 -1
  184. package/run/run-operations.d.ts +2 -2
  185. package/run/run-operations.d.ts.map +1 -1
  186. package/run/run-operations.js.map +1 -1
  187. package/run/run-orchestrator-types.d.ts +9 -0
  188. package/run/run-orchestrator-types.d.ts.map +1 -0
  189. package/run/run-orchestrator.entry-point.d.ts +1 -1
  190. package/run/run-orchestrator.entry-point.d.ts.map +1 -1
  191. package/run/run-orchestrator.js +2 -41
  192. package/run/run-orchestrator.js.map +1 -1
  193. package/run/run-request-types.d.ts +9 -1
  194. package/run/run-request-types.d.ts.map +1 -1
  195. package/run/run-selection-filters.d.ts.map +1 -1
  196. package/run/run-selection-filters.js +11 -1
  197. package/run/run-selection-filters.js.map +1 -1
  198. package/run/run-selection-schema.d.ts.map +1 -1
  199. package/run/run-selection-schema.js +2 -1
  200. package/run/run-selection-schema.js.map +1 -1
  201. package/run/run-selection.js +8 -2
  202. package/run/run-selection.js.map +1 -1
  203. package/run/run-supervised-process.js.map +1 -1
  204. package/run/run-support.js +13 -2
  205. package/run/run-support.js.map +1 -1
  206. package/run/run-test-plan.js +12 -0
  207. package/run/run-test-plan.js.map +1 -1
  208. package/run/run-types.d.ts +27 -10
  209. package/run/run-types.d.ts.map +1 -1
  210. package/run/run-types.js.map +1 -1
  211. package/run/run-validation.js +12 -0
  212. package/run/run-validation.js.map +1 -1
  213. package/run/run.js +4 -0
  214. package/run/run.js.map +1 -1
  215. package/run/runtime-attachment-boundary.js +2 -1
  216. package/run/runtime-attachment-boundary.js.map +1 -1
  217. package/run/supervised-child-execution.js +14 -0
  218. package/run/supervised-child-execution.js.map +1 -1
  219. package/run/supervised-child-process.js +7 -3
  220. package/run/supervised-child-process.js.map +1 -1
  221. package/run/supervised-child-test-plan.js +6 -5
  222. package/run/supervised-child-test-plan.js.map +1 -1
  223. package/run/supervised-child.js +24 -10
  224. package/run/supervised-child.js.map +1 -1
  225. package/run/supervised-protocol-schema.js +6 -3
  226. package/run/supervised-protocol-schema.js.map +1 -1
  227. package/run/supervised-protocol.js +3 -17
  228. package/run/supervised-protocol.js.map +1 -1
  229. package/run/supervised-run-runtime.js +3 -0
  230. package/run/supervised-run-runtime.js.map +1 -1
  231. package/run/supervised-run.js +10 -5
  232. package/run/supervised-run.js.map +1 -1
  233. package/run/worker-pool-host-protocol-schema.js +1 -1
  234. package/run/worker-pool-host-protocol-schema.js.map +1 -1
  235. package/run/workload-input-validation.js +5 -0
  236. package/run/workload-input-validation.js.map +1 -1
  237. package/{sbom.cdx.json → software-bill-of-materials.cyclonedx.json} +5 -5
  238. package/run/current-process-run-orchestrator.d.ts.map +0 -1
  239. package/run/run-orchestrator.d.ts.map +0 -1
@@ -0,0 +1,41 @@
1
+ import { createStoredValue } from "../stored-value.js";
2
+ import { initializeRun } from "./initialized-run.js";
3
+ import { withExecutionLifecycle } from "./execution-session-lifecycle.js";
4
+ import { runExecutionFailure } from "./execution-failure.js";
5
+ async function collectExecutionSession(options, dependencies) {
6
+ const initialized = await initializeRun(options.command, dependencies);
7
+ return await initialized.collect();
8
+ }
9
+ async function executeCollectedInvocation(execution, lifecycle) {
10
+ const collecting = execution.collection.read() ??
11
+ collectExecutionSession(execution.options, execution.dependencies);
12
+ execution.collection.write(collecting);
13
+ const collected = await collecting;
14
+ const selection = await lifecycle.select(collected.plan);
15
+ await lifecycle.beforeCases();
16
+ const result = await collected.run({ selection });
17
+ return { kind: 'result', result, data: lifecycle.snapshot(), deadlineExceeded: false };
18
+ }
19
+ export function createCollectedExecutionSession(options, dependencies) {
20
+ const collection = createStoredValue(null);
21
+ return {
22
+ lifetime: 'reused',
23
+ async execute(call) {
24
+ const reply = createStoredValue(null);
25
+ try {
26
+ return await withExecutionLifecycle(call.transport, options.command.policy.moduleBoundary, async function (lifecycle) {
27
+ try {
28
+ return await executeCollectedInvocation({ options, dependencies, collection }, lifecycle);
29
+ }
30
+ finally {
31
+ reply.write(lifecycle.snapshot());
32
+ }
33
+ });
34
+ }
35
+ catch (error) {
36
+ return { kind: 'failure', failure: runExecutionFailure(error), data: reply.read() };
37
+ }
38
+ }
39
+ };
40
+ }
41
+ //# sourceMappingURL=execution-session-collected.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-session-collected.js","sourceRoot":"","sources":["../../../../source/run/execution-session-collected.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAoB,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAM7D,KAAK,UAAU,uBAAuB,CAClC,OAAmC,EACnC,YAAyC;IAEzC,MAAM,WAAW,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACvE,OAAO,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;AACvC,CAAC;AAQD,KAAK,UAAU,0BAA0B,CACrC,SAA6B,EAC7B,SAAgC;IAEhC,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE;QAC1C,uBAAuB,CAAC,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;IACvE,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACvC,MAAM,S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N,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ const execution = new AsyncLocalStorage();
3
+ export const currentExecutionSession = function () {
4
+ return execution.getStore() ?? null;
5
+ };
6
+ export async function withExecutionSession(transport, run) {
7
+ return await execution.run(transport, run);
8
+ }
9
+ //# sourceMappingURL=execution-session-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-session-context.js","sourceRoot":"","sources":["../../../../source/run/execution-session-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AASrD,MAAM,SAAS,GAAG,IAAI,iBAAiB,EAAyB,CAAC;AACjE,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACnC,OAAO,SAAS,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC;AACxC,CAAC,CAAC;AACF,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACtC,SAAgC,EAChC,GAAyB;IAEzB,OAAO,MAAM,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { runFreshExecutionSession } from "./execution-session-process.js";
2
+ import { runSupervisedExecutionSession } from "./execution-session-supervised.js";
3
+ import { createCollectedExecutionSession } from "./execution-session-collected.js";
4
+ export function createExecutionSessionEnvironment(options, dependencies) {
5
+ if (options.command.policy.profile.execution.processModel === 'supervised-process') {
6
+ return {
7
+ lifetime: 'fresh',
8
+ async execute(call) {
9
+ return await runSupervisedExecutionSession(options, dependencies, call);
10
+ }
11
+ };
12
+ }
13
+ if (options.environment === 'fresh-invocation') {
14
+ return {
15
+ lifetime: 'fresh',
16
+ async execute(call) {
17
+ return await runFreshExecutionSession(options.command, call.transport, call.timeoutMilliseconds, call.signal);
18
+ }
19
+ };
20
+ }
21
+ return createCollectedExecutionSession(options, dependencies);
22
+ }
23
+ //# sourceMappingURL=execution-session-environment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-session-environment.js","sourceRoot":"","sources":["../../../../source/run/execution-session-environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,+BAA+B,EAAE,MAAM,kCAAkC,CAAC;AAKnF,MAAM,UAAU,iCAAiC,CAC7C,OAAmC,EACnC,YAAyC;IAEzC,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,YAAY,KAAK,oBAAoB,EAAE,CAAC;QACjF,OAAO;YACH,QAAQ,EAAE,OAAO;YACjB,KAAK,CAAC,OAAO,CAAC,IAAI;gBACd,OAAO,MAAM,6BAA6B,CAAC,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;YAC5E,CAAC;SACJ,CAAC;IACN,CAAC;IACD,IAAI,OAAO,CAAC,WAAW,KAAK,kBAAkB,EAAE,CAAC;QAC7C,OAAO;YACH,QAAQ,EAAE,OAAO;YACjB,KAAK,CAAC,OAAO,CAAC,IAAI;gBACd,OAAO,MAAM,wBAAwB,CACjC,OAAO,CAAC,OAAO,EACf,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,mBAAmB,EACxB,IAAI,CAAC,MAAM,CACd,CAAC;YACN,CAAC;SACJ,CAAC;IACN,CAAC;IACD,OAAO,+BAA+B,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AAClE,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { createPlainOutputRenderer } from "../engine/reporter-output.js";
2
+ import { createNodeRunOrchestratorDependencies } from "./node-run-orchestrator-dependencies.js";
3
+ import { createCurrentProcessRunInput } from "./current-process-run-input.js";
4
+ import { defaultRunEngine } from "./default-run-engine.js";
5
+ import { loadRunEngineModule, loadRunTestModules, runDiscovery } from "./node-run-dependencies.entry-point.js";
6
+ import { createCollectedExecutionSession } from "./execution-session-collected.js";
7
+ import { executionHostRequestSchema, executionReplySchema } from "./execution-session-schema.js";
8
+ import { parseFrozenMicrotestPolicy } from "./frozen-run-policy.js";
9
+ function unsupportedIsolatedDispatch() {
10
+ throw new Error('Fresh invocation hosts require an in-process profile.');
11
+ }
12
+ const dependencies = createNodeRunOrchestratorDependencies(createCurrentProcessRunInput(defaultRunEngine, {
13
+ discoverRunFilesWithProjectRoot: runDiscovery.discoverRunFilesWithProjectRoot,
14
+ loadRunEngineModule,
15
+ loadRunTestModules,
16
+ startSupervisedChild: unsupportedIsolatedDispatch,
17
+ startWorkerPoolHost: unsupportedIsolatedDispatch
18
+ }));
19
+ const input = await new Promise(function (resolve, reject) {
20
+ process.once('message', function (message) {
21
+ try {
22
+ resolve(executionHostRequestSchema.parse(message));
23
+ }
24
+ catch (error) {
25
+ reject(error instanceof Error ? error : new Error('Invalid execution host request.', { cause: error }));
26
+ }
27
+ });
28
+ });
29
+ const environment = createCollectedExecutionSession({
30
+ command: {
31
+ kind: 'frozen-policy',
32
+ policy: parseFrozenMicrotestPolicy(input.policy),
33
+ invocation: { seed: input.seed, selection: input.selection },
34
+ reporting: { outputRenderer: createPlainOutputRenderer(), reporters: [] }
35
+ },
36
+ environment: 'profile-default',
37
+ lifecycle: input.transport.lifecycle
38
+ }, dependencies);
39
+ const cancellation = new AbortController();
40
+ const reply = executionReplySchema.parse(await environment.execute({
41
+ transport: input.transport,
42
+ timeoutMilliseconds: input.timeoutMilliseconds,
43
+ signal: cancellation.signal
44
+ }));
45
+ await new Promise(function (resolve, reject) {
46
+ if (process.send === undefined) {
47
+ reject(new Error('Execution host requires IPC.'));
48
+ return;
49
+ }
50
+ process.send(reply, function (error) {
51
+ if (error === null) {
52
+ resolve();
53
+ }
54
+ else {
55
+ reject(error);
56
+ }
57
+ });
58
+ });
59
+ process.disconnect?.();
60
+ //# sourceMappingURL=execution-session-host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-session-host.js","sourceRoot":"","sources":["../../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 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
9
+ import { z } from 'zod/v4';
10
+ import { withCaseExecutionLifecycle } from "../engine/case-execution-lifecycle.js";
11
+ import { withExecutionSession } from "./execution-session-context.js";
12
+ import { withFileModuleBoundary } from "./file-module-boundary.js";
13
+ import { parseRunSelection } from "./run-selection-schema.js";
14
+ function isLifecycleFactory(value) {
15
+ return typeof value === 'function';
16
+ }
17
+ function isExecutionLifecycle(value) {
18
+ return typeof value === 'object' && value !== null &&
19
+ ['select', 'beforeCases', 'enterCase', 'completeCase', 'snapshot', 'dispose'].every(function (method) {
20
+ return typeof Reflect.get(value, method) === 'function';
21
+ });
22
+ }
23
+ function validatedLifecycle(lifecycle) {
24
+ return {
25
+ async select(plan) {
26
+ return parseRunSelection(await lifecycle.select(plan));
27
+ },
28
+ async beforeCases() {
29
+ await lifecycle.beforeCases();
30
+ },
31
+ async enterCase(work) {
32
+ await lifecycle.enterCase(work);
33
+ },
34
+ async completeCase(result, errors) {
35
+ return z.enum(['continue', 'stop']).parse(await lifecycle.completeCase(result, errors));
36
+ },
37
+ snapshot() {
38
+ return z.json().parse(lifecycle.snapshot());
39
+ },
40
+ async dispose() {
41
+ await lifecycle.dispose();
42
+ }
43
+ };
44
+ }
45
+ async function loadExecutionLifecycle(transport) {
46
+ const module = await import(__rewriteRelativeImportExtension(transport.lifecycle.moduleUrl));
47
+ const factory = typeof module === 'object' && module !== null
48
+ ? Reflect.get(module, transport.lifecycle.exportName)
49
+ : null;
50
+ if (!isLifecycleFactory(factory)) {
51
+ throw new TypeError('Execution lifecycle export must be a factory.');
52
+ }
53
+ const created = await factory(structuredClone(transport.data));
54
+ if (!isExecutionLifecycle(created)) {
55
+ throw new TypeError('Execution lifecycle factory returned an invalid lifecycle.');
56
+ }
57
+ return validatedLifecycle(created);
58
+ }
59
+ async function runOwnedLifecycle(lifecycle, run) {
60
+ const [execution] = await Promise.allSettled([withCaseExecutionLifecycle({
61
+ async enter(testCase) {
62
+ await lifecycle.enterCase(testCase.workId);
63
+ },
64
+ complete: lifecycle.completeCase
65
+ }, async function () {
66
+ return await run(lifecycle);
67
+ })]);
68
+ const [disposal] = await Promise.allSettled([lifecycle.dispose()]);
69
+ if (execution.status === 'rejected' && disposal.status === 'rejected') {
70
+ throw new AggregateError([execution.reason, disposal.reason], 'Execution and lifecycle disposal failed.', { cause: execution.reason });
71
+ }
72
+ if (disposal.status === 'rejected') {
73
+ throw disposal.reason;
74
+ }
75
+ if (execution.status === 'rejected') {
76
+ throw execution.reason;
77
+ }
78
+ return execution.value;
79
+ }
80
+ export async function withExecutionLifecycle(transport, boundary, run) {
81
+ return await withExecutionSession(transport, async function () {
82
+ return await withFileModuleBoundary(boundary, async function () {
83
+ const lifecycle = await loadExecutionLifecycle(transport);
84
+ return await runOwnedLifecycle(lifecycle, run);
85
+ });
86
+ });
87
+ }
88
+ //# sourceMappingURL=execution-session-lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-session-lifecycle.js","sourceRoot":"","sources":["../../../../source/run/execution-session-lifecycle.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AAEnF,OAAO,EAAE,oBAAoB,EAA8B,MAAM,gCAAgC,CAAC;AAClG,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,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C,MAAM,KAAK,UAAU,EAAE,CAAC;QACpE,MAAM,IAAI,cAAc,CACpB,CAAE,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAE,EACrC,0CAA0C,EAC1C,EAAE,KAAK,EAAE,SAAS,CAAC,MAAM,EAAE,CAC9B,CAAC;IACN,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QACjC,MAAM,QAAQ,CAAC,MAAM,CAAC;IAC1B,CAAC;IACD,IAAI,SAAS,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QAClC,MAAM,SAAS,CAAC,MAAM,CAAC;IAC3B,CAAC;IACD,OAAO,SAAS,CAAC,KAAK,CAAC;AAC3B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CACxC,SAAgC,EAChC,QAAmC,EACnC,GAAyD;IAEzD,OAAO,MAAM,oBAAoB,CAAC,SAAS,EAAE,KAAK;QAC9C,OAAO,MAAM,sBAAsB,CAAC,QAAQ,EAAE,KAAK;YAC/C,MAAM,SAAS,GAAG,MAAM,sBAAsB,CAAC,SAAS,CAAC,CAAC;YAC1D,OAAO,MAAM,iBAAiB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { fileURLToPath } from 'node:url';
2
+ import { readProcessEnvironment } from "./node-host-readers.js";
3
+ export const executionSessionProcessUrl = import.meta.url;
4
+ export const executionSessionProcessArgument = '--overkill-execution-session';
5
+ export function readExecutionSessionEnvironment() {
6
+ return readProcessEnvironment(process);
7
+ }
8
+ async function startExecutionSessionHost() {
9
+ await import("./execution-session-host.js");
10
+ }
11
+ if (process.argv[1] === fileURLToPath(executionSessionProcessUrl) &&
12
+ process.argv.includes(executionSessionProcessArgument)) {
13
+ await startExecutionSessionHost();
14
+ }
15
+ //# sourceMappingURL=execution-session-process.entry-point.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-session-process.entry-point.js","sourceRoot":"","sources":["../../../../source/run/execution-session-process.entry-point.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AAC1D,MAAM,CAAC,MAAM,+BAA+B,GAAG,8BAA8B,CAAC;AAC9E,MAAM,UAAU,+BAA+B;IAC3C,OAAO,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAC3C,CAAC;AAED,KAAK,UAAU,yBAAyB;IACpC,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;AAChD,CAAC;AAED,IACI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,0BAA0B,CAAC;IAC7D,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,+BAA+B,CAAC,EACxD,CAAC;IACC,MAAM,yBAAyB,EAAE,CAAC;AACtC,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { fork } from 'node:child_process';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { sanitizedChildEnvironment } from "./supervised-child-process.js";
4
+ import { executionReplySchema } from "./execution-session-schema.js";
5
+ import { executionSessionProcessArgument, executionSessionProcessUrl, readExecutionSessionEnvironment } from "./execution-session-process.entry-point.js";
6
+ export async function runFreshExecutionSession(command, transport, timeoutMilliseconds, signal) {
7
+ signal.throwIfAborted();
8
+ const child = fork(fileURLToPath(executionSessionProcessUrl), [executionSessionProcessArgument], {
9
+ cwd: command.policy.cwd,
10
+ env: sanitizedChildEnvironment(readExecutionSessionEnvironment(), 'microtest'),
11
+ execArgv: [],
12
+ serialization: 'advanced',
13
+ killSignal: 'SIGKILL',
14
+ signal,
15
+ stdio: ['ignore', 'pipe', 'pipe', 'ipc']
16
+ });
17
+ child.stdout?.resume();
18
+ child.stderr?.resume();
19
+ const closed = new Promise(function (resolve) {
20
+ child.once('close', resolve);
21
+ });
22
+ try {
23
+ return await new Promise(function (resolve, reject) {
24
+ child.once('error', reject);
25
+ child.once('exit', function (code, termination) {
26
+ reject(new Error(`Execution host exited without a result (${String(code)}, ${String(termination)}).`));
27
+ });
28
+ child.once('message', function (message) {
29
+ try {
30
+ resolve(executionReplySchema.parse(message));
31
+ }
32
+ catch (error) {
33
+ reject(error instanceof Error
34
+ ? error
35
+ : new Error('Execution host returned an invalid reply.', { cause: error }));
36
+ }
37
+ });
38
+ child.send({
39
+ policy: command.policy,
40
+ seed: command.invocation.seed,
41
+ selection: command.invocation.selection,
42
+ transport,
43
+ timeoutMilliseconds
44
+ }, function (error) {
45
+ if (error !== null) {
46
+ reject(error);
47
+ }
48
+ });
49
+ });
50
+ }
51
+ finally {
52
+ child.kill('SIGKILL');
53
+ await closed;
54
+ }
55
+ }
56
+ //# sourceMappingURL=execution-session-process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-session-process.js","sourceRoot":"","sources":["../../../../source/run/execution-session-process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EACH,+BAA+B,EAC/B,0BAA0B,EAC1B,+BAA+B,EAClC,MAAM,4CAA4C,CAAC;AAKpD,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC1C,OAAyB,EACzB,SAAgC,EAChC,mBAA2B,EAC3B,MAAmB;IAEnB,MAAM,CAAC,cAAc,EAAE,CAAC;IACxB,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,0BAA0B,CAAC,EAAE,CAAE,+BAA+B,CAAE,EAAE;QAC/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CAAC,CAAC,CAAC;YACH,KAAK,CAAC,IAAI,CACN;gBACI,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,IAAI;gBAC7B,SAAS,EAAE,OAAO,CAAC,UAAU,CAAC,SAAS;gBACvC,SAAS;gBACT,mBAAmB;aACtB,EACD,UAAU,KAAK;gBACX,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;oBACjB,MAAM,CAAC,KAAK,CAAC,CAAC;gBAClB,CAAC;YACL,CAAC,CACJ,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;YAAS,CAAC;QACP,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtB,MAAM,MAAM,CAAC;IACjB,CAAC;AACL,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { z } from 'zod/v4';
2
+ import { createPlainOutputRenderer } from "../engine/reporter-output.js";
3
+ import { frozenMicrotestPolicySchema } from "./frozen-run-policy-schema.js";
4
+ import { runResultSchema } from "./run-result-schema.js";
5
+ import { runExecutionFailureSchema } from "./execution-failure-schema.js";
6
+ import { runSelectionSchema } from "./run-selection-schema.js";
7
+ import { parseFrozenMicrotestPolicy } from "./frozen-run-policy.js";
8
+ import { RunResolutionError } from "./run-errors.js";
9
+ export function normalizeExecutionSessionOptions(supplied, createSeed) {
10
+ if (supplied.command.policy.request.coverage || supplied.command.policy.request.baselineUpdateMode !== 'none') {
11
+ throw new RunResolutionError('Memory execution sessions do not support recorded coverage or baseline updates.', undefined, 'unsupported-request');
12
+ }
13
+ return {
14
+ ...supplied,
15
+ lifecycle: { ...supplied.lifecycle },
16
+ command: {
17
+ ...supplied.command,
18
+ policy: parseFrozenMicrotestPolicy(supplied.command.policy),
19
+ invocation: {
20
+ seed: { value: supplied.command.invocation.seed.value ?? createSeed() },
21
+ selection: runSelectionSchema.parse(supplied.command.invocation.selection)
22
+ },
23
+ reporting: { outputRenderer: createPlainOutputRenderer(), reporters: [] }
24
+ }
25
+ };
26
+ }
27
+ export const executionTransportSchema = z.strictObject({
28
+ lifecycle: z.strictObject({ moduleUrl: z.url(), exportName: z.string().min(1) }),
29
+ data: z.json()
30
+ });
31
+ export const executionReplySchema = z.discriminatedUnion('kind', [
32
+ z.strictObject({
33
+ kind: z.literal('result'),
34
+ result: runResultSchema,
35
+ data: z.json(),
36
+ deadlineExceeded: z.boolean()
37
+ }),
38
+ z.strictObject({ kind: z.literal('failure'), failure: runExecutionFailureSchema, data: z.json() }),
39
+ z.strictObject({ kind: z.literal('timeout'), data: z.json() })
40
+ ]);
41
+ export const executionHostRequestSchema = z.strictObject({
42
+ policy: frozenMicrotestPolicySchema,
43
+ seed: z.strictObject({ value: z.bigint().nonnegative() }),
44
+ selection: runSelectionSchema,
45
+ transport: executionTransportSchema,
46
+ timeoutMilliseconds: z.number().positive()
47
+ });
48
+ //# sourceMappingURL=execution-session-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-session-schema.js","sourceRoot":"","sources":["../../../../source/run/execution-session-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,MAAM,UAAU,gCAAgC,CAC5C,QAAoC,EACpC,UAAwB;IAExB,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC,OAA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,EAAE,CAAC,CAAC,OAAO,EAAE;KAChC,CAAC;IACF,CAAC,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,yBAAyB,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;IAClG,CAAC,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;CACjE,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,YAAY,CAAC;IACrD,MAAM,EAAE,2BAA2B;IACnC,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;IACzD,SAAS,EAAE,kBAAkB;IAC7B,SAAS,EAAE,wBAAwB;IACnC,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC7C,CAAC,CAAC"}
@@ -0,0 +1,82 @@
1
+ import { createStoredValue } from "../stored-value.js";
2
+ import { envelopeMessage } from "./child-process-protocol.js";
3
+ import { supervisedChildMessageSchema } from "./supervised-protocol-schema.js";
4
+ import { supervisedChildCorrelationId } from "./supervised-protocol.js";
5
+ import { createRunOperations } from "./run-operations.js";
6
+ import { withExecutionSession } from "./execution-session-context.js";
7
+ import { runExecutionFailure } from "./execution-failure.js";
8
+ function readExecutionData(observation, message) {
9
+ const decoded = envelopeMessage(message, supervisedChildCorrelationId, supervisedChildMessageSchema);
10
+ if (decoded?.kind !== 'execution-data') {
11
+ return;
12
+ }
13
+ if (observation.delivered.read()) {
14
+ throw new Error('Duplicate execution lifecycle data.');
15
+ }
16
+ observation.delivered.write(true);
17
+ observation.data.write(decoded.data);
18
+ }
19
+ function observeExecutionMessage(observation, message) {
20
+ try {
21
+ readExecutionData(observation, message);
22
+ }
23
+ catch (error) {
24
+ observation.failure.write(error instanceof Error ? error : new Error('Invalid execution lifecycle data.', { cause: error }));
25
+ observation.invalid.abort();
26
+ }
27
+ }
28
+ function observedDependencies(dependencies, observation) {
29
+ return {
30
+ ...dependencies,
31
+ async startSupervisedChild(input) {
32
+ const child = await dependencies.startSupervisedChild(input);
33
+ child.on('message', function (message) {
34
+ observeExecutionMessage(observation, message);
35
+ });
36
+ return child;
37
+ }
38
+ };
39
+ }
40
+ function missingDataReply(result, call) {
41
+ if (call.signal.aborted && result.runnerErrors.every(function (error) {
42
+ return error.subtype === 'crash';
43
+ })) {
44
+ return { kind: 'failure', failure: runExecutionFailure(call.signal.reason), data: null };
45
+ }
46
+ const errors = result
47
+ .runnerErrors
48
+ .map(function (error) {
49
+ return error.message;
50
+ })
51
+ .join('\n');
52
+ return {
53
+ kind: 'failure',
54
+ failure: runExecutionFailure(new Error(`Execution lifecycle data was not delivered. ${errors}`)),
55
+ data: null
56
+ };
57
+ }
58
+ function observedReply(result, call, observation) {
59
+ const failure = observation.failure.read();
60
+ if (failure !== null) {
61
+ return { kind: 'failure', failure: runExecutionFailure(failure), data: observation.data.read() };
62
+ }
63
+ if (!observation.delivered.read()) {
64
+ return missingDataReply(result, call);
65
+ }
66
+ return { kind: 'result', result, data: observation.data.read(), deadlineExceeded: false };
67
+ }
68
+ export async function runSupervisedExecutionSession(options, dependencies, call) {
69
+ const observation = {
70
+ data: createStoredValue(null),
71
+ delivered: createStoredValue(false),
72
+ failure: createStoredValue(null),
73
+ invalid: new AbortController()
74
+ };
75
+ const operations = createRunOperations(observedDependencies(dependencies, observation), 'test');
76
+ const signal = AbortSignal.any([call.signal, observation.invalid.signal]);
77
+ const result = await withExecutionSession(call.transport, async function () {
78
+ return await operations.run(options.command, { signal, timing: null });
79
+ });
80
+ return observedReply(result, call, observation);
81
+ }
82
+ //# sourceMappingURL=execution-session-supervised.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-session-supervised.js","sourceRoot":"","sources":["../../../../source/run/execution-session-supervised.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAoB,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAe7D,SAAS,iBAAiB,CAAC,WAAqC,EAAE,OAAgB;IAC9E,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,EAAE,4BAA4B,EAAE,4BAA4B,CAAC,CAAC;IACrG,IAAI,OAAO,EAAE,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACrC,OAAO;IACX,CAAC;IACD,IAAI,WAAW,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IAC3D,CAAC;IACD,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC;AACD,SAAS,uBAAuB,CAAC,WAAqC,EAAE,OAAgB;IACpF,IAAI,CAAC;QACD,iBAAiB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACtB,WAAW,CAAC,OAAO,CAAC,KAAK,CACrB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,mCAAmC,EAAE,EAAE,KAAK,EAAE,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AAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3E,CAAC,CACJ,CAAC;IACF,OAAO,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,46 @@
1
+ import type { JsonValue } from 'type-fest';
2
+ import type { NonEmptyReadonlyArray } from '../assertion-protocol/assertion-node-shape.ts';
3
+ import type { RunResult, RunnerError } from './run-engine-primitives.ts';
4
+ type ExecutionFailureDetails = {
5
+ readonly name: string;
6
+ readonly message: string;
7
+ readonly cause: unknown;
8
+ readonly stack: string | null;
9
+ };
10
+ type ExecutionFailureKind = {
11
+ readonly kind: 'collection-error';
12
+ readonly errors: NonEmptyReadonlyArray<RunnerError>;
13
+ } | {
14
+ readonly kind: 'config-error';
15
+ } | {
16
+ readonly kind: 'error';
17
+ } | {
18
+ readonly kind: 'resolution-error';
19
+ readonly code: 'invalid-request' | 'no-tests-collected' | 'unsupported-request';
20
+ };
21
+ export type RunExecutionFailure = ExecutionFailureDetails & ExecutionFailureKind;
22
+ export type RunExecutionInvocation = {
23
+ readonly data: JsonValue;
24
+ readonly timeoutMilliseconds: number;
25
+ readonly signal: AbortSignal | null;
26
+ };
27
+ export type RunExecutionReply = {
28
+ readonly kind: 'failure';
29
+ readonly failure: RunExecutionFailure;
30
+ readonly data: JsonValue;
31
+ } | {
32
+ readonly kind: 'result';
33
+ readonly result: RunResult;
34
+ readonly data: JsonValue;
35
+ readonly deadlineExceeded: boolean;
36
+ } | {
37
+ readonly kind: 'timeout';
38
+ readonly data: JsonValue;
39
+ };
40
+ export type RunExecutionSession = {
41
+ readonly environmentLifetime: 'fresh' | 'reused';
42
+ readonly run: (invocation: RunExecutionInvocation) => Promise<RunExecutionReply>;
43
+ readonly dispose: () => Promise<void>;
44
+ };
45
+ export {};
46
+ //# sourceMappingURL=execution-session-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-session-types.d.ts","sourceRoot":"","sources":["../../../../source/run/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S,CAAC;CAC5B,GAAG;IACA,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;CACtC,GAAG;IACA,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;CAC5B,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG;IAC9B,QAAQ,CAAC,mBAAmB,EAAE,OAAO,GAAG,QAAQ,CAAC;IACjD,QAAQ,CAAC,GAAG,EAAE,CAAC,UAAU,EAAE,sBAAsB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACjF,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACzC,CAAC"}
@@ -0,0 +1,97 @@
1
+ import { setTimeout as scheduleDeadline, clearTimeout as cancelDeadline } from 'node:timers';
2
+ import { createStoredValue } from "../stored-value.js";
3
+ import { runExecutionFailure } from "./execution-failure.js";
4
+ import { executionTransportSchema, normalizeExecutionSessionOptions } from "./execution-session-schema.js";
5
+ async function initializeExecutionEnvironment(options, dependencies) {
6
+ const { createExecutionSessionEnvironment } = await import("./execution-session-environment.js");
7
+ return createExecutionSessionEnvironment(options, dependencies);
8
+ }
9
+ function deadlineCancelledReply(reply, signal, expired) {
10
+ return reply.kind === 'failure' && expired && signal.reason instanceof Error &&
11
+ reply.failure.message === signal.reason.message;
12
+ }
13
+ async function completeInvocation(environment, execution) {
14
+ const { invocation, signal, expired, lifecycle } = execution;
15
+ signal.throwIfAborted();
16
+ const transport = executionTransportSchema.parse({ lifecycle, data: structuredClone(invocation.data) });
17
+ const initialized = await environment;
18
+ const reply = await initialized.execute({ transport, timeoutMilliseconds: invocation.timeoutMilliseconds, signal });
19
+ if (deadlineCancelledReply(reply, signal, expired())) {
20
+ return { kind: 'timeout', data: reply.data };
21
+ }
22
+ return reply.kind === 'result' ? { ...reply, deadlineExceeded: reply.deadlineExceeded || expired() } : reply;
23
+ }
24
+ function cancelledDeadline(error, signal, expired) {
25
+ return expired && (error === signal.reason || error instanceof Error && error.cause === signal.reason);
26
+ }
27
+ async function executeInvocation(environment, invocation, disposed, lifecycle) {
28
+ const cancellation = new AbortController();
29
+ const signal = AbortSignal.any([
30
+ disposed,
31
+ cancellation.signal,
32
+ ...invocation.signal === null ? [] : [invocation.signal]
33
+ ]);
34
+ const expired = createStoredValue(false);
35
+ const started = performance.now();
36
+ const deadlineExpired = function () {
37
+ return expired.read() || performance.now() - started >= invocation.timeoutMilliseconds;
38
+ };
39
+ const timer = scheduleDeadline(function cancelExpiredInvocation() {
40
+ expired.write(true);
41
+ cancellation.abort();
42
+ }, invocation.timeoutMilliseconds);
43
+ try {
44
+ return await completeInvocation(environment, { invocation, signal, expired: deadlineExpired, lifecycle });
45
+ }
46
+ catch (error) {
47
+ return cancelledDeadline(error, signal, expired.read())
48
+ ? { kind: 'timeout', data: null }
49
+ : { kind: 'failure', failure: runExecutionFailure(error), data: null };
50
+ }
51
+ finally {
52
+ cancelDeadline(timer);
53
+ }
54
+ }
55
+ function assertSessionAdmission(disposed, active) {
56
+ if (disposed.aborted) {
57
+ throw new Error('Execution session has been disposed.');
58
+ }
59
+ if (active !== null) {
60
+ throw new Error('An execution invocation is already running.');
61
+ }
62
+ }
63
+ function executionLifetime(options) {
64
+ const fresh = options.environment === 'fresh-invocation' ||
65
+ options.command.policy.profile.execution.processModel === 'supervised-process';
66
+ return fresh ? 'fresh' : 'reused';
67
+ }
68
+ export function createExecutionSession(supplied, dependencies) {
69
+ const options = normalizeExecutionSessionOptions(supplied, dependencies.createSeed);
70
+ const environment = createStoredValue(null);
71
+ const disposed = new AbortController();
72
+ const active = createStoredValue(null);
73
+ return {
74
+ environmentLifetime: executionLifetime(options),
75
+ async run(invocation) {
76
+ assertSessionAdmission(disposed.signal, active.read());
77
+ if (!Number.isFinite(invocation.timeoutMilliseconds) || invocation.timeoutMilliseconds <= 0) {
78
+ return { kind: 'timeout', data: null };
79
+ }
80
+ const initialized = environment.read() ?? initializeExecutionEnvironment(options, dependencies);
81
+ environment.write(initialized);
82
+ const running = executeInvocation(initialized, invocation, disposed.signal, options.lifecycle);
83
+ active.write(running);
84
+ try {
85
+ return await running;
86
+ }
87
+ finally {
88
+ active.write(null);
89
+ }
90
+ },
91
+ async dispose() {
92
+ disposed.abort();
93
+ await active.read();
94
+ }
95
+ };
96
+ }
97
+ //# sourceMappingURL=execution-session.js.map