Skip to content

Instant and Duration - #3594

Merged
2kai2kai2 merged 3 commits into
canaryfrom
kai/time
May 29, 2026
Merged

Instant and Duration#3594
2kai2kai2 merged 3 commits into
canaryfrom
kai/time

Conversation

@2kai2kai2

@2kai2kai2 2kai2kai2 commented May 28, 2026

Copy link
Copy Markdown
Contributor
  • Adds baml.time.Instant, representing an absolute point in time with nanosecond granularity. Canonical serialization is an RFC3339 timestamp.
  • Adds baml.time.Duration, representing a difference between two Instants (a time span).
  • Changed $init_test_<file_id> identifiers to be path-based instead of using an unstable index so adding new files doesn't churn every test
  • Make builtins require a throws declaration (e.g. throws never or throws MyErrorType)

Note that at this time, neither Instant nor Duration implement operator overloading (since the language does not support it currently) and Instant does not override SAP coercion (also not currently supported).

Summary by CodeRabbit

  • New Features
    • Added Duration and Instant types with parsing, formatting, epoch conversions, and helpers; baml.time is available across runtimes (native & WASM).
  • Improvements
    • Many built-in APIs now explicitly declare non-throwing behavior for clearer error contracts and safer types.
    • Time support wired into multiple runtimes and builders.
  • Tests
    • Added tests for Instant parsing, now(), and Duration conversions.

Review Change Stack

@vercel

vercel Bot commented May 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
beps Ready Ready Preview, Comment May 28, 2026 10:43pm
promptfiddle Ready Ready Preview, Comment May 28, 2026 10:43pm
promptfiddle2 Ready Ready Preview, Comment May 28, 2026 10:43pm

Request Review

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8f49a9dc-3b1e-4b95-b3f0-2b319909c3b4

📥 Commits

Reviewing files that changed from the base of the PR and between 0863d21 and a38b06e.

⛔ Files ignored due to path filters (119)
  • baml_language/Cargo.lock is excluded by !**/*.lock
  • baml_language/crates/baml_cli/src/snapshots/baml_cli__describe_command_tests__render_builtin_package_listing.snap is excluded by !**/*.snap
  • baml_language/crates/baml_cli/src/snapshots/baml_cli__describe_command_tests__render_describe_builtin_deep_copy.snap is excluded by !**/*.snap
  • baml_language/crates/baml_cli/src/snapshots/baml_cli__describe_command_tests__render_describe_builtin_item_by_definition.snap is excluded by !**/*.snap
  • baml_language/crates/baml_cli/src/snapshots/baml_cli__describe_command_tests__render_describe_builtin_string.snap is excluded by !**/*.snap
  • baml_language/crates/baml_cli/src/snapshots/baml_cli__describe_command_tests__render_describe_truncation_hint.snap is excluded by !**/*.snap
  • baml_language/crates/baml_lsp2_actions/src/snapshots/baml_lsp2_actions__describe_tests__describe_builtin_deep_copy_with_compiler2_visible_files.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/_root.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/arrays.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/assignments.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/bigints.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/builtins.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/byte_strings.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/cancel_cascade.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/class_type_args_at_runtime.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/classes.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/closures.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/deep_copy.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/enums.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/env.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/exceptions.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/floats.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/for_loops.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/fs.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/functions.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/future_methods.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/glob.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/if_else.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/ints.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/is_operator.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/json_alias.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/json_auto_derive.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/json_parse_stringify.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/json_to_from_string.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/lambdas.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/lexical_scoping.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/maps.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/match_basics.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/match_optimization.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/match_types.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/null_handling.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/operators.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/optional_function_parameters.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/patterns_new_runtime.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/reflect_type_of.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/reflect_type_of_generic.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/shell.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/soundness.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_basic.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_name_object.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_semantics.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_throws.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/strings.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/time.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/type_error_repro.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/type_reflection.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/typed_inputs.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/typed_outputs.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/watch.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/while_loops.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_basic/baml_tests__compiles__test_expr_basic__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_basic/baml_tests__compiles__test_expr_basic__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_basic/baml_tests__compiles__test_expr_basic__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_basic/baml_tests__compiles__test_expr_basic__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_name_concat/baml_tests__compiles__test_expr_name_concat__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_name_concat/baml_tests__compiles__test_expr_name_concat__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_name_concat/baml_tests__compiles__test_expr_name_concat__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_name_concat/baml_tests__compiles__test_expr_name_concat__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_throwing_body/baml_tests__compiles__test_expr_throwing_body__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_throwing_body/baml_tests__compiles__test_expr_throwing_body__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_throwing_body/baml_tests__compiles__test_expr_throwing_body__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_throwing_body/baml_tests__compiles__test_expr_throwing_body__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_old_and_new/baml_tests__compiles__test_old_and_new__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_old_and_new/baml_tests__compiles__test_old_and_new__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_old_and_new/baml_tests__compiles__test_old_and_new__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_old_and_new/baml_tests__compiles__test_old_and_new__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_raw_string_name/baml_tests__compiles__test_raw_string_name__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_raw_string_name/baml_tests__compiles__test_raw_string_name__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_raw_string_name/baml_tests__compiles__test_raw_string_name__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_raw_string_name/baml_tests__compiles__test_raw_string_name__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_with_not_keyword/baml_tests__compiles__test_with_not_keyword__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_with_not_keyword/baml_tests__compiles__test_with_not_keyword__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_with_not_keyword/baml_tests__compiles__test_with_not_keyword__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_with_not_keyword/baml_tests__compiles__test_with_not_keyword__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_basic/baml_tests__compiles__testset_basic__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_basic/baml_tests__compiles__testset_basic__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_basic/baml_tests__compiles__testset_basic__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_basic/baml_tests__compiles__testset_basic__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_dynamic/baml_tests__compiles__testset_dynamic__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_dynamic/baml_tests__compiles__testset_dynamic__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_dynamic/baml_tests__compiles__testset_dynamic__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_dynamic/baml_tests__compiles__testset_dynamic__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_nested/baml_tests__compiles__testset_nested__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_nested/baml_tests__compiles__testset_nested__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_nested/baml_tests__compiles__testset_nested__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_nested/baml_tests__compiles__testset_nested__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_vibes_nested/baml_tests__compiles__testset_vibes_nested__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_vibes_nested/baml_tests__compiles__testset_vibes_nested__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_vibes_nested/baml_tests__compiles__testset_vibes_nested__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_vibes_nested/baml_tests__compiles__testset_vibes_nested__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_with_setup/baml_tests__compiles__testset_with_setup__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_with_setup/baml_tests__compiles__testset_with_setup__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_with_setup/baml_tests__compiles__testset_with_setup__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_with_setup/baml_tests__compiles__testset_with_setup__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/diagnostic_errors/test_expr_name_type_error/baml_tests__diagnostic_errors__test_expr_name_type_error__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/diagnostic_errors/test_expr_name_type_error/baml_tests__diagnostic_errors__test_expr_name_type_error__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/diagnostic_errors/test_expr_with_runner/baml_tests__diagnostic_errors__test_expr_with_runner__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/diagnostic_errors/test_expr_with_runner/baml_tests__diagnostic_errors__test_expr_with_runner__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/diagnostic_errors/test_expr_wrong_runner/baml_tests__diagnostic_errors__test_expr_wrong_runner__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/diagnostic_errors/test_expr_wrong_runner/baml_tests__diagnostic_errors__test_expr_wrong_runner__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/diagnostic_errors/test_with_runner_ambiguity/baml_tests__diagnostic_errors__test_with_runner_ambiguity__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/diagnostic_errors/test_with_runner_ambiguity/baml_tests__diagnostic_errors__test_with_runner_ambiguity__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/src/compiler2_tir/snapshots/baml_tests__compiler2_tir__phase5__snapshot_baml_package_items.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_expanded.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_expanded_unoptimized.snap is excluded by !**/*.snap
📒 Files selected for processing (48)
  • baml_language/Cargo.toml
  • baml_language/crates/baml_builtins2/baml_std/baml/bigint.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/bool.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/containers.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/core.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/float.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/int.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_errors/stack_trace.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_events/events.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_future/future.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_http/http.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_io/io.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_json/json.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_llm/llm_types.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_math/math.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_media/media.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_sys/sys.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_time/duration.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_time/instant.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_unstable/unstable.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/null.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/string.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/type_class.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/uint8array.baml
  • baml_language/crates/baml_builtins2/src/lib.rs
  • baml_language/crates/baml_builtins2_codegen/src/codegen.rs
  • baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs
  • baml_language/crates/baml_builtins2_codegen/src/extract.rs
  • baml_language/crates/baml_builtins2_codegen/src/types.rs
  • baml_language/crates/baml_compiler2_ast/src/lib.rs
  • baml_language/crates/baml_compiler2_ast/src/lower_cst.rs
  • baml_language/crates/baml_compiler2_emit/src/lib.rs
  • baml_language/crates/baml_compiler2_hir/src/builder.rs
  • baml_language/crates/baml_compiler2_hir/src/lib.rs
  • baml_language/crates/baml_compiler2_ppir/src/lib.rs
  • baml_language/crates/baml_tests/baml_src/ns_time/time.baml
  • baml_language/crates/bex_vm/Cargo.toml
  • baml_language/crates/bex_vm/src/package_baml/mod.rs
  • baml_language/crates/bex_vm/src/package_baml/stack_trace.rs
  • baml_language/crates/bex_vm/src/package_baml/time.rs
  • baml_language/crates/bridge_wasm/Cargo.toml
  • baml_language/crates/bridge_wasm/src/lib.rs
  • baml_language/crates/bridge_wasm/src/wasm_time.rs
  • baml_language/crates/sys_native/Cargo.toml
  • baml_language/crates/sys_native/src/io_impls.rs
  • baml_language/crates/sys_ops/Cargo.toml
  • baml_language/crates/sys_ops/src/lib.rs
  • baml_language/crates/sys_types/Cargo.toml
💤 Files with no reviewable changes (12)
  • baml_language/crates/sys_ops/Cargo.toml
  • baml_language/crates/bridge_wasm/Cargo.toml
  • baml_language/crates/sys_types/Cargo.toml
  • baml_language/crates/bex_vm/Cargo.toml
  • baml_language/crates/sys_native/Cargo.toml
  • baml_language/crates/sys_ops/src/lib.rs
  • baml_language/crates/sys_native/src/io_impls.rs
  • baml_language/crates/bex_vm/src/package_baml/time.rs
  • baml_language/crates/bridge_wasm/src/wasm_time.rs
  • baml_language/crates/bex_vm/src/package_baml/stack_trace.rs
  • baml_language/crates/bex_vm/src/package_baml/mod.rs
  • baml_language/crates/bridge_wasm/src/lib.rs
✅ Files skipped from review due to trivial changes (2)
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_errors/stack_trace.baml
  • baml_language/crates/baml_compiler2_emit/src/lib.rs
🚧 Files skipped from review as they are similar to previous changes (32)
  • baml_language/crates/baml_builtins2/baml_std/baml/bool.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/type_class.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_events/events.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_http/http.baml
  • baml_language/crates/baml_compiler2_hir/src/builder.rs
  • baml_language/crates/baml_builtins2/baml_std/baml/core.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_math/math.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_llm/llm_types.baml
  • baml_language/crates/baml_builtins2/src/lib.rs
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_unstable/unstable.baml
  • baml_language/Cargo.toml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_json/json.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_time/duration.baml
  • baml_language/crates/baml_builtins2_codegen/src/types.rs
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_sys/sys.baml
  • baml_language/crates/baml_compiler2_hir/src/lib.rs
  • baml_language/crates/baml_compiler2_ast/src/lib.rs
  • baml_language/crates/baml_compiler2_ppir/src/lib.rs
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_media/media.baml
  • baml_language/crates/baml_tests/baml_src/ns_time/time.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/bigint.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/int.baml
  • baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs
  • baml_language/crates/baml_builtins2/baml_std/baml/uint8array.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_future/future.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_time/instant.baml
  • baml_language/crates/baml_builtins2_codegen/src/codegen.rs
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_io/io.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/containers.baml
  • baml_language/crates/baml_builtins2_codegen/src/extract.rs
  • baml_language/crates/baml_compiler2_ast/src/lower_cst.rs
  • baml_language/crates/baml_builtins2/baml_std/baml/float.baml

📝 Walkthrough

Walkthrough

This PR adds a new baml.time API (Duration and Instant), marks many existing builtins as non-throwing by adding throws never, refactors builtin extraction/codegen to record fallibility and handle Bigint, implements time support across VM/native/WASM, migrates per-file test naming to use paths, and updates related tests and Cargo deps.

Changes

Time namespace and builtin modernization

Layer / File(s) Summary
Builtin method contract tightening
baml_language/crates/baml_builtins2/baml_std/baml/*.baml, baml_language/crates/baml_builtins2/baml_std/baml/ns_*/*.baml
Added explicit throws never annotations to many builtin methods (primitives, containers, and utility namespaces).
Duration and Instant time types
baml_language/crates/baml_builtins2/baml_std/baml/ns_time/duration.baml, .../instant.baml, baml_language/crates/baml_builtins2/src/lib.rs
Introduced Duration and Instant with constructors, conversions, parsing/serialization, JSON interop, and registered files in builtin list.
Extraction & types
baml_language/crates/baml_builtins2_codegen/src/extract.rs, .../src/types.rs
Change throws to Option<Vec<String>>, add NativeBuiltin.fallible: bool, read //baml:fallible, and require explicit throws for host-bound builtins.
Codegen bigint & receiver typing
baml_language/crates/baml_builtins2_codegen/src/codegen.rs, .../codegen_io.rs
Handle BamlType::Bigint in generated view/copy code (Arc, vm.try_alloc_bigint), refine instance-backed receiver extraction and trait signatures, and simplify fallible detection.
Test naming and lowering path plumbing
baml_language/crates/baml_compiler2_ast/src/lower_cst.rs, .../emit/src/lib.rs, .../hir/src/lib.rs, .../ppir/src/lib.rs
Introduce lower_file_with_path, sanitize path-derived $init_test_<path> suffixes, pass file path through lowering/emit stages.
VM time implementation
baml_language/crates/bex_vm/src/package_baml/time.rs, baml_language/crates/bex_vm/Cargo.toml
Implement BamlClassTimeInstant::parse/to_string, add time dependency and module registration.
Native & WASM time implementations
baml_language/crates/sys_native/src/io_impls.rs, baml_language/crates/bridge_wasm/src/wasm_time.rs, baml_language/crates/sys_ops/src/lib.rs, Cargo manifests
Add IoClassTimeInstant::now() impls (native uses SystemTime, WASM uses web_time), add num-bigint deps, and IoSysOpsBuilder helpers to wire time support.
Time tests
baml_language/crates/baml_tests/baml_src/ns_time/time.baml
Add tests for parsing (RFC3339/RFC2822/ISO fallback), Instant.now lower-bound, and Duration conversions.
Supporting changes
baml_language/Cargo.toml, baml_language/crates/bex_vm/src/package_baml/stack_trace.rs
Enable time parsing feature in workspace Cargo; change StackTrace.to_string receiver to view type.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • BoundaryML/baml#3488: Overlaps on builtin fallibility/throws handling and extraction/codegen changes.
  • BoundaryML/baml#3526: Related Bigint support and allocation/overflow semantics referenced by Bigint codegen and runtime wiring.
  • BoundaryML/baml#3484: Related JSON/to_json builtin adjustments that intersect with signature changes here.

"A rabbit in the compiler hops with glee,
Marking builtins safe and adding time to see.
Instants parsed and durations told,
Tests hop forward, cargo deps enrolled.
Hooray — a tiny hop for rabbitry!"

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch kai/time

@github-actions

github-actions Bot commented May 28, 2026

Copy link
Copy Markdown

Binary size checks passed

7 passed

Artifact Platform Gzip Baseline Delta Status
bridge_cffi Linux 6.6 MB 6.6 MB +40.9 KB (+0.6%) OK
bridge_cffi-stripped Linux 5.7 MB 5.7 MB -12.2 KB (-0.2%) OK
bridge_cffi macOS 5.5 MB 5.1 MB +387.2 KB (+7.6%) OK
bridge_cffi-stripped macOS 4.7 MB 4.7 MB +4.1 KB (+0.1%) OK
bridge_cffi Windows 5.5 MB 5.1 MB +389.2 KB (+7.6%) OK
bridge_cffi-stripped Windows 4.8 MB 4.7 MB +124.1 KB (+2.7%) OK
bridge_wasm WASM 3.7 MB 3.8 MB -69.6 KB (-1.9%) OK

Generated by cargo size-gate · workflow run

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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_builtins2_codegen/src/codegen.rs`:
- Around line 1521-1524: The instance-backed receiver branch only handles
!needs_owned and therefore when extraction produced an owned Value for a
VmUsage::MutRef receiver the call-site can pass the Value by value instead of
&Value; update the condition around args.push(format!("&{name}")) to also cover
the MutRef usage. Specifically, in the block using recv.instance_backed and
needs_owned, change the test so it pushes "&{name}" when recv.instance_backed &&
(!needs_owned || recv.usage == VmUsage::MutRef) (or equivalent) so MutRef
receivers extracted as owned Values are passed by reference; keep the existing
branch names (recv.instance_backed, needs_owned, VmUsage::MutRef,
args.push(format!("&{name}"))).

In `@baml_language/crates/baml_compiler2_ast/src/lower_cst.rs`:
- Around line 1183-1195: init_test_key_from_path currently collapses different
paths to the same key by mapping non-alphanumerics to '_', causing duplicate
$init_test_<key> symbols; change it to produce a collision-resistant identifier
by keeping the sanitized base name but appending a short hex hash (e.g., first 8
chars of SHA-1/SHA-256) of the original path (or using a reversible encoding of
path separators) and ensure the final string consists only of ASCII
alphanumerics and underscores; update the function init_test_key_from_path to
compute the hash from the full path string and append it (with an underscore
separator) and apply the same change where this helper is used around the other
occurrence (lines referenced in the review) so each path yields a unique test
key.

In `@baml_language/crates/bex_vm/src/package_baml/time.rs`:
- Around line 38-43: The code currently calls
OffsetDateTime::format(&Rfc3339).unwrap(), which can panic for out-of-range
years; change this to handle the Result and map any formatting error into a
VmRustFnError::BamlError(VmBamlError::InvalidArgument) instead of panicking.
Replace the unwrap with a match/map_err (e.g.,
datetime.format(&Rfc3339).map_err(|e|
VmRustFnError::BamlError(VmBamlError::InvalidArgument { message: format!("Could
not serialize Instant as RFC3339: {}", e) }))? or an equivalent match) so the
function returns Err(...) on formatting failure; target the code around
OffsetDateTime::format(&Rfc3339), Rfc3339, VmRustFnError::BamlError and
VmBamlError::InvalidArgument.
🪄 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

Run ID: 99735841-5277-40b4-9a57-ed91e94f440c

📥 Commits

Reviewing files that changed from the base of the PR and between 6bad793 and f6c471e.

⛔ Files ignored due to path filters (119)
  • baml_language/Cargo.lock is excluded by !**/*.lock
  • baml_language/crates/baml_cli/src/snapshots/baml_cli__describe_command_tests__render_builtin_package_listing.snap is excluded by !**/*.snap
  • baml_language/crates/baml_cli/src/snapshots/baml_cli__describe_command_tests__render_describe_builtin_deep_copy.snap is excluded by !**/*.snap
  • baml_language/crates/baml_cli/src/snapshots/baml_cli__describe_command_tests__render_describe_builtin_item_by_definition.snap is excluded by !**/*.snap
  • baml_language/crates/baml_cli/src/snapshots/baml_cli__describe_command_tests__render_describe_builtin_string.snap is excluded by !**/*.snap
  • baml_language/crates/baml_cli/src/snapshots/baml_cli__describe_command_tests__render_describe_truncation_hint.snap is excluded by !**/*.snap
  • baml_language/crates/baml_lsp2_actions/src/snapshots/baml_lsp2_actions__describe_tests__describe_builtin_deep_copy_with_compiler2_visible_files.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/_root.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/arrays.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/assignments.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/bigints.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/builtins.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/byte_strings.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/cancel_cascade.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/class_type_args_at_runtime.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/classes.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/closures.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/deep_copy.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/enums.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/env.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/exceptions.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/floats.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/for_loops.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/fs.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/functions.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/future_methods.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/glob.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/if_else.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/ints.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/is_operator.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/json_alias.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/json_auto_derive.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/json_parse_stringify.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/json_to_from_string.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/lambdas.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/lexical_scoping.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/maps.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/match_basics.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/match_optimization.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/match_types.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/null_handling.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/operators.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/optional_function_parameters.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/patterns_new_runtime.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/reflect_type_of.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/reflect_type_of_generic.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/shell.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/soundness.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_basic.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_name_object.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_semantics.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_throws.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/strings.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/time.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/type_error_repro.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/type_reflection.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/typed_inputs.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/typed_outputs.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/watch.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/while_loops.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_basic/baml_tests__compiles__test_expr_basic__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_basic/baml_tests__compiles__test_expr_basic__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_basic/baml_tests__compiles__test_expr_basic__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_basic/baml_tests__compiles__test_expr_basic__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_name_concat/baml_tests__compiles__test_expr_name_concat__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_name_concat/baml_tests__compiles__test_expr_name_concat__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_name_concat/baml_tests__compiles__test_expr_name_concat__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_name_concat/baml_tests__compiles__test_expr_name_concat__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_throwing_body/baml_tests__compiles__test_expr_throwing_body__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_throwing_body/baml_tests__compiles__test_expr_throwing_body__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_throwing_body/baml_tests__compiles__test_expr_throwing_body__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_expr_throwing_body/baml_tests__compiles__test_expr_throwing_body__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_old_and_new/baml_tests__compiles__test_old_and_new__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_old_and_new/baml_tests__compiles__test_old_and_new__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_old_and_new/baml_tests__compiles__test_old_and_new__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_old_and_new/baml_tests__compiles__test_old_and_new__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_raw_string_name/baml_tests__compiles__test_raw_string_name__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_raw_string_name/baml_tests__compiles__test_raw_string_name__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_raw_string_name/baml_tests__compiles__test_raw_string_name__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_raw_string_name/baml_tests__compiles__test_raw_string_name__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_with_not_keyword/baml_tests__compiles__test_with_not_keyword__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_with_not_keyword/baml_tests__compiles__test_with_not_keyword__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_with_not_keyword/baml_tests__compiles__test_with_not_keyword__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/test_with_not_keyword/baml_tests__compiles__test_with_not_keyword__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_basic/baml_tests__compiles__testset_basic__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_basic/baml_tests__compiles__testset_basic__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_basic/baml_tests__compiles__testset_basic__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_basic/baml_tests__compiles__testset_basic__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_dynamic/baml_tests__compiles__testset_dynamic__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_dynamic/baml_tests__compiles__testset_dynamic__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_dynamic/baml_tests__compiles__testset_dynamic__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_dynamic/baml_tests__compiles__testset_dynamic__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_nested/baml_tests__compiles__testset_nested__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_nested/baml_tests__compiles__testset_nested__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_nested/baml_tests__compiles__testset_nested__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_nested/baml_tests__compiles__testset_nested__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_vibes_nested/baml_tests__compiles__testset_vibes_nested__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_vibes_nested/baml_tests__compiles__testset_vibes_nested__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_vibes_nested/baml_tests__compiles__testset_vibes_nested__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_vibes_nested/baml_tests__compiles__testset_vibes_nested__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_with_setup/baml_tests__compiles__testset_with_setup__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_with_setup/baml_tests__compiles__testset_with_setup__04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_with_setup/baml_tests__compiles__testset_with_setup__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/testset_with_setup/baml_tests__compiles__testset_with_setup__06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/diagnostic_errors/test_expr_name_type_error/baml_tests__diagnostic_errors__test_expr_name_type_error__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/diagnostic_errors/test_expr_name_type_error/baml_tests__diagnostic_errors__test_expr_name_type_error__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/diagnostic_errors/test_expr_with_runner/baml_tests__diagnostic_errors__test_expr_with_runner__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/diagnostic_errors/test_expr_with_runner/baml_tests__diagnostic_errors__test_expr_with_runner__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/diagnostic_errors/test_expr_wrong_runner/baml_tests__diagnostic_errors__test_expr_wrong_runner__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/diagnostic_errors/test_expr_wrong_runner/baml_tests__diagnostic_errors__test_expr_wrong_runner__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/diagnostic_errors/test_with_runner_ambiguity/baml_tests__diagnostic_errors__test_with_runner_ambiguity__03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/diagnostic_errors/test_with_runner_ambiguity/baml_tests__diagnostic_errors__test_with_runner_ambiguity__04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/src/compiler2_tir/snapshots/baml_tests__compiler2_tir__phase5__snapshot_baml_package_items.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_expanded.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_expanded_unoptimized.snap is excluded by !**/*.snap
📒 Files selected for processing (48)
  • baml_language/Cargo.toml
  • baml_language/crates/baml_builtins2/baml_std/baml/bigint.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/bool.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/containers.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/core.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/float.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/int.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_errors/stack_trace.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_events/events.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_future/future.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_http/http.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_io/io.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_json/json.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_llm/llm_types.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_math/math.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_media/media.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_sys/sys.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_time/duration.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_time/instant.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_unstable/unstable.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/null.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/string.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/type_class.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/uint8array.baml
  • baml_language/crates/baml_builtins2/src/lib.rs
  • baml_language/crates/baml_builtins2_codegen/src/codegen.rs
  • baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs
  • baml_language/crates/baml_builtins2_codegen/src/extract.rs
  • baml_language/crates/baml_builtins2_codegen/src/types.rs
  • baml_language/crates/baml_compiler2_ast/src/lib.rs
  • baml_language/crates/baml_compiler2_ast/src/lower_cst.rs
  • baml_language/crates/baml_compiler2_emit/src/lib.rs
  • baml_language/crates/baml_compiler2_hir/src/builder.rs
  • baml_language/crates/baml_compiler2_hir/src/lib.rs
  • baml_language/crates/baml_compiler2_ppir/src/lib.rs
  • baml_language/crates/baml_tests/baml_src/ns_time/time.baml
  • baml_language/crates/bex_vm/Cargo.toml
  • baml_language/crates/bex_vm/src/package_baml/mod.rs
  • baml_language/crates/bex_vm/src/package_baml/stack_trace.rs
  • baml_language/crates/bex_vm/src/package_baml/time.rs
  • baml_language/crates/bridge_wasm/Cargo.toml
  • baml_language/crates/bridge_wasm/src/lib.rs
  • baml_language/crates/bridge_wasm/src/wasm_time.rs
  • baml_language/crates/sys_native/Cargo.toml
  • baml_language/crates/sys_native/src/io_impls.rs
  • baml_language/crates/sys_ops/Cargo.toml
  • baml_language/crates/sys_ops/src/lib.rs
  • baml_language/crates/sys_types/Cargo.toml

Comment thread baml_language/crates/baml_builtins2_codegen/src/codegen.rs
Comment thread baml_language/crates/baml_compiler2_ast/src/lower_cst.rs
Comment thread baml_language/crates/bex_vm/src/package_baml/time.rs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
baml_language/crates/baml_builtins2_codegen/src/extract.rs (1)

278-281: ⚡ Quick win

Extract the dedicated-variant class list to avoid divergence.

The set "Array" | "Map" | "String" | "Uint8Array" here must stay in lockstep with the identical match in extract_class_fields (Line 343). instance_backed is only correct while both lists agree; editing one without the other would mark a class as instance_backed with no generated view:: struct (or vice versa). A single shared predicate removes that risk.

♻️ Proposed helper + call sites
/// Classes that keep a dedicated `Object` variant (not `Object::Instance`),
/// so they get neither a `view::` struct nor `instance_backed` receivers.
fn is_dedicated_variant(class_name: &str) -> bool {
    matches!(class_name, "Array" | "Map" | "String" | "Uint8Array")
}
-            // Mirrors `extract_class_fields`: dedicated-variant types and
-            // field-less (opaque/marker) classes get no `view::` struct.
-            instance_backed: !matches!(class_name, "Array" | "Map" | "String" | "Uint8Array")
-                && !class_def.fields.is_empty(),
+            // Mirrors `extract_class_fields`: dedicated-variant types and
+            // field-less (opaque/marker) classes get no `view::` struct.
+            instance_backed: !is_dedicated_variant(class_name) && !class_def.fields.is_empty(),
-    // Skip classes with dedicated Object variants — they are not Instance-based.
-    match class_name {
-        "Array" | "Map" | "String" | "Uint8Array" => return None,
-        _ => {}
-    }
+    // Skip classes with dedicated Object variants — they are not Instance-based.
+    if is_dedicated_variant(class_name) {
+        return None;
+    }
🤖 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/crates/baml_builtins2_codegen/src/extract.rs` around lines 278
- 281, Extract the duplicate specialized-class match into a single helper to
keep `instance_backed` and the logic in `extract_class_fields` consistent: add a
function (e.g., `is_dedicated_variant(class_name: &str) -> bool`) that
encapsulates the current matches!(class_name, "Array" | "Map" | "String" |
"Uint8Array"), then replace the inline matches! usage in the `instance_backed`
calculation and the identical match in `extract_class_fields` with calls to
`is_dedicated_variant`; ensure the helper name is used in both places so future
edits affect both behaviors simultaneously.
🤖 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.

Nitpick comments:
In `@baml_language/crates/baml_builtins2_codegen/src/extract.rs`:
- Around line 278-281: Extract the duplicate specialized-class match into a
single helper to keep `instance_backed` and the logic in `extract_class_fields`
consistent: add a function (e.g., `is_dedicated_variant(class_name: &str) ->
bool`) that encapsulates the current matches!(class_name, "Array" | "Map" |
"String" | "Uint8Array"), then replace the inline matches! usage in the
`instance_backed` calculation and the identical match in `extract_class_fields`
with calls to `is_dedicated_variant`; ensure the helper name is used in both
places so future edits affect both behaviors simultaneously.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: aaf3b7f5-fd5b-4d3a-8657-6f98e5c7d62d

📥 Commits

Reviewing files that changed from the base of the PR and between f6c471e and 0863d21.

⛔ Files ignored due to path filters (11)
  • baml_language/Cargo.lock is excluded by !**/*.lock
  • baml_language/crates/baml_cli/src/snapshots/baml_cli__describe_command_tests__render_builtin_package_listing.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/_root.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/time.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____03_hir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____06_codegen.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/src/compiler2_tir/snapshots/baml_tests__compiler2_tir__phase5__snapshot_baml_package_items.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_expanded.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_expanded_unoptimized.snap is excluded by !**/*.snap
📒 Files selected for processing (21)
  • baml_language/Cargo.toml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_time/duration.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_time/instant.baml
  • baml_language/crates/baml_builtins2/src/lib.rs
  • baml_language/crates/baml_builtins2_codegen/src/codegen.rs
  • baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs
  • baml_language/crates/baml_builtins2_codegen/src/extract.rs
  • baml_language/crates/baml_builtins2_codegen/src/types.rs
  • baml_language/crates/baml_tests/baml_src/ns_time/time.baml
  • baml_language/crates/bex_vm/Cargo.toml
  • baml_language/crates/bex_vm/src/package_baml/mod.rs
  • baml_language/crates/bex_vm/src/package_baml/stack_trace.rs
  • baml_language/crates/bex_vm/src/package_baml/time.rs
  • baml_language/crates/bridge_wasm/Cargo.toml
  • baml_language/crates/bridge_wasm/src/lib.rs
  • baml_language/crates/bridge_wasm/src/wasm_time.rs
  • baml_language/crates/sys_native/Cargo.toml
  • baml_language/crates/sys_native/src/io_impls.rs
  • baml_language/crates/sys_ops/Cargo.toml
  • baml_language/crates/sys_ops/src/lib.rs
  • baml_language/crates/sys_types/Cargo.toml
✅ Files skipped from review due to trivial changes (3)
  • baml_language/crates/bex_vm/Cargo.toml
  • baml_language/Cargo.toml
  • baml_language/crates/sys_ops/Cargo.toml
🚧 Files skipped from review as they are similar to previous changes (14)
  • baml_language/crates/bridge_wasm/Cargo.toml
  • baml_language/crates/bex_vm/src/package_baml/mod.rs
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_time/duration.baml
  • baml_language/crates/baml_builtins2/src/lib.rs
  • baml_language/crates/sys_native/Cargo.toml
  • baml_language/crates/sys_native/src/io_impls.rs
  • baml_language/crates/bridge_wasm/src/lib.rs
  • baml_language/crates/baml_tests/baml_src/ns_time/time.baml
  • baml_language/crates/bex_vm/src/package_baml/time.rs
  • baml_language/crates/bridge_wasm/src/wasm_time.rs
  • baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs
  • baml_language/crates/sys_ops/src/lib.rs
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_time/instant.baml
  • baml_language/crates/baml_builtins2_codegen/src/codegen.rs

2kai2kai2 added 3 commits May 28, 2026 16:30
We previously had massive churn every time a new test file was added, as the `$init_test_<file_id>` was updated for on average half the test files. We now use the relative file path instead of the file id, which makes the init identifier stable if not moved.
We previously allowed `$rust_function` and `$rust_io_function` to not declare an explicit `throws` type. We now require it.
Also changed `is_fallible` to use `//baml:fallible` annotations instead of just being a single Rust function that matched on method paths.
Adds the `baml.time` namespace with initial absolute time representations. These currently lack special behaviors like operator overloading or SAP coercion, which rely on either hard-coding or interface implementation.
@2kai2kai2
2kai2kai2 added this pull request to the merge queue May 29, 2026
Merged via the queue into canary with commit ddd0ff1 May 29, 2026
42 checks passed
@2kai2kai2
2kai2kai2 deleted the kai/time branch May 29, 2026 00:41
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