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:
- each
withbinding that the callee'susesname counts at every operation the binding permits, not only those the callee declares, so rebinding a read-write binding as it is grants both; - a handler counts with its own
uses, the authority it runs with on the boundary's behalf; - the
usesof a function value or lambda given as an argument count too, since the boundary can run it.
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
- The repair narrows the grant to the ceiling, with
with @x = @y[ops]or a handler whoseuseslie within it. - When the callee needs more than the ceiling, no grant keeps both, and the repair says so: the consumer decides between the library and the ceiling.
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.una
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.toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.3"
[boundaries]
"demo.vendor" = ["Files[read]"]src/demo/store.una
module demo.store
pub capability Files
op read(path: Text) -> Text
op write(path: Text, data: Text) -> Unitsrc/demo/vendor.una
module demo.vendor
import demo.store (Files)
pub load(path: Text) -> Text
uses @files: Files[read]
=
@files.read(path)src/demo/app.una
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 = @filesFixed example
una.toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.3"
[boundaries]
"demo.vendor" = ["Files[read]"]src/demo/store.una
module demo.store
pub capability Files
op read(path: Text) -> Text
op write(path: Text, data: Text) -> Unitsrc/demo/vendor.una
module demo.vendor
import demo.store (Files)
pub load(path: Text) -> Text
uses @files: Files[read]
=
@files.read(path)src/demo/app.una
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]