Skip to content

feat: let Workflow code read a Stream - #2188

Draft
moetemp wants to merge 19 commits into
moe/streams-workflow-appendsfrom
moe/streams-workflow-reads
Draft

moetemp wants to merge 19 commits into
moe/streams-workflow-appendsfrom
moe/streams-workflow-reads

Conversation

@moetemp

@moetemp moetemp commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What was changed

This PR lets Workflow code read a Stream, and a StreamRef[T] decodes in a dataclass, a list and an optional. The Core pin moves to the head of Core #1819, with the read protos regenerated.

Why?

A replay reads the Records again from the Store, so History stays small. This is the only Python PR that waits for Core #1819.

Reviewer's guide

Review after #2187.

  1. Check the Core pin and regenerated read protos against Core #1819.
  2. Read the read path in temporalio/worker/_workflow_streams.py and the Worker's stream_read_time setting.
  3. Check replay and waiting-read behavior against temporalio/contrib/streams/README.md and the worker tests. Replay still needs the original Records in the Store.
  4. Check typed StreamRef conversion in temporalio/nexus/system/_support.py, including references inside containers.

Checklist

  • Regenerate the read bindings at the updated Core pin.
  • Run Python lint and focused Stream tests.

@moetemp
moetemp added this pull request to stack #2189 December 2, 2026 22:49
@moetemp
moetemp force-pushed the moe/streams-workflow-reads branch 2 times, most recently from 8a09e49 to b5dd883 Compare December 2, 2026 23:14
@moetemp
moetemp force-pushed the moe/streams-workflow-reads branch from b5dd883 to 7d0638b Compare December 2, 2026 23:24
@moetemp
moetemp force-pushed the moe/streams-workflow-reads branch from 7d0638b to 9af7a99 Compare December 3, 2026 08:49
@moetemp
moetemp removed this pull request from stack #2189 December 3, 2026 09:00
@moetemp
moetemp added this pull request to stack #2202 December 3, 2026 09:00
@moetemp
moetemp force-pushed the moe/streams-workflow-reads branch 2 times, most recently from 9729789 to 7a7f865 Compare December 3, 2026 10:04
@moetemp
moetemp force-pushed the moe/streams-workflow-reads branch from 7a7f865 to a8fe761 Compare December 3, 2026 10:14
@moetemp
moetemp force-pushed the moe/streams-workflow-reads branch from a8fe761 to ce52d9d Compare December 3, 2026 16:59
@moetemp
moetemp force-pushed the moe/streams-workflow-reads branch from ce52d9d to 40fb5b6 Compare December 3, 2026 18:10
@moetemp
moetemp force-pushed the moe/streams-workflow-reads branch from 40fb5b6 to f76e72b Compare December 3, 2026 22:18
@moetemp
moetemp force-pushed the moe/streams-workflow-reads branch from f76e72b to eb1f457 Compare December 3, 2026 23:44
Core runs each read and records the offset, the count and the digest of
its page, so a replay reads the Records from the Store again and checks
them. `stream_read_time` bounds how long reads keep a Workflow Task
open, and `StreamReplayError` lets a Workflow fail when Records changed.
A ref in Workflow or Activity input must keep its body type, since a
read converts each body to it. Only `StreamRef` takes the two new
decoding paths, since a change for any other type would alter the
replay of existing Workflow Histories.
The docstring says the same in plainer words. No code changes.
@moetemp
moetemp force-pushed the moe/streams-workflow-reads branch from eb1f457 to 99184e6 Compare December 4, 2026 00:26
# Conflicts:
#	temporalio/bridge/sdk-core
The bridge stubs take the new proto comments. No generated code changes.
# Conflicts:
#	temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.pyi
#	temporalio/bridge/sdk-core

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant