org.llm4s.agent.memory.testkit
Members list
Type members
Classlikes
How MemoryStoreContract and TransactionalMemoryStoreContract register their cases, and the two ways a store's spec says that a case does not hold for it yet:
How MemoryStoreContract and TransactionalMemoryStoreContract register their cases, and the two ways a store's spec says that a case does not hold for it yet:
- knownFailures: a case the store fails today because of a known defect, named with the issue that tracks it. The case still runs, as ScalaTest's
pendingUntilFixed: it is reported pending while it fails and fails once it passes, so the change that fixes the defect also removes the entry. - unsupported: a case the store cannot run at all, with the reason. It is cancelled.
A name in either map that matches no case fails the suite, so a renamed case cannot silently stop being excused. The name of a case is the text after should, as the suite's output shows it.
Attributes
- Companion
- object
- Source
- MemoryContractCases.scala
- Supertypes
-
trait OptionValuestrait EitherValuestrait Matcherstrait Explicitlytrait MatcherWordstrait Tolerancetrait AnyFlatSpecLiketrait Documentingtrait Alertingtrait Notifyingtrait Informingtrait CanVerbtrait MustVerbtrait ShouldVerbtrait TestRegistrationtrait TestSuitetrait Suitetrait Serializabletrait Assertionstrait TripleEqualstrait TripleEqualsSupportclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
trait MemoryStoreContract
Helpers for the specs that run the contracts.
Helpers for the specs that run the contracts.
Attributes
- Companion
- trait
- Source
- MemoryContractCases.scala
- Supertypes
- Self type
-
MemoryContractCases.type
The memories and filters every store answers alike (#3031, #3329): what MemoryFilter.matches says about each of fixtures is what a store must answer for recall, count, deleteMatching and search with each of filters. MemoryStoreContract runs the whole matrix, and random trees of its leaves (randomTree).
The memories and filters every store answers alike (#3031, #3329): what MemoryFilter.matches says about each of fixtures is what a store must answer for recall, count, deleteMatching and search with each of filters. MemoryStoreContract runs the whole matrix, and random trees of its leaves (randomTree).
The rows are chosen to catch a store that translates a filter loosely: % and _ read as LIKE wildcards, case folding that is not String.toLowerCase's, a NULL column that makes Not drop a row, a metadata key read as a JSON path.
Attributes
- Source
- MemoryFilterMatrix.scala
- Supertypes
- Self type
-
MemoryFilterMatrix.type
The contract every org.llm4s.agent.memory.MemoryStore must meet (#3038, #3329), as a ScalaTest suite: mix it into a spec, implement storeName, semantic and withStore, and every case below runs against your store:
The contract every org.llm4s.agent.memory.MemoryStore must meet (#3038, #3329), as a ScalaTest suite: mix it into a spec, implement storeName, semantic and withStore, and every case below runs against your store:
class MyMemoryStoreContractSpec extends MemoryStoreContract {
protected def storeName: String = "MyMemoryStore"
protected def semantic: Boolean = false
protected def withStore[A](embeddings: EmbeddingService)(body: MemoryStore => A): A = {
val store = MyMemoryStore.open().fold(e => fail(e.message), identity)
MemoryContractCases.after(store.close())(body(store))
}
}
The cases:
- '''Writes.''' A write over an existing id replaces every field; a batch keeps a repeated id's last occurrence;
updatechanges every field, refuses a changed id, answers a missing one withNotFoundError, and drops an embedding computed for the old content;replacestores, then deletes;delete,clearandstats. - '''Filters.''' Every filter of MemoryFilterMatrix, and 300 random trees of its leaves, in
recall,count,searchanddeleteMatching; a limit applied after the filter; sub-millisecond time bounds; metadata keys matched exactly. - '''The keyset cursor.''' Recall order (newest first, then id by its UTF-8 bytes, descending), and
MemoryFilter.Precedingpaging past memories that share a time, as consolidation pages (LLMMemoryManager.consolidatePage): every memory once, a replacement between pages neither repeating nor skipping one. - '''Durability.'''
durableanswers expectDurable; a durable store gives back everything it held when its storage is opened again (withReopened). - '''Limits and blank queries''', and, for a store that searches by embedding, the shared score rule (
org.llm4s.vectorstore.SearchScores, #3037):(1 + cos) / 2, a vector that cannot be compared left out, a store of another dimension aConfigurationError, nothing stored when embedding fails.
Eviction under bounds, applied writes and fencing are TransactionalMemoryStoreContract's. A store with a known defect lists the case in knownFailures with its issue; one that cannot run a case lists it in unsupported (see MemoryContractCases). Timestamps are whole milliseconds, the precision every store keeps.
Attributes
- Companion
- object
- Source
- MemoryStoreContract.scala
- Supertypes
-
trait MemoryContractCasestrait OptionValuestrait EitherValuestrait Matcherstrait Explicitlytrait MatcherWordstrait Tolerancetrait AnyFlatSpecLiketrait Documentingtrait Alertingtrait Notifyingtrait Informingtrait CanVerbtrait MustVerbtrait ShouldVerbtrait TestRegistrationtrait TestSuitetrait Suitetrait Serializabletrait Assertionstrait TripleEqualstrait TripleEqualsSupportclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- trait
- Source
- MemoryStoreContract.scala
- Supertypes
- Self type
-
MemoryStoreContract.type
The contract every org.llm4s.agent.memory.TransactionalMemoryStore must meet (design §4.31, #3328, #3329), as a ScalaTest suite: applied writes recorded with the write, fenced by the token per scope, and bounded by eviction in the same transaction. Mix it into a spec and implement storeName and newStore (or withStore, to release the store afterwards).
The contract every org.llm4s.agent.memory.TransactionalMemoryStore must meet (design §4.31, #3328, #3329), as a ScalaTest suite: applied writes recorded with the write, fenced by the token per scope, and bounded by eviction in the same transaction. Mix it into a spec and implement storeName and newStore (or withStore, to release the store afterwards).
The cases:
- '''Applied writes.''' A write and its recorded outcome; a key applied again replays the outcome and writes nothing, even after what it stored was deleted; a replacement whose sources another writer already replaced writes nothing;
forgetApplied; applied keys kept byclear(). - '''Fencing.''' A token older than its scope's newest refused by every operation, changing nothing.
- '''Eviction.''' Beyond
maxMemoriesandmaxBytes, lowest importance first (none counts as 0.5), then oldest, then by id (its UTF-8 bytes, as recall orders ids); with an owner, only the owner's memories counted and evicted. - '''Eviction against concurrent writers''' (#3328), on two handles of one storage (withSecondHandle): a memory another handle makes important while a write evicts is either evicted before that write lands - and then the other handle's update fails - or kept; never evicted after it.
A store with a known defect lists the case in knownFailures with its issue; one that cannot run a case lists it in unsupported (see MemoryContractCases).
Attributes
- Source
- TransactionalMemoryStoreContract.scala
- Supertypes
-
trait MemoryContractCasestrait OptionValuestrait EitherValuestrait Matcherstrait Explicitlytrait MatcherWordstrait Tolerancetrait AnyFlatSpecLiketrait Documentingtrait Alertingtrait Notifyingtrait Informingtrait CanVerbtrait MustVerbtrait ShouldVerbtrait TestRegistrationtrait TestSuitetrait Suitetrait Serializabletrait Assertionstrait TripleEqualstrait TripleEqualsSupportclass Objecttrait Matchableclass AnyShow all
