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.
floop/code — v0.1 draft implementation
A draft: every deciding stage (formal checks, the prover, real engines) is a stub, so the draft runs with only LLM calls (as decided) and every answer is honestly marked UNVERIFIED. The architecture — states, laws, control flow — is the real v0.1 shape; only the formal layer is missing.
Run
cd floop/code
uv run run_app.py "What information do I need to plan a trip to Tokyo?" # any question
uv run run_app.py --verbose "..." # + "thinking" on screen, flushed
uv run run_app.py --baseline "..." # A/B control: raw LLM, ONE call, no loop
FLOOP_LM=ollama-cloud uv run run_app.py "..." # cloud LM instead of local
Baselines (Emili, 2026-10-16)
The draft experts are baseline experts: the LLM answers each small subquestion
directly from its own knowledge — no engine, no verification yet. Each evidence row
records the honest source: model_weights (answered from the LLM's own knowledge) or
given_evidence (backed by a verbatim quote from the evidence it was given). When the
real engines arrive (knowledge first), the verification path replaces the baseline path
per expert, and every improvement becomes measurable against this baseline.
--baseline is the A/B control: the same LM answers the whole question in ONE raw
call — no decomposition, no experts, no evidence table. Same LM, same budget unit.
Compare: --baseline vs the loop's many small directed calls.
- Always:
runs/<ts>-<slug>/run.log(gitignored), written with explicit flush —tail -f runs/<latest>/run.logfrom another terminal shows progress live. --verbose: the thinking stream also prints to the screen, flushed. Thinking is floop's future user-facing "thinking" output (what floop-as-LLM will stream); it is a SUBSET of the log — the log keeps all technical detail (budget, provenance, raw payloads), thinking stays readable. They will diverge over time (Emili, 2026-10-13).- Screen thinking lines carry the
[T]marker; recursion depth shows as>prefixes. - The same events will drive the OpenAI-compatible endpoint's streaming mode (ARCHITECTURE.md §5).
config.yaml holds the budget knobs and the two LM providers (no keys in code:
ollama-cloud reads OLLAMA_API_KEY from the environment). Logs live in runs/.
What is real vs stub (the honest map)
| Stage (ALGORITHM.md) | Status | Where |
|---|---|---|
| INIT — epistemic decomposition (LLM call) | real (dspy.Predict) | floop/dspy_modules.py |
| MISSING — gap decomposition on stuck goal | real (dspy) | floop/dspy_modules.py |
| ROUTE — one LLM judgement over the catalogue | real (dspy) | floop/dspy_modules.py |
| Expert attendants (the draft answer) | BASELINE engine: LLM answers from its weights; verified=False; source recorded (model_weights/given_evidence) |
floop/engine.py |
| knowledge expert | REAL pipeline (2026-10-17): KG probe (entity+relation, stemmed) -> TRANSLATE (queries+entities from context) -> en.wikipedia search -> fetch_rich (text + wikitext tables) -> section chunks -> lexical gate -> EXTRACT (verbatim quotes) -> containment check -> merge (4 contradiction cases) -> answer from quoted rows. Fallback: baseline LLM on pipeline failure. | knowledge/ + floop/engine.py:KnowledgeEngine |
| Arrival check (type check + contradiction) | STUB: only UNKNOWN refusal | machine._append_checked |
| Prover (stop condition, derivability) | STUB: question stack terminal | machine._finish |
user expert |
not wired — explicit failure row | floop/engine.py |
| Backtracking / retraction (TMS) | not in the draft (§5 comes with the prover) | — |
| The machine (stack, dependency order, budget, recursion) | real fixed code | floop/machine.py, floop/state.py |
| Evidence table (append-only, provenance, no prose) | real | floop/state.py |
Laws kept: the table only ever receives typed payloads (never LLM prose); rows carry provenance + trace; the machine — not the LLM — owns sequencing, budget, retries and stopping; answer synthesis sees only evidence rows and cites them.
Layout
config.yaml budget + LM providers
run_app.py CLI entry
floop/state.py EvidenceTable, QuestionStack, Budget, slot instantiation (#En -> value)
floop/llm.py dspy LM configuration (OpenAI-compatible endpoints)
floop/dspy_modules.py every LLM call as a dspy module (INIT, ROUTE, EXPERT, MISSING, ANSWER)
floop/engine.py engine interface + draft stub engines
floop/machine.py FloopRun — the loop; recursion for the `floop` attendant
tests/state.py unit tests (no LLM)
Next steps (design order from the docs)
- Real check layer on expert arrival (well-formedness per expert kind) — the #1 failure mode is misformalization; keep it BEFORE engines.
DONE 2026-10-17 (Wikipedia-only, en; DuckDuckGo + general web later).knowledgeexpert with real search + verbatim quotes- Prover for the stop condition (clingo/Z3) — replaces the stub derivability.
- Log every run (v2's router will eat these trajectories).
- Knowledge efficiency: the gather still spends extraction calls on tangential
articles (US river lists matched the "longest river" gate); tune gate/articles.
Also: KG dedupe of noisy entities from early runs (
the loirevsloire river).