feat(package,daemon): revoke registry tokens; allow daemon deps updates
This commit is contained in:
1 parent
eb35bb6b6e
commit
c7d2662cf2
11 files changed
+309
-13
No files matched your search
@@ -257,6 +257,8 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
|
||||
|
||||
- **Wave 82 (Tokens Listing & Daemon `target_list`)**: added `Package::fetch_tokens` and `vbs tokens list --registry` (token id, label, user, scopes, active/revoked; the plaintext secret is never listed), covered in the CLI E2E. A swarm worker added the `target_list` daemon request (sorted name/kind/enabled with limit and member support) and its test (5/5 tasks, including its own verification).
|
||||
|
||||
- **Wave 83 (Token Revocation & Daemon `deps --update`)**: added `Package::revoke_token` and `vbs tokens revoke --registry --token-id`, with a CLI E2E that revokes a second token and observes it as revoked in the listing. A swarm worker added an `update` boolean to the daemon `deps` request (allow compatible upgrades) with validation and plumbing tests (5/5 substantive tasks; build task stopped and re-run).
|
||||
|
||||
## 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.
|
||||
@@ -86,4 +86,5 @@ Base HEAD: `fe0d1a6`
|
||||
| Wave 80 (Watch prefix + registry OPTIONS) | daemon watch `prefix` filter retaining non-matching events; swarm added registry OPTIONS 204 + Allow | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 9/9, Daemon suite passes, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `registry/service/RegistryService.cpp`, `tests/{DaemonTests,RegistryTests}.cpp`, docs |
|
||||
| Wave 81 (Registry stats + daemon doctor) | admin `GET /api/v1/stats` with ETag; swarm added daemon `doctor` diagnostics | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 9/9, Daemon suite passes, full CTest 8/8) | `registry/service/RegistryService.cpp`, `src/Daemon/Daemon.cpp`, `tests/{RegistryTests,DaemonTests}.cpp`, docs |
|
||||
| Wave 82 (Tokens list + target_list) | `fetch_tokens`/`vbs tokens list`; swarm added daemon `target_list` | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 9/9, Daemon suite passes, full CTest 8/8) | `include/Void/Build/Package/RegistryClient.hpp`, `src/Package/RegistryClient.cpp`, `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/{RegistryTests,DaemonTests}.cpp`, `tests/CliContracts.cmake`, docs |
|
||||
| Wave 83 (Tokens revoke + deps update) | `revoke_token`/`vbs tokens revoke`; swarm added daemon `deps` `update` flag | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 9/9, Daemon suite passes, full CTest 8/8) | `include/Void/Build/Package/RegistryClient.hpp`, `src/Package/RegistryClient.cpp`, `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/{RegistryTests,DaemonTests}.cpp`, `tests/CliContracts.cmake`, 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) |
|
||||
@@ -1243,6 +1243,15 @@ dev cpp-gcc -c build/pinned/bin/vbs_v1_tests --suite Daemon --no-color
|
||||
completing its own verification (5/5 tasks); `target_list_reports_targets` passes (2.48 s).
|
||||
- Registry suite: **9 / 9 passed** (12.02 s); full CTest: **8 / 8 passed** in 262.80 s.
|
||||
|
||||
## Token Revocation & Daemon `deps --update` (GCC 16.2, pin `0002e74`)
|
||||
|
||||
- `vbs tokens revoke --token-id <id>` revokes a second token and a following `vbs tokens list`
|
||||
shows it as `revoked` (live E2E, never printing the secret).
|
||||
- Swarm `swarm_mx8goqcn_4gdb` (one worker) added the `deps` `update` flag with validation and
|
||||
plumbing tests (5/5 substantive tasks; build task stopped and re-run by the orchestrator);
|
||||
`build_materializes_path_dependency` passes (4.68 s).
|
||||
- Registry suite: **9 / 9 passed** (11.47 s); full CTest: **8 / 8 passed** in 268.05 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, watch requests can be filtered by path prefix, registry endpoints answer OPTIONS with an Allow header and expose admin stats, the daemon serves structured `doctor` diagnostics, `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 tokens list` inspects registry token metadata, `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 and mutable metadata are managed through audited APIs, and `RegistryClient::fetch_package_owners` reads owners. 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, watch requests can be filtered by path prefix, registry endpoints answer OPTIONS with an Allow header and expose admin stats, the daemon serves structured `doctor` diagnostics, `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 tokens list|revoke` manages registry token metadata, `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 and mutable metadata are managed through audited APIs, and `RegistryClient::fetch_package_owners` reads owners. 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). |
|
||||
|
||||
---
|
||||
|
||||
@@ -49,6 +49,11 @@ struct TokenInfo {
|
||||
[[nodiscard]] Void::Result::Result<std::vector<TokenInfo>, Void::Result::Error>
|
||||
fetch_tokens(std::string_view registry_url, const RegistryAuth &auth = {});
|
||||
|
||||
// Revokes one API token via DELETE /api/v1/tokens/<token_id> (owner or admin only).
|
||||
[[nodiscard]] Void::Result::Result<void, Void::Result::Error>
|
||||
revoke_token(std::string_view registry_url, std::string_view token_id,
|
||||
const RegistryAuth &auth = {});
|
||||
|
||||
// Queries GET /api/v1/packages/<name> on a VBS registry and parses all release records
|
||||
// into Package::ReleaseRecord entries ready for PackageIndex + PubGrub solving.
|
||||
[[nodiscard]] Void::Result::Result<std::vector<ReleaseRecord>, Void::Result::Error>
|
||||
|
||||
+13
-2
@@ -578,7 +578,7 @@ make_resolve_options(const DaemonOptions &options) {
|
||||
// Resolves and materializes declared dependencies without building, returning the lock context.
|
||||
std::string deps_project(const DaemonOptions &options, std::string_view profile_name,
|
||||
std::optional<CompilerFamily> compiler_override, std::string_view member,
|
||||
bool offline) {
|
||||
bool offline, bool allow_upgrade) {
|
||||
auto effective_result = resolve_member_options(options, member);
|
||||
if (!effective_result) {
|
||||
return error_response(std::format("deps: {}", effective_result.error()));
|
||||
@@ -606,6 +606,7 @@ std::string deps_project(const DaemonOptions &options, std::string_view profile_
|
||||
return error_response(std::format("deps: {}", resolve_options.error()));
|
||||
}
|
||||
resolve_options->offline = offline;
|
||||
resolve_options->allow_upgrade = allow_upgrade;
|
||||
auto resolved = Package::resolve_and_materialize_dependencies(evaluated->context, *merged,
|
||||
*resolve_options);
|
||||
if (!resolved) {
|
||||
@@ -2570,7 +2571,17 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
|
||||
}
|
||||
offline = *value;
|
||||
}
|
||||
return {deps_project(options, profile_name, compiler_override, member, offline), false};
|
||||
bool allow_upgrade = false;
|
||||
if (const auto entry = object->find("update"); entry != object->end()) {
|
||||
const auto *value = std::get_if<bool>(&entry->second.value);
|
||||
if (value == nullptr) {
|
||||
return {error_response("\"update\" must be a boolean"), false};
|
||||
}
|
||||
allow_upgrade = *value;
|
||||
}
|
||||
return {deps_project(options, profile_name, compiler_override, member, offline,
|
||||
allow_upgrade),
|
||||
false};
|
||||
}
|
||||
if (*name == "install") {
|
||||
InstallRequest install_request;
|
||||
|
||||
+31
-9
@@ -1156,18 +1156,34 @@ int execute_publish_binary_command(const PublishBinaryCmdOptions &opts) {
|
||||
|
||||
struct TokensCmdOptions {
|
||||
std::optional<std::string> registry_arg;
|
||||
std::optional<std::string> token_id_arg;
|
||||
std::string token_env{"VBS_REGISTRY_TOKEN"};
|
||||
};
|
||||
|
||||
int execute_tokens_list_command(const TokensCmdOptions &opts) {
|
||||
int execute_tokens_command(std::string_view sub, const TokensCmdOptions &opts) {
|
||||
const std::string registry_url = opts.registry_arg
|
||||
? *opts.registry_arg
|
||||
: Void::Configuration::get_env_or("VBS_REGISTRY_URL", "");
|
||||
if (registry_url.empty()) {
|
||||
std::cerr << "vbs tokens list: --registry is required\n";
|
||||
std::cerr << "vbs tokens: --registry is required\n";
|
||||
return 2;
|
||||
}
|
||||
Package::RegistryAuth auth{Void::Configuration::get_env_or(opts.token_env, "")};
|
||||
|
||||
if (sub == "revoke") {
|
||||
if (!opts.token_id_arg || opts.token_id_arg->empty()) {
|
||||
std::cerr << "vbs tokens revoke: --token-id is required\n";
|
||||
return 2;
|
||||
}
|
||||
auto revoked = Package::revoke_token(registry_url, *opts.token_id_arg, auth);
|
||||
if (!revoked) {
|
||||
std::cerr << "vbs tokens revoke: " << revoked.error().message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
std::cout << "revoked " << *opts.token_id_arg << '\n';
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto tokens = Package::fetch_tokens(registry_url, auth);
|
||||
if (!tokens) {
|
||||
std::cerr << "vbs tokens: " << tokens.error().message() << '\n';
|
||||
@@ -2582,13 +2598,19 @@ int main(int argc, char **argv) {
|
||||
add_log_flags(publish_binary_cmd, false); // `-v` is `--version` on publish-binary.
|
||||
|
||||
auto &tokens_cmd = root.subcommand("tokens", "Inspect API tokens in a package registry");
|
||||
auto configure_tokens = [&](Void::Argparse::Parser &parser) {
|
||||
parser
|
||||
.option("--registry", "-r", "Registry base URL (or VBS_REGISTRY_URL)",
|
||||
tokens_opts.registry_arg)
|
||||
.option_default("--token-env", "", "Environment variable holding bearer token",
|
||||
tokens_opts.token_env, "VBS_REGISTRY_TOKEN");
|
||||
add_log_flags(parser);
|
||||
};
|
||||
auto &tokens_list_cmd = tokens_cmd.subcommand("list", "List token metadata");
|
||||
tokens_list_cmd
|
||||
.option("--registry", "-r", "Registry base URL (or VBS_REGISTRY_URL)",
|
||||
tokens_opts.registry_arg)
|
||||
.option_default("--token-env", "", "Environment variable holding bearer token",
|
||||
tokens_opts.token_env, "VBS_REGISTRY_TOKEN");
|
||||
add_log_flags(tokens_list_cmd);
|
||||
configure_tokens(tokens_list_cmd);
|
||||
auto &tokens_revoke_cmd = tokens_cmd.subcommand("revoke", "Revoke an API token");
|
||||
configure_tokens(tokens_revoke_cmd);
|
||||
tokens_revoke_cmd.option("--token-id", "", "Token id to revoke", tokens_opts.token_id_arg);
|
||||
|
||||
auto &releases_cmd =
|
||||
root.subcommand("releases", "List published releases in a package registry");
|
||||
@@ -3008,7 +3030,7 @@ int main(int argc, char **argv) {
|
||||
return execute_releases_list_command(releases_opts);
|
||||
}
|
||||
if (cmd == "tokens") {
|
||||
return execute_tokens_list_command(tokens_opts);
|
||||
return execute_tokens_command(parsed.matched_command_path.at(1), tokens_opts);
|
||||
}
|
||||
if (cmd == "bridge") {
|
||||
return execute_bridge_command(bridge_opts);
|
||||
|
||||
@@ -742,6 +742,33 @@ fetch_tokens(std::string_view registry_url, const RegistryAuth &auth) {
|
||||
return tokens;
|
||||
}
|
||||
|
||||
Void::Result::Result<void, Void::Result::Error>
|
||||
revoke_token(std::string_view registry_url, std::string_view token_id,
|
||||
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/tokens/" + Void::Encoding::Url::encode(token_id);
|
||||
auto reply = send_http_request(*parsed_url, "DELETE", path, headers, {});
|
||||
if (!reply) {
|
||||
return std::unexpected{reply.error()};
|
||||
}
|
||||
if (reply->status != 200) {
|
||||
return std::unexpected{make_error(
|
||||
reply->status == 404 ? Void::System::SystemErrorCode::not_found
|
||||
: reply->status == 401 || reply->status == 403
|
||||
? Void::System::SystemErrorCode::permission_denied
|
||||
: Void::System::SystemErrorCode::io_error,
|
||||
std::format("registry DELETE {} failed with HTTP {}", path, reply->status))};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -51,7 +51,8 @@ check_process(0 "Usage: vbs binaries <command>.*Commands:.*list.*fetch" "" binar
|
||||
check_process(0 "Usage: vbs binaries list " "" binaries list --help)
|
||||
check_process(0 "Usage: vbs releases list " "" releases list --help)
|
||||
check_process(0 "Usage: vbs tokens list " "" tokens list --help)
|
||||
check_process(2 "" "vbs tokens list: --registry is required" tokens list)
|
||||
check_process(2 "" "vbs tokens: --registry is required" tokens list)
|
||||
check_process(0 "Usage: vbs tokens revoke .*--token-id" "" tokens revoke --help)
|
||||
check_process(2 "" "--registry and --name are required" releases list)
|
||||
check_process(0 "Usage: vbs releases show " "" releases show --help)
|
||||
check_process(2 "" "--registry, --name, and --version are required" releases show)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <Void/Build/Daemon/Daemon.hpp>
|
||||
#include <Void/Build/Package/Lockfile.hpp>
|
||||
#include <Void/Build/Platform/Host.hpp>
|
||||
#include <Void/Build/Util/Json.hpp>
|
||||
#include <Void/Data/StrictJson.hpp>
|
||||
@@ -455,6 +456,23 @@ void build(Void::Build::Project &project) {
|
||||
Void::Testing::expect(str_field(*invalid_offline, "error").find("boolean") !=
|
||||
std::string::npos);
|
||||
|
||||
auto update_deps =
|
||||
request_object(socket, R"({"op":"deps","update":true})", std::chrono::seconds{120});
|
||||
Void::Testing::require(update_deps.has_value());
|
||||
Void::Testing::expect(bool_field(*update_deps, "ok"));
|
||||
const auto *update_entries = field(*update_deps, "entries");
|
||||
Void::Testing::require(update_entries != nullptr);
|
||||
const auto *update_array = std::get_if<JsonValue::Array>(&update_entries->value);
|
||||
Void::Testing::require(update_array != nullptr && !update_array->empty());
|
||||
const auto *update_first = std::get_if<JsonObject>(&update_array->front().value);
|
||||
Void::Testing::require(update_first != nullptr);
|
||||
Void::Testing::expect_eq(str_field(*update_first, "alias"), std::string{"helper"});
|
||||
|
||||
auto invalid_update = request_object(socket, R"({"op":"deps","update":"yes"})");
|
||||
Void::Testing::require(invalid_update.has_value());
|
||||
Void::Testing::expect(!bool_field(*invalid_update, "ok", true));
|
||||
Void::Testing::expect(str_field(*invalid_update, "error").find("boolean") != std::string::npos);
|
||||
|
||||
auto build = request_object(socket, R"({"op":"build"})", std::chrono::seconds{120});
|
||||
Void::Testing::require(build.has_value());
|
||||
Void::Testing::expect(bool_field(*build, "ok"));
|
||||
@@ -517,6 +535,159 @@ void build(Void::Build::Project &project) {
|
||||
Void::Testing::expect(run_result.has_value());
|
||||
}
|
||||
|
||||
VOID_TEST(Daemon, deps_update_flag_is_validated_and_accepted) {
|
||||
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
|
||||
Void::Testing::require(temp.has_value());
|
||||
const auto options = make_options(temp->path());
|
||||
|
||||
{
|
||||
std::ofstream descriptor{options.project_root / "build.cpp"};
|
||||
descriptor << R"cpp(#include <Void/Build.hpp>
|
||||
|
||||
void build(Void::Build::Project &project) {
|
||||
auto app = project.executable("app");
|
||||
app.sources({"main.cpp"});
|
||||
}
|
||||
)cpp";
|
||||
Void::Testing::require(descriptor.good());
|
||||
}
|
||||
{
|
||||
std::ofstream source{options.project_root / "main.cpp"};
|
||||
source << "int main() { return 0; }\n";
|
||||
Void::Testing::require(source.good());
|
||||
}
|
||||
|
||||
auto server = Void::Build::Daemon::DaemonServer::create(options);
|
||||
Void::Testing::require(server.has_value());
|
||||
const auto socket = server->socket_path();
|
||||
|
||||
Void::Result::Result<void, Void::Result::Error> run_result;
|
||||
std::jthread worker{[&] { run_result = server->run(); }};
|
||||
Void::Testing::require(wait_for_path(socket, std::chrono::seconds{5}));
|
||||
|
||||
auto default_deps = request_object(socket, R"({"op":"deps"})", std::chrono::seconds{120});
|
||||
Void::Testing::require(default_deps.has_value());
|
||||
Void::Testing::expect(bool_field(*default_deps, "ok"));
|
||||
const auto *default_entries = field(*default_deps, "entries");
|
||||
Void::Testing::require(default_entries != nullptr);
|
||||
const auto *default_array = std::get_if<JsonValue::Array>(&default_entries->value);
|
||||
Void::Testing::require(default_array != nullptr && default_array->empty());
|
||||
|
||||
auto update_deps =
|
||||
request_object(socket, R"({"op":"deps","update":true})", std::chrono::seconds{120});
|
||||
Void::Testing::require(update_deps.has_value());
|
||||
Void::Testing::expect(bool_field(*update_deps, "ok"));
|
||||
const auto *update_entries = field(*update_deps, "entries");
|
||||
Void::Testing::require(update_entries != nullptr);
|
||||
const auto *update_array = std::get_if<JsonValue::Array>(&update_entries->value);
|
||||
Void::Testing::require(update_array != nullptr && update_array->empty());
|
||||
|
||||
auto invalid_update = request_object(socket, R"({"op":"deps","update":"yes"})");
|
||||
Void::Testing::require(invalid_update.has_value());
|
||||
Void::Testing::expect(!bool_field(*invalid_update, "ok", true));
|
||||
Void::Testing::expect(
|
||||
str_field(*invalid_update, "error").find("\"update\" must be a boolean") !=
|
||||
std::string::npos);
|
||||
|
||||
auto shutdown = Void::Build::Daemon::request(socket, R"({"op":"shutdown"})");
|
||||
Void::Testing::expect(shutdown.has_value());
|
||||
worker.join();
|
||||
Void::Testing::expect(run_result.has_value());
|
||||
}
|
||||
|
||||
// Proves the `update` flag reaches ResolveOptions::allow_upgrade: a pinned package that is fully
|
||||
// cached resolves offline by default, but must force a registry query when update=true.
|
||||
VOID_TEST(Daemon, deps_update_bypasses_pinned_lock_offline) {
|
||||
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
|
||||
Void::Testing::require(temp.has_value());
|
||||
const auto options = make_options(temp->path());
|
||||
|
||||
const auto write_descriptor = [&](bool with_dependency) {
|
||||
std::ofstream descriptor{options.project_root / "build.cpp"};
|
||||
descriptor << "#include <Void/Build.hpp>\n\n"
|
||||
"void build(Void::Build::Project &project) {\n";
|
||||
if (with_dependency) {
|
||||
descriptor << " project.dependency(\"remote\")\n"
|
||||
" .package(\"remote-pkg\", \"^1.0\")\n"
|
||||
" .registry(\"http://127.0.0.1:1\");\n";
|
||||
}
|
||||
descriptor << " auto app = project.executable(\"app\");\n"
|
||||
" app.sources({\"main.cpp\"});\n"
|
||||
"}\n";
|
||||
Void::Testing::require(descriptor.good());
|
||||
};
|
||||
write_descriptor(false);
|
||||
{
|
||||
std::ofstream source{options.project_root / "main.cpp"};
|
||||
source << "int main() { return 0; }\n";
|
||||
Void::Testing::require(source.good());
|
||||
}
|
||||
|
||||
auto server = Void::Build::Daemon::DaemonServer::create(options);
|
||||
Void::Testing::require(server.has_value());
|
||||
const auto socket = server->socket_path();
|
||||
|
||||
Void::Result::Result<void, Void::Result::Error> run_result;
|
||||
std::jthread worker{[&] { run_result = server->run(); }};
|
||||
Void::Testing::require(wait_for_path(socket, std::chrono::seconds{5}));
|
||||
|
||||
// Ask the daemon for the context key it uses for this profile instead of hard-coding it.
|
||||
auto baseline = request_object(socket, R"({"op":"deps"})", std::chrono::seconds{120});
|
||||
Void::Testing::require(baseline.has_value());
|
||||
Void::Testing::expect(bool_field(*baseline, "ok"));
|
||||
const std::string context_key = str_field(*baseline, "context_key");
|
||||
Void::Testing::require(!context_key.empty());
|
||||
|
||||
write_descriptor(true);
|
||||
|
||||
// Pin the package in vbs.lock and pre-populate its extracted cache entry, so offline
|
||||
// resolution can succeed without any network access while the pin is honored.
|
||||
const std::string cached_sha(64, 'a');
|
||||
const auto cached_source =
|
||||
options.build_root / ".vbs" / "cache" / "packages" / cached_sha / "src";
|
||||
std::filesystem::create_directories(cached_source);
|
||||
|
||||
Void::Build::Package::LockContextRecord record;
|
||||
record.context_key = context_key;
|
||||
record.profile_name = str_field(*baseline, "profile");
|
||||
record.machine_role = "target";
|
||||
Void::Build::Package::LockedSourceEntry entry;
|
||||
entry.alias = "remote";
|
||||
entry.source_kind = "package";
|
||||
entry.registry_authority = "http://127.0.0.1:1";
|
||||
entry.package_name = "remote-pkg";
|
||||
entry.version = "1.0.0";
|
||||
entry.sha256 = cached_sha;
|
||||
record.entries.push_back(std::move(entry));
|
||||
auto published = Void::Build::Package::publish_lock_context_cas(
|
||||
options.project_root / "vbs.lock", "", record);
|
||||
Void::Testing::require(published.has_value());
|
||||
|
||||
auto pinned =
|
||||
request_object(socket, R"({"op":"deps","offline":true})", std::chrono::seconds{120});
|
||||
Void::Testing::require(pinned.has_value());
|
||||
Void::Testing::expect(bool_field(*pinned, "ok"));
|
||||
const auto *pinned_entries = field(*pinned, "entries");
|
||||
Void::Testing::require(pinned_entries != nullptr);
|
||||
const auto *pinned_array = std::get_if<JsonValue::Array>(&pinned_entries->value);
|
||||
Void::Testing::require(pinned_array != nullptr && !pinned_array->empty());
|
||||
|
||||
// update=true discards the pinned lock, so offline resolution must now fail while trying to
|
||||
// reach the registry; success here would mean allow_upgrade was never set.
|
||||
auto upgraded = request_object(socket, R"({"op":"deps","offline":true,"update":true})",
|
||||
std::chrono::seconds{120});
|
||||
Void::Testing::require(upgraded.has_value());
|
||||
Void::Testing::expect(!bool_field(*upgraded, "ok", true));
|
||||
Void::Testing::expect(
|
||||
str_field(*upgraded, "error").find("offline mode cannot query live package registry") !=
|
||||
std::string::npos);
|
||||
|
||||
auto shutdown = Void::Build::Daemon::request(socket, R"({"op":"shutdown"})");
|
||||
Void::Testing::expect(shutdown.has_value());
|
||||
worker.join();
|
||||
Void::Testing::expect(run_result.has_value());
|
||||
}
|
||||
|
||||
VOID_TEST(Daemon, ide_query_serves_workspace_targets_and_compdb) {
|
||||
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
|
||||
Void::Testing::require(temp.has_value());
|
||||
|
||||
@@ -1331,6 +1331,53 @@ target_include_directories(hello_pkg PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
Void::Testing::expect(tokens_res->stdout_data.find(*tok) == std::string::npos);
|
||||
}
|
||||
|
||||
// Revoke a second token through the CLI and observe it in the listing.
|
||||
auto extra_token = (*svc)->create_token("ci_pub", "extra", {"read"});
|
||||
Void::Testing::require(extra_token.has_value());
|
||||
tokens_list.environment.set_vars["VBS_REGISTRY_TOKEN"] = *tok;
|
||||
auto second_list = Platform::run_supervised(tokens_list);
|
||||
Void::Testing::require(second_list.has_value() && second_list->succeeded());
|
||||
std::string extra_id;
|
||||
{
|
||||
std::size_t pos = 0;
|
||||
const std::string &out = second_list->stdout_data;
|
||||
while (pos < out.size()) {
|
||||
const auto nl = out.find('\n', pos);
|
||||
const std::string line = out.substr(pos, nl == std::string::npos ? std::string::npos : nl - pos);
|
||||
if (line.find(" extra ") != std::string::npos) {
|
||||
extra_id = line.substr(0, line.find(' '));
|
||||
}
|
||||
if (nl == std::string::npos) {
|
||||
break;
|
||||
}
|
||||
pos = nl + 1;
|
||||
}
|
||||
}
|
||||
Void::Testing::require(!extra_id.empty());
|
||||
Platform::ProcessRequest revoke_req = tokens_list;
|
||||
revoke_req.arguments = {"tokens", "revoke", "--registry", reg_url, "--token-id", extra_id};
|
||||
auto revoke_res = Platform::run_supervised(revoke_req);
|
||||
Void::Testing::expect(revoke_res.has_value() && revoke_res->succeeded());
|
||||
auto final_list = Platform::run_supervised(tokens_list);
|
||||
Void::Testing::require(final_list.has_value() && final_list->succeeded());
|
||||
bool saw_revoked = false;
|
||||
{
|
||||
std::size_t pos = 0;
|
||||
const std::string &out = final_list->stdout_data;
|
||||
while (pos < out.size()) {
|
||||
const auto nl = out.find('\n', pos);
|
||||
const std::string line = out.substr(pos, nl == std::string::npos ? std::string::npos : nl - pos);
|
||||
if (line.starts_with(extra_id) && line.find("revoked") != std::string::npos) {
|
||||
saw_revoked = true;
|
||||
}
|
||||
if (nl == std::string::npos) {
|
||||
break;
|
||||
}
|
||||
pos = nl + 1;
|
||||
}
|
||||
}
|
||||
Void::Testing::expect(saw_revoked);
|
||||
|
||||
Platform::ProcessRequest releases_list;
|
||||
releases_list.executable = vbs_bin;
|
||||
releases_list.arguments = {"releases", "list", "--registry", reg_url, "--name", "hello-pkg"};
|
||||
|
||||
Reference in new issue
Block a user