diff --git a/ai-compliance-sdk/internal/api/handlers/iace_handler_init.go b/ai-compliance-sdk/internal/api/handlers/iace_handler_init.go index fc1940d3..235416a0 100644 --- a/ai-compliance-sdk/internal/api/handlers/iace_handler_init.go +++ b/ai-compliance-sdk/internal/api/handlers/iace_handler_init.go @@ -304,6 +304,11 @@ func (h *IACEHandler) InitializeProject(c *gin.Context) { hazCat := hazardCatByID[hazID] accepted := acceptableMeasureCategories(hazCat) added := 0 + // Aggregate norm references across all kept mitigations for this + // hazard so we can attach a single "Referenzierte Normen" line + // to the hazard description below. + var hazardNorms []string + seenNorm := map[string]bool{} if patternMIDs, ok := hazardPatternMeasures[hazID]; ok { for _, mid := range patternMIDs { @@ -324,9 +329,19 @@ func (h *IACEHandler) InitializeProject(c *gin.Context) { if rt == "" { rt = iace.ReductionTypeInformation } + mitDesc := entry.Description + if len(entry.NormReferences) > 0 { + mitDesc += "\n\nNormen: " + strings.Join(entry.NormReferences, " | ") + for _, n := range entry.NormReferences { + if !seenNorm[n] { + seenNorm[n] = true + hazardNorms = append(hazardNorms, n) + } + } + } _, cerr := h.store.CreateMitigation(ctx, iace.CreateMitigationRequest{ HazardID: hazID, ReductionType: rt, - Name: entry.Name, Description: entry.Description, + Name: entry.Name, Description: mitDesc, }) if cerr != nil { fmt.Printf("MEASURE-ERROR: mid=%s name=%s err=%v\n", mid, entry.Name, cerr) @@ -336,6 +351,18 @@ func (h *IACEHandler) InitializeProject(c *gin.Context) { } } } + // Append the aggregated norm list to the hazard so the UI shows + // a single "Referenzierte Normen" panel per hazard. + if len(hazardNorms) > 0 { + if existing, getErr := h.store.GetHazard(ctx, hazID); getErr == nil && existing != nil { + if !strings.Contains(existing.Description, "Referenzierte Normen:") { + newDesc := existing.Description + "\n\nReferenzierte Normen: " + strings.Join(hazardNorms, " | ") + _, _ = h.store.UpdateHazard(ctx, hazID, map[string]interface{}{ + "description": newDesc, + }) + } + } + } if added == 0 { zeroMitigationHazards++