Repository navigation
fix(slack): send or drop the stream's held text when a message ends - #17897
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS
Watch
Suggestions
[DESIGN-REVIEWED] 1e341e0 Description read[DESCRIPTION-READ] e969df461f745197705295af7deafc27bff367b0cbe58706bfd121c85d3e4f1b 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 (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The give-back edit (read the closed message back and rebuild its blocks) costs about 140 lines and four state fields to move one word, and is unverified on live Slack. Not justified as shipped
What this change shipsInventory (7 items) — 5 justifiedIntent: a streamed Slack answer always shows its last words. FIX (#16984).
[FIRST-PRINCIPLES-REVIEWED] 1e341e0 Description read[DESCRIPTION-READ] 3c3e1ab0467426463f556d1e66284cbc6ce7a45027506fd3b85bbd9cffde773e That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsNo findings that block the merge; one advisory finding. FINDING — src/kiro_crew/slack/handler_runtime/stream.py:924 — When a [OPUS-REVIEWED] 1e341e0 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
6aaf0c4 to
d90351d
Compare
|
|
d90351d to
44022f3
Compare
|
Sensitive Change ReviewSensitive files changed:
|
44022f3 to
1b4c52f
Compare
Security Scope Review -- 🟡 CONCERNSWhich legitimate operations does Verdict basis: the reviewer's own judgement; no confirmed regression. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: CONCERNS TIGHTENING: The Slack egress ADJUDICATED: 7 candidates, verdicts pending from the harness (the deterministic fold reports them). The candidates are controls for maintainer commands in the touched area. No shell matcher changed, so no regression is expected here and none is claimed. PLATFORM COVERAGE: I wrote posix and windows rows: the three pytest runs for the touched area (held-tail, composition-contract digests, security-gate liveness). The windows rows use UNADJUDICATED: The guard is the Slack native-stream output redaction path:
There are also two policy choices I can argue but not confirm:
[SCOPE-REVIEWED] 1e341e0 |
1b4c52f to
a40b4b8
Compare
|
a40b4b8 to
be59605
Compare
|
be59605 to
538b390
Compare
7af8a6b to
1afeb8b
Compare
Sensitive change review
|
At a wait the stream holds the last run of text until the next text shows
whether it is a word of its own. The next message used to open with it
("42Results are in.").
Now, once the first text after the wait has passed the filter whole and
unchanged, that run is put back at the end of the message it came from.
The edit is made on that message's own blocks, read back from Slack, so its
formatting and task plan stay as they were. If the joined text is changed
by the filter, the blocks cannot be edited, or the edit fails, the run opens
the next message as before. The next message's final copy and the saved
answer start after a run that was given back.
When the stream goes down while the turn's last text is sent, the seal now
re-sends the whole text as the final update, as it already did when the
held run's send failed.
1afeb8b to
1e341e0
Compare
Sensitive change review
|
|
@iamwhatever thanks for the review on 8fcb271. Head
Tests are in
Not yet run against a live workspace. Would you take another look? |
|
|
|
|
|
|
buluoray
left a comment
There was a problem hiding this comment.
Approve. The held run is now settled wherever a streamed message ends. In the common path no text is lost or duplicated, and the drop path only fires when a full-copy overwrite replaces the message.
What was verified
- Root cause is confirmed in source:
SlackClient.stop_streamnever sendsfinal_text(slack/client.py:764-778). On the base, the runStreamRedactorheld at the end of a message was on no message at all.seal→settle_tail(stream.py:410-431) now flushes it through_deliverwhen the final text is clean. - Drop only happens together with the overwrite.
settle_tail(redacted=had_redaction or redacted)drops in exactly the cases wheresealruns_safe_final_updatewith the full clean copy (stream.py:1037+), or where the demoted branch re-sends the whole text (stream.py:1025-1036). So a drop never takes away text the reader would otherwise see. - Normal end, cancel and error: the normal end and a user stop go through
seal. A cancel-by-delete removes the stream message. Error arms that replaceaccumulatedstill get the visible message's held run settled. The verdict is read afterseal(handler.py:2808-2813), so a one-word answer counts as delivered. - Edit-in-place at a
wait:_give_back(stream.py:486-524) moves the run only when the joined text comes out of the filter unchanged (no[REDACTED,redact(safe) == safe). It edits from the message's own blocks, and every failure (read miss, unknown block shape,chat.updateraising) returns False. The run then opens the next message: the change fails closed, and the run is neither lost nor duplicated. After a give-back,accumulated, the final copy (given_backtrim) and the saved answer all start after the run. - Each new guard/fix was disabled in turn. Each one reddens a named test, with two exceptions: the
redacteddrop insettle_tail(sending instead stays green, butflush()redacts and the overwrite replaces it, so harmless), and thediscardingcheck onmove_back(an equivalent mutant). - The earlier blocking finding, where the run held at a
waitwas glued onto the next message, is addressed by the give-back. Publicheld/discardingaccessors replace the reads of private fields.
Non-blocking follow-ups
- Live Slack has not been checked. In the fallback, the run opens the next message with no separator (
42Results are in.), because the gap is suppressed on purpose so a split value is filtered as one. If liveconversations.repliesdoes not returnmarkdown/rich_textblocks for achat.startStreammessage, everywaitwith a held word takes this path. Please check once against a real workspace that the give-back lands and thatchat.updatekeeps the streamed formatting. - When a value is being dropped across a
wait, the whole pre-wait text is carried, so the redaction overwrite of the next message repeats that text (Intro line here. Header: [REDACTED: credential] then more words.under a first message that already showsIntro line here. Header: [REDACTED: credential]). The repeat is safe but redundant, and only happens in the redaction case. - On the demoted re-send, after an earlier successful rotation in the same segment, the overwrite writes the whole segment onto the newer message and repeats the earlier part. This needs two refusals in one segment. Text is repeated, never lost.
- No test reddens if the
redacteddrop insettle_tailbecomes a send. A test that asserts noappend_streamfollows a redacted final would pin it.
Upgrade impact: none. Nothing is persisted, renamed or rejected, and a missing history scope just takes the existing fallback. Audience fit: this fixes the default native-streaming path every Slack user is on, without degrading it.
|
This settles the run that the Slack |
|
Deep re-review of a held PR. It makes the last word an answer holds back reach Slack. At the seal, |
Problem / Motivation
Goal: A streamed Slack answer never loses its last words. At a
wait, a word the stream still holds is shown at the end of its own message once the text after it shows the word is whole; when that cannot be shown, it opens the next message.The Slack stream holds back the last run of each chunk until more text shows where it ends. Nothing ever settled that held run when a message ended. So:
forty2,done) never reached the stream;waitshowed up glued to the start of the next message (waitafter).Why it matters
Every native Slack streaming turn is hit. Readers see answers with the last word cut off, short replies vanish, and the failure counter climbs on turns that worked.
Not a goal
slack/renderer.py).security/__init__.pyonly gains two read-only properties.What changed (motivation → approach → change)
Symptom: the run still held when a streamed answer ended was never sent. Cause:
_AnswerStreaminslack/handler_runtime/stream.pyfed every chunk through itsStreamRedactorbut never settled what it still held when the turn ended.Fix:
sealcalls a newsettle_tail. When the final text is clean it sends the held run through the same send-and-rotate path as any other text (if that send, or the last send infinish, fails and no new stream opens, the seal re-sends the whole text as the final update); when it is not, it drops the run and the final copy replaces the message as before. A run held before a tool card stays held, so the text after the call is joined to it and filtered as one.At a
waitthe message closes and the held run is kept incarried, so the filter sees it joined to the next text (take_carried, also called onEVENT_COMPLETEinslack/handler.py). When that joined text comes out of the filter whole and unchanged,_give_backreads the closed message back and edits it withchat.updateon its own blocks plus the run, so its formatting and task plan stay. The next message then starts after the run, and so do its final copy and the saved answer. When the joined text is changed by the filter, the blocks are not a known shape, or the read or edit fails, the run opens the next message as before.StreamRedactorgets read-onlyheldanddiscarding.slack/handler.pyreads the delivery flag afterseal.docs/system-specs/modules/slack-gateway.mdstates the held-run rule.Backwards compatibility
Compatible: nothing is rejected or renamed; the stream now sends text it used to drop.
Removes nothing: no key, record, path or function is taken away.
Tests
test/test_slack_stream_held_tail.pydriveshandle_messageon the streaming path: the last word of a clean answer arrives; a one-word answer is sent and counted as a success; a value split around a tool card or awaitis filtered as one, on the stream and in the final copy; the last word before awaitthat ends the turn is posted; the last word still arrives when its send and retry both fail, and so does the last text when the stream fails while the turn finishes; an agent that dies during awaitstill shows the error notice.wait: the held word goes back to the end of its message, with itsmarkdownorrich_textblocks and the plan block unchanged, and the next message starts "Results are in." (test_the_word_held_at_a_wait_goes_back_to_its_message_with_its_format); when the edit is refused, the blocks are another shape, or there is no read-back, the word opens the next message (..._when_the_edit_cannot_land); two waits in a row, and two waits each with their own word; the saved answer matches the last message; the next message keeps its own opening word in its final copy; a refused next message does not repeat the word; five split-value cases are never given back and never shown split (test_a_value_split_by_a_wait_is_never_given_back_split).test/test_slack_handler_composition_contract.py: 19 golden transcript digests updated; each diff was read.test/test_security_gate_liveness.py: the package line budget is raised by 10 lines for the twoStreamRedactorproperties, with its reason comment.Manual verification
N/A — unit coverage: the tests drive the real handler and stream object against a Slack client fake that hands back each message's blocks. Not run against a live workspace. If live Slack hands back a streamed message in another block shape, or refuses the edit, the expected outcome is the fallback: the word opens the next message, as before this change, and nothing is lost.
Related Issues
Closes #16984
Pattern harvest
Rule candidate: review-prompt
Pattern: a stateful buffer (a holdback, a hold, a debt) fed per chunk must be settled at every place the segment it belongs to ends.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)