Commit Graph
26 Commits
Author SHA1 Message Date
onibot 9cfc068ad6 research: conflicts taxonomy + temporal restrictions + derived answers (design docs)
Findings from the 24-25/10 session (live runs, glm-5.3-flash):
- The A/B (his question, cold KG): glm cloud 148s -> Rajoy; qwen local
  50min -> honest UNKNOWN (KG held Rajoy; a noise row misled it).
- The (K5) bug: judge value contamination kills the ablation audit
  silently; repro shows the detector works with a clean value.
- dspy disk cache replays repeated runs (measurement law recorded).
- The conflicts inventory: 20 pairs, zero real contradictions — the
  4-case classifier conflates conjunction/paraphrase/temporal/polisemia.

RESEARCH-derived-answers.md: the design growing from all of it:
merge-time taxonomy (co-asserted / temporal / alternatives / real),
temporal restrictions (not Allen labels) on the typed Fact extractor,
and a derived-answer engine (typed query DSL + goal-directed proof,
no LLM judge in the loop). Span: knowledge/ + floop/ — doc at code/.
2026-10-25 15:28:32 +01:00
onibot 522341a1f3 research(knowledge): live E2E findings — machinery works; two open traps
Pedro run: semantic probe + blind extraction live; answer fell into a
reading trap (3rd gov succeeded his own 2nd -> 'himself'), the Pedro
article was fetched-but-starved by early exit. Rivers run: LIST path
green; budget death by fan-out ROUTE spending (22x2 calls for data the
parent table held; join never ran). Both are machine-level issues
logged as next work on this branch, not regressions of the redesign.
2026-10-23 08:45:01 +02:00
onibot 872d4b9d42 research(knowledge): semantic KG retrieval + question-blind extraction
Implements his design (RESEARCH-semantic-kg.md) on the research branch:

1. EMBEDDINGS (knowledge/embeddings.py): local ollama /api/embed,
   nomic-embed-text 768d — the only proven endpoint (ollama.com has
   NO embeddings API). Honest failure: EmbedderDown -> lexical probe
   fallback, never a dead run.

2. SEMANTIC PROBE: edge_vectors cache in the store (keyed edge_id +
   model + text_hash; upsert, last model wins), cosine rank over all
   cached edges, tau=0.45 from real calibration (rivers 0.49-0.52 must
   pass; cross-question Pedro-vs-rivers 0.35-0.38 must not). Hybrid
   _probe: lexical UNION semantic, dedup by eid. EdgeView gains eid.

3. QUESTION-BLIND EXTRACTION: ExtractSignature loses 'question' and
   stop_table — it receives ENTITIES only (from TRANSLATE + evidence
   + proper nouns) and transcribes their facts, capped per chunk
   (max_facts_per_chunk=12). Facts cache vectors at ingest. The KG
   fattens per-entity, reusable across questions (his cacheability
   argument).

4. STOP MOVES TO THE SKIM: SkimTableSignature decides per table from
   caption+header+row count+first rows (one LLM call per page) BEFORE
   any extraction spend; tables that literally name an entity skip the
   call. The extractor itself never judges relevance.

VERIFIED: knowledge suite 8/8 (semantic.py new 4/4: lexical-missed edge
surfaced, hybrid dedup, embedder-down degradation, cache upsert;
tablefrags adapted: skim kills tables pre-extract). floop suite 9/9.
Live E2E (glm): semantic probe fires live (+1 lexical-missed edge);
blind extractor ingests 12-fact chunks; Pedro run answers 'himself'
(3rd gov succeeded his 2nd — a reading trap, NOT a retrieval failure;
INIT degraded honestly on garbage); rivers run burned budget on
fan-out ROUTE calls (22x2) — both findings logged as open work on the
research doc, not regressions of this PR.
2026-10-23 08:44:36 +02:00
onibot ca60442570 research(knowledge): semantic KG retrieval + question-blind extraction (doc only)
His diagnosis after the local qwen run (no ambiguity flagged, 'Spain'
after a long search, '15' as a term-start): the question-conditioned
extractor filters rows BEFORE the audit can see them — alternative
readings never enter the store.

The redesign (his proposal + agreed refinements, OPEN QUESTIONS, and
a verification plan) lives in knowledge/RESEARCH-semantic-kg.md.
Research branch by design: parkable — if it stalls we continue from
main (other experts / pending backtracking). No code yet.
2026-10-22 23:53:39 +02:00
onibot c257e9fe88 knowledge: rename ExtractSignature.stop -> stop_table (his review)
The field's purpose was unclear from its name; stop_table says what it
stops. Renamed across the signature, its desc/docstring, the caller
(raw.stop_table), the wiki.py legacy note, and the test fakes.
2026-10-22 16:26:03 +02:00
onibot 65d42d1942 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
2026-10-22 15:11:33 +02:00
onibot 109885773c knowledge: typed Fact extraction via dspy native structured output
His direction: stop explaining string formats to the LLM and parsing
them back with Python — that's exactly what dspy does natively and
better. The pipe format ('subject | relation | object | quote') was
fragile (run-L verbose values, pipe-in-quote ambiguity, STOP_TABLE
string protocol).

THE CHANGE (extractor only, PR-10 scope):
- Fact(BaseModel) with subject/relation/object/quote OutputFields
- ExtractSignature.facts: list[Fact] — the adapter renders the JSON
  schema into the prompt itself (verified in a live run's prompt log)
  and parses responses back into typed Fact objects
- STOP_TABLE string protocol -> stop: bool OutputField
- expert.py consumes typed objects; the cand dict is built at the
  check_candidate boundary only (checks.py unchanged)
- parse_facts/parse_stop_table kept as LEGACY for existing tests only

VERIFIED:
- dspy 3.4.1 pattern E2E'd first with a raw-text engine: list[Fact]
  parses back as Fact objects, schema rendered in prompt (tmp probes)
- full suite 12/12 green (74 tests) — tablefrags.py updated to script
  typed Fact objects
- live E2E run (ollama-cloud glm-5.3-flash, Italy rivers): correct
  Po/Adige/Tiber answer; prompt log shows the native JSON schema;
  table rows ingested cleanly (22 rows, quotes verbatim)

NEXT (his direction, not this PR): apply the same typed-output law to
ALL floop signatures — INIT subquestions, ROUTE engine choice,
AnswerFromKG, SelectTable, SkimPromote, Translate, VerifyCount.
2026-10-22 14:21:13 +02:00
onibot efd539c128 knowledge+llm: dst-first ablation mask (run L) + re-ask budget meter
Two fixes from his 22/10 re-run log, both small and deterministic:

1. THE ABLATION MASK WAS QUOTE-BLINDED (run L: Q1 stayed silent over
   the Pedro page that run J flags). The Pedro paragraph interleaves
   all three readings in ONE quote ('...Secretary-General ... ninth
   president of Socialist International...'), and _carries matched
   the picked value by substring over dst OR quote — so masking SI's
   support masked the PM/PSOE rows too; round 1 answered UNKNOWN and
   the audit died silent. The DST-FIRST LAW: when a row has a
   meaningful dst (non-empty, non-numeric) it is the VALUE BEARER and
   the mask matches IT; the quote is a fallback only for
   empty/numeric dsts. Same law in _carries_target for each round's
   surviving value, with one addition: the judge's round value may be
   an OFFICE DESCRIPTION ('prime minister of Spain') while the row's
   dst is the ENTITY ('Spain') — resolve by reciprocal token
   containment, or the loop dies after one alternative.

2. THE ADAPTER RE-ASK WAS INVISIBLE TO THE BUDGET (run L: prompts #9
   and #10 were both ANSWER — #10 5 chars shorter, 340s, the
   ChatAdapter's JSON-fallback second wire call after a parse
   failure; llm_calls said 9/80 while 10 hit the wire). THE METER:
   the prompt-log callback already sees every LM call — a second LM
   call with NO new module forward between them is the adapter
   fallback re-firing inside the same Predict. Count it, log the
   line, and charge the budget through a meter hook the machine
   wires at construction. A re-ask at the ceiling does not kill the
   run (the call already happened). dspy's BEHAVIOUR IS UNTOUCHED —
   his call: the fallback stays, it is future self-improvement
   signal (which prompts the model formats badly), not a bug.

Tests: knowledge/tests/ablation.py +3 — run-L regression (interleaved
one-paragraph quote flags all three readings), office-description
resolution, numeric-dst quote fallback. tests/reask_meter.py +3 —
fallback detected and charged on the REAL adapter path (custom engine
returning raw text, marker-less first response), separate forwards NOT
flagged (the ablation-rounds shape), ceiling charge survives. Suite
12/12 files green (74 tests). Live smokes: the run-L interleaved-quote
page flags SI+PM+SG through the full pipeline; the run-J
separate-quotes smoke still passes.
2026-10-22 11:21:25 +02:00
onibot 8b50e3076e knowledge: replace curated-vocab ambiguity audit with ablation detector (run J)
PR-7's audit (merged hours earlier) detected office ambiguity with a
curated role vocabulary (president, prime minister, ...) plus entity
and shape heuristics. His run-K log killed it: all three alternatives
came out '[prime minister]', Mariano Rajoy (a person, not an office)
was one, PSOE never appeared — the vocabulary could not see the
difference. His design replaces it, and it is better: instead of
listing what counts as a role, ask the judge whether the question
STILL answers once the support for the picked value is masked out.

_audit_ambiguity (knowledge/expert.py), zero new prompts:
- After a scalar KG answer V, find V's support rows (dst/quote carry
  the value) and MASK them from the view — the store is never
  mutated, the mask is a Python-level view.
- Re-ask the SAME judge (AnswerFromKG) on the surviving rows.
  A DIFFERENT value = a second defensible reading -> record, mask
  its support too, repeat (ambiguity_rounds=3, budget law).
- Same surviving value = corroboration -> silent stop.
- UNKNOWN -> clean answer, byte-identical to pre-audit behaviour.
- Run J: pick 'Socialist International' -> ablation surfaces
  'prime minister of Spain' then 'secretary-general of PSOE' — the
  third paragraph reading, no role vocabulary anywhere.

Removed: knowledge/ambiguity.py + knowledge/tests/ambiguity.py
(PR-7), the .ambiguity import, and _maybe_ambig at the three scalar
return paths — replaced by _audit_ambiguity(question, answer, rows,
charge_llm) at the same three sites.

Consumers (engine/machine) now render the simpler alternative shape
{value, quote, url} — no 'role' field exists to render.

Tests: knowledge/tests/ablation.py — the 4 agreed cases (2 Pedro
positives flag with 2 alternatives each, EU and rivers
counterexamples silent), corroboration-not-ambiguity, store
unchanged after audit (mask is a view), single-source silent, rounds
cap. Suite 70/70. Live smoke: full pipeline over the run-J page
picks SI and flags PM+SG via two ablation rounds; the rivers
question over the same KG stays silent.
2026-10-21 23:42:20 +02:00
onibot a43d827098 knowledge: deterministic ambiguity audit for office questions (run J)
Run J answered 'What office is Pedro Sanchez associated with as
President?' with Socialist International — a literally defensible
reading, but the KG ALSO held prime minister of Spain and
secretary-general of PSOE, and the machine never learned they existed.
The fix is not prompt tuning: it is a data type the pipeline could not
express — 'this answer is one of several defensible readings'.

Layer 1 (this PR) — knowledge/ambiguity.py, zero LLM, zero network:
- GATE: role_in_text(question) — only questions naming an office-class
  role (president, prime minister, secretary general, chancellor, ...)
  enter the audit. 'second most populated country in European Union'
  and 'three longest rivers in Italy' never even run it.
- ref_entity: the question's proper-noun run, broken at lowercase words
  and role words — 'Pedro Sanchez' (not 'President'), 'France' in
  'Who is the President of France?'.
- audit_role_multiplicity: rows about the entity whose role lives in
  the relation OR the object (extraction shape varies); dates and bare
  numbers never become alternatives; same office in two shapes merges
  by token containment (quote kept, corroboration summed); the PICKED
  reading is excluded from the report. Fires only at >= 2 alternatives.
- _maybe_ambig wires the audit at the three scalar return paths of
  answer_question; a clean answer is byte-identical (gate is cheap and
  the single-reading path changes nothing).

Propagation up (flag, never choose):
- payload carries {ambiguous, axis, alternatives[{value, role, quote,
  url}]}; provenance note says the choice among readings is NOT
  verified.
- OUTPUT EXPERT line: 'Q1 -> ANSWER value=... AMBIGUOUS ([prime
  minister] Spain; [secretary-general] PSOE) quote=...'.
- machine: run notes carry the axis + other readings; the evidence
  render shows them so the ANSWER step (and later the user) can decide.

Tests: knowledge/tests/ambiguity.py — the two agreed positives (both
Pedro phrasings), the two agreed counterexamples (silent), single
office, dates-as-values, duplicate shapes, role-in-object, wiring
(expert flags + clean untouched), engine log/payload/provenance,
machine notes/render. Suite 70/70. Live smoke: the full pipeline over
a run-J-shaped page flags the 3 offices; the rivers question over the
same KG stays silent.
2026-10-21 17:42:24 +02:00
onibot 0ef4f32c8f knowledge: subject guard + boundary matching + answer log (run H fixes)
Run H (his E2E of run G's fixes) answered Q1 'three longest rivers of
Italy' with the WORLD list (Nile/Amazon/Yangtze fanned out, 226 rows).
Three root causes, all deterministic code (one is an LLM-side miss the
code now guards):

1. THE SUBJECT GUARD (new, _list_from_page): proper nouns of the
   question ('Italy') must appear in the article title or the tables'
   caption/headers — whole token, stem, or word prefix ('Europe' ->
   'European', the gentilici pattern). The disjointness guard was vacuous
   (first hop, empty evidence) and the fetch order put the world list
   first; the guard now refuses it BEFORE the SELECT_TABLE call (zero
   budget spent), logged as 'subject guard: ... refusing LIST'. Live
   verified: world article refused, Italy article answered 22 members,
   top-3 by table order = Po, Adige, Tiber.

2. WORD-BOUNDARY MATCHING (run H's KG pollution): the harvest ingested
   227 world rows as 'Outflow' edges because goal term 'flow' matched
   'Outflow' by substring; the discharge-list page did the same with 929
   rows. _term_hits/_tokens/_col_hits replace every substring goal-term
   match (harvest goal_hit + val_i, promote val_i, skim notice filter);
   the keyword fallback ('flow'/'discharge' in ANY header) is gone — the
   column must carry a goal term. Live: 0 Outflow edges.

3. THE EXPERT ANSWER LOG (his ask): 'OUTPUT EXPERT: Q1 -> ANSWER
   value=3 (list of 3 members: Po, Adige, Tiber) quote=... url=...
   [knowledge_graph]' — the answer is now IN the log, not deduced from
   the fan-out that follows. Every expert output line carries the qid.

Tests: knowledge/tests/guards.py (boundary matching incl. flow !=
Outflow, proper-noun extraction, subject guard both ways, harvest
boundary, the new ANSWER log format). store.py fixture now names its
subject in the title (predates the law). Suite 52/52. Live smoke: the
full run-H regression chain on real Wikipedia.
2026-10-21 09:42:51 +02:00
onibot 9eab127727 knowledge: table fragments for extract + exact prompt log (run G fixes)
Run G hung at call 8/80 for minutes with no way to see what was sent.
Reproducing it found TWO root causes, both fixed here:

1. THE 22K TABLE CHUNK WAS A PARSER BUG, not just a size problem. The
   world-rivers table marks each data row's leading cell with
   '!scope="row"|' (a row-label th); parse_tables flagged any row that
   touched a '!' as a header row, so all 227 data rows collapsed into ONE
   header of 1,825 cells and zero rows. tables_as_text then flattened
   that monster into a single 22,021-char prose chunk. Fix: a row is a
   header row only if ALL its cells are '!' cells; mixed rows are data
   rows. Live: the world table now parses as 8 cols x 227 rows.

2. NO PROMPT OBSERVABILITY. The log's CALL/OUTPUT lines never carried
   what the LM actually received. floop/llm.py now installs a dspy global
   callback (PromptLogCallback): every LM call's exact rendered prompt
   lands in runs/<ts>/prompts/NN-stage.txt (NN mirrors the budget counter
   -- 08-EXTRACT.txt IS call 8/80), plus size/duration lines in run.log.
   Stage comes from a module stack (dspy fires on_module_start with a
   DIFFERENT call_id than the inner LM call -- verified with DummyLM
   probes), not a call_id map.

Plus the design Emili steered (tables reach the extractor as typed
fragments, never prose dumps):
- tables_as_chunks: per-table fragments of <=40 rows, EVERY fragment
  repeats header + caption, part i/N markers; the extractor always knows
  which table ('troç 2/10') it is reading.
- STOP_TABLE: the extractor may early-skip a table whose subject is
  wrong for the question after one fragment; fixed code skips the rest
  of THAT table. ExtractSignature teaches the protocol.
- fetch_rich no longer appends the '== Tables ==' enrichment to prose
  (the giant chunk's birthplace; also let verify_count cite the table as
  'prose'). Tables reach the extract path only as fragments; LIST and
  harvest keep reading page.tables directly.
- fragment candidates pass the same containment check against prose +
  full table text; LIST answer's table never re-enters extract.

Tests: knowledge/tests/tablefrags.py (fragment generation/render,
STOP_TABLE skipping, fragment extraction with containment, prompt log
files + log lines). Live smoke: world article 10 chunks none >5k; world
table = 6 fragments (max 5,787c); Italy discharge fragment intact
(Po/1540). Full suite 47/47.
2026-10-20 20:22:29 +02:00
onibot 1ebb4cfc0d knowledge: PR-3 skim notices to the loop + bounded lead promotion
PR-1 made the skim SEE (surfaces + signals); PR-2 made it HARVEST
deterministically. PR-3 closes the loop (KNOWLEDGE.md §7):

- Skim notices: every knowledge answer's stats carry what the fetched
  articles contained beyond the answer (table identities, infobox
  quantities, link candidates, goal-filtered). The engine copies them
  into payload['skim']; the machine renders them to the ROUTER context
  ('seen in passing (E1): ...') and to the run notes — later steps know
  what exists and where it lives instead of re-searching blind. A notice
  is a pointer, never evidence: it answers nothing by itself.
- Bounded lead promotion (Emili's 'deterministic + LLM fallback'):
  quantity tables that match NO goal word are queued as leads (PR-2);
  now ONE dspy call (SkimPromoteSignature) decides over the tables'
  IDENTITY lines (caption/headers/rows/quantities — never the rows),
  per fetched page with leads, only when leads exist. The LLM proposes;
  fixed code disposes: a promoted table still passes the entity-overlap
  check (a world discharge table is refused for Po/Adige/Tiber), the
  named column must exist, and ingestion goes through the same
  containment-checked _ingest_scalar_table as the deterministic path.
- Refactor: row ingestion extracted to _ingest_scalar_table (shared by
  harvest + promotion); _entity_overlap_count shared; skim state
  (_skim_notices/_skim_leads/_current_goal_question) reset per call.
- find_quantities: fix plain-digit quantities ('1540 m3/s', '1000 m3/s')
  — the thousands-separator-only regex missed them, and caption+header
  now join with a space ('m3/sRiver' broke the unit boundary).

Live smoke (real Wikipedia, scripted decision): goal terms without
'flow' queue both Italy tables as leads; the promoted 'Flow at the
mouth' table ingests all 27 rivers (Po 1540, Adige 235, Tiber 239
m3/s) containment-checked; promotion of the length table with a
'Flow' column name is refused (column does not exist).

Tests: 4 new (knowledge/tests/promote.py); suite 43/43 green.
2026-10-20 16:24:43 +02:00
onibot 3f269e2467 knowledge: PR-2 opportunistic harvest + seen-index (KNOWLEDGE §7)
The Italy run re-searched from scratch for Adige/Tiber discharge after Q1
had already fetched the article that contains it. PR-2 makes the skim
harvest what it sees in passing:

- _harvest_side_tables: goal-relevant tables beyond the LIST answer are
  ingested as typed scalar edges — zero LLM. Detection is deterministic
  and goal-directed: the table's caption/header must carry a GOAL term
  (the vocabulary the goal asks for, e.g. 'flow' in 'Flow at the mouth');
  the entity column must overlap the entities the parent's evidence names
  (a world discharge table is refused for Po/Adige/Tiber); the LIST
  answer's own table is skipped. Rows become edges: subject = entity
  cell, relation = value-column header, object = value + UNIT (the unit
  lives in the caption — quantities carry values AND units), quote = the
  verbatim stored row line, containment against the stored table text.
- A quantity table with no goal-vocabulary match is RECORDED as a lead
  (logged), never ingested on the unit pattern alone — the bounded LLM
  promotion is PR-3's call, by design.
- Seen-index (per run): articles already fetched are reused, zero
  re-fetch for later questions in the same run.
- Link queue: goal-region links from skim sheets join the candidate
  order (capped 12/article); hops still live in the plan — the law stands.
- config: skim_harvest / skim_harvest_max_tables / skim_link_queue.

Live smoke (cold temp store, real Wikipedia): harvesting the Italy list
article during Q1 ingests the discharge table; the Q5 probe
('average annual water flow discharge adige') and Q6 probe now return
'adige | Flow at the mouth | 235 m3/s' and 'tiber | Flow at the mouth |
239 m3/s' from the KG — the exact data Run G died without.

Tests: 4 new (knowledge/tests/harvest.py), suite 39/39 green.
2026-10-20 15:02:27 +02:00
onibot 73fe5cc8e1 knowledge: PR-1 skim surfaces — read articles in passing (KNOWLEDGE §7)
The Italy run (Run G) failed with the data in hand: Q1's LIST ingest
early-exited on the length table and discarded the same article's 27-row
discharge table; the Adige/Tiber discharges live in infobox templates,
invisible to both the plain extract and parse_tables; and {{cvt|50|m3/s}}
cleaned to "50" — units silently dropped everywhere.

PR-1 builds the skim's surfaces and signals (deterministic, zero LLM):

- knowledge/skim.py: skim_article() builds a per-article SkimSheet —
  section headings with term hits, table identity (caption/headers/row
  count), infobox parameter keys with resolved quantity values, link
  candidates from goal-relevant regions — from material fetch_rich
  already downloads.
- quantity-unit patterns (find_quantities): "50 m3/s" is a
  vocabulary-independent signal; the Italy discharge section's heading
  says "above 50 m3/s", never "discharge" — this finds what keyword
  search cannot.
- wiki.resolve_convert: {{convert|N|unit}} resolves to "N unit" inside
  _clean_cell BEFORE the generic template pass (which kept only the first
  argument and dropped the unit). Captions and cells keep units.
- WikiPage.wikitext: fetch_rich stores the raw source (infobox surface).
- _process_page: gated chunks are RANKED by skim signals (question + goal
  terms + quantity patterns) instead of first-N in document order.

Live smoke (real Wikipedia, no LLM): the Italy sheet shows table 2
"Rivers of Italy above 50 m3/s of average flow at the mouth", 27 rows,
quantities 50/350/239/235/187/170 m3/s; the Adige sheet shows infobox
discharge1_avg = 235 m3/s.

Tests: 6 new (knowledge/tests/skim.py), suite 35/35 green.
PR-2 (opportunistic harvest + seen-index) and PR-3 (notices to the
machine) follow.
2026-10-20 14:52:38 +02:00
onibot 06124a0198 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
2026-10-19 20:31:04 +02:00
onibot 209909e776 machine: fan-out planner + disjointness guard (runs 07/08 lessons)
(a) Disjointness guard (knowledge/expert.py): a LIST ingest whose members
    don't overlap the entities the parent's evidence names is refused; the
    gather continues to the next article. Run-08's 'flow of Po/Adige/Tiber'
    answered by the Amazon from a world-wide table can no longer happen.
(b) Fan-out planner (floop/machine.py): a 'for each' subquestion over a list
    row expands deterministically into N entity questions + one join.
    Top-N bound respected ('those three' over 22 rows -> top 3 by table
    order, logged). The join is a deterministic sum over the entity rows
    (verified=True: computation is its own proof), partial sums named.
    Entity rows are tagged fan_group in provenance so the join finds them.
Also: LIST ingest keeps TABLE ORDER (ranked tables rank; alphabetical sort
      destroyed the ranking) — dict.fromkeys dedup.
Budget: 40 -> 80 (a 3-entity fan-out needs ~3x a scalar question).

Verified live (cold KG, 2 runs): list ingest in table order, slice top-3,
fan-out -> 3 entity questions + join, Po answered with verbatim quote
(1,460 m3/s). 28/28 tests (fan-out expansion+join, top-N slice, guard).
2026-10-19 20:16:01 +02:00
onibot 852db78c99 knowledge: answer-level count corroboration (DESIGN §12) — LIST rows verified via prose
- VerifyCountSignature: LLM finds ONE verbatim sentence in the article prose
  (tables excluded by construction) stating the set's count
- _verify_count: code checks containment + digit equality — no LLM compares
  numbers; NOQUOTE -> count_corroborated=false (honest, one call, never loops)
- row verified <=> complete_per_source AND count_corroborated
- DESIGN §12 documents now vs deferred (extension, criteria, cross-article)
- live: EU question cold — E1 (50) + E2 (27) both corroborated with quotes,
  23 computed; 25/25 tests
2026-10-19 14:47:18 +02:00
onibot b14915079e store: auto-migrate old KGs (edges.origin_question); machine: abort honestly on dead LM
- KnowledgeStore._migrate(): idempotent additive migration on open — a
  pre-2026-10-19 KG no longer crashes the set gate with 'no such column'
- _lm_dead(): transport/timeout deaths abort the run with notes (no answer
  beats a made-up one); code bugs still crash loudly
- tests: migration from a hand-built old-schema store; LM-death abort (24/24)
2026-10-19 12:11:59 +02:00
onibot e5482bd092 feat(logic): setop engine + set gate — the Europe count computed end-to-end
A) SET GATE: enumerations are answered only from membership sets, never from mention rows (the probe early-exit that served 'Armenia, Cyprus, Georgia, Turkey' to 'what countries are in Europe' is dead). Sets carry origin_question; the gate matches stem-Jaccard>=0.5 so a set is served to its own question only. B) SETOP ENGINE: logic's first real engine — a count over list rows is computed (difference/intersection/count over norm_name'd items, table markers 'Austria*' == 'Austria'), before ROUTE, zero LLM calls, verified=True because the computation IS the check. C) Catalog honesty: knowledge 'lists are ONE fetch', logic 'how-many over lists in evidence', floop 'NOT mere size'. Plus four substrate bugs the live runs exposed: LM-proxy prompt cache (instant answers are cache hits, never trust zero latency), _context rendering list rows as scalars ('E1: 50' routed 'those countries' to user), <br> concatenation in multi-value name cells, multi-line refs leaking into values ('franceincludes the 101 departments' -> France dropped from EU -> 24 not 23). Cold E2E: Q1 50 states ingested, Q2 27 EU members ingested, Q3 difference computed = 23, cited over E1/E2. 22/22 tests.
2026-10-18 19:49:24 +02:00
onibot 6fcb3c0a86 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.
2026-10-18 16:53:10 +02:00
onibot 6db05fef48 fix(knowledge): cold-start gather — vertical tables, global rank, early exit
Emili's home run failed where the VPS seemed to work: warm-KG illusion; cold path never validated. Reproduced with a wiped KG. Fixes: (1) tables_as_text parses BOTH wikitext layouts (horizontal pipes and one-cell-per-line with row separators) + _clean_cell drops attrs/links/templates; (2) gather searches all queries, dedupes, ranks globally by title relevance, fetches ONE article at a time with EARLY EXIT when the KG answers; (3) hybrid order keeps each query's top-1 slot guaranteed (title relevance buries entity pages like 'Loire'). Also: NameError from refactor caught by baseline fallback; counters accumulate. Cold E2E verified: France (table quote) -> Loire (early exit, 1 article) in 2hops. RUNLOG Run D.
2026-10-17 10:39:34 +02:00
onibot 9094b2aec0 feat(knowledge): real Wikipedia vertical with containment-checked KG
knowledge/: wiki.py (official MediaWiki API, own session+UA; fetch_rich appends wikitext tables as text - plain extracts drop them), chunker.py (section-aware, level paths), checks.py (verbatim containment, quote-aware), store.py (SQLite append-only, 4 contradiction cases, probe by entity AND relation with stemming), extract.py (dspy Signatures: TRANSLATE resolves pronouns from context and emits queries+entities, EXTRACT per chunk, ANSWER from KG rows), expert.py (the pipeline: KG-first probe -> gap -> translate -> search -> fetch_rich -> chunk -> gate -> extract -> check -> merge -> re-probe -> answer). Wiring: KnowledgeEngine in floop/engine.py (machine injects charge+modules at call time; baseline fallback on pipeline failure), machine routes knowledge questions to it, config.yaml knowledge: block. E2E verified live: Loire length answered from KG with zero network; the 2-hop EU-river question resolved France (population table row quote) -> Loire (KG hit) in 12 calls/75s. Six live-run bugs closed (wiki lib 403/HTML, dropped tables, pipes-in-quotes parse, gate stemming, relation probe, pronoun context). RUNLOG Run C added; code/README honest map updated. Tests 17/17.
2026-10-16 23:19:09 +02:00
onibot 36a74770e6 docs: contradiction taxonomy for the KG; INTAKE component
KNOWLEDGE.md/DESIGN.md: new data contradicting or refining old data is normal operation, classified deterministically - temporal change (qualifiers, both coexist), supersession (subsumption test, supersedes link), real contradiction (conflict row, surfaced, never auto-resolved), retraction (TMS flag). Untyped qualifiers default to exposed conflict. Schema gains ref_date/supersedes/preferred/retraction_reason. ARCHITECTURE.md/ALGORITHM.md: INTAKE - the boundary before the loop; floop may accept 1M-token inputs over a 64k-window model: original stored whole on disk, deterministic format detection, structural splitting for known formats, staged LLM compression for unknown, goal separated from material early. Reception typing now operates on clean typed state.
2026-10-14 18:20:11 +02:00
onibot 67f466bd84 docs: full rewrite from a clean slate (v0.3)
The idea is now clear, so the docs are rewritten from zero around it: LLMs do language, algorithms do thinking, verified knowledge lives on disk. New set: ARCHITECTURE (system + laws: division of labour, LLM calls as typed function calls via dspy Signatures, context as a per-call budget over unlimited machine state, evidence table laws, interface contract, tools as loop output, fleet, guarantees, v1->v2), ALGORITHM (general loop for any goal: reception/typing, main loop, tool action, generic expert, recursion, backtracking, per-call context composition), KNOWLEDGE (substrate: store, gather, checks, probe, offline growth), META (two levels: in-run self-awareness; offline self-analysis, lessons bank, prompt optimization, fine-tuning, v2 router). PIPELINE.md and SCOPE.md removed - superseded; GAPS.md closed with a merge map. Code untouched.
2026-10-14 10:28:21 +02:00
onibot d0942bdc69 floop v0.1: design docs + executable dspy draft
Root: README, PIPELINE, ALGORITHM, GAPS, RUNLOG (design + first executable runs). code/: v0.1 draft on dspy 3.4 (INIT/ROUTE/EXPERT/MISSING/ANSWER as dspy calls, machine as fixed code, stub engines — honest Unverified). knowledge/: DESIGN.md for the KG-first knowledge expert (pre-implementation).
2026-10-13 13:39:31 +02:00