Class ContractExpressionValidator

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

public final class ContractExpressionValidator extends Object implements Validator
Build-time syntax check for declarative @Contract expressions (AGENT-V013). Each JEXL clause — every preconditions, postconditions and invariants entry on an action's @Contract — is parsed via ContractEvaluator.checkSyntax(String). A malformed expression is reported as a Severity.WARNING so it surfaces at AgentBuilder.build() instead of failing fail-closed on the first invocation (where ContractValidator would throw a ContractViolationException "could not be evaluated").

Pure metadata check — only actions backed by a reflective Method (i.e. @ActionSpec methods) can carry a @Contract; builder / handler actions have no method and are skipped. Suppress with .relaxValidation("AGENT-V013").

Since:
0.12.0 (TNS-637 phase 5)
  • Constructor Details

    • ContractExpressionValidator

      public ContractExpressionValidator()
  • 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