feat(daemon): export the target dependency graph as DOT or JSON
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 1m6s

This commit is contained in:
faumaray committed 2026-12-03 22:30:41 +03:00
1 parent 66d2fa6a2e
commit ae57ee7666
9 files changed
+175 -4

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 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 daemon run|status|stop|gc|recover|describe|build|ide query|ide generate|ide poll|ide wait|ide status|compdb use|compdb export|graph [--format dot|json] [--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] ...`
+1 -1
View File
@@ -165,7 +165,7 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
- Added `POST /api/v1/packages/<name>/<version>/binaries/<variant>/yank` to `vbs-registry` (auth + CSRF, publish authority, `{"yanked":bool}` body defaulting to true) with `BinaryReleaseMeta::yanked` persisted and listed in detail JSON. `RegistryClient::fetch_binary_variants` now exposes `yanked` and never returns yanked variants for selection.
- The registry binary-variant test now checks unauthenticated yank rejection, CSRF-protected session yank, the yanked flag in the detail JSON, and that the yanked variant disappears from the client variant list.
## Remaining future scope
- **Wave 37 (Daemon Graph Export)**:\n - Added the `graph` daemon request (`vbs daemon graph [--profile] [--format dot|json] [--member]`): evaluates the project (workspace-member aware) and returns the target dependency graph as Graphviz DOT or JSON inside a bounded JSON envelope (`profile`, `format`, `graph`).\n - Added `Daemon.graph_exports_target_dependencies_as_json_and_dot` (JSON and DOT payloads, invalid format rejected) and a CLI help contract; Daemon suite is now 16 cases.\n\n## Remaining future scope
- **Post-v1 Expansion Roadmap ([21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md) & [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md))**: Live `conan` CLI verification (Track B3), Track C (macOS/Windows ports + dual-profile cross-compilation), Track D3 signing (SBOM, Ed25519 primitives, trusted-key enforcement and distribution, binary-variant signing and distribution materialization, the #52 built-in-backend capability probe, and the VoidLibrary pin bump to `0002e74` done), Track E3 (daemon core, bounded `describe`, build-serving, dependency materialization, daemon-backed IDE metadata, compdb export, IDE config generation, editor watch poll and bounded long-poll done; dedicated external editor plugins remain), and Track E4 (`Void::Net`/`Void::Sqlite` alignment) remain planned scope.
+1
View File
@@ -43,4 +43,5 @@ Base HEAD: `fe0d1a6`
| 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 |
| Wave 36 (Registry binary-variant yank) | `POST .../binaries/<variant>/yank`, persisted `yanked` flag in detail JSON, client filters yanked variants | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry suite 6/6, full CTest 8/8) | `registry/include/Void/Build/Registry/RegistryService.hpp`, `registry/service/RegistryService.cpp`, `include/Void/Build/Package/RegistryClient.hpp`, `src/Package/RegistryClient.cpp`, `tests/RegistryTests.cpp`, docs |
| Wave 37 (Daemon graph export) | `graph` daemon request + `vbs daemon graph --format dot|json --member`: target dependency graph in a JSON envelope | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 16/16, 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
@@ -642,6 +642,21 @@ dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure
- Full CTest: **8 / 8 passed** in 212.64 s.
- `clang-format --dry-run --Werror` passes on the changed C++ files.
## Daemon Graph Export (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: **16 / 16 passed** in 32.47 s, including
`graph_exports_target_dependencies_as_json_and_dot`: `{"op":"graph","format":"json"}` returns a
`graph` string containing target `app`, the default request returns a DOT `digraph vbs_targets`
payload, and `format:"xml"` is rejected with `ok=false`.
- Full CTest: **8 / 8 passed** in 214.59 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, `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`. |
| **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, and `vbs daemon graph` exports the target dependency graph (DOT/JSON). 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. |
---
+78 -1
View File
@@ -810,6 +810,71 @@ std::string compdb_export_project(const DaemonOptions &options, std::string_view
return serialize_response(JsonValue{std::move(object)});
}
// Renders the evaluated target dependency graph as Graphviz DOT or JSON.
std::string graph_project(const DaemonOptions &options, std::string_view profile_name,
std::optional<CompilerFamily> compiler_override, std::string_view member,
std::string_view format) {
if (format != "dot" && format != "json") {
return error_response(
std::format("graph: unsupported format '{}' (expected dot or json)", format));
}
auto effective_result = resolve_member_options(options, member);
if (!effective_result) {
return error_response(std::format("graph: {}", effective_result.error()));
}
auto evaluated =
evaluate_project_graph(*effective_result, profile_name, compiler_override, "graph");
if (!evaluated) {
return error_response(evaluated.error());
}
const auto &description = evaluated->description;
const auto link_name = [](const LinkRecord &link) {
return link.kind == LinkKind::Imported ? (link.dependency + "::" + link.target)
: link.target;
};
std::string rendered;
if (format == "json") {
rendered = "{\"profile\":" + Util::json_quote(description.profile.name) + ",\"targets\":";
rendered += Util::json_array(description.targets, [](const TargetRecord &target) {
return "{\"name\":" + Util::json_quote(target.name) +
",\"kind\":" + Util::json_quote(target_kind_name(target.kind)) + ",\"links\":" +
Util::json_array(target.links,
[](const LinkRecord &link) {
return Util::json_quote(
link.kind == LinkKind::Imported
? (link.dependency + "::" + link.target)
: link.target);
}) +
'}';
});
rendered += '}';
} else {
rendered = "digraph vbs_targets {\n rankdir=LR;\n";
for (const auto &target : description.targets) {
rendered += " " + Util::json_quote(target.name) + " [label=" +
Util::json_quote(target.name + "\\n(" +
std::string{target_kind_name(target.kind)} + ")") +
"];\n";
}
for (const auto &target : description.targets) {
for (const auto &prerequisite : target.prerequisites) {
rendered += " " + Util::json_quote(target.name) + " -> " +
Util::json_quote(prerequisite) + " [style=dashed];\n";
}
for (const auto &link : target.links) {
rendered += " " + Util::json_quote(target.name) + " -> " +
Util::json_quote(link_name(link)) + ";\n";
}
}
rendered += "}\n";
}
return "{\"ok\":true,\"op\":\"graph\",\"format\":" + Util::json_quote(format) +
",\"profile\":" + Util::json_quote(description.profile.name) +
",\"graph\":" + Util::json_quote(rendered) + '}';
}
// 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 =
@@ -1246,7 +1311,7 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
return {serialize_response(JsonValue{std::move(object)}), false};
}
if (*name == "describe" || *name == "build" || *name == "ide_query" ||
*name == "ide_generate" || *name == "compdb_export") {
*name == "ide_generate" || *name == "compdb_export" || *name == "graph") {
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);
@@ -1290,6 +1355,18 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
if (*name == "compdb_export") {
return {compdb_export_project(options, profile_name, compiler_override, member), false};
}
if (*name == "graph") {
std::string graph_format{"dot"};
if (const auto entry = object->find("format"); entry != object->end()) {
const auto *value = std::get_if<std::string>(&entry->second.value);
if (value == nullptr) {
return {error_response("\"format\" must be a string"), false};
}
graph_format = *value;
}
return {graph_project(options, profile_name, compiler_override, member, graph_format),
false};
}
if (*name == "ide_generate") {
std::string editor_name{"all"};
if (const auto entry = object->find("editor"); entry != object->end()) {
+14
View File
@@ -1470,6 +1470,7 @@ struct DaemonCmdOptions {
std::string jobs_arg{"0"};
std::string editor_arg{"all"};
std::optional<std::string> member_arg;
std::string graph_format_arg{"dot"};
std::string timeout_ms_arg{"2000"};
bool force{false};
std::string max_bytes_arg{"0"};
@@ -1551,6 +1552,10 @@ 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 == "graph") {
request_json = std::format(R"({{"op":"graph","profile":{},"format":{}}})",
Util::json_quote(opts.profile_arg),
Util::json_quote(opts.graph_format_arg));
} else if (sub == "editor_status") {
request_json = R"({"op":"editor_status"})";
} else if (sub == "watch_poll") {
@@ -2627,6 +2632,15 @@ int main(int argc, char **argv) {
.option_default("--profile", "-p", "Profile to export", daemon_opts.profile_arg, "debug")
.option("--member", "", "Workspace member (required for workspace roots)",
daemon_opts.member_arg);
auto &daemon_graph_cmd =
daemon_cmd.subcommand("graph", "Export the target dependency graph via the daemon");
configure_daemon_common(daemon_graph_cmd);
daemon_graph_cmd
.option_default("--profile", "-p", "Profile to evaluate", daemon_opts.profile_arg, "debug")
.option_default("--format", "-f", "Output format (dot|json)", daemon_opts.graph_format_arg,
"dot")
.option("--member", "", "Workspace member (required for workspace roots)",
daemon_opts.member_arg);
auto &daemon_ide_cmd = daemon_cmd.subcommand("ide", "Editor/IDE metadata served by the daemon");
configure_daemon_common(daemon_ide_cmd);
auto &daemon_ide_query_cmd =
+1
View File
@@ -62,6 +62,7 @@ check_process(0 "Usage: vbs daemon compdb use .*--profile" "" daemon compdb use
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)
check_process(0 "Usage: vbs daemon graph .*--format" "" daemon graph --help)
check_process(0 "Usage: vbs daemon ide wait .*--timeout-ms" "" daemon ide wait --help)
check_process(2 "" "missing subcommand for 'vbs daemon'" daemon)
+63
View File
@@ -790,6 +790,69 @@ void build(Void::Build::Project &project) {
Void::Testing::expect(run_result.has_value());
}
VOID_TEST(Daemon, graph_exports_target_dependencies_as_json_and_dot) {
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 json_raw = Void::Build::Daemon::request(socket, R"({"op":"graph","format":"json"})",
std::chrono::seconds{120});
auto dot_raw =
Void::Build::Daemon::request(socket, R"({"op":"graph"})", std::chrono::seconds{120});
auto invalid =
request_object(socket, R"({"op":"graph","format":"xml"})", 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(json_raw.has_value());
const auto json_parsed = parse_json(*json_raw);
Void::Testing::require(json_parsed.has_value());
const auto *json_object = as_object(*json_parsed);
Void::Testing::require(json_object != nullptr);
Void::Testing::expect_eq(str_field(*json_object, "format"), std::string{"json"});
const std::string json_graph = str_field(*json_object, "graph");
Void::Testing::expect(json_graph.find("\"name\":\"app\"") != std::string::npos);
Void::Testing::require(dot_raw.has_value());
const auto dot_parsed = parse_json(*dot_raw);
Void::Testing::require(dot_parsed.has_value());
const auto *dot_object = as_object(*dot_parsed);
Void::Testing::require(dot_object != nullptr);
Void::Testing::expect_eq(str_field(*dot_object, "format"), std::string{"dot"});
const std::string dot_graph = str_field(*dot_object, "graph");
Void::Testing::expect(dot_graph.find("digraph vbs_targets") != std::string::npos);
Void::Testing::expect(dot_graph.find("\"app\"") != std::string::npos);
Void::Testing::require(invalid.has_value());
Void::Testing::expect(!bool_field(*invalid, "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());