TECHNICAL SPECIFICATION & RUNTIME GUIDE
Deterministic Proof For Web Applications
StateProof is an industrial-grade runtime validation engine designed for engineering teams and AI coding agents. It launches a controlled, isolated Chromium process and intercepts network traffic directly at the Chrome DevTools Protocol (CDP) layer — proving that your UI survives Loading, Empty, Error, and Offline states with zero code modifications.
Zero-Friction Getting Started
You don't need to install large browser binaries or modify your package dependencies. Run StateProof directly using npx against any running local dev server:
# 1. Initialize StateProof configuration for your app
npx @stateproof-dev/cli init --url http://localhost:5173
# 2. Run deterministic validation against all scenarios in parallel
npx @stateproof-dev/cli run --workers 4
# 3. Export Markdown PR proof card with timestamped artifacts
npx @stateproof-dev/cli export --format md
Want to see StateProof prove failure states immediately? Run npx @stateproof-dev/cli demo in any terminal. It spins up an ephemeral test workbench and outputs real evidence cards in under 3.5 seconds.
Wire-Level Interception: Pure CDP
Traditional testing tools rely on Mock Service Worker (MSW), proxy daemons, or monkey-patching window.fetch. These approaches distort the application environment, fail on WebSockets, and require editing source files.
StateProof takes a fundamentally different path:
| Vector | MSW / Proxy Servers | StateProof Engine |
|---|---|---|
| Interception Layer | Service Worker / Localhost Proxy | Pure Chromium CDP |
| Source Code Edits | Required (mock handlers, setup scripts) | Zero app edits (0 Tamper) |
| Per-Check Latency | 4.6s+ per full Playwright suite test | ~350ms median per check |
| Telemetry & Cloud | Varies by vendor | 100% Local / 0 Packets Phoned |
| Artifact Outputs | Test terminal logs | Timestamped PNG Proof & DOM Evidence |
Framework & Tool Compatibility Matrix
Because StateProof operates strictly from the outside at the browser wire, it is completely framework-agnostic. If it renders in Chromium, StateProof can prove it.
| Framework / Library | Compatibility | Tested Transport |
|---|---|---|
| React 19 / 18 (Vite, Next.js App Router, Remix) | Full Support | Fetch, XHR, WebSocket, TanStack Query, SWR |
| Vue 3 (Vite, Nuxt 3) | Full Support | Fetch, Axios, Pinia Colada |
| Svelte 5 / SvelteKit | Full Support | Fetch, Runes, WebSocket streams |
| Vanilla JS / Solid / Astro | Full Support | Native browser fetch & EventSource |
The 4 Canonical Edge States
AI agents routinely generate the "happy path" — but real users face network latency, zero-item states, server exceptions, and dropped connections. StateProof forces and captures all four:
Injects artificial millisecond delay (e.g. mode: 'delay', milliseconds: 2500) before response headers arrive. Proves loading spinners, skeleton shimmer, and disabled form submit buttons.
Fulfills endpoints with empty collections ([] or empty fixtures). Proves zero-item onboarding illustrations, clear messaging, and "Create First Item" CTAs.
Injects HTTP 4xx/5xx status codes (e.g. mode: 'error', status: 500). Proves error alerts, message descriptions, and interactive recovery buttons without prod incidents.
Aborts requests with network disconnect (mode: 'offline'). Proves offline fallbacks, cached data renders, and reconnection banners.
Scenario Specification Guide (stateproof.scenarios.json)
Scenarios are declared in a declarative, machine-readable JSON file at the root of your project:
{
"$schema": "https://unpkg.com/@stateproof-dev/core@0.2.2/schema/v1.json",
"name": "dashboard-app",
"baseUrl": "http://localhost:5173",
"route": "/dashboard",
"viewports": [
{ "name": "desktop", "width": 1440, "height": 1024 },
{ "name": "mobile", "width": 390, "height": 844, "isMobile": true }
],
"scenarios": [
{
"id": "loading-state",
"label": "Dashboard loading skeleton renders during latency",
"request": { "method": "GET", "urlPattern": "**/api/analytics" },
"response": { "mode": "delay", "milliseconds": 1500 },
"expect": {
"visible": ["[data-testid=\"skeleton-chart\"]", "[aria-busy=\"true\"]"]
}
},
{
"id": "empty-state",
"label": "Empty project banner and onboarding CTA",
"request": { "method": "GET", "urlPattern": "**/api/projects" },
"response": { "mode": "inline", "status": 200, "body": { "projects": [] } },
"expect": {
"visible": ["[data-state=\"empty\"]", "button#create-project"],
"text": { "h2": "No projects found" }
}
},
{
"id": "error-recovery",
"label": "500 failure triggers error card and retry recovery cycle",
"request": { "method": "GET", "urlPattern": "**/api/billing" },
"response": { "mode": "error", "status": 500 },
"expect": {
"visible": ["[data-state=\"error\"]", "button#retry-billing"]
},
"recovery": {
"action": { "type": "click", "selector": "button#retry-billing" },
"response": { "mode": "fixture", "path": "fixtures/billing-active.json" },
"expect": { "visible": ["[data-state=\"ready\"]"] }
}
},
{
"id": "offline-banner",
"label": "Offline banner appears on network disconnect",
"request": { "method": "GET", "urlPattern": "**/api/feed" },
"response": { "mode": "offline" },
"expect": {
"visible": [".offline-notice"]
}
}
]
}
Recovery Loops & WebSocket Interception
Testing error states is only half the proof — you must verify that the user can recover without refreshing the page.
StateProof's recovery block orchestrates this full lifecycle:
- Injects the failing response (e.g. 500 Internal Server Error).
- Asserts error banner visibility and captures failure screenshot.
- Emulates user click on the retry CTA selector.
- Dynamically switches CDP response interception to healthy fixture (200 OK).
- Asserts recovery state and captures resolved screenshot.
Empirical Performance & Benchmarks
StateProof is measured on real workloads (tested on Node v22, Chromium 151, Linux, 4 vCPU / 7.5 GB RAM against a full 4-state × 2-viewport suite):
| Execution Mode | Total Wall Time | Per-Check Median | Throughput |
|---|---|---|---|
--workers 1 (sequential) |
8.2s | 503ms | ~0.98 checks/s |
--workers 4 (parallel) |
4.9s | ~350ms (non-delayed) | ~1.63 checks/s (1.7x speedup) |
demo command |
3.3s | 240ms | ~2.42 checks/s |
AI Agent Token Economics: 3–5x Token Savings
When an AI coding assistant diagnoses failing UI states through the first-party StateProof MCP server, it avoids reading massive DOM trees or executing multi-step browser loops:
| Approach | Tokens / Cycle | Cycles to Fix | Total Tokens | Time to Fix |
|---|---|---|---|---|
| StateProof MCP Server | ~2,600 | 1–2 | ~5,200 | ~30s |
| Playwright + manual DOM dump | ~5,000 | 3–5 | ~20,000 | ~3–5 min |
| Cypress + traceback loop | ~4,000 | 3–5 | ~16,000 | ~2–4 min |
| Raw browser agent driving | ~3,000 / action | 10+ actions | ~30,000+ | ~5–10 min |
StateProof vs Traditional Testing Matrix
| Vector | StateProof 0.2.2 | Playwright | Cypress | MSW |
|---|---|---|---|---|
| Core Focus | Edge-State Proof & Survival | User Journeys & E2E | User Journeys & E2E | In-App Mocking |
| App Code Edits | Zero (0 App Edits) | Test code required | Test code required | Service workers in app |
| First-Party MCP | Native MCP Server | ❌ None | ❌ None | ❌ None |
| Self-Healing Hints | `suggest` Selector Hints | ❌ None | ❌ None | ❌ None |
CLI Command Reference
| Command | Flags | Description |
|---|---|---|
stateproof init |
--url <url>, --route <path> |
Scans running dev server, detects routes, and initializes stateproof.scenarios.json. |
stateproof run |
--workers <n>, --browser-channel <chrome|msedge>, --diff, --fail-fast |
Executes all configured scenarios across desktop & mobile viewports in parallel. |
stateproof studio |
--port <n> |
Launches interactive Terminal UI (TUI) studio for live inspection. |
stateproof demo |
--open |
Launches ephemeral interactive failure testing workbench in under 3.5s. |
stateproof export |
--format <md|html>, --out <dir> |
Exports visual proof cards ready for Pull Request descriptions or audit docs. |
MCP Server for AI Coding Agents
StateProof provides a standard Model Context Protocol (MCP) server so coding agents like Claude Code, Cursor, Windsurf, Cline, and Antigravity can run runtime proofs, inspect DOM diagnostics, and self-heal missing selectors autonomously.
{
"mcpServers": {
"stateproof": {
"command": "npx",
"args": ["-y", "@stateproof-dev/mcp-server@0.2.3"]
}
}
}
Continuous Integration (GitHub Actions)
Add deterministic runtime proof gates to your PR pipeline. If an AI agent or engineer breaks the offline fallback or error recovery, the build fails before reaching production:
name: StateProof Gate
on: [pull_request]
jobs:
prove-states:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm run build
- name: Start Preview Server
run: npx serve -s dist -l 5173 &
- name: Run StateProof Validation
run: npx @stateproof-dev/cli run --headless --workers 4
- name: Export PR Proof Card
if: always()
run: npx @stateproof-dev/cli export --format md >> $GITHUB_STEP_SUMMARY
Security Model & Operational Boundaries
By default, StateProof only navigates to http://localhost:* and http://127.0.0.1:*. Any external network origin is rejected to prevent accidental CI leakage or tampering with production APIs.
When StateProof Operates Best
- Client-Side Network Requests: StateProof intercepts client
fetch,XHR, WebSocket, and SSE calls in Chromium. - SSR Initial Data: If data is baked statically into HTML at build time without client fetch, test the client mutations, re-validations, or page transitions instead.
- Zero Telemetry: No accounts, no API keys, zero cloud metrics. Everything executes 100% on your workstation.