Skip to content

Synthesize per-topic events from event instances with stream-parity tests#779

Open
Kane610 wants to merge 8 commits intomasterfrom
feat/event-instance-topic-parity
Open

Synthesize per-topic events from event instances with stream-parity tests#779
Kane610 wants to merge 8 commits intomasterfrom
feat/event-instance-topic-parity

Conversation

@Kane610
Copy link
Copy Markdown
Owner

@Kane610 Kane610 commented May 1, 2026

Summary

This PR executes the event-instance parity plan by introducing a synthesis path that converts event instance metadata into initialized Event objects grouped per topic.

The goal is to make event-instance-derived events content-equivalent to stream-derived events on:

  • topic
  • source
  • id
  • state
  • group

Operation parity is intentionally excluded; synthesized events are initialized by design.

What Changed

1) Model synthesis primitives

  • Added Event.synthesize_initialized(...) in axis/models/event.py.
  • Added TOPIC_TO_INACTIVE_STATE mapping to normalize inactive defaults for topics with non-numeric states.
  • Added event-instance normalization helpers and EventInstance.to_events() in axis/models/event_instance.py:
    • source extraction (including list values expansion)
    • representative data-value extraction (prefers active where present)
    • conversion to initialized Event objects
  • Hardened EventInstance.decode() against missing MessageInstance.

2) Interface/lifecycle wiring

  • Added EventInstanceHandler.get_events_per_topic() in axis/interfaces/event_instances.py.
  • Extended Vapix.initialize_event_instances() to populate
    vapix.event_instance_events: dict[str, list[Event]] in axis/interfaces/vapix.py.

3) Verification tests

  • Added parity tests in tests/test_event_instances.py that compare synthesized vs stream events for overlapping topics (PIR, Light Status, VMD4 profile) using the agreed parity fields.
  • Added coverage that synthesized output includes unknown/non-enum topics.
  • Extended tests/test_vapix.py to verify initialize_event_instances() populates synthesized per-topic events.

Commit Breakdown

  1. 7e879e9 Add event-instance to initialized-event synthesis primitives
  2. d634b33 Expose synthesized per-topic events from event instances
  3. fb5b355 Add parity tests for synthesized event-instance events

Validation

  • Targeted tests:
    • uv run pytest tests/test_event_instances.py tests/test_vapix.py -v
  • Pre-commit hooks ran successfully on each commit:
    • ruff check
    • ruff format
    • mypy

Notes

  • This PR does not change stream-event behavior in EventManager.
  • This PR does not merge anything; review is requested first.

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.

1 participant