feat(registry,daemon): honour If-None-Match; allow offline deps resolution
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 4s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 10s

This commit is contained in:
faumaray committed 2026-12-04 05:44:26 +03:00
1 parent c6436a8010
commit fdfab9277b
8 files changed
+140 -19

No files matched your search

+2
View File
@@ -245,6 +245,8 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
- **Wave 76 (Range Downloads & Install Option Tests)**: registry release/binary downloads honour a single `Range: bytes=...` header (206 + `Content-Range`, `Accept-Ranges: bytes`, suffix/open-ended forms, 416 for unsatisfiable/multipart ranges). A swarm worker extended the daemon install test with `component`, `export_cmake=false`/`export_native=false`, and empty-prefix uninstall assertions (5/5 substantive tasks; build task stopped and re-run).
- **Wave 77 (ETag/304 & Daemon `deps --offline`)**: registry release detail, binary listing, and binary detail responses now carry a strong `ETag` (+ `Cache-Control: no-cache`) and honour `If-None-Match` with a bodyless 304; asserted in the registry binary-variant test. A swarm worker (5/5 substantive tasks; build task stopped and re-run) added an `offline` boolean to the daemon `deps` request with validation and tests.
## 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))**: Track C (macOS/Windows ports + dual-profile cross-compilation) and dedicated external editor plugins remain planned; Track D3 signing (SBOM, Ed25519 primitives, trusted-key enforcement/distribution, binary-variant signing/distribution) and Track E3 daemon capabilities are implemented, and Track E4 now uses `Void::Net` for the registry client/server and remote cache plus `Void::Sqlite` for the StateStore when available.
+1
View File
@@ -80,4 +80,5 @@ Base HEAD: `fe0d1a6`
| Wave 74 (Self-excluding archives + release-detail tests) | `create_source_package` excludes its own output; swarm added release-detail RegistryTests coverage | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 8/8, full CTest 8/8) | `src/Package/Archive.cpp`, `tests/{FullV1Tests,RegistryTests}.cpp`, docs |
| Wave 75 (HEAD support + daemon compdb_stale) | registry HEAD routes like GET without a body (POSIX and Net); swarm added daemon `compdb_stale` with tests | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 8/8, Daemon suite passes, full CTest 8/8) | `registry/service/HttpServer.cpp`, `src/Daemon/Daemon.cpp`, `tests/{RegistryTests,DaemonTests}.cpp`, docs |
| Wave 76 (Range downloads + install option tests) | `Range` support on registry downloads (206/416, Accept-Ranges); swarm extended daemon install tests | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 8/8, Daemon suite passes, full CTest 8/8) | `registry/service/RegistryService.cpp`, `tests/{RegistryTests,DaemonTests}.cpp`, docs |
| Wave 77 (ETag/304 + deps offline) | registry read endpoints emit ETag and answer If-None-Match with 304; swarm added daemon `deps` `offline` flag | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 8/8, Daemon suite passes, full CTest 8/8) | `registry/service/RegistryService.cpp`, `src/Daemon/Daemon.cpp`, `tests/{RegistryTests,DaemonTests}.cpp`, 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) |
+9
View File
@@ -1190,6 +1190,15 @@ dev cpp-gcc -c build/pinned/bin/vbs_v1_tests --suite Daemon --no-color
(2.48 s).
- Registry suite: **8 / 8 passed** (11.45 s); full CTest: **8 / 8 passed** in 257.65 s.
## ETag/304 & Daemon `deps --offline` (GCC 16.2, pin `0002e74`)
- Registry read responses carry an `ETag`; a repeat GET with `If-None-Match` returns 304 with an
empty body (asserted in `registry_binary_variant_publish_download_and_materialize`).
- Swarm `swarm_mx8d7skh_774j` (one worker) added the `offline` boolean to the daemon `deps`
request (5/5 substantive tasks; its build task was stopped and re-run); `build_materializes_path_dependency`
passes (4.72 s) with the offline and invalid-type assertions.
- Registry suite: **8 / 8 passed** (21.72 s); full CTest: **8 / 8 passed** in 289.03 s.
## 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
@@ -46,7 +46,7 @@ flowchart LR
| Phase | Concrete Scope | Acceptance Gate |
| --- | --- | --- |
| **C1 — Platform Backend Split** *(Linux backend split implemented; macOS/Windows pending)* | Split `src/Platform/` into `Linux/`, `MacOS/`, and `Windows/` behind clean interfaces (`FileOps`, `ProcessSupervisor`, `DirectoryWatcher`), delegating to `Void::System` as upstream adds OS backends. Linux implementations now live under `src/Platform/Linux/` and `src/Watch/Linux/` (inotify watcher) with an explicit `HostOs`/`host_supported()` boundary in `include/Void/Build/Platform/Host.hpp`; macOS/Windows backends await real hosts (`vbs doctor` and the daemon `info` request report the detected host and enabled backends, `Platform::current_executable_path()` isolates the executable-path lookup across sources and tests, the daemon `describe` request can be scoped to one workspace member, `vbs daemon target flags` serves per-unit compile arguments, `vbs releases show` prints one release's detail, source archives never embed themselves, and registry downloads answer HEAD with full headers and support single-range requests). | Zero Linux regressions; clean platform abstraction boundary. |
| **C1 — Platform Backend Split** *(Linux backend split implemented; macOS/Windows pending)* | Split `src/Platform/` into `Linux/`, `MacOS/`, and `Windows/` behind clean interfaces (`FileOps`, `ProcessSupervisor`, `DirectoryWatcher`), delegating to `Void::System` as upstream adds OS backends. Linux implementations now live under `src/Platform/Linux/` and `src/Watch/Linux/` (inotify watcher) with an explicit `HostOs`/`host_supported()` boundary in `include/Void/Build/Platform/Host.hpp`; macOS/Windows backends await real hosts (`vbs doctor` and the daemon `info` request report the detected host and enabled backends, `Platform::current_executable_path()` isolates the executable-path lookup across sources and tests, the daemon `describe` request can be scoped to one workspace member, `vbs daemon target flags` serves per-unit compile arguments, `vbs releases show` prints one release's detail, source archives never embed themselves, registry downloads answer HEAD with full headers, support single-range requests, and metadata reads are ETag-validated). | Zero Linux regressions; clean platform abstraction boundary. |
| **C2 — macOS / Apple Clang & `ld64`** | Apple Clang toolchain probes, `.dylib` + `@rpath`/`@loader_path` install-name lowering, `FSEvents` watcher, Mach-O deterministic timestamps. | Real macOS CI runner passing all SDK, core, module, and install tests. |
| **C3 — Windows / MSVC & `clang-cl`** | MSVC (`cl.exe`, `lib.exe`, `link.exe`, `/showIncludes`, `.pdb`, `/FS`, `.dll`/`.lib` import libraries), Job Object process-tree kill, `ReadDirectoryChangesW` watcher, case-insensitive path conflict detection. | Real Windows CI runner passing process-tree kill, header-shadowing, and install relocation tests. |
| **C4 — True Host-vs-Target Cross-Compilation** | Dual-context evaluation (`host` profile for code generators and `build_dependency` tools vs `target` profile for cross-compiled products), sysroot & `--target=` triple propagation. | `linux-x86_64` host cross-compiling `linux-aarch64` fixture while executing host-compiled generator natively. |
+23 -3
View File
@@ -30,6 +30,23 @@ Void::Result::Error make_error(Void::System::SystemErrorCode code, std::string m
return Void::System::make_system_error(code, std::move(msg));
}
// Adds a strong ETag to a cacheable 200 response and honours If-None-Match with 304.
HttpResponse with_etag(HttpResponse resp, const HttpRequest &req) {
if (resp.status != 200) {
return resp;
}
std::string etag = "\"" + Util::sha256_hex(resp.body).substr(0, 32) + "\"";
resp.headers["ETag"] = etag;
resp.headers["Cache-Control"] = "no-cache";
if (const auto inm = req.header("if-none-match"); inm && *inm == etag) {
HttpResponse not_modified;
not_modified.status = 304;
not_modified.headers["ETag"] = etag;
return not_modified;
}
return resp;
}
// Applies a single-range `Range: bytes=start-end` request to a download response. Always
// advertises Accept-Ranges; unsatisfiable or malformed ranges produce 416 with Content-Range.
HttpResponse apply_range(HttpResponse resp, std::string_view range_header) {
@@ -1037,7 +1054,7 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) {
return HttpResponse::error_json(404, "not_found", "release not found");
}
const auto &release = rit->second;
return HttpResponse::json(
HttpResponse detail = HttpResponse::json(
200, "{\"name\":" + json_quote(pkg_name) + ",\"version\":" +
json_quote(release.version) + ",\"sha256\":" + json_quote(release.sha256) +
",\"size_bytes\":" + std::to_string(release.size_bytes) +
@@ -1061,6 +1078,7 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) {
std::string{b.yanked ? "true" : "false"} + '}';
}) +
"}\n");
return with_etag(std::move(detail), req);
}
// Publish immutable release: PUT /api/v1/packages/<name>/<version>
@@ -1371,7 +1389,7 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) {
return HttpResponse::error_json(404, "not_found", "binary variant not found");
}
const auto &binary = bit->second;
return HttpResponse::json(
HttpResponse detail = HttpResponse::json(
200, "{\"variant_id\":" + json_quote(binary.variant_id) +
",\"sha256\":" + json_quote(binary.sha256) +
",\"size_bytes\":" + std::to_string(binary.size_bytes) +
@@ -1384,6 +1402,7 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) {
json_quote("/api/v1/packages/" + pkg_name + "/" + segs[4] + "/binaries/" +
segs[6] + "/download") +
"}\n");
return with_etag(std::move(detail), req);
}
// Download a prebuilt binary variant:
@@ -1435,7 +1454,7 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) {
if (rit == pit->second.releases.end()) {
return HttpResponse::error_json(404, "not_found", "release not found");
}
return HttpResponse::json(
HttpResponse detail = HttpResponse::json(
200,
"{\"binaries\":" + json_array(rit->second.binaries, [](const auto &entry) {
const auto &b = entry.second;
@@ -1449,6 +1468,7 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) {
: ",\"public_key\":" + json_quote(b.public_key)) +
'}';
}) + "}\n");
return with_etag(std::move(detail), req);
}
// Yank/unyank a binary variant:
+18 -9
View File
@@ -576,7 +576,8 @@ make_resolve_options(const DaemonOptions &options) {
// Resolves and materializes declared dependencies without building, returning the lock context.
std::string deps_project(const DaemonOptions &options, std::string_view profile_name,
std::optional<CompilerFamily> compiler_override, std::string_view member) {
std::optional<CompilerFamily> compiler_override, std::string_view member,
bool offline) {
auto effective_result = resolve_member_options(options, member);
if (!effective_result) {
return error_response(std::format("deps: {}", effective_result.error()));
@@ -603,6 +604,7 @@ std::string deps_project(const DaemonOptions &options, std::string_view profile_
if (!resolve_options) {
return error_response(std::format("deps: {}", resolve_options.error()));
}
resolve_options->offline = offline;
auto resolved = Package::resolve_and_materialize_dependencies(evaluated->context, *merged,
*resolve_options);
if (!resolved) {
@@ -1243,7 +1245,6 @@ std::string_view action_kind_label(Graph::ActionKind kind) noexcept {
return "unknown";
}
// Reports the bounded compile arguments of one target's compilation units.
std::string target_flags_project(const DaemonOptions &options, std::string_view profile_name,
std::optional<CompilerFamily> compiler_override,
@@ -1262,9 +1263,9 @@ std::string target_flags_project(const DaemonOptions &options, std::string_view
if (!graph) {
return error_response(graph.error());
}
if (std::ranges::none_of(
graph->targets,
[&](const Graph::ResolvedTargetSummary &node) { return node.name == target_name; })) {
if (std::ranges::none_of(graph->targets, [&](const Graph::ResolvedTargetSummary &node) {
return node.name == target_name;
})) {
return error_response(std::format("target_flags: unknown target '{}'", target_name));
}
@@ -2351,7 +2352,15 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
return {compdb_export_project(options, profile_name, compiler_override, member), false};
}
if (*name == "deps") {
return {deps_project(options, profile_name, compiler_override, member), false};
bool offline = false;
if (const auto entry = object->find("offline"); entry != object->end()) {
const auto *value = std::get_if<bool>(&entry->second.value);
if (value == nullptr) {
return {error_response("\"offline\" must be a boolean"), false};
}
offline = *value;
}
return {deps_project(options, profile_name, compiler_override, member, offline), false};
}
if (*name == "install") {
InstallRequest install_request;
@@ -2454,9 +2463,9 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
return {error_response("\"target\" must be a bounded non-empty string"), false};
}
if (*name == "target_info") {
return {target_info_project(options, profile_name, compiler_override, *value,
member),
false};
return {
target_info_project(options, profile_name, compiler_override, *value, member),
false};
}
std::string file_filter;
if (const auto file_entry = object->find("file"); file_entry != object->end()) {
+65
View File
@@ -438,6 +438,22 @@ void build(Void::Build::Project &project) {
Void::Testing::expect_eq(str_field(*first_dep, "source_kind"), std::string{"path"});
Void::Testing::expect(!str_field(*first_dep, "sha256").empty());
auto offline_deps =
request_object(socket, R"({"op":"deps","offline":true})", std::chrono::seconds{120});
Void::Testing::require(offline_deps.has_value());
Void::Testing::expect(bool_field(*offline_deps, "ok"));
Void::Testing::expect_eq(str_field(*offline_deps, "op"), std::string{"deps"});
const auto *offline_entries = field(*offline_deps, "entries");
Void::Testing::require(offline_entries != nullptr);
const auto *offline_array = std::get_if<JsonValue::Array>(&offline_entries->value);
Void::Testing::require(offline_array != nullptr && !offline_array->empty());
auto invalid_offline = request_object(socket, R"({"op":"deps","offline":"yes"})");
Void::Testing::require(invalid_offline.has_value());
Void::Testing::expect(!bool_field(*invalid_offline, "ok", true));
Void::Testing::expect(str_field(*invalid_offline, "error").find("boolean") !=
std::string::npos);
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"));
@@ -451,6 +467,55 @@ void build(Void::Build::Project &project) {
Void::Testing::expect(run_result.has_value());
}
VOID_TEST(Daemon, deps_offline_reports_uncached_registry_dependency) {
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) {
project.dependency("remote")
.package("remote-pkg", "^1.0")
.registry("http://127.0.0.1:1");
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}));
// The package is not in the lock or cache, so offline resolution must fail before any
// registry connection is attempted; a network error would mean `offline` was ignored.
auto offline =
request_object(socket, R"({"op":"deps","offline":true})", std::chrono::seconds{120});
Void::Testing::require(offline.has_value());
Void::Testing::expect(!bool_field(*offline, "ok", true));
Void::Testing::expect(
str_field(*offline, "error").find("offline mode cannot query live package registry") !=
std::string::npos);
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, ide_query_serves_workspace_targets_and_compdb) {
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
Void::Testing::require(temp.has_value());
+21 -6
View File
@@ -824,6 +824,20 @@ VOID_TEST(RegistryTests, registry_binary_variant_publish_download_and_materializ
}
auto missing_release = send_loopback_http(port, "GET", "/api/v1/packages/demo-bin/9.9.9");
Void::Testing::expect(missing_release.has_value() && missing_release->status == 404);
// Conditional requests: the ETag of a read response enables a bodyless 304.
if (release_detail) {
const auto etag_it = release_detail->headers.find("etag");
Void::Testing::expect(etag_it != release_detail->headers.end());
if (etag_it != release_detail->headers.end()) {
auto not_modified = send_loopback_http(port, "GET", "/api/v1/packages/demo-bin/1.0.0",
{{"If-None-Match", etag_it->second}});
Void::Testing::expect(not_modified.has_value() && not_modified->status == 304);
if (not_modified) {
Void::Testing::expect(not_modified->body.empty());
}
}
}
if (missing_release) {
Void::Testing::expect(missing_release->body.find("release not found") != std::string::npos);
}
@@ -857,16 +871,17 @@ VOID_TEST(RegistryTests, registry_binary_variant_publish_download_and_materializ
if (downloaded) {
Void::Testing::expect(downloaded->body == artifact);
}
auto ranged = send_loopback_http(port, "GET", binary_path + "/download",
{{"Range", "bytes=0-3"}});
auto ranged =
send_loopback_http(port, "GET", binary_path + "/download", {{"Range", "bytes=0-3"}});
Void::Testing::expect(ranged.has_value() && ranged->status == 206);
if (ranged) {
Void::Testing::expect_eq(ranged->body, artifact.substr(0, 4));
Void::Testing::expect(ranged->headers.at("content-range").find("/" +
std::to_string(artifact.size())) != std::string::npos);
Void::Testing::expect(
ranged->headers.at("content-range").find("/" + std::to_string(artifact.size())) !=
std::string::npos);
}
auto unsatisfiable = send_loopback_http(port, "GET", binary_path + "/download",
{{"Range", "bytes=999999-"}});
auto unsatisfiable =
send_loopback_http(port, "GET", binary_path + "/download", {{"Range", "bytes=999999-"}});
Void::Testing::expect(unsatisfiable.has_value() && unsatisfiable->status == 416);
auto head_binary = send_loopback_http(port, "HEAD", binary_path + "/download");
Void::Testing::expect(head_binary.has_value() && head_binary->status == 200);