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: false — BLOCKED is reserved for schemas the verifier cannot parse or validate. See the changelog for migration details.How it works
It validates that:- Structure: The output matches the required JSON keys and types.
- 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
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 includingproperties, 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:
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 includinguniqueItems.
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:
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, andschema_verifier.ucp_*constraint ids indeveloper_fields, for both valid and violated verdicts. - Type safety — string or
Noneamount fields and non-dict transactions produce deterministic verdicts instead of raisingTypeErrororAttributeError. - Exact money arithmetic — computed-total and tax checks use
Decimalquantized to the currency precision, removing the previous0.01float tolerance. taxis selected by key presence, not truthiness — a declaredtax: 0is used instead of silently falling back totax_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=TrueandadditionalProperties: falseare combined.