Files
floop/KNOWLEDGE.md
T
onibot 67f466bd84 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.
2026-10-14 10:28:21 +02:00

86 lines
4.6 KiB
Markdown

# KNOWLEDGE.md — the knowledge substrate
floop's knowledge lives on disk, not in model weights. This document defines the store,
how facts enter it, and how experts consult it.
## 1. The principle
**Model weights are not a knowledge store.** Anything floop claims to know must be
traceable to a trusted source: extracted from a fetched document, checked against it,
stored with provenance, and re-consulted from the store — never re-asserted from "model
memory". This is the epistemic core of the architecture: LLMs handle the language of
knowledge (find, extract, paraphrase-never, quote); algorithms handle its custody
(checks, storage, retrieval, merging).
## 2. The store
A persistent, append-only store on disk (SQLite + JSONL mirror in the draft; see
`code/knowledge/DESIGN.md` for schema and trade-offs). Contents:
- **documents** — fetched source texts (url, source, access date, checksum, text).
- **quotes** — verbatim spans from documents (the canonical text of a fact; url + access
date). Never paraphrased.
- **nodes** — entities (normalized name, sort: person, organization, concept, event,
quantity, document, place, date, other).
- **edges** — typed relations between nodes (or to literal values), each pointing at the
quote(s) that back it, with corroboration counts and extraction confidence.
- **conflicts** — same subject+relation with two different values: recorded and surfaced,
never silently merged.
Laws of the store: append-only (corrections are retraction flags, never overwrites);
every edge points at quotes (the quote carries the truth, the edge is the index);
quantities carry values AND units (the bridge to analytic/numeric computation); conflicts
are surfaced to the user, never auto-resolved; entity identity merges only on
normalized-name equality within the same sort (conservative by design).
## 3. How knowledge enters (the gather pipeline)
Extraction is the generic expert shape, run per document:
1. **Search & fetch** (engine): Wikipedia first (trusted-domain list in config), general
web later. Documents stored whole with checksums.
2. **Chunk** (engine): section-aware splitting sized to the model's window (~8k tokens
target, hard cap per call config). Context composition applies here like everywhere:
the extractor LLM sees the chunk plus its section path, not the whole document.
3. **Extract** (LLM Signature): per chunk, propose typed candidates — (subject, relation,
object/value+unit, verbatim span). Bounded retries on malformed output.
4. **Check** (engine, the gate): **verbatim containment** — the span must be
string-contained in the fetched document text; sort-checks on the relation's
endpoints; trusted-source check; dedupe. Rejected candidates are counted, never
silently dropped.
5. **Merge** (engine): into the store; corroboration counts; conflicts recorded.
A fact that fails containment does not exist. This is the cheap, deterministic check that
makes the KG trustworthy today, before any prover runs.
## 4. How knowledge is consulted (the probe)
KG-first: before any external fetch, an expert's question is matched to graph nodes
(seeds from the question's mentions) and the neighborhood is traversed (BFS depth 1 with
corroboration weighting in the draft; Personalized PageRank — HippoRAG's mechanism — is
the planned upgrade, adopted when measured recall justifies it). The probe is an engine:
no LLM inside. Multi-hop lives in the plan (one question referencing another's answer
slot), never hidden inside the expert.
What the probe returns feeds the calling LLM as compact, purpose-built context: quoted
spans with provenance, structured subgraphs sized to the window — not the whole store.
## 5. Knowledge growth over time
The store grows two ways: on-demand (a run's questions trigger gathers) and
**offline** — scheduled maintenance that fills gaps observed in past runs (entities
repeatedly unresolved, quotes whose checks failed, sources gone stale). Offline growth is
a `meta` goal (META.md §3): it uses the same gather pipeline, charged to a maintenance
budget, never inside a serving run.
## 6. Honest limits
- Extraction quality bounds KG quality: containment guarantees fidelity to the source,
not source truth — a quote can faithfully carry a false claim.
- Entity resolution is conservative (name-equality only in the draft); distinct nodes for
"Einstein" the person and near-miss names remain distinct until a measured linker
exists.
- Freshness: access dates are provenance; re-fetch policy is future work (a source older
than its field's decay rate should be re-consulted).
- The KG is floop's memory, not a world model: it holds what floop has had reason to
fetch, verify and keep.