Implement VoidBuildSystem v1 (Plans 01-19) with VoidLibrary integration
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s

This commit is contained in:
faumaray committed 2026-11-26 20:45:54 +03:00
1 parent 3cac890ce9
commit ab64147f9d
114 files changed
+23777 -1392

No files matched your search

+138
View File
@@ -0,0 +1,138 @@
#pragma once
#include <Void/Build/Snapshot/Snapshot.hpp>
#include <Void/Functional/Error.hpp>
#include <Void/Functional/Result.hpp>
#include <cstddef>
#include <cstdint>
#include <filesystem>
#include <map>
#include <optional>
#include <set>
#include <string>
#include <string_view>
#include <vector>
namespace Void::Build::State {
inline constexpr int kStateSchemaVersion = 1;
struct BlobRef {
std::string sha256;
std::uint64_t size{0};
std::uint32_t mode{0644};
};
struct ActionSuccessRecord {
std::string action_key;
std::string profile_identity;
std::string target_name;
std::map<std::string, BlobRef, std::less<>> outputs; // relative/logical output -> CAS blob
std::map<std::string, std::string, std::less<>> discovered_inputs; // path -> sha256
std::vector<Snapshot::LookupGuard> lookup_guards;
std::int64_t recorded_epoch{0};
};
struct GraphGenerationRecord {
std::string generation_id;
std::string profile_name;
std::string profile_identity;
std::string snapshot_id;
std::string status; // "valid", "invalid", "stale"
std::string diagnostic;
std::uint64_t sequence{0};
};
struct GcStats {
std::size_t removed_blobs{0};
std::uint64_t freed_bytes{0};
std::size_t retained_blobs{0};
std::size_t cleaned_staging_files{0};
};
struct LeaseHandle {
std::string lease_id;
std::filesystem::path lease_file;
~LeaseHandle() noexcept;
LeaseHandle() = default;
LeaseHandle(const LeaseHandle &) = delete;
LeaseHandle &operator=(const LeaseHandle &) = delete;
LeaseHandle(LeaseHandle &&other) noexcept;
LeaseHandle &operator=(LeaseHandle &&other) noexcept;
void release() noexcept;
};
// Transactional persistent state & SHA-256 content-addressed local artifact cache (Plan 07).
// Uses Void::Sqlite when compiled with SQLite3 support and a durable atomic-replace
// transactional store via Void::FileSystem::replace_file in minimal environments (VL-011).
class StateStore {
public:
[[nodiscard]] static Void::Result::Result<StateStore, Void::Result::Error>
open(const std::filesystem::path &vbs_dir);
[[nodiscard]] const std::filesystem::path &root() const noexcept { return root_; }
[[nodiscard]] std::filesystem::path cas_blob_path(std::string_view sha256) const;
// CAS operations: publish immutable blobs BEFORE recording references in state.
[[nodiscard]] Void::Result::Result<BlobRef, Void::Result::Error>
store_blob_from_file(const std::filesystem::path &file_path);
[[nodiscard]] Void::Result::Result<bool, Void::Result::Error>
verify_blob(std::string_view sha256) const;
[[nodiscard]] Void::Result::Result<void, Void::Result::Error>
materialize_blob(const BlobRef &ref, const std::filesystem::path &destination) const;
// Transactional action cache queries & publication.
[[nodiscard]] Void::Result::Result<std::optional<ActionSuccessRecord>, Void::Result::Error>
lookup_action(std::string_view action_key) const;
[[nodiscard]] Void::Result::Result<void, Void::Result::Error>
record_action_success(const ActionSuccessRecord &record);
// Graph generation tracking.
[[nodiscard]] Void::Result::Result<void, Void::Result::Error>
record_generation(const GraphGenerationRecord &generation);
[[nodiscard]] Void::Result::Result<std::vector<GraphGenerationRecord>, Void::Result::Error>
list_generations(std::optional<std::string_view> profile_name = std::nullopt) 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 = {});
// Conservative crash recovery: removes uncommitted staging files and dead leases;
// never invents a successful action record.
[[nodiscard]] Void::Result::Result<std::size_t, Void::Result::Error> recover();
// Garbage collects unreachable CAS blobs outside active leases and pinned generations.
[[nodiscard]] Void::Result::Result<GcStats, Void::Result::Error>
gc(std::uint64_t max_cache_bytes = 0);
[[nodiscard]] std::size_t recorded_action_count() const;
private:
struct DatabaseSnapshot {
int schema_version{kStateSchemaVersion};
std::uint64_t next_sequence{1};
std::map<std::string, ActionSuccessRecord, std::less<>> actions;
std::vector<GraphGenerationRecord> generations;
};
explicit StateStore(std::filesystem::path root);
[[nodiscard]] Void::Result::Result<DatabaseSnapshot, Void::Result::Error>
load_db_locked() const;
[[nodiscard]] Void::Result::Result<void, Void::Result::Error>
save_db_locked(const DatabaseSnapshot &db) const;
std::filesystem::path root_;
std::filesystem::path cas_dir_;
std::filesystem::path staging_dir_;
std::filesystem::path leases_dir_;
std::filesystem::path db_file_;
std::filesystem::path lock_file_;
};
} // namespace Void::Build::State