package ucca import "strings" // kbScopeTopics are high-precision data-protection / compliance topic markers that place a query in // the KB-2026.1 authoritative slice even when it does NOT name a regulation. Conservative by design: // an unmatched query falls back to the broad CE default (no regression) — the slice is only used when // the query is confidently in-scope. var kbScopeTopics = []string{ // DP-Guidance-Marker, die IN der Slice liegen (EDPB/DSK/WP/GL) — bewusst NICHT die generischen // Verben aus guidanceIntentSignals (sagt/laut/empfiehlt/auslegung) und NICHT enisa/bsi/nist/owasp // (die liegen im breiten CE-Pool, nicht in der Slice). "edpb", "dsk", "datenschutzausschuss", "orientierungshilfe", "wp2", "wp 2", "wp29", "working paper", "gl 0", "datenschutz", "dsgvo", "gdpr", "dsfa", "folgenabschätzung", "folgenabschaetzung", "einwilligung", "auftragsverarbeit", "betroffenenrecht", "auskunftsrecht", "verarbeitungsverzeichnis", "datenschutzbeauftragt", "verzeichnis von verarbeitung", "cookie", "tracking", "transparenzpflicht", "datenpanne", "meldepflicht", "technische und organisatorische maßnahmen", "cyber resilience", "schwachstelle", "vulnerability", "sicherheitsupdate", "maschinensicherheit", "wesentliche veränderung", "wesentliche veraenderung", "konformitätsbewertung", "konformitaetsbewertung", "ce-kennzeichnung", } // inKBScope reports whether the query belongs to the KB-2026.1 authoritative slice. True when it // names an in-slice regulation (detectRegulations), asks for guidance (EDPB/DSK/WP/GL), or hits a // data-protection / compliance topic marker. func inKBScope(query string) bool { if len(detectRegulations(query)) > 0 { return true } q := strings.ToLower(query) for _, t := range kbScopeTopics { if strings.Contains(q, t) { return true } } return false } // resolveCollection applies the Blue-Green „authoritative slice promotion" routing. An explicitly // requested collection is honoured unchanged; the DEFAULT (empty) request is routed to the KB-2026.1 // slice when the query is in-scope, else to the broad CE default. Disable via RAG_KB_SCOPE_ROUTING=false. func (c *LegalRAGClient) resolveCollection(query, requested string) string { if requested != "" { return requested } if c.kbScopeRoutingEnabled && c.kbSliceCollection != "" && inKBScope(query) { return c.kbSliceCollection } return c.collection }