Repeat the whole surrogate pair in REP #20999
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.40) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 307 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.343
Real PR Conversation Timeline
1 comments
"Review active on #20999"
general
weight: 0.35
lhecker
Summary of the Pull Request
REP(CSI Ps b) remembered only the last UTF-16 code unit that was printed. For characters outside the BMP, that is the trailing half of a surrogate pair. So for exampleprintf '\U0001FB81\e[3b'printed one U+1FB81 followed by three lone trailing surrogates.The output engine now stores the last code point (1 or 2 code units), and REP repeats all of it.
Detailed description of the pull request
OutputStateMachineEnginekeeps the last printed character asstd::array<wchar_t, 2>plus a size, instead of a singlewchar_t._StashLastCharusestil::utf16_iterate_prevto store the last code point of each print._leadingSurrogatepattern inTerminalInput.Open question: should unpaired surrogates be dropped instead of repeated? I kept the old behavior to keep the change minimal.
Validation Steps Performed
StateMachineExternalTest::TestRepeatCharacterSupplementaryPlane. It covers a pair in one string, a pair then REP in a separate write, text ending in a pair, a pair split across writes, a pair fed withProcessCharacter, a trailing surrogate after other text, and plain characters.StateMachineExternalTest::TestRepeatCharacterSupplementaryPlaneandTextBufferTests::TestRepeatCharacterboth pass on x86, x64 and arm64.Before / After
The left half shows REP printing only the trailing surrogate (
D83E DF81 DF81 DF81 DF81). The right half shows it repeating the whole pair (D83E DF81x4).https://github.com/user-attachments/assets/3969013f-5652-4278-b950-55f75fb5371a
AI disclosure: I used an AI assistant to help write and test this fix. I reviewed, understood and tested the change myself.
PR Checklist