Repository navigation
Description
Area
area: nvx
Base and confirmed scope
Base revision: e5330ad60af7f734a7a2fa75338053b0b064e4d1.
state::write_jsonappends a newline and then translates every newline to the host separator withformat!("{text}\n").replace('\n', LINE_SEPARATOR).output::linealready performs that same transformation.provisionis the production caller ofwrite_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_SEPARATORhas 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/devpass: run the applicable authoritativecheck-nvxformatting, 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
ppenna commentedon Nov 17, 2026
#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/dev65949325, where these files are unchanged since #1709's base,b67d1196:state.rsimport exists only for the duplicated expression, and it is the only reasonLINE_SEPARATORispub(crate). Every other use is insideoutput:line,line_end_after, and its tests, which reach private items throughuse super::*. So the least visibility that compiles is private.write_jsonhas three callers, and none of them changes: productionprovisionand two restore tests (one, two).host::cli::output::tests::lines_end_as_python_prints_themis the unit test ofoutput::line, and it must pass unchanged.host::cliis 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
af7f46a3toagents/issue-1708-reuse-cli-line-rendering. It changes 8 lines inoutput.rsandstate.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 onb67d1196and merges intoorigin/devwithout conflicts.What has been validated:
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.test-changes,markdown-links,test-layout, andnvx-formatpassed.nvx-lint,nvx-test,nvx-doc, andnvx-msrvfailed to link because Git'susr\bin\link.exeshadowed MSVC'slink.exeonPATH.To finish, run
/nvx-fix-issue 1708from that branch: it still has to run the selected gates and open the pull request.ppenna commentedon Nov 17, 2026
Recovered the existing implementation in Ready PR #1733 without touching the original occupied worktree or branch.
No merge or auto-merge was performed. The PR now awaits maintainer review/approval and landing.