Class GroupCheckpoint

java.lang.Object
com.tnsai.coordination.lifecycle.GroupCheckpoint

public final class GroupCheckpoint extends Object
Captures and persists snapshots of group state for recovery.

GroupCheckpoint provides a mechanism to serialize the current state of an AgentGroup to disk and reload it later. This enables checkpoint-based recovery where a group can be restored to a previously known good state.

Usage Example


 // Capture a snapshot
 GroupCheckpoint.Snapshot snapshot = GroupCheckpoint.capture(group);

 // Save to disk
 GroupCheckpoint.save(snapshot, Path.of("/tmp/group-checkpoint.json"));

 // Load from disk
 GroupCheckpoint.Snapshot loaded = GroupCheckpoint.load(Path.of("/tmp/group-checkpoint.json"));
 
See Also:
  • Method Details

    • capture

      public static GroupCheckpoint.Snapshot capture(com.tnsai.agents.groups.AgentGroup group)
      Captures a snapshot of the current group state.
      Parameters:
      group - the group to capture
      Returns:
      snapshot of the group's current state
      Throws:
      NullPointerException - if group is null
    • save

      public static void save(GroupCheckpoint.Snapshot snapshot, Path path) throws IOException
      Saves a snapshot to a file in JSON format.
      Parameters:
      snapshot - the snapshot to save
      path - the file path to write to
      Throws:
      IOException - if an I/O error occurs during writing
      NullPointerException - if snapshot or path is null
    • load

      public static GroupCheckpoint.Snapshot load(Path path) throws IOException
      Loads a snapshot from a JSON file.
      Parameters:
      path - the file path to read from
      Returns:
      the loaded snapshot
      Throws:
      IOException - if an I/O error occurs during reading or the file is invalid
      NullPointerException - if path is null