quint_driver
quint_driverv0.2.0MIT
Run a Ruby system the way a Quint spec says, and compare the two after every step.
Install
gem install quint_driverquint_driver holds your Ruby code to a Quint spec.
The spec says what each command must do, and quint_driver runs the same commands on your code and compares the two after every step.
You write a driver that runs each action of the spec on your code and reads the spec’s variables back as plain values.
A difference names the step, the variable, both values, and every step from init, so the failure can be run again by hand.
Features
Section titled “Features”- Trace replay.
QuintDriver::Quint.simulatehas Quint write traces, andQuintDriver::Trace.replayruns each one on the driver step by step. Quint picks the steps, so a trace reaches deep states quickly. - Hegel picks the steps.
QuintDriver.machinebuilds aHegel::StateMachinefrom the spec, so Hegel picks each step from the actions the spec allows now, and shrinks a failure to a short sequence of commands. - The spec runs in the Ruby process. quint_driver reads Quint’s JSON IR and evaluates it in Ruby, so a Hegel step does not start another process.
Trace.replay(path, spec.model)holds that model to Quint’s own traces. - Failures with a name. A disagreement raises
QuintDriver::Mismatch, an error inside a step raisesQuintDriver::StepRaised, and an expectation that breaks while the code still agrees with the spec raisesQuintDriver::Violated. - Hunting for bugs. Pass an expectation as
violate:toQuint.simulate, and Quint searches for traces that break it.bundle exec quint_driver targetsranks the files of an app where a hunt pays. - Minitest or RSpec. Trace replay works the same in a Minitest test and in an RSpec example.
How an agent uses it
Section titled “How an agent uses it”- Pick a model with a status column and a method that changes it, such as
Loan#approve. - Write a small Quint spec of its states, a driver that runs each action on the model, and one example that replays traces inside a rolled-back transaction.
- Run the example. A
Mismatchnames the first step where the code and the spec differ. - To hunt for bugs, write expectations in the spec and let Quint aim traces at each one.
The gem ships a quint_driver skill that takes an agent through the spec shape, the driver, trace replay, the model check, and Hegel.
Getting started
Section titled “Getting started”quint_driver needs Ruby 3.3 or later. It calls the quint command that QUINT names, or runs npx --yes @informalsystems/quint@0.33.0 without it.
# Gemfilegroup :test do gem "quint_driver", require: falseendbundle installnpm install --global @informalsystems/quint@0.33.0QUINT=quint bundle exec rspec spec/quint/loan_state_spec.rbWorks with
Section titled “Works with”- The Hegel adapter,
require "quint_driver/hegel", runs on hegel-ruby (the hegeltest gem), which needs Ruby 3.4 or later. quint_driver does not depend on it, so add hegeltest to your own Gemfile.