-- End one account's active life reservation so the account can be born again. -- -- DEV operator tool, run as the database owner, for an account whose cell has died but whose -- reservation was never ended. Before 2026-10-26 a region recorded a death under the dead -- cell's own identity; after the player had become a split's offspring, a bud or an organism, -- that identity was never reserved, so the founder's reservation stayed open and every new -- birth was refused ("Existing cell is already bound to this account"). -- -- Check first that the account has no living cell (the client shows the end-of-life screen). -- The reservation is ended at the region's latest commit, exactly as end_cellular_lives does; -- the region's checkpoints and history are left unchanged. The founder named by the -- reservation may still live on as wildlife; that is expected. -- -- `account` is the account id or its leading hex digits (the region logs show acct-xxxxxxxx). -- It is a dry run unless confirm=yes, and refuses unless exactly one active reservation -- matches. -- -- psql -X -v world=100 -v region=14 -v account=807813d1 -f end-account-life.sql -- psql -X -v world=100 -v region=14 -v account=807813d1 -v confirm=yes -f end-account-life.sql \set ON_ERROR_STOP on \if :{?world} \else \echo 'usage: psql -v world=W -v region=R -v account=HEX [-v confirm=yes] -f end-account-life.sql' \quit \endif \if :{?region} \else \echo 'usage: psql -v world=W -v region=R -v account=HEX [-v confirm=yes] -f end-account-life.sql' \quit \endif \if :{?account} \else \echo 'usage: psql -v world=W -v region=R -v account=HEX [-v confirm=yes] -f end-account-life.sql' \quit \endif \if :{?confirm} \else \set confirm no \endif BEGIN; SELECT set_config('ending.world', :'world', true), set_config('ending.region', :'region', true), set_config('ending.account', :'account', true); DO $$ DECLARE w numeric := current_setting('ending.world')::numeric; r numeric := current_setting('ending.region')::numeric; prefix text := lower(replace(current_setting('ending.account'), '-', '')); latest uuid; matches integer; reserved evolution.life_reservations%ROWTYPE; BEGIN IF w <= 0 OR r <= 0 OR prefix !~ '^[0-9a-f]{4,32}$' THEN RAISE EXCEPTION 'world and region must be positive and account at least 4 hex digits'; END IF; SELECT count(*) INTO matches FROM evolution.life_reservations x WHERE x.world_id = w AND x.region_id = r AND x.rejection = 0 AND x.ended_commit IS NULL AND replace(x.account_id::text, '-', '') LIKE prefix || '%'; IF matches <> 1 THEN RAISE EXCEPTION '% active reservations match account % in region %; expected exactly one', matches, prefix, r; END IF; SELECT * INTO reserved FROM evolution.life_reservations x WHERE x.world_id = w AND x.region_id = r AND x.rejection = 0 AND x.ended_commit IS NULL AND replace(x.account_id::text, '-', '') LIKE prefix || '%' FOR UPDATE; SELECT c.commit_id INTO latest FROM evolution.region_commits c WHERE c.world_id = w AND c.region_id = r ORDER BY c.commit_sequence DESC LIMIT 1; IF latest IS NULL THEN RAISE EXCEPTION 'region % of world % has no commit', r, w; END IF; IF NOT EXISTS (SELECT 1 FROM evolution.primitive_life_bindings b WHERE b.world_id = w AND b.account_id = reserved.account_id AND b.request_id = reserved.request_id) THEN UPDATE evolution.life_reservations x SET rejection = 3 WHERE x.world_id = w AND x.account_id = reserved.account_id AND x.request_id = reserved.request_id; RAISE NOTICE 'account %: unpublished reservation % cancelled', reserved.account_id, reserved.identity; ELSE UPDATE evolution.life_reservations x SET ended_commit = latest WHERE x.world_id = w AND x.account_id = reserved.account_id AND x.request_id = reserved.request_id; RAISE NOTICE 'account %: life % ended at commit %', reserved.account_id, reserved.identity, latest; END IF; END $$; \if :confirm COMMIT; \echo 'committed' \else ROLLBACK; \echo 'dry run: nothing changed (add -v confirm=yes to apply)' \endif