Skip to content

Harden bridge_cffi release artifact hygiene - #4174

Merged
rossirpaulo merged 4 commits into
canaryfrom
paulo/fix-release-artifact-hygiene
Jul 24, 2026
Merged

rossirpaulo merged 4 commits into
canaryfrom
paulo/fix-release-artifact-hygiene

Conversation

@rossirpaulo

@rossirpaulo rossirpaulo commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

What changed

  • remap native C/C++ build paths alongside Rust paths for every bridge_cffi release target
  • forward CFLAGS and CXXFLAGS through all Linux cross containers
  • correct Windows drive-letter remapping for Rust and MSVC /pathmap
  • add a shared ASCII/UTF-16LE binary hygiene checker and run it before CFFI artifact upload and again during C# package assembly
  • build the real eight-target CFFI release matrix in required PR, merge-group, and canary CI
  • require production release dispatches to present the successful canary CI run that attests the exact source SHA
  • reduce release workflow permissions to least privilege and avoid redundant fan-in failures

Root cause

The producer applied --remap-path-prefix only to Rust. AWS-LC is compiled through CMake/C, so GNU/Linux artifacts retained /cargo/... source paths. Windows also compared Git Bash paths with compiler-emitted drive-letter paths, leaving C:\Users\runneradmin\.cargo\... strings. The defect was only detected later by the C# product-package gate because CI used fixture natives instead of the actual release matrix.

Impact

Polluted native binaries now fail in their own producer matrix leg before upload. The same exact release matrix is required before merge and before canary release dispatch, while C# retains defense-in-depth over packaged bytes. Production releases are also bound to a successful CI - BAML Language canary push run for the exact source commit.

Validation

  • 24 release contract and workflow graph tests
  • scripts/baml-language-version check
  • Ruff
  • actionlint on the modified workflows (with existing unrelated CI lint exceptions)
  • ShellCheck and Bash syntax validation for the C# packaging script
  • real x86_64-unknown-linux-gnu release-bridge-cffi build passes the new checker
  • historical release artifacts reproduce the expected result: macOS/musl pass; both GNU/Linux and both Windows artifacts fail on their known build paths

Summary by CodeRabbit

  • Security & Reliability

    • Added native artifact hygiene verification to flag build-path leakage and credential-like strings.
    • Strengthened production release attestation with a tracked CI run identity, plus tighter release gating.
    • Tightened workflow permissions and least-privilege publishing controls.
  • CI & Release

    • Added a dedicated bridge CFFI release path that runs only when relevant release inputs change.
    • Improved native build setup via better compiler/debug/file-path remapping across targets.
  • Packaging

    • Integrated hygiene verification into native artifact inspection during packaging.
  • Tests

    • Extended pipeline contract tests for hygiene enforcement and CI-attested, least-privilege release behavior.

@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 8:27am
promptfiddle Ready Ready Preview, Comment Jul 24, 2026 8:27am
promptfiddle2 Ready Ready Preview, Comment Jul 24, 2026 8:27am

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: 5640d1c2-29cc-4025-83ba-a5bc4ba367cc

📥 Commits

Reviewing files that changed from the base of the PR and between fcbe575 and c162e1d.

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

📝 Walkthrough

Walkthrough

The PR adds native CFFI artifact hygiene checks and compiler path remapping, wires bridge release builds into CI, and requires production releases to attest the originating canary CI run with scoped permissions and stricter job gates.

Changes

CFFI release integrity

Layer / File(s) Summary
Native artifact hygiene verification
scripts/baml-bridge-cffi-hygiene, baml_language/sdks/csharp/bridge_csharp/tools/pack-product.sh, .github/workflows/build2-bridge-cffi.reusable.yaml, scripts/tests/test_release_pipeline_contract.py
Scans native binaries for build paths and credential patterns, integrates verification into build and packaging flows, and tests the behavior and workflow contracts.
Compiler path remapping
.github/workflows/build2-bridge-cffi.reusable.yaml, baml_language/Cross.toml
Applies target-specific Rust, C, and C++ path mappings and forwards compiler flags through Linux Cross builds.
Bridge release CI orchestration
.github/workflows/ci.yaml
Detects bridge release inputs, runs the reusable bridge build, includes it in required gates, and passes the source CI run id to release dispatch.
Production release attestation and permissions
.github/workflows/release-baml-language.yml, scripts/baml-language-version, scripts/tests/test_release_pipeline_contract.py
Validates the source CI run and SHA, propagates source_ci_run_id, tightens release prerequisites, scopes OIDC permissions, normalizes timestamps, and tests the release contracts.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CI
  participant BridgeBuild
  participant Hygiene
  participant Release
  CI->>BridgeBuild: run bridge CFFI release
  BridgeBuild->>Hygiene: verify native artifact
  Hygiene-->>BridgeBuild: return verification status
  CI->>Release: dispatch with source SHA and CI run id
  Release->>CI: attest canary CI run
  CI-->>Release: return successful matching run
Loading

Possibly related PRs

Poem

I’m a rabbit guarding binaries bright,
Mapping stray paths out of sight.
CI hops through gates in a row,
While clean artifacts proudly show.
The canary run proves the way.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. 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 is concise and accurately summarizes the main change: strengthening bridge_cffi release artifact hygiene.
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 paulo/fix-release-artifact-hygiene

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 24, 2026 07:21 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 24, 2026 07:29 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 +9.7 KB (+0.0%) OK
✅ packed-program Linux 🔒 17.4 MB 7.2 MB file 17.4 MB +8.2 KB (+0.0%) OK
✅ baml-cli macOS 🔒 21.0 MB 10.0 MB file 21.0 MB +32 B (+0.0%) OK
✅ packed-program macOS 🔒 13.6 MB 6.3 MB file 13.6 MB +16.5 KB (+0.1%) OK
✅ baml-cli Windows 🔒 22.7 MB 10.3 MB file 22.7 MB +5.1 KB (+0.0%) OK
✅ packed-program Windows 🔒 14.5 MB 6.4 MB file 14.5 MB +5.6 KB (+0.0%) OK
✅ bridge_wasm WASM 16.4 MB 🔒 4.5 MB gzip 4.5 MB +2.3 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 – beps July 24, 2026 07:36 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.

Actionable comments posted: 3

🧹 Nitpick comments (1)
baml_language/Cross.toml (1)

12-22: 📐 Maintainability & Code Quality | 🔵 Trivial

Consider a single global passthrough instead of repeating it per target.

cross-rs supports [build.env] passthrough = [...] applying to all targets; since all four Linux targets set the identical ["RUSTFLAGS", "CFLAGS", "CXXFLAGS"] list, this could be consolidated into one global entry, unless other per-target env settings not shown in this excerpt make target-specific sections a hard requirement.

♻️ Possible consolidation
+[build.env]
+passthrough = ["RUSTFLAGS", "CFLAGS", "CXXFLAGS"]
+
 [target.x86_64-unknown-linux-gnu.env]
-passthrough = ["RUSTFLAGS", "CFLAGS", "CXXFLAGS"]
-
 [target.aarch64-unknown-linux-gnu.env]
-passthrough = ["RUSTFLAGS", "CFLAGS", "CXXFLAGS"]
-
 [target.x86_64-unknown-linux-musl.env]
-passthrough = ["RUSTFLAGS", "CFLAGS", "CXXFLAGS"]
-
 [target.aarch64-unknown-linux-musl.env]
-passthrough = ["RUSTFLAGS", "CFLAGS", "CXXFLAGS"]
🤖 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 `@baml_language/Cross.toml` around lines 12 - 22, Consolidate the identical
passthrough environment configuration from the four target-specific sections
into a single [build.env] passthrough entry containing RUSTFLAGS, CFLAGS, and
CXXFLAGS, unless unseen target-specific settings require retaining those
sections.
🤖 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 197-206: Update the native_path_maps value used by CFLAGS and
CXXFLAGS to include /experimental:deterministic alongside the existing /pathmap
options, ensuring cl.exe applies the path mappings during Windows builds. Leave
the Rust RUSTFLAGS configuration unchanged.

In @.github/workflows/release-baml-language.yml:
- Around line 95-163: Update the retry loop in the “Attest production source CI
run” step so failures from the gh api call are handled without terminating under
set -euo pipefail. Guard the API request, log the transient error, and continue
through the existing attempt-based sleep/retry path, while preserving the
current validation and hard failures for successfully retrieved invalid or
unsuccessful run data.

In `@scripts/baml-bridge-cffi-hygiene`:
- Around line 36-48: Update the four path regex patterns in the anchor-only
checks to allow double and single quotes as valid preceding boundaries by adding
them to each negative lookbehind, while preserving the existing path
continuation classes and case-insensitive matching.

---

Nitpick comments:
In `@baml_language/Cross.toml`:
- Around line 12-22: Consolidate the identical passthrough environment
configuration from the four target-specific sections into a single [build.env]
passthrough entry containing RUSTFLAGS, CFLAGS, and CXXFLAGS, unless unseen
target-specific settings require retaining those sections.
🪄 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: 88277fde-92cd-4cbb-9c8f-13adb9c8a774

📥 Commits

Reviewing files that changed from the base of the PR and between a653fd1 and fc3312d.

📒 Files selected for processing (7)
  • .github/workflows/build2-bridge-cffi.reusable.yaml
  • .github/workflows/ci.yaml
  • .github/workflows/release-baml-language.yml
  • baml_language/Cross.toml
  • baml_language/sdks/csharp/bridge_csharp/tools/pack-product.sh
  • scripts/baml-bridge-cffi-hygiene
  • scripts/tests/test_release_pipeline_contract.py

Comment thread scripts/baml-bridge-cffi-hygiene Resolved
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 24, 2026 07:44 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps July 24, 2026 07:49 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 24, 2026 07:56 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps July 24, 2026 08:00 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 24, 2026 08:05 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 24, 2026 08:27 Inactive
@rossirpaulo
rossirpaulo added this pull request to the merge queue Jul 24, 2026
Merged via the queue into canary with commit 560dc6e Jul 24, 2026
79 checks passed
@rossirpaulo
rossirpaulo deleted the paulo/fix-release-artifact-hygiene branch July 24, 2026 08:39

This branch was previously deployed

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