Skip to content

Intelligent Indexing System #322

@ProjectLiminality

Description

@ProjectLiminality

Description

Background indexing system with intelligent incremental updates for DreamNode content. Implements git-integrated indexing pipeline that automatically maintains vector embeddings as DreamNodes are created, modified, or updated.

Parent Specification: #268 - Search Architecture Specification

Implementation Plan

Architecture Integration

1. IndexingService Creation (src/services/indexing-service.ts) ✅

  • Create IIndexingService interface following existing service pattern
  • Implement IndexingService class with cross-session persistence via InterBrain store
  • Store vector embeddings and indexing metadata in persisted store
  • Hook into existing GitDreamNodeService.checkGitStatus() for change detection

2. Store Enhancement (src/store/interbrain-store.ts) ✅

  • Add indexing state: indexingState, vectorData, indexingProgress
  • Include vector embeddings in persisted store data
  • Track progress for batch operations

3. Service Manager Integration ✅

  • Initialize and manage IndexingService instance
  • Handle indexing across mock/real mode transitions
  • Coordinate between DreamNode CRUD operations and indexing updates

4. Git Integration Hooks ✅

  • Trigger indexing on GitDreamNodeService.create()
  • Extend refreshGitStatus() to trigger re-indexing on commit detection
  • Use git commit hashes for delta detection

5. Command Palette Commands ✅

  • interbrain:index-selected-node - Index currently selected DreamNode
  • interbrain:index-all-nodes - Full reindex of all DreamNodes
  • interbrain:intelligent-reindex - Delta-based intelligent update (primary command)

Vector Storage Structure ✅

interface VectorData {
  nodeId: string;
  contentHash: string;  // Git commit hash for change detection
  embedding: number[];  // Vector embedding
  lastIndexed: number;  // Timestamp
  metadata: {
    title: string;
    type: 'dream' | 'dreamer';
    wordCount: number;
  };
}

Implementation Phases ✅

  1. Core Infrastructure: IndexingService, store integration, basic storage
  2. Git Integration: Creation hooks, commit detection, delta algorithm
  3. Service Manager: Lifecycle management, mode switching, CRUD coordination
  4. Performance & UX: Background processing, progress indicators, error handling

Acceptance Criteria

  • Command-based indexing system with progress indicators
  • Git integration for automatic re-indexing on DreamNode changes
  • Incremental updates for optimal performance (only changed nodes)
  • Multi-content-type indexing pipeline (text + future image support)
  • Background operation with no UX blocking
  • Intelligent change detection via git hooks and file monitoring

Dependencies

  • Parent specification Search Architecture Specification #268 must be approved
  • Qwen3-Embedding-0.6B model integration (deferred - using simple text analysis initially)
  • Vectra vector database setup (deferred - using in-memory storage initially)

Definition of Done

  • Implementation complete
  • Tests passing
  • Documentation updated
  • Code reviewed and merged
  • Git hooks integrated for automatic indexing triggers
  • Performance benchmarked for incremental vs full indexing

Technical Notes

  • Integration with existing service layer pattern (mock/real implementations)
  • Cross-session persistence via Zustand store middleware
  • Path of least resistance: Start with intelligent re-index command, then automate
  • Scale target: Thousands of DreamNodes
  • Storage: InterBrain store with persistent memory middleware

Implementation Complete ✅

Key Features Delivered:

  • Complete IndexingService with interface-based architecture
  • Cross-session vector data persistence via Zustand store
  • Three command palette commands with async operation patterns
  • Automatic indexing on DreamNode creation
  • Git-based change detection using commit hashes
  • Intelligent delta updates with cleanup of deleted nodes
  • Comprehensive test suite (22 tests) covering all functionality
  • Character frequency-based embeddings (placeholder for future Qwen3 integration)

Files Modified:

  • src/services/indexing-service.ts (new) - Core indexing functionality
  • src/store/interbrain-store.ts - Added vector data storage
  • src/main.ts - Added three indexing commands
  • src/services/git-dreamnode-service.ts - Auto-indexing integration
  • src/services/service-manager.ts - IndexingService registration
  • src/services/ui-service.ts - Added showWarning method
  • src/types/dreamnode.ts - Enhanced GitStatus interface
  • tests/services/indexing-service.test.ts (new) - Complete test coverage

Ready for merge to epic branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureFeature level issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions