Skip to content

Let input received before the deadline satisfy a condition wait with a timeout #230

Done

Description

@rmcdaniel

Problem

A condition wait with a timeout can report "timed out" even though the input that satisfied it arrived before the deadline. This happens whenever the workflow task that would evaluate the condition runs after the deadline, for example during a worker outage or backlog. An approval sent in time is then treated as expired.

So the outcome depends on worker timing and on which API the workflow used. Each outcome is recorded, so replay stays stable, but the result isn't predictable.

Source-verified, not reproduced.

Acceptance criteria

  • In every runtime, a condition wait with a timeout returns true when the signals and updates received before the timeout fired make the condition true. This holds even if the workflow task runs after the deadline.
  • Standalone condition waits, conditions inside select and named signal waits follow one documented tie-break rule.
  • Runs that already recorded an outcome replay it unchanged.
  • Tests deliver a satisfying signal before the deadline and run the workflow task after the timeout fired, in embedded PHP and each service SDK.
  • The signal and timer guide states the rule.

Ordering decision and next implementation

General selects durable input order as the tie-break contract. Worker execution time and equal wall-clock timestamps do not decide the result. This extends the existing named-signal ordering rule to unresolved standalone and grouped conditions.

  1. A previously committed wait outcome replays unchanged. An explicit satisfied/timed-out outcome, including its historical equivalent, takes precedence over reevaluating the predicate. Preserve subsequent recorded commands and results as well.
  2. For an unresolved wait, use its exact original run, logical wait and timeout identity. The matching durable TimerFired record bounds eligible input. Signals or accepted updates ordered before that record are eligible; input ordered after it cannot rescue the wait. Equal timestamps use canonical history/command order. Do not compare with the replacement worker's clock or move the original timer deadline.
  3. Replay eligible input effects in their durable order and resolve at the first eligible prefix that makes the predicate true. Later input cannot reverse that selected result. Rejected updates do not contribute state. An update receipt alone is not a satisfied predicate: bind the actual acknowledged handler effects to that original input identity/order, even when handler execution is delayed. Do not substitute another run, timeout or recorded wait outcome. Valid workflow state established before this wait remains part of its initial predicate evaluation; ordinary state and input consumption are not reset.
  4. Standalone conditions, conditions in select and named-signal waits use this same ordering boundary. Do not fix standalone waits by evaluating a predicate over all later state before inspecting the timeout.
  5. Runtime/SDK owners must demonstrate how their existing receipt, applied-input and recorded-outcome representations enforce this rule and preserve historical replay. A new representation, if actually needed, must have a compatibility boundary before adoption. No global reinterpretation of old histories or current timer qualification is selected by this decision.

The original acceptance criteria remain unchanged. These are the minimum counterexample/control expectations, not executed results:

Durable order for the same original wait Expected unresolved result
predicate is already true on entry, including a zero-second timeout true
open → qualifying input → timeout fire; workflow task executes after both true
open → timeout fire → otherwise qualifying input false
input and timeout have equal timestamps earlier canonical record wins
qualifying true prefix → later nonqualifying input → timeout fire selected true remains true
previously recorded false/true result, under changed later state or code original result and subsequent commands unchanged

Workflow owns the embedded counterexample and implementation. Server reviews the receipt/fire/command mapping; each SDK owner implements and tests its replay surface. They arrange direct peer reviews and normal qualification within existing authority. General owns the cross-runtime decision and final acceptance, without adding a routine per-PR approval gate. Existing explicit execution stops remain in force.

Workflow 2.29.1 shipped the embedded rule from Workflow #1193. The portable service implementation and its corresponding guide work remain open.

Native service counterexample on November 23. The checksum-verified Server CI binary matches the integrated source tree from Server #1314. The worker used the exact PHP SDK 3.28.0 prepublication archive at d39947c500434ed86310500ec3484167525c47b6. An isolated SQLite Server recorded the input and fired the original timer before a replacement worker polled. All three workflows completed.

Case SignalReceived sequences TimerFired sequence Expected result Actual result
Satisfying signal before the fire 5 6 true false
Satisfying signal after the fire 6 5 false false
True prefix followed by a false signal before the fire 5, 6 7 true false

SignalApplied followed the fire in each case. The early receipts are present in history, so the service change must preserve their original positions when the replacement worker evaluates the marked wait. The late receipt remains a negative control. A second run on the same tuple used a timed condition inside select() with an unserviced child in the other branch. It reproduced the same three results. The selected branch recorded SelectionResolved immediately after TimerFired, before applying any signal. The native selection path therefore also needs the marked condition's evaluated outcome before committing its winner. The published Rust SDK 4.22.1 reproduced the same three standalone results from its verified crate 18b82e152036daffd47602bee7a6eb26eeecdbed35b8ba6f014e6245155acf8b. Its timed condition returned false for the early approval and for the early true prefix, even though both prefix inputs applied later. The late approval remained false. Recorded outcome replay and the completed service implementation still need qualification. Rust SDK 4.22.1 Server fixture CI Exact PHP SDK source

Accepted update counterexample. The same native CI binary ran the published Python SDK 2.22.1 wheel with verified SHA-256 5a92725eb257bc7b265d98ca7106bac4036c52c71ffea208b444e1f3143d1ac5. The first Worker kept its update contract registered and parked before its next poll. A replacement Worker performed the update and wait replay after the original timer fired.

Case UpdateAccepted sequences TimerFired sequence UpdateApplied sequences Expected Actual
Handler sets approval after an early acceptance 5 6 7 true false
Approval accepted after the fire 6 5 none false false
Approval and withdrawal accepted before the fire 5, 6 7 8 true false
Early accepted call fails in the handler 5 6 none false false

The first case proves that a successfully applied handler can arrive too late in replay even though Server accepted the update in time. In the third case only the approval applied, and the run closed before the withdrawal applied. The failed handler produced no applied marker. Match the handler's applied effect to the original acceptance when evaluating the eligible prefix. Published Python SDK 2.22.1

Native outcome prototype. A local native branch kept the original timer and deferred selection until the worker recorded an evaluated outcome for the opted-in wait. SQLite, PostgreSQL, MySQL and MariaDB passed 29 focused tests each. They cover early signal delivery after the timer, refusing a premature timeout while eligible inputs remain pending, rejecting a late or missing receipt, atomic application of a successful early update, and excluding failed handlers. The same suite verifies that an older worker can still run existing waits, cannot activate this mode, and cannot claim a run with marked history after the wait resolves. The prototype publishes the earliest unsettled receipt on a capable worker’s task and wakes a still-open condition when the final input settles. Mixed Server versions, full SDK coverage and selection with a competing completed branch remain open.

Rust worker prototype. A replacement Rust worker on the local Native branch passed eight service cases after the original timer fired. It returned true for an early signal, kept the first true prefix after an early withdrawal, returned false for late input and two early false inputs, and preserved the matching condition outcome in a selection with a parked child. A successfully applied early update could satisfy the condition. A failed update left no applied event and the condition timed out. All eight histories recorded exactly one final condition result. Fifteen Rust condition tests and two downstream public task model checks passed. The Server and SDK changes are local and unreleased.

Cross-SDK qualification on the local Server prototype. On the same Server build, 24 real worker cases passed after the parent worker held delivery through the original timer. Rust passed eight cases, Python ten and PHP six. Each SDK covered standalone waits and the supported select() shape with a parked child. Rust and Python covered successfully applied and failed updates as well as signals. PHP covered early and late signals and kept the first qualifying prefix after a withdrawal. The Python start-before-worker-registration case additionally verified that Server uses the contract bound by the first completing worker when the original start event lacks signal declarations. The final Server build passed 29 focused tests on each of SQLite, PostgreSQL, MySQL and MariaDB. The local Python candidate passed 154 focused tests, and PHP passed 183 tests on its supported PHPUnit 11.

Competing child completion and failure. On the first prototype, Server accepted approval at sequence 7, the child reached a terminal event at 8 and Server committed the child winner at 9 before the original timer fired at 10. The corrected local Server retains the child's exact terminal event while a replacement worker evaluates the condition over the earlier receipts. It commits the condition when that prefix satisfies it, or the child when its terminal event came first. A child that wins can still unblock before the original condition timer fires. Previously committed winners replay unchanged.

PHP, Python and Rust each passed five competing-child worker cases covering completion and failure, both orderings and a false input before the child followed by a true input after it. Python additionally passed three update cases covering a qualifying applied update before the child, a later update and an earlier update whose handler failed. A Server restart between recording the failed child's event and starting the replacement PHP worker preserved the candidate and returned the earlier approval. The final Server branch passed 30 focused tests on each of SQLite, PostgreSQL, MySQL and MariaDB. The service changes are under review and remain unreleased.

Mixed-version rollout counterexample. A new Server opened a marked selection and accepted a qualifying signal at sequence 7. With the parent worker parked, the published Server 3.26.0 took over maintenance on the same disposable database. It fired the timer at sequence 8 and committed that timer as the selection winner at sequence 9. Worker routing alone cannot protect marked history from an older Server. Qualify activation and rollback so every Server that can process the database understands marked history before any worker opens a marked wait. Published service qualification remains open.

Staged rollout qualified locally. The Server exposes replay support separately from permission to author an ordered wait on a particular workflow lease. Authoring is off by default. The same claim keeps its original permission across retries. Previously marked waits remain replayable after disabling new authoring. All 31 focused Server tests passed on SQLite, PostgreSQL, MySQL and MariaDB.

In the staged run, published Server 3.26.0 and the compatible Server shared the database while authoring was disabled. An updated PHP worker wrote a legacy wait and replayed its timer winner. After removing the predecessor, the compatible Server opened a marked wait. Disabling authoring and replacing the Server again preserved the early approval and kept the next new wait unmarked. PHP, Python and Rust each passed five competing-child cases with authoring enabled. Rust also passed both orderings against a two-child group. PHP, Python and Rust SDK source merged after hosted CI passed. Native Server merged after the protected queue passed its checks. Server #1316 PHP SDK #475 Python SDK #375 Rust SDK #316

Installed release candidates. The PHP 3.29.0 Composer candidate passed all five competing-child cases with the Server candidate. A fresh install identified itself as durable-workflow-php/3.29.0 in worker registration and repeated the staged rollout and rollback on the same database. The Python 2.23.0 wheel from the build-only workflow passed five competing-child and three update cases against the Server candidate. It also replayed the legacy timeout without marked history against published Server 3.26.0. The verified Python promotion archive contains the same wheel bytes. Native Server 3.27.0 published the same index in both registries at sha256:fbc88e1b42cf8fa8d5dd080d60a509c69e533b7fcca243f06544352d79978a47. Both architecture builds and scans passed. The exact-image corpus and four Compose cells passed. Both registries promoted latest, 3 and 3.27 to that index, and the stable GitHub Release is live. A fresh Packagist install of PHP SDK 3.29.0 matched the release commit and repeated all five ordering cases and the staged rollout and rollback against that index. Native Server 3.27.0 Rolling alias proof PHP SDK 3.29.0 The exact Python wheel repeated its eight ordering cases against the same index. Python submitted the exact distributions for independent review. The exact Rust 4.24.0 crate passed the installed lifecycle and deadline cells and 15 timed-condition cases against that same published Server index. Its descriptor and summary are submitted for independent review. Python and Rust publication remain open. Rust package review Native release run Compose qualification Native corpus Python package review Rust release prep Server release prep PHP release prep Python build

The embedded Signal + Timer guide now states the released Laravel ordering rule, with the same text updated in all seven translations. The Pages deployment succeeded and the new text is live. Documentation #604

The live service-mode guide documents the timer boundary, competing child outcomes and the rollout requirement for Native Server 3.27.0 and PHP SDK 3.29.0. Deployment passed, and the live cross-link, timed-condition section and release links were verified in all eight locales. Service guide Documentation #605

Activity

  1. added
    bug
    kind:defect
    kind:cross-repository
    priority:P2
    on Oct 21, 2026
  2. rmcdaniel commented on Nov 4, 2026

    @rmcdaniel
    MemberAuthor

    General open-item pass, November 4. Owner: Workflow and Server for durable ordering semantics; SDK owners for replay; General for product decision.

    Next action: Return a counterexample and explicit event-time/deadline ordering decision where qualifying input arrived before timeout but evaluation ran later.

    Action taken in this pass: Asked both runtime owners to map existing condition-timeout work and the remaining standalone/grouped cases; current timeout-source integration is not blanket acceptance of this requirement.

    General retains the cross-repository follow-through. Existing operator stops and exact source/release/production gates remain binding; the item stays open until its actual acceptance is evidenced.

  3. rmcdaniel commented on Nov 4, 2026

    @rmcdaniel
    MemberAuthor

    Workflow owns the embedded ordering contract and counterexample; Server and SDK owners own the equivalent portable resolution. The narrow next source control is a qualifying signal/update committed before the original timeout boundary, with actual workflow evaluation delayed until afterward, comparing standalone condition, grouped condition and named signal wait.

    Preserve already recorded decisions. A new evaluation must use the eligible committed input prefix and deterministic event ordering, not today's predicate over unrelated later state. Exact tie behavior for equal timestamps must bind canonical history/command order and be reviewed by General/Server. I have kept this separate from Core #890 (accepted update delivery before successful closure), #1021/#1024 stream replay, and #863 opt-in deadline cleanup. No current timer helper proves the whole accepted rule or authorizes a global replay change. Return a small fail-before/source contract before new representation or runtime qualification.

  4. rmcdaniel commented on Nov 11, 2026

    @rmcdaniel
    MemberAuthor

    Workflow: open, not started. Embedded standalone condition waits still let a fired timeout win before input received earlier. Next: one tie-break rule for standalone, select and named-signal waits, with a counterexample test. Owner: workflow.

  5. rmcdaniel commented on Nov 11, 2026

    @rmcdaniel
    MemberAuthor

    Server: nothing needed; the outcome is decided in the SDK/Core replay rule. Server will review once the tie-break contract is posted. Owner: Workflow.

  6. rmcdaniel commented on Nov 11, 2026

    @rmcdaniel
    MemberAuthor

    PHP: same timeout-wins behavior as embedded PHP and Python today (a condition_timeout fire resolves the wait false). Will follow Workflow's tie-break rule once it is posted. Owner: workflow, then sdk-php.

  7. rmcdaniel commented on Nov 18, 2026

    @rmcdaniel
    MemberAuthor

    Embedded engine fixed: workflow#1193 merged as 44f86b08, shipping in Workflow 2.29.1 (the release is in progress). Condition waits with a timeout now resolve by durable input order: updates accepted before the wait's own timeout TimerFired can satisfy it, the first true wins, and later input can't reverse it. Recorded ConditionWaitSatisfied/ConditionWaitTimedOut outcomes replay unchanged; 2.29.0 records a timeout before acting on it. The release also fixes a 2.29.0 select() + condition-timeout replay stall.

    Remaining for this issue:

    1. Native Server: in service mode, a bare TimerFired is the only timeout record. Add an additive per-wait ordering marker (for example on open_condition_wait / ConditionWaitOpened); waits opened without it keep the old rule. Expose UpdateAccepted/SignalReceived order relative to TimerFired to workers.
    2. Python, PHP and Rust SDKs: for marked waits, replay inputs recorded before the condition-timeout TimerFired in order and stop at the first true. Unmarked waits keep today's behavior.
    3. Docs: docs/features/signal+timer.md states the rule, in all 7 translations with source hashes.
  8. rmcdaniel commented on Nov 25, 2026

    @rmcdaniel
    MemberAuthor

    Verified complete against the current releases. Closing as completed.

    Turning ordered authoring on by default in Server or in Cloud would be a separate, finite change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugkind:cross-repositorykind:defectpriority:P2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions