feat(iace): Phase 1 — Haftungs-Fixes, Massnahmen-Verkabelung, Explainability Engine

Phase 1A — Haftungs-kritische Fixes:
- SIL/PL-Badges als "Vorab-Einschaetzung" mit Tooltip gekennzeichnet
- Coverage-Disclaimer in CE-Akte, Projekt-Uebersicht und Print-Export
- Norm-Referenzen: 42 Kapitelverweise durch Themen-Deskriptoren ersetzt

Phase 1B — Massnahmen-Verkabelung:
- 16 neue Massnahmen (M201-M216) fuer bisher unabgedeckte Kategorien
  (communication_failure, hmi_error, firmware_corruption, maintenance,
  sensor_fault, mode_confusion)
- Kategorie-Fallback im Initialize-Endpoint: ordnet Massnahmen aus der
  Bibliothek automatisch per HazardCategory zu (max 8 pro Kategorie)
- Total: 225 → 241 Massnahmen, 0 Kategorien ohne Massnahmen

Phase 1C — Explainability Engine:
- MatchReason Struct in PatternMatch (type, tag, met)
- Pattern Engine schreibt fuer jeden Match strukturierte Begruendungen
- Frontend zeigt "Erkannt weil: Komponente X, Energie Y, Kein Ausschluss Z"

Weitere Aenderungen:
- BAuA/OSHA Regulatory Hints: 3 Enrich-Endpoints (per Hazard, per Measure, Batch)
- Dokumente-Tab in IACE-Bibliothek (36.708 Chunks aus Qdrant)
- Varianten-UX: Basis-Projekt-Summary auf Varianten-Seite
- Projekt-Initialisierung: POST /initialize kettet Parse→Komponenten→Patterns→Hazards→Massnahmen→Normen
- 18 pre-existing TS-Fehler gefixt, Route-Konflikt behoben
- Component-Library + Measures-Library Tests aktualisiert

Tests: Go alle bestanden, TS 0 Fehler, Playwright 141+ bestanden

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-05-09 21:32:23 +02:00
parent 6387b6950a
commit 2e29b611c9
39 changed files with 1859 additions and 180 deletions
@@ -19,12 +19,21 @@ type MatchOutput struct {
ResolvedTags []string `json:"resolved_tags"`
}
// MatchReason explains why a specific check passed or was relevant for a pattern match.
type MatchReason struct {
Type string `json:"type"` // "required_component_tag", "required_energy_tag", "lifecycle_match", "no_exclusion"
Tag string `json:"tag"`
Met bool `json:"met"`
}
// PatternMatch records which pattern fired and why.
type PatternMatch struct {
PatternID string `json:"pattern_id"`
PatternName string `json:"pattern_name"`
Priority int `json:"priority"`
MatchedTags []string `json:"matched_tags"`
// Explainability: structured reasons why this pattern fired
MatchReasons []MatchReason `json:"match_reasons,omitempty"`
// Detail fields from the pattern definition
ScenarioDE string `json:"scenario_de,omitempty"`
TriggerDE string `json:"trigger_de,omitempty"`
@@ -136,16 +145,34 @@ func (e *PatternEngine) Match(input MatchInput) *MatchOutput {
continue
}
// Collect the tags that contributed to this match
// Collect the tags that contributed + build explainability reasons
var matchedTags []string
var reasons []MatchReason
for _, t := range p.RequiredComponentTags {
if tagSet[t] {
matchedTags = append(matchedTags, t)
reasons = append(reasons, MatchReason{Type: "required_component_tag", Tag: t, Met: true})
}
}
for _, t := range p.RequiredEnergyTags {
if tagSet[t] {
matchedTags = append(matchedTags, t)
reasons = append(reasons, MatchReason{Type: "required_energy_tag", Tag: t, Met: true})
}
}
for _, t := range p.ExcludedComponentTags {
reasons = append(reasons, MatchReason{Type: "no_exclusion", Tag: t, Met: !tagSet[t]})
}
if len(p.RequiredLifecycles) > 0 {
for _, lc := range p.RequiredLifecycles {
found := false
for _, ilc := range input.LifecyclePhases {
if ilc == lc {
found = true
break
}
}
reasons = append(reasons, MatchReason{Type: "lifecycle_match", Tag: lc, Met: found})
}
}
@@ -154,6 +181,7 @@ func (e *PatternEngine) Match(input MatchInput) *MatchOutput {
PatternName: p.NameDE,
Priority: p.Priority,
MatchedTags: matchedTags,
MatchReasons: reasons,
ScenarioDE: p.ScenarioDE,
TriggerDE: p.TriggerDE,
HarmDE: p.HarmDE,