Repository navigation
test(mcp): add RFC 8785 canonicalization regression fixtures for #7935 - #8481
zsobpeter-code wants to merge 2 commits into
Conversation
Aias00
left a comment
There was a problem hiding this comment.
Stream Agent analysis
Test-only RFC 8785 (JCS) canonicalization regression fixtures and a test-scoped reference canonicalizer for shenyu-plugin-mcp-server (issue #7935). No production code changed.
Evidence
- Full diff read (has_more=false, 90175 chars): every addition is under shenyu-plugin/shenyu-plugin-mcp-server/src/test/; no src/main/production changes (repository-wide 'src/main' search only matched pre-existing .github/shenyu-admin files).
- New McpContractCanonicalizationFixtureTest + Rfc8785TestCanonicalizer (ASF-licensed, JUnit5) drive per-pair canonical-byte equality, SHA-256 sidecar verification, raw/canonical-equal flags and a negative-control assertion; two-pow-53-plus-one is listed with a canonical file and a dedicated test.
- CI complete: discover=success, policy (8481)=success, issue-spec-policy=neutral/completed; passed=true. Fixtures are self-validating via the included tests.
Recommended next steps
Scope: captured diff and GitHub check metadata only; no local tests were executed.
Task: 21ddbe27-c97a-4ebc-8925-ecd18e7c7447 · Commit: a091f0e8dd8c6e504a7e812804ce29c16b646a0f
Review verdict: PASS
Complete test-only change with self-consistent fixtures and a reference canonicalizer validated by the included tests; CI passed; no production impact or concrete defect identified.
Publication: APPROVE (EXPLICIT_PASS)
wy471x
left a comment
There was a problem hiding this comment.
Review: RFC 8785 canonicalization fixtures for #7935
Verdict: Request changes — small, mechanical fixes; the fixture content itself looks correct.
The RFC 8785 coverage is genuinely good: I spot-checked Appendix B number spellings, 1e+30/0.002/4.5, -0, the lowercase \u001b escaping, raw DEL/€/emoji, unescaped solidus and the UTF-16 code-unit key ordering, and they match the RFC. Hand-writing a test-scoped canonicalizer is defensible here — there is no JCS implementation anywhere in the repo's dependency set to reuse — and the 2^53+1 case is documented honestly in provenance.json ("a parser that keeps arbitrary precision would write 9007199254740993 and fail this case on purpose"), which I initially read as a wrong expectation.
Required changes
- Pin the fixture files to LF.
McpContractCanonicalizationFixtureTestcompares raw committed bytes (Files.readAllBytes(...)) against canonicalizer output, andread(before)/read(after)feed those bytes to the parser..gitattributescurrently only pinsshenyu-dist/**/docker/*andscript/*.sh, so a Windows checkout withcore.autocrlf=truegains CRLF in the 13.canonical.jsonfiles (and in the pairs) and every assertion intestEveryFixtureCanonicalizesToItsExpectedBytesfails for a test that is about JSON bytes, not line endings. One line fixes it:shenyu-plugin/shenyu-plugin-mcp-server/src/test/resources/mcp-7935/** -text(theshenyu-admin/src/test/resources/app-authprecedent you cite has the same latent exposure; that is not a reason to replicate it 74 files wide). - Fix or remove the orphan sidecar.
testEverySidecarHoldsTheSha256OfTheCanonicalByteschecks thebefore/aftersidecars plus<pair>.canonical.json.sha256, but a pair withafter_canonical(the negative control) also shipsrfc8785/negative-control/required-added.after.canonical.json.sha256, which no test ever reads — a wrong hash there passes silently. Either check it whenafter_canonicalis present, or add a test that walksFIXTURE_ROOTand fails on any.sha256file not referenced byexpected/canonical-equivalence.json, which would also catch future orphans. - Name the directory for the behaviour, not the issue.
mcp-7935/is named after a closed issue and will mean nothing once #7935 scrolls away; the subdirectories (numbers,strings,key-order) are already the meaningful axes, somcp/canonicalization/(or similar) would age better. Related:provenance.jsonsays the sidecars follow theapp-authconvention, but that directory uses stem-basedcanonical-request.sha256while these arefoo.json.sha256— pick one.
Droppable, per the review standards
- For every
canonical_equal: truepair,sha256(canonical(before)) == sha256(<pair>.canonical.json), so thebefore/aftersidecars repeat the canonical file's hash. Dropping them would leave one sidecar per fixture instead of three to keep in sync (not required, just noting the bookkeeping cost). testPairEqualityMatchesTheExpectedFile,testAsciiDescriptorKeyOrderIsNoCanonicalDescriptorDriftandtestNewRequiredFieldChangesTheCanonicalBytesre-assert whattestEveryFixtureCanonicalizesToItsExpectedBytesand theraw_equal/canonical_equalloop already cover.testExpectedFileStatesThatCanonicalEqualityIsNotSemanticEquivalenceasserts a prose sentence, so it will fail on rewording while verifying no behaviour. These can go without losing coverage.testTwoPowFiftyThreePlusOneIsWrittenAsTheDoubleItRoundsToassertscontains("\"minimum\":9007199254740992"), which would be satisfied by any document containing that member; comparing the full canonical bytes (already done in the first test) is stronger.
Spec (#7935)
The PR is upfront that runtime pinning, generation consistency under refresh/pin/unpin, tenant permissions, compatibility direction and legacy-tool shapes are out of scope — that is fine for a fixtures-only PR, and semantic_equivalence_proof: false keeps canonical equality from being read as compatibility. Two things would make the gap easier for reviewers to judge: a short mapping from the six acceptance criteria in #7935 to "covered here / deferred to ", so nobody assumes AC-1 is done; and a note that no production code consumes these fixtures yet, since shenyu-plugin-mcp-server/src/main has no canonicalizer — as things stand this suite guards a helper that only the test tree owns. Also consider dropping the pointer that outsources AC-1 to the external ChangeProof tree: it asks reviewers to trust a package that is not reviewable here.
…ixture with orphan check, rename to mcp/canonicalization, map apache#7935 acceptance criteria
Aias00
left a comment
There was a problem hiding this comment.
Stream Agent analysis
Test-only PR adding RFC 8785 (JCS) canonicalization regression fixtures and a test-scoped canonicalizer for MCP tools/list descriptors in shenyu-plugin-mcp-server. No production code changes.
Evidence
- Complete diff read: 82,408 characters across all pages (has_more=false).
- CI passing: 3 checks completed, all passed, failed_checks=[], passed=true.
- All 15 fixture pairs verified: number spelling (8), string escaping (1), key order (3), negative control (1) with sidecar SHA-256 integrity and cross-referencing tests.
Recommended next steps
Scope: captured diff and GitHub check metadata only; no local tests were executed.
Task: 276bc87d-860f-4c04-a1dd-73580ba63c0a · Commit: ae0df0d1372d4d136cec07ee177e5d7856f0d42d
Review verdict: PASS
Full diff coverage achieved, CI passing, no concrete blocking defects. Test-only addition with comprehensive RFC 8785 canonicalization fixtures covering number serialization, string escaping, member ordering, and a negative control for real schema changes.
Publication: APPROVE (EXPLICIT_PASS)
Related to #7935
What this adds
Test-only regression fixtures and a test-scoped RFC 8785 (JCS) reference canonicalizer for MCP
tools/listdescriptors inshenyu-plugin-mcp-server. No production code changes.src/test/resources/mcp-7935/rfc8785/: synthetictools/listdocuments with one tool (name,description,inputSchema), as before/after pairs whose raw bytes differ only by4.50/4.5,1E30/1e+30,2e-3/0.002,1.0/1,-0/0,1e-7, the 24 Appendix B rows with a canonical form, and2^53+1pinned to9007199254740992),""/"a"/"aa"/"ab", and an ASCII descriptor reordered at three levels: different raw bytes, same canonical bytes, i.e. no canonical descriptor drift),.sha256sidecar for its canonical bytes and an expected canonical file, followingshenyu-admin/src/test/resources/app-auth.expected/canonical-equivalence.jsonrecordsraw_equal,canonical_equalandsemantic_equivalence_proof: falseper pair. Canonical equality is not schema-semantic equivalence and not a compatibility verdict.provenance.jsonrecords the synthetic origin, the RFC 8785 sections the expected literals are taken from, and what is not included. The fixtures were independently cross-checked against a separate JavaScript JCS implementation.Rfc8785TestCanonicalizer(test utility, not production) parses with Jackson and writes the canonical form itself;McpContractCanonicalizationFixtureTestchecks every pair against the expected bytes and sidecars.What this does not cover
Runtime pinning, generation consistency under concurrent refresh/pin/unpin, tenant/namespace permissions, and compatibility direction (required/enum/annotation/unsupported composition) remain separate acceptance criteria. Lone surrogates, duplicate member names and NaN/Infinity are rejection cases, not before/after pairs, and are not included (reasons in
provenance.json).Relation to the ChangeProof pilot
These fixtures complement the ChangeProof pilot package (https://github.com/jajazpua/ChangeProof/tree/11bb0c33d70e0211e5649c27566da7069c0f0824/pilots/shenyu-7935) by adding the RFC 8785 number, escaping and Unicode key-order rules next to its ASCII key-order control; none of its files are copied.
No external CLI is required or invoked; the suite runs with the project's Maven/JUnit workflow.
Verification
full
./mvnw clean install -Dmaven.javadoc.skip=true(en_US locale): all 216 modules green; one run was interrupted by a transient local port conflict in an unrelated module and resumed with-rf./mvnw -pl shenyu-plugin/shenyu-plugin-mcp-server -am test -Dtest=McpContractCanonicalizationFixtureTest -Dsurefire.failIfNoSpecifiedTests=false: 7 tests, 0 failuresmodule tests: 231 tests, 0 failures;
checkstyle:checkandapache-rat:checkon the module: passedYou have read the contribution guidelines.
You submit test cases (unit or integration tests) that back your changes.
New production code follows the code quality rules Q1-Q9 in
AGENTS.md(no magic numbers, focused methods, reuse of existing utilities).Your local test passed
./mvnw clean install -Dmaven.javadoc.skip=true.