The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): a live listing drops the batch of a profile parked during its off-loop read
Tekniumd2be5394dc63
diff --git a/gateway/session_live_listing.py b/gateway/session_live_listing.pyindex c474232daa3..2833d492e91 100644--- a/gateway/session_live_listing.py+++ b/gateway/session_live_listing.py@@ -95,6 +95,8 @@ async def live_entries(authority, actor) -> list[LiveEntry]:if not batch:continuerows, pending = await asyncio.to_thread(_store_facts, authority.db, batch)+ if authority.retiring or authority.retired:+ return [] # parked or unserved during the read: nothing here is this profile's to list any morefor sid in batch:live, row = authority.sessions.get(sid), rows.get(sid)if live is None or row is None:diff --git a/tests/gateway/test_authority_listing_loop_turns.py b/tests/gateway/test_authority_listing_loop_turns.pyindex 328f00fb9ea..dfbd8427278 100644--- a/tests/gateway/test_authority_listing_loop_turns.py+++ b/tests/gateway/test_authority_listing_loop_turns.py@@ -122,3 +122,20 @@ async def test_a_session_retired_during_the_read_is_not_listed_or_restored(ownermonkeypatch.setattr(session_live_listing, '_store_facts', retire_midway)ids = {row['id'] for row in await owner.listing('session.active_list')}assert gone not in ids and gone not in owner.authority.sessions+++async def test_a_profile_parked_during_the_off_loop_read_lists_nothing(owner, monkeypatch):+ """The store read is an await: a park (unserve) can retire the authority while it runs, and the+ batch read for it belongs to the home's next owner, not to this listing."""+ from gateway import session_live_listing+ real = session_live_listing._store_facts++ def parked_mid_read(db, batch):+ owner.authority.retiring = True+ return real(db, batch)++ monkeypatch.setattr(session_live_listing, '_store_facts', parked_mid_read)+ actor = SimpleNamespace(profile_id='live', subject='viewer', capabilities=frozenset({'session:read'}))+ monkeypatch.setattr(owner.authority, 'authorize', lambda *a: None)+ assert await session_live_listing.live_entries(owner.authority, actor) == []