Legal clause extraction
@ensures contracts in natural language catch semantic errors that types alone cannot - like summaries that invent obligations.
The problem
Contract review tools extract indemnity caps, termination notice periods, and assignment
clauses into a summary table. Types can enforce that notice_days is an integer; they
cannot enforce that the integer appears in the source document.
When a model paraphrases "30 calendar days" as "one month" or silently adds a mutual confidentiality obligation that is not in the text, the bug is semantic. Downstream lawyers trust the summary until something expensive goes wrong.
Why Ecko
- Natural-language contracts
@ensuresaccepts plain English predicates checked by the model on retry: "the summary must not assert obligations absent from the source". Failed checks trigger self-correcting retries before your pipeline commits the result.- Typed skeleton, semantic guard
- Structs hold the extractable fields; contracts hold the lawyered constraints. You get compile-time shape and runtime meaning without two separate systems.
- Deterministic replay
- Mock mode returns schema-valid fixtures, so regression tests cover both parsing and contract enforcement without billing a partner firm's document set on every push.
In practice
@ensures "every obligation in the output appears verbatim in the source"
fn summarise(source: str) -> str {
ai "Summarise termination and assignment clauses only" from source
}
Try it on your workload.