fix(hub): reject a second register from an already registered agent - #161
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Reject a second REGISTER from an agent peer that is already registered.
Why
InterfaceRegistry_RegisterAgentrestartedagent_channelat 0 on every call and never checked the peer, so a second REGISTER on a live connection created duplicate(peer_id, channel)keys.FindByAgentChannelalways resolved to the stale entry, and the agent's ChannelMap had already been reassigned by the second ACK. Audit finding HUB-1 (HIGH).interface_id; wrong fan-out, wrong counters and shaper entryHubPeer_SetAgentNameoverwrites the peer name while the registry keeps the old oneHow
Guard in the registry domain (the "one registration per peer_id" invariant belongs there), before the collision check: reject with
REGISTER_STATUS_REJECTED. No broker change — the existing!registeredpath already sends the ack and disconnects, and the early return keeps the peer name in sync. Reusing status 1 means no wire orprotocol.mdchange. Both disconnect paths clear the registry, so a reconnecting agent is never blocked; ghost displacement (#146/#149) is unaffected because it always involves a different peer_id.Testing
make testgreen (405 tests)Notes
No wire-format impact. The reference agent sends REGISTER once per connection, so no legitimate flow is affected.