From ca9ad1158a2965cee20a87e3fadf18cd23939b59 Mon Sep 17 00:00:00 2001 From: "Aleksei (Faumaray) Selikhov" Date: Thu, 3 Dec 2026 23:27:57 +0300 Subject: [PATCH] feat(daemon): list workspace members without evaluating them --- docs/agent-workflow/STATE.md | 2 +- docs/agent-workflow/TASKS.md | 1 + docs/agent-workflow/VERIFICATION.md | 15 ++++++++++ docs/roadmap/21-expansion-roadmap.md | 2 +- src/Daemon/Daemon.cpp | 29 ++++++++++++++++++ src/Main.cpp | 10 +++++++ tests/CliContracts.cmake | 1 + tests/DaemonTests.cpp | 44 ++++++++++++++++++++++++++++ 8 files changed, 102 insertions(+), 2 deletions(-) diff --git a/docs/agent-workflow/STATE.md b/docs/agent-workflow/STATE.md index e4e7c10..dd21e69 100644 --- a/docs/agent-workflow/STATE.md +++ b/docs/agent-workflow/STATE.md @@ -173,7 +173,7 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B - Added the `compdb_entries` daemon request (`vbs daemon compdb entries [--file SUFFIX] [--limit N]`): reads the active published compilation database (selection state or root alias), returns bounded projected entries (`file`, `directory`, `output`, `command`, bounded `arguments`), reports `total`/`returned`, and errors explicitly when nothing is published. - Added `Daemon.compdb_entries_queries_published_database` (unpublished → error, then all entries, a `main.cpp` filter with `limit:1`, and an invalid limit) and a CLI help contract; Daemon suite is now 18 cases. -- **Wave 40 (Authenticated Binary-Variant Downloads)**:\n - `download_binary_artifact` now accepts `RegistryAuth` and sends the bearer token, so private registry binary artifacts can be fetched; `BinaryFetchOptions` gained `bearer_token` and `materialize_binary_variant` forwards it; `vbs binaries fetch` passes the configured token.\n - Added `RegistryTests.private_binary_variant_download_requires_auth`: anonymous download of a private binary → 401, authenticated client download and signed materialization succeed.\n\n- **Wave 41 (Yanked Binary Variants in Listing)**:\n - `fetch_binary_variants` gained `include_yanked` (default false, so selection/materialization still never sees yanked variants); `vbs binaries list` opts in and marks yanked entries while `binaries fetch` keeps the filtered view.\n - Extended the registry binary-variant test to assert the yanked variant is returned with `yanked=true` only when requested.\n\n- **Wave 42 (Registry Binary-Variant Listing Endpoint)**:\n - Added `GET /api/v1/packages///binaries` returning the release's binary variants (`variant_id`, `sha256`, `size_bytes`, `yanked`, optional signature/public key) under normal read permissions; `RegistryClient::fetch_binary_variants` now queries this endpoint directly instead of parsing package detail JSON.\n - The registry binary-variant test asserts the listing endpoint returns the published variant with `yanked:false`.\n\n## Remaining future scope +- **Wave 40 (Authenticated Binary-Variant Downloads)**:\n - `download_binary_artifact` now accepts `RegistryAuth` and sends the bearer token, so private registry binary artifacts can be fetched; `BinaryFetchOptions` gained `bearer_token` and `materialize_binary_variant` forwards it; `vbs binaries fetch` passes the configured token.\n - Added `RegistryTests.private_binary_variant_download_requires_auth`: anonymous download of a private binary → 401, authenticated client download and signed materialization succeed.\n\n- **Wave 41 (Yanked Binary Variants in Listing)**:\n - `fetch_binary_variants` gained `include_yanked` (default false, so selection/materialization still never sees yanked variants); `vbs binaries list` opts in and marks yanked entries while `binaries fetch` keeps the filtered view.\n - Extended the registry binary-variant test to assert the yanked variant is returned with `yanked=true` only when requested.\n\n- **Wave 42 (Registry Binary-Variant Listing Endpoint)**:\n - Added `GET /api/v1/packages///binaries` returning the release's binary variants (`variant_id`, `sha256`, `size_bytes`, `yanked`, optional signature/public key) under normal read permissions; `RegistryClient::fetch_binary_variants` now queries this endpoint directly instead of parsing package detail JSON.\n - The registry binary-variant test asserts the listing endpoint returns the published variant with `yanked:false`.\n\n- **Wave 43 (Workspace Members Request)**:\n - Added the `workspace_members` daemon request (`vbs daemon workspace members`): lists declared workspace members (`name`, canonical `path`) without evaluating member build descriptions; non-workspace roots return `workspace:false` with an empty list.\n - Added `Daemon.workspace_members_lists_declared_members` and a CLI help contract; Daemon suite is now 19 cases.\n\n## 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 eaaf3b2..126e383 100644 --- a/docs/agent-workflow/TASKS.md +++ b/docs/agent-workflow/TASKS.md @@ -49,4 +49,5 @@ Base HEAD: `fe0d1a6` | Wave 40 (Authenticated binary downloads) | `download_binary_artifact` bearer auth, `BinaryFetchOptions::bearer_token`, `vbs binaries fetch` token | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 7/7, full CTest 8/8) | `include/Void/Build/Package/{RegistryClient,Fetch}.hpp`, `src/Package/{RegistryClient,Fetch}.cpp`, `src/Main.cpp`, `tests/RegistryTests.cpp`, docs | | Wave 41 (Yanked binary listing) | `fetch_binary_variants(include_yanked)`, `vbs binaries list` marks yanked entries, fetch stays filtered | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 7/7, full CTest 8/8) | `include/Void/Build/Package/RegistryClient.hpp`, `src/Package/RegistryClient.cpp`, `src/Main.cpp`, `tests/RegistryTests.cpp`, docs | | Wave 42 (Registry binary listing endpoint) | `GET .../binaries` listing endpoint; client queries it directly | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 7/7, full CTest 8/8) | `registry/service/RegistryService.cpp`, `src/Package/RegistryClient.cpp`, `tests/RegistryTests.cpp`, docs | +| Wave 43 (Workspace members request) | `workspace_members` daemon request + `vbs daemon workspace members`: lightweight member listing | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 19/19, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, `tests/CliContracts.cmake`, docs | | Future (Plan 20 Slice 3 / Tracks C, 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 f0e42b8..04e7aa6 100644 --- a/docs/agent-workflow/VERIFICATION.md +++ b/docs/agent-workflow/VERIFICATION.md @@ -730,6 +730,21 @@ dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure - Full CTest: **8 / 8 passed** in 221.10 s. - `clang-format --dry-run --Werror` passes on the changed C++ files. +## Workspace Members Request (GCC 16.2, pin `0002e74`) + +```sh +dev cpp-gcc -c cmake --build build/pinned --parallel 8 +dev cpp-gcc -c build/pinned/bin/vbs_v1_tests --suite Daemon --no-color +dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure +``` + +- Build: exit 0. Daemon suite: **19 / 19 passed** in 39.02 s, including + `workspace_members_lists_declared_members`: a two-member `workspace.cpp` returns + `workspace:true` with `lib`/`app` names and canonical member paths, without evaluating member + build descriptions. +- Full CTest: **8 / 8 passed** in 222.06 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 bbf8f5f..4cb4e75 100644 --- a/docs/roadmap/21-expansion-roadmap.md +++ b/docs/roadmap/21-expansion-roadmap.md @@ -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 ` / `--changed-since `). | 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, and `vbs daemon compdb entries` serves bounded per-file compile arguments to editor extensions. 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 compdb entries` serves bounded per-file compile arguments to editor extensions, and `vbs daemon workspace members` lists workspace members cheaply. 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** | 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. | All `vbs_registry_tests` and `vbs_core_tests` pass on both minimal and full toolchains. | --- diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp index 059e5b4..5a33964 100644 --- a/src/Daemon/Daemon.cpp +++ b/src/Daemon/Daemon.cpp @@ -950,6 +950,32 @@ std::string graph_project(const DaemonOptions &options, std::string_view profile ",\"graph\":" + Util::json_quote(rendered) + '}'; } +// Lists declared workspace members without evaluating their build descriptions. +std::string workspace_members_project(const DaemonOptions &options) { + JsonValue::Object object; + object.emplace("ok", JsonValue{true}); + object.emplace("op", JsonValue{std::string{"workspace_members"}}); + if (!Config::is_workspace_root(options.project_root)) { + object.emplace("workspace", JsonValue{false}); + object.emplace("members", JsonValue{JsonValue::Array{}}); + return serialize_response(JsonValue{std::move(object)}); + } + auto members = evaluate_workspace_members(options); + if (!members) { + return error_response(members.error()); + } + JsonValue::Array member_array; + for (const auto &member : *members) { + JsonValue::Object entry; + entry.emplace("name", JsonValue{member.name}); + entry.emplace("path", JsonValue{member.path.string()}); + member_array.emplace_back(std::move(entry)); + } + object.emplace("workspace", JsonValue{true}); + object.emplace("members", JsonValue{std::move(member_array)}); + return serialize_response(JsonValue{std::move(object)}); +} + // Returns bounded compile_commands entries from the active compilation database, optionally // filtered by a path suffix. Editor extensions use this instead of parsing the file themselves. std::string compdb_entries_project(const DaemonOptions &options, std::string_view file_filter, @@ -1439,6 +1465,9 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view if (*name == "editor_status") { return {editor_status_project(options), false}; } + if (*name == "workspace_members") { + return {workspace_members_project(options), false}; + } if (*name == "compdb_entries") { std::string file_filter; if (const auto entry = object->find("file"); entry != object->end()) { diff --git a/src/Main.cpp b/src/Main.cpp index 69c849a..aa06611 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1565,6 +1565,8 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) { Util::json_quote(opts.graph_format_arg)); } else if (sub == "editor_status") { request_json = R"({"op":"editor_status"})"; + } else if (sub == "workspace_members") { + request_json = R"({"op":"workspace_members"})"; } else if (sub == "compdb_entries") { request_json = std::format(R"({{"op":"compdb_entries","limit":{}{}}})", opts.limit_arg, @@ -2662,6 +2664,11 @@ int main(int argc, char **argv) { .option_default("--profile", "-p", "Profile to export", daemon_opts.profile_arg, "debug") .option("--member", "", "Workspace member (required for workspace roots)", daemon_opts.member_arg); + auto &daemon_workspace_cmd = + daemon_cmd.subcommand("workspace", "Workspace metadata served by the daemon"); + auto &daemon_workspace_members_cmd = + daemon_workspace_cmd.subcommand("members", "List declared workspace members"); + configure_daemon_common(daemon_workspace_members_cmd); auto &daemon_graph_cmd = daemon_cmd.subcommand("graph", "Export the target dependency graph via the daemon"); configure_daemon_common(daemon_graph_cmd); @@ -2821,6 +2828,9 @@ int main(int argc, char **argv) { } else if (daemon_sub == "compdb" && parsed.matched_command_path.size() > 2 && parsed.matched_command_path[2] == "use") { daemon_sub = "compdb_use"; + } else if (daemon_sub == "workspace" && parsed.matched_command_path.size() > 2 && + parsed.matched_command_path[2] == "members") { + daemon_sub = "workspace_members"; } return execute_daemon_command(daemon_sub, daemon_opts); } diff --git a/tests/CliContracts.cmake b/tests/CliContracts.cmake index 5b71282..2e1ca9f 100644 --- a/tests/CliContracts.cmake +++ b/tests/CliContracts.cmake @@ -65,6 +65,7 @@ check_process(0 "Usage: vbs daemon ide poll " "" daemon ide poll --help) check_process(0 "Usage: vbs daemon ide status " "" daemon ide status --help) check_process(0 "Usage: vbs daemon graph .*--format" "" daemon graph --help) check_process(0 "Usage: vbs daemon test .*--profile.*--target.*--jobs" "" daemon test --help) +check_process(0 "Usage: vbs daemon workspace members " "" daemon workspace members --help) check_process(0 "Usage: vbs daemon ide wait .*--timeout-ms" "" daemon ide wait --help) check_process(2 "" "missing subcommand for 'vbs daemon'" daemon) diff --git a/tests/DaemonTests.cpp b/tests/DaemonTests.cpp index 215b39e..c414396 100644 --- a/tests/DaemonTests.cpp +++ b/tests/DaemonTests.cpp @@ -977,6 +977,50 @@ void build(Void::Build::Project &project) { Void::Testing::expect(run_result.has_value()); } +VOID_TEST(Daemon, workspace_members_lists_declared_members) { + auto temp = Void::FileSystem::TempDir::open("vbs_daemon_"); + Void::Testing::require(temp.has_value()); + const auto options = make_options(temp->path()); + + { + std::ofstream workspace{options.project_root / "workspace.cpp"}; + workspace << "#include \n" + "void workspace(Void::Build::Workspace &workspace) {\n" + " workspace.member(\"lib\", \"packages/lib\");\n" + " workspace.member(\"app\", \"packages/app\");\n" + "}\n"; + Void::Testing::require(workspace.good()); + } + std::filesystem::create_directories(options.project_root / "packages" / "lib"); + std::filesystem::create_directories(options.project_root / "packages" / "app"); + + auto server = Void::Build::Daemon::DaemonServer::create(options); + Void::Testing::require(server.has_value()); + const auto socket = server->socket_path(); + + Void::Result::Result run_result; + std::jthread worker{[&] { run_result = server->run(); }}; + Void::Testing::require(wait_for_path(socket, std::chrono::seconds{5})); + + auto raw = Void::Build::Daemon::request(socket, R"({"op":"workspace_members"})", + std::chrono::seconds{120}); + 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::Testing::require(raw.has_value()); + const auto parsed = parse_json(*raw); + Void::Testing::require(parsed.has_value()); + const auto *object = as_object(*parsed); + Void::Testing::require(object != nullptr); + Void::Testing::expect(bool_field(*object, "ok")); + Void::Testing::expect(bool_field(*object, "workspace")); + Void::Testing::expect(raw->find("\"name\":\"lib\"") != std::string::npos); + Void::Testing::expect(raw->find("\"name\":\"app\"") != std::string::npos); + Void::Testing::expect(raw->find("packages/lib") != std::string::npos); +} + VOID_TEST(Daemon, describe_empty_project_reports_zero_targets) { auto temp = Void::FileSystem::TempDir::open("vbs_daemon_"); Void::Testing::require(temp.has_value());