chore: align slurp config and scaffolding
This commit is contained in:
@@ -5,7 +5,9 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
slurpContext "chorus/pkg/slurp/context"
|
||||
"chorus/pkg/slurp/storage"
|
||||
"chorus/pkg/ucxl"
|
||||
)
|
||||
|
||||
// TemporalGraphFactory creates and configures temporal graph components
|
||||
@@ -17,44 +19,44 @@ type TemporalGraphFactory struct {
|
||||
// TemporalConfig represents configuration for the temporal graph system
|
||||
type TemporalConfig struct {
|
||||
// Core graph settings
|
||||
MaxDepth int `json:"max_depth"`
|
||||
StalenessWeights *StalenessWeights `json:"staleness_weights"`
|
||||
CacheTimeout time.Duration `json:"cache_timeout"`
|
||||
|
||||
MaxDepth int `json:"max_depth"`
|
||||
StalenessWeights *StalenessWeights `json:"staleness_weights"`
|
||||
CacheTimeout time.Duration `json:"cache_timeout"`
|
||||
|
||||
// Analysis settings
|
||||
InfluenceAnalysisConfig *InfluenceAnalysisConfig `json:"influence_analysis_config"`
|
||||
NavigationConfig *NavigationConfig `json:"navigation_config"`
|
||||
QueryConfig *QueryConfig `json:"query_config"`
|
||||
|
||||
|
||||
// Persistence settings
|
||||
PersistenceConfig *PersistenceConfig `json:"persistence_config"`
|
||||
|
||||
PersistenceConfig *PersistenceConfig `json:"persistence_config"`
|
||||
|
||||
// Performance settings
|
||||
EnableCaching bool `json:"enable_caching"`
|
||||
EnableCompression bool `json:"enable_compression"`
|
||||
EnableMetrics bool `json:"enable_metrics"`
|
||||
|
||||
EnableCaching bool `json:"enable_caching"`
|
||||
EnableCompression bool `json:"enable_compression"`
|
||||
EnableMetrics bool `json:"enable_metrics"`
|
||||
|
||||
// Debug settings
|
||||
EnableDebugLogging bool `json:"enable_debug_logging"`
|
||||
EnableValidation bool `json:"enable_validation"`
|
||||
EnableDebugLogging bool `json:"enable_debug_logging"`
|
||||
EnableValidation bool `json:"enable_validation"`
|
||||
}
|
||||
|
||||
// InfluenceAnalysisConfig represents configuration for influence analysis
|
||||
type InfluenceAnalysisConfig struct {
|
||||
DampingFactor float64 `json:"damping_factor"`
|
||||
MaxIterations int `json:"max_iterations"`
|
||||
ConvergenceThreshold float64 `json:"convergence_threshold"`
|
||||
CacheValidDuration time.Duration `json:"cache_valid_duration"`
|
||||
EnableCentralityMetrics bool `json:"enable_centrality_metrics"`
|
||||
EnableCommunityDetection bool `json:"enable_community_detection"`
|
||||
DampingFactor float64 `json:"damping_factor"`
|
||||
MaxIterations int `json:"max_iterations"`
|
||||
ConvergenceThreshold float64 `json:"convergence_threshold"`
|
||||
CacheValidDuration time.Duration `json:"cache_valid_duration"`
|
||||
EnableCentralityMetrics bool `json:"enable_centrality_metrics"`
|
||||
EnableCommunityDetection bool `json:"enable_community_detection"`
|
||||
}
|
||||
|
||||
// NavigationConfig represents configuration for decision navigation
|
||||
type NavigationConfig struct {
|
||||
MaxNavigationHistory int `json:"max_navigation_history"`
|
||||
BookmarkRetention time.Duration `json:"bookmark_retention"`
|
||||
SessionTimeout time.Duration `json:"session_timeout"`
|
||||
EnablePathCaching bool `json:"enable_path_caching"`
|
||||
MaxNavigationHistory int `json:"max_navigation_history"`
|
||||
BookmarkRetention time.Duration `json:"bookmark_retention"`
|
||||
SessionTimeout time.Duration `json:"session_timeout"`
|
||||
EnablePathCaching bool `json:"enable_path_caching"`
|
||||
}
|
||||
|
||||
// QueryConfig represents configuration for decision-hop queries
|
||||
@@ -68,17 +70,17 @@ type QueryConfig struct {
|
||||
|
||||
// TemporalGraphSystem represents the complete temporal graph system
|
||||
type TemporalGraphSystem struct {
|
||||
Graph TemporalGraph
|
||||
Navigator DecisionNavigator
|
||||
InfluenceAnalyzer InfluenceAnalyzer
|
||||
StalenessDetector StalenessDetector
|
||||
ConflictDetector ConflictDetector
|
||||
PatternAnalyzer PatternAnalyzer
|
||||
VersionManager VersionManager
|
||||
HistoryManager HistoryManager
|
||||
MetricsCollector MetricsCollector
|
||||
QuerySystem *querySystemImpl
|
||||
PersistenceManager *persistenceManagerImpl
|
||||
Graph TemporalGraph
|
||||
Navigator DecisionNavigator
|
||||
InfluenceAnalyzer InfluenceAnalyzer
|
||||
StalenessDetector StalenessDetector
|
||||
ConflictDetector ConflictDetector
|
||||
PatternAnalyzer PatternAnalyzer
|
||||
VersionManager VersionManager
|
||||
HistoryManager HistoryManager
|
||||
MetricsCollector MetricsCollector
|
||||
QuerySystem *querySystemImpl
|
||||
PersistenceManager *persistenceManagerImpl
|
||||
}
|
||||
|
||||
// NewTemporalGraphFactory creates a new temporal graph factory
|
||||
@@ -86,7 +88,7 @@ func NewTemporalGraphFactory(storage storage.ContextStore, config *TemporalConfi
|
||||
if config == nil {
|
||||
config = DefaultTemporalConfig()
|
||||
}
|
||||
|
||||
|
||||
return &TemporalGraphFactory{
|
||||
storage: storage,
|
||||
config: config,
|
||||
@@ -100,22 +102,22 @@ func (tgf *TemporalGraphFactory) CreateTemporalGraphSystem(
|
||||
encryptedStorage storage.EncryptedStorage,
|
||||
backupManager storage.BackupManager,
|
||||
) (*TemporalGraphSystem, error) {
|
||||
|
||||
|
||||
// Create core temporal graph
|
||||
graph := NewTemporalGraph(tgf.storage).(*temporalGraphImpl)
|
||||
|
||||
|
||||
// Create navigator
|
||||
navigator := NewDecisionNavigator(graph)
|
||||
|
||||
|
||||
// Create influence analyzer
|
||||
analyzer := NewInfluenceAnalyzer(graph)
|
||||
|
||||
|
||||
// Create staleness detector
|
||||
detector := NewStalenessDetector(graph)
|
||||
|
||||
|
||||
// Create query system
|
||||
querySystem := NewQuerySystem(graph, navigator, analyzer, detector)
|
||||
|
||||
|
||||
// Create persistence manager
|
||||
persistenceManager := NewPersistenceManager(
|
||||
tgf.storage,
|
||||
@@ -126,28 +128,28 @@ func (tgf *TemporalGraphFactory) CreateTemporalGraphSystem(
|
||||
graph,
|
||||
tgf.config.PersistenceConfig,
|
||||
)
|
||||
|
||||
|
||||
// Create additional components
|
||||
conflictDetector := NewConflictDetector(graph)
|
||||
patternAnalyzer := NewPatternAnalyzer(graph)
|
||||
versionManager := NewVersionManager(graph, persistenceManager)
|
||||
historyManager := NewHistoryManager(graph, persistenceManager)
|
||||
metricsCollector := NewMetricsCollector(graph)
|
||||
|
||||
|
||||
system := &TemporalGraphSystem{
|
||||
Graph: graph,
|
||||
Navigator: navigator,
|
||||
InfluenceAnalyzer: analyzer,
|
||||
StalenessDetector: detector,
|
||||
ConflictDetector: conflictDetector,
|
||||
PatternAnalyzer: patternAnalyzer,
|
||||
VersionManager: versionManager,
|
||||
HistoryManager: historyManager,
|
||||
MetricsCollector: metricsCollector,
|
||||
QuerySystem: querySystem,
|
||||
PersistenceManager: persistenceManager,
|
||||
Graph: graph,
|
||||
Navigator: navigator,
|
||||
InfluenceAnalyzer: analyzer,
|
||||
StalenessDetector: detector,
|
||||
ConflictDetector: conflictDetector,
|
||||
PatternAnalyzer: patternAnalyzer,
|
||||
VersionManager: versionManager,
|
||||
HistoryManager: historyManager,
|
||||
MetricsCollector: metricsCollector,
|
||||
QuerySystem: querySystem,
|
||||
PersistenceManager: persistenceManager,
|
||||
}
|
||||
|
||||
|
||||
return system, nil
|
||||
}
|
||||
|
||||
@@ -159,19 +161,19 @@ func (tgf *TemporalGraphFactory) LoadExistingSystem(
|
||||
encryptedStorage storage.EncryptedStorage,
|
||||
backupManager storage.BackupManager,
|
||||
) (*TemporalGraphSystem, error) {
|
||||
|
||||
|
||||
// Create system
|
||||
system, err := tgf.CreateTemporalGraphSystem(localStorage, distributedStorage, encryptedStorage, backupManager)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create system: %w", err)
|
||||
}
|
||||
|
||||
|
||||
// Load graph data
|
||||
err = system.PersistenceManager.LoadTemporalGraph(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to load temporal graph: %w", err)
|
||||
}
|
||||
|
||||
|
||||
return system, nil
|
||||
}
|
||||
|
||||
@@ -188,23 +190,23 @@ func DefaultTemporalConfig() *TemporalConfig {
|
||||
DependencyWeight: 0.3,
|
||||
},
|
||||
CacheTimeout: time.Minute * 15,
|
||||
|
||||
|
||||
InfluenceAnalysisConfig: &InfluenceAnalysisConfig{
|
||||
DampingFactor: 0.85,
|
||||
MaxIterations: 100,
|
||||
ConvergenceThreshold: 1e-6,
|
||||
CacheValidDuration: time.Minute * 30,
|
||||
EnableCentralityMetrics: true,
|
||||
DampingFactor: 0.85,
|
||||
MaxIterations: 100,
|
||||
ConvergenceThreshold: 1e-6,
|
||||
CacheValidDuration: time.Minute * 30,
|
||||
EnableCentralityMetrics: true,
|
||||
EnableCommunityDetection: true,
|
||||
},
|
||||
|
||||
|
||||
NavigationConfig: &NavigationConfig{
|
||||
MaxNavigationHistory: 100,
|
||||
BookmarkRetention: time.Hour * 24 * 30, // 30 days
|
||||
SessionTimeout: time.Hour * 2,
|
||||
EnablePathCaching: true,
|
||||
},
|
||||
|
||||
|
||||
QueryConfig: &QueryConfig{
|
||||
DefaultMaxHops: 10,
|
||||
MaxQueryResults: 1000,
|
||||
@@ -212,28 +214,28 @@ func DefaultTemporalConfig() *TemporalConfig {
|
||||
CacheQueryResults: true,
|
||||
EnableQueryOptimization: true,
|
||||
},
|
||||
|
||||
|
||||
PersistenceConfig: &PersistenceConfig{
|
||||
EnableLocalStorage: true,
|
||||
EnableDistributedStorage: true,
|
||||
EnableEncryption: true,
|
||||
EncryptionRoles: []string{"analyst", "architect", "developer"},
|
||||
SyncInterval: time.Minute * 15,
|
||||
EnableLocalStorage: true,
|
||||
EnableDistributedStorage: true,
|
||||
EnableEncryption: true,
|
||||
EncryptionRoles: []string{"analyst", "architect", "developer"},
|
||||
SyncInterval: time.Minute * 15,
|
||||
ConflictResolutionStrategy: "latest_wins",
|
||||
EnableAutoSync: true,
|
||||
MaxSyncRetries: 3,
|
||||
BatchSize: 50,
|
||||
FlushInterval: time.Second * 30,
|
||||
EnableWriteBuffer: true,
|
||||
EnableAutoBackup: true,
|
||||
BackupInterval: time.Hour * 6,
|
||||
RetainBackupCount: 10,
|
||||
KeyPrefix: "temporal_graph",
|
||||
NodeKeyPattern: "temporal_graph/nodes/%s",
|
||||
GraphKeyPattern: "temporal_graph/graph/%s",
|
||||
MetadataKeyPattern: "temporal_graph/metadata/%s",
|
||||
EnableAutoSync: true,
|
||||
MaxSyncRetries: 3,
|
||||
BatchSize: 50,
|
||||
FlushInterval: time.Second * 30,
|
||||
EnableWriteBuffer: true,
|
||||
EnableAutoBackup: true,
|
||||
BackupInterval: time.Hour * 6,
|
||||
RetainBackupCount: 10,
|
||||
KeyPrefix: "temporal_graph",
|
||||
NodeKeyPattern: "temporal_graph/nodes/%s",
|
||||
GraphKeyPattern: "temporal_graph/graph/%s",
|
||||
MetadataKeyPattern: "temporal_graph/metadata/%s",
|
||||
},
|
||||
|
||||
|
||||
EnableCaching: true,
|
||||
EnableCompression: false,
|
||||
EnableMetrics: true,
|
||||
@@ -308,11 +310,11 @@ func (cd *conflictDetectorImpl) ValidateDecisionSequence(ctx context.Context, ad
|
||||
func (cd *conflictDetectorImpl) ResolveTemporalConflict(ctx context.Context, conflict *TemporalConflict) (*ConflictResolution, error) {
|
||||
// Implementation would resolve specific temporal conflicts
|
||||
return &ConflictResolution{
|
||||
ConflictID: conflict.ID,
|
||||
Resolution: "auto_resolved",
|
||||
ResolvedAt: time.Now(),
|
||||
ResolvedBy: "system",
|
||||
Confidence: 0.8,
|
||||
ConflictID: conflict.ID,
|
||||
ResolutionMethod: "auto_resolved",
|
||||
ResolvedAt: time.Now(),
|
||||
ResolvedBy: "system",
|
||||
Confidence: 0.8,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -373,7 +375,7 @@ type versionManagerImpl struct {
|
||||
persistence *persistenceManagerImpl
|
||||
}
|
||||
|
||||
func (vm *versionManagerImpl) CreateVersion(ctx context.Context, address ucxl.Address,
|
||||
func (vm *versionManagerImpl) CreateVersion(ctx context.Context, address ucxl.Address,
|
||||
contextNode *slurpContext.ContextNode, metadata *VersionMetadata) (*TemporalNode, error) {
|
||||
// Implementation would create a new temporal version
|
||||
return vm.graph.EvolveContext(ctx, address, contextNode, metadata.Reason, metadata.Decision)
|
||||
@@ -390,7 +392,7 @@ func (vm *versionManagerImpl) ListVersions(ctx context.Context, address ucxl.Add
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
versions := make([]*VersionInfo, len(history))
|
||||
for i, node := range history {
|
||||
versions[i] = &VersionInfo{
|
||||
@@ -402,11 +404,11 @@ func (vm *versionManagerImpl) ListVersions(ctx context.Context, address ucxl.Add
|
||||
DecisionID: node.DecisionID,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return versions, nil
|
||||
}
|
||||
|
||||
func (vm *versionManagerImpl) CompareVersions(ctx context.Context, address ucxl.Address,
|
||||
func (vm *versionManagerImpl) CompareVersions(ctx context.Context, address ucxl.Address,
|
||||
version1, version2 int) (*VersionComparison, error) {
|
||||
// Implementation would compare two temporal versions
|
||||
return &VersionComparison{
|
||||
@@ -420,7 +422,7 @@ func (vm *versionManagerImpl) CompareVersions(ctx context.Context, address ucxl.
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (vm *versionManagerImpl) MergeVersions(ctx context.Context, address ucxl.Address,
|
||||
func (vm *versionManagerImpl) MergeVersions(ctx context.Context, address ucxl.Address,
|
||||
versions []int, strategy MergeStrategy) (*TemporalNode, error) {
|
||||
// Implementation would merge multiple versions
|
||||
return vm.graph.GetLatestVersion(ctx, address)
|
||||
@@ -447,7 +449,7 @@ func (hm *historyManagerImpl) GetFullHistory(ctx context.Context, address ucxl.A
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
return &ContextHistory{
|
||||
Address: address,
|
||||
Versions: history,
|
||||
@@ -455,7 +457,7 @@ func (hm *historyManagerImpl) GetFullHistory(ctx context.Context, address ucxl.A
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (hm *historyManagerImpl) GetHistoryRange(ctx context.Context, address ucxl.Address,
|
||||
func (hm *historyManagerImpl) GetHistoryRange(ctx context.Context, address ucxl.Address,
|
||||
startHop, endHop int) (*ContextHistory, error) {
|
||||
// Implementation would get history within a specific range
|
||||
return hm.GetFullHistory(ctx, address)
|
||||
@@ -539,13 +541,13 @@ func (mc *metricsCollectorImpl) GetInfluenceMetrics(ctx context.Context) (*Influ
|
||||
func (mc *metricsCollectorImpl) GetQualityMetrics(ctx context.Context) (*QualityMetrics, error) {
|
||||
// Implementation would get temporal data quality metrics
|
||||
return &QualityMetrics{
|
||||
DataCompleteness: 1.0,
|
||||
DataConsistency: 1.0,
|
||||
DataAccuracy: 1.0,
|
||||
AverageConfidence: 0.8,
|
||||
ConflictsDetected: 0,
|
||||
ConflictsResolved: 0,
|
||||
LastQualityCheck: time.Now(),
|
||||
DataCompleteness: 1.0,
|
||||
DataConsistency: 1.0,
|
||||
DataAccuracy: 1.0,
|
||||
AverageConfidence: 0.8,
|
||||
ConflictsDetected: 0,
|
||||
ConflictsResolved: 0,
|
||||
LastQualityCheck: time.Now(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -560,4 +562,4 @@ func (mc *metricsCollectorImpl) calculateInfluenceConnections() int {
|
||||
total += len(influences)
|
||||
}
|
||||
return total
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user