Class ManualConsumeEngine

java.lang.Object
org.egothor.methodatlas.ai.ManualConsumeEngine
All Implemented Interfaces:
AiSuggestionEngine

public final class ManualConsumeEngine extends Object implements AiSuggestionEngine
Handles the consume phase of the manual AI workflow.

For each test class this engine looks for a response file <fqcn>.response.txt in the configured response directory. If the file is present its content is parsed as an AI classification result and the extracted suggestions are returned normally. If the file is absent an empty suggestion is returned, which results in blank AI columns for that class in the final CSV.

This engine implements AiSuggestionEngine so it can be used as a drop-in replacement for network-based engines in the standard scan loop. The classSource parameter passed to suggestForClass(java.lang.String, java.lang.String, java.lang.String, java.util.List<org.egothor.methodatlas.ai.PromptBuilder.TargetMethod>) is ignored because the AI has already processed the source during the prepare phase.

Response file format

The response file may contain free-form text (for example the operator may have copied the AI response verbatim from the chat window). The engine extracts the first JSON object found in the file using JsonText.extractFirstJsonObject(java.lang.String) and deserializes it into an AiClassSuggestion. Any surrounding prose or formatting is silently discarded.

See Also:
  • Constructor Details

    • ManualConsumeEngine

      public ManualConsumeEngine(Path responseDir)
      Creates a new consume engine that reads response files from the given directory.
      Parameters:
      responseDir - path to the directory containing operator-saved response files
  • Method Details

    • suggestForClass

      public AiClassSuggestion suggestForClass(String fileStem, String fqcn, String classSource, List<PromptBuilder.TargetMethod> targetMethods) throws AiSuggestionException
      Returns AI classification results for the specified class by reading the corresponding response file.

      The response file is looked up as <fileStem>.response.txt in the configured response directory, where fileStem is the dot-separated path identifier computed from the source file's location relative to the scan root (e.g. module-a.src.test.java.com.acme.FooTest). If the file does not exist an empty AiClassSuggestion is returned so the caller emits blank AI columns rather than failing.

      Specified by:
      suggestForClass in interface AiSuggestionEngine
      Parameters:
      fileStem - dot-separated path stem used to locate the response file (<fileStem>.response.txt)
      fqcn - fully qualified class name; included in the returned suggestion for identification
      classSource - ignored — the AI already saw the source during the prepare phase
      targetMethods - ignored — method classification is read from the response file
      Returns:
      parsed and normalized suggestion, or an empty suggestion when no response file exists
      Throws:
      AiSuggestionException - if the response file exists but cannot be read or does not contain a valid JSON object
      See Also: