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) AddConstraint(_ context.Context, userID int64, agentID string, text string) ([]memory.ConstraintEntry, error)
- func (f *Fake) AddSummary(s FakeSummary)
- func (f *Fake) AdvanceSessionSnapshot(_ context.Context, sessionID string, userID int64, agentID string) error
- 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) Changelog() []memory.ChangeEntry
- 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) GetAgentSoulAt(_ context.Context, userID int64, agentID string, _ int64) (string, error)
- func (f *Fake) GetConstraints(_ context.Context, userID int64, agentID string) ([]memory.ConstraintEntry, error)
- func (f *Fake) GetConstraintsAt(_ context.Context, userID int64, agentID string, _ int64) ([]memory.ConstraintEntry, error)
- func (f *Fake) GetOrCreateSessionSnapshot(_ context.Context, sessionID string, userID int64, agentID string) (memory.SessionSnapshot, error)
- func (f *Fake) GetProfile(_ context.Context, userID int64, agentID string) (string, error)
- func (f *Fake) GetProfileAt(_ context.Context, userID int64, agentID string, _ int64) (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) ReadChangelog(_ context.Context, userID int64, agentID string, scope string, limit int) ([]memory.ChangeEntry, error)
- func (f *Fake) RemoveConstraint(_ context.Context, userID int64, agentID string, id string) ([]memory.ConstraintEntry, error)
- 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) Snapshots() map[string]memory.SessionSnapshot
- func (f *Fake) Stats(_ context.Context, session memory.Session) (memory.SessionStats, error)
- func (f *Fake) WriteChangelog(_ context.Context, entry memory.ChangeEntry) 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) AddConstraint ¶ added in v0.18.0
func (f *Fake) AddConstraint(_ context.Context, userID int64, agentID string, text string) ([]memory.ConstraintEntry, error)
AddConstraint implements memory.ConstraintStore.
func (*Fake) AddSummary ¶
func (f *Fake) AddSummary(s FakeSummary)
AddSummary adds a fake summary for testing Explorer capability.
func (*Fake) AdvanceSessionSnapshot ¶ added in v0.18.0
func (f *Fake) AdvanceSessionSnapshot(_ context.Context, sessionID string, userID int64, agentID string) error
AdvanceSessionSnapshot implements memory.SessionSnapshotStore. Updates the snapshot version to match the number of changelog entries.
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) Changelog ¶ added in v0.18.0
func (f *Fake) Changelog() []memory.ChangeEntry
Changelog returns all recorded changelog entries (in insertion order) for test assertions.
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) GetAgentSoulAt ¶ added in v0.18.0
func (f *Fake) GetAgentSoulAt(_ context.Context, userID int64, agentID string, _ int64) (string, error)
GetAgentSoulAt implements memory.VersionedProfileStore. The fake ignores version and returns the current soul (sufficient for tests).
func (*Fake) GetConstraints ¶ added in v0.18.0
func (f *Fake) GetConstraints(_ context.Context, userID int64, agentID string) ([]memory.ConstraintEntry, error)
GetConstraints implements memory.ConstraintStore.
func (*Fake) GetConstraintsAt ¶ added in v0.18.0
func (f *Fake) GetConstraintsAt(_ context.Context, userID int64, agentID string, _ int64) ([]memory.ConstraintEntry, error)
GetConstraintsAt implements memory.VersionedConstraintStore. The fake ignores version and returns the current constraints (sufficient for tests).
func (*Fake) GetOrCreateSessionSnapshot ¶ added in v0.18.0
func (f *Fake) GetOrCreateSessionSnapshot(_ context.Context, sessionID string, userID int64, agentID string) (memory.SessionSnapshot, error)
GetOrCreateSessionSnapshot implements memory.SessionSnapshotStore. Creates with version 0 when not found (sufficient for tests).
func (*Fake) GetProfile ¶
GetProfile implements memory.ProfileStore.
func (*Fake) GetProfileAt ¶ added in v0.18.0
func (f *Fake) GetProfileAt(_ context.Context, userID int64, agentID string, _ int64) (string, error)
GetProfileAt implements memory.VersionedProfileStore. The fake ignores version and returns the current profile (sufficient for tests).
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) ReadChangelog ¶ added in v0.18.0
func (f *Fake) ReadChangelog(_ context.Context, userID int64, agentID string, scope string, limit int) ([]memory.ChangeEntry, error)
ReadChangelog implements memory.ChangelogReader. Returns up to limit entries for the given scope in reverse-insertion order.
func (*Fake) RemoveConstraint ¶ added in v0.18.0
func (f *Fake) RemoveConstraint(_ context.Context, userID int64, agentID string, id string) ([]memory.ConstraintEntry, error)
RemoveConstraint implements memory.ConstraintStore.
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.
func (*Fake) Snapshots ¶ added in v0.18.0
func (f *Fake) Snapshots() map[string]memory.SessionSnapshot
Snapshots returns all stored snapshots for test assertions.
func (*Fake) WriteChangelog ¶ added in v0.18.0
WriteChangelog implements memory.ChangelogWriter.
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.