Skip to content

The agent that grows with you

fix(gateway): name a held compression lock on the busy refusal and read a null profile as this owner

yoniebans0374d0417622
diff --git a/gateway/session_busy_controls.py b/gateway/session_busy_controls.py
index e2ba88ec748..45e9778be5e 100644
--- a/gateway/session_busy_controls.py
+++ b/gateway/session_busy_controls.py
@@ -17,7 +17,8 @@ def handlers(connection):
def authorize(connection, ref, params, capability):
connection.authority.authorize(connection.actor, ref, capability)
- if 'profile' in params:
+ # The contract's ``profile`` is nullable; null means this owner, as an omitted key does.
+ if params.get('profile') is not None:
from hermes_cli.profiles import profile_matches_home
profile = params['profile']
if not isinstance(profile, str):
diff --git a/gateway/session_controls.py b/gateway/session_controls.py
index f7aad5bcfcb..239b682188d 100644
--- a/gateway/session_controls.py
+++ b/gateway/session_controls.py
@@ -724,8 +724,11 @@ class AuthorityConnection:
result = await mutate_session(self.authority, self.actor, ref, params)
except MUTATION_GUARD_REFUSALS as exc:
# A live turn lease / compression lock is the same retryable busy verdict a
- # running admission gets (REST maps it to 409), not an internal error.
- raise RuntimeStoreError('session_busy') from exc
+ # running admission gets (REST maps it to 409), not an internal error. A held
+ # compression lock is named: Stop does not end it, so clients say to wait instead.
+ from hermes_state_errors import SessionCompressionInProgressError
+ compressing = isinstance(exc, SessionCompressionInProgressError)
+ raise RuntimeStoreError('session_busy', field='compression' if compressing else None) from exc
except RuntimeStoreError as exc:
if exc.reason in {'revision_conflict', 'stale_generation'}:
# The fresh fences ride on the refusal, so the client retries once without a re-read.
diff --git a/gateway/session_tui_ops.py b/gateway/session_tui_ops.py
index 7750516049c..fe01a86cca1 100644
--- a/gateway/session_tui_ops.py
+++ b/gateway/session_tui_ops.py
@@ -119,8 +119,6 @@ async def export_session(connection, ref, params):
async def session_history(connection, ref, params):
"""Main's ``session.history``: the display transcript of the conversation's current physical row (compression tip or local receipt entry), ancestors included, each row with its durable ``row_id``; Desktop's edit resolves its turn by it."""
- # The contract's ``profile`` is nullable; null means this owner, as an omitted key does.
- params = {key: value for key, value in params.items() if not (key == 'profile' and value is None)}
_live_ref(connection, ref, params, {'session_id', 'profile'}, 'session:read')
authority = connection.authority
from gateway.session_local_recovery import transcript_target