Manuscript Documentation
v2026.12.0

Effects and permissions#

A function is pure unless a comment permits what it reaches. ms check --only lint reports a function that prints, reads a file, calls the network or reads the clock without that permission, and names the call that brings the effect in. Effects are comments, so the language has no extra syntax.

Manuscript
fn total(prices List[Int]) Int {
    print(f"summing {prices.length()} prices")

    sum := prices.sum()
    return sum
}

fn main() Void {
    print(total([2, 3]))
}
text
a.ms:2:5: warning MSL116: `total` reaches std.console.write: total -> print; permit it with `// ms: allow_effect std.console.write`, move the call to the caller, or take a capability parameter

main, test and fixture may do anything, so main is not reported. total is: the print is a surprise in a function that only adds numbers.

Permit what a function needs#

// ms: allow_effect NAME directly above a function permits it to reach that effect. Put the lines at the top of a file, ended by a blank line, to cover every function in the file. A function’s own lines can only narrow its file’s.

Manuscript
// ms: allow_effect std.fs.read

import (
    Bytes from "@std/bytes.ms",
    read_file from "@std/os/fs.ms",
)

fn load(path String) Bytes! {
    return read_file(path).wait()
}

fn main() Void {
    return
}

Each line names one effect or a pattern:

LinePermits
std.fs.readthat effect only
std.fs.*every effect under std.fs
*.readevery effect that ends in read
*everything

A file with no line is pure. Prefer the narrowest line, and prefer passing a capability over a wide permission.

Pass a capability instead#

A function that is handed an interface value does not need a permission to use it. The permission belongs where the value is made.

Manuscript
interface Logger {
    fn info(message String) Void
}

type ConsoleLogger {
    prefix String
}

// ms: allow_effect std.console.write
fn ConsoleLogger.info(message String) Void {
    print(f"{self.prefix}{message}")
}

fn total(log Logger, prices List[Int]) Int {
    log.info(f"summing {prices.length()} prices")

    sum := prices.sum()
    return sum
}

fn main() Void {
    print(total(ConsoleLogger("> "), [2, 3]))
}

total is pure here, so a test can pass a logger that records messages. Turning a ConsoleLogger into a Logger inside a pure function would be reported, because that is where the authority is obtained. The same holds when a function is written as a closure, named as a value, or passed for a generic parameter.

Declare your own effect#

// ms: effect NAME says a function performs NAME. Callers see that name instead of what the body reaches, so a wrapper can hide how it works.

Manuscript
import write_file from "@std/os/fs.ms"

// ms: effect db.write
// ms: allow_effect std.fs.write
fn save(order String) Void! {
    return write_file("orders.log", order).wait()
}

// ms: allow_effect db.*
fn checkout(total Int) Void! {
    return save(f"order {total}")
}

fn audit(total Int) Void! {
    return save(f"audit {total}")
}

fn main() Void {
    return
}

save may write a file and declares db.write. checkout may use any db effect but not the file system directly. audit has no line, so it is reported for db.write. Names starting with std. belong to the standard library.

Standard-library effects#

Standard-library functions declare what they let a caller do. Calls through a handle you already hold, such as reading from an open file, do not need a second permission.

EffectCovers
std.fs.read, std.fs.write, std.fs.deletefiles and directories
std.net.connect, std.net.listennetwork clients and servers
std.process.run, std.process.signal, std.process.read, std.process.writestarting, signalling and inspecting processes
std.env.read, std.env.writeenvironment variables and the working directory
std.clock.read, std.clock.sleepthe current time and waiting
std.random.readrandom values
std.console.read, std.console.writestandard input, output and error
std.system.readhost facts such as the hostname and system roots

ms search read_file prints effects: std.fs.read, and hovering a function in the editor shows its effects, its permissions, or that it is pure.

Seeing and reviewing effects#

  • ms check --only lint reports MSL116 for unpermitted effects (--deny-warnings makes it fail; --fix inserts the minimal // ms: allow_effect line above the function) and MSL136 as an error for malformed or unknown // ms: directives and user std.* declarations.
  • Hovering a function or method in the editor shows its effects, its permissions, or effects: pure (ambient authority only).
  • ms map --view review ms.toml --diff change.patch lists new permissions and newly reached effects as “new effect” changes (EFFECT+ in --json), permissions first. --effect 'std.net.*' keeps only the findings for one effect.
  • Understanding effects describes the separate call-graph view.

Rules and limits#

  • Defaults charge the caller: an omitted parameter or field default expression is checked against the caller’s permissions, not the callee’s.
  • Generics and implicit calls: generic functions and methods charge the interface methods and close of their concrete type arguments; ==/!=, </<=/>/>=, f"{x}", for x in iter, and scope-end close charge the concrete type’s equals, compare, to_string, next, and close methods.
  • Fetched packages: a dependency package cannot exceed the effects declared in its ms.toml, even if its source writes // ms: allow_effect *.
  • Foreign functions: a user-declared extern fn carries the ffi effect by default unless it declares explicit // ms: effect lines, so foreign code is never treated as pure.
  • Capabilities: ambient-pure functions may call interface methods or function values handed to them; effects are not tracked through runtime values or checked while the program runs.