Skip to content

cli: render sandbox records with the shared line helper #1709

Closed as duplicate
Closed as duplicate

Description

Area

area: nvx (host::cli::output and host::cli::sandbox::state, feature cli).

Base and confirmed scope

Base revision: b67d11964c7523e088ba7ff9c7ebcc399f5d868c.

The CLI already has one helper that turns text into a host line:
output::line
translates every \n to the host's line separator and then appends that separator.

sandbox::state::write_json
re-implements the same rendering inline:

let text = format!("{text}\n").replace('\n', LINE_SEPARATOR);

That ad hoc expression is the only reason the
state.rs import
needs LINE_SEPARATOR, and therefore the only reason
LINE_SEPARATOR
is pub(crate). Every other use is inside output:
line,
line_end_after,
and
output's tests,
which reach private items through use super::*.

The confirmed callers of write_json are production
provision
and two restore tests,
one
and
two,
which need no change.

Proposed change and benefit

  • Make write_json render its text with output::line(text) instead of repeating the line-ending logic.
  • Remove pub(crate) from LINE_SEPARATOR, making it private to host::cli::output, the least visibility that its remaining uses require.

This leaves one implementation of the CLI's host line rendering and keeps the line-separator detail inside the module that owns standard-stream and line-ending behavior.

Why behavior is unchanged

For any text:

  • the current expression renders text.replace('\n', LINE_SEPARATOR) followed by LINE_SEPARATOR, because the appended newline is translated too;
  • output::line(text) renders exactly the same text.replace('\n', LINE_SEPARATOR) and then pushes LINE_SEPARATOR.

The temporary-file creation, private permissions, flush, rename, cleanup, error codes and messages, JSON content, and line separators on Linux and Windows remain unchanged. The visibility narrowing changes no public API: host::cli is hidden, and both items are crate-private already.

Acceptance criteria

  • write_json uses output::line, and LINE_SEPARATOR is private to host::cli::output.
  • The public API snapshots in nvx/public-api/, protocol bytes, and golden fixtures stay unchanged.
  • Existing tests stay unchanged, including host::cli::output::tests::lines_end_as_python_prints_them and the sandbox state/restore tests. Record that the affected tests pass at the base revision.
  • No new abstraction is introduced; if implementation unexpectedly needs one, it gets a focused unit test.
  • git diff --shortstat reports fewer than 1000 changed lines in total, including tests and docs.
  • The gates that the change selects pass, including the applicable check-nvx gates. Any unavailable hardware or cross-platform gate is reported as left to CI.

Follow-ups

None found in the surveyed CLI output and sandbox-state code.

Activity

  1. ppenna commented on Nov 17, 2026

    @ppenna
    ContributorAuthor

    Assignment to Pedro Henrique Penna (@ppenna) is verified. Native In Progress could not be set: GitHub reports status=null and viewerCanSetStatus=false, and both repository and organization planningStatuses are null. Explicit invocation of nvx-fix-issue for #1709 was rejected because the skill sets disable-model-invocation: true. No substitute workflow was started: no code, tests, public-API snapshots, or pull request were changed or created.

  2. ppenna commented on Nov 17, 2026

    @ppenna
    ContributorAuthor

    Duplicate of #1708, which proposes the same change. This issue's additional evidence is now on #1708: #1708 (comment). That covers why LINE_SEPARATOR can become private, the full list of write_json callers, the unit test that must stay unchanged, and why there is no public API change. The comment also links an existing fix branch for #1708.

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

Metadata

Metadata

Labels

code-qualityFindings from focused code-quality reviews

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions