fix(lifecycle): keep install output truncation UTF-16 safe#102833
Conversation
|
ClawSweeper review: did not complete due to Codex infrastructure failure. Reviewed July 9, 2026, 9:53 AM ET / 13:53 UTC. Summary PR surface: Source +1, Tests +37. Total +38 across 2 files. Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path. Review metrics: none identified. Merge readiness This is a ClawSweeper/Codex infrastructure failure, not a PR readiness or patch-quality verdict. Risk before merge
Maintainer options:
Next step before merge
Review detailsBest possible solution: Retry the Codex review after fixing the execution failure. Do we have a high-confidence way to reproduce the issue? Unclear. The review failed before ClawSweeper could establish a reproduction path. Is this the best way to solve the issue? Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction. AGENTS.md: unclear because the file could not be read completely. Codex review notes: model internal, reasoning high; reviewed against f6b990124353. Evidence reviewedPR surface: Source +1, Tests +37. Total +38 across 2 files. View PR surface stats
What I checked:
Likely related people:
How this review workflow works
|
44ae475 to
d237624
Compare
|
Land-ready review complete at
No docs, changelog, config, dependency, or compatibility changes are needed. Thanks @LeonidasLux. |
|
Merged via squash.
|
…102833) * fix(lifecycle): keep install output truncation UTF-16 safe * test(lifecycle): exercise split surrogate boundary --------- Co-authored-by: Peter Steinberger <[email protected]>
Summary
Problem:
summarizeInstallOutputuses.slice(0, maxLen - 1)which can cut a UTF-16 surrogate pair in half, producing a broken character in install failure messages.Solution: Replace bare
.slice(0, maxLen - 1)withtruncateUtf16Safe(normalized, maxLen - 1)which backs off by one code unit when the truncation point falls in the middle of a surrogate pair.What changed: One line in
src/skills/lifecycle/install-output.ts+ new test file.What did NOT change: No behavioral changes for ASCII text. No other callers affected.
What Problem This Solves
When install error output contains multi-byte Unicode characters (emoji, CJK) at or near the 200-char truncation boundary, the current
.slice(0, maxLen - 1)can split a surrogate pair, leaving a dangling high or low surrogate in the displayed error.Root Cause
JavaScript's
.slice()operates on UTF-16 code units, not code points. Characters outside the BMP (U+10000+) are encoded as two surrogate code units. Whenslice(0, N)lands between the surrogates of such a pair, only half the character is kept. The fix usestruncateUtf16Safewhich checks for this case and adjusts the boundary.Real behavior proof
Behavior addressed: UTF-16 safe truncation at boundary
Real environment tested: Linux x86_64, Node 24.1.0
Exact steps or command run after this patch:
After-fix evidence:
What was not tested: Full end-to-end install flow. The fix is a one-line change in a pure function; unit coverage is sufficient.
Risk checklist
merge-risk: Low