Class PromptBuilder

java.lang.Object
org.egothor.methodatlas.ai.PromptBuilder

public final class PromptBuilder extends Object
Utility responsible for constructing the prompt supplied to AI providers for security classification of JUnit test classes.

The prompt produced by this class combines several components into a single instruction payload:

  • classification instructions for the AI model
  • a controlled security taxonomy definition
  • strict output formatting rules
  • the fully qualified class name
  • the complete source code of the analyzed test class

This revision keeps the full class source as semantic context but removes method discovery from the AI model. The caller supplies the exact list of JUnit test methods that must be classified, optionally with source line anchors.

The resulting prompt is passed to the configured AI provider and instructs the model to produce a deterministic JSON classification result describing security relevance and taxonomy tags for individual test methods.

The prompt enforces a closed taxonomy and strict JSON output rules to ensure that the returned content can be parsed reliably by the application.

This class is a non-instantiable utility holder.

See Also:
  • Method Details

    • build

      public static String build(String fqcn, String classSource, String taxonomyText, List<PromptBuilder.TargetMethod> targetMethods, boolean confidence)
      Builds the complete prompt supplied to an AI provider for security classification of a JUnit test class.

      The generated prompt contains:

      • task instructions describing the classification objective
      • the security taxonomy definition controlling allowed tags
      • the exact list of target test methods to classify
      • strict output rules enforcing JSON-only responses
      • a formal JSON schema describing the expected result structure
      • the fully qualified class name of the analyzed test class
      • the complete class source used as analysis input

      The taxonomy text supplied to this method is typically obtained from either DefaultSecurityTaxonomy.text() or OptimizedSecurityTaxonomy.text(), depending on the selected AiOptions.TaxonomyMode.

      The returned prompt is intended to be used as the content of a user message in chat-based inference APIs.

      Parameters:
      fqcn - fully qualified class name of the test class being analyzed
      classSource - complete source code of the test class
      taxonomyText - taxonomy definition guiding classification
      targetMethods - exact list of deterministically discovered JUnit test methods to classify
      confidence - when true, the prompt instructs the AI to include a confidence score for each method classification
      Returns:
      formatted prompt supplied to the AI provider
      See Also: