Repository navigation
Intercept Stream client calls by operation - #2180
Draft
tconley1428 wants to merge 13 commits into
Draft
tconley1428 wants to merge 13 commits into
tconley1428 wants to merge 13 commits into
Conversation
tconley1428
force-pushed
the
tconley/stream-client-interceptors
branch
from
December 1, 2026 17:35
66c3418 to
6e0f0ea
Compare
moetemp
force-pushed
the
moe/streams-api
branch
3 times, most recently
from
December 2, 2026 03:42
214106d to
02d8ff0
Compare
This Core has the Workflow commands and activation jobs of Stream appends and reads. A codec gets each Stream body alone and with no serialization context, and the passes of external storage skip Stream bodies, since any writer can make a body.
A Store is the service that keeps the Records of a Stream. The contract says what client, Activity and Workflow calls need from a Store, and `StreamConfig` registers the Stores of a client and its Workers.
Tests and local runs need a Store with no other service. The memory Store keeps its Streams in plain Python data and applies the rules of `StreamStore` in their order, so it also shows what a Store does.
An Activity that appends each model token pays one Store call for each token. The appender batches them with one write in flight, and stops at the first failed batch so that a reader sees no gap. `current_producer` and `as_producer` let resumed Activity work write as its first Producer.
The client passes each Stream call of the generated API through the typed interceptor hooks that nexgen generates, to the Store that its ref or the selector picks, with the codec and a request id that retries keep. It checks each request with the rules of SDK Core and the limits of the Stream config, so that client and Workflow calls refuse the same requests. An Activity writes as the Producer of its schedule, from the info that Core gives.
Workflow code can't call a Store itself, since a replay must get the same answers. Core runs each append on the Python Store through the bridge and records its result in History, and a create or a describe runs in a Local Activity of the SDK. In this commit a Workflow read reaches that Local Activity, which refuses it, so the Workflow Task fails.
A Stream create or describe runs as a Local Activity, and a Workflow Task that waits for one can complete with no command. Chunking merges such tasks in a replay, so Workflow code can get a result in another activation than in the first run. Core records the choice in the first completed Workflow Task, so a Workflow that started earlier keeps it.
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.
moetemp
force-pushed
the
moe/streams-api
branch
from
December 2, 2026 06:02
02d8ff0 to
7258a4d
Compare
Client interceptors need a typed hook for each Stream operation, since a Stream call of a client doesn't go through the generic Nexus chain. The hooks type `StartNexusOperationInput` by its argument and result. The generator is pinned to a nexgen commit that is not on main yet.
`datetime.fromtimestamp(0)` reads the local time zone, so on a host west of UTC the default times of `ActivityEnvironment` fall before 1970. SDK Core and the client both refuse a Stream append whose Producer has an attempt time before 1970.
moetemp
force-pushed
the
moe/streams-api
branch
from
December 2, 2026 07:28
7258a4d to
c15c1d4
Compare
moetemp
force-pushed
the
tconley/stream-client-interceptors
branch
from
December 2, 2026 07:43
6e0f0ea to
aa4068a
Compare
moetemp
force-pushed
the
moe/streams-api
branch
from
December 2, 2026 08:37
c15c1d4 to
bd9eca2
Compare
This branch has not been deployed
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.
Wire generated operation-specific Stream start hooks into client outbound interception, accepting typed Nexus input envelopes and returning operation handles while bypassing generic Nexus start/result hooks. Keep request IDs, result types, and all call options on the original envelope; default type arguments preserve existing unparameterized input annotations.
Cover envelope identity and options, client/Activity Store routing, handle-based response overrides, short-circuiting, unknown operations, and retries after lost Store responses.
Stacked on #2129. Paired with temporalio/nexgen#457; the generation script pins its generator commit, and the nexgen draft pins this SDK revision for runtime validation.