fix!: eliminate MessageId collisions in dialogue routing#47
Merged
Conversation
Replace the ambiguous FindDialogueForMessage search (which could match the wrong dialogue due to MessageId reuse across dialogues, uplinks, and downlinks) with four explicit paths: - BeginDialogueCommand / BeginDialogueCommandHandler: controller starts a new dialogue with an uplink (no search) - ReplyToDownlinkCommand / ReplyToDownlinkCommandHandler: controller replies to a known downlink, looks up dialogue by ID (no search) - NewDialogueFromDownlinkNotification / handler: aircraft initiates, MessageReference is null - AircraftRepliedToUplinkNotification / handler: aircraft replies, MessageReference is set; searches open dialogues by uplink ID only FindDialogueForMessage is replaced by FindOpenDialogueByUplink, scoped to open (non-archived) dialogues and uplink messages only, eliminating both the uplink/downlink type collision and the cross-dialogue collision. SendUplinkCommand is retained for system-internal use (logon, error responses) where no server-side dialogue ID is available.
…sts for #34 - Fix all test compilation errors caused by domain model API changes (Dialogue.AddUplink/AddDownlink, ReceivedDownlink, updated constructors) - Add BeginDialogueCommandHandlerTests and ReplyToDownlinkCommandHandlerTests - Add regression tests verifying replies append to existing dialogues rather than creating new ones, and that DialogueId lookup is used when multiple dialogues share the same downlink MessageId - Add DownlinkReceivedNotificationHandler tests for fallback-to-new-dialogue, closed-dialogue isolation, and logoff message handling
Owner
Author
Code reviewFound 1 issue:
CPDLCPlugin/source/CPDLCServer/Handlers/SendUplinkCommandHandler.cs Lines 40 to 46 in da4acf5 CPDLCPlugin/source/CPDLCServer/Handlers/LogonCommandHandler.cs Lines 36 to 42 in da4acf5 CPDLCPlugin/source/CPDLCServer/Handlers/LogonCommandHandler.cs Lines 66 to 73 in da4acf5 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
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.
Replies were landing in the wrong dialogue because
MessageIdis not unique across dialogues, uplinks, or downlinks, making the search inFindDialogueForMessageunreliable. Replaced the ambiguous search with four explicit paths - controller uplinks now route viaBeginDialogueCommandorReplyToDownlinkCommand(usingDialogueIddirectly), and incoming downlinks route via dedicated notifications that either create a new dialogue or search open dialogues by uplink message ID only.Closes #34