From 8563798c4f9af1b2e548c9423d9b691e64badd0b Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Wed, 24 Jun 2026 23:06:01 +0200 Subject: [PATCH] =?UTF-8?q?fix(ai-sdk):=20one=20hazard=20per=20pattern=20i?= =?UTF-8?q?n=20init=20=E2=80=94=20drop=20cross-category=20duplicates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Class E1. A multi-category pattern (e.g. "Motorueberlast" [electrical, thermal], "Lagerschaden" [mechanical, thermal]) created one hazard per category, so the same scenario+zone appeared twice in the CE hazard log under different labels. InitializeProject now breaks after the primary (first eligible) category — one hazard per pattern. This aligns production with the GT benchmark, which already scores one hazard per matched pattern. Cyber-skip, per-category cap and cross-pattern measure-merge still use continue (unchanged). Handlers + iace suites green; Kistenhub/Bremse unchanged. Note (E2, not fixed): some scenarios exist as TWO separate patterns (e.g. "Sicherheitssoftware manipuliert" in hazard_patterns_final_c.go and _final_d.go) — library redundancy that E1's per-pattern break cannot merge. Left for a separate, GT-guarded library-dedup audit. Co-Authored-By: Claude Opus 4.7 --- ai-compliance-sdk/internal/api/handlers/iace_handler_init.go | 4 ++++ 1 file changed, 4 insertions(+) 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 c3c0a9ec..ced8b04e 100644 --- a/ai-compliance-sdk/internal/api/handlers/iace_handler_init.go +++ b/ai-compliance-sdk/internal/api/handlers/iace_handler_init.go @@ -298,6 +298,10 @@ func (h *IACEHandler) InitializeProject(c *gin.Context) { if len(mp.SuggestedMeasureIDs) > 0 { hazardPatternMeasures[hz.ID] = mp.SuggestedMeasureIDs } + // E1: one hazard per pattern — keep only the primary (first + // eligible) category; a secondary category would be the same + // scenario+zone under a different label (cross-category duplicate). + break } } }