Commit Graph
104 Commits
Author SHA1 Message Date
onibot 72ebe44053 Merge pull request 'wikipedia fetch Ranking combining BM25 lexical relevance and embedding cosine similarity through reciprocal rank fusion' (#33) from feat/semantic-fetch into main 2026-10-28 17:54:13 +01:00
emili bc543459c7 wikipedia fetch Ranking combining BM25 lexical relevance and embedding cosine similarity through reciprocal rank fusion 2026-10-28 17:42:42 +01:00
emili 77fef0a499 Refactorin KnowledgeExpert.answer_question too long function 2026-10-28 17:27:56 +01:00
emili 12fb3c78b2 formalizing Named Entity Recognition types, Mask -> NER 2026-10-28 12:41:31 +01:00
emili a007e8da25 Merge pull request 'feat: OTel trace exporter — events.jsonl to Jaeger (post-mortem)' (#32) from feat/otel-traces into main
Reviewed-on: #32
2026-10-27 15:19:56 +01:00
onibotandClaude 1af308ae60 feat: named inputs/outputs in traces + clickable prompts + expert names
Owner's 27/10 review of the OTel export, four asks, all landed:

1. NAMED IN/OUT PER FUNCTION: fn.done events (fn, in, out) at the
   knowledge pipeline's main functions - search (in.query -> out.titles),
   fetch, skim, compose, chunk_gate, serve_set, list_ingest, harvest,
   promote, check, judge - rendered as spans with in.<arg>/out.<arg>
   attributes. "wiki search ('Pedro date take'): [...]" is now
   knowledge.search with in.query and out.titles as data.
2. SIGNATURE IN/OUT: the dspy prompt-log callback emits sig.start/sig.done
   - the typed fields of every dspy call (in.question, out.entities,
   out.facts...). The LLM span and the sig span are one node.
3. CLICKABLE PROMPT: every LLM span carries a child 'prompt' span with
   the exact prompt + raw response read from prompts/NN-stage.txt at
   export time - retroactive for old runs (the Pedro run re-exports with
   128 prompt children).
4. EXPERT NAMES: EXPERT comp spans carry expert= (EXPERT knowledge);
   nested spans prefix with the expert (knowledge.search,
   knowledge.state, knowledge.TranslateToDSL); each expert exports its
   spans under its own OTel service so Jaeger groups by component.

Live-verified end to end: smoke run (glm-5.3-flash) exported while
running - MASK shows in.question -> out.entities [{France, PLACE}],
EXPERT knowledge nests knowledge.TranslateToDSL under service
knowledge; read back via Jaeger's own API. Suite: traces 7/7, all
floop + knowledge test files green (guards/value_clean caught two bugs
in the new emissions before commit: a wrong-scope variable and a
use-before-define; _rec now reads getattr(streams) so __new__ test
fakes survive).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-27 14:27:56 +01:00
onibot 6ea769b7d1 feat: OTel trace exporter - events.jsonl to Jaeger (post-mortem)
ARCHITECTURE 9-bis BUILT: one run = one OTel trace, deterministic id
(sha of run dir name); root span named by the question with the final
answer as attribute; INIT/ROUTE/EXPERT/ANSWER as nested component spans;
every llm.done/probe.done/fact.merged event one span; recursive child
runs (same events.jsonl, own run_ts, seq restarts) nest as per-run
spans. Post-mortem only - the run never touches the network.

floop/traces.py stdlib only; pushes OTLP/HTTP JSON to Jaeger v2
(docker on agentvps, 10.3.14.59:16686 UI / :4318 ingest, VPN-bound).
python -m floop.traces runs/<dir> | --latest N | --dry.

Verified: Pedro 09:15 run -> 393 spans (root 1193.8s, 128 llm spans),
read back via Jaeger API; fractal goal run nests to depth 6.
tests/traces.py 5/5; recorder 3/3; inspect 3/3.
2026-10-27 12:34:44 +01:00
onibot d6c5bed443 Merge pull request 'feat: floop-inspect — the post-mortem HTML debugger' (#31) from feat/floop-inspect into main 2026-10-27 07:47:27 +01:00
onibot e365f6d1e8 feat: floop-inspect — the post-mortem HTML debugger (PR B)
One run dir in -> ONE self-contained inspect.html out. The events are
inlined as JSON; the page opens offline from file:// with ZERO network
references. Four views (owner 26/10: IDE-like debugging a posteriori):

- timeline: every component as a bar in time order — LLM calls (with
  real durations) vs code nodes colored differently; click a bar -> its
  in/out in the header detail line. The 'which expert are we inside'
  view.
- kg: the snapshot graph on canvas (spring layout, vanilla JS): nodes
  sized by degree, edges with temporal windows, THIS RUN's touched edges
  highlighted in accent blue, click a node/edge -> detail (subject, rel,
  object, window, last-touch event).
- facts: the two-pass debug table — claims per chunk, each claim ->
  typed fact (or declined), each merge verdict with reason.
- probes: per question what the hybrid probe returned (seeds, rows,
  semantic adds, tau) and the prover's DSL + verdict + bindings.

Fixed on real render (browser-verified): the KG canvas measured 0x0
while its tab was hidden (display:none) — layout now runs lazily on
first visible draw and every tab activation dispatches a resize, so
the canvas paints correctly (verified: painted pixels present, all
four tabs render content).

TDD: inspect_html 3/3 (self-contained offline, honest error without
events, empty run renders). Suite: 32 test files green.
Usage: python -m floop.inspect_html runs/<ts>/
2026-10-27 07:47:21 +01:00
onibot 9f2fbd711c Merge pull request 'feat: flight recorder — events.jsonl for post-mortem debugging' (#30) from feat/flight-recorder into main 2026-10-27 07:42:28 +01:00
onibot d384a10a8d feat: flight recorder — events.jsonl for post-mortem debugging
Owner ruling (26/10): 'vull poder fer com un debug amb l'IDE de
programació, però a posteriori de l'execució' — see WHERE inside which
expert we are at every moment, and the input/output of every component,
LLM or not. This is the recorder half (PR A of the observability plan).

- floop/recorder.py: append-only JSONL, one event per line. LAWS:
  never breaks a run (emitting is swallowed; no run dir = TOTAL no-op,
  no buffer, no counters); every line self-describing (seq, ts, run_ts,
  event, payload); in/out carry structured data, the exact prompt text
  stays in prompts/NN-stage.txt (events stay small).
- Wired via RunStreams (every component already had streams):
  comp.start/comp.out (machine stages INIT/ROUTE/EXPERT/ANSWER/FINAL),
  state, llm.done (stage, dur_s, call_seq, prompt file link — from the
  dspy callback), run.final.
- Knowledge pipeline components (floop-internal nodes, not LLMs):
  probe.done (seeds, rows, tau, semantic adds), claims.done (the claim
  list), type.done (claim -> typed fact, one per claim as ruled),
  fact.merged / fact.rejected (one per fact — _ingest_candidate is
  called per fact; verdict + reason + page), prover.done (dsl, verdict:
  invalid_dsl/no_closed_path/closed/ambiguous, bindings), kg.snapshot
  (once at run end: every edge with temporal window + last_touch from
  this run's merge events).
- kg_snapshot(): rows annotated with their last-touch event (owner:
  'cada fila del kg podria tenir anotat quan s'afegeix o edita').

Live-checked: baseline run writes real events (comp.start, llm.done
dur_s=17.35, comp.out '4'). TDD: recorder 3/3; suite 31 files green.

Next (PR B): floop-inspect — the HTML debugger reading events.jsonl
(timeline Gantt, KG view, facts table, probe view).
2026-10-27 07:42:23 +01:00
onibot 86af2c968d Merge pull request 'fix: completeness beats budget — no claim cap, dedup by code, budget 200' (#29) from fix/no-claim-cap into main 2026-10-26 20:29:31 +01:00
onibot 964189387d fix: completeness beats budget — no claim cap, dedup by code, budget 200
Owner ruling (26/10): 'the budget has never been a priority and must
never harm us here.' The cap=6 from #28 (my call, never agreed) cut the
Socialist International claim — it was #7 of 46 in the lead chunk of
live run 20261026-170521 — so the KG never held the third presidency
reading and the judge could not offer it.

- claims_from: NO cap, NO semantic filter. Code-only honesty: exact
  repeats dropped (live finding: glm listed its 46-claim list with ~26
  exact repeats + thinking leakage as items). Case/whitespace-insensitive
  dedup keeps the FIRST occurrence. Every unique claim gets its TYPE
  call.
- max_claims_per_chunk: deprecated in config (kept only for the
  table-frags legacy path).
- budget.max_llm_calls: 80 -> 200 (bounds runaway runs only).

TDD: two_pass_extract 6/6 (new: dedup keeps unique claims verbatim).
Suite: 30 test files green.
2026-10-26 20:29:27 +01:00
onibot 2ee3b54661 Merge pull request 'fix: two-pass Pass 2 needs the chunk text (invented quotes) + claim cap' (#28) from fix/two-pass-contract into main 2026-10-26 17:05:16 +01:00
onibot a9837981b3 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.
2026-10-26 17:05:10 +01:00
onibot 88769c508c Merge pull request 'feat: two-pass EXTRACT (claims -> typed Facts) for prose chunks' (#27) from feat/two-pass-extract into main 2026-10-26 16:42:27 +01:00
onibot f6e9164e92 feat: two-pass EXTRACT (claims -> typed Facts) for prose chunks
His diagnosis accepted (26/10): the single-pass EXTRACT's giant typed
JSON array (verbatim quotes + temporal restrictions + sibling orders)
is the output budget behind the 40-minute arithmetic on slow local
models. Two-pass shortens EVERY output:

- Pass 1 ExtractClaims: plain claim strings, coreferences resolved
  (entities named, never pronouns) — near-zero format tax.
- Pass 2 TypeClaim: ONE claim -> one typed Fact per call (same Fact
  schema the store eats; temporal fields optional, containment-checked
  downstream as always). Orders NEVER produced here: one claim at a
  time has no siblings — the legacy Fact keeps orders for the
  single-pass path and table frags, untouched.
- extract_mode: two_pass (default) | single (legacy) — config-driven,
  read from config.yaml's knowledge block by run_app.
- Budget: Pass 1 charges once per chunk; Pass 2 charges once per
  claim. Table frags keep the legacy single-pass call.
- Prompt log: CLAIMS/TYPE stage labels added.

TDD: two_pass_extract 5/5 (signatures, coref law, honest empties) +
two_pass_wiring 2/2 (end-to-end on a real store: two_pass ingests
typed facts with windows kept; single-pass control green). Suite: 29
test files green. The router from #26 makes the upcoming
extraction-model swap a pure config edit.
2026-10-26 16:42:22 +01:00
onibot 95dfdf7123 Merge pull request 'feat: per-signature LM router (lm[<SigName>] config blocks + predict factory)' (#26) from feat/lm-signature-router into main 2026-10-26 16:37:14 +01:00
onibot 6ba0bce863 feat: per-signature LM router (lm[<SigName>] config blocks + predict factory)
His ask: one general construction door so a signature's model/settings
change by editing config alone — no call-site ifs, now or ever after.
lm[ExtractSignature]: as a config.yaml sibling of lm: (provider:
inherits base_url + transport ceiling; model: builds a dedicated
cached LM; other keys -> per-call lm_kwargs through Predict config,
honored by dspy 3.4.1 _forward_preprocess). predict() is the door: the
13 construction sites swapped mechanically. First block shipped:
ExtractSignature max_tokens=1800 (the 4096 cap was 3x headroom that
only extended the worst case on slow local models — the 40-min
arithmetic). run.log reports active blocks at startup. TDD:
tests/lm_signature_router.py 5/5 (parse, no-block defaults,
settings-only override, dedicated+cached LM, provenance listing).
2026-10-26 16:37:04 +01:00
onibot 31c7e02e22 Merge pull request 'fix: LM transport ceiling per provider (read_timeout_s + num_retries)' (#25) from fix/lm-transport-ceiling into main 2026-10-26 12:27:57 +01:00
onibot f31b30d811 fix: LM transport ceiling per provider (read_timeout_s + num_retries)
The bug his log pinned: local EXTRACT died at 2407.3s = 4 attempts x
600s + 7s backoff — dspy's retry loop (default num_retries=3) ran
honestly but every attempt hit the SAME wall: lm15's default read
timeout of 600s (and the silent-ollama proxy in front cuts at its own
READ_TIMEOUT=600 too). Retries can't help when each attempt dies at
the same ceiling — the 27b on a single 3090 legitimately needs
minutes for a long EXTRACT output (his nvidia-smi: 21GB resident,
64k context, ~52% util).

The fix: the ceiling is CONFIG, not code.
- config.yaml: local read_timeout_s=1800 (one honest 30-min attempt),
  num_retries=1 (one re-try after a genuine cut, not 3x30min);
  ollama-cloud read_timeout_s=300 (glm answers EXTRACT in ~3s),
  num_retries=2 (cloud retries are cheap).
- configure_lm forwards read_timeout_s as dspy.LM(timeout=...) —
  dspy 3.4.1 routes it to lm15 Timeouts(read/write/pool) — and
  num_retries to the retry loop (LMTransportError is retryable).
- run.log first line now reports the ceiling (no more silent 600s
  walls — you SEE what will kill a slow call).
- Unset keys -> dspy defaults (600s / retries 3), nothing invented.

Verified on the wire (tests/lm_transport_wire.py): a hang server +
timeout=3 kills the call at 3.1s (not 600s); num_retries=1 gives
exactly 2 attempts (3.2s = 2x1s + backoff). Suite: 21 files green.
2026-10-26 12:27:49 +01:00
onibot 27c4bf3812 Merge pull request 'research/semantic-kg: semantic probe + conflict taxonomy + temporal layer + derived-answer prover' (#24) from research/semantic-kg into main 2026-10-25 21:40:17 +01:00
onibot 2cfcb1a59d research: phase 3 shipped live — evaluator + translator + gate, verified on the Pedro run 2026-10-25 21:39:13 +01:00
onibot ee315e0644 knowledge: the prover wired — translate->validate->prove, no judge in the loop (phase 3b)
The LLM at the INPUT boundary only: one structured-output call
(TranslateToDSL — question + the store's relation vocabulary in, typed
DSL out), VALIDATED before execution (validate_query: the shared
grammar — unknown filter/select, empty rel_any, malformed lookup are
rejected deterministically; a mistranslation can never reach
evaluate()). The evaluator (3a) closes the path; re-execution IS the
check. _prover_answer runs BEFORE any judge: a closed path returns the
answer with verified=True and the proof term; a multi-binding returns
the SET with ambiguous=True + alternatives (the three readings as what
they are — deterministic, no ablation rounds, no (K5) surface: the
judge never sees these questions). No translation / no closed path /
re-execution mismatch -> the judge path, unchanged; the prover can
never kill a run.

Wiring is additive: answer_question tries the prover first, falls
back honestly. Tests: translate_dsl.py 4/4 (signature, live-shape
translation, mistranslation rejection, honest decline -> None).
2026-10-25 21:12:56 +01:00
onibot fb612686d6 knowledge: the derived-answer engine, evaluator first (phase 3a)
No LLM in the loop. The query is a small typed DSL (conjunctive +
temporal, hand-writable); evaluation is goal-directed over the store;
THE ANSWER IS THE PROOF TERM — every step names its operator and the
edge ids it consumed — and re-execution over the store IS the
verification (deterministic; a stale proof fails after a retraction —
the check is real, not a flag).

Operators pinned by tests (the fixture = the live three-presidencies
shape): lookup (subject + rel_any -> bindings), value-join
(same_value_as — the SAME office, ANY holder), open_now (window open),
before (window a ended before window b started — both endpoints real,
an open end is never 'before' anything), neq_value (exclude the
queried entity), select all (the binding SET — multi-binding IS the
ambiguity) / latest_end (the predecessor).

Proven end-to-end on the fixture: "of what is Sánchez president?"
returns the three bindings (Spain, PSOE, SI); "who was President
before him?" proves RAJOY as a closed path citing both edges, rejects
the structural distractor (Feijóo holds a different office), returns
empty = UNKNOWN when no path exists, and re-execution fails after
Rajoy's edge is retracted.

The LLM translator (question -> DSL, one structured-output call) and
the machine wiring (prover as the real stop-check) arrive in 3b.
2026-10-25 21:09:19 +01:00
onibot 99f8b6e9db knowledge: temporal restrictions layer (phase 2, RESEARCH-derived-answers Part 2)
The extractor's temporal vocabulary is RESTRICTIONS, never Allen labels:
typed Fact gains start/end/point (optional, ISO-ish) + granularity +
orders [{rel: before|after|concurrent, other: <sibling index>}] — the
text's connectives transcribed, not classified. The Allen algebra stays
a COMPUTED VIEW over endpoints.

- checks.py: every stated date must be CONTAINED IN THE QUOTE — an
  invented date rejects the whole candidate (LLM proposes, code
  verifies against the source surface).
- store.py: edges gain t_start/t_end (valid-time window, None end =
  OPEN, honest to 'since 2018'); fact_order table (order assertions
  between addressable facts — reification is free); _classify consumes
  interval arithmetic: overlapping open windows -> alternatives
  (coexistence provable, no statistics), disjoint windows ->
  succession (never a conflict). Boundary law at year granularity:
  [2014,2018) vs [2018,None) = succession — the mandate changed hands
  in 2018. add_fact_order validates rel in {before, after, concurrent}.
- expert.py: _ingest_candidate returns (merged, eid) and passes the
  windows; the prose path collects positional fact_ids and wires the
  orders' sibling references to real edge ids (malformed refs skip
  honestly).

Tests: temporal.py 6/6 (typed fields, containment rejection, open-
window overlap -> alternatives, touch-at-year -> succession, empty
stays empty, fact_order ingest) + 7/7 interval cases incl. the
open-past degenerate. Suite: all green.

LIVE (run 20261025-205018, cold KG, glm-5.3-flash): 29 edges carry
windows (Spain 2018 / PSOE 2017 / SI 2022 all open-ended), 25
fact_order rows (Madrid before Congress of Deputies...), 8 invented
end-dates REJECTED by the containment check (the footballer Pedro
articles — the check catching exactly what it should), 0 conflicts.
The run itself answered UNKNOWN on its Q1 ("what DATE did he take
office") — honest: the blind extractor did not transcribe the exact
date this run and the noisy re-probe view (four Pedros) is the known
branch weakness, not a phase-2 regression. Design note for phase 4:
the three presidencies live under DIFFERENT rels, so the alternatives
substrate must be queried trans-rel by the consumer (alternatives_of
is per-rel by construction).
2026-10-25 21:07:34 +01:00
onibot b4b26c5ee6 research: phase 1 live result — 0 conflicts, the three presidencies queryable as alternatives 2026-10-25 20:24:18 +01:00
onibot f32a6db531 knowledge: conflict taxonomy at merge (phase 1, RESEARCH-derived-answers Part 1)
The four-case classifier conflated conjunction, paraphrase and polisèmia
into "contradiction" — the live KG after one Pedro run held 20 conflict
pairs, ZERO real ones. The taxonomy (deterministic, cost-ordered):

  co-asserted   same quote_id — one trusted sentence asserts both values
                (the platform sentence split into 5 "called for" facts)
  paraphrase    tails resolve to the same node — the same fact in two
                surfaces: MERGE (same_as alias, append-only; the canonical
                edge's corroboration goes up, no conflict row)
  alternatives  entity-ish values, different tails — co-true readings of a
                multi-valued relation (THE three presidencies). New table
                + alternatives_of(src, rel): the ambiguity substrate,
                detected at INGEST, deterministically — the audit no
                longer needs to re-derive it at judge time
  temporal      both dated — unchanged
  contradiction the residue: functional values (dates/quantities —
                _looks_functional: numbers with at most unit/month words;
                pure entity words are readings, not data)

Files: store.py (_classify 4->7 cases, migrations for alternatives +
same_as, alternatives_of), tests taxonomy.py (6/6: the 20-pair inventory
as fixtures), store.py test updated to the new law (different quotes for
the contradiction pair — same-quote is co-asserted by law).

Known scope notes: same_as is recorded but not yet consumed by the
probe/render (phase 4); the three-presidencies-in-one-sentence shape
stays conjunction (the live readings came from different quotes).
2026-10-25 20:14:06 +01:00
onibot 096326e3a3 merge main (phase 0: K5 fix, --no-cache, import assert) into research/semantic-kg
Conflict resolutions, the honest way:
- extract/expert gap-step: main's deterministic COMPOSE wins over the
  branch's TRANSLATE LLM (main removed it 23/10 with measurement: the
  model was putting the ANSWER into retrieval queries). The branch's
  _extract_entities contract (question-blind extractor) is fed from
  compose's entities.
- tablefrags/semantic tests: restored the branch's adapted versions +
  fixed their single-insert sys.path bug (parent.parent resolved to
  knowledge/, not code/ — the tests were silently importing MAIN's
  expert.py through the venv pth; same class as the run-085457 trap).
2026-10-25 20:04:47 +01:00
onibot 4c9c762b91 Merge pull request 'Phase 0 — judge value cleanup + --no-cache + import assert' (#23) from fix/judge-value-cleanup into main 2026-10-25 20:00:44 +01:00
onibot 985aec2f60 Phase 0 — judge value cleanup + --no-cache + import assert
The (K5) bug fix (his 24-25/10 session): glm-5.3-flash glues row
citations and glosses onto the judge's value field, killing the ablation
audit silently ("the judge invented it: nothing to ablate") and leaking
LLM prose into typed payloads. Fixed at the judge's output boundary
(_answer_from_rows): trailing-only, marker-anchored cleanup (_clean_value)
that strips the three live citation shapes and survives legitimate
parentheticals ("(PSOE)", "(since 2018)"). The AnswerFromKG value desc
now says what the value must be.

--no-cache CLI flag (his ruling: the dspy disk cache is not a bug, the
default stays; the flag exists for A/B and freshness testing) — builds
dspy.LM with cache=False for the process; verified live: repeated runs
re-run real inference instead of replaying.

Import assert at startup: floop/knowledge SUBMODULE files must resolve
inside this repo's tree. Namespace-package __path__ lies (it recomputes
dynamically and lists every tree), so the check pins the actual module
files (run 085457 was main's pipeline inside the branch worktree, no
signal). Abort loudly, don't log.
2026-10-25 20:00:34 +01:00
onibot 262f40b981 research: his ruling on the dspy cache (--no-cache, not a bug) + the implementation plan
- RESEARCH-semantic-kg: measurement note reworded per his call — the
  disk cache is caching doing its job; --no-cache CLI flag for test
  runs, default unchanged.
- RESEARCH-derived-answers: the 5-phase plan appended (hygiene →
  taxonomy → temporal → prover → consumers), open decisions listed
  (DSL vocabulary, order primitives placement, translator location).
  Awaiting his approval; no code.
2026-10-25 15:41:03 +01:00
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 e594339629 Merge pull request 'A run that asked the user ends IN the question (fixed-code clarify)' (#22) from feature/clarify-answer into main 2026-10-23 17:16:52 +02:00
onibot 7dfac55cf4 floop: a run that asked the user ends IN the question (fixed-code clarify)
His 23/10 run review: ROUTE correctly deferred Q2 to the user (the
evidence only flagged ambiguity — layer-3 policy working), the user
expert recorded needs_user_input, the cascade killed the dependents…
and then the ANSWER step ran anyway: the synthesis prompt read
'note=needs_user_input' as plain text and invented 'The provided
evidence does not identify who was the President…' — the machine had
DECIDED to ask, and the final node swallowed the question.

The fix (his call): a run that ASKED ends IN THE QUESTION.

- _finish now checks pending user rows (note=needs_user_input) BEFORE
  any synthesis; when present the final answer is composed by FIXED
  CODE (_clarify_answer, zero LLM calls): 'I need to ask you: <the
  instantiated question> (so far: <what the machine holds>)' — the
  dependency's value rendered as context, with the ambiguity note when
  the row is ambiguous ('so far: Socialist International — but other
  defensible readings exist: Spain').
- Ordering vs the branch answer: branches own the
  ambiguity-with-dependents shape (the fork); clarify owns every OTHER
  honest defer. A synthesis prompt can no longer re-render a machine
  decision as 'evidence is unknown'.
- test_user_expert_fails_question updated: it asserted the OLD
  behaviour ('synthesis still happens, honestly') — that assertion
  codified exactly the bug he rejected; the run that asks now ends in
  the ask.

New test: the defer path ends in the question, no synthesis runs.
Suite 18/18.
2026-10-23 17:16:47 +02:00
onibot 302e50120c Merge pull request 'Execution branches over ambiguity: fork per reading, conditional answer' (#21) from feature/branching-fork into main 2026-10-23 16:29:44 +02:00
onibot 004c7974c6 floop: execution branches over ambiguity — fork per reading, conditional answer
His branching design (22-23/10, consolidated; now coded): when an
expert returns SEVERAL defensible readings of one question (the
knowledge ablation audit's ambiguous + alternatives payload), a
question that DEPENDS on that row must not inherit the coin-flip.
The old behaviour: alternatives were passed in the router context
(rejected — it only moves the guess into answer_kg) or collapsed
inside the ANSWER prompt (run L: 'Papandreou was the predecessor' —
the exact rejected behaviour).

The mechanism (floop/branches.py + machine._run_branch):
- LAZY: a branch is born only when the ambiguous row has an OPEN
  dependent subtree (open_subtree, frozen at fork time so every
  branch of the fork copies the same questions); an ambiguity nobody
  needs stays a note.
- A branch is a WORLD, not a fork of the run: the dependent subtree
  is re-created inside the branch with branch-scoped qids (B1.Q2),
  and the shared evidence table is read through a BranchView that
  BINDS the ambiguous row to the branch's reading (a VIEW — the table
  is never mutated, the original row keeps all readings) and hides
  other branches' rows.
- SHARED: acquired knowledge lands in the ONE table, tagged
  provenance['branch']; the KG/seen-index live in the expert, shared
  by construction. A later branch reuses an earlier one's gathering.
- DEATH: by contradiction, dead end (all branch questions failed) or
  NATURAL MERGE (same normalized answer as another branch — one
  conclusion, recorded merged). Never an absurdity judge.
- NESTING: an ambiguous row answered inside a branch (with its own
  dependent) opens sub-branches under it (origin=<branch id>); the
  parent carries its children's conditional as its answer. Branch
  cap (6) drops and NAMES extra readings — never silent.
- CONDITIONAL ANSWER: _finish composes the final answer by FIXED
  CODE over surviving branches — 'if you meant X -> A | if you meant
  Y -> B'; single survivor renders plain. Never a synthesis prompt
  choosing a reading inside itself.
- WARNINGS: FORK/BRANCH lines on screen AND log ([W]) — the fork is
  a machine judgement worth a human's eye, and META's lessons bank
  counts them.

Docs: ALGORITHM.md §6-bis (the mechanism as a law); README honest map
row. Tests: tests/branches.py — 5 E2E (fork+conditional, lazy no-fork,
dead-branch honesty, natural merge, nested sub-branches). Suite 18/18.

Live smoke (ollama-cloud, warm agent KG): the Pedro question runs
clean through the new paths (8 calls, 52s, honest answer; the fork
did not fire — the audit found no second reading in that KG; the
mechanism is proven by the E2E tests, the real-detector proof is his
local run over his accumulated KG).
2026-10-23 16:29:26 +02:00
onibot 1df3ec591b Merge pull request 'Strict mask-seed detection + WARNING on seeded answers' (#20) from feature/strict-mask-seed into main 2026-10-23 16:03:39 +02:00
onibot 8a3f8b37e3 floop: strict mask-seed detection + WARNING on seeded answers
His 23/10 review of the merged run found Q1's answer missing from the
stream. Chain, verified against the real code:

1. Q1 ('...does the title "President" refer to in relation to
   PERSON_1?') fired the mask-seed detector's loose mechanism clause —
   any 'refer to' in the sentence, even when the verb governs the
   TITLE, not the placeholder. The seed answered 'Pedro Sanchez' to a
   question that asked which OFFICE 'President' means: wrong semantics,
   a false positive born from the collision of the detector's word
   list with INIT's new hidden-precondition phrasing.

Fixes (both his ask):
- identity_answer STRICT: the mechanism clause now fires only with the
  placeholder as the REFERENT of 'refer(s) to' (regex adjacency, both
  orders). The literal 'who/what is <ph>' clause is unchanged.
- Found while verifying: the literal clause's lookahead accepted
  apostrophes, so 'Who is PERSON_1's predecessor?' (possessive) seeded
  too — the old test only covered 'Who WAS...'. Apostrophe removed from
  the end-of-question char class; possessives never seed again.
- THE SEED IS NOW LOUD: RunStreams.warn() (new channel — WARNING line
  in run.log, [W] on screen ALWAYS, even non-verbose) fires on every
  seeded answer: 'WARNING SEED auto-answered Q1 ... (mask map; zero
  expert calls)'. Self-improvement signal (META): which phrasings the
  seed eats belongs to the lessons bank, and it must be legible that
  the machine auto-answered without any expert.

Also: ARCHITECTURE.md §9-bis — OpenTelemetry observability roadmap
(his future plan ask): run = trace, calls/steps/rows = spans carrying
today's log fields, events.jsonl as the shared bus, warnings as
first-class span events; deferred until the loop hardening settles.

Tests: anonymize +4 assertions (his false positive, possessive trap,
strict positive shapes), machine +1 (seed WARNING lands in run.log).
Suite 17/17.
2026-10-23 16:03:13 +02:00
onibot bb4afb6a66 Merge pull request 'Remove the TRANSLATE LLM: deterministic query composition' (#19) from feature/deterministic-translate into main 2026-10-23 15:15:18 +02:00
onibot dec1fccb53 knowledge: remove the TRANSLATE LLM — deterministic query composition
His 23/10 weights-tightness audit found the TRANSLATE step composing
search queries from its own knowledge of the entities: 'Pedro Sánchez
2018 investiture President of the Government of Spain' for a term-start
question (the '2018' IS the answer, steered into retrieval from weights),
'Po, Adige, Tiber' proposed as entities for a question that named only
Italy. Measured over every logged TRANSLATE call of runs 22-23/10: 5/10
calls carried untraceable query terms, 6/10 untraceable entity terms.

Probed against real Wikipedia before deciding: queries composed
deterministically from question ∪ evidence put the decisive article at
top-1/2 of the search in 8 of 9 cases — the LLM's world knowledge was
never load-bearing; the search engine's own relevance was. So the step
becomes code (the law: LLMs translate, fixed code composes — and here
nothing is left to translate).

- NEW knowledge/queries.py: compose_queries() + proper_nouns/keywords
  (moved here, single source — the expert delegates). Laws: every query
  token traces to the question or an evidence row; deterministic; never
  empty. Top-N asks slice the FIRST N evidence members by source order
  (never dump all members); enumerations with one subject NE get the
  list-article shape ('List of rivers of Italy'); sentence-initial
  capitals are dropped when other NEs exist ('During', 'Ranked').
- DELETED TranslateSignature + the Predict + the stage map entry;
  the gather charges one LLM call less.
- expert.py: COMPOSE at the gather head; the context var (rendered
  only for the dead prompt) removed — evidence feeds the probe seeds,
  the composer and the guards directly.
- Tests: knowledge/tests/queries.py (12) — the sonde's cases as the
  contract, incl. the traceback law over the logged questions.
- DESIGN.md §4 + code/README honest map updated.

Suite 17/17. Live probe (real Wikipedia): rivers/Pedro/France/Po all
fetch the decisive article at top-1.
2026-10-23 15:15:02 +02:00
onibot 0f5a3f4ceb merge main (INIT hidden-preconditions prompt) into research/semantic-kg 2026-10-23 13:38:07 +02:00
emili 30d0a48f7a Improving hidden preconditions in INIT prompt 2026-10-23 12:36:27 +02: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 1a4f25bc84 Merge branch 'main' into research/semantic-kg 2026-10-22 23:58:29 +02:00
onibot 86b444391d Merge pull request 'floop: DATE answer type + deterministic year check' (#18) from feature/date-type into main 2026-10-22 23:58:25 +02:00
onibot aabacf8c44 floop: DATE answer type + deterministic year check (his 22/10 run)
His local run: the term-start question answered '15' — not a date —
and the dependent predecessor question became unclear downstream.

- AnswerType.DATE joins the enum; the Subquestion desc the model sees
  now says: DATE for a specific date (day, month and year — '15' alone
  is NOT a date)
- _looks_like_date: deterministic admission bar — a plausible year
  (1500-2999). '2 June 2018'/'June 2018'/'2018' pass; '15', a month
  name alone, garbage: refused
- _append_checked: a DATE answer without a year becomes UNKNOWN, the
  question fails honestly, a note lands in the run log — the wrong
  type never flows silently into dependents

VERIFIED: tests/date_type.py 4/4 (enum+desc in the rendered schema,
deterministic admission, '15' rejected end-to-end, real date accepted);
suite 16/16.
2026-10-22 23:58:19 +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 cc1eceb720 Merge pull request 'floop: INIT told placeholders are resolved + identity seed' (#17) from feature/init-resolved-placeholders into main 2026-10-22 17:03:53 +02:00