diff --git a/docs/agent-workflow/STATE.md b/docs/agent-workflow/STATE.md index b60793b..62175a7 100644 --- a/docs/agent-workflow/STATE.md +++ b/docs/agent-workflow/STATE.md @@ -179,7 +179,7 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B - Tests: `Daemon.actions_lists_lowered_actions` and extended registry binary-variant assertions; Daemon suite is now 26 cases. - Note: a swarm retried for the daemon half stalled on its planning step again and was stopped; the work was then implemented directly. -- **Wave 61 (Registry Package Ownership API)**:\n - Added `GET/PUT/DELETE /api/v1/packages//owners[/]`: listing honors read permissions, mutations require authentication, CSRF for browser sessions, and ownership/publish authority; unknown users return 404 and removing the last owner returns 409. Owner changes are audited (`package.owner_add`/`package.owner_remove`) and persisted.\n - Extended the registry RBAC test with a dedicated package: list, add, unknown user, reader-with-ownership still denied (403), remove, and last-owner rejection.\n\n- **Wave 62 (`vbs releases list`)**:\n - Added `vbs releases list --registry URL --name PKG [--token-env VAR]` over `Package::fetch_package_releases`, printing `version sha256 active|yanked binaries=N` per release.\n - Covered by CLI contracts (help + required-argument error) and the live registry E2E (both published versions listed as active).\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 61 (Registry Package Ownership API)**:\n - Added `GET/PUT/DELETE /api/v1/packages//owners[/]`: listing honors read permissions, mutations require authentication, CSRF for browser sessions, and ownership/publish authority; unknown users return 404 and removing the last owner returns 409. Owner changes are audited (`package.owner_add`/`package.owner_remove`) and persisted.\n - Extended the registry RBAC test with a dedicated package: list, add, unknown user, reader-with-ownership still denied (403), remove, and last-owner rejection.\n\n- **Wave 62 (`vbs releases list`)**:\n - Added `vbs releases list --registry URL --name PKG [--token-env VAR]` over `Package::fetch_package_releases`, printing `version sha256 active|yanked binaries=N` per release.\n - Covered by CLI contracts (help + required-argument error) and the live registry E2E (both published versions listed as active).\n\n- **Wave 63 (Daemon Install Request)**:\n - Added the `install` daemon request (`vbs daemon install --prefix DIR [--package-version]`): builds the member graph, stages a relocatable install via `Install::install_project`, and returns `prefix`, `manifest`, and file count. Request fields cover `package_name` (defaults to the project/member directory name), `package_version`, `component`, and `export_cmake`/`export_native` booleans. `prefix` is required and bounded.\n - Added `Daemon.install_stages_prefix_and_writes_manifest` (installed binary + manifest present, missing prefix rejected) and a CLI help contract; Daemon suite is now 27 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 b6341eb..ca554af 100644 --- a/docs/agent-workflow/TASKS.md +++ b/docs/agent-workflow/TASKS.md @@ -67,4 +67,5 @@ Base HEAD: `fe0d1a6` | Wave 60 (Daemon actions + binary detail) | `actions` daemon request with target filter and limit; `GET .../binaries/` detail endpoint | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 26/26, Registry 7/7, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `registry/service/RegistryService.cpp`, `tests/DaemonTests.cpp`, `tests/RegistryTests.cpp`, `tests/CliContracts.cmake`, docs | | Wave 61 (Registry ownership API) | `GET/PUT/DELETE .../owners[/]` with authority, CSRF, audit, 404/409 handling | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 7/7, full CTest 8/8) | `registry/service/RegistryService.cpp`, `tests/RegistryTests.cpp`, docs | | Wave 62 (`vbs releases list`) | Registry client release listing CLI over `fetch_package_releases` | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 7/7, full CTest 8/8) | `src/Main.cpp`, `tests/RegistryTests.cpp`, `tests/CliContracts.cmake`, docs | +| Wave 63 (Daemon install request) | `install` daemon request + `vbs daemon install --prefix`: build, stage, export, return manifest and file count | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 27/27, 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) |"}] 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 fe1ee7a..b61bc7e 100644 --- a/docs/agent-workflow/VERIFICATION.md +++ b/docs/agent-workflow/VERIFICATION.md @@ -1025,6 +1025,20 @@ dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure - Full CTest: **8 / 8 passed** in 238.94 s. - `clang-format --dry-run --Werror` passes on `src/Main.cpp` and `tests/RegistryTests.cpp`. +## Daemon Install 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: **27 / 27 passed** in 52.69 s, including + `install_stages_prefix_and_writes_manifest`: installing `--prefix /prefix` writes + `/bin/app` and the manifest (`files >= 1`), and a request without `prefix` is rejected. +- Full CTest: **8 / 8 passed** in 261.67 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 857e26a..bf89567 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 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 compdb entries` serves bounded per-file compile arguments to editor extensions, `vbs daemon workspace members` lists workspace members cheaply, `vbs daemon ide configs` reports which editor configuration files exist, `vbs daemon compdb generations` lists editor generation history with the active selection, `vbs daemon info` exposes the daemon environment, `vbs daemon deps` resolves/materializes dependencies over the socket, registry package search and audit queries support bounded pagination/filters, releases expose a version-specific detail endpoint, and package ownership is managed through an audited owners API. Daemon workspace support describes members, builds all members in order (or a selected member) with the shared root lock, and serves member-scoped IDE query/generate/compdb requests via `--member`. Dedicated editor extensions remain planned. | `vbs ide` & `build.cpp` syntax-check verified in `FullV1Tests.cpp`; daemon lifecycle/status/gc/shutdown/describe verified in `DaemonTests.cpp` (6/6 under `dev cpp-gcc`); the live `vbs daemon describe` CLI round-trip is verified in `vbs_cli_contract`. | +| **E3 — IDE Config/Query & Background Daemon** | `build.cpp`/`build.profiles.cpp`/`build-support/` SDK entries in `compile_commands.json` + `vbs ide generate` (`.clangd`, `.vscode/`, `.zed/`, `.idea/customTargets.xml`) & `vbs ide query` (**Implemented & Verified in Wave 10**); Unix-socket daemon core holding a warm `StateStore` + project `DirectoryWatcher` with `vbs daemon run\|status\|stop\|gc\|recover\|describe` (**Implemented & Verified in Wave 14; bounded `describe` added in the post-v1 daemon follow-up**). `describe` returns a bounded graph summary (`target_names` ≤ 128 entries × 200 bytes, `profile` ≤ 128 bytes, 10 s evaluation timeout); `vbs daemon build` executes the lowered graph in-process against the warm state store with bounded `profile`/`targets`/`jobs`, including daemon-side dependency resolution/materialization and provider import via `Package::resolve_and_materialize_dependencies`; `vbs daemon ide query` publishes/selects the profile compilation database and serves the IDE workspace/target metadata JSON over the socket, `vbs daemon compdb export` returns the published compilation-database path and entry count, `vbs daemon ide generate` writes the editor presets over the socket, `vbs daemon ide poll` exposes a bounded editor-extension watch protocol (changed paths, sequence, overflow state), `vbs daemon ide wait` adds a bounded long-poll variant, `vbs daemon ide status` reports the active editor selection and compdb state, `vbs daemon compdb use` switches the active editor profile under the selection lock, `vbs daemon graph` exports the target dependency graph (DOT/JSON), `vbs daemon test` builds and runs declared test targets, `vbs daemon clean` removes generated outputs while preserving the shared cache, `vbs daemon target info` reports per-target sources/outputs, `vbs daemon actions` lists bounded lowered actions, `vbs daemon pack` creates a confined deterministic source archive, `vbs daemon install` stages an install prefix, `vbs daemon compdb entries` serves bounded per-file compile arguments to editor extensions, `vbs daemon workspace members` lists workspace members cheaply, `vbs daemon ide configs` reports which editor configuration files exist, `vbs daemon compdb generations` lists editor generation history with the active selection, `vbs daemon info` exposes the daemon environment, `vbs daemon deps` resolves/materializes dependencies over the socket, registry package search and audit queries support bounded pagination/filters, releases expose a version-specific detail endpoint, and package ownership is managed through an audited owners API. Daemon workspace support describes members, builds all members in order (or a selected member) with the shared root lock, and serves member-scoped IDE query/generate/compdb requests via `--member`. Dedicated editor extensions remain planned. | `vbs ide` & `build.cpp` syntax-check verified in `FullV1Tests.cpp`; daemon lifecycle/status/gc/shutdown/describe verified in `DaemonTests.cpp` (6/6 under `dev cpp-gcc`); the live `vbs daemon describe` CLI round-trip is verified in `vbs_cli_contract`. | | **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/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp index 8324f34..eb3481d 100644 --- a/src/Daemon/Daemon.cpp +++ b/src/Daemon/Daemon.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -907,6 +908,65 @@ std::string build_project(const DaemonOptions &options, State::StateStore &state return serialize_response(JsonValue{std::move(object)}); } +struct InstallRequest { + std::filesystem::path prefix; + std::string package_name; + std::string package_version{"0.1.0"}; + std::optional component; + bool export_cmake{true}; + bool export_native{true}; +}; + +// Builds the project graph and stages a relocatable install into the requested prefix. +std::string install_project_op(const DaemonOptions &options, State::StateStore &state, + std::string_view profile_name, + std::optional compiler_override, + std::string_view member, const InstallRequest &request) { + auto effective_result = resolve_member_options(options, member); + if (!effective_result) { + return error_response(std::format("install: {}", effective_result.error())); + } + const DaemonOptions &effective = *effective_result; + auto evaluated = evaluate_project_graph(effective, profile_name, compiler_override, "install"); + if (!evaluated) { + return error_response(evaluated.error()); + } + auto graph = lower_graph(effective, *evaluated, {}, "install"); + if (!graph) { + return error_response(graph.error()); + } + + Execution::ExecutionOptions exec_options; + auto executed = Execution::execute_graph(*graph, state, exec_options); + if (!executed) { + return error_response(std::format("install: {}", executed.error().format())); + } + if (!executed->succeeded) { + return error_response("install: build failed before staging"); + } + + Install::InstallOptions install_options; + install_options.prefix = request.prefix; + install_options.package_name = request.package_name; + install_options.package_version = request.package_version; + install_options.component = request.component; + install_options.export_cmake_config = request.export_cmake; + install_options.export_native_metadata = request.export_native; + auto installed = Install::install_project(evaluated->description, *graph, install_options); + if (!installed) { + return error_response(std::format("install: {}", installed.error().format())); + } + + JsonValue::Object object; + object.emplace("ok", JsonValue{true}); + object.emplace("op", JsonValue{std::string{"install"}}); + object.emplace("prefix", JsonValue{installed->prefix.string()}); + object.emplace("manifest", JsonValue{installed->manifest_path.string()}); + object.emplace("files", + JsonValue{static_cast(installed->installed_files.size())}); + return serialize_response(JsonValue{std::move(object)}); +} + // Publishes the profile compilation database, selecting it when no editor selection exists. Void::Result::Result publish_compdb(const DaemonOptions &options, const Graph::BuildGraph &graph) { @@ -1959,7 +2019,7 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view } if (*name == "describe" || *name == "build" || *name == "test" || *name == "ide_query" || *name == "ide_generate" || *name == "compdb_export" || *name == "graph" || - *name == "deps" || *name == "target_info" || *name == "actions") { + *name == "deps" || *name == "target_info" || *name == "actions" || *name == "install") { std::string profile_name{"debug"}; if (const auto entry = object->find("profile"); entry != object->end()) { const auto *value = std::get_if(&entry->second.value); @@ -2006,6 +2066,65 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view if (*name == "deps") { return {deps_project(options, profile_name, compiler_override, member), false}; } + if (*name == "install") { + InstallRequest install_request; + const auto prefix_entry = object->find("prefix"); + if (prefix_entry == object->end()) { + return {error_response("install requires \"prefix\""), false}; + } + const auto *prefix_value = std::get_if(&prefix_entry->second.value); + if (prefix_value == nullptr || prefix_value->empty() || prefix_value->size() > 4096) { + return {error_response("\"prefix\" must be a bounded non-empty string"), false}; + } + install_request.prefix = *prefix_value; + if (const auto entry = object->find("package_name"); entry != object->end()) { + const auto *value = std::get_if(&entry->second.value); + if (value == nullptr || value->empty()) { + return {error_response("\"package_name\" must be a non-empty string"), false}; + } + install_request.package_name = *value; + } else { + install_request.package_name = + member.empty() ? options.project_root.filename().string() : member; + if (install_request.package_name.empty()) { + install_request.package_name = "package"; + } + } + if (const auto entry = object->find("package_version"); entry != object->end()) { + const auto *value = std::get_if(&entry->second.value); + if (value == nullptr || value->empty()) { + return {error_response("\"package_version\" must be a non-empty string"), + false}; + } + install_request.package_version = *value; + } + if (const auto entry = object->find("component"); entry != object->end()) { + const auto *value = std::get_if(&entry->second.value); + if (value == nullptr || value->empty()) { + return {error_response("\"component\" must be a non-empty string"), false}; + } + install_request.component = *value; + } + const auto read_bool = [&](std::string_view key, bool &out) { + const auto entry = object->find(std::string{key}); + if (entry == object->end()) { + return true; + } + const auto *value = std::get_if(&entry->second.value); + if (value == nullptr) { + return false; + } + out = *value; + return true; + }; + if (!read_bool("export_cmake", install_request.export_cmake) || + !read_bool("export_native", install_request.export_native)) { + return {error_response("export flags must be booleans"), false}; + } + return {install_project_op(options, state_store, profile_name, compiler_override, + member, install_request), + false}; + } if (*name == "actions") { std::string target_filter; if (const auto entry = object->find("target"); entry != object->end()) { diff --git a/src/Main.cpp b/src/Main.cpp index f23ec36..f6c2e91 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1508,6 +1508,8 @@ struct DaemonCmdOptions { std::string graph_format_arg{"dot"}; std::optional target_arg; std::optional pack_output_arg; + std::optional prefix_arg; + std::string package_version_arg{"0.1.0"}; std::optional file_filter_arg; std::string limit_arg{"50"}; std::string timeout_ms_arg{"2000"}; @@ -1614,6 +1616,14 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) { request_json = opts.pack_output_arg ? std::format(R"({{"op":"pack","output":{}}})", Util::json_quote(*opts.pack_output_arg)) : R"({"op":"pack"})"; + } else if (sub == "install") { + if (!opts.prefix_arg || opts.prefix_arg->empty()) { + std::cerr << "vbs daemon install: --prefix is required\n"; + return 2; + } + request_json = std::format(R"({{"op":"install","prefix":{},"package_version":{}}})", + Util::json_quote(*opts.prefix_arg), + Util::json_quote(opts.package_version_arg)); } else if (sub == "editor_status") { request_json = R"({"op":"editor_status"})"; } else if (sub == "workspace_members") { @@ -2766,6 +2776,12 @@ int main(int argc, char **argv) { configure_daemon_common(daemon_pack_cmd); daemon_pack_cmd.option("--output", "-o", "Archive path relative to the build root", daemon_opts.pack_output_arg); + auto &daemon_install_cmd = + daemon_cmd.subcommand("install", "Build and stage an install prefix via the daemon"); + configure_daemon_common(daemon_install_cmd); + daemon_install_cmd.option("--prefix", "", "Install prefix (required)", daemon_opts.prefix_arg) + .option_default("--package-version", "", "Exported package version", + daemon_opts.package_version_arg, "0.1.0"); auto &daemon_target_cmd = daemon_cmd.subcommand("target", "Target metadata served by the daemon"); auto &daemon_target_info_cmd = daemon_target_cmd.subcommand( diff --git a/tests/CliContracts.cmake b/tests/CliContracts.cmake index 7dd41b9..ae8090c 100644 --- a/tests/CliContracts.cmake +++ b/tests/CliContracts.cmake @@ -78,6 +78,7 @@ check_process(0 "Usage: vbs daemon clean " "" daemon clean --help) check_process(0 "Usage: vbs daemon target info .*--name" "" daemon target info --help) check_process(0 "Usage: vbs daemon pack .*--output" "" daemon pack --help) check_process(0 "Usage: vbs daemon actions .*--limit" "" daemon actions --help) +check_process(0 "Usage: vbs daemon install .*--prefix" "" daemon install --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 725d335..5a04153 100644 --- a/tests/DaemonTests.cpp +++ b/tests/DaemonTests.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -1411,6 +1412,56 @@ void build(Void::Build::Project &project) { Void::Testing::expect(!bool_field(*invalid, "ok", true)); } +VOID_TEST(Daemon, install_stages_prefix_and_writes_manifest) { + 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"}).install("bin"); +} +)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})); + + const auto prefix = temp->path() / "prefix"; + const std::string install_request = + std::format(R"({{"op":"install","prefix":{},"package_name":"demo"}})", + Void::Build::Util::json_quote(prefix.string())); + auto installed = request_object(socket, install_request, std::chrono::seconds{120}); + auto missing_prefix = request_object(socket, R"({"op":"install"})"); + 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(installed.has_value()); + Void::Testing::expect(bool_field(*installed, "ok")); + Void::Testing::expect(int_field(*installed, "files") >= 1); + Void::Testing::expect(std::filesystem::exists(prefix / "bin" / "app")); + Void::Testing::expect(std::filesystem::exists(str_field(*installed, "manifest"))); + Void::Testing::require(missing_prefix.has_value()); + Void::Testing::expect(!bool_field(*missing_prefix, "ok", true)); +} + VOID_TEST(Daemon, describe_empty_project_reports_zero_targets) { auto temp = Void::FileSystem::TempDir::open("vbs_daemon_"); Void::Testing::require(temp.has_value());