Skip to content

Define runtime adapter message codes once - #738

Open
Matthew (theworker02) wants to merge 1 commit into
microsoft:devfrom
theworker02:magnexis/runtime-message-codes
Open

Matthew (theworker02) wants to merge 1 commit into
microsoft:devfrom
theworker02:magnexis/runtime-message-codes

Conversation

@theworker02

Copy link
Copy Markdown

Uses explicit #[repr(u8)] discriminants so each wire code has one definition and decoding derives from the complete set of kinds.\n\nValidation:\n- cargo fmt --all --check\n- cargo clippy --locked --all-targets -- -D warnings\n- cargo test --locked\n- git diff --check\n\nCloses #665.

Copilot AI balanced review requested due to automatic review settings October 21, 2026 22:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The localized refactor preserves existing behavior, adds no dependencies, and has no unresolved review findings.

No open issues 🎉

What changed in this PR

Centralizes runtime adapter message codes in Kind, addressing #665 while preserving the existing wire format.

Changes:

  • Defines each code once using explicit #[repr(u8)] discriminants.
  • Encodes kinds with a cast and decodes bytes by searching the complete kind list.
File Description
tests/​runtime-adapter/​src/​frame.rs Removes duplicate numeric mappings while preserving all five codes and unknown-code rejection.

Review effort: Balanced

5 => Some(Self::Stopped),
_ => None,
}
Self::ALL.into_iter().find(|kind| kind.code() == code)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple constant definition and reuse would avoid linear time here.

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.

3 participants