@overkill-dev/run 0.0.80 → 0.0.82
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.
- package/baselines/calibration-reference.js +10 -0
- package/baselines/calibration-reference.js.map +1 -0
- package/baselines/calibration-store.js +185 -0
- package/baselines/calibration-store.js.map +1 -0
- package/baselines/performance-adapter.d.ts +1 -1
- package/baselines/performance-adapter.d.ts.map +1 -1
- package/baselines/performance-baseline.d.ts +17 -3
- package/baselines/performance-baseline.d.ts.map +1 -1
- package/baselines/performance-baseline.js +13 -1
- package/baselines/performance-baseline.js.map +1 -1
- package/baselines/performance-evaluation.js +12 -11
- package/baselines/performance-evaluation.js.map +1 -1
- package/baselines/performance-observation.js +74 -0
- package/baselines/performance-observation.js.map +1 -0
- package/baselines/performance-plan.js +28 -2
- package/baselines/performance-plan.js.map +1 -1
- package/baselines/performance-schema.js +14 -1
- package/baselines/performance-schema.js.map +1 -1
- package/baselines/performance-store.js +2 -14
- package/baselines/performance-store.js.map +1 -1
- package/baselines/performance-workflow.js +18 -10
- package/baselines/performance-workflow.js.map +1 -1
- package/bench/benchmark-run-report.js +14 -5
- package/bench/benchmark-run-report.js.map +1 -1
- package/bench/benchmark-statistics-schema.d.ts +4 -0
- package/bench/benchmark-statistics-schema.d.ts.map +1 -0
- package/bench/benchmark-statistics-schema.js +40 -0
- package/bench/benchmark-statistics-schema.js.map +1 -0
- package/bench/calibration-evidence.js +80 -0
- package/bench/calibration-evidence.js.map +1 -0
- package/bench/calibration-machine.d.ts +14 -0
- package/bench/calibration-machine.d.ts.map +1 -0
- package/bench/calibration-machine.js +43 -0
- package/bench/calibration-machine.js.map +1 -0
- package/bench/calibration-report.d.ts +24 -0
- package/bench/calibration-report.d.ts.map +1 -0
- package/bench/calibration-report.js +28 -0
- package/bench/calibration-report.js.map +1 -0
- package/bench/cpu-reference-workload.d.ts +2 -0
- package/bench/cpu-reference-workload.d.ts.map +1 -0
- package/bench/cpu-reference-workload.js +12 -0
- package/bench/cpu-reference-workload.js.map +1 -0
- package/bench/host-calibration-result.d.ts +15 -0
- package/bench/host-calibration-result.d.ts.map +1 -0
- package/engine/async-leak-diagnostics.js +18 -5
- package/engine/async-leak-diagnostics.js.map +1 -1
- package/engine/benchmark-environment.d.ts +8 -0
- package/engine/benchmark-environment.d.ts.map +1 -0
- package/engine/benchmark-garbage-collection.d.ts +0 -5
- package/engine/benchmark-garbage-collection.d.ts.map +1 -1
- package/engine/benchmark-garbage-collection.js.map +1 -1
- package/engine/benchmark-node.d.ts +3 -2
- package/engine/benchmark-node.d.ts.map +1 -1
- package/engine/benchmark-node.js +9 -0
- package/engine/benchmark-node.js.map +1 -0
- package/engine/benchmark-result.d.ts +85 -1
- package/engine/benchmark-result.d.ts.map +1 -1
- package/engine/benchmark-result.js.map +1 -1
- package/engine/case-attempt-execution.js +25 -17
- package/engine/case-attempt-execution.js.map +1 -1
- package/engine/case-body-execution.js +1 -0
- package/engine/case-body-execution.js.map +1 -1
- package/engine/execution-async-leak-policy.d.ts +3 -0
- package/engine/execution-async-leak-policy.d.ts.map +1 -0
- package/engine/execution-async-leak-policy.js +38 -23
- package/engine/execution-async-leak-policy.js.map +1 -1
- package/engine/execution-error-ownership.d.ts +6 -0
- package/engine/execution-error-ownership.d.ts.map +1 -0
- package/engine/execution-error-ownership.js +83 -0
- package/engine/execution-error-ownership.js.map +1 -0
- package/engine/execution-global-error-observer.d.ts +1 -4
- package/engine/execution-global-error-observer.d.ts.map +1 -1
- package/engine/execution-global-error-observer.js +41 -81
- package/engine/execution-global-error-observer.js.map +1 -1
- package/engine/execution-observation.js +198 -0
- package/engine/execution-observation.js.map +1 -0
- package/engine/execution-options.d.ts +9 -0
- package/engine/execution-options.d.ts.map +1 -1
- package/engine/execution-preparation.d.ts +13 -0
- package/engine/execution-preparation.d.ts.map +1 -0
- package/engine/execution-preparation.js +34 -0
- package/engine/execution-preparation.js.map +1 -0
- package/engine/execution-supervision-state.js +8 -0
- package/engine/execution-supervision-state.js.map +1 -1
- package/engine/execution-supervision.d.ts +1 -1
- package/engine/execution-supervision.d.ts.map +1 -1
- package/engine/execution-supervision.js +3 -3
- package/engine/execution-supervision.js.map +1 -1
- package/engine/execution-test-plan-cases.js +11 -9
- package/engine/execution-test-plan-cases.js.map +1 -1
- package/engine/execution.d.ts +3 -1
- package/engine/execution.d.ts.map +1 -1
- package/engine/execution.js +3 -27
- package/engine/execution.js.map +1 -1
- package/engine/infrastructure-resource-observation.js +55 -0
- package/engine/infrastructure-resource-observation.js.map +1 -0
- package/engine/reporter-dispatcher.d.ts.map +1 -1
- package/engine/reporter-dispatcher.js +6 -3
- package/engine/reporter-dispatcher.js.map +1 -1
- package/engine/reporter-output-scope.js +7 -2
- package/engine/reporter-output-scope.js.map +1 -1
- package/engine/resource-owner-observation.js +97 -7
- package/engine/resource-owner-observation.js.map +1 -1
- package/execution-termination.d.ts +2 -0
- package/execution-termination.d.ts.map +1 -0
- package/execution-termination.js +8 -0
- package/execution-termination.js.map +1 -0
- package/invocation-budget.d.ts +13 -0
- package/invocation-budget.d.ts.map +1 -0
- package/invocation-budget.js +35 -0
- package/invocation-budget.js.map +1 -0
- package/package.json +13 -1
- package/packages/run/benchmark-calibration.entry-point.d.ts +12 -14
- package/packages/run/benchmark-calibration.entry-point.d.ts.map +1 -1
- package/packages/run/benchmark-calibration.entry-point.js +11 -54
- package/packages/run/benchmark-calibration.entry-point.js.map +1 -1
- package/packages/run/command-line.entry-point.d.ts.map +1 -1
- package/packages/run/command-line.entry-point.js +4 -0
- package/packages/run/command-line.entry-point.js.map +1 -1
- package/packages/run/run.entry-point.d.ts +2 -0
- package/packages/run/run.entry-point.d.ts.map +1 -1
- package/packages/run/run.entry-point.js +2 -0
- package/packages/run/run.entry-point.js.map +1 -1
- package/readme.md +27 -0
- package/run/benchmark-baseline-commands.js +9 -4
- package/run/benchmark-baseline-commands.js.map +1 -1
- package/run/benchmark-baseline-execution.js +20 -0
- package/run/benchmark-baseline-execution.js.map +1 -0
- package/run/benchmark-baseline-operations.js +0 -14
- package/run/benchmark-baseline-operations.js.map +1 -1
- package/run/benchmark-baseline-preparation.js +63 -0
- package/run/benchmark-baseline-preparation.js.map +1 -0
- package/run/benchmark-baseline-run.js +1 -44
- package/run/benchmark-baseline-run.js.map +1 -1
- package/run/benchmark-calibration.js +7 -0
- package/run/benchmark-calibration.js.map +1 -1
- package/run/benchmark-commands.d.ts.map +1 -1
- package/run/benchmark-commands.js +31 -0
- package/run/benchmark-commands.js.map +1 -1
- package/run/benchmark-definition-schema.js +4 -1
- package/run/benchmark-definition-schema.js.map +1 -1
- package/run/benchmark-execution-environment.js +2 -1
- package/run/benchmark-execution-environment.js.map +1 -1
- package/run/benchmark-garbage-collection.js +14 -3
- package/run/benchmark-garbage-collection.js.map +1 -1
- package/run/benchmark-normalization-preparation.js +59 -0
- package/run/benchmark-normalization-preparation.js.map +1 -0
- package/run/benchmark-placement.js +1 -1
- package/run/benchmark-placement.js.map +1 -1
- package/run/benchmark-policy-schema.js +30 -0
- package/run/benchmark-policy-schema.js.map +1 -0
- package/run/benchmark-report-metadata.js +5 -3
- package/run/benchmark-report-metadata.js.map +1 -1
- package/run/benchmark-result-schema.js +5 -53
- package/run/benchmark-result-schema.js.map +1 -1
- package/run/calibration-baseline-references.js +39 -0
- package/run/calibration-baseline-references.js.map +1 -0
- package/run/calibration-capture-session.js +97 -0
- package/run/calibration-capture-session.js.map +1 -0
- package/run/calibration-inventory.js +27 -0
- package/run/calibration-inventory.js.map +1 -0
- package/run/calibration-maintenance.js +88 -0
- package/run/calibration-maintenance.js.map +1 -0
- package/run/capability-policy.js +82 -79
- package/run/capability-policy.js.map +1 -1
- package/run/child-process-outbox.js +13 -5
- package/run/child-process-outbox.js.map +1 -1
- package/run/collected-run-execution.js +3 -7
- package/run/collected-run-execution.js.map +1 -1
- package/run/command-line-command-namespace.js +3 -0
- package/run/command-line-command-namespace.js.map +1 -1
- package/run/command-line-command.d.ts +1 -0
- package/run/command-line-command.d.ts.map +1 -1
- package/run/command-line-command.js.map +1 -1
- package/run/default-run-engine.js +25 -0
- package/run/default-run-engine.js.map +1 -1
- package/run/execution-session-child.js +9 -2
- package/run/execution-session-child.js.map +1 -1
- package/run/execution-session-collected.js +7 -1
- package/run/execution-session-collected.js.map +1 -1
- package/run/execution-session-environment.js +1 -1
- package/run/execution-session-environment.js.map +1 -1
- package/run/execution-session-host.js +17 -0
- package/run/execution-session-host.js.map +1 -1
- package/run/execution-session-lifecycle.js +38 -10
- package/run/execution-session-lifecycle.js.map +1 -1
- package/run/execution-session-observation.js +95 -0
- package/run/execution-session-observation.js.map +1 -0
- package/run/execution-session-ownership.js +23 -0
- package/run/execution-session-ownership.js.map +1 -0
- package/run/execution-session-process.js +26 -4
- package/run/execution-session-process.js.map +1 -1
- package/run/execution-session-schema.js +2 -0
- package/run/execution-session-schema.js.map +1 -1
- package/run/execution-session-supervised.js +21 -75
- package/run/execution-session-supervised.js.map +1 -1
- package/run/execution-session.js +37 -35
- package/run/execution-session.js.map +1 -1
- package/run/frozen-policy-validation.js +8 -2
- package/run/frozen-policy-validation.js.map +1 -1
- package/run/frozen-supervised-command-schema.js +2 -2
- package/run/frozen-supervised-command-schema.js.map +1 -1
- package/run/initialized-run-collection.js +80 -0
- package/run/initialized-run-collection.js.map +1 -0
- package/run/initialized-run.js +2 -49
- package/run/initialized-run.js.map +1 -1
- package/run/node-child-process-starters.js +2 -0
- package/run/node-child-process-starters.js.map +1 -1
- package/run/path-containment.js +13 -0
- package/run/path-containment.js.map +1 -1
- package/run/permission-denial-runtime-policy.js +30 -50
- package/run/permission-denial-runtime-policy.js.map +1 -1
- package/run/run-cancellation.js.map +1 -1
- package/run/run-collected-resolution.js +7 -0
- package/run/run-collected-resolution.js.map +1 -1
- package/run/run-command-schema.js +2 -0
- package/run/run-command-schema.js.map +1 -1
- package/run/run-engine-primitives.d.ts +2 -1
- package/run/run-engine-primitives.d.ts.map +1 -1
- package/run/run-execution.js +1 -1
- package/run/run-execution.js.map +1 -1
- package/run/run-facts.js +1 -0
- package/run/run-facts.js.map +1 -1
- package/run/run-input-resolution.js +5 -3
- package/run/run-input-resolution.js.map +1 -1
- package/run/run-isolated-command.js +8 -2
- package/run/run-isolated-command.js.map +1 -1
- package/run/run-isolated-process.js +5 -0
- package/run/run-isolated-process.js.map +1 -1
- package/run/run-local-command.js +3 -7
- package/run/run-local-command.js.map +1 -1
- package/run/run-local-coverage.js +3 -7
- package/run/run-local-coverage.js.map +1 -1
- package/run/run-local-planning.js +2 -0
- package/run/run-local-planning.js.map +1 -1
- package/run/run-supervised-process.js +14 -3
- package/run/run-supervised-process.js.map +1 -1
- package/run/run-support.js +11 -9
- package/run/run-support.js.map +1 -1
- package/run/run-types.d.ts +5 -2
- package/run/run-types.d.ts.map +1 -1
- package/run/run-types.js.map +1 -1
- package/run/run.js +3 -1
- package/run/run.js.map +1 -1
- package/run/supervised-child-execution.js +1 -1
- package/run/supervised-child-execution.js.map +1 -1
- package/run/supervised-child-failure.js +9 -3
- package/run/supervised-child-failure.js.map +1 -1
- package/run/supervised-child-process.d.ts.map +1 -1
- package/run/supervised-child-process.js +2 -2
- package/run/supervised-child-process.js.map +1 -1
- package/run/supervised-child-test-plan.js +3 -3
- package/run/supervised-child-test-plan.js.map +1 -1
- package/run/supervised-child-transport.js +10 -5
- package/run/supervised-child-transport.js.map +1 -1
- package/run/supervised-child.entry-point.js +1 -0
- package/run/supervised-child.entry-point.js.map +1 -1
- package/run/supervised-child.js +49 -35
- package/run/supervised-child.js.map +1 -1
- package/run/supervised-protocol-schema.js +1 -1
- package/run/supervised-protocol-schema.js.map +1 -1
- package/run/supervised-protocol.js.map +1 -1
- package/run/supervised-run-process-policy.js +11 -0
- package/run/supervised-run-process-policy.js.map +1 -1
- package/run/supervised-run-runtime.js +1 -1
- package/run/supervised-run-runtime.js.map +1 -1
- package/run/worker-execution-engine.js +1 -1
- package/run/worker-execution-engine.js.map +1 -1
- package/run/worker-pool-command.js +4 -6
- package/run/worker-pool-command.js.map +1 -1
- package/run/worker-pool-host.entry-point.js +1 -1
- package/run/worker-pool-host.entry-point.js.map +1 -1
- package/run/worker-pool-protocol.js.map +1 -1
- package/run/worker-pool-worker-plan.js +2 -2
- package/run/worker-pool-worker-plan.js.map +1 -1
- package/software-bill-of-materials.cyclonedx.json +4 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { executionErrorOwnership } from "./execution-error-ownership.js";
|
|
2
|
+
import { createExecutionObservation, observingInfrastructure } from "./execution-observation.js";
|
|
2
3
|
import { permissionDeniedRunnerErrorFromThrown } from "./run-result.js";
|
|
3
|
-
const runScopeStorage =
|
|
4
|
-
const activeCaseStorage = new AsyncLocalStorage();
|
|
4
|
+
const { runScopeStorage, activeCaseStorage, activeScopes, processHookListeners } = executionErrorOwnership();
|
|
5
5
|
function createStoredValue(initialValue) {
|
|
6
6
|
let currentValue = initialValue;
|
|
7
7
|
return {
|
|
@@ -14,6 +14,7 @@ function createStoredValue(initialValue) {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
function createRunErrorScope(boundary) {
|
|
17
|
+
const observation = createExecutionObservation();
|
|
17
18
|
const activeCaseKeys = new Set();
|
|
18
19
|
const errors = [];
|
|
19
20
|
const fatal = createStoredValue(false);
|
|
@@ -31,6 +32,7 @@ function createRunErrorScope(boundary) {
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
return {
|
|
35
|
+
observation,
|
|
34
36
|
activeCaseStarted(key) {
|
|
35
37
|
activeCaseKeys.add(key);
|
|
36
38
|
},
|
|
@@ -81,6 +83,8 @@ function createRunErrorScope(boundary) {
|
|
|
81
83
|
stop() {
|
|
82
84
|
stopped.write(true);
|
|
83
85
|
fatalHandlers.clear();
|
|
86
|
+
activeCaseKeys.clear();
|
|
87
|
+
observation.stop();
|
|
84
88
|
},
|
|
85
89
|
takeErrors() {
|
|
86
90
|
const currentErrors = Array.from(errors);
|
|
@@ -89,29 +93,6 @@ function createRunErrorScope(boundary) {
|
|
|
89
93
|
}
|
|
90
94
|
};
|
|
91
95
|
}
|
|
92
|
-
function createActiveScopes() {
|
|
93
|
-
const scopes = [];
|
|
94
|
-
return {
|
|
95
|
-
add(scope) {
|
|
96
|
-
scopes.push(scope);
|
|
97
|
-
},
|
|
98
|
-
all() {
|
|
99
|
-
return Array.from(scopes);
|
|
100
|
-
},
|
|
101
|
-
includes(scope) {
|
|
102
|
-
return scopes.includes(scope);
|
|
103
|
-
},
|
|
104
|
-
remove(scope) {
|
|
105
|
-
const index = scopes.lastIndexOf(scope);
|
|
106
|
-
if (index !== -1) {
|
|
107
|
-
scopes.splice(index, 1);
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
size() {
|
|
111
|
-
return scopes.length;
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
96
|
|
|
116
97
|
function serializedReason(reason) {
|
|
117
98
|
if (reason instanceof Error) {
|
|
@@ -187,41 +168,37 @@ function attributionDriftError(scope, hook, reason, activeCase) {
|
|
|
187
168
|
function scopeIncludesCase(scope, activeCase) {
|
|
188
169
|
return activeCase !== null && activeCase.scope === scope;
|
|
189
170
|
}
|
|
190
|
-
function activePermissionCase(input) {
|
|
191
|
-
if (!scopeIncludesCase(input.scope, input.activeCase)) {
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
return input.scope.hasActiveCase(input.activeCase) ? input.activeCase : null;
|
|
195
|
-
}
|
|
196
171
|
function permissionErrorForScope(input) {
|
|
197
|
-
const activeCase =
|
|
198
|
-
|
|
199
|
-
attributedTo:
|
|
200
|
-
attributedToWork: activeCase
|
|
172
|
+
const activeCase = scopeIncludesCase(input.scope, input.activeCase) ? input.activeCase : null;
|
|
173
|
+
const attribution = activeCase === null
|
|
174
|
+
? { attributedTo: null, attributedToWork: null, phase: input.scope.phase() }
|
|
175
|
+
: { attributedTo: activeCase.id, attributedToWork: activeCase.workId, phase: 'body' };
|
|
176
|
+
const error = permissionDeniedRunnerErrorFromThrown(input.reason, {
|
|
177
|
+
...attribution,
|
|
201
178
|
boundary: input.scope.boundary,
|
|
202
179
|
diagnosticChannel: null,
|
|
203
|
-
hook: input.hook
|
|
204
|
-
phase: activeCase === null ? input.scope.phase() : 'body'
|
|
180
|
+
hook: input.hook
|
|
205
181
|
});
|
|
182
|
+
return error === null ? null : input.scope.observation.attribute(error);
|
|
183
|
+
}
|
|
184
|
+
function ownedHookError(input) {
|
|
185
|
+
if (scopeIncludesCase(input.scope, input.activeCase)) {
|
|
186
|
+
return attributedError(input.scope, input.hook, input.reason, input.activeCase);
|
|
187
|
+
}
|
|
188
|
+
const error = runLevelHookError(input.scope, input.hook, input.reason);
|
|
189
|
+
return input.scope.observation.attribute(error).subtype === 'attribution-drift'
|
|
190
|
+
? attributionDriftError(input.scope, input.hook, input.reason, input.activeCase)
|
|
191
|
+
: error;
|
|
206
192
|
}
|
|
207
193
|
function errorForScope(input) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
return permissionError;
|
|
194
|
+
if (scopeIncludesCase(input.scope, input.activeCase) && !input.scope.hasActiveCase(input.activeCase)) {
|
|
195
|
+
return attributionDriftError(input.scope, input.hook, input.reason, input.activeCase);
|
|
211
196
|
}
|
|
212
197
|
if (input.ambiguousScope) {
|
|
213
|
-
return attributionDriftError(input.scope, input.hook, input.reason,
|
|
198
|
+
return attributionDriftError(input.scope, input.hook, input.reason, null);
|
|
214
199
|
}
|
|
215
|
-
|
|
216
|
-
return runLevelHookError(input.scope, input.hook, input.reason);
|
|
217
|
-
}
|
|
218
|
-
if (input.scope.hasActiveCase(input.activeCase)) {
|
|
219
|
-
return attributedError(input.scope, input.hook, input.reason, input.activeCase);
|
|
220
|
-
}
|
|
221
|
-
return attributionDriftError(input.scope, input.hook, input.reason, input.activeCase);
|
|
200
|
+
return permissionErrorForScope(input) ?? ownedHookError(input);
|
|
222
201
|
}
|
|
223
|
-
const activeScopes = createActiveScopes();
|
|
224
|
-
const listenersInstalled = createStoredValue(false);
|
|
225
202
|
function currentTargetScopes() {
|
|
226
203
|
const currentScope = runScopeStorage.getStore();
|
|
227
204
|
if (currentScope !== undefined && activeScopes.includes(currentScope)) {
|
|
@@ -230,40 +207,19 @@ function currentTargetScopes() {
|
|
|
230
207
|
return activeScopes.all();
|
|
231
208
|
}
|
|
232
209
|
function receiveHookFailure(hook, reason) {
|
|
233
|
-
const activeCase = activeCaseStorage.getStore() ?? null;
|
|
210
|
+
const activeCase = observingInfrastructure() ? null : activeCaseStorage.getStore() ?? null;
|
|
234
211
|
const ambiguousScope = runScopeStorage.getStore() === undefined && activeScopes.size() > 1;
|
|
235
212
|
for (const scope of currentTargetScopes()) {
|
|
236
213
|
scope.recordError(errorForScope({ activeCase, ambiguousScope, hook, reason, scope }));
|
|
237
214
|
}
|
|
238
215
|
}
|
|
239
|
-
function receiveUnhandledRejection(reason) {
|
|
240
|
-
receiveHookFailure('unhandledRejection', reason);
|
|
241
|
-
}
|
|
242
|
-
function receiveUncaughtException(error) {
|
|
243
|
-
receiveHookFailure('uncaughtException', error);
|
|
244
|
-
}
|
|
245
|
-
function createProcessHookListeners() {
|
|
246
|
-
return {
|
|
247
|
-
install() {
|
|
248
|
-
if (listenersInstalled.read()) {
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
process.prependListener('unhandledRejection', receiveUnhandledRejection);
|
|
252
|
-
process.prependListener('uncaughtException', receiveUncaughtException);
|
|
253
|
-
listenersInstalled.write(true);
|
|
254
|
-
},
|
|
255
|
-
removeWhenIdle() {
|
|
256
|
-
if (listenersInstalled.read() && activeScopes.size() === 0) {
|
|
257
|
-
process.removeListener('unhandledRejection', receiveUnhandledRejection);
|
|
258
|
-
process.removeListener('uncaughtException', receiveUncaughtException);
|
|
259
|
-
listenersInstalled.write(false);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
const processHookListeners = createProcessHookListeners();
|
|
265
216
|
export function createExecutionGlobalErrorObserver(boundary) {
|
|
266
217
|
const scope = createRunErrorScope(boundary);
|
|
218
|
+
scope.observation.register(function stopOwnedGlobalObserver() {
|
|
219
|
+
scope.stop();
|
|
220
|
+
activeScopes.remove(scope);
|
|
221
|
+
processHookListeners.removeWhenIdle();
|
|
222
|
+
});
|
|
267
223
|
return {
|
|
268
224
|
async fatalSignal() {
|
|
269
225
|
await scope.fatalSignal();
|
|
@@ -275,10 +231,12 @@ export function createExecutionGlobalErrorObserver(boundary) {
|
|
|
275
231
|
return scope.onFatalError(handler);
|
|
276
232
|
},
|
|
277
233
|
async runBoundary(run) {
|
|
278
|
-
processHookListeners.install();
|
|
234
|
+
processHookListeners.install(receiveHookFailure);
|
|
279
235
|
activeScopes.add(scope);
|
|
280
236
|
try {
|
|
281
|
-
return await
|
|
237
|
+
return await scope.observation.run(async function observeRunOwnership() {
|
|
238
|
+
return await runScopeStorage.run(scope, run);
|
|
239
|
+
});
|
|
282
240
|
}
|
|
283
241
|
finally {
|
|
284
242
|
activeScopes.remove(scope);
|
|
@@ -294,7 +252,9 @@ export function createExecutionGlobalErrorObserver(boundary) {
|
|
|
294
252
|
};
|
|
295
253
|
scope.activeCaseStarted(activeCase);
|
|
296
254
|
try {
|
|
297
|
-
return await
|
|
255
|
+
return await scope.observation.runAttempt(testCase, attempt, async function observeAttemptOwnership() {
|
|
256
|
+
return await activeCaseStorage.run(activeCase, run);
|
|
257
|
+
});
|
|
298
258
|
}
|
|
299
259
|
finally {
|
|
300
260
|
scope.activeCaseStopped(activeCase);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-global-error-observer.js","sourceRoot":"","sources":["../../../../source/engine/execution-global-error-observer.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"execution-global-error-observer.js","sourceRoot":"","sources":["../../../../source/engine/execution-global-error-observer.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,uBAAuB,EAQ1B,MAAM,gCAAgC,CAAC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AAE,KAAK,UAAU,uBAAuB;oBAC/F,OAAO,MAAM,iBAAiB,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;gBACxD,CAAC,CAAC,CAAC;YACP,CAAC;oBAAS,CAAC;gBACP,KAAK,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;YACxC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG;YACrB,OAAO,MAAM,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC5C,CAAC;QACD,IAAI;YACA,KAAK,CAAC,IAAI,EAAE,CAAC;YACb,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC3B,oBAAoB,CAAC,cAAc,EAAE,CAAC;QAC1C,CAAC;QACD,UAAU;YACN,OAAO,KAAK,CAAC,UAAU,EAAE,CAAC;QAC9B,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
const observationKey = Symbol.for('@overkill-dev/engine/executionObservation');
|
|
3
|
+
function isObservationStorage(value) {
|
|
4
|
+
return value instanceof AsyncLocalStorage;
|
|
5
|
+
}
|
|
6
|
+
function sharedObservationStorage() {
|
|
7
|
+
const existing = Reflect.get(globalThis, observationKey);
|
|
8
|
+
if (isObservationStorage(existing)) {
|
|
9
|
+
return existing;
|
|
10
|
+
}
|
|
11
|
+
const created = new AsyncLocalStorage();
|
|
12
|
+
Reflect.set(globalThis, observationKey, created);
|
|
13
|
+
return created;
|
|
14
|
+
}
|
|
15
|
+
const ownership = sharedObservationStorage();
|
|
16
|
+
function disposeObservations(disposers) {
|
|
17
|
+
const errors = [];
|
|
18
|
+
for (const dispose of disposers) {
|
|
19
|
+
try {
|
|
20
|
+
dispose();
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
errors.push(error);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (errors.length > 0) {
|
|
27
|
+
throw new AggregateError(errors, 'Execution observation shutdown failed.');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function createLifetime() {
|
|
31
|
+
const disposers = new Set();
|
|
32
|
+
let open = true;
|
|
33
|
+
return {
|
|
34
|
+
open() {
|
|
35
|
+
return open;
|
|
36
|
+
},
|
|
37
|
+
close() {
|
|
38
|
+
if (!open) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
open = false;
|
|
42
|
+
const pending = Array.from(disposers);
|
|
43
|
+
disposers.clear();
|
|
44
|
+
disposeObservations(pending);
|
|
45
|
+
},
|
|
46
|
+
register(dispose) {
|
|
47
|
+
if (open) {
|
|
48
|
+
disposers.add(dispose);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
dispose();
|
|
52
|
+
}
|
|
53
|
+
return function unregister() {
|
|
54
|
+
disposers.delete(dispose);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function createRunOwner() {
|
|
60
|
+
return { ...createLifetime(), identity: Symbol('execution run') };
|
|
61
|
+
}
|
|
62
|
+
export function observingInfrastructure() {
|
|
63
|
+
return ownership.getStore()?.kind === 'infrastructure';
|
|
64
|
+
}
|
|
65
|
+
export function registerExecutionDisposal(dispose) {
|
|
66
|
+
const run = ownership.getStore()?.run;
|
|
67
|
+
if (run === null || run === undefined) {
|
|
68
|
+
return function unregisterUnownedDisposal() {
|
|
69
|
+
return undefined;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return run.register(dispose);
|
|
73
|
+
}
|
|
74
|
+
export function withRunnerInfrastructure(operation) {
|
|
75
|
+
return ownership.run({ kind: 'infrastructure', run: ownership.getStore()?.run ?? null }, operation);
|
|
76
|
+
}
|
|
77
|
+
function closeFailedObservation(run, error) {
|
|
78
|
+
try {
|
|
79
|
+
run.close();
|
|
80
|
+
}
|
|
81
|
+
catch (cleanupError) {
|
|
82
|
+
throw new AggregateError([error, cleanupError], 'Execution and observation shutdown failed.', {
|
|
83
|
+
cause: cleanupError
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
export async function withExecutionObservation(operation) {
|
|
89
|
+
const current = ownership.getStore();
|
|
90
|
+
if (current?.kind === 'run' && current.run.open()) {
|
|
91
|
+
return await operation();
|
|
92
|
+
}
|
|
93
|
+
const run = createRunOwner();
|
|
94
|
+
try {
|
|
95
|
+
const result = await ownership.run({ kind: 'run', run }, operation);
|
|
96
|
+
run.close();
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
return closeFailedObservation(run, error);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function lateObservation(error, owner) {
|
|
104
|
+
return {
|
|
105
|
+
...error,
|
|
106
|
+
attributedTo: null,
|
|
107
|
+
attributedToWork: null,
|
|
108
|
+
attributedToAttempt: null,
|
|
109
|
+
subtype: 'attribution-drift',
|
|
110
|
+
cause: {
|
|
111
|
+
kind: 'late-observation',
|
|
112
|
+
origin: { case: owner.attempt.caseId, work: owner.attempt.workId, attempt: owner.attempt.attempt },
|
|
113
|
+
observation: error
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function attributeObservation(error, run) {
|
|
118
|
+
const owner = ownership.getStore();
|
|
119
|
+
if (owner?.kind === 'attempt') {
|
|
120
|
+
if (!owner.run.open() || !owner.attempt.open()) {
|
|
121
|
+
return lateObservation(error, owner);
|
|
122
|
+
}
|
|
123
|
+
if (owner.run === run) {
|
|
124
|
+
return {
|
|
125
|
+
...error,
|
|
126
|
+
attributedTo: owner.attempt.caseId,
|
|
127
|
+
attributedToWork: owner.attempt.workId,
|
|
128
|
+
attributedToAttempt: owner.attempt.attempt
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return { ...error, attributedTo: null, attributedToWork: null, attributedToAttempt: null };
|
|
133
|
+
}
|
|
134
|
+
function matchesAttempt(owner, testCase, attempt) {
|
|
135
|
+
return owner.caseId === testCase.id && owner.workId === testCase.workId && owner.attempt.index === attempt.index;
|
|
136
|
+
}
|
|
137
|
+
function ownsObservation(run, owner) {
|
|
138
|
+
if (owner === undefined) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
if (owner.kind === 'infrastructure') {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
return owner.run === run || !owner.run.open();
|
|
145
|
+
}
|
|
146
|
+
async function runOwnedAttempt(run, testCase, attempt, operation) {
|
|
147
|
+
const current = ownership.getStore();
|
|
148
|
+
if (current?.kind === 'attempt' && current.run === run && current.attempt.open() &&
|
|
149
|
+
matchesAttempt(current.attempt, testCase, attempt)) {
|
|
150
|
+
return await operation();
|
|
151
|
+
}
|
|
152
|
+
const owner = { ...createLifetime(), caseId: testCase.id, workId: testCase.workId, attempt };
|
|
153
|
+
try {
|
|
154
|
+
return await ownership.run({ kind: 'attempt', run, attempt: owner }, operation);
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
owner.close();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
export function createExecutionObservation() {
|
|
161
|
+
const current = ownership.getStore();
|
|
162
|
+
const inherited = current?.kind === 'run' && current.run.open();
|
|
163
|
+
const run = inherited ? current.run : createRunOwner();
|
|
164
|
+
const lifetime = createLifetime();
|
|
165
|
+
const unregister = run.register(lifetime.close);
|
|
166
|
+
return {
|
|
167
|
+
open: lifetime.open,
|
|
168
|
+
accepts() {
|
|
169
|
+
return lifetime.open() && ownsObservation(run, ownership.getStore());
|
|
170
|
+
},
|
|
171
|
+
hasActiveAttempt() {
|
|
172
|
+
const owner = ownership.getStore();
|
|
173
|
+
return owner?.kind === 'attempt' && owner.run === run && owner.run.open() && owner.attempt.open();
|
|
174
|
+
},
|
|
175
|
+
attribute(error) {
|
|
176
|
+
return attributeObservation(error, run);
|
|
177
|
+
},
|
|
178
|
+
register: lifetime.register,
|
|
179
|
+
async run(operation) {
|
|
180
|
+
return await ownership.run({ kind: 'run', run }, operation);
|
|
181
|
+
},
|
|
182
|
+
async runAttempt(testCase, attempt, operation) {
|
|
183
|
+
return await runOwnedAttempt(run, testCase, attempt, operation);
|
|
184
|
+
},
|
|
185
|
+
stop() {
|
|
186
|
+
unregister();
|
|
187
|
+
try {
|
|
188
|
+
lifetime.close();
|
|
189
|
+
}
|
|
190
|
+
finally {
|
|
191
|
+
if (!inherited) {
|
|
192
|
+
run.close();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=execution-observation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-observation.js","sourceRoot":"","sources":["../../../../source/engine/execution-observation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AA6CrD,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;AAE/E,SAAS,oBAAoB,CAAC,KAAc;IACxC,OAAO,KAAK,YAAY,iBAAiB,CAAC;AAC9C,CAAC;AAED,SAAS,wBAAwB;IAC7B,MAAM,QAAQ,GAAY,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAClE,IAAI,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjC,OAAO,QAAQ,CAAC;IACpB,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,iBAAiB,EAAoB,CAAC;IAC1D,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;IACjD,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,MAAM,SAAS,GAAG,wBAAwB,EAAE,CAAC;AAE7C,SAAS,mBAAmB,CAAC,SAAkC;IAC3D,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;QAC5C,CAAC;QACD,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,KAAK,CAAC,GAAG,CAAC,SAAS;YACf,OAAO,MAAM,SAAS,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC;QAChE,CAAC;QACD,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS;YACzC,OAAO,MAAM,eAAe,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QACpE,CAAC;QACD,IAAI;YACA,UAAU,EAAE,CAAC;YACb,IAAI,CAAC;gBACD,QAAQ,CAAC,KAAK,EAAE,CAAC;YACrB,CAAC;oBAAS,CAAC;gBACP,IAAI,CAAC,SAAS,EAAE,CAAC;oBACb,GAAG,CAAC,KAAK,EAAE,CAAC;gBAChB,CAAC;YACL,CAAC;QACL,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { BenchmarkExecutionEnvironment } from './benchmark-environment.ts';
|
|
1
2
|
import { type DefinedOutputRenderer } from './reporter-output.ts';
|
|
2
3
|
import { type DefinedReporter, type RunFacts } from './reporter.ts';
|
|
3
4
|
import type { RunResult } from './run-result.ts';
|
|
@@ -25,6 +26,14 @@ export type ExecuteOptions = {
|
|
|
25
26
|
readonly startedAt: string;
|
|
26
27
|
readonly timeoutPolicy?: ExecuteTimeoutPolicy | null;
|
|
27
28
|
};
|
|
29
|
+
type DefaultedExecuteOptions = ExecuteOptions & {
|
|
30
|
+
readonly finalizeResult: ExecuteResultFinalizer;
|
|
31
|
+
readonly outputRenderer: DefinedOutputRenderer;
|
|
32
|
+
readonly runtimePolicy: RuntimePolicy | null;
|
|
33
|
+
};
|
|
34
|
+
export type NormalizedExecuteOptions = DefaultedExecuteOptions & {
|
|
35
|
+
readonly benchmarkEnvironment: BenchmarkExecutionEnvironment | null;
|
|
36
|
+
};
|
|
28
37
|
type RuntimePolicy = NonNullable<ExecutionSupervisionDependencies['runtimePolicy']>;
|
|
29
38
|
export {};
|
|
30
39
|
//# sourceMappingURL=execution-options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-options.d.ts","sourceRoot":"","sources":["../../../../source/engine/execution-options.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"execution-options.d.ts","sourceRoot":"","sources":["../../../../source/engine/execution-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAA6B,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EAA4B,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EACR,oBAAoB,EACpB,gCAAgC,EACnC,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAwC,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;MAGzF,MAAM,gBAAgB,GAAG;IAC3B,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,WAAW,CAAC;IAC9C,QAAQ,CAAC,IAAI,EAAE,uBAAuB,CAAC;CAC1C,GAAG;IACA,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,CAAC,MAAM,EAAE,SAAS,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;AAE/E,MAAM,MAAM,cAAc,GAAG;IACzB,QAAQ,CAAC,WAAW,EAAE,eAAe,GAAG,IAAI,CAAC;IAC7C,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,QAAQ,CAAC,cAAc,CAAC,EAAE,sBAAsB,CAAC;IACjD,QAAQ,CAAC,cAAc,CAAC,EAAE,qBAAqB,CAAC;IAChD,QAAQ,CAAC,SAAS,EAAE,SAAS,eAAe,EAAE,CAAC;IAC/C,QAAQ,CAAC,cAAc,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACvD,QAAQ,CAAC,mBAAmB,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAC7D,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IAC9C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,aAAa,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACxD,CAAC;AAEF,KAAK,uBAAuB,GAAG,cAAc,GAAG;IAC5C,QAAQ,CAAC,cAAc,EAAE,sBAAsB,CAAC;IAChD,QAAQ,CAAC,cAAc,EAAE,qBAAqB,CAAC;IAC/C,QAAQ,CAAC,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,uBAAuB,GAAG;IAC7D,QAAQ,CAAC,oBAAoB,EAAE,6BAA6B,GAAG,IAAI,CAAC;CACvE,CAAC;AAEF,KAAK,aAAa,GAAG,WAAW,CAAC,gCAAgC,CAAC,eAAe,CAAC,CAAC,CAAC;AAmCpF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Clock } from '@enormora/clock';
|
|
2
|
+
import { type AsyncLeakDiagnostics } from './execution-async-leak-policy.ts';
|
|
3
|
+
import { type NormalizedExecuteOptions } from './execution-options.ts';
|
|
4
|
+
import type { ReporterDispatcher } from './reporter-dispatcher.ts';
|
|
5
|
+
export type ExecuteDependencies = {
|
|
6
|
+
readonly benchmarkEnvironment: NormalizedExecuteOptions['benchmarkEnvironment'];
|
|
7
|
+
readonly asyncLeakDiagnostics: AsyncLeakDiagnostics;
|
|
8
|
+
readonly readActiveResourceTypes: () => readonly string[];
|
|
9
|
+
readonly reporterDispatcher: ReporterDispatcher;
|
|
10
|
+
readonly wallClock: Clock;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=execution-preparation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-preparation.d.ts","sourceRoot":"","sources":["../../../../source/engine/execution-preparation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAEH,KAAK,oBACoB,EAC5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAEH,KAMK,wBAAwB,EAChC,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;MAG7D,MAAM,mBAAmB,GAAG;IAC9B,QAAQ,CAAC,oBAAoB,EAAE,wBAAwB,CAAC,sBAAsB,CAAC,CAAC;IAChF,QAAQ,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IACpD,QAAQ,CAAC,uBAAuB,EAAE,MAAM,SAAS,MAAM,EAAE,CAAC;IAC1D,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IAChD,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC;CAC7B,CAAC;OAU8B,EAK/B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createExecutionAsyncLeakMonitor } from "./execution-async-leak-policy.js";
|
|
2
|
+
import { createExecutionGlobalErrorObserver } from "./execution-global-error-observer.js";
|
|
3
|
+
import { withExecutionObservation } from "./execution-observation.js";
|
|
4
|
+
import { executeOptionsWithDefaults } from "./execution-options.js";
|
|
5
|
+
function prepareExecution(dependencies, options, testPlan) {
|
|
6
|
+
const executeOptions = executeOptionsWithDefaults(options, testPlan, dependencies.benchmarkEnvironment);
|
|
7
|
+
const asyncLeakMonitor = createExecutionAsyncLeakMonitor(dependencies.asyncLeakDiagnostics);
|
|
8
|
+
const globalErrorObserver = createExecutionGlobalErrorObserver('in-process');
|
|
9
|
+
return {
|
|
10
|
+
asyncLeakMonitor,
|
|
11
|
+
dependencies: {
|
|
12
|
+
asyncLeakMonitor,
|
|
13
|
+
globalErrorObserver,
|
|
14
|
+
...dependencies,
|
|
15
|
+
benchmarkEnvironment: executeOptions.benchmarkEnvironment,
|
|
16
|
+
runtimePolicy: executeOptions.runtimePolicy
|
|
17
|
+
},
|
|
18
|
+
globalErrorObserver,
|
|
19
|
+
options: executeOptions
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export async function withPreparedExecution(dependencies, options, testPlan, execute) {
|
|
23
|
+
return await withExecutionObservation(async function observeEngineExecution() {
|
|
24
|
+
const prepared = prepareExecution(dependencies, options, testPlan);
|
|
25
|
+
try {
|
|
26
|
+
return await execute(prepared);
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
prepared.asyncLeakMonitor.stop();
|
|
30
|
+
prepared.globalErrorObserver.stop();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=execution-preparation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-preparation.js","sourceRoot":"","sources":["../../../../source/engine/execution-preparation.ts"],"names":[],"mappings":"AACA,OAAO,EACH,+BAA+B,EAGlC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACH,kCAAkC,EAErC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EACH,0BAA0B,EAG7B,MAAM,wBAAwB,CAAC;AA2BhC,SAAS,gBAAgB,CACrB,YAAiC,EACjC,OAA6C,EAC7C,QAAkB;IAElB,MAAM,cAAc,GAAG,0BAA0B,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,CAAC,oBAAoB,CAAC,CAAC;IACxG,MAAM,gBAAgB,GAAG,+BAA+B,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAC;IAC5F,MAAM,mBAAmB,GAAG,kCAAkC,CAAC,YAAY,CAAC,CAAC;IAE7E,OAAO;QACH,gBAAgB;QAChB,YAAY,EAAE;YACV,gBAAgB;YAChB,mBAAmB;YACnB,GAAG,YAAY;YACf,oBAAoB,EAAE,cAAc,CAAC,oBAAoB;YACzD,aAAa,EAAE,cAAc,CAAC,aAAa;SAC9C;QACD,mBAAmB;QACnB,OAAO,EAAE,cAAc;KAC1B,CAAC;AACN,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACvC,YAAiC,EACjC,OAA6C,EAC7C,QAAkB,EAClB,OAAwD;IAExD,OAAO,MAAM,wBAAwB,CAAC,KAAK,UAAU,sBAAsB;QACvE,MAAM,QAAQ,GAAG,gBAAgB,CAAC,YAAY,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QACnE,IAAI,CAAC;YACD,OAAO,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;QACnC,CAAC;gBAAS,CAAC;YACP,QAAQ,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;YACjC,QAAQ,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAC;QACxC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
1
2
|
import { createStoredValue } from "../stored-value.js";
|
|
3
|
+
import { withRunnerInfrastructure } from "./execution-observation.js";
|
|
2
4
|
import { currentCaseExecutionLifecycle } from "./case-execution-lifecycle.js";
|
|
5
|
+
export function scheduleSupervisionTimeout(wallClock, callback, milliseconds) {
|
|
6
|
+
const ownedCallback = AsyncLocalStorage.bind(callback);
|
|
7
|
+
return withRunnerInfrastructure(function scheduleWatchdog() {
|
|
8
|
+
return wallClock.setTimeout(ownedCallback, milliseconds);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
3
11
|
export function createBenchmarkState() {
|
|
4
12
|
return createStoredValue(null);
|
|
5
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-supervision-state.js","sourceRoot":"","sources":["../../../../source/engine/execution-supervision-state.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"execution-supervision-state.js","sourceRoot":"","sources":["../../../../source/engine/execution-supervision-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAoB,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,6BAA6B,EAA+B,MAAM,+BAA+B,CAAC;AAM3G,MAAM,UAAU,0BAA0B,CACtC,SAAgB,EAChB,QAAoB,EACpB,YAAoB;IAEpB,MAAM,aAAa,GAAG,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvD,OAAO,wBAAwB,CAAC,SAAS,gBAAgB;QACrD,OAAO,SAAS,CAAC,UAAU,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACP,CAAC;AAGD,MAAM,UAAU,oBAAoB;IAChC,OAAO,iBAAiB,CAAkC,IAAI,CAAC,CAAC;AACpE,CAAC;AAaD,MAAM,UAAU,oBAAoB;IAChC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,aAAa,EAA2B,CAAC;IAC9E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC1C,CAAC;AAwBD,MAAM,UAAU,0BAA0B;IACtC,MAAM,WAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;IAClD,MAAM,YAAY,GAAmD,EAAE,CAAC;IACxE,IAAI,eAAe,GAAG,IAAI,CAAC;IAE3B,OAAO;QACH,SAAS,EAAE,6BAA6B,EAAE;QAC1C,eAAe;YACX,OAAO,eAAe,CAAC;QAC3B,CAAC;QACD,qBAAqB;YACjB,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,SAAS,gBAAgB,CAAC,KAAK;gBAC/D,OAAO,KAAK,CAAC,OAAO,KAAK,oBAAoB,CAAC;YAClD,CAAC,CAAC,CAAC;YACH,OAAO,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAAC;QACvD,CAAC;QACD,WAAW;QACX,aAAa,CAAC,GAAG,EAAE,UAAU;YACzB,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QACrC,CAAC;QACD,iBAAiB,CAAC,KAAK;YACnB,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;QACD,gBAAgB,CAAC,GAAG;YAChB,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;QACD,YAAY;QACZ,kBAAkB;YACd,eAAe,GAAG,KAAK,CAAC;QAC5B,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Clock } from '@enormora/clock';
|
|
2
|
-
import type { BenchmarkExecutionEnvironment } from './benchmark-
|
|
2
|
+
import type { BenchmarkExecutionEnvironment } from './benchmark-environment.ts';
|
|
3
3
|
import { type TestRuntimePolicy } from './case-execution.ts';
|
|
4
4
|
import type { ExecutionGlobalErrorObserver } from './execution-global-error-observer.ts';
|
|
5
5
|
export type ExecuteTimeoutPolicy = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-supervision.d.ts","sourceRoot":"","sources":["../../../../source/engine/execution-supervision.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"execution-supervision.d.ts","sourceRoot":"","sources":["../../../../source/engine/execution-supervision.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAIH,sBACsB,EACzB,MAAM,qBAAqB,CAAC;AAC7B,OAA0B,KASd,EAIH,4BAGiC,EAAE,MAAM,sCAAsC,CAAC;MAU/B,MAK9C,oBAAoB,GAAG;IAC/B,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;IACzC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;CACxC,CAAC;AACF,MAAM,MAAuB,gCACe,GAAG;IAC3C,QAAQ,CAAC,oBAAoB,EAAE,6BAA6B,GAAG,IAAI,CAAC;IACpE,QAAQ,CAAC,mBAAmB,EAAE,4BAA4B,CAAC;IAC3D,QAAQ,CAAC,aAAa,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAClD,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC;CAC7B,CAAC;AAiBF,MAAM,CAUiB,EAUtB,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { invalidTimeoutControlFailure, runTestCase, timeoutFailure } from "./cas
|
|
|
2
2
|
import { workIdentityKey } from "./identity.js";
|
|
3
3
|
import { singleAttemptResult, isPermissionDeniedRunnerError, verdictFromOutcome } from "./run-result.js";
|
|
4
4
|
import { findProcessBudgetBreach } from "./execution-process-budget-breach.js";
|
|
5
|
-
import { createExecutionSupervision as createExecutionSupervisionState, createBenchmarkState, createCaseCompletion } from "./execution-supervision-state.js";
|
|
5
|
+
import { createExecutionSupervision as createExecutionSupervisionState, createBenchmarkState, createCaseCompletion, scheduleSupervisionTimeout } from "./execution-supervision-state.js";
|
|
6
6
|
const microsecondsPerMillisecond = 1000;
|
|
7
7
|
export const createExecutionSupervision = createExecutionSupervisionState;
|
|
8
8
|
function createTerminalCase(testCase, verdict, durationMicroseconds, benchmark) {
|
|
@@ -206,7 +206,7 @@ async function runCaseWithSoftTimeout(input) {
|
|
|
206
206
|
return await runTestCaseWithPolicy(input);
|
|
207
207
|
}
|
|
208
208
|
const timing = { timedOut: false };
|
|
209
|
-
const softTimeout = input.dependencies.wallClock
|
|
209
|
+
const softTimeout = scheduleSupervisionTimeout(input.dependencies.wallClock, function abortTimedOutCase() {
|
|
210
210
|
timing.timedOut = true;
|
|
211
211
|
input.controller.abort();
|
|
212
212
|
}, input.timeoutMilliseconds);
|
|
@@ -230,7 +230,7 @@ function registerActiveCase(input) {
|
|
|
230
230
|
const startedAtMicroseconds = Number(input.dependencies.wallClock.currentMonotonicMicroseconds);
|
|
231
231
|
const hardTimeout = input.timeoutPolicy === null || input.timeoutPolicy === undefined
|
|
232
232
|
? null
|
|
233
|
-
: input.dependencies.wallClock
|
|
233
|
+
: scheduleSupervisionTimeout(input.dependencies.wallClock, function hardTimeoutActiveCases() {
|
|
234
234
|
completeActiveCasesWithCrash(input.supervision, input.dependencies);
|
|
235
235
|
}, input.timeoutPolicy.hardTimeoutMilliseconds);
|
|
236
236
|
const activeCase = {
|