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
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:
@@ -5,12 +5,13 @@
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
// ADR-0182 read-only region view for the admin portal: every cell, pool and bubble of a
|
||||
// cellular owner as compact JSON. It reads the committed in-memory state and changes nothing;
|
||||
// it is not a simulation output, a checkpoint or a client protocol.
|
||||
//
|
||||
// {"world":W,"region":R,"tick":T,"rules":N,"area":[w,h],
|
||||
// {"world":W,"region":R,"tick":T,"rules":N,["rules_sha256":"hex",]"area":[w,h],
|
||||
// "spent":[e,c,n,p,o],"cells_total":N,"deposits_total":N,
|
||||
// "cells":[["life","organism","account",x,y,extent,flags,members,
|
||||
// reserve_e,reserve_c,reserve_n,reserve_p,reserve_o,body_mass,"root"],...],
|
||||
@@ -22,7 +23,8 @@
|
||||
// request a lineage descends from, cellular_lineage_root). Flags: 1 wildlife, 2 the account's
|
||||
// session is connected, 4 lingering, 8 suspended. Deposit kind: 0 patch, 1 pool, 2 bubble. Energy
|
||||
// in pJ, matter in fg. Cells and deposits beyond the limits are left out (by ascending life id and
|
||||
// deposit id); the totals still count them.
|
||||
// deposit id); the totals still count them. `rules_sha256` is given by the caller (the SHA-256
|
||||
// of encode_cellular_revamp_rules, which tuning revisions are adopted by) and left out when empty.
|
||||
namespace evo::server {
|
||||
struct CellularAdminViewLimits {
|
||||
std::size_t cells{4096}, deposits{16384};
|
||||
@@ -31,7 +33,8 @@ struct CellularAdminViewLimits {
|
||||
using CellularAdminOnline = std::function<bool(const LifeAccount&)>;
|
||||
[[nodiscard]] std::string render_cellular_admin_view(const CellularLives& state,
|
||||
const CellularAdminOnline& online,
|
||||
CellularAdminViewLimits limits = {});
|
||||
CellularAdminViewLimits limits = {},
|
||||
std::string_view rules_sha256 = {});
|
||||
// Lowercase 8-4-4-4-12 text of a 16-byte account.
|
||||
[[nodiscard]] std::string cellular_account_text(const LifeAccount& account);
|
||||
} // namespace evo::server
|
||||
|
||||
@@ -126,11 +126,19 @@ struct CellularMutationOutcome {
|
||||
[[nodiscard]] std::expected<std::unique_ptr<CellularLives>, CellularBatchError>
|
||||
replay_cellular_batch(const CellularLives& base, const CellularBatch& batch,
|
||||
std::vector<CellularMutationOutcome>& mutation_outcomes);
|
||||
// ADR-0182: also reports every admin command's result in trace order.
|
||||
// ADR-0182: also reports every admin command's result in trace order; `tuning` names the
|
||||
// rules an adopt_tuning command adopts (a batch holds at most one).
|
||||
[[nodiscard]] std::expected<std::unique_ptr<CellularLives>, CellularBatchError>
|
||||
replay_cellular_batch(const CellularLives& base, const CellularBatch& batch,
|
||||
std::vector<CellularMutationOutcome>& mutation_outcomes,
|
||||
std::vector<CellularAdminResult>& admin_results);
|
||||
std::vector<CellularAdminResult>& admin_results,
|
||||
const CellularTuningResolver& tuning = {});
|
||||
// ADR-0182: the rules a batch's single adopt_tuning names are its successor's (nothing else
|
||||
// changes them), so publication and recovery resolve from the successor once they have
|
||||
// checked the digest: this returns the successor's rules for `check(encoding, digest)`.
|
||||
[[nodiscard]] CellularTuningResolver cellular_successor_tuning(
|
||||
const CellularLives& successor,
|
||||
std::function<bool(std::span<const std::uint8_t>, const std::array<std::uint8_t, 32>&)> check);
|
||||
// The canonical 34-byte reserved choice (schema v29): tick, life, event and offer tick as
|
||||
// u64 and the operator as u16, little-endian.
|
||||
inline constexpr std::size_t cellular_mutation_input_bytes = 34;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user