@euconform/core 1.0.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.
- package/.turbo/turbo-build.log +4 -0
- package/LICENSE +21 -0
- package/dist/fairness-metrics.d.ts +65 -0
- package/dist/fairness-metrics.d.ts.map +1 -0
- package/dist/fairness-metrics.js +394 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/inference/browser-inference.d.ts +60 -0
- package/dist/inference/browser-inference.d.ts.map +1 -0
- package/dist/inference/browser-inference.js +221 -0
- package/dist/inference/capability-detection.d.ts +183 -0
- package/dist/inference/capability-detection.d.ts.map +1 -0
- package/dist/inference/capability-detection.js +552 -0
- package/dist/inference/index.d.ts +43 -0
- package/dist/inference/index.d.ts.map +1 -0
- package/dist/inference/index.js +97 -0
- package/dist/inference/inference-factory.d.ts +73 -0
- package/dist/inference/inference-factory.d.ts.map +1 -0
- package/dist/inference/inference-factory.js +175 -0
- package/dist/inference/ollama-client.d.ts +114 -0
- package/dist/inference/ollama-client.d.ts.map +1 -0
- package/dist/inference/ollama-client.js +386 -0
- package/dist/legal-checks/annex-iv-report.d.ts +131 -0
- package/dist/legal-checks/annex-iv-report.d.ts.map +1 -0
- package/dist/legal-checks/annex-iv-report.js +62 -0
- package/dist/legal-checks/bias-metrics.d.ts +162 -0
- package/dist/legal-checks/bias-metrics.d.ts.map +1 -0
- package/dist/legal-checks/bias-metrics.js +408 -0
- package/dist/legal-checks/data-governance.d.ts +30 -0
- package/dist/legal-checks/data-governance.d.ts.map +1 -0
- package/dist/legal-checks/data-governance.js +99 -0
- package/dist/legal-checks/human-oversight-logging.d.ts +27 -0
- package/dist/legal-checks/human-oversight-logging.d.ts.map +1 -0
- package/dist/legal-checks/human-oversight-logging.js +106 -0
- package/dist/legal-checks/index.d.ts +13 -0
- package/dist/legal-checks/index.d.ts.map +1 -0
- package/dist/legal-checks/index.js +6 -0
- package/dist/legal-checks/risk-classifier.d.ts +35 -0
- package/dist/legal-checks/risk-classifier.d.ts.map +1 -0
- package/dist/legal-checks/risk-classifier.js +234 -0
- package/dist/legal-checks/robustness-transparency.d.ts +45 -0
- package/dist/legal-checks/robustness-transparency.d.ts.map +1 -0
- package/dist/legal-checks/robustness-transparency.js +111 -0
- package/dist/metrics/crows-pairs-bias.d.ts +41 -0
- package/dist/metrics/crows-pairs-bias.d.ts.map +1 -0
- package/dist/metrics/crows-pairs-bias.js +172 -0
- package/dist/metrics/index.d.ts +6 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +5 -0
- package/dist/metrics/stereotype-bias.d.ts +89 -0
- package/dist/metrics/stereotype-bias.d.ts.map +1 -0
- package/dist/metrics/stereotype-bias.js +157 -0
- package/dist/risk-engine.d.ts +23 -0
- package/dist/risk-engine.d.ts.map +1 -0
- package/dist/risk-engine.js +451 -0
- package/dist/types.d.ts +131 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/package.json +28 -0
- package/src/fairness-metrics.ts +498 -0
- package/src/index.ts +150 -0
- package/src/inference/browser-inference.ts +258 -0
- package/src/inference/capability-detection.ts +714 -0
- package/src/inference/index.ts +156 -0
- package/src/inference/inference-factory.ts +222 -0
- package/src/inference/ollama-client.ts +514 -0
- package/src/inference/transformers.d.ts +62 -0
- package/src/legal-checks/annex-iv-report.ts +157 -0
- package/src/legal-checks/bias-metrics.ts +590 -0
- package/src/legal-checks/data-governance.ts +148 -0
- package/src/legal-checks/human-oversight-logging.ts +135 -0
- package/src/legal-checks/index.ts +55 -0
- package/src/legal-checks/risk-classifier.ts +285 -0
- package/src/legal-checks/robustness-transparency.ts +162 -0
- package/src/metrics/crows-pairs-bias.ts +245 -0
- package/src/metrics/index.ts +22 -0
- package/src/metrics/stereotype-bias.ts +267 -0
- package/src/risk-engine.ts +525 -0
- package/src/types.ts +154 -0
- package/tests/annex-iv-report.test.ts +323 -0
- package/tests/crows-pairs-bias.test.ts +342 -0
- package/tests/fairness-metrics.test.ts +187 -0
- package/tests/integration/bias-calculation.integration.test.ts +688 -0
- package/tests/legal-checks.test.ts +53 -0
- package/tests/ollama-client.test.ts +427 -0
- package/tests/risk-engine.test.ts +149 -0
- package/tsconfig.json +11 -0
- package/vitest.config.ts +17 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Annex IV – Technical Documentation Report Builder (structured JSON)
|
|
3
|
+
*
|
|
4
|
+
* Provides a strict section structure (1–7) matching the requested outline:
|
|
5
|
+
* 1. Allgemeine Beschreibung
|
|
6
|
+
* 2. Design-Spezifikationen
|
|
7
|
+
* 3. Datenmanagement
|
|
8
|
+
* 4. Risikomanagement & Mitigation
|
|
9
|
+
* 5. Performance & Fairness-Metriken
|
|
10
|
+
* 6. Human Oversight
|
|
11
|
+
* 7. Technische Dokumentation
|
|
12
|
+
*
|
|
13
|
+
* IMPORTANT: This is a documentation scaffold to support a user's own conformity assessment.
|
|
14
|
+
* It is not legal advice and not a legal determination of compliance.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { BiasCalculationMethod, BiasTestResult, RiskLevel } from "../types";
|
|
18
|
+
import type { Citation } from "./bias-metrics";
|
|
19
|
+
import type { DataGovernanceChecklistResult } from "./data-governance";
|
|
20
|
+
import type { HumanOversightRecommendation } from "./human-oversight-logging";
|
|
21
|
+
import type { AnnexIIIRiskResult } from "./risk-classifier";
|
|
22
|
+
|
|
23
|
+
export interface AnnexIVStructuredReportV1 {
|
|
24
|
+
meta: {
|
|
25
|
+
reportVersion: "annex-iv.v1";
|
|
26
|
+
generatedAt: string;
|
|
27
|
+
tool: { name: string; version?: string };
|
|
28
|
+
disclaimer: string;
|
|
29
|
+
legalSources: Citation[];
|
|
30
|
+
reproducibility: {
|
|
31
|
+
seed?: number;
|
|
32
|
+
notes: string[];
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
section1_generalDescription: {
|
|
36
|
+
provider: { name: string; address?: string; contact?: string };
|
|
37
|
+
system: {
|
|
38
|
+
name: string;
|
|
39
|
+
intendedPurpose: string;
|
|
40
|
+
deploymentContext?: string;
|
|
41
|
+
userGroups?: string[];
|
|
42
|
+
riskLevel: RiskLevel;
|
|
43
|
+
annexIII: AnnexIIIRiskResult;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
section2_designSpecifications: {
|
|
47
|
+
architecture?: string;
|
|
48
|
+
modelType?: string;
|
|
49
|
+
interfaces?: { inputs?: string; outputs?: string };
|
|
50
|
+
assumptionsAndLimitations?: string[];
|
|
51
|
+
};
|
|
52
|
+
section3_dataManagement: {
|
|
53
|
+
datasets?: Array<{
|
|
54
|
+
name: string;
|
|
55
|
+
description?: string;
|
|
56
|
+
timeframe?: string;
|
|
57
|
+
license?: string;
|
|
58
|
+
preprocessing?: string;
|
|
59
|
+
version?: string;
|
|
60
|
+
knownLimitations?: string[];
|
|
61
|
+
}>;
|
|
62
|
+
dataGovernanceChecklist?: DataGovernanceChecklistResult;
|
|
63
|
+
};
|
|
64
|
+
section4_riskManagementAndMitigation: {
|
|
65
|
+
processDescription?: string;
|
|
66
|
+
identifiedRisks?: string[];
|
|
67
|
+
mitigations?: string[];
|
|
68
|
+
monitoringPlan?: string[];
|
|
69
|
+
};
|
|
70
|
+
section5_performanceAndFairness: {
|
|
71
|
+
performanceMetrics?: Array<{ name: string; value: number | string; notes?: string }>;
|
|
72
|
+
biasAndFairness?: Array<BiasTestResult | unknown>;
|
|
73
|
+
biasMethodology?: {
|
|
74
|
+
method: BiasCalculationMethod;
|
|
75
|
+
engine: "browser" | "ollama";
|
|
76
|
+
dataset: string;
|
|
77
|
+
citation: string;
|
|
78
|
+
description: string;
|
|
79
|
+
};
|
|
80
|
+
thresholdsAndInterpretationNotes: string[];
|
|
81
|
+
};
|
|
82
|
+
section6_humanOversight: {
|
|
83
|
+
humanOversight?: HumanOversightRecommendation;
|
|
84
|
+
loggingNotes?: string[];
|
|
85
|
+
};
|
|
86
|
+
section7_technicalDocumentation: {
|
|
87
|
+
artifacts?: Array<{ name: string; description?: string; location?: string }>;
|
|
88
|
+
changeLog?: Array<{ date: string; change: string }>;
|
|
89
|
+
references: Citation[];
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function buildAnnexIVReportV1(input: {
|
|
94
|
+
provider: AnnexIVStructuredReportV1["section1_generalDescription"]["provider"];
|
|
95
|
+
system: Omit<AnnexIVStructuredReportV1["section1_generalDescription"]["system"], "riskLevel"> & {
|
|
96
|
+
riskLevel: RiskLevel;
|
|
97
|
+
};
|
|
98
|
+
legalSources: Citation[];
|
|
99
|
+
reproducibility?: AnnexIVStructuredReportV1["meta"]["reproducibility"];
|
|
100
|
+
design?: AnnexIVStructuredReportV1["section2_designSpecifications"];
|
|
101
|
+
dataManagement?: AnnexIVStructuredReportV1["section3_dataManagement"];
|
|
102
|
+
riskManagement?: AnnexIVStructuredReportV1["section4_riskManagementAndMitigation"];
|
|
103
|
+
performanceAndFairness?: AnnexIVStructuredReportV1["section5_performanceAndFairness"];
|
|
104
|
+
humanOversight?: AnnexIVStructuredReportV1["section6_humanOversight"];
|
|
105
|
+
technicalDocumentation?: Partial<AnnexIVStructuredReportV1["section7_technicalDocumentation"]>;
|
|
106
|
+
biasMethodology?: AnnexIVStructuredReportV1["section5_performanceAndFairness"]["biasMethodology"];
|
|
107
|
+
tool?: { name: string; version?: string };
|
|
108
|
+
disclaimer?: string;
|
|
109
|
+
}): AnnexIVStructuredReportV1 {
|
|
110
|
+
const generatedAt = new Date().toISOString();
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
meta: {
|
|
114
|
+
reportVersion: "annex-iv.v1",
|
|
115
|
+
generatedAt,
|
|
116
|
+
tool: input.tool ?? { name: "AImpact" },
|
|
117
|
+
disclaimer:
|
|
118
|
+
input.disclaimer ??
|
|
119
|
+
"This tool provides technical assistance and guidance. The results do not replace a legally binding conformity assessment by a notified body or legal advice.",
|
|
120
|
+
legalSources: input.legalSources,
|
|
121
|
+
reproducibility: input.reproducibility ?? {
|
|
122
|
+
notes: ["Alle stichprobenbasierten Tests sollten Seed/Versionen dokumentieren."],
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
section1_generalDescription: {
|
|
126
|
+
provider: input.provider,
|
|
127
|
+
system: {
|
|
128
|
+
...input.system,
|
|
129
|
+
riskLevel: input.system.riskLevel,
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
section2_designSpecifications: input.design ?? {
|
|
133
|
+
assumptionsAndLimitations: [
|
|
134
|
+
"Dieses Report-Gerüst ersetzt keine vollständige technische Dokumentation; ergänzen Sie modell- und domänenspezifische Details.",
|
|
135
|
+
],
|
|
136
|
+
},
|
|
137
|
+
section3_dataManagement: input.dataManagement ?? {},
|
|
138
|
+
section4_riskManagementAndMitigation: input.riskManagement ?? {},
|
|
139
|
+
section5_performanceAndFairness: {
|
|
140
|
+
...(input.performanceAndFairness ?? {
|
|
141
|
+
thresholdsAndInterpretationNotes: [
|
|
142
|
+
"Thresholds in diesem Tool sind als technische Screening-Indikatoren markiert; sie sind keine Rechts- oder Compliance-Schwellenwerte.",
|
|
143
|
+
"Disparate Impact < 0.8 gilt als Indiz für potenzielle Diskriminierung (weitere Prüfung empfohlen).",
|
|
144
|
+
],
|
|
145
|
+
}),
|
|
146
|
+
biasMethodology: input.biasMethodology,
|
|
147
|
+
},
|
|
148
|
+
section6_humanOversight: input.humanOversight ?? {},
|
|
149
|
+
section7_technicalDocumentation: {
|
|
150
|
+
artifacts: input.technicalDocumentation?.artifacts ?? [],
|
|
151
|
+
changeLog: input.technicalDocumentation?.changeLog ?? [
|
|
152
|
+
{ date: generatedAt.slice(0, 10), change: "Report generated" },
|
|
153
|
+
],
|
|
154
|
+
references: input.technicalDocumentation?.references ?? input.legalSources,
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
}
|