Record Class SessionStart

java.lang.Object
java.lang.Record
com.tnsai.hooks.events.SessionStart
Record Components:
eventId - ULID-shaped correlation id
timestamp - when the connection opened
context - surrounding hook context
sessionId - framework session id (matches the corresponding SessionEnd)
clientAddress - client IP / address, or "unknown" when unavailable
headers - transport-level headers (immutable copy)
authToken - opaque auth token if present in the headers
protocol - transport protocol used by this session
All Implemented Interfaces:
HookEvent, SessionHookEvent

public record SessionStart(String eventId, Instant timestamp, HookContext context, String sessionId, String clientAddress, Map<String,String> headers, Optional<String> authToken, SessionProtocol protocol) extends Record implements SessionHookEvent
Fires when a new client session opens on the server (issue #63). The natural point for authentication, tenant resolution, and per-session rate-limit setup.

Hooks may Block to refuse the connection (the server returns a structured auth / policy error to the client) or Modify via withHeaders(Map) to rewrite headers (e.g. resolve a raw token into a tenant id before the session proceeds).

Since:
0.5.0 (issue #63)
  • Constructor Details

  • 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
    • withHeaders

      public SessionStart withHeaders(Map<String,String> newHeaders)
      Build a copy with newHeaders replacing headers. Used by Modify hooks that resolve auth headers into derived fields (e.g. tenantId) before the session proceeds.
    • 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
    • sessionId

      public String sessionId()
      Returns the value of the sessionId record component.
      Returns:
      the value of the sessionId record component
    • clientAddress

      public String clientAddress()
      Returns the value of the clientAddress record component.
      Returns:
      the value of the clientAddress record component
    • headers

      public Map<String,String> headers()
      Returns the value of the headers record component.
      Returns:
      the value of the headers record component
    • authToken

      public Optional<String> authToken()
      Returns the value of the authToken record component.
      Returns:
      the value of the authToken record component
    • protocol

      public SessionProtocol protocol()
      Returns the value of the protocol record component.
      Returns:
      the value of the protocol record component