-- Missing historical authority is deliberately not inferred from current state. ALTER TABLE gui_publications ADD COLUMN computer_authority JSONB; -- Keep obsolete history out of the current-assignment candidate lookup. The -- worker still revalidates authorization after claiming, before any RPC. CREATE INDEX gui_publication_current_claim ON gui_publications(computer_id,bot_id,(request->'claim')) WHERE status='pending' AND owner_user_id IS NOT NULL AND owner_space_id IS NOT NULL AND computer_authority IS NOT NULL; CREATE INDEX gui_publication_unexpired ON gui_publications(((request->>'lease_expires_at_ms')::BIGINT)) WHERE status='pending' AND owner_user_id IS NOT NULL AND owner_space_id IS NOT NULL AND computer_authority IS NOT NULL;