knowledge: deterministic ambiguity audit for office questions (run J) #7

Merged
onibot merged 1 commits from feature/ambiguity-audit into main 2026-10-21 17:42:42 +02:00
Owner

Run J layer 1 — "What office is Pedro Sanchez associated with as President?" answered Socialist International; the KG also held prime minister of Spain and secretary-general of PSOE, and the machine never knew. The fix is a data type the pipeline couldn't express: "this answer is one of several defensible readings".

Deterministic audit, zero LLM, zero network (knowledge/ambiguity.py):

  • Gate: only questions naming an office-class role (president, prime minister, secretary general…) enter the audit. Your two counterexamples ("second most populated country in EU", "three longest rivers in Italy") never even run it — no ambiguity detection everywhere.
  • ref_entity extracts the entity's proper-noun run ("Pedro Sanchez", never "President"; "France" in "Who is the President of France?").
  • The audit scans KG rows about the entity; role may live in relation or object; dates/bare numbers never become alternatives; the same office in two extraction shapes merges by token containment; the picked reading is excluded from the report. Fires only at ≥2 alternatives.

Propagation (flag, never choose): payload carries ambiguous/axis/alternatives[{value, role, quote, url}]; the EXPERT log line shows AMBIGUOUS ([prime minister] Spain; [secretary-general] PSOE); run notes + evidence render carry them so the ANSWER step (and later the user) can decide.

Suite 70/70 (11 new tests). Live smoke: the full pipeline over a run-J-shaped page flags the 3 offices; the rivers question over the same KG stays silent. What to do with the flag (fan-out per alternative, ask the user) remains open by design — layers 2-3.

**Run J layer 1** — "What office is Pedro Sanchez associated with as President?" answered Socialist International; the KG also held prime minister of Spain and secretary-general of PSOE, and the machine never knew. The fix is a data type the pipeline couldn't express: "this answer is one of several defensible readings". **Deterministic audit, zero LLM, zero network** (`knowledge/ambiguity.py`): - **Gate**: only questions naming an office-class role (president, prime minister, secretary general…) enter the audit. Your two counterexamples ("second most populated country in EU", "three longest rivers in Italy") never even run it — **no ambiguity detection everywhere**. - `ref_entity` extracts the entity's proper-noun run ("Pedro Sanchez", never "President"; "France" in "Who is the President of France?"). - The audit scans KG rows about the entity; role may live in relation or object; dates/bare numbers never become alternatives; the same office in two extraction shapes merges by token containment; the **picked reading is excluded** from the report. Fires only at ≥2 alternatives. **Propagation (flag, never choose)**: payload carries `ambiguous/axis/alternatives[{value, role, quote, url}]`; the EXPERT log line shows `AMBIGUOUS ([prime minister] Spain; [secretary-general] PSOE)`; run notes + evidence render carry them so the ANSWER step (and later the user) can decide. Suite **70/70** (11 new tests). Live smoke: the full pipeline over a run-J-shaped page flags the 3 offices; the rivers question over the same KG stays silent. What to do with the flag (fan-out per alternative, ask the user) remains open by design — layers 2-3.
onibot added 1 commit 2026-10-21 17:42:38 +02:00
Run J answered 'What office is Pedro Sanchez associated with as
President?' with Socialist International — a literally defensible
reading, but the KG ALSO held prime minister of Spain and
secretary-general of PSOE, and the machine never learned they existed.
The fix is not prompt tuning: it is a data type the pipeline could not
express — 'this answer is one of several defensible readings'.

Layer 1 (this PR) — knowledge/ambiguity.py, zero LLM, zero network:
- GATE: role_in_text(question) — only questions naming an office-class
  role (president, prime minister, secretary general, chancellor, ...)
  enter the audit. 'second most populated country in European Union'
  and 'three longest rivers in Italy' never even run it.
- ref_entity: the question's proper-noun run, broken at lowercase words
  and role words — 'Pedro Sanchez' (not 'President'), 'France' in
  'Who is the President of France?'.
- audit_role_multiplicity: rows about the entity whose role lives in
  the relation OR the object (extraction shape varies); dates and bare
  numbers never become alternatives; same office in two shapes merges
  by token containment (quote kept, corroboration summed); the PICKED
  reading is excluded from the report. Fires only at >= 2 alternatives.
- _maybe_ambig wires the audit at the three scalar return paths of
  answer_question; a clean answer is byte-identical (gate is cheap and
  the single-reading path changes nothing).

Propagation up (flag, never choose):
- payload carries {ambiguous, axis, alternatives[{value, role, quote,
  url}]}; provenance note says the choice among readings is NOT
  verified.
- OUTPUT EXPERT line: 'Q1 -> ANSWER value=... AMBIGUOUS ([prime
  minister] Spain; [secretary-general] PSOE) quote=...'.
- machine: run notes carry the axis + other readings; the evidence
  render shows them so the ANSWER step (and later the user) can decide.

Tests: knowledge/tests/ambiguity.py — the two agreed positives (both
Pedro phrasings), the two agreed counterexamples (silent), single
office, dates-as-values, duplicate shapes, role-in-object, wiring
(expert flags + clean untouched), engine log/payload/provenance,
machine notes/render. Suite 70/70. Live smoke: the full pipeline over
a run-J-shaped page flags the 3 offices; the rivers question over the
same KG stays silent.
onibot merged commit 599188181c into main 2026-10-21 17:42:42 +02:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: onibot/floop#7