floop: execution branches over ambiguity — fork per reading, conditional answer

His branching design (22-23/10, consolidated; now coded): when an
expert returns SEVERAL defensible readings of one question (the
knowledge ablation audit's ambiguous + alternatives payload), a
question that DEPENDS on that row must not inherit the coin-flip.
The old behaviour: alternatives were passed in the router context
(rejected — it only moves the guess into answer_kg) or collapsed
inside the ANSWER prompt (run L: 'Papandreou was the predecessor' —
the exact rejected behaviour).

The mechanism (floop/branches.py + machine._run_branch):
- LAZY: a branch is born only when the ambiguous row has an OPEN
  dependent subtree (open_subtree, frozen at fork time so every
  branch of the fork copies the same questions); an ambiguity nobody
  needs stays a note.
- A branch is a WORLD, not a fork of the run: the dependent subtree
  is re-created inside the branch with branch-scoped qids (B1.Q2),
  and the shared evidence table is read through a BranchView that
  BINDS the ambiguous row to the branch's reading (a VIEW — the table
  is never mutated, the original row keeps all readings) and hides
  other branches' rows.
- SHARED: acquired knowledge lands in the ONE table, tagged
  provenance['branch']; the KG/seen-index live in the expert, shared
  by construction. A later branch reuses an earlier one's gathering.
- DEATH: by contradiction, dead end (all branch questions failed) or
  NATURAL MERGE (same normalized answer as another branch — one
  conclusion, recorded merged). Never an absurdity judge.
- NESTING: an ambiguous row answered inside a branch (with its own
  dependent) opens sub-branches under it (origin=<branch id>); the
  parent carries its children's conditional as its answer. Branch
  cap (6) drops and NAMES extra readings — never silent.
- CONDITIONAL ANSWER: _finish composes the final answer by FIXED
  CODE over surviving branches — 'if you meant X -> A | if you meant
  Y -> B'; single survivor renders plain. Never a synthesis prompt
  choosing a reading inside itself.
- WARNINGS: FORK/BRANCH lines on screen AND log ([W]) — the fork is
  a machine judgement worth a human's eye, and META's lessons bank
  counts them.

Docs: ALGORITHM.md §6-bis (the mechanism as a law); README honest map
row. Tests: tests/branches.py — 5 E2E (fork+conditional, lazy no-fork,
dead-branch honesty, natural merge, nested sub-branches). Suite 18/18.

Live smoke (ollama-cloud, warm agent KG): the Pedro question runs
clean through the new paths (8 calls, 52s, honest answer; the fork
did not fire — the audit found no second reading in that KG; the
mechanism is proven by the E2E tests, the real-detector proof is his
local run over his accumulated KG).
This commit is contained in:
2026-10-23 16:29:26 +02:00
parent 1df3ec591b
commit 004c7974c6
5 changed files with 916 additions and 14 deletions
+34
View File
@@ -136,6 +136,40 @@ them) are dimensions of the answer function, never branches. And one thing can n
retracted: the user. A user-supplied fact colliding with a source is presented verbatim
to the user — never silently resolved.
## 6-bis. Execution branches over ambiguity (2026-10-23, coded)
When an expert answers with SEVERAL defensible readings (the knowledge ablation audit
flags `ambiguous` + named alternatives), a question that DEPENDS on that row does not
inherit the coin-flip. The machine opens ONE EXECUTION BRANCH PER READING:
- **Lazy.** The branch is born only when the ambiguous row has an open dependent
subtree — an ambiguity nobody downstream needs stays a note; the picked reading rides.
The subtree is frozen at fork time: every branch of the fork copies the same questions.
- **A branch is a world, not a fork of the run.** The branch reads the shared evidence
table through a VIEW that binds the ambiguous row to its reading (the same law as the
ablation mask: the table is never mutated — the original row keeps all its readings)
and hides other branches' rows. Acquired knowledge (new rows, KG facts, fetched
articles, conclusions) lands in the ONE shared store, tagged with the branch id —
a later branch reuses an earlier branch's gathering for free.
- **Death is honest.** A branch dies by contradiction, dead end (all its questions
failed — UNKNOWN), or natural merge (its answer equals another branch's — deduped by
normalized value, one conclusion). Never by an absurdity judge: surprising-but-cited
answers render.
- **Nesting composes.** An ambiguous row answered INSIDE a branch (with its own
dependent) opens sub-branches under it, under the same branch cap; a parent carries
its children's conditional as its answer.
- **The final answer is conditional, composed by fixed code** — `if you meant the
PM-of-Spain reading -> Rajoy | if you meant Socialist International -> Papandreou`.
Never one reading chosen inside a synthesis prompt; never the alternatives handed to
the next question's context (that only moves the coin-flip into answer_kg).
- Clarifying with the user instead of running the branches is a POLICY ABOVE this
mechanism (layer 3): asking = picking one branch upstairs. The mechanism itself
always runs the worlds it needs.
Budget: branches share the run's `llm_calls` pool (a fork of N readings costs ~N× the
dependent subtree — leave headroom or the later branches die by budget, honestly noted);
branch count is capped (extra readings are dropped and NAMED, never silent).
## 7. Per-call context composition
Every LLM call gets its own purpose-built context, assembled by fixed code within the