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
+21 -6
View File
@@ -2,10 +2,12 @@
//
// evo-admin-api --listen ADDRESS:PORT --world N --jwks JSON --oidc-issuer URL
// --audience NAME --client NAME --role NAME --assets DIR
// --pg-passfile F --pg-service F [--region REGION=HOST:PORT ...]
// --pg-passfile F --pg-service F [--region REGION=HOST:PORT ...] [--baseline-tuning F]
//
// --assets holds the portal's index.html, app.js and style.css. Each --region names a
// region's operations address, whose /admin/view the portal may show. No token is printed.
// region's operations address, whose /admin/view the portal may show; those regions adopt
// tuning revisions. --baseline-tuning is the revamp tuning file they opened with, shown
// until the first revision. No token is printed.
#include "evo/persistence/postgres.hpp"
#include "evo/server/admin/admin_api.hpp"
@@ -33,7 +35,7 @@ void on_stop(int) {
}
struct Options {
std::string listen, jwks, oidc_issuer, audience, client, role, assets;
std::string listen, jwks, oidc_issuer, audience, client, role, assets, baseline_tuning;
std::uint64_t world{};
std::map<std::uint64_t, std::string> regions; // Region to its operations address.
persistence::PgOptions pg;
@@ -70,6 +72,8 @@ std::optional<Options> parse(int argc, char** argv) {
o.role = value;
else if (flag == "--assets")
o.assets = value;
else if (flag == "--baseline-tuning")
o.baseline_tuning = value;
else if (flag == "--pg-service")
pg_service = value;
else if (flag == "--pg-passfile")
@@ -157,6 +161,14 @@ int main(int argc, char** argv) {
config.world = options->world;
for (const auto& [region, address] : options->regions)
config.view_regions.push_back(region);
if (!options->baseline_tuning.empty()) {
auto baseline = read_file(options->baseline_tuning);
if (!baseline) {
std::puts("error baseline-tuning");
return 2;
}
config.baseline_tuning = std::move(*baseline);
}
config.portal_config_json = "{\"issuer\":\"" + options->oidc_issuer + "\",\"client_id\":\"" +
options->client + "\",\"world\":" + std::to_string(options->world) +
"}\n";
@@ -191,9 +203,12 @@ int main(int argc, char** argv) {
static_cast<unsigned long long>(options->world));
std::fflush(stdout);
while (stop_requested == 0) {
(*listening)->serve_api([&](const server::ApiRequest& request) {
return api.handle(request, wall_seconds(), std::chrono::steady_clock::now());
});
(*listening)
->serve_api(
[&](const server::ApiRequest& request) {
return api.handle(request, wall_seconds(), std::chrono::steady_clock::now());
},
server::OpsServer::max_api_body_bytes); // Tuning texts (ADR-0182 section 13).
std::this_thread::sleep_for(5ms);
}
std::puts("admin api stopped");