Skip to content

chore(quest): plan instance names that adding code elsewhere keeps - #264

Merged
kixelated merged 2 commits into
mainfrom
quest-plan/ts-stable-names
Oct 30, 2026
Merged

kixelated merged 2 commits into
mainfrom
quest-plan/ts-stable-names

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Problem

moq-dev/rust2#259 found that adding a generic instance in rust2-ts can rename another module's import: a fixture closure renamed floats.ts's mapOr$Option_Ordering_u8_floats_closure0, so the fixture was changed to avoid it. Unrelated code then changes the output, which churns snapshots and consumers' generated diffs.

Reproduced on main at a0f08f4. Adding out.push(1u8.partial_cmp(&2).map_or(7, |o| o as i8 as u8)); to the lang fixture's fmt::added fails stable_names on core/option.ts's mapOr$Option_Ordering_u8_floats_closure0.

Approach

Adds quest/m2/ts-stable-names.md and ranks it first in m2.

  • Root cause: Program::merge (ts/src/program.rs) keeps whichever identical std instance sorts first by Symbol::key, and that name carries the member closure's identity. Program::name numbers matching suffixes $2 on in key order, which is the same flaw.
  • Why stable_names missed it: its one added root, fmt::added, reaches only a local generic (Wrap::map), which never merges, and no suffix collision.
  • Plan: name a mergeable instance from its merge key, using a signature-based suffix or a short hash of its output (the implementer weighs these), and replace the $n counter with a disambiguator taken from the instance itself. Extend stable_names to cover both paths.

Impact

None: a quest-only change. The planned work renames merged and collided std instances once.

Choices made without asking

  • One new quest. No existing quest covers naming.
  • Milestone m2, ranked first. The translator's research work is in m2, and this churn hits every concurrent translator PR's snapshots and moq's comparison diffs. It isn't m0 because no consumer ships the output yet, and it isn't m3 because it isn't a std gap. Ranked first because it is small and every other m2 translator quest's snapshots run into it.
  • The $2 collision numbering is in scope because it is the same problem (AGENTS.md: fix every instance in one PR).

Alternatives

Follow-ups

None.

Review

Skipped for head 75ec2cc: a quest-only change. quest check and just check passed locally.

(written by Claude Opus 5.5)

🤖 Generated with Claude Code

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

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

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 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: 0103163d-eea2-403a-b795-955a062d1192
Commits

Reviewing files that changed from the base of the PR and between 9df3118 and f4b0281.

Files selected for processing: 2
  • quest/m2/README.md
  • quest/m2/ts-stable-names.md
  • 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.

@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: 75ec2cc4b22531607bd08842b770468be0f5f3af.

P2 — Specify collision handling for the hash-based naming option (quest/m2/ts-stable-names.md:41–43). A short hash is not injective: distinct merge keys can produce the same suffix. Falling back to the current $2 numbering would reintroduce the order-dependent renaming this plan promises to eliminate, while omitting disambiguation could emit duplicate identifiers. Replace the unconditional injectivity claim with an explicit collision policy (for example, an injective canonical-key encoding or deterministic diagnostic), and require a forced-collision regression that adds an earlier-sorting instance without silently aliasing or renaming existing symbols. This is a correction to the proposed design, not a new runtime defect in this documentation-only PR.

Direction: naming every mergeable instance from stable intrinsic information, including singleton groups, is the right direction and preserves deduplication. Covering both merge-representative changes and suffix collisions closes the current fixture's main coverage gaps; the proposed bundle-size comparison is appropriate.

Verification limits: GitHub-only static review of the plan, Program::merge/name, and the existing stable_names fixture, with an independent pass. No tests or benchmarks were run; the reported reproduction and local checks were not executed independently.

@kixelated
kixelated merged commit 5b6adaa into main Oct 30, 2026
2 checks passed
@kixelated
kixelated deleted the quest-plan/ts-stable-names branch October 30, 2026 08:42
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