---
title: "U4004: `policy` outside a trusted module"
url: https://una-lang.org/en/docs/errors/U4004/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U4004.md
---

# U4004: `policy` outside a trusted module

A module whose header does not say `trusted` declares a policy.

## Why Una rejects it

A policy lowers labels, so it is part of the trusted computing base. It is allowed only in a module whose header says `trusted module` and that `una.toml` lists under `[trusted] modules`, or from edition `0.4` the `trusted` section of `ita.una` (`spec/07 §5, §6`).

U4004 reports a policy in a module whose header does not say `trusted`. A header that says `trusted` without the listing is U7005.

## How to fix it

- The repair that keeps the trusted base comes first: move the policy and its `via` function into a module that is already trusted, as the fixed example does.
- Declaring this module trusted in both places is the last repair, marked as an escape (ADR 0095): every line of a trusted module joins the trusted base and is listed in the build report.

## The repair at a glance

`src/keys.una`

```diff
  trusted module keys

  pub pepper() -> Int = 7
+
+ pub policy reveal
+   from secret Text
+   to Text
+   via shown
+   purpose "show a digest"
+   owner privacy
+
+ shown(t: secret Text) -> Text = t
```

`src/demo.una`

```diff
  module demo

- pub policy reveal
-   from secret Text
-   to Text
-   via shown
-   purpose "show a digest"
-   owner privacy
-
- shown(t: secret Text) -> Text = t
+ pub one() -> Int = 1
```

## Failing example

`una.toml`

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

[trusted]
modules = ["keys"]
```

`src/keys.una`

```una
trusted module keys

pub pepper() -> Int = 7
```

`src/demo.una`

```una
module demo

pub policy reveal
  from secret Text
  to Text
  via shown
  purpose "show a digest"
  owner privacy

shown(t: secret Text) -> Text = t
```

## Fixed example

`una.toml`

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

[trusted]
modules = ["keys"]
```

`src/keys.una`

```una
trusted module keys

pub pepper() -> Int = 7

pub policy reveal
  from secret Text
  to Text
  via shown
  purpose "show a digest"
  owner privacy

shown(t: secret Text) -> Text = t
```

`src/demo.una`

```una
module demo

pub one() -> Int = 1
```
