Repository navigation
Generate boundary's native dispatch from its .baml - #4116
Conversation
boundary was the last package still hand-wiring its natives: a match over string paths that nothing kept in sync with the .baml declarations, plus per-native arity checks, argument conversion, and result-to-NativeCallResult boilerplate the generated glue already writes. It now goes through the generated BamlPackageBoundary hierarchy like baml and reflect: the three natives become required trait methods that receive converted arguments (LocalId.capture takes Option<bool> triples instead of unpacking raw Values), the LocalId constructor builds through the generated copy:: struct, and the hand-written optional_bool helper is gone. log, assert, and testing declare no natives (log is all compiler intrinsics), so no other package is affected.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughBoundary native functions are added to build-time generation, exposed through a generated module, and registered through the trait-based VM dispatcher. Boundary ID and LocalId entrypoints now use typed trait implementations and direct state/value conversions. ChangesBoundary dispatcher migration
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
⏭️ Performance benchmarks were skippedPerf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to To run them on this PR, do any of the following, then push a commit (or re-run CI):
|
Binary size checks passed✅ 7 passed
Generated by |
Follow-up to #4099, which made
baml_builtins2_codegenpackage-generic and movedreflectonto it.boundarywas the last package still hand-wiring its natives.What it was
Nothing kept that in sync with the
.bamldeclarations: adding a$rust_functionand forgetting an arm gave a runtime lookup miss, not a build error. Each native also hand-rolled the boilerplate the generated glue already writes: arity checks, argument conversion, and theResult->NativeCallResultmatch.What it is now
boundarygenerates itsBamlPackageBoundary/BamlNamespaceId/BamlClassLocalIdhierarchy likebamlandreflect(three lines inbex_vm/build.rs), so:$rust_functionwithout an implementation is a compile error;LocalId.capturetakesOption<bool>triples instead of unpacking rawValues, and the hand-writtenoptional_boolhelper is deleted;LocalIdconstructor builds through the generatedcopy::LocalIdstruct instead of a positionalalloc_instance(vec![...]);VM_NATIVE_PACKAGESnow points every package at a generated dispatcher, so no entry in it can drift.Scope
I checked the other stdlib packages:
logis entirely$compiler_intrinsic(no natives), andassertandtestingdeclare none, soboundarywas the only remaining offender.Net +10 lines (the generation loop entry and trait scaffolding, minus the deleted dispatch and glue). Verified:
bex_vm+baml_tests2929 passing,baml_cli+bex_engine976 passing, clippy clean.Summary by CodeRabbit