Double-refund slips past a clean unit suite
The refund handler checks remaining balance, awaits an external gateway, and then updates the database. A concurrent webhook commits first and doubles the refunded total.
Coding agents ship billing, auth, and webhook code fast — and pass single-call unit tests while leaving double-refund races, token-refresh deadlocks, and cross-tenant leaks behind. SafeState explores thousands of interleaved call sequences deterministically, shrinks failures to the shortest failing sequence, and gives your coding agent a standalone Vitest repro it can fix.
billing-double-refund.spec.ts (0 SafeState imports).requestRefund() reads refunded_cents before calling the payment provider, then writes back after the webhook already incremented it.NO_OVER_REFUND failed on seed 42 after shrinking to 3 steps.CreateCharge("ch_2", 2500)RequestRefund("ch_2", 2500) yields while awaiting outbound refund callDeliverWebhook("refund.succeeded", "ch_2", 2500) commits before step 2 resumesbilling/refunds.ts:48 (reserve refund capacity atomically before calling the external gateway and deduplicate by webhook event ID).vitest run billing-double-refund.spec.ts
NO_OVER_REFUND before trusting the invariant.42 produced identical SHA-256 trace digest across independent worker runs.Single-call unit tests prove each function works in isolation. Production outages happen when retries, duplicate webhooks, concurrent requests, and clock skew collide across state transitions.
The refund handler checks remaining balance, awaits an external gateway, and then updates the database. A concurrent webhook commits first and doubles the refunded total.
Logout deletes the session while a refresh request is mid-flight. When the refresh resumes, it inserts a brand-new active session for an already logged-out user.
SafeState runs the exact same seeded sequence against your baseline and refactored implementations side by side and surfaces the shortest trace where state diverges.
Connect through the GitHub App, the hosted OpenAPI 3.1 API, or the remote Code-Mode MCP server. No npm packages to install into your production repo.
Request a free check on one module, connect the read-only GitHub App, or point your coding agent at https://api.safestate.dev/mcp.
SafeState drives your exported operations against in-memory PostgreSQL (PGlite), SQLite, and deterministic HTTP/SDK twins under virtual time and seeded interleavings.
Collapses a 40-step failure to 2–4 steps and emits a zero-dependency Vitest file plus a copy-paste prompt for your coding agent.
Before going green, SafeState injects planted P0 faults to prove your invariants fail on broken code and re-verifies 10,000 traces on your fix.
No LLM reads your code during deterministic checks, and we state our V1 database simulation boundary upfront.
Built to produce reproducible engineering evidence, never hand-wavy scores.
Promise.all, yields around fetch/SDK calls, duplicate webhooks, stale read-modify-write) over a single connection. True multi-connection PostgreSQL MVCC lock contention (FOR UPDATE, SERIALIZABLE retries) requires a multi-connection Postgres target rather than single-connection PGlite.Minimal permissions, offline execution, and transparent data retention.
contents: read, checks: write, pull_requests: read, and metadata: read. Cannot push commits, merge PRs, or alter settings.No per-seat fees, no per-minute cloud meter surprises, and no sales call. Every paid plan includes unlimited developers on one GitHub account.
Submit one public repository or stateful module for a complete deterministic check before paying anything.
Continuous stateful simulation on pull requests, plus hosted OpenAPI 3.1 API and Remote Code-Mode MCP access.
api.safestate.dev/mcp) + OpenAPI 3.1 APIBuilt for multi-repo backend teams shipping billing, ledger, auth, and workflow refactors every day.
No. SafeState connects via a read-only GitHub App, a hosted OpenAPI 3.1 API (https://api.safestate.dev/v1/openapi.json), and a Remote Code-Mode MCP server (https://api.safestate.dev/mcp). Emitted Vitest repro files have zero SafeState imports, so you never add a runtime or dev dependency to your project.
No AI model reads your code during deterministic PR checks. Stateful exploration, interleaving, shrinking, differential comparison, and anti-tautology mutation gating are all deterministic code running offline. Your own coding agent — never SafeState — edits your repository. See security and data handling.
In V1, SafeState runs PostgreSQL modules against in-memory PGlite for fast sub-second snapshot/restore across thousands of traces. PGlite faithfully catches application-level async interleavings (concurrent Promise.all handlers, yields around fetch or payment SDK calls, duplicate webhooks, and non-atomic read-modify-write logic) over one database connection. True multi-connection PostgreSQL MVCC lock contention (SELECT ... FOR UPDATE waits or SERIALIZABLE conflicts) requires a multi-connection Postgres server rather than single-connection PGlite.
TypeScript, JavaScript, and Python backends. SafeState supports Drizzle, Prisma, raw SQL PostgreSQL, SQLite / Cloudflare D1, and pure ORM-free stateful modules (in-memory caches, auth token managers, queues, and workflow engines). See the documentation.
They catch complementary bug classes. Diff-scoped mutation testing verifies that your existing unit tests catch single-line logic flips (>= vs >, inverted guards). SafeState verifies multi-step stateful behavior across retries, out-of-order webhooks, concurrent requests, and database transitions — and uses a mutation gate internally so your stateful invariants cannot be vacuous.
Manage or cancel your subscription directly in the Stripe billing portal (enter your billing email for a login link), reply to any SafeState email, or write to hello@safestate.dev. Your first month is refunded on request within 30 days.
Start with a free deterministic check on one stateful module. Receive a shrunk trace, a standalone zero-dependency Vitest repro, and a prompt ready for your coding agent.