Files
floop/GAPS.md
T
onibot 6733cb660e feat(stream): thinking + run log for CLI (GAP-13 CLI part)
RunStreams: run.log always (flushed, tail -f-able) with full technical detail; thinking stream to screen under --verbose (flushed, [T] lines, > depth prefixes). Machine hooks on INIT/MISSING/ROUTE/EXPERT/ANSWER + budget ticks; child runs share the parent's stream; engine emits its raw output. Verified live: 8-call train run inline, fresh-question run 69.6s (proxy caches identical temp-0 prompts; noted).
2026-10-13 17:50:57 +02:00

241 lines
16 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# FLOOP — Gap log (step-by-step replay)
Running log of design gaps found while virtually executing FLOOP on:
*"Quants qubits cal que tingui un ordinador quàntic per minar un bloc de bitcoin?"*
Each entry: what's missing → where it bites → proposed resolution → which doc to patch.
Status: **proposed**. Nothing patched yet — resolutions get merged into PIPELINE.md /
ALGORITHM.md at the end of the replay, once the walkthrough is complete.
---
## Found at INIT (step 1)
### GAP-1 — Goal schema undefined
`ALGORITHM.md` says INIT emits a "goal formula", but nothing defines its vocabulary or shape.
**Bites:** `PROVER.derivable` can only check goals written in the same sorted language the
evidence will be formalized into; left free-form, the LLM invents predicates the prover
cannot consume. No home for: answer type, free parameters, success criterion,
presupposition flags.
**Resolution:** new core type
`GoalSchema { quantity, unit?, answer_type, params[], criterion, presuppositions[] }`.
INIT emits it; `ANSWER` validates its output against it; flagged presuppositions may become
milestones (e.g. an m0 "frame check") at the planner's discretion.
**Patch:** ALGORITHM.md §0, §3; PIPELINE.md §3.
### GAP-2 — `Assumption` type and ask-vs-assume criterion missing
In the first replay, LLM-authored defaults entered the evidence table disguised as
`UserReply` (provenance: "assumption") — type pollution that violates invariant #1 in
spirit: LLM prose entering the table through the user channel.
**Resolution:** new evidence type `Assumption { author: llm, marked: true, weakens_verification }`.
Formal criterion for `ask_user`: a free parameter whose plausible range moves the answer
by ≥ 1 order of magnitude → ask; otherwise assume + mark. A verified answer must list
every Assumption it depends on.
**Patch:** PIPELINE.md §5; ALGORITHM.md §0.
### GAP-3 — Milestone acceptance criteria unspecified
Who validates an LLM-proposed decomposition? Nothing guarantees m1..mk ⇒ goal — proving
that would require solving the problem itself.
**Resolution:** acceptance check = formula well-sorted + usable as a planner subgoal.
State explicitly in the docs that **decomposition is heuristic**: system soundness rests
on the final PROVER check + replanning, not on decomposition soundness. (Honest
limitation to declare, not a bug to fix away.)
**Patch:** PIPELINE.md §4; ALGORITHM.md §3.
### GAP-4 — Answer typing (constant | interval | function)
The replay's goal had a free parameter (t_or) but ANSWER returned scenario constants —
presenting a function as bare numbers is exactly what made the answer feel wrong
("massa gran?"). The system should have *refused* to print a single number.
**Resolution:** `GoalSchema.answer_type ∈ {constant, interval, function}`; ANSWER must
match it; when later evidence bounds a parameter, function → interval → constant
(the answer tightens as evidence arrives).
**Patch:** ALGORITHM.md §6.
### GAP-5 — Fractal-table mapping bug (PIPELINE.md §3)
The orchestrator row maps CHECK → `PROVER.derivable`. But in the generic expert, CHECK
gates the *formalization before the engine runs*; derivability is the engine's goal test
(the stop condition). The table conflates the two.
**Resolution:** orchestrator's formalization check = GoalSchema validity (GAP-1);
engine goal-test = derivability (stop condition). Fix the table.
**Patch:** PIPELINE.md §3.
### GAP-6 — Budget policy undefined
Termination depends on `budget.exhausted()` but nothing sets the initial budget or its units.
**Resolution:** budget = cost units of the meta-domain price list (§5); set by user or system
default at INIT; logged per run; `ask_user` priced high (human latency).
**Patch:** ALGORITHM.md §3, §5.
### GAP-7 — Assumption branching & dependency-directed backtracking (TMS-lite)
Backtracking exists at search level (A* explores/prunes the plan space every turn, cheap),
but there is no machinery for branching over **hypotheses across turns**: a factual hypothesis
opens a world-branch that lives until evidence refutes or confirms it; on contradiction the
branch must die *including everything built on top of it*. Current design only replans the
active branch — nothing retracts downstream rows derived from a refuted premise.
**Bites:** the evidence table is a single linear world; a refuted premise leaves contradictory
rows alive; contradictions linger and poison the prover's derivability checks.
**Resolution:**
- Distinguish **factual hypotheses** (refutable by evidence → branch: explore, kill or
confirm; a refuted row is marked RETRACTED) from **parameter assumptions** (GAP-2; not
refutable by any evidence → scenario contexts, dimensions of the answer function, never
branches). Criterion: *if no possible evidence could refute it, it is a parameter, not a
hypothesis*.
- Consistency CHECK on every append; on contradiction, **dependency-directed backtracking**
(not chronological): walk the provenance graph from the contradictory rows → find culprit
assumptions → mark RETRACTED → transitively retract every row whose provenance includes a
culprit → replan the affected branch only.
- The provenance graph the table already carries for auditability **doubles as the TMS
justification graph** (Doyle 1979; ATMS de Kleer 1986 = the multi-world v2 option — keep
all assumption contexts alive in parallel).
- Append-only + retraction marks preserve the corpse: the dead-branch log (hypothesis,
what refuted it, what it cost) is exactly the training data for the learned v2 router.
**Worked example from the replay:** E5 ("the 1,151-qubit article measures the mining
oracle") was a factual hypothesis; CHECK flagged it; one targeted knowledge call refuted it
(it was Shor on ECDSA); the row died, nothing downstream depended on it. The machinery to
do this automatically is what this gap adds.
**Patch:** PIPELINE.md §4, §5; ALGORITHM.md §3.
### GAP-8 — INIT must be epistemically closed over the question's vocabulary
The replay's INIT emitted a goal full of domain predicates (`minQubits(T,D,t_or)`,
`N_c = D·2³²`, Grover, Zalka) — LLM world knowledge dressed as formalism, i.e. domain
content entering through the back door at t=0, before ANY evidence exists. Same disease
as CYC, one level up. Also: INIT imported the *competitive* framing (T = 600 s), which
inflated the answer by ~17 orders of magnitude — the user's "massa gran" was the symptom.
**Resolution (user's correction, adopted):**
- INIT may use ONLY: (a) concepts literally present in the question, (b) a small generic
planning scaffold (number, method, machine, resources, dependencies). No domain
predicates, no parameters, no time, no answer structure.
- **GoalSchema shrinks**: `{quantity, of, answer_type: OPEN, criterion}`. `answer_type`
starts OPEN — constant vs function vs interval is *discovered by the plan* when evidence
reveals dependencies, and tightens OPEN → FUNCTION → INTERVAL → CONSTANT.
- **Milestones become epistemic questions**, not formulas: `Milestone{question, produces,
deps}` — done = a sourced answer exists in the table. Dependency chains make milestones
*templates over slots* (ReWOO at milestone level): m2 cannot even be instantiated until
#m1 is filled. The first branch therefore has exactly ONE concrete step.
- Domain structure (including whether time matters!) enters ONLY via evidence rows; if
evidence at m3 says "the count depends on clock / parallelization policy", THEN the
planner opens parameters (and GAP-2's criterion decides ask_user — a machine-vs-fleet
spread of ≥10⁹ fires ask_user, which the first run skipped and decided alone).
**Patch:** PIPELINE.md §3, §4; ALGORITHM.md §0, §3, §6. Deepest gap so far — affects
fractality: the orchestrator's "formalization" is now question decomposition (a linguistic
skill, domain-independent), not domain modeling.
### GAP-9 — Semantics of user-supplied knowledge (UserReply rows)
In the replay, the user volunteered domain knowledge from memory (how the mining threshold
works) via chat. The docs define `UserReply` as a type but never say what the system does
with user-provided *facts* (as opposed to user-provided *scope decisions*, which the
ask_user action was designed for).
**Bites:** (a) Is a user fact a premise immediately, or does it need verification?
(b) What happens when cited evidence contradicts a user row? GAP-7's retraction machinery
assumes the culprit is a machine-checkable assumption — but you cannot "retract" the user.
(c) ANSWER ships sources: "the user told me" is provenance, but a reader cannot audit it.
**Resolution (proposed):**
- User rows are premises (user is the authority on intent and scope) but are typed
`UserReply{claim, marked: true}` and ALWAYS carry `provenance: user` into the final
answer — user-asserted facts are listed separately from source-cited facts.
- If a user fact is **load-bearing** for the goal (the derivation would collapse without
it) and verification is cheap, the planner may schedule a confirm-call to `knowledge`
— the row stays, the citation gets attached.
- On conflict between a user row and sourced evidence: **never silent-pick**. Fire
`ask_user` presenting the discrepancy verbatim (quote + user claim). The user is
the tie-breaker on facts, not the system.
**Patch:** PIPELINE.md §5; ALGORITHM.md §0.
### REDESIGN-1 — The orchestrator's engine is recursion into FLOOP (no symbolic planner in v1)
User proposal, adopted: INIT is a single LLM call ("what do I need to know to answer this?");
subquestions too big for one expert are solved by a recursive FLOOP run that knows it serves a
parent goal. The A*/clingo meta-planner was over-engineering: with dependent questions,
execution order = dependency order — nothing to search. Division of labour now: decomposition
proposal = LLM (linguistic, epistemically closed per GAP-8); sequencing/budget/depth/retries/
retraction = fixed code; stop = prover; expert-vs-recursion-vs-user per question = one cheap
LLM judgement over the expert catalogue (which now contains floop itself as the decomposition
expert, and the user as expert of last resort). A* returns only in v2 (budget competition
between parallel branches / learned routing costs). Supersedes the PLANNER-centric sections
of both docs — ALGORITHM.md rewritten as a prose description of the machine.
### GAP-10 — Adequacy contract & the decomposition criterion (found at depth-1 replay)
Walking the child run exposed three things the docs left implicit:
(a) **Who decides "is this question primitive or does it need decomposition?"** — no criterion
existed. Working answer: decompose only when a single expert call cannot produce an answer
of the declared type; prefer routing first and decomposing **on failure** (type-check miss /
shallow quotes), not by upfront inspection.
(b) **Adequacy for the parent lives in the declared answer type.** The child knows why it is
asked (parent context), and the parent's need is expressed as the fields of the declared
type (e.g. `Algorithm{function, input, variable, success_condition}`). A quote that fills
3 of 4 fields fails the arrival check → targeted retry/decomposition of just the missing
field. The type IS the parent-child interface.
(c) **Derivability degenerates for descriptive questions**: no real logical derivation, just
"an adequate typed, sourced row exists". Formal rigor concentrates where composition happens
(analytic/numeric levels). State this honestly — the prover is not equally strong at all
nodes of the tree.
**Also discovered (not a gap — a freebie):** the stop-check runs on newly-opened questions
too, so a child whose answer already exists in the visible table terminates with zero or one
confirm calls. The stop-check IS the cache/dedup of the architecture.
**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) — CLARIFIED by Emili the same day:** screen ≠ log. The
screen is the future **"thinking" output of floop-as-LLM** (a readable subset); the log is
the full technical record and stays a superset — they will diverge. **IMPLEMENTED (CLI part,
2026-10-13):** `floop/stream.py` (`RunStreams`: log always flushed; `think()` → screen iff
verbose), machine hooks on every LLM stage + engine + budget tick, child runs share the
parent's stream; `run_app.py --verbose`. Verified live: 8-call run shows reasoning inline.
**Remaining:** real token-level streaming (dspy/litellm path) and the endpoint SSE mode.
**Patch:** SCOPE.md §4; code/floop/stream.py; code/README.md next-steps.
### 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)
- The E5 rejection (Shor-on-ECDSA article posing as "quantum attack on Bitcoin") was the
type checker doing its job — the fleet config's `check` caught a cross-type confusion.
Keep per-expert checks that know the *failure shapes* of their sources.
- The knowledge expert ran degraded (search snippets only — page extraction unavailable)
and should have downgraded confidence accordingly. Degraded-source confidence policy
is a small open question, related to GAP-2.
- The honest answer to the demo question is a function of t_or (and weakly of D, T);
the literature-standard constant (~2.4k–13k logical qubits, one machine, no deadline)
is the collapse of that function under "no clock constraints".