Documentation
¶
Index ¶
- type Engine
- func (e *Engine) MetricsSnapshot() MetricsSnapshot
- func (e *Engine) Prune(ctx context.Context) error
- func (e *Engine) Retrieve(ctx context.Context, query string, limit int) ([]model.MemoryRecord, error)
- func (e *Engine) Store(ctx context.Context, sessionID, content string, metadata map[string]any) (model.MemoryRecord, error)
- func (e *Engine) WithEmbedder(embedder embed.Embedder) *Engine
- func (e *Engine) WithLogger(logger *log.Logger) *Engine
- func (e *Engine) WithSummarizer(s Summarizer) *Engine
- type HeuristicSummarizer
- type Metrics
- func (m *Metrics) IncClustersSummarized()
- func (m *Metrics) IncDeduplicated()
- func (m *Metrics) IncPruned(n int)
- func (m *Metrics) IncReembedded()
- func (m *Metrics) IncRetrieved(n int)
- func (m *Metrics) IncSizeEvicted(n int)
- func (m *Metrics) IncStored()
- func (m *Metrics) IncTTLExpired(n int)
- func (m *Metrics) ObserveRecency(decay float64)
- func (m *Metrics) Snapshot() MetricsSnapshot
- type MetricsSnapshot
- type Options
- type ScoreWeights
- type Summarizer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine coordinates scoring, clustering, pruning and retrieval of memories.
func NewEngine ¶
func NewEngine(store store.VectorStore, opts Options) *Engine
NewEngine constructs an advanced memory engine on top of a VectorStore implementation.
func (*Engine) MetricsSnapshot ¶
func (e *Engine) MetricsSnapshot() MetricsSnapshot
MetricsSnapshot returns a copy of the runtime counters.
func (*Engine) Prune ¶
Prune applies TTL, size and deduplication policies. Prune applies TTL, size and deduplication policies. Faster version: single Iterate pass for TTL+dedupe, no full sort, top-K heap for evictions.
func (*Engine) Retrieve ¶
func (e *Engine) Retrieve(ctx context.Context, query string, limit int) ([]model.MemoryRecord, error)
Retrieve performs weighted retrieval with MMR diversification and optional re-embedding.
func (*Engine) Store ¶
func (e *Engine) Store(ctx context.Context, sessionID, content string, metadata map[string]any) (model.MemoryRecord, error)
Store embeds, scores and persists a new memory.
func (*Engine) WithEmbedder ¶
WithEmbedder overrides the default embedder.
func (*Engine) WithLogger ¶
WithLogger overrides the default logger.
func (*Engine) WithSummarizer ¶
func (e *Engine) WithSummarizer(s Summarizer) *Engine
WithSummarizer overrides the default cluster summarizer.
type HeuristicSummarizer ¶
type HeuristicSummarizer struct{}
HeuristicSummarizer produces deterministic summaries suitable for tests.
func (HeuristicSummarizer) Summarize ¶
func (HeuristicSummarizer) Summarize(_ context.Context, cluster []model.MemoryRecord) (string, error)
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics captures lightweight runtime counters for observability.
func (*Metrics) IncClustersSummarized ¶
func (m *Metrics) IncClustersSummarized()
func (*Metrics) IncDeduplicated ¶
func (m *Metrics) IncDeduplicated()
func (*Metrics) IncReembedded ¶
func (m *Metrics) IncReembedded()
func (*Metrics) IncRetrieved ¶
func (*Metrics) IncSizeEvicted ¶
func (*Metrics) IncTTLExpired ¶
func (*Metrics) ObserveRecency ¶
func (*Metrics) Snapshot ¶
func (m *Metrics) Snapshot() MetricsSnapshot
type MetricsSnapshot ¶
type MetricsSnapshot struct {
Stored int64 `json:"stored"`
Retrieved int64 `json:"retrieved"`
Deduplicated int64 `json:"deduplicated"`
Reembedded int64 `json:"reembedded"`
Pruned int64 `json:"pruned"`
ClustersSummarized int64 `json:"clusters_summarized"`
TTLExpired int64 `json:"ttl_expired"`
SizeEvicted int64 `json:"size_evicted"`
RecencySamples int64 `json:"recency_samples"`
RecencyDecayAvg float64 `json:"recency_decay_avg"`
}
Snapshot returns the current values for reporting/logging.
type Options ¶
type Options struct {
Weights ScoreWeights
LambdaMMR float64
HalfLife time.Duration
ClusterSimilarity float64
DriftThreshold float64
DuplicateSimilarity float64
TTL time.Duration
MaxSize int
SourceBoost map[string]float64
Clock func() time.Time
EnableSummaries bool
GraphNeighborhoodHops int
GraphNeighborhoodLimit int
}
Options configures the advanced memory engine.
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions returns the recommended defaults for the advanced memory engine.
type ScoreWeights ¶
type ScoreWeights struct {
Similarity float64
Keywords float64
Importance float64
Recency float64
Source float64
}
ScoreWeights controls the contribution of each scoring component during retrieval.
type Summarizer ¶
type Summarizer interface {
Summarize(ctx context.Context, cluster []model.MemoryRecord) (string, error)
}
Summarizer abstracts cluster summarization backends (LLMs or heuristics).