Skip to content

test(mcp): check advertised schemas against a portable dialect in every profile - #10567

Merged
morluto merged 3 commits into
mainfrom
test/advertised-dialect-checker
Nov 14, 2026
Merged

morluto merged 3 commits into
mainfrom
test/advertised-dialect-checker

Conversation

@morluto

@morluto morluto commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Summary

Adds one owner for the portable advertised schema dialect (src/contracts/advertisedDialect.ts) and checks every schema REA can advertise against it. A catalog test lists tools/list through the in-memory client for every input × output × catalog profile combination (2 × 3 × 2) and compares the violation counts with a counted baseline (advertisedDialectBaseline.ts). The baseline may only shrink, and any construct not listed is enforced at zero. The packaged catalog check, which runs over the packed tarball in CI, on Windows and in the release rehearsal, applies the same rules to the default profiles.

Refs #10389 #7151 #10436

Problem and expected behavior

The advertised dialect was never written down. Each client rejection (\0, \uD800, look-around, v-mode classes, arrays without items, root unions, empty-string enums, size and depth) was repaired at one site, and each guard was a denylist for one construct. Most guards covered only the default profile, so the full input profile shipped look-around and v-mode failures (#10389) until a per-site fix. One refused construct can make a client reject the whole tools request, not just one tool.

Expected: any new construct outside the portable dialect, in any profile, fails a test before release, and the known remainder is listed explicitly.

Change and scope

  • advertisedDialect.ts is a TypeScript port of the audit's pad_audit.py allowlist. It checks:

    • per-node keyword allowlist;
    • a single primitive type;
    • items on arrays only;
    • non-empty string enums on string nodes;
    • anyOf only below the root, with at least two typed branches;
    • description ≤ 1,024 characters;
    • length and item bounds < 1,999;
    • property and tool name rules;
    • tool description ≤ 4,096 characters;
    • per-tool bytes ≤ 13 KiB;
    • JSON depth ≤ 10;
    • pattern restricted to the regex grammar that compiles in V8 (plain, u, v), Python re, Go regexp, Rust regex and fancy-regex.

    Output schemas are checked against the regex grammar only, because SDK clients compile them but no model reads them.

  • The 13 KiB per-tool cap moves from mcpInputSchemaProfile.ts into the dialect owner. COMPACT_INPUT_SCHEMA_BUDGET_BYTES now refers to it. The depth check reuses schemaDepth and COMPACT_SCHEMA_MAX_DEPTH.

  • verifyCompleteToolCatalog (packed tarball: verify:package, verify:package:windows, release rehearsal canary) refuses a catalog whose default-profile counts exceed the baseline.

  • The new test runs on the curated Windows lane and is in the package CI scope.

  • Superseded checks removed:

    • the look-around and \0/\u denylists and the full-profile compile test in advertisedPatternsVMode.test.ts (the canonical base64 semantics test stays);
    • the byte and depth checks and the local schemaDepth copy in compactInputSchemaMcp.test.ts;
    • the generic dependentRequired walker;
    • the Moonshot $ref walker and its unit test. $ref, $defs, dependentRequired and dependencies are now outside the allowlist at zero in both profiles.

Baseline today, measured over every distinct listed definition:

  • Default compact input: 18 keys. The largest are $schema (256), const (81), exclusiveMinimum (61), untyped nodes (40), \s patterns (21) and unanchored ^\/ prefixes (9).
  • full input: 33 keys. These include unanchored (98), \d/\w/\s (30), . (5), one [^…^…] and one \x80-\xff pattern.
  • full output: 67 patterns (., shorthand classes, unanchored).
  • compact and off output: zero.

The look-around and v-mode constructs from #10389 are at zero in every profile, so they are enforced.

Intentionally not included:

  • The pattern re-emitter (next PR).
  • The projector that removes the other baselined constructs (W3 step 3).
  • Changes to default profiles or output schemas.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/contracts/advertisedDialect.ts owns the dialect rules and the per-tool size cap. Its consumers are mcpInputSchemaProfile.ts, the catalog test and the packaged verifier.

  • Contribution scope fit and linked maintainer decision: not applicable (test and verification guard; no runtime behaviour change).

  • CLI and MCP/tool-catalog contract: unchanged. Nothing advertised changes.

  • 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: packaged verification now fails on a dialect regression.

  • Documentation or usability only; no target interaction.

Evidence and regression coverage

  • Tests added or updated:
    • tests/boundary/mcp/advertisedDialect.test.ts:
      • 20 refused grammar cases from the audit's 7-engine compile matrix;
      • 8 accepted cases, each also compiled in V8 ""/u/v;
      • the 12-combination catalog test, which also compiles every advertised pattern in the three V8 modes.
    • packageCatalogVerification.test.ts: the packaged check refuses a look-around pattern in an input or output schema before any tool call.
  • Base reproduction: restoring src/domain/portableBundleName.ts from before the [Bug] Full input-schema profile advertises look-ahead and v-mode-incompatible patterns #10389 fix (b6b6800346^) makes the catalog test fail with input pattern look-around: 6 > 0 and input pattern unanchored: 104 > 98 for the full profile.
  • Remaining proof gaps:
    • The regex grammar's soundness comes from the audit's offline 7-engine harness. This PR runs only V8 in CI.
    • No live provider was probed.

Validation performed

  • npm run check:fast: passed.
  • npm run test:focused -- tests/boundary/mcp/advertisedDialect.test.ts tests/boundary/mcp/advertisedPatternsVMode.test.ts tests/boundary/mcp/compactInputSchemaMcp.test.ts tests/boundary/mcp/packageCatalogVerification.test.ts tests/process-global/curatedWindowsLane.test.ts tests/boundary/filesystem/ciChangeScope.test.ts tests/boundary/filesystem/ciRequiredLanes.test.ts: 7 files and 452 tests passed.
  • npm run docs:check: passed.
  • npx oxfmt --check on changed files: passed.
  • Not run locally: verify:package, verify:package:windows and the Windows lane. CI exercises them.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; Windows coverage comes from the curated lane in CI.
  • Package or release metadata impact: the release rehearsal and package verifiers refuse a catalog that regresses the dialect.
  • 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

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T20:14:58.400582Z f6f72ce New commits
ℹ️ 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a6e25111d9

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/contracts/advertisedDialect.ts Resolved
@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge, with no new blocking issue found.

Summary

Adds one owner for the advertised schema dialect, counted baselines, all-profile catalog coverage, and packaged catalog checks.

  • Schema checks now share one portable dialect across every profile.
  • Package checks reject catalogs that exceed the portable schema limits.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Profiles["Input × output × catalog profiles"] --> Listed["Advertised tools"]
  Listed --> Dialect["Shared dialect checks"]
  Dialect --> Counts["Violation counts"]
  Counts --> Baseline["Compare with profile baseline"]
  Package["Packaged tools"] --> Dialect
Loading

Reviews (3) · Last reviewed commit: "fix(mcp): refuse zero-padded repeat boun..." · Reviewed by Greptile

Comment thread src/contracts/advertisedDialect.ts Resolved
Comment thread scripts/lib/verify-package-core.mjs Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2af5be9733

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/contracts/advertisedDialect.ts Resolved
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