Package com.tnsai.context.snapshot.impl
Class CheckpointerSnapshotStore
java.lang.Object
com.tnsai.context.snapshot.impl.CheckpointerSnapshotStore
- All Implemented Interfaces:
com.tnsai.context.snapshot.SnapshotStore
public class CheckpointerSnapshotStore
extends Object
implements com.tnsai.context.snapshot.SnapshotStore
Checkpointer-backed implementation of SnapshotStore.
This implementation leverages the existing Checkpointer system (SQLite, PostgreSQL, MongoDB, Redis) for persistent snapshot storage.
Storage Format
Each snapshot is stored as a checkpoint with:
- threadId = agentId
- checkpointId = snapshotId
- state = serialized snapshot data
- metadata = snapshot metadata (trigger, timestamp, etc.)
Usage Example
// Use with SQLite checkpointer
Checkpointer checkpointer = new SQLiteCheckpointer("snapshots.db");
SnapshotStore store = new CheckpointerSnapshotStore(checkpointer);
// Enable context graph
agent.enableContextGraph(store, new InMemoryDecisionTraceStore());
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.tnsai.context.snapshot.SnapshotStore
com.tnsai.context.snapshot.SnapshotStore.SnapshotStoreStatistics -
Constructor Summary
ConstructorsConstructorDescriptionCheckpointerSnapshotStore(com.tnsai.state.Checkpointer checkpointer) Creates a new CheckpointerSnapshotStore. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all data from the store.intcount()intcountByAgent(String agentId) booleanintdeleteByAgent(String agentId) intdeleteOlderThan(Instant cutoff) List<com.tnsai.context.snapshot.ContextSnapshot> findByAgent(String agentId) List<com.tnsai.context.snapshot.ContextSnapshot> findByAgentAndTimeRange(String agentId, Instant start, Instant end) List<com.tnsai.context.snapshot.ContextSnapshot> findByConversation(String conversationId) Optional<com.tnsai.context.snapshot.ContextSnapshot> List<com.tnsai.context.snapshot.ContextSnapshot> findByTimeRange(Instant start, Instant end) List<com.tnsai.context.snapshot.ContextSnapshot> findByTrigger(com.tnsai.context.snapshot.SnapshotTrigger trigger) Optional<com.tnsai.context.snapshot.ContextSnapshot> findLatestByAgent(String agentId) com.tnsai.context.snapshot.SnapshotStore.SnapshotStoreStatisticsvoidsave(com.tnsai.context.snapshot.ContextSnapshot snapshot)
-
Constructor Details
-
CheckpointerSnapshotStore
public CheckpointerSnapshotStore(com.tnsai.state.Checkpointer checkpointer) Creates a new CheckpointerSnapshotStore.- Parameters:
checkpointer- the underlying checkpointer for persistence
-
-
Method Details
-
save
public void save(com.tnsai.context.snapshot.ContextSnapshot snapshot) - Specified by:
savein interfacecom.tnsai.context.snapshot.SnapshotStore
-
findById
- Specified by:
findByIdin interfacecom.tnsai.context.snapshot.SnapshotStore
-
findLatestByAgent
- Specified by:
findLatestByAgentin interfacecom.tnsai.context.snapshot.SnapshotStore
-
findByAgent
- Specified by:
findByAgentin interfacecom.tnsai.context.snapshot.SnapshotStore
-
findByAgentAndTimeRange
public List<com.tnsai.context.snapshot.ContextSnapshot> findByAgentAndTimeRange(String agentId, Instant start, Instant end) - Specified by:
findByAgentAndTimeRangein interfacecom.tnsai.context.snapshot.SnapshotStore
-
findByConversation
- Specified by:
findByConversationin interfacecom.tnsai.context.snapshot.SnapshotStore
-
findByTrigger
public List<com.tnsai.context.snapshot.ContextSnapshot> findByTrigger(com.tnsai.context.snapshot.SnapshotTrigger trigger) - Specified by:
findByTriggerin interfacecom.tnsai.context.snapshot.SnapshotStore
-
findByTimeRange
- Specified by:
findByTimeRangein interfacecom.tnsai.context.snapshot.SnapshotStore
-
delete
- Specified by:
deletein interfacecom.tnsai.context.snapshot.SnapshotStore
-
deleteByAgent
- Specified by:
deleteByAgentin interfacecom.tnsai.context.snapshot.SnapshotStore
-
deleteOlderThan
- Specified by:
deleteOlderThanin interfacecom.tnsai.context.snapshot.SnapshotStore
-
count
public int count()- Specified by:
countin interfacecom.tnsai.context.snapshot.SnapshotStore
-
countByAgent
- Specified by:
countByAgentin interfacecom.tnsai.context.snapshot.SnapshotStore
-
getStatistics
public com.tnsai.context.snapshot.SnapshotStore.SnapshotStoreStatistics getStatistics()- Specified by:
getStatisticsin interfacecom.tnsai.context.snapshot.SnapshotStore
-
clear
public void clear()Clears all data from the store.
-