Skip to content

Conversation

@Iliya-usov
Copy link
Collaborator

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

Copy link

Copilot AI left a 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
Copy link

Copilot AI left a 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");;
Copy link

Copilot AI Feb 4, 2026

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.

Copilot uses AI. Check for mistakes.
}
}

public static class RdIdUtil
Copy link

Copilot AI Feb 4, 2026

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.

Copilot uses AI. Check for mistakes.
foreach (var x in items)
{
(x as IRdBindable).IdentifyEx(ids, id.Mix(i++));
(x as IRdBindable).IdentifyEx(ids, ids.Mix(id, i++));
Copy link
Collaborator

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.

@ulex
Copy link
Collaborator

ulex commented Feb 4, 2026

I have a similar thing in ultimate in branch, but would be happy to switch to your impl. Thanks!

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.

2 participants