Skip to main content
@withboundary/contract is the correctness engine. @withboundary/sdk is the observability layer on top of it — it captures every contract run as a structured event, batches them, and ships them to the Boundary cloud (or any sink you choose). You wire them together by passing a logger to your contract:
import { defineContract } from "@withboundary/contract";
import { createBoundaryLogger } from "@withboundary/sdk";

const logger = createBoundaryLogger({
  apiKey: process.env.BOUNDARY_API_KEY,
  environment: "production",
});

const contract = defineContract({
  name: "lead-scoring",
  schema,
  rules,
  logger,
});
That’s it. Every contract.accept(run) call now produces a BoundaryLogEvent with the outcome, duration, failure category, repair messages, and attempt count.

What ends up on the dashboard

  • Acceptance rate per contract, per environment, per model
  • Failure breakdown by category (RULE_ERROR, PARSE_ERROR, REFUSAL, …)
  • Repair patterns — which rules fail most, what the repair messages look like
  • Latency — wall-clock duration per run including retries
  • SDK attribution — version + runtime stamped on every event

Safe by default

Two things make it safe to leave the SDK wired up in every environment:
  1. Null logger in dev. When neither apiKey nor write is configured, createBoundaryLogger returns null. Passing null to defineContract({ logger }) is a no-op.
    // Works in prod with BOUNDARY_API_KEY set.
    // Works locally without it — logger is null, contract runs normally.
    const logger = createBoundaryLogger({
      apiKey: process.env.BOUNDARY_API_KEY,
    });
    
  2. Conservative capture policy. Raw LLM inputs and outputs are off by default. Only metadata, repair messages, and failure details leave the process. Opt into raw data explicitly — see Capture policy.

Where to go next

Quickstart

Install and see your first event

Capture policy

Control what leaves the process

Redaction

Scrub PII before events are sent

Shutdown

Drain the queue correctly on every platform

Contract library docs

Looking for the correctness engine itself? See Contracts and Rules in Core Concepts.