fix(orchestration): graceful drain on channel close, max_parallel drift, toposort 3-4x#2263
Merged
fix(orchestration): graceful drain on channel close, max_parallel drift, toposort 3-4x#2263
Conversation
This was
linked to
issues
Mar 27, 2026
64ec1f9 to
7fe929a
Compare
3189bcc to
6b77ad6
Compare
… drift, reduce toposort passes Fixes #2246, #2237, #2236. - #2246: DagScheduler now drains buffered task-completion events before calling cancel_all() on channel close, preventing in-flight tasks from being silently counted as "did not run". Shutdown status is now channel-type-aware: supports_exit()=true (CLI/TUI) -> Canceled; supports_exit()=false (Telegram/Discord/Slack) -> Failed so users can /plan retry after reconnect. - #2237: Extract compute_max_parallel(topology, base) as a single canonical method on TopologyClassifier. DagScheduler stores config_max_parallel (immutable config value) and uses it as the base in both analyze() and the tick() dirty-reanalysis path. After topology assignment in tick(), self.max_parallel is explicitly synced to self.topology.max_parallel, closing the drift bug. - #2236: Add classify_with_depths(graph, longest_path, depths) that accepts pre-computed toposort values. analyze() and tick() call it with values from a single compute_longest_path_and_depths pass, reducing toposort work from 3-4x to 1x per analysis. New tests: 8 topology unit tests, 2 scheduler regression tests, 3 agent-loop shutdown-path tests (including stale COV-04 replacement).
6b77ad6 to
d571264
Compare
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
tick()now drains buffered task-completion events beforecancel_all(), preventing in-flight tasks from being counted as "did not run". Channel-close status is now type-aware: CLI/TUI →Canceled, server channels (Telegram/Discord/Slack) →Failedso/plan retryremains available.max_paralleldrift across replan cycles — extractedcompute_max_parallel(topology, base)as a canonical method;DagSchedulerstoresconfig_max_parallel(immutable) and explicitly syncsself.max_parallel = self.topology.max_parallelafter topology assignment.TopologyClassifier::analyze()calledcompute_longest_path_and_depths3-4x per analysis — newclassify_with_depths(graph, longest_path, depths)accepts pre-computed values;analyze()and thetick()dirty path each call toposort exactly once.Test plan
cargo nextest run --config-file .github/nextest.toml -p zeph-orchestration --lib --bins— 251 tests passcargo nextest run --config-file .github/nextest.toml -p zeph-core --lib --bins— 1157 tests pass (includes 3 new shutdown-path tests replacing stale COV-04)classify_with_depths_matches_classify_for_all_variants, 6compute_max_parallel_*,config_max_parallel_initialized_from_config,max_parallel_does_not_drift_across_inject_tick_cycles,scheduler_loop_channel_close_supports_exit_returns_canceled,scheduler_loop_channel_close_no_exit_support_returns_failed,scheduler_loop_channel_close_drain_captures_completionCloses #2246, #2237, #2236