// Package context provides core context types and interfaces for the SLURP contextual intelligence system. // // This package defines the foundational data structures and interfaces for hierarchical // context resolution within the CHORUS distributed AI development system. It implements // bounded hierarchy traversal with role-based access control for efficient context // resolution and caching. // // Key Features: // - Hierarchical context resolution with bounded traversal depth // - Role-based access control and encryption for context data // - CSS-like inheritance patterns for cascading context properties // - Efficient caching with selective invalidation // - Integration with CHORUS election system for leader-only generation // // Core Types: // - ContextNode: Represents a single context entry in the hierarchy // - ResolvedContext: Final resolved context output with metadata // - RoleAccessLevel: Defines encryption levels for different roles // - EncryptedContext: Role-encrypted context data for DHT storage // // Primary Interfaces: // - ContextResolver: Main interface for hierarchical context resolution // - HierarchyManager: Manages the context hierarchy structure // - GlobalContextManager: Manages system-wide applicable contexts // // Integration Points: // - pkg/election: Leader election for context generation duties // - pkg/crypto: Role-based encryption and access control // - pkg/dht: Distributed storage of encrypted context data // - pkg/ucxl: UCXL address parsing and handling // // Example Usage: // // resolver := context.NewDefaultResolver(storage, crypto) // ctx := context.Background() // // // Resolve context for a UCXL address with bounded depth // resolved, err := resolver.ResolveWithDepth(ctx, "ucxl://project/src/main.go", 5) // if err != nil { // log.Fatal(err) // } // // fmt.Printf("Resolved context: %s\n", resolved.Summary) // fmt.Printf("Technologies: %v\n", resolved.Technologies) // fmt.Printf("Inheritance chain: %v\n", resolved.InheritanceChain) // // Architecture Design: // The context system uses a tree-like hierarchy where child contexts inherit // and override properties from their parents, similar to CSS cascading rules. // This enables efficient context resolution while maintaining consistency // and reducing duplication across the system. // // Performance Considerations: // - Bounded traversal prevents infinite loops and limits resource usage // - Caching with TTL reduces repeated resolution overhead // - Batch operations optimize multi-address resolution // - Role-based filtering reduces unnecessary data transfer // // Security Model: // All context data is encrypted based on role access levels before storage // in the distributed DHT. Only nodes with appropriate role permissions can // decrypt and access context information, ensuring secure context sharing // across the CHORUS cluster. package context