memory

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package memory stores memories: durable, source-backed knowledge derived from raw events. In v0.1 they are generated by rules (see summary.Memories); every memory keeps references to the events and sessions it came from.

Index

Constants

View Source
const (
	TypeEpisodic   = "episodic"
	TypeProcedural = "procedural"

	StatusCandidate = "candidate"
)

Types and statuses.

Variables

This section is empty.

Functions

func IDFor

func IDFor(dedupKey string) string

IDFor derives a stable memory id from its dedup key.

func Upsert

func Upsert(ctx context.Context, tx *sql.Tx, m *Memory, at time.Time) error

Upsert stores m (keyed by DedupKey) and indexes it for search. An existing memory keeps its id, creation time and status (a person may have verified or retracted it); content and sources are refreshed.

Types

type Filter

type Filter struct {
	ProjectID string
	Type      string
	Status    string
	// Before/BeforeID page backwards from the last row of the previous page
	// (memories generated together share updated_at).
	Before   *time.Time
	BeforeID string
	Limit    int
}

Filter selects memories.

type Memory

type Memory struct {
	ID          string      `json:"memory_id"`
	ProjectID   string      `json:"project_id"`
	ProjectName string      `json:"project_name,omitempty"`
	SessionID   string      `json:"session_id,omitempty"`
	DedupKey    string      `json:"-"`
	Scope       string      `json:"scope"`
	Type        string      `json:"type"`
	Title       string      `json:"title"`
	Content     string      `json:"content"`
	Status      string      `json:"status"`
	Confidence  float64     `json:"confidence"`
	SourceRefs  []SourceRef `json:"source_refs"`
	Generator   string      `json:"generator"`
	CreatedAt   time.Time   `json:"created_at"`
	UpdatedAt   time.Time   `json:"updated_at"`
}

Memory is one stored memory.

func Get

func Get(ctx context.Context, db *sql.DB, owner, id string) (*Memory, error)

Get returns one of the owner's memories, or nil.

func List

func List(ctx context.Context, db *sql.DB, owner string, f Filter) ([]Memory, error)

List returns the owner's memories, most recently updated first.

type SourceRef

type SourceRef struct {
	Kind string `json:"kind"` // event | session
	ID   string `json:"id"`
}

SourceRef points at what a memory was derived from.

Jump to

Keyboard shortcuts

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