Mexico is derelict in its border enforcement, partly because the authorities are corrupt and incompetent, but also because immigrants fleeing poverty who get to Mexico aren't interested in staying there, they're on their was to the US, these are transients just passing through.
I assume that, if one were to use your definition of "derelict" one would have to conclude that the East Germans (with their walls and practice of machine gunning those attempting to leave the country) would NOT qualify as "derelict".
Under the applicable international treaties and conventions, immigrants fleeing a well-founded fear of persecution are supposed to be granted asylum as soon as they reach safety.
Really?
Would you like to produce some evidence on that point? Would you like to produce some evidence as to exactly how "safety" is defined?
I do know that Canada and the US have a "Safe Third Country" treaty under which each accepts that the other is a "safe" country such that they do not accept "refugees" from the other (in most cases). Would you like to provide a link to the parallel US/Mexico treaty?
In the case of these migrant caravans of thousands making their way across Mexico, they should have all been granted asylum by Mexico ...
Those who ASKED FOR asylum in Mexico were granted it.
There is no international law which says that a country can FORCE "asylum" on people fleeing from another country.
I'm not sure Trump can restrict granting asylum to those who enter illegally, a clear legal contradiction arises over legislation which recognizes the right to claim asylum anywhere in the US and Trump's proposal to require this only be done at a legal entry point.
The odds on that fact having penetrated Mr. Trump's thinking are low. The odds that he is concerned about the fact that his action may be contrary to the laws of the United States of America are even lower. The odds that he knows that, regardless of whether his action is legal, his action will appeal to his "base" are incredibly high.
Another contradiction is that an applicant for asylum can be rejected for criminal activity, but crossing into the US without going through a legal entry point is a crime.
To be very specific (and that is what you have to do when dealing with the actual laws), "crossing into the US without going through a legal entry point" is NOT a crime - "entering the US without complying with the legal and procedural requirements", on the other hand, is a crime.
That may seem like an incredibly picky point, but that is what the law is all about.
FYI, the distinction between "crossing" and "entering" is (essentially) the presence or absence of an intention to remain without complying with the legal requirements.
Finally there's the problem with the number of refugee visas annually allocated, what happens to a meritorious claimant who exceeds the quota?
That one is easy, they don't get a visa and go back into the pool.
I suppose they go on a waiting list, ...
They don't have any priority and face the same competition the next year that they faced in the current one. There is also, if my memory serves, a time limit on how long the application for a visa remains valid (so once the applicant has been in the "application approved (subject to availability of visa)" pool past that time they have to re-apply from scratch.
... but I doubt there are ever unclaimed refugee visas, last year 130,000 Hondurans applied for asylum, but the total number of US refugee visas (for the whole world) was about 55,000.
There actually are "unclaimed visas" since that total is actually broken down by country and some countries simply don't have enough applicants to use up the number of visas available for applicants from those countries. The unused visas are pooled and then awarded through the so-called "visa lottery".