Skip to content

chore: add the generated Stream API and binding helpers - #2128

Open
moetemp wants to merge 38 commits into
moe/activity-workflow-task-infofrom
moe/streams-generated-code
Open

moetemp wants to merge 38 commits into
moe/activity-workflow-task-infofrom
moe/streams-generated-code

Conversation

@moetemp

@moetemp moetemp commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

What was changed

This PR adds the generated Python Stream API and its binding helpers. The WIT and protobuf definitions come from API main. The Core pin is Core main with Core #1879, which vendors API main.

Why?

WorkflowProducer.workflow_task_id lets readers distinguish separate tasks from retries. Core sets the task identity and attempt when the Workflow appends. Local Activity bindings use the original scheduling task and Activity ID, which must remain stable across retries.

The pinned nexgen revision leaves scheduling to the underlying I/O. The generated create builds the Stream from the create result, so a create of an existing Stream gives created=False. It also generates a typed client hook for each Stream operation, so StartNexusOperationInput takes the types of its argument and result. That revision is on nexgen#457, which must merge first. _support.py also has signal_with_start_workflow_storage_target, which the SDK check of nexgen calls.

This layer includes the helper functions it calls, so it passes lint and import checks alone. #2186 and the PRs on it connect the API to Stores and Workers.

Reviewer's guide

Review after #2127.

  1. Start with scripts/gen_nexus_system_api.py, pyproject.toml and the Core pin. They must reproduce the generated files.
  2. Compare request types and resource methods with API #895. Check routing, opaque offsets and the create result.
  3. Read _support.py with the generated wrappers. Empty pages keep after_offset unchanged. Populated pages use the last Record. The runtime PR contains the replay tests.

Checklist

  • poe gen-protos reproduces the generated files with the pinned generator, and a second run leaves no diff.
  • poe lint passes.

@moetemp
moetemp added this pull request to stack #2130 November 14, 2026 01:00
@moetemp
moetemp removed this pull request from stack #2130 November 15, 2026 08:27
@moetemp
moetemp force-pushed the moe/streams-generated-code branch from 434ddd3 to d70f12d Compare November 15, 2026 18:51
@moetemp
moetemp force-pushed the moe/streams-generated-code branch from d70f12d to 6b44118 Compare November 15, 2026 20:23
@moetemp
moetemp force-pushed the moe/streams-generated-code branch from 6b44118 to f330b20 Compare November 16, 2026 17:14
@moetemp
moetemp force-pushed the moe/streams-generated-code branch from f330b20 to 31151f2 Compare November 16, 2026 17:33
@moetemp
moetemp force-pushed the moe/streams-generated-code branch from 31151f2 to e8898ec Compare November 16, 2026 19:42
@moetemp
moetemp added this pull request to stack #2139 November 18, 2026 01:19
@moetemp
moetemp removed this pull request from stack #2139 November 22, 2026 21:24
@moetemp
moetemp added this pull request to stack #2156 November 22, 2026 21:24
@moetemp
moetemp force-pushed the moe/streams-generated-code branch from 293528d to 94fe3ec Compare November 23, 2026 21:22
@moetemp
moetemp force-pushed the moe/streams-generated-code branch from 94fe3ec to 932cbca Compare November 23, 2026 22:34
@moetemp moetemp added the skip-changelog PR changes do not require changelog updates label Nov 25, 2026
These are the files that `poe gen-protos` writes for the Stream service. They are in a PR of
their own, so that the hand-written change shows alone.
…eam.

The new Stream WIT gives the Workflow target `append` and `close`, so the generated Workflow `Stream` has them and `async with` closes it.
With nexgen commit 07b565b6, `read` yields Records, `read_pages` yields pages and `read_page`
sends one request. `PollIterator` moves to one `_poll.py` next to the models. The Workflow
interceptor terminal calls `_schedule_system_nexus_operation` and drops the generic hook, as
upstream nexgen does.
The API changes `epoch` to `attempt`, gives the Workflow `Stream` a read, passes the client to the default Producer of a client Stream, and drops `namespace` from the requests. This commit follows `temporalio/api` `7964b905` with nexgen 0.2.13.
The API takes a Stream id in each request and a request id on an append, and nexgen maps the ref of a request to its id with two helpers.
The API gives each kind of Producer a namespace and its own ids, and the Producer has no id string.
The API states the rules of a Store as the Stores keep them. Only docs change.
@moetemp moetemp changed the title chore: add the generated code of the Streams API Generate the Python Stream API Nov 27, 2026
@moetemp moetemp changed the title Generate the Python Stream API Add the generated Stream API and binding helpers Nov 28, 2026
@moetemp
moetemp removed this pull request from stack #2156 December 1, 2026 20:16
@moetemp moetemp changed the title Add the generated Stream API and binding helpers chore: add the generated Stream API and binding helpers Dec 2, 2026
Client interceptors need a typed hook for each Stream operation, so that
a Stream call of a client can skip 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.
nexgen's copy of the workflow service WIT names this helper as the
storage target of signal-with-start, and its SDK check runs against this
repository. The WIT of this repository doesn't name it, so no generated
code here calls it.
@moetemp
moetemp force-pushed the moe/streams-generated-code branch from 75cdfad to a5779b7 Compare December 2, 2026 08:37
moetemp added a commit to temporalio/sdk-rust that referenced this pull request Dec 2, 2026
## What was changed

Update the API subtree to temporalio/api@59be8f7. It brings in three API PRs:

- temporalio/api#934 drops the Python output transform of the Stream create.
- temporalio/api#925 adds `notification_triggered_heartbeat` to `RespondWorkflowTaskCompletedRequest`. Core sets it to false, since Core does not send a heartbeat for a Workflow Heartbeat Notification.
- temporalio/api#919 makes the base of the `buf breaking` check configurable.

## Why?

The Python SDK generates its Stream API from the WIT in this subtree. Without the transform, the generated create builds the Stream from the create result, so a create of an existing Stream gives `created=False`. Consumed by temporalio/sdk-python#2128. The Stream PRs of Core ([#1801](#1801) and the PRs on it) are based on this one.
Pin Core to the vendored API `main` and the generator to `4bf951e9`. API
`main` drops the Python output transform of the Stream create, so the
generated create builds the Stream from the create result. A create of
an existing Stream gives `created=False`. `stream_from_create` in
`_support.py` has no caller and goes.

The Core pin also brings the other API changes of Core `main`. The
`source_context` of `OnCompleteRequest` is optional, and the callback
tests check that it is set before they read it. The signal-with-start
operation names its storage target, so the generated registry now uses
`signal_with_start_workflow_storage_target`. A test covers each.
@moetemp
moetemp force-pushed the moe/streams-generated-code branch from 1090467 to 2208e72 Compare December 2, 2026 22:30
@moetemp moetemp mentioned this pull request Dec 2, 2026
2 tasks done
@moetemp
moetemp added this pull request to stack #2189 December 2, 2026 22:49
@moetemp
moetemp marked this pull request as ready for review December 2, 2026 22:59
@moetemp
moetemp requested a review from a team as a code owner December 2, 2026 22:59
@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

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

skip-changelog PR changes do not require changelog updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants