feat(admin): end a stranded life from the portal (schema 69)
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (checks) (push) Successful in 6s
Foundation / checks (deploy) (push) Successful in 6s
Foundation / checks (ecs) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / postgres-tools (push) Successful in 5m17s
Foundation / image (push) Successful in 6m23s
Foundation / server-image (push) Successful in 8m26s

ADR-0182 section 18. Region 16 refused every birth for an account with
"Existing cell is already bound to this account" although no cell in it
held the account: a published reservation was never ended, and the only
remedy was tools/ops/end-account-life.sql as the database owner.

- Account action POST /api/accounts/<uuid>/end-life?request=N. The admin
  API reads the life's region from the account's lives and refuses while
  that region's live view lists a cell holding the account (also a bud,
  split offspring or organism control moved to), a region it cannot view,
  an incomplete view, an unpublished request or a life no longer open.
- Schema 69: admin_end_account_life_v1 (admin role only) ends it at the
  region's latest commit and appends who and why to admin_life_endings.
- The account page shows End life for each published life not ended.
- A region refusing a birth because the account holds a cell (life_exists)
  could never record it: reject_primitive_life accepted reasons 1..3 only.
  The reservation stayed open and unpublished and refused every later
  birth. Schema 69 and the C++ wrapper accept existing_life (4).
- A region with no ticking cells ignored queued admin commands (such as a
  spawn) until something else woke it; a queued command now keeps it
  ticking until applied.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-29 07:32:08 -04:00
co-authored by Claude Opus 5.5
parent 8085392122
commit 6de2b7b1ca
15 changed files with 274 additions and 18 deletions
+6 -1
View File
@@ -312,7 +312,12 @@ async function accountPage(id) {
h('button', { onclick: () => act('logout', 'log out', `Log out ${short(a.account)} now? Its session closes within seconds.`) }, 'Log out'),
a.banned
? h('button', { onclick: () => act('ban?banned=0', 'lift the ban') }, 'Lift ban')
: h('button', { class: 'danger', onclick: () => act('ban?banned=1', 'ban', `Ban ${short(a.account)}? It is logged out and cannot sign in to play.`) }, 'Ban')),
: h('button', { class: 'danger', onclick: () => act('ban?banned=1', 'ban', `Ban ${short(a.account)}? It is logged out and cannot sign in to play.`) }, 'Ban'),
// A published life never ended refuses every new birth ("Existing cell is already bound").
data.lives.filter((l) => !l.rejection && l.born !== null && !l.ended_tick).map((l) =>
h('button', { class: 'danger', onclick: () => act(`end-life?request=${l.request}`, 'end the life',
`End life ${l.identity} in region ${l.region}? Use this only when the account has no cell left there. The region refuses while one still holds the account.`) },
`End life ${l.identity}`))),
reason, note,
data.bans.length ? h('table', { class: 'compact' }, h('tbody', {}, data.bans.slice(0, 8).map((b) =>
h('tr', {}, h('td', {}, fmtTime(b.at)), h('td', {}, b.banned ? h('span', { class: 'badge dead' }, 'banned') : 'lifted'),
+5 -3
View File
@@ -1162,9 +1162,11 @@ int serve_cellular(Options& o) {
[[maybe_unused]] const auto changed = host.set_population_mode(want_population);
state = host.state();
}
const bool needed = state && (player_present || birth_waiting ||
server::cellular_unattended_tick_needed(*state) ||
status.ecological_pending_ticks != 0);
// A queued admin command needs a tick too: an empty region must still take a spawn.
const bool needed =
state &&
(player_present || birth_waiting || server::cellular_unattended_tick_needed(*state) ||
status.ecological_pending_ticks != 0 || !host.unbound_admin_commands().empty());
const auto monotonic_us = [] {
return static_cast<std::uint64_t>(
std::chrono::duration_cast<std::chrono::microseconds>(
+8
View File
@@ -1,5 +1,13 @@
# Project status and next steps
## Ending a stranded life - 2026-10-29
The portal's account page can end a published life whose reservation was never ended, which
refused every new birth ("Existing cell is already bound to this account"). The admin API first
checks the region's live view for any cell holding the account; schema 69 records who ended it
and why. A region with no ticking cells now still applies queued admin commands, such as a
spawn. See [ADR-0182](adr/0182-admin-portal-and-world-tuning.md) section 18.
## Larger region ticks for testing - 2026-10-28
A region tick may hold up to 4,096 lives (was 256), for testing limits only, and
@@ -403,6 +403,38 @@ was capped at it.
250 lives, so a region near the bound will run far below real time. The client snapshot is
budgeted (nearest changes first), so it degrades rather than fails.
### 18. Ending a stranded life (delivered 2026-10-29, schema 69)
Region 16 playtest: the region refused every birth for an account with "Existing cell is
already bound to this account", although no cell in it held the account. The database refuses
a birth while the account has an open life reservation anywhere in the world; this one was
published and never ended. How it was left open is not yet known. Until 2026-10-29 the only
remedy was `tools/ops/end-account-life.sql` as the database owner.
- **Account action.** `POST /api/accounts/<uuid>/end-life?request=N[&reason=R]`. The admin API
reads the life's region from the account's lives, fetches that region's live view and refuses
(409 `life_in_region`) while any listed cell holds the account, including a bud, a split's
offspring or an organism that control moved to. It also refuses a region it cannot view, a
view that does not list every cell, a request never published (404) and a life no longer open
(409 `not_open`).
- **Schema 69.** `admin_end_account_life_v1` (admin role only) ends the reservation at the
region's latest commit, as `end_cellular_lives` does, and appends who and why to
`admin_life_endings` (immutable). Unpublished reservations stay with the region, which still
holds them as queued births. Checkpoints and history are unchanged.
- **Safety.** If the check were wrong, the region still refuses a birth for an account that holds
a cell in its state (`life_exists`), which records an existing-life refusal.
- **Existing-life refusals are recorded.** That refusal could never be recorded:
`reject_primitive_life` (schema 15) accepted only reasons 1 to 3, and existing_life is 4.
The region dropped the birth from its queue but left the reservation open and unpublished,
which then refused every later birth for the account. Schema 69 accepts 4, both in the
function and in its C++ wrapper.
- **Portal.** The account page shows an End life button for each published life that has not
ended.
- **Idle regions take commands.** A region ticks only while something needs it: a player, a
waiting birth, a cell not suspended, or ecological work. A command queued in an empty region,
such as a spawn of wildlife, waited until something else woke it. A queued admin command now
keeps the region ticking until it is applied.
## Delivery order
1. Read-only portal: login, accounts (from existing data), regions, region view (schema 61,
+6
View File
@@ -27,6 +27,10 @@
// GET /api/accounts/<uuid> one account, its life requests and ban history
// POST /api/accounts/<uuid>/ban?banned=1|0[&reason=R] bans (and logs out) or lifts a ban
// POST /api/accounts/<uuid>/logout ends the account's sessions now
// POST /api/accounts/<uuid>/end-life?request=N[&reason=R]
// ends a stranded published life (its reservation was
// never ended), refused while a cell in its region still
// holds the account (ADR-0182 section 18)
// GET /api/regions the world's regions, leases and heads
// GET /api/regions/<n>/view the region's live view (render_cellular_admin_view)
// GET /api/regions/<n>/session-window the current session window and its last changes
@@ -116,6 +120,8 @@ class AdminApi {
[[nodiscard]] OpsResponse account_action(std::string_view account, std::string_view action,
std::string_view query,
const broker::AccessTokenClaims& admin);
[[nodiscard]] OpsResponse end_life(std::string_view account, std::string_view query,
const broker::AccessTokenClaims& admin);
[[nodiscard]] OpsResponse regions();
[[nodiscard]] OpsResponse view(std::uint64_t region, std::chrono::steady_clock::time_point now);
[[nodiscard]] OpsResponse window(std::uint64_t region);
+83
View File
@@ -0,0 +1,83 @@
-- Admin: end a stranded life (ADR-0182 section 18, 2026-10-29). A published life whose
-- reservation was never ended refuses every new birth for the account ("Existing cell is
-- already bound to this account"). The admin API first checks that no cell in the life's
-- region holds the account; this function then ends the reservation at the region's latest
-- commit, exactly as end_cellular_lives does, and records who did it and why. Unpublished
-- reservations are left to the region, which still holds them as queued births. The region's
-- checkpoints and history are unchanged.
CREATE TABLE evolution.admin_life_endings (
sequence bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
world_id evolution.u64 NOT NULL,
account_id uuid NOT NULL,
request_id evolution.u64 NOT NULL,
ended_commit uuid NOT NULL,
author_subject text NOT NULL CHECK (octet_length(author_subject) BETWEEN 1 AND 255),
reason text NOT NULL DEFAULT '' CHECK (octet_length(reason) <= 500),
created_at timestamptz NOT NULL DEFAULT clock_timestamp()
);
CREATE TRIGGER admin_life_endings_immutable BEFORE UPDATE OR DELETE ON evolution.admin_life_endings
FOR EACH ROW EXECUTE FUNCTION evolution.refuse_history_rewrite();
-- Returns true when this call ended the life, false when it was not open (already ended,
-- refused or cancelled). Raises EVL21 for an unknown or unpublished request.
CREATE FUNCTION evolution.admin_end_account_life_v1(p_world evolution.u64, p_account uuid,
p_request evolution.u64, p_subject text, p_reason text)
RETURNS boolean LANGUAGE plpgsql SECURITY DEFINER SET search_path = pg_catalog, pg_temp AS $$
DECLARE r evolution.life_reservations%ROWTYPE; latest uuid;
BEGIN
IF p_world IS NULL OR p_world = 0 OR p_account IS NULL OR p_request IS NULL OR p_request = 0 THEN
RAISE EXCEPTION 'invalid life ending' USING ERRCODE = '22023';
END IF;
SELECT * INTO r FROM evolution.life_reservations x
WHERE x.world_id = p_world AND x.account_id = p_account AND x.request_id = p_request
FOR UPDATE;
IF NOT FOUND OR NOT EXISTS (SELECT 1 FROM evolution.primitive_life_bindings b
WHERE b.world_id = p_world AND b.account_id = p_account AND b.request_id = p_request) THEN
RAISE EXCEPTION 'no published life for this request' USING ERRCODE = 'EVL21';
END IF;
IF r.rejection <> 0 OR r.ended_commit IS NOT NULL THEN
RETURN false;
END IF;
SELECT c.commit_id INTO latest FROM evolution.region_commits c
WHERE c.world_id = p_world AND c.region_id = r.region_id
ORDER BY c.commit_sequence DESC LIMIT 1;
IF latest IS NULL THEN
RAISE EXCEPTION 'region has no commit' USING ERRCODE = 'EVL21';
END IF;
UPDATE evolution.life_reservations x SET ended_commit = latest
WHERE x.world_id = p_world AND x.account_id = p_account AND x.request_id = p_request;
INSERT INTO evolution.admin_life_endings(world_id, account_id, request_id, ended_commit,
author_subject, reason)
VALUES (p_world, p_account, p_request, latest, p_subject, coalesce(p_reason, ''));
RETURN true;
END $$;
REVOKE ALL ON FUNCTION evolution.admin_end_account_life_v1(evolution.u64, uuid, evolution.u64,
text, text) FROM PUBLIC;
-- A region refuses a birth whose account still holds a cell in its state (life_exists) and
-- records that refusal as existing_life (4). Schema 15 accepted only reasons 1..3, so the
-- refusal was never recorded: the reservation stayed open and unpublished, and refused every
-- later birth for the account. Schema 17 already let the column hold 4.
CREATE OR REPLACE FUNCTION evolution.reject_primitive_life(p_world evolution.u64,
p_region evolution.u64, p_holder uuid, p_epoch evolution.u64, p_account uuid,
p_generation evolution.u64, p_request evolution.u64, p_reason smallint)
RETURNS smallint LANGUAGE plpgsql SECURITY DEFINER SET search_path = pg_catalog, pg_temp AS $$
DECLARE r evolution.life_reservations%ROWTYPE;
BEGIN
IF p_request IS NULL OR p_request = 0 OR p_reason IS NULL OR p_reason NOT BETWEEN 1 AND 4 THEN
RAISE EXCEPTION 'invalid life rejection' USING ERRCODE = '22023';
END IF;
PERFORM evolution.check_life_control(p_world, p_region, p_holder, p_epoch, p_account, p_generation);
SELECT * INTO r FROM evolution.life_reservations x
WHERE x.world_id = p_world AND x.account_id = p_account AND x.request_id = p_request FOR UPDATE;
IF NOT FOUND OR r.region_id <> p_region THEN
RAISE EXCEPTION 'life reservation not owned' USING ERRCODE = 'EVL04';
END IF;
IF r.rejection <> 0 THEN RETURN r.rejection; END IF;
UPDATE evolution.life_reservations SET rejection = p_reason
WHERE world_id = p_world AND account_id = p_account AND request_id = p_request;
RETURN p_reason;
END $$;
INSERT INTO evolution.schema_migrations(version,sha256) VALUES(69,:'migration_sha_69');
+15 -3
View File
@@ -144,6 +144,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
SELECT :'history_v65' || ',66:' || :'migration_sha_66' AS history_v66 \gset
SELECT :'history_v66' || ',67:' || :'migration_sha_67' AS history_v67 \gset
SELECT :'history_v67' || ',68:' || :'migration_sha_68' AS history_v68 \gset
SELECT :'history_v68' || ',69:' || :'migration_sha_69' AS history_v69 \gset
SELECT :'history' = :'history_v22' AS at_v22,
:'history' = :'history_v23' AS at_v23,
:'history' = :'history_v24' AS at_v24,
@@ -190,8 +191,10 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
:'history' = :'history_v65' AS at_v65,
:'history' = :'history_v66' AS at_v66,
:'history' = :'history_v67' AS at_v67,
:'history' = :'history_v68' AS at_v68 \gset
\if :at_v68
:'history' = :'history_v68' AS at_v68,
:'history' = :'history_v69' AS at_v69 \gset
\if :at_v69
\elif :at_v68
\elif :at_v67
\elif :at_v66
\elif :at_v65
@@ -621,7 +624,8 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
coalesce(max(version), 0) = 65 AS at_v65,
coalesce(max(version), 0) = 66 AS at_v66,
coalesce(max(version), 0) = 67 AS at_v67,
coalesce(max(version), 0) = 68 AS at_v68
coalesce(max(version), 0) = 68 AS at_v68,
coalesce(max(version), 0) = 69 AS at_v69
FROM evolution.schema_migrations \gset
\if :at_v24
\ir 0025_cellular_v2_bundle.sql
@@ -858,6 +862,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
\elif :at_v66
\elif :at_v67
\elif :at_v68
\elif :at_v69
\else
\echo 'Unknown or changed migration history after v43'
DO $$ BEGIN RAISE EXCEPTION 'unknown or changed migration history'; END $$;
@@ -962,6 +967,10 @@ SELECT coalesce(max(version), 0) = 67 AS needs_v68 FROM evolution.schema_migrati
\if :needs_v68
\ir 0068_larger_region_ticks.sql
\endif
SELECT coalesce(max(version), 0) = 68 AS needs_v69 FROM evolution.schema_migrations \gset
\if :needs_v69
\ir 0069_admin_end_life.sql
\endif
-- Effective-privilege audit on every run, including no-ops (ADR-0060). Attributes
-- alone are insufficient: predefined roles such as pg_write_all_data, PUBLIC
-- grants or SET-able memberships would bypass the fenced functions. Checks the
@@ -1114,6 +1123,8 @@ GRANT EXECUTE ON FUNCTION evolution.admin_commands_v1(evolution.u64, evolution.u
GRANT EXECUTE ON FUNCTION evolution.admin_set_account_ban_v1(evolution.u64, uuid, boolean, text,
text) TO :"admin_role";
GRANT EXECUTE ON FUNCTION evolution.admin_logout_account_v1(evolution.u64, uuid) TO :"admin_role";
GRANT EXECUTE ON FUNCTION evolution.admin_end_account_life_v1(evolution.u64, uuid, evolution.u64,
text, text) TO :"admin_role";
GRANT EXECUTE ON FUNCTION evolution.admin_account_status_v1(evolution.u64) TO :"admin_role";
GRANT EXECUTE ON FUNCTION evolution.admin_account_bans_v1(uuid) TO :"admin_role";
GRANT EXECUTE ON FUNCTION evolution.admin_set_schedule_v1(evolution.u64, evolution.u64, bigint,
@@ -1152,6 +1163,7 @@ BEGIN
('evolution.admin_commands_v1(evolution.u64,evolution.u64)'::regprocedure::oid),
('evolution.admin_set_account_ban_v1(evolution.u64,uuid,boolean,text,text)'::regprocedure::oid),
('evolution.admin_logout_account_v1(evolution.u64,uuid)'::regprocedure::oid),
('evolution.admin_end_account_life_v1(evolution.u64,uuid,evolution.u64,text,text)'::regprocedure::oid),
('evolution.admin_account_status_v1(evolution.u64)'::regprocedure::oid),
('evolution.admin_account_bans_v1(uuid)'::regprocedure::oid),
('evolution.admin_set_schedule_v1(evolution.u64,evolution.u64,bigint,integer,integer,evolution.u64,evolution.u64,evolution.u64,evolution.u64,evolution.u64,integer,boolean,text,text)'::regprocedure::oid),
+2 -1
View File
@@ -987,8 +987,9 @@ std::expected<LifeRefusal, LifeReservationFailure>
reject_primitive_life(Postgres& db, RegionKey key, const LeaseGrant& lease, const Uuid& account,
std::uint64_t generation, std::uint64_t request_id, LifeRefusal reason,
milliseconds timeout) {
// Schema 69: existing_life (4) too, a region refusing a birth whose account holds a cell.
const auto value = static_cast<std::uint8_t>(reason);
if (value < 1 || value > 3)
if (value < 1 || value > 4)
return std::unexpected{LifeReservationFailure{LifeReservationError::invalid, {}}};
const auto base = control_parameters(key, lease, account, generation);
const std::array<std::string, 8> p{base[0],
+54 -1
View File
@@ -299,7 +299,7 @@ OpsResponse AdminApi::handle(const ApiRequest& request, std::uint64_t now_second
(path.ends_with("/session-window") || path.ends_with("/commands") ||
path.ends_with("/schedules"))) ||
(path.starts_with("/api/accounts/") &&
(path.ends_with("/ban") || path.ends_with("/logout"))))))
(path.ends_with("/ban") || path.ends_with("/logout") || path.ends_with("/end-life"))))))
return {405, "method not allowed\n"};
if (!request.body.empty() && path != "/api/tuning")
return {400, "bad request\n"};
@@ -480,6 +480,8 @@ OpsResponse AdminApi::account_action(std::string_view account, std::string_view
return error(503, "unavailable");
return json(200, "{\"logged_out\":" + bool_value(at(rows->front(), 0)) + "}\n");
}
if (action == "end-life")
return end_life(account, query_text, admin);
if (action != "ban")
return error(404, "not_found");
const auto banned = query_value(query_text, "banned", 1);
@@ -498,6 +500,57 @@ OpsResponse AdminApi::account_action(std::string_view account, std::string_view
return json(200, "{\"banned\":" + bool_value(at(rows->front(), 0)) + "}\n");
}
OpsResponse AdminApi::end_life(std::string_view account, std::string_view query_text,
const broker::AccessTokenClaims& admin) {
const auto world = std::to_string(config_.world);
const auto request = query_value(query_text, "request", 20);
if (!request || number(*request).value_or(0) == 0)
return error(400, "bad_request_id");
const auto reason = query_value(query_text, "reason");
if (!reason && query_text.find("reason=") != std::string_view::npos)
return error(400, "bad_reason");
const auto lives = query("SELECT region_id, rejection, born, ended_tick "
"FROM evolution.admin_account_lives_v1($1, $2::uuid) "
"WHERE request_id = $3::evolution.u64",
{world, std::string(account), *request});
if (!lives)
return error(503, "unavailable");
if (lives->empty() || !at(lives->front(), 2))
return error(404, "no_published_life");
if (at(lives->front(), 1) != "0" || at(lives->front(), 3))
return error(409, "not_open");
// Only a life no cell holds is stranded: the region's live view must list every cell and
// none for this account (control may have moved to a bud, split offspring or organism).
const auto region = number(at(lives->front(), 0).value_or(""));
if (!region || !std::ranges::contains(config_.view_regions, *region))
return error(409, "region_not_viewable");
const auto body = view_ ? view_(*region) : std::nullopt;
if (!body)
return error(503, "region_unavailable");
const auto view = serialization::JsonValue::parse(*body, std::size_t{16} << 20U);
const auto* cells = view ? view->member("cells") : nullptr;
const auto* total = view ? view->member("cells_total") : nullptr;
if (!cells || !cells->array() || !total || total->integer() != cells->array()->size())
return error(503, "region_unavailable");
std::string holder(account);
std::ranges::transform(holder, holder.begin(), [](char c) {
return c >= 'A' && c <= 'F' ? static_cast<char>(c - 'A' + 'a') : c;
});
for (const auto& cell : *cells->array()) {
const auto* fields = cell.array();
if (fields && fields->size() > 2 && fields->at(2).string() == holder)
return error(409, "life_in_region");
}
const auto rows =
query("SELECT evolution.admin_end_account_life_v1($1, $2::uuid, "
"$3::evolution.u64, $4, $5)",
{world, std::string(account), *request, author_of(admin), reason.value_or("")});
if (!rows || rows->empty())
return error(503, "unavailable");
views_.erase(*region);
return json(200, "{\"ended\":" + bool_value(at(rows->front(), 0)) + "}\n");
}
OpsResponse AdminApi::regions() {
const auto world = std::to_string(config_.world);
const auto rows =
+39
View File
@@ -1211,6 +1211,45 @@ void cellular_death_is_final_and_account_restarts() {
evo::network::PrimitiveLifeResult::insufficient_funding);
CHECK(host->create_primitive_life(newcomer, newcomer_control->generation, 21).result ==
evo::network::PrimitiveLifeResult::insufficient_funding);
// Schema 69: the admin ends a published, open life (the portal first checks that no cell
// holds the account); ended, refused and unknown requests are not open.
{
const std::string holder = "94949494-9494-9494-9494-949494949494";
const auto end_life = [&](std::uint64_t request) {
auto admin = connect_as(env("EVO_PG_ADMIN_USER"));
const std::array<std::string, 2> parameters{holder, std::to_string(request)};
const auto rows =
admin->query("SELECT evolution.admin_end_account_life_v1(9768, $1::uuid, $2, "
"'ops@example.test', 'stranded')::text",
parameters, 5s);
return rows && rows->size() == 1 ? rows->front().front() : std::nullopt;
};
CHECK(end_life(11) == "false"); // Died and ended by the region.
CHECK(!end_life(13)); // Refused, never published.
CHECK(!end_life(99));
CHECK(end_life(12) == "true");
CHECK(end_life(12) == "false");
// The database now admits a birth, but the region still holds the living cell and
// refuses it, so the account never gets a second life here.
CHECK(host->create_primitive_life(account, control->generation, 14).result ==
evo::network::PrimitiveLifeResult::pending);
const std::array again{
CellularBirthRefusal{host->queued_births().front(), CellularLivesError::life_exists}};
CellularBatch kept;
kept.header = header(1);
kept.ticks.push_back({{{second, {}}}, {}, {}});
CHECK(host->publish(kept));
host->refuse_births(again);
CHECK(host->queued_births().empty() && host->state()->lives().size() == 1);
CHECK(host->query_primitive_life(account, control->generation, 14).result ==
evo::network::PrimitiveLifeResult::existing_life);
auto owner_db = connect_as(env("PGUSER"));
CHECK(owner_db
->query("SELECT 1 FROM evolution.admin_life_endings WHERE request_id = 12 "
"AND author_subject = 'ops@example.test' AND reason = 'stranded'",
{}, 5s)
->size() == 1);
}
const auto snapshot = host->state()->snapshot();
host->drain();
host.reset();
+6
View File
@@ -1047,6 +1047,12 @@ void admin_api_tests(const Realm& realm) {
CHECK(persistence::issue_account_grant(*broker_db, 9831, issuer, "alice-sub", 5s));
}
CHECK(post(alice_path + "/logout").body == "{\"logged_out\":true}\n");
// Schema 69: only a published life can be ended (cellular_publication_tests ends one).
CHECK(post(alice_path + "/end-life").status == 400 &&
post(alice_path + "/end-life?request=0").status == 400);
const auto unpublished = post(alice_path + "/end-life?request=1");
CHECK(unpublished.status == 404 &&
unpublished.body.find("no_published_life") != std::string::npos);
// The read views are the only way in: the runtime role still cannot read the tables.
runtime = connect_as(env("EVO_PG_RUNTIME_USER"));
+5 -3
View File
@@ -234,6 +234,7 @@ void upgrade_across_migration_and_barrier() {
" -v migration_sha_66=$(s 0066_tuning_revisions.sql)"
" -v migration_sha_67=$(s 0067_admin_take_and_cull.sql)"
" -v migration_sha_68=$(s 0068_larger_region_ticks.sql)"
" -v migration_sha_69=$(s 0069_admin_end_life.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");
@@ -249,9 +250,10 @@ void upgrade_across_migration_and_barrier() {
CHECK(shell("PGDATABASE=" + database +
" EVO_PG_RUNTIME_ROLE=evo_runtime_test bash \"$EVO_SOURCE_ROOT/"
"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,64,65,66,67,68");
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,64,65,66,67,68,69");
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 = "
+5
View File
@@ -77,7 +77,12 @@ awk '/^CREATE OR REPLACE FUNCTION evolution\.valid_cellular_action_input\(/ {cap
# Schema 68 raised the trace checker's tick counts; restore schema 43's (renamed _v45 by 46).
awk '/^CREATE OR REPLACE FUNCTION evolution\.cellular_births\(/ {capture=1; sub(/cellular_births\(/,"cellular_births_v45(")} capture {print} capture && /^END \$\$;/ {capture=0}' \
"$root/migrations/0043_cellular_v9_foraging_bundle.sql" | sql > /dev/null
# Schema 69 let the rejection record existing_life; restore schema 15's.
awk '/^CREATE FUNCTION evolution\.reject_primitive_life\(/ {capture=1; sub(/^CREATE FUNCTION/,"CREATE OR REPLACE FUNCTION")} capture {print} capture && /^END \$\$;/ {capture=0}' \
"$root/migrations/0015_life_reservations.sql" | sql > /dev/null
sql -v runtime_role="$EVO_PG_RUNTIME_ROLE" > /dev/null <<'SQL'
DROP FUNCTION evolution.admin_end_account_life_v1(evolution.u64,uuid,evolution.u64,text,text);
DROP TABLE evolution.admin_life_endings;
DROP FUNCTION evolution.admin_tuning_text_v1(evolution.u64,bigint);
DROP FUNCTION evolution.admin_tuning_revisions_v1(evolution.u64);
DROP FUNCTION evolution.load_tuning_revision_v1(evolution.u64,bigint);
+5 -5
View File
@@ -172,7 +172,7 @@ PGDATABASE=upgrade_path psql -X -v ON_ERROR_STOP=1 -1 -v "migration_sha=$v1_sha"
-f "$root/migrations/0001_region_bootstrap.sql" > /dev/null
test "$(PGDATABASE=upgrade_path psql -XAtc "SELECT string_agg(version::text, ',') FROM evolution.schema_migrations")" = 1
PGDATABASE=upgrade_path bash "$root/tools/migrate-postgres.sh"
test "$(PGDATABASE=upgrade_path psql -XAtc "SELECT string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 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,64,65,66,67,68
test "$(PGDATABASE=upgrade_path psql -XAtc "SELECT string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 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,64,65,66,67,68,69
# v2 heads have no payload binding: v2->v3 fails closed and leaves history at v2.
v2_sha="$(sha256sum "$root/migrations/0002_region_fencing.sql")"
v2_sha="${v2_sha%% *}"
@@ -193,7 +193,7 @@ PGDATABASE=v3_commits psql -X -v ON_ERROR_STOP=1 \
-c "INSERT INTO evolution.retained_builds VALUES (decode(repeat('b1', 32), 'hex'))" \
-c "SELECT evolution.provision_region_checkpoint(decode('4145564f52434d31' || '01000000' || '01000000' || '0100000000000000' || '0100000000000000' || '0900000000000000' || repeat('11', 16) || repeat('00', 8) || repeat('00', 16) || repeat('00', 32) || repeat('00', 16) || repeat('00', 16) || repeat('00', 8) || '50c3000000000000' || '020000000200000001000000010000000100000001000000010000000100000001000000' || repeat('b1', 32) || '00000000' || '00000000' || '01000000' || '6400000000000000' || repeat('a0', 32), 'hex'))" > /dev/null
PGDATABASE=v3_commits bash "$root/tools/migrate-postgres.sh"
test "$(PGDATABASE=v3_commits psql -XAtc "SELECT count(*) || ':' || string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 68: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,64,65,66,67,68
test "$(PGDATABASE=v3_commits psql -XAtc "SELECT count(*) || ':' || string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 69: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,64,65,66,67,68,69
test "$(PGDATABASE=v3_commits psql -XAtc "SELECT count(*) FROM evolution.region_commits")" = 1
# Review P1: a v4 database holding a published (possibly terminal) checkpoint has
# no durable decisions for it. The v5 upgrade must refuse before changing anything.
@@ -247,7 +247,7 @@ PGDATABASE=v6_populated psql -X -v ON_ERROR_STOP=1 \
-c "INSERT INTO evolution.retained_builds VALUES (decode(repeat('b1', 32), 'hex'))" \
-c "SELECT evolution.provision_region_checkpoint(decode('4145564f52434d31' || '02000000' || '01000000' || '0100000000000000' || '0100000000000000' || '0900000000000000' || repeat('11', 16) || repeat('00', 8) || repeat('00', 16) || repeat('00', 32) || repeat('00', 16) || repeat('00', 16) || repeat('00', 8) || '50c3000000000000' || '020000000200000001000000010000000100000001000000010000000100000001000000' || repeat('b1', 32) || '00000000' || '00000000' || '01000000' || '6400000000000000' || repeat('a0', 32) || repeat('00', 80), 'hex'))" > /dev/null
PGDATABASE=v6_populated bash "$root/tools/migrate-postgres.sh"
test "$(PGDATABASE=v6_populated psql -XAtc "SELECT string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 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,64,65,66,67,68
test "$(PGDATABASE=v6_populated psql -XAtc "SELECT string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 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,64,65,66,67,68,69
test "$(PGDATABASE=v6_populated psql -XAtc "SELECT count(*) FROM evolution.region_commits c, LATERAL evolution.parse_checkpoint_manifest(c.manifest) m WHERE m.commit_sequence = 0 AND m.predecessor_commit IS NULL")" = 1
test "$(PGDATABASE=v6_populated psql -XAtc "SELECT string_agg(conname, ',') FROM pg_constraint WHERE conrelid = 'evolution.region_heads'::regclass AND contype = 'c' AND pg_get_constraintdef(oid) LIKE '%end_tick%'")" = region_heads_published_tick
phase permission-audit
@@ -305,9 +305,9 @@ expect_audit_failure 'REVOKE EXECUTE ON FUNCTION evolution.load_world_cellular_m
expect_audit_failure 'GRANT EXECUTE ON FUNCTION evolution.fork_restored_history_v1(uuid) TO evo_runtime_test' 'REVOKE EXECUTE ON FUNCTION evolution.fork_restored_history_v1(uuid) FROM evo_runtime_test'
phase checksum-drift
# Unknown future versions and checksum drift must not be repaired silently.
psql -X -v ON_ERROR_STOP=1 -c 'UPDATE evolution.schema_migrations SET version=69 WHERE version=68'
psql -X -v ON_ERROR_STOP=1 -c 'UPDATE evolution.schema_migrations SET version=70 WHERE version=69'
if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi
psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET version=68 WHERE version=69"
psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET version=69 WHERE version=70"
psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=14"
if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi
psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=13"
+3 -1
View File
@@ -152,6 +152,8 @@ digest_67="$(sha256sum "$root/migrations/0067_admin_take_and_cull.sql")"
digest_67="${digest_67%% *}"
digest_68="$(sha256sum "$root/migrations/0068_larger_region_ticks.sql")"
digest_68="${digest_68%% *}"
digest_69="$(sha256sum "$root/migrations/0069_admin_end_life.sql")"
digest_69="${digest_69%% *}"
psql -X --no-password --set=ON_ERROR_STOP=1 --set="migration_sha=$digest" \
--set="migration_sha_2=$digest_2" --set="migration_sha_3=$digest_3" \
--set="migration_sha_4=$digest_4" --set="migration_sha_5=$digest_5" \
@@ -203,6 +205,6 @@ psql -X --no-password --set=ON_ERROR_STOP=1 --set="migration_sha=$digest" \
--set="migration_sha_60=$digest_60" --set="migration_sha_61=$digest_61" \
--set="migration_sha_62=$digest_62" --set="migration_sha_63=$digest_63" \
--set="migration_sha_64=$digest_64" --set="migration_sha_65=$digest_65" \
--set="migration_sha_66=$digest_66" --set="migration_sha_67=$digest_67" --set="migration_sha_68=$digest_68" "${admin[@]}" \
--set="migration_sha_66=$digest_66" --set="migration_sha_67=$digest_67" --set="migration_sha_68=$digest_68" --set="migration_sha_69=$digest_69" "${admin[@]}" \
--set="runtime_role=$runtime_role" \
--file="$root/migrations/apply.sql"