feat(daemon): generate editor configuration files over the Unix socket
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 7s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 38s

This commit is contained in:
faumaray committed 2026-12-03 20:38:09 +03:00
1 parent 72f4237af2
commit e15e2cb2b4
9 files changed
+189 -9

No files matched your search

+1 -1
View File
@@ -105,7 +105,7 @@ All CLI help text (`vbs --help`, `vbs <command> --help`, `vbs compdb --help`, `v
- `vbs publish --registry URL --name PKG --version X.Y.Z [--project DIR] [--description TEXT] [--token-env VAR] [--private]`
- `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|compdb export [--project DIR] [--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|compdb export [--project DIR] [--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] ...`
+5 -1
View File
@@ -116,9 +116,13 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
- Added the `compdb_export` daemon request (`vbs daemon compdb export [--profile]`): it lowers the project graph, publishes/selects the profile compilation database, and returns `ok`/`op=compdb`/`profile`/`compdb` path/`entries` count. Shared compdb publication helpers are reused by `ide_query`.
- Added `Daemon.compdb_export_publishes_compilation_database` and a CLI help contract; Daemon suite is now 10 cases.
- **Wave 25 (Track E3 Daemon IDE Generate)**:
- Added the `ide_generate` daemon request (`vbs daemon ide generate [--profile] [--editor] [--force]`): it lowers the graph, publishes the compilation database, writes the requested editor presets (`.clangd`, `.vscode/`, `.zed/`, `.idea/`), and returns `ok`/`op=ide_generate`/`profile`/`editor` with `written` and `skipped` file lists.
- Added `Daemon.ide_generate_writes_editor_configs` (invalid editor rejected; `.clangd` written) and a CLI help contract; Daemon suite is now 11 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 and compdb export done; dedicated external editor extensions remain), and Track E4 (`Void::Net`/`Void::Sqlite` alignment) 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 and IDE config generation done; dedicated external editor extensions remain), and Track E4 (`Void::Net`/`Void::Sqlite` alignment) remain planned scope.
## Environment notes & upstream boundaries
+1
View File
@@ -31,4 +31,5 @@ Base HEAD: `fe0d1a6`
| Wave 22 (Track D3 binary-variant distribution) | `download_binary_artifact` with SHA-256 verification; `materialize_binary_variant` (signed selection, digest-validated cache reuse, download) | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; registry distribution test, full CTest 8/8) | `include/Void/Build/Package/{RegistryClient,Fetch}.hpp`, `src/Package/{RegistryClient,Fetch}.cpp`, `tests/RegistryTests.cpp`, docs |
| Wave 23 (Track C1 watcher split) | Move the Linux inotify watcher to `src/Watch/Linux/Watcher.cpp` with an explicit non-Linux boundary; update source lists/docs | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; full CTest 8/8) | `src/Watch/Linux/Watcher.cpp`, `CMakeLists.txt`, `build.cpp`, `recipes/SelfHost/VbsSelfHostRecipe.cpp`, docs |
| Wave 24 (Track E3 daemon compdb export) | `compdb_export` daemon request + `vbs daemon compdb export` CLI: lowers the graph, publishes/selects the profile compdb, returns path/entry count | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 10/10, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, `tests/CliContracts.cmake`, docs |
| Wave 25 (Track E3 daemon IDE generate) | `ide_generate` daemon request + `vbs daemon ide generate` CLI: lowers the graph, publishes compdb, writes editor presets, returns written/skipped lists | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 11/11, 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) |
+16
View File
@@ -462,6 +462,22 @@ dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure
- Full CTest: **8 / 8 passed** in 201.96 s.
- `clang-format --dry-run --Werror` passes on the changed C++ files.
## Track E3 Daemon IDE Generate (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: **11 / 11 passed** in 19.32 s, including
`ide_generate_writes_editor_configs`: an invalid editor preset returns `ok=false`, and
`{"op":"ide_generate","editor":"clangd","force":true}` returns
`ok`/`op=ide_generate`/`editor=clangd` with a non-empty `written` list and an existing
`project_root/.clangd`.
- Full CTest: **8 / 8 passed** in 222.22 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, and `vbs daemon compdb export` returns the published compilation-database path and entry count. 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, and `vbs daemon ide generate` writes the editor presets over the socket. 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. |
---
+81 -1
View File
@@ -609,6 +609,65 @@ std::string compdb_export_project(const DaemonOptions &options, std::string_view
return serialize_response(JsonValue{std::move(object)});
}
// Publishes the compilation database and writes the requested editor configuration files.
std::string ide_generate_project(const DaemonOptions &options, std::string_view profile_name,
std::optional<CompilerFamily> compiler_override,
std::string_view editor_name, bool force) {
auto kind = Editor::parse_ide_kind(editor_name);
if (!kind) {
return error_response(kind.error().format());
}
auto evaluated =
evaluate_project_graph(options, profile_name, compiler_override, "ide_generate");
if (!evaluated) {
return error_response(evaluated.error());
}
auto graph = lower_graph(options, *evaluated, {}, "ide_generate");
if (!graph) {
return error_response(graph.error());
}
auto published = publish_compdb(options, *graph);
if (!published) {
return error_response(std::format("ide_generate: {}", published.error()));
}
const auto frontend = make_frontend_options(options);
Editor::IdeConfigOptions ide;
ide.project_root = options.project_root;
ide.build_root = options.build_root;
ide.sdk_include_dir = frontend.sdk_include_dir;
ide.compdb_path = effective_compdb_path(options, *published);
ide.editor = *kind;
ide.force = force;
std::error_code ec;
ide.vbs_executable = std::filesystem::read_symlink("/proc/self/exe", ec);
if (ec || ide.vbs_executable.empty()) {
ide.vbs_executable = "vbs";
}
auto report = Editor::generate_ide_configs(*graph, ide);
if (!report) {
return error_response(std::format("ide_generate: {}", report.error().format()));
}
JsonValue::Array written;
for (const auto &path : report->written_files) {
written.emplace_back(path.string());
}
JsonValue::Array skipped;
for (const auto &path : report->skipped_existing_files) {
skipped.emplace_back(path.string());
}
JsonValue::Object object;
object.emplace("ok", JsonValue{true});
object.emplace("op", JsonValue{std::string{"ide_generate"}});
object.emplace("profile", JsonValue{evaluated->context.name});
object.emplace("editor", JsonValue{std::string{Editor::ide_kind_name(*kind)}});
object.emplace("written", JsonValue{std::move(written)});
object.emplace("skipped", JsonValue{std::move(skipped)});
return serialize_response(JsonValue{std::move(object)});
}
// Publishes the profile compilation database and returns the IDE query metadata JSON.
std::string ide_query_project(const DaemonOptions &options, std::string_view profile_name,
std::optional<CompilerFamily> compiler_override) {
@@ -796,7 +855,7 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
return {status_response(), false};
}
if (*name == "describe" || *name == "build" || *name == "ide_query" ||
*name == "compdb_export") {
*name == "ide_generate" || *name == "compdb_export") {
std::string profile_name{"debug"};
if (const auto entry = object->find("profile"); entry != object->end()) {
const auto *value = std::get_if<std::string>(&entry->second.value);
@@ -832,6 +891,27 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
if (*name == "compdb_export") {
return {compdb_export_project(options, profile_name, compiler_override), false};
}
if (*name == "ide_generate") {
std::string editor_name{"all"};
if (const auto entry = object->find("editor"); entry != object->end()) {
const auto *value = std::get_if<std::string>(&entry->second.value);
if (value == nullptr || value->empty()) {
return {error_response("\"editor\" must be a non-empty string"), false};
}
editor_name = *value;
}
bool force = false;
if (const auto entry = object->find("force"); entry != object->end()) {
const auto *value = std::get_if<bool>(&entry->second.value);
if (value == nullptr) {
return {error_response("\"force\" must be a boolean"), false};
}
force = *value;
}
return {
ide_generate_project(options, profile_name, compiler_override, editor_name, force),
false};
}
std::vector<std::string> selected_targets;
if (const auto entry = object->find("targets"); entry != object->end()) {
+28 -5
View File
@@ -1364,6 +1364,8 @@ struct DaemonCmdOptions {
std::string profile_arg{"debug"};
std::vector<std::string> targets;
std::string jobs_arg{"0"};
std::string editor_arg{"all"};
bool force{false};
std::string max_bytes_arg{"0"};
std::string max_requests_arg{"0"};
};
@@ -1443,6 +1445,15 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) {
}
request_json =
std::format(R"({{"op":"describe","profile":{}}})", Util::json_quote(opts.profile_arg));
} else if (sub == "ide_generate") {
if (opts.profile_arg.empty()) {
std::cerr << "vbs daemon ide generate: --profile must not be empty\n";
return 2;
}
request_json =
std::format(R"({{"op":"ide_generate","profile":{},"editor":{},"force":{}}})",
Util::json_quote(opts.profile_arg), Util::json_quote(opts.editor_arg),
opts.force ? "true" : "false");
} else if (sub == "compdb_export") {
if (opts.profile_arg.empty()) {
std::cerr << "vbs daemon compdb export: --profile must not be empty\n";
@@ -1480,11 +1491,12 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) {
// Describe evaluates the whole project graph (descriptor compile, toolchain probe, lowering),
// which can exceed the 2 s default; the daemon bounds evaluation at 10 s.
const auto request_timeout = sub == "build" ? std::chrono::milliseconds{std::chrono::hours{1}}
: sub == "describe" ? std::chrono::milliseconds{15000}
: (sub == "ide_query" || sub == "compdb_export")
? std::chrono::milliseconds{30000}
: std::chrono::milliseconds{2000};
const auto request_timeout =
sub == "build" ? std::chrono::milliseconds{std::chrono::hours{1}}
: sub == "describe" ? std::chrono::milliseconds{15000}
: (sub == "ide_query" || sub == "ide_generate" || sub == "compdb_export")
? std::chrono::milliseconds{30000}
: std::chrono::milliseconds{2000};
auto response = Daemon::request(socket_path, request_json, request_timeout);
if (!response) {
std::cerr << "vbs daemon: " << response.error().message() << '\n';
@@ -2441,6 +2453,14 @@ int main(int argc, char **argv) {
configure_daemon_common(daemon_ide_query_cmd);
daemon_ide_query_cmd.option_default("--profile", "-p", "Profile to query",
daemon_opts.profile_arg, "debug");
auto &daemon_ide_generate_cmd =
daemon_ide_cmd.subcommand("generate", "Write editor configuration files");
configure_daemon_common(daemon_ide_generate_cmd);
daemon_ide_generate_cmd
.option_default("--profile", "-p", "Profile to evaluate", daemon_opts.profile_arg, "debug")
.option_default("--editor", "-e", "Editor preset (all|clangd|vscode|clion|zed)",
daemon_opts.editor_arg, "all")
.flag("--force", "", "Overwrite existing IDE configuration files", daemon_opts.force);
const auto parsed = root.parse_detailed(argc, argv);
if (parsed.is_help()) {
@@ -2537,6 +2557,9 @@ int main(int argc, char **argv) {
if (daemon_sub == "ide" && parsed.matched_command_path.size() > 2 &&
parsed.matched_command_path[2] == "query") {
daemon_sub = "ide_query";
} else if (daemon_sub == "ide" && parsed.matched_command_path.size() > 2 &&
parsed.matched_command_path[2] == "generate") {
daemon_sub = "ide_generate";
} else if (daemon_sub == "compdb" && parsed.matched_command_path.size() > 2 &&
parsed.matched_command_path[2] == "export") {
daemon_sub = "compdb_export";
+1
View File
@@ -51,6 +51,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 ide generate .*--profile.*--editor.*--force" "" daemon ide generate --help)
check_process(2 "" "missing subcommand for 'vbs daemon'" daemon)
# Daemon-backed describe contract: start `vbs daemon run`, query the bounded graph summary over
+55
View File
@@ -541,6 +541,61 @@ void build(Void::Build::Project &project) {
Void::Testing::expect(std::filesystem::exists(compdb));
}
VOID_TEST(Daemon, ide_generate_writes_editor_configs) {
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 invalid = request_object(socket, R"({"op":"ide_generate","editor":"bogus"})",
std::chrono::seconds{120});
Void::Testing::require(invalid.has_value());
Void::Testing::expect(!bool_field(*invalid, "ok", true));
auto raw = Void::Build::Daemon::request(
socket, R"({"op":"ide_generate","editor":"clangd","force":true})",
std::chrono::seconds{120});
auto shutdown = Void::Build::Daemon::request(socket, R"({"op":"shutdown"})");
Void::Testing::expect(shutdown.has_value());
worker.join();
Void::Testing::expect(run_result.has_value());
Void::Testing::require(raw.has_value());
const auto parsed = parse_json(*raw);
Void::Testing::require(parsed.has_value());
const auto *object = as_object(*parsed);
Void::Testing::require(object != nullptr);
Void::Testing::expect(bool_field(*object, "ok"));
Void::Testing::expect_eq(str_field(*object, "op"), std::string{"ide_generate"});
Void::Testing::expect_eq(str_field(*object, "editor"), std::string{"clangd"});
Void::Testing::expect(!string_array_field(*object, "written").empty());
Void::Testing::expect(std::filesystem::exists(options.project_root / ".clangd"));
}
VOID_TEST(Daemon, describe_empty_project_reports_zero_targets) {
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
Void::Testing::require(temp.has_value());