Repository navigation
fix(skills): bound evaluator text without splitting surrogate pairs - #117673
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 6:56 PM ET / 22:56 UTC. ClawSweeper reviewWhat this changesThe PR makes Skill Workshop truncate evaluator summaries, errors, metrics, and related bounded fields without splitting UTF-16 surrogate pairs, with a regression test for emoji at each relevant boundary. Merge readinessKeep this PR open for merge review: current Priority: P2 Review scores
Verification
How this fits togetherSkill Workshop runs optional evaluator plugins against a proposed skill, normalizes their output, and stores the resulting evaluation in the proposal record and event log. Those stored results are subsequently returned to CLI, API, and UI consumers. flowchart LR
A[Evaluator plugin output] --> B[Skill Workshop evaluation]
B --> C[Bounded field normalization]
C --> D[Proposal record and event store]
D --> E[CLI, API, and UI readers]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +2, Tests +55. Total +57 across 2 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land this focused producer-boundary repair after the current merge head is validated, retaining Do we have a high-confidence way to reproduce the issue? Yes, from source: an evaluator can return 7,999 BMP code units followed by an emoji at the 8,000-unit summary cap, and current Is this the best way to solve the issue? Yes. Reusing AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against eb8c22ed13f9. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Maintainer verification for exact contributor head
Thanks @zenglingbiao for fixing the complete producer-owned invariant and adding focused regression coverage. |
|
Merged via squash.
|
Summary
Bound evaluator-produced text in the Skill Workshop evaluation pipeline with
truncateUtf16Safeinstead of UTF-16 code-unitslice, so emoji/CJK characters straddling a cap are no longer persisted to the proposal store as a lone surrogate (tofu).What Problem This Solves
src/skills/workshop/service-evaluation.tsnormalizes third-party evaluator output before persisting it. Four user-visible text paths are bounded by raw code-unit slicing:boundedRequired(service-evaluation.ts:355-357) — used for the evaluatorerrormessage (2000) and attribution ids.boundedOptional(service-evaluation.ts:360-361) — used forsummary(8000),decisionReason(2000),evaluatorVersion,mode, and findingfile.normalizeMetrics(service-evaluation.ts:350) — string metric values (value.slice(0, 4_000)).Any character outside the Basic Multilingual Plane (emoji, CJK ext-B) occupies two UTF-16 code units. When such a character straddles a cap,
slicekeeps only the leading high surrogate, and that lone surrogate is written into the durable proposal store (SQLite) — surfacing later as tofu/invalid glyphs wherever the evaluation summary, decision reason, error, or metric is displayed.Code evidence:
service-evaluation.ts:350,:356,:360bounded evaluator-controlled text withslice(0, n)on UTF-16 code units.Root Cause
14940edf15f("feat(skills): add Skill Workshop lifecycle hooks", 2026-07-29, feat(skills): add Skill Workshop lifecycle hooks #115606), which added the evaluation normalization helpers with code-unit slicing.slice(0, N); astral characters occupy two UTF-16 units, so the cut can persist half a character.Why This Fix
truncateUtf16Safefrom@openclaw/normalization-core/utf16-slice— the repo's established convention for this bug class (src/skills/lifecycle/install-output.ts,src/skills/loading/workspace.ts, ACP control plane, and fix(terminal): keep Unicode cron columns aligned #117062 all use it).length <= nunchanged; oversized input truncated tonunits) except a dangling surrogate at the cut is dropped instead of persisted.User Impact
"ssss…\uD83D"— a dangling high surrogate.Evidence
main, a real evaluator hook registered through the real global hook runner returns text with 🙂 straddling each cap; the record re-read from the real store endssummary/decisionReason/metrics.notewithU+D83D(lone high surrogate) → FAIL.U+0073/U+0072/U+006D) → PASS.Real Behavior Proof
The proof registers a real
skill_proposal_evaluatehook through the realinitializeGlobalHookRunner(exactly the dispatch path a third-party evaluator plugin uses), then runs the realproposeCreateSkill→evaluateSkillProposalpipeline and re-reads the persisted record from the real SQLite store viainspectSkillProposal.Before (on main)
$ node --import tsx proof.mjs summary_units=8000 tail=U+73 U+d83d lone_surrogate=true decisionReason_units=2000 tail=U+72 U+d83d lone_surrogate=true metrics.note_units=4000 tail=U+6d U+d83d lone_surrogate=true FAIL: store persists evaluator text ending in a lone UTF-16 surrogate (tofu)After (with fix)
Tests and Validation
src/skills/workshop/service-evaluation.test.ts: a completed outcome (summary/decisionReason/metric with 🙂 straddling the 8000/2000/4000 caps) and an error outcome (error with 🙂 straddling the 2000 cap) must persist with each emoji dropped whole. The test fails onmainand passes with the fix; the other 20 tests are unchanged.node scripts/run-vitest.mjs src/skills/workshop/service-evaluation.test.ts— 21/21 tests passed.oxfmt --checkandoxlintclean on both changed files;git diff --checkclean.sliceremains in the evaluation normalization path. The sametruncateUtf16Safeconvention was applied to the beam mirror in a companion PR.