From cf06b427b75a9658d152a7aea70fa0366d050453 Mon Sep 17 00:00:00 2001 From: "Aleksei (Faumaray) Selikhov" Date: Fri, 4 Dec 2026 02:10:53 +0300 Subject: [PATCH] feat(daemon): clean generated build outputs on request --- CMakeLists.txt | 1 + build.cpp | 1 + docs/agent-workflow/STATE.md | 2 +- docs/agent-workflow/TASKS.md | 1 + docs/agent-workflow/VERIFICATION.md | 14 ++++++ docs/roadmap/21-expansion-roadmap.md | 2 +- include/Void/Build/Config/BuildTree.hpp | 24 ++++++++++ recipes/SelfHost/VbsSelfHostRecipe.cpp | 1 + src/Config/BuildTree.cpp | 58 +++++++++++++++++++++++++ src/Daemon/Daemon.cpp | 24 ++++++++++ src/Main.cpp | 39 +++++++---------- tests/CliContracts.cmake | 1 + tests/DaemonTests.cpp | 55 +++++++++++++++++++++++ 13 files changed, 198 insertions(+), 25 deletions(-) create mode 100644 include/Void/Build/Config/BuildTree.hpp create mode 100644 src/Config/BuildTree.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index e9966f1..8172aa8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,7 @@ add_library(VoidBuild_Core STATIC src/State/RemoteCache.cpp src/Graph/Graph.cpp src/Execution/Scheduler.cpp + src/Config/BuildTree.cpp src/Config/Frontend.cpp src/Daemon/Daemon.cpp src/Editor/CompDb.cpp diff --git a/build.cpp b/build.cpp index 99eadd5..2e31909 100644 --- a/build.cpp +++ b/build.cpp @@ -32,6 +32,7 @@ void build(Void::Build::Project &project) { "src/State/RemoteCache.cpp", "src/Graph/Graph.cpp", "src/Execution/Scheduler.cpp", + "src/Config/BuildTree.cpp", "src/Config/Frontend.cpp", "src/Daemon/Daemon.cpp", "src/Editor/CompDb.cpp", diff --git a/docs/agent-workflow/STATE.md b/docs/agent-workflow/STATE.md index 76e7975..762f2cd 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- **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- **Wave 44 (IDE Configs Request)**:\n - Added the `ide_configs` daemon request (`vbs daemon ide configs`): reports presence of `.clangd`, `.vscode/tasks.json`, `.zed/tasks.json`, and `.idea/customTargets.xml` so editor extensions can see what is configured.\n - Added `Daemon.ide_configs_reports_generated_files` (absent before generation, present after `ide_generate`) and a CLI help contract; Daemon suite is now 20 cases.\n\n- **Wave 45 (Compdb Generations Request)**:\n - Added the `compdb_generations` daemon request (`vbs daemon compdb generations --profile`): lists immutable editor generations (bounded 128) with active flag, per-generation entry counts, and the per-profile status/diagnostic record; profile names are validated against `[A-Za-z0-9._-]` to prevent traversal.\n - Added `Daemon.compdb_generations_lists_history_and_active_generation` (empty before export, then a valid generation with entries and an active selection; invalid profile rejected) and a CLI help contract; Daemon suite is now 21 cases.\n\n- **Wave 46 (Registry Package Search Pagination)**:\n - `GET /api/v1/packages` now supports bounded `limit` (0-500, default 100) and `offset` (0-1,000,000) pagination with a `total`/`limit`/`offset` envelope; malformed values return 400.\n - The registry RBAC test asserts a `limit=1` page contains exactly one package and that `limit=501` is rejected.\n\n- **Wave 47 (Registry Release Detail Endpoint)**:\n - Added `GET /api/v1/packages//` returning release metadata (digest, size, yank state, publisher/epoch, optional signature/public key, binary variant summaries) under normal read permissions; unknown packages/releases return 404.\n - The registry binary-variant test asserts the release detail includes the version and published binary variant, and that an unknown version returns 404.\n\n- **Wave 48 (Daemon Deps Request)**:\n - Added the `deps` daemon request (`vbs daemon deps [--profile] [--member]`): evaluates the project, merges TOML/declared dependencies, resolves and materializes them with the pinned lock, registry environment, and trusted keys, then returns the lock context key and per-entry metadata (`alias`, `source_kind`, `package_name`, `version`, `sha256`, `signed`). Shared dependency-merge and resolve-option helpers were extracted for reuse by the build path.\n - Extended `Daemon.build_materializes_path_dependency` to assert a `deps` response with the `helper` path entry before building, plus a CLI help contract.\n\n- **Wave 49 (Daemon Info Request)**:\n - Added the `info` daemon request (`vbs daemon info`): reports the daemon version, host OS/architecture, project/build/lock roots, and socket path so editor extensions can discover the environment without guessing.\n - Added `Daemon.info_reports_daemon_paths_and_host` and a CLI help contract; Daemon suite is now 22 cases.\n\n- **Wave 50 (Registry Audit Query Filters)**:\n - `GET /api/v1/audit` now supports `actor`, `action` (substring), `outcome`, `limit` (0–2000, default 100) and `offset` filters with a `total`/`limit`/`offset` envelope; malformed limits return 400.\n - The registry RBAC test asserts the audit envelope and an action-filtered `limit=1` page contains a single entry.\n\n- **Wave 51 (Track E4 `Void::Sqlite` Alignment for the StateStore)**:\n - When built with SQLite3 (`VBS_HAS_VOID_SQLITE`, now available via `dev cpp-gcc -p sqlite`), `StateStore` keeps its transactional action cache in `state/state.v2.sqlite` using `Void::Sqlite` (`meta`, `actions`, `generations` tables, one transaction per publication) and imports an existing `state.v1.json` once. Without SQLite the journaled atomic JSON store remains unchanged.\n - `Void::Net` alignment is still pending: it requires OpenSSL, while only Boost is provided by `-p boost`.\n\n- **Wave 52 (Live Conan2 Verification)**:\n - `conan` 2.32.0 is available via `dev cpp-gcc -p conan`. Added `FullV1Tests.track_b3_live_conan_provider_install`: it builds a real local header-only package with `conan create` in an isolated `CONAN_HOME` (restored afterwards), then runs the Conan2 provider so a real `conan install` executes (verified by the generated `conanbuild.sh`). Skips when `conan` is absent.\n\n- **Wave 53 (Track E4 `Void::Net` Alignment for the Registry Client)**:\n - `cmake/VoidDependency.cmake` now enables the `Net` module when Boost (url; beast/asio are synthesized), OpenSSL and Threads are found (`VBS_HAS_VOID_NET`), and `VoidBuild_Core` links `Void::Net` with `VBS_HAS_VOID_NET=1`.\n - `RegistryClient`'s HTTP transport uses `Void::Net::HttpClient::secure()` (TLS-verifying) for every registry request when `VBS_HAS_VOID_NET` is defined, keeping the pure-POSIX/curl fallback otherwise. All registry client tests pass on the Net transport.\n\n- **Wave 54 (Track E4 `Void::Net` Registry HTTP Server)**:\n - `Registry::HttpServer` now serves through `Void::Net::HttpServer` when `VBS_HAS_VOID_NET` is defined: a catch-all route per HTTP method bridges `Void::Net::ServerRequest`/`ServerResponse` to the registry's transport-neutral `HttpRequest`/`HttpResponse` (method, path, query, lowercase headers, cookies, body, `Set-Cookie`). The default security headers were extracted into one helper applied by both transports. The POSIX server remains the fallback.\n - Registry suite passes on both transports (7/7 each); full CTest with Net enabled passes 8/8.\n\n- **Wave 55 (Track E4 `Void::Net` Remote Cache Transport)**:\n - `RemoteCache`'s HTTP exchange now uses `Void::Net::HttpClient::secure()` for the shared action cache (blob/action GET/PUT/HEAD) when `VBS_HAS_VOID_NET` is defined, keeping the POSIX/curl fallback otherwise.\n - Remote CAS tests pass on both transports (`shared_remote_action_cache_blob_and_record_roundtrip`, `shared_remote_cache_cold_populates_then_clean_build_all_hits`).\n\n- **Wave 56 (Track C1 Host Reporting in `vbs doctor`)**:\n - `vbs doctor` now reports the host platform through the `Platform::HostOs`/`host_supported()` abstraction (the first consumer of `Host.hpp`) and whether the optional `Void::Sqlite` and `Void::Net` backends are compiled in, making the Track C/E4 portability state visible without guessing.\n - Added CLI contract checks for the host and backend lines.\n\n## Remaining future scope"}"}"}, {"oldString": "Track E4 (the `Void::Net` registry-client transport and `Void::Sqlite` StateStore are adopted; further Net surfaces such as the registry HTTP server remain planned scope).", "newString": "Track E4 (`Void::Net` now backs both the registry client transport and the registry HTTP server when enabled, and `Void::Sqlite` backs the StateStore; the POSIX fallbacks remain for minimal toolchains)."}]"}, {"oldString": "Track E4 (`Void::Net` alignment; `Void::Sqlite` is now used by the StateStore when SQLite3 is available) remain planned scope.", "newString": "Track E4 (the `Void::Net` registry-client transport and `Void::Sqlite` StateStore are adopted; further Net surfaces such as the registry HTTP server remain planned scope)."}, {"oldString": "Live `conan` CLI verification (Track B3), Track C", "newString": "Track C"}"}, {"oldString": "Track E4 (`Void::Net`/`Void::Sqlite` alignment) remain planned scope.", "newString": "Track E4 (`Void::Net` alignment; `Void::Sqlite` is now used by the StateStore when SQLite3 is available) remain planned 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- **Wave 44 (IDE Configs Request)**:\n - Added the `ide_configs` daemon request (`vbs daemon ide configs`): reports presence of `.clangd`, `.vscode/tasks.json`, `.zed/tasks.json`, and `.idea/customTargets.xml` so editor extensions can see what is configured.\n - Added `Daemon.ide_configs_reports_generated_files` (absent before generation, present after `ide_generate`) and a CLI help contract; Daemon suite is now 20 cases.\n\n- **Wave 45 (Compdb Generations Request)**:\n - Added the `compdb_generations` daemon request (`vbs daemon compdb generations --profile`): lists immutable editor generations (bounded 128) with active flag, per-generation entry counts, and the per-profile status/diagnostic record; profile names are validated against `[A-Za-z0-9._-]` to prevent traversal.\n - Added `Daemon.compdb_generations_lists_history_and_active_generation` (empty before export, then a valid generation with entries and an active selection; invalid profile rejected) and a CLI help contract; Daemon suite is now 21 cases.\n\n- **Wave 46 (Registry Package Search Pagination)**:\n - `GET /api/v1/packages` now supports bounded `limit` (0-500, default 100) and `offset` (0-1,000,000) pagination with a `total`/`limit`/`offset` envelope; malformed values return 400.\n - The registry RBAC test asserts a `limit=1` page contains exactly one package and that `limit=501` is rejected.\n\n- **Wave 47 (Registry Release Detail Endpoint)**:\n - Added `GET /api/v1/packages//` returning release metadata (digest, size, yank state, publisher/epoch, optional signature/public key, binary variant summaries) under normal read permissions; unknown packages/releases return 404.\n - The registry binary-variant test asserts the release detail includes the version and published binary variant, and that an unknown version returns 404.\n\n- **Wave 48 (Daemon Deps Request)**:\n - Added the `deps` daemon request (`vbs daemon deps [--profile] [--member]`): evaluates the project, merges TOML/declared dependencies, resolves and materializes them with the pinned lock, registry environment, and trusted keys, then returns the lock context key and per-entry metadata (`alias`, `source_kind`, `package_name`, `version`, `sha256`, `signed`). Shared dependency-merge and resolve-option helpers were extracted for reuse by the build path.\n - Extended `Daemon.build_materializes_path_dependency` to assert a `deps` response with the `helper` path entry before building, plus a CLI help contract.\n\n- **Wave 49 (Daemon Info Request)**:\n - Added the `info` daemon request (`vbs daemon info`): reports the daemon version, host OS/architecture, project/build/lock roots, and socket path so editor extensions can discover the environment without guessing.\n - Added `Daemon.info_reports_daemon_paths_and_host` and a CLI help contract; Daemon suite is now 22 cases.\n\n- **Wave 50 (Registry Audit Query Filters)**:\n - `GET /api/v1/audit` now supports `actor`, `action` (substring), `outcome`, `limit` (0–2000, default 100) and `offset` filters with a `total`/`limit`/`offset` envelope; malformed limits return 400.\n - The registry RBAC test asserts the audit envelope and an action-filtered `limit=1` page contains a single entry.\n\n- **Wave 51 (Track E4 `Void::Sqlite` Alignment for the StateStore)**:\n - When built with SQLite3 (`VBS_HAS_VOID_SQLITE`, now available via `dev cpp-gcc -p sqlite`), `StateStore` keeps its transactional action cache in `state/state.v2.sqlite` using `Void::Sqlite` (`meta`, `actions`, `generations` tables, one transaction per publication) and imports an existing `state.v1.json` once. Without SQLite the journaled atomic JSON store remains unchanged.\n - `Void::Net` alignment is still pending: it requires OpenSSL, while only Boost is provided by `-p boost`.\n\n- **Wave 52 (Live Conan2 Verification)**:\n - `conan` 2.32.0 is available via `dev cpp-gcc -p conan`. Added `FullV1Tests.track_b3_live_conan_provider_install`: it builds a real local header-only package with `conan create` in an isolated `CONAN_HOME` (restored afterwards), then runs the Conan2 provider so a real `conan install` executes (verified by the generated `conanbuild.sh`). Skips when `conan` is absent.\n\n- **Wave 53 (Track E4 `Void::Net` Alignment for the Registry Client)**:\n - `cmake/VoidDependency.cmake` now enables the `Net` module when Boost (url; beast/asio are synthesized), OpenSSL and Threads are found (`VBS_HAS_VOID_NET`), and `VoidBuild_Core` links `Void::Net` with `VBS_HAS_VOID_NET=1`.\n - `RegistryClient`'s HTTP transport uses `Void::Net::HttpClient::secure()` (TLS-verifying) for every registry request when `VBS_HAS_VOID_NET` is defined, keeping the pure-POSIX/curl fallback otherwise. All registry client tests pass on the Net transport.\n\n- **Wave 54 (Track E4 `Void::Net` Registry HTTP Server)**:\n - `Registry::HttpServer` now serves through `Void::Net::HttpServer` when `VBS_HAS_VOID_NET` is defined: a catch-all route per HTTP method bridges `Void::Net::ServerRequest`/`ServerResponse` to the registry's transport-neutral `HttpRequest`/`HttpResponse` (method, path, query, lowercase headers, cookies, body, `Set-Cookie`). The default security headers were extracted into one helper applied by both transports. The POSIX server remains the fallback.\n - Registry suite passes on both transports (7/7 each); full CTest with Net enabled passes 8/8.\n\n- **Wave 55 (Track E4 `Void::Net` Remote Cache Transport)**:\n - `RemoteCache`'s HTTP exchange now uses `Void::Net::HttpClient::secure()` for the shared action cache (blob/action GET/PUT/HEAD) when `VBS_HAS_VOID_NET` is defined, keeping the POSIX/curl fallback otherwise.\n - Remote CAS tests pass on both transports (`shared_remote_action_cache_blob_and_record_roundtrip`, `shared_remote_cache_cold_populates_then_clean_build_all_hits`).\n\n- **Wave 56 (Track C1 Host Reporting in `vbs doctor`)**:\n - `vbs doctor` now reports the host platform through the `Platform::HostOs`/`host_supported()` abstraction (the first consumer of `Host.hpp`) and whether the optional `Void::Sqlite` and `Void::Net` backends are compiled in, making the Track C/E4 portability state visible without guessing.\n - Added CLI contract checks for the host and backend lines.\n\n- **Wave 57 (Daemon Clean Request)**:\n - Extracted build-tree cleaning into `Config::clean_build_tree` (`include/Void/Build/Config/BuildTree.hpp`, `src/Config/BuildTree.cpp`) returning a structured `CleanReport`; the CLI `vbs clean` is now a thin adapter.\n - Added the `clean` daemon request (`vbs daemon clean [--all]`): removes `profiles/` and the root compdb alias (or the whole build root with `--all`) and returns `existed`/`removed_all`/`removed_paths`. Added `Daemon.clean_removes_profile_outputs_and_preserves_cache` (build, clean, profiles gone while `.vbs` remains, invalid `all` rejected) and a CLI help contract; Daemon suite is now 23 cases.\n\n## Remaining future scope"}"}"}"}, {"oldString": "Track E4 (the `Void::Net` registry-client transport and `Void::Sqlite` StateStore are adopted; further Net surfaces such as the registry HTTP server remain planned scope).", "newString": "Track E4 (`Void::Net` now backs both the registry client transport and the registry HTTP server when enabled, and `Void::Sqlite` backs the StateStore; the POSIX fallbacks remain for minimal toolchains)."}]"}, {"oldString": "Track E4 (`Void::Net` alignment; `Void::Sqlite` is now used by the StateStore when SQLite3 is available) remain planned scope.", "newString": "Track E4 (the `Void::Net` registry-client transport and `Void::Sqlite` StateStore are adopted; further Net surfaces such as the registry HTTP server remain planned scope)."}, {"oldString": "Live `conan` CLI verification (Track B3), Track C", "newString": "Track C"}"}, {"oldString": "Track E4 (`Void::Net`/`Void::Sqlite` alignment) remain planned scope.", "newString": "Track E4 (`Void::Net` alignment; `Void::Sqlite` is now used by the StateStore when SQLite3 is available) remain planned 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 7424469..66ce6a3 100644 --- a/docs/agent-workflow/TASKS.md +++ b/docs/agent-workflow/TASKS.md @@ -61,4 +61,5 @@ Base HEAD: `fe0d1a6` | Wave 53 (Track E4 Net alignment) | Enable `Void::Net` when Boost/OpenSSL/Threads are found; `RegistryClient` HTTP transport on `Void::Net::HttpClient::secure()` with POSIX/curl fallback | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`, `-p openssl -p boost`: registry 7/7 and full CTest 8/8 on the Net transport; default build unaffected) | `cmake/VoidDependency.cmake`, `CMakeLists.txt`, `src/Package/RegistryClient.cpp`, docs | | Wave 54 (Track E4 Net server) | `Registry::HttpServer` on `Void::Net::HttpServer` behind `VBS_HAS_VOID_NET` with a request/response bridge and shared security headers; POSIX fallback retained | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`, `-p openssl -p boost`: registry 7/7 and full CTest 8/8 on Net; default registry 7/7) | `registry/service/HttpServer.cpp`, `registry/include/Void/Build/Registry/HttpServer.hpp`, docs |\n| Wave 55 (Track E4 Net remote cache) | `RemoteCache` HTTP exchange on `Void::Net::HttpClient::secure()` behind `VBS_HAS_VOID_NET`; POSIX/curl fallback | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; remote CAS 2/2 on both transports, Net full CTest 8/8) | `src/State/RemoteCache.cpp`, docs | | Wave 56 (Host reporting in doctor) | `vbs doctor` reports `HostOs`/`host_supported()` and the optional Sqlite/Net backends; CLI contracts added | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; CLI contract passed, full CTest 8/8) | `src/Main.cpp`, `tests/CliContracts.cmake`, docs | +| Wave 57 (Daemon clean request) | `Config::clean_build_tree` extraction; `clean` daemon request + `vbs daemon clean [--all]` returning a structured report | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 23/23, full CTest 8/8) | `include/Void/Build/Config/BuildTree.hpp`, `src/Config/BuildTree.cpp`, `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, `tests/CliContracts.cmake`, build lists, 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) | diff --git a/docs/agent-workflow/VERIFICATION.md b/docs/agent-workflow/VERIFICATION.md index e569ec4..7a3ced3 100644 --- a/docs/agent-workflow/VERIFICATION.md +++ b/docs/agent-workflow/VERIFICATION.md @@ -931,6 +931,20 @@ dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure - `vbs_cli_contract` (with the new host/backend checks): **passed** (8.54 s). - Full CTest: **8 / 8 passed** in 235.19 s. +## Daemon Clean 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: **23 / 23 passed** in 46.72 s, including + `clean_removes_profile_outputs_and_preserves_cache`: after a build, `clean` removes + `profiles/` (`removed_paths >= 1`) while `.vbs` remains, and `{"all":"yes"}` is rejected. +- Full CTest: **8 / 8 passed** in 243.91 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 930e2a4..1a2bdef 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, `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, and releases expose a version-specific detail endpoint. 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 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, and releases expose a version-specific detail endpoint. 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). | --- diff --git a/include/Void/Build/Config/BuildTree.hpp b/include/Void/Build/Config/BuildTree.hpp new file mode 100644 index 0000000..a68a3ad --- /dev/null +++ b/include/Void/Build/Config/BuildTree.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include +#include + +#include +#include + +namespace Void::Build::Config { + +struct CleanReport { + bool build_root_exists{false}; + bool removed_entire_root{false}; + std::size_t removed_paths{0}; +}; + +// Removes generated build outputs under `build_root`. +// - all == false: removes `profiles/` and the root compile_commands.json alias, preserving the +// shared `.vbs` cache/state. +// - all == true: removes the entire build root. +[[nodiscard]] Void::Result::Result +clean_build_tree(const std::filesystem::path &build_root, bool all = false); + +} // namespace Void::Build::Config diff --git a/recipes/SelfHost/VbsSelfHostRecipe.cpp b/recipes/SelfHost/VbsSelfHostRecipe.cpp index 7063924..a4d1260 100644 --- a/recipes/SelfHost/VbsSelfHostRecipe.cpp +++ b/recipes/SelfHost/VbsSelfHostRecipe.cpp @@ -85,6 +85,7 @@ add_vbs_selfhost_native(Project &project, const VbsSelfHostConfig &config) { "src/State/RemoteCache.cpp", "src/Graph/Graph.cpp", "src/Execution/Scheduler.cpp", + "src/Config/BuildTree.cpp", "src/Config/Frontend.cpp", "src/Daemon/Daemon.cpp", "src/Editor/CompDb.cpp", diff --git a/src/Config/BuildTree.cpp b/src/Config/BuildTree.cpp new file mode 100644 index 0000000..801c845 --- /dev/null +++ b/src/Config/BuildTree.cpp @@ -0,0 +1,58 @@ +#include + +#include + +#include +#include +#include + +namespace Void::Build::Config { + +Void::Result::Result +clean_build_tree(const std::filesystem::path &build_root, bool all) { + CleanReport report; + std::error_code ec; + report.build_root_exists = std::filesystem::exists(build_root, ec); + if (!report.build_root_exists) { + return report; + } + + if (all) { + std::filesystem::remove_all(build_root, ec); + if (ec) { + return std::unexpected{Void::System::make_system_error( + Void::System::map_errno_to_system_code(ec.value()), + std::format("cannot remove build root '{}': {}", build_root.string(), ec.message()), + ec.value())}; + } + report.removed_entire_root = true; + report.removed_paths = 1; + return report; + } + + const auto profiles_dir = build_root / "profiles"; + if (std::filesystem::exists(profiles_dir, ec)) { + report.removed_paths += + static_cast(std::filesystem::remove_all(profiles_dir, ec)); + if (ec) { + return std::unexpected{Void::System::make_system_error( + Void::System::map_errno_to_system_code(ec.value()), + std::format("cannot remove profile outputs '{}': {}", profiles_dir.string(), + ec.message()), + ec.value())}; + } + } + const auto compdb = build_root / "compile_commands.json"; + if (std::filesystem::exists(compdb, ec) || std::filesystem::is_symlink(compdb, ec)) { + std::filesystem::remove(compdb, ec); + if (ec) { + return std::unexpected{Void::System::make_system_error( + Void::System::map_errno_to_system_code(ec.value()), + std::format("cannot remove '{}': {}", compdb.string(), ec.message()), ec.value())}; + } + ++report.removed_paths; + } + return report; +} + +} // namespace Void::Build::Config diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp index 5504fce..644cb41 100644 --- a/src/Daemon/Daemon.cpp +++ b/src/Daemon/Daemon.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -1695,6 +1696,29 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view if (*name == "ide_configs") { return {ide_configs_project(options), false}; } + if (*name == "clean") { + bool all = false; + if (const auto entry = object->find("all"); entry != object->end()) { + const auto *value = std::get_if(&entry->second.value); + if (value == nullptr) { + return {error_response("\"all\" must be a boolean"), false}; + } + all = *value; + } + auto cleaned = Config::clean_build_tree(options.build_root, all); + if (!cleaned) { + return {error_response(std::format("clean: {}", cleaned.error().format())), false}; + } + JsonValue::Object cleaned_object; + cleaned_object.emplace("ok", JsonValue{true}); + cleaned_object.emplace("op", JsonValue{std::string{"clean"}}); + cleaned_object.emplace("build_root", JsonValue{options.build_root.string()}); + cleaned_object.emplace("existed", JsonValue{cleaned->build_root_exists}); + cleaned_object.emplace("removed_all", JsonValue{cleaned->removed_entire_root}); + cleaned_object.emplace("removed_paths", + JsonValue{static_cast(cleaned->removed_paths)}); + return {serialize_response(JsonValue{std::move(cleaned_object)}), false}; + } if (*name == "compdb_generations") { const auto entry = object->find("profile"); if (entry == object->end()) { diff --git a/src/Main.cpp b/src/Main.cpp index 8a437c7..4d8e910 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -1566,6 +1567,8 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) { Util::json_quote(opts.graph_format_arg)); } else if (sub == "info") { request_json = R"({"op":"info"})"; + } else if (sub == "clean") { + request_json = opts.force ? R"({"op":"clean","all":true})" : R"({"op":"clean"})"; } else if (sub == "editor_status") { request_json = R"({"op":"editor_status"})"; } else if (sub == "workspace_members") { @@ -1935,35 +1938,20 @@ struct CleanCmdOptions { int execute_clean_command(const CleanCmdOptions &opts) { const std::filesystem::path build_root{opts.build_arg}; - std::error_code ec; - if (!std::filesystem::exists(build_root, ec)) { + auto cleaned = Config::clean_build_tree(build_root, opts.clean_all); + if (!cleaned) { + std::cerr << "vbs clean: " << cleaned.error().message() << '\n'; + return 1; + } + if (!cleaned->build_root_exists) { std::cout << "clean: nothing to remove in " << build_root.string() << '\n'; return 0; } - if (opts.clean_all) { - Void::Log::info("Clean", "Removing entire build directory '{}'...", build_root.string()); - std::filesystem::remove_all(build_root, ec); - if (ec) { - std::cerr << "vbs clean: failed removing '" << build_root.string() - << "': " << ec.message() << '\n'; - return 1; - } + if (cleaned->removed_entire_root) { std::cout << "cleaned " << build_root.string() << " (all)\n"; return 0; } - const auto profiles_dir = build_root / "profiles"; - std::size_t removed = 0; - if (std::filesystem::exists(profiles_dir, ec)) { - Void::Log::info("Clean", "Removing profile outputs under '{}' (preserving .vbs/cache)...", - profiles_dir.string()); - removed += static_cast(std::filesystem::remove_all(profiles_dir, ec)); - } - const auto compdb = build_root / "compile_commands.json"; - if (std::filesystem::exists(compdb, ec) || std::filesystem::is_symlink(compdb, ec)) { - std::filesystem::remove(compdb, ec); - ++removed; - } - std::cout << "cleaned " << removed << " path(s) in " << build_root.string() + std::cout << "cleaned " << cleaned->removed_paths << " path(s) in " << build_root.string() << " (preserved .vbs cache/state)\n"; return 0; } @@ -2704,6 +2692,11 @@ int main(int argc, char **argv) { auto &daemon_info_cmd = daemon_cmd.subcommand("info", "Show daemon paths, version, and host facts"); configure_daemon_common(daemon_info_cmd); + auto &daemon_clean_cmd = daemon_cmd.subcommand( + "clean", "Remove generated profile outputs (preserving the shared cache)"); + configure_daemon_common(daemon_clean_cmd); + daemon_clean_cmd.flag("--all", "", "Also remove the entire build root (cache and state)", + daemon_opts.force); auto &daemon_deps_cmd = daemon_cmd.subcommand("deps", "Resolve and materialize dependencies via the daemon"); configure_daemon_common(daemon_deps_cmd); diff --git a/tests/CliContracts.cmake b/tests/CliContracts.cmake index 985e816..4ef55d4 100644 --- a/tests/CliContracts.cmake +++ b/tests/CliContracts.cmake @@ -72,6 +72,7 @@ check_process(0 "Usage: vbs daemon ide configs " "" daemon ide configs --help) check_process(0 "Usage: vbs daemon compdb generations .*--profile" "" daemon compdb generations --help) check_process(0 "Usage: vbs daemon deps .*--profile" "" daemon deps --help) check_process(0 "Usage: vbs daemon info " "" daemon info --help) +check_process(0 "Usage: vbs daemon clean " "" daemon clean --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 6a0611e..ffb39de 100644 --- a/tests/DaemonTests.cpp +++ b/tests/DaemonTests.cpp @@ -1198,6 +1198,61 @@ VOID_TEST(Daemon, info_reports_daemon_paths_and_host) { Void::Testing::expect_eq(str_field(*info, "socket"), socket.string()); } +VOID_TEST(Daemon, clean_removes_profile_outputs_and_preserves_cache) { + 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(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 run_result; + std::jthread worker{[&] { run_result = server->run(); }}; + Void::Testing::require(wait_for_path(socket, std::chrono::seconds{5})); + + 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")); + const auto profiles_dir = options.build_root / "profiles"; + Void::Testing::expect(std::filesystem::exists(profiles_dir)); + const auto cache_dir = options.build_root / ".vbs"; + Void::Testing::expect(std::filesystem::exists(cache_dir)); + + auto cleaned = request_object(socket, R"({"op":"clean"})"); + Void::Testing::require(cleaned.has_value()); + Void::Testing::expect(bool_field(*cleaned, "ok")); + Void::Testing::expect(int_field(*cleaned, "removed_paths") >= 1); + Void::Testing::expect(!std::filesystem::exists(profiles_dir)); + Void::Testing::expect(std::filesystem::exists(cache_dir)); + + auto invalid = request_object(socket, R"({"op":"clean","all":"yes"})"); + Void::Testing::require(invalid.has_value()); + Void::Testing::expect(!bool_field(*invalid, "ok", true)); + + 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, describe_empty_project_reports_zero_targets) { auto temp = Void::FileSystem::TempDir::open("vbs_daemon_"); Void::Testing::require(temp.has_value());