mirror of
https://github.com/proffesor-for-testing/agentic-qe.git
synced 2026-09-19 08:45:47 +08:00
2253d05618
Remove the nested v3/ subdirectory by moving all active source code, tests, configs, and assets directly to the project root. Archive v2/ (dead code, 847MB) to v2-archive.tar.gz. Key changes: - Move v3/src/ → src/, v3/tests/ → tests/, v3/packages/ → packages/ - Move v3/tsconfig.json, v3/vitest.config.ts to root - Merge v3/package.json into root package.json (ESM, scripts, deps, exports) - Merge v3/scripts/ into scripts/, v3/implementation/ into docs/implementation/ - Update all CI workflows to remove "cd v3 &&" and v3/ path prefixes - Fix all init installer path resolution (3-level-up → 2-level-up) - Fix hooks to use "node ./dist/cli/bundle.js" instead of bare "aqe" - Update settings.json ADR/DDD directories to docs/implementation/ - Fix helper scripts (statusline, adr-compliance, ddd-tracker, guidance-hooks) - Update 58 agent definitions: aqe/v3/ → aqe/ memory namespaces - Update 15 guidance shards: v3/src/ → src/ path references - Fix sync interfaces: remove v3/ and v2/ path references - Fix test path calculations (process.cwd() + '..' no longer needed) - Fix flaky perf test threshold (500ms → 1000ms for CI environments) - Fix complexity-analyzer test to match ADR-051 keyword-based eligibility Build passes, 17,901 tests pass, CLI and MCP bundles verified. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
76 lines
2.5 KiB
TypeScript
76 lines
2.5 KiB
TypeScript
/**
|
|
* Issue N3: UnifiedMemoryManager.queryCount() unit tests
|
|
*
|
|
* Verifies the queryCount method used by fleet_status to report
|
|
* learning metrics from the SQLite database.
|
|
*/
|
|
|
|
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import { UnifiedMemoryManager, resetUnifiedMemory } from '../../../src/kernel/unified-memory';
|
|
|
|
const TEST_DB_DIR = '/tmp/aqe-querycount-test-' + Date.now();
|
|
const TEST_DB_PATH = path.join(TEST_DB_DIR, 'memory.db');
|
|
|
|
describe('UnifiedMemoryManager.queryCount', () => {
|
|
let um: UnifiedMemoryManager;
|
|
|
|
beforeAll(() => {
|
|
fs.mkdirSync(TEST_DB_DIR, { recursive: true });
|
|
resetUnifiedMemory();
|
|
um = new UnifiedMemoryManager();
|
|
um.initialize(TEST_DB_PATH);
|
|
});
|
|
|
|
afterAll(() => {
|
|
um.close();
|
|
resetUnifiedMemory();
|
|
try {
|
|
fs.rmSync(TEST_DB_DIR, { recursive: true, force: true });
|
|
} catch { /* ignore */ }
|
|
});
|
|
|
|
it('should return 0 for empty allowed tables', () => {
|
|
// kv_store is in the allowlist and should exist after init
|
|
const count = um.queryCount('kv_store');
|
|
expect(typeof count).toBe('number');
|
|
expect(count).toBeGreaterThanOrEqual(0);
|
|
});
|
|
|
|
it('should throw for disallowed table names', () => {
|
|
expect(() => um.queryCount('users')).toThrow('not in allowed list');
|
|
expect(() => um.queryCount('DROP TABLE kv_store')).toThrow('not in allowed list');
|
|
expect(() => um.queryCount('')).toThrow('not in allowed list');
|
|
});
|
|
|
|
it('should count rows in vectors table', () => {
|
|
const count = um.queryCount('vectors');
|
|
expect(count).toBeGreaterThanOrEqual(0);
|
|
});
|
|
|
|
it('should allow all expected learning tables', () => {
|
|
const expectedTables = [
|
|
'qe_patterns', 'captured_experiences', 'qe_trajectories',
|
|
'experience_applications', 'dream_cycles', 'dream_insights',
|
|
'concept_nodes', 'concept_edges', 'rl_q_values', 'vectors',
|
|
'kv_store', 'routing_outcomes', 'qe_pattern_usage',
|
|
];
|
|
|
|
for (const table of expectedTables) {
|
|
// Should not throw
|
|
expect(() => um.queryCount(table)).not.toThrow();
|
|
}
|
|
});
|
|
|
|
it('should reflect data after insertion', async () => {
|
|
const before = um.queryCount('kv_store');
|
|
// Insert a row via the KV store API
|
|
await um.kvSet(`querycount-test-key-${Date.now()}`, 'test-value');
|
|
const after = um.queryCount('kv_store');
|
|
|
|
// Count should increase (may be more than +1 if background hooks also write)
|
|
expect(after).toBeGreaterThan(before);
|
|
});
|
|
});
|