fix(memory-host-sdk): use truncateUtf16Safe for qmd stderr truncation#102589
fix(memory-host-sdk): use truncateUtf16Safe for qmd stderr truncation#102589Pandah97 wants to merge 1 commit into
Conversation
The summarizeQmdStderr function uses naive .slice(0, 117) which can split surrogate pairs when stderr output contains emoji or other multi-codepoint characters. Replace with truncateUtf16Safe().
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 5:29 AM ET / 09:29 UTC. Summary PR surface: Source +1. Total +1 across 1 file. Reproducibility: yes. source-level reproduction is high confidence: current main slices stderr with Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Use one canonical QMD stderr truncation PR that applies the shared helper at this call site, includes the focused parser regression test, and has redacted terminal/log proof before merging; close the duplicate only after the canonical path is proven or merged. Do we have a high-confidence way to reproduce the issue? Yes, source-level reproduction is high confidence: current main slices stderr with Is this the best way to solve the issue? The code-level fix is the right narrow helper reuse, but this branch is not the best merge vehicle until it carries focused parser coverage and real behavior proof or maintainers choose it over the related open PR with the same fix plus test. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4ad94febcb31. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +1. Total +1 across 1 file. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
This is now superseded by #102547, which landed the same The canonical fix preserves the existing 117-code-unit prefix and 120-unit summarized result while proving the thrown QMD error contains no unpaired surrogate. Thanks for independently identifying the same boundary bug. |
Summary
summarizeQmdStderr()inpackages/memory-host-sdk/src/host/qmd-query-parser.tstruncates stderr text with naive.slice(0, 117), which can split UTF-16 surrogate pairs when the output contains emoji or other multi-codepoint characters..slice(0, 117)withtruncateUtf16Safe(raw, 117)— a guarded slice that preserves surrogate pair integrity.summarizeQmdStderr+ added import.Real behavior proof
pnpm tsgo:coretype check — the change is mechanical andtruncateUtf16Safecorrectness is independently verified inpackages/normalization-core/src/utf16-slice.test.ts.cd packages/memory-host-sdk && npx tsc --noEmit src/host/qmd-query-parser.tsconfirms compilation. The substitution is a direct 1:1 replacement at a single call site.truncateUtf16Safeis already used in 13+ merged PRs (fix(oc-path): use truncateUtf16Safe for error message path truncation #102527, fix(discord): use truncateUtf16Safe for deploy error body truncation #102525, fix(memory-core): use truncateUtf16Safe for diary context truncation #102524, fix(codex): use truncateUtf16Safe for tool transcript output truncation #102522, etc.) and in sibling files within the same package (read-file-shared.ts,response-snippet.ts,internal.ts).Risk checklist
truncateUtf16Safehas standalone unit tests innormalization-core. Zero behavioral change for ASCII/BMP text paths.AI-assisted
This PR was generated with Claude Code.