mirror of
https://github.com/proffesor-for-testing/agentic-qe.git
synced 2026-09-19 08:45:47 +08:00
1e3fbb5ea8
* SwarmMemoryManager Refactoring Plan * fix: add missing directories to npm package (v1.9.3) Added templates/, .claude/helpers/, and docs/reference/ to package.json files array. These were missing from the npm distribution, causing `aqe init` to fail with "Template file not found" errors. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * checkpoint improvements * fix: critical memory/learning system fixes for v1.9.4 ## Critical Fixes - Vector embeddings now stored correctly (was storing NULL) - SQL parameter style fixed for agentdb's SqlJsDatabase wrapper - HNSW index schema mismatch resolved with pattern_id column - Hooks now save to correct database (.agentic-qe/agentdb.db) ## New Features - Added 5 SwarmMemoryManager methods for learning data retrieval: - getBestAction() - Q-learning best action selection - getRecentLearningExperiences() - Recent experience retrieval - getLearningExperiencesByTaskType() - Task-filtered experiences - getHighRewardExperiences() - Successful experience extraction - getLearningStats() - Aggregate learning statistics - Added comprehensive integration test for memory/learning loop - Added RuVector pattern store integration (experimental) ## Technical Details - Vector embeddings: 384 dimensions × 4 bytes = 1,536 bytes per pattern - All 12 integration tests pass - HNSW index: 150x faster vector search enabled 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: move ARM64-only ruvector packages to optionalDependencies Fixes CI failures caused by platform-specific dependencies: - @ruvector/node-linux-arm64-gnu (ARM64 only) - ruvector-core-linux-arm64-gnu (ARM64 only) These packages caused npm ci to fail on x64 CI runners with: "EBADPLATFORM - wanted linux/arm64, current linux/x64" Solution: Move ARM64 packages to optionalDependencies and add x64 variants for cross-platform compatibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: regenerate package-lock.json with x64 ruvector packages Updates lockfile to include optional x64 platform packages for CI compatibility: - @ruvector/node-linux-x64-gnu@0.1.17 - ruvector-core-linux-x64-gnu@0.1.15 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: replace fake QUIC with proper implementation and clean up skills manifest QUIC Transport: - Remove fake HTTP/2-based QUICTransport.ts that pretended to be QUIC - Add proper QUIC implementation via Rust/WASM (@agentic-flow/quic-wasm) - Add WebSocket fallback transport for when WASM unavailable - Add dedicated type declarations for optional WASM module - Features: 0-RTT connection, stream multiplexing, TLS 1.3 built-in Skills Manifest: - Rewrite skills-manifest.json with only QE skills (41 skills) - Remove Claude Flow platform skills (agentdb-*, flow-nexus-*, github-*, etc.) - Organize into proper categories: qe-core, testing-methodologies, etc. Bug Fixes: - Fix UnifiedMemoryCoordinator.ts TypeScript errors - Use Logger.getInstance() instead of private constructor - Use swarmMemory.query() instead of non-existent list() method - Use correct close() method signatures for backends 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: add QX Partner agent, compact subagents, fix CLAUDE.md dynamic counts - Add QX Partner agent for Quality Experience analysis combining QA + UX perspectives - Compact 9 subagent definitions to ~80 lines each (88% reduction) - Fix CLAUDE.md template to dynamically count agents (including subagents) and skills - Move CLAUDE.md creation after parallel phases for accurate counts - Remove 'Production-Ready' claim from README and CHANGELOG - Clean up backup files and move docs to proper directory Initialization now correctly reports: - 31 QE Agents (20 main + 11 subagents) - 53 QE Skills - 8 Slash Commands 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: resolve CI failures and security alert #36 - Replace MD5 with SHA-256 for ETag calculation (security alert #36) - Fix CRLF line endings in shell scripts causing parse errors - Remove 'local' keyword from for-loop in test-integration-batched.sh - Use dynamic process.cwd() instead of hardcoded path in jest.config.js - Enhance quality-gate.ts to parse test logs when results file missing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: Complete Agentic QE Fleet v2.1 implementation (closes #101) ## Implemented Features ### Error Recovery Enhancement (Task 1.3) - CircuitBreaker class with state management (CLOSED/OPEN/HALF_OPEN) - RetryStrategy with exponential/linear/constant backoff - RecoveryOrchestrator with 6 recovery strategies - Transport fallback mechanisms ### Dynamic Skill Loader (Task 2.2) - Metadata-only initial loading (98% token reduction) - On-demand full skill retrieval - LRU caching with configurable TTL (30min default) - Preload suggestions for critical workflows ### Swarm Learning Optimizer (Task 4.1) - Topology recommendation engine (hierarchical/mesh/ring/star) - Agent allocation with capability matching and load balancing - Bottleneck detection (agent/memory/coordination/IO) - Real-time performance adjustments - Added getLatestRecommendation() method ### Workflow Orchestrator (Task 4.2) - AdaptiveScheduler with dynamic strategy selection - Priority-based task queue with age boosting - Task dependency resolution - Work stealing and backpressure handling - Added getQueueDepth() and getStatus() methods ### Unified Memory Coordinator (Task 4.3) - Consolidated memory managers (SQLite, AgentDB, Vector, JSON) - Automatic failover chain with health monitoring - Batch operations and namespace isolation - Periodic sync between backends ### SwarmCoordinator Improvements - Real CPU utilization tracking via process.cpuUsage() - Queue depth from WorkflowOrchestrator - Optimizer recommendations in feedback data - Calculated average complexity from metrics ## Additional Changes - Migration documentation and test restructuring plan - GitHub issue templates and workflows - Test suite improvements and cleanup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: optimize 38 QE skills with agent-focused format (#102) - Add enhanced YAML frontmatter (tokenEstimate, agents, tags, etc.) - Add <default_to_action> blocks for immediate actionable guidance - Add Quick Reference Cards with tables for at-a-glance info - Add Agent Integration examples using Task() pattern - Add Agent Coordination Hints (memory namespace + fleet coordination) - Condense content optimized for agent consumption - Reduce total token footprint by ~65% across skills Skills updated: - Core QE: agentic-quality-engineering, holistic-testing-pact - Testing Types: api-testing, chaos-engineering, compatibility, compliance, contract, database, exploratory, localization, mobile, mutation, performance, regression, security, visual-testing - Methodologies: tdd-london-chicago, xp-practices, context-driven, risk-based, shift-left, shift-right - Analysis: code-review-quality, quality-metrics, test-design-techniques - Strategy: test-automation-strategy, test-data-management, test-environment-management, test-reporting-analytics - CI/CD: cicd-pipeline-qe-orchestrator, accessibility-testing - Communication: brutal-honesty-review, bug-reporting-excellence, consultancy-practices, sherlock-review, six-thinking-hats, technical-writing - Refactoring: refactoring-patterns Also includes: package.json updates, docs/optimization/, docs/templates/, scripts/validate-skill-optimization.ts Skipped: testability-scoring (pending PR from @fndlalit) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * release: v2.1.0 - Comprehensive QX Analysis & Skills Optimization ## Summary - Comprehensive QX Analysis with 23+ heuristics (PR #104 by @fndlalit) - 38 QE Skills optimized with agent-focused format (PR #102) - Testability Scoring skill v2.1 with optimized format - QX Partner Agent v2.1 with enhanced capabilities - Fix MCP SDK compatibility for @modelcontextprotocol/sdk bump (PR #105) ## Changes - .claude/agents/qx-partner.md: Updated to v2.1 with domain-specific detection - .claude/skills/testability-scoring/SKILL.md: Optimized format (59% token reduction) - src/mcp/server.ts: Removed deprecated 'description' field for MCP SDK compatibility - package.json: Bumped version to 2.1.0 - README.md: Updated version and release notes - CHANGELOG.md: Added v2.1.0 release notes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
343 lines
10 KiB
TypeScript
343 lines
10 KiB
TypeScript
#!/usr/bin/env tsx
|
|
|
|
/**
|
|
* Test Duplicate Analysis Script
|
|
*
|
|
* Analyzes test files to identify:
|
|
* 1. Duplicate test cases across multiple files
|
|
* 2. Overlapping test coverage
|
|
* 3. Implementation detail tests vs user value tests
|
|
* 4. Large monolithic test files
|
|
*
|
|
* Usage: npx tsx scripts/analyze-test-duplicates.ts
|
|
* Output: docs/migration/duplicate-analysis.json
|
|
*/
|
|
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import { glob } from 'glob';
|
|
|
|
interface TestFile {
|
|
path: string;
|
|
lines: number;
|
|
testCases: string[];
|
|
describeSuites: string[];
|
|
imports: string[];
|
|
category: 'user-value' | 'implementation-detail' | 'contract' | 'unknown';
|
|
}
|
|
|
|
interface DuplicateGroup {
|
|
pattern: string;
|
|
files: string[];
|
|
totalLines: number;
|
|
overlapPercentage: number;
|
|
recommendation: 'consolidate' | 'delete' | 'keep';
|
|
}
|
|
|
|
interface AnalysisResult {
|
|
timestamp: string;
|
|
totalFiles: number;
|
|
totalLines: number;
|
|
largeFiles: { path: string; lines: number }[];
|
|
duplicates: DuplicateGroup[];
|
|
categoryBreakdown: Record<string, { files: number; lines: number }>;
|
|
recommendations: {
|
|
filesToDelete: string[];
|
|
filesToConsolidate: DuplicateGroup[];
|
|
estimatedReduction: { files: number; lines: number };
|
|
};
|
|
}
|
|
|
|
async function analyzeTestFile(filePath: string): Promise<TestFile> {
|
|
const content = fs.readFileSync(filePath, 'utf-8');
|
|
const lines = content.split('\n').length;
|
|
|
|
// Extract test cases (it(), test(), describe())
|
|
const testCaseRegex = /(?:it|test|describe)\s*\(\s*['"`]([^'"`]+)['"`]/g;
|
|
const testCases: string[] = [];
|
|
let match;
|
|
while ((match = testCaseRegex.exec(content)) !== null) {
|
|
testCases.push(match[1]);
|
|
}
|
|
|
|
// Extract describe suites
|
|
const describeSuiteRegex = /describe\s*\(\s*['"`]([^'"`]+)['"`]/g;
|
|
const describeSuites: string[] = [];
|
|
while ((match = describeSuiteRegex.exec(content)) !== null) {
|
|
describeSuites.push(match[1]);
|
|
}
|
|
|
|
// Extract imports
|
|
const importRegex = /import\s+.*?\s+from\s+['"`]([^'"`]+)['"`]/g;
|
|
const imports: string[] = [];
|
|
while ((match = importRegex.exec(content)) !== null) {
|
|
imports.push(match[1]);
|
|
}
|
|
|
|
// Categorize test
|
|
const category = categorizeTest(content, filePath);
|
|
|
|
return {
|
|
path: filePath,
|
|
lines,
|
|
testCases,
|
|
describeSuites,
|
|
imports,
|
|
category,
|
|
};
|
|
}
|
|
|
|
function categorizeTest(content: string, filePath: string): TestFile['category'] {
|
|
// Implementation detail indicators
|
|
const implementationIndicators = [
|
|
'null-safety',
|
|
'type checking',
|
|
'private method',
|
|
'internal state',
|
|
'constructor',
|
|
'.skip',
|
|
'should be defined',
|
|
'should be a function',
|
|
];
|
|
|
|
// User value indicators
|
|
const userValueIndicators = [
|
|
'user',
|
|
'journey',
|
|
'scenario',
|
|
'workflow',
|
|
'integration',
|
|
'end-to-end',
|
|
'e2e',
|
|
'acceptance',
|
|
];
|
|
|
|
// Contract indicators
|
|
const contractIndicators = [
|
|
'interface',
|
|
'contract',
|
|
'api',
|
|
'public method',
|
|
'exports',
|
|
];
|
|
|
|
const contentLower = content.toLowerCase();
|
|
const filePathLower = filePath.toLowerCase();
|
|
|
|
let implementationScore = 0;
|
|
let userValueScore = 0;
|
|
let contractScore = 0;
|
|
|
|
for (const indicator of implementationIndicators) {
|
|
if (contentLower.includes(indicator) || filePathLower.includes(indicator)) {
|
|
implementationScore++;
|
|
}
|
|
}
|
|
|
|
for (const indicator of userValueIndicators) {
|
|
if (contentLower.includes(indicator) || filePathLower.includes(indicator)) {
|
|
userValueScore++;
|
|
}
|
|
}
|
|
|
|
for (const indicator of contractIndicators) {
|
|
if (contentLower.includes(indicator) || filePathLower.includes(indicator)) {
|
|
contractScore++;
|
|
}
|
|
}
|
|
|
|
if (implementationScore > userValueScore && implementationScore > contractScore) {
|
|
return 'implementation-detail';
|
|
} else if (userValueScore > implementationScore && userValueScore > contractScore) {
|
|
return 'user-value';
|
|
} else if (contractScore > 0) {
|
|
return 'contract';
|
|
}
|
|
|
|
return 'unknown';
|
|
}
|
|
|
|
function findDuplicatePatterns(files: TestFile[]): DuplicateGroup[] {
|
|
const patterns = new Map<string, TestFile[]>();
|
|
|
|
// Group files by base name pattern
|
|
for (const file of files) {
|
|
const baseName = path.basename(file.path, '.test.ts');
|
|
const pattern = baseName
|
|
.replace(/\.(comprehensive|enhanced|null-safety|skip|ml|database|edge-cases|race-condition|lifecycle)$/, '')
|
|
.replace(/Agent$/, '');
|
|
|
|
if (!patterns.has(pattern)) {
|
|
patterns.set(pattern, []);
|
|
}
|
|
patterns.get(pattern)!.push(file);
|
|
}
|
|
|
|
// Analyze groups with multiple files
|
|
const duplicates: DuplicateGroup[] = [];
|
|
|
|
for (const [pattern, groupFiles] of patterns) {
|
|
if (groupFiles.length < 2) continue;
|
|
|
|
const totalLines = groupFiles.reduce((sum, f) => sum + f.lines, 0);
|
|
|
|
// Calculate overlap by comparing test case names
|
|
const allTestCases = new Set<string>();
|
|
const testCaseCounts = new Map<string, number>();
|
|
|
|
for (const file of groupFiles) {
|
|
for (const testCase of file.testCases) {
|
|
allTestCases.add(testCase);
|
|
testCaseCounts.set(testCase, (testCaseCounts.get(testCase) || 0) + 1);
|
|
}
|
|
}
|
|
|
|
let duplicateTestCases = 0;
|
|
for (const count of testCaseCounts.values()) {
|
|
if (count > 1) duplicateTestCases++;
|
|
}
|
|
|
|
const overlapPercentage = allTestCases.size > 0
|
|
? (duplicateTestCases / allTestCases.size) * 100
|
|
: 0;
|
|
|
|
// Determine recommendation
|
|
let recommendation: DuplicateGroup['recommendation'] = 'keep';
|
|
if (overlapPercentage > 60) {
|
|
recommendation = 'consolidate';
|
|
} else if (groupFiles.some(f => f.category === 'implementation-detail')) {
|
|
recommendation = 'delete';
|
|
}
|
|
|
|
duplicates.push({
|
|
pattern,
|
|
files: groupFiles.map(f => f.path),
|
|
totalLines,
|
|
overlapPercentage: Math.round(overlapPercentage),
|
|
recommendation,
|
|
});
|
|
}
|
|
|
|
return duplicates.sort((a, b) => b.totalLines - a.totalLines);
|
|
}
|
|
|
|
async function analyzeTestSuite(): Promise<AnalysisResult> {
|
|
const testFiles = await glob('tests/**/*.test.ts', {
|
|
cwd: process.cwd(),
|
|
absolute: true,
|
|
});
|
|
|
|
console.log(`Found ${testFiles.length} test files. Analyzing...`);
|
|
|
|
const analyzedFiles = await Promise.all(
|
|
testFiles.map(file => analyzeTestFile(file))
|
|
);
|
|
|
|
const totalLines = analyzedFiles.reduce((sum, f) => sum + f.lines, 0);
|
|
|
|
// Find large files (> 1000 lines)
|
|
const largeFiles = analyzedFiles
|
|
.filter(f => f.lines > 1000)
|
|
.map(f => ({ path: f.path, lines: f.lines }))
|
|
.sort((a, b) => b.lines - a.lines);
|
|
|
|
// Find duplicates
|
|
const duplicates = findDuplicatePatterns(analyzedFiles);
|
|
|
|
// Category breakdown
|
|
const categoryBreakdown: Record<string, { files: number; lines: number }> = {
|
|
'user-value': { files: 0, lines: 0 },
|
|
'implementation-detail': { files: 0, lines: 0 },
|
|
'contract': { files: 0, lines: 0 },
|
|
'unknown': { files: 0, lines: 0 },
|
|
};
|
|
|
|
for (const file of analyzedFiles) {
|
|
categoryBreakdown[file.category].files++;
|
|
categoryBreakdown[file.category].lines += file.lines;
|
|
}
|
|
|
|
// Generate recommendations
|
|
const filesToDelete = analyzedFiles
|
|
.filter(f =>
|
|
f.category === 'implementation-detail' ||
|
|
f.path.includes('.skip.') ||
|
|
f.path.includes('null-safety')
|
|
)
|
|
.map(f => f.path);
|
|
|
|
const filesToConsolidate = duplicates.filter(d => d.recommendation === 'consolidate');
|
|
|
|
const estimatedDeletionLines = filesToDelete.reduce((sum, path) => {
|
|
const file = analyzedFiles.find(f => f.path === path);
|
|
return sum + (file?.lines || 0);
|
|
}, 0);
|
|
|
|
const estimatedConsolidationLines = filesToConsolidate.reduce((sum, group) => {
|
|
// Assume we can reduce by 70% through consolidation
|
|
return sum + (group.totalLines * 0.7);
|
|
}, 0);
|
|
|
|
const estimatedReduction = {
|
|
files: filesToDelete.length + filesToConsolidate.reduce((sum, g) => sum + g.files.length - 1, 0),
|
|
lines: Math.round(estimatedDeletionLines + estimatedConsolidationLines),
|
|
};
|
|
|
|
return {
|
|
timestamp: new Date().toISOString(),
|
|
totalFiles: testFiles.length,
|
|
totalLines,
|
|
largeFiles,
|
|
duplicates,
|
|
categoryBreakdown,
|
|
recommendations: {
|
|
filesToDelete,
|
|
filesToConsolidate,
|
|
estimatedReduction,
|
|
},
|
|
};
|
|
}
|
|
|
|
async function main() {
|
|
console.log('🔍 Analyzing test suite for duplicates...\n');
|
|
|
|
const result = await analyzeTestSuite();
|
|
|
|
console.log('📊 Analysis Results:\n');
|
|
console.log(`Total test files: ${result.totalFiles}`);
|
|
console.log(`Total lines of test code: ${result.totalLines.toLocaleString()}`);
|
|
console.log(`Large files (>1000 lines): ${result.largeFiles.length}`);
|
|
console.log(`Duplicate groups found: ${result.duplicates.length}\n`);
|
|
|
|
console.log('📂 Category Breakdown:');
|
|
for (const [category, stats] of Object.entries(result.categoryBreakdown)) {
|
|
const percentage = ((stats.lines / result.totalLines) * 100).toFixed(1);
|
|
console.log(` ${category}: ${stats.files} files, ${stats.lines.toLocaleString()} lines (${percentage}%)`);
|
|
}
|
|
|
|
console.log('\n💡 Recommendations:');
|
|
console.log(` Files to delete: ${result.recommendations.filesToDelete.length}`);
|
|
console.log(` Groups to consolidate: ${result.recommendations.filesToConsolidate.length}`);
|
|
console.log(` Estimated reduction: ${result.recommendations.estimatedReduction.files} files, ${result.recommendations.estimatedReduction.lines.toLocaleString()} lines\n`);
|
|
|
|
// Write to JSON file
|
|
const outputPath = path.join(process.cwd(), 'docs/migration/duplicate-analysis.json');
|
|
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
|
|
fs.writeFileSync(outputPath, JSON.stringify(result, null, 2));
|
|
|
|
console.log(`✅ Analysis complete! Results saved to: ${outputPath}`);
|
|
|
|
// Print top duplicate groups
|
|
console.log('\n🔝 Top Duplicate Groups:\n');
|
|
for (const group of result.duplicates.slice(0, 10)) {
|
|
console.log(` ${group.pattern}:`);
|
|
console.log(` Files: ${group.files.length}`);
|
|
console.log(` Total lines: ${group.totalLines.toLocaleString()}`);
|
|
console.log(` Overlap: ${group.overlapPercentage}%`);
|
|
console.log(` Recommendation: ${group.recommendation}`);
|
|
console.log();
|
|
}
|
|
}
|
|
|
|
main().catch(console.error);
|