Class ActionNameCollisionValidator

java.lang.Object
com.tnsai.agents.validation.validators.ActionNameCollisionValidator
All Implemented Interfaces:
Validator

public final class ActionNameCollisionValidator extends Object implements Validator
AGENT-V008 — @ActionSpec method names must be unique across every role attached to an agent.

The framework dispatches actions by name (see ActionExecutor). When two roles each declare an action with the same name, the executor's name → action map silently keeps whichever role was registered last; the earlier one is shadowed. The runtime symptom is "the wrong implementation ran" — a class of bug that's painful to track down because nothing ever throws and nothing logs the shadowing.

This validator collects every

invalid reference
ActionMetadata#getName()
from every Role.getActions(), groups by name, and emits one ERROR per duplicated name. The error context lists every offending role class so the operator can see at a glance which roles need to disambiguate.

Intra-role duplicates are impossible — Java method dispatch already prevents two methods with the same name from coexisting after annotation processing collapses to ActionMetadata. The check here is strictly cross-role.

Empty action names are skipped — they indicate a metadata bug elsewhere (probably the discovery layer) and would produce noise rather than signal in this report.

Suppress with AgentBuilder.relaxValidation("AGENT-V008") — useful when the operator has wired an ActionExecutor subclass that disambiguates by role+name (rare but legitimate, e.g. multi-tenant role isolation).

Since:
0.5.0 (issue #85 slice)
  • Constructor Details

    • ActionNameCollisionValidator

      public ActionNameCollisionValidator()
  • Method Details

    • id

      public String id()
      Description copied from interface: Validator
      Short, stable id for logging and test assertions (e.g. "llm-presence").
      Specified by:
      id in interface Validator
    • validate

      public List<ValidationIssue> validate(ValidationContext ctx)
      Description copied from interface: Validator
      Inspect the agent configuration and return any issues detected. Returning an empty list means "no problems found by this validator".
      Specified by:
      validate in interface Validator
      Parameters:
      ctx - frozen view of the agent under construction
      Returns:
      zero-or-more issues; never null