fix(shell): decode Windows output reliably - #24
Conversation
|
Thanks @zhuowp for taking the time to contribute. This repository is observing a maintainer-managed PR intake gate in dry-run mode, so this pull request is staying open. This note helps maintainers prepare the allowlist before any enforcement is considered. Please read |
|
Independent review from the parent PR (Pinvou/pinvou-agent#348): the decoder implementation is sound and matches what upstream accepted into the 0.9.12 integration branch. One gap before publication: Missing upstream follow-up Also noting for the record: this PR currently has no approvals, and |
cc6cdc9 to
22ec868
Compare
|
Independent self-review result for exact head The explicit review request is resolved: the upstream Exact-head evidence: locked metadata, formatting, diff check, 9/9 output-module tests, 6/6 new shell-lifecycle regressions, 42/42 Publication remains blocked separately by the repository-level |
|
Review findings from the parent-side integration review (Pinvou/pinvou-agent#348), re-verified directly against candidate 1. MAJOR — the hard-invalid branch re-decodes the valid UTF-8 prefix as ACP (reverse mojibake)
Impact is bounded to one pending buffer in the delta path (pending is drained to ≤3 bytes between polls), but the synchronous paths ( Suggested fix: in the 2. MAJOR —
assert_eq!(decode_shell_bytes(b"ready \xE4", true), "ready \u{FFFD}");
Suggested fix: test the stateless path via the injectable helper (like the other tests do) so the non-Windows semantic is pinned cross-platform: decode_shell_bytes_with_legacy(b"ready \xE4", None, true)(The underlying semantic — dangling final byte decodes via ACP on Windows — is defensible; it just needs a dedicated Windows expectation rather than being asserted as U+FFFD unconditionally.) Minor items, non-blocking: the one-way legacy switch is claimed semantics but combined with finding 1 one stray byte poisons the rest of the stream (fixed by the same change); Since the parent PR pins the exact candidate SHA, any fix here changes |
Keep UTF-8 and legacy multibyte decoder state across background polls, use the Windows ANSI code page only after invalid UTF-8, and derive completion evidence from one output cutoff. Preserve UTF-8 prefixes already validated before switching the invalid suffix to the legacy decoder, and keep final incomplete-byte expectations explicit across Windows and non-Windows tests. Keep the Windows-only ACP mapping cross-platform tested without triggering dead_code in non-Windows library builds. This incorporates the behavior from upstream follow-up 0a85b13 without its policy-incompatible automated co-author trailer. Signed-off-by: zhuowp <zwp-1989@qq.com>
22ec868 to
6544900
Compare
|
Addressed both findings from the latest parent-side review in exact head
Exact-head verification: output decoder 10/10, new shell lifecycle regressions 6/6, For transparency, a broader concurrent Windows Parent Hmbown#348 will now be realigned to this exact SHA and revalidated. Repository-level advisory disposition remains a separate publication blocker. |
Realign the parent gitlink and fork inventory to the prefix-preserving decoder candidate reviewed in Pinvou/CodeWhale#24. Signed-off-by: zhuowp <zwp-1989@qq.com>
Realign the parent gitlink and fork inventory to the prefix-preserving decoder candidate reviewed in Pinvou/CodeWhale#24. Signed-off-by: zhuowp <zwp-1989@qq.com>
|
Follow-up work is available in #28. The original head repository is no longer available for additional commits or workflow dispatch, so #28 continues from a Pinvou-owned branch while preserving @zhuowp as the author of the signed topic commit. It adds the behavior-neutral Clippy fix, deterministic cross-platform test coverage, and a native Windows shell regression job. No merge or closure action has been taken on this PR. |
Realign the parent gitlink and fork inventory to the prefix-preserving decoder candidate reviewed in Pinvou/CodeWhale#24. Signed-off-by: zhuowp <zwp-1989@qq.com>
Realign the parent gitlink and fork inventory to the prefix-preserving decoder candidate reviewed in Pinvou/CodeWhale#24. Signed-off-by: zhuowp <zwp-1989@qq.com>
Realign the parent gitlink and fork inventory to the prefix-preserving decoder candidate reviewed in Pinvou/CodeWhale#24. Signed-off-by: zhuowp <zwp-1989@qq.com>
Background
Windows-native tools may emit stdout or stderr using the active ANSI code page even when the surrounding shell is configured for UTF-8. CodeWhale previously decoded those bytes as UTF-8 lossily, and background paths decoded individual polls independently. Once that happened, Pinvou Agent could no longer recover the original bytes, so both the model and UI could receive mojibake or replacement characters.
The reusable fix was first contributed upstream in Hmbown/CodeWhale #5602. This PR publishes the reviewed behavior on Pinvou's current maintenance baseline. It is based on public r10 (
feb8761aeda31749f3d54c6e1f8ef460540567a1, from Pinvou/CodeWhale #19) and contains one topic commit.Changes
-D dead_codefollow-up requested in review, with an English explanation andcfg_attron the Windows-only mapping helper.forkguard_*regression coverage.Review follow-up
Candidate head:
654490026edf2a3105858ff644c7087a23dd5f6cThis candidate resolves both findings in the parent-side review:
ShellStreamDecoder::decodenow usesUtf8Error::valid_up_to()to emit the valid UTF-8 prefix before legacy-decoding only the invalid suffix. The regression covers??followed by CP12520x92and expects??'.The earlier requested upstream follow-up
0a85b13baremains incorporated without an automated co-author trailer, which this repository's contribution policy rejects. The rebuilt candidate remains one DCO-compliant topic commit on public r10.Verification on the exact candidate
cargo metadata --locked --no-deps --format-version 1passed.cargo fmt --all -- --checkpassed.git diff --checkpassed.forkguard_*tests: 42/42 passed.tools::shellrun passed 100/104. Three timing-sensitive failures passed when rerun individually with one test thread; the remaining read-only-policy test could not locate canonicalpwdin this local environment. These are disclosed as local environment/scheduling limitations, not claimed as a full-suite pass.The exact candidate is 66 files, +6389/-794 (net +5595), and 15 commits over upstream
v0.9.5, including the already-published r10 maintenance history.Release request
pinvou-v0.9.5-r10unchanged.pinvou3-cleanafter its required checks and advisory disposition are complete.pinvou-v0.9.5-r11at the resulting final maintenance head.Risk
ACP detection is deliberately a fallback after invalid UTF-8 and cannot infer OEM or arbitrary child-selected encodings. The decoder switches one-way to its resolved legacy encoding after a genuine invalid UTF-8 suffix. The change is confined to the shell byte-decoding lifecycle and does not modify sandbox, PowerShell, Python, or command-generation behavior.
No-Issue: publishes the downstream-reviewed Windows shell output decoding fix on the Pinvou maintenance branch.