Captain / Documentation / Part 8. Where Captain runs

Captain in the platform's tools

Contents ↓

Captain is not only run with the captain command. Several of the platform's tools take a Captain program as their input: a build recipe, a project's tasks, a command sent to a machine, an application, an HTTP handler. Each tool is a host. It decides which effects a program may reach, gives it a small vocabulary for them, and refuses, before the program starts, anything outside that vocabulary.

The language is the same everywhere. The checker, the compiler, the bytecode and the VM are the ones this book describes. What differs from host to host is the module a program uses, which entries the host calls, and what the host checks beyond captain check.

Host The program Its module Checked by captain check Then refused by
Forge .forge, a build recipe Forge::Tasks (built in) yes forge check: any effect that is not a Forge task
Bosun bosun.capt, a project's tasks Bosun::Tasks (built in) yes bosun: any effect that is not a Bosun task
Mate a program sent to a machine Mate::Machine (built in) yes the machine: the caller's rights and path grants
Fleet a .fleet design, and formula programs formulas use Mate::Machine the formulas, yes; the design is TOML fleet: wiring, and each formula's inputs against its entry
Apps a .capb application App::Ui (lib/app/ui.capt) yes, with the library captain-app check: any effect at all, and the app contract
Workers a .capb HTTP handler Worker::Http (lib/worker/http.capt) yes, with the library captain-worker check: any effect but its three
Lifeboat and Gate backup plans, a draft; a qualification runs a Bosun task Lifeboat::Tasks, not built yet not yet

Two kinds of module

Hosts give their vocabulary in one of two ways, and a program reads differently for each.

Built-in modules. Forge::Tasks, Bosun::Tasks and Mate::Machine are known to the checker itself (crates/captain-check/src/prelude.rs). use Forge::Tasks. brings their types and effects into scope, and a program calls them unqualified: fetchCrates commit: commit, run named: "fmt" …, show memory: #this. Their effects may have optional trailing keywords, such as Bosun's in: and timeout:, which a declaration in Captain source cannot have today.

Library modules. App::Ui and Worker::Http are ordinary Captain source in lib/. A program is checked and built together with the library file, and calls the library's procedures qualified by the module's last segment: Ui::column children: …, Http::text status: 200 body: "hello". See Modules and names.

The common rule

Every host reads the compiled artifact's manifest, which lists each effect an export can reach, and admits the program only if that list is inside the host's vocabulary. So the refusal happens at the door, not in the middle of a run, and it does not depend on which branch a program happens to take. That is the same property Effects describes for every Captain program, put to work by a host that knows exactly what it is willing to do.

Each chapter shows what a program looks like for one host, what it may use, what is checked, and where that host's own documentation is. The chapters do not repeat those documents: the commands, file formats and operations of each tool belong to it.