Skip to content

The agent that grows with you

fix(gateway): Graph admission reserves its route off the owner loop via the split helpers; deflake the drain-step test

Tekniume66fec2b7184
diff --git a/gateway/platforms/msgraph_webhook.py b/gateway/platforms/msgraph_webhook.py
index c7015f0a1d2..30c36e0e396 100644
--- a/gateway/platforms/msgraph_webhook.py
+++ b/gateway/platforms/msgraph_webhook.py
@@ -338,7 +338,7 @@ class MSGraphWebhookAdapter(BasePlatformAdapter):
if provenance is None:
raise RuntimeStoreError('permission_denied')
# The routing reservation writes too: off the owner loop like the admission below.
- ref = await asyncio.to_thread(authority.register, event.source)
+ ref = authority._publish_route(event.source, *await asyncio.to_thread(authority._reserve_route, event.source))
route = authority.sessions[ref.session_id].route
source = event.source.to_dict()
source['is_bot'] = event.source.is_bot
diff --git a/tests/gateway/test_settlement_lock_liveness.py b/tests/gateway/test_settlement_lock_liveness.py
index 4a5eadd68b4..1f9543fc32e 100644
--- a/tests/gateway/test_settlement_lock_liveness.py
+++ b/tests/gateway/test_settlement_lock_liveness.py
@@ -246,5 +246,8 @@ async def test_admission_schedules_its_drain_in_the_admitting_callers_step(tmp_p
await task
while mutation_tasks(authority):
await asyncio.sleep(0.01)
- await asyncio.sleep(0)
- assert order == ['schedule', 'drain']
+ # The commit's done-callback schedules the drain, and the drain task runs a step after
+ # that: wait for the observable, not for one particular tick.
+ async with asyncio.timeout(5):
+ while order != ['schedule', 'drain']:
+ await asyncio.sleep(0)