Skip to content

cli: reuse line rendering for sandbox configuration #1708

Closed

Description

Area

area: nvx

Base and confirmed scope

Base revision: e5330ad60af7f734a7a2fa75338053b0b064e4d1.

  • state::write_json appends a newline and then translates every newline to the host separator with format!("{text}\n").replace('\n', LINE_SEPARATOR).
  • output::line already performs that same transformation.
  • provision is the production caller of write_json.
  • The existing line-rendering unit tests, sandbox state/lifecycle tests, and CLI integration tests cover the affected paths.

All references to LINE_SEPARATOR, all uses of output::line, and every write_json call were read at the base. The only separator reference outside output and its child tests is this duplicated expression. Both production files and their adjacent tests are unchanged at the inspected origin/dev, b67d11964c7523e088ba7ff9c7ebcc399f5d868c.

The open and closed code-quality issues and their linked pull requests were checked, including the review feedback on #1686, #1688, and #1695. No overlapping candidate or rejected version of this proposal was found. None of the eight open pull requests targeting dev changes either production file.

Change

Use the existing output::line(text) helper in state::write_json, then make output::LINE_SEPARATOR private to its module. Update the output module's introductory documentation to acknowledge its shared text-line rendering role. Do not introduce another abstraction or change the module layout.

This removes a second implementation of one platform-specific text rule and leaves the separator behind the helper instead of exposing it crate-wide.

Behavior preservation

For either separator (\n or Windows \r\n), translating the newlines in text and then appending the separator produces exactly the same bytes as appending \n and translating all newlines. This also preserves empty input, trailing newlines, embedded carriage returns, and existing CRLF input; this is not newline normalization.

Keep the temporary-file naming, write/flush/permissions/rename/cleanup sequence, error messages, error codes and ErrorKinds unchanged. No public API, protocol, guest command line, guest output, or exit status changes. Add no dependencies, features, or unsafe code.

Acceptance criteria

  • Record that the affected existing tests pass at the base revision, then pass unchanged after the refactor.
  • Reuse output::line; LINE_SEPARATOR has the least visibility that compiles across the relevant features and targets.
  • Public API snapshots, protocol bytes, golden fixtures, and existing tests stay unchanged.
  • Any new abstraction gets a unit test; none is proposed here because the existing helper and tests are reused.
  • Restrict the diff to the two production files above, including their directly related inline documentation. Leave module-layout documentation unchanged because no module moves.
  • Total insertions plus deletions stay below 1000, measured with git diff --shortstat (the expected diff is about ten lines).
  • The gates selected by python scripts\local_gates.py --base origin/dev pass: run the applicable authoritative check-nvx formatting, Clippy feature matrix, tests, rustdoc, MSRV, public-API and cross-target checks; run the other selected quality/CLI gates as applicable. Report platform/prerequisite gaps explicitly and obtain the remaining evidence from CI.

Follow-ups

None proposed. No suspected bug or security vulnerability is part of this issue. Do not expand this task into other serialization or output changes.

Activity

  1. ppenna commented on Nov 17, 2026

    @ppenna
    ContributorAuthor

    #1709 duplicates this issue and is being closed in its favor. It proposes the same change and adds the following, each point checked at origin/dev 65949325, where these files are unchanged since #1709's base, b67d1196:

    • The state.rs import exists only for the duplicated expression, and it is the only reason LINE_SEPARATOR is pub(crate). Every other use is inside output: line, line_end_after, and its tests, which reach private items through use super::*. So the least visibility that compiles is private.
    • write_json has three callers, and none of them changes: production provision and two restore tests (one, two).
    • host::cli::output::tests::lines_end_as_python_prints_them is the unit test of output::line, and it must pass unchanged.
    • Narrowing the visibility changes no public API: host::cli is hidden, and both items are already crate-private.

    A fix already exists but has no pull request. The automation session that filed this issue pushed the SSH-signed commit af7f46a3 to agents/issue-1708-reuse-cli-line-rendering. It changes 8 lines in output.rs and state.rs. The session was cancelled before it opened a pull request; after it resumed, it filed #1709 from an issue list fetched before this issue existed. The commit is based on b67d1196 and merges into origin/dev without conflicts.

    What has been validated:

    • Unit tests: the commit message records that the affected output, sandbox state, and lifecycle unit tests passed at the base on Windows and on Linux/KVM (24 passed, one ignored), and on Windows after the change.
    • Windows gates: test-changes, markdown-links, test-layout, and nvx-format passed. nvx-lint, nvx-test, nvx-doc, and nvx-msrv failed to link because Git's usr\bin\link.exe shadowed MSVC's link.exe on PATH.
    • Linux gates: the run stopped while compiling.

    To finish, run /nvx-fix-issue 1708 from that branch: it still has to run the selected gates and open the pull request.

  2. ppenna commented on Nov 17, 2026

    @ppenna
    ContributorAuthor

    Recovered the existing implementation in Ready PR #1733 without touching the original occupied worktree or branch.

    • Signed recovery commit: 6226af9. Its stable patch ID matches af7f46a.
    • Diff remains exactly two production files, 4 insertions and 4 deletions; existing tests, public API snapshots, protocols and OpenVMM pin are unchanged.
    • Unchanged affected tests passed before and after on Windows and Linux: 24 passed, one existing ignored helper per run.
    • Applicable Windows/Linux local gates passed. The PR records the process-only MSVC linker correction, approved isolated Linux Python dependencies, exact commands and results.
    • Current-head CI run https://github.com/microsoft/nvx/actions/runs/44126426700 succeeded, including Required status check. Final rollup: 46 successful, 9 skipped, no failed or pending checks.
    • Copilot reviewed the exact head and recommended approval; no unresolved threads or maintainer requests remain. The PR is mergeable.
    • Session-owned remote worktree, build output and Python environment were removed. The signed recovery branch is preserved on origin.

    No merge or auto-merge was performed. The PR now awaits maintainer review/approval and landing.

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