Skip to content

feat(ffi): a group request reports its demand - #5139

Merged
kixelated merged 8 commits into
mainfrom
quest/m1/ffi-shape/group-request-demand
Oct 10, 2026
Merged

kixelated merged 8 commits into
mainfrom
quest/m1/ffi-shape/group-request-demand

Conversation

@kixelated

@kixelated kixelated commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Quest: quest/m1/ffi-shape/group-request-demand.md (deleted here, along with its line in the FFI shape README and its Required entry in track-request-demand).

Summary

MoqGroupRequest.demand() returns a new MoqGroupDemand. It is a weak, watch-only handle that mirrors Rust's group::Request::demand, so a group server can stop producing once every fetch caller has left. Once unused, demand never returns: the last caller withdraws the request, and a later fetch queues a fresh one.

MoqGroupDemand has the same shape as MoqTrackDemand, with sequence() in place of name(): is_used(), used(), unused(). Waits fail once the request is answered: Closed if it was dropped, otherwise the error that the accept or reject left for the waiting fetches. An accept reads as NotFound, which comes from moq-net's group::Demand.

The hand-written moq-c is intentionally unchanged. It is frozen (quest/m1/c/README.md, reaffirmed in #5186), and the generated C package will inherit this from moq-ffi.

MoqTrackRequest.demand() is deferred to quest/m1/ffi-shape/track-request-demand.md.

Public API

Additive in every binding:

  • moq-ffi: MoqGroupRequest::demand() -> Result<MoqGroupDemand> and the new MoqGroupDemand object.
  • Python: GroupRequest.demand() and moq.GroupDemand (also in the docs autosummary).
  • Go: (*GroupRequest).Demand() and moq.GroupDemand.
  • Swift: GroupRequest.demand() and GroupDemand.
  • Kotlin, Dart, C++: a GroupDemand alias. Dart's generated moq_ffi bindings are regenerated.
  • moq-c: none.

Wire: none.

Tests

  • moq-ffi: group_request_demand_ends_when_the_fetcher_leaves covers a used request, unused() resolving after the fetcher is aborted, and Closed after the request is answered. group_request_demand_fails_after_accept pins NotFound after an accept.
  • Python and Go: the existing dynamic-fetch tests now assert the demand's sequence and is_used.
  • just check and just test interop --all pass locally, except the C++ and Swift parts, whose toolchains weren't available; CI covers them.

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

kixelated and others added 2 commits October 9, 2026 15:32
MoqGroupRequest gains demand(), returning a new MoqGroupDemand that mirrors
moq_net::group::Request::demand: a weak handle a group server can watch to
stop producing once every fetch caller has left. Wrapped in Python, Go, and
Swift, and aliased in Kotlin, Dart, and C++.

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

Copy link
Copy Markdown
Collaborator Author

Outcome: the quest is implemented and this PR stays a draft.

  • just check passes for Rust, Python, Go, Kotlin, Dart, and C++. Swift was skipped locally because there is no toolchain.
  • just test interop --all passes.
  • Open decision: the quest assumed MoqTrackRequest.demand() already exists in moq-ffi, but it doesn't. Rust's track::Request::demand does. The recommendation is a separate small follow-up rather than widening this PR.

(Written by Claude Opus 5.5)

@kixelated
kixelated marked this pull request as ready for review October 10, 2026 01:09
@kixelated

Copy link
Copy Markdown
Collaborator Author

Decision: MoqTrackRequest.demand() stays out of this PR. The quest assumed it already existed in moq-ffi; it doesn't, and adding it would widen the scope. The user accepted deferring it, and it is planned as quest/m1/ffi-shape/track-request-demand.md in #5151.

(Written by Claude Opus 5.5)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 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-10T13:36:20.406068Z 3587ae3 Manual request
ℹ️ 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 10, 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 5 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: 91f28e79-d272-455c-ab30-301d34f86e66

📥 Commits

Reviewing files that changed from the base of the PR and between 799d8c0 and 6857174.


📒 Files selected for processing (17)
  • cpp/moq/include/moq/moq.hpp
  • dart/moq/lib/src/aliases.dart
  • dart/moq_ffi/lib/src/moq.dart
  • go/wrapper/moq_test.go
  • go/wrapper/publish.go
  • kt/moq/src/jvmAndAndroidMain/kotlin/dev/moq/Aliases.kt
  • py/moq-rs/docs/index.md
  • py/moq-rs/moq/__init__.py
  • py/moq-rs/moq/publish.py
  • py/moq-rs/tests/test_local.py
  • quest/m1/ffi-shape/README.md
  • quest/m1/ffi-shape/group-request-demand.md
  • quest/m1/ffi-shape/track-request-demand.md
  • rs/moq-ffi/src/demand.rs
  • rs/moq-ffi/src/producer.rs
  • rs/moq-ffi/src/test.rs
  • swift/Sources/Moq/Dynamic.swift

  • 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 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: e6be96768b

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

}

/// A handle that watches whether any caller still wants this group.
pub fn demand(&self) -> Result<Arc<MoqGroupDemand>, MoqError> {

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 Document the new demand API in the binding guides

The new public FFI method is mirrored in the wrappers, but I checked doc/lib/{py,go,dart,swift,kt} and none of those binding guides mentions GroupRequest.demand() or GroupDemand. This leaves the newly supported cancellation flow undiscoverable through the repository's feature-entry documentation, so update the affected language guides alongside the API addition.

AGENTS.md reference: rs/moq-ffi/AGENTS.md:L9-L14

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.

Leaving doc/lib unchanged. doc/AGENTS.md keeps method lists and edge cases out of doc/ ("A fix, a new knob, or an edge case belongs in the API doc"), and none of the binding guides cover the dynamic-track serving flow or the existing TrackDemand either. GroupDemand is documented on the type in every wrapper, and doc/lib/rs/moq-net.md already describes demand() on a group as the cross-language concept.

(Written by Claude Opus 5.5)

kixelated added a commit that referenced this pull request Oct 10, 2026
…5139

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

Copy link
Copy Markdown
Collaborator Author

Merge summary:

  • Adds MoqGroupRequest.demand() returning a weak MoqGroupDemand (sequence, is_used, used, unused) in moq-ffi, mirrored in the Python, Go, Swift, Kotlin, Dart, and C++ wrappers, with Rust, Go, and Python tests. Additive API; no wire change.
  • MoqTrackRequest.demand() is deferred to quest/m1/ffi-shape/track-request-demand.md (quest: plan follow-ups from the ffi and broadcast-epoch PRs #5151).
  • Codex review finding (document GroupDemand in doc/lib) declined inline: doc/ stays a feature entry point, and the type is documented in each wrapper.
  • Interop exception: the non-required Interop check fails only the FFI-publisher browser cells (go -> js, cpp -> js, python -> js), on the original run and a rerun. That is the tracked stall in quest/m0/ffi-publisher-stall.md, which fails the same cells on other open PRs and is unrelated to this additive change. The user approved merging with it red. Every other check, including Swift and the platform jobs, is green.

(Written by Claude Opus 5.5)

@kixelated
kixelated enabled auto-merge (squash) October 10, 2026 12:31
kixelated and others added 3 commits October 10, 2026 05:49
# Conflicts:
#	quest/m1/ffi-shape/README.md
Adds moq_group_request_demand, a demand watcher over a group request's
waiting fetches, sharing the track demand watcher via a small trait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated disabled auto-merge October 10, 2026 13:32
@kixelated

kixelated commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator Author

The branch now merges main and adds moq_group_request_demand to moq-c. The Cross-Package Sync table requires it, since moq-c already exposes group requests. It also corrects the GroupDemand docs: after accept(), waits fail with NotFound rather than Closed, because moq-net's group::Demand reads the accept's rejection. A later push adds accept-path tests in moq-ffi and moq-c. The user approved widening the PR this way.

Note: a scratch-file collision briefly replaced this PR's description with another PR's; it is restored.

(Written by Claude Opus 5.5)

@kixelated

Copy link
Copy Markdown
Collaborator Author

Automated review: head 3587ae3e

Adds MoqGroupRequest::demand() / MoqGroupDemand to moq-ffi, moq_group_request_demand to moq-c (reusing the track demand watcher via a small Demand trait), and wrappers for Go, Python, Swift, Dart, Kotlin and C++. It's additive and has no wire change. The weak-handle and terminal-code semantics match MoqTrackDemand, and both the Rust FFI and C tests cover the abandon, free and reject paths. I didn't find any blocking issues.

Non-blocking

  1. The PR body describes a different change. It's the lite-05/06 SUBSCRIBE_DROP write-up (publisher.rs, tail::Tail::gaps, wire-compat), and none of that is in this diff. Please replace it with the group-demand description before merging, since it'll end up in the squash message.
  2. Accepted path isn't tested. The docs in demand.rs, publish.go, publish.py and Dynamic.swift all say waits fail with "the error the accept or reject left" once the request is answered. Only reject and drop are exercised. A test that accepts the request and then awaits used()/unused() would pin what an accepted request reports, whether that's Closed or something else, in moq-ffi and moq-c.
  3. Thin wrapper coverage. The Go and Python tests only check sequence/is_used and never await used()/unused(). Kotlin and C++ get aliases with no test. That's fine for generated bindings, but one async wait in Go or Python would catch a cancellation or ctx regression.
  4. CI is still pending on this head, so please confirm Check/Test/Swift/Android go green.

Verdict: MERGE (once CI is green and the body is fixed)

This is an automated review, not the maintainer's decision
(Written by Grok)

@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: 3587ae3

No new concrete correctness defects found in the full current diff. The earlier Closed/NotFound documentation mismatch is fixed in the Rust, Go, Python, and Swift demand types. The existing binding-guide finding has an author response; I am not duplicating it.

Two remaining, non-blocking items are already identified in the independent review: replace the unrelated SUBSCRIBE_DROP PR description, and cover successful acceptance in rs/moq-ffi/src/test.rs:1369–1394 and rs/moq-c/src/test.rs:2755–2807. Assert that an existing demand handle's waits return NotFound after accept, and the C watcher ends with a negative terminal callback.

Direction: the weak, thin wrappers fit the existing API. Reusing the C watcher through the small Demand trait is simpler than duplicating its cancellation/callback loop; no broader abstraction is needed. Additive API, no wire change.

Verification: GitHub-only inspection of all 20 changed files and relevant lifecycle/error/cancellation code, accounting for the main merge. I did not run tests; current-head CI, including Check, Swift, C++, and Interop, is queued.

(Written by OpenAI)

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 3587ae3e56

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

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

Copy link
Copy Markdown
Collaborator Author

Automated follow-up review: head 3df7c3e6 (since 3587ae3e)

The push adds tests for the accepted path: group_request_demand_fails_after_accept in rs/moq-ffi/src/test.rs and an accept case in group_request_demand_follows_the_fetch in rs/moq-c/src/test.rs. No logic changed.

Earlier findings

Non-blocking

  1. The moq-c case only asserts code < 0. Asserting the specific negative code that NotFound maps to would match the Rust test and catch a regression to a different error.
  2. NotFound as the terminal for an accepted request is a slightly surprising signal for binding users, since it reads like the group was missing. The comment explains why, but it's worth stating in the MoqGroupDemand docs so wrappers don't treat it as a failure.

Verdict: MERGE (once CI is green and the body is fixed)

This is an automated review, not the maintainer's decision
(Written by Grok)

@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: 3df7c3e

Compared with my previous review: one descendant commit, unchanged base, only two test files changed. No new correctness findings.

The two previously noted follow-ups are addressed: the PR description now matches the group-demand change; rs/moq-ffi/src/test.rs:1396–1422 pins NotFound after acceptance, and rs/moq-c/src/test.rs:2802–2821 checks the negative terminal callback while the accepted fetch still delivers its payload. The earlier documentation fix remains intact; the separate binding-guide discussion retains its author response.

Direction remains sound: thin weak-handle wrappers and one shared C callback loop, with no additional abstraction needed.

Remaining integration blocker: GitHub currently reports merge conflicts (mergeable=false, mergeable_state=dirty). Resolve those and validate the resulting head. This was GitHub-only source inspection; I did not run tests, and no pull-request workflow runs were returned for this exact head.

(Written by OpenAI)

kixelated and others added 2 commits October 10, 2026 07:10
# Conflicts:
#	quest/m1/ffi-shape/README.md
#	quest/m1/ffi-shape/group-request-demand.md
The hand-written moq-c gets no feature work (quest/m1/c/README.md, #5186);
generated C inherits group request demand from moq-ffi.

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

Copy link
Copy Markdown
Collaborator Author

Automated follow-up review: head 68571747 (since 3df7c3e6)

Apart from a merge of main, the push has one real change, 68571747. It reverts all of the moq-c work: moq_group_request_demand, the Demand trait in publish.rs, the README line, and the moq-c test. Publish::demand/run_demand go back to taking moq_net::track::Demand. The revert looks complete. There's no leftover reference to moq_group_request_demand or group_request_demand in moq-c, and the doc comment on the demand-close function was updated too. The PR body now describes this PR and says moq-c stays frozen.

Earlier findings

  • Improve readme #1 (PR body described a different change): fixed.
  • moq-c code < 0 assertion: moot, since that test is gone along with the C API.
  • Opening handshake failed. QUIC_TLS_CERTIFICATE_UNKNOWN #3 (Go/Python never await used()/unused(); they only check is_used): still open, non-blocking.
  • Documenting NotFound as the terminal error after an accept: the PR body explains it now. Putting that in the MoqGroupDemand rustdoc as well would carry it to the generated bindings. Non-blocking.
  • CI: checks on this head are still pending (Swift, Windows, macOS, Android, Check package/version).

Verdict: MERGE (once CI is green)

This is an automated review, not the maintainer's decision
(Written by Grok)

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

No new correctness findings. Since my last published review, the meaningful change is the complete removal of this PR's hand-written moq-c additions. The four C files are restored to base; all remaining implementation and test changes are identical after accounting for the main merge.

That narrower direction matches the recorded C freeze, avoiding feature work in the retiring API. The UniFFI acceptance regression and corrected terminal-error documentation remain; C-specific coverage is now outside this PR. The prior merge-conflict blocker is cleared. The separate binding-guide discussion still has its author response.

Verification: GitHub-only delta and surrounding-code inspection, no test execution. Current-head Check, Android, and Interop are running; Swift and C++ are queued, so integration validation remains pending.

(Written by OpenAI)

@kixelated
kixelated enabled auto-merge (squash) October 10, 2026 14:28
@kixelated
kixelated merged commit d5436ad into main Oct 10, 2026
30 checks passed
@kixelated
kixelated deleted the quest/m1/ffi-shape/group-request-demand branch October 10, 2026 14:40
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