eu-ai-act-classifier 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,45 @@
1
+ """Deterministic EU AI Act (Reg (EU) 2024/1689) classifier.
2
+
3
+ Public API::
4
+
5
+ from eu_ai_act_classifier import classify, SystemProfile
6
+ report = classify(SystemProfile(name="...", annex_iii_area=...))
7
+ print(report.risk_tier, report.disposition)
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ from .engine import classify
13
+ from .models import (
14
+ AnnexIII,
15
+ ClassificationReport,
16
+ Derogation,
17
+ Disposition,
18
+ ExcludedUse,
19
+ ProhibitedPractice,
20
+ ReviewStatus,
21
+ RiskTier,
22
+ Role,
23
+ ScopeStatus,
24
+ SourceStatus,
25
+ SystemProfile,
26
+ )
27
+ from .report import render_report
28
+
29
+ __version__ = "0.2.0"
30
+ __all__ = [
31
+ "AnnexIII",
32
+ "ClassificationReport",
33
+ "Derogation",
34
+ "Disposition",
35
+ "ExcludedUse",
36
+ "ProhibitedPractice",
37
+ "ReviewStatus",
38
+ "RiskTier",
39
+ "Role",
40
+ "ScopeStatus",
41
+ "SourceStatus",
42
+ "SystemProfile",
43
+ "classify",
44
+ "render_report",
45
+ ]
@@ -0,0 +1,103 @@
1
+ """Optional advisory overlay from nonbinding Commission materials."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from .citations import (
6
+ AI_SYSTEM_DEFINITION_GUIDELINES_URL,
7
+ GPAI_CODE_URL,
8
+ GPAI_PROVIDER_GUIDELINES_URL,
9
+ HIGH_RISK_GUIDELINES_URL,
10
+ PROHIBITED_GUIDELINES_URL,
11
+ TRANSPARENCY_GUIDANCE_URL,
12
+ )
13
+ from .models import AdvisoryNote, SystemProfile
14
+
15
+
16
+ def build_advisory_notes(profile: SystemProfile) -> list[AdvisoryNote]:
17
+ notes = [
18
+ AdvisoryNote(
19
+ note_id="guidance.ai-system-definition",
20
+ title="AI-system-definition guidance",
21
+ detail=(
22
+ "Use the Commission AI-system-definition guidelines to support the scope "
23
+ "analysis. This advisory note does not determine legal scope."
24
+ ),
25
+ source_id="ai-system-definition-guidelines",
26
+ source_url=AI_SYSTEM_DEFINITION_GUIDELINES_URL,
27
+ )
28
+ ]
29
+
30
+ if profile.prohibited_practices:
31
+ notes.append(
32
+ AdvisoryNote(
33
+ note_id="guidance.prohibited-practices",
34
+ title="Prohibited-practices guidance",
35
+ detail=(
36
+ "Commission prohibited-practices guidance may help review the asserted "
37
+ "Art. 5 trigger and examples."
38
+ ),
39
+ source_id="prohibited-practices-guidelines",
40
+ source_url=PROHIBITED_GUIDELINES_URL,
41
+ )
42
+ )
43
+
44
+ if profile.annex_i_safety_component or profile.annex_iii_area is not None:
45
+ notes.append(
46
+ AdvisoryNote(
47
+ note_id="guidance.high-risk-classification",
48
+ title="Draft high-risk classification guidance",
49
+ detail=(
50
+ "Draft high-risk classification guidance can support the intended-purpose, "
51
+ "Annex I, Annex III and Art. 6(3) review."
52
+ ),
53
+ source_id="draft-high-risk-guidelines-2026",
54
+ source_url=HIGH_RISK_GUIDELINES_URL,
55
+ )
56
+ )
57
+
58
+ if profile.is_gpai_model:
59
+ notes.extend(
60
+ [
61
+ AdvisoryNote(
62
+ note_id="guidance.gpai-code",
63
+ title="GPAI Code of Practice",
64
+ detail=(
65
+ "The GPAI Code of Practice is a voluntary tool for transparency, "
66
+ "copyright, safety and security obligations."
67
+ ),
68
+ source_id="gpai-code-of-practice",
69
+ source_url=GPAI_CODE_URL,
70
+ ),
71
+ AdvisoryNote(
72
+ note_id="guidance.gpai-provider",
73
+ title="GPAI provider guidelines",
74
+ detail=(
75
+ "GPAI provider guidelines support scope and compliance analysis for "
76
+ "general-purpose AI model providers."
77
+ ),
78
+ source_id="gpai-provider-guidelines",
79
+ source_url=GPAI_PROVIDER_GUIDELINES_URL,
80
+ ),
81
+ ]
82
+ )
83
+
84
+ if (
85
+ profile.interacts_with_natural_persons
86
+ or profile.generates_synthetic_content
87
+ or profile.deploys_emotion_or_biometric_categorisation
88
+ or profile.generates_deepfakes
89
+ ):
90
+ notes.append(
91
+ AdvisoryNote(
92
+ note_id="guidance.transparency",
93
+ title="Transparency guidance tracker",
94
+ detail=(
95
+ "Track final Art. 50 transparency guidance and marking or labelling "
96
+ "support tools when published."
97
+ ),
98
+ source_id="transparency-guidance",
99
+ source_url=TRANSPARENCY_GUIDANCE_URL,
100
+ )
101
+ )
102
+
103
+ return notes
@@ -0,0 +1,227 @@
1
+ """Draft legal work products generated from a classification report."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import re
6
+ from pathlib import Path
7
+
8
+ from .models import ClassificationReport, Disposition, ObligationGraphItem
9
+
10
+ ARTIFACT_NAMES = {
11
+ "art-6-4-assessment",
12
+ "fria",
13
+ "annex-iv-checklist",
14
+ "post-market-monitoring-plan",
15
+ "serious-incident-register",
16
+ "gpai-model-documentation",
17
+ "training-content-summary",
18
+ }
19
+
20
+ DRAFT_NOTICE = (
21
+ "Draft only. This work product is not legal advice, not a conformity assessment "
22
+ "and not a final regulatory filing. It requires human legal review before use."
23
+ )
24
+
25
+
26
+ def selected_artifacts(selection: str) -> list[str]:
27
+ if selection == "all":
28
+ return sorted(ARTIFACT_NAMES)
29
+ if selection not in ARTIFACT_NAMES:
30
+ allowed = ", ".join(sorted(ARTIFACT_NAMES | {"all"}))
31
+ raise ValueError(f"unknown artifact '{selection}'. Allowed values: {allowed}")
32
+ return [selection]
33
+
34
+
35
+ def render_artifact(name: str, report: ClassificationReport) -> str:
36
+ if name == "art-6-4-assessment":
37
+ return _render_artifact(
38
+ "Article 6(4) Non-High-Risk Assessment",
39
+ report,
40
+ [
41
+ "Document the asserted Art. 6(3) condition.",
42
+ "Confirm that the system does not pose a significant risk of harm.",
43
+ "Confirm that the system does not materially influence decision-making outcomes.",
44
+ "Record whether profiling of natural persons is performed.",
45
+ "Record EU database registration steps where the provider relies on Art. 6(3).",
46
+ ],
47
+ )
48
+ if name == "fria":
49
+ return _render_artifact(
50
+ "Article 27 Fundamental Rights Impact Assessment",
51
+ report,
52
+ [
53
+ "Describe deployer processes and intended purpose.",
54
+ "Describe period and frequency of use.",
55
+ "Identify affected natural persons and groups.",
56
+ "Identify specific fundamental-rights risks.",
57
+ "Describe human oversight measures.",
58
+ "Describe governance, mitigation and complaint mechanisms.",
59
+ "Record whether a DPIA covers any overlapping obligation.",
60
+ ],
61
+ )
62
+ if name == "annex-iv-checklist":
63
+ return _render_artifact(
64
+ "Annex IV Technical Documentation Checklist",
65
+ report,
66
+ [
67
+ "System description and intended purpose.",
68
+ "Provider details, versioning and lifecycle information.",
69
+ "Data, training, validation and testing documentation.",
70
+ "Risk management file and residual risk decisions.",
71
+ "Human oversight, accuracy, robustness and cybersecurity controls.",
72
+ "Conformity assessment and EU declaration records.",
73
+ ],
74
+ )
75
+ if name == "post-market-monitoring-plan":
76
+ return _render_artifact(
77
+ "Post-Market Monitoring Plan",
78
+ report,
79
+ [
80
+ "Define monitoring indicators and trigger thresholds.",
81
+ "Assign owners for monitoring, escalation and corrective action.",
82
+ "Track complaints, incidents, drift, misuse and performance changes.",
83
+ "Define review cadence and evidence retention.",
84
+ ],
85
+ )
86
+ if name == "serious-incident-register":
87
+ return _render_artifact(
88
+ "Serious Incident Register",
89
+ report,
90
+ [
91
+ "Incident date and detection date.",
92
+ "System version and deployment context.",
93
+ "Affected persons, harm category and severity.",
94
+ "Immediate mitigation and corrective action.",
95
+ "Authority notification status and deadline.",
96
+ ],
97
+ )
98
+ if name == "gpai-model-documentation":
99
+ return _render_artifact(
100
+ "GPAI Model Documentation Checklist",
101
+ report,
102
+ [
103
+ "Model architecture, parameters and modalities.",
104
+ "Training and testing process.",
105
+ "Evaluation results and limitations.",
106
+ "Information for downstream providers.",
107
+ "Systemic-risk evaluation where applicable.",
108
+ ],
109
+ )
110
+ if name == "training-content-summary":
111
+ return _render_artifact(
112
+ "Training-Content Summary Checklist",
113
+ report,
114
+ [
115
+ "Training data categories and high-level proportions.",
116
+ "Major data sources and collection methods.",
117
+ "Public summary suitable for rightsholder review.",
118
+ "Copyright policy linkage and update cadence.",
119
+ ],
120
+ )
121
+ raise ValueError(f"unknown artifact '{name}'")
122
+
123
+
124
+ def write_artifacts(selection: str, directory: Path, report: ClassificationReport) -> list[Path]:
125
+ directory.mkdir(parents=True, exist_ok=True)
126
+ written: list[Path] = []
127
+ for artifact_name in selected_artifacts(selection):
128
+ path = directory / f"{_slug(report.system)}.{artifact_name}.md"
129
+ path.write_text(render_artifact(artifact_name, report), encoding="utf-8")
130
+ written.append(path)
131
+ return written
132
+
133
+
134
+ def _render_artifact(title: str, report: ClassificationReport, checklist: list[str]) -> str:
135
+ lines = [
136
+ f"# {title}",
137
+ "",
138
+ DRAFT_NOTICE,
139
+ "",
140
+ f"System: {report.system}",
141
+ f"Risk tier: {report.risk_tier.value}",
142
+ f"Disposition: {report.disposition.value}",
143
+ f"Scope status: {report.scope.status.value}",
144
+ "",
145
+ "## Review Status",
146
+ "",
147
+ _review_status(report),
148
+ "",
149
+ "## Checklist",
150
+ "",
151
+ ]
152
+ lines.extend(f"- {item}" for item in checklist)
153
+ lines.extend(
154
+ [
155
+ "",
156
+ "## Relevant Obligation Graph Items",
157
+ "",
158
+ ]
159
+ )
160
+ graph = _relevant_graph(report, title)
161
+ if graph:
162
+ lines.extend(_format_graph_item(item) for item in graph)
163
+ else:
164
+ lines.append("- No directly matching graph item. Confirm relevance in review.")
165
+ lines.extend(["", "## Open Questions", ""])
166
+ if report.open_questions:
167
+ lines.extend(f"- {question}" for question in report.open_questions)
168
+ else:
169
+ lines.append("- No open questions recorded by the classifier.")
170
+ lines.extend(["", "## Source Manifest", ""])
171
+ lines.extend(
172
+ (
173
+ f"- {source.citation_label}: {source.legal_status.value}; "
174
+ f"retrieved {source.retrieved_on}; {source.url}"
175
+ )
176
+ for source in report.source_manifest
177
+ )
178
+ return "\n".join(lines) + "\n"
179
+
180
+
181
+ def _review_status(report: ClassificationReport) -> str:
182
+ if report.disposition is Disposition.REQUIRES_REVIEW or report.open_questions:
183
+ return "Review required before this draft is relied upon."
184
+ return "Classifier status is determined, but human legal review is still required."
185
+
186
+
187
+ def _relevant_graph(report: ClassificationReport, title: str) -> list[ObligationGraphItem]:
188
+ title_lower = title.lower()
189
+ if "fria" in title_lower or "fundamental rights" in title_lower:
190
+ return [item for item in report.obligation_graph if item.article.startswith("Art. 27")]
191
+ if "annex iv" in title_lower or "technical documentation" in title_lower:
192
+ return [
193
+ item
194
+ for item in report.obligation_graph
195
+ if item.article in {"Art. 18 AIA", "Art. 53(1)(a) AIA"}
196
+ ]
197
+ if "post-market" in title_lower:
198
+ return [item for item in report.obligation_graph if item.article.startswith("Art. 72")]
199
+ if "serious incident" in title_lower:
200
+ return [
201
+ item
202
+ for item in report.obligation_graph
203
+ if item.article.startswith("Art. 73") or item.article.startswith("Art. 55(1)(c)")
204
+ ]
205
+ if "gpai" in title_lower:
206
+ return [
207
+ item
208
+ for item in report.obligation_graph
209
+ if item.article.startswith("Art. 53") or item.article.startswith("Art. 55")
210
+ ]
211
+ if "training-content" in title_lower:
212
+ return [item for item in report.obligation_graph if item.article == "Art. 53(1)(d) AIA"]
213
+ if "6(4)" in title_lower:
214
+ return [item for item in report.obligation_graph if item.article == "Art. 49 AIA"]
215
+ return []
216
+
217
+
218
+ def _format_graph_item(item: ObligationGraphItem) -> str:
219
+ return (
220
+ f"- {item.article} ({item.actor.value}): {item.requirement} "
221
+ f"Evidence: {item.evidence_artifact}. Review: {item.review_status.value}."
222
+ )
223
+
224
+
225
+ def _slug(value: str) -> str:
226
+ slug = re.sub(r"[^a-zA-Z0-9]+", "-", value.strip().lower()).strip("-")
227
+ return slug or "ai-system"