Precise Mechanical Rigging (Intuitive method)
After a lot of trial and error here's what I could come up with.
It is not perfect and will glitch out at extreme cases, but otherwise works for the most part.

It relies on a system of three empties and relations between them.




The $Start$ $Empty$ - Has a Location constraint to prevent it from going anywhere away from $-0.90$ to $0.90$ in the $X$ axis





The $End$ $Empty$ - Has a Location constraint to prevent it from going anywhere away from $-0.90$ to $0.90$ in the $X$ axis and $0.2$ to $1.8$ in $Z$ direction. Additionally it as a Limit Distance constraint set to On Surface preventing it go further away than $1.8$ from $Start$ $Empty$





Lastly $Tracking$ $Empty$ is parented to $Start$ $Empty$ and has a locked track to the $End$ $Empty$.





The $Upper$ $Arm$ also has a Copy Location on $Z$ axis only from $End$ $Empty$so it keeps position correctly automatically