diff --git a/README.md b/README.md index 6fb462c..c87cda1 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ All CLI help text (`vbs --help`, `vbs --help`, `vbs compdb --help`, `v - `vbs pack [--project DIR] [--output FILE]` - `vbs publish --registry URL --name PKG --version X.Y.Z [--project DIR] [--description TEXT] [--token-env VAR] [--signing-key FILE] [--private]` - `vbs publish-binary --registry URL --name PKG --version X.Y.Z --variant ID --file ARTIFACT [--signing-key FILE] [--token-env VAR]` +- `vbs binaries list|fetch --registry URL --name PKG --version X.Y.Z [--variant ID --output FILE] [--token-env VAR]` - `vbs bridge --request FILE --output FILE` (backend for [cmake/bridge/VbsDeps.cmake](cmake/bridge/VbsDeps.cmake)) - `vbs gc [--build-dir DIR] [--max-bytes N]` - `vbs daemon run|status|stop|gc|recover|describe|build|ide query|ide generate|ide poll|ide wait|compdb export [--project DIR] [--build-dir DIR] [--socket PATH]` (Unix-socket daemon holding a warm state store and project watcher; `run` serves in the foreground, the rest are client requests) diff --git a/docs/agent-workflow/STATE.md b/docs/agent-workflow/STATE.md index fd31ce5..aa5189f 100644 --- a/docs/agent-workflow/STATE.md +++ b/docs/agent-workflow/STATE.md @@ -136,6 +136,10 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B - Added `Package::publish_binary_variant` (reads the artifact, computes SHA-256, optionally signs the canonical binary message with `--signing-key`, sends `X-Binary-Signature`/`X-Binary-Public-Key`) and `Package::fetch_binary_variants` (parses a release's binary list from the registry detail JSON) in `RegistryClient`. - Wired `vbs publish-binary --registry --name --version --variant --file [--signing-key] [--token-env]` into `src/Main.cpp`; the registry binary-variant test now publishes/lists through the client API in addition to the loopback endpoint checks. +- **Wave 30 (Binaries CLI)**: + - Added `vbs binaries list|fetch` backed by `Package::fetch_binary_variants`: `list` prints one line per variant (`id sha256 size signed|unsigned`), and `fetch` resolves the variant, builds the registry download URL, and downloads the artifact with SHA-256 verification via `download_binary_artifact`. + - `vbs_cli_contract` covers the help/error contracts; the live registry CLI E2E now publishes a binary variant with `vbs publish-binary`, lists it, and fetches it byte-for-byte. + ## 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 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, daemon-backed IDE metadata, compdb export, IDE config generation, editor watch poll and bounded long-poll done; dedicated external editor plugins remain), and Track E4 (`Void::Net`/`Void::Sqlite` alignment) remain planned scope. diff --git a/docs/agent-workflow/TASKS.md b/docs/agent-workflow/TASKS.md index d65796e..960e868 100644 --- a/docs/agent-workflow/TASKS.md +++ b/docs/agent-workflow/TASKS.md @@ -36,4 +36,5 @@ Base HEAD: `fe0d1a6` | Wave 27 (Track E3 editor long-poll watch) | `watch_wait` daemon request + `vbs daemon ide wait --timeout-ms`: bounded 0-5000 ms long poll over the warm watcher returning changed paths/sequence/timed_out | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 13/13, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, `tests/CliContracts.cmake`, docs | | Wave 28 (Registry binary-variant endpoints) | `BinaryReleaseMeta` storage, `PUT .../binaries/` + `GET .../binaries//download`, metadata persistence/detail listing, signature header validation, immutable conflicts | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry suite 6/6, full CTest 8/8) | `registry/include/Void/Build/Registry/RegistryService.hpp`, `registry/service/RegistryService.cpp`, `tests/RegistryTests.cpp`, docs | | Wave 29 (RegistryClient binary API + signed CLI) | `publish_binary_variant`/`fetch_binary_variants` in RegistryClient; `vbs publish-binary` CLI with optional signing; registry test extended | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry suite 6/6, full CTest 8/8) | `include/Void/Build/Package/RegistryClient.hpp`, `src/Package/RegistryClient.cpp`, `src/Main.cpp`, `tests/RegistryTests.cpp`, `tests/CliContracts.cmake`, docs | +| Wave 30 (`vbs binaries list|fetch`) | CLI over `fetch_binary_variants`: list id/digest/size/signature state; fetch resolves the variant and downloads with SHA-256 verification | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry suite 6/6, full CTest 8/8) | `src/Main.cpp`, `tests/RegistryTests.cpp`, `tests/CliContracts.cmake`, 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) | diff --git a/docs/agent-workflow/VERIFICATION.md b/docs/agent-workflow/VERIFICATION.md index d8f9ef5..0cfac40 100644 --- a/docs/agent-workflow/VERIFICATION.md +++ b/docs/agent-workflow/VERIFICATION.md @@ -538,6 +538,22 @@ dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure - Full CTest: **8 / 8 passed** in 206.08 s. - `clang-format --dry-run --Werror` passes on the changed C++ files. +## `vbs binaries list|fetch` (GCC 16.2, pin `0002e74`) + +```sh +dev cpp-gcc -c cmake --build build/pinned --parallel 8 +dev cpp-gcc -c build/pinned/bin/vbs_registry_tests --no-color +dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure +``` + +- Build: exit 0. Registry suite: **6 / 6 passed** in 11.92 s; the live CLI E2E publishes a binary + variant with `vbs publish-binary`, lists it (`cli-variant ... unsigned`) and fetches it + byte-for-byte into the requested output file. +- `vbs_cli_contract` covers `binaries --help`, `binaries list|fetch --help`, and the + missing-argument errors. +- Full CTest: **8 / 8 passed** in 207.71 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). diff --git a/docs/roadmap/21-expansion-roadmap.md b/docs/roadmap/21-expansion-roadmap.md index 222a077..7830804 100644 --- a/docs/roadmap/21-expansion-roadmap.md +++ b/docs/roadmap/21-expansion-roadmap.md @@ -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, `materialize_binary_variant` downloads digest-verified artifacts with cached-digest revalidation, `vbs-registry` stores/serves per-release binary variants with optional signature metadata, and `vbs publish-binary` publishes signed variants through `RegistryClient`. | 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, `materialize_binary_variant` downloads digest-verified artifacts with cached-digest revalidation, `vbs-registry` stores/serves per-release binary variants with optional signature metadata, `vbs publish-binary` publishes signed variants through `RegistryClient`, and `vbs binaries list|fetch` inspects and downloads them. | 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`). | --- diff --git a/src/Main.cpp b/src/Main.cpp index f7c3b69..94baa51 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -1151,6 +1152,67 @@ int execute_publish_binary_command(const PublishBinaryCmdOptions &opts) { return 0; } +struct BinariesCmdOptions { + std::optional registry_arg; + std::optional name_arg; + std::optional version_arg; + std::optional variant_arg; + std::optional output_arg; + std::string token_env{"VBS_REGISTRY_TOKEN"}; +}; + +int execute_binaries_command(std::string_view sub, const BinariesCmdOptions &opts) { + const std::string registry_url = opts.registry_arg + ? *opts.registry_arg + : Void::Configuration::get_env_or("VBS_REGISTRY_URL", ""); + if (registry_url.empty() || !opts.name_arg || !opts.version_arg) { + std::cerr << "vbs binaries: --registry, --name, and --version are required\n"; + return 2; + } + if (sub == "fetch" && (!opts.variant_arg || !opts.output_arg)) { + std::cerr << "vbs binaries fetch: --variant and --output are required\n"; + return 2; + } + + Package::RegistryAuth auth{Void::Configuration::get_env_or(opts.token_env, "")}; + auto variants = + Package::fetch_binary_variants(registry_url, *opts.name_arg, *opts.version_arg, auth); + if (!variants) { + std::cerr << "vbs binaries: " << variants.error().message() << '\n'; + return 1; + } + + if (sub == "list") { + for (const auto &variant : *variants) { + std::cout << variant.variant_id << ' ' << variant.sha256 << ' ' << variant.size_bytes + << ' ' << ((variant.signature && variant.public_key) ? "signed" : "unsigned") + << '\n'; + } + return 0; + } + + const auto match = std::ranges::find_if(*variants, [&](const Package::BinaryReleaseInfo &info) { + return info.variant_id == *opts.variant_arg; + }); + if (match == variants->end()) { + std::cerr << "vbs binaries fetch: variant '" << *opts.variant_arg << "' not found\n"; + return 1; + } + const std::string url = registry_url + "/api/v1/packages/" + + Void::Encoding::Url::encode(*opts.name_arg) + "/" + + Void::Encoding::Url::encode(*opts.version_arg) + "/binaries/" + + Void::Encoding::Url::encode(match->variant_id) + "/download"; + auto downloaded = Package::download_binary_artifact(url, match->sha256, + std::filesystem::path{*opts.output_arg}); + if (!downloaded) { + std::cerr << "vbs binaries fetch: " << downloaded.error().message() << '\n'; + return 1; + } + std::cout << "fetched " << match->variant_id << " sha256=" << match->sha256 << " -> " + << downloaded->string() << '\n'; + return 0; +} + struct PackCmdOptions { std::string project_arg; std::string out_arg{"package.tar"}; @@ -2222,6 +2284,7 @@ int main(int argc, char **argv) { pack_opts.project_arg = cwd; PublishCmdOptions publish_opts; PublishBinaryCmdOptions publish_binary_opts; + BinariesCmdOptions binaries_opts; publish_opts.project_arg = cwd; BridgeCmdOptions bridge_opts; GcCmdOptions gc_opts; @@ -2385,6 +2448,25 @@ int main(int argc, char **argv) { publish_binary_opts.token_env, "VBS_REGISTRY_TOKEN"); add_log_flags(publish_binary_cmd, false); // `-v` is `--version` on publish-binary. + auto &binaries_cmd = + root.subcommand("binaries", "Inspect prebuilt binary variants in a package registry"); + auto configure_binaries = [&](Void::Argparse::Parser &p) { + p.option("--registry", "-r", "Registry base URL (or VBS_REGISTRY_URL)", + binaries_opts.registry_arg) + .option("--name", "-n", "Package name", binaries_opts.name_arg) + .option("--version", "-v", "Release version", binaries_opts.version_arg) + .option_default("--token-env", "", "Environment variable holding bearer token", + binaries_opts.token_env, "VBS_REGISTRY_TOKEN"); + add_log_flags(p, false); + }; + configure_binaries(binaries_cmd.subcommand( + "list", "List a release's binary variants (id, digest, size, signature state)")); + auto &binaries_fetch_cmd = + binaries_cmd.subcommand("fetch", "Download one binary variant artifact"); + configure_binaries(binaries_fetch_cmd); + binaries_fetch_cmd.option("--variant", "", "Binary variant id", binaries_opts.variant_arg) + .option("--output", "-o", "Destination artifact path", binaries_opts.output_arg); + auto &pack_cmd = root.subcommand("pack", "Create a deterministic USTAR source archive (.tar)"); pack_cmd.option_default("--project", "-C", "Project directory", pack_opts.project_arg, cwd) .option_default("--output", "-o", "Output archive path", pack_opts.out_arg, "package.tar"); @@ -2614,6 +2696,9 @@ int main(int argc, char **argv) { if (cmd == "publish-binary") { return execute_publish_binary_command(publish_binary_opts); } + if (cmd == "binaries") { + return execute_binaries_command(parsed.matched_command_path.at(1), binaries_opts); + } if (cmd == "bridge") { return execute_bridge_command(bridge_opts); } diff --git a/tests/CliContracts.cmake b/tests/CliContracts.cmake index df61e65..59fcaa2 100644 --- a/tests/CliContracts.cmake +++ b/tests/CliContracts.cmake @@ -45,6 +45,11 @@ check_process(2 "" "--prefix is required" uninstall) check_process(2 "" "--input and --output-dir are required" gen-tests) check_process(0 "Usage: vbs publish " "" publish --help) check_process(0 "Usage: vbs publish-binary " "" publish-binary --help) +check_process(0 "Usage: vbs binaries .*Commands:.*list.*fetch" "" binaries --help) +check_process(0 "Usage: vbs binaries list " "" binaries list --help) +check_process(0 "Usage: vbs binaries fetch " "" binaries fetch --help) +check_process(2 "" "--registry, --name, and --version are required" binaries list) +check_process(2 "" "--variant and --output are required" binaries fetch --registry http://127.0.0.1:1 --name p --version 1.0.0) check_process(2 "" "--registry, --name, --version, --variant, and --file are required" publish-binary) check_process(2 "" "--registry, --name, and --version are required" publish) check_process(0 "Usage: vbs daemon .*Commands:.*run.*status.*stop.*recover.*gc.*describe" "" daemon --help) diff --git a/tests/RegistryTests.cpp b/tests/RegistryTests.cpp index 3b4e450..5323037 100644 --- a/tests/RegistryTests.cpp +++ b/tests/RegistryTests.cpp @@ -710,6 +710,51 @@ target_include_directories(hello_pkg PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include auto r2 = Platform::run_supervised(pub2); Void::Testing::expect(r2.has_value() && r2->succeeded()); + // 1b. Binary variant CLI: publish, list, and fetch the artifact. + const auto binary_artifact = tmp / "binary_artifact.bin"; + (void)Platform::atomic_write_file(binary_artifact, "CLI_BINARY_VARIANT_BYTES", false); + Platform::ProcessRequest bin_pub; + bin_pub.executable = vbs_bin; + bin_pub.arguments = {"publish-binary", + "--registry", + reg_url, + "--name", + "hello-pkg", + "--version", + "1.1.0", + "--variant", + "cli-variant", + "--file", + binary_artifact.string()}; + bin_pub.environment.set_vars["VBS_REGISTRY_TOKEN"] = *tok; + auto bin_pub_res = Platform::run_supervised(bin_pub); + Void::Testing::expect(bin_pub_res.has_value() && bin_pub_res->succeeded()); + + Platform::ProcessRequest bin_list; + bin_list.executable = vbs_bin; + bin_list.arguments = {"binaries", "list", "--registry", reg_url, + "--name", "hello-pkg", "--version", "1.1.0"}; + bin_list.environment.set_vars["VBS_REGISTRY_TOKEN"] = *tok; + auto bin_list_res = Platform::run_supervised(bin_list); + Void::Testing::expect(bin_list_res.has_value() && bin_list_res->succeeded()); + if (bin_list_res) { + Void::Testing::expect(bin_list_res->stdout_data.find("cli-variant") != std::string::npos); + Void::Testing::expect(bin_list_res->stdout_data.find("unsigned") != std::string::npos); + } + + const auto fetched_artifact = tmp / "fetched_binary.bin"; + Platform::ProcessRequest bin_fetch; + bin_fetch.executable = vbs_bin; + bin_fetch.arguments = {"binaries", "fetch", "--registry", reg_url, + "--name", "hello-pkg", "--version", "1.1.0", + "--variant", "cli-variant", "--output", fetched_artifact.string()}; + bin_fetch.environment.set_vars["VBS_REGISTRY_TOKEN"] = *tok; + auto bin_fetch_res = Platform::run_supervised(bin_fetch); + Void::Testing::expect(bin_fetch_res.has_value() && bin_fetch_res->succeeded()); + auto fetched_bytes = Void::FileSystem::read_file(fetched_artifact); + Void::Testing::require(fetched_bytes.has_value()); + Void::Testing::expect(*fetched_bytes == "CLI_BINARY_VARIANT_BYTES"); + // 2. Create a consumer project declaring `.package("hello-pkg", "^1.0").registry(reg_url)`. const auto cons_dir = tmp / "consumer"; const auto cons_build = tmp / "consumer_build";