docs: SCOPE.md - floop beyond Q&A (GAP-11..14)

Reposition floop as a drop-in harness LLM (intent layer, tool_call flow and tool_result epistemics, progress streaming for CLI, offline self-analysis meta level feeding dspy prompt improvement and the v2 router). Design only, no code - per Emili's request. GAP-11..14 added to GAPS.md.
This commit is contained in:
2026-10-13 17:31:16 +02:00
parent 66f124a4a5
commit 550128c9bb
3 changed files with 154 additions and 2 deletions
+51
View File
@@ -172,6 +172,57 @@ too, so a child whose answer already exists in the visible table terminates with
confirm calls. The stop-check IS the cache/dedup of the architecture. confirm calls. The stop-check IS the cache/dedup of the architecture.
**Patch:** PIPELINE.md §3, §4; ALGORITHM.md §2, §4. **Patch:** PIPELINE.md §3, §4; ALGORITHM.md §2, §4.
### GAP-11 — floop's scope is "answer questions"; the drop-in-LLM contract has no intent layer
Emili (2026-10-13): floop's final goal is to **replace the LLM of a Hermes agent (or any
harness)** — floop acts as an LLM from the outside. A harness request is not always a
question: it can be a tool execution request, chat, or self-management. The current design
only handles `answer`-shaped requests.
**Bites:** positioned as a harness model, floop would decompose "what's the weather in
Barcelona?" (needing the harness's weather tool) into retrieval subquestions instead of
emitting a tool call — unusable as an agent LLM.
**Resolution (design in SCOPE.md):** a top-level intent gate (one LLM judgement + fixed-code
validation; the LLM proposes, code disposes — same philosophy as ROUTE): `answer | tool_call |
chat | meta | plan_only(future)`. Misroute matrix declared; ambiguous → user (expert of last
resort). Q&A becomes one use case of the interface contract.
**Patch:** SCOPE.md §1-§2 (new doc); README.md definition; PIPELINE.md §1 note.
### GAP-12 — tool_call flow and `tool_result` semantics
Follows GAP-11: nothing defines how a harness's tool list flows through floop, nor what a
tool result is epistemically.
**Resolution (SCOPE.md §3):** harness sends OpenAI-style tools with the request; an LLM call
proposes (tool, arguments); **code validates** against the tool's JSON schema + tool list
membership; the tool executes outside the LLM (or the tool_call object is returned to the
harness — same contract as any LLM). The result enters the evidence table as a **`tool_result`
row: an observation with provenance** (tool name, args, ts, payload) — epistemically like
UserReply rows: user-side facts about what happened, never "verified" claims, no containment
check (that gate is for source-document quotes), never silently retracted; conflicts → user.
**Patch:** SCOPE.md §3; PIPELINE.md §5 (add row type + provenance law note).
### GAP-13 — serving is invisible: no per-call progress stream, no run log
Emili (2026-10-13): running from CLI shows only the final summary; LLM calls can be long —
he wants (a) a line before each LLM call naming it, (b) the raw LLM output as it lands,
(c) the same for engines, (d) log-to-file always (flushed, `tail -f`-able) + screen output
only under a flag.
**Resolution (design in SCOPE.md §4):** one event format, two sinks: events `call|output|
state|final` always land in `runs/<ts>-<slug>/run.log` with explicit flush; a `--verbose`
flag tees the same stream to screen (flushed). Later, the same events drive the
OpenAI-compatible endpoint's streaming mode.
**Patch:** SCOPE.md §4; code/README.md next-steps; runner design only — no code yet.
### GAP-14 — no meta level: floop does not learn from its own behaviour
Emili (2026-10-13): after executing, floop should analyse its own answer — **offline, as a
scheduled task, after having already replied** — to (a) grow the knowledge store (fill KG
gaps observed in runs) and (b) learn from itself; and later, fine-tune the called LLMs and/or
let dspy optimizers (MIPROv2-class) improve the Signature-docstring prompts from our own
usage data.
**Resolution (design in SCOPE.md §5):** a `SelfAnalysis` dspy signature consumes a completed
run (report + stack + evidence + failures) and emits a structured critique, appended to the
run dir and to a lessons bank (`runs/lessons.md`). Dspy optimizer trainsets come from
critiques; the metric = post-hoc evaluator agreement (improvements adopted when measured,
never silently shipped). The v2 router connection: PIPELINE §7 says v1's logs are v2's
training data — the meta-level is the machinery that produces them.
**Patch:** SCOPE.md §5; PIPELINE.md §7 pointer.
--- ---
## Notes from the replay (not gaps — lessons) ## Notes from the replay (not gaps — lessons)
+3 -2
View File
@@ -2,15 +2,16 @@
**Fractal loop.** One algorithm — an LLM translates, a sound engine computes, the answer carries its proof — instantiated at every level of abstraction, including the orchestration level itself. The orchestrator is not a special component: questions too big for one expert recurse into new FLOOP runs, so the engine of FLOOP is FLOOP itself. **Fractal loop.** One algorithm — an LLM translates, a sound engine computes, the answer carries its proof — instantiated at every level of abstraction, including the orchestration level itself. The orchestrator is not a special component: questions too big for one expert recurse into new FLOOP runs, so the engine of FLOOP is FLOOP itself.
FLOOP is ReAct where the "thought" step is replaced by computation and the "observation" is typed before it enters the state. FLOOP is ReAct where the "thought" step is replaced by computation and the "observation" is typed before it enters the state. From the outside floop acts as an **LLM** (`messages + tools in → text or tool_call out`): the final goal is to be a drop-in replacement for the LLM of an agent harness. Answering questions is one use case; see [`SCOPE.md`](SCOPE.md) for the intent layer, the tool interface, and the self-learning meta level.
## Documents ## Documents
| File | Contents | | File | Contents |
|---|---| |---|---|
| [`SCOPE.md`](SCOPE.md) | floop beyond Q&A: drop-in-LLM positioning, the intent layer (answer / tool_call / chat / meta), tool_call + tool_result semantics, progress streaming, the offline self-analysis meta level. DESIGN, no code yet. |
| [`PIPELINE.md`](PIPELINE.md) | Definition of the pipeline: the generic expert pattern, the expert fleet, the orchestrator-as-recursion, the living plan, table laws, guarantees, v1→v2, known risks. | | [`PIPELINE.md`](PIPELINE.md) | Definition of the pipeline: the generic expert pattern, the expert fleet, the orchestrator-as-recursion, the living plan, table laws, guarantees, v1→v2, known risks. |
| [`ALGORITHM.md`](ALGORITHM.md) | How the machine works, in words: the opening call (INIT), the main loop, the generic expert and the fleet, recursion (floop inside floop), backtracking, stopping and answering. | | [`ALGORITHM.md`](ALGORITHM.md) | How the machine works, in words: the opening call (INIT), the main loop, the generic expert and the fleet, recursion (floop inside floop), backtracking, stopping and answering. |
| [`GAPS.md`](GAPS.md) | Design gap log from the step-by-step replay: what was missing, why it bites, proposed resolutions. | | [`GAPS.md`](GAPS.md) | Design gap log from the step-by-step replay: what was missing, why it bites, proposed resolutions. GAP-11..14 = the 2026-10-13 scope additions. |
## Status ## Status
+100
View File
@@ -0,0 +1,100 @@
# SCOPE.md — floop beyond Q&A
Status: DESIGN for review — no code yet. Extends PIPELINE.md/README; three additions from
Emili's review of 2026-10-13: (1) floop's goal is a drop-in LLM replacement, Q&A is one use
case; (2) the CLI must stream progress; (3) an offline meta-level that learns from floop's
own runs.
## 1. Reframing: floop as a drop-in LLM
floop exposes an **LLM-like interface**: `messages + system + tools in → text (or tool_call)
out`, OpenAI-compatible. A Hermes agent (or any harness) should be able to point its model
provider at floop and behave exactly as before. Everything inside is the fractal loop — LLM
calls that translate/propose, typed evidence, engines that decide, a prover that gates
stopping. "Answer questions" is what the loop does for one request type; the contract with
the harness is broader.
## 2. The intent layer (new top-level gate)
Every harness request first passes an intent classification — one LLM judgement (same style
as ROUTE) + fixed-code validation — over a closed catalogue:
- `answer` — decompose → experts → proven answer (the current FLOOP loop)
- `tool_call` — the request maps to an external tool from the harness's tool list
- `chat` — conversation management (greetings, clarification, small talk): no decomposition,
no engines; direct synthesis, honestly marked like everything else
- `meta` — floop on itself: self-analysis, KG maintenance (§5)
- `plan_only` (future) — return the plan without executing, for harnesses that want to drive
Validation is code: a `tool_call` must name a tool present in the harness-provided list, and
its arguments must validate against that tool's JSON schema; invalid classification falls
back to `answer` or escalates to the user (the expert of last resort). The misroute matrix:
answer-routed requests that needed tools waste budget but stay honest; tool_call-routed
requests that fail fail loudly into the failure path (re-route or user).
## 3. The tool_call flow
1. The harness sends `tools` (OpenAI-style) with the request.
2. An LLM call proposes `(tool, arguments)`; fixed code validates against the tool schema and
the tool list.
3. The tool executes **outside the LLM** (engine discipline: no LLM inside a tool run); if
floop runs embedded as a harness model, it returns the `tool_call` object and the harness
executes — same contract as any LLM.
4. The result enters the evidence table as a `tool_result` row: an **observation with
provenance** (tool name, arguments, timestamp, raw result or summary). Epistemic treatment
identical to user replies: user-side facts about what happened, not verified claims; no
containment check (that gate is for source-document quotes); never silently retracted —
conflicts go back to the user.
## 4. progress streaming + run logs (CLI)
Design: an event stream is produced on every run — one format, two sinks.
Events: `call` (stage starting: INIT | ROUTE | EXPERT | MISSING | ANSWER | ENGINE, with input
summary), `output` (raw LLM output or engine payload), `state` (evidence row appended,
question status change, budget tick), `final` (the report).
Sinks:
- **Always**: `runs/<ts>-<slug>/run.log`, written with explicit flush after every event, so
`tail -f floop/code/runs/<latest>/run.log` works from another terminal.
- **`--verbose` flag**: tee the same events to the screen with `print(..., flush=True)`.
- (later, same events) the OpenAI-compatible endpoint's streaming mode: SSE-style events for
external consumers (§2-bis of the interface contract).
## 5. The meta-level: floop learns from its own runs (offline, future)
After answering, floop analyses itself — **as a scheduled task, not inside the serving
loop**. Design shape:
- **Self-analysis run** (a dspy signature, e.g. `SelfAnalysis`): input = a completed run's
report + question stack + evidence table (+ tool results, + which steps failed); output =
structured critique — where decomposition over-split or under-split, where routing misfired,
where the check layer should have caught something, budget spent well or wasted, and what
the lesson is. The critique is appended to the run dir and to a **lessons bank**
(`runs/lessons.md`), and its structured fields are what the v2 router will train on.
- **Knowledge growth**: the same scheduled task may run knowledge-expert gather offline —
filling KG gaps observed in past runs (entities repeatedly unresolved → fetch their
Wikipedia entry proactively).
- **Prompt improvement (dspy-native)**: our prompts are Signature docstrings; dspy's
optimizers (BootstrapFewShot now, MIPROv2-class later) can compile improved prompts from
the lessons bank + critiques — trainset = critiques with quality labels, metric = a
post-hoc evaluator's agreement. Adopted only when measured (never silently swap prompts).
- **Fine-tuning path (later)**: logged trajectories become SFT data for the models we call —
floop's honest logs are the dataset.
Connection to the plan: v2's learned router (PIPELINE §7) needs exactly these logged
trajectories + critiques as training data; the meta-level is how they get produced.
## 6. Doc ripple (what else changes when this lands)
- README: reposition the definition ("floop is a drop-in LLM replacement with provable tool
behaviour; Q&A is the first use case").
- PIPELINE.md: add the intent gate as §3-bis-antecessor (a top-level step before INIT) and
`tool_result` as a new evidence-row type in §5.
- GAPS.md: GAP-11 (intent layer), GAP-12 (event stream + run logs), GAP-13 (meta-level +
lessons bank) — entries with what/where-bites/resolution.
## 7. Explicitly NOT now
No code for the gate, the endpoint, the event stream, or self-analysis — this document only.
Everything here is future work recorded while the project is being defined, per Emili.