Skip to content

refactor(mir): remove dead visualization nodes from MIR - #4633

Merged
antoniosarosi merged 1 commit into
canaryfrom
antoniosarosi/remove-mir-viz
Aug 30, 2026
Merged

antoniosarosi merged 1 commit into
canaryfrom
antoniosarosi/remove-mir-viz

Conversation

@antoniosarosi

@antoniosarosi antoniosarosi commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The MIR still carried the remnants of the original playground animation scheme, where viz opcodes were inserted around every control-flow statement:

  • StatementKind::VizEnter / StatementKind::VizExit
  • VizNode, VizNodeType
  • MirFunctionBody::viz_nodes
  • MirBuilder::add_viz_node (zero callers)

None of it is used anymore:

  • The last producers (the //# header lowering in lower.rs) were removed in paulo/rust functions 2 #3247.
  • The VM opcode and VizNodeMeta were dropped in refactor(tracing): trim the event-stream surface for a fresh start #3616; since then emit.rs has treated both statements as explicit no-ops.
  • bex_vm, bex_vm_types, bex_engine, bex_events, bex_project and bridge_wasm have zero viz references.
  • The live playground (typescript2/pkg-playground) builds its graph from the AST via baml_compiler2_visualization and derives node run-state from the RunPatch/RunSnapshot event stream, not from bytecode.

This PR deletes the types, variants, field and builder helper, plus the ~20 pass-through match arms and test struct literals that referenced them. Nothing under engine/ or typescript/ is touched — those trees are legacy and carry their own complete viz system.

No .snap, .md or TS file referenced viz_enter/viz_exit/VizNode, so output is unchanged. Net −115/+7.

Test plan

  • cargo fmt with repo config
  • cargo clippy --workspace --all-targets -- -D warnings (clean)
  • cargo test --lib — green for baml_tests (954), baml_compiler2_*, baml_db, baml_ide, bex_vm, bex_engine, bex_project; only failures locally are environment-only (baml_bridge needs a prebuilt libbridge_cffi.dylib, sdk_test_* need external toolchains, one bex_prof_store StreamInUse flake that passes in isolation)

https://claude.ai/code/session_01Qai5VpnzsTj8SxtmDXB9Tz

Summary by CodeRabbit

  • Refactor
    • Removed control-flow visualization data and processing from the compiler’s intermediate representation.
    • Simplified MIR generation, optimization, validation, stack handling, bytecode emission, and pretty-printing.
    • Updated compiler test fixtures to reflect the streamlined representation.

The MIR still carried `StatementKind::VizEnter`/`VizExit`, `VizNode`,
`VizNodeType`, `MirFunctionBody::viz_nodes` and
`MirBuilder::add_viz_node`, left over from the original playground
animation scheme that inserted viz opcodes around control flow. Nothing
has produced these since the `//# header` lowering was removed in #3247,
and the emitter has treated them as no-ops since the VM opcode was
dropped in #3616. The live playground builds its graph from the AST
(`baml_compiler2_visualization`) and animates nodes from the run event
stream, so the MIR surface is unused.

Delete the variants, types, field and builder helper, and the
pass-through match arms and test struct literals that referenced them.
No snapshot references `viz_enter`/`viz_exit`, so output is unchanged.

Claude-Session: https://claude.ai/code/session_01Qai5VpnzsTj8SxtmDXB9Tz
@vercel

vercel Bot commented Aug 30, 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 30, 2026 1:18pm
promptfiddle2 Ready Ready Preview Aug 30, 2026 1:18pm

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.

@vercel
vercel Bot temporarily deployed to Preview – beps August 30, 2026 13:10 Inactive
@coderabbitai

coderabbitai Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0cce57ba-f666-48b1-af21-bef2e57830d8

📥 Commits

Reviewing files that changed from the base of the PR and between ccd8198 and 9923b6b.

📒 Files selected for processing (9)
  • baml_language/crates/baml_compiler2_emit/src/analysis.rs
  • baml_language/crates/baml_compiler2_emit/src/emit.rs
  • baml_language/crates/baml_compiler2_emit/src/stack_carry.rs
  • baml_language/crates/baml_compiler2_emit/src/verifier.rs
  • baml_language/crates/baml_compiler2_mir/src/builder.rs
  • baml_language/crates/baml_compiler2_mir/src/ir.rs
  • baml_language/crates/baml_compiler2_mir/src/lower.rs
  • baml_language/crates/baml_compiler2_mir/src/optimize.rs
  • baml_language/crates/baml_compiler2_mir/src/pretty.rs
💤 Files with no reviewable changes (6)
  • baml_language/crates/baml_compiler2_mir/src/pretty.rs
  • baml_language/crates/baml_compiler2_emit/src/verifier.rs
  • baml_language/crates/baml_compiler2_emit/src/emit.rs
  • baml_language/crates/baml_compiler2_mir/src/ir.rs
  • baml_language/crates/baml_compiler2_mir/src/builder.rs
  • baml_language/crates/baml_compiler2_mir/src/lower.rs

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The MIR visualization node data and VizEnter/VizExit statements were removed. MIR construction, optimization, analysis, emission, stack simulation, pretty printing, verification, and test fixtures were updated accordingly.

Changes

MIR visualization removal

Layer / File(s) Summary
Remove visualization MIR contracts
baml_language/crates/baml_compiler2_mir/src/ir.rs
MirFunctionBody no longer stores visualization nodes. StatementKind no longer includes visualization statements. VizNodeType and VizNode were removed.
Update MIR construction
baml_language/crates/baml_compiler2_mir/src/builder.rs, baml_language/crates/baml_compiler2_mir/src/lower.rs
MirBuilder no longer stores or transfers visualization nodes. Missing-function construction no longer initializes the removed field.
Remove downstream visualization handling
baml_language/crates/baml_compiler2_emit/src/*, baml_language/crates/baml_compiler2_mir/src/optimize.rs, baml_language/crates/baml_compiler2_mir/src/pretty.rs
Analysis, optimization, emission, stack simulation, pretty printing, verification, and test fixtures no longer handle the removed visualization data or statements.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 9923b

This change removes unused visualization data and no-op handling from MIR without changing runtime output or supported behavior. No actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: 2kai2kai2

Poem

A rabbit trims the MIR with care
No viz nodes hop through the air
Old enter and exit fade
Clean stacks and tests are made
The compiler rests, uncluttered there

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: removing obsolete visualization nodes and related MIR support.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch antoniosarosi/remove-mir-viz

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 August 30, 2026 13:18 Inactive
@github-actions

Copy link
Copy Markdown

Binary size checks passed

✅ 7 passed

Artifact Platform File Gzip Gated on Baseline Delta Status
✅ baml-cli Linux 🔒 72.6 MB 27.4 MB file 72.9 MB -263.6 KB (-0.4%) OK
✅ packed-program Linux 🔒 28.6 MB 10.9 MB file 28.6 MB -52.3 KB (-0.2%) OK
✅ baml-cli macOS 🔒 63.1 MB 25.1 MB file 63.3 MB -231.4 KB (-0.4%) OK
✅ packed-program macOS 🔒 25.7 MB 10.2 MB file 25.8 MB -60.3 KB (-0.2%) OK
✅ baml-cli Windows 🔒 82.8 MB 27.8 MB file 83.0 MB -277.8 KB (-0.3%) OK
✅ packed-program Windows 🔒 30.8 MB 10.8 MB file 30.9 MB -108.1 KB (-0.3%) OK
✅ bridge_wasm WASM 22.2 MB 🔒 5.7 MB gzip 5.7 MB +19.8 KB (+0.3%) 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

@antoniosarosi
antoniosarosi added this pull request to the merge queue Aug 30, 2026
Merged via the queue into canary with commit 48156d3 Aug 30, 2026
78 of 96 checks passed
@antoniosarosi
antoniosarosi deleted the antoniosarosi/remove-mir-viz branch August 30, 2026 13:45

This branch was previously deployed

2 inactive deployments
Preview – promptfiddle2 — 9923b6b9 Deployed Aug 30, 2026 by vercel[bot]
Preview – beps — 9923b6b9 Deployed Aug 30, 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