Home / Docs / Diagnostics

U3021: Call that grants a boundary module more than its ceiling

Release v0.4.0

A call into a boundary module grants it more than its ceiling.

Why Una rejects it

From edition 0.3, each entry of [boundaries] in una.toml, or from edition 0.4 of the boundaries section of ita.una, gives a boundary module its ceiling: the most authority it may ever receive, as C[ops] strings (ADR 0093). At every call into the boundary, what the call grants must lie within the ceiling:

The examples of a boundary module grant it their given handlers, each with its own uses, and are checked the same way, at the given line.

How to fix it

Raising the ceiling is a decision about trust, never a repair, and una fix never applies an edit of U3021 nor writes una.toml or ita.una.

The repair at a glance

src/demo/app.unadiff
  module demo.app

  import demo.store (Files)
  import demo.vendor (load)

  pub open(path: Text) -> Text
    uses @files: Files[read, write]
  =
-   load(path) with @files = @files
+   load(path) with @files = @files[read]

Failing example

una.tomltoml
[package]
name = "demo"
version = "0.1.0"
edition = "0.3"

[boundaries]
"demo.vendor" = ["Files[read]"]
src/demo/store.unauna
module demo.store

pub capability Files
  op read(path: Text) -> Text
  op write(path: Text, data: Text) -> Unit
src/demo/vendor.unauna
module demo.vendor

import demo.store (Files)

pub load(path: Text) -> Text
  uses @files: Files[read]
=
  @files.read(path)
src/demo/app.unauna
module demo.app

import demo.store (Files)
import demo.vendor (load)

pub open(path: Text) -> Text
  uses @files: Files[read, write]
=
  load(path) with @files = @files

Fixed example

una.tomltoml
[package]
name = "demo"
version = "0.1.0"
edition = "0.3"

[boundaries]
"demo.vendor" = ["Files[read]"]
src/demo/store.unauna
module demo.store

pub capability Files
  op read(path: Text) -> Text
  op write(path: Text, data: Text) -> Unit
src/demo/vendor.unauna
module demo.vendor

import demo.store (Files)

pub load(path: Text) -> Text
  uses @files: Files[read]
=
  @files.read(path)
src/demo/app.unauna
module demo.app

import demo.store (Files)
import demo.vendor (load)

pub open(path: Text) -> Text
  uses @files: Files[read, write]
=
  load(path) with @files = @files[read]