Commit Graph
12 Commits
Author SHA1 Message Date
onibot 4766b47127 floop: INIT told placeholders are resolved + identity seed (his design)
His two-part direction after the PR-16 live run (the model spent a
subquestion asking 'who is PERSON_1?'):

1. INIT desc now says masked entities (PERSON_1, ORGANIZATION_1...) are
   ALREADY-RESOLVED named entities — treat each as a known specific
   entity; do not ask what or who the placeholder is.
2. Safety net: identity_answer() detects a subquestion that ONLY asks
   who/what one placeholder refers to — the mask map already knows. The
   machine seeds it as evidence (engine=mask:seed, verified, zero LLM
   calls) instead of routing it to an expert.

Detection is deterministic and conservative by law: exactly one
placeholder in the text, literal 'who/what is <ph>' (ending there or in
punctuation — possessives like 'who is PERSON_1's predecessor' do NOT
match) or the text names the mask mechanism. Detection runs on the
MASKED text (placeholders still present) before restore.

VERIFIED: tests/anonymize.py 6/6 (seed marking, conservative detection
incl. possessives/comparatives/no-placeholder forms); suite 15/15.
Live E2E (glm-5.3-flash): with the new desc INIT returns exactly the
TWO subquestions he wants (term years + predecessor) — no identity
question, seed unused but armed; run answers Rajoy (E1+E2, 30 calls).
2026-10-22 17:03:44 +02:00
onibot 0ed26d3406 floop: anonymize named entities before INIT (his design)
The model was using its own knowledge of the people in the question
to decide decomposition (his qwen collapsed Pedro Sanchez to ONE
subquestion: 'the question is nearly atomic because I know who he
is'). Structural fix: INIT sees the question's SHAPE, not identity.

- EntityMaskSignature (typed NER proposal): entities as list[NamedEntity]
  (name verbatim + kind) — the typed-output law, no string parsing
- apply_mask/restore_mask: DETERMINISTIC code (LLMs propose, code
  applies): longest names first, one placeholder per surface text,
  typed prefixes PERSON_1/ORGANIZATION_1/..., restore longest-first
  (PERSON_10 never eaten by PERSON_1)
- init_decompose: mask -> INIT -> restore in each returned subquestion;
  MASK finding no entities OR dying (AdapterParseError) -> passthrough,
  never a dead run
- MASK stage in the prompt log (prompts/01-MASK.txt)

VERIFIED: tests/anonymize.py 4/4 (deterministic apply/restore, E2E
mask+restore, no-entity passthrough, mask-death passthrough); suite
15/15. Live E2E (glm-5.3-flash): MASK found exactly Pedro Sanchez
(reasoning explicitly excluded 'President' as a role, not entity);
INIT saw 'Who was the President before PERSON_1?' and returned FOUR
subquestions (identity, office, term start, predecessor) — the shape
split he wanted, plus a 'who is PERSON_1' question; run answers Rajoy
correctly (E1-E4).

OPEN (his question pending): the model now asks WHO the placeholder
is, spending one call per run. Options: (a) keep, (b) desc note that
placeholders are known entities, (c) give INIT the masked question PLUS
the original as context. Not decided — he answers when back.
2026-10-22 16:48:41 +02:00
onibot a6453b0cb3 floop: typed EXPERT confidence + ANSWER bool input
The last floop signatures migrate to the typed-output law:
- ExpertSignature.confidence: Confidence(str, Enum) high|medium|low,
  with guidance in the desc — out-of-set values are schema violations
- AnswerSignature.unverified: real bool InputField (callers already
  passed bools; the old signature stringified them)
- expert_draft/synthesize consume the typed values directly

VERIFIED: suite 14/14 green (new tests/typed_expert.py: enum parses
through the real adapter path, bad confidence raises, bool renders).
The floop side of the typed migration is COMPLETE — knowledge
signatures are the next (last) block.
2026-10-22 15:04:43 +02:00
onibot c3d1b5d6d3 floop: typed ROUTE attendant (closed enum) via dspy structured output
ROUTE migrates to the typed-output law: the attendant is a closed enum
rendered into the prompt's JSON schema — an invalid pick is impossible
by contract (AdapterParseError after dspy's own re-ask).

- Attendant(str, Enum): knowledge logic analytic numeric floop user
  (str mixin keeps the machine's == and `in EXPERT_ENGINES` intact)
- The per-field desc now carries the routing guidance (what each
  attendant is FOR) — replacing the 'one of: ...' list in the old
  string contract
- The machine's invalid-attendant branch stays as a contract guard
- New tests/typed_route.py: enum parses through the real adapter path
  (RawEngine + cache=False), out-of-set attendant raises, str
  compatibility holds

VERIFIED: suite 13/13 green; wire test with real glm-5.3-flash routes
all three probes correctly (knowledge / numeric / knowledge).
2026-10-22 15:03:48 +02:00
onibot c7bd010f47 floop: typed INIT+MISSING via dspy structured output (Subquestion)
The typed-output migration starts with the machine's decomposition step:
the pipe contract ('text | deps | answer_type' lines) is gone — dspy
renders the Subquestion schema natively.

- Subquestion(BaseModel): text + depends_on: list[int] +
  answer_type: AnswerType (enum rendered into the prompt's JSON schema)
- InitSignature/MissingSignature.subquestions: list[Subquestion]
- init_decompose keeps the (subs, raw) machine contract: a
  schema-violating response raises AdapterParseError after dspy's own
  JSON re-ask; its lm_response becomes the degrade signal so the
  run-I law survives typing — the machine still routes the ORIGINAL
  question, never garbage
- bare-number texts still dropped (now in _subs_from_typed)
- parse_subquestions kept as LEGACY for tests

Tests rewritten for the REAL adapter path (RawEngine + cache=False):
DummyLM bypasses the adapter; and dspy's disk cache (~/.dspy_cache)
cross-contaminates scripted tests sharing a fake model name — both
pitfalls found while migrating.

VERIFIED:
- suite 12/12 green (robust_init rewritten: 6/6 — E2E typed parse,
  bare-number drop, garbage degrade, machine degrade, atomic case,
  raw-response prompt log)
- live E2E (ollama-cloud glm-5.3-flash): INIT renders the enum schema,
  glm returns depends_on ints + valid enums, machine dicts clean,
  full run answers Rajoy with citations. NOTE: dspy's disk cache made
  the second run's INIT a 0.2s cache hit — runs share the cache.
2026-10-22 15:02:12 +02:00
onibot efd539c128 knowledge+llm: dst-first ablation mask (run L) + re-ask budget meter
Two fixes from his 22/10 re-run log, both small and deterministic:

1. THE ABLATION MASK WAS QUOTE-BLINDED (run L: Q1 stayed silent over
   the Pedro page that run J flags). The Pedro paragraph interleaves
   all three readings in ONE quote ('...Secretary-General ... ninth
   president of Socialist International...'), and _carries matched
   the picked value by substring over dst OR quote — so masking SI's
   support masked the PM/PSOE rows too; round 1 answered UNKNOWN and
   the audit died silent. The DST-FIRST LAW: when a row has a
   meaningful dst (non-empty, non-numeric) it is the VALUE BEARER and
   the mask matches IT; the quote is a fallback only for
   empty/numeric dsts. Same law in _carries_target for each round's
   surviving value, with one addition: the judge's round value may be
   an OFFICE DESCRIPTION ('prime minister of Spain') while the row's
   dst is the ENTITY ('Spain') — resolve by reciprocal token
   containment, or the loop dies after one alternative.

2. THE ADAPTER RE-ASK WAS INVISIBLE TO THE BUDGET (run L: prompts #9
   and #10 were both ANSWER — #10 5 chars shorter, 340s, the
   ChatAdapter's JSON-fallback second wire call after a parse
   failure; llm_calls said 9/80 while 10 hit the wire). THE METER:
   the prompt-log callback already sees every LM call — a second LM
   call with NO new module forward between them is the adapter
   fallback re-firing inside the same Predict. Count it, log the
   line, and charge the budget through a meter hook the machine
   wires at construction. A re-ask at the ceiling does not kill the
   run (the call already happened). dspy's BEHAVIOUR IS UNTOUCHED —
   his call: the fallback stays, it is future self-improvement
   signal (which prompts the model formats badly), not a bug.

Tests: knowledge/tests/ablation.py +3 — run-L regression (interleaved
one-paragraph quote flags all three readings), office-description
resolution, numeric-dst quote fallback. tests/reask_meter.py +3 —
fallback detected and charged on the REAL adapter path (custom engine
returning raw text, marker-less first response), separate forwards NOT
flagged (the ablation-rounds shape), ceiling charge survives. Suite
12/12 files green (74 tests). Live smokes: the run-L interleaved-quote
page flags SI+PM+SG through the full pipeline; the run-J
separate-quotes smoke still passes.
2026-10-22 11:21:25 +02:00
onibot b5a9403063 machine: robust INIT parsing + raw-response log (run I fixes)
Run I ('Who was the President before Pedro Sanchez?'): the INIT LM wrote
its own line numbers as an extra first pipe field ('1 | Who was... |
none | OPEN'), the naive parse took '1' as the subquestion text, ROUTE
classified Q1='1' as numeric, and the machine burned four calls on
garbage before luck produced the answer. Two of the fixes close the same
observability gap that hid the root cause for a day.

1. PARSER (parse_subquestions): shifts the numbered form (>=4 fields
   with a bare number first) and drops any text that is a bare number —
   a routable question is text, never '1'. Enumerator prefixes ('1.')
   inside the text field are stripped. Well-formed lines parse exactly
   as before (regression-tested).

2. INIT DEGRADE (machine): init_decompose now returns (subs, raw).
   Non-empty raw that parses to nothing = model garbage — degrade to
   the ORIGINAL question as one OPEN subquestion (routable, logged,
   budget-safe). Empty raw keeps the old law: the question is atomic,
   stop and synthesize — never fabricate a subquestion.

3. RAW RESPONSE LOG (the ask behind the ask): prompts/NN-stage.txt now
   carries the exact LM response after the prompt. Run I's parsed
   'OUTPUT INIT: 1\n2' could not show what the model actually wrote —
   the raw text is in the file from now on; the log stays line-based.

Tests: tests/robust_init.py — the numbered form, bare-number drop,
enumerator strip, happy-path regression, the degrade, the atomic stop,
raw-response capture. Suite 59/59. Smoke: the exact run-I transcript
replayed through the real machine (DummyLM) parses to Q1/Q2 real
subquestions and answers Mariano Rajoy.
2026-10-21 12:08:50 +02:00
onibot 06124a0198 store/expert/machine: keep source order end-to-end; refuse fake top-N
log-09 bug: a KG-served set answered the fan-out top-3 with adda, adige,
arno — the alphabetical list_members order masquerading as a ranking.

- edges.list_ord (auto-migrated): each member_of edge records its row
  position in the source table; list_members(ordered=True) returns source
  order, list_is_ordered() tells whether the set has proven order
- ingest writes ordinals; fresh-serve and _serve_set keep table order and
  set coverage.ranked accordingly
- fan-out top-N: slices ONLY ranked lists; an unranked list refuses the
  slice, expands all entities, and says so in notes + thinking (never
  silently alphabetical)
- regression test: Po/Adige/Tiber first; unordered set -> all expanded
2026-10-19 20:31:04 +02:00
onibot 209909e776 machine: fan-out planner + disjointness guard (runs 07/08 lessons)
(a) Disjointness guard (knowledge/expert.py): a LIST ingest whose members
    don't overlap the entities the parent's evidence names is refused; the
    gather continues to the next article. Run-08's 'flow of Po/Adige/Tiber'
    answered by the Amazon from a world-wide table can no longer happen.
(b) Fan-out planner (floop/machine.py): a 'for each' subquestion over a list
    row expands deterministically into N entity questions + one join.
    Top-N bound respected ('those three' over 22 rows -> top 3 by table
    order, logged). The join is a deterministic sum over the entity rows
    (verified=True: computation is its own proof), partial sums named.
    Entity rows are tagged fan_group in provenance so the join finds them.
Also: LIST ingest keeps TABLE ORDER (ranked tables rank; alphabetical sort
      destroyed the ranking) — dict.fromkeys dedup.
Budget: 40 -> 80 (a 3-entity fan-out needs ~3x a scalar question).

Verified live (cold KG, 2 runs): list ingest in table order, slice top-3,
fan-out -> 3 entity questions + join, Po answered with verbatim quote
(1,460 m3/s). 28/28 tests (fan-out expansion+join, top-N slice, guard).
2026-10-19 20:16:01 +02:00
onibot b14915079e store: auto-migrate old KGs (edges.origin_question); machine: abort honestly on dead LM
- KnowledgeStore._migrate(): idempotent additive migration on open — a
  pre-2026-10-19 KG no longer crashes the set gate with 'no such column'
- _lm_dead(): transport/timeout deaths abort the run with notes (no answer
  beats a made-up one); code bugs still crash loudly
- tests: migration from a hand-built old-schema store; LM-death abort (24/24)
2026-10-19 12:11:59 +02:00
onibot e5482bd092 feat(logic): setop engine + set gate — the Europe count computed end-to-end
A) SET GATE: enumerations are answered only from membership sets, never from mention rows (the probe early-exit that served 'Armenia, Cyprus, Georgia, Turkey' to 'what countries are in Europe' is dead). Sets carry origin_question; the gate matches stem-Jaccard>=0.5 so a set is served to its own question only. B) SETOP ENGINE: logic's first real engine — a count over list rows is computed (difference/intersection/count over norm_name'd items, table markers 'Austria*' == 'Austria'), before ROUTE, zero LLM calls, verified=True because the computation IS the check. C) Catalog honesty: knowledge 'lists are ONE fetch', logic 'how-many over lists in evidence', floop 'NOT mere size'. Plus four substrate bugs the live runs exposed: LM-proxy prompt cache (instant answers are cache hits, never trust zero latency), _context rendering list rows as scalars ('E1: 50' routed 'those countries' to user), <br> concatenation in multi-value name cells, multi-line refs leaking into values ('franceincludes the 101 departments' -> France dropped from EU -> 24 not 23). Cold E2E: Q1 50 states ingested, Q2 27 EU members ingested, Q3 difference computed = 23, cited over E1/E2. 22/22 tests.
2026-10-18 19:49:24 +02:00
onibot d0942bdc69 floop v0.1: design docs + executable dspy draft
Root: README, PIPELINE, ALGORITHM, GAPS, RUNLOG (design + first executable runs). code/: v0.1 draft on dspy 3.4 (INIT/ROUTE/EXPERT/MISSING/ANSWER as dspy calls, machine as fixed code, stub engines — honest Unverified). knowledge/: DESIGN.md for the KG-first knowledge expert (pre-implementation).
2026-10-13 13:39:31 +02:00