The algorithm used to select whether a conflicting proof should be preferred over the others can be split in 2 categories:
If the proof master key is the same, then consider the replacement to be legit: after D10140 the proof needs to be signed by the proof master key owner. In this case the sequence number can be used to determine if the proof is to be replaced.
In the event the proof master is different, things are different. After D10151 it becomes possible to participate to a pooled proof by signing somebody else's (here the pool) master public key with the stake key. This lets the user the possibility to stake its utxo in a pool, and at the same time generate a conflicting proof with another master pubkey he owns. In order to prevent an adversarial user from maliciously generate such conflicting proofs and invalidate the whole pool, if the master public key from the conflicting proof mistmatch the current one, it is required to stake more coins in order to take precedence. If the amount is the same, then the lowest number of stakes is used (which means the utxos have more coins in average), and finally the proofid in case of equality.
Note that the latter case will only become useful once the staked coins are locked, which is not implemented yet. In the meantime a user can just move the coins to invalidate the proof. The algorithm accounts for the future case in order to not be a breaking change in the future.
Ref T1854.
Depends on D10221.