Skip to content

feat(id-web): browser decode for negotiated binary screen patches — F12.11 phase 3 TS half (#12242) - #12667

Merged
dezren39 merged 4 commits into
mainfrom
archer-lane-t2/12242-msgpack-transport
Nov 22, 2026
Merged

dezren39 merged 4 commits into
mainfrom
archer-lane-t2/12242-msgpack-transport

Conversation

@dezren39

@dezren39 dezren39 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

What

The TypeScript/browser half of F12.11 phase 3 (#12242) — the remainder the Rust slice (#12655, merged) explicitly scoped out — plus two small repairs to breakage that slice's verification surfaced on main.

Browser binary screen patches

  • web/src/screen-codec.ts: a strict decoder for the merged ViewPatchFrame MessagePack envelope (id_core::screen_codec, codec version 1). Parity with the Rust decoder: exact key sets (deny-unknown-fields), one exact value (trailing bytes rejected), the 1 MiB frame bound, bounded integer ranges, style-token names validated, and the encoder's token-omission for None cells honored. Anything else returns null.
  • web/src/world.ts: the session join offers screen_msgpack beside screen_patches; the session socket takes binaryType = "arraybuffer"; a binary message decodes and applies exactly like a JSON view frame's patch (same base-revision check against the retained surface, same state updates), and any undecodable or inapplicable binary frame falls back to the same full-view recovery as a mismatched JSON patch (a same-size resize). JSON patches on an offered session remain accepted, per the contract's offer-and-observe rule. Join authorization, cursor, and view-revision semantics are unchanged.
  • web/src/world-surface.ts: ScreenCell gains the optional token field the wire model already carries.
  • web/src/screen-codec.test.ts: golden-vector parity with the Rust-pinned vector (view_patch_matches_versioned_messagepack_golden_vector), a populated-patch vector (warning token, double-width glyph, token-omitted cell), and rejection cases: unsupported version, trailing bytes, truncation, the patch-only envelope offered as a view frame.

Repairs riding along (both pre-existing on main, both blocking this slice's checks)

Verification (fleet-run, this head)

nix checks via nix build ./pkgs/id#checks.x86_64-linux.<name>:

Rust behavior is untouched except the test-module attribute; the Rust slice's own evidence stands in #12655.

Relationship to #12246

#12246 was the older parallel attempt at this issue (incompatible codec, unrun head). It is superseded by #12655 (Rust) + this PR (browser) and is being closed with that record; its two browser-resume review findings are tracked in #12648.

Closes #12242
Closes #12660


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

archer added 4 commits November 22, 2026 19:15
…12242)

The TS half of F12.11 phase 3, on the Rust slice merged in #12655:
the session join now offers screen_msgpack alongside screen_patches,
binary WebSocket messages decode through a strict MessagePack
view-patch decoder at golden-vector parity with id-core's
screen_codec, and a decoded patch applies exactly like a JSON view
frame's patch — with the same full-view fallback (a same-size
resize) when the frame is malformed, unsupported, or its base
revision does not match. JSON patches on an offered session remain
accepted, per the contract's offer-and-observe rule.
…he full join shape in world-program

device_input entered the shell's join in #12281 without a contract
field, leaving test-web-unit red on main (the conformance walk
rejects the undeclared field and every later frame's phase check
cascades). The host already parses the field (world_session join
handling); this declares it, and the program test now expects the
complete join the shell sends, screen_msgpack included.
…-lint passes

The #12655 test module used unwrap() in its proptest strategies
and golden tests without the test-module allow the codebase
requires (pkgs/id AGENTS.md); clippy-lint has been red on main
since the merge. No production code changes.
@dezren39
dezren39 requested a review from a team as a code owner November 22, 2026 20:17
@coderabbitai

coderabbitai Bot commented Nov 22, 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 46 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: 0a69cb26-9140-4f35-90ff-f325974c65a8
Commits

Reviewing files that changed from the base of the PR and between 1dd4c90 and 9d593eb.

Files selected for processing: 7

  • pkgs/id/contract/shell-contract.v1.json
  • pkgs/id/crates/id-core/src/screen_codec.rs
  • pkgs/id/web/src/screen-codec.test.ts
  • pkgs/id/web/src/screen-codec.ts
  • pkgs/id/web/src/world-program.test.ts
  • pkgs/id/web/src/world-surface.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 22, 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-22T20:19:39.834302Z 9d593eb 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.

@dezren39
dezren39 merged commit 3b382fc into main Nov 22, 2026
2 checks passed
@dezren39
dezren39 deleted the archer-lane-t2/12242-msgpack-transport branch November 22, 2026 20:17

@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: 9d593ebc1e

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

/** StyleToken's serialized names (id-core world_presentation). */
const STYLE_TOKENS = new Set(["emphasis", "muted", "heading", "code", "warning", "success", "link"]);

const unpackr = new Unpackr({ useRecords: false, structuredClone: true });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Decode safely representable uint64 counters as numbers

When sequence, view_revision, or base_view_revision exceeds 0xffffffff, Rust encodes it as a MessagePack uint64. With this configuration, msgpackr 1.12.1's uint64 handler returns a bigint, which the number-only isUint validation rejects even when the value is within Number.MAX_SAFE_INTEGER. Consequently, a world whose event cursor crosses this boundary rejects every binary patch and repeatedly requests full views. Configure safe uint64 conversion or explicitly normalize bounded bigint values before validation.

Useful? React with 👍 / 👎.

Comment on lines +29 to +30
describe("decodeViewPatch", () => {
it("decodes the Rust golden view-patch frame", () => {

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 the binary decoder

The new parser is covered only by fixed golden vectors and example rejection cases, despite having explicit invariants for numeric ranges, exact keys, frame bounds, and Rust wire compatibility. This violates the testing doctrine in AGENTS.md, which requires property-based tests where code has invariants; the existing Rust property tests exercise only the Rust codec, not this browser decoder. Add generated Rust-compatible frames and malformed mutations with parity and rejection oracles rather than relying exclusively on these examples.

AGENTS.md reference: AGENTS.md:L37-L39

Useful? React with 👍 / 👎.

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