@withboundary/contract. All are pure, synchronous, and side-effect free.
clean
verify
data against schema and, if provided, every rule. Returns the same ContractResult<T> shape contract.accept returns. No LLM involved.
result.ok === true→ data passed schema and all rules.result.datais typedT.result.ok === false→result.error.attempts[0]has the failurecategory("VALIDATION_ERROR"or"RULE_ERROR") and the list ofissues.
classify
repair
Message[]— messages to feed back to the model.false— the category is disabled (viaoverrides[category] = false), caller should not retry.
overrides shape
false— skip retry for this category.(detail) => Message[]— build custom repair messages for this category.
instructions
.describe() annotations.
contract.accept and available on attempt.instructions.
The primitive does not take an options object. If you want to append stable text to the generated instructions used by contract.accept, configure the contract instead:
createConsoleLogger
ContractLogger surface and prints formatted traces to console.log.
ConsoleLoggerOptions
debug: true option on defineContract / enforce is equivalent to logger: createConsoleLogger().
See also
Engine primitives guide
Recipes and custom pipelines
Testing contracts
Use verify() for unit tests