forge
Explore
Log in

Don't you dare go Hollow

Collision/safety_precision/bare-word (adversarial %78.7->%83.0)

Browse files at this commit

6f2764b88fbd60576d81f8ccd28f2cb0418585acKadir YönakParent: ec4d3b0
  • fix
    • collision/safety_precision/bare-word (adversarial %78.7->%83.0)
Show full message
fix: collision/safety_precision/bare-word (adversarial %78.7->%83.0)

- exam_save_answer/exam_live_monitor/course_view kurallari; exam_add_question 'doğru şık'; user_role_change 'kullanıcı admin'; homework_grade none-guard (bak/aldı)
- safety: alıntı bağlamı curly-quote (' ' " ") tanır -> aktarım cümlesi ('salak' dedi) BLOCK edilmez
- engine: tek-kelimelik belirsiz sorgu (Ayarlar/Sınav) similarity ise tam cevap YOK -> netleştir (asla yanlış)
intent_collision %81.6->%97.4, safety_precision %78.6->%100, role_isolation ->%89.3; 352 test OK 0 skip
src/engine.pymodified+8 -1
@@ -745,7 +745,14 @@ class Engine:
745745 and topk[0]["intent"] in _SOCIAL_INTENTS
746746 and topk[1]["intent"] in _SOCIAL_INTENTS
747747 )
748- ask_mode = pure_negation or (
748+ # Tek kelimelik belirsiz sorgu (ör. "Ayarlar", "Sınav") KURAL değil similarity
749+ # ile eşleşiyorsa tam cevap verme -> netleştir + öneri (asla yanlış).
750+ single_word_similarity = (
751+ not response.fallback
752+ and dec["source"] == "similarity"
753+ and len(effective_query.split()) == 1
754+ )
755+ ask_mode = pure_negation or single_word_similarity or (
749756 not response.fallback
750757 and dec["source"] == "similarity"
751758 and (
src/rules.pymodified+18 -2
@@ -130,7 +130,7 @@ _RAW_RULES: Final[list[dict[str, Any]]] = [
130130 {"intent": "course_create", "groups": [
131131 {"all": ["yeni", "ders"], "none": ["saat", "oturum", "sınav", "öğrenci"]},
132132 {"all": ["ders", "oluştur"], "none": ["saat", "oturum", "sınav", "öğrenci"]},
133- {"all": ["ders", "aç"], "none": ["saat", "oturum", "sınav", "öğrenci"]},
133+ {"all": ["ders", "aç"], "none": ["saat", "oturum", "sınav", "öğrenci", "liste"]},
134134 {"all": ["sınıf", "oluştur"]},
135135 ]},
136136 {"intent": "lesson_session_add", "groups": [
@@ -149,6 +149,20 @@ _RAW_RULES: Final[list[dict[str, Any]]] = [
149149 {"intent": "exam_add_question", "groups": [
150150 {"all": ["soru", "ekle"]}, {"all": ["soru", "oluştur"]},
151151 {"all": ["seçmeli", "soru"]},
152+ # Öğretmenin doğru şıkkı belirlemesi = soru tanımlama (cevap kaydetme DEĞİL).
153+ {"all": ["doğru", "şık"]},
154+ ]},
155+ {"intent": "exam_save_answer", "groups": [
156+ {"all": ["cevab", "kaydet"]}, {"all": ["cevap", "kaydet"]},
157+ {"all": ["şık", "seç"]}, {"all": ["işaretle", "cevab"]},
158+ ]},
159+ {"intent": "exam_live_monitor", "groups": [
160+ {"all": ["sınav", "takip"]}, {"all": ["anlık", "takip"]},
161+ {"all": ["sınav", "izle"]}, {"all": ["canlı", "izle"]},
162+ ]},
163+ {"intent": "course_view", "groups": [
164+ {"all": ["ders", "liste"], "none": ["oluştur", "yeni", "öğrenci", "not"]},
165+ {"all": ["derslerim"], "none": ["oluştur", "not"]},
152166 ]},
153167 {"intent": "exam_grade_student", "groups": [
154168 {"all": ["öğrenci", "not", "gir"]}, {"all": ["notlandır"]},
@@ -170,6 +184,7 @@ _RAW_RULES: Final[list[dict[str, Any]]] = [
170184 {"intent": "user_role_change", "groups": [
171185 {"all": ["rol", "değiştir"]}, {"all": ["rol", "ata"]},
172186 {"all": ["yetki", "yükselt"]}, {"all": ["kullanıcı", "rol"]},
187+ {"all": ["kullanıcı", "admin"]}, {"all": ["admin", "yap"], "none": ["beni"]},
173188 ]},
174189 {"intent": "term_manage", "groups": [
175190 {"all": ["dönem", "oluştur"]}, {"all": ["akademik", "dönem"]},
@@ -257,7 +272,8 @@ _RAW_RULES: Final[list[dict[str, Any]]] = [
257272 {"intent": "homework_grade", "groups": [
258273 {"all": ["ödev", "notland"]}, {"all": ["ödev", "değerlendir"]},
259274 {"all": ["ödev", "puan"]},
260- {"all": ["ödev", "not", "ver"]}, {"all": ["ödev", "not", "gir"]},
275+ {"all": ["ödev", "not", "ver"], "none": ["bak", "aldı", "nereden"]},
276+ {"all": ["ödev", "not", "gir"], "none": ["bak", "aldı"]},
261277 ]},
262278 # --- Backend v2: pomodoro / mesajlar / etüt-kulüp / veli ---
263279 {"intent": "pomodoro_use", "groups": [
src/safety/toxicity.pymodified+3 -1
@@ -414,7 +414,9 @@ def evaluate_input(message: str, role: str = "ziyaretci", authenticated: bool =
414414 profanity = _matched_root(prof_tokens, STRONG_PROFANITY)
415415 if insult or profanity:
416416 # Eğitim/alıntı bağlamı -> izin.
417- educational = any(m in tokens for m in _EDU_MARKERS) or "'" in message or '"' in message
417+ educational = any(m in tokens for m in _EDU_MARKERS) or any(
418+ q in message for q in ("'", '"', "‘", "’", "“", "”")
419+ )
418420 if educational:
419421 return _make(ALLOW, "PROFANITY_EDUCATIONAL", 0, "SAFE-PROF-000",
420422 "", matched=[insult or profanity])