Class: Ace::Test::EndToEndRunner::Atoms::SkillResultParser

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/test/end_to_end_runner/atoms/skill_result_parser.rb

Overview

Parses structured markdown results from CLI-provider skill/workflow execution

CLI providers return results in the subagent return contract format:

- **Test ID**: TS-LINT-001
- **Status**: pass
- **Passed**: 8
- **Failed**: 0
- **Total**: 8
- **Report Paths**: 8p5jo2-lint-ts001-reports/*
- **Observations**: None
- **Issues**: None

Falls back to ResultParser.parse() for JSON responses.

Class Method Summary collapse

Class Method Details

.parse(text) ⇒ Hash

Parse response text from a CLI provider

Parameters:

  • text (String)

    Raw response text

Returns:

  • (Hash)

    Parsed result with :test_id, :status, :test_cases, :summary, :observations

Raises:



26
27
28
29
30
31
32
33
34
# File 'lib/ace/test/end_to_end_runner/atoms/skill_result_parser.rb', line 26

def self.parse(text)
  raise ResultParser::ParseError, "Empty response from CLI provider" if text.nil? || text.strip.empty?

  parsed = parse_markdown(text)
  return to_normalized(parsed) if parsed

  # Fall back to JSON parsing via ResultParser
  ResultParser.parse(text)
end

.parse_tc(text) ⇒ Hash

Parse TC-level response text from a CLI provider

Handles TC-level markdown with **TC ID** field. Falls back to parse() if the response has the multi-TC format.

Parameters:

  • text (String)

    Raw response text

Returns:

  • (Hash)

    Parsed result with single-entry :test_cases array

Raises:



107
108
109
110
111
112
113
114
115
# File 'lib/ace/test/end_to_end_runner/atoms/skill_result_parser.rb', line 107

def self.parse_tc(text)
  raise ResultParser::ParseError, "Empty response from CLI provider" if text.nil? || text.strip.empty?

  parsed = parse_tc_markdown(text)
  return to_tc_normalized(parsed) if parsed

  # Fall back to standard parse (handles both markdown and JSON)
  parse(text)
end

.parse_verifier(text) ⇒ Hash

Parse verifier-mode markdown return contract.

Parameters:

  • text (String)

Returns:

  • (Hash)

    Normalized test result payload

Raises:



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/ace/test/end_to_end_runner/atoms/skill_result_parser.rb', line 121

def self.parse_verifier(text)
  raise ResultParser::ParseError, "Empty response from CLI provider" if text.nil? || text.strip.empty?

  fields = {}
  fields[:test_id] = extract_field(text, "Test ID")
  fields[:status] = extract_field(text, "Status")
  fields[:tcs_passed] = extract_field(text, "TCs Passed")
  fields[:tcs_failed] = extract_field(text, "TCs Failed")
  fields[:tcs_total] = extract_field(text, "TCs Total")
  fields[:score] = extract_field(text, "Score")
  fields[:verdict] = extract_field(text, "Verdict")
  fields[:failed_tcs] = extract_field(text, "Failed TCs")
  fields[:issues] = extract_field(text, "Issues")

  return parse_minimal_verifier(text) unless fields[:test_id] && fields[:status]
  return parse(text) unless fields[:tcs_passed] && fields[:tcs_failed] && fields[:tcs_total]

  passed = fields[:tcs_passed].to_i
  failed = fields[:tcs_failed].to_i
  total = fields[:tcs_total].to_i
  status = normalize_status(fields[:status])

  failed_entries = parse_failed_tcs(fields[:failed_tcs])
  failed_ids = failed_entries.map { |e| e[:tc] }.to_set
  test_cases = []
  pass_index = 0
  passed.times do
    pass_index += 1
    pass_index += 1 while failed_ids.include?("TC-#{format("%03d", pass_index)}")
    test_cases << {id: "TC-#{format("%03d", pass_index)}", description: "", status: "pass", actual: "", notes: ""}
  end
  if failed_entries.empty?
    failed.times do |i|
      test_cases << {id: "TC-#{format("%03d", passed + i + 1)}", description: "", status: "fail", actual: "", notes: ""}
    end
  else
    failed_entries.each do |entry|
      test_cases << {
        id: entry[:tc],
        description: "",
        status: "fail",
        actual: "",
        notes: entry[:category],
        category: entry[:category]
      }
    end
  end

  summary = if total.positive?
    "#{passed}/#{total} passed (#{fields[:verdict] || status})"
  else
    fields[:verdict] || status
  end

  {
    test_id: fields[:test_id],
    status: status,
    test_cases: test_cases,
    summary: summary,
    observations: (fields[:issues].to_s.strip.casecmp("none").zero? ? "" : fields[:issues].to_s)
  }
end