---
title: "U3023: Header that grants more than its lock in `una.toml`"
url: https://una-lang.org/en/docs/errors/U3023/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U3023.md
---

# U3023: Header that grants more than its lock in `una.toml`

The header of a public function grants more than its lock in `una.toml`, or from edition `0.4` in `ita.una`.

## Why Una rejects it

From edition `0.3`, `una.toml` can lock the `uses` of a public function under `[contracts]`, and from edition `0.4` the `contracts` section of `ita.una` does (ADR 0092 rule 8). The lock is the consumer's file, so an edit to the function's header cannot widen what the function may do. The header must be at least as strong as its lock:

- every binding of the header is one that the lock names, with the same capability;
- every operation of a binding is one that the lock lists;
- the header's condition on a locked operation implies the lock's condition. This is a `contract_lock` obligation, and when it is refuted the diagnostic is U3023 too;
- the header reads a locked operation at least at the label the lock writes after `gives` (ADR 0094): a lock `"@service_files: Files[owner gives internal[Service]]"` refuses a header that reads `owner` at `public` or at a label that leaves out `Service`. `una fix` writes the label back, joined with the header's.

A header may drop a binding or an operation, strengthen a condition, or read an operation at a higher label: that grants less.

## How to fix it

The repair is to bring the header back to its lock. Changing the lock is never the repair.

## The repair at a glance

`src/demo.una`

```diff
  module demo

  pub capability Catalog
    op price(sku: Int) -> Int
    op set_price(sku: Int, cents: Int) -> Unit

  pub update(sku: Int, cents: Int, dry_run: Bool) -> Unit
-   uses @shop: Catalog[price, set_price]
+   uses @catalog: Catalog[price, set_price where not dry_run]
  =
-   @shop.set_price(sku, cents)
+   if not dry_run
+     @catalog.set_price(sku, cents)
+   unit
```

## Failing example

`una.toml`

```toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.3"

[contracts]
"demo.update" = ["@catalog: Catalog[price, set_price where not dry_run]"]
```

`src/demo.una`

```una
module demo

pub capability Catalog
  op price(sku: Int) -> Int
  op set_price(sku: Int, cents: Int) -> Unit

pub update(sku: Int, cents: Int, dry_run: Bool) -> Unit
  uses @shop: Catalog[price, set_price]
=
  @shop.set_price(sku, cents)
```

## Fixed example

`una.toml`

```toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.3"

[contracts]
"demo.update" = ["@catalog: Catalog[price, set_price where not dry_run]"]
```

`src/demo.una`

```una
module demo

pub capability Catalog
  op price(sku: Int) -> Int
  op set_price(sku: Int, cents: Int) -> Unit

pub update(sku: Int, cents: Int, dry_run: Bool) -> Unit
  uses @catalog: Catalog[price, set_price where not dry_run]
=
  if not dry_run
    @catalog.set_price(sku, cents)
  unit
```
