From 6d98728a2eb1146d3fb907fb188584a1d2fabefc Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sun, 26 Apr 2026 17:40:46 -0400 Subject: [PATCH] chore: remove defensive stale-guest degrade in turns.py (T74.4) T44 carried a defensive degrade-to-1:1 block in post_turn for the case where chat.guest_bot_id pointed at a deleted bot. T47 then fixed the root cause by adding a bot_reset cascade that clears guest_bot_id from any chat that referenced the deleted bot, so the post_turn defensive block was rendered dead. Remove the orphan-clear branch and replace it with a comment documenting that get_bot now returns a real row when guest_bot_id is non-None. The cascade behavior is pinned by test_reset_clears_guest_reference_in_other_chats in tests/test_reset.py. --- chat/web/turns.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/chat/web/turns.py b/chat/web/turns.py index 48882f0..b3a4f0e 100644 --- a/chat/web/turns.py +++ b/chat/web/turns.py @@ -236,11 +236,12 @@ async def post_turn( guest_bot = None guest_bot_id = chat.get("guest_bot_id") if guest_bot_id is not None: + # T47's bot_reset cascade clears guest_bot_id from any chat that + # referenced the deleted bot, so by the time we read it here it's + # either None or a live bot id. The previous defensive + # degrade-to-1:1 block (T44) was rendered dead by T47 and removed + # in T74.4 — get_bot now returns a real row. guest_bot = get_bot(conn, guest_bot_id) - # If the chat references a deleted guest we degrade to single-bot - # rather than 404 — the chat is still usable as a 1:1. - if guest_bot is None: - guest_bot_id = None settings = request.app.state.settings