Repository navigation
nvx: name the NVXC frame header layout - #2327
Merged
Pedro Henrique Penna (ppenna) merged 1 commit intoNov 28, 2026
Merged
Conversation
Frame::encode laid out the 24-byte NVXC header by the order of its extend_from_slice calls, and Frame::decode read the same fields back at raw offsets: header[..4], [4], [5], [6..8], [8..16], [16..20] and [20..24]. Only the module documentation gave the layout, and nothing tied the decoder's offsets to the encoder's order or to APP_HEADER_LEN. Name the fields in a private field module, as the outer record header does: MAGIC, VERSION, KIND, FLAGS, REQUEST_ID, STATUS and LENGTH, the last ending at APP_HEADER_LEN. Compile-time assertions check that the fields tile the header in order and that each range is as wide as its field's type. The encoder writes each field at its range, and the decoder reads each one from it. The positions and widths are the ones that the code used, so every frame encodes to the same bytes, and the decoder accepts and refuses the same inputs with the same messages. The tests of protocol::app::v2, whose wire helper builds the header independently, pass unchanged: cargo test --locked --all-features --lib protocol:: gave 109 passed at ebaffcb and with the change, on Windows. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the NVXC v2 frame-header layout refactor.
No open issues 🎉
What changed in this PR
This PR centralizes the NVXC version 2 frame-header layout, following the existing outer-record header pattern while preserving wire bytes and decoding behavior.
Changes:
- Adds private field definitions and compile-time checks for field widths and complete header coverage.
- Updates encoding and decoding to use the shared layout instead of implicit write order and raw offsets.
| File | Description |
|---|---|
nvx/src/protocol/app/v2.rs |
Defines and validates the header layout, then uses it in the frame codec. |
Review effort: Balanced
Pedro Henrique Penna (ppenna)
deleted the
agents/issue-2326-nvxc-header-layout
branch
November 28, 2026 17:22
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.
Fixes #2326
What does this pull request change?
Frame::encodeinnvx/src/protocol/app/v2.rslaid out the 24-byte NVXC frame header by the order of itsextend_from_slicecalls, andFrame::decoderead the fields back at raw offsets (header[..4],[4],[5],[6..8],[8..16],[16..20],[20..24]).This change names the fields in a private
fieldmodule, asprotocol/outer.rsdoes for the outer record header:MAGIC,VERSION,KIND,FLAGS,REQUEST_ID,STATUSandLENGTH, the last ending atAPP_HEADER_LEN. Compile-time assertions check that the fields tile the header in order and that each range is as wide as its field's type. The encoder sizes the header, then writes each field at its range; the decoder reads each field from it.Start at the
fieldmodule inv2.rs. Left out: the fake OpenVMM and the tests still index frames by raw offsets (frame[5],frame[24..]). The issue records that as a follow-up.Why is this change needed?
Before this change, only the module documentation described the layout, and nothing tied the decoder's offsets to the encoder's order or to
APP_HEADER_LEN. Now the layout is stated once and checked at compile time. The positions and widths are unchanged, so every frame encodes to the same bytes, and the decoder accepts and refuses the same inputs with the same messages, in the same order.How was this change validated?
Checks and results:
ebaffcb22a8:cargo test --locked --all-features --lib protocol::(Windows) passed, 109 tests; with the change it also passed, 109 tests.python scripts\local_gates.py --base origin/dev --runon Windows 11 passed every gate: test-changes, markdown-links, test-layout, nvx-format, nvx-lint, nvx-test, nvx-doc, nvx-msrv, nvx-cli.python3 scripts/local_gates.py --base origin/dev --runin a WSL (Linux) clone of the commit passed test-changes, markdown-links, test-layout, nvx-format, nvx-lint, nvx-test, nvx-doc, nvx-public-api, nvx-msrv, nvx-macos, nvx-guest-binaries-lint and nvx-guest-binaries-build.pip install, because Debian's system Python refuses it (PEP 668).--only nvx-cli --runfrom a virtual environment then passed.python3 scripts/check_test_changes.py --base origin/dev: 0 changes to existing tests.Backend, host OS, host type, and guest: none. The change is a pure codec refactor that preserves the bytes on the wire, so I ran no microVM. Every configured KVM and WHP host was unreachable.
Left to CI: the microVM scenarios on KVM, MSHV and WHP, and the benchmarks.
Checklist
python3 scripts/check_test_layout.pychecks.python3 scripts/check_test_changes.py --base origin/devlists no changeto an existing test, or a Changes to existing tests section below
explains each one.
.github/copilot-instructions.mdand the skills when a convention orworkflow changes.
nvxupdatesnvx/public-api/withpython3 scripts/public_api.py --update.description says how the change versions or migrates them.