Prioritize investigation hypotheses by confidence after bootstrap

This commit is contained in:
Nico committed 2026-10-15 15:16:38 +02:00
1 parent f4082585ae
commit c44ccd5ce3
5 files changed
+128 -2

No files matched your search

@@ -0,0 +1,27 @@
"""Deterministic scheduling, independent of model calls and budget accounting."""
CONFIDENCE_ORDER = {
'strongly_supported': 5,
'supported': 4,
'plausible': 3,
'unassessed': 2,
'weak': 1,
'weakened': 0,
}
def priority_order(hypotheses):
"""One bootstrap turn each, then confidence with numeric ID tie-breaking.
Eligibility, pending-action checks and iteration/budget limits remain the
controller's responsibility. An interrupted active turn is never rescheduled.
These ranks order qualitative levels; they are not confidence probabilities.
"""
ids = sorted(hypotheses, key=lambda hid:int(hid[1:]))
positions = {hid:index for index,hid in enumerate(ids)}
def rank(hid):
hypothesis = hypotheses[hid]
return (0 if hypothesis['iterations']==0 else 1,
0 if hypothesis['iterations']==0 else -CONFIDENCE_ORDER[hypothesis['confidence']],
int(hid[1:]))
return [(positions[hid],hid) for hid in sorted(ids,key=rank)]
@@ -239,8 +239,9 @@ class Investigator:
snapshot=budget.snapshot(case_id,package_id)
ids=sorted(state["hypotheses"],key=lambda value:int(value[1:]))
selected=None
for offset in range(len(ids)):
pos=(state["cursor"]+offset)%len(ids);hid=ids[pos];h=state["hypotheses"][hid];account=snapshot.state["accounts"][hid]
from .investigation_scheduler import priority_order
for pos,hid in priority_order(state['hypotheses']):
h=state["hypotheses"][hid];account=snapshot.state["accounts"][hid]
if h["disposition"]!="active":continue
if any(a["status"]!="settled" for a in account["actions"].values()) and h["last_record_ref"] is None:
raise InvestigationError("INVESTIGATION_UNOWNED_PENDING_ACTION")