feedback

package
v0.5.24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package feedback provides feedback collection and storage for routing decisions. It records routing outcomes to enable future learning and system improvement.

Index

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

func NewCollector(dbPath string, retentionDays int) (*Collector, error)

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

func (c *Collector) GetRecent(ctx context.Context, limit int) ([]*FeedbackRecord, error)

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

func (c *Collector) GetStats(ctx context.Context) (map[string]interface{}, error)

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

func (c *Collector) Initialize(ctx context.Context) error

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

func (c *Collector) IsEnabled() bool

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

func (c *Collector) SetStateBox(sb *util.StateBox)

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

func (*Collector) Shutdown

func (c *Collector) Shutdown(ctx context.Context) error

Shutdown closes the database connection.

Parameters:

  • ctx: Context for shutdown operations

Returns:

  • error: Any error encountered during shutdown

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL