Repository navigation
refactor(mcp): leave input literal portability to the advertised dialect projection - #11207
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
[Low impact] The PR appears safe to merge; no new blocking issue was identified. SummaryMakes
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
C["Canonical Zod contract"] --> V["Runtime input checks"]
C --> I["presentInputJsonSchema"]
I --> A["advertiseToolInput"]
A --> P["projectToAdvertisedDialect"]
P --> L["Listed input schema and tool guidance"]
C --> O["presentOutputJsonSchema"]
O --> R["Registered output schema"]
Reviews (8) · Last reviewed commit: "Merge branch 'main' into refactor/portab..." · Reviewed by Greptile |
…ndency prose (#11238) * refactor(mcp): let the dialect projection own input patterns and dependency prose * refactor(mcp): drop the unused import from the output schema presentation
… not the registered one
Summary
Advertised input schemas rewrote boolean and empty-string literals twice: once in
inputSchemaPresentation.ts(widenGatewayLiterals, a Gemini-named branch), and again in the advertised dialect projection (literalKeywords, the dialect'senumrule). Every listed input schema passes through the projection, so the first rewrite changed nothing a client receives. This PR removes it, along with the Boolean-collapse code that only it could trigger, and replaces the remaining client-named comments ininputSchemaPresentation.tsandcompactInputSchema.tswith the dialect rule each one implements. Part of W3 (portable advertised schema dialect).Problem and expected behavior
presentInputJsonSchemawidenedconst: false,const: ""and boolean or empty-string enums, citing Gemini.projectToAdvertisedDialect(src/contracts/advertisedDialectProjection.ts) already keeps only non-empty string enums and gives other literals their type. It runs on every listed input schema (presentAdvertisedInput, the only input presentation since feat(mcp)!: retire the full schema profiles and declare schema facts as typed annotations #10693). The same rule therefore had two owners.oneOforanyOfof Boolean literals becametype: "boolean"). Without the rewrite, that path cannot trigger.advertisedDialect.ts.Change and scope
src/contracts/inputSchemaPresentation.ts: removedwidenGatewayLiterals,hasNormalizedLiteral, theNormalizationOptionsinput/output switch,isBooleanLiteralSchema,isBooleanSchema,collapsesToBoolean,preserveSharedDefault, and theanyOfcollapse case inthroughRemovableLocation. Normalization now rewrites only patterns, which it already did for both input and output. The root-union flattening comment now cites the dialect'sroot-shaperule instead of Anthropic.src/contracts/compactInputSchema.ts: the header cites the dialect (no$ref/$defs) instead of Kimi and Moonshot. Theinput-bytesrule inadvertisedDialect.tskeeps the evidence that the cap is measured after clients expand references.presentAdvertisedInputSchemaafterpresentInputJsonSchema). Tests that used a literal only to trigger dependency analysis now use a pattern with no portable form (^😀$). One test only checked that literal payloads were not rewritten; it was removed, because no literal rewrite remains. The sharedadvertisedSchemaErrorsfixture andcompactInputSchemaMcp.test.tsno longer apply the Gemini literal denylist (unsupportedInputLiteralSchemaError). For registered (pre-dialect) schemas the check no longer holds. For listed schemas,advertisedDialect.test.tsalready checks every listed input against all dialect rules with an empty baseline, andconstand non-string or empty enums are violations there.Not included:
compactJsonSchema.ts. That module also serves compact output schemas, which the dialect projection does not cover. They are left for the W3 step that gives one function ownership of everything advertised.tests/fixtures/mcpClientSchemaConstraints.tsandscripts/lib/gemini-schema-literals.mtsare kept. They still check served environment catalogs (environmentServeWritesMcp.test.ts), which the dialect projection does not present, and the Gemini verifier uses the second against the real client.arrayItemSchemaErrorstill checks registered output schemas.Contribution scope: not applicable (internal refactor within an existing boundary).
Collapsed from #11238
This PR now also carries #11238. The dialect projection re-emits input patterns through
projectPortablePatternand owns dependency prose.presentInputJsonSchemaonly describes fields and presents the root as one object. The dependency-tracking pattern normalization moved to the newsrc/contracts/outputSchemaPresentation.ts, because output schemas are now its only consumer.inputSchemaPresentation.tswent from 1,105 lines on main to 470. Listed input schemas, tool descriptions and output schemas are byte-identical for all 255 contracts.verify:advertised-schemas -- --update-summarygives identical output on this branch and on its base. Later fix:compactInputSchema.test.tsnow forces the reduced form by depth, because the unanchored pattern it relied on is now re-emitted. Across the 27 test files that import these modules, 445 tests passed; the one failure,applicationEvidenceMcp.test.ts, also fails on main.Contract and boundary impact
Semantic owner and earliest changed stage:
projectToAdvertisedDialectowns literal portability.presentInputJsonSchema(the intermediate registered presentation) now keeps canonical literals.Contribution scope fit and linked maintainer decision: not applicable.
CLI and MCP/tool-catalog contract: listed input and output schemas are byte-identical before and after (see Evidence). The intermediate
advertisedInputJsonSchemachanges for 6 tools: it now keeps their Boolean/empty-string literals. That projection feeds the catalog identity digest, so the catalog digest changes, as it does on any schema change.Provider, bridge, target-format, or platform compatibility: none.
Evidence, artifact, provenance, or reconstruction contract: none.
Target selection, authority, upstream behavior, and cleanup details: not applicable.
Generated metadata, package, or installation impact: none.
Read existing files or captured data.
Launch or attach to a process.
Inject instrumentation or run scripts/code.
Change process memory, registers, files, or configuration.
Contact network services.
Recover protected code or work around protections.
Documentation or usability only; no target interaction.
Not sure yet; investigation or maintainer guidance needed.
Evidence and regression coverage
presentAdvertisedInput(advertisedInputJsonSchema(c), COMPACT_INPUT_SCHEMA_PRESENTATION)(schema and guidance) for all 255 contracts, andadvertisedOutputJsonSchema(c)for each. Results were compared before and after withcmp/deep-equality. Listed input: identical. Output: 0 of 255 differ. Intermediate input: 6 of 255 differ (literals kept).src/contracts/toolInputReferences.test.ts(literal cases assert the advertised schema),src/contracts/inputObservationPresentation.test.ts(dependency triggers use an unexpressible pattern),tests/boundary/mcp/toolSchemaValidity.test.ts(Boolean-literal relaxation is checked on the advertised schema),tests/boundary/mcp/compactInputSchemaMcp.test.tsandtests/fixtures/mcpAdvertisedSchemaValidity.ts(the literal denylist is dropped there, because the dialect check covers listed inputs).Validation performed
npm run test:focused -- <18 files that use presentInputJsonSchema, presentOutputJsonSchema, canonicalTools or toolRegistrationOptions>: 18 files, 334 tests passed.npm run test:focused -- tests/boundary/mcp/toolSchemaValidity.test.ts tests/boundary/mcp/compactInputSchemaMcp.test.ts tests/boundary/mcp/environmentServeWritesMcp.test.ts tests/conformance/verifiers/geminiSchemaLiterals.test.ts tests/boundary/mcp/serverWorkflowMcp.test.ts tests/boundary/mcp/javascriptFactsViewMcp.test.ts tests/boundary/mcp/evidenceInputContractsMcp.test.ts tests/boundary/mcp/browserScenarioMcp.test.ts tests/boundary/mcp/serverIdentity.test.ts tests/boundary/mcp/advertisedDialect.test.ts src/contracts/enhancedInputs.test.ts src/contracts/advertisedDialectProjection.test.ts src/contracts/portablePattern.test.ts: passed after the compact-only literal check (13 files).compactInputSchemaMcp.test.ts:npm run test:focused -- tests/boundary/mcp/compactInputSchemaMcp.test.ts tests/boundary/mcp/advertisedDialect.test.ts: 2 files, 55 tests passed.npm run check:fast: passed (typecheck, lint, architecture guards).npm run docs:check: passed.npx oxfmt --checkon the changed files: passed.tests/boundary/mcp/applicationEvidenceMcp.test.tsfails with aZodErroronexclusions[0].entry_kind. It fails the same way with this PR'sinputSchemaPresentation.tsreverted to main, so it is unrelated.npm run verify:advertised-schemas(macOS, engines: V8 plain/u/v, Go RE2, Pythonre, C++ RE2; Rustregex,fancy-regexandjsonschemanot verified becausejsonschema_rsis not installed): 31/31 patterns accepted by every installed engine. The summary comparison reportssummary.jsonstale, and it reports the same on this PR's base (104b1a3), whose committed summary records another host's absolute-path patterns.--update-summaryoutput from this branch is byte-identical to the output from the base, so every listed schema in every profile is unchanged.After #11268 merged (38dbadd): merged main. Three tests added on this branch still called the removed
presentAdvertisedInputSchema, which is why the merger's gate refused this PR oncheck:fast. They now take the advertised input fromadvertiseToolInput/advertiseToolinsrc/contracts/advertisedTool.ts.npm run check:fast— passed.npm run test:focused -- src/contracts/toolInputReferences.test.ts src/contracts/portablePattern.test.ts tests/boundary/mcp/toolSchemaValidity.test.ts tests/boundary/mcp/compactInputSchemaMcp.test.ts src/contracts/compactInputSchema.test.ts— 5 files, 198 tests passed.oxfmt --check .,npm run check:fastandnpm run verify:advertised-schemasall passed.After the merger's gate refused this PR on affected tests (5bdab9f):
src/contracts/canonicalBase64Metadata.test.tsstill expected the registered input schema to admitAB==. Since this PR, the registered schema keeps canonical patterns, so it rejectsAB==exactly, andadvertiseToolInputwidens the negated pad-bit probe away for clients. The advertised projection was not broken; the test was checking the wrong layer. The test now checks the registered input (exact), the advertised input fromadvertiseToolInput, and the output presentation (both admitAB==), and checks that the server refusesAB==in both directions. I also corrected theadvertisedInputJsonSchemadoc comment.npm run test:local -- src/contracts/canonicalBase64Metadata.test.ts: 2 tests passed.npm run test:focused --on the registered-input consumers that were outside the gate's affected set (applicationEvidenceMcp,serverWorkflowMcp,javascriptFactsViewMcp,evidenceInputContractsMcp,browserScenarioMcp,generatedToolCatalog,toolInputAdmission, plussrc/contracts/toolSchemaMetadata.test.ts): 8 files, 19 tests passed.check:fastplus architecture guards): passed.briefs/local-gate.sh 11207: oxfmt, check:fast, the guards andverify:advertised-schemaspassed, andcanonicalBase64Metadatapassed. Two acceptance tests (analysisSettingsMcp,adbNumericDeclarations) timed out at 120 s while the machine was under load (load average about 9). Run alone on this head withnpm run test:focused, both passed: 11 tests, with the slowest case at 5.8 s.applicationManifestRootsandapplicationVersionMatchingCli. The host load average was 8 to 9 from concurrent agents.npm run test:focused --on the two assertion failures and the two PR-relevant schema tests (compactInputSchemaMcp,toolSchemaValidity): 4 files, 36 tests passed in 14.8 s wall time, 1.35 GB peak RSS.Compatibility, safety, and release
Author readiness
Human owner:
Before merge
type(scope): outcome.