-- Runs inside apply.sql's transaction immediately before 0005 (ADR-0063). Not a -- migration and not recorded in history; it only refuses an unsafe upgrade. -- -- Pre-v5 published checkpoints (sequence > 0) may hold organisms that died with no -- durable decision row, because decisions did not exist before v5. The database -- cannot inspect payloads to prove otherwise, and v5 recovery requires one -- decision per terminal actor, so accepting them would make those regions -- unrecoverable (RecoveryError::history). Genesis-only regions are safe: a tick-0 -- state has no terminal organisms. Until an explicit, verified legacy-history -- conversion exists, refuse and change nothing. DO $$ BEGIN IF EXISTS (SELECT 1 FROM evolution.region_commits WHERE commit_sequence > 0) THEN RAISE EXCEPTION 'pre-v5 published checkpoints lack durable decisions; convert or re-provision before v5' USING ERRCODE = 'EVL10'; END IF; END $$;