"""Choose a review batch from fabricated probabilities; no learning loop."""
import math,json
def entropy(probs):
    if any(p<0 or p>1 for p in probs) or not math.isclose(sum(probs),1):raise ValueError("probability vector required")
    return -sum(p*math.log2(p) for p in probs if p)
if __name__=="__main__":
    pool=[("A","g1",[.5,.5]),("B","g1",[.51,.49]),("C","g2",[.6,.4]),("D","g3",[.99,.01])]
    ranked=sorted(pool,key=lambda r:(-entropy(r[2]),r[0]))
    uncertainty=[r[0] for r in ranked[:2]]
    chosen=[];seen=set()
    for sid,family,probs in ranked:
        if family not in seen:chosen.append(sid);seen.add(family)
        if len(chosen)==2:break
    assert uncertainty==["A","B"] and chosen==["A","C"]
    scores={sid:entropy(p) for sid,_,p in pool}
    assert scores["A"]>scores["B"]>scores["C"]>scores["D"]
    print(json.dumps({"entropy_bits":scores,"uncertainty_only":uncertainty,"one_per_family_heuristic":chosen,"human_labels_collected":0,"model_trained":False},indent=2))
