Skip to content

Latest commit

 

History

History
389 lines (321 loc) · 10.8 KB

File metadata and controls

389 lines (321 loc) · 10.8 KB

MCP Soulfield Knowledge Graph - Comprehensive Test Suite

Purpose: Full capability testing of MCP soulfield-kg server and optimized graph Date: 2025-11-14 Database: 319 docs, 1,551 entities, 16,850 relationships (0 isolated nodes)

Prerequisites

# Verify MCP server is running
ps aux | grep mcp-server | grep -v grep
# Expected: node backend/services/knowledge-graph/mcp-server.cjs

# Check database health
node backend/scripts/verify-kg-health.cjs
# Expected: Isolated Nodes: 0, Communities: 106

# Ensure environment variables
grep "USE_KNOWLEDGE_GRAPH" .env
# Expected: USE_KNOWLEDGE_GRAPH=1

Test Suite Prompt for Codex

Copy this entire prompt to Codex for comprehensive testing:


Test MCP Soulfield Knowledge Graph - All Capabilities

I need you to comprehensively test the MCP soulfield-kg server and the optimized knowledge graph. The database has 319 documents, 1,551 entities, 16,850 relationships, and 0 isolated nodes after optimization.

Phase 1: Obsidian Document Search Operations

Test all 4 search types with Obsidian-specific queries (231 Obsidian docs in database):

  1. GRAPH_COMPLETION (search Obsidian reference docs):
await mcp__soulfield_kg__search({
  query: "How is the lens framework documented in Obsidian reference files?",
  searchType: "GRAPH_COMPLETION",
  options: { limit: 5, includeGraph: true, filter: "Obsidian" }
})

Verify: Should return Obsidian docs from workspace/docs/Obsidian-v2/

  1. CHUNKS (search Obsidian topic files):
await mcp__soulfield_kg__search({
  query: "GRAPH.md DATABASE.md knowledge graph topics",
  searchType: "CHUNKS",
  options: { limit: 10 }
})

Verify: Should return chunks from workspace/docs/Obsidian-v2/topics/

  1. INSIGHTS (analyze Obsidian vault structure):
await mcp__soulfield_kg__search({
  query: "What are the gaps in Obsidian documentation between agents and services?",
  searchType: "INSIGHTS",
  options: { includeQuestions: true, path: "Obsidian" }
})

Verify: Should analyze relationships between docs/reference/agents/ and docs/reference/services/

  1. CODE (searches actual source code files - NOT for Obsidian docs):
// ⚠️ CODE search filters for .js/.cjs/.ts files only
// Use CHUNKS instead for finding code references in Obsidian markdown
await mcp__soulfield_kg__search({
  query: "kg-sqlite.cjs backend services knowledge-graph",
  searchType: "CHUNKS",  // Use CHUNKS, not CODE
  options: { limit: 10 }
})

Verify: Returns Obsidian docs mentioning code files (CHUNKS works, CODE intentionally excludes .md)

Why CODE Doesn't Work for Obsidian:

  • CODE search filters: ['.js', '.cjs', '.ts'] (backend/services/knowledge-graph/graph-search.cjs:359-380)
  • Obsidian files are .md → excluded by design
  • CHUNKS mode is the correct choice for searching documentation

Phase 2: Graph Analysis Features

Test InfraNodus capabilities:

  1. Cognitive State Detection:
await mcp__soulfield_kg__search({
  query: "marketing strategy customer acquisition growth funnel optimization",
  searchType: "INSIGHTS",
  options: { detectCognitiveState: true }
})

Expected states: BIAS, FOCUSED, DIVERSE, or DISPERSED

  1. Gap Detection with Scoring:
await mcp__soulfield_kg__search({
  query: "Find structural gaps in agent communication patterns",
  searchType: "INSIGHTS",
  options: { findGaps: true, scoreGaps: true }
})

Should return gaps with severity: critical/major/minor

  1. Evolution Tracking:
await mcp__soulfield_kg__search({
  query: "Track knowledge graph evolution over time",
  searchType: "INSIGHTS",
  options: { trackEvolution: true }
})

Expected: 8-stage cycle position (exploration → stabilization)

  1. Community Detection:
await mcp__soulfield_kg__search({
  query: "Identify topic communities in the knowledge graph",
  searchType: "GRAPH_COMPLETION",
  options: { includeCommunities: true }
})

Should identify ~106 communities (natural domain clustering)

Phase 3: Cross-Domain Relationships

Test the new semantic bridges created during optimization:

  1. Marketing ↔ Finance Bridge:
await mcp__soulfield_kg__search({
  query: "How does marketing require metrics from finance?",
  searchType: "GRAPH_COMPLETION",
  options: { traverseDepth: 2 }
})

Should find "requires_metrics_from" relationships

  1. Knowledge Graph → Agents:
await mcp__soulfield_kg__search({
  query: "How does SQLiteKnowledgeGraph provide context to agents?",
  searchType: "GRAPH_COMPLETION",
  options: { includeRelationships: ["provides_context_to"] }
})

Should show context injection pattern

  1. Lens Validation Chain:
await mcp__soulfield_kg__search({
  query: "Which lenses validate marketing agent output?",
  searchType: "GRAPH_COMPLETION",
  options: { relationshipType: "validates_output_of" }
})

Should show TruthLens → marketing connections

Phase 4: Agent-Specific Queries

Test agent context retrieval patterns:

  1. Marketing Agent Context:
await mcp__soulfield_kg__search({
  query: "Create a viral marketing campaign for SaaS product",
  searchType: "GRAPH_COMPLETION",
  options: { agent: "marketing", useContext: true }
})
  1. Finance Agent Context:
await mcp__soulfield_kg__search({
  query: "Calculate burn rate and runway for startup",
  searchType: "GRAPH_COMPLETION",
  options: { agent: "finance", useContext: true }
})
  1. SEO Agent Context:
await mcp__soulfield_kg__search({
  query: "Optimize content for search rankings",
  searchType: "GRAPH_COMPLETION",
  options: { agent: "seo", useContext: true }
})

Phase 5: Performance & Scale Testing

  1. Bulk Query Test:
// Test 10 rapid queries
const queries = [
  "marketing strategy", "finance models", "seo keywords",
  "graph analysis", "lens validation", "agent routing",
  "context retrieval", "embedding service", "test coverage", "builder mvp"
];

for (const q of queries) {
  const start = Date.now();
  await mcp__soulfield_kg__search({
    query: q,
    searchType: "CHUNKS",
    options: { limit: 5 }
  });
  console.log(`Query "${q}": ${Date.now() - start}ms`);
}

Expected: All queries <100ms

  1. Large Result Set:
await mcp__soulfield_kg__search({
  query: "agent",
  searchType: "CHUNKS",
  options: { limit: 100 }
})

Should handle 100 results without timeout

  1. Deep Graph Traversal:
await mcp__soulfield_kg__search({
  query: "council.js orchestration flow",
  searchType: "GRAPH_COMPLETION",
  options: { traverseDepth: 5, includeAllPaths: true }
})

Test multi-hop reasoning capabilities

Phase 6: Edge Cases & Error Handling

  1. Empty Query:
await mcp__soulfield_kg__search({
  query: "",
  searchType: "CHUNKS"
})

Should return error or empty results gracefully

  1. Non-existent Entity:
await mcp__soulfield_kg__search({
  query: "quantum blockchain AI metaverse",
  searchType: "GRAPH_COMPLETION"
})

Should handle no results gracefully

  1. Invalid Search Type:
await mcp__soulfield_kg__search({
  query: "test",
  searchType: "INVALID_TYPE"
})

Should default to CHUNKS or return error

Phase 7: Integration Testing

  1. Test Auto-Context Injection: Verify council.js integration at lines 1432-1439:
// Simulate agent query that should get context
await mcp__soulfield_kg__search({
  query: "@marketing Create campaign",
  searchType: "GRAPH_COMPLETION",
  options: { simulateCouncil: true }
})
  1. Test Hybrid Search:
await mcp__soulfield_kg__search({
  query: "TruthLens validation process",
  searchType: "GRAPH_COMPLETION",
  options: {
    useTFIDF: true,
    useFTS5: true,
    useGraphScoring: true
  }
})

Should combine all three scoring methods

Phase 8: Statistics & Metrics

  1. Graph Statistics:
await mcp__soulfield_kg__getStats()

Expected output:

  • documents: 319
  • entities: 1,551
  • relationships: 16,850
  • isolated_nodes: 0
  • communities: 106
  • density: 1.40%
  1. Performance Metrics:
await mcp__soulfield_kg__getPerformance()

Should show:

  • avg_query_time: <150ms
  • cache_hit_rate
  • memory_usage: ~25MB

Verification Checklist

After running all tests, verify:

  • 3/4 search types work for Obsidian (GRAPH_COMPLETION, CHUNKS, INSIGHTS)
  • CODE search correctly excludes .md files (expected behavior)
  • Graph connectivity is 100% (0 isolated nodes)
  • Semantic bridges work (marketing↔finance, etc.)
  • InfraNodus features detect gaps and cognitive states
  • Query performance <150ms average
  • Agent-specific context retrieval works
  • No crashes on edge cases
  • Hybrid search combines TF-IDF + FTS5 + graph scoring
  • CHUNKS mode successfully finds code references in Obsidian docs

Expected Issues to Find

  1. Performance degradation on queries returning >50 results
  2. Memory growth with repeated large traversals
  3. Cache invalidation after database updates
  4. Timeout on GRAPH_COMPLETION with traverseDepth >3

Success Criteria

  • All search types functional
  • Zero isolated nodes maintained
  • Cross-domain queries work via semantic bridges
  • Performance within benchmarks (<150ms avg)
  • Graceful error handling
  • InfraNodus features operational (gaps, cognitive state, evolution)

Report findings with specific query/response examples and any errors encountered.


Usage Instructions

  1. In Codex: Copy the entire prompt above and execute systematically
  2. In Claude Code: Can test individual queries using the Task tool with MCP integration
  3. Direct Node.js: Run test scripts in backend/scripts/test-mcp-unified-search.cjs

Quick Verification Commands

# Test basic search
curl -X POST http://localhost:3000/search \
  -H "Content-Type: application/json" \
  -d '{"query": "marketing lens", "searchType": "CHUNKS"}'

# Check MCP server health
curl http://localhost:3000/health

# Run comprehensive test suite
node backend/scripts/test-mcp-unified-search.cjs

# Verify graph metrics
node backend/scripts/verify-kg-health.cjs

Files to Monitor

  • Logs: workspace/data/logs/mcp-server.log
  • Database: workspace/data/knowledge-graph.db
  • Test Results: backend/tests/mcp-kg-test-results.json

Expected Outcomes

  1. Functionality: All 4 search types operational
  2. Performance: Queries average <150ms
  3. Connectivity: Graph maintains 0 isolated nodes
  4. Relationships: Semantic bridges enable cross-domain queries
  5. InfraNodus: Gap detection, cognitive state, evolution tracking work
  6. Scale: Handles 100+ result sets without degradation
  7. Integration: Context injection pattern verified

This comprehensive test will validate the entire MCP soulfield-kg implementation including the recent optimizations.