Skip to content

The agent that grows with you

Merge simp/r3-37 (late tail) into hermes/simplify-codebase

Teknium93cf6b3dce67
diff --cc tui_gateway/session_lifecycle.py
index a3cb1b24d3b,6951a71309c..0868b05d499
--- a/tui_gateway/session_lifecycle.py
+++ b/tui_gateway/session_lifecycle.py
@@@ -83,18 -82,10 +82,17 @@@ def _release_active_session_slot(sessio
return True
+def _own_live_lease_ids(*, exclude=None) -> set[str]:
+ """Snapshot leases still backed by this process's live session records."""
+ with _sessions_lock:
+ return {str(lease.lease_id) for session in _sessions.values()
+ if (lease := session.get("active_session_lease")) is not None and lease is not exclude}
+
+
@contextlib.contextmanager
def _other_runtime_lease_guard(session_id: str, session: dict):
- """Release this runtime and lock sibling ownership through the DB write. Yields True (another runtime
- owns the lifecycle -> preserve) when the guard cannot be loaded or entered after 3 tries: an unknown
- ownership state must never end a row."""
+ """Release this runtime and lock sibling ownership through the DB write. Yields True (another runtime owns
+ the lifecycle -> preserve) when the guard can't be loaded/entered in 3 tries: unknown ownership never ends a row."""
lease = session.get("active_session_lease")
try:
from hermes_cli.active_sessions import active_session_liveness_guard, release_active_session_liveness_guard