Repository navigation
Read the WorkerReplayClock entry carrier in replay_now() - #380
Merged
Merged
Conversation
ctx.replay_now() now returns the run's canonical start at ordinary workflow entry when the workflow task carries a valid replay_clock object (WorkerReplayClock v1, server#1156). The carrier must name the task's run, use strict six-digit UTC and agree with the history's start kind; a redrive anchor that history already proves is never replaced. Tasks without a carrier keep entry unavailable and ctx.now() keeps its fixed start. Refs durable-workflow/.github#215 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #380: a body that reads replay_now() at entry must rebuild with the same entry value for updates. apply_update, query_state and validate_update (and the worker paths that call them), replay_history and Replayer.replay now accept the task's replay_clock object. Query tasks and pre-accept validation don't receive one from Server yet, so those rebuilds fail visibly; the docs now say so. The carrier key set must be exact, a non-string source counts as absent, and an unproved redrive start's own replayed_started_at must agree with the carrier. Refs durable-workflow/.github#215 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The worker calls _prepare_query_state and _prepare_update_validation, so the public query_state and validate_update don't need the carrier. A present but unreadable replayed_started_at now refuses the carrier, the entry pattern is ASCII-only, and the docs name proof-less starts and the in-memory environment among the unavailable cases. Refs durable-workflow/.github#215 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Member
Author
|
Independent review: PASS at
All 21 checks pass (4 intended skips), including SonarCloud. The regression fixture A further gap (tolerant bodies in carrier-less query rebuilds) is handled in #382. 🤖 Generated with Claude Code |
This was referenced Nov 26, 2026
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
ctx.replay_now()now has a value at ordinary workflow entry, before any durable step. It reads the workflow task'sreplay_clockcarrier (WorkerReplayClockv1), which Server has sent since 3.6.0 (durable-workflow/server#1156). This is the Python slice of durable-workflow/.github#215.Rules
The SDK accepts the carrier only if every one of these holds:
schema == "durable-workflow.worker-replay-clock/v1";workflow_run_idequals the task'srun_id, and is not empty;started_atis strict UTC with six fractional digits andZ, and is a real instant;sourceagrees with the history's own start kind:run_started_atfor an ordinary, continued or child run,redrive_replayed_started_atwhen the history declares a redrive.Anything else counts as absent, and no other time is substituted. A redrive anchor that history already proves is never replaced. The carrier sets only the entry value; every existing boundary, group and unavailability rule is unchanged after the first consumed step. Query, update and other reconstruction-only paths don't receive a carrier and stay unavailable.
Compatibility: tasks without the carrier behave exactly as before, and
ctx.now()still returns the fixed start time.Evidence
tests/test_business_replay_clock_entry.pycovers:business-clock-ordinary-entry-carrierruns a realWorker._run_workflow_taskon two leases. It fails on base:clock[0]isNone. It passes here.pytest tests/ -m "not integration"(7972 passed, 3 skipped),ruff check,mypy src/durable_workflow/, andvalidate-regression-corpus.py --base-ref origin/mainall pass.Docs: the
replay_now()docstring, the SDK reference's new "Advancing replay clock" section and CHANGELOG (Unreleased).Refs durable-workflow/.github#215
🤖 Generated with Claude Code