--- title: Architecture and Control Flow description: The layers, libraries and invariants behind VoidBuildSystem's configuration, execution, packaging and registry paths section: Architecture badge: design order: 1 tags: [architecture, layers, components, invariants, control-flow, source-map] updated: 2026-12-06 --- # Architecture and Control Flow VoidBuildSystem is one binary (`vbs`) plus two support binaries (`vbs-registry`, `vbs_describe`) and a static SDK (`libVoidBuildSdk.a`). It is built on VoidLibrary for configuration, text, Unicode, concurrency, crypto, archives, logging, filesystem and process primitives. The project has two build front ends for its own source: a CMake bootstrap and a zero-CMake `build.cpp` that builds the same targets. ## End-to-end flow :::flow CLI → host descriptor → profiles → dependency resolution → immutable snapshot → graph lowering → scheduler → CAS publication → editor/daemon projections ::: 1. **Select roots and profiles.** The CLI resolves absolute project and build roots, loads the lockfile, discovers profiles, and pins a target OS/architecture and compiler family. 2. **Compile the description.** `build.cpp`, optional `build.profiles.cpp`, `build-support/**/*.cpp` and explicit `--build-source` files are compiled into a cached host executable against the fixed SDK. Configuration helpers are found by filesystem membership, not Git or a package graph. 3. **Evaluate out of process.** For each resolved `ProfileContext`, the descriptor writes one versioned JSON `ProjectDescription` to a private result file. stdout/stderr cannot corrupt the protocol. 4. **Resolve dependencies.** Inline C++ and TOML declarations merge, registry constraints solve, sources materialize and providers return typed `ImportedTargetInterface` values. The lock context is validated or republished. 5. **Capture a snapshot.** Declared source/include/search roots are captured into an immutable snapshot with content hashes, resolved symlinks, absence/lookup guards and isolated materialized bytes. 6. **Lower the graph.** Targets are validated, usage requirements are resolved transitively, modules are scanned/collated, and every target becomes typed actions: compile, PCH, header unit, module scan, BMI, archive, link or custom. 7. **Execute.** The scheduler runs the selected action closure with bounded parallelism, process-group supervision, depfile discovery, CAS lookup/publication and cancellation. 8. **Project metadata.** The same graph drives `compile_commands.json`, CMake File API replies, editor presets, IDE query JSON and daemon responses. ## Component map | Area | Primary code | Responsibility | | --- | --- | --- | | Declaration SDK | `include/Void/Build.hpp`, `sdk/Build.cpp`, `sdk/Json.cpp` | Targets, profiles, dependencies, workspaces, deterministic JSON | | Configuration frontend | `src/Config/Frontend.cpp`, `Presets.cpp`, `CmakeImport.cpp`, `Scaffold.cpp`, `BuildTree.cpp` | Descriptor compilation, profile discovery/evaluation, presets, `vbs init`, `vbs migrate`, clean | | Graph | `src/Graph/Graph.cpp` | Target validation, usage propagation, source expansion, action lowering, output layout | | Toolchain | `src/Toolchain/Driver.cpp` | Compiler discovery, capability probes, C/C++/ASM commands, modules, PCH, LTO, sanitizers | | Snapshot | `src/Snapshot/Snapshot.cpp` | Namespace capture, hashing, reflink/copy isolation, lookup guards | | Execution | `src/Execution/Scheduler.cpp` | DAG scheduling, parallelism, cache lookup, depfiles, cancellation | | State | `src/State/StateStore.cpp`, `RemoteCache.cpp` | Local CAS, action records, generations, leases, GC, remote CAS | | Editor | `src/Editor/CompDb.cpp` | Compilation databases, selection tickets, editor presets, File API shim, plugin assets | | Modules | `src/Modules/ModuleScanner.cpp` | P1689 scan, BMI collation, header units, unity exclusions | | Packages | `src/Package/{Toml,Solver,Lockfile,Archive,Fetch,Resolver,RegistryClient}.cpp` | Manifest model, solver, lock CAS, verification, providers' inputs | | Providers | `src/Provider/{Provider,Translator,PkgConfig}.cpp` | Native, CMake, Meson, Conan, pkg-config; bounded native translation | | Install / provenance | `src/Install/Installer.cpp`, `src/Provenance/*` | Prefix staging, exports, eight archives, SBOM, Ed25519, trusted keys | | Reports | `src/Report/{Cdash,Coverage}.cpp` | JUnit-adjacent CDash XML and gcov/lcov | | Daemon | `src/Daemon/Daemon.cpp` | Warm state/watcher, Unix-socket request protocol | | Registry | `registry/service/*`, `registry/cli/Main.cpp`, `registry/web/*` | HTTP API, RBAC, CAS, workers, admin UI | | Native recipes | `recipes/VoidLibrary/*`, `recipes/SelfHost/*` | Built-in VoidLibrary closure and the Stage 0→1 self-host recipe | | CLI | `src/Main.cpp` | Argument parsing, orchestration, output; a thin adapter over libraries | | Platform | `src/Platform/Linux/*`, `src/Watch/Linux/*`, `include/Void/Build/Platform/*` | Atomic files, process supervision, inotify/DirectoryWatcher, host detection | Public libraries: | CMake target | Alias | Contents | | --- | --- | --- | | `VoidBuild_Sdk` | `Void::BuildSdk` | Declaration SDK and JSON serialization | | `VoidBuild_Core` | `Void::BuildCore` | Configuration, graph, execution, packages, providers, install, daemon, reports | | `VoidBuild_Registry` | `Void::BuildRegistry` | Registry service (POSIX only) | | `VoidBuild_Options` | — | C++26, `-freflection`, warnings interface | ## Invariants :::callout{type="contract" title="Non-negotiable design rules"} 1. **Descriptions are host programs, not engine callbacks.** The engine never links a project's `build.cpp` into the CLI process. 2. **Profiles are isolated.** Objects, BMIs, PCHs, response files and generated headers are never shared between incompatible contexts. 3. **Inputs are immutable.** Successful actions run against captured inputs, not a mutable working tree in place. 4. **Outputs publish before references.** A CAS blob exists and verifies before an action success record refers to it. 5. **Determinism is the default.** Reproducibility epochs, canonical snapshot metadata, `-frandom-seed`, `SOURCE_DATE_EPOCH`, `TZ=UTC` and `LC_ALL=C` are applied unless the action is explicitly nondeterministic. 6. **Errors are explicit.** Missing tools, unsupported constructs, unresolved imported targets, stale locks and output collisions fail; they are not guessed or silently skipped. 7. **One owner per interface.** The shared schema (`schema_version: 1`) and lock format are versioned contracts between components. ::: ## Two execution identities The build has three distinct tool identities: | Identity | Used for | Not used for | | --- | --- | --- | | Host compiler | Compiling `build.cpp` and helper sources | Project targets | | Target compiler | Compiling project sources | Evaluating the description | | Build-machine tools | CMake, Meson, Conan, Git, shader compilers | Being assumed present in a target profile | `build_dependency(true)` marks a dependency as a host/build-machine tool. In 1.0.0 the resolver records one target context (`machine_role = "target"`); the flag is carried in the model and lock entry, but a distinct build-machine solve is not implemented yet. ## What the graph owns `BuildGraph` is the single execution contract: - `profile` and `toolchain` identities; - `snapshot_id` and the materialized root; - `targets` with expanded sources, primary outputs, runtime libraries, labels, resources, fixtures and exported BMIs; - topologically ordered `actions` with argv, environment, cwd, response files, declared inputs/outputs, depfile, logical/physical paths, compile metadata, cacheability and an action key. Everything downstream — scheduler, compilation database, daemon responses, install staging, SBOMs — consumes this graph rather than re-deriving commands. ## Boundaries and ownership - The **SDK** declares, the **frontend** compiles/evaluates, the **graph** validates and lowers, the **scheduler** executes. - The **provider** returns complete usage requirements or an explicit gap; it never invents a library interface from a filename. - The **registry** stores immutable bytes and policy metadata; it never executes recipes or verifies signatures on the server. - The **daemon** is a transport and warm-state owner; it calls the same resolver/scheduler as the CLI and adds no alternate build algorithm. - The **editor projection** rewrites typed operands onto logical sources; it never string-replaces arbitrary flags or defines. The next page follows configuration and graph lowering in detail. See [Configuration and graphs](/build-system/developer/configuration-and-graph).