Repository navigation
reflex-workflow: give the wake-during-a-pass test a runtime of its own - #7385
Conversation
A pass that claimed nothing counted as caught up even while steps from the pass before it were still running. wake then returned True mid-step, and a host that suspends on that answer -- the reason wake holds the request open -- would cut the step off. It is also why test_wake_settles_once_the_worker_has_nothing_left_to_take flaked in CI: the pass after the claim settled before the step had committed. A pass is now counted only when no step is in flight. A finishing step already wakes the loop, so the pass after the last one is the one counted. The regression test holds a step open: wake must report False while it runs and True once it has committed. It fails without this change.
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.
Re-trigger cubic
|
A run started after a pass looked for work, but before the pass was counted, left wake returning True with that run still due. A pass during which the loop was woken is no longer counted: the loop looks again at once, and that pass is. The new test starts a run in that gap and fails without this change.
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
It ran its worker on the module's shared runtime, so a pass of the module's worker could clear the wake it was counting on and leave it waiting out a thirty-second poll. Run alongside the other wake tests on main it failed 2 times in 40; with its own runtime, 0 in 40.
Otherwise a failure there leaves the step blocked in a task the worker started, past the end of the test.
…nning-steps # Conflicts: # packages/reflex-workflow/README.md # packages/reflex-workflow/src/reflex_workflow/engine/runner.py # packages/reflex-workflow/src/reflex_workflow/engine/runtime.py # tests/units/reflex_workflow/engine/test_runner.py
* docs: add a Workflows section for reflex-workflow Thirteen pages under docs/workflows, grouped in the Backend sidebar: an overview, a tutorial, guides to defining workflows, steps, runs, events, schedules, fan-out, concurrency, workers and inspecting runs, an explanation of how the engine works and what it guarantees, and an API reference. Also fixes the package README's wake route, which used an app.api attribute Reflex does not have. * docs: qualify lease-bound claims and complete example imports * docs: retryable webhook response, precise cancel status, and what history records * docs: acknowledge webhooks only on known delivery, guard the cancel status, describe history as committed attempts * reflex-workflow: answer a message whose wake was refused while a held one ran A run holds one event at a time. When the conversation example's turn was running a held wake, a wake for a message that arrived after the turn read the transcript was refused, and nothing read that message until the four-hour reminder. That is what timed out test_a_burst_after_a_restart_is_answered_in_order in CI: a message landing while the previous reply step was still committing is held, and the next one can land in that gap. reply now reads the transcript again under the arrival lock before it waits, as remind already does, and takes another turn for anything new. A message that lands after that read finds the run still stepping, so its wake is held. The regression test drives the race deterministically: it fails on a thirty-second timeout before this change and passes in under a second after. * reflex-workflow: arm every conversation wait in one step that rereads first Checking for unread messages in reply was not enough. When reply found one it took another turn with the earlier wake still held, and the turn that finally ran that wake found nothing new and armed the wait directly: a message whose wake was refused while it ran then waited for the reminder. Every wait is now armed by settle, a step of its own that rereads the transcript under the arrival lock. reply and a turn with nothing new both go through it. The regression test now also drives a message into the turn that runs the stale wake, and fails without this change. The reminder race test waited on the status, which is set as soon as a wait is armed; it now waits until no wake is held and no step is running, since a held wake replaying through settle takes the lock the test holds. * docs: give Workflows its own top-level sidebar section Moved out of the State section, between State and Recipes as masenf suggested, with the guides grouped into Building and Running Workflows. Single pages are one-child groups, as elsewhere in the sidebar: the index that opens the active group counts top-level entries that way. * docs: keep inline code out of link text, which the docs site does not render * Revert "docs: keep inline code out of link text, which the docs site does not render" This reverts commit efcdd2e. * Name this PR's news fragments by its number * docs: wake also waits for the steps it started to finish Matches #7385. * Revert "reflex-workflow: arm every conversation wait in one step that rereads first" This reverts commit 47588c9. * Revert "reflex-workflow: answer a message whose wake was refused while a held one ran" This reverts commit 16cf37e. * docs(workflows): bring the Workflows docs up to date with main - Stop registering the workflow base with rx.ModelRegistry.register. Since #7797 a registered base turns off detection of the app's other DeclarativeBase bases, so reflex db makemigrations would write a revision dropping their tables. Explain detection, when registering is needed, and point MappedAsDataclass bases (the database docs' default) at reflex_workflow.dataclass. Same fix in the package README. - Describe the held event being released once a worker takes it (#7396). - Document OpenTelemetry tracing of step attempts (#7635). - Require Python 3.11 (#7449), spell Cron's default zone as UTC, say wake waits for the work to run (#7382), and import rx in the wake example. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01ESN8DiahHo8P4FLFNr6fHK * docs(workflows): say which bases Reflex detects, and why registering drops others Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01ESN8DiahHo8P4FLFNr6fHK * docs(reflex-workflow): rewrap the README's Reflex setup paragraph Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01ESN8DiahHo8P4FLFNr6fHK --------- Co-authored-by: Masen Furer <[email protected]> Co-authored-by: Claude <[email protected]>
Summary
The engine fix this PR started with (
wakewaiting for in-flight steps, and not counting a pass that was woken during it) landed separately in #7382 with the same condition, so after mergingmainthis PR keeps only the part #7382 doesn't have.test_a_wake_during_a_pass_is_not_lostran its worker on the module's shared runtime. A pass of the module's worker could clear the wake event this test's worker was counting on, leaving it to wait out a 30-second poll against a 5-second bound. It now builds aRuntimeof its own, like the other wake tests do throughonly_worker.Test plan
-k "wake or settle or idle"40 times before Fix wake to wait for inflight steps before returning #7382: the test failed 2 times in 40 onmain, 0 in 40 with its own runtime.main(with Fix wake to wait for inflight steps before returning #7382): 0 failures in 30 runs; fulltests/units/reflex_workflowpasses (1042).