Class SessionSerializer

java.lang.Object
com.tnsai.memory.advanced.SessionSerializer

public final class SessionSerializer extends Object
Serializes TieredMemoryStore state to JSON for session persistence.

Writes a JSON file named {agentId}-memory.json containing all memory entries with their tier, strength, provenance, and versioning metadata.

  • Constructor Details

    • SessionSerializer

      public SessionSerializer(Path directory) throws IOException
      Creates a serializer that writes to the given directory.
      Parameters:
      directory - the directory for session files
      Throws:
      IOException - if the directory cannot be created
  • Method Details

    • save

      public void save(String agentId, TieredMemoryStore store) throws IOException
      Serializes the store's state to a JSON file.
      Parameters:
      agentId - the agent ID (used for the filename)
      store - the tiered memory store to serialize
      Throws:
      IOException - if the file cannot be written
    • fileFor

      public Path fileFor(String agentId)
      Returns the file path for the given agent's session file.