Skip to content

fix(queue-helpers): use truncateUtf16Safe for queue overflow summary truncation#102721

Closed
zhangqueping wants to merge 1 commit into
openclaw:mainfrom
zhangqueping:fix/utf16-safe-queue-helpers
Closed

fix(queue-helpers): use truncateUtf16Safe for queue overflow summary truncation#102721
zhangqueping wants to merge 1 commit into
openclaw:mainfrom
zhangqueping:fix/utf16-safe-queue-helpers

Conversation

@zhangqueping

Copy link
Copy Markdown
Contributor

What Problem This Solves

The queue overflow summary helper uses a raw UTF-16 code-unit slice to truncate dropped item text. When the truncation boundary falls between an emoji's surrogate halves, the summary text contains an unpaired surrogate.

Why This Change Was Made

Replace .slice(0, limit-1) with truncateUtf16Safe in summarizeDroppedItem. The existing limit, trimming, and ellipsis suffix remain unchanged.

Files Changed

File Change
src/utils/queue-helpers.ts Replace raw .slice(0,N) with truncateUtf16Safe in summarizeDroppedItem.

🤖 Generated with Claude Code

…truncation

Replace raw UTF-16 slice in summarizeDroppedItem with truncateUtf16Safe
to prevent surrogate pair splitting in queue overflow summary text.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
@openclaw-barnacle openclaw-barnacle Bot added size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 9, 2026
@clawsweeper

clawsweeper Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 7:41 AM ET / 11:41 UTC.

Summary
The PR imports truncateUtf16Safe and uses it instead of raw slice when eliding queue overflow summary text.

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

Reproducibility: yes. by source inspection: current main slices queue summary text at an arbitrary UTF-16 code-unit boundary, and follow-up queue overflow summaries can be built from dropped user prompt text. I did not run a live reproduction in this read-only cleanup review.

Review metrics: none identified.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof 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 terminal output, logs, or a short live transcript showing before/after queue overflow summary text at an emoji surrogate boundary.
  • [P1] Add a focused regression test in src/utils/queue-helpers.test.ts for surrogate-safe overflow summary truncation.

Proof guidance:

  • [P1] Needs real behavior proof before merge: No after-fix real behavior proof is present in the PR body or comments; the contributor should add redacted terminal output, logs, screenshot, recording, or live transcript proof and update the PR body so ClawSweeper re-reviews, or ask a maintainer to comment @clawsweeper re-review.

Risk before merge

  • [P1] The contributor has not provided after-fix real behavior proof, so the external PR still needs contributor proof or maintainer validation before merge.
  • [P1] The queue-helper tests cover summary rendering but do not yet assert the emoji-boundary overflow summary case directly.

Maintainer options:

  1. Decide the mitigation before merge
    Keep the narrow helper-level change, add redacted real behavior proof for an emoji-boundary overflow summary, and preferably add a focused queue-helper regression test before merge.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] Contributor-supplied proof or maintainer validation is the remaining blocker; ClawSweeper should not queue a repair because automation cannot prove the contributor's setup for them.

Security
Cleared: The diff imports an existing in-repo normalization helper and changes only internal string truncation; no concrete security or supply-chain concern was found.

Review details

Best possible solution:

Keep the narrow helper-level change, add redacted real behavior proof for an emoji-boundary overflow summary, and preferably add a focused queue-helper regression test before merge.

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

Yes by source inspection: current main slices queue summary text at an arbitrary UTF-16 code-unit boundary, and follow-up queue overflow summaries can be built from dropped user prompt text. I did not run a live reproduction in this read-only cleanup review.

Is this the best way to solve the issue?

Yes, this is the best fix shape: reuse the existing surrogate-safe normalization helper at the shared queue-summary truncation point. Local surrogate logic or per-caller fixes would duplicate an existing contract and increase drift risk.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6621ead871a9.

Label changes

Label justifications:

  • P3: This is a narrow internal queue-summary text correctness fix with limited blast radius and no evidence of urgent user-facing breakage.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; 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. Needs real behavior proof before merge: No after-fix real behavior proof is present in the PR body or comments; the contributor should add redacted terminal output, logs, screenshot, recording, or live transcript proof and update the PR body so ClawSweeper re-reviews, or ask a maintainer to comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +2. Total +2 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 3 1 +2
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 3 1 +2

What I checked:

  • Root policy read: Root AGENTS.md was read fully and its OpenClaw PR review guidance applied; no scoped AGENTS.md exists for src/utils. (AGENTS.md:1, 6621ead871a9)
  • No maintainer notes: No .agents/maintainer-notes files were present for this touched surface.
  • Current main behavior: Current main still elides queue summary text with text.slice(0, Math.max(0, limit - 1)), which can cut a surrogate pair at the boundary. (src/utils/queue-helpers.ts:78, 6621ead871a9)
  • PR diff: The PR changes one source file by importing truncateUtf16Safe and replacing the raw slice at the shared queue summary truncation point. (src/utils/queue-helpers.ts:77, 14ba5fa30858)
  • Queue caller path: Follow-up enqueue passes dropped prompt or summary text into applyQueueDropPolicy, which appends bounded summary lines through buildQueueSummaryLine. (src/auto-reply/reply/queue/enqueue.ts:133, 6621ead871a9)
  • Queue summary rendering path: Follow-up drain renders stored summary lines into the synthetic overflow prompt through previewQueueSummaryPrompt. (src/auto-reply/reply/queue/drain.ts:548, 6621ead871a9)

Likely related people:

  • steipete: Git history shows Peter Steinberger introduced src/utils/queue-helpers.ts, added the current shared summary helpers/tests, and carried later queue-helper refactors. (role: introduced behavior and recent area contributor; confidence: high; commits: c7ae5100fae4, 1aa4d3a6f0d6, dacb3d1aa2c6; files: src/utils/queue-helpers.ts, src/utils/queue-helpers.test.ts, src/auto-reply/reply/queue/enqueue.ts)
  • adam91holt: The initial shared queue helper commit includes adam91holt as co-author, making them an adjacent routing signal for the helper's original extraction. (role: co-author on initial queue helper extraction; confidence: medium; commits: c7ae5100fae4; files: src/utils/queue-helpers.ts)
  • lsr911: The merged related PR fix(active-memory): use truncateUtf16Safe for log value truncation #102551 fixed the same raw-slice UTF-16 issue class in Active Memory using truncateUtf16Safe. (role: adjacent UTF-16 truncation contributor; confidence: medium; commits: e39e628a8416; files: extensions/active-memory/index.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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-09T11:30:49.527Z sha 14ba5fa :: needs real behavior proof before merge. :: none

@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. 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

Thanks @zhangqueping. #102823 landed the same UTF-16-safe queue-overflow preview cap in 5ef269c, including exact-output regression coverage. This branch is fully superseded, so I’m closing it.

@steipete steipete closed this Jul 9, 2026
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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants