Add M8.3 dev/stage stores: Retain volumes, free-space reserve, store check

Keep the filesystem object store on a node-local Retain-class PVC per
environment (ADR-0070), with the database on the external PostgreSQL VM.
Because local-path does not enforce sizes, the object store now refuses
new objects below a free-space reserve with a distinct full error, so a
full volume publishes and acknowledges nothing. evo-world-clone gains
check-store to qualify volume retention, reserve, database version/TLS
and the runtime privilege boundary from inside the cluster; it now ships
in the server image. Add the storage class, object claims, hand-applied
store Jobs, policy rules forbidding password env vars, and the runbook.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-09-29 13:51:15 -04:00
co-authored by Claude Opus 5.5
parent 9d9e00c307
commit 2d950060db
23 changed files with 833 additions and 24 deletions
+23 -6
View File
@@ -5,6 +5,7 @@
#include <fcntl.h>
#include <string>
#include <sys/stat.h>
#include <sys/statvfs.h>
#include <unistd.h>
namespace evo::persistence {
@@ -128,9 +129,17 @@ read_verified(int directory, const VerifiedObject& object, bool sync_file = fals
} // namespace
FilesystemObjectStore::FilesystemObjectStore(std::filesystem::path directory, int descriptor,
std::size_t maximum, ObjectStoreFaults* faults)
: directory_(std::move(directory)), descriptor_(descriptor), maximum_(maximum),
faults_(faults) {}
std::size_t maximum, ObjectStoreFaults* faults,
std::uint64_t reserve)
: directory_(std::move(directory)), descriptor_(descriptor), maximum_(maximum), faults_(faults),
reserve_(reserve) {}
std::optional<std::uint64_t> FilesystemObjectStore::available_bytes() const noexcept {
struct statvfs info{};
if (::fstatvfs(descriptor_, &info) != 0)
return std::nullopt;
return static_cast<std::uint64_t>(info.f_bavail) * static_cast<std::uint64_t>(info.f_frsize);
}
FilesystemObjectStore::~FilesystemObjectStore() {
static_cast<void>(::close(descriptor_));
@@ -138,7 +147,8 @@ FilesystemObjectStore::~FilesystemObjectStore() {
std::expected<std::unique_ptr<FilesystemObjectStore>, ObjectError>
FilesystemObjectStore::open(const std::filesystem::path& trusted_root, RegionKey key,
std::size_t max_object_bytes, ObjectStoreFaults* faults) {
std::size_t max_object_bytes, ObjectStoreFaults* faults,
std::uint64_t reserve_bytes) {
if (key.world == 0 || key.region == 0 || max_object_bytes == 0 ||
max_object_bytes > maximum_object_limit || trusted_root.empty())
return std::unexpected{ObjectError::invalid};
@@ -154,8 +164,9 @@ FilesystemObjectStore::open(const std::filesystem::path& trusted_root, RegionKey
Descriptor region_fd{subdirectory(world_fd.get(), region, faults)};
if (region_fd.get() < 0)
return std::unexpected{ObjectError::io};
return std::unique_ptr<FilesystemObjectStore>(new FilesystemObjectStore(
trusted_root / world / region, region_fd.release(), max_object_bytes, faults));
return std::unique_ptr<FilesystemObjectStore>(
new FilesystemObjectStore(trusted_root / world / region, region_fd.release(),
max_object_bytes, faults, reserve_bytes));
}
std::expected<VerifiedObject, ObjectError>
@@ -171,6 +182,12 @@ FilesystemObjectStore::put(std::span<const std::uint8_t> bytes) const {
// Immutable: identical content is reused (durably); anything else is corrupt.
if (auto found = durable_existing(object); found || found.error() != ObjectError::missing)
return found;
// Only new bytes need space; checked before anything is written.
const auto available = available_bytes();
if (!available)
return std::unexpected{ObjectError::io};
if (*available < reserve_ || *available - reserve_ < bytes.size())
return std::unexpected{ObjectError::full};
const auto name = key_name(*digest);
const auto temporary = ".tmp-" + name + "-" + std::to_string(::getpid()) + "-" +