Code · the deterministic floor

Code generation is solved
Trust is the bottleneck

AI now writes a growing share of the stateful code your systems depend on — workflows, control logic, anything with a "mode." That's exactly the code humans are worst at reviewing by eye: the dangerous bugs live in combinations that are hard to predict and easy to leave untested. Cognitive Fab brings deterministic, exhaustive verification to that code, so your team gates it on every change instead of trusting it on faith.

This is the code layer of the stack. See how it sits under expertise, governance, workflows and simulation →

Polygraph counterexample: with the guard that blocks ship() until payment succeeds removed, the gate returns the three-step path submit(Alice), ship(), deliver() that reaches a delivered-but-never-charged order, violating invariant S1. The same check passes against the clean build.

A real counterexample from the order-management example, rendered by polyviz. Same inputs, same diagram, every time — no model runs at check time or at render time.

Run it yourself →
Why it matters

The bugs that cause outages hide in the states hardest to enumerate.

Review catches what a reviewer thought to imagine. It doesn't reliably catch the interleaving that's hardest to picture in advance — the DNS race condition no test enumerates and no reviewer sees, until it's already in production. That's not a hypothetical: it's the exact class of bug that pushed Amazon and Microsoft to formally verify their most critical infrastructure.

Amazon engineers wrote TLA+ models of S3 and DynamoDB to catch design defects in reachable states that testing and code review couldn't reach — the kind of defect that only shows up once you check every reachable state, not the ones a person happens to think of.

Microsoft did the same for Azure Cosmos DB. In both cases, the fix wasn't more review — it was exhaustive, deterministic checking of the state machine underneath the service.

That precedent still asks a team to learn a separate modelling language and keep a second description of the system in sync with the code. Polygraph removes the second description: the spec is ordinary code, checked the same way.

And it's not just Amazon and Microsoft. MongoDB, Elastic, Datadog, PingCAP, Yandex, and dozens of others reach for the same class of tool once review by eye stops being enough.

Ref: Newcombe et al., "How Amazon Web Services Uses Formal Methods," CACM 2015; Microsoft Azure Cosmos DB TLA+ verification; a crowdsourced list of companies using formal methods.

Jean-Jacques Dubray, Ph.D.

Author of the SAM pattern

A career spent on stateful systems you can trust: a 1987 Ph.D.; the software engineer and material scientist behind the IMSC closed-loop control project at Hughes Research Labs; chief architect of the NEC Boston Technology Center, leading the design of one of the first business-process engines; and a contributor to the B2B and web-services standards that formalized how systems coordinate — ebXML BPSS, WS-TX, and XML DSig.

What's different now: the spec is ordinary code — no specialist team required to write the math.

A harder, largely unsolved problem

Verifying a version is one problem. Evolving a live fleet of them is another.

The moment you change a state machine's definition, every instance already running it — the order half-shipped, the session half-negotiated — is still running the old one. Most verification tooling stops at "is this version correct" and has nothing to say about "is this deploy safe for the instances already in flight." That's the problem polyvers is built to close: classify the change, seed it against real in-flight state from the live fleet, and gate the deploy on the verdict — so a live system can change without breaking the instances already running in it.

Introducing Polygraph

Every reachable state, checked.

A verification-gated lifecycle for the code AI agents now write. Code generation is solved — trust is the bottleneck. Agents already write large amounts of stateful code, the kind hardest to get right, and no human can enumerate every reachable state by eye. The dangerous bugs hide in combinations that are hard to predict and easy to leave untested.

Review — today

  • A human reads the diff
  • Samples the cases someone imagined
  • Misses combinatorial defects

Trust blindly

Verify — Polygraph

  • A deterministic gate runs on every change
  • Explores every reachable state exhaustively
  • Every bug arrives with its reproduction

Trust by construction

Seven tools, one gate

Plugins to a coding agent. Every step the agent takes, a deterministic gate checks — no model needed at check time.

hover a mark ↗ · click to open · all tools →

3 of the world's most critical cloud services — S3, DynamoDB, Azure Cosmos DB — had their core algorithms model-checked in TLA+, because their teams learned the hard way that review by eye doesn't catch race conditions across a system's reachable states. Polygraph brings that same rigor to the state machines AI now writes for everyone else, without the specialist team.

The system

The lifecycle, the deliverables, and who decides what

Where each tool fires across the development lifecycle, the artifact family they all speak.

Polygraph · fig 2
Where each tool fires in the lifecycle
Six phases. Each names the tool that acts, the artifact it leaves behind, and whether a human decides.
click a phase ↗
01
Elicit
polynv
Harvest, pre-check and disposition the rules the machine must obey.
→ invariants.mjs
→ intent-ledger.json
02
Author
polygen
Draft the contract, author the SAM v2 module, self-repair against the checker.
→ contract.json
→ next.cjs · effects.cjs
03
Audit
polygraph
Generate independent specs, replay real traces, model-check exhaustively from init.
→ specs 1..N
→ findings + counterexamples
04
Gate
polygate
Block the merge unless the committed artifacts are fresh and still pass.
→ merge verdict
→ published hashes
05
Run
polyrun
Execute the verified machine durably; keep checking it in production.
→ journal
→ fleet snapshots
06
Evolve
polyvers
Classify the change, seed the live fleet, gate the deploy on the verdict.
→ compat-report
→ migrate.cjs
designer decides
human reviews contract
mechanical
mechanical · keyless
poison on impossible
mechanical · exit 0
Polygraph · fig 3
One artifact family, every tool a consumer
What one tool produces, the next consumes. Every artifact is inspectable and diffable.
produces
consumes
poly
nv
poly
gen
poly
graph
poly
gate
poly
run
poly
vers
poly
sec
poly
man
poly
viz
contract.json
observable keys, action alphabet, data domains, terminals
next.cjs
the machine — a SAM v2 strict-profile module
invariants.mjs
intent, as plain JS predicates over state
*.ndjson traces
ground truth: {pre, action, data, post} windows
effects.cjs + manifest
pure effect mapper over transitions
fleet snapshots
live in-flight state, exported or synthesized
migrate.cjs
the pure shape migration for a version
compat-report.json
the versioning verdict — deterministic, PR-gateable
intent-ledger.json
every rule ever considered, with attributed dispositions
the universal currency
Every consumer speaks the same window: {pre, action, data, post} — the replayer scores against it, the harness captures it, the polyrun journal is a stream of it.
Get started

Install the gate. Break something. Watch it catch it.

Polygraph installs as a Claude Code plugin in two commands. Then point it at the DAAO demo — a dual-authorization action order: two distinct approvers inside a time window, two effects, each exactly once — and ask for the one thing review can't give you: the shortest path to the bug.

1 · Install

Inside Claude Code:
# add the marketplace, install the plugin
/plugin marketplace add cognitive-fab/polygraph
/plugin install polygraph@polygraph
Grab the demo:
git clone https://github.com/cognitive-fab/polygraph-demo-daao
Node ≥ 20 · replay & model checking need no API key — only spec generation calls a model

2 · Verify

One prompt, no test written:
“Take the DAAO machine in daao/verify/, make a copy with the distinct-approver guard removed, and run the Polygraph gate on both. Show me it clears the clean build and, on the buggy one, returns the shortest path to a state that violates the two-person rule — the reproduction — without me writing a test.”
The clean build passes every gate. The sabotaged one comes back with a counterexample: the exact action sequence where one person approves twice — the class of bug that hides in code review and ships.
Work with us

Put the gate to work.

Advisory, training and hands-on work on the code your team ships with AI, from the author of the SAM pattern — not a menu, a map: pick a corner, or blend a path across it.

Partner with us Design Partner Program — for coding-agent builders, dev-tool companies and frontier labs: co-develop the verification layer for your platform, with early access to the engines. selective

Tell me about your stateful code.

A 30-minute conversation about where AI-written code is quietly accumulating risk in your systems — and whether verification is the answer.