@agentic-qe/v3 3.0.0-alpha.6 → 3.0.0-alpha.7
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/assets/agents/v3/subagents/v3-qe-code-reviewer.md +339 -0
- package/assets/agents/v3/subagents/v3-qe-integration-reviewer.md +344 -0
- package/assets/agents/v3/subagents/v3-qe-performance-reviewer.md +351 -0
- package/assets/agents/v3/subagents/v3-qe-security-reviewer.md +374 -0
- package/assets/agents/v3/subagents/v3-qe-tdd-green.md +334 -0
- package/assets/agents/v3/subagents/v3-qe-tdd-red.md +329 -0
- package/assets/agents/v3/subagents/v3-qe-tdd-refactor.md +361 -0
- package/assets/agents/v3/v3-qe-accessibility-auditor.md +266 -0
- package/assets/agents/v3/v3-qe-bdd-generator.md +279 -0
- package/assets/agents/v3/v3-qe-chaos-engineer.md +265 -0
- package/assets/agents/v3/v3-qe-code-complexity.md +298 -0
- package/assets/agents/v3/v3-qe-code-intelligence.md +262 -0
- package/assets/agents/v3/v3-qe-contract-validator.md +267 -0
- package/assets/agents/v3/v3-qe-coverage-specialist.md +227 -0
- package/assets/agents/v3/v3-qe-defect-predictor.md +251 -0
- package/assets/agents/v3/v3-qe-dependency-mapper.md +277 -0
- package/assets/agents/v3/v3-qe-deployment-advisor.md +275 -0
- package/assets/agents/v3/v3-qe-flaky-hunter.md +248 -0
- package/assets/agents/v3/v3-qe-fleet-commander.md +293 -0
- package/assets/agents/v3/v3-qe-gap-detector.md +260 -0
- package/assets/agents/v3/v3-qe-graphql-tester.md +308 -0
- package/assets/agents/v3/v3-qe-impact-analyzer.md +299 -0
- package/assets/agents/v3/v3-qe-integration-tester.md +238 -0
- package/assets/agents/v3/v3-qe-kg-builder.md +273 -0
- package/assets/agents/v3/v3-qe-learning-coordinator.md +226 -0
- package/assets/agents/v3/v3-qe-load-tester.md +280 -0
- package/assets/agents/v3/v3-qe-metrics-optimizer.md +300 -0
- package/assets/agents/v3/v3-qe-mutation-tester.md +301 -0
- package/assets/agents/v3/v3-qe-parallel-executor.md +240 -0
- package/assets/agents/v3/v3-qe-pattern-learner.md +271 -0
- package/assets/agents/v3/v3-qe-performance-tester.md +262 -0
- package/assets/agents/v3/v3-qe-property-tester.md +247 -0
- package/assets/agents/v3/v3-qe-quality-gate.md +218 -0
- package/assets/agents/v3/v3-qe-queen-coordinator.md +214 -0
- package/assets/agents/v3/v3-qe-qx-partner.md +313 -0
- package/assets/agents/v3/v3-qe-regression-analyzer.md +322 -0
- package/assets/agents/v3/v3-qe-requirements-validator.md +360 -0
- package/assets/agents/v3/v3-qe-responsive-tester.md +311 -0
- package/assets/agents/v3/v3-qe-retry-handler.md +256 -0
- package/assets/agents/v3/v3-qe-risk-assessor.md +273 -0
- package/assets/agents/v3/v3-qe-root-cause-analyzer.md +286 -0
- package/assets/agents/v3/v3-qe-security-auditor.md +299 -0
- package/assets/agents/v3/v3-qe-security-scanner.md +235 -0
- package/assets/agents/v3/v3-qe-tdd-specialist.md +239 -0
- package/assets/agents/v3/v3-qe-test-architect.md +233 -0
- package/assets/agents/v3/v3-qe-transfer-specialist.md +295 -0
- package/assets/agents/v3/v3-qe-visual-tester.md +232 -0
- package/assets/skills/accessibility-testing/SKILL.md +216 -0
- package/assets/skills/agentdb-advanced/SKILL.md +550 -0
- package/assets/skills/agentdb-learning/SKILL.md +545 -0
- package/assets/skills/agentdb-memory-patterns/SKILL.md +339 -0
- package/assets/skills/agentdb-optimization/SKILL.md +509 -0
- package/assets/skills/agentdb-vector-search/SKILL.md +339 -0
- package/assets/skills/agentic-jujutsu/SKILL.md +645 -0
- package/assets/skills/agentic-quality-engineering/SKILL.md +335 -0
- package/assets/skills/api-testing-patterns/SKILL.md +294 -0
- package/assets/skills/aqe-v2-v3-migration/skill.md +322 -0
- package/assets/skills/brutal-honesty-review/README.md +218 -0
- package/assets/skills/brutal-honesty-review/SKILL.md +235 -0
- package/assets/skills/brutal-honesty-review/resources/assessment-rubrics.md +295 -0
- package/assets/skills/brutal-honesty-review/resources/review-template.md +102 -0
- package/assets/skills/brutal-honesty-review/scripts/assess-code.sh +179 -0
- package/assets/skills/brutal-honesty-review/scripts/assess-tests.sh +223 -0
- package/assets/skills/bug-reporting-excellence/SKILL.md +225 -0
- package/assets/skills/chaos-engineering-resilience/SKILL.md +158 -0
- package/assets/skills/cicd-pipeline-qe-orchestrator/README.md +304 -0
- package/assets/skills/cicd-pipeline-qe-orchestrator/SKILL.md +315 -0
- package/assets/skills/cicd-pipeline-qe-orchestrator/resources/workflows/microservice-pipeline.md +239 -0
- package/assets/skills/cicd-pipeline-qe-orchestrator/resources/workflows/mobile-pipeline.md +375 -0
- package/assets/skills/cicd-pipeline-qe-orchestrator/resources/workflows/monolith-pipeline.md +268 -0
- package/assets/skills/code-review-quality/SKILL.md +227 -0
- package/assets/skills/compatibility-testing/SKILL.md +205 -0
- package/assets/skills/compliance-testing/SKILL.md +225 -0
- package/assets/skills/consultancy-practices/SKILL.md +202 -0
- package/assets/skills/context-driven-testing/SKILL.md +196 -0
- package/assets/skills/contract-testing/SKILL.md +222 -0
- package/assets/skills/database-testing/SKILL.md +244 -0
- package/assets/skills/exploratory-testing-advanced/SKILL.md +201 -0
- package/assets/skills/flow-nexus-neural/SKILL.md +738 -0
- package/assets/skills/flow-nexus-platform/SKILL.md +1157 -0
- package/assets/skills/flow-nexus-swarm/SKILL.md +610 -0
- package/assets/skills/github-code-review/SKILL.md +1140 -0
- package/assets/skills/github-multi-repo/SKILL.md +874 -0
- package/assets/skills/github-project-management/SKILL.md +1277 -0
- package/assets/skills/github-release-management/SKILL.md +1081 -0
- package/assets/skills/github-workflow-automation/SKILL.md +1065 -0
- package/assets/skills/hive-mind-advanced/SKILL.md +712 -0
- package/assets/skills/holistic-testing-pact/SKILL.md +171 -0
- package/assets/skills/hooks-automation/SKILL.md +1201 -0
- package/assets/skills/localization-testing/SKILL.md +221 -0
- package/assets/skills/mobile-testing/SKILL.md +219 -0
- package/assets/skills/mutation-testing/SKILL.md +229 -0
- package/assets/skills/n8n-expression-testing/SKILL.md +434 -0
- package/assets/skills/n8n-integration-testing-patterns/SKILL.md +540 -0
- package/assets/skills/n8n-security-testing/SKILL.md +599 -0
- package/assets/skills/n8n-trigger-testing-strategies/SKILL.md +541 -0
- package/assets/skills/n8n-workflow-testing-fundamentals/SKILL.md +447 -0
- package/assets/skills/pair-programming/SKILL.md +1202 -0
- package/assets/skills/performance-analysis/SKILL.md +563 -0
- package/assets/skills/performance-testing/SKILL.md +310 -0
- package/assets/skills/quality-metrics/SKILL.md +225 -0
- package/assets/skills/reasoningbank-agentdb/SKILL.md +446 -0
- package/assets/skills/reasoningbank-intelligence/SKILL.md +201 -0
- package/assets/skills/refactoring-patterns/SKILL.md +205 -0
- package/assets/skills/regression-testing/SKILL.md +227 -0
- package/assets/skills/risk-based-testing/SKILL.md +206 -0
- package/assets/skills/security-testing/SKILL.md +306 -0
- package/assets/skills/sherlock-review/SKILL.md +250 -0
- package/assets/skills/shift-left-testing/SKILL.md +225 -0
- package/assets/skills/shift-right-testing/SKILL.md +227 -0
- package/assets/skills/six-thinking-hats/README.md +190 -0
- package/assets/skills/six-thinking-hats/SKILL.md +280 -0
- package/assets/skills/six-thinking-hats/resources/examples/api-testing-example.md +345 -0
- package/assets/skills/six-thinking-hats/resources/templates/solo-session-template.md +167 -0
- package/assets/skills/six-thinking-hats/resources/templates/team-session-template.md +336 -0
- package/assets/skills/skill-builder/SKILL.md +910 -0
- package/assets/skills/sparc-methodology/SKILL.md +1115 -0
- package/assets/skills/stream-chain/SKILL.md +563 -0
- package/assets/skills/swarm-advanced/SKILL.md +973 -0
- package/assets/skills/swarm-orchestration/SKILL.md +179 -0
- package/assets/skills/tdd-london-chicago/SKILL.md +244 -0
- package/assets/skills/technical-writing/SKILL.md +178 -0
- package/assets/skills/test-automation-strategy/SKILL.md +230 -0
- package/assets/skills/test-data-management/SKILL.md +270 -0
- package/assets/skills/test-design-techniques/SKILL.md +244 -0
- package/assets/skills/test-environment-management/SKILL.md +243 -0
- package/assets/skills/test-reporting-analytics/SKILL.md +214 -0
- package/assets/skills/testability-scoring/README.md +71 -0
- package/assets/skills/testability-scoring/SKILL.md +346 -0
- package/assets/skills/testability-scoring/resources/templates/config.template.js +84 -0
- package/assets/skills/testability-scoring/resources/templates/testability-scoring.spec.template.js +532 -0
- package/assets/skills/testability-scoring/scripts/generate-html-report.js +1007 -0
- package/assets/skills/testability-scoring/scripts/run-assessment.sh +70 -0
- package/assets/skills/v3-qe-chaos-resilience/SKILL.md +238 -0
- package/assets/skills/v3-qe-code-intelligence/SKILL.md +209 -0
- package/assets/skills/v3-qe-contract-testing/SKILL.md +218 -0
- package/assets/skills/v3-qe-coverage-analysis/SKILL.md +187 -0
- package/assets/skills/v3-qe-defect-intelligence/SKILL.md +205 -0
- package/assets/skills/v3-qe-learning-optimization/SKILL.md +238 -0
- package/assets/skills/v3-qe-quality-assessment/SKILL.md +213 -0
- package/assets/skills/v3-qe-requirements-validation/SKILL.md +248 -0
- package/assets/skills/v3-qe-test-execution/SKILL.md +182 -0
- package/assets/skills/v3-qe-test-generation/SKILL.md +141 -0
- package/assets/skills/v3-qe-visual-accessibility/SKILL.md +242 -0
- package/assets/skills/verification-quality/SKILL.md +649 -0
- package/assets/skills/visual-testing-advanced/SKILL.md +219 -0
- package/assets/skills/xp-practices/SKILL.md +229 -0
- package/dist/cli/bundle.js +8 -8
- package/dist/init/agents-installer.js +4 -4
- package/dist/init/agents-installer.js.map +1 -1
- package/dist/init/skills-installer.js +4 -4
- package/dist/init/skills-installer.js.map +1 -1
- package/package.json +7 -1
- package/docs/analysis/V3-INIT-REQUIREMENTS-ANALYSIS.md +0 -352
- package/implementation/README.md +0 -90
- package/implementation/adrs/ADR-030-coherence-gated-quality-gates.md +0 -312
- package/implementation/adrs/ADR-031-strange-loop-self-awareness.md +0 -484
- package/implementation/adrs/ADR-032-time-crystal-scheduling.md +0 -530
- package/implementation/adrs/ADR-033-early-exit-testing.md +0 -634
- package/implementation/adrs/ADR-034-neural-topology-optimizer.md +0 -589
- package/implementation/adrs/ADR-035-causal-discovery.md +0 -610
- package/implementation/adrs/ADR-036-result-persistence.md +0 -326
- package/implementation/adrs/ADR-037-v3-qe-agent-naming.md +0 -105
- package/implementation/adrs/ADR-038-v3-qe-memory-unification.md +0 -154
- package/implementation/adrs/ADR-039-v3-qe-mcp-optimization.md +0 -179
- package/implementation/adrs/ADR-040-v3-qe-agentic-flow-integration.md +0 -240
- package/implementation/adrs/ADR-041-v3-qe-cli-enhancement.md +0 -296
- package/implementation/adrs/ADR-042-v3-qe-token-tracking-integration.md +0 -517
- package/implementation/adrs/v3-adrs.md +0 -2783
- package/implementation/planning/AQE-V3-MASTER-PLAN.md +0 -815
- package/security-scan-report-2026-01-11.md +0 -410
- package/security-verification-report-2026-01-11.md +0 -278
- package/src/benchmarks/performance-benchmarks.ts +0 -646
- package/src/benchmarks/run-benchmarks.ts +0 -324
- package/src/causal-discovery/causal-graph.ts +0 -450
- package/src/causal-discovery/discovery-engine.ts +0 -438
- package/src/causal-discovery/index.ts +0 -117
- package/src/causal-discovery/types.ts +0 -456
- package/src/causal-discovery/weight-matrix.ts +0 -453
- package/src/cli/commands/qe-tools.ts +0 -634
- package/src/cli/index.ts +0 -1976
- package/src/compatibility/agent-mapper.ts +0 -291
- package/src/compatibility/cli-adapter.ts +0 -277
- package/src/compatibility/config-migrator.ts +0 -334
- package/src/compatibility/index.ts +0 -112
- package/src/compatibility/mcp-adapter.ts +0 -248
- package/src/compatibility/types.ts +0 -156
- package/src/coordination/claims/claim-repository.ts +0 -636
- package/src/coordination/claims/claim-service.ts +0 -675
- package/src/coordination/claims/handoff-manager.ts +0 -535
- package/src/coordination/claims/index.ts +0 -276
- package/src/coordination/claims/interfaces.ts +0 -687
- package/src/coordination/claims/work-stealing.ts +0 -436
- package/src/coordination/cross-domain-router.ts +0 -492
- package/src/coordination/index.ts +0 -127
- package/src/coordination/interfaces.ts +0 -691
- package/src/coordination/protocol-executor.ts +0 -760
- package/src/coordination/protocols/code-intelligence-index.ts +0 -855
- package/src/coordination/protocols/defect-investigation.ts +0 -1184
- package/src/coordination/protocols/index.ts +0 -11
- package/src/coordination/protocols/learning-consolidation.ts +0 -1181
- package/src/coordination/protocols/morning-sync.ts +0 -1055
- package/src/coordination/protocols/quality-gate.ts +0 -1566
- package/src/coordination/protocols/security-audit.ts +0 -1587
- package/src/coordination/queen-coordinator.ts +0 -1176
- package/src/coordination/result-saver.ts +0 -780
- package/src/coordination/task-executor.ts +0 -1146
- package/src/coordination/workflow-orchestrator.ts +0 -1917
- package/src/domains/chaos-resilience/coordinator.ts +0 -1032
- package/src/domains/chaos-resilience/index.ts +0 -143
- package/src/domains/chaos-resilience/interfaces.ts +0 -659
- package/src/domains/chaos-resilience/plugin.ts +0 -691
- package/src/domains/chaos-resilience/services/chaos-engineer.ts +0 -1097
- package/src/domains/chaos-resilience/services/index.ts +0 -19
- package/src/domains/chaos-resilience/services/load-tester.ts +0 -799
- package/src/domains/chaos-resilience/services/performance-profiler.ts +0 -792
- package/src/domains/code-intelligence/coordinator.ts +0 -631
- package/src/domains/code-intelligence/index.ts +0 -86
- package/src/domains/code-intelligence/interfaces.ts +0 -162
- package/src/domains/code-intelligence/plugin.ts +0 -451
- package/src/domains/code-intelligence/services/impact-analyzer.ts +0 -567
- package/src/domains/code-intelligence/services/index.ts +0 -26
- package/src/domains/code-intelligence/services/knowledge-graph.ts +0 -1067
- package/src/domains/code-intelligence/services/semantic-analyzer.ts +0 -901
- package/src/domains/contract-testing/coordinator.ts +0 -1038
- package/src/domains/contract-testing/index.ts +0 -122
- package/src/domains/contract-testing/interfaces.ts +0 -458
- package/src/domains/contract-testing/plugin.ts +0 -746
- package/src/domains/contract-testing/services/api-compatibility.ts +0 -748
- package/src/domains/contract-testing/services/contract-validator.ts +0 -1700
- package/src/domains/contract-testing/services/index.ts +0 -19
- package/src/domains/contract-testing/services/schema-validator.ts +0 -1102
- package/src/domains/coverage-analysis/coordinator.ts +0 -485
- package/src/domains/coverage-analysis/index.ts +0 -114
- package/src/domains/coverage-analysis/interfaces.ts +0 -142
- package/src/domains/coverage-analysis/plugin.ts +0 -172
- package/src/domains/coverage-analysis/services/coverage-analyzer.ts +0 -449
- package/src/domains/coverage-analysis/services/coverage-embedder.ts +0 -733
- package/src/domains/coverage-analysis/services/coverage-parser.ts +0 -753
- package/src/domains/coverage-analysis/services/gap-detector.ts +0 -592
- package/src/domains/coverage-analysis/services/hnsw-index.ts +0 -728
- package/src/domains/coverage-analysis/services/index.ts +0 -61
- package/src/domains/coverage-analysis/services/risk-scorer.ts +0 -540
- package/src/domains/coverage-analysis/services/sublinear-analyzer.ts +0 -747
- package/src/domains/defect-intelligence/coordinator.ts +0 -635
- package/src/domains/defect-intelligence/index.ts +0 -83
- package/src/domains/defect-intelligence/interfaces.ts +0 -152
- package/src/domains/defect-intelligence/plugin.ts +0 -483
- package/src/domains/defect-intelligence/services/causal-root-cause-analyzer.ts +0 -494
- package/src/domains/defect-intelligence/services/defect-predictor.ts +0 -852
- package/src/domains/defect-intelligence/services/index.ts +0 -37
- package/src/domains/defect-intelligence/services/pattern-learner.ts +0 -738
- package/src/domains/defect-intelligence/services/root-cause-analyzer.ts +0 -637
- package/src/domains/domain-interface.ts +0 -77
- package/src/domains/index.ts +0 -23
- package/src/domains/learning-optimization/coordinator.ts +0 -1215
- package/src/domains/learning-optimization/index.ts +0 -127
- package/src/domains/learning-optimization/interfaces.ts +0 -570
- package/src/domains/learning-optimization/plugin.ts +0 -851
- package/src/domains/learning-optimization/services/index.ts +0 -29
- package/src/domains/learning-optimization/services/learning-coordinator.ts +0 -972
- package/src/domains/learning-optimization/services/metrics-optimizer.ts +0 -915
- package/src/domains/learning-optimization/services/production-intel.ts +0 -971
- package/src/domains/learning-optimization/services/transfer-specialist.ts +0 -723
- package/src/domains/quality-assessment/coherence/gate-controller.ts +0 -549
- package/src/domains/quality-assessment/coherence/index.ts +0 -211
- package/src/domains/quality-assessment/coherence/lambda-calculator.ts +0 -384
- package/src/domains/quality-assessment/coherence/partition-detector.ts +0 -469
- package/src/domains/quality-assessment/coherence/types.ts +0 -384
- package/src/domains/quality-assessment/coordinator.ts +0 -605
- package/src/domains/quality-assessment/index.ts +0 -97
- package/src/domains/quality-assessment/interfaces.ts +0 -152
- package/src/domains/quality-assessment/plugin.ts +0 -496
- package/src/domains/quality-assessment/services/coherence-gate.ts +0 -358
- package/src/domains/quality-assessment/services/deployment-advisor.ts +0 -571
- package/src/domains/quality-assessment/services/index.ts +0 -34
- package/src/domains/quality-assessment/services/quality-analyzer.ts +0 -670
- package/src/domains/quality-assessment/services/quality-gate.ts +0 -384
- package/src/domains/requirements-validation/coordinator.ts +0 -812
- package/src/domains/requirements-validation/index.ts +0 -92
- package/src/domains/requirements-validation/interfaces.ts +0 -303
- package/src/domains/requirements-validation/plugin.ts +0 -576
- package/src/domains/requirements-validation/services/bdd-scenario-writer.ts +0 -676
- package/src/domains/requirements-validation/services/index.ts +0 -20
- package/src/domains/requirements-validation/services/requirements-validator.ts +0 -559
- package/src/domains/requirements-validation/services/testability-scorer.ts +0 -639
- package/src/domains/security-compliance/coordinator.ts +0 -757
- package/src/domains/security-compliance/index.ts +0 -120
- package/src/domains/security-compliance/interfaces.ts +0 -434
- package/src/domains/security-compliance/plugin.ts +0 -509
- package/src/domains/security-compliance/services/compliance-validator.ts +0 -1226
- package/src/domains/security-compliance/services/index.ts +0 -31
- package/src/domains/security-compliance/services/security-auditor.ts +0 -2227
- package/src/domains/security-compliance/services/security-scanner.ts +0 -2354
- package/src/domains/security-compliance/services/semgrep-integration.ts +0 -289
- package/src/domains/test-execution/coordinator.ts +0 -426
- package/src/domains/test-execution/index.ts +0 -76
- package/src/domains/test-execution/interfaces.ts +0 -119
- package/src/domains/test-execution/plugin.ts +0 -208
- package/src/domains/test-execution/services/flaky-detector.ts +0 -1240
- package/src/domains/test-execution/services/index.ts +0 -8
- package/src/domains/test-execution/services/retry-handler.ts +0 -820
- package/src/domains/test-execution/services/test-executor.ts +0 -885
- package/src/domains/test-generation/coordinator.ts +0 -656
- package/src/domains/test-generation/index.ts +0 -77
- package/src/domains/test-generation/interfaces.ts +0 -118
- package/src/domains/test-generation/plugin.ts +0 -397
- package/src/domains/test-generation/services/index.ts +0 -23
- package/src/domains/test-generation/services/pattern-matcher.ts +0 -1725
- package/src/domains/test-generation/services/test-generator.ts +0 -2750
- package/src/domains/visual-accessibility/coordinator.ts +0 -860
- package/src/domains/visual-accessibility/index.ts +0 -116
- package/src/domains/visual-accessibility/interfaces.ts +0 -435
- package/src/domains/visual-accessibility/plugin.ts +0 -568
- package/src/domains/visual-accessibility/services/accessibility-tester.ts +0 -982
- package/src/domains/visual-accessibility/services/axe-core-audit.ts +0 -630
- package/src/domains/visual-accessibility/services/index.ts +0 -28
- package/src/domains/visual-accessibility/services/responsive-tester.ts +0 -934
- package/src/domains/visual-accessibility/services/visual-tester.ts +0 -458
- package/src/early-exit/early-exit-controller.ts +0 -490
- package/src/early-exit/early-exit-decision.ts +0 -391
- package/src/early-exit/index.ts +0 -115
- package/src/early-exit/quality-signal.ts +0 -389
- package/src/early-exit/speculative-executor.ts +0 -505
- package/src/early-exit/types.ts +0 -407
- package/src/feedback/coverage-learner.ts +0 -456
- package/src/feedback/feedback-loop.ts +0 -426
- package/src/feedback/index.ts +0 -72
- package/src/feedback/pattern-promotion.ts +0 -373
- package/src/feedback/quality-score-calculator.ts +0 -334
- package/src/feedback/test-outcome-tracker.ts +0 -450
- package/src/feedback/types.ts +0 -497
- package/src/index.ts +0 -224
- package/src/init/agents-installer.ts +0 -536
- package/src/init/index.ts +0 -80
- package/src/init/init-wizard.ts +0 -1061
- package/src/init/project-analyzer.ts +0 -696
- package/src/init/self-configurator.ts +0 -488
- package/src/init/skills-installer.ts +0 -467
- package/src/init/types.ts +0 -432
- package/src/integrations/ruvector/ast-complexity.ts +0 -470
- package/src/integrations/ruvector/coverage-router.ts +0 -594
- package/src/integrations/ruvector/diff-risk-classifier.ts +0 -759
- package/src/integrations/ruvector/fallback.ts +0 -942
- package/src/integrations/ruvector/graph-boundaries.ts +0 -809
- package/src/integrations/ruvector/index.ts +0 -363
- package/src/integrations/ruvector/interfaces.ts +0 -609
- package/src/integrations/ruvector/q-learning-router.ts +0 -550
- package/src/kernel/agent-coordinator.ts +0 -165
- package/src/kernel/agentdb-backend.ts +0 -504
- package/src/kernel/event-bus.ts +0 -129
- package/src/kernel/hybrid-backend.ts +0 -538
- package/src/kernel/index.ts +0 -28
- package/src/kernel/interfaces.ts +0 -257
- package/src/kernel/kernel.ts +0 -285
- package/src/kernel/memory-backend.ts +0 -169
- package/src/kernel/memory-factory.ts +0 -293
- package/src/kernel/plugin-loader.ts +0 -179
- package/src/learning/index.ts +0 -219
- package/src/learning/pattern-store.ts +0 -990
- package/src/learning/qe-guidance.ts +0 -832
- package/src/learning/qe-hooks.ts +0 -644
- package/src/learning/qe-patterns.ts +0 -449
- package/src/learning/qe-reasoning-bank.ts +0 -951
- package/src/learning/real-embeddings.ts +0 -277
- package/src/learning/real-qe-reasoning-bank.ts +0 -833
- package/src/learning/sqlite-persistence.ts +0 -554
- package/src/mcp/entry.ts +0 -59
- package/src/mcp/handlers/agent-handlers.ts +0 -285
- package/src/mcp/handlers/core-handlers.ts +0 -317
- package/src/mcp/handlers/domain-handlers.ts +0 -1444
- package/src/mcp/handlers/index.ts +0 -57
- package/src/mcp/handlers/memory-handlers.ts +0 -338
- package/src/mcp/handlers/task-handlers.ts +0 -363
- package/src/mcp/index.ts +0 -30
- package/src/mcp/metrics/index.ts +0 -14
- package/src/mcp/metrics/metrics-collector.ts +0 -503
- package/src/mcp/protocol-server.ts +0 -752
- package/src/mcp/security/cve-prevention.ts +0 -742
- package/src/mcp/security/index.ts +0 -356
- package/src/mcp/security/oauth21-provider.ts +0 -821
- package/src/mcp/security/rate-limiter.ts +0 -615
- package/src/mcp/security/sampling-server.ts +0 -662
- package/src/mcp/security/schema-validator.ts +0 -855
- package/src/mcp/server.ts +0 -657
- package/src/mcp/tool-registry.ts +0 -391
- package/src/mcp/tools/base.ts +0 -399
- package/src/mcp/tools/chaos-resilience/inject.ts +0 -699
- package/src/mcp/tools/code-intelligence/analyze.ts +0 -745
- package/src/mcp/tools/contract-testing/validate.ts +0 -708
- package/src/mcp/tools/coverage-analysis/index.ts +0 -770
- package/src/mcp/tools/defect-intelligence/predict.ts +0 -466
- package/src/mcp/tools/index.ts +0 -214
- package/src/mcp/tools/learning-optimization/optimize.ts +0 -772
- package/src/mcp/tools/quality-assessment/evaluate.ts +0 -385
- package/src/mcp/tools/registry.ts +0 -248
- package/src/mcp/tools/requirements-validation/validate.ts +0 -394
- package/src/mcp/tools/security-compliance/scan.ts +0 -365
- package/src/mcp/tools/test-execution/execute.ts +0 -291
- package/src/mcp/tools/test-generation/generate.ts +0 -544
- package/src/mcp/tools/visual-accessibility/index.ts +0 -791
- package/src/mcp/transport/index.ts +0 -31
- package/src/mcp/transport/stdio.ts +0 -318
- package/src/mcp/types.ts +0 -543
- package/src/neural-optimizer/index.ts +0 -111
- package/src/neural-optimizer/replay-buffer.ts +0 -455
- package/src/neural-optimizer/swarm-topology.ts +0 -508
- package/src/neural-optimizer/topology-optimizer.ts +0 -828
- package/src/neural-optimizer/types.ts +0 -481
- package/src/neural-optimizer/value-network.ts +0 -351
- package/src/optimization/auto-tuner.ts +0 -817
- package/src/optimization/index.ts +0 -77
- package/src/optimization/metric-collectors.ts +0 -474
- package/src/optimization/qe-workers.ts +0 -704
- package/src/optimization/tuning-algorithm.ts +0 -401
- package/src/optimization/types.ts +0 -314
- package/src/routing/index.ts +0 -51
- package/src/routing/qe-agent-registry.ts +0 -963
- package/src/routing/qe-task-router.ts +0 -564
- package/src/routing/routing-feedback.ts +0 -365
- package/src/routing/types.ts +0 -406
- package/src/shared/embeddings/embedding-cache.ts +0 -157
- package/src/shared/embeddings/index.ts +0 -50
- package/src/shared/embeddings/nomic-embedder.ts +0 -404
- package/src/shared/embeddings/ollama-client.ts +0 -195
- package/src/shared/embeddings/types.ts +0 -147
- package/src/shared/entities/agent.ts +0 -141
- package/src/shared/entities/base-entity.ts +0 -79
- package/src/shared/entities/index.ts +0 -6
- package/src/shared/events/domain-events.ts +0 -259
- package/src/shared/events/index.ts +0 -5
- package/src/shared/git/git-analyzer.ts +0 -656
- package/src/shared/git/index.ts +0 -11
- package/src/shared/http/http-client.ts +0 -420
- package/src/shared/http/index.ts +0 -13
- package/src/shared/index.ts +0 -41
- package/src/shared/io/file-reader.ts +0 -525
- package/src/shared/io/index.ts +0 -25
- package/src/shared/llm/cache.ts +0 -473
- package/src/shared/llm/circuit-breaker.ts +0 -369
- package/src/shared/llm/cost-tracker.ts +0 -460
- package/src/shared/llm/index.ts +0 -140
- package/src/shared/llm/interfaces.ts +0 -629
- package/src/shared/llm/provider-manager.ts +0 -685
- package/src/shared/llm/providers/claude.ts +0 -524
- package/src/shared/llm/providers/index.ts +0 -8
- package/src/shared/llm/providers/ollama.ts +0 -575
- package/src/shared/llm/providers/openai.ts +0 -609
- package/src/shared/metrics/code-metrics.ts +0 -520
- package/src/shared/metrics/index.ts +0 -23
- package/src/shared/metrics/system-metrics.ts +0 -353
- package/src/shared/parsers/index.ts +0 -6
- package/src/shared/parsers/typescript-parser.ts +0 -841
- package/src/shared/security/compliance-patterns.ts +0 -666
- package/src/shared/security/index.ts +0 -30
- package/src/shared/security/osv-client.ts +0 -468
- package/src/shared/types/index.ts +0 -150
- package/src/shared/value-objects/index.ts +0 -273
- package/src/strange-loop/healing-controller.ts +0 -833
- package/src/strange-loop/index.ts +0 -104
- package/src/strange-loop/self-model.ts +0 -494
- package/src/strange-loop/strange-loop.ts +0 -446
- package/src/strange-loop/swarm-observer.ts +0 -448
- package/src/strange-loop/topology-analyzer.ts +0 -565
- package/src/strange-loop/types.ts +0 -640
- package/src/time-crystal/default-phases.ts +0 -520
- package/src/time-crystal/index.ts +0 -164
- package/src/time-crystal/oscillator.ts +0 -425
- package/src/time-crystal/phase-executor.ts +0 -521
- package/src/time-crystal/scheduler.ts +0 -1025
- package/src/time-crystal/test-runner.ts +0 -787
- package/src/time-crystal/types.ts +0 -421
- package/src/workers/base-worker.ts +0 -304
- package/src/workers/daemon.ts +0 -264
- package/src/workers/index.ts +0 -119
- package/src/workers/interfaces.ts +0 -393
- package/src/workers/worker-manager.ts +0 -424
- package/src/workers/workers/compliance-checker.ts +0 -445
- package/src/workers/workers/coverage-tracker.ts +0 -344
- package/src/workers/workers/defect-predictor.ts +0 -375
- package/src/workers/workers/flaky-detector.ts +0 -390
- package/src/workers/workers/index.ts +0 -17
- package/src/workers/workers/learning-consolidation.ts +0 -442
- package/src/workers/workers/performance-baseline.ts +0 -434
- package/src/workers/workers/quality-gate.ts +0 -419
- package/src/workers/workers/regression-monitor.ts +0 -357
- package/src/workers/workers/security-scan.ts +0 -349
- package/src/workers/workers/test-health.ts +0 -359
- package/tests/integration/code-intelligence/knowledge-graph-real.test.ts +0 -540
- package/tests/integration/coordination/cross-domain-router.test.ts +0 -403
- package/tests/integration/coordination/protocol-executor.test.ts +0 -454
- package/tests/integration/coordination/workflow-orchestrator.test.ts +0 -418
- package/tests/integration/feedback/feedback-loop-integration.test.ts +0 -560
- package/tests/integration/migration/v2-to-v3-migration.test.ts +0 -471
- package/tests/integration/parsers/typescript-parser.test.ts +0 -463
- package/tests/integration/security/vulnerability-detection.test.ts +0 -628
- package/tests/integration/test-execution/coordinator.test.ts +0 -410
- package/tests/integration/test-generation/coordinator.test.ts +0 -361
- package/tests/mocks/index.ts +0 -228
- package/tests/time-crystal/default-phases.test.ts +0 -476
- package/tests/time-crystal/oscillator.test.ts +0 -541
- package/tests/time-crystal/phase-executor.test.ts +0 -653
- package/tests/time-crystal/scheduler.test.ts +0 -626
- package/tests/time-crystal/test-runner.test.ts +0 -594
- package/tests/unit/causal-discovery/causal-graph.test.ts +0 -504
- package/tests/unit/causal-discovery/causal-root-cause-analyzer.test.ts +0 -347
- package/tests/unit/causal-discovery/discovery-engine.test.ts +0 -435
- package/tests/unit/causal-discovery/weight-matrix.test.ts +0 -328
- package/tests/unit/cli/cli.test.ts +0 -341
- package/tests/unit/cli/commands.test.ts +0 -414
- package/tests/unit/cli/init-command.test.ts +0 -274
- package/tests/unit/cli/migrate-command.test.ts +0 -396
- package/tests/unit/coordination/claims/claim-service.test.ts +0 -949
- package/tests/unit/coordination/claims/handoff-manager.test.ts +0 -773
- package/tests/unit/coordination/claims/work-stealing.test.ts +0 -492
- package/tests/unit/coordination/queen-coordinator.test.ts +0 -966
- package/tests/unit/coordination/result-saver.test.ts +0 -653
- package/tests/unit/coordination/task-executor.test.ts +0 -810
- package/tests/unit/domains/chaos-resilience/chaos-engineer.test.ts +0 -484
- package/tests/unit/domains/chaos-resilience/load-tester.test.ts +0 -559
- package/tests/unit/domains/chaos-resilience/performance-profiler.test.ts +0 -490
- package/tests/unit/domains/code-intelligence/impact-analyzer.test.ts +0 -560
- package/tests/unit/domains/code-intelligence/knowledge-graph.test.ts +0 -460
- package/tests/unit/domains/code-intelligence/semantic-analyzer.test.ts +0 -584
- package/tests/unit/domains/contract-testing/api-compatibility.test.ts +0 -483
- package/tests/unit/domains/contract-testing/contract-validator.test.ts +0 -370
- package/tests/unit/domains/contract-testing/schema-validator.test.ts +0 -610
- package/tests/unit/domains/coverage-analysis/coverage-embedder.test.ts +0 -298
- package/tests/unit/domains/coverage-analysis/hnsw-index.test.ts +0 -292
- package/tests/unit/domains/coverage-analysis/sublinear-analyzer.test.ts +0 -506
- package/tests/unit/domains/defect-intelligence/defect-predictor.test.ts +0 -370
- package/tests/unit/domains/defect-intelligence/pattern-learner.test.ts +0 -546
- package/tests/unit/domains/defect-intelligence/root-cause-analyzer.test.ts +0 -534
- package/tests/unit/domains/learning-optimization/learning-coordinator.test.ts +0 -541
- package/tests/unit/domains/learning-optimization/metrics-optimizer.test.ts +0 -552
- package/tests/unit/domains/learning-optimization/production-intel.test.ts +0 -589
- package/tests/unit/domains/learning-optimization/transfer-specialist.test.ts +0 -453
- package/tests/unit/domains/quality-assessment/coherence-gate.test.ts +0 -1006
- package/tests/unit/domains/quality-assessment/deployment-advisor.test.ts +0 -515
- package/tests/unit/domains/quality-assessment/quality-analyzer.test.ts +0 -401
- package/tests/unit/domains/quality-assessment/quality-gate.test.ts +0 -324
- package/tests/unit/domains/requirements-validation/bdd-scenario-writer.test.ts +0 -479
- package/tests/unit/domains/requirements-validation/requirements-validator.test.ts +0 -452
- package/tests/unit/domains/requirements-validation/testability-scorer.test.ts +0 -505
- package/tests/unit/domains/security-compliance/compliance-validator.test.ts +0 -500
- package/tests/unit/domains/security-compliance/security-auditor.test.ts +0 -498
- package/tests/unit/domains/security-compliance/security-scanner.test.ts +0 -412
- package/tests/unit/domains/visual-accessibility/accessibility-tester.test.ts +0 -432
- package/tests/unit/domains/visual-accessibility/responsive-tester.test.ts +0 -506
- package/tests/unit/domains/visual-accessibility/visual-tester.test.ts +0 -412
- package/tests/unit/early-exit/early-exit-controller.test.ts +0 -548
- package/tests/unit/early-exit/early-exit-decision.test.ts +0 -617
- package/tests/unit/early-exit/index.test.ts +0 -254
- package/tests/unit/early-exit/quality-signal.test.ts +0 -589
- package/tests/unit/early-exit/speculative-executor.test.ts +0 -453
- package/tests/unit/feedback/coverage-learner.test.ts +0 -288
- package/tests/unit/feedback/feedback-loop.test.ts +0 -458
- package/tests/unit/feedback/pattern-promotion.test.ts +0 -390
- package/tests/unit/feedback/quality-score-calculator.test.ts +0 -364
- package/tests/unit/feedback/test-outcome-tracker.test.ts +0 -243
- package/tests/unit/init/init-wizard.test.ts +0 -881
- package/tests/unit/init/project-analyzer.test.ts +0 -807
- package/tests/unit/init/self-configurator.test.ts +0 -493
- package/tests/unit/integrations/ruvector/ast-complexity.test.ts +0 -240
- package/tests/unit/integrations/ruvector/coverage-router.test.ts +0 -366
- package/tests/unit/integrations/ruvector/diff-risk-classifier.test.ts +0 -340
- package/tests/unit/integrations/ruvector/graph-boundaries.test.ts +0 -355
- package/tests/unit/integrations/ruvector/q-learning-router.test.ts +0 -314
- package/tests/unit/kernel/agent-coordinator.test.ts +0 -220
- package/tests/unit/kernel/event-bus.test.ts +0 -197
- package/tests/unit/learning/qe-reasoning-bank.test.ts +0 -666
- package/tests/unit/learning/real-qe-reasoning-bank.benchmark.test.ts +0 -415
- package/tests/unit/mcp/mcp-server.test.ts +0 -544
- package/tests/unit/mcp/metrics/metrics-collector.test.ts +0 -340
- package/tests/unit/mcp/security/cve-prevention.test.ts +0 -512
- package/tests/unit/mcp/security/oauth21-provider.test.ts +0 -624
- package/tests/unit/mcp/security/rate-limiter.test.ts +0 -410
- package/tests/unit/mcp/security/sampling-server.test.ts +0 -420
- package/tests/unit/mcp/security/schema-validator.test.ts +0 -494
- package/tests/unit/mcp/tools/base.test.ts +0 -336
- package/tests/unit/mcp/tools/domain-tools.test.ts +0 -759
- package/tests/unit/mcp/tools/registry.test.ts +0 -240
- package/tests/unit/neural-optimizer/replay-buffer.test.ts +0 -403
- package/tests/unit/neural-optimizer/swarm-topology.test.ts +0 -473
- package/tests/unit/neural-optimizer/topology-optimizer.test.ts +0 -595
- package/tests/unit/neural-optimizer/value-network.test.ts +0 -343
- package/tests/unit/optimization/auto-tuner.test.ts +0 -506
- package/tests/unit/optimization/metric-collectors.test.ts +0 -352
- package/tests/unit/optimization/qe-workers.test.ts +0 -407
- package/tests/unit/optimization/tuning-algorithm.test.ts +0 -467
- package/tests/unit/routing/qe-agent-registry.test.ts +0 -229
- package/tests/unit/routing/qe-task-router.test.ts +0 -390
- package/tests/unit/routing/routing-feedback.test.ts +0 -339
- package/tests/unit/shared/embeddings/nomic-embedder.test.ts +0 -419
- package/tests/unit/shared/http/http-client.test.ts +0 -719
- package/tests/unit/shared/io/file-reader.test.ts +0 -511
- package/tests/unit/shared/llm/cache.test.ts +0 -391
- package/tests/unit/shared/llm/circuit-breaker.test.ts +0 -293
- package/tests/unit/shared/llm/cost-tracker.test.ts +0 -431
- package/tests/unit/shared/llm/provider-manager.test.ts +0 -550
- package/tests/unit/shared/llm/providers.test.ts +0 -532
- package/tests/unit/shared/parsers/typescript-parser.test.ts +0 -693
- package/tests/unit/shared/value-objects.test.ts +0 -184
- package/tests/unit/strange-loop/strange-loop.test.ts +0 -1170
- package/tests/unit/workers/base-worker.test.ts +0 -341
- package/tests/unit/workers/daemon.test.ts +0 -291
- package/tests/unit/workers/worker-manager.test.ts +0 -284
- package/tsconfig.json +0 -32
- package/vitest.config.ts +0 -27
|
@@ -1,1181 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agentic QE v3 - Learning Consolidation Protocol
|
|
3
|
-
*
|
|
4
|
-
* Schedule: Friday 6pm (weekly)
|
|
5
|
-
* Participants: Learning Coordinator, Transfer Specialist, Pattern Learner
|
|
6
|
-
* Actions: Gather patterns, consolidate, update knowledge base
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
10
|
-
import {
|
|
11
|
-
Result,
|
|
12
|
-
ok,
|
|
13
|
-
err,
|
|
14
|
-
DomainName,
|
|
15
|
-
ALL_DOMAINS,
|
|
16
|
-
DomainEvent,
|
|
17
|
-
} from '../../shared/types/index.js';
|
|
18
|
-
import { TimeRange } from '../../shared/value-objects/index.js';
|
|
19
|
-
import { EventBus, MemoryBackend } from '../../kernel/interfaces.js';
|
|
20
|
-
import {
|
|
21
|
-
LearnedPattern,
|
|
22
|
-
PatternType,
|
|
23
|
-
Knowledge,
|
|
24
|
-
IPatternLearningService,
|
|
25
|
-
IKnowledgeSynthesisService,
|
|
26
|
-
} from '../../domains/learning-optimization/interfaces.js';
|
|
27
|
-
|
|
28
|
-
// ============================================================================
|
|
29
|
-
// Protocol Configuration
|
|
30
|
-
// ============================================================================
|
|
31
|
-
|
|
32
|
-
export interface LearningConsolidationConfig {
|
|
33
|
-
/** Minimum patterns per domain to trigger consolidation */
|
|
34
|
-
minPatternsForConsolidation: number;
|
|
35
|
-
/** Pattern similarity threshold for merging (0-1) */
|
|
36
|
-
similarityThreshold: number;
|
|
37
|
-
/** Maximum patterns to keep per domain after consolidation */
|
|
38
|
-
maxPatternsPerDomain: number;
|
|
39
|
-
/** Minimum confidence to retain pattern */
|
|
40
|
-
minConfidenceThreshold: number;
|
|
41
|
-
/** Number of weeks of data to analyze */
|
|
42
|
-
analysisWindowWeeks: number;
|
|
43
|
-
/** Enable cross-project transfer */
|
|
44
|
-
enableCrossProjectTransfer: boolean;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const DEFAULT_CONFIG: LearningConsolidationConfig = {
|
|
48
|
-
minPatternsForConsolidation: 5,
|
|
49
|
-
similarityThreshold: 0.85,
|
|
50
|
-
maxPatternsPerDomain: 100,
|
|
51
|
-
minConfidenceThreshold: 0.5,
|
|
52
|
-
analysisWindowWeeks: 4,
|
|
53
|
-
enableCrossProjectTransfer: true,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// ============================================================================
|
|
57
|
-
// Protocol Events
|
|
58
|
-
// ============================================================================
|
|
59
|
-
|
|
60
|
-
export interface LearningConsolidationStartedEvent extends DomainEvent {
|
|
61
|
-
readonly type: 'LearningConsolidationStarted';
|
|
62
|
-
readonly payload: {
|
|
63
|
-
consolidationId: string;
|
|
64
|
-
timestamp: Date;
|
|
65
|
-
domainsToProcess: DomainName[];
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface PatternConsolidatedEvent extends DomainEvent {
|
|
70
|
-
readonly type: 'PatternConsolidated';
|
|
71
|
-
readonly payload: {
|
|
72
|
-
consolidationId: string;
|
|
73
|
-
domain: DomainName;
|
|
74
|
-
patternsBeforeCount: number;
|
|
75
|
-
patternsAfterCount: number;
|
|
76
|
-
mergedPatternIds: string[];
|
|
77
|
-
removedPatternIds: string[];
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export interface LearningConsolidationCompletedEvent extends DomainEvent {
|
|
82
|
-
readonly type: 'LearningConsolidationCompleted';
|
|
83
|
-
readonly payload: {
|
|
84
|
-
consolidationId: string;
|
|
85
|
-
stats: ConsolidationStats;
|
|
86
|
-
insights: WeeklyInsight[];
|
|
87
|
-
duration: number;
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export interface TransferReadyEvent extends DomainEvent {
|
|
92
|
-
readonly type: 'TransferReady';
|
|
93
|
-
readonly payload: {
|
|
94
|
-
consolidationId: string;
|
|
95
|
-
transferablePatterns: TransferablePattern[];
|
|
96
|
-
targetProjects: string[];
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// ============================================================================
|
|
101
|
-
// Protocol Data Types
|
|
102
|
-
// ============================================================================
|
|
103
|
-
|
|
104
|
-
export interface DomainPatternGroup {
|
|
105
|
-
domain: DomainName;
|
|
106
|
-
patterns: LearnedPattern[];
|
|
107
|
-
stats: DomainPatternStats;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export interface DomainPatternStats {
|
|
111
|
-
totalPatterns: number;
|
|
112
|
-
avgConfidence: number;
|
|
113
|
-
avgSuccessRate: number;
|
|
114
|
-
avgUsageCount: number;
|
|
115
|
-
topPatternType: PatternType;
|
|
116
|
-
newPatternsThisWeek: number;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export interface ConsolidationStats {
|
|
120
|
-
domainsProcessed: number;
|
|
121
|
-
totalPatternsAnalyzed: number;
|
|
122
|
-
patternsMerged: number;
|
|
123
|
-
patternsRemoved: number;
|
|
124
|
-
patternsRetained: number;
|
|
125
|
-
knowledgeItemsUpdated: number;
|
|
126
|
-
improvementOpportunities: number;
|
|
127
|
-
crossDomainTransfers: number;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export interface WeeklyInsight {
|
|
131
|
-
type: 'improvement' | 'trend' | 'anomaly' | 'recommendation';
|
|
132
|
-
domain: DomainName;
|
|
133
|
-
title: string;
|
|
134
|
-
description: string;
|
|
135
|
-
impact: 'high' | 'medium' | 'low';
|
|
136
|
-
actionItems: string[];
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export interface TransferablePattern {
|
|
140
|
-
patternId: string;
|
|
141
|
-
domain: DomainName;
|
|
142
|
-
name: string;
|
|
143
|
-
applicableDomains: DomainName[];
|
|
144
|
-
transferConfidence: number;
|
|
145
|
-
reason: string;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export interface ConsolidationResult {
|
|
149
|
-
consolidationId: string;
|
|
150
|
-
startedAt: Date;
|
|
151
|
-
completedAt: Date;
|
|
152
|
-
stats: ConsolidationStats;
|
|
153
|
-
insights: WeeklyInsight[];
|
|
154
|
-
transferablePatterns: TransferablePattern[];
|
|
155
|
-
domainReports: DomainConsolidationReport[];
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export interface DomainConsolidationReport {
|
|
159
|
-
domain: DomainName;
|
|
160
|
-
patternsBeforeCount: number;
|
|
161
|
-
patternsAfterCount: number;
|
|
162
|
-
mergedPatterns: MergedPatternInfo[];
|
|
163
|
-
removedPatterns: RemovedPatternInfo[];
|
|
164
|
-
topPerformingPatterns: LearnedPattern[];
|
|
165
|
-
improvementAreas: string[];
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export interface MergedPatternInfo {
|
|
169
|
-
resultPatternId: string;
|
|
170
|
-
sourcePatternIds: string[];
|
|
171
|
-
mergeReason: string;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export interface RemovedPatternInfo {
|
|
175
|
-
patternId: string;
|
|
176
|
-
name: string;
|
|
177
|
-
removalReason: string;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// ============================================================================
|
|
181
|
-
// Learning Consolidation Protocol Implementation
|
|
182
|
-
// ============================================================================
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Learning Consolidation Protocol
|
|
186
|
-
*
|
|
187
|
-
* Orchestrates weekly learning consolidation across all QE domains.
|
|
188
|
-
* Gathers patterns, consolidates similar ones, removes underperformers,
|
|
189
|
-
* and prepares high-value patterns for cross-project transfer.
|
|
190
|
-
*/
|
|
191
|
-
export class LearningConsolidationProtocol {
|
|
192
|
-
private readonly config: LearningConsolidationConfig;
|
|
193
|
-
|
|
194
|
-
constructor(
|
|
195
|
-
private readonly eventBus: EventBus,
|
|
196
|
-
private readonly memory: MemoryBackend,
|
|
197
|
-
private readonly patternService: IPatternLearningService,
|
|
198
|
-
private readonly knowledgeService: IKnowledgeSynthesisService,
|
|
199
|
-
config: Partial<LearningConsolidationConfig> = {}
|
|
200
|
-
) {
|
|
201
|
-
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// ============================================================================
|
|
205
|
-
// Main Execution
|
|
206
|
-
// ============================================================================
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Execute the weekly learning consolidation protocol
|
|
210
|
-
*/
|
|
211
|
-
async execute(): Promise<Result<ConsolidationResult>> {
|
|
212
|
-
const consolidationId = uuidv4();
|
|
213
|
-
const startedAt = new Date();
|
|
214
|
-
|
|
215
|
-
try {
|
|
216
|
-
// Publish start event
|
|
217
|
-
await this.publishStartEvent(consolidationId);
|
|
218
|
-
|
|
219
|
-
// Step 1: Gather patterns from all domains
|
|
220
|
-
const gatheredPatterns = await this.gatherPatterns();
|
|
221
|
-
if (!gatheredPatterns.success) {
|
|
222
|
-
return err(gatheredPatterns.error);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
// Step 2: Consolidate patterns per domain
|
|
226
|
-
const domainReports: DomainConsolidationReport[] = [];
|
|
227
|
-
let totalMerged = 0;
|
|
228
|
-
let totalRemoved = 0;
|
|
229
|
-
let totalRetained = 0;
|
|
230
|
-
|
|
231
|
-
for (const domainGroup of gatheredPatterns.value) {
|
|
232
|
-
const consolidationResult = await this.consolidatePatterns(
|
|
233
|
-
consolidationId,
|
|
234
|
-
domainGroup
|
|
235
|
-
);
|
|
236
|
-
if (consolidationResult.success) {
|
|
237
|
-
domainReports.push(consolidationResult.value);
|
|
238
|
-
totalMerged += consolidationResult.value.mergedPatterns.length;
|
|
239
|
-
totalRemoved += consolidationResult.value.removedPatterns.length;
|
|
240
|
-
totalRetained += consolidationResult.value.patternsAfterCount;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// Step 3: Update knowledge base with consolidated patterns
|
|
245
|
-
const knowledgeUpdateResult = await this.updateKnowledgeBase(domainReports);
|
|
246
|
-
|
|
247
|
-
// Step 4: Prepare patterns for cross-project transfer
|
|
248
|
-
const transferResult = await this.prepareTransfer(
|
|
249
|
-
consolidationId,
|
|
250
|
-
domainReports
|
|
251
|
-
);
|
|
252
|
-
|
|
253
|
-
// Step 5: Generate weekly insights
|
|
254
|
-
const insights = await this.generateInsights(
|
|
255
|
-
gatheredPatterns.value,
|
|
256
|
-
domainReports
|
|
257
|
-
);
|
|
258
|
-
|
|
259
|
-
const completedAt = new Date();
|
|
260
|
-
const duration = completedAt.getTime() - startedAt.getTime();
|
|
261
|
-
|
|
262
|
-
const stats: ConsolidationStats = {
|
|
263
|
-
domainsProcessed: domainReports.length,
|
|
264
|
-
totalPatternsAnalyzed: gatheredPatterns.value.reduce(
|
|
265
|
-
(sum, g) => sum + g.patterns.length,
|
|
266
|
-
0
|
|
267
|
-
),
|
|
268
|
-
patternsMerged: totalMerged,
|
|
269
|
-
patternsRemoved: totalRemoved,
|
|
270
|
-
patternsRetained: totalRetained,
|
|
271
|
-
knowledgeItemsUpdated: knowledgeUpdateResult.success
|
|
272
|
-
? knowledgeUpdateResult.value
|
|
273
|
-
: 0,
|
|
274
|
-
improvementOpportunities: insights.filter(
|
|
275
|
-
(i) => i.type === 'improvement'
|
|
276
|
-
).length,
|
|
277
|
-
crossDomainTransfers: transferResult.success
|
|
278
|
-
? transferResult.value.length
|
|
279
|
-
: 0,
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
// Publish completion event
|
|
283
|
-
await this.publishCompletedEvent(consolidationId, stats, insights, duration);
|
|
284
|
-
|
|
285
|
-
const result: ConsolidationResult = {
|
|
286
|
-
consolidationId,
|
|
287
|
-
startedAt,
|
|
288
|
-
completedAt,
|
|
289
|
-
stats,
|
|
290
|
-
insights,
|
|
291
|
-
transferablePatterns: transferResult.success ? transferResult.value : [],
|
|
292
|
-
domainReports,
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
// Store result for historical analysis
|
|
296
|
-
await this.storeConsolidationResult(result);
|
|
297
|
-
|
|
298
|
-
return ok(result);
|
|
299
|
-
} catch (error) {
|
|
300
|
-
return err(error instanceof Error ? error : new Error(String(error)));
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// ============================================================================
|
|
305
|
-
// Pattern Gathering
|
|
306
|
-
// ============================================================================
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Gather patterns from all 12 domains
|
|
310
|
-
*/
|
|
311
|
-
async gatherPatterns(): Promise<Result<DomainPatternGroup[]>> {
|
|
312
|
-
try {
|
|
313
|
-
const domainGroups: DomainPatternGroup[] = [];
|
|
314
|
-
const timeRange = TimeRange.lastNDays(this.config.analysisWindowWeeks * 7);
|
|
315
|
-
|
|
316
|
-
for (const domain of ALL_DOMAINS) {
|
|
317
|
-
const patterns = await this.getPatternsForDomain(domain, timeRange);
|
|
318
|
-
if (patterns.length > 0) {
|
|
319
|
-
const stats = this.calculateDomainStats(patterns, timeRange);
|
|
320
|
-
domainGroups.push({ domain, patterns, stats });
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
return ok(domainGroups);
|
|
325
|
-
} catch (error) {
|
|
326
|
-
return err(error instanceof Error ? error : new Error(String(error)));
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Get patterns for a specific domain
|
|
332
|
-
*/
|
|
333
|
-
private async getPatternsForDomain(
|
|
334
|
-
domain: DomainName,
|
|
335
|
-
timeRange: TimeRange
|
|
336
|
-
): Promise<LearnedPattern[]> {
|
|
337
|
-
const keys = await this.memory.search(`learning:pattern:*`, 500);
|
|
338
|
-
const patterns: LearnedPattern[] = [];
|
|
339
|
-
|
|
340
|
-
for (const key of keys) {
|
|
341
|
-
const pattern = await this.memory.get<LearnedPattern>(key);
|
|
342
|
-
if (
|
|
343
|
-
pattern &&
|
|
344
|
-
pattern.domain === domain &&
|
|
345
|
-
!key.includes(':archived:') &&
|
|
346
|
-
(timeRange.contains(pattern.createdAt) || timeRange.contains(pattern.lastUsedAt))
|
|
347
|
-
) {
|
|
348
|
-
patterns.push(pattern);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
return patterns;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* Calculate statistics for a domain's patterns
|
|
357
|
-
*/
|
|
358
|
-
private calculateDomainStats(
|
|
359
|
-
patterns: LearnedPattern[],
|
|
360
|
-
timeRange: TimeRange
|
|
361
|
-
): DomainPatternStats {
|
|
362
|
-
if (patterns.length === 0) {
|
|
363
|
-
return {
|
|
364
|
-
totalPatterns: 0,
|
|
365
|
-
avgConfidence: 0,
|
|
366
|
-
avgSuccessRate: 0,
|
|
367
|
-
avgUsageCount: 0,
|
|
368
|
-
topPatternType: 'workflow-pattern',
|
|
369
|
-
newPatternsThisWeek: 0,
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
const typeCounts: Map<PatternType, number> = new Map();
|
|
374
|
-
let totalConfidence = 0;
|
|
375
|
-
let totalSuccessRate = 0;
|
|
376
|
-
let totalUsageCount = 0;
|
|
377
|
-
let newPatterns = 0;
|
|
378
|
-
|
|
379
|
-
for (const pattern of patterns) {
|
|
380
|
-
totalConfidence += pattern.confidence;
|
|
381
|
-
totalSuccessRate += pattern.successRate;
|
|
382
|
-
totalUsageCount += pattern.usageCount;
|
|
383
|
-
typeCounts.set(pattern.type, (typeCounts.get(pattern.type) || 0) + 1);
|
|
384
|
-
|
|
385
|
-
if (timeRange.contains(pattern.createdAt)) {
|
|
386
|
-
newPatterns++;
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
let topType: PatternType = 'workflow-pattern';
|
|
391
|
-
let maxCount = 0;
|
|
392
|
-
for (const [type, count] of typeCounts) {
|
|
393
|
-
if (count > maxCount) {
|
|
394
|
-
maxCount = count;
|
|
395
|
-
topType = type;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
return {
|
|
400
|
-
totalPatterns: patterns.length,
|
|
401
|
-
avgConfidence: totalConfidence / patterns.length,
|
|
402
|
-
avgSuccessRate: totalSuccessRate / patterns.length,
|
|
403
|
-
avgUsageCount: totalUsageCount / patterns.length,
|
|
404
|
-
topPatternType: topType,
|
|
405
|
-
newPatternsThisWeek: newPatterns,
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
// ============================================================================
|
|
410
|
-
// Pattern Consolidation
|
|
411
|
-
// ============================================================================
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Consolidate patterns within a domain - merge similar, remove underperformers
|
|
415
|
-
*/
|
|
416
|
-
async consolidatePatterns(
|
|
417
|
-
consolidationId: string,
|
|
418
|
-
domainGroup: DomainPatternGroup
|
|
419
|
-
): Promise<Result<DomainConsolidationReport>> {
|
|
420
|
-
try {
|
|
421
|
-
const { domain, patterns } = domainGroup;
|
|
422
|
-
const mergedPatterns: MergedPatternInfo[] = [];
|
|
423
|
-
const removedPatterns: RemovedPatternInfo[] = [];
|
|
424
|
-
const retainedPatterns: LearnedPattern[] = [];
|
|
425
|
-
|
|
426
|
-
// Group similar patterns for merging
|
|
427
|
-
const similarGroups = this.groupSimilarPatterns(patterns);
|
|
428
|
-
|
|
429
|
-
for (const group of similarGroups) {
|
|
430
|
-
if (group.length >= 2) {
|
|
431
|
-
// Merge similar patterns
|
|
432
|
-
const mergeResult = await this.mergePatternGroup(group);
|
|
433
|
-
if (mergeResult.success) {
|
|
434
|
-
mergedPatterns.push({
|
|
435
|
-
resultPatternId: mergeResult.value.id,
|
|
436
|
-
sourcePatternIds: group.map((p) => p.id),
|
|
437
|
-
mergeReason: 'Similar pattern context and template',
|
|
438
|
-
});
|
|
439
|
-
retainedPatterns.push(mergeResult.value);
|
|
440
|
-
}
|
|
441
|
-
} else {
|
|
442
|
-
// Single pattern - check if it should be retained
|
|
443
|
-
const pattern = group[0];
|
|
444
|
-
if (this.shouldRetainPattern(pattern)) {
|
|
445
|
-
retainedPatterns.push(pattern);
|
|
446
|
-
} else {
|
|
447
|
-
removedPatterns.push({
|
|
448
|
-
patternId: pattern.id,
|
|
449
|
-
name: pattern.name,
|
|
450
|
-
removalReason: this.getRemovalReason(pattern),
|
|
451
|
-
});
|
|
452
|
-
await this.archivePattern(pattern);
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
// Trim to max patterns if needed
|
|
458
|
-
const finalPatterns = this.trimToMaxPatterns(retainedPatterns, domain);
|
|
459
|
-
const trimmedCount = retainedPatterns.length - finalPatterns.length;
|
|
460
|
-
if (trimmedCount > 0) {
|
|
461
|
-
const trimmed = retainedPatterns.slice(finalPatterns.length);
|
|
462
|
-
for (const p of trimmed) {
|
|
463
|
-
removedPatterns.push({
|
|
464
|
-
patternId: p.id,
|
|
465
|
-
name: p.name,
|
|
466
|
-
removalReason: 'Exceeded max patterns per domain limit',
|
|
467
|
-
});
|
|
468
|
-
await this.archivePattern(p);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
// Publish domain consolidation event
|
|
473
|
-
await this.publishPatternConsolidatedEvent(
|
|
474
|
-
consolidationId,
|
|
475
|
-
domain,
|
|
476
|
-
patterns.length,
|
|
477
|
-
finalPatterns.length,
|
|
478
|
-
mergedPatterns.map((m) => m.resultPatternId),
|
|
479
|
-
removedPatterns.map((r) => r.patternId)
|
|
480
|
-
);
|
|
481
|
-
|
|
482
|
-
const report: DomainConsolidationReport = {
|
|
483
|
-
domain,
|
|
484
|
-
patternsBeforeCount: patterns.length,
|
|
485
|
-
patternsAfterCount: finalPatterns.length,
|
|
486
|
-
mergedPatterns,
|
|
487
|
-
removedPatterns,
|
|
488
|
-
topPerformingPatterns: this.getTopPerformingPatterns(finalPatterns, 5),
|
|
489
|
-
improvementAreas: this.identifyImprovementAreas(domainGroup),
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
return ok(report);
|
|
493
|
-
} catch (error) {
|
|
494
|
-
return err(error instanceof Error ? error : new Error(String(error)));
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
/**
|
|
499
|
-
* Group patterns by similarity
|
|
500
|
-
*/
|
|
501
|
-
private groupSimilarPatterns(patterns: LearnedPattern[]): LearnedPattern[][] {
|
|
502
|
-
const groups: LearnedPattern[][] = [];
|
|
503
|
-
const assigned = new Set<string>();
|
|
504
|
-
|
|
505
|
-
for (const pattern of patterns) {
|
|
506
|
-
if (assigned.has(pattern.id)) continue;
|
|
507
|
-
|
|
508
|
-
const group: LearnedPattern[] = [pattern];
|
|
509
|
-
assigned.add(pattern.id);
|
|
510
|
-
|
|
511
|
-
for (const other of patterns) {
|
|
512
|
-
if (assigned.has(other.id)) continue;
|
|
513
|
-
|
|
514
|
-
if (this.areSimilarPatterns(pattern, other)) {
|
|
515
|
-
group.push(other);
|
|
516
|
-
assigned.add(other.id);
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
groups.push(group);
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
return groups;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
/**
|
|
527
|
-
* Check if two patterns are similar enough to merge
|
|
528
|
-
*/
|
|
529
|
-
private areSimilarPatterns(a: LearnedPattern, b: LearnedPattern): boolean {
|
|
530
|
-
// Same type required
|
|
531
|
-
if (a.type !== b.type) return false;
|
|
532
|
-
|
|
533
|
-
// Check context similarity
|
|
534
|
-
const contextSimilarity = this.calculateContextSimilarity(a.context, b.context);
|
|
535
|
-
if (contextSimilarity < this.config.similarityThreshold) return false;
|
|
536
|
-
|
|
537
|
-
// Check template type
|
|
538
|
-
if (a.template.type !== b.template.type) return false;
|
|
539
|
-
|
|
540
|
-
return true;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
/**
|
|
544
|
-
* Calculate similarity between two pattern contexts
|
|
545
|
-
*/
|
|
546
|
-
private calculateContextSimilarity(
|
|
547
|
-
a: { language?: string; framework?: string; testType?: string; tags: string[] },
|
|
548
|
-
b: { language?: string; framework?: string; testType?: string; tags: string[] }
|
|
549
|
-
): number {
|
|
550
|
-
let score = 0;
|
|
551
|
-
let factors = 0;
|
|
552
|
-
|
|
553
|
-
// Language match
|
|
554
|
-
if (a.language && b.language) {
|
|
555
|
-
factors++;
|
|
556
|
-
if (a.language === b.language) score++;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
// Framework match
|
|
560
|
-
if (a.framework && b.framework) {
|
|
561
|
-
factors++;
|
|
562
|
-
if (a.framework === b.framework) score++;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
// Test type match
|
|
566
|
-
if (a.testType && b.testType) {
|
|
567
|
-
factors++;
|
|
568
|
-
if (a.testType === b.testType) score++;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
// Tag overlap
|
|
572
|
-
if (a.tags.length > 0 && b.tags.length > 0) {
|
|
573
|
-
factors++;
|
|
574
|
-
const overlap = a.tags.filter((t) => b.tags.includes(t)).length;
|
|
575
|
-
const union = new Set([...a.tags, ...b.tags]).size;
|
|
576
|
-
score += overlap / union;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
return factors > 0 ? score / factors : 0;
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
/**
|
|
583
|
-
* Merge a group of similar patterns into one
|
|
584
|
-
*/
|
|
585
|
-
private async mergePatternGroup(
|
|
586
|
-
group: LearnedPattern[]
|
|
587
|
-
): Promise<Result<LearnedPattern>> {
|
|
588
|
-
const patternIds = group.map((p) => p.id);
|
|
589
|
-
return this.patternService.consolidatePatterns(patternIds);
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
/**
|
|
593
|
-
* Check if a pattern should be retained
|
|
594
|
-
*/
|
|
595
|
-
private shouldRetainPattern(pattern: LearnedPattern): boolean {
|
|
596
|
-
// Remove low confidence patterns
|
|
597
|
-
if (pattern.confidence < this.config.minConfidenceThreshold) {
|
|
598
|
-
return false;
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
// Remove patterns with poor success rate and low usage
|
|
602
|
-
if (pattern.successRate < 0.3 && pattern.usageCount < 5) {
|
|
603
|
-
return false;
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
// Check for staleness (not used in 30 days)
|
|
607
|
-
const daysSinceLastUse =
|
|
608
|
-
(Date.now() - pattern.lastUsedAt.getTime()) / (1000 * 60 * 60 * 24);
|
|
609
|
-
if (daysSinceLastUse > 30 && pattern.usageCount < 10) {
|
|
610
|
-
return false;
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
return true;
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
/**
|
|
617
|
-
* Get reason for pattern removal
|
|
618
|
-
*/
|
|
619
|
-
private getRemovalReason(pattern: LearnedPattern): string {
|
|
620
|
-
if (pattern.confidence < this.config.minConfidenceThreshold) {
|
|
621
|
-
return `Low confidence (${(pattern.confidence * 100).toFixed(1)}%)`;
|
|
622
|
-
}
|
|
623
|
-
if (pattern.successRate < 0.3) {
|
|
624
|
-
return `Low success rate (${(pattern.successRate * 100).toFixed(1)}%)`;
|
|
625
|
-
}
|
|
626
|
-
const daysSinceLastUse =
|
|
627
|
-
(Date.now() - pattern.lastUsedAt.getTime()) / (1000 * 60 * 60 * 24);
|
|
628
|
-
if (daysSinceLastUse > 30) {
|
|
629
|
-
return `Stale - not used in ${Math.round(daysSinceLastUse)} days`;
|
|
630
|
-
}
|
|
631
|
-
return 'Below retention threshold';
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
/**
|
|
635
|
-
* Archive a pattern (soft delete)
|
|
636
|
-
*/
|
|
637
|
-
private async archivePattern(pattern: LearnedPattern): Promise<void> {
|
|
638
|
-
// Move to archived namespace
|
|
639
|
-
await this.memory.set(`learning:pattern:archived:${pattern.id}`, {
|
|
640
|
-
...pattern,
|
|
641
|
-
archivedAt: new Date(),
|
|
642
|
-
}, { namespace: 'learning-optimization', persist: true });
|
|
643
|
-
|
|
644
|
-
// Delete from active patterns
|
|
645
|
-
await this.memory.delete(`learning:pattern:${pattern.id}`);
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
/**
|
|
649
|
-
* Trim patterns to max allowed per domain
|
|
650
|
-
*/
|
|
651
|
-
private trimToMaxPatterns(
|
|
652
|
-
patterns: LearnedPattern[],
|
|
653
|
-
_domain: DomainName
|
|
654
|
-
): LearnedPattern[] {
|
|
655
|
-
if (patterns.length <= this.config.maxPatternsPerDomain) {
|
|
656
|
-
return patterns;
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
// Sort by effectiveness score and keep top N
|
|
660
|
-
return patterns
|
|
661
|
-
.sort((a, b) => {
|
|
662
|
-
const scoreA = a.confidence * 0.4 + a.successRate * 0.4 + Math.min(a.usageCount / 100, 0.2);
|
|
663
|
-
const scoreB = b.confidence * 0.4 + b.successRate * 0.4 + Math.min(b.usageCount / 100, 0.2);
|
|
664
|
-
return scoreB - scoreA;
|
|
665
|
-
})
|
|
666
|
-
.slice(0, this.config.maxPatternsPerDomain);
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
/**
|
|
670
|
-
* Get top performing patterns
|
|
671
|
-
*/
|
|
672
|
-
private getTopPerformingPatterns(
|
|
673
|
-
patterns: LearnedPattern[],
|
|
674
|
-
count: number
|
|
675
|
-
): LearnedPattern[] {
|
|
676
|
-
return patterns
|
|
677
|
-
.sort((a, b) => {
|
|
678
|
-
const scoreA = a.successRate * 0.6 + a.confidence * 0.4;
|
|
679
|
-
const scoreB = b.successRate * 0.6 + b.confidence * 0.4;
|
|
680
|
-
return scoreB - scoreA;
|
|
681
|
-
})
|
|
682
|
-
.slice(0, count);
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
/**
|
|
686
|
-
* Identify improvement areas for a domain
|
|
687
|
-
*/
|
|
688
|
-
private identifyImprovementAreas(group: DomainPatternGroup): string[] {
|
|
689
|
-
const areas: string[] = [];
|
|
690
|
-
const { stats } = group;
|
|
691
|
-
|
|
692
|
-
if (stats.avgSuccessRate < 0.7) {
|
|
693
|
-
areas.push(`Improve pattern success rate (currently ${(stats.avgSuccessRate * 100).toFixed(1)}%)`);
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
if (stats.avgConfidence < 0.6) {
|
|
697
|
-
areas.push(`Increase pattern confidence through more training data`);
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
if (stats.newPatternsThisWeek === 0) {
|
|
701
|
-
areas.push(`No new patterns learned this week - consider gathering more experiences`);
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
if (stats.avgUsageCount < 5) {
|
|
705
|
-
areas.push(`Low pattern utilization - promote pattern adoption`);
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
return areas;
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
// ============================================================================
|
|
712
|
-
// Knowledge Base Update
|
|
713
|
-
// ============================================================================
|
|
714
|
-
|
|
715
|
-
/**
|
|
716
|
-
* Update knowledge base with consolidated patterns
|
|
717
|
-
*/
|
|
718
|
-
async updateKnowledgeBase(
|
|
719
|
-
domainReports: DomainConsolidationReport[]
|
|
720
|
-
): Promise<Result<number>> {
|
|
721
|
-
try {
|
|
722
|
-
let updatedCount = 0;
|
|
723
|
-
|
|
724
|
-
for (const report of domainReports) {
|
|
725
|
-
// Create knowledge entries for top performing patterns
|
|
726
|
-
for (const pattern of report.topPerformingPatterns) {
|
|
727
|
-
const knowledgeResult = await this.createKnowledgeFromPattern(pattern);
|
|
728
|
-
if (knowledgeResult.success) {
|
|
729
|
-
updatedCount++;
|
|
730
|
-
|
|
731
|
-
// Share high-performing pattern knowledge with related domains
|
|
732
|
-
if (pattern.successRate >= 0.8) {
|
|
733
|
-
const knowledge = await this.memory.get<Knowledge>(
|
|
734
|
-
`learning:knowledge:pattern:${pattern.id}`
|
|
735
|
-
);
|
|
736
|
-
if (knowledge) {
|
|
737
|
-
// Use knowledgeService to share across domains
|
|
738
|
-
await this.knowledgeService.shareKnowledge(knowledge, [
|
|
739
|
-
{
|
|
740
|
-
value: `${pattern.domain}-coordinator`,
|
|
741
|
-
domain: pattern.domain,
|
|
742
|
-
type: 'coordinator',
|
|
743
|
-
},
|
|
744
|
-
]);
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
// Store consolidation summary as knowledge
|
|
751
|
-
await this.storeConsolidationSummary(report);
|
|
752
|
-
updatedCount++;
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
return ok(updatedCount);
|
|
756
|
-
} catch (error) {
|
|
757
|
-
return err(error instanceof Error ? error : new Error(String(error)));
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
/**
|
|
762
|
-
* Create a knowledge entry from a high-performing pattern
|
|
763
|
-
*/
|
|
764
|
-
private async createKnowledgeFromPattern(
|
|
765
|
-
pattern: LearnedPattern
|
|
766
|
-
): Promise<Result<void>> {
|
|
767
|
-
const knowledge: Knowledge = {
|
|
768
|
-
id: uuidv4(),
|
|
769
|
-
type: 'heuristic',
|
|
770
|
-
domain: pattern.domain,
|
|
771
|
-
content: {
|
|
772
|
-
format: 'json',
|
|
773
|
-
data: {
|
|
774
|
-
patternId: pattern.id,
|
|
775
|
-
patternType: pattern.type,
|
|
776
|
-
template: pattern.template,
|
|
777
|
-
context: pattern.context,
|
|
778
|
-
effectiveness: {
|
|
779
|
-
confidence: pattern.confidence,
|
|
780
|
-
successRate: pattern.successRate,
|
|
781
|
-
usageCount: pattern.usageCount,
|
|
782
|
-
},
|
|
783
|
-
},
|
|
784
|
-
metadata: {
|
|
785
|
-
sourceType: 'pattern-consolidation',
|
|
786
|
-
consolidatedAt: new Date().toISOString(),
|
|
787
|
-
},
|
|
788
|
-
},
|
|
789
|
-
sourceAgentId: {
|
|
790
|
-
value: 'learning-consolidation-protocol',
|
|
791
|
-
domain: 'learning-optimization',
|
|
792
|
-
type: 'coordinator',
|
|
793
|
-
},
|
|
794
|
-
targetDomains: [pattern.domain],
|
|
795
|
-
relevanceScore: pattern.confidence * 0.5 + pattern.successRate * 0.5,
|
|
796
|
-
version: 1,
|
|
797
|
-
createdAt: new Date(),
|
|
798
|
-
};
|
|
799
|
-
|
|
800
|
-
await this.memory.set(`learning:knowledge:pattern:${pattern.id}`, knowledge, {
|
|
801
|
-
namespace: 'learning-optimization',
|
|
802
|
-
persist: true,
|
|
803
|
-
});
|
|
804
|
-
|
|
805
|
-
return ok(undefined);
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
/**
|
|
809
|
-
* Store consolidation summary as knowledge
|
|
810
|
-
*/
|
|
811
|
-
private async storeConsolidationSummary(
|
|
812
|
-
report: DomainConsolidationReport
|
|
813
|
-
): Promise<void> {
|
|
814
|
-
await this.memory.set(
|
|
815
|
-
`learning:consolidation:summary:${report.domain}:${Date.now()}`,
|
|
816
|
-
{
|
|
817
|
-
domain: report.domain,
|
|
818
|
-
date: new Date(),
|
|
819
|
-
patternsBefore: report.patternsBeforeCount,
|
|
820
|
-
patternsAfter: report.patternsAfterCount,
|
|
821
|
-
mergedCount: report.mergedPatterns.length,
|
|
822
|
-
removedCount: report.removedPatterns.length,
|
|
823
|
-
improvementAreas: report.improvementAreas,
|
|
824
|
-
},
|
|
825
|
-
{ namespace: 'learning-optimization', persist: true }
|
|
826
|
-
);
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
// ============================================================================
|
|
830
|
-
// Cross-Project Transfer
|
|
831
|
-
// ============================================================================
|
|
832
|
-
|
|
833
|
-
/**
|
|
834
|
-
* Prepare high-value patterns for cross-project transfer
|
|
835
|
-
*/
|
|
836
|
-
async prepareTransfer(
|
|
837
|
-
consolidationId: string,
|
|
838
|
-
domainReports: DomainConsolidationReport[]
|
|
839
|
-
): Promise<Result<TransferablePattern[]>> {
|
|
840
|
-
try {
|
|
841
|
-
if (!this.config.enableCrossProjectTransfer) {
|
|
842
|
-
return ok([]);
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
const transferablePatterns: TransferablePattern[] = [];
|
|
846
|
-
|
|
847
|
-
for (const report of domainReports) {
|
|
848
|
-
for (const pattern of report.topPerformingPatterns) {
|
|
849
|
-
// Only transfer highly effective patterns
|
|
850
|
-
if (pattern.successRate >= 0.8 && pattern.confidence >= 0.7) {
|
|
851
|
-
const applicableDomains = this.findApplicableDomains(pattern);
|
|
852
|
-
if (applicableDomains.length > 1) {
|
|
853
|
-
transferablePatterns.push({
|
|
854
|
-
patternId: pattern.id,
|
|
855
|
-
domain: pattern.domain,
|
|
856
|
-
name: pattern.name,
|
|
857
|
-
applicableDomains,
|
|
858
|
-
transferConfidence: Math.min(pattern.successRate, pattern.confidence),
|
|
859
|
-
reason: `High success rate (${(pattern.successRate * 100).toFixed(0)}%) with ${pattern.usageCount} uses`,
|
|
860
|
-
});
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
// Publish transfer ready event if we have patterns to transfer
|
|
867
|
-
if (transferablePatterns.length > 0) {
|
|
868
|
-
await this.publishTransferReadyEvent(consolidationId, transferablePatterns);
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
return ok(transferablePatterns);
|
|
872
|
-
} catch (error) {
|
|
873
|
-
return err(error instanceof Error ? error : new Error(String(error)));
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
/**
|
|
878
|
-
* Find domains where a pattern could be applicable
|
|
879
|
-
*/
|
|
880
|
-
private findApplicableDomains(pattern: LearnedPattern): DomainName[] {
|
|
881
|
-
const relatedDomains: Record<DomainName, DomainName[]> = {
|
|
882
|
-
'test-generation': ['test-execution', 'coverage-analysis'],
|
|
883
|
-
'test-execution': ['test-generation', 'coverage-analysis', 'quality-assessment'],
|
|
884
|
-
'coverage-analysis': ['test-generation', 'test-execution', 'quality-assessment'],
|
|
885
|
-
'quality-assessment': ['test-execution', 'coverage-analysis', 'defect-intelligence'],
|
|
886
|
-
'defect-intelligence': ['quality-assessment', 'code-intelligence'],
|
|
887
|
-
'requirements-validation': ['test-generation', 'quality-assessment'],
|
|
888
|
-
'code-intelligence': ['defect-intelligence', 'security-compliance'],
|
|
889
|
-
'security-compliance': ['code-intelligence', 'quality-assessment'],
|
|
890
|
-
'contract-testing': ['test-generation', 'test-execution'],
|
|
891
|
-
'visual-accessibility': ['quality-assessment'],
|
|
892
|
-
'chaos-resilience': ['test-execution', 'quality-assessment'],
|
|
893
|
-
'learning-optimization': ALL_DOMAINS.filter((d) => d !== 'learning-optimization'),
|
|
894
|
-
};
|
|
895
|
-
|
|
896
|
-
return [pattern.domain, ...(relatedDomains[pattern.domain] || [])];
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
// ============================================================================
|
|
900
|
-
// Insight Generation
|
|
901
|
-
// ============================================================================
|
|
902
|
-
|
|
903
|
-
/**
|
|
904
|
-
* Generate weekly learning report with insights
|
|
905
|
-
*/
|
|
906
|
-
async generateInsights(
|
|
907
|
-
gatheredPatterns: DomainPatternGroup[],
|
|
908
|
-
domainReports: DomainConsolidationReport[]
|
|
909
|
-
): Promise<WeeklyInsight[]> {
|
|
910
|
-
const insights: WeeklyInsight[] = [];
|
|
911
|
-
|
|
912
|
-
// Analyze each domain
|
|
913
|
-
for (const group of gatheredPatterns) {
|
|
914
|
-
const report = domainReports.find((r) => r.domain === group.domain);
|
|
915
|
-
|
|
916
|
-
// Check for significant pattern growth
|
|
917
|
-
if (group.stats.newPatternsThisWeek > 5) {
|
|
918
|
-
insights.push({
|
|
919
|
-
type: 'trend',
|
|
920
|
-
domain: group.domain,
|
|
921
|
-
title: `High pattern learning activity in ${group.domain}`,
|
|
922
|
-
description: `${group.stats.newPatternsThisWeek} new patterns learned this week`,
|
|
923
|
-
impact: 'medium',
|
|
924
|
-
actionItems: ['Review new patterns for quality', 'Monitor success rates'],
|
|
925
|
-
});
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
// Check for declining success rates
|
|
929
|
-
if (group.stats.avgSuccessRate < 0.5) {
|
|
930
|
-
insights.push({
|
|
931
|
-
type: 'anomaly',
|
|
932
|
-
domain: group.domain,
|
|
933
|
-
title: `Low average success rate in ${group.domain}`,
|
|
934
|
-
description: `Average success rate is ${(group.stats.avgSuccessRate * 100).toFixed(1)}%`,
|
|
935
|
-
impact: 'high',
|
|
936
|
-
actionItems: [
|
|
937
|
-
'Review pattern selection criteria',
|
|
938
|
-
'Gather more training experiences',
|
|
939
|
-
'Consider retiring low-performing patterns',
|
|
940
|
-
],
|
|
941
|
-
});
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
// Identify improvement opportunities
|
|
945
|
-
if (report && report.improvementAreas.length > 0) {
|
|
946
|
-
insights.push({
|
|
947
|
-
type: 'improvement',
|
|
948
|
-
domain: group.domain,
|
|
949
|
-
title: `Improvement opportunities in ${group.domain}`,
|
|
950
|
-
description: `${report.improvementAreas.length} areas identified for improvement`,
|
|
951
|
-
impact: 'medium',
|
|
952
|
-
actionItems: report.improvementAreas,
|
|
953
|
-
});
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
// Recommend consolidation if many patterns
|
|
957
|
-
if (group.patterns.length > this.config.maxPatternsPerDomain * 0.8) {
|
|
958
|
-
insights.push({
|
|
959
|
-
type: 'recommendation',
|
|
960
|
-
domain: group.domain,
|
|
961
|
-
title: `Pattern count nearing limit in ${group.domain}`,
|
|
962
|
-
description: `${group.patterns.length} patterns (limit: ${this.config.maxPatternsPerDomain})`,
|
|
963
|
-
impact: 'low',
|
|
964
|
-
actionItems: [
|
|
965
|
-
'Review pattern effectiveness',
|
|
966
|
-
'Consider more aggressive consolidation',
|
|
967
|
-
],
|
|
968
|
-
});
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
// Cross-domain insights
|
|
973
|
-
const topDomains = gatheredPatterns
|
|
974
|
-
.sort((a, b) => b.stats.avgSuccessRate - a.stats.avgSuccessRate)
|
|
975
|
-
.slice(0, 3);
|
|
976
|
-
|
|
977
|
-
if (topDomains.length > 0) {
|
|
978
|
-
insights.push({
|
|
979
|
-
type: 'trend',
|
|
980
|
-
domain: topDomains[0].domain,
|
|
981
|
-
title: 'Top performing domains',
|
|
982
|
-
description: `Best success rates: ${topDomains.map((d) => `${d.domain} (${(d.stats.avgSuccessRate * 100).toFixed(0)}%)`).join(', ')}`,
|
|
983
|
-
impact: 'medium',
|
|
984
|
-
actionItems: ['Analyze successful patterns for cross-domain application'],
|
|
985
|
-
});
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
return insights;
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
// ============================================================================
|
|
992
|
-
// Event Publishing
|
|
993
|
-
// ============================================================================
|
|
994
|
-
|
|
995
|
-
private async publishStartEvent(consolidationId: string): Promise<void> {
|
|
996
|
-
const event: LearningConsolidationStartedEvent = {
|
|
997
|
-
id: uuidv4(),
|
|
998
|
-
type: 'LearningConsolidationStarted',
|
|
999
|
-
timestamp: new Date(),
|
|
1000
|
-
source: 'learning-optimization',
|
|
1001
|
-
payload: {
|
|
1002
|
-
consolidationId,
|
|
1003
|
-
timestamp: new Date(),
|
|
1004
|
-
domainsToProcess: [...ALL_DOMAINS],
|
|
1005
|
-
},
|
|
1006
|
-
};
|
|
1007
|
-
await this.eventBus.publish(event);
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
private async publishPatternConsolidatedEvent(
|
|
1011
|
-
consolidationId: string,
|
|
1012
|
-
domain: DomainName,
|
|
1013
|
-
patternsBeforeCount: number,
|
|
1014
|
-
patternsAfterCount: number,
|
|
1015
|
-
mergedPatternIds: string[],
|
|
1016
|
-
removedPatternIds: string[]
|
|
1017
|
-
): Promise<void> {
|
|
1018
|
-
const event: PatternConsolidatedEvent = {
|
|
1019
|
-
id: uuidv4(),
|
|
1020
|
-
type: 'PatternConsolidated',
|
|
1021
|
-
timestamp: new Date(),
|
|
1022
|
-
source: 'learning-optimization',
|
|
1023
|
-
payload: {
|
|
1024
|
-
consolidationId,
|
|
1025
|
-
domain,
|
|
1026
|
-
patternsBeforeCount,
|
|
1027
|
-
patternsAfterCount,
|
|
1028
|
-
mergedPatternIds,
|
|
1029
|
-
removedPatternIds,
|
|
1030
|
-
},
|
|
1031
|
-
};
|
|
1032
|
-
await this.eventBus.publish(event);
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
private async publishCompletedEvent(
|
|
1036
|
-
consolidationId: string,
|
|
1037
|
-
stats: ConsolidationStats,
|
|
1038
|
-
insights: WeeklyInsight[],
|
|
1039
|
-
duration: number
|
|
1040
|
-
): Promise<void> {
|
|
1041
|
-
const event: LearningConsolidationCompletedEvent = {
|
|
1042
|
-
id: uuidv4(),
|
|
1043
|
-
type: 'LearningConsolidationCompleted',
|
|
1044
|
-
timestamp: new Date(),
|
|
1045
|
-
source: 'learning-optimization',
|
|
1046
|
-
payload: {
|
|
1047
|
-
consolidationId,
|
|
1048
|
-
stats,
|
|
1049
|
-
insights,
|
|
1050
|
-
duration,
|
|
1051
|
-
},
|
|
1052
|
-
};
|
|
1053
|
-
await this.eventBus.publish(event);
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
private async publishTransferReadyEvent(
|
|
1057
|
-
consolidationId: string,
|
|
1058
|
-
transferablePatterns: TransferablePattern[]
|
|
1059
|
-
): Promise<void> {
|
|
1060
|
-
// Extract unique target projects (in this case, we derive from domains)
|
|
1061
|
-
const targetProjects = [...new Set(
|
|
1062
|
-
transferablePatterns.flatMap((p) => p.applicableDomains)
|
|
1063
|
-
)].map((d) => `project-${d}`);
|
|
1064
|
-
|
|
1065
|
-
const event: TransferReadyEvent = {
|
|
1066
|
-
id: uuidv4(),
|
|
1067
|
-
type: 'TransferReady',
|
|
1068
|
-
timestamp: new Date(),
|
|
1069
|
-
source: 'learning-optimization',
|
|
1070
|
-
payload: {
|
|
1071
|
-
consolidationId,
|
|
1072
|
-
transferablePatterns,
|
|
1073
|
-
targetProjects,
|
|
1074
|
-
},
|
|
1075
|
-
};
|
|
1076
|
-
await this.eventBus.publish(event);
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
// ============================================================================
|
|
1080
|
-
// Storage
|
|
1081
|
-
// ============================================================================
|
|
1082
|
-
|
|
1083
|
-
private async storeConsolidationResult(result: ConsolidationResult): Promise<void> {
|
|
1084
|
-
await this.memory.set(
|
|
1085
|
-
`learning:consolidation:result:${result.consolidationId}`,
|
|
1086
|
-
result,
|
|
1087
|
-
{ namespace: 'learning-optimization', persist: true }
|
|
1088
|
-
);
|
|
1089
|
-
|
|
1090
|
-
// Also store in historical timeline
|
|
1091
|
-
await this.memory.set(
|
|
1092
|
-
`learning:consolidation:history:${result.completedAt.getTime()}`,
|
|
1093
|
-
{
|
|
1094
|
-
consolidationId: result.consolidationId,
|
|
1095
|
-
completedAt: result.completedAt,
|
|
1096
|
-
stats: result.stats,
|
|
1097
|
-
},
|
|
1098
|
-
{ namespace: 'learning-optimization', persist: true }
|
|
1099
|
-
);
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
// ============================================================================
|
|
1103
|
-
// Utility Methods
|
|
1104
|
-
// ============================================================================
|
|
1105
|
-
|
|
1106
|
-
/**
|
|
1107
|
-
* Get previous consolidation results for trend analysis
|
|
1108
|
-
*/
|
|
1109
|
-
async getPreviousConsolidations(count: number): Promise<ConsolidationResult[]> {
|
|
1110
|
-
const keys = await this.memory.search('learning:consolidation:result:*', count);
|
|
1111
|
-
const results: ConsolidationResult[] = [];
|
|
1112
|
-
|
|
1113
|
-
for (const key of keys) {
|
|
1114
|
-
const result = await this.memory.get<ConsolidationResult>(key);
|
|
1115
|
-
if (result) {
|
|
1116
|
-
results.push(result);
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
return results.sort(
|
|
1121
|
-
(a, b) => b.completedAt.getTime() - a.completedAt.getTime()
|
|
1122
|
-
);
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
/**
|
|
1126
|
-
* Get consolidation history summary
|
|
1127
|
-
*/
|
|
1128
|
-
async getConsolidationHistory(weeks: number): Promise<{
|
|
1129
|
-
consolidations: number;
|
|
1130
|
-
totalPatternsMerged: number;
|
|
1131
|
-
totalPatternsRemoved: number;
|
|
1132
|
-
avgImprovementOpportunities: number;
|
|
1133
|
-
}> {
|
|
1134
|
-
const results = await this.getPreviousConsolidations(weeks);
|
|
1135
|
-
|
|
1136
|
-
if (results.length === 0) {
|
|
1137
|
-
return {
|
|
1138
|
-
consolidations: 0,
|
|
1139
|
-
totalPatternsMerged: 0,
|
|
1140
|
-
totalPatternsRemoved: 0,
|
|
1141
|
-
avgImprovementOpportunities: 0,
|
|
1142
|
-
};
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
const totalMerged = results.reduce((sum, r) => sum + r.stats.patternsMerged, 0);
|
|
1146
|
-
const totalRemoved = results.reduce((sum, r) => sum + r.stats.patternsRemoved, 0);
|
|
1147
|
-
const avgOpportunities =
|
|
1148
|
-
results.reduce((sum, r) => sum + r.stats.improvementOpportunities, 0) /
|
|
1149
|
-
results.length;
|
|
1150
|
-
|
|
1151
|
-
return {
|
|
1152
|
-
consolidations: results.length,
|
|
1153
|
-
totalPatternsMerged: totalMerged,
|
|
1154
|
-
totalPatternsRemoved: totalRemoved,
|
|
1155
|
-
avgImprovementOpportunities: avgOpportunities,
|
|
1156
|
-
};
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
|
|
1160
|
-
// ============================================================================
|
|
1161
|
-
// Factory Function
|
|
1162
|
-
// ============================================================================
|
|
1163
|
-
|
|
1164
|
-
/**
|
|
1165
|
-
* Create a Learning Consolidation Protocol instance
|
|
1166
|
-
*/
|
|
1167
|
-
export function createLearningConsolidationProtocol(
|
|
1168
|
-
eventBus: EventBus,
|
|
1169
|
-
memory: MemoryBackend,
|
|
1170
|
-
patternService: IPatternLearningService,
|
|
1171
|
-
knowledgeService: IKnowledgeSynthesisService,
|
|
1172
|
-
config?: Partial<LearningConsolidationConfig>
|
|
1173
|
-
): LearningConsolidationProtocol {
|
|
1174
|
-
return new LearningConsolidationProtocol(
|
|
1175
|
-
eventBus,
|
|
1176
|
-
memory,
|
|
1177
|
-
patternService,
|
|
1178
|
-
knowledgeService,
|
|
1179
|
-
config
|
|
1180
|
-
);
|
|
1181
|
-
}
|