GeezerVison is showing github.com — aggregator(actions): cleanText caps can split a surrogate pair — a stored action field ends in a lone surrogate · Issue #7694 · developing-today/code
aggregator(actions): cleanText caps can split a surrogate pair — a stored action field ends in a lone surrogate #7694Descriptionaggregator(actions): cleanText caps can split a surrogate pair — a stored action field ends in a lone surrogate
Evidence (verified this run, main 8a0a1c0cea)
pm-stack/aggregator/src/actions.ts:289-292 — every user-supplied payload field of a dashboard action passes through:
function cleanText(v: unknown, max: number): string | undefined {
if (typeof v !== "string") return undefined;
const t = v.trim();
return t === "" ? undefined : t.slice(0, max);
}
slice(0, max) counts UTF-16 code units. When an astral character (e.g. an emoji, 2 code units) straddles the cap, the stored value ends in a lone high surrogate. Call sites with caps: reason 2,000 (actions.ts:336), text 20,000 (:334), answer values 2,000 (:376), optionId/questionId 200 (:349/:351/:363/:370), status 60, until 64, and others (:321–:450). These values are persisted in the actions store (one JSON file, PM_AGG_ACTIONS_FILE) and consumed/rendered by the orchestration pass.
Probe (laptop ~/git/fleet/probe-actions-surrogate/probe.ts, real actions.ts imported from the laptop primary, validateNewAction with verb dismiss):
- Input
reason = "x" × 1999 + "😀" + "tail" (2,001+ code units) → validated ok: true; stored reason is exactly 2,000 code units and its last code unit is 0xd83d — a lone high surrogate.
JSON.stringify of the stored value ends …\ud83d" — the lone surrogate is carried into the persisted JSON.
- A UTF-8 encode/decode round-trip of the stored value differs from the original and ends in U+FFFD — any consumer that encodes the field to UTF-8 (file writes in other languages, GitHub bodies, Rust consumers, whose
serde_json rejects unpaired surrogates) silently corrupts or refuses the field.
- Control:
"x" × 1998 + "😀" (exactly 2,000 code units) is stored intact, length 2,000.
Why it matters
This is the exact defect class fixed for pm-dispatch in #3178 (validate.ts:319-328 keeps the cap but never leaves half a surrogate pair). The actions boundary was not given the same guard, so a dashboard user who pastes long text with an emoji at the cap boundary gets a silently corrupted reason/answer stored and delivered to consumers — and the corruption only surfaces downstream, far from the boundary that created it.
Acceptance criteria
cleanText (or an equivalent shared helper) never returns a string ending in a lone high surrogate or beginning-of-cap lone low surrogate: when the cap would split a surrogate pair, the pair is dropped whole (cap becomes max - 1 code units for that value), mirroring the pm-dispatch(validate): titleFromPrompt truncates by UTF-16 code units — an astral character at the cap leaves a lone surrogate in the title #3178 fix in pm-stack/dispatch/src/validate.ts.
- The cap semantics otherwise stay identical: same maximum code-unit lengths, same trim/empty behaviour, non-straddling values byte-for-byte unchanged.
- Regression tests in
pm-stack/aggregator/test/actions.test.ts (or a sibling suite run by the aggregator test workflow): an astral character straddling at least the reason (2,000) and one small cap (e.g. optionId 200) boundary is stored whole-or-dropped, never halved; the new tests fail on the pre-fix code.
- Existing aggregator test suite stays green.
Activitydeveloping-today commented on Nov 8, 2026 ContributorAuthor More actions 🤖 Agent note · state: filed
- Agent: new-issue-creator job (new-issue-creator-code-a)
- Session / ID: cron job new-issue-creator-code-a, run 2026-11-08 07:05 CST
- Found via: filed this run
- Task: cleanText caps in aggregator actions validation can split a surrogate pair, persisting a lone surrogate in a stored action field (probe: laptop ~/git/fleet/probe-actions-surrogate, real actions.ts @8a0a1c0cea). Self-assigned this run under lifecycle protocol §4 (trivial, clearly scoped, mirrors the pm-dispatch(validate): titleFromPrompt truncates by UTF-16 code units — an astral character at the cap leaves a lone surrogate in the title #3178 fix in pm-dispatch validate.ts): fixing + regression tests in the same run.
- Expectation: effort xs — done = fix PR merged, new tests fail pre-fix and pass post-fix, aggregator suite green.
- Links: probe ~/git/fleet/probe-actions-surrogate (laptop)
developing-today commented on Nov 8, 2026 ContributorAuthor More actions 🤖 Agent note · state: done
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|