agentic-qe 2.7.2 → 2.7.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/CHANGELOG.md +74 -0
- package/README.md +1 -1
- package/dist/core/memory/HNSWVectorMemory.js +1 -1
- package/dist/learning/QLearning.d.ts +101 -1
- package/dist/learning/QLearning.d.ts.map +1 -1
- package/dist/learning/QLearning.js +168 -0
- package/dist/learning/QLearning.js.map +1 -1
- package/dist/mcp/server-instructions.d.ts +1 -1
- package/dist/mcp/server-instructions.js +1 -1
- package/dist/planning/GOAPPlanner.d.ts +42 -0
- package/dist/planning/GOAPPlanner.d.ts.map +1 -1
- package/dist/planning/GOAPPlanner.js +151 -0
- package/dist/planning/GOAPPlanner.js.map +1 -1
- package/dist/planning/PlanLearning.d.ts +184 -0
- package/dist/planning/PlanLearning.d.ts.map +1 -0
- package/dist/planning/PlanLearning.js +526 -0
- package/dist/planning/PlanLearning.js.map +1 -0
- package/dist/planning/PlanSimilarity.d.ts +148 -0
- package/dist/planning/PlanSimilarity.d.ts.map +1 -0
- package/dist/planning/PlanSimilarity.js +463 -0
- package/dist/planning/PlanSimilarity.js.map +1 -0
- package/dist/planning/execution/PlanExecutor.d.ts +101 -2
- package/dist/planning/execution/PlanExecutor.d.ts.map +1 -1
- package/dist/planning/execution/PlanExecutor.js +587 -14
- package/dist/planning/execution/PlanExecutor.js.map +1 -1
- package/dist/planning/index.d.ts +2 -0
- package/dist/planning/index.d.ts.map +1 -1
- package/dist/planning/index.js +15 -4
- package/dist/planning/index.js.map +1 -1
- package/dist/planning/integration/GOAPQualityGateIntegration.d.ts +6 -0
- package/dist/planning/integration/GOAPQualityGateIntegration.d.ts.map +1 -1
- package/dist/planning/integration/GOAPQualityGateIntegration.js +7 -0
- package/dist/planning/integration/GOAPQualityGateIntegration.js.map +1 -1
- package/dist/planning/types.d.ts +2 -0
- package/dist/planning/types.d.ts.map +1 -1
- package/dist/planning/types.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,80 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.7.3] - 2025-12-30
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
#### GOAP Phase 5 & 6: Plan Learning & Live Agent Execution (Major Feature)
|
|
15
|
+
|
|
16
|
+
- **PlanLearning** (`src/planning/PlanLearning.ts`): Learning from execution outcomes
|
|
17
|
+
- EMA-based action success rate tracking (α=0.1 for stability)
|
|
18
|
+
- Q-Learning integration for GOAP action selection
|
|
19
|
+
- Execution history persistence in `goap_learning_history` table
|
|
20
|
+
- Per-action statistics in `goap_action_stats` table
|
|
21
|
+
- `learnFromExecution()` called automatically after plan execution
|
|
22
|
+
|
|
23
|
+
- **PlanSimilarity** (`src/planning/PlanSimilarity.ts`): Plan signature matching for reuse
|
|
24
|
+
- Feature vector extraction from goals and world states
|
|
25
|
+
- Cosine similarity for plan matching (<100ms lookup)
|
|
26
|
+
- Plan signatures stored in `goap_plan_signatures` table
|
|
27
|
+
- Configurable similarity threshold (default 0.75)
|
|
28
|
+
- `tryReuseSimilarPlan()` called before A* search
|
|
29
|
+
|
|
30
|
+
- **Live Agent Execution** (`src/planning/execution/PlanExecutor.ts` v1.2.0):
|
|
31
|
+
- Real agent spawning via AgentRegistry (not just dry-run)
|
|
32
|
+
- Output parsing for real-time world state updates:
|
|
33
|
+
- `parseTestOutput()`: Coverage and test result extraction
|
|
34
|
+
- `parseCoverageOutput()`: Coverage metric parsing
|
|
35
|
+
- `parseSecurityOutput()`: Vulnerability score calculation
|
|
36
|
+
- `parsePerformanceOutput()`: Performance metric extraction
|
|
37
|
+
- `parseAnalysisOutput()`: Code quality metric parsing
|
|
38
|
+
- Plan signature storage after successful live execution
|
|
39
|
+
- Learning feedback loop integration
|
|
40
|
+
|
|
41
|
+
- **GOAPPlanner Integration** (`src/planning/GOAPPlanner.ts`):
|
|
42
|
+
- `getPlanSimilarity()`: Access internal similarity matcher
|
|
43
|
+
- `setPlanReuseEnabled()`: Toggle plan reuse (default: enabled)
|
|
44
|
+
- `storePlanSignature()`: Persist plan for future reuse
|
|
45
|
+
- `recordPlanReuseOutcome()`: Track reuse success/failure
|
|
46
|
+
- `getPlanReuseStats()`: Reuse metrics
|
|
47
|
+
|
|
48
|
+
- **GOAPQualityGateIntegration** (`src/planning/integration/`):
|
|
49
|
+
- `getPlanner()`: Access internal planner for Phase 5/6 integration
|
|
50
|
+
|
|
51
|
+
### Changed
|
|
52
|
+
|
|
53
|
+
- **Planning Module** (`src/planning/index.ts`): Version 1.6.0
|
|
54
|
+
- Added 'Live agent execution via AgentRegistry' capability
|
|
55
|
+
- Added 'Real-time world state updates from agent output' capability
|
|
56
|
+
|
|
57
|
+
- **GOAPPlan Type** (`src/planning/types.ts`):
|
|
58
|
+
- Added `reusedFromPlanId?: string` for tracking plan reuse
|
|
59
|
+
- Added `similarityScore?: number` for reuse quality metrics
|
|
60
|
+
|
|
61
|
+
### Tests
|
|
62
|
+
|
|
63
|
+
- **New: Live Execution Tests** (`tests/integration/goap-live-execution.test.ts`): 17 tests
|
|
64
|
+
- 8 output parsing tests (all methods verified)
|
|
65
|
+
- 3 live execution tests (real agent spawning)
|
|
66
|
+
- 2 plan signature storage tests
|
|
67
|
+
- 2 agent type mapping tests
|
|
68
|
+
- 1 world state tracking test
|
|
69
|
+
- 1 live vs dry-run code path test
|
|
70
|
+
|
|
71
|
+
- **New: Phase 5 Integration Tests** (`tests/integration/goap-phase5-real-integration.test.ts`): 15 tests
|
|
72
|
+
- PlanSimilarity integration with GOAPPlanner
|
|
73
|
+
- PlanLearning integration with PlanExecutor
|
|
74
|
+
- End-to-end plan→execute→learn→reuse flow
|
|
75
|
+
- Performance verification (<100ms similarity lookup)
|
|
76
|
+
|
|
77
|
+
- **New: Plan Learning Tests** (`tests/integration/goap-plan-learning.test.ts`): 31 tests
|
|
78
|
+
- PlanLearning component tests
|
|
79
|
+
- PlanSimilarity component tests
|
|
80
|
+
- Q-Learning integration tests
|
|
81
|
+
|
|
82
|
+
- **Total GOAP Tests**: 84 tests passing
|
|
83
|
+
|
|
10
84
|
## [2.7.2] - 2025-12-29
|
|
11
85
|
|
|
12
86
|
### Added
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
[](https://smithery.ai/skills?ns=proffesor-for-testing&utm_source=github&utm_medium=badge)
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
**Version 2.7.
|
|
14
|
+
**Version 2.7.3** | [Changelog](CHANGELOG.md) | [Contributors](CONTRIBUTORS.md) | [Issues](https://github.com/proffesor-for-testing/agentic-qe/issues) | [Discussions](https://github.com/proffesor-for-testing/agentic-qe/discussions)
|
|
15
15
|
|
|
16
16
|
> AI-powered test automation that learns from every task, switches between 300+ AI models on-the-fly, scores code testability, visualizes agent activity in real-time, and improves autonomously overnight — with built-in safety guardrails and full observability.
|
|
17
17
|
|
|
@@ -7,9 +7,64 @@
|
|
|
7
7
|
* - Uses max Q-value for next state, not actual next action
|
|
8
8
|
* - Update rule: Q(s,a) ← Q(s,a) + α[r + γ·max(Q(s',a')) - Q(s,a)]
|
|
9
9
|
* - More aggressive than SARSA, finds optimal policy faster
|
|
10
|
+
*
|
|
11
|
+
* GOAP Integration (Phase 5):
|
|
12
|
+
* - Static methods for encoding WorldState to discrete state representation
|
|
13
|
+
* - GOAP action encoding for planning integration
|
|
14
|
+
* - Factory method for GOAP-configured learner
|
|
10
15
|
*/
|
|
11
16
|
import { AbstractRLLearner, RLConfig } from './algorithms/AbstractRLLearner';
|
|
12
|
-
import { TaskExperience, AgentAction } from './types';
|
|
17
|
+
import { TaskExperience, AgentAction, TaskState } from './types';
|
|
18
|
+
/**
|
|
19
|
+
* GOAP WorldState interface (imported type to avoid circular dependency)
|
|
20
|
+
*/
|
|
21
|
+
interface GOAPWorldState {
|
|
22
|
+
coverage: {
|
|
23
|
+
line: number;
|
|
24
|
+
branch: number;
|
|
25
|
+
function: number;
|
|
26
|
+
measured?: boolean;
|
|
27
|
+
};
|
|
28
|
+
quality: {
|
|
29
|
+
testsPassing: number;
|
|
30
|
+
securityScore: number;
|
|
31
|
+
performanceScore: number;
|
|
32
|
+
};
|
|
33
|
+
fleet: {
|
|
34
|
+
activeAgents: number;
|
|
35
|
+
availableAgents: string[];
|
|
36
|
+
};
|
|
37
|
+
resources: {
|
|
38
|
+
timeRemaining: number;
|
|
39
|
+
memoryAvailable: number;
|
|
40
|
+
parallelSlots: number;
|
|
41
|
+
};
|
|
42
|
+
context: {
|
|
43
|
+
environment: string;
|
|
44
|
+
changeSize: string;
|
|
45
|
+
riskLevel: string;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* GOAP Action interface (imported type to avoid circular dependency)
|
|
50
|
+
*/
|
|
51
|
+
interface GOAPAction {
|
|
52
|
+
id: string;
|
|
53
|
+
category: string;
|
|
54
|
+
agentType: string;
|
|
55
|
+
cost: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Discretized GOAP state for Q-table
|
|
59
|
+
*/
|
|
60
|
+
export interface DiscreteGOAPState {
|
|
61
|
+
coverageLevel: 'low' | 'medium' | 'high';
|
|
62
|
+
qualityLevel: 'low' | 'medium' | 'high';
|
|
63
|
+
securityLevel: 'low' | 'medium' | 'high';
|
|
64
|
+
fleetCapacity: 'limited' | 'normal' | 'high';
|
|
65
|
+
timeConstraint: 'tight' | 'normal' | 'relaxed';
|
|
66
|
+
riskLevel: string;
|
|
67
|
+
}
|
|
13
68
|
/**
|
|
14
69
|
* Q-learning configuration (same as base RL config)
|
|
15
70
|
*/
|
|
@@ -71,5 +126,50 @@ export declare class QLearning extends AbstractRLLearner {
|
|
|
71
126
|
type: 'on-policy' | 'off-policy';
|
|
72
127
|
stats: ReturnType<AbstractRLLearner['getStatistics']>;
|
|
73
128
|
};
|
|
129
|
+
/**
|
|
130
|
+
* Create a Q-Learner configured for GOAP planning
|
|
131
|
+
* Uses optimized hyperparameters for plan learning
|
|
132
|
+
*/
|
|
133
|
+
static createForGOAP(agentId?: string): QLearning;
|
|
134
|
+
/**
|
|
135
|
+
* Discretize WorldState for Q-table lookup
|
|
136
|
+
* Reduces continuous state space to discrete buckets
|
|
137
|
+
*/
|
|
138
|
+
static discretizeWorldState(state: GOAPWorldState): DiscreteGOAPState;
|
|
139
|
+
/**
|
|
140
|
+
* Encode discretized GOAP state to string key
|
|
141
|
+
*/
|
|
142
|
+
static encodeGOAPState(discrete: DiscreteGOAPState): string;
|
|
143
|
+
/**
|
|
144
|
+
* Encode GOAP action to string key
|
|
145
|
+
*/
|
|
146
|
+
static encodeGOAPAction(action: GOAPAction): string;
|
|
147
|
+
/**
|
|
148
|
+
* Convert WorldState to TaskState for Q-learning
|
|
149
|
+
*/
|
|
150
|
+
static worldStateToTaskState(state: GOAPWorldState): TaskState;
|
|
151
|
+
/**
|
|
152
|
+
* Convert GOAP action to AgentAction for Q-learning
|
|
153
|
+
*/
|
|
154
|
+
static goapActionToAgentAction(action: GOAPAction): AgentAction;
|
|
155
|
+
private static discretizeCoverage;
|
|
156
|
+
private static discretizeQuality;
|
|
157
|
+
private static discretizeSecurity;
|
|
158
|
+
private static discretizeFleet;
|
|
159
|
+
private static discretizeTime;
|
|
160
|
+
/**
|
|
161
|
+
* Calculate reward for GOAP action execution
|
|
162
|
+
* Used by PlanLearning for experience generation
|
|
163
|
+
*/
|
|
164
|
+
static calculateGOAPReward(success: boolean, executionTimeMs: number, expectedTimeMs: number, actionCost: number, coverageImprovement: number, qualityImprovement: number): number;
|
|
165
|
+
/**
|
|
166
|
+
* Get Q-value for a GOAP state-action pair
|
|
167
|
+
*/
|
|
168
|
+
getGOAPQValue(state: GOAPWorldState, action: GOAPAction): number;
|
|
169
|
+
/**
|
|
170
|
+
* Get best GOAP action from available actions
|
|
171
|
+
*/
|
|
172
|
+
getBestGOAPAction(state: GOAPWorldState, availableActions: GOAPAction[]): GOAPAction | null;
|
|
74
173
|
}
|
|
174
|
+
export {};
|
|
75
175
|
//# sourceMappingURL=QLearning.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QLearning.d.ts","sourceRoot":"","sources":["../../src/learning/QLearning.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"QLearning.d.ts","sourceRoot":"","sources":["../../src/learning/QLearning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGjE;;GAEG;AACH,UAAU,cAAc;IACtB,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACjF,OAAO,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC;QAAC,gBAAgB,EAAE,MAAM,CAAA;KAAE,CAAC;IACnF,KAAK,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAC3D,SAAS,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;IACrF,OAAO,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CACzE;AAED;;GAEG;AACH,UAAU,UAAU;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IAC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OAGG;IACH,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS;IAajD;;;OAGG;IACH,MAAM,CAAC,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,iBAAiB;IAWrE;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM;IAK3D;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM;IAKnD;;OAEG;IACH,MAAM,CAAC,qBAAqB,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS;IA0B9D;;OAEG;IACH,MAAM,CAAC,uBAAuB,CAAC,MAAM,EAAE,UAAU,GAAG,WAAW;IAa/D,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAMjC,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAMhC,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAMjC,OAAO,CAAC,MAAM,CAAC,eAAe;IAM9B,OAAO,CAAC,MAAM,CAAC,cAAc;IAM7B;;;OAGG;IACH,MAAM,CAAC,mBAAmB,CACxB,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,mBAAmB,EAAE,MAAM,EAC3B,kBAAkB,EAAE,MAAM,GACzB,MAAM;IAqBT;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM;IAMhE;;OAEG;IACH,iBAAiB,CAAC,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,UAAU,GAAG,IAAI;CAc5F"}
|
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
* - Uses max Q-value for next state, not actual next action
|
|
9
9
|
* - Update rule: Q(s,a) ← Q(s,a) + α[r + γ·max(Q(s',a')) - Q(s,a)]
|
|
10
10
|
* - More aggressive than SARSA, finds optimal policy faster
|
|
11
|
+
*
|
|
12
|
+
* GOAP Integration (Phase 5):
|
|
13
|
+
* - Static methods for encoding WorldState to discrete state representation
|
|
14
|
+
* - GOAP action encoding for planning integration
|
|
15
|
+
* - Factory method for GOAP-configured learner
|
|
11
16
|
*/
|
|
12
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
18
|
exports.QLearning = void 0;
|
|
@@ -160,6 +165,169 @@ class QLearning extends AbstractRLLearner_1.AbstractRLLearner {
|
|
|
160
165
|
stats: this.getStatistics()
|
|
161
166
|
};
|
|
162
167
|
}
|
|
168
|
+
// ============================================================================
|
|
169
|
+
// GOAP Integration Methods (Phase 5)
|
|
170
|
+
// ============================================================================
|
|
171
|
+
/**
|
|
172
|
+
* Create a Q-Learner configured for GOAP planning
|
|
173
|
+
* Uses optimized hyperparameters for plan learning
|
|
174
|
+
*/
|
|
175
|
+
static createForGOAP(agentId) {
|
|
176
|
+
return new QLearning({
|
|
177
|
+
learningRate: 0.1,
|
|
178
|
+
discountFactor: 0.95,
|
|
179
|
+
explorationRate: 0.2, // Lower exploration for planning
|
|
180
|
+
explorationDecay: 0.995,
|
|
181
|
+
minExplorationRate: 0.05,
|
|
182
|
+
useExperienceReplay: true,
|
|
183
|
+
replayBufferSize: 5000, // Smaller buffer for plans
|
|
184
|
+
batchSize: 32
|
|
185
|
+
}, agentId || 'goap-qlearner');
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Discretize WorldState for Q-table lookup
|
|
189
|
+
* Reduces continuous state space to discrete buckets
|
|
190
|
+
*/
|
|
191
|
+
static discretizeWorldState(state) {
|
|
192
|
+
return {
|
|
193
|
+
coverageLevel: QLearning.discretizeCoverage(state.coverage.line),
|
|
194
|
+
qualityLevel: QLearning.discretizeQuality(state.quality.testsPassing),
|
|
195
|
+
securityLevel: QLearning.discretizeSecurity(state.quality.securityScore),
|
|
196
|
+
fleetCapacity: QLearning.discretizeFleet(state.fleet.availableAgents.length),
|
|
197
|
+
timeConstraint: QLearning.discretizeTime(state.resources.timeRemaining),
|
|
198
|
+
riskLevel: state.context.riskLevel
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Encode discretized GOAP state to string key
|
|
203
|
+
*/
|
|
204
|
+
static encodeGOAPState(discrete) {
|
|
205
|
+
return `${discrete.coverageLevel}:${discrete.qualityLevel}:${discrete.securityLevel}:` +
|
|
206
|
+
`${discrete.fleetCapacity}:${discrete.timeConstraint}:${discrete.riskLevel}`;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Encode GOAP action to string key
|
|
210
|
+
*/
|
|
211
|
+
static encodeGOAPAction(action) {
|
|
212
|
+
const costLevel = action.cost < 1.5 ? 'L' : action.cost < 3 ? 'M' : 'H';
|
|
213
|
+
return `${action.category}:${action.agentType}:${costLevel}`;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Convert WorldState to TaskState for Q-learning
|
|
217
|
+
*/
|
|
218
|
+
static worldStateToTaskState(state) {
|
|
219
|
+
const discrete = QLearning.discretizeWorldState(state);
|
|
220
|
+
const complexityMap = {
|
|
221
|
+
low: 0.3, medium: 0.5, high: 0.8, critical: 1.0
|
|
222
|
+
};
|
|
223
|
+
const resourceMap = {
|
|
224
|
+
limited: 0.3, normal: 0.6, high: 0.9
|
|
225
|
+
};
|
|
226
|
+
return {
|
|
227
|
+
taskComplexity: complexityMap[discrete.riskLevel] ?? 0.5,
|
|
228
|
+
requiredCapabilities: [discrete.coverageLevel, discrete.qualityLevel, discrete.securityLevel],
|
|
229
|
+
contextFeatures: {
|
|
230
|
+
coverageLevel: discrete.coverageLevel,
|
|
231
|
+
qualityLevel: discrete.qualityLevel,
|
|
232
|
+
securityLevel: discrete.securityLevel,
|
|
233
|
+
fleetCapacity: discrete.fleetCapacity,
|
|
234
|
+
timeConstraint: discrete.timeConstraint,
|
|
235
|
+
riskLevel: discrete.riskLevel
|
|
236
|
+
},
|
|
237
|
+
previousAttempts: 0,
|
|
238
|
+
availableResources: resourceMap[discrete.fleetCapacity] ?? 0.6,
|
|
239
|
+
timeConstraint: state.resources.timeRemaining * 1000 // Convert to ms
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Convert GOAP action to AgentAction for Q-learning
|
|
244
|
+
*/
|
|
245
|
+
static goapActionToAgentAction(action) {
|
|
246
|
+
const costLevel = action.cost < 1.5 ? 'low' : action.cost < 3 ? 'medium' : 'high';
|
|
247
|
+
return {
|
|
248
|
+
strategy: action.category,
|
|
249
|
+
toolsUsed: [action.agentType],
|
|
250
|
+
parallelization: costLevel === 'high' ? 0.3 : costLevel === 'medium' ? 0.5 : 0.8,
|
|
251
|
+
retryPolicy: 'exponential',
|
|
252
|
+
resourceAllocation: costLevel === 'low' ? 0.3 : costLevel === 'medium' ? 0.5 : 0.8
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
// Discretization helper methods
|
|
256
|
+
static discretizeCoverage(coverage) {
|
|
257
|
+
if (coverage < 50)
|
|
258
|
+
return 'low';
|
|
259
|
+
if (coverage < 80)
|
|
260
|
+
return 'medium';
|
|
261
|
+
return 'high';
|
|
262
|
+
}
|
|
263
|
+
static discretizeQuality(quality) {
|
|
264
|
+
if (quality < 70)
|
|
265
|
+
return 'low';
|
|
266
|
+
if (quality < 90)
|
|
267
|
+
return 'medium';
|
|
268
|
+
return 'high';
|
|
269
|
+
}
|
|
270
|
+
static discretizeSecurity(score) {
|
|
271
|
+
if (score < 60)
|
|
272
|
+
return 'low';
|
|
273
|
+
if (score < 85)
|
|
274
|
+
return 'medium';
|
|
275
|
+
return 'high';
|
|
276
|
+
}
|
|
277
|
+
static discretizeFleet(agents) {
|
|
278
|
+
if (agents < 3)
|
|
279
|
+
return 'limited';
|
|
280
|
+
if (agents < 7)
|
|
281
|
+
return 'normal';
|
|
282
|
+
return 'high';
|
|
283
|
+
}
|
|
284
|
+
static discretizeTime(seconds) {
|
|
285
|
+
if (seconds < 300)
|
|
286
|
+
return 'tight'; // < 5 min
|
|
287
|
+
if (seconds < 1800)
|
|
288
|
+
return 'normal'; // < 30 min
|
|
289
|
+
return 'relaxed';
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Calculate reward for GOAP action execution
|
|
293
|
+
* Used by PlanLearning for experience generation
|
|
294
|
+
*/
|
|
295
|
+
static calculateGOAPReward(success, executionTimeMs, expectedTimeMs, actionCost, coverageImprovement, qualityImprovement) {
|
|
296
|
+
let reward = 0;
|
|
297
|
+
// Base reward for success/failure
|
|
298
|
+
reward += success ? 1.0 : -0.5;
|
|
299
|
+
// Time efficiency bonus (faster = better)
|
|
300
|
+
const timeRatio = expectedTimeMs / Math.max(executionTimeMs, 1);
|
|
301
|
+
reward += Math.min(timeRatio - 1, 0.5) * 0.3;
|
|
302
|
+
// Cost efficiency (penalize high-cost actions)
|
|
303
|
+
reward -= actionCost * 0.1;
|
|
304
|
+
// Improvement bonuses
|
|
305
|
+
reward += coverageImprovement * 0.02;
|
|
306
|
+
reward += qualityImprovement * 0.02;
|
|
307
|
+
// Clamp to [-1, 1]
|
|
308
|
+
return Math.max(-1, Math.min(1, reward));
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Get Q-value for a GOAP state-action pair
|
|
312
|
+
*/
|
|
313
|
+
getGOAPQValue(state, action) {
|
|
314
|
+
const taskState = QLearning.worldStateToTaskState(state);
|
|
315
|
+
const agentAction = QLearning.goapActionToAgentAction(action);
|
|
316
|
+
return this.getQValue(taskState, agentAction);
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Get best GOAP action from available actions
|
|
320
|
+
*/
|
|
321
|
+
getBestGOAPAction(state, availableActions) {
|
|
322
|
+
if (availableActions.length === 0)
|
|
323
|
+
return null;
|
|
324
|
+
const taskState = QLearning.worldStateToTaskState(state);
|
|
325
|
+
const agentActions = availableActions.map(a => QLearning.goapActionToAgentAction(a));
|
|
326
|
+
const bestAgentAction = this.getBestAction(taskState, agentActions);
|
|
327
|
+
const bestIndex = agentActions.findIndex(a => a.strategy === bestAgentAction.strategy &&
|
|
328
|
+
a.toolsUsed[0] === bestAgentAction.toolsUsed[0]);
|
|
329
|
+
return bestIndex >= 0 ? availableActions[bestIndex] : availableActions[0];
|
|
330
|
+
}
|
|
163
331
|
}
|
|
164
332
|
exports.QLearning = QLearning;
|
|
165
333
|
//# sourceMappingURL=QLearning.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QLearning.js","sourceRoot":"","sources":["../../src/learning/QLearning.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"QLearning.js","sourceRoot":"","sources":["../../src/learning/QLearning.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,sEAA6E;AAE7E,+DAA4D;AAwC5D;;GAEG;AACH,MAAM,cAAc,GAAa;IAC/B,YAAY,EAAE,GAAG;IACjB,cAAc,EAAE,IAAI;IACpB,eAAe,EAAE,GAAG;IACpB,gBAAgB,EAAE,KAAK;IACvB,kBAAkB,EAAE,IAAI;IACxB,mBAAmB,EAAE,IAAI;IACzB,gBAAgB,EAAE,KAAK;IACvB,SAAS,EAAE,EAAE;CACd,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,SAAU,SAAQ,qCAAiB;IAM9C,YAAY,SAA4B,EAAE,EAAE,OAAgB;QAC1D,MAAM,UAAU,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,MAAM,EAAE,CAAC;QACpD,KAAK,CAAC,UAAU,CAAC,CAAC;QALZ,6BAAwB,GAAW,EAAE,CAAC,CAAC,yBAAyB;QAMtE,IAAI,CAAC,aAAa,GAAG,UAAU,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,aAAa,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QAEpD,4DAA4D;QAC5D,IAAI,CAAC;YACH,IAAI,CAAC,eAAe,GAAG,IAAI,iCAAe,EAAE,CA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AM,SAAS,GAAG,SAAS,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;QACzD,MAAM,YAAY,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC;QAErF,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QACpE,MAAM,SAAS,GAAG,YAAY,CAAC,SAAS,CACtC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,eAAe,CAAC,QAAQ;YACvC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,CACrD,CAAC;QAEF,OAAO,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC5E,CAAC;CACF;AA3UD,8BA2UC"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export declare const SERVER_INSTRUCTIONS = "\n# Agentic QE Fleet - MCP Tool Guide\n\n## Overview\nAgentic QE provides 105 specialized quality engineering tools organized into a hierarchical system for efficient context usage.\n\n## Quick Start\n1. **Discover available tools:** Use `tools_discover` to see all domains\n2. **Load domain tools:** Use `tools_load_domain` to load specialized tools\n3. **Auto-loading:** Domain tools auto-load when relevant keywords are detected\n\n---\n\n## Core Tools (Always Available - 14 tools)\n\n### Fleet Management\n- `fleet_init` - Initialize QE fleet with topology\n- `agent_spawn` - Spawn specialized QE agent\n- `fleet_status` - Get fleet and agent status\n\n### Testing\n- `test_generate_enhanced` - AI test generation with pattern recognition\n- `test_execute_parallel` - Parallel test execution with retry\n- `test_report_comprehensive` - Multi-format test reports\n\n### Memory & Coordination\n- `memory_store` - Store data with TTL & namespacing\n- `memory_retrieve` - Retrieve stored data\n- `memory_query` - Pattern-based memory search\n\n### Quality & Orchestration\n- `quality_analyze` - Analyze quality metrics\n- `task_orchestrate` - Orchestrate tasks across agents\n- `task_status` - Check task progress\n\n### Discovery\n- `tools_discover` - List available tool domains\n- `tools_load_domain` - Load tools for a domain\n\n---\n\n## Domain Tools (Load as Needed)\n\n| Domain | Keywords | Tools | Use Case |\n|--------|----------|-------|----------|\n| **Security** | security, vulnerability, audit, owasp | 4 tools | Security scanning, vulnerability detection |\n| **Performance** | benchmark, bottleneck, profiling | 4 tools | Performance testing, bottleneck analysis |\n| **Coverage** | coverage, gap, uncovered | 5 tools | Coverage analysis, gap detection |\n| **Quality** | quality gate, deploy, release | 6 tools | Quality gates, deployment readiness |\n| **Flaky** | flaky, unstable, retry | 3 tools | Flaky test detection and stabilization |\n| **Visual** | screenshot, accessibility, wcag | 3 tools | Visual regression, accessibility testing |\n| **Requirements** | bdd, gherkin, acceptance | 2 tools | Requirements validation, BDD generation |\n\n### Loading Domain Tools\n```\n# Explicit load\ntools_load_domain({ domain: 'security' })\n\n# Auto-load: Just mention keywords in your request\n\"I need to run a security scan\" \u2192 Security tools auto-load\n```\n\n---\n\n## Specialized Tools (Expert Use)\n\n### Learning Domain (4 tools)\nFor persistent learning and pattern storage across sessions.\nLoad with: `tools_load_domain({ domain: 'learning' })`\n\n### Advanced Domain (7 tools)\nFor mutation testing, API contract validation, production incident replay.\nLoad with: `tools_load_domain({ domain: 'advanced' })`\n\n---\n\n## Best Practices\n\n1. **Start with core tools** - They handle 80% of use cases\n2. **Let auto-load work** - Mention keywords naturally\n3. **Use tools_discover** - When unsure what's available\n4. **Batch operations** - Use parallel execution for speed\n5. **Check fleet_status** - Monitor agent health\n\n---\n\n## Common Workflows\n\n### Test Generation & Execution\n1. `test_generate_enhanced` - Generate tests\n2. `test_execute_parallel` - Run tests\n3. `test_report_comprehensive` - Generate report\n\n### Quality Gate Check\n1. Load quality domain if not auto-loaded\n2. `quality_analyze` - Analyze metrics\n3. `qe_qualitygate_evaluate` - Make go/no-go decision\n\n### Security Audit\n1. `tools_load_domain({ domain: 'security' })`\n2. `qe_security_scan_comprehensive` - Full scan\n3. `qe_security_detect_vulnerabilities` - Detailed analysis\n\n---\n\n## Tool Naming Convention\nAll tools follow: `mcp__agentic_qe__<tool_name>`\n\nExample: `mcp__agentic_qe__test_generate_enhanced`\n";
|
|
8
8
|
export declare const SERVER_NAME = "agentic-qe";
|
|
9
|
-
export declare const SERVER_VERSION = "2.7.
|
|
9
|
+
export declare const SERVER_VERSION = "2.7.3";
|
|
10
10
|
/**
|
|
11
11
|
* Get formatted server info for MCP initialization
|
|
12
12
|
*/
|
|
@@ -119,7 +119,7 @@ All tools follow: \`mcp__agentic_qe__<tool_name>\`
|
|
|
119
119
|
Example: \`mcp__agentic_qe__test_generate_enhanced\`
|
|
120
120
|
`;
|
|
121
121
|
exports.SERVER_NAME = 'agentic-qe';
|
|
122
|
-
exports.SERVER_VERSION = '2.7.
|
|
122
|
+
exports.SERVER_VERSION = '2.7.3';
|
|
123
123
|
/**
|
|
124
124
|
* Get formatted server info for MCP initialization
|
|
125
125
|
*/
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import Database from 'better-sqlite3';
|
|
14
14
|
import { WorldState, StateConditions, GOAPAction, GOAPPlan, PlanConstraints } from './types';
|
|
15
|
+
import { PlanSimilarity, PlanReuseStats } from './PlanSimilarity';
|
|
15
16
|
/**
|
|
16
17
|
* GOAP Planner using A* search algorithm
|
|
17
18
|
*/
|
|
@@ -20,7 +21,21 @@ export declare class GOAPPlanner {
|
|
|
20
21
|
private db;
|
|
21
22
|
private logger;
|
|
22
23
|
private actionsLoaded;
|
|
24
|
+
private planSimilarity;
|
|
25
|
+
private enablePlanReuse;
|
|
23
26
|
constructor(db: Database.Database);
|
|
27
|
+
/**
|
|
28
|
+
* Get PlanSimilarity instance for direct access
|
|
29
|
+
*/
|
|
30
|
+
getPlanSimilarity(): PlanSimilarity;
|
|
31
|
+
/**
|
|
32
|
+
* Enable or disable plan reuse (useful for benchmarking)
|
|
33
|
+
*/
|
|
34
|
+
setPlanReuseEnabled(enabled: boolean): void;
|
|
35
|
+
/**
|
|
36
|
+
* Check if plan reuse is enabled
|
|
37
|
+
*/
|
|
38
|
+
isPlanReuseEnabled(): boolean;
|
|
24
39
|
/**
|
|
25
40
|
* Load action library from database (merges with programmatic actions)
|
|
26
41
|
*/
|
|
@@ -52,8 +67,35 @@ export declare class GOAPPlanner {
|
|
|
52
67
|
getActionCountFromDatabase(): number;
|
|
53
68
|
/**
|
|
54
69
|
* A* search to find optimal plan from current to goal state
|
|
70
|
+
* Phase 5: First checks for reusable similar plans before running A*
|
|
55
71
|
*/
|
|
56
72
|
findPlan(currentState: WorldState, goalConditions: StateConditions, constraints?: PlanConstraints): Promise<GOAPPlan | null>;
|
|
73
|
+
/**
|
|
74
|
+
* Phase 5: Try to reuse a similar plan from the signature cache
|
|
75
|
+
* Returns null if no suitable plan found, otherwise returns reconstructed plan
|
|
76
|
+
*/
|
|
77
|
+
private tryReuseSimilarPlan;
|
|
78
|
+
/**
|
|
79
|
+
* Reconstruct action objects from action ID sequence
|
|
80
|
+
*/
|
|
81
|
+
private reconstructActionsFromSequence;
|
|
82
|
+
/**
|
|
83
|
+
* Validate that action sequence can be executed from current state
|
|
84
|
+
*/
|
|
85
|
+
private validateActionSequence;
|
|
86
|
+
/**
|
|
87
|
+
* Store plan signature for future reuse
|
|
88
|
+
* Call this after successful plan execution
|
|
89
|
+
*/
|
|
90
|
+
storePlanSignature(plan: GOAPPlan, initialState: WorldState): void;
|
|
91
|
+
/**
|
|
92
|
+
* Record plan reuse outcome (for learning)
|
|
93
|
+
*/
|
|
94
|
+
recordPlanReuseOutcome(planId: string, success: boolean): void;
|
|
95
|
+
/**
|
|
96
|
+
* Get plan reuse statistics
|
|
97
|
+
*/
|
|
98
|
+
getPlanReuseStats(): PlanReuseStats;
|
|
57
99
|
/**
|
|
58
100
|
* Calculate heuristic distance to goal (admissible)
|
|
59
101
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GOAPPlanner.d.ts","sourceRoot":"","sources":["../../src/planning/GOAPPlanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,OAAO,EACL,UAAU,EACV,eAAe,EAIf,UAAU,EACV,QAAQ,EACR,eAAe,EAIhB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"GOAPPlanner.d.ts","sourceRoot":"","sources":["../../src/planning/GOAPPlanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,OAAO,EACL,UAAU,EACV,eAAe,EAIf,UAAU,EACV,QAAQ,EACR,eAAe,EAIhB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,cAAc,EAAe,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE/E;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,aAAa,CAAoB;IACzC,OAAO,CAAC,EAAE,CAAoB;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,eAAe,CAAQ;gBAEnB,EAAE,EAAE,QAAQ,CAAC,QAAQ;IAMjC;;OAEG;IACH,iBAAiB,IAAI,cAAc;IAInC;;OAEG;IACH,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAI3C;;OAEG;IACH,kBAAkB,IAAI,OAAO;IAI7B;;OAEG;IACG,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;IAmC9C;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,IAAI;IAIvC;;OAEG;IACH,YAAY,IAAI,IAAI;IAKpB;;OAEG;IACH,gBAAgB,IAAI,UAAU,EAAE;IAIhC;;OAEG;IACH,YAA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