Repository navigation
fix(channels): guard every delivery path the enumeration derives - #14047
chenmingwei23 wants to merge 1 commit into
Conversation
Three paths that grade a delivered sequence read a subject narrower than the answer, and the enumeration enforcing the guard was a hand-written list, so the paths most likely to be missed were invisible to it. WeCom re-counted a remainder starting at the rotation offset and assigned the result, dropping every placeholder already delivered; the count is an addition, measured against the slice of the answer taken BEFORE the display redaction, so the markers that pass introduces are announced rather than netted to zero. Slack's no-stream fallback recorded only chunk 0 in the ledger the notice counts, so an over-limit answer announced fewer placeholders than it shipped; every confirmed continuation is recorded. Telegram's table-aware cut re-split a repaired body with the prose splitter, which knows neither the table blocks nor the rich budget and cut the table run mid-body; the repair re-enters the assembly that graded it. The population is derived by walking every module that calls a splitter accepting a redactor, with an exception map whose entries state the property making them true and fail when it stops holding. The walk finds three delivery paths with no redactor: Discord's rotation and seal, Feishu's reply split, and the shared transport chunker, whose units every caller sends as its own message. Discord also gains the sealed-predecessor record at its seal sink and at its live frame, so all five of its sealing paths inherit it. Its upload-recovery fallback shows text too, under a message already sealed, so that path grades before it splits and the record it writes stands for text that was graded. The byte unit is guarded by grading the sequence the byte splitter produced, because that splitter reaches its budget by shrinking a character limit and retrying, which a cut free to decline would not terminate on. The shared splitter drops its `stable` mode: one streaming caller selects it and the branch is two calls that caller's own renderer already makes. The module spec is corrected to match and states the credential-aware cutting contract. Refs #13743
Design Review (Fable 5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS Module-keyed exemptions re-open the invisible-path class this PR exists to close: a new unguarded splitter call in an excepted module passes silently. Watch
SuggestionsDiscord's [DESIGN-REVIEWED] b3ac073 |
What is the problem?
Three of the delivery paths that grade a delivered sequence read a subject narrower than the answer, so the redaction notice under-counts what shipped, and one repair leaves a table run cut mid-body.
wecom/renderer.pyre-countsremainder = answer[self._carried:]and assigns the result. After a bubble rotation that subject starts past everything already delivered, so a placeholder in an earlier bubble drops out of the notice.slack/renderer.py's no-stream fallback writes the delivery ledger forchunks[0]only, while the continuation posts record nothing. The notice counts that ledger, so an over-limit answer announces fewer placeholders than it shipped.telegram/renderer.py's table-aware cut hands a repaired body to the prose splitter, which knows neither the table blocks nor the rich budget. The table run is re-cut against the wrong budget and its rows strand as literal pipes.Separately, the enforcement that every path delivering one chunk as one message passes a redactor was a hand-written list of seven modules. A path nobody adds to such a list is not merely unchecked, it is invisible, and the paths most likely to be forgotten are the new ones. Walking the tree finds three delivery paths outside that list with no redactor at all: Discord's rotation and seal, Feishu's reply split, and the shared transport chunker every channel-neutral sink calls.
The module spec also states something the code contradicts: that the splitter is "stdlib-only and pure -- no config objects, no modes".
Why this issue matters to the user
The redaction notice is how a user learns a credential was removed from the reply they just read. A tally that drops the placeholders already on screen tells them nothing was redacted when something was, so they do not know to rotate the key.
On the three unguarded paths the consequence is the one this work exists to close. A key written across a line break matches nothing as written, so every per-message scan passes it; the cut then removes that break and the reader scrolling two messages reads the key whole while neither message holds it. Both messages are already delivered, so there is no recovery. Discord and Feishu are ordinary answer-delivery paths, and the shared chunker carries the dashboard's channel-addressed sends and the Slack mirror.
A stranded table row is a smaller harm: the answer is complete but reads as literal pipes.
How our fix solves it
Each tally counts what it can see, and the count is an addition rather than a replacement:
repaired_for_deliveryanswers only with text that reads clean even with every whitespace run removed.The enumeration is derived instead of listed.
_modules_that_split()walks every module undersrc/kiro_crewthat calls a splitter accepting aredactor, and each call must pass one. Two calls are excepted, and each entry states the property that makes it true rather than an intention: the Teams replay preview keepschunks[0]and discards the rest, so no second message exists to rejoin across; WhatsApp's prefix-stable branch cuts an already-redacted body at its own budget and nowhere else, because searching for a safer budget would move a boundary under a message already sent. A staleness test fails when either claim stops holding, so an exception cannot outlive its reason, and a walk that returns a subset of the tree fails against the channels it must reach.That walk's three findings are closed rather than deferred:
bounded_for_deliverywith its own last-resort cutter, and gains one grader and one writer for the sealed predecessor. The grade runs at the seal sink, at the live frame, and on the upload-recovery fallback -- that fallback is reached when the files-bearing chunk fails to land, shows text under a message already sealed, and writes the record, so it grades before it splits. The record itself is written only where a send or edit confirms, because recording unsent text would cost the next delivered message a leading span for a key nobody read.chunk_for_transportguards both units. The character path passes the redactor; the byte path grades the sequencesplit_markdown_bytesproduced, using the byte cutter it measured in, because that splitter reaches its budget by shrinking a character limit and retrying and a cut free to decline would not terminate on it.The shared splitter drops its
stablemode. One streaming caller selected it, and the branch is two calls that caller's own renderer already makes, so the contract now lives with the caller that needs it and the pure primitive carries no mode. The spec sentence is corrected to match, and the credential-aware cutting contract is written down beside the others.What tests we did
Every run scoped with an explicit
-n0.test/test_split_credential_boundary.py: 156 passed, 5 skipped.docs_lint.pyclean; mypy oversrc/kiro_crew/reports 4 errors intranscribe.pyandops_mission_control/backend/providers/cloudwatch.py, neither touched here.Any other suggestions on the work
The content-revision half of the streaming case stays open and is not addressed here: a sealed message can render differently once a later frame arrives, which a delivered-chunk count cannot observe. Closing it needs grading against what is already on screen, which is #13494's subject. The disclosure half -- a sealed credential prefix completed by text arriving afterwards -- is closed on every path this touches.
Pattern harvest
Rule candidate: when a guard is added at a sink, enumerate every path that reaches that sink by DERIVING the set from the code rather than listing it, and count the guard per path rather than asking whether the function mentions it.
Pattern: this change fixed the same shape three times in a row. A guard lands on the path a reviewer named; a sibling path into the same sink keeps the old behaviour; and the check written alongside the fix asks only whether the guard appears somewhere in the file, so the sibling passes. It recurred here even inside one function -- adding the recovery grade made the older membership check on the seal pass vacuously, which the mutation caught only after the check began counting per path.
Where it generalises:
test_split_credential_boundary.pynow derives its population with_modules_that_split()and counts grades per sink, and the same two moves apply to any invariant enforced by a source-scanning test. The exception map is the other half: an exemption has to state the property that makes it true and fail when that property stops holding, otherwise it silently covers code written later.Predecessor: #13984, merged. Supersedes #14029, which carried this delta without the two fixes above.
Refs #13743