Record Class PostAction

java.lang.Object
java.lang.Record
com.tnsai.hooks.events.PostAction
Record Components:
eventId - ULID-shaped correlation id
timestamp - when the event was constructed (post-return)
context - surrounding hook context
request - typed request that was dispatched
response - typed response from the executor
type - dispatch channel
elapsed - wall-clock time the action took
All Implemented Interfaces:
ActionHookEvent, HookEvent

public record PostAction(String eventId, Instant timestamp, HookContext context, ActionRequest request, ActionResponse response, ActionType type, Duration elapsed) extends Record implements ActionHookEvent
Fires after an action returns successfully (issue #59). Counterpart to PreAction. Carries the typed ActionResponse and wall-clock elapsed so metric / cost-accounting hooks can compose measurements directly off the event stream.
Since:
0.5.0 (issue #59)
  • Constructor Details

    • PostAction

      public PostAction(String eventId, Instant timestamp, HookContext context, ActionRequest request, ActionResponse response, ActionType type, Duration elapsed)
      Creates an instance of a PostAction 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
      request - the value for the request record component
      response - the value for the response record component
      type - the value for the type record component
      elapsed - the value for the elapsed 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
    • withResponse

      public PostAction withResponse(ActionResponse newResponse)
      Build a copy with newResponse replacing response. Used by Modify hooks that scrub the response (e.g. redaction on a PostAction carrying an LLM response).
    • 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
    • request

      public ActionRequest request()
      Returns the value of the request record component.
      Returns:
      the value of the request record component
    • response

      public ActionResponse response()
      Returns the value of the response record component.
      Returns:
      the value of the response record component
    • type

      public ActionType type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • elapsed

      public Duration elapsed()
      Returns the value of the elapsed record component.
      Returns:
      the value of the elapsed record component