feat(iace): Phase 5+6 — frontend integration, RAG library search, comprehensive tests
All checks were successful
CI/CD / go-lint (push) Has been skipped
CI/CD / python-lint (push) Has been skipped
CI/CD / nodejs-lint (push) Has been skipped
CI/CD / test-go-ai-compliance (push) Successful in 34s
CI/CD / test-python-backend-compliance (push) Successful in 33s
CI/CD / test-python-document-crawler (push) Successful in 23s
CI/CD / test-python-dsms-gateway (push) Successful in 19s
CI/CD / validate-canonical-controls (push) Successful in 13s
CI/CD / Deploy (push) Successful in 2s

Phase 5 — Frontend Integration:
- components/page.tsx: ComponentLibraryModal with 120 components + 20 energy sources
- hazards/page.tsx: AutoSuggestPanel with 3-column pattern matching review
- mitigations/page.tsx: SuggestMeasuresModal per hazard with 3-level grouping
- verification/page.tsx: SuggestEvidenceModal per mitigation with evidence types

Phase 6 — RAG Library Search:
- Added bp_iace_libraries to AllowedCollections whitelist in rag_handlers.go
- SearchLibrary endpoint: POST /iace/library-search (semantic search across libraries)
- EnrichTechFileSection endpoint: POST /projects/:id/tech-file/:section/enrich
- Created ingest-iace-libraries.sh ingestion script for Qdrant collection

Tests (123 passing):
- tag_taxonomy_test.go: 8 tests for taxonomy entries, domains, essential tags
- controls_library_test.go: 7 tests for measures, reduction types, subtypes
- integration_test.go: 7 integration tests for full match flow and library consistency
- Extended tag_resolver_test.go: 9 new tests for FindByTags and cross-category resolution

Documentation:
- Updated iace.md with Hazard-Matching-Engine, RAG enrichment, and new DB tables

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-03-16 10:22:49 +01:00
parent 3b2006ebce
commit 9c1355c05f
13 changed files with 2422 additions and 43 deletions

View File

@@ -515,6 +515,108 @@ curl -sk "https://macmini:8093/sdk/v1/iace/controls-library?category=software_fa
---
## Hazard-Matching-Engine
Die Pattern Engine automatisiert die Ableitung von Gefaehrdungen, Schutzmassnahmen und Nachweisen aus der Maschinenkonfiguration.
### Komponentenbibliothek (120 Eintraege)
```bash
# Alle Komponenten abrufen
curl -sk "https://macmini:8093/sdk/v1/iace/component-library" | python3 -c \
"import sys,json; d=json.load(sys.stdin); print(f'{d[\"total\"]} Komponenten in {len(set(c[\"category\"] for c in d[\"components\"]))} Kategorien')"
# Nach Kategorie filtern
curl -sk "https://macmini:8093/sdk/v1/iace/component-library?category=mechanical"
```
| Kategorie | IDs | Anzahl | Beispiele |
|-----------|-----|--------|-----------|
| mechanical | C001-C020 | 20 | Roboterarm, Greifer, Foerderband |
| structural | C021-C030 | 10 | Maschinenrahmen, Schutzgehaeuse |
| drive | C031-C040 | 10 | Elektromotor, Servomotor |
| hydraulic | C041-C050 | 10 | Hydraulikpumpe, -zylinder |
| pneumatic | C051-C060 | 10 | Pneumatikzylinder, Kompressor |
| electrical | C061-C070 | 10 | Schaltschrank, Stromversorgung |
| control | C071-C080 | 10 | SPS, Sicherheits-SPS, HMI |
| sensor | C081-C090 | 10 | Positionssensor, Kamerasystem |
| actuator | C091-C100 | 10 | Magnetventil, Linearantrieb |
| safety | C101-C110 | 10 | Not-Halt, Lichtgitter |
| it_network | C111-C120 | 10 | Switch, Router, Firewall |
### Energiequellen (20 Eintraege)
```bash
curl -sk "https://macmini:8093/sdk/v1/iace/energy-sources"
```
### Tag-Taxonomie (~85 Tags)
| Domaene | Anzahl | Beispiele |
|---------|--------|-----------|
| component | ~30 | moving_part, rotating_part, high_voltage, networked, has_ai |
| energy | ~15 | kinetic, rotational, electrical_energy, hydraulic_pressure |
| hazard | ~20 | crush_risk, shear_risk, electric_shock_risk, cyber_risk |
| measure | ~10 | guard_measure, interlock_measure, software_safety_measure |
| evidence | ~10 | design_evidence, test_evidence, cyber_evidence |
```bash
# Alle Tags einer Domaene
curl -sk "https://macmini:8093/sdk/v1/iace/tags?domain=component"
```
### Hazard Patterns (44 Regeln)
Jedes Pattern definiert required_component_tags (AND), required_energy_tags (AND) und excluded_component_tags (NOT). Die Engine prueft alle Patterns gegen die aufgeloesten Tags der Projektkomponenten.
```bash
# Patterns auflisten
curl -sk "https://macmini:8093/sdk/v1/iace/hazard-patterns" | python3 -c \
"import sys,json; d=json.load(sys.stdin); print(f'{d[\"total\"]} Patterns')"
```
### Pattern-Matching Workflow
```bash
# 1. Pattern-Matching ausfuehren
curl -sk -X POST "https://macmini:8093/sdk/v1/iace/projects/{id}/match-patterns" \
-H "Content-Type: application/json" \
-d '{"component_library_ids": ["C001","C071"], "energy_source_ids": ["EN01","EN07"]}'
# 2. Ergebnisse uebernehmen
curl -sk -X POST "https://macmini:8093/sdk/v1/iace/projects/{id}/apply-patterns" \
-H "Content-Type: application/json" \
-d '{"accepted_hazards": [...], "accepted_measures": [...], "accepted_evidence": [...]}'
# 3. Pro-Hazard Massnahmen vorschlagen
curl -sk -X POST "https://macmini:8093/sdk/v1/iace/projects/{id}/hazards/{hid}/suggest-measures"
# 4. Pro-Massnahme Nachweise vorschlagen
curl -sk -X POST "https://macmini:8093/sdk/v1/iace/projects/{id}/mitigations/{mid}/suggest-evidence"
```
### RAG-Anreicherung (Phase 6)
IACE-Bibliotheken (Hazards, Komponenten, Energiequellen, Massnahmen, Nachweise) sind als RAG-Corpus in Qdrant verfuegbar (`bp_iace_libraries`).
```bash
# Semantische Suche in der IACE-Bibliothek
curl -sk -X POST "https://macmini:8093/sdk/v1/iace/library-search" \
-H "Content-Type: application/json" \
-d '{"query": "Quetschgefahr Roboterarm", "top_k": 5}'
# Tech-File-Abschnitt mit RAG-Kontext anreichern
curl -sk -X POST "https://macmini:8093/sdk/v1/iace/projects/{id}/tech-file/risk_assessment_report/enrich"
```
**Ingestion:**
```bash
# IACE-Bibliotheken in Qdrant ingestieren (auf Mac Mini)
bash ~/Projekte/breakpilot-compliance/scripts/ingest-iace-libraries.sh
```
---
## Datenbank-Tabellen
| Tabelle | Beschreibung |
@@ -534,6 +636,9 @@ curl -sk "https://macmini:8093/sdk/v1/iace/controls-library?category=software_fa
| `iace_lifecycle_phases` | 25 Lebensphasen (DE/EN) |
| `iace_roles` | 20 betroffene Personengruppen (DE/EN) |
| `iace_evidence_types` | 50 Nachweistypen in 7 Kategorien |
| `iace_component_library` | 120 Maschinenkomponenten (C001-C120) |
| `iace_energy_sources` | 20 Energiequellen (EN01-EN20) |
| `iace_pattern_results` | Audit-Trail fuer Pattern-Matching |
---