Skip to content

test: add unit tests for InsightBuilder and MemoryExporterHook#231

Open
acailic wants to merge 3 commits into
mainfrom
issue-227-insight-tests
Open

test: add unit tests for InsightBuilder and MemoryExporterHook#231
acailic wants to merge 3 commits into
mainfrom
issue-227-insight-tests

Conversation

@acailic

@acailic acailic commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds tests/test_insight_builder.py with 30 unit tests covering zero-coverage classes
  • InsightBuilder: build_insight, _build_session_digest, _build_failure_patterns, _build_entity_summaries
  • MemoryExporterHook: on_session_end gating logic, exception swallowing, create_memory_exporter_hook factory

Test plan

Closes #227

🤖 Generated with Claude Code

acailic and others added 3 commits June 5, 2026 02:57
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: add unit tests for InsightBuilder and MemoryExporterHook (zero coverage)

1 participant