Skip to main content

Coherence Rules

Define cross-field quality rules on a Spec. List, create, update, delete, and auto-propose coherence rules that penalize confidence on violating cells.

Coherence rules are cross-field quality rules attached to a Spec (a user_schema). Where a validation stage gates the pipeline at a position, a coherence rule expresses a relationship that should hold between fields in a record, for example "field A must not equal field B" or "if field A has a value then field B must be non-zero". When a rule is violated, the platform applies a confidence_penalty to the affected cells so they surface for review.

A rule has a rule_type (such as not_equal, implies_value, non_zero_when_sibling_filled, value_range, or custom) and a config object that names the fields and thresholds for that type. The service stores config verbatim and infers sane defaults for omitted fields. Rules carry a status of proposed, active, or rejected.

You can have Claude auto-propose rules from the Spec fields via the propose endpoint. Proposed rules land with status proposed. Approve one by updating it to status: active, or dismiss it with status: rejected. This keeps the human in the loop while letting the model surface candidate relationships you might not have hand-written.

GET/v1/schemas/{id}/coherence-rules
POST/v1/schemas/{id}/coherence-rules
POST/v1/schemas/{id}/coherence-rules/propose
PATCH/v1/schemas/{id}/coherence-rules/{ruleId}
DELETE/v1/schemas/{id}/coherence-rules/{ruleId}

Response

Rule fields

idstringCoherence rule UUID.
rule_typestringThe rule type identifier.
configobjectRule parameters keyed by rule_type.
descriptionstring | nullHuman-readable description.
confidence_penaltynumberConfidence reduction applied to violating cells (0 to 1).
statusstringOne of proposed, active, rejected.

Response

[
  {
    "id": "c0ffee00-1111-2222-3333-444455556666",
    "rule_type": "non_zero_when_sibling_filled",
    "config": {
      "trigger_field": "tax_rate",
      "required_field": "tax_amount"
    },
    "description": "If a tax rate is present, tax amount must be non-zero.",
    "confidence_penalty": 0.3,
    "status": "active"
  }
]
Use the propose endpoint to seed a Spec with candidate rules, then review each one. Proposals never affect a run until you set their status to active.

Errors

Error responses

400validation_errorInvalid body, or an unrecognized rule_type or status value.
401unauthorizedMissing or invalid API key.
404not_foundNo Spec (schema) or rule with this ID exists for your organization.
429rate_limitedToo many requests. Retry after the period indicated in the Retry-After header.