Skip to content

refactor(runtime): parse capability inputs before provider work - #1314

Merged
morluto merged 3 commits into
agent/centralize-dispatch-failuresfrom
agent/remove-schema-first-adapters
Aug 13, 2026
Merged

refactor(runtime): parse capability inputs before provider work#1314
morluto merged 3 commits into
agent/centralize-dispatch-failuresfrom
agent/remove-schema-first-adapters

Conversation

@morluto

@morluto morluto commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Problem

Jacobian's installed adapters had two request paths. Most adapters first ran a generic JSON Schema validator and then parsed the same payload into a Pydantic model, while marker-bearing adapters skipped that first pass. The split contradicted the parse-once architecture, allowed validation order to vary by adapter, and kept a schema-only extension path even though external operation packages are unsupported.

Removing the generic pass alone exposed two boundary gaps: Pydantic's default coercion could accept numeric strings that the catalog advertised as integers, and provider readiness could run before the adapter had validated its complete request. Published values also needed a typed invariant after removing the generic output-schema execution pass.

This PR is stacked on #1311, which centralizes final CapabilityResult projection.

Relates to #1210, #1212, and #1219.

Solution

  • Replace the marker-selected adapter modes with one generic CapabilityAdapter[PreparedT] contract. Every installed adapter now strictly parses and prepares its typed request before provider readiness, then executes only that prepared value.
  • Encode the supplied JSON losslessly and parse it through Pydantic in JSON mode with strict=True, preserving enum wire values while rejecting coercions such as "21" to int. Non-JSON and over-limit inputs become bounded INVALID_REQUEST diagnostics.
  • Check the published Pydantic model against the installed output contract and strictly revalidate its in-memory projection before the single wire serialization. Mismatched model types and unchecked model_construct values fail with ADAPTER_RESULT_INVALID.
  • Add a real LeanCheckRequest model, remove the descriptor-only registration facade, and update every surviving SAT/SMT, polynomial, graph, Lean, finite, and exact-checker adapter to the same boundary.
  • Remove stale documentation for external adapter entry-point loading and add an architecture ratchet that prevents marker-selected adapter modes from returning.

No MCP tool shape, operation ID, artifact format, checker authorization rule, or mathematical implementation changes. The stricter parser intentionally makes runtime acceptance match the catalog's generated JSON Schema.

Testing

  • make lint typecheck — Ruff, formatting, complexity, and mypy passed; 459 source files typechecked.
  • make test-unit — 877 passed on the final tree.
  • Component suite — 905 unaffected tests passed in the full lane; the corrected direct installed-operation helper passed 4/4, and the final adapter-boundary regression file passed 14/14.
  • Domain suite — 477 unaffected tests passed; the two updated typed-diagnostic regressions passed 2/2.
  • make test-composition — 157 passed.
  • make test-e2e — 4 passed.
  • make test-provider — 64 passed.
  • make import-contracts — 7 contracts kept.
  • make architecture — 1,685 files checked.
  • make test-architecture — 406 files checked.
  • make docs-linkcheck — passed.

Trust & Compatibility Impact

The adapter protocol is internal and pre-stable. Invalid requests now fail before provider readiness or execution, and invalid typed outputs fail before publication. Verification records, checker identity, evidence binding, and artifact lineage are unchanged.

External operation adapters remain unsupported; this change removes stale prose that implied an entry-point loader existed.

Architecture Budget

This deletes the TypedInputAdapter compatibility mode and the schema-first/schema-bypass branch. The shared strict parser and two-phase adapter contract replace both former production paths across all 58 installed adapters in this PR; no registry, facade, codec protocol, or external extension mechanism is added.

Suggested review order:

  1. capability_adapters.py and capability_dispatch.py for the parse/readiness/projection invariants.
  2. operation_installation.py for value-reference binding and typed execution.
  3. One representative direct adapter in graphs/composition.py, polynomials/_support.py, and exact_domain_checkers.py.
  4. test_capability_adapter_authority.py, the graph numeric-string regression, and the architecture ratchet.

Checklist

  • Ordinary Python validation is covered by the final-tree static/unit run and affected-lane reruns listed above.
  • Relevant composition, end-to-end, and maintained-provider specialist lanes are listed above.
  • No Harbor task or verifier contract changed.
  • No ordinary mathematical operation or publication binding was added.
  • The shared boundary replaces two surviving production paths and deletes the prior mode split.

@morluto
morluto marked this pull request as ready for review August 13, 2026 06:05
@cursor

cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@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: 8a85ecbd90

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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

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

Comment thread src/jacobian/capability_adapters.py Outdated
@morluto
morluto merged commit 7a3edda into agent/centralize-dispatch-failures Aug 13, 2026
@morluto
morluto deleted the agent/remove-schema-first-adapters branch August 13, 2026 06:33

@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: c562cede22

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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

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

Comment on lines +273 to +276
parsed_request = cast(
ContractModel,
parse_capability_input(self.spec.request_type, bounded_input),
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve typed values when binding operation inputs

When an installed operation is invoked with request.inputs, _bind_inputs() has already resolved each URI to its typed domain ContractModel, but this call parses bounded_input, which was built using model_dump(mode="json"), instead of validating the assembled typed mapping. Every producer-to-consumer composition therefore round-trips the shared value through its wire representation and constructs a second value; a domain value with non-lossless serialization or backend-native state can be changed or rejected before execution. Strictly validate the agent-supplied fields first, then bind and validate the resolved Python values without serializing them.

AGENTS.md reference: AGENTS.md:L76-L83

Useful? React with 👍 / 👎.

morluto added a commit that referenced this pull request Aug 13, 2026
* refactor(runtime): centralize capability result projection

* refactor(runtime): parse capability inputs before provider work (#1314)

* refactor(runtime): parse capability inputs once

* docs(architecture): enforce typed adapter boundaries

* fix(runtime): preserve request values before validation

* fix(composition): preserve resolved typed value identity

Carry a JSON accounting view beside each resolved input-port value, restore the exact validated object for strict Python-mode request binding, and keep ordinary caller payloads on the existing strict JSON parse. Add a regression proving both object identity and rejection of stringly external fields.

* fix(composition): separate typed binding from JSON accounting

Restore exact model instances at input ports, keep canonical JSON projection solely for request-size accounting, and parse the assembled typed payload directly in strict Python mode. External requests still cross the strict JSON parser, while direct and referenced composition preserve object identity.

* fix(runtime): preserve typed dispatch values and outputs

* fix exact replay preparation and relative import ratchet

* fix exact replay request preparation import

* fix exact replay prepared value handoff

* fix exact verifier typing and relative result imports

* test polytope adapter preparation handoff

* test(lean): prepare typed requests in live smoke

* fix(architecture): remove legacy checker mode marker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant