This commit is contained in:
Greer Guthrie 2026-04-24 16:32:43 -05:00 committed by GitHub
commit 078246766f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View file

@ -73,6 +73,7 @@ def _clear_approval_state():
mod._gateway_queues.clear()
mod._gateway_notify_cbs.clear()
mod._session_approved.clear()
mod._session_yolo.clear()
mod._permanent_approved.clear()
mod._pending.clear()

View file

@ -310,6 +310,24 @@ def approve_session(session_key: str, pattern_key: str):
_session_approved.setdefault(session_key, set()).add(pattern_key)
def clear_session(session_key: str) -> None:
"""Clear all in-memory approval state for a session key.
Safe to call even when the session has no tracked approval state.
Any blocked gateway approvals for the session are unblocked.
"""
if not session_key:
return
with _lock:
_pending.pop(session_key, None)
_session_approved.pop(session_key, None)
_session_yolo.discard(session_key)
_gateway_notify_cbs.pop(session_key, None)
entries = _gateway_queues.pop(session_key, [])
for entry in entries:
entry.event.set()
def enable_session_yolo(session_key: str) -> None:
"""Enable YOLO bypass for a single session key."""
if not session_key: