Skip to content

feat: let Workflow code read a Stream - #2188

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

moetemp wants to merge 9 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

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

Why?

History keeps only a digest of each page, so it stays small, and a replay reads the Records from the Store again. This is the only Python PR that waits for Core #1819.

Reviewer's guide

Review after #2187.

  1. Check the Core pin and the 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 reads against temporalio/contrib/streams/README.md and the Worker tests. A replay needs the original Records to still be in the Store.
  4. Check the typed StreamRef conversion in temporalio/nexus/system/_support.py, including refs inside containers.

Checklist

  • Regenerate the read bindings at the new Core pin.
  • Run Python lint and the 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 2 times, most recently from eb1f457 to 99184e6 Compare December 4, 2026 00:26
@moetemp
moetemp force-pushed the moe/streams-workflow-reads branch from ad054d4 to c17931c Compare December 5, 2026 00:53
@moetemp
moetemp force-pushed the moe/streams-workflow-reads branch from c17931c to 0dc8c5b Compare December 5, 2026 06:52
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.
The bridge stubs take the new proto comments. No generated code changes.
Explain why a read marker keeps a digest rather than the Records, so a
replay reads the Store again and Stores must keep Records. Say why a
waiting read is capped and why type checks fail early. Only
docstrings, comments and the README change.
@moetemp
moetemp force-pushed the moe/streams-workflow-reads branch from 0dc8c5b to 9f16e81 Compare December 6, 2026 10:15

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