Skip to content

feat(mcp)!: retire the full schema profiles and declare schema facts as typed annotations - #10693

Merged
morluto merged 133 commits into
mainfrom
refactor/typed-root-discriminator
Nov 15, 2026
Merged

morluto merged 133 commits into
mainfrom
refactor/typed-root-discriminator

Conversation

@morluto

@morluto morluto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Breaking. This W3 base PR now carries its collapsed stack: root discriminators as typed annotations (this PR), #10718 (typed complete observations, plus the typed schema constraints from #10725) and #10841, which retires the full input and output schema profiles. The squash commit to main must keep the ! title; the BREAKING CHANGE: footer is at the end of this body and in the collapsed commits' messages.

Typed root discriminators

First slice of plan W3 step 5: presentation facts become typed schema annotations instead of raw JSON Schema written through Zod .meta(). This slice moves the six x-rea-root-discriminator markers to a typed registry in src/domain/schemaAnnotations.ts that the input presenter reads, and adds a counted guard so new raw .meta() JSON Schema cannot be added. Stacked on #10658.

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

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

Problem and expected behavior

Typed root discriminators

x-rea-root-discriminator was written into each root union's Zod metadata as a JSON Schema extension keyword. The presenter then had to find it in the projected JSON Schema and strip it. Because it was raw metadata, the marker also appeared in every other z.toJSONSchema projection of those six schemas. Nothing checked its value either: a misspelled property name would only show up as a runtime TypeError during presentation.

Expected: the presenter receives the discriminator as a typed argument looked up by schema identity. The canonical JSON Schema no longer carries a presentation marker. The discriminator name is type-checked against the union's declared properties.

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 root discriminators

  • src/domain/schemaAnnotations.ts (new owner): a Zod registry of SchemaAnnotations that never enters toJSONSchema output. presentRootDiscriminator(schema, key) accepts only a union of two objects and a key declared by its alternatives (keyof z.input<Schema>). It lives in domain/ because apiContractQuery.ts is a domain schema.
  • presentInputJsonSchema takes the annotations as a parameter, and toolSchemaMetadata.ts passes schemaAnnotations(contract.inputSchema). The JSON-level marker read and strip are removed.
  • Six sites migrated: inspect_python_pyc, inspect_erlang_beam, analyze_web_bundle, analyze_javascript_application, trace_web_source_location, inspect_api_contract.
  • Guard: raw-json-schema-meta in scripts/verify/architecture-guards.mjs. It flags a .meta({...}) whose first key is a JSON Schema keyword or x-rea-*. The counted baseline holds the 23 remaining sites (29 before this PR) and can only shrink.

Not included, left for later slices:

  • x-rea-complete-observation (4 sites in webCaptureDiffSchemas.ts and browserScenarioDiffValues.ts). These are nested schemas, so the presenter can only see them through Zod's override hook, which also changes other toJSONSchema callers.
  • The constraint sites (not, allOf, dependentRequired, if, uniqueItems, and others) in src/domain and src/contracts.
  • The src/cli sites, which belong to the CLI registration workstream.

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 root discriminators

  • Semantic owner and earliest changed stage: src/domain/schemaAnnotations.ts owns presentation annotations, and inputSchemaPresentation.ts consumes them. The superseded JSON marker path 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: advertised MCP input schemas are byte-identical for all 255 tools (measured below). The canonical z.toJSONSchema of the six root schemas no longer contains "x-rea-root-discriminator". Those roots are not exposed by the CLI: no src/cli module references them, and contract-backed CLI commands need a ZodObject .shape, which a union does not have. The registered MCP wrappers already stripped the marker before this change.
  • 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.

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 root discriminators

  • Tests added or updated: src/domain/schemaAnnotations.test.ts (new). It checks that the annotation stays out of the canonical JSON Schema, which equals that of an unannotated copy. It also checks that the lookup follows Zod clones (.describe) but not wrappers or other schemas, and that a name the alternatives do not declare is a type error (@ts-expect-error). javascriptRouteDeliveryContracts.test.ts and bytecodeDeliveryContracts.test.ts now assert that the presented root carries the discriminator's if instead of asserting a marker is absent.
  • Base reproduction or other evidence: executed. A throwaway Vitest dump wrote advertisedInputJsonSchema(contract) and the canonical z.toJSONSchema(contract.inputSchema, { io: "input" }) for every TOOL_CONTRACTS entry, once on the base and once on this branch. Advertised schemas: identical for 255/255 tools. Canonical schemas: only these six differ, and only by the removed x-rea-root-discriminator key.
  • User-visible CLI/MCP output: none changed (see above).
  • Remaining proof gaps: CLI --schema was not run on a build. The no-change conclusion for the CLI comes from source.

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 root discriminators

  • npx vitest run src/domain/schemaAnnotations.test.ts src/contracts/javascriptRouteDeliveryContracts.test.ts src/contracts/bytecodeDeliveryContracts.test.ts src/contracts/inputObservationPresentation.test.ts src/contracts/toolSchemaMetadata.test.ts: 42 passed
  • node scripts/verify/architecture-guards.mjs: passed. Before the baseline was seeded it failed and listed the 23 remaining sites.
  • npx tsc --noEmit -p tsconfig.json: passed
  • npm run check:fast: passed
  • Before/after schema dump comparison described above: advertised schemas unchanged.

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

Main merge after the collapse

Merged current main (ec7de82). Conflicts resolved toward main's newer owners where they exist: toolSchemaMetadata.ts keeps main's shareOutputDefinitions (#11005) around this stack's object-root projection; the verifiers keep main's cleanup helpers (withVerifierCleanup) beside this stack's canonicalOutputSchema, and drop the retired schemaVerifierEnvironment; kimiClientConfiguration.test.ts keeps main's new registration-status assertion, with the profile set to compact; progressiveAnalysisViews.test.ts expects the default listing to omit output schemas. src/contracts/advertisedDialectBaseline.ts stays deleted; main changed only a full-profile count there. #10982 committed scripts/verify/advertised-schemas/summary.json, so 2593bfb regenerates it: only input compact/output compact digests remain, and the patterns that only the full listings carried are gone.

  • npx oxfmt --check ., npm run check:fast, node scripts/verify/architecture-guards.mjs: passed (the pre-push hook ran typecheck, lint and the guards).
  • npm run test:focused -- tests/boundary/mcp/advertisedDialect.test.ts tests/boundary/filesystem/kimiClientConfiguration.test.ts tests/acceptance/applications/progressiveAnalysisViews.test.ts src/contracts/toolSchemaMetadata.test.ts tests/boundary/filesystem/ciRequiredLanes.test.ts tests/boundary/mcp/deferredRuntime.test.ts tests/boundary/mcp/mcpDoctor.test.ts src/contracts/inputObservationPresentation.test.ts: 188 passed.
  • npm run verify:advertised-schemas -- --update-summary: 4 packaged catalogs, 253 distinct schemas, 31 distinct patterns, all accepted by V8 (plain, u, v), Go RE2, Python re and RE2 C++. The Rust engines (jsonschema-rs) are not installed locally, so they did not run here; CI requires them.

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.

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.
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.
… into HEAD

# Conflicts:
#	scripts/lib/verify-package-core.mjs
#	src/contracts/advertisedDialectBaseline.ts
#	tests/boundary/mcp/advertisedDialect.test.ts
… 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.
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.
# Conflicts:
#	tests/boundary/mcp/advertisedDialect.test.ts
# Conflicts:
#	docs/development/testing.md
#	scripts/lib/verify-package-core.mjs
#	src/contracts/advertisedDialectBaseline.ts
#	tests/boundary/mcp/advertisedDialect.test.ts
#	tests/boundary/mcp/advertisedPatternsVMode.test.ts
Plastic-time added a commit to Plastic-time/rea that referenced this pull request Nov 15, 2026
Main morluto#10693 retired the full schema profiles and deleted
src/contracts/advertisedDialectBaseline.ts. The merge keeps the deletion,
so this PR no longer raises that baseline.
mvanhorn added a commit to mvanhorn/rea that referenced this pull request Nov 15, 2026
Main replaced the per-tool register files with the service binding table
(morluto#11264) and declares standalone availability on contracts (morluto#11262), so
inspect_deb_package now binds through serviceToolBindings, declares
availability "standalone", and registerDebPackageTool.ts is removed.

The default MCP profile no longer lists output schemas (morluto#10693), so the
deb MCP test validates the canonical contract output schema instead.
morluto added a commit that referenced this pull request Nov 15, 2026
…helpers

The last raw JSON Schema keywords in CLI .meta() calls move to src/domain/schemaConstraints helpers: requirePresence gains requiresValue (the --outline-depth rule) and jsonDocumentText declares JSON document arguments. contractCliDescription reads the root discriminator from its typed annotation; since #10693 the x-rea-root-discriminator keyword no longer reached .meta(), so the check that the discriminator is the delivery's was dead. The raw-json-schema-meta baseline is now empty.
morluto added a commit that referenced this pull request Nov 15, 2026
…the remaining held listed definitions (#11182)

* test(mcp): check whole replies against canonical output contracts at the remaining held listed definitions

Retiring the full output profile (#10693) left listed tool definitions without output schemas, so tests that handed one to the SDK as toolDefinition stopped validating complete replies. Attach the canonical output schema with withCanonicalOutputSchema at the 41 remaining sites in 28 files that hold a definition taken directly from tools/list.

* test(mcp): check continuation pages against the canonical output contract
morluto added a commit that referenced this pull request Nov 15, 2026
…helpers (#11205)

The last raw JSON Schema keywords in CLI .meta() calls move to src/domain/schemaConstraints helpers: requirePresence gains requiresValue (the --outline-depth rule) and jsonDocumentText declares JSON document arguments. contractCliDescription reads the root discriminator from its typed annotation; since #10693 the x-rea-root-discriminator keyword no longer reached .meta(), so the check that the discriminator is the delivery's was dead. The raw-json-schema-meta baseline is now empty.
Davmunrey added a commit to Davmunrey/rea that referenced this pull request Nov 16, 2026
Main changed three English README passages after the Hindi edition was
written: morluto#10693 retired the full input schema profile, morluto#10632 made
output schemas omitted from tools/list by default with an opt-in
compact profile, and morluto#10755 runs a system ps instead of one on REA's
PATH. The Hindi text still recommended REA_MCP_INPUT_SCHEMA_PROFILE=full,
which the server now refuses, and said complete output schemas were the
default.

The two schema paragraphs and the Linux ps requirement now say what the
English README says.
@morluto morluto added area: mcp MCP server, transport, and tool registration enhancement New feature or request labels Nov 22, 2026
morluto added a commit that referenced this pull request Nov 26, 2026
…#10689)

* feat(artifacts): inspect Debian package control metadata and contents

* fix(deb): throw ParseFailureError and record the new tool's schema counts

DebPackageFormatFailure now extends ParseFailureError, as the architecture
guard requires of parser failure classes; its kind, partial and message are
unchanged. The advertised-dialect baseline takes the counts the
inspect_deb_package input schema adds ($schema in both profiles, and allOf,
default, examples, the \/ escape, the unanchored path pattern and untyped
nodes in the full profile).

* docs(deb): say dpkg runs maintainer scripts, not dpkg-deb

dpkg-deb only reads the archive; installing with dpkg is what runs the
maintainer scripts. Correct the spec so the safety rationale names the
right tool.

* refactor(deb): project format failures through parseFailureAnalysisError

The provider now maps DebPackageFormatFailure with the shared
parseFailureAnalysisError instead of its own instanceof ladder, passing the
partial ar/control/data observation as diagnostics. The helper takes that
optional diagnostics argument. DebPackageCapacityFailure extends
ParseFailureError<"limit"> with the resource and maximum as its limit, and
the provider keeps its limit recovery.

* test(deb): resolve inspect_deb_package from its contract family

The CLI acceptance and MCP boundary tests now take the contract from
DEB_PACKAGE_TOOL_CONTRACTS instead of the full catalog, as the testing guide
asks of focused contract tests.

* fix(deb): require debian-binary and a control file for complete coverage

Coverage was complete with a missing or empty debian-binary, or a control.tar
that held no control file. It now needs a known format version and the
control file as well as the control and data members, and each gap adds a
limitation.

* fix(deb): count hardlinks in the md5sums path cross-check

dpkg lists every name of a hardlinked file in md5sums, while tar stores the
later names as hardlink entries. The cross-check inventory now takes
hardlink paths as well as regular files, so those names are no longer
counted missing.

* fix(deb): decode xz only when its index declares a size within the limit

The sync @napi-rs/lzma decoder takes no output bound, so a member whose
index could not be read was decoded with no limit and checked only after
allocation. decodeXz now refuses such a member, as truncated when the footer
is missing and malformed otherwise, before calling the decoder.

* fix(deb): leave the md5sums cross-check unknown when an input is unread

md5sums that is not UTF-8 counted as zero listed paths, and a package with
no data.tar counted as an empty inventory. The cross-check is now computed
only when both were read; otherwise it stays null and a limitation says
which input was missing.

* fix(deb): refuse Version and Installed-Size values the output schema rejects

A Version with an empty upstream part or Debian revision (1:, 1:-1, 1.0-)
and an Installed-Size past the safe integer range reached DebControl and
failed the output schema, so the service lost the report. The parser now
records a malformed field issue and leaves the value null.

* build(deb): declare src/deb as a provider module layer

Main now requires every top-level src unit in UNIT_LAYERS. src/deb is a
provider like src/sqlite, and its two type imports of application ports
are recorded in the upward-import baseline the same way. The xz spy
binding now accepts the string or bytes input XzApi.compressSync takes.

* fix(deb): keep tar names and link targets as stored

Read ustar name, prefix and linkname fields, and GNU long names, as
NUL-terminated UTF-8 without trimming or rewriting backslashes, and keep
spaces in md5sums paths. A name that is not UTF-8 is shown with U+FFFD
replacements and counted in a limitation, since it may not match md5sums.

* fix(deb): read control files from the control.tar root only

Look up control, conffiles, md5sums and maintainer scripts by their
normalized root path, so a nested subdir/control or subdir/postinst no
longer stands in for the root file.

* fix(deb): read PAX records by byte length

PAX record lengths count bytes, so walk the extended header bytes and
decode each record on its own. A UTF-8 path no longer swallows part of
the next record. A path or linkpath record that is not UTF-8 is counted
in the same not-UTF-8 limitation as ustar names.

* fix(deb): keep unreadable relationship alternatives as issues

Accept hyphenated architecture qualifiers such as kfreebsd-amd64, and
have parseDebianRelationshipField return the alternatives it cannot
read. parseControl records each as a malformed issue on its field, so
the package reports partial coverage instead of dropping a dependency.

* fix(deb): deliver the whole partial report on a refusal

A Debian package refusal now carries the bounded partial report as
diagnostics.partial, so control facts, relationships, maintainer-script
facts, ar member offsets and file rows read before the failure reach CLI
and MCP callers, not just member names and a count.

* fix(deb): decode only the maintainer script interpreter line

interpreterLine now finds the first newline in the script bytes and
decodes only the #! line, so non-UTF-8 bytes later in the script, or a
cut through a multi-byte character at byte 256, no longer hide a valid
interpreter.

* fix(deb): bound unreadable relationship diagnostics per field

parseDebianRelationshipField now counts unreadable alternatives and keeps
only the first, and parseControl records one issue per field with that
count and the first term cut to 120 characters, so a field of many `|`
separators no longer grows the report with its input.

* test(deb): check parser guidance through its owning formatters

Export undecodableTarNamesLimitation and unreadableRelationshipsDetail
from the parser and assert delivered limitations and issue details
through them, so wording edits change one place.

* fix(deb): bound PAX header work before each tar entry

Keep only the path and linkpath PAX keys the reader uses, set in place
rather than copying an accumulated object per header, and refuse more
than eight GNU long name/link or PAX headers before one entry as
malformed, so a run of short PAX headers cannot stall the server.

* fix(deb): apply PAX owner records to the following entry

PAX uid, gid, uname and gname now override the fixed ustar fields,
which can hold shortened or fallback values. A uid or gid that is not a
safe decimal integer falls back to the fixed field.

* fix(deb): keep GNU ar string tables as counted members

A // string-table member is now kept in the ar inventory and counted
against max_ar_members like any other member. As an unknown role it is
listed in extra_member_names, so coverage reports partial.

* fix(deb): honor PAX size records and escaped md5sums names

- A PAX size record overrides the next entry's ustar size field. Reading
  and skipping by the header field reported an empty file and then parsed
  its data as a header, refusing a valid archive.
- GNU md5sum writes a leading backslash and escapes names that contain a
  backslash, newline or carriage return. Those lines were dropped, so the
  cross-check counted listed files as missing; they are now read, and lines
  that are not digest lines are counted in a limitation.

* fix(deb): bound relationship alternatives and read PAX headers faithfully

- Count relationship alternatives across the control file before building
  any, refusing more than a fixed 65,536; a field of '|' separators within
  the control budget could build millions of report objects.
- Refuse a PAX extended header whose record length is unreadable or runs
  past the member, instead of using the fields read so far.
- Keep global (g) PAX values for every later entry and per-file (x) values
  for the next entry only; global values were cleared after the first file.

* refactor(deb): drop an unused import

* chore(mcp): drop the dialect baseline main retired in #10693

* fix(analysis-view): call completeWithinViewCoverage with main's single count

Main dropped its redundant second argument; both arguments were the same
count here.

* test(mcp): record this PR's advertised-schema summary

Add the advertised-schema summary for inspect_deb_package, generated
with npm run verify:advertised-schemas -- --update-summary.

* fix(deb): bound repeated global PAX text and accept xz stream padding

A global PAX path, linkpath, uname or gname is copied into every later
row, so each reuse is now charged to the member byte budget
(max_data_bytes or max_control_bytes) and refused before the row is
added. An empty global PAX value now deletes the earlier global
override, so later entries read their header owner again.

xzUncompressedSize and the footer check skip trailing zero Stream
Padding in 4-byte groups before locating the footer, so valid padded
xz members are no longer reported as truncated.

* fix(deb): trim trailing tar path slashes with a backward scan

The unanchored /\/+$/u retried from every slash, so a PAX path or
md5sums name made of a long slash run and a final non-slash took
quadratic time. logicalTarPath now trims trailing slashes with a
linear charCodeAt scan from the end.

* fix(deb): parse global PAX owner ids once per global record

Global uid and gid values were run through paxId for every later
entry, and the repeated-text budget skips numeric keys, so a long
global owner value was rescanned once per row. Parse them when the
global record is read and reuse the numbers.

* refactor(deb): report coverage with the shared coverage status schema

* refactor(deb): classify provider failures through classifyProviderFailure

* fix(deb): bound resolved ar member names before copying them

GNU ar /N references can repeat one string-table entry without charging
its text to any budget, and every resolved name is copied into the report
and its Evidence. Refuse a BSD or GNU long name above 4096 bytes before it
is read or sliced, so repeated references cannot expand a small table into
large report text.

* test(deb): register the debPackage capability conformance case

debPackage is declared in CAPABILITY_DECLARATIONS but had no entry in
PROVIDER_CAPABILITY_CONFORMANCE, so the conformance suite failed for it.
Name the existing Debian package CLI acceptance test as its case.

* fix(deb): flag repeated control and data members as extra

Only the first debian-binary, control.tar*, and data.tar* member is
read. A later member with the same role was neither decoded nor listed,
so a package with an empty first data.tar and a populated second one
reported complete coverage. Repeated members now land in
extra_member_names with a limitation, which keeps coverage partial.

* refactor(deb): use the shared excerpt and error message owners

The architecture guards from main count a hand-written ellipsis cut in
the relationship issue detail and two inline error-to-message copies.
Use ellipsisExcerpt and errorMessage instead.

* refactor(deb): move DebPackagePort to src/ports/deb

The provider imported its port from the application layer, which needed
an upward allowance in the module-layer baseline. Put the port beside the
other provider ports and drop the allowance.

* fix(deb): record only caller-selected budgets in Evidence

Omitted inspect_deb_package budgets no longer appear in Evidence
parameters as if the caller set them; only supplied fields are kept.

* fix(deb): report fixed reader allowances as limits

The ar member name, tar extension header, and relationship alternatives
allowances stop inspection without showing the input is invalid. Report
them as `limit` parse failures (DebPackageAllowanceFailure) with the
partial report attached, and project them as resource_constraint with a
fixed-allowance recovery instead of invalid_request.

* fix(deb): refuse GNU ar long name references outside the string table

A `/<offset>` reference past the end of the `//` string table, or one
that lands on an empty entry, resolved to an empty member name. The
report then failed debPackageSchema and callers got AnalysisOutputError
with no file identity or partial facts. Check the offset and the
resolved name, and refuse as a malformed DebPackageFormatFailure that
carries the partial report.

* fix(deb): align ar members by stored size and require padding

Advance past each ar member using the stored header size, so a BSD #1/N
extended name with odd length keeps the next header aligned. Refuse an
odd-sized member whose padding byte is missing at end of file instead of
reporting complete coverage for a truncated container.

* fix(deb): trim NUL-terminated header fields in linear time

Trim fixed-width ar and tar header fields at the first NUL with indexOf
instead of a NUL-to-end regex, which retried from every NUL when a
continuation line followed a NUL run. Control-field decimal parsing no
longer applies header NUL trimming.

* fix(deb): skip the tar path prefix on GNU headers

GNU tar headers use the 345-499 region for atime, ctime and sparse
data, not a POSIX path prefix. Only join the prefix when the header
carries the POSIX "ustar\0" magic.

* docs(readme): drop duplicated target tables in five translations

The fa, ko, th, zh-TW and zh guides carried the target table twice.
Restore each to upstream and add the single Debian packages row.

* fix(deb): report oversized Zstandard windows as a fixed allowance

A valid control or data zstd member can request a decoder window above
the fixed 128 MiB ceiling. Node raises
ZSTD_error_frameParameter_windowTooLarge, which the parser reported as
malformed. Map it to a DebPackageAllowanceFailure naming the new
zstd_window_bytes allowance, matching ZipArtifactReader.

* fix(package): bundle XZ decoder binaries for every plugin host

The plugin archive is produced on Linux x64, where npm ci drops other
platforms' optional packages. The packaging step only restored the PTY
binaries, so Codex plugin installs on macOS and Windows had no
@napi-rs/lzma binding and valid XZ packages failed as unsupported.

Derive the platform packages from the locked runtime tree instead:
every optional dependency of a runtime package that targets
darwin/linux/win32 on x64/arm64 is restored at its locked path with a
verified integrity, and the packed archive is checked for each one.

* fix(deb): keep only applied PAX keys while reading records

parsePax stored every record's key before PAX_KEYS filtered them, so one
extended header of many short records with distinct keys grew an object
property per record before any entry limit ran. Records whose key is not
one this reader applies are now read and dropped, and parsePax is covered
directly in DebPackageParser.test.ts.

* Address review feedback

* Trim deb822 lines with linear scans

The trailing-whitespace alternative of the shared trim expression retried
from every position of a long interior whitespace run, so a package
Description could take quadratic time. Scan from each end instead and
cover a long tab and space run in a test.

* fix(deb): read only the first control paragraph

parseControl used the first paragraph of the control file, but
deb822Paragraphs built a map for every paragraph first. A control file
of many small paragraphs could allocate millions of maps within the
decompressed-size budget. deb822Paragraphs now takes a paragraph limit
and yields string lines lazily, and parseControl stops after the first
paragraph.

* fix(deb): report unreadable tar modes as null

A tar header whose mode field is not octal was reported as mode 0000,
which invents a permission the archive never stated. Report the mode as
null and add a malformed issue for the member, so coverage is partial.

* fix(deb): refuse GNU sparse tar entries

GNU PAX sparse headers (GNU.sparse.*) rename the following entry to a
synthetic GNUSparseFile path and store only mapped segments, so reading
it as a regular file reported the wrong name and size and could miss
md5sums cross-checks. Old GNU sparse (S) entries can also carry
extension blocks their size field does not count. Refuse both as an
unsupported format instead of reporting wrong file facts.

* refactor: use shared artifact inspection for Debian packages

* fix(deb): report per-call budget refusals as parameter limits

* Address review feedback

* Address review feedback

* fix(deb): bound xz decoding, inherit global PAX size, and redact Homepage URLs

* fix(deb): bound xz index preflight memory and preserve typed cancellation with partial facts

* fix(deb): bound nested relationship lists, align tar stored-body rule, and scope async parse

* fix(deb): walk actual XZ block boundaries, scan control lines without arrays, and guard XZ close gate

* refactor(deb): avoid throwaway filter arrays in DebPackageParser

---------

Co-authored-by: Matt Van Horn <[email protected]>
Co-authored-by: morluto <[email protected]>
Co-authored-by: Matt Van Horn <[email protected]>
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