Documentation

Connect SafeState without adding repo dependencies.

SafeState runs as a GitHub App, a hosted OpenAPI 3.1 REST API, and a Remote Code-Mode MCP server. Emitted Vitest repro files carry zero SafeState imports.

1. Quickstart

Choose the entry path that fits your workflow:

2. Remote Code-Mode MCP Server

SafeState exposes a Streamable HTTP MCP endpoint at https://api.safestate.dev/mcp using the compact Code-Mode pattern: instead of dumping dozens of tool schemas into your coding agent’s context window, SafeState exposes exactly 3 fixed tools backed by our live OpenAPI 3.1 spec:

ToolPurpose
search_operationsSearch available API operations by keyword, tag, or HTTP method with minimal token usage.
describe_operationLoad the complete OpenAPI 3.1 parameters, request body schema, and response schema for one operation.
execute_pipelineExecute 1–8 API calls in a single server-side round-trip with $steps.<id>.body.<field> chaining.
{
  "mcpServers": {
    "safestate": {
      "url": "https://api.safestate.dev/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_SAFESTATE_API_KEY"
      }
    }
  }
}

3. Hosted OpenAPI 3.1 REST API

The live machine-readable schema is served at https://api.safestate.dev/v1/openapi.json (also aliased at /openapi.json).

# Verify service health
curl -s https://api.safestate.dev/v1/health

# Inspect live OpenAPI 3.1 specification
curl -s https://api.safestate.dev/v1/openapi.json

# Start a deterministic stateful simulation burst run
curl -s -X POST https://api.safestate.dev/v1/runs \
  -H "Authorization: Bearer YOUR_SAFESTATE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "orgId": "your-org",
    "repo": "your-org/billing-api",
    "commitSha": "a1b2c3d4e5f6...",
    "moduleId": "billing-refunds",
    "traceCount": 5000,
    "shardCount": 10
  }'

4. Optional .safestate.yml configuration

SafeState auto-discovers stateful modules, Drizzle/Prisma/SQLite/SQL schemas, and exported operations automatically. Add .safestate.yml at the repository root only if you want to pin modules, budgets, or differential targets:

version: 1
modules:
  - id: billing-refunds
    entry:
      - src/billing/refunds.ts
      - src/billing/webhooks.ts
    orm: drizzle          # drizzle | prisma | sqlite | sql | none
    schema: src/db/schema.ts
    traces: 5000
    fail_on_violation: false  # advisory by default; set true to gate PR merges
    differential:
      enabled: false
      baselineRef: main

5. Supported stacks & verification modes

DimensionSupported in V1
LanguagesTypeScript, JavaScript (Node.js, npm, pnpm, yarn, bun workspaces), Python
Databases & ORMsPostgreSQL via Drizzle, Prisma, or raw SQL (PGlite in-memory snapshot/restore); SQLite & Cloudflare D1; ORM-free stateful modules
Deterministic twinsStripe API + webhooks, outbound HTTP fetch, virtual clock & timers, seeded PRNG, local filesystem/process state
Verification modesStateful invariant simulation, async yield-point interleaving, differential equivalence (v1 vs v2), anti-tautology mutation gating
Output artifactsShrunk minimal trace, deterministic seed & SHA-256 digest, standalone Vitest repro (0 SafeState imports), coding-agent prompt

6. Honest V1 PostgreSQL concurrency boundary

What PGlite simulates — and what it does not: In V1, SafeState runs PostgreSQL modules against in-memory PGlite for sub-millisecond snapshot/restore across thousands of traces. This faithfully catches application-level async interleavings (Promise.all concurrency, yields across outbound fetch/SDK calls, out-of-order or duplicate webhooks, non-atomic read-modify-write handlers, and module-level singleton leaks) on a single database connection. True multi-connection PostgreSQL MVCC lock contention (SELECT ... FOR UPDATE blocking or SERIALIZABLE retry storms) requires a multi-connection PostgreSQL server rather than single-connection PGlite.

7. Billing, activation & cancellation

Paid plans (Starter at $49/month, Team at $199/month) are sold through Link using Stripe Managed Payments (Merchant of Record). Enter your GitHub organization or user login in the GitHub account field at checkout so your plan activates automatically via webhook.