model: move guards `lookup_first_definition` after cache miss