Repository navigation
fix(imessage): keep fenced role-marker mapping keys out of the outbound stripper - #117159
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 4:47 AM ET / 08:47 UTC. ClawSweeper reviewWhat this changesThis PR makes iMessage outbound sanitization preserve literal Merge readinessThe focused iMessage repair remains necessary because current Priority: P1 Review scores
Verification
How this fits togetheriMessage replies pass through an outbound sanitizer before formatting, chunking, and the native send boundary. The sanitizer removes leaked model scaffolding, so it must distinguish internal prose markers from literal code supplied to recipients. flowchart LR
A[Agent reply text] --> B[iMessage delivery transform]
B --> C[Outbound sanitizer]
C --> D{Match inside Markdown code?}
D -->|No| E[Remove leaked internal marker]
D -->|Yes| F[Preserve literal code content]
E --> G[Format and chunk reply]
F --> G
G --> H[Native iMessage send boundary]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +50. Total +50 across 2 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Merge the focused owner-boundary fix after the active exact-head check completes, keeping Markdown code content literal while retaining the established prose-only leak stripping. Do we have a high-confidence way to reproduce the issue? Yes — current main directly replaces the standalone role-marker match before delivery, and the PR's colocated cases provide a focused fenced-YAML reproduction shape. This review did not execute the test suite because the checkout is read-only. Is this the best way to solve the issue? Yes — the patch fixes the corruption at AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ea3b5df17237. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
7e887a4 to
44d9076
Compare
|
The red The failing shard is Could a maintainer re-run |
9e91a2e to
3d45501
Compare
3d45501 to
0bfdf3c
Compare
|
@clawsweeper re-review: Assigned iMessage owner accepts literal marker-shaped text inside Markdown code regions while preserving prose stripping. Correct provenance: PR #33295 / adb9234 introduced the sanitizer (@joelnishanth; merged by @vincentkoc); PR #96392 / 770b19f only narrowed it to standalone role lines and did not add code-region protection. Release exposure: v2026.7.1 and v2026.7.2-beta.1 through v2026.7.2-beta.5 all contain sanitizer blob cd230ee1baef18b3e6ef44669c77bb02ce4d7ff9. Recheck repaired exact head 0bfdf3cbe9034358fa7af67e1019f923a147251a and replace any stale provenance in the durable review. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
sanitizeOutboundText strips standalone `user:`/`system:`/`assistant:` lines (leaked turn boundaries), `#+#` separators and `assistant to=` markers, but the three regexes had no code-fence awareness. A bare YAML mapping key like `user:` on its own line inside a ```yaml block matched ROLE_TURN_MARKER_RE and was silently deleted before iMessage delivery, reparenting its children under the wrong node — still-valid YAML, wrong meaning, and nothing signalling a line was removed. Skip matches whose offset falls inside a markdown code region for all three patterns, reusing findCodeRegions/isInsideCode already applied by the sibling reflection-guard on this channel. Regions are recomputed per pass because each strip shifts later offsets. Leaked markers in prose are still stripped. Refs: openclaw#116942 Co-Authored-By: Claude Opus 4.8 <[email protected]>
0bfdf3c to
b746c8b
Compare
|
@clawsweeper re-review: rebased the unchanged focused repair onto live main b0b708d after #117282 rewrote the downstream iMessage delivery boundary. Review exact head b746c8b. Sanitized AWS proof on that exact head passed 193/193 across monitor.behavior, deliver integration, and plugin-payload tests; targeted oxfmt and oxlint passed with zero findings; fresh autoreview is clean. The exact-head check-lint failure has no diagnostic and is another externally canceled core shard (exit 143); one failed-only rerun is active. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
vincentkoc
left a comment
There was a problem hiding this comment.
Maintainer review complete on exact head b746c8b against live main ea3b5df. The sanitizer-owner fix is the best repair: it reuses the canonical Markdown code-region contract, preserves literal fenced/indented content, and keeps prose leak stripping intact. Sanitized AWS proof passed 193/193 focused iMessage tests; targeted formatting and oxlint passed; fresh autoreview and exact-head ClawSweeper found no actionable defects; required CI is green; zero unresolved threads; no iMessage drift since the rebase; merge tree is clean. Approved.
…nd stripper (openclaw#117159) * fix(imessage): stop the outbound sanitizer deleting fenced role keys sanitizeOutboundText strips standalone `user:`/`system:`/`assistant:` lines (leaked turn boundaries), `#+#` separators and `assistant to=` markers, but the three regexes had no code-fence awareness. A bare YAML mapping key like `user:` on its own line inside a ```yaml block matched ROLE_TURN_MARKER_RE and was silently deleted before iMessage delivery, reparenting its children under the wrong node — still-valid YAML, wrong meaning, and nothing signalling a line was removed. Skip matches whose offset falls inside a markdown code region for all three patterns, reusing findCodeRegions/isInsideCode already applied by the sibling reflection-guard on this channel. Regions are recomputed per pass because each strip shifts later offsets. Leaked markers in prose are still stripped. Refs: openclaw#116942 Co-Authored-By: Claude Opus 4.8 <[email protected]> * test(imessage): cover code-aware marker stripping --------- Co-authored-by: Claude Opus 4.8 <[email protected]> Co-authored-by: Vincent Koc <[email protected]>
What Problem This Solves
Every outbound iMessage reply runs through
sanitizeOutboundText, which strips threeinternal-marker patterns. One of them,
ROLE_TURN_MARKER_RE(extensions/imessage/src/monitor/sanitize-outbound.ts:12),deletes any line that is only
user:,system:orassistant:— a leaked turn boundary.The regex is anchored per line and allows leading whitespace, and it runs with no code-fence
awareness. So a bare YAML mapping key on its own line inside a fenced block matches and is
silently deleted before delivery.
The recipient gets YAML that still parses but now nests the child keys under the wrong parent:
Trigger is ordinary technical chat, not an edge case: Ansible
user:modules, docker-composetop-level
user:, cloud-init, netplan, and LLM prompt templates withsystem:/assistant:lines all hit it. The corruption is silent — nothing signals a line was removed. The two sibling
patterns on the same path (
INTERNAL_SEPARATOR_RE,ASSISTANT_ROLE_MARKER_RE) share the blind spot.Closes #116942.
Why This Change Was Made
The role-marker strippers exist to remove leaked turn scaffolding from prose. Inside a code
region a bare
user:mapping key or a#+#line is the user's own content, not scaffolding,so the strip must skip it. The plugin already owns the exact tool:
findCodeRegions/isInsideCodeare exported fromopenclaw/plugin-sdk/text-chunkingand the siblingextensions/imessage/src/monitor/reflection-guard.tson this same channel already uses them toignore matches inside code. Core's
assistant-visible-text.tsuses the identicalrecompute-between-passes shape. So this is the established, narrowest boundary — it preserves the
existing "strip leaked markers in prose" contract while restoring fenced content, rather than
weakening or deleting the strip.
Root cause is fully contained in
sanitizeOutboundText; everything downstream operates on thealready-corrupted text. Fix = one file, one small helper applied to all three patterns; regions
are recomputed per pass because each strip shifts later offsets. Blast radius:
sanitizeOutboundTexthas three callers, all in the iMessage extension (
deliver.ts:39,deliver.ts:89,channel.ts:412).Grep confirms no other channel carries a role-turn stripper, so this is iMessage-only.
User Impact
Fenced code blocks in iMessage replies are delivered intact. A
user:/system:/assistant:mapping key inside a fence survives, and its children stay correctly nested. Leaked standalone
role markers in prose are still stripped, unchanged.
Evidence
AI-assisted.
Focused regression proof (also the ClawSweeper-listed acceptance command):
Three new cases in
sanitize-outbound.test-support.tsfail on the unmodified sanitizer and passafter the fix; full suite 178/178 (185/185 including
deliver.test.ts).Real-behavior proof — a harness drives the real production delivery transform chain exactly as
deliver.ts:39-46composes it (sanitizeOutboundText→ realconvertMarkdownTables→ realchunkTextWithMode) and captures the exact payload handed to the send boundary. Negative controlon unfixed
mainvs this branch, same command:git diff --checkclean;oxfmtclean. Production delta +17 LOC (one helper).What was not tested: the send RPC itself needs a signed-in Mac + imsg bridge, so the harness
stops at the send boundary and captures the pre-send payload — the same limitation the reporter
noted. The corruption is introduced entirely by
sanitizeOutboundText, upstream of that boundary,so the captured payload proves it. Typecheck was left to CI (the linked worktree can't run the
tsgo lane locally without a dependency reconcile).
Maintainer validation
#+#, assistant-role, anduser:/system:/assistant:markers in prose.extensions/imessage/src/monitor/sanitize-outbound.ts, where outbound text is corrupted before formatting, chunking, or send. The branch uses the existing public code-region helpers already used by the sibling iMessage reflection guard.user:,system:, andassistant:inside and outside code; backtick fences, tilde fences, indented code, and an unterminated fence with earlier removals that shift offsets.adb9234d0375df93d1ec96ce4008107788cc46c2introduced the sanitizer (@joelnishanth, merged by@vincentkoc, March 7, 2026). PR fix(imessage): only strip standalone role-turn markers, not prose ending in a role word #96392 /770b19f496c1637774e660d31306105b671d1526(@ly-wang19, merged by@vincentkoc) narrowed role stripping to standalone lines but did not protect code regions.v2026.7.1and everyv2026.7.2-beta.1throughv2026.7.2-beta.5contain sanitizer blobcd230ee1baef18b3e6ef44669c77bb02ce4d7ff9.0bfdf3cbe9034358fa7af67e1019f923a147251a, rebuilt onorigin/main6922ddd936106c95c2f1388812bc49e8f7920dd0; the empty CI-retrigger commit was removed and contributor authorship was preserved.node scripts/run-vitest.mjs extensions/imessage/src/monitor.behavior.test.ts- 179/179 passed.