feat(admin): bans, admin logout and time played (schema 64)
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / postgres-tools (push) Successful in 2m9s
Foundation / server-image (push) Successful in 5m23s
Foundation / image (push) Successful in 6m10s

ADR-0182 section 11.
- Append-only account bans; a ban also revokes the account's grants (its live
  session closes at the next control renewal) and issue_account_grant refuses a
  banned account (EVL20 -> broker 403 account_banned). Lifting is another row.
- admin_logout_account_v1 revokes by account id.
- Session intervals recorded by claim/renew/release (signatures unchanged):
  time played, sessions and last seen per account.
- The region view carries each cell's lineage root; the portal counts living
  wildlife descended from an account's lives.
- Portal: Ban/Unban and Log out with reason and history; time played column.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-27 17:50:34 -04:00
co-authored by Claude Opus 5.5
parent b3eca78549
commit 070c458dc5
18 changed files with 490 additions and 36 deletions
+22
View File
@@ -587,6 +587,28 @@ void admin_api_tests(const Realm& realm) {
CHECK(!reader->query("DELETE FROM evolution.admin_commands", {}, 5s));
}
// Accounts (schema 64): control claims recorded alice's sessions; a ban refuses grants
// and is listed with its reason; lifting it restores them; an admin logout succeeds.
CHECK(alice->member("sessions")->integer().value_or(0) >= 1 &&
alice->member("banned")->boolean() == false);
const auto alice_path = "/api/accounts/" + alice_id;
CHECK(post(alice_path + "/ban?banned=2").status == 400);
CHECK(post(alice_path + "/other").status == 405); // Not an account action.
CHECK(api.handle({"POST", alice_path, admin}, now, t0).status == 405);
CHECK(post(alice_path + "/ban?banned=1&reason=cheating").body == "{\"banned\":true}\n");
const auto banned_view = must(JsonValue::parse(get(alice_path, admin).body));
CHECK(banned_view.member("account")->member("banned")->boolean() == true &&
banned_view.member("bans")->array()->at(0).member("reason")->string() == "cheating");
{
auto broker_db = connect_as(env("EVO_PG_RUNTIME_USER"));
const auto refused =
persistence::issue_account_grant(*broker_db, 9831, issuer, "alice-sub", 5s);
CHECK(!refused && refused.error() == persistence::AccountIdentityError::banned);
CHECK(post(alice_path + "/ban?banned=0").body == "{\"banned\":false}\n");
CHECK(persistence::issue_account_grant(*broker_db, 9831, issuer, "alice-sub", 5s));
}
CHECK(post(alice_path + "/logout").body == "{\"logged_out\":true}\n");
// 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));
+2 -1
View File
@@ -229,6 +229,7 @@ void upgrade_across_migration_and_barrier() {
" -v migration_sha_61=$(s 0061_admin_read_views.sql)"
" -v migration_sha_62=$(s 0062_session_windows.sql)"
" -v migration_sha_63=$(s 0063_admin_commands.sql)"
" -v migration_sha_64=$(s 0064_account_admin.sql)"
" -v runtime_role=evo_runtime_test -f migrations/apply.sql"
" > /dev/null 2>&1") != 0);
CHECK(history(*owner_db) == "1,2,3,4,5,6,7");
@@ -246,7 +247,7 @@ void upgrade_across_migration_and_barrier() {
"tools/migrate-postgres.sh\" > /dev/null") == 0);
CHECK(history(*owner_db) == "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,"
"25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,"
"47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63");
"47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64");
CHECK(scalar(*owner_db, "SELECT (c.condeferrable AND c.condeferred AND "
"c.confrelid = 'evolution.region_commits'::regclass)::text "
"FROM pg_catalog.pg_constraint c WHERE c.conrelid = "