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

Five Crates, Ports and Adapters

buildl is five Rust crates, split so that the logic of a build depends only on abstractions it owns. Everything that touches the outside world, the airsl engine, the filesystem, child processes, threads, the clock, plugs into that logic from the outside. Two of the five are binaries: buildl-cli, the buildl command, and buildl-cargo, the cargo buildl command.

buildl/
  Cargo.toml        # workspace: resolver 3, shared lints (airsl's lint set)
  crates/
    buildl-core/    # domain data, ports (traits), pure logic of every phase: no I/O, no Lua
    buildl-lua/     # DeclarationSource over airsl: engine per file, the buildl HostModule
    buildl/         # every other adapter + LocalPorts + the command line: the composition root
    buildl-cli/     # the `buildl` binary: `main` alone, which calls buildl::cli::run
    buildl-cargo/   # the `cargo-buildl` binary, run as `cargo buildl`: buildl's commands from cargo

The workspace shares airsl's policy: unsafe_code = "forbid", unwrap_used and panic denied, Clippy's pedantic and nursery groups at warn, and a comment in the workspace Cargo.toml giving the reason for every dependency.

The five crates

Every dependency points at buildl-core, and buildl is the one crate that names concrete adapters together. The two binaries are thin: each depends on buildl and on nothing else of buildl's:

%% Crate dependency graph — arrows point at the dependency
graph TD
    CLI["buildl-cli<br/>main"] --> LIB["buildl<br/>adapters + command line + composition root"]
    CARGO["buildl-cargo<br/>cargo-buildl"] --> LIB
    LIB --> LUA["buildl-lua<br/>DeclarationSource via airsl"]
    LIB --> CORE["buildl-core<br/>domain data · ports · pure logic"]
    LUA --> CORE
    LUA --> AIRSL["airsl<br/>Engine, Policy, HostModule"]

Two rules are built into that picture:

  • airsl is a dependency of buildl-lua only. No other crate knows Lua exists, and buildl-core cannot name airsl at all, because airsl is not among its dependencies. The whole boundary with the runtime is one crate deep. That keeps the execution side testable without a Lua state, and keeps an airsl upgrade from spreading.
  • Phases talk through values, not calls. Load hands on Vec<Declaration>, Resolve a TargetGraph, Plan a Plan, Execute Vec<ActionOutcome>, as Declare, Then Execute showed. The pipeline in buildl-core owns the order, and no phase calls the next.

Dependency inversion

The logic of a build, loading, resolving, planning, scheduling and recording, depends only on abstractions it defines itself. The concrete implementations depend on those abstractions, and exactly one place picks which implementations run together. This is Robert C. Martin's Dependency Inversion Principle. The abstractions are ports and the implementations are adapters, in Alistair Cockburn's hexagonal architecture:

%% Dependency direction — arrows point at the dependency
graph TD
    ROOT["buildl<br/>composition root: LocalPorts"] --> LOGIC["buildl-core<br/>pure logic of every phase"]
    ROOT --> ADAPT["adapters in buildl and buildl-lua<br/>airsl engine · filesystem · processes · threads · clock"]
    LOGIC --> PORTS["buildl-core<br/>ports — traits"]
    ADAPT --> PORTS
    ADAPT --> AIRSL["airsl"]
    BINS["buildl-cli and buildl-cargo<br/>the two binaries"] --> ROOT

The structure exists for one result: every flow of the pipeline runs in buildl-core's tests against fake ports, with no Lua state, no filesystem, no process and no thread. Testing Layers shows how.

What buildl-core may depend on

Dependency inversion is aimed at I/O and at parts that change often. A stable library doing pure computation is not the implementation of a port, so the core may use one directly:

buildl-core may depend onbuildl-core must not depend on
std, excluding its I/O, process, thread, environment, and clock APIsairsl, mlua, toml, clap
serde, serde_jsonstd::fs, std::process, std::thread, std::env, SystemTime
thiserrorrayon, tempfile, walkdir, globset
sha2any other buildl crate

The table is the rule. crates/buildl-core/clippy.toml spells it out: 129 entries across disallowed-methods, disallowed-types and disallowed-macros, split into nine families:

FamilyEntriesNote
the filesystem41counting the nine Path methods that reach it
the environment23including the compile-time reads and the two PATH-format helpers
threads20
processes14std::process::ExitCode is unbanned: rustc's generated test harness names it through libtest's re-export, which clippy 1.100 flags with a spanless error on every test target (see the decision record)
the platform filesystem extensions13
the standard streams10including the print macros
the clock3
the network3
floating-point numbers2not an I/O surface at all

The nine counts add up to the 129, so the families cover the whole file. A float is banned because a non-finite one is written to JSON as null, so a value could reach an action key that differs from the value it was computed from (Determinism Rules, rule 2). cargo make guard-core-purity checks that every entry still names something real, that no source file switches the lints off, and that the file itself is not switched off.

The name buildl

Three different things are called buildl, and the crates keep them apart:

NameWhat it isLives in
buildl binarythe command users runbuildl-cli ([[bin]] name = "buildl"), whose main calls buildl::cli::run
buildl Lua globalthe declaration framework build authors callbuildl-lua (the buildl HostModule)
buildl Rust cratethe complete framework: every real adapter wired onto buildl-corecrates/buildl

The fifth crate has a name of its own. buildl-cargo holds the cargo-buildl binary, which cargo runs as cargo buildl. It runs every command through buildl::cli::execute, so a command given to cargo buildl takes the buildl binary's flags and gives its output and exit codes.

The C4 views

The rest of the structure is drawn as the four levels of Simon Brown's C4 model: the system in its surroundings, then its running parts, then the components inside the process, then the code.

Level 1: system context

%% C4 level 1 — system context
graph TD
    AUTHOR["[Person]<br/>Build author<br/>writes build.lua, runs buildl"]
    CI["[Person]<br/>CI pipeline<br/>runs build and plan, reads the exit class"]
    BUILDL["[Software system]<br/>buildl<br/>sandboxed, deterministic build system:<br/>Lua declares, Rust executes"]
    WS["[External system]<br/>Workspace filesystem<br/>sources, out/"]
    TOOLS["[External system]<br/>Toolchains<br/>go, cargo, bun, docker"]
    REMOTE["[External system]<br/>Remote cache and executor — REAPI over gRPC<br/>results shared between machines, actions run there"]
    GIT["[External system]<br/>Plugin repositories<br/>read by buildl plugins fetch"]
    AUTHOR -->|"writes build files, invokes commands"| BUILDL
    CI -->|"invokes build and plan"| BUILDL
    BUILDL -->|"reads, writes"| WS
    BUILDL -->|"spawns, no shell"| TOOLS
    BUILDL -->|"looks results up, stores them and sends actions when asked"| REMOTE
    BUILDL -->|"fetches a pinned revision, through the system git"| GIT

Level 2: containers

A C4 container is a separately running process or a place data is kept. The crates are not containers: they compile into the two binaries, buildl and cargo-buildl, which run the same pipeline, and appear at level 3.

%% C4 level 2 — containers
graph TD
    subgraph SYS["buildl — system boundary"]
        CLIP["[Container: Rust binary]<br/>buildl CLI process<br/>Load → Resolve → Plan → Execute → Record"]
        CARGOP["[Container: Rust binary]<br/>cargo-buildl process<br/>the same pipeline, started as cargo buildl"]
        DEFS["[Data]<br/>Build definitions<br/>buildl.toml, buildl.lock, build.lua, plugins"]
        STATE["[Data store]<br/>.buildl/<br/>cas/, cache.json, cache.journal,<br/>log.jsonl, statcache.json,<br/>graph.json, lock, plugins/"]
        OUT["[Data store]<br/>out/<br/>hard links and copies from the cas"]
    end
    CHILD["[Container]<br/>Child processes<br/>one toolchain invocation per action"]
    CARGOP -->|"reads"| DEFS
    CARGOP -->|"the same state as the CLI process"| STATE
    CARGOP -->|"links named outputs"| OUT
    CARGOP -->|"spawns argv with granted env"| CHILD
    CLIP -->|"reads"| DEFS
    CLIP -->|"cas first, row after, log always"| STATE
    CLIP -->|"links named outputs"| OUT
    CLIP -->|"spawns argv with granted env"| CHILD

Level 3: components

Inside the process, every adapter depends on buildl-core, and the one edge between adapter crates is buildl → buildl-lua, which only the composition root may hold. buildl-cargo is the second binary and calls buildl as buildl-cli does:

%% C4 level 3 — components inside the CLI process
graph TD
    CLI["[Component: crate] buildl-cli<br/>main: reads the process,<br/>calls buildl::cli::run"]
    CARGO["[Component: crate] buildl-cargo<br/>main: reads the process,<br/>calls buildl::cli::execute"]
    LIB["[Component: crate] buildl — composition root<br/>command line: cli — clap argument surface,<br/>outcome classes and error variants to exit codes<br/>adapters: manifest, host, digest, tools,<br/>cas, cache, log, statcache, graph,<br/>exec, dispatch, clock, report, approver, remote, watch,<br/>ignore_rules<br/>no port: plugins — lock, check, fetch<br/>shared: state, search_path<br/>assembly: LocalPorts, Workspace facade"]
    LUA["[Component: crate] buildl-lua<br/>implements DeclarationSource<br/>airsl Engine per build file<br/>buildl HostModule bound as a global<br/>buildl.use: one plugin instance per chain"]
    subgraph CORE["[Component: crate] buildl-core — no I/O, no Lua, no threads"]
        DATA["domain data<br/>Label, Digest, NodeId, Provenance<br/>Declaration, Origin, Discovered<br/>TargetGraph, Plan, Attribution<br/>KeyComponents, ActionKey<br/>RemoteAction, RemoteHit, RemoteUpload<br/>ChangedPath, ChangeBatch, Trigger<br/>WatchLayout, Built, Reference, Reaction<br/>Watched, Cycle<br/>ActionOutcome, OutcomeClass"]
        PORTS["ports — traits<br/>DeclarationSource, Manifest, Host<br/>Digester, StatCache, ToolResolver<br/>ContentStore, ActionCache, EventLog<br/>RunHistory, Sweep, ExecStrategy, Dispatcher<br/>Clock, GraphRecord, Reporter<br/>Approver, RemoteCache, IgnoreRules<br/>Changes, Cycles, WatchReport"]
        LOGIC["pure logic<br/>load, resolve, placement, plan, grants<br/>discovery, Schedule, record, verify<br/>react, watch, watched_inputs<br/>canonical JSON"]
    end
    AIRSL["[External crate] airsl<br/>Engine, Policy, HostModule"]
    CLI -->|"calls"| LIB
    CARGO -->|"calls"| LIB
    LIB -->|"wires"| LUA
    LIB -->|"implements"| PORTS
    LIB -->|"wires into Pipeline"| LOGIC
    LUA -->|"implements"| PORTS
    LUA -->|"evaluates with"| AIRSL
    LOGIC --> PORTS
    LOGIC --> DATA
    PORTS --> DATA
CrateRoleDepends onMust not depend on
buildl-coredomain data, ports, the pure logic of every phaseserde, serde_json, thiserror, sha2any buildl crate, airsl, any I/O API
buildl-luathe DeclarationSource adapter: evaluates one build file through airsl, and loads the plugins it usesbuildl-core, airsl, globset, walkdir, serde, serde_json, tomlbuildl
buildlevery other adapter; the plugins module; LocalPorts; the Workspace facade; the command line, in cli; re-exports buildl-core as buildl::buildl_corebuildl-core, buildl-lua, clap, toml, toml_edit, rayon, serde, thiserror, tempfile, tonic, tonic-prost, prost, prost-types, tokio, uuid, notify, ignorenothing: it is the composition root
buildl-climain alone: reads the process and calls buildl::cli::runbuildlbuildl-core and buildl-lua directly
buildl-cargothe cargo-buildl binary, run as cargo buildl: reads the process, calls buildl::cli::execute, and runs cargo buildl sync itself (reads cargo metadata, rewrites the generated section of build.lua)buildl, clap, serde, serde_json; tempfile as a dev dependency onlybuildl-core and buildl-lua directly: it reaches core types through buildl, as in buildl::buildl_core::TargetName

crates/expected-edges.txt holds that list as the gate checks it. Each adapter dependency has a reason: toml reads buildl.toml, and toml_edit points at the place in it where a [remote] table is refused, since toml keeps no positions; in buildl-lua, toml reads the env.unkeyed list of a plugin's extension.toml, a key airsl's manifest parser refuses; rayon hashes files, in the Digester adapter and nowhere else; tempfile gives the write-then-rename every state file and blob goes through. The remote cache's gRPC client is tonic, with tonic-prost, prost and prost-types for its messages, tokio for the runtime the client needs, and uuid to name uploads. Only the remote module names them. notify reports the operating system's file events to the watch module and to no other. ignore matches the patterns of .buildlignore files, in the ignore_rules module and nowhere else; buildl-lua does not depend on it, and reaches the rules through the core's port. In buildl-cargo, serde and serde_json read the output of cargo metadata.

Inside buildl there is one module per adapter, plus plugins, which serves no port but is kept apart as an adapter is, two shared modules and three that put everything together:

ModuleHoldsImplements
manifestbuildl.toml, finding the workspace root, and the [plugins.<name>] tablesManifest
hostthe operating system, the processor, environment valuesHost
digestwhat stands at an input's path, and file hashing on rayonDigester
toolsa program's lookup and its fingerprintToolResolver
cas.buildl/cas, and the files placed under out/; listed and pruned through SweepContentStore and Sweep
cachecache.json and cache.journalActionCache
loglog.jsonl, appended to and read backEventLog and RunHistory
statcachestatcache.jsonStatCache
graphgraph.jsonGraphRecord
exectier 1, Bare; tier 2, InputSandbox; and Local, which picks between them from the manifestExecStrategy
dispatchworker threads for Load and ExecuteDispatcher
clockthe system clockClock
reportterminal output, and every rendering of a value into textReporter and WatchReport
approverthe three approvers a manifest can name, LocalApprover, which picks one, and the approvals it remembers outside the workspaceApprover
remotethe Remote Execution API client: its tokio runtime, the gRPC channel, blob transfer, Execute and WaitExecution, the retry rule; behind the test-server feature, an in-memory server for testsRemoteCache
watchthe workspace's file events through notify, gathered into batches by a 50 ms windowChanges
ignore_rulesthe .buildlignore files of one workspace, read from the root down, and the decision for a pathIgnoreRules
pluginsbuildl.lock, the digest of a plugin's files, the check that every plugin is there and unchanged, and fetching git pluginsnone
stateshared: where each state file is, the state lock, writing a file whole, clearing a path, the sandbox's scratch directorynone
search_pathshared: the lookup of a program namenone
local_portscomposition: the Ports bundle and its wiringnone
workspacecomposition: the Workspace facade, and the Cycles of buildl watchnone
clicomposition: the buildl command line, its argument surface through clap, each command's flow, and the mapping of outcome classes and errors to exit codesnone

The DeclarationSource adapter is buildl_lua::LuaSource. buildl, buildl-cli and buildl-cargo build on Unix only; Linux and macOS are the supported platforms, the two the CI matrix runs.

Level 4: the code of buildl-core

Domain data

Every value is a checked newtype or a handoff that can be written out:

KindTypes
Names and identityDirectory, TargetName, Label, NodeId, Provenance
ContentDigest, the single SHA-256 type for files, outputs, keys and log blobs; Hasher, the same digest over bytes handed over in pieces
OutputsOutputManifest, with StoredFile and FileMode, Tree, TreeEntry and TreePath; Found, FoundEntry and FoundKind, what a strategy reports at an output path
TimeTimestamp, nanoseconds since the Unix epoch, read only through the Clock port
Phase handoffsDeclaration, TargetGraph, Plan, ActionOutcome
Execution handoffsOutputPath, ReadyAction with its ExpandedDescription, RawOutcome and Exit, OutcomeEvent, OnFailure, Summary
IncrementalityKeyComponents, ActionKey
AuthorityCeiling, WantedSet, Want, Workspace, Approval, DenialReason, ApproverMode, Attribution, Checkup
PluginsPluginName, PluginVersion, PluginRef, PluginChain, Origin, PluginCap, PluginNetwork, PluginViolation, PluginSource, GitUrl, Rev, TagName, CommitId
DiscoveryDiscovered, Loaded, TargetRole::Discovery
Remote cacheRemoteSettings, RemoteAction, RemoteHit, RemoteUpload, Uploaded, Blob, RemotePolicy, RemoteUse, RemoteFailure, RemoteExecution, Executed, RemoteSwitch, RemoteCall, RemoteNotice, and the smaller values they are made of
Ignored pathsEntryKind, a path as its asker knows it: file, folder or unknown; Ignoring, the ignore file and the pattern that decided; IgnoredPath, the inputs file or subdir folder an error names
Watch modeChangedPath, ChangeBatch, Trigger, WatchLayout, Built, Reference, Reaction, Watched, Cycle
Execution settingsExecution, with Workers, Timeout and Isolation; none of them is part of a key
A run and what it showsScope, Purpose, Rerun, LiveOutput, Channel, LiveSink, Captured, Turn
InputsInputStat and InputKind: nothing, a regular file, or something else at an input's path
The log, read backLogLine, LoggedRun
A verify and what it foundSample, Check, OutputDifference, FileChange, EntryChange, Verification
ClassificationOutcomeClass, InfraKind, OutputRefusal, TreeFault

Ports

A port is a trait in crates/buildl-core/src/ports/. Every fallible method returns the crate's one Result, whose error is the single buildl_core::Error enum described in Errors. Two of them show the shape:

#![allow(unused)]
fn main() {
/// Evaluates one build file. The directory queue, `subdir` handling, and the
/// sorted merge across files are Load logic in `buildl-core`, not the adapter's.
pub trait DeclarationSource: Sync {
    fn evaluate(&self, file: &BuildFile, discovered: &Discovered) -> Result<Evaluated>;
}

/// The scheduler side is the single writer. A row is durable once `record` returns
/// `Ok`; after `Err` the cache holds what it held before the call.
pub trait ActionCache {
    fn row(&self, label: &Label) -> Option<&CacheRow>;
    fn labels(&self) -> Vec<Label>;
    fn record(&mut self, label: Label, row: CacheRow) -> Result<()>;
    fn forget(&mut self, label: &Label) -> Result<()>;
}
}

The full list is the port catalog below.

Pipeline and the Ports bundle

buildl uses static dispatch throughout. One trait of associated types carries every port, so Pipeline takes a single type parameter instead of one per port. The trait lives in crates/buildl-core/src/ports/bundle.rs, beside the traits it names:

#![allow(unused)]
fn main() {
pub trait Ports {
    type Source: DeclarationSource;
    type Manifest: Manifest;
    type Host: Host;
    type Digester: Digester;
    type StatCache: StatCache;
    type Tools: ToolResolver;
    type Cache: ActionCache;
    type Cas: ContentStore;
    type Log: EventLog + RunHistory;   // plan, verify and build read discovery results from it
    type Strategy: ExecStrategy;
    type Dispatcher: Dispatcher;
    type Clock: Clock + Sync;          // a worker reads the clock
    type Graph: GraphRecord;
    type Reporter: Reporter;
    type Approver: Approver;
    type Ignore: IgnoreRules;          // Load asks it, from several threads
    type Remote: RemoteCache;          // NoRemote when there is none
}

pub struct PortSet<P: Ports> { pub source: P::Source, pub manifest: P::Manifest, /* ... */ }

pub struct Pipeline<P: Ports> { /* ports: PortSet<P> */ }

// in `buildl`: generic over the reporter and the console a build is lent
pub struct LocalPorts<R, C>(PhantomData<fn() -> (R, C)>);
pub type LocalPipeline<R, C> = Pipeline<LocalPorts<R, C>>;
}
%% C4 level 4 — the Ports bundle and its two implementations
classDiagram
    class Pipeline~P~ {
        check()
        graph()
        query()
        plan()
        build()
        build_watched()
        test()
        verify()
    }
    class Ports {
        <<trait>>
        Source: DeclarationSource
        Manifest: Manifest
        Host: Host
        Digester: Digester
        StatCache: StatCache
        Tools: ToolResolver
        Cas: ContentStore
        Cache: ActionCache
        Log: EventLog + RunHistory
        Strategy: ExecStrategy
        Dispatcher: Dispatcher
        Clock: Clock + Sync
        Graph: GraphRecord
        Reporter: Reporter
        Approver: Approver
        Ignore: IgnoreRules
        Remote: RemoteCache
    }
    class LocalPorts {
        crate buildl
        real adapters
        generic over R and C, the reporter and console of one build
    }
    class FakePorts {
        crate buildl-core, tests only
        in-memory fakes
    }
    Pipeline --> Ports : generic over
    LocalPorts ..|> Ports
    FakePorts ..|> Ports

Ports::Remote is called only by build and test. Every other command, a workspace with no [remote] table and a run with the remote turned off hold a cache that is never asked: NoRemote in the core's tests, Remote::Off in LocalPorts. Ports::Ignore has a default of the same kind, NothingIgnored, which the core's tests bind and the watch loop passes to react. Ports::Log is bound by both EventLog and RunHistory, because plan, verify, build and test read the last result of each discovery target from the log they append to. The two stay separate traits, since a writer and a reader never share a method. Ports::Ignore is asked by Load for each inputs entry and each subdir, in both discovery passes. local_ports makes one BuildlIgnore for each opening of the workspace and hands it both to Ports::Ignore and to LuaSource, whose walk asks it about every entry and never enters an ignored folder. buildl watch opens the workspace again on every cycle. Each file is read lazily and kept by that instance, so a changed .buildlignore applies at the latest from the next open. Reopening keeps the rules of the last workspace it opened and returns them through Cycles::rules.

Commands that need only a few ports are also free functions, beside the Pipeline methods. The free functions need no state directory and take no lock: pipeline::check, pipeline::graph and pipeline::query over a DeclarationSource, a Dispatcher, a RunHistory and a ContentStore; pipeline::doctor with a Manifest as well; pipeline::log over just RunHistory and ContentStore; and pipeline::gc, which adds an ActionCache and a Sweep.

Pure logic

LogicInput → outputPorts used
loadworkspace root and a Discovered → Vec<Declaration>; an inputs entry or a subdir the rules ignore is Error::IgnoredDeclarationSource, IgnoreRules, Dispatcher
discoverythe build files, the log and the cas → declarations loaded twice, the second time with the discovery resultsDeclarationSource, IgnoreRules, Dispatcher, RunHistory, ContentStore
resolveVec<Declaration> → TargetGraphnone
narrowTargetGraph, a Scope and a Purpose → the graph of what a run asked fornone
reachTargetGraph and a Query → the targets deps() or rdeps() reachesnone
planTargetGraph, setting overrides and a Rerun → PlanManifest, Host, Digester, StatCache, ToolResolver, ActionCache
grantsa plan's WantedSet and Attribution → go on, or Error::NotApproved; also what plugins do not allow, and which programs a dependency builtApprover
executethe graph, the narrowed graph, its Plan and the run's choices → Vec<ActionOutcome>Manifest, Dispatcher, ExecStrategy, ContentStore, ActionCache, EventLog, Clock, Reporter, RemoteCache
last_runthe log's lines and a Label → the newest run of that label that stored its outputnone
verifythe graph, the narrowed graph, its Plan and a Sample → VerificationManifest, ActionCache, ContentStore, ExecStrategy, Dispatcher, Clock
reacta ChangeBatch, a Reference and, when there are any, the ignore rules → a Reaction: build, check the build files, or nothingIgnoreRules
watched_inputsthe graph and the narrowed graph → the files a build readsnone
watcha WatchLayout → the error that ended itChanges, Cycles (which hands back the rules of the last workspace it opened), WatchReport
canonical JSONvalue → sorted-key bytes, and those bytes, and no others, → the valuenone

The port catalog

"Milestone" is the step of the roadmap the adapter arrived with: 1 is the core build, 2 the rest of the everyday commands, 3 the sandbox, 4 approvers, 6 the remote cache and 7 watch mode. Plugins and discovery targets (5) and remote execution (8) added no port of their own. IgnoreRules came with .buildlignore, outside any milestone, so its row has a dash.

Portbuildl-core uses it forAdapterCrateMilestone
DeclarationSourceLoad: one build file per call, several calls at once, each with the discovery resultsLuaSource: an airsl engine per file, with the plugins it uses loaded into the same evaluationbuildl-lua1
Manifestthe ceiling, the output and state directories, the execution settings and each plugin's capthe buildl.toml readerbuildl1
Hostthe platform in every key, and the values of the variables targets readthe running machinebuildl1
Digesterwhat stands at each input's path, and its content hashthe filesystem, with rayon, each file streamed in piecesbuildl1
StatCachereusing a digest when size and modification time are unchanged.buildl/statcache.json; keeps only files changed more than 2 s before the run beganbuildl1
ToolResolverthe fingerprint of each program, in the keya PATH lookup and a content hashbuildl1
ContentStorethe cas: storing a blob, asking for one, reading one back, clearing an output's path and placing a blob thereLocalCas: .buildl/cas/ab/…, read-only blobs, hard links or copies into out/ (copies only, for a file that may be run)buildl1
ActionCachereading, listing, recording and forgetting cache rows, each durable on return.buildl/cache.json and .buildl/cache.journalbuildl1
EventLogone event per outcome.buildl/log.jsonl, appended tobuildl1
RunHistorythe log's lines, oldest first, each an event or a damaged line.buildl/log.jsonl, read onlybuildl2
Sweeplisting what the cas holds and removing a blob; kept out of Ports, so a build cannot remove what it storedthe same .buildl/casbuildl2
ExecStrategyrunning one action and reporting, and storing, what it left at each output pathBare, tier 1buildl1
ExecStrategythe same, in a directory of its own outside the workspace, with TZ, LC_ALL and SOURCE_DATE_EPOCH pinnedInputSandbox, tier 2, the default; Local picks Bare, InputSandbox or a refusalbuildl3
Dispatcherevaluating build files and running actions in parallel, and carrying a running action's messages backThreadPool: scoped threads and mpsc, up to [execution] workersbuildl1
Approverwhether a build whose wants are inside the ceiling may runLocalApprover: ManifestApprover, DenyApprover or InteractiveApproverbuildl4
RemoteCacheresults shared between machines, and actions the server runs; every answer checked by the core, never trustedRemote: a gRPC client over the Remote Execution API, its tokio runtime reached through block_onbuildl6
Clocklog timestamps and durationsthe system clockbuildl1
GraphRecordkeeping the graph a build resolved.buildl/graph.json, written wholebuildl1
Reporteroutput blocks, the status line, the summary and notices about the remotethe terminal reporter, with a live and a plain modebuildl1
IgnoreRulesLoad: is an inputs entry or a subdir ignored; watch: is a changed path ignored; the walk behind buildl.sources asks it too, through the buildl-lua adapterBuildlIgnore: the .buildlignore files, read from the root down through the ignore crate's pattern matcherbuildl—
Changeswaiting for files of the workspace to changeNotifyChanges: notify, relative paths, a 50 ms windowbuildl7
Cyclesone watch cycle: the workspace opened again and built, or loaded; it also carries type Ignore and rules(), the rules of the last workspace openedReopening, in workspace/watching.rsbuildl7
WatchReportwhat a watch says about itselfthe terminal reporter's watch: linesbuildl7

One more trait sits beside them: BlobSource, which an upload to the remote reads blobs through, because the remote adapter may not import the local content store.

The Clock port is how the wall clock is kept out of the core (Determinism Rules, rule 4). The crate boundary alone does not enforce it, since std::time is open to every crate, so crates/buildl-core/clippy.toml bans Instant, SystemTime and SystemTimeError by name.

Dependency rules

  1. buildl-core depends on no buildl crate, no airsl, and no I/O API (see What buildl-core may depend on).
  2. Adapters depend on buildl-core. buildl-lua never depends on buildl; inside buildl, adapter modules never import each other. What several adapters need lives in two shared modules, state and search_path, which implement no port and name no module of the crate; adapters meet only in the three composition modules, local_ports, workspace and cli. plugins, which implements no port, is held to the same rule: it names state and search_path, local_ports calls its check and workspace its fetch, and the manifest adapter, which reads which plugins a workspace names, shares with it values in buildl-core and no code.
  3. buildl is the single composition root: the only adapter crate that depends on another adapter crate (buildl-lua), and the only code that names more than one concrete adapter, through LocalPorts. This is dependency inversion applied, not broken: the principle constrains the logic, and a composition root is where concrete choices are made.
  4. The command line reaches core types through buildl, where it lives. It is the cli module of buildl, so it names core types through buildl's re-exports, and both binaries have buildl as their one buildl dependency: buildl-cli, which holds main alone, and buildl-cargo, which names a core type as buildl::buildl_core::TargetName. Neither depends on buildl-core or buildl-lua directly.
  5. The remote cache's gRPC client, its protobuf messages and its async runtime are the remote module's, in buildl. tonic, prost and uuid have buildl as the one crate that may depend on them, beside their own companion crates; tokio is not banned by name, and guard-crate-edges keeps every other member off it. Nothing outside the module names tokio, and the runtime is reached through block_on, so buildl-core, the Dispatcher and every other adapter stay synchronous (Decision Records). deny.toml holds the crate edge; that no other module of buildl names them is the module layout's doing, as it is for rayon in digest.
RuleEnforced by
the dependency half of 1, rules 4 and 5, and the cross-crate half of 2deny.toml's [bans] lists, which name the only direct parents a crate may have, plus cargo make guard-crate-edges, which compares every member's direct dependencies with crates/expected-edges.txt. The compiler alone stops a crate using what its [dependencies] leave out, but not a dependency being added or removed
the "no I/O API" half of 1crates/buildl-core/clippy.toml, the enumerated ban on the filesystem, process, thread, network, environment, standard-stream and clock APIs, checked by cargo make guard-core-purity
no phase module of buildl-core names anothercrates/expected-module-edges.txt, the committed list of buildl-core's module-to-module imports, compared by cargo make guard-module-edges. Import forms the list cannot read, such as a grouped crate::{…}, are refused outright
adapter isolation inside buildlcargo make guard-adapter-isolation, which reads every file under crates/buildl/src but lib.rs, test code included: an adapter module may name crate::state and crate::search_path and no other module, the two shared modules name none, and only local_ports, workspace and cli name any module they like

Publishing

buildl-cli and buildl-cargo are published to crates.io, and crates.io takes a crate only when its dependencies are published too, so all five crates are published, the one depended on first:

%% crates.io publish order
graph LR
    P1["1: buildl-core"] --> P2["2: buildl-lua"] --> P3["3: buildl"] --> P4["4: buildl-cli"] --> P5["5: buildl-cargo"]

Only buildl-cli is shipped as a prebuilt binary, through cargo-dist. buildl-cargo sets dist = false, so it comes through crates.io alone, with cargo install --locked buildl-cargo.

RequirementForm
internal dependenciesbuildl-core = { version = "…", path = "crates/buildl-core" } in [workspace.dependencies]; packaging keeps the version and drops the path
version synceach workspace dependency's version matches the crate's own version
metadatadescription and readme per crate; license and repository from the workspace
crate README.mdwritten for crates.io readers of that crate

Four rules keep publishing possible, and every change to the workspace follows them:

  1. Every dependency between members is { workspace = true }, and no member depends, dev dependencies included, on a member later in the publish order: cargo package fails on one, and a dev dependency given by path alone is silently dropped from the packaged manifest.
  2. The workspace has the five members and no sixth (the generator of the Remote Execution API types, tools/reapi-codegen, sits outside it), and buildl gains no [[bin]] or [[example]] for the sake of tests. Its one feature, test-server, builds the in-memory server the remote cache's tests talk to. It is off by default and turned on by buildl-cli only as a dev dependency, so the shipped binary does not hold the server.
  3. Fixtures and golden files live inside the package whose tests read them, reached through CARGO_MANIFEST_DIR or include_str!; no test reads another package's directory.
  4. No fixture path holds a component named target or debug.

Once published, the ports are a promise to anyone who writes an adapter:

ConcernRule
sealed or openopen: adapters live in other crates, and a sealed trait cannot be implemented outside its own crate
growing a portnew methods get default bodies; a required method breaks every implementor
growing data#[non_exhaustive] on enums and structs expected to gain variants or fields
version line0.x until the port surface settles