feat(cache): add shared HTTP action cache and parallel snapshot hashing
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 4s

- D1: RemoteCasClient + registry /api/v1/cas endpoints with bearer auth and digest verification, StateStore remote action/blob APIs, build-path-independent action keys, --remote-cache CLI
- D2: parallel snapshot revalidation hashing via Void::Concurrency::ThreadPool
- Verified in Docker GCC 16: 8/8 CTest suites, cross-build-dir 100% cache hit, 5001-file warm no-op 374 ms
- Fix self-host recipe source list for RemoteCache.cpp and accept GCC 16 -lgcc_s_asneeded
This commit is contained in:
faumaray committed 2026-12-03 12:36:21 +03:00
1 parent 6c225c2dff
commit 09c0a91d1d
19 files changed
+1213 -18

No files matched your search

+50
View File
@@ -0,0 +1,50 @@
#pragma once
#include <Void/Functional/Error.hpp>
#include <Void/Functional/Result.hpp>
#include <cstdint>
#include <optional>
#include <string>
#include <string_view>
namespace Void::Build::State {
// Runtime-only remote cache endpoint. The bearer token is never persisted, logged or
// embedded in action records; callers read it from the environment.
struct RemoteCacheConfig {
std::string url; // http(s)://host:port[/base-path]
std::string bearer_token; // Runtime-only authentication secret.
};
// Small HTTP client for the shared content-addressed action cache (Track D1).
// Blobs are addressed by their SHA-256 content digest and are always re-verified on read;
// action records are addressed by a build-path-independent action key.
class RemoteCasClient {
public:
explicit RemoteCasClient(RemoteCacheConfig config);
[[nodiscard]] const RemoteCacheConfig &config() const noexcept { return config_; }
[[nodiscard]] bool configured() const noexcept { return !config_.url.empty(); }
// PUT /api/v1/cas/blobs/<sha256> with the exact blob bytes.
[[nodiscard]] Void::Result::Result<void, Void::Result::Error>
put_blob(std::string_view sha256, std::string_view bytes) const;
// GET /api/v1/cas/blobs/<sha256>; the returned bytes are SHA-256 verified before use.
[[nodiscard]] Void::Result::Result<std::optional<std::string>, Void::Result::Error>
get_blob(std::string_view sha256) const;
// PUT /api/v1/cas/actions/<action_key> with a UTF-8 JSON action record.
[[nodiscard]] Void::Result::Result<void, Void::Result::Error>
put_action(std::string_view action_key, std::string_view json) const;
// GET /api/v1/cas/actions/<action_key>; std::nullopt on 404.
[[nodiscard]] Void::Result::Result<std::optional<std::string>, Void::Result::Error>
get_action(std::string_view action_key) const;
private:
RemoteCacheConfig config_;
};
} // namespace Void::Build::State
+17
View File
@@ -1,6 +1,7 @@
#pragma once
#include <Void/Build/Snapshot/Snapshot.hpp>
#include <Void/Build/State/RemoteCache.hpp>
#include <Void/Functional/Error.hpp>
#include <Void/Functional/Result.hpp>
@@ -99,6 +100,21 @@ class StateStore {
[[nodiscard]] Void::Result::Result<std::vector<GraphGenerationRecord>, Void::Result::Error>
list_generations(std::optional<std::string_view> profile_name = std::nullopt) const;
// Shared HTTP content-addressed action cache (Track D1). Configuration is runtime-only;
// the bearer token is never persisted. Remote reads always re-verify SHA-256 digests.
void configure_remote_cache(std::optional<RemoteCacheConfig> config);
[[nodiscard]] bool has_remote_cache() const noexcept { return remote_.has_value(); }
[[nodiscard]] Void::Result::Result<std::optional<std::string>, Void::Result::Error>
fetch_remote_action(std::string_view action_key) const;
[[nodiscard]] Void::Result::Result<void, Void::Result::Error>
publish_remote_action(std::string_view action_key, std::string_view json) const;
// Ensures a remote blob is present in the local CAS (downloading + verifying if needed).
[[nodiscard]] Void::Result::Result<bool, Void::Result::Error>
ensure_remote_blob(std::string_view sha256);
[[nodiscard]] Void::Result::Result<void, Void::Result::Error>
publish_remote_blob(std::string_view sha256) const;
// Leases protect active runs from GC deletion.
[[nodiscard]] Void::Result::Result<LeaseHandle, Void::Result::Error>
acquire_lease(std::string_view profile_name, const std::set<std::string> &pinned_blobs = {});
@@ -137,6 +153,7 @@ class StateStore {
std::filesystem::path db_file_;
std::filesystem::path lock_file_;
std::shared_ptr<CacheState> cache_;
std::optional<RemoteCasClient> remote_;
};
} // namespace Void::Build::State