@euconform/core 1.0.1 → 1.2.0

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.
Files changed (71) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +6 -0
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/inference/ollama-client.d.ts +1 -0
  7. package/dist/inference/ollama-client.d.ts.map +1 -1
  8. package/dist/inference/ollama-client.js +15 -5
  9. package/dist/legal-checks/annex-iv-report.d.ts +3 -0
  10. package/dist/legal-checks/annex-iv-report.d.ts.map +1 -1
  11. package/dist/legal-checks/annex-iv-report.js +1 -0
  12. package/dist/legal-checks/deadline-timeline.d.ts +57 -0
  13. package/dist/legal-checks/deadline-timeline.d.ts.map +1 -0
  14. package/dist/legal-checks/deadline-timeline.js +265 -0
  15. package/dist/legal-checks/gap-analysis.d.ts +48 -0
  16. package/dist/legal-checks/gap-analysis.d.ts.map +1 -0
  17. package/dist/legal-checks/gap-analysis.js +397 -0
  18. package/dist/legal-checks/gpai-classifier.d.ts +49 -0
  19. package/dist/legal-checks/gpai-classifier.d.ts.map +1 -0
  20. package/dist/legal-checks/gpai-classifier.js +197 -0
  21. package/dist/legal-checks/index.d.ts +6 -0
  22. package/dist/legal-checks/index.d.ts.map +1 -1
  23. package/dist/legal-checks/index.js +3 -0
  24. package/package.json +1 -1
  25. package/src/index.ts +25 -0
  26. package/src/inference/ollama-client.ts +21 -5
  27. package/src/legal-checks/annex-iv-report.ts +4 -0
  28. package/src/legal-checks/deadline-timeline.ts +313 -0
  29. package/src/legal-checks/gap-analysis.ts +454 -0
  30. package/src/legal-checks/gpai-classifier.ts +281 -0
  31. package/src/legal-checks/index.ts +33 -0
  32. package/tests/gpai-classifier.test.ts +125 -0
  33. package/tests/gpai-timeline.test.ts +55 -0
  34. package/.turbo/turbo-check-types.log +0 -4
  35. package/.turbo/turbo-test.log +0 -364
  36. package/coverage/base.css +0 -224
  37. package/coverage/block-navigation.js +0 -87
  38. package/coverage/clover.xml +0 -3282
  39. package/coverage/coverage-final.json +0 -20
  40. package/coverage/favicon.png +0 -0
  41. package/coverage/index.html +0 -161
  42. package/coverage/prettify.css +0 -1
  43. package/coverage/prettify.js +0 -2
  44. package/coverage/sort-arrow-sprite.png +0 -0
  45. package/coverage/sorter.js +0 -210
  46. package/coverage/src/fairness-metrics.ts.html +0 -1579
  47. package/coverage/src/index.html +0 -161
  48. package/coverage/src/index.ts.html +0 -535
  49. package/coverage/src/inference/browser-inference.ts.html +0 -859
  50. package/coverage/src/inference/capability-detection.ts.html +0 -2227
  51. package/coverage/src/inference/index.html +0 -176
  52. package/coverage/src/inference/index.ts.html +0 -553
  53. package/coverage/src/inference/inference-factory.ts.html +0 -751
  54. package/coverage/src/inference/ollama-client.ts.html +0 -1627
  55. package/coverage/src/legal-checks/annex-iv-report.ts.html +0 -556
  56. package/coverage/src/legal-checks/bias-metrics.ts.html +0 -1855
  57. package/coverage/src/legal-checks/data-governance.ts.html +0 -529
  58. package/coverage/src/legal-checks/human-oversight-logging.ts.html +0 -490
  59. package/coverage/src/legal-checks/index.html +0 -206
  60. package/coverage/src/legal-checks/index.ts.html +0 -250
  61. package/coverage/src/legal-checks/risk-classifier.ts.html +0 -940
  62. package/coverage/src/legal-checks/robustness-transparency.ts.html +0 -571
  63. package/coverage/src/metrics/crows-pairs-bias.ts.html +0 -820
  64. package/coverage/src/metrics/index.html +0 -146
  65. package/coverage/src/metrics/index.ts.html +0 -151
  66. package/coverage/src/metrics/stereotype-bias.ts.html +0 -886
  67. package/coverage/src/risk-engine.ts.html +0 -1660
  68. package/coverage/src/types.ts.html +0 -547
  69. package/dist/legal-checks/disclaimer.d.ts +0 -2
  70. package/dist/legal-checks/disclaimer.d.ts.map +0 -1
  71. package/dist/legal-checks/disclaimer.js +0 -1
@@ -0,0 +1,397 @@
1
+ /**
2
+ * Compliance Gap Analysis Generator
3
+ * Produces prioritized action plans from EU AI Act assessment results.
4
+ *
5
+ * Supports:
6
+ * - Annex III high-risk assessment → mandatory Art. 9–15 + Art. 43 + Art. 71 obligations
7
+ * - GPAI compliance assessment → gaps directly from GPAIComplianceResult flags
8
+ *
9
+ * IMPORTANT: This module provides technical orientation, not legal advice.
10
+ */
11
+ // ---------------------------------------------------------------------------
12
+ // Annex III: Mandatory obligations for ALL high-risk systems (Art. 9–15 + Art. 43 + Art. 71 + Art. 72)
13
+ // ---------------------------------------------------------------------------
14
+ const HIGH_RISK_OBLIGATIONS = [
15
+ {
16
+ id: "risk-management-system",
17
+ title: "Risk Management System",
18
+ description: "Establish and maintain a continuous risk management system covering the full AI system lifecycle.",
19
+ articleRef: "Art. 9",
20
+ priority: "critical",
21
+ status: "missing",
22
+ steps: [
23
+ "Identify and analyze foreseeable risks to health, safety, and fundamental rights",
24
+ "Implement risk mitigation measures proportionate to identified risks",
25
+ "Test residual risks against acceptance criteria before deployment",
26
+ "Document and update risk assessment throughout lifecycle",
27
+ ],
28
+ penaltyRef: "Art. 99(3)",
29
+ },
30
+ {
31
+ id: "data-governance",
32
+ title: "Data Governance & Training Data",
33
+ description: "Implement data governance practices covering training, validation, and testing datasets.",
34
+ articleRef: "Art. 10",
35
+ priority: "critical",
36
+ status: "missing",
37
+ steps: [
38
+ "Document data sources, collection methods, and data preparation processes",
39
+ "Assess training data for biases that could lead to discriminatory outcomes",
40
+ "Implement data quality and relevance criteria appropriate to the intended purpose",
41
+ "Establish and document data governance policies",
42
+ ],
43
+ penaltyRef: "Art. 99(3)",
44
+ },
45
+ {
46
+ id: "technical-documentation",
47
+ title: "Technical Documentation (Annex IV)",
48
+ description: "Prepare and maintain comprehensive technical documentation per Annex IV.",
49
+ articleRef: "Art. 11 + Annex IV",
50
+ priority: "critical",
51
+ status: "missing",
52
+ steps: [
53
+ "Document general system description including intended purpose and high-risk category",
54
+ "Describe design specifications, architecture, and development methods",
55
+ "Document training methods, datasets, and accuracy/robustness metrics",
56
+ "Keep documentation up-to-date throughout the system lifecycle",
57
+ ],
58
+ penaltyRef: "Art. 99(3)",
59
+ },
60
+ {
61
+ id: "record-keeping",
62
+ title: "Logging & Record-Keeping",
63
+ description: "Implement automatic logging capabilities throughout system operation.",
64
+ articleRef: "Art. 12",
65
+ priority: "high",
66
+ status: "missing",
67
+ steps: [
68
+ "Enable automatic logging of system events during operation",
69
+ "Ensure logs identify operating periods and referenced databases used",
70
+ "Retain logs for minimum 6 months (or as required by sector regulations)",
71
+ "Implement secure log storage with appropriate access controls",
72
+ ],
73
+ penaltyRef: "Art. 99(3)",
74
+ },
75
+ {
76
+ id: "transparency-information",
77
+ title: "Transparency & User Information",
78
+ description: "Provide clear instructions for use and ensure deployers and users understand the system.",
79
+ articleRef: "Art. 13",
80
+ priority: "high",
81
+ status: "missing",
82
+ steps: [
83
+ "Prepare instructions for use covering capabilities, limitations, and intended purpose",
84
+ "Disclose the AI nature of the system clearly",
85
+ "Inform users about accuracy levels and known limitations",
86
+ "Document contact information for user questions and complaints",
87
+ ],
88
+ penaltyRef: "Art. 99(3)",
89
+ },
90
+ {
91
+ id: "human-oversight",
92
+ title: "Human Oversight Measures",
93
+ description: "Enable meaningful human oversight of the AI system throughout its operation.",
94
+ articleRef: "Art. 14",
95
+ priority: "high",
96
+ status: "missing",
97
+ steps: [
98
+ "Implement interfaces enabling human monitoring of AI outputs",
99
+ "Ensure humans can override, correct, or disregard AI decisions",
100
+ "Train persons responsible for oversight on capabilities and limitations",
101
+ "Document human oversight procedures",
102
+ ],
103
+ penaltyRef: "Art. 99(3)",
104
+ },
105
+ {
106
+ id: "accuracy-robustness",
107
+ title: "Accuracy, Robustness & Cybersecurity",
108
+ description: "Ensure the system meets required accuracy levels and is resilient against errors and attacks.",
109
+ articleRef: "Art. 15",
110
+ priority: "high",
111
+ status: "missing",
112
+ steps: [
113
+ "Define and test accuracy metrics appropriate to the intended purpose",
114
+ "Test for robustness against errors, faults, and inconsistencies",
115
+ "Implement cybersecurity measures against adversarial manipulation",
116
+ "Document all performance metrics in technical documentation",
117
+ ],
118
+ penaltyRef: "Art. 99(3)",
119
+ },
120
+ {
121
+ id: "conformity-assessment",
122
+ title: "Conformity Assessment",
123
+ description: "Conduct conformity assessment before placing the system on the EU market.",
124
+ articleRef: "Art. 43",
125
+ priority: "critical",
126
+ status: "missing",
127
+ steps: [
128
+ "Determine the applicable conformity assessment procedure for your category",
129
+ "Conduct internal assessment OR involve a notified body (depending on category)",
130
+ "Draw up EU declaration of conformity per Annex V",
131
+ "Affix CE marking to the system or accompanying documentation",
132
+ ],
133
+ penaltyRef: "Art. 99(4)",
134
+ },
135
+ {
136
+ id: "eu-database-registration",
137
+ title: "EU AI Database Registration",
138
+ description: "Register the high-risk AI system in the EU AI Database before market placement.",
139
+ articleRef: "Art. 71",
140
+ priority: "critical",
141
+ status: "missing",
142
+ steps: [
143
+ "Create an account on the EU AI Database (managed by the AI Office)",
144
+ "Provide all required information per Art. 71(3)",
145
+ "Register before placing the system on the EU market",
146
+ "Update the registration when significant modifications occur",
147
+ ],
148
+ penaltyRef: "Art. 99(4)",
149
+ },
150
+ {
151
+ id: "post-market-monitoring",
152
+ title: "Post-Market Monitoring",
153
+ description: "Set up a post-market monitoring system to track performance and report incidents.",
154
+ articleRef: "Art. 72",
155
+ priority: "medium",
156
+ status: "missing",
157
+ steps: [
158
+ "Establish a post-market monitoring plan before deployment",
159
+ "Collect and analyze data on system performance over time",
160
+ "Report serious incidents to national market surveillance authorities",
161
+ "Report near misses and systemic issues to the AI Office",
162
+ ],
163
+ penaltyRef: "Art. 99(3)",
164
+ },
165
+ ];
166
+ // ---------------------------------------------------------------------------
167
+ // GPAI: Detailed gap definitions for each obligation type
168
+ // ---------------------------------------------------------------------------
169
+ const GPAI_OBLIGATION_GAPS = {
170
+ "technical-docs": {
171
+ title: "Technical Documentation (Annex XI/XII)",
172
+ description: "Prepare and maintain technical documentation covering the GPAI model per Annex XI (standard) or Annex XII (systemic risk extension).",
173
+ articleRef: "Art. 53(1)(a)",
174
+ priority: "critical",
175
+ steps: [
176
+ "Document general model description, training approach, and architecture",
177
+ "List training data sources, data governance policies, and total compute (FLOP)",
178
+ "Document capabilities, limitations, and foreseeable misuse risks",
179
+ "Keep documentation updated with each significant model change",
180
+ ],
181
+ penaltyRef: "Art. 101",
182
+ },
183
+ "downstream-info": {
184
+ title: "Downstream Provider Information Package",
185
+ description: "Provide downstream providers with all information they need for their own EU AI Act obligations.",
186
+ articleRef: "Art. 53(1)(b)",
187
+ priority: "critical",
188
+ steps: [
189
+ "Document model capabilities, limitations, and intended use cases",
190
+ "Specify restrictions on use and integration requirements",
191
+ "Provide API documentation and integration guidance",
192
+ "Update the information package when the model is updated",
193
+ ],
194
+ penaltyRef: "Art. 101",
195
+ },
196
+ "copyright-policy": {
197
+ title: "Copyright Policy + Training Data Summary",
198
+ description: "Establish a copyright compliance policy and publish a training data summary.",
199
+ articleRef: "Art. 53(1)(c–d)",
200
+ priority: "high",
201
+ steps: [
202
+ "Implement a text and data mining (TDM) opt-out compliance policy (Art. 53(1)(c))",
203
+ "Publish a sufficiently detailed training data summary (Art. 53(1)(d))",
204
+ "Document copyright clearances obtained for training data",
205
+ "Establish an ongoing compliance process for future training data updates",
206
+ ],
207
+ penaltyRef: "Art. 101",
208
+ },
209
+ "eu-database": {
210
+ title: "EU AI Database Registration",
211
+ description: "Register the GPAI model in the EU AI Database before placing it on the EU market.",
212
+ articleRef: "Art. 71",
213
+ priority: "critical",
214
+ steps: [
215
+ "Access the EU AI Database portal managed by the AI Office",
216
+ "Provide required model information including name, type, and capabilities",
217
+ "Register before placing the model on the EU market",
218
+ "Update the registration when the model is significantly updated",
219
+ ],
220
+ penaltyRef: "Art. 101",
221
+ },
222
+ "open-source": {
223
+ title: "Open-Source Release Compliance",
224
+ description: "Verify compliance with remaining obligations that apply despite the open-source exemption.",
225
+ articleRef: "Art. 53(2)",
226
+ priority: "medium",
227
+ steps: [
228
+ "Confirm that weights, parameters, and architecture are publicly available",
229
+ "Ensure Art. 53(1)(d) training data summary obligation is still fulfilled",
230
+ "If systemic risk threshold is met, Art. 55 obligations remain applicable",
231
+ ],
232
+ },
233
+ "systemic-risk": {
234
+ title: "Systemic Risk Threshold Verification",
235
+ description: "Formally determine if the model meets the ≥10²⁵ FLOP systemic risk threshold.",
236
+ articleRef: "Art. 51 + Annex XIII",
237
+ priority: "high",
238
+ steps: [
239
+ "Document total training compute (FLOP) with engineering sign-off",
240
+ "Consult with technical experts if compute is near the threshold",
241
+ "If threshold is met, implement all Art. 55 obligations",
242
+ "Notify the AI Office if the systemic risk threshold is reached",
243
+ ],
244
+ },
245
+ "red-teaming": {
246
+ title: "Adversarial Testing / Red-Teaming",
247
+ description: "Conduct model evaluations and adversarial testing to identify and mitigate systemic risks.",
248
+ articleRef: "Art. 55(1)(a)",
249
+ priority: "critical",
250
+ steps: [
251
+ "Define red-teaming scope covering systemic risks (CBRN, cyberattacks, disinformation, etc.)",
252
+ "Conduct standardized evaluations per AI Office guidelines and emerging standards",
253
+ "Engage external domain experts for adversarial testing",
254
+ "Document findings and implement mitigation measures",
255
+ "Repeat evaluations before each significant model release",
256
+ ],
257
+ penaltyRef: "Art. 101",
258
+ },
259
+ "incident-reporting": {
260
+ title: "Serious Incident Reporting Mechanisms",
261
+ description: "Establish systems to track and report serious incidents caused by the GPAI model.",
262
+ articleRef: "Art. 55(1)(b)",
263
+ priority: "critical",
264
+ steps: [
265
+ "Define criteria for what constitutes a serious incident for your GPAI model",
266
+ "Implement an incident tracking and documentation system",
267
+ "Establish a direct reporting channel to the AI Office",
268
+ "Set up notification procedures for affected national authorities and users",
269
+ "Document incident response and remediation procedures",
270
+ ],
271
+ penaltyRef: "Art. 101",
272
+ },
273
+ cybersecurity: {
274
+ title: "Cybersecurity Measures",
275
+ description: "Implement adequate cybersecurity protections for the GPAI model and its infrastructure.",
276
+ articleRef: "Art. 55(1)(c)",
277
+ priority: "high",
278
+ steps: [
279
+ "Assess cybersecurity risks specific to the GPAI model and API surface",
280
+ "Implement adversarial robustness measures against prompt injection and model extraction",
281
+ "Secure training infrastructure, model weights, and API endpoints",
282
+ "Document cybersecurity measures in Annex XII technical documentation",
283
+ ],
284
+ penaltyRef: "Art. 101",
285
+ },
286
+ };
287
+ // ---------------------------------------------------------------------------
288
+ // Public API
289
+ // ---------------------------------------------------------------------------
290
+ const PRIORITY_ORDER = { critical: 0, high: 1, medium: 2 };
291
+ const SORTED_HIGH_RISK_OBLIGATIONS = [...HIGH_RISK_OBLIGATIONS].sort((a, b) => PRIORITY_ORDER[a.priority] - PRIORITY_ORDER[b.priority]);
292
+ function countByPriority(actions) {
293
+ let criticalCount = 0;
294
+ let highCount = 0;
295
+ let mediumCount = 0;
296
+ for (const a of actions) {
297
+ if (a.priority === "critical")
298
+ criticalCount++;
299
+ else if (a.priority === "high")
300
+ highCount++;
301
+ else
302
+ mediumCount++;
303
+ }
304
+ return { criticalCount, highCount, mediumCount };
305
+ }
306
+ /**
307
+ * Generate a gap analysis action plan from an Annex III risk assessment.
308
+ *
309
+ * - unacceptable → Art. 5 prohibition action (critical)
310
+ * - high → all mandatory Art. 9–15 + Art. 43 + Art. 71 + Art. 72 obligations
311
+ * - limited → Art. 50 transparency obligations
312
+ * - minimal → no gaps
313
+ */
314
+ export function generateAnnexIIIGapAnalysis(assessment) {
315
+ if (assessment.level === "minimal") {
316
+ return { totalGaps: 0, criticalCount: 0, highCount: 0, mediumCount: 0, actions: [] };
317
+ }
318
+ if (assessment.level === "unacceptable") {
319
+ const actions = [
320
+ {
321
+ id: "prohibited-ai",
322
+ title: "Prohibited AI System (Art. 5)",
323
+ description: "This system shows characteristics potentially prohibited under Art. 5. Do not deploy in the EU without comprehensive legal review.",
324
+ articleRef: "Art. 5",
325
+ priority: "critical",
326
+ status: "missing",
327
+ steps: [
328
+ "Immediately halt deployment plans for the EU market",
329
+ "Seek qualified legal counsel to assess whether the Art. 5 prohibition applies",
330
+ "Consider fundamental system redesign to eliminate prohibited characteristics",
331
+ ],
332
+ penaltyRef: "Art. 99(4)",
333
+ },
334
+ ];
335
+ return { totalGaps: 1, criticalCount: 1, highCount: 0, mediumCount: 0, actions };
336
+ }
337
+ if (assessment.level === "limited") {
338
+ const actions = [
339
+ {
340
+ id: "ai-interaction-disclosure",
341
+ title: "AI Interaction Disclosure",
342
+ description: "Inform users that they are interacting with an AI system (Art. 50(1)).",
343
+ articleRef: "Art. 50(1)",
344
+ priority: "high",
345
+ status: "missing",
346
+ steps: [
347
+ "Add a clear disclosure at the start of each AI interaction",
348
+ "Exception: disclosure not required if obvious from context to a reasonable person",
349
+ "Document the disclosure mechanism in your compliance records",
350
+ ],
351
+ penaltyRef: "Art. 99(3)",
352
+ },
353
+ {
354
+ id: "ai-content-labeling",
355
+ title: "AI-Generated Content Labeling",
356
+ description: "Label AI-generated audio, image, video, or text content that could mislead users (Art. 50(2–4)).",
357
+ articleRef: "Art. 50(2–4)",
358
+ priority: "high",
359
+ status: "partial",
360
+ steps: [
361
+ "Implement machine-readable marking of AI-generated content",
362
+ "Add visible disclosure for synthetic media (deepfakes, AI-generated images/video)",
363
+ "Apply Art. 50(4) disclosure for emotion recognition or biometric categorization",
364
+ ],
365
+ penaltyRef: "Art. 99(3)",
366
+ },
367
+ ];
368
+ return {
369
+ totalGaps: actions.length,
370
+ ...countByPriority(actions),
371
+ actions,
372
+ };
373
+ }
374
+ // high: all mandatory obligations, pre-sorted at module init
375
+ return {
376
+ totalGaps: SORTED_HIGH_RISK_OBLIGATIONS.length,
377
+ ...countByPriority(SORTED_HIGH_RISK_OBLIGATIONS),
378
+ actions: SORTED_HIGH_RISK_OBLIGATIONS,
379
+ };
380
+ }
381
+ /**
382
+ * Generate a gap analysis action plan from a GPAI compliance result.
383
+ * Only generates actions for obligations flagged as missing or partial.
384
+ */
385
+ export function generateGPAIGapAnalysis(result) {
386
+ if (result.flags.length === 0) {
387
+ return { totalGaps: 0, criticalCount: 0, highCount: 0, mediumCount: 0, actions: [] };
388
+ }
389
+ const actions = result.flags
390
+ .map((flag) => ({
391
+ id: flag.obligation,
392
+ status: flag.status,
393
+ ...GPAI_OBLIGATION_GAPS[flag.obligation],
394
+ }))
395
+ .sort((a, b) => PRIORITY_ORDER[a.priority] - PRIORITY_ORDER[b.priority]);
396
+ return { totalGaps: actions.length, ...countByPriority(actions), actions };
397
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * GPAI / Foundation Model Compliance Classifier
3
+ * Based on EU AI Act (Regulation EU 2024/1689) – Art. 53–55 + Art. 51 + Art. 71
4
+ *
5
+ * Obligations enforceable since August 2, 2025 (Phase 2, Art. 113(2)).
6
+ *
7
+ * IMPORTANT: This module provides technical orientation, not legal advice.
8
+ */
9
+ import type { QuizAnswer, QuizQuestion } from "../types";
10
+ /** The specific obligations checked under Art. 53–55 */
11
+ export type GPAIObligationType = "technical-docs" | "downstream-info" | "copyright-policy" | "eu-database" | "open-source" | "systemic-risk" | "red-teaming" | "incident-reporting" | "cybersecurity";
12
+ /** Overall compliance determination */
13
+ export type GPAIComplianceLevel = "compliant" | "partial" | "non-compliant";
14
+ /** A specific obligation that is missing or only partially met */
15
+ export interface GPAIComplianceFlag {
16
+ obligation: GPAIObligationType;
17
+ status: "missing" | "partial";
18
+ articleRef: string;
19
+ }
20
+ /** Full result of GPAI compliance classification */
21
+ export interface GPAIComplianceResult {
22
+ level: GPAIComplianceLevel;
23
+ isSystemicRisk: boolean;
24
+ flags: GPAIComplianceFlag[];
25
+ legalBasis: string[];
26
+ notes: string[];
27
+ }
28
+ /**
29
+ * The 9 GPAI compliance questions (Art. 53–55).
30
+ * Order matters: q1–q9 map to i18n keys gpai_q1–gpai_q9.
31
+ */
32
+ export declare const GPAI_QUESTIONS: QuizQuestion[];
33
+ /** Returns the full ordered list of GPAI compliance questions */
34
+ export declare function getGPAIQuestions(): QuizQuestion[];
35
+ /** Returns true if the model meets the systemic risk threshold (Art. 51) */
36
+ export declare function isSystemicRiskModel(answers: QuizAnswer[]): boolean;
37
+ /**
38
+ * Classify GPAI compliance based on answers to the 9 questions.
39
+ * Returns a GPAIComplianceResult with level, flags, and legal basis.
40
+ *
41
+ * Classification logic:
42
+ * - Open-source (Art. 53(2)): exempt from docs/downstream/copyright obligations
43
+ * - Systemic risk (Art. 51): Art. 55 obligations apply
44
+ * - Critical Art. 53 all missing → "non-compliant"
45
+ * - Any "unsure" or partial → "partial"
46
+ * - All applicable "yes" → "compliant"
47
+ */
48
+ export declare function classifyGPAICompliance(answers: QuizAnswer[]): GPAIComplianceResult;
49
+ //# sourceMappingURL=gpai-classifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gpai-classifier.d.ts","sourceRoot":"","sources":["../../src/legal-checks/gpai-classifier.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEzD,wDAAwD;AACxD,MAAM,MAAM,kBAAkB,GAC1B,gBAAgB,GAChB,iBAAiB,GACjB,kBAAkB,GAClB,aAAa,GACb,aAAa,GACb,eAAe,GACf,aAAa,GACb,oBAAoB,GACpB,eAAe,CAAC;AAEpB,uCAAuC;AACvC,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,SAAS,GAAG,eAAe,CAAC;AAE5E,kEAAkE;AAClE,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,kBAAkB,CAAC;IAC/B,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,oDAAoD;AACpD,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,mBAAmB,CAAC;IAC3B,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,YAAY,EAoGxC,CAAC;AAEF,iEAAiE;AACjE,wBAAgB,gBAAgB,IAAI,YAAY,EAAE,CAEjD;AAED,4EAA4E;AAC5E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,OAAO,CAGlE;AAsFD;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,oBAAoB,CA0BlF"}
@@ -0,0 +1,197 @@
1
+ /**
2
+ * GPAI / Foundation Model Compliance Classifier
3
+ * Based on EU AI Act (Regulation EU 2024/1689) – Art. 53–55 + Art. 51 + Art. 71
4
+ *
5
+ * Obligations enforceable since August 2, 2025 (Phase 2, Art. 113(2)).
6
+ *
7
+ * IMPORTANT: This module provides technical orientation, not legal advice.
8
+ */
9
+ /**
10
+ * The 9 GPAI compliance questions (Art. 53–55).
11
+ * Order matters: q1–q9 map to i18n keys gpai_q1–gpai_q9.
12
+ */
13
+ export const GPAI_QUESTIONS = [
14
+ {
15
+ id: "gpai-technical-docs",
16
+ question: "Art. 53(1)(a): Technical documentation (Annex XI/XII)?",
17
+ description: "Have you prepared and maintain up-to-date technical documentation for the GPAI model per Annex XI/XII (general-purpose) or the systemic-risk extension?",
18
+ options: [
19
+ { value: "yes", label: "Yes, implemented" },
20
+ { value: "no", label: "No, missing" },
21
+ { value: "unsure", label: "In progress / unsure" },
22
+ ],
23
+ },
24
+ {
25
+ id: "gpai-downstream-info",
26
+ question: "Art. 53(1)(b): Downstream provider information?",
27
+ description: "Do you provide downstream providers / deployers with the information they need to comply with their own EU AI Act obligations (capabilities, limitations, intended use)?",
28
+ options: [
29
+ { value: "yes", label: "Yes, implemented" },
30
+ { value: "no", label: "No, missing" },
31
+ { value: "unsure", label: "In progress / unsure" },
32
+ ],
33
+ },
34
+ {
35
+ id: "gpai-copyright-policy",
36
+ question: "Art. 53(1)(c–d): Copyright policy + training data summary?",
37
+ description: "Have you established a copyright compliance policy (Art. 53(1)(c)) and published a sufficiently detailed training data summary for copyright purposes (Art. 53(1)(d))?",
38
+ options: [
39
+ { value: "yes", label: "Yes, implemented" },
40
+ { value: "no", label: "No, missing" },
41
+ { value: "unsure", label: "In progress / unsure" },
42
+ ],
43
+ },
44
+ {
45
+ id: "gpai-eu-database",
46
+ question: "Art. 71: EU AI Database registration?",
47
+ description: "Is the GPAI model registered in the EU AI Database as required under Art. 71 (providers of GPAI models must register before placing the model on the EU market)?",
48
+ options: [
49
+ { value: "yes", label: "Yes, registered" },
50
+ { value: "no", label: "No, not registered" },
51
+ { value: "unsure", label: "In progress / unsure" },
52
+ ],
53
+ },
54
+ {
55
+ id: "gpai-open-source",
56
+ question: "Art. 53(2): Open-source model release?",
57
+ description: "Is the model released as open source with weights publicly available? Open-source GPAI models are exempt from Art. 53(1)(a–c) obligations (technical docs, downstream info, copyright policy) but not from Art. 53(1)(d) (training data summary) or Art. 55 systemic-risk obligations.",
58
+ options: [
59
+ { value: "yes", label: "Yes, open source" },
60
+ { value: "no", label: "No, proprietary" },
61
+ { value: "unsure", label: "Unsure / partially open" },
62
+ ],
63
+ },
64
+ {
65
+ id: "gpai-systemic-risk",
66
+ question: "Art. 51 + Annex XIII: Trained with ≥ 10²⁵ FLOP?",
67
+ description: "Was the model trained using compute exceeding 10²⁵ floating-point operations (FLOP)? Models at or above this threshold are designated as GPAI models with systemic risk (Art. 51) and are subject to the additional Art. 55 obligations below.",
68
+ options: [
69
+ { value: "yes", label: "Yes (systemic risk)" },
70
+ { value: "no", label: "No (below threshold)" },
71
+ { value: "unsure", label: "Unknown / unsure" },
72
+ ],
73
+ },
74
+ {
75
+ id: "gpai-red-teaming",
76
+ question: "Art. 55(1)(a): Adversarial testing / red-teaming?",
77
+ description: "Have you conducted model evaluations, adversarial testing, and red-teaming to identify and mitigate systemic risks (required only for Art. 51 systemic-risk models)?",
78
+ options: [
79
+ { value: "yes", label: "Yes, conducted" },
80
+ { value: "no", label: "No, not done" },
81
+ { value: "unsure", label: "In progress / unsure" },
82
+ ],
83
+ },
84
+ {
85
+ id: "gpai-incident-reporting",
86
+ question: "Art. 55(1)(b): Serious incident reporting mechanisms?",
87
+ description: "Do you have mechanisms to track, document, and report serious incidents caused by the GPAI model to the AI Office and affected national authorities (required only for Art. 51 systemic-risk models)?",
88
+ options: [
89
+ { value: "yes", label: "Yes, in place" },
90
+ { value: "no", label: "No, missing" },
91
+ { value: "unsure", label: "In progress / unsure" },
92
+ ],
93
+ },
94
+ {
95
+ id: "gpai-cybersecurity",
96
+ question: "Art. 55(1)(c): Cybersecurity measures?",
97
+ description: "Have you implemented adequate cybersecurity protections for the GPAI model and its infrastructure, including adversarial robustness measures (required only for Art. 51 systemic-risk models)?",
98
+ options: [
99
+ { value: "yes", label: "Yes, implemented" },
100
+ { value: "no", label: "No, missing" },
101
+ { value: "unsure", label: "In progress / unsure" },
102
+ ],
103
+ },
104
+ ];
105
+ /** Returns the full ordered list of GPAI compliance questions */
106
+ export function getGPAIQuestions() {
107
+ return GPAI_QUESTIONS;
108
+ }
109
+ /** Returns true if the model meets the systemic risk threshold (Art. 51) */
110
+ export function isSystemicRiskModel(answers) {
111
+ const systemicAnswer = answers.find((a) => a.questionId === "gpai-systemic-risk");
112
+ return systemicAnswer?.value === "yes";
113
+ }
114
+ /** Push a flag if the answer value is "no" or "unsure" */
115
+ function checkObligation(value, obligation, articleRef, flags) {
116
+ if (value === "no") {
117
+ flags.push({ obligation, status: "missing", articleRef });
118
+ }
119
+ else if (value === "unsure") {
120
+ flags.push({ obligation, status: "partial", articleRef });
121
+ }
122
+ }
123
+ /** Evaluate Art. 53 obligations and populate flags / notes */
124
+ function evaluateArt53Obligations(byId, isOpenSource, flags, legalBasis, notes) {
125
+ if (!isOpenSource) {
126
+ checkObligation(byId.get("gpai-technical-docs"), "technical-docs", "Art. 53(1)(a)", flags);
127
+ checkObligation(byId.get("gpai-downstream-info"), "downstream-info", "Art. 53(1)(b)", flags);
128
+ checkObligation(byId.get("gpai-copyright-policy"), "copyright-policy", "Art. 53(1)(c–d)", flags);
129
+ }
130
+ else {
131
+ // Open-source: Art. 53(1)(a–c) exempt, but training data summary (Art. 53(1)(d)) still applies
132
+ const copyrightVal = byId.get("gpai-copyright-policy");
133
+ checkObligation(copyrightVal, "copyright-policy", "Art. 53(1)(d)", flags);
134
+ if (copyrightVal === "no" || copyrightVal === "unsure") {
135
+ notes.push("Open-source models are exempt from Art. 53(1)(c) copyright policy obligations, but Art. 53(1)(d) training data summary still applies.");
136
+ }
137
+ }
138
+ const euDatabase = byId.get("gpai-eu-database");
139
+ checkObligation(euDatabase, "eu-database", "Art. 71", flags);
140
+ if (euDatabase === "no") {
141
+ legalBasis.push("Verordnung (EU) 2024/1689 – Art. 71 (EU AI Database)");
142
+ }
143
+ }
144
+ /** Evaluate Art. 55 systemic risk obligations and populate flags */
145
+ function evaluateArt55Obligations(byId, flags, legalBasis) {
146
+ legalBasis.push("Verordnung (EU) 2024/1689 – Art. 51 + Art. 55 (Systemic Risk)");
147
+ legalBasis.push("Verordnung (EU) 2024/1689 – Annex XIII (Systemic Risk Indicators)");
148
+ checkObligation(byId.get("gpai-red-teaming"), "red-teaming", "Art. 55(1)(a)", flags);
149
+ checkObligation(byId.get("gpai-incident-reporting"), "incident-reporting", "Art. 55(1)(b)", flags);
150
+ checkObligation(byId.get("gpai-cybersecurity"), "cybersecurity", "Art. 55(1)(c)", flags);
151
+ }
152
+ /** Determine overall compliance level from accumulated flags */
153
+ function determineLevel(flags, isOpenSource) {
154
+ const criticalObligations = isOpenSource
155
+ ? ["eu-database"]
156
+ : ["technical-docs", "downstream-info", "copyright-policy", "eu-database"];
157
+ const allCriticalMissing = !isOpenSource &&
158
+ criticalObligations.every((obl) => flags.some((f) => f.obligation === obl && f.status === "missing"));
159
+ if (allCriticalMissing)
160
+ return "non-compliant";
161
+ if (flags.length > 0)
162
+ return "partial";
163
+ return "compliant";
164
+ }
165
+ /**
166
+ * Classify GPAI compliance based on answers to the 9 questions.
167
+ * Returns a GPAIComplianceResult with level, flags, and legal basis.
168
+ *
169
+ * Classification logic:
170
+ * - Open-source (Art. 53(2)): exempt from docs/downstream/copyright obligations
171
+ * - Systemic risk (Art. 51): Art. 55 obligations apply
172
+ * - Critical Art. 53 all missing → "non-compliant"
173
+ * - Any "unsure" or partial → "partial"
174
+ * - All applicable "yes" → "compliant"
175
+ */
176
+ export function classifyGPAICompliance(answers) {
177
+ const byId = new Map(answers.map((a) => [a.questionId, a.value]));
178
+ const isOpenSource = byId.get("gpai-open-source") === "yes";
179
+ const hasSystemicRisk = byId.get("gpai-systemic-risk") === "yes";
180
+ const flags = [];
181
+ const legalBasis = ["Verordnung (EU) 2024/1689 – Art. 53 (GPAI obligations)"];
182
+ const notes = [];
183
+ evaluateArt53Obligations(byId, isOpenSource, flags, legalBasis, notes);
184
+ if (hasSystemicRisk) {
185
+ evaluateArt55Obligations(byId, flags, legalBasis);
186
+ }
187
+ else {
188
+ notes.push("Art. 55 systemic risk obligations (red-teaming, incident reporting, cybersecurity) are not applicable as the model does not meet the Art. 51 threshold (≥ 10²⁵ FLOP).");
189
+ }
190
+ return {
191
+ level: determineLevel(flags, isOpenSource),
192
+ isSystemicRisk: hasSystemicRisk,
193
+ flags,
194
+ legalBasis,
195
+ notes,
196
+ };
197
+ }
@@ -10,4 +10,10 @@ export type { HumanOversightRecommendation, LoggingTemplate } from "./human-over
10
10
  export { getHumanOversightAndLoggingTemplate } from "./human-oversight-logging";
11
11
  export type { AnnexIVStructuredReportV1 } from "./annex-iv-report";
12
12
  export { buildAnnexIVReportV1 } from "./annex-iv-report";
13
+ export type { DeadlineStatus, AffectedAudience, DeadlineObligation, DeadlinePhase, } from "./deadline-timeline";
14
+ export { EU_AI_ACT_TIMELINE, DIGITAL_OMNIBUS_PROPOSALS, getDeadlineStatus, getDaysUntilDeadline, getAudiencesForRiskLevel, getNextDeadline, getTimelineForRiskLevel, getTimelineForAudiences, } from "./deadline-timeline";
15
+ export type { GPAIObligationType, GPAIComplianceLevel, GPAIComplianceFlag, GPAIComplianceResult, } from "./gpai-classifier";
16
+ export { GPAI_QUESTIONS, classifyGPAICompliance, getGPAIQuestions, isSystemicRiskModel, } from "./gpai-classifier";
17
+ export type { GapPriority, GapAction, GapAnalysisResult } from "./gap-analysis";
18
+ export { generateAnnexIIIGapAnalysis, generateGPAIGapAnalysis } from "./gap-analysis";
13
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/legal-checks/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EACL,mBAAmB,EACnB,iCAAiC,EACjC,oBAAoB,EACpB,oBAAoB,EACpB,iCAAiC,GAClC,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,QAAQ,EACR,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,EACvB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,cAAc,EACd,cAAc,EACd,kCAAkC,EAClC,8BAA8B,EAC9B,gCAAgC,EAChC,sBAAsB,EACtB,2BAA2B,EAC3B,uBAAuB,EACvB,4BAA4B,EAC5B,wBAAwB,EACxB,aAAa,EACb,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EAAE,eAAe,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAE/D,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,aAAa,GACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,wBAAwB,EACxB,iCAAiC,GAClC,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EAAE,4BAA4B,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC/F,OAAO,EAAE,mCAAmC,EAAE,MAAM,2BAA2B,CAAC;AAEhF,YAAY,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/legal-checks/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EACL,mBAAmB,EACnB,iCAAiC,EACjC,oBAAoB,EACpB,oBAAoB,EACpB,iCAAiC,GAClC,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,QAAQ,EACR,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,EACvB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,cAAc,EACd,cAAc,EACd,kCAAkC,EAClC,8BAA8B,EAC9B,gCAAgC,EAChC,sBAAsB,EACtB,2BAA2B,EAC3B,uBAAuB,EACvB,4BAA4B,EAC5B,wBAAwB,EACxB,aAAa,EACb,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EAAE,eAAe,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAE/D,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,aAAa,GACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,wBAAwB,EACxB,iCAAiC,GAClC,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EAAE,4BAA4B,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC/F,OAAO,EAAE,mCAAmC,EAAE,MAAM,2BAA2B,CAAC;AAEhF,YAAY,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,oBAAoB,EACpB,wBAAwB,EACxB,eAAe,EACf,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACV,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC"}