Skip to content

protocol: limit NVXS record helpers to their callers #1692

Closed

Description

Area: area: nvx (protocol::nvxs::record).

Base revision: e5330ad60af7f734a7a2fa75338053b0b064e4d1. The candidate file is unchanged between this checkout and the current origin/dev.

What is over-exposed

Five production methods of the private NVXS record codec are pub(crate), although their callers all belong to protocol or its nvxs child. Narrow each method to the least visibility that preserves every existing use, including the unchanged tests:

Method at the base revision Replacement visibility All uses
RecordType::from_code pub(in crate::protocol) parse_header; protocol::tests::record_type; NVXS record tests at 40, 99-100, and 627
RecordType::name pub(in crate::protocol) Its Display implementation and protocol::tests::record_type
RecordType::is_bootstrap pub(super) check_bootstrap; nvxs::tests::sample; NVXS record tests at 42, 257, and 655
RecordType::allows_length pub(super) check_length and NVXS record tests at 263 and 270
ErrorCode::from_code pub(super) Record::error_code, check_payload, and NVXS record tests at 202 and 373-376

The use-site search covered the whole crate's Rust sources without filtering by active feature or target; every matching call and the module declarations were read at the base revision. record is a private child of protocol::nvxs; nvxs::tests is its sibling, so the three methods used there cannot be private without changing tests. The two methods used in protocol::tests need the wider, but still protocol-only, visibility.

Why this is better and preserves behavior

The compiler will keep record-code decoding, classification, payload-length rules, and naming with the codec and its existing callers rather than expose them to unrelated crate modules. The change is five visibility edits in one production file, approximately 10 changed lines.

No function body, constant, type, field, re-export, feature gate, dependency, or unsafe block changes. The public API remains unchanged because these methods are already crate-private. Protocol bytes, error messages and ErrorKinds, golden fixtures, guest command lines, exit statuses, and output are unchanged. Existing tests retain their current access, and no test needs an edit.

The code-quality issues and their associated open and closed PRs were checked: #1683/#1686 and #1685/#1688 are merged, with no corrective review comments; #1689 concerns CLI argument arity. No rejected closed-unmerged proposal was found. No currently open PR to dev changes this file, including the legacy nvx-rs/ path on older branches. This proposal avoids the modules changed by those recent code-quality PRs.

Acceptance criteria

  • Change only these five visibility qualifiers in nvx/src/protocol/nvxs/record.rs, to the scopes above; verify all features and supported targets compile with those scopes.
  • Keep both public API snapshots in nvx/public-api/ unchanged, and pass python3 scripts/public_api.py.
  • Preserve protocol bytes, golden fixtures, error messages and ErrorKinds, and guest-program command lines, exit statuses, and output exactly.
  • Record that the affected existing protocol tests pass at the base revision and after the change; keep all existing tests unchanged.
  • A new abstraction must have a unit test. This visibility-only change introduces no abstraction and needs no new test.
  • Keep the complete diff below 1000 changed lines, insertions plus deletions reported by git diff --shortstat; the expected diff is 5 insertions and 5 deletions.
  • Pass the gates selected by python3 scripts/local_gates.py --base origin/dev, including the applicable commands in check-nvx: rustfmt, all prescribed feature-set Clippy checks, tests, rustdoc with warnings denied, public API checks, MSRV, macOS, and guest-binary gates. Clearly distinguish local evidence from CI-only platform validation.
  • Add no dependencies, features, or unsafe code, and do not edit scripts, workflow files, data, or OpenVMM.

Follow-ups

None is required for this self-contained change, and no suspected bug was identified. Any further visibility reduction in other codec methods requires a separate use-site audit and is out of scope.

Metadata

Metadata

Labels

area: nvxInitial title-keyword triage suggestioncode-qualityFindings from focused code-quality reviews

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions