Skip to content

fix(zalouser): sanitize outbound tool traces - #101441

Open
clawSean wants to merge 1 commit into
openclaw:mainfrom
clawSean:fix/zalouser-sanitize-outbound-90684
Open

clawSean wants to merge 1 commit into
openclaw:mainfrom
clawSean:fix/zalouser-sanitize-outbound-90684

Conversation

@clawSean

@clawSean clawSean commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Merge Brief

  • Problem / value: Zalo Personal's custom monitor callback bypasses its standard adapter, so a message_sending hook can reintroduce internal tool traces immediately before transport. This patch keeps recipient text and captions clean while preserving configured Markdown-table rendering.
  • Relevance: Independent P1/security report Feishu (and non-Discord channels) should apply sanitizeAssistantVisibleText() on outbound text #90684 tracks this leakage class. Merged fix(channels): hide internal tool text in Reef and Zalo Personal #112621 sanitizes the standard adapter only; current main still leaves this distinct callback seam open.
  • Smallest complete fix / review map: Keep configured table conversion in delivery.preparePayload, where durable final delivery sees it, and sanitize only the effective post-hook payload in the custom callback. Scope is 4 files, +76/-20: two small helpers, two focused regressions, and the boundary wiring.
  • Risk / proof: Risk is limited to ordering between two existing transforms. Exact head b012137ca6889eab50e9474c9d34497b2e4752e3; full Zalouser 221/221; changed-file format/lint, extension production/test types, branch ratchets, and all 36 non-skipped hosted checks pass. The exact deterministic wrapper has only untouched frozen-base Codex/dead-export debt.
  • External proof limit: Authenticated recipient-visible transport is blocked_external because no safe configured account/recipient route exists. Exact-head tests reach both lifecycle boundaries; no live send is claimed.
  • Non-goals: Standard adapter, sanitizer parser dialects, Zalo Bot, authentication, configuration schema, and protocol changes.
  • Maintainer ask: Please apply no-stale while authenticated recipient proof is coordinated; the assigned-PR age clock otherwise ignores substantive updates.

What Problem This Solves

Zalo Personal's custom inbound-reply path in monitor.ts can deliver a post-hook payload without passing through the standard outbound adapter. That leaves one route for compact tool-failure lines or tool XML to reach recipients. The repair must also preserve channels.zalouser.markdown.tables for final replies handled by durable delivery. Related: #90684.

User Impact

Recipients get intended assistant text and media without internal tool-trace scaffolding, while existing table preferences such as markdown.tables: "bullets" continue to apply to durable final replies. Ordinary prose, captions, chunking, and media delivery remain unchanged; users have no migration step.

Why This Change Was Made

  • delivery.preparePayload owns configured table conversion before the lifecycle can return through durable delivery.
  • The private custom callback owns sanitization after message_sending, so a supported hook cannot reintroduce internal traces.
  • Merged fix(channels): hide internal tool text in Reef and Zalo Personal #112621 covers the standard adapter only; this remains a narrow, distinct callback repair.

Evidence

  • Exact signed candidate head: 41e305a4a4f4fd73973bac5858b07766db1791f9 on frozen maintenance base b464d49019995ec229595bdcbba9d3b61ff035f7.
  • pnpm exec vitest run extensions/zalouser: 33 files and 317/317 tests passing, including configured bullet-table preparation before durable delivery and post-hook trace sanitization at custom delivery.
  • pnpm tsgo:extensions and pnpm tsgo:extensions:test: passing.
  • Changed Zalouser scope passes type-aware Oxlint, Oxfmt, and git diff --check. Repository-wide extension lint's only failure is unchanged frozen-base debt in extensions/amazon-bedrock/stream.runtime.test.ts (max-lines).
  • Deterministic openclaw-pre-pr.sh gate: passed for frozen base b464d49019995ec229595bdcbba9d3b61ff035f7, exact head 41e305a4a4f4fd73973bac5858b07766db1791f9, and merge tree 1d2e0ad6dc09fd07dfa21423c38602b80e92ae9d.
  • Current-main negative control: the custom monitor callback still resolves and delivers the post-hook payload directly. This head restores pre-durable table preparation and sanitizes immediately before custom text/caption resolution.
  • Remaining proof state is blocked_external, not a claimed live pass: authenticated recipient-visible proof still requires a safe Zalo Personal account and recipient route.

AI-assisted change, manually reviewed and validated.

Exact-head refresh (2026-10-26)

The current signed PR head is b012137ca6889eab50e9474c9d34497b2e4752e3, rebuilt on frozen base f4a0d4875912103be54dd672e32db17064d003db with a four-file patch and clean merge tree f44ddf096cf52e14aadcf50b892f2ea4b8765eee.

  • Disposable Linux/arm64 proof used Node 24.22.1 and a fresh frozen-lockfile install; the full Zalouser suite passed 221/221 across 30 files.
  • Changed-file format/lint, production and test extension typechecks, conflict/line-cap/assertion/SQLite/plugin-boundary ratchets, doctor-contract tests, media/runtime guards, and import-cycle checks passed.
  • Independent exact-diff review found no P0-P2 findings. GitHub and the fork ref read back this exact head, and all 36 non-skipped hosted checks pass with none pending or failed.
  • Authenticated recipient-visible Zalo proof remains externally blocked: no consented safe recipient route is available, so no private recipient was used and no live-send claim is made. The deterministic negative path, exact-head full suite, and hosted execution are the strongest contributor-safe evidence currently possible.

@openclaw-barnacle openclaw-barnacle Bot added channel: zalouser Channel integration: zalouser size: XS labels Jul 7, 2026
@clawsweeper

clawsweeper Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR sanitizes Zalo Personal custom replies and captions after hook rewrites while preserving configured table conversion.

Example: A message_sending hook rewrites a tool reply to "Done.\n⚠️ 🛠️ search repos (agent) failed".

  • Before: The custom monitor sends the tool-failure trace alongside "Done.".
  • After: The custom monitor sends only "Done.".

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused repair appears correct, but the supplied automated evidence does not satisfy the required real-behavior proof gate.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Zalo Personal recipients can receive internal tool traces introduced into custom replies by a message-sending hook.
Reason: This completes the existing channel sanitization contract at a distinct delivery boundary without adding configuration or changing public APIs.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: current main still leaves the custom post-hook delivery path unsanitized, and this assigned PR retains a distinct, useful repair.

Reviewed head: b012137ca6889eab50e9474c9d34497b2e4752e3

Before merge

  • Add real behavior proof - The changed monitor is exercised with synthetic rewritten payloads, a mocked inbound lifecycle, and a mocked sender; the authenticated account probe establishes connectivity only. The contributor explicitly reports that recipient-visible delivery remains blocked. Supply screenshots, redacted logs, or live output from the reviewed head exercising post-hook text and caption sanitization while preserving prose and configured tables; redact credentials, phone numbers, private identifiers, IPs, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Low-value test extensions/zalouser/src/reply-text.test.ts: Remove the duplicate sanitizer-helper assertion and move table coverage to the production lifecycle boundary: directly calling these helpers proves neither post-hook ordering nor preparation before durable bypass.
  • Missing end-to-end proof: Missing a real recipient-visible run through the custom callback showing post-hook trace removal in text and captions with ordinary prose and configured tables preserved; exact-head base-failing/head-passing boundary execution is also not supplied.
Agent review details

How this fits together

The Zalo Personal monitor supplies delivery callbacks to the shared inbound lifecycle, which prepares tables and applies hooks before routing replies through durable delivery or the custom text/media sender.

flowchart TD
  A[Assistant reply] --> B[Configured table preparation]
  B --> C[Shared delivery lifecycle]
  C --> D[Durable outbound adapter]
  C --> E[Post-hook custom callback]
  D --> F[Canonical text sanitizer]
  E --> F
  F --> G[Zalo text or media transport]
Loading

Technical review

Best possible solution:

Keep table preparation before durable routing and apply the existing canonical sanitizer to the effective custom-delivery payload.

Do we have a high-confidence way to reproduce the issue?

Source inspection establishes the path: a hook can add a known sanitizer target before the unsanitized custom callback sends it; no target code was executed during this review.

Is this the best way to solve the issue?

The repair uses the established sanitizer at the missing boundary and preserves durable table preparation, media handling, and partial-delivery ownership.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7ca7ecb804ef.

Provenance checked

  • Configured table preparation keeps the original intent (05eda57: The lifecycle migration prepares configured tables before durable delivery can bypass the custom callback.)
  • Custom callback delivery ownership keeps the original intent (520f698: The refactor kept delivery preparation and callbacks with their consumers while preserving behavior and effect boundaries.)
  • Partial-delivery receipts and errors keeps the original intent (0d13bec: Accepted platform receipts must survive later failures, and the dispatcher must receive authoritative delivery errors.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 520f698 adds extensions/zalouser/src/monitor.ts:660 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 520f698c81d8; files: extensions/zalouser/src/monitor.ts)

PR surface

Source +17, Tests +39. Total +56 across 4 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 35 18 +17
Tests 2 41 2 +39
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 76 20 +56

Labels

Label changes:

No label changes.

Label justifications:

  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (32 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-26T18:58:12.326Z sha 875c9009cc67a798fff9a92eae1677d5bb54c94a :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-30T17:20:29.026Z sha cce78deb8485bb2d24ee839b47e7fa1f5fc7c916 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-06T00:39:32.278Z sha 4477aec80a4c72f96620dd4564efc3bac7eddec8 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-06T01:03:39.587Z sha 4477aec80a4c72f96620dd4564efc3bac7eddec8 :: needs real behavior proof before merge. :: [P2] Sanitize custom replies after the message-sending rewrite
  • reviewed 2026-10-08T02:29:46.170Z sha 13888901b7479dbd658870439609b60556241a30 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-09T08:28:20.091Z sha 13888901b7479dbd658870439609b60556241a30 :: needs real behavior proof before merge. :: [P1] [P1] Preserve table preparation for durable final replies
  • reviewed 2026-10-09T09:33:02.283Z sha 41e305a4a4f4fd73973bac5858b07766db1791f9 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-15T13:10:59.655Z sha 41e305a4a4f4fd73973bac5858b07766db1791f9 :: needs real behavior proof before merge. :: none

Reviewed November 3, 2026, 11:41 PM ET / November 4, 2026, 04:41 UTC (Revision 33).

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 7, 2026
@clawSean
clawSean force-pushed the fix/zalouser-sanitize-outbound-90684 branch from 4045447 to 1895376 Compare July 8, 2026 22:55
@clawSean

clawSean commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Contributor proof-assist request: I do not currently have access to a credentialed Zalo Personal / QR-login test account, so I cannot produce the final live-channel proof myself yet. The code path is covered by focused tests and the pre-PR gate, but this PR still needs redacted real behavior proof from someone with Zalo Personal access.

Because this path uses unofficial personal-account automation, please use a safe test or disposable Zalo account if possible, not an account you cannot risk.

What would clear the proof gap:

  1. Check out this PR branch (clawSean:fix/zalouser-sanitize-outbound-90684) or otherwise run the PR head against a safe Zalo Personal account and test thread.
  2. Send an outbound Zalo Personal message containing a harmless synthetic compact tool-trace failure line shaped like the internal trace/banner ClawSweeper called out.
    • Expected: the internal trace/banner text is stripped before delivery.
  3. Send ordinary user-facing prose, preferably including a small markdown/plain-text case.
    • Expected: normal text still delivers unchanged.
  4. Optional but useful: include media-caption proof if that harness is already available.

A redacted screenshot, transcript, terminal log, or short recording is enough. Please redact cookies/session data, phone numbers, user IDs, endpoints, private chat names, and any message content not needed for the proof.

If someone can provide that evidence, I can update the PR body and request ClawSweeper re-review.

@clawSean
clawSean force-pushed the fix/zalouser-sanitize-outbound-90684 branch from 1895376 to 9694fcd Compare July 20, 2026 22:59
@clawSean

Copy link
Copy Markdown
Contributor Author

Updated and rebased at exact head 9694fcd7187bc71ab44b60d9cf3af1825dccd73c on upstream main e07de4c56159fb90e811482b34ff466438c3cf54.

The patch now covers both the standard outbound adapter and Zalouser's custom inbound reply pipeline. Exact-head proof is documented in the PR body: 347 focused/shared tests pass, including mixed text/media preservation, trace-only suppression, fenced-example preservation, and low-level raw-send preservation.

Proof boundary remains explicit: this is adapter/runtime-boundary proof, not a credentialed live Zalo Personal round trip.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawSean
clawSean force-pushed the fix/zalouser-sanitize-outbound-90684 branch from 9694fcd to 676fd73 Compare July 20, 2026 23:01
@clawSean

Copy link
Copy Markdown
Contributor Author

Final freshness update: rebased conflict-free at head 676fd73da348fdd849e40551d3935d789718822e on upstream main b628882d0b0932b9cf132e51d38f7b2ef847c85a.

The patch covers both the standard outbound adapter and Zalouser's custom inbound reply pipeline. Proof is documented in the PR body: 347 focused/shared tests passed on the identical two-commit patch immediately before this final conflict-free rebase, including mixed text/media preservation, trace-only suppression, fenced-example preservation, and low-level raw-send preservation. CI is validating the final head.

Proof boundary remains explicit: this is adapter/runtime-boundary proof, not a credentialed live Zalo Personal round trip.

@clawsweeper re-review

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jul 21, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 2, 2026
@clawSean
clawSean force-pushed the fix/zalouser-sanitize-outbound-90684 branch from 676fd73 to 8c6a155 Compare August 9, 2026 22:36
@clawSean

clawSean commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawSean
clawSean force-pushed the fix/zalouser-sanitize-outbound-90684 branch from 8c6a155 to 08e489d Compare August 9, 2026 22:51
@clawSean

clawSean commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Oct 6, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Oct 6, 2026
@clawSean
clawSean force-pushed the fix/zalouser-sanitize-outbound-90684 branch from 4477aec to 1388890 Compare October 8, 2026 02:22
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Oct 8, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Oct 8, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Oct 8, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Oct 9, 2026
@clawSean
clawSean force-pushed the fix/zalouser-sanitize-outbound-90684 branch from 1388890 to 41e305a Compare October 9, 2026 09:24
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Oct 9, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Oct 10, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Oct 10, 2026
@clawSean

Copy link
Copy Markdown
Contributor Author

@fuller-stack-dev — Barnacle is now repeatedly marking this assigned PR stale under the 27-day creation-age rule, which ignores substantive updates. The current exact head is code-clean (ClawSweeper Revision 31: zero findings); the only remaining blocker is authenticated recipient proof that requires a safe Zalo Personal account. Could you please apply no-stale while that proof is coordinated, or unassign it if the assigned-PR lane is no longer intended? I will not churn the branch merely to create activity.

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Oct 13, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Oct 13, 2026
@clawsweeper clawsweeper Bot removed the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Oct 15, 2026
@clawSean

Copy link
Copy Markdown
Contributor Author

Substantive maintenance update (no unverified push):

  • rebased the candidate once onto frozen main a0ffdb1b8dbf
  • resolved the current monitor conflicts while preserving upstream flow and the final hook-rewritten-payload sanitization
  • signed local candidate: 436a2341ff586ff7267071552f79411518d51d13; git diff --check is clean; focused reply-helper tests pass 2/2
  • the canonical group-gating shard and mandatory wrapper stop before collection on the same stale dependency graph, so I did not publish the head

Because this PR is assigned, contributor activity does not reset its 27-day clock. @fuller-stack-dev, could you please either remove the assignment or apply no-stale while authenticated recipient proof remains pending? That is the policy-valid action needed to keep it open. No re-review is requested until the current exact head can be published and proved.

@clawSean

Copy link
Copy Markdown
Contributor Author

Fresh current-main maintenance status:

  • Current main 3df26eebaf4f and merged standard Zalo work still leave the custom-monitor payload sanitizer gap distinct.
  • The preserved signed candidate 7c0bc82b6c4968dc37d4b6b8be74a243126ff644 has a clean one-commit shape; a fresh merge-tree audit narrows current-main integration to one conflict in the owning monitor.
  • Existing authenticated recipient-visible proof remains externally blocked, so I am not claiming that proof or sending to a private recipient.

I am reconciling the current monitor owner and exact dependency graph before any guarded branch update. No duplicate review request or unverified push was made.

@clawSean

clawSean commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The durable body now matches exact current head b012137ca6889eab50e9474c9d34497b2e4752e3 and records the complete exact-head 221/221 Zalouser, branch-ratchet, independent-review, and 36-check hosted packet. Recipient-visible proof remains explicitly blocked on a consented Zalo Personal recipient; no private recipient was used. Please reassess whether the executed exact-head evidence clears the contributor proof gate, with any live-recipient requirement left as external debt.

@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: zalouser Channel integration: zalouser P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants