Class: AISpec::Core::Reporters::Markdown

Inherits:
Base
  • Object
show all
Defined in:
lib/aispec/core/reporters/markdown.rb

Instance Attribute Summary

Attributes inherited from Base

#output_io, #results

Instance Method Summary collapse

Methods inherited from Base

get, #initialize, register

Constructor Details

This class inherits a constructor from AISpec::Core::Reporters::Base

Instance Method Details

#renderObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/aispec/core/reporters/markdown.rb', line 7

def render
  contract = results[:contract]
  stats = results[:statistics]
  summary = stats.summary

  md = []
  md << "## AISpec Contract Verification Report: `#{contract.name}`"
  md << ""
  md << "| Metric | Value |"
  md << "| ------ | ----- |"
  md << "| **Provider / Model** | `#{results[:provider_name]}` / `#{results[:model]}` |"
  md << "| **Behavior Score** | **#{summary[:success_rate]}%** (Confidence ±#{summary[:confidence_interval]}%) |"
  md << "| **Assertions Passed** | #{summary[:passed_assertions]} / #{summary[:total_assertions]} |"
  md << "| **Mean Latency** | #{summary[:mean_latency]}ms |"
  md << "| **Total Cost** | $#{sprintf('%.4f', summary[:total_cost])} |"
  md << "| **Judge Score** | #{summary[:average_judge_score] || 'N/A'} |"
  md << "| **Variance** | #{summary[:variance]} |"
  md << "| **Recommendation** | **#{summary[:recommendation]}** |"
  md << ""
  md << "### Assertion Breakdown"
  md << ""

  results[:runs].each_with_index do |run, i|
    md << "#### Case ##{i + 1}: `#{run[:input]}`"
    run[:assertion_results].each do |ar|
      badge = ar.passed? ? "✅ PASS" : "❌ FAIL"
      md << "- #{badge} **#{ar.name}**: #{ar.message}"
    end
    md << ""
  end

  text = md.join("\n")
  output_io.puts text
  text
end