@usearazzo/runner 1.0.1-alpha.34 → 1.0.1-alpha.35

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 (44) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +6 -1
  3. package/dist/arazzo-runner.browser.js +687 -317
  4. package/dist/arazzo-runner.browser.min.js +1 -1
  5. package/package.json +52 -7
  6. package/src/errors/ExecutionError.cjs +2 -0
  7. package/src/errors/ExecutionError.mjs +2 -0
  8. package/src/executor/OpenAPIOperationExecutor.cjs +58 -47
  9. package/src/executor/OpenAPIOperationExecutor.mjs +58 -47
  10. package/src/executor/WorkflowExecutor.cjs +302 -160
  11. package/src/executor/WorkflowExecutor.mjs +302 -160
  12. package/src/index.cjs +14 -0
  13. package/src/index.mjs +2 -0
  14. package/src/observability/EventChannel.cjs +30 -20
  15. package/src/observability/EventChannel.mjs +30 -23
  16. package/src/observability/Redactor.cjs +7 -5
  17. package/src/observability/Redactor.mjs +7 -5
  18. package/src/observability/combineObservers.cjs +18 -0
  19. package/src/observability/combineObservers.mjs +12 -0
  20. package/src/observability/instrument.cjs +159 -0
  21. package/src/observability/instrument.mjs +144 -0
  22. package/src/observability/logging/LoggingObserver.cjs +177 -0
  23. package/src/observability/logging/LoggingObserver.mjs +172 -0
  24. package/src/observability/logging/index.cjs +13 -0
  25. package/src/observability/logging/index.mjs +1 -0
  26. package/src/observability/opentelemetry/ArazzoRunnerInstrumentation.cjs +321 -0
  27. package/src/observability/opentelemetry/ArazzoRunnerInstrumentation.mjs +313 -0
  28. package/src/observability/opentelemetry/index.cjs +13 -0
  29. package/src/observability/opentelemetry/index.mjs +1 -0
  30. package/src/observability/stream/EventStream.cjs +112 -0
  31. package/src/observability/stream/EventStream.mjs +107 -0
  32. package/src/observability/stream/index.cjs +13 -0
  33. package/src/observability/stream/index.mjs +1 -0
  34. package/src/registry/DocumentRegistry.cjs +14 -9
  35. package/src/registry/DocumentRegistry.mjs +14 -9
  36. package/src/version.cjs +9 -0
  37. package/src/version.mjs +3 -0
  38. package/types/observability/logging/LoggingObserver.d.ts +82 -0
  39. package/types/observability/logging/index.d.ts +2 -0
  40. package/types/observability/opentelemetry/ArazzoRunnerInstrumentation.d.ts +84 -0
  41. package/types/observability/opentelemetry/index.d.ts +2 -0
  42. package/types/observability/stream/EventStream.d.ts +68 -0
  43. package/types/observability/stream/index.d.ts +2 -0
  44. package/types/runner.d.ts +131 -34
@@ -11291,6 +11291,8 @@ class ExecutionError extends _ArazzoRunnerError_ts__WEBPACK_IMPORTED_MODULE_0__[
11291
11291
  static GotoTargetMissing = 'goto-target-missing';
11292
11292
  /** A `goto` action's `stepId` names no step in the workflow. */
11293
11293
  static GotoTargetNotFound = 'goto-target-not-found';
11294
+ /** A process-wide instrumentation wrap (see `instrument`) settled without running its workflow or step. */
11295
+ static InstrumentationWrap = 'instrumentation-wrap';
11294
11296
  /** An `operationId` or `operationPath` is not a valid operation reference. */
11295
11297
  static InvalidOperationReference = 'invalid-operation-reference';
11296
11298
  /** A `workflowId` is not a valid `$sourceDescriptions.{name}.{workflowId}` expression. */
@@ -11908,6 +11910,7 @@ class OpenAPIOperationExecutor {
11908
11910
  #operationNormalizer;
11909
11911
  #documentAssembler;
11910
11912
  #captureBodies;
11913
+ // emits only while `hasObservers`, so an unobserved block builds no events
11911
11914
  #events;
11912
11915
  constructor(options = {}) {
11913
11916
  this.#httpClient = options.httpClient ?? _client_HTTPClientFetch_ts__WEBPACK_IMPORTED_MODULE_10__["default"];
@@ -11916,7 +11919,7 @@ class OpenAPIOperationExecutor {
11916
11919
  this.#operationExtractor = options.operationExtractor ?? new _extractor_OpenAPIOperationExtractor_ts__WEBPACK_IMPORTED_MODULE_12__["default"]();
11917
11920
  this.#operationNormalizer = options.operationNormalizer ?? new _normalizer_OpenAPIOperationNormalizer_ts__WEBPACK_IMPORTED_MODULE_13__["default"]();
11918
11921
  this.#documentAssembler = options.documentAssembler ?? new _assembler_OpenAPIDocumentAssembler_ts__WEBPACK_IMPORTED_MODULE_14__["default"]();
11919
- this.#events = _observability_EventChannel_ts__WEBPACK_IMPORTED_MODULE_16__["default"].open({
11922
+ this.#events = new _observability_EventChannel_ts__WEBPACK_IMPORTED_MODULE_16__["default"]({
11920
11923
  observer: options.observer,
11921
11924
  now: options.now
11922
11925
  });
@@ -11976,26 +11979,32 @@ class OpenAPIOperationExecutor {
11976
11979
  }
11977
11980
  })
11978
11981
  };
11979
- this.#events?.emit({
11980
- type: 'openapi-operation-normalize-start',
11981
- ...context,
11982
- runId,
11983
- location: location()
11984
- });
11982
+ if (this.#events.hasObservers) {
11983
+ this.#events.emit({
11984
+ type: 'openapi:operation:normalize:start',
11985
+ ...context,
11986
+ runId,
11987
+ location: location()
11988
+ });
11989
+ }
11985
11990
  const normalizedOperation = await this.#operationNormalizer.normalize(operation, locator.document);
11986
- this.#events?.emit({
11987
- type: 'openapi-operation-normalize-settled',
11988
- ...context,
11989
- runId,
11990
- location: location()
11991
- });
11991
+ if (this.#events.hasObservers) {
11992
+ this.#events.emit({
11993
+ type: 'openapi:operation:normalize:settled',
11994
+ ...context,
11995
+ runId,
11996
+ location: location()
11997
+ });
11998
+ }
11992
11999
  const assembled = this.#documentAssembler.assemble(normalizedOperation, locator.document);
11993
- this.#events?.emit({
11994
- type: 'openapi-operation-assembled',
11995
- ...context,
11996
- runId,
11997
- location: location()
11998
- });
12000
+ if (this.#events.hasObservers) {
12001
+ this.#events.emit({
12002
+ type: 'openapi:operation:assembled',
12003
+ ...context,
12004
+ runId,
12005
+ location: location()
12006
+ });
12007
+ }
11999
12008
  const rest = (0,ramda__WEBPACK_IMPORTED_MODULE_0__["default"])(['requestInterceptor', 'step', 'runId', 'operationId', 'operationPath', 'userFetch', 'responseInterceptor'], executeOptions);
12000
12009
 
12001
12010
  // each step derives the next options rather than editing in place
@@ -12040,20 +12049,22 @@ class OpenAPIOperationExecutor {
12040
12049
  },
12041
12050
  body: request.body
12042
12051
  };
12043
- this.#events?.emit({
12044
- type: 'openapi-operation-request-start',
12045
- ...context,
12046
- runId,
12047
- location: location(),
12048
- request: {
12049
- method: request.method,
12050
- url: request.url,
12051
- headers: request.headers,
12052
- ...(this.#captureBodies ? {
12053
- body: request.body
12054
- } : {})
12055
- }
12056
- });
12052
+ if (this.#events.hasObservers) {
12053
+ this.#events.emit({
12054
+ type: 'openapi:operation:request:start',
12055
+ ...context,
12056
+ runId,
12057
+ location: location(),
12058
+ request: {
12059
+ method: request.method,
12060
+ url: request.url,
12061
+ headers: request.headers,
12062
+ ...(this.#captureBodies ? {
12063
+ body: request.body
12064
+ } : {})
12065
+ }
12066
+ });
12067
+ }
12057
12068
  let rawResponse;
12058
12069
  try {
12059
12070
  rawResponse = await this.#httpClient(request);
@@ -12064,20 +12075,22 @@ class OpenAPIOperationExecutor {
12064
12075
  });
12065
12076
  }
12066
12077
  const response = await this.#responseNormalizer.normalize(rawResponse, requestInfo);
12067
- this.#events?.emit({
12068
- type: 'openapi-operation-request-settled',
12069
- ...context,
12070
- runId,
12071
- location: location(),
12072
- response: {
12073
- status: response.status,
12074
- headers: response.headers,
12075
- size: response.size,
12076
- ...(this.#captureBodies ? {
12077
- body: response.body
12078
- } : {})
12079
- }
12080
- });
12078
+ if (this.#events.hasObservers) {
12079
+ this.#events.emit({
12080
+ type: 'openapi:operation:request:settled',
12081
+ ...context,
12082
+ runId,
12083
+ location: location(),
12084
+ response: {
12085
+ status: response.status,
12086
+ headers: response.headers,
12087
+ size: response.size,
12088
+ ...(this.#captureBodies ? {
12089
+ body: response.body
12090
+ } : {})
12091
+ }
12092
+ });
12093
+ }
12081
12094
  return response;
12082
12095
  }
12083
12096
 
@@ -13872,11 +13885,13 @@ __webpack_require__.r(__webpack_exports__);
13872
13885
  /* harmony import */ var _ArazzoWorkflowLocatorNormalizer_ts__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(98885);
13873
13886
  /* harmony import */ var _StepRetryRunner_ts__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(18760);
13874
13887
  /* harmony import */ var _WorkflowCallStack_ts__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(64661);
13875
- /* harmony import */ var _StepTransitionInterpreter_ts__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(2835);
13876
- /* harmony import */ var _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(17658);
13877
- /* harmony import */ var _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(8696);
13878
- /* harmony import */ var _abort_ts__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(99628);
13879
- /* harmony import */ var _observability_EventChannel_ts__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(12993);
13888
+ /* harmony import */ var _observability_instrument_ts__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(21327);
13889
+ /* harmony import */ var _StepTransitionInterpreter_ts__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(2835);
13890
+ /* harmony import */ var _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(17658);
13891
+ /* harmony import */ var _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(8696);
13892
+ /* harmony import */ var _abort_ts__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(99628);
13893
+ /* harmony import */ var _observability_EventChannel_ts__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(12993);
13894
+
13880
13895
 
13881
13896
 
13882
13897
 
@@ -13969,6 +13984,12 @@ function settledResult(result) {
13969
13984
  * @internal
13970
13985
  */
13971
13986
 
13987
+ /**
13988
+ * How a step ran: its last attempt's outcome, the terminal action its retries
13989
+ * resolved to, how many attempts it took, and where the run goes next.
13990
+ * @internal
13991
+ */
13992
+
13972
13993
  /**
13973
13994
  * One completed `dependsOn` run, remembered with the inputs it was actually
13974
13995
  * given — see {@link RunScope.dependencyRuns}.
@@ -14063,8 +14084,9 @@ class WorkflowExecutor {
14063
14084
  #parameterResolver = new _resolver_WorkflowParameterResolver_ts__WEBPACK_IMPORTED_MODULE_9__["default"]();
14064
14085
  #stepExecutor;
14065
14086
  #retryRunner;
14066
- #interpreter = new _StepTransitionInterpreter_ts__WEBPACK_IMPORTED_MODULE_15__["default"]();
14087
+ #interpreter = new _StepTransitionInterpreter_ts__WEBPACK_IMPORTED_MODULE_16__["default"]();
14067
14088
  #workflowLocatorNormalizer;
14089
+ // emits only while `hasObservers`, so an unobserved block builds no events
14068
14090
  #events;
14069
14091
  constructor(options) {
14070
14092
  this.#document = options.document;
@@ -14074,7 +14096,7 @@ class WorkflowExecutor {
14074
14096
  this.#maxSteps = options.maxSteps ?? WorkflowExecutor.#DEFAULT_MAX_STEPS;
14075
14097
  this.#maxWorkflowDepth = options.maxWorkflowDepth ?? WorkflowExecutor.#DEFAULT_MAX_WORKFLOW_DEPTH;
14076
14098
  this.#now = options.now ?? WorkflowExecutor.#DEFAULT_NOW;
14077
- this.#events = _observability_EventChannel_ts__WEBPACK_IMPORTED_MODULE_19__["default"].open({
14099
+ this.#events = new _observability_EventChannel_ts__WEBPACK_IMPORTED_MODULE_20__["default"]({
14078
14100
  observer: options.observer,
14079
14101
  now: this.#now
14080
14102
  });
@@ -14145,20 +14167,20 @@ class WorkflowExecutor {
14145
14167
  #executeOptionsByName(executeOptions) {
14146
14168
  const byName = new Map();
14147
14169
  const fail = (name, problem, reason) => {
14148
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`executeOptions is keyed by source description name, and "${name}" ${problem}`, {
14170
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"](`executeOptions is keyed by source description name, and "${name}" ${problem}`, {
14149
14171
  reason
14150
14172
  });
14151
14173
  };
14152
14174
  for (const [name, options] of Object.entries(executeOptions)) {
14153
14175
  const uri = this.#document.resolveSourceDescriptionURI(name);
14154
14176
  if (uri === undefined) {
14155
- return fail(name, `names no source description with a url in the Arazzo document at "${this.#document.uri}"`, _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].SourceDescriptionNotFound);
14177
+ return fail(name, `names no source description with a url in the Arazzo document at "${this.#document.uri}"`, _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].SourceDescriptionNotFound);
14156
14178
  }
14157
14179
  if (this.#document.resolveSourceDescriptionField(name, 'type') === 'arazzo') {
14158
- fail(name, 'names an Arazzo document', _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].SourceDescriptionNotOpenAPI);
14180
+ fail(name, 'names an Arazzo document', _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].SourceDescriptionNotOpenAPI);
14159
14181
  }
14160
14182
  if (!(0,ramda_adjunct__WEBPACK_IMPORTED_MODULE_1__["default"])(options)) {
14161
- fail(name, 'is not given an object of options', _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].UnknownExecuteOption);
14183
+ fail(name, 'is not given an object of options', _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].UnknownExecuteOption);
14162
14184
  }
14163
14185
  byName.set(name, {
14164
14186
  uri,
@@ -14180,9 +14202,9 @@ class WorkflowExecutor {
14180
14202
  const configuring = [...entries].filter(([, entry]) => entry.uri === locator.document.uri);
14181
14203
  if (configuring.length > 1) {
14182
14204
  const names = configuring.map(([name]) => `"${name}"`).join(', ');
14183
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`Step "${step.stepId}" has no executeOptions entry of its own, and ${names} all configure "${locator.document.uri}", the document it calls`, {
14205
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"](`Step "${step.stepId}" has no executeOptions entry of its own, and ${names} all configure "${locator.document.uri}", the document it calls`, {
14184
14206
  ...step,
14185
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].AmbiguousExecuteOptions
14207
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].AmbiguousExecuteOptions
14186
14208
  });
14187
14209
  }
14188
14210
  return configuring[0]?.[1].options;
@@ -14201,8 +14223,8 @@ class WorkflowExecutor {
14201
14223
  #rejectUnknownOptions(options) {
14202
14224
  const unknown = Object.keys(options).filter(key => !WorkflowExecutor.#EXECUTE_OPTION_KEYS.has(key));
14203
14225
  if (unknown.length === 0) return;
14204
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`execute received unknown option(s) ${unknown.join(', ')}; it takes (workflowId, { inputs, executeOptions, dependencyInputs, runDependencies, signal }) — workflow inputs go under "inputs"`, {
14205
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].UnknownExecuteOption
14226
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"](`execute received unknown option(s) ${unknown.join(', ')}; it takes (workflowId, { inputs, executeOptions, dependencyInputs, runDependencies, signal }) — workflow inputs go under "inputs"`, {
14227
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].UnknownExecuteOption
14206
14228
  });
14207
14229
  }
14208
14230
 
@@ -14228,7 +14250,7 @@ class WorkflowExecutor {
14228
14250
  // run cancelled before any step — or between a prerequisite and the workflow
14229
14251
  // that needed it — must not go on to normalize and enter a workflow nobody
14230
14252
  // is waiting for.
14231
- (0,_abort_ts__WEBPACK_IMPORTED_MODULE_18__.throwIfAborted)(scope.signal, {
14253
+ (0,_abort_ts__WEBPACK_IMPORTED_MODULE_19__.throwIfAborted)(scope.signal, {
14232
14254
  workflowId,
14233
14255
  callStack: nested
14234
14256
  });
@@ -14237,29 +14259,81 @@ class WorkflowExecutor {
14237
14259
  workflowId,
14238
14260
  path: nested.path
14239
14261
  };
14240
- // extracted before `workflow-start`: a workflow its document does not
14262
+ // extracted before `workflow:start`: a workflow its document does not
14241
14263
  // define never starts, and the event can say where the one it runs is.
14242
14264
  const extracted = this.#extractWorkflow(locator);
14243
- // emitted before normalization, so its events nest inside this workflow's.
14244
- this.#events?.emit({
14245
- type: 'workflow-start',
14246
- ...frame,
14247
- via,
14248
- location: locator.document.locationOf(extracted)
14249
- }, startedAt);
14250
- const workflow = await this.#resolveWorkflow(locator, extracted, scope, frame);
14251
- const state = new _state_WorkflowExecutionState_ts__WEBPACK_IMPORTED_MODULE_10__["default"]({
14252
- inputs
14253
- });
14265
+ const location = locator.document.locationOf(extracted);
14254
14266
  const invocation = {
14255
14267
  workflowId,
14256
14268
  document: locator.document,
14257
- state,
14269
+ state: new _state_WorkflowExecutionState_ts__WEBPACK_IMPORTED_MODULE_10__["default"]({
14270
+ inputs
14271
+ }),
14258
14272
  callStack: nested,
14259
14273
  via,
14260
14274
  frame
14261
14275
  };
14262
14276
 
14277
+ // traced from its `workflow:start` to its `workflow:settled`, so a span an
14278
+ // instrumentation opens around it is active for all of its events.
14279
+ return (0,_observability_instrument_ts__WEBPACK_IMPORTED_MODULE_15__.traced)(() => ({
14280
+ kind: 'workflow',
14281
+ ...frame,
14282
+ via,
14283
+ location
14284
+ }), async () => {
14285
+ // a started workflow always settles, a throwing one included (an
14286
+ // observer throwing on its start too), so an observer holding it open
14287
+ // (a span, a stream consumer) can close it.
14288
+ let result;
14289
+ try {
14290
+ // emitted before normalization, so its events nest inside this workflow's.
14291
+ if (this.#events.hasObservers) {
14292
+ this.#events.emit({
14293
+ type: 'workflow:start',
14294
+ ...frame,
14295
+ via,
14296
+ location
14297
+ }, startedAt);
14298
+ }
14299
+ result = await this.#runInvocation(locator, extracted, invocation, scope, startedAt);
14300
+ } catch (error) {
14301
+ this.#settleThrown({
14302
+ type: 'workflow:settled',
14303
+ ...frame,
14304
+ status: 'failed',
14305
+ settledStatus: 'failed',
14306
+ outputs: {},
14307
+ error
14308
+ });
14309
+ throw error;
14310
+ }
14311
+ if (this.#events.hasObservers) {
14312
+ this.#events.emit({
14313
+ type: 'workflow:settled',
14314
+ ...frame,
14315
+ status: result.status,
14316
+ settledStatus: result.settledStatus,
14317
+ outputs: result.outputs
14318
+ }, startedAt + result.durationMs);
14319
+ }
14320
+ return result;
14321
+ });
14322
+ }
14323
+
14324
+ /**
14325
+ * The part of {@link WorkflowExecutor.#run} after `workflow:start`:
14326
+ * normalizes the workflow, checks its definition, runs its dependencies
14327
+ * and its steps, and builds its result.
14328
+ */
14329
+ async #runInvocation(locator, extracted, invocation, scope, startedAt) {
14330
+ const {
14331
+ workflowId,
14332
+ callStack: nested,
14333
+ frame
14334
+ } = invocation;
14335
+ const workflow = await this.#resolveWorkflow(locator, extracted, scope, frame);
14336
+
14263
14337
  // validated before any prerequisite runs: a malformed `steps` is an
14264
14338
  // authoring error, and discovering it only after the dependencies have
14265
14339
  // fired would mean live side effects on the way to a throw.
@@ -14291,7 +14365,7 @@ class WorkflowExecutor {
14291
14365
  // result carrying the dependency trace, not a throw — and none of its own
14292
14366
  // steps run. Unless the run was cancelled, in which case the prerequisite
14293
14367
  // did not fail on its own terms either.
14294
- (0,_abort_ts__WEBPACK_IMPORTED_MODULE_18__.throwIfAborted)(scope.signal, {
14368
+ (0,_abort_ts__WEBPACK_IMPORTED_MODULE_19__.throwIfAborted)(scope.signal, {
14295
14369
  workflowId,
14296
14370
  callStack: nested
14297
14371
  });
@@ -14312,103 +14386,23 @@ class WorkflowExecutor {
14312
14386
  stepLoop: while (index < steps.length) {
14313
14387
  const step = steps[index];
14314
14388
  const stepId = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(step.stepId);
14315
- const stepStartedAt = this.#now();
14316
- // the sub-workflow runs this step produces — one per attempt, so a retried
14317
- // sub-workflow step keeps every attempt's trace rather than only the last.
14318
- const subWorkflows = [];
14319
- // the retry reference runs this step's attempts produced, one per firing —
14320
- // separate from `subWorkflows` because a reference belongs to the retry
14321
- // that invoked it, not to the step's own target.
14322
- const retryReferences = [];
14323
- const stepFrame = {
14324
- ...frame,
14325
- stepId
14326
- };
14327
- this.#events?.emit({
14328
- type: 'step-start',
14329
- ...stepFrame,
14330
- location: invocation.document.locationOf(step)
14331
- }, stepStartedAt);
14332
- const attempt = this.#chargedAttempt(this.#observedAttempt(this.#stepAttempt(step, stepId, invocation, scope, subWorkflows), stepFrame), invocation, scope, stepId);
14333
-
14334
- // the retry runner settles any `retry` actions, so `action` is the terminal
14335
- // action a retry chain resolved to and `attempts` is how many times the step
14336
- // ran.
14337
14389
  const {
14338
14390
  outcome,
14339
14391
  action,
14340
- attempts
14341
- } = await this.#retryRunner.run(attempt, {
14392
+ transition
14393
+ } = await (0,_observability_instrument_ts__WEBPACK_IMPORTED_MODULE_15__.traced)(() => ({
14394
+ kind: 'step',
14395
+ ...frame,
14342
14396
  stepId,
14343
- workflowId,
14344
- signal: scope.signal,
14345
- runReference: this.#retryReference(steps, stepFrame, invocation, scope, retryReferences),
14346
- onRetry: (retry, delayMs, attempt) => {
14347
- const decided = {
14348
- ...stepFrame,
14349
- attempt
14350
- };
14351
- this.#events?.emit({
14352
- type: 'action-selected',
14353
- ...decided,
14354
- action: retry,
14355
- transition: {
14356
- kind: 'retry'
14357
- },
14358
- location: invocation.document.locationOf(retry)
14359
- });
14360
- if (delayMs > 0) {
14361
- this.#events?.emit({
14362
- type: 'retry-wait',
14363
- ...decided,
14364
- delayMs
14365
- });
14366
- }
14367
- }
14368
- });
14369
- const transition = this.#interpreter.interpret(action, outcome.successful, {
14370
- workflowId,
14371
- stepId
14372
- });
14373
- this.#events?.emit({
14374
- type: 'action-selected',
14375
- ...stepFrame,
14376
- attempt: attempts,
14377
- action,
14378
- transition,
14379
- location: action === undefined ? undefined : invocation.document.locationOf(action)
14380
- });
14381
- state.setStepOutputs(outcome.stepId, outcome.outputs);
14382
- const stepSettledAt = this.#now();
14383
- trace.push({
14384
- stepId: outcome.stepId,
14385
- location: invocation.document.locationOf(step),
14386
- successful: outcome.successful,
14387
- action,
14388
- attempts,
14389
- durationMs: stepSettledAt - stepStartedAt,
14390
- successCriteria: outcome.successCriteria,
14391
- actionCriteria: outcome.actionCriteria,
14392
- ...(subWorkflows.length > 0 ? {
14393
- subWorkflows
14394
- } : {}),
14395
- ...(retryReferences.length > 0 ? {
14396
- retryReferences
14397
- } : {})
14398
- });
14399
- this.#events?.emit({
14400
- type: 'step-settled',
14401
- ...stepFrame,
14402
- successful: outcome.successful,
14403
- attempts
14404
- }, stepSettledAt);
14397
+ location: invocation.document.locationOf(step)
14398
+ }), () => this.#runStep(step, stepId, steps, invocation, scope, trace));
14405
14399
  switch (transition.kind) {
14406
14400
  case 'next':
14407
14401
  index += 1;
14408
14402
  break;
14409
14403
  case 'goto':
14410
14404
  index = this.#interpreter.indexOfStep(steps, transition.stepId, workflowId, {
14411
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].GotoTargetNotFound,
14405
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].GotoTargetNotFound,
14412
14406
  label: 'goto target'
14413
14407
  });
14414
14408
  break;
@@ -14421,7 +14415,7 @@ class WorkflowExecutor {
14421
14415
  // resolution, so an aborted run reports `aborted` rather than
14422
14416
  // whatever resolving the target (a malformed reference, a missing
14423
14417
  // source) would have thrown.
14424
- (0,_abort_ts__WEBPACK_IMPORTED_MODULE_18__.throwIfAborted)(scope.signal, {
14418
+ (0,_abort_ts__WEBPACK_IMPORTED_MODULE_19__.throwIfAborted)(scope.signal, {
14425
14419
  workflowId,
14426
14420
  stepId,
14427
14421
  callStack: nested
@@ -14452,10 +14446,10 @@ class WorkflowExecutor {
14452
14446
  // loudly — `transition` is provably `never` once every kind above
14453
14447
  // has its own case, which TypeScript checks at compile time.
14454
14448
  const unreachable = transition;
14455
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`step "${stepId}" in workflow "${workflowId}" produced an unrecognized transition ${JSON.stringify(unreachable)}`, {
14449
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"](`step "${stepId}" in workflow "${workflowId}" produced an unrecognized transition ${JSON.stringify(unreachable)}`, {
14456
14450
  workflowId,
14457
14451
  stepId,
14458
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].UnknownTransitionKind
14452
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].UnknownTransitionKind
14459
14453
  });
14460
14454
  }
14461
14455
  }
@@ -14467,13 +14461,166 @@ class WorkflowExecutor {
14467
14461
  // transport, since one honoring the signal fails the request instead.
14468
14462
  // Cancellation must not be the one outcome that reads differently for the
14469
14463
  // last step than for every step before it.
14470
- ;(0,_abort_ts__WEBPACK_IMPORTED_MODULE_18__.throwIfAborted)(scope.signal, {
14464
+ ;(0,_abort_ts__WEBPACK_IMPORTED_MODULE_19__.throwIfAborted)(scope.signal, {
14471
14465
  workflowId,
14472
14466
  callStack: nested
14473
14467
  });
14474
14468
  return this.#result(invocation, workflow, trace, runOutcome, dependencies, startedAt);
14475
14469
  }
14476
14470
 
14471
+ /**
14472
+ * Emits the settled event of a workflow or step that threw. An observer
14473
+ * throwing on it is ignored: the error that failed the operation is the one
14474
+ * to report.
14475
+ */
14476
+ #settleThrown(event) {
14477
+ if (!this.#events.hasObservers) return;
14478
+ try {
14479
+ this.#events.emit(event);
14480
+ } catch {
14481
+ // the operation's own error is rethrown by the caller
14482
+ }
14483
+ }
14484
+
14485
+ /**
14486
+ * Runs one step of a workflow invocation, from its `step:start` to its
14487
+ * `step:settled`, recording it in `trace` and its outputs in the state. A
14488
+ * step that throws still settles, so an observer holding it open can close
14489
+ * it.
14490
+ */
14491
+ async #runStep(step, stepId, steps, invocation, scope, trace) {
14492
+ const {
14493
+ workflowId,
14494
+ frame,
14495
+ state
14496
+ } = invocation;
14497
+ const stepStartedAt = this.#now();
14498
+ // the sub-workflow runs this step produces — one per attempt, so a retried
14499
+ // sub-workflow step keeps every attempt's trace rather than only the last.
14500
+ const subWorkflows = [];
14501
+ // the retry reference runs this step's attempts produced, one per firing —
14502
+ // separate from `subWorkflows` because a reference belongs to the retry
14503
+ // that invoked it, not to the step's own target.
14504
+ const retryReferences = [];
14505
+ const stepFrame = {
14506
+ ...frame,
14507
+ stepId
14508
+ };
14509
+ // the attempt reached, once past its boundary checks and before its
14510
+ // step:attempt: an attempt announced is an attempt counted
14511
+ let attempted = 0;
14512
+ const countAttempt = runAttempt => attempt => {
14513
+ attempted = attempt;
14514
+ return runAttempt(attempt);
14515
+ };
14516
+ let settled;
14517
+ try {
14518
+ if (this.#events.hasObservers) {
14519
+ this.#events.emit({
14520
+ type: 'step:start',
14521
+ ...stepFrame,
14522
+ location: invocation.document.locationOf(step)
14523
+ }, stepStartedAt);
14524
+ }
14525
+ const attempt = this.#chargedAttempt(countAttempt(this.#observedAttempt(this.#stepAttempt(step, stepId, invocation, scope, subWorkflows), stepFrame)), invocation, scope, stepId);
14526
+
14527
+ // the retry runner settles any `retry` actions, so `action` is the terminal
14528
+ // action a retry chain resolved to and `attempts` is how many times the step
14529
+ // ran.
14530
+ const {
14531
+ outcome,
14532
+ action,
14533
+ attempts
14534
+ } = await this.#retryRunner.run(attempt, {
14535
+ stepId,
14536
+ workflowId,
14537
+ signal: scope.signal,
14538
+ runReference: this.#retryReference(steps, stepFrame, invocation, scope, retryReferences),
14539
+ onRetry: (retry, delayMs, attempt) => {
14540
+ const decided = {
14541
+ ...stepFrame,
14542
+ attempt
14543
+ };
14544
+ if (this.#events.hasObservers) {
14545
+ this.#events.emit({
14546
+ type: 'action:selected',
14547
+ ...decided,
14548
+ action: retry,
14549
+ transition: {
14550
+ kind: 'retry'
14551
+ },
14552
+ location: invocation.document.locationOf(retry)
14553
+ });
14554
+ }
14555
+ if (delayMs > 0 && this.#events.hasObservers) {
14556
+ this.#events.emit({
14557
+ type: 'retry:wait',
14558
+ ...decided,
14559
+ delayMs
14560
+ });
14561
+ }
14562
+ }
14563
+ });
14564
+ const transition = this.#interpreter.interpret(action, outcome.successful, {
14565
+ workflowId,
14566
+ stepId
14567
+ });
14568
+ if (this.#events.hasObservers) {
14569
+ this.#events.emit({
14570
+ type: 'action:selected',
14571
+ ...stepFrame,
14572
+ attempt: attempts,
14573
+ action,
14574
+ transition,
14575
+ location: action === undefined ? undefined : invocation.document.locationOf(action)
14576
+ });
14577
+ }
14578
+ state.setStepOutputs(outcome.stepId, outcome.outputs);
14579
+ const stepSettledAt = this.#now();
14580
+ trace.push({
14581
+ stepId: outcome.stepId,
14582
+ location: invocation.document.locationOf(step),
14583
+ successful: outcome.successful,
14584
+ action,
14585
+ attempts,
14586
+ durationMs: stepSettledAt - stepStartedAt,
14587
+ successCriteria: outcome.successCriteria,
14588
+ actionCriteria: outcome.actionCriteria,
14589
+ ...(subWorkflows.length > 0 ? {
14590
+ subWorkflows
14591
+ } : {}),
14592
+ ...(retryReferences.length > 0 ? {
14593
+ retryReferences
14594
+ } : {})
14595
+ });
14596
+ settled = {
14597
+ outcome,
14598
+ action,
14599
+ transition,
14600
+ attempts,
14601
+ settledAt: stepSettledAt
14602
+ };
14603
+ } catch (error) {
14604
+ this.#settleThrown({
14605
+ type: 'step:settled',
14606
+ ...stepFrame,
14607
+ successful: false,
14608
+ attempts: attempted,
14609
+ error
14610
+ });
14611
+ throw error;
14612
+ }
14613
+ if (this.#events.hasObservers) {
14614
+ this.#events.emit({
14615
+ type: 'step:settled',
14616
+ ...stepFrame,
14617
+ successful: settled.outcome.successful,
14618
+ attempts: settled.attempts
14619
+ }, settled.settledAt);
14620
+ }
14621
+ return settled;
14622
+ }
14623
+
14477
14624
  /**
14478
14625
  * Assembles the run's result from how it ended, resolving the workflow's
14479
14626
  * `outputs` against the final state (unless it transferred) and stamping
@@ -14516,13 +14663,6 @@ class WorkflowExecutor {
14516
14663
  status: outcome.status,
14517
14664
  settledStatus: outcome.status
14518
14665
  };
14519
- this.#events?.emit({
14520
- type: 'workflow-settled',
14521
- ...invocation.frame,
14522
- status: result.status,
14523
- settledStatus: result.settledStatus,
14524
- outputs: result.outputs
14525
- }, settledAt);
14526
14666
  return result;
14527
14667
  }
14528
14668
 
@@ -14546,10 +14686,10 @@ class WorkflowExecutor {
14546
14686
  */
14547
14687
  #chargeBudget(scope, invocation, stepId) {
14548
14688
  if (++scope.budget.spent <= this.#maxSteps) return;
14549
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`workflow "${invocation.workflowId}" exceeded its budget of ${this.#maxSteps} step attempts (a goto loop, excessive retries, or runaway sub-workflow calls)`, {
14689
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"](`workflow "${invocation.workflowId}" exceeded its budget of ${this.#maxSteps} step attempts (a goto loop, excessive retries, or runaway sub-workflow calls)`, {
14550
14690
  workflowId: invocation.workflowId,
14551
14691
  stepId,
14552
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].StepBudget,
14692
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].StepBudget,
14553
14693
  path: invocation.callStack.path
14554
14694
  });
14555
14695
  }
@@ -14572,7 +14712,7 @@ class WorkflowExecutor {
14572
14712
  callStack
14573
14713
  } = invocation;
14574
14714
  return async attempt => {
14575
- (0,_abort_ts__WEBPACK_IMPORTED_MODULE_18__.throwIfAborted)(scope.signal, {
14715
+ (0,_abort_ts__WEBPACK_IMPORTED_MODULE_19__.throwIfAborted)(scope.signal, {
14576
14716
  workflowId,
14577
14717
  stepId,
14578
14718
  callStack
@@ -14581,7 +14721,7 @@ class WorkflowExecutor {
14581
14721
  try {
14582
14722
  return await runAttempt(attempt);
14583
14723
  } catch (error) {
14584
- ;(0,_abort_ts__WEBPACK_IMPORTED_MODULE_18__.throwIfAborted)(scope.signal, {
14724
+ ;(0,_abort_ts__WEBPACK_IMPORTED_MODULE_19__.throwIfAborted)(scope.signal, {
14585
14725
  workflowId,
14586
14726
  stepId,
14587
14727
  callStack
@@ -14592,26 +14732,26 @@ class WorkflowExecutor {
14592
14732
  }
14593
14733
 
14594
14734
  /**
14595
- * Wraps a step-attempt thunk with the events of an attempt: `step-attempt`
14596
- * as it begins, then a `criterion-evaluated` for each criterion it
14735
+ * Wraps a step-attempt thunk with the events of an attempt: `step:attempt`
14736
+ * as it begins, then a `criterion:evaluated` for each criterion it
14597
14737
  * evaluated, success criteria first.
14598
14738
  */
14599
14739
  #observedAttempt(runAttempt, stepFrame) {
14600
- const events = this.#events;
14601
- if (events === undefined) return runAttempt;
14740
+ // observers read per attempt, so hooks added mid-step apply from its next one
14602
14741
  return async attempt => {
14603
14742
  const attemptFrame = {
14604
14743
  ...stepFrame,
14605
14744
  attempt
14606
14745
  };
14607
- events.emit({
14608
- type: 'step-attempt',
14746
+ if (this.#events.hasObservers) this.#events.emit({
14747
+ type: 'step:attempt',
14609
14748
  ...attemptFrame
14610
14749
  });
14611
14750
  const outcome = await runAttempt();
14751
+ if (!this.#events.hasObservers) return outcome;
14612
14752
  for (const criterion of outcome.successCriteria) {
14613
- events.emit({
14614
- type: 'criterion-evaluated',
14753
+ this.#events.emit({
14754
+ type: 'criterion:evaluated',
14615
14755
  ...attemptFrame,
14616
14756
  kind: 'success',
14617
14757
  criterion,
@@ -14619,8 +14759,8 @@ class WorkflowExecutor {
14619
14759
  });
14620
14760
  }
14621
14761
  for (const criterion of outcome.actionCriteria) {
14622
- events.emit({
14623
- type: 'criterion-evaluated',
14762
+ this.#events.emit({
14763
+ type: 'criterion:evaluated',
14624
14764
  ...attemptFrame,
14625
14765
  kind: 'action',
14626
14766
  criterion,
@@ -14684,7 +14824,7 @@ class WorkflowExecutor {
14684
14824
  stepId
14685
14825
  } = stepFrame;
14686
14826
  return async (action, outcome, attempt) => {
14687
- (0,_abort_ts__WEBPACK_IMPORTED_MODULE_18__.throwIfAborted)(scope.signal, {
14827
+ (0,_abort_ts__WEBPACK_IMPORTED_MODULE_19__.throwIfAborted)(scope.signal, {
14688
14828
  workflowId,
14689
14829
  stepId,
14690
14830
  callStack
@@ -14692,12 +14832,12 @@ class WorkflowExecutor {
14692
14832
  const {
14693
14833
  hasStepId,
14694
14834
  hasWorkflowId
14695
- } = (0,_StepTransitionInterpreter_ts__WEBPACK_IMPORTED_MODULE_15__.actionTargets)(action);
14835
+ } = (0,_StepTransitionInterpreter_ts__WEBPACK_IMPORTED_MODULE_16__.actionTargets)(action);
14696
14836
  if (hasWorkflowId && hasStepId) {
14697
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`retry action on step "${stepId}" in workflow "${workflowId}" declares both a stepId and a workflowId (mutually exclusive)`, {
14837
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"](`retry action on step "${stepId}" in workflow "${workflowId}" declares both a stepId and a workflowId (mutually exclusive)`, {
14698
14838
  stepId,
14699
14839
  workflowId,
14700
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].AmbiguousTarget
14840
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].AmbiguousTarget
14701
14841
  });
14702
14842
  }
14703
14843
  if (hasWorkflowId) {
@@ -14712,11 +14852,13 @@ class WorkflowExecutor {
14712
14852
  kind: 'workflow',
14713
14853
  id: reference
14714
14854
  };
14715
- this.#events?.emit({
14716
- type: 'retry-reference-start',
14717
- ...referenceFrame,
14718
- location: invocation.document.locationOf(action)
14719
- });
14855
+ if (this.#events.hasObservers) {
14856
+ this.#events.emit({
14857
+ type: 'retry:reference:start',
14858
+ ...referenceFrame,
14859
+ location: invocation.document.locationOf(action)
14860
+ });
14861
+ }
14720
14862
  const result = await this.#runReferencedWorkflow(reference, stepId, invocation, scope, 'retry', inputs);
14721
14863
  // the result's workflowId is the bare id the reference resolved to —
14722
14864
  // the key run state is recorded under, whichever document owns it.
@@ -14732,16 +14874,18 @@ class WorkflowExecutor {
14732
14874
  successful,
14733
14875
  subWorkflow: result
14734
14876
  });
14735
- this.#events?.emit({
14736
- type: 'retry-reference-settled',
14737
- ...referenceFrame,
14738
- successful
14739
- });
14877
+ if (this.#events.hasObservers) {
14878
+ this.#events.emit({
14879
+ type: 'retry:reference:settled',
14880
+ ...referenceFrame,
14881
+ successful
14882
+ });
14883
+ }
14740
14884
  return;
14741
14885
  }
14742
14886
  const refStepId = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(action.stepId);
14743
14887
  const refIndex = this.#interpreter.indexOfStep(steps, refStepId, workflowId, {
14744
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].RetryTargetNotFound,
14888
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].RetryTargetNotFound,
14745
14889
  label: 'retry reference'
14746
14890
  });
14747
14891
  const refStep = steps[refIndex];
@@ -14752,11 +14896,13 @@ class WorkflowExecutor {
14752
14896
  kind: 'step',
14753
14897
  id: refStepId
14754
14898
  };
14755
- this.#events?.emit({
14756
- type: 'retry-reference-start',
14757
- ...referenceFrame,
14758
- location: invocation.document.locationOf(action)
14759
- });
14899
+ if (this.#events.hasObservers) {
14900
+ this.#events.emit({
14901
+ type: 'retry:reference:start',
14902
+ ...referenceFrame,
14903
+ location: invocation.document.locationOf(action)
14904
+ });
14905
+ }
14760
14906
  // the referenced step's attempt is observed like any other, under its
14761
14907
  // own stepId and with a count of its own.
14762
14908
  const refOutcome = await this.#chargedAttempt(this.#observedAttempt(this.#stepAttempt(refStep, refStepId, invocation, scope, refSubWorkflows), {
@@ -14772,11 +14918,13 @@ class WorkflowExecutor {
14772
14918
  subWorkflow: refSubWorkflows[0]
14773
14919
  } : {})
14774
14920
  });
14775
- this.#events?.emit({
14776
- type: 'retry-reference-settled',
14777
- ...referenceFrame,
14778
- successful: refOutcome.successful
14779
- });
14921
+ if (this.#events.hasObservers) {
14922
+ this.#events.emit({
14923
+ type: 'retry:reference:settled',
14924
+ ...referenceFrame,
14925
+ successful: refOutcome.successful
14926
+ });
14927
+ }
14780
14928
  };
14781
14929
  }
14782
14930
 
@@ -14829,12 +14977,14 @@ class WorkflowExecutor {
14829
14977
  workflowId: dependency.locator.workflowId,
14830
14978
  documentURI: dependency.locator.document.uri
14831
14979
  };
14832
- this.#events?.emit({
14833
- type: 'dependency-start',
14834
- ...frame,
14835
- dependency: target,
14836
- location: invocation.document.locationOf(dependency.entry)
14837
- });
14980
+ if (this.#events.hasObservers) {
14981
+ this.#events.emit({
14982
+ type: 'dependency:start',
14983
+ ...frame,
14984
+ dependency: target,
14985
+ location: invocation.document.locationOf(dependency.entry)
14986
+ });
14987
+ }
14838
14988
  // a dependency already completed in this run is satisfied, not repeated: a
14839
14989
  // precondition holds once met, and a diamond (two dependents sharing one
14840
14990
  // dependency) must not duplicate its live side effects. Every dependent
@@ -14857,13 +15007,15 @@ class WorkflowExecutor {
14857
15007
  inputs,
14858
15008
  outputs: result.outputs
14859
15009
  });
14860
- this.#events?.emit({
14861
- type: 'dependency-settled',
14862
- ...frame,
14863
- dependency: target,
14864
- memoized: memoized !== undefined,
14865
- settledStatus: result.settledStatus
14866
- });
15010
+ if (this.#events.hasObservers) {
15011
+ this.#events.emit({
15012
+ type: 'dependency:settled',
15013
+ ...frame,
15014
+ dependency: target,
15015
+ memoized: memoized !== undefined,
15016
+ settledStatus: result.settledStatus
15017
+ });
15018
+ }
14867
15019
  if (this.#settledFailed(result)) return results;
14868
15020
 
14869
15021
  // only a dependency whose chain settled non-`failed` is remembered as
@@ -14900,16 +15052,16 @@ class WorkflowExecutor {
14900
15052
  } = invocation;
14901
15053
  const dependsOn = workflow.dependsOn;
14902
15054
  if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isArrayElement)(dependsOn)) {
14903
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`workflow "${workflowId}" has a non-list "dependsOn"`, {
15055
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"](`workflow "${workflowId}" has a non-list "dependsOn"`, {
14904
15056
  workflowId,
14905
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].MalformedDependsOn
15057
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].MalformedDependsOn
14906
15058
  });
14907
15059
  }
14908
15060
  const entries = [...dependsOn].map((entry, index) => {
14909
15061
  if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isStringElement)(entry)) {
14910
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`workflow "${workflowId}" has a non-string entry at dependsOn[${index}]`, {
15062
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"](`workflow "${workflowId}" has a non-string entry at dependsOn[${index}]`, {
14911
15063
  workflowId,
14912
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].MalformedDependsOn
15064
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].MalformedDependsOn
14913
15065
  });
14914
15066
  }
14915
15067
  return entry;
@@ -15094,10 +15246,10 @@ class WorkflowExecutor {
15094
15246
  // cannot be rejected by one and silently accepted by the other.
15095
15247
  const conflicting = _StepExecutor_ts__WEBPACK_IMPORTED_MODULE_11__.STEP_TARGET_FIELDS.filter(field => field !== 'workflowId' && (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isStringElement)(step[field]));
15096
15248
  if (conflicting.length > 0) {
15097
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`step "${stepId}" in workflow "${workflowId}" declares a workflowId alongside ${conflicting.join(', ')} (mutually exclusive)`, {
15249
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"](`step "${stepId}" in workflow "${workflowId}" declares a workflowId alongside ${conflicting.join(', ')} (mutually exclusive)`, {
15098
15250
  stepId,
15099
15251
  workflowId,
15100
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].AmbiguousTarget
15252
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].AmbiguousTarget
15101
15253
  });
15102
15254
  }
15103
15255
  return (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(step.workflowId);
@@ -15181,16 +15333,16 @@ class WorkflowExecutor {
15181
15333
  parameters
15182
15334
  } = action;
15183
15335
  if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isArrayElement)(parameters)) {
15184
- throw new _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_17__["default"]('`parameters` is present but is not a list', {
15336
+ throw new _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_18__["default"]('`parameters` is present but is not a list', {
15185
15337
  ...scope,
15186
- reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].MalformedParameters
15338
+ reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_18__["default"].MalformedParameters
15187
15339
  });
15188
15340
  }
15189
15341
  const inline = [...parameters].some(parameter => (0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_4__.isParameterElement)(parameter) && parameter.hasKey('in') && !parameter.meta.hasKey('ref-fields'));
15190
15342
  if (inline) {
15191
- throw new _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_17__["default"](`An action parameter of ${owner} declares an \`in\`; action parameters map to the target workflow's inputs by name`, {
15343
+ throw new _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_18__["default"](`An action parameter of ${owner} declares an \`in\`; action parameters map to the target workflow's inputs by name`, {
15192
15344
  ...scope,
15193
- reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].ActionParameterLocation
15345
+ reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_18__["default"].ActionParameterLocation
15194
15346
  });
15195
15347
  }
15196
15348
  }
@@ -15211,9 +15363,9 @@ class WorkflowExecutor {
15211
15363
  workflowId
15212
15364
  }) {
15213
15365
  if (!document.workflowIndex.has(workflowId)) {
15214
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`workflow "${workflowId}" not found in Arazzo document at "${document.uri}"`, {
15366
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"](`workflow "${workflowId}" not found in Arazzo document at "${document.uri}"`, {
15215
15367
  workflowId,
15216
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].WorkflowNotFound
15368
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].WorkflowNotFound
15217
15369
  });
15218
15370
  }
15219
15371
  return this.#extractor.extract(document, workflowId);
@@ -15227,17 +15379,21 @@ class WorkflowExecutor {
15227
15379
  const cached = scope.workflows.get(qualifiedId);
15228
15380
  if (cached !== undefined) return cached;
15229
15381
  const location = locator.document.locationOf(extracted);
15230
- this.#events?.emit({
15231
- type: 'workflow-normalize-start',
15232
- ...frame,
15233
- location
15234
- });
15382
+ if (this.#events.hasObservers) {
15383
+ this.#events.emit({
15384
+ type: 'workflow:normalize:start',
15385
+ ...frame,
15386
+ location
15387
+ });
15388
+ }
15235
15389
  const workflow = await this.#normalizer.normalize(extracted, locator.document);
15236
- this.#events?.emit({
15237
- type: 'workflow-normalize-settled',
15238
- ...frame,
15239
- location
15240
- });
15390
+ if (this.#events.hasObservers) {
15391
+ this.#events.emit({
15392
+ type: 'workflow:normalize:settled',
15393
+ ...frame,
15394
+ location
15395
+ });
15396
+ }
15241
15397
  scope.workflows.set(qualifiedId, workflow);
15242
15398
  return workflow;
15243
15399
  }
@@ -15263,16 +15419,16 @@ class WorkflowExecutor {
15263
15419
  if (!workflow.hasKey('steps')) return [];
15264
15420
  const steps = workflow.steps;
15265
15421
  if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isArrayElement)(steps)) {
15266
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`workflow "${workflowId}" has a non-list "steps"`, {
15422
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"](`workflow "${workflowId}" has a non-list "steps"`, {
15267
15423
  workflowId,
15268
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].MalformedSteps
15424
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].MalformedSteps
15269
15425
  });
15270
15426
  }
15271
15427
  return [...steps].map((step, index) => {
15272
15428
  if (!(0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_4__.isStepElement)(step)) {
15273
- throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"](`workflow "${workflowId}" has a non-step entry at steps[${index}]`, {
15429
+ throw new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"](`workflow "${workflowId}" has a non-step entry at steps[${index}]`, {
15274
15430
  workflowId,
15275
- reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_16__["default"].MalformedSteps
15431
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].MalformedSteps
15276
15432
  });
15277
15433
  }
15278
15434
  return step;
@@ -15292,10 +15448,10 @@ class WorkflowExecutor {
15292
15448
  if (!workflow.hasKey('outputs')) return;
15293
15449
  const outputs = workflow.outputs;
15294
15450
  if ((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isObjectElement)(outputs)) return;
15295
- throw new _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_17__["default"]('`outputs` is present but is not a map', {
15451
+ throw new _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_18__["default"]('`outputs` is present but is not a map', {
15296
15452
  workflowId,
15297
15453
  target: 'outputs',
15298
- reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_17__["default"].MalformedOutputs
15454
+ reason: _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_18__["default"].MalformedOutputs
15299
15455
  });
15300
15456
  }
15301
15457
 
@@ -16827,6 +16983,8 @@ class OpenAPIOperationNormalizer {
16827
16983
  "use strict";
16828
16984
  __webpack_require__.r(__webpack_exports__);
16829
16985
  /* harmony import */ var ramda_adjunct__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(34606);
16986
+ /* harmony import */ var _instrument_ts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(21327);
16987
+
16830
16988
 
16831
16989
 
16832
16990
  /**
@@ -16841,33 +16999,19 @@ __webpack_require__.r(__webpack_exports__);
16841
16999
  */
16842
17000
 
16843
17001
  /**
16844
- * Delivers a building block's events to its observer: stamps each with the
17002
+ * Delivers a building block's events to its observer, then to the
17003
+ * process-wide observers {@link instrument} registered: stamps each with the
16845
17004
  * block's clock, snapshots it, and hands it over synchronously, without
16846
17005
  * awaiting anything.
16847
17006
  *
16848
- * A block holds a channel only when it was given an observer (see
16849
- * {@link EventChannel.open}), and emits through `this.#events?.emit(...)`: with
16850
- * no channel, optional chaining skips evaluating the event too, so an
16851
- * unobserved run builds no events at all.
17007
+ * A block emits only while {@link EventChannel.hasObservers}:
17008
+ * `if (this.#events.hasObservers) this.#events.emit({...})`, so an unobserved
17009
+ * run builds no events at all, like `diagnostics_channel`'s `hasSubscribers`.
16852
17010
  * @internal
16853
17011
  */
16854
17012
  class EventChannel {
16855
17013
  static #DEFAULT_NOW = () => performance.now();
16856
17014
 
16857
- /**
16858
- * A channel to `options.observer`, or `undefined` when there is none.
16859
- */
16860
- static open(options) {
16861
- const {
16862
- observer,
16863
- now
16864
- } = options;
16865
- return observer === undefined ? undefined : new EventChannel({
16866
- observer,
16867
- now
16868
- });
16869
- }
16870
-
16871
17015
  /**
16872
17016
  * A frozen deep copy of the plain objects and arrays in `value`; anything
16873
17017
  * else, an ApiDOM element above all, is shared as it is. The run keeps
@@ -16900,6 +17044,15 @@ class EventChannel {
16900
17044
  this.#now = options.now ?? EventChannel.#DEFAULT_NOW;
16901
17045
  }
16902
17046
 
17047
+ /**
17048
+ * Whether anyone observes the channel: its own observer or a process-wide
17049
+ * one. Read per event, so hooks registered mid-run apply from the next
17050
+ * event on.
17051
+ */
17052
+ get hasObservers() {
17053
+ return this.#observer !== undefined || (0,_instrument_ts__WEBPACK_IMPORTED_MODULE_1__.isInstrumented)();
17054
+ }
17055
+
16903
17056
  /**
16904
17057
  * Emits the event. `timestamp` is the clock reading the event describes,
16905
17058
  * when the caller already took one (so a start/settled pair matches a
@@ -16914,7 +17067,21 @@ class EventChannel {
16914
17067
  ...Object.fromEntries(fields),
16915
17068
  timestamp: timestamp ?? this.#now()
16916
17069
  };
16917
- this.#observer(EventChannel.#snapshot(stamped, new WeakMap()));
17070
+ const snapshot = EventChannel.#snapshot(stamped, new WeakMap());
17071
+ // process-wide observers see the event even when the block's own throws,
17072
+ // so a buggy observer cannot leave a trace incomplete; the block's own
17073
+ // error is the one that aborts what emitted the event
17074
+ try {
17075
+ this.#observer?.(snapshot);
17076
+ } catch (error) {
17077
+ try {
17078
+ ;(0,_instrument_ts__WEBPACK_IMPORTED_MODULE_1__.notify)(snapshot);
17079
+ } catch {
17080
+ // the block's own observer failed first
17081
+ }
17082
+ throw error;
17083
+ }
17084
+ ;(0,_instrument_ts__WEBPACK_IMPORTED_MODULE_1__.notify)(snapshot);
16918
17085
  }
16919
17086
  }
16920
17087
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (EventChannel);
@@ -16973,7 +17140,8 @@ __webpack_require__.r(__webpack_exports__);
16973
17140
  * - a request or response body that is JSON or a URL-encoded form, field by
16974
17141
  * field, and any other body, or any object that is not plain data, whole.
16975
17142
  *
16976
- * A credential under a name no pattern matches is carried as it is. The
17143
+ * A settled event's `error` is carried as it is, the error `execute` rejects
17144
+ * with. A credential under a name no pattern matches is carried as it is. The
16977
17145
  * masked value is `REDACTED`.
16978
17146
  * @public
16979
17147
  */
@@ -17001,10 +17169,11 @@ class Redactor {
17001
17169
  #walk(value, seen) {
17002
17170
  if (typeof value === 'string') return URL.canParse(value) ? this.#url(value) : value;
17003
17171
  if (typeof value !== 'object' || value === null) return value;
17004
- // an ApiDOM element (a selected action) is the document's own, and a date
17005
- // holds no credential; any other object that is not plain data cannot be
17006
- // walked field by field.
17007
- if ((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__.isElement)(value) || value instanceof Date) return value;
17172
+ // an ApiDOM element (a selected action) is the document's own, a date
17173
+ // holds no credential, and an error is the one `execute` rejects with,
17174
+ // unmasked; any other object that is not plain data cannot be walked
17175
+ // field by field.
17176
+ if ((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__.isElement)(value) || value instanceof Date || value instanceof Error) return value;
17008
17177
  if (!Array.isArray(value) && !(0,ramda_adjunct__WEBPACK_IMPORTED_MODULE_0__["default"])(value)) return Redactor.CENSOR;
17009
17178
  // only the objects on the current path: a shared, acyclic one is walked
17010
17179
  // again where it reappears, a cycle is cut.
@@ -17148,6 +17317,196 @@ class Redactor {
17148
17317
  /* harmony export */ ]);
17149
17318
 
17150
17319
 
17320
+ /***/ },
17321
+
17322
+ /***/ 35622
17323
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
17324
+
17325
+ "use strict";
17326
+ __webpack_require__.r(__webpack_exports__);
17327
+ /**
17328
+ * One observer that hands each event to every observer given, in order, so
17329
+ * several consumers (a log, a trace, a stream) can watch the same run.
17330
+ *
17331
+ * Delivery stays synchronous. An observer that throws aborts the run with its
17332
+ * error, as any observer does, and the observers after it miss that event.
17333
+ * @public
17334
+ */
17335
+ const combineObservers = (...observers) => event => {
17336
+ for (const observer of observers) observer(event);
17337
+ };
17338
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (combineObservers);
17339
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, [
17340
+ /* harmony export */ "default", 0, __WEBPACK_DEFAULT_EXPORT__
17341
+ /* harmony export */ ]);
17342
+
17343
+
17344
+ /***/ },
17345
+
17346
+ /***/ 21327
17347
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
17348
+
17349
+ "use strict";
17350
+ __webpack_require__.r(__webpack_exports__);
17351
+ /* harmony import */ var _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(17658);
17352
+
17353
+
17354
+ /**
17355
+ * A workflow invocation an {@link InstrumentationWrap} runs around: its
17356
+ * `workflow:start`, its steps and its `workflow:settled`.
17357
+ * @public
17358
+ */
17359
+
17360
+ /**
17361
+ * A step an {@link InstrumentationWrap} runs around: its `step:start`, its
17362
+ * attempts and requests, and its `step:settled`.
17363
+ * @public
17364
+ */
17365
+
17366
+ /**
17367
+ * What an {@link InstrumentationWrap} runs around.
17368
+ * @public
17369
+ */
17370
+
17371
+ /**
17372
+ * Runs around each workflow invocation and each step, so what `run` does
17373
+ * happens inside it: in the active context of a span it opened, for one. It
17374
+ * must call `run`, and should settle once `run` settles; a second call runs
17375
+ * nothing again. What it resolves or rejects with does not change the run:
17376
+ * the run's own outcome stands, once the run settled, and the operation's
17377
+ * settled event says what it was.
17378
+ * @public
17379
+ */
17380
+
17381
+ /**
17382
+ * Hooks that apply to every runner in the process, on top of the observer
17383
+ * each was given.
17384
+ * @public
17385
+ */
17386
+
17387
+ // on globalThis, so the ESM and CommonJS builds of the runner, or two copies
17388
+ // of it, share one registry
17389
+ const KEY = Symbol.for('@usearazzo/runner/observability/instrument');
17390
+ const registry = () => {
17391
+ const scope = globalThis;
17392
+ scope[KEY] ??= {
17393
+ hooks: []
17394
+ };
17395
+ return scope[KEY];
17396
+ };
17397
+
17398
+ /**
17399
+ * Applies `hooks` to every runner in the process, until the returned
17400
+ * function removes them: the seam process-wide tooling, such as the
17401
+ * OpenTelemetry instrumentation, is built on. A run already in progress
17402
+ * picks hooks up at its next event or operation, and drops removed ones the
17403
+ * same way: a removed hook misses the settled events of what it saw start.
17404
+ * Hooks apply in the order they were added, the first wrap outermost.
17405
+ * @public
17406
+ */
17407
+ const instrument = hooks => {
17408
+ const {
17409
+ hooks: registered
17410
+ } = registry();
17411
+ registered.push(hooks);
17412
+ return () => {
17413
+ const index = registered.indexOf(hooks);
17414
+ if (index !== -1) registered.splice(index, 1);
17415
+ };
17416
+ };
17417
+
17418
+ /**
17419
+ * Whether any process-wide observer is registered.
17420
+ * @internal
17421
+ */
17422
+ const isInstrumented = () => registry().hooks.some(hooks => hooks.observer);
17423
+
17424
+ /**
17425
+ * Hands the event to every process-wide observer.
17426
+ * @internal
17427
+ */
17428
+ const notify = event => {
17429
+ // a copy: an observer that removes hooks must not skip the next one
17430
+ for (const {
17431
+ observer
17432
+ } of [...registry().hooks]) observer?.(event);
17433
+ };
17434
+
17435
+ /**
17436
+ * Runs `work` inside every registered wrap, returning what `work` resolves
17437
+ * to or rejecting with what it rejects with, whatever a wrap settles with,
17438
+ * and only once `work` settled. A wrap that throws before running `work`
17439
+ * aborts it; one that throws after is ignored.
17440
+ * @internal
17441
+ */
17442
+ const traced = async (describe, work) => {
17443
+ const wraps = registry().hooks.flatMap(({
17444
+ wrap
17445
+ }) => wrap === undefined ? [] : [wrap]);
17446
+ // described only when a wrap is registered: an uninstrumented run builds nothing
17447
+ if (wraps.length === 0) return work();
17448
+ const operation = describe();
17449
+ let outcome;
17450
+ let running;
17451
+ let abandoned = false;
17452
+ const unrun = () => new _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_0__["default"](`an instrumentation wrap settled without running the ${operation.kind}`, {
17453
+ workflowId: operation.workflowId,
17454
+ ...(operation.kind === 'step' ? {
17455
+ stepId: operation.stepId
17456
+ } : {}),
17457
+ reason: _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_0__["default"].InstrumentationWrap
17458
+ });
17459
+ // once, however many times a wrap calls it
17460
+ const innermost = () => {
17461
+ // a wrap calling it after the run gave up on it: running the work then
17462
+ // would act for a run that already rejected
17463
+ if (abandoned) return Promise.reject(unrun());
17464
+ if (running === undefined) {
17465
+ running = (async () => {
17466
+ try {
17467
+ outcome = {
17468
+ value: await work()
17469
+ };
17470
+ } catch (error) {
17471
+ outcome = {
17472
+ error
17473
+ };
17474
+ throw error;
17475
+ }
17476
+ })();
17477
+ // handled here too: a wrap that settles later than the work must not
17478
+ // leave its rejection unhandled, which would end the process
17479
+ running.catch(() => undefined);
17480
+ }
17481
+ return running;
17482
+ };
17483
+ const run = wraps.reduceRight((next, wrap) => () => wrap(operation, next), innermost);
17484
+ try {
17485
+ await run();
17486
+ } catch (error) {
17487
+ if (running === undefined) {
17488
+ abandoned = true;
17489
+ throw error;
17490
+ }
17491
+ }
17492
+ // a wrap that settled without waiting for the work: the work still decides
17493
+ if (running !== undefined) await running.catch(() => undefined);
17494
+ if (outcome === undefined) {
17495
+ abandoned = true;
17496
+ throw unrun();
17497
+ }
17498
+ if ('error' in outcome) throw outcome.error;
17499
+ return outcome.value;
17500
+ };
17501
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (instrument);
17502
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, [
17503
+ /* harmony export */ "default", 0, __WEBPACK_DEFAULT_EXPORT__,
17504
+ /* harmony export */ "isInstrumented", 0, /* binding */ isInstrumented,
17505
+ /* harmony export */ "notify", 0, /* binding */ notify,
17506
+ /* harmony export */ "traced", 0, /* binding */ traced
17507
+ /* harmony export */ ]);
17508
+
17509
+
17151
17510
  /***/ },
17152
17511
 
17153
17512
  /***/ 4044
@@ -17193,10 +17552,11 @@ class DocumentRegistry {
17193
17552
  #documents = new Map();
17194
17553
  #loading = new Map();
17195
17554
  #providers;
17555
+ // emits only while `hasObservers`, so an unobserved block builds no events
17196
17556
  #events;
17197
17557
  constructor(options = {}) {
17198
17558
  this.#providers = options.providers ?? [new _providers_ArazzoDocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_2__["default"](), new _providers_OpenAPIDocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_3__["default"]()];
17199
- this.#events = _observability_EventChannel_ts__WEBPACK_IMPORTED_MODULE_9__["default"].open({
17559
+ this.#events = new _observability_EventChannel_ts__WEBPACK_IMPORTED_MODULE_9__["default"]({
17200
17560
  observer: options.observer,
17201
17561
  now: options.now
17202
17562
  });
@@ -17245,10 +17605,12 @@ class DocumentRegistry {
17245
17605
  * caches it.
17246
17606
  */
17247
17607
  async #load(canonicalURI) {
17248
- this.#events?.emit({
17249
- type: 'document-load-start',
17250
- uri: canonicalURI
17251
- });
17608
+ if (this.#events.hasObservers) {
17609
+ this.#events.emit({
17610
+ type: 'document:load:start',
17611
+ uri: canonicalURI
17612
+ });
17613
+ }
17252
17614
  for (const provider of this.#providers) {
17253
17615
  let document;
17254
17616
  try {
@@ -17267,10 +17629,12 @@ class DocumentRegistry {
17267
17629
  if (document !== undefined) {
17268
17630
  // outside the try, so an observer's own error is not a failed load, and
17269
17631
  // before caching, so a run it aborts leaves no half-registered document.
17270
- this.#events?.emit({
17271
- type: 'document-load-settled',
17272
- uri: canonicalURI
17273
- });
17632
+ if (this.#events.hasObservers) {
17633
+ this.#events.emit({
17634
+ type: 'document:load:settled',
17635
+ uri: canonicalURI
17636
+ });
17637
+ }
17274
17638
  this.#set(canonicalURI, document);
17275
17639
  return document;
17276
17640
  }
@@ -119950,7 +120314,7 @@ __webpack_require__.r(__webpack_exports__);
119950
120314
  /* harmony export */ ArazzoDocument: () => (/* reexport safe */ _document_ArazzoDocument_ts__WEBPACK_IMPORTED_MODULE_6__["default"]),
119951
120315
  /* harmony export */ ArazzoDocumentRegistryProvider: () => (/* reexport safe */ _registry_providers_ArazzoDocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_3__["default"]),
119952
120316
  /* harmony export */ ArazzoRunner: () => (/* reexport safe */ _ArazzoRunner_ts__WEBPACK_IMPORTED_MODULE_0__["default"]),
119953
- /* harmony export */ ArazzoRunnerError: () => (/* reexport safe */ _errors_ArazzoRunnerError_ts__WEBPACK_IMPORTED_MODULE_49__["default"]),
120317
+ /* harmony export */ ArazzoRunnerError: () => (/* reexport safe */ _errors_ArazzoRunnerError_ts__WEBPACK_IMPORTED_MODULE_51__["default"]),
119954
120318
  /* harmony export */ ArazzoSourceDescriptionIndex: () => (/* reexport safe */ _document_ArazzoSourceDescriptionIndex_ts__WEBPACK_IMPORTED_MODULE_10__["default"]),
119955
120319
  /* harmony export */ ArazzoStepExtractor: () => (/* reexport safe */ _extractor_ArazzoStepExtractor_ts__WEBPACK_IMPORTED_MODULE_13__["default"]),
119956
120320
  /* harmony export */ ArazzoStepIndex: () => (/* reexport safe */ _document_ArazzoStepIndex_ts__WEBPACK_IMPORTED_MODULE_9__["default"]),
@@ -119960,19 +120324,19 @@ __webpack_require__.r(__webpack_exports__);
119960
120324
  /* harmony export */ ArazzoWorkflowIndex: () => (/* reexport safe */ _document_ArazzoWorkflowIndex_ts__WEBPACK_IMPORTED_MODULE_8__["default"]),
119961
120325
  /* harmony export */ ArazzoWorkflowLocatorNormalizer: () => (/* reexport safe */ _executor_ArazzoWorkflowLocatorNormalizer_ts__WEBPACK_IMPORTED_MODULE_47__["default"]),
119962
120326
  /* harmony export */ ArazzoWorkflowNormalizer: () => (/* reexport safe */ _normalizer_ArazzoWorkflowNormalizer_ts__WEBPACK_IMPORTED_MODULE_15__["default"]),
119963
- /* harmony export */ AssemblerError: () => (/* reexport safe */ _errors_AssemblerError_ts__WEBPACK_IMPORTED_MODULE_50__["default"]),
119964
- /* harmony export */ ClientError: () => (/* reexport safe */ _errors_ClientError_ts__WEBPACK_IMPORTED_MODULE_51__["default"]),
119965
- /* harmony export */ CriterionError: () => (/* reexport safe */ _errors_CriterionError_ts__WEBPACK_IMPORTED_MODULE_58__["default"]),
119966
- /* harmony export */ CriterionEvaluationError: () => (/* reexport safe */ _errors_CriterionEvaluationError_ts__WEBPACK_IMPORTED_MODULE_59__["default"]),
120327
+ /* harmony export */ AssemblerError: () => (/* reexport safe */ _errors_AssemblerError_ts__WEBPACK_IMPORTED_MODULE_52__["default"]),
120328
+ /* harmony export */ ClientError: () => (/* reexport safe */ _errors_ClientError_ts__WEBPACK_IMPORTED_MODULE_53__["default"]),
120329
+ /* harmony export */ CriterionError: () => (/* reexport safe */ _errors_CriterionError_ts__WEBPACK_IMPORTED_MODULE_60__["default"]),
120330
+ /* harmony export */ CriterionEvaluationError: () => (/* reexport safe */ _errors_CriterionEvaluationError_ts__WEBPACK_IMPORTED_MODULE_61__["default"]),
119967
120331
  /* harmony export */ CriterionEvaluator: () => (/* reexport safe */ _criterion_CriterionEvaluator_ts__WEBPACK_IMPORTED_MODULE_29__["default"]),
119968
- /* harmony export */ DocumentLoadError: () => (/* reexport safe */ _errors_DocumentLoadError_ts__WEBPACK_IMPORTED_MODULE_56__["default"]),
120332
+ /* harmony export */ DocumentLoadError: () => (/* reexport safe */ _errors_DocumentLoadError_ts__WEBPACK_IMPORTED_MODULE_58__["default"]),
119969
120333
  /* harmony export */ DocumentRegistry: () => (/* reexport safe */ _registry_DocumentRegistry_ts__WEBPACK_IMPORTED_MODULE_1__["default"]),
119970
120334
  /* harmony export */ DocumentRegistryProvider: () => (/* reexport safe */ _registry_providers_DocumentRegistryProvider_ts__WEBPACK_IMPORTED_MODULE_2__["default"]),
119971
- /* harmony export */ ExecutionError: () => (/* reexport safe */ _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_61__["default"]),
119972
- /* harmony export */ ExtractionError: () => (/* reexport safe */ _errors_ExtractionError_ts__WEBPACK_IMPORTED_MODULE_53__["default"]),
119973
- /* harmony export */ InvalidEntryDocumentError: () => (/* reexport safe */ _errors_InvalidEntryDocumentError_ts__WEBPACK_IMPORTED_MODULE_54__["default"]),
120335
+ /* harmony export */ ExecutionError: () => (/* reexport safe */ _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_63__["default"]),
120336
+ /* harmony export */ ExtractionError: () => (/* reexport safe */ _errors_ExtractionError_ts__WEBPACK_IMPORTED_MODULE_55__["default"]),
120337
+ /* harmony export */ InvalidEntryDocumentError: () => (/* reexport safe */ _errors_InvalidEntryDocumentError_ts__WEBPACK_IMPORTED_MODULE_56__["default"]),
119974
120338
  /* harmony export */ JSONPathCriterionEvaluator: () => (/* reexport safe */ _criterion_JSONPathCriterionEvaluator_ts__WEBPACK_IMPORTED_MODULE_32__["default"]),
119975
- /* harmony export */ NormalizationError: () => (/* reexport safe */ _errors_NormalizationError_ts__WEBPACK_IMPORTED_MODULE_52__["default"]),
120339
+ /* harmony export */ NormalizationError: () => (/* reexport safe */ _errors_NormalizationError_ts__WEBPACK_IMPORTED_MODULE_54__["default"]),
119976
120340
  /* harmony export */ OpenAPI2DocumentAssembler: () => (/* reexport safe */ _assembler_OpenAPI2DocumentAssembler_ts__WEBPACK_IMPORTED_MODULE_22__["default"]),
119977
120341
  /* harmony export */ OpenAPI2OperationNormalizer: () => (/* reexport safe */ _normalizer_OpenAPI2OperationNormalizer_ts__WEBPACK_IMPORTED_MODULE_18__["default"]),
119978
120342
  /* harmony export */ OpenAPI30DocumentAssembler: () => (/* reexport safe */ _assembler_OpenAPI30DocumentAssembler_ts__WEBPACK_IMPORTED_MODULE_23__["default"]),
@@ -119991,22 +120355,24 @@ __webpack_require__.r(__webpack_exports__);
119991
120355
  /* harmony export */ OpenAPIOperationResponse: () => (/* reexport safe */ _client_OpenAPIOperationResponse_ts__WEBPACK_IMPORTED_MODULE_26__["default"]),
119992
120356
  /* harmony export */ OpenAPIOperationResponseNormalizer: () => (/* reexport safe */ _client_OpenAPIOperationResponseNormalizer_ts__WEBPACK_IMPORTED_MODULE_27__["default"]),
119993
120357
  /* harmony export */ OutputResolver: () => (/* reexport safe */ _resolver_OutputResolver_ts__WEBPACK_IMPORTED_MODULE_39__["default"]),
119994
- /* harmony export */ Redactor: () => (/* reexport safe */ _observability_Redactor_ts__WEBPACK_IMPORTED_MODULE_48__["default"]),
120358
+ /* harmony export */ Redactor: () => (/* reexport safe */ _observability_Redactor_ts__WEBPACK_IMPORTED_MODULE_50__["default"]),
119995
120359
  /* harmony export */ RegexCriterionEvaluator: () => (/* reexport safe */ _criterion_RegexCriterionEvaluator_ts__WEBPACK_IMPORTED_MODULE_31__["default"]),
119996
120360
  /* harmony export */ RequestBodyResolver: () => (/* reexport safe */ _resolver_RequestBodyResolver_ts__WEBPACK_IMPORTED_MODULE_40__["default"]),
119997
- /* harmony export */ ResolverError: () => (/* reexport safe */ _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_60__["default"]),
119998
- /* harmony export */ RuntimeExpressionError: () => (/* reexport safe */ _errors_RuntimeExpressionError_ts__WEBPACK_IMPORTED_MODULE_57__["default"]),
120361
+ /* harmony export */ ResolverError: () => (/* reexport safe */ _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_62__["default"]),
120362
+ /* harmony export */ RuntimeExpressionError: () => (/* reexport safe */ _errors_RuntimeExpressionError_ts__WEBPACK_IMPORTED_MODULE_59__["default"]),
119999
120363
  /* harmony export */ RuntimeExpressionEvaluator: () => (/* reexport safe */ _expression_RuntimeExpressionEvaluator_ts__WEBPACK_IMPORTED_MODULE_28__["default"]),
120000
120364
  /* harmony export */ SimpleCriterionEvaluator: () => (/* reexport safe */ _criterion_SimpleCriterionEvaluator_ts__WEBPACK_IMPORTED_MODULE_30__["default"]),
120001
120365
  /* harmony export */ SourceDescriptionsLocatorNormalizer: () => (/* reexport safe */ _executor_SourceDescriptionsLocatorNormalizer_ts__WEBPACK_IMPORTED_MODULE_45__["default"]),
120002
120366
  /* harmony export */ StepExecutor: () => (/* reexport safe */ _executor_StepExecutor_ts__WEBPACK_IMPORTED_MODULE_43__["default"]),
120003
120367
  /* harmony export */ StepParameterResolver: () => (/* reexport safe */ _resolver_StepParameterResolver_ts__WEBPACK_IMPORTED_MODULE_36__["default"]),
120004
- /* harmony export */ UnmatchedProviderError: () => (/* reexport safe */ _errors_UnmatchedProviderError_ts__WEBPACK_IMPORTED_MODULE_55__["default"]),
120368
+ /* harmony export */ UnmatchedProviderError: () => (/* reexport safe */ _errors_UnmatchedProviderError_ts__WEBPACK_IMPORTED_MODULE_57__["default"]),
120005
120369
  /* harmony export */ WorkflowExecutionState: () => (/* reexport safe */ _state_WorkflowExecutionState_ts__WEBPACK_IMPORTED_MODULE_34__["default"]),
120006
120370
  /* harmony export */ WorkflowExecutor: () => (/* reexport safe */ _executor_WorkflowExecutor_ts__WEBPACK_IMPORTED_MODULE_42__["default"]),
120007
120371
  /* harmony export */ WorkflowParameterResolver: () => (/* reexport safe */ _resolver_WorkflowParameterResolver_ts__WEBPACK_IMPORTED_MODULE_38__["default"]),
120008
120372
  /* harmony export */ XPathCriterionEvaluator: () => (/* reexport safe */ _criterion_XPathCriterionEvaluator_ts__WEBPACK_IMPORTED_MODULE_33__["default"]),
120373
+ /* harmony export */ combineObservers: () => (/* reexport safe */ _observability_combineObservers_ts__WEBPACK_IMPORTED_MODULE_48__["default"]),
120009
120374
  /* harmony export */ httpClientFetch: () => (/* reexport safe */ _client_HTTPClientFetch_ts__WEBPACK_IMPORTED_MODULE_25__["default"]),
120375
+ /* harmony export */ instrument: () => (/* reexport safe */ _observability_instrument_ts__WEBPACK_IMPORTED_MODULE_49__["default"]),
120010
120376
  /* harmony export */ settledResult: () => (/* reexport safe */ _executor_WorkflowExecutor_ts__WEBPACK_IMPORTED_MODULE_42__.settledResult)
120011
120377
  /* harmony export */ });
120012
120378
  /* harmony import */ var _ArazzoRunner_ts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(57253);
@@ -120057,20 +120423,22 @@ __webpack_require__.r(__webpack_exports__);
120057
120423
  /* harmony import */ var _executor_SourceDescriptionsLocatorNormalizer_ts__WEBPACK_IMPORTED_MODULE_45__ = __webpack_require__(83461);
120058
120424
  /* harmony import */ var _executor_OpenAPIOperationLocatorNormalizer_ts__WEBPACK_IMPORTED_MODULE_46__ = __webpack_require__(7308);
120059
120425
  /* harmony import */ var _executor_ArazzoWorkflowLocatorNormalizer_ts__WEBPACK_IMPORTED_MODULE_47__ = __webpack_require__(98885);
120060
- /* harmony import */ var _observability_Redactor_ts__WEBPACK_IMPORTED_MODULE_48__ = __webpack_require__(4050);
120061
- /* harmony import */ var _errors_ArazzoRunnerError_ts__WEBPACK_IMPORTED_MODULE_49__ = __webpack_require__(23949);
120062
- /* harmony import */ var _errors_AssemblerError_ts__WEBPACK_IMPORTED_MODULE_50__ = __webpack_require__(90706);
120063
- /* harmony import */ var _errors_ClientError_ts__WEBPACK_IMPORTED_MODULE_51__ = __webpack_require__(81763);
120064
- /* harmony import */ var _errors_NormalizationError_ts__WEBPACK_IMPORTED_MODULE_52__ = __webpack_require__(35523);
120065
- /* harmony import */ var _errors_ExtractionError_ts__WEBPACK_IMPORTED_MODULE_53__ = __webpack_require__(90713);
120066
- /* harmony import */ var _errors_InvalidEntryDocumentError_ts__WEBPACK_IMPORTED_MODULE_54__ = __webpack_require__(40198);
120067
- /* harmony import */ var _errors_UnmatchedProviderError_ts__WEBPACK_IMPORTED_MODULE_55__ = __webpack_require__(46132);
120068
- /* harmony import */ var _errors_DocumentLoadError_ts__WEBPACK_IMPORTED_MODULE_56__ = __webpack_require__(24089);
120069
- /* harmony import */ var _errors_RuntimeExpressionError_ts__WEBPACK_IMPORTED_MODULE_57__ = __webpack_require__(48770);
120070
- /* harmony import */ var _errors_CriterionError_ts__WEBPACK_IMPORTED_MODULE_58__ = __webpack_require__(41233);
120071
- /* harmony import */ var _errors_CriterionEvaluationError_ts__WEBPACK_IMPORTED_MODULE_59__ = __webpack_require__(71731);
120072
- /* harmony import */ var _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_60__ = __webpack_require__(8696);
120073
- /* harmony import */ var _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_61__ = __webpack_require__(17658);
120426
+ /* harmony import */ var _observability_combineObservers_ts__WEBPACK_IMPORTED_MODULE_48__ = __webpack_require__(35622);
120427
+ /* harmony import */ var _observability_instrument_ts__WEBPACK_IMPORTED_MODULE_49__ = __webpack_require__(21327);
120428
+ /* harmony import */ var _observability_Redactor_ts__WEBPACK_IMPORTED_MODULE_50__ = __webpack_require__(4050);
120429
+ /* harmony import */ var _errors_ArazzoRunnerError_ts__WEBPACK_IMPORTED_MODULE_51__ = __webpack_require__(23949);
120430
+ /* harmony import */ var _errors_AssemblerError_ts__WEBPACK_IMPORTED_MODULE_52__ = __webpack_require__(90706);
120431
+ /* harmony import */ var _errors_ClientError_ts__WEBPACK_IMPORTED_MODULE_53__ = __webpack_require__(81763);
120432
+ /* harmony import */ var _errors_NormalizationError_ts__WEBPACK_IMPORTED_MODULE_54__ = __webpack_require__(35523);
120433
+ /* harmony import */ var _errors_ExtractionError_ts__WEBPACK_IMPORTED_MODULE_55__ = __webpack_require__(90713);
120434
+ /* harmony import */ var _errors_InvalidEntryDocumentError_ts__WEBPACK_IMPORTED_MODULE_56__ = __webpack_require__(40198);
120435
+ /* harmony import */ var _errors_UnmatchedProviderError_ts__WEBPACK_IMPORTED_MODULE_57__ = __webpack_require__(46132);
120436
+ /* harmony import */ var _errors_DocumentLoadError_ts__WEBPACK_IMPORTED_MODULE_58__ = __webpack_require__(24089);
120437
+ /* harmony import */ var _errors_RuntimeExpressionError_ts__WEBPACK_IMPORTED_MODULE_59__ = __webpack_require__(48770);
120438
+ /* harmony import */ var _errors_CriterionError_ts__WEBPACK_IMPORTED_MODULE_60__ = __webpack_require__(41233);
120439
+ /* harmony import */ var _errors_CriterionEvaluationError_ts__WEBPACK_IMPORTED_MODULE_61__ = __webpack_require__(71731);
120440
+ /* harmony import */ var _errors_ResolverError_ts__WEBPACK_IMPORTED_MODULE_62__ = __webpack_require__(8696);
120441
+ /* harmony import */ var _errors_ExecutionError_ts__WEBPACK_IMPORTED_MODULE_63__ = __webpack_require__(17658);
120074
120442
  /* Runner */
120075
120443
 
120076
120444
 
@@ -120146,6 +120514,8 @@ __webpack_require__.r(__webpack_exports__);
120146
120514
  /* Observability */
120147
120515
 
120148
120516
 
120517
+
120518
+
120149
120519
  /* Errors */
120150
120520
 
120151
120521