From 66d2fa6a2e3c4df7f74d1d4e08bb00e79d628a53 Mon Sep 17 00:00:00 2001 From: "Aleksei (Faumaray) Selikhov" Date: Thu, 3 Dec 2026 22:15:50 +0300 Subject: [PATCH] feat(registry): yank binary variants and exclude them from selection --- docs/agent-workflow/STATE.md | 4 ++ docs/agent-workflow/TASKS.md | 1 + docs/agent-workflow/VERIFICATION.md | 14 +++++ docs/roadmap/21-expansion-roadmap.md | 2 +- include/Void/Build/Package/RegistryClient.hpp | 1 + .../Void/Build/Registry/RegistryService.hpp | 1 + registry/service/RegistryService.cpp | 62 +++++++++++++++++-- src/Package/RegistryClient.cpp | 4 +- tests/RegistryTests.cpp | 34 ++++++++++ 9 files changed, 116 insertions(+), 7 deletions(-) diff --git a/docs/agent-workflow/STATE.md b/docs/agent-workflow/STATE.md index 02033aa..442f057 100644 --- a/docs/agent-workflow/STATE.md +++ b/docs/agent-workflow/STATE.md @@ -161,6 +161,10 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B - Added the `compdb_use` daemon request (`vbs daemon compdb use --profile`): it switches the active editor profile to an already-published compilation database via `Editor::select_editor_profile` (selection lock) and returns the selected profile, generation id, ticket, and compdb path. - Added `Daemon.compdb_use_switches_active_editor_profile` (export then select `debug`; unknown profile rejected) and a CLI help contract; Daemon suite is now 15 cases. +- **Wave 36 (Registry Binary-Variant Yank)**: + - Added `POST /api/v1/packages///binaries//yank` to `vbs-registry` (auth + CSRF, publish authority, `{"yanked":bool}` body defaulting to true) with `BinaryReleaseMeta::yanked` persisted and listed in detail JSON. `RegistryClient::fetch_binary_variants` now exposes `yanked` and never returns yanked variants for selection. + - The registry binary-variant test now checks unauthenticated yank rejection, CSRF-protected session yank, the yanked flag in the detail JSON, and that the yanked variant disappears from the client variant list. + ## 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 7d28b10..f51ac72 100644 --- a/docs/agent-workflow/TASKS.md +++ b/docs/agent-workflow/TASKS.md @@ -42,4 +42,5 @@ Base HEAD: `fe0d1a6` | Wave 33 (Daemon workspace-wide build) | `execute_project_build`/`BuildOutcome` split; workspace build without `member` builds all members in order with per-member and aggregate results | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 13/13, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `tests/DaemonTests.cpp`, docs | | Wave 34 (Editor status request) | `editor_status` daemon request + `vbs daemon ide status`: selection state, compdb existence/entry count | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 14/14, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, `tests/CliContracts.cmake`, docs | | Wave 35 (Daemon compdb use) | `compdb_use` daemon request + `vbs daemon compdb use --profile`: switches the active editor profile under the selection lock | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 15/15, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, `tests/CliContracts.cmake`, docs | +| Wave 36 (Registry binary-variant yank) | `POST .../binaries//yank`, persisted `yanked` flag in detail JSON, client filters yanked variants | 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`, `include/Void/Build/Package/RegistryClient.hpp`, `src/Package/RegistryClient.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) | diff --git a/docs/agent-workflow/VERIFICATION.md b/docs/agent-workflow/VERIFICATION.md index ba873b3..5b29307 100644 --- a/docs/agent-workflow/VERIFICATION.md +++ b/docs/agent-workflow/VERIFICATION.md @@ -628,6 +628,20 @@ dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure - Full CTest: **8 / 8 passed** in 213.57 s. - `clang-format --dry-run --Werror` passes on the changed C++ files. +## Registry Binary-Variant Yank (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.95 s; the binary-variant test verifies an + unauthenticated yank returns 401, a CSRF-authenticated session yank returns 200, the detail JSON + shows `"yanked":true` for the variant, and `fetch_binary_variants` no longer returns it. +- Full CTest: **8 / 8 passed** in 212.64 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 c28ce6b..bb74e9a 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, `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`). | +| **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 CSRF-protected yank (the client never selects yanked variants), `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/include/Void/Build/Package/RegistryClient.hpp b/include/Void/Build/Package/RegistryClient.hpp index 1eca3d2..d24a9e5 100644 --- a/include/Void/Build/Package/RegistryClient.hpp +++ b/include/Void/Build/Package/RegistryClient.hpp @@ -61,6 +61,7 @@ struct BinaryReleaseInfo { std::string variant_id; std::string sha256; std::uint64_t size_bytes{0}; + bool yanked{false}; std::optional signature; std::optional public_key; }; diff --git a/registry/include/Void/Build/Registry/RegistryService.hpp b/registry/include/Void/Build/Registry/RegistryService.hpp index c441c30..f8ca3eb 100644 --- a/registry/include/Void/Build/Registry/RegistryService.hpp +++ b/registry/include/Void/Build/Registry/RegistryService.hpp @@ -46,6 +46,7 @@ struct BinaryReleaseMeta { std::string variant_id; std::string sha256; std::uint64_t size_bytes{0}; + bool yanked{false}; std::string signature; // Ed25519 signature hex; empty = unsigned artifact. std::string public_key; // Ed25519 public key hex; empty = unsigned artifact. std::string publisher; diff --git a/registry/service/RegistryService.cpp b/registry/service/RegistryService.cpp index 11e1d7e..008ef76 100644 --- a/registry/service/RegistryService.cpp +++ b/registry/service/RegistryService.cpp @@ -310,6 +310,7 @@ Void::Result::Result RegistryService::load_locked() { bm.sha256 = get_str(*bo, "sha256"); bm.size_bytes = static_cast( get_i64(*bo, "size_bytes", 0)); + bm.yanked = get_bool(*bo, "yanked", false); bm.signature = get_str(*bo, "signature"); bm.public_key = get_str(*bo, "public_key"); bm.publisher = get_str(*bo, "publisher"); @@ -413,7 +414,8 @@ Void::Result::Result RegistryService::save_locked() { return "{\"variant_id\":" + json_quote(b.variant_id) + ",\"sha256\":" + json_quote(b.sha256) + ",\"size_bytes\":" + - std::to_string(b.size_bytes) + + std::to_string(b.size_bytes) + ",\"yanked\":" + + std::string{b.yanked ? "true" : "false"} + ",\"signature\":" + json_quote(b.signature) + ",\"public_key\":" + json_quote(b.public_key) + ",\"publisher\":" + json_quote(b.publisher) + @@ -852,7 +854,8 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) { return "{\"variant_id\":" + json_quote(b.variant_id) + ",\"sha256\":" + json_quote(b.sha256) + ",\"size_bytes\":" + - std::to_string(b.size_bytes) + + std::to_string(b.size_bytes) + ",\"yanked\":" + + std::string{b.yanked ? "true" : "false"} + ",\"signature\":" + json_quote(b.signature) + ",\"public_key\":" + json_quote(b.public_key) + '}'; @@ -1131,9 +1134,15 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) { copied.error().message()); } } - rit->second.binaries[variant_id] = BinaryReleaseMeta{ - variant_id, actual_sha, req.body.size(), binary_signature, - binary_public_key, principal->username, now_epoch()}; + BinaryReleaseMeta binary_meta; + binary_meta.variant_id = variant_id; + binary_meta.sha256 = actual_sha; + binary_meta.size_bytes = req.body.size(); + binary_meta.signature = binary_signature; + binary_meta.public_key = binary_public_key; + binary_meta.publisher = principal->username; + binary_meta.published_epoch = now_epoch(); + rit->second.binaries[variant_id] = std::move(binary_meta); append_audit_locked(principal->username, "binary.publish", pkg_name + "@" + ver_str + "/" + variant_id, "ok", "sha256=" + actual_sha); @@ -1178,6 +1187,49 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) { return resp; } + // Yank/unyank a binary variant: + // POST /api/v1/packages///binaries//yank + if (segs.size() == 8 && segs[5] == "binaries" && segs[7] == "yank" && + req.method == "POST") { + if (!principal) { + return HttpResponse::error_json(401, "unauthorized", "authentication required"); + } + if (!check_csrf_locked(req, *principal)) { + return HttpResponse::error_json(403, "csrf_failed", + "missing or invalid CSRF token"); + } + const auto pit = packages_.find(pkg_name); + if (pit == packages_.end()) { + return HttpResponse::error_json(404, "not_found", "package not found"); + } + if (!can_publish_pkg(&pit->second)) { + return HttpResponse::error_json(403, "forbidden", "insufficient yank authority"); + } + const auto rit = pit->second.releases.find(segs[4]); + if (rit == pit->second.releases.end()) { + return HttpResponse::error_json(404, "not_found", "release not found"); + } + const auto bit = rit->second.binaries.find(segs[6]); + if (bit == rit->second.binaries.end()) { + return HttpResponse::error_json(404, "not_found", "binary variant not found"); + } + bool yanked = true; + if (!req.body.empty()) { + if (auto parsed = Void::Json::Strict::parse(req.body); parsed) { + if (const auto *obj = std::get_if(&parsed->value)) { + yanked = get_bool(*obj, "yanked", true); + } + } + } + bit->second.yanked = yanked; + append_audit_locked(principal->username, yanked ? "binary.yank" : "binary.unyank", + pkg_name + "@" + segs[4] + "/" + segs[6], "ok", ""); + (void)save_locked(); + return HttpResponse::json( + 200, "{\"variant_id\":" + json_quote(segs[6]) + + ",\"yanked\":" + std::string{yanked ? "true" : "false"} + "}\n"); + } + // Yank/unyank release: POST /api/v1/packages///yank if (segs.size() == 6 && segs[5] == "yank" && req.method == "POST") { if (!principal) { diff --git a/src/Package/RegistryClient.cpp b/src/Package/RegistryClient.cpp index d682586..8311bfe 100644 --- a/src/Package/RegistryClient.cpp +++ b/src/Package/RegistryClient.cpp @@ -512,13 +512,15 @@ fetch_binary_variants(std::string_view registry_url, std::string_view package_na info.variant_id = get_str(*bo, "variant_id"); info.sha256 = get_str(*bo, "sha256"); info.size_bytes = static_cast(get_i64(*bo, "size_bytes", 0)); + info.yanked = get_bool(*bo, "yanked", false); if (const auto sig = get_str(*bo, "signature"); !sig.empty()) { info.signature = sig; } if (const auto key = get_str(*bo, "public_key"); !key.empty()) { info.public_key = key; } - if (!info.variant_id.empty()) { + // Yanked variants stay listed but must never be selected for materialization. + if (!info.variant_id.empty() && !info.yanked) { variants.push_back(std::move(info)); } } diff --git a/tests/RegistryTests.cpp b/tests/RegistryTests.cpp index 5323037..372645d 100644 --- a/tests/RegistryTests.cpp +++ b/tests/RegistryTests.cpp @@ -583,6 +583,11 @@ VOID_TEST(RegistryTests, registry_binary_variant_publish_download_and_materializ "different"); Void::Testing::expect(conflict.has_value() && conflict->status == 409); + // Binary yank requires authentication (bearer tokens are not CSRF-exempt). + auto bin_yank = + send_loopback_http(port, "POST", binary_path + "/yank", {}, "{\"yanked\":true}"); + Void::Testing::expect(bin_yank.has_value() && bin_yank->status == 401); + // The registry-served artifact materializes through the signed binary-variant path. Package::BinaryVariantMeta variant; variant.variant_id = variant_id; @@ -644,6 +649,35 @@ VOID_TEST(RegistryTests, registry_binary_variant_publish_download_and_materializ } Void::Testing::expect(found_client_variant); + // Authenticated session + CSRF allows yanking the variant; the detail JSON reflects it. + auto yank_login = send_loopback_http(port, "POST", "/api/v1/auth/login", + {{"Content-Type", "application/json"}}, + "{\"username\":\"admin\",\"password\":\"admin_pw\"}"); + Void::Testing::require(yank_login.has_value() && yank_login->status == 200); + const auto yank_cookie = extract_session_cookie(yank_login->set_cookies); + const auto yank_csrf = extract_json_str(yank_login->body, "csrf_token"); + Void::Testing::expect(!yank_cookie.empty() && !yank_csrf.empty()); + auto session_yank = send_loopback_http(port, "POST", binary_path + "/yank", + {{"Cookie", yank_cookie}, {"X-CSRF-Token", yank_csrf}}, + "{\"yanked\":true}"); + Void::Testing::expect(session_yank.has_value() && session_yank->status == 200); + auto after_yank = send_loopback_http(port, "GET", "/api/v1/packages/demo-bin", + {{"Authorization", "Bearer " + *tok}}); + Void::Testing::expect(after_yank.has_value() && after_yank->status == 200); + if (after_yank) { + const auto variant_pos = after_yank->body.find(variant_id); + Void::Testing::expect(variant_pos != std::string::npos); + if (variant_pos != std::string::npos) { + Void::Testing::expect(after_yank->body.find("\"yanked\":true", variant_pos) != + std::string::npos); + } + } + auto variants_after_yank = + Package::fetch_binary_variants(reg_url, "demo-bin", "1.0.0", Package::RegistryAuth{*tok}); + Void::Testing::require(variants_after_yank.has_value()); + Void::Testing::expect(std::ranges::none_of( + *variants_after_yank, [&](const auto &info) { return info.variant_id == variant_id; })); + (*svc)->stop_http(); }