Rule Learning for Knowledge Graph Reasoning under Agnostic Distribution Shift