Repository navigation
Conversation
…ssion channels WorkflowAdapter and DiscussionAdapter declare `turn_within` expectations, but `default_evaluators()` shipped no turn_within evaluator, so the sweeper silently skipped them (core.py `if evaluator is None: continue`) and a stalled workflow never auto-closed. The `warn` handler named on those manifests was also never registered. - Add TurnWithinEvaluator, anchored on the triggering envelope's created_at (falling back to channel created_at for the fresh-channel turn). - Add WarnHandler, posting EV_EXPECTATION_VIOLATED to the violator(s) only. - Pass the adapter's expected_next() into ExpectationContext.expected_turn. - Read adapter state and WAL under the same channel lock in _expectation_tick so a concurrent reply can't pair stale turn state with a fresh WAL. - Make violation dedup turn-aware (Violation.turn_key) so the same participant can fire on distinct turns while still deduping within one. The discussion `hide` handler remains unimplemented (documented as such) and is out of scope here.
This branch has not been deployed
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.
Why are these changes needed?
WorkflowAdapterandDiscussionAdapterdeclareturn_withinexpectations (e.g.turn_within(600s, auto_close)so a stalled workflow "fails fast"), butdefault_evaluators()shipped noturn_withinevaluator, anddefault_handlers()never registered thewarnhandler those manifests name. The expectation sweeper skips any expectation whose evaluator or handler is missing (if evaluator is None: continue/if handler is None: continue), soturn_withinwas silently never evaluated — a workflow whose expected next speaker never speaks stayedACTIVEforever instead of auto-closing.This PR:
TurnWithinEvaluator(anchored on the triggering envelope'screated_at, falling back to channelcreated_atfor the fresh-channel turn) and a targetedWarnHandler(postsEV_EXPECTATION_VIOLATEDto the violator(s) only), and registers both.expected_next()result intoExpectationContext.expected_turn._expectation_tick, so a concurrent reply can't pair stale turn state with a fresh WAL and falsely time out a participant who just spoke.Violation.turn_key) so the same participant can fire on distinct turns while still deduplicating within a single turn.Validation:
pytest test/network/— 589 passed;ruff checkon the touched files passes.Related issue number
Related issue: #3700
Checks
AI assistance