Skip to content

test: add unit tests for the GCF data format (follow-up to #2235)#2343

Open
blackwell-systems wants to merge 1 commit into
ChromeDevTools:mainfrom
blackwell-systems:gcf-format-tests
Open

test: add unit tests for the GCF data format (follow-up to #2235)#2343
blackwell-systems wants to merge 1 commit into
ChromeDevTools:mainfrom
blackwell-systems:gcf-format-tests

Conversation

@blackwell-systems

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #2235, which added --experimentalDataFormat=gcf. During that review the request was to add unit tests as the prerequisite for GCF being considered for the default/non-experimental path:

"Please also consider adding some unit tests - they are not strictly required for experimental feature, but we'll need them in case we do decide to make GCF the default. This might be a separate PR I think."

This PR adds that coverage. It introduces one new test file, tests/McpResponseGcf.test.ts (8 tests), with no changes to src/.

Scope

Covers every McpResponse-level surface that compactEncode touches:

Encode surfaces — each round-trips losslessly back to structuredContent:

  • Page snapshot
  • Network requests
  • Console messages (including the bracket-colon shapes, e.g. [Error]: net::ERR_CONNECTION_REFUSED)
  • Heap snapshot class diffs (array of flat objects)
  • Detailed heap class diff (object with nested numeric arrays)

Safety / robustness:

  • default format emits no GCF header and still renders the built-in formatter output (guards against a vacuous pass)
  • structuredContent is byte-identical with and without GCF — clients consume structuredContent, so enabling GCF must only change the text representation
  • Values containing delimiters and GCF sentinels (| , " ~ - @ ##, newlines, tabs, unicode, empty strings, typed-literal lookalikes like true) round-trip losslessly

Rigor

  • Tests decode the emitted block with @blackwell-systems/gcf and deep-equal it against structuredContent, so they assert real losslessness rather than snapshotting opaque bytes — a regression in the encode path fails them.
  • One test additionally pins the exact wire bytes (golden assertion), so a symmetric encode+decode bug can't round-trip its way past it.
  • All 8 pass; verified stable across repeated runs. Lint, type-check, and build are clean. The rest of the suite is unaffected (the only failures locally are the pre-existing e2e tests that require a system Chrome stable channel).

Notes

cc @zyzyzyryxy — follow-up to the unit-test request in #2235.

Follow-up to ChromeDevTools#2235. Builds confidence for promoting GCF from an
experimental flag to a default format, covering every McpResponse-level
surface plus the promotion-critical safety and robustness properties:

Surfaces (decode(GCF) round-trips losslessly to structuredContent):
- page snapshot
- network requests
- console messages (incl. bracket-colon shapes that crash TOON's decoder)
- heap snapshot class diffs (array of flat objects)
- detailed heap class diff (object with nested numeric arrays)

Safety / robustness:
- default format emits no GCF header (control)
- structuredContent is byte-identical with and without GCF (MCP clients
  consume structuredContent; GCF must only change the text representation)
- values containing delimiters and GCF sentinels (| , " ~ - @ ## newline,
  unicode, empty, typed-literal lookalikes) round-trip losslessly

Tests decode the emitted block with @blackwell-systems/gcf rather than
snapshotting opaque bytes, so they assert real losslessness.
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