feat(admin): live tuning revisions adopted at recorded ticks (schema 66)
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (checks) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 4m47s
Foundation / postgres-tools (push) Successful in 29s
Foundation / server-image (push) Successful in 4m42s
Foundation / image (push) Successful in 5m55s

ADR-0182 section 13. The admin portal's Tuning page edits the world's
rules-13 tuning (the Git revamp file format); the admin API checks it,
stores an append-only revision and queues an adopt_tuning admin command
(kind 7: revision and rules digest) for every region of the world.

- Lifecycle: adopt_tuning replaces the region's rules after births when
  a resolver names the rules for that revision and digest; the safety
  revision cannot change live. At most one adoption per batch.
- Host: fetches the revision text, rebuilds and digests the rules before
  appending the command; publication and recovery name the rules from
  the successor state, checked against the recorded digest.
- Schema 66: tuning_revisions, admin_set_tuning_v1, load_tuning_revision_v1
  (runtime), admin_tuning_revisions_v1, admin_tuning_text_v1.
- OpsServer: optional bounded request bodies (Content-Length, 413).
- Region view: rules_sha256, so the portal shows each region's revision.
- Portal: Tuning page; baseline from the mounted cellular-revamp.tuning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-27 19:35:09 -04:00
co-authored by Claude Opus 5.5
parent 7041c947a9
commit 7273b157d6
33 changed files with 1241 additions and 97 deletions
@@ -7,10 +7,12 @@
#include "evo/server/lifecycle/cellular_revamp.hpp"
#include "evo/server/lifecycle/primitive_lives.hpp"
#include <array>
#include <compare>
#include <cstddef>
#include <cstdint>
#include <expected>
#include <functional>
#include <memory>
#include <optional>
#include <span>
@@ -190,6 +192,10 @@ enum class CellularAdminKind : std::uint8_t { // A u16 in the trace.
add_pool = 4, // `amount` imported into the spent pool.
release_pool = 5, // Up to `amount` moved from the spent pool into `count` bubbles.
spawn_wildlife = 6, // `count` (1..64) random-genome roots, identities `target`.., imported.
// ADR-0182 tuning amendment: the region's rules-13 rules become tuning revision `target`,
// whose canonical rules encoding (encode_cellular_revamp_rules) has the SHA-256 held in the
// energy, carbon, nitrogen and phosphorus amounts (little-endian words; `other` zero).
adopt_tuning = 7,
};
struct CellularAdminCommand {
std::uint64_t id{}; // The durable queue id.
@@ -201,6 +207,18 @@ struct CellularAdminCommand {
};
// Shape only (kind, counts, amounts, identity range); whether it applies is decided at its tick.
[[nodiscard]] bool cellular_admin_command_valid(const CellularAdminCommand& command) noexcept;
// The 32-byte digest an adopt_tuning command carries, and a command carrying one.
[[nodiscard]] std::array<std::uint8_t, 32>
cellular_admin_digest(const CellularAdminCommand& command) noexcept;
[[nodiscard]] CellularAdminCommand
cellular_adopt_tuning_command(std::uint64_t id, std::uint64_t revision,
const std::array<std::uint8_t, 32>& digest) noexcept;
// The rules an adopt_tuning command names, from whoever can check its digest (the region host
// from the revision text, publication and recovery from the successor state). Nullopt: unknown.
using CellularTuningResolver = std::function<std::optional<CellularRevampRules>(
std::uint64_t revision, const std::array<std::uint8_t, 32>& digest)>;
// Canonical bytes of the rules-13 rules (as the owner snapshot stores them, without the pool).
[[nodiscard]] std::vector<std::uint8_t> encode_cellular_revamp_rules(const CellularRevampRules& r);
struct CellularAdminResult {
std::uint64_t id{};
bool applied{};
@@ -443,7 +461,8 @@ class CellularLives {
// current tick, after its births. Rules 13 only. `results` reports each command, in order.
[[nodiscard]] std::expected<std::unique_ptr<CellularLives>, CellularLivesError>
admin_candidate(std::span<const CellularAdminCommand> commands,
std::vector<CellularAdminResult>* results = nullptr) const;
std::vector<CellularAdminResult>* results = nullptr,
const CellularTuningResolver& tuning = {}) const;
private:
friend class CellularMigration;