Documentation
¶
Index ¶
- func RecordTierDepth(ctx context.Context, store Store, recorder observability.Recorder, ...)
- type CognitiveAdapter
- 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 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 NoopMigrationObserver
- type Policy
- type RecallBudget
- type RecallWeights
- type Record
- type Settings
- type Store
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 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 CompositeStore ¶
CompositeStore routes tier records across hot, warm, and cold backends.
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) 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.
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 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"`
}
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.