test: broaden coverage of analysis, OTel merge, and rendering#24
Merged
Conversation
Add offline unit tests targeting the session-analysis internals that were thinly covered: - analyze_trajectory (ATIF) driven by synthetic, hand-controlled inputs (metadata, tool histogram + failure detection, final_metrics economics, summed-output fallbacks, malformed-input guards). Real trajectory.json is produced by this package's own converter, so it can't serve as authoritative golden data; these tests exercise the parsing logic directly. - _apply_otel_records merge: shutdown stays authoritative while turns are still enriched; OTel-only reconstruction without a shutdown; unmatched turn_id and no-chat-span paths. - OTel decoders: _otel_attrs (dict + OTLP list), _otel_value typed scalars and array/kvlist, _otel_attr_value flat + nested dotted lookup, _parse_otel_time across ISO / [sec,nanos] / epoch s|ms|ns, and llm_calls_from_otel over OTLP list-format attributes. - sessionlog: load_events blank/invalid skipping, copy_events roundtrip and missing-source, compaction_start peak tracking without a shutdown. - render: render_session_analysis overview incl. the multi-model "Per model" table and the no-economics path; remaining LiveEventFormatter branches. Coverage: analysis.py 77%->90%, render.py 87%->93%, sessionlog.py 90%->93%. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Follow-up to #23 (merged): a thorough test-coverage review of the
session-analysis, session-reading, and OTel-merge code paths. Tests only — no
production code changes.
What's added (43 offline tests)
analyze_trajectory(ATIF) — driven by synthetic, hand-controlledinputs. The real
trajectory.jsonis produced by this package's own Pierconverter, so it can't serve as authoritative golden data; these tests
exercise the parsing/aggregation logic directly: metadata, tool histogram +
failure detection (
"code":"failure", permission-denied markers),final_metrics→ economics (aiu/reasoning/peak/compactions), summed-outputfallbacks, and malformed-input guards.
_apply_otel_recordsmerge — shutdown stays authoritative while turns arestill enriched; OTel-only reconstruction without a shutdown; unmatched
turn_idand no-chat-span paths._otel_attrs(dict + OTLP list),_otel_valuetypedscalars + array/kvlist,
_otel_attr_valueflat + nested dotted lookup,_parse_otel_timeacross ISO /[sec,nanos]/ epoch s·ms·ns, andllm_calls_from_otelover OTLP list-format attributes.load_eventsblank/invalid skipping,copy_eventsroundtrip + missing-source,
compaction_startpeak tracking without ashutdown.
render_session_analysisoverview incl. the multi-model"Per model" table and the no-economics path; remaining
LiveEventFormatterbranches.
Coverage
Full suite: 203 passed. Ruff clean + formatted.