feat(package): read package owners through the registry client
This commit is contained in:
1 parent
eb4af6f3d2
commit
105519924a
7 files changed
+106
-1
No files matched your search
@@ -229,6 +229,8 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
|
||||
|
||||
- **Wave 68 (Daemon `clean --all` Coverage)**: `Daemon.clean_all_removes_entire_build_root` verifies whole-build-root removal while the connected client still receives the response.
|
||||
|
||||
- **Wave 69 (RegistryClient Owners Helper, via swarm)**: a swarm worker added `Package::fetch_package_owners` (GET `/api/v1/packages/<name>/owners`, explicit 404/401/403 mapping) and RegistryTests coverage (owner list contains `pub_alice`, missing package fails, anonymous private access fails); the orchestrator reviewed, built, and verified it.
|
||||
|
||||
## 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))**: Track C (macOS/Windows ports + dual-profile cross-compilation) and dedicated external editor plugins remain planned; Track D3 signing (SBOM, Ed25519 primitives, trusted-key enforcement/distribution, binary-variant signing/distribution) and Track E3 daemon capabilities are implemented, and Track E4 now uses `Void::Net` for the registry client/server and remote cache plus `Void::Sqlite` for the StateStore when available.
|
||||
@@ -72,4 +72,5 @@ Base HEAD: `fe0d1a6`
|
||||
| Wave 65 (Daemon gen-tests request) | `gen_tests` daemon request + `vbs daemon gen-tests --input --output-dir`: confined registration-unit generation, returns path and case count | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 28/28, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, `tests/CliContracts.cmake`, docs |
|
||||
| Wave 66 (Signed binaries fetch) | `binaries fetch --trusted-public-key/--trusted-key-file` verifies the variant signature before download; E2E covers unsigned rejection | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 7/7, full CTest 8/8) | `src/Main.cpp`, `tests/RegistryTests.cpp`, docs |
|
||||
| Wave 67 (Daemon init request) | `Config::scaffold_project` extraction; `init` daemon request + `vbs daemon init --dir`: confined project scaffolding | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 29/29, full CTest 8/8) | `include/Void/Build/Config/Scaffold.hpp`, `src/Config/Scaffold.cpp`, `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, `tests/CliContracts.cmake`, build lists, docs |
|
||||
| Wave 69 (RegistryClient owners helper, via swarm) | `fetch_package_owners` in RegistryClient + RegistryTests coverage (owners list, missing package 404, anonymous private 401) | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 7/7, full CTest 8/8) | `include/Void/Build/Package/RegistryClient.hpp`, `src/Package/RegistryClient.cpp`, `tests/RegistryTests.cpp`, docs |
|
||||
| Future (Plan 20 Slice 3 / Tracks C, E3 editor extensions) |"}] 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) |
|
||||
@@ -1110,6 +1110,15 @@ dev cpp-gcc -c build/pinned/bin/vbs_v1_tests --suite Daemon --no-color
|
||||
own. Asserted: response correct and `build_root` no longer exists.
|
||||
- Daemon suite: **30 / 30 passed** in 55.81 s.
|
||||
|
||||
## RegistryClient Owners Helper via Swarm (GCC 16.2, pin `0002e74`)
|
||||
|
||||
- Swarm `swarm_mx89q8ak_2at3` (one worker) planned, decomposed, and completed all 6 tasks this
|
||||
time; the orchestrator reviewed the diff before building.
|
||||
- `Package::fetch_package_owners` returns the owners of `owner-pkg` (including `pub_alice`), fails
|
||||
for a missing package (404) and for anonymous access to a private package (401).
|
||||
- Registry suite after integration: **7 / 7 passed** (11.02 s); full CTest: **8 / 8 passed** in
|
||||
271.07 s.
|
||||
|
||||
## 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).
|
||||
|
||||
@@ -73,7 +73,7 @@ flowchart LR
|
||||
| --- | --- | --- |
|
||||
| **E1 — Everyday CLI Ergonomics (Implemented in Wave 8)** | `vbs init` project scaffolding, `vbs clean`, `vbs doctor` environment diagnostics, `vbs graph --format dot|json`, and `vbs build --native-foreign`. | End-to-end CLI & integration tests passing in `vbs_cli_contract` and `vbs_v1_tests`. |
|
||||
| **E2 — Multi-Package Workspaces (`workspace.cpp`)** *(verified in Docker GCC 16)* | Shared root `vbs.lock` and `build/.vbs` CAS, `workspace_dependency()` cross-member native linking, and affected-member selection (`vbs build/test --member <pkg>` / `--changed-since <ref>`). | 3-package workspace fixture (shared library + app + tests) builds/tests with one root lockfile; member selection and `--changed-since` verified in `FullV1Tests.workspace_members_shared_build_and_member_selection`. |
|
||||
| **E3 — IDE Config/Query & Background Daemon** | `build.cpp`/`build.profiles.cpp`/`build-support/` SDK entries in `compile_commands.json` + `vbs ide generate` (`.clangd`, `.vscode/`, `.zed/`, `.idea/customTargets.xml`) & `vbs ide query` (**Implemented & Verified in Wave 10**); Unix-socket daemon core holding a warm `StateStore` + project `DirectoryWatcher` with `vbs daemon run\|status\|stop\|gc\|recover\|describe` (**Implemented & Verified in Wave 14; bounded `describe` added in the post-v1 daemon follow-up**). `describe` returns a bounded graph summary (`target_names` ≤ 128 entries × 200 bytes, `profile` ≤ 128 bytes, 10 s evaluation timeout); `vbs daemon build` executes the lowered graph in-process against the warm state store with bounded `profile`/`targets`/`jobs`, including daemon-side dependency resolution/materialization and provider import via `Package::resolve_and_materialize_dependencies`; `vbs daemon ide query` publishes/selects the profile compilation database and serves the IDE workspace/target metadata JSON over the socket, `vbs daemon compdb export` returns the published compilation-database path and entry count, `vbs daemon ide generate` writes the editor presets over the socket, `vbs daemon ide poll` exposes a bounded editor-extension watch protocol (changed paths, sequence, overflow state), `vbs daemon ide wait` adds a bounded long-poll variant, `vbs daemon ide status` reports the active editor selection and compdb state, `vbs daemon compdb use` switches the active editor profile under the selection lock, `vbs daemon graph` exports the target dependency graph (DOT/JSON), `vbs daemon test` builds and runs declared test targets, `vbs daemon clean` removes generated outputs while preserving the shared cache, `vbs daemon target info` reports per-target sources/outputs, `vbs daemon actions` lists bounded lowered actions, `vbs daemon pack` creates a confined deterministic source archive, `vbs daemon install` stages an install prefix (and `uninstall` removes only manifest-owned files), `vbs daemon gen-tests` generates the native test registration unit, `vbs daemon init` scaffolds confined projects, `vbs daemon compdb entries` serves bounded per-file compile arguments to editor extensions, `vbs daemon workspace members` lists workspace members cheaply, `vbs daemon ide configs` reports which editor configuration files exist, `vbs daemon compdb generations` lists editor generation history with the active selection, `vbs daemon info` exposes the daemon environment, `vbs daemon deps` resolves/materializes dependencies over the socket, registry package search and audit queries support bounded pagination/filters, releases expose a version-specific detail endpoint, and package ownership is managed through an audited owners API. Daemon workspace support describes members, builds all members in order (or a selected member) with the shared root lock, and serves member-scoped IDE query/generate/compdb requests via `--member`. Dedicated editor extensions remain planned. | `vbs ide` & `build.cpp` syntax-check verified in `FullV1Tests.cpp`; daemon lifecycle/status/gc/shutdown/describe verified in `DaemonTests.cpp` (6/6 under `dev cpp-gcc`); the live `vbs daemon describe` CLI round-trip is verified in `vbs_cli_contract`. |
|
||||
| **E3 — IDE Config/Query & Background Daemon** | `build.cpp`/`build.profiles.cpp`/`build-support/` SDK entries in `compile_commands.json` + `vbs ide generate` (`.clangd`, `.vscode/`, `.zed/`, `.idea/customTargets.xml`) & `vbs ide query` (**Implemented & Verified in Wave 10**); Unix-socket daemon core holding a warm `StateStore` + project `DirectoryWatcher` with `vbs daemon run\|status\|stop\|gc\|recover\|describe` (**Implemented & Verified in Wave 14; bounded `describe` added in the post-v1 daemon follow-up**). `describe` returns a bounded graph summary (`target_names` ≤ 128 entries × 200 bytes, `profile` ≤ 128 bytes, 10 s evaluation timeout); `vbs daemon build` executes the lowered graph in-process against the warm state store with bounded `profile`/`targets`/`jobs`, including daemon-side dependency resolution/materialization and provider import via `Package::resolve_and_materialize_dependencies`; `vbs daemon ide query` publishes/selects the profile compilation database and serves the IDE workspace/target metadata JSON over the socket, `vbs daemon compdb export` returns the published compilation-database path and entry count, `vbs daemon ide generate` writes the editor presets over the socket, `vbs daemon ide poll` exposes a bounded editor-extension watch protocol (changed paths, sequence, overflow state), `vbs daemon ide wait` adds a bounded long-poll variant, `vbs daemon ide status` reports the active editor selection and compdb state, `vbs daemon compdb use` switches the active editor profile under the selection lock, `vbs daemon graph` exports the target dependency graph (DOT/JSON), `vbs daemon test` builds and runs declared test targets, `vbs daemon clean` removes generated outputs while preserving the shared cache, `vbs daemon target info` reports per-target sources/outputs, `vbs daemon actions` lists bounded lowered actions, `vbs daemon pack` creates a confined deterministic source archive, `vbs daemon install` stages an install prefix (and `uninstall` removes only manifest-owned files), `vbs daemon gen-tests` generates the native test registration unit, `vbs daemon init` scaffolds confined projects, `vbs daemon compdb entries` serves bounded per-file compile arguments to editor extensions, `vbs daemon workspace members` lists workspace members cheaply, `vbs daemon ide configs` reports which editor configuration files exist, `vbs daemon compdb generations` lists editor generation history with the active selection, `vbs daemon info` exposes the daemon environment, `vbs daemon deps` resolves/materializes dependencies over the socket, registry package search and audit queries support bounded pagination/filters, releases expose a version-specific detail endpoint, package ownership is managed through an audited owners API, and `RegistryClient::fetch_package_owners` reads it. Daemon workspace support describes members, builds all members in order (or a selected member) with the shared root lock, and serves member-scoped IDE query/generate/compdb requests via `--member`. Dedicated editor extensions remain planned. | `vbs ide` & `build.cpp` syntax-check verified in `FullV1Tests.cpp`; daemon lifecycle/status/gc/shutdown/describe verified in `DaemonTests.cpp` (6/6 under `dev cpp-gcc`); the live `vbs daemon describe` CLI round-trip is verified in `vbs_cli_contract`. |
|
||||
| **E4 — Transport & Storage Upstream Alignment** *(Sqlite and Net client adopted)* | Adopt `Void::Net` (`VL-004`/`VL-005`) and `Void::Sqlite` (`VL-011b`) when lightweight/bundled builds become available in minimal Nix toolchains, reducing VBS transport code further. `Void::Sqlite` backs the `StateStore` when SQLite3 is present, `Void::Net` backs the `RegistryClient`, remote-cache, and registry-server HTTP transports (TLS-verifying `HttpClient`/`HttpServer`) when `Net` is enabled (`-p openssl -p boost`), keeping the pure-POSIX fallbacks. | All `vbs_registry_tests` and `vbs_core_tests` pass on both minimal and full toolchains (verified: registry 7/7 on the Net transport; default and SQLite builds 8/8). |
|
||||
|
||||
---
|
||||
|
||||
@@ -78,6 +78,13 @@ fetch_binary_variants(std::string_view registry_url, std::string_view package_na
|
||||
std::string_view version, const RegistryAuth &auth = {},
|
||||
bool include_yanked = false);
|
||||
|
||||
// Lists package owners from GET /api/v1/packages/<name>/owners. Requires read permission on
|
||||
// the package (or ownership): a missing package is not_found, missing credentials are
|
||||
// permission_denied.
|
||||
[[nodiscard]] Void::Result::Result<std::vector<std::string>, Void::Result::Error>
|
||||
fetch_package_owners(std::string_view registry_url, std::string_view package_name,
|
||||
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>
|
||||
|
||||
@@ -558,6 +558,63 @@ fetch_binary_variants(std::string_view registry_url, std::string_view package_na
|
||||
return variants;
|
||||
}
|
||||
|
||||
Void::Result::Result<std::vector<std::string>, Void::Result::Error>
|
||||
fetch_package_owners(std::string_view registry_url, std::string_view package_name,
|
||||
const RegistryAuth &auth) {
|
||||
auto parsed_url = parse_registry_url(registry_url);
|
||||
if (!parsed_url) {
|
||||
return std::unexpected{parsed_url.error()};
|
||||
}
|
||||
std::map<std::string, std::string, std::less<>> headers;
|
||||
if (!auth.bearer_token.empty()) {
|
||||
headers["Authorization"] = "Bearer " + auth.bearer_token;
|
||||
}
|
||||
const std::string path =
|
||||
"/api/v1/packages/" + Void::Encoding::Url::encode(package_name) + "/owners";
|
||||
auto reply = send_http_request(*parsed_url, "GET", path, headers, {});
|
||||
if (!reply) {
|
||||
return std::unexpected{reply.error()};
|
||||
}
|
||||
if (reply->status != 200) {
|
||||
auto code = Void::System::SystemErrorCode::io_error;
|
||||
if (reply->status == 404) {
|
||||
code = Void::System::SystemErrorCode::not_found;
|
||||
} else if (reply->status == 401 || reply->status == 403) {
|
||||
code = Void::System::SystemErrorCode::permission_denied;
|
||||
}
|
||||
return std::unexpected{
|
||||
make_error(code, std::format("registry GET {} failed with HTTP {}: {}", path,
|
||||
reply->status, reply->body))};
|
||||
}
|
||||
auto json = Void::Json::Strict::parse(reply->body);
|
||||
if (!json) {
|
||||
return std::unexpected{make_error(Void::System::SystemErrorCode::io_error,
|
||||
"invalid JSON returned by registry owners endpoint")};
|
||||
}
|
||||
const auto *root = std::get_if<JsonVal::Object>(&json->value);
|
||||
if (!root) {
|
||||
return std::unexpected{make_error(Void::System::SystemErrorCode::io_error,
|
||||
"registry response root must be a JSON object")};
|
||||
}
|
||||
std::vector<std::string> owners;
|
||||
const auto oit = root->find("owners");
|
||||
if (oit == root->end()) {
|
||||
return owners;
|
||||
}
|
||||
const auto *array = std::get_if<JsonVal::Array>(&oit->second.value);
|
||||
if (!array) {
|
||||
return std::unexpected{make_error(Void::System::SystemErrorCode::io_error,
|
||||
"registry owners field must be a JSON array")};
|
||||
}
|
||||
owners.reserve(array->size());
|
||||
for (const auto &entry : *array) {
|
||||
if (const auto *name = std::get_if<std::string>(&entry.value); name && !name->empty()) {
|
||||
owners.push_back(*name);
|
||||
}
|
||||
}
|
||||
return owners;
|
||||
}
|
||||
|
||||
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, const RegistryAuth &auth) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <span>
|
||||
@@ -187,10 +188,38 @@ VOID_TEST(RegistryTests, registry_rbac_immutability_csrf_xss_web_and_backup_rest
|
||||
if (owners) {
|
||||
Void::Testing::expect(owners->body.find("pub_alice") != std::string::npos);
|
||||
}
|
||||
// The RegistryClient helper parses the owners endpoint and surfaces a missing package.
|
||||
const std::string reg_url = "http://127.0.0.1:" + std::to_string(port);
|
||||
auto client_owners =
|
||||
Package::fetch_package_owners(reg_url, "owner-pkg", Package::RegistryAuth{*alice_tok});
|
||||
Void::Testing::require(client_owners.has_value());
|
||||
Void::Testing::expect(std::ranges::find(*client_owners, std::string{"pub_alice"}) !=
|
||||
client_owners->end());
|
||||
auto missing_owners =
|
||||
Package::fetch_package_owners(reg_url, "missing-pkg", Package::RegistryAuth{*alice_tok});
|
||||
Void::Testing::expect(!missing_owners.has_value());
|
||||
if (!missing_owners) {
|
||||
Void::Testing::expect(missing_owners.error().message().find("404") != std::string::npos);
|
||||
}
|
||||
// Private packages require read permission, so anonymous access is rejected.
|
||||
auto denied_owners =
|
||||
Package::fetch_package_owners(reg_url, "secret-pkg", Package::RegistryAuth{});
|
||||
Void::Testing::expect(!denied_owners.has_value());
|
||||
if (!denied_owners) {
|
||||
Void::Testing::expect(denied_owners.error().message().find("401") != std::string::npos);
|
||||
}
|
||||
auto add_owner = send_loopback_http(port, "PUT", "/api/v1/packages/owner-pkg/owners/read_bob",
|
||||
{{"Authorization", "Bearer " + *alice_tok}});
|
||||
Void::Testing::require(add_owner.has_value());
|
||||
Void::Testing::expect_eq(static_cast<int>(add_owner->status), 200);
|
||||
// The helper reflects subsequent ownership changes.
|
||||
auto updated_owners =
|
||||
Package::fetch_package_owners(reg_url, "owner-pkg", Package::RegistryAuth{*alice_tok});
|
||||
Void::Testing::require(updated_owners.has_value());
|
||||
Void::Testing::expect(std::ranges::find(*updated_owners, std::string{"pub_alice"}) !=
|
||||
updated_owners->end());
|
||||
Void::Testing::expect(std::ranges::find(*updated_owners, std::string{"read_bob"}) !=
|
||||
updated_owners->end());
|
||||
auto add_unknown = send_loopback_http(port, "PUT", "/api/v1/packages/owner-pkg/owners/ghost",
|
||||
{{"Authorization", "Bearer " + *alice_tok}});
|
||||
Void::Testing::expect(add_unknown.has_value() && add_unknown->status == 404);
|
||||
|
||||
Reference in new issue
Block a user