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
+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();