Skip to content

aggregator(comments): author and body caps split surrogate pairs — validateAuthor/validateNewComment raw-slice at 120/20,000, bypassing the #7694/#7711 capUnits guard #7731

Closed

Description

@developing-today

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 \ud83d in 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

Acceptance criteria

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    app/aggregatorPackage/app: aggregator (pm-stack in this repo)
    on Nov 8, 2026
  2. developing-today commented on Nov 8, 2026

    @developing-today
    ContributorAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator (lane B, new-issue-creator-code-b)
    • Session / ID: cron new-issue-creator-code-b, run 2026-11-08 08:20 CST
    • Found via: filed this run
    • Task: comments.ts author/body caps split surrogate pairs (validateAuthor 120, comment body 20,000) — verified with a probe against the real module on the laptop primary @ f9dfb4c; the shared validateAuthor also serves actions.ts and roadmap-annotations.ts
    • Expectation: effort s — pair-safe caps mirroring capUnits (aggregator(actions): markResult caps split surrogate pairs — appliedByRun/resultNote stored with a lone surrogate (residual of #7694) #7711) + regression tests; self-solve attempted this run under lifecycle §4 (trivial, clearly scoped)
    • Links: probe ~/git/fleet/probe-comments-surrogate (laptop)
  3. developing-today commented on Nov 8, 2026

    @developing-today
    ContributorAuthor

    🤖 Agent note · picked up

    • Agent: new-issue-creator (lane B, new-issue-creator-code-b)
    • Session / ID: cron new-issue-creator-code-b, run 2026-11-08 08:20 CST
    • Found via: self-assigned during new-issue-creator-code-b run (filed this run; lifecycle §4 trivial self-solve — small, clearly scoped, low-risk, easy verification; no safety labels)
    • Task: make the four comments.ts caps pair-safe (local capUnits mirror, no import cycle with actions.ts) + regression tests, PR, merge when verified
    • Expectation: effort s — done = PR merged, aggregator suite green for the touched area, tests fail pre-fix
    • Links: branch creator-b/7731-comments-surrogate-caps
  4. added
    work/self-assignedAn agent grabbed this item directly, outside the queue
    and removed on Nov 8, 2026
  5. added a commit that references this issue on Nov 8, 2026
  6. developing-today commented on Nov 8, 2026

    @developing-today
    ContributorAuthor

    🤖 Agent note · done

  7. added and removed
    work/self-assignedAn agent grabbed this item directly, outside the queue
    on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/aggregatorPackage/app: aggregator (pm-stack in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions