save

open suspend override fun save(fact: Fact, subject: MemorySubject, scope: MemoryScope)(source)

Persists a fact to the local storage system with thread-safe guarantees. This method provides atomic updates to the fact collection by:

  1. Creating necessary storage directories if they don't exist

  2. Loading existing facts for the concept

  3. Appending the new fact to the existing collection

  4. Saving the updated collection atomically

Example usage:

// Save project dependency information
save(
fact = SingleFact(
concept = Concept("dependencies", "Project build dependencies", FactType.MULTIPLE),
timestamp = timeProvider.getCurrentTimestamp(),
value = "org.jetbrains.kotlin:kotlin-stdlib:1.8.0"
),
subject = MemorySubject.Project,
scope = MemoryScope.Product("my-app")
)

Parameters

fact

New fact to be stored

subject

Context category for the fact (e.g., MACHINE, PROJECT)

scope

Visibility scope for the fact (e.g., Agent, Feature)