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.
- package/.claude/commands/subtask-planning/prp-base-create.md +120 -0
- package/.claude/commands/subtask-planning/prp-base-execute.md +65 -0
- package/.claude/commands/task-breakdown.md +94 -0
- package/.claude/system_prompts/task-breakdown.md +1 -0
- package/CHANGELOG.md +188 -0
- package/PRD.md +543 -0
- package/README.md +99 -5
- package/examples/README.md +15 -1
- package/examples/examples/11-reparenting-workflows.ts +269 -0
- package/examples/index.ts +4 -0
- package/package-lock.json +2398 -0
- package/package.json +3 -1
- package/plan/001_d3bb02af4886/TEST_RESULTS.md +259 -0
- package/plan/001_d3bb02af4886/bug_fix_tasks.json +484 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M1T1S1/PRP.md +488 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M1T1S2/PRP.md +581 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M1T1S3/PRP.md +687 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T1S1/PRP.md +492 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T1S3/PRP.md +932 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T1S3/research/concurrent_error_testing_patterns.md +1109 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T1S3/research/vitest_concurrent_testing.md +802 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T1S3/research/workflow_engine_test_references.md +603 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T2S1/PRP.md +564 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T2S3/PRP.md +518 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T2S4/PRP.md +1252 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T3S1/PRP.md +364 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T3S1/research/CODEBASE_INVENTORY.md +114 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T3S1/research/DECORATOR_DOCUMENTATION_PATTERNS.md +205 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T3S1/research/PRD_LOCATION_ANALYSIS.md +199 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M2T3S1/research/ULTRATHINK_PRP_PLAN.md +134 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T1S1/PRP.md +495 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T1S1/research/console_error_inventory.md +435 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T1S2/PRP.md +506 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T1S3/PRP.md +612 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S2/PRP.md +558 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S2/research/external_research.md +788 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T3S2/PRP.md +460 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T3S3/PRP.md +454 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T4S1/PRP.md +520 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T4S1/RECOMMENDATION.md +417 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T4S1/research/external_workflow_engines_research.md +760 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T4S1/research/security_implications_analysis.md +245 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T4S2/PRP.md +792 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M4T1S1/PRP.md +535 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M4T1S1/TEST_EXECUTION_REPORT.md +190 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M4T1S2/PRP.md +654 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M4T1S2/TEST_FIX_REPORT.md +227 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M4T1S2/research/KEY_FINDINGS.md +345 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M4T1S2/research/QUICK_REFERENCE.md +193 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M4T1S2/research/test_maintenance_research.md +1323 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M4T3S1/BREAKING_CHANGES_AUDIT.md +1011 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M4T3S1/PRP.md +927 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M4T3S2/PRP.md +505 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/architecture/logger_child_signature_analysis.md +401 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M1T1S3/child_implementation_research.md +142 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M1T1S3/test_patterns_research.md +112 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M1T1S3/vitest_patterns_research.md +159 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M1T1S4/PRP.md +549 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M1T1S4/VERIFICATION_REPORT.md +368 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M1T1S4/edge_case_analysis.md +172 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M1T1S4/usage_inventory.md +175 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T1S2/PRP.md +696 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T1S4/PRP.md +860 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/PRP.md +1066 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/01-testing-aggregated-errors.md +1103 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/01_typescript_error_aggregation_patterns.md +789 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/02-error-merge-strategy-testing-guide.md +1098 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/02_aggregate_error_patterns.md +1037 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/03-promise-allsettled-testing-patterns.md +916 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/03_error_merging_strategies.md +1045 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/04_github_stackoverflow_examples.md +890 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/05_comprehensive_summary.md +822 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/INDEX.md +668 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/QUICK_REFERENCE.md +706 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/README.md +265 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S2/research/RESEARCH_REPORT.md +655 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T2S4/research/vitest_testing_patterns.md +1103 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M2T3S2/PRP.md +426 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T1S2/PRP.md +506 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T1S2/research/QUICK_REFERENCE.md +114 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T1S2/research/RESEARCH_SUMMARY.md +316 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T1S2/research/vitest_observer_error_logging_best_practices.md +754 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T1S3/PRP.md +612 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T2S1/PRP.md +719 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T2S1/README.md +215 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T2S1/analysis.md +765 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T2S3/PRP.md +718 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T3S1/DECISION.md +149 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T3S1/PRP.md +470 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T3S1/research/ULTRATHINK_PLAN.md +332 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T3S1/research/codebase_workflow_name_analysis.md +167 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T3S1/research/external_best_practices.md +265 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T3S1/research/validation_patterns.md +273 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T4S1/workflow_engine_ancestry_api_research.md +760 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M3T4S3-PRP.md +434 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M4T2S1/PRP.md +717 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M4T2S2/PRP.md +472 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M4T2S2/VALIDATION_REPORT.md +125 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/P1M4T2S2/research/ULTRATHINK_PRP_PLAN.md +301 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/error-logging-best-practices.md +1170 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/research_typescript_partial_and_overloads.md +940 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/vitest-quick-reference.md +151 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/docs/vitest-research.md +650 -0
- package/plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/prd_snapshot.md +259 -0
- package/plan/001_d3bb02af4886/bugfix/P1M1T1S1/PRP.md +457 -0
- package/plan/001_d3bb02af4886/bugfix/RESEARCH_SUMMARY.md +346 -0
- package/plan/001_d3bb02af4886/bugfix/architecture/codebase_structure.md +311 -0
- package/plan/001_d3bb02af4886/bugfix/architecture/concurrent_execution_best_practices.md +1565 -0
- package/plan/001_d3bb02af4886/bugfix/architecture/error_handling_patterns.md +288 -0
- package/plan/001_d3bb02af4886/bugfix/architecture/promise_all_analysis.md +741 -0
- package/plan/001_d3bb02af4886/docs/PRP/P1M1T1S4-functional-workflow-error-state-capture-test.md +652 -0
- package/plan/001_d3bb02af4886/docs/PRP/PRP.md +527 -0
- package/plan/001_d3bb02af4886/docs/PRP/bugfix/P1M1T2S1-PRP.md +415 -0
- package/plan/001_d3bb02af4886/docs/PRP/bugfix/P1M1T2S2-PRP.md +378 -0
- package/plan/001_d3bb02af4886/docs/PRP/bugfix/P1M1T2S4-PRP.md +713 -0
- package/plan/001_d3bb02af4886/docs/PRP/bugfix/P1M2T1S4-PRP.md +370 -0
- package/plan/001_d3bb02af4886/docs/PRP_P1M3T1S3.md +499 -0
- package/plan/001_d3bb02af4886/docs/TEST_RESULTS.md +230 -0
- package/plan/001_d3bb02af4886/docs/bugfix/ANALYSIS_PRD_VS_IMPLEMENTATION.md +1134 -0
- package/plan/001_d3bb02af4886/docs/bugfix/GAP_ANALYSIS_SUMMARY.md +179 -0
- package/plan/001_d3bb02af4886/docs/bugfix/P1M4T2S1/PRP.md +629 -0
- package/plan/001_d3bb02af4886/docs/bugfix/P1M4T2S1/validation-report.md +214 -0
- package/plan/001_d3bb02af4886/docs/bugfix/PRP_P1M4T2S3.md +629 -0
- package/plan/001_d3bb02af4886/docs/bugfix/bugfix_PRP.md +529 -0
- package/plan/001_d3bb02af4886/docs/bugfix/bugfix_QUICK_REFERENCE.md +142 -0
- package/plan/001_d3bb02af4886/docs/bugfix/bugfix_README.md +304 -0
- package/plan/001_d3bb02af4886/docs/bugfix/bugfix_TEST_RESULTS.md +558 -0
- package/plan/001_d3bb02af4886/docs/bugfix/bugfix_VALIDATION_SUMMARY.md +256 -0
- package/plan/001_d3bb02af4886/docs/bugfix/system_context.md +346 -0
- package/plan/001_d3bb02af4886/docs/bugfix-architecture/bug_analysis.md +415 -0
- package/plan/001_d3bb02af4886/docs/bugfix-architecture/implementation_patterns.md +489 -0
- package/plan/001_d3bb02af4886/docs/bugfix-architecture/system_context.md +218 -0
- package/plan/001_d3bb02af4886/docs/bugfix_INITIATION_SUMMARY.md +380 -0
- package/plan/001_d3bb02af4886/docs/research/CYCLE_DETECTION_PATTERNS.md +1923 -0
- package/plan/001_d3bb02af4886/docs/research/CYCLE_DETECTION_QUICK_REF.md +319 -0
- package/plan/001_d3bb02af4886/docs/research/P1M1T2S1/codebase-context.md +115 -0
- package/plan/001_d3bb02af4886/docs/research/P1M1T2S1/cycle-detection-algorithms.md +134 -0
- package/plan/001_d3bb02af4886/docs/research/P1M1T2S1/test-patterns.md +153 -0
- package/plan/001_d3bb02af4886/docs/research/P1M1T2S1/workflow-class.md +132 -0
- package/plan/001_d3bb02af4886/docs/research/P1M2T1S4/DECORATOR_DOCUMENTATION_BEST_PRACTICES.md +716 -0
- package/plan/001_d3bb02af4886/docs/research/P1M2T1S4/DECORATOR_DOCUMENTATION_QUICK_REF.md +186 -0
- package/plan/001_d3bb02af4886/docs/research/P1M2T1S4/GROUNDSWELL_DECORATOR_EXAMPLES.md +604 -0
- package/plan/001_d3bb02af4886/docs/research/P1M2T1S4/INDEX.md +213 -0
- package/plan/001_d3bb02af4886/docs/research/P1M2T1S4/codebase_structure.md +30 -0
- package/plan/001_d3bb02af4886/docs/research/P1M2T1S4/existing_test_pattern.md +56 -0
- package/plan/001_d3bb02af4886/docs/research/P1M2T1S4/getRootObservers_implementation.md +53 -0
- package/plan/001_d3bb02af4886/docs/research/P1M2T1S4/test_conventions.md +49 -0
- package/plan/001_d3bb02af4886/docs/research/P1M3T1S4/PRP.md +958 -0
- package/plan/001_d3bb02af4886/docs/research/P1M3T1S4/QUICK_REFERENCE.md +339 -0
- package/plan/001_d3bb02af4886/docs/research/P1M3T1S4/README.md +305 -0
- package/plan/001_d3bb02af4886/docs/research/P1M3T1S4/SUMMARY.md +433 -0
- package/plan/001_d3bb02af4886/docs/research/P1M3T1S4/bidirectional-tree-consistency-testing.md +1574 -0
- package/plan/001_d3bb02af4886/docs/research/P1M3T1S4/test-pattern-examples.md +1014 -0
- package/plan/001_d3bb02af4886/docs/research/PROMISE_ALLSETTLED_QUICK_REF.md +376 -0
- package/plan/001_d3bb02af4886/docs/research/PROMISE_ALLSETTLED_RESEARCH.md +1507 -0
- package/plan/001_d3bb02af4886/docs/research/bugfix_typescript_patterns.md +949 -0
- package/plan/001_d3bb02af4886/docs/research/error-testing-research.md +619 -0
- package/plan/001_d3bb02af4886/docs/research/error_handling_patterns.md +723 -0
- package/plan/{research → 001_d3bb02af4886/docs/research/general}/introspection-security-guide.md +56 -0
- package/plan/001_d3bb02af4886/docs/research/incremental-tree-map-updates/PRP_TEMPLATE.md +460 -0
- package/plan/001_d3bb02af4886/docs/research/incremental-tree-map-updates/QUICK_REFERENCE.md +324 -0
- package/plan/001_d3bb02af4886/docs/research/incremental-tree-map-updates/README.md +175 -0
- package/plan/001_d3bb02af4886/docs/research/incremental-tree-map-updates/RESEARCH_REPORT.md +499 -0
- package/plan/001_d3bb02af4886/docs/research/incremental-tree-map-updates/SUMMARY.md +163 -0
- package/plan/bugfix/BUG_FIX_SUMMARY.md +961 -0
- package/src/__tests__/adversarial/attachChild-performance.test.ts +216 -0
- package/src/__tests__/adversarial/circular-reference.test.ts +101 -0
- package/src/__tests__/adversarial/complex-circular-reference.test.ts +139 -0
- package/src/__tests__/adversarial/concurrent-task-failures.test.ts +571 -0
- package/src/__tests__/adversarial/deep-analysis.test.ts +729 -0
- package/src/__tests__/adversarial/deep-hierarchy-stress.test.ts +213 -0
- package/src/__tests__/adversarial/e2e-prd-validation.test.ts +448 -0
- package/src/__tests__/adversarial/edge-case.test.ts +703 -0
- package/src/__tests__/adversarial/error-merge-strategy.test.ts +760 -0
- package/src/__tests__/adversarial/incremental-performance.test.ts +140 -0
- package/src/__tests__/adversarial/node-map-update-benchmarks.test.ts +457 -0
- package/src/__tests__/adversarial/observer-propagation.test.ts +487 -0
- package/src/__tests__/adversarial/parent-validation.test.ts +143 -0
- package/src/__tests__/adversarial/prd-12-2-compliance.test.ts +611 -0
- package/src/__tests__/adversarial/prd-compliance.test.ts +731 -0
- package/src/__tests__/compatibility/backward-compatibility.test.ts +1572 -0
- package/src/__tests__/helpers/index.ts +18 -0
- package/src/__tests__/helpers/tree-verification.ts +257 -0
- package/src/__tests__/integration/bidirectional-consistency.test.ts +847 -0
- package/src/__tests__/integration/observer-logging.test.ts +643 -0
- package/src/__tests__/integration/tree-mirroring.test.ts +37 -0
- package/src/__tests__/integration/workflow-reparenting.test.ts +303 -0
- package/src/__tests__/unit/context.test.ts +79 -0
- package/src/__tests__/unit/logger.test.ts +293 -0
- package/src/__tests__/unit/observable.test.ts +321 -0
- package/src/__tests__/unit/tree-debugger-incremental.test.ts +170 -0
- package/src/__tests__/unit/utils/workflow-error-utils.test.ts +209 -0
- package/src/__tests__/unit/workflow-detachChild.test.ts +100 -0
- package/src/__tests__/unit/workflow-emitEvent-childDetached.test.ts +153 -0
- package/src/__tests__/unit/workflow-isDescendantOf.test.ts +180 -0
- package/src/__tests__/unit/workflow.test.ts +277 -1
- package/src/core/agent.ts +21 -1
- package/src/core/logger.ts +27 -2
- package/src/core/workflow-context.ts +6 -4
- package/src/core/workflow.ts +252 -14
- package/src/debugger/tree-debugger.ts +52 -7
- package/src/decorators/task.ts +65 -2
- package/src/index.ts +4 -2
- package/src/types/decorators.ts +8 -1
- package/src/types/events.ts +1 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/observable.ts +32 -3
- package/src/utils/workflow-error-utils.ts +56 -0
- package/tsconfig.json +1 -1
- package/llms_full.txt +0 -5890
- package/tasks.json +0 -0
- /package/plan/{backlog.json → 001_d3bb02af4886/backlog.json} +0 -0
- /package/plan/{P1P2/PRP.md → 001_d3bb02af4886/docs/PRP/P1P2-PRP.md} +0 -0
- /package/plan/{P3P4/PRP.md → 001_d3bb02af4886/docs/PRP/P3P4-PRP.md} +0 -0
- /package/plan/{P4P5/PRP.md → 001_d3bb02af4886/docs/PRP/P4P5-PRP.md} +0 -0
- /package/plan/{architecture → 001_d3bb02af4886/docs/architecture}/external_deps.md +0 -0
- /package/plan/{architecture → 001_d3bb02af4886/docs/architecture}/system_context.md +0 -0
- /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/LRU_CACHE_BEST_PRACTICES.md +0 -0
- /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/LRU_CACHE_CODE_PATTERNS.md +0 -0
- /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/LRU_CACHE_INTEGRATION_GUIDE.md +0 -0
- /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/LRU_CACHE_RESEARCH_INDEX.md +0 -0
- /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/REFLECTION_INDEX.md +0 -0
- /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/REFLECTION_RESEARCH_REPORT.md +0 -0
- /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/RESEARCH_SUMMARY.md +0 -0
- /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/anthropic-sdk.md +0 -0
- /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/async-local-storage.md +0 -0
- /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/reflection-code-patterns.md +0 -0
- /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/reflection-decision-matrix.md +0 -0
- /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/reflection-implementation-guide.md +0 -0
- /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/reflection-integration-guide.md +0 -0
- /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/reflection-patterns.md +0 -0
- /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/reflection-quick-reference.md +0 -0
- /package/plan/{P1P2/research → 001_d3bb02af4886/docs/research/P1P2}/zod-schema.md +0 -0
- /package/plan/{P3P4/research → 001_d3bb02af4886/docs/research/P3P4}/caching-lru.md +0 -0
- /package/plan/{P3P4/research → 001_d3bb02af4886/docs/research/P3P4}/introspection-tools.md +0 -0
- /package/plan/{P3P4/research → 001_d3bb02af4886/docs/research/P3P4}/reflection-patterns.md +0 -0
- /package/plan/{P4P5/research → 001_d3bb02af4886/docs/research/P4P5}/RESEARCH_SUMMARY.md +0 -0
- /package/plan/{research → 001_d3bb02af4886/docs/research/general}/INTROSPECTION_RESEARCH_SUMMARY.md +0 -0
- /package/plan/{research → 001_d3bb02af4886/docs/research/general}/README-INTROSPECTION.md +0 -0
- /package/plan/{research → 001_d3bb02af4886/docs/research/general}/agent-introspection-patterns.md +0 -0
- /package/plan/{research → 001_d3bb02af4886/docs/research/general}/introspection-tool-examples.md +0 -0
- /package/{PRPs/PRDs/001-hierarchical-workflow-engine.md → plan/001_d3bb02af4886/prd_snapshot.md} +0 -0
|
@@ -0,0 +1,719 @@
|
|
|
1
|
+
# Product Requirement Prompt (PRP): P1.M3.T2.S1 - Analyze Tree Debugger onTreeChanged Implementation
|
|
2
|
+
|
|
3
|
+
**PRP ID**: P1M3T2S1
|
|
4
|
+
**Task ID**: P1.M3.T2.S1
|
|
5
|
+
**Story Points**: 1
|
|
6
|
+
**Status**: Researching
|
|
7
|
+
**Created**: 2025-01-12
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Goal
|
|
12
|
+
|
|
13
|
+
**Feature Goal**: Conduct a comprehensive analysis of the WorkflowTreeDebugger's `onTreeChanged()` implementation to understand the current full-rebuild behavior and identify opportunities for incremental updates.
|
|
14
|
+
|
|
15
|
+
**Deliverable**: Analysis document stored at `plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S1/analysis.md` containing:
|
|
16
|
+
- Current rebuild logic documentation with line number references
|
|
17
|
+
- Tree change event type analysis (childAttached, childDetached, treeUpdated)
|
|
18
|
+
- Performance impact assessment for current O(n) rebuild behavior
|
|
19
|
+
- Identified opportunities for incremental O(1)/O(k) updates
|
|
20
|
+
- Recommendations for P1.M3.T2.S2 implementation
|
|
21
|
+
|
|
22
|
+
**Success Definition**:
|
|
23
|
+
- [ ] Analysis document exists at specified path
|
|
24
|
+
- [ ] Current implementation behavior fully documented with code references
|
|
25
|
+
- [ ] All tree change trigger events identified and documented
|
|
26
|
+
- [ ] Performance bottleneck clearly explained with complexity analysis
|
|
27
|
+
- [ ] Incremental update opportunities identified with specific recommendations
|
|
28
|
+
- [ ] Research findings stored in research/ subdirectory for P1.M3.T2.S2 reference
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## User Persona (if applicable)
|
|
33
|
+
|
|
34
|
+
**Target User**: Implementation AI agent for P1.M3.T2.S2 and P1.M3.T2.S3
|
|
35
|
+
|
|
36
|
+
**Use Case**: The analysis document serves as the foundation for implementing incremental node map updates (P1.M3.T2.S2) and creating benchmark tests (P1.M3.T2.S3).
|
|
37
|
+
|
|
38
|
+
**User Journey**:
|
|
39
|
+
1. Read analysis document to understand current behavior
|
|
40
|
+
2. Use identified opportunities to implement incremental updates
|
|
41
|
+
3. Reference performance analysis for benchmark test design
|
|
42
|
+
4. Validate implementation against recommendations
|
|
43
|
+
|
|
44
|
+
**Pain Points Addressed**:
|
|
45
|
+
- Eliminates need for P1.M3.T2.S2 agent to rediscover current implementation
|
|
46
|
+
- Provides concrete recommendations backed by research
|
|
47
|
+
- Accelerates implementation by providing clear guidance
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Why
|
|
52
|
+
|
|
53
|
+
- **Performance Optimization**: Current O(n) full rebuild on every tree change is inefficient for large workflow trees (1000+ nodes)
|
|
54
|
+
- **Foundation for Implementation**: Analysis enables P1.M3.T2.S2 to implement incremental updates without additional research overhead
|
|
55
|
+
- **Informed Benchmark Design**: Performance assessment informs P1.M3.T2.S3 benchmark test design
|
|
56
|
+
- **Documentation**: Creates permanent record of optimization rationale for future maintainers
|
|
57
|
+
|
|
58
|
+
**Business Value**:
|
|
59
|
+
- Reduces node map update overhead from O(n) to O(1) for single-node operations
|
|
60
|
+
- Enables 100-1000× performance improvement for large trees with frequent structural changes
|
|
61
|
+
- Prevents garbage collection pressure from Map.clear() and full rebuild
|
|
62
|
+
- Maintains correctness while improving performance
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## What
|
|
67
|
+
|
|
68
|
+
**User-Visible Behavior**: No behavior change - this is a research and analysis task only.
|
|
69
|
+
|
|
70
|
+
**Technical Requirements**:
|
|
71
|
+
- Read and analyze `src/debugger/tree-debugger.ts` implementation
|
|
72
|
+
- Read and analyze `src/core/workflow.ts` emitEvent and observer notification logic
|
|
73
|
+
- Document all tree change events that trigger `onTreeChanged()`
|
|
74
|
+
- Map current rebuild logic with specific line number references
|
|
75
|
+
- Calculate time complexity of current operations
|
|
76
|
+
- Research incremental update patterns
|
|
77
|
+
- Document specific opportunities for optimization
|
|
78
|
+
|
|
79
|
+
### Success Criteria
|
|
80
|
+
|
|
81
|
+
- [ ] Analysis document contains complete current implementation documentation
|
|
82
|
+
- [ ] All three tree change events (childAttached, childDetached, treeUpdated) documented
|
|
83
|
+
- [ ] Performance impact quantified with complexity analysis
|
|
84
|
+
- [ ] At least 3 specific incremental update opportunities identified
|
|
85
|
+
- [ ] Recommendations include code pattern examples
|
|
86
|
+
- [ ] External research cited with specific URLs
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## All Needed Context
|
|
91
|
+
|
|
92
|
+
### Context Completeness Check
|
|
93
|
+
|
|
94
|
+
**"No Prior Knowledge" Test**: If someone knew nothing about this codebase, would they have everything needed to conduct this analysis successfully?
|
|
95
|
+
|
|
96
|
+
**Answer**: YES - This PRP provides:
|
|
97
|
+
- Exact file paths and line numbers for all relevant code
|
|
98
|
+
- Complete WorkflowNode and WorkflowEvent type definitions
|
|
99
|
+
- Observer pattern documentation
|
|
100
|
+
- Testing framework patterns
|
|
101
|
+
- External research with specific URLs
|
|
102
|
+
- Output template for analysis document
|
|
103
|
+
|
|
104
|
+
### Documentation & References
|
|
105
|
+
|
|
106
|
+
```yaml
|
|
107
|
+
# MUST READ - Code Files (read in order)
|
|
108
|
+
|
|
109
|
+
- file: src/debugger/tree-debugger.ts
|
|
110
|
+
why: Core implementation to analyze - contains onTreeChanged(), buildNodeMap(), onEvent(), nodeMap
|
|
111
|
+
lines: "53-84" # buildNodeMap() and onTreeChanged() implementation
|
|
112
|
+
pattern: Recursive tree traversal using for-of loop over node.children
|
|
113
|
+
gotcha: "onEvent() at line 66-74 already handles childAttached incrementally - onTreeChanged() redundant"
|
|
114
|
+
|
|
115
|
+
- file: src/core/workflow.ts
|
|
116
|
+
why: Understanding when onTreeChanged is called via emitEvent()
|
|
117
|
+
lines: "360-379" # emitEvent() method showing observer notification logic
|
|
118
|
+
pattern: "obs.onTreeChanged(this.getRoot().node) called for childAttached, childDetached, treeUpdated events"
|
|
119
|
+
gotcha: "onTreeChanged called AFTER onEvent - causing redundant work for childAttached"
|
|
120
|
+
|
|
121
|
+
- file: src/types/workflow.ts
|
|
122
|
+
why: WorkflowNode structure definition - needed to understand tree hierarchy
|
|
123
|
+
lines: "16-37" # Complete WorkflowNode interface
|
|
124
|
+
pattern: "id, name, parent, children[], status, logs[], events[], stateSnapshot"
|
|
125
|
+
gotcha: "parent is WorkflowNode | null - null for root nodes"
|
|
126
|
+
|
|
127
|
+
- file: src/types/events.ts
|
|
128
|
+
why: WorkflowEvent discriminated union - all tree change event types
|
|
129
|
+
lines: "8-18" # Core workflow events including childAttached, childDetached, treeUpdated
|
|
130
|
+
pattern: "type: 'childAttached' | 'childDetached' | 'treeUpdated' are tree structure change events"
|
|
131
|
+
gotcha: "childDetached only provides childId string, not full child node"
|
|
132
|
+
|
|
133
|
+
- file: src/types/observer.ts
|
|
134
|
+
why: WorkflowObserver interface defining onTreeChanged signature
|
|
135
|
+
lines: "9-18" # Complete WorkflowObserver interface
|
|
136
|
+
pattern: "onTreeChanged(root: WorkflowNode): void - receives root node after any tree change"
|
|
137
|
+
gotcha: "Called for ALL tree events including state changes (via treeUpdated)"
|
|
138
|
+
|
|
139
|
+
# EXTERNAL RESEARCH - Read for best practices and patterns
|
|
140
|
+
|
|
141
|
+
- url: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#instance-methods
|
|
142
|
+
why: Map.set(), Map.get(), Map.delete() are O(1) - validates incremental approach feasibility
|
|
143
|
+
critical: "Map operations have O(1) average case complexity - incremental updates faster than O(n) rebuild"
|
|
144
|
+
|
|
145
|
+
- url: https://react.dev/learn/understanding-reacts-render-phase#rendering-and-committing
|
|
146
|
+
why: React reconciliation algorithm - tree diffing strategy reference
|
|
147
|
+
critical: "React only updates changed subtrees - same principle applies to node map updates"
|
|
148
|
+
|
|
149
|
+
- url: https://v8.dev/blog/elements-kinds#hidden-classes
|
|
150
|
+
why: V8 Map optimization and garbage collection behavior
|
|
151
|
+
critical: "Map.clear() triggers full GC - incremental updates spread GC cost over time"
|
|
152
|
+
|
|
153
|
+
- url: https://stackoverflow.com/questions/38476433/what-is-the-time-complexity-of-map-set-in-javascript#answer-38476768
|
|
154
|
+
why: Confirmed O(1) complexity for Map operations
|
|
155
|
+
critical: "Map.set() and Map.delete() are O(1) on average in modern JavaScript engines"
|
|
156
|
+
|
|
157
|
+
# INTERNAL RESEARCH - Generated research package
|
|
158
|
+
|
|
159
|
+
- docfile: plan/001_d3bb02af4886/docs/research/incremental-tree-map-updates/QUICK_REFERENCE.md
|
|
160
|
+
why: Code examples and implementation patterns for incremental updates
|
|
161
|
+
section: "Code Examples - Incremental Update Pattern"
|
|
162
|
+
|
|
163
|
+
- docfile: plan/001_d3bb02af4886/docs/research/incremental-tree-map-updates/RESEARCH_REPORT.md
|
|
164
|
+
why: Comprehensive analysis of current implementation and recommended patterns
|
|
165
|
+
section: "Current Implementation Analysis" and "Recommended Implementation"
|
|
166
|
+
|
|
167
|
+
- docfile: plan/001_d3bb02af4886/bugfix/architecture/codebase_structure.md
|
|
168
|
+
why: Overall codebase architecture and dual tree structure
|
|
169
|
+
section: "7. Observer Pattern Implementation" and "8. Additional Architecture Patterns"
|
|
170
|
+
|
|
171
|
+
# TEST PATTERNS - For validation approach
|
|
172
|
+
|
|
173
|
+
- file: src/__tests__/unit/tree-debugger.test.ts
|
|
174
|
+
why: Existing test patterns for tree-debugger functionality
|
|
175
|
+
pattern: "WorkflowTreeDebugger instantiation, getNode() lookup, tree string rendering"
|
|
176
|
+
gotcha: "Tests verify nodeMap behavior - useful for validating incremental correctness"
|
|
177
|
+
|
|
178
|
+
- file: src/__tests__/integration/tree-mirroring.test.ts
|
|
179
|
+
why: Observer propagation and treeUpdated event testing
|
|
180
|
+
pattern: "treeUpdated events trigger onTreeChanged callback"
|
|
181
|
+
gotcha: "Test at lines 115-150 verifies onTreeChanged is called with correct root"
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Current Codebase Tree (relevant portions)
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
src/
|
|
188
|
+
├── debugger/
|
|
189
|
+
│ └── tree-debugger.ts # PRIMARY ANALYSIS TARGET
|
|
190
|
+
│ ├── WorkflowTreeDebugger class
|
|
191
|
+
│ ├── buildNodeMap() # Line 53-58 - O(n) recursive rebuild
|
|
192
|
+
│ ├── onEvent() # Line 66-74 - handles childAttached incrementally
|
|
193
|
+
│ ├── onTreeChanged() # Line 80-84 - O(n) full rebuild (OPTIMIZE TARGET)
|
|
194
|
+
│ └── nodeMap: Map # Line 33 - node lookup map
|
|
195
|
+
├── core/
|
|
196
|
+
│ └── workflow.ts # Event emission logic
|
|
197
|
+
│ ├── emitEvent() # Line 363-379 - triggers onTreeChanged
|
|
198
|
+
│ ├── attachChild() # Line 266-305 - childAttached trigger
|
|
199
|
+
│ └── detachChild() # Line 329-358 - childDetached trigger
|
|
200
|
+
├── types/
|
|
201
|
+
│ ├── workflow.ts # WorkflowNode interface
|
|
202
|
+
│ ├── events.ts # WorkflowEvent discriminated union
|
|
203
|
+
│ └── observer.ts # WorkflowObserver interface
|
|
204
|
+
└── __tests__/
|
|
205
|
+
├── unit/
|
|
206
|
+
│ └── tree-debugger.test.ts # Existing test patterns
|
|
207
|
+
└── integration/
|
|
208
|
+
└── tree-mirroring.test.ts # Observer propagation tests
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Known Gotchas of Our Codebase & Library Quirks
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
// CRITICAL: onEvent() and onTreeChanged() are BOTH called for tree changes
|
|
215
|
+
// From src/core/workflow.ts:372-374
|
|
216
|
+
if (event.type === 'treeUpdated' || event.type === 'childAttached' || event.type === 'childDetached') {
|
|
217
|
+
obs.onTreeChanged(this.getRoot().node); // ❌ This triggers full rebuild
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// CRITICAL: onEvent() already handles childAttached incrementally
|
|
221
|
+
// From src/debugger/tree-debugger.ts:66-70
|
|
222
|
+
onEvent(event: WorkflowEvent): void {
|
|
223
|
+
if (event.type === 'childAttached') {
|
|
224
|
+
this.buildNodeMap(event.child); // ✅ Already incremental!
|
|
225
|
+
}
|
|
226
|
+
// Then onTreeChanged() is called, causing REDUNDANT full rebuild
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// CRITICAL: childDetached only provides childId, not full node
|
|
230
|
+
// From src/types/events.ts:11
|
|
231
|
+
{ type: 'childDetached'; parentId: string; childId: string }
|
|
232
|
+
// Must use stored node reference to collect descendants for removal
|
|
233
|
+
|
|
234
|
+
// CRITICAL: buildNodeMap() is recursive - may hit call stack limits on deep trees
|
|
235
|
+
// From src/debugger/tree-debugger.ts:53-58
|
|
236
|
+
private buildNodeMap(node: WorkflowNode): void {
|
|
237
|
+
this.nodeMap.set(node.id, node);
|
|
238
|
+
for (const child of node.children) {
|
|
239
|
+
this.buildNodeMap(child); // Recursive call
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// CRITICAL: treeUpdated is called for non-structural changes
|
|
244
|
+
// From src/core/workflow.ts:414
|
|
245
|
+
this.emitEvent({ type: 'treeUpdated', root: this.getRoot().node });
|
|
246
|
+
// Called by setStatus() - NO tree structure change, just status update
|
|
247
|
+
// Current implementation rebuilds entire map for status changes!
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Implementation Blueprint
|
|
253
|
+
|
|
254
|
+
### Data Models and Structure
|
|
255
|
+
|
|
256
|
+
**No data model changes** - This is a research task only.
|
|
257
|
+
|
|
258
|
+
**Data structures to analyze**:
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
// From src/types/workflow.ts:20-37
|
|
262
|
+
interface WorkflowNode {
|
|
263
|
+
id: string; // Unique identifier
|
|
264
|
+
name: string; // Human-readable name
|
|
265
|
+
parent: WorkflowNode | null; // Parent reference (null for root)
|
|
266
|
+
children: WorkflowNode[]; // Child nodes (tree structure)
|
|
267
|
+
status: WorkflowStatus; // Current execution state
|
|
268
|
+
logs: LogEntry[]; // Log entries
|
|
269
|
+
events: WorkflowEvent[]; // Emitted events
|
|
270
|
+
stateSnapshot: SerializedWorkflowState | null; // State snapshot
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Tree structure maintained by debugger:
|
|
274
|
+
// - this.root: WorkflowNode (root node reference)
|
|
275
|
+
// - this.nodeMap: Map<string, WorkflowNode> (id -> node lookup)
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Implementation Tasks (ordered by dependencies)
|
|
279
|
+
|
|
280
|
+
```yaml
|
|
281
|
+
Task 1: READ and document current implementation
|
|
282
|
+
- READ: src/debugger/tree-debugger.ts lines 53-84 (buildNodeMap, onTreeChanged)
|
|
283
|
+
- READ: src/debugger/tree-debugger.ts lines 66-74 (onEvent childAttached handling)
|
|
284
|
+
- DOCUMENT: Current rebuild logic in analysis.md
|
|
285
|
+
- IDENTIFY: Time complexity of buildNodeMap() - O(n) where n = total nodes
|
|
286
|
+
- IDENTIFY: Redundant work - childAttached handled in both onEvent() AND onTreeChanged()
|
|
287
|
+
- OUTPUT: Section "Current Implementation" in analysis.md
|
|
288
|
+
|
|
289
|
+
Task 2: ANALYZE tree change event types
|
|
290
|
+
- READ: src/types/events.ts lines 8-18 (core workflow events)
|
|
291
|
+
- READ: src/core/workflow.ts lines 360-379 (emitEvent observer notification)
|
|
292
|
+
- IDENTIFY: Three events trigger onTreeChanged:
|
|
293
|
+
1. childAttached - new subtree added
|
|
294
|
+
2. childDetached - subtree removed (only childId provided)
|
|
295
|
+
3. treeUpdated - root reference or status change
|
|
296
|
+
- DOCUMENT: For each event:
|
|
297
|
+
- When it occurs
|
|
298
|
+
- What data it provides
|
|
299
|
+
- Current onTreeChanged behavior
|
|
300
|
+
- Optimal incremental behavior
|
|
301
|
+
- OUTPUT: Section "Tree Change Event Analysis" in analysis.md
|
|
302
|
+
|
|
303
|
+
Task 3: CALCULATE performance impact
|
|
304
|
+
- CALCULATE: Current complexity per event type
|
|
305
|
+
- childAttached: O(n) - rebuilds entire map
|
|
306
|
+
- childDetached: O(n) - rebuilds entire map
|
|
307
|
+
- treeUpdated: O(n) - rebuilds entire map
|
|
308
|
+
- CALCULATE: Potential incremental complexity
|
|
309
|
+
- childAttached: O(k) where k = nodes in new subtree (already implemented in onEvent)
|
|
310
|
+
- childDetached: O(k) where k = nodes in removed subtree
|
|
311
|
+
- treeUpdated: O(1) - just update root reference
|
|
312
|
+
- CALCULATE: Speedup potential
|
|
313
|
+
- Single node attach to 1000-node tree: 1000× faster (O(1000) → O(1))
|
|
314
|
+
- Single node detach from 1000-node tree: 100× faster (O(1000) → O(10))
|
|
315
|
+
- Root status update: 1000× faster (O(1000) → O(1))
|
|
316
|
+
- OUTPUT: Section "Performance Impact Analysis" in analysis.md
|
|
317
|
+
|
|
318
|
+
Task 4: IDENTIFY incremental update opportunities
|
|
319
|
+
- RESEARCH: Read plan/001_d3bb02af4886/docs/research/incremental-tree-map-updates/
|
|
320
|
+
- IDENTIFY: Opportunity 1 - Remove redundant childAttached rebuild
|
|
321
|
+
- onEvent() already adds new subtree
|
|
322
|
+
- onTreeChanged() rebuild is redundant work
|
|
323
|
+
- IDENTIFY: Opportunity 2 - Implement childDetached subtree removal
|
|
324
|
+
- Use stored node reference to collect descendants
|
|
325
|
+
- Remove collected node IDs from map
|
|
326
|
+
- IDENTIFY: Opportunity 3 - Replace treeUpdated full rebuild
|
|
327
|
+
- Just update this.root reference
|
|
328
|
+
- Node references in map unchanged
|
|
329
|
+
- IDENTIFY: Opportunity 4 - Eliminate onTreeChanged rebuild entirely
|
|
330
|
+
- All tree changes can be handled incrementally in onEvent()
|
|
331
|
+
- OUTPUT: Section "Incremental Update Opportunities" in analysis.md
|
|
332
|
+
|
|
333
|
+
Task 5: CREATE implementation recommendations
|
|
334
|
+
- DOCUMENT: Specific code changes for P1.M3.T2.S2
|
|
335
|
+
- Add handleChildDetached() method with BFS subtree collection
|
|
336
|
+
- Modify onEvent() to handle childDetached
|
|
337
|
+
- Remove full rebuild from onTreeChanged()
|
|
338
|
+
- DOCUMENT: Code pattern examples (from research package)
|
|
339
|
+
- BFS-based subtree removal
|
|
340
|
+
- Incremental update pattern
|
|
341
|
+
- DOCUMENT: Gotchas to avoid
|
|
342
|
+
- Must remove entire subtree, not just detached node
|
|
343
|
+
- Must handle case where node already removed from map
|
|
344
|
+
- Recursive removal may hit stack limits - use iterative BFS
|
|
345
|
+
- OUTPUT: Section "Implementation Recommendations" in analysis.md
|
|
346
|
+
|
|
347
|
+
Task 6: STORE research for P1.M3.T2.S2 and P1.M3.T2.S3
|
|
348
|
+
- CREATE: plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S1/research/ directory
|
|
349
|
+
- COPY: External research URLs with annotations
|
|
350
|
+
- STORE: Code pattern examples for incremental updates
|
|
351
|
+
- STORE: Performance benchmark template for P1.M3.T2.S3
|
|
352
|
+
- OUTPUT: research/README.md with links to all resources
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### Implementation Patterns & Key Details
|
|
356
|
+
|
|
357
|
+
```typescript
|
|
358
|
+
// Current Implementation (to analyze and document)
|
|
359
|
+
|
|
360
|
+
// From src/debugger/tree-debugger.ts:53-58
|
|
361
|
+
private buildNodeMap(node: WorkflowNode): void {
|
|
362
|
+
// PATTERN: Recursive DFS traversal
|
|
363
|
+
this.nodeMap.set(node.id, node);
|
|
364
|
+
for (const child of node.children) {
|
|
365
|
+
this.buildNodeMap(child); // RECURSIVE - may hit stack limits
|
|
366
|
+
}
|
|
367
|
+
// COMPLEXITY: O(n) where n = total nodes in tree
|
|
368
|
+
// SIDE EFFECT: Replaces entire map content
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// From src/debugger/tree-debugger.ts:66-74
|
|
372
|
+
onEvent(event: WorkflowEvent): void {
|
|
373
|
+
// PATTERN: Event-type dispatch
|
|
374
|
+
if (event.type === 'childAttached') {
|
|
375
|
+
this.buildNodeMap(event.child); // ✅ Already adds new subtree
|
|
376
|
+
}
|
|
377
|
+
// GOTCHA: No handling for childDetached - leaks orphaned nodes
|
|
378
|
+
|
|
379
|
+
this.events.next(event);
|
|
380
|
+
// GOTCHA: After onEvent returns, emitEvent() calls onTreeChanged()
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// From src/debugger/tree-debugger.ts:80-84
|
|
384
|
+
onTreeChanged(root: WorkflowNode): void {
|
|
385
|
+
// PATTERN: Complete map invalidation
|
|
386
|
+
this.root = root;
|
|
387
|
+
this.nodeMap.clear(); // ❌ Clears entire map
|
|
388
|
+
this.buildNodeMap(root); // ❌ O(n) rebuild from scratch
|
|
389
|
+
// PROBLEM: Redundant work for childAttached (already handled in onEvent)
|
|
390
|
+
// PROBLEM: Unnecessary for treeUpdated (node references unchanged)
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// Recommended Incremental Pattern (for recommendations section)
|
|
394
|
+
|
|
395
|
+
onEvent(event: WorkflowEvent): void {
|
|
396
|
+
switch (event.type) {
|
|
397
|
+
case 'childAttached':
|
|
398
|
+
// ✅ Keep existing logic - already optimal
|
|
399
|
+
this.buildNodeMap(event.child);
|
|
400
|
+
break;
|
|
401
|
+
|
|
402
|
+
case 'childDetached':
|
|
403
|
+
// ✅ NEW: Incremental subtree removal
|
|
404
|
+
this.removeSubtree(event.childId);
|
|
405
|
+
break;
|
|
406
|
+
|
|
407
|
+
case 'treeUpdated':
|
|
408
|
+
// ✅ NEW: Just update root reference
|
|
409
|
+
this.root = event.root;
|
|
410
|
+
break;
|
|
411
|
+
}
|
|
412
|
+
this.events.next(event);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// BFS-based subtree removal (recommended over recursive)
|
|
416
|
+
private removeSubtree(nodeId: string): void {
|
|
417
|
+
const node = this.nodeMap.get(nodeId);
|
|
418
|
+
if (!node) return;
|
|
419
|
+
|
|
420
|
+
// Collect all descendants using BFS (avoid stack overflow)
|
|
421
|
+
const toRemove: string[] = [];
|
|
422
|
+
const queue = [node];
|
|
423
|
+
|
|
424
|
+
while (queue.length > 0) {
|
|
425
|
+
const current = queue.shift()!;
|
|
426
|
+
toRemove.push(current.id);
|
|
427
|
+
queue.push(...current.children);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// Remove all collected nodes
|
|
431
|
+
for (const id of toRemove) {
|
|
432
|
+
this.nodeMap.delete(id);
|
|
433
|
+
}
|
|
434
|
+
// COMPLEXITY: O(k) where k = nodes in removed subtree
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
onTreeChanged(root: WorkflowNode): void {
|
|
438
|
+
// ✅ No longer needed - all updates handled in onEvent()
|
|
439
|
+
this.root = root;
|
|
440
|
+
}
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
### Integration Points
|
|
444
|
+
|
|
445
|
+
```yaml
|
|
446
|
+
WORKFLOW EMIT EVENT:
|
|
447
|
+
- file: src/core/workflow.ts:363-379
|
|
448
|
+
- pattern: "emitEvent() calls obs.onEvent() then obs.onTreeChanged()"
|
|
449
|
+
- gotcha: "Both observers called for same event - causes redundant work"
|
|
450
|
+
|
|
451
|
+
EVENT TYPES:
|
|
452
|
+
- file: src/types/events.ts:10-18
|
|
453
|
+
- pattern: "Discriminated union with type field"
|
|
454
|
+
- gotcha: "childDetached only provides childId, not full node"
|
|
455
|
+
|
|
456
|
+
OBSERVER PATTERN:
|
|
457
|
+
- file: src/core/workflow.ts:124-139
|
|
458
|
+
- pattern: "getRootObservers() traverses parent chain"
|
|
459
|
+
- gotcha: "Uses visited Set for cycle detection"
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
## Validation Loop
|
|
465
|
+
|
|
466
|
+
### Level 1: Completeness Check (Immediate Feedback)
|
|
467
|
+
|
|
468
|
+
```bash
|
|
469
|
+
# Verify analysis document exists
|
|
470
|
+
test -f plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S1/analysis.md
|
|
471
|
+
echo "Analysis document exists: $?"
|
|
472
|
+
|
|
473
|
+
# Verify document contains all required sections
|
|
474
|
+
grep -q "Current Implementation" plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S1/analysis.md
|
|
475
|
+
echo "Current Implementation section exists: $?"
|
|
476
|
+
|
|
477
|
+
grep -q "Tree Change Event Analysis" plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S1/analysis.md
|
|
478
|
+
echo "Event Analysis section exists: $?"
|
|
479
|
+
|
|
480
|
+
grep -q "Performance Impact Analysis" plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S1/analysis.md
|
|
481
|
+
echo "Performance Analysis section exists: $?"
|
|
482
|
+
|
|
483
|
+
grep -q "Incremental Update Opportunities" plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S1/analysis.md
|
|
484
|
+
echo "Opportunities section exists: $?"
|
|
485
|
+
|
|
486
|
+
grep -q "Implementation Recommendations" plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S1/analysis.md
|
|
487
|
+
echo "Recommendations section exists: $?"
|
|
488
|
+
|
|
489
|
+
# Expected: All checks return 0 (true)
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
### Level 2: Content Quality Validation
|
|
493
|
+
|
|
494
|
+
```bash
|
|
495
|
+
# Verify line number references are accurate
|
|
496
|
+
grep -n "onTreeChanged" src/debugger/tree-debugger.ts
|
|
497
|
+
# Expected: Line 80 shows onTreeChanged method
|
|
498
|
+
|
|
499
|
+
grep -n "buildNodeMap" src/debugger/tree-debugger.ts
|
|
500
|
+
# Expected: Line 53 shows buildNodeMap method
|
|
501
|
+
|
|
502
|
+
grep -n "childAttached\|childDetached\|treeUpdated" src/types/events.ts
|
|
503
|
+
# Expected: Lines 10-18 show event definitions
|
|
504
|
+
|
|
505
|
+
# Verify analysis document contains code references
|
|
506
|
+
grep -q "src/debugger/tree-debugger.ts:80-84" plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S1/analysis.md
|
|
507
|
+
echo "Line number references present: $?"
|
|
508
|
+
|
|
509
|
+
# Verify complexity analysis present
|
|
510
|
+
grep -q "O(n)\|O(1)\|O(k)" plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S1/analysis.md
|
|
511
|
+
echo "Complexity analysis present: $?"
|
|
512
|
+
|
|
513
|
+
# Verify external research cited
|
|
514
|
+
grep -q "https://" plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S1/analysis.md
|
|
515
|
+
echo "External references cited: $?"
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
### Level 3: Research Artifact Validation
|
|
519
|
+
|
|
520
|
+
```bash
|
|
521
|
+
# Verify research directory exists
|
|
522
|
+
test -d plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S1/research
|
|
523
|
+
echo "Research directory exists: $?"
|
|
524
|
+
|
|
525
|
+
# Verify research README exists
|
|
526
|
+
test -f plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S1/research/README.md
|
|
527
|
+
echo "Research README exists: $?"
|
|
528
|
+
|
|
529
|
+
# Verify README contains link to main research package
|
|
530
|
+
grep -q "incremental-tree-map-updates" plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S1/research/README.md
|
|
531
|
+
echo "Research package linked: $?"
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
### Level 4: Readiness for P1.M3.T2.S2 Validation
|
|
535
|
+
|
|
536
|
+
```bash
|
|
537
|
+
# Verify recommendations are actionable
|
|
538
|
+
grep -q "addSubtree\|removeSubtree\|handleChildDetached" plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S1/analysis.md
|
|
539
|
+
echo "Actionable method names present: $?"
|
|
540
|
+
|
|
541
|
+
# Verify code examples provided
|
|
542
|
+
grep -q "```typescript" plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S1/analysis.md
|
|
543
|
+
echo "Code examples present: $?"
|
|
544
|
+
|
|
545
|
+
# Verify gotchas documented
|
|
546
|
+
grep -q "GOTCHA\|gotcha\|WARNING" plan/001_d3bb02af4886/bugfix/001_e8e04329daf3/P1M3T2S1/analysis.md
|
|
547
|
+
echo "Gotchas documented: $?"
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
---
|
|
551
|
+
|
|
552
|
+
## Final Validation Checklist
|
|
553
|
+
|
|
554
|
+
### Technical Validation
|
|
555
|
+
|
|
556
|
+
- [ ] Analysis document exists at correct path
|
|
557
|
+
- [ ] All required sections completed (Current Implementation, Event Analysis, Performance, Opportunities, Recommendations)
|
|
558
|
+
- [ ] Line number references accurate and verifiable
|
|
559
|
+
- [ ] Complexity analysis includes O(n), O(1), O(k) notations
|
|
560
|
+
- [ ] External research URLs cited with annotations
|
|
561
|
+
- [ ] Code pattern examples included for each recommendation
|
|
562
|
+
|
|
563
|
+
### Content Quality Validation
|
|
564
|
+
|
|
565
|
+
- [ ] Current implementation behavior fully documented
|
|
566
|
+
- [ ] All three tree change events (childAttached, childDetached, treeUpdated) analyzed
|
|
567
|
+
- [ ] Performance impact quantified with specific complexity values
|
|
568
|
+
- [ ] Redundant work identified (onEvent + onTreeChanged for childAttached)
|
|
569
|
+
- [ ] At least 3 specific optimization opportunities identified
|
|
570
|
+
- [ ] Implementation recommendations include specific method names and patterns
|
|
571
|
+
|
|
572
|
+
### Research Artifact Validation
|
|
573
|
+
|
|
574
|
+
- [ ] research/ directory created
|
|
575
|
+
- [ ] research/README.md exists with links to external resources
|
|
576
|
+
- [ ] Code pattern examples stored for P1.M3.T2.S2 reference
|
|
577
|
+
- [ ] Benchmark template provided for P1.M3.T2.S3
|
|
578
|
+
|
|
579
|
+
### P1.M3.T2.S2 Readiness Validation
|
|
580
|
+
|
|
581
|
+
- [ ] Recommendations enable implementation without additional research
|
|
582
|
+
- [ ] Specific method signatures provided (removeSubtree, handleChildDetached)
|
|
583
|
+
- [ ] Code examples follow existing codebase patterns
|
|
584
|
+
- [ ] Gotchas and anti-patterns documented to avoid
|
|
585
|
+
- [ ] Performance expectations quantified for validation
|
|
586
|
+
|
|
587
|
+
---
|
|
588
|
+
|
|
589
|
+
## Anti-Patterns to Avoid
|
|
590
|
+
|
|
591
|
+
- ❌ Don't implement code changes - this is a research task only
|
|
592
|
+
- ❌ Don't skip external research - use provided URLs for validation
|
|
593
|
+
- ❌ Don't omit line number references - P1.M3.T2.S2 needs exact locations
|
|
594
|
+
- ❌ Don't ignore the redundancy between onEvent() and onTreeChanged()
|
|
595
|
+
- ❌ Don't forget that childDetached only provides childId, not full node
|
|
596
|
+
- ❌ Don't recommend recursive subtree removal - use iterative BFS to avoid stack limits
|
|
597
|
+
- ❌ Don't omit complexity analysis - quantitative comparison essential
|
|
598
|
+
- ❌ Don't forget to document the treeUpdated case - root reference changes only
|
|
599
|
+
|
|
600
|
+
---
|
|
601
|
+
|
|
602
|
+
## Output Template
|
|
603
|
+
|
|
604
|
+
The analysis document should follow this structure:
|
|
605
|
+
|
|
606
|
+
```markdown
|
|
607
|
+
# Tree Debugger onTreeChanged Implementation Analysis
|
|
608
|
+
|
|
609
|
+
## Current Implementation
|
|
610
|
+
|
|
611
|
+
### buildNodeMap() - Line 53-58
|
|
612
|
+
[Code snippet and analysis]
|
|
613
|
+
|
|
614
|
+
### onEvent() - Line 66-74
|
|
615
|
+
[Code snippet and analysis]
|
|
616
|
+
|
|
617
|
+
### onTreeChanged() - Line 80-84
|
|
618
|
+
[Code snippet and analysis]
|
|
619
|
+
|
|
620
|
+
## Tree Change Event Analysis
|
|
621
|
+
|
|
622
|
+
### childAttached Event
|
|
623
|
+
- When: Called by attachChild() after child added to workflow.children and node.children
|
|
624
|
+
- Data: { type: 'childAttached', parentId: string, child: WorkflowNode }
|
|
625
|
+
- Current behavior: Added in onEvent(), then entire map rebuilt in onTreeChanged()
|
|
626
|
+
- Optimal behavior: Just add in onEvent(), skip onTreeChanged() rebuild
|
|
627
|
+
|
|
628
|
+
### childDetached Event
|
|
629
|
+
[Similar analysis]
|
|
630
|
+
|
|
631
|
+
### treeUpdated Event
|
|
632
|
+
[Similar analysis]
|
|
633
|
+
|
|
634
|
+
## Performance Impact Analysis
|
|
635
|
+
|
|
636
|
+
### Current Complexity
|
|
637
|
+
- childAttached: O(n)
|
|
638
|
+
- childDetached: O(n)
|
|
639
|
+
- treeUpdated: O(n)
|
|
640
|
+
|
|
641
|
+
### Incremental Complexity
|
|
642
|
+
- childAttached: O(k) already implemented
|
|
643
|
+
- childDetached: O(k) - needs implementation
|
|
644
|
+
- treeUpdated: O(1) - needs implementation
|
|
645
|
+
|
|
646
|
+
### Speedup Potential
|
|
647
|
+
[Table with specific speedup calculations]
|
|
648
|
+
|
|
649
|
+
## Incremental Update Opportunities
|
|
650
|
+
|
|
651
|
+
### Opportunity 1: Eliminate Redundant childAttached Rebuild
|
|
652
|
+
[Description and recommendation]
|
|
653
|
+
|
|
654
|
+
### Opportunity 2: Implement childDetached Subtree Removal
|
|
655
|
+
[Description with code pattern]
|
|
656
|
+
|
|
657
|
+
### Opportunity 3: Replace treeUpdated Full Rebuild
|
|
658
|
+
[Description with code pattern]
|
|
659
|
+
|
|
660
|
+
### Opportunity 4: Remove onTreeChanged Rebuild Entirely
|
|
661
|
+
[Description with code pattern]
|
|
662
|
+
|
|
663
|
+
## Implementation Recommendations
|
|
664
|
+
|
|
665
|
+
### For P1.M3.T2.S2: Add removeSubtree() Method
|
|
666
|
+
[Specific implementation guidance]
|
|
667
|
+
|
|
668
|
+
### For P1.M3.T2.S2: Modify onEvent() to Handle childDetached
|
|
669
|
+
[Specific implementation guidance]
|
|
670
|
+
|
|
671
|
+
### For P1.M3.T2.S2: Simplify onTreeChanged()
|
|
672
|
+
[Specific implementation guidance]
|
|
673
|
+
|
|
674
|
+
### Gotchas to Avoid
|
|
675
|
+
[List of potential issues]
|
|
676
|
+
|
|
677
|
+
## References
|
|
678
|
+
|
|
679
|
+
### External Research
|
|
680
|
+
[Links to MDN, React docs, V8 blog, StackOverflow]
|
|
681
|
+
|
|
682
|
+
### Internal Research
|
|
683
|
+
[Links to research package files]
|
|
684
|
+
|
|
685
|
+
### Code Files Referenced
|
|
686
|
+
[Links to specific files with line numbers]
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
---
|
|
690
|
+
|
|
691
|
+
## Appendix: Research Summary
|
|
692
|
+
|
|
693
|
+
### Research Package Location
|
|
694
|
+
|
|
695
|
+
`plan/001_d3bb02af4886/docs/research/incremental-tree-map-updates/`
|
|
696
|
+
|
|
697
|
+
### Key Files
|
|
698
|
+
|
|
699
|
+
- `QUICK_REFERENCE.md` - Code examples and patterns
|
|
700
|
+
- `RESEARCH_REPORT.md` - Comprehensive analysis
|
|
701
|
+
- `SUMMARY.md` - Executive summary
|
|
702
|
+
- `PRP_TEMPLATE.md` - Implementation PRP template
|
|
703
|
+
|
|
704
|
+
### Expected P1.M3.T2.S2 Output
|
|
705
|
+
|
|
706
|
+
After this analysis, P1.M3.T2.S2 should implement:
|
|
707
|
+
|
|
708
|
+
1. `removeSubtree(nodeId: string)` - BFS-based subtree removal
|
|
709
|
+
2. Modified `onEvent()` - Handle childDetached
|
|
710
|
+
3. Simplified `onTreeChanged()` - Remove full rebuild
|
|
711
|
+
|
|
712
|
+
Expected performance improvement: **100-1000× faster** for large trees.
|
|
713
|
+
|
|
714
|
+
---
|
|
715
|
+
|
|
716
|
+
**PRP Version**: 1.0
|
|
717
|
+
**Last Updated**: 2025-01-12
|
|
718
|
+
**Next PRP**: P1.M3.T2.S2 (Implementation)
|
|
719
|
+
**Dependencies**: None (research task)
|