feat: named inputs/outputs in traces + clickable prompts + expert names

Owner's 27/10 review of the OTel export, four asks, all landed:

1. NAMED IN/OUT PER FUNCTION: fn.done events (fn, in, out) at the
   knowledge pipeline's main functions - search (in.query -> out.titles),
   fetch, skim, compose, chunk_gate, serve_set, list_ingest, harvest,
   promote, check, judge - rendered as spans with in.<arg>/out.<arg>
   attributes. "wiki search ('Pedro date take'): [...]" is now
   knowledge.search with in.query and out.titles as data.
2. SIGNATURE IN/OUT: the dspy prompt-log callback emits sig.start/sig.done
   - the typed fields of every dspy call (in.question, out.entities,
   out.facts...). The LLM span and the sig span are one node.
3. CLICKABLE PROMPT: every LLM span carries a child 'prompt' span with
   the exact prompt + raw response read from prompts/NN-stage.txt at
   export time - retroactive for old runs (the Pedro run re-exports with
   128 prompt children).
4. EXPERT NAMES: EXPERT comp spans carry expert= (EXPERT knowledge);
   nested spans prefix with the expert (knowledge.search,
   knowledge.state, knowledge.TranslateToDSL); each expert exports its
   spans under its own OTel service so Jaeger groups by component.

Live-verified end to end: smoke run (glm-5.3-flash) exported while
running - MASK shows in.question -> out.entities [{France, PLACE}],
EXPERT knowledge nests knowledge.TranslateToDSL under service
knowledge; read back via Jaeger's own API. Suite: traces 7/7, all
floop + knowledge test files green (guards/value_clean caught two bugs
in the new emissions before commit: a wrong-scope variable and a
use-before-define; _rec now reads getattr(streams) so __new__ test
fakes survive).

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-10-27 14:27:56 +01:00
co-authored by Claude
parent 6ea769b7d1
commit 1af308ae60
10 changed files with 628 additions and 132 deletions
+14
View File
@@ -97,6 +97,20 @@ runs appear as nested run-spans. Trace ids are deterministic — re-pushing
a run lands on the same trace. Stdlib only; the run itself never touches
the network.
Since 2026-10-27 (visibility laws), inputs and outputs are data:
- Pipeline functions emit `fn.done` — spans carry in.query / out.titles
(search), in.title / out.{url, chars, tables} (fetch), the judge's
question/value, compose/skim/chunk_gate/serve_set/list_ingest/harvest/
promote/check, each with NAMED arguments.
- dspy calls emit `sig.start`/`sig.done` — the Signature's input and
output fields as typed attributes (in.question, out.entities, out.facts).
- Every LLM span carries a CHILD `prompt` span with the exact prompt and
raw response (read from prompts/NN-stage.txt at export time) — click and
read, retroactively for old runs too.
- EXPERT spans carry the attendant name (EXPERT knowledge); nested spans
use the expert prefix (knowledge.search, knowledge.state); each expert
exports under its own OTel service (floop / knowledge / ...).
## Next steps (design order from the docs)
1. Real check layer on expert arrival (well-formedness per expert kind) — the