Rule now carries a required Jurisdiction (land) field, and Facts a matching Jurisdiction supplied by the caller (like Platform — no legal jurisdiction can be read off a caption or image, so the model never guesses it). Evaluate() only lets a rule fire when its jurisdiction matches the facts' jurisdiction. This is the structural half of "deutsche Rechtslage zuerst, Struktur für Österreich und Schweiz vorgesehen": a future AT/CH rule set can be added as plain new YAML files without touching existing DE rules, but no AT/CH content is added now — that needs its own legal research first, same as WK-001/WK-004 needed for Germany. WK-001 and WK-004 are tagged land: DE, all golden fixtures carry jurisdiction: DE, and extract.Input passes Jurisdiction through unchanged into the returned Facts. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package rules
|
|
|
|
// Finding ist das Ergebnis einer einzelnen zutreffenden Regel.
|
|
type Finding struct {
|
|
RuleID string
|
|
RuleVersion int
|
|
Severity Severity
|
|
Title string
|
|
Fix string
|
|
Sources []string
|
|
}
|
|
|
|
// Evaluate prüft alle Regeln gegen f und liefert ein Finding für jede
|
|
// zutreffende Regel. Reihenfolge folgt der Reihenfolge von rules.
|
|
//
|
|
// Ist f.Consideration "unklar", wird KEINE Bewertung abgegeben —
|
|
// needsClarification ist dann true und findings ist immer leer. Das ist
|
|
// Absicht (Kernprinzip): eine unsichere Extraktion erzeugt eine
|
|
// Rückfrage an den Nutzer, niemals eine stille "keine Findings"-
|
|
// Bewertung, die wie "alles in Ordnung" aussähe.
|
|
func Evaluate(rules []Rule, f Facts) (findings []Finding, needsClarification bool) {
|
|
if f.Consideration == ConsiderationUnclear {
|
|
return nil, true
|
|
}
|
|
|
|
for _, r := range rules {
|
|
if r.Jurisdiction != f.Jurisdiction {
|
|
continue
|
|
}
|
|
if r.Condition.Matches(f) {
|
|
findings = append(findings, Finding{
|
|
RuleID: r.ID,
|
|
RuleVersion: r.Version,
|
|
Severity: r.Severity,
|
|
Title: r.Title,
|
|
Fix: r.Fix,
|
|
Sources: r.Sources,
|
|
})
|
|
}
|
|
}
|
|
return findings, false
|
|
}
|