Repository navigation
host: give the hexadecimal text of identities one parser and one writer - #1688
Merged
Pedro Henrique Penna (ppenna) merged 1 commit intoNov 17, 2026
Merged
Conversation
host::platform held two parsers of hexadecimal identities that differed only in their length: parse_hex_id, for 32 digits and 16 bytes, and parse_hex32, for 64 digits and 32 bytes. The lowercase-hexadecimal Display loop was written out three times: as snapshot::key's private write_hex, which KeyIdentity's Display called through the identity! macro, and inline in the Display of BootId and of CaptureIdentity. host::platform now holds one const-generic parse_hex::<N>, the body of both parsers for 2 * N digits, with which BootId, the host's and the boot's IDs, CaptureIdentity, and KeyIdentity parse, each call inferring N from the array that it builds; and one write_hex, moved from snapshot::key, which the Display of all three identities calls. host::platform already lies beneath process, config, and snapshot in host's order of dependencies, and all three imported its parsers, so no module depends on one that it did not depend on before. The text that each identity writes and parses, its error messages, and its serde form do not change. The affected unit tests, those of host::platform, host::process, host::config, and host::snapshot::key, pass unchanged at 621f8b2 and with the change, on Windows with Rust 1.97.1: 124 before, and 125 with the new test, hexadecimal_text_is_written_in_lowercase_and_read_in_either_case, which covers both functions: a round trip in either case, the refusal of an odd, short, or long length, a digit beyond f, a sign, and a non-ASCII byte, and the lengths of the host's identities. Refs #1685 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 shared hexadecimal identity parsing and formatting changes.
No open issues 🎉
What changed in this PR
This PR addresses #1685 by centralizing hexadecimal identity parsing and formatting in nvx::host::platform, preserving existing text formats, errors, serialization, and public APIs.
Changes:
- Replace the two fixed-length parsers with one const-generic
parse_hex::<N>. - Share one lowercase hexadecimal writer across boot, capture, and snapshot key identities.
- Add unit coverage for formatting, case-insensitive parsing, invalid input, and identity lengths without modifying existing tests.
| File | Description |
|---|---|
nvx/src/host/snapshot/key.rs |
Use shared helpers and remove the local writer. |
nvx/src/host/process.rs |
Route BootId parsing and formatting through shared helpers. |
nvx/src/host/platform/tests.rs |
Add hexadecimal parser and writer coverage. |
nvx/src/host/platform/mod.rs |
Define the generic parser and shared writer; update host-ID parsing. |
nvx/src/host/platform/linux/process.rs |
Use the generic parser for Linux boot IDs. |
nvx/src/host/config/mod.rs |
Use shared helpers for capture identity formatting and deserialization. |
Review effort: Balanced
Pedro Henrique Penna (ppenna)
enabled auto-merge
November 17, 2026 04:56
7 tasks
Pedro Henrique Penna (ppenna)
deleted the
agents/issue-1685-hex-identity-text
branch
November 17, 2026 06:03
This was referenced Nov 17, 2026
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 #1685
What does this pull request change?
nvx::hostnow parses and writes the hexadecimal text of its identities with one function each, both private to the crate, inhost::platform. Start withnvx/src/host/platform/mod.rs.platform::parse_hex_id, which parsed 32 digits into 16 bytes, andplatform::parse_hex32, which parsed 64 digits into 32 bytes, had the same body apart from the length. The lowercase-hexadecimalDisplayloop was written three times: assnapshot::key's privatewrite_hex, whichKeyIdentitycalls through theidentity!macro, and inline inBootIdandCaptureIdentity.platform::parse_hex::<N>replaces both parsers, for2 * Ndigits into[u8; N], and each caller infersNfrom the array that it builds:BootId, the host's and the boot's IDs,CaptureIdentity, andKeyIdentity.platform::write_hex, moved fromsnapshot::key, writes the text ofBootId,CaptureIdentity, andKeyIdentity.ErrorKinds, its serde form, the public API, and every existing test.A new unit test,
host::platform::tests::hexadecimal_text_is_written_in_lowercase_and_read_in_either_case, covers both functions: a round trip in either case, the refusal of an odd, short, or long length, a digit beyondf, a sign, and a non-ASCII byte, and the lengths of the host's identities.Left out: the follow-ups that #1685 lists: the host's other hexadecimal text, which builds a
Stringbyte by byte, ashost::cli::hexdoes, and the same text outsidehost, inguest_restore,protocol,uuid, and the guest, which a crate-wide module could serve.Why is this change needed?
Two parsers that differed only in a constant and three copies of one loop defined a single text form, so a change to that text had to be made in each copy, and each new identity added one.
host::platformalready held the parsers, and it lies beneathprocess,config, andsnapshotinhost's order of dependencies, whichnvx/tests/host_modules.rschecks. All three already imported its parsers, so sharing the writer there adds no dependency betweenhost's modules.Alternatives rejected:
guest_restore,protocol,uuid, and the guest could share too. A new top-level module changes the layouts innvx/README.mdanddoc/project-structure.md, which the open pull requests arm64: add native cold-boot foundation #1509 and ci: check that every pull request references an issue #1679 change, so host: give the hexadecimal text of identities one parser and one writer #1685 leaves it as a follow-up.Displayadapter type in place ofwrite_hex(formatter, bytes). It adds a type, where moving the existing function, the form thatsnapshot::keyandguest_restorealready use, is enough.How was this change validated?
Checks and results, with Rust 1.97.1, at the base 621f8b2 and with the change, 842e7f5. The change preserves behavior, so the affected tests, unchanged, stand in for a reproduction:
cargo test --locked --all-features --lib -- host::platform:: host::process:: host::config:: host::snapshot::key::(innvx/)python scripts\local_gates.py --base origin/dev --run, aftercargo build --release --locked --features cli --manifest-path nvx/Cargo.tomltest-changes(0 changed tests, 1 added),markdown-links,test-layout,nvx-format,nvx-lint,nvx-test(1099 library tests with all features),nvx-doc,nvx-msrv, andnvx-cli(2261 tests, 88 skipped, and 84 adversarial tests, 11 skipped)python3 scripts/local_gates.py --base origin/dev --run --keep-going --only nvx-format nvx-lint nvx-test nvx-doc nvx-public-api nvx-msrv nvx-macos nvx-guest-binaries-lint nvx-guest-binaries-buildnvx-public-api,nvx-macos, and both guest-binary gates;nvx-testran 1816 library tests with all featuresOn both hosts, the tests that pin the identities' text,
host_identities_are_read_as_openvmm_reads_them,boot_identities_have_one_text_form,the_current_boot_has_one_identity,equal_captures_have_one_identity_in_one_text, andidentities_have_a_text_form, pass before and after the change.A code-review pass over the whole diff found no issues.
Backend, host OS, host type, and guest: no VM ran. The Linux checks ran in a temporary worktree on an Azure Linux 3.0 virtual machine with KVM; the change starts no VM and affects no backend, so no microVM scenario applies.
Left to CI:
nvx-clivalidation: the Linux host's Python lackspip, which the gate's first step runs. Its Windows counterpart passed locally.CI run 44019934502 of the head, 842e7f5, passed, among its jobs
nvxon Ubuntu and Windows,NVX CLIon Linux and Windows, and the microVM tests on KVM, MSHV, and WHP.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-rs/public-api/withpython3 scripts/public_api.py --update.description says how the change versions or migrates them.
No documentation describes the functions that change, which are private to the crate. The public API, snapshots, protocols, and on-disk formats are unchanged: each identity writes and parses the same text, with the same messages, and
python3 scripts/public_api.pypasses.