import { Callout } from "./components/Callout";
import { Link } from "react-router-dom";

const v100Changes = {
  features: [
    "AI proxy with OpenAI-compatible API (/v1/chat/completions)",
    "3-layer PII detection: regex + spaCy NER + LLM validation",
    "PII pseudonymization with AES-256-GCM Redis mappings",
    "Intelligent routing engine (PostgreSQL JSONB rules, in-memory cache, priority ASC)",
    "RBAC: admin, manager, user, auditor roles with model restrictions",
    "Streaming SSE support (PII anonymization on request, not response)",
    "Circuit breaker per provider (threshold=5, TTL=60s) with fallback chain",
    "Token-bucket rate limiting (per-tenant + per-user, DB overrides)",
    "ClickHouse append-only audit logs with async batch writer",
    "GDPR Article 30 processing registry with PDF/JSON export",
    "EU AI Act risk classification questionnaire (forbidden/high/limited/minimal)",
    "DPIA template generation",
    "GDPR Art. 15 (Right of Access) and Art. 17 (Right to Erasure) endpoints",
    "Feature flags (PostgreSQL + in-memory fallback)",
    "React 18 dashboard with 11 pages (French UI)",
    "Public AI playground at /playground (IP rate-limited 20/min)",
    "Swagger UI at /docs",
    "Provider adapters: OpenAI, Anthropic, Azure, Mistral, Ollama",
    "Prometheus metrics + Grafana dashboards (overview + SLO)",
    "7 Prometheus alerts with Alertmanager (PagerDuty + Slack)",
    "HPA autoscaling 3→15 replicas (CPU 70% + memory 80%)",
    "Blue/green deployment with Istio VirtualService (<5s rollback)",
    "Terraform EKS v1.31, 3-AZ, eu-west-3",
    "PostgreSQL backup CronJob (daily 02:00 UTC, S3, 7-day retention)",
    "k6 load tests: smoke, load, stress, soak scenarios",
    "HashiCorp Vault integration for API key rotation (90-day cycle)",
    "AES-256-GCM prompt encryption",
    "Production SLO dashboard (99.5% availability)",
    "6 operational runbooks",
    "Admin guide + integration guide + onboarding scripts",
    "Pentest scope + remediation report (0 Critical, 0 High)",
    "Commercial materials: one-pager, pitch deck, battle card",
    "CHANGELOG.md with full v1.0.0 history",
    "GitHub Actions release pipeline (multi-arch Docker + Helm OCI + GitHub Release)",
  ],
  bugfixes: [
    "Rate limit 429 responses now include Retry-After: 1 header (RFC 6585)",
    "CSP header updated to allow dashboard iframe embeds",
    "CORS allowed origins now configurable (server.allowed_origins) instead of wildcard",
    "Routing rule cache race condition on concurrent updates fixed",
  ],
};

const v110Roadmap = [
  { priority: "Must-have", item: "Layer 3 LLM validation for PII (ambiguous cases)" },
  { priority: "Must-have", item: "Per-routing-rule PII control (enable/disable per rule)" },
  { priority: "Must-have", item: "Native OpenAI SDK (Go) for seamless migration" },
  { priority: "Should-have", item: "ML anomaly detection on prompt patterns" },
  { priority: "Should-have", item: "Shadow AI discovery (network traffic analysis)" },
  { priority: "Should-have", item: "Physical multi-tenant isolation (separate DB schemas)" },
  { priority: "Should-have", item: "SIEM integrations (Splunk, Elastic)" },
  { priority: "Could-have", item: "Custom model adapters via plugin API" },
  { priority: "Could-have", item: "Prompt caching (provider-level + in-proxy)" },
  { priority: "Could-have", item: "Cost budget alerts via email/Slack (direct)" },
];

export function ChangelogPage() {
  return (
    <div>
      <h1 id="changelog">Changelog</h1>
      <p>
        All notable changes to Veylant IA are documented here. Versioning follows{" "}
        <a
          href="https://semver.org"
          target="_blank"
          rel="noopener noreferrer"
          className="text-primary hover:underline"
        >
          Semantic Versioning
        </a>
        .
      </p>

      <h2 id="v100">v1.0.0 — February 25, 2026</h2>
      <Callout type="tip" title="General Availability">
        First production release. Pentest passed (0 Critical, 0 High). 2 pilot clients migrated.
      </Callout>

      <h3 id="features">Features</h3>
      <ul className="space-y-1">
        {v100Changes.features.map((f) => (
          <li key={f} className="text-sm text-muted-foreground leading-relaxed">
            {f}
          </li>
        ))}
      </ul>

      <h3 id="bug-fixes">Bug Fixes</h3>
      <ul className="space-y-1">
        {v100Changes.bugfixes.map((b) => (
          <li key={b} className="text-sm text-muted-foreground leading-relaxed">
            {b}
          </li>
        ))}
      </ul>

      <h2 id="v110-roadmap">v1.1.0 — Planned (Q2 2026)</h2>
      <p className="text-muted-foreground text-sm">
        Priorities sourced from 2 pilot client sessions (MoSCoW method). See{" "}
        <code>docs/feedback-backlog.md</code> for the full backlog.
      </p>

      <div className="overflow-x-auto my-4">
        <table className="w-full text-sm border rounded-lg overflow-hidden">
          <thead>
            <tr className="bg-muted/50 border-b">
              <th className="text-left px-4 py-2.5 font-semibold">Priority</th>
              <th className="text-left px-4 py-2.5 font-semibold">Feature</th>
            </tr>
          </thead>
          <tbody>
            {v110Roadmap.map((item) => (
              <tr key={item.item} className="border-b last:border-0">
                <td className="px-4 py-2.5">
                  <span
                    className={`text-xs px-1.5 py-0.5 rounded font-medium ${
                      item.priority === "Must-have"
                        ? "bg-red-100 dark:bg-red-900/40 text-red-700 dark:text-red-300"
                        : item.priority === "Should-have"
                        ? "bg-amber-100 dark:bg-amber-900/40 text-amber-700 dark:text-amber-300"
                        : "bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300"
                    }`}
                  >
                    {item.priority}
                  </span>
                </td>
                <td className="px-4 py-2.5 text-sm text-muted-foreground">{item.item}</td>
              </tr>
            ))}
          </tbody>
        </table>
      </div>

      <h2 id="migration">Migration & Compatibility</h2>
      <p>
        V1.0.0 has no breaking changes from the beta releases used by pilot clients. The{" "}
        <code>/v1/chat/completions</code> API is fully backward-compatible with the OpenAI API
        format. Any client using the OpenAI SDK will continue to work without changes.
      </p>
      <p>
        See the <Link to="/docs/installation/docker">Installation guide</Link> for upgrade
        instructions from beta.
      </p>
    </div>
  );
}
