feat(admin): live admin commands in trace 5 (schema 63)
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / postgres-tools (push) Successful in 30s
Foundation / server-image (push) Successful in 4m44s
Foundation / image (push) Successful in 5m33s
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / postgres-tools (push) Successful in 30s
Foundation / server-image (push) Successful in 4m44s
Foundation / image (push) Successful in 5m33s
The admin portal can now spawn wildlife, add bubbles, add to or release the spent pool, remove a cell and grant a cell's reserve on a running rules-13 region (ADR-0182 section 10). No new owner format or region opening. - Trace 5: trace 4 plus 64-byte command records counted in the tick header's last word; a batch without commands stays trace 4 (older builds replay it). Bundle 15 admits trace 5. - CellularLives::admin_candidate applies a tick's commands after its births, each on a copy kept only when it applies and closes: imports through the boundary ledger, removals into the spent pool with a new `removed` corpse cause, spawned roots via the ADR-0180 seed (now a shared helper) funded by an exact import. Refused commands change nothing. - Schema 63: the immutable admin_commands queue (spawn identities from the life allocator), pending/history reads, and binding of every recorded command exactly once inside both cellular publishers; the SQL trace parsers read trace 5 through its trace-4 normal form. - The region polls pending commands every 2 s and appends up to 16 per tick; the admin API and portal gain region actions, per-cell Remove/Grant and the command history. - Fixes an existing test that did not advance its head after a tick commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -550,6 +550,43 @@ void admin_api_tests(const Realm& realm) {
|
||||
CHECK(!owner->query(
|
||||
"SELECT * FROM evolution.admin_set_session_window_v1(9831, 1, 14401, 'x', '')", {}, 5s));
|
||||
|
||||
// Admin commands (schema 63): queued with the admin's identity, shape-checked, listed.
|
||||
for (const std::string_view bad :
|
||||
{"/api/regions/1/commands", "/api/regions/1/commands?kind=explode",
|
||||
"/api/regions/1/commands?kind=add_pool", "/api/regions/1/commands?kind=add_pool&energy=x",
|
||||
"/api/regions/1/commands?kind=remove_cell&target=7&energy=5",
|
||||
"/api/regions/1/commands?kind=spawn_wildlife&count=65"})
|
||||
CHECK(post(bad).status == 400);
|
||||
const auto queued =
|
||||
must(JsonValue::parse(post("/api/regions/1/commands?kind=add_pool&energy=1000&carbon=7"
|
||||
"&reason=top+up")
|
||||
.body));
|
||||
CHECK(queued.member("id") && queued.member("target")->string() == "0");
|
||||
CHECK(post("/api/regions/1/commands?kind=remove_cell&target=424242").status == 200);
|
||||
CHECK(post("/api/regions/2/commands?kind=add_pool&energy=1").status == 400);
|
||||
const auto listed_commands = must(JsonValue::parse(get("/api/regions/1/commands", admin).body));
|
||||
const auto& newest = listed_commands.member("commands")->array()->at(0);
|
||||
const auto& older = listed_commands.member("commands")->array()->at(1);
|
||||
CHECK(newest.member("kind")->string() == "remove_cell" &&
|
||||
newest.member("target")->string() == "424242" &&
|
||||
newest.member("applied_tick")->kind() == JsonValue::Kind::null &&
|
||||
older.member("kind")->string() == "add_pool" &&
|
||||
older.member("amount")->array()->at(0).string() == "1000" &&
|
||||
older.member("amount")->array()->at(1).string() == "7" &&
|
||||
older.member("reason")->string() == "top up" &&
|
||||
older.member("author")->string() == "ops@example.test (ops)");
|
||||
{
|
||||
auto reader = connect_as(env("EVO_PG_RUNTIME_USER"));
|
||||
const auto pending = reader->query(
|
||||
"SELECT count(*) FROM evolution.load_pending_admin_commands_v1(9831, 1)", {}, 5s);
|
||||
CHECK(pending && (*pending)[0][0] == "2");
|
||||
CHECK(!reader->query("SELECT * FROM evolution.admin_enqueue_command_v1(9831, 1, 4, 0, 0, "
|
||||
"1, 0, 0, 0, 0, 'x', '')",
|
||||
{}, 5s));
|
||||
reader = connect_as(env("PGUSER"));
|
||||
CHECK(!reader->query("DELETE FROM evolution.admin_commands", {}, 5s));
|
||||
}
|
||||
|
||||
// The read views are the only way in: the runtime role still cannot read the tables.
|
||||
runtime = connect_as(env("EVO_PG_RUNTIME_USER"));
|
||||
CHECK(!runtime->query("SELECT count(*) FROM evolution.life_reservations", {}, 5s));
|
||||
|
||||
Reference in New Issue
Block a user