Repository navigation
fix(session): quote provenance-shaped lines inside session_send bodies - #20037
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS Matching any Not justified as shipped
What this change shipsInventory (4 items) — 3 justifiedIntent: a peer session receiving a
[FIRST-PRINCIPLES-REVIEWED] 884bc57 Description read[DESCRIPTION-READ] 57a4d068274439f0708580407bb0b6499992799688f588b0c7aff8323def1f72 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that rewriting prose like Suggestions
[DESIGN-REVIEWED] 884bc57 Description read[DESCRIPTION-READ] 0ef9770cbbe547b9fd130a3efa16fe14b663ad15f1c8d14eeddb7e1b04c463a7 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 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: |
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: |
|
Disposition for the Opus 5.5 and Design reviews of
Case folding uses the pattern's |
The [sent by session X via Y] envelope tells the target which peer sent a message. A body line with the same shape is now rewritten to [quoted: sent by session ...] on both the send and broadcast paths, so only the real envelope opens with the marker.
Reuse context_assembly.markers._marker_spans (NFKC, every Cf char dropped) and accept any Ps opening bracket instead of listing spellings, so bidi controls, soft hyphens and other brackets fold away before the match. Only the matched span is rewritten. Spec updated.
a7c66a6 to
884bc57
Compare
|
Disposition for the reviews of
|
Problem / Motivation
Goal: A
session_sendtarget can always tell the dashboard's real sender line from text inside the message body.session_sendand broadcast prefix each delivered message with[sent by session <caller> via <tool>]. The body was passed through unchanged, so a body that itself contains a line of that shape shows the target more than one sender line, and the target cannot tell which one the dashboard wrote.Why it matters
The sender line is how a target session decides which peer a message came from. If body text can look identical to it, the target can attribute a message to the wrong session.
Not a goal
sanitize_outboundor any other message path besidessession_send/ broadcast.What changed (motivation → approach → change)
Symptom: a body line shaped like the sender header is indistinguishable from the real header. Cause: the body is appended verbatim after the header. Change: in
src/kiro_crew/dashboard/session_control.py,_neutralize_send_provenance()runs aftersanitize_outbound(body)in bothsend_to_targetandbroadcast_to_targets. It finds_FORGED_PROVENANCE_RE(anyPsopening bracket, thensent by session, case-insensitive) on a normalized view built by the existingcontext_assembly.markers._marker_spans: NFKC, everyCfchar dropped (bidi controls, zero-width chars, BOM, soft hyphen), dashes folded. Each match maps back to its span in the original text and only that span becomes[quoted: sent by session; the rest of the body stays byte-exact. Matching a normalized view instead of listing spellings follows the Design review. Only the real header, prepended by this module, opens with[sent by session. The spec paragraph indocs/system-specs/modules/session-control.md(Provenance) now says so.Backwards compatibility
Compatible: only body text with the bracketed sender shape changes, and it is quoted rather than removed; the header format and every caller are unchanged.
Removes nothing: the body is rewritten in place, no key, path, record or function is removed.
Tests
test_send_body_cannot_forge_a_second_provenance_envelope(test/test_session_control.py): a body with three sender-shaped lines is delivered with exactly one real header and three[quoted: ...]lines.test_neutralize_send_provenance_folds_invisible_chars_and_any_opening_bracket(7 cases): bidi-wrapped words, soft hyphen and BOM inside words, and the【,⟦,(,{brackets are all quoted. All 7 fail on the first commit's regex; all 8 sender-shaped cases fail with the rewrite removed.test_neutralize_send_provenance_leaves_plain_text_alone: ordinary text, a fullwidth letter, an em dash and an accented letter come through byte-exact.python3 -m pytest test/test_session_control.py: 238 passed.python3 scripts/local-gate.py: backend related set and frontend related set (361 files) passed.Manual verification
N/A — unit coverage sufficient: the change is a pure string transform on the delivered prompt, exercised end to end through
send_to_targetin the new test.Related Issues
Closes #20036
Pattern harvest
Not generalizable: the sender header is the only trust-label line this module prepends to caller-controlled text.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.