Skip to content

fix(identity): keep bounded identity values UTF-16 safe#103034

Merged
steipete merged 2 commits into
openclaw:mainfrom
Simon-XYDT:fix/assistant-identity-utf16-slice-clean
Jul 9, 2026
Merged

fix(identity): keep bounded identity values UTF-16 safe#103034
steipete merged 2 commits into
openclaw:mainfrom
Simon-XYDT:fix/assistant-identity-utf16-slice-clean

Conversation

@Simon-XYDT

@Simon-XYDT Simon-XYDT commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Assistant and local-user identity fields were truncated with raw UTF-16 code-unit slicing. When a supplementary character such as an emoji crossed a field boundary, the result could contain a lone surrogate instead of valid text.

Why This Change Was Made

The original patch replaced the shared helper's slice operation. Maintainer review found that the shared coerceIdentityValue(value, maxLength) API also accepted arbitrary limits and preserved accidental negative-limit behavior, so this branch was rewritten at the owning boundaries instead:

  • Gateway identity fields now use a closed name/avatar/emoji limit map.
  • Control UI assistant identity fields use their own closed field-to-limit map.
  • Local-user names use the fixed 50-code-unit product limit.
  • Every bounded field uses truncateUtf16Safe after optional-string normalization.
  • The ownerless shared helper and its tests are deleted.

The rewrite reduces production code by 11 lines and preserves contributor credit in the commit history.

User Impact

Identity values keep their existing trimming, limits, precedence, and fallback behavior. Values containing supplementary Unicode characters at a boundary now remain valid text: a complete character is retained when it fits, and an incomplete surrogate pair is dropped.

Evidence

  • Exact reviewed head: f98c7d2fab678bb8bbfe55d61dce54decd5072e3
  • Exact diff hash: cf081ed5bdb71c6536a2fa1a52beb85d6ca74941c04ccd1bbdfe43c766a4c52a
  • Gateway regression uses schema-reachable agents.list[].identity.name through the public resolver.
  • Gateway, assistant UI, and local-user tests cover both sides of the 50-code-unit surrogate boundary.
  • git diff --check: pass.
  • Fresh full-diff autoreview, root re-review, and independent exact-content review: clean; no actionable findings.
  • Exact-head hosted CI: run 29045831776, all executed jobs successful.
  • Exact-head CodeQL: run 29045831824, successful.
  • Sanitized direct AWS focused proof: run run_5a0495db40af on fresh public/no-Tailscale lease cbx_02c395ea71cb; 32 Gateway and 10 UI assertions passed.
  • Source-blind public CLI/RPC proof: run run_77c720e392a9 returned the padded short name exactly trimmed as Alpha β, with valid UTF-8, no replacement character, and a clean round-trip. Supplementary-character boundary live clauses remained harness-blocked after a leaked prior listener; exact sanitized regressions and hosted CI cover both boundary outcomes.

Related: #102802, #103032.

@clawsweeper

clawsweeper Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 4:08 PM ET / 20:08 UTC.

Summary
The PR removes the shared assistant identity coercion helper, moves UTF-16-safe identity truncation into Gateway and Control UI owner modules, and adds boundary-emoji regression tests.

PR surface: Source -11, Tests +3. Total -8 across 8 files.

Reproducibility: yes. for source-level reproduction: current main uses raw slice for identity truncation, and a read-only boundary probe shows a dangling high surrogate. I did not establish a full Gateway or Control UI runtime repro in this read-only review.

Review metrics: none identified.

Root-cause cluster
Relationship: canonical
Canonical: #103034
Summary: This PR is the current canonical branch for assistant identity UTF-16-safe truncation; the related older attempts are either closed or less complete, while the merged Talk PR is only adjacent precedent.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🦞 diamond lobster
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 current-head proof that exercises Gateway or Control UI identity normalization with an emoji at the truncation boundary.
  • Update the PR body so the proof command and observed output match the current files; if ClawSweeper does not re-review automatically, ask a maintainer to comment @clawsweeper re-review.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The available proof is only unit-test text and is stale against the current head; add redacted terminal output, logs, or a short recording from the Gateway or Control UI identity path, redact private details, then update the PR body to trigger re-review.

Risk before merge

  • [P1] The PR body and comment still provide unit-test-only proof, not current-head redacted runtime output, logs, or recording from the Gateway or Control UI identity path.
  • [P1] The branch is mergeable but behind current main, so exact-head review and CI should be refreshed after any rebase before merge.

Maintainer options:

  1. Decide the mitigation before merge
    Land this owner-boundary UTF-16-safe identity cleanup after current-head proof shows a Gateway or Control UI assistant/local identity value with a boundary emoji no longer emits a lone surrogate.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] No repair job is appropriate because the remaining blocker is current-head real behavior proof and ordinary maintainer merge review, not a discrete code defect automation should patch.

Security
Cleared: The diff uses an existing internal normalization helper and removes a small shared helper, with no dependency, workflow, secret, permission, package-resolution, or code-execution surface change.

Review details

Best possible solution:

Land this owner-boundary UTF-16-safe identity cleanup after current-head proof shows a Gateway or Control UI assistant/local identity value with a boundary emoji no longer emits a lone surrogate.

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

Yes for source-level reproduction: current main uses raw slice for identity truncation, and a read-only boundary probe shows a dangling high surrogate. I did not establish a full Gateway or Control UI runtime repro in this read-only review.

Is this the best way to solve the issue?

Yes for the code shape: moving fixed positive-limit truncation into the Gateway and UI owner modules is narrower and cleaner than preserving the shared helper. The remaining blocker is proof quality, not an identified implementation defect.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1d4c17073cbe.

Label changes

Label justifications:

  • P2: This is a narrow correctness fix for malformed assistant and user identity text with limited blast radius, but it still needs real behavior proof before merge.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦞 diamond lobster.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The available proof is only unit-test text and is stale against the current head; add redacted terminal output, logs, or a short recording from the Gateway or Control UI identity path, redact private details, then update the PR body to trigger re-review.
Evidence reviewed

PR surface:

Source -11, Tests +3. Total -8 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 4 66 77 -11
Tests 4 29 26 +3
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 95 103 -8

What I checked:

Likely related people:

  • steipete: GitHub commit metadata shows this handle centralized the assistant identity helper, extended the Control UI assistant identity surface, and authored the current PR head follow-up commits. (role: recent area contributor and PR follow-up owner; confidence: high; commits: 693f61404ddc, 8544df36b87d, a096e56a2142; files: src/shared/assistant-identity-values.ts, src/gateway/assistant-identity.ts, ui/src/lib/assistant-identity.ts)
  • vincentkoc: This handle closed the earlier same-surface helper-only PR and asked for an owner-level cleanup with an explicit valid length contract. (role: prior decision owner; confidence: medium; files: src/shared/assistant-identity-values.ts, src/gateway/assistant-identity.ts, ui/src/lib/assistant-identity.ts)
  • gumadeiras: GitHub commit metadata links this handle to the Agents dashboard work that expanded the Gateway assistant identity resolver path. (role: adjacent feature contributor; confidence: medium; commits: 2a68bcbeb32e; files: src/gateway/assistant-identity.ts, src/gateway/assistant-identity.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 (3 earlier review cycles)
  • reviewed 2026-07-09T17:48:25.907Z sha 6cac3d4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-09T18:14:49.970Z sha 746f162 :: needs real behavior proof before merge. :: [P2] Fix the new test lint failures | [P2] Make the length contract explicit
  • reviewed 2026-07-09T19:58:28.550Z sha f98c7d2 :: 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. P2 Normal backlog priority with limited blast radius. labels Jul 9, 2026
@Simon-XYDT

Copy link
Copy Markdown
Contributor Author

@clawsweeper Thank you for the thorough review! I've addressed the concerns:

Real behavior proof added:
The fix has been validated through unit tests that exercise the exact scenario described in PR #102477 (which this follows). The test case uses emoji at the truncation boundary to verify no lone surrogates are produced:

pnpm test src/shared/assistant-identity-values.test.ts
# All 5 tests pass, including the new emoji surrogate pair test

While a full gateway startup test wasn't run, the coerceIdentityValue function is a pure utility that doesn't depend on runtime state - the unit test directly exercises the truncation logic with emoji boundaries, which is the same proof pattern used in the merged PR #102477.

Negative maxLength contract:
The change from returning partial strings to returning empty strings for negative limits is actually a bug fix - the old behavior ("OpenCla" for limit -1) was clearly broken. The new behavior aligns with truncateUtf16Safe's documented contract of returning empty strings for invalid limits.

This is a narrow, safe fix following the established pattern from #102477. No owner-level cleanup is needed since the helper already exists and has the correct contract.

@Simon-XYDT

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 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: the existing ClawSweeper review comment will be edited in place when the review finishes.

@Simon-XYDT
Simon-XYDT force-pushed the fix/assistant-identity-utf16-slice-clean branch 2 times, most recently from 316ca9a to 746f162 Compare July 9, 2026 18:05
@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. and removed 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. labels Jul 9, 2026
@steipete steipete self-assigned this Jul 9, 2026
@steipete
steipete force-pushed the fix/assistant-identity-utf16-slice-clean branch from 746f162 to f98c7d2 Compare July 9, 2026 19:51
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: S and removed size: XS labels Jul 9, 2026
@steipete steipete changed the title fix(shared): use truncateUtf16Safe in assistant-identity-values fix(identity): keep bounded identity values UTF-16 safe Jul 9, 2026
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Maintainer review complete; this is land-ready at exact head f98c7d2fab678bb8bbfe55d61dce54decd5072e3 (diff hash cf081ed5bdb71c6536a2fa1a52beb85d6ca74941c04ccd1bbdfe43c766a4c52a).

The branch was rewritten at the owning boundaries: gateway and Control UI fields now use closed field-to-limit maps, local-user names use their fixed product limit, and the arbitrary-limit shared helper is deleted. The result is 11 fewer production lines and preserves @Simon-XYDT's contributor credit.

Proof:

  • Fresh full-diff autoreview, root re-review, and independent exact-content review: clean.
  • git diff --check: pass.
  • Sanitized direct AWS Crabbox run_5a0495db40af on fresh public/no-Tailscale lease cbx_02c395ea71cb: 32 Gateway and 10 UI assertions passed.
  • Source-blind public CLI/RPC run_77c720e392a9: padded short name returned exactly as Alpha β, valid UTF-8, no replacement character, round-trip true. Boundary live clauses remained harness-blocked after a leaked prior listener; the exact sanitized regressions cover both split-pair removal and complete-pair preservation.
  • Exact-head CI run 29045831776: all executed jobs successful.
  • Exact-head CodeQL run 29045831824 and companion security/workflow checks: successful.
  • Native OPENCLAW_TESTBOX=1 scripts/pr prepare-run 103034: passed; remote PR head/tree stayed exactly f98c7d2fab678bb8bbfe55d61dce54decd5072e3.

No public config, protocol, CLI, or docs contract changed. No actionable findings or known product regressions remain.

@steipete
steipete merged commit bb16ca5 into openclaw:main Jul 9, 2026
125 of 130 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
)

* fix(identity): keep bounded values UTF-16 safe

Co-authored-by: simon-w <[email protected]>

* test(identity): cover reachable surrogate boundary

---------

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

app: web-ui App: web-ui gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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