-
Notifications
You must be signed in to change notification settings - Fork 59
Add SequentialIdentities to avoid RdId collisions #588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Problem:
The old Identities class mixed parent ID into dynamic IDs, which caused
collisions.
Solution:
- Add SequentialIdentities class with two ID strategies:
* Dynamic IDs (Next): Sequential integers ignoring parent, preventing
order-dependent collisions. Client IDs are even, server IDs are odd.
* Stable IDs (Mix): Hash-based with the high bit set (0x8000000000000000)
ensuring they never collide with dynamic IDs.
- Add Identities to SerializationCtx for consistent ID generation during
serialization (required for intern roots).
- Mark old Identities class as deprecated/obsolete.
- Make RdIdUtil internal to prevent accidental direct usage.
API changes in IIdentities:
- Next(parent): generates next dynamic ID
- Mix(rdId, tail): creates stable ID from hash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 86 out of 88 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| myInternRoot.RdId = RdId.Mix("InternRoot"); | ||
| myProtocolValueSet.RdId = RdId.Mix("ValueSet"); | ||
| myInternRoot.RdId = proto.Identities.Mix(RdId, "InternRoot");; |
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an extra semicolon at the end of this line. It should be a single semicolon, not a double semicolon.
| } | ||
| } | ||
|
|
||
| public static class RdIdUtil |
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the PR description, RdIdUtil should be made internal to prevent accidental direct usage. However, this class is still marked as public. Consider changing it to internal.
rd-kt/rd-framework/src/test/kotlin/com/jetbrains/rd/framework/test/cases/RdSignalTest.kt
Show resolved
Hide resolved
| foreach (var x in items) | ||
| { | ||
| (x as IRdBindable).IdentifyEx(ids, id.Mix(i++)); | ||
| (x as IRdBindable).IdentifyEx(ids, ids.Mix(id, i++)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this thing could also be migrated to seq ids. I'm not sure how to preserve backward compatibility, though. Maybe it could be in another PR.
|
I have a similar thing in ultimate in branch, but would be happy to switch to your impl. Thanks! |
Problem:
The old Identities class mixed parent ID into dynamic IDs, which caused collisions.
Solution:
Add SequentialIdentities class with two ID strategies:
Add Identities to SerializationCtx for consistent ID generation during serialization (required for intern roots).
Mark old Identities class as deprecated/obsolete.
Make RdIdUtil internal to prevent accidental direct usage.
API changes in IIdentities: