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
+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.