Skip to content

quest(m2): spike UniFFI-generated browser bindings before growing moq-wasm - #5478

Merged
kixelated merged 3 commits into
mainfrom
claude/uniffi-js-bindings-f7ad3f
Oct 14, 2026
Merged

kixelated merged 3 commits into
mainfrom
claude/uniffi-js-bindings-f7ad3f

Conversation

@kixelated

@kixelated kixelated commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Adds quest/m2/rs2ts/generator.md. Before rs2ts grows the hand-written wasm-bindgen moq-wasm, a spike measures TypeScript that UniFFI or BoltFFI generates from moq-ffi against it on the browser baseline harness. The maintainer then picks which binding @moq/net wraps. wasm-bindings now requires this quest and completes whichever binding is chosen.

Background: moq-ffi already compiles for wasm32 (#2911). #2907 argued for this route before it was folded into rs2ts. Upstream UniFFI won't ship a JS generator and points to uniffi-bindgen-react-native, whose wasm2 flavour targets plain browsers. That generator pins UniFFI 0.31, and moq-ffi is on 0.32.

Decisions

Goal

  • ✅ Settle the generator in rs2ts with a comparison spike
  • Commit to UniFFI now
  • Separate web package
  • Just the answer

Goal confirmed: a spike measures UniFFI-generated TS from moq-ffi against moq-wasm on the baseline harness, and the maintainer picks. No adoption, no deletion of moq-wasm, no JS-only work.

  • ✅ Yes
  • Broaden to React Native and Node

Generator version

  • ✅ Spike on 0.31 in a throwaway branch, with a waiting quest on ubrn 0.32 gating adoption
  • Fork-port ubrn to 0.32
  • nchapman/uniffi-bindgen-js

Surface

  • ✅ moq-ffi as-is. The maintainer asked whether it tree-shakes: the TS does, but the .wasm doesn't, so the spike measures cargo features on and off.
  • Browser-only UniFFI crate

Placement

  • ✅ New quest before wasm-bindings
  • Fold into the baseline spike
  • First step of wasm-bindings

BoltFFI

Public API: none. Wire: none.

(written by Claude Opus 5.5)

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 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-14T03:47:21.668272Z d08c136 New commits
ℹ️ About Codex in GitHub

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

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

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

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 15 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 437f028a-23fe-4907-a646-b3579861b889
📥 Commits

Reviewing files that changed from the base of the PR and between f9c2c9f and fb19781.

📒 Files selected for processing: 3
  • quest/m2/rs2ts/README.md
  • quest/m2/rs2ts/generator.md
  • quest/m2/rs2ts/wasm-bindings.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@kixelated kixelated left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Automated review by review (OpenAI)

Reviewed commit: b17ebcd.

One P3 correction to the cancellation premise below. Overall direction is sound: compare measured candidates before choosing a binding, keep the compatibility downgrade confined to the spike, and gate adoption on the supported generator version. The baseline → generator → complete bindings → adoption dependencies are acyclic; the existing baseline already calls for matched workloads and complete shipped assets. No blocking design issue found.

Verification: GitHub-only static review of the three changed plans, surrounding prerequisites and current moq-ffi feature/lifetime implementation. No builds or browser tests run. Upstream generator implementation/version claims were not independently verified because this review is scoped to moq-dev/moq.

Comment thread quest/m2/rs2ts/generator.md Outdated
- Parity on the harness cases: exact u64 above 2^53, cancellation through
`AbortSignal`, close/error propagation, and freeing a handle mid-call.
- On wasm, `ffi::Task` cancels when the caller drops it, whereas native
detaches. Check that `@moq/net` semantics hold under that difference.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[P3] Update the Task cancellation premise

The native/WASM split described here no longer exists: rs/moq-ffi/src/ffi.rs:319–348 uses one await-in-place Task::run implementation for both. Its comment explicitly avoids spawned work so a cancelled foreign call cannot consume the next call's event before rust_future_free. Describe that current contract and test that aborting/freeing a pending call releases its state without stealing the next event, rather than measuring against native detachment.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed: the premise now describes the current await-in-place contract and tests that aborting or freeing a pending call releases its state without stealing the next event.

(Written by Claude Opus 5.5)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b17ebcd6ce

ℹ️ About Codex in GitHub

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

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +26 to +29
- Use [uniffi-bindgen-react-native](https://github.com/jhugman/uniffi-bindgen-react-native)
(ubrn), whose `wasm2` flavour is a plain wasm32 cargo build driven by a
generic JS player. Upstream UniFFI will not ship a JS generator and points
to ubrn. ubrn pins UniFFI 0.31, while `moq-ffi` is on 0.32. The spike

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add the required wasm2 runtime to the spike setup

The current rs/moq-ffi manifest and crate root contain neither uniffi-runtime-wasm nor extern crate uniffi_runtime_wasm as _, so this proposed wasm2 build cannot reach the browser harness: ubrn build wasm2 rejects the missing dependency, and without the forced link the player fails to load because __ubrn_alloc is absent. The spike must temporarily add and link the matching 0.31 runtime, and count it in the shipped-size measurement, rather than treating the existing crate as directly runnable. See the upstream wasm2 preparation requirements.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed: the spike branch adds the matching uniffi-runtime-wasm plus the forced extern crate link, and counts the runtime in the shipped size.

(Written by Claude Opus 5.5)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d08c136fac

ℹ️ About Codex in GitHub

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

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +37 to +40
BoltFFI has its own macros, so it cannot bind `moq-ffi` as-is. Reuse
that spike's slice crate, which binds both generators via `cfg_attr`,
and measure UniFFI on the same slice so the per-call numbers compare
like for like. Full `moq-ffi` through UniFFI still provides the size and

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Compare a full BoltFFI binding before selecting it

These lines restrict BoltFFI to the slice crate and explicitly reserve full moq-ffi size and coverage measurements for UniFFI. As a result, BoltFFI cannot run the promised browser parity cases or produce comparable shipped-size, startup, and memory results, yet the quest still permits the maintainer to select it and the dependent quest assumes moq-ffi through BoltFFI. Either port a representative full workload for this spike or treat the slice measurement only as a feasibility filter, not winner-selection evidence.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed: the slice is now a feasibility filter. If BoltFFI passes and is favored, the harness workload is ported and the parity, size, startup, and memory cases rerun before it can be picked.

(Written by Claude Opus 5.5)

Comment thread quest/m2/rs2ts/generator.md Outdated
Comment on lines +23 to +25
keeps every UniFFI export, so only cargo features reduce size. Measure
`default-features` on and off. If size decides the result, propose a
net-only feature rather than a new crate.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use a feature split that changes the wasm build

On wasm32, toggling default-features currently changes no compiled surface: moq-ffi's defaults are only audio and video, their dependencies are under cfg(not(target_arch = "wasm32")), and both modules have the same non-wasm guard. The proposed on/off measurements therefore build the same browser code and cannot inform the stated size-driven feature decision; define an actual feature over browser-exported modules or omit this comparison.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Correct, audio/video are native-only. The on/off comparison is replaced with each module's share of the .wasm; a net-only size knob would need a new gate.

(Written by Claude Opus 5.5)

Comment thread quest/m2/rs2ts/generator.md Outdated
Comment on lines +45 to +48
(2026-09-28, released in v0.31.0). Async constructors and static async
methods are dropped
([boltffi#95](https://github.com/boltffi/boltffi/issues/95), open),
which `connect` hits. TypeScript streams are experimental

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Correct the claimed BoltFFI connect limitation

The cited BoltFFI issue explicitly shows that async instance methods with &self work and that only no-receiver static methods are dropped. moq-ffi has a synchronous MoqClient::new constructor followed by the async instance method MoqClient::connect(&self, ...), so this limitation does not hit its connect; leaving this claim in the decision record incorrectly presents a nonexistent blocker for BoltFFI.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Correct, connect takes &self. The example is now the async constructor MoqMediaCatalogConsumer::subscribe.

(Written by Claude Opus 5.5)

@kixelated kixelated left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Automated review by review (OpenAI)

Reviewed commit: d08c136

Reviewed the substantive BoltFFI addition against my previous review, excluding equivalent rebased changes.

  • New P3, already independently reported in 4266559190: quest/m2/rs2ts/generator.md:45–48 says the async-static/constructor limitation affects connect. In this repository MoqClient::new is synchronous and connect is async with &self (rs/moq-ffi/src/session.rs:553–578). Remove that claimed blocker and assess the actual instance-method path in the spike.
  • Prior P3 4265516925 remains open at generator.md:69–70: Task::run awaits in place on both targets; native detachment is not the current baseline.

Direction: adding a measured candidate before adoption is reasonable. Matching the two generated slices for per-call costs is useful; keep those measurements distinct from full-library size/coverage and the later complete-workload adoption gate. No additional actionable design bug found.

Limits: GitHub-only static review of changed plans, surrounding prerequisites and current FFI implementation. No builds/browser tests run; upstream generator/version claims were not independently verified outside moq-dev/moq.

kixelated and others added 3 commits October 13, 2026 20:49
…-wasm

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…I evidence, and cancel

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated force-pushed the claude/uniffi-js-bindings-f7ad3f branch from d08c136 to fb19781 Compare October 14, 2026 03:50
@kixelated

Copy link
Copy Markdown
Collaborator Author

Merge summary. Quest files only, with no API or wire impact.

quest/m2/rs2ts/generator.md compares three candidates: UniFFI via ubrn wasm2, BoltFFI, and moq-wasm. BoltFFI was added via #5498 and reuses that PR's slice crate.

Review fixes:

  • The cancel premise now matches today's await-in-place Task::run.
  • wasm2 needs uniffi-runtime-wasm and its forced link, both counted in the shipped size.
  • The BoltFFI slice is only a feasibility filter: picking BoltFFI requires porting the full workload first.
  • Size is reported per module, since toggling default-features doesn't change the wasm32 build.
  • BoltFFI's connect claim is corrected.

(Written by Claude Opus 5.5)

@kixelated
kixelated enabled auto-merge October 14, 2026 03:50
@kixelated
kixelated added this pull request to the merge queue Oct 14, 2026
Merged via the queue into main with commit db9276f Oct 14, 2026
3 checks passed
@kixelated
kixelated deleted the claude/uniffi-js-bindings-f7ad3f branch October 14, 2026 03:58
kixelated added a commit that referenced this pull request Oct 17, 2026
…feature

#5776 put uniffi-bindgen's binary behind a `cli` feature, so run.sh now
runs it through `cargo run --features cli` like rs/moq-ffi/build.sh.

`just bench-ffi-gen` takes several steps, and `size` builds the moq-ffi
and moq-wasm references only it needs. The nightly runs `build bench` so
#5478 and #5838 can reuse a slice that still builds. Also fixes clippy on
the standalone crate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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