CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

trysac/eu-ai-act-checklist

Build an EU AI Act (2024/1689 as amended by 2026/1744) obligations checklist for an AI system. Use when asked about AI Act compliance, high-risk, Annex III, Article 50 transparency, GPAI or application dates. Not legal advice.

Quality

90%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Medium

Suggest reviewing before use

Overview
Quality
Evals
Security
Files

assess.pyscripts/

#!/usr/bin/env python3
"""Map answers about an AI system to EU AI Act obligations (standard library only).

Regulation (EU) 2024/1689 as amended by Regulation (EU) 2026/1744.
Dates last verified against EUR-Lex: 2026-12-01. This is not legal advice.

Usage:
    python3 assess.py ANSWERS.json [--format markdown|json]
    python3 assess.py - < answers.json

Exit codes: 0 success, 2 invalid input. The script reads only the file you give it,
makes no network calls and writes only to standard output and standard error.
"""

from __future__ import annotations

import argparse
import json
import re
import sys
from datetime import date

VERIFIED = "2026-12-01"
DISCLAIMER = (
    "This is not legal advice. Technical aid based on Regulation (EU) 2024/1689 as amended by "
    f"Regulation (EU) 2026/1744 (dates verified against EUR-Lex on {VERIFIED}); "
    "check later amendments."
)

D_2025_02 = date(2025, 2, 2)
D_2025_08 = date(2025, 8, 2)
D_2026_08 = date(2026, 8, 2)
D_2026_12 = date(2026, 12, 2)
D_2027_12 = date(2027, 12, 2)
D_2028_08 = date(2028, 8, 2)

# id -> (article, title, applies_from, applies_from_if_only_annex_i)
TABLE: dict[str, tuple[str, str, date, date | None]] = {
    "art4": ("Art. 4", "AI literacy measures", D_2025_02, None),
    "art5": (
        "Art. 5",
        "Do not place on the market or use (prohibited practice)",
        D_2025_02,
        None,
    ),
    "art5_ba_bb": (
        "Art. 5",
        "Do not place on the market or use (prohibited practice)",
        D_2026_12,
        None,
    ),
    "art6_4": (
        "Art. 6(4)",
        "Document the Art. 6(3) assessment before placing on the market",
        D_2027_12,
        None,
    ),
    "art49_2": ("Art. 49(2)", "Registration of the Art. 6(3) exception", D_2026_08, None),
    "art9": ("Art. 9", "Risk management system", D_2027_12, D_2028_08),
    "art10": ("Art. 10", "Data and data governance", D_2027_12, D_2028_08),
    "art11": ("Art. 11", "Technical documentation", D_2027_12, D_2028_08),
    "art12": ("Art. 12", "Record-keeping (logs)", D_2027_12, D_2028_08),
    "art13": ("Art. 13", "Transparency and instructions for deployers", D_2027_12, D_2028_08),
    "art14": ("Art. 14", "Human oversight", D_2027_12, D_2028_08),
    "art15": ("Art. 15", "Accuracy, robustness and cybersecurity", D_2027_12, D_2028_08),
    "art17": ("Art. 17", "Quality management system", D_2027_12, D_2028_08),
    "art26": ("Art. 26", "Deployer obligations", D_2027_12, D_2028_08),
    "art27": (
        "Art. 27",
        "Fundamental rights impact assessment (check whether Art. 27(1) applies to you)",
        D_2027_12,
        D_2028_08,
    ),
    "art43": ("Art. 43", "Conformity assessment", D_2027_12, D_2028_08),
    "art49": ("Art. 49", "Registration in the EU database", D_2027_12, D_2028_08),
    "art50_1": ("Art. 50(1)", "Inform people they interact with an AI system", D_2026_08, None),
    "art50_2": ("Art. 50(2)", "Mark synthetic content as machine-readable", D_2026_08, None),
    "art50_3": (
        "Art. 50(3)",
        "Inform people exposed to emotion recognition or biometric categorisation",
        D_2026_08,
        None,
    ),
    "art50_4": ("Art. 50(4)", "Disclose deep fakes", D_2026_08, None),
    "art53": ("Art. 53", "GPAI provider obligations", D_2025_08, None),
    "art72": ("Art. 72", "Post-market monitoring", D_2027_12, D_2028_08),
    "art73": ("Art. 73", "Serious incident reporting", D_2027_12, D_2028_08),
}

ART5_POINTS = {"a", "b", "c", "d", "e", "f", "g", "h", "ba", "bb"}
ANNEX_III_AREAS = {
    "biometrics",
    "critical_infrastructure",
    "education",
    "employment",
    "essential_services",
    "law_enforcement",
    "migration",
    "justice_democracy",
}
BOOL_QUESTIONS = (
    "annex_i_safety_component",
    "art6_3_exception",
    "profiling",
    "interacts_with_persons",
    "generates_synthetic_content",
    "emotion_or_biometric_categorisation",
    "deepfake",
    "gpai",
)
KNOWN = {"role", "art5", "annex_iii_area", *BOOL_QUESTIONS}
PROVIDER_HIGH_RISK = [f"art{n}" for n in (9, 10, 11, 12, 13, 14, 15, 17, 43, 72, 73)]
MAX_BYTES = 65_536


class InputError(Exception):
    """Invalid answers; the message names the offending question."""


def clip(value: object) -> str:
    return str(value)[:50]


def load_answers(text: str) -> dict:
    if len(text.encode("utf-8")) > MAX_BYTES:
        raise InputError(f"input_too_large: more than {MAX_BYTES} bytes")
    try:
        data = json.loads(text)
    except ValueError as exc:
        raise InputError(f"invalid_json: {exc}") from exc
    if not isinstance(data, dict):
        raise InputError("invalid_json: JSON payload must be an object")
    for key in data:
        if key not in KNOWN:
            raise InputError(f"unknown_question: '{clip(key)}'")
    if data.get("role") not in ("provider", "deployer"):
        raise InputError(
            f"invalid_answer: 'role' must be 'provider' or 'deployer', got {data.get('role')!r}"
        )
    points = data.get("art5", [])
    if not isinstance(points, list):
        raise InputError("invalid_answer: 'art5' must be a list of strings")
    for point in points:
        if not isinstance(point, str) or point not in ART5_POINTS:
            raise InputError(f"invalid_answer: Invalid Art. 5 point: '{clip(point)}'")
    area = data.get("annex_iii_area")
    if area is not None and (not isinstance(area, str) or area not in ANNEX_III_AREAS):
        raise InputError(f"invalid_answer: Invalid Annex III area: '{clip(area)}'")
    for key in BOOL_QUESTIONS:
        if not isinstance(data.get(key, False), bool):
            raise InputError(f"invalid_answer: '{key}' must be a boolean")
    return data


def article_key(article: str, oid: str) -> tuple[int, int, str]:
    match = re.search(r"(\d+)(?:\((\d+)\))?", article)
    if not match:
        return (9999, 0, oid)
    return (int(match.group(1)), int(match.group(2) or 0), oid)


def assess(answers: dict) -> dict:
    """Return {'category', 'obligations', 'notes'} for validated answers."""
    role = answers["role"]
    area = answers.get("annex_iii_area")
    exception = answers.get("art6_3_exception", False)
    profiling = answers.get("profiling", False)
    notes: list[str] = []

    def item(oid: str, when: date | None = None) -> dict:
        article, title, applies, _ = TABLE[oid]
        return {
            "id": oid,
            "article": article,
            "title": title,
            "applies_from": (when or applies).isoformat(),
        }

    points = answers.get("art5", [])
    if points:
        earliest = min(TABLE["art5_ba_bb" if p in ("ba", "bb") else "art5"][2] for p in points)
        return {"category": "prohibited", "obligations": [item("art5", earliest)], "notes": []}

    annex_i = answers.get("annex_i_safety_component", False)
    annex_iii = False
    if area is not None and not (exception and not profiling):
        annex_iii = True
        if exception and profiling:
            notes.append(
                "Art. 6(3): an Annex III system that performs profiling of natural persons "
                "is always high-risk"
            )
    high_risk = annex_i or annex_iii
    only_annex_i = annex_i and not annex_iii

    def dated(oid: str) -> dict:
        annex_i_date = TABLE[oid][3]
        return item(oid, annex_i_date if only_annex_i and annex_i_date else None)

    out = [item("art4")]
    if area is not None and exception and not profiling and role == "provider":
        out += [item("art6_4"), item("art49_2")]
    if high_risk:
        if role == "provider":
            ids = PROVIDER_HIGH_RISK + (["art49"] if annex_iii else [])
        else:
            ids = ["art26", "art27"]
        out += [dated(oid) for oid in ids]

    transparency = False
    if role == "provider":
        if answers.get("interacts_with_persons"):
            out.append(item("art50_1"))
            transparency = True
        if answers.get("generates_synthetic_content"):
            out.append(item("art50_2"))
            notes.append(
                "Art. 111(4): a generative system placed on the market before 2 August 2026 "
                "must comply with Art. 50(2) by 2 December 2026"
            )
            transparency = True
        if answers.get("gpai"):
            out.append(item("art53"))
            notes.append(
                "Art. 111(3): a general-purpose AI model placed on the market before "
                "2 August 2025 must comply by 2 August 2027"
            )
    else:
        if answers.get("emotion_or_biometric_categorisation"):
            out.append(item("art50_3"))
            transparency = True
        if answers.get("deepfake"):
            out.append(item("art50_4"))
            transparency = True

    category = "high_risk" if high_risk else "limited" if transparency else "minimal"
    out.sort(key=lambda o: article_key(o["article"], o["id"]))
    return {"category": category, "obligations": out, "notes": notes}


def render(result: dict, fmt: str) -> str:
    if fmt == "json":
        payload = {**result, "disclaimer": DISCLAIMER}
        return json.dumps(payload, indent=2, sort_keys=True)
    title = result["category"].replace("_", " ").title()
    lines = [DISCLAIMER, "", f"# EU AI Act Assessment: {title}", ""]
    if result["notes"]:
        lines.append("## Notes")
        lines += [f"- {note}" for note in result["notes"]]
        lines.append("")
    lines.append("## Obligations")
    for o in result["obligations"]:
        lines.append(f"- [ ] {o['article']}: {o['title']} (from {o['applies_from']})")
    return "\n".join(lines)


def main(argv: list[str] | None = None) -> int:
    parser = argparse.ArgumentParser(description="EU AI Act obligations from JSON answers.")
    parser.add_argument("file", nargs="?", default="-", help="answers JSON file or '-' for stdin")
    parser.add_argument(
        "--format", "-f", dest="fmt", choices=["markdown", "json"], default="markdown"
    )
    args = parser.parse_args(argv)
    try:
        if args.file == "-":
            text = sys.stdin.read()
        else:
            with open(args.file, encoding="utf-8") as handle:
                text = handle.read(MAX_BYTES + 1)
        print(render(assess(load_answers(text)), args.fmt))
    except (InputError, OSError) as exc:
        sys.stderr.write(f"error: {exc}\n")
        return 2
    return 0


if __name__ == "__main__":
    sys.exit(main())

scripts

SKILL.md

tile.json