Inspired by this article, and this two-year-old question on Travel SE, I am wondering what a traveler should do when their travel documents are accidentally left in baggage that is checked-in at the gate, and not earlier. As gate-checking is more common nowadays, especially in flights across Europe and North America, I'm wondering if this poses different challenges at immigration, and whether immigration authorities are aware of this, since it is now much more likely than before that a passenger accidentally leaves their travel documents in baggage that gets checked in.
My question, therefore, is: assuming that a passenger has all the correct documents to enter their destination country, what steps should they take on arrival if these documents are accidentally left in baggage that gets gate-checked?