Skip to content

fix(qa-matrix): keep room scenario preview truncation UTF-16 safe#102606

Merged
steipete merged 2 commits into
openclaw:mainfrom
Pandah97:fix/room-truncate-utf16
Jul 9, 2026
Merged

fix(qa-matrix): keep room scenario preview truncation UTF-16 safe#102606
steipete merged 2 commits into
openclaw:mainfrom
Pandah97:fix/room-truncate-utf16

Conversation

@Pandah97

@Pandah97 Pandah97 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Matrix QA stores bounded body and formatted-body previews in scenario artifacts and timeout diagnostics. Raw UTF-16 slicing could leave a dangling surrogate when an emoji crossed the 200- or 237-code-unit boundary, producing invalid evidence text.

Why This Change Was Made

Use the shared truncateUtf16Safe helper for every room-scenario preview boundary. A local artifact-preview helper keeps all 200-unit call sites consistent and preserves the prior distinction between an absent value and an empty string.

User Impact

QA Matrix evidence remains valid text around emoji boundaries. Transport behavior, Matrix events, final replies, limits, and configuration are unchanged.

Evidence

  • node ../../node_modules/vitest/vitest.mjs run --config test/vitest/vitest.extensions.config.ts extensions/qa-matrix/src/runners/contract/scenarios.test.ts — 74 passed
  • oxfmt on both changed files
  • focused oxlint on both changed files
  • git diff --check
  • fresh branch autoreview: clean, no actionable findings

Regression coverage asserts exact 200-unit body/formatted-body artifact output, preserves empty strings, and asserts the exact 237-unit timeout diagnostic line. No live Matrix run is needed because the change only formats already-observed evidence; event selection, network I/O, and delivery are untouched.

Risk

Low. This replaces unsafe presentation-only slices with the shared normalization helper and reduces production LOC. No API, config, dependency, or state change.

AI-assisted

Initial patch generated with Claude Code; maintainer review refactored the call sites and added public-path regression coverage.

Replace 7x `.slice(0, N)` with `truncateUtf16Safe(..., N)` in
runMatrixStreamingPreviewScenario and runMatrixToolProgressScenario
to prevent surrogate pair corruption in body/formattedBody previews.

Ref. lsr911 pattern — mechanical substitution, no behavior change.
@clawsweeper

clawsweeper Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 5:37 AM ET / 09:37 UTC.

Summary
The branch replaces seven QA Matrix room scenario preview .slice truncations with the existing truncateUtf16Safe plugin SDK helper.

PR surface: Source +13. Total +13 across 1 file.

Reproducibility: yes. by source inspection: current main slices Matrix preview body/formattedBody artifacts with .slice(0, 200) and the candidate-preview helper with .slice(0, 237), which can split a surrogate pair when the limit lands between its UTF-16 code units. I did not run a Matrix QA scenario in this read-only review.

Review metrics: none identified.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦐 gold shrimp
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted real behavior proof for the Matrix QA room scenario path, such as terminal output or logs from a focused run showing an emoji-boundary preview artifact after the fix.
  • [P1] Preserve empty-string body and formattedBody values with nullish checks, and add focused coverage if practical.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body provides typecheck/helper-test evidence but no after-fix Matrix QA scenario run, artifact transcript, logs, or live output for this room scenario path. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] Contributor real-behavior proof is mock-only, so merge should wait for a redacted Matrix QA scenario run, artifact/log transcript, or maintainer proof override showing the after-fix room scenario preview path.

Maintainer options:

  1. Decide the mitigation before merge
    Use truncateUtf16Safe at the room preview truncation sites while preserving existing undefined-vs-empty-string artifact semantics, then add real behavior proof for the Matrix QA room scenario path.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] This external PR needs contributor real behavior proof and a small author-side semantic fix; ClawSweeper should not queue repair because automation cannot supply the contributor's after-fix setup proof.

Security
Cleared: The diff only imports and calls an existing plugin SDK text helper in a QA harness file; no security or supply-chain concern was found.

Review findings

  • [P3] Preserve blank preview strings — extensions/qa-matrix/src/runners/contract/scenario-runtime-room.ts:351-356
Review details

Best possible solution:

Use truncateUtf16Safe at the room preview truncation sites while preserving existing undefined-vs-empty-string artifact semantics, then add real behavior proof for the Matrix QA room scenario path.

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

Yes by source inspection: current main slices Matrix preview body/formattedBody artifacts with .slice(0, 200) and the candidate-preview helper with .slice(0, 237), which can split a surrogate pair when the limit lands between its UTF-16 code units. I did not run a Matrix QA scenario in this read-only review.

Is this the best way to solve the issue?

Yes for the main fix shape: reusing the existing plugin SDK truncateUtf16Safe helper at the local truncation sites is the narrow maintainable solution. The submitted patch should still preserve blank string values and needs real behavior proof before merge.

Full review comments:

  • [P3] Preserve blank preview strings — extensions/qa-matrix/src/runners/contract/scenario-runtime-room.ts:351-356
    The optional chaining this replaces returned "" when Matrix supplied an empty body or formattedBody, but these truthy checks now return undefined, so the artifact field silently disappears for a real blank string. Use an explicit nullish/undefined check before calling truncateUtf16Safe at the preview artifact sites.
    Confidence: 0.86

Overall correctness: patch is correct
Overall confidence: 0.87

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4cc92009ed90.

Label changes

Label changes:

  • add P3: This is a small QA harness text-truncation correctness fix with limited blast radius and no config, protocol, data, availability, or security surface change.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body provides typecheck/helper-test evidence but no after-fix Matrix QA scenario run, artifact transcript, logs, or live output for this room scenario path. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P3: This is a small QA harness text-truncation correctness fix with limited blast radius and no config, protocol, data, availability, or security surface change.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body provides typecheck/helper-test evidence but no after-fix Matrix QA scenario run, artifact transcript, logs, or live output for this room scenario path. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +13. Total +13 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 20 7 +13
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 20 7 +13

What I checked:

Likely related people:

  • vincentkoc: Live GitHub history shows repeated recent changes to Matrix room tool-progress and mention-preview behavior in scenario-runtime-room.ts, including final command preview edits and Matrix tool-progress hardening. (role: recent area contributor; confidence: high; commits: 4d7d34e6a5f8, ac973a8f6053, b8cf83aeb3b5; files: extensions/qa-matrix/src/runners/contract/scenario-runtime-room.ts)
  • RomneyDa: Recent live GitHub history shows this contributor migrated channel routing/thread scenarios touching the QA Matrix room scenario runtime and adjacent tests shortly before this PR. (role: recent QA Matrix refactor contributor; confidence: medium; commits: 253b784468c6, c1b9e3622162, 627f6988a07d; files: extensions/qa-matrix/src/runners/contract/scenario-runtime-room.ts, extensions/qa-matrix/src/runners/contract/scenarios.test.ts)
  • steipete: History shows recent QA Matrix commits and the merged analogous truncateUtf16Safe cleanup proof path in fix(compaction): use truncateUtf16Safe for post-compaction context text #102515, which is relevant to reviewing this helper substitution pattern. (role: adjacent helper and QA maintainer-history contributor; confidence: medium; commits: 96e581242605, aed7de306e22, b22c36f1125c; files: extensions/qa-matrix/src/runners/contract/scenario-runtime-room.ts, extensions/qa-matrix/src/runners/contract/scenarios.test.ts, packages/normalization-core/src/utf16-slice.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 9, 2026
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Land-ready review complete on exact head a011ebfbd68fa41757020c35757c73722be800ff.

  • Improved the contributor patch so all six 200-unit Matrix QA artifact previews share one UTF-16-safe helper and still preserve "" versus undefined.
  • Kept the 237-unit timeout diagnostic on the same shared UTF-16-safe primitive.
  • Added exact public-path assertions for message body, formatted body, empty-string preservation, and the timeout diagnostic boundary.
  • Focused proof: node ../../node_modules/vitest/vitest.mjs run --config test/vitest/vitest.extensions.config.ts extensions/qa-matrix/src/runners/contract/scenarios.test.ts (74 passed).
  • Static proof: focused oxfmt, oxlint, git diff --check; fresh autoreview clean.
  • Native prepare gate: exact-head hosted CI/Testbox passed; remote PR head tree matches the prepared tree.

No docs or changelog entry is required because this only changes private QA evidence formatting.

@steipete
steipete merged commit 5ba981a into openclaw:main Jul 9, 2026
99 of 105 checks passed
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 10, 2026
…enclaw#102606)

* fix(qa-matrix): keep room scenario preview truncation UTF-16 safe

Replace 7x `.slice(0, N)` with `truncateUtf16Safe(..., N)` in
runMatrixStreamingPreviewScenario and runMatrixToolProgressScenario
to prevent surrogate pair corruption in body/formattedBody previews.

Ref. lsr911 pattern — mechanical substitution, no behavior change.

* test(qa-matrix): prove UTF-16 artifact boundaries

Co-authored-by: 黄剑雄0668001315 <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S 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