obligation to render justice? related to, but not the same as Does Buddhism have a significant notion of justice

I need some clarification.  What is one's moral obligation to render justice (or bring to justice) others for observed misdeeds?  this can but need not be as member of a jury which must render justice.

it is clear that one should sympathize with the perpetrator.  it is clear that one should not get emotional over a (passed) misdeed or over (or while) rendering a sentence.

I am guessing that to be compassionate is to contemplate the effects of a sentence on other sentient beings, [a] in light of the future incentives that one's judicial actions will create, and [b] in light of the contemporaneous effect that one's sentence will have on the perpetrators, victims, and others.  even though the deed was done and thus has passed, and even though others should be philosophical about it now, it is still true that a sentence can improve the lives of many others at the cost of worsening the life of the perpetrator.  [there is no dilemma if the latter is not the case.]

is there more Buddhist advice to us here?
because with a worldling justice is being served from a defiled mind, the intentions can't ever be completely pure and so justice will eventually not be just

i think the most Buddhist advice would be to refrain from rendering justice as much as possible, the law of kamma will in due course take care of that anyway



in response to the comment below


  If anyone gives those bhikkhunis a blow with his hand, with a clod,
  with a stick, or with a knife in your presence, you should abandon any
  desires and any thoughts based on the household life. And herein you
  should train thus: 'My mind will be unaffected, and I shall utter no
  evil words; I shall abide compassionate for his welfare, with a mind
  of loving-kindness, without inner hate.' 
  
  If anyone should give you a blow with his hand, with a clod, with a
  stick, or with a knife, you should abandon any desires and any
  thoughts based on the household life. And herein you should train
  thus: 'My mind will be unaffected, and I shall utter no evil words; I
  shall abide compassionate for his welfare, with a mind of
  loving-kindness, without inner hate.' That is how you should train,
  Phagguna.


Kakacupama sutta (MN 21)

to be sure, bearing no ill-will towards the perpetrator doesn't negate bringing him/her to justice, but the very act of bringing to justice is certainly not dissimilar to taking revenge, because that particular moment occurs after the fact, by the time the victim or the object of the crime is usually out of danger, and deprivation a person of freedom for X amount of time isn't after all an act of compassion or benevolence