ContractGate README

The full upstream README, mirrored for reference. Install config, tool schemas, adoption signals and our own overview live on the ContractGate listing page.

DataContractGate

Semantic contracts at every pipeline boundary — Patent Pending

Trust but verify at ingest, between stages, and on egress — before your warehouse, reverse ETL, partners, or AI agents.

Try it in 10 minutes

You need Docker with Compose, and make. No Supabase account. No API keys. No sign-up.

bash
git clone https://github.com/nightmoose/contractgate.git
cd contractgate
make demo

Opens at http://localhost:3000 — dashboard pre-loaded with three starter contracts and a live event stream. A cold start (image pulls plus the dashboard image) took about 1 minute. Later runs reuse the Docker layer cache.

bash
make demo-reset   # wipe + reseed (clean slate)
make demo-down    # stop and remove volumes
make demo-logs    # follow all service logs

make demo runs the real gateway binary with auth off. Unlimited local events, full YAML editor, playground, audit log. That preview is not the Self-Hosted Free comparison.

Run the demo locally

Everything the demo shows runs on your machine in Docker — no account, no hosted service, no data leaving your laptop. Two options, depending on what you want to see:

1. The full product (dashboard in your browser). The zero-auth stack boots the real gateway, Postgres, and the dashboard, pre-seeded with three starter contracts and a live event stream:

bash
git clone https://github.com/nightmoose/contractgate.git
cd contractgate
make demo            # docker compose --profile demo up --build
# open http://localhost:3000

Prefer a single container? The gateway image is published to GHCR on every release, so you can run just the API without cloning:

Terminal
docker run --rm -p 3001:3001 ghcr.io/nightmoose/contractgate-gateway:latest
# health check: curl http://localhost:3001/health

2. The throughput speed demo. A self-contained, Kafka-backed demo that races the real validator against a zero-validation baseline over the same stream, with a live dashboard at http://localhost:8088. This is the local replacement for the old hosted stream demo:

Terminal
docker compose -f docker-compose.kafka-demo.yml up -d   # Redpanda (Kafka)
cargo run --release --features demo --bin demo          # start the demo
# open http://localhost:8088

Full walkthrough and tuning knobs: demo/README.md.

Purchase passes the user_events contract; delete is outside the enum and a negative amount is below the minimum

DataContractGate is a high-performance validation gateway that enforces rich semantic data contracts in real time. Built in Rust, it goes far beyond JSON Schema or basic type checks — ontology, glossary, patterns, enums, computed metrics, and automatic inference. In-process validation of the passing stripe-charges catalog samples is p99 0.93 µs and 1,547,368 events/sec on one thread.

The same contract can gate what leaves your system. POST /egress/{contract_id} runs the identical engine on any outbound payload — a reverse-ETL row, a notebook export, a state object headed to a decision model. Failing records are blocked, declared PII is masked, and the caller forwards only the returned payload. See docs/egress-validation-reference.md.

Validating LLM output? The same engine powers AISchemaGate (pip install aischemagate / npm install @nightmoose/aischemagate). One-line wrapper over OpenAI / Anthropic / vLLM / Ollama responses — extracts the structured JSON, validates against your contract, optionally re-prompts on violation. Non-streaming only in v1. See docs/llm-output-validation.md, docs/llm-sdk-reference.md, and the copy-paste guides in docs/integrations/ (Vercel AI SDK, structured outputs, LangGraph). Ingest recipes: examples/recipes/.

Measured validation performance (in-process validate() only — not HTTP, auth, or Postgres). Passing samples from catalog/seeds/stripe-charges, contract compiled once before the timer, one thread: p99 0.93 µs, 1,547,368 events/sec. A one-field failure on the same contract was slower (p99 1.27 µs, 1,153,482 events/sec). Measured 2026-11-10 on an Intel Xeon (family 6 model 207 stepping 2, 2400 MHz, 4 vCPU KVM guest). Those two pass figures are the slower end of three release runs. Reproduce from the repository root:

bash
cargo run --release --bin contractgate-bench

How to read the output, the hardware note, and the three runs: ops/bench/README.md. make bench runs the same command.

Security License: MIT

See it run → Run the demo locally in Docker, or open the playground.


Using Claude, Cursor, or Codex? Paste this

Code
https://app.datacontractgate.com/llm-integration.md
https://github.com/nightmoose/contractgate

implement this in my repo

Your agent reads the integration playbook (source), finds your event shape, infers a contract from real samples, deploys it, wires your producer to /v1/ingest, and verifies with a dry run before anything is written. Machine index: /llms.txt.

MCP (Cursor, Claude Desktop, Windsurf, Copilot, Codex):

config.json
{
  "mcpServers": {
    "contractgate": {
      "command": "npx",
      "args": ["-y", "@nightmoose/contractgate-mcp-server"],
      "env": {
        "CONTRACTGATE_API_KEY": "${CONTRACTGATE_API_KEY}"
      }
    }
  }
}

Tools and auth: docs/mcp-reference.md.

Claude Code / Cursor plugin:

Code
/plugin marketplace add nightmoose/contractgate
/plugin install contractgate@contractgate

Redpanda Connect (HTTP processor, no custom plugin): docs/examples/redpanda-connect/.

Zapier — validate the record a Zap just pulled, before the next step writes it. A failure is quarantined and the Zap stops. A pass continues with the payload DataContractGate returned. Setup and the zapier-platform push commands: docs/zapier.md. Source: zapier/.


Real login (self-host)

Auth on, dashboard sign-up, and every paid feature unlocked. From a fresh clone:

bash
git clone https://github.com/nightmoose/contractgate.git
cd contractgate
docker compose -f docker-compose.yml -f docker-compose.selfhost.yml up --build

Sign up at http://localhost:3000/auth/signup, then sign in at http://localhost:3000/auth/login. Mail is not configured; confirmation is automatic. Do not combine this with --profile demo. First boot generates keys and binds ports to 127.0.0.1. Exact steps: docs/self-host-reference.md.

The comparison table is Self-Hosted Free: real login with CONTRACTGATE_SELF_HOSTED=true. The stored plan stays free and paid product gates open. SSO and managed hosting stay on hosted Enterprise. make demo does not set that flag.


Key Features

  • Semantic YAML Contracts — entities, types, patterns, enums, required fields, glossary, and computed metrics
  • Real-time Validation — at ingestion (Kafka, HTTP, batch). The in-process engine on the recorded host is p99 0.93 µs (see Measured validation performance)
  • Visual Contract Builder — intuitive UI + live YAML preview
  • AI-Powered Inference — paste sample JSON → instantly generates a full contract
  • Quarantine + Replay — automatically hold and replay violating events
  • Versioned Contracts — draft → stable → deprecated with compliance mode
  • High Performance — Rust + Axum core, 1,547,368 events/sec on one thread, in-process (see Measured validation performance)
  • Polyglot — Rust engine, Python SDK, CLI, Kafka Connect, Zapier, Next.js dashboard

Self-Hosted Free vs Cloud

CapabilitySelf-Hosted FreeCloud Free / Pro / Enterprise
Validation engine✅ Unlimited (local)✅ 100K / 25M / Unlimited events/month
Contracts✅ Unlimited✅ 3 / Unlimited (fair use) / Unlimited
Contract versions✅ Unlimited✅ 3 per contract / Unlimited (fair use) / Unlimited
Playground✅✅
Audit log✅ Local Postgres✅ 7 / 90 / Custom days retention
Live event stream✅✅
Auth & API keys✅✅
Multi-tenancy✅✅ Pro
Visual contract builder✅✅ Pro
AI inference (JSON → YAML)✅✅ Pro
Quarantine + replay✅✅ Pro
PII transform rules✅✅ Pro
Semantic versioning UI✅✅ Pro
GitHub sync✅✅ Pro
Team invites & roles✅✅ Pro
SSO / SAML❌✅ Enterprise
Managed hosting + SLA❌ Self-hosted✅

→ Full pricing → Talk to sales


Other Quickstarts

Docker (gateway + Postgres only):

Terminal
docker compose up

Python SDK (pip install contractgate installs this library, not the contractgate CLI):

Terminal
pip install contractgate
server.ts
from contractgate import Client
client = Client(base_url="http://localhost:8080", api_key="cg_demo_key")
client.ingest(contract_id="...", events={"user_id": "u1", "event_type": "click"})

CLI (contractgate test is the Rust binary, installed with Cargo):

bash
cargo install --git https://github.com/nightmoose/contractgate contractgate
contractgate test --contract examples/contracts/api/user_events.yaml --data examples/contracts/api/pass.json
contractgate test --contract examples/contracts/api/user_events.yaml --data examples/contracts/api/fail.json

GitHub Action (compile every YAML under contracts/ on PRs):

yaml
- uses: nightmoose/contractgate/actions/validate@main
  with:
    path: contracts

pre-commit (same compile, no network):

yaml
# .pre-commit-config.yaml
repos:
  - repo: https://github.com/nightmoose/contractgate
    rev: main   # pin to a git sha
    hooks:
      - id: contractgate-validate

Architecture

LayerTech
Validation engineRust + Axum (in-process p99 0.93 µs, see Measured validation performance)
DashboardNext.js 15 + TypeScript + Tailwind
StorageSupabase (Postgres + Auth)
ConnectorsKafka Connect, HTTP, batch, Python SDK, CLI
ObservabilityPrometheus + Grafana

Where to put the gate: Trust but verify at every boundary — ingest, between stages, egress, and AISchemaGate for LLM output, plus Airflow/dbt quarantine-check examples under examples/airflow/ and examples/dbt/.

Full RFCs and design docs live in docs/rfcs/. For a quick shipped-vs-draft view, see docs/STATUS.md.


Comparison

FeatureDataContractGateGreat ExpectationsSodaMonte Carlodbt
Validation timingAt every boundary (ingest + egress)After modelingMix (mostly after modeling)ObservabilityDuring dbt runs
Performancep99 0.93 µs, 1,547,368 ev/s (in-process, one thread; see Measured validation performance)Python-basedVariesNot a validatorNot real-time
Semantic depthOntology + glossary + metricsBasic expectationsChecks + rulesNo contractsBasic schema
Visual builderYes + live YAMLPartialLimitedNoYAML only
Inference from sample dataOne-click JSON → YAMLProfiler (basic)LimitedNoNo
Quarantine + replayBuilt-inNoNoNoNo
VersioningDraft → stable → deprecatedManualBasicNoBasic
Self-hosted OSSYes (make demo)YesOpen coreCommercialYes
LicenseMITApache 2.0Open coreCommercialApache 2.0

Keep your Great Expectations, Soda, and dbt tests. They check modeled data after processing. DataContractGate verifies payloads as they cross boundaries — complementary, not either/or.


Contributing

PRs welcome. See CONTRIBUTING.md and the reference docs in docs/.

Active RFCs: docs/rfcs/ · RFC status index: docs/STATUS.md


License

MIT — see LICENSE. Free to use, fork, and build on top (commercial use welcome).

The semantic contract enforcement algorithm is the subject of a pending patent. The MIT License governs this code. The patent application covers the enforcement method as an invention and does not limit anyone's right to use this code under the MIT License. Questions about patent scope: hello@datacontractgate.com. See NOTICE.


Built with ❤️ in Florida by NightMoose