store/expert/machine: keep source order end-to-end; refuse fake top-N
log-09 bug: a KG-served set answered the fan-out top-3 with adda, adige, arno — the alphabetical list_members order masquerading as a ranking. - edges.list_ord (auto-migrated): each member_of edge records its row position in the source table; list_members(ordered=True) returns source order, list_is_ordered() tells whether the set has proven order - ingest writes ordinals; fresh-serve and _serve_set keep table order and set coverage.ranked accordingly - fan-out top-N: slices ONLY ranked lists; an unranked list refuses the slice, expands all entities, and says so in notes + thinking (never silently alphabetical) - regression test: Po/Adige/Tiber first; unordered set -> all expanded
This commit is contained in:
+19
-6
@@ -219,14 +219,27 @@ class FloopRun:
|
||||
|
||||
def _expand_fanout(self, q: OpenQuestion, fan: tuple[str, list[str]]) -> None:
|
||||
list_eid, items = fan
|
||||
# top-N slice: 'for each of those three rivers' over a 22-row ranked
|
||||
# table means the TOP 3 by table order (ranked tables rank; the slice
|
||||
# is honest and logged, the value-ranked top-N is part (c))
|
||||
# TOP-N HONESTY: 'those three rivers' over an ordered (ranked) list
|
||||
# is the top 3 by table order. An UNORDERED list has no top-N —
|
||||
# slicing it silently answered alphabetical trivia (2026-10-20:
|
||||
# adda, adige, arno instead of Po, Adige, Tiber). Refuse instead.
|
||||
n = self._fan_count(q.text)
|
||||
if n and 0 < n < len(items):
|
||||
items = items[:n]
|
||||
self.notes.append(f"{q.qid}: fan-out sliced to top {n} of "
|
||||
f"{len(fan[1])} by table order (ranked list assumed)")
|
||||
list_row = self.table.row(list_eid)
|
||||
ranked = (list_row.payload.get("coverage") or {}).get("ranked", False) \
|
||||
if list_row else False
|
||||
if ranked:
|
||||
items = items[:n]
|
||||
self.notes.append(f"{q.qid}: fan-out sliced to top {n} of "
|
||||
f"{len(fan[1])} by table order (ranked list)")
|
||||
else:
|
||||
self.notes.append(
|
||||
f"{q.qid}: fan-out REFUSED top-{n} slice — the list has no "
|
||||
f"proven order (ingested before ordinals or unranked source); "
|
||||
f"all {len(items)} entities expanded")
|
||||
self.streams.state(
|
||||
f"fan-out warning: top-{n} asked but the list is not "
|
||||
f"ranked — expanding all {len(items)} entities", think=True)
|
||||
attribute = self._attribute_of(q.text)
|
||||
self.streams.call("FANOUT", f"expanding {q.qid} into {len(items)} entity questions",
|
||||
think=self.tprefix + f"fan-out: {q.qid} over {list_eid}'s "
|
||||
|
||||
Reference in New Issue
Block a user