Skip to main content

emit

Function emit 

Source
pub fn emit(envelope: SessionEventEnvelope)
Expand description

Publish an envelope AND emit it on stderr with the __OMPM_EVENT__ prefix so a parent process can re-broadcast on its own bus.

Why: Workflow runs spawn as tcode --workflow ... subprocesses of the API server (api/server.rs::run_task). Events emitted inside that child reach the parent’s bus only via the existing stderr stream. This helper does both in one call so emit sites don’t have to know whether they’re running as a child. What: Calls publish(envelope.clone()) for in-process subscribers, then writes one NDJSON line to stderr prefixed with __OMPM_EVENT__ . The parent’s stderr reader (in api::server::run_task) detects the prefix and re-publishes on its own bus. Test: events_tests::sm_harness_doc_documents_the_prefix_tcode_emits covers the wire line via format_event_line; the stderr write itself is exercised by the workflow integration path.