memorytest

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package memorytest provides test doubles and conformance testing for memory.Provider implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunConformance

func RunConformance(t *testing.T, provider memory.Provider)

RunConformance runs the standard conformance suite against any Provider. It tests: Bootstrap idempotency, Append ordering, Assemble budget/freshTail, Stats accuracy, and any optional capabilities detected via type assertion.

Types

type Fake

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

Fake is an in-memory Provider that implements all optional capability interfaces. Use it in unit tests to avoid database setup.

func New

func New() *Fake

New creates a new Fake provider ready for use.

func (*Fake) AddSummary

func (f *Fake) AddSummary(s FakeSummary)

AddSummary adds a fake summary for testing Explorer capability.

func (*Fake) Append

func (f *Fake) Append(_ context.Context, session memory.Session, msgs ...ai.Message) error

Append implements memory.Provider.

func (*Fake) Assemble

func (f *Fake) Assemble(_ context.Context, session memory.Session, budget, freshTail int) ([]ai.Message, error)

Assemble implements memory.Provider.

func (*Fake) Bootstrap

func (f *Fake) Bootstrap(_ context.Context, session memory.Session) error

Bootstrap implements memory.Provider.

func (*Fake) BuildReviewContext

func (f *Fake) BuildReviewContext(_ context.Context, session memory.Session, since time.Time) (string, error)

BuildReviewContext implements memory.Reviewer.

func (*Fake) Close

func (f *Fake) Close() error

Close implements memory.Provider.

func (*Fake) Compact

Compact implements memory.Compactor.

func (*Fake) Describe

func (f *Fake) Describe(_ context.Context, summaryID string) (*memory.DescribeResult, error)

Describe implements memory.Explorer.

func (*Fake) Expand

func (f *Fake) Expand(_ context.Context, summaryID string, _ int) (*memory.ExpandResult, error)

Expand implements memory.Explorer.

func (*Fake) GetAgentSoul

func (f *Fake) GetAgentSoul(_ context.Context, userID int64, agentID string) (string, error)

GetAgentSoul implements memory.ProfileStore.

func (*Fake) GetProfile

func (f *Fake) GetProfile(_ context.Context, userID int64, agentID string) (string, error)

GetProfile implements memory.ProfileStore.

func (*Fake) ListInfo

func (f *Fake) ListInfo(_ context.Context, opts memory.ListOptions) ([]memory.SessionInfo, error)

ListInfo implements memory.SessionManager.

func (*Fake) LoadHistory

func (f *Fake) LoadHistory(_ context.Context, sessionID string) ([]ai.Message, error)

LoadHistory implements memory.SessionManager.

func (*Fake) LoadInfo

func (f *Fake) LoadInfo(_ context.Context, sessionID string) (memory.SessionInfo, error)

LoadInfo implements memory.SessionManager.

func (*Fake) Name

func (f *Fake) Name() string

Name implements memory.Provider.

func (*Fake) NeedsCompaction

func (f *Fake) NeedsCompaction(_ context.Context, session memory.Session, threshold float64) bool

NeedsCompaction implements memory.Compactor.

func (*Fake) SaveInfo

func (f *Fake) SaveInfo(_ context.Context, info memory.SessionInfo) error

SaveInfo implements memory.SessionManager.

func (*Fake) Search

func (f *Fake) Search(_ context.Context, session memory.Session, query memory.SearchQuery) ([]memory.SearchResult, error)

Search implements memory.Searcher.

func (*Fake) SetAgentSoul

func (f *Fake) SetAgentSoul(_ context.Context, userID int64, agentID string, content string) error

SetAgentSoul implements memory.ProfileStore.

func (*Fake) SetProfile

func (f *Fake) SetProfile(_ context.Context, userID int64, agentID string, content string) error

SetProfile implements memory.ProfileStore.

func (*Fake) Stats

func (f *Fake) Stats(_ context.Context, session memory.Session) (memory.SessionStats, error)

Stats implements memory.Provider.

type FakeSummary

type FakeSummary struct {
	ID              string
	Kind            string // "leaf" or "condensed"
	Depth           int
	Content         string
	EarliestAt      *time.Time
	LatestAt        *time.Time
	DescendantCount int
	ParentIDs       []string
	ChildIDs        []string
	// For leaf: source messages. For condensed: child summaries.
	SourceMessages []memory.ExpandMessage
	ChildSummaries []memory.ExpandChild
}

FakeSummary holds summary data for the Explorer capability.

Jump to

Keyboard shortcuts

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