<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>frenum — guardrail regression test report</title>
<style>
  :root { --pass: #22c55e; --fail: #ef4444; --bg: #ffffff; --border: #d1d5db; --muted: #6b7280; }
  body { font-family: system-ui, -apple-system, sans-serif; max-width: 960px; margin: 2rem auto; padding: 0 1rem; color: #1f2937; }
  h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
  .meta { color: var(--muted); font-size: 0.875rem; margin-bottom: 1.5rem; }
  .meta code { background: #f3f4f6; padding: 0.125rem 0.375rem; border-radius: 3px; font-size: 0.8rem; }
  .summary { display: flex; gap: 2rem; margin-bottom: 1.5rem; }
  .stat { text-align: center; }
  .stat .num { font-size: 2rem; font-weight: 700; }
  .stat .label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; }
  table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
  th, td { border: 1px solid var(--border); padding: 0.5rem 0.75rem; text-align: left; font-size: 0.875rem; }
  th { background: #f9fafb; font-weight: 600; }
  .pass { color: var(--pass); font-weight: 700; }
  .fail { color: var(--fail); font-weight: 700; }
  .coverage-bar { background: #e5e7eb; border-radius: 4px; height: 1.5rem; position: relative; margin: 0.5rem 0; }
  .coverage-fill { background: var(--pass); border-radius: 4px; height: 100%; transition: width 0.3s; }
  .coverage-label { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-weight: 700; font-size: 0.875rem; }
  .section { margin-top: 2rem; }
  ul { padding-left: 1.25rem; }
  li { margin: 0.25rem 0; font-size: 0.875rem; }
  footer { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.75rem; }
</style>
</head>
<body>

<h1>frenum — guardrail regression test report</h1>
<div class="meta">
  Timestamp: {{ timestamp }}<br>
  {% if policy_hash %}Policy hash: <code>{{ policy_hash[:16] }}...</code><br>{% endif %}
  Evidence hash: <code>{{ evidence_hash[:16] }}...</code>
</div>

<div class="summary">
  <div class="stat">
    <div class="num">{{ summary.total }}</div>
    <div class="label">Total</div>
  </div>
  <div class="stat">
    <div class="num pass">{{ summary.passed }}</div>
    <div class="label">Passed</div>
  </div>
  <div class="stat">
    <div class="num fail">{{ summary.failed }}</div>
    <div class="label">Failed</div>
  </div>
</div>

<div class="section">
  <h2>Test Results</h2>
  <table>
    <thead>
      <tr><th>Test</th><th>Tool</th><th>Expected</th><th>Actual</th><th>Rule</th><th>Status</th></tr>
    </thead>
    <tbody>
      {% for t in tests %}
      <tr>
        <td>{{ t.description }}</td>
        <td>{{ t.tool }}</td>
        <td>{{ t.expected }}</td>
        <td>{{ t.actual }}</td>
        <td>{{ t.rule }}</td>
        <td class="{{ 'pass' if t.passed else 'fail' }}">{{ "PASS" if t.passed else "FAIL" }}</td>
      </tr>
      {% endfor %}
    </tbody>
  </table>
</div>

<div class="section">
  <h2>Guardrail Coverage</h2>
  <div class="coverage-bar">
    <div class="coverage-fill" style="width: {{ coverage.coverage_pct }}%"></div>
    <div class="coverage-label">{{ coverage.coverage_pct }}%</div>
  </div>
  <p>{{ coverage.rules_exercised | length }} / {{ coverage.total_deterministic_rules }} deterministic rules exercised</p>

  {% if coverage.rules_not_exercised %}
  <h3>Rules Not Exercised</h3>
  <ul>
    {% for rule in coverage.rules_not_exercised %}
    <li>{{ rule }}</li>
    {% endfor %}
  </ul>
  {% endif %}

  {% if coverage.semantic_rules %}
  <h3>Semantic Rules (manual validation required)</h3>
  <ul>
    {% for rule in coverage.semantic_rules %}
    <li>{{ rule }}</li>
    {% endfor %}
  </ul>
  {% endif %}
</div>

<footer>
  Generated by <strong>frenum</strong> — guardrail lifecycle for LLM agent tool calls
</footer>

</body>
</html>
