Repository navigation
fix(wecom): choose a streaming cut the reader cannot rejoin into a credential - #12198
Conversation
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify no other capped streaming renderer (Slack, Feishu, WhatsApp) shares the blind raw-cut pattern — the primitive is general but wired into WeCom only. [DESIGN-REVIEWED] b9a2ffc |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify no other streaming renderer cuts raw text before per-slice scrubbing — the fix lands only in WeCom's What this change shipsInventory (5 items) — 5 justifiedIntent: FIX — stop WeCom's streaming cap from severing a credential across two bubbles the reader's client rejoins on screen (issue #11727; the gap was already documented as a known residual in the base
[FIRST-PRINCIPLES-REVIEWED] b9a2ffc |
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/wecom/renderer.py:663 -- “the next frame of this bubble carries the remainder” contradicts False positive or not applicable? A repository writer can comment: |
Opus 4.8 Review — ✅ no blocking findingsReviewed Review detailsNo findings. Both candidates are performance/UX observations below the survival bar, not concrete defects. Candidate 1 (full-remainder scan per frame) describes correct output at possibly higher cost: Candidate 2 (backoff returns 0 → footer replaces shown text) is self-rated low confidence and is transient by its own account: returning 0 sets No un-inherited defect met the (a)/(b)/(c) bar at 80+ under my own re-derivation: the cap is only strengthened (no guard removed), [OPUS-REVIEWED] b9a2ffc Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
1feac70 to
5cb38a1
Compare
GPT 5.6 Review —
|
1 similar comment
GPT 5.6 Review —
|
5cb38a1 to
d41a8c7
Compare
d41a8c7 to
0f92ff3
Compare
0f92ff3 to
811a004
Compare
811a004 to
983ec52
Compare
d426b89 to
7dc02a2
Compare
7dc02a2 to
1d07708
Compare
1d07708 to
7f93c2d
Compare
7f93c2d to
234f05e
Compare
Rebuttal: the footer-erasure finding names a state this renderer cannot reachRe the blocking finding on The finding's premise is sound about the frame model: a WeCom stream frame replaces the I implemented the suggested fix -- skip sending the footer-only replacement when the answer Why the state is unreachableThree facts have to hold at once, and the second and third exclude each other.
Point 3 is the constraint. For every offset to fail, the answer has to begin with the That is what my fixture hit. Prose delivered first (satisfying 1), then the straddling tail The remaining route would be for the frozen head to GROW after the delivery, making a DispositionRebutted as unreachable on this head, with the failing test as the evidence rather than an Two notes for the record. The frame model the finding describes is real, so if a later |
GPT 5.6 Review —
|
1 similar comment
GPT 5.6 Review —
|
GPT 5.6 Review — 🔴 changes requested (blocking)GPT 5.6 found at least one blocking issue that must be resolved before merging This comment is updated in place on each push. BLOCKING -- src/kiro_crew/wecom/renderer.py:696 -- Replaced reasoning remains in the frozen screen Adjudication (Opus 4.8) — is blocking on each finding proportionate?The adjudicable input block is empty (0 findings). One fenced finding, F1, requires a ruling. F1 — Conditions I confirmed on disk:
The code (comments 686–695) deliberately chooses the unconditional fold, arguing over-grading is "the safe direction." That makes the realistic consequence a bounded, visible, self-correcting over-redaction rather than a leak or hole — which would favor accepting residual risk. But the condition combination (reasoning → delivered answer → age rotation with a credential-like reasoning tail joining the answer head) is not extreme: a long agentic turn plus content the LLM can produce is plausible, so I cannot complete the extreme-rarity record FLAG requires. When torn on a fenced/unbounded-anchored finding, the contract is UPHOLD-FENCED. False positive or not applicable? A repository writer can comment: |
The item offers two clearance routes: cite the ACK semantics showing an accepted frame
A frame therefore has three states, refused, accepted, and no answer yet, and the protocol The cost of this reading is one frame's worth of text appearing twice at a rotation, which |
GPT 5.6 Review — 🔴 changes requested (blocking)GPT 5.6 found at least one blocking issue that must be resolved before merging This comment is updated in place on each push. BLOCKING -- src/kiro_crew/wecom/renderer.py:730 -- Max-only edges discard an intermediate visible screen [BLOCK-MERGE] 4449dad Adjudication (Opus 4.8) — is blocking on each finding proportionate?This is the empty adjudicable block plus one fenced finding F1. I've opened the code F1 names ( F1 concerns Harm class is credential text reaching WeCom — unbounded. To FLAG I would need to prove from the code that a distinct intermediate buried tail cannot arise across two rotations, i.e. that two tracked edges always suffice. I cannot complete that rarity argument: the two-head design shows the author tracked exactly two edges, and whether a third is reachable across chained rotations is the open question F1 raises, not one the code visibly forecloses. An incomplete rarity record on an unbounded-harm fenced finding is UPHOLD-FENCED, and when torn the contract says UPHOLD-FENCED. [ADJUDICATION] 4449dad total=0 uphold=0 downgrade=0 [ADJUDICATION-FENCED] 4449dad fenced=1 flagged=0 False positive or not applicable? A repository writer can comment: |
This item now clears on two things a maintainer does: confirm the ACK semantics against WeCom's The unobservability is TWO facts in
Neither fact alone settles it. Together they leave no observation that separates "accepted" The trade, stated plainly so acceptance is a decision and not an inference. Cost: at a rotation What a maintainer is being asked to decide, concretely: whether that repeat is acceptable |
The bubble cap was applied to the raw answer while the reader sees the canonical rendering of each bubble, so a credential the model split with markup could be severed by it: each bubble was scrubbed alone and matched nothing, and the client rendered the markup away and joined the halves on screen. A bubble rotation is irreversible, so there was no recovery. The cut is now decided by the transforms that decide the display, not by a set of characters a split might hide behind. joins_to_a_credential redacts each side the way it will be sent, joins the two, canonicalises the join and scans it; safe_split_offset walks the boundary back exponentially until that is clean. _push fills a bubble to that offset, and _roll_if_sealed re-decides the boundary against the whole answer before a rotation makes it permanent, because the answer grows after a frame goes out. Closes #11727
GPT 5.6 Review —
|
bolichen97
left a comment
There was a problem hiding this comment.
Approved after a live re-verification: readiness: passed label, PR Readiness status success on this head, no required check pending/failed/cancelled, mergeable, no effective CHANGES_REQUESTED, and no unresolved human blocking request found in comments or review threads. Native auto-merge (squash) enabled; no admin override used.
What is the problem?
WeComRendererstreams an answer in capped bubbles. The cap is applied to the RAW answertext, but the reader sees the CANONICAL rendering of each bubble. So a credential the model
split with markup is severed by the cap without anything noticing:
canonicalize_displaycollapses[label](target)tolabel, so the reader seesAKIAIOSFODNN7EXAMPLEspanning the two bubbles. Each bubble is scrubbed on its own andneither half matches a credential pattern, so the per-message redaction is blind to it.
Why this issue matters to the user
The user is shown a live credential. Not in a log, not in a debug path: in the answer, on
screen, in their own chat. A bubble rotation is irreversible -- a sealed bubble can never be
rewritten -- so there is no in-frame recovery once the two halves are up.
How our fix solves it
The symptom is a key on screen. The immediate cause is that the two bubbles' contents are
adjacent to the reader but separate to the scrubber. The root cause is WHERE the cut falls:
it is chosen in raw coordinates, with no reference to what the pieces will look like once
rendered.
So the cut is chosen against the rendered form.
_pushreplaces its blind slice withsafe_split_offset(body, room, _default_redactor), which returns the largest sampled offsetat or below the budget that severs no credential. Nothing after that offset has been
delivered, so the next frame of the bubble carries the remainder and the answer is not
truncated.
safe_split_offsetrests onjoins_to_a_credential, which asks the question directly ratherthan guessing which characters could hide a split. That distinction is the whole reason the
earlier attempt at this failed: #11196 carried a ~360-line engine whose straddle predicate was
sound but whose search WINDOW was found by walking backwards over a hand-written character
class. Whenever canonicalisation can join text across a character the class does not contain,
the walk stops early, the window excludes the credential's prefix, and the predicate passes
vacuously. There is no character class, no window and no anchor list anywhere in this guard.
The oracle reads the pair BOTH ways, because neither reading contains the other:
where one ends. It is wider for a run of delimiters, which concatenation can only extend:
AKIA**beside**RESTis a run only once the halves sit together.read one after the other. This is wider wherever canonicalising DROPS text, which is what a
link does to its target. A cut one character inside
[l](https://x/AKIA+REST)completesthe link only in the concatenation, where the url collapses to the label and the key vanishes
from the scan -- while on screen each half is an unfinished link whose url stays visible.
Soundness:
redact_for_displayalready emits the canonical form whenever canonicalisingreveals something the literal form hid, so redacting and then canonicalising is a fixed point
for any single string. Whatever the scan finds is therefore produced by putting the two sides
together and by nothing else.
What tests we did
test/test_display_split_safety.py(new) pins the two primitives on their own.TestTheCapCutsWhereTheReaderCannotRejoinintest/test_wecom_renderer.pydrives the rendererend to end and asserts against the reader's RENDERED view, scanned with the same redaction pair
the renderer sends through.
The reader model asserts EVERY instant the screen passed through, not just the final state: a
stream frame replaces its own bubble, so a frame that puts a credential on screen has been read
by the time a later frame supersedes it.
The straddling shapes live in one shared table (
conftest.CREDENTIAL_STRADDLE_SHAPES) so theprimitive and the renderer cannot drift apart on what they cover: a comma inside a link target,
whitespace in an authorization header, underscore and tilde emphasis, URL-terminating
punctuation, a cut inside a link's URL, a PEM anchor split mid-word, the same anchor split by
emphasis, and a cut through a key carrying no markup at all. Each row asserts its own premise
first -- neither half is a credential alone -- so a fixture that stops straddling fails loudly
instead of passing on a case it does not cover.
Mutation-verified. Restoring the blind cut (
body[:room]) reddens TEN tests, every one of themin the new renderer class and every one with "a credential reached the reader". The allow
direction stays green throughout: an answer within the cap is sent unchanged, which is the case
that says the guard is conditional rather than refusing every boundary.
166 tests pass across the three touched test files. black, isort, flake8, mypy, docs lint and
the comment-history gate are clean.
Pattern harvest
Rule candidate: semgrep
Pattern: a credential or redaction scan whose search window is bounded by a hand-written
character class, typically a backwards walk that stops at the first character outside the
set, when the text will be transformed after the scan
A scan that has to anticipate a later transformation cannot be scoped by a character
class. This is the generalisable shape, and it is why the earlier attempt at the same bug
failed. The predicate was right; the WINDOW it ran in was found by walking over a
hand-written set of characters, and such a set can never be closed -- the next character it
does not know about is one more place a split can hide. The walk stops early, the check runs
on a span the credential was never inside, and it passes vacuously. Anywhere a scan happens
before a transformation (markup rendering, canonicalisation, unicode folding, a client's own
prettifier), ask the transformation what it produces and scan THAT, rather than enumerating
the characters you think it can cross.
When two readings of the same data both exist, neither may be assumed to contain the
other. Canonicalising a concatenation and concatenating two canonicalised pieces give
different answers, and which one is wider depends on whether the transformation EXTENDS text
(a delimiter run) or DROPS it (a link target). Checking either alone leaves a real case
unscanned. One test per reading pins that neither covers the other.
A fixed point is what makes a two-sided check sound.
redact_for_displayalready emitsthe canonical form whenever canonicalising reveals what the literal form hid, so redacting
and then canonicalising is idempotent for any single string. Without that property, a
finding from the joined scan could have come from one side alone and the check would not be
attributing it correctly. It is pinned on its own rather than assumed
(
TestRedactionIsAFixedPoint).Scope discipline: a boundary whose other side can still be edited is a different problem
from one that is frozen. Both look like "a credential spans a cut". The first is closed by
choosing the cut; the second needs a model of what the reader currently has, which turned out
to need four review rounds of its own and is now #12683. Shipping them together hid that they
were two problems.
Any other suggestions on the work
This PR was descoped deliberately, and the rest is tracked rather than dropped. An earlier
revision of this branch also re-decided the seam at a BUBBLE ROTATION, which is a different
problem: the sealed bubble cannot be rewritten, the platform never reports that a frame was
accepted, and the graded screen therefore has two possible edges at once. Four consecutive
review rounds each found a real defect in that half, each one in the state model rather than in
a line, so it is taken out of this PR and filed as #12683. The cap cut is what this
issue asks for, it has been stable across every round, and it stands alone.
What is left is deliberately small, so a reviewer can hold all of it at once: one behaviour change
in
_push, two functions indisplay_safety.pywith no deletions from that module, one specsection, and the tests. Six files, 538 insertions, 9 deletions.
One residual worth naming for whoever picks that up: the rotation seam's correctness rests on
WeCom's ACK semantics, specifically that an accepted frame is not acknowledged in a way that can
be attributed to a frame. That claim is sourced from the code (
send_streamhas no per-frameACK wait because every frame replays the one inbound
req_id, and the ACK handler's own commentsays an accepted frame is not documented to be acknowledged), but a maintainer who knows the
protocol should confirm it before that half ships.
Closes #11727