Skip to content

cli: keep argument arity private to the parser #1689

Closed

Description

Area: area: nvx (host::cli::args, feature cli).

Base revision: e5330ad60af7f734a7a2fa75338053b0b064e4d1.

What is over-exposed

The CLI parser's Arity enum and Spec::arity field are pub(crate), although every use is inside host::cli::args:

A search of all Rust source at this revision found no other reference to Arity or arity. The parser has no target-specific branches; its parent host::cli compiles with feature cli, and args is private.

Proposed change and benefit

Remove pub(crate) from Arity and Spec::arity, making both private to the parser module. Keep Spec, its name field, and all three existing constructors unchanged.

This makes the constructor-based interface explicit and prevents other CLI modules from coupling to the parser's arity representation or constructing or mutating that field directly. It needs only two line replacements, introduces no abstraction, and changes no executable expression, layout, variant, or call site.

Why behavior is unchanged

Only Rust visibility changes. Parsing order, accepted arguments, error messages and error kinds/codes, help text, output, and exit statuses remain identical. Neither item is public API. No protocol, guest-program command line, fixture, dependency, feature, or unsafe code changes.

Prior work and overlap

The open and closed code-quality issue inventory was checked: #1683 and #1685 address different modules. Their linked production-code pull requests, #1686 and #1688, have no review objections to carry into this change. No closed-unmerged code-quality pull request was found.

All changed-file pages of every open pull request targeting dev were checked; none changes nvx/src/host/cli/args.rs. Do not modify any file held by those pull requests.

Acceptance criteria

  • Make Arity and Spec::arity private, the least visibility their uses require, without changing any other parser interface or logic.
  • Record passing affected CLI-parser tests at the base revision, then run the same tests after the change. Keep existing tests unchanged.
  • Leave public API snapshots, protocol bytes, golden fixtures, guest command lines, exit statuses, and output unchanged.
  • Introduce no dependency, feature, or unsafe code. If implementation introduces a new abstraction, give it a focused unit test; none is proposed here.
  • Check the relevant feature/target combinations, including CLI-only and all-features on Windows and Linux, the no-default/serde/testing configurations, and the repository's macOS and guest-target checks. Public-API checks must pass without rewriting snapshots.
  • Pass the gates selected by scripts/local_gates.py --base origin/dev and the applicable commands in .github/actions/check-nvx/action.yml; distinguish locally run gates from CI-only platform checks.
  • Keep the entire diff below 1000 changed lines (insertions plus deletions), restricted to the allowed NVX crate and module documentation paths. The expected diff is one production file, two insertions and two deletions; no documentation or test changes are needed because the module layout and behavior do not change.

Follow-ups

None required for this self-contained change. Other visibility cleanup and refactors are out of scope. No suspected bug was identified in this candidate.

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