Skip to content

Initial standard library cleanup - #4350

Merged
2kai2kai2 merged 3 commits into
canaryfrom
kai/stdlib-cleanup
Aug 10, 2026
Merged

Initial standard library cleanup#4350
2kai2kai2 merged 3 commits into
canaryfrom
kai/stdlib-cleanup

Conversation

@2kai2kai2

@2kai2kai2 2kai2kai2 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor
  • Deletes baml.sys.now_ms which was redundant and not sysop-swappable
  • Moved baml.schema.schema to baml.json.schema, deleting the baml.schema namespace.
  • Added more doc comments to things

Summary by CodeRabbit

  • New Features

    • Added conversion from bigint to 63-bit signed int, with clear errors for out-of-range values.
    • Added provider-neutral JSON Schema generation for BAML types.
  • Removed

    • Removed the legacy system timestamp function and previous schema conversion entry point.
  • Documentation

    • Expanded standard-library documentation for HTTP responses, iterators, arithmetic, time, TOML tables, and bigint conversions.
  • Tests

    • Updated timing, temporary-file, schema, and standard-library coverage for the revised APIs.

@vercel

vercel Bot commented Aug 7, 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 Aug 10, 2026 5:36pm
promptfiddle2 Ready Ready Preview Aug 10, 2026 5:36pm

Request Review

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

⏭️ Performance benchmarks were skipped

Perf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to canary/main.

To run them on this PR, do any of the following, then push a commit (or re-run CI):

  • Add RUN_CODSPEED=1 to the PR description, or
  • Include run-perf or /perf in the PR title or any commit message.

@2kai2kai2
2kai2kai2 force-pushed the kai/stdlib-cleanup branch from a0f7ba9 to bd54c3c Compare August 7, 2026 23:59
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (2)
  • 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_render__tests__renders_builtin_class_with_impls.snap is excluded by !**/*.snap

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6d8df6f9-f0a1-4e8f-ab69-9f4dda3e5869

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The change adds Bigint.to_int and baml.json.schema, removes legacy schema and timing APIs, migrates timing and entry-point tests, and expands standard-library documentation.

Changes

Standard-library consolidation

Layer / File(s) Summary
Bigint integer conversion
baml_language/crates/baml_builtins2/baml_std/baml/bigint.baml, baml_language/crates/bex_vm/src/package_baml/bigint.rs, baml_language/crates/baml_tests/baml_src/ns_bigints/bigints.baml
Bigint.to_int validates the BAML 63-bit signed integer range and returns InvalidArgument when conversion fails. Tests cover valid boundaries and out-of-range values.
JSON schema API migration
baml_language/crates/baml_builtins2/baml_std/baml/ns_json/json.baml, baml_language/crates/sys_ops/src/lib.rs, baml_language/crates/baml_builtins2/src/lib.rs, baml_language/crates/baml_tests/baml_src/ns_provider_stdlib/provider_stdlib.baml
JSON Schema generation is exposed as baml.json.schema. The old schema builtin registration is removed, and provider schema generation uses the new API.
Timing API migration
baml_language/crates/baml_builtins2/baml_std/testing/registry.baml, baml_language/crates/baml_tests/baml_src/ns_cancel_cascade/cancel_cascade.baml, baml_language/crates/baml_tests/baml_src/ns_csv/csv.baml, baml_language/crates/baml_tests/baml_src/ns_fs/fs.baml, baml_language/crates/baml_tests/baml_src/ns_glob/glob.baml, baml_language/crates/bridge_wasm/src/wasm_time.rs
Timing and temporary-path code uses baml.time.Instant and millisecond conversion instead of baml.sys.now_ms. Browser clock documentation no longer equates its clock source with now_ms.
Legacy API reference migration
baml_language/crates/baml_builtins2_codegen/src/*.rs
Code-generation examples and path-conversion tests use baml.sys.argv instead of baml.sys.now_ms.
Native entry-point coverage
baml_language/crates/bex_engine/tests/function_resolution.rs, baml_language/sdk_tests/crates/*/function_calls/customizable/*, baml_language/sdk_tests/crates/parity_analysis.md
Entry-point tests across the engine and SDK bindings replace timestamp assertions with baml.sys.argv invocation and result checks.
Standard-library documentation
baml_language/crates/baml_builtins2/baml_std/baml/ns_http/http.baml, baml_language/crates/baml_builtins2/baml_std/baml/ns_iter/iter.baml, baml_language/crates/baml_builtins2/baml_std/baml/ns_ops/math.baml, baml_language/crates/baml_builtins2/baml_std/baml/ns_time/*.baml, baml_language/crates/baml_builtins2/baml_std/baml/ns_toml/toml.baml, typescript2/app-website/lib/baml-docs/index.ts, typescript2/biome.json
Documentation describes HTTP responses, iterator operations, arithmetic interfaces, time APIs, TOML tables, and the updated standard-library symbol count. Biome ignores the generated standard-library documentation file.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Possibly related PRs

Poem

A rabbit checks bounds in the moonlit night,
Schemas unfold in a JSON light.
Instants measure each careful run,
argv hops where old clocks spun.
New docs gleam, precise and bright.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the removal, relocation, and documentation updates in the standard library.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch kai/stdlib-cleanup

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@vercel
vercel Bot temporarily deployed to Preview – beps August 8, 2026 00:01 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 August 8, 2026 00:07 Inactive
@2kai2kai2
2kai2kai2 force-pushed the kai/stdlib-cleanup branch from bd54c3c to 34bd786 Compare August 8, 2026 00:07

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
baml_language/crates/sys_ops/src/lib.rs (1)

668-680: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Use an integer constant for representable bigint literals.

Literal::Bigint currently emits "type": "integer" with "const": n.to_string(), so JSON Schema compares the instance to the string "n". Large integers that fit in BexExternalValue::Int should emit a numeric const; values that do not fit should return root.errors.Unsupported. Add unit tests for both cases.

🤖 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/sys_ops/src/lib.rs` around lines 668 - 680, Update the
Literal::Bigint JSON Schema generation to parse representable values into the
integer type used by BexExternalValue::Int and emit a numeric const instead of
n.to_string(); return root.errors.Unsupported when conversion fails. Add unit
tests covering both an in-range bigint and an out-of-range bigint.
🤖 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/baml_std/baml/ns_iter/iter.baml`:
- Around line 66-70: Update the documentation for step_by and chain to remove
the inaccurate “provided function” callback wording. For step_by, describe that
the source iterator is not advanced until next is called; for chain, state that
other.iter() is created when chain is called while iteration remains deferred.
- Around line 66-70: Define explicit handling for non-positive n in step_by:
reject n <= 0, or document that these values behave as a step of one and guard
any n - 1 calculation against int.min_value() overflow. Keep the existing lazy
iterator behavior and positive-step semantics unchanged.

In
`@baml_language/sdk_tests/crates/typescript/function_calls/customizable/stdlib_entrypoints.test.ts`:
- Line 6: Update the import declaration for argv and argv_async to use single
quotes instead of double quotes, preserving the imported symbols and module
path.

---

Outside diff comments:
In `@baml_language/crates/sys_ops/src/lib.rs`:
- Around line 668-680: Update the Literal::Bigint JSON Schema generation to
parse representable values into the integer type used by BexExternalValue::Int
and emit a numeric const instead of n.to_string(); return
root.errors.Unsupported when conversion fails. Add unit tests covering both an
in-range bigint and an out-of-range bigint.
🪄 Autofix

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: f0c3aa1a-1a06-423c-ab02-05df9e7f1a08

📥 Commits

Reviewing files that changed from the base of the PR and between a071bd8 and bd54c3c.

⛔ Files ignored due to path filters (21)
  • 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_testing_package_listing.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/cancel_cascade.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/csv.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/glob.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/provider_stdlib.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____03_ppir.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/__testing_std__/baml_tests__compiles____testing_std____03_ppir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____04_5_mir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_std____04_tir.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/compiles/__testing_std__/baml_tests__compiles____testing_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
  • baml_language/crates/baml_tests/tests/bytecode_format/snapshots/bytecode_format__bytecode_display_textual.snap is excluded by !**/*.snap
📒 Files selected for processing (36)
  • baml_language/crates/baml_builtins2/baml_std/baml/bigint.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_http/http.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_iter/iter.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_json/json.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_ops/math.baml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_schema/schema.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_toml/toml.baml
  • baml_language/crates/baml_builtins2/baml_std/testing/registry.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/extract.rs
  • baml_language/crates/baml_builtins2_codegen/src/types.rs
  • baml_language/crates/baml_tests/baml_src/ns_bigints/bigints.baml
  • baml_language/crates/baml_tests/baml_src/ns_cancel_cascade/cancel_cascade.baml
  • baml_language/crates/baml_tests/baml_src/ns_csv/csv.baml
  • baml_language/crates/baml_tests/baml_src/ns_fs/fs.baml
  • baml_language/crates/baml_tests/baml_src/ns_glob/glob.baml
  • baml_language/crates/baml_tests/baml_src/ns_provider_stdlib/provider_stdlib.baml
  • baml_language/crates/bex_engine/tests/function_resolution.rs
  • baml_language/crates/bex_vm/Cargo.toml
  • baml_language/crates/bex_vm/src/package_baml/bigint.rs
  • baml_language/crates/bex_vm/src/package_baml/sys.rs
  • baml_language/crates/bridge_wasm/src/wasm_time.rs
  • baml_language/crates/sys_ops/src/lib.rs
  • baml_language/sdk_tests/crates/cpp/function_calls/customizable/tests/test_stdlib_entrypoints.cc
  • baml_language/sdk_tests/crates/java/function_calls/customizable/TestStdlibEntrypoints.java
  • baml_language/sdk_tests/crates/parity_analysis.md
  • baml_language/sdk_tests/crates/python_pydantic2/function_calls/customizable/test_stdlib_entrypoints.py
  • baml_language/sdk_tests/crates/rust/function_calls/customizable/test_stdlib_entrypoints.rs
  • baml_language/sdk_tests/crates/swift/function_calls/customizable/TestStdlibEntrypoints.swift
  • baml_language/sdk_tests/crates/typescript/function_calls/customizable/stdlib_entrypoints.test.ts
  • typescript2/app-website/lib/baml-docs/index.ts
  • typescript2/app-website/lib/baml-docs/stdlib.json
💤 Files with no reviewable changes (5)
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_schema/schema.baml
  • baml_language/crates/bex_vm/Cargo.toml
  • baml_language/crates/baml_builtins2/baml_std/baml/ns_sys/sys.baml
  • baml_language/crates/baml_builtins2/src/lib.rs
  • baml_language/crates/bex_vm/src/package_baml/sys.rs

Comment thread baml_language/crates/baml_builtins2/baml_std/baml/ns_iter/iter.baml
@vercel
vercel Bot temporarily deployed to Preview – beps August 8, 2026 00:09 Inactive
@2kai2kai2
2kai2kai2 force-pushed the kai/stdlib-cleanup branch from 34bd786 to a16d915 Compare August 8, 2026 00:12
@vercel
vercel Bot temporarily deployed to Preview – beps August 8, 2026 00:14 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 August 8, 2026 00:19 Inactive
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

Binary size checks passed

7 passed

Artifact Platform File Gzip Gated on Baseline Delta Status
baml-cli Linux 🔒 27.8 MB 11.8 MB file 27.4 MB +423.9 KB (+1.5%) OK
packed-program Linux 🔒 18.0 MB 7.4 MB file 17.7 MB +300.7 KB (+1.7%) OK
baml-cli macOS 🔒 21.6 MB 10.3 MB file 21.3 MB +329.4 KB (+1.5%) OK
packed-program macOS 🔒 14.1 MB 6.5 MB file 13.8 MB +244.0 KB (+1.8%) OK
baml-cli Windows 🔒 23.3 MB 10.5 MB file 23.0 MB +297.9 KB (+1.3%) OK
packed-program Windows 🔒 15.0 MB 6.6 MB file 14.8 MB +225.5 KB (+1.5%) OK
bridge_wasm WASM 17.1 MB 🔒 4.7 MB gzip 4.6 MB +48.5 KB (+1.1%) OK

🔒 = the size this artifact is GATED on (ceiling + delta). Binaries gate on file size (installed binary); WASM gates on gzip (download size). The other size is shown for information only.


Generated by cargo size-gate · workflow run

It is redundant as we have `baml.time.Instant.now`. It also was a VM
function instead of being a sysop despite interacting with the outside
world.

As part of this added `bigint.to_int`
@vercel
vercel Bot temporarily deployed to Preview – beps August 10, 2026 17:29 Inactive
@2kai2kai2
2kai2kai2 enabled auto-merge August 10, 2026 17:36
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 August 10, 2026 17:36 Inactive
@2kai2kai2
2kai2kai2 added this pull request to the merge queue Aug 10, 2026
Merged via the queue into canary with commit f63c7df Aug 10, 2026
84 checks passed
@2kai2kai2
2kai2kai2 deleted the kai/stdlib-cleanup branch August 10, 2026 17:53
aaronvg added a commit that referenced this pull request Aug 10, 2026
Canary's "Initial standard library cleanup" (#4350) moved
`baml.schema.json_schema` to `baml.json.schema` and deleted the
`baml.schema` namespace. Git reported only four conflicts, all in
generated snapshots, but the real breakage was a semantic one it could
not see: the ai and claude_code packages both call that function, so the
merged tree compiled to 251 failures with `unresolved name: schema`.

Both call sites (ai/ns_internal/helpers.baml, claude_code's
ns_internal/cli.baml) now use `baml.json.schema` — same signature, same
throws clause, so this is a pure rename — along with the seven _planv2
pages that document it.

The snapshot conflicts are regenerated rather than hand-resolved, since
they are generated files and the merged source is the only correct
input. Their net symbol delta is exactly what it should be:
`baml.json.schema` in; `baml.schema.json_schema` and the removed
`baml.sys.now_ms` out; plus canary's new iter/ops interfaces.

Verified: 3181/3184 pass (the 3 failures are a local gofmt shim with no
go version set, green in CI), no unreferenced snapshots, clippy clean,
and the _planv2 suite is 35/35 including the streaming and wrapper
tests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai coderabbitai Bot mentioned this pull request Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant