feat: context aware replay status#488
Open
wangyb-A wants to merge 3 commits into
Open
Conversation
zhongkechen
reviewed
Jun 24, 2026
zhongkechen
reviewed
Jun 24, 2026
|
|
||
| @contextmanager | ||
| def _replay_aware(self): | ||
| def _replay_aware(self, *, executes_user_code: bool = False): |
Contributor
There was a problem hiding this comment.
is this true for context operations?
| # - user-code op that is non-terminal (brand-new or retrying): the user | ||
| # function is about to run real work, so flip to NEW before it. | ||
| if was_replaying and ( | ||
| not next_exists or (executes_user_code and not next_terminal) |
Contributor
There was a problem hiding this comment.
why don't we always flip before the op?
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.
Issue #, if available: first piece of #389
Summary
Track replay status per-context instead of as a single execution-wide flag.
Changes
context.py:DurableContextowns its replay status, seeded from itscreator and refined per-operation via a
_replay_aware()context manager.Added public
context.is_replaying().logger.py:Loggerconsults a per-contextis_replayingcallableinstead of holding
ExecutionState.state.py: removed the global replay machinery (track_replay,is_replaying,_visited_operations); addedhas_prior_operations()forexecution-level first-invocation detection.
execution.py: seeds the root context's status; useshas_prior_operations()for the pluginis_first_invocationflag.concurrency/executor.py: branches track their own status; removed theper-branch
track_replaycall.Replay boundary behavior
_replay_aware()flips REPLAY→NEW at three points:immediately after a
waitare treated as new, not suppressed).The third case fixes a regression where a log right after a
waitwassilently dropped on replay.
Testing
Logging from examples:
Invocation 1 (requestId 8b1e9590) — first run, suspends at parent wait
Invocation 2 (requestId a46ca6bd) — parent wait fired
Invocation 3 (requestId 22d99bc2) — child wait fired
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.