fix(session): reject review event frames whose id disagrees with their publication fields - #781
Open
lilfrogdev wants to merge 1 commit into
Open
Conversation
…r publication fields
|
@lilfrogdev is attempting to deploy a commit to the Modem Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
PR author is not in the allowed authors list. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #761
Problem
Event frames carry their publication position twice: inside
eventId(revent:<type>:<generation>@<revision>) and as the loosegeneration/stateRevisionfields. The four frame parsers validated each part but never checked they agree, so an id naming generation 1 / revision 1 on a frame claiming generation 2 / revision 9 was accepted. The id drives SSE resume and chunk assembly; the fields are what consumers report, so they must name the same position.Approach
eventIdMatchesFrame(record, fields): parses the id with the existingparseReviewEventId(still the only id grammar) and compares the listed address fields to the frame's own.isReviewEventIdgate for that helper. Frame and begin comparegeneration+stateRevision; chunk and end comparegenerationonly (they don't carry a revision).isReviewEventId, which has no remaining callers.Non-goals: parsers keep returning the validated record via the existing casts (
hasExactKeysdoesn't narrow; rebuilding each object adds casts without changing behavior). Checking the id's eventtypeagainst the SSEevent:name is out of scope; the parsers never see it.Belongs in
src/session/reviewEventProtocol.ts: both ends of the stream import this one contract; not expressible as an extension.Tests
New cases in
src/session/reviewEventProtocol.test.ts: a well-formed single frame parses; each of the four parsers rejects an id whose generation (and, where carried, revision) disagrees with the frame while every value is individually valid. The rejection test fails against the previous code. Existing round-trip/framing/reassembly tests,browserReviewServer.integration.test.ts, and the review-conformance consumers cover the unchanged accept path.Ran:
Two pre-existing failures reproduce identically on
mainat 5ebe975 and are unrelated to this change:test/review-conformance: 3 failures inpure-deletion-hunk (A1, A2)(geometry fixtures).bun run knip: unused filetest/cli/fixtures/compiled-highlight-worker-control.tsand unused exports insrc/ui/diff/worker/index.ts(from fix(ui): offload large diff highlighting to a worker #759).Knip reports nothing for
src/session/reviewEventProtocol.ts, including the removedisReviewEventId.Tested on macOS (Bun 1.3.14). Not run on Linux/Windows; change is platform-neutral validation with no I/O. No UI change.
AI assistance
An AI coding agent helped scope the change, draft the helper/tests, and this description. I wrote and reviewed the final diff, ran every command above, and can speak to each decision here.