Class ForbiddenTermScanner

java.lang.Object
com.agentforge4j.testkit.assertion.ForbiddenTermScanner

public final class ForbiddenTermScanner extends Object
Generic, reusable scanner asserting that a configurable set of forbidden terms is absent from a tree of shipped OSS resource files (workflow definitions, agent bundles, prompts, verification fixtures, examples). It complements the run-output check WorkflowRunAssert.outputsHaveNoForbiddenTerms(Collection): that one scans a run's context and captured files, this one scans resource files on disk that never flow through a run.

Matching is case-insensitive and substring-based. Files are read as UTF-8 text; a file that is not valid UTF-8 is skipped as non-text. Callers pass a fileFilter to scope the scan to the text resource kinds they care about (for example .json / .md).

  • Method Details

    • scan

      public static List<ForbiddenTermScanner.Violation> scan(Path root, Collection<String> forbiddenTerms, Predicate<Path> fileFilter)
      Scans every regular file under root that matches fileFilter for any forbidden term.
      Parameters:
      root - the resource-tree root to scan; must not be null
      forbiddenTerms - the terms that must be absent; must not be empty
      fileFilter - selects which files to scan; must not be null
      Returns:
      all violations found, in file then line order (empty when clean)
    • assertNoForbiddenTerms

      public static void assertNoForbiddenTerms(Path root, Collection<String> forbiddenTerms, Predicate<Path> fileFilter)
      Scans root and throws an AssertionError listing every violation when any forbidden term is found.
      Parameters:
      root - the resource-tree root to scan; must not be null
      forbiddenTerms - the terms that must be absent; must not be empty
      fileFilter - selects which files to scan; must not be null