Repository navigation
nvx: keep the declarations that only their own file uses private - #1775
Merged
Pedro Henrique Penna (ppenna) merged 1 commit intoNov 20, 2026
Merged
Conversation
ENDPOINT_CLOSED of host/cli/mod.rs, check_exit of host/snapshot/capture.rs, safe_path of guest/managed_agent/launch.rs, and preparation_failure and its PreparationFailure alias of guest/snapshot.rs were pub(crate), pub(super), or pub(in crate::host), although each is used only in the file that declares it and in that file's own tests child module, which sees a private item. Make each private, the least visibility that its uses require, so the compiler enforces that the rest of the crate cannot call or depend on them. Only visibility changes; function bodies, messages, protocol bytes, and the public API stay as they were. Part of #1772 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 this change restricting the visibility of internal declarations.
No open issues 🎉
What changed in this PR
Addresses #1772 by making five internal declarations private within the nvx crate, preventing unrelated modules from depending on implementation details.
Changes:
- Removes broader visibility from host CLI and snapshot helpers.
- Makes guest path validation and snapshot preparation helpers private.
- Leaves function bodies, callers, tests, and public API unchanged.
| File | Description |
|---|---|
nvx/src/host/snapshot/capture.rs |
Makes check_exit private. |
nvx/src/host/cli/mod.rs |
Makes ENDPOINT_CLOSED private. |
nvx/src/guest/snapshot.rs |
Makes PreparationFailure and preparation_failure private. |
nvx/src/guest/managed_agent/launch.rs |
Makes safe_path private, retaining child-test access. |
Review effort: Balanced
Pedro Henrique Penna (ppenna)
deleted the
agents/issue-1772-private-declarations
branch
November 20, 2026 00:58
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 #1772
What does this pull request change?
Narrows five declarations in the
nvxcrate to the visibility that theironly users need. Each is a one-keyword change, so the diff is 5 lines added
and 5 removed across 4 files:
ENDPOINT_CLOSEDnvx/src/host/cli/mod.rspub(crate) constconstcheck_exitnvx/src/host/snapshot/capture.rspub(in crate::host) fnfnsafe_pathnvx/src/guest/managed_agent/launch.rspub(crate) fnfnPreparationFailurenvx/src/guest/snapshot.rspub(crate) typetypepreparation_failurenvx/src/guest/snapshot.rspub(super) fnfnEach item's only non-test user is in its own file, and
safe_pathis alsoused by the file's
testschild module, which sees its parent's private itemsthrough
use super::*. No item appears in the signature of a more visibleitem, so the
private_interfaceslint stays quiet. The change alters nobehavior, public API, error message, protocol byte, or guest binary, and it
adds or changes no test.
Left out on purpose: the helpers of
host/cli/mod.rsthat its submodulesuse (
temporary_path,random_bytes,io_message,check_interrupt,from_stop,from_os_error). Theirpub(crate)could narrow in principle,but doing so spreads the change across files, which the issue lists as a
follow-up.
Why is this change needed?
A declaration that is more visible than its users need makes the reader check
the whole crate before changing it, and lets another module start depending on
it by accident. Closed issues #1683, #1696, #1700, #1706, #1710, #1713, #1755,
and #1767 narrowed other declarations the same way. This pull request covers
the over-visible declarations that a scan of the crate found and whose every
use I checked.
ENDPOINT_CLOSEDwas an unconfirmed candidate of #1683.I rejected narrowing items that appear in the signature of a
pub(crate)orpub(super)item (PolicyPath,RestoreOptions,LockedSnapshot,CompiledEgressPolicy,UnmountFailure,AppliedTeardownError,DataFailure): the compiler rejects them underprivate_interfaces.How was this change validated?
Checks and results (Windows, in
nvx/unless noted):cargo fmt --all --check: passed.cargo clippy --lockedwith-- -D warnings, over--all-targets --all-features,--lib,--lib --no-default-features,--lib --no-default-features --features serde,--lib --bins --features cli, and--lib --bins --no-default-features --features testing: all passed.RUSTDOCFLAGS="-D warnings" cargo doc --locked --no-deps --all-features: passed.cargo check --locked --all-targets --all-features --target aarch64-apple-darwin: passed. One warning, inhost/snapshot/tests.rs, was already present before the change.cargo clippy --locked --all-targets --all-features --target x86_64-unknown-linux-gnu -- -D warningsandcargo clippy --locked --lib --bins --no-default-features --features guest --target x86_64-unknown-linux-musl -- -D warnings: passed. These compile the Linux-onlyguestmodule that the Windows build skips.cargo test --locked --all-features --lib -- host::cli host::snapshot: 345 passed, 0 failed, 6 ignored, the same as at the base commit.python scripts\check_test_layout.py: passed.python scripts\check_test_changes.py --base origin/dev: 0 changes to existing tests.Backend, host OS, host type, and guest: no microVM ran, since the change touches no runtime behavior. The Linux checks ran on a KVM host (Azure Linux 3.0, x86_64) in a temporary worktree at
2bcc739a9:cargo test --locked --all-features --lib -- guest::managed_agent::launch guest::snapshot host::cli host::snapshot: 394 passed, 0 failed, 7 ignored, the same as at the base commit.cargo fmt --all --check, the six clippy runs above with-D warnings,cargo test --locked --all-features,cargo test --locked,cargo build --locked --lib --no-default-features,cargo test --locked --lib --no-default-features,cargo doc --locked --no-deps --all-featureswith-D warnings, and the minimum supported Rust version check (cargo +1.89 check --locked --all-targets --all-features): all passed.python3 scripts/public_api.py: passed, with no snapshot change.python3 scripts/nvx.py check-guest-binaries --toolchain 1.97.1: passed.Left to CI: the microVM and hypervisor scenarios,
build-guest-binariesandtest-guest-binaries, and the other repository gates, none of which this change reaches.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.