models

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

ValidConflictStatuses lists all valid non-empty conflict statuses.

ValidEntityTypes is the set of all valid entity types.

ValidMemoryScopes is the set of all valid memory scopes.

ValidMemoryTypes is the set of all valid memory types.

Functions

This section is empty.

Types

type CapturedMemory

type CapturedMemory struct {
	Content    string     `json:"content"`
	Type       MemoryType `json:"type"`
	Confidence float64    `json:"confidence"`
	Tags       []string   `json:"tags"`
}

CapturedMemory is a memory extracted from a conversation by the LLM.

type CollectionStats

type CollectionStats struct {
	TotalMemories int64            `json:"total_memories"`
	ByType        map[string]int64 `json:"by_type"`
	ByScope       map[string]int64 `json:"by_scope"`

	// Health metrics
	OldestMemory       *time.Time       `json:"oldest_memory,omitempty"`
	NewestMemory       *time.Time       `json:"newest_memory,omitempty"`
	TopAccessed        []MemoryPreview  `json:"top_accessed,omitempty"`
	ReinforcementTiers map[string]int64 `json:"reinforcement_tiers,omitempty"`
	ActiveConflicts    int64            `json:"active_conflicts"`
	PendingTTLExpiry   int64            `json:"pending_ttl_expiry"`
	StorageEstimate    int64            `json:"storage_estimate_bytes"`
}

CollectionStats holds summary statistics about the memory collection.

type ConflictStatus added in v0.4.0

type ConflictStatus string

ConflictStatus represents the conflict resolution state of a memory.

const (
	ConflictStatusNone     ConflictStatus = ""
	ConflictStatusActive   ConflictStatus = "active"
	ConflictStatusResolved ConflictStatus = "resolved"
)

func (ConflictStatus) IsValid added in v0.4.0

func (cs ConflictStatus) IsValid() bool

IsValid returns true if cs is a recognized conflict status (including empty).

type Entity added in v0.4.0

type Entity struct {
	ID        string         `json:"id"`
	Name      string         `json:"name"`
	Type      EntityType     `json:"type"`
	Aliases   []string       `json:"aliases,omitempty"`
	MemoryIDs []string       `json:"memory_ids,omitempty"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	Metadata  map[string]any `json:"metadata,omitempty"`

	// Graph integration fields (v0.5.0)
	Project       string    `json:"project,omitempty"`
	Summary       string    `json:"summary,omitempty"`
	NameEmbedding []float32 `json:"name_embedding,omitempty"`
	CommunityID   string    `json:"community_id,omitempty"`
}

Entity represents a named entity that can be linked to memories.

type EntityType added in v0.4.0

type EntityType string

EntityType classifies the kind of entity.

const (
	EntityTypePerson   EntityType = "person"
	EntityTypeProject  EntityType = "project"
	EntityTypeSystem   EntityType = "system"
	EntityTypeDecision EntityType = "decision"
	EntityTypeConcept  EntityType = "concept"
)

func (EntityType) IsValid added in v0.4.0

func (et EntityType) IsValid() bool

IsValid returns true if the entity type is recognized.

type Episode added in v0.8.0

type Episode struct {
	UUID         string    `json:"uuid"`
	SessionID    string    `json:"session_id"`
	UserMsg      string    `json:"user_msg"`
	AssistantMsg string    `json:"assistant_msg"`
	CapturedAt   time.Time `json:"captured_at"`
	// MemoryIDs are the Memory UUIDs derived from this episode via blob extraction.
	MemoryIDs []string `json:"memory_ids,omitempty"`
	// FactIDs are the Fact IDs (RELATES_TO edge IDs) extracted from this episode.
	FactIDs []string `json:"fact_ids,omitempty"`
}

Episode captures the provenance of a conversation turn — which memories and facts were extracted from it. Inspired by Graphiti's episodic layer.

type Fact added in v0.6.0

type Fact struct {
	ID             string    `json:"id"`
	SourceEntityID string    `json:"source_entity_id"`
	TargetEntityID string    `json:"target_entity_id"`
	RelationType   string    `json:"relation_type"`
	Fact           string    `json:"fact"`
	FactEmbedding  []float32 `json:"fact_embedding,omitempty"`

	// Bi-temporal fields: system time vs world time
	CreatedAt time.Time  `json:"created_at"`
	ExpiredAt *time.Time `json:"expired_at,omitempty"`
	ValidAt   *time.Time `json:"valid_at,omitempty"`
	InvalidAt *time.Time `json:"invalid_at,omitempty"`

	// Provenance
	SourceMemoryIDs []string `json:"source_memory_ids,omitempty"`
	Episodes        []string `json:"episodes,omitempty"`
	Confidence      float64  `json:"confidence"`
}

Fact represents a relationship between two entities with bi-temporal validity. Inspired by Graphiti's EntityEdge — facts are first-class search units with their own embeddings, enabling semantic search over relationships.

type Memory

type Memory struct {
	ID         string           `json:"id"`
	Type       MemoryType       `json:"type"`
	Scope      MemoryScope      `json:"scope"`
	Visibility MemoryVisibility `json:"visibility"`
	Content    string           `json:"content"`
	Confidence float64          `json:"confidence"`
	Source     string           `json:"source"`
	Tags       []string         `json:"tags"`
	Project    string           `json:"project,omitempty"`
	// UserID is the owner of this memory. Empty string means unscoped (legacy/shared).
	UserID       string    `json:"user_id,omitempty" db:"user_id"`
	TTLSeconds   int64     `json:"ttl_seconds,omitempty"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
	LastAccessed time.Time `json:"last_accessed"`
	AccessCount  int64     `json:"access_count"`

	// ReinforcedAt is the last time this memory's confidence was boosted
	// because a similar memory was captured again.
	ReinforcedAt time.Time `json:"reinforced_at,omitempty"`

	// ReinforcedCount is how many times this memory has been reinforced.
	ReinforcedCount int `json:"reinforced_count,omitempty"`

	Metadata     map[string]any `json:"metadata,omitempty"`
	SupersedesID string         `json:"supersedes_id,omitempty"` // ID of memory this replaces
	ValidUntil   time.Time      `json:"valid_until,omitempty"`   // zero = never expires

	// ValidFrom is when this memory version became the current truth.
	// Set to CreatedAt on first write. Immutable after initial store.
	ValidFrom time.Time `json:"valid_from,omitempty"`

	// ValidTo is set when this memory is superseded by a newer version or contradicted.
	// Zero/nil = currently valid.
	ValidTo *time.Time `json:"valid_to,omitempty"`

	// IsCurrentVersion is derived (not stored): ValidTo == nil.
	// Used for display only.
	IsCurrentVersion bool `json:"is_current_version,omitempty"`

	// ConflictGroupID links memories that contradict each other.
	// All memories in a conflict group share the same non-empty UUID.
	ConflictGroupID string `json:"conflict_group_id,omitempty"`

	// ConflictStatus tracks resolution: "" (no conflict), "active" (unresolved), "resolved".
	ConflictStatus ConflictStatus `json:"conflict_status,omitempty"`
}

Memory is the core data structure for a stored memory.

type MemoryPreview added in v0.4.0

type MemoryPreview struct {
	ID          string `json:"id"`
	Content     string `json:"content"`
	AccessCount int64  `json:"access_count"`
}

MemoryPreview is a lightweight summary of a memory used in stats output.

type MemoryScope

type MemoryScope string

MemoryScope defines the persistence scope of a memory.

const (
	ScopePermanent MemoryScope = "permanent"
	ScopeProject   MemoryScope = "project"
	ScopeSession   MemoryScope = "session"
	ScopeTTL       MemoryScope = "ttl"
)

func (MemoryScope) IsValid added in v0.4.0

func (ms MemoryScope) IsValid() bool

IsValid returns true if the memory scope is recognized.

type MemoryType

type MemoryType string

MemoryType classifies the kind of memory.

const (
	MemoryTypeRule       MemoryType = "rule"
	MemoryTypeFact       MemoryType = "fact"
	MemoryTypeEpisode    MemoryType = "episode"
	MemoryTypeProcedure  MemoryType = "procedure"
	MemoryTypePreference MemoryType = "preference"
)

func (MemoryType) IsValid

func (mt MemoryType) IsValid() bool

IsValid returns true if the memory type is recognized.

type MemoryVisibility

type MemoryVisibility string

MemoryVisibility controls access to a memory.

const (
	VisibilityPrivate   MemoryVisibility = "private"
	VisibilityShared    MemoryVisibility = "shared"
	VisibilitySensitive MemoryVisibility = "sensitive"
)

type RecallResult

type RecallResult struct {
	Memory              Memory  `json:"memory"`
	SimilarityScore     float64 `json:"similarity_score"`
	RecencyScore        float64 `json:"recency_score"`
	FrequencyScore      float64 `json:"frequency_score"`
	TypeBoost           float64 `json:"type_boost"`
	ScopeBoost          float64 `json:"scope_boost"`
	ConfidenceScore     float64 `json:"confidence_score"`
	ReinforcementScore  float64 `json:"reinforcement_score"`
	TagAffinityScore    float64 `json:"tag_affinity_score"`
	SupersessionPenalty float64 `json:"supersession_penalty"`
	ConflictPenalty     float64 `json:"conflict_penalty"`
	FinalScore          float64 `json:"final_score"`
}

RecallResult wraps a Memory with multi-factor ranking details.

type SearchResult

type SearchResult struct {
	Memory Memory  `json:"memory"`
	Score  float64 `json:"score"`
}

SearchResult wraps a Memory with its similarity score.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL