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.
This commit is contained in:
2026-10-22 16:48:41 +02:00
parent 4301277ccd
commit 0ed26d3406
4 changed files with 204 additions and 3 deletions
+1
View File
@@ -156,6 +156,7 @@ _STAGE_BY_MODULE = {
"Expert": "EXPERT",
"Missing": "MISSING",
"Answer": "ANSWER",
"EntityMaskSignature": "MASK",
"KnowledgeExpert": "knowledge",
"InitSignature": "INIT",
"RouteSignature": "ROUTE",