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).
This commit is contained in:
+137
@@ -0,0 +1,137 @@
|
||||
# FLOOP — Pipeline Definition
|
||||
|
||||
**FLOOP = fractal loop.** An architecture where:
|
||||
|
||||
- an LLM **translates** between natural language and formal representations,
|
||||
- a **sound computational engine** does the deciding — solving, proving, planning,
|
||||
- the answer **carries its proof** — every verified claim is traceable to typed evidence and engine traces.
|
||||
|
||||
The same pattern runs at every level of abstraction: inside each expert, and at the orchestration level — which is not a special component but the same loop run recursively on subquestions. That is the "fractal".
|
||||
|
||||
Division of labour, stated as laws:
|
||||
|
||||
1. **LLMs never reason to conclusions and never compute values.** They translate, they decompose questions, they interpret.
|
||||
2. **Engines never see natural language.** They receive typed formalizations and return typed results plus traces.
|
||||
3. **Nothing is "done" or "answerable" because a model said so.** Both are formal checks made by a prover over the evidence.
|
||||
|
||||
---
|
||||
|
||||
## 1. The generic expert pattern
|
||||
|
||||
Every expert is an instance of one shape — formalize → check → solve → return:
|
||||
|
||||
```
|
||||
task (NL or typed refs)
|
||||
│
|
||||
▼ LLM (translate)
|
||||
formal representation (typed grammar: formulas, equations, query plans)
|
||||
│
|
||||
▼ CHECK (cheap, formal: sorts, units, consistency)
|
||||
│ fail ──▶ error fed back to LLM ──▶ re-formalize (≤ 3 refinements)
|
||||
▼
|
||||
ENGINE (sound, deterministic, no LLM inside)
|
||||
│ fail ──▶ error fed back to LLM ──▶ re-formalize
|
||||
▼
|
||||
typed payload + trace (proof / derivation / citation chain)
|
||||
```
|
||||
|
||||
Two design decisions locked in this document:
|
||||
|
||||
- **The expert's output is a typed formal payload, not prose.** Interpretation (formal → NL) happens once, at answer synthesis. Prose inside the pipeline would make the evidence un-checkable by the prover.
|
||||
- **Self-refinement is bounded** (≤ 3 attempts). If formalization never passes or the engine never solves, the expert returns an *Unverified* result — the honest fallback. Nothing is ever silently guessed and marked as verified.
|
||||
|
||||
## 2. The expert fleet
|
||||
|
||||
Each expert is the generic shape plus a configuration. All of them return typed evidence rows — never raw text.
|
||||
|
||||
| Expert | Formalizes into | Formal check | Engine | Typed payload |
|
||||
|---|---|---|---|---|
|
||||
| `logic` | sorted FOL / Horn program + query | well-sorted, consistent, query well-formed | clingo / Z3 / Prover9 (picked by problem class) | model + proof trace |
|
||||
| `analytic` | equations over quantities, each with a Unit | **dimensional analysis** (units are the type system) | SymPy `solve` / `simplify` / `dsolve` | symbolic value + unit + assumptions |
|
||||
| `numeric` | closed-form expressions + constants | dimensional analysis | SymPy `evalf` | numeric value + unit + precision |
|
||||
| `knowledge` | retrieval plan: query templates with slot refs | source ∈ trusted list, freshness, no duplicate | search + fetch (Wikipedia, trusted sources) | verbatim quote + url + access date |
|
||||
|
||||
Notes on the fleet:
|
||||
|
||||
- **`numeric` exists to enforce a law**: the LLM writes expressions; it never evaluates arithmetic — not even a multiplication. All computation is delegated to an engine.
|
||||
- **`knowledge` never paraphrases.** Its payload is the verbatim quote with provenance. Synthesis quotes the citation; it does not restate it.
|
||||
- **Multi-hop retrieval is not inside `knowledge`.** Each call is one round of search+fetch. Multi-hop emerges at the orchestration level: one question references the answer of another — the hops live in the question stack, where they are visible and auditable.
|
||||
|
||||
## 3. The orchestrator is an expert — and its engine is FLOOP itself
|
||||
|
||||
The component that decides how to answer is not a special "planner" piece: it is the generic pattern one level up, with **recursion as its engine**.
|
||||
|
||||
| Generic stage | Orchestrator instantiation |
|
||||
|---|---|
|
||||
| LLM formalizes the task | one LLM call asks the generic meta-question: *what information or knowledge do I need to answer this?* — and emits a short list of open subquestions (epistemically closed over the question's own words: no domain vocabulary allowed) |
|
||||
| CHECK | the goal is well-formed; subquestions are typed, in acyclic dependency order |
|
||||
| ENGINE solves | **FLOOP itself**: each subquestion runs through the same loop — directly by an expert, or recursively by a new FLOOP run that knows it serves this goal |
|
||||
| typed payload + trace | answered subquestions append typed evidence; the final answer carries its derivation |
|
||||
|
||||
Why this works — and why there is no A* in v1: with questions that carry dependencies, **there is nothing to search**. Execution order *is* dependency order: take the first open question whose inputs are filled. Decomposition is a linguistic act (LLM), sequencing is a property of the question list (code), and stopping is a formal check (prover). The earlier design's symbolic meta-planner was over-engineering — it earns its place only when open questions compete for budget in parallel (v2).
|
||||
|
||||
- The machine **runs on slots and types, never content**: a question is instantiated only when the answers it references exist, with the right types.
|
||||
- The orchestrator LLM translates (question → subquestions; results → next instantiation; final evidence → NL answer). It **never decides when to stop** — that is the prover's job.
|
||||
- The recursion bottoms out at the **expert catalogue**: for each open question, one cheap LLM judgement picks who attends it — `knowledge`, `logic`, `analytic`, `numeric`, **`floop` itself** (the decomposition expert: this question is too big for one call), or **the user** (expert of last resort, when nothing else covers it).
|
||||
|
||||
## 4. The living plan (receding horizon)
|
||||
|
||||
Plans are not written once and followed. FLOOP plans like MPC (model predictive control):
|
||||
|
||||
- The **goal** is fixed. The **open questions** — the first level of decomposition — mark the way; each is answered by evidence or by further decomposition, never by fiat.
|
||||
- Only the **first openable question** is concretely instantiated (its inputs exist, its attendant is chosen); the rest wait as questions-with-references until their turns come.
|
||||
- After every answer, the machine re-decides against the new table: invalidated questions reopen, dependencies resolve, new subquestions may be proposed. No global replanning — **the stack is the plan**.
|
||||
|
||||
Replan triggers are formal, not vibes:
|
||||
|
||||
- an answer arrives with an unexpected type, or below the confidence the question declared it needed;
|
||||
- a question's precondition is no longer derivable from the evidence;
|
||||
- evidence makes a cheaper path to the same subquestion obvious.
|
||||
|
||||
Stop conditions are formal too:
|
||||
|
||||
- **answer**: the goal is derivable from the evidence table (prover check) → synthesize the verified answer;
|
||||
- **budget exhausted** → honest fallback: an *Unverified* answer, marked as such.
|
||||
|
||||
## 5. The evidence table
|
||||
|
||||
The shared state — one per run, **append-only**, visible to everyone. Each row: an id (referenced by questions), a type, a typed payload (formal value, verbatim quote, or user reply — never LLM prose), an engine trace (proof | derivation | url chain), and provenance (expert, sources, cost, timestamp).
|
||||
|
||||
Laws of the table:
|
||||
|
||||
1. **Only engines write to it** (typed payloads), plus verbatim quotes and user replies. The orchestrator LLM reads it but never writes free-form rows — that is the single most dangerous injection point of the architecture, so it is closed by rule.
|
||||
2. **Every row carries provenance.**
|
||||
3. **Derivability runs over formal rows only.** A `Citation` is a premise, not a fact: some question must formalize it before it can support the goal or any subquestion's answer. A verified answer therefore always cites sources that were themselves formalized.
|
||||
4. Prose is never stored. The only text in the table is verbatim source quotes (and user replies, typed as such).
|
||||
|
||||
## 6. Guarantees
|
||||
|
||||
What FLOOP promises, and on what condition:
|
||||
|
||||
- **Auditable answers.** Every verified answer ships: the claim, the derivation (which facts, which rules, which engines), and the sources. This is the product — reasoning you can check, not a confidence score.
|
||||
- **Bounded routing, sound stopping.** Who attends a question is an LLM judgement over a small expert catalogue, type-checked on arrival; when to stop is a formal check (derivability), never a model's feeling.
|
||||
- **Honesty at the boundary.** What cannot be formalized or solved within budget is answered by the LLM directly and explicitly marked *Unverified*.
|
||||
- The guarantee is conditional on formalization quality — see §8.
|
||||
|
||||
## 7. v1 → v2
|
||||
|
||||
- **v1** (this document): LLM translates and decomposes; the machine is fixed control code (open-question stack, budget slices, depth cap, bounded retries, retraction); the prover is clingo/Z3. Everything sound is sound by construction, everything cheap is cheap by prompt.
|
||||
- **v2**: the **router is learned** — costs and expected gains (value of computation) estimated from logged trajectories (rational metareasoning, Russell & Wefald 1991). The machine stays sound; only its cost model becomes data-driven — and if parallel branches ever compete for a shared budget, that is where a real search planner earns its place. The logs v1 produces are exactly the training data v2 needs.
|
||||
|
||||
## 8. Known risks (stated, not hidden)
|
||||
|
||||
1. **Misformalization with a veneer of rigor** — the top failure mode. A wrong formalization of "most birds fly" produces a mathematically correct answer to the wrong question. Mitigations in the design: sorted logics and units as type systems (kill half the errors before solving), bounded self-refinement, provenance on every row, and — planned — the **round-trip check**: re-translate the formalization back to NL and compare with the original.
|
||||
2. **Non-monotonicity.** Default reasoning (birds fly… except penguins) lives in the `logic` expert via ASP default negation, not in FOL-pure solving.
|
||||
3. **Over-decomposition.** Pure-LLM decomposition can produce subquestions whose answers never feed the parent. Contained by: budget charged per question, dependency typing on arrival (an answer nobody consumes flags the dead question), and the final derivability check.
|
||||
4. **Infinite regress.** Recursion needs a depth cap and a budget slice per level; a child that cannot finish returns "unverified" upward.
|
||||
5. **Ambiguity, reference, pragmatics** stay on the neural side, deliberately. FLOOP does not attempt to formalize the world — it formalizes what a task needs, checks what it formalized, and marks the rest as unverified.
|
||||
6. **Scope.** Each expert is a small pipeline with its own failure modes; the whole is several projects. Build order: one expert end-to-end on a benchmark, then the loop, then the fleet.
|
||||
|
||||
## 9. Lineage
|
||||
|
||||
- **Logic-LM** (Pan et al., EMNLP 2023, arXiv:2305.12295) — the lm→solver pipeline with self-refinement; +39% over plain LLM on logic benchmarks. The generic expert pattern.
|
||||
- **ReWOO** (Xu et al., 2023, arXiv:2305.18323) — plan-on-slots, decoupled execution; 5× token efficiency, +4% HotpotQA. The slot mechanism and the evidence table.
|
||||
- **LLM-Modulo** (Kambhampati, ICML 2024, arXiv:2402.01817) — LLMs can't plan, but can help: propose, let external verifiers decide. The orchestrator's philosophy.
|
||||
- **LLM+P** (Liu et al., 2023, arXiv:2304.11477) — NL → PDDL → classical planner → NL. Translate, plan, translate back.
|
||||
- **POMDP-Coder** (2025, arXiv:2505.02216) — LLM writes the world model as a probabilistic program; a POMDP solver plans. Measured evidence that "lm models, solver decides" beats "lm decides".
|
||||
- **Rational metareasoning** (Russell & Wefald 1991; for LLMs arXiv:2410.05563) — deciding what to compute next is itself a decision problem. The v2 router.
|
||||
Reference in New Issue
Block a user