Repository navigation
Description
aggregator(comments): author and body caps split surrogate pairs — validateAuthor/validateNewComment raw-slice at 120/20,000, bypassing the #7694/#7711 capUnits guard
Problem
pm-stack/aggregator/src/comments.ts caps dashboard-comment text with raw slice, none of it pair-safe:
- lines 96–98 —
validateAuthor:id.slice(0, 120),label.slice(0, 120),sessionId.slice(0, 120) - line 132 —
validateNewComment:body: b.body.trim().slice(0, 20_000)
This is the #3178 defect class that #7694 fixed for actions.ts cleanText and #7711 fixed for markResult via the capUnits helper (actions.ts:292, module-private): an astral character straddling the cap is dropped whole. The comments boundary was not audited in either fix — and it matters more here, because validateAuthor is the SHARED author validator: actions.ts (lines 154, 329) and roadmap-annotations.ts (lines 55, 80) both import it from comments.ts, so the pair-safe actions store still persists split-pair author ids/labels through this door, and roadmap annotations inherit the same defect.
The values are persisted, not just displayed: comments are written to the comments JSON store (CommentsStore.persist, comments.ts:259–264, JSON.stringify + atomic rename), so a split pair is stored as a lone \ud83d and any UTF-8 round-trip (file read, HTTP response) replaces it with U+FFFD.
Note on fix shape: capUnits cannot simply be imported from actions.ts — actions.ts imports validateAuthor from comments.ts, so that direction would create a module cycle. A local helper in comments.ts (or a shared helper in validate.ts, which comments.ts already imports) avoids the cycle.
Evidence (verified this run, laptop primary @ f9dfb4c, real module md5 567b6272246f4fcf519fe3213b490389)
Probe ~/git/fleet/probe-comments-surrogate/probe.ts (bun, imports the real comments.ts):
label straddle | len: 120 | lone high surrogate at end: true | utf8 roundtrip changes: true
label control | len: 120 | lone: false | roundtrip changes: false
id straddle | len: 120 | lone: true | roundtrip changes: true
body straddle | ok: true | len: 20000 | lone: true | roundtrip changes: true
body control | ok: true | len: 20000 | lone: false | roundtrip changes: false
json stored label last unit: d83d
- Straddle cases: label/id = 119 ×
x+ 😀 + tail → capped value is 120 units ending in lone\ud83d; comment body = 19,999 ×z+ 😀 + tail → 20,000 units ending in lone\ud83d. - Controls: pair fully inside the cap (118 ×
x+ 😀; 19,998 ×z+ 😀) → value intact, round-trips cleanly. - The JSON persistence round-trip preserves the lone surrogate as
\ud83din the stored record.
Dedup: searches for "validateAuthor surrogate", "comments surrogate", "DashAuthor slice", and "surrogate" (open + closed) return no issue for these caps; #7694/#7711 cover actions.ts text fields only, #7725 covers activity.ts summary caps — neither touches the shared author validator or the comment body cap.
Why it matters
- Author labels and comment bodies are operator/user text — an emoji at the wrong offset permanently corrupts the stored author identity or comment body (U+FFFD in the persisted store, and in every action/annotation record that carries the same author).
- Because
validateAuthoris shared, this is the residual door for the two fixes that landed this morning: aggregator(actions): cleanText caps can split a surrogate pair — a stored action field ends in a lone surrogate #7694/aggregator(actions): markResult caps split surrogate pairs — appliedByRun/resultNote stored with a lone surrogate (residual of #7694) #7711 made action text pair-safe while the author on those same records can still be split.
Acceptance criteria
- All four caps in
comments.ts(author id/label/sessionId at 120, comment body at 20,000) are surrogate-pair-safe: an astral character straddling the cap is dropped whole, never split (mirroringcapUnitssemantics from aggregator(actions): markResult caps split surrogate pairs — appliedByRun/resultNote stored with a lone surrogate (residual of #7694) #7711), without introducing a module import cycle. - Regression tests in the aggregator suite pin the straddle case for the author label (or id) cap and the comment body cap, plus an exact-fit control (pair fully inside the cap stays intact); the new tests fail on the pre-fix code.
- The existing aggregator test suite stays green.
Activity
developing-today commentedon Nov 8, 2026
🤖 Agent note · filed
developing-today commentedon Nov 8, 2026
🤖 Agent note · picked up
Merge pull request #7733 from developing-today/creator-b/7731-comment…
developing-today commentedon Nov 8, 2026
🤖 Agent note · done