Skip to content

fix(cli): normalize bytecode-cache rel-paths across platforms - #4208

Closed
antoniosarosi wants to merge 1 commit into
canaryfrom
antoniosarosi/b-748
Closed

antoniosarosi wants to merge 1 commit into
canaryfrom
antoniosarosi/b-748

Conversation

@antoniosarosi

@antoniosarosi antoniosarosi commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • normalize bytecode-cache key, manifest, and compilation-unit source paths to portable / separators
  • keep cache rel-path generation consistent between CacheContext::open, manifest collection, compiler output, and LSP consumers
  • add cross-platform path regressions plus a real on-disk partial-reuse scenario

Root cause

Cache keys, manifest entries, and compiled-unit source_file values were rendered with platform-native separators. That made the serialized cache identity platform-dependent and could make key, manifest, or unit lookups disagree at cache boundaries on Windows.

The macOS temp-root canonicalization half was already fixed on canary by commit 2660b8b9f, which anchors the cache test roots under a canonical temp base; the four partial-reuse tests were already ungated on this baseline. Real on-disk macOS projects were not affected by that test-harness symlink mismatch because project discovery canonicalizes existing roots and source paths, and the new real-project-style regression confirms plan_reuse returns Some with two clean files and one dirty file.

Validation

  • BAML_CACHE_DEBUG=1 cargo test -p baml_cli plan_reuse -- --nocapture (17 passed)
  • cargo test -p bex_cache relative_paths_use_forward_slashes -- --nocapture
  • cargo test -p baml_compiler2_emit relative_source_paths_use_forward_slashes -- --nocapture
  • cargo clippy -p bex_cache -p baml_compiler2_emit -p baml_cli --tests -- -D warnings
  • cargo fmt --all -- --check

Fixes B-748

Summary by CodeRabbit

  • Bug Fixes
    • Improved cache reliability across platforms by standardizing stored file paths.
    • Fixed cache reuse behavior for projects with nested files, allowing unchanged files to remain reusable after edits.
    • Normalized displayed source paths to consistently use forward slashes on Windows and other platforms.

@linear

linear Bot commented Jul 26, 2026

Copy link
Copy Markdown

B-748

@vercel

vercel Bot commented Jul 26, 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 26, 2026 2:09pm
promptfiddle Ready Ready Preview, Comment Jul 26, 2026 2:09pm
promptfiddle2 Ready Ready Preview, Comment Jul 26, 2026 2:09pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 26, 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: ca741a50-29ac-42e5-a73b-cefb6eb5e9ab

📥 Commits

Reviewing files that changed from the base of the PR and between 788d5c0 and 4397863.

📒 Files selected for processing (3)
  • baml_language/crates/baml_cli/src/bytecode_cache.rs
  • baml_language/crates/baml_compiler2_emit/src/lib.rs
  • baml_language/crates/bex_cache/src/lib.rs

📝 Walkthrough

Walkthrough

Cache key inputs, manifest paths, and compiler source paths now use portable root-relative paths with / separators. Tests cover normalized paths, expected cache keys, manifest entries, and partial reuse after editing a nested source file.

Changes

Portable path normalization

Layer / File(s) Summary
Normalize cache path contracts
baml_language/crates/bex_cache/src/lib.rs
rel_path now emits /-separated root-relative paths, with updated key and manifest documentation and unit coverage.
Normalize compiler source paths
baml_language/crates/baml_compiler2_emit/src/lib.rs
relative_source_path normalizes nested project paths to forward slashes and verifies the result with a unit test.
Apply portable paths to cache reuse
baml_language/crates/baml_cli/src/bytecode_cache.rs
Cache key generation uses rel_path; integration coverage verifies portable manifest entries and partial reuse after one file changes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • BoundaryML/baml#3924: Introduced the content-addressed caching code whose path inputs are normalized here.

Suggested reviewers: hellovai

Poem

I’m a bunny with paths in my paws,
Making slashes agree with the laws.
Keys stay neat, manifests align,
Nested files reuse just fine.
Hop, hop—portable by design!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: normalizing bytecode-cache relative paths across platforms.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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 antoniosarosi/b-748

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 – beps July 26, 2026 13:48 Inactive
@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 – promptfiddle2 July 26, 2026 13:55 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 🔒 27.2 MB 11.6 MB file 27.1 MB +150.9 KB (+0.6%) OK
✅ packed-program Linux 🔒 17.6 MB 7.3 MB file 17.6 MB +7.2 KB (+0.0%) OK
✅ baml-cli macOS 🔒 21.2 MB 10.1 MB file 21.0 MB +149.1 KB (+0.7%) OK
✅ packed-program macOS 🔒 13.8 MB 6.4 MB file 13.8 MB +33.1 KB (+0.2%) OK
✅ baml-cli Windows 🔒 22.8 MB 10.3 MB file 22.7 MB +126.0 KB (+0.6%) OK
✅ packed-program Windows 🔒 14.7 MB 6.5 MB file 14.7 MB +4.6 KB (+0.0%) OK
✅ bridge_wasm WASM 16.5 MB 🔒 4.5 MB gzip 4.5 MB +18.6 KB (+0.4%) 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

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 26, 2026 14:09 Inactive
@antoniosarosi

Copy link
Copy Markdown
Contributor Author

Closing — this was an orchestration experiment run; not landing.

This branch was previously deployed

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