feat(go): expand generated SDK completeness - #4147
Conversation
…e-pass-2 # Conflicts: # baml_language/crates/baml_project/src/client_codegen.rs # baml_language/crates/bex_engine/src/conversion.rs # baml_language/crates/bex_engine/tests/host_value_callable.rs # baml_language/crates/bex_external_types/src/host_return.rs # baml_language/crates/bex_external_types/src/lib.rs # baml_language/crates/bridge_cffi/src/ffi/host_value.rs # baml_language/crates/bridge_ctypes/README.md # baml_language/crates/bridge_ctypes/src/error.rs # baml_language/crates/bridge_ctypes/src/ty_decode.rs # baml_language/crates/bridge_ctypes/src/value_decode.rs # baml_language/crates/bridge_ctypes/src/value_encode.rs # baml_language/crates/bridge_ctypes/types/baml_bridge/cffi/v1/baml_inbound.proto # baml_language/crates/bridge_ctypes/types/baml_bridge/cffi/v1/baml_outbound.proto # baml_language/crates/bridge_ctypes/types/baml_bridge/cffi/v1/baml_type.proto # baml_language/sdks/cpp/bridge_cpp/pb/baml_bridge/cffi/v1/baml_inbound.pb.cc # baml_language/sdks/cpp/bridge_cpp/pb/baml_bridge/cffi/v1/baml_outbound.pb.cc # baml_language/sdks/cpp/bridge_cpp/pb/baml_bridge/cffi/v1/baml_outbound.pb.h # baml_language/sdks/go/baml_go/class.go # baml_language/sdks/go/baml_go/internal/cffi/baml_inbound.pb.go # baml_language/sdks/go/baml_go/internal/cffi/baml_outbound.pb.go # baml_language/sdks/go/bridge_go/cffi/proto/baml_bridge/cffi/v1/baml_inbound.pb.go # baml_language/sdks/go/bridge_go/cffi/proto/baml_bridge/cffi/v1/baml_outbound.pb.go # baml_language/sdks/go/bridge_go/cffi/proto/baml_bridge/cffi/v1/baml_type.pb.go # baml_language/sdks/python/src/baml_bridge/cffi/v1/baml_inbound_pb2.py # baml_language/sdks/python/src/baml_bridge/cffi/v1/baml_inbound_pb2.pyi # baml_language/sdks/python/src/baml_bridge/cffi/v1/baml_outbound_pb2.py # baml_language/sdks/python/src/baml_bridge/cffi/v1/baml_outbound_pb2.pyi # baml_language/sdks/rust/bridge_rust/src/baml_value.rs # baml_language/sdks/rust/bridge_rust/src/wire/baml_bridge.cffi.v1.rs # baml_language/sdks/typescript/bridge_typescript/dist/proto/baml_cffi.d.ts # baml_language/sdks/typescript/bridge_typescript/dist/proto/baml_cffi.js # baml_language/sdks/typescript/bridge_typescript/typescript_src/proto/baml_cffi.d.ts # baml_language/sdks/typescript/bridge_typescript/typescript_src/proto/baml_cffi.js # typescript2/pkg-proto/src/encode.ts
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughThis PR adds Go union-arity configuration, projection-aware generation, generic and dynamic runtime support, transactional generated-output installation, C# migration to the shared writer, and extensive cross-SDK fixtures and tests. ChangesGo SDK generation and runtime
Shared generated-output writer
Other SDK adjustments
Estimated code review effort: 5 (Critical) | ~180 minutes Sequence Diagram(s)sequenceDiagram
participant Runtime as BAML Runtime
participant Go as Go SDK
participant Callable as HostCallableFunc
Runtime->>Go: Dispatch host-call payload
Go->>Go: Validate and decode arguments
Go->>Callable: Invoke callback
Callable-->>Go: Return result or error
Go->>Runtime: Complete host call
sequenceDiagram
participant Generator as SDK Generator
participant Writer as write_generated_output
participant Target as Output Directory
Generator->>Writer: GeneratedOutputFile list
Writer->>Writer: Validate and stage output
Writer->>Target: Install generated tree
Writer-->>Generator: OutputWriterReport
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
⏭️ Performance benchmarks were skippedPerf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to To run them on this PR, do any of the following, then push a commit (or re-run CI):
|
Binary size checks passed✅ 7 passed
Generated by |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
baml_language/sdk_tests/harness_setup/src/lib.rs (1)
242-251: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd unit tests for the new harness filesystem-traversal logic. Both sites add new recursive/selective filesystem logic to
.rsfiles without a dedicated Rust unit test, which the repo's coding guidelines prefer over relying solely on the downstream integration tests to catch regressions.
baml_language/sdk_tests/harness_setup/src/lib.rs#L242-L251: add a unit test forcopy_customizable's new directory-recursion branch (e.g., build a small nested tempdir tree and assert the copied tree matches).baml_language/sdk_tests/harness_setup/src/go.rs#L131-L146: add a unit test forstage_output's selective cleanup, asserting.baml/targetentries survive while everything else undergenerated/is removed.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@baml_language/sdk_tests/harness_setup/src/lib.rs` around lines 242 - 251, The new filesystem traversal logic lacks dedicated Rust unit coverage. In baml_language/sdk_tests/harness_setup/src/lib.rs:242-251, add a unit test for copy_customizable that creates a nested temporary directory tree and verifies the recursive copy preserves it; in baml_language/sdk_tests/harness_setup/src/go.rs:131-146, add a unit test for stage_output that verifies .baml and target entries remain while all other generated/ contents are removed.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@baml_language/sdk_tests/crates/go/src/lib.rs`:
- Around line 60-71: Update collect_go_files to return immediately when
fs::read_dir reports a NotFound error for the requested directory, treating the
missing generated/baml_sdk fixture as empty. Preserve the existing panic
behavior for other read_dir errors and directory-entry failures, so the final
checked > 0 assertion handles fixtures with no collected Go files.
In
`@baml_language/sdk_tests/fixtures/type_shapes/baml_src/ns_go_codegen/ns_rust_type_edges/types.baml`:
- Around line 10-36: Update every function parameter declaration in
make_opaque_response, read_opaque_response, round_trip_opaque_response,
round_trip_optional_opaque_response, round_trip_opaque_responses,
round_trip_opaque_response_map, and round_trip_response_envelope to use
colon-separated name: Type syntax, preserving the existing parameter names and
types.
---
Nitpick comments:
In `@baml_language/sdk_tests/harness_setup/src/lib.rs`:
- Around line 242-251: The new filesystem traversal logic lacks dedicated Rust
unit coverage. In baml_language/sdk_tests/harness_setup/src/lib.rs:242-251, add
a unit test for copy_customizable that creates a nested temporary directory tree
and verifies the recursive copy preserves it; in
baml_language/sdk_tests/harness_setup/src/go.rs:131-146, add a unit test for
stage_output that verifies .baml and target entries remain while all other
generated/ contents are removed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f859af7a-f955-4063-9416-cb3a3f6f43de
📒 Files selected for processing (97)
baml_language/crates/baml_cli/src/generate.rsbaml_language/crates/baml_cli/src/init_command.rsbaml_language/crates/baml_cli/src/manifest.rsbaml_language/sdk_tests/crates/go/docstrings_etc/.gitignorebaml_language/sdk_tests/crates/go/docstrings_etc/customizable/go_codegen_edges_test.gobaml_language/sdk_tests/crates/go/docstrings_etc/customizable/test_main_test.gobaml_language/sdk_tests/crates/go/function_calls/customizable/go_codegen_edges_test.gobaml_language/sdk_tests/crates/go/function_calls/customizable/main_test.gobaml_language/sdk_tests/crates/go/function_calls/customizable/test_cancellation_test.gobaml_language/sdk_tests/crates/go/function_calls/customizable/test_errors_test.gobaml_language/sdk_tests/crates/go/function_calls/customizable/test_generics_test.gobaml_language/sdk_tests/crates/go/function_calls/customizable/test_host_callables_test.gobaml_language/sdk_tests/crates/go/function_calls/customizable/test_json_test.gobaml_language/sdk_tests/crates/go/function_calls/customizable/test_main_test.gobaml_language/sdk_tests/crates/go/function_calls/customizable/test_methods_on_classes_test.gobaml_language/sdk_tests/crates/go/function_calls/customizable/test_optional_args_test.gobaml_language/sdk_tests/crates/go/function_calls/customizable/test_reflected_type_test.gobaml_language/sdk_tests/crates/go/function_calls/customizable/test_static_methods_test.gobaml_language/sdk_tests/crates/go/function_calls/customizable/test_time_values_test.gobaml_language/sdk_tests/crates/go/llm_functions/customizable/test_build_request_stream_companions_test.gobaml_language/sdk_tests/crates/go/llm_functions/customizable/test_main_test.gobaml_language/sdk_tests/crates/go/llm_functions/customizable/test_parse_companions_test.gobaml_language/sdk_tests/crates/go/package_edges/customizable/compile_test.gobaml_language/sdk_tests/crates/go/src/lib.rsbaml_language/sdk_tests/crates/go/type_shapes/customizable/go_codegen_edges_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/go_codegen_union_edges_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/roundtrip_tests/test_aliases_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/roundtrip_tests/test_class_refs_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/roundtrip_tests/test_enums_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/roundtrip_tests/test_forward_refs_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/roundtrip_tests/test_generics_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/roundtrip_tests/test_lists_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/roundtrip_tests/test_literals_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/roundtrip_tests/test_maps_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/roundtrip_tests/test_media_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/roundtrip_tests/test_optional_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/roundtrip_tests/test_primitives_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/roundtrip_tests/test_recursion_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/roundtrip_tests/test_routing_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/roundtrip_tests/test_rust_type_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/roundtrip_tests/test_streams_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/roundtrip_tests/test_symbol_collisions_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/roundtrip_tests/test_unions_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/roundtrip_tests/test_void_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/test_complex_models_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/test_generic_test.gobaml_language/sdk_tests/crates/go/type_shapes/customizable/test_main_test.gobaml_language/sdk_tests/fixtures/function_calls/baml_src/ns_generic_tests/types.bamlbaml_language/sdk_tests/fixtures/function_calls/baml_src/ns_go_json_tests/main.bamlbaml_language/sdk_tests/fixtures/function_calls/baml_src/ns_go_time_tests/main.bamlbaml_language/sdk_tests/fixtures/function_calls/baml_src/ns_go_type_tests/main.bamlbaml_language/sdk_tests/fixtures/function_calls/baml_src/ns_host_callable_tests/main.bamlbaml_language/sdk_tests/fixtures/function_calls/baml_src/ns_method_self_edges/types.bamlbaml_language/sdk_tests/fixtures/function_calls/baml_src/ns_static_method_edges/types.bamlbaml_language/sdk_tests/fixtures/type_shapes/baml_src/ns_go_codegen/ns_alias_edges/types.bamlbaml_language/sdk_tests/fixtures/type_shapes/baml_src/ns_go_codegen/ns_rust_type_edges/types.bamlbaml_language/sdk_tests/fixtures/type_shapes/baml_src/ns_go_codegen/ns_union_edges/ns_left/types.bamlbaml_language/sdk_tests/fixtures/type_shapes/baml_src/ns_go_codegen/ns_union_edges/ns_right/types.bamlbaml_language/sdk_tests/fixtures/type_shapes/baml_src/ns_go_codegen/ns_union_edges/types.bamlbaml_language/sdk_tests/fixtures/type_shapes/baml_src/ns_media/types.bamlbaml_language/sdk_tests/harness_setup/src/go.rsbaml_language/sdk_tests/harness_setup/src/lib.rsbaml_language/sdks/cpp/bridge_cpp/pb/baml_bridge/cffi/v1/baml_inbound.pb.hbaml_language/sdks/go/baml_go/class.gobaml_language/sdks/go/baml_go/container.gobaml_language/sdks/go/baml_go/container_test.gobaml_language/sdks/go/baml_go/dynamic.gobaml_language/sdks/go/baml_go/dynamic_test.gobaml_language/sdks/go/baml_go/enum.gobaml_language/sdks/go/baml_go/generics_test.gobaml_language/sdks/go/baml_go/host_callable.gobaml_language/sdks/go/baml_go/host_callable_test.gobaml_language/sdks/go/baml_go/input_ownership_test.gobaml_language/sdks/go/baml_go/json.gobaml_language/sdks/go/baml_go/json_test.gobaml_language/sdks/go/baml_go/literal_test.gobaml_language/sdks/go/baml_go/media.gobaml_language/sdks/go/baml_go/media_ownership_test.gobaml_language/sdks/go/baml_go/media_test.gobaml_language/sdks/go/baml_go/native_unix.gobaml_language/sdks/go/baml_go/native_unsupported.gobaml_language/sdks/go/baml_go/native_windows.gobaml_language/sdks/go/baml_go/optional_arg.gobaml_language/sdks/go/baml_go/optional_arg_test.gobaml_language/sdks/go/baml_go/runtime.gobaml_language/sdks/go/baml_go/runtime_test.gobaml_language/sdks/go/baml_go/rust_type.gobaml_language/sdks/go/baml_go/rust_type_test.gobaml_language/sdks/go/baml_go/type_test.gobaml_language/sdks/go/baml_go/value.gobaml_language/sdks/go/baml_go/value_test.gobaml_language/sdks/go/sdkgen_go/src/formatting.rsbaml_language/sdks/go/sdkgen_go/src/lib.rsbaml_language/sdks/go/sdkgen_go/src/names.rsbaml_language/sdks/go/sdkgen_go/src/rendering.rsbaml_language/sdks/go/sdkgen_go/src/types.rstypescript2/pkg-proto/src/test/encode-decode.test.ts
💤 Files with no reviewable changes (1)
- baml_language/sdk_tests/crates/go/function_calls/customizable/main_test.go
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@baml_language/crates/baml_cli/src/generate.rs`:
- Around line 302-312: Update the generation flow around write_generated_output
so an initial generation into an existing SDK directory does not adopt all
unmanifested files as generated or delete them as stale; preserve unmanaged
legacy files while still removing previously generated stale outputs safely.
Extend the e2e coverage to create a user-owned file before the first manifest is
written and verify it survives generation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9bcc85d4-eaa8-4884-89c6-043b63a4fd5b
⛔ Files ignored due to path filters (1)
baml_language/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (17)
baml_language/crates/baml_cli/Cargo.tomlbaml_language/crates/baml_cli/src/generate.rsbaml_language/crates/baml_cli/tests/exit_code_e2e.rsbaml_language/crates/baml_codegen_types/Cargo.tomlbaml_language/crates/baml_codegen_types/src/lib.rsbaml_language/crates/baml_codegen_types/src/output_writer.rsbaml_language/sdk_tests/harness_setup/src/cpp.rsbaml_language/sdk_tests/harness_setup/src/go.rsbaml_language/sdk_tests/harness_setup/src/java.rsbaml_language/sdk_tests/harness_setup/src/lib.rsbaml_language/sdk_tests/harness_setup/src/python_pydantic2.rsbaml_language/sdk_tests/harness_setup/src/rust.rsbaml_language/sdk_tests/harness_setup/src/swift.rsbaml_language/sdk_tests/harness_setup/src/typescript.rsbaml_language/sdk_tests/harness_setup/src/typescript_web.rsbaml_language/sdks/csharp/sdkgen_csharp/src/transaction.rsbaml_language/sdks/go/baml_go/dynamic.go
🚧 Files skipped from review as they are similar to previous changes (2)
- baml_language/sdk_tests/harness_setup/src/go.rs
- baml_language/sdks/go/baml_go/dynamic.go
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@baml_language/crates/baml_codegen_types/src/output_writer.rs`:
- Around line 460-473: Update validate_no_file_directory_collisions to check
each sorted path against all of its ancestor directory prefixes, rather than
only adjacent entries via windows(2). Preserve case-insensitive matching and
return FileDirectoryPathCollision for the conflicting ancestor so both
validate_generated_files and validate_preserved_paths detect non-adjacent
collisions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4a4c616c-6d0c-492d-b4e3-72aeffec6b24
⛔ Files ignored due to path filters (1)
baml_language/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (14)
baml_language/crates/baml_cli/tests/exit_code_e2e.rsbaml_language/crates/baml_codegen_types/Cargo.tomlbaml_language/crates/baml_codegen_types/src/output_writer.rsbaml_language/sdk_tests/crates/swift/type_shapes/customizable/roundtrip_tests/TestEnums.swiftbaml_language/sdk_tests/crates/swift/type_shapes/customizable/roundtrip_tests/TestHandles.swiftbaml_language/sdk_tests/harness_setup/src/rust.rsbaml_language/sdks/csharp/sdkgen_csharp/Cargo.tomlbaml_language/sdks/csharp/sdkgen_csharp/src/lib.rsbaml_language/sdks/csharp/sdkgen_csharp/src/output.rsbaml_language/sdks/csharp/sdkgen_csharp/src/pipeline.rsbaml_language/sdks/csharp/sdkgen_csharp/src/semantic.rsbaml_language/sdks/csharp/sdkgen_csharp/src/transaction.rsbaml_language/sdks/rust/sdkgen_rust/src/emit/function.rsbaml_language/sdks/rust/sdkgen_rust/src/lib.rs
💤 Files with no reviewable changes (5)
- baml_language/sdk_tests/crates/swift/type_shapes/customizable/roundtrip_tests/TestEnums.swift
- baml_language/sdks/csharp/sdkgen_csharp/Cargo.toml
- baml_language/sdks/rust/sdkgen_rust/src/lib.rs
- baml_language/sdk_tests/crates/swift/type_shapes/customizable/roundtrip_tests/TestHandles.swift
- baml_language/sdks/csharp/sdkgen_csharp/src/transaction.rs
🚧 Files skipped from review as they are similar to previous changes (3)
- baml_language/crates/baml_codegen_types/Cargo.toml
- baml_language/sdk_tests/harness_setup/src/rust.rs
- baml_language/crates/baml_cli/tests/exit_code_e2e.rs
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
baml_language/sdks/cpp/sdkgen_cpp/src/lib.rs (1)
2273-2353: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winGood unit-test coverage for the new completeness helpers, consider adding an alias-wrapped-class case.
The three tests correctly validate ordinary vs. optional-arg semantics across containers and alias-declaration ordering. As per coding guidelines (
**/*.rs: "Prefer writing Rust unit tests over integration tests where possible"), these are appropriately scoped#[test]unit tests. Given the gap flagged onincomplete_stored_type_issue(lines 1237-1269), consider adding a case withTy::TypeAliaswrapping an incomplete class to lock in the fix.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@baml_language/sdks/cpp/sdkgen_cpp/src/lib.rs` around lines 2273 - 2353, Extend declaration_safety_tests::optional_arg_storage_rejects_later_classes_in_every_container with a Ty::TypeAlias case wrapping the incomplete user.Later class, and assert incomplete_stored_type_issue reports the same incomplete-class message before Later is complete and no issue afterward.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@baml_language/sdks/cpp/sdkgen_cpp/src/lib.rs`:
- Around line 1237-1269: Update incomplete_stored_type_issue to recurse through
every Ty::TypeAlias using its resolves_to target, while retaining the existing
recursive-alias diagnostic where applicable. Ensure aliases resolving to
incomplete classes or nested container types are detected, and extend the
declaration-safety tests to cover non-recursive alias targets.
---
Nitpick comments:
In `@baml_language/sdks/cpp/sdkgen_cpp/src/lib.rs`:
- Around line 2273-2353: Extend
declaration_safety_tests::optional_arg_storage_rejects_later_classes_in_every_container
with a Ty::TypeAlias case wrapping the incomplete user.Later class, and assert
incomplete_stored_type_issue reports the same incomplete-class message before
Later is complete and no issue afterward.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 10a6fd2a-b32e-4796-bc3f-609b6fb58583
📒 Files selected for processing (4)
baml_language/crates/baml_codegen_types/src/output_writer.rsbaml_language/sdk_tests/crates/swift/type_shapes/customizable/roundtrip_tests/TestHandles.swiftbaml_language/sdks/cpp/sdkgen_cpp/src/lib.rsbaml_language/sdks/go/sdkgen_go/src/formatting.rs
💤 Files with no reviewable changes (1)
- baml_language/sdk_tests/crates/swift/type_shapes/customizable/roundtrip_tests/TestHandles.swift
🚧 Files skipped from review as they are similar to previous changes (2)
- baml_language/sdks/go/sdkgen_go/src/formatting.rs
- baml_language/crates/baml_codegen_types/src/output_writer.rs
Outcome
This makes the generated Go SDK usable across the broad static/runtime surface we have completed so far, while keeping unsupported BAML shapes omitted instead of emitting uncompilable Go.
Before, Go generation covered the initial free-function and basic-type slice. After this PR, generated callers can use packages/namespaces, classes, enums, optionals/defaults, closed and dynamic unions, aliases, generic classes/functions, media, canonical JSON, reflected
typevalues, opaque$rust_typehandles, host callbacks, methods/static methods, parse/build-request companions, cancellation, and BAML time values through one Go-native API.Generated classes, closed unions, and callbacks remain statically typed where the configured union threshold permits it. Larger unions intentionally project to
any, retain candidate documentation, and rely on BAML's runtime validation.User-visible behavior
Audit map
Review in this order:
baml_language/sdks/go/sdkgen_go/src/types.rs— canonical BAML-to-Go semantic projection and support filtering.baml_language/sdks/go/sdkgen_go/src/names.rs— collision-safe name allocation and exact wire identity.baml_language/sdks/go/sdkgen_go/src/lib.rs— package layout, declarations, codecs, functions, methods, callbacks, and descriptors.baml_language/sdks/go/baml_go/— runtime encoding/decoding, ownership, callbacks, media, JSON, reflected types, and handles.baml_language/sdk_tests/crates/go/plus Go customizable fixtures — generated compile/runtime coverage and Python-parity tests.baml_language/crates/baml_cli/andsdk_tests/harness_setup/src/go.rs— CLI and test-harness integration.Validation
Final post-#4087 sync validation:
cargo test -p sdkgen_go— 84/84 passedcargo test -p bex_external_types— 21/21 passed; 3 doctests ignoredcargo test -p bex_engine --test host_value_callable— 23 passed; 1 documented compiler-gap test ignoredcargo nextest run -p sdk_test_go --no-fail-fast— 9/9 passedDeliberate remaining scope
anyabove the configured typed-union threshold.Summary by CodeRabbit
max_typed_union_aritysetting (default 3) withbaml.tomltemplate support, validation, and generation behavior for typed unions.