Skip to content

fix(channels): grade the delivered sequence so a split cannot rejoin a key - #13852

Closed
chenmingwei23 wants to merge 2 commits into
mainfrom
fix/cross-delivery-redaction-13743-v6
Closed

chenmingwei23 wants to merge 2 commits into
mainfrom
fix/cross-delivery-redaction-13743-v6

Conversation

@chenmingwei23

Copy link
Copy Markdown
Contributor

What is the problem?

Supersedes #13844, and before it #13839, #13836, #13828 and #13758. Each replacement exists for the
same mechanical reason: taking a review fix while staying inside the two-commit limit
needs the commits reshaped, and a reshaped branch cannot be published by a
fast-forward push. Cutting a fresh branch publishes the same two commits as a plain
create instead. No review had been left on either predecessor.

Six channel delivery paths cut model text on a length budget and scan each piece on its
own. A credential the cut severs matches nothing in either piece, so both are reported
clean and the reader rejoins the halves reading one message and then the next.

Five of the six already redact the whole buffer before splitting, and that closes a cut
that lands mid-line: the credential is one marker before any boundary can reach it. It
does not close a cut at a line boundary. Sealing a chunk trims the whitespace that
ended it, and the next chunk starts at the first character after that whitespace, so the
two halves end up flush against each other on screen while the whole text still holds the
break between them. That form is invisible to a scan of the text as written and to a scan
of either piece.

Why this issue matters to the user

The reader sees the key and nothing reports it. Because each piece scans clean, no
redaction notice is emitted and the delivery is recorded as a clean send: the operator has
no signal at all. This is the audit half of the problem, not only the disclosure half.

How our fix solves it

The boundary is where the defect lives, so the fix goes into the two shared splitters
rather than into six renderers. split_markdown_safe and chunk_utf8_bytes take an
optional redactor and, when given one, reduce the text before any boundary is chosen:

  1. the text is redacted against the rendered form first, via the existing
    redact_for_display, which closes a cut landing mid-line and the markup-hidden variant;
  2. the boundaries it then chooses are graded on the RENDERED SEQUENCE. A platform drops
    the whitespace at a message's edges, so the last visible character of one message sits
    against the first visible character of the next and a trailing newline separates
    nothing. Stripping every chunk's edges before the grade is what makes the predicate see
    what a reader sees, and it is what carries the guarantee to the byte splitter, which
    stores the break rather than trimming it.

The whole sequence, not each neighbouring pair, because a key needs no more than a narrow
budget to span three chunks: split a twenty-character key over four and every pair holds a
fragment matching nothing while the screen holds the key whole. The same gap swallows a
chunk that renders to nothing at all, which the lossless byte splitter can place between
the halves. A fragment is only ever part of a key, so no pair of neighbours can be asked
about it. Both readings joins_to_a_credential names are kept, and each is scanned once
over the joined text rather than per boundary, which is what keeps the search affordable --
measured at 10.5 ms against 160 ms on a 74 KB reply, so the ordinary path is 15 times
cheaper than a per-boundary grade.

When a boundary does rejoin a key the cut is MOVED before any text is given up. Candidate
budgets step back one at a time for the first 128 and exponentially after that; the dense
prefix is what stops a budget clean at 6997 being stepped over by a walk that jumps 4, 8,
16, and the exponential tail keeps the reach without a probe per byte. Worst case 1.49 s on
a 74 KB reply, below the 2.2 s a purely exponential walk cost with the old grade.

A STREAMING caller cannot use that search at all, and this is the sharpest thing the change
had to get right. Such a caller re-splits its growing body every frame and treats all but
the last chunk as delivered, which whatsapp/turn_renderer.py states as its own
requirement: chunk i never changes once chunk i+1 exists. A search that reads the whole
body breaks it -- appending ONE character moved a boundary under an already-sent message in
a measured case, and the final pass slices the new list from the delivered count, so the
span is duplicated or dropped with no way back. That leg therefore takes a prefix-stable
split: the text is redacted, and every boundary stays where the caller's own budget puts
it. The same search space that produced a revision produces none under it.

Prefix stability says nothing about whether a BOUNDARY is safe, so the streaming renderer
grades each one against everything that follows before counting the chunk final, using
joins_to_a_credential, which main already has. That grade reads the RENDERED text, every
chunk's edges stripped, for the same reason the splitter's own predicate strips them: a
platform drops the whitespace at a message's edges, so a tail beginning with a tab separates
nothing once two messages sit on screen. Asking about the characters as stored approves
exactly that pair, and the case is reachable -- the splitter never strips leading whitespace
and a hard cut can leave a remainder starting with one. Both grades now answer the same
question about the same boundary, and a test pins that they agree. A chunk that does not pass stays in the
live bubble, where a later frame may still revise it; at finalization every chunk must go,
so the still-unsealed tail is repaired through repaired_for_delivery rather than held.

Only when no budget at or below the caller's cuts safely is text given up, and then only
the credential's own span. There is no wider fallback that strips a whole message: when no
span names the key, the splitter DECLINES TO CUT and returns the text whole. A boundary is
the only thing that rejoins a key across messages, so creating none is fail-closed, and it
costs the caller a chunk over its limit instead of costing the reader a reply stripped of
its whitespace and markup. A caller that bounds that chunk again has
repaired_for_delivery to grade what it produced. The span is found by SHRINKING -- a span known to collapse into
a key is trimmed from each end by half its width, the trim kept while what remains still
collapses into one -- so a message carrying two keys keeps the paragraphs between them. The
whitespace inside that span is closed up, which makes the key contiguous for the ordinary
redaction, and the loop returns only once the form with EVERY run removed reads clean. That
last condition is the promise to a caller that re-cuts these chunks under its own limit, and
it is why one grade at the end of such a caller is enough. For a key only the rendering
assembles, which no span of the literal text names, the answer is the canonical form -- the
one-directional trade redact_for_display already makes, giving up markup and keeping every
space and every break.

Grading chosen boundaries rather than every candidate is what keeps ordinary wrapped content
intact -- two lines that read as one key when glued are never joined by a cut, so they are
left exactly as written, and a fixture pins that.

The parameter is optional because a caller whose chunks land inside one message severs
nothing a reader can rejoin across messages. It is not optional for the six paths that do
turn one chunk into one message: those are enumerated in the tests, and any splitter call
there that omits the redactor fails. The check walks the AST and counts both shapes,
including the four sites that hand the splitter to asyncio.to_thread as a reference --
a check reading direct calls only would see three of the seven sites and silently pass the
rest.

Per path, all seven call sites:

path call before now
slack/renderer.py:875 split_markdown_safe, offloaded no whole-buffer redaction at the cut passes _redact_all
webex/renderer.py:396 chunk_utf8_bytes display-safe via webex_display_safe line-boundary seam also closed
whatsapp/renderer.py:302 split_markdown_safe display-safe before the split line-boundary seam also closed
teams/renderer.py:383 split_markdown_safe, offloaded display-safe via _display_text line-boundary seam also closed
teams/renderer.py:743 split_markdown_safe, offloaded display-safe before the split line-boundary seam also closed
wecom/renderer.py:306 split_markdown_safe, offloaded display-safe before the split line-boundary seam also closed
dashboard/chat_mirror.py:588 split_markdown_safe display-safe before the split line-boundary seam also closed

WeCom's streaming push already picks a credential-safe offset for the frame it is about to
send, and that path is untouched.

Two legs needed more than the redactor argument, both found by review and both reproduced
before they were fixed.

Slack bounds the splitter's output AFTER it has been graded. A logical line placed whole
carries its fence scaffolding on top, so a chunk can exceed the limit, and chunk_text then
blind-slices it and each slice is posted as its own message -- an ungraded boundary at the
very last step. _split_for_slack now grades that final sequence through the new
repaired_for_delivery and repairs it when it rejoins a key. One grade suffices because the
repair is only returned once its fully-collapsed form reads clean, which the tests check by
re-cutting the repaired text at five different caps.

Webex also has a HARD cap, and the splitter's fail-closed answer collides with it. When no
budget cuts without rejoining a key the splitter declines to cut and answers with the text
whole, which costs the caller a chunk over its budget; this client truncates a larger payload,
so the answer's tail would go with no notice. That path now grades the sequence once more
through repaired_for_delivery and cuts the repair back to the budget, which is sound because
the repair is safe to bound again by contract. A test asserts no chunk it produces exceeds the
cap, and another asserts ordinary text still comes back whole.

Webex was the one path that kept the grade on the loop thread. Its final answer calls the
byte splitter directly inside on_done, and with no cut clean the search and the span repair
hold that thread for seconds -- long enough for the liveness watchdog to exit the gateway and
take every other channel's in-flight turn with it. It now offloads like the other five. A
test walks all six paths and fails if any of them stops handing its splitter call to a
thread.

The span repair is also bounded now. Its passes were capped only by the number of whitespace
runs in the text, and each pass costs a logarithmic number of whole-text redactions, so a
reply whose every break split a key-shaped token would cost thousands of them and the send
would never finish. The cap is the same constant the budget search uses, and past it the
answer is to decline to cut, which gives up nothing.

The dashboard mirror's backfill composed its units inline on the loop thread. An imported
history row carries no size cap, the grade redacts and rescans each candidate boundary, and
the liveness watchdog exits the process after seconds of loop silence -- so one large row
could terminate the gateway. The units are now composed inside asyncio.to_thread, the same
offload the Slack twin already uses and this handler already uses for its selection read.

What tests we did

test/test_split_credential_boundary.py, 82 cases, every run scoped with an explicit -n0:

  • the seam, measured rather than assumed: the fixture's cut is shown to fall between the
    halves of a key, the two pieces are shown to scan clean individually, and the joined
    sequence is shown to hold the key;
  • a key spanning three and four chunks, where every neighbouring pair reads clean, on both
    splitters and across five narrow budgets;
  • a chunk that renders to nothing placed between the halves by the lossless splitter;
  • a key inside a link, which the canonicalised join loses to the label and only the
    per-side reading sees;
  • the dense probe: a budget off the doubling ladder is reached, asserted on the probe order;
  • the terminal, on text no budget can cut safely: the prose around the span survives byte
    for byte, every break and delimiter is kept, two keys keep the paragraph between them,
    the fully-collapsed form of the result reads clean, and the wider flush is shown to keep
    neither -- plus the end-to-end case through the byte splitter, where all seven breaks
    survive;
  • the post-bounding grade: a blind slice is shown to reopen the seam, the repair fires, a
    clean sequence needs none, and the repair stays safe when re-cut at five caps;
  • structural checks that the Slack path runs that grade and that the mirror composes its
    units in a thread;
  • prefix stability, which is the streamed-reply case: the searching path is shown to revise
    an already-sealed chunk after a single appended character, the stable path is shown not to
    across seven append lengths, and the stable path is shown to still redact;
  • structural checks that the streaming renderer asks for the stable split, grades its seam
    and repairs its tail, and that no global whitespace flush remains in the module;
  • all six delivery paths, asserting each hands its splitter call to a thread, so none of
    them can put the grade back on the event loop;
  • the repair loop's bound, asserting the constant is in force;
  • the hard byte cap: no chunk the Webex path produces exceeds it, ordinary text is returned
    whole, and the re-bound is shown to run after the grade;
  • the seam's edge whitespace: the stored reading is shown to approve a tab-separated pair
    the reader sees whole, the rendered reading to refuse it, and the two grades to agree;
  • one channel end to end, through the function WhatsApp's client sends from, asserting on
    the frames it would deliver;
  • backward compatibility: prose and a table row are returned byte for byte with a redactor
    passed, so existing callers are unaffected.

Mutation proof, ten ways, each against a pristine copy kept outside the repo and each
verified by hash to have applied and been restored. Three cover the streaming and terminal
work: stopping the renderer from asking for the stable split fails 1, making the stable mode
fall back to the search fails 2, and sealing without grading the seam fails 1. Four cover the
grade and the repair. Dropping the redactor from one of the
seven call sites fails the enumeration test. Replacing the dense probe with a doubling walk
fails the two probe-order cases. Sending the terminal straight to the wider flush fails the
end-to-end case, where the breaks drop from seven to zero. Widening the repair's span to the
whole text fails four cases, including the two-key one. A fifth mutation, dropping one of the
grade's two readings, initially failed NOTHING -- that gap is what the link case was added
for, and it now fails.

Regression, each file scoped with -n0: test_messaging_split.py 138 passed,
test_channel_table_rendering.py 82 passed (the reassembly invariant the byte splitter
documents), test_chat_mirror.py 82 passed, test_display_split_safety.py 50 passed,
test_whatsapp_renderer.py 46 passed, test_whatsapp_turn_renderer.py 39 passed,
test_security_posture.py 53 passed, test_slack_renderer.py 73 passed,
test_webex_renderer.py 34 passed. Gates: black, isort, flake8, mypy on the changed files,
and the comment-history gate, all clean.

messaging/split.py is listed in NON_EGRESS_REDACTION_MODULES with the reason the
display-safety module gives: it applies a redactor its caller injects, owns no output, and
the modules calling it are the registered sinks.

The fixture uses the AWS-documented example key the repo's own display-safety tests
already use, so no new credential shape is introduced.

Any other suggestions on the work

This does NOT close the issue, and the issue stays open on purpose. Five of the six delivery
paths it names are closed end to end: every boundary they choose is graded, and the
enumeration test fails if any of them stops passing a redactor. The sixth, WhatsApp's
streaming leg, keeps the graded cut but carries a residual that is present on current main
independently of this change -- that leg re-renders a growing reply on every frame while
treating earlier messages as delivered, so a delivery tracked by a count cannot notice when
an earlier message would be rendered differently. Closing it properly means grading a
boundary against what is already on screen, which is the channel-neutral work in #13494, not
something this change can reach. The residual is recorded on #13743 rather than a duplicate
issue. What it does NOT add is predecessor bookkeeping at each point a message stops
being editable -- a streaming leg that has already delivered a message cannot re-cut it, so
that piece has to be graded against what is already on screen. The channel-neutral
primitives for that are in #13494 and are not on main yet, so this change reuses only what
main already has and touches none of the files that PR owns. That bookkeeping belongs to a
follow-up once #13494 lands, not to the six paths this issue is about.

Two things found while measuring, worth recording. The splitter has callers beyond the six
paths named in the issue: discord/renderer.py (five calls), telegram/renderer.py,
feishu/client.py, messaging/renderer.py and teams/session_resume.py. Discord and
Telegram seal splitter chunks as separate messages and carry the same open seam, and both
files belong to #13494, which is rewriting them with the predecessor primitives -- so they
are stage-two scope here by construction, not an oversight, and this PR touches neither.
Feishu, the shared renderer and the Teams resume path are unchanged, and none of them
belongs to #13494. Their own code answers whether their chunks become separate messages
rather than leaving it open: feishu/client.py sends every chunk as its own reply to the
same inbound anchor, and chunk_for_transport hands its parts to callers that send them
one message at a time. Neither passes a redactor, so the seam is open on those legs too.
They sit outside this stage by scope, not by another PR's ownership. And the issue's per-file grade was measured by grepping for the new primitives'
names, which cannot see that five of the six paths already close the mid-line cut by
redacting the whole buffer first; the line-boundary seam is what was actually open at all
of them.

Two advisory findings are recorded rather than fixed. One asks that the redaction-tag tally
be taken from the chunks actually delivered rather than before the split, which changes a
notice rather than a boundary; it is worth doing and is not in this change's scope. The other
is the spec below.

One review finding is recorded rather than fixed. The owning spec,
docs/system-specs/modules/messaging.md, still calls the Webex splitter lossless and the
character splitter free of modes, and the redactor ladder falsifies both. That file belongs
to #13494, which this change deliberately does not touch, so the correction travels with the
follow-up that lands after it rather than creating a conflict here.

Pattern harvest

Rule candidate: enumeration test, added in this PR as
test_split_credential_boundary.py::TestEveryDeliveryPathIsEnumerated.

Pattern: a text is cut on a length budget and then scanned one piece at a time, so the scan
runs after the boundary is chosen and cannot see what the cut separated.

The shape generalises past credentials: any check that reads one piece of a text the caller
will deliver in several is blind to whatever the boundary split. It resists a purely
syntactic rule, because "these chunks each become their own message" is not visible at the
call site -- which is why the enforceable half is an enumeration: the delivery paths are
listed, and every splitter call in them must pass a redactor. The list is checked in both
directions, so a path that stops reaching a splitter fails rather than passing by having
nothing left to check, and the AST pass counts the offloaded asyncio.to_thread shape as
well as the direct call.

Refs #13743

Six delivery paths cut model text on a length budget and scan each piece
on its own. A key the cut severs matches nothing in either piece, so both
are reported clean, and the reader rejoins the halves reading one message
and then the next. The per-piece scan emits no notice, so the operator
sees a clean send.

Five of those paths already redact the whole buffer before splitting,
which closes a mid-line hard cut. It cannot close a cut at a line
boundary: sealing a chunk trims the whitespace that ended it, so the two
halves sit flush against each other on screen while the whole text still
holds the break between them, invisible to a scan of the text as written
and to a scan of either piece.

The shared splitters now take the redactor themselves. split_markdown_safe
and chunk_utf8_bytes reduce the text before any boundary is chosen: the
form the platform renders, and the form the seal's trim produces once
every break is collapsed. A credential visible in either is a marker
before a boundary can land inside it. The parameter stays optional, so a
caller whose chunks stay inside one message is unaffected, and an
enumeration test over the six delivery paths fails when any splitter call
there omits it.

Refs #13743
Grade the boundaries the ladder chooses, one at a time, rather than every
break at once. A scan of all of them together answers a wider question than
any cut asks: two lines that read as one key when glued would cost the message
every break and its markup, though no cut ever joins them. Wrapped content in a
fence is that shape.

The grade reads the RENDERED pair. A platform drops the whitespace at a
message's edges, so the last visible character of one message sits against the
first visible character of the next: neither a trailing newline nor a trailing
space separates anything. That is also what carries the guarantee to the byte
splitter, which stores the whitespace rather than trimming it -- lossless where
it is kept, invisible where it is shown.

The repair moves the CUT before it gives up any text. Budgets step back
exponentially and every candidate is verified, so a key straddling a boundary
ends up whole inside one chunk with every character and every break intact,
where the space between its halves is on screen and the scanner's own reading
of such text stands. Only when no budget at or below the caller's cuts safely
is the whitespace flushed and the text redacted -- every run, because the
whitespace a cut consumes can be a single space -- and that result is graded as
well, since a repair returned without a grade is a repair nobody checked.
Flushing every run is deliberately wider than one cut produces: that width is
what lets a caller bound the chunks again under its own platform limit without
a grade of its own.

The splitter applies a caller's redactor, so it is classified in
security_posture's NON_EGRESS_REDACTION_MODULES. It owns no output; the modules
that call it are the registered sinks. Same reason display_safety.py sits
there, and the posture drift guard fails without the entry.

Refs #13743
@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

Design-level review of e1984a17ac467058524d6ddb3fc021784b7fdd5a — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

Three delivery legs the PR itself names — Feishu, chunk_for_transport callers, Teams session-resume — keep the open credential seam with no tracked owner.

Watch

Suggestions

  • whatsapp/turn_renderer.py importing _redact_all from whatsapp/renderer.py makes a private symbol a cross-module contract the enumeration test now depends on — promote it to a public name.

[DESIGN-REVIEWED] e1984a1

@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of e1984a17ac467058524d6ddb3fc021784b7fdd5a — 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/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

The test claims to enumerate "every path that turns one chunk into one message," yet Discord, Telegram, and Feishu deliver splitter chunks as messages with no redactor.

Not justified as shipped

  • Item 2 — symptom-level: the description says "Six channel delivery paths cut model text on a length budget," but I count nine: discord/renderer.py seals each split_markdown_safe chunk as its own message at 5 call sites (941, 962, 966, 1219, 1244) with only per-piece _redact_all; telegram/renderer.py:400 (_split_markdown, feeding the delivery loops at 1227/1253/1263, each chunk scanned alone via _display_safe); feishu/client.py:213. All three carry the exact line-boundary defect this PR names, and Discord's streaming seal loop mirrors the WhatsApp one that got the seam grade. The general fix now lives in the shared splitter, so the unfixed siblings are point-patch residue the enumeration's own docstring ("every path...") claims not to exist.
    Clears when: those three channels pass a redactor (Discord's streaming leg with the stable + seam-grade treatment) and join DELIVERY_PATHS, or the PR description names them as counted, deferred siblings.

What this change ships

Inventory (10 items) — 9 justified

Intent: stop a length-budget cut from delivering a credential as two clean-scanning message halves a reader rejoins on screen — a FIX.

  1. A cut can no longer rejoin a key: the shared splitters take a redactor, move the cut, repair the span, or decline to cut — justified
  2. Six delivery paths pass the redactor; Discord, Telegram, Feishu still cut unguarded — symptom-level: counted 3 unfixed sibling channels
  3. Text no budget cuts safely is delivered whole, over the caller's limit — justified
  4. Slack/Webex re-grade and re-bound their own post-splitter slices — justified
  5. WhatsApp streaming holds a chunk whose boundary is unsafe instead of sealing it; the final flush repairs the tail — justified
  6. New prefix-stable split (stable) so streaming never revises a sent message — justified
  7. New public repaired_for_delivery for callers that re-bound (3 consumers: slack, webex, whatsapp) — justified
  8. Chat-mirror backfill composition moved off the event loop — rides along
  9. Webex chunking moved off the event loop — rides along
  10. messaging/split.py registered in NON_EGRESS_REDACTION_MODULES — justified

[FIRST-PRINCIPLES-REVIEWED] e1984a1

@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — 🔴 changes requested (blocking)

GPT 5.6 found at least one blocking issue that must be resolved before merging e1984a17ac467058524d6ddb3fc021784b7fdd5a. 2 of 2 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

This comment is updated in place on each push.

BLOCKING -- src/kiro_crew/whatsapp/turn_renderer.py:257 -- Streaming can seal an incomplete credential prefix
if joins_to_a_credential(rendered[index], "".join(rendered[index + 1 :]), _redact_all):
A key split 10/10 across a newline, streamed with only nine suffix characters first -> this check passes and seals the head -> the final character completes the credential across immutable messages.
Anchor: residual/security
Fix: Withhold boundaries ending in a potential credential prefix until finalization.

BLOCKING -- src/kiro_crew/teams/renderer.py:382, src/kiro_crew/wecom/renderer.py:305, src/kiro_crew/dashboard/chat_mirror.py:588 -- Whole fallback is truncated after its final security scan (origin: validation)
split_markdown_safe(..., redactor=...)
An over-cap Markdown link hiding a key-shaped target -> every cut is refused and one oversized chunk returns -> wire truncation removes the closing link, exposes the credential, and drops the tail.
Anchor: backend-security-controls
Fix: Hard-bound oversized results, repair that sequence with repaired_for_delivery, then send only repaired, re-bounded chunks.

[BLOCK-MERGE] e1984a1
[GPT-REVIEWED] e1984a1

Adjudication (Opus 5) — is blocking on each finding proportionate?

F1 — src/kiro_crew/whatsapp/turn_renderer.py:257
UNBOUNDED (credential visible to a chat reader). Conditions confirmed: ≥2 chunks exist mid-stream so the seal loop runs (turn_renderer.py:255); the tail argument is only the text buffered so far (turn_renderer.py:257), and joins_to_a_credential scans just those two strings (display_safety.py:163-169); a sealed chunk is never re-graded — on_done grades only chunks[start:] and never the sealed/pending seam (turn_renderer.py:536-545), and the whole-text pass deliberately accepts a key split by whitespace inside one message (split.py:_cut_where_no_key_rejoins step 4), so recovery is none. Given a boundary inside the key, the partial-suffix window is the first flush after the second chunk forms — the common case, not contradictory timing.

F2 — src/kiro_crew/teams/renderer.py:382, src/kiro_crew/wecom/renderer.py:305, src/kiro_crew/dashboard/chat_mirror.py:588
UNBOUNDED (credential visible on the wire, plus silent tail loss). Conditions confirmed: _cut_where_no_key_rejoins returns a single over-cap chunk at [safe] / [repaired] when no probed budget is clean (split.py, steps 3-4), which is newly reachable at these three sites now that they pass redactor=; none of the three re-grades or re-bounds, unlike the two sibling sites in this same PR (slack/renderer.py:886-891, webex/renderer.py:134-136); WeCom's client then hard-truncates at WECOM_MAX_REPLY_BYTES (wecom/client.py:445,493,573), and wecom/renderer.py:289-292 states that path drops the tail silently while drive_turn persists the full text. Recovery: none. The remedy already exists in-tree (repaired_for_delivery + re-bound) and is three copies of a pattern the PR itself established.

[ADJUDICATION] e1984a1 total=0 uphold=0 downgrade=0
[GPT-ADJUDICATED] e1984a1
[ADJUDICATION-FENCED] e1984a1 fenced=2 flagged=0
UPHOLD-FENCED F1 src/kiro_crew/whatsapp/turn_renderer.py:257 -- The seal grades the boundary against only the text buffered so far and no later pass re-grades a sealed seam, so the partial-suffix window is the ordinary first flush after the boundary forms rather than an extreme timing coincidence.
UPHOLD-FENCED F2 src/kiro_crew/teams/renderer.py:382 -- These three sites newly accept the splitter's over-cap fail-closed answer with no re-grade or re-bound, and WeCom's client hard-truncates it silently, a condition combination that is ordinary operation of the path this PR just added.
[GPT-ADJUDICATED-FENCED] e1984a1

False positive or not applicable? A repository writer can comment:
/ai-review override gpt e1984a17ac467058524d6ddb3fc021784b7fdd5a: <one-sentence reason>

@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 Sep 25, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Superseded by #13858 at b470842. Independent REST readback confirmed two commits on main, Refs #13743, no closing text, and Issue #13743 still open. Closing this predecessor unmerged.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Sep 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

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

Review details

No blocking defect, but the new seam guard has reachable holes on WhatsApp, Webex and three ungated channels.

FINDING — src/kiro_crew/whatsapp/turn_renderer.py:257 — the seam is graded against only the text that has arrived, so a frame where chunks[1] is still "I" clears joins_to_a_credential("…AKIA", "I", _redact_all) and seals chunk 0; stable=True pins that boundary, on_done's pending = chunks[start:] (line 536) excludes it, and a key completed by a later frame is delivered whole across two messages with no marker → Fix: hold a chunk whose stripped tail can still grow into a credential prefix, or include chunks[start - 1] in on_done's grade so the unshipped half is at least redacted.

FINDING — test/test_split_credential_boundary.py:47 — DELIVERY_PATHS is documented as "Every path that delivers one splitter chunk as one message" yet omits discord/renderer.py:941 (split_markdown_safe(candidate, limit), then one _seal_current per chunk), telegram/renderer.py:400 and feishu/client.py:213, none of which pass redactor=, so the severed-key hole stays open on three channels while the enumeration reads as closed → Fix: add those three paths and pass the redactor, or name in the comment which channels are deliberately still ungated.

FINDING — src/kiro_crew/webex/renderer.py:132 — repaired_for_delivery(chunks, _redact_all) can never return non-None here (chunk_utf8_bytes(..., redactor=) returns either a sequence _rejoins_a_key already cleared or the single uncut chunk of split.py:439, and len(chunks) < 2 short-circuits to False), so the re-bound at :135 is dead and the splitter's over-cap "decline to cut" answer — reachable for text like AKIA + a whitespace run wider than the budget + *IOSFODNN7EXAMPLE*, where no probed budget is clean and no literal span names the key — reaches client.truncate_utf8 and the answer's tail is dropped with no notice, the exact failure the added comment says this prevents → Fix: bound on byte length in _bounded_chunks instead of on the grade's answer.

FINDING — src/kiro_crew/whatsapp/turn_renderer.py:567 — count_redaction_tags("\n".join(chunks)) measures the PRE-repair chunks, so on the PR's own primary scenario (a key across a line break: the seal loop holds, repaired_for_delivery at :541 replaces it with a placeholder, pending is re-split) the delivered answer visibly carries a redaction marker and no notice is sent → Fix: count over chunks[:start] + pending after the repair.

FINDING — src/kiro_crew/whatsapp/turn_renderer.py:258 — the refusal return also skips await self._show(tail), and since rendered[index] is prefix-stable the grade answers True on every later frame too, so the live bubble stops updating for the rest of the turn — contradicting the adjacent "stays in the live bubble, where a later frame may still revise it" → Fix: leave the unsealed remainder in the live bubble instead of returning.

FINDING — src/kiro_crew/whatsapp/turn_renderer.py:541 — repaired_for_delivery (and the per-frame joins_to_a_credential at :257, once per unsealed chunk over the whole remaining body) runs ON the event loop while every other site this diff touches offloads the identical work; the repair runs up to _DENSE_PROBES shrink passes, each a logarithmic number of whole-text redaction scans → Fix: wrap both in await asyncio.to_thread(...).

[OPUS-REVIEWED] e1984a1

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable e1984a17ac467058524d6ddb3fc021784b7fdd5a: <one-sentence reason>

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.

1 participant