Repository navigation
feat(cards): channel card catalog Phase 1 for Stop and working cards - #35974
Conversation
Sensitive Change Review
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Three small surfaces have no caller or repeat an existing helper, and all three can be removed later. Notes
What this change shipsInventory (9 items) — 6 justifiedIntent: let a maintainer build Slack cards from one typed spec through one redacting, cap-checking render path, starting with four constant cards. This is an ADDITION (a staged refactor).
[FIRST-PRINCIPLES-REVIEWED] ef9118c Description read[DESCRIPTION-READ] c4807fdd3ba6fa82890475e24a06cb4be44aeeea24d8040bba78e5034bd65340 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level blocker: the four builders keep their output, the shape follows the merged RFC, and every type the PR adds has a caller. Notes
[DESIGN-REVIEWED] ef9118c Description read[DESCRIPTION-READ] 5f3bb74c543f9f354892ab324b581d258ef769f733a141578dfc2bfee68d72cf 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 |
Opus 5.5 Review — ✅ no blocking findingsReviewed 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: |
a95c896 to
4c5b516
Compare
Code change approver recommendation: A person should decideWhy: the decider estimates a 10% chance that this change introduces a defect, within the 12% limit for approving on its own, but it changes 1199 lines, more than the 400 it may approve on its own. Phase 1 of the channel card catalog RFC. Four constant-text Slack builders (stopping, stopped, stop-failed, working) now go through a new neutral render() that redacts, defuses mentions and checks Slack's size limits. I checked the claim that Slack sees no change against the code. The constant strings come out byte-identical after the bold rewrite and the escaping, which has nothing to replace. The session key goes into the ids and button value under Fit.KEEP, so it is never cut and never raises. Callers (events.py, commands.py, turn.py, interactions_sessions.py) are unchanged. The import-purity rules hold, and the claim that no security-posture row is needed matches the registry test, which treats redact_via_context as the answer rather than a finding. Golden snapshot tests for all variants plus thorough renderer tests (limits, redaction, structure, no remote media) back the change. No regression, data-loss or trust-boundary problem found. 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 |
4c5b516 to
3ec83b1
Compare
2fcc43f to
64706f1
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Thanks. I read the whole diff on this head against the Phase 1 sign on the RFC (#34612): a card that posts today keeps today's behavior, and nothing gets stricter. That part holds:
- The goldens pin all four builders, both working-card variants included, as equal dicts and as sorted-key JSON.
- The session key, the only variable input, goes into the ids and the button value under
Fit.KEEP. So a builder never raises where main returned blocks.test_a_builder_returns_main_payload_for_any_session_keycovers an empty key and a key over every cap. - The RFC document edits stay inside the signed Phases 1 and 2. They narrow Phase 1 to what its four cards use, defer the other pieces to the phase that first needs them, and add
Fit.KEEPto keep today's behavior on routing data. The posture row moving to the first phase that calls a redactor directly loosens nothing, because redaction still runs throughdisplay_safe_for. - No check is red. Some are still running.
One blocker: this project does not accept new regex in product code, and messaging/cards/render.py adds one:
_BOLD = re.compile(r"\*\*([^*\n]+?)\*\*")
...
safe = _BOLD.sub(r"*\1*", _escape(...))Please replace it with plain string code and drop import re from render.py. For example, walk the string with str.find:
def _slack_bold(text: str) -> str:
out, i = [], 0
while (start := text.find("**", i)) >= 0:
end = text.find("**", start + 2)
inner = text[start + 2 : end] if end >= 0 else ""
if not inner or "*" in inner or "\n" in inner:
out.append(text[i : start + 1])
i = start + 1
continue
out.append(f"{text[i:start]}*{inner}*")
i = end + 2
return "".join(out) + text[i:]test_markdown_bold_becomes_slack_bold and the goldens should pass as written. The re uses in the two test files are fine. Everything else looks good to me, and I will approve once the regex is gone.
The four builders in slack/blocks.py, both working-card variants included, as they render before moving onto card specs.
Adds kiro_crew.messaging.cards: a typed card spec (sections, context lines, button rows) and one render() that joins and redacts each text through display_safe_for with redact_via_context and the mention defuse, escapes mrkdwn, checks Slack's own caps, and checks every emitted string once more in the form it ships. build_stopping_blocks, build_stopped_blocks, build_stop_failed_blocks and build_working_blocks are now card specs. Their output equals the goldens.
64706f1 to
ef9118c
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Approve. Thanks for the change. All checks are green.
I compared this head with 64706f1, the head I reviewed in full. The only changes are in render.py and its tests:
_BOLD = re.compile(...)andimport reare gone._slack_boldwalks the string withstr.find, andmrkdwncalls it in place of_BOLD.sub. No other regex is in the product files.- The new tests pin the regex's old behavior case by case (
****, a newline inside, a*inside, an unclosed pair,***a**, a lone**).test_render_holds_no_regexkeepsreout ofrender.py. - The rest is unchanged from the head I read in full. The goldens pin all four Stop and working cards, the session key stays under
Fit.KEEPso no builder raises where main returned blocks, and the RFC edits stay inside the signed Phases 1 and 2.
Phase 1 direction signed by maintainer (bolichen97) on #34612: existing card behavior unchanged and no added strictness. Phase 3 onward needs a separate sign-off.
Problem / Motivation
Goal: Slack cards come from one typed card spec and one render path that redacts, defuses mentions and checks Slack's caps, starting with the Stop and working cards, with no change to what Slack shows.
Today every Slack card is hand-built Block Kit JSON. Each builder does its own redaction, mention defusing and length cuts, so a new card can forget a step. The channel card catalog RFC (merged 2026-11-11) replaces that with a spec and a
render()that runs every step for every card. This PR is its Phase 1.Why it matters
The Slack Code PRs keep hitting the same four kinds of bug (text cut mid-sentence at a cap, fields dropped on a rebuild, redaction or defusing missed on one path, writes racing a Stop). Each fix stays in the module that found it, so the next card starts over. Phase 1 lands the package and proves it on four low-risk cards, so later phases can move the cards that hold model text.
Not a goal
Fit.SPLIT. It lands with the first card that uses it.What changed (motivation → approach → change)
Approach. Follow the RFC's design, shipping only what the four cards use. Every spec type, fit and render step in this PR is reached by at least one of the four builders.
Narrowed after First Principles review. The first head of this PR (
a95c896317) also carriedsend.py(post_card/edit_card),links.py, a plain-text renderer, the split-secret step and more elements and fits. First Principles blocked it because none of those had a caller. The team lead agreed, so they are removed, not overridden. Each now lands with the first card that uses it, and the RFC's Migration plan names that phase:send, its commit-point tests and the plain-text renderer: Phase 2.Fit.CUTandConfirm: Phase 2.Fit.MARKED: Phase 3.codetext style: Phase 4.Fields,Table,Divider, titles, theplainstyle and theprimarybutton style: the first card that uses each.New package
src/kiro_crew/messaging/cards/:spec.pyCard,Section,Context,Text,Actions,Button;Fit(REFUSE,KEEP);Issue;CardError. No element can express an image, a video, a link preview or a URL.render.pyrender(spec, Platform.SLACK, limits=None). AText's runs are joined and redacted as one string, throughdisplay_safe_forwithredact_via_contextand the mention defuse. A button label gets the same treatment. Then Slackmrkdwnescaping and**bold**→*bold*, and Slack's caps measured on what Slack receives. Every string placed in the payload then passes one last check in the form it ships (_Pass.emit): if redaction would still change what the reader sees, the card is refused. A string that shows nothing once redacted is refused. A breach underFit.REFUSEraisesCardErrorwith everyIssue(path, code, limit, actual).Fit.KEEPlogs it and sends the value unchanged.limits.pySLACK_LIMITS, Slack's own documented caps: 50 blocks, 3,000 section and context text, 10 context items, 25 buttons, 75 label, 2,000 value, 255 action and block id.slack/blocks.py.build_stopping_blocks,build_stopped_blocks,build_stop_failed_blocksandbuild_working_blocksare card specs rendered byrender. Signatures, action ids, values and block ids are unchanged, and no caller changes. Each field's declared fit:build_stopping_blocks(key)Section(Text("⏹ **Stopping…**\nCooperative cancel in progress.")),Actions(id="stop-actions-{key}", Button("Kill Now", "stop_kill_now", value=key, danger))REFUSE; button and block idKEEPbuild_stopped_blocks()Section(Text("⏹ **[Stopped]**"))REFUSEbuild_stop_failed_blocks()Section(Text("⛔ **[Stop Failed, Session Reset]**"))REFUSEbuild_working_blocks(key, include_dashboard_link=)Context(Text("⏳ _Working…_")),Actions(Button("⏹ Stop", "mc_inline_stop_{key}", value=key, danger), plusButton("Link to Dashboard", LINK_DASHBOARD_ACTION)when asked)REFUSE; Stop buttonKEEPDecisions made while building (team lead, 2026-11-12), also in the RFC's Phase 1 text:
stylebeforetext, Stop listedtext, value, style, and Link to Dashboard listedtextbeforeaction_id. The goldens therefore assert dict equality and byte-equal sorted-key JSON. Slack reads a JSON object by key, so the order has no effect. A grep ofsrc/found nothing that hashes, fingerprints or string-compares these payloads. The builders' output goes straight topost_ephemeral,post_blocksor aresponse_urlPOST. The onlyjson.dumps(blocks)near them (handler_runtime/stream.py_blocks_with_run) is a deep copy.Fit.KEEP: an over-cap value goes out unchanged, as the hand-built payload sent it, and the issue is logged. The "Link to Dashboard" button is constant (label and action id, no value, no URL).messagingmay not import a channel package (test_messaging_import_purity.py). The Slack escape is a local copy ofescape_mrkdwn's three replacements, pinned to it by a test. Slack's mention grammar is pinned toSLACK_CAPABILITIES. The remote-media backstop is the Slack client seam (blocks_request_remote_mediaonpost_blocksandupdate_message), which every send already passes. The no-media test runs that same check over the renderer's output.render.pyredacts only throughdisplay_safe_for. The redaction-sink registry's call check does not count that as a redactor call;messaging/inbound_spool.py, which also redacts only through it, has no row either. Sotest_security_posture.pyasks for no row, and this PR touches no Sensitive Change Review file. The "Channel cards" row lands with the first phase whose render path calls a redactor directly.Docs:
docs/system-specs/modules/messaging.md(files row and a "Channel cards" section),slack-gateway.md(theslack/blocks.pyrow), the RFC's status, Phase 1 and 2 text, Security considerations and Testing wording, and its index row indocs/request-for-change/README.md.Backwards compatibility
Compatible: the four builders keep their signatures and return payloads equal to the goldens captured on main, so every caller and click handler sees what it saw before.
Removes nothing: no function, key, row or behaviour is removed.
slack/blocks.pystops importingbuild_link_dashboard_button, which stays inslack/format.pyfor its other callers, and a test holds the working card's dashboard button equal to it.Tests
test/fixtures/channel_cards/slack_stop_working_goldens.json: captured from main9e9de7bfc9in the first commit, beforeslack/blocks.pychanged. It holds all four builders, including bothbuild_working_blocksvariants.test/test_channel_cards_slack_builders.py:build_link_dashboard_button().escape_mrkdwn, and the mention grammar matchesSLACK_CAPABILITIES."type"literal.test/test_channel_cards_render.py:**-split key,<!channel>,<@U…>,@everyone, nested character references and backtick runs, in a section, a context line and a button label. Every display string is settled:display_safe_forwith no mention grammar leaves what Slack shows unchanged (it is not idempotent on@, so the check has two parts), no live mention remains, and the key never shows. A key or a<!channel>split across aText's runs is redacted or defused.emitrefuses a string that shows a key.pathandtoo_long. Each count (blocks, context items, buttons) renders at the cap and refuses one over (too_many) and zero (empty).Fit.KEEPsends an over-cap action id, value and block id unchanged and logs them. A redaction placeholder can push text over the cap, and so can escaping.blocks_request_remote_media, and the spec defines no media, preview, link or URL element.Proof: not provable -- other: a refactor with no behaviour change; the goldens are the proof
Manual verification
Not done: I did not post these cards to a real Slack client. The goldens show the payloads are equal to main's, so a real client renders them the same.
Related Issues
RFC: docs/request-for-change/rfc-channel-card-catalog.md, Phase 1.
No issue is linked: Kyle asked for this directly, and tracking issues are opened only when he asks.
Checklist