Skip to content

aggregator(actions): markResult caps split surrogate pairs — appliedByRun/resultNote stored with a lone surrogate (residual of #7694) #7711

Closed

Description

@dezren39

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" → stored appliedByRun is exactly 200 code units, last code unit 0xd83d — a lone high surrogate. UTF-8 encode/decode round-trip differs and ends in U+FFFD.
  • note = "n" × 1999 + "😀" + "tail" → stored resultNote is exactly 2,000 code units, last code unit 0xd83d — same lone surrogate, same U+FFFD round-trip corruption.
  • The persisted actions file literally contains the \ud83d escape.
  • 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

  • markResultTransition never stores an appliedByRun or resultNote ending in a lone high surrogate: when a cap would split a surrogate pair, the pair is dropped whole (stored length max - 1 code 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 #7694 cleanText guard.
  • 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 the byRun (200) and note (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

  1. developing-today commented on Nov 8, 2026

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

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  4. added a commit that references this issue on Nov 8, 2026
  5. developing-today commented on Nov 8, 2026

    @developing-today
    Contributor

    🤖 Agent note · done

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