Class: Aidp::Watch::CiLogExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/aidp/watch/ci_log_extractor.rb

Overview

Intelligently extracts relevant failure information from CI logs to reduce token usage when analyzing failures with AI.

Instead of feeding full CI output to AI, this creates a tailored extraction script for each failure type, runs it, and provides only the relevant excerpts.

Constant Summary collapse

MAX_EXTRACTED_SIZE =

Maximum size for extracted log content (in characters)

10_000

Instance Method Summary collapse

Constructor Details

#initialize(provider_manager:) ⇒ CiLogExtractor

Returns a new instance of CiLogExtractor.



19
20
21
# File 'lib/aidp/watch/ci_log_extractor.rb', line 19

def initialize(provider_manager:)
  @provider_manager = provider_manager
end

Instance Method Details

#extract_failure_info(check:, check_run_url: nil) ⇒ Hash

Extract relevant failure information from a CI check

Parameters:

  • check (Hash)

    Failed check information

  • check_run_url (String) (defaults to: nil)

    URL to the GitHub Actions run (optional)

Returns:

  • (Hash)

    Extracted failure info with :summary, :details, :script_used



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/aidp/watch/ci_log_extractor.rb', line 28

def extract_failure_info(check:, check_run_url: nil)
  Aidp.log_debug("ci_log_extractor", "extract_start",
    check_name: check[:name],
    has_output: !check[:output].nil?)

  # If we have structured output from the check, use it
  if check[:output] && check[:output]["summary"]
    return extract_from_structured_output(check)
  end

  # If we have a check run URL, fetch the logs
  if check_run_url
    raw_logs = fetch_check_logs(check_run_url)
    return extract_from_raw_logs(check: check, raw_logs: raw_logs) if raw_logs
  end

  # Fallback: minimal information
  {
    summary: "Check '#{check[:name]}' failed",
    details: check[:output]&.dig("text") || "No additional details available",
    extraction_method: "fallback"
  }
end