From 85ff7a8c759864256ae464b7afec8c0032d280ad Mon Sep 17 00:00:00 2001 From: "Aleksei (Faumaray) Selikhov" Date: Fri, 4 Dec 2026 05:57:16 +0300 Subject: [PATCH] feat(registry,daemon): ETag downloads; report pending changes --- docs/agent-workflow/STATE.md | 2 ++ docs/agent-workflow/TASKS.md | 1 + docs/agent-workflow/VERIFICATION.md | 9 +++++++++ docs/roadmap/21-expansion-roadmap.md | 2 +- registry/service/RegistryService.cpp | 24 ++++++++++++++++++++++++ src/Daemon/Daemon.cpp | 1 + tests/DaemonTests.cpp | 11 +++++++++++ tests/RegistryTests.cpp | 18 ++++++++++++++++-- 8 files changed, 65 insertions(+), 3 deletions(-) diff --git a/docs/agent-workflow/STATE.md b/docs/agent-workflow/STATE.md index 5a515c6..53c1237 100644 --- a/docs/agent-workflow/STATE.md +++ b/docs/agent-workflow/STATE.md @@ -247,6 +247,8 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B - **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. +- **Wave 78 (Download ETag/304 & Daemon `status` Pending Changes)**: release and binary downloads now carry an `ETag` equal to the artifact digest and answer matching `If-None-Match` requests with a bodyless 304 before reading any bytes. A swarm worker added `pending_changes` to the daemon `status` response and covered it in the watch test (4/4 substantive tasks; build task stopped and re-run). + ## 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. diff --git a/docs/agent-workflow/TASKS.md b/docs/agent-workflow/TASKS.md index 35012de..b2a66de 100644 --- a/docs/agent-workflow/TASKS.md +++ b/docs/agent-workflow/TASKS.md @@ -81,4 +81,5 @@ Base HEAD: `fe0d1a6` | 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 | +| Wave 78 (Download ETag + status pending changes) | download ETag/If-None-Match 304 before reads; swarm added daemon `status` `pending_changes` | 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) | diff --git a/docs/agent-workflow/VERIFICATION.md b/docs/agent-workflow/VERIFICATION.md index f7cae42..e92cf51 100644 --- a/docs/agent-workflow/VERIFICATION.md +++ b/docs/agent-workflow/VERIFICATION.md @@ -1199,6 +1199,15 @@ dev cpp-gcc -c build/pinned/bin/vbs_v1_tests --suite Daemon --no-color 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. +## Download ETag/304 & Daemon `status` Pending Changes (GCC 16.2, pin `0002e74`) + +- A binary download returns an `ETag`; repeating the GET with `If-None-Match` returns 304 with an + empty body (asserted in `registry_binary_variant_publish_download_and_materialize`). +- Swarm `swarm_mx8dtkrm_1trd` (one worker) added `pending_changes` to the daemon `status` + response (4/4 substantive tasks; build task stopped and re-run by the orchestrator); + `watch_poll_reports_changed_paths` passes (71 ms). +- Registry suite: **8 / 8 passed** (11.01 s); full CTest: **8 / 8 passed** in 257.22 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). diff --git a/docs/roadmap/21-expansion-roadmap.md b/docs/roadmap/21-expansion-roadmap.md index f14669e..0935b98 100644 --- a/docs/roadmap/21-expansion-roadmap.md +++ b/docs/roadmap/21-expansion-roadmap.md @@ -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, registry downloads answer HEAD with full headers, support single-range requests, and metadata reads are ETag-validated). | 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 both metadata reads and downloads 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. | diff --git a/registry/service/RegistryService.cpp b/registry/service/RegistryService.cpp index a1af6ba..e437089 100644 --- a/registry/service/RegistryService.cpp +++ b/registry/service/RegistryService.cpp @@ -30,6 +30,22 @@ Void::Result::Error make_error(Void::System::SystemErrorCode code, std::string m return Void::System::make_system_error(code, std::move(msg)); } +// Returns a bodyless 304 when the request's If-None-Match matches the artifact digest. +std::optional not_modified_for(const HttpRequest &req, const std::string &digest) { + const auto inm = req.header("if-none-match"); + if (!inm) { + return std::nullopt; + } + const std::string etag = "\"" + digest + "\""; + if (*inm != etag && *inm != digest) { + return std::nullopt; + } + HttpResponse resp; + resp.status = 304; + resp.headers["ETag"] = etag; + return resp; +} + // 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) { @@ -1235,6 +1251,9 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) { if (rit == pit->second.releases.end()) { return HttpResponse::error_json(404, "not_found", "release not found"); } + if (auto not_modified = not_modified_for(req, rit->second.sha256)) { + return *not_modified; + } const auto bpath = blob_path(rit->second.sha256); auto bytes = Void::FileSystem::read_file_bounded(bpath, {256ULL * 1024ULL * 1024ULL}); if (!bytes || Util::sha256_hex(*bytes) != rit->second.sha256) { @@ -1245,6 +1264,7 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) { resp.status = 200; resp.headers["Content-Type"] = "application/x-tar"; resp.headers["X-Content-SHA256"] = rit->second.sha256; + resp.headers["ETag"] = "\"" + rit->second.sha256 + "\""; resp.body = std::move(*bytes); const auto range = req.header("range"); return apply_range(std::move(resp), range ? *range : std::string_view{}); @@ -1425,6 +1445,9 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) { if (bit == rit->second.binaries.end()) { return HttpResponse::error_json(404, "not_found", "binary variant not found"); } + if (auto not_modified = not_modified_for(req, bit->second.sha256)) { + return *not_modified; + } const auto bpath = blob_path(bit->second.sha256); auto bytes = Void::FileSystem::read_file_bounded(bpath, {256ULL * 1024ULL * 1024ULL}); if (!bytes || Util::sha256_hex(*bytes) != bit->second.sha256) { @@ -1435,6 +1458,7 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) { resp.status = 200; resp.headers["Content-Type"] = "application/octet-stream"; resp.headers["X-Content-SHA256"] = bit->second.sha256; + resp.headers["ETag"] = "\"" + bit->second.sha256 + "\""; resp.body = std::move(*bytes); const auto range = req.header("range"); return apply_range(std::move(resp), range ? *range : std::string_view{}); diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp index 9868837..a6695a2 100644 --- a/src/Daemon/Daemon.cpp +++ b/src/Daemon/Daemon.cpp @@ -1929,6 +1929,7 @@ std::string DaemonServer::Impl::status_response() const { object.emplace("watch_events", JsonValue{static_cast(status.watch_events)}); object.emplace("last_event_path", JsonValue{status.last_event_path}); object.emplace("sequence", JsonValue{static_cast(status.sequence)}); + object.emplace("pending_changes", JsonValue{static_cast(pending_changes.size())}); return serialize_response(JsonValue{std::move(object)}); } diff --git a/tests/DaemonTests.cpp b/tests/DaemonTests.cpp index 86062ad..376c1d3 100644 --- a/tests/DaemonTests.cpp +++ b/tests/DaemonTests.cpp @@ -162,6 +162,7 @@ VOID_TEST(Daemon, lifecycle_ping_status_gc_shutdown_and_unknown_op) { Void::Testing::expect(int_field(*status_object, "pid") > 0); Void::Testing::expect(int_field(*status_object, "watched_directories") >= 1); Void::Testing::expect(int_field(*status_object, "sequence") >= 0); + Void::Testing::expect(int_field(*status_object, "pending_changes") >= 0); auto gc = Void::Build::Daemon::request(socket, R"({"op":"gc","max_bytes":0})"); Void::Testing::require(gc.has_value()); @@ -690,11 +691,17 @@ VOID_TEST(Daemon, watch_poll_reports_changed_paths) { std::jthread worker{[&] { run_result = server->run(); }}; Void::Testing::require(wait_for_path(socket, std::chrono::seconds{5})); + auto initial_status = request_object(socket, R"({"op":"status"})"); + Void::Testing::require(initial_status.has_value()); + Void::Testing::expect_eq(int_field(*initial_status, "pending_changes"), std::int64_t{0}); + { std::ofstream probe{options.project_root / "probe.txt"}; probe << "changed\n"; Void::Testing::require(probe.good()); } + // Let every inotify event from the write queue up so one poll drains them all. + std::this_thread::sleep_for(std::chrono::milliseconds{50}); bool saw_probe = false; for (int attempt = 0; attempt < 100 && !saw_probe; ++attempt) { @@ -711,6 +718,10 @@ VOID_TEST(Daemon, watch_poll_reports_changed_paths) { } Void::Testing::expect(saw_probe); + auto drained_status = request_object(socket, R"({"op":"status"})"); + Void::Testing::require(drained_status.has_value()); + Void::Testing::expect_eq(int_field(*drained_status, "pending_changes"), std::int64_t{0}); + auto shutdown = Void::Build::Daemon::request(socket, R"({"op":"shutdown"})"); Void::Testing::expect(shutdown.has_value()); worker.join(); diff --git a/tests/RegistryTests.cpp b/tests/RegistryTests.cpp index d94a5ca..fa72404 100644 --- a/tests/RegistryTests.cpp +++ b/tests/RegistryTests.cpp @@ -871,8 +871,22 @@ 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 etag_head = send_loopback_http(port, "GET", binary_path + "/download"); + Void::Testing::expect(etag_head.has_value() && etag_head->status == 200); + if (etag_head) { + const auto etag_it = etag_head->headers.find("etag"); + Void::Testing::expect(etag_it != etag_head->headers.end()); + if (etag_it != etag_head->headers.end()) { + auto cached = send_loopback_http(port, "GET", binary_path + "/download", + {{"If-None-Match", etag_it->second}}); + Void::Testing::expect(cached.has_value() && cached->status == 304); + if (cached) { + Void::Testing::expect(cached->body.empty()); + } + } + } + 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));