Plain English rules
Write the rule as a sentence. The platform classifies it as Logic (a deterministic Python check) or Judgment (an AI reasoning step) and runs it on every extraction without further work from you.
Audience: builders
Why you're here
Your AP team's rule for an invoice is simple: the total equals the sum of the line items, and the invoice date is no more than ninety days old. Your shipping desk's rule is fuzzier: the consignee name on the bill of lading matches the customer of record, allowing for legal-entity variations like "Inc." versus "Incorporated". Your quality team's rule is somewhere in between: the test reading is within the tolerance band for the certificate's product class.
The first rule is arithmetic. The second is judgment. The third is both. Document intelligence lets you write all three as sentences and routes each one to the right runner. You do not write Python and you do not stand up an LLM prompt by hand.
Where rules live
Rules attach to the Schema, not to the App or the work item. Save a rule once and every extraction the Schema runs validates against it automatically. There is no "configure rules per App" step; the contract is "this document type, these rules, every time."
In the workbench, the Rules block sits beneath Fields and Prompt. Each row is one sentence with a runner pill on the right showing how it will evaluate.
Write a rule
Open the workbench
Open your Project, click the Context tab, pick Schemas, and open the Schema you want to extend. See The visual workbench if you do not have a Schema yet.
Click Add rule
In the Rules block, click + Add rule. A new row appears with an empty sentence field.
Write the rule as a sentence
Examples that classify cleanly as Logic:
- "The total equals the sum of line items."
- "The invoice date is no more than 90 days old."
- "The currency on every line item is the same as the document currency."
Examples that classify cleanly as Judgment:
- "The consignee name matches the customer of record, allowing for legal-entity variations."
- "The work described in the contract is a software services engagement."
- "The product class on the certificate matches the SKU on the purchase order."
Save the draft
Click Save Draft in the top bar. The rule is stamped with its runner choice on save, so subsequent extractions skip the re-classification round-trip.
How the classifier picks
The classifier reads your sentence and the Schema's fields, then decides:
- Logic (the pill reads Logic). The rule is deterministic. The platform generates a complete
def evaluate(context):body and runs it in a sandbox. The sandbox has no network access and sees only the extracted document.context.extractionis the structured output your Schema produced. - Judgment (the pill reads Judgment). The rule needs reasoning over the extracted values. The platform routes the sentence to an LLM that returns pass or fail with a one-line explanation.
The pill carries a tooltip explaining which runner was picked: "Evaluated as Python on the extracted values." or "Evaluated by an LLM reasoning over the extraction."
No code required. When the classifier picks Logic, the platform writes the Python itself. The generated body is stamped onto the rule's runner_config.python_source field and is visible in the Advanced view of the Rules block if you want to read or override it.
Override the classifier
Click the runner pill on any rule. A popover opens with two buttons: Run as Logic and Run as Judgment. Pick the one you want. The platform either re-classifies the sentence as Logic (and generates a fresh Python body) or marks the rule as user-confirmed Judgment so it does not get re-classified later.
Use an override when:
- You wrote a sentence the classifier read as Logic but the math depends on context the extracted values do not carry. Pick Judgment.
- You wrote a sentence the classifier read as Judgment but the underlying check is arithmetic the platform should be able to encode. Pick Logic and inspect the generated body.
Stale classifications
If you edit a rule's sentence after it was classified, the pill shows Logic - stale or Judgment - stale with a yellow dot. The tooltip explains: "Sentence changed since classification - Python may no longer match. Re-classify to refresh." Click the pill, pick the runner you want, and the platform re-classifies against the new sentence.
Reading rule results
When you click Try on sample in the workbench (see The visual workbench), the Rules block in the result panel shows each sentence with a status pill: Passed, Failed, Warning, Error, or Skipped. Failed rules carry a one-line message explaining what went wrong, taken from the runner's diagnostic output.
At runtime in your App, failed rules attach to the work item as part of the extraction record. How analysts review and act on them depends on your Runbook. See App contracts for how to wire rule results into the work item review surface.