Repository navigation
Description
Area: area: nvx (gpt).
Base revision: e5330ad60af7f734a7a2fa75338053b0b064e4d1.
What can be simpler
check_protective_mbr collects the MBR's four partition records into a temporary Vec<&[u8]>. It only indexes and iterates that collection; it never grows, owns, or changes the records. The records already occupy a contiguous 64-byte region of the local MBR buffer, with 16-byte records at offsets 446 through 510.
Use the standard library's borrowed fixed-size chunk view instead:
let (records, _) = mbr[MBR_RECORDS_OFFSET..MBR_SIGNATURE_OFFSET]
.as_chunks::<MBR_RECORD_SIZE>();Add the corresponding explicit borrow in u32_at(&records[protective], MBR_RECORD_START_OFFSET), because indexing now yields an array rather than a stored slice reference. Keep every other operation unchanged. as_chunks is available since Rust 1.88, below the crate's 1.89 MSRV.
This removes an unnecessary collection and heap allocation, makes the record width part of the borrowed view's type, and reduces the code. No new custom abstraction, dependency, feature, or unsafe code is needed.
Use-site confirmation and behavior
All uses of the local records value are within the function and were read at the base revision: locating the first protective record, reading its starting LBA, and enumerating the remaining records to reject nonzero bytes. The view yields the same four records in the same order; its remainder is empty because 510 - 446 is exactly four times 16.
The function's only caller is Disk::read, before the header and partition checks. Its production entry is the guest's read_disk. The existing u32_at accepts the same bytes through the array-to-slice coercion. No signature or caller changes.
Preserve the read and validation order, including MbrSignature, NoProtectiveRecord, ProtectiveRecordStart, and MbrRecords, and preserve all error messages and ErrorKinds. Public API, protocol bytes, golden fixtures, guest command lines, exit statuses, and output do not change. The private module's feature and target gates stay unchanged. No module moves or changes purpose, so layout documentation needs no edit.
Prior work and overlap
Checked all current open and closed code-quality issues: #1683, #1685, #1689, #1692, #1696, and #1700, and their linked pull requests. #1686 and #1688 merged; #1695 is open. Their reviews recommended approval without corrective threads. No closed-unmerged code-quality proposal was found. None concerns GPT or MBR records.
Checked the changed files of every open pull request targeting dev, including equivalent legacy nvx-rs/ paths in #1509. None changes nvx/src/gpt/mod.rs. Keep all files held by another open pull request untouched.
Base validation
At the base revision, with no tracked changes:
cargo test --locked --lib --no-default-features --manifest-path nvx\Cargo.toml gpt::on Windows: passed, 30 passed, 0 failed, 0 ignored, 161 filtered out. GPT is compiled undercfg(test)even without guest features.- The unchanged protective-MBR tests cover missing signatures, missing/prohibited records, starting LBA, nonzero extra records, a protective record in a different slot, and 4096-byte logical blocks.
python scripts\nvx.py verify: blocked, because the OpenVMM submodule is not initialized in this worktree. No OpenVMM files were changed. This does not prevent the independent Cargo-only unit check above; broader validation remains outstanding.
Acceptance criteria
- Replace only the temporary record collection and its necessary borrow in
nvx/src/gpt/mod.rs; preserve the function's remaining operations and validation order. - Keep existing tests unchanged and rerun the affected tests above after the change. Record the base pass, rather than inventing a failure reproduction or regression test for this behavior-preserving refactor.
- A new abstraction gets a focused unit test if implementation introduces one. None is proposed here: reuse the existing standard-library slice operation.
- Leave
nvx/public-api/snapshots unchanged and pass the public-API check without rewriting them. - Preserve protocol bytes, golden fixtures, error messages and ErrorKinds, guest command lines, exit statuses, and output exactly.
- Add no dependencies, features, or unsafe code.
- Pass the gates selected by
python3 scripts/local_gates.py --base origin/devand the applicable commands in check-nvx, including the MSRV and Linux guest-target checks. Distinguish locally executed evidence from CI-only platform validation. - Keep the entire diff below 1000 changed lines, insertions plus deletions reported by
git diff --shortstat. Expected: one production file, approximately eight changed lines. Restrict changes tonvx/and, only if necessary,doc/project-structure.md; no scripts, workflow, data, or OpenVMM changes.
Follow-ups
None required for this self-contained slice. Broader GPT parser changes are out of scope. No suspected bug was identified in this candidate.
Activity
ppenna commentedon Nov 17, 2026
Assignment to Pedro Henrique Penna (@ppenna) is verified. Native In Progress could not be set because GitHub reports
viewerCanSetStatus=falseandstatus=null. Explicit invocation ofnvx-fix-issuefor #1701 was rejected becausedisable-model-invocationis enabled, so the change workflow was not substituted or started. Unchanged baseline GPT unit tests passed 30/30; prerequisite verify failed solely because OpenVMM is uninitialized. No production/test changes or PR were made. Continuing requires native issue-status permission and a user-enabled/invokednvx-fix-issueskill.ppenna commentedon Nov 17, 2026
Implementation is saved in signed commit
e5bb60f
on
agents/issue-1701-borrow-mbr-records.The change is limited to
nvx/src/gpt/mod.rs(2 insertions, 4 deletions):borrow the four protective MBR records with
as_chunksand borrow theselected record for
u32_at. Validation order, errors, tests, fixtures,public API snapshots, and on-disk bytes are unchanged. Independent code
review found no significant issue.
Base:
659493256316ec367ce36ffbc9dad62b471b28b4, freshly fetched fromdev.OpenVMM was initialized at the unchanged pin
c7122cd2022cfd96f6a923593bc584f51c228ab8.Validation:
python scripts\nvx.py verify(Windows) andpython3 scripts/nvx.py verify(Linux): passed at base and head.cargo test --locked --manifest-path nvx\Cargo.toml --all-features --lib gpt::on Windows: 30 passed at base and after the change.
cargo test --locked --manifest-path nvx/Cargo.toml --all-features --lib gpt::on Linux: 33 passed at base and head.
python scripts\check_test_changes.py --base origin/dev: passed,zero existing-test changes.
python scripts\local_gates.py --base origin/dev --run --keep-goingon Windows: test-change, Markdown, test-layout, formatting, all Clippy
feature sets, all/default/no-default Rust tests, documentation, and MSRV
gates passed. The CLI gate was stopped after the Linux blocker was
established; it is not claimed as passed.
python3 scripts/local_gates.py --base 659493256316ec367ce36ffbc9dad62b471b28b4 --run --keep-goingon Linux: Rust formatting, all Clippy feature sets, all/default/no-default
tests, documentation, public API checks, MSRV, macOS checking, and musl guest
lint/tests/build passed. Public API snapshots remained unchanged.
python;both passed with the existing
python3exposed as a process-local shellfunction, using the same gate runner with
--only markdown-links test-layout --run --keep-going.No module named pip). No packages were installed. Running the action's unchangedvalidation commands without its installation step ran 2,302 tests:
one failure and 41 skips.
The Windows CLI gate also exposed a runner PATH issue: the gate runner
prepends Git's
usr/bin, so a test's directrustcinvocation selectedGit's
link.exedespite Cargo being explicitly configured for MSVC.python -m unittest scripts.test_nvx_tools.CiConfigurationTests.test_windows_curl_shim_retries_http_500 -vpassed (1 test) when rerun in the same MSVC environment with its linker
first on PATH. The broader CLI run remains incomplete; no repository
workaround was introduced.
The blocker is
scripts.test_nvx_tools.SandboxSmokeProfileTests.test_sleeper_subshell_records_and_reaps_its_sleepers.Its
/procscan foundsleep\x00611.25\x00. The exact commandpython3 -m unittest scripts.test_nvx_tools.SandboxSmokeProfileTests.test_sleeper_subshell_records_and_reaps_its_sleepers -vfailed with the same assertion on both the untouched base and fixed head,
on the same Linux virtual machine. No tests were modified and no other
session's processes were terminated.
No Ready PR has been opened because the required local-gates condition is
not green. CI/review follow-through and runtime scenarios therefore remain
unrun. This is an implementation/validation blocker report, not a request
to merge or close the issue. The session-owned Linux worktree and build
outputs were removed; the signed branch and local isolated worktree remain.