Skip to content

fix(aggregator): pair-safe caps for event-log writers (#7740) - #8114

Merged
dezren39 merged 1 commit into
mainfrom
queue/14514-7740-event-surrogate-caps
Nov 10, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/14514-7740-event-surrogate-caps

Conversation

@dezren39

@dezren39 dezren39 commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Fixes #7740.

What

The event log's writers capped actor/summary with raw UTF-16 .slice() at exactly the lengths validateStreamEvent enforces (200/500). An astral character straddling a cap was split, the length-only validator passed it, and a lone high surrogate was persisted into the append-only, hash-chained event log.

  • pm-stack/aggregator/src/sources/live.ts: pair-safe capUnits (the aggregator(actions): cleanText caps can split a surrogate pair — a stored action field ends in a lone surrogate #7694-family guard) at the three writer sites — session-registry event, orchestration action event, tier-change event.
  • pm-stack/aggregator/src/server.ts: pair-safe capUnits at the two action-result writer sites — the byRun actor fallback (200) and the constructed summary (500).
  • pm-stack/aggregator/src/events.ts: boundary guard in validateStreamEvent — a trailing lone high surrogate in actor/summary is dropped before the value is stored, so no present or future writer can persist one into the hash chain.

Tests

New pm-stack/aggregator/test/events-surrogate-7740.test.ts (oracle: a stored event field never ends in a lone high surrogate and always round-trips through UTF-8 unchanged):

  • writer-shaped summary straddling the 500 cap and actor straddling the 200 cap are cleaned at the boundary (fail pre-fix: 3 of 6 tests fail with the events.ts guard stashed);
  • exact-fit pair at each cap stays intact; under-cap values unchanged;
  • EventsStore.record of writer-shaped events persists no \ud83d in the on-disk file and the hash chain verifies (health().integrity.ok).

Existing suites: events.test.ts + events-archive-3322.test.ts pass (57 tests with the new file). bunx tsc --noEmit shows 8 pre-existing errors, none in the touched files.

Queue: task 14514, lane code-y.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 10, 2026 03:57
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-10T03:57:28.067007Z
We couldn’t complete this review. Comment @codex review to try again.
d24409a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Nov 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 47 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c56c190b-6426-41bc-a992-215f78478a81
Commits

Reviewing files that changed from the base of the PR and between a849685 and d24409a.

Files selected for processing: 4

  • pm-stack/aggregator/src/events.ts
  • pm-stack/aggregator/src/server.ts
  • pm-stack/aggregator/src/sources/live.ts
  • pm-stack/aggregator/test/events-surrogate-7740.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@dezren39

Copy link
Copy Markdown
Member Author

Codex findings disposition (task 14514, lane code-t): the Codex code review on this PR failed to run — the connector reported Codex usage limits reached, and no review findings were posted (review-comment list is empty). There is therefore no substantive Codex finding to fix or rebut on this PR; the failed-review state is a quota failure, not a code finding. Merge remains gated on CI green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant