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
+68
View File
@@ -243,4 +243,72 @@ chunker.py, extract.py, check.py, search.py, expert.py, tests/…}` +
3. **Draft search scope**: Wikipedia-only first (recommended) vs adding a
general-web search provider in the same cut.
4. **Chunk target**: 8k tokens with 12k cap inside your 16–32k window —
## 11. Lists and tables — two different problems (2026-10-18)
**Full table ingestion vs answer completeness are different problems with
different owners.** Emili's distinction, formalized:
1. **Full table ingestion (mechanical, always achievable).** Every table row
the parser finds is ingested — no silent truncation, no gate dropping rows.
The parser (deterministic) computes `total_rows`; that number is a computed
fact, not a judgement. "Bigger than the chunk" is solved structurally: in
the LIST path the LLM never sees the whole table — it only picks WHICH
table and WHICH column is the enumeration (one cheap call, language work);
fixed code ingests ALL rows and aggregates (thinking, zero calls). The
table is never "chunked"; the problem disappears by design.
2. **Answer completeness (epistemic, often NOT assure-able, always flag-able).**
A fetched table is complete *per source*; whether the ANSWER is complete
depends on the sources consulted (partial articles, A–M / N–Z splits).
Presence of rows proves membership; it never proves absence of unseen
members. Every LIST answer therefore carries a typed `coverage` record —
a computed flag, not a promise: what was consulted, what fraction of the
candidate space was exhausted. floop is *aware* when completeness is
guaranteed (one table, fully parsed) and when it is not (search space not
exhausted). Part 2 (pending): surface the flag up to the machine so the
synthesizer can say "27 of 52 ingested" honestly; and the planner can
open "fetch the N–Z article" as an ordinary subquestion when coverage
says the space is not exhausted.
### The LIST answer path (part 1, implemented in the draft)
When a question is answered by an enumeration from a fetched source:
1. **SELECT TABLE** (LLM, one call): given the question and the list of
tables found in candidate articles (title + headers + row count, NOT the
rows), pick the table that enumerates the answer. Output: article title +
table index + the column holding the answer elements.
2. **INGEST ROWS** (code): the chosen table's rows become membership edges —
one edge per element (`<element> | member_of | <set>`), quote = the full
stored table row, containment-checked against the stored table text.
All rows, no truncation, no gate.
3. **AGGREGATE** (code): the answer value = sorted unique elements; the
count = `len()` — never an LLM call.
The result enters the evidence table as a typed payload:
```python
{"value": "27", "list_items": ["Albania", ...], "list_count": 27,
"quote": "<first row>", "url": "...",
"coverage": {"source": "<article>", "rows_ingested": 52, "rows_total": 52,
"complete_per_source": true}}
```
**Why per-row membership edges (not one fat edge).** One edge per element
keeps the KG honest: each element carries its own quote and URL, conflicts
and corroboration work per element, and set operations (filter, difference,
count) are graph queries in deterministic code — the exact operations Q2–Q4
of the Europe plan needed. The set node (e.g. `countries of Europe`) is an
ordinary node; membership is an ordinary edge; nothing new in the schema.
**Containment target for table rows.** The quote of a membership edge is the
full stored table row (post-`_clean_cell`, the canonical text). It is checked
against the stored table text — the same string the parser produced — so the
check stays verbatim and deterministic. The wikitext raw form is kept in the
document artifact for audit.
**Budget law in the LIST path.** TRANSLATE + SELECT TABLE are the only LLM
calls (2 + retries); ingestion and aggregation are free. A 500-row table
costs the same LLM budget as a 5-row one — the cost of an enumeration is
O(1) in the size of the list.
confirm or set preferred numbers.