Quint Connect for Elixir

quint_connect brings model-based testing with Quint to Elixir projects. It generates ITF traces with the Quint CLI, decodes each trace, and replays the actions against an Elixir driver that wraps your implementation.

This package is an Elixir sibling of the Rust quint-connect crate. It keeps the same Apache-2.0 license and ports the core workflow into idiomatic ExUnit.

Installation

Add quint_connect to mix.exs:

def deps do
[
{:quint_connect, "~> 0.2.0", only: :test}
]
end

Install the Quint CLI separately:

npm install --global @informalsystems/quint

Requirements:

Quick Start

Write a driver that translates each Quint action into implementation calls:

defmodule CounterDriver do
@behaviour QuintConnect.Driver
@behaviour QuintConnect.State
import QuintConnect.Step.Switch
def init(_opts), do: {:ok, %{"counter" => nil}}
def step(state, step) do
quint_switch step do
init -> {:ok, %{"counter" => 0}}
inc(amount) -> {:ok, Map.update!(state, "counter", &(&1 + amount))}
end
end
def from_implementation(state), do: {:ok, state}
end

For Quint action names that are not valid Elixir identifiers, use string clauses:

quint_switch step do
"MoveX", [corner?, coordinate?] -> move_x(corner? || coordinate?)
"MoveO", [coordinate] -> move_o(coordinate)
end

Required picks return {:error, {:missing_nondet, name}} when absent. Optional picks end in ? and bind nil when absent.

Use the ExUnit DSL to generate Quint traces and replay them:

defmodule CounterMBTTest do
use QuintConnect.Case, spec: "priv/examples/counter.qnt"
quint_run "counter follows the model",
driver: CounterDriver,
max_samples: 10,
max_steps: 20,
seed: "1"
end

For Quint test actions:

quint_test "counter property",
driver: CounterDriver,
test: "counterWorks",
max_samples: 10,
seed: "1"

Driver Contract

The driver init callback creates the implementation state. step/2 receives a QuintConnect.Step with:

If the driver also implements the state projection callback, replay compares the projected implementation state after every step.

Configuration

Common options:

OptionPurpose
:seedReproduce Quint traces.
:max_samplesNumber of generated traces.
:max_stepsMaximum steps for quint run.
:n_tracesNumber of generated traces when :max_samples is absent.
:main_moduleQuint module passed as --main.
:init_actionInit action name for quint run; defaults to "init".
:step_actionStep action name for quint run; defaults to "step".
:backendQuint backend for run and test.
:n_threadsThreads for the Quint Rust backend.
:invariantSingle invariant expression/name for quint run.
:invariantsInvariant names for quint run --invariants.
:witnessesWitness names for quint run --witnesses.
:hideVariable names hidden from terminal output.
:mbtEnables quint run --mbt; defaults to true.
:state_pathPath into model state before comparison.
:nondet_pathPath to a custom action record when not using --mbt.
:quint_executableCLI executable; defaults to "quint".
:verbosityQuint verbosity; defaults to 0 for subprocess runs.

Environment variables:

VariablePurpose
QUINT_VERBOSEDefault verbosity passed to Quint.
QUINT_SEEDDefault seed when no :seed option is provided.

When neither :seed nor QUINT_SEED is set, Runner generates a seed and passes it to Quint. Replay failures include QUINT_SEED=... reproduction text.

Examples

The priv/examples/ directory includes:

Local Development

Run the normal suite:

mix test

Run tests that require the Quint CLI:

mix test --include quint

The :quint suite includes self-hosted specs under priv/specs/. These specs replay through QuintConnect.Case and validate the package's own CLI and step extraction behavior.

Release checks:

mix format --check-formatted
mix test --include quint
mix docs
mix hex.build

Limitations

License

Apache-2.0. See LICENSE.