feat(knowledge): LIST answer path — full table ingestion, typed list payloads

Part 1 of the lists design (DESIGN.md §11): mechanical full ingestion, separated from epistemic answer-completeness. parse_tables rewritten as a GRID parser: cells accumulate until |- (both layouts), empty cells kept as placeholders (image cells clean to ''; dropping them shifted France rows to start at 'FRA'), rowspan/colspan expanded at placement, total_rows is the computed extent — no truncation. _clean_cell: refs/sup/File links dropped, citation templates (cref2/efn...) resolve empty, links take display text, attrs split first. LIST path in expert.py: deterministic enumeration detection OR planner-declared LIST; SELECT TABLE (one LLM call over table metadata, never rows); ingest ALL rows as member_of edges (quote = full row line, containment against stored table text); aggregate via len() — no LLM. AnswerType.LIST added; evidence payloads carry list_items + coverage. Verified live cold: 50 sovereign states from the Europe article table (51 rows - Total footer), every member with verbatim quote. 19/19 tests.
This commit is contained in:
2026-10-18 16:53:10 +02:00
parent a78f65de2c
commit 6fcb3c0a86
9 changed files with 480 additions and 40 deletions
+13
View File
@@ -47,6 +47,19 @@ class AnswerFromKG(dspy.Signature):
confidence: str = dspy.OutputField(desc="high medium low")
class SelectTableSignature(dspy.Signature):
"""You are the SELECT TABLE step of a knowledge machine. Given a question
and the tables found in an article (index, caption, header columns, row
count — NOT the rows), decide: does one of these tables enumerate the
answer? Output the table index and the column holding the answer
elements, or NONE."""
question: str = dspy.InputField()
tables: str = dspy.InputField(desc="one line per table: 'idx | caption | header: a, b, c | rows: N'")
table_index: str = dspy.OutputField(desc="the chosen table index (e.g. '2'), or NONE")
column: str = dspy.OutputField(desc="header name of the column holding the answer elements; empty if NONE")
set_name: str = dspy.OutputField(desc="short name of the set this table enumerates, e.g. 'sovereign states in Europe'; empty if NONE")
def parse_facts(raw: str) -> list[dict]:
"""Parse the extractor's piped lines; malformed lines are dropped+counted.