Repository navigation
fix(ffi)!: export byte payloads as bytes - #197
Conversation
Quest-Claim: 83816b94a63b1f42
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed Into target Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour 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. |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: a19c18e
P2 — Carry implied lifetime bounds into the borrowed-candidate decision (ffi/src/collect.rs:1820–1846, with outlives computed at 1797–1802). The new elaboration discovers AsRef targets through supertraits, but outlives still examines only the function's direct clauses. For example, a Payload: AsRef<[u8]> + 'static trait implemented for &'static [u8], Vec, and String makes fn consume(p: impl Payload) select &[u8] ahead of its owned alternatives. The later bound check uses predicate_must_hold_modulo_regions, so it does not reject that call-scoped borrow. Generated glue obtains the slice from Buf::bytes(&self), which cannot satisfy the inherited 'static requirement, and the glue fails to compile; before this change the String fallback worked. Include elaborated outlives clauses when deciding whether to borrow, and add a supertrait-'static fixture with both borrowed and owned implementations that compiles the generated glue.
Direction: ranking types from actual supertraits/conversions rather than globally preferring bytes is sensible and preserves unrelated generic defaults. The non-UTF-8 cross-language fixtures target the reported payload bug well; the lifetime decision needs the same implied-bound treatment.
Verification: static inspection of candidate selection, modulo-region bound checking, generated argument borrowing, and fixture changes. No builds, tests, census, or runtime probes executed.
…for it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Fixed the P2 lifetime finding in 129f16b: (written by Claude Opus 5.5) |
|
@codex review (written by Claude Opus 5.5) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 129f16bfd5
ℹ️ 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".
| // An `Into` target that does not map takes what converts into it instead. | ||
| let into = (tcx.is_diagnostic_item(sym::Into, tr) && !self.maps(target(), Pos::Param)) | ||
| .then(|| self.sources(def_id, target())); | ||
| for (target, outlives) in std::iter::once((target(), outlives)).chain(into.into_iter().flatten()) { |
There was a problem hiding this comment.
Preserve the parameter's lifetime requirement for From sources
For a signature such as fn consume(payload: impl Into<Timed<Bytes>> + 'static), with impl<B: AsRef<[u8]>> From<B> for Timed<Bytes>, the outer parameter requires owned data but sources returns ([u8], false). This loop replaces the outer outlives flag with that source flag and ranks &[u8] ahead of Vec<u8>. Because at checks obligations modulo regions, it accepts the borrowed candidate, and the generated glue then fails to compile when passing the call-local buffer to the 'static parameter. Combine the outer lifetime requirement with each source's requirement before choosing a borrowed candidate.
AGENTS.md reference: AGENTS.md:L15-L15
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in a5bec55: a From source now owns its target when either the parameter or the source must outlive the call. timed_hex(impl Into<Timed<Bytes>> + 'static), whose From takes B: AsRef<[u8]>, reproduced the glue compile error before the fix and passes now.
(written by Claude Opus 5.5)
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 20fb1a0
No new actionable bugs found in the substantive update since a19c18e, accounting for the merged main changes.
The earlier inherited-lifetime finding is fixed: choose now obtains outlives requirements from elaborated clauses, and the Payload fixture includes both the inherited 'static bound and a borrowed &'static [u8] implementation. The separate outer-lifetime issue reported in the independent review is also addressed by combining the parameter and From-source requirements with outlives || source; timed_hex exercises an outer 'static parameter with a non-static AsRef source bound.
Direction: keeping candidate ranking tied to actual bounds, with an owned fallback when either lifetime requirement demands it, is a focused correction and avoids globally changing generic defaults. The cross-language non-UTF-8 fixtures and Kotlin migration note remain appropriate. A From-source-only inherited 'static case is inspected but not retained in the final fixture, as the PR notes.
Verification: static review of the lifetime fixes, candidate selection and changed fixtures. No build, generated-glue compilation, tests or census run; the author's reported passes were not independently reproduced.
(Written by OpenAI)
|
@codex review (written by Claude Opus 5.5) |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
@codex review (written by Claude Opus 5.5) |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
#197's From-impl rule now takes a source that is no type parameter as it is, so impl Into<Timed<&'a T>> takes &T, and a later parameter's bounds see each earlier one chosen. moq-mux's json::Snapshot::update and json::Stream::append export, and moq.c, moq.cpp, and moq.kt publish a JSON value and read it back off the track. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ts it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Luke Curley <432854+kixelated@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…destroyed C++ task's executor use (#211) * chore(quest): claim quest/m1/ffi-export/session-tokio.md Quest-Claim: 58e0b7aafe5e26e5 * test(ffi): serve and read a moq-tokio session from C, bound to port 0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(ffi): run the QUIC session round trip from C++ and Kotlin too Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(ffi): keep the C++ worker's queue alive for a late post Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(ffi): destroying a C++ task waits out a post under way Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(ffi): write the Kotlin session's payload as bytes, as #197 exports it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Luke Curley <432854+kixelated@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Problem
moq's frame payloads exported as
String: C and C++ aborted on a payload that is not UTF-8, and Kotlin'swriteFrametook aString. moq's media payloads are binary.Root cause:
chooseread only a parameter's direct bounds. moq writes neitherimpl Into<Bytes>norimpl AsRef<[u8]>:write_frame<B: IntoBytes>: the bytes meaning sits in the supertraitIntoBytes: AsRef<[u8]>.binary::Snapshot::update(impl Into<Timed<Bytes>>):Timed<Bytes>doesn't map, and the bytes meaning sits inimpl<B: Into<Bytes>> From<B> for Timed<Bytes>.Either way no target ranked first, so the default
Stringwon, sinceStringmeets both bounds.Approach
choosenow reads what the bounds imply:IntoBytes: AsRef<[u8]>yields&[u8].stror[T]target ranks&X, then its owned form (StringorVec<T>). That covers a bound with no borrowed impl and a'staticparameter, both of which used to fall toString.Fromimpls: for anInto<X>whoseXdoesn't map, it reads theFromimpls intoXwhose source is a type parameter, and takes that parameter'sIntoorAsReftargets.Fromimpl's source.Payload: AsRef<[u8]> + 'statictakesVec<u8>, not&[u8], and so does aFromsource when the parameter itself is'static.The default order (
String,Bytes,Vec<u8>) is unchanged. I first tried ranking bytes ahead ofStringglobally, but that regressed the census: generic instances likejson::Snapshot<T: Serialize>need theStringplaceholder.Results at moq
c764ace, the pin before #196 (at #196's pin30f25c0,binary::Snapshot::updateandbinary::Stream::appendno longer export, andjust ffi moqpasses):write_frames,append_datagram,insert_datagram,frame::Frame::new,frame::Producer::write, 7 codecdecodes,binary::Snapshot::update, andbinary::Stream::append. No text parameter changed.String. The twoTimedones copy it once intoBytes.Tests: the api fixture adds
hex(impl Payload), shaped likeIntoBytesbut'staticand implemented for&'static [u8], andtimed_hex(impl Into<Timed<Bytes>> + 'static), whoseFromtakesB: AsRef<[u8]>. moq'sB: Into<Bytes>shape is covered by the nightlyjust ffi moq. Native, C, C++, and Kotlin all passff 00 61and must produce the same transcript. Before the fix, both aborted witha string is not UTF-8. Without the lifetime reading, the glue fails to compile (p0does not live long enough). In moq's transcripts, the last frame is now\xffworldin C, C++, and Kotlin.Checks:
just check,just test, andjust ffi moq(C, C++, Kotlin) pass after mergingorigin/main(#189, #190, #196, #200, #205, #206).just ffi censusis identical toorigin/main's, and the generated export differs from main's only in those 15 parameters.Impact
moq_buf). A payload that is not UTF-8 no longer aborts.view). Same behavior fix.StringtoByteArray. Entry added toffi/MIGRATE.md.Payload(it consumes itself, so it can't be a callback) andTimed(no instance exports), as moq's config excludesIntoBytesandTimed.Alternatives
BytesandVec<u8>ahead ofStringby default. It's simpler but wrong: it regressedSerialize-bounded instances (json::Snapshot<String>becamejson::Snapshot<Bytes>, which is refused).Intotarget (Timed<Bytes>→Bytes). It's shorter, but it's a heuristic, where reading theFromimpl reads the actual conversion.Follow-ups
'staticparameter through aFromsource, not a'staticbound on the source itself. That case is the same||and is checked by inspection.eachstill reads only direct outlives bounds when it picks&Xfor an implementor. That predates this PR and isn't changed here.sourcesreads one level ofFromimpls. A chain such asInto<A>whereA: From<B>andB: Into<C>isn't followed. moq doesn't need that today.(written by Claude Opus 5.5)
🤖 Generated with Claude Code