fix(gateway): salvage stale-output/typing interrupt handling#12494
Merged
Conversation
Follow-up on top of the helix4u #12388 cherry-picks: - make deferred post-delivery callbacks generation-aware end-to-end so stale runs cannot clear callbacks registered by a fresher run for the same session - bind callback ownership to the active session event at run start and snapshot that generation inside base adapter processing so later event mutation cannot retarget cleanup - pass run_generation through proxy mode and drop stale proxy streams / final results the same way local runs are dropped - centralize stop/new interrupt cleanup into one helper and replace the open-coded branches with shared logic - unify internal control interrupt reason strings via shared constants - remove the return from base.py's finally block so cleanup no longer swallows cancellation/exception flow - add focused regressions for generation forwarding, proxy stale suppression, and newer-callback preservation This addresses all review findings from the initial #12388 review while keeping the fix scoped to stale-output/typing-loop interrupt handling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/stopor/newWhat this fixes
This PR hardens the gateway interrupt path so old runs cannot keep leaking output after they are invalidated:
Current-main follow-up fixes included
On top of the original PR, this salvage fixes the review findings:
run_generationand drops stale proxy streams/final results tooreturnfromBasePlatformAdapter._process_message_background()'sfinallyblock so cleanup no longer swallows cancellation/exception flowFiles changed
gateway/platforms/base.pygateway/run.pytests/gateway/test_pending_event_none.pytests/gateway/test_run_progress_topics.pytests/gateway/test_session_race_guard.pytests/gateway/test_status_command.pytests/gateway/test_proxy_mode.pyVerification
Focused gateway suite:
scripts/run_tests.sh tests/gateway/test_base_topic_sessions.py tests/gateway/test_run_progress_topics.py tests/gateway/test_session_race_guard.py tests/gateway/test_pending_event_none.py tests/gateway/test_status_command.py tests/gateway/test_plan_command.py tests/gateway/test_proxy_mode.py -q81 passedSyntax/smoke:
py_compile gateway/run.pypy_compile gateway/platforms/base.pypy_compile tests/gateway/test_status_command.pypy_compile tests/gateway/test_proxy_mode.pyContributor credit
This PR cherry-picks helix4u's original commits from #12388 so rebase-merge preserves their authorship in git history.