Skip to content

feat(id): negotiated binary v2 ScreenPatch transport — F12.11 phase 3 Rust slice (#12242) - #12655

Merged
dezren39 merged 1 commit into
mainfrom
felix/12242-msgpack-negotiation
Nov 22, 2026
Merged

dezren39 merged 1 commit into
mainfrom
felix/12242-msgpack-negotiation

Conversation

@dezren39

@dezren39 dezren39 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

The slice

The negotiation itself, Rust side: an explicitly negotiated binary v2 ScreenPatch session path on the #12241 MessagePack codec, covering acceptance bullet 1 and the Rust half of bullet 2 of #12242. TypeScript golden parity and the browser client decode are the follow-up slice (below).

Negotiation + fallback semantics

  • Offer: the join frame gains an additive screen_msgpack flag (shell contract revision 12), following the existing screen_patches serde-default pattern. No ALPN/path v2 split: the contract's own rule is that additive changes bump revision, and there is no in-repo v2 client to negotiate with at the ALPN level.
  • Selection: the host enables binary patches per session only when the client offered the flag AND screen_patches is on AND the transport is byte-capable (SessionIo::supports_bytes, default false). Selection is by use — no confirmation frame: a negotiated session either receives binary patch frames or keeps receiving JSON ones.
  • Frame: one versioned MessagePack value (id_core::screen_codec::ViewPatchFrame) carrying exactly the JSON view frame's patch fields — sequence, view_revision, base_view_revision, resume_token, patch — so world-event cursor and view-revision semantics are unchanged. A patch is sent binary only when it encodes smaller than the full view; encode failure falls through to the existing JSON patch/full-view choice. Full views and every other frame stay text.
  • Wire marking: length-prefixed transports (iroh streams, SSH channels) prefix binary bodies with a single NUL byte (id_core::frames::BINARY_FRAME_MARKER — JSON text frames always start with {); WebSocket uses native binary messages.
  • Fallbacks, all fail-safe: offer on a text-only transport → JSON patches, exactly as today; v1 client (no flag) → never sent binary; client→host frames stay text JSON, and a binary client frame is refused like a non-UTF-8 frame (error frame; the session continues mid-session, ends at first frame). Join authorization is untouched.

Evidence

Fail-before: at base 9b88acfda none of this exists — the offer is ignored, patches are JSON-only, and the new tests fail to compile against base (the codec envelope, join field, Inbound::Bytes, and the byte capability are all new).

Sandbox (this worktree):

  • cargo test -p id-core --lib — 533 passed (codec: golden vector for the view-patch envelope, round-trip proptest, unsupported-version/trailing/oversized rejection; frames: marker round-trip)
  • cargo test -p id-worlds --lib world_session:: — 84 passed, incl. the 4 new session tests: negotiated binary catch-up patch decodes and applies with full-view parity; offer on a text-only transport stays JSON; binary frames before/after join fail safely
  • cargo test -p id-worlds --lib shell_contract — 12 passed (revision pins moved 11 → 12); contract_tests — 5 passed
  • cargo fmt --check -p id-core -p id-worlds -p id-web — clean

Laptop (fleet shell, worktree at this head):

  • cargo test -p id-web --lib world_ws — 20 passed (WebSocket adapter incl. binary messages)
  • cargo test -p id-worlds --lib world_net — 53 passed (iroh adapter; the coordinator test in this set times out in the sandbox at base too — QUIC loopback is unavailable there — and passes here)
  • cargo test -p id-worlds --lib --features ssh,sandbox world_ssh — 49 passed (SSH adapter)

Not run: id-native-shell tests — their build needs wayland client libs a bare laptop shell lacks (wayland-sys build script); no native-shell code changes here, and the contract it embeds is validated by the shell_contract suite above.

Dependencies

None. rmp-serde was already a dependency from #12241; no Cargo.toml changes.

What remains on #12242

  • TypeScript: id-web client decode of binary patch frames + TS golden-vector parity against the pinned Rust vectors (bullet 3's TS half, bullet 2's browser half).
  • Compression and the under-10% measurement are phase 4, out of scope here as the issue states.

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

…12242)

Join gains an additive screen_msgpack opt-in (shell contract
revision 12). When it is set together with screen_patches and the
transport carries bytes, patch frames are sent as one versioned
MessagePack binary frame (id-core screen_codec ViewPatchFrame:
sequence, view_revision, base_view_revision, resume_token, patch)
instead of the JSON view frame, whenever the binary patch is
smaller than the full view. Full views and all other frames stay
on the text path; v1 clients and text-only transports keep the
exact JSON behavior, and an offer the transport cannot take up
negotiates down to JSON patches.

SessionIo gains a byte capability (supports_bytes / send_bytes,
text-only by default) and Inbound::Bytes; client binary frames
fail safely like non-UTF-8 frames. The iroh and SSH length-prefixed
transports mark binary bodies with a leading NUL (never a JSON
start); WebSocket uses native binary messages.

Codec: golden vector + round-trip proptest + unsupported-version /
trailing / oversized rejection for the view-patch envelope.
Session tests: negotiated binary catch-up patch applies with
full-view parity, text-only fallback stays JSON, binary frames
before and after join fail safely.
@dezren39
dezren39 requested a review from a team as a code owner November 22, 2026 18:49
@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 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: 1d57cfa9-882c-46c6-bd3c-1b98118c8d1a
Commits

Reviewing files that changed from the base of the PR and between 8aa0064 and ba19653.

Files selected for processing: 12

  • pkgs/id/contract/shell-contract.v1.json
  • pkgs/id/crates/id-core/src/frames.rs
  • pkgs/id/crates/id-core/src/screen_codec.rs
  • pkgs/id/crates/id-web/src/world_ws.rs
  • pkgs/id/crates/id-worlds/src/shell_contract/tests.rs
  • pkgs/id/crates/id-worlds/src/world_net.rs
  • pkgs/id/crates/id-worlds/src/world_session/mod.rs
  • pkgs/id/crates/id-worlds/src/world_session/session_core.rs
  • pkgs/id/crates/id-worlds/src/world_session/tests.rs
  • pkgs/id/crates/id-worlds/src/world_session/types.rs
  • pkgs/id/crates/id-worlds/src/world_session/view.rs
  • pkgs/id/crates/id-worlds/src/world_ssh.rs
  • 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-22T18:51:16.208478Z ba19653 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 62a495e into main Nov 22, 2026
2 checks passed
@dezren39
dezren39 deleted the felix/12242-msgpack-negotiation branch November 22, 2026 18:50
dezren39 pushed a commit that referenced this pull request Nov 22, 2026
…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.
dezren39 pushed a commit that referenced this pull request Nov 22, 2026
…-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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant