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
fix(soup): gate domain helpers on the feature their callers compile under (#8748)
gbirmand12318209340
diff --git a/.github/workflows/code_check_cloud_storage.yml b/.github/workflows/code_check_cloud_storage.ymlindex 987e47db8f..a297fa1797 100644--- a/.github/workflows/code_check_cloud_storage.yml+++ b/.github/workflows/code_check_cloud_storage.yml@@ -307,9 +307,18 @@ jobs:-A clippy::collapsible_if}+ # Most of soup's dependents build it without `outbound` (no features, or+ # `ports` alone), where helpers only the service or the Postgres repository+ # call are dead code that --all-features hides.+ clippy_soup_without_outbound() {+ cargo clippy -p soup --no-default-features+ cargo clippy -p soup --no-default-features --features ports+ }+if [ -z "$packages" ] || [ "$packages" = "all" ]; thencargo clippy --workspace --all-features --exclude sync_serviceclippy_sync_service+ clippy_soup_without_outboundexit 0fi@@ -319,6 +328,7 @@ jobs:fisync=false+ soup=falsepkg_args=()for p in $packages; doif [ "$p" = "sync_service" ]; then@@ -326,6 +336,9 @@ jobs:elsepkg_args+=(-p "$p")fi+ if [ "$p" = "soup" ]; then+ soup=true+ fidoneif [ "${#pkg_args[@]}" -gt 0 ]; then@@ -335,6 +348,10 @@ jobs:if [ "$sync" = true ]; thenclippy_sync_servicefi++ if [ "$soup" = true ]; then+ clippy_soup_without_outbound+ fienv:RUST_PACKAGES: ${{ needs.path-check.outputs.rust_packages }}- name: show sccache statsdiff --git a/crates/soup/AGENTS.md b/crates/soup/AGENTS.mdindex 7d1027179b..8c94052775 100644--- a/crates/soup/AGENTS.md+++ b/crates/soup/AGENTS.md@@ -59,6 +59,10 @@ rows, initiatives, ...) and get back a single unified, paginated result.- `cargo test -p soup --features outbound` (`SQLX_OFFLINE` unset; needs localMacroDB). Without the feature the Postgres repo and its tests don't compile.- After schema/query changes: `nix develop --command just prepare_db` (see `justfile`).+- `cargo clippy -p soup --no-default-features`, and again with `--features ports`+ (both run in `just clippy` and CI): most dependents build soup without+ `outbound`. Gate a domain helper on the feature its callers compile under:+ `ports` for `domain/service`, `outbound` for the Postgres repository.## Gotchasdiff --git a/crates/soup/src/domain/models.rs b/crates/soup/src/domain/models.rsindex b26fed6336..a50d850c02 100644--- a/crates/soup/src/domain/models.rs+++ b/crates/soup/src/domain/models.rs@@ -1,51 +1,63 @@+#[cfg(feature = "ports")]pub(crate) mod contact_listing;pub mod grouping;+#[cfg(feature = "ports")]mod exclusions;-#[cfg(test)]+#[cfg(all(test, feature = "ports"))]mod test;-use call::domain::models::GetCallRecordsRequest;-use channels::domain::models::{GetChannelsRequest, GetThreadReplyRowsRequest};use crm::domain::auth::CrmTeamReceipt;use crm::domain::companies_repo::{CrmCompanyListSort, CrmCompanySoupCursor};-use email::domain::models::{GetEmailsRequest, PreviewView};-use entity_access::domain::models::{EntityAccessReceipt, MemberTeamRole};-use filter_ast::Expr;-use foreign_entity::domain::{models::SourceId, ports::ForeignEntityListQuery};+use email::domain::models::PreviewView;+use entity_access::domain::models::MemberTeamRole;+use foreign_entity::domain::models::SourceId;use frecency::domain::models::{AggregateFrecency, FrecencyQueryErr};use github_pull_requests::domain::models::GithubPullRequestError;use item_filters::{EntityFilters,- ast::{- EntityFilterAst, ExpandErr, LiteralTree,- calendar_event::CalendarEventLiteral,- call::CallLiteral,- crm_company::CrmCompanyLiteral,- email::EmailLiteral,- github_pull_request::GithubPullRequestLiteral,- properties::{- PropertiesLiteral, PropertyEntityType, properties_filter_can_apply_to,- properties_filter_matches_propertyless,- },- },+ ast::{EntityFilterAst, ExpandErr},};use macro_user_id::user_id::MacroUserIdStr;use model_entity::{Entity, EntityType};use models_grouping::GroupingConfig;use models_pagination::{- Cursor, CursorWithValAndFilter, Frecency, NotifiedAt, Query, SimpleSortMethod, TouchedByMe,+ CursorWithValAndFilter, Frecency, NotifiedAt, Query, SimpleSortMethod, TouchedByMe,};use models_soup::SoupProperty;use models_soup::item::SoupItem;use non_empty::IsEmpty;-use recursion::CollapsibleExt;use serde::{Deserialize, Serialize};-use std::sync::Arc;use thiserror::Error;use uuid::Uuid;+// Only the service's sub-request builders below use these.+#[cfg(feature = "ports")]+use {+ call::domain::models::GetCallRecordsRequest,+ channels::domain::models::{GetChannelsRequest, GetThreadReplyRowsRequest},+ email::domain::models::GetEmailsRequest,+ entity_access::domain::models::EntityAccessReceipt,+ filter_ast::Expr,+ foreign_entity::domain::ports::ForeignEntityListQuery,+ item_filters::ast::{+ LiteralTree,+ calendar_event::CalendarEventLiteral,+ call::CallLiteral,+ crm_company::CrmCompanyLiteral,+ email::EmailLiteral,+ github_pull_request::GithubPullRequestLiteral,+ properties::{+ PropertiesLiteral, PropertyEntityType, properties_filter_can_apply_to,+ properties_filter_matches_propertyless,+ },+ },+ models_pagination::Cursor,+ recursion::CollapsibleExt,+ std::sync::Arc,+};+/// Direction the merged Soup page is ordered in.////// Deliberately Soup's own type rather than one borrowed from the paginator:@@ -70,6 +82,14 @@ pub enum SoupType {}/// the parameters required for a [SimpleSortMethod]+#[cfg(feature = "ports")]+#[cfg_attr(+ not(any(feature = "outbound", test)),+ expect(+ dead_code,+ reason = "only the outbound Postgres repository and tests read it"+ )+)]#[derive(Debug, Clone)]pub struct SimpleSortRequest<'a> {/// the limit of the number of items to return@@ -93,6 +113,14 @@ pub struct GroupedSortRequest<'a> {pub grouping: GroupingConfig,}+#[cfg(feature = "ports")]+#[cfg_attr(+ not(any(feature = "outbound", test)),+ expect(+ dead_code,+ reason = "only the outbound Postgres repository and tests read it"+ )+)]#[derive(Debug, Clone)]pub(crate) enum SimpleSortQuery {/// we dont have anything to filter out@@ -105,6 +133,7 @@ pub(crate) enum SimpleSortQuery {ItemsAndFrecencyFilter(Query<Uuid, SimpleSortMethod, (Frecency, EntityFilterAst)>),}+#[cfg(feature = "ports")]impl SimpleSortQuery {pub(crate) fn from_entity_cursor(cursor: Query<Uuid, SimpleSortMethod, Option<EntityFilterAst>>,@@ -138,6 +167,7 @@ impl SimpleSortQuery {}}+#[cfg(any(feature = "outbound", all(test, feature = "ports")))]impl SimpleSortQuery {pub(crate) fn sort_method(&self) -> &SimpleSortMethod {match self {@@ -402,6 +432,7 @@ impl IntoSoupReqAst for SoupRequest<EntityFilterAst> {}}+#[cfg(feature = "ports")]impl<T> SoupRequest<T> {/// returns a reference to the filters to pass to the paginator/// this is used to prevent passing back the full ast on each server request@@ -410,6 +441,7 @@ impl<T> SoupRequest<T> {}}+#[cfg(feature = "ports")]impl SoupRequest<Option<EntityFilterAst>> {/// take the parts of the [SoupRequest] that are only relevant to email/// and move them into a [GetEmailsRequest] if it is possible to create one.@@ -1028,6 +1060,7 @@ pub struct WorkFeedSoupPage {/// (status, time bounds, attendee, organizer) live in the calendar leg's/// query builder, which the candidate query cannot reach. Rejecting up front/// beats silently returning a feed with those events unfiltered.+#[cfg(feature = "ports")]pub(crate) fn calendar_filter_supported_by_notified(tree: Option<&Expr<CalendarEventLiteral>>,) -> bool {@@ -1046,6 +1079,7 @@ pub(crate) fn calendar_filter_supported_by_notified(/// ANDs a properties filter into the email filter tree as thread-level/// [EmailLiteral::Property] conditions, so the email query returns exactly/// the threads that satisfy it.+#[cfg(feature = "ports")]fn with_properties_filter(tree: Option<Arc<Expr<EmailLiteral>>>,properties_filter: Option<&Expr<PropertiesLiteral>>,@@ -1060,6 +1094,7 @@ fn with_properties_filter(}))}+#[cfg(feature = "ports")]fn map_properties_to_email(expr: &Expr<PropertiesLiteral>) -> Expr<EmailLiteral> {match expr {Expr::And(a, b) => Expr::and(map_properties_to_email(a), map_properties_to_email(b)),@@ -1072,6 +1107,7 @@ fn map_properties_to_email(expr: &Expr<PropertiesLiteral>) -> Expr<EmailLiteral>/// ANDs a properties filter (mapped to [CallLiteral::Property] conditions) into/// the call filter tree, so the call query returns exactly the calls that also/// satisfy the tag filter.+#[cfg(feature = "ports")]fn with_call_properties_filter(tree: Option<Arc<Expr<CallLiteral>>>,properties_filter: Option<&Expr<PropertiesLiteral>>,@@ -1086,6 +1122,7 @@ fn with_call_properties_filter(}))}+#[cfg(feature = "ports")]fn map_properties_to_call(expr: &Expr<PropertiesLiteral>) -> Expr<CallLiteral> {match expr {Expr::And(a, b) => Expr::and(map_properties_to_call(a), map_properties_to_call(b)),@@ -1132,6 +1169,7 @@ pub struct GetCrmCompaniesRequest {/// Outcome of walking a `CrmCompanyLiteral` AST: the ids and the/// optional `hidden` constraint pulled out of the tree.+#[cfg(feature = "ports")]#[derive(Debug, Default)]pub(crate) struct CrmCompanyFilterExtract {pub ids: Vec<Uuid>,@@ -1145,6 +1183,7 @@ pub(crate) struct CrmCompanyFilterExtract {/// - two `Hidden(_)` literals conflict (e.g. `Hidden(true) AND Hidden(false)`),/// - an `Or(_, _)` branch mixes ids and a hidden literal (would change/// set semantics in ways the simple extractor can't represent).+#[cfg(feature = "ports")]fn extract_crm_company_filter(expr: &Expr<CrmCompanyLiteral>,out: &mut CrmCompanyFilterExtract,@@ -1175,6 +1214,7 @@ fn extract_crm_company_filter(/// Helper for [`extract_crm_company_filter`]: an `Or` branch must be a/// pure id sub-tree (nested `Or` of `Id` literals) — any `Hidden`, `And`,/// or `Not` inside fails closed.+#[cfg(feature = "ports")]fn or_is_ids_only(expr: &Expr<CrmCompanyLiteral>, out: &mut CrmCompanyFilterExtract) -> bool {match expr {Expr::Literal(CrmCompanyLiteral::Id(id)) => {diff --git a/tooling/just/rust.just b/tooling/just/rust.justindex 3be13c0fd4..096c35147c 100644--- a/tooling/just/rust.just+++ b/tooling/just/rust.just@@ -9,6 +9,8 @@ rust-check:clippy:RUSTFLAGS="-Dwarnings -Dclippy::disallowed_methods" RUSTDOCFLAGS=-Dwarnings CARGO_TERM_COLOR=always SQLX_OFFLINE=true cargo clippy --workspace --all-features --exclude sync_serviceRUSTFLAGS="-Dwarnings -Dclippy::disallowed_methods" RUSTDOCFLAGS=-Dwarnings CARGO_TERM_COLOR=always SQLX_OFFLINE=true cargo clippy -p sync_service -- -A clippy::unnecessary_map_or -A clippy::collapsible_if+ RUSTFLAGS="-Dwarnings -Dclippy::disallowed_methods" RUSTDOCFLAGS=-Dwarnings CARGO_TERM_COLOR=always SQLX_OFFLINE=true cargo clippy -p soup --no-default-features+ RUSTFLAGS="-Dwarnings -Dclippy::disallowed_methods" RUSTDOCFLAGS=-Dwarnings CARGO_TERM_COLOR=always SQLX_OFFLINE=true cargo clippy -p soup --no-default-features --features ports# This can be used in any crate that uses macrodb under the hood[no-cd]diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage/test.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage/test.rsindex 8c709472c3..5517319f72 100644--- a/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage/test.rs+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage/test.rs@@ -113,6 +113,20 @@ fn tests_continue_to_exclude_sync_service() {);}+/// --all-features hides soup helpers that only the service or the Postgres+/// repository call; most dependents build soup without `outbound`.+#[test]+fn clippy_lints_soup_without_outbound_whenever_soup_is_linted() {+ let script = include_str!("../scripts/cargo_clippy.sh");+ assert!(script.contains("cargo clippy -p soup --no-default-features\n"));+ assert!(script.contains("cargo clippy -p soup --no-default-features --features ports"));+ let calls = script.matches("\n clippy_soup_without_outbound\n").count();+ assert_eq!(+ calls, 2,+ "both the full run and a targeted soup run lint it: {script}"+ );+}+/// The `if … fi` block starting at `marker` in the filter script.fn filter_script_block(marker: &str) -> &'static str {let script = include_str!("../scripts/compute_nextest_filter.sh");diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/cargo_clippy.sh b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/cargo_clippy.shindex aed182e108..8e5da49888 100644--- a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/cargo_clippy.sh+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/cargo_clippy.sh@@ -12,9 +12,18 @@ clippy_sync_service() {-A clippy::collapsible_if}+# Most of soup's dependents build it without `outbound` (no features, or+# `ports` alone), where helpers only the service or the Postgres repository+# call are dead code that --all-features hides.+clippy_soup_without_outbound() {+ cargo clippy -p soup --no-default-features+ cargo clippy -p soup --no-default-features --features ports+}+if [ -z "$packages" ] || [ "$packages" = "all" ]; thencargo clippy --workspace --all-features --exclude sync_serviceclippy_sync_service+ clippy_soup_without_outboundexit 0fi@@ -24,6 +33,7 @@ if [ "$packages" = "none" ]; thenfisync=false+soup=falsepkg_args=()for p in $packages; doif [ "$p" = "sync_service" ]; then@@ -31,6 +41,9 @@ for p in $packages; doelsepkg_args+=(-p "$p")fi+ if [ "$p" = "soup" ]; then+ soup=true+ fidoneif [ "${#pkg_args[@]}" -gt 0 ]; then@@ -40,3 +53,7 @@ fiif [ "$sync" = true ]; thenclippy_sync_servicefi++if [ "$soup" = true ]; then+ clippy_soup_without_outbound+fi