tests: trace-shape schema and checker - #7148
Open
davidzhao wants to merge 2 commits into
Open
Conversation
davidzhao
force-pushed
the
dz/telemetry-trace-schema
branch
2 times, most recently
from
September 6, 2026 23:40
cec2b33 to
ff6cbdf
Compare
davidzhao
force-pushed
the
dz/telemetry-trace-schema
branch
from
September 7, 2026 00:10
419b712 to
fe20391
Compare
davidzhao
force-pushed
the
dz/telemetry-trace-schema
branch
from
September 7, 2026 03:54
fe20391 to
baf98f2
Compare
davidzhao
force-pushed
the
dz/telemetry-trace-schema
branch
2 times, most recently
from
September 7, 2026 04:14
1a6bb39 to
6464a56
Compare
davidzhao
marked this pull request as ready for review
September 7, 2026 05:05
davidzhao
force-pushed
the
dz/telemetry-trace-schema
branch
from
September 7, 2026 05:05
6464a56 to
aab813c
Compare
Contributor
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
davidzhao
force-pushed
the
dz/telemetry-trace-schema
branch
from
September 7, 2026 05:48
aab813c to
f524ea1
Compare
davidzhao
force-pushed
the
dz/telemetry-trace-schema
branch
from
September 7, 2026 06:26
f524ea1 to
5d8b16f
Compare
davidzhao
force-pushed
the
dz/telemetry-trace-schema
branch
from
September 7, 2026 06:50
5d8b16f to
1037b94
Compare
chenghao-mou
approved these changes
Sep 7, 2026
| "keyterm_detection", | ||
| "judge_evaluation", | ||
| "amd", | ||
| }, |
Member
There was a problem hiding this comment.
A fallback can also trigger:
llm_fallback_adapter
└── llm_request_run
└── llm_request
└── llm_request_run
llm_fallback_adapter → llm_request_run → llm_requesttts_fallback_adapter → tts_request_run → tts_requesttts_node → tts_stream_adapter → tts_request_run → tts_request
davidzhao
force-pushed
the
dz/telemetry-trace-schema
branch
from
September 8, 2026 04:23
1037b94 to
f876f07
Compare
davidzhao
force-pushed
the
dz/telemetry-trace-schema
branch
from
September 8, 2026 04:26
f876f07 to
06e9590
Compare
davidzhao
force-pushed
the
dz/telemetry-trace-schema
branch
from
September 8, 2026 04:32
06e9590 to
359f6fb
Compare
davidzhao
force-pushed
the
dz/telemetry-trace-schema
branch
2 times, most recently
from
September 8, 2026 05:06
150aaef to
ce939a1
Compare
davidzhao
force-pushed
the
dz/telemetry-trace-schema
branch
from
September 8, 2026 05:21
ce939a1 to
f0c99d5
Compare
davidzhao
force-pushed
the
dz/telemetry-trace-schema
branch
2 times, most recently
from
September 8, 2026 05:48
0a22c73 to
b95bbce
Compare
davidzhao
force-pushed
the
dz/telemetry-trace-schema
branch
from
September 8, 2026 05:58
b95bbce to
e7260a5
Compare
davidzhao
force-pushed
the
dz/telemetry-trace-schema
branch
from
September 8, 2026 06:10
e7260a5 to
189771f
Compare
…nd for exports SPAN_PARENTS lists, for every span the framework emits, the parents it may have; MAY_OUTLIVE_PARENT the four deliberate overruns. check_trace applies them plus the per-turn invariants (one agent_turn per speech, generation events matching lk.generation_count, an outcome on every eou_wait) to spans from an in-memory exporter or an OTLP JSON export, and doubles as a CLI for downloaded traces. The full-session tests now end with the checker, so each scenario guards the whole tree rather than the one edge it names. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… outlast it Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
davidzhao
force-pushed
the
dz/telemetry-trace-schema
branch
from
September 8, 2026 07:30
189771f to
2632d51
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The nesting of spans is an emergent property of many call sites. A refactor can move a span under the wrong parent while every existing test passes, because each test only asserts the one edge it was written for. This layer writes the rules down once and checks every span in every full-session test against them, and applies the same rules to a real run's export.
How
tests/trace_schema.py(test support, not shipped):SPAN_PARENTS: for every span name the framework emits, the parents it may have (ROOTfor none,ANYfor spans that follow their caller:rpc_call,event_loop_blocked). An unknown name is a violation, so a new span must be registered.MAY_OUTLIVE_PARENT: the four child/parent edges where the child is allowed to end after its parent, each with the reason (the three startup spanssession.start()does not wait for,on_enter, and stalls whose end is one heartbeat late). Everything else must sit inside its parent, with 2 ms of slack.check_trace(): one trace id, every parent present, parent allowed by the schema, bounds, and the per-turn invariants: oneagent_turnperlk.speech_id,lk.generation_countequal to the number ofgenerationevents, everyeou_waitwith an outcome. Returns the violations as one line each.from_readable_spansfor an in-memory exporter,from_otlp_jsonfor an export downloaded from LiveKit Cloud. As a CLI,uv run python -m tests.trace_schema traces.jsonprints the span summary and the violations, so a downloaded trace is validated in seconds (a partial export, keyed to one span, is checked with orphans tolerated).assert_trace_well_formed(exporter.get_finished_spans())now ends the full-session tests: the tool call and plain reply intest_agent_turn_span, the barge-in and handoff intest_coverage_spans, the hook and redaction sessions intest_eou_wait_span, the lifecycle and SIP sessions intest_startup_spans. Each scenario guards the whole tree.Tests
tests/test_trace_schema.py: the schema is self-consistent; a sound trace passes; a misparentedllm_request(the keyterm-detection mistake), aneou_detectionoutside its wait, an unknown span, a missing parent, a child outside its parent, a duplicated speech turn, a generation-count mismatch and a second trace id are each reported; the deliberate overruns pass; the OTLP and in-memory sources agree; a full fake session is well-formed.Not covered here: the job-level spans (
job_entrypoint,room_connect,job_shutdown) have no fake-session path and stay on their unit tests, and only a real room exercises the task contexts that leaked earlier, so the CLI on a downloaded export remains part of the workflow.Stacked on #7143.
🤖 Generated with Claude Code