memory

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddContract

func AddContract() error

AddContract adds the MANDATORY TINYMEM CONTROL PROTOCOL to agent markdown and JSON settings files

Types

type Evidence

type Evidence struct {
	ID        int64     `json:"id"`
	MemoryID  int64     `json:"memory_id"`
	Type      string    `json:"type"`
	Content   string    `json:"content"`
	Verified  bool      `json:"verified"`
	CreatedAt time.Time `json:"created_at"`
}

Evidence represents evidence for a memory

type EvidenceInput

type EvidenceInput struct {
	Type    string `json:"type"`
	Content string `json:"content"`
}

EvidenceInput represents evidence input for creating a fact.

type Memory

type Memory struct {
	ID             int64      `json:"id"`
	ProjectID      string     `json:"project_id"`
	Type           Type       `json:"type"`
	Summary        string     `json:"summary"`
	Detail         string     `json:"detail"`
	Key            *string    `json:"key,omitempty"`
	Source         *string    `json:"source,omitempty"`
	RecallTier     RecallTier `json:"recall_tier"`
	TruthState     TruthState `json:"truth_state"`
	Classification *string    `json:"classification,omitempty"` // Optional classification for better recall precision
	CreatedAt      time.Time  `json:"created_at"`
	UpdatedAt      time.Time  `json:"updated_at"`
	SupersededBy   *int64     `json:"superseded_by,omitempty"`
}

Memory represents a memory entry

type RecallTier

type RecallTier string

RecallTier represents the recall tier of a memory

const (
	Always        RecallTier = "always"
	Contextual    RecallTier = "contextual"
	Opportunistic RecallTier = "opportunistic"
)

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service handles memory operations

func NewService

func NewService(db *storage.DB) *Service

NewService creates a new memory service

func (*Service) CreateFactWithEvidence

func (s *Service) CreateFactWithEvidence(mem *Memory, evidences []EvidenceInput, verify func(string, string) (bool, error)) error

CreateFactWithEvidence creates a fact only when evidence is verified.

func (*Service) CreateMemory

func (s *Service) CreateMemory(memory *Memory) error

CreateMemory creates a new memory entry

func (*Service) GetAllMemories

func (s *Service) GetAllMemories(projectID string) ([]*Memory, error)

GetAllMemories retrieves all memories for a project

func (*Service) GetMemory

func (s *Service) GetMemory(id int64, projectID string) (*Memory, error)

GetMemory retrieves a memory by ID

func (*Service) MarkAsSuperseded

func (s *Service) MarkAsSuperseded(oldID, newID int64) error

MarkAsSuperseded marks a memory as superseded by another

func (*Service) PromoteToFact

func (s *Service) PromoteToFact(memoryID int64, projectID string, isValidated bool) error

PromoteToFact promotes a memory to fact type after verifying evidence

func (*Service) SearchMemories

func (s *Service) SearchMemories(projectID string, searchTerm string, limit int) ([]*Memory, error)

SearchMemories performs a full-text search on memories

func (*Service) UpdateMemory

func (s *Service) UpdateMemory(memory *Memory) error

UpdateMemory updates an existing memory entry

type TruthState

type TruthState string

TruthState represents the truth state of a memory

const (
	Tentative TruthState = "tentative"
	Asserted  TruthState = "asserted"
	Verified  TruthState = "verified"
)

type Type

type Type string

Type represents the type of memory entry

const (
	Fact        Type = "fact"
	Claim       Type = "claim"
	Plan        Type = "plan"
	Decision    Type = "decision"
	Constraint  Type = "constraint"
	Observation Type = "observation"
	Note        Type = "note"
	Task        Type = "task"
)

func (Type) IsValid

func (t Type) IsValid() bool

func (Type) RequiresEvidence

func (t Type) RequiresEvidence() bool

Validation rules for memory types

Jump to

Keyboard shortcuts

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