feat(iace): generic cross-domain leak gates + norm vocab reconciliation

- Domain-gate ~15 foreign machine classes (pool, amusement, paint booth,
  tank farm, reactor, lathe/chips, saw, film/carton, robot, mobile cab,
  asbestos, playground swing) in pattern_domain_gates.go so ungated hazard
  patterns stop leaking into unrelated machines; matching emit keywords
  added in keyword_dictionary.go (gate+emit share one vocabulary).
- Extend the cross-domain precision guard to 6 machine classes (press,
  cobot, motor, welding + the 2 GTs) with per-case homeDomains, so a
  machine's own domain terms are never flagged. GT coverage stays 100%.
- Reconcile the fine-grained norm machine-type vocabulary (455 keys) with
  the 68 canonical dropdown keys via canonicalMachineType() family folding
  in matchNorm — welding 0->17, robotics_cobot 0->6, press 8->13,
  circular_saw 1->35 machine-specific C-norms. Pattern gating left strict.
- Fix initialize?force=true summary index-shift that mislabeled counts
  (reported matched-patterns as "hazards"); now uses named step vars.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-06-10 22:29:10 +02:00
parent b7a7e70731
commit 005a2ed711
10 changed files with 656 additions and 9 deletions
@@ -447,13 +447,19 @@ func (h *IACEHandler) InitializeProject(c *gin.Context) {
mustMarshalJSON(map[string]interface{}{"steps": steps}),
)
// Summary is built from the NAMED step variables, not positional steps[]
// indices: with ?force=true an extra "Alte Daten geloescht" step is prepended,
// which previously shifted steps[1..5] by one and mislabeled every count
// (e.g. reporting matched-patterns as "hazards"). These vars are stable.
c.JSON(http.StatusOK, gin.H{
"project_id": projectID.String(),
"steps": steps,
"summary": gin.H{
"components": steps[1].Count, "patterns": steps[2].Count,
"hazards": steps[3].Count, "mitigations": steps[4].Count,
"norms": steps[5].Count,
"components": compStep.Count,
"patterns": len(matchOutput.MatchedPatterns),
"hazards": hazardStep.Count,
"mitigations": mitStep.Count,
"norms": normCount,
},
})
}