---
title: "Requirements and examples"
url: https://una-lang.org/en/docs/guides/requirements-and-examples/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/docs/guide/una-for-agents.md
---

# Requirements and examples

A requirement records a statement with its source and owner; `derived from` traces functions to it, and `una trace <ID>` lists them with their obligations. A `generated` requirement stays `proposed` until a person changes its source.

Examples are executable evidence next to the code: `given` installs handlers (never host capabilities), `do` runs one expression, and each `expect` checks `result`, `fails V`, `performed @x.op` or `not performed @x.op`. `una test` runs them with their effect traces. A `do` line whose call fails is checked with `expect fails V`, as `parse_slug` in §6 shows; `do attempt f(x)` with `expect result == Err(V)` checks the same through the `Result`.

```una
module demo

requirement SEATS_1
  text "An event with no seats left is shown as sold out"
  source human
  owner box_office
  status active

pub kind Availability = SoldOut | Open

pub availability(remaining: Int) -> Availability
  ensures remaining < 1 implies result is SoldOut
  derived from SEATS_1
=
  if remaining < 1 then SoldOut else Open

example "no seats left is sold out"
  do availability(0)
  expect result is SoldOut
```
