Skip to content

Fix Windows bridge export containment - #4176

Merged
rossirpaulo merged 4 commits into
canaryfrom
paulo/fix-windows-cffi-export-surface
Jul 24, 2026
Merged

rossirpaulo merged 4 commits into
canaryfrom
paulo/fix-windows-cffi-export-surface

Conversation

@rossirpaulo

@rossirpaulo rossirpaulo commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

What changed

  • disable aws-lc-sys 0.41.0's optional CPU-jitter object library on Windows using its supported AWS_LC_SYS_NO_JITTER_ENTROPY=1 control
  • inspect each final Windows bridge_cffi.dll export table in the producer workflow before artifact upload
  • move the canonical bridge export allowlist into release/ so the producer and C# package verifier share one ABI contract
  • add workflow-contract assertions covering the opt-out, pre-upload export check, shared allowlist, ordering, and absence of AWS-LC exports

Root cause

The bundled jitter-entropy library declares nine internal entry points with __declspec(dllexport) under MSVC. Because AWS-LC is linked statically into bridge_cffi.dll, those linker directives widened the DLL's public ABI. Path hygiene was already fixed; the nightly release then correctly exposed this latent export violation during C# product assembly.

Impact

Windows retains AWS-LC as its crypto backend and continues using Windows OS entropy. Only the optional CPU-jitter source is excluded. Any future dependency export leakage now fails in the real Windows producer matrix before upload rather than during the production release.

Validation

  • python3 -m unittest scripts.tests.test_release_pipeline_contract
  • mise exec actionlint -- actionlint .github/workflows/build2-bridge-cffi.reusable.yaml
  • shellcheck baml_language/sdks/csharp/bridge_csharp/tools/pack-product.sh
  • bash -n baml_language/sdks/csharp/bridge_csharp/tools/pack-product.sh
  • scripts/baml-language-version check
  • commit hooks, including YAML validation

The decisive runtime validation is the PR's real x64 and ARM64 Windows release build plus final-DLL export inspection.

Summary by CodeRabbit

  • New Features

    • Added two additional public CFFI exports: register_unhandled_spawn_error_callback and shutdown_runtime.
  • Bug Fixes

    • Improved Windows release builds by disabling optional entropy-related exports.
    • Strengthened Windows smoke testing to validate the DLL’s exported symbols against the approved public API set.
    • Release packaging now verifies exported symbols against the maintained allowlist.
  • Tests

    • Updated release pipeline contract tests to enforce deterministic public export lists and confirm the export-diff step ordering.
    • Ensured the public export allowlist is included in packed C# release artifacts.

@vercel

vercel Bot commented Jul 24, 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 24, 2026 6:53pm
promptfiddle Ready Ready Preview, Comment Jul 24, 2026 6:53pm
promptfiddle2 Ready Ready Preview, Comment Jul 24, 2026 6:53pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 24, 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: 6b66489c-46ff-4e52-b7c6-b47f3d61a68a

📥 Commits

Reviewing files that changed from the base of the PR and between 48d72f3 and 45549d2.

📒 Files selected for processing (1)
  • release/bridge-cffi-public-exports.txt
🚧 Files skipped from review as they are similar to previous changes (1)
  • release/bridge-cffi-public-exports.txt

📝 Walkthrough

Walkthrough

The release pipeline now maintains a canonical CFFI export allowlist, validates Windows DLL exports against it, disables AWS-LC jitter entropy exports, uses the allowlist during packaging, and tests these release-contract requirements.

Changes

CFFI export hygiene

Layer / File(s) Summary
Canonical export contract
release/bridge-cffi-public-exports.txt
Populates the canonical list of permitted CFFI export symbols and adds runtime callback and shutdown exports.
Windows build and smoke validation
.github/workflows/build2-bridge-cffi.reusable.yaml
Disables AWS-LC jitter entropy exports and compares bridge_cffi.dll exports with the canonical allowlist before the ABI smoke test.
Packaging and contract validation
baml_language/sdks/csharp/bridge_csharp/tools/pack-product.sh, scripts/tests/test_release_pipeline_contract.py
Uses the canonical allowlist for packaging and verifies export contents, workflow ordering, and packaged artifacts.

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

Sequence Diagram(s)

sequenceDiagram
  participant WindowsBuild
  participant Dumpbin
  participant Allowlist
  participant SmokeTest
  WindowsBuild->>Dumpbin: Enumerate bridge_cffi.dll exports
  Dumpbin->>Allowlist: Compare sorted export names
  Allowlist-->>WindowsBuild: Pass or report differences
  WindowsBuild->>SmokeTest: Run ABI smoke test
Loading

Possibly related PRs

Poem

I’m a rabbit guarding exports bright,
Sorting symbols left and right.
Windows hops through dumpbin’s gate,
AWS-LC jitter stays out late.
The package carries its list with care—
CFFI bounds are neat and fair.

🚥 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: fixing Windows bridge export containment.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch paulo/fix-windows-cffi-export-surface

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 24, 2026 17:39 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/build2-bridge-cffi.reusable.yaml:
- Around line 381-398: Update the export comparison in the PowerShell block
using $actualExports, $expectedExports, and $exportDifference so both
Sort-Object calls and Compare-Object use case-sensitive comparison. Preserve the
existing export extraction, deduplication, reporting, and failure behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9c78a8d6-2429-4a24-93f9-cd1c67d776ad

📥 Commits

Reviewing files that changed from the base of the PR and between cd31f0a and 157d42b.

📒 Files selected for processing (4)
  • .github/workflows/build2-bridge-cffi.reusable.yaml
  • baml_language/sdks/csharp/bridge_csharp/tools/pack-product.sh
  • release/bridge-cffi-public-exports.txt
  • scripts/tests/test_release_pipeline_contract.py

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 24, 2026 17:47 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps July 24, 2026 17:52 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
scripts/tests/test_release_pipeline_contract.py (1)

640-656: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Bind hygiene assertions to the actual Windows smoke step.

The global assertIn/index checks can be satisfied by comments or unrelated workflow steps, allowing a future regression in the real export-validation step to pass contract tests. Scope these checks to the named Windows smoke step and assert the exact opt-out write, export comparison, and ordering there.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/tests/test_release_pipeline_contract.py` around lines 640 - 656,
Update the contract assertions in the test covering the Windows smoke step so
export-validation checks are extracted from and bound to the named step’s script
body, not the entire builder text. Within that scoped body, assert the exact
opt-out write, dumpbin/export-list handling, Compare-Object validation, and
ordering before artifact upload; keep the public export-file content checks
unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@scripts/tests/test_release_pipeline_contract.py`:
- Around line 640-656: Update the contract assertions in the test covering the
Windows smoke step so export-validation checks are extracted from and bound to
the named step’s script body, not the entire builder text. Within that scoped
body, assert the exact opt-out write, dumpbin/export-list handling,
Compare-Object validation, and ordering before artifact upload; keep the public
export-file content checks unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 624275ff-3345-4f8d-bdcb-c4409b0dbe94

📥 Commits

Reviewing files that changed from the base of the PR and between 157d42b and 48d72f3.

📒 Files selected for processing (2)
  • .github/workflows/build2-bridge-cffi.reusable.yaml
  • scripts/tests/test_release_pipeline_contract.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/build2-bridge-cffi.reusable.yaml

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 24, 2026 17:59 Inactive
@github-actions

github-actions Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

Binary size checks passed

✅ 7 passed

Artifact Platform File Gzip Gated on Baseline Delta Status
✅ baml-cli Linux 🔒 27.1 MB 11.5 MB file 27.1 MB +29.6 KB (+0.1%) OK
✅ packed-program Linux 🔒 17.4 MB 7.2 MB file 17.4 MB +12.3 KB (+0.1%) OK
✅ baml-cli macOS 🔒 21.0 MB 10.1 MB file 21.0 MB +16.7 KB (+0.1%) OK
✅ packed-program macOS 🔒 13.6 MB 6.3 MB file 13.6 MB +32 B (+0.0%) OK
✅ baml-cli Windows 🔒 22.7 MB 10.3 MB file 22.7 MB +22.5 KB (+0.1%) OK
✅ packed-program Windows 🔒 14.5 MB 6.4 MB file 14.5 MB +8.7 KB (+0.1%) OK
✅ bridge_wasm WASM 16.4 MB 🔒 4.5 MB gzip 4.5 MB +4.2 KB (+0.1%) 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 24, 2026 18:11 Inactive
@rossirpaulo
rossirpaulo added this pull request to the merge queue Jul 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 24, 2026
@vercel
vercel Bot temporarily deployed to Preview – beps July 24, 2026 18:32 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 24, 2026 18:39 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 24, 2026 18:53 Inactive
@rossirpaulo
rossirpaulo added this pull request to the merge queue Jul 24, 2026
Merged via the queue into canary with commit ddb3e60 Jul 24, 2026
79 checks passed
@rossirpaulo
rossirpaulo deleted the paulo/fix-windows-cffi-export-surface branch July 24, 2026 19:05

This branch was previously deployed

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