test: add unit tests for the GCF data format (follow-up to #2235)#2343
Open
blackwell-systems wants to merge 1 commit into
Open
test: add unit tests for the GCF data format (follow-up to #2235)#2343blackwell-systems wants to merge 1 commit into
blackwell-systems wants to merge 1 commit into
Conversation
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.
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.
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:This PR adds that coverage. It introduces one new test file,
tests/McpResponseGcf.test.ts(8 tests), with no changes tosrc/.Scope
Covers every
McpResponse-level surface thatcompactEncodetouches:Encode surfaces — each round-trips losslessly back to
structuredContent:[Error]: net::ERR_CONNECTION_REFUSED)Safety / robustness:
defaultformat emits no GCF header and still renders the built-in formatter output (guards against a vacuous pass)structuredContentis byte-identical with and without GCF — clients consumestructuredContent, so enabling GCF must only change the text representation|,"~-@##, newlines, tabs, unicode, empty strings, typed-literal lookalikes liketrue) round-trip losslesslyRigor
@blackwell-systems/gcfand deep-equal it againststructuredContent, so they assert real losslessness rather than snapshotting opaque bytes — a regression in the encode path fails them.stablechannel).Notes
src/changes; no new runtime dependencies (@blackwell-systems/gcfis already the optional peer dep added in feat: add experimentalGcfFormat flag for GCF-encoded tool responses #2235).withMcpContextharness and mock helpers, matching the conventions intests/McpResponse.test.ts.cc @zyzyzyryxy — follow-up to the unit-test request in #2235.