Repository navigation
fix(moq-ffi,libmoq,bindings): route watch through run, keep finished windows, roll back dropped listens, export every enum, guard timestamps - #9341
Conversation
Quest-Claim: f6236aedfd5c66f5
…roll back cancelled listens, export every enum Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ps, and saturation; test the moq-ffi fixes 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>
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>
… mid-start Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou'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 10 minutes. View limit details
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. |
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion inline.
Approach: sound — each fix lands where its bug comes from: watch itself now enters run, the window producer keeps its finished track through the broadcast's existing Children::keep path, and a drop guard handles listen's rollback.
Reviewed changes
Reviewed all 16 files across the 10 commits: the moq-ffi runtime routing, window retention, and server lifecycle changes, the libmoq header generation, and the three binding timestamp helpers.
Background::watch/supervise: everywatchcaller now getsrun's panic isolation, shutdown accounting, and runtime context.supervisekeepsMoqSession::watchfrom nesting twice.MoqSession::closedandstate_changedstill nest tworuns throughTask::run, but nestingPollingandhostis harmless.MoqJsonWindowProducer::finish: it keepsFinishedin the broadcast'sChildren, as audio and video producers already do.Family::Releaseddrops the strong broadcast, so this creates no cycle.MoqServerPhase::Starting+Rollback: I traced a failed bind, a concurrentcancel, a drop before the first poll, and a drop mid-start. Each one ends inIdleorCancelledas intended.settleblocks under the phase lock the same waycancelalready did.- libmoq
build.rs: cbindgen'sincludelist now comes from scanningsrc/forpub enum moq_*. The new test checks four of those names. - Kotlin/Python/Dart timestamps: added zero-scale guards, the Kotlin
Longquotient check, exactBigIntegernanoseconds intoTimestamp, and unsigned u64 reads in Dart. I checked the arithmetic in the new test cases.
claude-opus-5-5 | 𝕏
|
quest land watch: ended this pull request's pick, disarming its auto-merge, since its head 8686830 is held by finding by pullfrog[bot]: If the phase lock is poisoned, this (written by quest land watch) |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the single commit since the prior pullfrog review.
Rollback::droppoison tolerance: the drop guard now takes the phase lock withunwrap_or_else(PoisonError::into_inner), so a panic unwinding throughlistencan no longer double-panic and abort. This resolves the earlier finding.
claude-sonnet-5-5 | 𝕏

Finishes quest/m1/precut-audit/ffi-and-bindings-fixes.md.
Summary
ffi::run.Background::watchnow wraps its call inrun, so the ten exported methods behind it get panic isolation,stopped()cancellation, shutdown poll accounting, and the runtime context, like every other entry point.MoqMediaCatalogConsumer::subscribegoes throughwatchtoo. A newBackground::superviseis the owner-failure select withoutrun, forMoqSession::watch, which nests two owners.Task::runandMoqServer::acceptdrop their now-redundant innerrun.MoqTrackProducer::adopthands the typed writer its broadcast'sChildren.MoqJsonWindowProducer::finishkeeps themoq_json::window::Finishedthere, as media producers already do, so a late subscriber still finds the window until the broadcast closes. Snapshot and stream producers stay as they are: moq-mux retires their catalog entry on finish on purpose.MoqServer::listenrolls back. A newPhase::Startingholds the loop until its address arrives, and aRollbackdrop guard turns a dropped or failed listen back intoIdle. It stops the loop without blocking and keeps it asIdle::stopping. The nextlistenorcancelwaits for the loop to release its sockets, so the same address binds again. Before this, a listen dropped mid-start leftListeningin place, and every laterlistenfailed with "already listening".moq.hdeclares every enum.build.rsnow builds cbindgen's include list by scanningsrc/forpub enum moq_*instead of keeping a hand list. That addsmoq_orderandmoq_refresh, plusmoq_announce_kind,moq_connection_phase,moq_decode_read_kind,moq_follow_event, andmoq_json_window_kind, which signatures already reached. A future enum can't be forgotten.toDuration(): errors on a zero scale, and on a seconds quotient past aLongthat used to wrap negative (Timestamp(ULong.MAX_VALUE, 1)gave -1 s).toTimestamp(): rejectsDuration.INFINITE, and builds the nanosecond count from exacttoComponentsparts instead of the saturatinginWholeNanoseconds. It accepts anything that fits in 64 bits of nanoseconds (about 584 years) and errors past that.to_timedelta(): raisesValueErroron a scale that isn't positive.toDuration(): throwsArgumentErroron a zero scale, and readsvalueandscaleas the unsigned u64 they are. A Dartintpast 2^63 holds them as negative.Choices made without asking (for review)
toTimestampaccepts up to 2^64 ns, not just up to 292 years as the quest's Plan said. Every value in that range converts exactly, and moq-net's write still refuses one past its own bound withTimeOverflow.scale <= 0check. A "negative" Dart scale is a valid huge u64.demand_handle_outlives_finish).json_window_demandis updated to match.Rollbackdrop guard takes a poisoned phase lock rather than panicking, since it may run whilelistenunwinds (Pullfrog's finding).listenthat waits for a dropped loop reports that loop's panic, if it had one.Public API
Additive only.
moq.hnow declares seven more enums. The Kotlin, Python, and Dart timestamp conversions throw on inputs that used to give wrong values. The window producer's finish keeps the track until the broadcast closes. No breaking API change. Wire: none.Validation
just rs test -p moq-ffi: 327 passed. New tests:watch_isolates_a_panic_and_enters_the_runtime, with and without an owner.json_window_finish_serves_a_late_subscriber.server_listen_dropped_mid_start_rolls_back.json_window_finish_serves_a_late_subscriberandserver_listen_dropped_mid_start_rolls_backboth failed without their fix.just rs test -p libmoq: 208 passed, including the newheader_declares_every_enum. I also checked the generatedmoq.hby hand: all 20pub enum moq_*insrc/are declared.just py test(128 passed),just dart check(all tests passed),just kt check(:moq:jvmTestran and passed), each with new cases for the guards above.just rs checkpasses. The fulljust checkpassed every language check exceptrs, which failed on formatting; aftercargo fmt,just rs checkpasses.Caused by
Background::watchpolled only throughhost, outsideffi::run(found by reviewer: precut audit).MoqMediaCatalogConsumer::subscribebuilds its consumer outsiderun(found by reviewer: precut audit).MoqJsonWindowProducer::finishdrops the newFinishedhandle, releasing the track (found by reviewer: precut audit).listenwaits for its address with no rollback if it is dropped (found by reviewer: precut audit).moq_orderandmoq_refreshwithout adding them to the header's enum list (found by reviewer: precut audit).Follow-ups
None.
Models
Size: M
Implementer: Claude Code, claude-opus-5-5, unknown effort (arm A)
Implementer: Claude Code, claude-opus-5-5, unknown effort (iterate, XS, arm A)
🤖 Generated with Claude Code
Review
Rewritten by
quest reviewafter each round.Head: 82b0184
Base: origin/main at f1b6e06
Risk: medium,
FFI runtime routing, server cancellation, finished-window retention, timestamp conversions, and additive C enum exports change behavior binding consumers rely on, but introduce no API or wire break and can be fully undone by reverting.Classified: medium by Codex, gpt-6.1-sol, low effort, session
01a201d4-49fd-7e03-a431-bb48ba48fba6Reviewer: Codex, gpt-6.1-sol, high effort
Session:
01a2018a-b02d-7d63-80fa-2b4286a652c8, round 3Score: 10/10,
The incremental change safely recovers a poisoned lock during rollback cleanup, with no new issues found by code review; builds and tests were not run as instructed.Rounds: 3; first round 1 (medium 1); findings 1 (medium 1): fixed 1, refuted 0, open 0
Findings: none