Skip to main content
Updated in v7.0.0 (breaking). SchemaVerifier.verify() and verify_ucp_transaction() now return a DiagnosticResult instead of an ad-hoc dict. A payload that violates its schema is VERIFIED (the check completed and proved the violation) with developer_fields.is_valid: falseBLOCKED is reserved for schemas the verifier cannot parse or validate. See the changelog for migration details.
The Schema Verifier goes beyond standard JSON validation. It combines Pydantic structure enforcement with Symbolic Math checks deeply embedded within the schema.

How it works

It validates that:
  1. Structure: The output matches the required JSON keys and types.
  2. Logic: The numeric values inside the JSON are mathematically consistent (e.g., total == sum(items)).

The DiagnosticResult contract

verify() returns a DiagnosticResult with a status, an agent-safe agent_message, structured developer_fields, and a deterministic proof_ref: A schema violation is a completed, proven verdict, so it is VERIFIED — read developer_fields.is_valid for the pass/fail outcome and developer_fields.issues for per-path detail. proof_ref is computed deterministically from a canonical JSON encoding of the schema plus the instance evidence. Unsupported values (non-finite floats such as NaN or ±inf, hostile objects) and cyclic structures fail closed to BLOCKED instead of emitting a proof. Malformed schemas also fail closed: non-dict properties, invalid required entries, invalid numeric constraints, non-finite bounds, and negative size constraints return BLOCKED (schema_verifier.parse_error) instead of being silently treated as empty. agent_message is sanitized — rule IDs, issue types, and schema internals never leak into agent-facing output.

Usage

Money arithmetic uses Decimal, not float tolerance — computed-total and tax checks quantize operands to the currency precision and compare exactly, so boundary transactions deterministically pass or fail.

Object validation

The Schema Verifier supports standard JSON Schema object keywords including properties, required, and additionalProperties.

additionalProperties: false — strict fail-closed validation

When a schema sets "additionalProperties": false and the verifier runs with strict=True (the default), any property that is not declared in properties causes the payload to fail validation. The verifier records each undeclared property as an ERROR-severity additional_property issue, so developer_fields.is_valid is false. In non-strict mode (strict=False), additionalProperties: false is treated as advisory and undeclared properties do not block validation. Issue types returned for additionalProperties: Example — strict mode rejects extra fields:
Example — declared-only payloads pass:
Example — nested objects also fail closed:
Behavior matrix:
This fail-closed behavior for strict additionalProperties: false was hardened in the v5.1.x line. See the changelog for the release notes.

Array validation

The Schema Verifier supports standard JSON Schema array keywords including uniqueItems.

uniqueItems — fail-closed validation

When a schema sets uniqueItems: true, the verifier checks that every element in the array is distinct. If an element is unhashable or otherwise cannot be compared deterministically (for example, an object containing a Python set), the verifier fails closed — it reports a uniqueness_validation_error issue instead of silently passing. This ensures that unverifiable arrays are never treated as valid. Issue types returned for uniqueItems: Example — duplicate items:
Example — uncheckable items fail closed:
This fail-closed behavior shipped in v5.1.0. See the changelog for the full release notes.

UCP transaction verification

verify_ucp_transaction() shares the same DiagnosticResult contract and was hardened in v7.0.0:
  • Complete verdict fields on every path — the result always carries transaction_type, currency, and schema_verifier.ucp_* constraint ids in developer_fields, for both valid and violated verdicts.
  • Type safety — string or None amount fields and non-dict transactions produce deterministic verdicts instead of raising TypeError or AttributeError.
  • Exact money arithmetic — computed-total and tax checks use Decimal quantized to the currency precision, removing the previous 0.01 float tolerance.
  • tax is selected by key presence, not truthiness — a declared tax: 0 is used instead of silently falling back to tax_amount.

When to use

  • Invoice Processing: Ensure line items sum to the total.
  • Financial Reports: Ensure balance sheets balance.
  • Tax Forms: Ensure calculated fields match underlying data.
  • Strict API contracts: Reject payloads with undeclared fields when strict=True and additionalProperties: false are combined.