Files
breakpilot-compliance/admin-compliance/app/sdk/compliance-optimizer/new/page.tsx
Benjamin Admin 1ac716261c
Some checks failed
Build + Deploy / build-admin-compliance (push) Successful in 1m45s
Build + Deploy / build-backend-compliance (push) Successful in 4m42s
Build + Deploy / build-ai-sdk (push) Successful in 46s
Build + Deploy / build-developer-portal (push) Successful in 1m6s
Build + Deploy / build-tts (push) Successful in 1m14s
Build + Deploy / build-document-crawler (push) Successful in 31s
Build + Deploy / build-dsms-gateway (push) Successful in 24s
CI / branch-name (push) Has been skipped
CI / guardrail-integrity (push) Has been skipped
CI / loc-budget (push) Failing after 15s
CI / secret-scan (push) Has been skipped
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / nodejs-build (push) Successful in 2m27s
CI / dep-audit (push) Has been skipped
CI / sbom-scan (push) Has been skipped
CI / test-go (push) Failing after 37s
CI / test-python-backend (push) Successful in 42s
CI / test-python-document-crawler (push) Successful in 25s
CI / test-python-dsms-gateway (push) Successful in 23s
CI / validate-canonical-controls (push) Successful in 18s
Build + Deploy / trigger-orca (push) Successful in 4m35s
feat: Compliance Maximizer — Regulatory Optimization Engine
Neues Modul das den regulatorischen Spielraum fuer KI-Use-Cases
deterministisch berechnet und optimale Konfigurationen vorschlaegt.

Kernfeatures:
- 13-Dimensionen Constraint-Space (DSGVO + AI Act)
- 3-Zonen-Analyse: Verboten / Eingeschraenkt / Erlaubt
- Deterministische Optimizer-Engine (kein LLM im Kern)
- 28 Constraint-Regeln aus DSGVO, AI Act, EDPB Guidelines
- 28 Tests (Golden Suite + Meta-Tests)
- REST API: /sdk/v1/maximizer/* (9 Endpoints)
- Frontend: 3-Zonen-Visualisierung, Dimension-Form, Score-Gauges

[migration-approved]

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-23 09:10:20 +02:00

164 lines
7.7 KiB
TypeScript

'use client'
import React, { useState } from 'react'
import { useRouter } from 'next/navigation'
import { ZoneBadge } from '@/components/sdk/compliance-optimizer/ZoneBadge'
interface DimensionField {
key: string
label: string
options: { value: string; label: string }[]
type?: 'select' | 'toggle'
}
const DIMENSIONS: DimensionField[] = [
{ key: 'automation_level', label: 'Automatisierungsgrad', options: [
{ value: 'none', label: 'Keine' }, { value: 'assistive', label: 'Assistierend' },
{ value: 'partial', label: 'Teilautomatisiert' }, { value: 'full', label: 'Vollautomatisiert' },
]},
{ key: 'decision_binding', label: 'Entscheidungsbindung', options: [
{ value: 'non_binding', label: 'Unverbindlich' }, { value: 'human_review_required', label: 'Mensch entscheidet' },
{ value: 'fully_binding', label: 'Vollstaendig bindend' },
]},
{ key: 'decision_impact', label: 'Entscheidungswirkung', options: [
{ value: 'low', label: 'Niedrig' }, { value: 'medium', label: 'Mittel' }, { value: 'high', label: 'Hoch' },
]},
{ key: 'domain', label: 'Branche', options: [
{ value: 'hr', label: 'HR / Personal' }, { value: 'finance', label: 'Finanzen' },
{ value: 'education', label: 'Bildung' }, { value: 'health', label: 'Gesundheit' },
{ value: 'marketing', label: 'Marketing' }, { value: 'general', label: 'Allgemein' },
]},
{ key: 'data_type', label: 'Datensensitivitaet', options: [
{ value: 'non_personal', label: 'Keine personenbezogenen' }, { value: 'personal', label: 'Personenbezogen' },
{ value: 'sensitive', label: 'Besondere Kategorien (Art. 9)' }, { value: 'biometric', label: 'Biometrisch' },
]},
{ key: 'human_in_loop', label: 'Menschliche Kontrolle', options: [
{ value: 'required', label: 'Erforderlich' }, { value: 'optional', label: 'Optional' }, { value: 'none', label: 'Keine' },
]},
{ key: 'explainability', label: 'Erklaerbarkeit', options: [
{ value: 'high', label: 'Hoch' }, { value: 'basic', label: 'Basis' }, { value: 'none', label: 'Keine' },
]},
{ key: 'risk_classification', label: 'Risikoklasse (AI Act)', options: [
{ value: 'minimal', label: 'Minimal' }, { value: 'limited', label: 'Begrenzt' },
{ value: 'high', label: 'Hoch' }, { value: 'prohibited', label: 'Verboten' },
]},
{ key: 'legal_basis', label: 'Rechtsgrundlage (DSGVO)', options: [
{ value: 'consent', label: 'Einwilligung' }, { value: 'contract', label: 'Vertrag' },
{ value: 'legal_obligation', label: 'Rechtl. Verpflichtung' },
{ value: 'legitimate_interest', label: 'Berechtigtes Interesse' },
{ value: 'public_interest', label: 'Oeffentl. Interesse' },
]},
{ key: 'model_type', label: 'Modelltyp', options: [
{ value: 'rule_based', label: 'Regelbasiert' }, { value: 'statistical', label: 'Statistisch / ML' },
{ value: 'blackbox_llm', label: 'Blackbox / LLM' },
]},
{ key: 'deployment_scope', label: 'Einsatzbereich', options: [
{ value: 'internal', label: 'Intern' }, { value: 'external', label: 'Extern (Kunden)' },
{ value: 'public', label: 'Oeffentlich' },
]},
]
const TOGGLE_DIMENSIONS = [
{ key: 'transparency_required', label: 'Transparenzpflicht' },
{ key: 'logging_required', label: 'Protokollierungspflicht' },
]
export default function NewOptimizationPage() {
const router = useRouter()
const [title, setTitle] = useState('')
const [config, setConfig] = useState<Record<string, string>>({
automation_level: 'assistive', decision_binding: 'non_binding', decision_impact: 'low',
domain: 'general', data_type: 'non_personal', human_in_loop: 'required',
explainability: 'basic', risk_classification: 'minimal', legal_basis: 'contract',
transparency_required: 'false', logging_required: 'false',
model_type: 'rule_based', deployment_scope: 'internal',
})
const [preview, setPreview] = useState<Record<string, { zone: string }> | null>(null)
const [submitting, setSubmitting] = useState(false)
async function handlePreview() {
try {
const body = { ...config, transparency_required: config.transparency_required === 'true', logging_required: config.logging_required === 'true' }
const res = await fetch('/api/sdk/v1/maximizer/evaluate', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) })
if (res.ok) {
const data = await res.json()
setPreview(data.zone_map || {})
}
} catch { /* silent */ }
}
async function handleSubmit() {
setSubmitting(true)
try {
const body = {
config: { ...config, transparency_required: config.transparency_required === 'true', logging_required: config.logging_required === 'true' },
title: title || 'Optimierung ' + new Date().toLocaleDateString('de-DE'),
}
const res = await fetch('/api/sdk/v1/maximizer/optimize', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) })
if (res.ok) {
const data = await res.json()
router.push(`/sdk/compliance-optimizer/${data.id}`)
}
} finally {
setSubmitting(false)
}
}
return (
<div className="max-w-4xl mx-auto p-6">
<h1 className="text-2xl font-bold text-gray-900 mb-1">Neue Optimierung</h1>
<p className="text-sm text-gray-500 mb-6">Konfigurieren Sie Ihren KI-Use-Case und finden Sie den maximalen regulatorischen Spielraum.</p>
<div className="mb-4">
<label className="block text-sm font-medium text-gray-700 mb-1">Titel</label>
<input type="text" value={title} onChange={(e) => setTitle(e.target.value)} placeholder="z.B. HR Bewerber-Ranking"
className="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm" />
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4 mb-6">
{DIMENSIONS.map((dim) => (
<div key={dim.key}>
<label className="block text-sm font-medium text-gray-700 mb-1">
{dim.label}
{preview && preview[dim.key] && (
<span className="ml-2"><ZoneBadge zone={preview[dim.key].zone as 'FORBIDDEN' | 'RESTRICTED' | 'SAFE'} /></span>
)}
</label>
<select
value={config[dim.key]}
onChange={(e) => { setConfig({ ...config, [dim.key]: e.target.value }); setPreview(null) }}
className="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm bg-white"
>
{dim.options.map((o) => <option key={o.value} value={o.value}>{o.label}</option>)}
</select>
</div>
))}
{TOGGLE_DIMENSIONS.map((dim) => (
<div key={dim.key} className="flex items-center gap-3">
<input type="checkbox" checked={config[dim.key] === 'true'}
onChange={(e) => { setConfig({ ...config, [dim.key]: String(e.target.checked) }); setPreview(null) }}
className="h-4 w-4 rounded border-gray-300 text-blue-600" />
<label className="text-sm font-medium text-gray-700">
{dim.label}
{preview && preview[dim.key] && (
<span className="ml-2"><ZoneBadge zone={preview[dim.key].zone as 'FORBIDDEN' | 'RESTRICTED' | 'SAFE'} /></span>
)}
</label>
</div>
))}
</div>
<div className="flex gap-3">
<button onClick={handlePreview} className="border border-gray-300 text-gray-700 px-4 py-2 rounded-lg hover:bg-gray-50 text-sm">
Vorschau (3-Zonen-Check)
</button>
<button onClick={handleSubmit} disabled={submitting}
className="bg-blue-600 text-white px-6 py-2 rounded-lg hover:bg-blue-700 text-sm font-medium disabled:opacity-50">
{submitting ? 'Optimiere...' : 'Optimieren'}
</button>
</div>
</div>
)
}