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
ai_projections
What it is
Part of AI: materialized, cached AI-generated views of a user's data (for example a dashboard widget), keyed by a frontend-defined id and regenerated on demand or when cold.
Start here
src/lib.rsdoc comment: the full lifecycle — upsert-and-read onPOST /ai-projections, async vs.await: truematerialization,prompt_hashversioning, push via connection gateway.- Reads recover abandoned loading instances as cold when their processing claim is missing or expired; active claims and retained results stay intact; queued refreshing instances need no processing claim. The persistence adapter shares one processing lease for recovery and claim replacement. Recovery locks the instance before checking its claim in a fresh statement snapshot.
src/domain/ai_projection_service.rs: the upsert/read/invalidate logic.src/domain/projection_generator.rs: the generation port.src/outbound/agent_generator.rs: the agent-backed generator (behind theagentfeature) — two-phase whenoutput_schemais set (tool-enabled agent gathers context, then a structured completion distills it).src/worker.rs: the SQS-polling worker that drainsai_projection_queue.
Scope
- Owns: projection definitions, per-user cached instances, generation orchestration (inline or queued), and push notification on completion.
- Not here: the agent turn loop itself →
agent; tool definitions →ai_tools/ai_toolset.
Boundaries
- Depends on:
models_ai_projection, and (behindagent)ai_tools,ai_toolset,agent,ai_usage. - Used by:
document_cognition_service(inbound/outbound/agent) andai_projections_refresh_handler(the scheduled refresh lambda).
Recipes
- Add a projection type: define its prompt/schema at the frontend-defined
id →
src/domain/model.rsif a new output shape →src/outbound/agent_generator.rsif it needs the two-phase schema path.
Checks
cargo test -p ai_projections(SQLX_OFFLINEunset).
Related
- Rules:
.agents/rules/rust/architecture.md