test: add unit tests for FrameTracer and DivergenceDetector#212
Open
acailic wants to merge 3 commits into
Open
test: add unit tests for FrameTracer and DivergenceDetector#212acailic wants to merge 3 commits into
acailic wants to merge 3 commits into
Conversation
Makes `evidence` an optional keyword argument (default `None`, treated as `[]`) in `RecordingMixin.record_decision`. All existing callers already pass evidence explicitly so this is non-breaking. Also adds lightweight drift-event collection to `record_decision` and wires `_drift_events`/`_drift_compare_index` onto `TraceContext.restore` so the previously-skipped drift-emission test now passes. Closes #205 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ison fixes - Add `*` after `chosen_action` in `record_decision` to make `evidence` and remaining params keyword-only, preventing accidental positional use and protecting existing positional callers - Use clamped `event.confidence` instead of raw `confidence` in drift event_dict to match what is actually persisted - Add `action` alias alongside `chosen_action` in drift event_dict so baselines using either key are matched - Advance `_drift_compare_index` to the next decision event in the baseline (skipping non-decision events) to prevent index misalignment Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
51 tests covering TokenUsage arithmetic, FrameEvent/FrameLifetimeTrace serialization, build_frame_tree, FrameCaptureContext parent-child linking, capture_function_call decorator (success/exception/options), helper functions (get_frame_by_id, get_frames_at_depth, filter_frames_by_name, get_cost_breakdown), serialization round-trip, DivergenceType/Severity enums, DivergencePoint.to_dict, detect_divergences, compare_session_structures, analyze_temporal_divergence, and analyze_behavioral_divergence. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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.
Summary
Closes #208
tests/test_frame_tracer_divergence.pywith 51 unit testsFrameTracer:TokenUsagearithmetic/serialization,FrameEvent/FrameLifetimeTraceconstruction andto_dict,build_frame_tree(empty/single/child/multi-root),FrameCaptureContextparent-child linking,capture_function_calldecorator (success, exception capture, arg/return suppression), helper functions (get_frame_by_id,get_frames_at_depth,filter_frames_by_name,get_cost_breakdown), and serialization round-trip viato_dict/from_dictDivergenceDetector:DivergenceType/DivergenceSeverityenum values,DivergencePoint.to_dict(with/without timestamp),SessionComparison.to_dict,detect_divergences(empty, identical, count mismatch, session ID extraction, summary keys, critical severity),compare_session_structures,analyze_temporal_divergence,analyze_behavioral_divergenceTest plan
ruff check .— clean.venv-ci/bin/python3 -m pytest -q tests/test_frame_tracer_divergence.py— 51 passed in 0.55s🤖 Generated with Claude Code