knowledge: typed outputs for all 5 remaining signatures (block PR)

The typed-output migration completes: every knowledge signature now
declares its structure as Python types and dspy renders/parses it.

- TranslateSignature: queries/entities as list[str] — the
  'QUERIES:'/'ENTITIES:' line protocol and its prefix-scraping parser
  are gone
- AnswerFromKG: confidence is a local Confidence(str, Enum)
  (knowledge stays decoupled from floop)
- SelectTableSignature: chosen is TableChoice | None (index int,
  column, set_name) — 'NONE' string handling gone; origin_question
  dropped (it duplicated the input)
- SkimPromoteSignature: decisions as list[PromotionDecision]
  (table_index int, promote bool, column) — the 'idx: YES col' regex
  parser gone
- VerifyCountSignature: unchanged shape (quote str + NOQUOTE
  convention predates typed migration; kept — it is an answer-shaped
  field, not a format protocol)

Callers consume typed objects directly. Test fakes updated to the new
contracts (promote/store/guards).

VERIFIED:
- suite 14/14 green (84 tests)
- live E2E (ollama-cloud glm-5.3-flash, Italy rivers, fresh KG):
  correct answer 2014 m3/s (Po 1540 + Adige 235 + Tiber 239) with
  verified join; wire prompts show list[str]/TableChoice/Confidence/
  list[Fact] schemas rendered natively
This commit is contained in:
2026-10-22 15:11:33 +02:00
parent ce028b6973
commit 65d42d1942
5 changed files with 70 additions and 65 deletions
+4 -8
View File
@@ -11,6 +11,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parent.parent.parent)) # repo r
from knowledge.checks import check_candidate, quote_containment, trusted_source
from knowledge.chunker import chunk_page
from knowledge.extract import TableChoice
from knowledge.store import KnowledgeStore
@@ -225,10 +226,8 @@ def test_list_ingest_aggregate(tmp="/tmp/floop_kg_list.sqlite"):
def __call__(self, **kw):
class P: pass
p = P()
p.table_index = "1"
p.column = "Country"
p.set_name = "sovereign states in Europe"
p.origin_question = kw.get("question", "")
p.chosen = TableChoice(table_index=1, column="Country",
set_name="sovereign states in Europe")
return p
class FakeStore:
@@ -286,10 +285,7 @@ def test_list_ingest_aggregate(tmp="/tmp/floop_kg_list.sqlite"):
def __call__(self, **kw):
class P: pass
p = P()
p.table_index = "NONE"
p.column = ""
p.set_name = ""
p.origin_question = ""
p.chosen = None
return p
ke.select_table = FakeNonePicker()
assert ke._list_from_page(page, "irrelevant", None) is None