---
title: "Una: the agent writes, Una verifies"
url: https://una-lang.org/en/
release: v0.4.0
---

# Una

> Your AI agent writes the code. Una proves it keeps its contracts before it runs. A programming language with declared authority and JSON output for agents.

The agent writes. Una verifies.

Your agent writes the code. Una proves each function's declared contract for every input, or shows the input that breaks it; what it cannot decide is an error, never a pass. What a function may touch, such as files, the network or sensitive data, is in its header too.

## One round of the loop

1. Agent writes. Your agent wrote this function. It reads fine, and a test with 5 or 50 items would pass.

```una
pub kind Availability = SoldOut | Few | Open

--- How much of an item is left to sell.
pub availability(remaining: Int) -> Availability
  requires remaining >= 0
  ensures remaining == 0 implies result is SoldOut
=
  if remaining < 20 then Few else Open
```

2. Una refutes.

```text
$ una check stock.una   # trimmed
[U5001] postcondition of `availability` is refuted
counterexample: remaining = 0, result = Few
repair 1: add a guard or an arm so that the failing path returns a value for which `remaining == 0 implies result is SoldOut` holds
```

3. Agent repairs. The agent applies repair 1: a guard for the input the counterexample names.

```una
  if remaining == 0 then SoldOut else if remaining < 20 then Few else Open
```

4. Proven. Nothing printed, exit 0. The promise now holds for every `remaining >= 0`, not only for the inputs a test tried.

```text
$ una --json check stock.una
{"schema":"una.diagnostics/1","diagnostics":[],"fixable":0}
```

Una proves that the code matches what you declared. Declaring the right thing is still your job.

## What Una checks, and what it tells you it did not.

- Contracts: Preconditions, postconditions and refined types are proven before the program runs. A proof that fails, or that the prover cannot finish, is an error and never a pass.
- Authority: Each public function declares the capabilities and operations it uses, and Una infers and checks the rest. A program gets authority from the host only through grants: those its package declares, and those given on the command line for one run.
- Information flow: Labels follow data through assignments and conditions. A value labeled secret reaches a less restricted place only through a declared policy, which the build report lists.
- Agent interface: Every command but the language server returns JSON with a schema: diagnostic codes, exact positions and, where they exist, ranked repairs an agent can apply.

## Start where you are.

```sh
curl -fsSL https://raw.githubusercontent.com/una-lang/una/main/install.sh | sh
export PATH="$HOME/.una/bin:$PATH"
una explain U5001
```

- [In five minutes: Install Una, write a contract, watch it fail, fix it.](https://una-lang.org/en/docs/get-started.md)
- [With your agent: Give your agent the language in one page and the loop to run.](https://una-lang.org/en/docs/agents/compact.md)
- [From the ground up: Una by Example: small complete programs, one idea per page.](https://una-lang.org/en/learn.md)
- [Language guide](https://una-lang.org/en/docs/language.md)
- [Diagnostics](https://una-lang.org/en/docs/errors.md)

Una is a research beta and is not ready for production use. Feedback is welcome.
