baml_language: route vm function execution to BexEngine#3173
baml_language: route vm function execution to BexEngine#3173miguelcsx wants to merge 3 commits intoBoundaryML:canaryfrom
BexEngine#3173Conversation
|
@miguelcsx is attempting to deploy a commit to the Boundary Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughMoves test-only VM construction into a new Changes
Sequence Diagram(s)sequenceDiagram
participant UI as "UI / Runner"
participant CR as "CompilerRunner"
participant RT as "Tokio Runtime"
participant Engine as "bex_engine"
participant Fmt as "Formatter"
UI->>CR: run selected function
CR->>CR: compile_program_with_builtins()
CR->>RT: spawn current-thread runtime
RT->>Engine: init(engine with sysops)
RT->>Engine: function_params(func_idx)
alt requires args
Engine-->>RT: params (non-empty)
RT-->>CR: RequiresArgs(n)
CR-->>UI: update UI (requires args)
else no args
RT->>Engine: call_function(func_idx, [])
Engine-->>RT: BexExternalValue
RT->>Fmt: format_external_value(value)
Fmt-->>RT: String
RT-->>CR: VmExecutionResult::Ok(formatted)
CR-->>UI: update UI (result)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
baml_language/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (6)
baml_language/crates/baml_tests/Cargo.tomlbaml_language/crates/baml_tests/src/bytecode.rsbaml_language/crates/bex_vm/benches/fib.rsbaml_language/crates/bex_vm/src/vm.rsbaml_language/crates/tools_onionskin/Cargo.tomlbaml_language/crates/tools_onionskin/src/compiler.rs
💤 Files with no reviewable changes (1)
- baml_language/crates/bex_vm/src/vm.rs
- use all unsupported instead of driving the VM directly - replaces from_program for the VM-level tests that legitimately need raw bytecode access
- compile vm runner programs with builtins via shared helper - reduce clones/unwraps in bytecode tests and benches - add unit coverage for external value formatting
03d7b5a to
71e6740
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
baml_language/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (6)
baml_language/crates/baml_tests/Cargo.tomlbaml_language/crates/baml_tests/src/bytecode.rsbaml_language/crates/bex_vm/benches/fib.rsbaml_language/crates/bex_vm/src/vm.rsbaml_language/crates/tools_onionskin/Cargo.tomlbaml_language/crates/tools_onionskin/src/compiler.rs
💤 Files with no reviewable changes (1)
- baml_language/crates/bex_vm/src/vm.rs
- reflect correct vm failure
| let Some(function_index) = program.function_index(input.function) else { | ||
| panic!("function not found"); | ||
| }; |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Include function name in panic message for easier debugging.
The panic message would be more helpful if it included the function name that wasn't found.
Proposed fix
let Some(function_index) = program.function_index(input.function) else {
- panic!("function not found");
+ panic!("function '{}' not found", input.function);
};
Why this change
BexVm::from_programlet callers run the VM without the engine, but the engine is where execution correctness lives (event loop, notify/span-notify handling, GC, and consistent result/error propagation). In practice, bypassing it meant re-implementing that logic, and getting edge cases wrong.tools_onionskinwas the only real non-test user, and its custom loop had a user-visible bug:SpanNotifycould be dropped, leaving the final result unset (blank Runner panel). It also treatedNotifyas an error instead of a normal mid-execution event.What this PR does
from_programto prevent bypassing the engine.tools_onionskinto run viaBexEngineusingSysOps::all_unsupported()(safe no-op SysOps), so all intermediate events are handled correctly and results are always set.make_vm()inbaml_testsfor VM-level tests/benchmarks that need direct VM control; everywhere else should useBexEngine.Summary by CodeRabbit
Refactor
Chores
Tests