Skip to content

perf(octane): validate streamed selection identities directly - #2096

Merged
trueadm merged 1 commit into
octanejs:nextfrom
openai-oss-forks:codex/next-stream-identity-validation
Oct 15, 2026
Merged

trueadm merged 1 commit into
octanejs:nextfrom
openai-oss-forks:codex/next-stream-identity-validation

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Validate a streamed selection's identity directly at registration. The old path fabricated a complete result frame solely to reach the same identity validator; real incoming frames still undergo full protocol validation.

Validation

  • pnpm format:check (scoped format check passed)
  • pnpm typecheck (scoped typecheck passed)
  • pnpm test (full workspace suite not run locally)
  • targeted tests: 35 streamed receiver/delivery tests passed in production compile mode. Disabling the identity guard made the malformed-identity test fail, and the restored source passed it.
  • Perf review: scan found zero candidates. registerSelection runs once per selection; the change removes a temporary frame object and checks of constant frame fields, with no new hot fields, DOM work, or scheduling. The matched production public-entry fixture changed 62,055→62,000 raw and 19,570→19,553 gzip bytes. Browser latency and a complete consumer bundle were not measured.
  • Concise-code: runtime source +2/−8; call the protocol's existing identity validator. Keeping the fabricated wrapper adds allocation and validates known constants; removing validation would weaken the public boundary. The regression test disposes its receiver even if the assertion fails.

Risk / follow-ups

The bundle result is a public-entry fixture, not a complete application bundle. Current-head CI provides broader coverage.

Provenance

  • An agent produced this diff (agent-authored)

Codex task · host com-79386.


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


Note

Low Risk
Narrows registration validation to the identity helper without changing result/placement receive paths; regression test covers the public boundary.

Overview
registerSelection now validates streamed selection identities with isStreamFrameIdentity instead of building a synthetic complete result frame and running it through isStreamedRendererFrame. Incoming frames on receive are unchanged and still get full protocol checks.

A regression test rejects malformed identities (e.g. negative attempt) before registration, with dispose in a finally block. Octane patch changeset added.

Reviewed by Cursor Bugbot for commit aa445d1. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work labels Oct 15, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review October 15, 2026 14:54
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark report

🟢 No byte growth, no added work, and no timing changes beyond ±3%.

Compares c4cbd556e, the merge commit's first parent with a8fb02521 on the same runner. Any increase in a js-framework work counter fails this check; byte changes are a report. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 3.508 3.067 +3.3% ±0.0% … +12.1% ⚪ within noise
octane-tsrx replace 8.017 7.675 ±0.0% −8.6% … +2.2% ⚪ within noise
octane-tsrx add 2.692 2.775 +0.0% −3.6% … +7.5% ⚪ within noise
octane-tsrx update 0.094 0.097 +0.3% −2.8% … +2.0% ⚪ within noise
octane-tsrx select 0.006 0.006 +0.0% −3.5% … +3.4% ⚪ within noise
octane-tsrx swap 0.019 0.020 +0.3% −2.6% … +7.7% ⚪ within noise
octane-tsrx remove 0.019 0.019 +0.7% −10.4% … +5.7% ⚪ within noise
octane-tsrx runlots 30.650 31.958 +6.4% −11.5% … +14.7% ⚪ within noise
octane-tsrx select_lots 0.007 0.007 −0.8% −5.5% … +3.8% ⚪ within noise
octane-tsrx clear 60.958 61.900 +5.7% −4.2% … +8.1% ⚪ within noise
octane-jsx run 3.975 3.675 −0.0% −5.2% … +1.2% ⚪ within noise
octane-jsx replace 8.400 8.325 −4.0% −8.7% … +0.6% ⚪ within noise
octane-jsx add 3.425 3.433 +2.9% −4.9% … +6.5% ⚪ within noise
octane-jsx update 0.218 0.230 +0.7% −2.8% … +2.3% ⚪ within noise
octane-jsx select 0.107 0.108 −0.6% −5.6% … +2.2% ⚪ within noise
octane-jsx swap 0.157 0.160 −1.3% −5.7% … +1.6% ⚪ within noise
octane-jsx remove 0.152 0.153 +0.3% −3.9% … +4.0% ⚪ within noise
octane-jsx runlots 30.767 33.075 +2.0% −1.8% … +8.3% ⚪ within noise
octane-jsx select_lots 0.977 1.014 +2.3% −0.3% … +9.2% ⚪ within noise
octane-jsx clear 68.175 60.950 −1.0% −11.6% … +6.3% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

target metric base head Δ
octane-tsrx wayfinder_js_raw 438,498 438,443 −55 (−0.0%) 🟢
octane-tsrx wayfinder_js_gzip 144,659 144,641 −18 (−0.0%) 🟢
octane-tsrx wayfinder_js_brotli 126,303 126,261 −42 (−0.0%) 🟢

90 other measured values are unchanged.

Public-import reachability bundles (bytes)

No changes across 123 measured values.

@trueadm trueadm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving: the change is small, it behaves the same, and it makes the bundle slightly smaller.

Correctness. In streamed-signals-protocol.ts, isStreamedRendererFrame starts by checking isStreamFrameIdentity(value.identity). The rest of what the old synthetic { identity, sequence: 0, channel: 'result', kind: 'complete' } frame was checked for is constant: isCounter(0), the complete kind, and hasOnly(RESULT_BASE_KEYS). So registerSelection (hydration/stream-result-receiver.ts:198) accepts and rejects exactly the same identities as before, and still throws StreamedReceiverError('identity') with code 253. Incoming frames still go through decodeStreamedRendererFrame's full validation. This also matches how hydration/streamed-signals.ts and server/streamed-signals.ts already validate identities.

Test. The new case "rejects a malformed selection identity before registration" (attempt: -1) checks the public boundary rather than internals, and dispose() sits in a finally. Strictly, it guards behaviour rather than catching a regression, since the old code also rejected this identity. That's appropriate for a refactor. Your note that disabling the guard makes it fail is what matters.

Numbers (benchmark on aa445d1, run 38755664888):

  • All 64 work counters are unchanged.
  • wayfinder_js is −55 raw, −18 gzip and −42 brotli. The other 90 application values and all 123 reachability values are unchanged.
  • All 20 paired timings are within noise.

CI on the current head is fully green: 30 pass, 6 skipped matrix placeholders.

Reviewed with Claude Code

@trueadm
trueadm merged commit 79ea274 into octanejs:next Oct 15, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants