fix: remove unsound structured-output Tapioca compiler - #405
Conversation
OkTest Summary🟡 Running for Ruby SDK PR #405. SDK merge (pending) · head ( |
HAYDEN-OAI
left a comment
There was a problem hiding this comment.
Reviewed the compiler rollback, transport-model compatibility, structured-output hydration, and optional Sorbet boundary. Looks good.
HAYDEN-OAI
left a comment
There was a problem hiding this comment.
Approved after reviewing all six changed files and the coordinated Castiron generator removal. The unreleased compiler can be removed without breaking published APIs; direct model construction and assignment still preserve caller-owned raw values, while both Chat Completions and Responses hydrate nested structured outputs. Nullable-array Sorbet types, optional sorbet-runtime, and Rails/Tapioca loader behavior remain intact.
Summary
OpenAI::BaseModelTapioca DSL compiler, its compiler-specific README section, and the compiler-only tests.sorbet-runtimeremains optional for normal SDK usage.Why this is the correct architectural rollback
#364 addressed the customer report in #309 by adding a compiler that generated readers such as
ParticipantandT::Array[Participant]. Those signatures are unsound for the SDK's supported transport-model contract:Parsed API responses correctly hydrate those same fields into application-defined model objects. The original compiler test only type-checked synthetic RBI usage; it never compared generated reader signatures with direct model construction, assignment, or both public parsed-response boundaries. The proposed runtime workaround in #385 introduced additional coercion and conflicting accessor/storage semantics instead of addressing the incorrect abstraction.
Architecture review concluded that SDK transport models should remain permissive transport models. Sound application-owned typed structured outputs should instead be designed at the structured-output integration boundary. #309 has therefore been reopened and rewritten around the original customer outcome rather than the rejected implementation.
The removed compiler has not appeared in a released gem, so removing it now avoids publishing an unsound API contract. The actual live Castiron generator also emitted this compiler; its coordinated upstream removal is https://github.com/openai/openai/pull/1291001.
Why retain the other #364 changes
lib/openai.rbloader detection independently fixes Rails/Tapioca load order and retains its existing regression coverage.ArrayOf#to_sorbet_typecorrectly preserves nullable array elements independently of the deleted compiler; the new isolated subprocess test preserves coverage without making Sorbet a runtime dependency.OpenAI::BaseModeltests cover both individual nested fields and nested arrays.Validation
bundle exec rake lint: 2,618 RuboCop files clean, Sorbet clean, 1,212 RBS files valid.bundle exec rake build:gem; inspected the built gem to verify it contains no Tapioca compiler and does not addsorbet-runtimeas a runtime dependency.Related customer issue: #309. Do not auto-close it: the underlying typed structured-output design remains open.