# HCFS - Hierarchical Context File System **Context-Aware Hierarchical Context File System (HCFS)**: Production-ready context management system with multi-language SDK ecosystem ## Overview HCFS is a comprehensive context management system that maps hierarchical paths to context blobs, enabling AI agents to navigate, store, and retrieve context in a structured manner. The system combines intuitive filesystem navigation with advanced semantic search capabilities and provides enterprise-grade APIs and SDKs across multiple programming languages. ## ✨ Key Features ### Core System - **πŸ“ Virtual Filesystem Layer**: POSIX-style directory navigation with context inheritance - **πŸ—„οΈ Context Database**: SQLite-backed storage with versioning and metadata - **πŸ” Hybrid Search**: Semantic similarity + BM25 keyword search with ML embeddings - **⚑ High Performance**: <5ms API response times, intelligent caching strategies - **πŸ” Enterprise Security**: JWT and API key authentication with comprehensive middleware ### Production API - **πŸš€ FastAPI Server**: Enterprise-grade REST API with OpenAPI documentation - **πŸ“‘ WebSocket Streaming**: Real-time context updates and notifications - **πŸ“¦ Batch Operations**: High-throughput processing for large-scale operations - **πŸ“Š Analytics**: Built-in usage tracking and performance monitoring ### Multi-Language SDK Ecosystem - **🐍 Python SDK**: Synchronous and asynchronous clients with advanced features - **πŸ“± JavaScript/TypeScript**: Promise-based API with full type safety - **πŸ”΅ Go**: Context-aware implementation with goroutine safety - **⚑ Rust**: Memory-safe async/await with zero-cost abstractions - **β˜• Java**: Reactive streams with RxJava integration - **πŸ”· C#**: .NET 6+ with dependency injection support ### Advanced Features - **πŸ’Ύ Smart Caching**: LRU, LFU, FIFO, and TTL strategies across all SDKs - **πŸ”„ Retry Logic**: Exponential backoff with jitter for resilient operations - **πŸ“‹ Comprehensive Error Handling**: Rich error hierarchies in every language - **πŸ“– Professional Documentation**: OpenAPI specs, PDF manuals, and SDK guides ## πŸš€ Quick Start ### Installation **Python SDK:** ```bash cd hcfs-python pip install -e . ``` **Other SDKs:** ```bash # JavaScript/TypeScript npm install @hcfs/sdk # Go go get github.com/hcfs/hcfs-go # Rust cargo add hcfs-sdk # Java (Gradle) implementation 'dev.hcfs:hcfs-sdk:2.0.0' # C# (.NET) dotnet add package HCFS.SDK ``` ### Basic Usage **Start the API Server:** ```bash hcfs server --host 0.0.0.0 --port 8000 ``` **Python Example:** ```python from hcfs.sdk import HCFSClient # Initialize client client = HCFSClient(base_url="http://localhost:8000") # Create a context context = client.create_context( path="/projects/ai-research", content="Research on context-aware AI systems", summary="AI research project context" ) # Search contexts results = client.search_contexts( "machine learning", search_type="semantic" ) print(f"Found {len(results)} related contexts") ``` **JavaScript Example:** ```javascript import { HCFSClient } from '@hcfs/sdk'; const client = new HCFSClient({ baseUrl: 'http://localhost:8000' }); // Create context const context = await client.createContext({ path: '/projects/web-app', content: 'Modern web application development', summary: 'Web development project' }); // Semantic search const results = await client.searchContexts('frontend development', { searchType: 'semantic', topK: 10 }); ``` ## πŸ—οΈ Architecture ### System Overview ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Multi-Language β”‚ β”‚ Production API β”‚ β”‚ Context Engine β”‚ β”‚ SDK Ecosystem β”‚ β”‚ (FastAPI) β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β€’ Python │◄──►│ β€’ Authentication│◄──►│ β€’ SQLite DB β”‚ β”‚ β€’ JavaScript/TS β”‚ β”‚ β€’ WebSocket β”‚ β”‚ β€’ ML Embeddings β”‚ β”‚ β€’ Go β”‚ β”‚ β€’ REST APIs β”‚ β”‚ β€’ Hybrid Search β”‚ β”‚ β€’ Rust β”‚ β”‚ β€’ Batch Ops β”‚ β”‚ β€’ Caching β”‚ β”‚ β€’ Java β”‚ β”‚ β€’ Monitoring β”‚ β”‚ β€’ Analytics β”‚ β”‚ β€’ C# β”‚ β”‚ β€’ Rate Limiting β”‚ β”‚ β€’ Versioning β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` ### Core Components #### 🎯 Context Management - **Hierarchical Storage**: Path-based context organization with inheritance - **Semantic Indexing**: sentence-transformers for context embeddings - **Hybrid Search**: BM25 + semantic similarity for optimal relevance - **Versioning System**: Full context history with rollback capabilities #### πŸ”Œ API Layer - **FastAPI Server**: Production-grade REST API with OpenAPI documentation - **Authentication**: JWT tokens and API key support with middleware - **WebSocket Streaming**: Real-time context updates and notifications - **Batch Operations**: Efficient bulk context processing #### πŸ“š SDK Ecosystem - **Consistent Interface**: Same API patterns across all programming languages - **Advanced Features**: Caching, retry logic, error handling, analytics - **Type Safety**: Full type definitions where supported by language - **Performance Optimized**: Language-specific optimizations and idioms ## βœ… Development Status ### Completed Phases #### Phase 1: Core System βœ… **COMPLETE** - βœ… Virtual filesystem layer with FUSE integration - βœ… SQLite context database with versioning - βœ… Semantic search with ML embeddings - βœ… Hybrid BM25 + semantic ranking - βœ… CLI interface and basic REST API #### Phase 2: Production API & SDK Ecosystem βœ… **COMPLETE** - βœ… Enterprise FastAPI server with authentication - βœ… Comprehensive Python SDK (sync + async) - βœ… Multi-language SDK ecosystem (5 languages) - βœ… OpenAPI documentation with PDF generation - βœ… WebSocket streaming and advanced caching - βœ… Professional documentation system ### Future Development (Optional Extensions) - **Distributed Systems**: Multi-node synchronization and consensus - **Advanced Analytics**: Context usage patterns and insights - **Enterprise Features**: Multi-tenancy and advanced security - **Performance Optimization**: Large-scale deployment optimizations ## πŸ“Š Performance & Testing ### Benchmarks - **API Response Times**: <5ms for cached operations, <50ms for uncached - **Search Performance**: <100ms for semantic search across 1000+ contexts - **WebSocket Latency**: <100ms for real-time updates - **Batch Processing**: 1000+ contexts processed efficiently - **Memory Usage**: ~500MB with full ML stack loaded ### Testing Coverage - βœ… **Unit Tests**: Core functionality across all components - βœ… **Integration Tests**: End-to-end API and SDK testing - βœ… **Performance Tests**: Load testing and benchmarking - βœ… **Multi-language Validation**: All SDKs tested for consistency ## πŸ“š Documentation - **[API Reference](hcfs-python/openapi.yaml)**: Complete OpenAPI specification - **[Project Report](HCFS_PROJECT_REPORT.md)**: Comprehensive project documentation - **[SDK Documentation](sdks/)**: Language-specific guides and examples - **[Architecture Guide](docs/ARCHITECTURE.md)**: Technical implementation details ## 🀝 Contributing HCFS is production-ready and open for contributions! Areas of interest: ### Core Development - Performance optimizations for large-scale deployments - Additional language SDK implementations - Advanced caching strategies and storage backends ### Extensions & Integrations - Vector database integrations (Pinecone, Weaviate, etc.) - Cloud deployment templates (AWS, GCP, Azure) - Framework integrations (LangChain, LlamaIndex, etc.) ### Getting Started 1. Fork the repository 2. Set up development environment: `cd hcfs-python && pip install -e .` 3. Run tests: `python -m pytest tests/` 4. Check specific SDK directories for language-specific setup ## 🎯 Use Cases ### AI Agent Development - **Context Sharing**: Multi-agent systems with shared context spaces - **Knowledge Management**: Hierarchical organization of agent knowledge - **Session Continuity**: Persistent context across agent interactions ### Enterprise Applications - **Document Management**: Semantic document organization and retrieval - **Team Collaboration**: Shared context spaces for development teams - **Knowledge Bases**: Intelligent corporate knowledge management ### Research & Development - **Context-Aware Systems**: Research on hierarchical context models - **Semantic Filesystems**: Novel approaches to file organization - **AI Agent Coordination**: Multi-agent context sharing patterns ## πŸ“„ License MIT License - see [LICENSE](LICENSE) for details. ## πŸ”¬ Research Foundation HCFS represents novel research in context-aware systems, combining: - **Semantic Filesystems**: Hierarchical path-to-context mapping - **ML-Powered Search**: Hybrid BM25 + semantic similarity ranking - **Agent-Centric Design**: Purpose-built for AI agent context management - **Multi-Language Ecosystem**: Comprehensive SDK support across languages **Academic Applications**: Ready for research publication and academic use. **Commercial Viability**: Production-ready for enterprise deployment and licensing.