feat: flight recorder — events.jsonl for post-mortem debugging
Owner ruling (26/10): 'vull poder fer com un debug amb l'IDE de programació, però a posteriori de l'execució' — see WHERE inside which expert we are at every moment, and the input/output of every component, LLM or not. This is the recorder half (PR A of the observability plan). - floop/recorder.py: append-only JSONL, one event per line. LAWS: never breaks a run (emitting is swallowed; no run dir = TOTAL no-op, no buffer, no counters); every line self-describing (seq, ts, run_ts, event, payload); in/out carry structured data, the exact prompt text stays in prompts/NN-stage.txt (events stay small). - Wired via RunStreams (every component already had streams): comp.start/comp.out (machine stages INIT/ROUTE/EXPERT/ANSWER/FINAL), state, llm.done (stage, dur_s, call_seq, prompt file link — from the dspy callback), run.final. - Knowledge pipeline components (floop-internal nodes, not LLMs): probe.done (seeds, rows, tau, semantic adds), claims.done (the claim list), type.done (claim -> typed fact, one per claim as ruled), fact.merged / fact.rejected (one per fact — _ingest_candidate is called per fact; verdict + reason + page), prover.done (dsl, verdict: invalid_dsl/no_closed_path/closed/ambiguous, bindings), kg.snapshot (once at run end: every edge with temporal window + last_touch from this run's merge events). - kg_snapshot(): rows annotated with their last-touch event (owner: 'cada fila del kg podria tenir anotat quan s'afegeix o edita'). Live-checked: baseline run writes real events (comp.start, llm.done dur_s=17.35, comp.out '4'). TDD: recorder 3/3; suite 31 files green. Next (PR B): floop-inspect — the HTML debugger reading events.jsonl (timeline Gantt, KG view, facts table, probe view).
This commit is contained in:
@@ -143,6 +143,16 @@ def main() -> None:
|
||||
report: RunReport = FloopRun(question, budget, streams=streams,
|
||||
knowledge_engine=knowledge_engine).run()
|
||||
finally:
|
||||
# THE FLIGHT RECORDER CLOSE-OUT: the KG snapshot (owner 26/10:
|
||||
# one snapshot at the end, each row annotated with its last-touch
|
||||
# event) and the recorder's file handle. Best-effort: the report
|
||||
# has already been produced; observability never kills a run.
|
||||
try:
|
||||
if knowledge_engine is not None and streams is not None:
|
||||
streams.recorder.emit("kg.snapshot",
|
||||
kg=knowledge_engine.ke.kg_snapshot())
|
||||
except Exception: # noqa: BLE001
|
||||
pass
|
||||
streams.close()
|
||||
|
||||
print(f"goal: {report.goal}")
|
||||
|
||||
Reference in New Issue
Block a user