Skip to content

bcu: add baml_bcu crate and move PackageInterface/BcuMeta out of TIR - #5845

Open
hellovai wants to merge 10 commits into
kai/mir-stack-rebasedfrom
claude/bcu-meta-rebased
Open

hellovai wants to merge 10 commits into
kai/mir-stack-rebasedfrom
claude/bcu-meta-rebased

Conversation

@hellovai

@hellovai hellovai commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Stack (on top of kai/mir-stack-rebased)

  1. bcu: add baml_bcu crate and move PackageInterface/BcuMeta out of TIR #5845 (claude/bcu-meta-rebased): baml_bcu crate + .bmeta (replaces bcu: add baml_bcu crate and move PackageInterface/BcuMeta out of TIR #5827) (this PR)
  2. bcu: add BcuModule (.bcu), parallel baml_mir_linker, and Salsa-free emit pipeline #5846 (claude/bcu-module-rebased): BcuModule (.bcu) + parallel baml_mir_linker + Salsa-free emit (replaces bcu: add BcuModule (.bcu), parallel baml_mir_linker, and Salsa-free emit pipeline #5830)
  3. feat(cranelift): vendor cranelift-codegen 0.138 with AArch64 LSE2 + x86_64 AVX 128-bit atomics #5849 (claude/cranelift-vendor-rebased): Vendor cranelift-codegen 0.138 + LSE2/AVX 128-bit atomics (from feat(cranelift): vendor cranelift-codegen 0.138 and add AArch64 LSE2 + x86_64 AVX 128-bit atomics #5844)
  4. feat(cranelift,bex2): add Cranelift AOT backend, bex2 M:N runtime, and baml pack --native #5850 (claude/cranelift-bex2-rebased): Cranelift AOT backend + bex2 M:N runtime + baml pack --native (squashes feat(cranelift): add clean-room Cranelift AOT backend, runtime, and baml pack --native #5839, perf(cranelift): pinned mutator register, CallConv::Tail, TCO, scalar call ABI, and can_throw elision #5842, feat(cranelift): native 128-bit atomic Value slots across ABI, runtime, and Cranelift (no BUSY_BIT, unvendored) #5843, feat(cranelift): vendor cranelift-codegen 0.138 and add AArch64 LSE2 + x86_64 AVX 128-bit atomics #5844, feat(bex2): M:N work-stealing runtime, shared-heap GC, wait-free containers, direct-poll Tokio I/O, and two-tier package init #5847)

Rebased replacement for #5827 on top of kai/mir-stack-rebased (adapted for upstream ExportedClassBody).

Why

  • Establish a pure, target-independent, Salsa-free wire-format crate (baml_bcu) for BAML package artifacts (.bmeta now, .bcu next), decoupled from compiler internals (baml_compiler*, salsa, bex_*, baml_linker*).
  • Move the existing .bmeta surface (PackageInterface<N> and WireInterface, renamed BcuMeta) out of baml_compiler2_hir_ty without changing Borsh wire layout.

What changes

Creates baml_language/crates/baml_bcu, moves BuiltinKind into baml_type, moves PackageInterface<N> + BcuMeta (formerly WireInterface) and all pure interface export structs (including ExportedClassBody) into baml_bcu, adds a deterministic sigil-free .bmeta text printer, and enforces baml_bcu dependency purity in baml_language/stow.toml.

The situation

Downstream compilation, runtime mounting, precompiled stdlib seeding, and future native backends all consume a package's typed export surface (.bmeta). Previously, those wire structs lived inside baml_compiler2_hir_ty/src/package_interface.rs, forcing any consumer of .bmeta to depend on the entire Salsa-backed TIR crate.

Before

baml_compiler2_hir_ty (pulls in salsa + HIR + AST + parser)
  └── package_interface.rs
        ├── pub struct WireInterface { claimed, compiler_version, dependencies, rows }
        └── pub struct PackageInterface<N = DeclName> { types, functions, values, throw_sets, namespaces, impls, reexports }

baml_compiler2_ast
  └── pub enum BuiltinKind { Vm, Io, Intrinsic, AwaitAny, Spawn }
  • No standalone wire crate existed for .bmeta, and stow.toml had no salsa or baml_linker* guardrails for wire crates.
  • No human-readable text renderer existed for inspecting .bmeta blobs.

After

baml_type
  └── pub enum BuiltinKind { Vm, Io, Intrinsic, AwaitAny, Spawn }   // re-exported in baml_compiler2_ast

baml_bcu  (deps: baml_artifact, baml_base, baml_type, baml_version, borsh, indexmap, sha2)
  ├── meta.rs: BcuMeta (was WireInterface), PackageInterface<N>, ExportedClassBody<N>, ExportedType/Function/Value/Impl/ReExport/ExternalCallTarget
  │            + BcuMeta::{encode_artifact, decode_artifact, payload_digest, format_text}
  └── text.rs: deterministic sigil-free BAML text printer (Display for BcuMeta)

baml_compiler2_hir_ty
  └── pub use baml_bcu::{ BcuMeta, ExportedClassBody, PackageInterface, ... };

The concept this changes: .bmeta is owned by a pure wire crate

Where Before After
baml_bcu Did not exist Pure wire crate owning BcuMeta, PackageInterface<N>, and ExportedClassBody<N> (byte-identical Borsh layout)
baml_type Did not own BuiltinKind Owns BuiltinKind (re-exported by baml_compiler2_ast)
baml_language/stow.toml No bcu suffix or salsa/baml_linker* rules Adds "bcu" suffix and forbids baml_bcu from depending on salsa, baml_compiler*, baml_linker*, or bex_*
Callers (hir_ty, baml_db, bex_project, baml_ide, baml_tests) Imported WireInterface from baml_compiler2_hir_ty Uses BcuMeta (re-exported from baml_compiler2_hir_ty or directly from baml_bcu)

What a reader should take away

  • Borsh wire layout is byte-identical. Every enum variant, discriminant, and field order in BcuMeta / PackageInterface / ExportedClassBody / BuiltinKind is preserved verbatim.
  • Crate boundaries are CI-enforced. cargo stow --check guarantees baml_bcu stays free of Salsa, compiler crates, linker crates, and VM crates as .bcu MIR types are added next.

Observable changes

  • cargo run --profile fasttest -p cargo-stow -- stow --check: 0 violations.
  • cargo test --profile fasttest -p baml_bcu: 3/3 passed.
  • cargo test --profile fasttest -p baml_tests --test hir_ty_package_interface --test mounted_package_parity --test runtime_mount_parity: 37/37 + 13/13 + 2/2 passed.
  • cargo clippy --profile fasttest --no-deps --tests -p baml_bcu -p baml_type -p baml_compiler2_hir_ty -p baml_db -p bex_project -p baml_ide -p baml_cli -- -D warnings: 0 warnings.

…the Rust registry is gone (#5786)

- testing: gate leaves on a global semaphore, and call untimed bodies directly
- testing: drop registry helpers nothing calls
- testing: a file's tests are a global, and the registry is built in BAML
- testing: count duplicate test names in BAML, and delete the Rust counters
- testing: count duplicate names on the collector
- testing: the semaphore belongs to the run, not to a package global
- testing: delete `$invoke_collector` and the IDE category it alone filled
- cli: `baml test --list` asks BAML every time, and Rust filters nothing
- testing: a package lists its test files in one compiler-written global
- testing: a failed verdict with no failed leaf counts as a failure in BAML
- mir: self of a generic class's method is declared with the class's type parameters
- mir: await and system-operation temporaries are declared with their own types
- mir: an inlined callee's locals are declared in the caller's type parameters
- mir: the verifier checks the types locals are declared with
…dia.Media (#5797)

- compiler: image, audio, video and pdf name the baml.media classes
- stdlib: media is an interface the four media classes implement
- sdks: host media values have no base64 accessor
- mir: the media classes are ordinary classes to MIR
- bridge: a host PDF built from a URL defaults to application/pdf
- compiler: a class records whether it implements baml.media.Media
- vm: the interpreter knows media by the class, not by a media type
- stdlib: the media classes give their own JSON form
- compiler: the media classes reach the interpreter as classes
@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
developer-docs Ready Ready Preview Dec 3, 2026 5:56am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d3bd4692-0e15-44c1-89e1-2fff53190276

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
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

…IME type says what it is (#5797)

- compiler: media leaves the compiler and runtime type families
- stdlib: the MIME type tells the ai package and providers what media is
- vm: delete the media code nothing reaches any more
…5798, #5799, #5800, #5801)

- mir: a value is read at the type the checker narrowed it to, and self has the checker's type (#5798)
- cli: baml mir prints the MIR of a project, file, package or snippet
- mir: the verifier counts contract rule sites, and baml mir --verify
- mir: run-time signatures and impl rules are queries beside MIR
…5802, #5803)

- reflect: Session and session submissions are no longer in the language
- package: another package can name a body an implements block provides
…urning calls, intrinsics, typed operators (#5804 to #5817, #5829)

- mir: calls the checker can resolve are direct, unions call per member
- mir: for loops run the iterator protocol, with no array special case
- mir: a call that cannot return writes never and stops
- mir: intrinsics have one signature table and the verifier asserts it
- mir: a call to an I/O function is a call, sys_op is gone
- mir: a defaulted parameter is read through is_omitted and take
- mir: global initializers and $init are MIR functions
- mir: a compiler temporary is unknown only when the program says so
- mir: a copy keeps its type, narrow and widen change it
- mir: operators are typed instructions, decided once in lowering
- hir: package functions and package order are shared functions
- baml: use const for top-level client values
- docs: refresh the vision client annotations
- Remove remaining legacy client declarations from examples
- cache: remove bex_cache and CLI disk bytecode/diagnostics cache
- cache: prune remaining dead cache counters, test helpers, and stale comments
Move BuiltinKind into baml_type (re-exported by baml_compiler2_ast), create the pure Salsa-free baml_bcu crate with BcuMeta and PackageInterface<N> (preserving exact Borsh wire layout), add artifact encode/decode, payload digest, and sigil-free text formatter, enforce baml_bcu boundaries in stow.toml (forbidding salsa and baml_linker*), and re-export from baml_compiler2_hir_ty while renaming WireInterface to BcuMeta across callers.

This branch was successfully deployed

1 active deployment
Preview – developer-docs — e424b527 Deployed Dec 3, 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