Skip to content

fix(slack): never cut a flag, emoji or accent between two posts - #37998

Merged
RohanK6 merged 1 commit into
mainfrom
crew/conductor/slack-split-grapheme
Nov 16, 2026
Merged

RohanK6 merged 1 commit into
mainfrom
crew/conductor/slack-split-grapheme

Conversation

@RohanK6

@RohanK6 RohanK6 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A long Slack reply split into several posts never shows a flag, emoji or accented letter broken at the seam.

split_message hard-cut a line too long for one post at the limit by code point. That cut could land inside a grapheme cluster, so one post ended with a lone regional indicator, a bare base or half a ZWJ emoji, and the next began with a dangling mark; every flag after a split one paired with the wrong neighbour.

Why it matters

Slack's separate-post path (render_for_slack: cron delivery, result posts, subagent replies, the dashboard's Slack mirror; and the native handler's final reply) is where long replies split. Emoji-heavy text and non-Latin scripts show the reader corrupted characters, or a different flag from the one written. The shared splitter already avoids this since #37119; Slack's own cutter was the gap.

Not a goal

What changed (motivation → approach → change)

Symptom: a flag, emoji or accent shows broken across two Slack posts. Cause: _hard_cut in src/kiro_crew/slack/format.py started at chunk_limit with no look at grapheme clusters. Change: it now steps the cut left while messaging.graphemes.joins_previous says the cut would split a visible character, then applies its existing <...> token guard. It never steps back to or before a cut already ruled out (past), so the reopened-fence path keeps its progress. When the whole reach is one run of joining marks, with no boundary to step back to, the cut stays at the limit. The Slack gateway spec line on final-message splitting says so.

Backwards compatibility

Compatible: every cut that split no visible character lands where it did; one that would have split one moves left by a few code points.

Removes nothing: the change only moves a hard cut earlier.

Tests

  • test/test_slack_render_pipeline.py::test_a_hard_cut_never_splits_a_visible_character (40 cases: flag, ZWJ family, combining accent, keycap at ten lead widths): the posts rejoin to the input and no seam falls inside a unit. 25 cases fail on main by assertion.
  • test_a_line_of_joining_marks_longer_than_a_post_is_cut_at_the_limit (2 cases): a line holding more joining marks than one post is cut at the limit, so a 10,000-mark run stays a handful of posts instead of one mark per post. Both fail on 4d7c5b97a3d9 by assertion.
  • test/test_slack*.py, test_messaging_split.py, test_messaging_import_purity.py and the other split_message callers' tests pass (6,943 on an earlier base; the core Slack suites pass on this head).
  • Proof: PROVEN test/test_slack_render_pipeline.py::test_a_hard_cut_never_splits_a_visible_character[3870-zwj], test/test_slack_render_pipeline.py::test_a_hard_cut_never_splits_a_visible_character[3870-keycap], test/test_slack_render_pipeline.py::test_a_hard_cut_never_splits_a_visible_character[3871-flag], test/test_slack_render_pipeline.py::test_a_hard_cut_never_splits_a_visible_character[3871-zwj], test/test_slack_render_pipeline.py::test_a_hard_cut_never_splits_a_visible_character[3871-combining] (head 44b58d2)

Manual verification

N/A — unit coverage sufficient: split_message is a pure function and the tests read its seams directly; I did not post to a live Slack workspace.

Related Issues

Fixes #37996

Sibling sweep

Swept: git grep -n -E "def (split_message|_hard_cut|_lossless_blocks)(|joins_previous" -- src/kiro_crew
Sibling: src/kiro_crew/messaging/split.py:_safe_cut -- not affected -- it already checks joins_previous since #37119
Sibling: src/kiro_crew/slack/format.py:_lossless_blocks -- not affected -- its blocks are rejoined into one text before posting, so no seam is shown
Sibling: src/kiro_crew/imessage/plaintext.py:_grapheme_boundary -- not affected -- it already uses joins_previous

Pattern harvest

Not generalizable: the grapheme rule is shared in messaging.graphemes; this was the last hard cutter not calling it.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

@RohanK6
RohanK6 requested review from a team and KiroCrewCaptain as code owners November 16, 2026 15:28
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 16, 2026
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 44b58d229b2a6ad10459aaa40b2388671d5d29d3 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 44b58d229b2a6ad10459aaa40b2388671d5d29d3 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The grapheme rule comes from the existing messaging.graphemes.joins_previous, and the fix is in the cutter that caused the defect (issue #37996, 25 tests that fail on base).

Inventory (3 items) — 3 justified

Intent: when a long Slack reply is split into several posts, no flag, emoji or accented letter is broken at the seam between two posts. This is a FIX.

  1. A Slack hard cut that would split a flag, ZWJ emoji or accent now moves left to the start of that character. — justified
  2. A line made entirely of joining marks is still cut at the limit, not one mark per post. — justified
  3. The Slack gateway spec's line on splitting the final message now names the grapheme guard. — justified

[FIRST-PRINCIPLES-REVIEWED] 44b58d2

Description read

[DESCRIPTION-READ] bb8e23cd57816cd91dd4b7e36d7711c9778cb5f31c1400e6872373a1ff8f9fc2

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 44b58d229b2a6ad10459aaa40b2388671d5d29d3 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: a hard cut that splits a grapheme is the real cause, and the fix reuses the shared grapheme rule rather than adding a new one.

[DESIGN-REVIEWED] 44b58d2

Description read

[DESCRIPTION-READ] 820b134446c38cd1b3365de68fb5e582d088f6bacaecd9a27635d73963e97e07

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 44b58d229b2a6ad10459aaa40b2388671d5d29d3 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 44b58d2

Verdict parsed from the review's SHA-scoped output markers for commit 44b58d229b2a6ad10459aaa40b2388671d5d29d3.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 44b58d229b2a6ad10459aaa40b2388671d5d29d3 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 44b58d229b2a6ad10459aaa40b2388671d5d29d3 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 44b58d2

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 44b58d229b2a6ad10459aaa40b2388671d5d29d3 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 16, 2026
split_message cut a line too long for one post exactly at the limit,
counting code points. That cut could land between a flag's two
regional indicators, inside a ZWJ emoji, or before a combining accent
or keycap, so one post ended with a broken glyph and the next began
with a dangling mark. The shared splitter already refuses such a cut;
Slack's separate-post cutter did not.

The hard cut now moves left to the start of the visible character it
would split, using the same messaging.graphemes rule.
@RohanK6
RohanK6 force-pushed the crew/conductor/slack-split-grapheme branch from 4d7c5b9 to 44b58d2 Compare November 16, 2026 16:18
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 16, 2026
@RohanK6
RohanK6 enabled auto-merge (squash) November 16, 2026 17:47
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates a 10% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

_hard_cut now uses the shared messaging.graphemes.joins_previous rule. When a cut would split a visible character, it steps left until it reaches a boundary. It never steps back to or before past, and if every position in reach joins its neighbour it falls back to the limit, so each post still makes at least one character of progress and split_message always terminates (this holds even when chunk_limit is 1). The <...> token guard still runs after the step-back. Nothing in that guard depends on the change: < and > never count as joining marks, so stepping back cannot cross a token boundary. Callers (_fenced_cut's two call sites, render_for_slack via presplit/_settled_pieces, stream.py, delivery.py) all accept a cut a few code points earlier. The only way a fenced cut could be reset back to the limit is through the sealed is None path, which needs a cut that holds no more than the opener, and a step-back of a few code points cannot get there. Each step calls joins_previous once; that call is O(1), except inside a regional-indicator run, where it scans back to the run's start (at most about one post) and only a step or two happens. So the worst case is a

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit 44b58d229b · 47 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. On head 44b58d2 the review checked these points. _hard_cut now steps the cut left while messaging.graphemes.joins_previous holds. It never goes back to past or before it, and it falls back to the limit when the whole reach is one run of joining marks. Both callers in _fenced_cut were traced. The new tests were rebuilt and run: all 40 seam cases pass on this head, and 25 fail on the merge base, with the cut inside a unit at offset 3884. Removing the fallback reds the joining-run test. A fuzz of 4,000 mixed texts produced no seam inside a grapheme, rejoined every text without loss, and kept every post within 3900 characters. The spec line is updated in the same commit.

Done well: the fix reuses the shared joins_previous rule instead of adding another grapheme check, and the no-boundary fallback has its own test.

Optional:

  • Neither new test is fenced, so the _hard_cut(text, chunk_limit, past=cut) path has no grapheme test. A probe shows it works today: no graphemes split on this head, against 34 of 90 on the base. A fenced case of the same parametrised units would pin it.

@RohanK6
RohanK6 merged commit b14fb59 into main Nov 16, 2026
99 checks passed
@RohanK6
RohanK6 deleted the crew/conductor/slack-split-grapheme branch November 16, 2026 18:03
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slack posts cut a flag, emoji or accented letter in two when a long line is split

2 participants