"""Layer-1 readers over dialogue originals and derived records. No formulas.""" from __future__ import annotations from data_layer import register_reader from dialogue_store import latest_derived, list_messages def _conversation_messages(*, profile_id: str, context: dict): conversation_id = context.get("conversation_id") if not conversation_id: raise KeyError("conversation_id") return list_messages(profile_id, conversation_id) def _latest_derived(*, profile_id: str, context: dict): return latest_derived( profile_id, context.get("subject_type") or "", context.get("subject_id") or "", context.get("kind") or "", ) register_reader("conversation_messages", _conversation_messages) register_reader("latest_derived", _latest_derived)