Skip to content

feat: publish RBS and RBI types with Gem#410

Open
chris-olszewski wants to merge 60 commits into
mainfrom
olszewski/feat_publish_types
Open

feat: publish RBS and RBI types with Gem#410
chris-olszewski wants to merge 60 commits into
mainfrom
olszewski/feat_publish_types

Conversation

@chris-olszewski

@chris-olszewski chris-olszewski commented Apr 6, 2026

Copy link
Copy Markdown
Member

What was changed

Include RBS types in published Gem along with newly added RBI types.

RBS

The codebase is already type checked with RBS, we just never included these type definitions as part of the gem. We now include these in the gem with experimental support.

RBI

These are net new, initially generated with Tapioca, narrowed via Claude/myself, and validated using srb tc and enabling sobet-runtime in our tests.

SigApplicator

To better verify that the RBI is correct, we run our tests with each method with sorbet-runtime signatures generated from our RBI files. Currently this added check is only enabled on for the ubuntu-latest test runs. These will also be released as experimental.

We cannot apply this to every class as some:

  • Would require generic which we cannot easily declare without altering runtime behavior e.g. Temporalio::Workflow::Future
  • We intentionally avoid following the type definition e.g. base constructor for interceptors

Using SigApplicator is controlled by the TEMPORAL_SORBET_RUNTIME_CHECK environment variable.

We did have to update some tests where we intentionally pass in mistyped data.

Review Guidelines

I would focus highly on the SigApplicator module as this is our primary tool for verifying our RBI file. Any changes to Ruby files should be reviewed as these are the more impactful.

Looking at the RBI definitions for Workflow and Activities are worthwhile, but we rely on the tests to validate correctness for the majority of these new type signatures.

Why?

Community ask

Checklist

  1. Closes [Feature Request] Publish RBI types #412

  2. How was this tested:
    See RBI section above.

  3. Any docs updates needed?
    Updated README, further docs will be updated as we move this out of experimental.

@chris-olszewski chris-olszewski force-pushed the olszewski/feat_publish_types branch from 5e70a0f to 68ce2da Compare April 7, 2026 01:05
@chris-olszewski chris-olszewski marked this pull request as ready for review April 7, 2026 01:19
@chris-olszewski chris-olszewski requested a review from a team as a code owner April 7, 2026 01:19

@jazev-stripe jazev-stripe left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really promising, and I think would already be pretty useful to us. The approach of applying the runtime checks during tests is new to me--seems quite cool!

I left a few comments; we also have a thread in the shared Stripe <> Temporal Slack channel (#support-stripe-temporal) about this.

Comment thread temporalio/extra/sorbet_check/check_types.rb Outdated
Comment thread README.md Outdated
Comment thread temporalio/sig/temporalio/error.rbs
Comment thread temporalio/rbi/temporalio.rbi Outdated
Comment thread temporalio/rbi/temporalio.rbi Outdated
Comment thread temporalio/rbi/temporalio.rbi Outdated
Comment thread temporalio/rbi/temporalio.rbi

@jez jez left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jazev-stripe mentioned that you might want some feedback on this approach, don't mean to intrude, very excited to see this in any form it takes, it's extremely cool!

Comment thread temporalio/test/support/sig_applicator.rb Outdated
Comment thread temporalio/test/support/sig_applicator.rb Outdated
Comment thread temporalio/test/support/sig_applicator.rb Outdated
@chris-olszewski chris-olszewski force-pushed the olszewski/feat_publish_types branch from 68ce2da to 76e1c77 Compare April 10, 2026 00:18
@chris-olszewski chris-olszewski force-pushed the olszewski/feat_publish_types branch from 76e1c77 to cd3758a Compare May 29, 2026 14:59
@chris-olszewski chris-olszewski marked this pull request as draft June 2, 2026 16:45
@chris-olszewski chris-olszewski force-pushed the olszewski/feat_publish_types branch from db4afac to e6cc2f5 Compare June 9, 2026 12:35

# @see ActivityExecutor.initialize_activity
def execute_activity(_defn, &)
def execute_activity(defn, &) # rubocop:disable Lint/UnusedMethodArgument

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorbet cares about argument names so it is better to suppress the unused method lint explicitly instead of using _


# @see ActivityExecutor.execute_activity
def execute_activity(_defn, &)
def execute_activity(defn, &) # rubocop:disable Lint/UnusedMethodArgument

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorbet cares about argument names so it is better to suppress the unused method lint explicitly instead of using _

@chris-olszewski chris-olszewski marked this pull request as ready for review June 9, 2026 12:53
chris-olszewski and others added 17 commits June 9, 2026 10:52
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Generated via `tapioca gem temporalio` against SDK v1.3.0.
This file is used by CI to detect when the public API surface
changes and the enriched RBI needs updating. It is not shipped
to users.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Hand-maintained RBI file with typed sig blocks covering the full
public API surface (~8,250 lines). Types are derived from the
existing RBS signatures in sig/. Internal APIs are excluded.

Also adds rbi/temporalio.rbi to the gemspec so it ships with the gem.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Move tapioca baseline from rbi/ to extra/ to prevent Sorbet from
  loading it alongside the enriched RBI via path: gem references
- Fix parameter ordering in list_workflow_page sig
- Fix Future Elem type_member variance (remove :out since result=
  uses it as input)
- Replace T.nilable(T.untyped) with T.untyped
- Fix unresolved bare Worker:: references to use full qualification

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
These classes inherit from ::Mutex, ::Queue, ::SizedQueue respectively.
Without the inheritance, methods like `synchronize` are not available
to Sorbet users.

Found while porting message_passing_simple sample to Sorbet.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Custom PayloadCodec implementations reference these protobuf types
directly. Without stubs, Sorbet cannot resolve them.

Found while porting encryption sample to Sorbet.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds extra/sorbet_check/ — a self-contained Sorbet project that
validates the enriched RBI against realistic SDK usage patterns
(activities, workflows, client, worker, codecs, errors, cancellation,
search attributes, mutex). Runs `srb tc` on the checkTarget CI matrix.

Also removes the tapioca baseline (extra/tapioca_baseline/) — the
Sorbet type check provides better validation than diffing tapioca
output, which is fragile across tapioca versions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds a "Maintaining Type Signatures" section under Development with
instructions on keeping RBS and RBI in sync, type mapping reference,
and guidance on what to include/exclude from the RBI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@chris-olszewski chris-olszewski force-pushed the olszewski/feat_publish_types branch from 5f0f624 to 4c21098 Compare June 9, 2026 15:15
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.

[Feature Request] Publish RBI types

3 participants