You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor: move generate_from_raw hook firing into Backend base class #1183
PR #1181 (Phase 1 of #444) introduces the generation_batch_{pre_call,post_call,error} hooks for raw-path coverage. The chat path was simultaneously cleaned up: Backend.generate_from_chat_context is now a base-class wrapper that fires hooks and calls an abstract _generate_from_chat_context_impl per backend.
The raw path was not given the same treatment. Hook-firing logic is duplicated inline across all 5 backends' generate_from_raw implementations:
Each one redoes UUID generation, pre_call firing, try/except for error firing, latency timing, and post_call firing.
Why this matters
Beyond the duplication: the duplication blocks unit tests of the firing sites. _MockBackend.generate_from_raw would have to reimplement the production firing logic verbatim, making any test of "do the hooks fire correctly" tautological. Today's test/plugins/test_hook_call_sites.py covers chat firing because the base class owns it — raw firing has no equivalent coverage.
Scope
Mirror the chat-path fix:
Backend.generate_from_raw becomes a concrete base method that fires the three batch hooks.
Add an abstract _generate_from_raw_impl that each backend overrides.
Strip the inline hook-firing blocks from all 5 backend implementations.
Add base-class firing-site tests using a _MockBackend that overrides _generate_from_raw_impl only.
Acceptance criteria
No HookType.GENERATION_BATCH_* references remain in any mellea/backends/*.py file.
Backend.generate_from_raw fires all three batch hooks; backends only implement _generate_from_raw_impl.
Firing-site tests cover all three batch hooks against a mock backend.
All five backend implementations pass existing tests unchanged.
Activity
refactor(backends): move generate_from_raw hook firing into Backend b…
refactor(backends): move generate_from_raw hook firing into Backend b…