feat(daemon): select the active editor profile over the socket
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 4s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 22s

This commit is contained in:
faumaray committed 2026-12-03 21:57:47 +03:00
1 parent 343e03c27c
commit 502f2b0c51
9 files changed
+120 -2

No files matched your search

+1 -1
View File
@@ -107,7 +107,7 @@ All CLI help text (`vbs --help`, `vbs <command> --help`, `vbs compdb --help`, `v
- `vbs binaries list|fetch --registry URL --name PKG --version X.Y.Z [--variant ID --output FILE] [--token-env VAR]`
- `vbs bridge --request FILE --output FILE` (backend for [cmake/bridge/VbsDeps.cmake](cmake/bridge/VbsDeps.cmake))
- `vbs gc [--build-dir DIR] [--max-bytes N]`
- `vbs daemon run|status|stop|gc|recover|describe|build|ide query|ide generate|ide poll|ide wait|ide status|compdb export [--project DIR] [--member NAME]` [--build-dir DIR] [--socket PATH]` (Unix-socket daemon holding a warm state store and project watcher; `run` serves in the foreground, the rest are client requests)
- `vbs daemon run|status|stop|gc|recover|describe|build|ide query|ide generate|ide poll|ide wait|ide status|compdb use|compdb export [--project DIR] [--member NAME]` [--build-dir DIR] [--socket PATH]` (Unix-socket daemon holding a warm state store and project watcher; `run` serves in the foreground, the rest are client requests)
- `vbs gen-tests --input FILE --output-dir DIR`
- `vbs-registry --data-dir DIR --web-root DIR [--bind ADDR] [--port PORT] ...`
+4
View File
@@ -157,6 +157,10 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
- Added the `editor_status` daemon request (`vbs daemon ide status`): reports the active editor selection (`ticket`, profile, build root, generation id, compdb path, root-alias state) plus whether the selected compilation database exists and how many entries it holds.
- Added `Daemon.editor_status_reports_selection_after_compdb_export` (no selection before export, then `debug` selection with a non-empty compdb) and a CLI help contract; Daemon suite is now 14 cases.
- **Wave 35 (Daemon Compdb Use)**:
- Added the `compdb_use` daemon request (`vbs daemon compdb use --profile`): it switches the active editor profile to an already-published compilation database via `Editor::select_editor_profile` (selection lock) and returns the selected profile, generation id, ticket, and compdb path.
- Added `Daemon.compdb_use_switches_active_editor_profile` (export then select `debug`; unknown profile rejected) and a CLI help contract; Daemon suite is now 15 cases.
## 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.
+1
View File
@@ -41,4 +41,5 @@ Base HEAD: `fe0d1a6`
| Wave 32 (Member-scoped daemon IDE) | `resolve_member_options` shared by daemon IDE query/generate and compdb export; `--member` CLI flags; workspace member IDE coverage | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 13/13, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, docs |
| Wave 33 (Daemon workspace-wide build) | `execute_project_build`/`BuildOutcome` split; workspace build without `member` builds all members in order with per-member and aggregate results | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 13/13, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `tests/DaemonTests.cpp`, docs |
| Wave 34 (Editor status request) | `editor_status` daemon request + `vbs daemon ide status`: selection state, compdb existence/entry count | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 14/14, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, `tests/CliContracts.cmake`, docs |
| Wave 35 (Daemon compdb use) | `compdb_use` daemon request + `vbs daemon compdb use --profile`: switches the active editor profile under the selection lock | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 15/15, 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) |
+15
View File
@@ -613,6 +613,21 @@ dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure
- Full CTest: **8 / 8 passed** in 216.37 s.
- `clang-format --dry-run --Werror` passes on the changed C++ files.
## Daemon Compdb Use (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: **15 / 15 passed** in 30.55 s, including
`compdb_use_switches_active_editor_profile`: after `compdb_export`,
`{"op":"compdb_use","profile":"debug"}` returns profile `debug`, ticket >= 1, and an
existing compdb path; an unknown profile is rejected.
- Full CTest: **8 / 8 passed** in 213.57 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).
+1 -1
View File
@@ -73,7 +73,7 @@ flowchart LR
| --- | --- | --- |
| **E1 — Everyday CLI Ergonomics (Implemented in Wave 8)** | `vbs init` project scaffolding, `vbs clean`, `vbs doctor` environment diagnostics, `vbs graph --format dot|json`, and `vbs build --native-foreign`. | End-to-end CLI & integration tests passing in `vbs_cli_contract` and `vbs_v1_tests`. |
| **E2 — Multi-Package Workspaces (`workspace.cpp`)** *(verified in Docker GCC 16)* | Shared root `vbs.lock` and `build/.vbs` CAS, `workspace_dependency()` cross-member native linking, and affected-member selection (`vbs build/test --member <pkg>` / `--changed-since <ref>`). | 3-package workspace fixture (shared library + app + tests) builds/tests with one root lockfile; member selection and `--changed-since` verified in `FullV1Tests.workspace_members_shared_build_and_member_selection`. |
| **E3 — IDE Config/Query & Background Daemon** | `build.cpp`/`build.profiles.cpp`/`build-support/` SDK entries in `compile_commands.json` + `vbs ide generate` (`.clangd`, `.vscode/`, `.zed/`, `.idea/customTargets.xml`) & `vbs ide query` (**Implemented & Verified in Wave 10**); Unix-socket daemon core holding a warm `StateStore` + project `DirectoryWatcher` with `vbs daemon run\|status\|stop\|gc\|recover\|describe` (**Implemented & Verified in Wave 14; bounded `describe` added in the post-v1 daemon follow-up**). `describe` returns a bounded graph summary (`target_names` ≤ 128 entries × 200 bytes, `profile` ≤ 128 bytes, 10 s evaluation timeout); `vbs daemon build` executes the lowered graph in-process against the warm state store with bounded `profile`/`targets`/`jobs`, including daemon-side dependency resolution/materialization and provider import via `Package::resolve_and_materialize_dependencies`; `vbs daemon ide query` publishes/selects the profile compilation database and serves the IDE workspace/target metadata JSON over the socket, `vbs daemon compdb export` returns the published compilation-database path and entry count, `vbs daemon ide generate` writes the editor presets over the socket, `vbs daemon ide poll` exposes a bounded editor-extension watch protocol (changed paths, sequence, overflow state), `vbs daemon ide wait` adds a bounded long-poll variant, and `vbs daemon ide status` reports the active editor selection and compdb state. 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, and `vbs daemon compdb use` switches the active editor profile under the selection lock. 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. |
---
+28
View File
@@ -810,6 +810,23 @@ std::string compdb_export_project(const DaemonOptions &options, std::string_view
return serialize_response(JsonValue{std::move(object)});
}
// Switches the active editor profile to an already-published compilation database.
std::string compdb_use_project(const DaemonOptions &options, std::string_view profile_name) {
auto state =
Editor::select_editor_profile(options.project_root, options.build_root, profile_name);
if (!state) {
return error_response(std::format("compdb_use: {}", state.error().format()));
}
JsonValue::Object object;
object.emplace("ok", JsonValue{true});
object.emplace("op", JsonValue{std::string{"compdb_use"}});
object.emplace("profile", JsonValue{state->selected_profile});
object.emplace("generation_id", JsonValue{state->selected_generation_id});
object.emplace("ticket", JsonValue{static_cast<std::int64_t>(state->ticket)});
object.emplace("compdb", JsonValue{state->selected_compdb_path.string()});
return serialize_response(JsonValue{std::move(object)});
}
// Reports the active editor selection and the published compilation database state.
std::string editor_status_project(const DaemonOptions &options) {
auto selection = Editor::read_selection_state(options.project_root);
@@ -1179,6 +1196,17 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
if (*name == "editor_status") {
return {editor_status_project(options), false};
}
if (*name == "compdb_use") {
const auto entry = object->find("profile");
if (entry == object->end()) {
return {error_response("compdb_use requires \"profile\""), false};
}
const auto *value = std::get_if<std::string>(&entry->second.value);
if (value == nullptr || value->empty() || value->size() > kMaxDescribeProfileBytes) {
return {error_response("\"profile\" must be a bounded non-empty string"), false};
}
return {compdb_use_project(options, *value), false};
}
if (*name == "watch_wait") {
std::int64_t timeout_ms = kDefaultWatchWaitMs;
if (const auto entry = object->find("timeout_ms"); entry != object->end()) {
+16
View File
@@ -1578,6 +1578,13 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) {
opts.force ? "true" : "false",
opts.member_arg ? std::format(",\"member\":{}", Util::json_quote(*opts.member_arg))
: std::string{});
} else if (sub == "compdb_use") {
if (opts.profile_arg.empty()) {
std::cerr << "vbs daemon compdb use: --profile must not be empty\n";
return 2;
}
request_json = std::format(R"({{"op":"compdb_use","profile":{}}})",
Util::json_quote(opts.profile_arg));
} else if (sub == "compdb_export") {
if (opts.profile_arg.empty()) {
std::cerr << "vbs daemon compdb export: --profile must not be empty\n";
@@ -1622,6 +1629,7 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) {
const auto request_timeout =
sub == "build" ? std::chrono::milliseconds{std::chrono::hours{1}}
: (sub == "watch_poll" || sub == "editor_status") ? std::chrono::milliseconds{5000}
: sub == "compdb_use" ? std::chrono::milliseconds{10000}
: sub == "watch_wait" ? std::chrono::milliseconds{10000}
: sub == "describe" ? std::chrono::milliseconds{15000}
: (sub == "ide_query" || sub == "ide_generate" || sub == "compdb_export")
@@ -2607,6 +2615,11 @@ int main(int argc, char **argv) {
daemon_opts.jobs_arg, "0");
auto &daemon_compdb_cmd =
daemon_cmd.subcommand("compdb", "Editor compilation database served by the daemon");
auto &daemon_compdb_use_cmd =
daemon_compdb_cmd.subcommand("use", "Select an already-published editor profile");
configure_daemon_common(daemon_compdb_use_cmd);
daemon_compdb_use_cmd.option_default("--profile", "-p", "Profile to select",
daemon_opts.profile_arg, "debug");
auto &daemon_compdb_export_cmd =
daemon_compdb_cmd.subcommand("export", "Publish the profile compilation database");
configure_daemon_common(daemon_compdb_export_cmd);
@@ -2761,6 +2774,9 @@ int main(int argc, char **argv) {
} else if (daemon_sub == "compdb" && parsed.matched_command_path.size() > 2 &&
parsed.matched_command_path[2] == "export") {
daemon_sub = "compdb_export";
} else if (daemon_sub == "compdb" && parsed.matched_command_path.size() > 2 &&
parsed.matched_command_path[2] == "use") {
daemon_sub = "compdb_use";
}
return execute_daemon_command(daemon_sub, daemon_opts);
}
+1
View File
@@ -58,6 +58,7 @@ check_process(0 "Usage: vbs daemon describe .*--profile" "" daemon describe --he
check_process(0 "Usage: vbs daemon build .*--profile.*--target.*--jobs" "" daemon build --help)
check_process(0 "Usage: vbs daemon ide query .*--profile" "" daemon ide query --help)
check_process(0 "Usage: vbs daemon compdb export .*--profile" "" daemon compdb export --help)
check_process(0 "Usage: vbs daemon compdb use .*--profile" "" daemon compdb use --help)
check_process(0 "Usage: vbs daemon ide generate .*--profile.*--editor.*--force" "" daemon ide generate --help)
check_process(0 "Usage: vbs daemon ide poll " "" daemon ide poll --help)
check_process(0 "Usage: vbs daemon ide status " "" daemon ide status --help)
+53
View File
@@ -737,6 +737,59 @@ void build(Void::Build::Project &project) {
Void::Testing::expect(run_result.has_value());
}
VOID_TEST(Daemon, compdb_use_switches_active_editor_profile) {
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
Void::Testing::require(temp.has_value());
const auto options = make_options(temp->path());
{
std::ofstream descriptor{options.project_root / "build.cpp"};
descriptor << R"cpp(#include <Void/Build.hpp>
void build(Void::Build::Project &project) {
auto app = project.executable("app");
app.sources({"main.cpp"});
}
)cpp";
Void::Testing::require(descriptor.good());
}
{
std::ofstream source{options.project_root / "main.cpp"};
source << "int main() { return 0; }\n";
Void::Testing::require(source.good());
}
auto server = Void::Build::Daemon::DaemonServer::create(options);
Void::Testing::require(server.has_value());
const auto socket = server->socket_path();
Void::Result::Result<void, Void::Result::Error> run_result;
std::jthread worker{[&] { run_result = server->run(); }};
Void::Testing::require(wait_for_path(socket, std::chrono::seconds{5}));
auto exported = request_object(socket, R"({"op":"compdb_export"})", std::chrono::seconds{120});
Void::Testing::require(exported.has_value());
Void::Testing::expect(bool_field(*exported, "ok"));
auto selected = request_object(socket, R"({"op":"compdb_use","profile":"debug"})");
Void::Testing::require(selected.has_value());
Void::Testing::expect(bool_field(*selected, "ok"));
Void::Testing::expect_eq(str_field(*selected, "profile"), std::string{"debug"});
Void::Testing::expect(int_field(*selected, "ticket") >= 1);
const std::string compdb = str_field(*selected, "compdb");
Void::Testing::expect(!compdb.empty());
Void::Testing::expect(std::filesystem::exists(compdb));
auto missing = request_object(socket, R"({"op":"compdb_use","profile":"nope"})");
Void::Testing::require(missing.has_value());
Void::Testing::expect(!bool_field(*missing, "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());