Repository navigation
Description
aggregator(actions): markResult caps split surrogate pairs — appliedByRun/resultNote stored with a lone surrogate (residual of #7694)
Evidence (verified this run, main 83b7a024b8)
#7694 fixed cleanText in pm-stack/aggregator/src/actions.ts so its caps never split a surrogate pair. The action-result path in the same file was not given the same guard — it caps with raw slice:
pm-stack/aggregator/src/actions.ts:797-798 (ActionsStore.markResultTransition):
a.appliedByRun = result.byRun.slice(0, 200);
if (result.note) a.resultNote = result.note.slice(0, 2_000);Both values are stored on the action record and persisted by persist() into the actions store file — the same stored-field corruption class as #7694, reached through the result route (pm-stack/aggregator/src/server.ts:1236, POST /api/action-result) instead of validateNewAction. markResult (actions.ts:778) delegates to markResultTransition, so both entry points are affected.
Probe (laptop ~/git/fleet/probe-actions-result-surrogate/probe.ts, real actions.ts imported from the laptop primary at 83b7a024b8, md5 1485fa202f948031c9ea283fb8f25bfe; ActionsStore over a temp file):
byRun="r" × 199 + "😀" + "tail"→ storedappliedByRunis exactly 200 code units, last code unit0xd83d— a lone high surrogate. UTF-8 encode/decode round-trip differs and ends in U+FFFD.note="n" × 1999 + "😀" + "tail"→ storedresultNoteis exactly 2,000 code units, last code unit0xd83d— same lone surrogate, same U+FFFD round-trip corruption.- The persisted actions file literally contains the
\ud83descape. - Control:
note="n" × 1998 + "😀"(exactly 2,000 code units, pair fits) is stored intact, length 2,000.
Dedup: #7694 (closed, fixed by PR #7698) covers only cleanText / validateNewAction payload fields; its acceptance criteria do not reach markResultTransition. Searches for markResult + surrogate and resultNote found no other filing.
Why it matters
This is the exact defect class fixed three times now in sibling boundaries (#3178 for pm-dispatch, #7694 for action payloads): a cap counted in UTF-16 code units silently halves an astral character, and the lone surrogate is then persisted and delivered to downstream consumers — UTF-8 encoders corrupt it to U+FFFD, and strict parsers (e.g. Rust serde_json) reject unpaired surrogates outright. A result reported by a run whose id or note happens to place an emoji at the 200 / 2,000 boundary corrupts the audit record for that action.
Acceptance criteria
markResultTransitionnever stores anappliedByRunorresultNoteending in a lone high surrogate: when a cap would split a surrogate pair, the pair is dropped whole (stored lengthmax - 1code units for that value), reusing or mirroring the aggregator(actions): cleanText caps can split a surrogate pair — a stored action field ends in a lone surrogate #7694cleanTextguard.- Cap semantics otherwise identical: same maximum code-unit lengths (200 / 2,000), no trim or empty-handling changes, non-straddling values byte-for-byte unchanged.
- Regression tests in
pm-stack/aggregator/test/actions.test.ts: an astral character straddling both thebyRun(200) andnote(2,000) caps is stored whole-or-dropped, never halved; an exact-fit pair at the cap is kept whole; the new tests fail on the pre-fix code. - Existing aggregator actions suite stays green.
Activity
developing-today commentedon Nov 8, 2026
CODE-2297
dezren39 commentedon Nov 8, 2026
🤖 Agent note · filed
markResultTransition(actions.ts:797-798) capsappliedByRun/resultNotewith raw slice, splitting surrogate pairs and persisting a lone surrogate; reproduced with the real actions.ts in a laptop probe (both caps straddle, control exact-fit intact, persisted file contains the \ud83d escape).Merge pull request #7713 from developing-today/creator-b/7711-markres…
developing-today commentedon Nov 8, 2026
🤖 Agent note · done
capUnitshelper and routedmarkResultTransition'sappliedByRun(200) /resultNote(2,000) caps through it; regression tests added (straddle at both caps dropped whole, exact-fit pair kept whole).tsc --noEmitoutput identical to clean main.