Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
item_filters
What it is
Belongs to Search (Soup): typed filter DTOs for every entity type searchable in soup/search, plus the AST layer that expands them into a strict, logically-combinable query form.
Start here
src/lib.rs: the public filter structs (DocumentFilters,EmailFilters,ChannelFilters,CallFilters,EntityFilters, ...) — one per entity type, bundled together inEntityFilters.src/ast.rs+src/ast/<entity>.rs: typed AST literals each filter struct expands into, viaExpandFrame/Exprfromfilter_ast, for consumers that need a logical (AND/OR/NOT) representation instead of a flat DTO.src/ast/tests.rs: expansion test coverage per entity type.
Scope
- Owns: the filter DTO shape for every soup entity type, their
IsEmptysemantics (an empty filter must impose no constraint), and the AST expansion used to turn a filter into a query. - Not here: the
fef:filter-query-language parser (filter_ast), applying filters to a search backend (OpenSearch/Postgres), or authorization checks on filter values (e.g. CRM domain/address ownership) — those live in the service that calls in (e.g.email,crm).
Boundaries
- Depends on:
filter_ast,document_sub_type,notification_state,model_file_type,model_owner,macro_user_id. - Used by: crates building soup/search queries (
graphql_soup,database_sql/databases_sql,email,channels,crm,call,github_pull_requests,ai_tools,search_service,item_filter_index); a new field here needs eachIsEmptyimpl updated or filters silently stop being "no-ops" when empty.
Recipes
- Add a filter field to an existing entity (e.g.
EmailFilters): add the field insrc/lib.rs→ update that struct'sIsEmptyimpl (the destructure forces you not to forget it) → add/extend the matching AST literal insrc/ast/<entity>.rs→ extendsrc/ast/tests.rs. - Add a new filterable entity type: new struct +
IsEmptyimpl insrc/lib.rs→ newsrc/ast/<entity>.rsmodule declared insrc/ast.rs→ field onEntityFilters→ the caller's expansion code.
Checks
cargo test -p item_filters(SQLX_OFFLINEunset).
Gotchas
CRM associations serialize company/contact IDs or the unit string
activity. The CRM service resolves activity scope; clients do not enumerate record IDs.Several entity types (initiatives, agent sessions) are opt-in:
include: falseby default, and asking for specific ids/owners (or, for initiatives, notification states) also implicitly opts in — don't assume an emptyincludeflag means "show everything".#![deny(missing_docs)]: every new public field needs a doc comment.Represent DATE presence as
DateRangewith both bounds open and absence as its negation;startis inclusive andendexclusive.Export filter intervals as
PropertyDateFilterRangein schemas to distinguish half-open optional bounds from stored, inclusivemodels_properties::DateRangevalues.Keep DATE evaluation in Soup/OpenSearch; call, email, and frecency treat date literals as false and preserve ordinary boolean negation.
Related
- Rules:
.agents/rules/rust/code.md(CS-54 missing-docs)