groundswell 0.0.3 → 1.0.0

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 (292) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +26 -9
  3. package/dist/cache/cache-key.d.ts +20 -0
  4. package/dist/cache/cache-key.d.ts.map +1 -1
  5. package/dist/cache/cache-key.js +9 -0
  6. package/dist/cache/cache-key.js.map +1 -1
  7. package/dist/core/agent.d.ts +120 -29
  8. package/dist/core/agent.d.ts.map +1 -1
  9. package/dist/core/agent.js +584 -177
  10. package/dist/core/agent.js.map +1 -1
  11. package/dist/core/mcp-handler.d.ts +63 -5
  12. package/dist/core/mcp-handler.d.ts.map +1 -1
  13. package/dist/core/mcp-handler.js +184 -4
  14. package/dist/core/mcp-handler.js.map +1 -1
  15. package/dist/core/workflow-context.d.ts +6 -2
  16. package/dist/core/workflow-context.d.ts.map +1 -1
  17. package/dist/core/workflow-context.js +99 -4
  18. package/dist/core/workflow-context.js.map +1 -1
  19. package/dist/core/workflow.d.ts +315 -13
  20. package/dist/core/workflow.d.ts.map +1 -1
  21. package/dist/core/workflow.js +552 -30
  22. package/dist/core/workflow.js.map +1 -1
  23. package/dist/debugger/event-replayer.d.ts +422 -0
  24. package/dist/debugger/event-replayer.d.ts.map +1 -0
  25. package/dist/debugger/event-replayer.js +639 -0
  26. package/dist/debugger/event-replayer.js.map +1 -0
  27. package/dist/debugger/tree-debugger.d.ts +170 -1
  28. package/dist/debugger/tree-debugger.d.ts.map +1 -1
  29. package/dist/debugger/tree-debugger.js +423 -1
  30. package/dist/debugger/tree-debugger.js.map +1 -1
  31. package/dist/decorators/step.d.ts.map +1 -1
  32. package/dist/decorators/step.js +129 -47
  33. package/dist/decorators/step.js.map +1 -1
  34. package/dist/harnesses/claude-code-harness.d.ts +391 -0
  35. package/dist/harnesses/claude-code-harness.d.ts.map +1 -0
  36. package/dist/harnesses/claude-code-harness.js +1076 -0
  37. package/dist/harnesses/claude-code-harness.js.map +1 -0
  38. package/dist/harnesses/harness-registry.d.ts +440 -0
  39. package/dist/harnesses/harness-registry.d.ts.map +1 -0
  40. package/dist/harnesses/harness-registry.js +543 -0
  41. package/dist/harnesses/harness-registry.js.map +1 -0
  42. package/dist/harnesses/index.d.ts +12 -0
  43. package/dist/harnesses/index.d.ts.map +1 -0
  44. package/dist/harnesses/index.js +11 -0
  45. package/dist/harnesses/index.js.map +1 -0
  46. package/dist/harnesses/pi-harness.d.ts +219 -0
  47. package/dist/harnesses/pi-harness.d.ts.map +1 -0
  48. package/dist/harnesses/pi-harness.js +676 -0
  49. package/dist/harnesses/pi-harness.js.map +1 -0
  50. package/dist/harnesses/pi-schema-converter.d.ts +24 -0
  51. package/dist/harnesses/pi-schema-converter.d.ts.map +1 -0
  52. package/dist/harnesses/pi-schema-converter.js +81 -0
  53. package/dist/harnesses/pi-schema-converter.js.map +1 -0
  54. package/dist/harnesses/register-defaults.d.ts +24 -0
  55. package/dist/harnesses/register-defaults.d.ts.map +1 -0
  56. package/dist/harnesses/register-defaults.js +40 -0
  57. package/dist/harnesses/register-defaults.js.map +1 -0
  58. package/dist/harnesses/session-store.d.ts +201 -0
  59. package/dist/harnesses/session-store.d.ts.map +1 -0
  60. package/dist/harnesses/session-store.js +254 -0
  61. package/dist/harnesses/session-store.js.map +1 -0
  62. package/dist/index.d.ts +12 -2
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +17 -0
  65. package/dist/index.js.map +1 -1
  66. package/dist/reflection/reflection.d.ts.map +1 -1
  67. package/dist/reflection/reflection.js +19 -4
  68. package/dist/reflection/reflection.js.map +1 -1
  69. package/dist/types/agent.d.ts +1253 -2
  70. package/dist/types/agent.d.ts.map +1 -1
  71. package/dist/types/agent.js +418 -1
  72. package/dist/types/agent.js.map +1 -1
  73. package/dist/types/decorators.d.ts +10 -1
  74. package/dist/types/decorators.d.ts.map +1 -1
  75. package/dist/types/events.d.ts +26 -0
  76. package/dist/types/events.d.ts.map +1 -1
  77. package/dist/types/harnesses.d.ts +474 -0
  78. package/dist/types/harnesses.d.ts.map +1 -0
  79. package/dist/types/harnesses.js +2 -0
  80. package/dist/types/harnesses.js.map +1 -0
  81. package/dist/types/index.d.ts +9 -1
  82. package/dist/types/index.d.ts.map +1 -1
  83. package/dist/types/index.js +6 -0
  84. package/dist/types/index.js.map +1 -1
  85. package/dist/types/providers.d.ts +691 -0
  86. package/dist/types/providers.d.ts.map +1 -0
  87. package/dist/types/providers.js +14 -0
  88. package/dist/types/providers.js.map +1 -0
  89. package/dist/types/restart.d.ts +132 -0
  90. package/dist/types/restart.d.ts.map +1 -0
  91. package/dist/types/restart.js +2 -0
  92. package/dist/types/restart.js.map +1 -0
  93. package/dist/types/streaming.d.ts +194 -0
  94. package/dist/types/streaming.d.ts.map +1 -0
  95. package/dist/types/streaming.js +67 -0
  96. package/dist/types/streaming.js.map +1 -0
  97. package/dist/types/workflow-context.d.ts +137 -1
  98. package/dist/types/workflow-context.d.ts.map +1 -1
  99. package/dist/utils/agent-validation.d.ts +88 -0
  100. package/dist/utils/agent-validation.d.ts.map +1 -0
  101. package/dist/utils/agent-validation.js +87 -0
  102. package/dist/utils/agent-validation.js.map +1 -0
  103. package/dist/utils/delay.d.ts +7 -0
  104. package/dist/utils/delay.d.ts.map +1 -0
  105. package/dist/utils/delay.js +9 -0
  106. package/dist/utils/delay.js.map +1 -0
  107. package/dist/utils/harness-config.d.ts +180 -0
  108. package/dist/utils/harness-config.d.ts.map +1 -0
  109. package/dist/utils/harness-config.js +311 -0
  110. package/dist/utils/harness-config.js.map +1 -0
  111. package/dist/utils/index.d.ts +9 -1
  112. package/dist/utils/index.d.ts.map +1 -1
  113. package/dist/utils/index.js +8 -1
  114. package/dist/utils/index.js.map +1 -1
  115. package/dist/utils/model-spec.d.ts +110 -0
  116. package/dist/utils/model-spec.d.ts.map +1 -0
  117. package/dist/utils/model-spec.js +149 -0
  118. package/dist/utils/model-spec.js.map +1 -0
  119. package/dist/utils/provider-config.d.ts +10 -0
  120. package/dist/utils/provider-config.d.ts.map +1 -0
  121. package/dist/utils/provider-config.js +10 -0
  122. package/dist/utils/provider-config.js.map +1 -0
  123. package/dist/utils/restart-analysis.d.ts +202 -0
  124. package/dist/utils/restart-analysis.d.ts.map +1 -0
  125. package/dist/utils/restart-analysis.js +426 -0
  126. package/dist/utils/restart-analysis.js.map +1 -0
  127. package/dist/utils/session-serialization.d.ts +118 -0
  128. package/dist/utils/session-serialization.d.ts.map +1 -0
  129. package/dist/utils/session-serialization.js +217 -0
  130. package/dist/utils/session-serialization.js.map +1 -0
  131. package/package.json +31 -5
  132. package/CHANGELOG.md +0 -188
  133. package/dist/__tests__/adversarial/attachChild-performance.test.d.ts +0 -16
  134. package/dist/__tests__/adversarial/attachChild-performance.test.d.ts.map +0 -1
  135. package/dist/__tests__/adversarial/attachChild-performance.test.js +0 -187
  136. package/dist/__tests__/adversarial/attachChild-performance.test.js.map +0 -1
  137. package/dist/__tests__/adversarial/circular-reference.test.d.ts +0 -13
  138. package/dist/__tests__/adversarial/circular-reference.test.d.ts.map +0 -1
  139. package/dist/__tests__/adversarial/circular-reference.test.js +0 -92
  140. package/dist/__tests__/adversarial/circular-reference.test.js.map +0 -1
  141. package/dist/__tests__/adversarial/complex-circular-reference.test.d.ts +0 -16
  142. package/dist/__tests__/adversarial/complex-circular-reference.test.d.ts.map +0 -1
  143. package/dist/__tests__/adversarial/complex-circular-reference.test.js +0 -127
  144. package/dist/__tests__/adversarial/complex-circular-reference.test.js.map +0 -1
  145. package/dist/__tests__/adversarial/concurrent-task-failures.test.d.ts +0 -21
  146. package/dist/__tests__/adversarial/concurrent-task-failures.test.d.ts.map +0 -1
  147. package/dist/__tests__/adversarial/concurrent-task-failures.test.js +0 -667
  148. package/dist/__tests__/adversarial/concurrent-task-failures.test.js.map +0 -1
  149. package/dist/__tests__/adversarial/deep-analysis.test.d.ts +0 -6
  150. package/dist/__tests__/adversarial/deep-analysis.test.d.ts.map +0 -1
  151. package/dist/__tests__/adversarial/deep-analysis.test.js +0 -877
  152. package/dist/__tests__/adversarial/deep-analysis.test.js.map +0 -1
  153. package/dist/__tests__/adversarial/deep-hierarchy-stress.test.d.ts +0 -13
  154. package/dist/__tests__/adversarial/deep-hierarchy-stress.test.d.ts.map +0 -1
  155. package/dist/__tests__/adversarial/deep-hierarchy-stress.test.js +0 -186
  156. package/dist/__tests__/adversarial/deep-hierarchy-stress.test.js.map +0 -1
  157. package/dist/__tests__/adversarial/e2e-prd-validation.test.d.ts +0 -6
  158. package/dist/__tests__/adversarial/e2e-prd-validation.test.d.ts.map +0 -1
  159. package/dist/__tests__/adversarial/e2e-prd-validation.test.js +0 -626
  160. package/dist/__tests__/adversarial/e2e-prd-validation.test.js.map +0 -1
  161. package/dist/__tests__/adversarial/edge-case.test.d.ts +0 -6
  162. package/dist/__tests__/adversarial/edge-case.test.d.ts.map +0 -1
  163. package/dist/__tests__/adversarial/edge-case.test.js +0 -857
  164. package/dist/__tests__/adversarial/edge-case.test.js.map +0 -1
  165. package/dist/__tests__/adversarial/error-merge-strategy.test.d.ts +0 -20
  166. package/dist/__tests__/adversarial/error-merge-strategy.test.d.ts.map +0 -1
  167. package/dist/__tests__/adversarial/error-merge-strategy.test.js +0 -907
  168. package/dist/__tests__/adversarial/error-merge-strategy.test.js.map +0 -1
  169. package/dist/__tests__/adversarial/incremental-performance.test.d.ts +0 -2
  170. package/dist/__tests__/adversarial/incremental-performance.test.d.ts.map +0 -1
  171. package/dist/__tests__/adversarial/incremental-performance.test.js +0 -113
  172. package/dist/__tests__/adversarial/incremental-performance.test.js.map +0 -1
  173. package/dist/__tests__/adversarial/node-map-update-benchmarks.test.d.ts +0 -22
  174. package/dist/__tests__/adversarial/node-map-update-benchmarks.test.d.ts.map +0 -1
  175. package/dist/__tests__/adversarial/node-map-update-benchmarks.test.js +0 -383
  176. package/dist/__tests__/adversarial/node-map-update-benchmarks.test.js.map +0 -1
  177. package/dist/__tests__/adversarial/observer-propagation.test.d.ts +0 -21
  178. package/dist/__tests__/adversarial/observer-propagation.test.d.ts.map +0 -1
  179. package/dist/__tests__/adversarial/observer-propagation.test.js +0 -404
  180. package/dist/__tests__/adversarial/observer-propagation.test.js.map +0 -1
  181. package/dist/__tests__/adversarial/parent-validation.test.d.ts +0 -13
  182. package/dist/__tests__/adversarial/parent-validation.test.d.ts.map +0 -1
  183. package/dist/__tests__/adversarial/parent-validation.test.js +0 -128
  184. package/dist/__tests__/adversarial/parent-validation.test.js.map +0 -1
  185. package/dist/__tests__/adversarial/prd-12-2-compliance.test.d.ts +0 -20
  186. package/dist/__tests__/adversarial/prd-12-2-compliance.test.d.ts.map +0 -1
  187. package/dist/__tests__/adversarial/prd-12-2-compliance.test.js +0 -482
  188. package/dist/__tests__/adversarial/prd-12-2-compliance.test.js.map +0 -1
  189. package/dist/__tests__/adversarial/prd-compliance.test.d.ts +0 -6
  190. package/dist/__tests__/adversarial/prd-compliance.test.d.ts.map +0 -1
  191. package/dist/__tests__/adversarial/prd-compliance.test.js +0 -886
  192. package/dist/__tests__/adversarial/prd-compliance.test.js.map +0 -1
  193. package/dist/__tests__/compatibility/backward-compatibility.test.d.ts +0 -22
  194. package/dist/__tests__/compatibility/backward-compatibility.test.d.ts.map +0 -1
  195. package/dist/__tests__/compatibility/backward-compatibility.test.js +0 -1843
  196. package/dist/__tests__/compatibility/backward-compatibility.test.js.map +0 -1
  197. package/dist/__tests__/helpers/index.d.ts +0 -10
  198. package/dist/__tests__/helpers/index.d.ts.map +0 -1
  199. package/dist/__tests__/helpers/index.js +0 -10
  200. package/dist/__tests__/helpers/index.js.map +0 -1
  201. package/dist/__tests__/helpers/tree-verification.d.ts +0 -90
  202. package/dist/__tests__/helpers/tree-verification.d.ts.map +0 -1
  203. package/dist/__tests__/helpers/tree-verification.js +0 -202
  204. package/dist/__tests__/helpers/tree-verification.js.map +0 -1
  205. package/dist/__tests__/integration/agent-workflow.test.d.ts +0 -2
  206. package/dist/__tests__/integration/agent-workflow.test.d.ts.map +0 -1
  207. package/dist/__tests__/integration/agent-workflow.test.js +0 -256
  208. package/dist/__tests__/integration/agent-workflow.test.js.map +0 -1
  209. package/dist/__tests__/integration/bidirectional-consistency.test.d.ts +0 -14
  210. package/dist/__tests__/integration/bidirectional-consistency.test.d.ts.map +0 -1
  211. package/dist/__tests__/integration/bidirectional-consistency.test.js +0 -668
  212. package/dist/__tests__/integration/bidirectional-consistency.test.js.map +0 -1
  213. package/dist/__tests__/integration/observer-logging.test.d.ts +0 -2
  214. package/dist/__tests__/integration/observer-logging.test.d.ts.map +0 -1
  215. package/dist/__tests__/integration/observer-logging.test.js +0 -517
  216. package/dist/__tests__/integration/observer-logging.test.js.map +0 -1
  217. package/dist/__tests__/integration/tree-mirroring.test.d.ts +0 -2
  218. package/dist/__tests__/integration/tree-mirroring.test.d.ts.map +0 -1
  219. package/dist/__tests__/integration/tree-mirroring.test.js +0 -117
  220. package/dist/__tests__/integration/tree-mirroring.test.js.map +0 -1
  221. package/dist/__tests__/integration/workflow-reparenting.test.d.ts +0 -12
  222. package/dist/__tests__/integration/workflow-reparenting.test.d.ts.map +0 -1
  223. package/dist/__tests__/integration/workflow-reparenting.test.js +0 -239
  224. package/dist/__tests__/integration/workflow-reparenting.test.js.map +0 -1
  225. package/dist/__tests__/unit/agent.test.d.ts +0 -2
  226. package/dist/__tests__/unit/agent.test.d.ts.map +0 -1
  227. package/dist/__tests__/unit/agent.test.js +0 -143
  228. package/dist/__tests__/unit/agent.test.js.map +0 -1
  229. package/dist/__tests__/unit/cache-key.test.d.ts +0 -5
  230. package/dist/__tests__/unit/cache-key.test.d.ts.map +0 -1
  231. package/dist/__tests__/unit/cache-key.test.js +0 -145
  232. package/dist/__tests__/unit/cache-key.test.js.map +0 -1
  233. package/dist/__tests__/unit/cache.test.d.ts +0 -5
  234. package/dist/__tests__/unit/cache.test.d.ts.map +0 -1
  235. package/dist/__tests__/unit/cache.test.js +0 -132
  236. package/dist/__tests__/unit/cache.test.js.map +0 -1
  237. package/dist/__tests__/unit/context.test.d.ts +0 -2
  238. package/dist/__tests__/unit/context.test.d.ts.map +0 -1
  239. package/dist/__tests__/unit/context.test.js +0 -220
  240. package/dist/__tests__/unit/context.test.js.map +0 -1
  241. package/dist/__tests__/unit/decorators.test.d.ts +0 -2
  242. package/dist/__tests__/unit/decorators.test.d.ts.map +0 -1
  243. package/dist/__tests__/unit/decorators.test.js +0 -162
  244. package/dist/__tests__/unit/decorators.test.js.map +0 -1
  245. package/dist/__tests__/unit/introspection-tools.test.d.ts +0 -5
  246. package/dist/__tests__/unit/introspection-tools.test.d.ts.map +0 -1
  247. package/dist/__tests__/unit/introspection-tools.test.js +0 -191
  248. package/dist/__tests__/unit/introspection-tools.test.js.map +0 -1
  249. package/dist/__tests__/unit/logger.test.d.ts +0 -2
  250. package/dist/__tests__/unit/logger.test.d.ts.map +0 -1
  251. package/dist/__tests__/unit/logger.test.js +0 -241
  252. package/dist/__tests__/unit/logger.test.js.map +0 -1
  253. package/dist/__tests__/unit/observable.test.d.ts +0 -2
  254. package/dist/__tests__/unit/observable.test.d.ts.map +0 -1
  255. package/dist/__tests__/unit/observable.test.js +0 -251
  256. package/dist/__tests__/unit/observable.test.js.map +0 -1
  257. package/dist/__tests__/unit/prompt.test.d.ts +0 -2
  258. package/dist/__tests__/unit/prompt.test.d.ts.map +0 -1
  259. package/dist/__tests__/unit/prompt.test.js +0 -113
  260. package/dist/__tests__/unit/prompt.test.js.map +0 -1
  261. package/dist/__tests__/unit/reflection.test.d.ts +0 -5
  262. package/dist/__tests__/unit/reflection.test.d.ts.map +0 -1
  263. package/dist/__tests__/unit/reflection.test.js +0 -160
  264. package/dist/__tests__/unit/reflection.test.js.map +0 -1
  265. package/dist/__tests__/unit/tree-debugger-incremental.test.d.ts +0 -2
  266. package/dist/__tests__/unit/tree-debugger-incremental.test.d.ts.map +0 -1
  267. package/dist/__tests__/unit/tree-debugger-incremental.test.js +0 -136
  268. package/dist/__tests__/unit/tree-debugger-incremental.test.js.map +0 -1
  269. package/dist/__tests__/unit/tree-debugger.test.d.ts +0 -2
  270. package/dist/__tests__/unit/tree-debugger.test.d.ts.map +0 -1
  271. package/dist/__tests__/unit/tree-debugger.test.js +0 -69
  272. package/dist/__tests__/unit/tree-debugger.test.js.map +0 -1
  273. package/dist/__tests__/unit/utils/workflow-error-utils.test.d.ts +0 -2
  274. package/dist/__tests__/unit/utils/workflow-error-utils.test.d.ts.map +0 -1
  275. package/dist/__tests__/unit/utils/workflow-error-utils.test.js +0 -154
  276. package/dist/__tests__/unit/utils/workflow-error-utils.test.js.map +0 -1
  277. package/dist/__tests__/unit/workflow-detachChild.test.d.ts +0 -2
  278. package/dist/__tests__/unit/workflow-detachChild.test.d.ts.map +0 -1
  279. package/dist/__tests__/unit/workflow-detachChild.test.js +0 -76
  280. package/dist/__tests__/unit/workflow-detachChild.test.js.map +0 -1
  281. package/dist/__tests__/unit/workflow-emitEvent-childDetached.test.d.ts +0 -2
  282. package/dist/__tests__/unit/workflow-emitEvent-childDetached.test.d.ts.map +0 -1
  283. package/dist/__tests__/unit/workflow-emitEvent-childDetached.test.js +0 -122
  284. package/dist/__tests__/unit/workflow-emitEvent-childDetached.test.js.map +0 -1
  285. package/dist/__tests__/unit/workflow-isDescendantOf.test.d.ts +0 -2
  286. package/dist/__tests__/unit/workflow-isDescendantOf.test.d.ts.map +0 -1
  287. package/dist/__tests__/unit/workflow-isDescendantOf.test.js +0 -140
  288. package/dist/__tests__/unit/workflow-isDescendantOf.test.js.map +0 -1
  289. package/dist/__tests__/unit/workflow.test.d.ts +0 -2
  290. package/dist/__tests__/unit/workflow.test.d.ts.map +0 -1
  291. package/dist/__tests__/unit/workflow.test.js +0 -330
  292. package/dist/__tests__/unit/workflow.test.js.map +0 -1
@@ -1,187 +0,0 @@
1
- /**
2
- * Performance Test: attachChild() with isDescendantOf() validation
3
- *
4
- * Validates that the isDescendantOf() method (added in P1.M1.T2.S2)
5
- * does not cause significant performance degradation in attachChild()
6
- * operations across various tree sizes and configurations.
7
- *
8
- * Performance Thresholds (from deep-hierarchy-stress.test.ts):
9
- * - Single operation: < 100ms
10
- * - Bulk operations (100 iterations): < 1000ms
11
- * - isDescendantOf() complexity: O(d) where d = tree depth
12
- *
13
- * Related: plan/bugfix/P1M4T2S2/PRP.md
14
- */
15
- import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
16
- import { Workflow } from '../../index.js';
17
- import { validateTreeConsistency, verifyBidirectionalLink } from '../helpers/tree-verification.js';
18
- /**
19
- * SimpleWorkflow class for performance testing
20
- * Pattern from: src/__tests__/adversarial/deep-hierarchy-stress.test.ts:20-26
21
- */
22
- class SimpleWorkflow extends Workflow {
23
- async run() {
24
- this.setStatus('running');
25
- this.setStatus('completed');
26
- return 'done';
27
- }
28
- }
29
- describe('attachChild Performance Regression Tests', () => {
30
- /**
31
- * Setup: Mock console methods to capture error messages
32
- * Pattern from: src/__tests__/adversarial/deep-hierarchy-stress.test.ts:33-37
33
- */
34
- beforeEach(() => {
35
- vi.spyOn(console, 'log').mockImplementation(() => { });
36
- vi.spyOn(console, 'error').mockImplementation(() => { });
37
- vi.spyOn(console, 'warn').mockImplementation(() => { });
38
- });
39
- /**
40
- * Teardown: Restore all mocks to prevent test pollution
41
- * CRITICAL: Always use vi.restoreAllMocks() in afterEach
42
- */
43
- afterEach(() => {
44
- vi.restoreAllMocks();
45
- });
46
- /**
47
- * Test 1: Shallow tree performance (depth 10)
48
- *
49
- * Validates that attachChild() performs very fast on shallow trees
50
- * where isDescendantOf() only needs to traverse a short parent chain.
51
- *
52
- * Threshold: < 10ms (should be very fast for shallow trees)
53
- */
54
- it('should attach child in shallow tree within acceptable time', () => {
55
- // ARRANGE: Create shallow tree (depth 10)
56
- const DEPTH = 10;
57
- const root = new SimpleWorkflow('Root');
58
- let current = root;
59
- for (let i = 0; i < DEPTH; i++) {
60
- current = new SimpleWorkflow(`Level-${i}`, current);
61
- }
62
- // ACT: Measure attachChild() time for new child at depth 10
63
- const startTime = performance.now();
64
- const newChild = new SimpleWorkflow('NewChild', current);
65
- const attachDuration = performance.now() - startTime;
66
- // ASSERT: Verify functional correctness
67
- expect(newChild.parent).toBe(current);
68
- expect(current.children).toContain(newChild);
69
- verifyBidirectionalLink(current, newChild);
70
- // ASSERT: Verify performance threshold (< 10ms for shallow tree)
71
- expect(attachDuration).toBeLessThan(10);
72
- });
73
- /**
74
- * Test 2: Deep tree performance (depth 100)
75
- *
76
- * Validates that attachChild() scales linearly with tree depth.
77
- * isDescendantOf() must traverse 100 parent references, which should
78
- * complete in < 50ms given the O(d) iterative implementation.
79
- *
80
- * Threshold: < 50ms (linear scaling with depth)
81
- */
82
- it('should attach child in deep tree (depth 100) within acceptable time', () => {
83
- // ARRANGE: Create deep tree
84
- const DEPTH = 100;
85
- const root = new SimpleWorkflow('Root');
86
- let current = root;
87
- for (let i = 0; i < DEPTH; i++) {
88
- current = new SimpleWorkflow(`Child-${i}`, current);
89
- }
90
- // ACT: Measure attachChild() at deepest level
91
- const startTime = performance.now();
92
- const newChild = new SimpleWorkflow('NewChild', current);
93
- const attachDuration = performance.now() - startTime;
94
- // ASSERT: Functional correctness
95
- verifyBidirectionalLink(current, newChild);
96
- // ASSERT: Performance threshold (< 50ms for depth 100)
97
- expect(attachDuration).toBeLessThan(50);
98
- // ASSERT: Validate overall tree consistency
99
- const errors = validateTreeConsistency(root);
100
- expect(errors).toHaveLength(0);
101
- });
102
- /**
103
- * Test 3: Extreme deep tree (depth 1000)
104
- *
105
- * Validates that attachChild() handles extreme depth without stack overflow
106
- * and completes within acceptable time. This tests the O(d) complexity
107
- * at the upper bound of typical workflow tree depths.
108
- *
109
- * Threshold: < 100ms (from deep-hierarchy-stress.test.ts:169)
110
- */
111
- it('should attach child in extreme deep tree (depth 1000) without stack overflow', () => {
112
- const DEPTH = 1000;
113
- const root = new SimpleWorkflow('Root');
114
- let current = root;
115
- for (let i = 0; i < DEPTH; i++) {
116
- current = new SimpleWorkflow(`Child-${i}`, current);
117
- }
118
- // ACT: Measure attachChild() at depth 1000
119
- const startTime = performance.now();
120
- const newChild = new SimpleWorkflow('NewChild', current);
121
- const attachDuration = performance.now() - startTime;
122
- // ASSERT: Functional correctness
123
- verifyBidirectionalLink(current, newChild);
124
- // ASSERT: Performance threshold (< 100ms from deep-hierarchy-stress.test.ts:169)
125
- expect(attachDuration).toBeLessThan(100);
126
- // ASSERT: Validate tree consistency at extreme depth
127
- const errors = validateTreeConsistency(root);
128
- expect(errors).toHaveLength(0);
129
- });
130
- /**
131
- * Test 4: Wide tree performance (100 children)
132
- *
133
- * Validates that attachChild() performs efficiently when attaching
134
- * multiple children to a single parent. Each attachment only requires
135
- * checking immediate parent chain, so performance should be excellent.
136
- *
137
- * Threshold: < 100ms total, < 1ms average per attachment
138
- */
139
- it('should attach 100 children to single parent efficiently', () => {
140
- // ARRANGE: Create parent
141
- const parent = new SimpleWorkflow('Parent');
142
- const NUM_CHILDREN = 100;
143
- // ACT: Measure time to attach all children
144
- const startTime = performance.now();
145
- for (let i = 0; i < NUM_CHILDREN; i++) {
146
- const child = new SimpleWorkflow(`Child-${i}`, parent);
147
- }
148
- const totalDuration = performance.now() - startTime;
149
- // ASSERT: Verify all children attached
150
- expect(parent.children).toHaveLength(NUM_CHILDREN);
151
- parent.children.forEach(child => {
152
- verifyBidirectionalLink(parent, child);
153
- });
154
- // ASSERT: Performance (< 100ms total, < 1ms average)
155
- expect(totalDuration).toBeLessThan(100);
156
- const avgTime = totalDuration / NUM_CHILDREN;
157
- expect(avgTime).toBeLessThan(1); // < 1ms per attachment
158
- });
159
- /**
160
- * Test 5: Bulk attachment performance (100 operations)
161
- *
162
- * Validates that sequential attachChild() operations complete within
163
- * acceptable time. This measures cumulative overhead of isDescendantOf()
164
- * validation across multiple operations.
165
- *
166
- * Threshold: < 1000ms (from deep-hierarchy-stress.test.ts:186)
167
- */
168
- it('should complete 100 sequential attachChild operations within acceptable time', () => {
169
- // ARRANGE: Create root workflow
170
- const root = new SimpleWorkflow('Root');
171
- const ITERATIONS = 100;
172
- // ACT: Measure cumulative time for 100 attachments
173
- const totalStartTime = performance.now();
174
- for (let i = 0; i < ITERATIONS; i++) {
175
- const child = new SimpleWorkflow(`Child-${i}`, root);
176
- }
177
- const totalDuration = performance.now() - totalStartTime;
178
- // ASSERT: Verify functional correctness
179
- expect(root.children).toHaveLength(ITERATIONS);
180
- // ASSERT: Performance threshold (< 1000ms from deep-hierarchy-stress.test.ts:186)
181
- expect(totalDuration).toBeLessThan(1000);
182
- // ASSERT: Average time per operation
183
- const avgTime = totalDuration / ITERATIONS;
184
- expect(avgTime).toBeLessThan(10); // < 10ms average
185
- });
186
- });
187
- //# sourceMappingURL=attachChild-performance.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachChild-performance.test.js","sourceRoot":"","sources":["../../../src/__tests__/adversarial/attachChild-performance.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAEnG;;;GAGG;AACH,MAAM,cAAe,SAAQ,QAAQ;IACnC,KAAK,CAAC,GAAG;QACP,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC1B,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAC5B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,QAAQ,CAAC,0CAA0C,EAAE,GAAG,EAAE;IACxD;;;OAGG;IACH,UAAU,CAAC,GAAG,EAAE;QACd,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACtD,EAAE,CAAC,KAAK,CAAC,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
2
- * Circular Reference Tests (TDD Red Phase)
3
- *
4
- * These tests validate the attachChild() method properly prevents
5
- * attaching an ancestor workflow as a child (which would create a circular reference).
6
- *
7
- * This is the RED phase of TDD - tests are written to FAIL initially,
8
- * documenting the expected behavior before implementation.
9
- *
10
- * Related: plan/docs/bugfix-architecture/bug_analysis.md
11
- */
12
- export {};
13
- //# sourceMappingURL=circular-reference.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"circular-reference.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/adversarial/circular-reference.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
@@ -1,92 +0,0 @@
1
- /**
2
- * Circular Reference Tests (TDD Red Phase)
3
- *
4
- * These tests validate the attachChild() method properly prevents
5
- * attaching an ancestor workflow as a child (which would create a circular reference).
6
- *
7
- * This is the RED phase of TDD - tests are written to FAIL initially,
8
- * documenting the expected behavior before implementation.
9
- *
10
- * Related: plan/docs/bugfix-architecture/bug_analysis.md
11
- */
12
- import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
13
- import { Workflow } from '../../index.js';
14
- /**
15
- * SimpleWorkflow class for testing
16
- * Pattern from: src/__tests__/unit/workflow.test.ts:4-11
17
- */
18
- class SimpleWorkflow extends Workflow {
19
- async run() {
20
- this.setStatus('running');
21
- this.setStatus('completed');
22
- return 'done';
23
- }
24
- }
25
- describe('Adversarial: Circular Reference Detection', () => {
26
- /**
27
- * Setup: Mock console methods to capture error messages
28
- * Pattern from: research/console-mocking.md "Basic Spying Patterns"
29
- */
30
- beforeEach(() => {
31
- vi.spyOn(console, 'log').mockImplementation(() => { });
32
- vi.spyOn(console, 'error').mockImplementation(() => { });
33
- vi.spyOn(console, 'warn').mockImplementation(() => { });
34
- });
35
- /**
36
- * Teardown: Restore all mocks to prevent test pollution
37
- * CRITICAL: Always use vi.restoreAllMocks() in afterEach
38
- */
39
- afterEach(() => {
40
- vi.restoreAllMocks();
41
- });
42
- /**
43
- * Test 1: Immediate Circular Reference
44
- *
45
- * Bug: attachChild() does NOT check if the child being attached is actually
46
- * an ancestor of this workflow (would create a circular reference)
47
- *
48
- * Expected: Error thrown with message containing 'circular' OR 'cycle' OR 'ancestor'
49
- * Actual: No error thrown, circular reference created
50
- *
51
- * Pattern from: plan/docs/bugfix-architecture/implementation_patterns.md "Pattern 2"
52
- */
53
- it('should throw when attaching immediate parent as child', () => {
54
- // ARRANGE: Create parent and child workflows
55
- const parent = new SimpleWorkflow('Parent');
56
- const child = new SimpleWorkflow('Child', parent);
57
- // Verify initial state
58
- // CRITICAL: Constructor auto-attaches child to parent at workflow.ts:113-116
59
- expect(child.parent).toBe(parent);
60
- expect(parent.children).toContain(child);
61
- // ACT & ASSERT: Attempting to attach parent as child should throw
62
- // This test FAILS because attachChild() doesn't call this.isDescendantOf(child)
63
- expect(() => child.attachChild(parent)).toThrow(/circular|cycle|ancestor/i);
64
- });
65
- /**
66
- * Test 2: Ancestor Circular Reference (Multi-level)
67
- *
68
- * Bug: attachChild() does NOT check if the child being attached is an ancestor
69
- * anywhere up the parent chain (would create a circular reference)
70
- *
71
- * Expected: Error thrown with message containing 'circular' OR 'cycle' OR 'ancestor'
72
- * Actual: No error thrown, circular reference created
73
- *
74
- * Pattern from: plan/docs/bugfix-architecture/implementation_patterns.md "Pattern 2"
75
- */
76
- it('should throw when attaching ancestor as child', () => {
77
- // ARRANGE: Create 3-level hierarchy
78
- const root = new SimpleWorkflow('Root');
79
- const child1 = new SimpleWorkflow('Child1', root);
80
- const child2 = new SimpleWorkflow('Child2', child1);
81
- // Verify initial state
82
- // CRITICAL: Constructor auto-attaches at workflow.ts:113-116
83
- expect(child2.parent).toBe(child1);
84
- expect(child1.parent).toBe(root);
85
- expect(root.children).toContain(child1);
86
- expect(child1.children).toContain(child2);
87
- // ACT & ASSERT: Attempting to attach root as child of child2 should throw
88
- // This test FAILS because attachChild() doesn't call this.isDescendantOf(child)
89
- expect(() => child2.attachChild(root)).toThrow(/circular|cycle|ancestor/i);
90
- });
91
- });
92
- //# sourceMappingURL=circular-reference.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"circular-reference.test.js","sourceRoot":"","sources":["../../../src/__tests__/adversarial/circular-reference.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;;GAGG;AACH,MAAM,cAAe,SAAQ,QAAQ;IACnC,KAAK,CAAC,GAAG;QACP,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC1B,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAC5B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,QAAQ,CAAC,2CAA2C,EAAE,GAAG,EAAE;IACzD;;;OAGG;IACH,UAAU,CAAC,GAAG,EAAE;QACd,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACtD,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACxD,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH;;;OAGG;IACH,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,eAAe,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH;;;;;;;;;;OAUG;IACH,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC/D,6CAA6C;QAC7C,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,QAAQ,CAAC,C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,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,16 +0,0 @@
1
- /**
2
- * Complex Circular Reference Tests
3
- *
4
- * These tests validate that isDescendantOf() correctly detects circular
5
- * references at various depths in the workflow tree.
6
- *
7
- * Test Cases:
8
- * 1. Immediate circular reference (depth 1): child.attachChild(parent)
9
- * 2. Two-level circular reference (depth 2): grandchild.attachChild(root)
10
- * 3. Three-level circular reference (depth 3): great-grandchild.attachChild(root)
11
- *
12
- * Pattern from: plan/docs/bugfix-architecture/implementation_patterns.md Pattern 8
13
- * Related: plan/bugfix/P1M3T1S3/PRP.md
14
- */
15
- export {};
16
- //# sourceMappingURL=complex-circular-reference.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"complex-circular-reference.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/adversarial/complex-circular-reference.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
@@ -1,127 +0,0 @@
1
- /**
2
- * Complex Circular Reference Tests
3
- *
4
- * These tests validate that isDescendantOf() correctly detects circular
5
- * references at various depths in the workflow tree.
6
- *
7
- * Test Cases:
8
- * 1. Immediate circular reference (depth 1): child.attachChild(parent)
9
- * 2. Two-level circular reference (depth 2): grandchild.attachChild(root)
10
- * 3. Three-level circular reference (depth 3): great-grandchild.attachChild(root)
11
- *
12
- * Pattern from: plan/docs/bugfix-architecture/implementation_patterns.md Pattern 8
13
- * Related: plan/bugfix/P1M3T1S3/PRP.md
14
- */
15
- import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
16
- import { Workflow } from '../../index.js';
17
- /**
18
- * SimpleWorkflow class for testing
19
- * Pattern from: src/__tests__/adversarial/circular-reference.test.ts:20-26
20
- */
21
- class SimpleWorkflow extends Workflow {
22
- async run() {
23
- this.setStatus('running');
24
- this.setStatus('completed');
25
- return 'done';
26
- }
27
- }
28
- describe('Adversarial: Complex Circular Reference Detection', () => {
29
- /**
30
- * Setup: Mock console methods to capture error messages
31
- * Pattern from: src/__tests__/adversarial/circular-reference.test.ts:33-37
32
- */
33
- beforeEach(() => {
34
- vi.spyOn(console, 'log').mockImplementation(() => { });
35
- vi.spyOn(console, 'error').mockImplementation(() => { });
36
- vi.spyOn(console, 'warn').mockImplementation(() => { });
37
- });
38
- /**
39
- * Teardown: Restore all mocks to prevent test pollution
40
- * CRITICAL: Always use vi.restoreAllMocks() in afterEach
41
- */
42
- afterEach(() => {
43
- vi.restoreAllMocks();
44
- });
45
- /**
46
- * Test 1: Immediate Circular Reference (depth 1)
47
- *
48
- * Validates that attachChild() prevents creating a cycle when a child
49
- * attempts to attach its immediate parent as its child.
50
- *
51
- * Hierarchy: root -> child1
52
- * Cycle attempt: child1.attachChild(root)
53
- *
54
- * Expected: Error thrown with message containing 'circular' OR 'cycle' OR 'ancestor'
55
- */
56
- it('should throw when attaching immediate parent as child (depth 1)', () => {
57
- // ARRANGE: Create 2-level hierarchy (root, child1)
58
- const root = new SimpleWorkflow('Root');
59
- const child1 = new SimpleWorkflow('Child1', root);
60
- // Verify initial state
61
- // CRITICAL: Constructor auto-attaches child to parent at workflow.ts:113-116
62
- expect(child1.parent).toBe(root);
63
- expect(root.children).toContain(child1);
64
- // ACT & ASSERT: Attempting to attach parent as child should throw
65
- // This validates isDescendantOf() detects the immediate ancestor
66
- expect(() => child1.attachChild(root)).toThrow(/circular|cycle|ancestor/i);
67
- });
68
- /**
69
- * Test 2: Two-Level Circular Reference (depth 2)
70
- *
71
- * Validates that attachChild() prevents creating a cycle when a grandchild
72
- * attempts to attach its grandparent (root) as its child.
73
- *
74
- * Hierarchy: root -> child1 -> child2
75
- * Cycle attempt: child2.attachChild(root)
76
- *
77
- * Expected: Error thrown with message containing 'circular' OR 'cycle' OR 'ancestor'
78
- */
79
- it('should throw when attaching grandparent as child (depth 2)', () => {
80
- // ARRANGE: Create 3-level hierarchy (root, child1, child2)
81
- const root = new SimpleWorkflow('Root');
82
- const child1 = new SimpleWorkflow('Child1', root);
83
- const child2 = new SimpleWorkflow('Child2', child1);
84
- // Verify initial state
85
- // CRITICAL: Constructor auto-attaches at workflow.ts:113-116
86
- expect(child2.parent).toBe(child1);
87
- expect(child1.parent).toBe(root);
88
- expect(root.children).toContain(child1);
89
- expect(child1.children).toContain(child2);
90
- // ACT & ASSERT: Attempting to attach root as child of child2 should throw
91
- // This validates isDescendantOf() traverses the full ancestor chain
92
- expect(() => child2.attachChild(root)).toThrow(/circular|cycle|ancestor/i);
93
- });
94
- /**
95
- * Test 3: Three-Level Circular Reference (depth 3)
96
- *
97
- * Validates that attachChild() prevents creating a cycle when a great-grandchild
98
- * attempts to attach its great-grandparent (root) as its child.
99
- *
100
- * Hierarchy: root -> child1 -> child2 -> child3
101
- * Cycle attempt: child3.attachChild(root)
102
- *
103
- * Expected: Error thrown with message containing 'circular' OR 'cycle' OR 'ancestor'
104
- *
105
- * This test provides NEW coverage not present in circular-reference.test.ts
106
- * which only tests depth 1 (immediate parent) and depth 2 (ancestor).
107
- */
108
- it('should throw when attaching great-grandparent as child (depth 3)', () => {
109
- // ARRANGE: Create 4-level hierarchy (root, child1, child2, child3)
110
- const root = new SimpleWorkflow('Root');
111
- const child1 = new SimpleWorkflow('Child1', root); // root -> child1
112
- const child2 = new SimpleWorkflow('Child2', child1); // root -> child1 -> child2
113
- const child3 = new SimpleWorkflow('Child3', child2); // root -> child1 -> child2 -> child3
114
- // Verify initial state
115
- // CRITICAL: Constructor auto-attaches at workflow.ts:113-116
116
- expect(child3.parent).toBe(child2);
117
- expect(child2.parent).toBe(child1);
118
- expect(child1.parent).toBe(root);
119
- expect(root.children).toContain(child1);
120
- expect(child1.children).toContain(child2);
121
- expect(child2.children).toContain(child3);
122
- // ACT & ASSERT: Attempting to attach root as child of child3 should throw
123
- // This validates isDescendantOf() detects deep ancestors (3+ levels)
124
- expect(() => child3.attachChild(root)).toThrow(/circular|cycle|ancestor/i);
125
- });
126
- });
127
- //# sourceMappingURL=complex-circular-reference.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"complex-circular-reference.test.js","sourceRoot":"","sources":["../../../src/__tests__/adversarial/complex-circular-reference.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;;GAGG;AACH,MAAM,cAAe,SAAQ,QAAQ;IACnC,KAAK,CAAC,GAAG;QACP,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC1B,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAC5B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,QAAQ,CAAC,mDAAmD,EAAE,GAAG,EAAE;IACjE;;;OAGG;IACH,UAAU,CAAC,GAAG,EAAE;QACd,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACtD,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACxD,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH;;;OAGG;IACH,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,eAAe,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH;;;;;;;;;;OAUG;IACH,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;QACzE,mDAAmD;QACnD,MAAM,IAAI,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;QACxC,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,QAAQ,EAAE,IAAI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EAAE,GAAG,EAAE;QAC1E,mEAAmE;QACnE,MAAM,IAAI,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;QACxC,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAG,iBAAiB;QACtE,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,2BAA2B;QAChF,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,qCAAqC;QAE1F,uBAAuB;QACvB,6DAA6D;QAC7D,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACxC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC1C,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAE1C,0EAA0E;QAC1E,qEAAqE;QACrE,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,21 +0,0 @@
1
- /**
2
- * Concurrent Task Failure Scenarios Test Suite
3
- *
4
- * Tests the Promise.allSettled implementation in @Task decorator
5
- * for concurrent execution with various failure scenarios.
6
- *
7
- * Validates:
8
- * - Single child failure in concurrent batch
9
- * - Multiple children failing concurrently
10
- * - Mixed success/failure scenarios
11
- * - All children failing edge case
12
- * - No orphaned or hanging promises
13
- * - Error collection correctness
14
- * - Event emission during failures
15
- *
16
- * Related:
17
- * - S2 Implementation: Promise.allSettled in task.ts (lines 111-120)
18
- * - Bug: 001_e8e04329daf3 - Concurrent task error collection
19
- */
20
- export {};
21
- //# sourceMappingURL=concurrent-task-failures.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"concurrent-task-failures.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/adversarial/concurrent-task-failures.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG"}