Repository navigation
fix(channels): record the reasoning note as the seam it opens - #14088
Conversation
25f00d7 to
95855f7
Compare
Design Review (Fable 5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS One repair-resistant byte seam halves the global budget, so a long Webex/WeCom reply can ship shredded into many tiny messages for one bad span. WatchThe byte branch's ladder ("Shrink the byte budget and re-split until the delivered sequence rejoins no key") re-cuts the entire body at the halved budget: a mid-ladder success delivers every chunk at that shrunken size ( Suggestions
[DESIGN-REVIEWED] 392f457 Description read[DESCRIPTION-READ] 9fe9ab44f24e68297007d349a754a652dd99a8478e82295c8ef5b83858893165 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 |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsFINDING -- src/kiro_crew/messaging/renderer.py:189 -- function-local False positive or not applicable? A repository writer can comment: |
First Principles Review (Fable 5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS Switching the seal to the classified edit verb strands Not justified as shipped
What this change shipsInventory (10 items) — 9 justifiedIntent: FIX — close the remaining channel-delivery seams where a credential invisible in any single message reads whole across two adjacent messages on screen.
[FIRST-PRINCIPLES-REVIEWED] 392f457 Description read[DESCRIPTION-READ] 1c48d6fa8eabdd2058bea2d27f949763cbb3097acfc5af17394968465fca3379 That sha256 names the PR description this verdict read. Recompute it with |
95855f7 to
6838ebd
Compare
167ef87 to
2d75f6f
Compare
Opus 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: |
2d75f6f to
4b656a8
Compare
2b56cfd to
5829a18
Compare
a3e0a9b to
bb1420a
Compare
bb1420a to
8f7fc95
Compare
7763ab1 to
87b6271
Compare
87b6271 to
3541d53
Compare
B1 (Opus 5): keep the open bubble's predecessor in _bubble_above (which _record_sent does not clobber) and grade the edit, seal and fallback paths against it, so an edit or the final seal of the bubble no longer restores a credential span the fresh-send grade repaired. B2 (Opus 5): drop redact_for_display/_display_safe from guaranteed_by_call (they do not collapse whitespace, so AKIA\nIOSFODNN survives) and route the WhatsApp stable branch and teams _replay_preview through repaired_for_delivery before the no-redactor cut. The universal splitter gate now recognises the grade-then-resplit idiom (a measurement split fed to repaired_for_delivery, and a delivery split of a grade-vouched body).
bolichen97
left a comment
There was a problem hiding this comment.
Reviewed on behalf of the maintainers (sweep 2026-09-30): readiness passed, required checks green on 392f457, no blocking review threads, security posture unchanged. Approving and merging.
Problem / Motivation
Goal: Close the remaining channel-delivery paths where a credential is invisible in any one message yet whole on the reader's screen because two adjacent messages read as one block of text.
A credential can pass every per-message scan and still be readable down the screen: two halves of a key, one per delivered message, rejoin visually once the platform drops the whitespace at each message's edge. This branch closes the last places on the channel delivery paths where that still happens.
discord.show_thinking) is posted as its own message, then the answer's first live frame grades its seam against the message that came before the reasoning. A note whose preview ends in a credential prefix is completed by the answer's leading characters. The preview is cut after redaction, which is exactly how a trailing prefix survives a pass that never saw a whole key.discord/session_resume.pypasses a redactor to the splitter;test_discord_sessions.py's double did not accept the keyword, so the shard failed with aTypeError.Why it matters
For (1) the consequence is not recoverable: both bubbles are already delivered when the key becomes readable, so nothing later can take it back, and the reader who scrolls past sees a working credential in a channel the operator believed was redacted. For (2) the harm is in the future: a guard that exists to catch the next unguarded delivery path could not see a path its list never named, so the protection this series added reads as present while being off for a whole module.
Not a goal
What changed (motivation → approach → change)
The reasoning note records what it delivered.
_flush_thinkingrecords the exact subtext it sent, once the send confirms, so the answer's first frame grades against the message the reader is actually looking at. It is not graded on the way in, deliberately: the thought-bubble emoji prefix is unconditional and survives rendering, so it separates the note from the message above in the only form the reader sees. Grading there would model an adjacency that does not exist and give up a leading span for a key the emoji already broke.A late note no longer loses its record to a rotation. When the note is posted below a still-live answer bubble,
_flush_thinkingnow clears the live message id (_stream_mid) after recording the note. Without that, the next_rotate_on_length→_seal_current→_land_sealededits the older bubble and records THAT as_sent_tail, displacing the note as the predecessor and leaving the note → next-message seam ungraded. Clearing the id forces the next seal down the send path, so the message that actually lands below the note is the one recorded.The seal grades against the right neighbour when an edit fails. A failed live edit is classified: a transient failure (429/5xx) leaves the bubble on screen, so the fallback grades against it (
_sent_tail); a deleted bubble (a 404 — moderator/automod removed it) means the on-screen neighbour is the message above it (_bubble_above), so the fallback grades against that instead. The client returns the classified outcome (EDIT_OK/EDIT_GONE/EDIT_FAILED) rather than a bare boolean, so the renderer can pick the predecessor the reader actually sees, and the record is only written when the send or edit reports success.The byte-delivery path grades its own seams.
messaging.renderer.chunk_for_transport's byte branch fedsplit_markdown_bytes(which takes no redactor) straight intobounded_for_delivery, andbounded_for_deliverygrades only the slices it cuts inside a chunk — never the byte splitter's own inter-chunk seams. On the two byte-capped channels (Webex, WeCom) a credential straddling a byte-splitter boundary shipped whole across two messages. It now runsrepaired_for_deliveryover the split sequence before bounding, re-splitting a repair through the same byte splitter — the guarantee the character branch already gets by threading the redactor into its splitter — and shrinks through the real byte floor with a fail-closed terminal grade so an exhausted search never returns an unsafe sequence.The population that must be graded is read off the tree, not curated. The enforcement test derives its module population by walking
src/kiro_crew(SRC.rglob("*.py")) and collecting every module that calls a redactor-accepting splitter — a module joins the moment it calls one, so a new delivery path is enforced without anyone remembering to add it to a list.messaging/split.pyis skipped because it defines those functions. Then the check is universal, with no per-module exemptions: every splitter call in every collected module must either passredactor=or cut already-redacted text (the output ofrepaired_for_delivery/redact_for_display, which carries the same seam guarantee). A companion assertion fails if the walk stops reaching the known delivery channels, so a derivation that silently finds too little cannot pass quietly.Backwards compatibility
Compatible: no field, validator, type, or key changes — the diff threads an existing redactor/grade through delivery paths that already existed, clears an internal streaming id earlier, and adds a classified-edit return the renderer reads. Nothing that works today stops working.
Tests
Automated tests added/updated:
EDIT_OK/EDIT_GONE/EDIT_FAILEDoutcome on 200/404/503; the session-resume double now asserts the redactor it receives.TestEveryDeliveryPathIsEnumerated: the module population is derived by walkingsrc/kiro_crew, and every splitter call in every collected module must pass a redactor (or cut already-redacted text) — universal, no exceptions. A companion assertion fails if the walk stops reaching the known delivery channels, so an under-reaching derivation cannot pass quietly. An unguarded call in any collected module fails the parametrized check.TestChunkForTransportGradesTheByteSeam:chunk_for_transportcloses a key straddling a byte-splitter seam on a byte-capped channel, with an unguarded control (split_markdown_bytesalone) that leaks — locking in the byte-path grade, including that the byte path never returns a rejoining sequence even when the budget search exhausts.Local verification on the resolved tree (worktree,
PYTHONPATH=src): the credential-boundary suite (incl. the derived enumeration and the byte-seam class),test_discord.py,test_discord_sessions.py,test_discord_render_config.py,test_channel_table_rendering.py,test_discord_rate_limits.py→ all green (830 passed across the touched sets), plus black / isort / flake8 / mypy clean.Manual verification
N/A — unit coverage is sufficient; the seam guarantees are exercised by the credential-boundary suite with explicit rejoin controls.
Related Issues
Refs #13743. Predecessor #13984 (merged); supersedes #14047.
Pattern harvest
Rule candidate: when a guard is added to "the paths that do X", enumerate the paths by a property of the code (derive the population from the tree) rather than by a curated list in the diff — a path nobody adds to a curated list is not merely unchecked, it is invisible, and the paths most likely to be forgotten are the new ones. Make the derivation itself fail if it stops reaching the paths you already know deliver.
Rule candidate: an edit that can fail two different ways (transient vs the target being gone) must return which way it failed, not a bare boolean — the caller's correct recovery differs by case, and a collapsed boolean makes it grade against the wrong neighbour.
Checklist
fix: ...)docs/system-specs/modules/messaging.md