fix: two-pass Pass 2 needs the chunk text (quotes were invented) + claim cap

Live cloud run 20261026-164236 found both on the wire:
1. TypeClaim carried ONLY the claim — the model could not copy the
   verbatim quote from anywhere, so it invented one and the containment
   check rejected 69/70 candidates (the safety net working, the
   CONTRACT wrong). Fix: TypeClaim gains the chunk text; the model finds
   the real quote there ('find the VERBATIM quote here, copied exactly').
2. One charge per claim starved the budget: ~70 claims ate all 80
   llm_calls before Q2 (80/80, baseline fallback, no FINAL). Fix:
   max_claims_per_chunk=6 (each claim costs a TYPE call; without a cap
   one big article starves the run).

The speed win is real and kept: CLAIMS 14-20s/chunk, TYPE 2.8-8s/claim
(the 40-minute output budget is gone). Honest note: the cap bounds per
chunk, not the whole run (3 articles x 6 chunks x 7 calls ~ 126 > 80)
— if the run starves again, next lever is claim selection or a lower
cap, his call.

TDD: two_pass_extract 5/5 on the new contract (TypeClaim fields
{claim,text,fact}). Suite: 29 test files green.
This commit is contained in:
2026-10-26 17:05:10 +01:00
parent 88769c508c
commit a9837981b3
4 changed files with 32 additions and 18 deletions
+8 -2
View File
@@ -164,6 +164,10 @@ class KnowledgeConfig:
semantic_tau: float = 0.45 # calibration: rivers 0.49-0.52 in, Pedro
# cross-question 0.35-0.38 out, spouse-noise ~0.67
max_facts_per_chunk: int = 12 # question-blind extraction needs a cap
max_claims_per_chunk: int = 6 # two-pass: each claim costs a TYPE call —
# the budget is finite (80/run); without a
# cap one big article starves the run
# (live finding 26/10: 70 claims -> 80/80)
extract_mode: str = "two_pass" # "two_pass" (claims -> typed Facts, short
# outputs) | "single" (legacy one-call typed
# array — table frags keep using it)
@@ -1179,8 +1183,10 @@ class KnowledgeExpert:
claims = claims_from(self, entities=ent_str,
heading=chunk.heading_path,
text=chunk.text, charge_llm=charge_llm)
for claim in claims[: self.cfg.max_facts_per_chunk]:
fact = fact_from_claim(self, claim, charge_llm=charge_llm)
# budget law: each claim costs a TYPE call — cap per chunk
for claim in claims[: self.cfg.max_claims_per_chunk]:
fact = fact_from_claim(self, claim, text=chunk.text,
charge_llm=charge_llm)
if fact is None:
continue # honestly declined: no invention
merged, _eid = self._ingest_candidate(