importance

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDecayHalfLife = 30 * 24 * time.Hour // 30 days

Variables

This section is empty.

Functions

func DefaultDecayCurve

func DefaultDecayCurve(createdAt time.Time, now time.Time) float64

func MemoryEntryRelevance

func MemoryEntryRelevance(entry Entry, query string) float64

Types

type Entry

type Entry struct {
	ID         string            `json:"id"`
	Content    string            `json:"content"`
	Tags       []string          `json:"tags"`
	Importance float64           `json:"importance"`
	SessionID  string            `json:"session_id,omitempty"`
	CreatedAt  time.Time         `json:"created_at"`
	UpdatedAt  time.Time         `json:"updated_at"`
	Metadata   map[string]string `json:"metadata,omitempty"`
}

Entry is the scoring input shape for agent-managed memory.

type RetentionAction

type RetentionAction string
const (
	RetentionActionSummarize RetentionAction = "summarize"
	RetentionActionForget    RetentionAction = "forget"
)

type RetentionCandidate

type RetentionCandidate struct {
	Entry               Entry
	Age                 time.Duration
	EffectiveImportance float64
	Action              RetentionAction
	Reason              string
}

type RetentionPolicy

type RetentionPolicy struct {
	Now                    time.Time
	MinAge                 time.Duration
	MinEffectiveImportance float64
	Limit                  int
}

type ScoredEntry

type ScoredEntry struct {
	Entry               Entry
	Relevance           float64
	Recency             float64
	EffectiveImportance float64
	Score               float64
}

type Scorer

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

func NewScorer

func NewScorer() *Scorer

func (*Scorer) EffectiveImportance

func (s *Scorer) EffectiveImportance(entry Entry, now time.Time) float64

func (*Scorer) Rank

func (s *Scorer) Rank(entries []Entry, relevanceByID map[string]float64, now time.Time) []ScoredEntry

func (*Scorer) RankByQuery

func (s *Scorer) RankByQuery(entries []Entry, query string, now time.Time) []ScoredEntry

func (*Scorer) ReviewRetentionCandidates

func (s *Scorer) ReviewRetentionCandidates(entries []Entry, policy RetentionPolicy) []RetentionCandidate

func (*Scorer) Score

func (s *Scorer) Score(entry Entry, relevanceScore float64, now time.Time) float64

Jump to

Keyboard shortcuts

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