All files / src/app/docs/developer/quality-gates page.tsx

100% Statements 68/68
85.71% Branches 18/21
100% Functions 23/23
100% Lines 68/68

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 16481x                                                       1x   1x   1x     1x 1x     1x 387x       1x 1x                         1x   1x     1x 1x               1x   1x 1x   1x 1x 1x   1x 1x 1x   1x   1x   1x 1x   1x 1x   1x 1x     1x       1x 11x                             1141x                                           385x               196x       84x       84x       56x         105x     231x                                         1x                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         1x 4x             1x                 1x                 1x             1x                     1x 8x                                   1x                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         1x               1x                                                                                                                                                                                                                                                                                                   126x                       70x             70x                           7x 7x                                                                           56x                                                                                                   252x                                                                                                                                                                                                     112x                                                                                                                                                                                                                                                                         56x                                                         189x                                                                                             28x                                                                                                         70x 70x                                                                                                                             119x                                                                                                                                                      
"use client";
 
import Link from "next/link";
import type { ReactNode } from "react";
import {
  ArrowLeft,
  ShieldCheck,
  FlaskConical,
  Lock,
  Gauge,
  FileCheck,
  Scale,
  Boxes,
  Accessibility,
  Server,
  RefreshCw,
} from "lucide-react";
import MermaidDiagram from "@/components/MermaidDiagram";
import { DocsLastUpdated } from "@/components/docs/DocsLastUpdated";
import facts from "@/app/docs/docs-facts.json";
import { localizedChart } from "@/lib/i18n/diagrams";
import { useLanguage } from "@/lib/use-language";
 
/* ------------------------------------------------------------------ */
/*  Sources                                                            */
/* ------------------------------------------------------------------ */
 
const CI_WORKFLOW_URL =
  "https://github.com/ma3u/MinimumViableHealthDataspacev2/actions/workflows/test.yml";
const COMPLIANCE_WORKFLOW_URL =
  "https://github.com/ma3u/MinimumViableHealthDataspacev2/actions/workflows/compliance.yml";
const PAGES_WORKFLOW_URL =
  "https://github.com/ma3u/MinimumViableHealthDataspacev2/actions/workflows/pages.yml";
 
const REPO_BLOB =
  "https://github.com/ma3u/MinimumViableHealthDataspacev2/blob/main/";
const ISSUES = "https://github.com/ma3u/MinimumViableHealthDataspacev2/issues/";
 
/** A file in this repository, at a line or a range (`L12-L20`). */
const repo = (path: string, lines?: string) =>
  `${REPO_BLOB}${path}${lines ? `#${lines}` : ""}`;
 
/** BSI C5:2020, the English catalogue; a criterion links to its PDF page. */
const C5_URL =
  "https://www.bsi.bund.de/SharedDocs/Downloads/EN/BSI/CloudComputing/ComplianceControlsCatalogue/2020/C5_2020.pdf?__blob=publicationFile&v=3";
const C5_PAGES = {
  "AM-01": 48, // Asset Inventory
  "OPS-22": 72, // Testing and Documentation of known Vulnerabilities
  "OPS-23": 73, // Managing Vulnerabilities ... System Hardening
  "CRY-04": 83, // Secure key management
  "DEV-01": 91, // Policies for the development/procurement of information systems
  "DEV-06": 94, // Testing changes
  "DEV-09": 95, // Approvals for provision in the production environment
  "PSS-02": 114, // Identification of Vulnerabilities of the Cloud Service
} as const;
type C5Id = keyof typeof C5_PAGES;
 
/** Cyber Resilience Act, Regulation (EU) 2024/2847. */
const CRA_URL = "https://eur-lex.europa.eu/eli/reg/2024/2847/oj/eng";
/** EHDS, Regulation (EU) 2025/327, as adopted. */
const EHDS_URL = "https://eur-lex.europa.eu/eli/reg/2025/327/oj/eng";
 
/** OWASP Top 10, the 2021 edition: its numbering is the one used here. */
const OWASP_TOP10_2021 = "https://top10.owasp.org/2021/";
const OWASP_2021 = {
  A01: "https://top10.owasp.org/2021/A01_2021-Broken_Access_Control/",
  A05: "https://top10.owasp.org/2021/A05_2021-Security_Misconfiguration/",
  A06: "https://top10.owasp.org/2021/A06_2021-Vulnerable_and_Outdated_Components/",
  A07: "https://top10.owasp.org/2021/A07_2021-Identification_and_Authentication_Failures/",
} as const;
type OwaspId = keyof typeof OWASP_2021;
 
const WCAG22_URL = "https://www.w3.org/TR/WCAG22/";
const EN_301_549_URL =
  "https://www.etsi.org/deliver/etsi_en/301500_301599/301549/03.02.01_60/en_301549v030201p.pdf";
const WAD_URL = "https://eur-lex.europa.eu/eli/dir/2016/2102/oj/eng";
const NSA_K8S_URL =
  "https://www.cisa.gov/news-events/alerts/2022/03/15/updated-kubernetes-hardening-guide";
const CIS_K8S_URL = "https://www.cisecurity.org/benchmark/kubernetes";
const CORE_WEB_VITALS_URL = "https://web.dev/articles/vitals";
const NTIA_SBOM_URL =
  "https://www.ntia.gov/sites/default/files/publications/sbom_minimum_elements_report_0.pdf";
const CYCLONEDX_15_URL = "https://cyclonedx.org/docs/1.5/json/";
const CYCLONEDX_17_URL = "https://cyclonedx.org/docs/1.7/json/";
const DSP_URL =
  "https://eclipse-dataspace-protocol-base.github.io/DataspaceProtocol/2025-1/";
const DCP_URL =
  "https://eclipse-dataspace-dcp.github.io/decentralized-claims-protocol/v1.0/";
const DSP_TCK_URL =
  "https://github.com/eclipse-dataspacetck/dsp-tck/releases/tag/v1.0.2";
const DCP_TCK_URL = "https://github.com/eclipse-dataspacetck/dcp-tck/releases";
const ODRL_MODEL_URL =
  "https://www.w3.org/TR/odrl-model/#x2-odrl-information-model";
const OPENAPI_URL = `https://spec.openapis.org/oas/v${facts.openapi.version}.html`;
const JAD_URL =
  "https://github.com/Metaform/jad/tree/4a7e5bd096c58814748e956cc9329586ad309698";
const ADR_074_URL = repo(
  "docs/ADRs/ADR-074-e2e-and-compliance-suites-run-nightly-when-main-changed.md",
);
const ADR_078_URL = repo(
  "docs/ADRs/ADR-078-edc-1-on-container-apps-without-cfm.md",
);
 
const release = (repoPath: string, tag: string) =>
  `https://github.com/${repoPath}/releases/tag/${tag}`;
 
/* ------------------------------------------------------------------ */
/*  Link helpers                                                       */
/* ------------------------------------------------------------------ */
 
function Src({
  href,
  children,
  mono = false,
}: {
  href: string;
  children: ReactNode;
  mono?: boolean;
}) {
  return (
    <a
      href={href}
      target="_blank"
      rel="noopener noreferrer"
      className={`text-(--accent) hover:underline${mono ? " font-mono" : ""}`}
    >
      {children}
    </a>
  );
}
 
/** A repository file, shown by name, linked at its line. */
function RepoFile({
  path,
  lines,
  children,
}: {
  path: string;
  lines?: string;
  children?: ReactNode;
}) {
  return (
    <Src href={repo(path, lines)} mono>
      {children ?? path}
    </Src>
  );
}
 
function C5({ id }: { id: C5Id }) {
  return <Src href={`${C5_URL}#page=${C5_PAGES[id]}`}>C5 {id}</Src>;
}
 
function Owasp({ id }: { id: OwaspId }) {
  return <Src href={OWASP_2021[id]}>OWASP {id}:2021</Src>;
}
 
function Cra({ anchor, children }: { anchor: string; children: ReactNode }) {
  return <Src href={`${CRA_URL}#${anchor}`}>{children}</Src>;
}
 
function Ehds({ art }: { art: number }) {
  return <Src href={`${EHDS_URL}#art_${art}`}>EHDS Art. {art}</Src>;
}
 
/** Elements joined with ", " in a table cell. */
function List({ items }: { items: ReactNode[] }) {
  return (
    <>
      {items.map((item, i) => (
        <span key={i}>
          {i > 0 && ", "}
          {item}
        </span>
      ))}
    </>
  );
}
 
/* ------------------------------------------------------------------ */
/*  Data                                                               */
/* ------------------------------------------------------------------ */
 
interface CiGate {
  job: string;
  tests: string;
  tool: ReactNode;
  blocking: boolean;
  standard: ReactNode;
}
 
const ciGates: CiGate[] = [
  {
    job: "PR Gate",
    tests: "—",
    tool: (
      <>
        <RepoFile path=".github/workflows/pr-gate.yml" lines="L29-L123">
          pr-gate.yml
        </RepoFile>
        : pre-commit on the diff, API spec drift, Bruno coverage, knip, gitleaks
        over the pull request&apos;s commits
      </>
    ),
    blocking: true,
    standard: <C5 id="DEV-09" />,
  },
  {
    job: "CodeQL",
    tests: "—",
    tool: (
      <>
        <RepoFile path=".github/workflows/codeql.yml" lines="L44-L56">
          codeql.yml
        </RepoFile>{" "}
        (JS/TS, Python, Actions) on every PR;{" "}
        <RepoFile path=".github/workflows/codeql-swift.yml" lines="L36-L38">
          codeql-swift.yml
        </RepoFile>{" "}
        when clients/ios changes, or locally with{" "}
        <RepoFile path="clients/ios/Scripts/codeql-swift.sh">
          Scripts/codeql-swift.sh
        </RepoFile>
      </>
    ),
    blocking: false,
    standard: (
      <List
        items={[
          <C5 key="c5" id="PSS-02" />,
          <Src key="owasp" href={OWASP_TOP10_2021}>
            OWASP Top 10 (2021)
          </Src>,
        ]}
      />
    ),
  },
  {
    job: "Security scan",
    tests: "—",
    tool: (
      <>
        Source SBOM, image and deployed-image CVEs (
        <RepoFile path=".github/workflows/security-scan.yml" lines="L50-L90">
          security-scan.yml
        </RepoFile>
        ). CVEs fail a run only when a manual run asks for it (
        <RepoFile path=".github/workflows/security-scan.yml" lines="L317-L329">
          severity gate
        </RepoFile>
        )
      </>
    ),
    blocking: false,
    standard: (
      <List
        items={[
          <C5 key="c5" id="OPS-22" />,
          <Cra key="cra" anchor="anx_I">
            CRA Annex I, Part II (1)
          </Cra>,
        ]}
      />
    ),
  },
  {
    job: "UI Tests (Vitest)",
    tests: "—",
    tool: (
      <>
        <Src
          href={release("vitest-dev/vitest", `v${facts.toolVersions.vitest}`)}
        >
          Vitest {facts.toolVersions.vitest}
        </Src>{" "}
        + v8 coverage (
        <RepoFile path=".github/workflows/test.yml" lines="L112-L155">
          test.yml
        </RepoFile>
        )
      </>
    ),
    blocking: true,
    standard: <C5 id="DEV-06" />,
  },
  {
    job: "Neo4j Proxy Tests",
    tests: "—",
    tool: (
      <>
        Vitest (
        <RepoFile path=".github/workflows/test.yml" lines="L156-L201">
          test.yml
        </RepoFile>
        )
      </>
    ),
    blocking: true,
    standard: <C5 id="DEV-06" />,
  },
  {
    job: "Lint",
    tests: "—",
    tool: (
      <>
        Next.js ESLint, a pre-commit hook the PR Gate runs (
        <RepoFile path=".pre-commit-config.yaml" lines="L75-L79">
          .pre-commit-config.yaml
        </RepoFile>
        )
      </>
    ),
    blocking: true,
    standard: <C5 id="DEV-06" />,
  },
  {
    job: "Secret Scan",
    tests: "—",
    tool: (
      <>
        <Src
          href={release("gitleaks/gitleaks", `v${facts.toolVersions.gitleaks}`)}
        >
          Gitleaks v{facts.toolVersions.gitleaks}
        </Src>{" "}
        over the whole history each night (
        <RepoFile path=".github/workflows/nightly.yml" lines="L330-L354">
          nightly.yml
        </RepoFile>
        ); the PR Gate scans the pull request&apos;s commits
      </>
    ),
    blocking: true,
    standard: (
      <List items={[<C5 key="c5" id="CRY-04" />, <Owasp key="o" id="A07" />]} />
    ),
  },
  {
    job: "Dependency Audit",
    tests: "—",
    tool: (
      <>
        npm audit, HIGH+ (
        <RepoFile path=".github/workflows/test.yml" lines="L478-L486">
          test.yml
        </RepoFile>
        , through{" "}
        <RepoFile path="scripts/check-npm-audit.py">
          check-npm-audit.py
        </RepoFile>
        )
      </>
    ),
    blocking: true,
    standard: (
      <List items={[<C5 key="c5" id="PSS-02" />, <Owasp key="o" id="A06" />]} />
    ),
  },
  {
    job: "Trivy Scan",
    tests: "—",
    tool: (
      <>
        <Src
          href={release("aquasecurity/trivy", `v${facts.toolVersions.trivy}`)}
        >
          Trivy v{facts.toolVersions.trivy}
        </Src>{" "}
        (
        <RepoFile path=".github/workflows/test.yml" lines="L345-L398">
          test.yml
        </RepoFile>
        )
      </>
    ),
    blocking: false,
    standard: (
      <List items={[<C5 key="c5" id="OPS-22" />, <Owasp key="o" id="A06" />]} />
    ),
  },
  {
    job: "K8s Posture",
    tests: "—",
    tool: (
      <>
        Kubescape, NSA and CIS frameworks, critical findings (
        <RepoFile path=".github/workflows/test.yml" lines="L399-L445">
          test.yml
        </RepoFile>
        )
      </>
    ),
    blocking: true,
    standard: (
      <List
        items={[
          <C5 key="c5" id="OPS-23" />,
          <Src key="nsa" href={NSA_K8S_URL}>
            NSA/CISA Kubernetes Hardening Guide
          </Src>,
          <Src key="cis" href={CIS_K8S_URL}>
            CIS Kubernetes Benchmark
          </Src>,
        ]}
      />
    ),
  },
  {
    job: "E2E Tests",
    tests: "—",
    tool: (
      <>
        <Src
          href={release(
            "microsoft/playwright",
            `v${facts.toolVersions.playwright}`,
          )}
        >
          Playwright v{facts.toolVersions.playwright}
        </Src>
        , nightly (
        <RepoFile path=".github/workflows/nightly.yml" lines="L177-L185">
          nightly.yml
        </RepoFile>
        )
      </>
    ),
    blocking: false,
    standard: "—",
  },
  {
    job: "WCAG 2.2 AA Audit",
    tests: "—",
    tool: (
      <>
        axe-core/playwright, nightly (
        <RepoFile path=".github/workflows/nightly.yml" lines="L197-L199">
          nightly.yml
        </RepoFile>
        , continue-on-error)
      </>
    ),
    blocking: false,
    standard: (
      <List
        items={[
          <Src key="wcag" href={WCAG22_URL}>
            WCAG 2.2 AA
          </Src>,
          <Src key="en" href={EN_301_549_URL}>
            EN 301 549
          </Src>,
        ]}
      />
    ),
  },
  {
    job: "Security Pentest",
    tests: "—",
    tool: (
      <>
        OWASP/BSI patterns,{" "}
        <RepoFile path="ui/__tests__/e2e/journeys/28-security-pentest.spec.ts">
          28-security-pentest.spec.ts
        </RepoFile>
        , nightly (
        <RepoFile path=".github/workflows/nightly.yml" lines="L208-L210">
          nightly.yml
        </RepoFile>
        )
      </>
    ),
    blocking: false,
    standard: (
      <List
        items={[
          <C5 key="c5" id="PSS-02" />,
          <Src key="owasp" href={OWASP_TOP10_2021}>
            OWASP Top 10 (2021)
          </Src>,
        ]}
      />
    ),
  },
  {
    job: "SBOM Generation",
    tests: "2",
    tool: (
      <>
        CycloneDX npm, <Src href={CYCLONEDX_15_URL}>CycloneDX 1.5</Src> (
        <RepoFile path=".github/workflows/test.yml" lines="L512-L531">
          test.yml
        </RepoFile>
        )
      </>
    ),
    blocking: true,
    standard: (
      <List
        items={[
          <Cra key="cra" anchor="anx_I">
            CRA Annex I, Part II (1)
          </Cra>,
          <C5 key="c5" id="AM-01" />,
        ]}
      />
    ),
  },
  {
    job: "Licence Compliance",
    tests: "—",
    tool: (
      <>
        license-checker-rseidelsohn 4.4.2 with an allowlist (
        <RepoFile path=".github/workflows/test.yml" lines="L559-L565">
          test.yml
        </RepoFile>
        )
      </>
    ),
    blocking: true,
    standard: "No C5 criterion or CRA article requires it",
  },
  {
    job: "Lighthouse CI",
    tests: "12",
    tool: (
      <>
        Lighthouse CI (4 pages × 3 runs), nightly (
        <RepoFile path=".github/workflows/nightly.yml" lines="L254-L310">
          nightly.yml
        </RepoFile>
        )
      </>
    ),
    blocking: false,
    standard: <Src href={CORE_WEB_VITALS_URL}>Core Web Vitals</Src>,
  },
];
 
const coverageData = Object.entries(facts.coverageThresholds).map(
  ([metric, value]) => ({
    metric: metric[0].toUpperCase() + metric.slice(1),
    value: `≥ ${value}%`,
  }),
);
 
const DSP_CHECKS: ReactNode = (
  <>
    <Src href={DSP_URL}>Dataspace Protocol</Src>: the hub&apos;s own checks (
    <RepoFile path="scripts/run-ehds-dataspace-checks.sh" lines="L5-L9">
      run-ehds-dataspace-checks.sh
    </RepoFile>
    ), not the <Src href={DSP_TCK_URL}>Eclipse DSP TCK</Src>
  </>
);
const DCP_CHECKS: ReactNode = (
  <>
    <Src href={DCP_URL}>Decentralised Claims</Src>: the hub&apos;s own checks (
    <RepoFile path="scripts/run-ehds-identity-checks.sh" lines="L5-L9">
      run-ehds-identity-checks.sh
    </RepoFile>
    ), not the <Src href={DCP_TCK_URL}>Eclipse DCP TCK</Src>
  </>
);
const EHDS_CHECKS: ReactNode = (
  <>
    <Ehds art={53} /> purposes, <Ehds art={71} /> opt-out, HealthDCAT-AP,
    EEHRxF, OMOP (
    <RepoFile path="scripts/run-ehds-tests.sh">run-ehds-tests.sh</RepoFile>)
  </>
);
 
const SUITE_NAMES: Record<string, [string, ReactNode]> = {
  "dsp-tck-results": ["DSP 2025-1 checks", DSP_CHECKS],
  "dcp-compliance-results": ["DCP v1.0 checks", DCP_CHECKS],
  "ehds-compliance-results": ["EHDS Domain", EHDS_CHECKS],
  "bruno-api-results": ["API collection (CI)", "Bruno, persona folders"],
  "bruno-api-azure-results": ["API collection (Azure)", "Bruno, ehds.mabu.red"],
  "dsp-azure-results": ["DSP 2025-1 checks (Azure)", DSP_CHECKS],
  "dcp-azure-results": ["DCP v1.0 checks (Azure)", DCP_CHECKS],
  "ehds-azure-results": ["EHDS Domain (Azure)", EHDS_CHECKS],
};
 
const complianceSuites = Object.entries(facts.complianceFloors).map(
  ([key, floor]) => ({
    suite: SUITE_NAMES[key]?.[0] ?? key,
    protocol: SUITE_NAMES[key]?.[1] ?? "",
    minPassed: floor.min_passed,
    maxFailed: floor.max_failed,
  }),
);
 
interface FutureGate {
  priority: number;
  title: string;
  icon: React.ElementType;
  description: ReactNode;
  standard: ReactNode;
  rationale: ReactNode;
  effort: string;
}
 
const futureGates: FutureGate[] = [
  {
    priority: 1,
    title: "Enforce Coverage Thresholds",
    icon: FlaskConical,
    description: (
      <>
        Minimum coverage thresholds in{" "}
        <RepoFile path="ui/vitest.config.ts" lines="L36-L41">
          vitest.config.ts
        </RepoFile>
        : {facts.coverageThresholds.statements}% statements,{" "}
        {facts.coverageThresholds.branches}% branches,{" "}
        {facts.coverageThresholds.functions}% functions,{" "}
        {facts.coverageThresholds.lines}% lines. Vitest fails if coverage drops
        below.
      </>
    ),
    standard: <C5 id="DEV-06" />,
    rationale:
      "Enforcement prevents silent regression; raise a floor whenever coverage rises.",
    effort: "Done: vitest.config.ts",
  },
  {
    priority: 2,
    title: "Mutation Testing",
    icon: FlaskConical,
    description: (
      <>
        Add <Src href="https://stryker-mutator.io/">Stryker Mutator</Src> to
        measure test effectiveness. Target mutation score &gt; 60%.
      </>
    ),
    standard: <C5 id="DEV-06" />,
    rationale:
      "Line coverage does not guarantee tests catch bugs. Mutation testing verifies tests detect real defects.",
    effort: "Medium: new tool + CI job",
  },
  {
    priority: 3,
    title: "Licence Compliance Scanning",
    icon: Scale,
    description: (
      <>
        license-checker-rseidelsohn in CI with an allowlist (
        <RepoFile path=".github/workflows/test.yml" lines="L559-L565">
          test.yml
        </RepoFile>
        ): MIT, Apache-2.0, ISC, BSD-2/3-Clause, 0BSD, CC0-1.0, CC-BY-4.0,
        Unlicense, Python-2.0, BlueOak-1.0.0, LGPL-3.0-or-later. The job fails
        on any production dependency under another licence.
      </>
    ),
    standard: "No C5 criterion or CRA article requires it",
    rationale:
      "Neither the CRA nor BSI C5 asks for a licence check. It keeps the dependencies compatible with the hub's Apache-2.0 licence.",
    effort: "Done: implemented in test.yml",
  },
  {
    priority: 4,
    title: "API Contract Testing",
    icon: FileCheck,
    description: (
      <>
        <RepoFile path="scripts/check-api-spec-drift.py" /> already blocks any
        new route missing from openapi.yaml ({facts.openapi.operations}{" "}
        operations documented). Next: validate response shapes against the spec
        with swagger-parser or Prism.
      </>
    ),
    standard: <Src href={OPENAPI_URL}>OpenAPI {facts.openapi.version}</Src>,
    rationale:
      "No formal schema enforces response shapes. Contract tests prevent frontend/backend drift.",
    effort: "Partly done: spec drift ratchet in the PR Gate",
  },
  {
    priority: 5,
    title: "SBOM Generation",
    icon: Boxes,
    description: (
      <>
        <Src href={CYCLONEDX_15_URL}>CycloneDX 1.5</Src> SBOM generated on every
        CI run for UI and Neo4j Proxy, uploaded as a 90-day artifact (
        <RepoFile path=".github/workflows/test.yml" lines="L512-L531">
          test.yml
        </RepoFile>
        ). The bills committed in{" "}
        <RepoFile path="docs/sbom/README.md">docs/sbom</RepoFile> are{" "}
        <Src href={CYCLONEDX_17_URL}>CycloneDX 1.7</Src>, made by syft (
        <RepoFile path="scripts/security/generate-sbom.sh" lines="L68">
          generate-sbom.sh
        </RepoFile>
        ); the iPhone app&apos;s is 1.5. The CRA asks for a software bill of
        materials in a commonly used, machine-readable format (
        <Cra anchor="anx_I">Annex I, Part II (1)</Cra>); the Commission may fix
        its format by implementing act (<Cra anchor="013.024">Art. 13(24)</Cra>
        ).
      </>
    ),
    standard: (
      <List
        items={[
          <Cra key="cra" anchor="anx_I">
            CRA Annex I, Part II (1)
          </Cra>,
          <Src key="ntia" href={NTIA_SBOM_URL}>
            NTIA SBOM minimum elements
          </Src>,
          <C5 key="c5" id="AM-01" />,
        ]}
      />
    ),
    rationale: (
      <>
        Supply chain attacks (XZ Utils,{" "}
        <Src href="https://www.cve.org/CVERecord?id=CVE-2024-3094">
          CVE-2024-3094
        </Src>
        ; the Trivy compromise,{" "}
        <Src href="https://github.com/aquasecurity/trivy/security/advisories/GHSA-69fq-xp46-6x23">
          GHSA-69fq-xp46-6x23
        </Src>
        ) make SBOMs non-negotiable. The CRA&apos;s Annex I applies from 11
        December 2027 (<Cra anchor="071.002">Art. 71(2)</Cra>).
      </>
    ),
    effort: "Done: implemented in test.yml",
  },
  {
    priority: 6,
    title: "Performance Regression Testing",
    icon: Gauge,
    description: (
      <>
        Lighthouse CI with Core Web Vitals budgets: LCP &lt; 4s (error), CLS
        &lt; 0.1 (error), TBT &lt; 300ms (warn), script size &lt; 500 KB (warn)
        (
        <RepoFile path=".github/workflows/nightly.yml" lines="L306-L310">
          nightly.yml
        </RepoFile>
        ). Runs on 4 key pages.
      </>
    ),
    standard: <Src href={CORE_WEB_VITALS_URL}>Core Web Vitals</Src>,
    rationale: (
      <>
        Healthcare professionals use the platform under time pressure. A budget
        error turns the nightly run red, which opens an issue; it does not block
        a merge (<Src href={ADR_074_URL}>ADR-074</Src>).
      </>
    ),
    effort: "Done: Lighthouse CI in nightly.yml",
  },
  {
    priority: 7,
    title: "Runtime ODRL Policy Enforcement",
    icon: Lock,
    description:
      "Implement ODRL engine: validate API responses respect the caller's permitted datasets and temporal limits.",
    standard: (
      <List
        items={[
          <Ehds key="ehds" art={66} />,
          <Src key="odrl" href={ODRL_MODEL_URL}>
            ODRL 2.2 §2
          </Src>,
        ]}
      />
    ),
    rationale:
      "Currently ODRL policies are decorative. Any authenticated user can query any dataset. This is the largest EHDS compliance gap.",
    effort: "High: new engine + tests",
  },
  {
    priority: 8,
    title: "WCAG Blocking Gate",
    icon: Accessibility,
    description: (
      <>
        WCAG 2.2 AA audit with a zero-violation budget. Since it moved to the
        nightly run (<Src href={ADR_074_URL}>ADR-074</Src>) it runs with
        continue-on-error (
        <RepoFile path=".github/workflows/nightly.yml" lines="L197-L199">
          nightly.yml
        </RepoFile>
        ), so a violation shows in the report but fails nothing.
      </>
    ),
    standard: (
      <List
        items={[
          <Src key="en" href={EN_301_549_URL}>
            EN 301 549
          </Src>,
          <Src key="wad" href={WAD_URL}>
            Directive (EU) 2016/2102
          </Src>,
        ]}
      />
    ),
    rationale:
      "The audit found zero violations when it last blocked. To block again it needs a step that fails the nightly job.",
    effort: "Partly done: runs nightly, does not block",
  },
  {
    priority: 9,
    title: "IaC Policy Enforcement",
    icon: Server,
    description: (
      <>
        Kubescape blocks on critical findings (--severity-threshold critical)
        under the NSA and CIS frameworks (
        <RepoFile path=".github/workflows/test.yml" lines="L419-L445">
          test.yml
        </RepoFile>
        ).
      </>
    ),
    standard: (
      <List
        items={[
          <C5 key="c5" id="OPS-23" />,
          <Src key="nsa" href={NSA_K8S_URL}>
            NSA/CISA Kubernetes Hardening Guide
          </Src>,
        ]}
      />
    ),
    rationale:
      "K8s manifests define production topology. Critical security findings now block the build.",
    effort: "Done: blocking in test.yml",
  },
  {
    priority: 10,
    title: "Dependency Freshness",
    icon: RefreshCw,
    description: (
      <>
        Renovate Bot configured (
        <RepoFile path="renovate.json" lines="L5-L42">
          renovate.json
        </RepoFile>
        ): auto-merge patches, weekly PRs for minor, manual review for major.
        Security updates bypass schedule.
      </>
    ),
    standard: (
      <List
        items={[
          <Owasp key="o" id="A06" />,
          <C5 key="c5" id="OPS-22" />,
          <Cra key="cra" anchor="anx_I">
            CRA Annex I, Part II (2)
          </Cra>,
        ]}
      />
    ),
    rationale: (
      <>
        Automated dependency updates prevent CVE accumulation. The CRA asks
        manufacturers to remediate vulnerabilities without delay, including by
        security updates (<Cra anchor="anx_I">Annex I, Part II (2)</Cra>).
      </>
    ),
    effort: "Done: renovate.json",
  },
];
 
/** The compliance mapping: each cell names the criterion and links it. */
const DASH = "—";
const complianceMatrix: {
  gate: string;
  c5: ReactNode;
  owasp: ReactNode;
  cra: ReactNode;
  ehds: ReactNode;
  wcag: ReactNode;
}[] = [
  {
    gate: "TypeScript strict",
    c5: <C5 id="DEV-01" />,
    owasp: DASH,
    cra: DASH,
    ehds: DASH,
    wcag: DASH,
  },
  {
    gate: "ESLint",
    c5: <C5 id="DEV-06" />,
    owasp: DASH,
    cra: DASH,
    ehds: DASH,
    wcag: DASH,
  },
  {
    gate: "Unit tests + coverage thresholds",
    c5: <C5 id="DEV-06" />,
    owasp: DASH,
    cra: DASH,
    ehds: DASH,
    wcag: DASH,
  },
  {
    gate: "Secret scan (Gitleaks)",
    c5: <C5 id="CRY-04" />,
    owasp: <Owasp id="A07" />,
    cra: DASH,
    ehds: DASH,
    wcag: DASH,
  },
  {
    gate: "Dependency audit",
    c5: <C5 id="PSS-02" />,
    owasp: <Owasp id="A06" />,
    cra: <Cra anchor="anx_I">Annex I, Part II (1)</Cra>,
    ehds: DASH,
    wcag: DASH,
  },
  {
    gate: "Trivy vuln scan",
    c5: <C5 id="OPS-22" />,
    owasp: <Owasp id="A06" />,
    cra: <Cra anchor="anx_I">Annex I, Part II (1)</Cra>,
    ehds: DASH,
    wcag: DASH,
  },
  {
    gate: "Security headers",
    c5: <C5 id="OPS-23" />,
    owasp: <Owasp id="A05" />,
    cra: DASH,
    ehds: DASH,
    wcag: DASH,
  },
  {
    gate: "WCAG 2.2 AA (nightly, reports)",
    c5: DASH,
    owasp: DASH,
    cra: DASH,
    ehds: DASH,
    wcag: <Src href={WCAG22_URL}>2.2 AA</Src>,
  },
  {
    gate: "DSP 2025-1 checks (own, not the TCK)",
    c5: DASH,
    owasp: DASH,
    cra: DASH,
    ehds: DASH,
    wcag: DASH,
  },
  {
    gate: "DCP v1.0 checks (own, not the TCK)",
    c5: DASH,
    owasp: DASH,
    cra: DASH,
    ehds: DASH,
    wcag: DASH,
  },
  {
    gate: "EHDS domain tests",
    c5: DASH,
    owasp: DASH,
    cra: DASH,
    ehds: (
      <List items={[<Ehds key="53" art={53} />, <Ehds key="71" art={71} />]} />
    ),
    wcag: DASH,
  },
  {
    gate: "SBOM (CycloneDX 1.5 in CI)",
    c5: <C5 id="AM-01" />,
    owasp: <Owasp id="A06" />,
    cra: <Cra anchor="anx_I">Annex I, Part II (1)</Cra>,
    ehds: DASH,
    wcag: DASH,
  },
  {
    gate: "Licence compliance",
    c5: "No C5 criterion",
    owasp: DASH,
    cra: "No CRA article",
    ehds: DASH,
    wcag: DASH,
  },
  {
    gate: "Lighthouse perf budget",
    c5: DASH,
    owasp: DASH,
    cra: DASH,
    ehds: DASH,
    wcag: DASH,
  },
  {
    gate: "Kubescape (blocking)",
    c5: <C5 id="OPS-23" />,
    owasp: DASH,
    cra: DASH,
    ehds: DASH,
    wcag: DASH,
  },
  {
    gate: "Renovate freshness",
    c5: <C5 id="OPS-22" />,
    owasp: <Owasp id="A06" />,
    cra: <Cra anchor="anx_I">Annex I, Part II (2)</Cra>,
    ehds: DASH,
    wcag: DASH,
  },
  {
    gate: "ODRL enforcement (planned)",
    c5: DASH,
    owasp: <Owasp id="A01" />,
    cra: DASH,
    ehds: <Ehds art={66} />,
    wcag: DASH,
  },
];
 
/* ------------------------------------------------------------------ */
/*  Helpers                                                            */
/* ------------------------------------------------------------------ */
 
function Badge({ blocking }: { blocking: boolean }) {
  return blocking ? (
    <span className="text-[10px] font-semibold px-2 py-0.5 rounded-sm bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-300">
      Blocks
    </span>
  ) : (
    <span className="text-[10px] font-semibold px-2 py-0.5 rounded-sm bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-300">
      Reports
    </span>
  );
}
 
function EffortBadge({ effort }: { effort: string }) {
  const color = effort.startsWith("Done")
    ? "bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300"
    : effort.startsWith("Low")
      ? "bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300"
      : effort.startsWith("High")
        ? "bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-300"
        : "bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-300";
  return (
    <span
      className={`text-[10px] font-semibold px-2 py-0.5 rounded-sm ${color}`}
    >
      {effort}
    </span>
  );
}
 
/* ------------------------------------------------------------------ */
/*  Page                                                               */
/* ------------------------------------------------------------------ */
 
export default function QualityGatesPage() {
  const lang = useLanguage();
  return (
    <div className="max-w-5xl mx-auto px-6 py-12">
      <Link
        href="/docs/developer"
        className="inline-flex items-center gap-1 text-sm text-(--text-secondary) hover:text-(--text-primary) mb-6"
      >
        <ArrowLeft size={14} /> Back to Developer Guide
      </Link>
 
      <div className="flex items-center gap-3 mb-2">
        <ShieldCheck size={28} className="text-(--accent)" />
        <h1 className="text-3xl font-bold">Quality Gates</h1>
      </div>
      <DocsLastUpdated page="/docs/developer/quality-gates" />
      <p className="text-(--text-secondary) mb-8">
        Every check enforced from developer workstation to production
        deployment, mapped to <Src href={C5_URL}>BSI C5:2020</Src>, the{" "}
        <Src href={OWASP_TOP10_2021}>OWASP Top 10 (2021)</Src>, the{" "}
        <Src href={CRA_URL}>Cyber Resilience Act</Src>, the{" "}
        <Src href={EHDS_URL}>EHDS regulation</Src> and{" "}
        <Src href={WCAG22_URL}>WCAG 2.2 AA</Src> where a criterion fits, and
        left unmapped where none does.
      </p>
 
      {/* TOC */}
      <nav className="border border-(--border) rounded-xl p-5 mb-10">
        <h2 className="font-semibold mb-3">Contents</h2>
        <ul className="text-sm space-y-1.5 text-(--accent)">
          {[
            ["#pipeline", "Pipeline Overview"],
            ["#pre-commit", "Stage 1 — Pre-commit Hooks"],
            ["#pre-push", "Stage 2 — Pre-push Gates"],
            ["#ci", "Stage 3 — CI Pipeline"],
            ["#compliance", "Stage 4 — Protocol Compliance"],
            ["#coverage", "Current Coverage"],
            ["#future", "Future Quality Gates"],
            ["#matrix", "Compliance Mapping"],
          ].map(([href, label]) => (
            <li key={href}>
              <a href={href} className="hover:underline">
                {label}
              </a>
            </li>
          ))}
        </ul>
      </nav>
 
      {/* Pipeline Overview */}
      <section className="mb-12">
        <h2 className="text-2xl font-semibold mb-4" id="pipeline">
          Pipeline Overview
        </h2>
        <MermaidDiagram
          chart={localizedChart("quality-gates-pipeline", lang)}
          caption="Four-stage quality pipeline from commit to compliance"
        />
      </section>
 
      {/* Pre-commit */}
      <section className="mb-12">
        <h2 className="text-2xl font-semibold mb-4" id="pre-commit">
          Stage 1 — Pre-commit Hooks
        </h2>
        <p className="text-sm text-(--text-secondary) mb-4">
          The {facts.preCommitHooks.length} hooks configured in{" "}
          <RepoFile path=".pre-commit-config.yaml" />, in the order they run.
          They run before every <code>git commit</code>, and the PR Gate runs
          them again on the pull request&apos;s diff. Hooks that rewrite a file
          (Prettier, end-of-file) fail the commit; stage the file again and
          commit.
        </p>
        <div className="overflow-x-auto">
          <table className="w-full text-sm border border-(--border) rounded-lg">
            <thead className="bg-(--surface-2)">
              <tr>
                <th className="px-3 py-2 text-left text-(--text-primary)">
                  Hook
                </th>
                <th className="px-3 py-2 text-left text-(--text-primary)">
                  Source
                </th>
                <th className="px-3 py-2 text-left text-(--text-primary)">
                  Stage
                </th>
              </tr>
            </thead>
            <tbody className="text-(--text-secondary)">
              {facts.preCommitHooks.map((h) => (
                <tr key={h.id} className="border-t border-(--border)">
                  <td className="px-3 py-2 text-xs">{h.name}</td>
                  <td className="px-3 py-2 text-xs font-mono">{h.source}</td>
                  <td className="px-3 py-2 text-xs">{h.stage}</td>
                </tr>
              ))}
            </tbody>
          </table>
        </div>
      </section>
 
      {/* Pre-push */}
      <section className="mb-12">
        <h2 className="text-2xl font-semibold mb-4" id="pre-push">
          Stage 2 — Pre-push Gates
        </h2>
        <p className="text-sm text-(--text-secondary) mb-4">
          Run before <code>git push</code>. These catch issues that are too slow
          for pre-commit.
        </p>
        <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
          <div className="border border-(--border) rounded-lg p-4">
            <h4 className="font-semibold text-sm mb-1">Unit Tests</h4>
            <p className="text-xs text-(--text-secondary) mb-2">
              <code>vitest run --bail 1</code>: stops on first failure (
              <RepoFile path=".pre-commit-config.yaml" lines="L86-L92">
                .pre-commit-config.yaml
              </RepoFile>
              )
            </p>
            <Badge blocking={true} />
          </div>
          <div className="border border-(--border) rounded-lg p-4">
            <h4 className="font-semibold text-sm mb-1">Dependency Audit</h4>
            <p className="text-xs text-(--text-secondary) mb-2">
              <code>scripts/check-npm-audit.py ui --omit=dev</code>: npm audit,
              HIGH and CRITICAL fail unless excepted with an expiry (
              <RepoFile path=".pre-commit-config.yaml" lines="L287-L292">
                .pre-commit-config.yaml
              </RepoFile>
              )
            </p>
            <Badge blocking={true} />
          </div>
        </div>
      </section>
 
      {/* CI Pipeline */}
      <section className="mb-12">
        <h2 className="text-2xl font-semibold mb-4" id="ci">
          Stage 3 — CI Pipeline
        </h2>
        <p className="text-sm text-(--text-secondary) mb-4">
          GitHub Actions workflow{" "}
          <a
            href={CI_WORKFLOW_URL}
            target="_blank"
            rel="noopener noreferrer"
            className="text-(--accent) hover:underline font-mono"
          >
            .github/workflows/test.yml
          </a>{" "}
          runs {facts.workflowJobs["test.yml"].length} jobs on every push. The
          other rows run in the PR Gate, CodeQL, the security scan and the
          nightly run (<Src href={ADR_074_URL}>ADR-074</Src>); each row links
          the lines that run it. C5 criteria link to their page in the BSI
          C5:2020 catalogue; OWASP numbers are the 2021 edition.{" "}
          <a
            href={CI_WORKFLOW_URL}
            target="_blank"
            rel="noopener noreferrer"
            className="text-(--accent) hover:underline text-xs"
          >
            View latest run &rarr;
          </a>
        </p>
        <div className="overflow-x-auto">
          <table className="w-full text-sm border border-(--border) rounded-lg">
            <thead className="bg-(--surface-2)">
              <tr>
                <th className="px-3 py-2 text-left text-(--text-primary)">
                  Job
                </th>
                <th className="px-3 py-2 text-left text-(--text-primary)">
                  Tests
                </th>
                <th className="px-3 py-2 text-left text-(--text-primary)">
                  Tool
                </th>
                <th className="px-3 py-2 text-left text-(--text-primary)">
                  Standard
                </th>
                <th className="px-3 py-2 text-left text-(--text-primary)">
                  Gate
                </th>
              </tr>
            </thead>
            <tbody className="text-(--text-secondary)">
              {ciGates.map((g) => (
                <tr key={g.job} className="border-t border-(--border)">
                  <td className="px-3 py-2 text-xs font-semibold">{g.job}</td>
                  <td className="px-3 py-2 text-xs font-mono">{g.tests}</td>
                  <td className="px-3 py-2 text-xs">{g.tool}</td>
                  <td className="px-3 py-2 text-xs">{g.standard}</td>
                  <td className="px-3 py-2">
                    <Badge blocking={g.blocking} />
                  </td>
                </tr>
              ))}
            </tbody>
          </table>
        </div>
 
        <div className="mt-4 bg-(--surface-2) border border-(--border) rounded-lg p-4">
          <h4 className="font-semibold text-sm mb-2">Supply-Chain Hardening</h4>
          <ul className="text-xs text-(--text-secondary) space-y-1 list-disc ml-4">
            <li>
              Trivy (
              <RepoFile path=".github/workflows/test.yml" lines="L345-L354">
                test.yml
              </RepoFile>
              ) and the nightly gitleaks (
              <RepoFile path=".github/workflows/nightly.yml" lines="L341-L351">
                nightly.yml
              </RepoFile>
              ) are pinned to exact versions and checked against their SHA-256
              checksums; the PR Gate pins its gitleaks version without a
              checksum check (
              <RepoFile path=".github/workflows/pr-gate.yml" lines="L53-L58">
                pr-gate.yml
              </RepoFile>
              )
            </li>
            <li>
              <Src href={release("aquasecurity/trivy", "v0.69.3")}>
                Trivy v0.69.3
              </Src>{" "}
              used explicitly: versions 0.69.4 to 0.69.6 were compromised (
              <Src href="https://www.cve.org/CVERecord?id=CVE-2026-33634">
                CVE-2026-33634
              </Src>
              ,{" "}
              <Src href="https://github.com/aquasecurity/trivy/security/advisories/GHSA-69fq-xp46-6x23">
                GHSA-69fq-xp46-6x23
              </Src>
              )
            </li>
            <li>
              Ten fingerprints allowlisted in{" "}
              <RepoFile path=".gitleaksignore" />, each with the reason: local
              dev-stack credentials, false positives, and one dead session token
              kept in history
            </li>
          </ul>
        </div>
 
        <div className="mt-4 bg-(--surface-2) border border-(--border) rounded-lg p-4">
          <h4 className="font-semibold text-sm mb-2">
            Security Headers (Runtime)
          </h4>
          <p className="text-xs text-(--text-secondary) mb-2">
            Set in{" "}
            <RepoFile path="ui/next.config.js" lines="L76-L123">
              next.config.js
            </RepoFile>
            ; the Content-Security-Policy is built per request, with a nonce, in{" "}
            <RepoFile path="ui/src/middleware.ts" lines="L92-L98">
              middleware.ts
            </RepoFile>
            . Not set in the static GitHub Pages build, which has no server (
            <C5 id="OPS-23" /> system hardening, <Owasp id="A05" /> Security
            Misconfiguration):
          </p>
          <div className="font-mono text-xs text-(--text-secondary) space-y-0.5">
            <div>X-Frame-Options: DENY</div>
            <div>X-Content-Type-Options: nosniff</div>
            <div>Referrer-Policy: strict-origin-when-cross-origin</div>
            <div>
              Permissions-Policy: camera=(), microphone=(), geolocation=(),
              interest-cohort=()
            </div>
            <div>
              Strict-Transport-Security: max-age=63072000; includeSubDomains;
              preload
            </div>
            <div>
              Content-Security-Policy: default-src &apos;self&apos;; script-src
              &apos;self&apos; with a per-request nonce
            </div>
          </div>
        </div>
      </section>
 
      {/* Compliance */}
      <section className="mb-12">
        <h2 className="text-2xl font-semibold mb-4" id="compliance">
          Stage 4 — Protocol Compliance
        </h2>
        <p className="text-sm text-(--text-secondary) mb-4">
          Once a night, when main has changed (
          <RepoFile path=".github/workflows/nightly.yml" lines="L376-L385">
            nightly.yml
          </RepoFile>
          , <Src href={ADR_074_URL}>ADR-074</Src>), and on manual dispatch. Each
          suite must stay at or above the floor recorded in{" "}
          <RepoFile path="scripts/compliance-baseline.json" lines="L16-L59">
            scripts/compliance-baseline.json
          </RepoFile>
          ; a floor is raised when a suite improves and never lowered without a
          reason. The DSP and DCP suites are the hub&apos;s own checks of its
          reading of the specifications, not the Eclipse TCKs; neither TCK has
          run against the hub yet (<Src href={`${ISSUES}338`}>#338</Src>).
          Workflow:{" "}
          <a
            href={COMPLIANCE_WORKFLOW_URL}
            target="_blank"
            rel="noopener noreferrer"
            className="text-(--accent) hover:underline font-mono"
          >
            .github/workflows/compliance.yml
          </a>{" "}
          <a
            href={COMPLIANCE_WORKFLOW_URL}
            target="_blank"
            rel="noopener noreferrer"
            className="text-(--accent) hover:underline text-xs"
          >
            View latest run &rarr;
          </a>
        </p>
        <div className="grid grid-cols-1 md:grid-cols-3 gap-4">
          {complianceSuites.map((s) => (
            <div
              key={s.suite}
              className="border border-(--border) rounded-lg p-4"
            >
              <h4 className="font-semibold text-sm mb-1">{s.suite}</h4>
              <p className="text-xs text-(--text-secondary) mb-2">
                {s.protocol}
              </p>
              <div className="flex items-baseline gap-2">
                <span className="text-2xl font-bold text-(--text-primary)">
                  ≥ {s.minPassed}
                </span>
                <span className="text-xs text-(--text-secondary)">
                  passed, at most {s.maxFailed} failed
                </span>
              </div>
            </div>
          ))}
        </div>
        <div className="mt-4 bg-(--surface-2) border border-(--border) rounded-lg p-4">
          <h4 className="font-semibold text-sm mb-2">
            Infrastructure Requirements
          </h4>
          <p className="text-xs text-(--text-secondary) mb-2">
            Protocol compliance tests require the full{" "}
            <Src href={JAD_URL}>JAD</Src> stack (
            <RepoFile path="docker-compose.jad.yml">
              {
                facts.composeServices["docker-compose.jad.yml"].filter(
                  (s) => s.profiles.length === 0,
                ).length
              }{" "}
              services
            </RepoFile>
            , 8 GB RAM), on EDC 1.0 (<Src href={ADR_078_URL}>ADR-078</Src>). In
            CI, the workflow starts JAD infrastructure with graceful fallback:
            tests produce results only when the controlplane is healthy.
          </p>
          <p className="text-xs text-(--text-secondary)">
            Local execution:{" "}
            <RepoFile path="scripts/run-ehds-dataspace-checks.sh">
              ./scripts/run-ehds-dataspace-checks.sh
            </RepoFile>
            ,{" "}
            <RepoFile path="scripts/run-ehds-identity-checks.sh">
              ./scripts/run-ehds-identity-checks.sh
            </RepoFile>
            ,{" "}
            <RepoFile path="scripts/run-ehds-tests.sh">
              ./scripts/run-ehds-tests.sh
            </RepoFile>
            . The old names{" "}
            <RepoFile path="scripts/run-dsp-tck.sh" lines="L2-L5">
              run-dsp-tck.sh
            </RepoFile>{" "}
            and{" "}
            <RepoFile path="scripts/run-dcp-tests.sh" lines="L2-L5">
              run-dcp-tests.sh
            </RepoFile>{" "}
            are shims for the first two; despite the name, neither is a TCK.
          </p>
        </div>
      </section>
 
      {/* Coverage */}
      <section className="mb-12">
        <h2 className="text-2xl font-semibold mb-4" id="coverage">
          Coverage Floors
        </h2>
        <p className="text-sm text-(--text-secondary) mb-4">
          Enforced by <RepoFile path="ui/vitest.config.ts" lines="L36-L41" />:
          the UI suite fails when coverage drops below these. The measured
          numbers are in the published test report.
        </p>
        <div className="grid grid-cols-2 md:grid-cols-4 gap-4 mb-4">
          {coverageData.map((c) => (
            <div
              key={c.metric}
              className="border border-(--border) rounded-lg p-4 text-center"
            >
              <div className="text-2xl font-bold text-(--text-primary)">
                {c.value}
              </div>
              <div className="text-xs text-(--text-secondary)">{c.metric}</div>
            </div>
          ))}
        </div>
        <div className="bg-(--surface-2) border border-(--border) rounded-lg p-4">
          <h4 className="font-semibold text-sm mb-2">Test Inventory</h4>
          <div className="grid grid-cols-3 gap-4 text-center">
            <div>
              <div className="text-xl font-bold text-(--text-primary)">
                Vitest
              </div>
              <div className="text-xs text-(--text-secondary)">
                Unit tests, UI and Neo4j proxy
              </div>
            </div>
            <div>
              <div className="text-xl font-bold text-(--text-primary)">
                Playwright
              </div>
              <div className="text-xs text-(--text-secondary)">
                E2E journeys, incl. WCAG 2.2 AA
              </div>
            </div>
            <div>
              <div className="text-xl font-bold text-(--text-primary)">
                {Object.keys(facts.complianceFloors).length}
              </div>
              <div className="text-xs text-(--text-secondary)">
                Compliance suites with a floor
              </div>
            </div>
          </div>
        </div>
      </section>
 
      {/* Future Gates */}
      <section className="mb-12">
        <h2 className="text-2xl font-semibold mb-4" id="future">
          Future Quality Gates
        </h2>
        <p className="text-sm text-(--text-secondary) mb-6">
          Recommended improvements prioritised by impact and regulatory
          alignment.
        </p>
        <div className="space-y-4">
          {futureGates.map((g) => {
            const Icon = g.icon;
            return (
              <div
                key={g.priority}
                className="border border-(--border) rounded-lg p-4"
              >
                <div className="flex items-start gap-3">
                  <span className="shrink-0 w-7 h-7 rounded-full bg-(--accent)/10 flex items-center justify-center text-xs font-bold text-(--accent)">
                    {g.priority}
                  </span>
                  <div className="flex-1">
                    <div className="flex items-center gap-2 mb-1 flex-wrap">
                      <Icon size={16} className="text-(--accent)" />
                      <h4 className="font-semibold text-sm">{g.title}</h4>
                      <EffortBadge effort={g.effort} />
                    </div>
                    <p className="text-xs text-(--text-secondary) mb-2">
                      {g.description}
                    </p>
                    <p className="text-xs text-(--text-secondary) italic mb-1">
                      {g.rationale}
                    </p>
                    <span className="text-[10px] font-mono text-(--text-secondary) bg-(--surface) px-2 py-0.5 rounded-sm">
                      {g.standard}
                    </span>
                  </div>
                </div>
              </div>
            );
          })}
        </div>
      </section>
 
      {/* Compliance Matrix */}
      <section className="mb-12">
        <h2 className="text-2xl font-semibold mb-4" id="matrix">
          Compliance Mapping
        </h2>
        <div className="overflow-x-auto">
          <table className="w-full text-sm border border-(--border) rounded-lg">
            <thead className="bg-(--surface-2)">
              <tr>
                <th className="px-3 py-2 text-left text-(--text-primary)">
                  Quality Gate
                </th>
                <th className="px-3 py-2 text-left text-(--text-primary)">
                  BSI C5:2020
                </th>
                <th className="px-3 py-2 text-left text-(--text-primary)">
                  OWASP 2021
                </th>
                <th className="px-3 py-2 text-left text-(--text-primary)">
                  CRA
                </th>
                <th className="px-3 py-2 text-left text-(--text-primary)">
                  EHDS
                </th>
                <th className="px-3 py-2 text-left text-(--text-primary)">
                  WCAG
                </th>
              </tr>
            </thead>
            <tbody className="text-(--text-secondary) text-xs">
              {complianceMatrix.map((row) => (
                <tr key={row.gate} className="border-t border-(--border)">
                  <td className="px-3 py-2 font-semibold">{row.gate}</td>
                  <td className="px-3 py-2">{row.c5}</td>
                  <td className="px-3 py-2">{row.owasp}</td>
                  <td className="px-3 py-2">{row.cra}</td>
                  <td className="px-3 py-2">{row.ehds}</td>
                  <td className="px-3 py-2">{row.wcag}</td>
                </tr>
              ))}
            </tbody>
          </table>
        </div>
      </section>
 
      {/* Related */}
      <section className="bg-(--surface-2) border border-(--border) rounded-xl p-6">
        <h2 className="font-semibold mb-2">Related Documentation</h2>
        <div className="flex flex-wrap gap-3">
          <Link
            href="/docs/developer"
            className="text-sm text-(--accent) hover:underline"
          >
            Developer Guide
          </Link>
          <Link
            href="/docs/architecture"
            className="text-sm text-(--accent) hover:underline"
          >
            Architecture
          </Link>
          <a
            href="https://github.com/ma3u/MinimumViableHealthDataspacev2/blob/main/docs/quality-gates.md"
            target="_blank"
            rel="noopener noreferrer"
            className="text-sm text-(--accent) hover:underline"
          >
            Full Markdown (GitHub)
          </a>
          <a
            href="https://github.com/ma3u/MinimumViableHealthDataspacev2/blob/main/docs/test-coverage-report.md"
            target="_blank"
            rel="noopener noreferrer"
            className="text-sm text-(--accent) hover:underline"
          >
            Coverage Report
          </a>
          <a
            href={CI_WORKFLOW_URL}
            target="_blank"
            rel="noopener noreferrer"
            className="text-sm text-(--accent) hover:underline"
          >
            CI Pipeline (latest)
          </a>
          <a
            href={COMPLIANCE_WORKFLOW_URL}
            target="_blank"
            rel="noopener noreferrer"
            className="text-sm text-(--accent) hover:underline"
          >
            Compliance Tests (latest)
          </a>
          <a
            href={PAGES_WORKFLOW_URL}
            target="_blank"
            rel="noopener noreferrer"
            className="text-sm text-(--accent) hover:underline"
          >
            Pages Deploy (latest)
          </a>
        </div>
      </section>
    </div>
  );
}