Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
description: "Use the workspace's standard Rust crates and their house idioms instead of hand-rolling or adding alternatives." paths: - "crates//*.rs" - "services//.rs" - "tooling/**/.rs" - "/Cargo.toml" globs: "crates//.rs,services/**/.rs,tooling//*.rs,/Cargo.toml" alwaysApply: false
Rust libraries
Reach for these before writing a helper or adding a dependency. Infrastructure
crates (macro_config, macro_entrypoint, macro_service_urls, kafka_util,
sqs_worker, macro_cors, macro_tower_layers, macro_auth,
macro_authorization) are covered by the config and observability rules; use
them instead of their generic equivalents.
- CS-56 Error types:
thiserrorenums for every public error (domain and adapters), with caller-meaningful variants plusInternal(rootcause::Report). Ports exposetype Err: std::error::Error + Send + Sync + 'static; services map adapter errors withrootcause::Report::new(e).into_dynamic(). Binaries returnResult<(), rootcause::Report>. Never addanyhowto a crate that doesn't use it (CS-46). Model:crates/user_api_key. - CS-57 No panics outside tests and startup: no
.unwrap(),.expect(),unreachable!,panic!,todo!, or unchecked indexing on a path a request, tool call, or message can reach. Return a typed error the caller can show instead, even for an "impossible" state. Never recover from a panic withcatch_unwindor aJoinError; fix the code that panics. NoBox<dyn Error>orResult<_, String>either. - CS-58 Parse structured text with
nom(andlogosfor tokenizing a real grammar, ascrates/database_sqldoes), not hand-rolledsplit_once/strip_prefix/ index scanners. - CS-59 Enum string forms (CS-11) use
strumderives (EnumString,Display,AsRefStr,IntoStaticStr,EnumIter) withserialize_allmatching serde'srename_all, imported fromstrum, notstrum_macros. Serde: API DTOs arecamelCase; new enums are internally tagged (tag = "...");untaggedonly for backward-compatible input. HTTP schemas areutoipa::ToSchema; AI-tool schemas areschemars::JsonSchema. - CS-60 Async traits are native:
fn x(&self) -> impl Future<Output = ...> + Send. Use#[async_trait]only when the trait must be object-safe (Arc<dyn Port>), and say so in a comment. - CS-61 Concurrency uses tokio:
mpsc/oneshot/watch/broadcast/Notify.std::sync::Mutexwhen no.awaithappens under the guard,tokio::sync::Mutexonly across awaits. Every spawned background loop takes aCancellationTokenand is tracked by aTaskTracker. - CS-62 Outbound HTTP: build one
reqwest::Clientwith a timeout in the adapter's constructor and keep it; take the base URL frommacro_service_urls; callmacro_tower_layers::inject_trace_headerson every request. NeverClient::new()per call or.unwrap()the builder. - CS-63 Time is
chrono(DateTime<Utc>);timeonly where a dependency's API requires it. New ids areUuid::now_v7()or a newtype'sgenerate()(CS-01, CS-10), nevernew_v4. - CS-64 Statics use
std::sync::LazyLock/OnceLock; literal regexes uselazy_regex::regex!, others aLazyLock<Regex>. Never addlazy_staticoronce_cell, and never compile a regex per call. - CS-65 Domain-service tests use hand-written fakes implementing the port;
mockallonly for narrow interaction assertions. DB tests use#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]; HTTP doubles usewiremock; transcript and replay output usesinsta. - CS-66 Never wait for a condition by polling: no
yield_noworsleeploops. Signal withoneshot,Notify,watch,Barrier, or a channel, and use#[tokio::test(start_paused = true)]for time. - CS-67 Dependencies come from root
[workspace.dependencies]asx = { workspace = true }; after anyCargo.tomlchange runjust hakariand commitcrates/workspace-hack. Check the workspace list before adding a crate, and don't add one that duplicates an existing choice.