feat(sdk): Multi-Tenancy, Versionierung, Change-Requests, Dokumentengenerierung (Phase 1-6)
All checks were successful
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-ai-compliance (push) Successful in 32s
CI / test-python-backend-compliance (push) Successful in 30s
CI / test-python-document-crawler (push) Successful in 21s
CI / test-python-dsms-gateway (push) Successful in 18s
All checks were successful
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-ai-compliance (push) Successful in 32s
CI / test-python-backend-compliance (push) Successful in 30s
CI / test-python-document-crawler (push) Successful in 21s
CI / test-python-dsms-gateway (push) Successful in 18s
6-Phasen-Implementation fuer cloud-faehiges, mandantenfaehiges Compliance SDK:
Phase 1: Multi-Tenancy Fix
- Shared tenant_utils.py Dependency (UUID-Validierung, kein "default" mehr)
- VVT tenant_id Column + tenant-scoped Queries
- DSFA/Vendor DEFAULT_TENANT_ID von "default" auf UUID migriert
- Migration 035
Phase 2: Stammdaten-Erweiterung
- Company Profile um JSONB-Felder erweitert (processing_systems, ai_systems, technical_contacts)
- Regulierungs-Flags (NIS2, AI Act, ISO 27001)
- GET /template-context Endpoint
- Migration 036
Phase 3: Dokument-Versionierung
- 5 Versions-Tabellen (DSFA, VVT, TOM, Loeschfristen, Obligations)
- Shared versioning_utils.py Helper
- /{id}/versions Endpoints auf allen 5 Dokumenttypen
- Migration 037
Phase 4: Change-Request System
- Zentrale CR-Inbox mit CRUD + Accept/Reject/Edit Workflow
- Regelbasierte CR-Engine (VVT DPIA → DSFA CR, Datenkategorien → Loeschfristen CR)
- Audit-Trail
- Migration 038
Phase 5: Dokumentengenerierung
- 5 Template-Generatoren (DSFA, VVT, TOM, Loeschfristen, Obligations)
- Preview + Apply Endpoints (erzeugt CRs, keine direkten Dokumente)
Phase 6: Frontend-Integration
- Change-Request Inbox Page mit Stats, Filtern, Modals
- VersionHistory Timeline-Komponente
- SDKSidebar CR-Badge (60s Polling)
- Company Profile: 2 neue Wizard-Steps + "Dokumente generieren" CTA
Docs: 5 neue MkDocs-Seiten, CLAUDE.md aktualisiert
Tests: 97 neue Tests (alle bestanden)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
141
backend-compliance/migrations/037_document_versions.sql
Normal file
141
backend-compliance/migrations/037_document_versions.sql
Normal file
@@ -0,0 +1,141 @@
|
||||
-- Migration 037: Document Versioning Tables
|
||||
-- Separate version tables for DSFA, VVT, TOM, Loeschfristen, Obligations
|
||||
-- Pattern: snapshot JSONB + status workflow + audit trail
|
||||
|
||||
BEGIN;
|
||||
|
||||
-- ============================================================================
|
||||
-- 1. Add current_version column to all 5 document tables
|
||||
-- ============================================================================
|
||||
|
||||
ALTER TABLE compliance_dsfas
|
||||
ADD COLUMN IF NOT EXISTS current_version INTEGER DEFAULT 0;
|
||||
|
||||
ALTER TABLE compliance_vvt_activities
|
||||
ADD COLUMN IF NOT EXISTS current_version INTEGER DEFAULT 0;
|
||||
|
||||
ALTER TABLE compliance_tom_measures
|
||||
ADD COLUMN IF NOT EXISTS current_version INTEGER DEFAULT 0;
|
||||
|
||||
ALTER TABLE compliance_loeschfristen
|
||||
ADD COLUMN IF NOT EXISTS current_version INTEGER DEFAULT 0;
|
||||
|
||||
ALTER TABLE compliance_obligations
|
||||
ADD COLUMN IF NOT EXISTS current_version INTEGER DEFAULT 0;
|
||||
|
||||
-- ============================================================================
|
||||
-- 2. DSFA Versions
|
||||
-- ============================================================================
|
||||
|
||||
CREATE TABLE IF NOT EXISTS compliance_dsfa_versions (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
dsfa_id UUID NOT NULL,
|
||||
tenant_id VARCHAR(255) NOT NULL,
|
||||
version_number INTEGER NOT NULL,
|
||||
status VARCHAR(20) DEFAULT 'draft',
|
||||
snapshot JSONB NOT NULL,
|
||||
change_summary TEXT,
|
||||
changed_sections JSONB DEFAULT '[]'::jsonb,
|
||||
created_by VARCHAR(200) DEFAULT 'system',
|
||||
approved_by VARCHAR(200),
|
||||
approved_at TIMESTAMPTZ,
|
||||
created_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
UNIQUE (dsfa_id, version_number)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_dsfa_versions_dsfa ON compliance_dsfa_versions(dsfa_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_dsfa_versions_tenant ON compliance_dsfa_versions(tenant_id);
|
||||
|
||||
-- ============================================================================
|
||||
-- 3. VVT Activity Versions
|
||||
-- ============================================================================
|
||||
|
||||
CREATE TABLE IF NOT EXISTS compliance_vvt_activity_versions (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
activity_id UUID NOT NULL,
|
||||
tenant_id VARCHAR(255) NOT NULL,
|
||||
version_number INTEGER NOT NULL,
|
||||
status VARCHAR(20) DEFAULT 'draft',
|
||||
snapshot JSONB NOT NULL,
|
||||
change_summary TEXT,
|
||||
changed_sections JSONB DEFAULT '[]'::jsonb,
|
||||
created_by VARCHAR(200) DEFAULT 'system',
|
||||
approved_by VARCHAR(200),
|
||||
approved_at TIMESTAMPTZ,
|
||||
created_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
UNIQUE (activity_id, version_number)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_vvt_activity_versions_activity ON compliance_vvt_activity_versions(activity_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_vvt_activity_versions_tenant ON compliance_vvt_activity_versions(tenant_id);
|
||||
|
||||
-- ============================================================================
|
||||
-- 4. TOM Versions
|
||||
-- ============================================================================
|
||||
|
||||
CREATE TABLE IF NOT EXISTS compliance_tom_versions (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
measure_id UUID NOT NULL,
|
||||
tenant_id VARCHAR(255) NOT NULL,
|
||||
version_number INTEGER NOT NULL,
|
||||
status VARCHAR(20) DEFAULT 'draft',
|
||||
snapshot JSONB NOT NULL,
|
||||
change_summary TEXT,
|
||||
changed_sections JSONB DEFAULT '[]'::jsonb,
|
||||
created_by VARCHAR(200) DEFAULT 'system',
|
||||
approved_by VARCHAR(200),
|
||||
approved_at TIMESTAMPTZ,
|
||||
created_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
UNIQUE (measure_id, version_number)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_tom_versions_measure ON compliance_tom_versions(measure_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_tom_versions_tenant ON compliance_tom_versions(tenant_id);
|
||||
|
||||
-- ============================================================================
|
||||
-- 5. Loeschfristen Versions
|
||||
-- ============================================================================
|
||||
|
||||
CREATE TABLE IF NOT EXISTS compliance_loeschfristen_versions (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
policy_id UUID NOT NULL,
|
||||
tenant_id VARCHAR(255) NOT NULL,
|
||||
version_number INTEGER NOT NULL,
|
||||
status VARCHAR(20) DEFAULT 'draft',
|
||||
snapshot JSONB NOT NULL,
|
||||
change_summary TEXT,
|
||||
changed_sections JSONB DEFAULT '[]'::jsonb,
|
||||
created_by VARCHAR(200) DEFAULT 'system',
|
||||
approved_by VARCHAR(200),
|
||||
approved_at TIMESTAMPTZ,
|
||||
created_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
UNIQUE (policy_id, version_number)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_loeschfristen_versions_policy ON compliance_loeschfristen_versions(policy_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_loeschfristen_versions_tenant ON compliance_loeschfristen_versions(tenant_id);
|
||||
|
||||
-- ============================================================================
|
||||
-- 6. Obligation Versions
|
||||
-- ============================================================================
|
||||
|
||||
CREATE TABLE IF NOT EXISTS compliance_obligation_versions (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
obligation_id UUID NOT NULL,
|
||||
tenant_id VARCHAR(255) NOT NULL,
|
||||
version_number INTEGER NOT NULL,
|
||||
status VARCHAR(20) DEFAULT 'draft',
|
||||
snapshot JSONB NOT NULL,
|
||||
change_summary TEXT,
|
||||
changed_sections JSONB DEFAULT '[]'::jsonb,
|
||||
created_by VARCHAR(200) DEFAULT 'system',
|
||||
approved_by VARCHAR(200),
|
||||
approved_at TIMESTAMPTZ,
|
||||
created_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
UNIQUE (obligation_id, version_number)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_obligation_versions_obligation ON compliance_obligation_versions(obligation_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_obligation_versions_tenant ON compliance_obligation_versions(tenant_id);
|
||||
|
||||
COMMIT;
|
||||
Reference in New Issue
Block a user