[codex] Reproduce reused-sleep replay divergence in core runtime#2169
Draft
pranaygp wants to merge 4 commits into
Draft
[codex] Reproduce reused-sleep replay divergence in core runtime#2169pranaygp wants to merge 4 commits into
pranaygp wants to merge 4 commits into
Conversation
|
Contributor
Contributor
🧪 E2E Test Results❌ Some tests failed Summary
❌ Failed Tests▲ Vercel Production (1 failed)example (1 failed):
🌍 Community Worlds (69 failed)mongodb-dev (1 failed):
redis-dev (1 failed):
turso-dev (1 failed):
turso (66 failed):
Details by Category❌ ▲ Vercel Production
✅ 💻 Local Development
✅ 📦 Local Production
✅ 🐘 Local Postgres
❌ 🌍 Community Worlds
✅ 📋 Other
❌ Some E2E test jobs failed:
Check the workflow run for details. |
| expect(result).toEqual(['first', 'second']); | ||
| }); | ||
|
|
||
| it('should let a queued hook payload win when a reused wait completes after the step that installs the race', async () => { |
Contributor
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.
What this proves
This adds core-runtime regression and discriminator tests for the observed
Promise.race([iterator.next(), reused sleep])divergence. The tests drivesetupWorkflowContext()with explicitly ordered in-memory event histories, so they do not involve DynamoDB, Postgres,world-local, a Vercel deployment, or network timing.The original ordered durable history is:
That history records the hook branch having won: the durable next operation is
drainStep. Currentstablereplay instead follows the sleep branch and attempts to consumesyncNextStep, reporting the same path-divergence corruption observed in hosted runs.Early waiter across a drain
The hosted repro was subsequently changed to install
iterator.next()beforesyncStatusSurfaceLikeStep, matching this PR's original positive control. That narrows the original boundary, but it is not a complete workaround when the loop reuses its sleep.This PR now includes a two-iteration history matching the remaining window:
There are two order-controlled tests for that history:
drainStepbranch and passes.wait_completedis delivered first, the recorded next operation isprogressStep, but currentstablereplay consumes the hook branch and attemptsdrainStep.The failing error is:
This reproduces the failure direction seen in
wrun_01KSV07R3NQ9C26F4E0D0RTA8Sfrom a complete, ordered in-memory event history. Movingiterator.next()before the progress step cannot cover the interval while the previous hook-winningdrainStepis awaited.Expected failing validation
The targeted suite deterministically fails in both synchronous and asynchronous deserialization modes. This PR is intentionally test-only and expected to be red: its purpose is to preserve the minimal runtime-only reproductions while the fix is developed.
Promise-shape discriminator
For the original one-race history, both the mapped race
and raw
Promise.race([iterator.next(), pendingSleep])fail with the samedrainStepversussyncNextStepdivergence. Installing the iterator read beforesetupStepmakes that original history pass.The new two-iteration test demonstrates why that source-level adjustment does not resolve the overall bug: after the first hook value is consumed, no next iterator read is pending while the hook-side drain step is awaited. Reused sleep completion and buffered hook delivery can still be consumed into a trajectory different from the recorded next operation.
Relationship to the candidate fix
#2048 repairs the original single-iteration waiter-installation reproduction. I also applied the new two-iteration drain-window test to its current candidate commit (
6164a6dd9) locally: the hook-first control passes, but the wait-first case still fails in both deserialization modes with the sameprogressStepversusdrainStepcorruption. The new test therefore captures a remaining runtime boundary not covered by that candidate repair.