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.
This commit is contained in:
2026-10-14 10:28:21 +02:00
parent e8fa401597
commit 67f466bd84
10 changed files with 540 additions and 544 deletions
+124 -46
View File
@@ -1,72 +1,150 @@
# FLOOP — how the machine works, in words
# ALGORITHM.md — the machine in words
This document describes what each part of the system **does**. No schemas, no code.
How floop serves any goal: the general loop, tool action, the generic expert, recursion,
stopping, failure, and how every LLM call gets its context composed.
## 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.
A goal arrives (a question to answer, a tool to call, a chat to hold, a maintenance task
to run). floop never "thinks a goal through" in one pass: the goal reduces to open
questions until one is small enough for a single expert call; answers flow back up and are
assembled into the response. Three kinds of parts do the work. **The LLMs** propose: read
the request, type the response expected, decompose the goal into subquestions, translate
between language and formal formats, compose the final prose. They never decide, never
compute, never assert facts. **The engines** — solvers, provers, retrieval, the knowledge
graph — do the deciding: deterministic, typed inputs in, typed payloads and traces out.
**The machine** — plain fixed code — owns the state: the open-question stack, the
dependency order, the budget, the retries, the stopping rule, and the per-call context
composition. One law runs through everything: a claim enters the state only as a typed row
with provenance — never as free-form model prose.
## 1. INIT — the opening
## 1. RECEPTION — typing the goal
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?"**
A request arrives with (possibly) a tool list. One LLM call reads it and declares the
**response type expected by the requester**: `answer` (a question to answer), `tool_call`
(an action to take), `chat` (conversation to hold), `meta` (a floop-maintenance task),
`plan_only` (a plan without execution). This typing annotates the goal — like
`answer_type`, it may be tightened later by evidence. It is NOT a path switch: whatever
the type, the goal is served by the same loop below. The typing costs one cheap call and
buys a contract: the output is checked against the declared type on arrival, and a
mismatch is a refusal-replan, not a silent guess.
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.
## 2. The main loop
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.
The machine keeps the **stack of open questions**, each declaring its answer type and its
dependencies (which questions it waits on). The loop, in words:
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.
1. **Stop check.** No open questions? Ask the prover: is the goal derivable from the
evidence table? Yes → synthesize the response. No → the decomposition was incomplete:
one more LLM call asks "what is still missing?" and new questions open. Stopping is a
formal condition, never a model's feeling.
2. **Pick.** Take the first question whose dependencies are all answered. If none can be
picked, a question is waiting on a failed answer: handle the failure (re-open,
re-decompose, escalate to the user). There is no search: dependency order IS execution
order.
3. **Route.** One cheap LLM judgement, with the expert catalogue in view, picks who
attends the question: a base expert, floop itself (recurse — too big for one call), or
the user (expert of last resort).
4. **Execute.** The attendant runs. Its result is checked on arrival: type must match,
claim must not contradict the table. A mismatch is refused — bounded reformulation
attempts; a contradiction triggers dependency-directed backtracking (§6). Nothing
untyped or unprovenanced is ever appended.
5. **Tick the budget.** Every LLM call and engine run costs. When the budget dies, the
loop stops and the LLM answers directly from what the table holds — explicitly
marked `Unverified`.
## 2. The main loop — the machine
## 3. Tool action — an output of the loop, not an alternative to it
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:
When the goal type is `tool_call`, the loop does not change: the harness's tool schemas
are evidence rows; "which tool satisfies the goal?", "what arguments does it need?",
"which of the previous observations are relevant?" are **ordinary subquestions**, routed
to experts like any other — logic reasons over schemas, analytic/numeric compute argument
values, knowledge supplies world facts. The loop's output is a `tool_call` row (tool,
arguments) whose provenance cites the schema rows and evidence that justify it; fixed
code validates it against the schema before emission. The harness executes the tool and
returns the observation, which enters the table as a `tool_result` row (a user-side fact,
never "verified", never silently retracted). Then the loop iterates on the new
observation — the next decision may be another tool, an expert, or stop. This is the ReAct
pattern with every step typed, evidenced and auditable; for the harness it looks exactly
like an LLM deciding tool calls. The prover's stopping predicate for tool goals: "the
evidence supports a concrete (tool, arguments)".
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.
## 4. The generic expert
## 3. The generic expert
Every expert is the same shape: **translate → check → solve → return**.
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.
- An LLM call (a dspy Signature) turns the question plus its referenced evidence into the
expert's formal format — the call receives a purpose-built context (§7), never the
whole state.
- A cheap formal check runs (well-typed, consistent units, well-formed query, trusted
source); failures go back to the translating LLM for bounded retries (≤3).
- The deterministic engine solves — no LLM inside. Out comes a typed payload with a
trace: a proof, a derivation, a verbatim quote with URL and access date.
- If nothing passes after the retries, the expert returns `Unverified` — the honest
fallback; the loop decides what to do with the hole.
The fleet, in words:
Fleet specializations (formal formats, checks, engines, payloads) live in
ARCHITECTURE.md §7. Two laws bear repeating: the LLM never computes — not even a
multiplication (`numeric` exists to enforce this); and `knowledge` never paraphrases —
its payload is the verbatim quote with provenance.
- **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.
## 5. Recursion — floop inside floop
## 4. Recursion — floop inside floop
A question too big for one expert call recurses: a child floop run on that question,
knowing its parent goal. Same loop, same discipline, two differences: **context shapes
adequacy** (the child knows why it is asked, so it knows when its answer is good enough)
and **budget is partitioned** (a slice of the parent's, plus a depth cap; a child that
cannot finish returns Unverified upward). The recursion bottoms out at the expert
catalogue — base case: one expert call; recursive case: one more level of the same
machine. There is no separate planner component: the plan is the open-question stack,
planning is proposing reductions of it, execution is answering from it.
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:
## 6. Failure and backtracking
- **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.
Failure is information. A contradiction in the table walks the provenance graph to the
culprit assumption, marks it retracted, and retracts exactly its downstream rows —
dependency-directed, not chronological; work that never depended on the dead assumption
survives; the corpse stays for inspection and learning (append-only). Factual hypotheses
(refutable by evidence) open branches; parameter assumptions (no evidence could refute
them) are dimensions of the answer function, never branches. And one thing can never be
retracted: the user. A user-supplied fact colliding with a source is presented verbatim
to the user — never silently resolved.
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.**
## 7. Per-call context composition
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.
Every LLM call gets its own purpose-built context, assembled by fixed code within the
model's window:
## 5. Failure and backtracking
- The machine state (evidence table, question stack, knowledge graph) is machine-sized —
disk, database, RAM — and can exceed any window. **No call ever receives the whole
state.**
- For each call the composer assembles: the task (the Signature's inputs), the referenced
rows (by id, compact summaries), the orientation the task needs (parent goal, section
headers, document chunk). What went in is logged.
- When the needed background exceeds the window, the machine **synthesizes** rather than
truncates: compact row summaries, structured KG subgraphs, chunked documents
(KNOWLEDGE.md). The callee gets what its function needs — not everything floop knows.
- Different calls to the same Signature may carry different context sizes: the contract
is the fields, not the window.
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.
## 8. Stopping and responding
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.
The stop condition is formal (prover over the table; for tool goals: a concrete
justified (tool, args) is derivable). Then — and only then — one final LLM pass composes
the response in natural language from the evidence rows and traces: every number carries
its source, every derivation its steps, every assumption its mark. If the budget died
first, the response is composed anyway from what the table holds — 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.
## 6. Stopping and answering
## 9. Who does what
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).
- **LLM, always**: reading and typing requests; proposing subquestions; translating
between language and formal formats; the routing judgement; composing responses.
- **Fixed code, always**: the question stack and dependency ordering; budget partition;
bounded retries; arrival checks; contradiction detection and retraction; refusing to
stop; per-call context composition.
- **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.