feat(Phase1/B): user_visible Flag — Auto-Route User-Zugriff-Schutz
Schema-Erweiterung: Jeder Raum in room-map.json bekommt ein user_visible Flag (Default: true, abwärtskompatibel). - RoomEntry.user_visible: bool = True (neues Feld) - room_map.py find_room_by_keywords(): filtert user_visible=false Räume aus allen drei Stufen (100%-Keywords, Origin-Priorität, Kontext-Keywords) - room_map.py is_user_visible(): neue Helper-Methode - room_map.py _from_dict()/save(): Serialisierung/Deserialisierung des Flags - onboarding.py check_room_map_completeness(): user_visible=false Räume werden NICHT als missing_rooms gemeldet (kein Onboarding-Trigger) Tests: test_user_visible.py (9 Tests) — Routing-Filter, Default-true, Onboarding-Ignore, Persistenz.
This commit is contained in:
@@ -77,6 +77,16 @@ class RoomEntry:
|
||||
active_status_indikator: bool = True
|
||||
"""V8.6: Aktivitäts-Indikator — Bot-Status automatisch anzeigen (PresenceEngine)."""
|
||||
|
||||
user_visible: bool = True
|
||||
"""Auto-Route User-Zugriff-Schutz (Phase 1/B): Sichtbarkeits-Flag.
|
||||
|
||||
- ``True`` (Default): Raum ist Routing-Ziel und Onboarding-relevant.
|
||||
- ``False``: Raum wird NICHT als Routing-Ziel verwendet und triggert
|
||||
KEIN Onboarding (kein ``missing_rooms``-Eintrag).
|
||||
|
||||
Abwärtskompatibel: Räume ohne Flag (alte room-map.json) sind sichtbar.
|
||||
"""
|
||||
|
||||
# V8.2: Keyword-Tracking für Lern-Persistenz und Demotion
|
||||
_keyword_last_matched: Dict[str, str] = field(default_factory=dict)
|
||||
"""Mapping keyword → ISO timestamp des letzten Matches (für Demotion)."""
|
||||
@@ -397,6 +407,10 @@ class RoomMap:
|
||||
for room in self._rooms.values():
|
||||
if room.catch_all:
|
||||
continue
|
||||
# Auto-Route User-Zugriff-Schutz (Phase 1/B): user_visible=false
|
||||
# Räume sind keine Routing-Kandidaten.
|
||||
if not room.user_visible:
|
||||
continue
|
||||
|
||||
matched = self._get_matched_keywords(room, text, "100")
|
||||
score_100 = len(matched)
|
||||
@@ -420,12 +434,15 @@ class RoomMap:
|
||||
# V8.4.6: Catch-All-Räume sind in Stufe 2 als Butler-Ziele erlaubt
|
||||
if origin_room_id is not None and origin_room_id in self._rooms:
|
||||
origin_room = self._rooms[origin_room_id]
|
||||
# Prüfe kontextabhängige Keywords im Ursprungsraum
|
||||
# (auch Catch-All-Räume — sie können Kontext-Keywords haben)
|
||||
# Context-Keywords: exaktes Matching (kein Stemming/Fuzzy)
|
||||
context_score = sum(1 for kw in origin_room.keywords_context if match_keyword_exact(kw, text))
|
||||
if context_score >= min_score:
|
||||
return origin_room
|
||||
# Auto-Route User-Zugriff-Schutz (Phase 1/B): user_visible=false
|
||||
# Räume sind keine Routing-Kandidaten (auch nicht als Origin-Ziel).
|
||||
if origin_room.user_visible:
|
||||
# Prüfe kontextabhängige Keywords im Ursprungsraum
|
||||
# (auch Catch-All-Räume — sie können Kontext-Keywords haben)
|
||||
# Context-Keywords: exaktes Matching (kein Stemming/Fuzzy)
|
||||
context_score = sum(1 for kw in origin_room.keywords_context if match_keyword_exact(kw, text))
|
||||
if context_score >= min_score:
|
||||
return origin_room
|
||||
|
||||
# Stufe 3: Globaler Scan mit kontextabhängigen Keywords
|
||||
# V8.4.6: Catch-All-Räume sind in Stufe 3 als Butler-Ziele erlaubt.
|
||||
@@ -437,6 +454,10 @@ class RoomMap:
|
||||
best_matched: list[str] = []
|
||||
|
||||
for room in self._rooms.values():
|
||||
# Auto-Route User-Zugriff-Schutz (Phase 1/B): user_visible=false
|
||||
# Räume sind keine Routing-Kandidaten.
|
||||
if not room.user_visible:
|
||||
continue
|
||||
matched = self._get_matched_keywords(room, text, "context")
|
||||
context_score = len(matched)
|
||||
|
||||
@@ -493,6 +514,18 @@ class RoomMap:
|
||||
"""True if *room_id* is in the excluded list (e.g. Multi-Agent-Raum)."""
|
||||
return room_id in self._excluded_room_ids
|
||||
|
||||
def is_user_visible(self, room_id: str) -> bool:
|
||||
"""True if *room_id* is user-visible (routing + onboarding relevant).
|
||||
|
||||
Auto-Route User-Zugriff-Schutz (Phase 1/B): Räume mit
|
||||
``user_visible=False`` sind weder Routing-Ziel noch Onboarding-relevant.
|
||||
Unbekannte room_id → False (konservativ: nicht sichtbar).
|
||||
"""
|
||||
entry = self._rooms.get(room_id)
|
||||
if entry is None:
|
||||
return False
|
||||
return entry.user_visible
|
||||
|
||||
def get_room_by_id(self, room_id: str) -> Optional[RoomEntry]:
|
||||
"""Hole einen Raum anhand seiner ID.
|
||||
|
||||
@@ -717,6 +750,7 @@ class RoomMap:
|
||||
"keywords_context": room_entry.keywords_context,
|
||||
"catch_all": room_entry.catch_all,
|
||||
"active_status_indikator": room_entry.active_status_indikator,
|
||||
"user_visible": room_entry.user_visible,
|
||||
# V8.2.1 A3: Persistiere Tracking-Felder
|
||||
"_stay_counts": room_entry._stay_counts,
|
||||
"_keyword_last_matched": room_entry._keyword_last_matched,
|
||||
@@ -1135,6 +1169,7 @@ class RoomMap:
|
||||
keywords_context=keywords_context,
|
||||
catch_all=room_data.get("catch_all", False),
|
||||
active_status_indikator=room_data.get("active_status_indikator", True),
|
||||
user_visible=room_data.get("user_visible", True),
|
||||
)
|
||||
# V8.2.1 A3: Tracking-Felder aus JSON deserialisieren
|
||||
if "_stay_counts" in room_data:
|
||||
|
||||
Reference in New Issue
Block a user