Skip to content

wip: support keyed BAML runtime instances across bridge_cffi - #4221

Closed
sxlijin wants to merge 1 commit into
canaryfrom
agent/bridge-cffi-runtime-registry
Closed

sxlijin wants to merge 1 commit into
canaryfrom
agent/bridge-cffi-runtime-registry

Conversation

@sxlijin

@sxlijin sxlijin commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace the process-wide bridge_cffi runtime singleton with a keyed runtime registry on native and WASM targets
  • return runtime keys from initialization and route calls through the selected runtime across Python, TypeScript, Web, and the C ABI
  • reserve runtime key 0 for generated SDK initialization and generated function calls while dynamically allocating independent nonzero keys
  • update C++, C#, Go, Java, Rust, and Swift CFFI consumers for the expanded ABI
  • add Python and TypeScript SDK regression coverage proving multiple runtime instances remain independent

Why

The singleton bridge made dynamically constructed BAML runtimes overwrite one another. Runtime handles now carry a stable u32 registry key, allowing calls to remain bound to the runtime instance that created them while generated SDKs continue using the well-known key 0.

Validation

  • cargo check --workspace
  • cargo test -p bridge_cffi
  • cargo test -p sdkgen_python_pydantic2 -p sdkgen_typescript_shared
  • cargo check -p bridge_cffi -p bridge_typescript_web --target wasm32-unknown-unknown
  • Python SDK function_calls::pytest
  • TypeScript Node SDK function_calls::vitest_node
  • TypeScript Web browser and Workers function-call suites
  • pnpm build:debug for bridge_typescript
  • go test ./... for sdks/go/baml_go
  • C ABI fixture compilation with warnings treated as errors

C# validation was unavailable because dotnet is not installed in the development environment. Swift tests require the local BamlBridgeFFI.xcframework binary artifact, which is not present.

@vercel

vercel Bot commented Jul 27, 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 27, 2026 8:36pm
promptfiddle Ready Ready Preview, Comment Jul 27, 2026 8:36pm
promptfiddle2 Ready Ready Preview, Comment Jul 27, 2026 8:36pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

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

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b3e5b3ce-baf9-4bc9-a4c2-056179777340

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/bridge-cffi-runtime-registry

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.

@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 July 27, 2026 19:54 Inactive
@sxlijin
sxlijin force-pushed the agent/bridge-cffi-runtime-registry branch from 6215a41 to 87c27be Compare July 27, 2026 20:00
@vercel
vercel Bot temporarily deployed to Preview – beps July 27, 2026 20:01 Inactive
@sxlijin
sxlijin force-pushed the agent/bridge-cffi-runtime-registry branch from 87c27be to 656b12d Compare July 27, 2026 20:06
@vercel
vercel Bot temporarily deployed to Preview – beps July 27, 2026 20:07 Inactive
@sxlijin
sxlijin force-pushed the agent/bridge-cffi-runtime-registry branch from 656b12d to 832aca1 Compare July 27, 2026 20:13
@vercel
vercel Bot temporarily deployed to Preview – beps July 27, 2026 20:14 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 27, 2026 20:22 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.3 MB 11.6 MB file 27.3 MB +4.4 KB (+0.0%) OK
✅ packed-program Linux 🔒 17.7 MB 7.3 MB file 17.7 MB +4.1 KB (+0.0%) OK
✅ baml-cli macOS 🔒 21.2 MB 10.1 MB file 21.2 MB +16 B (+0.0%) OK
✅ packed-program macOS 🔒 13.8 MB 6.4 MB file 13.8 MB +0 B (+0.0%) OK
✅ baml-cli Windows 🔒 22.8 MB 10.3 MB file 22.8 MB +4.6 KB (+0.0%) OK
✅ packed-program Windows 🔒 14.7 MB 6.5 MB file 14.7 MB +7.2 KB (+0.0%) OK
✅ bridge_wasm WASM 16.5 MB 🔒 4.5 MB gzip 4.5 MB +1.6 KB (+0.0%) 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 27, 2026 20:36 Inactive
@sxlijin sxlijin changed the title Support keyed BAML runtime instances across bridge_cffi wip: support keyed BAML runtime instances across bridge_cffi Jul 28, 2026
@sxlijin

sxlijin commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #4754, which implements uint64 registrations for distinct generated SDKs and independent dynamic runtimes, with Python and TypeScript coexistence regressions.

@sxlijin sxlijin closed this Sep 4, 2026

This branch was previously deployed

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