--- title: Packages, Solvers and Providers description: The normalized dependency model, lockfile schema, fetch/cache layout, provider contracts and bounded foreign translation section: Packages & Providers badge: internals order: 1 tags: [internals, solver, lockfile, fetch, providers, cmake, meson, conan, pkg-config, bridge] updated: 2026-12-06 --- # Packages, Solvers and Providers Package management is split into four stages with explicit boundaries: :::flow normalize → solve → lock/materialize → provide typed targets ::: The C++ and TOML front ends produce the same `DependencyRecord`, the solver works only on registry packages, materialization produces a `MaterializedSource`, and a provider turns that source into `ImportedTargetInterface` values consumed by graph lowering. ## Normalized model `DependencyRecord` (`include/Void/Build.hpp`) is the shared representation: ```text name, source_kind, location, revision, package, version, builder, options (string|bool|int64), registry_authority, sha256, features, build_dependency ``` `DependencySourceKind` is `Git`, `Path`, `Archive`, `Package`, `Conan` or `PkgConfig`. Validation is immediate: - exactly one source; - Git requires a 40-hex commit; archive requires a 64-hex SHA-256; - `.cmake()`/`.meson()` cannot be combined with a registry package source in C++; - a builder cannot be reassigned; - duplicate aliases are rejected. C++ and TOML declarations merge by alias. Identical records merge; different records fail and report both origins. `build_dependencies` entries force `build_dependency = true`; the flag is recorded, but 1.0.0 resolves a single target context (`machine_role = "target"`). ### TOML loader details The loader is intentionally strict: - top-level tables: `dependencies`, `build_dependencies`, plus an accepted-but-unused `registries` placeholder; - fields: `git`, `rev`, `path`, `archive`, `sha256`, `package`, `version`, `conan`, `builder`, `options`, `registry`, `features`, `build_dependency`; - options are typed: string, bool or signed integer; floats, arrays and tables are rejected; - `builder` must be `cmake`, `meson`, `conan` or `native`; - a registry package may only use an explicit `native` builder; if the builder is omitted, `vbs build` inspects the extracted source for `build.cpp`, `CMakeLists.txt` or `meson.build`; - diagnostics carry exact `file:line:column` origins; - unknown keys and duplicate keys are never ignored. ## Solver Registry identities are `{registry_authority, package_name}`. There is no cross-registry fallback: the same name from two authorities is two packages. The solver is deterministic chronological backtracking with: - fewest-candidates-first selection; - fail-fast propagation and a bounded step count (`50,000`); - pinned-version preference when not upgrading; - highest compatible SemVer otherwise; - yanked versions skipped unless they are the pinned version (configurable); - up to eight `no version of satisfies (from )` explanations on failure. :::callout{type="info" title="Naming vs implementation"} The codebase and tests describe the solver as “PubGrub-style”. The current implementation does not use PubGrub incompatibility clauses or clause learning; it is a deterministic backtracking solver with pinned-version preference. Treat “PubGrub-style” as design lineage, not an algorithmic guarantee. ::: Features are carried in constraints and lock entries, but do not affect acquisition or target export in 1.0.0. They are metadata for a future feature-aware solve. The resolver always solves with `machine_role = "target"`. The API and lock schema allow a build role; a distinct build-machine solve is not implemented yet. ## Lockfile format `vbs.lock` is JSON with `schema_version: 1`: ```json { "schema_version": 1, "revision_hash": "sha256 over the canonical contexts payload", "contexts": { "debug:gcc:Linux:x86_64:target": { "context_key": "debug:gcc:Linux:x86_64:target", "profile_name": "debug", "compiler": "gcc", "os": "Linux", "architecture": "x86_64", "machine_role": "target", "declaration_fingerprint": "…", "entries": [ { "alias": "fmt", "source_kind": "package", "registry_authority": "https://packages.example.com", "package_name": "fmt", "version": "11.0.2", "location": "", "revision": "", "sha256": "…", "builder": "native", "features": ["header-only"], "build_dependency": false, "signature": "…", "public_key": "…" } ] } } } ``` - `revision_hash` is re-computed and validated on read; a hand-edited hash is rejected. - URLs are written without embedded credentials; bearer tokens never enter the lock. - Optional signature fields are omitted when absent, preserving byte compatibility with unsigned locks. - One immutable lock revision is pinned at build start. `declaration_fingerprint` covers the profile name, compiler, OS, architecture, role, and every non-build dependency's normalized fields with typed options. Build-dependency declarations are written to lock entries but are excluded from the fingerprint in 1.0.0, so changing only a build dependency does not by itself force a lock republish. Lock publication is compare-and-swap: - `--locked` refuses creation or modification; - a changed context is re-solved and republished by a normal build; - a competing update to the same context with a different fingerprint returns busy; - other profiles' contexts are preserved; - multi-profile builds merge contexts instead of replacing the file. ## Materialization and cache All dependency data lives under `/.vbs/cache`: | Content | Path | | --- | --- | | Registry tarball | `packages/.tar` | | Registry extracted source | `packages//src/` | | Git checkout | `git/_/` with `.vbs_verified_rev` | | Archive extraction | `archives//` with `.vbs_verified` | | Archive download staging | `downloads/.tar` | | Fetch locks | `locks/.lock`, `locks/git_.lock` | | Path snapshot | `path-snapshots/` | | Binary variant cache | `binaries/` | Materialization properties: - **Path** dependencies are canonicalized, snapshotted for content identity, and never modified; `compile_commands.json` is excluded from the snapshot. - **Archives** are verified before extraction. Local and `file://` sources are copied; remote sources use `curl` with HTTPS/HTTP only and a 120 s timeout. A digest mismatch deletes the download. - **Git** uses `git clone --no-checkout` + detached checkout, then verifies `HEAD` equals the pinned commit. `GIT_TERMINAL_PROMPT=0` prevents interactive hangs. The checkout is published by atomic directory rename. - **Registry packages** download with SHA-256 verification, extract safely, and reuse a cached extraction only while the expected directory exists. - **Safe extraction** rejects absolute paths, `..`, symlinks, hardlinks, special files and duplicate entries, with entry/size/total quotas. Extraction is staged and published only on full success. - **Integrity is checked before use**, and a cached extraction marker is not a substitute for an explicit re-verification when the source digest changes (the digest is part of the path). Environment overrides: `VBS_VOID_SOURCE_DIR` (VoidLibrary only, Git source), `VBS_REGISTRY_URL`, `VBS_REGISTRY_TOKEN`, `VBS_TRUSTED_PUBLIC_KEYS`. ## Provider contract A provider receives the materialized source, profile, toolchain and options, and returns `ImportedTargetInterface`: ```text include_dirs (path, is_system), defines, compile_options, link_options, static_libraries, shared_libraries, runtime_files, generated_prerequisites, module_bmis ``` The graph then applies the same visibility and ordering rules as local targets. Missing imported targets are hard errors; a provider cannot return a partial interface and have it guessed. ### Native `builder == "native"` requires a `build.cpp` or a recognized VoidLibrary tree (which uses the built-in recipe). The provider: - sets `VBS_DEP_NAME`, `VBS_DEP_OPTION_` and the plain option name (for VoidLibrary's `VOID_ENABLED_MODULES`-style options); - evaluates/builds the dependency's graph through VBS itself; - exports compile usage, reverse-post-order static link closure, runtime shared libraries, module BMIs and `Void_` → `Void::` aliases; - supports static/shared/object/custom targets, plus executables for build dependencies; - rejects nested dependencies inside a native subproject in 1.0.0. No CMake is invoked on this path. ### CMake Full-build mode writes a File API `codemodel-v2` query, configures CMake (Ninja if available), builds with `cmake --build`, and imports compile groups. It preserves only a small set of system link fragments (`-pthread`, `-lpthread`, `-ldl`, `-lm`, `-lrt`) and reconstructs static link order from dependencies. Provider outputs are cached at `/.vbs/providers///provider-export.json`. The identity includes builder, source content hash, profile, toolchain identity and options. Metadata-only mode never executes CMake; an unbuilt provider returns `stale_needs_build` instead of fabricated targets. ### Meson `meson setup` only, then `meson compile -C`, then reads `meson-info/intro-targets.json`. Static/shared targets, `-I` flags and `/include` are imported. Defines and richer introspection are not imported in 1.0.0. ### Conan The adapter checks for `conan` in `PATH`, writes host/build profiles, and runs `conan install --format json`. The current adapter imports no package targets beyond explicit overrides. A standalone `.conan(...)` source dependency also fails at materialization (`requires package/registry resolution before source fetch`), so it is not yet usable as a `vbs build` dependency. ### pkg-config `.pc` files are parsed directly (no executable): - recursive `${var}` expansion, including `${pcfiledir}`; - comma-separated module specs with `=`, `==`, `!=`, `<`, `<=`, `>`, `>=` and RPM-style comparison; - `Requires`, `Cflags`, `Libs` merged across the chain; - `PKG_CONFIG_PATH`, then `PKG_CONFIG_LIBDIR` (which suppresses fallbacks), then conventional prefixes; - `-I`/`-isystem` → include dirs (currently marked system), `-D` → defines, other cflags → compile options, `-l/-L/-Wl,/-pthread/-ldl` → link options, `.a`/`.so` → library inputs; - lock entry as `pkgconfig`, never fetched. Current gaps: `Requires.private`/`Libs.private` are ignored, a two-token `-isystem ` is not parsed, and all include dirs are marked system. ### CMake bridge `cmake/bridge/VbsDeps.cmake` lets a CMake project ask VBS for dependencies: ```cmake include(VbsDeps.cmake) vbs_declare_dependency(fmt PACKAGE fmt VERSION "^11.0" REGISTRY "https://...") vbs_make_available(fmt) ``` The bridge writes a request JSON and calls `vbs bridge`, which materializes the source and imports provider targets as `IMPORTED` CMake targets. In 1.0.0 it cannot resolve registry `package` sources (the same materialization gap as Conan) and ignores `FEATURES`/`LOCKED`; use Git/path/archive sources in bridge mode. ## Bounded native translation `--native-foreign` attempts to translate a foreign CMake/Meson graph into native VBS actions instead of delegating the build. - **Policy**: `FallbackToForeignBuild` is the default and the only policy the CLI selects. `RequireNative` is available to library callers and fails on unsupported constructs. - **CMake**: configure-only, audit `codemodel-v2`, lower compile/link groups and custom commands into a `BuildGraph`, execute with VBS's scheduler and CAS. - **Meson**: `meson setup` only, audit `intro-targets.json`, recover link edges from `build.ninja`, lower custom targets. - **Unsupported**: console pools, out-of-tree working directories/outputs, non-hermetic utility rules, build-system regeneration, unbounded shell custom commands, non-C/C++ languages, PCH, `run` targets, and untranslated dependency edges. Each is a named diagnostic, never a silent drop. - **Caching**: translated provider graphs are not yet written as `provider-export.json`, so metadata-only readers such as `vbs ide` cannot see them until that is fixed. ## Signing and trust Package signing uses Ed25519 over: ```text vbs-package-v1 @ sha256: ``` The trust policy is: | Situation | Decision | | --- | --- | | No trusted keys configured | `Unsigned` (legacy behavior) | | Missing signature/public key | `Unsigned` | | Signer key not trusted | `UntrustedKey` (no crypto invoked) | | Trusted key, valid signature | `Verified` | | Trusted key, invalid signature | `InvalidSignature` | | Malformed hex or no crypto backend | explicit error | Enforcement happens in `vbs build`/`vbs test` and the daemon before extraction. `vbs deps resolve|update` do not accept trusted keys yet, so run a build (or `vbs verify`) when enforcing signatures in automation. Keys come from `--trusted-public-key`, `--trusted-key-file`, `vbs.keys`, and `VBS_TRUSTED_PUBLIC_KEYS`. Binary variants use `vbs-binary-v1\n\nsha256:\n`; installer archives use `vbs-installer-v1\n\n` and sign the archive digest, not the bytes. ## Install and SBOM internals `install_project` stages privately, validates destinations, then publishes file-by-file and writes `.vbs-install-manifest.json`. It installs only targets with install rules plus declared files. Public headers require an explicit `install_directory`. CMake exports are relocatable and skip executables; native metadata lives under `share/vbs//package.json`. Installer archives are generated from the installed file list, so the ownership manifest itself is **not** included in the archive. `--bundle-dependencies` bundles only local shared-library outputs in 1.0.0, not imported provider libraries. SBOMs include lock entries with a concrete version (registry packages) and all lowered target primary outputs. Git/path/archive/pkgconfig entries without a version are omitted; the document is deterministic for identical inputs. ## Current limits :::callout{type="warning" title="Known 1.0.0 gaps"} - Conan is not usable as a standalone `vbs build` dependency yet. - Features are recorded but do not affect acquisition. - Only the target machine role is solved. - Build-dependency declarations are excluded from the lock fingerprint. - `vbs deps update --offline` with registry packages always fails. - `vbs install` has no `--locked`, `--offline` or `--native-foreign`. - Downloads are buffered in memory rather than streamed. - Foreign translation results are not cached as provider exports. - Binary variants are verified but not selected by `vbs build`. - pkg-config private requirements and two-token `-isystem` are unsupported. ::: Next: [inspect the registry internals](/build-system/developer/registry-internals) or [trace execution and snapshots](/build-system/developer/snapshots-and-execution).