Initial commit: breakpilot-compliance - Compliance SDK Platform

Services: Admin-Compliance, Backend-Compliance,
AI-Compliance-SDK, Consent-SDK, Developer-Portal,
PCA-Platform, DSMS

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Benjamin Boenisch
2026-02-11 23:47:28 +01:00
commit 4435e7ea0a
734 changed files with 251369 additions and 0 deletions

View File

@@ -0,0 +1,359 @@
/**
* Shared Types & Constants for AI Modules
*
* Diese Datei enthält gemeinsame Typen und Konstanten für die drei AI-Module:
* - OCR-Labeling: Ground Truth für Handschrift-OCR
* - RAG Pipeline: Dokument-Indexierung (NiBiS, EH, Schulordnungen)
* - Daten & RAG: Vektor-Suche & Collection-Mapping
*
* Alle Module kommunizieren mit dem klausur-service auf Port 8086.
*/
// =============================================================================
// Qdrant Collection IDs
// =============================================================================
/**
* Gemeinsame Qdrant Collection-IDs für das RAG-System
*/
export const QDRANT_COLLECTIONS = {
/** Offizielle NiBiS Erwartungshorizonte */
NIBIS_EH: 'bp_nibis_eh',
/** Benutzerdefinierte/eigene Erwartungshorizonte */
CUSTOM_EH: 'bp_eh',
/** Schulordnungen aller Bundesländer */
SCHULORDNUNGEN: 'bp_schulordnungen',
/** Rechtskorpus (DSGVO, AI Act, BSI Standards, etc.) */
LEGAL_CORPUS: 'bp_legal_corpus',
} as const
export type QdrantCollectionId = typeof QDRANT_COLLECTIONS[keyof typeof QDRANT_COLLECTIONS]
// =============================================================================
// Shared Status Types
// =============================================================================
/**
* Gemeinsamer Verarbeitungsstatus für alle Module
*/
export type ProcessingStatus = 'pending' | 'processing' | 'completed' | 'failed'
/**
* Status für Indexierungs-Jobs
*/
export type IndexingJobStatus =
| 'queued'
| 'preparing'
| 'processing'
| 'validating'
| 'completed'
| 'failed'
| 'paused'
/**
* Status für OCR-Labeling Items
*/
export type OCRLabelingStatus = 'pending' | 'confirmed' | 'corrected' | 'skipped'
// =============================================================================
// Cross-Module Navigation
// =============================================================================
/**
* Link-Definition für AI-Modul-Navigation
*/
export interface AIModuleLink {
/** Eindeutige ID des Moduls */
id: string
/** Anzeigename */
name: string
/** Navigation href */
href: string
/** Kurzbeschreibung */
description: string
/** Optional: Icon-Name oder Emoji */
icon?: string
/** Optional: Farbe für Hervorhebung */
color?: string
}
/**
* KI-Daten-Pipeline Module
* Diese Module bilden eine zusammenhaengende Pipeline mit Datenfluss.
* Datenfluss: Magic Help ⟷ OCR-Labeling → RAG Pipeline → Daten & RAG
*/
export const AI_PIPELINE_MODULES: AIModuleLink[] = [
{
id: 'magic-help',
name: 'Magic Help',
href: '/ai/magic-help',
description: 'TrOCR Testing & LoRA Fine-Tuning',
icon: '✨',
},
{
id: 'ocr-labeling',
name: 'OCR-Labeling',
href: '/ai/ocr-labeling',
description: 'Handschrift-Training & Ground Truth Erfassung',
icon: '🏷️',
},
{
id: 'rag-pipeline',
name: 'RAG Pipeline',
href: '/ai/rag-pipeline',
description: 'Dokument-Indexierung & Vektor-Embedding',
icon: '🔄',
},
{
id: 'rag',
name: 'Daten & RAG',
href: '/ai/rag',
description: 'Vektor-Suche & Collection-Management',
icon: '🔍',
},
]
/**
* KI-Werkzeuge Module
* Standalone-Tools fuer Entwicklung, QA und Evaluation.
* Kein direkter Datenfluss zur Pipeline.
*/
export const AI_TOOLS_MODULES: AIModuleLink[] = [
{
id: 'llm-compare',
name: 'LLM Vergleich',
href: '/ai/llm-compare',
description: 'KI-Provider Vergleich & Evaluation',
icon: '⚖️',
},
{
id: 'test-quality',
name: 'Test Quality (BQAS)',
href: '/ai/test-quality',
description: 'Golden Suite & Synthetic Tests',
icon: '🧪',
},
]
/**
* Alle AI-Module für Cross-Navigation (Legacy - fuer Abwaertskompatibilitaet)
* @deprecated Nutze AI_PIPELINE_MODULES oder AI_TOOLS_MODULES
*/
export const AI_MODULES: AIModuleLink[] = [
...AI_PIPELINE_MODULES,
...AI_TOOLS_MODULES,
]
/**
* Verwandte Module für jedes AI-Modul
*/
export const AI_MODULE_RELATIONS: Record<string, AIModuleLink[]> = {
// KI-Daten-Pipeline Relations
'magic-help': [
{
id: 'ocr-labeling',
name: 'OCR-Labeling',
href: '/ai/ocr-labeling',
description: 'Ground Truth erstellen',
},
{
id: 'rag-pipeline',
name: 'RAG Pipeline',
href: '/ai/rag-pipeline',
description: 'Erkannte Texte indexieren',
},
],
'ocr-labeling': [
{
id: 'magic-help',
name: 'Magic Help',
href: '/ai/magic-help',
description: 'TrOCR testen & fine-tunen',
},
{
id: 'rag-pipeline',
name: 'RAG Pipeline',
href: '/ai/rag-pipeline',
description: 'Trainierte Daten indexieren',
},
{
id: 'klausur-korrektur',
name: 'Klausur-Korrektur',
href: '/ai/klausur-korrektur',
description: 'OCR in Aktion',
},
],
'rag-pipeline': [
{
id: 'ocr-labeling',
name: 'OCR-Labeling',
href: '/ai/ocr-labeling',
description: 'Ground Truth erstellen',
},
{
id: 'rag',
name: 'Daten & RAG',
href: '/ai/rag',
description: 'Indexierte Daten durchsuchen',
},
],
rag: [
{
id: 'rag-pipeline',
name: 'RAG Pipeline',
href: '/ai/rag-pipeline',
description: 'Neue Dokumente indexieren',
},
{
id: 'klausur-korrektur',
name: 'Klausur-Korrektur',
href: '/ai/klausur-korrektur',
description: 'RAG-Suche nutzen',
},
],
// KI-Werkzeuge Relations (Standalone-Tools)
'llm-compare': [
{
id: 'test-quality',
name: 'Test Quality (BQAS)',
href: '/ai/test-quality',
description: 'Golden Suite & Synthetic Tests',
},
{
id: 'agents',
name: 'Agent Management',
href: '/ai/agents',
description: 'Multi-Agent System',
},
],
'test-quality': [
{
id: 'llm-compare',
name: 'LLM Vergleich',
href: '/ai/llm-compare',
description: 'KI-Provider vergleichen',
},
{
id: 'klausur-korrektur',
name: 'Klausur-Korrektur',
href: '/ai/klausur-korrektur',
description: 'BQAS in Aktion',
},
],
}
// =============================================================================
// Data Flow Types
// =============================================================================
/**
* Datenfluss-Verbindung zwischen Modulen
*/
export interface DataFlowConnection {
from: string
to: string
label: string
description: string
}
/**
* Definiert den Datenfluss zwischen den AI-Modulen
*
* Magic Help ⟷ OCR-Labeling: Bidirektionaler Austausch (LoRA + Ground Truth)
* OCR-Labeling → RAG Pipeline: Ground Truth für Training
* RAG Pipeline → Daten & RAG: Embeddings für Vektor-Suche
* Daten & RAG → Klausur-Korrektur: RAG-Suche für Bewertung
*/
export const DATA_FLOW_CONNECTIONS: DataFlowConnection[] = [
{
from: 'magic-help',
to: 'ocr-labeling',
label: 'LoRA Model',
description: 'Verbessertes TrOCR-Modell für OCR-Labeling',
},
{
from: 'ocr-labeling',
to: 'magic-help',
label: 'TrOCR Export',
description: 'Ground Truth Daten im TrOCR-Format für Fine-Tuning',
},
{
from: 'ocr-labeling',
to: 'rag-pipeline',
label: 'Ground Truth',
description: 'Gelabelte Handschriftproben für OCR-Training',
},
{
from: 'rag-pipeline',
to: 'rag',
label: 'Embeddings',
description: 'Vektor-Embeddings indexierter Dokumente',
},
{
from: 'rag',
to: 'klausur-korrektur',
label: 'RAG-Suche',
description: 'Semantische Suche für Erwartungshorizonte',
},
]
// =============================================================================
// API Configuration
// =============================================================================
/**
* Backend-Endpunkte für die AI-Module
*/
export const AI_API_ENDPOINTS = {
/** OCR-Labeling Endpoints */
OCR_LABELING: {
SESSIONS: '/api/v1/ocr-label/sessions',
QUEUE: '/api/v1/ocr-label/queue',
CONFIRM: '/api/v1/ocr-label/confirm',
CORRECT: '/api/v1/ocr-label/correct',
SKIP: '/api/v1/ocr-label/skip',
STATS: '/api/v1/ocr-label/stats',
EXPORT: '/api/v1/ocr-label/export',
},
/** RAG Pipeline Endpoints */
RAG_PIPELINE: {
JOBS: '/api/ai/rag-pipeline?action=jobs',
DATASET_STATS: '/api/ai/rag-pipeline?action=dataset-stats',
CREATE_JOB: '/api/ai/rag-pipeline?action=create-job',
},
/** Legal Corpus / RAG Endpoints */
LEGAL_CORPUS: {
STATUS: '/api/legal-corpus/status',
SEARCH: '/api/legal-corpus/search',
INGEST: '/api/legal-corpus/ingest',
},
} as const
// =============================================================================
// Architecture Documentation
// =============================================================================
/**
* Architektur-Information für Dokumentationszwecke
*/
export const AI_ARCHITECTURE = {
services: [
{ name: 'klausur-service', port: 8086, language: 'Python', description: 'Haupt-Backend für alle AI-Module' },
{ name: 'embedding-service', port: 8087, language: 'Python', description: 'Vektor-Embedding Generation' },
],
databases: [
{ name: 'Qdrant', type: 'Vector', description: 'Vektor-Datenbank für RAG' },
{ name: 'PostgreSQL', type: 'Relational', description: 'Metadaten und Session-Storage' },
{ name: 'MinIO', type: 'Object', description: 'Bild- und Dokumenten-Storage' },
],
embeddingModel: {
name: 'text-embedding-3-small',
dimensions: 1536,
provider: 'OpenAI',
},
chunkConfig: {
size: 1000,
overlap: 200,
metric: 'COSINE',
},
}

View File

@@ -0,0 +1,396 @@
/**
* Shared Types & Constants for Infrastructure/DevOps Modules
*
* Diese Datei enthaelt gemeinsame Typen und Konstanten fuer die DevOps-Pipeline:
* - CI/CD: Woodpecker Pipelines & Deployments
* - Tests: Test Dashboard & Backlog
* - SBOM: Software Bill of Materials & Lizenz-Checks
* - Security: DevSecOps Scans & Vulnerabilities
*
* Pipeline-Flow: CI/CD → Tests → SBOM → Security
*/
// =============================================================================
// DevOps Module IDs
// =============================================================================
/**
* Eindeutige IDs fuer DevOps-Module in der Sidebar
*/
export type DevOpsToolId = 'ci-cd' | 'tests' | 'sbom' | 'security' | 'middleware' | 'gpu'
/**
* Module die zur DevOps-Pipeline gehoeren
*/
export const DEVOPS_PIPELINE_IDS: DevOpsToolId[] = ['ci-cd', 'tests', 'sbom', 'security']
// =============================================================================
// Shared Status Types
// =============================================================================
/**
* Pipeline-Status fuer CI/CD
*/
export type PipelineStatus = 'pending' | 'running' | 'success' | 'failure' | 'error' | 'blocked' | 'skipped'
/**
* Quelle fuer Backlog-Eintraege
*/
export type BacklogSource = 'manual' | 'ci_cd' | 'security' | 'sbom'
/**
* Kategorien fuer extrahierte Fehler
*/
export type ErrorCategory = 'test_failure' | 'build_error' | 'security_warning' | 'license_violation' | 'dependency_issue'
/**
* LLM-Routing-Optionen
*/
export type LLMRoutingOption = 'local_only' | 'claude_preferred' | 'smart_routing'
/**
* Sensitivity-Level fuer Privacy Classifier
*/
export type SensitivityLevel = 'sensitive' | 'non_sensitive' | 'unknown'
// =============================================================================
// Module Navigation
// =============================================================================
/**
* Link-Definition fuer DevOps-Modul-Navigation
*/
export interface DevOpsModule {
/** Eindeutige ID des Moduls */
id: DevOpsToolId
/** Anzeigename */
name: string
/** Navigation href */
href: string
/** Kurzbeschreibung */
description: string
/** Icon (Emoji) */
icon: string
/** Optional: Subgroup fuer Gruppierung */
subgroup?: 'pipeline' | 'infrastructure'
}
/**
* DevOps-Pipeline Module
* Diese Module bilden eine zusammenhaengende Pipeline mit Datenfluss.
* Datenfluss: CI/CD → Tests → SBOM → Security
*/
export const DEVOPS_PIPELINE_MODULES: DevOpsModule[] = [
{
id: 'ci-cd',
name: 'CI/CD Pipelines',
href: '/infrastructure/ci-cd',
description: 'Gitea Actions & Deployments',
icon: '🔄',
subgroup: 'pipeline',
},
{
id: 'tests',
name: 'Test Dashboard',
href: '/infrastructure/tests',
description: '280+ Tests & Coverage',
icon: '✅',
subgroup: 'pipeline',
},
{
id: 'sbom',
name: 'SBOM',
href: '/infrastructure/sbom',
description: 'Dependencies & Licenses',
icon: '📦',
subgroup: 'pipeline',
},
{
id: 'security',
name: 'Security',
href: '/infrastructure/security',
description: 'DevSecOps & Scans',
icon: '🛡️',
subgroup: 'pipeline',
},
]
/**
* Andere Infrastructure-Module (nicht Teil der Pipeline)
*/
export const OTHER_INFRASTRUCTURE_MODULES: DevOpsModule[] = [
{
id: 'middleware',
name: 'Middleware',
href: '/infrastructure/middleware',
description: 'API Gateway & Rate Limiting',
icon: '🔗',
subgroup: 'infrastructure',
},
{
id: 'gpu',
name: 'GPU',
href: '/infrastructure/gpu',
description: 'GPU Monitoring & Management',
icon: '🖥️',
subgroup: 'infrastructure',
},
]
/**
* Alle Infrastructure-Module
*/
export const ALL_INFRASTRUCTURE_MODULES: DevOpsModule[] = [
...DEVOPS_PIPELINE_MODULES,
...OTHER_INFRASTRUCTURE_MODULES,
]
// =============================================================================
// Data Flow Types
// =============================================================================
/**
* Datenfluss-Verbindung zwischen Modulen
*/
export interface DataFlowConnection {
from: DevOpsToolId
to: DevOpsToolId
label: string
description: string
}
/**
* Definiert den Datenfluss zwischen den DevOps-Modulen
*
* CI/CD → Tests: Pipeline-Ergebnisse fuellen Test Dashboard
* Tests → Backlog: Fehlgeschlagene Tests → Backlog (automatisch bei CI/CD Failure)
* CI/CD → SBOM: Nach erfolgreichem Build SBOM generieren
* SBOM → Security: SBOM-Daten fuer Vulnerability-Checks
*/
export const DEVOPS_DATA_FLOW_CONNECTIONS: DataFlowConnection[] = [
{
from: 'ci-cd',
to: 'tests',
label: 'Test Results',
description: 'Pipeline-Ergebnisse fuellen Test Dashboard',
},
{
from: 'ci-cd',
to: 'sbom',
label: 'Build Artifacts',
description: 'Nach erfolgreichem Build SBOM generieren (Syft)',
},
{
from: 'sbom',
to: 'security',
label: 'Dependencies',
description: 'SBOM-Daten fuer Vulnerability-Scanning (Grype)',
},
]
// =============================================================================
// Log Extraction Types
// =============================================================================
/**
* Extrahierter Fehler aus Pipeline-Logs
*/
export interface ExtractedError {
/** Pipeline-Step in dem der Fehler auftrat */
step: string
/** Zeilen-Nummer im Log */
line: number
/** Fehlermeldung */
message: string
/** Kategorie des Fehlers */
category: ErrorCategory
/** Von LLM generierter Korrekturvorschlag */
suggested_fix?: string
/** Datei in der der Fehler auftrat (falls bekannt) */
file_path?: string
/** Service-Name (falls bekannt) */
service?: string
}
/**
* Response von Log-Extraktion Endpoint
*/
export interface LogExtractionResponse {
/** Liste der extrahierten Fehler */
errors: ExtractedError[]
/** Pipeline-Nummer */
pipeline_number: number
/** Zeitpunkt der Extraktion */
extracted_at: string
/** Anzahl geparster Log-Zeilen */
lines_parsed: number
}
// =============================================================================
// Webhook Types
// =============================================================================
/**
* Woodpecker Webhook Event Types
*/
export type WoodpeckerEventType = 'pipeline_success' | 'pipeline_failure' | 'pipeline_started'
/**
* Woodpecker Webhook Payload
*/
export interface WoodpeckerWebhookPayload {
event: WoodpeckerEventType
repo_id: number
pipeline_number: number
branch?: string
commit?: string
author?: string
message?: string
}
// =============================================================================
// LLM Integration Types
// =============================================================================
/**
* LLM-Analyse Request
*/
export interface LLMAnalysisRequest {
/** Text/Code der analysiert werden soll */
content: string
/** Kontext (z.B. Fehlermeldung, Test-Name) */
context?: string
/** Routing-Praeferenz */
routing: LLMRoutingOption
}
/**
* LLM-Analyse Response
*/
export interface LLMAnalysisResponse {
/** Generierter Fix-Vorschlag */
suggested_fix: string
/** Erklaerung des Problems */
explanation: string
/** Welches LLM wurde verwendet */
model_used: 'claude-sonnet' | 'qwen2.5-32b' | 'other'
/** Grund fuer Routing-Entscheidung */
routing_reason?: string
/** Confidence Score (0-1) */
confidence?: number
}
/**
* Privacy Classifier Result
*/
export interface PrivacyClassifierResult {
/** Sensitivity-Level */
level: SensitivityLevel
/** Gefundene sensitive Patterns */
patterns_found: string[]
/** Empfohlenes Routing */
recommended_routing: 'local' | 'external'
}
// =============================================================================
// Sidebar Props
// =============================================================================
/**
* Props fuer DevOpsPipelineSidebar
*/
export interface DevOpsPipelineSidebarProps {
/** Aktuell aktives Tool */
currentTool: DevOpsToolId
/** Kompakte Ansicht (collapsed by default) */
compact?: boolean
/** Zusaetzliche CSS-Klassen */
className?: string
}
/**
* Props fuer responsive Sidebar-Variante
*/
export interface DevOpsPipelineSidebarResponsiveProps extends DevOpsPipelineSidebarProps {
/** FAB-Position auf Mobile */
fabPosition?: 'bottom-right' | 'bottom-left'
}
// =============================================================================
// Live Status Types (fuer Badges)
// =============================================================================
/**
* Live-Status fuer Sidebar-Badges
*/
export interface PipelineLiveStatus {
/** Aktuelle Pipeline laeuft */
isRunning: boolean
/** Letzte Pipeline erfolgreich */
lastSuccess: boolean
/** Anzahl offener Backlog-Items */
backlogCount: number
/** Anzahl Security-Findings */
securityFindingsCount: number
/** Letzte Aktualisierung */
lastUpdated: string
}
// =============================================================================
// API Configuration
// =============================================================================
/**
* Backend-Endpunkte fuer die Infrastructure-Module
*/
export const INFRASTRUCTURE_API_ENDPOINTS = {
/** CI/CD Endpoints */
CI_CD: {
PIPELINES: '/api/admin/infrastructure/woodpecker',
TRIGGER: '/api/admin/infrastructure/woodpecker/trigger',
LOGS: '/api/admin/infrastructure/woodpecker/logs',
},
/** Log Extraction Endpoints */
LOG_EXTRACT: {
EXTRACT: '/api/infrastructure/log-extract/extract',
},
/** Webhook Endpoints */
WEBHOOKS: {
WOODPECKER: '/api/webhooks/woodpecker',
},
/** LLM Endpoints */
LLM: {
ANALYZE: '/api/ai/analyze',
LOCAL: '/api/ai/local-llm',
CLASSIFY: '/api/ai/privacy-classify',
},
} as const
// =============================================================================
// Architecture Documentation
// =============================================================================
/**
* Architektur-Information fuer Dokumentationszwecke
*/
export const DEVOPS_ARCHITECTURE = {
services: [
{ name: 'Woodpecker CI', port: 8000, description: 'CI/CD Pipeline Server' },
{ name: 'Gitea', port: 3003, description: 'Git Repository Server' },
{ name: 'Syft', type: 'CLI', description: 'SBOM Generator' },
{ name: 'Grype', type: 'CLI', description: 'Vulnerability Scanner' },
{ name: 'Semgrep', type: 'CLI', description: 'Static Analysis' },
{ name: 'Gitleaks', type: 'CLI', description: 'Secret Detection' },
],
workflow: {
description: 'CI/CD Pipeline Flow',
steps: [
{ name: 'Code Push', icon: '📝' },
{ name: 'Build', icon: '🏗️' },
{ name: 'Test', icon: '✅' },
{ name: 'SBOM', icon: '📦' },
{ name: 'Security', icon: '🛡️' },
{ name: 'Deploy', icon: '🚀' },
],
},
}