Repository navigation
feat(id-web): browser decode for negotiated binary screen patches — F12.11 phase 3 TS half (#12242) - #12667
Conversation
…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.
|
Warning Review limit reachedYou'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. View limit details
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. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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 }); |
There was a problem hiding this comment.
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 👍 / 👎.
| describe("decodeViewPatch", () => { | ||
| it("decodes the Rust golden view-patch frame", () => { |
There was a problem hiding this comment.
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 👍 / 👎.
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 mergedViewPatchFrameMessagePack 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'stoken-omission for None cells honored. Anything else returns null.web/src/world.ts: the session join offersscreen_msgpackbesidescreen_patches; the session socket takesbinaryType = "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:ScreenCellgains the optionaltokenfield 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)
device_input(added in fix(id): validate forms against presenter input #12281, parsed by the host) was never declared in the shell contract, leavingtest-web-unitred on main — the conformance walk rejected the join and every later phase check cascaded. Declaresdevice_inputas an optional object field;world-program.test.tsnow pins the complete join the shell sends. Verified pre-existing with a pure-main baseline run (fleet-run 45061975197).screen_codectest module usedunwrap()without the test-module#[allow(clippy::unwrap_used, clippy::expect_used)]the codebase requires — 9 errors, all in that module. One-line allow; no production code changes. The workspaceclippy-lintcheck itself remains red on main for an unrelated crate (src/boards/records.rstest unwraps) — filed as id: clippy-lint red on main — unwrap() in boards/records.rs tests (and formerly screen_codec tests) #12665, out of scope here.Verification (fleet-run, this head)
nix checks via
nix build ./pkgs/id#checks.x86_64-linux.<name>:test-web-unit— 879 passed, 9 skipped, 0 failed (full web suite: the new codec parity tests, the conformance walk, world-program)test-web-typecheck,web-fmt-check,web-lint,cargo-fmt-check— passclippy-lint— thescreen_codecerrors are fixed (fleet-run 45063969351: id-core now compiles clean under clippy); the check still fails later in the unrelatedidCLI boards tests (id: clippy-lint red on main — unwrap() in boards/records.rs tests (and formerly screen_codec tests) #12665)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
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.