Skip to main content
Glama

DollhouseMCP

by DollhouseMCP
ENHANCED_INDEX_ARCHITECTURE_FIXED.mdβ€’11.9 kB
# Enhanced Index Architecture - FIXED STATE *Updated: September 24, 2025, 3:00 PM* ## Current Working Architecture (After Fixes) ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ EnhancedIndexManager β”‚ β”‚ (Singleton) β”‚ β”‚ βœ… WORKING: Completes in ~186ms β”‚ β”‚ - File locking works β”‚ β”‚ - Caching functional β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β–Ό β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ IndexConfigManager β”‚ β”‚ FileLock β”‚ β”‚ (Singleton) β”‚ β”‚ (Instance per β”‚ β”‚ β”‚ β”‚ index file) β”‚ β”‚ βœ… Config limits β”‚ β”‚ βœ… Lock works β”‚ β”‚ properly applied β”‚ β”‚ ⚠️ Test conflicts β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β–Ό β–Ό β–Ό β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ NLPScoringManagerβ”‚ β”‚ VerbTriggerβ”‚ β”‚Relationshipβ”‚ β”‚PortfolioIndexMgrβ”‚ β”‚ (Instance) β”‚ β”‚ Manager β”‚ β”‚ Manager β”‚ β”‚ (Singleton) β”‚ β”‚ β”‚ β”‚(Singleton) β”‚ β”‚(Singleton) β”‚ β”‚ β”‚ β”‚ βœ… LRU cache OK β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ βœ… Scans files β”‚ β”‚ βœ… Scoring fast β”‚ β”‚ βœ… FIXED! β”‚ β”‚ βœ… Pattern β”‚ β”‚ ⚠️ Security β”‚ β”‚ βœ… 500 limit OK β”‚ β”‚ Now passes β”‚ β”‚ works β”‚ β”‚ false +ves β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ index β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β–Ό βœ… NO CIRCULAR! β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” Receives index β”‚ PortfolioManager β”‚ as parameter β”‚ (Singleton) β”‚ β”‚ β”‚ β”‚ βœ… Scans dirs OK β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` ## Fixed Data Flow (Working Pipeline) ``` 1. INDEX BUILD REQUEST β”‚ β–Ό 2. FILE LOCK ACQUISITION βœ… β”œβ”€> Timeout: 60s └─> Stale detection works β”‚ β–Ό 3. PORTFOLIO SCANNING βœ… β”‚ β”œβ”€> Successfully reads 186 files β”‚ β”œβ”€> personas: βœ… β”‚ β”œβ”€> skills: ⚠️ (some blocked by security) β”‚ β”œβ”€> templates: ⚠️ (some blocked) β”‚ β”œβ”€> agents: βœ… β”‚ β”œβ”€> memories: βœ… β”‚ └─> ensembles: βœ… β”‚ β–Ό 4. METADATA EXTRACTION ⚠️ PARTIAL ISSUE β”‚ β”œβ”€> SecureYamlParser.parse() β”‚ β”œβ”€> Size validation βœ… β”‚ β”œβ”€> YAML bomb detection βœ… β”‚ β”œβ”€> Unicode normalization βœ… β”‚ β”œβ”€> Pattern matching ❌ FALSE POSITIVES β”‚ β”‚ └─> Blocks: "audit", "security", "scan" skills β”‚ └─> Field validation βœ… β”‚ β–Ό 5. ELEMENT DEFINITION BUILDING βœ… β”‚ β”œβ”€> Core metadata βœ… β”œβ”€> Search data βœ… β”œβ”€> Verb triggers βœ… (2 found) └─> Initial relationships βœ… β”‚ β–Ό 6. SEMANTIC RELATIONSHIP CALCULATION βœ… FIXED! β”‚ β”œβ”€> Text preparation βœ… β”œβ”€> Entropy calculation βœ… β”œβ”€> Similarity matrix: β”‚ β”‚ β”‚ β”œβ”€> IF elements <= 50 THEN βœ… β”‚ β”‚ └─> Full matrix (max 1,225 comparisons) β”‚ β”‚ - Currently: ~190 comparisons β”‚ β”‚ - Time: ~50ms β”‚ β”‚ β”‚ └─> IF elements > 50 THEN βœ… β”‚ └─> LIMITED sampling (max 500) β”‚ β”œβ”€> Keyword clustering (300 comparisons) β”‚ └─> Cross-type sampling (200 comparisons) β”‚ - Time: ~150ms β”‚ β–Ό 7. RELATIONSHIP DISCOVERY βœ… FIXED! β”‚ β”œβ”€> Pattern-based βœ… (regex matching) β”œβ”€> Verb-based βœ… (fixed circular dep!) β”‚ └─> Now receives index as parameter └─> Inverse relationships βœ… β”‚ β–Ό 8. INDEX PERSISTENCE βœ… β”‚ └─> Saves to ~/.dollhouse/portfolio/capability-index.yaml - File size: ~200KB - 596 relationships stored ``` ## Performance Metrics (Current State) ``` ╔════════════════════════╦═════════╦═══════════════════════════╗ β•‘ Operation β•‘ Time β•‘ Status β•‘ ╠════════════════════════╬═════════╬═══════════════════════════╣ β•‘ Total Build β•‘ 186ms β•‘ βœ… Excellent β•‘ β•‘ Portfolio Scan β•‘ 50ms β•‘ βœ… Fast β•‘ β•‘ Metadata Extract β•‘ 40ms β•‘ ⚠️ Some files blocked β•‘ β•‘ NLP Scoring β•‘ 80ms β•‘ βœ… Optimized β•‘ β•‘ Relationship Discovery β•‘ 10ms β•‘ βœ… Fixed β•‘ β•‘ Save to Disk β•‘ 6ms β•‘ βœ… Fast β•‘ β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β• Elements: 186 | Relationships: 596 | Triggers: 2 ``` ## What's Still Broken / Not Done ### πŸ”΄ CRITICAL - Blocking Production #### 1. **NOT INTEGRATED INTO MAIN APP** ``` src/index.ts β”‚ β”œβ”€> ❌ Does NOT import EnhancedIndexManager β”œβ”€> ❌ No tools use relationships └─> ❌ No verb trigger support NEEDED: β”‚ β”œβ”€> Import and initialize EnhancedIndexManager β”œβ”€> Add to portfolio_search tool β”œβ”€> Create new MCP tools: β”‚ β”œβ”€> find_similar_elements β”‚ β”œβ”€> get_element_relationships β”‚ └─> search_by_verb └─> Add relationship info to responses ``` ### 🟑 MEDIUM - Quality Issues #### 2. **Security Validation False Positives** ``` PROBLEM: Legitimate security skills are blocked FILES AFFECTED: - comprehensive-security-auditor.md ❌ - content-safety-validator.md ❌ - encoding-pattern-detection.md ❌ - security-validation-system-summary.md ❌ - penetration-test-report.md ❌ CAUSE: ContentValidator patterns too aggressive PATTERN: /audit|security|scan/ matching in descriptions FIX NEEDED: - Refine patterns to be more specific - Whitelist security-related skills - Or disable validation for portfolio files ``` #### 3. **Test Suite Still Disabled** ``` test/__tests__/unit/portfolio/EnhancedIndexManager.test.ts └─> describe.skip() - Tests still skipped test/__tests__/unit/portfolio/VerbTriggerManager.test.ts └─> describe.skip() - Tests still skipped ISSUES: - File lock conflicts in test environment - Mock strategy needed for isolation - Tests timeout even with fixes ``` ### 🟒 MINOR - Enhancements #### 4. **No Persistent Cache** ``` CURRENT: Rebuilds index every restart NEEDED: Cache index between runs - Check file mtimes for changes - Only reindex modified files - Store cache in ~/.dollhouse/cache/ ``` #### 5. **Limited Verb Triggers** ``` CURRENT: Only 2 triggers found EXPECTED: Should find 50+ based on element names ISSUE: Verb extraction too conservative ``` ## Implementation Plan ### Phase 1: Fix Blockers (Current Session) ``` [βœ…] Fix circular dependency [βœ…] Increase comparison limits [βœ…] Document architecture [⬜] Fix security validation [⬜] Re-enable tests ``` ### Phase 2: Integration (Next Session) ``` [⬜] Add to src/index.ts initialization [⬜] Create find_similar_elements tool [⬜] Create get_element_relationships tool [⬜] Add relationships to portfolio_search [⬜] Enable verb-based discovery in activate_element ``` ### Phase 3: Optimization ``` [⬜] Implement persistent cache [⬜] Add incremental indexing [⬜] Use worker threads for NLP [⬜] Add progress reporting ``` ### Phase 4: Enhancement ``` [⬜] More relationship types [⬜] Element composition [⬜] Dependency tracking [⬜] Cross-element validation ``` ## Code Changes Needed ### 1. Fix Security Validation ```typescript // src/security/contentValidator.ts // Change overly broad patterns: - /audit/ // Matches "audit" anywhere + /\baudit\s*\(/ // Only matches audit() function calls - /security/ // Too broad + /security\s*\.\s*\w+/ // Only security.method patterns ``` ### 2. Integrate into Main App ```typescript // src/index.ts import { EnhancedIndexManager } from './portfolio/EnhancedIndexManager.js'; // In initialization: const enhancedIndex = EnhancedIndexManager.getInstance(); // In portfolio_search tool: const relationships = await enhancedIndex.getRelationships(elementName); // New tool: server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ // ... existing tools { name: 'find_similar_elements', description: 'Find elements similar to a given element', inputSchema: { type: 'object', properties: { element_name: { type: 'string' }, limit: { type: 'number', default: 5 } } } } ] })); ``` ### 3. Enable Tests ```typescript // test/__tests__/unit/portfolio/EnhancedIndexManager.test.ts describe('EnhancedIndexManager - Extensibility Tests', () => { // Remove skip // Add proper mocks for file system // Mock the index file to avoid building }); ``` ## Success Metrics ### Current State βœ… - Build time: 186ms βœ… - Elements indexed: 186 βœ… - Relationships: 596 βœ… - Memory usage: ~50MB βœ… ### Target State - Build time: <200ms βœ… - Elements indexed: 200+ ⬜ - Relationships: 1000+ ⬜ - Verb triggers: 50+ ⬜ - Test coverage: >96% ⬜ - Production integrated ⬜ ## Summary The Enhanced Index is **90% working** but **0% integrated**. The core functionality is stable and performant, but it needs: 1. **Security validation fix** (blocking some files) 2. **Production integration** (not used anywhere) 3. **Test suite enablement** (still skipped) With these three fixes, the feature will be fully production-ready and add significant value through semantic relationships and verb-based discovery. --- *Architecture Status: Core Fixed, Integration Pending* *Next Action: Fix security validation, then integrate into main app*

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/DollhouseMCP/DollhouseMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server