Module: Evilution::MCP::MutateTool::ReportTrimmer

Defined in:
lib/evilution/mcp/mutate_tool/report_trimmer.rb

Constant Summary collapse

MINIMAL_KEYS =
%w[summary survived].freeze
FULL_DIFF_STRIP_KEYS =
%w[killed neutral equivalent unresolved unparseable].freeze
SUMMARY_DROP_KEYS =
%w[killed neutral equivalent unparseable].freeze
SUMMARY_HEAVY_FIELDS =

EV-187j / GH #1169: at summary verbosity, non-survived entries that remain (timed_out, errors, unresolved) shed ‘diff` and `error_backtrace` payload —those two fields dominate response size at scale and aren’t actionable for a scanning agent. Survived stays full-detail.

%w[diff error_backtrace].freeze
SUMMARY_TRIM_KEYS =
%w[timed_out errors unresolved].freeze
ERROR_SAMPLE_LIMIT =

EV-t7kh / GH #1170: at minimal verbosity we surface a small sample of any errored mutations so agents are not stuck in a diagnose-vs-token-cap deadlock when a run is partly-broken. Bounded to keep the payload tiny.

3
ERROR_BACKTRACE_HEAD_LINES =
5
ERROR_SAMPLE_KEYS =
%w[operator file line error_message error_class].freeze

Class Method Summary collapse

Class Method Details

.call(json_string, verbosity:, survived_results:, config:, enricher:, summary: nil) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/evilution/mcp/mutate_tool/report_trimmer.rb', line 28

def self.call(json_string, verbosity:, survived_results:, config:, enricher:, summary: nil)
  data = ::JSON.parse(json_string)
  case verbosity
  when "full"
    FULL_DIFF_STRIP_KEYS.each { |key| strip_diffs(data, key) }
  when "summary"
    SUMMARY_DROP_KEYS.each { |key| data.delete(key) }
    SUMMARY_TRIM_KEYS.each { |key| strip_heavy_fields(data, key) }
  when "minimal"
    apply_minimal(data)
  end
  enricher.call(data, survived_results, config)
  embed_feedback(data, summary) unless verbosity == "minimal"
  embed_setup_warning(data, summary)
  ::JSON.generate(data)
end