fix(rectification): keep hour-window tail clusters and lock the search window (BUG-623, BUG-624, BUG-625)
Hour windows no longer drop later signature clusters. Credible range uses cluster coverage, and a mid-session spoken birth window gets a fixed reply without calling the model. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -402,16 +402,40 @@ def build_candidate_decisions(
|
||||
abs(score - other) <= TIE_ABSOLUTE_TOLERANCE
|
||||
for other in all_scores
|
||||
)
|
||||
cluster_times, cluster_start, cluster_end = _cluster_span(row)
|
||||
decisions.append({
|
||||
"candidate_id": str(uuid5(NAMESPACE_URL, f"{POLICY_VERSION}:{result_id}:{row['time']}")),
|
||||
"rank": index + 1,
|
||||
"time": row["time"],
|
||||
"relative_support": supports[index],
|
||||
"tied_minute_count": tied_minute_count,
|
||||
"cluster_times": cluster_times,
|
||||
"cluster_start": cluster_start,
|
||||
"cluster_end": cluster_end,
|
||||
})
|
||||
return decisions
|
||||
|
||||
|
||||
def _cluster_span(row: dict[str, Any]) -> tuple[list[str], str, str]:
|
||||
raw = row.get("cluster_times")
|
||||
times: list[str] = []
|
||||
seen: set[str] = set()
|
||||
values = raw if isinstance(raw, list) and raw else [row.get("time")]
|
||||
for item in values:
|
||||
text = str(item or "")[:5]
|
||||
if len(text) != 5 or text[2] != ":" or text in seen:
|
||||
continue
|
||||
seen.add(text)
|
||||
times.append(text)
|
||||
if not times:
|
||||
clock = str(row.get("time") or "")[:5]
|
||||
times = [clock] if len(clock) == 5 and clock[2] == ":" else []
|
||||
times.sort(key=lambda value: int(value[:2]) * 60 + int(value[3:5]))
|
||||
start = times[0] if times else str(row.get("time") or "")[:5]
|
||||
end = times[-1] if times else start
|
||||
return times, start, end
|
||||
|
||||
|
||||
def _gate(passed: bool, **details: Any) -> dict[str, Any]:
|
||||
return {"passed": passed, **details}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user