fix(tool-policy-audit): use truncateUtf16Safe for audit field truncation#102464
Conversation
Replace naive .slice(0, MAX) with truncateUtf16Safe() to prevent surrogate pair splitting in tool policy audit log output. Co-Authored-By: Claude <[email protected]>
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 2:48 AM ET / 06:48 UTC. Summary PR surface: Source +1. Total +1 across 1 file. Reproducibility: yes. Source inspection is enough to reproduce the current-main failure path: a sanitized audit field longer than 160 UTF-16 units with a surrogate pair crossing the cutoff can be raw-sliced into a dangling surrogate, though I did not run a live audit-log repro. Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Tool-policy audit fields should keep the existing bounds while using the shared surrogate-safe UTF-16 helper, with merge evidence showing a long emoji-containing field no longer emits a dangling surrogate. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection is enough to reproduce the current-main failure path: a sanitized audit field longer than 160 UTF-16 units with a surrogate pair crossing the cutoff can be raw-sliced into a dangling surrogate, though I did not run a live audit-log repro. Is this the best way to solve the issue? Yes. Replacing the one owner-local truncation boundary with the shared AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5f91f6c95840. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +1. Total +1 across 1 file. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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
|
|
Land-ready maintainer pass complete at exact head I kept the useful runtime fix, switched it to the direct normalization-core import, and added a production-path regression that verifies both the rendered audit message and structured metadata at a split surrogate boundary. Proof:
The focused test ran locally because fork-contributor code is not eligible for credential-hydrated Testbox execution before landing review. Exact-head fork CI supplies the broad hosted proof. No remaining proof gap. |
|
Merged via squash.
|
|
@clawsweeper re-review |
|
🦞🧹 Reason: re-review requires an open issue or PR. |
…ion (openclaw#102464) * fix(tool-policy-audit): use truncateUtf16Safe for audit field truncation Replace naive .slice(0, MAX) with truncateUtf16Safe() to prevent surrogate pair splitting in tool policy audit log output. Co-Authored-By: Claude <[email protected]> * test(agents): cover audit UTF-16 boundary --------- Co-authored-by: Claude <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
The tool policy audit logger uses naive
.slice(0, MAX_AUDIT_FIELD_LENGTH)to truncate field values. This can split surrogate pairs mid-character, producing garbled output in audit logs.Why This Change Was Made
Replace with
truncateUtf16Safe()which preserves surrogate pair boundaries.Evidence
Files Changed
src/agents/tool-policy-audit.ts.slice(0,N)→truncateUtf16Safe()🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]