Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("memory: not found")
Functions ¶
func EncodeRecord ¶ added in v0.1.5
func EncodeRecord(record CognitiveRecord) (json.RawMessage, error)
EncodeRecord serializes a cognitive record for repository storage.
func ImportanceForRole ¶ added in v0.1.9
ImportanceForRole returns a default cognitive importance score for a message role.
func SearchableContent ¶ added in v0.1.9
SearchableContent returns plain text suitable for cognitive recall indexing. When content is JSON (tier message envelope), callers should pass decoded message text.
Types ¶
type CognitiveMemory ¶ added in v0.1.5
type CognitiveMemory interface {
Remember(ctx context.Context, ns Namespace, record CognitiveRecord) error
Recall(ctx context.Context, ns Namespace, query string, limit int) ([]CognitiveRecord, error)
}
CognitiveMemory stores and recalls scored memories for agents.
type CognitiveRecord ¶ added in v0.1.5
type CognitiveRecord struct {
ID string `json:"id"`
Content string `json:"content"`
Scope string `json:"scope"`
Categories []string `json:"categories,omitempty"`
Importance float64 `json:"importance"`
CreatedAt time.Time `json:"created_at"`
Metadata map[string]string `json:"metadata,omitempty"`
}
CognitiveRecord is a scored long-term memory entry.
func DecodeRecord ¶ added in v0.1.5
func DecodeRecord(raw json.RawMessage) (CognitiveRecord, error)
DecodeRecord deserializes a cognitive record from repository storage.
type Entry ¶
type Entry struct {
Key string `json:"key"`
Value json.RawMessage `json:"value"`
}
type Namespace ¶
type Namespace struct {
RunID string `json:"run_id,omitempty"`
SessionID string `json:"session_id,omitempty"`
Agent string `json:"agent,omitempty"`
Scope Scope `json:"scope"`
}
func TenantScopedNamespace ¶ added in v0.1.9
TenantScopedNamespace prefixes namespace identifiers with tenantID when present.
type RecallScore ¶ added in v0.1.5
type RecallScore struct {
Record CognitiveRecord
Score float64
}
RecallScore ranks a memory for composite recall scoring.
func RankMemories ¶ added in v0.1.5
func RankMemories(query string, records []CognitiveRecord, now time.Time, semanticWeight, recencyWeight, importanceWeight float64) []RecallScore
RankMemories applies semantic overlap, recency, and importance weighting.
type RecallWeights ¶ added in v0.1.9
type RecallWeights struct {
Semantic float64 `json:"semantic,omitempty"`
Recency float64 `json:"recency,omitempty"`
Importance float64 `json:"importance,omitempty"`
}
RecallWeights configures semantic, recency, and importance weighting for RankMemories.
func DefaultRecallWeights ¶ added in v0.1.9
func DefaultRecallWeights() RecallWeights
DefaultRecallWeights returns the default RankMemories weighting.
func (RecallWeights) Normalize ¶ added in v0.1.9
func (w RecallWeights) Normalize() RecallWeights
Normalize fills zero values with defaults.
type Repository ¶
type Repository interface {
Get(ctx context.Context, ns Namespace, key string) (json.RawMessage, error)
Set(ctx context.Context, ns Namespace, key string, value json.RawMessage) error
Append(ctx context.Context, ns Namespace, key string, value json.RawMessage) error
Delete(ctx context.Context, ns Namespace, key string) error
// List returns all entries whose keys begin with prefix within the
// namespace. An empty prefix matches all keys in the namespace.
List(ctx context.Context, ns Namespace, prefix string) ([]Entry, error)
}