Skip to content

fix(id/web/world): reject wrong-shape invite/view/error frames (#7924) - #8536

Merged
dezren39 merged 2 commits into
mainfrom
queue/14284-7924-world-frame-guards
Nov 11, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/14284-7924-world-frame-guards

Conversation

@dezren39

@dezren39 dezren39 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Fixes #7924.

Session-WS invite/view/error frames in pkgs/id/web/src/world.ts receive() were shape-trusted:

  • invite: any truthy capability was passed to showCapability, persisting a coerced '[object Object]' / '12345' to sessionStorage with 'Invite ready to share'
  • view: any data was assigned to view.textContent and a non-number view_revision stored verbatim
  • error: any message was displayed coerced

Now, mirroring the snapshot/event rejectFrame() discipline:

  • invite: a present non-string capability (or non-record invite / non-string display_name) is rejected before any persisted/rendered state changes; a missing capability stays a no-op
  • view: non-string data, or a present non-finite view_revision / base_view_revision, is rejected before any state changes
  • error: a present non-string message is rejected; '[object Object]' is never displayed

Tests (oracle = the frame-shape acceptance in #7924; the FakeWebSocket harness pins persisted sessionStorage, the capability field, rendered view text and status):

  • new pkgs/id/web/src/world-frames.test.ts (5 tests): control valid invite/view/error plus object/numeric invite capabilities, object view data, string view_revision, object error message — 4/5 fail pre-fix, 5/5 pass post-fix
  • all 9 world suites on the laptop: 81/81 pass
  • tsc --noEmit clean

Queue: task 14284, lane tmp-code-v.


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 11, 2026 04:43
@coderabbitai

coderabbitai Bot commented Nov 11, 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 51 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: ebfca151-00ab-4149-a45f-84c6fc12f39b
Commits

Reviewing files that changed from the base of the PR and between 4e3192a and 70e8aaa.

Files selected for processing: 2

  • pkgs/id/web/src/world-frames.test.ts
  • pkgs/id/web/src/world.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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T11:03:54.838283Z 70e8aaa Manual request
ℹ️ 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf3b0466b3

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +124 to +129
const malformed: Array<Record<string, unknown>> = [
{ type: "invite", invite: { capability: { forged: true } } },
{ type: "invite", invite: { capability: 12345 } },
{ type: "invite", capability: { forged: true } },
{ type: "invite", capability: 12345 },
];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add property-based coverage for frame-shape invariants

For this frame parser, the new suite covers only handcrafted examples, but the repository testing doctrine explicitly requires property tests for parser/state invariants. Add generated JSON frame shapes with an explicit acceptance oracle and verify that rejected frames preserve the capability, sessionStorage, rendered view, and revision state. This would also cover the newly added display-name and base-revision validation branches, which the current examples do not exercise.

AGENTS.md reference: AGENTS.md:L41-L45

Useful? React with 👍 / 👎.

…ew/error (#7924)

Codex P1 on PR #8536: the frame parser suite covered only handcrafted examples. Add a fixed-seed generated-shape property test with an explicit acceptance oracle restated from the world.ts validation: 240 generated invite/view/error frames; rejected frames must preserve capability, sessionStorage, rendered view and status semantics, accepted frames apply exactly the named field effects. Coverage guards assert both outcomes per kind plus the display_name and base_view_revision branches.
@dezren39

Copy link
Copy Markdown
Member Author

Fixed in 70e8aaa. Added a property-based test to world-frames.test.ts: a fixed-seed PRNG generates 240 invite/view/error frames from a mixed JSON value pool, checked against an explicit acceptance oracle restated from the world.ts validation rules. Rejected frames are asserted to preserve the capability field, sessionStorage, and the rendered view; accepted frames apply exactly the named field effects. Coverage guards assert both outcomes per frame kind and that the display_name and base_view_revision branches are exercised. Suite: vitest run src/world-frames.test.ts — 6 passed.

@dezren39

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 70e8aaae4e

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dezren39
dezren39 merged commit 6219b31 into main Nov 11, 2026
1 of 8 checks passed
@dezren39
dezren39 deleted the queue/14284-7924-world-frame-guards branch November 11, 2026 11:05
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