@midscene/core 1.15.2-beta-20261012123219.0 → 1.15.2

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 (180) hide show
  1. package/dist/es/agent/action-readiness.mjs +6 -3
  2. package/dist/es/agent/action-readiness.mjs.map +1 -1
  3. package/dist/es/agent/agent.mjs +4 -2
  4. package/dist/es/agent/agent.mjs.map +1 -1
  5. package/dist/es/agent/execution-session.mjs.map +1 -1
  6. package/dist/es/agent/task-builder.mjs +35 -16
  7. package/dist/es/agent/task-builder.mjs.map +1 -1
  8. package/dist/es/agent/tasks.mjs +35 -12
  9. package/dist/es/agent/tasks.mjs.map +1 -1
  10. package/dist/es/agent/utils.mjs +1 -1
  11. package/dist/es/device/index.mjs +7 -6
  12. package/dist/es/device/index.mjs.map +1 -1
  13. package/dist/es/report-generator.mjs +30 -14
  14. package/dist/es/report-generator.mjs.map +1 -1
  15. package/dist/es/report-html-template.mjs +1 -1
  16. package/dist/es/report.mjs +121 -44
  17. package/dist/es/report.mjs.map +1 -1
  18. package/dist/es/service/index.mjs.map +1 -1
  19. package/dist/es/task-runner.mjs +22 -12
  20. package/dist/es/task-runner.mjs.map +1 -1
  21. package/dist/es/test-run-report.mjs.map +1 -1
  22. package/dist/es/test-runner/engine/case-runner.mjs +1 -1
  23. package/dist/es/test-runner/engine/case-runner.mjs.map +1 -1
  24. package/dist/es/test-runner/engine/document-runtime.mjs +42 -12
  25. package/dist/es/test-runner/engine/document-runtime.mjs.map +1 -1
  26. package/dist/es/test-runner/engine/execute-step.mjs +130 -12
  27. package/dist/es/test-runner/engine/execute-step.mjs.map +1 -1
  28. package/dist/es/test-runner/engine/index.mjs +1 -0
  29. package/dist/es/test-runner/engine/project-runtime.mjs +14 -5
  30. package/dist/es/test-runner/engine/project-runtime.mjs.map +1 -1
  31. package/dist/es/test-runner/engine/resource-operations.mjs +286 -35
  32. package/dist/es/test-runner/engine/resource-operations.mjs.map +1 -1
  33. package/dist/es/test-runner/engine/result-metadata.mjs +21 -0
  34. package/dist/es/test-runner/engine/result-metadata.mjs.map +1 -0
  35. package/dist/es/test-runner/engine/run-collected-case.mjs +30 -9
  36. package/dist/es/test-runner/engine/run-collected-case.mjs.map +1 -1
  37. package/dist/es/test-runner/engine/run-workflow-document.mjs +57 -10
  38. package/dist/es/test-runner/engine/run-workflow-document.mjs.map +1 -1
  39. package/dist/es/test-runner/errors.mjs +26 -13
  40. package/dist/es/test-runner/errors.mjs.map +1 -1
  41. package/dist/es/test-runner/execution-record.mjs +2 -0
  42. package/dist/es/test-runner/execution-record.mjs.map +1 -1
  43. package/dist/es/test-runner/index.mjs +3 -0
  44. package/dist/es/test-runner/reporting/agent-report.mjs +2 -7
  45. package/dist/es/test-runner/reporting/agent-report.mjs.map +1 -1
  46. package/dist/es/test-runner/reporting/merge-report.mjs +207 -6
  47. package/dist/es/test-runner/reporting/merge-report.mjs.map +1 -1
  48. package/dist/es/test-runner/reporting/metrics.mjs +77 -0
  49. package/dist/es/test-runner/reporting/metrics.mjs.map +1 -0
  50. package/dist/es/test-runner/reporting/sanitize.mjs +92 -16
  51. package/dist/es/test-runner/reporting/sanitize.mjs.map +1 -1
  52. package/dist/es/test-runner/reporting/test-plan.mjs +56 -0
  53. package/dist/es/test-runner/reporting/test-plan.mjs.map +1 -0
  54. package/dist/es/test-runner/reporting/test-run-report.mjs +208 -21
  55. package/dist/es/test-runner/reporting/test-run-report.mjs.map +1 -1
  56. package/dist/es/types.mjs.map +1 -1
  57. package/dist/es/utils.mjs +1 -1
  58. package/dist/es/yaml/legacy-yaml-runtime.mjs +3 -3
  59. package/dist/es/yaml/legacy-yaml-runtime.mjs.map +1 -1
  60. package/dist/lib/agent/action-readiness.js +6 -3
  61. package/dist/lib/agent/action-readiness.js.map +1 -1
  62. package/dist/lib/agent/agent.js +4 -2
  63. package/dist/lib/agent/agent.js.map +1 -1
  64. package/dist/lib/agent/execution-session.js.map +1 -1
  65. package/dist/lib/agent/task-builder.js +42 -23
  66. package/dist/lib/agent/task-builder.js.map +1 -1
  67. package/dist/lib/agent/tasks.js +35 -12
  68. package/dist/lib/agent/tasks.js.map +1 -1
  69. package/dist/lib/agent/utils.js +1 -1
  70. package/dist/lib/device/index.js +7 -6
  71. package/dist/lib/device/index.js.map +1 -1
  72. package/dist/lib/report-generator.js +30 -14
  73. package/dist/lib/report-generator.js.map +1 -1
  74. package/dist/lib/report-html-template.js +1 -1
  75. package/dist/lib/report.js +121 -44
  76. package/dist/lib/report.js.map +1 -1
  77. package/dist/lib/service/index.js.map +1 -1
  78. package/dist/lib/task-runner.js +22 -12
  79. package/dist/lib/task-runner.js.map +1 -1
  80. package/dist/lib/test-run-report.js.map +1 -1
  81. package/dist/lib/test-runner/engine/case-runner.js +1 -1
  82. package/dist/lib/test-runner/engine/case-runner.js.map +1 -1
  83. package/dist/lib/test-runner/engine/document-runtime.js +41 -11
  84. package/dist/lib/test-runner/engine/document-runtime.js.map +1 -1
  85. package/dist/lib/test-runner/engine/execute-step.js +131 -10
  86. package/dist/lib/test-runner/engine/execute-step.js.map +1 -1
  87. package/dist/lib/test-runner/engine/index.js +9 -2
  88. package/dist/lib/test-runner/engine/index.js.map +1 -1
  89. package/dist/lib/test-runner/engine/project-runtime.js +13 -4
  90. package/dist/lib/test-runner/engine/project-runtime.js.map +1 -1
  91. package/dist/lib/test-runner/engine/resource-operations.js +319 -38
  92. package/dist/lib/test-runner/engine/resource-operations.js.map +1 -1
  93. package/dist/lib/test-runner/engine/result-metadata.js +58 -0
  94. package/dist/lib/test-runner/engine/result-metadata.js.map +1 -0
  95. package/dist/lib/test-runner/engine/run-collected-case.js +29 -8
  96. package/dist/lib/test-runner/engine/run-collected-case.js.map +1 -1
  97. package/dist/lib/test-runner/engine/run-workflow-document.js +57 -10
  98. package/dist/lib/test-runner/engine/run-workflow-document.js.map +1 -1
  99. package/dist/lib/test-runner/errors.js +42 -23
  100. package/dist/lib/test-runner/errors.js.map +1 -1
  101. package/dist/lib/test-runner/execution-record.js +2 -0
  102. package/dist/lib/test-runner/execution-record.js.map +1 -1
  103. package/dist/lib/test-runner/index.js +88 -16
  104. package/dist/lib/test-runner/index.js.map +1 -1
  105. package/dist/lib/test-runner/node/index.js +2 -2
  106. package/dist/lib/test-runner/reporting/agent-report.js +2 -7
  107. package/dist/lib/test-runner/reporting/agent-report.js.map +1 -1
  108. package/dist/lib/test-runner/reporting/merge-report.js +207 -6
  109. package/dist/lib/test-runner/reporting/merge-report.js.map +1 -1
  110. package/dist/lib/test-runner/reporting/metrics.js +114 -0
  111. package/dist/lib/test-runner/reporting/metrics.js.map +1 -0
  112. package/dist/lib/test-runner/reporting/sanitize.js +94 -15
  113. package/dist/lib/test-runner/reporting/sanitize.js.map +1 -1
  114. package/dist/lib/test-runner/reporting/test-plan.js +90 -0
  115. package/dist/lib/test-runner/reporting/test-plan.js.map +1 -0
  116. package/dist/lib/test-runner/reporting/test-run-report.js +208 -21
  117. package/dist/lib/test-runner/reporting/test-run-report.js.map +1 -1
  118. package/dist/lib/types.js.map +1 -1
  119. package/dist/lib/utils.js +1 -1
  120. package/dist/lib/yaml/legacy-yaml-runtime.js +2 -2
  121. package/dist/lib/yaml/legacy-yaml-runtime.js.map +1 -1
  122. package/dist/types/agent/action-readiness.d.ts +1 -1
  123. package/dist/types/agent/action-readiness.d.ts.map +1 -1
  124. package/dist/types/agent/agent.d.ts +1 -1
  125. package/dist/types/agent/agent.d.ts.map +1 -1
  126. package/dist/types/agent/execution-session.d.ts +1 -1
  127. package/dist/types/agent/execution-session.d.ts.map +1 -1
  128. package/dist/types/agent/task-builder.d.ts +4 -2
  129. package/dist/types/agent/task-builder.d.ts.map +1 -1
  130. package/dist/types/agent/tasks.d.ts +3 -0
  131. package/dist/types/agent/tasks.d.ts.map +1 -1
  132. package/dist/types/device/index.d.ts +3 -3
  133. package/dist/types/device/index.d.ts.map +1 -1
  134. package/dist/types/report-generator.d.ts +4 -2
  135. package/dist/types/report-generator.d.ts.map +1 -1
  136. package/dist/types/report.d.ts.map +1 -1
  137. package/dist/types/service/index.d.ts +2 -2
  138. package/dist/types/service/index.d.ts.map +1 -1
  139. package/dist/types/task-runner.d.ts +1 -1
  140. package/dist/types/task-runner.d.ts.map +1 -1
  141. package/dist/types/test-run-report.d.ts +157 -8
  142. package/dist/types/test-run-report.d.ts.map +1 -1
  143. package/dist/types/test-runner/engine/document-runtime.d.ts.map +1 -1
  144. package/dist/types/test-runner/engine/execute-step.d.ts +1 -0
  145. package/dist/types/test-runner/engine/execute-step.d.ts.map +1 -1
  146. package/dist/types/test-runner/engine/index.d.ts +1 -0
  147. package/dist/types/test-runner/engine/index.d.ts.map +1 -1
  148. package/dist/types/test-runner/engine/project-runtime.d.ts.map +1 -1
  149. package/dist/types/test-runner/engine/resource-operations.d.ts +41 -3
  150. package/dist/types/test-runner/engine/resource-operations.d.ts.map +1 -1
  151. package/dist/types/test-runner/engine/result-metadata.d.ts +18 -0
  152. package/dist/types/test-runner/engine/result-metadata.d.ts.map +1 -0
  153. package/dist/types/test-runner/engine/run-collected-case.d.ts.map +1 -1
  154. package/dist/types/test-runner/engine/run-workflow-document.d.ts.map +1 -1
  155. package/dist/types/test-runner/engine/types.d.ts +47 -8
  156. package/dist/types/test-runner/engine/types.d.ts.map +1 -1
  157. package/dist/types/test-runner/errors.d.ts +7 -0
  158. package/dist/types/test-runner/errors.d.ts.map +1 -1
  159. package/dist/types/test-runner/execution-record.d.ts.map +1 -1
  160. package/dist/types/test-runner/index.d.ts +2 -0
  161. package/dist/types/test-runner/index.d.ts.map +1 -1
  162. package/dist/types/test-runner/node/types.d.ts +9 -1
  163. package/dist/types/test-runner/node/types.d.ts.map +1 -1
  164. package/dist/types/test-runner/parser/types.d.ts +5 -0
  165. package/dist/types/test-runner/parser/types.d.ts.map +1 -1
  166. package/dist/types/test-runner/reporting/agent-report.d.ts.map +1 -1
  167. package/dist/types/test-runner/reporting/merge-report.d.ts +1 -1
  168. package/dist/types/test-runner/reporting/merge-report.d.ts.map +1 -1
  169. package/dist/types/test-runner/reporting/metrics.d.ts +7 -0
  170. package/dist/types/test-runner/reporting/metrics.d.ts.map +1 -0
  171. package/dist/types/test-runner/reporting/sanitize.d.ts +1 -0
  172. package/dist/types/test-runner/reporting/sanitize.d.ts.map +1 -1
  173. package/dist/types/test-runner/reporting/test-plan.d.ts +8 -0
  174. package/dist/types/test-runner/reporting/test-plan.d.ts.map +1 -0
  175. package/dist/types/test-runner/reporting/test-run-report.d.ts.map +1 -1
  176. package/dist/types/test-runner/reporting/types.d.ts +6 -1
  177. package/dist/types/test-runner/reporting/types.d.ts.map +1 -1
  178. package/dist/types/types.d.ts +3 -1
  179. package/dist/types/types.d.ts.map +1 -1
  180. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"test-runner/engine/resource-operations.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/test-runner/engine/resource-operations.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { WorkflowError } from '../errors';\n\ninterface CleanupOwner {\n resources: Set<object>;\n signal?: AbortSignal;\n}\n\ninterface ResourceScope {\n operations: Map<object, number>;\n resources?: Set<object>;\n}\n\ninterface ResourceHandle {\n operations: Map<Promise<unknown>, AbortSignal>;\n retiring: Set<CleanupOwner>;\n cleanup?: Promise<unknown>;\n}\n\ninterface ResourceState {\n resources: WeakMap<object, ResourceHandle>;\n scopes: WeakMap<AbortSignal, ResourceScope>;\n parents: WeakMap<AbortSignal, AbortSignal>;\n cleanupOwners: WeakMap<AbortSignal, CleanupOwner>;\n}\n\n// CJS and ESM hosts must agree about ownership of the same Agent instance.\nconst stateKey = Symbol.for('@midscene/core/resource-operations/v3');\nconst host = globalThis as typeof globalThis & { [stateKey]?: ResourceState };\nhost[stateKey] ??= {\n resources: new WeakMap(),\n scopes: new WeakMap(),\n parents: new WeakMap(),\n cleanupOwners: new WeakMap(),\n};\nconst { resources, scopes, parents, cleanupOwners } = host[stateKey];\nconst resourceHandle = (resource: object): ResourceHandle => {\n let handle = resources.get(resource);\n if (!handle) {\n handle = { operations: new Map(), retiring: new Set() };\n resources.set(resource, handle);\n }\n return handle;\n};\n\n/** Actual teardown completion belongs to the owner, never to a thrown error. */\nexport const getResourceCleanupCompletion = (\n owner: object,\n): Promise<unknown> | undefined => resources.get(owner)?.cleanup;\n\nexport const RESOURCE_CLEANUP_GRACE_MS = 1000;\nexport const RESOURCE_RECOVERY_GRACE_MS = 30_000;\n\n/** Resource ancestry is independent of cancellation: cleanup can outlive abort. */\nexport function linkResourceSignal(signal: AbortSignal, parent?: AbortSignal) {\n if (parent && parent !== signal) parents.set(signal, parent);\n}\n\nfunction* ownerSignals(signal?: AbortSignal): Generator<AbortSignal> {\n const seen = new Set<AbortSignal>();\n for (\n let owner = signal;\n owner && !seen.has(owner);\n owner = parents.get(owner)\n ) {\n seen.add(owner);\n yield owner;\n }\n}\n\n/** Each Case/document owns its cleanup, even when cancellation is shared. */\nexport function createResourceScope(parent?: AbortSignal) {\n const controller = new AbortController();\n const scope: ResourceScope = { operations: new Map(), resources: new Set() };\n scopes.set(controller.signal, scope);\n linkResourceSignal(controller.signal, parent);\n const abort = () => controller.abort(parent?.reason);\n if (parent?.aborted) abort();\n else parent?.addEventListener('abort', abort, { once: true });\n return {\n signal: controller.signal,\n dispose() {\n parent?.removeEventListener('abort', abort);\n scope.resources = undefined;\n if (!scope.operations.size) scopes.delete(controller.signal);\n },\n };\n}\n\nexport function assertResourceAvailable(\n resource: object,\n exclusive = false,\n signal?: AbortSignal,\n): boolean {\n const retiringOwners = resources.get(resource)?.retiring;\n const isOwnerCleanup = [...ownerSignals(signal)].some((ownerSignal) => {\n const owner = cleanupOwners.get(ownerSignal);\n return owner !== undefined && retiringOwners?.has(owner);\n });\n if (retiringOwners?.size && !isOwnerCleanup)\n throw new WorkflowError(\n 'A resource cannot execute overlapping Runner operations while its cleanup is pending.',\n { code: 'RESOURCE_CLEANUP_PENDING' },\n );\n const pending = resources.get(resource)?.operations;\n if (exclusive && pending?.size && !isOwnerCleanup)\n throw new WorkflowError(\n 'The same Agent instance cannot execute overlapping Runner operations.',\n { code: 'RESOURCE_OPERATION_PENDING' },\n );\n if (\n pending &&\n !isOwnerCleanup &&\n [...pending.values()].some((signal) => signal.aborted)\n )\n throw new WorkflowError(\n 'Cannot reuse an Agent while an aborted YAML action or Runner operation is still running.',\n { code: 'RESOURCE_OPERATION_PENDING' },\n );\n return isOwnerCleanup;\n}\n\nconst retainForCleanup = (owner: CleanupOwner, resource: object) => {\n owner.resources.add(resource);\n resourceHandle(resource).retiring.add(owner);\n};\n\n/** Track actual completion, not the Runner timeout race. */\nexport function trackResourceOperation<T>(\n resource: object,\n operation: Promise<T>,\n signal: AbortSignal,\n): Promise<T> {\n const active = resourceHandle(resource).operations;\n active.set(operation, signal);\n const ownerScopes: Array<[AbortSignal, ResourceScope]> = [];\n let retainedByScope = false;\n for (const ownerSignal of ownerSignals(signal)) {\n const scope: ResourceScope = scopes.get(ownerSignal) ?? {\n operations: new Map(),\n };\n scopes.set(ownerSignal, scope);\n scope.operations.set(resource, (scope.operations.get(resource) ?? 0) + 1);\n ownerScopes.push([ownerSignal, scope]);\n // Only the closest owner retains idle resources for its teardown. Parents\n // wait on active operations, not every Agent used by completed Cases.\n if (!retainedByScope && scope.resources) {\n scope.resources.add(resource);\n retainedByScope = true;\n }\n const cleanupOwner = cleanupOwners.get(ownerSignal);\n if (cleanupOwner) retainForCleanup(cleanupOwner, resource);\n }\n const finish = () => {\n active.delete(operation);\n for (const [ownerSignal, scope] of ownerScopes) {\n const count = scope.operations.get(resource)! - 1;\n if (count) scope.operations.set(resource, count);\n else scope.operations.delete(resource);\n if (!scope.operations.size && !scope.resources)\n scopes.delete(ownerSignal);\n }\n };\n void operation.then(finish, finish);\n return operation;\n}\n\nexport async function waitForResourceIdle(resource: object): Promise<void> {\n while (resources.get(resource)?.operations?.size)\n await Promise.allSettled([...resources.get(resource)!.operations.keys()]);\n}\n\n/** Wait for this scope's cancelled work before scheduling its next Step. */\nexport async function recoverCancelledScopeResources(\n signal: AbortSignal,\n graceMs = RESOURCE_RECOVERY_GRACE_MS,\n): Promise<void> {\n signal.throwIfAborted();\n const pendingOperations = () => {\n const pending: Array<{\n operation: Promise<unknown>;\n signal: AbortSignal;\n resource: object;\n }> = [];\n for (const resource of scopes.get(signal)?.operations.keys() ?? []) {\n for (const [operation, ownerSignal] of resources.get(resource)\n ?.operations ?? []) {\n if (\n ownerSignal.aborted &&\n [...ownerSignals(ownerSignal)].includes(signal)\n )\n pending.push({ operation, signal: ownerSignal, resource });\n }\n }\n return pending;\n };\n let pending = pendingOperations();\n if (!pending.length) return;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let onAbort!: () => void;\n const stopped = new Promise<never>((_resolve, reject) => {\n onAbort = () => reject(signal.reason);\n signal.addEventListener('abort', onAbort, { once: true });\n timer = setTimeout(\n () =>\n reject(\n new WorkflowError(\n `Cancelled operations did not finish within ${graceMs}ms; execution cannot continue safely.`,\n {\n code: 'RESOURCE_RECOVERY_TIMEOUT',\n details: {\n graceMs,\n resourceCount: new Set(pending.map(({ resource }) => resource))\n .size,\n },\n cause: pending[0]?.signal.reason,\n },\n ),\n ),\n graceMs,\n );\n });\n try {\n while (pending.length) {\n await Promise.race([\n Promise.allSettled(pending.map(({ operation }) => operation)),\n stopped,\n ]);\n signal.throwIfAborted();\n pending = pendingOperations();\n }\n } finally {\n clearTimeout(timer);\n signal.removeEventListener('abort', onAbort);\n }\n}\n\nexport class ResourceCleanupDeferredError extends WorkflowError {\n constructor(graceMs: number, resourceCount: number) {\n super(\n 'Resource cleanup was deferred because an operation did not stop after cancellation. The resource remains quarantined and cleanup will run when that operation settles.',\n {\n code: 'RESOURCE_CLEANUP_DEFERRED',\n details: { graceMs, resourceCount },\n },\n );\n }\n}\n\ninterface CleanupOptions {\n /** Stable owner of this cleanup, distinct from borrowed resource identities. */\n owner?: object;\n /** Parent scope observes deferred completion without host-specific forwarding. */\n signal?: AbortSignal;\n graceMs?: number;\n onDeferredError(error: unknown): void;\n}\n\n/** Bound draining, but keep ownership until the actual cleanup has finished. */\nasync function runResourceCleanup<T>(\n resources: readonly object[],\n cleanup: () => Promise<T>,\n options: CleanupOptions,\n beforeCleanup?: {\n signal: AbortSignal;\n run(signal: AbortSignal): Promise<void>;\n },\n): Promise<T> {\n const owner: CleanupOwner = {\n resources: new Set(),\n signal: beforeCleanup?.signal,\n };\n for (const resource of resources) retainForCleanup(owner, resource);\n if (owner.signal) cleanupOwners.set(owner.signal, owner);\n\n let defer!: () => void;\n const deferred = new Promise<{ deferred: true }>((resolve) => {\n defer = () => resolve({ deferred: true });\n });\n const graceMs = options.graceMs ?? RESOURCE_CLEANUP_GRACE_MS;\n const drain = async () => {\n const pending = [...owner.resources].filter(\n (resource) => resourceHandle(resource).operations.size,\n );\n if (!pending.length) return;\n const timer = setTimeout(defer, graceMs);\n try {\n await Promise.all(pending.map(waitForResourceIdle));\n } finally {\n clearTimeout(timer);\n }\n };\n const completion = (async () => {\n try {\n if (beforeCleanup) {\n // Authored lifecycle cleanup must be allowed to stop or reset a\n // resource whose timed-out operation is still settling. Its signal is\n // registered as the retiring owner's cleanup signal, so unrelated\n // scopes remain quarantined while this hook runs.\n await beforeCleanup.run(beforeCleanup.signal);\n }\n // Lifecycle hooks can themselves time out with an action still running.\n // Drain both the original work and any operation started by the hook\n // before disposing the resource.\n await drain();\n return await cleanup();\n } finally {\n if (owner.signal) cleanupOwners.delete(owner.signal);\n for (const resource of owner.resources) {\n const owners = resourceHandle(resource).retiring;\n owners.delete(owner);\n }\n }\n })();\n const ownerKey = options.owner ?? beforeCleanup?.signal ?? resources[0];\n if (ownerKey) resourceHandle(ownerKey).cleanup = completion;\n const outcome = await Promise.race([\n completion.then((value) => ({ value })),\n deferred,\n ]);\n if ('deferred' in outcome) {\n void completion.catch((error) => {\n try {\n options.onDeferredError(error);\n } catch {\n // The returned completion still carries the original cleanup failure.\n }\n });\n if (options.signal) trackResourceOperation({}, completion, options.signal);\n throw new ResourceCleanupDeferredError(graceMs, owner.resources.size);\n }\n return outcome.value;\n}\n\nexport function cleanupResources<T>(\n resources: readonly object[],\n cleanup: () => Promise<T>,\n options: CleanupOptions,\n): Promise<T> {\n return runResourceCleanup(resources, cleanup, options);\n}\n\nexport async function cleanupScopeResources<T>(\n signal: AbortSignal,\n cleanup: () => Promise<T>,\n options: CleanupOptions & {\n beforeCleanup?(signal: AbortSignal): Promise<void>;\n },\n): Promise<T> {\n const cleanupSignal = new AbortController().signal;\n linkResourceSignal(cleanupSignal, signal);\n const scope = scopes.get(signal);\n return runResourceCleanup(\n [...(scope?.resources ?? []), ...(scope?.operations.keys() ?? [])],\n cleanup,\n { ...options, owner: signal, signal },\n options.beforeCleanup\n ? { signal: cleanupSignal, run: options.beforeCleanup }\n : undefined,\n );\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","stateKey","host","globalThis","WeakMap","resources","scopes","parents","cleanupOwners","resourceHandle","resource","handle","Map","Set","getResourceCleanupCompletion","owner","RESOURCE_CLEANUP_GRACE_MS","RESOURCE_RECOVERY_GRACE_MS","linkResourceSignal","signal","parent","ownerSignals","seen","createResourceScope","controller","AbortController","scope","abort","undefined","assertResourceAvailable","exclusive","retiringOwners","isOwnerCleanup","ownerSignal","WorkflowError","pending","retainForCleanup","trackResourceOperation","operation","active","ownerScopes","retainedByScope","cleanupOwner","finish","count","waitForResourceIdle","Promise","recoverCancelledScopeResources","graceMs","pendingOperations","timer","onAbort","stopped","_resolve","reject","setTimeout","clearTimeout","ResourceCleanupDeferredError","resourceCount","runResourceCleanup","cleanup","options","beforeCleanup","defer","deferred","resolve","drain","completion","owners","ownerKey","outcome","value","error","cleanupResources","cleanupScopeResources","cleanupSignal"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;;;;ACoBA,MAAMI,WAAWD,OAAO,GAAG,CAAC;AAC5B,MAAME,OAAOC;AACbD,IAAI,CAACD,SAAS,KAAK;IACjB,WAAW,IAAIG;IACf,QAAQ,IAAIA;IACZ,SAAS,IAAIA;IACb,eAAe,IAAIA;AACrB;AACA,MAAM,EAAEC,WAAS,+BAAEC,MAAM,EAAEC,OAAO,EAAEC,aAAa,EAAE,GAAGN,IAAI,CAACD,SAAS;AACpE,MAAMQ,iBAAiB,CAACC;IACtB,IAAIC,SAASN,8BAAU,GAAG,CAACK;IAC3B,IAAI,CAACC,QAAQ;QACXA,SAAS;YAAE,YAAY,IAAIC;YAAO,UAAU,IAAIC;QAAM;QACtDR,8BAAU,GAAG,CAACK,UA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C,OAAuB;IAEvB,OAAOF,mBAAmBtD,WAAWuD,SAASC;AAChD;AAEO,eAAea,sBACpBvD,MAAmB,EACnByC,OAAyB,EACzBC,OAEC;IAED,MAAMc,gBAAgB,IAAIlD,kBAAkB,MAAM;IAClDP,mBAAmByD,eAAexD;IAClC,MAAMO,QAAQpB,OAAO,GAAG,CAACa;IACzB,OAAOwC,mBACL;WAAKjC,OAAO,aAAa,EAAE;WAAOA,OAAO,WAAW,UAAU,EAAE;KAAE,EAClEkC,SACA;QAAE,GAAGC,OAAO;QAAE,OAAO1C;QAAQA;IAAO,GACpC0C,QAAQ,aAAa,GACjB;QAAE,QAAQc;QAAe,KAAKd,QAAQ,aAAa;IAAC,IACpDjC;AAER"}
1
+ {"version":3,"file":"test-runner/engine/resource-operations.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/test-runner/engine/resource-operations.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { getDebug } from '@midscene/shared/logger';\nimport { uuid } from '@midscene/shared/utils';\nimport type {\n TestRunReportCleanup,\n TestRunReportOperationEvent,\n TestRunReportOperationReference,\n} from '../../test-run-report';\nimport { WorkflowError } from '../errors';\nimport { sanitizeReportError } from '../reporting/sanitize';\n\ninterface OperationIdentity {\n scopeId: string;\n stepId?: string;\n node?: string;\n}\ninterface ResourceOperation {\n signal: AbortSignal;\n operationId: string;\n identity?: OperationIdentity;\n settled?: boolean;\n blockers?: Set<ResourceOperation>;\n}\ntype OperationListener = (event: Readonly<TestRunReportOperationEvent>) => void;\n\ninterface CleanupOwner {\n resources: Set<object>;\n signal?: AbortSignal;\n blockers: Set<ResourceOperation>;\n}\n\ninterface ResourceScope {\n operations: Map<object, number>;\n resources?: Set<object>;\n cleanupOwner?: CleanupOwner;\n}\n\ninterface ResourceHandle {\n operations: Map<Promise<unknown>, ResourceOperation>;\n retiring: Set<CleanupOwner>;\n cleanup?: Promise<unknown>;\n cleanupState?: {\n operationId?: string;\n status: 'pending' | 'completed' | 'failed';\n blockers: Set<ResourceOperation>;\n error?: unknown;\n };\n}\n\ninterface ResourceState {\n resources: WeakMap<object, ResourceHandle>;\n scopes: WeakMap<AbortSignal, ResourceScope>;\n parents: WeakMap<AbortSignal, AbortSignal>;\n cleanupOwners: WeakMap<AbortSignal, CleanupOwner>;\n identities: WeakMap<AbortSignal, OperationIdentity>;\n listeners: WeakMap<AbortSignal, Set<OperationListener>>;\n}\n\n// CJS and ESM hosts must agree about ownership of the same Agent instance.\nconst admissionErrorKey = Symbol.for('@midscene/core/resource-admission-error');\nconst stateKey = Symbol.for('@midscene/core/resource-operations/v4');\nconst host = globalThis as typeof globalThis & { [stateKey]?: ResourceState };\nhost[stateKey] ??= {\n resources: new WeakMap(),\n scopes: new WeakMap(),\n parents: new WeakMap(),\n cleanupOwners: new WeakMap(),\n identities: new WeakMap(),\n listeners: new WeakMap(),\n};\nconst { resources, scopes, parents, cleanupOwners, identities, listeners } =\n host[stateKey];\nconst resourceHandle = (resource: object): ResourceHandle => {\n let handle = resources.get(resource);\n if (!handle) {\n handle = {\n operations: new Map(),\n retiring: new Set(),\n };\n resources.set(resource, handle);\n }\n return handle;\n};\n\n/** Actual teardown completion belongs to the owner, never to a thrown error. */\nexport const getResourceCleanupCompletion = (\n owner: object,\n): Promise<unknown> | undefined => resources.get(owner)?.cleanup;\n\nfunction blockingReferences(\n blockers: Iterable<ResourceOperation>,\n): TestRunReportOperationReference[] {\n const references = new Map<string, TestRunReportOperationReference>();\n const visited = new Set<ResourceOperation>();\n const visit = (record: ResourceOperation) => {\n if (visited.has(record)) return;\n visited.add(record);\n if (!record.settled)\n references.set(record.operationId, {\n operationId: record.operationId,\n ...record.identity,\n });\n for (const blocker of record.blockers ?? []) visit(blocker);\n };\n for (const blocker of blockers) visit(blocker);\n return [...references.values()];\n}\n\n/** Read a copy at the publication boundary; never expose the live cleanup state. */\nexport function getResourceCleanupSnapshot(\n owner: object,\n): TestRunReportCleanup {\n const state = resources.get(owner)?.cleanupState;\n return freezeEvent({\n capturedAt: new Date().toISOString(),\n status: state?.status ?? 'not-required',\n ...(state?.operationId ? { operationId: state.operationId } : {}),\n ...(state?.status === 'pending'\n ? { blockingOperations: blockingReferences(state.blockers) }\n : {}),\n ...(state?.error === undefined\n ? {}\n : { error: sanitizeReportError(state.error) }),\n });\n}\n\nexport const RESOURCE_CLEANUP_GRACE_MS = 1000;\nexport const RESOURCE_RECOVERY_GRACE_MS = 30_000;\nconst RESOURCE_TEARDOWN_GRACE_MS = 10_000;\n\nexport function getPendingScopeOperations(\n signal: AbortSignal,\n): TestRunReportOperationReference[] {\n return freezeEvent(\n blockingReferences(\n [...(scopes.get(signal)?.operations.keys() ?? [])].flatMap((resource) => [\n ...(resources.get(resource)?.operations.values() ?? []),\n ]),\n ),\n );\n}\n\n/** Snapshotting must not wait for a timed-out operation to release its resource. */\nexport const hasPendingResourceOperation = (resource: object): boolean =>\n (resources.get(resource)?.operations.size ?? 0) > 0;\n\n/** Resource ancestry is independent of cancellation: cleanup can outlive abort. */\nexport function linkResourceSignal(signal: AbortSignal, parent?: AbortSignal) {\n if (parent && parent !== signal) parents.set(signal, parent);\n}\n\nfunction* ownerSignals(signal?: AbortSignal): Generator<AbortSignal> {\n const seen = new Set<AbortSignal>();\n for (\n let owner = signal;\n owner && !seen.has(owner);\n owner = parents.get(owner)\n ) {\n seen.add(owner);\n yield owner;\n }\n}\n\n/** Each Case/document owns its cleanup, even when cancellation is shared. */\nexport function createResourceScope(parent?: AbortSignal) {\n const controller = new AbortController();\n const scope: ResourceScope = { operations: new Map(), resources: new Set() };\n scopes.set(controller.signal, scope);\n linkResourceSignal(controller.signal, parent);\n const abort = () => controller.abort(parent?.reason);\n if (parent?.aborted) abort();\n else parent?.addEventListener('abort', abort, { once: true });\n return {\n signal: controller.signal,\n dispose() {\n parent?.removeEventListener('abort', abort);\n scope.resources = undefined;\n if (!scope.operations.size) scopes.delete(controller.signal);\n },\n };\n}\n\nexport function assertResourceAvailable(\n resource: object,\n exclusive = false,\n signal?: AbortSignal,\n): boolean {\n const retiringOwners = resources.get(resource)?.retiring;\n const isOwnerCleanup = [...ownerSignals(signal)].some((ownerSignal) => {\n const owner = cleanupOwners.get(ownerSignal);\n return owner !== undefined && retiringOwners?.has(owner);\n });\n if (retiringOwners?.size && !isOwnerCleanup)\n throw new WorkflowError(\n 'A resource cannot execute overlapping Runner operations while its cleanup is pending.',\n { code: 'RESOURCE_CLEANUP_PENDING' },\n );\n const pending = resources.get(resource)?.operations;\n if (exclusive && pending?.size)\n throw new WorkflowError(\n 'The same Agent instance cannot execute overlapping Runner operations.',\n { code: 'RESOURCE_OPERATION_PENDING' },\n );\n if (\n pending &&\n [...pending.values()].some((operation) => operation.signal.aborted)\n )\n throw new WorkflowError(\n 'Cannot reuse an Agent while an aborted YAML action or Runner operation is still running.',\n { code: 'RESOURCE_OPERATION_PENDING' },\n );\n return isOwnerCleanup;\n}\n\n/** Capture subscribers at registration: late settlement stays with its original run. */\nexport function observeResourceOperations(\n signal: AbortSignal,\n listener: OperationListener,\n) {\n const subscribers = listeners.get(signal) ?? new Set<OperationListener>();\n listeners.set(signal, subscribers);\n subscribers.add(listener);\n return () => {\n subscribers.delete(listener);\n if (!subscribers.size) listeners.delete(signal);\n };\n}\n\nexport function setResourceOperationIdentity(\n signal: AbortSignal,\n identity: OperationIdentity,\n) {\n identities.set(signal, Object.freeze({ ...identity }));\n}\n\nfunction freezeEvent<T>(value: T): T {\n if (typeof value === 'object' && value !== null && !Object.isFrozen(value)) {\n for (const child of Object.values(value)) freezeEvent(child);\n Object.freeze(value);\n }\n return value;\n}\n\nexport function recordOperation(\n operation: Promise<unknown>,\n signal: AbortSignal,\n operationKind: TestRunReportOperationEvent['operationKind'],\n) {\n const owners = [...ownerSignals(signal)];\n const identity = owners.map((owner) => identities.get(owner)).find(Boolean);\n const record: ResourceOperation = { signal, operationId: uuid(), identity };\n const subscribers = new Set(\n owners.flatMap((owner) => [...(listeners.get(owner) ?? [])]),\n );\n let settled = false;\n const emit = (\n event: Omit<\n TestRunReportOperationEvent,\n 'operationId' | 'operationKind' | 'at'\n >,\n ) => {\n const frozen = freezeEvent({\n ...identity,\n operationId: record.operationId,\n operationKind,\n at: new Date().toISOString(),\n ...event,\n });\n for (const subscriber of subscribers) {\n try {\n subscriber(frozen);\n } catch (error) {\n getDebug('runner:operations', { console: true })(\n `Operation observer failed: ${String(error)}`,\n );\n }\n }\n };\n const abort = () =>\n emit({\n kind: 'cancel-requested',\n error: sanitizeReportError(signal.reason),\n });\n emit({ kind: 'started' });\n if (signal.aborted) abort();\n else signal.addEventListener('abort', abort, { once: true });\n const finish = (\n status: 'success' | 'failed' | 'not-run',\n error?: unknown,\n ) => {\n settled = true;\n record.settled = true;\n signal.removeEventListener('abort', abort);\n emit({\n kind: 'settled',\n status,\n ...(status !== 'success' ? { error: sanitizeReportError(error) } : {}),\n });\n };\n void operation.then(\n () => finish('success'),\n (error) =>\n finish(isResourceAdmissionError(error) ? 'not-run' : 'failed', error),\n );\n return {\n record,\n runnerReturned(status: 'success' | 'failed' | 'not-run') {\n emit({ kind: 'runner-returned', status, pending: !settled });\n },\n cleanupDeferred(blockers: Iterable<ResourceOperation>) {\n emit({\n kind: 'cleanup-deferred',\n blockingOperations: blockingReferences(blockers),\n });\n },\n };\n}\n\n/** A scheduling decision, distinct from an action that ran and failed. */\nexport class ResourceAdmissionError extends WorkflowError {\n readonly blockedBy?: string;\n readonly [admissionErrorKey] = true;\n constructor(code: string, blockers: readonly ResourceOperation[]) {\n super(\n 'The Agent is occupied by an unfinished operation or pending cleanup; this action was not started.',\n {\n code,\n details: {\n blockingOperations: blockers.map(({ operationId, identity }) => ({\n operationId,\n ...identity,\n })),\n },\n },\n );\n this.blockedBy = blockers.find(\n (blocker) => blocker.identity?.stepId,\n )?.identity?.stepId;\n }\n}\n\nexport function isResourceAdmissionError(\n error: unknown,\n): error is ResourceAdmissionError {\n return (\n typeof error === 'object' &&\n error !== null &&\n (error as ResourceAdmissionError)[admissionErrorKey] === true\n );\n}\n\nexport function admitResourceOperation(\n resource: object,\n signal: AbortSignal,\n exclusive = true,\n): boolean {\n let isCleanupOwner: boolean;\n try {\n isCleanupOwner = assertResourceAvailable(resource, exclusive, signal);\n } catch (error) {\n if (\n error instanceof WorkflowError &&\n ['RESOURCE_OPERATION_PENDING', 'RESOURCE_CLEANUP_PENDING'].includes(\n error.code,\n )\n )\n throw new ResourceAdmissionError(error.code, [\n ...(resources.get(resource)?.operations.values() ?? []),\n ...[...(resources.get(resource)?.retiring ?? [])].flatMap((owner) => [\n ...owner.blockers,\n ]),\n ]);\n throw error;\n }\n return isCleanupOwner;\n}\n\nconst retainForCleanup = (owner: CleanupOwner, resource: object) => {\n owner.resources.add(resource);\n const handle = resourceHandle(resource);\n for (const operation of handle.operations.values())\n owner.blockers.add(operation);\n handle.retiring.add(owner);\n};\n\n/** Acquisition establishes cleanup ownership even if action admission is rejected. */\nexport function retainResourceForScope(resource: object, signal: AbortSignal) {\n let retained = false;\n for (const ownerSignal of ownerSignals(signal)) {\n const scope = scopes.get(ownerSignal);\n if (!retained && scope?.resources) {\n scope.resources.add(resource);\n retained = true;\n }\n if (scope?.cleanupOwner) retainForCleanup(scope.cleanupOwner, resource);\n }\n}\n\n/** Track actual completion, not the Runner timeout race. */\nexport function trackResourceOperation<T>(\n resource: object,\n operation: Promise<T>,\n signal: AbortSignal,\n kind: TestRunReportOperationEvent['operationKind'] = 'resource',\n existingObservation?: ReturnType<typeof recordOperation>,\n): Promise<T> {\n const observation =\n existingObservation ?? recordOperation(operation, signal, kind);\n const active = resourceHandle(resource).operations;\n active.set(operation, observation.record);\n const ownerScopes: Array<[AbortSignal, ResourceScope]> = [];\n let retainedByScope = false;\n for (const ownerSignal of ownerSignals(signal)) {\n const scope: ResourceScope = scopes.get(ownerSignal) ?? {\n operations: new Map(),\n };\n scopes.set(ownerSignal, scope);\n scope.operations.set(resource, (scope.operations.get(resource) ?? 0) + 1);\n ownerScopes.push([ownerSignal, scope]);\n // Only the closest owner retains idle resources for its teardown. Parents\n // wait on active operations, not every Agent used by completed Cases.\n if (!retainedByScope && scope.resources) {\n scope.resources.add(resource);\n retainedByScope = true;\n }\n const cleanupOwner = cleanupOwners.get(ownerSignal);\n if (cleanupOwner) {\n cleanupOwner.blockers.add(observation.record);\n retainForCleanup(cleanupOwner, resource);\n }\n }\n const finish = () => {\n active.delete(operation);\n for (const [ownerSignal, scope] of ownerScopes) {\n const count = scope.operations.get(resource)! - 1;\n if (count) scope.operations.set(resource, count);\n else scope.operations.delete(resource);\n if (!scope.operations.size && !scope.resources)\n scopes.delete(ownerSignal);\n }\n };\n void operation.then(finish, finish);\n return operation;\n}\n\nexport async function waitForResourceIdle(resource: object): Promise<void> {\n while (resources.get(resource)?.operations?.size)\n await Promise.allSettled([...resources.get(resource)!.operations.keys()]);\n}\n\n/** Wait for this scope's cancelled work before scheduling its next Step. */\nexport async function recoverCancelledScopeResources(\n signal: AbortSignal,\n graceMs = RESOURCE_RECOVERY_GRACE_MS,\n): Promise<number> {\n signal.throwIfAborted();\n const startedAt = Date.now();\n const pendingOperations = () => {\n const pending: Array<{\n operation: Promise<unknown>;\n signal: AbortSignal;\n resource: object;\n record: ResourceOperation;\n }> = [];\n for (const resource of scopes.get(signal)?.operations.keys() ?? []) {\n for (const [operation, tracked] of resources.get(resource)?.operations ??\n []) {\n const ownerSignal = tracked.signal;\n if (\n ownerSignal.aborted &&\n [...ownerSignals(ownerSignal)].includes(signal)\n )\n pending.push({\n operation,\n signal: ownerSignal,\n resource,\n record: tracked,\n });\n }\n }\n return pending;\n };\n let pending = pendingOperations();\n if (!pending.length) return 0;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let onAbort!: () => void;\n const stopped = new Promise<never>((_resolve, reject) => {\n onAbort = () => reject(signal.reason);\n signal.addEventListener('abort', onAbort, { once: true });\n timer = setTimeout(() => {\n const blockingOperations = blockingReferences(\n pending.map(({ record }) => record),\n );\n const blockedByStepId = blockingOperations.every(\n ({ stepId }) => stepId === blockingOperations[0]?.stepId,\n )\n ? blockingOperations[0]?.stepId\n : undefined;\n reject(\n new WorkflowError(\n `The previous operation was still running after ${graceMs / 1000} s. Later steps were not started.`,\n {\n code: 'RESOURCE_RECOVERY_TIMEOUT',\n details: {\n graceMs,\n waitedMs: Date.now() - startedAt,\n resourceCount: new Set(pending.map(({ resource }) => resource))\n .size,\n blockingOperations,\n blockedByStepId,\n },\n cause: pending[0]?.signal.reason,\n },\n ),\n );\n }, graceMs);\n });\n try {\n while (pending.length) {\n await Promise.race([\n Promise.allSettled(pending.map(({ operation }) => operation)),\n stopped,\n ]);\n signal.throwIfAborted();\n pending = pendingOperations();\n }\n return Date.now() - startedAt;\n } finally {\n clearTimeout(timer);\n signal.removeEventListener('abort', onAbort);\n }\n}\n\nexport class ResourceCleanupDeferredError extends WorkflowError {\n constructor(\n graceMs: number,\n resourceCount: number,\n blockers: readonly ResourceOperation[] = [],\n ) {\n super(\n `Resource cleanup did not finish within ${graceMs}ms. Resources remain quarantined until cleanup settles.`,\n {\n code: 'RESOURCE_CLEANUP_DEFERRED',\n details: {\n graceMs,\n resourceCount,\n blockingOperations: blockers.map(({ operationId, identity }) => ({\n operationId,\n ...identity,\n })),\n },\n },\n );\n }\n}\n\ninterface CleanupOptions {\n /** Stable owner of this cleanup, distinct from borrowed resource identities. */\n owner?: object;\n /** Parent scope observes deferred completion without host-specific forwarding. */\n signal?: AbortSignal;\n graceMs?: number;\n onDeferredError(error: unknown): void;\n}\n\n/** Bound waiting, but keep ownership until the actual cleanup has finished. */\nasync function runResourceCleanup<T>(\n resources: readonly object[],\n cleanup: () => Promise<T>,\n options: CleanupOptions,\n beforeCleanup?: {\n signal: AbortSignal;\n run(signal: AbortSignal): Promise<void>;\n },\n): Promise<T> {\n const owner: CleanupOwner = {\n resources: new Set(),\n blockers: new Set(),\n signal: beforeCleanup?.signal,\n };\n for (const resource of resources) retainForCleanup(owner, resource);\n if (owner.signal) cleanupOwners.set(owner.signal, owner);\n const ownerScope = options.signal ? scopes.get(options.signal) : undefined;\n if (ownerScope) ownerScope.cleanupOwner = owner;\n\n let defer!: () => void;\n const deferred = new Promise<{ deferred: true }>((resolve) => {\n defer = () => resolve({ deferred: true });\n });\n let graceMs = options.graceMs ?? RESOURCE_CLEANUP_GRACE_MS;\n let timer: ReturnType<typeof setTimeout> | undefined;\n const drain = async () => {\n timer = setTimeout(defer, graceMs);\n try {\n // An acquisition may finish late and add another shared resource to its\n // owner. Keep draining that resource before calling any disposer.\n while (true) {\n const pending = [...owner.resources].filter(\n (resource) => resourceHandle(resource).operations.size,\n );\n if (!pending.length) return;\n await Promise.all(pending.map(waitForResourceIdle));\n }\n } finally {\n clearTimeout(timer);\n }\n };\n const completion = (async () => {\n try {\n if (beforeCleanup) {\n // Hooks may use idle resources owned by this cleanup. Busy resources\n // still reject overlapping actions, including cleanup actions.\n await beforeCleanup.run(beforeCleanup.signal);\n }\n // Lifecycle hooks can themselves time out with an action still running.\n // Drain both the original work and any operation started by the hook\n // before disposing the resource.\n await drain();\n graceMs = options.graceMs ?? RESOURCE_TEARDOWN_GRACE_MS;\n timer = setTimeout(defer, graceMs);\n return await cleanup();\n } finally {\n clearTimeout(timer);\n if (owner.signal) cleanupOwners.delete(owner.signal);\n if (ownerScope?.cleanupOwner === owner)\n ownerScope.cleanupOwner = undefined;\n for (const resource of owner.resources) {\n const owners = resourceHandle(resource).retiring;\n owners.delete(owner);\n }\n }\n })();\n const cleanupObservation = options.signal\n ? recordOperation(completion, options.signal, 'cleanup')\n : undefined;\n const ownerKey = options.owner ?? beforeCleanup?.signal ?? resources[0];\n const cleanupState: NonNullable<ResourceHandle['cleanupState']> = {\n status: 'pending',\n operationId: cleanupObservation?.record.operationId,\n blockers: owner.blockers,\n };\n if (cleanupObservation) cleanupObservation.record.blockers = owner.blockers;\n if (ownerKey) {\n resourceHandle(ownerKey).cleanup = completion;\n resourceHandle(ownerKey).cleanupState = cleanupState;\n }\n void completion.then(\n () => {\n cleanupState.status = 'completed';\n },\n (error) => {\n cleanupState.status = 'failed';\n cleanupState.error = error;\n },\n );\n const outcome = await Promise.race([\n completion.then((value) => ({ value })),\n deferred,\n ]);\n if ('deferred' in outcome) {\n cleanupObservation?.cleanupDeferred(owner.blockers);\n void completion.catch((error) => {\n try {\n options.onDeferredError(error);\n } catch {\n // The returned completion still carries the original cleanup failure.\n }\n });\n if (options.signal)\n trackResourceOperation(\n {},\n completion,\n options.signal,\n 'cleanup',\n cleanupObservation,\n );\n throw new ResourceCleanupDeferredError(graceMs, owner.resources.size, [\n ...owner.blockers,\n ]);\n }\n return outcome.value;\n}\n\nexport function cleanupResources<T>(\n resources: readonly object[],\n cleanup: () => Promise<T>,\n options: CleanupOptions,\n): Promise<T> {\n return runResourceCleanup(resources, cleanup, options);\n}\n\nexport async function cleanupScopeResources<T>(\n signal: AbortSignal,\n cleanup: () => Promise<T>,\n options: CleanupOptions & {\n beforeCleanup?(signal: AbortSignal): Promise<void>;\n },\n): Promise<T> {\n const cleanupSignal = new AbortController().signal;\n linkResourceSignal(cleanupSignal, signal);\n const scope = scopes.get(signal);\n return runResourceCleanup(\n [...(scope?.resources ?? []), ...(scope?.operations.keys() ?? [])],\n cleanup,\n { ...options, owner: signal, signal },\n options.beforeCleanup\n ? { signal: cleanupSignal, run: options.beforeCleanup }\n : undefined,\n );\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","admissionErrorKey","stateKey","host","globalThis","WeakMap","resources","scopes","parents","cleanupOwners","identities","listeners","resourceHandle","resource","handle","Map","Set","getResourceCleanupCompletion","owner","blockingReferences","blockers","references","visited","visit","record","blocker","getResourceCleanupSnapshot","state","freezeEvent","Date","undefined","sanitizeReportError","RESOURCE_CLEANUP_GRACE_MS","RESOURCE_RECOVERY_GRACE_MS","RESOURCE_TEARDOWN_GRACE_MS","getPendingScopeOperations","signal","hasPendingResourceOperation","linkResourceSignal","parent","ownerSignals","seen","createResourceScope","controller","AbortController","scope","abort","assertResourceAvailable","exclusive","retiringOwners","isOwnerCleanup","ownerSignal","WorkflowError","pending","operation","observeResourceOperations","listener","subscribers","setResourceOperationIdentity","identity","value","child","recordOperation","operationKind","owners","Boolean","uuid","settled","emit","event","frozen","subscriber","error","getDebug","String","finish","status","isResourceAdmissionError","_admissionErrorKey","ResourceAdmissionError","code","operationId","admitResourceOperation","isCleanupOwner","retainForCleanup","retainResourceForScope","retained","trackResourceOperation","kind","existingObservation","observation","active","ownerScopes","retainedByScope","cleanupOwner","count","waitForResourceIdle","Promise","recoverCancelledScopeResources","graceMs","startedAt","pendingOperations","tracked","timer","onAbort","stopped","_resolve","reject","setTimeout","blockingOperations","blockedByStepId","stepId","clearTimeout","ResourceCleanupDeferredError","resourceCount","runResourceCleanup","cleanup","options","beforeCleanup","ownerScope","defer","deferred","resolve","drain","completion","cleanupObservation","ownerKey","cleanupState","outcome","cleanupResources","cleanupScopeResources","cleanupSignal"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAA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bd,SAASjF,MAAM,SAAS,CAAC,IAAI,EAAE;eACjEA,MAAM,QAAQ;SAClB;IACH;IACA,OAAO8G,QAAQ,KAAK;AACtB;AAEO,SAASC,iBACd3H,SAA4B,EAC5B8G,OAAyB,EACzBC,OAAuB;IAEvB,OAAOF,mBAAmB7G,WAAW8G,SAASC;AAChD;AAEO,eAAea,sBACpB9F,MAAmB,EACnBgF,OAAyB,EACzBC,OAEC;IAED,MAAMc,gBAAgB,IAAIvF,kBAAkB,MAAM;IAClDN,mBAAmB6F,eAAe/F;IAClC,MAAMS,QAAQtC,OAAO,GAAG,CAAC6B;IACzB,OAAO+E,mBACL;WAAKtE,OAAO,aAAa,EAAE;WAAOA,OAAO,WAAW,UAAU,EAAE;KAAE,EAClEuE,SACA;QAAE,GAAGC,OAAO;QAAE,OAAOjF;QAAQA;IAAO,GACpCiF,QAAQ,aAAa,GACjB;QAAE,QAAQc;QAAe,KAAKd,QAAQ,aAAa;IAAC,IACpDvF;AAER"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ decideRetry: ()=>decideRetry,
28
+ phaseResult: ()=>phaseResult
29
+ });
30
+ function phaseResult(plannedStepCount, steps) {
31
+ const executedStepCount = steps.filter((step)=>'not-run' !== step.status).length;
32
+ return {
33
+ plannedStepCount,
34
+ executedStepCount,
35
+ status: 0 === plannedStepCount ? 'not-required' : steps.some((step)=>'failed' === step.status) ? 'failed' : executedStepCount < plannedStepCount ? 'not-run' : 'success'
36
+ };
37
+ }
38
+ function decideRetry(options) {
39
+ const reason = options.infrastructureError ? 'infrastructure-error' : options.cleanupPending ? 'cleanup-pending' : options.cleanupFailed ? 'cleanup-failed' : options.operationPending ? 'operation-pending' : options.fatalError ? 'fatal-error' : options.interrupted ? 'interrupted' : options.shouldStop ? 'bail' : 'success' === options.status ? 'passed' : options.attemptIndex >= options.retryCount ? 'budget-exhausted' : 'attempt-failed';
40
+ return {
41
+ scope: options.scope,
42
+ retryCount: options.retryCount,
43
+ attemptIndex: options.attemptIndex,
44
+ decision: 'attempt-failed' === reason ? 'retry' : 'stop',
45
+ reason
46
+ };
47
+ }
48
+ exports.decideRetry = __webpack_exports__.decideRetry;
49
+ exports.phaseResult = __webpack_exports__.phaseResult;
50
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
51
+ "decideRetry",
52
+ "phaseResult"
53
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
54
+ Object.defineProperty(exports, '__esModule', {
55
+ value: true
56
+ });
57
+
58
+ //# sourceMappingURL=result-metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-runner/engine/result-metadata.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/test-runner/engine/result-metadata.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type {\n TestRunReportPhaseResult,\n TestRunReportRetryDecision,\n} from '../../test-run-report';\nimport type { StepRunResult } from './types';\n\nexport function phaseResult(\n plannedStepCount: number,\n steps: readonly StepRunResult[],\n): TestRunReportPhaseResult {\n const executedStepCount = steps.filter(\n (step) => step.status !== 'not-run',\n ).length;\n return {\n plannedStepCount,\n executedStepCount,\n status:\n plannedStepCount === 0\n ? 'not-required'\n : steps.some((step) => step.status === 'failed')\n ? 'failed'\n : executedStepCount < plannedStepCount\n ? 'not-run'\n : 'success',\n };\n}\n\n/** Facts at the retry boundary, separate from the eventual cleanup outcome. */\nexport function decideRetry(options: {\n scope: 'case' | 'document';\n retryCount: number;\n attemptIndex: number;\n status: 'success' | 'failed';\n cleanupPending?: boolean;\n cleanupFailed?: boolean;\n operationPending?: boolean;\n infrastructureError?: boolean;\n fatalError?: boolean;\n interrupted?: boolean;\n shouldStop?: boolean;\n}): TestRunReportRetryDecision {\n const reason = options.infrastructureError\n ? 'infrastructure-error'\n : options.cleanupPending\n ? 'cleanup-pending'\n : options.cleanupFailed\n ? 'cleanup-failed'\n : options.operationPending\n ? 'operation-pending'\n : options.fatalError\n ? 'fatal-error'\n : options.interrupted\n ? 'interrupted'\n : options.shouldStop\n ? 'bail'\n : options.status === 'success'\n ? 'passed'\n : options.attemptIndex >= options.retryCount\n ? 'budget-exhausted'\n : 'attempt-failed';\n return {\n scope: options.scope,\n retryCount: options.retryCount,\n attemptIndex: options.attemptIndex,\n decision: reason === 'attempt-failed' ? 'retry' : 'stop',\n reason,\n };\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","phaseResult","plannedStepCount","steps","executedStepCount","step","decideRetry","options","reason"],"mappings":";;;IAAAA,oBAAoB,CAAC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QAC9B,cAAcA,QAAQ,YAAY;QAClC,UAAUC,AAAW,qBAAXA,SAA8B,UAAU;QAClDA;IACF;AACF"}
@@ -32,6 +32,7 @@ const external_errors_js_namespaceObject = require("../errors.js");
32
32
  const external_execute_step_js_namespaceObject = require("./execute-step.js");
33
33
  const external_execution_failure_js_namespaceObject = require("./execution-failure.js");
34
34
  const external_resource_operations_js_namespaceObject = require("./resource-operations.js");
35
+ const external_result_metadata_js_namespaceObject = require("./result-metadata.js");
35
36
  const external_scope_teardown_js_namespaceObject = require("./scope-teardown.js");
36
37
  async function runCollectedCase(collectedCase, options) {
37
38
  const phases = {
@@ -48,9 +49,13 @@ async function runCollectedCase(collectedCase, options) {
48
49
  const scopeSignal = resourceScope.signal;
49
50
  const runId = options.createRunId?.() ?? (0, utils_namespaceObject.uuid)();
50
51
  const startedAt = new Date();
52
+ (0, external_resource_operations_js_namespaceObject.setResourceOperationIdentity)(scopeSignal, {
53
+ scopeId: runId
54
+ });
51
55
  const beforeEach = [];
52
56
  const steps = [];
53
57
  const afterEach = [];
58
+ const capturedSources = new Map();
54
59
  const teardownStack = [];
55
60
  let acceptingTeardowns = true;
56
61
  const onTeardown = (node, teardown)=>{
@@ -70,7 +75,7 @@ async function runCollectedCase(collectedCase, options) {
70
75
  };
71
76
  const runPhase = async (phase, results, signal = scopeSignal)=>{
72
77
  for (const [stepIndex, step] of phases[phase].entries()){
73
- if (stepIndex > 0) await (0, external_resource_operations_js_namespaceObject.recoverCancelledScopeResources)(signal);
78
+ const waitForPreviousOperationMs = stepIndex > 0 ? await (0, external_resource_operations_js_namespaceObject.recoverCancelledScopeResources)(signal) : 0;
74
79
  const caseContext = {
75
80
  caseId: collectedCase.caseId,
76
81
  runId,
@@ -97,15 +102,17 @@ async function runCollectedCase(collectedCase, options) {
97
102
  defaultTimeoutMs: options.defaultTimeoutMs,
98
103
  onTeardown
99
104
  });
105
+ if (waitForPreviousOperationMs > 0) result.waitForPreviousOperationMs = waitForPreviousOperationMs;
100
106
  results.push(result);
107
+ for (const source of result.report?.sources ?? [])capturedSources.set(`${source.sourcePath}\u0000${source.dumpPath ?? ''}`, source);
101
108
  await options.onStepResult?.(stepInfo, result);
102
- if ('failed' === result.status && !result.continuedAfterError) break;
109
+ if ('success' !== result.status && !result.continuedAfterError) break;
103
110
  }
104
111
  };
105
112
  const executionErrors = [];
106
113
  try {
107
114
  await runPhase('beforeEach', beforeEach);
108
- if (!beforeEach.some((step)=>'failed' === step.status)) await runPhase('steps', steps);
115
+ if (!beforeEach.some((step)=>'success' !== step.status)) await runPhase('steps', steps);
109
116
  } catch (error) {
110
117
  executionErrors.push(error);
111
118
  }
@@ -129,12 +136,12 @@ async function runCollectedCase(collectedCase, options) {
129
136
  registrationIndex
130
137
  }));
131
138
  }
132
- if (deferredCleanup) {
139
+ {
133
140
  const errors = [
134
141
  ...cleanupExecutionErrors,
135
142
  ...teardownErrors.slice(priorTeardownErrors)
136
143
  ];
137
- if (errors.length) throw new AggregateError(errors, 'Deferred Case cleanup failed');
144
+ if (errors.length) throw new AggregateError(errors, 'Case cleanup failed');
138
145
  }
139
146
  };
140
147
  try {
@@ -155,7 +162,7 @@ async function runCollectedCase(collectedCase, options) {
155
162
  } catch (error) {
156
163
  deferredCleanup = error instanceof external_resource_operations_js_namespaceObject.ResourceCleanupDeferredError;
157
164
  if (!deferredCleanup) acceptingTeardowns = false;
158
- teardownErrors.push(new external_errors_js_namespaceObject.NodeScopeTeardownError(error, {
165
+ if (!deferredCleanup && !teardownErrors.length && !cleanupExecutionErrors.length) teardownErrors.push(new external_errors_js_namespaceObject.NodeScopeTeardownError(error, {
159
166
  scope: 'case',
160
167
  scopeId: runId,
161
168
  node: 'resource-drain',
@@ -163,6 +170,13 @@ async function runCollectedCase(collectedCase, options) {
163
170
  }));
164
171
  }
165
172
  const endedAt = new Date();
173
+ const cleanupSnapshot = (0, external_resource_operations_js_namespaceObject.getResourceCleanupSnapshot)(scopeSignal);
174
+ const pendingOperations = (0, external_resource_operations_js_namespaceObject.getPendingScopeOperations)(scopeSignal);
175
+ const phaseResults = {
176
+ beforeEach: (0, external_result_metadata_js_namespaceObject.phaseResult)(phases.beforeEach.length, beforeEach),
177
+ steps: (0, external_result_metadata_js_namespaceObject.phaseResult)(phases.steps.length, steps),
178
+ afterEach: (0, external_result_metadata_js_namespaceObject.phaseResult)(phases.afterEach.length, afterEach)
179
+ };
166
180
  const result = {
167
181
  caseId: collectedCase.caseId,
168
182
  runId,
@@ -171,7 +185,7 @@ async function runCollectedCase(collectedCase, options) {
171
185
  name: collectedCase.definition.name,
172
186
  sourcePath: collectedCase.sourcePath,
173
187
  caseIndex: collectedCase.caseIndex,
174
- status: executionErrors.length > 0 || beforeEach.some((step)=>'failed' === step.status) || steps.some((step)=>'failed' === step.status) || afterEach.some((step)=>'failed' === step.status) || teardownErrors.length > 0 ? 'failed' : 'success',
188
+ status: executionErrors.length > 0 || beforeEach.some((step)=>'success' !== step.status) || steps.some((step)=>'success' !== step.status) || afterEach.some((step)=>'success' !== step.status) || 'pending' === cleanupSnapshot.status || 'failed' === cleanupSnapshot.status || pendingOperations.length > 0 || teardownErrors.length > 0 ? 'failed' : 'success',
175
189
  beforeEach: [
176
190
  ...beforeEach
177
191
  ],
@@ -181,6 +195,12 @@ async function runCollectedCase(collectedCase, options) {
181
195
  afterEach: [
182
196
  ...afterEach
183
197
  ],
198
+ executionStatus: Object.values(phaseResults).some((phase)=>'failed' === phase.status) ? 'failed' : Object.values(phaseResults).some((phase)=>'not-run' === phase.status) ? 'not-run' : 'success',
199
+ phases: phaseResults,
200
+ cleanup: cleanupSnapshot,
201
+ ...pendingOperations.length ? {
202
+ pendingOperations
203
+ } : {},
184
204
  ...executionErrors.length ? {
185
205
  executionErrors: executionErrors.map(external_execution_failure_js_namespaceObject.asExecutionError)
186
206
  } : {},
@@ -194,8 +214,9 @@ async function runCollectedCase(collectedCase, options) {
194
214
  ...reportPaths
195
215
  ]
196
216
  } : {},
197
- ...reportSources.length ? {
217
+ ...capturedSources.size || reportSources.length ? {
198
218
  reportSources: [
219
+ ...capturedSources.values(),
199
220
  ...reportSources
200
221
  ]
201
222
  } : {},
@@ -1 +1 @@
1
- {"version":3,"file":"test-runner/engine/run-collected-case.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/test-runner/engine/run-collected-case.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { getDebug } from '@midscene/shared/logger';\nimport { uuid as randomUUID } from '@midscene/shared/utils';\nimport { NodeScopeTeardownError, WorkflowLifecycleError } from '../errors';\nimport type { CollectedCase, NormalizedStep } from '../parser/types';\nimport { executeStep } from './execute-step';\nimport {\n WorkflowExecutionFailure,\n asExecutionError,\n} from './execution-failure';\nimport {\n ResourceCleanupDeferredError,\n cleanupScopeResources,\n createResourceScope,\n recoverCancelledScopeResources,\n} from './resource-operations';\nimport { reportPathsFromTeardown } from './scope-teardown';\nimport type {\n CaseNodePhase,\n CaseRunResult,\n NodeCaseContext,\n NodeScopeTeardown,\n RunCollectedCaseOptions,\n StepRunResult,\n} from './types';\n\nexport async function runCollectedCase<TContext = undefined>(\n collectedCase: CollectedCase,\n options: RunCollectedCaseOptions<TContext>,\n): Promise<CaseRunResult> {\n const phases: Record<CaseNodePhase, readonly NormalizedStep[]> = {\n beforeEach: options.beforeEach ?? [],\n steps: collectedCase.definition.steps,\n afterEach: options.afterEach ?? [],\n };\n const nodes = {\n beforeEach: phases.beforeEach.map((step) => options.resolveNode(step.node)),\n steps: phases.steps.map((step) => options.resolveNode(step.node)),\n afterEach: phases.afterEach.map((step) => options.resolveNode(step.node)),\n };\n const resourceScope = createResourceScope(options.signal);\n const scopeSignal = resourceScope.signal;\n const runId = options.createRunId?.() ?? randomUUID();\n const startedAt = new Date();\n const beforeEach: StepRunResult[] = [];\n const steps: StepRunResult[] = [];\n const afterEach: StepRunResult[] = [];\n const teardownStack: Array<{\n registrationIndex: number;\n node: string;\n teardown: NodeScopeTeardown;\n }> = [];\n let acceptingTeardowns = true;\n\n const onTeardown = (node: string, teardown: NodeScopeTeardown): void => {\n if (!acceptingTeardowns) {\n throw new WorkflowLifecycleError(\n 'Node teardown can only be registered while a case attempt is running.',\n { runId, node },\n );\n }\n if (typeof teardown !== 'function') {\n throw new WorkflowLifecycleError(\n 'Node onTeardown() requires a teardown function.',\n { runId, node },\n );\n }\n teardownStack.push({\n registrationIndex: teardownStack.length,\n node,\n teardown,\n });\n };\n\n const runPhase = async (\n phase: CaseNodePhase,\n results: StepRunResult[],\n signal = scopeSignal,\n ): Promise<void> => {\n for (const [stepIndex, step] of phases[phase].entries()) {\n // A Step timeout ends the Runner's wait, not the underlying operation.\n // Recovery belongs between Steps, outside the next Step's timeout budget.\n if (stepIndex > 0) await recoverCancelledScopeResources(signal);\n const caseContext: NodeCaseContext = {\n caseId: collectedCase.caseId,\n runId,\n projectName: options.projectName ?? collectedCase.projectId,\n attemptIndex: options.attemptIndex ?? 0,\n name: collectedCase.definition.name,\n sourcePath: collectedCase.sourcePath,\n caseIndex: collectedCase.caseIndex,\n phase,\n stepIndex,\n };\n const stepInfo = {\n scope: 'case' as const,\n node: step.node,\n stepCount: phases[phase].length,\n case: caseContext,\n };\n await options.onStepStart?.(stepInfo);\n const result = await executeStep(\n step,\n nodes[phase][stepIndex],\n { scope: 'case', case: caseContext },\n options.context as TContext,\n {\n signal,\n defaultTimeoutMs: options.defaultTimeoutMs,\n onTeardown,\n },\n );\n results.push(result);\n await options.onStepResult?.(stepInfo, result);\n if (result.status === 'failed' && !result.continuedAfterError) break;\n }\n };\n\n const executionErrors: unknown[] = [];\n try {\n await runPhase('beforeEach', beforeEach);\n if (!beforeEach.some((step) => step.status === 'failed')) {\n await runPhase('steps', steps);\n }\n } catch (error) {\n executionErrors.push(error);\n }\n const teardownErrors: NodeScopeTeardownError[] = [];\n const reportPaths = new Set<string>();\n const reportSources: import('./types').WorkflowReportSource[] = [];\n const cleanupExecutionErrors: unknown[] = [];\n let deferredCleanup = false;\n const cleanup = async () => {\n const priorTeardownErrors = teardownErrors.length;\n acceptingTeardowns = false;\n for (const {\n registrationIndex,\n node,\n teardown,\n } of teardownStack.reverse()) {\n try {\n const released = await teardown();\n reportSources.push(...(released?.reportSources ?? []));\n for (const path of reportPathsFromTeardown(released)) {\n reportPaths.add(path);\n }\n } catch (error) {\n teardownErrors.push(\n new NodeScopeTeardownError(error, {\n scope: 'case',\n scopeId: runId,\n node,\n registrationIndex,\n }),\n );\n }\n }\n if (deferredCleanup) {\n const errors = [\n ...cleanupExecutionErrors,\n ...teardownErrors.slice(priorTeardownErrors),\n ];\n if (errors.length)\n throw new AggregateError(errors, 'Deferred Case cleanup failed');\n }\n };\n try {\n if (phases.afterEach.length || teardownStack.length)\n await cleanupScopeResources(scopeSignal, cleanup, {\n beforeCleanup: async (cleanupSignal) => {\n try {\n await runPhase('afterEach', afterEach, cleanupSignal);\n } catch (error) {\n executionErrors.push(error);\n cleanupExecutionErrors.push(error);\n }\n },\n onDeferredError: (error) =>\n getDebug('runner:cleanup', { console: true })(\n `Deferred Case cleanup failed: ${String(error)}`,\n ),\n });\n else acceptingTeardowns = false;\n } catch (error) {\n deferredCleanup = error instanceof ResourceCleanupDeferredError;\n if (!deferredCleanup) acceptingTeardowns = false;\n teardownErrors.push(\n new NodeScopeTeardownError(error, {\n scope: 'case',\n scopeId: runId,\n node: 'resource-drain',\n registrationIndex: -1,\n }),\n );\n }\n const endedAt = new Date();\n const result: CaseRunResult = {\n caseId: collectedCase.caseId,\n runId,\n projectName: options.projectName ?? collectedCase.projectId,\n attemptIndex: options.attemptIndex ?? 0,\n name: collectedCase.definition.name,\n sourcePath: collectedCase.sourcePath,\n caseIndex: collectedCase.caseIndex,\n status:\n executionErrors.length > 0 ||\n beforeEach.some((step) => step.status === 'failed') ||\n steps.some((step) => step.status === 'failed') ||\n afterEach.some((step) => step.status === 'failed') ||\n teardownErrors.length > 0\n ? 'failed'\n : 'success',\n beforeEach: [...beforeEach],\n steps: [...steps],\n afterEach: [...afterEach],\n ...(executionErrors.length\n ? { executionErrors: executionErrors.map(asExecutionError) }\n : {}),\n ...(teardownErrors.length > 0\n ? { teardownErrors: [...teardownErrors] }\n : {}),\n ...(reportPaths.size > 0 ? { reportPaths: [...reportPaths] } : {}),\n ...(reportSources.length ? { reportSources: [...reportSources] } : {}),\n ...(options.reportScopeId ? { reportScopeId: options.reportScopeId } : {}),\n startedAt: startedAt.toISOString(),\n endedAt: endedAt.toISOString(),\n durationMs: Math.max(0, endedAt.getTime() - startedAt.getTime()),\n };\n\n try {\n await options.onResult?.(result);\n } catch (error) {\n executionErrors.push(error);\n result.status = 'failed';\n result.executionErrors = executionErrors.map(asExecutionError);\n }\n resourceScope.dispose();\n if (executionErrors.length)\n throw new WorkflowExecutionFailure(result, executionErrors);\n return result;\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","runCollectedCase","collectedCase","options","phases","nodes","step","resourceScope","createResourceScope","scopeSignal","runId","randomUUID","startedAt","Date","beforeEach","steps","afterEach","teardownStack","acceptingTeardowns","onTeardown","node","teardown","WorkflowLifecycleError","runPhase","phase","results","signal","stepIndex","recoverCancelledScopeResources","caseContext","stepInfo","result","executeStep","executionErrors","error","teardownErrors","reportPaths","Set","reportSources","cleanupExecutionErrors","deferredCleanup","cleanup","priorTeardownErrors","registrationIndex","released","path","reportPathsFromTeardown","NodeScopeTeardownError","errors","AggregateError","cleanupScopeResources","cleanupSignal","getDebug","String","Res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A,AAAgB,aAAhBA,KAAK,MAAM,KACpC6B,eAAe,MAAM,GAAG,IACpB,WACA;QACN,YAAY;eAAIrB;SAAW;QAC3B,OAAO;eAAIC;SAAM;QACjB,WAAW;eAAIC;SAAU;QACzB,GAAIiB,gBAAgB,MAAM,GACtB;YAAE,iBAAiBA,gBAAgB,GAAG,CAACuB,8CAAAA,gBAAgBA;QAAE,IACzD,CAAC,CAAC;QACN,GAAIrB,eAAe,MAAM,GAAG,IACxB;YAAE,gBAAgB;mBAAIA;aAAe;QAAC,IACtC,CAAC,CAAC;QACN,GAAIC,YAAY,IAAI,GAAG,IAAI;YAAE,aAAa;mBAAIA;aAAY;QAAC,IAAI,CAAC,CAAC;QACjE,GAAIE,cAAc,MAAM,GAAG;YAAE,eAAe;mBAAIA;aAAc;QAAC,IAAI,CAAC,CAAC;QACrE,GAAInC,QAAQ,aAAa,GAAG;YAAE,eAAeA,QAAQ,aAAa;QAAC,IAAI,CAAC,CAAC;QACzE,WAAWS,UAAU,WAAW;QAChC,SAAS2C,QAAQ,WAAW;QAC5B,YAAYE,KAAK,GAAG,CAAC,GAAGF,QAAQ,OAAO,KAAK3C,UAAU,OAAO;IAC/D;IAEA,IAAI;QACF,MAAMT,QAAQ,QAAQ,GAAG4B;IAC3B,EAAE,OAAOG,OAAO;QACdD,gBAAgB,IAAI,CAACC;QACrBH,OAAO,MAAM,GAAG;QAChBA,OAAO,eAAe,GAAGE,gBAAgB,GAAG,CAACuB,8CAAAA,gBAAgBA;IAC/D;IACAjD,cAAc,OAAO;IACrB,IAAI0B,gBAAgB,MAAM,EACxB,MAAM,IAAIyB,8CAAAA,wBAAwBA,CAAC3B,QAAQE;IAC7C,OAAOF;AACT"}
1
+ {"version":3,"file":"test-runner/engine/run-collected-case.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/test-runner/engine/run-collected-case.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { getDebug } from '@midscene/shared/logger';\nimport { uuid as randomUUID } from '@midscene/shared/utils';\nimport { NodeScopeTeardownError, WorkflowLifecycleError } from '../errors';\nimport type { CollectedCase, NormalizedStep } from '../parser/types';\nimport { executeStep } from './execute-step';\nimport {\n WorkflowExecutionFailure,\n asExecutionError,\n} from './execution-failure';\nimport {\n ResourceCleanupDeferredError,\n cleanupScopeResources,\n createResourceScope,\n getPendingScopeOperations,\n getResourceCleanupSnapshot,\n recoverCancelledScopeResources,\n setResourceOperationIdentity,\n} from './resource-operations';\nimport { phaseResult } from './result-metadata';\nimport { reportPathsFromTeardown } from './scope-teardown';\nimport type {\n CaseNodePhase,\n CaseRunResult,\n NodeCaseContext,\n NodeScopeTeardown,\n RunCollectedCaseOptions,\n StepRunResult,\n} from './types';\n\nexport async function runCollectedCase<TContext = undefined>(\n collectedCase: CollectedCase,\n options: RunCollectedCaseOptions<TContext>,\n): Promise<CaseRunResult> {\n const phases: Record<CaseNodePhase, readonly NormalizedStep[]> = {\n beforeEach: options.beforeEach ?? [],\n steps: collectedCase.definition.steps,\n afterEach: options.afterEach ?? [],\n };\n const nodes = {\n beforeEach: phases.beforeEach.map((step) => options.resolveNode(step.node)),\n steps: phases.steps.map((step) => options.resolveNode(step.node)),\n afterEach: phases.afterEach.map((step) => options.resolveNode(step.node)),\n };\n const resourceScope = createResourceScope(options.signal);\n const scopeSignal = resourceScope.signal;\n const runId = options.createRunId?.() ?? randomUUID();\n const startedAt = new Date();\n setResourceOperationIdentity(scopeSignal, { scopeId: runId });\n const beforeEach: StepRunResult[] = [];\n const steps: StepRunResult[] = [];\n const afterEach: StepRunResult[] = [];\n const capturedSources = new Map<\n string,\n import('./types').WorkflowReportSource\n >();\n const teardownStack: Array<{\n registrationIndex: number;\n node: string;\n teardown: NodeScopeTeardown;\n }> = [];\n let acceptingTeardowns = true;\n\n const onTeardown = (node: string, teardown: NodeScopeTeardown): void => {\n if (!acceptingTeardowns) {\n throw new WorkflowLifecycleError(\n 'Node teardown can only be registered while a case attempt is running.',\n { runId, node },\n );\n }\n if (typeof teardown !== 'function') {\n throw new WorkflowLifecycleError(\n 'Node onTeardown() requires a teardown function.',\n { runId, node },\n );\n }\n teardownStack.push({\n registrationIndex: teardownStack.length,\n node,\n teardown,\n });\n };\n\n const runPhase = async (\n phase: CaseNodePhase,\n results: StepRunResult[],\n signal = scopeSignal,\n ): Promise<void> => {\n for (const [stepIndex, step] of phases[phase].entries()) {\n // A Step timeout ends the Runner's wait, not the underlying operation.\n // Recovery belongs between Steps, outside the next Step's timeout budget.\n const waitForPreviousOperationMs =\n stepIndex > 0 ? await recoverCancelledScopeResources(signal) : 0;\n const caseContext: NodeCaseContext = {\n caseId: collectedCase.caseId,\n runId,\n projectName: options.projectName ?? collectedCase.projectId,\n attemptIndex: options.attemptIndex ?? 0,\n name: collectedCase.definition.name,\n sourcePath: collectedCase.sourcePath,\n caseIndex: collectedCase.caseIndex,\n phase,\n stepIndex,\n };\n const stepInfo = {\n scope: 'case' as const,\n node: step.node,\n stepCount: phases[phase].length,\n case: caseContext,\n };\n await options.onStepStart?.(stepInfo);\n const result = await executeStep(\n step,\n nodes[phase][stepIndex],\n { scope: 'case', case: caseContext },\n options.context as TContext,\n {\n signal,\n defaultTimeoutMs: options.defaultTimeoutMs,\n onTeardown,\n },\n );\n if (waitForPreviousOperationMs > 0)\n result.waitForPreviousOperationMs = waitForPreviousOperationMs;\n results.push(result);\n for (const source of result.report?.sources ?? [])\n capturedSources.set(\n `${source.sourcePath}\\u0000${source.dumpPath ?? ''}`,\n source,\n );\n await options.onStepResult?.(stepInfo, result);\n if (result.status !== 'success' && !result.continuedAfterError) break;\n }\n };\n\n const executionErrors: unknown[] = [];\n try {\n await runPhase('beforeEach', beforeEach);\n if (!beforeEach.some((step) => step.status !== 'success')) {\n await runPhase('steps', steps);\n }\n } catch (error) {\n executionErrors.push(error);\n }\n const teardownErrors: NodeScopeTeardownError[] = [];\n const reportPaths = new Set<string>();\n const reportSources: import('./types').WorkflowReportSource[] = [];\n const cleanupExecutionErrors: unknown[] = [];\n let deferredCleanup = false;\n const cleanup = async () => {\n const priorTeardownErrors = teardownErrors.length;\n acceptingTeardowns = false;\n for (const {\n registrationIndex,\n node,\n teardown,\n } of teardownStack.reverse()) {\n try {\n const released = await teardown();\n reportSources.push(...(released?.reportSources ?? []));\n for (const path of reportPathsFromTeardown(released)) {\n reportPaths.add(path);\n }\n } catch (error) {\n teardownErrors.push(\n new NodeScopeTeardownError(error, {\n scope: 'case',\n scopeId: runId,\n node,\n registrationIndex,\n }),\n );\n }\n }\n {\n const errors = [\n ...cleanupExecutionErrors,\n ...teardownErrors.slice(priorTeardownErrors),\n ];\n if (errors.length)\n throw new AggregateError(errors, 'Case cleanup failed');\n }\n };\n try {\n if (phases.afterEach.length || teardownStack.length)\n await cleanupScopeResources(scopeSignal, cleanup, {\n beforeCleanup: async (cleanupSignal) => {\n try {\n await runPhase('afterEach', afterEach, cleanupSignal);\n } catch (error) {\n executionErrors.push(error);\n cleanupExecutionErrors.push(error);\n }\n },\n onDeferredError: (error) =>\n getDebug('runner:cleanup', { console: true })(\n `Deferred Case cleanup failed: ${String(error)}`,\n ),\n });\n else acceptingTeardowns = false;\n } catch (error) {\n deferredCleanup = error instanceof ResourceCleanupDeferredError;\n if (!deferredCleanup) acceptingTeardowns = false;\n if (\n !deferredCleanup &&\n !teardownErrors.length &&\n !cleanupExecutionErrors.length\n )\n teardownErrors.push(\n new NodeScopeTeardownError(error, {\n scope: 'case',\n scopeId: runId,\n node: 'resource-drain',\n registrationIndex: -1,\n }),\n );\n }\n const endedAt = new Date();\n const cleanupSnapshot = getResourceCleanupSnapshot(scopeSignal);\n const pendingOperations = getPendingScopeOperations(scopeSignal);\n const phaseResults = {\n beforeEach: phaseResult(phases.beforeEach.length, beforeEach),\n steps: phaseResult(phases.steps.length, steps),\n afterEach: phaseResult(phases.afterEach.length, afterEach),\n };\n const result: CaseRunResult = {\n caseId: collectedCase.caseId,\n runId,\n projectName: options.projectName ?? collectedCase.projectId,\n attemptIndex: options.attemptIndex ?? 0,\n name: collectedCase.definition.name,\n sourcePath: collectedCase.sourcePath,\n caseIndex: collectedCase.caseIndex,\n status:\n executionErrors.length > 0 ||\n beforeEach.some((step) => step.status !== 'success') ||\n steps.some((step) => step.status !== 'success') ||\n afterEach.some((step) => step.status !== 'success') ||\n cleanupSnapshot.status === 'pending' ||\n cleanupSnapshot.status === 'failed' ||\n pendingOperations.length > 0 ||\n teardownErrors.length > 0\n ? 'failed'\n : 'success',\n beforeEach: [...beforeEach],\n steps: [...steps],\n afterEach: [...afterEach],\n executionStatus: Object.values(phaseResults).some(\n (phase) => phase.status === 'failed',\n )\n ? 'failed'\n : Object.values(phaseResults).some((phase) => phase.status === 'not-run')\n ? 'not-run'\n : 'success',\n phases: phaseResults,\n cleanup: cleanupSnapshot,\n ...(pendingOperations.length ? { pendingOperations } : {}),\n ...(executionErrors.length\n ? { executionErrors: executionErrors.map(asExecutionError) }\n : {}),\n ...(teardownErrors.length > 0\n ? { teardownErrors: [...teardownErrors] }\n : {}),\n ...(reportPaths.size > 0 ? { reportPaths: [...reportPaths] } : {}),\n ...(capturedSources.size || reportSources.length\n ? { reportSources: [...capturedSources.values(), ...reportSources] }\n : {}),\n ...(options.reportScopeId ? { reportScopeId: options.reportScopeId } : {}),\n startedAt: startedAt.toISOString(),\n endedAt: endedAt.toISOString(),\n durationMs: Math.max(0, endedAt.getTime() - startedAt.getTime()),\n };\n\n try {\n await options.onResult?.(result);\n } catch (error) {\n executionErrors.push(error);\n result.status = 'failed';\n result.executionErrors = executionErrors.map(asExecutionError);\n }\n resourceScope.dispose();\n if (executionErrors.length)\n throw new WorkflowExecutionFailure(result, executionErrors);\n return result;\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","runCollectedCase","collectedCase","options","phases","nodes","step","resourceScope","createResourceScope","scopeSignal","runId","randomUUID","startedAt","Date","setResourceOperationIdentity","beforeEach","steps","afterEach","capturedSources","Map","teardownStack","acceptingTeardowns","onTeardown","node","teardown","WorkflowLifecycleError","runPhase","phase","results","signal","stepIndex","waitForPreviousOperationMs","recoverCancelledScopeResources","caseContext","stepInfo","result","executeStep","source","executionErrors","error","teardownErrors","reportPaths","Set","reportSources","cleanupExecutionErrors","deferredCleanup","cleanup","priorTeardownErrors","registrationIndex","released","path","reportPathsFromTeardown","NodeScopeTeardownError","errors","AggregateError","cleanupScopeResources","cleanupSignal","getDebug","String","ResourceCleanupDeferredError","endedAt","cleanupSnapshot","getResourceCleanupSnapshot","pendingOperations","getPendingScopeOperations","phaseResults","phaseResult","asExecutionError","Math","WorkflowExecutionFailure"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO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C,QAAQ,aAAa,GAAG;YAAE,eAAeA,QAAQ,aAAa;QAAC,IAAI,CAAC,CAAC;QACzE,WAAWS,UAAU,WAAW;QAChC,SAASgD,QAAQ,WAAW;QAC5B,YAAYQ,KAAK,GAAG,CAAC,GAAGR,QAAQ,OAAO,KAAKhD,UAAU,OAAO;IAC/D;IAEA,IAAI;QACF,MAAMT,QAAQ,QAAQ,GAAGgC;IAC3B,EAAE,OAAOI,OAAO;QACdD,gBAAgB,IAAI,CAACC;QACrBJ,OAAO,MAAM,GAAG;QAChBA,OAAO,eAAe,GAAGG,gBAAgB,GAAG,CAAC6B,8CAAAA,gBAAgBA;IAC/D;IACA5D,cAAc,OAAO;IACrB,IAAI+B,gBAAgB,MAAM,EACxB,MAAM,IAAI+B,8CAAAA,wBAAwBA,CAAClC,QAAQG;IAC7C,OAAOH;AACT"}
@@ -26,8 +26,11 @@ __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  runWorkflowDocument: ()=>runWorkflowDocument
28
28
  });
29
+ const external_errors_js_namespaceObject = require("../errors.js");
30
+ const test_plan_js_namespaceObject = require("../reporting/test-plan.js");
29
31
  const external_document_runtime_js_namespaceObject = require("./document-runtime.js");
30
32
  const external_execution_failure_js_namespaceObject = require("./execution-failure.js");
33
+ const external_result_metadata_js_namespaceObject = require("./result-metadata.js");
31
34
  const external_run_collected_case_js_namespaceObject = require("./run-collected-case.js");
32
35
  const asNotRun = (collectedCase, projectName, reason)=>({
33
36
  caseId: collectedCase.caseId,
@@ -49,6 +52,13 @@ async function runWorkflowDocument(document, options) {
49
52
  const retry = options.retry ?? options.project?.retry ?? 0;
50
53
  if (!Number.isInteger(retry) || retry < 0) throw new TypeError('Workflow document retry must be a non-negative integer.');
51
54
  const runtime = (0, external_document_runtime_js_namespaceObject.createDocumentRuntime)(document, {
55
+ plan: options.plan ?? (0, test_plan_js_namespaceObject.buildTestRunReportPlan)(document, {
56
+ defaultTimeoutMs: options.defaultTimeoutMs,
57
+ retry: {
58
+ scope: 'case',
59
+ count: retry
60
+ }
61
+ }),
52
62
  documentSetup: options.documentSetup,
53
63
  documentAttemptIndex: options.documentAttemptIndex,
54
64
  resolveNode: options.resolveNode,
@@ -69,13 +79,13 @@ async function runWorkflowDocument(document, options) {
69
79
  let documentResult;
70
80
  const executionErrors = [];
71
81
  let fatalError = false;
72
- let stoppedByCase = false;
82
+ let documentStopReason;
73
83
  try {
74
84
  runtimeStarted = true;
75
85
  const startedDocument = await runtime.start();
76
86
  if (runtime.canRunCases) for (const collectedCase of document.cases){
77
- if (stoppedByCase || fatalError || signal.aborted || options.shouldStop?.()) {
78
- const outcome = asNotRun(collectedCase, projectName, signal.aborted ? options.stopReason?.() ?? 'interrupted' : fatalError ? 'fatal-error' : stoppedByCase ? 'bail' : options.stopReason?.() ?? 'interrupted');
87
+ if (documentStopReason || fatalError || signal.aborted || options.shouldStop?.()) {
88
+ const outcome = asNotRun(collectedCase, projectName, signal.aborted ? options.stopReason?.() ?? 'interrupted' : fatalError ? 'fatal-error' : documentStopReason ?? options.stopReason?.() ?? 'interrupted');
79
89
  cases.push(outcome);
80
90
  await options.onCaseOutcome?.(outcome);
81
91
  continue;
@@ -83,6 +93,7 @@ async function runWorkflowDocument(document, options) {
83
93
  await options.onCaseStart?.(collectedCase);
84
94
  const attempts = [];
85
95
  for(let attemptIndex = 0; attemptIndex <= retry; attemptIndex += 1){
96
+ let attemptFatalError = false;
86
97
  let attemptFailure;
87
98
  const run = await (0, external_run_collected_case_js_namespaceObject.runCollectedCase)(collectedCase, {
88
99
  resolveNode: options.resolveNode,
@@ -95,7 +106,23 @@ async function runWorkflowDocument(document, options) {
95
106
  defaultTimeoutMs: options.defaultTimeoutMs,
96
107
  onStepStart: options.onStepStart,
97
108
  onStepResult: options.onStepResult,
98
- onResult: options.onCaseResult,
109
+ onResult: async (result)=>{
110
+ attemptFatalError = options.isFatalError?.(result) ?? false;
111
+ result.retryDecision = (0, external_result_metadata_js_namespaceObject.decideRetry)({
112
+ scope: 'case',
113
+ retryCount: retry,
114
+ attemptIndex,
115
+ status: result.status,
116
+ cleanupPending: result.cleanup?.status === 'pending',
117
+ operationPending: !!result.pendingOperations?.length,
118
+ cleanupFailed: result.cleanup?.status === 'failed' || !!result.teardownErrors?.length,
119
+ infrastructureError: result.executionErrors?.some((error)=>!(0, external_errors_js_namespaceObject.isResourceRecoveryError)(error)),
120
+ fatalError: attemptFatalError,
121
+ interrupted: signal.aborted,
122
+ shouldStop: options.shouldStop?.()
123
+ });
124
+ await options.onCaseResult?.(result);
125
+ },
99
126
  reportScopeId: options.resolveCaseReportScopeId?.(collectedCase, attemptIndex, startedDocument.documentRunId),
100
127
  createRunId: createCaseRunId ? ()=>createCaseRunId(collectedCase, attemptIndex) : void 0
101
128
  }).catch((error)=>{
@@ -104,7 +131,14 @@ async function runWorkflowDocument(document, options) {
104
131
  return attemptFailure.result;
105
132
  });
106
133
  attempts.push(run);
107
- if (attemptFailure) {
134
+ if (attemptFailure && !attemptFailure.errors.every(external_errors_js_namespaceObject.isResourceRecoveryError)) {
135
+ run.retryDecision = (0, external_result_metadata_js_namespaceObject.decideRetry)({
136
+ scope: 'case',
137
+ retryCount: retry,
138
+ attemptIndex,
139
+ status: run.status,
140
+ infrastructureError: true
141
+ });
108
142
  cases.push({
109
143
  caseId: collectedCase.caseId,
110
144
  projectName,
@@ -120,8 +154,20 @@ async function runWorkflowDocument(document, options) {
120
154
  });
121
155
  throw attemptFailure;
122
156
  }
123
- fatalError = options.isFatalError?.(run) ?? false;
124
- if ('success' === run.status || !!run.teardownErrors?.length || fatalError || signal.aborted || options.shouldStop?.()) break;
157
+ fatalError = attemptFatalError;
158
+ run.retryDecision = (0, external_result_metadata_js_namespaceObject.decideRetry)({
159
+ scope: 'case',
160
+ retryCount: retry,
161
+ attemptIndex,
162
+ status: run.status,
163
+ cleanupPending: run.cleanup?.status === 'pending',
164
+ cleanupFailed: run.cleanup?.status === 'failed' || !!run.teardownErrors?.length,
165
+ operationPending: !!run.pendingOperations?.length,
166
+ fatalError: fatalError || !!run.executionErrors?.some(external_errors_js_namespaceObject.isResourceRecoveryError),
167
+ interrupted: signal.aborted,
168
+ shouldStop: options.shouldStop?.()
169
+ });
170
+ if (run.retryDecision?.decision !== 'retry') break;
125
171
  }
126
172
  const run = attempts.at(-1);
127
173
  const outcome = {
@@ -138,7 +184,8 @@ async function runWorkflowDocument(document, options) {
138
184
  attempts
139
185
  };
140
186
  cases.push(outcome);
141
- stoppedByCase = 'failed' === outcome.status && 'stop-document' === collectedCase.definition.onFailure;
187
+ const retryStopReason = run.retryDecision?.reason;
188
+ documentStopReason = 'cleanup-pending' === retryStopReason || 'cleanup-failed' === retryStopReason || 'operation-pending' === retryStopReason || 'fatal-error' === retryStopReason ? retryStopReason : 'failed' === outcome.status && 'stop-document' === collectedCase.definition.onFailure ? 'bail' : void 0;
142
189
  await options.onCaseOutcome?.(outcome);
143
190
  }
144
191
  else {
@@ -165,9 +212,9 @@ async function runWorkflowDocument(document, options) {
165
212
  }
166
213
  if (executionErrors.length) {
167
214
  const completed = new Set(cases.map((outcome)=>outcome.caseId));
168
- cases.push(...document.cases.filter((item)=>!completed.has(item.caseId)).map((item)=>asNotRun(item, projectName, 'interrupted')));
215
+ cases.push(...document.cases.filter((item)=>!completed.has(item.caseId)).map((item)=>asNotRun(item, projectName, executionErrors.every(external_errors_js_namespaceObject.isResourceRecoveryError) ? 'operation-pending' : 'interrupted')));
169
216
  documentResult.status = 'failed';
170
- documentResult.executionErrors = executionErrors.map(external_execution_failure_js_namespaceObject.asExecutionError);
217
+ documentResult.executionErrors = executionErrors.filter((error)=>!documentResult.hostErrors?.some((host)=>host.error === error)).map(external_execution_failure_js_namespaceObject.asExecutionError);
171
218
  throw new external_execution_failure_js_namespaceObject.WorkflowExecutionFailure({
172
219
  document: documentResult,
173
220
  cases