Skip to content

perf(tests): give MCP boundary test clients the shared schema validation - #11022

Merged
morluto merged 2 commits into
perf/test-mcp-shared-schema-validationfrom
perf/mcp-boundary-shared-validation
Nov 15, 2026
Merged

morluto merged 2 commits into
perf/test-mcp-shared-schema-validationfrom
perf/mcp-boundary-shared-validation

Conversation

@morluto

@morluto morluto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

This PR moves the remaining MCP boundary test clients onto the shared, lazy schema validation that #10960 introduced. It changes 119 files in tests/boundary/mcp/ and shrinks the test-mcp-client-default-validation baseline from 161 files (282 sites) to 41 files (43 sites). outputValidatorReuse.test.ts checks the SDK default validator itself, so it becomes a named owner of the guard and keeps that validator.

Stacked on #10960.

Problem and expected behavior

A test client built with the SDK default compiles the output schema of every listed tool on its first callTool. In the mcp-boundary thread workers, those compilations accumulate. Expected: each client pays only for the tools it calls, and pays once per worker.

Change and scope

  • Each new Client(info) in the slice now passes { jsonSchemaValidator: createMcpSchemaValidation() }. Where an options object already existed, the validator was added to it. The rewrite was mechanical and parenthesis-aware, followed by oxfmt.
  • progressMcp.test.ts and electronMcp.test.ts gain a local testClient(name) helper, and one client's info object in adbStartMcp.test.ts is collapsed to a single line. Without these changes, three test functions would exceed max-lines-per-function.
  • scripts/verify/architecture-guards.mjs names tests/boundary/mcp/outputValidatorReuse.test.ts as an owner, since it deliberately exercises the SDK default validator. The baseline was lowered with --shrink-baselines.

Not included: the remaining 41 baseline files in acceptance, process-global, CLI, filesystem, providers, firmware and process tests. They follow in a further slice.

Contract and boundary impact

  • Semantic owner and earliest changed stage: tests/fixtures/mcpSchemaValidation.ts (from perf(tests): give MCP test clients the shared lazy schema validation #10960); test clients consume it.
  • Contribution scope fit and linked maintainer decision: not applicable (test infrastructure).
  • CLI and MCP/tool-catalog contract: none. The fixture keeps the SDK's Ajv 2020 + formats + allErrors policy.
  • 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.

Expected effects:

  • 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

I ran the same 119 files with npm run test:focused, first on #10960's head and then on this branch. Both runs were on macOS, back to back on a shared host. Peak is process-family RSS sampled every 200 ms.

Run Wall User CPU Peak family RSS Largest process
before (#10960 head) 112 s 219 s 5,389 MiB 5,226 MiB
after 66 s 110 s 3,707 MiB 3,319 MiB

Both runs: 117 files passed and 2 skipped, 879 tests passed and 7 skipped.

  • Tests added or updated: test clients only. No assertions changed.
  • Remaining proof gaps: Linux CI was not measured.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:focused -- <the 119 migrated tests/boundary/mcp files>: 117 files passed, 2 skipped; 879 tests passed, 7 skipped (66 s wall, 3.7 GiB peak).
  • node scripts/verify/architecture-guards.mjs: passed.
  • npm run check:fast: passed.
  • npx oxfmt --check on the changed files: passed.

After rebasing onto main at 5c53bca (#10693), head f551d72: import conflicts kept both sides; outputSchemaProfile.test.ts drops the now-unused advertisedInputJsonSchema import.

  • npm run test:focused -- tests/boundary/mcp/advertisedPatternsVMode.test.ts tests/boundary/mcp/batchSourcePublicationCleanup.test.ts tests/boundary/mcp/outputSchemaProfile.test.ts tests/boundary/mcp/providerSelectionMcp.test.ts tests/boundary/mcp/webModuleTraceMcp.test.ts: 5 files, 36 tests passed.
  • node scripts/verify/architecture-guards.mjs --shrink-baselines (no change) and npm run check:fast passed; npx oxfmt --check on the changed files passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS only.
  • Package or release metadata impact: none.
  • 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 15, 2026 •

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:52:07.978797Z
We couldn’t complete this review. Comment @codex review to try again.
58c3bd5 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.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Low impact] The reviewed changes appear safe to merge, with no blocking findings.

Summary

Moves MCP SDK clients in 159 test files onto the existing shared, lazy schema validator. Updates the testing guide and removes the remaining default-client baseline, with two named exceptions.

  • MCP test clients compile and reuse schemas through the shared validator.

Reviews (3) · Last reviewed commit: "perf(tests): give the remaining MCP test..." · Reviewed by Greptile

@morluto
morluto force-pushed the perf/test-mcp-shared-schema-validation branch from 82e0975 to 3d24b37 Compare November 15, 2026 10:28
@morluto
morluto force-pushed the perf/mcp-boundary-shared-validation branch from 27fd9af to 2b83410 Compare November 15, 2026 10:29
@morluto
morluto force-pushed the perf/test-mcp-shared-schema-validation branch from 3d24b37 to 1dd25fb Compare November 15, 2026 14:03
@morluto
morluto force-pushed the perf/mcp-boundary-shared-validation branch from 2b83410 to f551d72 Compare November 15, 2026 14:07
@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.

@morluto
morluto force-pushed the perf/test-mcp-shared-schema-validation branch from 1dd25fb to 632d2ee Compare November 15, 2026 14:25
@morluto
morluto force-pushed the perf/mcp-boundary-shared-validation branch from f551d72 to ffad7e5 Compare November 15, 2026 14:25
@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.

@morluto
morluto force-pushed the perf/mcp-boundary-shared-validation branch from ffad7e5 to b3d0639 Compare November 15, 2026 14:51
@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.

@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.

@morluto
morluto merged commit f66e2a1 into perf/test-mcp-shared-schema-validation Nov 15, 2026
1 check passed
@morluto
morluto deleted the perf/mcp-boundary-shared-validation branch November 15, 2026 14:52
morluto added a commit that referenced this pull request Nov 16, 2026
…10960)

* perf(tests): give MCP test clients the shared lazy schema validation

The MCP SDK client compiles every listed tool's output schema on its
first tool call. With the SDK's default Ajv options, REA's catalog costs
gigabytes of allocation per client (inspect_analysis_view alone: 1.7 s and
~500 MiB retained), so native MCP files peaked at 1-2 GiB per worker.

tests/fixtures/mcpSchemaValidation already owns lazy, reference-preserving
validation. Route the native MCP, process-boundary and shared harness
clients through it, share compiled validators across clients in a worker
(bounded LRU keyed by schema text), and add a counted architecture guard so
default-validation test clients cannot spread; the remaining copies are the
baseline.

* fix(guards): read call arguments past parentheses inside string literals

* perf(tests): give MCP boundary test clients the shared schema validation (#11022)

* perf(tests): give MCP boundary test clients the shared schema validation

* perf(tests): give the remaining MCP test clients the shared schema validation (#11025)

* fix(guards): read an MCP client's validator option from parsed code

The default-validation counter searched each new Client(...) call's text for jsonSchemaValidator, so an inline comment, a string literal or a client name naming the option hid a default client. Parse the source with @babel/parser and count NewExpressions of Client whose object-literal arguments have no jsonSchemaValidator property; a source that does not parse counts every textual call. The guard reads raw test sources, and the generated-child-script allowlist entry, which no longer counts as a call, is removed.

* fix(guards): read an MCP client's options only from a whole object-literal argument

The default-validation counter skipped files without the text
'new Client(', so a comment between the tokens hid a client, and it took
any depth-two key as an option, so 'enabled ? { jsonSchemaValidator } : {}'
passed while its false branch uses the SDK default. The skip now only
requires the name Client, and the validator counts only when it is a key
of an object literal that is a whole argument; anything else counts as the
default.
@morluto morluto added area: tests Test suite and verification performance Performance regressions, scaling limits, and bounded-resource work labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tests Test suite and verification performance Performance regressions, scaling limits, and bounded-resource work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant