Repository navigation
fix: clip at grapheme boundaries at all text cut sites - #10422
aniruddhaadak80 wants to merge 1 commit into
Conversation
f79d992 to
c6a7a97
Compare
|
Fast Gate root-caused: Comment History Gate flagged 3 markers on my added lines - (#10380) refs in both test docstrings and a used-to narration phrase. Removed the issue refs and restated the shared-guard rationale in present tense (no behavior change). Folded into the single fix commit (branch stays at 1 commit, within the 2-commit rule). CI re-running. |
|
Correction: my narration fix never actually landed - the amend committed a clean index and the edits sat uncommitted in the worktree (merge ref proved it). Re-done properly this time with in-commit verification (docstrings confirmed marker-free in HEAD). Branch is back to 1 commit. CI re-running on the real fix. |
5464cfd to
c813d52
Compare
Opus 5 Review (fork) — ✅ no blocking findingsReviewed Review detailsNothing blocks; three advisory findings, all in prose the diff adds — an invisible source literal and two misstated justifications. FINDING — src/kiro_crew/imessage/plaintext.py:66 — FINDING — src/kiro_crew/apps/builtins/ops_mission_control/backend/notify_out.py:244 — the new comment justifies splitting an oversize leading cluster with "the oversize body is then rejected by payload validation, which drops the notification", but FINDING — src/kiro_crew/imessage/plaintext.py:77 — the recorded rationale for widening from combining class to [OPUS-REVIEWED] e24d1b8 |
Design Review (Fable 5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS Undocumented hunk rewrites Watch
Suggestions
[DESIGN-REVIEWED] 69257e8 Description read[DESCRIPTION-READ] 8e99813112f32f390b3602c7e88c23cc57e9c95ffd7e2199f144fe7da2910fe0 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Fable 5, fork) — 🔴 BLOCKPremise-level review of First-Principles-Verdict: BLOCK The Not justified as shipped
What this change shipsInventory (6 items) — 5 justifiedIntent: FIX — user-visible strings at three cut sites must never end mid-glyph (Fixes #10380).
BlockersTrigger (b) — a rider the fix is already complete without. The change is framed as a FIX; the [FIRST-PRINCIPLES-REVIEWED] 69257e8 Description read[DESCRIPTION-READ] ce91bfb16b2ea71bf420204627d3687dd08395d6395cb1663809b99f93152b68 That sha256 names the PR description this verdict read. Recompute it with |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsFINDING -- src/kiro_crew/apps/builtins/ops_mission_control/backend/notify_out.py:243 -- A 4,001-character body passes the bus’s 20,000-character limit, so “is then rejected by payload validation” contradicts the executable guard -> Fix: qualify the rejection threshold or remove this claim. (origin: validation) |
|
🤖 Kiro Crew [operator: NicholasRBowers#a942f9ca]: This PR has been inactive with failing CI. I've assessed the blockers and they appear resolvable — I'll push fixes directly to this branch as a co-author. Assessment: No reviewer has raised a finding against this code — every lane failed to produce a verdict at all ( If you'd prefer I don't touch this PR, add the |
|
Rebased onto current One conflict, in Verification on the rebased tree:
This also clears the "inactive with failing CI" notice from NicholasRBowers on 2026-09-23; the previous head's failures were from the stale run. CI is restarting on |
871e7df to
96fbfb6
Compare
|
Note on the description edit: |
96fbfb6 to
78eae17
Compare
|
Both blocking findings were the same real defect, and it was mine. Reproduced, fixed, and pinned. The bug.
Both confirmed against the real functions, not reasoned about. After the fix: 6 and 2000. The fix — the caller's budget as the fallback, per Opus 5's suggestion, at both sites: A cluster that wide is hostile or malformed input rather than a glyph, and on this input the cap is the contract. Regression tests for both sites, as Design Review asked for ("with a test on a long crafted cluster"): Not taken up: Design Review's suggestion to promote Verification: Also fixed while I was in the tree: the incidental black reformat of |
78eae17 to
3431fc6
Compare
3431fc6 to
e24d1b8
Compare
|
Confirmed and fixed. Measured on the reported input before the fix: The class is the wrong property to test on its own — a mark belongs to the preceding base whatever its class is. And erring wide here can only move a cut earlier, never split a cluster, so the module's "never separate a mark from its base" guarantee gets strictly stronger rather than traded off. Blast radius, since this touches a shared helper: New tests pin all three scripts at the exact code points, so a mark that happens to have a nonzero class (like the U+0E49 my first Thai test used, which is why this slipped past me) can no longer stand in for a class-zero one.
Note this one was pre-existing in the guard, and the pre-change |
A slice by code point can land inside a grapheme cluster, which is the unit a reader sees as one character, so the result is a changed or broken glyph. The repository already carries a guard for exactly this (_grapheme_boundary / _grapheme_end in imessage/plaintext.py, measured against ZWJ families, flags, skin tones, keycaps and combining accents), but three cut sites each modelled only a subset of the mechanisms. _title_reveal_prefixes in dashboard/chat_title.py extended past combining marks only, 1 of 6 mechanisms: on a ZWJ family two frames ended on a dangling U+200D and animated a broken family in the sidebar. The _clip in computer_use/render.py (flat[:limit]) turned a family into a half family at limit 3 and dropped the tone mark off a Thai word, and that text is the user's own desktop, so non-Latin is the normal case. The _clip in ops_mission_control/backend/notify_out.py turned a flag into a lone regional indicator, a boxed letter rather than a flag. All three now route through the shared guard, which is already imported cross-module elsewhere and is stdlib-only, so there is no cycle and no second implementation to drift. Reveal extends each cut to the grapheme end, keeping the same frame rhythm on clean cuts. Both _clips pull the cut back to the boundary and emit the leading cluster whole rather than an empty cut. Bare digit runs are deliberately not masked, so steady progress through a parametrised case still reads as progress. A leading cluster WIDER than the limit has no boundary below it, and _grapheme_boundary then returns 0. Falling back to _grapheme_end there -- the emit-whole shape _preferred_cut uses, where the chunker sends everything anyway -- walked forward uncapped and defeated the limit the _clips exist to enforce: a Zalgo run of 41 code points came out of render._clip at limit 5 as 42 characters, and render's inputs are macOS accessibility fields that nothing else bounds, so that text reaches the model unbounded. At notify_out the same input produced an oversize body that the notify bus rejects, which drops the "an incident is waiting on a person" note behind a WARNING. Both sites now take the limit itself as the cut when the boundary is 0: a cluster that long is hostile or malformed input rather than a glyph, and the cap is the contract. The guard decides what "boundary" means, and it asked unicodedata.combining(), which is the canonical combining CLASS. That is 0 for a large share of real marks -- Thai U+0E31 MAO EK, Khmer U+17C1, the Devanagari matras -- so the class alone declared them safe to cut after and split a grapheme the reader sees as one character, in exactly the non-Latin text the clip exists to protect. It now also tests the general category (Mn/Mc/Me), which is the property that actually holds: a mark belongs to the preceding base whatever its class. Erring wide here can only move a cut earlier, never split a cluster, so the module's guarantee gets stronger. The helper's only other consumer is _preferred_cut in the same file, where a marginally earlier cut is harmless. chat_title.py is on the black baseline, and reformatting it to satisfy black moved a pre-existing "/".join(...) onto a line this change adds, which the cross-platform portability gate reads as manual path assembly. The unrelated reformatting is reverted and the file stays on the baseline: this change is the grapheme cut sites, not a formatting sweep of a baselined file. Tests: test_grapheme_safe_clips.py covers the family dropped whole, the Thai tone mark kept, a class-zero Thai mark, a class-zero Khmer mark and a class-zero Devanagari matra, the flag dropped whole, short text untouched, a cluster kept whole when it fits, and -- for both _clips -- a crafted leading cluster wider than the limit that must not defeat the cap. test_chat_title.py adds a reveal test asserting no prefix ends where the next code point joins onto it, so a ZWJ family, flag, skin tone, keycap or accented sequence is never left dangling. test_imessage_plaintext.py (35), the iMessage renderer/dispatch/gateway suites, the notify_out suite (38) and the computer_use snapshot and backend suites (114) all pass. black, flake8 and isort clean.
|
PR triage (2026-10-05): DISTINCT, recommend REBASE, then keep developing I checked the full diff at
Still open on this head (raised earlier by the review lanes, repeated here only so they are tracked):
Once those are addressed and the branch is rebased, this looks ready for review. |
|
Thank you for this fix, @aniruddhaadak80 — the grapheme-boundary clipping across the three cut sites (plus the class-zero mark fix in the shared guard) is exactly right. Since this fork branch is behind |
Problem / Motivation
Goal: Text shown in the sidebar reveal animation, the computer-use desktop, and push notifications is now cut only at grapheme-cluster boundaries, so no user-visible string ever ends mid-glyph.
A slice by code point can land inside a grapheme cluster, which is the unit a reader sees as one character — the result is a changed or broken glyph. The repository already contains a guard that prevents exactly this (
_grapheme_boundary/_grapheme_endinimessage/plaintext.py, measured against ZWJ families, flags, skin tones, keycaps, and combining accents), but three cut sites each modeled only a subset:_title_reveal_prefixes(dashboard/chat_title.py) extended past combining marks only (1 of 6 mechanisms): on👨👩👧two frames ended on a dangling U+200D, animating a broken family in the sidebar._clip(computer_use/render.py,flat[:limit]) turnedAB👨👩👧at limit 3 intoAB👨👩and dropped the tone mark offหน้าก้— this text is the user's own desktop, so non-Latin is the normal case._clip(ops_mission_control/backend/notify_out.py) turnedAB🇰🇷CDat limit 4 intoAB🇰, a lone regional indicator (boxed letter, not a flag).Why it matters
Broken glyphs in the sidebar animation, model-relayed desktop text, and push notifications — all user-visible, all silent.
Not a goal
render._clipat limit 5 returned 42 characters for a 41-code-point Zalgo run;notify_out._clipat 2000 returned 4002). Width budgeting is unchanged.imessage/plaintext.py. It is stdlib-only and already covers all six joining mechanisms, so the fix is reuse, not a second implementation.What changed (motivation → approach → change)
All three sites route through the shared guard (already imported cross-module elsewhere, e.g.
_ChatSlotinchat_title.py; the helper module is stdlib-only so no cycle):_clips pull the cut back to the boundary, emitting a leading cluster whole rather than an empty cut, and fall back to the limit itself when the boundary is 0. Bare digit runs are deliberately not masked, so steady progress through a parametrized case still reads as progress._joins_previousaskedunicodedata.combining(), the canonical combining class, which is 0 for a large share of real marks — Thai U+0E31, Khmer U+17C1, the Devanagari matras — so it declared them safe to cut after and split a grapheme the reader sees as one character, in exactly the non-Latin text the clip exists to protect. It now also tests the general category (Mn/Mc/Me), which is the property that holds: a mark belongs to the preceding base whatever its class. Erring wide can only move a cut earlier, never split a cluster.Tests
test/test_grapheme_safe_clips.py: family dropped whole, Thai tone mark kept, a class-zero Thai mark (U+0E31), a class-zero Khmer mark (U+17C1) and a class-zero Devanagari matra (U+093E), flag dropped whole, short text untouched, cluster kept whole when it fits, and — for both_clips — a crafted leading cluster wider than the limit that must not defeat the cap. All pass.test/test_chat_title.py: new ZWJ-family reveal test asserting no prefix ends where the next code point joins onto it; full file green.test_imessage_plaintext.py(35), the iMessage renderer/dispatch/gateway suites,test_notify_out.py(38) and the computer_use snapshot and backend suites (114) all pass — the guard's only other consumer is_preferred_cutin the same file, where a marginally earlier cut is harmless.black,flake8andisortclean.chat_title.pyis on the black baseline, so its unrelated reformatting is reverted and it stays there — reformatting it moved a pre-existing"/".join(...)onto an added line, which the cross-platform portability gate reads as manual path assembly.Manual verification
N/A — covered by the unit tests above; the three sites are pure functions of their input string and limit.
Screenshots / video
N/A — no layout, theme, or component surface in the diff; the fix is string-boundary arithmetic in three helpers.
Pattern harvest
Not generalizable: one-off consolidation onto the existing guard; no new pattern.
Related Issues
Fixes #10380.
Checklist
Contribution License Agreement