agentic-qe 3.3.1 → 3.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/helpers/statusline-v3.cjs +96 -27
- package/README.md +6 -3
- package/package.json +1 -1
- package/scripts/sync-claude-flow.cjs +99 -0
- package/v3/CHANGELOG.md +133 -0
- package/v3/README.md +9 -5
- package/v3/dist/cli/bundle.js +60879 -51811
- package/v3/dist/coordination/consensus/domain-findings.d.ts +202 -0
- package/v3/dist/coordination/consensus/domain-findings.d.ts.map +1 -0
- package/v3/dist/coordination/consensus/domain-findings.js +66 -0
- package/v3/dist/coordination/consensus/domain-findings.js.map +1 -0
- package/v3/dist/coordination/consensus/index.d.ts +2 -0
- package/v3/dist/coordination/consensus/index.d.ts.map +1 -1
- package/v3/dist/coordination/consensus/index.js +4 -0
- package/v3/dist/coordination/consensus/index.js.map +1 -1
- package/v3/dist/coordination/index.d.ts +1 -0
- package/v3/dist/coordination/index.d.ts.map +1 -1
- package/v3/dist/coordination/index.js +4 -0
- package/v3/dist/coordination/index.js.map +1 -1
- package/v3/dist/coordination/mixins/consensus-enabled-domain.d.ts +225 -0
- package/v3/dist/coordination/mixins/consensus-enabled-domain.d.ts.map +1 -0
- package/v3/dist/coordination/mixins/consensus-enabled-domain.js +466 -0
- package/v3/dist/coordination/mixins/consensus-enabled-domain.js.map +1 -0
- package/v3/dist/coordination/mixins/index.d.ts +14 -0
- package/v3/dist/coordination/mixins/index.d.ts.map +1 -0
- package/v3/dist/coordination/mixins/index.js +28 -0
- package/v3/dist/coordination/mixins/index.js.map +1 -0
- package/v3/dist/coordination/mixins/mincut-aware-domain.d.ts +227 -0
- package/v3/dist/coordination/mixins/mincut-aware-domain.d.ts.map +1 -0
- package/v3/dist/coordination/mixins/mincut-aware-domain.js +368 -0
- package/v3/dist/coordination/mixins/mincut-aware-domain.js.map +1 -0
- package/v3/dist/coordination/queen-coordinator.d.ts +23 -1
- package/v3/dist/coordination/queen-coordinator.d.ts.map +1 -1
- package/v3/dist/coordination/queen-coordinator.js +131 -3
- package/v3/dist/coordination/queen-coordinator.js.map +1 -1
- package/v3/dist/coordination/task-executor.d.ts +21 -1
- package/v3/dist/coordination/task-executor.d.ts.map +1 -1
- package/v3/dist/coordination/task-executor.js +222 -5
- package/v3/dist/coordination/task-executor.js.map +1 -1
- package/v3/dist/domains/chaos-resilience/coordinator.d.ts +92 -0
- package/v3/dist/domains/chaos-resilience/coordinator.d.ts.map +1 -1
- package/v3/dist/domains/chaos-resilience/coordinator.js +241 -1
- package/v3/dist/domains/chaos-resilience/coordinator.js.map +1 -1
- package/v3/dist/domains/chaos-resilience/plugin.js +1 -1
- package/v3/dist/domains/chaos-resilience/plugin.js.map +1 -1
- package/v3/dist/domains/chaos-resilience/services/chaos-engineer.d.ts +29 -2
- package/v3/dist/domains/chaos-resilience/services/chaos-engineer.d.ts.map +1 -1
- package/v3/dist/domains/chaos-resilience/services/chaos-engineer.js +62 -3
- package/v3/dist/domains/chaos-resilience/services/chaos-engineer.js.map +1 -1
- package/v3/dist/domains/code-intelligence/coordinator.d.ts +112 -0
- package/v3/dist/domains/code-intelligence/coordinator.d.ts.map +1 -1
- package/v3/dist/domains/code-intelligence/coordinator.js +221 -0
- package/v3/dist/domains/code-intelligence/coordinator.js.map +1 -1
- package/v3/dist/domains/code-intelligence/services/knowledge-graph.d.ts +66 -2
- package/v3/dist/domains/code-intelligence/services/knowledge-graph.d.ts.map +1 -1
- package/v3/dist/domains/code-intelligence/services/knowledge-graph.js +253 -3
- package/v3/dist/domains/code-intelligence/services/knowledge-graph.js.map +1 -1
- package/v3/dist/domains/contract-testing/coordinator.d.ts +89 -1
- package/v3/dist/domains/contract-testing/coordinator.d.ts.map +1 -1
- package/v3/dist/domains/contract-testing/coordinator.js +222 -1
- package/v3/dist/domains/contract-testing/coordinator.js.map +1 -1
- package/v3/dist/domains/contract-testing/interfaces.d.ts +29 -1
- package/v3/dist/domains/contract-testing/interfaces.d.ts.map +1 -1
- package/v3/dist/domains/contract-testing/plugin.js +1 -1
- package/v3/dist/domains/contract-testing/plugin.js.map +1 -1
- package/v3/dist/domains/contract-testing/services/contract-validator.d.ts +29 -2
- package/v3/dist/domains/contract-testing/services/contract-validator.d.ts.map +1 -1
- package/v3/dist/domains/contract-testing/services/contract-validator.js +58 -3
- package/v3/dist/domains/contract-testing/services/contract-validator.js.map +1 -1
- package/v3/dist/domains/coverage-analysis/coordinator.d.ts +95 -2
- package/v3/dist/domains/coverage-analysis/coordinator.d.ts.map +1 -1
- package/v3/dist/domains/coverage-analysis/coordinator.js +274 -6
- package/v3/dist/domains/coverage-analysis/coordinator.js.map +1 -1
- package/v3/dist/domains/coverage-analysis/plugin.d.ts +6 -1
- package/v3/dist/domains/coverage-analysis/plugin.d.ts.map +1 -1
- package/v3/dist/domains/coverage-analysis/plugin.js +73 -0
- package/v3/dist/domains/coverage-analysis/plugin.js.map +1 -1
- package/v3/dist/domains/coverage-analysis/services/coverage-analyzer.d.ts +119 -3
- package/v3/dist/domains/coverage-analysis/services/coverage-analyzer.d.ts.map +1 -1
- package/v3/dist/domains/coverage-analysis/services/coverage-analyzer.js +267 -5
- package/v3/dist/domains/coverage-analysis/services/coverage-analyzer.js.map +1 -1
- package/v3/dist/domains/coverage-analysis/services/gap-detector.d.ts +111 -2
- package/v3/dist/domains/coverage-analysis/services/gap-detector.d.ts.map +1 -1
- package/v3/dist/domains/coverage-analysis/services/gap-detector.js +231 -3
- package/v3/dist/domains/coverage-analysis/services/gap-detector.js.map +1 -1
- package/v3/dist/domains/defect-intelligence/coordinator.d.ts +80 -1
- package/v3/dist/domains/defect-intelligence/coordinator.d.ts.map +1 -1
- package/v3/dist/domains/defect-intelligence/coordinator.js +262 -7
- package/v3/dist/domains/defect-intelligence/coordinator.js.map +1 -1
- package/v3/dist/domains/defect-intelligence/interfaces.d.ts +17 -0
- package/v3/dist/domains/defect-intelligence/interfaces.d.ts.map +1 -1
- package/v3/dist/domains/defect-intelligence/services/defect-predictor.d.ts +91 -2
- package/v3/dist/domains/defect-intelligence/services/defect-predictor.d.ts.map +1 -1
- package/v3/dist/domains/defect-intelligence/services/defect-predictor.js +274 -7
- package/v3/dist/domains/defect-intelligence/services/defect-predictor.js.map +1 -1
- package/v3/dist/domains/defect-intelligence/services/root-cause-analyzer.d.ts +79 -2
- package/v3/dist/domains/defect-intelligence/services/root-cause-analyzer.d.ts.map +1 -1
- package/v3/dist/domains/defect-intelligence/services/root-cause-analyzer.js +259 -3
- package/v3/dist/domains/defect-intelligence/services/root-cause-analyzer.js.map +1 -1
- package/v3/dist/domains/domain-interface.d.ts +194 -2
- package/v3/dist/domains/domain-interface.d.ts.map +1 -1
- package/v3/dist/domains/domain-interface.js +239 -0
- package/v3/dist/domains/domain-interface.js.map +1 -1
- package/v3/dist/domains/learning-optimization/coordinator.d.ts +171 -0
- package/v3/dist/domains/learning-optimization/coordinator.d.ts.map +1 -1
- package/v3/dist/domains/learning-optimization/coordinator.js +401 -1
- package/v3/dist/domains/learning-optimization/coordinator.js.map +1 -1
- package/v3/dist/domains/learning-optimization/index.d.ts +1 -1
- package/v3/dist/domains/learning-optimization/index.d.ts.map +1 -1
- package/v3/dist/domains/learning-optimization/index.js.map +1 -1
- package/v3/dist/domains/learning-optimization/interfaces.d.ts +18 -0
- package/v3/dist/domains/learning-optimization/interfaces.d.ts.map +1 -1
- package/v3/dist/domains/learning-optimization/plugin.js +1 -1
- package/v3/dist/domains/learning-optimization/plugin.js.map +1 -1
- package/v3/dist/domains/learning-optimization/services/learning-coordinator.d.ts +54 -2
- package/v3/dist/domains/learning-optimization/services/learning-coordinator.d.ts.map +1 -1
- package/v3/dist/domains/learning-optimization/services/learning-coordinator.js +90 -3
- package/v3/dist/domains/learning-optimization/services/learning-coordinator.js.map +1 -1
- package/v3/dist/domains/quality-assessment/coordinator.d.ts +127 -0
- package/v3/dist/domains/quality-assessment/coordinator.d.ts.map +1 -1
- package/v3/dist/domains/quality-assessment/coordinator.js +493 -7
- package/v3/dist/domains/quality-assessment/coordinator.js.map +1 -1
- package/v3/dist/domains/quality-assessment/interfaces.d.ts +22 -0
- package/v3/dist/domains/quality-assessment/interfaces.d.ts.map +1 -1
- package/v3/dist/domains/quality-assessment/plugin.d.ts +6 -1
- package/v3/dist/domains/quality-assessment/plugin.d.ts.map +1 -1
- package/v3/dist/domains/quality-assessment/plugin.js +67 -0
- package/v3/dist/domains/quality-assessment/plugin.js.map +1 -1
- package/v3/dist/domains/quality-assessment/services/deployment-advisor.d.ts +61 -2
- package/v3/dist/domains/quality-assessment/services/deployment-advisor.d.ts.map +1 -1
- package/v3/dist/domains/quality-assessment/services/deployment-advisor.js +213 -5
- package/v3/dist/domains/quality-assessment/services/deployment-advisor.js.map +1 -1
- package/v3/dist/domains/quality-assessment/services/quality-analyzer.d.ts +59 -4
- package/v3/dist/domains/quality-assessment/services/quality-analyzer.d.ts.map +1 -1
- package/v3/dist/domains/quality-assessment/services/quality-analyzer.js +195 -3
- package/v3/dist/domains/quality-assessment/services/quality-analyzer.js.map +1 -1
- package/v3/dist/domains/requirements-validation/coordinator.d.ts +78 -0
- package/v3/dist/domains/requirements-validation/coordinator.d.ts.map +1 -1
- package/v3/dist/domains/requirements-validation/coordinator.js +189 -0
- package/v3/dist/domains/requirements-validation/coordinator.js.map +1 -1
- package/v3/dist/domains/requirements-validation/interfaces.d.ts +4 -0
- package/v3/dist/domains/requirements-validation/interfaces.d.ts.map +1 -1
- package/v3/dist/domains/requirements-validation/services/requirements-validator.d.ts +106 -2
- package/v3/dist/domains/requirements-validation/services/requirements-validator.d.ts.map +1 -1
- package/v3/dist/domains/requirements-validation/services/requirements-validator.js +263 -3
- package/v3/dist/domains/requirements-validation/services/requirements-validator.js.map +1 -1
- package/v3/dist/domains/security-compliance/coordinator.d.ts +56 -1
- package/v3/dist/domains/security-compliance/coordinator.d.ts.map +1 -1
- package/v3/dist/domains/security-compliance/coordinator.js +241 -17
- package/v3/dist/domains/security-compliance/coordinator.js.map +1 -1
- package/v3/dist/domains/security-compliance/interfaces.d.ts +2 -0
- package/v3/dist/domains/security-compliance/interfaces.d.ts.map +1 -1
- package/v3/dist/domains/security-compliance/services/security-scanner.d.ts +33 -2
- package/v3/dist/domains/security-compliance/services/security-scanner.d.ts.map +1 -1
- package/v3/dist/domains/security-compliance/services/security-scanner.js +107 -3
- package/v3/dist/domains/security-compliance/services/security-scanner.js.map +1 -1
- package/v3/dist/domains/test-execution/coordinator.d.ts +89 -0
- package/v3/dist/domains/test-execution/coordinator.d.ts.map +1 -1
- package/v3/dist/domains/test-execution/coordinator.js +259 -2
- package/v3/dist/domains/test-execution/coordinator.js.map +1 -1
- package/v3/dist/domains/test-execution/plugin.d.ts +6 -1
- package/v3/dist/domains/test-execution/plugin.d.ts.map +1 -1
- package/v3/dist/domains/test-execution/plugin.js +77 -0
- package/v3/dist/domains/test-execution/plugin.js.map +1 -1
- package/v3/dist/domains/test-execution/services/test-executor.d.ts +30 -2
- package/v3/dist/domains/test-execution/services/test-executor.d.ts.map +1 -1
- package/v3/dist/domains/test-execution/services/test-executor.js +64 -3
- package/v3/dist/domains/test-execution/services/test-executor.js.map +1 -1
- package/v3/dist/domains/test-generation/coordinator.d.ts +137 -0
- package/v3/dist/domains/test-generation/coordinator.d.ts.map +1 -1
- package/v3/dist/domains/test-generation/coordinator.js +421 -1
- package/v3/dist/domains/test-generation/coordinator.js.map +1 -1
- package/v3/dist/domains/test-generation/interfaces.d.ts +2 -0
- package/v3/dist/domains/test-generation/interfaces.d.ts.map +1 -1
- package/v3/dist/domains/test-generation/plugin.d.ts +6 -1
- package/v3/dist/domains/test-generation/plugin.d.ts.map +1 -1
- package/v3/dist/domains/test-generation/plugin.js +84 -0
- package/v3/dist/domains/test-generation/plugin.js.map +1 -1
- package/v3/dist/domains/test-generation/services/test-generator.d.ts +32 -0
- package/v3/dist/domains/test-generation/services/test-generator.d.ts.map +1 -1
- package/v3/dist/domains/test-generation/services/test-generator.js +158 -3
- package/v3/dist/domains/test-generation/services/test-generator.js.map +1 -1
- package/v3/dist/domains/visual-accessibility/coordinator.d.ts +77 -0
- package/v3/dist/domains/visual-accessibility/coordinator.d.ts.map +1 -1
- package/v3/dist/domains/visual-accessibility/coordinator.js +210 -2
- package/v3/dist/domains/visual-accessibility/coordinator.js.map +1 -1
- package/v3/dist/domains/visual-accessibility/plugin.d.ts.map +1 -1
- package/v3/dist/domains/visual-accessibility/plugin.js +3 -3
- package/v3/dist/domains/visual-accessibility/plugin.js.map +1 -1
- package/v3/dist/domains/visual-accessibility/services/visual-tester.d.ts +47 -2
- package/v3/dist/domains/visual-accessibility/services/visual-tester.d.ts.map +1 -1
- package/v3/dist/domains/visual-accessibility/services/visual-tester.js +87 -3
- package/v3/dist/domains/visual-accessibility/services/visual-tester.js.map +1 -1
- package/v3/dist/kernel/interfaces.d.ts +54 -1
- package/v3/dist/kernel/interfaces.d.ts.map +1 -1
- package/v3/dist/learning/dream/dream-scheduler.d.ts +302 -0
- package/v3/dist/learning/dream/dream-scheduler.d.ts.map +1 -0
- package/v3/dist/learning/dream/dream-scheduler.js +551 -0
- package/v3/dist/learning/dream/dream-scheduler.js.map +1 -0
- package/v3/dist/learning/dream/index.d.ts +1 -0
- package/v3/dist/learning/dream/index.d.ts.map +1 -1
- package/v3/dist/learning/dream/index.js +4 -0
- package/v3/dist/learning/dream/index.js.map +1 -1
- package/v3/dist/learning/experience-capture-middleware.d.ts +119 -0
- package/v3/dist/learning/experience-capture-middleware.d.ts.map +1 -0
- package/v3/dist/learning/experience-capture-middleware.js +416 -0
- package/v3/dist/learning/experience-capture-middleware.js.map +1 -0
- package/v3/dist/mcp/bundle.js +83142 -70580
- package/v3/dist/mcp/handlers/core-handlers.d.ts.map +1 -1
- package/v3/dist/mcp/handlers/core-handlers.js +16 -2
- package/v3/dist/mcp/handlers/core-handlers.js.map +1 -1
- package/v3/dist/mcp/handlers/domain-handlers.d.ts +12 -13
- package/v3/dist/mcp/handlers/domain-handlers.d.ts.map +1 -1
- package/v3/dist/mcp/handlers/index.d.ts +1 -1
- package/v3/dist/mcp/handlers/index.d.ts.map +1 -1
- package/v3/dist/mcp/handlers/index.js +2 -2
- package/v3/dist/mcp/handlers/index.js.map +1 -1
- package/v3/dist/mcp/handlers/task-handlers.d.ts +1 -0
- package/v3/dist/mcp/handlers/task-handlers.d.ts.map +1 -1
- package/v3/dist/mcp/handlers/task-handlers.js +46 -12
- package/v3/dist/mcp/handlers/task-handlers.js.map +1 -1
- package/v3/dist/mcp/handlers/wrapped-domain-handlers.d.ts +30 -0
- package/v3/dist/mcp/handlers/wrapped-domain-handlers.d.ts.map +1 -0
- package/v3/dist/mcp/handlers/wrapped-domain-handlers.js +75 -0
- package/v3/dist/mcp/handlers/wrapped-domain-handlers.js.map +1 -0
- package/v3/dist/mcp/services/reasoning-bank-service.d.ts +87 -13
- package/v3/dist/mcp/services/reasoning-bank-service.d.ts.map +1 -1
- package/v3/dist/mcp/services/reasoning-bank-service.js +291 -31
- package/v3/dist/mcp/services/reasoning-bank-service.js.map +1 -1
- package/v3/dist/mcp/tools/chaos-resilience/inject.js +1 -1
- package/v3/dist/mcp/tools/chaos-resilience/inject.js.map +1 -1
- package/v3/dist/mcp/tools/contract-testing/validate.js +1 -1
- package/v3/dist/mcp/tools/contract-testing/validate.js.map +1 -1
- package/v3/dist/mcp/tools/learning-optimization/optimize.js +1 -1
- package/v3/dist/mcp/tools/learning-optimization/optimize.js.map +1 -1
- package/v3/dist/mcp/tools/visual-accessibility/index.js +2 -2
- package/v3/dist/mcp/tools/visual-accessibility/index.js.map +1 -1
- package/v3/dist/routing/qe-agent-registry.d.ts +28 -1
- package/v3/dist/routing/qe-agent-registry.d.ts.map +1 -1
- package/v3/dist/routing/qe-agent-registry.js +116 -1
- package/v3/dist/routing/qe-agent-registry.js.map +1 -1
- package/v3/dist/shared/events/domain-events.d.ts +27 -0
- package/v3/dist/shared/events/domain-events.d.ts.map +1 -1
- package/v3/dist/shared/events/domain-events.js +1 -0
- package/v3/dist/shared/events/domain-events.js.map +1 -1
- package/v3/dist/sync/claude-flow-bridge.d.ts +63 -0
- package/v3/dist/sync/claude-flow-bridge.d.ts.map +1 -0
- package/v3/dist/sync/claude-flow-bridge.js +320 -0
- package/v3/dist/sync/claude-flow-bridge.js.map +1 -0
- package/v3/package.json +1 -1
|
@@ -2,11 +2,18 @@
|
|
|
2
2
|
* Agentic QE v3 - ReasoningBank Service
|
|
3
3
|
* ADR-051: Provides ReasoningBank integration for MCP task handlers
|
|
4
4
|
*
|
|
5
|
-
* This service bridges the
|
|
6
|
-
* enabling learning from task outcomes and
|
|
5
|
+
* This service bridges the EnhancedReasoningBankAdapter with MCP task execution,
|
|
6
|
+
* enabling learning from task outcomes, intelligent routing, and trajectory tracking.
|
|
7
|
+
*
|
|
8
|
+
* INTEGRATION FIX: Now uses EnhancedReasoningBankAdapter for full learning pipeline:
|
|
9
|
+
* - Trajectory tracking during task execution
|
|
10
|
+
* - Experience-guided routing decisions
|
|
11
|
+
* - Pattern evolution and consolidation
|
|
12
|
+
* - Synchronous learning (no fire-and-forget)
|
|
7
13
|
*/
|
|
8
|
-
import { type
|
|
9
|
-
import type
|
|
14
|
+
import { type Trajectory, type TrajectoryStep as TrackerTrajectoryStep, type TrajectoryOptions, type ExperienceGuidance, type EnhancedReasoningBankAdapterStats } from '../../integrations/agentic-flow/reasoning-bank/index.js';
|
|
15
|
+
import { type RealQERoutingRequest, type RealQERoutingResult, type RealQEReasoningBankStats } from '../../learning/real-qe-reasoning-bank.js';
|
|
16
|
+
import type { QEPattern, QEDomain } from '../../learning/qe-patterns.js';
|
|
10
17
|
/**
|
|
11
18
|
* Task outcome record for learning
|
|
12
19
|
*/
|
|
@@ -54,6 +61,18 @@ export interface TrajectoryStep {
|
|
|
54
61
|
/** Quality score (0-1) */
|
|
55
62
|
quality?: number;
|
|
56
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Enhanced routing result with experience guidance
|
|
66
|
+
*/
|
|
67
|
+
export interface EnhancedRoutingResult extends RealQERoutingResult {
|
|
68
|
+
experienceGuidance?: ExperienceGuidance;
|
|
69
|
+
similarTrajectories?: Array<{
|
|
70
|
+
id: string;
|
|
71
|
+
task: string;
|
|
72
|
+
outcome: string;
|
|
73
|
+
similarity: number;
|
|
74
|
+
}>;
|
|
75
|
+
}
|
|
57
76
|
/**
|
|
58
77
|
* ReasoningBank service configuration
|
|
59
78
|
*/
|
|
@@ -64,6 +83,12 @@ export interface ReasoningBankServiceConfig {
|
|
|
64
83
|
enableRouting: boolean;
|
|
65
84
|
/** Enable pattern guidance */
|
|
66
85
|
enableGuidance: boolean;
|
|
86
|
+
/** Enable trajectory tracking */
|
|
87
|
+
enableTrajectories: boolean;
|
|
88
|
+
/** Enable experience replay */
|
|
89
|
+
enableExperienceReplay: boolean;
|
|
90
|
+
/** Auto-store successful trajectories as experiences */
|
|
91
|
+
autoStoreExperiences: boolean;
|
|
67
92
|
/** Minimum quality score to store patterns */
|
|
68
93
|
minQualityThreshold: number;
|
|
69
94
|
}
|
|
@@ -75,13 +100,17 @@ export declare const DEFAULT_SERVICE_CONFIG: ReasoningBankServiceConfig;
|
|
|
75
100
|
* ReasoningBank Service
|
|
76
101
|
*
|
|
77
102
|
* Provides learning and routing capabilities for MCP task execution.
|
|
78
|
-
*
|
|
103
|
+
* Uses EnhancedReasoningBankAdapter for full learning pipeline including:
|
|
104
|
+
* - Trajectory tracking
|
|
105
|
+
* - Experience replay
|
|
106
|
+
* - Pattern evolution
|
|
107
|
+
* - HNSW-indexed pattern storage
|
|
79
108
|
*/
|
|
80
109
|
export declare class ReasoningBankService {
|
|
81
110
|
private static instance;
|
|
82
111
|
private static initPromise;
|
|
83
112
|
private readonly config;
|
|
84
|
-
private readonly
|
|
113
|
+
private readonly enhancedAdapter;
|
|
85
114
|
private disposed;
|
|
86
115
|
private patternsLoaded;
|
|
87
116
|
private qualityThresholdsFromPatterns;
|
|
@@ -90,6 +119,7 @@ export declare class ReasoningBankService {
|
|
|
90
119
|
private failedTasks;
|
|
91
120
|
private patternsStored;
|
|
92
121
|
private routingRequests;
|
|
122
|
+
private activeTrajectories;
|
|
93
123
|
private constructor();
|
|
94
124
|
/**
|
|
95
125
|
* Get or create the singleton service instance
|
|
@@ -104,6 +134,11 @@ export declare class ReasoningBankService {
|
|
|
104
134
|
* Falls back to hardcoded defaults if patterns unavailable
|
|
105
135
|
*/
|
|
106
136
|
private loadPatternsFromLoader;
|
|
137
|
+
/**
|
|
138
|
+
* INTEGRATION FIX: Seed initial QE patterns for bootstrap
|
|
139
|
+
* This ensures the system has baseline data to work with
|
|
140
|
+
*/
|
|
141
|
+
private seedInitialPatternsIfNeeded;
|
|
107
142
|
/**
|
|
108
143
|
* ADR-051: Get pattern loading status for health checks
|
|
109
144
|
*/
|
|
@@ -112,22 +147,51 @@ export declare class ReasoningBankService {
|
|
|
112
147
|
* ADR-051: Get quality thresholds from patterns (for debugging/reporting)
|
|
113
148
|
*/
|
|
114
149
|
getQualityThresholdsFromPatterns(): typeof this.qualityThresholdsFromPatterns;
|
|
150
|
+
/**
|
|
151
|
+
* Start tracking a task trajectory
|
|
152
|
+
* Call this when a task begins execution
|
|
153
|
+
*/
|
|
154
|
+
startTaskTrajectory(taskId: string, task: string, options?: TrajectoryOptions): Promise<string>;
|
|
155
|
+
/**
|
|
156
|
+
* Record a step in the current task trajectory
|
|
157
|
+
*/
|
|
158
|
+
recordTrajectoryStep(taskId: string, action: string, result: TrackerTrajectoryStep['result'], options?: {
|
|
159
|
+
quality?: number;
|
|
160
|
+
durationMs?: number;
|
|
161
|
+
tokensUsed?: number;
|
|
162
|
+
context?: Record<string, unknown>;
|
|
163
|
+
}): Promise<void>;
|
|
164
|
+
/**
|
|
165
|
+
* End a task trajectory and trigger learning
|
|
166
|
+
* Call this when a task completes
|
|
167
|
+
*/
|
|
168
|
+
endTaskTrajectory(taskId: string, success: boolean, feedback?: string): Promise<Trajectory | null>;
|
|
169
|
+
/**
|
|
170
|
+
* Get active trajectory ID for a task
|
|
171
|
+
*/
|
|
172
|
+
getActiveTrajectoryId(taskId: string): string | undefined;
|
|
115
173
|
/**
|
|
116
174
|
* Record a task outcome for learning
|
|
117
|
-
*
|
|
118
|
-
* This is called after task execution to learn from the outcome.
|
|
175
|
+
* INTEGRATION FIX: Now synchronous (awaited) to ensure learning occurs
|
|
119
176
|
*/
|
|
120
177
|
recordTaskOutcome(outcome: TaskOutcome): Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* INTEGRATION FIX: Update agent performance metrics from task outcome
|
|
180
|
+
*/
|
|
181
|
+
private updateAgentPerformanceFromOutcome;
|
|
121
182
|
/**
|
|
122
183
|
* Store a successful task as a reusable pattern
|
|
123
184
|
*/
|
|
124
185
|
private storeTaskPattern;
|
|
125
186
|
/**
|
|
126
|
-
* Get routing recommendation
|
|
127
|
-
*
|
|
128
|
-
* Uses pattern similarity to recommend the best agent and approach.
|
|
187
|
+
* Get routing recommendation with experience guidance
|
|
188
|
+
* INTEGRATION FIX: Uses routeTaskWithExperience for enhanced routing
|
|
129
189
|
*/
|
|
130
|
-
getRoutingRecommendation(request: RealQERoutingRequest): Promise<
|
|
190
|
+
getRoutingRecommendation(request: RealQERoutingRequest): Promise<EnhancedRoutingResult>;
|
|
191
|
+
/**
|
|
192
|
+
* Get experience guidance for a task (without routing)
|
|
193
|
+
*/
|
|
194
|
+
getExperienceGuidance(task: string, domain?: QEDomain): Promise<ExperienceGuidance | null>;
|
|
131
195
|
/**
|
|
132
196
|
* Get guidance for a task
|
|
133
197
|
*/
|
|
@@ -151,8 +215,10 @@ export declare class ReasoningBankService {
|
|
|
151
215
|
patternsStored: number;
|
|
152
216
|
routingRequests: number;
|
|
153
217
|
patternsLoaded: boolean;
|
|
218
|
+
activeTrajectories: number;
|
|
154
219
|
};
|
|
155
220
|
reasoningBank: RealQEReasoningBankStats;
|
|
221
|
+
adapter: EnhancedReasoningBankAdapterStats;
|
|
156
222
|
}>;
|
|
157
223
|
/**
|
|
158
224
|
* Create fallback routing when service unavailable
|
|
@@ -182,5 +248,13 @@ export declare function recordTaskOutcome(outcome: TaskOutcome): Promise<void>;
|
|
|
182
248
|
/**
|
|
183
249
|
* Get routing recommendation (shorthand)
|
|
184
250
|
*/
|
|
185
|
-
export declare function getRoutingRecommendation(request: RealQERoutingRequest): Promise<
|
|
251
|
+
export declare function getRoutingRecommendation(request: RealQERoutingRequest): Promise<EnhancedRoutingResult>;
|
|
252
|
+
/**
|
|
253
|
+
* Start task trajectory (shorthand)
|
|
254
|
+
*/
|
|
255
|
+
export declare function startTaskTrajectory(taskId: string, task: string, options?: TrajectoryOptions): Promise<string>;
|
|
256
|
+
/**
|
|
257
|
+
* End task trajectory (shorthand)
|
|
258
|
+
*/
|
|
259
|
+
export declare function endTaskTrajectory(taskId: string, success: boolean, feedback?: string): Promise<Trajectory | null>;
|
|
186
260
|
//# sourceMappingURL=reasoning-bank-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reasoning-bank-service.d.ts","sourceRoot":"","sources":["../../../src/mcp/services/reasoning-bank-service.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"reasoning-bank-service.d.ts","sourceRoot":"","sources":["../../../src/mcp/services/reasoning-bank-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,cAAc,IAAI,qBAAqB,EAC5C,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,iCAAiC,EACvC,MAAM,yDAAyD,CAAC;AACjE,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EAExB,KAAK,wBAAwB,EAC9B,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAQzE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,cAAc;IACd,MAAM,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,IAAI,E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AAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAG5B"}
|
|
@@ -2,11 +2,18 @@
|
|
|
2
2
|
* Agentic QE v3 - ReasoningBank Service
|
|
3
3
|
* ADR-051: Provides ReasoningBank integration for MCP task handlers
|
|
4
4
|
*
|
|
5
|
-
* This service bridges the
|
|
6
|
-
* enabling learning from task outcomes and
|
|
5
|
+
* This service bridges the EnhancedReasoningBankAdapter with MCP task execution,
|
|
6
|
+
* enabling learning from task outcomes, intelligent routing, and trajectory tracking.
|
|
7
|
+
*
|
|
8
|
+
* INTEGRATION FIX: Now uses EnhancedReasoningBankAdapter for full learning pipeline:
|
|
9
|
+
* - Trajectory tracking during task execution
|
|
10
|
+
* - Experience-guided routing decisions
|
|
11
|
+
* - Pattern evolution and consolidation
|
|
12
|
+
* - Synchronous learning (no fire-and-forget)
|
|
7
13
|
*/
|
|
8
|
-
import {
|
|
9
|
-
import { getPatternLoader } from '../../integrations/agentic-flow/pattern-loader';
|
|
14
|
+
import { createEnhancedReasoningBank, } from '../../integrations/agentic-flow/reasoning-bank/index.js';
|
|
15
|
+
import { getPatternLoader } from '../../integrations/agentic-flow/pattern-loader.js';
|
|
16
|
+
import { updateAgentPerformance } from '../../routing/qe-agent-registry.js';
|
|
10
17
|
/**
|
|
11
18
|
* Default configuration
|
|
12
19
|
*/
|
|
@@ -14,6 +21,9 @@ export const DEFAULT_SERVICE_CONFIG = {
|
|
|
14
21
|
enableLearning: true,
|
|
15
22
|
enableRouting: true,
|
|
16
23
|
enableGuidance: true,
|
|
24
|
+
enableTrajectories: true,
|
|
25
|
+
enableExperienceReplay: true,
|
|
26
|
+
autoStoreExperiences: true,
|
|
17
27
|
minQualityThreshold: 0.6,
|
|
18
28
|
};
|
|
19
29
|
// ============================================================================
|
|
@@ -23,13 +33,17 @@ export const DEFAULT_SERVICE_CONFIG = {
|
|
|
23
33
|
* ReasoningBank Service
|
|
24
34
|
*
|
|
25
35
|
* Provides learning and routing capabilities for MCP task execution.
|
|
26
|
-
*
|
|
36
|
+
* Uses EnhancedReasoningBankAdapter for full learning pipeline including:
|
|
37
|
+
* - Trajectory tracking
|
|
38
|
+
* - Experience replay
|
|
39
|
+
* - Pattern evolution
|
|
40
|
+
* - HNSW-indexed pattern storage
|
|
27
41
|
*/
|
|
28
42
|
export class ReasoningBankService {
|
|
29
43
|
static instance = null;
|
|
30
44
|
static initPromise = null;
|
|
31
45
|
config;
|
|
32
|
-
|
|
46
|
+
enhancedAdapter;
|
|
33
47
|
disposed = false;
|
|
34
48
|
// ADR-051: Pattern loading status
|
|
35
49
|
patternsLoaded = false;
|
|
@@ -40,9 +54,11 @@ export class ReasoningBankService {
|
|
|
40
54
|
failedTasks = 0;
|
|
41
55
|
patternsStored = 0;
|
|
42
56
|
routingRequests = 0;
|
|
43
|
-
|
|
57
|
+
// INTEGRATION FIX: Track active trajectories per task
|
|
58
|
+
activeTrajectories = new Map();
|
|
59
|
+
constructor(config, enhancedAdapter) {
|
|
44
60
|
this.config = config;
|
|
45
|
-
this.
|
|
61
|
+
this.enhancedAdapter = enhancedAdapter;
|
|
46
62
|
}
|
|
47
63
|
/**
|
|
48
64
|
* Get or create the singleton service instance
|
|
@@ -71,16 +87,21 @@ export class ReasoningBankService {
|
|
|
71
87
|
...DEFAULT_SERVICE_CONFIG,
|
|
72
88
|
...config,
|
|
73
89
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
90
|
+
// INTEGRATION FIX: Use EnhancedReasoningBankAdapter instead of RealQEReasoningBank
|
|
91
|
+
const enhancedAdapter = createEnhancedReasoningBank({
|
|
92
|
+
enableTrajectories: fullConfig.enableTrajectories,
|
|
93
|
+
enableExperienceReplay: fullConfig.enableExperienceReplay,
|
|
94
|
+
enablePatternEvolution: true,
|
|
95
|
+
autoStoreExperiences: fullConfig.autoStoreExperiences,
|
|
96
|
+
autoConsolidate: true,
|
|
78
97
|
});
|
|
79
|
-
await
|
|
80
|
-
const service = new ReasoningBankService(fullConfig,
|
|
98
|
+
await enhancedAdapter.initialize();
|
|
99
|
+
const service = new ReasoningBankService(fullConfig, enhancedAdapter);
|
|
81
100
|
// ADR-051: Load quality thresholds from PatternLoader
|
|
82
101
|
await service.loadPatternsFromLoader();
|
|
83
|
-
|
|
102
|
+
// INTEGRATION FIX: Seed initial patterns if none exist
|
|
103
|
+
await service.seedInitialPatternsIfNeeded();
|
|
104
|
+
console.error('[ReasoningBankService] Initialized with EnhancedReasoningBankAdapter (trajectory + experience + evolution)');
|
|
84
105
|
return service;
|
|
85
106
|
}
|
|
86
107
|
/**
|
|
@@ -108,6 +129,102 @@ export class ReasoningBankService {
|
|
|
108
129
|
}
|
|
109
130
|
this.patternsLoaded = false;
|
|
110
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* INTEGRATION FIX: Seed initial QE patterns for bootstrap
|
|
134
|
+
* This ensures the system has baseline data to work with
|
|
135
|
+
*/
|
|
136
|
+
async seedInitialPatternsIfNeeded() {
|
|
137
|
+
try {
|
|
138
|
+
const stats = await this.enhancedAdapter.getStats();
|
|
139
|
+
if (stats.reasoningBank.totalPatterns > 0) {
|
|
140
|
+
console.error(`[ReasoningBankService] Found ${stats.reasoningBank.totalPatterns} existing patterns, skipping seed`);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
console.error('[ReasoningBankService] Seeding initial QE patterns...');
|
|
144
|
+
// Helper to create template variables
|
|
145
|
+
const makeVar = (name, type = 'string', required = false) => ({
|
|
146
|
+
name,
|
|
147
|
+
type,
|
|
148
|
+
required,
|
|
149
|
+
description: `${name} parameter`,
|
|
150
|
+
});
|
|
151
|
+
const seedPatterns = [
|
|
152
|
+
{
|
|
153
|
+
patternType: 'test-template',
|
|
154
|
+
name: 'unit-test-generation',
|
|
155
|
+
description: 'Generate comprehensive unit tests for TypeScript/JavaScript modules',
|
|
156
|
+
domain: 'test-generation',
|
|
157
|
+
template: {
|
|
158
|
+
type: 'workflow',
|
|
159
|
+
content: 'Analyze module exports, identify edge cases, generate Jest/Vitest tests with proper mocking',
|
|
160
|
+
variables: [makeVar('modulePath'), makeVar('framework')],
|
|
161
|
+
},
|
|
162
|
+
context: { tags: ['unit', 'typescript', 'jest', 'vitest'] },
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
patternType: 'coverage-strategy',
|
|
166
|
+
name: 'coverage-gap-analysis',
|
|
167
|
+
description: 'Identify untested code paths and recommend targeted tests',
|
|
168
|
+
domain: 'coverage-analysis',
|
|
169
|
+
template: {
|
|
170
|
+
type: 'workflow',
|
|
171
|
+
content: 'Parse coverage report, identify uncovered branches, prioritize by risk, generate recommendations',
|
|
172
|
+
variables: [makeVar('coveragePath'), makeVar('threshold', 'number')],
|
|
173
|
+
},
|
|
174
|
+
context: { tags: ['coverage', 'analysis', 'risk'] },
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
patternType: 'test-template',
|
|
178
|
+
name: 'integration-test-generation',
|
|
179
|
+
description: 'Generate integration tests for API endpoints and service interactions',
|
|
180
|
+
domain: 'test-generation',
|
|
181
|
+
template: {
|
|
182
|
+
type: 'workflow',
|
|
183
|
+
content: 'Identify API contracts, generate request/response tests, validate error handling',
|
|
184
|
+
variables: [makeVar('apiPath'), makeVar('framework')],
|
|
185
|
+
},
|
|
186
|
+
context: { tags: ['integration', 'api', 'contract'] },
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
patternType: 'flaky-fix',
|
|
190
|
+
name: 'flaky-test-remediation',
|
|
191
|
+
description: 'Detect and fix flaky tests through pattern analysis',
|
|
192
|
+
domain: 'test-execution',
|
|
193
|
+
template: {
|
|
194
|
+
type: 'workflow',
|
|
195
|
+
content: 'Analyze test history, identify timing/race conditions, apply stabilization patterns',
|
|
196
|
+
variables: [makeVar('testPath'), makeVar('retryCount', 'number')],
|
|
197
|
+
},
|
|
198
|
+
context: { tags: ['flaky', 'stability', 'retry'] },
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
patternType: 'error-handling',
|
|
202
|
+
name: 'security-vulnerability-scan',
|
|
203
|
+
description: 'Scan code for security vulnerabilities using OWASP patterns',
|
|
204
|
+
domain: 'security-compliance',
|
|
205
|
+
template: {
|
|
206
|
+
type: 'workflow',
|
|
207
|
+
content: 'Run SAST analysis, check for injection risks, validate authentication/authorization',
|
|
208
|
+
variables: [makeVar('targetPath'), makeVar('severity')],
|
|
209
|
+
},
|
|
210
|
+
context: { tags: ['security', 'owasp', 'sast'] },
|
|
211
|
+
},
|
|
212
|
+
];
|
|
213
|
+
for (const pattern of seedPatterns) {
|
|
214
|
+
try {
|
|
215
|
+
await this.enhancedAdapter.storePattern(pattern);
|
|
216
|
+
this.patternsStored++;
|
|
217
|
+
}
|
|
218
|
+
catch (err) {
|
|
219
|
+
console.error(`[ReasoningBankService] Failed to seed pattern ${pattern.name}:`, err);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
console.error(`[ReasoningBankService] Seeded ${seedPatterns.length} initial patterns`);
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
console.error('[ReasoningBankService] Failed to seed patterns:', error);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
111
228
|
/**
|
|
112
229
|
* ADR-051: Get pattern loading status for health checks
|
|
113
230
|
*/
|
|
@@ -120,10 +237,85 @@ export class ReasoningBankService {
|
|
|
120
237
|
getQualityThresholdsFromPatterns() {
|
|
121
238
|
return this.qualityThresholdsFromPatterns;
|
|
122
239
|
}
|
|
240
|
+
// ============================================================================
|
|
241
|
+
// INTEGRATION FIX: Trajectory Tracking Methods
|
|
242
|
+
// ============================================================================
|
|
243
|
+
/**
|
|
244
|
+
* Start tracking a task trajectory
|
|
245
|
+
* Call this when a task begins execution
|
|
246
|
+
*/
|
|
247
|
+
async startTaskTrajectory(taskId, task, options = {}) {
|
|
248
|
+
if (!this.config.enableTrajectories || this.disposed) {
|
|
249
|
+
return taskId; // Return taskId as fallback trajectory ID
|
|
250
|
+
}
|
|
251
|
+
try {
|
|
252
|
+
const trajectoryId = await this.enhancedAdapter.startTaskTrajectory(task, options);
|
|
253
|
+
this.activeTrajectories.set(taskId, trajectoryId);
|
|
254
|
+
console.error(`[ReasoningBankService] Started trajectory: task=${taskId} trajectory=${trajectoryId}`);
|
|
255
|
+
return trajectoryId;
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
console.error('[ReasoningBankService] Failed to start trajectory:', error);
|
|
259
|
+
return taskId;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Record a step in the current task trajectory
|
|
264
|
+
*/
|
|
265
|
+
async recordTrajectoryStep(taskId, action, result, options) {
|
|
266
|
+
if (!this.config.enableTrajectories || this.disposed) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const trajectoryId = this.activeTrajectories.get(taskId);
|
|
270
|
+
if (!trajectoryId) {
|
|
271
|
+
console.error(`[ReasoningBankService] No active trajectory for task ${taskId}`);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
try {
|
|
275
|
+
await this.enhancedAdapter.recordTaskStep(trajectoryId, action, result, options);
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
console.error('[ReasoningBankService] Failed to record trajectory step:', error);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* End a task trajectory and trigger learning
|
|
283
|
+
* Call this when a task completes
|
|
284
|
+
*/
|
|
285
|
+
async endTaskTrajectory(taskId, success, feedback) {
|
|
286
|
+
if (!this.config.enableTrajectories || this.disposed) {
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
const trajectoryId = this.activeTrajectories.get(taskId);
|
|
290
|
+
if (!trajectoryId) {
|
|
291
|
+
console.error(`[ReasoningBankService] No active trajectory for task ${taskId}`);
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
try {
|
|
295
|
+
const trajectory = await this.enhancedAdapter.endTaskTrajectory(trajectoryId, success, feedback);
|
|
296
|
+
this.activeTrajectories.delete(taskId);
|
|
297
|
+
console.error(`[ReasoningBankService] Ended trajectory: task=${taskId} success=${success} ` +
|
|
298
|
+
`steps=${trajectory.steps.length} quality=${trajectory.metrics.averageQuality.toFixed(2)}`);
|
|
299
|
+
return trajectory;
|
|
300
|
+
}
|
|
301
|
+
catch (error) {
|
|
302
|
+
console.error('[ReasoningBankService] Failed to end trajectory:', error);
|
|
303
|
+
this.activeTrajectories.delete(taskId);
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Get active trajectory ID for a task
|
|
309
|
+
*/
|
|
310
|
+
getActiveTrajectoryId(taskId) {
|
|
311
|
+
return this.activeTrajectories.get(taskId);
|
|
312
|
+
}
|
|
313
|
+
// ============================================================================
|
|
314
|
+
// Record Task Outcome (Synchronous Learning)
|
|
315
|
+
// ============================================================================
|
|
123
316
|
/**
|
|
124
317
|
* Record a task outcome for learning
|
|
125
|
-
*
|
|
126
|
-
* This is called after task execution to learn from the outcome.
|
|
318
|
+
* INTEGRATION FIX: Now synchronous (awaited) to ensure learning occurs
|
|
127
319
|
*/
|
|
128
320
|
async recordTaskOutcome(outcome) {
|
|
129
321
|
if (!this.config.enableLearning || this.disposed) {
|
|
@@ -151,18 +343,44 @@ export class ReasoningBankService {
|
|
|
151
343
|
},
|
|
152
344
|
feedback: outcome.error,
|
|
153
345
|
};
|
|
154
|
-
await this.
|
|
346
|
+
await this.enhancedAdapter.recordPatternOutcome(learningOutcome);
|
|
155
347
|
// If high quality, store as a pattern
|
|
156
348
|
if (outcome.success &&
|
|
157
349
|
(outcome.qualityScore || 0.5) >= this.config.minQualityThreshold) {
|
|
158
350
|
await this.storeTaskPattern(outcome);
|
|
159
351
|
this.patternsStored++;
|
|
160
352
|
}
|
|
353
|
+
// INTEGRATION FIX: Update agent performance metrics
|
|
354
|
+
if (outcome.agentId) {
|
|
355
|
+
await this.updateAgentPerformanceFromOutcome(outcome);
|
|
356
|
+
}
|
|
161
357
|
console.error(`[ReasoningBankService] Recorded outcome: task=${outcome.taskId} ` +
|
|
162
358
|
`success=${outcome.success} quality=${outcome.qualityScore?.toFixed(2) || 'N/A'}`);
|
|
163
359
|
}
|
|
164
360
|
catch (error) {
|
|
165
361
|
console.error('[ReasoningBankService] Failed to record outcome:', error);
|
|
362
|
+
// INTEGRATION FIX: Re-throw to ensure caller knows learning failed
|
|
363
|
+
throw error;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* INTEGRATION FIX: Update agent performance metrics from task outcome
|
|
368
|
+
*/
|
|
369
|
+
async updateAgentPerformanceFromOutcome(outcome) {
|
|
370
|
+
if (!outcome.agentId)
|
|
371
|
+
return;
|
|
372
|
+
try {
|
|
373
|
+
updateAgentPerformance(outcome.agentId, {
|
|
374
|
+
success: outcome.success,
|
|
375
|
+
executionTimeMs: outcome.executionTimeMs,
|
|
376
|
+
qualityScore: outcome.qualityScore,
|
|
377
|
+
});
|
|
378
|
+
console.error(`[ReasoningBankService] Updated agent performance: agent=${outcome.agentId} ` +
|
|
379
|
+
`success=${outcome.success} duration=${outcome.executionTimeMs}ms`);
|
|
380
|
+
}
|
|
381
|
+
catch (error) {
|
|
382
|
+
// Don't fail the whole operation if performance update fails
|
|
383
|
+
console.error('[ReasoningBankService] Failed to update agent performance:', error);
|
|
166
384
|
}
|
|
167
385
|
}
|
|
168
386
|
/**
|
|
@@ -177,7 +395,7 @@ export class ReasoningBankService {
|
|
|
177
395
|
outcome.agentId ? `agent:${outcome.agentId}` : undefined,
|
|
178
396
|
outcome.modelTier ? `tier:${outcome.modelTier}` : undefined,
|
|
179
397
|
].filter((t) => t !== undefined);
|
|
180
|
-
await this.
|
|
398
|
+
await this.enhancedAdapter.storePattern({
|
|
181
399
|
patternType: 'test-template',
|
|
182
400
|
name: `${outcome.taskType}-${outcome.domain || 'general'}`,
|
|
183
401
|
description: outcome.task,
|
|
@@ -199,10 +417,12 @@ export class ReasoningBankService {
|
|
|
199
417
|
console.error('[ReasoningBankService] Failed to store pattern:', error);
|
|
200
418
|
}
|
|
201
419
|
}
|
|
420
|
+
// ============================================================================
|
|
421
|
+
// INTEGRATION FIX: Experience-Guided Routing
|
|
422
|
+
// ============================================================================
|
|
202
423
|
/**
|
|
203
|
-
* Get routing recommendation
|
|
204
|
-
*
|
|
205
|
-
* Uses pattern similarity to recommend the best agent and approach.
|
|
424
|
+
* Get routing recommendation with experience guidance
|
|
425
|
+
* INTEGRATION FIX: Uses routeTaskWithExperience for enhanced routing
|
|
206
426
|
*/
|
|
207
427
|
async getRoutingRecommendation(request) {
|
|
208
428
|
if (!this.config.enableRouting || this.disposed) {
|
|
@@ -210,20 +430,43 @@ export class ReasoningBankService {
|
|
|
210
430
|
}
|
|
211
431
|
this.routingRequests++;
|
|
212
432
|
try {
|
|
213
|
-
|
|
433
|
+
// INTEGRATION FIX: Use experience-guided routing
|
|
434
|
+
const result = await this.enhancedAdapter.routeTaskWithExperience(request);
|
|
214
435
|
if (!result.success) {
|
|
215
436
|
console.error('[ReasoningBankService] Routing returned error:', result.error);
|
|
216
437
|
return this.createFallbackRouting(request);
|
|
217
438
|
}
|
|
439
|
+
const enhancedResult = result.value;
|
|
440
|
+
// Log experience guidance if available
|
|
441
|
+
if (enhancedResult.experienceGuidance) {
|
|
442
|
+
console.error(`[ReasoningBankService] Experience guidance: strategy="${enhancedResult.experienceGuidance.recommendedStrategy}" ` +
|
|
443
|
+
`confidence=${enhancedResult.experienceGuidance.confidence.toFixed(2)} ` +
|
|
444
|
+
`tokenSavings=${enhancedResult.experienceGuidance.estimatedTokenSavings}`);
|
|
445
|
+
}
|
|
218
446
|
console.error(`[ReasoningBankService] Routing: task="${request.task.slice(0, 50)}..." ` +
|
|
219
|
-
|
|
220
|
-
return
|
|
447
|
+
`-> agent=${enhancedResult.recommendedAgent} confidence=${enhancedResult.confidence.toFixed(2)}`);
|
|
448
|
+
return enhancedResult;
|
|
221
449
|
}
|
|
222
450
|
catch (error) {
|
|
223
451
|
console.error('[ReasoningBankService] Routing failed:', error);
|
|
224
452
|
return this.createFallbackRouting(request);
|
|
225
453
|
}
|
|
226
454
|
}
|
|
455
|
+
/**
|
|
456
|
+
* Get experience guidance for a task (without routing)
|
|
457
|
+
*/
|
|
458
|
+
async getExperienceGuidance(task, domain) {
|
|
459
|
+
if (!this.config.enableExperienceReplay || this.disposed) {
|
|
460
|
+
return null;
|
|
461
|
+
}
|
|
462
|
+
try {
|
|
463
|
+
return await this.enhancedAdapter.getExperienceGuidance(task, domain);
|
|
464
|
+
}
|
|
465
|
+
catch (error) {
|
|
466
|
+
console.error('[ReasoningBankService] Failed to get experience guidance:', error);
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
227
470
|
/**
|
|
228
471
|
* Get guidance for a task
|
|
229
472
|
*/
|
|
@@ -232,7 +475,7 @@ export class ReasoningBankService {
|
|
|
232
475
|
return [];
|
|
233
476
|
}
|
|
234
477
|
try {
|
|
235
|
-
const result = await this.
|
|
478
|
+
const result = await this.enhancedAdapter.routeTaskWithExperience({
|
|
236
479
|
task,
|
|
237
480
|
domain,
|
|
238
481
|
});
|
|
@@ -254,7 +497,7 @@ export class ReasoningBankService {
|
|
|
254
497
|
return [];
|
|
255
498
|
}
|
|
256
499
|
try {
|
|
257
|
-
const results = await this.
|
|
500
|
+
const results = await this.enhancedAdapter.searchPatterns(query, {
|
|
258
501
|
limit: options?.limit || 10,
|
|
259
502
|
domain: options?.domain,
|
|
260
503
|
});
|
|
@@ -273,7 +516,7 @@ export class ReasoningBankService {
|
|
|
273
516
|
* Get service statistics
|
|
274
517
|
*/
|
|
275
518
|
async getStats() {
|
|
276
|
-
const
|
|
519
|
+
const adapterStats = await this.enhancedAdapter.getStats();
|
|
277
520
|
return {
|
|
278
521
|
service: {
|
|
279
522
|
tasksRecorded: this.tasksRecorded,
|
|
@@ -282,9 +525,11 @@ export class ReasoningBankService {
|
|
|
282
525
|
successRate: this.tasksRecorded > 0 ? this.successfulTasks / this.tasksRecorded : 0,
|
|
283
526
|
patternsStored: this.patternsStored,
|
|
284
527
|
routingRequests: this.routingRequests,
|
|
285
|
-
patternsLoaded: this.patternsLoaded,
|
|
528
|
+
patternsLoaded: this.patternsLoaded,
|
|
529
|
+
activeTrajectories: this.activeTrajectories.size,
|
|
286
530
|
},
|
|
287
|
-
reasoningBank:
|
|
531
|
+
reasoningBank: adapterStats.reasoningBank,
|
|
532
|
+
adapter: adapterStats.adapter,
|
|
288
533
|
};
|
|
289
534
|
}
|
|
290
535
|
/**
|
|
@@ -315,7 +560,8 @@ export class ReasoningBankService {
|
|
|
315
560
|
if (this.disposed)
|
|
316
561
|
return;
|
|
317
562
|
this.disposed = true;
|
|
318
|
-
await this.
|
|
563
|
+
await this.enhancedAdapter.dispose();
|
|
564
|
+
this.activeTrajectories.clear();
|
|
319
565
|
ReasoningBankService.instance = null;
|
|
320
566
|
console.error('[ReasoningBankService] Disposed');
|
|
321
567
|
}
|
|
@@ -353,4 +599,18 @@ export async function getRoutingRecommendation(request) {
|
|
|
353
599
|
const service = await getReasoningBankService();
|
|
354
600
|
return service.getRoutingRecommendation(request);
|
|
355
601
|
}
|
|
602
|
+
/**
|
|
603
|
+
* Start task trajectory (shorthand)
|
|
604
|
+
*/
|
|
605
|
+
export async function startTaskTrajectory(taskId, task, options) {
|
|
606
|
+
const service = await getReasoningBankService();
|
|
607
|
+
return service.startTaskTrajectory(taskId, task, options);
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* End task trajectory (shorthand)
|
|
611
|
+
*/
|
|
612
|
+
export async function endTaskTrajectory(taskId, success, feedback) {
|
|
613
|
+
const service = await getReasoningBankService();
|
|
614
|
+
return service.endTaskTrajectory(taskId, success, feedback);
|
|
615
|
+
}
|
|
356
616
|
//# sourceMappingURL=reasoning-bank-service.js.map
|