diff --git a/chat/services/regenerate.py b/chat/services/regenerate.py index 020f57d..5e39b5c 100644 --- a/chat/services/regenerate.py +++ b/chat/services/regenerate.py @@ -686,23 +686,28 @@ async def regenerate_assistant_turn( (new_assistant_event_id, original_interjection_event_id), ) - # 10. Event-lifecycle detection (Phase 3, T61). Mirrors the post_turn - # block: classify whether any active events transitioned in the - # regenerated narrative and append the corresponding event_started / + # 9a. Event-lifecycle detection (Phase 3, T61). T83.5 cosmetic + # ordering: mirrors ``chat.web.turns.post_turn``'s 8a block — runs + # AFTER the interjection branch (and AFTER the post-interjection + # state-update + memory passes) so the classifier sees the same + # narrative-text input post_turn does. Numbering uses ``9a`` to + # match post_turn's ``8a`` shape (the interjection branch is step 9 + # in regenerate vs step 8 in post_turn; lifecycle is the immediate + # follow-on in both). Behaviour identical to the prior ``step 10`` + # placement — the block was already structurally last in regenerate + # because there's no scene-close pass here. + # + # Classify whether any active events transitioned in the regenerated + # narrative and append the corresponding event_started / # event_completed / event_cancelled. ``promote_completed_event`` # runs inline after a completion so promotion artifacts land in the # same regenerate path. # - # Phase 3.5 follow-up: when a regenerate replaces a turn that had - # already produced event transitions, those original transitions are - # NOT undone here. The superseded ``assistant_turn`` group keeps its - # prior ``event_started`` / ``event_completed`` events in the log - # (they remain projected onto the events table). Phase 3.5 will add - # an "undo lifecycle" step to roll back the prior transitions before - # re-classifying the regenerated text. For v3 we accept that a - # regenerate-after-completion will double-emit promotion artifacts - # if the new text re-completes the same event — narratively rare, - # and a true fix needs the lifecycle-undo pass. + # T83.4 follow-up: when a regenerate replaces a turn that had + # already produced event transitions, those original transitions + # are NOT undone here (Phase 4 work). A WARNING log earlier in this + # function names the affected event_log ids — see the T83.4 block + # near the function entry. new_active_events = list_active_events(conn, chat_id) if new_active_events: lifecycle_decision = await detect_event_transitions(