Skip to content

fix(slack): skip a break too early in the chunk when splitting - #28614

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

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

Conversation

@RohanK6

@RohanK6 RohanK6 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A long Slack reply that opens with a short line goes out in as few messages as it needs, not one extra tiny one.

Both Slack splitters cut at the last line break in reach, even one two characters in. "Hi\n" plus a 5,000-character answer posts three messages (Hi, then 3,900, then 1,116) instead of two. The streamed reply does the same with its appends.

Why it matters

Every Slack user who gets a long answer that starts with a greeting or a heading sees a near-empty message before the real one. That is noise in the thread and one more API call per reply.

Not a goal

  • Preferring a paragraph break over a later line break. The Slack splitters keep cutting at the last line break that counts.
  • Cutting split_message at a space. It still breaks only at line breaks, then hard-cuts, as today.
  • The one-shot truncation helpers (_truncated, the SLACK_MAX_TEXT trim in format.py) and the internal _lossless_blocks pre-split. Each yields one message, so an early cut there adds no post.

What changed (motivation → approach → change)

A cut point too near the start strands most of the budget. The shared messaging.split splitter only counts a line break at least a quarter into the chunk; the Slack splitters had no floor. #28277 gave iMessage the same floor.

Splitter Breaks at Floor No break past the floor
split_message (separate posts) line break 1/4 of chunk early line break if the next line fits one post (the last post holds the full limit), else hard cut
_append_pieces (stream appends) line break, then space 1/4 of piece early break if the next word fits one piece, else hard cut

Both use one new helper, slack/break_point.last_break. The "next line fits" rule keeps a long URL behind a short lead-in whole, as today. The Slack specs (messaging.md, slack-gateway.md) describe the floor.

Backwards compatibility

Compatible: only where a long reply is cut changes; every character still arrives, and short replies are untouched.

Removes nothing: no key, path, record or public function is taken away.

Tests

TestSplitMessageSkipsAnEarlyBreak in test/test_slack_handler_rendering.py pins: a short first line before one long line or long prose costs no message; a line break a quarter in is still taken; an early break falls through to a later one; a line that fits a post, or the last post, moves whole; link prose behind a short lead-in is hard-cut, never cut at a space. test/test_slack_renderer.py pins the same floor for _append_pieces, and that a break a quarter in and a URL that fits still move as today.

Proof: PROVEN test/test_slack_handler_rendering.py::TestSplitMessageSkipsAnEarlyBreak::test_a_short_first_line_before_one_long_line_costs_no_message, test/test_slack_handler_rendering.py::TestSplitMessageSkipsAnEarlyBreak::test_a_short_first_line_before_long_prose_costs_no_message, test/test_slack_handler_rendering.py::TestSplitMessageSkipsAnEarlyBreak::test_link_prose_behind_a_short_lead_in_is_cut_hard_not_at_a_space, test/test_slack_renderer.py::TestStreamMachinery::test_append_pieces_skip_a_break_too_early_in_the_piece (head 6ba1047)

The new tests are pure functions with no clock, I/O or ordering. The related Slack, messaging and iMessage suites (7,654 tests) pass locally. The full local-gate.py run timed out on a busy host, so CI runs the full set.

Manual verification

N/A — unit coverage sufficient: both splitters are pure string functions, and the tests call them directly.

Related Issues

Fixes #28607

Sibling sweep

Swept: git grep -nF rfind -- src/kiro_crew
Sibling: src/kiro_crew/slack/format.py:1225 -- changed here
Sibling: src/kiro_crew/slack/reply_pieces.py:77 -- changed here
Sibling: src/kiro_crew/imessage/plaintext.py:230 -- not affected -- already carries the floor from #28277
Sibling: src/kiro_crew/acp/_dispatch_parts/surfaced_text.py:135 -- not affected -- a one-shot diff truncation, not a splitter

Pattern harvest

Rule candidate: review-prompt
Pattern: a splitter that takes the last separator in reach with no floor on how far into the chunk it sits

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

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 6ba1047491006a2bd9b89977db394e80eb3a8ca8 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 2, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 6ba1047491006a2bd9b89977db394e80eb3a8ca8 — 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 new helper is a second copy of iMessage's break-floor algorithm. That is a note, because the iMessage function is private and also handles paragraph breaks and graphemes.

Notes

  • Item 5 — duplicate of src/kiro_crew/imessage/plaintext.py:_preferred_cut: the iMessage function and break_point.last_break run the same logic. A break counts only from a quarter of the budget in (index + len(separator) >= limit // divisor). With none past that floor, the last break is taken when the next run fits one piece (_word_end vs the new ends/run_end). The two copies must now be kept in step by hand. Subtraction: give _preferred_cut the shared floor and next-run check from last_break, keeping only its own paragraph tier and grapheme handling, and delete its inline copy.

What this change ships

Inventory (6 items) — 5 justified

Intent: a long Slack reply that opens with a short line goes out with no extra near-empty message. This is a FIX (#28607; the new tests fail on base).

  1. Slack posts no longer split at a line break less than a quarter into the chunk — justified
  2. Streamed Slack appends no longer cut at an early line break or space — justified
  3. A long line or URL behind a short lead-in still moves whole — justified
  4. A last line that fits the last post's full limit goes out whole after an early break — justified
  5. New shared helper slack/break_point.last_break — duplicate of imessage/plaintext.py:_preferred_cut
  6. Both Slack specs describe the floor — justified

[FIRST-PRINCIPLES-REVIEWED] 6ba1047

Description read

[DESCRIPTION-READ] 06d51db4e7280409547df93e14f0c32357c214c355cdbbb6908db879db9670ae

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 2, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: this changes only where the two Slack splitters cut, every character still arrives, and the change is easy to revert.

Notes

[DESIGN-REVIEWED] 6ba1047

Description read

[DESCRIPTION-READ] 1c8e0e021cd4f2c4091858c4855c5ca5726322c8345b01b13ecae85183359c38

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 2, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 6ba1047491006a2bd9b89977db394e80eb3a8ca8 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 6ba1047

Verdict parsed from the review's SHA-scoped output markers for commit 6ba1047491006a2bd9b89977db394e80eb3a8ca8.

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

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 6ba1047491006a2bd9b89977db394e80eb3a8ca8 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 6ba1047

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

@RohanK6
RohanK6 force-pushed the crew/conductor/slack-split-break branch from 8fbd8b2 to 6ba1047 Compare November 2, 2026 23:10
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 2, 2026
@RohanK6

RohanK6 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=5b0c8916cb29 split_message splits a last line that fits the last post (format.py:1225)

fixed in 6ba1047: with no line break past the floor, split_message takes an early line break when the remainder after it fits the last post (up to limit, which carries no CONTINUATION), as main did.
Test: test_a_last_line_that_fits_the_last_post_moves_whole pins a 3,890-character URL after a short lead-in going out whole.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Nov 2, 2026
@RohanK6
RohanK6 enabled auto-merge (squash) November 3, 2026 05:13

@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.

Tier 1 auto-approve: fix (7 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: the Slack splitters skip a line break too early in the chunk, through one shared break-point helper, with tests. Spec files changed as a ride-along (a minority of the diff on both file count and changed lines), not reviewed as a design decision: docs/system-specs/modules/messaging.md, docs/system-specs/modules/slack-gateway.md.

@RohanK6
RohanK6 merged commit 8da614d into main Nov 3, 2026
124 of 161 checks passed
@RohanK6
RohanK6 deleted the crew/conductor/slack-split-break branch November 3, 2026 06:07
RohanK6 added a commit that referenced this pull request Nov 14, 2026
split_message cut a line too long for one post exactly at the limit.
In converted mrkdwn that cut could land inside a <url|label> link, a
<@u123> mention or a <#C123> channel. The first post then ended with
a raw, unlinked "<https://example.com/docs/de", and the next began
with "sign/section-44|the design doc>" as literal text.

A cut that would land inside a token now moves back to the token's
"<", so each post holds whole tokens. The cut stays a hard cut at the
limit otherwise, as #28614 chose.
RohanK6 added a commit that referenced this pull request Nov 16, 2026
…37230)

split_message cut a line too long for one post exactly at the limit.
In converted mrkdwn that cut could land inside a <url|label> link, a
<@u123> mention or a <#C123> channel. The first post then ended with
a raw, unlinked "<https://example.com/docs/de", and the next began
with "sign/section-44|the design doc>" as literal text.

A cut that would land inside a token now moves back to the token's
"<", so each post holds whole tokens. The cut stays a hard cut at the
limit otherwise, as #28614 chose.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slack splitters cut at a line break near the start, so a short first line costs an extra message

2 participants