Documentation
¶
Index ¶
- func RecordTierDepth(ctx context.Context, store Store, recorder observability.Recorder, ...)
- func WithMigrationRunID(ctx context.Context, runID string) context.Context
- type ChainedMigrationObserver
- func (o ChainedMigrationObserver) Demoted(ctx context.Context, ns memory.Namespace, recordID string, from, to Level)
- func (o ChainedMigrationObserver) Evicted(ctx context.Context, ns memory.Namespace, recordID string, from Level)
- func (o ChainedMigrationObserver) Promoted(ctx context.Context, ns memory.Namespace, recordID string, from, to Level)
- type CognitiveAdapter
- type ColdSummaryBackend
- type ColdSummaryIndexer
- type ColdSummarySettings
- type CompositeStore
- func (c *CompositeStore) Count(ctx context.Context, ns memory.Namespace, level Level) (int, error)
- func (c *CompositeStore) Delete(ctx context.Context, ns memory.Namespace, id string) error
- func (c *CompositeStore) Get(ctx context.Context, ns memory.Namespace, id string) (Record, error)
- func (c *CompositeStore) List(ctx context.Context, ns memory.Namespace, level Level, limit int) ([]Record, error)
- func (c *CompositeStore) Put(ctx context.Context, ns memory.Namespace, record Record) error
- type ContentSummarizer
- type EventSinkMigrationObserver
- func (o EventSinkMigrationObserver) Demoted(ctx context.Context, ns memory.Namespace, recordID string, from, to Level)
- func (o EventSinkMigrationObserver) Evicted(ctx context.Context, ns memory.Namespace, recordID string, from Level)
- func (o EventSinkMigrationObserver) Promoted(ctx context.Context, ns memory.Namespace, recordID string, from, to Level)
- type Level
- type Manager
- type MetricsObserver
- func (o MetricsObserver) Demoted(ctx context.Context, ns memory.Namespace, recordID string, from, to Level)
- func (o MetricsObserver) Evicted(ctx context.Context, ns memory.Namespace, recordID string, from Level)
- func (o MetricsObserver) Promoted(ctx context.Context, ns memory.Namespace, recordID string, from, to Level)
- type MigrationObserver
- type MigrationReport
- type NoopColdSummaryBackend
- type NoopMigrationObserver
- type Policy
- type RecallBudget
- type RecallWeights
- type Record
- type Settings
- type Store
- type TruncateColdSummaryBackend
- func (b TruncateColdSummaryBackend) Archive(ctx context.Context, ns memory.Namespace, record *Record) error
- func (b TruncateColdSummaryBackend) Delete(ctx context.Context, ns memory.Namespace, recordID string) error
- func (b TruncateColdSummaryBackend) SearchRecordIDs(ctx context.Context, ns memory.Namespace, query string, limit int) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RecordTierDepth ¶
func RecordTierDepth(ctx context.Context, store Store, recorder observability.Recorder, scenario string, ns memory.Namespace)
RecordTierDepth publishes per-level record counts for a namespace.
Types ¶
type ChainedMigrationObserver ¶ added in v0.2.0
type ChainedMigrationObserver struct {
Observers []MigrationObserver
}
ChainedMigrationObserver fans out migration notifications to multiple observers.
type CognitiveAdapter ¶
type CognitiveAdapter struct {
Manager Manager
Weights RecallWeights
Budget func(limit int) RecallBudget
}
CognitiveAdapter implements memory.CognitiveMemory using a tier Manager.
func NewCognitiveAdapter ¶
func NewCognitiveAdapter(manager Manager, weights RecallWeights) *CognitiveAdapter
NewCognitiveAdapter wraps a tier Manager as a CognitiveMemory port.
func (*CognitiveAdapter) Recall ¶
func (a *CognitiveAdapter) Recall(ctx context.Context, ns memory.Namespace, query string, limit int) ([]memory.CognitiveRecord, error)
func (*CognitiveAdapter) Remember ¶
func (a *CognitiveAdapter) Remember(ctx context.Context, ns memory.Namespace, record memory.CognitiveRecord) error
type ColdSummaryBackend ¶ added in v0.2.0
type ColdSummaryBackend interface {
Archive(ctx context.Context, ns memory.Namespace, record *Record) error
SearchRecordIDs(ctx context.Context, ns memory.Namespace, query string, limit int) ([]string, error)
Delete(ctx context.Context, ns memory.Namespace, recordID string) error
}
ColdSummaryBackend archives cold records and optionally indexes summaries for semantic recall.
type ColdSummaryIndexer ¶ added in v0.2.0
type ColdSummaryIndexer interface {
UpsertSummary(ctx context.Context, ns memory.Namespace, record Record, summary string) error
SearchSummaries(ctx context.Context, ns memory.Namespace, query string, limit int) ([]string, error)
DeleteSummary(ctx context.Context, ns memory.Namespace, recordID string) error
}
ColdSummaryIndexer stores and searches cold summaries in a vector index.
type ColdSummarySettings ¶ added in v0.2.0
type ColdSummarySettings struct {
Enabled bool `json:"enabled,omitempty" yaml:"enabled"`
MinBytes int64 `json:"min_bytes,omitempty" yaml:"min_bytes"`
MaxSummaryChars int `json:"max_summary_chars,omitempty" yaml:"max_summary_chars"`
SummaryProfile string `json:"summary_profile,omitempty" yaml:"summary_profile"`
}
ColdSummarySettings configures cold-tier summarization before archive.
type CompositeStore ¶
CompositeStore routes tier records across hot, warm, and cold backends.
type ContentSummarizer ¶ added in v0.2.0
type ContentSummarizer interface {
Summarize(ctx context.Context, content string, maxChars int) (string, error)
}
ContentSummarizer compresses large record content before cold archive.
type EventSinkMigrationObserver ¶ added in v0.2.0
EventSinkMigrationObserver emits tier migration events to a core.EventSink.
type Manager ¶
type Manager interface {
Remember(ctx context.Context, ns memory.Namespace, record Record) error
Recall(ctx context.Context, ns memory.Namespace, query string, budget RecallBudget) ([]Record, error)
Reconcile(ctx context.Context, ns memory.Namespace, now time.Time) (MigrationReport, error)
}
Manager orchestrates tiered remember, recall, and reconciliation.
func NewDualWriteManager ¶
func NewDualWriteManager(inner Manager, index memory.CognitiveMemory) Manager
NewDualWriteManager remembers tier records and mirrors searchable cognitive entries.
func NewManager ¶
func NewManager(store Store, policy Policy, observer MigrationObserver) Manager
NewManager constructs a tier Manager backed by store and policy.
func NewManagerWithWeights ¶
func NewManagerWithWeights(store Store, policy Policy, observer MigrationObserver, weights memory.RecallWeights, coldSummary ColdSummaryBackend) Manager
NewManagerWithWeights constructs a tier Manager with custom RankMemories weights.
type MetricsObserver ¶
type MetricsObserver struct {
Recorder observability.Recorder
Scenario string
}
MetricsObserver records tier migration and depth metrics.
type MigrationObserver ¶
type MigrationObserver interface {
Promoted(ctx context.Context, ns memory.Namespace, recordID string, from, to Level)
Demoted(ctx context.Context, ns memory.Namespace, recordID string, from, to Level)
Evicted(ctx context.Context, ns memory.Namespace, recordID string, from Level)
}
MigrationObserver receives tier migration notifications from a Manager.
func ChainMigrationObservers ¶ added in v0.2.0
func ChainMigrationObservers(observers ...MigrationObserver) MigrationObserver
type MigrationReport ¶
type MigrationReport struct {
Promoted int `json:"promoted"`
Demoted int `json:"demoted"`
Evicted int `json:"evicted"`
}
MigrationReport summarizes tier migrations from a reconcile pass.
type NoopColdSummaryBackend ¶ added in v0.2.0
type NoopColdSummaryBackend struct{}
NoopColdSummaryBackend disables cold summary behavior.
type NoopMigrationObserver ¶
type NoopMigrationObserver struct{}
NoopMigrationObserver discards migration notifications.
type Policy ¶
type Policy struct {
HotCapacity int
WarmCapacity int
ColdCapacity int
HotTTL time.Duration
WarmTTL time.Duration
PromoteAccess int
DemoteIdle time.Duration
}
Policy configures automatic promotion, demotion, and eviction between tiers.
func DefaultPolicy ¶
func DefaultPolicy() Policy
DefaultPolicy returns baseline hot/warm/cold promotion and demotion rules.
func (Policy) NextTierOnDemote ¶
NextTierOnDemote returns the colder tier, or empty if eviction is required.
func (Policy) ShouldDemote ¶
ShouldDemote reports whether a record should move to a colder tier.
func (Policy) ShouldPromote ¶
ShouldPromote reports whether a record should move to a hotter tier after access.
type RecallBudget ¶
type RecallBudget struct {
Total int `json:"total"`
Hot int `json:"hot"`
Warm int `json:"warm"`
Cold int `json:"cold"`
}
RecallBudget limits how many records to pull from each tier during recall.
func (RecallBudget) Normalize ¶
func (b RecallBudget) Normalize() RecallBudget
Normalize fills zero values with sensible defaults and caps per-tier limits by Total.
type RecallWeights ¶
type RecallWeights struct {
Semantic float64 `json:"semantic,omitempty" yaml:"semantic"`
Recency float64 `json:"recency,omitempty" yaml:"recency"`
Importance float64 `json:"importance,omitempty" yaml:"importance"`
}
RecallWeights configures RankMemories weighting during tier recall.
type Record ¶
type Record struct {
memory.CognitiveRecord
Tier Level `json:"tier"`
AccessCount int `json:"access_count"`
LastAccessAt time.Time `json:"last_access_at"`
PromotedAt time.Time `json:"promoted_at"`
SizeBytes int64 `json:"size_bytes,omitempty"`
Pinned bool `json:"pinned,omitempty"`
}
Record extends a cognitive memory entry with tier lifecycle metadata.
type Settings ¶
type Settings struct {
Enabled bool `json:"enabled,omitempty" yaml:"enabled"`
HotCapacity int `json:"hot_capacity,omitempty" yaml:"hot_capacity"`
WarmCapacity int `json:"warm_capacity,omitempty" yaml:"warm_capacity"`
ColdCapacity int `json:"cold_capacity,omitempty" yaml:"cold_capacity"`
HotTTL time.Duration `json:"hot_ttl,omitempty" yaml:"hot_ttl"`
WarmTTL time.Duration `json:"warm_ttl,omitempty" yaml:"warm_ttl"`
PromoteAccess int `json:"promote_access,omitempty" yaml:"promote_access"`
DemoteIdle time.Duration `json:"demote_idle,omitempty" yaml:"demote_idle"`
RecallBudget RecallBudget `json:"recall_budget,omitempty" yaml:"recall_budget"`
RecallWeights RecallWeights `json:"recall_weights,omitempty" yaml:"recall_weights"`
ColdSummary ColdSummarySettings `json:"cold_summary,omitempty" yaml:"cold_summary"`
}
Settings configures tiered memory for a scenario memory reference.
func SettingsFromCore ¶
func SettingsFromCore(ref *core.MemoryTierSettings) (Settings, bool)
SettingsFromCore converts a scenario memory tier reference into tier settings.
func (Settings) Budget ¶
func (s Settings) Budget() RecallBudget
Budget returns the normalized recall budget for tier recall.
func (Settings) Policy ¶
Policy returns the effective tier policy from settings, overlaying defaults.
func (Settings) Weights ¶
func (s Settings) Weights() memory.RecallWeights
Weights returns normalized RankMemories weights.
type Store ¶
type Store interface {
Put(ctx context.Context, ns memory.Namespace, record Record) error
Get(ctx context.Context, ns memory.Namespace, id string) (Record, error)
List(ctx context.Context, ns memory.Namespace, level Level, limit int) ([]Record, error)
Delete(ctx context.Context, ns memory.Namespace, id string) error
Count(ctx context.Context, ns memory.Namespace, level Level) (int, error)
}
Store persists tier-scoped memory records.
type TruncateColdSummaryBackend ¶ added in v0.2.0
type TruncateColdSummaryBackend struct {
Settings ColdSummarySettings
Vector ColdSummaryIndexer
Summarizer ContentSummarizer
}
TruncateColdSummaryBackend summarizes large records with a deterministic truncate fallback.