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.

curl -fsSL https://raw.githubusercontent.com/una-lang/una/main/install.sh | sh
Or hand this to your agentFetch https://una-lang.org/llms.txt and follow it to install Una. Then run "una --version" and "una explain U5001".

Research beta · open source · macOS arm64 · Linux arm64

stock.unaOutput for
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  if remaining == 0 then SoldOut else if remaining < 20 then Few else Open

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

$ 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 the clause holds
$ una --json check stock.una   # trimmed
{ "code": "U5001",
  "obligation": { "kind": "postcondition", "status": "refuted" },
  "counterexample": { "bindings": [
    { "name": "remaining", "value": 0 },
    { "name": "result", "value": "Few" } ] },
  "repairs": [ { "rank": 1, "escape_cost": 0,
    "description": "add a guard or an arm ..." } ] }

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

$ una check stock.una
$ 

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

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

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

Read the header and you know what the function can do.

In a short-links example, effects and failures appear in the header. The compiler checks the declared limits as the program is composed.

shortlinks/links.unaFROM THE REPOSITORY
--- A slug, checked once where it enters the program.
pub kind Slug = Text where valid_slug(it)

pub kind LinkError = BadSlug | Unknown(slug: Text) | StoreDown
pub kind StoreError = | Offline

--- Where short links are kept.
pub capability Links
  op put(slug: Slug, target: Text) -> Unit
    fails StoreError

--- Stores a short link and returns its slug.
pub shorten(raw: Text, target: Text) -> Slug
  uses @links: Links[put]
  fails LinkError
=
  let slug = parse_slug(raw)
    if error fail BadSlug
  @links.put(slug, target)
    if error fail StoreDown
  slug

uses @links: Links[put]

The function may store links through the declared operation. It gets no implicit authority over anything else.

fails LinkError

The failures that reach callers have names. Each call handles its result before going on.

Text where valid_slug(it)

Slug is a refined type. The input text is checked in parse_slug before it becomes a slug.

checked

checked tests a fact when the program runs, where the text enters, instead of proving it. Each module has a budget for these, so they stay few and visible.

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

Una checks the properties you declare in the code and in the package. Its report also lists what is trusted, assumed or left to human review.

Contracts requires, ensures

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 uses @

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 public < secret

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 --json

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.

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

Is it ready?

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