feat(package): download and verify prebuilt binary variants
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 1m5s

This commit is contained in:
faumaray committed 2026-12-03 20:17:17 +03:00
1 parent 118c0dc860
commit 9b405ce772
9 files changed
+199 -3

No files matched your search

+5 -1
View File
@@ -105,9 +105,13 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
- Added the `ide_query` daemon request (`vbs daemon ide query`): it evaluates/lowers the project graph, publishes the profile compilation database (selecting it when no editor selection exists), and returns the IDE metadata JSON (`schema_version`, project/build roots, profile identity, toolchain, compdb path, and per-target sources/outputs) wrapped with `ok`/`op`/`compdb`. The response flattens the query's trailing newline so the socket protocol stays one JSON object per line.
- Added `Daemon.ide_query_serves_workspace_targets_and_compdb` (compdb exists on disk, schema/profile/app target present) and a CLI help contract; Daemon suite is now 9 cases.
- **Wave 22 (Track D3 Binary-Variant Distribution)**:
- Added `download_binary_artifact` (`RegistryClient`): fetches an absolute http(s) binary artifact URL and verifies its SHA-256 before the atomic write. Added `materialize_binary_variant` (`BinaryFetchOptions`): selects a compatible variant (trusted-signature checked), reuses `<cache>/binaries/<sha256>` only when the cached digest still matches, and downloads otherwise.
- `RegistryTests.binary_variant_distribution_downloads_and_verifies`: a signed variant is downloaded from the live registry package endpoint, byte-for-byte verified, reused from cache after the server stops, and rejected on digest mismatch.
## Remaining future scope
- **Post-v1 Expansion Roadmap ([21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md) & [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md))**: Live `conan` CLI verification (Track B3), Track C (macOS/Windows ports + dual-profile cross-compilation), Track D3 signing (SBOM, Ed25519 primitives, trusted-key enforcement and distribution, binary-variant signing, the #52 built-in-backend capability probe, and the VoidLibrary pin bump to `0002e74` done; binary-variant distribution remains), Track E3 (daemon core, bounded `describe`, build-serving, dependency materialization, and daemon-backed IDE metadata done; dedicated external editor extensions remain), and Track E4 (`Void::Net`/`Void::Sqlite` alignment) remain planned scope.
- **Post-v1 Expansion Roadmap ([21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md) & [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md))**: Live `conan` CLI verification (Track B3), Track C (macOS/Windows ports + dual-profile cross-compilation), Track D3 signing (SBOM, Ed25519 primitives, trusted-key enforcement and distribution, binary-variant signing and distribution materialization, the #52 built-in-backend capability probe, and the VoidLibrary pin bump to `0002e74` done), Track E3 (daemon core, bounded `describe`, build-serving, dependency materialization, and daemon-backed IDE metadata done; dedicated external editor extensions remain), and Track E4 (`Void::Net`/`Void::Sqlite` alignment) remain planned scope.
## Environment notes & upstream boundaries
+2 -1
View File
@@ -28,4 +28,5 @@ Base HEAD: `fe0d1a6`
| Wave 19 (Track D3 trusted-key distribution) | `Provenance::load_trusted_keys` over `--trusted-key-file`, project `vbs.keys`, and `VBS_TRUSTED_PUBLIC_KEYS`; 64-hex validation/lowercasing/dedup with `file:line` errors; wired into CLI builds and daemon dependency resolution | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; SignatureEnforcement 5/5, Daemon 8/8, full CTest 8/8) | `include/Void/Build/Provenance/TrustedKeys.hpp`, `src/Provenance/TrustedKeys.cpp`, `src/Main.cpp`, `src/Daemon/Daemon.cpp`, `tests/SignatureEnforcementTests.cpp`, build lists, docs |
| Wave 20 (Track D3 binary-variant signing) | `sign_message`/`verify_message`, `BinaryVariantMeta` signature fields, canonical `vbs-binary-v1` message + trusted-key policy, `select_compatible_signed_binary` fail-closed selection | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; SignatureEnforcement 7/7, full CTest 8/8) | `include/Void/Build/Provenance/{Signing,Verification}.hpp`, `src/Provenance/{Signing,Verification}.cpp`, `include/Void/Build/Package/{Solver,Fetch}.hpp`, `src/Package/Fetch.cpp`, `tests/SignatureEnforcementTests.cpp`, docs |
| Wave 21 (Track E3 daemon-backed editor metadata) | `ide_query` daemon request + `vbs daemon ide query` CLI: lowers the graph, publishes/selects the profile compdb, returns IDE query JSON (workspace/targets/compdb) over the socket | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 9/9, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, `tests/CliContracts.cmake`, docs |
| Future (Plan 20 Slice 3 / Tracks C, D3 binary distribution, E3 editor extensions, E4, live `conan`) | Live `conan` CLI verification; macOS/Windows/cross-compile; binary-variant signing and key distribution; daemon-side dependency materialization and editor plugins; `Void::Net`/`Void::Sqlite` alignment | PLANNED (unimplemented) | [21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md), [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md) |
| Wave 22 (Track D3 binary-variant distribution) | `download_binary_artifact` with SHA-256 verification; `materialize_binary_variant` (signed selection, digest-validated cache reuse, download) | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; registry distribution test, full CTest 8/8) | `include/Void/Build/Package/{RegistryClient,Fetch}.hpp`, `src/Package/{RegistryClient,Fetch}.cpp`, `tests/RegistryTests.cpp`, docs |
| Future (Plan 20 Slice 3 / Tracks C, E3 editor extensions, E4, live `conan`) | Live `conan` CLI verification; macOS/Windows/cross-compile; binary-variant signing and key distribution; daemon-side dependency materialization and editor plugins; `Void::Net`/`Void::Sqlite` alignment | PLANNED (unimplemented) | [21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md), [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md) |
+15
View File
@@ -419,6 +419,21 @@ dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure
`vbs daemon ide query --help` contract: **passed** (7.45 s).
- `clang-format --dry-run --Werror` passes on the changed C++ files.
## Track D3 Binary-Variant Distribution (GCC 16.2, pin `0002e74`, built-in Ed25519)
```sh
dev cpp-gcc -c cmake --build build/pinned --parallel 8
dev cpp-gcc -c build/pinned/bin/vbs_registry_tests --filter binary_variant_distribution_downloads_and_verifies --no-color
dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure
```
- Build: exit 0. `RegistryTests.binary_variant_distribution_downloads_and_verifies`: **passed**
(529 ms) - a signed binary variant is selected with a trusted key, downloaded from the live
registry package endpoint, written to `<cache>/binaries/<sha256>` with byte-for-byte equality,
reused from cache after the registry stops, and rejected when the expected digest is tampered.
- Full CTest: **8 / 8 passed** in 200.71 s (`vbs_registry_tests` 11.39 s).
- `clang-format --dry-run --Werror` passes on the changed C++ files.
## Limits and Unrun Checks
1. **HTTPS git fetch**: the host shell is proxy-restricted, but the Docker container could clone `https://git.faumaray.com/Void/VoidLibrary.git`; the pinned commit `3e254055e081a104f08df68dde39711bc7813518` was fetched directly for the verification above. A separate configure against the local `/home/faumaray/Projects/Library` checkout via `VBS_VOID_SOURCE_DIR` also succeeded (development-only override, checkout unmodified).
+1 -1
View File
@@ -61,7 +61,7 @@ flowchart LR
| --- | --- | --- |
| **D1 — Shared HTTP Content-Addressed Action Cache (CAS)** *(verified: cross-build-directory 100% cache hit)* | Push/pull action records and output blobs (`PUT/GET /api/v1/cas/blobs/{sha256}`, `/api/v1/cas/actions/{action_key}`) against `vbs-registry` or any compatible HTTP CAS server with bearer auth and digest verification on every read. Action keys are normalized to be build-directory independent; `vbs build/test --remote-cache URL [--remote-cache-token-env VAR]` (or `VBS_REMOTE_CACHE` / `VBS_REMOTE_CACHE_TOKEN`). | Cold CI build populates remote CAS; second clean machine achieves 100% cache hit with verified SHA-256 outputs. |
| **D2 — Fast Hashing & Parallel Snapshot Pipeline** *(verified: 5,001-file warm no-op 374 ms)* | Adopt `Void::Crypto` BLAKE2b / hardware-accelerated SHA-256 (when available) + parallel snapshot hashing across `Void::Concurrency::ThreadPool` + optional `Void::Sqlite` indexed state store for >10k-file monorepos. Snapshot capture revalidation now hashes on a bounded thread pool for trees of 32+ files. | Sub-second warm no-op on 5,000-file synthetic benchmark fixture (`vbs_benchmarks`). |
| **D3 — Supply-Chain Provenance & Signed Packages** *(SBOM, Ed25519 signing primitives, and trusted-key enforcement implemented; OpenSSL or the built-in Ed25519 backend)* | Emit SPDX/CycloneDX SBOM JSON from `vbs.lock` + `BuildGraph` (`vbs build/test --sbom FILE --sbom-format spdx\|cyclonedx`, `src/Provenance/Sbom.cpp`); Ed25519 detached-signature primitives in `Void::Build::Provenance::Signing` (`include/Void/Build/Provenance/Signing.hpp`, `src/Provenance/Signing.cpp`): 0600 seed generation, public-key derivation, canonical `vbs-package-v1` package message, and sign/verify; package signature/public-key metadata persisted in `vbs.lock` and registry releases; `vbs publish --signing-key FILE`; `vbs build\|test --trusted-public-key HEX` enforced before extraction via `Provenance::verify_trusted_package_signature` (`include/Void/Build/Provenance/Verification.hpp`); trusted keys can also come from `--trusted-key-file`, a project `vbs.keys` ring, or `VBS_TRUSTED_PUBLIC_KEYS` (`Provenance::load_trusted_keys`); prebuilt binary variants carry optional signatures verified by `select_compatible_signed_binary` over the canonical `vbs-binary-v1` message. | SBOM is deterministic and valid JSON; signing primitives pass round-trip/tamper/malformed tests (`tests/SigningTests.cpp`); trusted-key policy tests pass with and without OpenSSL (`tests/SignatureEnforcementTests.cpp`); a signed publish -> deps update -> `--locked` trusted build succeeds and an untrusted/unsigned package fails closed before extraction (`RegistryTests.cpp`). |
| **D3 — Supply-Chain Provenance & Signed Packages** *(SBOM, Ed25519 signing primitives, and trusted-key enforcement implemented; OpenSSL or the built-in Ed25519 backend)* | Emit SPDX/CycloneDX SBOM JSON from `vbs.lock` + `BuildGraph` (`vbs build/test --sbom FILE --sbom-format spdx\|cyclonedx`, `src/Provenance/Sbom.cpp`); Ed25519 detached-signature primitives in `Void::Build::Provenance::Signing` (`include/Void/Build/Provenance/Signing.hpp`, `src/Provenance/Signing.cpp`): 0600 seed generation, public-key derivation, canonical `vbs-package-v1` package message, and sign/verify; package signature/public-key metadata persisted in `vbs.lock` and registry releases; `vbs publish --signing-key FILE`; `vbs build\|test --trusted-public-key HEX` enforced before extraction via `Provenance::verify_trusted_package_signature` (`include/Void/Build/Provenance/Verification.hpp`); trusted keys can also come from `--trusted-key-file`, a project `vbs.keys` ring, or `VBS_TRUSTED_PUBLIC_KEYS` (`Provenance::load_trusted_keys`); prebuilt binary variants carry optional signatures verified by `select_compatible_signed_binary` over the canonical `vbs-binary-v1` message, and `materialize_binary_variant` downloads digest-verified artifacts with cached-digest revalidation. | SBOM is deterministic and valid JSON; signing primitives pass round-trip/tamper/malformed tests (`tests/SigningTests.cpp`); trusted-key policy tests pass with and without OpenSSL (`tests/SignatureEnforcementTests.cpp`); a signed publish -> deps update -> `--locked` trusted build succeeds and an untrusted/unsigned package fails closed before extraction (`RegistryTests.cpp`). |
---
+13
View File
@@ -67,6 +67,19 @@ select_compatible_signed_binary(const BinaryCompatibilityKey &key,
const std::vector<BinaryVariantMeta> &available,
const std::vector<std::string> &trusted_public_keys_hex);
struct BinaryFetchOptions {
std::filesystem::path cache_dir;
std::vector<std::string> trusted_public_keys;
};
// Selects a compatible binary variant (verifying its trusted signature when keys are supplied),
// downloads the artifact into `<cache_dir>/binaries/<sha256>` with SHA-256 verification, and
// reuses a cached artifact only when its digest still matches.
[[nodiscard]] Void::Result::Result<BinaryVariantMeta, Void::Result::Error>
materialize_binary_variant(const BinaryCompatibilityKey &key,
const std::vector<BinaryVariantMeta> &available,
const BinaryFetchOptions &options);
// Acquires and verifies a source dependency (local path, exact pinned Git SHA, or
// SHA-256 verified archive) into managed storage without ever modifying external checkouts.
[[nodiscard]] Void::Result::Result<MaterializedSource, Void::Result::Error>
@@ -47,6 +47,12 @@ download_release_archive(std::string_view registry_url, std::string_view package
std::string_view version, std::string_view expected_sha256,
const std::filesystem::path &dest_file, const RegistryAuth &auth = {});
// Downloads a prebuilt binary artifact from an absolute http(s) URL into `dest_file`,
// rejecting any content whose SHA-256 differs from `expected_sha256` (verified before writing).
[[nodiscard]] Void::Result::Result<std::filesystem::path, Void::Result::Error>
download_binary_artifact(std::string_view url, std::string_view expected_sha256,
const std::filesystem::path &dest_file);
// Publishes a verified deterministic archive via PUT /api/v1/packages/<name>/<version>.
[[nodiscard]] Void::Result::Result<PublishReceipt, Void::Result::Error>
publish_package_archive(const PublishOptions &options);
+27
View File
@@ -1,5 +1,6 @@
#include <Void/Build/Package/Fetch.hpp>
#include <Void/Build/Package/RegistryClient.hpp>
#include <Void/Build/Platform/FileOps.hpp>
#include <Void/Build/Platform/ProcessSupervisor.hpp>
#include <Void/Build/Provenance/Verification.hpp>
@@ -172,6 +173,32 @@ select_compatible_signed_binary(const BinaryCompatibilityKey &key,
return *selected;
}
Void::Result::Result<BinaryVariantMeta, Void::Result::Error>
materialize_binary_variant(const BinaryCompatibilityKey &key,
const std::vector<BinaryVariantMeta> &available,
const BinaryFetchOptions &options) {
auto selected = select_compatible_signed_binary(key, available, options.trusted_public_keys);
if (!selected) {
return std::unexpected{selected.error()};
}
const auto destination = options.cache_dir / "binaries" / selected->sha256;
std::error_code ec;
if (std::filesystem::is_regular_file(destination, ec)) {
auto cached_digest = Util::sha256_file_hex(destination);
if (cached_digest && *cached_digest == selected->sha256) {
return *selected;
}
}
std::filesystem::create_directories(destination.parent_path(), ec);
auto downloaded =
download_binary_artifact(selected->download_url, selected->sha256, destination);
if (!downloaded) {
return std::unexpected{downloaded.error()};
}
return *selected;
}
Void::Result::Result<MaterializedSource, Void::Result::Error>
materialize_dependency_source(const DependencyRecord &dep, const FetchOptions &options) {
std::error_code ec;
+31
View File
@@ -379,6 +379,37 @@ download_release_archive(std::string_view registry_url, std::string_view package
return dest_file;
}
Void::Result::Result<std::filesystem::path, Void::Result::Error>
download_binary_artifact(std::string_view url, std::string_view expected_sha256,
const std::filesystem::path &dest_file) {
auto parsed_url = parse_registry_url(url);
if (!parsed_url) {
return std::unexpected{parsed_url.error()};
}
auto reply = send_http_request(*parsed_url, "GET", "", {}, {});
if (!reply) {
return std::unexpected{reply.error()};
}
if (reply->status != 200) {
return std::unexpected{make_error(
reply->status == 404 ? Void::System::SystemErrorCode::not_found
: Void::System::SystemErrorCode::io_error,
std::format("binary artifact GET {} failed with HTTP {}", url, reply->status))};
}
const std::string actual_sha = Util::sha256_hex(reply->body);
if (!expected_sha256.empty() && actual_sha != expected_sha256) {
return std::unexpected{
make_error(Void::System::SystemErrorCode::invalid_argument,
std::format("binary artifact SHA-256 mismatch: expected {}, got {}",
expected_sha256, actual_sha))};
}
auto wrote = Platform::atomic_write_file(dest_file, reply->body, true);
if (!wrote) {
return std::unexpected{wrote.error()};
}
return dest_file;
}
Void::Result::Result<PublishReceipt, Void::Result::Error>
publish_package_archive(const PublishOptions &options) {
if (!Void::Semver::parse_strict(options.version)) {
+99
View File
@@ -1,8 +1,10 @@
#include <Void/Build/BootstrapConfig.hpp>
#include <Void/Build/Package/Archive.hpp>
#include <Void/Build/Package/Fetch.hpp>
#include <Void/Build/Platform/FileOps.hpp>
#include <Void/Build/Platform/ProcessSupervisor.hpp>
#include <Void/Build/Provenance/Signing.hpp>
#include <Void/Build/Provenance/Verification.hpp>
#include <Void/Build/Registry/HttpServer.hpp>
#include <Void/Build/Registry/RegistryService.hpp>
#include <Void/Build/State/StateStore.hpp>
@@ -15,6 +17,7 @@
#include <cstring>
#include <fstream>
#include <span>
using namespace Void::Build;
using namespace Void::Build::Registry;
@@ -389,6 +392,102 @@ void build(Void::Build::Project &p) {
(*svc)->stop_http();
}
VOID_TEST(RegistryTests, binary_variant_distribution_downloads_and_verifies) {
if (!Provenance::signing_available()) {
return;
}
Void::FileSystem::TempDir tmp{"vbs_bin_dist_"};
RegistryConfig cfg;
cfg.data_dir = tmp / "reg_data";
cfg.web_root = std::filesystem::path{Bootstrap::source_dir} / "registry" / "web";
cfg.bind_address = "127.0.0.1";
cfg.port = 0;
cfg.bootstrap_admin_user = "admin";
cfg.bootstrap_admin_password = "admin_pw";
auto svc = RegistryService::open(cfg);
Void::Testing::expect(svc.has_value());
if (!svc) {
return;
}
Void::Testing::expect((*svc)->create_user("bin_pub", "bin_pass", Role::Publisher).has_value());
auto tok = (*svc)->create_token("bin_pub", "publish", {"read", "publish"});
Void::Testing::expect(tok.has_value());
if (!tok) {
return;
}
Void::Testing::expect((*svc)->start_http().has_value());
const auto port = (*svc)->bound_port();
const std::string reg_url = "http://127.0.0.1:" + std::to_string(port);
const auto pkg_src = tmp / "bin_pkg";
(void)Platform::atomic_write_file(pkg_src / "payload.bin", "BINARY_VARIANT_PAYLOAD", false);
const auto tar = tmp / "bin.tar";
auto sha = Package::create_source_package(pkg_src, tar, 0);
Void::Testing::require(sha.has_value());
auto bytes = Void::FileSystem::read_file(tar);
Void::Testing::require(bytes.has_value());
auto published = send_loopback_http(
port, "PUT", "/api/v1/packages/demo-bin/1.0.0",
{{"Authorization", "Bearer " + *tok}, {"X-Content-SHA256", *sha}}, *bytes);
Void::Testing::require(published.has_value() && published->status == 201);
const auto seed_path = tmp / "binary.seed";
Void::Testing::require(Provenance::generate_signing_seed(seed_path).has_value());
auto public_key = Provenance::public_key_from_seed(seed_path);
Void::Testing::require(public_key.has_value());
Package::BinaryVariantMeta variant;
variant.variant_id = "demo-bin-1.0.0-linux-x86_64";
variant.os = "Linux";
variant.architecture = "x86_64";
variant.compiler_family = "gcc";
variant.compiler_abi = "gcc-16";
variant.stdlib_abi = "libstdc++";
variant.linkage = "static";
variant.lto_mode = "off";
variant.dependency_closure_hash = "closure";
variant.sha256 = *sha;
variant.download_url = reg_url + "/api/v1/packages/demo-bin/1.0.0/download";
const std::string message =
Provenance::canonical_binary_message(variant.variant_id, variant.sha256);
auto signature = Provenance::sign_message(
std::as_bytes(std::span<const char>{message.data(), message.size()}), seed_path);
Void::Testing::require(signature.has_value());
variant.signature = *signature;
variant.public_key = *public_key;
Package::BinaryCompatibilityKey key;
key.os = variant.os;
key.architecture = variant.architecture;
key.compiler_family = variant.compiler_family;
key.compiler_abi = variant.compiler_abi;
key.stdlib_abi = variant.stdlib_abi;
key.linkage = variant.linkage;
key.lto_mode = variant.lto_mode;
key.dependency_closure_hash = variant.dependency_closure_hash;
Package::BinaryFetchOptions options{tmp / "binary_cache", {*public_key}};
auto fetched = Package::materialize_binary_variant(key, {variant}, options);
Void::Testing::require(fetched.has_value());
auto downloaded =
Void::FileSystem::read_file(tmp / "binary_cache" / "binaries" / variant.sha256);
Void::Testing::require(downloaded.has_value());
Void::Testing::expect(*downloaded == *bytes);
// Cached artifacts are reused without contacting the registry.
(*svc)->stop_http();
auto cached = Package::materialize_binary_variant(key, {variant}, options);
Void::Testing::expect(cached.has_value());
// A digest mismatch fails closed instead of materializing unverified bytes.
auto tampered = variant;
tampered.sha256 = std::string(64, '0');
auto mismatched = Package::materialize_binary_variant(key, {tampered}, options);
Void::Testing::expect(!mismatched.has_value());
}
// End-to-end live client <-> server test: `vbs publish` -> `vbs deps resolve` -> `vbs build
// --locked`!
VOID_TEST(RegistryTests, cli_publish_deps_resolve_and_locked_build_against_live_registry) {