Compare commits
2
Commits
bb4afb6a66
...
1df3ec591b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1df3ec591b | ||
|
|
8a3f8b37e3 |
@@ -260,6 +260,28 @@ branches compete for budget, a learned router earns its place (v2).
|
||||
becomes data-driven. v1's logs — enriched by meta-level critiques — are v2's training
|
||||
data, and the same data feeds prompt optimization and fine-tuning (META.md).
|
||||
|
||||
## 9-bis. Observability roadmap (future plan): OpenTelemetry
|
||||
|
||||
Today a run's observability is files: `runs/<ts>/run.log` (the line-based technical
|
||||
superset), `prompts/NN-stage.txt` (every exact rendered prompt + raw response), and the
|
||||
WARNING channel (machine judgements worth a human's eye — the mask seed that
|
||||
auto-answered a question, guards refusing ingests, budget starvation). This is complete
|
||||
but closed: reading it means tailing files.
|
||||
|
||||
**Planned, not built:** export the run as **OpenTelemetry** traces/spans so floop is
|
||||
observable from the standard tooling that already exists — Jaeger, Grafana Tempo,
|
||||
any OTLP consumer — instead of floop growing its own dashboards. The mapping is
|
||||
natural: one run = one trace; each LLM call, engine step (probe, search, fetch, check,
|
||||
merge) and evidence append = one span, carrying the fields the logs carry today
|
||||
(stage, budget tick, duration, prompt-file pointer, verification flags, warnings).
|
||||
The planned `events.jsonl` (machine-readable event stream) becomes the in-process
|
||||
event bus this exporter reads — one schema, two consumers (offline self-analysis in
|
||||
META.md, live OTel export). Warnings export as span events first-class, since they are
|
||||
the self-improvement signal the lessons bank counts.
|
||||
|
||||
Deferred until the loop hardening is done — building it before v1's shape settles
|
||||
would instrument a moving target.
|
||||
|
||||
## 10. Risks
|
||||
|
||||
1. **Misformalization** (top failure mode) — wrong formalization, correct math, wrong
|
||||
|
||||
+20
-5
@@ -82,18 +82,33 @@ def identity_answer(masked_text: str, restore: dict[str, str]) -> str | None:
|
||||
Conservative by law (never over-detect): exactly one placeholder in
|
||||
the text, and the question is literally 'who/what is <ph>' (ending
|
||||
there or in punctuation — 'who is PERSON_1's predecessor' does NOT
|
||||
match) or it names the mask mechanism ('placeholder', 'refer(s) to')."""
|
||||
match) or it names the mask mechanism with the placeholder as the
|
||||
REFERENT: 'refer(s) to' must govern <ph> DIRECTLY ('what does
|
||||
PERSON_1 refer to?', 'the placeholder PERSON_1 refers to…'). A bare
|
||||
'refer to' anywhere in the sentence no longer fires — his 23/10 run:
|
||||
INIT's hidden-precondition phrasing 'does the title "President"
|
||||
refer to in relation to PERSON_1?' asked about the TITLE, the old
|
||||
clause seeded 'Pedro Sanchez' as the answer to which office was
|
||||
meant (a false positive with wrong semantics)."""
|
||||
phs = [ph for ph in restore if re.search(rf"\b{re.escape(ph)}\b",
|
||||
masked_text)]
|
||||
if len(phs) != 1:
|
||||
return None
|
||||
ph = phs[0]
|
||||
t = masked_text.strip()
|
||||
# lookahead: end-of-sentence/punctuation AFTER the placeholder — but
|
||||
# never an apostrophe: "PERSON_1's predecessor" is a possessive, not an
|
||||
# identity question (pre-existing trap found while verifying the 23/10
|
||||
# fix; the old test only covered 'Who WAS…', which dodges the literal)
|
||||
literal = re.match(
|
||||
rf"^(?:who|what)\s+(?:is|are)\s+{re.escape(ph)}(?=$|[\s,.?!:;)\"'])",
|
||||
rf"^(?:who|what)\s+(?:is|are)\s+{re.escape(ph)}(?=$|[\s,.?!:;)\"])",
|
||||
t, flags=re.IGNORECASE)
|
||||
mechanism = any(k in t.casefold() for k in
|
||||
("placeholder", "refer to", "refers to"))
|
||||
if literal or mechanism:
|
||||
if literal:
|
||||
return restore[ph]
|
||||
# mechanism mention: strict — the placeholder must be the REFERENT of
|
||||
# 'refer(s) to', not merely present in a sentence that uses the verb
|
||||
for pat in (rf"\brefer(?:s)?\s+to\s+{re.escape(ph)}\b",
|
||||
rf"{re.escape(ph)}\s+refer(?:s)?\s+to\b"):
|
||||
if re.search(pat, t, flags=re.IGNORECASE):
|
||||
return restore[ph]
|
||||
return None
|
||||
@@ -203,7 +203,10 @@ class FloopRun:
|
||||
resolved.append(created[tok - 1].qid)
|
||||
q.deps = resolved
|
||||
# anonymization seeds (his design): identity questions the mask map
|
||||
# already answers land as evidence NOW — zero LLM calls
|
||||
# already answers land as evidence NOW — zero LLM calls. WARN on
|
||||
# screen AND log (his 23/10 ask): the machine auto-answered a
|
||||
# question without any expert — legible, and a self-improvement
|
||||
# signal (which phrasings the seed eats -> META's lessons bank).
|
||||
for q, s in zip(created, subs):
|
||||
if s.get("known_answer"):
|
||||
self.table.append(EvidenceRow(
|
||||
@@ -216,6 +219,9 @@ class FloopRun:
|
||||
q.reason = "identity seeded from the mask map"
|
||||
self.notes.append(
|
||||
f"{q.qid}: seeded from anonymization — no expert call needed")
|
||||
self.streams.warn(
|
||||
f"SEED auto-answered {q.qid} '{q.text[:60]}' -> "
|
||||
f"'{s['known_answer']}' (mask map; zero expert calls)")
|
||||
|
||||
# ---- fan-out (the planner's expansion; deterministic guard) --------------
|
||||
|
||||
|
||||
@@ -83,6 +83,15 @@ class RunStreams:
|
||||
if think:
|
||||
self.think_line(text)
|
||||
|
||||
def warn(self, text: str) -> None:
|
||||
"""A machine judgement worth a human's eye even non-verbose:
|
||||
the seed that auto-answered a question, a guard refusing an
|
||||
ingest, a budget starvation. Self-improvement signal (META.md):
|
||||
the offline analysis counts these first. Log always; screen
|
||||
ALWAYS (unlike thinking, the [W] line is the point)."""
|
||||
self._emit_log(f"WARNING {text}")
|
||||
print(f"[W] {text}", flush=True)
|
||||
|
||||
def final(self, text: str) -> None:
|
||||
self._emit_log(f"FINAL {text}")
|
||||
self.think_line(f"[FINAL] {text}")
|
||||
|
||||
+11
-1
@@ -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():
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user