Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

4.5 KB
Raw Blame
#![deny(missing_docs)]
//! Defines all topics for kafka.
//! This file is also programmatically grabbed in infra to ensure all kafka topics are created.

#[cfg(test)]
mod test;

use sealed::sealed;

/// Errors that can occur for a Topic
#[derive(Debug, thiserror::Error)]
pub enum TopicError {
    /// The Kafka topic name is not known to this broker crate.
    #[error("unknown event topic: {0}")]
    UnknownTopic(String),
}

/// A Topic is mapped to a Kafka topic that events can be published to.
#[sealed]
pub trait Topic: Copy + Send + Sync + 'static {
    /// the statically known string name of this topic
    const TOPIC_STR: &'static str;
}

/// Defines each topic struct with its `Topic` impl, plus [`all_topic_names`]
/// so every declared topic is automatically included in the registry.
macro_rules! topics {
    ($($(#[$meta:meta])* $name:ident => $topic:literal),* $(,)?) => {
        $(
            $(#[$meta])*
            #[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Hash)]
            pub struct $name;

            #[sealed]
            impl Topic for $name {
                const TOPIC_STR: &'static str = $topic;
            }
        )*

        /// The names of all Kafka topics defined in this crate.
        pub fn all_topic_names() -> &'static [&'static str] {
            &[$($name::TOPIC_STR),*]
        }
    };
}

topics! {
    /// Example kafka topic.
    MacroExampleTopic => "macro.example",
    /// Bot lifecycle events (created / updated / deleted).
    MacroBotsTopic => "macro.bots",
    /// Call lifecycle and recording events.
    MacroCallsTopic => "macro.calls",
    /// Public call notifications for webhooks and event streams.
    MacroCallNotificationsTopic => "macro.call_notifications",
    /// Document lifecycle events (created / updated / deleted / copied).
    MacroDocumentsTopic => "macro.documents",
    /// Committed GitHub pull request updates.
    MacroGithubPullRequestsTopic => "macro.github_pull_requests",
    /// Every delivery the GitHub App verified, whatever its event.
    MacroGithubWebhooksTopic => "macro.github_webhooks",
    /// User-scoped full Soup items produced from entity updates.
    MacroSoupRealtimeTopic => "macro.soup",
    /// Project lifecycle events (created, updated, deleted, restored, permanently deleted, and uploaded).
    MacroProjectsTopic => "macro.projects",
    /// Initiative lifecycle and task membership changes.
    MacroInitiativesTopic => "macro.initiatives",
    /// Property definition, option, and entity property value mutation events.
    MacroPropertiesTopic => "macro.properties",
    /// Team lifecycle, invite, and membership events.
    MacroTeamsTopic => "macro.teams",
    /// Channel lifecycle, message, participant, and attachment events.
    MacroChannelsTopic => "macro.channels",
    /// Shared channel and document message events.
    MacroMessagesTopic => "macro.messages",
    /// Signals telling the agent harness to open or feed an agent session.
    MacroAgentSessionsTopic => "macro.agent_sessions",
    /// Email lifecycle events (links, messages, threads, labels).
    MacroEmailTopic => "macro.email",
    /// Webhook configuration lifecycle events (created / updated / deleted / validated).
    MacroWebhooksTopic => "macro.webhooks",
    /// Entity mention events (created / deleted) across channels and docs.
    MacroMentionsTopic => "macro.mentions",
    /// Notifications awaiting delivery through WebSocket connections.
    MacroNotificationsTopic => "macro.notifications",
    /// Recorded activity rows awaiting delivery to realtime subscribers.
    MacroActivityTopic => "macro.activity",
    /// AI chat lifecycle and message events.
    MacroChatsTopic => "macro.chats",
    /// Calendar event changes, from provider sync and user mutations alike.
    MacroCalendarTopic => "macro.calendar",
    /// Agent session lifecycle facts: opened, turns, waiting for input, settled, stopped, renamed, deleted.
    MacroAgentSessionLifecycleTopic => "macro.agent_session_lifecycle",
    /// Retired: runs of appended agent session log frames now travel over a
    /// Redis Stream (`agent_session_realtime::outbound::redis_stream`). Kept
    /// declared until every harness task publishing here has been replaced;
    /// remove it, and its cluster topic, after that rollout.
    MacroAgentSessionLogTopic => "macro.agent_session_log",
    /// Database lifecycle (created, renamed, trashed, restored, purged) and table-change events.
    MacroDatabasesTopic => "macro.databases",
    /// Form lifecycle (created, renamed, trashed, restored, purged), sharing and response events.
    MacroFormsTopic => "macro.forms",
}