Interface SnapshotStore


public interface SnapshotStore
Interface for storing and retrieving context snapshots.

SnapshotStore provides persistence for context snapshots, enabling:

  • Historical state retrieval
  • Decision auditing
  • Recovery and debugging

Usage Example


 SnapshotStore store = new InMemorySnapshotStore();

 // Store snapshot
 ContextSnapshot snapshot = contextManager.createSnapshot(SnapshotTrigger.PRE_DECISION);
 store.save(snapshot);

 // Retrieve by ID
 Optional<ContextSnapshot> retrieved = store.findById(snapshot.getSnapshotId());

 // Query by time range
 List<ContextSnapshot> recent = store.findByTimeRange(
     Instant.now().minusHours(1),
     Instant.now()
 );
 
  • Method Details

    • save

      void save(ContextSnapshot snapshot)
      Saves a context snapshot.
      Parameters:
      snapshot - snapshot to save
    • findById

      Optional<ContextSnapshot> findById(String snapshotId)
      Finds a snapshot by ID.
      Parameters:
      snapshotId - snapshot identifier
      Returns:
      Optional containing the snapshot if found
    • findLatestByAgent

      Optional<ContextSnapshot> findLatestByAgent(String agentId)
      Finds the most recent snapshot for an agent.
      Parameters:
      agentId - agent identifier
      Returns:
      Optional containing the most recent snapshot if any exist
    • findByAgent

      List<ContextSnapshot> findByAgent(String agentId)
      Finds all snapshots for an agent.
      Parameters:
      agentId - agent identifier
      Returns:
      list of snapshots, ordered by timestamp descending
    • findByTrigger

      List<ContextSnapshot> findByTrigger(SnapshotTrigger trigger)
      Finds snapshots by trigger type.
      Parameters:
      trigger - snapshot trigger type
      Returns:
      list of matching snapshots
    • findByTimeRange

      List<ContextSnapshot> findByTimeRange(Instant start, Instant end)
      Finds snapshots within a time range.
      Parameters:
      start - start of time range (inclusive)
      end - end of time range (inclusive)
      Returns:
      list of snapshots in the time range
    • findByAgentAndTimeRange

      List<ContextSnapshot> findByAgentAndTimeRange(String agentId, Instant start, Instant end)
      Finds snapshots for an agent within a time range.
      Parameters:
      agentId - agent identifier
      start - start of time range (inclusive)
      end - end of time range (inclusive)
      Returns:
      list of snapshots
    • findByConversation

      List<ContextSnapshot> findByConversation(String conversationId)
      Finds snapshots for a conversation.
      Parameters:
      conversationId - conversation identifier
      Returns:
      list of snapshots for the conversation
    • delete

      boolean delete(String snapshotId)
      Deletes a snapshot by ID.
      Parameters:
      snapshotId - snapshot identifier
      Returns:
      true if snapshot was deleted
    • deleteByAgent

      int deleteByAgent(String agentId)
      Deletes all snapshots for an agent.
      Parameters:
      agentId - agent identifier
      Returns:
      number of deleted snapshots
    • deleteOlderThan

      int deleteOlderThan(Instant before)
      Deletes snapshots older than a specified time.
      Parameters:
      before - delete snapshots before this time
      Returns:
      number of deleted snapshots
    • count

      int count()
      Counts total snapshots in the store.
      Returns:
      snapshot count
    • countByAgent

      int countByAgent(String agentId)
      Counts snapshots for an agent.
      Parameters:
      agentId - agent identifier
      Returns:
      snapshot count for the agent
    • getStatistics

      Gets store statistics.
      Returns:
      store statistics