dafny-replay is an experimental methodology for correct-by-construction application state using formal verification. The questions below cover the most common points of confusion: what the proofs actually cover, where the boundaries are, and how to fit dafny-replay into a real application.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/metareflection/dafny-replay/llms.txt
Use this file to discover all available pages before exploring further.
What does dafny-replay prove exactly?
What does dafny-replay prove exactly?
dafny-replay proves that state transitions in the verified kernel cannot violate your domain invariant. Concretely:
- If you discharge the domain obligations (two lemmas for most kernels), all kernel theorems apply to your domain automatically.
- Undo/redo cannot corrupt state (Replay kernel).
- The server state always satisfies the invariant regardless of client behavior (Authority and Multi-Collaboration kernels).
- Pending actions are never silently lost and retries are bounded (Effect State Machine).
Is this a CRDT library?
Is this a CRDT library?
No. dafny-replay is server-authoritative, not peer-to-peer.CRDTs guarantee convergence across replicas without a central authority, typically by weakening semantics (unordered sets, tombstones) to achieve commutativity. dafny-replay takes the opposite approach: a single authoritative server maintains strong global invariants, and clients submit requests that the server accepts or rejects.The Multi-Collaboration kernel handles offline clients and stale versions through intent-relative rebasing — the server tries candidates in order and rejects only when no meaning-preserving interpretation can succeed — but this is reconciliation against an authority, not symmetric convergence.
Is this a UI framework?
Is this a UI framework?
No. dafny-replay owns state transitions and proofs; React (or any other UI layer) owns rendering and user interaction.The boundary is clean: Dafny-generated code lives in a
.cjs bundle you import into JavaScript. You store kernel state in React’s useState, call Dispatch, Undo, and Redo from event handlers, and pass the resulting state to your components as props. dafny-replay has no opinion about your component tree, styling, or routing.Does it work without undo/redo?
Does it work without undo/redo?
Yes. The Authority kernel is designed for server-authoritative state without local history. Its state space is
ServerState = { version, present }, not a History.Use the Authority kernel when:- You want server-side safety independent of client correctness.
- You do not need local undo/redo.
- Clients may submit optimistic actions, but the server is the sole source of truth.
How does it handle concurrent edits?
How does it handle concurrent edits?
The Multi-Collaboration kernel handles clients that submit actions based on stale server versions.When a stale action arrives, the server:
- Rebases the action through the intervening history using the domain-defined
Rebasefunction. - Enumerates a finite set of
Candidatesin order. - Tries each candidate with
TryStep; accepts the first success, or rejects if all fail.
Explains) would succeed, the request is not rejected. The domain defines the envelope; the kernel guarantees the boundary.For position-sensitive operations like card moves, dafny-replay uses anchor-based placement (Before(anchor), After(anchor), AtEnd) instead of positional indices, which are more robust to concurrent edits.What is the performance overhead?
What is the performance overhead?
dafny-replay is not optimized for performance. It is an experimental methodology focused on correctness by construction, not throughput or latency.Specific costs to be aware of:
- Dafny integers compile to
BigNumberobjects, which are slower than native JS numbers. - Immutable Dafny maps and sequences create new objects on every update.
- The
BigNumber.EUCLIDmodulo configuration must be set globally before any Dafny code runs.
Can I use this with any backend?
Can I use this with any backend?
Yes. dafny-replay includes a backend abstraction layer that separates verified transition logic from I/O.Two reference backend integrations are provided:
You can implement your own backend by providing the storage and realtime layers that the effect state machine expects. The verified kernels do not depend on any specific backend.See the backends overview for integration details.
| Backend | Features |
|---|---|
| Supabase | Managed auth (OAuth), Row Level Security, built-in realtime |
| Cloudflare | D1, Workers, Durable Objects, custom JWT auth |
What Dafny version is required?
What Dafny version is required?
dafny-replay targets a recent stable release of Dafny. Check the repository’s CI configuration (
.github/workflows/ci.yml) for the exact version pinned in the test suite — that is the version the proofs are known to pass on.For Dafny installation instructions and release notes, see dafny.org.How does LLM assistance work?
How does LLM assistance work?
dafny-replay doubles as a benchmark for Dafny + LLM proof assistance. The workflow separates human review from LLM implementation:
- A human expresses the domain intent in natural language.
- An LLM generates a formal Dafny specification (types, invariant, apply function).
- The human reviews and approves the spec — this is the only review required.
- An LLM writes the implementation lemmas and proofs.
- Dafny verifies every implementation against the approved spec.
What is app-extras.js for?
What is app-extras.js for?
app-extras.js is the recommended pattern for customizing the generated API without modifying generated code.The dafny2js tool generates app.js automatically from your Dafny source. Because app.js is regenerated every time you recompile, you should not edit it directly. Instead, create app-extras.js that imports app.js, spreads its exports, and overrides or adds methods:Result types into { ok, value } objects, providing object-style enum access, and accepting JSON for server communication.See the app-extras pattern guide for a complete walkthrough.Guarantees reference
Full list of kernel theorems, domain obligations, and integration boundaries.
Type mappings reference
Every Dafny-to-JavaScript type conversion with copy-paste examples.