The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: reject fresh session registration while gateway drains
Tekniuma67637cc973a
diff --git a/gateway/session_authority.py b/gateway/session_authority.pyindex 3321c1aab6b..51a8964d414 100644--- a/gateway/session_authority.py+++ b/gateway/session_authority.py@@ -60,6 +60,7 @@ class SessionAuthority:raise RuntimeStoreError('runtime_draining')def register(self, source):+ self._require_admission_open()entry = self.runner.session_store.get_or_create_session(source)sid = entry.session_idself.sessions.setdefault(sid, LiveSession(source, entry.session_key))diff --git a/tests/gateway/fixtures/local_session_peer.py b/tests/gateway/fixtures/local_session_peer.pyindex 206ccd510c9..1495b5ea083 100644--- a/tests/gateway/fixtures/local_session_peer.py+++ b/tests/gateway/fixtures/local_session_peer.py@@ -51,6 +51,14 @@ async def probe(peer, target, kind):{'profile': 'foreign'}, {'cwd': str(target)}, {'yolo': True}):denied = await rpc(a, 'session.create', **payload)assert 'error' in denied, denied+ before_sessions = set(authority.sessions)+ runner._draining = True+ try:+ draining = await rpc(a, 'session.create', request_id='during-drain', source='cli')+ assert draining.get('error', {}).get('message') == 'runtime_draining', draining+ assert set(authority.sessions) == before_sessions+ finally:+ runner._draining = Falsecreated = await rpc(a, 'session.create', request_id='fresh', source='cli')assert 'result' in created, createdsid = created['result']['session_id']diff --git a/website/docs/developer-guide/gateway-internals.md b/website/docs/developer-guide/gateway-internals.mdindex aaaaa749d36..cba294c43a7 100644--- a/website/docs/developer-guide/gateway-internals.md+++ b/website/docs/developer-guide/gateway-internals.md@@ -40,7 +40,8 @@ The session handle in `session.resume` supplies the current revision.The edit and its retry receipt commit together. Repeating the same request returnsthe original result without incrementing the revision again; reusing its ID withdifferent contents returns `admission_conflict`. A competing edit with a stale-revision returns `revision_conflict`. Draining rejects new mutations. These edits+revision returns `revision_conflict`. Draining rejects new mutations and fresh+session registration before routing or transcript creation. These editsdo not interrupt a running turn. This RPC does not yet migrate legacy directwriters, expose arbitrary SQL, or implement reset, delete, or rewind.