Skip to content

Move server-only v2 frame codecs out of ws-v2.ts into a test helper - #1777

Closed
joepio wants to merge 1 commit into
developfrom
claude/project-thread-mes3rj-protocol
Closed

joepio wants to merge 1 commit into
developfrom
claude/project-thread-mes3rj-protocol

Conversation

@joepio

@joepio joepio commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Requested by Joep · project thread

Before: the browser's wire codec browser/lib/src/ws-v2.ts also held the encoders for frames only a server sends (AUTH_OK, ERROR, COMMIT_OK full and slim, CHALLENGE, SYNC_RESEND) and the decoder for another client's HELLO capabilities. The client never calls them; only the tests do, to play the server.

After: those seven functions live in browser/lib/src/test-ws-v2-server.ts, next to test-store.ts, and ws-v2.ts holds only what the client uses. Nothing a user sees changes.

How: moved encodeAuthOk, encodeError, encodeCommitOk, encodeCommitOkSlim, encodeChallenge, encodeSyncResend and decodeHelloCaps verbatim (with small private writeU16/readU16 copies) and pointed ws-v2.test.ts and websockets.test.ts at the new file. decodeGet and decodeGetMany stay: debugFrameInfo uses them to log the client's own outgoing GET / GET_MANY frames.

Public API: ws-v2.ts is not re-exported from @tomic/lib's index.ts and is not in the package exports, so no published API changes. Nothing in data-browser, react, e2e or other packages imported the moved functions. The only outside consumer of ws-v2.ts is data-browser's E2E-only e2eModules.ts, which takes it as a namespace and whose specs only use encodeSyncPush (a client frame, kept).

Bundle size: the release build of @tomic/lib is byte-for-byte the same size before and after (dist/*.js + *.cjs = 848,508 bytes), because tsup/esbuild already tree-shook these unused exports. So the shipped bundle did not actually carry them; this PR is a source cleanup (the codec file now reads as the client's codec), and it trims the namespace import in the E2E-only build.

Tests

  • browser/lib: pnpm exec vitest run: 125 files passed, 1010 tests passed (1 skipped). pnpm exec tsc --noEmit: clean. pnpm run lint: clean.
  • browser/data-browser: pnpm exec tsc --noEmit: the same 16 pre-existing error lines as the base (unbuilt workspace packages), none touching ws-v2.
  • pnpm exec tsup before and after: identical output size.

@joepio joepio self-assigned this Sep 25, 2026
Base automatically changed from trekmeester/combined-20260925 to develop September 25, 2026 13:04
@gitguardian

gitguardian Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
While these secrets were previously flagged, we no longer have a reference to the
specific commits where they were detected. Once a secret has been leaked into a git
repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

joepio commented Sep 25, 2026

Copy link
Copy Markdown
Member Author

GitGuardian fails here on incident 37585749, which is not from this PR. The flagged commits (4f6fe33, 49ac330, 1d80224) come from #1767 through the base branch. The hit is a false positive: a test fixture in lib/src/vault/secret_envelope.rs with zero-byte placeholder salts for a legacy password wrapper kind. It is explained on #1767. The finding can only be cleared by marking the incident as a false positive in GitGuardian, not by a push here.


Generated by Claude Code

encodeAuthOk, encodeError, encodeCommitOk(Slim), encodeChallenge,
encodeSyncResend and decodeHelloCaps are frames only a server sends or
reads. The browser client never calls them; only the tests do, to play the
server. They now live in browser/lib/src/test-ws-v2-server.ts, and
ws-v2.ts keeps only what the client uses.
@joepio
joepio force-pushed the claude/project-thread-mes3rj-protocol branch from 2b4e398 to 9030c48 Compare September 25, 2026 16:08
joepio added a commit that referenced this pull request Sep 25, 2026
…, #1779, #1780, #1784, #1782) (#1852)

Combined batch, green on Mancave in run on 01d080f (CI and Downstream).

Includes #1772, #1777, #1779, #1780, #1784 and #1782, and restores six
catalog strings from #1820 and #1787 that earlier batches dropped.

joepio commented Sep 25, 2026

Copy link
Copy Markdown
Member Author

Landed on develop in 4a3a0bf via the combined batch #1852 (green on Mancave). Closing.


Generated by Claude Code

@joepio joepio closed this Sep 25, 2026
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