When result.ok === true
The output is guaranteed to be:
- Valid JSON — successfully parsed
- Schema-compliant — matches your Zod schema exactly
- Rule-correct — all domain rules returned
true - Safe to use — no additional checks required in your application
result.data as trusted input to your system.
When result.ok === false
No output is returned to your application.
Instead, you receive a structured error:
- No invalid data leaks through
- All attempts are preserved for debugging
- Failures are fully explained with categories and violations
What Boundary guarantees
Boundary guarantees system-level correctness, not model behavior:| Guarantee | Description |
|---|---|
| Deterministic gate | Every run is accepted or rejected. No partial passes, no silent corruption. |
| Schema compliance | Accepted output matches your Zod schema exactly. |
| Rule enforcement | Every rule returned true on the accepted output. |
| Targeted repair | On failure, specific violations are sent back to the model — not blind retry. |
| Full history | Every attempt is recorded with raw output, cleaned output, issues, and failure category. |
The model may generate incorrect outputs. Boundary prevents incorrect outputs from entering your system. Only validated, correct data crosses the boundary.
What Boundary does NOT guarantee
| Not guaranteed | Why |
|---|---|
| The model will succeed | It may exhaust all retries and return ok: false |
| Zero retries | Most calls take 1-2 attempts. Some need 3. |
| Correctness beyond your rules | If you don’t write a rule for it, Boundary can’t catch it |
| Latency bounds | Total time depends on retry count and model speed |
Mental model
The model proposes outputs.
Boundary decides what your system accepts.This separation makes your application deterministic, even when the model is probabilistic.
The acceptance boundary
Next steps
When to Use
Where Boundary fits — and where it doesn’t
API Reference
Full API surface