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
databases_sql
What it is
Part of the Databases feature: runs the database_sql engine over Macro
databases for agents and authenticated HTTP clients, alongside the browser's direct
database_sql wasm usage. Reads go through Soup and contacts, writes go
through databases' typed ops.
Start here
src/inbound/axum_router.rs:POST /databases/query, delegating to the same SQL service.src/lib.rs: module list and public re-exports (DatabasesSql,SqlRequest,SqlOutcome).src/service.rs: the entry point — runs a parsed statement's engineRequests againstrow_source/ops_sinkand returns aSqlOutcome.src/row_source.rs/src/ops_sink.rs: the two adapters that plug this crate's Soup/contacts/databases access into thedatabase_sqlengine's genericRowSource/write traits.src/toolset.rs+src/toolset/*.md: theQueryDatabaseandSaveDatabaseQueryagent tools; the.mdfiles are the tool descriptions sent to the model.src/view_only.rs: a read-only variant of access, used where writes must be refused.
Scope
- Owns: binding the
database_sqlengine to live Macro data for agents, the HTTP query adapter, and the two SQL agent tools. - Not here: the SQL grammar/engine itself →
crates/database_sql; table/row persistence and the ops API →crates/databases.
Boundaries
- Depends on:
database_sql(engine),databases(ops/storage,portsonly),soup,contacts,entity_access(allports-only — this crate is an adapter, not a composition root). - Used by:
crates/ai_tools(wires theai_toolsfeature'sQueryDatabase/SaveDatabaseQueryinto the agent toolset), and DSS (HTTP query composition).
Recipes
- Change what a SQL read/write can see or do:
src/row_source.rsorsrc/ops_sink.rs→src/service.rs. - Edit a tool's behavior or its description:
src/toolset/query_database.rs/query_database_writes.mdorsrc/toolset/save_database_query.rs→src/toolset/sql_guide.mdif the shared SQL guidance text changes.
Checks
cargo test -p databases_sql --features ai_tools,inbound.
Gotchas
This crate only depends on
portsfeatures of its domain crates — it must not importdatabases' orsoup'soutboundadapters directly; the composition root supplies those.HTTP SQL reads use the viewer catalog; writes mint edit receipts and forward version guards into atomic ops. Never retry a statement automatically.
Related
- Skill:
database-core· Rules:.agents/rules/rust/architecture.md