Skip to content

refactor(wasm): scope the default build - #547

Open
Ankur Goyal (ankrgyl) wants to merge 3 commits into
mainfrom
codex/browser-trace-wasm
Open

Ankur Goyal (ankrgyl) wants to merge 3 commits into
mainfrom
codex/browser-trace-wasm

Conversation

@ankrgyl

@ankrgyl Ankur Goyal (ankrgyl) commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Shrink the standard Node and browser WASM builds to the APIs Braintrust uses: message conversions, message imports/deduplication, span imports, and trajectory streaming/collection. The existing import paths and browser WASM asset path stay the same, so Braintrust does not need an entry-point migration.

Request/response validators and request/response/stream transforms are removed from the default WASM exports and TypeScript wrappers. The native Rust API remains unchanged. Lingua's own fixture capture/transform tooling uses an explicit full Node build via @braintrust/lingua-wasm/full and the wasm-full feature.

Braintrust's runtime JavaScript call sites use importMessagesFromSpans, linguaToChatCompletionsMessages, import_span, trajectory_metadata_fields, and TrajectoryStream; the other direct package imports are types. Its gateway and Brainstore use the native Rust API.

Measured against main feff763e (including #536), with Rust 1.97.1 / wasm-bindgen 0.2.100 and unchanged release opt-level = 3:

Browser WASM Main New default Reduction
Raw 9,261,490 bytes (8.83 MiB) 5,212,372 bytes (4.97 MiB) 43.7%
gzip level 9 2,913,200 bytes (2.78 MiB) 1,604,135 bytes (1.53 MiB) 44.9%

Validation:

  • Ran Braintrust against these exact packages without source changes: 223 tests passed across 12 trace/converter/preprocessor test files, and the full app typecheck passed.
  • Lingua TypeScript build/typecheck and all 10 test files: 344 passed, 118 skipped. Both standard WASM targets match the full build across all 102 import fixtures and both import APIs, including native-input/cache tests and trajectories.
  • Fixture tooling typecheck and transform suite: 1,866 passed, 117 skipped using the explicit full Node build.
  • Packed both npm packages, installed into an isolated consumer, and exercised standard Node/browser imports, trajectories, full transforms, and TypeScript declarations. A browser-only consumer loads neither Node nor full WASM.
  • Release builds for default Node/browser and full Node; WASM Clippy with warnings denied for both feature configurations, Rust formatting, and the branch typed-boundary check pass.
  • Real web-WASM benchmark, 333-message batch, 50 warmups and 200 alternating samples: import median 7.35 → 7.34 ms; import+dedup median 7.09 → 7.12 ms (within 0.4%).

Offer message conversion and trajectory APIs through a smaller optional
browser entry point. Retain the full Node and browser entry points and
keep release builds at O3.

Share the TypeScript conversion wrappers while giving the scoped module
its own initialization state.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T00:17:47.018979Z cf394f9 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ankrgyl Ankur Goyal (ankrgyl) changed the title feat(wasm): add a scoped browser trace build refactor(wasm): scope the default build Oct 27, 2026
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.

3 participants