floop: strict mask-seed detection + WARNING on seeded answers

His 23/10 review of the merged run found Q1's answer missing from the
stream. Chain, verified against the real code:

1. Q1 ('...does the title "President" refer to in relation to
   PERSON_1?') fired the mask-seed detector's loose mechanism clause —
   any 'refer to' in the sentence, even when the verb governs the
   TITLE, not the placeholder. The seed answered 'Pedro Sanchez' to a
   question that asked which OFFICE 'President' means: wrong semantics,
   a false positive born from the collision of the detector's word
   list with INIT's new hidden-precondition phrasing.

Fixes (both his ask):
- identity_answer STRICT: the mechanism clause now fires only with the
  placeholder as the REFERENT of 'refer(s) to' (regex adjacency, both
  orders). The literal 'who/what is <ph>' clause is unchanged.
- Found while verifying: the literal clause's lookahead accepted
  apostrophes, so 'Who is PERSON_1's predecessor?' (possessive) seeded
  too — the old test only covered 'Who WAS...'. Apostrophe removed from
  the end-of-question char class; possessives never seed again.
- THE SEED IS NOW LOUD: RunStreams.warn() (new channel — WARNING line
  in run.log, [W] on screen ALWAYS, even non-verbose) fires on every
  seeded answer: 'WARNING SEED auto-answered Q1 ... (mask map; zero
  expert calls)'. Self-improvement signal (META): which phrasings the
  seed eats belongs to the lessons bank, and it must be legible that
  the machine auto-answered without any expert.

Also: ARCHITECTURE.md §9-bis — OpenTelemetry observability roadmap
(his future plan ask): run = trace, calls/steps/rows = spans carrying
today's log fields, events.jsonl as the shared bus, warnings as
first-class span events; deferred until the loop hardening settles.

Tests: anonymize +4 assertions (his false positive, possessive trap,
strict positive shapes), machine +1 (seed WARNING lands in run.log).
Suite 17/17.
This commit is contained in:
2026-10-23 16:03:13 +02:00
parent bb4afb6a66
commit 8a3f8b37e3
6 changed files with 95 additions and 7 deletions
+11 -1
View File
@@ -121,10 +121,20 @@ def test_identity_detection_conservative():
assert identity_answer("What is ORGANIZATION_1?", {"ORGANIZATION_1": "PSOE"}) == "PSOE"
assert identity_answer("Which specific individual does the placeholder refer to?", r) is None
assert identity_answer("Who is PERSON_1, i.e., which specific individual does the placeholder refer to?", r) == "Pedro Sanchez"
assert identity_answer("Who is PERSON_1's predecessor?", r) is None
assert identity_answer("Who was PERSON_1's predecessor?", r) is None
assert identity_answer("What office does PERSON_1 hold?", r) is None
assert identity_answer("Who is PERSON_1 compared to PERSON_2?", {**r, "PERSON_2": "x"}) is None
print("ok: identity detection conservative (possessives/comparatives not eaten)")
# his 23/10 false positive: 'refer to' about the TITLE, not the
# placeholder — the hidden-precondition INIT phrasing. Strict law:
# 'refer(s) to' fires only with the placeholder as its REFERENT.
assert identity_answer(
'What country, organization, or office does the title "President" '
'refer to in relation to PERSON_1?', r) is None
# and the strict mechanism shapes still fire
assert identity_answer("What does the placeholder PERSON_1 refer to?", r) == "Pedro Sanchez"
assert identity_answer("the term PERSON_1 refers to in the question", r) == "Pedro Sanchez"
print("ok: identity detection conservative (possessives/comparatives/title-refer not eaten)")
def test_mask_death_passthrough():
+26
View File
@@ -264,6 +264,32 @@ def test_fanout_respects_top_n_slice():
print("ok test_fanout_respects_top_n_slice")
def test_seed_warning_is_emitted():
"""The mask seed auto-answering a question must WARN (his 23/10 ask):
on the log as WARNING, on screen even non-verbose — self-improvement
signal, not silent evidence."""
import tempfile
from floop.stream import RunStreams
streams = RunStreams("seed warn test", verbose=False,
runs_dir=tempfile.mkdtemp())
fm = FakeModules(
init_subs=[
{"text": "Who is Pedro Sanchez?", "deps": [],
"answer_type": "OPEN", "known_answer": "Pedro Sanchez"},
{"text": "What office did Pedro Sanchez hold?", "deps": [1],
"answer_type": "OPEN"},
],
route_fn=lambda q: "knowledge", expert_value="President")
run = FloopRun("Who is Pedro Sanchez and what office does he hold?",
budget(), modules=fm, streams=streams)
run.run()
log = streams.log_path.read_text(encoding="utf-8")
assert "WARNING SEED auto-answered Q1" in log, log[-400:]
assert "mask map; zero expert calls" in log
assert any("seeded from anonymization" in n for n in run.notes)
print("ok: seed WARNING lands in run.log (auto-answer is loud)")
# keep a handle to restore the real engine after monkeypatching
from floop.engine import LLMExpertEngine as _restore_llm_engine