Documentation
¶
Overview ¶
Package feedback provides feedback collection and storage for routing decisions. It records routing outcomes to enable future learning and system improvement.
Index ¶
- type Collector
- func (c *Collector) GetRecent(ctx context.Context, limit int) ([]*FeedbackRecord, error)
- func (c *Collector) GetStats(ctx context.Context) (map[string]interface{}, error)
- func (c *Collector) Initialize(ctx context.Context) error
- func (c *Collector) IsEnabled() bool
- func (c *Collector) Record(ctx context.Context, record *FeedbackRecord) error
- func (c *Collector) SetStateBox(sb *util.StateBox)
- func (c *Collector) Shutdown(ctx context.Context) error
- type FeedbackRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector manages feedback collection and storage.
func NewCollector ¶
NewCollector creates a new feedback collector instance.
Parameters:
- dbPath: Path to the SQLite database file (can be relative or absolute)
- retentionDays: Number of days to retain feedback records
Returns:
- *Collector: A new collector instance
- error: Any error encountered during creation
Note: If a StateBox is set via SetStateBox(), the dbPath will be resolved relative to the StateBox intelligence directory.
func (*Collector) GetRecent ¶
GetRecent retrieves the most recent feedback records.
Parameters:
- ctx: Context for the operation
- limit: Maximum number of records to retrieve
Returns:
- []*FeedbackRecord: The retrieved records
- error: Any error encountered during retrieval
func (*Collector) GetStats ¶
GetStats returns aggregated statistics about feedback records.
Parameters:
- ctx: Context for the operation
Returns:
- map[string]interface{}: Statistics including counts, success rates, etc.
- error: Any error encountered during retrieval
func (*Collector) Initialize ¶
Initialize sets up the database and creates necessary tables. If a StateBox is configured, the database path is resolved relative to the StateBox intelligence directory. In read-only mode, the database is opened with SQLITE_OPEN_READONLY flag.
Parameters:
- ctx: Context for initialization operations
Returns:
- error: Any error encountered during initialization
func (*Collector) IsEnabled ¶
IsEnabled returns whether the collector is active.
Returns:
- bool: true if the collector is enabled
func (*Collector) Record ¶
func (c *Collector) Record(ctx context.Context, record *FeedbackRecord) error
Record stores a feedback record in the database. In read-only mode, this method returns an error without attempting to insert.
Parameters:
- ctx: Context for the operation
- record: The feedback record to store
Returns:
- error: Any error encountered during storage, including ErrReadOnlyMode
func (*Collector) SetStateBox ¶
SetStateBox configures the State Box for the feedback collector. This should be called before Initialize() to ensure the database path is resolved correctly within the State Box directory structure.
Parameters:
- sb: The StateBox instance to use for path resolution
type FeedbackRecord ¶
type FeedbackRecord struct {
ID int64 `json:"id"`
Timestamp time.Time `json:"timestamp"`
Query string `json:"query"`
Intent string `json:"intent"`
SelectedModel string `json:"selected_model"`
RoutingTier string `json:"routing_tier"` // reflex, semantic, cognitive
Confidence float64 `json:"confidence"`
MatchedSkill string `json:"matched_skill,omitempty"`
CascadeOccurred bool `json:"cascade_occurred"`
ResponseQuality float64 `json:"response_quality,omitempty"`
LatencyMs int64 `json:"latency_ms"`
Success bool `json:"success"`
ErrorMessage string `json:"error_message,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
FeedbackRecord represents a single routing feedback entry.