Skip to content

refactor(mcp): let the dialect projection own input patterns and dependency prose - #11238

Merged
morluto merged 2 commits into
refactor/portable-dialect-rulesfrom
refactor/split-input-presentation
Nov 15, 2026
Merged

morluto merged 2 commits into
refactor/portable-dialect-rulesfrom
refactor/split-input-presentation

Conversation

@morluto

@morluto morluto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

inputSchemaPresentation.ts (1,105 lines on main) did two jobs. It presented input schemas (field descriptions, root-union flattening, discriminator roots), and it ran a dependency-tracking pattern normalization that input and output schemas shared. For input, the advertised dialect projection then rewrote the same schema again: it copied patterns verbatim, so it depended on the earlier pass, and it restated dependentRequired as prose a second time. This PR makes the dialect projection the one owner of what a listed input schema may contain, and moves the normalization to the output schemas, its only remaining consumer. Part of W3. Stacked on #11207.

Problem and expected behavior

  • Input patterns had two stages: normalizeAdvertisedSchema re-emitted them, and projectToAdvertisedDialect trusted the result. Dependency prose had two copies: presentInputJsonSchema folded dependentRequired/dependencies into the root description, and the projection's dependencyGuidance did it again.
  • The projection already drops every construct the normalization protected: not, if/then/else, contains, unevaluated*, references (inlined first), and oneOf, which it widens to anyOf. For input, the dependency analysis therefore changed nothing a client receives.
  • Expected: one input path (presentation, then the dialect projection), with the projection owning patterns, literals and dependency prose. Output keeps the normalization, because output schemas are listed in their canonical structure.

Change and scope

  • src/contracts/advertisedDialectProjection.ts: scalarBounds re-emits each pattern through projectPortablePattern and drops a pattern that has no portable form.
  • src/contracts/inputSchemaPresentation.ts (987 → 470 lines): presentInputJsonSchema only describes fields and presents the root as one object. The dependency-to-prose copy is removed.
  • New src/contracts/outputSchemaPresentation.ts: normalizeAdvertisedSchema, its dependency context and presentOutputJsonSchema, moved unchanged except for two things. It uses the shared isRecord. Its reduced-reference note no longer says "input": "This referenced schema is advertised in reduced form; the server validates the complete canonical value." No current output schema emits that note (see Evidence).
  • Tests: normalization cases move from presentInputJsonSchema to presentOutputJsonSchema, the owner (inputObservationPresentation.test.ts). In portablePattern.test.ts, the "input" presenter is now the listed presentation, with expectations for the two places where the dialect differs (it drops not, and it types a single-type union). The dependency tests assert the canonical keyword on the registered schema and the sentence in the listed guidance or description. advertisedDialectProjection.test.ts adds two rows, one for an exact portable re-emission and one for an omitted pattern; they fail on the base, which copied patterns verbatim.

Not included:

  • A single exported "advertised tool definition" function. The server (EvidenceMcpServerCore.presentInput), catalogIdentity and scripts/verify-copilot-client.mjs each still compose presentAdvertisedInput over the registered projection, and served environment catalogs do not take the dialect projection at all. That is the remaining W3 "one function produces everything advertised" step.
  • The compact-output item/type repairs in compactJsonSchema.ts.

Contribution scope: not applicable (internal refactor within an existing boundary).

Contract and boundary impact

  • Semantic owner and earliest changed stage: projectToAdvertisedDialect owns input pattern portability and dependency prose. outputSchemaPresentation.ts owns output pattern normalization. presentInputJsonSchema keeps canonical patterns and dependency keywords in the registered schema.

  • Contribution scope fit and linked maintainer decision: not applicable.

  • CLI and MCP/tool-catalog contract: listed input schemas and listed tool descriptions are byte-identical across all 255 contracts. The guidance is now separate sentences instead of one joined sentence, and describeAdvertisedTool joins it to the same text. Output schemas: 0 of 255 differ. The registered (pre-dialect) input projection keeps canonical patterns and dependency keywords, which changes the catalog identity digest.

  • 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

  • Executed: for all 255 contracts, a script compared presentAdvertisedInput(advertisedInputJsonSchema(c), COMPACT_INPUT_SCHEMA_PRESENTATION) before and after. Listed schemas were identical, and guidance joined with a space was identical. The only guidance array that differed was inspect_sqlite_database (sentences split, same joined text). advertisedOutputJsonSchema(c) showed 0 differences.
  • Regression: the two new projection rows fail on the base projection.
  • Remaining proof gaps: no real-client run. The listed bytes are unchanged.

Validation performed

  • npm run test:focused -- <18 files using the presentation functions> tests/boundary/mcp/advertisedDialect.test.ts src/contracts/advertisedDialectProjection.test.ts tests/boundary/mcp/serverIdentity.test.ts tests/boundary/mcp/javascriptFactsViewMcp.test.ts tests/boundary/mcp/serverWorkflowMcp.test.ts tests/boundary/mcp/browserScenarioMcp.test.ts tests/boundary/mcp/applicationEvidenceMcp.test.ts src/contracts/enhancedInputs.test.ts: 25 files passed, 417 tests. One failure, in applicationEvidenceMcp.test.ts (ZodError at exclusions[0].entry_kind), also fails on main and is unrelated.
  • After switching to the shared isRecord: npm run test:focused -- src/contracts/portablePattern.test.ts src/contracts/inputObservationPresentation.test.ts tests/boundary/mcp/outputSchemaProfile.test.ts tests/boundary/mcp/outputSchemaSemanticConstraints.test.ts: 4 files, 119 tests passed. Output schemas were re-compared: 0 differences.
  • npm run check:fast: passed (typecheck, lint, architecture guards).
  • npx oxfmt on the changed files.
  • npm run verify:advertised-schemas (macOS, engines: V8 plain/u/v, Go RE2, Python re, C++ RE2; Rust regex, fancy-regex and jsonschema not verified because jsonschema_rs is not installed): 31/31 patterns accepted by every installed engine. The summary comparison reports summary.json stale, and it reports the same on this PR's base (104b1a3), whose committed summary records another host's absolute-path patterns. --update-summary output from this branch is byte-identical to the output from the base, so every listed schema in every profile is unchanged.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Listed schemas and descriptions are unchanged.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: the catalog identity digest changes (registered input projection).
  • Security, privacy, process, or containment review: none.

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T14:36:48.434951Z
We couldn’t complete this review. Comment @codex review to try again.
155d1f8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Low impact] The PR appears safe to merge based on this re-review.

Summary

This PR separates input and output schema presentation.

  • Listed input schemas get portable patterns and dependency guidance.
  • Output schemas keep portable normalization in their own presenter.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  C[Canonical contracts] --> I[presentInputJsonSchema]
  I --> D[projectToAdvertisedDialect]
  D --> L[Listed input schema and tool guidance]
  C --> O[presentOutputJsonSchema]
  O --> R[Listed output schema]
Loading

Reviews (3) · Last reviewed commit: "refactor(mcp): drop the unused import fr..." · Reviewed by Greptile

@morluto
morluto force-pushed the refactor/split-input-presentation branch from 155d1f8 to 8e549c4 Compare November 15, 2026 14:42
@morluto
morluto merged commit f10f69c into refactor/portable-dialect-rules Nov 15, 2026
1 check passed
@morluto
morluto deleted the refactor/split-input-presentation branch November 15, 2026 14:51
morluto added a commit that referenced this pull request Nov 15, 2026
…ect projection (#11207)

* refactor(mcp): leave input literal portability to the advertised dialect projection

* test(mcp): leave listed-input literal portability to the dialect check

* test(mcp): trigger normalization dependency cases with non-portable patterns

* refactor(mcp): let the dialect projection own input patterns and dependency 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

* test(mcp): force the reduced form by depth now that the projection re-emits patterns

* test(mcp): take advertised input from the one advertised-tool owner after #11268

* test(mcp): check the base64 pad-bit widening on the advertised input, not the registered one
@morluto morluto added the area: mcp MCP server, transport, and tool registration label Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: mcp MCP server, transport, and tool registration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant