Skip to content

protocol: fold the single-use EXEC byte reader into its caller #1704

Description

Area

area: nvx

Base and confirmed scope

Base revision: e5330ad60af7f734a7a2fa75338053b0b064e4d1.

The production EXEC decoder in nvx/src/protocol/exec.rs splits one operation
between two private functions with identical feature/target guards:

  • prefixed_string and prefixed_bytes:
    prefixed_string only calls S::convert(prefixed_bytes(...)?, what).
    prefixed_bytes has no other caller.
  • decode_exec
    is the only caller of prefixed_string, once for each argument and once for
    each environment entry.
  • ExecString and its implementations
    keep the guest's byte strings and the fake OpenVMM's UTF-8 conversion distinct.
    Leave those implementations, their feature guards, and the testing feature
    unchanged.

All uses of the two private helpers and both immediate call sites were read at
the base revision. Neither helper is re-exported or part of the public API.

Proposed change

Put the existing length-prefix reading, bounds checks, non-NUL byte extraction,
allocation, and offset updates directly in prefixed_string<S>, then call
S::convert(bytes, what) at the end. Remove prefixed_bytes and its redundant
documentation and feature guard.

This leaves one private function for one operation, instead of a forwarding
wrapper and a helper with no independent caller. Retain the existing
prefixed_string name, signature, documentation, feature guard, and both call
sites. No new abstraction is needed.

Why behavior is unchanged

Move the statements without changing their order. In particular, preserve the
offset advance past the length before validating it, the bounded non-NUL check,
the single to_vec() allocation, the final checked offset advance, and conversion
only after that advance. Keep every refusal and its text exactly as it is.
The host's UTF-8 behavior and the guest's arbitrary non-NUL byte strings remain
distinct. Encoding, protocol bytes, command lines, exit statuses, and output
are untouched.

Prior work and overlap check

Checked all open and closed issues labeled code-quality and their linked pull
requests: #1683, #1685, #1689, #1692, #1696, #1700, and #1701. Their scopes do not
include this helper. The recent merged #1686 and #1688 and open #1695 contain no
corrective review feedback for this candidate.

Also read the earlier merged EXEC refactors #603 and #1000, their reviews, and
the relevant closed-unmerged search results. The earlier refactors deliberately
preserved decoder-specific conversion and error behavior; this change does too.
Neither required keeping the now-single-use byte helper. No closed-unmerged
pull request proposed this consolidation.

Rechecked every open pull request targeting dev: none changes
nvx/src/protocol/exec.rs, including its former nvx-rs/ path. Do not edit any
file that an open pull request changes.

Acceptance criteria

  • Change only the two private helper definitions in
    nvx/src/protocol/exec.rs; do not change their callers or the testing
    feature.
  • Preserve the public API and leave nvx/public-api/ unchanged.
  • Preserve protocol bytes, validation/error order, error messages and
    ErrorKinds, golden fixtures, guest command lines, exit statuses, and
    output exactly.
  • Record that the affected existing tests pass at the base revision, then
    run them unchanged with the refactor. Use the existing EXEC decoder
    acceptance/error cases and conformance/property coverage in
    protocol::tests, including the Linux guest-feature cases.
  • Keep existing tests and fixtures unchanged. This introduces no new
    abstraction; if the implementation instead introduces one, give it a
    focused unit test without changing existing tests.
  • Add no dependency, feature, or unsafe code, and make no bug fix.
  • Keep the total diff below 1000 changed lines (insertions plus deletions
    reported by git diff --shortstat), including any tests and docs.
  • Pass the gates selected by scripts/local_gates.py --base origin/dev,
    following .github/actions/check-nvx/action.yml, including the relevant
    feature/target builds, public-API comparison, and guest checks. Report
    unavailable local gates explicitly and verify their CI results.

Follow-ups

None required for this self-contained slice. Broader decoder changes, visibility
changes, test restructuring, and other modules are outside this issue.
No suspected bug is included in this proposal.

Activity

  1. ppenna commented on Nov 17, 2026

    @ppenna
    ContributorAuthor

    Assignment to Pedro Henrique Penna (@ppenna) is verified. Native planning status could not be set: GitHub reports status: null and viewerCanSetStatus: false. Explicit invocation of nvx-fix-issue for #1704 was refused because disable-model-invocation is enabled. No alternative workflow was substituted: no production code or tests were changed, no validation was run, and no pull request was created. Continuing requires native issue-status permission and a user invocation (or enabling model invocation) of nvx-fix-issue for #1704. The confirmed candidate and acceptance criteria remain in the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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