Skip to content

refactor(ffi)!: separate announce input from route observation and trim the binding surface - #6473

Merged
kixelated merged 16 commits into
mainfrom
quest/m1/api-audit/binding-trim
Oct 23, 2026
Merged

kixelated merged 16 commits into
mainfrom
quest/m1/api-audit/binding-trim

Conversation

@kixelated

@kixelated kixelated commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Completes quest/m1/api-audit/binding-trim.md.

Problem

The moq-ffi surface, audited against release, had inputs and observations sharing one type, two watch spellings, and objects with no consumer:

  • MoqRoute was both the announce input and what MoqAnnounceConsumer reports. Its anonymous was ignored on input and its hops was writable, so a local publisher could fabricate a relay hop chain.
  • MoqBandwidthConsumer spelled its watch peek/changed, while MoqTrackDemand uses wanted/wanted_changed.
  • MoqGroupRequest::demand and MoqGroupDemand had no consumer beyond wrapper pass-throughs.
  • MoqBroadcastConsumer::resolve(reference, epoch) took two adjacent Option<String>s that are easy to swap, while every other rendition consumer takes a MoqRendition.
  • moq-c's moq_bandwidth_set_target had no consumer beyond its README, and moq-ffi's MoqBandwidth::set_target none beyond the Python, Swift, and Go pass-throughs.

Approach

  • MoqBroadcastProducer::announce takes a new MoqAnnounceRoute { cost, epoch }. MoqRoute is observation-only: no defaults, anonymous derived from hops. With no hop chain to validate, MoqError::InvalidRoute is gone (Go's ErrInvalidRoute with it). The route docs no longer pair a route with MoqOriginProducer::dynamic, which takes none since moq-dev/moq#5678.
  • MoqBandwidthConsumer::peek/changed become rate/rate_changed.
  • MoqGroupRequest::demand and MoqGroupDemand are removed, with their wrappers.
  • MoqBroadcastConsumer::resolve takes a MoqRendition and reads the reference and epoch from it.
  • MoqBroadcastFinish docs (moq-ffi, Go, doc/lib/{kt,go,dart}) say a garbage-collected language closes the broadcast only when the collector reclaims an unreferenced handle.
  • moq-c drops moq_bandwidth_set_target. Native rung disable keeps a disabled rung's reservation at its ceiling instead of setting a target, and OBS goes through the generated C++ package, so nothing uses it. moq-ffi's MoqBandwidth::set_target goes too, with the Python Bandwidth.set_target, Swift Bandwidth.setTarget, and Go Bandwidth.SetTarget pass-throughs, and Kotlin, Dart, and C++ lose the generated method.
  • moq_client_defaults: Kotlin's hand-written clientDefaults() goes. Swift, Python, Go, and Dart never wrapped it, and C++'s wrapper becomes the generated function under cpp-free-function-prefix, so every language reaches the generated function directly.
  • Wrappers (Python, Swift, Kotlin, Go, Dart), OBS, the carla demo, interop/smoke clients, wasm cases, and doc/lib/* follow. A Python test that announced a fabricated hop chain now re-prices by cost.

Impact

  • moq-ffi (breaking): MoqAnnounceRoute added; MoqBroadcastProducer::announce(MoqAnnounceRoute); MoqRoute fields lose their defaults; MoqError::InvalidRoute removed; MoqBandwidthConsumer::{rate, rate_changed} replace {peek, changed}; MoqGroupDemand and MoqGroupRequest::demand removed; MoqBroadcastConsumer::resolve(MoqRendition).
  • moq-c (unreleased surface): moq_bandwidth_set_target removed.
  • moq-ffi (unreleased surface): MoqBandwidth::set_target removed, with Python Bandwidth.set_target, Swift Bandwidth.setTarget, Go Bandwidth.SetTarget, and the generated Kotlin, Dart, and C++ method. No MIGRATE.md entry, since no release shipped it.
  • Python: moq.AnnounceRoute; BroadcastProducer.announce(AnnounceRoute); Bandwidth.Consumer.rate()/rate_changed(); BroadcastConsumer.resolve(id, rendition); GroupDemand and GroupRequest.demand() removed.
  • Swift: AnnounceRoute; announce(route: AnnounceRoute); Bandwidth.Consumer.rate()/rateChanged(); resolve(_: Media.Rendition); GroupDemand removed.
  • Kotlin: AnnounceRoute alias; GroupDemand alias and clientDefaults() removed; generated methods renamed as in moq-ffi.
  • Go: moq.AnnounceRoute; Announce(AnnounceRoute); BandwidthConsumer.Rate()/RateChanged(ctx); Resolve(ctx, rendition); GroupDemand, GroupRequest.Demand, ErrInvalidRoute removed.
  • Dart: AnnounceRoute typedef; GroupDemand typedef removed; generated methods renamed; raw bindings regenerated.
  • C++/OBS: follow the generated names (moq::AnnounceRoute, rate()).
  • MIGRATE.md entries in every affected released package. Wire: none.

Alternatives

  • Keep one MoqRoute and refuse a non-empty hops on announce: a runtime refusal for what the type can make unrepresentable.
  • resolve(reference: MoqReference { broadcast, epoch }): a new record for one call, when MoqRendition already carries both and is what the caller holds.
  • moq-c: also rename moq_bandwidth_consumer_peek/_changed. Skipped: the hand-written crate is being replaced by the generated C API (moq-dev/moq#6052), which picks up moq-ffi's names.

Decisions

  1. moq_client_defaults alignment: remove Kotlin's clientDefaults() (its only consumer was its own test), so no wrapper hand-writes it and every language reaches the generated function. Rejected: adding client_defaults() to Swift, Python, Go, and Dart, which would expose the FFI ClientConfig those wrappers otherwise hide.
  2. moq-ffi MoqBandwidth::set_target: removed with its wrappers, on the same no-consumer finding as moq-c's.

Follow-ups

None new. The origin announces will move announce off the broadcast producer and can keep MoqAnnounceRoute as its input.

Checks

just check passes (Swift skipped: no toolchain on this host). just test interop --all passes.

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

kixelated and others added 3 commits October 22, 2026 20:56
…unused binding surface

MoqBroadcastProducer::announce takes MoqAnnounceRoute { cost, epoch }; MoqRoute
is observation-only. MoqBandwidthConsumer reads rate/rate_changed. MoqGroupDemand
and MoqGroupRequest::demand are gone. resolve takes a MoqRendition. moq-c drops
moq_bandwidth_set_target and Kotlin drops its clientDefaults wrapper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Binding surface trim refactor(ffi)!: separate announce input from route observation and trim the binding surface Oct 23, 2026
kixelated and others added 7 commits October 22, 2026 21:58
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing calls it beyond the Python, Swift, and Go pass-throughs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated

Copy link
Copy Markdown
Collaborator Author

The quest is implemented and just check passes locally. Swift was skipped because this host has no toolchain. I'm leaving the PR as a draft for two maintainer decisions (see ## Decisions needed):

  1. moq_client_defaults alignment. I removed Kotlin's hand-written clientDefaults() so no wrapper hand-writes it. The alternative is to add it to Swift, Python, Go, and Dart instead.
  2. Whether moq-ffi's MoqBandwidth::set_target should also go, along with its Python, Swift, and Go pass-throughs. It has the same no-consumer finding as the removed moq-c moq_bandwidth_set_target. I recommend removing it.

(Written by Claude Opus 5.5)

kixelated and others added 2 commits October 22, 2026 23:32
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review October 23, 2026 07:55
@coderabbitai

coderabbitai Bot commented Oct 23, 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 18 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
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e5efd670-8a10-4a8e-9385-6ff6645d09a5
📥 Commits

Reviewing files that changed from the base of the PR and between 177e92c and bd0d7fd.

📒 Files selected for processing: 80
  • cpp/moq/MIGRATE.md
  • cpp/moq/include/moq/moq.hpp
  • cpp/obs/src/moq-output.cpp
  • cpp/obs/test/moq-audio-encoder-test.cpp
  • cpp/obs/test/moq-source-test.cpp
  • dart/moq/MIGRATE.md
  • dart/moq/README.md
  • dart/moq/lib/src/aliases.dart
  • dart/moq/lib/src/epoch.dart
  • dart/moq/test/moq_test.dart
  • dart/moq_ffi/MIGRATE.md
  • dart/moq_ffi/lib/src/moq.dart
  • dart/moq_ffi/lib/src/uniffi_runtime.dart
  • dart/moq_ffi/test/future_test.dart
  • dart/moq_ffi/test/leak_test.dart
  • demo/carla/sim/moq_carla_sim/main.py
  • demo/carla/sim/moq_carla_sim/runtime.py
  • demo/carla/sim/tests/conftest.py
  • doc/lib/cpp/index.md
  • doc/lib/dart/index.md
  • doc/lib/go/index.md
  • doc/lib/kt/index.md
  • doc/lib/py/index.md
  • doc/lib/swift/index.md
  • go/ffi/MIGRATE.md
  • go/wrapper/MIGRATE.md
  • go/wrapper/bandwidth_test.go
  • go/wrapper/doc.go
  • go/wrapper/errors.go
  • go/wrapper/errors_test.go
  • go/wrapper/example_test.go
  • go/wrapper/moq_test.go
  • go/wrapper/publish.go
  • go/wrapper/reconnect_test.go
  • go/wrapper/session.go
  • go/wrapper/subscribe.go
  • go/wrapper/types.go
  • kt/moq-ffi/MIGRATE.md
  • kt/moq/MIGRATE.md
  • kt/moq/src/jvmAndAndroidMain/kotlin/dev/moq/Aliases.kt
  • kt/moq/src/jvmAndAndroidMain/kotlin/dev/moq/Client.kt
  • kt/moq/src/jvmAndAndroidMain/kotlin/dev/moq/Epoch.kt
  • kt/moq/src/jvmAndAndroidTest/kotlin/dev/moq/SmokeTest.kt
  • py/moq-ffi/MIGRATE.md
  • py/moq-ffi/tests/exit_inside_callback.py
  • py/moq-rs/MIGRATE.md
  • py/moq-rs/README.md
  • py/moq-rs/docs/index.md
  • py/moq-rs/moq/__init__.py
  • py/moq-rs/moq/epoch.py
  • py/moq-rs/moq/publish.py
  • py/moq-rs/moq/session.py
  • py/moq-rs/moq/subscribe.py
  • py/moq-rs/moq/types.py
  • py/moq-rs/tests/test_local.py
  • py/moq-rs/tests/test_server.py
  • quest/m1/api-audit/README.md
  • quest/m1/api-audit/binding-trim.md
  • rs/moq-c/README.md
  • rs/moq-c/src/bandwidth.rs
  • rs/moq-ffi/MIGRATE.md
  • rs/moq-ffi/src/bandwidth.rs
  • rs/moq-ffi/src/consumer.rs
  • rs/moq-ffi/src/demand.rs
  • rs/moq-ffi/src/error.rs
  • rs/moq-ffi/src/media.rs
  • rs/moq-ffi/src/origin.rs
  • rs/moq-ffi/src/producer.rs
  • rs/moq-ffi/src/test.rs
  • swift/MIGRATE.md
  • swift/Sources/Moq/Aliases.swift
  • swift/Sources/Moq/Bandwidth.swift
  • swift/Sources/Moq/Broadcast.swift
  • swift/Sources/Moq/Dynamic.swift
  • swift/Sources/Moq/Epoch.swift
  • swift/Tests/MoqTests/SmokeTests.swift
  • swift/ffi/MIGRATE.md
  • test/interop/clients/go/main.go
  • test/smoke/clients/go/smoke.go
  • test/wasm/uniffi/cases.ts
  • 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 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-23T15:46:23.563432Z bd0d7fd 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.

@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: d18c77a4ba

ℹ️ 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 thread cpp/moq/MIGRATE.md
Comment thread rs/moq-ffi/MIGRATE.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated

Copy link
Copy Markdown
Collaborator Author

@codex review

(Written by Claude Opus 5.5)

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@kixelated

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

(Written by Claude Opus 5.5)

@kixelated

Copy link
Copy Markdown
Collaborator Author

@codex review

(Written by Claude Opus 5.5)

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 0f5ea92b6d

ℹ️ 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".

@kixelated
kixelated enabled auto-merge October 23, 2026 15:35
kixelated and others added 2 commits October 23, 2026 08:40
# Conflicts:
#	dart/moq/MIGRATE.md
#	dart/moq_ffi/MIGRATE.md
#	dart/moq_ffi/lib/src/moq.dart
#	doc/lib/dart/index.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated added this pull request to the merge queue Oct 23, 2026

@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: bd0d7fdaa0

ℹ️ 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 +274 to +275
pub async fn resolve(&self, rendition: MoqRendition) -> Result<Arc<MoqBroadcastConsumer>, MoqError> {
let (reference, epoch, _, _) = rendition.into_parts();

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 Kotlin FFI resolve migration

For raw Kotlin callers upgrading across this Unreleased batch, kt/moq-ffi/MIGRATE.md:29 still instructs them to pass epoch after reference, but this new signature accepts a single MoqRendition; following the package's migration instructions therefore targets an overload that no longer exists. Update the Kotlin raw-binding entry to explain constructing and passing the rendition, as the other binding guides do.

AGENTS.md reference: AGENTS.md:L60-L61

Useful? React with 👍 / 👎.

Merged via the queue into main with commit f719866 Oct 23, 2026
10 checks passed
@kixelated
kixelated deleted the quest/m1/api-audit/binding-trim branch October 23, 2026 17:28
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