Documentation
¶
Index ¶
- type ConfidenceUpdate
- type ConfirmRequest
- type FeedbackService
- func (fs *FeedbackService) ConfirmSuggestion(ctx context.Context, req ConfirmRequest) error
- func (fs *FeedbackService) GetTopValidatedPatterns(ctx context.Context, userID string, limit int) ([]Memory, error)
- func (fs *FeedbackService) PromoteMemory(ctx context.Context, req PromoteRequest) error
- func (fs *FeedbackService) ValidatePattern(ctx context.Context, patternID string, userID string) (bool, float64, error)
- type Memory
- type MemoryStore
- func (ms *MemoryStore) BatchUpdateConfidence(ctx context.Context, updates []ConfidenceUpdate) error
- func (ms *MemoryStore) Clear()
- func (ms *MemoryStore) Close() error
- func (ms *MemoryStore) Count() int
- func (ms *MemoryStore) GetByID(id string) (*Memory, bool)
- func (ms *MemoryStore) GetPatternConfidence(ctx context.Context, patternID string) (float64, error)
- func (ms *MemoryStore) GetPatternFeedbackCounts(ctx context.Context, patternID string) (confirmed, failed int, err error)
- func (ms *MemoryStore) GetPatterns(ctx context.Context, errorType string) ([]Memory, error)
- func (ms *MemoryStore) GetPatternsForCalibration(ctx context.Context, projectID string, batchSize int) ([]Memory, error)
- func (ms *MemoryStore) GetProjectPatterns(ctx context.Context, projectID, errorType string) ([]Memory, error)
- func (ms *MemoryStore) GetStats(ctx context.Context, projectID string) (map[string]interface{}, error)
- func (ms *MemoryStore) GetUserPatterns(ctx context.Context, userID, errorType string) ([]Memory, error)
- func (ms *MemoryStore) GetUserStats(ctx context.Context, userID string) (map[string]interface{}, error)
- func (ms *MemoryStore) Query(ctx context.Context, query string, limit int) ([]Memory, error)
- func (ms *MemoryStore) QueryUserMemories(ctx context.Context, userID, query string, limit int) ([]Memory, error)
- func (ms *MemoryStore) QueryWithScope(ctx context.Context, query string, limit int, projectID, sessionID string) ([]Memory, error)
- func (ms *MemoryStore) SimilaritySearch(ctx context.Context, text string, limit int) ([]Memory, error)
- func (ms *MemoryStore) Store(ctx context.Context, content string, memType string, ...) (string, error)
- func (ms *MemoryStore) StoreForUser(ctx context.Context, userID, content string, memType string, ...) (string, error)
- func (ms *MemoryStore) StoreWithScope(ctx context.Context, content string, memType string, ...) (string, error)
- func (ms *MemoryStore) SuggestFix(ctx context.Context, errorMsg string) (string, error)
- func (ms *MemoryStore) SuggestFixForUser(ctx context.Context, userID, errorMsg string) (string, error)
- type Pattern
- type PromoteRequest
- type RedisStore
- func (rs *RedisStore) BatchUpdateConfidence(ctx context.Context, updates []ConfidenceUpdate) error
- func (rs *RedisStore) Close() error
- func (rs *RedisStore) GetPatternConfidence(ctx context.Context, patternID string) (float64, error)
- func (rs *RedisStore) GetPatternFeedbackCounts(ctx context.Context, patternID string) (confirmed, failed int, err error)
- func (rs *RedisStore) GetPatterns(ctx context.Context, errorType string) ([]Memory, error)
- func (rs *RedisStore) GetPatternsForCalibration(ctx context.Context, projectID string, batchSize int) ([]Memory, error)
- func (rs *RedisStore) GetProjectPatterns(ctx context.Context, projectID, errorType string) ([]Memory, error)
- func (rs *RedisStore) GetStats(ctx context.Context, projectID string) (map[string]interface{}, error)
- func (rs *RedisStore) GetUserPatterns(ctx context.Context, userID, errorType string) ([]Memory, error)
- func (rs *RedisStore) GetUserStats(ctx context.Context, userID string) (map[string]interface{}, error)
- func (rs *RedisStore) Query(ctx context.Context, query string, limit int) ([]Memory, error)
- func (rs *RedisStore) QueryUserMemories(ctx context.Context, userID, query string, limit int) ([]Memory, error)
- func (rs *RedisStore) QueryWithScope(ctx context.Context, query string, limit int, projectID, sessionID string) ([]Memory, error)
- func (rs *RedisStore) SimilaritySearch(ctx context.Context, text string, limit int) ([]Memory, error)
- func (rs *RedisStore) Store(ctx context.Context, content string, memType string, ...) (string, error)
- func (rs *RedisStore) StoreForUser(ctx context.Context, userID, content string, memType string, ...) (string, error)
- func (rs *RedisStore) StoreWithScope(ctx context.Context, content string, memType string, ...) (string, error)
- func (rs *RedisStore) SuggestFix(ctx context.Context, errorMsg string) (string, error)
- func (rs *RedisStore) SuggestFixForUser(ctx context.Context, userID, errorMsg string) (string, error)
- type SearchQuery
- type SearchService
- func (ss *SearchService) AggregateStats(ctx context.Context, groupBy string, projectID string) (map[string]interface{}, error)
- func (ss *SearchService) InitializeIndexes(ctx context.Context) error
- func (ss *SearchService) SearchMemories(ctx context.Context, query SearchQuery) ([]Memory, error)
- func (ss *SearchService) SearchPatterns(ctx context.Context, errorMsg string, minConfidence float64) ([]Pattern, error)
- func (ss *SearchService) SimilaritySearch(ctx context.Context, text string, limit int) ([]Memory, error)
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfidenceUpdate ¶
type ConfidenceUpdate struct { PatternID string `json:"pattern_id"` NewConfidence float64 `json:"new_confidence"` ConfidenceDelta float64 `json:"confidence_delta"` UpdateReason string `json:"update_reason,omitempty"` }
ConfidenceUpdate represents a batch confidence score update
type ConfirmRequest ¶
type ConfirmRequest struct { PatternID string `json:"pattern_id"` Success bool `json:"success"` UserID string `json:"user_id,omitempty"` ProjectID string `json:"project_id,omitempty"` SessionID string `json:"session_id,omitempty"` ErrorMsg string `json:"error_msg,omitempty"` Solution string `json:"solution,omitempty"` Feedback string `json:"feedback,omitempty"` TimeToFix time.Duration `json:"time_to_fix,omitempty"` Metadata map[string]interface{} `json:"metadata,omitempty"` }
ConfirmRequest represents a request to confirm that a suggested fix or pattern worked
type FeedbackService ¶
type FeedbackService struct {
// contains filtered or unexported fields
}
FeedbackService manages the feedback loop for promoting and validating memories
func NewFeedbackService ¶
func NewFeedbackService(store Store) *FeedbackService
NewFeedbackService creates a new feedback service
func (*FeedbackService) ConfirmSuggestion ¶
func (fs *FeedbackService) ConfirmSuggestion(ctx context.Context, req ConfirmRequest) error
ConfirmSuggestion records feedback on whether a suggestion worked
func (*FeedbackService) GetTopValidatedPatterns ¶
func (fs *FeedbackService) GetTopValidatedPatterns(ctx context.Context, userID string, limit int) ([]Memory, error)
GetTopValidatedPatterns returns the most validated patterns for a user or globally
func (*FeedbackService) PromoteMemory ¶
func (fs *FeedbackService) PromoteMemory(ctx context.Context, req PromoteRequest) error
PromoteMemory promotes a validated memory to a higher scope
func (*FeedbackService) ValidatePattern ¶
func (fs *FeedbackService) ValidatePattern(ctx context.Context, patternID string, userID string) (bool, float64, error)
ValidatePattern checks if a pattern has sufficient positive feedback
type Memory ¶
type Memory struct { ID string `json:"id"` Content string `json:"content"` Type string `json:"type"` Metadata map[string]interface{} `json:"metadata"` Timestamp time.Time `json:"timestamp"` Score float64 `json:"score"` UserID string `json:"user_id,omitempty"` // User who created this memory ProjectID string `json:"project_id,omitempty"` // Project scope SessionID string `json:"session_id,omitempty"` // Session scope }
Memory represents a stored piece of knowledge. This is a shared type.
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is an in-memory implementation of the Store interface for testing.
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
NewMemoryStore creates a new in-memory knowledge store.
func (*MemoryStore) BatchUpdateConfidence ¶
func (ms *MemoryStore) BatchUpdateConfidence(ctx context.Context, updates []ConfidenceUpdate) error
BatchUpdateConfidence updates confidence scores for multiple patterns in a single transaction
func (*MemoryStore) Close ¶
func (ms *MemoryStore) Close() error
Close implements the Store interface.
func (*MemoryStore) Count ¶
func (ms *MemoryStore) Count() int
Count returns the number of memories stored.
func (*MemoryStore) GetByID ¶
func (ms *MemoryStore) GetByID(id string) (*Memory, bool)
GetByID retrieves a memory by its ID.
func (*MemoryStore) GetPatternConfidence ¶
GetPatternConfidence retrieves the current confidence score for a pattern
func (*MemoryStore) GetPatternFeedbackCounts ¶
func (ms *MemoryStore) GetPatternFeedbackCounts(ctx context.Context, patternID string) (confirmed, failed int, err error)
GetPatternFeedbackCounts retrieves feedback statistics for a pattern
func (*MemoryStore) GetPatterns ¶
GetPatterns implements the Store interface.
func (*MemoryStore) GetPatternsForCalibration ¶
func (ms *MemoryStore) GetPatternsForCalibration(ctx context.Context, projectID string, batchSize int) ([]Memory, error)
GetPatternsForCalibration retrieves patterns that are eligible for calibration
func (*MemoryStore) GetProjectPatterns ¶
func (ms *MemoryStore) GetProjectPatterns(ctx context.Context, projectID, errorType string) ([]Memory, error)
GetProjectPatterns implements the Store interface for project-specific patterns.
func (*MemoryStore) GetStats ¶
func (ms *MemoryStore) GetStats(ctx context.Context, projectID string) (map[string]interface{}, error)
GetStats implements the Store interface for analytics
func (*MemoryStore) GetUserPatterns ¶
func (ms *MemoryStore) GetUserPatterns(ctx context.Context, userID, errorType string) ([]Memory, error)
GetUserPatterns implements the Store interface for user-specific patterns
func (*MemoryStore) GetUserStats ¶
func (ms *MemoryStore) GetUserStats(ctx context.Context, userID string) (map[string]interface{}, error)
GetUserStats implements the Store interface for user analytics
func (*MemoryStore) QueryUserMemories ¶
func (ms *MemoryStore) QueryUserMemories(ctx context.Context, userID, query string, limit int) ([]Memory, error)
QueryUserMemories implements the Store interface for user-specific queries
func (*MemoryStore) QueryWithScope ¶
func (ms *MemoryStore) QueryWithScope(ctx context.Context, query string, limit int, projectID, sessionID string) ([]Memory, error)
QueryWithScope implements the Store interface with project/session scope.
func (*MemoryStore) SimilaritySearch ¶
func (ms *MemoryStore) SimilaritySearch(ctx context.Context, text string, limit int) ([]Memory, error)
SimilaritySearch implements the Store interface for finding similar memories
func (*MemoryStore) Store ¶
func (ms *MemoryStore) Store(ctx context.Context, content string, memType string, metadata map[string]interface{}) (string, error)
Store implements the Store interface.
func (*MemoryStore) StoreForUser ¶
func (ms *MemoryStore) StoreForUser(ctx context.Context, userID, content string, memType string, metadata map[string]interface{}) (string, error)
StoreForUser implements the Store interface for user-specific memories
func (*MemoryStore) StoreWithScope ¶
func (ms *MemoryStore) StoreWithScope(ctx context.Context, content string, memType string, metadata map[string]interface{}, projectID, sessionID string) (string, error)
StoreWithScope implements the Store interface with project/session scope.
func (*MemoryStore) SuggestFix ¶
SuggestFix implements the Store interface.
func (*MemoryStore) SuggestFixForUser ¶
func (ms *MemoryStore) SuggestFixForUser(ctx context.Context, userID, errorMsg string) (string, error)
SuggestFixForUser implements the Store interface for user-specific fix suggestions
type Pattern ¶
type Pattern struct { ID string `json:"id"` ErrorType string `json:"error_type"` ErrorSignature string `json:"error_signature"` Solution string `json:"solution"` Confidence float64 `json:"confidence"` SuccessRate float64 `json:"success_rate"` Occurrences int `json:"occurrences"` }
Pattern represents an error-solution pattern (minimal definition for search)
type PromoteRequest ¶
type PromoteRequest struct { MemoryID string `json:"memory_id"` FromScope string `json:"from_scope"` // "session", "project", "user" ToScope string `json:"to_scope"` // "project", "user", "global" UserID string `json:"user_id,omitempty"` ProjectID string `json:"project_id,omitempty"` Confidence float64 `json:"confidence"` Feedback string `json:"feedback,omitempty"` Metadata map[string]interface{} `json:"metadata,omitempty"` }
PromoteRequest represents a request to promote a memory from one scope to another based on validation
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
RedisStore handles all knowledge and memory operations backed by Redis.
func NewRedisStore ¶
func NewRedisStore(redisAddr string) (*RedisStore, error)
NewRedisStore creates a new Redis-backed knowledge store.
func NewRedisStoreWithClient ¶
func NewRedisStoreWithClient(client *redis.Client) *RedisStore
NewRedisStoreWithClient creates a new Redis-backed knowledge store with an existing client. This is useful for testing or when you want to manage the client lifecycle externally.
func (*RedisStore) BatchUpdateConfidence ¶
func (rs *RedisStore) BatchUpdateConfidence(ctx context.Context, updates []ConfidenceUpdate) error
BatchUpdateConfidence updates confidence scores for multiple patterns in a single transaction
func (*RedisStore) Close ¶
func (rs *RedisStore) Close() error
Close implements the Store interface.
func (*RedisStore) GetPatternConfidence ¶
GetPatternConfidence retrieves the current confidence score for a pattern
func (*RedisStore) GetPatternFeedbackCounts ¶
func (rs *RedisStore) GetPatternFeedbackCounts(ctx context.Context, patternID string) (confirmed, failed int, err error)
GetPatternFeedbackCounts retrieves feedback statistics for a pattern
func (*RedisStore) GetPatterns ¶
GetPatterns implements the Store interface.
func (*RedisStore) GetPatternsForCalibration ¶
func (rs *RedisStore) GetPatternsForCalibration(ctx context.Context, projectID string, batchSize int) ([]Memory, error)
GetPatternsForCalibration retrieves patterns that are eligible for calibration
func (*RedisStore) GetProjectPatterns ¶
func (rs *RedisStore) GetProjectPatterns(ctx context.Context, projectID, errorType string) ([]Memory, error)
GetProjectPatterns implements the Store interface for project-specific patterns.
func (*RedisStore) GetStats ¶
func (rs *RedisStore) GetStats(ctx context.Context, projectID string) (map[string]interface{}, error)
GetStats implements the Store interface for analytics
func (*RedisStore) GetUserPatterns ¶
func (rs *RedisStore) GetUserPatterns(ctx context.Context, userID, errorType string) ([]Memory, error)
GetUserPatterns implements the Store interface for user-specific patterns
func (*RedisStore) GetUserStats ¶
func (rs *RedisStore) GetUserStats(ctx context.Context, userID string) (map[string]interface{}, error)
GetUserStats implements the Store interface for user analytics
func (*RedisStore) QueryUserMemories ¶
func (rs *RedisStore) QueryUserMemories(ctx context.Context, userID, query string, limit int) ([]Memory, error)
QueryUserMemories implements the Store interface for user-specific queries
func (*RedisStore) QueryWithScope ¶
func (rs *RedisStore) QueryWithScope(ctx context.Context, query string, limit int, projectID, sessionID string) ([]Memory, error)
QueryWithScope implements the Store interface with project/session scope.
func (*RedisStore) SimilaritySearch ¶
func (rs *RedisStore) SimilaritySearch(ctx context.Context, text string, limit int) ([]Memory, error)
SimilaritySearch implements the Store interface for finding similar memories
func (*RedisStore) Store ¶
func (rs *RedisStore) Store(ctx context.Context, content string, memType string, metadata map[string]interface{}) (string, error)
Store implements the Store interface.
func (*RedisStore) StoreForUser ¶
func (rs *RedisStore) StoreForUser(ctx context.Context, userID, content string, memType string, metadata map[string]interface{}) (string, error)
StoreForUser implements the Store interface for user-specific memories
func (*RedisStore) StoreWithScope ¶
func (rs *RedisStore) StoreWithScope(ctx context.Context, content string, memType string, metadata map[string]interface{}, projectID, sessionID string) (string, error)
StoreWithScope implements the Store interface with project/session scope.
func (*RedisStore) SuggestFix ¶
SuggestFix implements the Store interface.
func (*RedisStore) SuggestFixForUser ¶
func (rs *RedisStore) SuggestFixForUser(ctx context.Context, userID, errorMsg string) (string, error)
SuggestFixForUser implements the Store interface for user-specific fix suggestions
type SearchQuery ¶
type SearchQuery struct { Text string Type string UserID string // User-specific search ProjectID string SessionID string StartTime time.Time EndTime time.Time MinScore float64 Fuzzy bool Limit int Offset int SortBy string SortDesc bool }
SearchQuery defines parameters for searching memories
type SearchService ¶
type SearchService struct {
// contains filtered or unexported fields
}
SearchService provides advanced search capabilities using Redis Full-Text Search
func NewSearchService ¶
func NewSearchService(client *redis.Client) *SearchService
NewSearchService creates a new search service
func (*SearchService) AggregateStats ¶
func (ss *SearchService) AggregateStats(ctx context.Context, groupBy string, projectID string) (map[string]interface{}, error)
AggregateStats performs aggregation queries for analytics
func (*SearchService) InitializeIndexes ¶
func (ss *SearchService) InitializeIndexes(ctx context.Context) error
InitializeIndexes creates Redis search indexes for different memory types
func (*SearchService) SearchMemories ¶
func (ss *SearchService) SearchMemories(ctx context.Context, query SearchQuery) ([]Memory, error)
SearchMemories performs full-text search on memories with advanced features
func (*SearchService) SearchPatterns ¶
func (ss *SearchService) SearchPatterns(ctx context.Context, errorMsg string, minConfidence float64) ([]Pattern, error)
SearchPatterns searches for patterns with similarity matching
func (*SearchService) SimilaritySearch ¶
func (ss *SearchService) SimilaritySearch(ctx context.Context, text string, limit int) ([]Memory, error)
SimilaritySearch finds memories similar to a given text using vector-like scoring
type Store ¶
type Store interface { // Store saves a new memory and returns its unique ID. Store(ctx context.Context, content string, memType string, metadata map[string]interface{}) (string, error) // StoreWithScope saves a memory with project and session scope. StoreWithScope(ctx context.Context, content string, memType string, metadata map[string]interface{}, projectID, sessionID string) (string, error) // StoreForUser saves a memory associated with a specific user (long-term personalization) StoreForUser(ctx context.Context, userID, content string, memType string, metadata map[string]interface{}) (string, error) // Query searches for relevant memories based on a query string. Query(ctx context.Context, query string, limit int) ([]Memory, error) // QueryWithScope searches memories within a specific project/session scope. QueryWithScope(ctx context.Context, query string, limit int, projectID, sessionID string) ([]Memory, error) // QueryUserMemories searches memories for a specific user QueryUserMemories(ctx context.Context, userID, query string, limit int) ([]Memory, error) // GetPatterns retrieves memories of type "pattern". GetPatterns(ctx context.Context, errorType string) ([]Memory, error) // GetProjectPatterns retrieves patterns specific to a project. GetProjectPatterns(ctx context.Context, projectID, errorType string) ([]Memory, error) // GetUserPatterns retrieves patterns learned by a specific user GetUserPatterns(ctx context.Context, userID, errorType string) ([]Memory, error) // SuggestFix suggests a fix based on historical patterns. SuggestFix(ctx context.Context, errorMsg string) (string, error) // SuggestFixForUser suggests a fix based on user's personal patterns SuggestFixForUser(ctx context.Context, userID, errorMsg string) (string, error) // SimilaritySearch finds memories similar to the given text SimilaritySearch(ctx context.Context, text string, limit int) ([]Memory, error) // GetStats returns aggregated statistics about stored memories GetStats(ctx context.Context, projectID string) (map[string]interface{}, error) // GetUserStats returns statistics about a user's memories GetUserStats(ctx context.Context, userID string) (map[string]interface{}, error) // BatchUpdateConfidence updates confidence scores for multiple patterns in a single transaction BatchUpdateConfidence(ctx context.Context, updates []ConfidenceUpdate) error // GetPatternConfidence retrieves the current confidence score for a pattern GetPatternConfidence(ctx context.Context, patternID string) (float64, error) // GetPatternsForCalibration retrieves patterns that are eligible for calibration GetPatternsForCalibration(ctx context.Context, projectID string, batchSize int) ([]Memory, error) // GetPatternFeedbackCounts retrieves feedback statistics for a pattern GetPatternFeedbackCounts(ctx context.Context, patternID string) (confirmed, failed int, err error) // Close cleans up any resources used by the store. Close() error }
Store is the interface that defines the contract for knowledge and memory operations. Any storage backend (Redis, in-memory, etc.) must implement this interface.