Skip to content

test(mcp): compile advertised patterns with the regex engines clients run - #10982

Merged
morluto merged 4 commits into
mainfrom
test/advertised-schema-engines
Nov 15, 2026
Merged

morluto merged 4 commits into
mainfrom
test/advertised-schema-engines

Conversation

@morluto

@morluto morluto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Combined stack. #10983 (Rust/Python jsonschema validators), #10984 (required CI step in the build job plus its workflow policy test), #10985 (committed summary.json of the advertised catalog) and #10986 (release-guide check of the qualified archive) were collapsed into this PR; their bodies hold the details and the re-run regression proof for #11040 (in #10983). Rebased onto main 598a0c4, and summary.json was regenerated from that main's catalog (8 tool schemas changed since 1151763; no pattern changes). This PR changes package.json (one script), so it needs full CI.

Compile every regular expression the packaged server advertises, in every schema profile, with the regex engines clients and gateways actually run, so a pattern one of them cannot compile is caught before merge. Refs #10830.

First of five stacked PRs: engines (this), validators, CI wiring, catalog summary, release-gate docs.

Problem and expected behavior

rea-agents 6.9.0 advertised ^[^\uD800-\uDFFF]*$ on every local path input. RE2 (Go gateways) and Rust regex/jsonschema clients cannot compile it, and those clients refuse the whole tools/list, so no tool was usable (#10830). Advertised schemas were only checked with Ajv/V8, so tests passed. #10567 added a rule-based portable grammar, and #10582 now re-emits patterns in it, but neither runs a real engine.

Expected: a pattern any supported engine refuses fails a named check, with the engine, its error, and each tool, schema path and profile that advertises it.

Change and scope

  • scripts/lib/advertised-catalog.mjs lists tools from the built package's stdio entry (scripts/rea.mjs mcp, the same entry an installed client starts) for every catalog profile, pairing input and output profiles in turn: 6 server processes, run concurrently, cover all 712 distinct advertised schemas. I checked that against listing all 12 combinations. The full product would only repeat schemas, and advertisedDialect.test.ts already lists it in process.
  • scripts/verify-advertised-schemas.mjs (npm run verify:advertised-schemas) deduplicates patterns (180 on current main) and compiles each one once per engine, one process per toolchain:
    • V8 plain, u and v, in process;
    • Go regexp (RE2) through go run of a stdlib-only file, with GOTOOLCHAIN=local so nothing is ever downloaded;
    • C++ RE2 (google-re2), Python re, and Rust regex and fancy-regex through the Rust jsonschema crate (jsonschema-rs), in one Python process.
  • Engine choice: these are prebuilt, pinned wheels, so no Rust or C++ toolchain is built. jsonschema-rs runs the actual Rust crate, with both regex backends selectable. requirements.txt pins wheels only (--only-binary=:all:, --require-hashes, PyPI wheel digests). jsonschema-rs is pinned to 0.60.3 (2026-10-27), not 0.61.x, so it is more than two weeks old.
  • Helpers run under the verifier command owner (scripts/lib/verify-commands.mjs → runOwnedCommand in src/process/), which applies a 120 s deadline to the whole process group (go run starts a grandchild) and drains output; the request is a file argument. Listings use the owned MCP stdio transport (scripts/lib/owned-mcp-stdio.mjs). Each temporary root is a VerifierFixture, removed only after its processes are confirmed stopped. A refusal prints the engine's headline, the first complete explanation, every affected tool and the first exact locations.
  • A missing engine is reported as not verified, never as passed. REA_REQUIRE_SCHEMA_ENGINES=1 turns it into a failure (CI sets it in the CI wiring PR). Nothing installs engines on a developer machine.
  • --package-root=DIR lists an installed package instead of the checkout, for the release-gate step in the last PR.
  • advertisedSchemaPatterns (the pattern owner in advertisedDialect.ts) now also reports patternProperties keys, which clients compile too, so the dialect rules and this check cover them. No current schema advertises patternProperties, so baseline counts are unchanged.

Not included: validators (next PR), CI wiring, the catalog summary and docs (later PRs). Raw regex::Regex::new callers that skip the jsonschema crate's ECMA-262 translation are covered only by the portable-grammar rules.

Contract and boundary impact

  • Semantic owner and earliest changed stage: advertisedSchemaPatterns in src/contracts/advertisedDialect.ts stays the single owner of "which strings are advertised regexes"; the new script consumes it from dist.

  • Contribution scope fit and linked maintainer decision: test and verification tooling only; not applicable.

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

  • Provider, bridge, target-format, or platform compatibility: none. The script runs on POSIX and Windows hosts; on Windows the Python default is python.

  • Evidence, artifact, provenance, or reconstruction contract: none.

  • Target selection, authority, upstream behavior, and cleanup details (if applicable): the listing uses a temporary HOME per server process, owned by a VerifierFixture and removed after the server is stopped.

  • Generated metadata, package, or installation impact: none; no new npm dependency.

  • 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

Validation performed

  • node scripts/verify-advertised-schemas.mjs (after npm run build:cached) with the pinned wheels in a scratch venv and REA_REQUIRE_SCHEMA_ENGINES=1, on main 1151763: all 180 patterns accepted by all 8 engines (exit 0).
  • REA_SCHEMA_ENGINES_PYTHON=/nonexistent/python: the four Python engines are reported not verified (… could not start (ENOENT)); with REA_REQUIRE_SCHEMA_ENGINES=1 the run fails naming each. REA_SCHEMA_ENGINES_PYTHON=/usr/bin/false: reported as failed checks.
  • A probe of the verifier command owner with sh -c 'sleep 5 & sleep 5' and a 300 ms deadline returned the deadline failure (the owned process group is stopped; on macOS, cleanup confirmation is withheld for Apple platform binaries such as sh, which the Go and venv Python helpers are not).
  • Regression proof above (exit 1), then reverted.
  • pip install --require-hashes -r scripts/verify/advertised-schemas/requirements.txt into a fresh venv: installs only the pinned wheels.
  • npm run test:focused -- tests/boundary/mcp/advertisedDialect.test.ts: passed.
  • npm run check:fast, node scripts/verify/architecture-guards.mjs, npx oxfmt --check ., npm run docs:check: passed. gofmt -l: clean.

Timings on an Apple-silicon 10-core host shared with other agents (load average 15-30, so these are noisy upper bounds):

Stage Cold Warm
List 6 packaged catalogs (6 server processes) n/a 1.8-4 s; up to 14 s at load 30
V8 plain/u/v n/a <1 ms each
Go regexp (go run, compile included) 2.3 s (empty GOCACHE) 0.3-1.1 s
Python re, C++ RE2, Rust regex, fancy-regex n/a 4-20 ms each
Python engine install (venv plus wheels, no pip cache) 7 s n/a (cached venv)
Whole check (this PR) n/a 3.2 s wall / 8 CPU-s, peak RSS 410 MB

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable. Engines were run on macOS arm64 only; the Linux runner is exercised once the CI PR lands.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: helper processes get the patterns on stdin and are killed after 120 s. Python runs with -I. Go cannot fetch a toolchain.

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-15T12:36:53.087671Z
We couldn’t complete this review. Comment @codex review to try again.
12f7756 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: plus

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

This PR checks advertised MCP patterns and schemas with the engines clients use.

  • The packaged MCP catalog gets checked with the engines clients use.
  • The catalog summary shows which tools gained or changed schemas.
  • Schema checks now include regex keys used to match property names.
  • The build job checks client engines for every code change.

No new actionable or security issues were found. This was a source review; builds and engine checks were not run here. Live PR status could not be checked because GitHub authentication was unavailable.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Built or installed package] --> B[List MCP catalogs]
  B --> C[Collect distinct schemas and patterns]
  C --> D[Run client engines and validators]
  B --> E[Compare committed catalog summary]
  D --> F{All required checks pass?}
  E --> F
  F -->|No| G[Exit with failure]
  F -->|Yes| H[Check succeeds]
Loading

Reviews (3) · Last reviewed commit: "test(mcp): load advertised schemas in th..." · Reviewed by Greptile

Comment thread scripts/verify-advertised-schemas.mjs Resolved
Comment thread scripts/verify-advertised-schemas.mjs Resolved
@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 commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

@greptileai please re-review head fc8d966 (rebased onto main 1151763). Issue 1 (helper children outlive the timeout) is fixed: helpers run under the verifier command owner (runOwnedCommand, process-group deadline), listings use the owned MCP stdio transport, and temporary roots are VerifierFixtures. Issue 2 (failure reports hide details) is fixed: each refusal prints the first complete explanation, every affected tool and exact locations. Both threads are answered and resolved.

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

… run

List the built package's tools over stdio in every input, output and
catalog profile and compile each distinct advertised regular expression
with V8 (plain, u, v), Go regexp (RE2), C++ RE2, Python re, and Rust regex
and fancy-regex through the Rust jsonschema crate. A refusal names the
engine, its error, and each tool, schema path and profile.

The Python engines are pinned, hash-checked wheels; Go is the host
toolchain with GOTOOLCHAIN=local. A missing engine is reported as not
verified, and REA_REQUIRE_SCHEMA_ENGINES=1 makes it a failure.

The pattern owner now also reports patternProperties keys, which clients
compile as well.

Refs #10830
…10983)

* test(mcp): load advertised schemas in the validators clients build

Build a validator for every distinct advertised input and output schema
with the Rust jsonschema crate's defaults, which check the declared draft's
meta-schema and formats and compile every subschema. --complete adds Python
jsonschema's check_schema, which jsonschema.validate runs in Python clients;
it takes several seconds, so it is opt-in.

Refusals are grouped by reason, so one shared pattern that breaks many
schemas is reported once with its sites.

Ajv strict mode and OpenAI strict mode are documented as not covered, with
the reasons.

Refs #10830

* ci(mcp): require the client schema engines on every code change (#10984)

* ci(mcp): require the client schema engines on every code change

Run scripts/verify-advertised-schemas.mjs at the end of the build job, after
its artifacts upload, with REA_REQUIRE_SCHEMA_ENGINES=1 so a missing engine
fails rather than passes. Go is the runner's toolchain; the Python engines
install into a virtual environment cached by the requirements file's digest
and interpreter version. Full qualification adds --complete.

Refs #10830

* test(ci): require the client schema engine step in code builds

* test(mcp): record a reviewable summary of the advertised catalog (#10985)

* test(mcp): record a reviewable summary of the advertised catalog

Commit scripts/verify/advertised-schemas/summary.json: each advertised
pattern with the tool schemas that carry it, and a digest of every tool's
schema per input or output profile. The advertised schema check compares it
with the packaged listings it already makes and fails on any difference,
printing lines such as '119 tool schemas gained pattern /.../', so a change
that reaches many tools at once is visible in review.
--update-summary regenerates it.

Refs #10830

* docs(release): check the packed catalog with client engines before publishing (#10986)

* docs(release): check the packed catalog with client engines before publishing

Add a pre-publish step to the release guide: install the packed candidate
into an empty prefix and run verify-advertised-schemas.mjs against it with
--package-root, requiring the RE2 (Go regexp and C++ RE2) and Rust (regex,
fancy-regex and jsonschema) engines. CI checks each commit's build; this
covers the archive that will be published.

Refs #10830

* docs(release): check the exact qualified archive and clean up afterwards
@morluto
morluto force-pushed the test/advertised-schema-engines branch from 761c2b1 to 12f7756 Compare November 15, 2026 12:36
@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 bd46f3c into main Nov 15, 2026
13 of 16 checks passed
@morluto
morluto deleted the test/advertised-schema-engines branch November 15, 2026 13:38
@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.

2 participants