Repository navigation
feat(ffi)!: export setters for an object's pub fields - #189
Conversation
Quest-Claim: 960131fbad487495
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c732e7c62f
ℹ️ 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".
| let at = owner_name | ||
| .filter(|owner| name.starts_with(&format!("{owner}_"))) | ||
| .unwrap_or(&self.prefix); | ||
| format!("{at}_set_{}", &name[at.len() + 1..]) |
There was a problem hiding this comment.
Document setter-name collisions in the migration guide
For an existing exported object with a public field x and a method set_x, the new setter claims the method's C name and makes a previously valid export fail until the method is renamed in the config. The new reject fixture confirms this collision, so the public API change is not purely additive. Add an entry under ## Unreleased in ffi/MIGRATE.md describing the collision and the required rename; the commit description alone does not satisfy the repository's breaking-change requirement.
AGENTS.md reference: AGENTS.md:L47-L47
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 410fb74: added an ## Unreleased entry to ffi/MIGRATE.md, retitled the PR feat(ffi)!, and marked the Impact bullet breaking.
(Written by Claude Opus 5.5)
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: c732e7c
The existing setter-name collision finding is valid: an existing set_<field> method can now make export fail. Add the migration note and required rename to ffi/MIGRATE.md; this is not purely additive. Referencing that finding rather than duplicating an inline comment.
No additional actionable bugs found in the collector, naming, generated assignment, or C/C++ fixture changes. Reusing the ordinary &mut self borrow checks and get/edit/set-back for nested values is a sensible, simpler design than reach-through setters. Whole-field refusal is explicit, though it also removes getters whose setters cannot map.
Verification: static inspection only; I did not run tests, builds, or the census.
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: 410fb74
The previously referenced migration-note finding is fixed: ffi/MIGRATE.md:5–7 now documents the setter/method name collision and required rename.
This is the only file change since c732e7c; the base is unchanged. No new actionable bugs found. The focused compatibility note is appropriate, and the previously reviewed setter design is unchanged.
Verification: static comparison and documentation inspection only; tests, builds, and census were not run.
|
@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: 410fb74570
ℹ️ 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".
| Ok(set) if matches!(set, Type::Ref(..)) || lends_inside(&set) => { | ||
| Err(why("'static borrow", ty.to_string())) |
There was a problem hiding this comment.
Document the rejection of previously exported borrowed fields
For an existing object with a public borrowed field such as pub label: &'static str, this now refuses the entire field, including its previously supported getter, and makes exporting fail unless the field is excluded. The new Tag reject fixture confirms this behavior. The migration entry covers setter-name collisions but not this separate breaking change; extend ffi/MIGRATE.md under ## Unreleased to explain the rejection and required exclusion. (Written by GPT-6.1 Sol)
AGENTS.md reference: AGENTS.md:L47-L47
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 92858dd: ffi/MIGRATE.md now says a field whose setter can't map is refused whole, with the borrowed-field example and the exclude it needs.
(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. |
…used whole Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@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". |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 92858dd
The independent borrowed-field migration finding is fixed: ffi/MIGRATE.md:8–10 now explains that an unmappable setter removes the whole field, including its old getter, and gives the required exclude. The earlier setter-name collision note remains intact.
Only these three documentation lines changed since 410fb74; the base is unchanged. No new actionable bugs found. This focused migration guidance fits the existing whole-field design without adding implementation complexity.
Verification: static comparison and documentation inspection only; tests, builds, and census were not run.
🛡️ 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. |
…ield-setters # Conflicts: # ffi/fixtures/reject/expected.txt # ffi/src/collect.rs
|
@codex review (Written by Claude Opus 5.5) |
|
Codex Review: Didn't find any major issues. Another round soon, please! 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. |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 0c5a68d
Reviewed the integration since 92858dd, separating imported main changes from the setter-specific changes. No new actionable bugs found. Both prior migration-note findings remain fixed.
The Kotlin setter calls now have transcript coverage for moved objects, byte buffers, Copy handles, nullable fields, and renamed fields. Exposing setters as functions fits the existing move/close semantics better than hiding consumption in a property assignment; the existing parameter-count guard keeps them distinct from getter properties. The collector integration retains whole-field refusal and ordinary mutable borrowing without new special cases.
Verification: static comparison of the merge/integration, collector, Kotlin call generation, and added fixture calls only. I did not run tests, builds, or census.
(Written by OpenAI)
…nd Kotlin With #189's setters and the foreign types mapped, `connect.url`, `tls.fingerprint`, and `listen.bind` generate setters. moq's tests set each and read it back, which closes field-setters' goal end to end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…#190) * chore(quest): claim quest/m1/ffi-export/foreign-types.md Quest-Claim: f7dcad73d3172280 * feat(ffi): export Url, SocketAddr, paths, and Vec<T> across the C ABI `url::Url` exports as an object parsed from text, failing with the parse error's message; `SocketAddr` as `<prefix>_socket_addr`; `&Path` and `PathBuf` as a buffer of the OS's bytes; and `Vec<T>` of any other mapped `T` as `<prefix>_vec_<T>`, an array C frees with what it holds. C++ gets `std::vector`, lowered through an arena that lives for the call. moq's config drops the excludes these unblock and renames moq-mux's `catalog::Consumer`, which now clashes with hang's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(ffi): keep moq's excludes sorted Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(ffi): keep Url out of values, free returned Vec<&T> clones A `Url` field makes its type an object, as any handle C cannot copy does, so reading the value no longer consumes it. A returned `Vec<&T>`'s free drops the clones it holds. A parameter's `Vec` refuses a reference nested in its elements, and C++ takes an optional `Vec` of handles by value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(ffi): carry Url, SocketAddr, paths, and Vec<T> through the Kotlin export A path is a String, which throws for one that is not UTF-8; a SocketAddr is an InetSocketAddress, which throws for an IPv6 flow label Java does not keep; a Vec<T> is a List, whose objects close once a call moves them in. The JNI reader keeps each array it reads until the call returns. The api transcript uses a UTF-8 path, which Kotlin can express, with the non-UTF-8 round trip checked from C and Kotlin's refusal of one as a broken case; moq.kt mirrors moq.c's foreign-type checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(ffi): close Kotlin objects moved in through a boxed Vec Gate the close on `moved` alone, which already recurses through Box, so a Box<Vec<T>> parameter closes each object as Option<Vec<T>> does. The api fixture's `worth` takes Option<Box<Vec<Counter>>>, and Kotlin checks a counter it moved in is closed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(quest): plan slices and SocketAddrV4/V6 for the exporter The follow-ups #190 leaves: `&[T]` of any mapped type (12 refusals at the pinned moq) and the typed socket addresses moq-tokio's listen config holds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(ffi): move objects in through a bare Box<Vec<T>> too `worth` takes an Option<Vec<Counter>> and a Box<Vec<Counter>> apart, so the fixture covers a boxed Vec without an Option around it, which the Kotlin close missed before b368920. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(ffi): set a session's URL, fingerprints, and bind from C, C++, and Kotlin With #189's setters and the foreign types mapped, `connect.url`, `tls.fingerprint`, and `listen.bind` generate setters. moq's tests set each and read it back, which closes field-setters' goal end to end. 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
A
pubfield of an exported object exported only a getter returning a copy, so C could read a session's config but not fill it in (found from C in #161).Approach
Each
pubfield of an object now exports a setter beside its getter:x.field = value, taking&mut selfand the value by move.&mut Tdoes, checked at run time, and assigns in place. A handle lent&mut(the catalogmutatelends) writes Rust's own value. A handle lent shared, or one a future holds, aborts, as Rust would refuse it. No copy is hidden.tls, setsinsecure, and setstlsback, as Rust does with values. This adds no names per path.set_after its type's name:moq_connect_config_set_tls, andmoq_backoff_set_initial_settingfor the renamedfield@Backoff::initial. In C++ it becomes the memberconnect_config::set_tls.'staticin a handle, so C's borrow for the call can't fill it.Tests:
Copyhandle,None, and a renamed field's setter.set_<field>method, and a'staticborrow field.moq/moq.c: setsconnect::Config'stls.insecureandtls.host_nameby get, edit, set back, and setsimplementation. It also moves astatstrack into the lenthang::Catalogin onemutateand reads it back in the next.moq/moq.cpp: the same config through the C++ header.tests/api.kt: the Kotlin transcript makes the same setter calls and matches native.Ran
just check,just ffi test(C, C++, Kotlin),just ffi moq, andjust ffi census. The rest ofjust test(ts, driver, uniffi) was not run, since this PR touches onlyffi/.Census
Identical before and after (
diff -roftarget/census): no field newly refused, and exported and refused counts are unchanged. moq's header gains 442 setters.The quest's other named fields (
connect.url,tls.fingerprint,tls.generate,listen.bind'sSocketAddr) are still refused for their types:url::Url,Vec<String>,SocketAddr. foreign-types (#190) owns those. Their setters come with no further work once the types map.Impact
<prefix>_<type>_set_<field>(self, value)for each exported field of an object, plus the matching C++ membersset_<field>. The contract hash changes, as it does with any header change.set_<field>on the same type. That is a compile error at both spans, fixed by arenameof the method. This is noted inffi/MIGRATE.md. moq has no such clash.ffi/MIGRATE.md. The census shows no such field in moq.Access::Fieldgainsset. Kotlin already matchesAccess::Field { .. }.Alternatives
<getter>_setsuffix: simpler for renamed fields, but reads oddly in C and C++.set_tls_insecure): one name per path, which grows with nesting.Choices made without asking
set_naming rule above, including renamed fields.Follow-ups
setFirst(value), a function rather than avar, since setting an object moves it in and closes its handle, which an assignment would hide.Closes the quest
quest/m1/ffi-export/field-setters.md.(Written by Claude Opus 5.5)
🤖 Generated with Claude Code