Files
breakpilot-compliance/ai-compliance-sdk/internal/iace/keyword_dictionary.go
T
Benjamin Admin f534b52817 feat(iace): pattern audit suite + library hygiene wave
Add cmd/iace-audit CLI with 5 deterministic methods that find engine
gaps without ground truth:

- A reachability: 1058 patterns vs achievable tag universe
- B consistency: components vs their declared hazard categories
- C vocabulary: limits-form tokens vs keyword dictionary
- D echo: limits-form sentences vs generated hazards (jaccard)
- E hierarchy: hazards vs ISO 12100 design/protection/info levels

Library fixes triggered by A+B+C findings:

- tag_resolver: synonym map for electrical/pneumatic/hydraulic aliases
- component_library: crush_point + EN03 (gravitational) on C014/C128
  (Hubwerk family) - fixes HP1014/1015/1017/1018 which were silently
  weakly_reachable. noise_source added on 7 components (C006/C011/
  C017/C020/C031/C041/C096). electrical_part on 8 drive components
  (C031/C032/C033/C034/C035/C036/C037/C038/C077/C092). cyber tag
  on 10 sensors (C081-C090) + 3 IT components (C111/C112/C116) +
  KI module C119 (ai_model added). pneumatic_part+hydraulic_part
  on valves C091/C093, hydraulic_part+chemical_risk on pump C097,
  moving_part on motion controller C075
- keyword_dictionary: EN03 added to aufzug/lift/hubwerk/hubgeraet
  (was wrongly EN04-only). New keyword entries for hub-action verbs:
  absenken/senken/anheben/heben + hubhoehe/hubweg/hubgeschwindig

Audit impact:
- A: weakly_reachable 409 -> 358 (-51 patterns now fully reachable)
- B: incomplete components 46 -> 30 (-16, -33%)
- HP1018 (Person unter absenkendem Maschinenteil eingeklemmt):
  weakly_reachable -> reachable

Why: methods A/B/C surfaced that the Kistenhubgeraet test project
generated 0 crush-under-load hazards despite OSHA 1910.212(a)(3) +
EN ISO 12100 6.3.5.5 explicitly requiring them. Three orthogonal
bugs (missing crush_point tag, wrong energy source mapping, missing
action verbs in dictionary) silently disabled the entire lift crush
pattern family.
2026-05-21 10:51:08 +02:00

175 lines
20 KiB
Go

package iace
// KeywordEntry maps German/English keywords to component library IDs,
// energy source IDs, and additional tags for deterministic text parsing.
type KeywordEntry struct {
Keywords []string // Search terms (lowercase, may include partial matches)
ComponentIDs []string // Matched component library IDs (C001-C135)
EnergyIDs []string // Matched energy source IDs (EN01-EN20)
ExtraTags []string // Additional tags derived from keyword context
// MachineTypes restricts this keyword to specific machine types.
// Empty = matches all machine types. If set, only matches when the
// project's machine_type is in this list.
MachineTypes []string // e.g. ["press", "hydraulic_press"]
}
// GetKeywordDictionary returns the complete keyword dictionary for
// deterministic narrative parsing. ~250 entries covering industrial
// machinery terminology in German and English.
func GetKeywordDictionary() []KeywordEntry {
return []KeywordEntry{
// ── Pressen / Umformmaschinen (NUR fuer press/hydraulic_press) ──
{Keywords: []string{"presse", "press", "umform", "umformung"}, ComponentIDs: []string{"C008", "C122"}, EnergyIDs: []string{"EN01"}, ExtraTags: []string{"high_force", "crush_point"}, MachineTypes: []string{"press", "hydraulic_press", "mechanical_press", "stamping_press"}},
{Keywords: []string{"kniehebel", "toggle"}, ComponentIDs: []string{"C121"}, ExtraTags: []string{"mechanical_transmission"}, MachineTypes: []string{"press"}},
{Keywords: []string{"stossel", "stoessel", "ram", "slide"}, ComponentIDs: []string{"C122"}, EnergyIDs: []string{"EN01"}, ExtraTags: []string{"moving_part", "crush_point", "gravity_risk"}, MachineTypes: []string{"press", "hydraulic_press", "mechanical_press"}},
{Keywords: []string{"stempel", "punch", "matrize", "die"}, ComponentIDs: []string{"C126"}, ExtraTags: []string{"crush_point", "cutting_part"}, MachineTypes: []string{"press", "hydraulic_press", "mechanical_press", "stamping_press"}},
{Keywords: []string{"schwungrad", "flywheel"}, ComponentIDs: []string{"C133"}, EnergyIDs: []string{"EN02", "EN03"}, ExtraTags: []string{"stored_energy", "rotating_part"}, MachineTypes: []string{"press", "mechanical_press"}},
{Keywords: []string{"werkzeugeinbauraum", "die space"}, ComponentIDs: []string{"C132"}, ExtraTags: []string{"crush_point", "pinch_point"}, MachineTypes: []string{"press", "hydraulic_press", "mechanical_press"}},
// ── Foerdertechnik ──────────────────────────────────────────────
{Keywords: []string{"foerderband", "transportband", "conveyor"}, ComponentIDs: []string{"C003"}, EnergyIDs: []string{"EN01", "EN02"}, ExtraTags: []string{"entanglement_risk"}},
{Keywords: []string{"transfer", "transferanlage", "transfersystem"}, ComponentIDs: []string{"C127"}, ExtraTags: []string{"shear_risk", "pinch_point"}},
// Hubgeraete: korrigiert auf EN03 (Potentielle/Gravitational) statt
// nur EN04 (Elektrisch). Audit-Methode A zeigte, dass HP1014/HP1015/
// HP1017/HP1018 (alle Quetsch-Patterns unter absenkender Last) nicht
// zuendeten weil sowohl crush_point als auch gravitational fehlten.
// EN04 bleibt fuer Steuerstrom-bezogene Patterns mit drin.
{Keywords: []string{"aufzug", "elevator", "lift"}, ComponentIDs: []string{"C014", "C128"}, EnergyIDs: []string{"EN03", "EN04"}, ExtraTags: []string{"gravity_risk", "person_under_load", "crush_point"}},
{Keywords: []string{"hubwerk", "hoist", "hubgeraet"}, ComponentIDs: []string{"C128"}, EnergyIDs: []string{"EN03", "EN04"}, ExtraTags: []string{"gravity_risk", "person_under_load", "crush_point"}},
// Hub-Verben aus Methode-C-Vocabulary-Diff: "absenken/senken/
// anheben/heben/hubhoehe" tauchten im Limits-Form auf, der Parser
// kannte sie nicht. Konservativ EN03 + Tags, Component bleibt offen.
{Keywords: []string{"absenk", "senken", "anheben", "heben"}, EnergyIDs: []string{"EN03"}, ExtraTags: []string{"gravity_risk", "person_under_load", "crush_point"}},
{Keywords: []string{"hubhoehe", "hubweg", "hubgeschwindig"}, EnergyIDs: []string{"EN03"}, ExtraTags: []string{"gravity_risk", "crush_point"}},
{Keywords: []string{"ruettel", "vibration", "vibrationsfoerderer"}, ComponentIDs: []string{"C125"}, ExtraTags: []string{"vibration_source", "noise_source"}},
{Keywords: []string{"fallrohr", "auswurf", "chute"}, ComponentIDs: []string{"C129"}, EnergyIDs: []string{"EN04"}, ExtraTags: []string{"gravity_risk"}},
{Keywords: []string{"kistenwechsel", "bin change"}, ComponentIDs: []string{"C134"}, ExtraTags: []string{"ergonomic", "gravity_risk"}},
{Keywords: []string{"drehtisch", "rotary table"}, ComponentIDs: []string{"C004"}, EnergyIDs: []string{"EN02"}, ExtraTags: []string{"rotating_part"}},
{Keywords: []string{"linearachse", "linear axis"}, ComponentIDs: []string{"C005"}, EnergyIDs: []string{"EN01"}, ExtraTags: []string{"crush_point"}},
{Keywords: []string{"waage", "wiege", "scale", "pruefstation"}, ComponentIDs: []string{"C135"}, ExtraTags: []string{"sensor_part"}},
// ── Antriebe ────────────────────────────────────────────────────
{Keywords: []string{"motor", "elektromotor", "drehstrom"}, ComponentIDs: []string{"C031"}, EnergyIDs: []string{"EN02", "EN05"}, ExtraTags: []string{"rotating_part"}},
{Keywords: []string{"servomotor", "servo"}, ComponentIDs: []string{"C032"}, EnergyIDs: []string{"EN02"}, ExtraTags: []string{"rotating_part", "high_speed"}},
{Keywords: []string{"frequenzumrichter", "vfd", "inverter"}, ComponentIDs: []string{"C034"}, EnergyIDs: []string{"EN05"}, ExtraTags: []string{"electrical_part"}},
{Keywords: []string{"getriebe", "gearbox"}, ComponentIDs: []string{"C035"}, EnergyIDs: []string{"EN02"}, ExtraTags: []string{"rotating_part"}},
{Keywords: []string{"riemen", "belt drive"}, ComponentIDs: []string{"C040"}, EnergyIDs: []string{"EN02"}, ExtraTags: []string{"entanglement_risk"}},
// ── Hydraulik ───────────────────────────────────────────────────
{Keywords: []string{"hydraulik", "hydraulisch", "hydraulic"}, ComponentIDs: []string{"C041"}, EnergyIDs: []string{"EN07"}, ExtraTags: []string{"hydraulic_part", "high_pressure"}},
{Keywords: []string{"hydraulikpumpe", "hydraulic pump"}, ComponentIDs: []string{"C041"}, EnergyIDs: []string{"EN07"}, ExtraTags: []string{"hydraulic_part"}},
{Keywords: []string{"hydraulikzylinder", "hydraulic cylinder"}, ComponentIDs: []string{"C042"}, EnergyIDs: []string{"EN07"}, ExtraTags: []string{"hydraulic_part", "moving_part"}},
{Keywords: []string{"hydraulikventil", "hydraulic valve"}, ComponentIDs: []string{"C043"}, EnergyIDs: []string{"EN07"}, ExtraTags: []string{"hydraulic_part"}},
{Keywords: []string{"hydraulikspeicher", "accumulator"}, ComponentIDs: []string{"C044"}, EnergyIDs: []string{"EN07", "EN10"}, ExtraTags: []string{"stored_energy", "rapid_energy_release"}},
{Keywords: []string{"hydraulikschlauch", "hose"}, ComponentIDs: []string{"C045"}, ExtraTags: []string{"hydraulic_part"}},
{Keywords: []string{"druckbegrenzung", "pressure relief"}, ComponentIDs: []string{"C131"}, ExtraTags: []string{"safety_device"}},
{Keywords: []string{"schmier", "lubrication", "schmieranlage"}, ComponentIDs: []string{"C123"}, EnergyIDs: []string{"EN07"}, ExtraTags: []string{"oil_mist_risk"}},
{Keywords: []string{"oelfang", "auffangwanne", "drip tray"}, ComponentIDs: []string{"C130"}, ExtraTags: []string{"chemical_risk"}},
// ── Pneumatik ───────────────────────────────────────────────────
{Keywords: []string{"pneumatik", "pneumatisch", "pneumatic"}, ComponentIDs: []string{"C051"}, EnergyIDs: []string{"EN08"}, ExtraTags: []string{"pneumatic_part"}},
{Keywords: []string{"kompressor", "compressor", "druckluft"}, ComponentIDs: []string{"C052"}, EnergyIDs: []string{"EN08"}, ExtraTags: []string{"noise_source"}},
{Keywords: []string{"vakuum", "vacuum", "sauger"}, ComponentIDs: []string{"C055"}, EnergyIDs: []string{"EN08"}, ExtraTags: []string{}},
// ── Elektrik ────────────────────────────────────────────────────
{Keywords: []string{"schaltschrank", "cabinet", "electrical cabinet"}, ComponentIDs: []string{"C061"}, EnergyIDs: []string{"EN05"}, ExtraTags: []string{"high_voltage", "electrical_part"}},
{Keywords: []string{"stromversorgung", "power supply"}, ComponentIDs: []string{"C062"}, EnergyIDs: []string{"EN05"}, ExtraTags: []string{"electrical_part"}},
{Keywords: []string{"transformator", "transformer"}, ComponentIDs: []string{"C063"}, EnergyIDs: []string{"EN05"}, ExtraTags: []string{"high_voltage"}},
{Keywords: []string{"hauptschalter", "main switch"}, ComponentIDs: []string{"C070"}, EnergyIDs: []string{"EN05"}, ExtraTags: []string{"electrical_part"}},
{Keywords: []string{"fi-schutz", "rcd", "fehlerstrom"}, ComponentIDs: []string{"C066"}, ExtraTags: []string{"safety_device"}},
{Keywords: []string{"usv", "ups"}, ComponentIDs: []string{"C067"}, EnergyIDs: []string{"EN09"}, ExtraTags: []string{"stored_energy"}},
// ── Steuerung / SPS ─────────────────────────────────────────────
{Keywords: []string{"sps", "plc", "steuerung", "speicherprogrammierbar"}, ComponentIDs: []string{"C071"}, ExtraTags: []string{"has_software", "programmable"}},
{Keywords: []string{"sicherheits-sps", "safety plc", "f-sps"}, ComponentIDs: []string{"C072"}, ExtraTags: []string{"has_software", "safety_device"}},
{Keywords: []string{"hmi", "bedienfeld", "bedienpanel", "touchpanel"}, ComponentIDs: []string{"C073"}, ExtraTags: []string{"user_interface"}},
{Keywords: []string{"bedienpult", "control desk"}, ComponentIDs: []string{"C079"}, ExtraTags: []string{"user_interface"}},
// ── Sensorik ────────────────────────────────────────────────────
{Keywords: []string{"positionssensor", "position sensor", "initiator"}, ComponentIDs: []string{"C081"}, ExtraTags: []string{"sensor_part"}},
{Keywords: []string{"kamera", "vision", "bildverarbeitung"}, ComponentIDs: []string{"C082"}, ExtraTags: []string{"sensor_part"}},
{Keywords: []string{"kraftsensor", "force sensor", "kraftmessdose"}, ComponentIDs: []string{"C083"}, ExtraTags: []string{"sensor_part"}},
{Keywords: []string{"temperatursensor", "thermocouple"}, ComponentIDs: []string{"C084"}, ExtraTags: []string{"sensor_part"}},
{Keywords: []string{"drucksensor", "pressure sensor"}, ComponentIDs: []string{"C085"}, ExtraTags: []string{"sensor_part"}},
{Keywords: []string{"drehgeber", "encoder"}, ComponentIDs: []string{"C086"}, ExtraTags: []string{"sensor_part"}},
{Keywords: []string{"laserscanner", "laser scanner"}, ComponentIDs: []string{"C087"}, ExtraTags: []string{"sensor_part", "safety_device"}},
// ── Sicherheitseinrichtungen ────────────────────────────────────
{Keywords: []string{"not-halt", "not-aus", "emergency stop", "e-stop"}, ComponentIDs: []string{"C101"}, ExtraTags: []string{"safety_device", "emergency_stop"}},
{Keywords: []string{"lichtgitter", "lichtvorhang", "light curtain", "light grid"}, ComponentIDs: []string{"C102"}, ExtraTags: []string{"safety_device"}},
{Keywords: []string{"sicherheitsschalter", "safety switch"}, ComponentIDs: []string{"C104"}, ExtraTags: []string{"safety_device", "interlocked"}},
{Keywords: []string{"zuhaltung", "guard locking", "interlock"}, ComponentIDs: []string{"C105"}, ExtraTags: []string{"safety_device", "interlocked"}},
{Keywords: []string{"zweihand", "two-hand", "zweihandschaltung"}, ComponentIDs: []string{"C106"}, ExtraTags: []string{"safety_device", "two_hand_control_required"}},
{Keywords: []string{"schaltmatte", "safety mat"}, ComponentIDs: []string{"C108"}, ExtraTags: []string{"safety_device"}},
{Keywords: []string{"seilzug", "pull wire"}, ComponentIDs: []string{"C109"}, ExtraTags: []string{"safety_device"}},
{Keywords: []string{"zustimmtaster", "enabling device"}, ComponentIDs: []string{"C110"}, ExtraTags: []string{"safety_device"}},
// ── Schutzeinrichtungen / Strukturell ───────────────────────────
{Keywords: []string{"schutzumhausung", "schutzeinhausung", "enclosure"}, ComponentIDs: []string{"C022"}, ExtraTags: []string{"guard", "interlocked"}},
{Keywords: []string{"schutzgitter", "protective fence", "schutzzaun"}, ComponentIDs: []string{"C028"}, ExtraTags: []string{"guard"}},
{Keywords: []string{"schutztuer", "safety door", "schutztuer"}, ComponentIDs: []string{"C023"}, ExtraTags: []string{"guard", "interlocked"}},
// ── Absaugung / Umwelt ──────────────────────────────────────────
{Keywords: []string{"absaug", "extraction", "abscheider"}, ComponentIDs: []string{"C124"}, ExtraTags: []string{"noise_source"}},
{Keywords: []string{"filter", "filteranlage"}, ComponentIDs: []string{"C124"}, ExtraTags: []string{}},
// ── IT / Netzwerk ───────────────────────────────────────────────
{Keywords: []string{"switch", "netzwerk"}, ComponentIDs: []string{"C111"}, ExtraTags: []string{"networked"}},
{Keywords: []string{"firewall"}, ComponentIDs: []string{"C113"}, ExtraTags: []string{"networked"}},
{Keywords: []string{"iot", "gateway"}, ComponentIDs: []string{"C114"}, ExtraTags: []string{"networked"}},
{Keywords: []string{"wlan", "wifi", "wireless"}, ComponentIDs: []string{"C116"}, ExtraTags: []string{"wireless"}},
{Keywords: []string{"opc ua", "opc-ua"}, ComponentIDs: []string{"C117"}, ExtraTags: []string{"networked"}},
// ── KI / Software ───────────────────────────────────────────────
{Keywords: []string{"kuenstliche intelligenz", "ki-", "ai ", "machine learning", "neural"}, ComponentIDs: []string{"C119"}, ExtraTags: []string{"has_ai"}},
{Keywords: []string{"software", "firmware"}, ComponentIDs: []string{}, ExtraTags: []string{"has_software"}},
// ── Allgemeine Maschinen-Keywords ────────────────────────────────
{Keywords: []string{"roboter", "robot"}, ComponentIDs: []string{"C001"}, EnergyIDs: []string{"EN01", "EN02"}, ExtraTags: []string{"moving_part", "high_force"}},
{Keywords: []string{"greifer", "gripper"}, ComponentIDs: []string{"C002"}, ExtraTags: []string{"clamping_part", "pinch_point"}},
{Keywords: []string{"spindel", "spindle"}, ComponentIDs: []string{"C006"}, EnergyIDs: []string{"EN02"}, ExtraTags: []string{"rotating_part", "high_speed"}},
{Keywords: []string{"saege", "saw"}, ComponentIDs: []string{"C007"}, ExtraTags: []string{"cutting_part"}},
{Keywords: []string{"walze", "roller"}, ComponentIDs: []string{"C009"}, EnergyIDs: []string{"EN02"}, ExtraTags: []string{"rotating_part", "entanglement_risk"}},
{Keywords: []string{"kette", "chain"}, ComponentIDs: []string{"C010"}, ExtraTags: []string{"entanglement_risk"}},
{Keywords: []string{"bremse", "brake"}, ComponentIDs: []string{"C013"}, ExtraTags: []string{"safety_device"}},
{Keywords: []string{"schweiss", "weld"}, ComponentIDs: []string{"C016"}, EnergyIDs: []string{"EN05"}, ExtraTags: []string{"high_temperature"}},
{Keywords: []string{"biege", "bend"}, ComponentIDs: []string{"C019"}, ExtraTags: []string{"high_force"}},
{Keywords: []string{"stanz", "stamp", "punch"}, ComponentIDs: []string{"C018"}, ExtraTags: []string{"high_force", "crush_point"}},
{Keywords: []string{"heiz", "heater", "heating"}, ComponentIDs: []string{"C094"}, EnergyIDs: []string{"EN06"}, ExtraTags: []string{"high_temperature"}},
{Keywords: []string{"kuehl", "cool"}, ComponentIDs: []string{"C095"}, ExtraTags: []string{}},
{Keywords: []string{"luefter", "fan", "geblaese"}, ComponentIDs: []string{"C096"}, ExtraTags: []string{"rotating_part", "noise_source"}},
{Keywords: []string{"spannvorrichtung", "fixture", "clamp"}, ComponentIDs: []string{"C100"}, ExtraTags: []string{"clamping_part"}},
// ── Cobot / Kollaborativer Betrieb ──────────────────────────────
{Keywords: []string{"kollaborier", "kollaboration", "collaborative"}, ComponentIDs: []string{"C139"}, ExtraTags: []string{"collaborative_operation", "force_limited"}},
{Keywords: []string{"cobot"}, ComponentIDs: []string{"C139"}, ExtraTags: []string{"collaborative_operation"}},
{Keywords: []string{"endeffektor", "end effector", "werkzeug am roboter"}, ComponentIDs: []string{"C136"}, ExtraTags: []string{"tool_at_robot"}},
{Keywords: []string{"werkstueck", "workpiece"}, ComponentIDs: []string{"C137"}, ExtraTags: []string{"variable_workpiece"}},
{Keywords: []string{"sicherheitsscanner", "safety scanner"}, ComponentIDs: []string{"C138"}, ExtraTags: []string{"safety_device"}},
{Keywords: []string{"kraftsensor", "momentsensor", "force sensor", "torque sensor"}, ComponentIDs: []string{"C140"}, ExtraTags: []string{"force_limited"}},
{Keywords: []string{"nachlauf", "afterrun"}, ExtraTags: []string{"afterrun_risk"}},
{Keywords: []string{"traglast", "payload"}, ExtraTags: []string{"gravity_risk"}},
{Keywords: []string{"reichweite", "reach"}, ExtraTags: []string{"moving_part"}},
// ── Elektromotor-spezifisch ────────────────────────────────────
{Keywords: []string{"elektromotor", "electric motor", "asynchronmotor", "synchronmotor"}, ComponentIDs: []string{"C031"}, EnergyIDs: []string{"EN02", "EN05"}, ExtraTags: []string{"rotating_part"}},
{Keywords: []string{"wicklung", "winding", "stator", "rotor"}, ComponentIDs: []string{"C031"}, EnergyIDs: []string{"EN05"}, ExtraTags: []string{"rotating_part", "high_voltage"}},
{Keywords: []string{"lager", "bearing", "waelzlager", "kugellager"}, ComponentIDs: []string{"C013"}, ExtraTags: []string{"rotating_part"}},
{Keywords: []string{"luefter", "ventilator", "kuehlung"}, ComponentIDs: []string{"C096"}, ExtraTags: []string{"rotating_part", "noise_source"}},
{Keywords: []string{"klemmenkasten", "terminal box"}, ComponentIDs: []string{"C061"}, EnergyIDs: []string{"EN05"}, ExtraTags: []string{"high_voltage"}},
{Keywords: []string{"welle", "shaft", "abtriebswelle"}, ComponentIDs: []string{"C031"}, EnergyIDs: []string{"EN02"}, ExtraTags: []string{"rotating_part", "entanglement_risk"}},
{Keywords: []string{"drehmoment", "torque"}, EnergyIDs: []string{"EN02"}, ExtraTags: []string{"high_force", "rotating_part"}},
{Keywords: []string{"isolierung", "insulation"}, ExtraTags: []string{"high_voltage"}},
// ── Kontext-Keywords (keine Komponente, nur Tags) ───────────────
{Keywords: []string{"vollautomatisch", "automatisch"}, ExtraTags: []string{"auto_operation"}},
{Keywords: []string{"schutzausruestung", "psa", "ppe"}, ExtraTags: []string{"ppe_required"}},
{Keywords: []string{"gehoerschutz", "hearing protection"}, ExtraTags: []string{"noise_source", "ppe_required"}},
{Keywords: []string{"sicherheitsschuh", "safety shoe"}, ExtraTags: []string{"ppe_required"}},
{Keywords: []string{"fehlanwendung", "misuse"}, ExtraTags: []string{"bypass_risk"}},
{Keywords: []string{"umgehung", "bypass"}, ExtraTags: []string{"bypass_risk"}},
{Keywords: []string{"explosion", "explosionsgefaehrd"}, ExtraTags: []string{"chemical_risk"}},
{Keywords: []string{"flurfoerderfahrzeug", "forklift", "gabelstapler"}, ExtraTags: []string{"moving_part", "gravity_risk"}},
}
}