Home / Docs / Diagnostics

U3020: Call into a boundary module whose capability is not granted with with

Release v0.4.0

A call into a boundary module needs a capability that the call does not grant with with.

Why Una rejects it

From edition 0.3, una.toml can declare modules of the package as boundaries under [boundaries], and from edition 0.4 the boundaries section of ita.una does (ADR 0093): code the package's author does not control, such as a vendored library or a plug-in. No authority crosses a boundary by name.

A call into a boundary module, from any module outside its extent, does not meet the callee's uses from the caller's bindings by name. Every capability the callee needs is granted at the call with with, as a rebinding, a narrowed rebinding (@y[ops]) or a handler.

The same holds for:

An example's do line takes no with, so an example outside a boundary can call only boundary functions that need no capability.

How to fix it

The repair is a grant at the call, within the boundary's ceiling (U3021), narrowed to what the callee declares.

Widening the caller's header or the ceiling is never the repair: the grant is what the consumer reviews, and the ceiling is the consumer's decision.

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)
+   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)

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]