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
feat(whatsapp-session): run the session service in prod (#9066)
Wolf Mermelstein4efbd432ffd1
diff --git a/docs/architecture/whatsapp-linked-devices.md b/docs/architecture/whatsapp-linked-devices.mdindex ea962c5a06..04c0aafb88 100644--- a/docs/architecture/whatsapp-linked-devices.md+++ b/docs/architecture/whatsapp-linked-devices.md@@ -192,7 +192,10 @@ The web flag `enable-whatsapp-linked` is the only rollout gate; DSS alwaysserves `/external-chats` and `/whatsapp`. To stop all WhatsApp traffic (receiving and sending),scale the session service to zero tasks: accounts stay `connected`, history andaccess are kept, and sends recorded meanwhile expire unsent after ten minutes.-Replicas pick every account up again when scaled back.+Replicas pick every account up again when scaled back. Prod runs two replicas+and dev one (`infra/stacks/whatsapp-session-service/service.ts`); with two, a+deploy hands every lease to a running replica. A deploy restores the task+count. Prod deploys with each published release.## Mediadiff --git a/infra/stacks/whatsapp-session-service/AGENTS.md b/infra/stacks/whatsapp-session-service/AGENTS.mdindex 049d5a329e..e2df2555eb 100644--- a/infra/stacks/whatsapp-session-service/AGENTS.md+++ b/infra/stacks/whatsapp-session-service/AGENTS.md@@ -46,16 +46,18 @@ From `infra/`: `bun run check`, `bunx biome check stacks/whatsapp-session-servicdrops every application log.- No ECS container health check: the runtime image has no HTTP client. Areplica that loses its lock connection must exit non-zero so ECS replaces it.-- No autoscaling: replicas own accounts, so scaling in forces takeovers. Change- `desired_count` in `Pulumi.<stack>.yaml`.+- No autoscaling: replicas own accounts, so scaling in forces takeovers. The+ task count is `desiredCount` in `service.ts`: 2 in prod, so a deploy hands+ leases to a running replica instead of dropping them, and 1 in dev. Prod+ deploys with each published release (`release-production.yml` →+ `deploy_all_services.yml`, after the MacroDB migrations); dev on merge.- The KMS key only answers calls whose encryption context has`macro:purpose = whatsapp-session` (`crates/whatsapp_store_pg/src/kms.rs`).Changing that string strands every stored session.- Deploys need the `doppler-projects` stack applied first: `DopplerEcsEnvironment`reads `/doppler-sync/whatsapp-session-service/<stack>`, which its sync writes.-- To stop all WhatsApp traffic, set `desired_count: 0` (or scale the ECS- service to 0); see the service runbook. Prod ships at 0 until it is turned- on deliberately.+- To stop all WhatsApp traffic, scale the ECS service to 0 like any service;+ the next deploy restores the count in `service.ts`. See the service runbook.## Relateddiff --git a/infra/stacks/whatsapp-session-service/Pulumi.dev.yaml b/infra/stacks/whatsapp-session-service/Pulumi.dev.yamlindex cfb3863b2b..9b05ff524e 100644--- a/infra/stacks/whatsapp-session-service/Pulumi.dev.yaml+++ b/infra/stacks/whatsapp-session-service/Pulumi.dev.yaml@@ -2,4 +2,3 @@ config:aws-native:region: us-east-1aws:region: us-east-1whatsapp-session-service:session_kms_deletion_window_days: 7- whatsapp-session-service:desired_count: 2diff --git a/infra/stacks/whatsapp-session-service/Pulumi.prod.yaml b/infra/stacks/whatsapp-session-service/Pulumi.prod.yamlindex b0738c50ca..bf6475fb8c 100644--- a/infra/stacks/whatsapp-session-service/Pulumi.prod.yaml+++ b/infra/stacks/whatsapp-session-service/Pulumi.prod.yaml@@ -2,5 +2,3 @@ config:aws-native:region: us-east-1aws:region: us-east-1whatsapp-session-service:session_kms_deletion_window_days: 30- # Prod stays off until Wolf turns it on.- whatsapp-session-service:desired_count: 0diff --git a/infra/stacks/whatsapp-session-service/index.ts b/infra/stacks/whatsapp-session-service/index.tsindex bddcc867d3..5b01ad8ce8 100644--- a/infra/stacks/whatsapp-session-service/index.ts+++ b/infra/stacks/whatsapp-session-service/index.ts@@ -27,7 +27,6 @@ const service = new WhatsappSessionService(ecsClusterName: cloudStorageStack.getOutput('cloudStorageClusterName').apply((value) => value as string),- desiredCount: config.requireNumber('desired_count'),kmsDeletionWindowInDays: config.requireNumber('session_kms_deletion_window_days'),diff --git a/infra/stacks/whatsapp-session-service/service.ts b/infra/stacks/whatsapp-session-service/service.tsindex 62bab9670e..7a82b9ba78 100644--- a/infra/stacks/whatsapp-session-service/service.ts+++ b/infra/stacks/whatsapp-session-service/service.ts@@ -35,7 +35,6 @@ type WhatsappSessionServiceArgs = {};ecsClusterArn: pulumi.Input<string>;ecsClusterName: pulumi.Input<string>;- desiredCount: number;kmsDeletionWindowInDays: number;tags: { [key: string]: string };};@@ -240,7 +239,7 @@ export class WhatsappSessionService extends pulumi.ComponentResource {BASE_NAME,{cluster: args.ecsClusterArn,- desiredCount: args.desiredCount,+ desiredCount: stack === 'prod' ? 2 : 1,// Start the replacement before stopping the old task: the old task// drains and NOTIFYs `whatsapp_account_released` so a running replica// takes each account over at once.diff --git a/services/whatsapp_session_service/AGENTS.md b/services/whatsapp_session_service/AGENTS.mdindex 0535b9ab37..d51df2d1ad 100644--- a/services/whatsapp_session_service/AGENTS.md+++ b/services/whatsapp_session_service/AGENTS.md@@ -140,7 +140,9 @@ JIDs, phone numbers, QR codes or message text.- **Stop all WhatsApp traffic**: scale the ECS service to 0 tasks. Accountsstay `connected` and are picked up again when it scales back; sends recorded- meanwhile expire unsent after ten minutes. The web flag+ meanwhile expire unsent after ten minutes. A deploy restores the task+ count in `infra/stacks/whatsapp-session-service/service.ts` (2 in prod, 1 in+ dev). The web flag`enable-whatsapp-linked` only hides the UI; the API keeps answering.- **Stuck lease** (an account no replica runs, `accounts_unowned` > 0): findthe holder with `SELECT pid FROM pg_locks WHERE locktype = 'advisory' AND