Class DefaultHierarchy

java.lang.Object
com.tnsai.coordination.groups.DefaultAgentGroup
com.tnsai.coordination.groups.hierarchy.DefaultHierarchy
All Implemented Interfaces:
com.tnsai.agents.groups.AgentGroup, Hierarchy

public class DefaultHierarchy extends DefaultAgentGroup implements Hierarchy
Default implementation of Hierarchy.

Provides a tree-based organization structure with parent-child relationships, task delegation down the chain, and escalation up.

  • Constructor Details

    • DefaultHierarchy

      public DefaultHierarchy(String id, String name, String description, com.tnsai.agents.groups.GroupPolicy policy)
      Creates a new DefaultHierarchy.
      Parameters:
      id - hierarchy ID
      name - hierarchy name
      description - hierarchy description
      policy - group policy
  • Method Details

    • getRoot

      public Optional<com.tnsai.agents.Agent> getRoot()
      Description copied from interface: Hierarchy
      Returns the root agent of the hierarchy.
      Specified by:
      getRoot in interface Hierarchy
      Returns:
      root agent
    • setRoot

      public void setRoot(String agentId)
      Sets the root agent of the hierarchy.
      Parameters:
      agentId - root agent ID
      Throws:
      IllegalArgumentException - if agent is not a member
    • getSupervisor

      public Optional<com.tnsai.agents.Agent> getSupervisor(String agentId)
      Description copied from interface: Hierarchy
      Returns the supervisor of a given agent.
      Specified by:
      getSupervisor in interface Hierarchy
      Parameters:
      agentId - agent ID
      Returns:
      supervisor, or empty if agent is root or not found
    • getSubordinates

      public List<com.tnsai.agents.Agent> getSubordinates(String agentId)
      Description copied from interface: Hierarchy
      Returns the direct subordinates of a given agent.
      Specified by:
      getSubordinates in interface Hierarchy
      Parameters:
      agentId - agent ID
      Returns:
      list of subordinate agents
    • getReportingChain

      public List<com.tnsai.agents.Agent> getReportingChain(String agentId)
      Description copied from interface: Hierarchy
      Returns the full reporting chain from root to the given agent.
      Specified by:
      getReportingChain in interface Hierarchy
      Parameters:
      agentId - agent ID
      Returns:
      list of agents from root to the target (inclusive)
    • getReportingLines

      public List<ReportingLine> getReportingLines()
      Description copied from interface: Hierarchy
      Returns all reporting lines in the hierarchy.
      Specified by:
      getReportingLines in interface Hierarchy
      Returns:
      list of reporting lines
    • getLevel

      public int getLevel(String agentId)
      Description copied from interface: Hierarchy
      Returns the depth level of an agent in the hierarchy. Root is level 0.
      Specified by:
      getLevel in interface Hierarchy
      Parameters:
      agentId - agent ID
      Returns:
      level, or -1 if not found
    • setReportingLine

      public void setReportingLine(String parentId, String childId)
      Description copied from interface: Hierarchy
      Sets a parent-child relationship.
      Specified by:
      setReportingLine in interface Hierarchy
      Parameters:
      parentId - parent agent ID
      childId - child agent ID
    • delegate

      public HierarchyResult delegate(String task, int targetLevel)
      Description copied from interface: Hierarchy
      Delegates a task down to a specific level in the hierarchy.
      Specified by:
      delegate in interface Hierarchy
      Parameters:
      task - task description
      targetLevel - target hierarchy level (0=root)
      Returns:
      delegation result
    • escalate

      public HierarchyResult escalate(String task, String fromAgentId)
      Description copied from interface: Hierarchy
      Escalates a task up from a given agent to their supervisor.
      Specified by:
      escalate in interface Hierarchy
      Parameters:
      task - task description
      fromAgentId - agent escalating the task
      Returns:
      escalation result
    • getDelegationChain

      public DelegationChain getDelegationChain()
      Description copied from interface: Hierarchy
      Returns the delegation chain history.
      Specified by:
      getDelegationChain in interface Hierarchy
      Returns:
      delegation chain
    • toString

      public String toString()
      Overrides:
      toString in class DefaultAgentGroup