Skip to content

aggregator(events): event-log writers raw-slice actor/summary at the validateStreamEvent caps — a straddling pair persists a lone surrogate into the hash-chained event log #7740

Closed

Description

@developing-today

Summary

The event log's writers cap actor/summary with raw UTF-16 slices at exactly the lengths validateStreamEvent enforces (200 / 500). The validator checks length only, so when an astral character straddles a writer's cap, the event validates, is appended, and a lone high surrogate is persisted into the append-only, hash-chained event log (#1739/#3322). Same defect class as #7694/#7711/#7725/#7731 — at the event log's writer boundary, which none of those fixes covered.

Evidence

Raw slice sites (main 722fbe8aa2):

  • pm-stack/aggregator/src/sources/live.ts:1065 — session-registry event: summary: `session ${r.label} (${r.agentLabel}) merged into the registry`.slice(0, 500) (label/agentLabel are source data)
  • pm-stack/aggregator/src/sources/live.ts:1630 — orchestration action event: summary: action.summary.slice(0, 500) (summary comes from the orchestration feed)
  • pm-stack/aggregator/src/sources/live.ts:1643 — tier-change event: summary: `tier ${prev} → ${tier} (run ${section.runId})`.slice(0, 500)
  • pm-stack/aggregator/src/server.ts:1248 — action-result event: actor: updated.appliedByRun ?? body.byRun.slice(0, 200) (the appliedByRun branch is pair-safe after aggregator(actions): markResult caps split surrogate pairs — appliedByRun/resultNote stored with a lone surrogate (residual of #7694) #7711; the fallback raw-slices the request's byRun)
  • pm-stack/aggregator/src/server.ts:1254 — action-result event: constructed summary (... + note).slice(0, 500) (note is caller-supplied)

The receiving side does not re-guard: validateStreamEvent (events.ts:160-171) rejects only length > 200 / length > 500; a 200/500-unit string ending in a lone surrogate passes. EventsStore.record (events.ts:795) validates through it, and the summary is folded into the hash chain (events.ts:308).

Verification (this run, laptop primary @ 722fbe8aa2)

Probe ~/git/fleet/probe-roadmap-events-surrogate/probe.ts (laptop), importing the real validateStreamEvent and EventsStore:

  • Writer-shaped summary ("x"×499 + 😀 + "y"×50).slice(0, 500) (the live.ts:1630 expression shape) → validateStreamEvent returns ok; value length 500, last code unit 0xd83d (lone high surrogate); UTF-8 round-trip contains U+FFFD.
  • Writer-shaped actor ("r"×199 + 😀 + "z"×10).slice(0, 200) (the server.ts:1248 fallback shape) → same: ok, lone 0xd83d at the tail.
  • Recording the summary event through a real EventsStore persists it: the events JSON file on disk contains the escaped lone surrogate \ud83d.

Why it matters

The event log is the cross-stack audit stream: append-only, hash-chained, rendered in the UI and searched (events.ts:390). A corrupted summary is not a transient display glitch — it is written into the durable record (and its hash), and every UTF-8 read-back renders U+FFFD. Orchestration summaries and session labels are feed data, so a straddling emoji at the boundary is a matter of time, not imagination.

Acceptance criteria

  • No event writer can emit an actor or summary ending in a lone surrogate: pair-safe caps at the five sites above, or an equivalent guard at the recordStreamEvent/validateStreamEvent boundary — triage picks the placement (per-site mirrors the aggregator(actions): cleanText caps can split a surrogate pair — a stored action field ends in a lone surrogate #7694-family pattern; a boundary guard covers future writers).
  • Regression tests: straddling pair at the 500-unit summary cap and at the 200-unit actor cap (fail pre-fix), exact-fit pair at each cap (stays intact), under-cap values unchanged.
  • Existing events test suite (pm-stack/aggregator/test/events.test.ts) passes; hash-chain integrity check stays green for newly written events.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    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 A, new-issue-creator-code-a)
    • Session / ID: cron new-issue-creator-code-a, run 2026-11-08 08:35 CST
    • Found via: filed this run
    • Task: event-log writers (live.ts:1065/:1630/:1643, server.ts:1248/:1254) raw-slice actor/summary at the exact validateStreamEvent caps (200/500); the validator checks length only — verified with a probe against the real validateStreamEvent + EventsStore on the laptop primary @ 722fbe8: straddling pair validates and persists a lone \ud83d into the hash-chained events file
    • Expectation: effort s — triage picks the guard placement (per-site pair-safe caps mirroring aggregator(actions): cleanText caps can split a surrogate pair — a stored action field ends in a lone surrogate #7694-family, or a boundary guard in recordStreamEvent/validateStreamEvent covering future writers) + regression tests; filed-only (placement is a design call, not §4-trivial)
    • Links: probe ~/git/fleet/probe-roadmap-events-surrogate (laptop)
  3. added
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    effort/sSmall: expected under 2 hours of work
    and removed
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 10, 2026
  4. dezren39 commented on Nov 10, 2026

    @dezren39
    Member

    🤖 Agent note · triaged

    • Agent: triage-step
    • State: triaged
    • Verdict: work kind task/small-fix · priority/normal · effort/s · kind/bug
    • Priority why: priority/normal retained from filing — brief line 5: a bounded data-integrity bug at the event log's writer boundary.
    • First step: Replace the raw UTF-16 .slice(0, N) caps at the event-log writer sites (pm-stack/aggregator/src/sources/live.ts:1065/:1630/:1643, server.ts:1248/:1254) with surrogate-safe truncation.
    • Acceptance: No lone surrogate can be persisted into the append-only event log; writers truncate at the validateStreamEvent caps (200/500) without splitting astral characters; aggregator tests green.
    • Fix packet: repo-health:v1:fix:developing-today/code:issue:7740 → queue repo-health-code-pilot, task 14514 (enqueued by triage-step this run).
  5. dezren39 commented on Nov 10, 2026

    @dezren39
    Member

    agent-note:v1
    task 14514 (queue repo-health-code-pilot, lane code-y) — picked up, in progress.

    Revalidated fresh: issue #7740 OPEN, no hard-stop labels, no status/needs-triage. Direct execution lane (lane row 5702).

    Work: pair-safe capUnits at the five raw-slice writer sites (live.ts x3, server.ts x2) plus a boundary guard in validateStreamEvent (events.ts) dropping a lone trailing surrogate in actor/summary, with regression tests in test/events-surrogate-7740.test.ts. Branch: queue/14514-7740-event-surrogate-caps (laptop worktree ~/git/fleet/14514-7740).

  6. added
    work/assignedQueue worker lifecycle state
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed on Nov 10, 2026
  7. dezren39 commented on Nov 10, 2026

    @dezren39
    Member

    🤖 Agent note · parked

  8. dezren39 commented on Nov 10, 2026

    @dezren39
    Member

    🤖 Agent note · awaiting CI (parked)

  9. added a commit that references this issue on Nov 10, 2026
  10. dezren39 commented on Nov 10, 2026

    @dezren39
    Member

    agent-note:v1
    task 14514 — done (lane code-k). PR #8114 MERGED 212b60b; issue #7740 CLOSED. Targeted tests: targeted tests verified by prior shifts (recorded on issue #7740); Codex review failed to run (usage limits), zero Codex findings on PR. PR checks were QUEUED in the fleet CI backlog; merged under standing merge authority (verified diff + targeted tests; CI runs on main). Labels cleaned.

  11. removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedQueue worker lifecycle state
    on Nov 10, 2026
  12. dezren39 commented on Nov 10, 2026

    @dezren39
    Member

    🤖 Agent note · done (already_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)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/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