Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Warder

Warder is the project tool for Restrict Language v0.0.1. It creates project layouts, edits the repository-root warder.toml, builds Restrict source through the compiler, creates local cage files, and runs basic project checks.

Commands

The v0.0.1 CLI exposes these subcommands:

CommandDescription
warder new <name>Create a project directory
warder initInitialize the current directory
warder add <alias> --path <dir>Add a direct local path dependency
warder remove <name>Remove a dependency
warder buildBuild the package
warder run [args...]Build, then run the generated WASM
warder test [filter]Compile and execute Boolean tests under tests/
warder publishRun publish preflight checks
warder wrap <wasm>Wrap a WASM file into an experimental cage
warder unwrap <cage>Extract a cage
warder doctorCheck project structure and tools

The table above is the complete v0.0.1 subcommand surface.

Every subcommand accepts the global --project <dir> option. This makes it possible to build or test a project from a script without changing the caller’s working directory:

warder build --project ./services/checkout
warder test --project ./services/checkout

Projects

Create a new project:

warder new my-project
cd my-project

This creates:

my-project/
├── warder.toml
├── src/
│   └── main.rl
├── tests/
│   └── main_test.rl
├── README.md
└── .gitignore

Initialize an existing directory:

warder init

warder init writes the root warder.toml, creates src/ and tests/ when needed, and adds a starter src/main.rl only when there is no existing source entry point.

Repository Configuration

warder.toml is the only authored Warder configuration in a managed repository. warder new and warder init generate this minimal form:

manifest-version = 1

[package]
name = "my-project"
version = "0.1.0"

The project conventions supply src/main.rl as the entry, edition 2025, and the default build settings (wasm32, optimization enabled, and dist/). Empty dependencies are omitted. Write package.entry, package.edition, or a build table only when overriding those conventions; description and authors remain optional metadata.

Adding a local dependency creates a separate table when it is needed:

[dependencies]
local_utils = { path = "../local-utils" }

The current implementation has one publishable root package. Direct local source packages are selected centrally from this root file; they do not have leaf manifests or leaf locks. A future multi-publish workspace graph will extend this same root warder.toml rather than add a workspace file or member manifests. Public package and Component identities are explicit configuration, not values derived from directory names.

The dependency-table key is the source namespace used by import. In the current v0.0.1 buildable slice, every dependency must be a direct local path dependency. The alias must be one non-keyword Restrict identifier, so use local_utils rather than local-utils; Warder never converts hyphens implicitly. The aliases std and project are reserved; Warder maps project to the root package source directory while compiling tests.

Registry versions, Git repositories, foreign WASM dependencies, and dependencies declared by a local dependency are not resolved yet. warder add, warder build, and warder test reject those forms explicitly instead of writing placeholder lock entries. Use warder wrap separately for experimental local evaluation of a foreign WASM file.

An explicit build table controls the target name, whether optimization is requested, and the output directory when the defaults are overridden.

Dependencies

Add a local dependency:

warder add local_utils --path ../local-utils

The referenced local source package needs only its library root:

local-utils/
└── src/
    ├── lib.rl
    └── numbers.rl

A minimal src/lib.rl might export a function:

pub fun score: () -> Int32 = {
    42
}

Remove a dependency:

warder remove local_utils

Package namespaces

The root configuration binding mounts the dependency’s src/ directory under its alias:

Source importDependency file
import local_utils.{score}../local-utils/src/lib.rl
import local_utils../local-utils/src/lib.rl
import local_utils.numbers.{double}../local-utils/src/numbers.rl

An unqualified import inside a dependency stays package-local. For example, import numbers.{double} inside local-utils/src/lib.rl resolves to that package’s src/numbers.rl, not an application module.

This is a configuration-to-compiler namespace binding. It does not add source-level import ... as aliases or re-exports; both remain unsupported.

On a successful build, Warder writes one generated warder.lock beside the root configuration. The lock records only dependency choices that cannot be reconstructed deterministically from repository sources. Direct local source packages are therefore not lock entries. Registry, Git, foreign WASM, and transitive resolution currently fail closed, so a local-only lock has no resolved package entries. Commit warder.lock when Warder generates it; do not edit it by hand.

Warder compiles immutable snapshots of both the application source tree and each dependency source tree. It rejects overlapping application, dependency, and output roots. Builds for one project are serialized, and the WAT, WASM, Cage, and lock file are published together through a recoverable transaction; a failed compile keeps the previous artifact set intact.

Build Outputs

Build the project:

warder build

For a package named my-project at version 0.1.0 with no [component] selection, the default outputs are:

dist/my-project-0.1.0.wat
dist/my-project-0.1.0.wasm
dist/my-project-0.1.0.rgc

The output stem is always <name>-<version>. Change the output directory with the root configuration’s build.output field.

The build target is read from warder.toml, not from a command-line flag.

Use watch mode during local iteration:

warder build --watch

Warder performs an initial build, then rebuilds when warder.toml, project .rl files, or .rl files in a configured direct local dependency change. This is a full rebuild watcher, not an incremental compiler or an npm bundler.

Component build

A Component project requires a schema-v1 or schema-v2 [component] selection in the root warder.toml. Ordinary pub and export declarations are not published implicitly. For example, schema v1 selects a public root function:

[component]
schema = 1
package = "acme:my-project@0.1.0"
world = "my-project"
abi = "canonical-v1-sync"

[[component.exports]]
interface = "api"
source = "run"
name = "run"

Once [component] is present, plain warder build publishes the Component artifact set. --component is an explicit assertion that the project must have a Component selection, while --core overrides the project default:

warder build
warder build --component
warder build --core

Warder validates and transactionally publishes this set together with the lock update:

dist/my-project-0.1.0.component.wasm
dist/my-project-0.1.0.component.wit
dist/my-project-0.1.0.component.toml

The metadata separates the semantic interface hash from exact Component and WIT content hashes. A failed rebuild preserves the previous complete set. Schema v2 adds root-only resources, value-only capture once-callables, and explicit generic function instances.

The .component.toml file above is generated artifact metadata under dist/, not another project configuration file. Source-first Component publication is also future work: a later edition may distinguish package-visible pub from Component-intent export, but the current implementation still requires the source-public plus [component] double gate.

Run And Test

Run the built program through an installed WASM runtime:

warder run
warder run -- arg1 arg2

warder run builds first, then looks for the generated dist/<name>-<version>.wasm. It is currently a Core Wasm program runner. In a Component project it reports that it is forcing a Core build; Component execution needs an explicit Component host.

Run tests:

warder test
warder test bonus

Warder discovers source-public functions whose names begin with test_ or end with _test. Each test must be synchronous, non-generic, take no arguments, and explicitly return Boolean:

import project.main.{calculate_bonus}

pub fun test_bonus: () -> Boolean = {
    (21, 4) calculate_bonus == 25
}

Warder compiles each test file to WASI Preview 1 Core Wasm and executes every matching export in an isolated Wasm instance. true passes; false, a trap, a compilation error, or a missing export fails. The optional filter matches function names. Tests resolve the same direct-local dependencies as warder build. This is a convention over ordinary functions, not a dedicated test declaration syntax. The reserved project namespace maps to the directory containing package.entry, which is src/ by default.

Publish Preflight

warder publish
warder publish --registry https://example.com/registry

For v0.0.1, warder publish performs a release-style preflight build and metadata validation. Registry upload, authentication, and signing remain experimental and no package is uploaded. This preflight currently validates the Core Cage profile and reports when it forces a Core build for a Component project.

Cage Commands

Builds already write a local .rgc cage next to the .wat and .wasm files.

Wrap an external WASM module for local evaluation:

warder wrap module.wasm --name module-name --version 0.1.0
warder wrap module.wasm --name module-name --version 0.1.0 --wit interface.wit --output module-name-0.1.0.rgc

Extract a cage:

warder unwrap module-name-0.1.0.rgc
warder unwrap module-name-0.1.0.rgc --output extracted-module

Foreign Wasm wrapping is experimental in v0.0.1. wrap --wit stores the caller-supplied WIT text without parsing, type-checking, matching it to the Core module, or componentizing the module. It is separate from warder build --component, which generates and validates the Component artifact set from a Restrict package selection.

Doctor

Check the current project:

warder doctor

warder doctor validates the root warder.toml, checks that the entry source exists, and validates warder.lock when present. It also checks for a Restrict compiler and reports whether a WASM runtime such as Wasmtime or Wasmer is available.