mirror of
https://github.com/lukaszraczylo/claude-mnemonic.git
synced 2026-06-14 02:11:34 +00:00
74ae8ed4c1
- [x] Add AST-aware code chunking for Go, Python, and TypeScript using tree-sitter - [x] Implement LEANN-inspired hybrid vector storage with hub detection and selective embedding storage (60-80% savings) - [x] Add observation relationship graph with CSR format and edge detection (file overlap, semantic similarity, temporal, concept) - [x] Implement graph-aware search with two-level traversal and relationship-based ranking - [x] Add auto-tuning system for dynamic hub threshold adjustment based on query performance - [x] Add comprehensive metrics tracking for vector storage, queries, latency, and graph traversals - [x] Update configuration system with graph and hybrid storage settings - [x] Add graph stats and vector metrics endpoints to worker service - [x] Enhance UI sidebar with advanced metrics display and graph visualization - [x] Optimize struct field alignment throughout codebase for memory efficiency - [x] Update documentation with LEANN Phase 2 features and performance benefits - [x] Add tree-sitter dependency for AST parsing
63 lines
1.4 KiB
Go
63 lines
1.4 KiB
Go
package hybrid
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
// GetStrategyFromEnv reads CLAUDE_MNEMONIC_VECTOR_STRATEGY from environment
|
|
func GetStrategyFromEnv() VectorStorageStrategy {
|
|
strategyStr := os.Getenv("CLAUDE_MNEMONIC_VECTOR_STRATEGY")
|
|
if strategyStr == "" {
|
|
// Default to hub strategy for optimal balance
|
|
return StorageHub
|
|
}
|
|
|
|
strategy := ParseStrategy(strategyStr)
|
|
log.Info().
|
|
Str("env_value", strategyStr).
|
|
Str("strategy", strategyToString(strategy)).
|
|
Msg("Vector storage strategy from environment")
|
|
|
|
return strategy
|
|
}
|
|
|
|
// GetHubThresholdFromEnv reads CLAUDE_MNEMONIC_HUB_THRESHOLD from environment
|
|
func GetHubThresholdFromEnv() int {
|
|
thresholdStr := os.Getenv("CLAUDE_MNEMONIC_HUB_THRESHOLD")
|
|
if thresholdStr == "" {
|
|
return 5 // Default threshold
|
|
}
|
|
|
|
threshold, err := strconv.Atoi(thresholdStr)
|
|
if err != nil {
|
|
log.Warn().
|
|
Err(err).
|
|
Str("env_value", thresholdStr).
|
|
Msg("Invalid hub threshold in environment, using default")
|
|
return 5
|
|
}
|
|
|
|
if threshold < 1 {
|
|
log.Warn().
|
|
Int("env_value", threshold).
|
|
Msg("Hub threshold too low, using minimum of 1")
|
|
return 1
|
|
}
|
|
|
|
log.Info().
|
|
Int("threshold", threshold).
|
|
Msg("Hub threshold from environment")
|
|
|
|
return threshold
|
|
}
|
|
|
|
// IsHybridEnabled checks if hybrid storage should be used
|
|
// Returns false if CLAUDE_MNEMONIC_VECTOR_STRATEGY=always (backwards compat)
|
|
func IsHybridEnabled() bool {
|
|
strategy := GetStrategyFromEnv()
|
|
return strategy != StorageAlways
|
|
}
|