Record Class DecisionTrigger

java.lang.Object
java.lang.Record
com.tnsai.context.decision.DecisionTrigger

public record DecisionTrigger(DecisionTrigger.TriggerType type, String description, String source, Instant timestamp, Map<String,Object> context) extends Record
Represents what initiated a decision.

DecisionTrigger captures the event or condition that led to the agent making a decision. This enables understanding the causal chain leading to agent actions.

Usage Example


 DecisionTrigger trigger = DecisionTrigger.userRequest(
     "Process discount request",
     "user-123"
 );

 // Or from a system event
 DecisionTrigger eventTrigger = DecisionTrigger.systemEvent(
     "account.status.changed",
     Map.of("oldStatus", "active", "newStatus", "suspended")
 );
 
  • Constructor Details

  • Method Details

    • userRequest

      public static DecisionTrigger userRequest(String description, String userId)
      Creates a trigger from a user request.
      Parameters:
      description - what the user requested
      userId - user identifier
      Returns:
      new DecisionTrigger
    • systemEvent

      public static DecisionTrigger systemEvent(String eventType, Map<String,Object> context)
      Creates a trigger from a system event.
      Parameters:
      eventType - event type identifier
      context - event context data
      Returns:
      new DecisionTrigger
    • scheduled

      public static DecisionTrigger scheduled(String taskName)
      Creates a trigger from a scheduled task.
      Parameters:
      taskName - name of the scheduled task
      Returns:
      new DecisionTrigger
    • agentRequest

      public static DecisionTrigger agentRequest(String description, String agentId)
      Creates a trigger from another agent.
      Parameters:
      description - what the agent requested
      agentId - requesting agent identifier
      Returns:
      new DecisionTrigger
    • goalActivation

      public static DecisionTrigger goalActivation(String goalDescription)
      Creates a trigger from a goal activation.
      Parameters:
      goalDescription - description of the goal
      Returns:
      new DecisionTrigger
    • beliefChange

      public static DecisionTrigger beliefChange(String beliefDescription, String changeType)
      Creates a trigger from a belief change.
      Parameters:
      beliefDescription - description of the changed belief
      changeType - type of change (added, modified, removed)
      Returns:
      new DecisionTrigger
    • manual

      public static DecisionTrigger manual(String description)
      Creates a manual trigger for debugging/testing.
      Parameters:
      description - description of the manual trigger
      Returns:
      new DecisionTrigger
    • isUserInitiated

      public boolean isUserInitiated()
      Returns true if this trigger was from a user.
    • isSystemInitiated

      public boolean isSystemInitiated()
      Returns true if this trigger was from the system.
    • 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.
    • type

      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • description

      public String description()
      Returns the value of the description record component.
      Returns:
      the value of the description record component
    • source

      public String source()
      Returns the value of the source record component.
      Returns:
      the value of the source record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Returns:
      the value of the timestamp record component
    • context

      public Map<String,Object> context()
      Returns the value of the context record component.
      Returns:
      the value of the context record component