Documentation
¶
Index ¶
- Constants
- Variables
- func EncodeRecord(record CognitiveRecord) (json.RawMessage, error)
- func ImportanceForRole(role string) float64
- func SearchableContent(content string) string
- type CognitiveMemory
- type CognitiveRecord
- type Entry
- type Namespace
- type RecallScore
- type RecallWeights
- type Repository
- type Scope
Constants ¶
const ( // ProvenanceKey is the metadata key used to record how a memory message // entered the repository. ProvenanceKey = "provenance" // ProvenanceRunTurn marks user/assistant turns written by the framework // during a normal run or stream completion. ProvenanceRunTurn = "run_turn" // ProvenanceToolLoop marks assistant tool-call turns and tool results // persisted by the framework tool loop. ProvenanceToolLoop = "tool_loop" // ProvenanceIntegrator marks messages seeded by an integrator before or // between framework runs (for example chat transcript hydration). ProvenanceIntegrator = "integrator" // ProvenanceChatHydrate marks messages seeded from a chat transcript // hydrate (the AF-014 contract). It is the suggested marker for hosts // backfilling session memory via tier.MessageRecord before a run. ProvenanceChatHydrate = "chat_hydrate" // ProvenanceUntracked marks messages with no provenance metadata. This // usually indicates data written before provenance tracking or by an // external writer that did not set metadata.provenance. ProvenanceUntracked = "untracked" )
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 {
TenantID string `json:"tenant_id,omitempty"`
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 assigns tenantID as a dedicated namespace dimension. Session and run identifiers remain unchanged, so tenant strings and user-configured namespace prefixes cannot collide.
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)
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package tier implements the tiered memory subsystem: tier-scoped record stores, a manager that remembers and recalls records across hot/warm/cold levels, and the policies that migrate records between them.
|
Package tier implements the tiered memory subsystem: tier-scoped record stores, a manager that remembers and recalls records across hot/warm/cold levels, and the policies that migrate records between them. |