feat(iace): cross-domain precision overhaul + component review + schema reconcile
Engine precision (stop foreign-machine patterns leaking into a project):
- Wire project.MachineType into the engine machine-type gate (empty input no
longer fires every machine class — press/cnc/excavator/crane/medical...).
- Capability-domain gating extended by 7 domains (outdoor, ventilation,
machining, bulk, palletizer, playground, fitness) so domain-specific hazards
only fire when the narrative names that domain; emitted via keyword_dictionary.
- Relevance backstop moved into iace (single gating contract, testable), and its
dominant false-anchor class removed (a long pattern word no longer matches a
short common token; prepositions/leitung added to the generic stoplist).
- New guard tests: TestCrossDomainPrecision (full pipeline, 0 foreign per GT) and
TestPatternReachability now asserts 0 dead patterns. Both GTs keep coverage 1.0.
Reachability fix: the 51 dead patterns required electrical/pneumatic/hydraulic
tags nothing produced — renamed to the canonical electrical_energy/
pneumatic_pressure/hydraulic_pressure/hydraulic_part.
Component review (negation is best-effort + expert-correctable):
- Parser surfaces negated components (ComponentMatch.Negated) instead of dropping
them; negated contribute no tags/energy → no phantom hazards.
- presence_status (vorhanden|nicht_vorhanden|geloescht) + ce_marked on components;
only `vorhanden` feed matching. CE+safety-relevant flags the PL/SIL obligation.
- Force re-seed preserves the expert's component decisions instead of wiping them.
- Tag-based component→hazard assignment (was: all on the first component).
- Negation-aware narrative parsing ("keine Pneumatik" no longer extracts it).
Local-dev DB: ai-sdk sets search_path=compliance,core,public; reconcile migrations
152-156 bring the consolidated local iace tables to the current schema + add the
presence_status/ce_marked columns. Machine-type vocabulary endpoint for the form.
[migration-approved]
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -112,7 +112,7 @@ func GetMaintenanceExtPatterns() []HazardPattern {
|
||||
HarmDE: "Quetschung der Fuesse", AffectedDE: "Einrichter", ZoneDE: "Spannbereich",
|
||||
DefaultSeverity: 3, DefaultExposure: 4},
|
||||
{ID: "HP715", NameDE: "Stromschlag bei Steckerwechsel", NameEN: "Shock during connector change",
|
||||
RequiredComponentTags: []string{"electrical_part"}, RequiredEnergyTags: []string{"electrical"},
|
||||
RequiredComponentTags: []string{"electrical_part"}, RequiredEnergyTags: []string{"electrical_energy"},
|
||||
RequiredLifecycles: []string{"setup"}, GeneratedHazardCats: []string{"electrical_hazard"},
|
||||
SuggestedMeasureIDs: []string{"M522", "M539", "M518", "M141"}, SuggestedEvidenceIDs: []string{"E09"}, Priority: 65,
|
||||
ScenarioDE: "Steckverbinder unter Spannung gewechselt", TriggerDE: "Nicht spannungsfrei",
|
||||
@@ -312,7 +312,7 @@ func GetMaintenanceExtPatterns() []HazardPattern {
|
||||
DefaultSeverity: 3, DefaultExposure: 2},
|
||||
// — Reinigung (HP913-HP917) —
|
||||
{ID: "HP913", NameDE: "Nassreinigung nahe Elektrik", NameEN: "Wet cleaning near electrics",
|
||||
RequiredComponentTags: []string{"electrical_part"}, RequiredEnergyTags: []string{"electrical"},
|
||||
RequiredComponentTags: []string{"electrical_part"}, RequiredEnergyTags: []string{"electrical_energy"},
|
||||
RequiredLifecycles: []string{"cleaning"}, GeneratedHazardCats: []string{"electrical_hazard"},
|
||||
SuggestedMeasureIDs: []string{"M082", "M141"}, SuggestedEvidenceIDs: []string{"E09"}, Priority: 75,
|
||||
ScenarioDE: "Wasser gelangt in Schaltschrank", TriggerDE: "Hochdruckreiniger nahe Elektrik",
|
||||
@@ -407,7 +407,7 @@ func GetMaintenanceExtPatterns() []HazardPattern {
|
||||
HarmDE: "Erfassen, Quetschen", AffectedDE: "Pruefpersonal", ZoneDE: "Maschinenarbeitsraum",
|
||||
DefaultSeverity: 5, DefaultExposure: 2},
|
||||
{ID: "HP926", NameDE: "Messung an spannungsfuehrender Anlage", NameEN: "Measurement on energized system",
|
||||
RequiredComponentTags: []string{"electrical_part"}, RequiredEnergyTags: []string{"electrical"},
|
||||
RequiredComponentTags: []string{"electrical_part"}, RequiredEnergyTags: []string{"electrical_energy"},
|
||||
RequiredLifecycles: []string{"maintenance"}, GeneratedHazardCats: []string{"electrical_hazard"},
|
||||
SuggestedMeasureIDs: []string{"M082", "M141"}, SuggestedEvidenceIDs: []string{"E09"}, Priority: 75,
|
||||
ScenarioDE: "Messung unter Spannung", TriggerDE: "Messgeraet rutscht ab",
|
||||
|
||||
Reference in New Issue
Block a user