Skip to content

fix(agents): keep truncation surrogate-safe#102332

Merged
steipete merged 2 commits into
openclaw:mainfrom
QiuYuang:fix/utf16-safe-truncation-siblings
Jul 9, 2026
Merged

fix(agents): keep truncation surrogate-safe#102332
steipete merged 2 commits into
openclaw:mainfrom
QiuYuang:fix/utf16-safe-truncation-siblings

Conversation

@QiuYuang

@QiuYuang QiuYuang commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Agent-facing background-process labels are capped at 140 UTF-16 code units. Their outer formatter used raw slicing before the ... suffix and could retain a lone high surrogate when a long command verb crossed the cut.

Why This Change Was Made

The existing outer label formatter now uses the canonical truncateUtf16Safe helper. Process execution, registry state, scope isolation, command parsing, and the 140-unit policy are unchanged.

The maintainer fixup also corrected the regression proof. The original emoji argument was shortened by deriveSessionName before the outer cap, so it never exercised the changed code; another test asserted only that an unscoped session stayed absent. The replacement uses a long single-token command that crosses the actual 137-unit cut and asserts the exact final label. Unrelated tests for already-safe web-fetch behavior were removed.

User Impact

Reconnectable background-process metadata remains valid UTF-16 when a compact label boundary crosses an emoji or another astral character.

Evidence

  • Exact production-boundary assertion through listActiveProcessSessionReferences.
  • Targeted oxfmt and git diff --check: pass.
  • Fresh maintainer local-diff autoreview: clean, confidence 0.98.
  • Fresh full-branch autoreview: clean, confidence 0.99.
  • Exact-head CI run 28991774236, OpenGrep run 28991774230, CodeQL Critical Quality run 28991774226, and CodeQL run 28991774348 on cecd014b51357df49dd6f760b6870dd67bc0252d: success.

AI-assisted: yes. Maintainer-reviewed and tightened.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S 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 8, 2026, 11:30 PM ET / 03:30 UTC.

Summary
The PR changes active bash process reference label truncation to use UTF-16-safe slicing and adds a focused surrogate-boundary regression test.

PR surface: Source +1, Tests +25. Total +26 across 2 files.

Reproducibility: yes. from source inspection: current main’s active process label helper slices raw UTF-16 strings at the 140-character boundary. The PR test constructs a label where that boundary bisects an emoji, but I did not run a product repro in this read-only review.

Review metrics: none identified.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
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 runtime proof from an actual background bash session label or agent-context run.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body includes terminal output from focused Vitest tests, but no real background bash session or agent-context runtime transcript; the contributor should add redacted live output, logs, or a terminal screenshot and update the PR body.

Risk before merge

  • [P1] External PR proof is still limited to focused Vitest output rather than a real background bash session or agent-context runtime transcript.
  • [P1] The PR is mergeable but behind the current base, so exact-head checks and review should refresh before landing.

Maintainer options:

  1. Decide the mitigation before merge
    Land the narrow helper reuse after the contributor adds redacted real runtime proof showing an actual active background bash session label or agent-context output remains UTF-16 well-formed.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] Contributor-visible real behavior proof is still required, and automation should not queue a repair because it cannot supply proof from the contributor's real setup.

Security
Cleared: The diff reuses an existing internal normalization helper and adds a focused test, with no dependency, CI, package, permission, secret, or network-execution surface change.

Review details

Best possible solution:

Land the narrow helper reuse after the contributor adds redacted real runtime proof showing an actual active background bash session label or agent-context output remains UTF-16 well-formed.

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

Yes from source inspection: current main’s active process label helper slices raw UTF-16 strings at the 140-character boundary. The PR test constructs a label where that boundary bisects an emoji, but I did not run a product repro in this read-only review.

Is this the best way to solve the issue?

Yes for the production code: reusing the existing UTF-16-safe helper at the outer label cap is the narrowest maintainable fix. The remaining blocker is real behavior proof from a real setup, not a different code shape.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1252a3da59a8.

Label changes

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.

Label justifications:

  • P2: This is a normal-priority user-visible agent text correctness fix with limited blast radius and no config, migration, or security surface change.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish 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: The PR body includes terminal output from focused Vitest tests, but no real background bash session or agent-context runtime transcript; the contributor should add redacted live output, logs, or a terminal screenshot and update the PR body.
Evidence reviewed

PR surface:

Source +1, Tests +25. Total +26 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 2 +1
Tests 1 25 0 +25
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 28 2 +26

What I checked:

Likely related people:

  • vincentkoc: Blame and PR metadata tie both the current bash-process-references.ts helper and the shared UTF-16-safe helper to recent merged work in commit fc4626c1221d from refactor(zalo): localize internal declarations #102065. (role: recent area contributor; confidence: high; commits: fc4626c1221d, 84e5327720b4; files: src/agents/bash-process-references.ts, packages/normalization-core/src/utf16-slice.ts, src/utils.ts)
  • pgondhi987: Recent merged work changed the adjacent web-fetch-utils surface that earlier revisions of this PR touched and that the PR body still mentions. (role: recent adjacent contributor; confidence: medium; commits: 64015e71dd5a; files: src/agents/tools/web-fetch-utils.ts, src/agents/tools/web-fetch-utils.test.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 (2 earlier review cycles)
  • reviewed 2026-07-09T01:26:00.028Z sha cec3a49 :: needs real behavior proof before merge. :: [P3] Exercise the changed truncation helper
  • reviewed 2026-07-09T01:32:29.115Z sha cec3a49 :: needs real behavior proof before merge. :: [P3] Exercise the changed truncation helper

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 9, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 9, 2026
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Maintainer verification complete on exact head cecd014b51357df49dd6f760b6870dd67bc0252d.

  • Replaced two ineffective tests with one exact regression through the real outer process-label boundary.
  • Removed unrelated web-fetch test churn for behavior already safe on main.
  • Fresh local-diff autoreview: clean, confidence 0.98.
  • Fresh full-branch autoreview: clean, confidence 0.99.
  • CI run 28991774236, OpenGrep run 28991774230, CodeQL Critical Quality run 28991774226, and CodeQL run 28991774348: success.

The change is limited to agent-facing background-process metadata; execution, registry state, and scope isolation are unchanged.

@steipete
steipete merged commit b62c796 into openclaw:main Jul 9, 2026
129 of 133 checks passed
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

nicknmorty added a commit to nicknmorty/openclaw that referenced this pull request Jul 9, 2026
After merging main, upstream openclaw#102332 added a test asserting surrogate-safe END truncation for active-process session labels. This branch had incidentally switched name truncation to truncateMiddle when the local truncate() helper was removed. Restore the surrogate-safe end-truncation helper (truncateUtf16Safe) for the redacted label so it truncates at the end like upstream, while keeping all redaction. Fixes the checks-node-compact-large-whole-1 shard failure; upstream test passes unmodified.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 9, 2026
* fix(agents): keep truncation surrogate-safe

* test(agents): tighten process label truncation coverage

---------

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

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants