Skip to main content

Annex IV-as-Code CLI: generate & validate EU AI Act Annex IV with legal compliance

Project description

Annex IV‑as‑Code (annex4ac)

Generate and validate EU AI Act Annex IV technical documentation straight from your CI.

100% local by default.

SaaS/PDF unlocks with a licence key .

⚠️ Legal Disclaimer: This software is provided for informational and compliance assistance purposes only. It is not legal advice and should not be relied upon as such. Users are responsible for ensuring their documentation meets all applicable legal requirements and should consult with qualified legal professionals for compliance matters. The authors disclaim any liability for damages arising from the use of this software.

🔒 Data Protection: All processing occurs locally on your machine. No data leaves your system.


✨ Features

  • Always up‑to‑date – every run pulls the latest Annex IV HTML from the official AI Act Explorer.
  • Schema‑first – YAML scaffold mirrors the 9 numbered sections adopted in the July 2024 Official Journal.
  • Fail‑fast CIannex4ac validate exits 1 when a mandatory field is missing, so a GitHub Action can block the PR.
  • Zero binaries – ReportLab renders the PDF; no LaTeX, no system packages.
  • Freemiumfetch-schema & validate are free; generate (PDF) requires ANNEX4AC_LICENSE.
  • Built-in rule engine – business-logic validation runs locally via pure Python.
  • EU-compliant formatting – proper list punctuation (semicolons and periods) and ordered list formatting (a), (b), (c) according to EU drafting rules.
  • Retention tracking – automatic 10-year retention period calculation and metadata embedding (Article 18 compliance).
  • Freshness validation – warns or fails when documentation is older than specified threshold (Article 11 compliance).
  • PDF/A-2b support – optional archival PDF format with embedded ICC profiles for long-term preservation.
  • Unified text processing – consistent handling of escaped characters and list formatting across all formats (PDF/HTML/DOCX).

🛠 Requirements


🚀 Quick‑start

# 1 Install (Python 3.9+)
pip install annex4ac

# 2 Pull the latest Annex IV layout
annex4ac fetch-schema annex_template.yaml

# 3 Fill in the YAML → validate
cp annex_template.yaml my_annex.yaml
$EDITOR my_annex.yaml
annex4ac validate my_annex.yaml   # "Validation OK!" or exit 1

# 4 Generate output (PDF requires license)
# HTML (free)
annex4ac generate my_annex.yaml --output annex_iv.html --fmt html

# DOCX (free)  
annex4ac generate my_annex.yaml --output annex_iv.docx --fmt docx

# PDF (Pro - requires license)
export ANNEX4AC_LICENSE="your_jwt_token_here"
annex4ac generate my_annex.yaml --output annex_iv.pdf --fmt pdf

License System: Pro features require a JWT license token. Contact support to obtain your token, then set it as the ANNEX4AC_LICENSE environment variable. See LICENSE_SYSTEM.md for details.

Hint : You only need to edit the YAML once per model version—CI keeps it green.


🗂 Required YAML fields (June 2024 format)

Key Annex IV §
risk_level
use_cases
system_overview 1
development_process 2
system_monitoring 3
performance_metrics 4
risk_management 5
changes_and_versions 6
standards_applied 7
compliance_declaration 8
post_market_plan 9
enterprise_size
placed_on_market
last_updated

🛠 Commands

Command What it does
fetch-schema Download the current Annex IV HTML, convert to YAML scaffold annex_schema.yaml.
validate Validate your YAML against the Pydantic schema and built-in Python rules. Exits 1 on error. Supports --sarif for GitHub annotations, --max-age for freshness validation, and --strict-age for strict age checking.
generate Render PDF (Pro), HTML, or DOCX from YAML. PDF requires license, HTML/DOCX are free.

Run annex4ac --help for full CLI.


🆕 New Features

EU-Compliant List Formatting

Lists are automatically formatted according to EU drafting rules:

  • Ordered lists: (a) ...; (b) ...; (c) ...
  • Unordered lists: • ...; • ...; • ...
  • Hierarchical lists: Support for nested structure with (a) + - subitems
  • Proper punctuation with semicolons and final periods
  • Cross-format consistency: Same list structure in PDF, HTML, and DOCX

Retention and Freshness Tracking

  • 10-year retention: Automatic calculation and metadata embedding according to Article 18(1)
  • Freshness validation: --max-age 180 (default) or --strict-age for CI enforcement
  • Compliance: Meets Article 11 (up-to-date) and Article 18 (retention) requirements
  • Legal accuracy: Retention period calculated from placed_on_market date

Unified Text Processing

All formats (PDF/HTML/DOCX) now use consistent text processing:

  • Automatic handling of escaped characters (\\n\n)
  • Proper list detection and formatting
  • YAML flow scalar restoration
  • EU-compliant punctuation

PDF/A-2b Archival Support

Enable archival PDF generation with:

# Generate PDF/A-2b for long-term preservation
annex4ac generate my_annex.yaml --fmt pdf --pdfa

# PDF/A-2b includes:
# - Embedded sRGB ICC profile
# - XMP metadata
# - ISO 19005-2:2011 compliance
# - 10-year retention metadata

Legal compliance: PDF/A-2b format ensures documents remain accessible and visually identical for decades, meeting archival requirements under Article 18 of Regulation 2024/1689.

List Formatting Examples

Hierarchical Lists (EU-Compliant)

development_process: |
  (a) Requirements analysis phase (3 months):
      - Stakeholder interviews and requirements gathering
      - Technical feasibility assessment
      - Risk analysis and compliance review
  
  (b) Design and architecture phase (4 months):
      - System architecture design
      - Data flow and security design
      - Integration planning

Regular Bulleted Lists

standards_applied: |
  Compliance with international standards:
  
  - ISO 27001: Information security management
  - IEEE 2857: AI system development guidelines
  - GDPR: Data protection and privacy
  - ISO 9001: Quality management systems
  - Internal AI ethics guidelines and policies

Both formats are supported across all output formats (PDF, HTML, DOCX) with consistent rendering.


🏷️ High-risk tags (Annex III)

The list of high-risk tags (Annex III) is now loaded dynamically from the official website. If the network is unavailable, a cache or fallback list is used. This affects the auto_high_risk logic in validation.


🏷️ Schema version in PDF

Each PDF now displays the Annex IV schema version stamp (e.g., v20240613) and the document generation date.


🔑 Pro-licence & JWT

To generate PDF in Pro mode, a license is required (JWT, RSA signature). The ANNEX4AC_LICENSE key can be checked offline, the public key is stored in the package. See LICENSE_SYSTEM.md for detailed information about the license system.


🛡️ Rule-based validation (Python)

  • High-risk systems: All 9 sections of Annex IV are mandatory (Art. 11 §1).
  • Limited/minimal risk: Annex IV is optional but recommended for transparency (Art. 52).
  • For high-risk (risk_level: high), post_market_plan is required.
  • If use_cases contains a high-risk tag (Annex III), risk_level must be high (auto high-risk).
  • SARIF report now supports coordinates (line/col) for integration with GitHub Code Scanning.
  • Auto-detection: Systems with Annex III use_cases are automatically classified as high-risk.

🐙 GitHub Action example

name: Annex IV gate
on: [pull_request]

jobs:
  ai-act-check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.11'
      - run: pip install annex4ac
      - run: annex4ac validate model.yaml

Add ANNEX4AC_LICENSE as a secret to use PDF export in CI.


📄 Offline cache

If Annex IV is temporarily unavailable online, use:

annex4ac fetch-schema --offline

This will load the last saved schema from ~/.cache/annex4ac/ (the cache is updated automatically every 14 days).


⚙️ Local development

git clone https://github.com/your‑org/annex4ac
cd annex4ac
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
pytest                     # unit tests
python annex4ac.py --help

🔑 Licensing & pricing

Tier Price Features
Community Free fetch-schema, validate, unlimited public repos
Pro €15 / month PDF generation, version history (future SaaS), email support
Enterprise Custom Self‑hosted Docker, SLA 99.9 %, custom sections

Pay once, use anywhere – CLI, GitHub Action, future REST API.


📚 References


📄 Licensing

This project is licensed under the MIT License - see the LICENSE file for details.

Third-party Components

  • PyJWT - MIT License
  • ReportLab - BSD-style License
  • Typer - MIT License
  • Liberation Sans Fonts - SIL Open Font License 1.1 (included in fonts/ directory)

The Liberation Sans fonts are used for PDF generation and are licensed under the SIL Open Font License 1.1. See the LICENSE file for the complete license text.

The software assists in preparing documentation, but does not confirm compliance with legal requirements or standards. The user is responsible for the final accuracy and compliance of the documents.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

annex4ac-1.1.0.tar.gz (274.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

annex4ac-1.1.0-py3-none-any.whl (267.7 kB view details)

Uploaded Python 3

File details

Details for the file annex4ac-1.1.0.tar.gz.

File metadata

  • Download URL: annex4ac-1.1.0.tar.gz
  • Upload date:
  • Size: 274.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for annex4ac-1.1.0.tar.gz
Algorithm Hash digest
SHA256 f616c6b2c285fc21a17fe0a708b0eb4e2dfc2ecfa9c2230eca6a9d1f28a4803a
MD5 bdcc3d2b4e58aec9b75b8c7c47130e39
BLAKE2b-256 f737b6cec67248f9a0bfd872eb1c9dca29cc229d684e27f14f71bd99aba13b6d

See more details on using hashes here.

File details

Details for the file annex4ac-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: annex4ac-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 267.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for annex4ac-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d058dc247c189f5dc81de1332d8fade7be58c8f8b09c40f81d98cc676ac38f69
MD5 94730300a137a776de6d1483f4687542
BLAKE2b-256 c2b734fe8544cecd12671c7eaf95934289b9d08ce3613d7dcad61798d71d5a5b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page