Quint: stay in command by understanding what matters

4 min read Original article ↗

Quint Studio is your structured way to adopt formal methods, helping you validate what matters most and deepen your understanding of your software with every check.

Orders1

Payments

CartSETUP 1/3

Misbehavior1 open · 0 fixed

Correctness10 of 11 · 1 broken

1 component selectedView selection ▾Set up Quint110+ min per component

Peripheral

Cart

not modeled

Central

Inventory

not modeled

Central

Orders

modeled1 misbehavior

★ RecommendedCentral

Returns

not modeled

← CartRunning…■ Stop

Running • 0m 00s • your-model • $0.01

Execution Logs

Starting the model

Quint specDraft

cart/cart.qnt

Code is scaling.
Understanding isn't.

Developers need to understand how their software works, how it behaves, and the implications of changes, but traditional development workflows don't scale with AI-generated code.

Don't Drown in Markdown

If you switched from reading code to reading markdown files as your main activity, Quint specs can bring you the executability you are missing.

glossary.md

disputes.md

inventory.md

refunds.md

sessions.md

payments.md

checkout.md


Retries

A payment retry should never charge the customer twice. Expired sessions release their items.

Provider timeouts

When the provider times out we re-queue the order, unless it was already accepted, in which case we settle it and move on.

ReadableStaticDrifts from code

checkout.qnt


invariant settledOnce =
  payments.forall(p =>
    p.settlements.size() <= 1)

ReadableRuns & checksStays in sync

retry.test.ts

ledger.ts

provider.ts

session.ts

settle.ts

queue.ts

retry.ts


export async function retry(ord, n, ctx) {
  const res = await prov.charge(ord, ctx)
  if (res.status === 408 && !ctx.idem) {
    await queue.push({ ...ord, try: n+1 })
  } else if (await prov.accepted(ord.id)) {
    await settle(ord, { force: true })
  }
  return res
}

RunsToo detailed

How Quint Works

1

Your codebase is broken down into components

Capturing your whole code base in one huge state machine wouldn't be helpful. Quint Studio breaks it up into multiple components so you can reason about it one state machine at a time.

2

Agents write a Quint specification

The spec is authored automatically taking your code and documentation as input. Modeling techniques and several checks are applied to ensure the spec meets quality standards.

← OrderRunning…■ Stop

Running • 5m 00s • your-provider/your-model • $0.48

Execution Logs

Reviewing the spec against the code

09:42:56Reviewing the spec against the code09:42:54The author is working on the spec09:42:53Reading src/modules/order/service.ts09:42:53Model order started

Quint specDraft

order/order.qnt

module order {
  type Status = Draft | Pending | Completed | Archived | Canceled

  type OrderState = {
    version: int,
    status: Status,
    canceled_at: bool,
    item_total: int,     // summary item_total at the current version
    expected_item: int,  // independently tracked correct item_total
    paid_total: int,
    fulfilled: bool,
  }

3

Issues get reproduced against code in a test

Each violation found by Studio is judged, and real bugs are reproduced as a test against your code. Interactively explore the behavior to understand the violation better.

Hover over the property to understand what broke

no_orphaned_return  Confirmed Product bug

Undoing the last change strands a return created on top of it.

Found by the model  no_orphaned_return  violated in a run of up to 20 steps

Propertyat state 5false

val no_orphaned_return: bool = RETURNS.forall(r6‹1/1› => not(returns.get(r6){ active: true, deleted: false, order_id: 1, order_version: 2 }.activetruetrue and not(returns.get(r6){ active: true, deleted: false, order_id: 1, order_version: 2 }.deletedfalse)truetrue and returns.get(r6){ active: true, deleted: false, order_id: 1, order_version: 2 }.order_version2 > orders.get(returns.get(r6){ active: true, deleted: false, order_id: 1, order_version: 2 }.order_id1){ status: Pending, item_total: 120, version: 2, … }{ status: Pending, item_total: 100, version: 1, … }.version21falsetruetruefalsetrue)truefalse)truefalse

Behavior

0  Initial state›1  Create orders›2  Create order change›3  Confirm order change›4  Create returns›5  Undo last change

Reproduced by a test

packages

/modules

/order

/integration-tests

/__tests__

/undo-change-return.spec.ts

Undoing an order change does not strand a return created on top of it

it('does not strand a return when the last change is undone', async () => {
  const order = await anOrder({ status: 'pending' })
  await service.confirmOrderChange(await aChange(order.id))
  const ret = await service.createReturn({ order_id: order.id })
  await service.undoLastChange(order.id)
  const current = await service.retrieveOrder(order.id)
  expect((await service.retrieveReturn(ret.id)).order_version)
    .toBeLessThanOrEqual(current.version)
})

No fix proposed yet

4

Keep specs in your workflow and check behavioral changes

Quint plugs into your coding agent. When a change touches a modeled component, Studio checks if the spec needs to be updated and flags any new violations.

>Can we deduct items from the inventory when adding them to a cart, to reduce the failure rate of checkouts?

●Checkouts fail when stock sells out before payment. I'll take items out of inventory as they're added.

●Search(pattern: "inventory", path: "src/modules/cart")

⎿Found 2 files

●Read(src/modules/cart/service.ts)

⎿Read 184 lines

●Update(src/modules/cart/service.ts)

⎿Updated src/modules/cart/service.ts with 2 additions

52

async addItem(cartId, item) {

53 + await this.inventory.take(item.sku, item.qty)

...

91

const item = cart.find(itemId)

92 + await this.inventory.put(item.sku, item.qty)

●Bash(npm test -- cart)

⎿Tests: 42 passed, 42 total

●Done: adding an item takes it out of inventory, and removing it puts it back.

>

Cart outdated ✓ 3/4 tested 8/12

Quint

‹CartoutdatedUpdate

Misbehavior ░░░░░░░░░░░░

0 open issues

Correctness █████████░░░

3/4 1 broken

Coverage ████████░░░░

8/12 tested

✓ itemsNeverNegative✓ paidCartsHoldStock

✗ addedItemsCountedOnce

// each unit: in stock, in a cart or soldval addedItemsCountedOnce = VARIANTS.forall(v => available.get(v) + held(v) + sold.get(v) == STOCK.get(v))

✓ completedCartsAreClosed

▸ Tests 8/12

▸ Bugs 0 open

The result: A continuously maintained source of control over your software, from design through development and production.

See Quint Studio in action

Quint is battle-testedand Studio packages what those battles have taught us

Quint, the language, is open source. It launched in 2022 and has been used across industries since, from databases and protocols to UI interactions.

As Seen On