Package com.tnsai.reliability
Record Class Checkpoint
java.lang.Object
java.lang.Record
com.tnsai.reliability.Checkpoint
- Record Components:
runId- correlation id for the whole run; opaquestepIndex- zero-based position in the run's step listcapturedAt- wall-clock instant the checkpoint was savedstate- serialized agent / step state — opaque bytesmetadata- free-form labels (step name, agent id, …) visible to operators in store dumpspreviousCheckpointId- parent checkpoint, when forming a chain for retention truncation; empty for the first checkpoint of a run
public record Checkpoint(String runId, int stepIndex, Instant capturedAt, byte[] state, Map<String,Object> metadata, Optional<String> previousCheckpointId)
extends Record
Durable snapshot of a
ResumableRun at a step boundary
(issue #82 closeout / TNS-299).
Each step boundary in a long-running agent execution captures one
of these. The orchestrator persists them via a CheckpointStore
so a process crash, runtime upgrade, or operator-initiated pause can
be recovered from the latest entry without redoing finished steps.
Serialization shape
state is opaque to this primitive — the orchestrator and the
step impls own its format. JSON is the recommended default for
debuggability; binary is opt-in for hot paths. Keeping the byte
payload format off the Checkpoint record itself lets stores
round-trip checkpoints without parsing them.
Identity
(runId, stepIndex) is the natural identifier — every step in
a run produces at most one checkpoint. checkpointId() returns
the conventional concatenation that adapters use when keying their
underlying storage.- Since:
- 0.10.0 (TNS-299)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecapturedAtrecord component.Stable identifier formed fromrunIdandstepIndex.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.metadata()Returns the value of themetadatarecord component.Returns the value of thepreviousCheckpointIdrecord component.runId()Returns the value of therunIdrecord component.byte[]state()Returns the value of thestaterecord component.byte[]intReturns the value of thestepIndexrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Checkpoint
public Checkpoint(String runId, int stepIndex, Instant capturedAt, byte[] state, Map<String, Object> metadata, Optional<String> previousCheckpointId) Creates an instance of aCheckpointrecord class.- Parameters:
runId- the value for therunIdrecord componentstepIndex- the value for thestepIndexrecord componentcapturedAt- the value for thecapturedAtrecord componentstate- the value for thestaterecord componentmetadata- the value for themetadatarecord componentpreviousCheckpointId- the value for thepreviousCheckpointIdrecord component
-
-
Method Details
-
checkpointId
Stable identifier formed fromrunIdandstepIndex. Stores typically use this as their primary key. Format is intentionally simple —<runId>:<stepIndex>— so it survives filesystem / SQL / Redis backends without escaping concerns. Run ids must therefore not contain':'; compact constructor does NOT enforce this so consumers can use a different separator convention if they own the id space. -
stateCopy
public byte[] stateCopy()- Returns:
- defensive copy of
state; mutations to the returned array do not affect the checkpoint.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
runId
Returns the value of therunIdrecord component.- Returns:
- the value of the
runIdrecord component
-
stepIndex
public int stepIndex()Returns the value of thestepIndexrecord component.- Returns:
- the value of the
stepIndexrecord component
-
capturedAt
Returns the value of thecapturedAtrecord component.- Returns:
- the value of the
capturedAtrecord component
-
state
public byte[] state()Returns the value of thestaterecord component.- Returns:
- the value of the
staterecord component
-
metadata
Returns the value of themetadatarecord component.- Returns:
- the value of the
metadatarecord component
-
previousCheckpointId
Returns the value of thepreviousCheckpointIdrecord component.- Returns:
- the value of the
previousCheckpointIdrecord component
-