How does the BWA-MEM algorithm assign its mapping qualities?
Yes, there bwa-mem was published as a preprint


  BWA-MEM’s seed extension differs from the standard seed extension in two aspects. Firstly, suppose at a certain extension step we come to reference
  position x with the best extension score achieved at query position y.
  
  ...
  
  Secondly, while extending a seed, BWA-MEM tries to keep track of the
  best extension score reaching the end of the query sequence


And there is a description of the scoring algorithm directly in the source code of bwa-mem (lines 22 - 44), but maybe the only solution is really to go though the source code.