Record Class OnStateTransition

java.lang.Object
java.lang.Record
com.tnsai.hooks.events.OnStateTransition
Record Components:
eventId - ULID-shaped correlation id
timestamp - when the transition occurred
context - surrounding hook context
from - previous state; null only for the initial transition out of pre-built state
to - new state
trigger - short label describing the trigger
All Implemented Interfaces:
AgentHookEvent, HookEvent

public record OnStateTransition(String eventId, Instant timestamp, HookContext context, AgentState from, AgentState to, String trigger) extends Record implements AgentHookEvent
Fires on an agent FSM state change (issue #60).

Today every agent has only one visible state —

invalid reference
AgentState#READY
— so the only transition possible is null → READY at init; the orchestrator (follow-up) fires that synthetic transition so consumers can bind against the final hook API even before the full FSM from #21 lands. Adding states to AgentState in #21 automatically extends the transitions this event can carry.

trigger is a short stable label describing what caused the transition ("build_complete", "chat_start", "error" …). Used in audit logs + dashboards.

Since:
0.5.0 (issue #60)
  • Constructor Details

    • OnStateTransition

      public OnStateTransition(String eventId, Instant timestamp, HookContext context, AgentState from, AgentState to, String trigger)
      Creates an instance of a OnStateTransition record class.
      Parameters:
      eventId - the value for the eventId record component
      timestamp - the value for the timestamp record component
      context - the value for the context record component
      from - the value for the from record component
      to - the value for the to record component
      trigger - the value for the trigger record component
  • Method Details

    • eventType

      public String eventType()
      Description copied from interface: HookEvent
      Short stable string identifier of the event kind, e.g. "PreToolUse". Default implementation derives it from the concrete record's simple class name; concrete records may override if a different naming is desirable.
      Specified by:
      eventType in interface HookEvent
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • eventId

      public String eventId()
      Returns the value of the eventId record component.
      Specified by:
      eventId in interface HookEvent
      Returns:
      the value of the eventId record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Specified by:
      timestamp in interface HookEvent
      Returns:
      the value of the timestamp record component
    • context

      public HookContext context()
      Returns the value of the context record component.
      Specified by:
      context in interface HookEvent
      Returns:
      the value of the context record component
    • from

      public AgentState from()
      Returns the value of the from record component.
      Returns:
      the value of the from record component
    • to

      public AgentState to()
      Returns the value of the to record component.
      Returns:
      the value of the to record component
    • trigger

      public String trigger()
      Returns the value of the trigger record component.
      Returns:
      the value of the trigger record component