@agentic-qe/v3 3.0.0-alpha.6 → 3.0.0-alpha.8
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 +23 -13
- package/dist/init/agents-installer.js +4 -4
- package/dist/init/agents-installer.js.map +1 -1
- package/dist/init/init-wizard.d.ts.map +1 -1
- package/dist/init/init-wizard.js +15 -5
- package/dist/init/init-wizard.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,1184 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agentic QE v3 - Defect Investigation Protocol
|
|
3
|
-
*
|
|
4
|
-
* Orchestrates multi-agent investigation of test failures.
|
|
5
|
-
* Trigger: Test failure event
|
|
6
|
-
* Participants: Defect Predictor, RCA, Flaky Hunter, Regression
|
|
7
|
-
* Actions: Check flakiness, analyze root cause, predict related failures
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
11
|
-
import {
|
|
12
|
-
Result,
|
|
13
|
-
ok,
|
|
14
|
-
err,
|
|
15
|
-
DomainName,
|
|
16
|
-
Severity,
|
|
17
|
-
} from '../../shared/types';
|
|
18
|
-
import { createEvent } from '../../shared/events/domain-events';
|
|
19
|
-
import { EventBus, MemoryBackend } from '../../kernel/interfaces';
|
|
20
|
-
import {
|
|
21
|
-
RootCauseAnalysis,
|
|
22
|
-
ContributingFactor,
|
|
23
|
-
RegressionRisk,
|
|
24
|
-
} from '../../domains/defect-intelligence/interfaces';
|
|
25
|
-
import { ImpactAnalysis } from '../../domains/code-intelligence/interfaces';
|
|
26
|
-
|
|
27
|
-
// ============================================================================
|
|
28
|
-
// Protocol Types
|
|
29
|
-
// ============================================================================
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Input for defect investigation - a test failure to investigate
|
|
33
|
-
*/
|
|
34
|
-
export interface TestFailure {
|
|
35
|
-
testId: string;
|
|
36
|
-
testName: string;
|
|
37
|
-
file: string;
|
|
38
|
-
error: string;
|
|
39
|
-
stack?: string;
|
|
40
|
-
duration: number;
|
|
41
|
-
runId: string;
|
|
42
|
-
timestamp: Date;
|
|
43
|
-
context?: TestFailureContext;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface TestFailureContext {
|
|
47
|
-
precedingTests?: string[];
|
|
48
|
-
environment?: Record<string, string>;
|
|
49
|
-
parallelWorkers?: number;
|
|
50
|
-
retryAttempt?: number;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Result of a complete defect investigation
|
|
55
|
-
*/
|
|
56
|
-
export interface DefectInvestigationResult {
|
|
57
|
-
investigationId: string;
|
|
58
|
-
testFailure: TestFailure;
|
|
59
|
-
isFlaky: boolean;
|
|
60
|
-
flakyAnalysis?: FlakyTestAnalysis;
|
|
61
|
-
rootCause?: RootCauseAnalysis;
|
|
62
|
-
regressionAnalysis?: RegressionRisk;
|
|
63
|
-
relatedFailures: RelatedFailure[];
|
|
64
|
-
impactAnalysis?: ImpactAnalysis;
|
|
65
|
-
coverageContext?: CoverageContext;
|
|
66
|
-
recommendations: DefectRecommendation[];
|
|
67
|
-
confidence: number;
|
|
68
|
-
duration: number;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface FlakyTestAnalysis {
|
|
72
|
-
isFlaky: boolean;
|
|
73
|
-
confidence: number;
|
|
74
|
-
pattern?: 'timing' | 'ordering' | 'resource' | 'async' | 'unknown';
|
|
75
|
-
failureRate?: number;
|
|
76
|
-
recommendation?: string;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface RelatedFailure {
|
|
80
|
-
testId: string;
|
|
81
|
-
testName: string;
|
|
82
|
-
file: string;
|
|
83
|
-
similarity: number;
|
|
84
|
-
reason: string;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export interface CoverageContext {
|
|
88
|
-
file: string;
|
|
89
|
-
lineCoverage: number;
|
|
90
|
-
branchCoverage: number;
|
|
91
|
-
uncoveredLines: number[];
|
|
92
|
-
riskScore: number;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface DefectRecommendation {
|
|
96
|
-
type: 'fix' | 'investigate' | 'retry' | 'skip' | 'quarantine';
|
|
97
|
-
priority: 'critical' | 'high' | 'medium' | 'low';
|
|
98
|
-
description: string;
|
|
99
|
-
action: string;
|
|
100
|
-
effort: 'low' | 'medium' | 'high';
|
|
101
|
-
confidence: number;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// ============================================================================
|
|
105
|
-
// Protocol Events
|
|
106
|
-
// ============================================================================
|
|
107
|
-
|
|
108
|
-
export interface DefectInvestigationStartedPayload {
|
|
109
|
-
investigationId: string;
|
|
110
|
-
testId: string;
|
|
111
|
-
testFile: string;
|
|
112
|
-
error: string;
|
|
113
|
-
runId: string;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export interface FlakinessDetectedPayload {
|
|
117
|
-
investigationId: string;
|
|
118
|
-
testId: string;
|
|
119
|
-
pattern: string;
|
|
120
|
-
failureRate: number;
|
|
121
|
-
confidence: number;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export interface RootCauseIdentifiedPayload {
|
|
125
|
-
investigationId: string;
|
|
126
|
-
testId: string;
|
|
127
|
-
rootCause: string;
|
|
128
|
-
confidence: number;
|
|
129
|
-
contributingFactors: string[];
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export interface RelatedFailuresPredictedPayload {
|
|
133
|
-
investigationId: string;
|
|
134
|
-
testId: string;
|
|
135
|
-
relatedTests: string[];
|
|
136
|
-
similarityScores: number[];
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export interface DefectInvestigationCompletedPayload {
|
|
140
|
-
investigationId: string;
|
|
141
|
-
testId: string;
|
|
142
|
-
isFlaky: boolean;
|
|
143
|
-
rootCause?: string;
|
|
144
|
-
relatedFailuresCount: number;
|
|
145
|
-
recommendationsCount: number;
|
|
146
|
-
confidence: number;
|
|
147
|
-
duration: number;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export const DefectInvestigationEvents = {
|
|
151
|
-
DefectInvestigationStarted: 'coordination.DefectInvestigationStarted',
|
|
152
|
-
FlakinessDetected: 'coordination.FlakinessDetected',
|
|
153
|
-
RootCauseIdentified: 'coordination.RootCauseIdentified',
|
|
154
|
-
RelatedFailuresPredicted: 'coordination.RelatedFailuresPredicted',
|
|
155
|
-
DefectInvestigationCompleted: 'coordination.DefectInvestigationCompleted',
|
|
156
|
-
} as const;
|
|
157
|
-
|
|
158
|
-
// ============================================================================
|
|
159
|
-
// Protocol Configuration
|
|
160
|
-
// ============================================================================
|
|
161
|
-
|
|
162
|
-
export interface DefectInvestigationConfig {
|
|
163
|
-
/** Maximum time to spend on investigation (ms) */
|
|
164
|
-
maxDuration: number;
|
|
165
|
-
/** Minimum confidence threshold to report findings */
|
|
166
|
-
minConfidence: number;
|
|
167
|
-
/** Number of historical runs to check for flakiness */
|
|
168
|
-
flakinessHistorySize: number;
|
|
169
|
-
/** Failure rate threshold to consider test flaky */
|
|
170
|
-
flakinessThreshold: number;
|
|
171
|
-
/** Maximum related failures to predict */
|
|
172
|
-
maxRelatedFailures: number;
|
|
173
|
-
/** Enable deep root cause analysis */
|
|
174
|
-
enableDeepAnalysis: boolean;
|
|
175
|
-
/** Skip investigation for known flaky tests */
|
|
176
|
-
skipKnownFlaky: boolean;
|
|
177
|
-
/** Namespace for storing investigation data */
|
|
178
|
-
namespace: string;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const DEFAULT_CONFIG: DefectInvestigationConfig = {
|
|
182
|
-
maxDuration: 30000,
|
|
183
|
-
minConfidence: 0.3,
|
|
184
|
-
flakinessHistorySize: 10,
|
|
185
|
-
flakinessThreshold: 0.2,
|
|
186
|
-
maxRelatedFailures: 10,
|
|
187
|
-
enableDeepAnalysis: true,
|
|
188
|
-
skipKnownFlaky: true,
|
|
189
|
-
namespace: 'defect-investigation',
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
// ============================================================================
|
|
193
|
-
// Defect Investigation Protocol
|
|
194
|
-
// ============================================================================
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* DefectInvestigationProtocol orchestrates multi-agent investigation of test failures.
|
|
198
|
-
*
|
|
199
|
-
* Investigation workflow:
|
|
200
|
-
* 1. Check if test is known flaky (return early if yes)
|
|
201
|
-
* 2. Analyze root cause
|
|
202
|
-
* 3. Check for regression patterns
|
|
203
|
-
* 4. Predict related failures
|
|
204
|
-
* 5. Generate remediation suggestions
|
|
205
|
-
*/
|
|
206
|
-
export class DefectInvestigationProtocol {
|
|
207
|
-
private readonly config: DefectInvestigationConfig;
|
|
208
|
-
private readonly source: DomainName = 'defect-intelligence';
|
|
209
|
-
|
|
210
|
-
constructor(
|
|
211
|
-
private readonly eventBus: EventBus,
|
|
212
|
-
private readonly memory: MemoryBackend,
|
|
213
|
-
config: Partial<DefectInvestigationConfig> = {}
|
|
214
|
-
) {
|
|
215
|
-
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Execute the full defect investigation protocol
|
|
220
|
-
*/
|
|
221
|
-
async execute(
|
|
222
|
-
testFailure: TestFailure
|
|
223
|
-
): Promise<Result<DefectInvestigationResult, Error>> {
|
|
224
|
-
const startTime = Date.now();
|
|
225
|
-
const investigationId = uuidv4();
|
|
226
|
-
|
|
227
|
-
try {
|
|
228
|
-
// Publish investigation started event
|
|
229
|
-
await this.publishEvent(
|
|
230
|
-
DefectInvestigationEvents.DefectInvestigationStarted,
|
|
231
|
-
{
|
|
232
|
-
investigationId,
|
|
233
|
-
testId: testFailure.testId,
|
|
234
|
-
testFile: testFailure.file,
|
|
235
|
-
error: testFailure.error,
|
|
236
|
-
runId: testFailure.runId,
|
|
237
|
-
} as DefectInvestigationStartedPayload,
|
|
238
|
-
investigationId
|
|
239
|
-
);
|
|
240
|
-
|
|
241
|
-
// Step 1: Check flakiness
|
|
242
|
-
const flakyResult = await this.checkFlakiness(
|
|
243
|
-
investigationId,
|
|
244
|
-
testFailure
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
// If known flaky and configured to skip, return early
|
|
248
|
-
if (
|
|
249
|
-
flakyResult.isFlaky &&
|
|
250
|
-
flakyResult.confidence > 0.8 &&
|
|
251
|
-
this.config.skipKnownFlaky
|
|
252
|
-
) {
|
|
253
|
-
const result = this.buildEarlyFlakyResult(
|
|
254
|
-
investigationId,
|
|
255
|
-
testFailure,
|
|
256
|
-
flakyResult,
|
|
257
|
-
Date.now() - startTime
|
|
258
|
-
);
|
|
259
|
-
|
|
260
|
-
await this.completeInvestigation(result);
|
|
261
|
-
return ok(result);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// Step 2: Analyze root cause
|
|
265
|
-
const rootCause = await this.analyzeRootCause(
|
|
266
|
-
investigationId,
|
|
267
|
-
testFailure
|
|
268
|
-
);
|
|
269
|
-
|
|
270
|
-
// Step 3: Analyze regression patterns
|
|
271
|
-
const regressionAnalysis = await this.analyzeRegression(testFailure);
|
|
272
|
-
|
|
273
|
-
// Step 4: Predict related failures
|
|
274
|
-
const relatedFailures = await this.predictRelatedFailures(
|
|
275
|
-
investigationId,
|
|
276
|
-
testFailure,
|
|
277
|
-
rootCause
|
|
278
|
-
);
|
|
279
|
-
|
|
280
|
-
// Step 5: Get coverage context
|
|
281
|
-
const coverageContext = await this.getCoverageContext(testFailure.file);
|
|
282
|
-
|
|
283
|
-
// Step 6: Get impact analysis
|
|
284
|
-
const impactAnalysis = await this.getImpactAnalysis(testFailure.file);
|
|
285
|
-
|
|
286
|
-
// Step 7: Generate recommendations
|
|
287
|
-
const recommendations = this.suggestFixes(
|
|
288
|
-
testFailure,
|
|
289
|
-
flakyResult,
|
|
290
|
-
rootCause,
|
|
291
|
-
regressionAnalysis,
|
|
292
|
-
relatedFailures
|
|
293
|
-
);
|
|
294
|
-
|
|
295
|
-
// Calculate overall confidence
|
|
296
|
-
const confidence = this.calculateOverallConfidence(
|
|
297
|
-
flakyResult,
|
|
298
|
-
rootCause,
|
|
299
|
-
recommendations
|
|
300
|
-
);
|
|
301
|
-
|
|
302
|
-
// Build final result
|
|
303
|
-
const result: DefectInvestigationResult = {
|
|
304
|
-
investigationId,
|
|
305
|
-
testFailure,
|
|
306
|
-
isFlaky: flakyResult.isFlaky,
|
|
307
|
-
flakyAnalysis: flakyResult,
|
|
308
|
-
rootCause: rootCause ?? undefined,
|
|
309
|
-
regressionAnalysis: regressionAnalysis ?? undefined,
|
|
310
|
-
relatedFailures,
|
|
311
|
-
impactAnalysis: impactAnalysis ?? undefined,
|
|
312
|
-
coverageContext: coverageContext ?? undefined,
|
|
313
|
-
recommendations,
|
|
314
|
-
confidence,
|
|
315
|
-
duration: Date.now() - startTime,
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
// Step 8: Update defect patterns for learning
|
|
319
|
-
await this.updateDefectPatterns(result);
|
|
320
|
-
|
|
321
|
-
// Complete investigation
|
|
322
|
-
await this.completeInvestigation(result);
|
|
323
|
-
|
|
324
|
-
return ok(result);
|
|
325
|
-
} catch (error) {
|
|
326
|
-
return err(error instanceof Error ? error : new Error(String(error)));
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Check if the test failure is due to flakiness
|
|
332
|
-
*/
|
|
333
|
-
async checkFlakiness(
|
|
334
|
-
investigationId: string,
|
|
335
|
-
testFailure: TestFailure
|
|
336
|
-
): Promise<FlakyTestAnalysis> {
|
|
337
|
-
// Get execution history for this test
|
|
338
|
-
const historyKey = `test-execution:history:${testFailure.testId}`;
|
|
339
|
-
const history = await this.memory.get<TestExecutionHistory[]>(historyKey);
|
|
340
|
-
|
|
341
|
-
if (!history || history.length < 2) {
|
|
342
|
-
return {
|
|
343
|
-
isFlaky: false,
|
|
344
|
-
confidence: 0.5,
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
// Calculate failure rate
|
|
349
|
-
const failures = history.filter((h) => !h.passed).length;
|
|
350
|
-
const failureRate = failures / history.length;
|
|
351
|
-
|
|
352
|
-
// Detect flakiness pattern
|
|
353
|
-
const pattern = this.detectFlakinessPattern(history, testFailure);
|
|
354
|
-
|
|
355
|
-
// Determine if flaky
|
|
356
|
-
const isFlaky =
|
|
357
|
-
failureRate > 0 &&
|
|
358
|
-
failureRate < 1 &&
|
|
359
|
-
failureRate >= this.config.flakinessThreshold;
|
|
360
|
-
|
|
361
|
-
// Calculate confidence
|
|
362
|
-
const confidence = this.calculateFlakinessConfidence(
|
|
363
|
-
history.length,
|
|
364
|
-
failureRate,
|
|
365
|
-
pattern
|
|
366
|
-
);
|
|
367
|
-
|
|
368
|
-
const result: FlakyTestAnalysis = {
|
|
369
|
-
isFlaky,
|
|
370
|
-
confidence,
|
|
371
|
-
pattern: isFlaky ? pattern : undefined,
|
|
372
|
-
failureRate: isFlaky ? failureRate : undefined,
|
|
373
|
-
recommendation: isFlaky
|
|
374
|
-
? this.getFlakyRecommendation(pattern)
|
|
375
|
-
: undefined,
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
// Publish event if flaky detected
|
|
379
|
-
if (isFlaky && confidence > this.config.minConfidence) {
|
|
380
|
-
await this.publishEvent(
|
|
381
|
-
DefectInvestigationEvents.FlakinessDetected,
|
|
382
|
-
{
|
|
383
|
-
investigationId,
|
|
384
|
-
testId: testFailure.testId,
|
|
385
|
-
pattern: pattern,
|
|
386
|
-
failureRate,
|
|
387
|
-
confidence,
|
|
388
|
-
} as FlakinessDetectedPayload,
|
|
389
|
-
investigationId
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
return result;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* Analyze root cause of the test failure
|
|
398
|
-
*/
|
|
399
|
-
async analyzeRootCause(
|
|
400
|
-
investigationId: string,
|
|
401
|
-
testFailure: TestFailure
|
|
402
|
-
): Promise<RootCauseAnalysis | null> {
|
|
403
|
-
try {
|
|
404
|
-
// Extract symptoms from error message and stack
|
|
405
|
-
const symptoms = this.extractSymptoms(testFailure);
|
|
406
|
-
|
|
407
|
-
// Use heuristic analysis to determine root cause
|
|
408
|
-
const analysis = await this.performRootCauseAnalysis(
|
|
409
|
-
testFailure,
|
|
410
|
-
symptoms
|
|
411
|
-
);
|
|
412
|
-
|
|
413
|
-
if (analysis && analysis.confidence >= this.config.minConfidence) {
|
|
414
|
-
// Publish event
|
|
415
|
-
await this.publishEvent(
|
|
416
|
-
DefectInvestigationEvents.RootCauseIdentified,
|
|
417
|
-
{
|
|
418
|
-
investigationId,
|
|
419
|
-
testId: testFailure.testId,
|
|
420
|
-
rootCause: analysis.rootCause,
|
|
421
|
-
confidence: analysis.confidence,
|
|
422
|
-
contributingFactors: analysis.contributingFactors.map(
|
|
423
|
-
(f) => f.factor
|
|
424
|
-
),
|
|
425
|
-
} as RootCauseIdentifiedPayload,
|
|
426
|
-
investigationId
|
|
427
|
-
);
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
return analysis;
|
|
431
|
-
} catch {
|
|
432
|
-
return null;
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* Predict tests that may have related failures
|
|
438
|
-
*/
|
|
439
|
-
async predictRelatedFailures(
|
|
440
|
-
investigationId: string,
|
|
441
|
-
testFailure: TestFailure,
|
|
442
|
-
rootCause: RootCauseAnalysis | null
|
|
443
|
-
): Promise<RelatedFailure[]> {
|
|
444
|
-
const relatedFailures: RelatedFailure[] = [];
|
|
445
|
-
|
|
446
|
-
try {
|
|
447
|
-
// Find tests in same file
|
|
448
|
-
const sameFileTests = await this.findTestsInSameFile(testFailure.file);
|
|
449
|
-
for (const test of sameFileTests) {
|
|
450
|
-
if (test.testId !== testFailure.testId) {
|
|
451
|
-
relatedFailures.push({
|
|
452
|
-
testId: test.testId,
|
|
453
|
-
testName: test.testName,
|
|
454
|
-
file: testFailure.file,
|
|
455
|
-
similarity: 0.8,
|
|
456
|
-
reason: 'Same test file',
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
// Find tests with similar error patterns
|
|
462
|
-
if (rootCause) {
|
|
463
|
-
const similarTests = await this.findTestsWithSimilarErrors(
|
|
464
|
-
testFailure.error,
|
|
465
|
-
rootCause.rootCause
|
|
466
|
-
);
|
|
467
|
-
for (const test of similarTests) {
|
|
468
|
-
if (
|
|
469
|
-
test.testId !== testFailure.testId &&
|
|
470
|
-
!relatedFailures.find((r) => r.testId === test.testId)
|
|
471
|
-
) {
|
|
472
|
-
relatedFailures.push({
|
|
473
|
-
testId: test.testId,
|
|
474
|
-
testName: test.testName,
|
|
475
|
-
file: test.file,
|
|
476
|
-
similarity: test.similarity,
|
|
477
|
-
reason: `Similar error pattern: ${rootCause.rootCause}`,
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
// Find tests that depend on same code
|
|
484
|
-
const dependentTests = await this.findDependentTests(testFailure.file);
|
|
485
|
-
for (const test of dependentTests) {
|
|
486
|
-
if (
|
|
487
|
-
test.testId !== testFailure.testId &&
|
|
488
|
-
!relatedFailures.find((r) => r.testId === test.testId)
|
|
489
|
-
) {
|
|
490
|
-
relatedFailures.push({
|
|
491
|
-
testId: test.testId,
|
|
492
|
-
testName: test.testName,
|
|
493
|
-
file: test.file,
|
|
494
|
-
similarity: 0.6,
|
|
495
|
-
reason: 'Tests same code dependency',
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
// Limit results and sort by similarity
|
|
501
|
-
const limitedResults = relatedFailures
|
|
502
|
-
.sort((a, b) => b.similarity - a.similarity)
|
|
503
|
-
.slice(0, this.config.maxRelatedFailures);
|
|
504
|
-
|
|
505
|
-
// Publish event if any related failures predicted
|
|
506
|
-
if (limitedResults.length > 0) {
|
|
507
|
-
await this.publishEvent(
|
|
508
|
-
DefectInvestigationEvents.RelatedFailuresPredicted,
|
|
509
|
-
{
|
|
510
|
-
investigationId,
|
|
511
|
-
testId: testFailure.testId,
|
|
512
|
-
relatedTests: limitedResults.map((r) => r.testId),
|
|
513
|
-
similarityScores: limitedResults.map((r) => r.similarity),
|
|
514
|
-
} as RelatedFailuresPredictedPayload,
|
|
515
|
-
investigationId
|
|
516
|
-
);
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
return limitedResults;
|
|
520
|
-
} catch {
|
|
521
|
-
return [];
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
/**
|
|
526
|
-
* Generate fix recommendations based on investigation findings
|
|
527
|
-
*/
|
|
528
|
-
suggestFixes(
|
|
529
|
-
testFailure: TestFailure,
|
|
530
|
-
flakyAnalysis: FlakyTestAnalysis,
|
|
531
|
-
rootCause: RootCauseAnalysis | null,
|
|
532
|
-
regressionAnalysis: RegressionRisk | null,
|
|
533
|
-
relatedFailures: RelatedFailure[]
|
|
534
|
-
): DefectRecommendation[] {
|
|
535
|
-
const recommendations: DefectRecommendation[] = [];
|
|
536
|
-
|
|
537
|
-
// Handle flaky tests
|
|
538
|
-
if (flakyAnalysis.isFlaky) {
|
|
539
|
-
recommendations.push(
|
|
540
|
-
this.createFlakyRecommendation(flakyAnalysis, testFailure)
|
|
541
|
-
);
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
// Root cause based recommendations
|
|
545
|
-
if (rootCause) {
|
|
546
|
-
recommendations.push(
|
|
547
|
-
...this.createRootCauseRecommendations(rootCause, testFailure)
|
|
548
|
-
);
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
// Regression-based recommendations
|
|
552
|
-
if (regressionAnalysis && regressionAnalysis.overallRisk > 0.5) {
|
|
553
|
-
recommendations.push({
|
|
554
|
-
type: 'investigate',
|
|
555
|
-
priority: regressionAnalysis.riskLevel === 'critical' ? 'critical' : 'high',
|
|
556
|
-
description: 'High regression risk detected',
|
|
557
|
-
action: `Review recent changes to: ${regressionAnalysis.impactedAreas.map((a) => a.area).join(', ')}`,
|
|
558
|
-
effort: 'medium',
|
|
559
|
-
confidence: regressionAnalysis.confidence,
|
|
560
|
-
});
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
// Related failures recommendations
|
|
564
|
-
if (relatedFailures.length > 2) {
|
|
565
|
-
recommendations.push({
|
|
566
|
-
type: 'investigate',
|
|
567
|
-
priority: 'high',
|
|
568
|
-
description: `${relatedFailures.length} related tests may also fail`,
|
|
569
|
-
action:
|
|
570
|
-
'Review common code path and consider batch fix across related tests',
|
|
571
|
-
effort: 'high',
|
|
572
|
-
confidence: 0.7,
|
|
573
|
-
});
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
// Default recommendation if nothing specific
|
|
577
|
-
if (recommendations.length === 0) {
|
|
578
|
-
recommendations.push({
|
|
579
|
-
type: 'investigate',
|
|
580
|
-
priority: 'medium',
|
|
581
|
-
description: 'Manual investigation required',
|
|
582
|
-
action: `Review test ${testFailure.testName} for failure cause`,
|
|
583
|
-
effort: 'medium',
|
|
584
|
-
confidence: 0.5,
|
|
585
|
-
});
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
// Sort by priority and confidence
|
|
589
|
-
return recommendations.sort((a, b) => {
|
|
590
|
-
const priorityOrder = { critical: 0, high: 1, medium: 2, low: 3 };
|
|
591
|
-
const priorityDiff = priorityOrder[a.priority] - priorityOrder[b.priority];
|
|
592
|
-
if (priorityDiff !== 0) return priorityDiff;
|
|
593
|
-
return b.confidence - a.confidence;
|
|
594
|
-
});
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
/**
|
|
598
|
-
* Update defect patterns for learning from this investigation
|
|
599
|
-
*/
|
|
600
|
-
async updateDefectPatterns(
|
|
601
|
-
result: DefectInvestigationResult
|
|
602
|
-
): Promise<void> {
|
|
603
|
-
try {
|
|
604
|
-
// Store investigation result
|
|
605
|
-
await this.memory.set(
|
|
606
|
-
`${this.config.namespace}:investigation:${result.investigationId}`,
|
|
607
|
-
{
|
|
608
|
-
investigationId: result.investigationId,
|
|
609
|
-
testId: result.testFailure.testId,
|
|
610
|
-
file: result.testFailure.file,
|
|
611
|
-
isFlaky: result.isFlaky,
|
|
612
|
-
rootCause: result.rootCause?.rootCause,
|
|
613
|
-
relatedCount: result.relatedFailures.length,
|
|
614
|
-
confidence: result.confidence,
|
|
615
|
-
timestamp: new Date().toISOString(),
|
|
616
|
-
},
|
|
617
|
-
{ namespace: this.config.namespace, persist: true }
|
|
618
|
-
);
|
|
619
|
-
|
|
620
|
-
// Update test history
|
|
621
|
-
const historyKey = `test-execution:history:${result.testFailure.testId}`;
|
|
622
|
-
const history =
|
|
623
|
-
(await this.memory.get<TestExecutionHistory[]>(historyKey)) ?? [];
|
|
624
|
-
|
|
625
|
-
history.push({
|
|
626
|
-
runId: result.testFailure.runId,
|
|
627
|
-
passed: false,
|
|
628
|
-
duration: result.testFailure.duration,
|
|
629
|
-
error: result.testFailure.error,
|
|
630
|
-
timestamp: result.testFailure.timestamp,
|
|
631
|
-
});
|
|
632
|
-
|
|
633
|
-
// Keep only recent history
|
|
634
|
-
const trimmedHistory = history.slice(-this.config.flakinessHistorySize);
|
|
635
|
-
|
|
636
|
-
await this.memory.set(historyKey, trimmedHistory, {
|
|
637
|
-
namespace: 'test-execution',
|
|
638
|
-
persist: true,
|
|
639
|
-
});
|
|
640
|
-
|
|
641
|
-
// Update pattern statistics
|
|
642
|
-
if (result.rootCause) {
|
|
643
|
-
const patternKey = `${this.config.namespace}:pattern-stats`;
|
|
644
|
-
const stats =
|
|
645
|
-
(await this.memory.get<PatternStats>(patternKey)) ?? {
|
|
646
|
-
patterns: {},
|
|
647
|
-
totalInvestigations: 0,
|
|
648
|
-
};
|
|
649
|
-
|
|
650
|
-
const pattern = result.rootCause.rootCause;
|
|
651
|
-
stats.patterns[pattern] = (stats.patterns[pattern] ?? 0) + 1;
|
|
652
|
-
stats.totalInvestigations += 1;
|
|
653
|
-
|
|
654
|
-
await this.memory.set(patternKey, stats, {
|
|
655
|
-
namespace: this.config.namespace,
|
|
656
|
-
persist: true,
|
|
657
|
-
});
|
|
658
|
-
}
|
|
659
|
-
} catch {
|
|
660
|
-
// Non-critical - log but don't fail
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
// ============================================================================
|
|
665
|
-
// Private Helper Methods
|
|
666
|
-
// ============================================================================
|
|
667
|
-
|
|
668
|
-
private async publishEvent<T>(
|
|
669
|
-
eventType: string,
|
|
670
|
-
payload: T,
|
|
671
|
-
correlationId: string
|
|
672
|
-
): Promise<void> {
|
|
673
|
-
const event = createEvent(eventType, this.source, payload, correlationId);
|
|
674
|
-
await this.eventBus.publish(event);
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
private async completeInvestigation(
|
|
678
|
-
result: DefectInvestigationResult
|
|
679
|
-
): Promise<void> {
|
|
680
|
-
await this.publishEvent(
|
|
681
|
-
DefectInvestigationEvents.DefectInvestigationCompleted,
|
|
682
|
-
{
|
|
683
|
-
investigationId: result.investigationId,
|
|
684
|
-
testId: result.testFailure.testId,
|
|
685
|
-
isFlaky: result.isFlaky,
|
|
686
|
-
rootCause: result.rootCause?.rootCause,
|
|
687
|
-
relatedFailuresCount: result.relatedFailures.length,
|
|
688
|
-
recommendationsCount: result.recommendations.length,
|
|
689
|
-
confidence: result.confidence,
|
|
690
|
-
duration: result.duration,
|
|
691
|
-
} as DefectInvestigationCompletedPayload,
|
|
692
|
-
result.investigationId
|
|
693
|
-
);
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
private buildEarlyFlakyResult(
|
|
697
|
-
investigationId: string,
|
|
698
|
-
testFailure: TestFailure,
|
|
699
|
-
flakyResult: FlakyTestAnalysis,
|
|
700
|
-
duration: number
|
|
701
|
-
): DefectInvestigationResult {
|
|
702
|
-
return {
|
|
703
|
-
investigationId,
|
|
704
|
-
testFailure,
|
|
705
|
-
isFlaky: true,
|
|
706
|
-
flakyAnalysis: flakyResult,
|
|
707
|
-
relatedFailures: [],
|
|
708
|
-
recommendations: [
|
|
709
|
-
{
|
|
710
|
-
type: 'quarantine',
|
|
711
|
-
priority: 'medium',
|
|
712
|
-
description: 'Known flaky test detected',
|
|
713
|
-
action: flakyResult.recommendation ?? 'Quarantine or fix flakiness',
|
|
714
|
-
effort: 'medium',
|
|
715
|
-
confidence: flakyResult.confidence,
|
|
716
|
-
},
|
|
717
|
-
],
|
|
718
|
-
confidence: flakyResult.confidence,
|
|
719
|
-
duration,
|
|
720
|
-
};
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
private detectFlakinessPattern(
|
|
724
|
-
history: TestExecutionHistory[],
|
|
725
|
-
testFailure: TestFailure
|
|
726
|
-
): 'timing' | 'ordering' | 'resource' | 'async' | 'unknown' {
|
|
727
|
-
const failedRuns = history.filter((h) => !h.passed);
|
|
728
|
-
const passedRuns = history.filter((h) => h.passed);
|
|
729
|
-
|
|
730
|
-
if (failedRuns.length === 0 || passedRuns.length === 0) {
|
|
731
|
-
return 'unknown';
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
// Check for timing issues
|
|
735
|
-
const avgFailedDuration = this.average(failedRuns.map((r) => r.duration));
|
|
736
|
-
const avgPassedDuration = this.average(passedRuns.map((r) => r.duration));
|
|
737
|
-
|
|
738
|
-
if (Math.abs(avgFailedDuration - avgPassedDuration) / avgPassedDuration > 0.5) {
|
|
739
|
-
return 'timing';
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
// Check for async issues
|
|
743
|
-
const asyncKeywords = ['timeout', 'promise', 'async', 'await', 'callback'];
|
|
744
|
-
const error = testFailure.error.toLowerCase();
|
|
745
|
-
if (asyncKeywords.some((k) => error.includes(k))) {
|
|
746
|
-
return 'async';
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
// Check for resource issues
|
|
750
|
-
const resourceKeywords = ['connection', 'database', 'network', 'port', 'file'];
|
|
751
|
-
if (resourceKeywords.some((k) => error.includes(k))) {
|
|
752
|
-
return 'resource';
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
// Check for ordering issues
|
|
756
|
-
if (testFailure.context?.precedingTests?.length) {
|
|
757
|
-
return 'ordering';
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
return 'unknown';
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
private calculateFlakinessConfidence(
|
|
764
|
-
sampleSize: number,
|
|
765
|
-
failureRate: number,
|
|
766
|
-
pattern: string
|
|
767
|
-
): number {
|
|
768
|
-
// Base confidence on sample size
|
|
769
|
-
const sampleConfidence = Math.min(1, sampleSize / 10);
|
|
770
|
-
|
|
771
|
-
// Pattern confidence
|
|
772
|
-
const patternConfidence = pattern !== 'unknown' ? 0.8 : 0.5;
|
|
773
|
-
|
|
774
|
-
// Failure rate confidence (middle rates are more clearly flaky)
|
|
775
|
-
const rateConfidence = Math.min(failureRate, 1 - failureRate) * 2;
|
|
776
|
-
|
|
777
|
-
return sampleConfidence * 0.4 + patternConfidence * 0.3 + rateConfidence * 0.3;
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
private getFlakyRecommendation(
|
|
781
|
-
pattern: 'timing' | 'ordering' | 'resource' | 'async' | 'unknown'
|
|
782
|
-
): string {
|
|
783
|
-
switch (pattern) {
|
|
784
|
-
case 'timing':
|
|
785
|
-
return 'Increase timeouts or use explicit waits instead of fixed delays';
|
|
786
|
-
case 'ordering':
|
|
787
|
-
return 'Ensure test isolation and independent setup/teardown';
|
|
788
|
-
case 'resource':
|
|
789
|
-
return 'Mock external dependencies or use connection pooling';
|
|
790
|
-
case 'async':
|
|
791
|
-
return 'Properly await async operations and handle promise rejections';
|
|
792
|
-
case 'unknown':
|
|
793
|
-
return 'Review test for potential race conditions or external dependencies';
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
private extractSymptoms(testFailure: TestFailure): string[] {
|
|
798
|
-
const symptoms: string[] = [];
|
|
799
|
-
|
|
800
|
-
// Add error message
|
|
801
|
-
if (testFailure.error) {
|
|
802
|
-
symptoms.push(testFailure.error);
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
// Extract key phrases from stack
|
|
806
|
-
if (testFailure.stack) {
|
|
807
|
-
const stackLines = testFailure.stack.split('\n').slice(0, 5);
|
|
808
|
-
symptoms.push(...stackLines.filter((l) => l.trim().length > 0));
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
// Add file context
|
|
812
|
-
symptoms.push(`file: ${testFailure.file}`);
|
|
813
|
-
|
|
814
|
-
return symptoms;
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
private async performRootCauseAnalysis(
|
|
818
|
-
testFailure: TestFailure,
|
|
819
|
-
symptoms: string[]
|
|
820
|
-
): Promise<RootCauseAnalysis | null> {
|
|
821
|
-
const symptomText = symptoms.join(' ').toLowerCase();
|
|
822
|
-
|
|
823
|
-
// Match against known root cause categories
|
|
824
|
-
const categories: Array<{
|
|
825
|
-
category: string;
|
|
826
|
-
patterns: string[];
|
|
827
|
-
rootCause: string;
|
|
828
|
-
impact: 'high' | 'medium' | 'low';
|
|
829
|
-
}> = [
|
|
830
|
-
{
|
|
831
|
-
category: 'assertion',
|
|
832
|
-
patterns: ['expect', 'assert', 'should', 'toBe', 'toEqual'],
|
|
833
|
-
rootCause: 'Assertion failure - expected value mismatch',
|
|
834
|
-
impact: 'high',
|
|
835
|
-
},
|
|
836
|
-
{
|
|
837
|
-
category: 'null-reference',
|
|
838
|
-
patterns: ['null', 'undefined', 'cannot read property', 'is not a function'],
|
|
839
|
-
rootCause: 'Null or undefined reference error',
|
|
840
|
-
impact: 'high',
|
|
841
|
-
},
|
|
842
|
-
{
|
|
843
|
-
category: 'timeout',
|
|
844
|
-
patterns: ['timeout', 'timed out', 'exceeded', 'too long'],
|
|
845
|
-
rootCause: 'Operation timeout - async operation too slow',
|
|
846
|
-
impact: 'medium',
|
|
847
|
-
},
|
|
848
|
-
{
|
|
849
|
-
category: 'network',
|
|
850
|
-
patterns: ['econnrefused', 'network', 'socket', 'connection'],
|
|
851
|
-
rootCause: 'Network or connection error',
|
|
852
|
-
impact: 'high',
|
|
853
|
-
},
|
|
854
|
-
{
|
|
855
|
-
category: 'type-error',
|
|
856
|
-
patterns: ['typeerror', 'type mismatch', 'invalid type'],
|
|
857
|
-
rootCause: 'Type error - incorrect data type',
|
|
858
|
-
impact: 'high',
|
|
859
|
-
},
|
|
860
|
-
];
|
|
861
|
-
|
|
862
|
-
let bestMatch: {
|
|
863
|
-
category: string;
|
|
864
|
-
rootCause: string;
|
|
865
|
-
score: number;
|
|
866
|
-
impact: 'high' | 'medium' | 'low';
|
|
867
|
-
} | null = null;
|
|
868
|
-
|
|
869
|
-
for (const cat of categories) {
|
|
870
|
-
const matchCount = cat.patterns.filter((p) =>
|
|
871
|
-
symptomText.includes(p)
|
|
872
|
-
).length;
|
|
873
|
-
const score = matchCount / cat.patterns.length;
|
|
874
|
-
|
|
875
|
-
if (!bestMatch || score > bestMatch.score) {
|
|
876
|
-
bestMatch = {
|
|
877
|
-
category: cat.category,
|
|
878
|
-
rootCause: cat.rootCause,
|
|
879
|
-
score,
|
|
880
|
-
impact: cat.impact,
|
|
881
|
-
};
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
if (!bestMatch || bestMatch.score < 0.2) {
|
|
886
|
-
return null;
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
const contributingFactors: ContributingFactor[] = [
|
|
890
|
-
{
|
|
891
|
-
factor: `Error category: ${bestMatch.category}`,
|
|
892
|
-
impact: bestMatch.impact,
|
|
893
|
-
evidence: symptoms.slice(0, 3),
|
|
894
|
-
},
|
|
895
|
-
];
|
|
896
|
-
|
|
897
|
-
return {
|
|
898
|
-
defectId: testFailure.testId,
|
|
899
|
-
rootCause: bestMatch.rootCause,
|
|
900
|
-
confidence: bestMatch.score,
|
|
901
|
-
contributingFactors,
|
|
902
|
-
relatedFiles: [testFailure.file],
|
|
903
|
-
recommendations: this.getRootCauseRecommendations(bestMatch.category),
|
|
904
|
-
timeline: [],
|
|
905
|
-
};
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
private getRootCauseRecommendations(category: string): string[] {
|
|
909
|
-
const recommendations: Record<string, string[]> = {
|
|
910
|
-
assertion: [
|
|
911
|
-
'Review expected vs actual values',
|
|
912
|
-
'Check for race conditions in state setup',
|
|
913
|
-
'Verify test data correctness',
|
|
914
|
-
],
|
|
915
|
-
'null-reference': [
|
|
916
|
-
'Add null checks before accessing properties',
|
|
917
|
-
'Verify object initialization order',
|
|
918
|
-
'Use optional chaining (?.) for safe access',
|
|
919
|
-
],
|
|
920
|
-
timeout: [
|
|
921
|
-
'Increase timeout for slow operations',
|
|
922
|
-
'Add explicit waits for async conditions',
|
|
923
|
-
'Check for deadlocks or infinite loops',
|
|
924
|
-
],
|
|
925
|
-
network: [
|
|
926
|
-
'Mock external services in tests',
|
|
927
|
-
'Verify service availability',
|
|
928
|
-
'Add retry logic for transient failures',
|
|
929
|
-
],
|
|
930
|
-
'type-error': [
|
|
931
|
-
'Verify input data types',
|
|
932
|
-
'Add type validation',
|
|
933
|
-
'Check for undefined parameters',
|
|
934
|
-
],
|
|
935
|
-
};
|
|
936
|
-
|
|
937
|
-
return recommendations[category] ?? ['Manual investigation required'];
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
private async analyzeRegression(
|
|
941
|
-
testFailure: TestFailure
|
|
942
|
-
): Promise<RegressionRisk | null> {
|
|
943
|
-
try {
|
|
944
|
-
// Check for recent changes to the test file
|
|
945
|
-
const changesKey = `code-intelligence:changes:${testFailure.file}`;
|
|
946
|
-
const recentChanges = await this.memory.get<string[]>(changesKey);
|
|
947
|
-
|
|
948
|
-
if (!recentChanges || recentChanges.length === 0) {
|
|
949
|
-
return null;
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
// Calculate risk based on change recency
|
|
953
|
-
const risk = Math.min(1, recentChanges.length * 0.2);
|
|
954
|
-
|
|
955
|
-
return {
|
|
956
|
-
overallRisk: risk,
|
|
957
|
-
riskLevel: this.riskToSeverity(risk),
|
|
958
|
-
impactedAreas: [
|
|
959
|
-
{
|
|
960
|
-
area: testFailure.file,
|
|
961
|
-
files: [testFailure.file],
|
|
962
|
-
risk,
|
|
963
|
-
reason: `${recentChanges.length} recent changes`,
|
|
964
|
-
},
|
|
965
|
-
],
|
|
966
|
-
recommendedTests: [testFailure.testId],
|
|
967
|
-
confidence: 0.7,
|
|
968
|
-
};
|
|
969
|
-
} catch {
|
|
970
|
-
return null;
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
private async getCoverageContext(
|
|
975
|
-
file: string
|
|
976
|
-
): Promise<CoverageContext | null> {
|
|
977
|
-
try {
|
|
978
|
-
const coverageKey = `coverage-analysis:file:${file}`;
|
|
979
|
-
const coverage = await this.memory.get<{
|
|
980
|
-
line: number;
|
|
981
|
-
branch: number;
|
|
982
|
-
uncoveredLines: number[];
|
|
983
|
-
}>(coverageKey);
|
|
984
|
-
|
|
985
|
-
if (!coverage) {
|
|
986
|
-
return null;
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
// Calculate risk based on coverage
|
|
990
|
-
const avgCoverage = (coverage.line + coverage.branch) / 2;
|
|
991
|
-
const riskScore = 1 - avgCoverage / 100;
|
|
992
|
-
|
|
993
|
-
return {
|
|
994
|
-
file,
|
|
995
|
-
lineCoverage: coverage.line,
|
|
996
|
-
branchCoverage: coverage.branch,
|
|
997
|
-
uncoveredLines: coverage.uncoveredLines,
|
|
998
|
-
riskScore,
|
|
999
|
-
};
|
|
1000
|
-
} catch {
|
|
1001
|
-
return null;
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
private async getImpactAnalysis(
|
|
1006
|
-
file: string
|
|
1007
|
-
): Promise<ImpactAnalysis | null> {
|
|
1008
|
-
try {
|
|
1009
|
-
const impactKey = `code-intelligence:impact:${file}`;
|
|
1010
|
-
const impact = await this.memory.get<ImpactAnalysis>(impactKey);
|
|
1011
|
-
return impact ?? null;
|
|
1012
|
-
} catch {
|
|
1013
|
-
return null;
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
private async findTestsInSameFile(
|
|
1018
|
-
file: string
|
|
1019
|
-
): Promise<Array<{ testId: string; testName: string }>> {
|
|
1020
|
-
try {
|
|
1021
|
-
const testsKey = `test-execution:tests-by-file:${file}`;
|
|
1022
|
-
const tests = await this.memory.get<
|
|
1023
|
-
Array<{ testId: string; testName: string }>
|
|
1024
|
-
>(testsKey);
|
|
1025
|
-
return tests ?? [];
|
|
1026
|
-
} catch {
|
|
1027
|
-
return [];
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
private async findTestsWithSimilarErrors(
|
|
1032
|
-
_error: string,
|
|
1033
|
-
rootCause: string
|
|
1034
|
-
): Promise<
|
|
1035
|
-
Array<{ testId: string; testName: string; file: string; similarity: number }>
|
|
1036
|
-
> {
|
|
1037
|
-
try {
|
|
1038
|
-
const results: Array<{
|
|
1039
|
-
testId: string;
|
|
1040
|
-
testName: string;
|
|
1041
|
-
file: string;
|
|
1042
|
-
similarity: number;
|
|
1043
|
-
}> = [];
|
|
1044
|
-
|
|
1045
|
-
// Search memory for similar error patterns
|
|
1046
|
-
const keys = await this.memory.search(`${this.config.namespace}:investigation:*`, 50);
|
|
1047
|
-
|
|
1048
|
-
for (const key of keys) {
|
|
1049
|
-
const investigation = await this.memory.get<{
|
|
1050
|
-
testId: string;
|
|
1051
|
-
file: string;
|
|
1052
|
-
rootCause?: string;
|
|
1053
|
-
}>(key);
|
|
1054
|
-
|
|
1055
|
-
if (investigation && investigation.rootCause === rootCause) {
|
|
1056
|
-
results.push({
|
|
1057
|
-
testId: investigation.testId,
|
|
1058
|
-
testName: investigation.testId,
|
|
1059
|
-
file: investigation.file,
|
|
1060
|
-
similarity: 0.7,
|
|
1061
|
-
});
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
return results;
|
|
1066
|
-
} catch {
|
|
1067
|
-
return [];
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
private async findDependentTests(
|
|
1072
|
-
file: string
|
|
1073
|
-
): Promise<Array<{ testId: string; testName: string; file: string }>> {
|
|
1074
|
-
try {
|
|
1075
|
-
const depsKey = `code-intelligence:test-dependencies:${file}`;
|
|
1076
|
-
const deps = await this.memory.get<
|
|
1077
|
-
Array<{ testId: string; testName: string; file: string }>
|
|
1078
|
-
>(depsKey);
|
|
1079
|
-
return deps ?? [];
|
|
1080
|
-
} catch {
|
|
1081
|
-
return [];
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
private createFlakyRecommendation(
|
|
1086
|
-
flakyAnalysis: FlakyTestAnalysis,
|
|
1087
|
-
_testFailure: TestFailure
|
|
1088
|
-
): DefectRecommendation {
|
|
1089
|
-
const pattern = flakyAnalysis.pattern ?? 'unknown';
|
|
1090
|
-
|
|
1091
|
-
return {
|
|
1092
|
-
type: flakyAnalysis.failureRate && flakyAnalysis.failureRate > 0.5 ? 'quarantine' : 'retry',
|
|
1093
|
-
priority: flakyAnalysis.failureRate && flakyAnalysis.failureRate > 0.5 ? 'high' : 'medium',
|
|
1094
|
-
description: `Flaky test (${pattern} pattern, ${Math.round((flakyAnalysis.failureRate ?? 0) * 100)}% failure rate)`,
|
|
1095
|
-
action: flakyAnalysis.recommendation ?? 'Investigate and stabilize test',
|
|
1096
|
-
effort: pattern === 'unknown' ? 'high' : 'medium',
|
|
1097
|
-
confidence: flakyAnalysis.confidence,
|
|
1098
|
-
};
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
private createRootCauseRecommendations(
|
|
1102
|
-
rootCause: RootCauseAnalysis,
|
|
1103
|
-
_testFailure: TestFailure
|
|
1104
|
-
): DefectRecommendation[] {
|
|
1105
|
-
return rootCause.recommendations.slice(0, 3).map((rec, index) => ({
|
|
1106
|
-
type: 'fix' as const,
|
|
1107
|
-
priority: (index === 0 ? 'high' : index === 1 ? 'medium' : 'low') as
|
|
1108
|
-
| 'high'
|
|
1109
|
-
| 'medium'
|
|
1110
|
-
| 'low',
|
|
1111
|
-
description: rec,
|
|
1112
|
-
action: rec,
|
|
1113
|
-
effort: 'medium' as const,
|
|
1114
|
-
confidence: rootCause.confidence * (1 - index * 0.1),
|
|
1115
|
-
}));
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
private calculateOverallConfidence(
|
|
1119
|
-
flakyAnalysis: FlakyTestAnalysis,
|
|
1120
|
-
rootCause: RootCauseAnalysis | null,
|
|
1121
|
-
recommendations: DefectRecommendation[]
|
|
1122
|
-
): number {
|
|
1123
|
-
const weights = {
|
|
1124
|
-
flaky: 0.3,
|
|
1125
|
-
rootCause: 0.4,
|
|
1126
|
-
recommendations: 0.3,
|
|
1127
|
-
};
|
|
1128
|
-
|
|
1129
|
-
let confidence = 0;
|
|
1130
|
-
|
|
1131
|
-
// Flaky analysis confidence
|
|
1132
|
-
confidence += flakyAnalysis.confidence * weights.flaky;
|
|
1133
|
-
|
|
1134
|
-
// Root cause confidence
|
|
1135
|
-
if (rootCause) {
|
|
1136
|
-
confidence += rootCause.confidence * weights.rootCause;
|
|
1137
|
-
} else {
|
|
1138
|
-
confidence += 0.3 * weights.rootCause; // Base confidence if no root cause
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
// Recommendations confidence (average of top recommendations)
|
|
1142
|
-
if (recommendations.length > 0) {
|
|
1143
|
-
const avgRecConfidence =
|
|
1144
|
-
recommendations.slice(0, 3).reduce((sum, r) => sum + r.confidence, 0) /
|
|
1145
|
-
Math.min(3, recommendations.length);
|
|
1146
|
-
confidence += avgRecConfidence * weights.recommendations;
|
|
1147
|
-
} else {
|
|
1148
|
-
confidence += 0.3 * weights.recommendations;
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
return Math.min(1, Math.max(0, confidence));
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
private riskToSeverity(risk: number): Severity {
|
|
1155
|
-
if (risk >= 0.8) return 'critical';
|
|
1156
|
-
if (risk >= 0.6) return 'high';
|
|
1157
|
-
if (risk >= 0.4) return 'medium';
|
|
1158
|
-
if (risk >= 0.2) return 'low';
|
|
1159
|
-
return 'info';
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
private average(values: number[]): number {
|
|
1163
|
-
return values.length === 0
|
|
1164
|
-
? 0
|
|
1165
|
-
: values.reduce((a, b) => a + b, 0) / values.length;
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
// ============================================================================
|
|
1170
|
-
// Supporting Types
|
|
1171
|
-
// ============================================================================
|
|
1172
|
-
|
|
1173
|
-
interface TestExecutionHistory {
|
|
1174
|
-
runId: string;
|
|
1175
|
-
passed: boolean;
|
|
1176
|
-
duration: number;
|
|
1177
|
-
error?: string;
|
|
1178
|
-
timestamp: Date;
|
|
1179
|
-
}
|
|
1180
|
-
|
|
1181
|
-
interface PatternStats {
|
|
1182
|
-
patterns: Record<string, number>;
|
|
1183
|
-
totalInvestigations: number;
|
|
1184
|
-
}
|