Skip to content

feat(mcp)!: retire the full schema profiles and declare complete observations as a typed annotation - #10718

Merged
morluto merged 17 commits into
refactor/typed-root-discriminatorfrom
refactor/typed-complete-observation
Nov 15, 2026
Merged

morluto merged 17 commits into
refactor/typed-root-discriminatorfrom
refactor/typed-complete-observation

Conversation

@morluto

@morluto morluto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Breaking. This PR now carries two W3 slices: the typed complete-observation annotation (below) and #10841, which was collapsed into it and retires the full input and output schema profiles. Whichever W3 PR finally squash-merges to main must keep the ! title and the BREAKING CHANGE: footer at the end of this body.

Typed complete observations

Second slice of plan W3 step 5. The four x-rea-complete-observation markers become a typed completeObservation annotation in src/domain/schemaAnnotations.ts. Zod's override hook applies it, and only inside the advertised MCP input projection. CLI --schema and every other z.toJSONSchema caller now get the canonical schema without the private marker. Stacked on #10693.

Refs #10389 (W3 dialect work; does not close it).

Retire the full schema profiles (#10841)

Retire the full input schema profile and the full output schema profile (decision D2 in the structural cleanup plan, Phase 5). Every MCP server now advertises the compact input presentation; output schemas are either omitted (off, the default) or bounded (compact). The presentation switches, catalog identity, the build-recorded digest profiles and the recorded startup catalog collapse to what remains.

Refs #10509 (tracker under #10517). Stacked on #10718 (W3 advertised-dialect stack) because that stack owns the projector code this PR simplifies.

Problem and expected behavior

Typed complete observations

compare_web_captures accepts complete normalized_result objects from inspect_web_page, discover_webmcp_tools and capture_browser_scenario. Its advertised input shows each of them as an opaque object with an instruction, so agents are not sent the full producer schema again. That rule was written as raw .meta({ "x-rea-complete-observation": true }). The result:

  • The marker leaked into every JSON Schema projection of the input, six times in compare_web_captures.
  • The presenter (describeSchema) had to find a JSON keyword by spelling and rebuild the property description itself.

Expected: the annotation is typed, is looked up by schema identity, and applies only in the advertised projection. Advertised MCP schemas stay byte-identical.

Retire the full schema profiles

Each schema change had to be correct in 2 input × 3 output presentations (× catalog profile × families). full input is the only source of advertised constructs outside the portable dialect (#10389, a 30-key input baseline existed only for it), and full output re-advertised what REA already validates server-side. Expected after this PR:

  • tools/list input schemas are always the compact presentation (13,312-byte budget, portable dialect, guidance appended to the tool description).
  • REA_MCP_INPUT_SCHEMA_PROFILE accepts only compact; REA_MCP_OUTPUT_SCHEMA_PROFILE accepts off (default) or compact.
  • A registration that still selects full for either setting fails closed: server startup, rea mcp doctor and rea setup refuse it with a ConfigurationError whose settings names the setting and the accepted values.
  • Canonical server-side input and output validation is unchanged.

Change and scope

Typed complete observations

  • src/domain/schemaAnnotations.ts: completeObservation?: true plus presentCompleteObservation(schema). It annotates a clone, so a shared result schema keeps its full form elsewhere, including the producer's output schema. The clone inherits the source's description.
  • src/contracts/toolSchemaMetadata.ts: the advertised input projection passes override: presentAnnotatedInput to Zod. For an annotated schema, the override replaces the projected node with { type: "object", description: <own description> + <instruction> }. A non-object annotated schema throws instead of being ignored.
  • src/contracts/inputSchemaPresentation.ts: the x-rea-complete-observation branch is removed from describeSchema.
  • Sites migrated: webCaptureDiffSchemas.ts (inspection, webmcp) and browserScenarioDiffValues.ts (before_scenario, after_scenario).
  • Guard baseline raw-json-schema-meta: 23 → 19.

Property-name fallback description: the old branch prefixed the presenter's property-name fallback (fallbackPropertyDescription) to the instruction. The projection now writes the schema's own description plus the instruction, so the fallback is never consulted for these nodes. No current site depends on it. inspection, before_scenario and after_scenario carry their own descriptions. The webmcp property description is on its nullable wrapper, and its inner object had no fallback before either. The dump below shows identical output.

Not included: the constraint .meta() sites in src/domain/src/contracts, which are the next slice, and the 8 src/cli sites, which belong to the CLI registration workstream.

Retire the full schema profiles

  • Config owners (src/config/mcpInputSchemaProfile.ts, mcpOutputSchemaProfile.ts): the enums shrink, and the refusal text lives on the schema so the environment parser and the direct parser report the same constraint. COMPACT_INPUT_SCHEMA_PRESENTATION / COMPACT_OUTPUT_SCHEMA_PRESENTATION replace the compactPresentationFor… resolvers; mcpInputSchemaProfile is no longer carried in AppConfig.
  • Server: EvidenceMcpServerCore, EvidenceMcpServer, DeferredEvidenceMcpServer and createServer take a required input presentation (default compact) and default to off; the undefined = full representation and the "full" transport branch are removed.
  • Identity: CatalogDigestProfiles is keyed by output profile only (2 digests, was 6); FULL_CATALOG_IDENTITY is removed (scripts use DEFAULT_CATALOG_IDENTITY.counts).
  • Build: one recorded catalog (dist/mcp-catalog.json); mcp-catalog-full.json and the per-profile recorded SHA map are gone. src/contracts/advertisedDialectBaseline.ts is deleted; the input dialect is enforced at zero like outputs.
  • Tests and verifiers: the Vitest default REA_MCP_OUTPUT_SCHEMA_PROFILE=full, schemaVerifierEnvironment() and the local-tools fixture's full override are removed. Replies are validated against the canonical output contract (tests/fixtures/canonicalOutputSchema.ts, scripts/lib/canonical-output-schema.mjs, artifactMcpCall binds it as the SDK toolDefinition output schema); tests that asserted canonical input restrictions read advertisedInputJsonSchema instead of a full listing. Per-profile test rows that only duplicated the compact row are removed; full-only checks either moved to the canonical schema or were deleted.
  • Docs: README, its 23 translations, MCP contracts guide, client configuration, client verification, installation, testing and catalog-evaluation guides.

Not included (intentionally):

  • The deferred startup path (src/main/deferredRuntime.ts) is kept. It now serves the only recorded catalog for the default off output profile; compact output, HTTP, family scopes and Hopper targets still compose eagerly. Deleting it would move every default stdio start onto eager composition; that is a startup-time trade-off that needs measurement and maintainer buy-in, not part of this removal.
  • rea setup does not strip a stored full value; it fails closed and the migration below is documented. Stripping would mutate a caller-selected setting and touches the client table owned by another workstream.
  • Single-row it.each(["compact"]) tables left by the pruning are kept to limit churn.
  • [Design] Accept one spelling and one interpretation per analysis selector #10512 (selector spellings and Evidence flags) is untouched.

Contract and boundary impact

Typed complete observations

  • Semantic owner and earliest changed stage: schemaAnnotations.ts declares the annotation, and the advertised input projection in toolSchemaMetadata.ts applies it during Zod conversion. The presenter's JSON-keyword branch is removed.
  • Contribution scope fit and linked maintainer decision: within the approved W3 cleanup plan (step 5); no new capability.
  • CLI and MCP/tool-catalog contract: MCP tools/list is byte-identical for all 255 tools in both the compact and full profiles. Advertised output schemas are identical for 255/255. The plain z.toJSONSchema(inputSchema, { io: "input", unrepresentable: "any" }), the conversion jsonInputContentSchema uses for CLI JSON arguments, differs only for compare_web_captures. The difference is the removal of its 6 x-rea-complete-observation keys; everything else is equal. rea compare-web-captures takes its JSON documents as plain string arguments, so its --schema does not embed these schemas.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none. Runtime parsing still validates the complete canonical observation.
  • Target selection, authority, upstream behavior, and cleanup details: not applicable.
  • Generated metadata, package, or installation impact: none.

Retire the full schema profiles

  • Semantic owner and earliest changed stage: the two profile config modules own the accepted values and the refusal; catalogIdentity.ts owns the digested presentation; EvidenceMcpServerCore owns the listed presentation. Superseded: the full branches, compactPresentationFor… resolvers, FULL_CATALOG_IDENTITY, the full recorded catalog, the 6-way digest table, the input dialect baseline and schemaVerifierEnvironment.
  • Contribution scope fit and linked maintainer decision: Phase 5 / D2 of the approved plan (tracker [Design] Retire the full input schema profile and bound output schema advertisements #10509).
  • CLI and MCP/tool-catalog contract: breaking (see Compatibility). Tool names, input/output canonical contracts and result payloads are unchanged; only advertised presentations shrink.
  • 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: the package no longer contains dist/mcp-catalog-full.json; dist/recordedCatalogDigests.js records two profiles.

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

Typed complete observations

  • Tests added or updated: inputObservationPresentation.test.ts now tests the real compare_web_captures contract instead of a handwritten JSON marker. It checks:

    • The advertised inspection, webmcp and before_scenario nodes are opaque objects with their description plus the instruction.
    • normalization controls stay explicit.
    • Ajv accepts {} and rejects a string for an observation.
    • The plain z.toJSONSchema keeps the full scenario declaration with no x-rea- key.
    • inspect_web_page's output schema is unaffected.

    schemaAnnotations.test.ts checks that the annotation marks only the copy, that the canonical JSON Schema and parsing are unchanged, and that the source stays unannotated.

  • Base reproduction: the new contract test fails against the previous production code with expected '{"$schema":…' not to contain 'x-rea-'.

  • Before/after dump (executed): a throwaway tsx script started the in-memory MCP server from source with REA_MCP_INPUT_SCHEMA_PROFILE=compact and full, and recorded tools/list. It also recorded toolOutputSchemaWithMetadata(...).output(draft-2020-12) and the plain z.toJSONSchema of every TOOL_CONTRACTS input. Results on feat(mcp)!: retire the full schema profiles and declare schema facts as typed annotations #10693's head vs this branch:

    • tools/list compact: 255/255 identical.
    • tools/list full: 255/255 identical.
    • Output schemas: 255/255 identical.
    • Plain input schemas: 254 identical. compare_web_captures is equal once its 6 marker keys are removed.
  • User-visible CLI/MCP output: none changed.

  • Remaining proof gaps: CLI --schema was not run on a build. The no-change conclusion comes from source, since the command's arguments are plain strings.

Retire the full schema profiles

  • Tests added or updated: tests/conformance/contracts/mcpInputSchemaProfile.test.ts and mcpOutputSchemaProfile.test.ts assert full is refused (structured settings) by the parsers and by parseConfig; kimiClientConfiguration.test.ts asserts setup fails closed on a stored full and leaves the file unchanged, and that an explicit compact replaces it (the migration path); advertisedDialect.test.ts enforces zero input dialect violations for every remaining output × catalog profile; serverIdentity.test.ts/mcpDoctor.test.ts pin the two recorded digest profiles; outputSchemaProfile.test.ts keeps both remaining output profiles under the 1 MiB frame; deferredRuntime.test.ts compares deferred and eager listings for the single catalog.
  • Base reproduction or other evidence: on the base, parseMcpInputSchemaProfile("full") and parseMcpOutputSchemaProfile("full") return ok, so the new conformance cases fail there (source-derived; not separately re-run on the base).
  • User-visible output (executed): startup with REA_MCP_INPUT_SCHEMA_PROFILE=full prints REA configuration is invalid: REA_MCP_INPUT_SCHEMA_PROFILE accepts only "compact", the default. The "full" input profile was removed: remove the setting from the client registration, or set it to "compact". … and exits 1.
  • Remaining proof gaps: the full test suite was not run locally (CI will). connectLocalToolsMcp users outside the listTools+outputSchema set were sampled rather than all run. Real-client verifiers (Copilot, Gemini, Claude) and real-provider verifiers were edited but not executed.

Validation performed

Typed complete observations

  • npm run test:local -- src/contracts/toolSchemaMetadata.test.ts src/domain/browserScenarioDiff.test.ts src/domain/webCaptureDiff.network.test.ts src/domain/webCaptureDiff.resources.test.ts src/domain/schemaAnnotations.test.ts src/contracts/inputObservationPresentation.test.ts src/contracts/compactInputSchema.test.ts: 171 passed
  • npm run test:local -- src/contracts/inputObservationPresentation.test.ts with the production change stashed: 1 failed (the new contract test), as expected
  • node scripts/verify/architecture-guards.mjs --shrink-baselines: passed; baseline 23 → 19
  • npm run check:fast: passed
  • Before/after schema dump comparison described above

Retire the full schema profiles

  • node scripts/run-typescript.mjs --noEmit — passes.
  • npm run check:fast (typecheck + lint) — passes.
  • npm run docs:check — passes.
  • npm run test:focused over 151 files (every directly changed test file plus a 1-in-12 sample of connectLocalToolsMcp users and 1-in-4 of advertisedMcpTool/verifier-helper users), in 7 batches; every failing file was fixed and rerun. Final reruns: 44 files, 7 files, 21 files, 2 files and 5 files — all pass. One mcpDoctor.test.ts case reported a child exit code of null under concurrent load on one run and passed on rerun.
  • Pre-push hook (typecheck + lint) — passed.
  • Follow-up commit (review findings): npm run test:focused over every test combining listTools with outputSchema/toolDefinition (124 files, 5 batches) and the 24 tests that construct EvidenceMcpServer directly; the failures exposed were fixed and the final rerun (31 files) passed. npm run check:fast passes.
  • REA_MCP_INPUT_SCHEMA_PROFILE=full node scripts/rea.mjs mcp </dev/null and the same with REA_MCP_OUTPUT_SCHEMA_PROFILE=full (built runtime) — each prints REA configuration is invalid: <constraint naming the setting> and exits 1.

Stack update (main merge and review findings)

Merged current main through the stack (#10632 → #10658 → #10693 → this PR), kept the stack's newer owners in conflicts, kept the deleted input dialect baseline deleted, and lowered the raw-json-schema-meta baseline for CLI .meta() sites main already removed. Review fixes: scripts/verify-real-hopper.mjs copies process.env again instead of deleting the caller's REA_VERIFY_SERVER_* launch settings from it; every test that hands the SDK a held REA tool definition now attaches the canonical output schema with withCanonicalOutputSchema (environment-served tools, and the deferred-runtime and doctor tests that exercise per-profile listings, keep their listed definitions).

  • npm run check:fast: passed.
  • npx oxfmt --check .: passed.
  • node scripts/verify/architecture-guards.mjs: passed.
  • npm run test:focused over the 24 test files whose held definitions now carry the canonical output schema (3 batches: 15, 8 and 3 files): all pass (one batch first failed in environmentServeWritesMcp.test.ts, whose environment-served tools are not REA contracts; that file was reverted and is excluded).
  • npm run test:focused -- tests/boundary/mcp/advertisedDialect.test.ts tests/boundary/mcp/deferredRuntime.test.ts tests/boundary/mcp/mcpDoctor.test.ts src/contracts/inputObservationPresentation.test.ts src/domain/schemaAnnotations.test.ts tests/boundary/mcp/evidenceInputContractsMcp.test.ts: 140 passed.
  • Not run: the real Hopper verifier (scripts/verify-real-hopper.mjs) needs a real Hopper install; the fix is source-derived and restores main's { ...process.env }.

Compatibility, safety, and release

  • Breaking changes or migration steps:
    • Previous configuration: REA_MCP_INPUT_SCHEMA_PROFILE=full (complete advertised input guidance) or REA_MCP_OUTPUT_SCHEMA_PROFILE=full (complete output schemas in tools/list).
    • New behaviour: the server, rea mcp doctor and rea setup refuse either value with a configuration error naming the setting.
    • Migration: remove the setting from the client registration's env, or rerun REA_MCP_INPUT_SCHEMA_PROFILE=compact rea setup --client <id> (respectively REA_MCP_OUTPUT_SCHEMA_PROFILE=compact) so setup replaces the stored value. Clients that validated results against listed output schemas should rely on REA's server-side validation, which is unchanged.
    • Why compatibility cannot be preserved: keeping full as an accepted alias would either advertise a different presentation (keeping the extra matrix this removes) or silently ignore an explicit caller choice; failing closed with the setting named is the documented fail-closed rule.
  • Real Hopper/Ghidra, browser, or OS coverage: none run; no provider behaviour changes.
  • Package or release metadata impact: dist/mcp-catalog-full.json removed; breaking marker on the commit.
  • Security, privacy, process, or containment review: no new authority; only advertised presentations shrink.

The typed-observation slice itself changes no advertised schema; the canonical JSON Schema of compare_web_captures input no longer carries the private x-rea-complete-observation key.

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.

BREAKING CHANGE: REA_MCP_INPUT_SCHEMA_PROFILE=full and REA_MCP_OUTPUT_SCHEMA_PROFILE=full are removed. The server, rea mcp doctor and rea setup refuse either value with a configuration error naming the setting. Migration: remove the setting from the client registration's env, or rerun setup with REA_MCP_INPUT_SCHEMA_PROFILE=compact / REA_MCP_OUTPUT_SCHEMA_PROFILE=compact so it replaces the stored value. tools/list now always advertises the compact input presentation and omits output schemas by default (compact bounds them); the package no longer ships dist/mcp-catalog-full.json. Server-side input and output validation is unchanged, so clients that validated results against listed full output schemas should rely on it.

@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-15T11:08:02.909110Z
We couldn’t complete this review. Comment @codex review to try again.
3ae2921 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

[High impact] The reviewed changes appear safe to merge; no new blocking issue was established.

Summary

The PR replaces raw observation markers with typed annotations and retires the full schema profiles.

  • MCP servers always list compact input schemas and no longer offer full schema profiles.
  • Comparison tools show complete observations as opaque inputs with guidance.
  • Shared schema helpers keep runtime checks and JSON Schema declarations together.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Canonical Zod contracts] --> B[Server input and output checks]
  A --> C[Advertised input projection]
  D[Typed observation annotations] --> C
  C --> E[Compact input schemas and guidance]
  A --> F[Canonical output projection]
  F --> G{Output profile}
  G -->|off| H[Omit output schemas]
  G -->|compact| I[Bound output schemas]
  E --> J[MCP tools/list]
  H --> J
  I --> J
Loading

Reviews (16) · Last reviewed commit: "Merge branch 'w3/10693' into w3/10718" · Reviewed by Greptile

# Conflicts:
#	scripts/verify/architecture-guard-baselines.json
… keywords (#10725)

* refactor(schema): couple Zod checks with their JSON Schema constraint keywords

* refactor(schema): declare pattern approximations and object output roots as typed annotations (#10754)

* refactor(schema): declare pattern approximations and object output roots as typed annotations

* fix(schema): refuse pattern declarations JSON Schema cannot state

* test(schema): select guided_workflows from its contract family

@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: 83a8b669a0

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

* feat(mcp)!: retire the full input and output schema profiles

The compact input presentation is now the only advertised input schema, and
output schemas are either omitted (`off`, the default) or bounded
(`compact`). Catalog identity, the build-recorded digests and the recorded
startup catalog collapse to those presentations: two digest profiles instead
of six, one recorded catalog instead of two, and no input dialect baseline.

Tests and verifiers that validated replies against listed full output
schemas now validate against the canonical output contract, which REA
already enforces server-side; tests that asserted canonical input
restrictions read the canonical input schema instead of a full listing.

BREAKING CHANGE: `REA_MCP_INPUT_SCHEMA_PROFILE=full` and
`REA_MCP_OUTPUT_SCHEMA_PROFILE=full` are refused at startup and by `rea setup`
with a configuration error naming the setting. Remove the setting from the
client registration (or rerun setup with `REA_MCP_INPUT_SCHEMA_PROFILE=compact`
/ `REA_MCP_OUTPUT_SCHEMA_PROFILE=compact`). `REA_MCP_INPUT_SCHEMA_PROFILE`
still accepts `compact`. Server-side validation is unchanged.

* test(mcp): validate replies against canonical output contracts at every listed-schema reader

tools/list omits output schemas by default, so fixtures, verifiers and the
Android analysis runners that read a listed outputSchema now bind the
canonical contract instead. connectLocalToolsMcp and advertisedMcpToolSchemas
hand the SDK a definition carrying the canonical output schema, so the SDK
client and caller-supplied validators check every successful reply.

* test(mcp): resolve Android runners' output contracts from the selected repository

The Android efficiency runners imported the canonical output-schema helper from the harness checkout while --repository selects the revision under test. Import it from the selected repository, as the runners already do for the SDK and Ajv.

* test(mcp): let Android runners compare revisions before the canonical output helper

A selected revision without scripts/lib/canonical-output-schema.mjs could not start the Android runners. Choose the output contracts in one harness helper: the selected revision's canonical contracts when it has them, otherwise its listed schemas under the full output profile it still supports.
Comment thread scripts/verify-real-hopper.mjs Resolved
Comment thread src/config/mcpInputSchemaProfile.ts Resolved
# Conflicts:
#	docs/development/testing.md
#	scripts/verify/architecture-guard-baselines.json
#	src/contracts/advertisedDialectBaseline.ts
…er builds its server environment

The verifier deleted REA_VERIFY_SERVER_COMMAND and REA_VERIFY_SERVER_ARGS_JSON from process.env itself before reading them, so a caller selecting an installed REA command silently ran the checkout's dist/main.js. Copy the environment, as main does, so only the child's environment changes.
…wherever a listed definition is held

tools/list omits output schemas by default and the full output profile is gone, so tests that handed the SDK a listed definition no longer checked complete replies. Attach the canonical output schema with withCanonicalOutputSchema at every held REA tool definition. Environment-served tools (not REA contracts), and the deferred-runtime and doctor tests that exercise per-profile listings, keep their listed definitions.
@morluto morluto changed the title refactor(mcp): declare complete observations as a typed annotation applied only on the wire feat(mcp)!: retire the full schema profiles and declare complete observations as a typed annotation Nov 15, 2026
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

@greptileai Both summary points from review 12 are addressed; please re-review the current head.

  • Whole-reply checks: every test that hands the SDK a held REA tool definition attaches the canonical output schema with withCanonicalOutputSchema (0b5a7b0, 25 files). The remaining toolDefinition sites without it are intentional. environmentServeWritesMcp.test.ts calls environment-served tools (patch_books, ...) that have no REA contract, so canonicalOutputSchema throws No tool contract named patch_books. deferredRuntime.test.ts, mcpDoctor.test.ts and stdioFrameDiagnostics.test.ts exercise the listing a given output profile produces, including the off listing without output schemas. Validation: npm run test:focused over the 24 changed boundary/process/acceptance files passed.
  • Migration visibility: the title now carries !, and the body describes the full input/output profile removal, the fail-closed refusal, migration steps and current validation. It ends with a BREAKING CHANGE: footer. The collapsed feat(mcp)!: retire the full input and output schema profiles #10841 commit (414a359) carries the same footer.

@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 4c9fed9 into refactor/typed-root-discriminator Nov 15, 2026
2 checks passed
@morluto
morluto deleted the refactor/typed-complete-observation branch November 15, 2026 11:10
morluto added a commit that referenced this pull request Nov 15, 2026
…as typed annotations (#10693)

* test(mcp): check advertised schemas against a portable dialect in every profile

* fix(mcp): re-emit advertised patterns in a portable regex grammar

* fix(mcp): present discover_tools input through the selected profile

The hot-cold catalog registered discover_tools directly with the SDK, so
the default compact input profile still advertised its canonical schema,
including page-size defaults clients apply on their own (#5322). Route
every listed input schema, transport discovery included, through one
server-owned presentation, and pass the selected presentation to the
deferred server, which serves recorded tool schemas but not discovery.

* fix(mcp): keep the Evidence union on described borrowed inputs

borrowEvidenceInput installed its advertised projection on one schema
instance. A call site's .describe() rebuilds the schema from its
definition, so match_native_functions advertised left and right as
unconstrained values in every input profile. Install the projection in
the borrowed parser's constructor so derived schemas keep it, for both
borrowed inputs and borrowed arrays.

* fix(mcp): validate advertised dialect by selected profile

* fix(mcp): preserve schema widening through references

* feat(mcp): project compact input schemas into the portable advertised dialect

One projection (advertisedDialectProjection.ts) owns the compact input
advertisement: one type per node, items on every array, string literals
as enums, oneOf widened to anyOf, allOf merged, tuples as element unions,
exclusive bounds made inclusive, and every keyword outside the dialect
dropped. Each rewrite is exact or widening; server validation is
unchanged. The root description and sentences for dropped cross-field
constraints move to the tool description, which Codex and Zed keep.

The compact baseline falls to nullable values only (29), which the
dialect cannot express without narrowing an input. The gateway shape
repairs (typeArrayItemUnions, hasGatewayIncompatibleShape), the second
dependentRequired-to-prose copy and the strict-gateway test denylist are
removed; the dialect checker gates the inline presentation instead.

* feat(mcp): omit output schemas from tools/list by default

No surveyed model API reads an output schema, MCP client validators
repeat REA's own result validation, and complete output schemas were
about 92% of the default tools/list. REA_MCP_OUTPUT_SCHEMA_PROFILE now
resolves to off through one owner (resolveMcpOutputSchemaProfile);
compact and full remain selectable. structuredContent is still
delivered, and the deferred server serves both off and full from the
recorded catalog with the matching recorded identity.

Tests and artifact verifiers that validate results against complete
advertised output contracts select full explicitly.

* docs: describe omitted output schemas as the default in README translations

* fix(mcp): select schemas in verification workflows

* fix(mcp): refuse zero-padded repeat bounds and record host-specific path patterns

* fix(mcp): keep projected schemas permissive

* fix(mcp): keep references valid when presentation widens their targets

* fix(mcp): keep a single union branch's closure scoped to its properties

* fix(mcp): select complete output schemas in the Electron verifier

* fix(mcp): select complete output schemas in standalone verifier probes

* fix(mcp): keep an allOf member's tuple tail with its own positions

* fix(mcp): relax references into negations and conditionals presentation may remove

* refactor(contracts): declare root discriminators as typed schema annotations

* test(mcp): select the borrowed Evidence contract from its family

* fix(mcp): keep astral literals and dynamic references widening in every mode

* fix(mcp): omit astral literals and relax untracked references when presentation widens

* fix(mcp): select complete output schemas in every verifier transport

* fix(mcp): read reference pointers by schema position, not segment spelling

* fix(mcp): protect references into collapsing boolean unions and keep referencing branches out of the collapse

* fix(mcp): keep reduced schemas open when their root admits names by pattern

* test(mcp): keep the reduced-schema pattern case outside the size-limited block

* fix(mcp): omit patterns whose classes name astral characters

* fix(mcp): decide union collapse and pointer protection from canonical branches

* docs(mcp): document non-u astral matching and pin BMP agreement across V8 modes

* fix(mcp): keep prototype-named properties as own properties in the dialect projection

* test(mcp): select full output schemas in packet and signal schema checks

* test(mcp): expect the advertised base64 schema to omit the unbounded pad-bit probe

* fix(mcp): protect references into unevaluated keywords lost evaluation removes

* fix(mcp): validate the doctor probe reply against the canonical output contract (#10655)

* fix(mcp): validate the doctor probe reply against the canonical output contract

* test(mcp): replay doctor probe validation under every output profile

* test(mcp): accept typed-branch nullable unions in the advertised dialect (#10649)

* test(mcp): select full output schemas in HTTP session workflows

* fix(mcp): emit stack-safe classes with non-ASCII members and protect draft-07 reference siblings

* fix(mcp): protect references into literal siblings of relaxed draft-07 references

* feat(mcp): omit output schemas from tools/list by default (#10646)

* feat(mcp): omit output schemas from tools/list by default

No surveyed model API reads an output schema, MCP client validators
repeat REA's own result validation, and complete output schemas were
about 92% of the default tools/list. REA_MCP_OUTPUT_SCHEMA_PROFILE now
resolves to off through one owner (resolveMcpOutputSchemaProfile);
compact and full remain selectable. structuredContent is still
delivered, and the deferred server serves both off and full from the
recorded catalog with the matching recorded identity.

Tests and artifact verifiers that validate results against complete
advertised output contracts select full explicitly.

* fix(mcp): select schemas in verification workflows

* fix(mcp): select complete output schemas in the Electron verifier

* fix(mcp): select complete output schemas in standalone verifier probes

* fix(mcp): select complete output schemas in every verifier transport

* test(mcp): select full output schemas in packet and signal schema checks

* fix(mcp): validate the doctor probe reply against the canonical output contract (#10655)

* fix(mcp): validate the doctor probe reply against the canonical output contract

* test(mcp): replay doctor probe validation under every output profile

* test(mcp): accept typed-branch nullable unions in the advertised dialect (#10649)

* test(mcp): select full output schemas in HTTP session workflows

* fix(mcp): keep the Evidence union on described borrowed inputs (#10597)

* fix(mcp): keep the Evidence union on described borrowed inputs

borrowEvidenceInput installed its advertised projection on one schema
instance. A call site's .describe() rebuilds the schema from its
definition, so match_native_functions advertised left and right as
unconstrained values in every input profile. Install the projection in
the borrowed parser's constructor so derived schemas keep it, for both
borrowed inputs and borrowed arrays.

* test(mcp): select the borrowed Evidence contract from its family

* docs(mcp): admit baseline growth only for restored contract declarations

* fix(mcp): state reduced multi-type properties as typed branches, not type lists

The reduced fallback derived a property's types and emitted them as a type
list, which Gemini, Moonshot and Ark reject. A property whose canonical
schema is anyOf string and number therefore traded a typed union for a
rejected construct when the inline projection fell back. Emit one type, or
anyOf typed branches, so [T, null] becomes the dialect's nullable union.

* feat(mcp)!: retire the full schema profiles and declare complete observations as a typed annotation (#10718)

* refactor(mcp): declare complete observations as a typed annotation applied only on the wire

* test(mcp): compare complete-observation declarations with their owning text

* refactor(schema): couple Zod checks with their JSON Schema constraint keywords (#10725)

* refactor(schema): couple Zod checks with their JSON Schema constraint keywords

* refactor(schema): declare pattern approximations and object output roots as typed annotations (#10754)

* refactor(schema): declare pattern approximations and object output roots as typed annotations

* fix(schema): refuse pattern declarations JSON Schema cannot state

* test(schema): select guided_workflows from its contract family

* feat(mcp)!: retire the full input and output schema profiles (#10841)

* feat(mcp)!: retire the full input and output schema profiles

The compact input presentation is now the only advertised input schema, and
output schemas are either omitted (`off`, the default) or bounded
(`compact`). Catalog identity, the build-recorded digests and the recorded
startup catalog collapse to those presentations: two digest profiles instead
of six, one recorded catalog instead of two, and no input dialect baseline.

Tests and verifiers that validated replies against listed full output
schemas now validate against the canonical output contract, which REA
already enforces server-side; tests that asserted canonical input
restrictions read the canonical input schema instead of a full listing.

BREAKING CHANGE: `REA_MCP_INPUT_SCHEMA_PROFILE=full` and
`REA_MCP_OUTPUT_SCHEMA_PROFILE=full` are refused at startup and by `rea setup`
with a configuration error naming the setting. Remove the setting from the
client registration (or rerun setup with `REA_MCP_INPUT_SCHEMA_PROFILE=compact`
/ `REA_MCP_OUTPUT_SCHEMA_PROFILE=compact`). `REA_MCP_INPUT_SCHEMA_PROFILE`
still accepts `compact`. Server-side validation is unchanged.

* test(mcp): validate replies against canonical output contracts at every listed-schema reader

tools/list omits output schemas by default, so fixtures, verifiers and the
Android analysis runners that read a listed outputSchema now bind the
canonical contract instead. connectLocalToolsMcp and advertisedMcpToolSchemas
hand the SDK a definition carrying the canonical output schema, so the SDK
client and caller-supplied validators check every successful reply.

* test(mcp): resolve Android runners' output contracts from the selected repository

The Android efficiency runners imported the canonical output-schema helper from the harness checkout while --repository selects the revision under test. Import it from the selected repository, as the runners already do for the SDK and Ajv.

* test(mcp): let Android runners compare revisions before the canonical output helper

A selected revision without scripts/lib/canonical-output-schema.mjs could not start the Android runners. Choose the output contracts in one harness helper: the selected revision's canonical contracts when it has them, otherwise its listed schemas under the full output profile it still supports.

* fix(scripts): keep caller launch settings when the real Hopper verifier builds its server environment

The verifier deleted REA_VERIFY_SERVER_COMMAND and REA_VERIFY_SERVER_ARGS_JSON from process.env itself before reading them, so a caller selecting an installed REA command silently ran the checkout's dist/main.js. Copy the environment, as main does, so only the child's environment changes.

* test(mcp): validate whole replies against canonical output contracts wherever a listed definition is held

tools/list omits output schemas by default and the full output profile is gone, so tests that handed the SDK a listed definition no longer checked complete replies. Attach the canonical output schema with withCanonicalOutputSchema at every held REA tool definition. Environment-served tools (not REA contracts), and the deferred-runtime and doctor tests that exercise per-profile listings, keep their listed definitions.

* test(mcp): record the advertised catalog summary without the retired full profiles

Retiring the full input and output profiles leaves only the compact input and compact output listings, so the summary drops the full-profile digests and every pattern only the full listings carried. Regenerated with npm run verify:advertised-schemas -- --update-summary.
@morluto morluto added area: mcp MCP server, transport, and tool registration enhancement New feature or request labels 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 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant