test: add unit tests for InsightBuilder and MemoryExporterHook#231
Open
acailic wants to merge 3 commits into
Open
test: add unit tests for InsightBuilder and MemoryExporterHook#231acailic wants to merge 3 commits into
acailic wants to merge 3 commits into
Conversation
…ord_decision - Add EventType.DRIFT and DriftDetectedEvent to the events module - Override record_decision in TraceContext to call DriftDetector.compare() and emit a DriftDetectedEvent when replay diverges from the original execution - Make the `evidence` parameter optional (default None) in RecordingMixin.record_decision, since all existing callers already pass it explicitly as a keyword arg - Fix skipped test: correct mock URL key (events→traces), add post-checkpoint timestamp to mock event so the timestamp filter passes, and check ctx._events instead of a disconnected capture_event callback Closes #205 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…mping - Filter drift detector baseline to decision events only so _drift_decision_index aligns with the correct original event at each position (was indexing into the full post-checkpoint stream including tool calls) - Clamp confidence to [0.0, 1.0] before drift comparison to match what RecordingMixin.record_decision() persists, preventing false confidence drift for out-of-range inputs - Use ctx.get_events() in test instead of private ctx._events to avoid bypassing the async lock Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds 30 unit tests covering all methods of InsightBuilder (_build_session_digest, _build_failure_patterns, _build_entity_summaries, build_insight) and all MemoryExporterHook behaviors including export gating, exception swallowing, and the create_memory_exporter_hook factory. Closes #227 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
tests/test_insight_builder.pywith 30 unit tests covering zero-coverage classesInsightBuilder:build_insight,_build_session_digest,_build_failure_patterns,_build_entity_summariesMemoryExporterHook:on_session_endgating logic, exception swallowing,create_memory_exporter_hookfactoryTest plan
pytest tests/test_insight_builder.py -q)ruff checkcleanCloses #227
🤖 Generated with Claude Code