review

package
v0.4.21 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackgroundReview

type BackgroundReview struct {
	// contains filtered or unexported fields
}

BackgroundReview handles the third system from Cortex Agent: "Background Review - an independent daemon that runs asynchronously, specifically designed to summarize experiences without interrupting the user conversation."

func NewBackgroundReview

func NewBackgroundReview(baseDir string) *BackgroundReview

NewBackgroundReview creates a new background review manager

func (*BackgroundReview) GetRecentReviews

func (br *BackgroundReview) GetRecentReviews(limit int) []ReviewEntry

GetRecentReviews returns recent review entries

func (*BackgroundReview) Start

func (br *BackgroundReview) Start() error

Start initializes the background review system

func (*BackgroundReview) TriggerNudgeReview

func (br *BackgroundReview) TriggerNudgeReview(turnCount int, toolCalls []string)

TriggerNudgeReview triggers a review on nudge (every N turns) This runs asynchronously and does NOT block

func (*BackgroundReview) TriggerTaskCompletionReview

func (br *BackgroundReview) TriggerTaskCompletionReview(task string, toolSequence []string)

TriggerTaskCompletionReview triggers a review when a task completes

type DetectedPattern

type DetectedPattern struct {
	ID           string        `json:"id"`
	Name         string        `json:"name"`
	ToolSequence []string      `json:"tool_sequence"`
	Frequency    int           `json:"frequency"`
	FirstSeen    time.Time     `json:"first_seen"`
	LastSeen     time.Time     `json:"last_seen"`
	SuccessRate  float64       `json:"success_rate"`
	AvgDuration  time.Duration `json:"avg_duration"`
	Contexts     []string      `json:"contexts"`
	Score        float64       `json:"score"` // Computed importance score
}

DetectedPattern is an enhanced pattern with richer metadata

type EnhancedBackgroundReview

type EnhancedBackgroundReview struct {
	// contains filtered or unexported fields
}

EnhancedBackgroundReview is System 3 of Cortex Agent: "Background Review - an independent daemon that runs asynchronously, specifically designed to summarize experiences without interrupting the user conversation."

func NewEnhancedBackgroundReview

func NewEnhancedBackgroundReview(baseDir string) *EnhancedBackgroundReview

NewEnhancedBackgroundReview creates an enhanced background review manager

func NewEnhancedBackgroundReviewWithConfig added in v0.4.16

func NewEnhancedBackgroundReviewWithConfig(baseDir string, config *ReviewConfig) *EnhancedBackgroundReview

NewEnhancedBackgroundReviewWithConfig creates an enhanced background review manager with custom config

func (*EnhancedBackgroundReview) AddCustomMetric

func (br *EnhancedBackgroundReview) AddCustomMetric(key string, value interface{})

AddCustomMetric allows adding custom metrics to review

func (*EnhancedBackgroundReview) ExportReviewReport

func (br *EnhancedBackgroundReview) ExportReviewReport(format string) (string, error)

ExportReviewReport generates a comprehensive review report

func (*EnhancedBackgroundReview) GetErrorPatterns

func (br *EnhancedBackgroundReview) GetErrorPatterns() []ErrorPattern

GetErrorPatterns returns detected error patterns

func (*EnhancedBackgroundReview) GetRecentReviews

func (br *EnhancedBackgroundReview) GetRecentReviews(limit int) []ReviewEntry

GetRecentReviews returns recent review entries

func (*EnhancedBackgroundReview) GetStats

func (br *EnhancedBackgroundReview) GetStats() *ReviewStats

GetStats returns current review statistics

func (*EnhancedBackgroundReview) GetTopPatterns

func (br *EnhancedBackgroundReview) GetTopPatterns(limit int) []DetectedPattern

GetTopPatterns returns the most significant patterns

func (*EnhancedBackgroundReview) IsReviewing

func (br *EnhancedBackgroundReview) IsReviewing() bool

IsReviewing returns whether a review is currently in progress

func (*EnhancedBackgroundReview) Reset

func (br *EnhancedBackgroundReview) Reset()

Reset clears all review data

func (*EnhancedBackgroundReview) SetConfig

func (br *EnhancedBackgroundReview) SetConfig(config *ReviewConfig)

SetConfig updates review configuration

func (*EnhancedBackgroundReview) Start

func (br *EnhancedBackgroundReview) Start() error

Start initializes the background review system

func (*EnhancedBackgroundReview) Stop

func (br *EnhancedBackgroundReview) Stop()

Stop gracefully stops the review system

func (*EnhancedBackgroundReview) TriggerNudgeReview

func (br *EnhancedBackgroundReview) TriggerNudgeReview(turnCount int, toolCalls []string, metrics *PerformanceMetrics)

TriggerNudgeReview triggers a review on nudge (every N turns) This runs asynchronously and does NOT block

func (*EnhancedBackgroundReview) TriggerPeriodicReview

func (br *EnhancedBackgroundReview) TriggerPeriodicReview()

TriggerPeriodicReview triggers a scheduled periodic review

func (*EnhancedBackgroundReview) TriggerTaskCompletionReview

func (br *EnhancedBackgroundReview) TriggerTaskCompletionReview(task string, toolSequence []string, success bool)

TriggerTaskCompletionReview triggers a review when a task completes

type ErrorPattern

type ErrorPattern struct {
	ErrorType    string    `json:"error_type"`
	ToolSequence []string  `json:"tool_sequence"`
	Frequency    int       `json:"frequency"`
	LastSeen     time.Time `json:"last_seen"`
	Suggestions  []string  `json:"suggestions"`
}

ErrorPattern represents a recurring error pattern

type PatternRanking

type PatternRanking struct {
	Pattern   string `json:"pattern"`
	Frequency int    `json:"frequency"`
}

PatternRanking represents a pattern with its frequency

type PerformanceMetrics

type PerformanceMetrics struct {
	PerceptionLatency time.Duration `json:"perception_latency_ms"`
	PlanningLatency   time.Duration `json:"planning_latency_ms"`
	ExecutionLatency  time.Duration `json:"execution_latency_ms"`
	MemoryRetrievalMs float64       `json:"memory_retrieval_ms"`
	TotalToolsUsed    int           `json:"total_tools_used"`
	UniqueToolsUsed   int           `json:"unique_tools_used"`
	SuccessRate       float64       `json:"success_rate"`
}

PerformanceMetrics captures detailed performance data

type ReviewConfig

type ReviewConfig struct {
	ReviewInterval   time.Duration
	MinPatternFreq   int
	MaxPatterns      int
	AutoSaveEnabled  bool
	SnapshotInterval int
}

ReviewConfig holds configuration for the review system

type ReviewEntry

type ReviewEntry struct {
	ID                 string              `json:"id"`
	Timestamp          time.Time           `json:"timestamp"`
	TurnCount          int                 `json:"turn_count"`
	Summary            string              `json:"summary"`
	Patterns           []DetectedPattern   `json:"patterns"`
	SkillsSuggested    []string            `json:"skills_suggested"`
	Duration           time.Duration       `json:"duration"`
	ErrorSummary       string              `json:"error_summary,omitempty"`
	PerformanceMetrics *PerformanceMetrics `json:"performance_metrics,omitempty"`
}

ReviewEntry represents a single review session (enhanced)

type ReviewStats

type ReviewStats struct {
	TotalReviews         int
	TotalPatterns        int
	TotalSkillsSuggested int
	AvgReviewDuration    time.Duration
	LastReviewTime       time.Time
	TopPatterns          []PatternRanking
}

ReviewStats holds aggregated statistics

type SessionSnapshot

type SessionSnapshot struct {
	Timestamp time.Time
	TurnCount int
	ToolCount int
	Errors    int
	Duration  time.Duration
}

SessionSnapshot captures a point in time for session analysis

Jump to

Keyboard shortcuts

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