Skip to content

perf(ci): faster cargo tests via dedup, opt-level, cache sharing + migrate exec tests to BAML corpus - #4075

Merged
hellovai merged 6 commits into
canaryfrom
hellovai/slow-tests
Jul 17, 2026
Merged

hellovai merged 6 commits into
canaryfrom
hellovai/slow-tests

Conversation

@hellovai

@hellovai hellovai commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Goal

Get CI (`CI - BAML Language`) from ~12 min toward <5 min. The critical path was the two linux cargo jobs (~11 min each, 8-vcpu saturated). Almost all of that time is test execution, not compilation: the tests run the compiler thousands of times.

What's here (2 commits)

perf(ci) — cut cargo-test wall time

  • Dedup: the linux cargo test job re-ran baml_tests/baml_cli/baml_lsp2_actions that the snapshot job already covers on the same OS. Now excluded at the cargo level (--workspace --exclude), not just via a nextest -E filter, so their heavy test binaries aren't even built. The duplicated pack_e2e step is dropped (the snapshot job runs it).
  • Opt-level: tests exercise the compiler thousands of times, so build it optimized under test — CARGO_PROFILE_DEV/TEST_OPT_LEVEL=1 in CI, and salsa (the query engine that runs on every compile) at opt-level 3 in the dev profile.
  • Cache sharing: the spawned-CLI e2e suites (exit_code_e2e, pack_e2e) hit a cold <project>/.baml/cache per test and recompiled the stdlib every time (~14s/spawn). They now share a BAML_CACHE_DIR under CARGO_TARGET_TMPDIR, so only the first invocation pays the stdlib compile. The cache is content-addressed and fingerprinted on the CLI binary, so sharing across tests/runs is safe.
  • Phantom build: exit_code_e2e called ensure_built() (which shells cargo build -p baml_pack_host, ~10s/process even when fresh) despite never running baml pack; switched to baml_cli().
  • Both linux jobs bumped 8 → 16 vcpu (cost-neutral: they were CPU-saturated).

test(baml_tests) — move exec tests into the BAML corpus

Each Rust-side baml_test! test recompiled a BAML project from scratch in its own nextest process (~0.7–2.5s); a test { } block in the baml_src/ corpus compiles once with the whole project and runs for ~40ms.

  • 370 tests migrated across 43 files, one block per former Rust test (name preserved), each validated with baml-cli test.
  • Stays in Rust, documented at each site: compile-diagnostics tests (setup_test_db + collect_diagnostics), host-FFI tests (BexExternalValue, VM introspection), host infrastructure (stub HTTP/TCP servers, symlink creation), OptLevel::Two dispatch, and #[should_panic] compile-time checks.
  • The corpus runner snapshots each namespace's bytecode; new/extended namespaces add the corresponding baml_src/*.snap.

Verification

  • Full cargo nextest run -p baml_tests: 2819/2819 pass.
  • Local measurements (salsa-opt only, before CI opt-1): warm spawned-CLI test 14s → 1.4s; exit_code_e2e suite 574s CPU → 147s.

Notes for review

  • First CI run is sccache-cold for the opt-level change (one slow build per platform); it warms once canary refreshes the cache.
  • Follow-up, not in this PR: feature-gate baml_test! behind an off-by-default rust-baml-exec-tests so new BAML behavior tests are written in the corpus, not Rust (compile-diagnostics tests keep running under a plain cargo test).
  • The pre-existing slow/failing python-pydantic2 (windows) and Test Go Client Windows Support jobs are unrelated to this change.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added expanded runtime coverage for PromptAst accessors and prompt/tagged-template interpolation behavior.
  • Bug Fixes
    • Improved correctness verification for defer/cleanup, cancellation, error-cause chains, exception routing, string handling, sorting, GC stability, CSV decoding, networking, and filesystem error mapping.
  • Tests
    • Added many new BAML regression suites (array rest bindings, interfaces/associated types, tagged templates, JSON conversion, SSE streaming, shell/CLI scenarios) plus additional compile/diagnostic assertions.
    • Improved CI reliability by isolating CLI/cache state, sharing CLI e2e cache, and redistributing workloads while excluding heavy packages from general jobs.
  • Chores
    • Tuned local dev build optimization for faster interactive iteration.

hellovai and others added 2 commits July 17, 2026 00:48
…aring

The two linux cargo jobs dominated CI (~11 min each, 8-vcpu saturated).
Root causes and fixes:

- The linux `cargo test` job re-ran baml_tests/baml_cli/baml_lsp2_actions
  that the snapshot job already covers on the same OS. Exclude them at the
  cargo level (--workspace --exclude), not just via a nextest -E filter, so
  their heavy test binaries aren't even built. Drop the duplicated pack_e2e
  step (the snapshot job runs it) and document that contract on the snapshot
  job. Same build-skip on macos/windows.
- Tests exercise the compiler thousands of times, so test *execution*, not
  compilation, is the cost. Build the compiler optimized under test:
  CARGO_PROFILE_DEV/TEST_OPT_LEVEL=1 in CI, and salsa (the query engine that
  runs on every compile) at opt-level 3 in the dev profile.
- The spawned-CLI e2e suites (exit_code_e2e, pack_e2e) hit a cold
  `<project>/.baml/cache` per test and recompiled the stdlib every time
  (~14s/spawn). Point them at a shared BAML_CACHE_DIR under CARGO_TARGET_TMPDIR
  so only the first invocation pays the stdlib compile; the cache is
  content-addressed and fingerprinted on the CLI binary, so sharing is safe.
- exit_code_e2e used common::ensure_built() (which shells `cargo build -p
  baml_pack_host`, ~10s/process even when fresh) despite never running
  `baml pack`; switch it to baml_cli().
- Bump both linux jobs 8 -> 16 vcpu (cost-neutral: they were CPU-saturated).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01J2XzpcdbF2ddFDrCgc7fuF
…corpus

Each Rust-side `baml_test!` test recompiled a BAML project from scratch in its
own nextest process (~0.7-2.5s), while a `test { }` block in the `baml_src/`
corpus compiles once with the whole project and runs for ~40ms. Port the
compile-and-run tests out of `crates/baml_tests/tests/*.rs` and into
`baml_src/ns_*/`, one block per former Rust test (name preserved).

- 370 tests migrated across 43 files; each new block validated with
  `baml-cli test` and the full corpus (2819 tests) passes.
- What stays in Rust, and why: compile-diagnostics tests (setup_test_db +
  collect_diagnostics assert on error codes/messages), host-FFI tests
  (BexExternalValue args, VM introspection), host infrastructure (stub
  HTTP/TCP servers, symlink creation), OptLevel::Two-specific dispatch, and
  #[should_panic] compile-time checks. Each is documented at its call site.
- The corpus runner snapshots each namespace's bytecode; new/extended
  namespaces add the corresponding baml_src/*.snap.

Follow-up (not in this commit): feature-gate `baml_test!` behind an
off-by-default `rust-baml-exec-tests` so new BAML behavior tests are written
in the corpus, not Rust.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01J2XzpcdbF2ddFDrCgc7fuF
@cursor

cursor Bot commented Jul 17, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@vercel

vercel Bot commented Jul 17, 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 Jul 17, 2026 5:48pm
promptfiddle Ready Ready Preview, Comment Jul 17, 2026 5:48pm
promptfiddle2 Ready Ready Preview, Comment Jul 17, 2026 5:48pm

Request Review

@github-actions

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.

@github-actions

github-actions Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Binary size checks failed

❌ 2 violations · ✅ 5 passed

⚠️ Please fix the size gate issues or acknowledge them by updating baselines.

Artifact Platform File Gzip Gated on Baseline Delta Status
✅ baml-cli Linux 🔒 25.2 MB 10.7 MB file 24.5 MB +727.9 KB (+3.0%) OK
✅ packed-program Linux 🔒 17.0 MB 7.0 MB file 17.0 MB -4.1 KB (-0.0%) OK
❌ baml-cli macOS 🔒 19.5 MB 9.3 MB file 18.9 MB +611.9 KB (+3.2%) FAIL
✅ packed-program macOS 🔒 13.2 MB 6.2 MB file 13.2 MB +0 B (+0.0%) OK
✅ baml-cli Windows 🔒 21.0 MB 9.5 MB file 20.4 MB +612.4 KB (+3.0%) OK
✅ packed-program Windows 🔒 14.1 MB 6.2 MB file 14.1 MB -512 B (-0.0%) OK
❌ bridge_wasm WASM 16.2 MB 🔒 4.4 MB gzip 4.3 MB +130.5 KB (+3.1%) FAIL

🔒 = 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.

Details & how to fix

Violations:

  • baml-cli (macOS) file_bytes: 19.5 MB exceeds limit of 19.5 MB (exceeded by +44.9 KB, policy: max_file_bytes)
  • baml-cli (macOS) file_delta_pct: +3.2% exceeds limit of 3.0% (exceeded by +0.2pp, policy: max_delta_pct)
  • bridge_wasm (WASM) gzip_bytes: 4.4 MB exceeds limit of 4.4 MB (exceeded by +2.3 KB, policy: max_gzip_bytes)
  • bridge_wasm (WASM) gzip_delta_pct: +3.1% exceeds limit of 3.0% (exceeded by +0.1pp, policy: max_delta_pct)

Add/update baselines:

.ci/size-gate/aarch64-apple-darwin.toml:

[artifacts.baml-cli]
file_bytes = 19512048
stripped_bytes = 19512096
gzip_bytes = 9320307

.ci/size-gate/wasm32-unknown-unknown.toml:

[artifacts.bridge_wasm]
file_bytes = 16160508
gzip_bytes = 4402886

Generated by cargo size-gate · workflow run

@vercel
vercel Bot temporarily deployed to Preview – beps July 17, 2026 07:54 Inactive
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hellovai/slow-tests

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.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR expands BAML runtime corpus coverage across language semantics, interfaces, associated types, serialization, networking, templates, and standard-library behavior. It also refactors CLI caching and CI test distribution, adjusts optimization profiles, and moves selected runtime checks between BAML and Rust harnesses.

Changes

Runtime and test coverage

Layer / File(s) Summary
CI distribution and CLI caching
.github/workflows/*, baml_language/Cargo.toml, baml_language/crates/baml_cli/tests/*
CI excludes dedicated packages at the Cargo level, increases selected Linux runners to 16 vCPUs, adjusts optimization levels, and shares CLI bytecode caches across end-to-end tests.
Core language semantics
baml_language/crates/baml_tests/baml_src/ns_array_*/*, ns_cleanup/*, ns_defer/*, ns_errorcontext/*, ns_comparable_sort/*
New corpus tests cover array bindings, cleanup latches, defer ordering and unwinding, error cause chains, cancellation, sorting, constants, CSV behavior, exceptions, and floating-point semantics.
Standard-library and serialization coverage
baml_language/crates/baml_tests/baml_src/ns_{from_json_interface,fs,gc,glob,google_llm_env,parse_companions,prompt_tag_runtime,promptast_accessors}/*
BAML tests cover JSON interface dispatch, filesystem error mapping, GC pressure, glob failures, Google enterprise routing, nullable companion parsing, prompt rendering, and PromptAst accessors.
Interface and associated-type suites
baml_language/crates/baml_tests/baml_src/ns_interfaces*/*
Extensive runtime suites cover interface dispatch, blanket implementations, generic bounds, reflection, unions, requires chains, and associated-type projection and substitution.
Streaming, templates, and string conversion
baml_language/crates/baml_tests/baml_src/ns_{net,streaming_*,string_regressions,tagged_template_runtime,to_json_interface,to_string_interface,tostring_sugar}/*
Tests cover TCP/UDP behavior, SSE streams, character iteration, tagged-template captures and flattening, JSON serialization, ToString overrides, and .to_string() lowering.
Type regressions and test-suite support
baml_language/crates/baml_tests/tests/*, baml_language/crates/baml_tests/baml_src/ns_{type_error_repro,wildcard_type_inference,json_auto_derive,env}/*
Compile diagnostics, wildcard throws precision, host-boundary requirements, isolated CLI test state, and selected Rust-side runtime coverage are updated or relocated.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

  • BoundaryML/baml#3496: Both update Cargo and nextest package selection in the shared CI workflow.
  • BoundaryML/baml#3785: The defer corpus coverage exercises the corresponding compiler and runtime implementation.
  • BoundaryML/baml#4031: The array rest-binding corpus tests cover the related compiler feature.

Poem

A rabbit hops through tests so wide,
With cached commands and flags beside.
Interfaces bloom, streams gently flow,
Defers unwind in tidy row.
“Hop hop!” says Bun, “the corpus grew!”

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main CI performance changes and the migration of execution tests into the BAML corpus.
✨ 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 hellovai/slow-tests

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 – promptfiddle2 July 17, 2026 08:02 Inactive

@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: 10

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/baml_tests/tests/http.rs (1)

259-260: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Retain host-backed timeout-failure coverage.

The corpus migration removes deterministic timeout-expiry tests even though they require Rust-created network peers and therefore belong in the retained host-infrastructure suite.

  • baml_language/crates/baml_tests/tests/http.rs#L259-L260: restore the silent-server HTTP timeout test or equivalent host-backed coverage.
  • baml_language/crates/baml_tests/tests/net.rs#L128-L154: retain a TCP read that actually expires and verifies the timeout error.
  • baml_language/crates/baml_tests/tests/net.rs#L219-L248: retain a UDP receive that actually expires and verifies the timeout error.
🤖 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_tests/tests/http.rs` around lines 259 - 260,
Restore host-backed timeout-failure coverage: in
baml_language/crates/baml_tests/tests/http.rs:259-260, add a silent-server HTTP
timeout test or equivalent; in
baml_language/crates/baml_tests/tests/net.rs:128-154, retain a TCP read that
genuinely expires and asserts the timeout error; and in
baml_language/crates/baml_tests/tests/net.rs:219-248, retain a UDP receive that
genuinely expires and asserts the timeout error.
🧹 Nitpick comments (1)
baml_language/crates/baml_tests/tests/to_json_interface.rs (1)

6-15: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract duplicated compile_errors function to a shared helper.

Both files define an identical compile_errors test helper function. Consider extracting this function into a common test utility module (e.g., tests/common/mod.rs or baml_tests::testing) to reduce code duplication and improve maintainability.

  • baml_language/crates/baml_tests/tests/to_json_interface.rs#L6-L15: remove this local definition and import the shared helper.
  • baml_language/crates/baml_tests/tests/tostring_sugar.rs#L7-L16: remove this local definition and import the shared helper.
🤖 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_tests/tests/to_json_interface.rs` around lines 6 -
15, Extract the duplicated compile_errors helper into a shared test utility,
preserving its current diagnostic filtering and formatting behavior. In
baml_language/crates/baml_tests/tests/to_json_interface.rs lines 6-15 and
baml_language/crates/baml_tests/tests/tostring_sugar.rs lines 7-16, remove the
local compile_errors definitions and import the shared helper instead.
🤖 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_tests/baml_src/ns_array_rest_binding/array_rest_binding.baml`:
- Around line 230-237: Strengthen arb_rest_bind_chain_aliases_same_slice so the
test mutates one chained rest binding before comparing through the other,
proving r and s alias the same slice rather than merely sharing its initial
length. Update the expected assertion in rest_bind_chain_aliases_same_slice to
reflect the mutation while preserving the existing binding pattern.

In
`@baml_language/crates/baml_tests/baml_src/ns_cancel_cascade/cancel_cascade.baml`:
- Around line 15-17: Update the cancellation test around the waiter spawn so it
emits a deterministic readiness signal after entering the await path, then wait
for that signal before calling waiter.cancel(). Preserve the existing slow task
and await slow behavior, ensuring cancellation exercises the await-race path
rather than pre-start cancellation.
- Around line 21-24: Remove local bindings of catch-expression results across
the affected tests: in
baml_language/crates/baml_tests/baml_src/ns_cancel_cascade/cancel_cascade.baml:21-24,
set a cancellation flag inside the catch arm and assert that flag inline; in
baml_language/crates/baml_tests/baml_src/ns_csv/csv_smoke.baml:126-137, mutate
step and done directly within the match and catch branches; in
baml_language/crates/baml_tests/baml_src/ns_errorcontext/errorcontext.baml:139-150,
have the helper return the catch expression and bind only the normal helper-call
result. Keep catch outcomes out of local bindings while preserving each test’s
existing assertions.

In
`@baml_language/crates/baml_tests/baml_src/ns_comparable_sort/comparable_sort.baml`:
- Around line 247-249: Update the explicit-binding test path by adding a helper
that assigns the result of high.compare(low) to a local variable and returns
that variable, then have phase2_user_class_compare_with_explicit_binding_in_main
assert through that helper instead of calling phase2_compare_main directly.
Preserve the expected result of 1.
- Around line 470-480: Update the float parity inputs in parity_main by
replacing or supplementing the existing 0.0 entry with a representable
negative-zero value in both f and g. Keep the arrays otherwise identical so
check validates native and comparator sorting across the ±0 boundary.

In `@baml_language/crates/baml_tests/baml_src/ns_fs/fs_from_rust.baml`:
- Around line 117-126: Avoid retaining catch-expression results in local let
bindings across all listed sites: in fs_from_rust.baml at lines 117-126, 49-56,
89-102, 158-166, 180-188, 203-210, 226-233, 248-257, 290-297, 330-337, and
369-376, perform message checks, boolean assertions, returns, and cleanup
directly within the catch/result branches; in glob.baml at lines 357-368 and
392-405, move cleanup into both result paths and return or assert the catch
expression inline. Preserve each helper’s existing validation and cleanup
behavior without assigning the caught value or branch result to threw or another
local binding.

In
`@baml_language/crates/baml_tests/baml_src/ns_interfaces_associated_types/interfaces_associated_types.baml`:
- Around line 38-48: Update atp_throws_main so both AlwaysFails
{}.value_plus_one() catch and call_value(AlwaysFails {}) catch expressions are
consumed inline in the returned expression instead of being assigned to
default_result and generic_result locals. Preserve the existing catch behavior
and explicit string conversion while avoiding boxed local results.

In `@baml_language/crates/baml_tests/baml_src/ns_interfaces/interfaces_2.baml`:
- Around line 43-60: Update F1saDescribable.describe and its F1saPair
implementation so describe accesses at least one receiver field through self,
while preserving the existing "a pair" result expected by f1sa_main and the
regression test.

In `@baml_language/crates/baml_tests/baml_src/ns_interfaces/interfaces.baml`:
- Around line 759-766: Update gbr_first_name to be generic with a type parameter
T constrained by GbrNamed, accepting T[] while returning the first item’s name.
Keep gbr_main’s concrete dogs array unchanged so the test exercises the generic
bound rather than only interface-array access.

In
`@baml_language/crates/baml_tests/baml_src/ns_streaming_parsing/streaming_parsing.baml`:
- Around line 139-146: The catch result is incorrectly stored in a local before
assertion; assert each catch expression inline, then cancel the task and return
true. Apply this in
baml_language/crates/baml_tests/baml_src/ns_streaming_parsing/streaming_parsing.baml
lines 139-146,
baml_language/crates/baml_tests/baml_src/ns_streaming_sse_primitives/streaming_sse_primitives.baml
lines 115-131, and the same file lines 324-340, preserving each test’s existing
error-status expectation.

---

Outside diff comments:
In `@baml_language/crates/baml_tests/tests/http.rs`:
- Around line 259-260: Restore host-backed timeout-failure coverage: in
baml_language/crates/baml_tests/tests/http.rs:259-260, add a silent-server HTTP
timeout test or equivalent; in
baml_language/crates/baml_tests/tests/net.rs:128-154, retain a TCP read that
genuinely expires and asserts the timeout error; and in
baml_language/crates/baml_tests/tests/net.rs:219-248, retain a UDP receive that
genuinely expires and asserts the timeout error.

---

Nitpick comments:
In `@baml_language/crates/baml_tests/tests/to_json_interface.rs`:
- Around line 6-15: Extract the duplicated compile_errors helper into a shared
test utility, preserving its current diagnostic filtering and formatting
behavior. In baml_language/crates/baml_tests/tests/to_json_interface.rs lines
6-15 and baml_language/crates/baml_tests/tests/tostring_sugar.rs lines 7-16,
remove the local compile_errors definitions and import the shared helper
instead.
🪄 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: 5a81790f-a3f4-467b-9be1-3d444bc26e54

📥 Commits

Reviewing files that changed from the base of the PR and between 1ebf901 and 16c40db.

⛔ Files ignored due to path filters (35)
  • baml_language/crates/baml_tests/snapshots/baml_src/_root.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/array_length_snapshot.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/array_rest_binding.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/cleanup.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/comparable_sort.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/const_bindings.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/defer.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/errorcontext.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/from_json_interface.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/gc.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/google_llm_env.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/http.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/interfaces.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/interfaces_associated_types.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/interfaces_class_generics.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/net.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/parse_companions.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/prompt_tag_runtime.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/promptast_accessors.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/streaming_parsing.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/streaming_sse_primitives.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/string_regressions.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/tagged_template_runtime.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/to_json_interface.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/to_string_interface.snap is excluded by !**/*.snap
  • baml_language/crates/baml_tests/snapshots/baml_src/tostring_sugar.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/wildcard_type_inference.snap is excluded by !**/*.snap
📒 Files selected for processing (72)
  • .github/workflows/cargo-tests.reusable.yaml
  • baml_language/Cargo.toml
  • baml_language/crates/baml_cli/tests/common/mod.rs
  • baml_language/crates/baml_cli/tests/exit_code_e2e.rs
  • baml_language/crates/baml_cli/tests/pack_e2e.rs
  • baml_language/crates/baml_tests/baml_src/ns_array_length_snapshot/array_length_snapshot.baml
  • baml_language/crates/baml_tests/baml_src/ns_array_rest_binding/array_rest_binding.baml
  • baml_language/crates/baml_tests/baml_src/ns_cancel_cascade/cancel_cascade.baml
  • baml_language/crates/baml_tests/baml_src/ns_cleanup/cleanup.baml
  • baml_language/crates/baml_tests/baml_src/ns_comparable_sort/comparable_sort.baml
  • baml_language/crates/baml_tests/baml_src/ns_const_bindings/const_bindings.baml
  • baml_language/crates/baml_tests/baml_src/ns_csv/csv_smoke.baml
  • baml_language/crates/baml_tests/baml_src/ns_defer/defer.baml
  • baml_language/crates/baml_tests/baml_src/ns_env/env.baml
  • baml_language/crates/baml_tests/baml_src/ns_errorcontext/errorcontext.baml
  • baml_language/crates/baml_tests/baml_src/ns_exceptions/exceptions.baml
  • baml_language/crates/baml_tests/baml_src/ns_floats/floats.baml
  • baml_language/crates/baml_tests/baml_src/ns_from_json_interface/from_json_interface.baml
  • baml_language/crates/baml_tests/baml_src/ns_fs/fs_from_rust.baml
  • baml_language/crates/baml_tests/baml_src/ns_gc/gc.baml
  • baml_language/crates/baml_tests/baml_src/ns_glob/glob.baml
  • baml_language/crates/baml_tests/baml_src/ns_google_llm_env/google_llm_env.baml
  • baml_language/crates/baml_tests/baml_src/ns_http/http.baml
  • baml_language/crates/baml_tests/baml_src/ns_interfaces/interfaces.baml
  • baml_language/crates/baml_tests/baml_src/ns_interfaces/interfaces_2.baml
  • baml_language/crates/baml_tests/baml_src/ns_interfaces/interfaces_3.baml
  • baml_language/crates/baml_tests/baml_src/ns_interfaces_associated_types/interfaces_associated_types.baml
  • baml_language/crates/baml_tests/baml_src/ns_interfaces_class_generics/interfaces_class_generics.baml
  • baml_language/crates/baml_tests/baml_src/ns_json_auto_derive/json_auto_derive.baml
  • baml_language/crates/baml_tests/baml_src/ns_net/net.baml
  • baml_language/crates/baml_tests/baml_src/ns_parse_companions/parse_companions.baml
  • baml_language/crates/baml_tests/baml_src/ns_prompt_tag_runtime/prompt_tag_runtime.baml
  • baml_language/crates/baml_tests/baml_src/ns_promptast_accessors/promptast_accessors.baml
  • baml_language/crates/baml_tests/baml_src/ns_shell/shell.baml
  • baml_language/crates/baml_tests/baml_src/ns_streaming_parsing/streaming_parsing.baml
  • baml_language/crates/baml_tests/baml_src/ns_streaming_sse_primitives/streaming_sse_primitives.baml
  • baml_language/crates/baml_tests/baml_src/ns_string_regressions/string_regressions.baml
  • baml_language/crates/baml_tests/baml_src/ns_tagged_template_runtime/tagged_template_runtime.baml
  • baml_language/crates/baml_tests/baml_src/ns_to_json_interface/to_json_interface.baml
  • baml_language/crates/baml_tests/baml_src/ns_to_string_interface/to_string_interface.baml
  • baml_language/crates/baml_tests/baml_src/ns_tostring_sugar/tostring_sugar.baml
  • baml_language/crates/baml_tests/baml_src/ns_type_error_repro/type_error_repro.baml
  • baml_language/crates/baml_tests/baml_src/ns_wildcard_type_inference/wildcard_type_inference.baml
  • baml_language/crates/baml_tests/tests/array_length_snapshot.rs
  • baml_language/crates/baml_tests/tests/array_rest_binding.rs
  • baml_language/crates/baml_tests/tests/byte_strings.rs
  • baml_language/crates/baml_tests/tests/cancel_cascade.rs
  • baml_language/crates/baml_tests/tests/cleanup.rs
  • baml_language/crates/baml_tests/tests/comparable_sort.rs
  • baml_language/crates/baml_tests/tests/env.rs
  • baml_language/crates/baml_tests/tests/errorcontext.rs
  • baml_language/crates/baml_tests/tests/exceptions.rs
  • baml_language/crates/baml_tests/tests/floats.rs
  • baml_language/crates/baml_tests/tests/from_json_interface.rs
  • baml_language/crates/baml_tests/tests/fs.rs
  • baml_language/crates/baml_tests/tests/glob.rs
  • baml_language/crates/baml_tests/tests/google_llm_env.rs
  • baml_language/crates/baml_tests/tests/http.rs
  • baml_language/crates/baml_tests/tests/interfaces_associated_types.rs
  • baml_language/crates/baml_tests/tests/interfaces_class_generics.rs
  • baml_language/crates/baml_tests/tests/json_auto_derive.rs
  • baml_language/crates/baml_tests/tests/net.rs
  • baml_language/crates/baml_tests/tests/prompt_tag_e2e.rs
  • baml_language/crates/baml_tests/tests/prompt_tag_runtime.rs
  • baml_language/crates/baml_tests/tests/shell.rs
  • baml_language/crates/baml_tests/tests/streaming_parsing.rs
  • baml_language/crates/baml_tests/tests/tagged_template_runtime.rs
  • baml_language/crates/baml_tests/tests/to_json_interface.rs
  • baml_language/crates/baml_tests/tests/to_string_interface.rs
  • baml_language/crates/baml_tests/tests/tostring_sugar.rs
  • baml_language/crates/baml_tests/tests/type_error_repro.rs
  • baml_language/crates/baml_tests/tests/wildcard_type_inference.rs
💤 Files with no reviewable changes (3)
  • baml_language/crates/baml_tests/baml_src/ns_json_auto_derive/json_auto_derive.baml
  • baml_language/crates/baml_tests/tests/interfaces_class_generics.rs
  • baml_language/crates/baml_tests/tests/to_string_interface.rs

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 17, 2026 08:22 Inactive
…s to Rust

The `baml_src` corpus test flaked ~40% under full-suite nextest load. The
failing block was `net_read_timeout_fires`: the migration replaced the
original Rust controlled silent server (a tokio listener held open past the
client deadline) with `baml.http.Server.bind()` relying on an unaccepted
backlog connection. That BAML listener object can be GC-collected between
`connect` and the throwing `read`, resetting the connection into a
`baml.errors.Io` error instead of the expected `Timeout`, so the `catch
Timeout` misses and the block fails — intermittently, only under GC/CPU
pressure (hence it passed standalone and in isolated verification).

- Move `net_read_timeout_fires` (tests/net.rs) and `http_fetch_timeout_fires`
  (tests/http.rs, same latent listener-GC pattern) back to Rust with their
  original controlled silent servers. `ns_http` had no other blocks, so it's
  removed. `net.snap`/`_root.snap` regenerated.
- Keep `net_udp_recv_timeout_fires` in the corpus: no listener to reset, and
  with no sender a `recv_from` deadline can only expire into `Timeout`.
- Isolate the corpus runner's BAML_CACHE_DIR/BAML_HOME per run so the CLI no
  longer writes `.baml/cache` into the source tree that the bytecode /
  emit-determinism / link-oracle tests scan concurrently; make
  `collect_baml_files` skip dot-dirs as defense-in-depth.
- Reconcile the canary merge: its new `generate_go_writes_sdk_through_cli`
  used `ensure_built()` against this branch's `run_baml_cli(&Path)` signature;
  switch it to `baml_cli()` (it only runs `baml generate`).

Verified: 3x full `cargo nextest run -p baml_tests` all green (2822 passed).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01J2XzpcdbF2ddFDrCgc7fuF
@vercel
vercel Bot temporarily deployed to Preview – beps July 17, 2026 09:32 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 17, 2026 09:39 Inactive
CodeRabbit flagged five corpus tests that were faithful ports of already-weak
Rust originals — each passed without exercising the behavior its name claims.
Strengthen them so the assertion actually depends on that behavior. All still
pass (full corpus: 2467/0), confirming the underlying BAML semantics hold.

- rest_bind_chain_aliases_same_slice: push through one chained binding and
  observe it via the other (44), proving `r`/`s` alias one slice rather than
  sharing an initial length (33).
- phase2_user_class_compare_with_explicit_binding_in_main: call a helper that
  binds `high.compare(low)` to a local first, instead of duplicating the
  direct-call test.
- parity float inputs: add a representable -0.0 so native and comparator sort
  are checked across the ±0 total-order boundary the comment promised.
- form1_self_accesses_receiver_fields: `describe` returns `self.label` (a real
  field read) instead of a constant.
- generic_bound_runtime: `gbr_first_name<T extends GbrNamed>(items: T[])` over
  a concrete `GbrDog[]`, exercising a generic bound rather than interface-array
  access.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01J2XzpcdbF2ddFDrCgc7fuF
@vercel
vercel Bot temporarily deployed to Preview – beps July 17, 2026 09:49 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 17, 2026 09:56 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 17, 2026 10:10 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps July 17, 2026 17:26 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 17, 2026 17:33 Inactive
@hellovai

Copy link
Copy Markdown
Contributor Author

@coderabbitai I've addressed this review — summary by comment. (The review predates commit 936a462, which is why it's still marked changes-requested.)

Strengthened (commit 936a462) — each was a faithful port of an already-weak Rust original; all now exercise the behavior their name claims, and all still pass (full corpus 2467/0):

  • rest_bind_chain_aliases_same_slice: pushes through one chained binding and observes it via the other (→44), proving r/s alias one slice.
  • phase2_user_class_compare_with_explicit_binding_in_main: added a helper that binds high.compare(low) to a local before returning.
  • parity float inputs: added a representable -0.0 for the ±0 total-order boundary.
  • form1_self_accesses_receiver_fields: describe now returns self.label (a real field read).
  • generic_bound_runtime: gbr_first_name<T extends GbrNamed>(items: T[]) over a concrete GbrDog[].

Not changed — the "catch result in a local let may stay boxed" comments (cancel_cascade L21-24, fs_from_rust, glob, csv_smoke, errorcontext, interfaces_associated_types, streaming_*): these are false positives here. That VM boxing quirk is specific to test-block locals; every flagged binding is inside a helper function, which is the documented workaround for exactly that quirk (see the ns_bigints header). These pass deterministically across repeated full-suite runs, which a real boxing failure would not allow.

Not changed — cancel_unblocks_await_on_non_descendant "synchronize before cancelling": faithful port of the Rust original, which also cancels with no readiness signal. It verifies the outcome that matters — cancelling waiter makes await waiter observe Cancelled in <5s instead of blocking ~60s on slow — which holds whether cancel lands before or after the await parks. Forcing the parked-await path specifically would need a BAML readiness primitive.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== Follow-up commit =='
git show --stat --oneline --decorate --no-renames 936a462b4

echo '== Locate named corpus files =='
fd -a -t f -e baml . baml_language/crates/baml_tests/baml_src | \
  rg '(array_rest_binding|comparable_sort|interfaces_2|interfaces_class_generics|cancel_cascade|bigints|fs_from_rust|glob|csv_smoke|errorcontext|interfaces_associated_types|streaming_)'

echo '== Strengthened-test snippets =='
rg -n -A20 -B8 \
  'rest_bind_chain_aliases_same_slice|phase2_compare_explicit_binding_main|phase2_user_class_compare_with_explicit_binding_in_main|parity_main|form1_self_accesses_receiver_fields|generic_bound_runtime|gbr_first_name' \
  baml_language/crates/baml_tests/baml_src

echo '== Boxing-workaround and affected helper scopes =='
rg -n -A14 -B5 \
  'boxing|boxed|catch \(e\)|let .*catch|catch.*let|function .*fn|function .*main' \
  baml_language/crates/baml_tests/baml_src/ns_bigints \
  baml_language/crates/baml_tests/baml_src/ns_cancel_cascade \
  baml_language/crates/baml_tests/baml_src/ns_fs \
  baml_language/crates/baml_tests/baml_src/ns_glob \
  baml_language/crates/baml_tests/baml_src/ns_csv \
  baml_language/crates/baml_tests/baml_src/ns_errorcontext \
  baml_language/crates/baml_tests/baml_src/ns_interfaces_associated_types \
  baml_language/crates/baml_tests/baml_src/ns_streaming_parsing \
  baml_language/crates/baml_tests/baml_src/ns_streaming_sse_primitives || true

echo '== Cancellation test and original Rust test =='
rg -n -A35 -B10 \
  'cancel_unblocks_await_on_non_descendant|non_descendant|waiter|slow' \
  baml_language/crates/baml_tests/baml_src/ns_cancel_cascade \
  baml_language/crates/baml_tests/tests/cancel_cascade.rs

Length of output: 200140


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== Exact follow-up diff =='
git show --format=fuller --find-renames --find-copies -- \
  936a462b4 \
  baml_language/crates/baml_tests/baml_src/ns_array_rest_binding/array_rest_binding.baml \
  baml_language/crates/baml_tests/baml_src/ns_comparable_sort/comparable_sort.baml \
  baml_language/crates/baml_tests/baml_src/ns_interfaces/interfaces_2.baml \
  baml_language/crates/baml_tests/baml_src/ns_interfaces_class_generics/interfaces_class_generics.baml

echo '== Narrow current assertions =='
rg -n -A16 -B6 \
  'arb_rest_bind_chain_aliases_same_slice|rest_bind_chain_aliases_same_slice|phase2_compare_explicit_binding_main|phase2_user_class_compare_with_explicit_binding_in_main|float_nan_sort_main|parity_main|form1_self_accesses_receiver_fields|gbr_first_name|generic_bound_runtime' \
  baml_language/crates/baml_tests/baml_src/ns_array_rest_binding/array_rest_binding.baml \
  baml_language/crates/baml_tests/baml_src/ns_comparable_sort/comparable_sort.baml \
  baml_language/crates/baml_tests/baml_src/ns_interfaces/interfaces_2.baml \
  baml_language/crates/baml_tests/baml_src/ns_interfaces_class_generics/interfaces_class_generics.baml

Length of output: 18331


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -A18 -B8 \
  'gbr_first_name|generic_bound_runtime|GbrNamed|GbrDog' \
  baml_language/crates/baml_tests/baml_src

Length of output: 4667


@hellovai Thanks for the detailed breakdown. I verified the five strengthened tests, including the concrete GbrDog[] generic-bound path.

I also confirmed the local-boxing issue is documented as specific to test {}-block locals; the flagged catch results are all contained in top-level helper functions. The cancellation test’s bounded Cancelled outcome is appropriate for the available BAML synchronization primitives, and it correctly tears down slow.

Re-reviewing the updated PR now.


✏️ Learnings added
Learnt from: hellovai
URL: https://github.com/BoundaryML/baml/pull/4075

Timestamp: 2026-07-17T17:47:23.706Z
Learning: In the BAML corpus under `baml_language/crates/baml_tests/baml_src`, the VM local-boxing workaround applies to locals declared directly in `test {}` blocks. Tests that require local bindings should place their logic in top-level helper functions and have the `test {}` block assert on the helper’s returned scalar.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 17, 2026 17:48 Inactive
@hellovai
hellovai added this pull request to the merge queue Jul 17, 2026
Merged via the queue into canary with commit 6217713 Jul 17, 2026
62 of 63 checks passed

This branch was previously deployed

3 inactive deployments
Preview – promptfiddle — f44dca60 Deployed Jul 17, 2026 by vercel[bot]
Preview – promptfiddle2 — f44dca60 Deployed Jul 17, 2026 by vercel[bot]
Preview – beps — f44dca60 Deployed Jul 17, 2026 by vercel[bot]
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