Documentation
¶
Overview ¶
Package memorytest provides test doubles and conformance testing for memory.Provider implementations.
Index ¶
- func RunConformance(t *testing.T, provider memory.Provider)
- type Fake
- func (f *Fake) AddSummary(s FakeSummary)
- func (f *Fake) Append(_ context.Context, session memory.Session, msgs ...ai.Message) error
- func (f *Fake) Assemble(_ context.Context, session memory.Session, budget, freshTail int) ([]ai.Message, error)
- func (f *Fake) Bootstrap(_ context.Context, session memory.Session) error
- func (f *Fake) BuildReviewContext(_ context.Context, session memory.Session, since time.Time) (string, error)
- func (f *Fake) Close() error
- func (f *Fake) Compact(_ context.Context, _ memory.Session, _ memory.CompactionMode) (*memory.CompactionResult, error)
- func (f *Fake) Describe(_ context.Context, summaryID string) (*memory.DescribeResult, error)
- func (f *Fake) Expand(_ context.Context, summaryID string, _ int) (*memory.ExpandResult, error)
- func (f *Fake) GetAgentSoul(_ context.Context, userID int64, agentID string) (string, error)
- func (f *Fake) GetProfile(_ context.Context, userID int64, agentID string) (string, error)
- func (f *Fake) ListInfo(_ context.Context, opts memory.ListOptions) ([]memory.SessionInfo, error)
- func (f *Fake) LoadHistory(_ context.Context, sessionID string) ([]ai.Message, error)
- func (f *Fake) LoadInfo(_ context.Context, sessionID string) (memory.SessionInfo, error)
- func (f *Fake) Name() string
- func (f *Fake) NeedsCompaction(_ context.Context, session memory.Session, threshold float64) bool
- func (f *Fake) SaveInfo(_ context.Context, info memory.SessionInfo) error
- func (f *Fake) Search(_ context.Context, session memory.Session, query memory.SearchQuery) ([]memory.SearchResult, error)
- func (f *Fake) SetAgentSoul(_ context.Context, userID int64, agentID string, content string) error
- func (f *Fake) SetProfile(_ context.Context, userID int64, agentID string, content string) error
- func (f *Fake) Stats(_ context.Context, session memory.Session) (memory.SessionStats, error)
- type FakeSummary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunConformance ¶
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 (*Fake) AddSummary ¶
func (f *Fake) AddSummary(s FakeSummary)
AddSummary adds a fake summary for testing Explorer capability.
func (*Fake) Assemble ¶
func (f *Fake) Assemble(_ context.Context, session memory.Session, budget, freshTail int) ([]ai.Message, error)
Assemble 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) Compact ¶
func (f *Fake) Compact(_ context.Context, _ memory.Session, _ memory.CompactionMode) (*memory.CompactionResult, error)
Compact implements memory.Compactor.
func (*Fake) GetAgentSoul ¶
GetAgentSoul implements memory.ProfileStore.
func (*Fake) GetProfile ¶
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 ¶
LoadHistory implements memory.SessionManager.
func (*Fake) NeedsCompaction ¶
NeedsCompaction implements memory.Compactor.
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 ¶
SetAgentSoul implements memory.ProfileStore.
func (*Fake) SetProfile ¶
SetProfile implements memory.ProfileStore.
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.