groundswell 0.0.1 → 0.0.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 (242) hide show
  1. package/.claude/commands/subtask-planning/prp-base-create.md +120 -0
  2. package/.claude/commands/subtask-planning/prp-base-execute.md +65 -0
  3. package/.claude/commands/task-breakdown.md +94 -0
  4. package/.claude/system_prompts/task-breakdown.md +1 -0
  5. package/CHANGELOG.md +188 -0
  6. package/PRD.md +543 -0
  7. package/README.md +99 -5
  8. package/examples/README.md +15 -1
  9. package/examples/examples/11-reparenting-workflows.ts +269 -0
  10. package/examples/index.ts +4 -0
  11. package/package-lock.json +2398 -0
  12. package/package.json +3 -1
  13. package/plan/001_d3bb02af4886/TEST_RESULTS.md +259 -0
  14. package/plan/001_d3bb02af4886/bug_fix_tasks.json +484 -0
  15. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M1T1S1/PRP.md +488 -0
  16. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M1T1S2/PRP.md +581 -0
  17. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M1T1S3/PRP.md +687 -0
  18. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T1S1/PRP.md +492 -0
  19. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T1S3/PRP.md +932 -0
  20. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T1S3/research/concurrent_error_testing_patterns.md +1109 -0
  21. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T1S3/research/vitest_concurrent_testing.md +802 -0
  22. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T1S3/research/workflow_engine_test_references.md +603 -0
  23. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T2S1/PRP.md +564 -0
  24. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T2S3/PRP.md +518 -0
  25. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T2S4/PRP.md +1252 -0
  26. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T3S1/PRP.md +364 -0
  27. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T3S1/research/CODEBASE_INVENTORY.md +114 -0
  28. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T3S1/research/DECORATOR_DOCUMENTATION_PATTERNS.md +205 -0
  29. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T3S1/research/PRD_LOCATION_ANALYSIS.md +199 -0
  30. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T3S1/research/ULTRATHINK_PRP_PLAN.md +134 -0
  31. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T1S1/PRP.md +495 -0
  32. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T1S1/research/console_error_inventory.md +435 -0
  33. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T1S2/PRP.md +506 -0
  34. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T1S3/PRP.md +612 -0
  35. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S2/PRP.md +558 -0
  36. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S2/research/external_research.md +788 -0
  37. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T3S2/PRP.md +460 -0
  38. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T3S3/PRP.md +454 -0
  39. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T4S1/PRP.md +520 -0
  40. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T4S1/RECOMMENDATION.md +417 -0
  41. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T4S1/research/external_workflow_engines_research.md +760 -0
  42. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T4S1/research/security_implications_analysis.md +245 -0
  43. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T4S2/PRP.md +792 -0
  44. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M4T1S1/PRP.md +535 -0
  45. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M4T1S1/TEST_EXECUTION_REPORT.md +190 -0
  46. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M4T1S2/PRP.md +654 -0
  47. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M4T1S2/TEST_FIX_REPORT.md +227 -0
  48. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M4T1S2/research/KEY_FINDINGS.md +345 -0
  49. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M4T1S2/research/QUICK_REFERENCE.md +193 -0
  50. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M4T1S2/research/test_maintenance_research.md +1323 -0
  51. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M4T3S1/BREAKING_CHANGES_AUDIT.md +1011 -0
  52. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M4T3S1/PRP.md +927 -0
  53. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M4T3S2/PRP.md +505 -0
  54. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/architecture/logger_child_signature_analysis.md +401 -0
  55. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M1T1S3/child_implementation_research.md +142 -0
  56. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M1T1S3/test_patterns_research.md +112 -0
  57. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M1T1S3/vitest_patterns_research.md +159 -0
  58. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M1T1S4/PRP.md +549 -0
  59. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M1T1S4/VERIFICATION_REPORT.md +368 -0
  60. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M1T1S4/edge_case_analysis.md +172 -0
  61. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M1T1S4/usage_inventory.md +175 -0
  62. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T1S2/PRP.md +696 -0
  63. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T1S4/PRP.md +860 -0
  64. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/PRP.md +1066 -0
  65. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/01-testing-aggregated-errors.md +1103 -0
  66. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/01_typescript_error_aggregation_patterns.md +789 -0
  67. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/02-error-merge-strategy-testing-guide.md +1098 -0
  68. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/02_aggregate_error_patterns.md +1037 -0
  69. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/03-promise-allsettled-testing-patterns.md +916 -0
  70. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/03_error_merging_strategies.md +1045 -0
  71. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/04_github_stackoverflow_examples.md +890 -0
  72. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/05_comprehensive_summary.md +822 -0
  73. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/INDEX.md +668 -0
  74. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/QUICK_REFERENCE.md +706 -0
  75. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/README.md +265 -0
  76. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/RESEARCH_REPORT.md +655 -0
  77. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S4/research/vitest_testing_patterns.md +1103 -0
  78. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T3S2/PRP.md +426 -0
  79. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T1S2/PRP.md +506 -0
  80. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T1S2/research/QUICK_REFERENCE.md +114 -0
  81. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T1S2/research/RESEARCH_SUMMARY.md +316 -0
  82. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T1S2/research/vitest_observer_error_logging_best_practices.md +754 -0
  83. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T1S3/PRP.md +612 -0
  84. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T2S1/PRP.md +719 -0
  85. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T2S1/README.md +215 -0
  86. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T2S1/analysis.md +765 -0
  87. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T2S3/PRP.md +718 -0
  88. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T3S1/DECISION.md +149 -0
  89. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T3S1/PRP.md +470 -0
  90. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T3S1/research/ULTRATHINK_PLAN.md +332 -0
  91. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T3S1/research/codebase_workflow_name_analysis.md +167 -0
  92. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T3S1/research/external_best_practices.md +265 -0
  93. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T3S1/research/validation_patterns.md +273 -0
  94. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T4S1/workflow_engine_ancestry_api_research.md +760 -0
  95. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T4S3-PRP.md +434 -0
  96. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M4T2S1/PRP.md +717 -0
  97. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M4T2S2/PRP.md +472 -0
  98. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M4T2S2/VALIDATION_REPORT.md +125 -0
  99. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M4T2S2/research/ULTRATHINK_PRP_PLAN.md +301 -0
  100. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/error-logging-best-practices.md +1170 -0
  101. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/research_typescript_partial_and_overloads.md +940 -0
  102. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/vitest-quick-reference.md +151 -0
  103. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/vitest-research.md +650 -0
  104. package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/prd_snapshot.md +259 -0
  105. package/plan/001_d3bb02af4886/bugfix/P1M1T1S1/PRP.md +457 -0
  106. package/plan/001_d3bb02af4886/bugfix/RESEARCH_SUMMARY.md +346 -0
  107. package/plan/001_d3bb02af4886/bugfix/architecture/codebase_structure.md +311 -0
  108. package/plan/001_d3bb02af4886/bugfix/architecture/concurrent_execution_best_practices.md +1565 -0
  109. package/plan/001_d3bb02af4886/bugfix/architecture/error_handling_patterns.md +288 -0
  110. package/plan/001_d3bb02af4886/bugfix/architecture/promise_all_analysis.md +741 -0
  111. package/plan/001_d3bb02af4886/docs/PRP/P1M1T1S4-functional-workflow-error-state-capture-test.md +652 -0
  112. package/plan/001_d3bb02af4886/docs/PRP/PRP.md +527 -0
  113. package/plan/001_d3bb02af4886/docs/PRP/bugfix/P1M1T2S1-PRP.md +415 -0
  114. package/plan/001_d3bb02af4886/docs/PRP/bugfix/P1M1T2S2-PRP.md +378 -0
  115. package/plan/001_d3bb02af4886/docs/PRP/bugfix/P1M1T2S4-PRP.md +713 -0
  116. package/plan/001_d3bb02af4886/docs/PRP/bugfix/P1M2T1S4-PRP.md +370 -0
  117. package/plan/001_d3bb02af4886/docs/PRP_P1M3T1S3.md +499 -0
  118. package/plan/001_d3bb02af4886/docs/TEST_RESULTS.md +230 -0
  119. package/plan/001_d3bb02af4886/docs/bugfix/ANALYSIS_PRD_VS_IMPLEMENTATION.md +1134 -0
  120. package/plan/001_d3bb02af4886/docs/bugfix/GAP_ANALYSIS_SUMMARY.md +179 -0
  121. package/plan/001_d3bb02af4886/docs/bugfix/P1M4T2S1/PRP.md +629 -0
  122. package/plan/001_d3bb02af4886/docs/bugfix/P1M4T2S1/validation-report.md +214 -0
  123. package/plan/001_d3bb02af4886/docs/bugfix/PRP_P1M4T2S3.md +629 -0
  124. package/plan/001_d3bb02af4886/docs/bugfix/bugfix_PRP.md +529 -0
  125. package/plan/001_d3bb02af4886/docs/bugfix/bugfix_QUICK_REFERENCE.md +142 -0
  126. package/plan/001_d3bb02af4886/docs/bugfix/bugfix_README.md +304 -0
  127. package/plan/001_d3bb02af4886/docs/bugfix/bugfix_TEST_RESULTS.md +558 -0
  128. package/plan/001_d3bb02af4886/docs/bugfix/bugfix_VALIDATION_SUMMARY.md +256 -0
  129. package/plan/001_d3bb02af4886/docs/bugfix/system_context.md +346 -0
  130. package/plan/001_d3bb02af4886/docs/bugfix-architecture/bug_analysis.md +415 -0
  131. package/plan/001_d3bb02af4886/docs/bugfix-architecture/implementation_patterns.md +489 -0
  132. package/plan/001_d3bb02af4886/docs/bugfix-architecture/system_context.md +218 -0
  133. package/plan/001_d3bb02af4886/docs/bugfix_INITIATION_SUMMARY.md +380 -0
  134. package/plan/001_d3bb02af4886/docs/research/CYCLE_DETECTION_PATTERNS.md +1923 -0
  135. package/plan/001_d3bb02af4886/docs/research/CYCLE_DETECTION_QUICK_REF.md +319 -0
  136. package/plan/001_d3bb02af4886/docs/research/P1M1T2S1/codebase-context.md +115 -0
  137. package/plan/001_d3bb02af4886/docs/research/P1M1T2S1/cycle-detection-algorithms.md +134 -0
  138. package/plan/001_d3bb02af4886/docs/research/P1M1T2S1/test-patterns.md +153 -0
  139. package/plan/001_d3bb02af4886/docs/research/P1M1T2S1/workflow-class.md +132 -0
  140. package/plan/001_d3bb02af4886/docs/research/P1M2T1S4/DECORATOR_DOCUMENTATION_BEST_PRACTICES.md +716 -0
  141. package/plan/001_d3bb02af4886/docs/research/P1M2T1S4/DECORATOR_DOCUMENTATION_QUICK_REF.md +186 -0
  142. package/plan/001_d3bb02af4886/docs/research/P1M2T1S4/GROUNDSWELL_DECORATOR_EXAMPLES.md +604 -0
  143. package/plan/001_d3bb02af4886/docs/research/P1M2T1S4/INDEX.md +213 -0
  144. package/plan/001_d3bb02af4886/docs/research/P1M2T1S4/codebase_structure.md +30 -0
  145. package/plan/001_d3bb02af4886/docs/research/P1M2T1S4/existing_test_pattern.md +56 -0
  146. package/plan/001_d3bb02af4886/docs/research/P1M2T1S4/getRootObservers_implementation.md +53 -0
  147. package/plan/001_d3bb02af4886/docs/research/P1M2T1S4/test_conventions.md +49 -0
  148. package/plan/001_d3bb02af4886/docs/research/P1M3T1S4/PRP.md +958 -0
  149. package/plan/001_d3bb02af4886/docs/research/P1M3T1S4/QUICK_REFERENCE.md +339 -0
  150. package/plan/001_d3bb02af4886/docs/research/P1M3T1S4/README.md +305 -0
  151. package/plan/001_d3bb02af4886/docs/research/P1M3T1S4/SUMMARY.md +433 -0
  152. package/plan/001_d3bb02af4886/docs/research/P1M3T1S4/bidirectional-tree-consistency-testing.md +1574 -0
  153. package/plan/001_d3bb02af4886/docs/research/P1M3T1S4/test-pattern-examples.md +1014 -0
  154. package/plan/001_d3bb02af4886/docs/research/PROMISE_ALLSETTLED_QUICK_REF.md +376 -0
  155. package/plan/001_d3bb02af4886/docs/research/PROMISE_ALLSETTLED_RESEARCH.md +1507 -0
  156. package/plan/001_d3bb02af4886/docs/research/bugfix_typescript_patterns.md +949 -0
  157. package/plan/001_d3bb02af4886/docs/research/error-testing-research.md +619 -0
  158. package/plan/001_d3bb02af4886/docs/research/error_handling_patterns.md +723 -0
  159. package/plan/{research → 001_d3bb02af4886/docs/research/general}/introspection-security-guide.md +56 -0
  160. package/plan/001_d3bb02af4886/docs/research/incremental-tree-map-updates/PRP_TEMPLATE.md +460 -0
  161. package/plan/001_d3bb02af4886/docs/research/incremental-tree-map-updates/QUICK_REFERENCE.md +324 -0
  162. package/plan/001_d3bb02af4886/docs/research/incremental-tree-map-updates/README.md +175 -0
  163. package/plan/001_d3bb02af4886/docs/research/incremental-tree-map-updates/RESEARCH_REPORT.md +499 -0
  164. package/plan/001_d3bb02af4886/docs/research/incremental-tree-map-updates/SUMMARY.md +163 -0
  165. package/plan/bugfix/BUG_FIX_SUMMARY.md +961 -0
  166. package/src/__tests__/adversarial/attachChild-performance.test.ts +216 -0
  167. package/src/__tests__/adversarial/circular-reference.test.ts +101 -0
  168. package/src/__tests__/adversarial/complex-circular-reference.test.ts +139 -0
  169. package/src/__tests__/adversarial/concurrent-task-failures.test.ts +571 -0
  170. package/src/__tests__/adversarial/deep-analysis.test.ts +729 -0
  171. package/src/__tests__/adversarial/deep-hierarchy-stress.test.ts +213 -0
  172. package/src/__tests__/adversarial/e2e-prd-validation.test.ts +448 -0
  173. package/src/__tests__/adversarial/edge-case.test.ts +703 -0
  174. package/src/__tests__/adversarial/error-merge-strategy.test.ts +760 -0
  175. package/src/__tests__/adversarial/incremental-performance.test.ts +140 -0
  176. package/src/__tests__/adversarial/node-map-update-benchmarks.test.ts +457 -0
  177. package/src/__tests__/adversarial/observer-propagation.test.ts +487 -0
  178. package/src/__tests__/adversarial/parent-validation.test.ts +143 -0
  179. package/src/__tests__/adversarial/prd-12-2-compliance.test.ts +611 -0
  180. package/src/__tests__/adversarial/prd-compliance.test.ts +731 -0
  181. package/src/__tests__/compatibility/backward-compatibility.test.ts +1572 -0
  182. package/src/__tests__/helpers/index.ts +18 -0
  183. package/src/__tests__/helpers/tree-verification.ts +257 -0
  184. package/src/__tests__/integration/bidirectional-consistency.test.ts +847 -0
  185. package/src/__tests__/integration/observer-logging.test.ts +643 -0
  186. package/src/__tests__/integration/tree-mirroring.test.ts +37 -0
  187. package/src/__tests__/integration/workflow-reparenting.test.ts +303 -0
  188. package/src/__tests__/unit/context.test.ts +79 -0
  189. package/src/__tests__/unit/logger.test.ts +293 -0
  190. package/src/__tests__/unit/observable.test.ts +321 -0
  191. package/src/__tests__/unit/tree-debugger-incremental.test.ts +170 -0
  192. package/src/__tests__/unit/utils/workflow-error-utils.test.ts +209 -0
  193. package/src/__tests__/unit/workflow-detachChild.test.ts +100 -0
  194. package/src/__tests__/unit/workflow-emitEvent-childDetached.test.ts +153 -0
  195. package/src/__tests__/unit/workflow-isDescendantOf.test.ts +180 -0
  196. package/src/__tests__/unit/workflow.test.ts +277 -1
  197. package/src/core/agent.ts +21 -1
  198. package/src/core/logger.ts +27 -2
  199. package/src/core/workflow-context.ts +6 -4
  200. package/src/core/workflow.ts +252 -14
  201. package/src/debugger/tree-debugger.ts +52 -7
  202. package/src/decorators/task.ts +65 -2
  203. package/src/index.ts +4 -2
  204. package/src/types/decorators.ts +8 -1
  205. package/src/types/events.ts +1 -0
  206. package/src/utils/index.ts +1 -0
  207. package/src/utils/observable.ts +32 -3
  208. package/src/utils/workflow-error-utils.ts +56 -0
  209. package/tsconfig.json +1 -1
  210. package/llms_full.txt +0 -5890
  211. package/tasks.json +0 -0
  212. /package/plan/{backlog.json → 001_d3bb02af4886/backlog.json} +0 -0
  213. /package/plan/{P1P2/PRP.md → 001_d3bb02af4886/docs/PRP/P1P2-PRP.md} +0 -0
  214. /package/plan/{P3P4/PRP.md → 001_d3bb02af4886/docs/PRP/P3P4-PRP.md} +0 -0
  215. /package/plan/{P4P5/PRP.md → 001_d3bb02af4886/docs/PRP/P4P5-PRP.md} +0 -0
  216. /package/plan/{architecture → 001_d3bb02af4886/docs/architecture}/external_deps.md +0 -0
  217. /package/plan/{architecture → 001_d3bb02af4886/docs/architecture}/system_context.md +0 -0
  218. /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/LRU_CACHE_BEST_PRACTICES.md +0 -0
  219. /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/LRU_CACHE_CODE_PATTERNS.md +0 -0
  220. /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/LRU_CACHE_INTEGRATION_GUIDE.md +0 -0
  221. /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/LRU_CACHE_RESEARCH_INDEX.md +0 -0
  222. /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/REFLECTION_INDEX.md +0 -0
  223. /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/REFLECTION_RESEARCH_REPORT.md +0 -0
  224. /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/RESEARCH_SUMMARY.md +0 -0
  225. /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/anthropic-sdk.md +0 -0
  226. /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/async-local-storage.md +0 -0
  227. /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/reflection-code-patterns.md +0 -0
  228. /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/reflection-decision-matrix.md +0 -0
  229. /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/reflection-implementation-guide.md +0 -0
  230. /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/reflection-integration-guide.md +0 -0
  231. /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/reflection-patterns.md +0 -0
  232. /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/reflection-quick-reference.md +0 -0
  233. /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/zod-schema.md +0 -0
  234. /package/plan/{P3P4/research → 001_d3bb02af4886/docs/research/P3P4}/caching-lru.md +0 -0
  235. /package/plan/{P3P4/research → 001_d3bb02af4886/docs/research/P3P4}/introspection-tools.md +0 -0
  236. /package/plan/{P3P4/research → 001_d3bb02af4886/docs/research/P3P4}/reflection-patterns.md +0 -0
  237. /package/plan/{P4P5/research → 001_d3bb02af4886/docs/research/P4P5}/RESEARCH_SUMMARY.md +0 -0
  238. /package/plan/{research → 001_d3bb02af4886/docs/research/general}/INTROSPECTION_RESEARCH_SUMMARY.md +0 -0
  239. /package/plan/{research → 001_d3bb02af4886/docs/research/general}/README-INTROSPECTION.md +0 -0
  240. /package/plan/{research → 001_d3bb02af4886/docs/research/general}/agent-introspection-patterns.md +0 -0
  241. /package/plan/{research → 001_d3bb02af4886/docs/research/general}/introspection-tool-examples.md +0 -0
  242. /package/{PRPs/PRDs/001-hierarchical-workflow-engine.md → plan/001_d3bb02af4886/prd_snapshot.md} +0 -0
@@ -0,0 +1,120 @@
1
+ # Create BASE PRP
2
+
3
+ ## Feature: $ARGUMENTS or $(tsk next) subtask
4
+
5
+ ## PRP Creation Mission
6
+
7
+ Create a comprehensive PRP that enables **one-pass implementation success** through systematic research and context curation.
8
+
9
+
10
+ **Critical Understanding**:
11
+ You must start by reading and understanding the prp concepts plan/README.md
12
+ Be aware that the executing AI agent only receives:
13
+ - The PRP content you create
14
+ - Its training data knowledge
15
+ - Access to codebase files (but needs guidance on which ones)
16
+
17
+
18
+ **Therefore**: Your research and context curation directly determines implementation success. Incomplete context = implementation failure.
19
+
20
+ ## Research Process
21
+
22
+ > During the research process, create clear tasks and spawn as many agents and subagents as needed using the batch tools. The deeper research we do here the better the PRP will be. We optimize for chance of success, not for speed.
23
+
24
+ 1. **Codebase Analysis in depth**
25
+ - Create clear todos and spawn subagents to search the codebase for similar features/patterns. Think hard and plan your approach
26
+ - Identify all the necessary files to reference in the PRP
27
+ - Note all existing conventions to follow
28
+ - Check existing test patterns for validation approach, if none are found plan to find a new one
29
+ - Use the batch tools to spawn subagents to search the codebase for similar features/patterns
30
+
31
+ 2. **Internal Research at scale**
32
+ - Use relevant research and plan information in the `plan/M#P#T#S#` directory according to the current subtask
33
+ - Consider the scope of the subtask within the overall PRD. Respect the boundaries of scope of implementation for this task. Ensure cohesion across
34
+ previously completed tasks and guard against harming future task completion in your plan
35
+
36
+ 2. **External Research at scale**
37
+ - Create clear todos and spawn subagents with instructions to do deep research for similar features/patterns online and include urls to documentation and examples
38
+ - Library documentation (include specific URLs)
39
+ - Store all research in plans/\[M#P#T#S#]/research according to the current task and reference critical pieces of documentation in the PRP with clear
40
+ reasoning and instructions
41
+ - Implementation examples (GitHub/StackOverflow/blogs)
42
+ - New validation approach none found in existing codebase and user confirms they would like one added
43
+ - Best practices and common pitfalls found during research
44
+ - Use the batch tools to spawn subagents to search for similar features/patterns online and include urls to documentation and examples
45
+
46
+ 3. **User Clarification**
47
+ - Ask for clarification if you need it
48
+ - If no testing framework is found, ask the user if they would like to set one up
49
+ - If a fundamental misalignemnt of objectives across tasks is detected, halt and produce a thorough explanation of the problem at a 10th grade level
50
+
51
+ ## PRP Generation Process
52
+
53
+ ### Step 1: Choose Template
54
+
55
+ Use `plan/templates/prp_base.md` as your template structure - it contains all necessary sections and formatting.
56
+
57
+ ### Step 2: Context Completeness Validation
58
+
59
+ Before writing, apply the **"No Prior Knowledge" test** from the template:
60
+ _"If someone knew nothing about this codebase, would they have everything needed to implement this successfully?"_
61
+
62
+ ### Step 3: Research Integration
63
+
64
+ Transform your research findings into the template sections:
65
+
66
+ **Goal Section**: Use research to define specific, measurable Feature Goal and concrete Deliverable
67
+ **Context Section**: Populate YAML structure with your research findings - specific URLs, file patterns, gotchas
68
+ **Implementation Tasks**: Create dependency-ordered tasks using information-dense keywords from codebase analysis
69
+ **Validation Gates**: Use project-specific validation commands that you've verified work in this codebase
70
+
71
+ ### Step 4: Information Density Standards
72
+
73
+ Ensure every reference is **specific and actionable**:
74
+
75
+ - URLs include section anchors, not just domain names
76
+ - File references include specific patterns to follow, not generic mentions
77
+ - Task specifications include exact naming conventions and placement
78
+ - Validation commands are project-specific and executable
79
+
80
+ ### Step 5: ULTRATHINK Before Writing
81
+
82
+ After research completion, create comprehensive PRP writing plan using TodoWrite tool:
83
+
84
+ - Plan how to structure each template section with your research findings
85
+ - Identify gaps that need additional research
86
+ - Create systematic approach to filling template with actionable context
87
+
88
+ ## Output
89
+
90
+ Store the PRP at `plan/M#P#T#S#/PRP.md`
91
+ Store documentation at `plan/M#P#T#S#/research/`
92
+
93
+ ## PRP Quality Gates
94
+
95
+ ### Context Completeness Check
96
+
97
+ - [ ] Passes "No Prior Knowledge" test from template
98
+ - [ ] All YAML references are specific and accessible
99
+ - [ ] Implementation tasks include exact naming and placement guidance
100
+ - [ ] Validation commands are project-specific and verified working
101
+
102
+ ### Template Structure Compliance
103
+
104
+ - [ ] All required template sections completed
105
+ - [ ] Goal section has specific Feature Goal, Deliverable, Success Definition
106
+ - [ ] Implementation Tasks follow dependency ordering
107
+ - [ ] Final Validation Checklist is comprehensive
108
+
109
+ ### Information Density Standards
110
+
111
+ - [ ] No generic references - all are specific and actionable
112
+ - [ ] File patterns point at specific examples to follow
113
+ - [ ] URLs include section anchors for exact guidance
114
+ - [ ] Task specifications use information-dense keywords from codebase
115
+
116
+ ## Success Metrics
117
+
118
+ **Confidence Score**: Rate 1-10 for one-pass implementation success likelihood
119
+
120
+ **Validation**: The completed PRP should enable an AI agent unfamiliar with the codebase to implement the feature successfully using only the PRP content and codebase access.
@@ -0,0 +1,65 @@
1
+ # Execute BASE PRP
2
+
3
+ ## PRP File: $ARGUMENTS or $(tsk next) subtask information located at plans/M#P#T#S#/PRP.md
4
+
5
+ ## Mission: One-Pass Implementation Success
6
+
7
+ PRPs enable working code on the first attempt through:
8
+
9
+ - **Context Completeness**: Everything needed, nothing guessed
10
+ - **Progressive Validation**: 4-level gates catch errors early
11
+ - **Pattern Consistency**: Follow existing codebase approaches
12
+ - Read PRPs/README.md to understand PRP concepts
13
+
14
+ **Your Goal**: Transform the PRP into working code that passes all validation gates.
15
+
16
+ ## Execution Process
17
+
18
+ 1. **Load PRP**
19
+ - Read the specified PRP file completely
20
+ - Absorb all context, patterns, requirements and gather codebase intelligence
21
+ - Use the provided documentation references and file patterns, consume the right documentation before the appropriate todo/task
22
+ - Trust the PRP's context and guidance - it's designed for one-pass success
23
+ - If needed do additional codebase exploration and research as needed
24
+
25
+ 2. **ULTRATHINK & Plan**
26
+ - Create comprehensive implementation plan following the PRP's task order
27
+ - Break down into clear todos using TodoWrite tool
28
+ - Use subagents for parallel work when beneficial (always create prp inspired prompts for subagents when used)
29
+ - Follow the patterns referenced in the PRP
30
+ - Use specific file paths, class names, and method signatures from PRP context
31
+ - Never guess - always verify the codebase patterns and examples referenced in the PRP yourself
32
+
33
+ 3. **Execute Implementation**
34
+ - Follow the PRP's Implementation Tasks sequence, add more detail as needed, especially when using subagents
35
+ - Use the patterns and examples referenced in the PRP
36
+ - Create files in locations specified by the desired codebase tree
37
+ - Apply naming conventions from the task specifications and CLAUDE.md
38
+
39
+ 4. **Progressive Validation**
40
+
41
+ **Execute the level validation system from the PRP:**
42
+ - **Level 1**: Run syntax & style validation commands from PRP
43
+ - **Level 2**: Execute unit test validation from PRP
44
+ - **Level 3**: Run integration testing commands from PRP
45
+ - **Level 4**: Execute specified validation from PRP
46
+
47
+ **Each level must pass before proceeding to the next.**
48
+
49
+ 5. **Completion Verification**
50
+ - Work through the Final Validation Checklist in the PRP
51
+ - Verify all Success Criteria from the "What" section are met
52
+ - Confirm all Anti-Patterns were avoided
53
+ - Implementation is ready and working
54
+
55
+ **Failure Protocol**: When validation fails, use the patterns and gotchas from the PRP to fix issues, then re-run validation until passing.
56
+
57
+ If a fundamental issue with the plan is found, halt and produce a thorough explanation of the problem at a 10th grade level.
58
+
59
+ Strictly output your results in this JSON format:
60
+
61
+ ```json
62
+ {
63
+ "result": "success" | "error" | "issue",
64
+ "message": "Detailed explanation of the issue"
65
+ }
@@ -0,0 +1,94 @@
1
+ Act as a Lead Technical Architect and Project Management Synthesizer. You have already convened a panel of senior specialists (Security, DevOps, Backend, Frontend, and QA) who hold adversarial views on scope and complexity. Your job is not to output their debate, but to output their rigorous, unified consensus on how to decompose the attached PRD.
2
+
3
+ Your Primary Goal: Assess the PRD to determine its hierarchy (Phase > Milestone > Task > Subtask) and decompose it into atomic, coherent work units.
4
+
5
+ Hierarchy Definitions:
6
+
7
+ Phase: Project-scope goals (e.g., MVP, V1.0). Weeks to months of effort.
8
+
9
+ Milestone: Key objectives within a Phase. 1 to 12 weeks of effort.
10
+
11
+ Task: Complete features within a Milestone. Days to weeks of effort.
12
+
13
+ Subtask: Atomic implementation steps. 0.5, 1, or 2 Story Points (SP). Max 2 SP per subtask.
14
+
15
+ Critical Constraints & Standard of Work (SOW):
16
+
17
+ Coherence & Continuity (Priority):
18
+
19
+ You must ensure architectural flow. Subtasks must not exist in a vacuum.
20
+
21
+ If Subtask A defines a data schema, Subtask B must explicitly be told to consume that specific schema.
22
+
23
+ Reference specific file paths, variable names, or API endpoints within the context_scope to ensure the implementing agent follows the chain of logic.
24
+
25
+ Implicit TDD & Quality:
26
+
27
+ Do not create subtasks for "Write Tests."
28
+
29
+ Assume every subtask implies: "Write the failing test, implement the code, pass the test."
30
+
31
+ Code is not complete without tests.
32
+
33
+ The "Context Scope" Blinder:
34
+
35
+ For every Subtask, the context_scope must be a strict set of instructions for a developer who cannot see the rest of the project.
36
+
37
+ It must define Inputs (what data/interfaces are available from previous subtasks) and Outputs (what exact interface this subtask exposes).
38
+
39
+ It must explicitly state Mocking Strategies to keep the subtask isolated.
40
+
41
+ Process:
42
+
43
+ Analyze the attached or referenced PRD.
44
+
45
+ Determine the highest level of scope (Phase, Milestone, or Task) this PRD represents.
46
+
47
+ Decompose strictly downwards to the Subtask level.
48
+
49
+ Output Format:
50
+ Output only a JSON object. No conversational text.
51
+
52
+ ```json
53
+ {
54
+ "backlog": [
55
+ {
56
+ "type": "Phase",
57
+ "id": "P[#]",
58
+ "title": "Phase Title",
59
+ "status": "Planned | Researching | Ready | Implementing | Complete | Failed",
60
+ "description": "High level goal.",
61
+ "milestones": [
62
+ {
63
+ "type": "Milestone",
64
+ "id": "P[#].M[#]",
65
+ "title": "Milestone Title",
66
+ "status": "Planned",
67
+ "description": "Key objective.",
68
+ "tasks": [
69
+ {
70
+ "type": "Task",
71
+ "id": "P[#].M[#].T[#]",
72
+ "title": "Task Title",
73
+ "status": "Planned",
74
+ "description": "Feature definition.",
75
+ "subtasks": [
76
+ {
77
+ "type": "Subtask",
78
+ "id": "P[#].M[#].T[#].S[#]",
79
+ "title": "Subtask Title",
80
+ "status": "Planned",
81
+ "story_points": 1,
82
+ "dependencies": ["ID of prerequisite subtask"],
83
+ "context_scope": "CONTRACT DEFINITION:\n1. INPUT: [Specific data structure/variable] from [Dependency ID].\n2. LOGIC: Implement [PRD Section X] logic. Mock [Service Y] for isolation.\n3. OUTPUT: Return [Result Object/Interface] for consumption by [Next Subtask ID]."
84
+ }
85
+ ]
86
+ }
87
+ ]
88
+ }
89
+ ]
90
+ }
91
+ ]
92
+ }
93
+ ```
94
+
@@ -98,3 +98,4 @@ For every Subtask, the `context_scope` must be a **strict set of instructions**
98
98
  }
99
99
  ]
100
100
  }
101
+ ```
package/CHANGELOG.md ADDED
@@ -0,0 +1,188 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.0.3] - 2026-01-12
9
+
10
+ ### Fixed
11
+
12
+ - **WorkflowLogger.child() signature** (Critical): Updated to accept `Partial<LogEntry>` parameter matching PRD specification, while maintaining backward compatibility with string-based API via function overloads.
13
+ - Implementation: [src/core/logger.ts:98-111](src/core/logger.ts#L98-L111)
14
+ - **Promise.allSettled for concurrent tasks** (Major): Replaced `Promise.all()` with `Promise.allSettled()` for comprehensive error collection when multiple concurrent workflows fail, enabling aggregate error reporting.
15
+ - Implementation: [src/decorators/task.ts:112-142](src/decorators/task.ts#L112-L142)
16
+ - **ErrorMergeStrategy implementation** (Major): Added error merge strategy for concurrent task failures with configurable custom combinators, enabling aggregation of all concurrent errors into a single WorkflowError.
17
+ - Implementation: [src/types/decorators.ts:25-32](src/types/decorators.ts#L25-L32), [src/utils/workflow-error-utils.ts:23-56](src/utils/workflow-error-utils.ts#L23-L56)
18
+ - **Console.error to logger replacement** (Minor): Replaced `console.error()` with workflow logger for observer error handling, ensuring consistent structured logging throughout the codebase.
19
+ - Implementation: [src/core/workflow.ts:426, 444](src/core/workflow.ts#L426)
20
+ - **Tree debugger optimization** (Minor): Implemented incremental node map updates for childDetached events using BFS traversal, avoiding O(n) full map rebuilds and improving performance on large workflow trees.
21
+ - Implementation: [src/debugger/tree-debugger.ts:65-84, 92-117](src/debugger/tree-debugger.ts#L65-L84)
22
+ - **Workflow name validation** (Minor): Added validation for empty, whitespace-only, and overly long (>100 chars) workflow names to prevent invalid configurations.
23
+ - Implementation: [src/core/workflow.ts:98-107](src/core/workflow.ts#L98-L107)
24
+ - **trackTiming default documentation** (Major): Clarified documentation that `trackTiming` in `@Step` decorator defaults to `true` via `!== false` check, improving API discoverability.
25
+ - Implementation: [src/decorators/step.ts:94-101](src/decorators/step.ts#L94-L101)
26
+ - **isDescendantOf public API** (Minor): Made previously private `isDescendantOf()` helper method public with comprehensive JSDoc documentation, enabling workflow hierarchy validation and topology checking.
27
+ - Implementation: [src/core/workflow.ts:201-219](src/core/workflow.ts#L201-L219)
28
+
29
+ ### Added
30
+
31
+ - **Public isDescendantOf() method**: Made the previously private `isDescendantOf()` helper method public for workflow hierarchy validation, circular reference prevention, and topology checking.
32
+ - Implementation: [src/core/workflow.ts:201-219](src/core/workflow.ts#L201-L219)
33
+
34
+ ### Test Coverage
35
+
36
+ **New Test Files Added** (12 files):
37
+ - `src/__tests__/unit/logger.test.ts` - WorkflowLogger.child() signature tests (294 lines)
38
+ - `src/__tests__/adversarial/concurrent-task-failures.test.ts` - Concurrent task failure scenarios
39
+ - `src/__tests__/adversarial/error-merge-strategy.test.ts` - Error merge strategy functionality
40
+ - `src/__tests__/unit/tree-debugger-incremental.test.ts` - Incremental node map updates
41
+ - `src/__tests__/adversarial/node-map-update-benchmarks.test.ts` - Performance benchmarks
42
+ - `src/__tests__/integration/observer-logging.test.ts` - Observer logging tests
43
+ - `src/__tests__/unit/workflow.test.ts` - Workflow name validation
44
+ - `src/__tests__/unit/workflow-isDescendantOf.test.ts` - Public isDescendantOf API
45
+ - `src/__tests__/adversarial/parent-validation.test.ts` - Parent validation edge cases
46
+ - `src/__tests__/adversarial/circular-reference.test.ts` - Circular reference detection
47
+ - `src/__tests__/adversarial/complex-circular-reference.test.ts` - Deep circular reference scenarios
48
+ - `src/__tests__/integration/workflow-reparenting.test.ts` - Reparenting workflow tests
49
+
50
+ **Test Count Increase**: +50+ new test cases
51
+ **Regression Tests**: All existing tests continue to pass (100% pass rate maintained)
52
+
53
+ ### Implementation Details
54
+
55
+ - **WorkflowLogger.child() signature fix**: [src/core/logger.ts:98-111](src/core/logger.ts#L98-L111)
56
+ - Function overloads for type safety with both string and Partial<LogEntry> parameters
57
+ - Backward compatible with existing string-based API
58
+ - Follows PRD specification exactly
59
+ - **Promise.allSettled for concurrent tasks**: [src/decorators/task.ts:112-142](src/decorators/task.ts#L112-L142)
60
+ - Captures all concurrent errors using Promise.allSettled()
61
+ - Optional error merge strategy for aggregate error reporting
62
+ - Backward compatible: throws first error by default
63
+ - **ErrorMergeStrategy implementation**: [src/types/decorators.ts:25-32](src/types/decorators.ts#L25-L32), [src/utils/workflow-error-utils.ts:23-56](src/utils/workflow-error-utils.ts#L23-L56)
64
+ - New TaskOptions.errorMergeStrategy property
65
+ - Default merger aggregates all error messages, logs, and workflow IDs
66
+ - Custom combine function support for specialized error handling
67
+ - **Console.error to logger replacement**: [src/core/workflow.ts:426, 444](src/core/workflow.ts#L426)
68
+ - Observer onEvent errors now logged with structured context
69
+ - Observer onStateUpdated errors now logged with node context
70
+ - **Tree debugger optimization**: [src/debugger/tree-debugger.ts:65-84, 92-117](src/debugger/tree-debugger.ts#L65-L84)
71
+ - Incremental subtree removal using BFS traversal
72
+ - O(k) complexity for subtree operations instead of O(n)
73
+ - Prevents stack overflow on deep trees with iterative BFS
74
+ - **Workflow name validation**: [src/core/workflow.ts:98-107](src/core/workflow.ts#L98-L107)
75
+ - Rejects empty and whitespace-only names
76
+ - Rejects names exceeding 100 characters
77
+ - Fail-fast validation during construction
78
+ - **trackTiming default documentation**: [src/decorators/step.ts:94-101](src/decorators/step.ts#L94-L101)
79
+ - Clarified that trackTiming defaults to true via !== false check
80
+ - Explicit false disables timing, undefined/true enables timing
81
+ - **isDescendantOf public API**: [src/core/workflow.ts:201-219](src/core/workflow.ts#L201-L219)
82
+ - Cycle detection during parent chain traversal
83
+ - Comprehensive JSDoc with security warning and usage examples
84
+ - Time/space complexity documentation
85
+
86
+ ## [0.0.2] - 2026-01-12
87
+
88
+ ### Fixed
89
+
90
+ - **attachChild() parent validation**: `attachChild()` now throws an Error if you attempt to attach a child that already has a different parent. Previously, this would silently create an inconsistent tree state where the child appeared in multiple parents' `children` arrays while only linking to one parent via its `parent` property.
91
+ - **Circular reference detection**: `attachChild()` now detects and prevents attaching an ancestor as a child, which would create a circular reference in the tree.
92
+ - **Observer event propagation**: Observer events now propagate correctly after reparenting operations. Previously, events from a shared child would only reach the original parent's observers, not any new parents.
93
+
94
+ ### Added
95
+
96
+ - **New `detachChild()` method**: Enables proper reparenting workflow by removing a child from both the workflow tree (`this.children`) and the node tree (`this.node.children`), clearing the child's parent reference, and emitting a `childDetached` event.
97
+ - Implementation: [src/core/workflow.ts:329-358](src/core/workflow.ts#L329-L358)
98
+ - **New `childDetached` event type**: Discriminated union member for detachment notifications, following the existing event pattern with `type`, `parentId`, and `childId` properties.
99
+ - Implementation: [src/types/events.ts:11](src/types/events.ts#L11)
100
+ - **New `isDescendantOf()` helper**: Private method for circular reference detection that traverses the parent chain upward with cycle detection.
101
+ - Implementation: [src/core/workflow.ts:151-169](src/core/workflow.ts#L151-L169)
102
+
103
+ ### Migration Guide for attachChild() Behavior Change
104
+
105
+ **What Changed**:
106
+ The `attachChild()` method now throws an Error if you attempt to attach a child that already has a different parent. Previously, this would silently create an inconsistent tree state that broke observer propagation and violated the PRD's single-parent requirement.
107
+
108
+ **Before (Buggy Pattern)**:
109
+ ```typescript
110
+ // This would silently create inconsistent state
111
+ const parent1 = new Workflow({ name: 'parent1' });
112
+ const parent2 = new Workflow({ name: 'parent2' });
113
+ const child = new Workflow({ name: 'child' });
114
+
115
+ parent1.attachChild(child); // child.parent = parent1
116
+ parent2.attachChild(child); // BUG: child still has parent1, but parent2 thinks it's attached
117
+ // Result: child.parent === parent1, but parent2.children.includes(child) === true
118
+ ```
119
+
120
+ **After (Correct Pattern)**:
121
+ ```typescript
122
+ // Use detachChild() before reattaching
123
+ const parent1 = new Workflow({ name: 'parent1' });
124
+ const parent2 = new Workflow({ name: 'parent2' });
125
+ const child = new Workflow({ name: 'child' });
126
+
127
+ parent1.attachChild(child);
128
+ parent1.detachChild(child); // Explicitly detach first
129
+ parent2.attachChild(child); // Now works correctly
130
+ // Result: child.parent === parent2, parent1.children does NOT include child
131
+ ```
132
+
133
+ **Migration Steps**:
134
+ 1. Search your code for patterns of attaching the same child to multiple parents
135
+ 2. Add `detachChild()` calls before reattaching to a new parent
136
+ 3. Test that your workflow tree operations complete without errors
137
+ 4. Verify observer events propagate correctly after reparenting
138
+
139
+ ### Test Coverage
140
+
141
+ **New Test Files Added** (12 files):
142
+ - `src/__tests__/unit/workflow-detachChild.test.ts` - `detachChild()` method tests
143
+ - `src/__tests__/unit/workflow-emitEvent-childDetached.test.ts` - `childDetached` event tests
144
+ - `src/__tests__/adversarial/parent-validation.test.ts` - Parent validation edge cases
145
+ - `src/__tests__/adversarial/circular-reference.test.ts` - Circular reference detection
146
+ - `src/__tests__/adversarial/complex-circular-reference.test.ts` - Deep circular reference scenarios
147
+ - `src/__tests__/adversarial/attachChild-performance.test.ts` - Performance validation
148
+ - `src/__tests__/adversarial/deep-hierarchy-stress.test.ts` - Deep nesting tests (1000+ levels)
149
+ - `src/__tests__/adversarial/bidirectional-consistency.test.ts` - Tree consistency tests
150
+ - `src/__tests__/adversarial/edge-case.test.ts` - Edge case coverage
151
+ - `src/__tests__/adversarial/observer-propagation.test.ts` - Observer propagation validation
152
+ - `src/__tests__/adversarial/deep-analysis.test.ts` - Comprehensive deep tree analysis
153
+ - `src/__tests__/integration/workflow-reparenting.test.ts` - Reparenting workflow tests
154
+
155
+ **Test Count Increase**: +25 new test cases
156
+ **Regression Tests**: All existing tests continue to pass (100% pass rate maintained)
157
+
158
+ ### Implementation Details
159
+
160
+ - **attachChild() validation**: [src/core/workflow.ts:266-305](src/core/workflow.ts#L266-L305)
161
+ - Validates child is not already attached to this workflow
162
+ - Validates child does not have a different parent (throws with helpful error message)
163
+ - Validates child is not an ancestor of this parent (circular reference detection)
164
+ - **detachChild() method**: [src/core/workflow.ts:329-358](src/core/workflow.ts#L329-L358)
165
+ - Removes child from both workflow and node trees
166
+ - Clears child's parent reference
167
+ - Emits childDetached event for observer notification
168
+ - **isDescendantOf() helper**: [src/core/workflow.ts:151-169](src/core/workflow.ts#L151-L169)
169
+ - Private helper method for circular reference detection
170
+ - Traverses parent chain with Set-based cycle detection
171
+ - **childDetached event**: [src/types/events.ts:11](src/types/events.ts#L11)
172
+ - Follows existing discriminated union pattern
173
+ - Uses `childId` (string) instead of `child` (WorkflowNode) since child is no longer in tree
174
+
175
+ ## [0.0.1] - 2025-01-10
176
+
177
+ ### Added
178
+ - Initial release with hierarchical workflow engine
179
+ - `Workflow` base class with parent/child relationships
180
+ - Observer pattern for event propagation
181
+ - `WorkflowTreeDebugger` for real-time tree visualization
182
+ - `@Step`, `@Task`, and `@ObservedState` decorators
183
+ - Full TypeScript type definitions
184
+
185
+ [Unreleased]: https://github.com/dustin/groundswell/compare/v0.0.3...HEAD
186
+ [0.0.3]: https://github.com/dustin/groundswell/compare/v0.0.2...v0.0.3
187
+ [0.0.2]: https://github.com/dustin/groundswell/compare/v0.0.1...v0.0.2
188
+ [0.0.1]: https://github.com/dustin/groundswell/releases/tag/v0.0.1