chore: import upstream snapshot with attribution
ADR-166 MCP Bridge Security Lock / Static-source security lock (push) Failing after 0s
ADR-166 MCP Bridge Security Lock / Compose default binds loopback + Mongo has auth (push) Failing after 2s
CodeQL Advanced / Analyze (rust) (push) Failing after 0s
ADR-166 MCP Bridge Security Lock / plugin-agent-federation bindHost default (push) Failing after 1s
ADR-166 MCP Bridge Security Lock / Runtime behavior — 401 + terminal gate + fail-closed (push) Failing after 4s
business-pods-smoke / smoke (push) Failing after 1s
all-plugins-smoke / smoke-all (push) Failing after 2s
CI/CD Pipeline / Security & Code Quality (push) Failing after 1s
CI/CD Pipeline / Test Suite (ubuntu-latest) (push) Failing after 1s
CI/CD Pipeline / Build & Package (macos-latest) (push) Has been skipped
CI/CD Pipeline / Build & Package (ubuntu-latest) (push) Has been skipped
CI/CD Pipeline / Build & Package (windows-latest) (push) Has been skipped
CI/CD Pipeline / Documentation & Examples (push) Failing after 1s
Clone Tracker (14-day rolling) / Snapshot clones for ruflo ecosystem (push) Failing after 1s
CodeQL Advanced / Analyze (actions) (push) Failing after 1s
CodeQL Advanced / Analyze (javascript-typescript) (push) Failing after 1s
federation-peer-rust / stable-noop (push) Failing after 1s
metaharness-ci / score (push) Failing after 1s
metaharness-ci / router-compat (push) Failing after 0s
metaharness-ci / similarity-tests (push) Failing after 0s
no-agentbbs-smoke / smoke-without-agentbbs (push) Failing after 1s
V3 CI/CD Pipeline / Build V3 (windows-latest) (push) Has been skipped
codex-integration-audit / Codex integration audit (push) Failing after 1s
helpers-manifest-guard / guard (push) Failing after 1s
🔗 Cross-Agent Integration Tests / 🤝 Agent Coordination Tests (push) Has been skipped
🔗 Cross-Agent Integration Tests / 🧠 Memory Sharing Integration (push) Has been skipped
🔗 Cross-Agent Integration Tests / 🛡️ Fault Tolerance Tests (push) Has been skipped
🔗 Cross-Agent Integration Tests / ⚡ Performance Integration Tests (push) Has been skipped
metaharness-ci / mcp-scan (push) Failing after 1s
metaharness-ci / eject-dryrun (push) Failing after 1s
metaharness-ci / metaharness-real-data (push) Failing after 0s
no-cli-optdep-bloat-2561 / guard (push) Failing after 1s
no-metaharness-smoke / smoke-without-metaharness (push) Failing after 1s
no-phantom-agentic-flow-subpath / guard (push) Failing after 1s
🔄 Automated Rollback Manager / 🚨 Failure Detection (push) Failing after 1s
V3 CI/CD Pipeline / Plugin hooks smoke / ubuntu-latest / Node 22 (push) Failing after 1s
V3 CI/CD Pipeline / ruflo-graph-intelligence build + test smoke (#2044, ADR-123) (push) Failing after 1s
CVE Audit Gate / Audit root (critical-blocking) (push) Failing after 2s
cost-tracker-smoke / smoke (push) Failing after 3s
oia-audit-weekly / audit (push) Failing after 2s
ruflo-agent-smoke / ruflo-agent structural smoke (push) Failing after 1s
📊 Status Badges Update / 📊 Update Status Badges (push) Failing after 1s
V3 CI/CD Pipeline / Static regression guards (#2267 YAML + (push) Failing after 1s
V3 CI/CD Pipeline / Test V3 Packages (push) Failing after 0s
V3 CI/CD Pipeline / agent_execute provider routing smoke (#2042) (push) Failing after 0s
CVE Audit Gate / Audit v3 (critical-blocking) (push) Failing after 1s
federation-peer-rust / stable-native (push) Failing after 2s
🔗 Cross-Agent Integration Tests / 🚀 Integration Test Setup (push) Failing after 2s
neural-trader-smoke / runtime-smoke (push) Failing after 1s
V3 CI/CD Pipeline / Build V3 (macos-latest) (push) Has been skipped
V3 CI/CD Pipeline / Build V3 (ubuntu-latest) (push) Has been skipped
V3 CI/CD Pipeline / Type Check V3 (push) Failing after 1s
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / ubuntu-latest / Node 24 (push) Failing after 1s
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / ubuntu-latest / Node 22 (push) Failing after 2s
V3 CI/CD Pipeline / browser rvf create flag smoke (#2015) (push) Failing after 0s
V3 CI/CD Pipeline / Dependency review (#2046) (push) Has been skipped
V3 CI/CD Pipeline / Supply-chain audit (#2046) (push) Failing after 0s
V3 CI/CD Pipeline / witness marker drift smoke (#2021) (push) Failing after 1s
V3 CI/CD Pipeline / neural-trader portfolio CG smoke (#2068, ADR-126 Phase 3) (push) Failing after 1s
V3 CI/CD Pipeline / neural-trader backtest signing smoke (#2068, ADR-126 Phase 4) (push) Failing after 1s
V3 CI/CD Pipeline / kg-extract type-import classification smoke (#2049) (push) Failing after 0s
V3 CI/CD Pipeline / witness verify precondition smoke (#1880) (push) Failing after 2s
V3 CI/CD Pipeline / neural-trader pipeline risk-gate smoke (#2068, ADR-126 Phase 5) (push) Failing after 0s
V3 CI/CD Pipeline / neural-trader feature attribution smoke (#2068, ADR-126 Phase 6) (push) Failing after 0s
V3 CI/CD Pipeline / plugin-registry signature verification smoke (#1922, CWE-347) (push) Failing after 4s
V3 CI/CD Pipeline / memory stats legacy-DB smoke (#2120) (push) Failing after 4s
V3 CI/CD Pipeline / github deprecated actions smoke (#2089, ADR-127 Phase 3) (push) Failing after 1s
V3 CI/CD Pipeline / graph query + pathfinder smoke (ADR-130 P2+P5) (push) Has been skipped
V3 CI/CD Pipeline / graph trajectory hooks smoke (ADR-130 P3) (push) Has been skipped
V3 CI/CD Pipeline / graph plugin adapter smoke (ADR-130 P4) (push) Has been skipped
V3 CI/CD Pipeline / graph benchmark (ADR-130 P6) (push) Has been skipped
V3 CI/CD Pipeline / statusline generator delegation smoke (#2195) (push) Failing after 1s
V3 CI/CD Pipeline / wizard init regression guard (#2206 (push) Failing after 1s
V3 CI/CD Pipeline / memory no-stray-db smoke (ADR-125 P7) (push) Failing after 1s
V3 CI/CD Pipeline / github-safe injection smoke (#2089, ADR-127 Phase 1) (push) Failing after 1s
V3 CI/CD Pipeline / github actions pin smoke (#2089, ADR-127 Phase 1) (push) Failing after 1s
V3 CI/CD Pipeline / github attribution opt-in smoke (#2089, ADR-127 Phase 4) (push) Failing after 1s
V3 CI/CD Pipeline / pre-bash hook safety smoke (#2017) (push) Failing after 1s
V3 CI/CD Pipeline / Memory import smoke / ubuntu-latest (push) Failing after 0s
V3 CI/CD Pipeline / MCP protocol smoke / ubuntu-latest (push) Failing after 2s
V3 CI/CD Pipeline / ruvllm WASM auto-init smoke (#2086) (push) Failing after 4s
V3 CI/CD Pipeline / MCP paired-tool round-trip smoke (#1889) (push) Failing after 1s
V3 CI/CD Pipeline / Plugin package install-safety (#1902/#1903/#1904) (push) Failing after 1s
V3 CI/CD Pipeline / Tool description discoverability (ADR-112) (push) Failing after 3s
V3 CI/CD Pipeline / CLI npx-install smoke (#1147 / (22) (push) Failing after 1s
V3 CI/CD Pipeline / CLI npx-install smoke (#1147 / (24) (push) Failing after 1s
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / ubuntu-latest (push) Failing after 2s
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / ubuntu-latest (push) Failing after 1s
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / ubuntu-latest (push) Failing after 1s
V3 CI/CD Pipeline / Vector-index dimension audit (#1947) (push) Failing after 0s
V3 CI/CD Pipeline / Hook-command install safety (#1921) (push) Failing after 1s
V3 CI/CD Pipeline / ToolOutputGuardrail smoke (ADR-131, (push) Failing after 1s
V3 CI/CD Pipeline / init-bundle invariants smoke (#2095, ADR-128 Phase 5) (push) Failing after 1s
V3 CI/CD Pipeline / wasm provider bridge smoke (ADR-129 P1) (push) Failing after 2s
V3 CI/CD Pipeline / wasm gallery CRUD smoke (ADR-129 P3) (push) Failing after 1s
V3 CI/CD Pipeline / wasm plugin bridge smoke (ADR-129 P4) (push) Failing after 0s
V3 CI/CD Pipeline / wasm compose smoke (ADR-129 P2) (push) Failing after 4s
V3 CI/CD Pipeline / graph schema smoke (ADR-130 P1) (push) Failing after 0s
Validate Marketplace / validate (push) Failing after 1s
🔍 Verification Pipeline / 🚀 Setup Verification (push) Failing after 1s
🔍 Verification Pipeline / 🛡️ Security Verification (push) Has been skipped
🔍 Verification Pipeline / 📝 Code Quality (push) Has been skipped
🔍 Verification Pipeline / 🧪 Test Verification (${{ matrix.os }}, Node ${{ matrix.node }}) (push) Has been skipped
🔍 Verification Pipeline / 🏗️ Build Verification (push) Has been skipped
🔍 Verification Pipeline / 📚 Documentation Verification (push) Has been skipped
CVE Audit Gate / High-severity report (warn only) (push) Has been cancelled
🔄 Automated Rollback Manager / 🔄 Execute Rollback (push) Has been cancelled
🔄 Automated Rollback Manager / ✅ Post-Rollback Verification (push) Has been cancelled
🔄 Automated Rollback Manager / 📊 Rollback Monitoring (push) Has been cancelled
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / windows-latest (push) Has been cancelled
🔄 Automated Rollback Manager / ⏳ Manual Rollback Approval (push) Has been cancelled
V3 CI/CD Pipeline / MCP protocol smoke / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Memory import smoke / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / ubuntu-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Publish to npm (alpha) (push) Has been cancelled
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / macos-latest / Node 22 (push) Has been cancelled
V3 CI/CD Pipeline / Plugin hooks smoke / macos-latest / Node 22 (push) Has been cancelled
CI/CD Pipeline / Deploy & Release (push) Has been cancelled
CI/CD Pipeline / CI Status (push) Has been cancelled
🔗 Cross-Agent Integration Tests / 📊 Integration Test Report (push) Has been cancelled
🔄 Automated Rollback Manager / 🔍 Pre-Rollback Validation (push) Has been cancelled
🔍 Verification Pipeline / ⚡ Performance Verification (push) Has been cancelled
🔍 Verification Pipeline / 📊 Verification Report (push) Has been cancelled
ADR-166 MCP Bridge Security Lock / Static-source security lock (push) Failing after 0s
ADR-166 MCP Bridge Security Lock / Compose default binds loopback + Mongo has auth (push) Failing after 2s
CodeQL Advanced / Analyze (rust) (push) Failing after 0s
ADR-166 MCP Bridge Security Lock / plugin-agent-federation bindHost default (push) Failing after 1s
ADR-166 MCP Bridge Security Lock / Runtime behavior — 401 + terminal gate + fail-closed (push) Failing after 4s
business-pods-smoke / smoke (push) Failing after 1s
all-plugins-smoke / smoke-all (push) Failing after 2s
CI/CD Pipeline / Security & Code Quality (push) Failing after 1s
CI/CD Pipeline / Test Suite (ubuntu-latest) (push) Failing after 1s
CI/CD Pipeline / Build & Package (macos-latest) (push) Has been skipped
CI/CD Pipeline / Build & Package (ubuntu-latest) (push) Has been skipped
CI/CD Pipeline / Build & Package (windows-latest) (push) Has been skipped
CI/CD Pipeline / Documentation & Examples (push) Failing after 1s
Clone Tracker (14-day rolling) / Snapshot clones for ruflo ecosystem (push) Failing after 1s
CodeQL Advanced / Analyze (actions) (push) Failing after 1s
CodeQL Advanced / Analyze (javascript-typescript) (push) Failing after 1s
federation-peer-rust / stable-noop (push) Failing after 1s
metaharness-ci / score (push) Failing after 1s
metaharness-ci / router-compat (push) Failing after 0s
metaharness-ci / similarity-tests (push) Failing after 0s
no-agentbbs-smoke / smoke-without-agentbbs (push) Failing after 1s
V3 CI/CD Pipeline / Build V3 (windows-latest) (push) Has been skipped
codex-integration-audit / Codex integration audit (push) Failing after 1s
helpers-manifest-guard / guard (push) Failing after 1s
🔗 Cross-Agent Integration Tests / 🤝 Agent Coordination Tests (push) Has been skipped
🔗 Cross-Agent Integration Tests / 🧠 Memory Sharing Integration (push) Has been skipped
🔗 Cross-Agent Integration Tests / 🛡️ Fault Tolerance Tests (push) Has been skipped
🔗 Cross-Agent Integration Tests / ⚡ Performance Integration Tests (push) Has been skipped
metaharness-ci / mcp-scan (push) Failing after 1s
metaharness-ci / eject-dryrun (push) Failing after 1s
metaharness-ci / metaharness-real-data (push) Failing after 0s
no-cli-optdep-bloat-2561 / guard (push) Failing after 1s
no-metaharness-smoke / smoke-without-metaharness (push) Failing after 1s
no-phantom-agentic-flow-subpath / guard (push) Failing after 1s
🔄 Automated Rollback Manager / 🚨 Failure Detection (push) Failing after 1s
V3 CI/CD Pipeline / Plugin hooks smoke / ubuntu-latest / Node 22 (push) Failing after 1s
V3 CI/CD Pipeline / ruflo-graph-intelligence build + test smoke (#2044, ADR-123) (push) Failing after 1s
CVE Audit Gate / Audit root (critical-blocking) (push) Failing after 2s
cost-tracker-smoke / smoke (push) Failing after 3s
oia-audit-weekly / audit (push) Failing after 2s
ruflo-agent-smoke / ruflo-agent structural smoke (push) Failing after 1s
📊 Status Badges Update / 📊 Update Status Badges (push) Failing after 1s
V3 CI/CD Pipeline / Static regression guards (#2267 YAML + (push) Failing after 1s
V3 CI/CD Pipeline / Test V3 Packages (push) Failing after 0s
V3 CI/CD Pipeline / agent_execute provider routing smoke (#2042) (push) Failing after 0s
CVE Audit Gate / Audit v3 (critical-blocking) (push) Failing after 1s
federation-peer-rust / stable-native (push) Failing after 2s
🔗 Cross-Agent Integration Tests / 🚀 Integration Test Setup (push) Failing after 2s
neural-trader-smoke / runtime-smoke (push) Failing after 1s
V3 CI/CD Pipeline / Build V3 (macos-latest) (push) Has been skipped
V3 CI/CD Pipeline / Build V3 (ubuntu-latest) (push) Has been skipped
V3 CI/CD Pipeline / Type Check V3 (push) Failing after 1s
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / ubuntu-latest / Node 24 (push) Failing after 1s
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / ubuntu-latest / Node 22 (push) Failing after 2s
V3 CI/CD Pipeline / browser rvf create flag smoke (#2015) (push) Failing after 0s
V3 CI/CD Pipeline / Dependency review (#2046) (push) Has been skipped
V3 CI/CD Pipeline / Supply-chain audit (#2046) (push) Failing after 0s
V3 CI/CD Pipeline / witness marker drift smoke (#2021) (push) Failing after 1s
V3 CI/CD Pipeline / neural-trader portfolio CG smoke (#2068, ADR-126 Phase 3) (push) Failing after 1s
V3 CI/CD Pipeline / neural-trader backtest signing smoke (#2068, ADR-126 Phase 4) (push) Failing after 1s
V3 CI/CD Pipeline / kg-extract type-import classification smoke (#2049) (push) Failing after 0s
V3 CI/CD Pipeline / witness verify precondition smoke (#1880) (push) Failing after 2s
V3 CI/CD Pipeline / neural-trader pipeline risk-gate smoke (#2068, ADR-126 Phase 5) (push) Failing after 0s
V3 CI/CD Pipeline / neural-trader feature attribution smoke (#2068, ADR-126 Phase 6) (push) Failing after 0s
V3 CI/CD Pipeline / plugin-registry signature verification smoke (#1922, CWE-347) (push) Failing after 4s
V3 CI/CD Pipeline / memory stats legacy-DB smoke (#2120) (push) Failing after 4s
V3 CI/CD Pipeline / github deprecated actions smoke (#2089, ADR-127 Phase 3) (push) Failing after 1s
V3 CI/CD Pipeline / graph query + pathfinder smoke (ADR-130 P2+P5) (push) Has been skipped
V3 CI/CD Pipeline / graph trajectory hooks smoke (ADR-130 P3) (push) Has been skipped
V3 CI/CD Pipeline / graph plugin adapter smoke (ADR-130 P4) (push) Has been skipped
V3 CI/CD Pipeline / graph benchmark (ADR-130 P6) (push) Has been skipped
V3 CI/CD Pipeline / statusline generator delegation smoke (#2195) (push) Failing after 1s
V3 CI/CD Pipeline / wizard init regression guard (#2206 (push) Failing after 1s
V3 CI/CD Pipeline / memory no-stray-db smoke (ADR-125 P7) (push) Failing after 1s
V3 CI/CD Pipeline / github-safe injection smoke (#2089, ADR-127 Phase 1) (push) Failing after 1s
V3 CI/CD Pipeline / github actions pin smoke (#2089, ADR-127 Phase 1) (push) Failing after 1s
V3 CI/CD Pipeline / github attribution opt-in smoke (#2089, ADR-127 Phase 4) (push) Failing after 1s
V3 CI/CD Pipeline / pre-bash hook safety smoke (#2017) (push) Failing after 1s
V3 CI/CD Pipeline / Memory import smoke / ubuntu-latest (push) Failing after 0s
V3 CI/CD Pipeline / MCP protocol smoke / ubuntu-latest (push) Failing after 2s
V3 CI/CD Pipeline / ruvllm WASM auto-init smoke (#2086) (push) Failing after 4s
V3 CI/CD Pipeline / MCP paired-tool round-trip smoke (#1889) (push) Failing after 1s
V3 CI/CD Pipeline / Plugin package install-safety (#1902/#1903/#1904) (push) Failing after 1s
V3 CI/CD Pipeline / Tool description discoverability (ADR-112) (push) Failing after 3s
V3 CI/CD Pipeline / CLI npx-install smoke (#1147 / (22) (push) Failing after 1s
V3 CI/CD Pipeline / CLI npx-install smoke (#1147 / (24) (push) Failing after 1s
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / ubuntu-latest (push) Failing after 2s
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / ubuntu-latest (push) Failing after 1s
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / ubuntu-latest (push) Failing after 1s
V3 CI/CD Pipeline / Vector-index dimension audit (#1947) (push) Failing after 0s
V3 CI/CD Pipeline / Hook-command install safety (#1921) (push) Failing after 1s
V3 CI/CD Pipeline / ToolOutputGuardrail smoke (ADR-131, (push) Failing after 1s
V3 CI/CD Pipeline / init-bundle invariants smoke (#2095, ADR-128 Phase 5) (push) Failing after 1s
V3 CI/CD Pipeline / wasm provider bridge smoke (ADR-129 P1) (push) Failing after 2s
V3 CI/CD Pipeline / wasm gallery CRUD smoke (ADR-129 P3) (push) Failing after 1s
V3 CI/CD Pipeline / wasm plugin bridge smoke (ADR-129 P4) (push) Failing after 0s
V3 CI/CD Pipeline / wasm compose smoke (ADR-129 P2) (push) Failing after 4s
V3 CI/CD Pipeline / graph schema smoke (ADR-130 P1) (push) Failing after 0s
Validate Marketplace / validate (push) Failing after 1s
🔍 Verification Pipeline / 🚀 Setup Verification (push) Failing after 1s
🔍 Verification Pipeline / 🛡️ Security Verification (push) Has been skipped
🔍 Verification Pipeline / 📝 Code Quality (push) Has been skipped
🔍 Verification Pipeline / 🧪 Test Verification (${{ matrix.os }}, Node ${{ matrix.node }}) (push) Has been skipped
🔍 Verification Pipeline / 🏗️ Build Verification (push) Has been skipped
🔍 Verification Pipeline / 📚 Documentation Verification (push) Has been skipped
CVE Audit Gate / High-severity report (warn only) (push) Has been cancelled
🔄 Automated Rollback Manager / 🔄 Execute Rollback (push) Has been cancelled
🔄 Automated Rollback Manager / ✅ Post-Rollback Verification (push) Has been cancelled
🔄 Automated Rollback Manager / 📊 Rollback Monitoring (push) Has been cancelled
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / windows-latest (push) Has been cancelled
🔄 Automated Rollback Manager / ⏳ Manual Rollback Approval (push) Has been cancelled
V3 CI/CD Pipeline / MCP protocol smoke / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Memory import smoke / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / ubuntu-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Publish to npm (alpha) (push) Has been cancelled
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / macos-latest / Node 22 (push) Has been cancelled
V3 CI/CD Pipeline / Plugin hooks smoke / macos-latest / Node 22 (push) Has been cancelled
CI/CD Pipeline / Deploy & Release (push) Has been cancelled
CI/CD Pipeline / CI Status (push) Has been cancelled
🔗 Cross-Agent Integration Tests / 📊 Integration Test Report (push) Has been cancelled
🔄 Automated Rollback Manager / 🔍 Pre-Rollback Validation (push) Has been cancelled
🔍 Verification Pipeline / ⚡ Performance Verification (push) Has been cancelled
🔍 Verification Pipeline / 📊 Verification Report (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,268 @@
|
||||
/**
|
||||
* Code Intelligence Plugin - Bridge Tests
|
||||
*
|
||||
* Tests for GNNBridge initialization, lifecycle, and methods
|
||||
*/
|
||||
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
import { GNNBridge } from '../src/bridges/gnn-bridge.js';
|
||||
|
||||
// Mock WASM module
|
||||
vi.mock('../src/bridges/gnn-wasm.js', () => ({
|
||||
initWasm: vi.fn().mockResolvedValue(undefined),
|
||||
wasmAvailable: vi.fn().mockReturnValue(false),
|
||||
}));
|
||||
|
||||
describe('GNNBridge', () => {
|
||||
let bridge: GNNBridge;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
bridge = new GNNBridge();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// GNNBridge doesn't have explicit destroy
|
||||
});
|
||||
|
||||
describe('Initialization', () => {
|
||||
it('should create bridge instance', () => {
|
||||
expect(bridge).toBeInstanceOf(GNNBridge);
|
||||
});
|
||||
|
||||
it('should not be initialized before init', () => {
|
||||
expect(bridge.isInitialized()).toBe(false);
|
||||
});
|
||||
|
||||
it('should initialize successfully', async () => {
|
||||
await bridge.initialize();
|
||||
expect(bridge.isInitialized()).toBe(true);
|
||||
});
|
||||
|
||||
it('should initialize with custom embedding dimension', async () => {
|
||||
const customBridge = new GNNBridge(256);
|
||||
await customBridge.initialize();
|
||||
expect(customBridge.isInitialized()).toBe(true);
|
||||
});
|
||||
|
||||
it('should handle double initialization gracefully', async () => {
|
||||
await bridge.initialize();
|
||||
await bridge.initialize();
|
||||
expect(bridge.isInitialized()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Build Code Graph', () => {
|
||||
beforeEach(async () => {
|
||||
await bridge.initialize();
|
||||
});
|
||||
|
||||
it('should build code graph from files', async () => {
|
||||
const files = [
|
||||
'src/utils.ts',
|
||||
'src/main.ts',
|
||||
'src/types.ts',
|
||||
];
|
||||
|
||||
const graph = await bridge.buildCodeGraph(files, true);
|
||||
|
||||
expect(graph).toHaveProperty('nodes');
|
||||
expect(graph).toHaveProperty('edges');
|
||||
expect(graph).toHaveProperty('metadata');
|
||||
expect(graph.nodes.length).toBe(3);
|
||||
});
|
||||
|
||||
it('should handle empty file list', async () => {
|
||||
const graph = await bridge.buildCodeGraph([], false);
|
||||
|
||||
expect(graph.nodes.length).toBe(0);
|
||||
expect(graph.edges.length).toBe(0);
|
||||
});
|
||||
|
||||
it('should detect file types correctly', async () => {
|
||||
const files = [
|
||||
'src/component.tsx',
|
||||
'src/style.css',
|
||||
'src/config.json',
|
||||
'src/script.py',
|
||||
];
|
||||
|
||||
const graph = await bridge.buildCodeGraph(files, false);
|
||||
|
||||
expect(graph.nodes.length).toBe(4);
|
||||
// Each node should have detected language
|
||||
for (const node of graph.nodes) {
|
||||
expect(node).toHaveProperty('language');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('Compute Node Embeddings', () => {
|
||||
beforeEach(async () => {
|
||||
await bridge.initialize();
|
||||
});
|
||||
|
||||
it('should compute embeddings for graph nodes', async () => {
|
||||
const files = ['src/a.ts', 'src/b.ts'];
|
||||
const graph = await bridge.buildCodeGraph(files, false);
|
||||
|
||||
const embeddings = await bridge.computeNodeEmbeddings(graph, 64);
|
||||
|
||||
expect(embeddings.size).toBe(2);
|
||||
expect(embeddings.has('src/a.ts')).toBe(true);
|
||||
expect(embeddings.has('src/b.ts')).toBe(true);
|
||||
});
|
||||
|
||||
it('should return embeddings of correct dimension', async () => {
|
||||
const files = ['src/test.ts'];
|
||||
const graph = await bridge.buildCodeGraph(files, false);
|
||||
const embeddingDim = 128;
|
||||
|
||||
const embeddings = await bridge.computeNodeEmbeddings(graph, embeddingDim);
|
||||
|
||||
const embedding = embeddings.get('src/test.ts');
|
||||
expect(embedding).toBeDefined();
|
||||
expect(embedding!.length).toBe(embeddingDim);
|
||||
});
|
||||
|
||||
it('should handle empty graph', async () => {
|
||||
const graph = await bridge.buildCodeGraph([], false);
|
||||
const embeddings = await bridge.computeNodeEmbeddings(graph, 64);
|
||||
|
||||
expect(embeddings.size).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Impact Prediction', () => {
|
||||
beforeEach(async () => {
|
||||
await bridge.initialize();
|
||||
});
|
||||
|
||||
it('should predict impact of changes', async () => {
|
||||
const files = [
|
||||
'src/core.ts',
|
||||
'src/utils.ts',
|
||||
'src/api.ts',
|
||||
];
|
||||
const graph = await bridge.buildCodeGraph(files, true);
|
||||
|
||||
// predictImpact returns Map<string, number> with node impact scores
|
||||
const impact = await bridge.predictImpact(graph, ['src/core.ts'], 3);
|
||||
|
||||
expect(impact).toBeInstanceOf(Map);
|
||||
expect(impact.has('src/core.ts')).toBe(true);
|
||||
});
|
||||
|
||||
it('should handle empty changed files', async () => {
|
||||
const files = ['src/a.ts', 'src/b.ts'];
|
||||
const graph = await bridge.buildCodeGraph(files, false);
|
||||
|
||||
const impact = await bridge.predictImpact(graph, [], 3);
|
||||
|
||||
expect(impact).toBeInstanceOf(Map);
|
||||
expect(impact.size).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Community Detection', () => {
|
||||
beforeEach(async () => {
|
||||
await bridge.initialize();
|
||||
});
|
||||
|
||||
it('should detect communities in code graph', async () => {
|
||||
const files = [
|
||||
'src/auth/login.ts',
|
||||
'src/auth/logout.ts',
|
||||
'src/data/fetch.ts',
|
||||
'src/data/save.ts',
|
||||
];
|
||||
const graph = await bridge.buildCodeGraph(files, true);
|
||||
|
||||
// detectCommunities returns Map<string, number> (nodeId -> communityId)
|
||||
const communities = await bridge.detectCommunities(graph);
|
||||
|
||||
expect(communities).toBeInstanceOf(Map);
|
||||
expect(communities.size).toBe(4);
|
||||
});
|
||||
|
||||
it('should handle single node graph', async () => {
|
||||
const files = ['src/single.ts'];
|
||||
const graph = await bridge.buildCodeGraph(files, false);
|
||||
|
||||
const communities = await bridge.detectCommunities(graph);
|
||||
|
||||
expect(communities).toBeInstanceOf(Map);
|
||||
expect(communities.size).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Pattern Matching', () => {
|
||||
beforeEach(async () => {
|
||||
await bridge.initialize();
|
||||
});
|
||||
|
||||
it('should find similar patterns', async () => {
|
||||
const files = [
|
||||
'src/userService.ts',
|
||||
'src/orderService.ts',
|
||||
'src/productService.ts',
|
||||
];
|
||||
const graph = await bridge.buildCodeGraph(files, true);
|
||||
|
||||
// Create a pattern graph to search for
|
||||
const patternGraph = await bridge.buildCodeGraph(['src/userService.ts'], false);
|
||||
|
||||
// findSimilarPatterns expects (graph, patternGraph, threshold)
|
||||
const patterns = await bridge.findSimilarPatterns(graph, patternGraph, 0.5);
|
||||
|
||||
expect(Array.isArray(patterns)).toBe(true);
|
||||
for (const pattern of patterns) {
|
||||
expect(pattern).toHaveProperty('matchId');
|
||||
expect(pattern).toHaveProperty('score');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('JavaScript Fallback', () => {
|
||||
it('should work without WASM', async () => {
|
||||
const fallbackBridge = new GNNBridge();
|
||||
await fallbackBridge.initialize();
|
||||
|
||||
const files = ['src/test.ts'];
|
||||
const graph = await fallbackBridge.buildCodeGraph(files, false);
|
||||
|
||||
expect(graph.nodes.length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Performance', () => {
|
||||
beforeEach(async () => {
|
||||
await bridge.initialize();
|
||||
});
|
||||
|
||||
it('should handle large file lists efficiently', async () => {
|
||||
const files = Array(100).fill(null).map((_, i) => `src/file${i}.ts`);
|
||||
|
||||
const start = performance.now();
|
||||
const graph = await bridge.buildCodeGraph(files, true);
|
||||
const duration = performance.now() - start;
|
||||
|
||||
expect(graph.nodes.length).toBe(100);
|
||||
expect(duration).toBeLessThan(5000); // Should complete in < 5 seconds
|
||||
});
|
||||
});
|
||||
|
||||
describe('Memory Management', () => {
|
||||
it('should handle multiple graph operations', async () => {
|
||||
await bridge.initialize();
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const files = Array(20).fill(null).map((_, j) => `src/module${i}/file${j}.ts`);
|
||||
const graph = await bridge.buildCodeGraph(files, true);
|
||||
await bridge.computeNodeEmbeddings(graph, 64);
|
||||
}
|
||||
|
||||
expect(bridge.isInitialized()).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,667 @@
|
||||
/**
|
||||
* Code Intelligence Plugin - MCP Tools Tests
|
||||
*
|
||||
* Tests for MCP tool handlers with mock data
|
||||
*/
|
||||
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
import {
|
||||
semanticSearchTool,
|
||||
architectureAnalyzeTool,
|
||||
refactorImpactTool,
|
||||
splitSuggestTool,
|
||||
learnPatternsTool,
|
||||
codeIntelligenceTools,
|
||||
getTool,
|
||||
getToolNames,
|
||||
} from '../src/mcp-tools.js';
|
||||
|
||||
// Mock bridges
|
||||
vi.mock('../src/bridges/hnsw-bridge.js', () => ({
|
||||
CodeHNSWBridge: vi.fn().mockImplementation(() => ({
|
||||
initialized: false,
|
||||
initialize: vi.fn().mockResolvedValue(undefined),
|
||||
searchSemantic: vi.fn().mockResolvedValue([
|
||||
{
|
||||
id: 'result-1',
|
||||
path: 'src/auth/login.ts',
|
||||
content: 'async function login(username, password) { ... }',
|
||||
score: 0.92,
|
||||
language: 'typescript',
|
||||
},
|
||||
{
|
||||
id: 'result-2',
|
||||
path: 'src/auth/session.ts',
|
||||
content: 'function createSession(user) { ... }',
|
||||
score: 0.85,
|
||||
language: 'typescript',
|
||||
},
|
||||
]),
|
||||
count: vi.fn().mockResolvedValue(5000),
|
||||
})),
|
||||
}));
|
||||
|
||||
vi.mock('../src/bridges/gnn-bridge.js', () => ({
|
||||
CodeGNNBridge: vi.fn().mockImplementation(() => ({
|
||||
initialized: false,
|
||||
initialize: vi.fn().mockResolvedValue(undefined),
|
||||
analyzeArchitecture: vi.fn().mockResolvedValue({
|
||||
components: [
|
||||
{ name: 'AuthModule', type: 'module', files: 5, dependencies: 3 },
|
||||
{ name: 'UserService', type: 'service', files: 3, dependencies: 2 },
|
||||
],
|
||||
metrics: {
|
||||
modularity: 0.72,
|
||||
coupling: 0.35,
|
||||
cohesion: 0.68,
|
||||
},
|
||||
issues: [
|
||||
{ type: 'circular_dependency', components: ['AuthModule', 'UserService'], severity: 'medium' },
|
||||
],
|
||||
}),
|
||||
analyzeRefactorImpact: vi.fn().mockResolvedValue({
|
||||
directImpact: ['src/user.ts', 'src/auth.ts'],
|
||||
indirectImpact: ['src/api/routes.ts', 'tests/user.test.ts'],
|
||||
riskLevel: 'medium',
|
||||
breakingChanges: ['UserService.getById signature changed'],
|
||||
}),
|
||||
suggestSplit: vi.fn().mockResolvedValue([
|
||||
{
|
||||
file: 'src/utils.ts',
|
||||
reason: 'File exceeds 500 lines with multiple responsibilities',
|
||||
suggestedSplits: [
|
||||
{ name: 'string-utils.ts', functions: ['capitalize', 'truncate', 'slugify'] },
|
||||
{ name: 'date-utils.ts', functions: ['formatDate', 'parseDate', 'addDays'] },
|
||||
],
|
||||
},
|
||||
]),
|
||||
learnPatterns: vi.fn().mockResolvedValue({
|
||||
patterns: [
|
||||
{ name: 'Repository Pattern', occurrences: 12, confidence: 0.88 },
|
||||
{ name: 'Factory Pattern', occurrences: 5, confidence: 0.75 },
|
||||
],
|
||||
antiPatterns: [
|
||||
{ name: 'God Object', files: ['src/app.ts'], severity: 'high' },
|
||||
],
|
||||
}),
|
||||
})),
|
||||
}));
|
||||
|
||||
// Mock context for testing
|
||||
const createMockContext = (overrides = {}) => ({
|
||||
logger: {
|
||||
debug: vi.fn(),
|
||||
info: vi.fn(),
|
||||
warn: vi.fn(),
|
||||
error: vi.fn(),
|
||||
},
|
||||
userId: 'test-user',
|
||||
...overrides,
|
||||
});
|
||||
|
||||
describe('Code Intelligence MCP Tools', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
describe('Tool Registry', () => {
|
||||
it('should export all 5 tools', () => {
|
||||
expect(codeIntelligenceTools).toHaveLength(5);
|
||||
});
|
||||
|
||||
it('should have correct tool names', () => {
|
||||
const toolNames = codeIntelligenceTools.map(t => t.name);
|
||||
expect(toolNames).toContain('code/semantic-search');
|
||||
expect(toolNames).toContain('code/architecture-analyze');
|
||||
expect(toolNames).toContain('code/refactor-impact');
|
||||
expect(toolNames).toContain('code/split-suggest');
|
||||
expect(toolNames).toContain('code/learn-patterns');
|
||||
});
|
||||
|
||||
it('should have category code-intelligence', () => {
|
||||
for (const tool of codeIntelligenceTools) {
|
||||
expect(tool.category).toBe('code-intelligence');
|
||||
}
|
||||
});
|
||||
|
||||
it('should have version 0.1.0', () => {
|
||||
for (const tool of codeIntelligenceTools) {
|
||||
expect(tool.version).toBe('0.1.0');
|
||||
}
|
||||
});
|
||||
|
||||
it('should get tool by name', () => {
|
||||
const tool = getTool('code/semantic-search');
|
||||
expect(tool).toBeDefined();
|
||||
expect(tool?.name).toBe('code/semantic-search');
|
||||
});
|
||||
|
||||
it('should return undefined for unknown tool', () => {
|
||||
const tool = getTool('code/unknown');
|
||||
expect(tool).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should get all tool names', () => {
|
||||
const names = getToolNames();
|
||||
expect(names).toHaveLength(5);
|
||||
expect(names).toContain('code/semantic-search');
|
||||
});
|
||||
});
|
||||
|
||||
describe('code/semantic-search', () => {
|
||||
it('should have correct tool definition', () => {
|
||||
expect(semanticSearchTool.name).toBe('code/semantic-search');
|
||||
expect(semanticSearchTool.inputSchema.required).toContain('query');
|
||||
expect(semanticSearchTool.cacheable).toBe(true);
|
||||
});
|
||||
|
||||
it('should handle valid input', async () => {
|
||||
const input = {
|
||||
query: 'authentication login function',
|
||||
topK: 10,
|
||||
};
|
||||
|
||||
const result = await semanticSearchTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBeUndefined();
|
||||
const data = JSON.parse(result.content[0].text!);
|
||||
expect(data.results).toBeDefined();
|
||||
expect(Array.isArray(data.results)).toBe(true);
|
||||
expect(data.searchTime).toBeDefined();
|
||||
});
|
||||
|
||||
it('should handle language filter', async () => {
|
||||
const input = {
|
||||
query: 'error handling',
|
||||
language: 'typescript',
|
||||
};
|
||||
|
||||
const result = await semanticSearchTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should handle search type filter', async () => {
|
||||
const types = ['function', 'class', 'interface', 'type', 'variable', 'comment', 'any'] as const;
|
||||
|
||||
for (const searchType of types) {
|
||||
const input = {
|
||||
query: 'user data',
|
||||
searchType,
|
||||
};
|
||||
|
||||
const result = await semanticSearchTool.handler(input, createMockContext());
|
||||
expect(result.isError).toBeUndefined();
|
||||
}
|
||||
});
|
||||
|
||||
it('should handle path filter', async () => {
|
||||
const input = {
|
||||
query: 'API endpoint',
|
||||
pathFilter: 'src/api/',
|
||||
};
|
||||
|
||||
const result = await semanticSearchTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should reject missing query', async () => {
|
||||
const input = {
|
||||
topK: 10,
|
||||
};
|
||||
|
||||
const result = await semanticSearchTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBe(true);
|
||||
});
|
||||
|
||||
it('should reject query exceeding max length', async () => {
|
||||
const input = {
|
||||
query: 'a'.repeat(1001),
|
||||
};
|
||||
|
||||
const result = await semanticSearchTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBe(true);
|
||||
});
|
||||
|
||||
it('should reject topK outside valid range', async () => {
|
||||
const input = {
|
||||
query: 'test',
|
||||
topK: 0, // below min
|
||||
};
|
||||
|
||||
const result = await semanticSearchTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('code/architecture-analyze', () => {
|
||||
it('should have correct tool definition', () => {
|
||||
expect(architectureAnalyzeTool.name).toBe('code/architecture-analyze');
|
||||
expect(architectureAnalyzeTool.inputSchema.required).toContain('targetPath');
|
||||
expect(architectureAnalyzeTool.cacheable).toBe(true);
|
||||
});
|
||||
|
||||
it('should handle valid input', async () => {
|
||||
const input = {
|
||||
targetPath: 'src/',
|
||||
analysisTypes: ['dependencies', 'modularity'],
|
||||
};
|
||||
|
||||
const result = await architectureAnalyzeTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBeUndefined();
|
||||
const data = JSON.parse(result.content[0].text!);
|
||||
expect(data.components).toBeDefined();
|
||||
expect(data.metrics).toBeDefined();
|
||||
expect(data.analysisTime).toBeDefined();
|
||||
});
|
||||
|
||||
it('should handle all analysis types', async () => {
|
||||
const types = ['dependencies', 'modularity', 'complexity', 'coupling', 'cohesion', 'layers'] as const;
|
||||
|
||||
const input = {
|
||||
targetPath: 'src/',
|
||||
analysisTypes: [...types],
|
||||
};
|
||||
|
||||
const result = await architectureAnalyzeTool.handler(input, createMockContext());
|
||||
expect(result.isError).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should handle depth option', async () => {
|
||||
const input = {
|
||||
targetPath: 'src/',
|
||||
depth: 5,
|
||||
};
|
||||
|
||||
const result = await architectureAnalyzeTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should handle exclude patterns', async () => {
|
||||
const input = {
|
||||
targetPath: 'src/',
|
||||
excludePatterns: ['node_modules', '*.test.ts'],
|
||||
};
|
||||
|
||||
const result = await architectureAnalyzeTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should reject missing targetPath', async () => {
|
||||
const input = {
|
||||
analysisTypes: ['dependencies'],
|
||||
};
|
||||
|
||||
const result = await architectureAnalyzeTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBe(true);
|
||||
});
|
||||
|
||||
it('should reject targetPath exceeding max length', async () => {
|
||||
const input = {
|
||||
targetPath: 'a'.repeat(501),
|
||||
};
|
||||
|
||||
const result = await architectureAnalyzeTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('code/refactor-impact', () => {
|
||||
it('should have correct tool definition', () => {
|
||||
expect(refactorImpactTool.name).toBe('code/refactor-impact');
|
||||
expect(refactorImpactTool.inputSchema.required).toContain('targetPath');
|
||||
expect(refactorImpactTool.inputSchema.required).toContain('changeType');
|
||||
expect(refactorImpactTool.cacheable).toBe(false);
|
||||
});
|
||||
|
||||
it('should handle valid input', async () => {
|
||||
const input = {
|
||||
targetPath: 'src/services/user.ts',
|
||||
changeType: 'rename',
|
||||
description: 'Rename UserService to UserRepository',
|
||||
};
|
||||
|
||||
const result = await refactorImpactTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBeUndefined();
|
||||
const data = JSON.parse(result.content[0].text!);
|
||||
expect(data.directImpact).toBeDefined();
|
||||
expect(data.indirectImpact).toBeDefined();
|
||||
expect(data.riskLevel).toBeDefined();
|
||||
});
|
||||
|
||||
it('should handle all change types', async () => {
|
||||
const types = ['rename', 'move', 'delete', 'signature_change', 'type_change', 'dependency_change'] as const;
|
||||
|
||||
for (const changeType of types) {
|
||||
const input = {
|
||||
targetPath: 'src/test.ts',
|
||||
changeType,
|
||||
};
|
||||
|
||||
const result = await refactorImpactTool.handler(input, createMockContext());
|
||||
expect(result.isError).toBeUndefined();
|
||||
}
|
||||
});
|
||||
|
||||
it('should handle include tests option', async () => {
|
||||
const input = {
|
||||
targetPath: 'src/service.ts',
|
||||
changeType: 'delete',
|
||||
includeTests: true,
|
||||
};
|
||||
|
||||
const result = await refactorImpactTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should handle depth option', async () => {
|
||||
const input = {
|
||||
targetPath: 'src/core.ts',
|
||||
changeType: 'signature_change',
|
||||
depth: 3,
|
||||
};
|
||||
|
||||
const result = await refactorImpactTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should reject missing targetPath', async () => {
|
||||
const input = {
|
||||
changeType: 'rename',
|
||||
};
|
||||
|
||||
const result = await refactorImpactTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBe(true);
|
||||
});
|
||||
|
||||
it('should reject missing changeType', async () => {
|
||||
const input = {
|
||||
targetPath: 'src/test.ts',
|
||||
};
|
||||
|
||||
const result = await refactorImpactTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBe(true);
|
||||
});
|
||||
|
||||
it('should reject invalid changeType', async () => {
|
||||
const input = {
|
||||
targetPath: 'src/test.ts',
|
||||
changeType: 'invalid_change',
|
||||
};
|
||||
|
||||
const result = await refactorImpactTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('code/split-suggest', () => {
|
||||
it('should have correct tool definition', () => {
|
||||
expect(splitSuggestTool.name).toBe('code/split-suggest');
|
||||
expect(splitSuggestTool.inputSchema.required).toContain('targetPath');
|
||||
expect(splitSuggestTool.cacheable).toBe(true);
|
||||
});
|
||||
|
||||
it('should handle valid input', async () => {
|
||||
const input = {
|
||||
targetPath: 'src/utils.ts',
|
||||
threshold: 300,
|
||||
};
|
||||
|
||||
const result = await splitSuggestTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBeUndefined();
|
||||
const data = JSON.parse(result.content[0].text!);
|
||||
expect(data.suggestions).toBeDefined();
|
||||
expect(data.analysisTime).toBeDefined();
|
||||
});
|
||||
|
||||
it('should handle all split strategies', async () => {
|
||||
const strategies = ['responsibility', 'cohesion', 'size', 'complexity'] as const;
|
||||
|
||||
for (const strategy of strategies) {
|
||||
const input = {
|
||||
targetPath: 'src/',
|
||||
strategy,
|
||||
};
|
||||
|
||||
const result = await splitSuggestTool.handler(input, createMockContext());
|
||||
expect(result.isError).toBeUndefined();
|
||||
}
|
||||
});
|
||||
|
||||
it('should use default threshold', async () => {
|
||||
const input = {
|
||||
targetPath: 'src/',
|
||||
};
|
||||
|
||||
const result = await splitSuggestTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBeUndefined();
|
||||
const data = JSON.parse(result.content[0].text!);
|
||||
expect(data.threshold).toBe(500); // default
|
||||
});
|
||||
|
||||
it('should handle include patterns', async () => {
|
||||
const input = {
|
||||
targetPath: 'src/',
|
||||
includePatterns: ['*.ts', '*.tsx'],
|
||||
};
|
||||
|
||||
const result = await splitSuggestTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should reject missing targetPath', async () => {
|
||||
const input = {
|
||||
threshold: 300,
|
||||
};
|
||||
|
||||
const result = await splitSuggestTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBe(true);
|
||||
});
|
||||
|
||||
it('should reject threshold outside valid range', async () => {
|
||||
const tooLow = {
|
||||
targetPath: 'src/',
|
||||
threshold: 49, // below min of 50
|
||||
};
|
||||
|
||||
const result = await splitSuggestTool.handler(tooLow, createMockContext());
|
||||
expect(result.isError).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('code/learn-patterns', () => {
|
||||
it('should have correct tool definition', () => {
|
||||
expect(learnPatternsTool.name).toBe('code/learn-patterns');
|
||||
expect(learnPatternsTool.inputSchema.required).toContain('targetPath');
|
||||
expect(learnPatternsTool.cacheable).toBe(true);
|
||||
});
|
||||
|
||||
it('should handle valid input', async () => {
|
||||
const input = {
|
||||
targetPath: 'src/',
|
||||
patternTypes: ['design_patterns', 'anti_patterns'],
|
||||
};
|
||||
|
||||
const result = await learnPatternsTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBeUndefined();
|
||||
const data = JSON.parse(result.content[0].text!);
|
||||
expect(data.patterns).toBeDefined();
|
||||
expect(data.antiPatterns).toBeDefined();
|
||||
expect(data.analysisTime).toBeDefined();
|
||||
});
|
||||
|
||||
it('should handle all pattern types', async () => {
|
||||
const types = ['design_patterns', 'anti_patterns', 'idioms', 'conventions', 'architecture'] as const;
|
||||
|
||||
const input = {
|
||||
targetPath: 'src/',
|
||||
patternTypes: [...types],
|
||||
};
|
||||
|
||||
const result = await learnPatternsTool.handler(input, createMockContext());
|
||||
expect(result.isError).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should handle language filter', async () => {
|
||||
const input = {
|
||||
targetPath: 'src/',
|
||||
language: 'typescript',
|
||||
};
|
||||
|
||||
const result = await learnPatternsTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should handle min confidence threshold', async () => {
|
||||
const input = {
|
||||
targetPath: 'src/',
|
||||
minConfidence: 0.8,
|
||||
};
|
||||
|
||||
const result = await learnPatternsTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should reject missing targetPath', async () => {
|
||||
const input = {
|
||||
patternTypes: ['design_patterns'],
|
||||
};
|
||||
|
||||
const result = await learnPatternsTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBe(true);
|
||||
});
|
||||
|
||||
it('should reject minConfidence outside valid range', async () => {
|
||||
const input = {
|
||||
targetPath: 'src/',
|
||||
minConfidence: 1.5, // above max of 1.0
|
||||
};
|
||||
|
||||
const result = await learnPatternsTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Security - Secret Masking', () => {
|
||||
it('should mask secrets in search results', async () => {
|
||||
// This tests that the tool doesn't expose secrets
|
||||
const input = {
|
||||
query: 'api key configuration',
|
||||
};
|
||||
|
||||
const result = await semanticSearchTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBeUndefined();
|
||||
const data = JSON.parse(result.content[0].text!);
|
||||
|
||||
// Results should not contain unmasked secrets
|
||||
for (const r of data.results) {
|
||||
expect(r.content).not.toMatch(/sk-[a-zA-Z0-9]{48}/); // OpenAI key pattern
|
||||
expect(r.content).not.toMatch(/AKIA[0-9A-Z]{16}/); // AWS key pattern
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('Error Handling', () => {
|
||||
it('should handle validation errors gracefully', async () => {
|
||||
const input = {
|
||||
query: '', // Invalid empty query
|
||||
};
|
||||
|
||||
const result = await semanticSearchTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBe(true);
|
||||
const data = JSON.parse(result.content[0].text!);
|
||||
expect(data.error).toBe(true);
|
||||
expect(data.message).toBeDefined();
|
||||
});
|
||||
|
||||
it('should include timestamp in error response', async () => {
|
||||
const input = {
|
||||
targetPath: '', // Invalid
|
||||
};
|
||||
|
||||
const result = await architectureAnalyzeTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBe(true);
|
||||
const data = JSON.parse(result.content[0].text!);
|
||||
expect(data.timestamp).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Performance Logging', () => {
|
||||
it('should log duration on success', async () => {
|
||||
const mockLogger = {
|
||||
debug: vi.fn(),
|
||||
info: vi.fn(),
|
||||
warn: vi.fn(),
|
||||
error: vi.fn(),
|
||||
};
|
||||
|
||||
const input = { query: 'test function' };
|
||||
await semanticSearchTool.handler(input, { logger: mockLogger });
|
||||
|
||||
expect(mockLogger.info).toHaveBeenCalledWith(
|
||||
expect.stringContaining('completed'),
|
||||
expect.objectContaining({ durationMs: expect.any(String) })
|
||||
);
|
||||
});
|
||||
|
||||
it('should include analysis time in results', async () => {
|
||||
const input = {
|
||||
targetPath: 'src/',
|
||||
};
|
||||
|
||||
const result = await architectureAnalyzeTool.handler(input, createMockContext());
|
||||
|
||||
expect(result.isError).toBeUndefined();
|
||||
const data = JSON.parse(result.content[0].text!);
|
||||
expect(data.analysisTime).toBeDefined();
|
||||
expect(typeof data.analysisTime).toBe('number');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Output Format', () => {
|
||||
it('should support different output formats', async () => {
|
||||
const formats = ['json', 'markdown', 'summary'] as const;
|
||||
|
||||
for (const outputFormat of formats) {
|
||||
const input = {
|
||||
targetPath: 'src/',
|
||||
outputFormat,
|
||||
};
|
||||
|
||||
const result = await architectureAnalyzeTool.handler(input, createMockContext());
|
||||
expect(result.isError).toBeUndefined();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,543 @@
|
||||
/**
|
||||
* Code Intelligence Plugin - Types Tests
|
||||
*
|
||||
* Tests for Zod schemas and type validation
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import {
|
||||
Language,
|
||||
LanguageTier,
|
||||
SearchType,
|
||||
AnalysisType,
|
||||
OutputFormat,
|
||||
ChangeType,
|
||||
SplitStrategy,
|
||||
PatternType,
|
||||
SemanticSearchInputSchema,
|
||||
ArchitectureAnalyzeInputSchema,
|
||||
RefactorImpactInputSchema,
|
||||
SplitSuggestInputSchema,
|
||||
LearnPatternsInputSchema,
|
||||
DEFAULT_CONFIG,
|
||||
CodeIntelligenceErrorCodes,
|
||||
CodeIntelligenceError,
|
||||
SECRET_PATTERNS,
|
||||
maskSecrets,
|
||||
} from '../src/types.js';
|
||||
|
||||
describe('Code Intelligence Types', () => {
|
||||
describe('Language Enum', () => {
|
||||
it('should validate all supported languages', () => {
|
||||
const validLanguages = [
|
||||
'typescript', 'javascript', 'python', 'java', 'go',
|
||||
'rust', 'cpp', 'csharp', 'ruby', 'php', 'swift', 'kotlin', 'scala',
|
||||
];
|
||||
|
||||
for (const lang of validLanguages) {
|
||||
const result = Language.safeParse(lang);
|
||||
expect(result.success).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('should reject invalid languages', () => {
|
||||
const result = Language.safeParse('cobol');
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('LanguageTier', () => {
|
||||
it('should classify TypeScript and JavaScript as tier1', () => {
|
||||
expect(LanguageTier.typescript).toBe('tier1');
|
||||
expect(LanguageTier.javascript).toBe('tier1');
|
||||
});
|
||||
|
||||
it('should classify Python and Java as tier2', () => {
|
||||
expect(LanguageTier.python).toBe('tier2');
|
||||
expect(LanguageTier.java).toBe('tier2');
|
||||
});
|
||||
|
||||
it('should classify Go and Rust as tier3', () => {
|
||||
expect(LanguageTier.go).toBe('tier3');
|
||||
expect(LanguageTier.rust).toBe('tier3');
|
||||
});
|
||||
});
|
||||
|
||||
describe('SearchType Enum', () => {
|
||||
it('should validate all search types', () => {
|
||||
const validTypes = ['semantic', 'structural', 'clone', 'api_usage'];
|
||||
|
||||
for (const type of validTypes) {
|
||||
const result = SearchType.safeParse(type);
|
||||
expect(result.success).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('AnalysisType Enum', () => {
|
||||
it('should validate all analysis types', () => {
|
||||
const validTypes = [
|
||||
'dependency_graph', 'layer_violations', 'circular_deps',
|
||||
'component_coupling', 'module_cohesion', 'dead_code',
|
||||
'api_surface', 'architectural_drift',
|
||||
];
|
||||
|
||||
for (const type of validTypes) {
|
||||
const result = AnalysisType.safeParse(type);
|
||||
expect(result.success).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('OutputFormat Enum', () => {
|
||||
it('should validate all output formats', () => {
|
||||
const validFormats = ['json', 'graphviz', 'mermaid'];
|
||||
|
||||
for (const format of validFormats) {
|
||||
const result = OutputFormat.safeParse(format);
|
||||
expect(result.success).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('ChangeType Enum', () => {
|
||||
it('should validate all change types', () => {
|
||||
const validTypes = ['rename', 'move', 'delete', 'extract', 'inline'];
|
||||
|
||||
for (const type of validTypes) {
|
||||
const result = ChangeType.safeParse(type);
|
||||
expect(result.success).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('SplitStrategy Enum', () => {
|
||||
it('should validate all split strategies', () => {
|
||||
const validStrategies = ['minimize_coupling', 'balance_size', 'feature_isolation'];
|
||||
|
||||
for (const strategy of validStrategies) {
|
||||
const result = SplitStrategy.safeParse(strategy);
|
||||
expect(result.success).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('PatternType Enum', () => {
|
||||
it('should validate all pattern types', () => {
|
||||
const validTypes = ['bug_patterns', 'refactor_patterns', 'api_patterns', 'test_patterns'];
|
||||
|
||||
for (const type of validTypes) {
|
||||
const result = PatternType.safeParse(type);
|
||||
expect(result.success).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('SemanticSearchInputSchema', () => {
|
||||
it('should validate valid semantic search input', () => {
|
||||
const validInput = {
|
||||
query: 'authentication middleware',
|
||||
searchType: 'semantic',
|
||||
topK: 10,
|
||||
};
|
||||
|
||||
const result = SemanticSearchInputSchema.safeParse(validInput);
|
||||
expect(result.success).toBe(true);
|
||||
if (result.success) {
|
||||
expect(result.data.topK).toBe(10);
|
||||
}
|
||||
});
|
||||
|
||||
it('should use defaults when not provided', () => {
|
||||
const input = {
|
||||
query: 'find user service',
|
||||
};
|
||||
|
||||
const result = SemanticSearchInputSchema.safeParse(input);
|
||||
expect(result.success).toBe(true);
|
||||
if (result.success) {
|
||||
expect(result.data.searchType).toBe('semantic');
|
||||
expect(result.data.topK).toBe(10);
|
||||
}
|
||||
});
|
||||
|
||||
it('should validate with scope options', () => {
|
||||
const input = {
|
||||
query: 'database connection',
|
||||
scope: {
|
||||
paths: ['src/', 'lib/'],
|
||||
languages: ['typescript', 'javascript'],
|
||||
excludeTests: true,
|
||||
},
|
||||
};
|
||||
|
||||
const result = SemanticSearchInputSchema.safeParse(input);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it('should reject empty query', () => {
|
||||
const input = { query: '' };
|
||||
const result = SemanticSearchInputSchema.safeParse(input);
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
|
||||
it('should reject query exceeding max length', () => {
|
||||
const input = { query: 'a'.repeat(5001) };
|
||||
const result = SemanticSearchInputSchema.safeParse(input);
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
|
||||
it('should reject topK outside valid range', () => {
|
||||
const tooLow = { query: 'test', topK: 0 };
|
||||
const tooHigh = { query: 'test', topK: 1001 };
|
||||
|
||||
expect(SemanticSearchInputSchema.safeParse(tooLow).success).toBe(false);
|
||||
expect(SemanticSearchInputSchema.safeParse(tooHigh).success).toBe(false);
|
||||
});
|
||||
|
||||
it('should validate all search types', () => {
|
||||
const types = ['semantic', 'structural', 'clone', 'api_usage'] as const;
|
||||
for (const searchType of types) {
|
||||
const input = { query: 'test', searchType };
|
||||
const result = SemanticSearchInputSchema.safeParse(input);
|
||||
expect(result.success).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('ArchitectureAnalyzeInputSchema', () => {
|
||||
it('should validate valid architecture analyze input', () => {
|
||||
const validInput = {
|
||||
rootPath: './src',
|
||||
analysis: ['dependency_graph', 'circular_deps'],
|
||||
};
|
||||
|
||||
const result = ArchitectureAnalyzeInputSchema.safeParse(validInput);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it('should use default root path', () => {
|
||||
const input = {};
|
||||
const result = ArchitectureAnalyzeInputSchema.safeParse(input);
|
||||
expect(result.success).toBe(true);
|
||||
if (result.success) {
|
||||
expect(result.data.rootPath).toBe('.');
|
||||
}
|
||||
});
|
||||
|
||||
it('should validate with layers configuration', () => {
|
||||
const input = {
|
||||
rootPath: './src',
|
||||
layers: {
|
||||
presentation: ['src/ui/', 'src/components/'],
|
||||
business: ['src/services/', 'src/domain/'],
|
||||
data: ['src/repositories/', 'src/database/'],
|
||||
},
|
||||
};
|
||||
|
||||
const result = ArchitectureAnalyzeInputSchema.safeParse(input);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it('should validate with baseline', () => {
|
||||
const input = {
|
||||
rootPath: './src',
|
||||
baseline: 'main',
|
||||
outputFormat: 'mermaid',
|
||||
};
|
||||
|
||||
const result = ArchitectureAnalyzeInputSchema.safeParse(input);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it('should validate all output formats', () => {
|
||||
const formats = ['json', 'graphviz', 'mermaid'] as const;
|
||||
for (const outputFormat of formats) {
|
||||
const input = { outputFormat };
|
||||
const result = ArchitectureAnalyzeInputSchema.safeParse(input);
|
||||
expect(result.success).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('RefactorImpactInputSchema', () => {
|
||||
it('should validate valid refactor impact input', () => {
|
||||
const validInput = {
|
||||
changes: [
|
||||
{ file: 'src/service.ts', type: 'rename' },
|
||||
{ file: 'src/utils.ts', type: 'move' },
|
||||
],
|
||||
depth: 3,
|
||||
};
|
||||
|
||||
const result = RefactorImpactInputSchema.safeParse(validInput);
|
||||
expect(result.success).toBe(true);
|
||||
if (result.success) {
|
||||
expect(result.data.includeTests).toBe(true); // default
|
||||
}
|
||||
});
|
||||
|
||||
it('should use default depth', () => {
|
||||
const input = {
|
||||
changes: [{ file: 'src/test.ts', type: 'delete' }],
|
||||
};
|
||||
|
||||
const result = RefactorImpactInputSchema.safeParse(input);
|
||||
expect(result.success).toBe(true);
|
||||
if (result.success) {
|
||||
expect(result.data.depth).toBe(3);
|
||||
}
|
||||
});
|
||||
|
||||
it('should reject empty changes array', () => {
|
||||
const input = { changes: [] };
|
||||
const result = RefactorImpactInputSchema.safeParse(input);
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
|
||||
it('should reject too many changes', () => {
|
||||
const changes = Array(101).fill({ file: 'test.ts', type: 'rename' });
|
||||
const input = { changes };
|
||||
const result = RefactorImpactInputSchema.safeParse(input);
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
|
||||
it('should reject depth outside valid range', () => {
|
||||
const tooLow = { changes: [{ file: 'test.ts', type: 'rename' }], depth: 0 };
|
||||
const tooHigh = { changes: [{ file: 'test.ts', type: 'rename' }], depth: 11 };
|
||||
|
||||
expect(RefactorImpactInputSchema.safeParse(tooLow).success).toBe(false);
|
||||
expect(RefactorImpactInputSchema.safeParse(tooHigh).success).toBe(false);
|
||||
});
|
||||
|
||||
it('should validate all change types', () => {
|
||||
const types = ['rename', 'move', 'delete', 'extract', 'inline'] as const;
|
||||
for (const type of types) {
|
||||
const input = { changes: [{ file: 'test.ts', type }] };
|
||||
const result = RefactorImpactInputSchema.safeParse(input);
|
||||
expect(result.success).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('SplitSuggestInputSchema', () => {
|
||||
it('should validate valid split suggest input', () => {
|
||||
const validInput = {
|
||||
targetPath: './src/monolith',
|
||||
strategy: 'minimize_coupling',
|
||||
targetModules: 5,
|
||||
};
|
||||
|
||||
const result = SplitSuggestInputSchema.safeParse(validInput);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it('should use default strategy', () => {
|
||||
const input = {
|
||||
targetPath: './src',
|
||||
};
|
||||
|
||||
const result = SplitSuggestInputSchema.safeParse(input);
|
||||
expect(result.success).toBe(true);
|
||||
if (result.success) {
|
||||
expect(result.data.strategy).toBe('minimize_coupling');
|
||||
}
|
||||
});
|
||||
|
||||
it('should validate with constraints', () => {
|
||||
const input = {
|
||||
targetPath: './src',
|
||||
constraints: {
|
||||
maxModuleSize: 500,
|
||||
minModuleSize: 50,
|
||||
preserveBoundaries: ['src/core/', 'src/api/'],
|
||||
},
|
||||
};
|
||||
|
||||
const result = SplitSuggestInputSchema.safeParse(input);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it('should reject targetModules outside valid range', () => {
|
||||
const tooLow = { targetPath: './src', targetModules: 1 };
|
||||
const tooHigh = { targetPath: './src', targetModules: 51 };
|
||||
|
||||
expect(SplitSuggestInputSchema.safeParse(tooLow).success).toBe(false);
|
||||
expect(SplitSuggestInputSchema.safeParse(tooHigh).success).toBe(false);
|
||||
});
|
||||
|
||||
it('should validate all strategies', () => {
|
||||
const strategies = ['minimize_coupling', 'balance_size', 'feature_isolation'] as const;
|
||||
for (const strategy of strategies) {
|
||||
const input = { targetPath: './src', strategy };
|
||||
const result = SplitSuggestInputSchema.safeParse(input);
|
||||
expect(result.success).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('LearnPatternsInputSchema', () => {
|
||||
it('should validate valid learn patterns input', () => {
|
||||
const validInput = {
|
||||
scope: {
|
||||
gitRange: 'HEAD~50..HEAD',
|
||||
authors: ['john@example.com'],
|
||||
},
|
||||
patternTypes: ['bug_patterns', 'refactor_patterns'],
|
||||
minOccurrences: 5,
|
||||
};
|
||||
|
||||
const result = LearnPatternsInputSchema.safeParse(validInput);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it('should use default values', () => {
|
||||
const input = {};
|
||||
const result = LearnPatternsInputSchema.safeParse(input);
|
||||
expect(result.success).toBe(true);
|
||||
if (result.success) {
|
||||
expect(result.data.minOccurrences).toBe(3);
|
||||
}
|
||||
});
|
||||
|
||||
it('should validate with scope paths', () => {
|
||||
const input = {
|
||||
scope: {
|
||||
paths: ['src/', 'lib/'],
|
||||
},
|
||||
};
|
||||
|
||||
const result = LearnPatternsInputSchema.safeParse(input);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it('should reject minOccurrences outside valid range', () => {
|
||||
const tooLow = { minOccurrences: 0 };
|
||||
const tooHigh = { minOccurrences: 101 };
|
||||
|
||||
expect(LearnPatternsInputSchema.safeParse(tooLow).success).toBe(false);
|
||||
expect(LearnPatternsInputSchema.safeParse(tooHigh).success).toBe(false);
|
||||
});
|
||||
|
||||
it('should validate all pattern types', () => {
|
||||
const types = ['bug_patterns', 'refactor_patterns', 'api_patterns', 'test_patterns'] as const;
|
||||
const input = { patternTypes: [...types] };
|
||||
const result = LearnPatternsInputSchema.safeParse(input);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Default Configuration', () => {
|
||||
it('should have valid search configuration', () => {
|
||||
expect(DEFAULT_CONFIG.search.embeddingDimension).toBe(384);
|
||||
expect(DEFAULT_CONFIG.search.defaultTopK).toBe(10);
|
||||
expect(DEFAULT_CONFIG.search.similarityThreshold).toBe(0.7);
|
||||
});
|
||||
|
||||
it('should have valid architecture configuration', () => {
|
||||
expect(DEFAULT_CONFIG.architecture.maxGraphDepth).toBe(10);
|
||||
expect(DEFAULT_CONFIG.architecture.includeVendor).toBe(false);
|
||||
});
|
||||
|
||||
it('should have valid refactoring configuration', () => {
|
||||
expect(DEFAULT_CONFIG.refactoring.defaultDepth).toBe(3);
|
||||
expect(DEFAULT_CONFIG.refactoring.includeTests).toBe(true);
|
||||
});
|
||||
|
||||
it('should have valid security configuration', () => {
|
||||
expect(DEFAULT_CONFIG.security.allowedRoots).toContain('.');
|
||||
expect(DEFAULT_CONFIG.security.maskSecrets).toBe(true);
|
||||
expect(DEFAULT_CONFIG.security.blockedPatterns.length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Error Codes', () => {
|
||||
it('should have all expected error codes', () => {
|
||||
expect(CodeIntelligenceErrorCodes.PATH_TRAVERSAL).toBe('CODE_PATH_TRAVERSAL');
|
||||
expect(CodeIntelligenceErrorCodes.SENSITIVE_FILE).toBe('CODE_SENSITIVE_FILE');
|
||||
expect(CodeIntelligenceErrorCodes.GRAPH_TOO_LARGE).toBe('CODE_GRAPH_TOO_LARGE');
|
||||
expect(CodeIntelligenceErrorCodes.ANALYSIS_FAILED).toBe('CODE_ANALYSIS_FAILED');
|
||||
expect(CodeIntelligenceErrorCodes.PARSER_ERROR).toBe('CODE_PARSER_ERROR');
|
||||
expect(CodeIntelligenceErrorCodes.WASM_NOT_INITIALIZED).toBe('CODE_WASM_NOT_INITIALIZED');
|
||||
expect(CodeIntelligenceErrorCodes.LANGUAGE_NOT_SUPPORTED).toBe('CODE_LANGUAGE_NOT_SUPPORTED');
|
||||
expect(CodeIntelligenceErrorCodes.GIT_ERROR).toBe('CODE_GIT_ERROR');
|
||||
});
|
||||
});
|
||||
|
||||
describe('CodeIntelligenceError', () => {
|
||||
it('should create error with code and message', () => {
|
||||
const error = new CodeIntelligenceError(
|
||||
CodeIntelligenceErrorCodes.PATH_TRAVERSAL,
|
||||
'Path traversal detected'
|
||||
);
|
||||
|
||||
expect(error.name).toBe('CodeIntelligenceError');
|
||||
expect(error.code).toBe('CODE_PATH_TRAVERSAL');
|
||||
expect(error.message).toBe('Path traversal detected');
|
||||
});
|
||||
|
||||
it('should create error with details', () => {
|
||||
const error = new CodeIntelligenceError(
|
||||
CodeIntelligenceErrorCodes.SENSITIVE_FILE,
|
||||
'Access denied',
|
||||
{ filePath: '/etc/passwd' }
|
||||
);
|
||||
|
||||
expect(error.details).toEqual({ filePath: '/etc/passwd' });
|
||||
});
|
||||
|
||||
it('should be instance of Error', () => {
|
||||
const error = new CodeIntelligenceError(
|
||||
CodeIntelligenceErrorCodes.ANALYSIS_FAILED,
|
||||
'Failed'
|
||||
);
|
||||
|
||||
expect(error).toBeInstanceOf(Error);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Secret Patterns', () => {
|
||||
it('should have defined secret patterns', () => {
|
||||
expect(SECRET_PATTERNS).toBeDefined();
|
||||
expect(SECRET_PATTERNS.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('should detect API keys in quotes', () => {
|
||||
const code = 'const apiKey = "sk_live_abc123xyz"';
|
||||
const pattern = SECRET_PATTERNS[0];
|
||||
expect(pattern.test(code)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('maskSecrets', () => {
|
||||
it('should mask API keys', () => {
|
||||
const code = 'const apiKey = "sk-live-abcdefghijklmnopqrstuvwx"';
|
||||
const masked = maskSecrets(code);
|
||||
expect(masked).toContain('[REDACTED]');
|
||||
});
|
||||
|
||||
it('should mask GitHub tokens', () => {
|
||||
const code = 'const token = "ghp_abcdefghijklmnopqrstuvwxyz123456"';
|
||||
const masked = maskSecrets(code);
|
||||
expect(masked).toContain('[REDACTED]');
|
||||
});
|
||||
|
||||
it('should mask AWS keys', () => {
|
||||
const code = 'AWS_ACCESS_KEY = "AKIAIOSFODNN7EXAMPLE"';
|
||||
const masked = maskSecrets(code);
|
||||
expect(masked).toContain('[REDACTED]');
|
||||
});
|
||||
|
||||
it('should mask private key headers', () => {
|
||||
const code = '-----BEGIN RSA PRIVATE KEY-----\nMIIE...';
|
||||
const masked = maskSecrets(code);
|
||||
expect(masked).toContain('[REDACTED]');
|
||||
});
|
||||
|
||||
it('should leave non-secret code unchanged', () => {
|
||||
const code = 'const message = "Hello, World!"';
|
||||
const masked = maskSecrets(code);
|
||||
expect(masked).toBe(code);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user