Skip to content

[Brook] Declared the Stream handle as a WIT resource with methods. - #32

Closed
moetemp wants to merge 6 commits into
moe/brook/v4/s15-wit-docs-and-no-intervalfrom
moe/brook/v4/s16-stream-resource
Closed

moetemp wants to merge 6 commits into
moe/brook/v4/s15-wit-docs-and-no-intervalfrom
moe/brook/v4/s16-stream-resource

Conversation

@moetemp

@moetemp moetemp commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

What changed?

This PR declares the Stream handle in crates/streams/nexus/stream-service.wit as a WIT resource with methods.

resource stream is built from its stream-ref (constructor(stream: stream-ref)), so the ref stays the handle's serialized form. It has four methods: append-records, close, read-records and describe. Each takes its request without the stream field, and names its operation with @nexus.operation "<operation>", so nexgen fills in the ref from the handle. create-stream returns create-stream-result, a record mapped to CreateStreamResponse that holds own<stream> with created and status, since the facade needs status. The single stream field binds by name to the stream field of each request and of the create response. The handle and its methods carry @nexus.doc lines.

The Stream service proto gets the standard API language options (go_package, csharp_namespace and the others), so nexgen can map its wire types in Go and .NET. The proto messages, the @nexus.proto mappings and the operation names on the wire are unchanged, so the server and the crate don't change. tests/wit.rs checks the resource and its bindings.

Why?

Decision S84: Tim asked in the 2026-10-21 meeting that stream_handle.publish come from a resource in the IDL, not from hand-written sugar. With moetemp/nexgen#45, the generated Python is a Stream class with append_records, close, read_records, iter_read_records and describe, and create_stream returns a Stream.

With moetemp/nexgen#45, the long poll on read-records also gives iter_read_records, an async iterator over the Records (decision S85, no WIT stream<T>). The handle stays an immutable identity value (decision S86). moetemp/nexgen#45 gives the reasons for both.

Open for Tim: none left here. The create result, the docs, reads (S85) and handle state (S86) are settled, and moetemp/nexgen#45 gives the reasons.

How did you test it?

cargo test --test wit in crates/streams, and cargo fmt --all --check. The sdk-python Stream bindings generated from this WIT with moetemp/nexgen#45 pass pyright with 0 errors.

git fetch origin moe/brook/v4/s16-stream-resource && git checkout FETCH_HEAD
cd crates/streams && cargo test --test wit

Stacked on #31 (moe/brook/v4/s15-wit-docs-and-no-interval).

@moetemp

moetemp commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

Closing as stale. This layer is folded into the v5 tip, #41, and the upstream review uses a fresh series instead. Plan: https://www.notion.so/4048fc567738814990b7c796ac28fe3f

@moetemp moetemp closed this Oct 25, 2026
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