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:
@@ -0,0 +1,72 @@
|
||||
# FLOOP — how the machine works, in words
|
||||
|
||||
This document describes what each part of the system **does**. No schemas, no code.
|
||||
|
||||
## 0. The whole machine in one paragraph
|
||||
|
||||
FLOOP answers a question by never "thinking it through" directly. Every question is reduced to smaller questions until one is small enough for a single expert — a real tool with a deterministic engine — to answer; the answers then flow back up and are assembled into the final reply. Three kinds of parts do all the work. **The LLM** proposes: it reads, decomposes, translates between language and formal formats, and writes prose. It never decides, never computes, never asserts facts on its own authority. **The experts** answer primitive questions with tools (search, solvers, computer algebra): formalization in, typed result with trace out, no LLM inside the tool. **The machine** — plain, fixed code — keeps the list of open questions, orders them by dependency, spends the budget, handles failure, and refuses to stop until a formal check says the goal is derivable from evidence. One law runs through everything: a claim enters the state only as a typed row with provenance (a verbatim quote, a solver result, a user reply, or a marked assumption) — never as free-form model prose.
|
||||
|
||||
## 1. INIT — the opening
|
||||
|
||||
When the user's question arrives, the system makes exactly one LLM call, and that call asks one generic meta-question: **"what information or knowledge do I need to answer this?"**
|
||||
|
||||
What this call may do: read the words of the question plus a generic scaffold — is it asking for a number, a method, a comparison? What kind of thing would count as an answer? From this, and only from this, it writes a short list of **open subquestions** in dependency order — each phrased as a question, each declaring what type of answer it needs, each allowed to reference the answers of the others.
|
||||
|
||||
What this call may NOT do: use domain knowledge. If the question is about bitcoin mining and quantum computers, INIT does not know what a hash is, what Grover's algorithm is, or that time might matter. Those facts arrive later, as evidence — and they *reshape* the plan: if the answer turns out to depend on something the question never mentioned (a clock speed, a time limit), the plan discovers that mid-run instead of importing it at minute zero.
|
||||
|
||||
INIT has no engine, because INIT does not solve anything. It is the *translate* stage of the orchestrator. Its solving stage is the entire loop that follows.
|
||||
|
||||
## 2. The main loop — the machine
|
||||
|
||||
The machine keeps one simple data structure: the **stack of open questions**. Each question declares the type of answer it needs and which other questions it depends on. The loop, in words:
|
||||
|
||||
1. **Stop check.** No open questions left? Ask the prover: is the user's original question now derivable from the evidence table? Yes → answer. No → the decomposition was incomplete, so one more LLM call asks "what is still missing?" and new questions open. The system stops because a formal condition holds — never because a model feels finished.
|
||||
2. **Pick.** Take the first question whose dependencies are all answered. If none can be picked, some question is waiting on an answer that failed: treat the failure (re-open, re-decompose, or escalate to the user). There is no search here: dependency order *is* execution order.
|
||||
3. **Route.** One cheap LLM judgement, with the expert catalogue in view, picks who attends the question: an expert that answers it in one call (the base case), **FLOOP itself** — i.e. recurse, this question needs decomposition — or **the user**, when nothing in the catalogue covers it. The user is the expert of last resort: the machine asks precise questions and files the replies as evidence.
|
||||
4. **Execute.** The chosen attendant runs. Its result is checked on arrival: the type must match what the question declared, and the claim must not contradict the table. A mismatch is refused — the error goes back for a bounded number of reformulation attempts; a contradiction triggers backtracking (§5). Nothing untyped or unprovenanced is ever appended.
|
||||
5. **Tick the budget.** Every action costs. When the budget dies, the loop stops and the LLM answers directly from what the table holds — explicitly marked as unverified.
|
||||
|
||||
## 3. The generic expert
|
||||
|
||||
Every expert is the same shape: **translate, check, solve, return**. An LLM call turns the question (plus whatever evidence rows it references) into the expert's formal format. A cheap formal check runs — well-typed expressions, consistent units, well-formed query, trusted source — and failures go back to the translating LLM for bounded retries. The deterministic tool solves: a solver, a search engine, computer algebra — no LLM inside. Out comes a typed result with a trace: a proof, a derivation, a verbatim quote with its URL. If nothing passes after the retries, the expert returns "unverified", and the loop decides what to do with the hole.
|
||||
|
||||
The fleet, in words:
|
||||
|
||||
- **knowledge** turns the question into search queries, fetches from trusted sources, and returns *verbatim quotes* with URL and date — never paraphrase. One round per call; a multi-hop chain is several visible calls, each built on the previous answer.
|
||||
- **logic** turns question and premises into a logic program (defaults allowed) and runs a solver; returns the answer and the proof.
|
||||
- **analytic** turns the question into equations where every quantity carries its unit; dimensional analysis is the type check; a computer algebra system solves exactly.
|
||||
- **numeric** evaluates closed expressions to numbers. It exists to enforce one law: the LLM never computes — not even a multiplication.
|
||||
|
||||
## 4. Recursion — floop inside floop
|
||||
|
||||
The orchestration "engine" is the recursion itself. When a question is too big for one expert call, the machine starts a FLOOP run *on that question*, passing down the context: "you serve this parent goal." The child behaves exactly like the top level — same generic INIT question ("what do I need to answer this?"), same loop, same discipline — with two differences that matter:
|
||||
|
||||
- **Context shapes adequacy.** The same subquestion deserves different depth depending on why it is being asked. "Which algorithm mines a block?" needs a different level of detail when the parent asks about quantum resources than when the parent is a history essay. The child always knows the parent, so it knows when its answer is good enough.
|
||||
- **Budget is partitioned, not infinite.** A child receives a slice of its parent's budget and a depth cap. A child that cannot finish returns "unverified" upward, and the parent treats that hole like any failed premise: re-decompose, retry, or ask the user.
|
||||
|
||||
The recursion bottoms out when a question is answerable by a single expert call (§2, step 3). Base case: one expert. Recursive case: one more level of the same machine. There is no separate "planner" component anywhere: **the plan is the open-question stack, planning is proposing reductions of it, and execution is answering from it.**
|
||||
|
||||
Seen from the side, the machine is a relative of Prolog: goals reduce to subgoals, subgoals are solved recursively, answers bind into the templates of later questions, failure backtracks. The differences: the reduction step is generated live by an LLM instead of looked up in a fixed clause database, the primitive predicates are the experts, and no reduction is ever assumed sound — the prover checks the final assembly anyway.
|
||||
|
||||
## 5. Failure and backtracking
|
||||
|
||||
Failure is information, not death. When a new piece of evidence contradicts the table, the machine walks the provenance links — every row records which rows and assumptions it was built from — finds the responsible assumption, marks it retracted, and retracts exactly the rows that descend from it. Work that never depended on the dead assumption survives. Because the table is append-only, the corpse stays for inspection: which hypothesis died, what killed it, what it cost.
|
||||
|
||||
Two kinds of "assumption" get different treatment, decided by one question: *could any evidence refute this?* If yes — a factual hypothesis — it lives as a branch: explore until evidence confirms or kills it. If no — a scenario parameter like a clock speed — it is not a branch at all but a dimension of the answer, marked as such and carried into the final reply. One thing can never be retracted: the user. When a user-supplied fact collides with a source, the machine does not silently pick a side; it asks, presenting the discrepancy verbatim.
|
||||
|
||||
## 6. Stopping and answering
|
||||
|
||||
The stop condition is formal: the original question is derivable from the evidence. Then — and only then — one final LLM pass writes the answer in natural language, working from the evidence rows and traces: every number carries its source, every derivation its steps, every assumption its mark. If the budget dies first, the LLM answers anyway from what the table holds, and the answer is explicitly marked unverified. The product is the same in both cases: a reply that tells you exactly which parts are proven and which are, honestly, a guess.
|
||||
|
||||
## 7. Who does what
|
||||
|
||||
- **LLM, always:** reading the question; proposing subquestions; translating between language and every formal format; the routing judgement (which attendant); the final prose.
|
||||
- **Fixed code, always:** the open-question stack and its ordering; budget partition and depth caps; bounded retries; type-checking on arrival; contradiction detection and retraction; refusing to stop.
|
||||
- **The prover (a solver, not a model), always:** the stop condition; "answered" for any question; the final derivability check.
|
||||
- **Never the LLM:** computing values, deciding when it is finished, writing free-form rows into the state, silently picking between conflicting facts.
|
||||
|
||||
## 8. What was removed, and why (v1 → v2)
|
||||
|
||||
The earlier draft had a symbolic planner (A* over a tiny action domain) choosing every move. For dependent question chains there is nothing for it to search — execution order is dependency order — so v1 drops it: decomposition is an LLM act, sequencing is a property of the stack, stopping is the prover's call. A real search planner earns its place only when open questions compete for a shared budget in parallel, or when routing costs are learned from logs — the rational-metareasoning step of v2. The recursion absorbs what "milestones" and "branch planning" used to do: the first decomposition level *is* the milestone list, and the stack *is* the living plan — only the first openable question is ever concretely instantiated, exactly the receding horizon we wanted.
|
||||
|
||||
Table laws, guarantees, risks and lineage live in [`PIPELINE.md`](PIPELINE.md).
|
||||
Reference in New Issue
Block a user