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
rate_limit
What it is
Part of shared infrastructure. Generic rate limiting: a hashed-key sliding-window counter, checked and rolled back atomically via Redis.
Start here
src/domain/ports.rs:RateLimitPort(atomic check/decrement) andRateLimitService(ticket-returningcheck_rate_limit+rollback_ticket) — read these before the implementation.src/outbound/redis.rs: the Redis-backed adapter.src/domain/models.rs:RateLimitKey/RateLimitKeyBuilder— callers build the key from whatever data should be rate-limited; the crate never interprets it.
Scope
- Owns: the check/decrement/ticket protocol and its Redis implementation.
- Not here: what gets rate-limited or at what threshold — that's each
caller's
RateLimitConfigand key construction.
Boundaries
- Used by:
dictation,contacts,webhook,call,notification,referral,gtm_invite,services/document_storage_service,services/notification_service,services/contacts_service,services/authentication_service.
Recipes
- Rate-limit a new action: build a
RateLimitKeywithRateLimitKeyBuilder→ callcheck_rate_limitbefore the action →rollback_ticketif the action then fails.
Checks
cargo test -p rate_limit(SQLX_OFFLINEunset).cargo test -p rate_limit --features testingto exercise the testing-only constructors insrc/domain/models.rs.
Related
- Rules:
.agents/rules/rust/architecture.md