Skip to main content

Contract library types

All exported from @withboundary/contract.

ContractResult<T>

The return type of every contract call. Discriminated union on ok.

ContractAttempt

Passed to your RunFn on each attempt.

ContractError

AttemptDetail

FailureCategory

Rule<T>

Rules are named, synchronous checks. check returns true when the data is correct. It returns false or a string when the rule fails. A string return becomes the failure message for that specific attempt; otherwise Boundary uses message when provided. Use stable name values for dashboards, metrics, and ruleIssues. Use description as the human label. Use fields when a rule maps cleanly to one or more output fields.

RunFn

Your LLM call function. Return the raw response as a string, or null if the model returned nothing.

Message

Used in attempt.repairs and repair functions.

Configuration types

ContractConfig<T>

RetryOptions

RepairOverrides

ContractLogger<T>

Hook into the execution lifecycle. All hooks are optional. Every context object includes contractName and runHandle so one logger can serve multiple contracts and correlate hooks from the same run.

ConsoleLoggerOptions

See createConsoleLogger.

Engine primitives

Lower-level functions for advanced use cases. All pure and side-effect-free. Full reference: Engine primitives.

SDK types

All exported from @withboundary/sdk.
@withboundary/contract also exports a BoundaryLogEvent type for contract-level logger integrations. The SDK’s BoundaryLogEvent below is the hosted ingest event used by createBoundaryLogger, beforeSend, and custom write sinks.

BoundaryLogger<T>

The object returned by createBoundaryLogger. Implements every ContractLogger<T> hook and adds drain controls.

BoundaryLoggerOptions

Full options shape for createBoundaryLogger. See createBoundaryLogger for a per-field table with defaults.

BoundaryLogEvent

The wire format shipped to the ingest endpoint. A tagged union on okAcceptedEvent (always terminal) or FailedEvent (one per non-terminal attempt plus the terminal one). See BoundaryLogEvent for examples and lifecycle.

CapturePolicy

Failure attribution (category, issues, ruleFailures) and run metadata are always sent on the wire — they are not gated by a capture flag.

RedactionOptions

BoundaryEnvironment

The wire format (BoundaryLogEvent.environment) is string so the server accepts future names without an SDK bump; the SDK’s input type is the narrow union to prevent typos like "prod" or "stg" that would fragment dashboards.

Transport

Low-level extension point. Typical users don’t implement this — they pass write instead.