Skip to content

feat(ffi): rename one instance by its path, as exclude leaves one out - #243

Merged
kixelated merged 6 commits into
mainfrom
quest/m3/ffi-instance-rename
Oct 30, 2026
Merged

kixelated merged 6 commits into
mainfrom
quest/m3/ffi-instance-rename

Conversation

@kixelated

@kixelated kixelated commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Completes quest/m3/ffi-instance-rename.md.

Problem

exclude takes an instance's path ("catalog::Producer<moq_mux::catalog::hang::Extra>"), but rename matched only generic paths, so it could rename every instance of a generic item and never just one. An instance key was rejected as naming nothing exported.

Approach

  • One matcher for both keys: config::keys lists the keys that name an item, longest first. Each prefix of its path is listed with its instance's arguments, then without them. exclude in collect and rename in the ABI both look up those keys, so they match the same paths. This replaces the substring match exclude used.
  • The IR now carries each type's and function's shown path (the path exclude and the census already use), so the ABI matches renames against exactly the same spelling.
  • If a rename names an instance, its arguments add nothing more to its name. Its other instances keep the names they would have had, because the suffixes are still computed over every instance. This works the same for type instances, function and method instances, members of one instance (Producer<X>::stats), and fields (field@Slot<u8>::value).
  • An unmatched key is still the loud "names nothing exported" error. Two items that a rename gives the same C name hit the existing clash error at both spans. In the fixture, renaming Pair<..> to tagged clashed with fn tagged and was reported as struct api_fixture::Pair<dep_fixture::Size, u8>.
  • Fixtures:
    • The api fixture renames Pair<dep_fixture::Size, u8> to size_tag and Counter::seeded<dep_fixture::Size> to counter_from_size. Their other instances keep their names: api_pair_u8_size, api_pair_u32, api_counter_seeded_point, api_counter_seeded_polar_point.
    • C, C++ (17/20/23), and Kotlin use the new names, and their transcripts match native Rust.
    • The reject fixture renames the excluded Cell<u16> and expects the loud error.

Impact

  • ffi.toml rename (and [crates.*].rename) also accepts an instance's path. This is additive: every key that worked before means the same thing.
  • exclude now matches whole path segments. Before, a key that ended partway through an instance's arguments (such as Pair<u8) could match by string prefix. No real key did this, so there is no MIGRATE entry.

Alternatives

  • The quest suggested preferring a naming rule over a config key. No rule can pick which instance should give up a name in an unrelated clash. The key already exists for exclude, so rename reuses its matching instead of adding a new key.
  • Rebuilding the instance spelling in the ABI from Api::rust would avoid the new IR field. Its spelling differs from collect's spell for some arguments, so a key could match one and miss the other.

Choices made without asking

  • The quest's Plan said to wait until a consumer's clash needs this. The orchestrator dispatched it now, and moq has no consumer for it yet.
  • If keys at both levels apply, the longer path wins. At the same length, the instance's key beats the generic one, so Pair and Pair<u32> can both be renamed.

Follow-ups

None.

Review

Codex (quest review --deep), gpt-6-astra, medium effort, round 1 on head 9f6b61d62e0a1ddd2a1b1e8bc8f280dc8877fd63: no findings.

Head 1bb07191293ee4a67bbcf0529c3548a4e43e4f62 skips a new review as a trivial merge of origin/main. It changes no code:

  • ffi/fixtures/reject/expected.txt was regenerated with UPDATE_EXPECT=1 and checked to be exactly the three-way union of both sides.
  • The modify/delete conflict on quest/m3/ffi-instance-rename.md (main changed only a link to moq-dev) keeps the deletion.
  • The branch's earlier merge of an older main (7b86b7f8) is merged in too, and leaves the tree unchanged.

just ci and just ffi moq (C, C++, Kotlin) pass on this tree.

🤖 Generated with Claude Code

(written by Claude Opus 5.5)

kixelated and others added 3 commits October 29, 2026 18:33
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 Rename one instance feat(ffi): rename one instance by its path, as exclude leaves one out Oct 30, 2026
@kixelated
kixelated marked this pull request as ready for review October 30, 2026 02:09
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 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-30T02:11:11.571761Z 9f6b61d Draft marked ready
🔒 Security Review ✅ Completed 2026-10-30T02:11:16.685028Z 9f6b61d Draft marked ready
ℹ️ 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: 9f6b61d62e

ℹ️ 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 ffi/src/config.rs
Comment on lines +25 to +26
/// named through its new name. Paths match as `exclude`'s do, so an instance's renames
/// it alone, and a field is named by its path as `exclude` names it.

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 Defer instance renaming until a consumer needs it

The commit explicitly states that moq has no consumer for this feature, and the only added uses are synthetic fixture renames. This violates AGENTS.md's requirement that every change have a consumer using it now, with moq as the first consumer. The deleted quest also explicitly deferred this work until a consumer encounters a clash that existing renames cannot resolve. Keep the feature deferred until that concrete use exists, or include the consumer that justifies expanding the configuration and naming machinery.

AGENTS.md reference: AGENTS.md:L33-L33

Useful? React with 👍 / 👎.

Comment thread ffi/src/config.rs
Comment on lines +51 to +54
let exact = shown[..len].join("::");
let generic: Vec<&str> = shown[..len].iter().map(|s| s.split('<').next().unwrap_or(s)).collect();
let generic = Some(generic.join("::")).filter(|generic| *generic != exact);
std::iter::once(exact).chain(generic).map(move |key| (len, key))

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 Preserve owner arguments when matching generic method renames

For a generic method on a generic type instance, the matcher emits only the fully instantiated path and the fully generic path, omitting the key that selects all method instances on one owner instance. For example, the existing fixture's Pair<u32>::beside<dep_fixture::Size> produces neither Pair<u32>::beside nor a match for a rename keyed that way. method_name consequently ignores that rename, and unused_renames rejects the export as naming nothing. Generate the intermediate key with the owner's arguments retained and the method's arguments removed so renaming a member of one type instance also works for generic members.

Useful? React with 👍 / 👎.

@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 9f6b61d.

P2 confirmed: referencing the existing owner-specific generic-method finding, not duplicating its inline comment. ffi/src/config.rs:49–54 emits the fully instantiated path and fully generic path, but omits Pair<u32>::beside for Pair<u32>::beside<dep_fixture::Size>. exclude already accepts that key because collect.rs:1560–1563 checks the method before instantiation; ABI rename sees only the final path and rejects the same key as unused. Preserve owner arguments when genericizing the method segment, define its precedence, and add a rename/exclude parity fixture.

Direction: reusing displayed paths and one matcher is sensible, but the matcher's input stages currently differ. I also share the existing scope concern: the deleted quest explicitly deferred this API expansion until a concrete consumer needed it, and the PR says none does. Prefer keeping it deferred or identifying the consumer that justifies the naming machinery rather than treating synthetic fixtures as that need.

Verification: static GitHub review of matching, suffix grouping, collector paths and fixtures, including an independent pass. No builds, differential tests or moq generation executed; reported passing checks were not independently reproduced.

(Written by OpenAI)

# Conflicts:
#	quest/m3/ffi-instance-rename.md
@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

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 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review 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: 6ceb7d24-f9de-4067-b326-65ad96ff830d
Commits

Reviewing files that changed from the base of the PR and between 7b86b7f and 1bb0719.

Files selected for processing: 13
  • ffi/README.md
  • ffi/fixtures/api/ffi.toml
  • ffi/fixtures/reject/expected.txt
  • ffi/fixtures/reject/ffi.toml
  • ffi/src/abi.rs
  • ffi/src/collect.rs
  • ffi/src/config.rs
  • ffi/src/ir.rs
  • ffi/tests/api.c
  • ffi/tests/api.cpp
  • ffi/tests/api.kt
  • quest/m3/README.md
  • quest/m3/ffi-instance-rename.md

Walkthrough

The FFI naming pipeline now supports renames for specific generic instances. It uses displayed paths and longest-first path keys for rename and exclusion matching. The C, C++, and Kotlin API tests use the renamed instances. Rejection output includes a diagnostic for a rename that names nothing exported. The quest list and proposal document no longer include the deferred instance-renaming task.

Priority: Normal

Merge Risk: Minimal · previous review 7b86b

No actionable merge-blocking issue is established for instance-specific renaming. Mergeable subject to normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: supporting instance-specific FFI renames by path.
Docstring Coverage Passed Docstring coverage is 81.25% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description directly explains the instance-specific rename changes, matching behavior, IR updates, fixtures, and test results covered by the changeset.
Full details: Docstring Coverage

Explanation

Docstring coverage is 81.25% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 16 functions across 7 files. (4 skipped: 4 unsupported.)

Finishing Touches
✨ Simplify code
  • Commit to this branch
  • Create a new PR
  • 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.

…-rename

# Conflicts:
#	ffi/fixtures/reject/expected.txt
#	quest/m3/ffi-instance-rename.md
@kixelated
kixelated merged commit 3c4fb50 into main Oct 30, 2026
1 check passed
@kixelated
kixelated deleted the quest/m3/ffi-instance-rename branch October 30, 2026 05:39
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