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:
@@ -1587,6 +1587,56 @@ void run_starting_wildlife_publication_tests() {
|
||||
CHECK(!publish_cellular_batch(*runtime, **objects, *lease, head, again, **again_state,
|
||||
identity(11), build, 5s));
|
||||
runtime = connect_as(env("EVO_PG_RUNTIME_USER"));
|
||||
|
||||
// ADR-0182 (schema 66): a tuning revision's adoption publishes, binds and recovers; the
|
||||
// publisher and recovery name its rules from the successor state, checked by digest.
|
||||
auto tuned_rules = recovered->state->revamp_rules();
|
||||
auto& upkeep = tuned_rules.body.essential_upkeep_per_thousand;
|
||||
upkeep = upkeep == 100 ? 101 : 100;
|
||||
CHECK(evo::server::cellular_revamp_valid(tuned_rules) &&
|
||||
tuned_rules != recovered->state->revamp_rules());
|
||||
const auto tuned_digest = checked_value(
|
||||
evo::persistence::sha256(evo::server::encode_cellular_revamp_rules(tuned_rules)));
|
||||
std::string tuned_hex;
|
||||
for (const auto byte : tuned_digest) {
|
||||
constexpr std::string_view digits = "0123456789abcdef";
|
||||
tuned_hex.push_back(digits[byte >> 4U]);
|
||||
tuned_hex.push_back(digits[byte & 0x0FU]);
|
||||
}
|
||||
const auto revision_rows = owner->query(
|
||||
"SELECT evolution.admin_set_tuning_v1($1, 'not parsed by publication', "
|
||||
"decode($2, 'hex'), ARRAY[$3::bigint], 'ops', 'test')",
|
||||
std::array{std::to_string(key.world), tuned_hex, std::to_string(key.region)}, 5s);
|
||||
CHECK(revision_rows && revision_rows->size() == 1);
|
||||
const auto tuning_revision = std::stoull(revision_rows.value().at(0).at(0).value_or(""));
|
||||
const auto queued_adoption = runtime->query(
|
||||
"SELECT command_id FROM evolution.load_pending_admin_commands_v1($1, $2) WHERE kind = 7",
|
||||
std::array{std::to_string(key.world), std::to_string(key.region)}, 5s);
|
||||
CHECK(queued_adoption && queued_adoption->size() == 1);
|
||||
const auto adoption = evo::server::cellular_adopt_tuning_command(
|
||||
std::stoull(queued_adoption.value().at(0).at(0).value_or("")), tuning_revision,
|
||||
tuned_digest);
|
||||
auto adopt_batch = admin_batch({adoption});
|
||||
adopt_batch.header = {key.world, key.region, 1, head.head.commit, head.head.digest, 3, 4};
|
||||
adopt_batch.ticks.front().lives = checked_value(wildlife_intents(*recovered->state, 4));
|
||||
auto adopted = evo::fixture::restore(*recovered->state);
|
||||
CHECK(adopted->advance_tick(adopt_batch.ticks.front().lives));
|
||||
std::vector<evo::server::CellularAdminResult> adopt_results;
|
||||
auto adopted_state =
|
||||
adopted->admin_candidate(std::vector{adoption}, &adopt_results,
|
||||
[&](std::uint64_t, const std::array<std::uint8_t, 32>&) {
|
||||
return std::optional{tuned_rules};
|
||||
});
|
||||
CHECK(adopted_state && adopt_results.size() == 1 && adopt_results.front().applied);
|
||||
const auto adopted_bytes = (*adopted_state)->snapshot();
|
||||
auto adopted_publish = publish_cellular_batch(*runtime, **objects, *lease, head, adopt_batch,
|
||||
**adopted_state, identity(12), build, 5s);
|
||||
CHECK(adopted_publish);
|
||||
head = adopted_publish->committed;
|
||||
CHECK(pending() == 0);
|
||||
recovered = recover_cellular_checkpoint(*runtime, **objects, key, *lease, builds, 5s);
|
||||
CHECK(recovered && recovered->state->snapshot() == adopted_bytes &&
|
||||
recovered->state->revamp_rules() == tuned_rules);
|
||||
CHECK(release_region_lease(*runtime, key, *lease, 5s));
|
||||
std::puts("starting wildlife publication and replacement-owner replay passed");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user