项目文件夹

文件
wehub-resource-sync 23f7624596
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
chore: import upstream snapshot with attribution
2026-07-13 12:02:19 +08:00

467 行
13 KiB
TypeScript

/**
* Neural Coordination Plugin - MCP Tools Tests
*
* Tests for MCP tool handlers with mock data
*/
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
import {
neuralCoordinationTools,
getTool,
getToolNames,
} from '../src/mcp-tools.js';
describe('neuralCoordinationTools', () => {
it('should export 5 MCP tools', () => {
expect(neuralCoordinationTools).toHaveLength(5);
});
it('should have unique tool names', () => {
const names = neuralCoordinationTools.map(t => t.name);
const uniqueNames = new Set(names);
expect(uniqueNames.size).toBe(names.length);
});
it('should have required tool properties', () => {
for (const tool of neuralCoordinationTools) {
expect(tool.name).toBeDefined();
expect(tool.description).toBeDefined();
expect(tool.inputSchema).toBeDefined();
expect(tool.handler).toBeDefined();
expect(typeof tool.handler).toBe('function');
}
});
});
describe('getTool', () => {
it('should return tool by name', () => {
const tool = getTool('coordination/neural-consensus');
expect(tool).toBeDefined();
expect(tool?.name).toBe('coordination/neural-consensus');
});
it('should return undefined for unknown tool', () => {
const tool = getTool('unknown/tool');
expect(tool).toBeUndefined();
});
});
describe('getToolNames', () => {
it('should return array of tool names', () => {
const names = getToolNames();
expect(names).toContain('coordination/neural-consensus');
expect(names).toContain('coordination/topology-optimize');
expect(names).toContain('coordination/collective-memory');
expect(names).toContain('coordination/emergent-protocol');
expect(names).toContain('coordination/swarm-behavior');
});
});
describe('coordination/neural-consensus handler', () => {
const tool = getTool('coordination/neural-consensus')!;
it('should handle valid input', async () => {
const input = {
proposal: {
topic: 'Choose deployment strategy',
options: [
{ id: 'blue-green', value: { risk: 0.2, speed: 0.8 } },
{ id: 'canary', value: { risk: 0.5, speed: 0.5 } },
],
},
agents: [
{ id: 'agent-1', preferences: { risk: -0.5, speed: 0.8 } },
{ id: 'agent-2', preferences: { risk: -0.8, speed: 0.3 } },
{ id: 'agent-3', preferences: { risk: 0.2, speed: 0.9 } },
],
protocol: 'neural_voting',
maxRounds: 5,
};
const result = await tool.handler(input);
expect(result.isError).toBeUndefined();
const parsed = JSON.parse(result.content[0].text!);
expect(parsed).toHaveProperty('consensusReached');
expect(parsed).toHaveProperty('agreementRatio');
expect(parsed).toHaveProperty('details');
});
it('should return error for insufficient agents', async () => {
const input = {
proposal: {
topic: 'Test',
options: [
{ id: '1', value: 1 },
{ id: '2', value: 2 },
],
},
agents: [{ id: 'agent-1' }], // Need at least 2
};
const result = await tool.handler(input);
expect(result.isError).toBe(true);
});
it('should handle all protocols', async () => {
const protocols = ['neural_voting', 'iterative_refinement', 'auction', 'contract_net'];
for (const protocol of protocols) {
const input = {
proposal: {
topic: 'Test',
options: [{ id: '1', value: 1 }, { id: '2', value: 2 }],
},
agents: [{ id: 'a1' }, { id: 'a2' }],
protocol,
};
const result = await tool.handler(input);
expect(result.isError).toBeUndefined();
}
});
it('should report divergent agents', async () => {
const input = {
proposal: {
topic: 'Contentious topic',
options: [
{ id: 'option-a', value: { x: 1 } },
{ id: 'option-b', value: { x: -1 } },
],
},
agents: [
{ id: 'agent-1', preferences: { x: 1 } },
{ id: 'agent-2', preferences: { x: -1 } },
],
maxRounds: 3,
};
const result = await tool.handler(input);
const parsed = JSON.parse(result.content[0].text!);
expect(parsed.details).toHaveProperty('divergentAgents');
expect(Array.isArray(parsed.details.divergentAgents)).toBe(true);
});
});
describe('coordination/topology-optimize handler', () => {
const tool = getTool('coordination/topology-optimize')!;
it('should handle valid input', async () => {
const input = {
agents: [
{ id: 'agent-1', capabilities: ['code', 'test'], location: { x: 0, y: 0 } },
{ id: 'agent-2', capabilities: ['review'], location: { x: 1, y: 0 } },
{ id: 'agent-3', capabilities: ['deploy'], location: { x: 0, y: 1 } },
],
objective: 'minimize_latency',
constraints: {
maxConnections: 5,
preferredTopology: 'mesh',
},
};
const result = await tool.handler(input);
expect(result.isError).toBeUndefined();
const parsed = JSON.parse(result.content[0].text!);
expect(parsed).toHaveProperty('topology');
expect(parsed).toHaveProperty('edges');
expect(parsed).toHaveProperty('metrics');
});
it('should return error for insufficient agents', async () => {
const input = {
agents: [{ id: 'agent-1' }], // Need at least 2
};
const result = await tool.handler(input);
expect(result.isError).toBe(true);
});
it('should handle all topology types', async () => {
const topologies = ['mesh', 'tree', 'ring', 'star', 'hybrid'];
for (const preferredTopology of topologies) {
const input = {
agents: [
{ id: 'a1' },
{ id: 'a2' },
{ id: 'a3' },
],
constraints: { preferredTopology },
};
const result = await tool.handler(input);
expect(result.isError).toBeUndefined();
const parsed = JSON.parse(result.content[0].text!);
expect(parsed.topology).toBe(preferredTopology);
}
});
it('should compute topology metrics', async () => {
const input = {
agents: [
{ id: 'a1', capabilities: ['code'] },
{ id: 'a2', capabilities: ['code', 'test'] },
{ id: 'a3', capabilities: ['test'] },
],
};
const result = await tool.handler(input);
const parsed = JSON.parse(result.content[0].text!);
expect(parsed.metrics).toHaveProperty('avgLatency');
expect(parsed.metrics).toHaveProperty('redundancy');
expect(parsed.metrics).toHaveProperty('diameter');
expect(parsed.metrics).toHaveProperty('avgDegree');
});
});
describe('coordination/collective-memory handler', () => {
const tool = getTool('coordination/collective-memory')!;
it('should handle store action', async () => {
const input = {
action: 'store',
memory: {
key: 'shared-context',
value: { data: 'test-data' },
importance: 0.8,
},
scope: 'team',
};
const result = await tool.handler(input);
expect(result.isError).toBeUndefined();
const parsed = JSON.parse(result.content[0].text!);
expect(parsed.action).toBe('store');
expect(parsed.success).toBe(true);
});
it('should handle retrieve action', async () => {
// First store
await tool.handler({
action: 'store',
memory: { key: 'test-key', value: 'test-value' },
scope: 'team',
});
// Then retrieve
const result = await tool.handler({
action: 'retrieve',
memory: { key: 'test-key' },
scope: 'team',
});
expect(result.isError).toBeUndefined();
const parsed = JSON.parse(result.content[0].text!);
expect(parsed.action).toBe('retrieve');
});
it('should handle consolidate action', async () => {
const input = {
action: 'consolidate',
scope: 'team',
consolidationStrategy: 'ewc',
};
const result = await tool.handler(input);
expect(result.isError).toBeUndefined();
const parsed = JSON.parse(result.content[0].text!);
expect(parsed.action).toBe('consolidate');
});
it('should handle forget action', async () => {
const input = {
action: 'forget',
memory: { key: 'obsolete-key' },
scope: 'team',
};
const result = await tool.handler(input);
expect(result.isError).toBeUndefined();
const parsed = JSON.parse(result.content[0].text!);
expect(parsed.action).toBe('forget');
});
it('should handle synchronize action', async () => {
const input = {
action: 'synchronize',
scope: 'global',
};
const result = await tool.handler(input);
expect(result.isError).toBeUndefined();
const parsed = JSON.parse(result.content[0].text!);
expect(parsed.action).toBe('synchronize');
});
it('should return error for missing key on store', async () => {
const input = {
action: 'store',
memory: { value: 'data' }, // Missing key
};
const result = await tool.handler(input);
expect(result.isError).toBe(true);
});
});
describe('coordination/emergent-protocol handler', () => {
const tool = getTool('coordination/emergent-protocol')!;
it('should handle valid input', async () => {
const input = {
task: {
type: 'coordination',
objectives: ['reach consensus', 'minimize messages'],
},
communicationBudget: {
symbolsPerMessage: 5,
messagesPerRound: 2,
},
trainingEpisodes: 100,
interpretability: true,
};
const result = await tool.handler(input);
expect(result.isError).toBeUndefined();
const parsed = JSON.parse(result.content[0].text!);
expect(parsed).toHaveProperty('protocolLearned');
expect(parsed).toHaveProperty('vocabularySize');
expect(parsed).toHaveProperty('successRate');
});
it('should generate symbols for task objectives', async () => {
const input = {
task: {
type: 'navigation',
objectives: ['find target', 'avoid obstacles', 'report position'],
},
trainingEpisodes: 500,
};
const result = await tool.handler(input);
const parsed = JSON.parse(result.content[0].text!);
expect(parsed.vocabularySize).toBeGreaterThan(0);
expect(parsed.details.symbols.length).toBeGreaterThan(0);
});
it('should generate composition rules when interpretability enabled', async () => {
const input = {
task: {
type: 'test',
objectives: ['goal-1'],
},
interpretability: true,
};
const result = await tool.handler(input);
const parsed = JSON.parse(result.content[0].text!);
expect(Array.isArray(parsed.details.compositionRules)).toBe(true);
expect(parsed.details.compositionRules.length).toBeGreaterThan(0);
});
});
describe('coordination/swarm-behavior handler', () => {
const tool = getTool('coordination/swarm-behavior')!;
it('should handle valid input', async () => {
const input = {
behavior: 'flocking',
parameters: { separationWeight: 1.0 },
adaptiveRules: true,
observability: {
recordTrajectories: true,
measureEmergence: true,
},
};
const result = await tool.handler(input);
expect(result.isError).toBeUndefined();
const parsed = JSON.parse(result.content[0].text!);
expect(parsed.behaviorActive).toBe(true);
expect(parsed).toHaveProperty('metrics');
});
it('should handle all behavior types', async () => {
const behaviors = [
'flocking', 'foraging', 'formation', 'task_allocation',
'exploration', 'aggregation', 'dispersion',
];
for (const behavior of behaviors) {
const input = { behavior };
const result = await tool.handler(input);
expect(result.isError).toBeUndefined();
const parsed = JSON.parse(result.content[0].text!);
expect(parsed.details.behavior).toBe(behavior);
}
});
it('should compute swarm metrics', async () => {
const input = {
behavior: 'flocking',
};
const result = await tool.handler(input);
const parsed = JSON.parse(result.content[0].text!);
expect(parsed.metrics).toHaveProperty('cohesion');
expect(parsed.metrics).toHaveProperty('alignment');
expect(parsed.metrics).toHaveProperty('separation');
expect(parsed.metrics).toHaveProperty('emergenceScore');
// All metrics should be in [0, 1] range
expect(parsed.metrics.cohesion).toBeGreaterThanOrEqual(0);
expect(parsed.metrics.cohesion).toBeLessThanOrEqual(1);
});
it('should return error for invalid behavior', async () => {
const input = {
behavior: 'invalid_behavior',
};
const result = await tool.handler(input);
expect(result.isError).toBe(true);
});
});
describe('Tool metadata', () => {
it('should have correct categories', () => {
for (const tool of neuralCoordinationTools) {
expect(tool.category).toBe('coordination');
}
});
it('should have version numbers', () => {
for (const tool of neuralCoordinationTools) {
expect(tool.version).toBeDefined();
expect(tool.version).toMatch(/^\d+\.\d+\.\d+$/);
}
});
it('should have tags', () => {
for (const tool of neuralCoordinationTools) {
expect(Array.isArray(tool.tags)).toBe(true);
expect(tool.tags!.length).toBeGreaterThan(0);
}
});
});